From 586e76948391a4a6e5e52f6a42f752228ea366b5 Mon Sep 17 00:00:00 2001 From: hrmny Date: Mon, 3 Jul 2023 22:39:49 +0200 Subject: [PATCH] top-level-await support --- crates/turbopack-core/src/resolve/mod.rs | 2 +- .../js/src/build/runtime.ts | 18 +- .../js/src/dev/runtime/base/runtime-base.ts | 20 +- .../runtime/nodejs/runtime-backend-nodejs.ts | 7 + .../js/src/shared/runtime-types.d.ts | 33 ++- .../js/src/shared/runtime-utils.ts | 219 +++++++++++++++++- .../src/analyzer/top_level_await.rs | 23 +- crates/turbopack-ecmascript/src/chunk/item.rs | 27 +++ .../src/chunk/placeable.rs | 5 +- crates/turbopack-ecmascript/src/lib.rs | 28 ++- .../src/references/async_module.rs | 149 ++++++++++++ .../src/references/esm/base.rs | 40 +++- .../src/references/mod.rs | 107 ++++++--- .../src/tree_shake/chunk_item.rs | 10 +- .../basic/top-level-await/input/Actions.js | 28 +++ .../basic/top-level-await/input/README.md | 2 + .../basic/top-level-await/input/UserAPI.js | 7 + .../top-level-await/input/db-connection.js | 18 ++ .../basic/top-level-await/input/index.js | 6 + ...ic_top-level-await_input_UserAPI_030d34.js | 48 ++++ ...op-level-await_input_UserAPI_030d34.js.map | 8 + ...ic_top-level-await_input_UserAPI_6657ac.js | 11 + ...ic_top-level-await_input_UserAPI_853a42.js | 11 + ...ic_top-level-await_input_UserAPI_d6e51f.js | 16 ++ ...op-level-await_input_UserAPI_d6e51f.js.map | 4 + ...asic_top-level-await_input_index_5771e1.js | 11 + ...asic_top-level-await_input_index_b53fce.js | 47 ++++ ..._top-level-await_input_index_b53fce.js.map | 8 + ...asic_top-level-await_input_index_d8ac4f.js | 6 + ..._top-level-await_input_index_d8ac4f.js.map | 4 + ...de_protocol_external_input_index_b53fce.js | 2 +- .../output/[turbopack]_runtime.js | 136 ++++++++++- .../output/[turbopack]_runtime.js.map | 4 +- ..._default_dev_runtime_input_index_e60ecd.js | 138 ++++++++++- ...ault_dev_runtime_input_index_e60ecd.js.map | 8 +- 35 files changed, 1096 insertions(+), 115 deletions(-) create mode 100644 crates/turbopack-ecmascript/src/references/async_module.rs create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map diff --git a/crates/turbopack-core/src/resolve/mod.rs b/crates/turbopack-core/src/resolve/mod.rs index 40e78e64566a33..8edc3715ba45d4 100644 --- a/crates/turbopack-core/src/resolve/mod.rs +++ b/crates/turbopack-core/src/resolve/mod.rs @@ -1428,7 +1428,7 @@ pub async fn handle_resolve_error( }) } -/// ModulePart represnts a part of a module. +/// ModulePart represents a part of a module. /// /// Currently this is used only for ESMs. #[turbo_tasks::value] diff --git a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts index 978df9c65221ca..feefe129b20f7f 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts @@ -30,21 +30,8 @@ interface RequireContextEntry { type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject; -interface TurbopackNodeBuildContext { - e: Module["exports"]; - r: CommonJsRequire; +interface TurbopackNodeBuildContext extends TurbopackBaseContext { x: ExternalRequire; - f: RequireContextFactory; - i: EsmImport; - s: EsmExport; - j: typeof dynamicExport; - v: ExportValue; - n: typeof exportNamespace; - m: Module; - c: ModuleCache; - l: LoadChunk; - g: typeof globalThis; - __dirname: string; } type ModuleFactory = ( @@ -176,13 +163,14 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { // NOTE(alexkirsz) This can fail when the module encounters a runtime error. try { moduleFactory.call(module.exports, { + a: asyncModule.bind(null, module), e: module.exports, r: commonJsRequire.bind(null, module), x: externalRequire, f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esm.bind(null, module.exports), - j: dynamicExport.bind(null, module), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts index c10b9f91fc75ad..2178864af42052 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts @@ -32,21 +32,8 @@ type RefreshContext = { type RefreshHelpers = RefreshRuntimeGlobals["$RefreshHelpers$"]; -interface TurbopackDevBaseContext { - e: Module["exports"]; - r: CommonJsRequire; - f: RequireContextFactory; - i: EsmImport; - s: EsmExport; - j: typeof dynamicExport; - v: ExportValue; - n: typeof exportNamespace; - m: Module; - c: ModuleCache; - l: LoadChunk; - g: typeof globalThis; +interface TurbopackDevBaseContext extends TurbopackBaseContext { k: RefreshContext; - __dirname: string; } interface TurbopackDevContext extends TurbopackDevBaseContext {} @@ -332,12 +319,13 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { moduleFactory.call( module.exports, augmentContext({ + a: asyncModule.bind(null, module), e: module.exports, r: commonJsRequire.bind(null, module), f: requireContext.bind(null, module), i: esmImport.bind(null, module), - s: esmExport.bind(null, module), - j: dynamicExport.bind(null, module), + s: esmExport.bind(null, module, module.exports), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts index 2a08b173813679..0449e30421d1c8 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts @@ -13,9 +13,11 @@ interface RequireContextEntry { } type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject; +type ExternalImport = (id: ModuleId) => Promise; interface TurbopackDevContext { x: ExternalRequire; + y: ExternalImport; } function commonJsRequireContext( @@ -27,6 +29,10 @@ function commonJsRequireContext( : commonJsRequire(sourceModule, entry.id()); } +function externalImport(id: ModuleId) { + return import(id) +} + function externalRequire( id: ModuleId, esm: boolean = false @@ -62,6 +68,7 @@ externalRequire.resolve = ( function augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext { const nodejsContext = context as TurbopackDevContext; nodejsContext.x = externalRequire; + nodejsContext.y = externalImport; return nodejsContext; } diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts index f9ed380b10767a..07763b07d48141 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts @@ -20,16 +20,43 @@ type ChunkData = }; type CommonJsRequire = (moduleId: ModuleId) => Exports; -type CommonJsExport = (exports: Record) => void; - type EsmImport = ( moduleId: ModuleId, allowExportDefault: boolean -) => EsmNamespaceObject; +) => EsmNamespaceObject | Promise; type EsmExport = (exportGetters: Record any>) => void; type ExportValue = (value: any) => void; +type ExportNamespace = (namespace: any) => void; +type DynamicExport = (object: Record) => void; type LoadChunk = (chunkPath: ChunkPath) => Promise | undefined; type ModuleCache = Record; type ModuleFactories = Record; + +type AsyncModule = ( + body: ( + handleAsyncDependencies: ( + deps: Dep[] + ) => Exports[] | Promise<() => Exports[]>, + asyncResult: (err?: any) => void + ) => void, + hasAwait: boolean +) => void; + +interface TurbopackBaseContext { + a: AsyncModule; + e: Module["exports"]; + r: CommonJsRequire; + f: RequireContextFactory; + i: EsmImport; + s: EsmExport; + j: DynamicExport; + v: ExportValue; + n: ExportNamespace; + m: Module; + c: ModuleCache; + l: LoadChunk; + g: typeof globalThis; + __dirname: string; +} diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index c099f3c20d1b15..2a710e5f98a1ef 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -14,18 +14,19 @@ interface Exports { [key: string]: any; } + type EsmNamespaceObject = Record; const REEXPORTED_OBJECTS = Symbol("reexported objects"); interface BaseModule { - exports: Exports; + exports: Exports | AsyncModulePromise; error: Error | undefined; loaded: boolean; id: ModuleId; children: ModuleId[]; parents: ModuleId[]; - namespaceObject?: EsmNamespaceObject; + namespaceObject?: EsmNamespaceObject | AsyncModulePromise; [REEXPORTED_OBJECTS]?: any[]; } @@ -39,7 +40,9 @@ interface RequireContextEntry { interface RequireContext { (moduleId: ModuleId): Exports | EsmNamespaceObject; + keys(): ModuleId[]; + resolve(moduleId: ModuleId): ModuleId; } @@ -79,18 +82,26 @@ function esm(exports: Exports, getters: Record any>) { /** * Makes the module an ESM with exports */ -function esmExport(module: Module, getters: Record any>) { - esm((module.namespaceObject = module.exports), getters); +function esmExport( + module: Module, + exports: Exports, + getters: Record any> +) { + esm((module.namespaceObject = exports), getters); } /** * Dynamically exports properties from an object */ -function dynamicExport(module: Module, object: Record) { +function dynamicExport( + module: Module, + exports: Exports, + object: Record +) { let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.namespaceObject = new Proxy(module.exports, { + module.namespaceObject = new Proxy(exports, { get(target, prop) { if ( hasOwnProperty.call(target, prop) || @@ -142,6 +153,8 @@ const getProto: (obj: any) => any = Object.getPrototypeOf const LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)]; /** + * @param raw + * @param ns * @param allowExportDefault * * `false`: will have the raw module as default export * * `true`: will have the default property as default export @@ -168,11 +181,37 @@ function interopEsm( esm(ns, getters); } -function esmImport(sourceModule: Module, id: ModuleId): EsmNamespaceObject { +function esmImport( + sourceModule: Module, + id: ModuleId +): EsmNamespaceObject | (Promise & AsyncModuleExt) { const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; + + if (isPromise(raw)) { + const promise = raw.then((e) => { + const ns = {}; + interopEsm(e, ns, e.__esModule); + return ns; + }); + + module.namespaceObject = Object.assign(promise, { + get [turbopackExports]() { + return raw[turbopackExports]; + }, + get [turbopackQueues]() { + return raw[turbopackQueues]; + }, + get [turbopackError]() { + return raw[turbopackError]; + }, + } satisfies AsyncModuleExt); + + return module.namespaceObject; + } + const ns = (module.namespaceObject = {}); interopEsm(raw, ns, raw.__esModule); return ns; @@ -227,3 +266,169 @@ function requireContext( function getChunkPath(chunkData: ChunkData): ChunkPath { return typeof chunkData === "string" ? chunkData : chunkData.path; } + +function isPromise(maybePromise: any): maybePromise is Promise { + return ( + maybePromise != null && + typeof maybePromise === "object" && + "then" in maybePromise && + typeof maybePromise.then === "function" + ); +} + +function createPromise() { + let resolve: (value: T | PromiseLike) => void; + let reject: (reason?: any) => void; + + const promise = new Promise((res, rej) => { + reject = rej; + resolve = res; + }); + + return { + promise, + resolve: resolve!, + reject: reject!, + }; +} + +// everything below is adapted from webpack +// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13 + +const turbopackQueues = Symbol("turbopack queues"); +const turbopackExports = Symbol("turbopack exports"); +const turbopackError = Symbol("turbopack error"); + +type AsyncQueueFn = (() => void) & { queueCount: number }; +type AsyncQueue = AsyncQueueFn[] & { resolved: boolean }; + +function resolveQueue(queue?: AsyncQueue) { + if (queue && !queue.resolved) { + queue.resolved = true; + queue.forEach((fn) => fn.queueCount--); + queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn())); + } +} + +type Dep = Exports | AsyncModulePromise | Promise; + +type AsyncModuleExt = { + [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void; + [turbopackExports]: Exports; + [turbopackError]?: any; +}; + +type AsyncModulePromise = Promise & AsyncModuleExt; + +function wrapDeps(deps: Dep[]): AsyncModuleExt[] { + return deps.map((dep) => { + if (dep !== null && typeof dep === "object") { + if (turbopackQueues in dep) return dep; + if (isPromise(dep)) { + const queue: AsyncQueue = Object.assign([], { resolved: false }); + + const obj: AsyncModuleExt = { + [turbopackExports]: {}, + [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue), + }; + + dep.then( + (res) => { + obj[turbopackExports] = res; + resolveQueue(queue); + }, + (err) => { + obj[turbopackError] = err; + resolveQueue(queue); + } + ); + + return obj; + } + } + + const ret: AsyncModuleExt = { + [turbopackExports]: dep, + [turbopackQueues]: () => {}, + }; + + return ret; + }); +} + +function asyncModule( + module: Module, + body: ( + handleAsyncDependencies: ( + deps: Dep[] + ) => Exports[] | Promise<() => Exports[]>, + asyncResult: (err?: any) => void + ) => void, + hasAwait: boolean +) { + const queue: AsyncQueue | undefined = hasAwait + ? Object.assign([], { resolved: true }) + : undefined; + + const depQueues: Set = new Set(); + const exports = module.exports; + + const { resolve, reject, promise: rawPromise } = createPromise(); + + const promise: AsyncModulePromise = Object.assign(rawPromise, { + [turbopackExports]: exports, + [turbopackQueues]: (fn) => { + queue && fn(queue); + depQueues.forEach(fn); + promise["catch"](() => {}); + }, + } satisfies AsyncModuleExt); + + module.exports = promise; + + function handleAsyncDependencies(deps: Dep[]) { + const currentDeps = wrapDeps(deps); + + const getResult = () => + currentDeps.map((d) => { + if (d[turbopackError]) throw d[turbopackError]; + return d[turbopackExports]; + }); + + const { promise, resolve } = createPromise<() => Exports[]>(); + + const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), { + queueCount: 0, + }); + + function fnQueue(q: AsyncQueue) { + if (q !== queue && !depQueues.has(q)) { + depQueues.add(q); + if (q && !q.resolved) { + fn.queueCount++; + q.push(fn); + } + } + } + + currentDeps.map((dep) => dep[turbopackQueues](fnQueue)); + + return fn.queueCount ? promise : getResult(); + } + + function asyncResult(err?: any) { + if (err) { + reject((promise[turbopackError] = err)); + } else { + resolve(exports); + } + + resolveQueue(queue); + } + + body(handleAsyncDependencies, asyncResult); + + if (queue) { + queue.resolved = false; + } +} diff --git a/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs b/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs index 507980c3ea554f..61d44e29c04736 100644 --- a/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs +++ b/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs @@ -1,19 +1,24 @@ -use swc_core::ecma::{ - ast::*, - visit::{noop_visit_type, Visit, VisitWith}, +use swc_core::{ + common::Span, + ecma::{ + ast::*, + visit::{noop_visit_type, Visit, VisitWith}, + }, }; -pub(crate) fn has_top_level_await(m: &Program) -> bool { +/// Checks if the program contains a top level await, if it does it will returns +/// the span of the first await. +pub(crate) fn has_top_level_await(m: &Program) -> Option { let mut visitor = TopLevelAwaitVisitor::default(); m.visit_with(&mut visitor); - visitor.has_top_level_await + visitor.top_level_await_span } #[derive(Default)] struct TopLevelAwaitVisitor { - has_top_level_await: bool, + top_level_await_span: Option, } macro_rules! noop { @@ -23,8 +28,10 @@ macro_rules! noop { } impl Visit for TopLevelAwaitVisitor { - fn visit_await_expr(&mut self, _: &AwaitExpr) { - self.has_top_level_await = true; + fn visit_await_expr(&mut self, n: &AwaitExpr) { + if self.top_level_await_span.is_none() { + self.top_level_await_span = Some(n.span); + } } // prevent non top level items from visiting their children diff --git a/crates/turbopack-ecmascript/src/chunk/item.rs b/crates/turbopack-ecmascript/src/chunk/item.rs index 3394440e043c27..a3374749c80162 100644 --- a/crates/turbopack-ecmascript/src/chunk/item.rs +++ b/crates/turbopack-ecmascript/src/chunk/item.rs @@ -22,6 +22,7 @@ use super::{ }; use crate::{ manifest::{chunk_asset::ManifestChunkAssetVc, loader_item::ManifestLoaderItemVc}, + references::async_module::{AsyncModuleOptions, OptionAsyncModuleOptionsVc}, utils::FormatIter, EcmascriptModuleContentVc, ParseResultSourceMapVc, }; @@ -41,6 +42,7 @@ impl EcmascriptChunkItemContentVc { pub async fn new( content: EcmascriptModuleContentVc, context: EcmascriptChunkingContextVc, + async_module_options: OptionAsyncModuleOptionsVc, ) -> Result { let refresh = *context.has_react_refresh().await?; let externals = *context.environment().node_externals().await?; @@ -50,9 +52,12 @@ impl EcmascriptChunkItemContentVc { inner_code: content.inner_code.clone(), source_map: content.source_map, options: if content.is_esm { + let async_module = async_module_options.await?.clone_value(); + EcmascriptChunkItemOptions { refresh, externals, + async_module, ..Default::default() } } else { @@ -88,8 +93,12 @@ impl EcmascriptChunkItemContentVc { // HACK "__dirname", ]; + if this.options.async_module.is_some() { + args.push("a: __turbopack_async_module__"); + } if this.options.externals { args.push("x: __turbopack_external_require__"); + args.push("y: __turbopack_external_import__"); } if this.options.refresh { args.push("k: __turbopack_refresh__"); @@ -108,8 +117,23 @@ impl EcmascriptChunkItemContentVc { write!(code, "(({{ {} }}) => (() => {{\n\n", args,)?; } + if this.options.async_module.is_some() { + code += "__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, \ + __turbopack_async_result__) => { try {"; + } + let source_map = this.source_map.map(|sm| sm.as_generate_source_map()); code.push_source(&this.inner_code, source_map); + + if let Some(opts) = &this.options.async_module { + write!( + code, + "__turbopack_async_result__();\n}} catch(e) {{ __turbopack_async_result__(e); }} \ + }}, {});", + opts.has_top_level_await + )?; + } + if this.options.this { code += "\n}.call(this) })"; } else { @@ -133,6 +157,9 @@ pub struct EcmascriptChunkItemOptions { /// Whether this chunk item's module factory should include a /// `__turbopack_external_require__` argument. pub externals: bool, + /// Whether this chunk item's module is async (either has a top level await + /// or is importing async modules). + pub async_module: Option, pub this: bool, pub placeholder_for_future_extensions: (), } diff --git a/crates/turbopack-ecmascript/src/chunk/placeable.rs b/crates/turbopack-ecmascript/src/chunk/placeable.rs index 4db50ee0fec3e9..0bc2718a08e4b7 100644 --- a/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -5,12 +5,15 @@ use turbopack_core::{ }; use super::{item::EcmascriptChunkItemVc, EcmascriptChunkingContextVc}; -use crate::references::esm::EsmExportsVc; +use crate::references::{async_module::OptionAsyncModuleOptionsVc, esm::EsmExportsVc}; #[turbo_tasks::value_trait] pub trait EcmascriptChunkPlaceable: ChunkableAsset + Asset { fn as_chunk_item(&self, context: EcmascriptChunkingContextVc) -> EcmascriptChunkItemVc; fn get_exports(&self) -> EcmascriptExportsVc; + fn get_async_module_options(&self) -> OptionAsyncModuleOptionsVc { + OptionAsyncModuleOptionsVc::cell(None) + } } #[turbo_tasks::value(transparent)] diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index 2489045c2a6a07..f501dc30c92fcb 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -87,7 +87,10 @@ use self::{ use crate::{ chunk::{EcmascriptChunkPlaceable, EcmascriptChunkPlaceableVc}, code_gen::CodeGenerateable, - references::analyze_ecmascript_module, + references::{ + analyze_ecmascript_module, + async_module::{OptionAsyncModuleOptionsReadRef, OptionAsyncModuleOptionsVc}, + }, transform::remove_shebang, }; @@ -135,7 +138,7 @@ struct MemoizedSuccessfulAnalysis { operation: RawVc, references: AssetReferencesReadRef, exports: EcmascriptExportsReadRef, - has_top_level_await: bool, + async_module_options: OptionAsyncModuleOptionsReadRef, } pub struct EcmascriptModuleAssetBuilder { @@ -313,13 +316,13 @@ impl EcmascriptModuleAssetVc { // We need to store the ReadRefs since we want to keep a snapshot. references: result_value.references.await?, exports: result_value.exports.await?, - has_top_level_await: result_value.has_top_level_await, + async_module_options: result_value.async_module_options.await?, })); } else if let Some(MemoizedSuccessfulAnalysis { operation, references, exports, - has_top_level_await, + async_module_options, }) = &*this.last_successful_analysis.get() { // It's important to connect to the last operation here to keep it active, so @@ -329,7 +332,7 @@ impl EcmascriptModuleAssetVc { references: ReadRef::cell(references.clone()), exports: ReadRef::cell(exports.clone()), code_generation: result_value.code_generation, - has_top_level_await: *has_top_level_await, + async_module_options: ReadRef::cell(async_module_options.clone()), successful: false, } .cell()); @@ -445,6 +448,13 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { async fn get_exports(self_vc: EcmascriptModuleAssetVc) -> Result { Ok(self_vc.failsafe_analyze().await?.exports) } + + #[turbo_tasks::function] + async fn get_async_module_options( + self_vc: EcmascriptModuleAssetVc, + ) -> Result { + Ok(self_vc.failsafe_analyze().await?.async_module_options) + } } #[turbo_tasks::value_impl] @@ -516,7 +526,13 @@ impl EcmascriptChunkItem for ModuleChunkItem { ) -> Result { let this = self_vc.await?; let content = this.module.module_content(this.context, availability_info); - Ok(EcmascriptChunkItemContentVc::new(content, this.context)) + let async_module_options = this.module.get_async_module_options(); + + Ok(EcmascriptChunkItemContentVc::new( + content, + this.context, + async_module_options, + )) } } diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs new file mode 100644 index 00000000000000..d4943df238ccb7 --- /dev/null +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -0,0 +1,149 @@ +use anyhow::Result; +use indexmap::IndexSet; +use serde::{Deserialize, Serialize}; +use swc_core::{ + common::DUMMY_SP, + ecma::ast::{ArrayLit, ArrayPat, Expr, Ident, Pat, Program}, + quote, +}; +use turbo_tasks::{primitives::BoolVc, trace::TraceRawVcs, TryJoinIterExt}; + +use crate::{ + chunk::EcmascriptChunkingContextVc, + code_gen::{CodeGenerateable, CodeGeneration, CodeGenerationVc}, + create_visitor, + references::esm::{base::insert_hoisted_stmt, EsmAssetReferenceVc}, + CodeGenerateableVc, +}; + +#[derive(PartialEq, Eq, Default, Debug, Clone, Serialize, Deserialize, TraceRawVcs)] +pub struct AsyncModuleOptions { + pub has_top_level_await: bool, +} + +#[turbo_tasks::value(transparent)] +pub struct OptionAsyncModuleOptions(Option); + +#[turbo_tasks::value_impl] +impl OptionAsyncModuleOptionsVc { + #[turbo_tasks::function] + pub(super) async fn is_async(self) -> Result { + Ok(BoolVc::cell(self.await?.is_some())) + } +} + +#[turbo_tasks::value(shared)] +pub struct AsyncModule { + pub(super) references: IndexSet, + pub(super) has_top_level_await: bool, +} + +#[turbo_tasks::value(transparent)] +pub struct OptionAsyncModule(Option); + +#[turbo_tasks::value_impl] +impl AsyncModuleVc { + #[turbo_tasks::function] + pub(super) async fn is_async(self) -> Result { + let this = self.await?; + + if this.has_top_level_await { + return Ok(BoolVc::cell(this.has_top_level_await)); + } + + let references_async = this + .references + .iter() + .map(|r| async { anyhow::Ok(*r.is_async().await?) }) + .try_join() + .await?; + + Ok(BoolVc::cell(references_async.contains(&true))) + } + + #[turbo_tasks::function] + pub(crate) async fn module_options(self) -> Result { + if !*self.is_async().await? { + return Ok(OptionAsyncModuleOptionsVc::cell(None)); + } + + Ok(OptionAsyncModuleOptionsVc::cell(Some(AsyncModuleOptions { + has_top_level_await: self.await?.has_top_level_await, + }))) + } +} + +#[turbo_tasks::value_impl] +impl CodeGenerateable for AsyncModule { + #[turbo_tasks::function] + async fn code_generation( + self_vc: AsyncModuleVc, + _context: EcmascriptChunkingContextVc, + ) -> Result { + let this = self_vc.await?; + let mut visitors = Vec::new(); + + if *self_vc.is_async().await? { + let reference_idents: Vec> = this + .references + .iter() + .map(|r| async { + let referenced_asset = r.get_referenced_asset().await?; + let ident = referenced_asset.get_ident().await?; + anyhow::Ok(ident) + }) + .try_join() + .await?; + + let reference_idents = reference_idents + .into_iter() + .flatten() + .collect::>(); + + if !reference_idents.is_empty() { + visitors.push(create_visitor!(visit_mut_program(program: &mut Program) { + add_async_dependency_handler(program, &reference_idents); + })); + } + } + + Ok(CodeGeneration { visitors }.into()) + } +} + +fn add_async_dependency_handler(program: &mut Program, idents: &IndexSet) { + let idents = idents + .iter() + .map(|ident| Ident::new(ident.clone().into(), DUMMY_SP)) + .collect::>(); + + let stmt = quote!( + "var __turbopack_async_dependencies__ = __turbopack_handle_async_dependencies__($deps);" + as Stmt, + deps: Expr = Expr::Array(ArrayLit { + span: DUMMY_SP, + elems: idents + .iter() + .map(|ident| { Some(Expr::Ident(ident.clone()).into()) }) + .collect(), + }), + ); + + insert_hoisted_stmt(program, stmt); + + let stmt = quote!( + "($deps = __turbopack_async_dependencies__.then ? (await \ + __turbopack_async_dependencies__)() : __turbopack_async_dependencies__);" as Stmt, + deps: Pat = Pat::Array(ArrayPat { + span: DUMMY_SP, + elems: idents + .into_iter() + .map(|ident| { Some(ident.into()) }) + .collect(), + optional: false, + type_ann: None, + }), + ); + + insert_hoisted_stmt(program, stmt); +} diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index 5031e548523135..4058957571fbb0 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -5,7 +5,10 @@ use swc_core::{ ecma::ast::{Expr, ExprStmt, Ident, Lit, Module, ModuleItem, Program, Script, Stmt}, quote, }; -use turbo_tasks::{primitives::StringVc, Value, ValueToString, ValueToStringVc}; +use turbo_tasks::{ + primitives::{BoolVc, StringVc}, + Value, ValueToString, ValueToStringVc, +}; use turbopack_core::{ asset::Asset, chunk::{ @@ -116,16 +119,6 @@ impl EsmAssetReference { #[turbo_tasks::value_impl] impl EsmAssetReferenceVc { - #[turbo_tasks::function] - pub(super) async fn get_referenced_asset(self) -> Result { - let this = self.await?; - - Ok(ReferencedAssetVc::from_resolve_result( - self.resolve_reference(), - this.request, - )) - } - #[turbo_tasks::function] pub fn new( origin: ResolveOriginVc, @@ -140,6 +133,31 @@ impl EsmAssetReferenceVc { export_name, }) } + + #[turbo_tasks::function] + pub(crate) async fn get_referenced_asset(self) -> Result { + let this = self.await?; + + Ok(ReferencedAssetVc::from_resolve_result( + self.resolve_reference(), + this.request, + )) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async(self) -> Result { + let asset = self.get_referenced_asset().await?; + + let placeable = match &*asset { + ReferencedAsset::Some(placeable) => placeable, + // TODO(WEB-1259): we need to detect if external modules are esm + ReferencedAsset::OriginalReferenceTypeExternal(_) | ReferencedAsset::None => { + return Ok(BoolVc::cell(false)); + } + }; + + Ok(placeable.get_async_module_options().is_async()) + } } #[turbo_tasks::value_impl] diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index cebab8e317b857..88e26d1ee28b81 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -1,4 +1,5 @@ pub mod amd; +pub mod async_module; pub mod cjs; pub mod constant_condition; pub mod constant_value; @@ -45,7 +46,7 @@ use swc_core::{ }, }; use turbo_tasks::{ - primitives::{BoolVc, RegexVc}, + primitives::{BoolVc, RegexVc, StringVc}, TryJoinIterExt, Value, }; use turbo_tasks_fs::{FileJsonContent, FileSystemPathVc}; @@ -53,7 +54,7 @@ use turbopack_core::{ asset::{Asset, AssetVc}, compile_time_info::{CompileTimeInfoVc, FreeVarReference}, error::PrettyPrintError, - issue::{IssueSourceVc, OptionIssueSourceVc}, + issue::{analyze::AnalyzeIssue, IssueSeverity, IssueSourceVc, OptionIssueSourceVc}, reference::{AssetReferenceVc, AssetReferencesVc, SourceMapReferenceVc}, reference_type::{CommonJsReferenceSubType, ReferenceType}, resolve::{ @@ -118,6 +119,7 @@ use crate::{ }, magic_identifier, references::{ + async_module::{AsyncModule, OptionAsyncModuleOptionsVc}, cjs::{ CjsRequireAssetReferenceVc, CjsRequireCacheAccess, CjsRequireResolveAssetReferenceVc, }, @@ -136,7 +138,7 @@ pub struct AnalyzeEcmascriptModuleResult { pub references: AssetReferencesVc, pub code_generation: CodeGenerateablesVc, pub exports: EcmascriptExportsVc, - pub has_top_level_await: bool, + pub async_module_options: OptionAsyncModuleOptionsVc, /// `true` when the analysis was successful. pub successful: bool, } @@ -173,7 +175,7 @@ pub(crate) struct AnalyzeEcmascriptModuleResultBuilder { references: IndexSet, code_gens: Vec, exports: EcmascriptExports, - has_top_level_await: bool, + async_module_options: OptionAsyncModuleOptionsVc, successful: bool, } @@ -183,7 +185,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { references: IndexSet::new(), code_gens: Vec::new(), exports: EcmascriptExports::None, - has_top_level_await: false, + async_module_options: OptionAsyncModuleOptionsVc::cell(None), successful: false, } } @@ -222,9 +224,9 @@ impl AnalyzeEcmascriptModuleResultBuilder { self.exports = exports; } - /// Sets whether the analysed module has a top level await. - pub fn set_top_level_await(&mut self, top_level_await: bool) { - self.has_top_level_await = top_level_await; + /// Sets the analysis result ES export. + pub fn set_async_module_options(&mut self, options: OptionAsyncModuleOptionsVc) { + self.async_module_options = options; } /// Sets whether the analysis was successful. @@ -254,7 +256,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { references: AssetReferencesVc::cell(references), code_generation: CodeGenerateablesVc::cell(self.code_gens), exports: self.exports.into(), - has_top_level_await: self.has_top_level_await, + async_module_options: self.async_module_options, successful: self.successful, }, )) @@ -450,11 +452,6 @@ pub(crate) async fn analyze_ecmascript_module( }), ); - let has_top_level_await = - set_handler_and_globals(&handler, globals, || has_top_level_await(program)); - - analysis.set_top_level_await(has_top_level_await); - let mut var_graph = set_handler_and_globals(&handler, globals, || create_graph(program, eval_context)); @@ -568,6 +565,10 @@ pub(crate) async fn analyze_ecmascript_module( } } + let top_level_await_span = + set_handler_and_globals(&handler, globals, || has_top_level_await(program)); + let has_top_level_await = top_level_await_span.is_some(); + let exports = if !esm_exports.is_empty() || !esm_star_exports.is_empty() { if matches!(specified_type, SpecifiedModuleType::CommonJs) { SpecifiedModuleTypeIssue { @@ -579,15 +580,31 @@ pub(crate) async fn analyze_ecmascript_module( .emit(); } + let async_module = AsyncModule { + references: import_references.iter().copied().collect(), + has_top_level_await, + } + .cell(); + analysis.set_async_module_options(async_module.module_options()); + let esm_exports: EsmExportsVc = EsmExports { exports: esm_exports, star_exports: esm_star_exports, } .cell(); + analysis.add_code_gen(esm_exports); + analysis.add_code_gen(async_module); EcmascriptExports::EsmExports(esm_exports) } else if matches!(specified_type, SpecifiedModuleType::EcmaScript) { + let async_module = AsyncModule { + references: import_references.iter().copied().collect(), + has_top_level_await, + } + .cell(); + analysis.set_async_module_options(async_module.module_options()); + match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => { SpecifiedModuleTypeIssue { @@ -597,6 +614,9 @@ pub(crate) async fn analyze_ecmascript_module( .cell() .as_issue() .emit(); + + analysis.add_code_gen(async_module); + EcmascriptExports::EsmExports( EsmExports { exports: Default::default(), @@ -608,30 +628,63 @@ pub(crate) async fn analyze_ecmascript_module( DetectedDynamicExportType::Namespace => EcmascriptExports::DynamicNamespace, DetectedDynamicExportType::Value => EcmascriptExports::Value, DetectedDynamicExportType::UsingModuleDeclarations - | DetectedDynamicExportType::None => EcmascriptExports::EsmExports( - EsmExports { - exports: Default::default(), - star_exports: Default::default(), - } - .cell(), - ), + | DetectedDynamicExportType::None => { + analysis.add_code_gen(async_module); + + EcmascriptExports::EsmExports( + EsmExports { + exports: Default::default(), + star_exports: Default::default(), + } + .cell(), + ) + } } } else { match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => EcmascriptExports::CommonJs, DetectedDynamicExportType::Namespace => EcmascriptExports::DynamicNamespace, DetectedDynamicExportType::Value => EcmascriptExports::Value, - DetectedDynamicExportType::UsingModuleDeclarations => EcmascriptExports::EsmExports( - EsmExports { - exports: Default::default(), - star_exports: Default::default(), + DetectedDynamicExportType::UsingModuleDeclarations => { + let async_module = AsyncModule { + references: import_references.iter().copied().collect(), + has_top_level_await, } - .cell(), - ), + .cell(); + analysis.add_code_gen(async_module); + analysis.set_async_module_options(async_module.module_options()); + + EcmascriptExports::EsmExports( + EsmExports { + exports: Default::default(), + star_exports: Default::default(), + } + .cell(), + ) + } DetectedDynamicExportType::None => EcmascriptExports::None, } }; + if let Some(span) = top_level_await_span { + if !matches!(exports, EcmascriptExports::EsmExports(_)) { + AnalyzeIssue { + code: None, + category: StringVc::cell("analyze".to_string()), + message: StringVc::cell( + "top level await is only supported in ESM modules.".to_string(), + ), + source_ident: source.ident(), + severity: IssueSeverity::Error.into(), + source: Some(issue_source(source, span)), + title: StringVc::cell("unexpected top level await".to_string()), + } + .cell() + .as_issue() + .emit(); + } + } + analysis.set_exports(exports); let effects = take(&mut var_graph.effects); diff --git a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index 94b4c8bcbbde4c..dd84d89698419a 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -11,7 +11,7 @@ use super::{asset::EcmascriptModulePartAssetVc, part_of_module, split_module}; use crate::{ chunk::{ EcmascriptChunkItem, EcmascriptChunkItemContentVc, EcmascriptChunkItemVc, - EcmascriptChunkingContextVc, + EcmascriptChunkPlaceable, EcmascriptChunkingContextVc, }, EcmascriptModuleContentVc, }; @@ -56,7 +56,13 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { availability_info, ); - Ok(EcmascriptChunkItemContentVc::new(content, this.context)) + let async_module_options = module.full_module.get_async_module_options(); + + Ok(EcmascriptChunkItemContentVc::new( + content, + this.context, + async_module_options, + )) } #[turbo_tasks::function] diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js new file mode 100644 index 00000000000000..0f2170c5a2d335 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js @@ -0,0 +1,28 @@ +// import() doesn't care about whether a module is an async module or not +const UserApi = import("./UserAPI.js"); + +export const CreateUserAction = async (name) => { + console.log("Creating user", name); + // These are normal awaits, because they are in an async function + const { createUser } = await UserApi; + await createUser(name); +}; + +// You can place import() where you like +// Placing it at top-level will start loading and evaluating on +// module evaluation. +// see CreateUserAction above +// Here: Connecting to the DB starts when the application starts +// Placing it inside of an (async) function will start loading +// and evaluating when the function is called for the first time +// which basically makes it lazy-loaded. +// see AlternativeCreateUserAction below +// Here: Connecting to the DB starts when AlternativeCreateUserAction +// is called +export const AlternativeCreateUserAction = async (name) => { + const { createUser } = await import("./UserAPI.js"); + await createUser(name); +}; + +// Note: Using await import() at top-level doesn't make much sense +// except in rare cases. It will import modules sequentially. diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md new file mode 100644 index 00000000000000..723f730dc51101 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md @@ -0,0 +1,2 @@ +Adapted from webpack +https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/examples/top-level-await/README.md diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js new file mode 100644 index 00000000000000..810fe24f9aa7f5 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js @@ -0,0 +1,7 @@ +import { dbCall } from "./db-connection.js"; + +export const createUser = async (name) => { + const command = `CREATE USER ${name}`; + // This is a normal await, because it's in an async function + await dbCall({ command }); +}; diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js new file mode 100644 index 00000000000000..412eee71b72cf5 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js @@ -0,0 +1,18 @@ +const connectToDB = async (url) => { + console.log("connecting to db", url); + await new Promise((r) => setTimeout(r, 1000)); +}; + +// This is a top-level-await +await connectToDB("my-sql://example.com"); + +export const dbCall = async (data) => { + console.log("dbCall", data); + // This is a normal await, because it's in an async function + await new Promise((r) => setTimeout(r, 100)); + return "fake data"; +}; + +export const close = () => { + console.log("closes the DB connection"); +}; diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js new file mode 100644 index 00000000000000..db6ef5c78f9a9d --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js @@ -0,0 +1,6 @@ +import { CreateUserAction } from "./Actions.js"; + +(async () => { + await CreateUserAction("John"); + console.log("created user John"); +})(); diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js new file mode 100644 index 00000000000000..0695bab5349485 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js @@ -0,0 +1,48 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, a: __turbopack_async_module__, k: __turbopack_refresh__ }) => (() => { + +__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try {__turbopack_esm__({ + "close": ()=>close, + "dbCall": ()=>dbCall +}); +const connectToDB = async (url)=>{ + console.log("connecting to db", url); + await new Promise((r)=>setTimeout(r, 1000)); +}; +await connectToDB("my-sql://example.com"); +const dbCall = async (data)=>{ + console.log("dbCall", data); + await new Promise((r)=>setTimeout(r, 100)); + return "fake data"; +}; +const close = ()=>{ + console.log("closes the DB connection"); +}; +__turbopack_async_result__(); +} catch(e) { __turbopack_async_result__(e); } }, true); +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, a: __turbopack_async_module__, k: __turbopack_refresh__ }) => (() => { + +__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try {__turbopack_esm__({ + "createUser": ()=>createUser +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js (ecmascript)"); +var __turbopack_async_dependencies__ = __turbopack_handle_async_dependencies__([ + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__ +]); +[__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__] = __turbopack_async_dependencies__.then ? (await __turbopack_async_dependencies__)() : __turbopack_async_dependencies__; +"__TURBOPACK__ecmascript__hoisting__location__"; +; +const createUser = async (name)=>{ + const command = `CREATE USER ${name}`; + await __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__["dbCall"]({ + command + }); +}; +__turbopack_async_result__(); +} catch(e) { __turbopack_async_result__(e); } }, false); +})()), +}]); + +//# sourceMappingURL=crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map new file mode 100644 index 00000000000000..fada634db8b2e3 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sections": [ + {"offset": {"line": 4, "column": 113}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js"],"sourcesContent":["const connectToDB = async (url) => {\n console.log(\"connecting to db\", url);\n await new Promise((r) => setTimeout(r, 1000));\n};\n\n// This is a top-level-await\nawait connectToDB(\"my-sql://example.com\");\n\nexport const dbCall = async (data) => {\n console.log(\"dbCall\", data);\n // This is a normal await, because it's in an async function\n await new Promise((r) => setTimeout(r, 100));\n return \"fake data\";\n};\n\nexport const close = () => {\n console.log(\"closes the DB connection\");\n};\n"],"names":[],"mappings":";;;;AAAA,MAAM,cAAc,OAAO;IACzB,QAAQ,GAAG,CAAC,oBAAoB;IAChC,MAAM,IAAI,QAAQ,CAAC,IAAM,WAAW,GAAG;AACzC;AAGA,MAAM,YAAY;AAEX,MAAM,SAAS,OAAO;IAC3B,QAAQ,GAAG,CAAC,UAAU;IAEtB,MAAM,IAAI,QAAQ,CAAC,IAAM,WAAW,GAAG;IACvC,OAAO;AACT;AAEO,MAAM,QAAQ;IACnB,QAAQ,GAAG,CAAC;AACd"}}, + {"offset": {"line": 21, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 26, "column": 113}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js"],"sourcesContent":["import { dbCall } from \"./db-connection.js\";\n\nexport const createUser = async (name) => {\n const command = `CREATE USER ${name}`;\n // This is a normal await, because it's in an async function\n await dbCall({ command });\n};\n"],"names":[],"mappings":";;;;;;;;;;AAEO,MAAM,aAAa,OAAO;IAC/B,MAAM,UAAU,CAAC,YAAY,EAAE,KAAK,CAAC;IAErC,MAAM,uMAAO;QAAE;IAAQ;AACzB"}}, + {"offset": {"line": 42, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js new file mode 100644 index 00000000000000..8c05e55adcc789 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js @@ -0,0 +1,11 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js", + {}, +]); +(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js", + "chunks": [ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js" + ], + "source": "dynamic" +}); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js new file mode 100644 index 00000000000000..bed5a724b7d384 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js @@ -0,0 +1,11 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js", + {}, +]); +(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js", + "chunks": [ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js" + ], + "source": "dynamic" +}); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js new file mode 100644 index 00000000000000..2b49a61144a470 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js @@ -0,0 +1,16 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname }) => (() => { + +__turbopack_export_value__([ + { + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js", + "included": [ + "[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript)" + ] + }, + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js" +]); + +})()), +}]); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map new file mode 100644 index 00000000000000..a12b83d3337ca5 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map @@ -0,0 +1,4 @@ +{ + "version": 3, + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js new file mode 100644 index 00000000000000..976c8cdd3f9cf0 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js @@ -0,0 +1,11 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js", + {}, +]); +(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js", + "chunks": [ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js" + ], + "source": "entry" +}); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js new file mode 100644 index 00000000000000..cb2812fd9ae057 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js @@ -0,0 +1,47 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk, loader)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname }) => (() => { + +__turbopack_export_value__((__turbopack_import__) => { + return Promise.all([{"path":"output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js","included":["[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk)"]},"output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js"].map((chunk) => __turbopack_load__(chunk))).then(() => { + return __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk)"); + }).then((chunks) => { + return Promise.all(chunks.map((chunk) => __turbopack_load__(chunk))); + }).then(() => { + return __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript)"); + }); +}); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, k: __turbopack_refresh__ }) => (() => { + +__turbopack_esm__({ + "AlternativeCreateUserAction": ()=>AlternativeCreateUserAction, + "CreateUserAction": ()=>CreateUserAction +}); +const UserApi = __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk, loader)")(__turbopack_import__); +const CreateUserAction = async (name)=>{ + console.log("Creating user", name); + const { createUser } = await UserApi; + await createUser(name); +}; +const AlternativeCreateUserAction = async (name)=>{ + const { createUser } = await __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk, loader)")(__turbopack_import__); + await createUser(name); +}; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, k: __turbopack_refresh__ }) => (() => { + +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$Actions$2e$js__$28$ecmascript$29$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js (ecmascript)"); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +(async ()=>{ + await __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$Actions$2e$js__$28$ecmascript$29$__["CreateUserAction"]("John"); + console.log("created user John"); +})(); + +})()), +}]); + +//# sourceMappingURL=crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map new file mode 100644 index 00000000000000..071ae668d4723c --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sections": [ + {"offset": {"line": 17, "column": 0}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js"],"sourcesContent":["// import() doesn't care about whether a module is an async module or not\nconst UserApi = import(\"./UserAPI.js\");\n\nexport const CreateUserAction = async (name) => {\n console.log(\"Creating user\", name);\n // These are normal awaits, because they are in an async function\n const { createUser } = await UserApi;\n await createUser(name);\n};\n\n// You can place import() where you like\n// Placing it at top-level will start loading and evaluating on\n// module evaluation.\n// see CreateUserAction above\n// Here: Connecting to the DB starts when the application starts\n// Placing it inside of an (async) function will start loading\n// and evaluating when the function is called for the first time\n// which basically makes it lazy-loaded.\n// see AlternativeCreateUserAction below\n// Here: Connecting to the DB starts when AlternativeCreateUserAction\n// is called\nexport const AlternativeCreateUserAction = async (name) => {\n const { createUser } = await import(\"./UserAPI.js\");\n await createUser(name);\n};\n\n// Note: Using await import() at top-level doesn't make much sense\n// except in rare cases. It will import modules sequentially.\n"],"names":[],"mappings":";;;;AACA,MAAM,UAAU;AAET,MAAM,mBAAmB,OAAO;IACrC,QAAQ,GAAG,CAAC,iBAAiB;IAE7B,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM;IAC7B,MAAM,WAAW;AACnB;AAaO,MAAM,8BAA8B,OAAO;IAChD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM;IAC7B,MAAM,WAAW;AACnB"}}, + {"offset": {"line": 31, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js"],"sourcesContent":["import { CreateUserAction } from \"./Actions.js\";\n\n(async () => {\n await CreateUserAction(\"John\");\n console.log(\"created user John\");\n})();\n"],"names":[],"mappings":";;;AAEC,CAAA;IACC,MAAM,wMAAiB;IACvB,QAAQ,GAAG,CAAC;AACd,CAAA"}}, + {"offset": {"line": 42, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js new file mode 100644 index 00000000000000..7906e87cf8af44 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js @@ -0,0 +1,6 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js", + {}, + {"otherChunks":[{"path":"output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js","included":["[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js (ecmascript)"]}],"runtimeModuleIds":["[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js (ecmascript)"]} +]); +// Dummy runtime \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map new file mode 100644 index 00000000000000..a12b83d3337ca5 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map @@ -0,0 +1,4 @@ +{ + "version": 3, + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js b/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js index 000224a78745d2..4994c0316cad44 100644 --- a/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js +++ b/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js @@ -1,6 +1,6 @@ (globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js", { -"[project]/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/input/index.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, x: __turbopack_external_require__, k: __turbopack_refresh__ }) => (() => { +"[project]/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/input/index.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, k: __turbopack_refresh__ }) => (() => { var __TURBOPACK__external__node$3a$fs__ = __turbopack_external_require__("node:fs", true); "__TURBOPACK__ecmascript__hoisting__location__"; diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index eea9eef065bbd0..84e8aead73d17b 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -24,14 +24,14 @@ function esm(exports, getters) { }); } } -function esmExport(module, getters) { - esm(module.namespaceObject = module.exports, getters); +function esmExport(module, exports, getters) { + esm(module.namespaceObject = exports, getters); } -function dynamicExport(module, object) { +function dynamicExport(module, exports, object) { let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.namespaceObject = new Proxy(module.exports, { + module.namespaceObject = new Proxy(exports, { get (target, prop) { if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { return Reflect.get(target, prop); @@ -88,6 +88,25 @@ function esmImport(sourceModule, id) { if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; + if (isPromise(raw)) { + const promise = raw.then((e)=>{ + const ns = {}; + interopEsm(e, ns, e.__esModule); + return ns; + }); + module.namespaceObject = Object.assign(promise, { + get [turbopackExports] () { + return raw[turbopackExports]; + }, + get [turbopackQueues] () { + return raw[turbopackQueues]; + }, + get [turbopackError] () { + return raw[turbopackError]; + } + }); + return module.namespaceObject; + } const ns = module.namespaceObject = {}; interopEsm(raw, ns, raw.__esModule); return ns; @@ -120,6 +139,112 @@ function requireContext(sourceModule, map) { function getChunkPath(chunkData) { return typeof chunkData === "string" ? chunkData : chunkData.path; } +function isPromise(maybePromise) { + return maybePromise != null && typeof maybePromise === "object" && "then" in maybePromise && typeof maybePromise.then === "function"; +} +function createPromise() { + let resolve; + let reject; + const promise = new Promise((res, rej)=>{ + reject = rej; + resolve = res; + }); + return { + promise, + resolve: resolve, + reject: reject + }; +} +const turbopackQueues = Symbol("turbopack queues"); +const turbopackExports = Symbol("turbopack exports"); +const turbopackError = Symbol("turbopack error"); +function resolveQueue(queue) { + if (queue && !queue.resolved) { + queue.resolved = true; + queue.forEach((fn)=>fn.queueCount--); + queue.forEach((fn)=>fn.queueCount-- ? fn.queueCount++ : fn()); + } +} +function wrapDeps(deps) { + return deps.map((dep)=>{ + if (dep !== null && typeof dep === "object") { + if (turbopackQueues in dep) return dep; + if (isPromise(dep)) { + const queue = Object.assign([], { + resolved: false + }); + const obj = { + [turbopackExports]: {}, + [turbopackQueues]: (fn)=>fn(queue) + }; + dep.then((res)=>{ + obj[turbopackExports] = res; + resolveQueue(queue); + }, (err)=>{ + obj[turbopackError] = err; + resolveQueue(queue); + }); + return obj; + } + } + const ret = { + [turbopackExports]: dep, + [turbopackQueues]: ()=>{} + }; + return ret; + }); +} +function asyncModule(module, body, hasAwait) { + const queue = hasAwait ? Object.assign([], { + resolved: true + }) : undefined; + const depQueues = new Set(); + const exports = module.exports; + const { resolve, reject, promise: rawPromise } = createPromise(); + const promise = Object.assign(rawPromise, { + [turbopackExports]: exports, + [turbopackQueues]: (fn)=>{ + queue && fn(queue); + depQueues.forEach(fn); + promise["catch"](()=>{}); + } + }); + module.exports = promise; + function handleAsyncDependencies(deps) { + const currentDeps = wrapDeps(deps); + const getResult = ()=>currentDeps.map((d)=>{ + if (d[turbopackError]) throw d[turbopackError]; + return d[turbopackExports]; + }); + const { promise, resolve } = createPromise(); + const fn = Object.assign(()=>resolve(getResult), { + queueCount: 0 + }); + function fnQueue(q) { + if (q !== queue && !depQueues.has(q)) { + depQueues.add(q); + if (q && !q.resolved) { + fn.queueCount++; + q.push(fn); + } + } + } + currentDeps.map((dep)=>dep[turbopackQueues](fnQueue)); + return fn.queueCount ? promise : getResult(); + } + function asyncResult(err) { + if (err) { + reject(promise[turbopackError] = err); + } else { + resolve(exports); + } + resolveQueue(queue); + } + body(handleAsyncDependencies, asyncResult); + if (queue) { + queue.resolved = false; + } +} ; var SourceType; (function(SourceType) { @@ -214,13 +339,14 @@ function instantiateModule(id, source) { moduleCache[id] = module1; try { moduleFactory.call(module1.exports, { + a: asyncModule.bind(null, module1), e: module1.exports, r: commonJsRequire.bind(null, module1), x: externalRequire, f: requireContext.bind(null, module1), i: esmImport.bind(null, module1), s: esm.bind(null, module1.exports), - j: dynamicExport.bind(null, module1), + j: dynamicExport.bind(null, module1, module1.exports), v: exportValue.bind(null, module1), n: exportNamespace.bind(null, module1), m: module1, diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index c4050c052c4abb..38e6bf92a3358f 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -1,6 +1,6 @@ { "version": 3, "sections": [ - {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/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 @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?: EsmNamespaceObject;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n keys(): ModuleId[];\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\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\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(module: Module, getters: Record any>) {\n esm((module.namespaceObject = module.exports), getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(module: Module, object: Record) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.namespaceObject = new Proxy(module.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 reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\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 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 getters: { [s: string]: () => any } = Object.create(null);\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 getters[key] = createGetter(raw, key);\n }\n }\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n esm(ns, getters);\n}\n\nfunction esmImport(sourceModule: Module, id: ModuleId): EsmNamespaceObject {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n if (module.namespaceObject) return module.namespaceObject;\n const raw = module.exports;\n const ns = (module.namespaceObject = {});\n interopEsm(raw, ns, raw.__esModule);\n return ns;\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\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"],"names":[],"mappings":";AAkBA,MAAM,qBAAqB,OAAO;;;;;AAqClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UAAU,MAAc,EAAE,OAAkC;IACnE,IAAK,OAAO,eAAe,GAAG,OAAO,OAAO,EAAG;AACjD;AAKA,SAAS,cAAc,MAAc,EAAE,MAA2B;IAChE,IAAI,oBAAoB,MAAM,CAAC,mBAAmB;IAClD,IAAI,CAAC,mBAAmB;QACtB,oBAAoB,MAAM,CAAC,mBAAmB,GAAG,EAAE;QACnD,OAAO,eAAe,GAAG,IAAI,MAAM,OAAO,OAAO,EAAE;YACjD,KAAI,MAAM,EAAE,IAAI;gBACd,IACE,eAAe,IAAI,CAAC,QAAQ,SAC5B,SAAS,aACT,SAAS,cACT;oBACA,OAAO,QAAQ,GAAG,CAAC,QAAQ;gBAC7B;gBACA,KAAK,MAAM,OAAO,kBAAoB;oBACpC,MAAM,QAAQ,QAAQ,GA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AU,YAAoB,EAAE,EAAY;IACnD,MAAM,SAAS,iCAAiC,IAAI;IACpD,IAAI,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK;IACpC,IAAI,OAAO,eAAe,EAAE,OAAO,OAAO,eAAe;IACzD,MAAM,MAAM,OAAO,OAAO;IAC1B,MAAM,KAAM,OAAO,eAAe,GAAG,CAAC;IACtC,WAAW,KAAK,IAAI,IAAI,UAAU;IAClC,OAAO;AACT;AAEA,SAAS,gBAAgB,YAAoB,EAAE,EAAY;IACzD,MAAM,SAAS,iCAAiC,IAAI;IACpD,IAAI,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK;IACpC,OAAO,OAAO,OAAO;AACvB;AAIA,SAAS,eACP,YAAoB,EACpB,GAAsB;IAEtB,SAAS,eAAe,EAAY;QAClC,MAAM,QAAQ,GAAG,CAAC,GAAG;QAErB,IAAI,CAAC,OAAO;YACV,MAAM,IAAI,MACR,CAAC,OAAO,EAAE,GAAG,8DAA8D,CAAC;QAEhF;QAEA,OAAO,uBAAuB,OAAO;IACvC;IAEA,eAAe,IAAI,GAAG;QACpB,OAAO,OAAO,IAAI,CAAC;IACrB;IAEA,eAAe,OAAO,GAAG,CAAC;QACxB,MAAM,QAAQ,GAAG,CAAC,GAAG;QAErB,IAAI,CAAC,OAAO;YACV,MAAM,IAAI,MACR,CAAC,OAAO,EAAE,GAAG,8DAA8D,CAAC;QAEhF;QAEA,OAAO,MAAM,EAAE;IACjB;IAEA,OAAO;AACT;AAKA,SAAS,aAAa,SAAoB;IACxC,OAAO,OAAO,cAAc,WAAW,YAAY,UAAU,IAAI;AACnE"}}, - {"offset": {"line": 122, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n };\n\ninterface RequireContextEntry {\n external: boolean;\n}\n\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\n\ninterface TurbopackNodeBuildContext {\n e: Module[\"exports\"];\n r: CommonJsRequire;\n x: ExternalRequire;\n f: RequireContextFactory;\n i: EsmImport;\n s: EsmExport;\n j: typeof dynamicExport;\n v: ExportValue;\n n: typeof exportNamespace;\n m: Module;\n c: ModuleCache;\n l: LoadChunk;\n g: typeof globalThis;\n __dirname: string;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(id);\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`);\n }\n if (!esm || raw.__esModule) {\n return raw;\n }\n const ns = {};\n interopEsm(raw, ns, true);\n return ns;\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return;\n }\n\n const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[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 let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n };\n moduleCache[id] = module;\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n moduleFactory.call(module.exports, {\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\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/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\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 instantiateRuntimeModule(moduleId, chunkPath);\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAIA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GATG,eAAA;;;AAkDL,MAAM,OAAO,QAAQ;AACrB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAE9C,MAAM,k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M,GAAG;IAChB,IAAI,QAAO,eAAe,IAAI,QAAO,OAAO,KAAK,QAAO,eAAe,EAAE;QAEvE,WAAW,QAAO,OAAO,EAAE,QAAO,eAAe;IACnD;IAEA,OAAO;AACT;AAKA,SAAS,iCACP,EAAY,EACZ,YAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,GAAG;IAE9B,IAAI,aAAa,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG;QAC5C,aAAa,QAAQ,CAAC,IAAI,CAAC;IAC7B;IAEA,IAAI,SAAQ;QACV,IAAI,QAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,MAAM,WAAW,MAAM;QACvB,UAAU,aAAa,EAAE;IAC3B;AACF;AAKA,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,MAAM,WAAW,OAAO;QAAE;IAAU;AAC3E;AAKA,SAAS,8BACP,QAAkB,EAClB,SAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,SAAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] + {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/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 @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?: EsmNamespaceObject | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\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\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n esm((module.namespaceObject = exports), getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n 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 reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\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 getters: { [s: string]: () => any } = Object.create(null);\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 getters[key] = createGetter(raw, key);\n }\n }\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n esm(ns, getters);\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): EsmNamespaceObject | (Promise & AsyncModuleExt) {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n if (module.namespaceObject) return module.namespaceObject;\n const raw = module.exports;\n\n if (isPromise(raw)) {\n const promise = raw.then((e) => {\n const ns = {};\n interopEsm(e, ns, e.__esModule);\n return ns;\n });\n\n module.namespaceObject = Object.assign(promise, {\n get [turbopackExports]() {\n return raw[turbopackExports];\n },\n get [turbopackQueues]() {\n return raw[turbopackQueues];\n },\n get [turbopackError]() {\n return raw[turbopackError];\n },\n } satisfies AsyncModuleExt);\n\n return module.namespaceObject;\n }\n\n const ns = (module.namespaceObject = {});\n interopEsm(raw, ns, raw.__esModule);\n return ns;\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\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(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\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\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (turbopackQueues in dep) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\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 const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: 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 queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = promise;\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.resolved) {\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(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AAuClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAA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,CAAC,CAAC;gBACf,IAAI,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,eAAe;gBAC9C,OAAO,CAAC,CAAC,iBAAiB;YAC5B;QAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;QAE7B,MAAM,KAAmB,OAAO,MAAM,CAAC,IAAM,QAAQ,YAAY;YAC/D,YAAY;QACd;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, + {"offset": {"line": 247, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n };\n\ninterface RequireContextEntry {\n external: boolean;\n}\n\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n x: ExternalRequire;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(id);\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`);\n }\n if (!esm || raw.__esModule) {\n return raw;\n }\n const ns = {};\n interopEsm(raw, ns, true);\n return ns;\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return;\n }\n\n const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[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 let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n };\n moduleCache[id] = module;\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\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/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\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 instantiateRuntimeModule(moduleId, chunkPath);\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAIA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GATG,eAAA;;;AAqCL,MAAM,OAAO,QAAQ;AACrB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAE9C,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAE/C,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,gBACP,EAAY,EACZ,OAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAA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IAEA,IAAI,SAAQ;QACV,IAAI,QAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,MAAM,WAAW,MAAM;QACvB,UAAU,aAAa,EAAE;IAC3B;AACF;AAKA,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,MAAM,WAAW,OAAO;QAAE;IAAU;AAC3E;AAKA,SAAS,8BACP,QAAkB,EAClB,SAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,SAAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] } \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js index c6e9ea38899268..43a5aa2370d419 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js @@ -32,14 +32,14 @@ function esm(exports, getters) { }); } } -function esmExport(module, getters) { - esm(module.namespaceObject = module.exports, getters); +function esmExport(module, exports, getters) { + esm(module.namespaceObject = exports, getters); } -function dynamicExport(module, object) { +function dynamicExport(module, exports, object) { let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.namespaceObject = new Proxy(module.exports, { + module.namespaceObject = new Proxy(exports, { get (target, prop) { if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { return Reflect.get(target, prop); @@ -96,6 +96,25 @@ function esmImport(sourceModule, id) { if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; + if (isPromise(raw)) { + const promise = raw.then((e)=>{ + const ns = {}; + interopEsm(e, ns, e.__esModule); + return ns; + }); + module.namespaceObject = Object.assign(promise, { + get [turbopackExports] () { + return raw[turbopackExports]; + }, + get [turbopackQueues] () { + return raw[turbopackQueues]; + }, + get [turbopackError] () { + return raw[turbopackError]; + } + }); + return module.namespaceObject; + } const ns = module.namespaceObject = {}; interopEsm(raw, ns, raw.__esModule); return ns; @@ -128,6 +147,112 @@ function requireContext(sourceModule, map) { function getChunkPath(chunkData) { return typeof chunkData === "string" ? chunkData : chunkData.path; } +function isPromise(maybePromise) { + return maybePromise != null && typeof maybePromise === "object" && "then" in maybePromise && typeof maybePromise.then === "function"; +} +function createPromise() { + let resolve; + let reject; + const promise = new Promise((res, rej)=>{ + reject = rej; + resolve = res; + }); + return { + promise, + resolve: resolve, + reject: reject + }; +} +const turbopackQueues = Symbol("turbopack queues"); +const turbopackExports = Symbol("turbopack exports"); +const turbopackError = Symbol("turbopack error"); +function resolveQueue(queue) { + if (queue && !queue.resolved) { + queue.resolved = true; + queue.forEach((fn)=>fn.queueCount--); + queue.forEach((fn)=>fn.queueCount-- ? fn.queueCount++ : fn()); + } +} +function wrapDeps(deps) { + return deps.map((dep)=>{ + if (dep !== null && typeof dep === "object") { + if (turbopackQueues in dep) return dep; + if (isPromise(dep)) { + const queue = Object.assign([], { + resolved: false + }); + const obj = { + [turbopackExports]: {}, + [turbopackQueues]: (fn)=>fn(queue) + }; + dep.then((res)=>{ + obj[turbopackExports] = res; + resolveQueue(queue); + }, (err)=>{ + obj[turbopackError] = err; + resolveQueue(queue); + }); + return obj; + } + } + const ret = { + [turbopackExports]: dep, + [turbopackQueues]: ()=>{} + }; + return ret; + }); +} +function asyncModule(module, body, hasAwait) { + const queue = hasAwait ? Object.assign([], { + resolved: true + }) : undefined; + const depQueues = new Set(); + const exports = module.exports; + const { resolve, reject, promise: rawPromise } = createPromise(); + const promise = Object.assign(rawPromise, { + [turbopackExports]: exports, + [turbopackQueues]: (fn)=>{ + queue && fn(queue); + depQueues.forEach(fn); + promise["catch"](()=>{}); + } + }); + module.exports = promise; + function handleAsyncDependencies(deps) { + const currentDeps = wrapDeps(deps); + const getResult = ()=>currentDeps.map((d)=>{ + if (d[turbopackError]) throw d[turbopackError]; + return d[turbopackExports]; + }); + const { promise, resolve } = createPromise(); + const fn = Object.assign(()=>resolve(getResult), { + queueCount: 0 + }); + function fnQueue(q) { + if (q !== queue && !depQueues.has(q)) { + depQueues.add(q); + if (q && !q.resolved) { + fn.queueCount++; + q.push(fn); + } + } + } + currentDeps.map((dep)=>dep[turbopackQueues](fnQueue)); + return fn.queueCount ? promise : getResult(); + } + function asyncResult(err) { + if (err) { + reject(promise[turbopackError] = err); + } else { + resolve(exports); + } + resolveQueue(queue); + } + body(handleAsyncDependencies, asyncResult); + if (queue) { + queue.resolved = false; + } +} ; ; ; @@ -272,12 +397,13 @@ function instantiateModule(id, source) { try { runModuleExecutionHooks(module, (refresh)=>{ moduleFactory.call(module.exports, augmentContext({ + a: asyncModule.bind(null, module), e: module.exports, r: commonJsRequire.bind(null, module), f: requireContext.bind(null, module), i: esmImport.bind(null, module), - s: esmExport.bind(null, module), - j: dynamicExport.bind(null, module), + s: esmExport.bind(null, module, module.exports), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map index c7b62871d9e59c..1a109d522da727 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map @@ -1,8 +1,8 @@ { "version": 3, "sections": [ - {"offset": {"line": 9, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/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 @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?: EsmNamespaceObject;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n keys(): ModuleId[];\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\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\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(module: Module, getters: Record any>) {\n esm((module.namespaceObject = module.exports), getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(module: Module, object: Record) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.namespaceObject = new Proxy(module.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 reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\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 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 getters: { [s: string]: () => any } = Object.create(null);\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 getters[key] = createGetter(raw, key);\n }\n }\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n esm(ns, getters);\n}\n\nfunction esmImport(sourceModule: Module, id: ModuleId): EsmNamespaceObject {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n if (module.namespaceObject) return module.namespaceObject;\n const raw = module.exports;\n const ns = (module.namespaceObject = {});\n interopEsm(raw, ns, raw.__esModule);\n return ns;\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\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"],"names":[],"mappings":";AAkBA,MAAM,qBAAqB,OAAO;;;;;AAqClC,MAAM,iBAAiB,OAAO,SAAS,CAAC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,gBAAgB,YAAoB,EAAE,EAAY;IACzD,MAAM,SAAS,iCAAiC,IAAI;IACpD,IAAI,OAAO,KAAK,EAAE,MAAM,OAAO,KAAK;IACpC,OAAO,OAAO,OAAO;AACvB;AAIA,SAAS,eACP,YAAoB,EACpB,GAAsB;IAEtB,SAAS,eAAe,EAAY;QAClC,MAAM,QAAQ,GAAG,CAAC,GAAG;QAErB,IAAI,CAAC,OAAO;YACV,MAAM,IAAI,MACR,CAAC,OAAO,EAAE,GAAG,8DAA8D,CAAC;QAEhF;QAEA,OAAO,uBAAuB,OAAO;IACvC;IAEA,eAAe,IAAI,GAAG;QACpB,OAAO,OAAO,IAAI,CAAC;IACrB;IAEA,eAAe,OAAO,GAAG,CAAC;QACxB,MAAM,QAAQ,GAAG,CAAC,GAAG;QAErB,IAAI,CAAC,OAAO;YACV,MAAM,IAAI,MACR,CAAC,OAAO,EAAE,GAAG,8DAA8D,CAAC;QAEhF;QAEA,OAAO,MAAM,EAAE;IACjB;IAEA,OAAO;AACT;AAKA,SAAS,aAAa,SAAoB;IACxC,OAAO,OAAO,cAAc,WAAW,YAAY,UAAU,IAAI;AACnE"}}, - {"offset": {"line": 130, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* 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 @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext {\n e: Module[\"exports\"];\n r: CommonJsRequire;\n f: RequireContextFactory;\n i: EsmImport;\n s: EsmExport;\n j: typeof dynamicExport;\n v: ExportValue;\n n: typeof exportNamespace;\n m: Module;\n c: ModuleCache;\n l: LoadChunk;\n g: typeof globalThis;\n k: RefreshContext;\n __dirname: string;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\n};\n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[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 return Promise.all(modulesPromises);\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;\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 return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = 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(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, 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 return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[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 let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n const hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module),\n j: dynamicExport.bind(null, module),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\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/**\n * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\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\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Gets or instantiates a runtime module.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\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, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;IA6EA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;IATG,WAAA,WAcH,YAAS,KAAT;GAdG,eAAA;;AAwCL,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAK/C,MAAM,gBAAwC,IAAI;AAIlD,MAAM,iBAAwC,IAAI;AAIlD,MAAM,2BAA0C,IAAI;AAIpD,MAAM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;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, - {"offset": {"line": 930, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\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 // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\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 loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"/${chunkPath}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(\n `script[src=\"/${chunkPath}\"]`\n );\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"/${encodedChunkPath}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = `/${encodedChunkPath}`;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\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 (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = `/${chunkPath}`;\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 document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = `/${chunkPath}`;\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 document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval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AoB;QACrC,IAAI,UAAS,QAAQ,EAAE;YACrB,OAAO,UAAS,OAAO;QACzB;QAEA,IAAI,QAAO,IAAI,KAAK,WAAW,OAAO,EAAE;YAItC,IAAI,WAAU,QAAQ,CAAC,SAAS;gBAG9B,UAAS,OAAO;YAClB;YAMA,OAAO,UAAS,OAAO;QACzB;QAEA,IAAI,WAAU,QAAQ,CAAC,SAAS;YAC9B,MAAM,QAAO,SAAS,aAAa,CAAC;YACpC,MAAK,GAAG,GAAG;YACX,MAAK,IAAI,GAAG,CAAC,CAAC,EAAE,WAAU,CAAC;YAC3B,MAAK,OAAO,GAAG;gBACb,UAAS,MAAM;YACjB;YACA,MAAK,MAAM,GAAG;gBAGZ,UAAS,OAAO;YAClB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO,IAAI,WAAU,QAAQ,CAAC,QAAQ;YACpC,MAAM,UAAS,SAAS,aAAa,CAAC;YACtC,QAAO,GAAG,GAAG,CAAC,CAAC,EAAE,WAAU,CAAC;YAI5B,QAAO,OAAO,GAAG;gBACf,UAAS,MAAM;YACjB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,WAAU,CAAC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,EAAE,IAAI,CAAC;IACpD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, - {"offset": {"line": 1071, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] + {"offset": {"line": 9, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/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 @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?: EsmNamespaceObject | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\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\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n esm((module.namespaceObject = exports), getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n 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 reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\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 getters: { [s: string]: () => any } = Object.create(null);\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 getters[key] = createGetter(raw, key);\n }\n }\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n esm(ns, getters);\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): EsmNamespaceObject | (Promise & AsyncModuleExt) {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n if (module.namespaceObject) return module.namespaceObject;\n const raw = module.exports;\n\n if (isPromise(raw)) {\n const promise = raw.then((e) => {\n const ns = {};\n interopEsm(e, ns, e.__esModule);\n return ns;\n });\n\n module.namespaceObject = Object.assign(promise, {\n get [turbopackExports]() {\n return raw[turbopackExports];\n },\n get [turbopackQueues]() {\n return raw[turbopackQueues];\n },\n get [turbopackError]() {\n return raw[turbopackError];\n },\n } satisfies AsyncModuleExt);\n\n return module.namespaceObject;\n }\n\n const ns = (module.namespaceObject = {});\n interopEsm(raw, ns, raw.__esModule);\n return ns;\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\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(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\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\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (turbopackQueues in dep) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\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 const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: 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 queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = promise;\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.resolved) {\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(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AAuClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK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AU,OAAO,CAAC;YAClB,OAAO,CAAC,QAAQ,CAAC,KAAO;QAC1B;IACF;IAEA,OAAO,OAAO,GAAG;IAEjB,SAAS,wBAAwB,IAAW;QAC1C,MAAM,cAAc,SAAS;QAE7B,MAAM,YAAY,IAChB,YAAY,GAAG,CAAC,CAAC;gBACf,IAAI,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,eAAe;gBAC9C,OAAO,CAAC,CAAC,iBAAiB;YAC5B;QAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;QAE7B,MAAM,KAAmB,OAAO,MAAM,CAAC,IAAM,QAAQ,YAAY;YAC/D,YAAY;QACd;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, + {"offset": {"line": 255, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* 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 @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\n};\n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[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 return Promise.all(modulesPromises);\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;\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 return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = 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(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, 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 return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[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 let instantiationReason;\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`;\n break;\n case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n );\n }\n\n const hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\n });\n } catch (error) {\n module.error = error as any;\n throw error;\n }\n\n module.loaded = true;\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/**\n * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\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\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Gets or instantiates a runtime module.\n */\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\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, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;IAgEA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;IATG,WAAA,WAcH,YAAS,KAAT;GAdG,eAAA;;AAwCL,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AA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ClB,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAAC,SAAS,GAAG;QAC9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, + {"offset": {"line": 1056, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\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 // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\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 loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"/${chunkPath}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(\n `script[src=\"/${chunkPath}\"]`\n );\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"/${encodedChunkPath}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = `/${encodedChunkPath}`;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\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 (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = `/${chunkPath}`;\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 document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = `/${chunkPath}`;\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 document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAgBA,IAAI;AAEJ,SAAS,eAAe,QAAgC;IACtD,OAAO;AACT;AAEA,SAAS,uBACP,MAA0B,EAC1B,aAAoB;IAEpB,OAAO,gBAAgB,eAAc,OAAM,EAAE;AAC/C;AAEC,CAAA;IACC,UAAU;QACR,MAAM,eAAc,UAAS,EAAE,OAAM;YACnC,MAAM,YAAW,qBAAoB;YACrC,UAAS,OAAO;YAEhB,IAAI,WAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,mBAAkB,QAAO,WAAW,CAAE;gBAC/C,MAAM,kBAAiB,aAAa;gBAEpC,qBAAoB;YACtB;YAGA,MAAM,QAAQ,GAAG,CACf,QAAO,WAAW,CAAC,GAAG,CAAC,CAAC,kBACtB,UAAU;oBAAE,MAAM,WAAW,OAAO;oBAAE,WAAA;gBAAU,GAAG;YAIvD,IAAI,QAAO,gBAAgB,CAAC,MAAM,GAAG,GAAG;gBACtC,KAAK,MAAM,aAAY,QAAO,gBAAgB,CAAE;oBAC9C,8BAA8B,WAAU;gBAC1C;YACF;QACF;QAEA,WAAU,UAAS,EAAE,OAAM;YACzB,OAAO,aAAY,YAAW;QAChC;QAEA,aAAY,UAAS;YACnB,gBAAe;YAEf,IAAI,WAAU,QAAQ,CAAC,SAAS;gBAC9B,MAAM,SAAQ,SAAS,gBAAgB,CAAC,CAAC,YAAY,EAAE,WAAU,EAAE,CAAC;gBACpE,KAAK,MAAM,SAAQ,MAAM,IAAI,CAAC,QAAQ;oBACpC,MAAK,MAAM;gBACb;YACF,OAAO,IAAI,WAAU,QAAQ,CAAC,QAAQ;gBAKpC,MAAM,WAAU,SAAS,gBAAgB,CACvC,CAAC,aAAa,EAAE,W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