Unverified Commit 8be5a3c2 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

[turbopack] Fix CSS HMR on Safari (#92123)

Fixes #91818

**Regression source:** Commit `b7e4c6a0` ("Turbopack: transpile
CHUNK_SUFFIX") introduced `getChunkSuffixFromScriptSrc()` which reads
query strings from `<script>` tags. On Safari, this picks up the `?ts=`
param injected by the server-side cache-busting workaround in
`render.tsx` (for [WebKit
#187726](https://bugs.webkit.org/show_bug.cgi?id=187726)), baking it
into `ASSET_SUFFIX`. This causes HMR CSS URLs to match the preloaded URL
exactly, re-triggering the Safari preload cache bug and preventing style
updates.

**Changes:**

- **`dev-backend-dom.ts`**: Match existing `<link>` elements by base
path (strip query string) so selectors work across HMR updates with
different `?ts=` values. Add Safari to the Firefox cache-busting branch
so new stylesheet links always get a fresh `?ts=`.
- **`hmr-client.ts`**: Fix `mergeChunkUpdates` so a `total` update
always supersedes any prior update type.
parent 9b66a376
......@@ -1054,19 +1054,24 @@ jobs:
# these all run without concurrency because they're heavier
export TEST_CONCURRENCY=1
export IS_WEBPACK_TEST=1
BROWSER_NAME=firefox node run-tests.js \
export IS_TURBOPACK_TEST=1
TURBOPACK_BUILD=1 NEXT_TEST_MODE=start BROWSER_NAME=firefox node run-tests.js \
test/production/pages-dir/production/test/index.test.ts \
test/production/chunk-load-failure/chunk-load-failure.test.ts
NEXT_TEST_MODE=start BROWSER_NAME=safari node run-tests.js \
TURBOPACK_DEV=1 NEXT_TEST_MODE=dev BROWSER_NAME=firefox node run-tests.js \
test/e2e/app-dir/scss/hmr-module/hmr-module.test.ts
TURBOPACK_DEV=1 NEXT_TEST_MODE=dev BROWSER_NAME=safari node run-tests.js \
test/e2e/app-dir/scss/hmr-module/hmr-module.test.ts
TURBOPACK_BUILD=1 NEXT_TEST_MODE=start BROWSER_NAME=safari node run-tests.js \
test/production/pages-dir/production/test/index.test.ts \
test/production/chunk-load-failure/chunk-load-failure.test.ts \
test/e2e/basepath/basepath.test.ts \
test/e2e/basepath/error-pages.test.ts
BROWSER_NAME=safari DEVICE_NAME='iPhone XR' node run-tests.js \
TURBOPACK_BUILD=1 NEXT_TEST_MODE=start BROWSER_NAME=safari DEVICE_NAME='iPhone XR' node run-tests.js \
test/production/prerender-prefetch/index.test.ts
stepName: 'test-firefox-safari'
secrets: inherit
......
......@@ -153,8 +153,8 @@ export declare function minify(
export declare function minifySync(input: Buffer, opts: Buffer): TransformOutput
export interface NapiEndpointConfig {}
export interface NapiAssetPath {
path: string
contentHash: string
path: RcStr
contentHash: RcStr
}
export interface NapiWrittenEndpoint {
type: string
......@@ -363,7 +363,7 @@ export interface AppPageNapiRoute {
}
export interface NapiRoute {
/** The router path */
pathname: string
pathname: RcStr
/** The relative path from project_path to the route file */
originalName?: RcStr
/** The type of route, eg a Page or App */
......@@ -522,13 +522,13 @@ export declare function rootTaskDispose(rootTask: {
export interface NapiIssue {
severity: string
stage: string
filePath: string
filePath: RcStr
title: any
description?: any
detail?: any
source?: NapiIssueSource
additionalSources: Array<NapiAdditionalIssueSource>
documentationLink: string
documentationLink: RcStr
importTraces: any
/**
* Pre-rendered code frame for the issue's source location, if available.
......@@ -537,7 +537,7 @@ export interface NapiIssue {
codeFrame?: string
}
export interface NapiAdditionalIssueSource {
description: string
description: RcStr
source: NapiIssueSource
/** Pre-rendered code frame for this additional source location, if available. */
codeFrame?: string
......@@ -551,16 +551,16 @@ export interface NapiIssueSourceRange {
end: NapiSourcePos
}
export interface NapiSource {
ident: string
filePath: string
ident: RcStr
filePath: RcStr
}
export interface NapiSourcePos {
line: number
column: number
}
export interface NapiDiagnostic {
category: string
name: string
category: RcStr
name: RcStr
payload: Record<string, string>
}
export declare function expandNextJsTemplate(
......
......@@ -237,6 +237,11 @@ function mergeChunkUpdates(
return undefined
}
if (updateB.type === 'total') {
// A total update replaces the entire chunk, so it supersedes any prior update.
return updateB
}
if (updateA.type === 'partial') {
invariant(updateA.instruction, 'Partial updates are unsupported')
}
......
......@@ -18,12 +18,15 @@ let DEV_BACKEND: DevRuntimeBackend
unloadChunk(chunkUrl) {
deleteResolver(chunkUrl)
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0]
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl)
const decodedBaseChunkUrl = decodeURI(baseChunkUrl)
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(
`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`
`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`
)
for (const link of Array.from(links)) {
link.remove()
......@@ -34,7 +37,7 @@ let DEV_BACKEND: DevRuntimeBackend
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(
`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`
`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`
)
for (const script of Array.from(scripts)) {
script.remove()
......@@ -51,9 +54,12 @@ let DEV_BACKEND: DevRuntimeBackend
return
}
const decodedChunkUrl = decodeURI(chunkUrl)
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0]
const decodedBaseChunkUrl = decodeURI(baseChunkUrl)
const previousLinks = document.querySelectorAll(
`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`
`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`
)
if (previousLinks.length === 0) {
......@@ -64,15 +70,28 @@ let DEV_BACKEND: DevRuntimeBackend
const link = document.createElement('link')
link.rel = 'stylesheet'
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (
navigator.userAgent.includes('Firefox') ||
(navigator.userAgent.includes('Safari') &&
!navigator.userAgent.includes('Chrome') &&
!navigator.userAgent.includes('Chromium'))
) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin)
url.searchParams.set('ts', String(Date.now()))
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()))
link.href = url.pathname + url.search
} else {
link.href = chunkUrl
}
......
......@@ -11,13 +11,10 @@
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (
(self.TURBOPACK_ASSET_SUFFIX ??
document?.currentScript
?.getAttribute?.('src')
?.replace(/^(.*(?=\?)|^.*$)/, '')) ||
''
)
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX
const src = document?.currentScript?.getAttribute?.('src') ?? ''
const qi = src.indexOf('?')
return qi >= 0 ? src.slice(qi) : ''
}
type ChunkResolver = {
......
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="9cce6140-a664-1990-1f64-3699b6ffe1e3")}catch(e){}}();
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="d770a5d4-1204-13a9-f97e-0b13896fee56")}catch(e){}}();
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1i9t_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_19boa0e.js",
{"otherChunks":["output/1do3_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_03ibyvs.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]}
......@@ -1967,7 +1967,10 @@ globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (self.TURBOPACK_ASSET_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
const src = document?.currentScript?.getAttribute?.('src') ?? '';
const qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
let BACKEND;
/**
......@@ -2139,10 +2142,13 @@ let DEV_BACKEND;
DEV_BACKEND = {
unloadChunk (chunkUrl) {
deleteResolver(chunkUrl);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl);
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`);
const links = document.querySelectorAll(`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`);
for (const link of Array.from(links)){
link.remove();
}
......@@ -2151,7 +2157,7 @@ let DEV_BACKEND;
// runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`);
const scripts = document.querySelectorAll(`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`);
for (const script of Array.from(scripts)){
script.remove();
}
......@@ -2165,23 +2171,34 @@ let DEV_BACKEND;
reject(new Error('The DOM backend can only reload CSS chunks'));
return;
}
const decodedChunkUrl = decodeURI(chunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`);
if (previousLinks.length === 0) {
reject(new Error(`No link element found for chunk ${chunkUrl}`));
return;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`;
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin);
url.searchParams.set('ts', String(Date.now()));
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()));
link.href = url.pathname + url.search;
} else {
link.href = chunkUrl;
}
......@@ -2227,5 +2244,5 @@ chunkListsToRegister.forEach(registerChunkList);
})();
//# debugId=9cce6140-a664-1990-1f64-3699b6ffe1e3
//# debugId=d770a5d4-1204-13a9-f97e-0b13896fee56
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_19boa0e.js.map
\ No newline at end of file
......@@ -1966,7 +1966,10 @@ globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (self.TURBOPACK_ASSET_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
const src = document?.currentScript?.getAttribute?.('src') ?? '';
const qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
let BACKEND;
/**
......@@ -2138,10 +2141,13 @@ let DEV_BACKEND;
DEV_BACKEND = {
unloadChunk (chunkUrl) {
deleteResolver(chunkUrl);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl);
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`);
const links = document.querySelectorAll(`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`);
for (const link of Array.from(links)){
link.remove();
}
......@@ -2150,7 +2156,7 @@ let DEV_BACKEND;
// runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`);
const scripts = document.querySelectorAll(`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`);
for (const script of Array.from(scripts)){
script.remove();
}
......@@ -2164,23 +2170,34 @@ let DEV_BACKEND;
reject(new Error('The DOM backend can only reload CSS chunks'));
return;
}
const decodedChunkUrl = decodeURI(chunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`);
if (previousLinks.length === 0) {
reject(new Error(`No link element found for chunk ${chunkUrl}`));
return;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`;
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin);
url.searchParams.set('ts', String(Date.now()));
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()));
link.href = url.pathname + url.search;
} else {
link.href = chunkUrl;
}
......
......@@ -5,5 +5,5 @@
{"offset": {"line": 14, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared/runtime/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"./runtime-types.d.ts\" />\n\ntype EsmNamespaceObject = Record<string, any>\n\n/**\n * Describes why a module was instantiated.\n * Shared between browser and Node.js runtimes.\n */\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n * SourceData is a ChunkPath.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n * SourceData is a ModuleId.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n * SourceData is an array of ModuleIds or undefined.\n */\n Update = 2,\n}\n\ntype SourceData = ChunkPath | ModuleId | ModuleId[] | undefined\n\n// @ts-ignore Defined in `dev-base.ts`\ndeclare function getOrInstantiateModuleFromParent<M>(\n id: ModuleId,\n sourceModule: M\n): M\n\n// @ts-ignore Defined in `hmr-runtime.ts` (dev mode only)\ndeclare let devModuleCache: Record<ModuleId, any> | undefined\n\n/**\n * Flag indicating which module object type to create when a module is merged. Set to `true`\n * by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,\n * nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it\n * uses plain Module objects.\n */\nlet createModuleWithDirectionFlag = false\n\nconst REEXPORTED_OBJECTS = new WeakMap<Module, ReexportedObjects>()\n\n/**\n * Constructs the `__turbopack_context__` object for a module.\n */\nfunction Context(\n this: TurbopackBaseContext<Module>,\n module: Module,\n exports: Exports\n) {\n this.m = module\n // We need to store this here instead of accessing it from the module object to:\n // 1. Make it available to factories directly, since we rewrite `this` to\n // `__turbopack_context__.e` in CJS modules.\n // 2. Support async modules which rewrite `module.exports` to a promise, so we\n // can still access the original exports object from functions like\n // `esmExport`\n // Ideally we could find a new approach for async modules and drop this property altogether.\n this.e = exports\n}\nconst contextPrototype = Context.prototype as TurbopackBaseContext<Module>\n\ntype ModuleContextMap = Record<ModuleId, ModuleContextEntry>\n\ninterface ModuleContextEntry {\n id: () => ModuleId\n module: () => any\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: string): Exports | EsmNamespaceObject\n\n // async import call\n import(moduleId: string): Promise<Exports | EsmNamespaceObject>\n\n keys(): ModuleId[]\n\n resolve(moduleId: string): ModuleId\n}\n\ntype GetOrInstantiateModuleFromParent<M extends Module> = (\n moduleId: M['id'],\n parentModule: M\n) => M\n\ndeclare function getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): Module\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty\nconst toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType<any>\n) {\n if (!hasOwnProperty.call(obj, name)) Object.defineProperty(obj, name, options)\n}\n\nfunction getOverwrittenModule(\n moduleCache: ModuleCache<Module>,\n id: ModuleId\n): Module {\n let module = moduleCache[id]\n if (!module) {\n if (createModuleWithDirectionFlag) {\n // set in development modes for hmr support\n module = createModuleWithDirection(id)\n } else {\n module = createModuleObject(id)\n }\n moduleCache[id] = module\n }\n return module\n}\n\n/**\n * Creates the module object. Only done here to ensure all module objects have the same shape.\n */\nfunction createModuleObject(id: ModuleId): Module {\n return {\n exports: {},\n error: undefined,\n id,\n namespaceObject: undefined,\n }\n}\n\nfunction createModuleWithDirection(id: ModuleId): ModuleWithDirection {\n return {\n exports: {},\n error: undefined,\n id,\n namespaceObject: undefined,\n parents: [],\n children: [],\n }\n}\n\ntype BindingTag = 0\nconst BindingTag_Value = 0 as BindingTag\n\n// an arbitrary sequence of bindings as\n// - a prop name\n// - BindingTag_Value, a value to be bound directly, or\n// - 1 or 2 functions to bind as getters and sdetters\ntype EsmBindings = Array<\n string | BindingTag | (() => unknown) | ((v: unknown) => void) | unknown\n>\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, bindings: EsmBindings) {\n defineProp(exports, '__esModule', { value: true })\n if (toStringTag) defineProp(exports, toStringTag, { value: 'Module' })\n let i = 0\n while (i < bindings.length) {\n const propName = bindings[i++] as string\n const tagOrFunction = bindings[i++]\n if (typeof tagOrFunction === 'number') {\n if (tagOrFunction === BindingTag_Value) {\n defineProp(exports, propName, {\n value: bindings[i++],\n enumerable: true,\n writable: false,\n })\n } else {\n throw new Error(`unexpected tag: ${tagOrFunction}`)\n }\n } else {\n const getterFn = tagOrFunction as () => unknown\n if (typeof bindings[i] === 'function') {\n const setterFn = bindings[i++] as (v: unknown) => void\n defineProp(exports, propName, {\n get: getterFn,\n set: setterFn,\n enumerable: true,\n })\n } else {\n defineProp(exports, propName, {\n get: getterFn,\n enumerable: true,\n })\n }\n }\n }\n Object.seal(exports)\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n this: TurbopackBaseContext<Module>,\n bindings: EsmBindings,\n id: ModuleId | undefined\n) {\n let module: Module\n let exports: Module['exports']\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n exports = module.exports\n } else {\n module = this.m\n exports = this.e\n }\n module.namespaceObject = exports\n esm(exports, bindings)\n}\ncontextPrototype.s = esmExport\n\ntype ReexportedObjects = Record<PropertyKey, unknown>[]\nfunction ensureDynamicExports(\n module: Module,\n exports: Exports\n): ReexportedObjects {\n let reexportedObjects: ReexportedObjects | undefined =\n REEXPORTED_OBJECTS.get(module)\n\n if (!reexportedObjects) {\n REEXPORTED_OBJECTS.set(module, (reexportedObjects = []))\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === 'default' ||\n prop === '__esModule'\n ) {\n return Reflect.get(target, prop)\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop)\n if (value !== undefined) return value\n }\n return undefined\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target)\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== 'default' && !keys.includes(key)) keys.push(key)\n }\n }\n return keys\n },\n })\n }\n return reexportedObjects\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n this: TurbopackBaseContext<Module>,\n object: Record<string, any>,\n id: ModuleId | undefined\n) {\n let module: Module\n let exports: Exports\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n exports = module.exports\n } else {\n module = this.m\n exports = this.e\n }\n const reexportedObjects = ensureDynamicExports(module, exports)\n\n if (typeof object === 'object' && object !== null) {\n reexportedObjects.push(object)\n }\n}\ncontextPrototype.j = dynamicExport\n\nfunction exportValue(\n this: TurbopackBaseContext<Module>,\n value: any,\n id: ModuleId | undefined\n) {\n let module: Module\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n } else {\n module = this.m\n }\n module.exports = value\n}\ncontextPrototype.v = exportValue\n\nfunction exportNamespace(\n this: TurbopackBaseContext<Module>,\n namespace: any,\n id: ModuleId | undefined\n) {\n let module: Module\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n } else {\n module = this.m\n }\n module.exports = module.namespaceObject = namespace\n}\ncontextPrototype.n = exportNamespace\n\nfunction createGetter(obj: Record<string | symbol, any>, key: string | symbol) {\n return () => obj[key]\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)]\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const bindings: EsmBindings = []\n let defaultLocation = -1\n for (\n let current = raw;\n (typeof current === 'object' || typeof current === 'function') &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n bindings.push(key, createGetter(raw, key))\n if (defaultLocation === -1 && key === 'default') {\n defaultLocation = bindings.length - 1\n }\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && defaultLocation >= 0)) {\n // Replace the binding with one for the namespace itself in order to preserve iteration order.\n if (defaultLocation >= 0) {\n // Replace the getter with the value\n bindings.splice(defaultLocation, 1, BindingTag_Value, raw)\n } else {\n bindings.push('default', BindingTag_Value, raw)\n }\n }\n\n esm(ns, bindings)\n return ns\n}\n\nfunction createNS(raw: Module['exports']): EsmNamespaceObject {\n if (typeof raw === 'function') {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args)\n }\n } else {\n return Object.create(null)\n }\n}\n\nfunction esmImport(\n this: TurbopackBaseContext<Module>,\n id: ModuleId\n): Exclude<Module['namespaceObject'], undefined> {\n const module = getOrInstantiateModuleFromParent(id, this.m)\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports\n return (module.namespaceObject = interopEsm(\n raw,\n createNS(raw),\n raw && (raw as any).__esModule\n ))\n}\ncontextPrototype.i = esmImport\n\nfunction asyncLoader(\n this: TurbopackBaseContext<Module>,\n moduleId: ModuleId\n): Promise<Exports> {\n const loader = this.r(moduleId) as (\n importFunction: EsmImport\n ) => Promise<Exports>\n return loader(esmImport.bind(this))\n}\ncontextPrototype.A = asyncLoader\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n // @ts-ignore\n typeof require === 'function'\n ? // @ts-ignore\n require\n : function require() {\n throw new Error('Unexpected use of runtime require')\n }\ncontextPrototype.t = runtimeRequire\n\nfunction commonJsRequire(\n this: TurbopackBaseContext<Module>,\n id: ModuleId\n): Exports {\n return getOrInstantiateModuleFromParent(id, this.m).exports\n}\ncontextPrototype.r = commonJsRequire\n\n/**\n * Remove fragments and query parameters since they are never part of the context map keys\n *\n * This matches how we parse patterns at resolving time. Arguably we should only do this for\n * strings passed to `import` but the resolve does it for `import` and `require` and so we do\n * here as well.\n */\nfunction parseRequest(request: string): string {\n // Per the URI spec fragments can contain `?` characters, so we should trim it off first\n // https://datatracker.ietf.org/doc/html/rfc3986#section-3.5\n const hashIndex = request.indexOf('#')\n if (hashIndex !== -1) {\n request = request.substring(0, hashIndex)\n }\n\n const queryIndex = request.indexOf('?')\n if (queryIndex !== -1) {\n request = request.substring(0, queryIndex)\n }\n\n return request\n}\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: string): Exports {\n id = parseRequest(id)\n if (hasOwnProperty.call(map, id)) {\n return map[id].module()\n }\n\n const e = new Error(`Cannot find module '${id}'`)\n ;(e as any).code = 'MODULE_NOT_FOUND'\n throw e\n }\n\n moduleContext.keys = (): string[] => {\n return Object.keys(map)\n }\n\n moduleContext.resolve = (id: string): ModuleId => {\n id = parseRequest(id)\n if (hasOwnProperty.call(map, id)) {\n return map[id].id()\n }\n\n const e = new Error(`Cannot find module '${id}'`)\n ;(e as any).code = 'MODULE_NOT_FOUND'\n throw e\n }\n\n moduleContext.import = async (id: string) => {\n return await (moduleContext(id) as Promise<Exports>)\n }\n\n return moduleContext\n}\ncontextPrototype.f = moduleContext\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === 'string' ? chunkData : chunkData.path\n}\n\nfunction isPromise<T = any>(maybePromise: any): maybePromise is Promise<T> {\n return (\n maybePromise != null &&\n typeof maybePromise === 'object' &&\n 'then' in maybePromise &&\n typeof maybePromise.then === 'function'\n )\n}\n\nfunction isAsyncModuleExt<T extends {}>(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj\n}\n\nfunction createPromise<T>() {\n let resolve: (value: T | PromiseLike<T>) => void\n let reject: (reason?: any) => void\n\n const promise = new Promise<T>((res, rej) => {\n reject = rej\n resolve = res\n })\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n }\n}\n\n// Load the CompressedmoduleFactories of a chunk into the `moduleFactories` Map.\n// The CompressedModuleFactories format is\n// - 1 or more module ids\n// - a module factory function\n// So walking this is a little complex but the flat structure is also fast to\n// traverse, we can use `typeof` operators to distinguish the two cases.\nfunction installCompressedModuleFactories(\n chunkModules: CompressedModuleFactories,\n offset: number,\n moduleFactories: ModuleFactories,\n newModuleId?: (id: ModuleId) => void\n) {\n let i = offset\n while (i < chunkModules.length) {\n let end = i + 1\n // Find our factory function\n while (\n end < chunkModules.length &&\n typeof chunkModules[end] !== 'function'\n ) {\n end++\n }\n if (end === chunkModules.length) {\n throw new Error('malformed chunk format, expected a factory function')\n }\n\n // Install the factory for each module ID that doesn't already have one.\n // When some IDs in this group already have a factory, reuse that existing\n // group factory for the missing IDs to keep all IDs in the group consistent.\n // Otherwise, install the factory from this chunk.\n const moduleFactoryFn = chunkModules[end] as Function\n let existingGroupFactory: Function | undefined = undefined\n for (let j = i; j < end; j++) {\n const id = chunkModules[j] as ModuleId\n const existingFactory = moduleFactories.get(id)\n if (existingFactory) {\n existingGroupFactory = existingFactory\n break\n }\n }\n const factoryToInstall = existingGroupFactory ?? moduleFactoryFn\n\n let didInstallFactory = false\n for (let j = i; j < end; j++) {\n const id = chunkModules[j] as ModuleId\n if (!moduleFactories.has(id)) {\n if (!didInstallFactory) {\n if (factoryToInstall === moduleFactoryFn) {\n applyModuleFactoryName(moduleFactoryFn)\n }\n didInstallFactory = true\n }\n moduleFactories.set(id, factoryToInstall)\n newModuleId?.(id)\n }\n }\n i = end + 1 // end is pointing at the last factory advance to the next id or the end of the array.\n }\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol('turbopack queues')\nconst turbopackExports = Symbol('turbopack exports')\nconst turbopackError = Symbol('turbopack error')\n\nconst enum QueueStatus {\n Unknown = -1,\n Unresolved = 0,\n Resolved = 1,\n}\n\ntype AsyncQueueFn = (() => void) & { queueCount: number }\ntype AsyncQueue = AsyncQueueFn[] & {\n status: QueueStatus\n}\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && queue.status !== QueueStatus.Resolved) {\n queue.status = QueueStatus.Resolved\n queue.forEach((fn) => fn.queueCount--)\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()))\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise<Exports>\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void\n [turbopackExports]: Exports\n [turbopackError]?: any\n}\n\ntype AsyncModulePromise<T = Exports> = Promise<T> & AsyncModuleExt\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep): AsyncModuleExt => {\n if (dep !== null && typeof dep === 'object') {\n if (isAsyncModuleExt(dep)) return dep\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], {\n status: QueueStatus.Unresolved,\n })\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n }\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res\n resolveQueue(queue)\n },\n (err) => {\n obj[turbopackError] = err\n resolveQueue(queue)\n }\n )\n\n return obj\n }\n }\n\n return {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n }\n })\n}\n\nfunction asyncModule(\n this: TurbopackBaseContext<Module>,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const module = this.m\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { status: QueueStatus.Unknown })\n : undefined\n\n const depQueues: Set<AsyncQueue> = new Set()\n\n const { resolve, reject, promise: rawPromise } = createPromise<Exports>()\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: module.exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue)\n depQueues.forEach(fn)\n promise['catch'](() => {})\n },\n } satisfies AsyncModuleExt)\n\n const attributes: PropertyDescriptor = {\n get(): any {\n return promise\n },\n set(v: any) {\n // Calling `esmExport` leads to this.\n if (v !== promise) {\n promise[turbopackExports] = v\n }\n },\n }\n\n Object.defineProperty(module, 'exports', attributes)\n Object.defineProperty(module, 'namespaceObject', attributes)\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps)\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError]\n return d[turbopackExports]\n })\n\n const { promise, resolve } = createPromise<() => Exports[]>()\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n })\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q)\n if (q && q.status === QueueStatus.Unresolved) {\n fn.queueCount++\n q.push(fn)\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue))\n\n return fn.queueCount ? promise : getResult()\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err))\n } else {\n resolve(promise[turbopackExports])\n }\n\n resolveQueue(queue)\n }\n\n body(handleAsyncDependencies, asyncResult)\n\n if (queue && queue.status === QueueStatus.Unknown) {\n queue.status = QueueStatus.Unresolved\n }\n}\ncontextPrototype.a = asyncModule\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, 'x:/')\n const values: Record<string, any> = {}\n for (const key in realUrl) values[key] = (realUrl as any)[key]\n values.href = inputUrl\n values.pathname = inputUrl.replace(/[?#].*/, '')\n values.origin = values.protocol = ''\n values.toString = values.toJSON = (..._args: Array<any>) => inputUrl\n for (const key in values)\n Object.defineProperty(this, key, {\n enumerable: true,\n configurable: true,\n value: values[key],\n })\n}\nrelativeURL.prototype = URL.prototype\ncontextPrototype.U = relativeURL\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`)\n}\n\n/**\n * Constructs an error message for when a module factory is not available.\n */\nfunction factoryNotAvailableMessage(\n moduleId: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): string {\n let instantiationReason: string\n switch (sourceType) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${sourceData}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${sourceData}`\n break\n case SourceType.Update:\n instantiationReason = 'because of an HMR update'\n break\n default:\n invariant(\n sourceType,\n (sourceType) => `Unknown source type: ${sourceType}`\n )\n }\n return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`\n}\n\n/**\n * A stub function to make `require` available but non-functional in ESM.\n */\nfunction requireStub(_moduleId: ModuleId): never {\n throw new Error('dynamic usage of require is not supported')\n}\ncontextPrototype.z = requireStub\n\n// Make `globalThis` available to the module in a way that cannot be shadowed by a local variable.\ncontextPrototype.g = globalThis\n\ntype ContextConstructor<M> = {\n new (module: Module, exports: Exports): TurbopackBaseContext<M>\n}\n\nfunction applyModuleFactoryName(factory: Function) {\n // Give the module factory a nice name to improve stack traces.\n Object.defineProperty(factory, 'name', {\n value: 'module evaluation',\n })\n}\n"],"names":["SourceType","createModuleWithDirectionFlag","REEXPORTED_OBJECTS","WeakMap","Context","module","exports","m","e","contextPrototype","prototype","hasOwnProperty","Object","toStringTag","Symbol","defineProp","obj","name","options","call","defineProperty","getOverwrittenModule","moduleCache","id","createModuleWithDirection","createModuleObject","error","undefined","namespaceObject","parents","children","BindingTag_Value","esm","bindings","value","i","length","propName","tagOrFunction","enumerable","writable","Error","getterFn","setterFn","get","set","seal","esmExport","c","s","ensureDynamicExports","reexportedObjects","Proxy","target","prop","Reflect","_iteratorError","ownKeys","keys","_iteratorError1","key","includes","push","dynamicExport","object","_type_of","j","exportValue","v","exportNamespace","namespace","n","createGetter","getProto","getPrototypeOf","__proto__","LEAF_PROTOTYPES","interopEsm","raw","ns","allowExportDefault","defaultLocation","current","getOwnPropertyNames","splice","createNS","_key","args","apply","create","esmImport","getOrInstantiateModuleFromParent","__esModule","asyncLoader","moduleId","loader","r","bind","A","runtimeRequire","require","require1","t","commonJsRequire","parseRequest","request","hashIndex","indexOf","substring","queryIndex","moduleContext","map","code","resolve","import","f","getChunkPath","chunkData","path","isPromise","maybePromise","then","isAsyncModuleExt","turbopackQueues","createPromise","reject","promise","Promise","res","rej","installCompressedModuleFactories","chunkModules","offset","moduleFactories","newModuleId","end","moduleFactoryFn","existingGroupFactory","existingFactory","factoryToInstall","didInstallFactory","j1","id1","has","applyModuleFactoryName","turbopackExports","turbopackError","resolveQueue","queue","status","forEach","fn","queueCount","wrapDeps","deps","dep","assign","_obj","err","_obj1","asyncModule","body","hasAwait","depQueues","Set","_createPromise","rawPromise","attributes","handleAsyncDependencies","currentDeps","getResult","d","fnQueue","q","add","asyncResult","a","relativeURL","inputUrl","realUrl","URL","values","href","pathname","replace","origin","protocol","toString","toJSON","_args","key1","configurable","U","invariant","never","computeMessage","factoryNotAvailableMessage","sourceType","sourceData","instantiationReason","requireStub","_moduleId","z","g","globalThis","factory"],"mappings":"AAAA;;;;;CAKC,GAED,oDAAoD,GAEpD,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI7C;;;CAGC,GACD,IAAA,AAAKA,oCAAAA;IACH;;;;GAIC;IAED;;;GAGC;IAED;;;;GAIC;WAhBEA;EAAAA;AA+BL;;;;;CAKC,GACD,IAAIC,gCAAgC;AAEpC,IAAMC,qBAAqB,IAAIC;AAE/B;;CAEC,GACD,SAASC,QAEPC,MAAc,EACdC,OAAgB;IAEhB,IAAI,CAACC,CAAC,GAAGF;IACT,gFAAgF;IAChF,yEAAyE;IACzE,+CAA+C;IAC/C,8EAA8E;IAC9E,sEAAsE;IACtE,iBAAiB;IACjB,4FAA4F;IAC5F,IAAI,CAACG,CAAC,GAAGF;AACX;AACA,IAAMG,mBAAmBL,QAAQM,SAAS;AA+B1C,IAAMC,iBAAiBC,OAAOF,SAAS,CAACC,cAAc;AACtD,IAAME,cAAc,OAAOC,WAAW,eAAeA,OAAOD,WAAW;AAEvE,SAASE,WACPC,GAAQ,EACRC,IAAiB,EACjBC,OAA2C;IAE3C,IAAI,CAACP,eAAeQ,IAAI,CAACH,KAAKC,OAAOL,OAAOQ,cAAc,CAACJ,KAAKC,MAAMC;AACxE;AAEA,SAASG,qBACPC,WAAgC,EAChCC,EAAY;IAEZ,IAAIlB,SAASiB,WAAW,CAACC,GAAG;IAC5B,IAAI,CAAClB,QAAQ;QACX,IAAIJ,+BAA+B;YACjC,2CAA2C;YAC3CI,SAASmB,0BAA0BD;QACrC,OAAO;YACLlB,SAASoB,mBAAmBF;QAC9B;QACAD,WAAW,CAACC,GAAG,GAAGlB;IACpB;IACA,OAAOA;AACT;AAEA;;CAEC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0]}},
{"offset": {"line": 840, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/browser/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *browser* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../base/globals.d.ts\" />\n/// <reference path=\"../../../shared/runtime/runtime-utils.ts\" />\n\n// Used in WebWorkers to tell the runtime about the chunk suffix\ndeclare var TURBOPACK_ASSET_SUFFIX: string\n// Used in WebWorkers to tell the runtime about the current chunk url since it\n// can't be detected via `document.currentScript`. Note it's stored in reversed\n// order to use `push` and `pop`\ndeclare var TURBOPACK_NEXT_CHUNK_URLS: ChunkUrl[] | undefined\n\n// Injected by rust code\ndeclare var CHUNK_BASE_PATH: string\ndeclare var ASSET_SUFFIX: string\ndeclare var WORKER_FORWARDED_GLOBALS: string[]\n\ninterface TurbopackBrowserBaseContext<M> extends TurbopackBaseContext<M> {\n R: ResolvePathFromModule\n}\n\nconst browserContextPrototype =\n Context.prototype as TurbopackBrowserBaseContext<unknown>\n\n// Provided by build or dev base\ndeclare function instantiateModule(\n id: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): Module\n\ntype RuntimeParams = {\n otherChunks: ChunkData[]\n runtimeModuleIds: ModuleId[]\n}\n\ntype ChunkRegistrationChunk =\n | ChunkPath\n | { getAttribute: (name: string) => string | null }\n | undefined\n\ntype ChunkRegistration = [\n chunkPath: ChunkRegistrationChunk,\n ...([RuntimeParams] | CompressedModuleFactories),\n]\n\ntype ChunkList = {\n script: ChunkRegistrationChunk\n chunks: ChunkData[]\n source: 'entry' | 'dynamic'\n}\n\ninterface RuntimeBackend {\n registerChunk: (\n chunkPath: ChunkPath | ChunkScript,\n params?: RuntimeParams\n ) => void\n /**\n * Returns the same Promise for the same chunk URL.\n */\n loadChunkCached: (sourceType: SourceType, chunkUrl: ChunkUrl) => Promise<void>\n loadWebAssembly: (\n sourceType: SourceType,\n sourceData: SourceData,\n wasmChunkPath: ChunkPath,\n edgeModule: () => WebAssembly.Module,\n importsObj: WebAssembly.Imports\n ) => Promise<Exports>\n loadWebAssemblyModule: (\n sourceType: SourceType,\n sourceData: SourceData,\n wasmChunkPath: ChunkPath,\n edgeModule: () => WebAssembly.Module\n ) => Promise<WebAssembly.Module>\n}\n\ninterface DevRuntimeBackend {\n reloadChunk?: (chunkUrl: ChunkUrl) => Promise<void>\n unloadChunk?: (chunkUrl: ChunkUrl) => void\n restart: () => void\n}\n\nconst moduleFactories: ModuleFactories = new Map()\ncontextPrototype.M = moduleFactories\n\nconst availableModules: Map<ModuleId, Promise<any> | true> = new Map()\n\nconst availableModuleChunks: Map<ChunkPath, Promise<any> | true> = new Map()\n\nfunction loadChunk(\n this: TurbopackBrowserBaseContext<Module>,\n chunkData: ChunkData\n): Promise<void> {\n return loadChunkInternal(SourceType.Parent, this.m.id, chunkData)\n}\nbrowserContextPrototype.l = loadChunk\n\nfunction loadInitialChunk(chunkPath: ChunkPath, chunkData: ChunkData) {\n return loadChunkInternal(SourceType.Runtime, chunkPath, chunkData)\n}\n\nasync function loadChunkInternal(\n sourceType: SourceType,\n sourceData: SourceData,\n chunkData: ChunkData\n): Promise<void> {\n if (typeof chunkData === 'string') {\n return loadChunkPath(sourceType, sourceData, chunkData)\n }\n\n const includedList = chunkData.included || []\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories.has(included)) return true\n return availableModules.get(included)\n })\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n await Promise.all(modulesPromises)\n return\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || []\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included)\n })\n .filter((p) => p)\n\n let promise: Promise<unknown>\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length === includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n await Promise.all(moduleChunksPromises)\n return\n }\n\n const moduleChunksToLoad: Set<ChunkPath> = new Set()\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk)\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(sourceType, sourceData, moduleChunkToLoad)\n\n availableModuleChunks.set(moduleChunkToLoad, promise)\n\n moduleChunksPromises.push(promise)\n }\n\n promise = Promise.all(moduleChunksPromises)\n } else {\n promise = loadChunkPath(sourceType, sourceData, chunkData.path)\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise)\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise)\n }\n }\n\n await promise\n}\n\nconst loadedChunk = Promise.resolve(undefined)\nconst instrumentedBackendLoadChunks = new WeakMap<\n Promise<any>,\n Promise<any> | typeof loadedChunk\n>()\n// Do not make this async. React relies on referential equality of the returned Promise.\nfunction loadChunkByUrl(\n this: TurbopackBrowserBaseContext<Module>,\n chunkUrl: ChunkUrl\n) {\n return loadChunkByUrlInternal(SourceType.Parent, this.m.id, chunkUrl)\n}\nbrowserContextPrototype.L = loadChunkByUrl\n\n// Do not make this async. React relies on referential equality of the returned Promise.\nfunction loadChunkByUrlInternal(\n sourceType: SourceType,\n sourceData: SourceData,\n chunkUrl: ChunkUrl\n): Promise<any> {\n const thenable = BACKEND.loadChunkCached(sourceType, chunkUrl)\n let entry = instrumentedBackendLoadChunks.get(thenable)\n if (entry === undefined) {\n const resolve = instrumentedBackendLoadChunks.set.bind(\n instrumentedBackendLoadChunks,\n thenable,\n loadedChunk\n )\n entry = thenable.then(resolve).catch((cause) => {\n let loadReason: string\n switch (sourceType) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${sourceData}`\n break\n case SourceType.Parent:\n loadReason = `from module ${sourceData}`\n break\n case SourceType.Update:\n loadReason = 'from an HMR update'\n break\n default:\n invariant(\n sourceType,\n (sourceType) => `Unknown source type: ${sourceType}`\n )\n }\n let error = new Error(\n `Failed to load chunk ${chunkUrl} ${loadReason}${\n cause ? `: ${cause}` : ''\n }`,\n cause ? { cause } : undefined\n )\n error.name = 'ChunkLoadError'\n throw error\n })\n instrumentedBackendLoadChunks.set(thenable, entry)\n }\n\n return entry\n}\n\n// Do not make this async. React relies on referential equality of the returned Promise.\nfunction loadChunkPath(\n sourceType: SourceType,\n sourceData: SourceData,\n chunkPath: ChunkPath\n): Promise<void> {\n const url = getChunkRelativeUrl(chunkPath)\n return loadChunkByUrlInternal(sourceType, sourceData, url)\n}\n\n/**\n * Returns an absolute url to an asset.\n */\nfunction resolvePathFromModule(\n this: TurbopackBaseContext<Module>,\n moduleId: string\n): string {\n const exported = this.r(moduleId)\n return exported?.default ?? exported\n}\nbrowserContextPrototype.R = resolvePathFromModule\n\n/**\n * no-op for browser\n * @param modulePath\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n return `/ROOT/${modulePath ?? ''}`\n}\nbrowserContextPrototype.P = resolveAbsolutePath\n\n/**\n * Exports a URL with the static suffix appended.\n */\nfunction exportUrl(\n this: TurbopackBrowserBaseContext<Module>,\n url: string,\n id: ModuleId | undefined\n) {\n exportValue.call(this, `${url}${ASSET_SUFFIX}`, id)\n}\nbrowserContextPrototype.q = exportUrl\n\n/**\n * Creates a worker by instantiating the given WorkerConstructor with the\n * appropriate URL and options.\n *\n * The entrypoint is a pre-compiled worker runtime file. The params configure\n * which module chunks to load and which module to run as the entry point.\n *\n * The params are a JSON array of the following structure:\n * `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`\n *\n * @param WorkerConstructor The Worker or SharedWorker constructor\n * @param entrypoint URL path to the worker entrypoint chunk\n * @param moduleChunks list of module chunk paths to load\n * @param workerOptions options to pass to the Worker constructor (optional)\n */\nfunction createWorker(\n WorkerConstructor: { new (url: URL, options?: object): Worker },\n entrypoint: ChunkPath,\n moduleChunks: ChunkPath[],\n workerOptions?: object\n): Worker {\n const isSharedWorker = WorkerConstructor.name === 'SharedWorker'\n\n const chunkUrls = moduleChunks\n .map((chunk) => getChunkRelativeUrl(chunk))\n .reverse()\n const params: unknown[] = [chunkUrls, ASSET_SUFFIX]\n for (const globalName of WORKER_FORWARDED_GLOBALS) {\n params.push((globalThis as Record<string, unknown>)[globalName])\n }\n\n const url = new URL(getChunkRelativeUrl(entrypoint), location.origin)\n const paramsJson = JSON.stringify(params)\n if (isSharedWorker) {\n url.searchParams.set('params', paramsJson)\n } else {\n url.hash = '#params=' + encodeURIComponent(paramsJson)\n }\n\n // Remove type: \"module\" from options since our worker entrypoint is not a module\n const options = workerOptions\n ? { ...workerOptions, type: undefined }\n : undefined\n return new WorkerConstructor(url, options)\n}\nbrowserContextPrototype.b = createWorker\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, SourceType.Runtime, chunkPath)\n}\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath | ChunkListPath): ChunkUrl {\n return `${CHUNK_BASE_PATH}${chunkPath\n .split('/')\n .map((p) => encodeURIComponent(p))\n .join('/')}${ASSET_SUFFIX}` as ChunkUrl\n}\n\n/**\n * Return the ChunkPath from a ChunkScript.\n */\nfunction getPathFromScript(chunkScript: ChunkPath | ChunkScript): ChunkPath\nfunction getPathFromScript(\n chunkScript: ChunkListPath | ChunkListScript\n): ChunkListPath\nfunction getPathFromScript(\n chunkScript: ChunkPath | ChunkListPath | ChunkScript | ChunkListScript\n): ChunkPath | ChunkListPath {\n if (typeof chunkScript === 'string') {\n return chunkScript as ChunkPath | ChunkListPath\n }\n const chunkUrl = chunkScript.src!\n const src = decodeURIComponent(chunkUrl.replace(/[?#].*$/, ''))\n const path = src.startsWith(CHUNK_BASE_PATH)\n ? src.slice(CHUNK_BASE_PATH.length)\n : src\n return path as ChunkPath | ChunkListPath\n}\n\n/**\n * Return the ChunkUrl from a ChunkScript.\n */\nfunction getUrlFromScript(chunk: ChunkPath | ChunkScript): ChunkUrl {\n if (typeof chunk === 'string') {\n return getChunkRelativeUrl(chunk)\n } else {\n // This is already exactly what we want\n return chunk.src! as ChunkUrl\n }\n}\n\n/**\n * Determine the chunk to register. Note that this function has side-effects!\n */\nfunction getChunkFromRegistration(\n chunk: ChunkRegistrationChunk\n): ChunkPath | CurrentScript {\n if (typeof chunk === 'string') {\n return chunk\n } else if (!chunk) {\n if (typeof TURBOPACK_NEXT_CHUNK_URLS !== 'undefined') {\n return { src: TURBOPACK_NEXT_CHUNK_URLS.pop()! } as CurrentScript\n } else {\n throw new Error('chunk path empty but not in a worker')\n }\n } else {\n return { src: chunk.getAttribute('src')! } as CurrentScript\n }\n}\n\n/**\n * Checks if a given path/URL ends with the given extension,\n * optionally followed by ?query or #fragment.\n */\nfunction endsWithExtension(\n chunkUrlOrPath: ChunkUrl | ChunkPath,\n ext: string\n): boolean {\n // Find where the path ends (before query or fragment)\n const q = chunkUrlOrPath.indexOf('?')\n let end: number\n if (q !== -1) {\n end = q\n } else {\n const h = chunkUrlOrPath.indexOf('#')\n end = h !== -1 ? h : chunkUrlOrPath.length\n }\n // Check if the path portion ends with the extension\n return end >= ext.length && chunkUrlOrPath.startsWith(ext, end - ext.length)\n}\n\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return endsWithExtension(chunkUrlOrPath, '.js')\n}\n\nfunction isCss(chunkUrl: ChunkUrl): boolean {\n return endsWithExtension(chunkUrl, '.css')\n}\n\nfunction loadWebAssembly(\n this: TurbopackBaseContext<Module>,\n chunkPath: ChunkPath,\n edgeModule: () => WebAssembly.Module,\n importsObj: WebAssembly.Imports\n): Promise<Exports> {\n return BACKEND.loadWebAssembly(\n SourceType.Parent,\n this.m.id,\n chunkPath,\n edgeModule,\n importsObj\n )\n}\ncontextPrototype.w = loadWebAssembly\n\nfunction loadWebAssemblyModule(\n this: TurbopackBaseContext<Module>,\n chunkPath: ChunkPath,\n edgeModule: () => WebAssembly.Module\n): Promise<WebAssembly.Module> {\n return BACKEND.loadWebAssemblyModule(\n SourceType.Parent,\n this.m.id,\n chunkPath,\n edgeModule\n )\n}\ncontextPrototype.u = loadWebAssemblyModule\n"],"names":["browserContextPrototype","Context","prototype","moduleFactories","Map","contextPrototype","M","availableModules","availableModuleChunks","loadChunk","chunkData","loadChunkInternal","SourceType","Parent","m","id","l","loadInitialChunk","chunkPath","Runtime","sourceType","sourceData","includedList","modulesPromises","includedModuleChunksList","moduleChunksPromises","promise","moduleChunksToLoad","_iteratorError","moduleChunk","_iteratorError1","moduleChunkToLoad","promise1","_iteratorError2","includedModuleChunk","_iteratorError3","included","loadChunkPath","map","has","get","length","every","p","Promise","all","moduleChunks","filter","Set","add","set","push","path","loadedChunk","resolve","undefined","instrumentedBackendLoadChunks","WeakMap","loadChunkByUrl","chunkUrl","loadChunkByUrlInternal","L","thenable","BACKEND","loadChunkCached","entry","bind","then","catch","cause","loadReason","Update","invariant","error","Error","name","url","getChunkRelativeUrl","resolvePathFromModule","moduleId","exported","r","default","R","resolveAbsolutePath","modulePath","P","exportUrl","exportValue","call","ASSET_SUFFIX","q","createWorker","WorkerConstructor","entrypoint","workerOptions","isSharedWorker","chunkUrls","chunk","reverse","params","WORKER_FORWARDED_GLOBALS","globalName","globalThis","URL","location","origin","paramsJson","JSON","stringify","searchParams","hash","encodeURIComponent","options","type","b","instantiateRuntimeModule","instantiateModule","CHUNK_BASE_PATH","split","join","getPathFromScript","chunkScript","src","decodeURIComponent","replace","startsWith","slice","getUrlFromScript","getChunkFromRegistration","TURBOPACK_NEXT_CHUNK_URLS","pop","getAttribute","endsWithExtension","chunkUrlOrPath","ext","indexOf","end","h","isJs","isCss","loadWebAssembly","edgeModule","importsObj","w","loadWebAssemblyModule","u"],"mappings":"AAAA;;;;;;CAMC,GAED,oDAAoD,GAEpD,6CAA6C;AAC7C,iEAAiE;AAEjE,gEAAgE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBhE,IAAMA,0BACJC,QAAQC,SAAS;AA4DnB,IAAMC,kBAAmC,IAAIC;AAC7CC,iBAAiBC,CAAC,GAAGH;AAErB,IAAMI,mBAAuD,IAAIH;AAEjE,IAAMI,wBAA6D,IAAIJ;AAEvE,SAASK,UAEPC,SAAoB;IAEpB,OAAOC,kBAAkBC,WAAWC,MAAM,EAAE,IAAI,CAACC,CAAC,CAACC,EAAE,EAAEL;AACzD;AACAV,wBAAwBgB,CAAC,GAAGP;AAE5B,SAASQ,iBAAiBC,SAAoB,EAAER,SAAoB;IAClE,OAAOC,kBAAkBC,WAAWO,OAAO,EAAED,WAAWR;AAC1D;AAEA,SAAeC,kBACbS,UAAsB,EACtBC,UAAsB,EACtBX,SAAoB;;YAMdY,cACAC,iBAUAC,0BACAC,sBAQFC,SAUIC,oBACDC,2BAAAA,mBAAAA,gBAAAA,WAAAA,OAAMC,aAMNC,4BAAAA,oBAAAA,iBAAAA,YAAAA,QAAMC,mBACHC,UAYHC,4BAAAA,oBAAAA,iBAAAA,YAAAA,QAAMC,qBAORC,4BAAAA,oBAAAA,iBAAAA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AIJ,eAAeE,OAAO,CAAC;QACjCC,MAAMC,MAAM,CAAC,IAAIA,IAAIJ,eAAe7F,MAAM;IAC5C;IACA,oDAAoD;IACpD,OAAOgG,OAAOF,IAAI9F,MAAM,IAAI6F,eAAeR,UAAU,CAACS,KAAKE,MAAMF,IAAI9F,MAAM;AAC7E;AAEA,SAASkG,KAAKL,cAAoC;IAChD,OAAOD,kBAAkBC,gBAAgB;AAC3C;AAEA,SAASM,MAAMjF,QAAkB;IAC/B,OAAO0E,kBAAkB1E,UAAU;AACrC;AAEA,SAASkF,gBAEP3H,SAAoB,EACpB4H,UAAoC,EACpCC,UAA+B;IAE/B,OAAOhF,QAAQ8E,eAAe,CAC5BjI,WAAWC,MAAM,EACjB,IAAI,CAACC,CAAC,CAACC,EAAE,EACTG,WACA4H,YACAC;AAEJ;AACA1I,iBAAiB2I,CAAC,GAAGH;AAErB,SAASI,sBAEP/H,SAAoB,EACpB4H,UAAoC;IAEpC,OAAO/E,QAAQkF,qBAAqB,CAClCrI,WAAWC,MAAM,EACjB,IAAI,CAACC,CAAC,CAACC,EAAE,EACTG,WACA4H;AAEJ;AACAzI,iBAAiB6I,CAAC,GAAGD","ignoreList":[0]}},
{"offset": {"line": 1419, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/browser/runtime/base/build-base.ts"],"sourcesContent":["/// <reference path=\"./runtime-base.ts\" />\n/// <reference path=\"./dummy.ts\" />\n\nconst moduleCache: ModuleCache<Module> = {}\ncontextPrototype.c = moduleCache\n\n/**\n * Gets or instantiates a runtime module.\n */\n// @ts-ignore\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateModule(moduleId, SourceType.Runtime, chunkPath)\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// Used by the backend\n// @ts-ignore\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent<\n Module\n> = (id, sourceModule) => {\n const module = moduleCache[id]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateModule(id, SourceType.Parent, sourceModule.id)\n}\n\nfunction instantiateModule(\n id: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): Module {\n const moduleFactory = moduleFactories.get(id)\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData))\n }\n\n const module: Module = createModuleObject(id)\n const exports = module.exports\n\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n const context = new (Context as any as ContextConstructor<Module>)(\n module,\n exports\n )\n try {\n moduleFactory(context, module, exports)\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction registerChunk(registration: ChunkRegistration) {\n const chunk = getChunkFromRegistration(registration[0]) as\n | ChunkScript\n | ChunkPath\n let runtimeParams: RuntimeParams | undefined\n // When bootstrapping we are passed a single runtimeParams object so we can distinguish purely based on length\n if (registration.length === 2) {\n runtimeParams = registration[1] as RuntimeParams\n } else {\n runtimeParams = undefined\n installCompressedModuleFactories(\n registration as CompressedModuleFactories,\n /* offset= */ 1,\n moduleFactories\n )\n }\n\n return BACKEND.registerChunk(chunk, runtimeParams)\n}\n"],"names":["moduleCache","contextPrototype","c","getOrInstantiateRuntimeModule","chunkPath","moduleId","module","error","instantiateModule","SourceType","Runtime","getOrInstantiateModuleFromParent","id","sourceModule","Parent","sourceType","sourceData","moduleFactory","moduleFactories","get","Error","factoryNotAvailableMessage","createModuleObject","exports","context","Context","namespaceObject","interopEsm","registerChunk","registration","chunk","getChunkFromRegistration","runtimeParams","length","undefined","installCompressedModuleFactories","BACKEND"],"mappings":"AAAA,0CAA0C;AAC1C,mCAAmC;AAEnC,IAAMA,cAAmC,CAAC;AAC1CC,iBAAiBC,CAAC,GAAGF;AAErB;;CAEC,GACD,aAAa;AACb,6DAA6D;AAC7D,SAASG,8BACPC,SAAoB,EACpBC,QAAkB;IAElB,IAAMC,SAASN,WAAW,CAACK,SAAS;IACpC,IAAIC,QAAQ;QACV,IAAIA,OAAOC,KAAK,EAAE;YAChB,MAAMD,OAAOC,KAAK;QACpB;QACA,OAAOD;IACT;IAEA,OAAOE,kBAAkBH,UAAUI,WAAWC,OAAO,EAAEN;AACzD;AAEA;;CAEC,GACD,sBAAsB;AACtB,aAAa;AACb,6DAA6D;AAC7D,IAAMO,mCAEF,0CAACC,IAAIC;IACP,IAAMP,SAASN,WAAW,CAACY,GAAG;IAE9B,IAAIN,QAAQ;QACV,IAAIA,OAAOC,KAAK,EAAE;YAChB,MAAMD,OAAOC,KAAK;QACpB;QACA,OAAOD;IACT;IAEA,OAAOE,kBAAkBI,IAAIH,WAAWK,MAAM,EAAED,aAAaD,EAAE;AACjE;AAEA,SAASJ,kBACPI,EAAY,EACZG,UAAsB,EACtBC,UAAsB;IAEtB,IAAMC,gBAAgBC,gBAAgBC,GAAG,CAACP;IAC1C,IAAI,OAAOK,kBAAkB,YAAY;QACvC,sEAAsE;QACtE,0EAA0E;QAC1E,mDAAmD;QACnD,MAAM,IAAIG,MAAMC,2BAA2BT,IAAIG,YAAYC;IAC7D;IAEA,IAAMV,SAAiBgB,mBAAmBV;IAC1C,IAAMW,UAAUjB,OAAOiB,OAAO;IAE9BvB,WAAW,CAACY,GAAG,GAAGN;IAElB,4EAA4E;IAC5E,IAAMkB,UAAU,IAAKC,QACnBnB,QACAiB;IAEF,IAAI;QACFN,cAAcO,SAASlB,QAAQiB;IACjC,EAAE,OAAOhB,OAAO;QACdD,OAAOC,KAAK,GAAGA;QACf,MAAMA;IACR;IAEA,IAAID,OAAOoB,eAAe,IAAIpB,OAAOiB,OAAO,KAAKjB,OAAOoB,eAAe,EAAE;QACvE,yDAAyD;QACzDC,WAAWrB,OAAOiB,OAAO,EAAEjB,OAAOoB,eAAe;IACnD;IAEA,OAAOpB;AACT;AAEA,6DAA6D;AAC7D,SAASsB,cAAcC,YAA+B;IACpD,IAAMC,QAAQC,yBAAyBF,YAAY,CAAC,EAAE;IAGtD,IAAIG;IACJ,8GAA8G;IAC9G,IAAIH,aAAaI,MAAM,KAAK,GAAG;QAC7BD,gBAAgBH,YAAY,CAAC,EAAE;IACjC,OAAO;QACLG,gBAAgBE;QAChBC,iCACEN,cACA,WAAW,GAAG,GACdX;IAEJ;IAEA,OAAOkB,QAAQR,aAAa,CAACE,OAAOE;AACtC","ignoreList":[0]}},
{"offset": {"line": 1490, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/browser/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack ECMAScript DOM runtime.\n *\n * It will be appended to the base runtime code.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../../../browser/runtime/base/runtime-base.ts\" />\n/// <reference path=\"../../../shared/runtime/runtime-types.d.ts\" />\n\nfunction getAssetSuffixFromScriptSrc() {\n // TURBOPACK_ASSET_SUFFIX is set in web workers\n return (\n (self.TURBOPACK_ASSET_SUFFIX ??\n document?.currentScript\n ?.getAttribute?.('src')\n ?.replace(/^(.*(?=\\?)|^.*$)/, '')) ||\n ''\n )\n}\n\ntype ChunkResolver = {\n resolved: boolean\n loadingStarted: boolean\n resolve: () => void\n reject: (error?: Error) => void\n promise: Promise<any>\n}\n\nlet BACKEND: RuntimeBackend\n\n/**\n * Maps chunk paths to the corresponding resolver.\n */\nconst chunkResolvers: Map<ChunkUrl, ChunkResolver> = new Map()\n\n;(() => {\n BACKEND = {\n async registerChunk(chunk, params) {\n let chunkPath = getPathFromScript(chunk)\n let chunkUrl = getUrlFromScript(chunk)\n\n const resolver = getOrCreateResolver(chunkUrl)\n resolver.resolve()\n\n if (params == null) {\n return\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData)\n const otherChunkUrl = getChunkRelativeUrl(otherChunkPath)\n\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkUrl)\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadInitialChunk(chunkPath, otherChunkData)\n )\n )\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(chunkPath, moduleId)\n }\n }\n },\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n loadChunkCached(sourceType: SourceType, chunkUrl: ChunkUrl) {\n return doLoadChunk(sourceType, chunkUrl)\n },\n\n async loadWebAssembly(\n _sourceType: SourceType,\n _sourceData: SourceData,\n wasmChunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n importsObj: WebAssembly.Imports\n ): Promise<Exports> {\n const req = fetchWebAssembly(wasmChunkPath)\n\n const { instance } = await WebAssembly.instantiateStreaming(\n req,\n importsObj\n )\n\n return instance.exports\n },\n\n async loadWebAssemblyModule(\n _sourceType: SourceType,\n _sourceData: SourceData,\n wasmChunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n ): Promise<WebAssembly.Module> {\n const req = fetchWebAssembly(wasmChunkPath)\n\n return await WebAssembly.compileStreaming(req)\n },\n }\n\n function getOrCreateResolver(chunkUrl: ChunkUrl): ChunkResolver {\n let resolver = chunkResolvers.get(chunkUrl)\n if (!resolver) {\n let resolve: () => void\n let reject: (error?: Error) => void\n const promise = new Promise<void>((innerResolve, innerReject) => {\n resolve = innerResolve\n reject = innerReject\n })\n resolver = {\n resolved: false,\n loadingStarted: false,\n promise,\n resolve: () => {\n resolver!.resolved = true\n resolve()\n },\n reject: reject!,\n }\n chunkResolvers.set(chunkUrl, resolver)\n }\n return resolver\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n function doLoadChunk(sourceType: SourceType, chunkUrl: ChunkUrl) {\n const resolver = getOrCreateResolver(chunkUrl)\n if (resolver.loadingStarted) {\n return resolver.promise\n }\n\n if (sourceType === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n resolver.loadingStarted = true\n\n if (isCss(chunkUrl)) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve()\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise\n }\n\n if (typeof importScripts === 'function') {\n // We're in a web worker\n if (isCss(chunkUrl)) {\n // ignore\n } else if (isJs(chunkUrl)) {\n self.TURBOPACK_NEXT_CHUNK_URLS!.push(chunkUrl)\n importScripts(chunkUrl)\n } else {\n throw new Error(\n `can't infer type of chunk from URL ${chunkUrl} in worker`\n )\n }\n } else {\n // TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.\n const decodedChunkUrl = decodeURI(chunkUrl)\n\n if (isCss(chunkUrl)) {\n const previousLinks = document.querySelectorAll(\n `link[rel=stylesheet][href=\"${chunkUrl}\"],link[rel=stylesheet][href^=\"${chunkUrl}?\"],link[rel=stylesheet][href=\"${decodedChunkUrl}\"],link[rel=stylesheet][href^=\"${decodedChunkUrl}?\"]`\n )\n if (previousLinks.length > 0) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve()\n } else {\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = chunkUrl\n link.onerror = () => {\n resolver.reject()\n }\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve()\n }\n // Append to the `head` for webpack compatibility.\n document.head.appendChild(link)\n }\n } else if (isJs(chunkUrl)) {\n const previousScripts = document.querySelectorAll(\n `script[src=\"${chunkUrl}\"],script[src^=\"${chunkUrl}?\"],script[src=\"${decodedChunkUrl}\"],script[src^=\"${decodedChunkUrl}?\"]`\n )\n if (previousScripts.length > 0) {\n // There is this edge where the script already failed loading, but we\n // can't detect that. The Promise will never resolve in this case.\n for (const script of Array.from(previousScripts)) {\n script.addEventListener('error', () => {\n resolver.reject()\n })\n }\n } else {\n const script = document.createElement('script')\n script.src = chunkUrl\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject()\n }\n // Append to the `head` for webpack compatibility.\n document.head.appendChild(script)\n }\n } else {\n throw new Error(`can't infer type of chunk from URL ${chunkUrl}`)\n }\n }\n\n resolver.loadingStarted = true\n return resolver.promise\n }\n\n function fetchWebAssembly(wasmChunkPath: ChunkPath) {\n return fetch(getChunkRelativeUrl(wasmChunkPath))\n }\n})()\n"],"names":["getAssetSuffixFromScriptSrc","_self_TURBOPACK_ASSET_SUFFIX","_document_currentScript_getAttribute","TURBOPACK_ASSET_SUFFIX","currentScript","getAttribute","replace","BACKEND","chunkResolvers","Map","registerChunk","chunk","params","chunkPath","chunkUrl","resolver","_iteratorError","otherChunkData","otherChunkPath","otherChunkUrl","_iteratorError1","moduleId","getPathFromScript","getUrlFromScript","getOrCreateResolver","resolve","otherChunks","getChunkPath","getChunkRelativeUrl","Promise","all","map","loadInitialChunk","runtimeModuleIds","length","getOrInstantiateRuntimeModule","loadChunkCached","sourceType","doLoadChunk","loadWebAssembly","_sourceType","_sourceData","wasmChunkPath","_edgeModule","importsObj","req","instance","fetchWebAssembly","WebAssembly","instantiateStreaming","exports","loadWebAssemblyModule","compileStreaming","get","reject","promise","innerResolve","innerReject","resolved","loadingStarted","resolve1","set","SourceType","Runtime","isCss","importScripts","isJs","self","TURBOPACK_NEXT_CHUNK_URLS","push","Error","decodedChunkUrl","decodeURI","previousLinks","document","querySelectorAll","link","createElement","rel","href","onerror","onload","head","appendChild","previousScripts","Array","from","script","addEventListener","script1","src","fetch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;CAIC,GAED,oDAAoD,GAEpD,sEAAsE;AACtE,mEAAmE;AAEnE,SAASA;QAGJC;QACCC,sCAAAA,uCAAAA,yBAAAA;IAHJ,+CAA+C;IAC/C,OACE,CAAA,CAACD,+BAAAA,KAAKE,sBAAsB,AAGS,cAHpCF,0CAAAA,gCACCC,YAAAA,sBAAAA,iCAAAA,0BAAAA,UAAUE,aAAa,cAAvBF,+CAAAA,wCAAAA,wBACIG,YAAY,cADhBH,6DAAAA,uCAAAA,2CAAAA,yBACmB,oBADnBA,2DAAAA,qCAEII,OAAO,CAAC,oBAAoB,QAClC;AAEJ;AAUA,IAAIC;AAEJ;;CAEC,GACD,IAAMC,iBAA+C,IAAIC;AAExD,CAAC;IACAF,UAAU;QACFG,eAAN,SAAMA,cAAcC,KAAK,EAAEC,MAAM;;oBAC3BC,WACAC,UAEEC,UAODC,2BAAAA,mBAAAA,gBAAAA,WAAAA,OAAMC,gBACHC,gBACAC,eAcDC,4BAAAA,oBAAAA,iBAAAA,YAAAA,QAAMC;;;;4BA1BTR,YAAYS,kBAAkBX;4BAC9BG,WAAWS,iBAAiBZ;4BAE1BI,WAAWS,oBAAoBV;4BACrCC,SAASU,OAAO;4BAEhB,IAAIb,UAAU,MAAM;gCAClB;;;4BACF;4BAEKI,kCAAAA,2BAAAA;;gCAAL,IAAKA,YAAwBJ,OAAOc,WAAW,uBAA1CV,6BAAAA,QAAAA,yBAAAA,iCAA4C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,CAACC,WAAW,CAACM;gBAC5B;YACF,OAAO;gBACL,MAAM,IAAInB,MAAM,CAAC,mCAAmC,EAAExD,UAAU;YAClE;QACF;QAEAC,SAAS4C,cAAc,GAAG;QAC1B,OAAO5C,SAASwC,OAAO;IACzB;IAEA,SAASR,iBAAiBL,aAAwB;QAChD,OAAOiD,MAAM/D,oBAAoBc;IACnC;AACF,CAAC","ignoreList":[0]}}]
{"offset": {"line": 1490, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/browser/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack ECMAScript DOM runtime.\n *\n * It will be appended to the base runtime code.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../../../browser/runtime/base/runtime-base.ts\" />\n/// <reference path=\"../../../shared/runtime/runtime-types.d.ts\" />\n\nfunction getAssetSuffixFromScriptSrc() {\n // TURBOPACK_ASSET_SUFFIX is set in web workers\n if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX\n const src = document?.currentScript?.getAttribute?.('src') ?? ''\n const qi = src.indexOf('?')\n return qi >= 0 ? src.slice(qi) : ''\n}\n\ntype ChunkResolver = {\n resolved: boolean\n loadingStarted: boolean\n resolve: () => void\n reject: (error?: Error) => void\n promise: Promise<any>\n}\n\nlet BACKEND: RuntimeBackend\n\n/**\n * Maps chunk paths to the corresponding resolver.\n */\nconst chunkResolvers: Map<ChunkUrl, ChunkResolver> = new Map()\n\n;(() => {\n BACKEND = {\n async registerChunk(chunk, params) {\n let chunkPath = getPathFromScript(chunk)\n let chunkUrl = getUrlFromScript(chunk)\n\n const resolver = getOrCreateResolver(chunkUrl)\n resolver.resolve()\n\n if (params == null) {\n return\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData)\n const otherChunkUrl = getChunkRelativeUrl(otherChunkPath)\n\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkUrl)\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadInitialChunk(chunkPath, otherChunkData)\n )\n )\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(chunkPath, moduleId)\n }\n }\n },\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n loadChunkCached(sourceType: SourceType, chunkUrl: ChunkUrl) {\n return doLoadChunk(sourceType, chunkUrl)\n },\n\n async loadWebAssembly(\n _sourceType: SourceType,\n _sourceData: SourceData,\n wasmChunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n importsObj: WebAssembly.Imports\n ): Promise<Exports> {\n const req = fetchWebAssembly(wasmChunkPath)\n\n const { instance } = await WebAssembly.instantiateStreaming(\n req,\n importsObj\n )\n\n return instance.exports\n },\n\n async loadWebAssemblyModule(\n _sourceType: SourceType,\n _sourceData: SourceData,\n wasmChunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n ): Promise<WebAssembly.Module> {\n const req = fetchWebAssembly(wasmChunkPath)\n\n return await WebAssembly.compileStreaming(req)\n },\n }\n\n function getOrCreateResolver(chunkUrl: ChunkUrl): ChunkResolver {\n let resolver = chunkResolvers.get(chunkUrl)\n if (!resolver) {\n let resolve: () => void\n let reject: (error?: Error) => void\n const promise = new Promise<void>((innerResolve, innerReject) => {\n resolve = innerResolve\n reject = innerReject\n })\n resolver = {\n resolved: false,\n loadingStarted: false,\n promise,\n resolve: () => {\n resolver!.resolved = true\n resolve()\n },\n reject: reject!,\n }\n chunkResolvers.set(chunkUrl, resolver)\n }\n return resolver\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n function doLoadChunk(sourceType: SourceType, chunkUrl: ChunkUrl) {\n const resolver = getOrCreateResolver(chunkUrl)\n if (resolver.loadingStarted) {\n return resolver.promise\n }\n\n if (sourceType === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n resolver.loadingStarted = true\n\n if (isCss(chunkUrl)) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve()\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise\n }\n\n if (typeof importScripts === 'function') {\n // We're in a web worker\n if (isCss(chunkUrl)) {\n // ignore\n } else if (isJs(chunkUrl)) {\n self.TURBOPACK_NEXT_CHUNK_URLS!.push(chunkUrl)\n importScripts(chunkUrl)\n } else {\n throw new Error(\n `can't infer type of chunk from URL ${chunkUrl} in worker`\n )\n }\n } else {\n // TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.\n const decodedChunkUrl = decodeURI(chunkUrl)\n\n if (isCss(chunkUrl)) {\n const previousLinks = document.querySelectorAll(\n `link[rel=stylesheet][href=\"${chunkUrl}\"],link[rel=stylesheet][href^=\"${chunkUrl}?\"],link[rel=stylesheet][href=\"${decodedChunkUrl}\"],link[rel=stylesheet][href^=\"${decodedChunkUrl}?\"]`\n )\n if (previousLinks.length > 0) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve()\n } else {\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = chunkUrl\n link.onerror = () => {\n resolver.reject()\n }\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve()\n }\n // Append to the `head` for webpack compatibility.\n document.head.appendChild(link)\n }\n } else if (isJs(chunkUrl)) {\n const previousScripts = document.querySelectorAll(\n `script[src=\"${chunkUrl}\"],script[src^=\"${chunkUrl}?\"],script[src=\"${decodedChunkUrl}\"],script[src^=\"${decodedChunkUrl}?\"]`\n )\n if (previousScripts.length > 0) {\n // There is this edge where the script already failed loading, but we\n // can't detect that. The Promise will never resolve in this case.\n for (const script of Array.from(previousScripts)) {\n script.addEventListener('error', () => {\n resolver.reject()\n })\n }\n } else {\n const script = document.createElement('script')\n script.src = chunkUrl\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject()\n }\n // Append to the `head` for webpack compatibility.\n document.head.appendChild(script)\n }\n } else {\n throw new Error(`can't infer type of chunk from URL ${chunkUrl}`)\n }\n }\n\n resolver.loadingStarted = true\n return resolver.promise\n }\n\n function fetchWebAssembly(wasmChunkPath: ChunkPath) {\n return fetch(getChunkRelativeUrl(wasmChunkPath))\n }\n})()\n"],"names":["getAssetSuffixFromScriptSrc","_document_currentScript","self","TURBOPACK_ASSET_SUFFIX","src","currentScript","getAttribute","qi","indexOf","slice","BACKEND","chunkResolvers","Map","registerChunk","chunk","params","chunkPath","chunkUrl","resolver","_iteratorError","otherChunkData","otherChunkPath","otherChunkUrl","_iteratorError1","moduleId","getPathFromScript","getUrlFromScript","getOrCreateResolver","resolve","otherChunks","getChunkPath","getChunkRelativeUrl","Promise","all","map","loadInitialChunk","runtimeModuleIds","length","getOrInstantiateRuntimeModule","loadChunkCached","sourceType","doLoadChunk","loadWebAssembly","_sourceType","_sourceData","wasmChunkPath","_edgeModule","importsObj","req","instance","fetchWebAssembly","WebAssembly","instantiateStreaming","exports","loadWebAssemblyModule","compileStreaming","get","reject","promise","innerResolve","innerReject","resolved","loadingStarted","resolve1","set","SourceType","Runtime","isCss","importScripts","isJs","TURBOPACK_NEXT_CHUNK_URLS","push","Error","decodedChunkUrl","decodeURI","previousLinks","document","querySelectorAll","link","createElement","rel","href","onerror","onload","head","appendChild","previousScripts","Array","from","script","addEventListener","script1","fetch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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generator(thisArg, body) {
*/ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../../../browser/runtime/base/runtime-base.ts" />
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
var _self_TURBOPACK_ASSET_SUFFIX;
var _document_currentScript_getAttribute, _document_currentScript_getAttribute1, _document_currentScript, _document;
var _ref;
var _document_currentScript_getAttribute, _document_currentScript, _document;
// TURBOPACK_ASSET_SUFFIX is set in web workers
return ((_self_TURBOPACK_ASSET_SUFFIX = self.TURBOPACK_ASSET_SUFFIX) !== null && _self_TURBOPACK_ASSET_SUFFIX !== void 0 ? _self_TURBOPACK_ASSET_SUFFIX : (_document = document) === null || _document === void 0 ? void 0 : (_document_currentScript = _document.currentScript) === null || _document_currentScript === void 0 ? void 0 : (_document_currentScript_getAttribute1 = _document_currentScript.getAttribute) === null || _document_currentScript_getAttribute1 === void 0 ? void 0 : (_document_currentScript_getAttribute = _document_currentScript_getAttribute1.call(_document_currentScript, 'src')) === null || _document_currentScript_getAttribute === void 0 ? void 0 : _document_currentScript_getAttribute.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
var src = (_ref = (_document = document) === null || _document === void 0 ? void 0 : (_document_currentScript = _document.currentScript) === null || _document_currentScript === void 0 ? void 0 : (_document_currentScript_getAttribute = _document_currentScript.getAttribute) === null || _document_currentScript_getAttribute === void 0 ? void 0 : _document_currentScript_getAttribute.call(_document_currentScript, 'src')) !== null && _ref !== void 0 ? _ref : '';
var qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
var BACKEND;
/**
......
......@@ -1966,7 +1966,10 @@ globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (self.TURBOPACK_ASSET_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
const src = document?.currentScript?.getAttribute?.('src') ?? '';
const qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
let BACKEND;
/**
......@@ -2138,10 +2141,13 @@ let DEV_BACKEND;
DEV_BACKEND = {
unloadChunk (chunkUrl) {
deleteResolver(chunkUrl);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl);
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`);
const links = document.querySelectorAll(`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`);
for (const link of Array.from(links)){
link.remove();
}
......@@ -2150,7 +2156,7 @@ let DEV_BACKEND;
// runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`);
const scripts = document.querySelectorAll(`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`);
for (const script of Array.from(scripts)){
script.remove();
}
......@@ -2164,23 +2170,34 @@ let DEV_BACKEND;
reject(new Error('The DOM backend can only reload CSS chunks'));
return;
}
const decodedChunkUrl = decodeURI(chunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`);
if (previousLinks.length === 0) {
reject(new Error(`No link element found for chunk ${chunkUrl}`));
return;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`;
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin);
url.searchParams.set('ts', String(Date.now()));
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()));
link.href = url.pathname + url.search;
} else {
link.href = chunkUrl;
}
......
......@@ -1966,7 +1966,10 @@ globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (self.TURBOPACK_ASSET_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
const src = document?.currentScript?.getAttribute?.('src') ?? '';
const qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
let BACKEND;
/**
......@@ -2138,10 +2141,13 @@ let DEV_BACKEND;
DEV_BACKEND = {
unloadChunk (chunkUrl) {
deleteResolver(chunkUrl);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl);
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`);
const links = document.querySelectorAll(`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`);
for (const link of Array.from(links)){
link.remove();
}
......@@ -2150,7 +2156,7 @@ let DEV_BACKEND;
// runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`);
const scripts = document.querySelectorAll(`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`);
for (const script of Array.from(scripts)){
script.remove();
}
......@@ -2164,23 +2170,34 @@ let DEV_BACKEND;
reject(new Error('The DOM backend can only reload CSS chunks'));
return;
}
const decodedChunkUrl = decodeURI(chunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`);
if (previousLinks.length === 0) {
reject(new Error(`No link element found for chunk ${chunkUrl}`));
return;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`;
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin);
url.searchParams.set('ts', String(Date.now()));
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()));
link.href = url.pathname + url.search;
} else {
link.href = chunkUrl;
}
......
......@@ -1966,7 +1966,10 @@ globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (self.TURBOPACK_ASSET_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
const src = document?.currentScript?.getAttribute?.('src') ?? '';
const qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
let BACKEND;
/**
......@@ -2138,10 +2141,13 @@ let DEV_BACKEND;
DEV_BACKEND = {
unloadChunk (chunkUrl) {
deleteResolver(chunkUrl);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl);
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`);
const links = document.querySelectorAll(`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`);
for (const link of Array.from(links)){
link.remove();
}
......@@ -2150,7 +2156,7 @@ let DEV_BACKEND;
// runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`);
const scripts = document.querySelectorAll(`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`);
for (const script of Array.from(scripts)){
script.remove();
}
......@@ -2164,23 +2170,34 @@ let DEV_BACKEND;
reject(new Error('The DOM backend can only reload CSS chunks'));
return;
}
const decodedChunkUrl = decodeURI(chunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`);
if (previousLinks.length === 0) {
reject(new Error(`No link element found for chunk ${chunkUrl}`));
return;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`;
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin);
url.searchParams.set('ts', String(Date.now()));
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()));
link.href = url.pathname + url.search;
} else {
link.href = chunkUrl;
}
......
......@@ -1966,7 +1966,10 @@ globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];
/// <reference path="../../../shared/runtime/runtime-types.d.ts" />
function getAssetSuffixFromScriptSrc() {
// TURBOPACK_ASSET_SUFFIX is set in web workers
return (self.TURBOPACK_ASSET_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, '')) || '';
if (self.TURBOPACK_ASSET_SUFFIX != null) return self.TURBOPACK_ASSET_SUFFIX;
const src = document?.currentScript?.getAttribute?.('src') ?? '';
const qi = src.indexOf('?');
return qi >= 0 ? src.slice(qi) : '';
}
let BACKEND;
/**
......@@ -2138,10 +2141,13 @@ let DEV_BACKEND;
DEV_BACKEND = {
unloadChunk (chunkUrl) {
deleteResolver(chunkUrl);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
// TODO(PACK-2140): remove this once all filenames are guaranteed to be escaped.
const decodedChunkUrl = decodeURI(chunkUrl);
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
if (isCss(chunkUrl)) {
const links = document.querySelectorAll(`link[href="${chunkUrl}"],link[href^="${chunkUrl}?"],link[href="${decodedChunkUrl}"],link[href^="${decodedChunkUrl}?"]`);
const links = document.querySelectorAll(`link[href="${baseChunkUrl}"],link[href^="${baseChunkUrl}?"],link[href="${decodedBaseChunkUrl}"],link[href^="${decodedBaseChunkUrl}?"]`);
for (const link of Array.from(links)){
link.remove();
}
......@@ -2150,7 +2156,7 @@ let DEV_BACKEND;
// runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep
// the HTML somewhat consistent from the user's perspective.
const scripts = document.querySelectorAll(`script[src="${chunkUrl}"],script[src^="${chunkUrl}?"],script[src="${decodedChunkUrl}"],script[src^="${decodedChunkUrl}?"]`);
const scripts = document.querySelectorAll(`script[src="${baseChunkUrl}"],script[src^="${baseChunkUrl}?"],script[src="${decodedBaseChunkUrl}"],script[src^="${decodedBaseChunkUrl}?"]`);
for (const script of Array.from(scripts)){
script.remove();
}
......@@ -2164,23 +2170,34 @@ let DEV_BACKEND;
reject(new Error('The DOM backend can only reload CSS chunks'));
return;
}
const decodedChunkUrl = decodeURI(chunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${chunkUrl}"],link[rel=stylesheet][href^="${chunkUrl}?"],link[rel=stylesheet][href="${decodedChunkUrl}"],link[rel=stylesheet][href^="${decodedChunkUrl}?"]`);
// Strip query string so we match links regardless of cache-busting
// params (e.g. ?ts=) that may differ between HMR updates.
const baseChunkUrl = chunkUrl.split('?')[0];
const decodedBaseChunkUrl = decodeURI(baseChunkUrl);
const previousLinks = document.querySelectorAll(`link[rel=stylesheet][href="${baseChunkUrl}"],link[rel=stylesheet][href^="${baseChunkUrl}?"],link[rel=stylesheet][href="${decodedBaseChunkUrl}"],link[rel=stylesheet][href^="${decodedBaseChunkUrl}?"]`);
if (previousLinks.length === 0) {
reject(new Error(`No link element found for chunk ${chunkUrl}`));
return;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
if (navigator.userAgent.includes('Firefox')) {
// Firefox won't reload CSS files that were previously loaded on the current page,
// we need to add a query param to make sure CSS is actually reloaded from the server.
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
//
// I believe this is this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
// Safari serves cached CSS when a <link rel=preload> exists for the
// same URL: https://bugs.webkit.org/show_bug.cgi?id=187726
//
// Safari has a similar issue, but only if you have a `<link rel=preload ... />` tag
// pointing to the same URL as the stylesheet: https://bugs.webkit.org/show_bug.cgi?id=187726
link.href = `${chunkUrl}?ts=${Date.now()}`;
// Replace or add a fresh `ts` cache-busting param without
// discarding other query parameters that may already be present.
const url = new URL(chunkUrl, location.origin);
url.searchParams.set('ts', String(Date.now()));
// Reduced timer precision in some browers could lead to an update getting dropped
// in firefox if it happens fast enough (in firefox precision is sometimes 100ms!).
// So trust that the server is only updating us when it is important and use a
// random number to bust the cache.
url.searchParams.set('_next_rand', String(Math.random()));
link.href = url.pathname + url.search;
} else {
link.href = chunkUrl;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment