remote-components 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html/host.cjs +78 -0
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +78 -0
- package/dist/html/host.js.map +1 -1
- package/dist/internal/next/remote/render-server.cjs.map +1 -1
- package/dist/internal/next/remote/render-server.d.ts +13 -0
- package/dist/internal/next/remote/render-server.js.map +1 -1
- package/dist/next/host/client/index.cjs +41 -2
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.d.ts +13 -0
- package/dist/next/host/client/index.js +41 -2
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/react/index.cjs +41 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.js +41 -2
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/html/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared/error.ts","../../src/shared/webpack/next-client-pages-loader.ts","../../src/shared/webpack/shared-modules.ts","../../src/shared/utils/index.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/shared/client/static-loader.ts","../../src/shared/client/polyfill.tsx","../../src/html/host/runtime/webpack.ts","../../src/html/host/runtime/turbopack.ts","../../src/html/host/runtime/script.ts","../../src/html/host/index.tsx","../../src/shared/client/apply-origin.ts","../../src/shared/client/remote-component.ts","../../src/shared/client/component-loader.ts","../../src/shared/client/rsc.ts","../../src/shared/client/script-loader.ts","../../src/shared/ssr/fetch-headers.ts","../../src/html/host/runtime/index.ts"],"sourcesContent":["export class RemoteComponentsError extends Error {\n code = 'REMOTE_COMPONENTS_ERROR';\n\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RemoteComponentsError';\n }\n}\n\nexport function multipleRemoteComponentsError(url: string | undefined) {\n return new Error(\n `Multiple Remote Components found at \"${url}\". When a page exposes multiple Remote Components you must specify the \"name\" prop to select which one to load.`,\n );\n}\n\nexport function failedToFetchRemoteComponentError(url: string, error: unknown) {\n return new RemoteComponentsError(\n `Failed to fetch Remote Component from \"${url}\". Is the URL correct and accessible?`,\n { cause: error instanceof Error ? error : new Error(String(error)) },\n );\n}\n","import { RemoteComponentsError } from '../error';\n\n// module loader for Next.js Pages Router\nexport function nextClientPagesLoader(\n bundle: string,\n route: string,\n styleContainer: HTMLHeadElement | ShadowRoot | null = document.head,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n c?: Record<\n string | number,\n { id: string; parents: string[]; children: string[] }\n >;\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: 'turbopack' | 'webpack';\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // Next.js client pages loader reference storage\n __NEXT_P?: [\n (\n | [\n string,\n () => { default?: React.ComponentType<Record<string, unknown>> },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n ];\n // Next.js Pages Router CSS cache\n __remote_next_css__?: Record<string, ChildNode[]>;\n };\n\n // temporarily remove the original Next.js CSS loader\n const nextCssOriginal = document.querySelector(\n `[id=\"__next_css__DO_NOT_USE__\"]:not([data-bundle=\"${bundle}\"][data-route=\"${route}\"])`,\n );\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.removeChild(nextCssOriginal);\n }\n\n // create a new Next.js CSS loader element\n const nextCss = document.createElement('noscript');\n nextCss.id = '__next_css__DO_NOT_USE__';\n nextCss.setAttribute('data-bundle', bundle);\n nextCss.setAttribute('data-route', route);\n const nextCssEnd = document.createElement('noscript');\n nextCssEnd.id = '__next_css__DO_NOT_USE_END__';\n nextCssEnd.setAttribute('data-bundle', bundle);\n nextCssEnd.setAttribute('data-route', route);\n document.head.appendChild(nextCssEnd);\n document.head.appendChild(nextCss);\n\n // find the page component loader chunk\n const componentLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}!`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}!`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // find the app loader chunk\n const appLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // if we didn't find the component loader or app loader, throw an error\n if (!(componentLoaderChunk && appLoaderChunk)) {\n throw new RemoteComponentsError(\n `Next.js client pages loader not found in bundle \"${bundle}\".`,\n );\n }\n\n // temporarily store the original __NEXT_P reference\n // this is required to avoid conflicts with the Next.js client pages loader\n // which uses the same global variable to store the page components\n const __NEXT_P_ORIGINAL = self.__NEXT_P;\n const selfOriginal = self;\n delete selfOriginal.__NEXT_P;\n\n // load the component and app loader chunks\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? componentLoaderChunk\n : `[${bundle}] ${componentLoaderChunk}`,\n );\n if (\n typeof appLoaderChunk === 'string' ||\n (typeof appLoaderChunk === 'number' && appLoaderChunk !== -1)\n ) {\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? appLoaderChunk\n : `[${bundle}] ${appLoaderChunk}`,\n );\n }\n\n // if we have the __NEXT_P global variable, we can extract the component and app\n if (self.__NEXT_P) {\n const [, componentLoader] = self.__NEXT_P[0] ?? [\n undefined,\n () => ({ default: null }),\n ];\n const [, appLoader] = self.__NEXT_P[2] ?? [\n undefined,\n () => ({\n default: null,\n }),\n ];\n const { default: Component } = componentLoader();\n const { default: App } = appLoader();\n\n if (!self.__remote_next_css__) {\n // eslint-disable-next-line camelcase\n self.__remote_next_css__ = {};\n }\n\n if (!self.__remote_next_css__[bundle]) {\n // load the CSS files from the remote bundle\n const cssRE = /\\.s?css$/;\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {})\n .filter((id) => cssRE.test(id))\n .forEach((id) => {\n self.__remote_webpack_require__?.[bundle]?.(id);\n });\n\n Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {})\n .filter((path) => cssRE.test(path))\n .forEach((path) => {\n const id = self.__remote_webpack_module_map__?.[bundle]?.[path];\n if (id) {\n self.__remote_webpack_require__?.[bundle]?.(id);\n }\n });\n\n const elements = [];\n let node = nextCss.previousSibling;\n while (node && node !== nextCssEnd) {\n elements.push(node);\n node.remove();\n node = nextCss.previousSibling;\n }\n self.__remote_next_css__[bundle] = elements;\n }\n\n // if the styleContainer is provided, we need to move the styles to it\n if (styleContainer) {\n const elements = self.__remote_next_css__[bundle];\n elements.forEach((el) => {\n styleContainer.appendChild(el.cloneNode(true));\n });\n } else {\n // if no styleContainer is provided, we need to move the styles back to the head\n const elements = self.__remote_next_css__[bundle];\n elements.forEach((el) => {\n document.head.appendChild(el);\n });\n }\n\n // restore the original __NEXT_P reference\n delete self.__NEXT_P;\n self.__NEXT_P = __NEXT_P_ORIGINAL;\n\n // restore the original Next.js CSS loader\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.appendChild(nextCssOriginal);\n }\n\n nextCss.remove();\n nextCssEnd.remove();\n\n return { Component, App };\n }\n\n return { Component: null, App: null };\n}\n","// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // if we have the bundle\n if (self.__remote_webpack_require__?.[bundle]) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ??\n self.__remote_webpack_require__[bundle].m ??\n {},\n );\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n let ids = modulePaths.filter((p) => p === key);\n if (ids.length === 0) {\n ids = modulePaths.filter((p) => p.includes(key));\n }\n for (let id of ids) {\n const webpackBundle = self.__remote_webpack_require__[bundle];\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {\n id = `${self.__remote_webpack_module_map__[bundle][id]}`;\n }\n // create a mock module which exports the shared module\n webpackBundle.m[id] = (module) => {\n module.exports = value;\n };\n }\n }\n }\n }\n}\n","export function escapeString(str: string) {\n return str.replace(/[^a-z0-9]/g, '_');\n}\n\nexport const attrToProp = {\n fetchpriority: 'fetchPriority',\n crossorigin: 'crossOrigin',\n imagesrcset: 'imageSrcSet',\n imagesizes: 'imageSizes',\n srcset: 'srcSet',\n} as Record<string, string>;\n","import { escapeString } from '../utils';\n\nexport const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\nexport const RUNTIME_SCRIPT = 'script';\n\nexport const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\nexport function getBundleKey(bundle: string): string {\n return escapeString(bundle);\n}\n\nexport type Runtime =\n | typeof RUNTIME_WEBPACK\n | typeof RUNTIME_TURBOPACK\n | typeof RUNTIME_SCRIPT;\n","import { RemoteComponentsError } from '../error';\nimport {\n getBundleKey,\n REMOTE_COMPONENT_REGEX,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n type Runtime,\n} from './const';\nimport type { GlobalScope } from './types';\n\n/**\n * Sets up webpack runtime environment for remote components\n */\nexport async function setupWebpackRuntime(\n runtime: Runtime,\n scripts: { src: string | null }[] = [],\n url: URL = new URL(location.href),\n bundle?: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n): Promise<void> {\n const self = globalThis as GlobalScope;\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n self.__remote_bundle_url__[bundle ?? 'default'] = url;\n // eslint-disable-next-line camelcase\n self.__webpack_get_script_filename__ = () => null;\n\n if (\n typeof self.__webpack_require__ !== 'function' ||\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n if (\n !self.__original_webpack_require__ &&\n !self.__original_webpack_chunk_load__\n ) {\n // eslint-disable-next-line camelcase\n self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;\n // eslint-disable-next-line camelcase\n self.__original_webpack_require__ = self.__webpack_require__;\n }\n\n self.__webpack_chunk_load__ = createChunkLoader(runtime);\n self.__webpack_require__ = createModuleRequire(runtime);\n // eslint-disable-next-line camelcase\n self.__webpack_require_type__ = runtime;\n\n if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {\n const remoteBundle = bundle ?? 'default';\n self.__remote_webpack_require__[remoteBundle] =\n self.__webpack_require__ as (remoteId: string | number) => unknown;\n self.__remote_webpack_require__[remoteBundle].type = 'turbopack';\n }\n }\n // load all initial chunks when using Turbopack runtime\n if (runtime === RUNTIME_TURBOPACK) {\n await Promise.all(\n scripts.map((script) => {\n if (script.src) {\n return self.__webpack_chunk_load__?.(script.src, bundle);\n }\n return Promise.resolve(undefined);\n }),\n );\n }\n\n // initialize shared modules\n await initializeSharedModules(\n bundle ?? 'default',\n // include all core modules as shared\n {\n react: async () => (await import('react')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n ...shared,\n },\n remoteShared,\n );\n}\n\n/**\n * Creates chunk loader function for webpack runtime\n */\nfunction createChunkLoader(\n runtime: Runtime,\n): (chunkId: string) => Promise<unknown> | undefined {\n // eslint-disable-next-line camelcase\n return function __turbopack_chunk_load__(\n chunkId: string,\n scriptBundle?: string,\n ) {\n const self = globalThis as GlobalScope;\n const {\n bundle,\n id: path,\n prefix,\n } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {\n bundle: scriptBundle ?? '',\n id: chunkId,\n };\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : runtime;\n if (remoteRuntime === RUNTIME_WEBPACK) {\n // all scripts are already loaded for this remote\n return Promise.resolve(undefined);\n }\n\n const url = new URL(\n path\n ? `${prefix ?? ''}${path}`.replace(\n /(?<char>[^:])(?<double>\\/\\/)/g,\n '$1/',\n )\n : '/',\n self.__remote_bundle_url__?.[bundle ?? 'default'] ??\n new URL(location.origin),\n ).href;\n if (url.endsWith('.css')) {\n return;\n }\n\n if (!self.__remote_components_turbopack_chunk_loader_promise__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_chunk_loader_promise__ = {};\n }\n if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {\n return self.__remote_components_turbopack_chunk_loader_promise__[url];\n }\n\n self.__remote_components_turbopack_chunk_loader_promise__[url] =\n new Promise((resolve, reject) => {\n fetch(url)\n .then((res) => res.text())\n .then((code) => {\n if (code.includes('globalThis.TURBOPACK')) {\n return handleTurbopackChunk(code, bundle ?? '', url);\n }\n })\n .then(resolve)\n .catch(reject);\n });\n\n return self.__remote_components_turbopack_chunk_loader_promise__[url];\n };\n}\n\n/**\n * Handles Turbopack chunk loading\n */\nasync function handleTurbopackChunk(\n code: string,\n bundle: string,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (/importScripts\\(\\.\\.\\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {\n // remove preload links for this chunk\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n\n // replace global variables with bundle-specific ones\n const transformedCode = code\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`,\n )\n .replace(/__next_require__/g, `__${bundleKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${\n new URL(\n '.',\n new URL(\n url,\n self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin),\n ),\n ).href\n }$1$2.js.map`,\n );\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.setAttribute('data-turbopack-src', url);\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n script.remove();\n };\n script.onerror = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n script.remove();\n };\n document.head.appendChild(script);\n });\n const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkLists = [] as (Promise<unknown> | undefined)[];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n chunks.forEach((id: string) => {\n const chunkLoadResult = self.__webpack_chunk_load__?.(\n `[${bundle}] ${url.slice(0, url.indexOf('/_next'))}/_next/${id}`,\n );\n if (chunkLoadResult) {\n loadChunkLists.push(chunkLoadResult);\n }\n });\n }\n }\n if (loadChunkLists.length > 0) {\n await Promise.all(loadChunkLists);\n }\n}\n\n/**\n * Creates module require function for webpack runtime\n */\nfunction createModuleRequire(runtime: Runtime): (id: string) => unknown {\n return (id: string) => {\n const self = globalThis as GlobalScope;\n const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)\n ?.groups ?? {\n bundle: 'default',\n id,\n };\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : runtime;\n try {\n if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {\n return self.__remote_webpack_require__?.[bundle]?.(moduleId);\n }\n const sharedModule = getSharedModule(bundle ?? 'default', moduleId ?? id);\n if (sharedModule) {\n return sharedModule;\n }\n if (bundle && moduleId) {\n return handleTurbopackModule(bundle, moduleId, id);\n }\n throw new Error(`Module \"${id}\" not found.`);\n } catch (requireError) {\n if (typeof self.__original_webpack_require__ !== 'function') {\n throw new RemoteComponentsError(\n `Module \"${id}\" not found in remote component bundle \"${bundle}\".`,\n {\n cause: requireError instanceof Error ? requireError : undefined,\n },\n );\n }\n try {\n return self.__original_webpack_require__(id);\n } catch (originalError) {\n throw new RemoteComponentsError(\n `Module \"${id}\" not found in remote component bundle \"${bundle}\".`,\n { cause: originalError instanceof Error ? originalError : undefined },\n );\n }\n }\n };\n}\n\nasync function initializeSharedModules(\n bundle: string,\n hostShared: Record<string, (bundle?: string) => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n) {\n const self = globalThis as GlobalScope & {\n __next_f?: unknown[];\n };\n // eslint-disable-next-line camelcase\n self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};\n\n if (!self.__remote_shared_modules__[bundle]) {\n self.__remote_shared_modules__[bundle] = {};\n }\n\n // prepare to load shared module initializers from the Turbopack bundle\n const bundleKey = getBundleKey(bundle);\n const modules = self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined;\n let sharedModuleInitializer: Promise<{\n shared: Record<string, string | (() => Promise<unknown>)>;\n }> | null = null;\n\n // find the shared module initializer in the Turbopack bundle\n if (modules && Array.isArray(modules)) {\n const allModules = modules.flat();\n // find the shared module initializer module id\n const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {\n if (typeof idOrFunc !== 'function') {\n return false;\n }\n const funcCode = idOrFunc.toString();\n // look for the specific pattern in the function code\n return /[a-z]\\.TURBOPACK_REMOTE_SHARED/.test(funcCode);\n });\n\n // if found, extract the shared module initializer\n // first element in the array is always the source script element\n if (sharedModuleInitializerIndex > 0) {\n const sharedModuleInitializerCode = (\n allModules[sharedModuleInitializerIndex] as () => unknown\n ).toString();\n const sharedModuleInitializerId = allModules[\n sharedModuleInitializerIndex - 1\n ] as string | number;\n // extract the shared module id from the function code\n const { sharedModuleId } =\n /\\.TURBOPACK_REMOTE_SHARED=await e\\.A\\((?<sharedModuleId>[0-9]+)\\)/.exec(\n sharedModuleInitializerCode,\n )?.groups ?? {};\n // load the shared module initializer using the extracted module id\n if (sharedModuleId) {\n // load the shared module initializer\n const { default: sharedModuleInitializerInstance } =\n handleTurbopackModule(\n bundle,\n sharedModuleId,\n `[${bundle}] ${sharedModuleInitializerId}`,\n ) as {\n default: Promise<{\n shared: Record<string, string | (() => Promise<unknown>)>;\n }>;\n };\n // save the shared module initializer for later use\n sharedModuleInitializer = sharedModuleInitializerInstance;\n }\n }\n\n // if we have a shared module initializer, load the shared modules from the host application\n if (sharedModuleInitializer) {\n // async load the shared modules using the initializer\n const { shared } = await sharedModuleInitializer;\n // map shared module ids to their initializer functions\n const sharedModuleIds = Object.entries(shared)\n .filter(([, value]) => typeof value === 'function')\n .reduce<Record<string, string>>((acc, [key, value]) => {\n // extract the module id from the function code\n const { asyncSharedModuleId } =\n /e\\.A\\((?<asyncSharedModuleId>[0-9]+)\\)/.exec(value.toString())\n ?.groups ?? {};\n if (asyncSharedModuleId) {\n const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);\n\n let asyncSharedModule;\n const newAllModules =\n (\n self[`TURBOPACK_${bundleKey}`] as unknown[] | undefined\n )?.flat() ?? [];\n const asyncSharedModuleIdIndex = newAllModules.indexOf(\n asyncSharedModuleIdNumber,\n );\n if (\n asyncSharedModuleIdIndex !== -1 &&\n typeof newAllModules[asyncSharedModuleIdIndex + 1] === 'function'\n ) {\n asyncSharedModule = newAllModules[\n asyncSharedModuleIdIndex + 1\n ] as () => unknown;\n }\n if (asyncSharedModule) {\n const asyncSharedModuleCode = asyncSharedModule.toString();\n // extract the shared module id from the async module loader function code\n const { sharedModuleId } =\n /e=>{e\\.v\\(e=>Promise\\.resolve\\(\\)\\.then\\(\\(\\)=>e\\((?<sharedModuleId>[0-9]+)\\)\\)\\)}/.exec(\n asyncSharedModuleCode,\n )?.groups ??\n /e=>{e\\.v\\(t=>Promise\\.all\\(\\[\"[^\"]+\"\\].map\\(t=>e\\.l\\(t\\)\\)\\)\\.then\\(\\(\\)=>t\\((?<sharedModuleId>[0-9]+)\\)\\)\\)}/.exec(\n asyncSharedModuleCode,\n )?.groups ??\n {};\n\n // map the shared module id to the actual module name\n acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(\n '__remote_shared_module_',\n '',\n );\n }\n }\n return acc;\n }, {});\n\n // load shared modules from the host application\n return Promise.all(\n Object.entries(sharedModuleIds).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n if (hostShared[module]) {\n self.__remote_shared_modules__[bundle][id] =\n await hostShared[module](bundle);\n }\n }\n }),\n );\n }\n }\n\n // ensure that the shared modules are initialized\n return Promise.all(\n Object.entries(remoteShared).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n if (hostShared[module]) {\n self.__remote_shared_modules__[bundle][\n id.replace('[app-ssr]', '[app-client]')\n ] = await hostShared[module](bundle);\n } else {\n // eslint-disable-next-line no-console\n console.error(`Shared module \"${module}\" not found for \"${bundle}\".`);\n }\n }\n }),\n );\n}\n\n/**\n * Returns shared modules for common dependencies\n */\nfunction getSharedModule(bundle: string, id: string | number): unknown {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, unknown>;\n };\n\n for (const [key, value] of Object.entries(\n self.__remote_shared_modules__?.[bundle] ?? {},\n )) {\n if (\n typeof value !== 'undefined' &&\n ((typeof id === 'string' && id.includes(key)) || id === key)\n ) {\n return value;\n }\n }\n return null;\n}\n\ntype TurbopackModuleInit = (\n turbopackContext: unknown,\n module: unknown,\n exports: unknown,\n) => void;\n/**\n * Handles Turbopack module resolution\n */\nfunction handleTurbopackModule(\n bundle: string,\n moduleId: string,\n id: string,\n): unknown {\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n const modules = self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined;\n let moduleInit: TurbopackModuleInit | undefined;\n\n // flatten the modules array to simplify searching for the module\n const allModules = modules?.flat() ?? [];\n if (typeof allModules[1] === 'string' || typeof allModules[1] === 'number') {\n // convert moduleId to number if it's numeric\n const normalizedId = /^[0-9]+$/.test(moduleId)\n ? Number(moduleId)\n : moduleId;\n // try to find the module by its id\n let moduleIdIndex = allModules.indexOf(normalizedId);\n if (moduleIdIndex === -1) {\n // fallback: try to find the module by partial match (for cases where moduleId is a path)\n moduleIdIndex = allModules.findIndex(\n (bundleEntry) =>\n (typeof bundleEntry === 'string' &&\n bundleEntry.startsWith(moduleId)) ||\n bundleEntry === normalizedId,\n );\n }\n if (moduleIdIndex !== -1) {\n // iterate to find the next function which is the module initializer\n while (\n typeof allModules[moduleIdIndex] !== 'function' &&\n moduleIdIndex < allModules.length\n ) {\n moduleIdIndex++;\n }\n // get the module initializer function\n moduleInit = allModules[moduleIdIndex] as TurbopackModuleInit;\n }\n } else {\n // legacy Turbopack format where modules are mapped by objects\n moduleInit = (\n allModules.find(\n (bundleEntry) =>\n typeof bundleEntry === 'object' &&\n bundleEntry !== null &&\n moduleId in bundleEntry,\n ) as Record<string, TurbopackModuleInit | string | number> | undefined\n )?.[moduleId] as TurbopackModuleInit;\n }\n const exports = {} as Record<string, unknown>;\n const moduleExports = { exports };\n\n // prepare module cache\n if (!self.__remote_components_turbopack_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_modules__ = {};\n }\n if (!self.__remote_components_turbopack_modules__[bundle]) {\n self.__remote_components_turbopack_modules__[bundle] = {};\n }\n if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {\n return self.__remote_components_turbopack_modules__[bundle][moduleId];\n }\n\n // if module initializer is not found, throw an error\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\n\n // store a reference to the module exports in the module cache\n self.__remote_components_turbopack_modules__[bundle][moduleId] =\n moduleExports.exports;\n\n // prepare global object for the bundle if not already present\n if (!self.__remote_components_turbopack_global__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_global__ = {};\n }\n if (!self.__remote_components_turbopack_global__[bundle]) {\n self.__remote_components_turbopack_global__[bundle] = {};\n }\n\n // execute the module initializer function\n moduleInit(\n {\n // HMR not implemented for Remote Components\n k: {\n register() {\n // omit\n },\n registerExports() {\n // omit\n },\n signature() {\n return (fn: unknown) => {\n return fn;\n };\n },\n },\n // esm\n s(\n bindings:\n | Record<string, () => unknown>\n | [...([string, () => unknown] | [string, number, () => unknown])],\n esmId?: string | number,\n ) {\n let mod = exports;\n if (typeof esmId === 'string' || typeof esmId === 'number') {\n if (!self.__remote_components_turbopack_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_modules__ = {};\n }\n\n if (!self.__remote_components_turbopack_modules__[bundle]) {\n self.__remote_components_turbopack_modules__[bundle] = {};\n }\n\n if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {\n self.__remote_components_turbopack_modules__[bundle][esmId] =\n {} as Record<string, unknown>;\n }\n\n mod = self.__remote_components_turbopack_modules__[bundle][\n esmId\n ] as Record<string, unknown>;\n }\n\n Object.defineProperty(mod, '__esModule', { value: true });\n if (Array.isArray(bindings)) {\n let i = 0;\n while (i < bindings.length) {\n const propName = bindings[i++] as string;\n const tagOrFunc = bindings[i++];\n if (typeof tagOrFunc === 'number') {\n Object.defineProperty(mod, propName, {\n value: bindings[i++],\n enumerable: true,\n writable: false,\n });\n } else {\n const getterFn = tagOrFunc as () => unknown;\n if (typeof bindings[i] === 'function') {\n const setterFn = bindings[i++] as (v: unknown) => unknown;\n Object.defineProperty(mod, propName, {\n get: getterFn,\n set: setterFn,\n enumerable: true,\n });\n } else {\n Object.defineProperty(mod, propName, {\n get: getterFn,\n enumerable: true,\n });\n }\n }\n }\n }\n },\n // import\n i(importId: string | number) {\n let mod: Record<string, unknown> | undefined;\n if (typeof importId === 'string') {\n // parse export syntax if present\n const { exportSource, exportName } =\n /\\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(\n importId,\n )?.groups ?? {};\n const normalizedId = importId.replace(\n /\\s+<export(?<specifier>.*)>$/,\n '',\n );\n // load the module using the normalized id\n mod = self.__webpack_require__?.(\n `[${bundle}] ${normalizedId}`,\n ) as Record<string, unknown>;\n // if export syntax is used, map the requested export to the module exports\n if (\n exportSource &&\n exportName &&\n (exportSource === '*' ||\n typeof mod[exportSource] !== 'undefined') &&\n typeof mod[exportName] === 'undefined'\n ) {\n if (exportSource === '*') {\n mod[exportName] = mod;\n } else {\n mod[exportName] = mod[exportSource];\n }\n }\n } else {\n // numeric ids can be used directly\n mod = self.__webpack_require__?.(`[${bundle}] ${importId}`) as Record<\n string,\n unknown\n >;\n }\n if (typeof mod !== 'object') {\n mod = { default: mod };\n } else if (\n !('default' in mod) &&\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n mod.toString() !== '[object Module]'\n ) {\n try {\n mod.default = mod;\n } catch {\n // ignore if mod is not extensible\n }\n }\n return mod;\n },\n // require\n r(requireId: string) {\n return self.__webpack_require__?.(`[${bundle}] ${requireId}`);\n },\n // value exports\n v(value: unknown) {\n if (typeof value === 'function') {\n exports.default = value((vid: string | number) => {\n return self.__webpack_require__?.(`[${bundle}] ${vid}`);\n });\n } else {\n moduleExports.exports = value as Record<string, unknown>;\n }\n },\n // async module initializer\n async a(\n mod: (\n handleDeps: unknown,\n setResult: (value: unknown) => void,\n ) => Promise<void>,\n ) {\n let result;\n await mod(\n () => {\n // not implemented\n },\n (value) => (result = value),\n );\n exports.default = result;\n },\n // async module loader\n async A(Aid: string) {\n const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`) as {\n default: (\n parentImport: (parentId: string) => unknown,\n ) => Promise<unknown>;\n };\n return mod.default((parentId: string) =>\n self.__webpack_require__?.(`[${bundle}] ${parentId}`),\n );\n },\n // chunk loader\n l(url: string) {\n // try to find the script tag that loaded the current module\n const moduleInitIndex = allModules.indexOf(moduleInit);\n if (moduleInitIndex !== -1) {\n const scriptIndex = allModules\n .slice(0, moduleInitIndex)\n .findLastIndex((bundleEntry) => bundleEntry instanceof Element);\n if (scriptIndex !== -1) {\n const script = allModules[scriptIndex] as HTMLScriptElement;\n // use the original script src to construct the chunk url\n const scriptSrc = script.getAttribute('data-turbopack-src') || '';\n // construct the full chunk url based on the current script src\n const nextIndex = scriptSrc.indexOf('/_next');\n const baseUrl =\n nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : '';\n const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;\n return self.__webpack_chunk_load__?.(bundleUrl, bundle);\n }\n }\n throw new Error(\n `Failed to load Turbopack chunk \"${url}\" for module \"${id}\". Check the URL is correct.`,\n );\n },\n // global\n g: self.__remote_components_turbopack_global__[bundle],\n m: moduleExports,\n e: exports,\n },\n moduleExports,\n exports,\n );\n\n // update the module cache with the final exports\n if (\n self.__remote_components_turbopack_modules__[bundle][moduleId] !==\n moduleExports.exports\n ) {\n self.__remote_components_turbopack_modules__[bundle][moduleId] =\n moduleExports.exports;\n }\n\n return moduleExports.exports;\n}\n","import { RemoteComponentsError } from '../error';\nimport type {\n MountOrUnmountFunction,\n RemoteComponentMountUnmount,\n} from './types';\n\nexport async function loadStaticRemoteComponent(\n scripts: HTMLScriptElement[],\n url: URL,\n) {\n const self = globalThis as typeof globalThis & RemoteComponentMountUnmount;\n if (self.__remote_script_entrypoint_mount__?.[url.href]) {\n self.__remote_script_entrypoint_mount__[url.href] = new Set();\n }\n if (self.__remote_script_entrypoint_unmount__?.[url.href]) {\n self.__remote_script_entrypoint_unmount__[url.href] = new Set();\n }\n const mountUnmountSets = await Promise.all(\n scripts.map(async (script) => {\n try {\n let src =\n typeof script.getAttribute === 'function'\n ? (script.getAttribute('src') ?? script.src)\n : script.src;\n // if there's no src attribute but there is inline script content, create a blob URL for it\n if (!src && script.textContent) {\n const blob = new Blob(\n [\n script.textContent.replace(\n /import\\.meta\\.url/g,\n JSON.stringify(url),\n ),\n ],\n {\n type: 'text/javascript',\n },\n );\n src = URL.createObjectURL(blob);\n }\n const mod = (await import(\n /* @vite-ignore */\n /* webpackIgnore: true */ new URL(src, url).href\n )) as {\n mount?: MountOrUnmountFunction;\n unmount?: MountOrUnmountFunction;\n default?: {\n mount?: MountOrUnmountFunction;\n unmount?: MountOrUnmountFunction;\n };\n };\n // revoke the object URL if we created one\n if (src.startsWith('blob:')) {\n URL.revokeObjectURL(src);\n }\n if (\n typeof mod.mount === 'function' ||\n typeof mod.default?.mount === 'function'\n ) {\n if (!self.__remote_script_entrypoint_mount__) {\n // eslint-disable-next-line camelcase\n self.__remote_script_entrypoint_mount__ = {};\n }\n if (!self.__remote_script_entrypoint_mount__[url.href]) {\n self.__remote_script_entrypoint_mount__[url.href] = new Set();\n }\n self.__remote_script_entrypoint_mount__[url.href]?.add(\n mod.mount ||\n mod.default?.mount ||\n (() => {\n // noop\n }),\n );\n }\n if (\n typeof mod.unmount === 'function' ||\n typeof mod.default?.unmount === 'function'\n ) {\n if (!self.__remote_script_entrypoint_unmount__) {\n // eslint-disable-next-line camelcase\n self.__remote_script_entrypoint_unmount__ = {};\n }\n if (!self.__remote_script_entrypoint_unmount__[url.href]) {\n self.__remote_script_entrypoint_unmount__[url.href] = new Set();\n }\n self.__remote_script_entrypoint_unmount__[url.href]?.add(\n mod.unmount ||\n mod.default?.unmount ||\n (() => {\n // noop\n }),\n );\n }\n return {\n mount: mod.mount || mod.default?.mount,\n unmount: mod.unmount || mod.default?.unmount,\n };\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(\n `Error loading remote component script from \"${script.src || url.href}\".`,\n { cause: e },\n ),\n );\n return {\n mount: undefined,\n unmount: undefined,\n };\n }\n }),\n );\n return mountUnmountSets.reduce(\n (acc, { mount, unmount }) => {\n if (typeof mount === 'function') {\n acc.mount.add(mount);\n }\n if (typeof unmount === 'function') {\n acc.unmount.add(unmount);\n }\n return acc;\n },\n {\n mount: new Set<MountOrUnmountFunction>(),\n unmount: new Set<MountOrUnmountFunction>(),\n },\n );\n}\n","import type { ImageProps, StaticImageData } from 'next/image';\nimport type { LinkProps } from 'next/link';\n\nfunction applyBundleUrlToSrc(bundle: string, src: string) {\n const self = globalThis as typeof globalThis & {\n __remote_bundle_url__?: Record<string, URL>;\n };\n\n if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {\n return src;\n }\n\n const { assetPrefix, path } =\n /^(?<assetPrefix>.*?)\\/_next\\/(?<path>.*)/.exec(src)?.groups ?? {};\n if (!path) {\n return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;\n }\n return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ''}${assetPrefix}/_next/${path}`;\n}\n\nexport function applyBundleUrlToImagePropsSrc(\n bundle: string,\n src: ImageProps['src'],\n) {\n if (typeof src === 'string') {\n return applyBundleUrlToSrc(bundle, src);\n }\n const propSrc = src as StaticImageData;\n return applyBundleUrlToSrc(bundle, propSrc.src);\n}\n\nconst imageImpl = (bundle: string) =>\n function RemoteImage({\n fill: _fill,\n loader: _loader,\n quality: _quality,\n priority: _priority,\n loading: _loading,\n placeholder: _placeholder,\n blurDataURL: _blurDataURL,\n unoptimized: _unoptimized,\n overrideSrc: _overrideSrc,\n src,\n ...props\n }: ImageProps) {\n const newSrc = applyBundleUrlToImagePropsSrc(\n bundle,\n typeof src === 'string' ? src : (src as StaticImageData).src,\n );\n\n return (\n // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text\n <img\n decoding=\"async\"\n style={{ color: 'transparent' }}\n {...props}\n src={newSrc}\n suppressHydrationWarning\n />\n );\n };\n\n// polyfill Next.js App Router client API (minimal)\n// implementations are minimal and do not cover all use cases\n// developer can override these shared modules from configuration\nexport function sharedPolyfills(\n shared?: Record<string, () => Promise<unknown>>,\n) {\n const self = globalThis as typeof globalThis & {\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n };\n const polyfill = {\n 'next/dist/client/components/navigation':\n self.__remote_component_host_shared_modules__?.['next/navigation'] ??\n shared?.['next/navigation'] ??\n (() =>\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n },\n back: () => {\n history.back();\n },\n };\n },\n usePathname() {\n return location.pathname;\n },\n useParams() {\n return {};\n },\n useSearchParams() {\n return new URLSearchParams(location.search);\n },\n useSelectedLayoutSegment() {\n return null;\n },\n useSelectedLayoutSegments() {\n return [];\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/link':\n self.__remote_component_host_shared_modules__?.['next/link'] ??\n shared?.['next/link'] ??\n (() =>\n Promise.resolve({\n default: ({\n scroll: _,\n replace,\n prefetch,\n onNavigate,\n children,\n ...props\n }: React.PropsWithChildren<LinkProps>) => {\n if (prefetch) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Next.js Link prefetch is not supported in remote components',\n );\n }\n return (\n <a\n {...props}\n href={props.href as string}\n onClick={(e) => {\n e.preventDefault();\n let preventDefaulted = false;\n e.preventDefault = () => {\n preventDefaulted = true;\n e.defaultPrevented = true;\n };\n if (typeof props.onClick === 'function') {\n props.onClick(e);\n }\n onNavigate?.(e);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (preventDefaulted) {\n return;\n }\n if (replace) {\n history.replaceState({}, '', props.href as string);\n } else {\n history.pushState({}, '', props.href as string);\n }\n }}\n suppressHydrationWarning\n >\n {children ?? null}\n </a>\n );\n },\n useLinkStatus() {\n return { pending: false };\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/form':\n self.__remote_component_host_shared_modules__?.['next/form'] ??\n shared?.['next/form'] ??\n (() =>\n Promise.resolve({\n default: () => {\n // TODO: implement <Form> component for non-Next.js host applications\n throw new Error('Next.js <Form> component not implemented');\n },\n __esModule: true,\n })),\n 'next/dist/client/image-component':\n self.__remote_component_host_shared_modules__?.['next/image'] ??\n shared?.['next/image'] ??\n ((bundle: string) =>\n Promise.resolve({\n Image: imageImpl(bundle),\n __esModule: true,\n })),\n 'next/image':\n self.__remote_component_host_shared_modules__?.['next/image'] ??\n shared?.['next/image'] ??\n ((bundle: string) =>\n Promise.resolve({\n default: imageImpl(bundle),\n getImageProps: (_imgProps: ImageProps) => {\n throw new Error(\n 'Next.js getImageProps() is not implemented in remote components',\n );\n },\n __esModule: true,\n })),\n 'next/dist/client/script':\n self.__remote_component_host_shared_modules__?.['next/script'] ??\n shared?.['next/script'] ??\n (() =>\n Promise.resolve({\n // TODO: implement <Script> component for non-Next.js host applications\n // do not throw an error for now\n default: () => null,\n __esModule: true,\n })),\n 'next/router':\n self.__remote_component_host_shared_modules__?.['next/router'] ??\n shared?.['next/router'] ??\n (() =>\n // TODO: incomplete implementation\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n },\n back: () => {\n history.back();\n },\n };\n },\n __esModule: true,\n })),\n 'next/dist/build/polyfills/process': () =>\n Promise.resolve({\n default: {\n env: {\n NODE_ENV: 'production',\n },\n },\n __esModule: true,\n }),\n } as Record<string, () => Promise<unknown>>;\n\n polyfill['next/navigation'] = polyfill[\n 'next/dist/client/components/navigation'\n ] as () => Promise<unknown>;\n polyfill['next/link'] = polyfill[\n 'next/dist/client/app-dir/link'\n ] as () => Promise<unknown>;\n polyfill['next/form'] = polyfill[\n 'next/dist/client/app-dir/form'\n ] as () => Promise<unknown>;\n polyfill['next/dist/api/image'] = polyfill[\n 'next/dist/client/image-component'\n ] as () => Promise<unknown>;\n polyfill['next/script'] = polyfill[\n 'next/dist/client/script'\n ] as () => Promise<unknown>;\n\n return polyfill;\n}\n","import type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport { sharedPolyfills } from '../../../shared/client/polyfill';\nimport { RemoteComponentsError } from '../../../shared/error';\nimport { nextClientPagesLoader } from '../../../shared/webpack/next-client-pages-loader';\nimport { applySharedModules } from '../../../shared/webpack/shared-modules';\n\n// initializer for the webpack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function webpackRuntime(\n bundle: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string | number>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__?: Record<string, boolean>;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __webpack_require_type__: 'webpack' | 'turbopack';\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n } & RemoteComponentMountUnmount &\n Record<RSCKey, string[]>;\n\n // disable webpack exec to prevent automatically executing the entry module\n if (!self.__DISABLE_WEBPACK_EXEC__) {\n self.__DISABLE_WEBPACK_EXEC__ = {};\n }\n self.__DISABLE_WEBPACK_EXEC__[bundle] = true;\n // add a custom webpack require function to load remote components from multiple bundles / zones\n if (\n typeof self.__webpack_require__ !== 'function' &&\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n self.__webpack_require__ = (remoteId: string) => {\n const re = /\\[(?<bundle>[^\\]]+)\\] (?<id>.*)/;\n const match = re.exec(remoteId);\n const remoteBundle = match?.groups?.bundle;\n const id = match?.groups?.id;\n if (!(id && remoteBundle)) {\n throw new RemoteComponentsError(\n `Remote Component module \"${remoteId}\" not found. Did you forget to wrap the Next.js config with \\`withRemoteComponents\\` on both host and remote?`,\n );\n }\n if (\n typeof self.__remote_webpack_require__?.[remoteBundle] !== 'function'\n ) {\n throw new RemoteComponentsError(\n `Remote Components are not available in \"${remoteBundle}\". Did you forget to wrap the Next.js config with \\`withRemoteComponents\\` on both host and remote?`,\n );\n }\n return self.__remote_webpack_require__[remoteBundle](id);\n };\n // not used but required by react-server-dom-webpack\n self.__webpack_chunk_load__ = () => {\n return Promise.resolve([]);\n };\n }\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n async function preloadScripts(\n scripts: HTMLScriptElement[],\n url: URL,\n remoteBundle: string,\n _: string,\n ) {\n // we need to properly attach script elements to the document to load the remote component bundles\n // we need to wait for all scripts to load before we can hydrate the remote component\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n newScript.remove();\n };\n newScript.onerror = () => {\n reject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n newScript.remove();\n };\n const scriptSrc =\n script.getAttribute('src') || script.getAttribute('data-src');\n if (scriptSrc) {\n newScript.src = new URL(\n scriptSrc.replace(/\\/_next\\/\\[(?:.+)\\](?:%20| )/, '/_next/'),\n url,\n ).href;\n }\n newScript.async = true;\n document.body.appendChild(newScript);\n // safe to remove the original script element\n script.parentElement?.removeChild(script);\n });\n }),\n );\n\n // module resolution map for the shared modules\n const hostShared = {\n ...sharedPolyfills(shared),\n ...self.__remote_component_host_shared_modules__,\n ...shared,\n } as Record<string, () => Promise<unknown>>;\n const resolve = {\n '/react/index.js': (await import('react')).default,\n '/react/jsx-dev-runtime.js': (await import('react/jsx-dev-runtime'))\n .default,\n '/react/jsx-runtime.js': (await import('react/jsx-runtime')).default,\n '/react-dom/index.js': (await import('react-dom')).default,\n '/react-dom/client.js': (await import('react-dom/client')).default,\n ...Object.entries(remoteShared ?? {}).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (typeof hostShared[value] !== 'undefined') {\n acc[key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '')] =\n hostShared[value];\n }\n return acc;\n },\n {},\n ),\n } as Record<string, unknown>;\n await Promise.all(\n Object.entries(resolve).map(async ([key, value]) => {\n if (typeof value === 'function') {\n resolve[key] = await value(remoteBundle);\n }\n return Promise.resolve(value);\n }),\n );\n\n // apply shared modules to the bundle\n applySharedModules(remoteBundle, resolve);\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","import type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport { sharedPolyfills } from '../../../shared/client/polyfill';\nimport { setupWebpackRuntime } from '../../../shared/client/webpack-adapter';\nimport { nextClientPagesLoader } from '../../../shared/webpack/next-client-pages-loader';\nimport { applySharedModules } from '../../../shared/webpack/shared-modules';\n\n// initializer for the turbopack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function turbopackRuntime(\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __remote_component_shared__?: Record<string, () => Promise<unknown>>;\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n } & RemoteComponentMountUnmount &\n Record<RSCKey, string[]>;\n\n const hostShared = {\n ...sharedPolyfills(shared),\n ...self.__remote_component_host_shared_modules__,\n ...shared,\n ...self.__remote_component_shared__,\n };\n\n await setupWebpackRuntime(\n 'turbopack',\n [],\n url,\n bundle,\n hostShared,\n remoteShared,\n );\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n function preloadScripts(scripts: HTMLScriptElement[], __: URL) {\n return setupWebpackRuntime(\n 'turbopack',\n scripts.map((script) => ({\n src:\n script.getAttribute('src') ||\n script.getAttribute('data-src') ||\n script.src,\n })),\n url,\n bundle,\n hostShared,\n remoteShared,\n );\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","// initializer for the script runtime\n\nimport type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport { loadStaticRemoteComponent } from '../../../shared/client/static-loader';\n\n// required to run exposed client components of the remote component\nexport function scriptRuntime() {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n } & RemoteComponentMountUnmount &\n Record<RSCKey, string[]>;\n\n return {\n self,\n createFromReadableStream: () => Promise.resolve(null),\n applySharedModules: () => Promise.resolve(),\n nextClientPagesLoader: () => ({\n Component: null,\n App: null,\n }),\n preloadScripts: loadStaticRemoteComponent,\n };\n}\n","import { startTransition, useLayoutEffect } from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport { applyOriginToNodes } from '#internal/shared/client/apply-origin';\nimport {\n createRSCStream,\n RemoteComponentsError,\n} from '#internal/shared/client/remote-component';\nimport type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport {\n failedToFetchRemoteComponentError,\n multipleRemoteComponentsError,\n} from '#internal/shared/error';\nimport { remoteFetchHeaders } from '#internal/shared/ssr/fetch-headers';\nimport { escapeString } from '#internal/shared/utils';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name?: string;\n bundle?: string;\n fallbackSlot?: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n isLoading = false;\n prevIsRemoteComponent = false;\n prevUrl?: URL;\n root?: ShadowRoot | null = null;\n reactRoot?: ReturnType<typeof hydrateRoot>;\n additionalHeaders?: Headers;\n\n static get observedAttributes() {\n return ['src', 'name', 'mode'];\n }\n\n // watch for src attribute changes\n // this is required to reload the remote component when the src attribute is added later\n // this is for rendering the custom element using React\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if ((name === 'src' || name === 'name') && oldValue !== newValue) {\n if (this.getAttribute('src')) {\n this.load().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n } else if (name === 'mode' && oldValue !== newValue && this.root) {\n // changing the shadow DOM mode is not supported\n // we need to recreate the shadow DOM and reload the component\n const newRoot = this.attachShadow({\n mode: newValue === 'closed' ? 'closed' : 'open',\n });\n // move all existing children to the new shadow root\n Array.from(this.root.children).forEach((child) => {\n newRoot.appendChild(child);\n });\n this.root = newRoot;\n // reload the remote component to apply the new shadow DOM\n this.load().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n }\n\n async load() {\n // wait for the current call stack to finish\n await new Promise((resolve) => {\n (typeof queueMicrotask === 'function'\n ? queueMicrotask\n : requestAnimationFrame)(() => {\n resolve(undefined);\n });\n });\n\n // prevent multiple loads\n if (this.isLoading) {\n return;\n }\n\n if (!this.root) {\n this.root = this.attachShadow({\n mode: this.getAttribute('mode') === 'closed' ? 'closed' : 'open',\n });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.root.appendChild(this.fallbackSlot);\n }\n\n this.name = this.getAttribute('name') || '__vercel_remote_component';\n this.bundle = 'default';\n\n const additionalHeadersString = this.getAttribute('additional-headers');\n if (additionalHeadersString) {\n this.additionalHeaders = additionalHeadersString\n .split(';')\n .reduce((headers, headerPair) => {\n const [key, value] = headerPair.split(':');\n if (key && value) {\n headers.set(key.trim(), value.trim());\n }\n return headers;\n }, new Headers());\n }\n\n // load when the custom element has an src, data-ssr attribute or contains an SSR remote component div\n if (\n this.hasAttribute('src') ||\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.hasAttribute('data-ssr')\n ) {\n // start loading and hydration\n this.load().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n\n this.isLoading = true;\n const src = this.getAttribute('src');\n const remoteComponentChild =\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.querySelector('div[data-bundle][data-route]');\n\n if (!src && !remoteComponentChild) {\n throw new RemoteComponentsError('\"src\" attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (src) {\n url = new URL(src, window.location.href);\n if (url.hash) {\n this.name = url.hash.slice(1);\n }\n }\n\n if (!remoteComponentChild && url) {\n // fetch the remote component\n const fetchInit = {\n method: 'GET',\n headers: remoteFetchHeaders(this.additionalHeaders),\n credentials: this.getAttribute('credentials') || 'same-origin',\n } as RequestInit;\n\n const res = await fetch(url, fetchInit);\n\n if (!res.ok) {\n let error: Error = failedToFetchRemoteComponentError(url.href, {\n cause: new Error(`${res.status} ${res.statusText}`),\n });\n try {\n const body = await res.text();\n const parser = new DOMParser();\n const doc = parser.parseFromString(body, 'text/html');\n const errorTemplate = doc.querySelector(\n 'template[data-next-error-message]',\n );\n const errorMessage = errorTemplate?.getAttribute(\n 'data-next-error-message',\n );\n const errorStack = errorTemplate?.getAttribute(\n 'data-next-error-stack',\n );\n\n if (errorMessage) {\n error = new RemoteComponentsError(errorMessage);\n if (errorStack) {\n error.stack = errorStack;\n }\n }\n } catch {\n // ignore\n }\n\n throw error;\n }\n\n // get the full HTML content as a string\n html = await res.text();\n }\n // create a virtual element which will be used to parse the HTML and extract the component and RSC flight data\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, 'text/html');\n\n if (\n (doc.querySelectorAll('div[data-bundle][data-route]').length > 1 &&\n !doc.querySelector(\n `div[data-bundle][data-route][id^=\"${this.name}\"]`,\n )) ||\n (doc.querySelectorAll('remote-component').length > 1 &&\n !doc.querySelector(`remote-component[name=\"${this.name}\"]`))\n ) {\n throw multipleRemoteComponentsError(\n url?.href ?? (this.getAttribute('src') || 'unknown'),\n );\n }\n\n // reference to the remote component content\n const component =\n doc.querySelector(`div[data-bundle][data-route][id^=\"${this.name}\"]`) ??\n // fallback to the first element with the data-bundle and data-route attributes when not using a named remote component\n doc.querySelector('div[data-bundle][data-route]') ??\n // fallback to Next.js Pages Router\n doc.querySelector('div#__next') ??\n // fallback to a <remote-component> element\n doc.querySelector(`remote-component[name=\"${this.name}\"]:not([src])`) ??\n doc.querySelector('remote-component:not([src])');\n const nextData = JSON.parse(\n (\n doc.querySelector('#__NEXT_DATA__') ??\n doc.querySelector('#__REMOTE_NEXT_DATA__')\n )?.textContent ?? 'null',\n ) as {\n props: {\n pageProps: Record<string, unknown>;\n __REMOTE_COMPONENT__?: {\n bundle: string;\n runtime: 'turbopack' | 'webpack' | 'script';\n shared?: Record<string, string>;\n };\n };\n page: string;\n buildId: string;\n } | null;\n\n const isRemoteComponent =\n component?.tagName.toLowerCase() === 'remote-component';\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development' && !this.reactRoot) {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.root.appendChild(this.fouc);\n }\n\n this.name =\n component?.getAttribute('id')?.replace(/_ssr$/, '') ||\n (isRemoteComponent && component.getAttribute('name')) ||\n (nextData ? '__next' : this.name);\n // reference to the RSC flight data\n const rsc = doc.querySelector(`#${this.name}_rsc`);\n\n // reference to the bundle containing the client components\n this.bundle =\n component?.getAttribute('data-bundle') ||\n nextData?.props.__REMOTE_COMPONENT__?.bundle ||\n this.bundle;\n\n if (url) {\n const self = globalThis as typeof globalThis & {\n __remote_bundle_url__?: Record<string, URL>;\n };\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n\n self.__remote_bundle_url__[this.bundle ?? 'default'] = url;\n }\n\n // add remote component metadata information at the custom element\n const metadata = document.createElement('script');\n metadata.type = 'application/json';\n metadata.setAttribute('data-remote-component', '');\n const metadataObj = {\n name: this.name,\n bundle: this.bundle,\n route:\n component?.getAttribute('data-route') ??\n nextData?.page ??\n url?.pathname ??\n '/',\n runtime:\n component?.getAttribute('data-runtime') ??\n nextData?.props.__REMOTE_COMPONENT__?.runtime ??\n 'script',\n };\n metadata.textContent = JSON.stringify(metadataObj);\n\n if (\n this.previousElementSibling?.getAttribute('data-remote-component') !==\n null\n ) {\n this.previousElementSibling?.remove();\n }\n this.parentElement?.insertBefore(metadata, this);\n\n const remoteSharedEl = doc.querySelector(\n `#${this.name}_shared[data-remote-components-shared]`,\n );\n const remoteShared =\n nextData?.props.__REMOTE_COMPONENT__?.shared ??\n ((JSON.parse(remoteSharedEl?.textContent ?? '{}') ?? {}) as Record<\n string,\n string\n >);\n remoteSharedEl?.parentElement?.removeChild(remoteSharedEl);\n\n if ('__remote_components_missing_shared__' in remoteShared) {\n throw new RemoteComponentsError(\n remoteShared.__remote_components_missing_shared__,\n );\n }\n\n if (!component || !(rsc || nextData || isRemoteComponent)) {\n throw new RemoteComponentsError(\n `Remote Component not found on ${src}.${this.name !== '__vercel_remote_component' ? ` The name for the <RemoteComponent> is \"${this.name}\". Check <RemoteComponent> usage.` : ''} Did you forget to wrap the content in <RemoteComponent>?`,\n );\n }\n\n if (this.prevIsRemoteComponent) {\n if (this.prevUrl) {\n const prevUrl = this.prevUrl;\n const self = globalThis as typeof globalThis &\n RemoteComponentMountUnmount;\n if (self.__remote_script_entrypoint_unmount__?.[prevUrl.href]) {\n // call unmount() for all registered unmount functions for the previous remote component\n await Promise.all(\n Array.from(\n self.__remote_script_entrypoint_unmount__[prevUrl.href] ?? [],\n ).map(async (unmount) => {\n try {\n await unmount(this.root);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(\n `Error while calling unmount() for Remote Component from ${prevUrl.href}.`,\n { cause: e as Error },\n ),\n );\n }\n }),\n );\n }\n }\n this.root.innerHTML = '';\n }\n this.prevUrl = url ?? new URL(location.href);\n this.prevIsRemoteComponent = isRemoteComponent;\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n // reference to all script elements in the remote component\n const remoteComponentSrc = this.getAttribute('src');\n\n const attachLinks = async () => {\n // attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links)\n .filter((link) => {\n return !component.contains(link);\n })\n .map((link) => {\n return new Promise<void>((resolve, reject) => {\n const newLink = document.createElement('link');\n if (link.rel === 'stylesheet') {\n newLink.onload = () => {\n resolve();\n };\n newLink.onerror = () => {\n reject(\n new RemoteComponentsError(\n `Failed to load <link href=\"${link.href}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n };\n } else {\n resolve();\n }\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n newLink.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n\n if (remoteComponentSrc) {\n newLink.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n\n this.root?.appendChild(newLink);\n });\n }),\n );\n\n const styles = doc.querySelectorAll<HTMLStyleElement>('style');\n styles.forEach((style) => {\n if (style.parentElement?.tagName.toLowerCase() === 'head') {\n const newStyle = document.createElement('style');\n newStyle.textContent = style.textContent;\n\n if (remoteComponentSrc) {\n newStyle.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n\n this.root?.appendChild(newStyle);\n }\n });\n };\n\n if (!this.reactRoot) {\n // ensure all styles are loaded before hydrating to prevent FOUC\n await attachLinks();\n }\n\n // update all relative URLs to absolute URLs based on the remote component URL\n applyOriginToNodes(doc, url ?? new URL(location.href));\n\n if (!this.reactRoot) {\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n if (!isRemoteComponent && el.tagName.toLowerCase() === 'script') {\n const newScript = document.createElement('script');\n // copy all attributes\n for (const attr of el.attributes) {\n if (attr.name === 'src') {\n newScript.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n newScript.textContent = el.textContent;\n if (remoteComponentSrc) {\n newScript.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n this.root?.appendChild(newScript);\n } else {\n const newEl = el.cloneNode(true) as HTMLElement;\n for (const attr of el.attributes) {\n if (attr.name.startsWith('on')) {\n newEl.setAttribute(attr.name, attr.value);\n }\n }\n this.root?.appendChild(newEl);\n }\n });\n }\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.fallbackSlot?.remove();\n\n // function to apply the reset styles to the shadow DOM\n const applyReset = () => {\n if (\n this.getAttribute('reset') !== null &&\n !this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n // all initial styles to reset inherited styles leaking from the host page\n const allInitial = document.createElement('link');\n allInitial.setAttribute('data-remote-components-reset', '');\n const css = `:host { all: initial; }`;\n const allInitialHref = URL.createObjectURL(\n new Blob([css], { type: 'text/css' }),\n );\n allInitial.href = allInitialHref;\n allInitial.rel = 'stylesheet';\n // we need to revoke the object URL after the stylesheet is loaded to free up memory\n allInitial.onload = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n allInitial.onerror = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n this.root?.prepend(allInitial);\n } else if (\n this.getAttribute('reset') === null &&\n this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n this.root\n .querySelector('link[data-remote-components-reset]')\n ?.remove();\n }\n };\n\n // apply the reset styles if required and not already applied\n if (!this.reactRoot) {\n applyReset();\n }\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n metadataObj.runtime as Runtime,\n url ?? new URL(location.href),\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n );\n\n const scripts = isRemoteComponent\n ? component.querySelectorAll<HTMLScriptElement>('script')\n : doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src],script[data-remote-component-entrypoint]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(\n Array.from(scripts),\n url,\n this.bundle ?? 'default',\n this.name ?? '__vercel_remote_component',\n );\n\n // remove all script elements from the shadow DOM to prevent re-execution of scripts\n if (isRemoteComponent) {\n Array.from(component.children).forEach((child) => {\n if (child.tagName === 'SCRIPT') {\n child.remove();\n }\n });\n }\n\n // cleanup previous remote component instances when a new remote component is loaded\n // this is required when the src attribute is changed to load a new remote component\n const doCleanup = () => {\n if (this.root && remoteComponentSrc) {\n const selector = `[data-remote-component-src]:not([data-remote-component-src=\"${remoteComponentSrc}\"])`;\n const prevCleanup = [\n ...this.root.querySelectorAll(selector),\n ...document.body.querySelectorAll(selector),\n ] as HTMLElement[];\n\n if (prevCleanup.length > 0) {\n prevCleanup.forEach((prev) => {\n prev.remove();\n });\n }\n }\n };\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscName = `__remote_component_rsc_${escapeString(url.href)}_${escapeString(this.name)}`;\n const rscClone = document.createElement('script');\n rscClone.id = `${rscName}_rsc`;\n rscClone.textContent =\n rsc.textContent?.replace(\n new RegExp(`self\\\\[\"${this.name}\"\\\\]`, 'g'),\n `self[\"${rscName}\"]`,\n ) ?? '';\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n initial,\n }: {\n name: string;\n initial: boolean;\n }) => {\n // convert the RSC flight data array into a ReadableStream\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const stream = createRSCStream(\n rscName,\n self[rscName as RSCKey] ?? [`0:[null]\\n`],\n );\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(stream) as React.ReactNode);\n\n useLayoutEffect(() => {\n // clear the RSC flight data from the global scope to free up memory\n if (self[name as RSCKey]) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete self[name as RSCKey];\n }\n const rscScript = document.getElementById(`${name}_rsc`);\n if (rscScript) {\n rscScript.remove();\n }\n\n doCleanup();\n applyReset();\n if (!initial) {\n attachLinks().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n this.isLoading = false;\n }, [initial, name]);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(\n <RemoteComponentFromReadableStream\n initial={false}\n name={this.name ?? '__vercel_remote_component'}\n />,\n );\n });\n return;\n }\n\n // hydrate the remote component using the RSC flight data\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromReadableStream\n initial\n name={this.name ?? '__vercel_remote_component'}\n />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle ?? 'default',\n nextData.page,\n this.root,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n const RemoteComponentFromNext = ((\n NextApp: ReturnType<typeof nextClientPagesLoader>['App'],\n NextComponent: NonNullable<\n ReturnType<typeof nextClientPagesLoader>['Component']\n >,\n remoteComponent = this,\n ) =>\n function RemoteComponentNext({ initial }: { initial: boolean }) {\n useLayoutEffect(() => {\n doCleanup();\n if (!initial) {\n applyReset();\n attachLinks().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n remoteComponent.isLoading = false;\n }, [initial, remoteComponent]);\n\n return NextApp ? (\n <NextApp Component={NextComponent} {...nextData.props} />\n ) : (\n <NextComponent {...nextData.props} />\n );\n })(App, Component, this);\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(<RemoteComponentFromNext initial={false} />);\n doCleanup();\n this.isLoading = false;\n });\n return;\n }\n\n // hydrate the remote component using the Next.js pages router\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromNext initial />,\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.root.removeChild(this.fouc);\n }\n } else if (self.__remote_script_entrypoint_mount__?.[url.href]) {\n // using script entrypoint when no RSC or Next.js data is available\n await Promise.all(\n Array.from(\n self.__remote_script_entrypoint_mount__[url.href] ?? [],\n ).map(async (mount) => {\n try {\n await mount(this.root);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(\n `Error while calling mount() for Remote Component from ${url.href}.`,\n { cause: e as Error },\n ),\n );\n }\n }),\n );\n }\n\n this.isLoading = false;\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n\nexport function registerSharedModules(\n modules: Record<string, () => Promise<unknown>> = {},\n) {\n const self = globalThis as typeof globalThis & {\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n };\n\n if (!self.__remote_component_host_shared_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_component_host_shared_modules__ = {};\n }\n\n Object.entries(modules).forEach(([key, value]) => {\n if (self.__remote_component_host_shared_modules__) {\n self.__remote_component_host_shared_modules__[key] = value;\n }\n });\n}\n","const tagNames = [\n 'img',\n 'source',\n 'video',\n 'audio',\n 'track',\n 'iframe',\n 'embed',\n 'script',\n 'link',\n];\n\nexport function applyOriginToNodes(doc: Document | HTMLElement, url: URL) {\n if (url.origin !== location.origin) {\n const nodes = doc.querySelectorAll<HTMLImageElement>(\n tagNames\n .map(\n (type) =>\n `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`,\n )\n .join(','),\n );\n nodes.forEach((node) => {\n if (\n node.hasAttribute('src') &&\n /^[./]+\\/?/.test(node.getAttribute('src') ?? '')\n ) {\n node.src = new URL(node.getAttribute('src') ?? '/', url).href;\n }\n if (\n node.hasAttribute('href') &&\n /^[./]+\\/?/.test(node.getAttribute('href') ?? '')\n ) {\n node.setAttribute(\n 'href',\n new URL(node.getAttribute('href') ?? '/', url).href,\n );\n }\n if (node.hasAttribute('srcset')) {\n const srcSet = node\n .getAttribute('srcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('srcset', srcSet);\n }\n }\n if (node.hasAttribute('imagesrcset')) {\n const srcSet = node\n .getAttribute('imagesrcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('imagesrcset', srcSet);\n }\n }\n });\n }\n}\n","export { RemoteComponentsError } from '../error';\nexport {\n type LoadRemoteComponentProps,\n loadRemoteComponent,\n} from './component-loader';\nexport type { Runtime } from './const';\nexport {\n DEFAULT_ROUTE,\n getBundleKey,\n REMOTE_COMPONENT_REGEX,\n RUNTIME_SCRIPT,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n} from './const';\nexport { createRSCStream, fixPayload } from './rsc';\nexport { loadScripts } from './script-loader';\nexport { setAttributesFromProps } from './set-attributes-from-props';\nexport { loadStaticRemoteComponent } from './static-loader';\nexport type { GlobalScope, LoaderResult, RemoteComponentProps } from './types';\nexport { setupWebpackRuntime } from './webpack-adapter';\n","import * as React from 'react';\nimport * as JSXDevRuntime from 'react/jsx-dev-runtime';\nimport * as JSXRuntime from 'react/jsx-runtime';\nimport * as ReactDOM from 'react-dom';\nimport * as ReactDOMClient from 'react-dom/client';\nimport { RemoteComponentsError } from '../error';\nimport { nextClientPagesLoader } from '../webpack/next-client-pages-loader';\nimport { applySharedModules } from '../webpack/shared-modules';\nimport { createRSCStream } from './rsc';\nimport { loadScripts } from './script-loader';\nimport type { GlobalScope, LoaderResult, RemoteComponentProps } from './types';\nimport { setupWebpackRuntime } from './webpack-adapter';\n\nexport type LoadRemoteComponentProps = Pick<\n RemoteComponentProps,\n 'name' | 'bundle' | 'route' | 'runtime' | 'data' | 'nextData' | 'scripts'\n> & {\n url: URL;\n shared:\n | Promise<Record<string, (bundle?: string) => Promise<unknown>>>\n | Record<string, (bundle?: string) => Promise<unknown>>;\n remoteShared: Record<string, string>;\n container?: HTMLHeadElement | ShadowRoot | null;\n rscName?: string;\n};\n\n/**\n * Main loader function that orchestrates the component loading process\n */\nexport async function loadRemoteComponent({\n url,\n name,\n rscName,\n bundle,\n route = '/',\n runtime = 'webpack',\n data,\n nextData,\n scripts = [],\n shared = Promise.resolve({}),\n remoteShared = {},\n container,\n}: LoadRemoteComponentProps): Promise<LoaderResult> {\n try {\n // Load scripts if using webpack runtime\n if (runtime === 'webpack') {\n const self = globalThis as GlobalScope;\n // disable webpack entrypoint execution for the remote\n if (!self.__DISABLE_WEBPACK_EXEC__) {\n self.__DISABLE_WEBPACK_EXEC__ = {};\n }\n // disable webpack entrypoint execution for the current remote bundle\n self.__DISABLE_WEBPACK_EXEC__[bundle] = true;\n await loadScripts(scripts);\n }\n\n const hostShared = await shared;\n // Setup webpack runtime environment\n await setupWebpackRuntime(\n runtime,\n scripts,\n url,\n bundle,\n hostShared,\n remoteShared,\n );\n\n // Setup shared modules\n if (bundle) {\n const resolve = {\n '/react/index.js': React,\n '/react/jsx-dev-runtime.js': JSXDevRuntime,\n '/react/jsx-runtime.js': JSXRuntime,\n '/react-dom/index.js': ReactDOM,\n '/react-dom/client.js': ReactDOMClient,\n ...Object.entries(remoteShared).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (typeof hostShared[value] !== 'undefined') {\n acc[key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '')] =\n hostShared[value];\n }\n return acc;\n },\n {},\n ),\n } as Record<string, unknown>;\n await Promise.all(\n Object.entries(resolve).map(async ([key, value]) => {\n if (typeof value === 'function') {\n resolve[key] = await value(bundle);\n }\n return Promise.resolve(value);\n }),\n );\n applySharedModules(bundle, resolve);\n }\n\n // Load component based on data type\n if (data.length > 0) {\n return await loadRSCComponent(rscName ?? name, data);\n } else if (nextData) {\n return loadNextPagesComponent(bundle, route, nextData, name, container);\n }\n\n return loadRSCComponent(rscName ?? name, [`0:[null]\\n`]); // Fallback to empty RSC payload\n } catch (error) {\n return {\n component: null,\n error: new RemoteComponentsError(\n `Failed to load remote component \"${name}\".`,\n {\n cause: error instanceof Error ? error : new Error(String(error)),\n },\n ),\n };\n }\n}\n\n/**\n * Loads RSC (React Server Components) based component\n */\nasync function loadRSCComponent(\n rscName: string,\n data: string[],\n): Promise<LoaderResult> {\n // try to import react-server-dom-webpack from Next.js with a fallback\n let createFromReadableStream;\n try {\n const { createFromReadableStream: _createFromReadableStream } =\n await import(\n 'next/dist/compiled/react-server-dom-webpack/client.browser'\n );\n createFromReadableStream = _createFromReadableStream;\n } catch {\n const {\n default: { createFromReadableStream: _createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n createFromReadableStream = _createFromReadableStream;\n }\n // remote components with RSC requires react-server-dom-webpack\n if (typeof createFromReadableStream !== 'function') {\n throw new RemoteComponentsError(\n 'Failed to import \"react-server-dom-webpack\". Is Next.js installed correctly?',\n );\n }\n\n const stream = createRSCStream(rscName, data);\n const component = createFromReadableStream(stream);\n\n return { component };\n}\n\n/**\n * Loads Next.js Pages Router based component\n */\nfunction loadNextPagesComponent(\n bundle: string,\n route: string,\n nextData: NonNullable<RemoteComponentProps['nextData']>,\n name: string,\n container?: HTMLHeadElement | ShadowRoot | null,\n): LoaderResult {\n const { Component, App } = nextClientPagesLoader(bundle, route, container);\n\n if (!Component) {\n throw new RemoteComponentsError(\n `Remote Component \"${name}\" is trying to load the component for route \"${route}\" but it is not available.`,\n );\n }\n\n // error tolerance when app component is not found\n const component = App\n ? React.createElement(App, { Component, ...nextData.props })\n : React.createElement(Component, nextData.props);\n\n return { component };\n}\n","import { ReadableStream } from 'web-streams-polyfill';\n\n/**\n * Fixes RSC payload to make it compatible with React JSX development runtime\n */\nexport function fixPayload(payload: unknown): void {\n if (Array.isArray(payload)) {\n // if the current node is a React element, we need to fix the payload\n if (payload[0] === '$') {\n // fix the props (children or other React elements)\n fixPayload(payload[3]);\n if (payload.length === 4) {\n // add placeholder for the missing debug info\n payload.push(null, null, 1);\n }\n } else {\n // we are in an array, continue with visiting each item\n for (const item of payload) {\n fixPayload(item);\n }\n }\n } else if (typeof payload === 'object' && payload !== null) {\n // we are in an object, continue with visiting each property\n for (const key in payload) {\n fixPayload((payload as Record<string, unknown>)[key]);\n }\n }\n}\n\n/**\n * Processes RSC flight data and creates a ReadableStream\n */\nexport function createRSCStream(\n rscName: string,\n data: string[],\n): ReadableStream<Uint8Array> {\n return new ReadableStream({\n type: 'bytes',\n start(controller) {\n const encoder = new TextEncoder();\n const self = globalThis as typeof globalThis &\n Record<string, string[] | null>;\n\n // when the remote component RSC scripts are not found or loaded\n // we need to load the RSC flight data parsing the chunks\n if (data.length > 0) {\n data.forEach((chunk) => {\n const lines = chunk.split('\\n');\n for (const line of lines) {\n const match = /\\.push\\(\"(?<rsc>.*)\"\\);$/.exec(line);\n if (match?.groups?.rsc) {\n self[rscName] = self[rscName] ?? [];\n self[rscName].push(JSON.parse(`\"${match.groups.rsc}\"`) as string);\n }\n }\n });\n }\n\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const allChunks = (self[rscName] ?? [`0:[null]\\n`]).join('');\n\n // clear the RSC flight data from the global scope\n self[rscName] = null;\n\n // process each line in the RSC flight data\n allChunks.split('\\n').forEach((chunk) => {\n if (chunk.length > 0) {\n // parse the chunk to get the id, prefix and payload\n const { before, id, prefix, payload } =\n /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\\[.*\\])/.exec(\n chunk,\n )?.groups ?? {};\n\n if (payload) {\n // parse the payload to a JSON object\n const jsonPayload = JSON.parse(payload) as unknown[];\n // fix the payload to make it compatible with React JSX development runtime\n fixPayload(jsonPayload);\n // reconstruct the chunk to a string\n const reconstruct = `${before ?? ''}${id}:${prefix ?? ''}${JSON.stringify(jsonPayload)}`;\n // encode the chunk to a byte buffer\n controller.enqueue(encoder.encode(`${reconstruct}\\n`));\n } else {\n // add empty line before closing the stream\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n } else {\n // add empty line before closing the stream\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n });\n // close the stream when all chunks are enqueued\n controller.close();\n },\n });\n}\n","import { RemoteComponentsError } from '../error';\n\n/**\n * Loads external scripts for remote components\n */\nexport async function loadScripts(scripts: { src: string }[]): Promise<void> {\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newSrc = new URL(\n // remove the remote component bundle name identifier from the script src\n script.src.replace(/\\/_next\\/\\[.+\\](?<whitespace>%20| )/, '/_next/'),\n location.origin,\n ).href;\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n };\n newScript.onerror = () => {\n reject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n };\n newScript.src = newSrc;\n newScript.async = true;\n document.head.appendChild(newScript);\n });\n }),\n );\n}\n","/**\n * The headers to use when fetching the remote component.\n */\nexport function remoteFetchHeaders(\n additionalHeaders: Headers | Record<string, string> | undefined,\n) {\n return {\n /**\n * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.\n * Ensure the automation bypass secret is the same on the client and host.\n * Otherwise, manually specify x-vercel-protection-bypass for the remote in the `additionalHeaders` parameter.\n */\n ...(typeof process === 'object' &&\n typeof process.env === 'object' &&\n typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === 'string'\n ? {\n 'x-vercel-protection-bypass':\n process.env.VERCEL_AUTOMATION_BYPASS_SECRET,\n }\n : {}),\n ...Object.fromEntries(\n additionalHeaders instanceof Headers\n ? additionalHeaders.entries()\n : Object.entries(additionalHeaders ?? {}),\n ),\n Accept: 'text/html',\n };\n}\n","import { RemoteComponentsError } from '#internal/shared/error';\n\nexport type Runtime = 'webpack' | 'turbopack' | 'script' | 'unknown';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime(bundle ?? 'default', shared, remoteShared);\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(url, bundle, shared, remoteShared);\n } else if (type === 'script') {\n const { scriptRuntime } = await import(`./script`);\n return scriptRuntime();\n }\n throw new RemoteComponentsError(\n `Remote Components runtime \"${type}\" is not supported. Supported runtimes are \"webpack\", \"turbopack\", and \"script\".`,\n );\n}\n"],"mappings":";;;;;;;;;;;AASO,SAAS,8BAA8B,KAAyB;AACrE,SAAO,IAAI;AAAA,IACT,wCAAwC;AAAA,EAC1C;AACF;AAEO,SAAS,kCAAkC,KAAa,OAAgB;AAC7E,SAAO,IAAI;AAAA,IACT,0CAA0C;AAAA,IAC1C,EAAE,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,EAAE;AAAA,EACrE;AACF;AApBA,IAAa;AAAb;AAAA;AAAA;AAAO,IAAM,wBAAN,cAAoC,MAAM;AAAA,MAC/C,OAAO;AAAA,MAEP,YAAY,SAAiB,SAA+B;AAC1D,cAAM,SAAS,OAAO;AACtB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA;AAAA;;;ACJO,SAAS,sBACd,QACA,OACA,iBAAsD,SAAS,MAC/D;AAEA,QAAM,OAAO;AAwDb,QAAM,kBAAkB,SAAS;AAAA,IAC/B,qDAAqD,wBAAwB;AAAA,EAC/E;AACA,MAAI,iBAAiB;AACnB,oBAAgB,YAAY,YAAY,eAAe;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IAAI,IAAI,KAAK,CAAC;AAAA,UACxD,EAAE,IAAI,OAAO,UAAU;AACrB,gBAAI;AACF,oBAAM,MAAM,KAAK,IAAI;AAAA,YACvB,SAAS,GAAP;AAEA,sBAAQ;AAAA,gBACN,IAAI;AAAA,kBACF,yDAAyD,IAAI;AAAA,kBAC7D,EAAE,OAAO,EAAW;AAAA,gBACtB;AAAA,cACF;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAEA,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAGA,iBAAe,OAAO,oBAAoB,eAAe;AAC3D;AAEO,SAAS,sBACd,UAAkD,CAAC,GACnD;AACA,QAAM,OAAO;AAOb,MAAI,CAAC,KAAK,0CAA0C;AAElD,SAAK,2CAA2C,CAAC;AAAA,EACnD;AAEA,SAAO,QAAQ,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChD,QAAI,KAAK,0CAA0C;AACjD,WAAK,yCAAyC,GAAG,IAAI;AAAA,IACvD;AAAA,EACF,CAAC;AACH;","names":["resolve","webpackRuntime","turbopackRuntime","scriptRuntime","jsx","parser","doc","self","nextClientPagesLoader"]}
|
|
1
|
+
{"version":3,"sources":["../../src/shared/error.ts","../../src/shared/webpack/next-client-pages-loader.ts","../../src/shared/webpack/shared-modules.ts","../../src/shared/utils/index.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/shared/client/static-loader.ts","../../src/shared/client/polyfill.tsx","../../src/html/host/runtime/webpack.ts","../../src/html/host/runtime/turbopack.ts","../../src/html/host/runtime/script.ts","../../src/html/host/index.tsx","../../src/shared/client/apply-origin.ts","../../src/shared/client/remote-component.ts","../../src/shared/client/component-loader.ts","../../src/shared/client/rsc.ts","../../src/shared/client/script-loader.ts","../../src/shared/ssr/fetch-headers.ts","../../src/html/host/runtime/index.ts"],"sourcesContent":["export class RemoteComponentsError extends Error {\n code = 'REMOTE_COMPONENTS_ERROR';\n\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RemoteComponentsError';\n }\n}\n\nexport function multipleRemoteComponentsError(url: string | undefined) {\n return new Error(\n `Multiple Remote Components found at \"${url}\". When a page exposes multiple Remote Components you must specify the \"name\" prop to select which one to load.`,\n );\n}\n\nexport function failedToFetchRemoteComponentError(url: string, error: unknown) {\n return new RemoteComponentsError(\n `Failed to fetch Remote Component from \"${url}\". Is the URL correct and accessible?`,\n { cause: error instanceof Error ? error : new Error(String(error)) },\n );\n}\n","import { RemoteComponentsError } from '../error';\n\n// module loader for Next.js Pages Router\nexport function nextClientPagesLoader(\n bundle: string,\n route: string,\n styleContainer: HTMLHeadElement | ShadowRoot | null = document.head,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n c?: Record<\n string | number,\n { id: string; parents: string[]; children: string[] }\n >;\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: 'turbopack' | 'webpack';\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // Next.js client pages loader reference storage\n __NEXT_P?: [\n (\n | [\n string,\n () => { default?: React.ComponentType<Record<string, unknown>> },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n ];\n // Next.js Pages Router CSS cache\n __remote_next_css__?: Record<string, ChildNode[]>;\n };\n\n // temporarily remove the original Next.js CSS loader\n const nextCssOriginal = document.querySelector(\n `[id=\"__next_css__DO_NOT_USE__\"]:not([data-bundle=\"${bundle}\"][data-route=\"${route}\"])`,\n );\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.removeChild(nextCssOriginal);\n }\n\n // create a new Next.js CSS loader element\n const nextCss = document.createElement('noscript');\n nextCss.id = '__next_css__DO_NOT_USE__';\n nextCss.setAttribute('data-bundle', bundle);\n nextCss.setAttribute('data-route', route);\n const nextCssEnd = document.createElement('noscript');\n nextCssEnd.id = '__next_css__DO_NOT_USE_END__';\n nextCssEnd.setAttribute('data-bundle', bundle);\n nextCssEnd.setAttribute('data-route', route);\n document.head.appendChild(nextCssEnd);\n document.head.appendChild(nextCss);\n\n // find the page component loader chunk\n const componentLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}!`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}!`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // find the app loader chunk\n const appLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // if we didn't find the component loader or app loader, throw an error\n if (!(componentLoaderChunk && appLoaderChunk)) {\n throw new RemoteComponentsError(\n `Next.js client pages loader not found in bundle \"${bundle}\".`,\n );\n }\n\n // temporarily store the original __NEXT_P reference\n // this is required to avoid conflicts with the Next.js client pages loader\n // which uses the same global variable to store the page components\n const __NEXT_P_ORIGINAL = self.__NEXT_P;\n const selfOriginal = self;\n delete selfOriginal.__NEXT_P;\n\n // load the component and app loader chunks\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? componentLoaderChunk\n : `[${bundle}] ${componentLoaderChunk}`,\n );\n if (\n typeof appLoaderChunk === 'string' ||\n (typeof appLoaderChunk === 'number' && appLoaderChunk !== -1)\n ) {\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? appLoaderChunk\n : `[${bundle}] ${appLoaderChunk}`,\n );\n }\n\n // if we have the __NEXT_P global variable, we can extract the component and app\n if (self.__NEXT_P) {\n const [, componentLoader] = self.__NEXT_P[0] ?? [\n undefined,\n () => ({ default: null }),\n ];\n const [, appLoader] = self.__NEXT_P[2] ?? [\n undefined,\n () => ({\n default: null,\n }),\n ];\n const { default: Component } = componentLoader();\n const { default: App } = appLoader();\n\n if (!self.__remote_next_css__) {\n // eslint-disable-next-line camelcase\n self.__remote_next_css__ = {};\n }\n\n if (!self.__remote_next_css__[bundle]) {\n // load the CSS files from the remote bundle\n const cssRE = /\\.s?css$/;\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {})\n .filter((id) => cssRE.test(id))\n .forEach((id) => {\n self.__remote_webpack_require__?.[bundle]?.(id);\n });\n\n Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {})\n .filter((path) => cssRE.test(path))\n .forEach((path) => {\n const id = self.__remote_webpack_module_map__?.[bundle]?.[path];\n if (id) {\n self.__remote_webpack_require__?.[bundle]?.(id);\n }\n });\n\n const elements = [];\n let node = nextCss.previousSibling;\n while (node && node !== nextCssEnd) {\n elements.push(node);\n node.remove();\n node = nextCss.previousSibling;\n }\n self.__remote_next_css__[bundle] = elements;\n }\n\n // if the styleContainer is provided, we need to move the styles to it\n if (styleContainer) {\n const elements = self.__remote_next_css__[bundle];\n elements.forEach((el) => {\n styleContainer.appendChild(el.cloneNode(true));\n });\n } else {\n // if no styleContainer is provided, we need to move the styles back to the head\n const elements = self.__remote_next_css__[bundle];\n elements.forEach((el) => {\n document.head.appendChild(el);\n });\n }\n\n // restore the original __NEXT_P reference\n delete self.__NEXT_P;\n self.__NEXT_P = __NEXT_P_ORIGINAL;\n\n // restore the original Next.js CSS loader\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.appendChild(nextCssOriginal);\n }\n\n nextCss.remove();\n nextCssEnd.remove();\n\n return { Component, App };\n }\n\n return { Component: null, App: null };\n}\n","// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // if we have the bundle\n if (self.__remote_webpack_require__?.[bundle]) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ??\n self.__remote_webpack_require__[bundle].m ??\n {},\n );\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n let ids = modulePaths.filter((p) => p === key);\n if (ids.length === 0) {\n ids = modulePaths.filter((p) => p.includes(key));\n }\n for (let id of ids) {\n const webpackBundle = self.__remote_webpack_require__[bundle];\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {\n id = `${self.__remote_webpack_module_map__[bundle][id]}`;\n }\n // create a mock module which exports the shared module\n webpackBundle.m[id] = (module) => {\n module.exports = value;\n };\n }\n }\n }\n }\n}\n","export function escapeString(str: string) {\n return str.replace(/[^a-z0-9]/g, '_');\n}\n\nexport const attrToProp = {\n fetchpriority: 'fetchPriority',\n crossorigin: 'crossOrigin',\n imagesrcset: 'imageSrcSet',\n imagesizes: 'imageSizes',\n srcset: 'srcSet',\n} as Record<string, string>;\n","import { escapeString } from '../utils';\n\nexport const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\nexport const RUNTIME_SCRIPT = 'script';\n\nexport const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\nexport function getBundleKey(bundle: string): string {\n return escapeString(bundle);\n}\n\nexport type Runtime =\n | typeof RUNTIME_WEBPACK\n | typeof RUNTIME_TURBOPACK\n | typeof RUNTIME_SCRIPT;\n","import { RemoteComponentsError } from '../error';\nimport {\n getBundleKey,\n REMOTE_COMPONENT_REGEX,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n type Runtime,\n} from './const';\nimport type { GlobalScope } from './types';\n\n/**\n * Sets up webpack runtime environment for remote components\n */\nexport async function setupWebpackRuntime(\n runtime: Runtime,\n scripts: { src: string | null }[] = [],\n url: URL = new URL(location.href),\n bundle?: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n): Promise<void> {\n const self = globalThis as GlobalScope;\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n self.__remote_bundle_url__[bundle ?? 'default'] = url;\n // eslint-disable-next-line camelcase\n self.__webpack_get_script_filename__ = () => null;\n\n if (\n typeof self.__webpack_require__ !== 'function' ||\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n if (\n !self.__original_webpack_require__ &&\n !self.__original_webpack_chunk_load__\n ) {\n // eslint-disable-next-line camelcase\n self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;\n // eslint-disable-next-line camelcase\n self.__original_webpack_require__ = self.__webpack_require__;\n }\n\n self.__webpack_chunk_load__ = createChunkLoader(runtime);\n self.__webpack_require__ = createModuleRequire(runtime);\n // eslint-disable-next-line camelcase\n self.__webpack_require_type__ = runtime;\n\n if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {\n const remoteBundle = bundle ?? 'default';\n self.__remote_webpack_require__[remoteBundle] =\n self.__webpack_require__ as (remoteId: string | number) => unknown;\n self.__remote_webpack_require__[remoteBundle].type = 'turbopack';\n }\n }\n // load all initial chunks when using Turbopack runtime\n if (runtime === RUNTIME_TURBOPACK) {\n await Promise.all(\n scripts.map((script) => {\n if (script.src) {\n return self.__webpack_chunk_load__?.(script.src, bundle);\n }\n return Promise.resolve(undefined);\n }),\n );\n }\n\n // initialize shared modules\n await initializeSharedModules(\n bundle ?? 'default',\n // include all core modules as shared\n {\n react: async () => (await import('react')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n ...shared,\n },\n remoteShared,\n );\n}\n\n/**\n * Creates chunk loader function for webpack runtime\n */\nfunction createChunkLoader(\n runtime: Runtime,\n): (chunkId: string) => Promise<unknown> | undefined {\n // eslint-disable-next-line camelcase\n return function __turbopack_chunk_load__(\n chunkId: string,\n scriptBundle?: string,\n ) {\n const self = globalThis as GlobalScope;\n const {\n bundle,\n id: path,\n prefix,\n } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {\n bundle: scriptBundle ?? '',\n id: chunkId,\n };\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : runtime;\n if (remoteRuntime === RUNTIME_WEBPACK) {\n // all scripts are already loaded for this remote\n return Promise.resolve(undefined);\n }\n\n const url = new URL(\n path\n ? `${prefix ?? ''}${path}`.replace(\n /(?<char>[^:])(?<double>\\/\\/)/g,\n '$1/',\n )\n : '/',\n self.__remote_bundle_url__?.[bundle ?? 'default'] ??\n new URL(location.origin),\n ).href;\n if (url.endsWith('.css')) {\n return;\n }\n\n if (!self.__remote_components_turbopack_chunk_loader_promise__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_chunk_loader_promise__ = {};\n }\n if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {\n return self.__remote_components_turbopack_chunk_loader_promise__[url];\n }\n\n self.__remote_components_turbopack_chunk_loader_promise__[url] =\n new Promise((resolve, reject) => {\n fetch(url)\n .then((res) => res.text())\n .then((code) => {\n if (code.includes('globalThis.TURBOPACK')) {\n return handleTurbopackChunk(code, bundle ?? '', url);\n }\n })\n .then(resolve)\n .catch(reject);\n });\n\n return self.__remote_components_turbopack_chunk_loader_promise__[url];\n };\n}\n\n/**\n * Handles Turbopack chunk loading\n */\nasync function handleTurbopackChunk(\n code: string,\n bundle: string,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (/importScripts\\(\\.\\.\\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {\n // remove preload links for this chunk\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n\n // replace global variables with bundle-specific ones\n const transformedCode = code\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`,\n )\n .replace(/__next_require__/g, `__${bundleKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${\n new URL(\n '.',\n new URL(\n url,\n self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin),\n ),\n ).href\n }$1$2.js.map`,\n );\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.setAttribute('data-turbopack-src', url);\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n script.remove();\n };\n script.onerror = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n script.remove();\n };\n document.head.appendChild(script);\n });\n const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkLists = [] as (Promise<unknown> | undefined)[];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n chunks.forEach((id: string) => {\n const chunkLoadResult = self.__webpack_chunk_load__?.(\n `[${bundle}] ${url.slice(0, url.indexOf('/_next'))}/_next/${id}`,\n );\n if (chunkLoadResult) {\n loadChunkLists.push(chunkLoadResult);\n }\n });\n }\n }\n if (loadChunkLists.length > 0) {\n await Promise.all(loadChunkLists);\n }\n}\n\n/**\n * Creates module require function for webpack runtime\n */\nfunction createModuleRequire(runtime: Runtime): (id: string) => unknown {\n return (id: string) => {\n const self = globalThis as GlobalScope;\n const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)\n ?.groups ?? {\n bundle: 'default',\n id,\n };\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : runtime;\n try {\n if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {\n return self.__remote_webpack_require__?.[bundle]?.(moduleId);\n }\n const sharedModule = getSharedModule(bundle ?? 'default', moduleId ?? id);\n if (sharedModule) {\n return sharedModule;\n }\n if (bundle && moduleId) {\n return handleTurbopackModule(bundle, moduleId, id);\n }\n throw new Error(`Module \"${id}\" not found.`);\n } catch (requireError) {\n if (typeof self.__original_webpack_require__ !== 'function') {\n throw new RemoteComponentsError(\n `Module \"${id}\" not found in remote component bundle \"${bundle}\".`,\n {\n cause: requireError instanceof Error ? requireError : undefined,\n },\n );\n }\n try {\n return self.__original_webpack_require__(id);\n } catch (originalError) {\n throw new RemoteComponentsError(\n `Module \"${id}\" not found in remote component bundle \"${bundle}\".`,\n { cause: originalError instanceof Error ? originalError : undefined },\n );\n }\n }\n };\n}\n\nasync function initializeSharedModules(\n bundle: string,\n hostShared: Record<string, (bundle?: string) => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n) {\n const self = globalThis as GlobalScope & {\n __next_f?: unknown[];\n };\n // eslint-disable-next-line camelcase\n self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};\n\n if (!self.__remote_shared_modules__[bundle]) {\n self.__remote_shared_modules__[bundle] = {};\n }\n\n // prepare to load shared module initializers from the Turbopack bundle\n const bundleKey = getBundleKey(bundle);\n const modules = self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined;\n let sharedModuleInitializer: Promise<{\n shared: Record<string, string | (() => Promise<unknown>)>;\n }> | null = null;\n\n // find the shared module initializer in the Turbopack bundle\n if (modules && Array.isArray(modules)) {\n const allModules = modules.flat();\n // find the shared module initializer module id\n const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {\n if (typeof idOrFunc !== 'function') {\n return false;\n }\n const funcCode = idOrFunc.toString();\n // look for the specific pattern in the function code\n return /[a-z]\\.TURBOPACK_REMOTE_SHARED/.test(funcCode);\n });\n\n // if found, extract the shared module initializer\n // first element in the array is always the source script element\n if (sharedModuleInitializerIndex > 0) {\n const sharedModuleInitializerCode = (\n allModules[sharedModuleInitializerIndex] as () => unknown\n ).toString();\n const sharedModuleInitializerId = allModules[\n sharedModuleInitializerIndex - 1\n ] as string | number;\n // extract the shared module id from the function code\n const { sharedModuleId } =\n /\\.TURBOPACK_REMOTE_SHARED=await e\\.A\\((?<sharedModuleId>[0-9]+)\\)/.exec(\n sharedModuleInitializerCode,\n )?.groups ?? {};\n // load the shared module initializer using the extracted module id\n if (sharedModuleId) {\n // load the shared module initializer\n const { default: sharedModuleInitializerInstance } =\n handleTurbopackModule(\n bundle,\n sharedModuleId,\n `[${bundle}] ${sharedModuleInitializerId}`,\n ) as {\n default: Promise<{\n shared: Record<string, string | (() => Promise<unknown>)>;\n }>;\n };\n // save the shared module initializer for later use\n sharedModuleInitializer = sharedModuleInitializerInstance;\n }\n }\n\n // if we have a shared module initializer, load the shared modules from the host application\n if (sharedModuleInitializer) {\n // async load the shared modules using the initializer\n const { shared } = await sharedModuleInitializer;\n // map shared module ids to their initializer functions\n const sharedModuleIds = Object.entries(shared)\n .filter(([, value]) => typeof value === 'function')\n .reduce<Record<string, string>>((acc, [key, value]) => {\n // extract the module id from the function code\n const { asyncSharedModuleId } =\n /e\\.A\\((?<asyncSharedModuleId>[0-9]+)\\)/.exec(value.toString())\n ?.groups ?? {};\n if (asyncSharedModuleId) {\n const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);\n\n let asyncSharedModule;\n const newAllModules =\n (\n self[`TURBOPACK_${bundleKey}`] as unknown[] | undefined\n )?.flat() ?? [];\n const asyncSharedModuleIdIndex = newAllModules.indexOf(\n asyncSharedModuleIdNumber,\n );\n if (\n asyncSharedModuleIdIndex !== -1 &&\n typeof newAllModules[asyncSharedModuleIdIndex + 1] === 'function'\n ) {\n asyncSharedModule = newAllModules[\n asyncSharedModuleIdIndex + 1\n ] as () => unknown;\n }\n if (asyncSharedModule) {\n const asyncSharedModuleCode = asyncSharedModule.toString();\n // extract the shared module id from the async module loader function code\n const { sharedModuleId } =\n /e=>{e\\.v\\(e=>Promise\\.resolve\\(\\)\\.then\\(\\(\\)=>e\\((?<sharedModuleId>[0-9]+)\\)\\)\\)}/.exec(\n asyncSharedModuleCode,\n )?.groups ??\n /e=>{e\\.v\\(t=>Promise\\.all\\(\\[\"[^\"]+\"\\].map\\(t=>e\\.l\\(t\\)\\)\\)\\.then\\(\\(\\)=>t\\((?<sharedModuleId>[0-9]+)\\)\\)\\)}/.exec(\n asyncSharedModuleCode,\n )?.groups ??\n {};\n\n // map the shared module id to the actual module name\n acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(\n '__remote_shared_module_',\n '',\n );\n }\n }\n return acc;\n }, {});\n\n // load shared modules from the host application\n return Promise.all(\n Object.entries(sharedModuleIds).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n if (hostShared[module]) {\n self.__remote_shared_modules__[bundle][id] =\n await hostShared[module](bundle);\n }\n }\n }),\n );\n }\n }\n\n // ensure that the shared modules are initialized\n return Promise.all(\n Object.entries(remoteShared).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n if (hostShared[module]) {\n self.__remote_shared_modules__[bundle][\n id.replace('[app-ssr]', '[app-client]')\n ] = await hostShared[module](bundle);\n } else {\n // eslint-disable-next-line no-console\n console.error(`Shared module \"${module}\" not found for \"${bundle}\".`);\n }\n }\n }),\n );\n}\n\n/**\n * Returns shared modules for common dependencies\n */\nfunction getSharedModule(bundle: string, id: string | number): unknown {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, unknown>;\n };\n\n for (const [key, value] of Object.entries(\n self.__remote_shared_modules__?.[bundle] ?? {},\n )) {\n if (\n typeof value !== 'undefined' &&\n ((typeof id === 'string' && id.includes(key)) || id === key)\n ) {\n return value;\n }\n }\n return null;\n}\n\ntype TurbopackModuleInit = (\n turbopackContext: unknown,\n module: unknown,\n exports: unknown,\n) => void;\n/**\n * Handles Turbopack module resolution\n */\nfunction handleTurbopackModule(\n bundle: string,\n moduleId: string,\n id: string,\n): unknown {\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n const modules = self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined;\n let moduleInit: TurbopackModuleInit | undefined;\n\n // flatten the modules array to simplify searching for the module\n const allModules = modules?.flat() ?? [];\n if (typeof allModules[1] === 'string' || typeof allModules[1] === 'number') {\n // convert moduleId to number if it's numeric\n const normalizedId = /^[0-9]+$/.test(moduleId)\n ? Number(moduleId)\n : moduleId;\n // try to find the module by its id\n let moduleIdIndex = allModules.indexOf(normalizedId);\n if (moduleIdIndex === -1) {\n // fallback: try to find the module by partial match (for cases where moduleId is a path)\n moduleIdIndex = allModules.findIndex(\n (bundleEntry) =>\n (typeof bundleEntry === 'string' &&\n bundleEntry.startsWith(moduleId)) ||\n bundleEntry === normalizedId,\n );\n }\n if (moduleIdIndex !== -1) {\n // iterate to find the next function which is the module initializer\n while (\n typeof allModules[moduleIdIndex] !== 'function' &&\n moduleIdIndex < allModules.length\n ) {\n moduleIdIndex++;\n }\n // get the module initializer function\n moduleInit = allModules[moduleIdIndex] as TurbopackModuleInit;\n }\n } else {\n // legacy Turbopack format where modules are mapped by objects\n moduleInit = (\n allModules.find(\n (bundleEntry) =>\n typeof bundleEntry === 'object' &&\n bundleEntry !== null &&\n moduleId in bundleEntry,\n ) as Record<string, TurbopackModuleInit | string | number> | undefined\n )?.[moduleId] as TurbopackModuleInit;\n }\n const exports = {} as Record<string, unknown>;\n const moduleExports = { exports };\n\n // prepare module cache\n if (!self.__remote_components_turbopack_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_modules__ = {};\n }\n if (!self.__remote_components_turbopack_modules__[bundle]) {\n self.__remote_components_turbopack_modules__[bundle] = {};\n }\n if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {\n return self.__remote_components_turbopack_modules__[bundle][moduleId];\n }\n\n // if module initializer is not found, throw an error\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\n\n // store a reference to the module exports in the module cache\n self.__remote_components_turbopack_modules__[bundle][moduleId] =\n moduleExports.exports;\n\n // prepare global object for the bundle if not already present\n if (!self.__remote_components_turbopack_global__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_global__ = {};\n }\n if (!self.__remote_components_turbopack_global__[bundle]) {\n self.__remote_components_turbopack_global__[bundle] = {};\n }\n\n // execute the module initializer function\n moduleInit(\n {\n // HMR not implemented for Remote Components\n k: {\n register() {\n // omit\n },\n registerExports() {\n // omit\n },\n signature() {\n return (fn: unknown) => {\n return fn;\n };\n },\n },\n // esm\n s(\n bindings:\n | Record<string, () => unknown>\n | [...([string, () => unknown] | [string, number, () => unknown])],\n esmId?: string | number,\n ) {\n let mod = exports;\n if (typeof esmId === 'string' || typeof esmId === 'number') {\n if (!self.__remote_components_turbopack_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_modules__ = {};\n }\n\n if (!self.__remote_components_turbopack_modules__[bundle]) {\n self.__remote_components_turbopack_modules__[bundle] = {};\n }\n\n if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {\n self.__remote_components_turbopack_modules__[bundle][esmId] =\n {} as Record<string, unknown>;\n }\n\n mod = self.__remote_components_turbopack_modules__[bundle][\n esmId\n ] as Record<string, unknown>;\n }\n\n Object.defineProperty(mod, '__esModule', { value: true });\n if (Array.isArray(bindings)) {\n let i = 0;\n while (i < bindings.length) {\n const propName = bindings[i++] as string;\n const tagOrFunc = bindings[i++];\n if (typeof tagOrFunc === 'number') {\n Object.defineProperty(mod, propName, {\n value: bindings[i++],\n enumerable: true,\n writable: false,\n });\n } else {\n const getterFn = tagOrFunc as () => unknown;\n if (typeof bindings[i] === 'function') {\n const setterFn = bindings[i++] as (v: unknown) => unknown;\n Object.defineProperty(mod, propName, {\n get: getterFn,\n set: setterFn,\n enumerable: true,\n });\n } else {\n Object.defineProperty(mod, propName, {\n get: getterFn,\n enumerable: true,\n });\n }\n }\n }\n }\n },\n // import\n i(importId: string | number) {\n let mod: Record<string, unknown> | undefined;\n if (typeof importId === 'string') {\n // parse export syntax if present\n const { exportSource, exportName } =\n /\\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(\n importId,\n )?.groups ?? {};\n const normalizedId = importId.replace(\n /\\s+<export(?<specifier>.*)>$/,\n '',\n );\n // load the module using the normalized id\n mod = self.__webpack_require__?.(\n `[${bundle}] ${normalizedId}`,\n ) as Record<string, unknown>;\n // if export syntax is used, map the requested export to the module exports\n if (\n exportSource &&\n exportName &&\n (exportSource === '*' ||\n typeof mod[exportSource] !== 'undefined') &&\n typeof mod[exportName] === 'undefined'\n ) {\n if (exportSource === '*') {\n mod[exportName] = mod;\n } else {\n mod[exportName] = mod[exportSource];\n }\n }\n } else {\n // numeric ids can be used directly\n mod = self.__webpack_require__?.(`[${bundle}] ${importId}`) as Record<\n string,\n unknown\n >;\n }\n if (typeof mod !== 'object') {\n mod = { default: mod };\n } else if (\n !('default' in mod) &&\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n mod.toString() !== '[object Module]'\n ) {\n try {\n mod.default = mod;\n } catch {\n // ignore if mod is not extensible\n }\n }\n return mod;\n },\n // require\n r(requireId: string) {\n return self.__webpack_require__?.(`[${bundle}] ${requireId}`);\n },\n // value exports\n v(value: unknown) {\n if (typeof value === 'function') {\n exports.default = value((vid: string | number) => {\n return self.__webpack_require__?.(`[${bundle}] ${vid}`);\n });\n } else {\n moduleExports.exports = value as Record<string, unknown>;\n }\n },\n // async module initializer\n async a(\n mod: (\n handleDeps: unknown,\n setResult: (value: unknown) => void,\n ) => Promise<void>,\n ) {\n let result;\n await mod(\n () => {\n // not implemented\n },\n (value) => (result = value),\n );\n exports.default = result;\n },\n // async module loader\n async A(Aid: string) {\n const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`) as {\n default: (\n parentImport: (parentId: string) => unknown,\n ) => Promise<unknown>;\n };\n return mod.default((parentId: string) =>\n self.__webpack_require__?.(`[${bundle}] ${parentId}`),\n );\n },\n // chunk loader\n l(url: string) {\n // try to find the script tag that loaded the current module\n const moduleInitIndex = allModules.indexOf(moduleInit);\n if (moduleInitIndex !== -1) {\n const scriptIndex = allModules\n .slice(0, moduleInitIndex)\n .findLastIndex((bundleEntry) => bundleEntry instanceof Element);\n if (scriptIndex !== -1) {\n const script = allModules[scriptIndex] as HTMLScriptElement;\n // use the original script src to construct the chunk url\n const scriptSrc = script.getAttribute('data-turbopack-src') || '';\n // construct the full chunk url based on the current script src\n const nextIndex = scriptSrc.indexOf('/_next');\n const baseUrl =\n nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : '';\n const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;\n return self.__webpack_chunk_load__?.(bundleUrl, bundle);\n }\n }\n throw new Error(\n `Failed to load Turbopack chunk \"${url}\" for module \"${id}\". Check the URL is correct.`,\n );\n },\n // global\n g: self.__remote_components_turbopack_global__[bundle],\n m: moduleExports,\n e: exports,\n },\n moduleExports,\n exports,\n );\n\n // update the module cache with the final exports\n if (\n self.__remote_components_turbopack_modules__[bundle][moduleId] !==\n moduleExports.exports\n ) {\n self.__remote_components_turbopack_modules__[bundle][moduleId] =\n moduleExports.exports;\n }\n\n return moduleExports.exports;\n}\n","import { RemoteComponentsError } from '../error';\nimport type {\n MountOrUnmountFunction,\n RemoteComponentMountUnmount,\n} from './types';\n\nexport async function loadStaticRemoteComponent(\n scripts: HTMLScriptElement[],\n url: URL,\n) {\n const self = globalThis as typeof globalThis & RemoteComponentMountUnmount;\n if (self.__remote_script_entrypoint_mount__?.[url.href]) {\n self.__remote_script_entrypoint_mount__[url.href] = new Set();\n }\n if (self.__remote_script_entrypoint_unmount__?.[url.href]) {\n self.__remote_script_entrypoint_unmount__[url.href] = new Set();\n }\n const mountUnmountSets = await Promise.all(\n scripts.map(async (script) => {\n try {\n let src =\n typeof script.getAttribute === 'function'\n ? (script.getAttribute('src') ?? script.src)\n : script.src;\n // if there's no src attribute but there is inline script content, create a blob URL for it\n if (!src && script.textContent) {\n const blob = new Blob(\n [\n script.textContent.replace(\n /import\\.meta\\.url/g,\n JSON.stringify(url),\n ),\n ],\n {\n type: 'text/javascript',\n },\n );\n src = URL.createObjectURL(blob);\n }\n const mod = (await import(\n /* @vite-ignore */\n /* webpackIgnore: true */ new URL(src, url).href\n )) as {\n mount?: MountOrUnmountFunction;\n unmount?: MountOrUnmountFunction;\n default?: {\n mount?: MountOrUnmountFunction;\n unmount?: MountOrUnmountFunction;\n };\n };\n // revoke the object URL if we created one\n if (src.startsWith('blob:')) {\n URL.revokeObjectURL(src);\n }\n if (\n typeof mod.mount === 'function' ||\n typeof mod.default?.mount === 'function'\n ) {\n if (!self.__remote_script_entrypoint_mount__) {\n // eslint-disable-next-line camelcase\n self.__remote_script_entrypoint_mount__ = {};\n }\n if (!self.__remote_script_entrypoint_mount__[url.href]) {\n self.__remote_script_entrypoint_mount__[url.href] = new Set();\n }\n self.__remote_script_entrypoint_mount__[url.href]?.add(\n mod.mount ||\n mod.default?.mount ||\n (() => {\n // noop\n }),\n );\n }\n if (\n typeof mod.unmount === 'function' ||\n typeof mod.default?.unmount === 'function'\n ) {\n if (!self.__remote_script_entrypoint_unmount__) {\n // eslint-disable-next-line camelcase\n self.__remote_script_entrypoint_unmount__ = {};\n }\n if (!self.__remote_script_entrypoint_unmount__[url.href]) {\n self.__remote_script_entrypoint_unmount__[url.href] = new Set();\n }\n self.__remote_script_entrypoint_unmount__[url.href]?.add(\n mod.unmount ||\n mod.default?.unmount ||\n (() => {\n // noop\n }),\n );\n }\n return {\n mount: mod.mount || mod.default?.mount,\n unmount: mod.unmount || mod.default?.unmount,\n };\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(\n `Error loading remote component script from \"${script.src || url.href}\".`,\n { cause: e },\n ),\n );\n return {\n mount: undefined,\n unmount: undefined,\n };\n }\n }),\n );\n return mountUnmountSets.reduce(\n (acc, { mount, unmount }) => {\n if (typeof mount === 'function') {\n acc.mount.add(mount);\n }\n if (typeof unmount === 'function') {\n acc.unmount.add(unmount);\n }\n return acc;\n },\n {\n mount: new Set<MountOrUnmountFunction>(),\n unmount: new Set<MountOrUnmountFunction>(),\n },\n );\n}\n","import type { ImageProps, StaticImageData } from 'next/image';\nimport type { LinkProps } from 'next/link';\n\nfunction applyBundleUrlToSrc(bundle: string, src: string) {\n const self = globalThis as typeof globalThis & {\n __remote_bundle_url__?: Record<string, URL>;\n };\n\n if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {\n return src;\n }\n\n const { assetPrefix, path } =\n /^(?<assetPrefix>.*?)\\/_next\\/(?<path>.*)/.exec(src)?.groups ?? {};\n if (!path) {\n return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;\n }\n return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ''}${assetPrefix}/_next/${path}`;\n}\n\nexport function applyBundleUrlToImagePropsSrc(\n bundle: string,\n src: ImageProps['src'],\n) {\n if (typeof src === 'string') {\n return applyBundleUrlToSrc(bundle, src);\n }\n const propSrc = src as StaticImageData;\n return applyBundleUrlToSrc(bundle, propSrc.src);\n}\n\nconst imageImpl = (bundle: string) =>\n function RemoteImage({\n fill: _fill,\n loader: _loader,\n quality: _quality,\n priority: _priority,\n loading: _loading,\n placeholder: _placeholder,\n blurDataURL: _blurDataURL,\n unoptimized: _unoptimized,\n overrideSrc: _overrideSrc,\n src,\n ...props\n }: ImageProps) {\n const newSrc = applyBundleUrlToImagePropsSrc(\n bundle,\n typeof src === 'string' ? src : (src as StaticImageData).src,\n );\n\n return (\n // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text\n <img\n decoding=\"async\"\n style={{ color: 'transparent' }}\n {...props}\n src={newSrc}\n suppressHydrationWarning\n />\n );\n };\n\n// polyfill Next.js App Router client API (minimal)\n// implementations are minimal and do not cover all use cases\n// developer can override these shared modules from configuration\nexport function sharedPolyfills(\n shared?: Record<string, () => Promise<unknown>>,\n) {\n const self = globalThis as typeof globalThis & {\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n };\n const polyfill = {\n 'next/dist/client/components/navigation':\n self.__remote_component_host_shared_modules__?.['next/navigation'] ??\n shared?.['next/navigation'] ??\n (() =>\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n },\n back: () => {\n history.back();\n },\n };\n },\n usePathname() {\n return location.pathname;\n },\n useParams() {\n return {};\n },\n useSearchParams() {\n return new URLSearchParams(location.search);\n },\n useSelectedLayoutSegment() {\n return null;\n },\n useSelectedLayoutSegments() {\n return [];\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/link':\n self.__remote_component_host_shared_modules__?.['next/link'] ??\n shared?.['next/link'] ??\n (() =>\n Promise.resolve({\n default: ({\n scroll: _,\n replace,\n prefetch,\n onNavigate,\n children,\n ...props\n }: React.PropsWithChildren<LinkProps>) => {\n if (prefetch) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Next.js Link prefetch is not supported in remote components',\n );\n }\n return (\n <a\n {...props}\n href={props.href as string}\n onClick={(e) => {\n e.preventDefault();\n let preventDefaulted = false;\n e.preventDefault = () => {\n preventDefaulted = true;\n e.defaultPrevented = true;\n };\n if (typeof props.onClick === 'function') {\n props.onClick(e);\n }\n onNavigate?.(e);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (preventDefaulted) {\n return;\n }\n if (replace) {\n history.replaceState({}, '', props.href as string);\n } else {\n history.pushState({}, '', props.href as string);\n }\n }}\n suppressHydrationWarning\n >\n {children ?? null}\n </a>\n );\n },\n useLinkStatus() {\n return { pending: false };\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/form':\n self.__remote_component_host_shared_modules__?.['next/form'] ??\n shared?.['next/form'] ??\n (() =>\n Promise.resolve({\n default: () => {\n // TODO: implement <Form> component for non-Next.js host applications\n throw new Error('Next.js <Form> component not implemented');\n },\n __esModule: true,\n })),\n 'next/dist/client/image-component':\n self.__remote_component_host_shared_modules__?.['next/image'] ??\n shared?.['next/image'] ??\n ((bundle: string) =>\n Promise.resolve({\n Image: imageImpl(bundle),\n __esModule: true,\n })),\n 'next/image':\n self.__remote_component_host_shared_modules__?.['next/image'] ??\n shared?.['next/image'] ??\n ((bundle: string) =>\n Promise.resolve({\n default: imageImpl(bundle),\n getImageProps: (_imgProps: ImageProps) => {\n throw new Error(\n 'Next.js getImageProps() is not implemented in remote components',\n );\n },\n __esModule: true,\n })),\n 'next/dist/client/script':\n self.__remote_component_host_shared_modules__?.['next/script'] ??\n shared?.['next/script'] ??\n (() =>\n Promise.resolve({\n // TODO: implement <Script> component for non-Next.js host applications\n // do not throw an error for now\n default: () => null,\n __esModule: true,\n })),\n 'next/router':\n self.__remote_component_host_shared_modules__?.['next/router'] ??\n shared?.['next/router'] ??\n (() =>\n // TODO: incomplete implementation\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n },\n back: () => {\n history.back();\n },\n };\n },\n __esModule: true,\n })),\n 'next/dist/build/polyfills/process': () =>\n Promise.resolve({\n default: {\n env: {\n NODE_ENV: 'production',\n },\n },\n __esModule: true,\n }),\n } as Record<string, () => Promise<unknown>>;\n\n polyfill['next/navigation'] = polyfill[\n 'next/dist/client/components/navigation'\n ] as () => Promise<unknown>;\n polyfill['next/link'] = polyfill[\n 'next/dist/client/app-dir/link'\n ] as () => Promise<unknown>;\n polyfill['next/form'] = polyfill[\n 'next/dist/client/app-dir/form'\n ] as () => Promise<unknown>;\n polyfill['next/dist/api/image'] = polyfill[\n 'next/dist/client/image-component'\n ] as () => Promise<unknown>;\n polyfill['next/script'] = polyfill[\n 'next/dist/client/script'\n ] as () => Promise<unknown>;\n\n return polyfill;\n}\n","import type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport { sharedPolyfills } from '../../../shared/client/polyfill';\nimport { RemoteComponentsError } from '../../../shared/error';\nimport { nextClientPagesLoader } from '../../../shared/webpack/next-client-pages-loader';\nimport { applySharedModules } from '../../../shared/webpack/shared-modules';\n\n// initializer for the webpack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function webpackRuntime(\n bundle: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string | number>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__?: Record<string, boolean>;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __webpack_require_type__: 'webpack' | 'turbopack';\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n } & RemoteComponentMountUnmount &\n Record<RSCKey, string[]>;\n\n // disable webpack exec to prevent automatically executing the entry module\n if (!self.__DISABLE_WEBPACK_EXEC__) {\n self.__DISABLE_WEBPACK_EXEC__ = {};\n }\n self.__DISABLE_WEBPACK_EXEC__[bundle] = true;\n // add a custom webpack require function to load remote components from multiple bundles / zones\n if (\n typeof self.__webpack_require__ !== 'function' &&\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n self.__webpack_require__ = (remoteId: string) => {\n const re = /\\[(?<bundle>[^\\]]+)\\] (?<id>.*)/;\n const match = re.exec(remoteId);\n const remoteBundle = match?.groups?.bundle;\n const id = match?.groups?.id;\n if (!(id && remoteBundle)) {\n throw new RemoteComponentsError(\n `Remote Component module \"${remoteId}\" not found. Did you forget to wrap the Next.js config with \\`withRemoteComponents\\` on both host and remote?`,\n );\n }\n if (\n typeof self.__remote_webpack_require__?.[remoteBundle] !== 'function'\n ) {\n throw new RemoteComponentsError(\n `Remote Components are not available in \"${remoteBundle}\". Did you forget to wrap the Next.js config with \\`withRemoteComponents\\` on both host and remote?`,\n );\n }\n return self.__remote_webpack_require__[remoteBundle](id);\n };\n // not used but required by react-server-dom-webpack\n self.__webpack_chunk_load__ = () => {\n return Promise.resolve([]);\n };\n }\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n async function preloadScripts(\n scripts: HTMLScriptElement[],\n url: URL,\n remoteBundle: string,\n _: string,\n ) {\n // we need to properly attach script elements to the document to load the remote component bundles\n // we need to wait for all scripts to load before we can hydrate the remote component\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n newScript.remove();\n };\n newScript.onerror = () => {\n reject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n newScript.remove();\n };\n const scriptSrc =\n script.getAttribute('src') || script.getAttribute('data-src');\n if (scriptSrc) {\n newScript.src = new URL(\n scriptSrc.replace(/\\/_next\\/\\[(?:.+)\\](?:%20| )/, '/_next/'),\n url,\n ).href;\n }\n newScript.async = true;\n document.body.appendChild(newScript);\n // safe to remove the original script element\n script.parentElement?.removeChild(script);\n });\n }),\n );\n\n // module resolution map for the shared modules\n const hostShared = {\n ...sharedPolyfills(shared),\n ...self.__remote_component_host_shared_modules__,\n ...shared,\n } as Record<string, () => Promise<unknown>>;\n const resolve = {\n '/react/index.js': (await import('react')).default,\n '/react/jsx-dev-runtime.js': (await import('react/jsx-dev-runtime'))\n .default,\n '/react/jsx-runtime.js': (await import('react/jsx-runtime')).default,\n '/react-dom/index.js': (await import('react-dom')).default,\n '/react-dom/client.js': (await import('react-dom/client')).default,\n ...Object.entries(remoteShared ?? {}).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (typeof hostShared[value] !== 'undefined') {\n acc[key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '')] =\n hostShared[value];\n }\n return acc;\n },\n {},\n ),\n } as Record<string, unknown>;\n await Promise.all(\n Object.entries(resolve).map(async ([key, value]) => {\n if (typeof value === 'function') {\n resolve[key] = await value(remoteBundle);\n }\n return Promise.resolve(value);\n }),\n );\n\n // apply shared modules to the bundle\n applySharedModules(remoteBundle, resolve);\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","import type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport { sharedPolyfills } from '../../../shared/client/polyfill';\nimport { setupWebpackRuntime } from '../../../shared/client/webpack-adapter';\nimport { nextClientPagesLoader } from '../../../shared/webpack/next-client-pages-loader';\nimport { applySharedModules } from '../../../shared/webpack/shared-modules';\n\n// initializer for the turbopack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function turbopackRuntime(\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __remote_component_shared__?: Record<string, () => Promise<unknown>>;\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n } & RemoteComponentMountUnmount &\n Record<RSCKey, string[]>;\n\n const hostShared = {\n ...sharedPolyfills(shared),\n ...self.__remote_component_host_shared_modules__,\n ...shared,\n ...self.__remote_component_shared__,\n };\n\n await setupWebpackRuntime(\n 'turbopack',\n [],\n url,\n bundle,\n hostShared,\n remoteShared,\n );\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n function preloadScripts(scripts: HTMLScriptElement[], __: URL) {\n return setupWebpackRuntime(\n 'turbopack',\n scripts.map((script) => ({\n src:\n script.getAttribute('src') ||\n script.getAttribute('data-src') ||\n script.src,\n })),\n url,\n bundle,\n hostShared,\n remoteShared,\n );\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","// initializer for the script runtime\n\nimport type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport { loadStaticRemoteComponent } from '../../../shared/client/static-loader';\n\n// required to run exposed client components of the remote component\nexport function scriptRuntime() {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n } & RemoteComponentMountUnmount &\n Record<RSCKey, string[]>;\n\n return {\n self,\n createFromReadableStream: () => Promise.resolve(null),\n applySharedModules: () => Promise.resolve(),\n nextClientPagesLoader: () => ({\n Component: null,\n App: null,\n }),\n preloadScripts: loadStaticRemoteComponent,\n };\n}\n","import { startTransition, useLayoutEffect } from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport { applyOriginToNodes } from '#internal/shared/client/apply-origin';\nimport {\n createRSCStream,\n RemoteComponentsError,\n} from '#internal/shared/client/remote-component';\nimport type {\n RemoteComponentMountUnmount,\n RSCKey,\n} from '#internal/shared/client/types';\nimport {\n failedToFetchRemoteComponentError,\n multipleRemoteComponentsError,\n} from '#internal/shared/error';\nimport { remoteFetchHeaders } from '#internal/shared/ssr/fetch-headers';\nimport { escapeString } from '#internal/shared/utils';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name?: string;\n bundle?: string;\n fallbackSlot?: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n isLoading = false;\n prevIsRemoteComponent = false;\n prevUrl?: URL;\n prevSrc?: string | null = null;\n prevName?: string;\n root?: ShadowRoot | null = null;\n reactRoot?: ReturnType<typeof hydrateRoot>;\n additionalHeaders?: Headers;\n\n static get observedAttributes() {\n return ['src', 'name', 'mode'];\n }\n\n // watch for src attribute changes\n // this is required to reload the remote component when the src attribute is added later\n // this is for rendering the custom element using React\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if ((name === 'src' || name === 'name') && oldValue !== newValue) {\n if (this.getAttribute('src')) {\n this.load().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n // Dispatch error event\n const errorEvent = new Event('error', {\n bubbles: true,\n composed: true,\n });\n Object.assign(errorEvent, {\n error: e,\n src: this.getAttribute('src'),\n });\n this.dispatchEvent(errorEvent);\n this.isLoading = false;\n });\n }\n } else if (name === 'mode' && oldValue !== newValue && this.root) {\n // changing the shadow DOM mode is not supported\n // we need to recreate the shadow DOM and reload the component\n const newRoot = this.attachShadow({\n mode: newValue === 'closed' ? 'closed' : 'open',\n });\n // move all existing children to the new shadow root\n Array.from(this.root.children).forEach((child) => {\n newRoot.appendChild(child);\n });\n this.root = newRoot;\n // reload the remote component to apply the new shadow DOM\n this.load().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n // Dispatch error event\n const errorEvent = new Event('error', {\n bubbles: true,\n composed: true,\n });\n Object.assign(errorEvent, {\n error: e,\n src: this.getAttribute('src'),\n });\n this.dispatchEvent(errorEvent);\n });\n }\n }\n\n async load() {\n // wait for the current call stack to finish\n await new Promise((resolve) => {\n (typeof queueMicrotask === 'function'\n ? queueMicrotask\n : requestAnimationFrame)(() => {\n resolve(undefined);\n });\n });\n\n // prevent multiple loads\n if (this.isLoading) {\n return;\n }\n\n if (!this.root) {\n this.root = this.attachShadow({\n mode: this.getAttribute('mode') === 'closed' ? 'closed' : 'open',\n });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.root.appendChild(this.fallbackSlot);\n }\n\n this.name = this.getAttribute('name') || '__vercel_remote_component';\n this.bundle = 'default';\n\n const additionalHeadersString = this.getAttribute('additional-headers');\n if (additionalHeadersString) {\n this.additionalHeaders = additionalHeadersString\n .split(';')\n .reduce((headers, headerPair) => {\n const [key, value] = headerPair.split(':');\n if (key && value) {\n headers.set(key.trim(), value.trim());\n }\n return headers;\n }, new Headers());\n }\n\n // load when the custom element has an src, data-ssr attribute or contains an SSR remote component div\n if (\n this.hasAttribute('src') ||\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.hasAttribute('data-ssr')\n ) {\n // start loading and hydration\n this.load().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n // Dispatch error event\n const errorEvent = new Event('error', {\n bubbles: true,\n composed: true,\n });\n Object.assign(errorEvent, {\n error: e,\n src: this.getAttribute('src'),\n });\n this.dispatchEvent(errorEvent);\n });\n }\n\n this.isLoading = true;\n const src = this.getAttribute('src');\n\n // Dispatch beforeload event\n const beforeLoadEvent = new Event('beforeload', {\n bubbles: true,\n composed: true,\n });\n Object.assign(beforeLoadEvent, { src });\n this.dispatchEvent(beforeLoadEvent);\n\n const remoteComponentChild =\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.querySelector('div[data-bundle][data-route]');\n\n if (!src && !remoteComponentChild) {\n throw new RemoteComponentsError('\"src\" attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (src) {\n url = new URL(src, window.location.href);\n if (url.hash) {\n this.name = url.hash.slice(1);\n }\n }\n\n if (!remoteComponentChild && url) {\n // fetch the remote component\n const fetchInit = {\n method: 'GET',\n headers: remoteFetchHeaders(this.additionalHeaders),\n credentials: this.getAttribute('credentials') || 'same-origin',\n } as RequestInit;\n\n const res = await fetch(url, fetchInit);\n\n if (!res.ok) {\n let error: Error = failedToFetchRemoteComponentError(url.href, {\n cause: new Error(`${res.status} ${res.statusText}`),\n });\n try {\n const body = await res.text();\n const parser = new DOMParser();\n const doc = parser.parseFromString(body, 'text/html');\n const errorTemplate = doc.querySelector(\n 'template[data-next-error-message]',\n );\n const errorMessage = errorTemplate?.getAttribute(\n 'data-next-error-message',\n );\n const errorStack = errorTemplate?.getAttribute(\n 'data-next-error-stack',\n );\n\n if (errorMessage) {\n error = new RemoteComponentsError(errorMessage);\n if (errorStack) {\n error.stack = errorStack;\n }\n }\n } catch {\n // ignore\n }\n\n throw error;\n }\n\n // get the full HTML content as a string\n html = await res.text();\n }\n // create a virtual element which will be used to parse the HTML and extract the component and RSC flight data\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, 'text/html');\n\n if (\n (doc.querySelectorAll('div[data-bundle][data-route]').length > 1 &&\n !doc.querySelector(\n `div[data-bundle][data-route][id^=\"${this.name}\"]`,\n )) ||\n (doc.querySelectorAll('remote-component').length > 1 &&\n !doc.querySelector(`remote-component[name=\"${this.name}\"]`))\n ) {\n throw multipleRemoteComponentsError(\n url?.href ?? (this.getAttribute('src') || 'unknown'),\n );\n }\n\n // reference to the remote component content\n const component =\n doc.querySelector(`div[data-bundle][data-route][id^=\"${this.name}\"]`) ??\n // fallback to the first element with the data-bundle and data-route attributes when not using a named remote component\n doc.querySelector('div[data-bundle][data-route]') ??\n // fallback to Next.js Pages Router\n doc.querySelector('div#__next') ??\n // fallback to a <remote-component> element\n doc.querySelector(`remote-component[name=\"${this.name}\"]:not([src])`) ??\n doc.querySelector('remote-component:not([src])');\n const nextData = JSON.parse(\n (\n doc.querySelector('#__NEXT_DATA__') ??\n doc.querySelector('#__REMOTE_NEXT_DATA__')\n )?.textContent ?? 'null',\n ) as {\n props: {\n pageProps: Record<string, unknown>;\n __REMOTE_COMPONENT__?: {\n bundle: string;\n runtime: 'turbopack' | 'webpack' | 'script';\n shared?: Record<string, string>;\n };\n };\n page: string;\n buildId: string;\n } | null;\n\n const isRemoteComponent =\n component?.tagName.toLowerCase() === 'remote-component';\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development' && !this.reactRoot) {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.root.appendChild(this.fouc);\n }\n\n this.name =\n component?.getAttribute('id')?.replace(/_ssr$/, '') ||\n (isRemoteComponent && component.getAttribute('name')) ||\n (nextData ? '__next' : this.name);\n // reference to the RSC flight data\n const rsc = doc.querySelector(`#${this.name}_rsc`);\n\n // reference to the bundle containing the client components\n this.bundle =\n component?.getAttribute('data-bundle') ||\n nextData?.props.__REMOTE_COMPONENT__?.bundle ||\n this.bundle;\n\n if (url) {\n const self = globalThis as typeof globalThis & {\n __remote_bundle_url__?: Record<string, URL>;\n };\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n\n self.__remote_bundle_url__[this.bundle ?? 'default'] = url;\n }\n\n // add remote component metadata information at the custom element\n const metadata = document.createElement('script');\n metadata.type = 'application/json';\n metadata.setAttribute('data-remote-component', '');\n const metadataObj = {\n name: this.name,\n bundle: this.bundle,\n route:\n component?.getAttribute('data-route') ??\n nextData?.page ??\n url?.pathname ??\n '/',\n runtime:\n component?.getAttribute('data-runtime') ??\n nextData?.props.__REMOTE_COMPONENT__?.runtime ??\n 'script',\n };\n metadata.textContent = JSON.stringify(metadataObj);\n\n if (\n this.previousElementSibling?.getAttribute('data-remote-component') !==\n null\n ) {\n this.previousElementSibling?.remove();\n }\n this.parentElement?.insertBefore(metadata, this);\n\n const remoteSharedEl = doc.querySelector(\n `#${this.name}_shared[data-remote-components-shared]`,\n );\n const remoteShared =\n nextData?.props.__REMOTE_COMPONENT__?.shared ??\n ((JSON.parse(remoteSharedEl?.textContent ?? '{}') ?? {}) as Record<\n string,\n string\n >);\n remoteSharedEl?.parentElement?.removeChild(remoteSharedEl);\n\n if ('__remote_components_missing_shared__' in remoteShared) {\n throw new RemoteComponentsError(\n remoteShared.__remote_components_missing_shared__,\n );\n }\n\n if (!component || !(rsc || nextData || isRemoteComponent)) {\n throw new RemoteComponentsError(\n `Remote Component not found on ${src}.${this.name !== '__vercel_remote_component' ? ` The name for the <RemoteComponent> is \"${this.name}\". Check <RemoteComponent> usage.` : ''} Did you forget to wrap the content in <RemoteComponent>?`,\n );\n }\n\n if (this.prevIsRemoteComponent) {\n if (this.prevUrl) {\n const prevUrl = this.prevUrl;\n const self = globalThis as typeof globalThis &\n RemoteComponentMountUnmount;\n if (self.__remote_script_entrypoint_unmount__?.[prevUrl.href]) {\n // call unmount() for all registered unmount functions for the previous remote component\n await Promise.all(\n Array.from(\n self.__remote_script_entrypoint_unmount__[prevUrl.href] ?? [],\n ).map(async (unmount) => {\n try {\n await unmount(this.root);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(\n `Error while calling unmount() for Remote Component from ${prevUrl.href}.`,\n { cause: e as Error },\n ),\n );\n }\n }),\n );\n }\n }\n this.root.innerHTML = '';\n }\n // Dispatch change event if this is not the first load\n if (this.prevSrc !== null) {\n const changeEvent = new Event('change', {\n bubbles: true,\n composed: true,\n });\n Object.assign(changeEvent, {\n previousSrc: this.prevSrc,\n nextSrc: src,\n previousName: this.prevName,\n nextName: this.name,\n });\n this.dispatchEvent(changeEvent);\n }\n\n this.prevUrl = url ?? new URL(location.href);\n this.prevIsRemoteComponent = isRemoteComponent;\n this.prevSrc = src;\n this.prevName = this.name;\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n // reference to all script elements in the remote component\n const remoteComponentSrc = this.getAttribute('src');\n\n const attachLinks = async () => {\n // attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links)\n .filter((link) => {\n return !component.contains(link);\n })\n .map((link) => {\n return new Promise<void>((resolve, reject) => {\n const newLink = document.createElement('link');\n if (link.rel === 'stylesheet') {\n newLink.onload = () => {\n resolve();\n };\n newLink.onerror = () => {\n reject(\n new RemoteComponentsError(\n `Failed to load <link href=\"${link.href}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n };\n } else {\n resolve();\n }\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n newLink.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n\n if (remoteComponentSrc) {\n newLink.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n\n this.root?.appendChild(newLink);\n });\n }),\n );\n\n const styles = doc.querySelectorAll<HTMLStyleElement>('style');\n styles.forEach((style) => {\n if (style.parentElement?.tagName.toLowerCase() === 'head') {\n const newStyle = document.createElement('style');\n newStyle.textContent = style.textContent;\n\n if (remoteComponentSrc) {\n newStyle.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n\n this.root?.appendChild(newStyle);\n }\n });\n };\n\n if (!this.reactRoot) {\n // ensure all styles are loaded before hydrating to prevent FOUC\n await attachLinks();\n }\n\n // update all relative URLs to absolute URLs based on the remote component URL\n applyOriginToNodes(doc, url ?? new URL(location.href));\n\n if (!this.reactRoot) {\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n if (!isRemoteComponent && el.tagName.toLowerCase() === 'script') {\n const newScript = document.createElement('script');\n // copy all attributes\n for (const attr of el.attributes) {\n if (attr.name === 'src') {\n newScript.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n newScript.textContent = el.textContent;\n if (remoteComponentSrc) {\n newScript.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n this.root?.appendChild(newScript);\n } else {\n const newEl = el.cloneNode(true) as HTMLElement;\n for (const attr of el.attributes) {\n if (attr.name.startsWith('on')) {\n newEl.setAttribute(attr.name, attr.value);\n }\n }\n this.root?.appendChild(newEl);\n }\n });\n }\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.fallbackSlot?.remove();\n\n // function to apply the reset styles to the shadow DOM\n const applyReset = () => {\n if (\n this.getAttribute('reset') !== null &&\n !this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n // all initial styles to reset inherited styles leaking from the host page\n const allInitial = document.createElement('link');\n allInitial.setAttribute('data-remote-components-reset', '');\n const css = `:host { all: initial; }`;\n const allInitialHref = URL.createObjectURL(\n new Blob([css], { type: 'text/css' }),\n );\n allInitial.href = allInitialHref;\n allInitial.rel = 'stylesheet';\n // we need to revoke the object URL after the stylesheet is loaded to free up memory\n allInitial.onload = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n allInitial.onerror = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n this.root?.prepend(allInitial);\n } else if (\n this.getAttribute('reset') === null &&\n this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n this.root\n .querySelector('link[data-remote-components-reset]')\n ?.remove();\n }\n };\n\n // apply the reset styles if required and not already applied\n if (!this.reactRoot) {\n applyReset();\n }\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n metadataObj.runtime as Runtime,\n url ?? new URL(location.href),\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n );\n\n const scripts = isRemoteComponent\n ? component.querySelectorAll<HTMLScriptElement>('script')\n : doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src],script[data-remote-component-entrypoint]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(\n Array.from(scripts),\n url,\n this.bundle ?? 'default',\n this.name ?? '__vercel_remote_component',\n );\n\n // remove all script elements from the shadow DOM to prevent re-execution of scripts\n if (isRemoteComponent) {\n Array.from(component.children).forEach((child) => {\n if (child.tagName === 'SCRIPT') {\n child.remove();\n }\n });\n }\n\n // cleanup previous remote component instances when a new remote component is loaded\n // this is required when the src attribute is changed to load a new remote component\n const doCleanup = () => {\n if (this.root && remoteComponentSrc) {\n const selector = `[data-remote-component-src]:not([data-remote-component-src=\"${remoteComponentSrc}\"])`;\n const prevCleanup = [\n ...this.root.querySelectorAll(selector),\n ...document.body.querySelectorAll(selector),\n ] as HTMLElement[];\n\n if (prevCleanup.length > 0) {\n prevCleanup.forEach((prev) => {\n prev.remove();\n });\n }\n }\n };\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscName = `__remote_component_rsc_${escapeString(url.href)}_${escapeString(this.name)}`;\n const rscClone = document.createElement('script');\n rscClone.id = `${rscName}_rsc`;\n rscClone.textContent =\n rsc.textContent?.replace(\n new RegExp(`self\\\\[\"${this.name}\"\\\\]`, 'g'),\n `self[\"${rscName}\"]`,\n ) ?? '';\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n initial,\n }: {\n name: string;\n initial: boolean;\n }) => {\n // convert the RSC flight data array into a ReadableStream\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const stream = createRSCStream(\n rscName,\n self[rscName as RSCKey] ?? [`0:[null]\\n`],\n );\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(stream) as React.ReactNode);\n\n useLayoutEffect(() => {\n // clear the RSC flight data from the global scope to free up memory\n if (self[name as RSCKey]) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete self[name as RSCKey];\n }\n const rscScript = document.getElementById(`${name}_rsc`);\n if (rscScript) {\n rscScript.remove();\n }\n\n doCleanup();\n applyReset();\n if (!initial) {\n attachLinks().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n this.isLoading = false;\n\n // Dispatch load event\n const loadEvent = new Event('load', {\n bubbles: true,\n composed: true,\n });\n Object.assign(loadEvent, { src: this.getAttribute('src') });\n this.dispatchEvent(loadEvent);\n }, [initial, name]);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(\n <RemoteComponentFromReadableStream\n initial={false}\n name={this.name ?? '__vercel_remote_component'}\n />,\n );\n });\n return;\n }\n\n // hydrate the remote component using the RSC flight data\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromReadableStream\n initial\n name={this.name ?? '__vercel_remote_component'}\n />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle ?? 'default',\n nextData.page,\n this.root,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n const RemoteComponentFromNext = ((\n NextApp: ReturnType<typeof nextClientPagesLoader>['App'],\n NextComponent: NonNullable<\n ReturnType<typeof nextClientPagesLoader>['Component']\n >,\n remoteComponent = this,\n ) =>\n function RemoteComponentNext({ initial }: { initial: boolean }) {\n useLayoutEffect(() => {\n doCleanup();\n if (!initial) {\n applyReset();\n attachLinks().catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n remoteComponent.isLoading = false;\n\n // Dispatch load event\n const loadEvent = new Event('load', {\n bubbles: true,\n composed: true,\n });\n Object.assign(loadEvent, {\n src: remoteComponent.getAttribute('src'),\n });\n remoteComponent.dispatchEvent(loadEvent);\n }, [initial, remoteComponent]);\n\n return NextApp ? (\n <NextApp Component={NextComponent} {...nextData.props} />\n ) : (\n <NextComponent {...nextData.props} />\n );\n })(App, Component, this);\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(<RemoteComponentFromNext initial={false} />);\n doCleanup();\n this.isLoading = false;\n });\n return;\n }\n\n // hydrate the remote component using the Next.js pages router\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromNext initial />,\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.root.removeChild(this.fouc);\n }\n } else if (self.__remote_script_entrypoint_mount__?.[url.href]) {\n // using script entrypoint when no RSC or Next.js data is available\n await Promise.all(\n Array.from(\n self.__remote_script_entrypoint_mount__[url.href] ?? [],\n ).map(async (mount) => {\n try {\n await mount(this.root);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(\n `Error while calling mount() for Remote Component from ${url.href}.`,\n { cause: e as Error },\n ),\n );\n }\n }),\n );\n\n // Dispatch load event for script entrypoint path\n const loadEvent = new Event('load', {\n bubbles: true,\n composed: true,\n });\n Object.assign(loadEvent, { src: this.getAttribute('src') });\n this.dispatchEvent(loadEvent);\n } else {\n // Static remote component without mount script - dispatch load event\n const loadEvent = new Event('load', {\n bubbles: true,\n composed: true,\n });\n Object.assign(loadEvent, { src: this.getAttribute('src') });\n this.dispatchEvent(loadEvent);\n }\n\n this.isLoading = false;\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n\nexport function registerSharedModules(\n modules: Record<string, () => Promise<unknown>> = {},\n) {\n const self = globalThis as typeof globalThis & {\n __remote_component_host_shared_modules__?: Record<\n string,\n () => Promise<unknown>\n >;\n };\n\n if (!self.__remote_component_host_shared_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_component_host_shared_modules__ = {};\n }\n\n Object.entries(modules).forEach(([key, value]) => {\n if (self.__remote_component_host_shared_modules__) {\n self.__remote_component_host_shared_modules__[key] = value;\n }\n });\n}\n","const tagNames = [\n 'img',\n 'source',\n 'video',\n 'audio',\n 'track',\n 'iframe',\n 'embed',\n 'script',\n 'link',\n];\n\nexport function applyOriginToNodes(doc: Document | HTMLElement, url: URL) {\n if (url.origin !== location.origin) {\n const nodes = doc.querySelectorAll<HTMLImageElement>(\n tagNames\n .map(\n (type) =>\n `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`,\n )\n .join(','),\n );\n nodes.forEach((node) => {\n if (\n node.hasAttribute('src') &&\n /^[./]+\\/?/.test(node.getAttribute('src') ?? '')\n ) {\n node.src = new URL(node.getAttribute('src') ?? '/', url).href;\n }\n if (\n node.hasAttribute('href') &&\n /^[./]+\\/?/.test(node.getAttribute('href') ?? '')\n ) {\n node.setAttribute(\n 'href',\n new URL(node.getAttribute('href') ?? '/', url).href,\n );\n }\n if (node.hasAttribute('srcset')) {\n const srcSet = node\n .getAttribute('srcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('srcset', srcSet);\n }\n }\n if (node.hasAttribute('imagesrcset')) {\n const srcSet = node\n .getAttribute('imagesrcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('imagesrcset', srcSet);\n }\n }\n });\n }\n}\n","export { RemoteComponentsError } from '../error';\nexport {\n type LoadRemoteComponentProps,\n loadRemoteComponent,\n} from './component-loader';\nexport type { Runtime } from './const';\nexport {\n DEFAULT_ROUTE,\n getBundleKey,\n REMOTE_COMPONENT_REGEX,\n RUNTIME_SCRIPT,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n} from './const';\nexport { createRSCStream, fixPayload } from './rsc';\nexport { loadScripts } from './script-loader';\nexport { setAttributesFromProps } from './set-attributes-from-props';\nexport { loadStaticRemoteComponent } from './static-loader';\nexport type { GlobalScope, LoaderResult, RemoteComponentProps } from './types';\nexport { setupWebpackRuntime } from './webpack-adapter';\n","import * as React from 'react';\nimport * as JSXDevRuntime from 'react/jsx-dev-runtime';\nimport * as JSXRuntime from 'react/jsx-runtime';\nimport * as ReactDOM from 'react-dom';\nimport * as ReactDOMClient from 'react-dom/client';\nimport { RemoteComponentsError } from '../error';\nimport { nextClientPagesLoader } from '../webpack/next-client-pages-loader';\nimport { applySharedModules } from '../webpack/shared-modules';\nimport { createRSCStream } from './rsc';\nimport { loadScripts } from './script-loader';\nimport type { GlobalScope, LoaderResult, RemoteComponentProps } from './types';\nimport { setupWebpackRuntime } from './webpack-adapter';\n\nexport type LoadRemoteComponentProps = Pick<\n RemoteComponentProps,\n 'name' | 'bundle' | 'route' | 'runtime' | 'data' | 'nextData' | 'scripts'\n> & {\n url: URL;\n shared:\n | Promise<Record<string, (bundle?: string) => Promise<unknown>>>\n | Record<string, (bundle?: string) => Promise<unknown>>;\n remoteShared: Record<string, string>;\n container?: HTMLHeadElement | ShadowRoot | null;\n rscName?: string;\n};\n\n/**\n * Main loader function that orchestrates the component loading process\n */\nexport async function loadRemoteComponent({\n url,\n name,\n rscName,\n bundle,\n route = '/',\n runtime = 'webpack',\n data,\n nextData,\n scripts = [],\n shared = Promise.resolve({}),\n remoteShared = {},\n container,\n}: LoadRemoteComponentProps): Promise<LoaderResult> {\n try {\n // Load scripts if using webpack runtime\n if (runtime === 'webpack') {\n const self = globalThis as GlobalScope;\n // disable webpack entrypoint execution for the remote\n if (!self.__DISABLE_WEBPACK_EXEC__) {\n self.__DISABLE_WEBPACK_EXEC__ = {};\n }\n // disable webpack entrypoint execution for the current remote bundle\n self.__DISABLE_WEBPACK_EXEC__[bundle] = true;\n await loadScripts(scripts);\n }\n\n const hostShared = await shared;\n // Setup webpack runtime environment\n await setupWebpackRuntime(\n runtime,\n scripts,\n url,\n bundle,\n hostShared,\n remoteShared,\n );\n\n // Setup shared modules\n if (bundle) {\n const resolve = {\n '/react/index.js': React,\n '/react/jsx-dev-runtime.js': JSXDevRuntime,\n '/react/jsx-runtime.js': JSXRuntime,\n '/react-dom/index.js': ReactDOM,\n '/react-dom/client.js': ReactDOMClient,\n ...Object.entries(remoteShared).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (typeof hostShared[value] !== 'undefined') {\n acc[key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '')] =\n hostShared[value];\n }\n return acc;\n },\n {},\n ),\n } as Record<string, unknown>;\n await Promise.all(\n Object.entries(resolve).map(async ([key, value]) => {\n if (typeof value === 'function') {\n resolve[key] = await value(bundle);\n }\n return Promise.resolve(value);\n }),\n );\n applySharedModules(bundle, resolve);\n }\n\n // Load component based on data type\n if (data.length > 0) {\n return await loadRSCComponent(rscName ?? name, data);\n } else if (nextData) {\n return loadNextPagesComponent(bundle, route, nextData, name, container);\n }\n\n return loadRSCComponent(rscName ?? name, [`0:[null]\\n`]); // Fallback to empty RSC payload\n } catch (error) {\n return {\n component: null,\n error: new RemoteComponentsError(\n `Failed to load remote component \"${name}\".`,\n {\n cause: error instanceof Error ? error : new Error(String(error)),\n },\n ),\n };\n }\n}\n\n/**\n * Loads RSC (React Server Components) based component\n */\nasync function loadRSCComponent(\n rscName: string,\n data: string[],\n): Promise<LoaderResult> {\n // try to import react-server-dom-webpack from Next.js with a fallback\n let createFromReadableStream;\n try {\n const { createFromReadableStream: _createFromReadableStream } =\n await import(\n 'next/dist/compiled/react-server-dom-webpack/client.browser'\n );\n createFromReadableStream = _createFromReadableStream;\n } catch {\n const {\n default: { createFromReadableStream: _createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n createFromReadableStream = _createFromReadableStream;\n }\n // remote components with RSC requires react-server-dom-webpack\n if (typeof createFromReadableStream !== 'function') {\n throw new RemoteComponentsError(\n 'Failed to import \"react-server-dom-webpack\". Is Next.js installed correctly?',\n );\n }\n\n const stream = createRSCStream(rscName, data);\n const component = createFromReadableStream(stream);\n\n return { component };\n}\n\n/**\n * Loads Next.js Pages Router based component\n */\nfunction loadNextPagesComponent(\n bundle: string,\n route: string,\n nextData: NonNullable<RemoteComponentProps['nextData']>,\n name: string,\n container?: HTMLHeadElement | ShadowRoot | null,\n): LoaderResult {\n const { Component, App } = nextClientPagesLoader(bundle, route, container);\n\n if (!Component) {\n throw new RemoteComponentsError(\n `Remote Component \"${name}\" is trying to load the component for route \"${route}\" but it is not available.`,\n );\n }\n\n // error tolerance when app component is not found\n const component = App\n ? React.createElement(App, { Component, ...nextData.props })\n : React.createElement(Component, nextData.props);\n\n return { component };\n}\n","import { ReadableStream } from 'web-streams-polyfill';\n\n/**\n * Fixes RSC payload to make it compatible with React JSX development runtime\n */\nexport function fixPayload(payload: unknown): void {\n if (Array.isArray(payload)) {\n // if the current node is a React element, we need to fix the payload\n if (payload[0] === '$') {\n // fix the props (children or other React elements)\n fixPayload(payload[3]);\n if (payload.length === 4) {\n // add placeholder for the missing debug info\n payload.push(null, null, 1);\n }\n } else {\n // we are in an array, continue with visiting each item\n for (const item of payload) {\n fixPayload(item);\n }\n }\n } else if (typeof payload === 'object' && payload !== null) {\n // we are in an object, continue with visiting each property\n for (const key in payload) {\n fixPayload((payload as Record<string, unknown>)[key]);\n }\n }\n}\n\n/**\n * Processes RSC flight data and creates a ReadableStream\n */\nexport function createRSCStream(\n rscName: string,\n data: string[],\n): ReadableStream<Uint8Array> {\n return new ReadableStream({\n type: 'bytes',\n start(controller) {\n const encoder = new TextEncoder();\n const self = globalThis as typeof globalThis &\n Record<string, string[] | null>;\n\n // when the remote component RSC scripts are not found or loaded\n // we need to load the RSC flight data parsing the chunks\n if (data.length > 0) {\n data.forEach((chunk) => {\n const lines = chunk.split('\\n');\n for (const line of lines) {\n const match = /\\.push\\(\"(?<rsc>.*)\"\\);$/.exec(line);\n if (match?.groups?.rsc) {\n self[rscName] = self[rscName] ?? [];\n self[rscName].push(JSON.parse(`\"${match.groups.rsc}\"`) as string);\n }\n }\n });\n }\n\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const allChunks = (self[rscName] ?? [`0:[null]\\n`]).join('');\n\n // clear the RSC flight data from the global scope\n self[rscName] = null;\n\n // process each line in the RSC flight data\n allChunks.split('\\n').forEach((chunk) => {\n if (chunk.length > 0) {\n // parse the chunk to get the id, prefix and payload\n const { before, id, prefix, payload } =\n /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\\[.*\\])/.exec(\n chunk,\n )?.groups ?? {};\n\n if (payload) {\n // parse the payload to a JSON object\n const jsonPayload = JSON.parse(payload) as unknown[];\n // fix the payload to make it compatible with React JSX development runtime\n fixPayload(jsonPayload);\n // reconstruct the chunk to a string\n const reconstruct = `${before ?? ''}${id}:${prefix ?? ''}${JSON.stringify(jsonPayload)}`;\n // encode the chunk to a byte buffer\n controller.enqueue(encoder.encode(`${reconstruct}\\n`));\n } else {\n // add empty line before closing the stream\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n } else {\n // add empty line before closing the stream\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n });\n // close the stream when all chunks are enqueued\n controller.close();\n },\n });\n}\n","import { RemoteComponentsError } from '../error';\n\n/**\n * Loads external scripts for remote components\n */\nexport async function loadScripts(scripts: { src: string }[]): Promise<void> {\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newSrc = new URL(\n // remove the remote component bundle name identifier from the script src\n script.src.replace(/\\/_next\\/\\[.+\\](?<whitespace>%20| )/, '/_next/'),\n location.origin,\n ).href;\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n };\n newScript.onerror = () => {\n reject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${script.src}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n };\n newScript.src = newSrc;\n newScript.async = true;\n document.head.appendChild(newScript);\n });\n }),\n );\n}\n","/**\n * The headers to use when fetching the remote component.\n */\nexport function remoteFetchHeaders(\n additionalHeaders: Headers | Record<string, string> | undefined,\n) {\n return {\n /**\n * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.\n * Ensure the automation bypass secret is the same on the client and host.\n * Otherwise, manually specify x-vercel-protection-bypass for the remote in the `additionalHeaders` parameter.\n */\n ...(typeof process === 'object' &&\n typeof process.env === 'object' &&\n typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === 'string'\n ? {\n 'x-vercel-protection-bypass':\n process.env.VERCEL_AUTOMATION_BYPASS_SECRET,\n }\n : {}),\n ...Object.fromEntries(\n additionalHeaders instanceof Headers\n ? additionalHeaders.entries()\n : Object.entries(additionalHeaders ?? {}),\n ),\n Accept: 'text/html',\n };\n}\n","import { RemoteComponentsError } from '#internal/shared/error';\n\nexport type Runtime = 'webpack' | 'turbopack' | 'script' | 'unknown';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime(bundle ?? 'default', shared, remoteShared);\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(url, bundle, shared, remoteShared);\n } else if (type === 'script') {\n const { scriptRuntime } = await import(`./script`);\n return scriptRuntime();\n }\n throw new RemoteComponentsError(\n `Remote Components runtime \"${type}\" is not supported. Supported runtimes are \"webpack\", \"turbopack\", and \"script\".`,\n );\n}\n"],"mappings":";;;;;;;;;;;AASO,SAAS,8BAA8B,KAAyB;AACrE,SAAO,IAAI;AAAA,IACT,wCAAwC;AAAA,EAC1C;AACF;AAEO,SAAS,kCAAkC,KAAa,OAAgB;AAC7E,SAAO,IAAI;AAAA,IACT,0CAA0C;AAAA,IAC1C,EAAE,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,EAAE;AAAA,EACrE;AACF;AApBA,IAAa;AAAb;AAAA;AAAA;AAAO,IAAM,wBAAN,cAAoC,MAAM;AAAA,MAC/C,OAAO;AAAA,MAEP,YAAY,SAAiB,SAA+B;AAC1D,cAAM,SAAS,OAAO;AACtB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA;AAAA;;;ACJO,SAAS,sBACd,QACA,OACA,iBAAsD,SAAS,MAC/D;AAEA,QAAM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