remote-components 0.4.3 → 0.4.5
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/{chunk-C5EYU7EQ.cjs → chunk-4MLJE6UP.cjs} +3 -3
- package/dist/{chunk-SECN7UAL.cjs → chunk-7OD5S534.cjs} +18 -18
- package/dist/{chunk-7XXO2DLF.cjs → chunk-I7VKDF3E.cjs} +115 -77
- package/dist/chunk-I7VKDF3E.cjs.map +1 -0
- package/dist/{chunk-55TEMSB5.js → chunk-JZRA6DPE.js} +116 -78
- package/dist/chunk-JZRA6DPE.js.map +1 -0
- package/dist/{chunk-HYVNEUIK.js → chunk-MJ2KYXGR.js} +3 -3
- package/dist/{chunk-KV5J7PNM.js → chunk-NZM2SI6U.js} +3 -3
- package/dist/{chunk-DGZVFKSQ.js → chunk-O4A6CJGI.js} +19 -11
- package/dist/chunk-O4A6CJGI.js.map +1 -0
- package/dist/{chunk-2W7JBTID.cjs → chunk-PNASFKWA.cjs} +39 -31
- package/dist/chunk-PNASFKWA.cjs.map +1 -0
- package/dist/{chunk-4NW46ZVD.js → chunk-PT3R275L.js} +93 -38
- package/dist/chunk-PT3R275L.js.map +1 -0
- package/dist/{chunk-4AH3KXDW.cjs → chunk-TWO3XB6H.cjs} +19 -19
- package/dist/{chunk-HMB3SIVJ.cjs → chunk-W5FSHVWU.cjs} +107 -52
- package/dist/chunk-W5FSHVWU.cjs.map +1 -0
- package/dist/{chunk-HL6BL5HY.js → chunk-WGSS7TJP.js} +2 -2
- package/dist/config/nextjs.cjs +98 -30
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.d.ts +14 -1
- package/dist/config/nextjs.js +89 -21
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +19 -19
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +7 -7
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +11 -11
- package/dist/host/nextjs/app/client-only.js +6 -6
- package/dist/host/nextjs/pages.cjs +32 -9
- package/dist/host/nextjs/pages.cjs.map +1 -1
- package/dist/host/nextjs/pages.js +39 -9
- package/dist/host/nextjs/pages.js.map +1 -1
- package/dist/host/react.cjs +7 -7
- package/dist/host/react.js +6 -6
- package/dist/internal/host/nextjs/app-client.d.ts +3 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +17 -2
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.d.ts +5 -1
- package/dist/internal/host/nextjs/dom-flight.js +18 -2
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +4 -2
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.d.ts +2 -0
- package/dist/internal/host/server/fetch-remote-component.js +4 -2
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/server/types.cjs.map +1 -1
- package/dist/internal/host/server/types.d.ts +4 -1
- package/dist/internal/host/shared/pipeline.cjs +7 -8
- package/dist/internal/host/shared/pipeline.cjs.map +1 -1
- package/dist/internal/host/shared/pipeline.d.ts +5 -3
- package/dist/internal/host/shared/pipeline.js +9 -8
- package/dist/internal/host/shared/pipeline.js.map +1 -1
- package/dist/internal/host/shared/shared-broker.cjs +51 -10
- package/dist/internal/host/shared/shared-broker.cjs.map +1 -1
- package/dist/internal/host/shared/shared-broker.d.ts +19 -3
- package/dist/internal/host/shared/shared-broker.js +48 -10
- package/dist/internal/host/shared/shared-broker.js.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.d.ts +2 -2
- package/dist/internal/host/shared/shared-module-resolver.js.map +1 -1
- package/dist/internal/remote/nextjs/app-client.cjs +28 -19
- package/dist/internal/remote/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/remote/nextjs/app-client.d.ts +6 -1
- package/dist/internal/remote/nextjs/app-client.js +20 -11
- package/dist/internal/remote/nextjs/app-client.js.map +1 -1
- package/dist/internal/runtime/html/html-spec.cjs +6 -0
- package/dist/internal/runtime/html/html-spec.cjs.map +1 -1
- package/dist/internal/runtime/html/html-spec.d.ts +3 -1
- package/dist/internal/runtime/html/html-spec.js +4 -0
- package/dist/internal/runtime/html/html-spec.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +7 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.d.ts +5 -3
- package/dist/internal/runtime/html/parse-remote-html.js +9 -1
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.d.ts +4 -2
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +39 -23
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js +39 -23
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs +15 -5
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.d.ts +10 -2
- package/dist/internal/runtime/turbopack/patterns.js +13 -4
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.cjs +39 -10
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +2 -2
- package/dist/internal/runtime/turbopack/shared-modules.js +43 -11
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/remote/defaults/app.cjs +4 -2
- package/dist/remote/defaults/app.cjs.map +1 -1
- package/dist/remote/defaults/app.d.ts +3 -1
- package/dist/remote/defaults/app.js +3 -2
- package/dist/remote/defaults/app.js.map +1 -1
- package/dist/remote/defaults/pages.cjs +4 -2
- package/dist/remote/defaults/pages.cjs.map +1 -1
- package/dist/remote/defaults/pages.d.ts +3 -1
- package/dist/remote/defaults/pages.js +3 -2
- package/dist/remote/defaults/pages.js.map +1 -1
- package/dist/remote/defaults/shared.cjs +5 -2
- package/dist/remote/defaults/shared.cjs.map +1 -1
- package/dist/remote/defaults/shared.d.ts +5 -1
- package/dist/remote/defaults/shared.js +3 -1
- package/dist/remote/defaults/shared.js.map +1 -1
- package/dist/remote/nextjs/pages.cjs +4 -1
- package/dist/remote/nextjs/pages.cjs.map +1 -1
- package/dist/remote/nextjs/pages.d.ts +5 -0
- package/dist/remote/nextjs/pages.js +8 -2
- package/dist/remote/nextjs/pages.js.map +1 -1
- package/dist/{server-handoff-8c89b856.d.ts → server-handoff-9e905049.d.ts} +2 -1
- package/dist/{turbopack-7F757Z7V.js → turbopack-55EJDSUT.js} +4 -4
- package/dist/turbopack-55EJDSUT.js.map +1 -0
- package/dist/{turbopack-DULMVTWV.cjs → turbopack-Q6KJAEOX.cjs} +11 -11
- package/dist/turbopack-Q6KJAEOX.cjs.map +1 -0
- package/dist/{webpack-WGVTKJ3W.js → webpack-AQ34DAJZ.js} +4 -4
- package/dist/webpack-AQ34DAJZ.js.map +1 -0
- package/dist/{webpack-6LXCB7WA.cjs → webpack-FWUNUWLF.cjs} +11 -11
- package/dist/webpack-FWUNUWLF.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-2W7JBTID.cjs.map +0 -1
- package/dist/chunk-4NW46ZVD.js.map +0 -1
- package/dist/chunk-55TEMSB5.js.map +0 -1
- package/dist/chunk-7XXO2DLF.cjs.map +0 -1
- package/dist/chunk-DGZVFKSQ.js.map +0 -1
- package/dist/chunk-HMB3SIVJ.cjs.map +0 -1
- package/dist/turbopack-7F757Z7V.js.map +0 -1
- package/dist/turbopack-DULMVTWV.cjs.map +0 -1
- package/dist/webpack-6LXCB7WA.cjs.map +0 -1
- package/dist/webpack-WGVTKJ3W.js.map +0 -1
- /package/dist/{chunk-C5EYU7EQ.cjs.map → chunk-4MLJE6UP.cjs.map} +0 -0
- /package/dist/{chunk-SECN7UAL.cjs.map → chunk-7OD5S534.cjs.map} +0 -0
- /package/dist/{chunk-HYVNEUIK.js.map → chunk-MJ2KYXGR.js.map} +0 -0
- /package/dist/{chunk-KV5J7PNM.js.map → chunk-NZM2SI6U.js.map} +0 -0
- /package/dist/{chunk-4AH3KXDW.cjs.map → chunk-TWO3XB6H.cjs.map} +0 -0
- /package/dist/{chunk-HL6BL5HY.js.map → chunk-WGSS7TJP.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/shared/shared-broker.ts","../src/utils/index.ts","../src/runtime/constants.ts","../src/runtime/patterns.ts","../src/runtime/turbopack/remote-scope.ts","../src/host/shared/remote-image-loader.ts","../src/host/shared/polyfill.tsx","../src/host/shared/shared-module-resolver.ts"],"sourcesContent":["import type { LogLocation } from '#internal/utils/logger';\nimport { logDebug, logError } from '#internal/utils/logger';\n\nexport type SharedModuleFactory = (bundle?: string) => Promise<unknown>;\n\nexport const SHARED_MODULE_MANIFEST_PROTOCOL =\n 'remote-components.shared.v1' as const;\n\nexport type LegacySharedModuleMap = Record<string, string | number>;\n\nexport interface SharedModuleManifestRequirement {\n id: string | number;\n specifier: string;\n required?: boolean;\n singleton?: boolean;\n scope?: string;\n}\n\nexport interface SharedModuleManifest {\n protocol: typeof SHARED_MODULE_MANIFEST_PROTOCOL;\n requirements: SharedModuleManifestRequirement[];\n}\n\nexport type RemoteSharedModules = LegacySharedModuleMap | SharedModuleManifest;\n\nexport interface SharedModuleRequirement {\n id: string;\n specifier: string;\n required: boolean;\n singleton: boolean;\n scope: string;\n}\n\nexport interface SharedModuleResolution extends SharedModuleRequirement {\n provider?: SharedModuleFactory | unknown;\n status: 'resolved' | 'missing';\n}\n\nexport interface SharedModulePlan {\n protocol: 'legacy' | typeof SHARED_MODULE_MANIFEST_PROTOCOL;\n bundle: string;\n entries: SharedModuleResolution[];\n}\n\nexport function isSharedModuleManifest(\n value: unknown,\n): value is SharedModuleManifest {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'protocol' in value &&\n value.protocol === SHARED_MODULE_MANIFEST_PROTOCOL &&\n 'requirements' in value &&\n Array.isArray(value.requirements)\n );\n}\n\nexport function getMissingSharedModulesMessage(\n remoteShared: RemoteSharedModules,\n): string | undefined {\n if (isSharedModuleManifest(remoteShared)) return undefined;\n const message = remoteShared.__remote_components_missing_shared__;\n return typeof message === 'string' ? message : undefined;\n}\n\nexport function createSharedModulePlan({\n bundle,\n hostShared,\n remoteShared,\n scope = `remote:${bundle}`,\n callerTag = 'SharedBroker',\n}: {\n bundle: string;\n hostShared: Record<string, SharedModuleFactory | unknown>;\n remoteShared: RemoteSharedModules;\n scope?: string;\n callerTag?: LogLocation;\n}): SharedModulePlan {\n const protocol = isSharedModuleManifest(remoteShared)\n ? remoteShared.protocol\n : 'legacy';\n const requirements: SharedModuleManifestRequirement[] =\n isSharedModuleManifest(remoteShared)\n ? remoteShared.requirements\n : // @legacy(remote-components<=0.4.x): normalize the historical shared\n // map until hosts and remotes on 0.4.x are no longer supported.\n Object.entries(remoteShared).map(([id, specifier]) => ({\n id,\n specifier: String(specifier),\n required: true,\n singleton: true,\n }));\n\n const entries = requirements.map((requirement) => {\n const specifier = String(requirement.specifier);\n const provider = hostShared[specifier];\n const entry: SharedModuleResolution = {\n id: String(requirement.id),\n specifier,\n required: requirement.required ?? true,\n singleton: requirement.singleton ?? true,\n scope: requirement.scope ?? scope,\n provider,\n status: typeof provider === 'undefined' ? 'missing' : 'resolved',\n };\n\n if (entry.status === 'missing') {\n logDebug(\n callerTag,\n `Remote \"${bundle}\" requests \"${specifier}\" for \"${entry.id}\" but the host does not provide it`,\n );\n }\n\n return entry;\n });\n\n logDebug(\n callerTag,\n `Share plan (${protocol}) for \"${bundle}\": ${entries\n .map((entry) => `${entry.id}=>${entry.specifier}:${entry.status}`)\n .join(', ')}`,\n );\n\n return {\n protocol,\n bundle,\n entries,\n };\n}\n\nfunction missingRequiredSharedModuleMessage(\n plan: SharedModulePlan,\n entry: SharedModuleResolution,\n): string {\n return (\n `Remote Component \"${plan.bundle}\" requires shared module \"${entry.specifier}\", but the host does not provide it. ` +\n 'Add it to the host shared modules through `withRemoteComponentsConfig({ shared: [...] })` or the `shared` prop. ' +\n 'This diagnostic runs when both host and remote support the shared-module manifest in remote-components >=0.5.0. ' +\n 'The remote may load its bundled copy during the compatibility window; this will become a load error after remote-components <=0.4.x support is removed.'\n );\n}\n\nfunction logMissingRequiredSharedModule(\n callerTag: LogLocation,\n plan: SharedModulePlan,\n entry: SharedModuleResolution,\n): void {\n logError(callerTag, missingRequiredSharedModuleMessage(plan, entry));\n}\n\nexport async function resolveSharedModulePlan(\n plan: SharedModulePlan,\n): Promise<Record<string, unknown>> {\n const resolved: Record<string, unknown> = {};\n\n await Promise.all(\n plan.entries.map(async (entry) => {\n if (entry.status !== 'resolved') {\n if (\n plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL &&\n entry.required\n ) {\n logMissingRequiredSharedModule('SharedBroker', plan, entry);\n }\n return;\n }\n const value =\n typeof entry.provider === 'function'\n ? await (entry.provider as SharedModuleFactory)(plan.bundle)\n : entry.provider;\n resolved[entry.id] = value;\n }),\n );\n\n return resolved;\n}\n\nexport async function installSharedModulePlan({\n plan,\n target,\n callerTag = 'SharedBroker',\n onMissing,\n}: {\n plan: SharedModulePlan;\n target: Record<string, unknown>;\n callerTag?: LogLocation;\n onMissing?: (entry: SharedModuleResolution) => void;\n}): Promise<undefined[]> {\n return Promise.all(\n plan.entries.map(async (entry) => {\n if (entry.status !== 'resolved') {\n if (\n plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL &&\n entry.required\n ) {\n logMissingRequiredSharedModule(callerTag, plan, entry);\n return undefined;\n }\n if (onMissing) {\n onMissing(entry);\n } else {\n logError(\n callerTag,\n `Shared module \"${entry.specifier}\" not found for \"${plan.bundle}\".`,\n );\n }\n return undefined;\n }\n\n target[entry.id] =\n typeof entry.provider === 'function'\n ? await (entry.provider as SharedModuleFactory)(plan.bundle)\n : entry.provider;\n return undefined;\n }),\n );\n}\n","export function escapeString(str: string) {\n return str.replace(/[^a-z0-9]/g, '_');\n}\n\n/**\n * Computes the origin-qualified scoped name for a bundle by appending\n * the escaped host (hostname + port). This ensures the server and client\n * always agree on the scoped name — the server's cross-origin detection\n * (based on deployment URL) can differ from the client's (based on\n * `location.origin`), so the name must not depend on that distinction.\n *\n * Used on both the server (to rewrite RSC flight data) and the client\n * (to create and look up RemoteScopes). Both sides must produce the\n * same value for a given remote.\n */\nexport function computeScopedName(\n name: string,\n options: { remoteHost: string },\n): string {\n return `${name}_${escapeString(options.remoteHost.toLowerCase())}`;\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 '#internal/utils';\n\nexport const DEFAULT_BUNDLE_NAME = '__vercel_remote_bundle';\nexport const DEFAULT_COMPONENT_NAME = '__vercel_remote_component';\nexport const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\nexport const RUNTIME_SCRIPT = 'script';\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","export const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\n// Matches Next.js bundle-prefixed paths like /_next/[bundle-name] /static/...\n// Used to strip the bundle identifier before loading scripts via the standard /_next/ path.\nexport const NEXT_BUNDLE_PATH_RE = /\\/_next\\/\\[.+\\](?:%20| )/;\n\n/** Collapse duplicate path separators (`//`) while preserving protocol (`://`). */\nconst DOUBLE_SLASH_RE = /(?<!:)\\/\\//g;\nexport function collapseDoubleSlashes(path: string): string {\n return path.replace(DOUBLE_SLASH_RE, '/');\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { getBundleKey, type Runtime } from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { REMOTE_COMPONENT_REGEX } from '#internal/runtime/patterns';\nimport { computeScopedName } from '#internal/utils';\nimport { logDebug, logWarn } from '#internal/utils/logger';\n\n/**\n * Encapsulates all per-remote state so that two remotes sharing the same\n * bundle name but served from different origins never collide.\n *\n * A scope is created once per `setupRemoteScope` call and threaded\n * directly through internal code paths (chunk loading, module resolution,\n * shared modules). Global dispatchers (`__webpack_require__`,\n * `__webpack_chunk_load__`) only exist for external callers (RSC runtime)\n * and resolve the correct scope via the registry.\n */\nexport interface RemoteScope {\n /** Plain bundle name (e.g. \"remote-component-registry\") */\n name: string;\n /** Origin-qualified key — unique even when two remotes share a name */\n scopedName: string;\n /** Escaped key used as suffix for TURBOPACK_ globals */\n globalKey: string;\n /** Base URL for resolving relative chunk paths */\n url: URL;\n /** Bundler runtime type */\n runtime: Runtime;\n /** Proxy callback for routing chunks through the host */\n resolveClientUrl?: InternalResolveClientUrl;\n /** Per-scope cache of executed Turbopack module exports */\n moduleCache: Record<string, unknown>;\n /** Per-scope shared modules provided by the host (React, etc.) */\n sharedModules: Record<string, unknown>;\n /** Per-scope globalThis substitute passed to module initializers as `g` */\n moduleGlobal: Record<string, unknown>;\n /**\n * Webpack's bundle-scoped require function, populated from\n * `__remote_webpack_require__[bundleName]` for webpack remotes.\n * Undefined for turbopack remotes.\n */\n webpackRequire?: ((id: string | number) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: string;\n };\n /**\n * Flat array of captured turbopack module entries: [scriptEl, id, factory, ...].\n * Populated by the push interceptor in handleTurbopackChunk. This is the\n * primary source of truth for getTurbopackModules — immune to the turbopack\n * runtime replacing the TURBOPACK global (canary builds use a deferred-loading\n * pattern that swaps the array for an immediate-processing dispatcher).\n */\n turbopackModules: unknown[];\n}\n\nfunction getRegistry(): Map<string, RemoteScope> {\n return getNamespace().scopes;\n}\n\nexport function createScope(\n name: string,\n url: URL,\n runtime: Runtime,\n resolveClientUrl?: InternalResolveClientUrl,\n): RemoteScope {\n const scopedName = computeScopedName(name, { remoteHost: url.host });\n const globalKey = getBundleKey(scopedName);\n return {\n name,\n scopedName,\n globalKey,\n url,\n runtime,\n resolveClientUrl,\n moduleCache: {},\n sharedModules: {},\n moduleGlobal: {},\n turbopackModules: [],\n };\n}\n\nexport function registerScope(scope: RemoteScope): void {\n const registry = getRegistry();\n registry.set(scope.scopedName, scope);\n\n // Also register under the plain name so static/HTML hosts (which don't\n // rewrite RSC chunk IDs) can look up scopes by the unrewritten bundle name.\n if (scope.scopedName !== scope.name) {\n const existing = registry.get(scope.name);\n if (existing && existing.scopedName !== scope.scopedName) {\n logWarn(\n 'RemoteScope',\n `Plain name \"${scope.name}\" already registered by scope \"${existing.scopedName}\" — ` +\n `overwriting with \"${scope.scopedName}\". Static hosts will only resolve the latest one.`,\n );\n }\n registry.set(scope.name, scope);\n }\n\n logDebug(\n 'RemoteScope',\n `Registered scope \"${scope.scopedName}\" (${registry.size} total)`,\n );\n}\n\n/**\n * Resolves a scope by name. Accepts either the scoped name (used by Next.js\n * hosts that rewrite RSC data server-side) or the plain bundle name (used by\n * static/HTML hosts where chunks arrive unrewritten).\n */\nexport function getScope(name: string): RemoteScope | undefined {\n return getRegistry().get(name);\n}\n\n/** Formats a `[scopedName] path` string for use in chunk/module IDs. */\nexport function formatRemoteId(scope: RemoteScope, path: string): string {\n return `[${scope.scopedName}] ${path}`;\n}\n\n/**\n * Parses the `[bundle] path` format used in chunk/module IDs.\n * Uses REMOTE_COMPONENT_REGEX (the same pattern used by the module dispatcher\n * and script loader) so the two parsing paths can never diverge.\n */\nexport function parseRemoteId(id: string): {\n bundle: string;\n path: string;\n prefix: string;\n} {\n const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;\n if (groups?.bundle && groups.id) {\n return {\n bundle: groups.bundle,\n path: groups.id,\n prefix: groups.prefix ?? '',\n };\n }\n return { bundle: 'default', path: id, prefix: '' };\n}\n","import { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n","import type { LinkProps } from 'next/link';\nimport {\n REMOTE_NAVIGATE_EVENT,\n type RemoteNavigateDetail,\n} from '#internal/host/shared/navigate-event';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { logWarn } from '#internal/utils/logger';\n\nfunction dispatchRemoteNavigate(detail: RemoteNavigateDetail) {\n window.dispatchEvent(\n new CustomEvent<RemoteNavigateDetail>(REMOTE_NAVIGATE_EVENT, { detail }),\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 resolveClientUrl?: InternalResolveClientUrl,\n) {\n const hostShared = getNamespace().hostSharedModules;\n const polyfill = {\n 'next/dist/client/components/navigation':\n hostShared['next/navigation'] ??\n shared?.['next/navigation'] ??\n (() =>\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'push' });\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'replace' });\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 hostShared['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 logWarn(\n 'Polyfill',\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 dispatchRemoteNavigate({\n url: props.href as string,\n type: replace ? 'replace' : 'push',\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 hostShared['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 // Instead of replacing next/image entirely, we let the real Next.js Image\n // component load from the remote bundle and only replace its default loader.\n // This gives us full next/image fidelity (fill, priority, srcSet, blur\n // placeholders, error handling) while routing image optimization through the\n // remote app's /_next/image endpoint.\n 'next/dist/shared/lib/image-loader':\n hostShared['next/dist/shared/lib/image-loader'] ??\n shared?.['next/dist/shared/lib/image-loader'] ??\n ((bundle: string) =>\n Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n })),\n 'next/dist/client/script':\n hostShared['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 hostShared['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 dispatchRemoteNavigate({ url: routerUrl, type: 'push' });\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'replace' });\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/esm/shared/lib/image-loader'] = polyfill[\n 'next/dist/shared/lib/image-loader'\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 { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { sharedPolyfills } from '#internal/host/shared/polyfill';\nimport {\n createSharedModulePlan,\n type RemoteSharedModules,\n resolveSharedModulePlan,\n type SharedModuleFactory,\n} from '#internal/host/shared/shared-broker';\nimport type { LogLocation } from '#internal/utils/logger';\n\n/**\n * The core React packages that are always shared between host and remote.\n * These correspond to the `/react/*.js` and `/react-dom/*.js` path keys\n * used in the webpack module resolution map.\n */\nexport const CORE_REACT_SHARED_KEYS = [\n 'react',\n 'react/jsx-dev-runtime',\n 'react/jsx-runtime',\n 'react-dom',\n 'react-dom/client',\n] as const;\n\n/**\n * Maps each core React package to its webpack-style path key.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_PATH_MAP: Record<string, string> = {\n react: '/react/index.js',\n 'react/jsx-dev-runtime': '/react/jsx-dev-runtime.js',\n 'react/jsx-runtime': '/react/jsx-runtime.js',\n 'react-dom': '/react-dom/index.js',\n 'react-dom/client': '/react-dom/client.js',\n};\n\n/**\n * The vendorShared record used by the Next.js config to map React packages\n * to their webpack path-key string literals. Derived from CORE_REACT_PATH_MAP\n * but excludes `react-dom/client` to match the existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_PATH_MAP)\n .filter(([key]) => key !== 'react-dom/client')\n .map(([key, path]) => [key, `'${path}'`]),\n);\n\n/**\n * Builds the `coreShared` map for the Turbopack runtime's\n * `initializeSharedModules`. Each entry is an async factory that dynamically\n * imports the corresponding React package. User-provided shared modules\n * override core entries (e.g. to supply a pinned React version).\n */\nexport function buildCoreShared(\n userShared?: Record<string, SharedModuleFactory>,\n): Record<string, SharedModuleFactory> {\n return {\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 () => (await import('react-dom/client')).default,\n ...userShared,\n };\n}\n\ninterface HostSharedGlobals {\n __remote_component_host_shared_modules__?: Record<\n string,\n SharedModuleFactory\n >;\n __remote_component_shared__?: Record<string, SharedModuleFactory>;\n}\n\n/**\n * Builds the merged host shared modules map with a consistent merge priority:\n * 1. Polyfills (lowest priority — fallback implementations)\n * 2. Global host shared modules (`__remote_component_host_shared_modules__`)\n * 3. User-provided shared modules (highest priority — explicit overrides)\n *\n * Some callers also include `__remote_component_shared__` (the pages router\n * global). Pass `includeRemoteComponentShared: true` to include it at the end.\n */\nexport function buildHostShared(\n userShared?: Record<string, SharedModuleFactory>,\n resolveClientUrl?: InternalResolveClientUrl,\n options?: { includeRemoteComponentShared?: boolean },\n): Record<string, SharedModuleFactory> {\n const self = globalThis as typeof globalThis & HostSharedGlobals;\n const result: Record<string, SharedModuleFactory> = {\n ...sharedPolyfills(userShared, resolveClientUrl),\n ...self.__remote_component_host_shared_modules__,\n ...userShared,\n };\n if (options?.includeRemoteComponentShared) {\n Object.assign(result, self.__remote_component_shared__);\n }\n return result;\n}\n\n/**\n * React module instances keyed by their webpack path, e.g.\n * `{ '/react/index.js': React }`. Passed into `buildWebpackResolve` so it\n * can populate the resolve map without importing React itself.\n */\nexport interface ReactModules {\n '/react/index.js': unknown;\n '/react/jsx-dev-runtime.js': unknown;\n '/react/jsx-runtime.js': unknown;\n '/react-dom/index.js': unknown;\n '/react-dom/client.js': unknown;\n}\n\n/**\n * Builds the `resolve` map passed to `applySharedModules` for the webpack\n * runtime. Combines:\n * - Static React module path keys (`/react/index.js`, etc.)\n * - Remote shared modules matched against host shared, with `(ssr)/` prefix stripped\n *\n * After building the map, resolves any factory functions by awaiting them\n * with the given bundle name.\n */\nexport async function buildWebpackResolve(\n hostShared: Record<string, SharedModuleFactory | unknown>,\n remoteShared: RemoteSharedModules,\n bundle: string,\n reactModules: ReactModules,\n callerTag: LogLocation = 'SharedModuleResolver',\n): Promise<Record<string, unknown>> {\n const sharePlan = createSharedModulePlan({\n bundle,\n hostShared,\n remoteShared,\n callerTag,\n });\n const plannedResolve = await resolveSharedModulePlan(sharePlan);\n const resolve: Record<string, unknown> = {\n ...reactModules,\n ...Object.fromEntries(\n Object.entries(plannedResolve).map(([key, value]) => [\n key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, ''),\n value,\n ]),\n ),\n };\n return resolve;\n}\n"],"mappings":";;;;;;;;;;;;;AAKO,IAAM,kCACX;AAsCK,SAAS,uBACd,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,MAAM,aAAa,mCACnB,kBAAkB,SAClB,MAAM,QAAQ,MAAM,YAAY;AAEpC;AAEO,SAAS,+BACd,cACoB;AACpB,MAAI,uBAAuB,YAAY;AAAG,WAAO;AACjD,QAAM,UAAU,aAAa;AAC7B,SAAO,OAAO,YAAY,WAAW,UAAU;AACjD;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,UAAU;AAAA,EAClB,YAAY;AACd,GAMqB;AACnB,QAAM,WAAW,uBAAuB,YAAY,IAChD,aAAa,WACb;AACJ,QAAM,eACJ,uBAAuB,YAAY,IAC/B,aAAa;AAAA;AAAA;AAAA,IAGb,OAAO,QAAQ,YAAY,EA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B,wBACS;AAClC,QAAM,YAAY,uBAAuB;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,iBAAiB,MAAM,wBAAwB,SAAS;AAC9D,QAAM,UAAmC;AAAA,IACvC,GAAG;AAAA,IACH,GAAG,OAAO;AAAA,MACR,OAAO,QAAQ,cAAc,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,QACnD,IAAI,QAAQ,gCAAgC,EAAE;AAAA,QAC9C;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
makeReactEmitter,
|
|
8
8
|
preparePipeline,
|
|
9
9
|
resolveNameFromSrc
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-O4A6CJGI.js";
|
|
11
11
|
import {
|
|
12
12
|
loadStaticRemoteComponent
|
|
13
13
|
} from "./chunk-LEKG4YWI.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
RUNTIME_WEBPACK,
|
|
22
22
|
attrToProp,
|
|
23
23
|
escapeString
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-JZRA6DPE.js";
|
|
25
25
|
import {
|
|
26
26
|
getNamespace
|
|
27
27
|
} from "./chunk-D5GNZB6O.js";
|
|
@@ -679,4 +679,4 @@ export {
|
|
|
679
679
|
useRemoteNavigate,
|
|
680
680
|
ConsumeRemoteComponent
|
|
681
681
|
};
|
|
682
|
-
//# sourceMappingURL=chunk-
|
|
682
|
+
//# sourceMappingURL=chunk-MJ2KYXGR.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createChunkDispatcher,
|
|
3
3
|
loadChunkWithScope,
|
|
4
4
|
requireModule
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PT3R275L.js";
|
|
6
6
|
import {
|
|
7
7
|
REMOTE_COMPONENT_REGEX,
|
|
8
8
|
RUNTIME_TURBOPACK,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
createScope,
|
|
11
11
|
getScope,
|
|
12
12
|
registerScope
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JZRA6DPE.js";
|
|
14
14
|
import {
|
|
15
15
|
getNamespace
|
|
16
16
|
} from "./chunk-D5GNZB6O.js";
|
|
@@ -149,4 +149,4 @@ function createModuleDispatcher(runtime) {
|
|
|
149
149
|
export {
|
|
150
150
|
setupRemoteScope
|
|
151
151
|
};
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
152
|
+
//# sourceMappingURL=chunk-NZM2SI6U.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadScripts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WGSS7TJP.js";
|
|
4
4
|
import {
|
|
5
5
|
setupRemoteScope
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NZM2SI6U.js";
|
|
7
7
|
import {
|
|
8
8
|
applySharedModules,
|
|
9
9
|
initializeSharedModules,
|
|
10
10
|
nextClientPagesLoader
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PT3R275L.js";
|
|
12
12
|
import {
|
|
13
13
|
loadStaticRemoteComponent
|
|
14
14
|
} from "./chunk-LEKG4YWI.js";
|
|
@@ -22,8 +22,9 @@ import {
|
|
|
22
22
|
buildHostShared,
|
|
23
23
|
buildWebpackResolve,
|
|
24
24
|
collapseDoubleSlashes,
|
|
25
|
-
escapeString
|
|
26
|
-
|
|
25
|
+
escapeString,
|
|
26
|
+
getMissingSharedModulesMessage
|
|
27
|
+
} from "./chunk-JZRA6DPE.js";
|
|
27
28
|
import {
|
|
28
29
|
RemoteComponentsError,
|
|
29
30
|
logDebug,
|
|
@@ -203,12 +204,14 @@ var ORIGIN_REWRITE_TAGS = [
|
|
|
203
204
|
var ID_SUFFIX_RSC = "_rsc";
|
|
204
205
|
var ID_SUFFIX_SSR = "_ssr";
|
|
205
206
|
var ID_SUFFIX_SHARED = "_shared";
|
|
207
|
+
var ID_SUFFIX_SHARED_MANIFEST = "_shared_manifest";
|
|
206
208
|
var DATA_BUNDLE = "data-bundle";
|
|
207
209
|
var DATA_ROUTE = "data-route";
|
|
208
210
|
var DATA_RUNTIME = "data-runtime";
|
|
209
211
|
var DATA_TYPE = "data-type";
|
|
210
212
|
var DATA_SRC = "data-src";
|
|
211
213
|
var DATA_REMOTE_COMPONENTS_SHARED = "data-remote-components-shared";
|
|
214
|
+
var DATA_REMOTE_COMPONENTS_SHARED_MANIFEST = "data-remote-components-shared-manifest";
|
|
212
215
|
var TAG_REMOTE_COMPONENT = "remote-component";
|
|
213
216
|
var NEXT_DATA_ID = "__NEXT_DATA__";
|
|
214
217
|
var REMOTE_NEXT_DATA_ID = "__REMOTE_NEXT_DATA__";
|
|
@@ -319,10 +322,16 @@ function resolveComponentName(component, nextData, fallbackName) {
|
|
|
319
322
|
return { name, isRemoteComponent };
|
|
320
323
|
}
|
|
321
324
|
function extractRemoteShared(doc, name, nextData) {
|
|
325
|
+
const remoteSharedManifestEl = doc.querySelector(
|
|
326
|
+
`#${name}${ID_SUFFIX_SHARED_MANIFEST}[${DATA_REMOTE_COMPONENTS_SHARED_MANIFEST}]`
|
|
327
|
+
);
|
|
322
328
|
const remoteSharedEl = doc.querySelector(
|
|
323
329
|
`#${name}${ID_SUFFIX_SHARED}[${DATA_REMOTE_COMPONENTS_SHARED}]`
|
|
324
330
|
);
|
|
325
|
-
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.
|
|
331
|
+
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.sharedManifest ?? (remoteSharedManifestEl?.textContent ? JSON.parse(remoteSharedManifestEl.textContent) : void 0) ?? // @legacy(remote-components<=0.4.x): keep reading the historical shared
|
|
332
|
+
// map until remotes on 0.4.x are outside the compatibility window.
|
|
333
|
+
nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
334
|
+
remoteSharedManifestEl?.remove();
|
|
326
335
|
remoteSharedEl?.remove();
|
|
327
336
|
return remoteShared;
|
|
328
337
|
}
|
|
@@ -531,10 +540,9 @@ function preparePipeline(input) {
|
|
|
531
540
|
const doc = parser.parseFromString(input.html, "text/html");
|
|
532
541
|
const parsed = parseRemoteComponentDocument(doc, input.name, input.url);
|
|
533
542
|
const remoteShared = input.remoteShared ?? parsed.remoteShared;
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
);
|
|
543
|
+
const missingSharedModulesMessage = getMissingSharedModulesMessage(remoteShared);
|
|
544
|
+
if (missingSharedModulesMessage) {
|
|
545
|
+
throw new RemoteComponentsError(missingSharedModulesMessage);
|
|
538
546
|
}
|
|
539
547
|
applyOriginToNodes(doc, input.url, input.resolveClientUrl);
|
|
540
548
|
const scriptDescriptors = buildScriptDescriptors(parsed.scripts, input.url);
|
|
@@ -701,4 +709,4 @@ export {
|
|
|
701
709
|
resolveNameFromSrc,
|
|
702
710
|
bindResolveClientUrl
|
|
703
711
|
};
|
|
704
|
-
//# sourceMappingURL=chunk-
|
|
712
|
+
//# sourceMappingURL=chunk-O4A6CJGI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/server/fetch-with-hooks.ts","../src/host/server/get-client-or-server-url.ts","../src/host/shared/lifecycle.ts","../src/runtime/rsc.ts","../src/runtime/html/html-spec.ts","../src/runtime/html/rewrite-srcset.ts","../src/runtime/html/apply-origin.ts","../src/runtime/metadata.ts","../src/runtime/html/parse-remote-html.ts","../src/runtime/loaders/component-loader.ts","../src/runtime/rsc-imports.ts","../src/host/shared/pipeline.ts","../src/host/shared/state.ts","../src/host/utils/resolve-name-from-src.ts","../src/runtime/url/resolve-client-url.ts","../src/runtime/url/default-resolve-client-url.ts"],"sourcesContent":["import type {\n HookOptions,\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nimport { warnCrossOriginFetchError } from '#internal/utils/logger';\nimport { remoteFetchHeaders } from './fetch-headers';\n\n/**\n * Options for fetching with request/response hooks.\n */\ninterface FetchWithHooksOptions {\n /** Hook to intercept the request before fetching */\n onRequest?: OnRequestHook;\n /** Hook to process the response after fetching */\n onResponse?: OnResponseHook;\n /** AbortController to cancel loading - aborts will throw AbortError */\n abortController?: AbortController;\n}\n\n/**\n * Performs a fetch with optional request and response lifecycle hooks.\n *\n * This utility centralizes the logic for:\n * 1. Calling onRequest hook - if it returns a Response, use it instead of fetching\n * 2. Performing the actual fetch if onRequest didn't provide a response\n * 3. Calling onResponse hook - if it returns a Response, use that transformed response\n *\n * Hooks receive an AbortSignal and abort function to cancel loading at any point.\n * When aborted, throws AbortError (DOMException with name 'AbortError').\n *\n * @param url - The URL to fetch\n * @param init - The fetch init options\n * @param options - Optional hooks for request/response interception and AbortController\n * @returns The response (never null - throws on abort)\n * @throws DOMException with name 'AbortError' if loading is aborted\n *\n * @example\n * const controller = new AbortController();\n * try {\n * const response = await fetchWithHooks(url, fetchInit, {\n * abortController: controller,\n * onResponse: async (url, response, { abort }) => {\n * if (response.redirected) {\n * abort(); // Throws AbortError\n * }\n * },\n * });\n * } catch (error) {\n * if (error.name === 'AbortError') {\n * console.log('Loading was aborted');\n * }\n * }\n */\nasync function fetchWithWarning(\n url: URL,\n init: RequestInit,\n): Promise<Response> {\n try {\n return await fetch(url, init);\n } catch (error) {\n warnCrossOriginFetchError('FetchRemoteComponent', url);\n throw error;\n }\n}\n\nexport async function fetchWithHooks(\n url: URL,\n additionalInit: {\n credentials?: RequestCredentials;\n next?: {\n tags?: string[];\n };\n },\n options: FetchWithHooksOptions = {},\n): Promise<Response> {\n const {\n onRequest,\n onResponse,\n abortController = new AbortController(),\n } = options;\n const signal = abortController.signal;\n\n const hookOptions: HookOptions = {\n signal,\n abort: (reason?: unknown) => abortController.abort(reason),\n };\n\n // Include signal in fetch init for reactive abort support\n const init: RequestInit = {\n method: 'GET',\n headers: remoteFetchHeaders(),\n signal,\n ...additionalInit,\n };\n\n // Call onRequest hook if provided - may return a Response to skip fetching\n const res =\n (await onRequest?.(url, init, hookOptions)) ??\n (await fetchWithWarning(url, init));\n\n // Call onResponse hook if provided - may return a transformed Response\n return (await onResponse?.(url, res, hookOptions)) ?? res;\n}\n","export function getClientOrServerUrl(\n src: string | URL | undefined,\n serverFallback: string,\n): URL {\n const fallback =\n typeof location !== 'undefined' ? location.href : serverFallback;\n\n if (!src) {\n return new URL(fallback);\n }\n\n return typeof src === 'string' ? new URL(src, fallback) : src;\n}\n","import type { ChangeInfo, ConsumeLifecycleCallbacks } from './config';\n\n/**\n * Unified lifecycle event emitter used by the host loading pipeline.\n *\n * Hosts create an emitter that matches their eventing model — React hosts\n * wrap callback props via {@link makeReactEmitter}, while the HTML custom\n * element dispatches DOM events via {@link makeEventEmitter}. The pipeline\n * calls emitter methods at the appropriate phases without knowing which\n * host is driving the load.\n */\nexport interface LifecycleEmitter {\n beforeLoad(src: string | URL): void;\n load(src: string | URL): void;\n error(error: unknown, src?: string | URL): void;\n change(info: ChangeInfo): void;\n}\n\n/**\n * Wraps React-style callback props into a {@link LifecycleEmitter}.\n *\n * Missing callbacks are silently ignored — this is the normal case for\n * hosts that only subscribe to a subset of events.\n */\nexport function makeReactEmitter(\n callbacks: ConsumeLifecycleCallbacks,\n): LifecycleEmitter {\n return {\n beforeLoad(src) {\n callbacks.onBeforeLoad?.(src);\n },\n load(src) {\n callbacks.onLoad?.(src);\n },\n error(error, _src?) {\n callbacks.onError?.(error);\n },\n change(info) {\n callbacks.onChange?.(info);\n },\n };\n}\n\n/**\n * Wraps a DOM element into a {@link LifecycleEmitter} by dispatching\n * `CustomEvent`s with `bubbles: true` and `composed: true` (crosses\n * Shadow DOM boundaries).\n */\nexport function makeEventEmitter(element: HTMLElement): LifecycleEmitter {\n function dispatch(\n type: 'beforeload' | 'load' | 'error' | 'change',\n detail?: Record<string, unknown>,\n ) {\n const event = new Event(type, { bubbles: true, composed: true });\n if (detail) {\n Object.assign(event, detail);\n }\n element.dispatchEvent(event);\n }\n\n return {\n beforeLoad(src) {\n dispatch('beforeload', { src });\n },\n load(src) {\n dispatch('load', { src });\n },\n error(error, src?) {\n dispatch('error', src != null ? { error, src } : { error });\n },\n change(info) {\n dispatch('change', info as unknown as Record<string, unknown>);\n },\n };\n}\n","import { ReadableStream } from 'web-streams-polyfill';\n\n/**\n * Fixes RSC payload arrays to be compatible with React JSX development runtime.\n * React elements in the wire format are 4-element arrays (`['$', type, key, props]`);\n * the dev runtime expects 7 elements with debug info in positions 4-6.\n */\nexport function fixPayload(payload: unknown): void {\n if (Array.isArray(payload)) {\n if (payload[0] === '$') {\n // React element — fix props recursively, then pad to 7 elements\n fixPayload(payload[3]);\n if (payload.length === 4) {\n payload.push(null, null, 1);\n }\n } else {\n for (const item of payload) {\n fixPayload(item);\n }\n }\n } else if (typeof payload === 'object' && payload !== null) {\n for (const key in payload) {\n fixPayload((payload as Record<string, unknown>)[key]);\n }\n }\n}\n\n/**\n * Parses raw RSC script chunks (the `self[\"name\"].push(\"...\")` format produced\n * by `<RemoteComponentData>`) into a flat array of flight-data strings.\n *\n * This is a pure function — it reads from `data` only, never from `globalThis`.\n */\nexport function buildRSCChunks(rscName: string, data: string[]): string[] {\n const chunks: string[] = [];\n\n for (const chunk of data) {\n for (const line of chunk.split('\\n')) {\n const match = /\\.push\\(\"(?<rsc>.*)\"\\);$/.exec(line);\n if (match?.groups?.rsc) {\n chunks.push(JSON.parse(`\"${match.groups.rsc}\"`) as string);\n }\n }\n }\n\n return chunks;\n}\n\n/**\n * Processes RSC flight data and creates a ReadableStream.\n *\n * First checks `data` for inline script chunks (parsed via {@link buildRSCChunks}),\n * merging them onto `globalThis[rscName]`. Then consumes the global array\n * (or falls back to an empty RSC payload) and pipes fixed chunks into the stream.\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 // Parse inline script chunks and merge onto the global array\n if (data.length > 0) {\n const parsed = buildRSCChunks(rscName, data);\n if (parsed.length > 0) {\n self[rscName] = self[rscName] ?? [];\n self[rscName].push(...parsed);\n }\n }\n\n // Consume the global RSC flight data, falling back to an empty payload\n const allChunks = (self[rscName] ?? [`0:[null]\\n`]).join('');\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 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 const jsonPayload = JSON.parse(payload) as unknown[];\n fixPayload(jsonPayload);\n const reconstruct = `${before ?? ''}${id}:${prefix ?? ''}${JSON.stringify(jsonPayload)}`;\n controller.enqueue(encoder.encode(`${reconstruct}\\n`));\n } else {\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n } else {\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n });\n controller.close();\n },\n });\n}\n","/**\n * Pure constants for HTML element names, data attributes, and ID suffixes\n * used across both server-side (parse5) and browser (DOM) HTML processing.\n *\n * No imports, no runtime code — safe to use in any context.\n */\n\n/** Elements whose `src`, `href`, `srcset`, and `imagesrcset` need origin rewriting. */\nexport const ORIGIN_REWRITE_TAGS = [\n 'img',\n 'source',\n 'video',\n 'audio',\n 'track',\n 'iframe',\n 'embed',\n 'script',\n 'link',\n] as const;\n\n// ID suffixes appended to the component name to form element IDs.\nexport const ID_SUFFIX_RSC = '_rsc';\nexport const ID_SUFFIX_SSR = '_ssr';\nexport const ID_SUFFIX_SHARED = '_shared';\nexport const ID_SUFFIX_SHARED_MANIFEST = '_shared_manifest';\n\n// Data attributes written on the remote component wrapper element.\nexport const DATA_BUNDLE = 'data-bundle';\nexport const DATA_ROUTE = 'data-route';\nexport const DATA_RUNTIME = 'data-runtime';\nexport const DATA_TYPE = 'data-type';\nexport const DATA_SRC = 'data-src';\nexport const DATA_REMOTE_COMPONENTS_SHARED = 'data-remote-components-shared';\nexport const DATA_REMOTE_COMPONENTS_SHARED_MANIFEST =\n 'data-remote-components-shared-manifest';\n\n// Well-known element identifiers.\nexport const TAG_REMOTE_COMPONENT = 'remote-component';\nexport const NEXT_DATA_ID = '__NEXT_DATA__';\nexport const REMOTE_NEXT_DATA_ID = '__REMOTE_NEXT_DATA__';\nexport const NEXT_CONTAINER_ID = '__next';\n","/**\n * Rewrites relative URLs in an HTML `srcset` or `imagesrcset` attribute value\n * to absolute URLs. Works identically in server (parse5) and browser (DOM) contexts.\n *\n * @param srcset - The raw srcset attribute value (comma-separated entries).\n * @param base - Base URL or origin to resolve relative URLs against.\n * @param resolve - Optional callback applied to each absolute URL (e.g. to proxy through a CDN).\n * @returns The rewritten srcset string with absolute (and optionally resolved) URLs.\n */\nexport function rewriteSrcset(\n srcset: string,\n base: URL | string,\n resolve?: (absoluteUrl: string) => string,\n): string {\n return srcset\n .split(',')\n .map((entry) => {\n const [url, descriptor] = entry.trim().split(/\\s+/);\n if (!url) return entry;\n\n const absoluteUrl = new URL(url, base).href;\n const resolvedUrl = resolve ? resolve(absoluteUrl) : absoluteUrl;\n return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;\n })\n .join(', ');\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { ORIGIN_REWRITE_TAGS } from './html-spec';\nimport { rewriteSrcset } from './rewrite-srcset';\n\nexport function applyOriginToNodes(\n doc: Document | HTMLElement,\n url: URL,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n if (url.origin !== location.origin) {\n const nodes = doc.querySelectorAll<HTMLImageElement>(\n ORIGIN_REWRITE_TAGS.map(\n (type) =>\n `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`,\n ).join(','),\n );\n nodes.forEach((node) => {\n if (\n node.hasAttribute('src') &&\n /^[./]+\\/?/.test(node.getAttribute('src') ?? '')\n ) {\n const absoluteSrc = new URL(node.getAttribute('src') ?? '/', url).href;\n // Script elements are handled by the loaders (script-loader, static-loader)\n // which apply the callback themselves. Only apply it here for non-script elements.\n const isScript = node.tagName.toLowerCase() === 'script';\n node.src = isScript\n ? absoluteSrc\n : (resolveClientUrl?.(absoluteSrc) ?? absoluteSrc);\n }\n if (\n node.hasAttribute('href') &&\n /^[./]+\\/?/.test(node.getAttribute('href') ?? '')\n ) {\n const absoluteHref = new URL(node.getAttribute('href') ?? '/', url)\n .href;\n node.setAttribute(\n 'href',\n resolveClientUrl?.(absoluteHref) ?? absoluteHref,\n );\n }\n if (node.hasAttribute('srcset')) {\n const raw = node.getAttribute('srcset');\n if (raw) {\n const resolve = resolveClientUrl\n ? (abs: string) => resolveClientUrl(abs) ?? abs\n : undefined;\n node.setAttribute('srcset', rewriteSrcset(raw, url, resolve));\n }\n }\n if (node.hasAttribute('imagesrcset')) {\n const raw = node.getAttribute('imagesrcset');\n if (raw) {\n const resolve = resolveClientUrl\n ? (abs: string) => resolveClientUrl(abs) ?? abs\n : undefined;\n node.setAttribute('imagesrcset', rewriteSrcset(raw, url, resolve));\n }\n }\n });\n }\n}\n","import {\n DEFAULT_BUNDLE_NAME,\n DEFAULT_COMPONENT_NAME,\n DEFAULT_ROUTE,\n} from '#internal/runtime/constants';\n\n/**\n * Metadata embedded in the HTML response by a remote application.\n *\n * Extracted from a `<script type=\"application/json\" data-remote-component>`\n * element during both SSR parsing ({@link fetchRemoteComponent}) and\n * client-side parsing ({@link parseRemoteComponentDocument}).\n */\nexport interface RemoteComponentMetadata {\n name: string;\n bundle: string;\n route: string;\n runtime: 'webpack' | 'turbopack' | 'script';\n id: string;\n type: 'nextjs' | 'remote-component' | 'unknown';\n}\n\n/**\n * Raw attribute values before defaults are applied. Accepts nullable strings\n * so callers can pass DOM attributes or parsed JSON directly.\n */\nexport interface RawMetadataAttrs {\n name?: string | null;\n bundle?: string | null;\n route?: string | null;\n runtime?: string | null;\n id?: string | null;\n type?: string | null;\n}\n\nconst VALID_RUNTIMES: Set<string> = new Set(['webpack', 'turbopack', 'script']);\nconst VALID_TYPES: Set<string> = new Set([\n 'nextjs',\n 'remote-component',\n 'unknown',\n]);\n\nfunction isRuntime(value: string): value is RemoteComponentMetadata['runtime'] {\n return VALID_RUNTIMES.has(value);\n}\n\nfunction isComponentType(\n value: string,\n): value is RemoteComponentMetadata['type'] {\n return VALID_TYPES.has(value);\n}\n\nfunction toRuntime(\n value: string | null | undefined,\n): RemoteComponentMetadata['runtime'] {\n return value && isRuntime(value) ? value : 'webpack';\n}\n\nfunction toComponentType(\n value: string | null | undefined,\n): RemoteComponentMetadata['type'] {\n return value && isComponentType(value) ? value : 'unknown';\n}\n\n/**\n * Applies default values to raw metadata attributes and returns a fully\n * resolved {@link RemoteComponentMetadata}. When no bundle is provided, falls\n * back to the `NEXT_PUBLIC_MFE_CURRENT_APPLICATION` env var (the host's\n * application name), then `DEFAULT_BUNDLE_NAME`.\n */\nexport function buildMetadata(\n attrs: RawMetadataAttrs,\n url: URL,\n): RemoteComponentMetadata {\n const id = attrs.id || DEFAULT_COMPONENT_NAME;\n const bundle =\n attrs.bundle ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n DEFAULT_BUNDLE_NAME;\n return {\n name: attrs.name || id.replace(/_ssr$/, ''),\n bundle,\n route: attrs.route || url.pathname || DEFAULT_ROUTE,\n runtime: toRuntime(attrs.runtime),\n id,\n type: toComponentType(attrs.type),\n };\n}\n","import type { NextData } from '#internal/host/server/types';\nimport type { RemoteSharedModules } from '#internal/host/shared/shared-broker';\nimport {\n DEFAULT_COMPONENT_NAME,\n RUNTIME_SCRIPT,\n} from '#internal/runtime/constants';\nimport {\n buildMetadata,\n type RemoteComponentMetadata,\n} from '#internal/runtime/metadata';\nimport {\n multipleRemoteComponentsError,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport {\n DATA_BUNDLE,\n DATA_REMOTE_COMPONENTS_SHARED,\n DATA_REMOTE_COMPONENTS_SHARED_MANIFEST,\n DATA_ROUTE,\n DATA_RUNTIME,\n DATA_SRC,\n DATA_TYPE,\n ID_SUFFIX_RSC,\n ID_SUFFIX_SHARED,\n ID_SUFFIX_SHARED_MANIFEST,\n ID_SUFFIX_SSR,\n NEXT_CONTAINER_ID,\n NEXT_DATA_ID,\n REMOTE_NEXT_DATA_ID,\n TAG_REMOTE_COMPONENT,\n} from './html-spec';\n\nexport interface ParsedRemoteComponent {\n /** The DOM element representing the remote component content. */\n component: Element;\n /** Resolved name of the remote component (with _ssr suffix stripped). */\n name: string;\n /** Whether the component is a <remote-component> custom element. */\n isRemoteComponent: boolean;\n /** Component metadata: bundle, route, runtime. */\n metadata: RemoteComponentMetadata;\n /** Parsed __NEXT_DATA__ or __REMOTE_NEXT_DATA__, or null. */\n nextData: NextData | null;\n /** The RSC flight data script element, or null. */\n rsc: Element | null;\n /** Shared module manifest or compatibility map extracted from the document. */\n remoteShared: RemoteSharedModules;\n /** Link elements extracted from the document (outside the component). */\n links: HTMLLinkElement[];\n /** Script elements extracted from the component or document. */\n scripts: HTMLScriptElement[];\n}\n\n/**\n * Validates that the document does not contain multiple unnamed remote components.\n * When multiple components exist, the consumer must specify a name to select one.\n */\nexport function validateSingleComponent(\n doc: Document,\n name: string,\n url: string,\n): void {\n if (\n (doc.querySelectorAll(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`).length > 1 &&\n !doc.querySelector(\n `div[${DATA_BUNDLE}][${DATA_ROUTE}][id^=\"${name}\"]`,\n )) ||\n (doc.querySelectorAll(`${TAG_REMOTE_COMPONENT}:not([src])`).length > 1 &&\n !doc.querySelector(`${TAG_REMOTE_COMPONENT}[name=\"${name}\"]`))\n ) {\n throw multipleRemoteComponentsError(url);\n }\n}\n\n/**\n * Finds the remote component element in the parsed HTML document using the\n * standard querySelector chain. Returns null if no component is found.\n */\nexport function findComponentElement(\n doc: Document,\n name: string,\n): Element | null {\n return (\n doc.querySelector(`div[${DATA_BUNDLE}][${DATA_ROUTE}][id^=\"${name}\"]`) ??\n doc.querySelector(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`) ??\n doc.querySelector(`div#${NEXT_CONTAINER_ID}`) ??\n doc.querySelector(`${TAG_REMOTE_COMPONENT}[name=\"${name}\"]:not([src])`) ??\n doc.querySelector(`${TAG_REMOTE_COMPONENT}:not([src])`)\n );\n}\n\n/**\n * Parses the __NEXT_DATA__ or __REMOTE_NEXT_DATA__ script element from the document.\n */\nexport function parseNextData(doc: Document): NextData | null {\n return JSON.parse(\n (\n doc.querySelector(`#${NEXT_DATA_ID}`) ??\n doc.querySelector(`#${REMOTE_NEXT_DATA_ID}`)\n )?.textContent ?? 'null',\n ) as NextData | null;\n}\n\n/**\n * Resolves the component name from the element's id attribute, the name attribute\n * (for <remote-component> elements), nextData, or a fallback value.\n * Strips the _ssr suffix from the id if present.\n */\nexport function resolveComponentName(\n component: Element | null,\n nextData: NextData | null,\n fallbackName: string,\n): { name: string; isRemoteComponent: boolean } {\n const isRemoteComponent =\n component?.tagName.toLowerCase() === TAG_REMOTE_COMPONENT;\n\n const name =\n component\n ?.getAttribute('id')\n ?.replace(new RegExp(`${ID_SUFFIX_SSR}$`), '') ||\n (isRemoteComponent && component?.getAttribute('name')) ||\n (nextData ? '__next' : fallbackName);\n\n return { name, isRemoteComponent };\n}\n\n/**\n * Extracts the shared module map from the document and removes the element.\n * Falls back to nextData's shared modules if available.\n */\nexport function extractRemoteShared(\n doc: Document,\n name: string,\n nextData: NextData | null,\n): RemoteSharedModules {\n const remoteSharedManifestEl = doc.querySelector(\n `#${name}${ID_SUFFIX_SHARED_MANIFEST}[${DATA_REMOTE_COMPONENTS_SHARED_MANIFEST}]`,\n );\n const remoteSharedEl = doc.querySelector(\n `#${name}${ID_SUFFIX_SHARED}[${DATA_REMOTE_COMPONENTS_SHARED}]`,\n );\n const remoteShared =\n nextData?.props.__REMOTE_COMPONENT__?.sharedManifest ??\n ((remoteSharedManifestEl?.textContent\n ? JSON.parse(remoteSharedManifestEl.textContent)\n : undefined) as RemoteSharedModules | undefined) ??\n // @legacy(remote-components<=0.4.x): keep reading the historical shared\n // map until remotes on 0.4.x are outside the compatibility window.\n nextData?.props.__REMOTE_COMPONENT__?.shared ??\n ((JSON.parse(remoteSharedEl?.textContent ?? '{}') ?? {}) as Record<\n string,\n string\n >);\n remoteSharedManifestEl?.remove();\n remoteSharedEl?.remove();\n return remoteShared;\n}\n\n/**\n * Validates that a remote component was found in the document and that it has\n * RSC data, Next.js data, or is a <remote-component> element.\n * Acts as a type assertion - narrows component to non-null on success.\n */\nexport function validateComponentFound(\n component: Element | null,\n rsc: Element | null,\n nextData: NextData | null,\n isRemoteComponent: boolean,\n url: string,\n name: string,\n): asserts component is Element {\n if (!component || !(rsc || nextData || isRemoteComponent)) {\n throw new RemoteComponentsError(\n `Remote Component not found on ${url}.${\n name !== DEFAULT_COMPONENT_NAME\n ? ` The name for the <RemoteComponent> is \"${name}\". Check <RemoteComponent> usage.`\n : ''\n } Did you forget to wrap the content in <RemoteComponent>?`,\n );\n }\n}\n\n/**\n * Extracts link elements from the document that are not inside the component.\n */\nexport function extractLinks(\n doc: Document,\n component: Element,\n): HTMLLinkElement[] {\n return Array.from(doc.querySelectorAll<HTMLLinkElement>('link[href]')).filter(\n (link) => !component.contains(link),\n );\n}\n\n/**\n * Extracts script elements from the component or document, depending on whether\n * the component is a <remote-component> custom element.\n */\nexport function extractScripts(\n doc: Document,\n component: Element,\n isRemoteComponent: boolean,\n): HTMLScriptElement[] {\n return Array.from(\n (isRemoteComponent ? component : doc).querySelectorAll<HTMLScriptElement>(\n `script[src],script[${DATA_SRC}]`,\n ),\n );\n}\n\n/**\n * Parses a remote component HTML document and extracts all data needed for\n * loading and hydrating the component. This is the main orchestrator that\n * calls the individual extraction functions.\n */\nexport function parseRemoteComponentDocument(\n doc: Document,\n name: string,\n url: URL,\n): ParsedRemoteComponent {\n validateSingleComponent(doc, name, url.href);\n\n const component = findComponentElement(doc, name);\n const nextData = parseNextData(doc);\n\n const { name: resolvedName, isRemoteComponent } = resolveComponentName(\n component,\n nextData,\n name,\n );\n\n const rsc = doc.querySelector(`#${resolvedName}${ID_SUFFIX_RSC}`);\n const metadata = buildMetadata(\n {\n name: resolvedName,\n bundle:\n component?.getAttribute(DATA_BUNDLE) ||\n nextData?.props.__REMOTE_COMPONENT__?.bundle,\n route: component?.getAttribute(DATA_ROUTE) ?? nextData?.page,\n runtime:\n component?.getAttribute(DATA_RUNTIME) ??\n nextData?.props.__REMOTE_COMPONENT__?.runtime ??\n RUNTIME_SCRIPT,\n id: component?.getAttribute('id'),\n type: component?.getAttribute(DATA_TYPE),\n },\n url,\n );\n const remoteShared = extractRemoteShared(doc, resolvedName, nextData);\n\n validateComponentFound(\n component,\n rsc,\n nextData,\n isRemoteComponent,\n url.href,\n resolvedName,\n );\n\n const links = extractLinks(doc, component);\n const scripts = extractScripts(doc, component, isRemoteComponent);\n\n return {\n component,\n name: resolvedName,\n isRemoteComponent,\n metadata,\n nextData,\n rsc,\n remoteShared,\n links,\n scripts,\n };\n}\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 { applySharedModules } from '#internal/config/webpack/apply-shared-modules';\nimport { nextClientPagesLoader } from '#internal/config/webpack/next-client-pages-loader';\nimport type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport type { ConsumeLoaderPayload } from '#internal/host/shared/server-handoff';\nimport type { RemoteSharedModules } from '#internal/host/shared/shared-broker';\nimport {\n buildCoreShared,\n buildWebpackResolve,\n} from '#internal/host/shared/shared-module-resolver';\nimport { createRSCStream } from '#internal/runtime/rsc';\nimport { importRSCClientBrowser } from '#internal/runtime/rsc-imports';\nimport { setupRemoteScope } from '#internal/runtime/turbopack/remote-scope-setup';\nimport { initializeSharedModules } from '#internal/runtime/turbopack/shared-modules';\nimport type { GlobalScope, LoaderResult } from '#internal/runtime/types';\nimport { RemoteComponentsError } from '#internal/utils/error';\nimport { logDebug, logWarn } from '#internal/utils/logger';\nimport { loadScripts } from './script-loader';\n\n/**\n * Props accepted by {@link loadRemoteComponent}.\n *\n * Extends {@link ConsumeLoaderPayload} (the SSR-resolved fields needed for\n * hydration) with loader-specific fields (`url`, `shared`, `container`, etc.).\n * `remoteShared` is narrowed from optional to required (defaults to `{}` at\n * the call site).\n */\nexport interface ConsumeLoaderProps extends ConsumeLoaderPayload {\n url: URL;\n shared:\n | Promise<Record<string, (bundle?: string) => Promise<unknown>>>\n | Record<string, (bundle?: string) => Promise<unknown>>;\n remoteShared: RemoteSharedModules;\n container?: HTMLHeadElement | ShadowRoot | null;\n rscName?: string;\n resolveClientUrl?: InternalResolveClientUrl;\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 resolveClientUrl,\n}: ConsumeLoaderProps): 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, resolveClientUrl);\n }\n\n const hostShared = await shared;\n logDebug(\n 'ComponentLoader',\n `loadRemoteComponent: bundle=\"${bundle}\", name=\"${name}\"`,\n );\n logDebug(\n 'ComponentLoader',\n `Host shared modules available: ${Object.keys(hostShared)}`,\n );\n logDebug(\n 'ComponentLoader',\n `Remote shared modules requested: ${JSON.stringify(remoteShared)}`,\n );\n\n // Setup remote scope and load turbopack chunks\n const scope = await setupRemoteScope(\n runtime,\n scripts,\n url,\n bundle,\n resolveClientUrl,\n );\n\n // Initialize turbopack shared modules (React, etc.) now that chunks are loaded\n if (runtime === 'turbopack') {\n await initializeSharedModules(\n scope,\n buildCoreShared(hostShared),\n remoteShared,\n );\n }\n\n // Setup shared modules\n if (bundle && runtime === 'webpack') {\n const resolve = await buildWebpackResolve(\n hostShared,\n remoteShared,\n bundle,\n {\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 },\n 'ComponentLoader',\n );\n applySharedModules(bundle, resolve);\n } else if (bundle && runtime === 'turbopack') {\n // New shared-module architecture: Turbopack installs resolved modules\n // onto RemoteScope in initializeSharedModules(). Keep Webpack patching\n // isolated above so this branch can be deleted with the old\n // applySharedModules path once Webpack also moves to scope adapters.\n } else {\n logWarn(\n 'ComponentLoader',\n 'No bundle specified, skipping shared module setup',\n );\n }\n\n // Rewrite plain bundle references in RSC data to the scoped name so\n // the client dispatchers resolve the correct scope.\n const scopedData = data.map((chunk) =>\n chunk.replaceAll(`[${bundle}]`, `[${scope.scopedName}]`),\n );\n\n // Load component based on data type\n if (scopedData.length > 0) {\n return await loadRSCComponent(rscName ?? name, scopedData);\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 const { createFromReadableStream } = await importRSCClientBrowser();\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<ConsumeLoaderPayload['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","/**\n * Single import hub for all React Server Components runtime modules.\n *\n * Each function encapsulates the try/catch fallback chain that probes\n * Next.js internal paths first, then falls back to the public\n * `react-server-dom-webpack` / `react-server-dom-turbopack` packages.\n * This keeps version-specific import paths out of business logic.\n */\n\nimport type {\n RSCClientBrowserRuntime,\n RSCClientEdgeRuntime,\n RSCServerRuntime,\n} from './rsc-runtime';\n\n/**\n * Imports the RSC client for the **edge** runtime (server-side).\n * Used by `fetch-remote-component.ts` to deserialise RSC flight data.\n *\n * Tries the Next.js compiled path first, falls back to the bare\n * `react-server-dom-webpack/client.edge` module.\n */\nexport async function importRSCClientEdge(): Promise<RSCClientEdgeRuntime> {\n try {\n return await import(\n 'next/dist/compiled/react-server-dom-webpack/client.edge'\n );\n } catch {\n return await import('react-server-dom-webpack/client.edge');\n }\n}\n\n/**\n * Imports the RSC client for the **browser** runtime (client-side hydration).\n * Used by `component-loader.ts` to hydrate RSC streams in the browser.\n *\n * Tries the Next.js compiled path first, falls back to the bare\n * `react-server-dom-webpack/client.browser` module (which may use a\n * default export depending on the package version).\n */\nexport async function importRSCClientBrowser(): Promise<RSCClientBrowserRuntime> {\n try {\n return await import(\n 'next/dist/compiled/react-server-dom-webpack/client.browser'\n );\n } catch {\n const mod = await import('react-server-dom-webpack/client.browser');\n // Some versions export `createFromReadableStream` as a default export\n return (mod.default ?? mod) as RSCClientBrowserRuntime;\n }\n}\n\n/**\n * Imports the RSC **server** renderer for `ExposeRemoteComponent`.\n *\n * When `TURBOPACK` is set in the environment, imports from\n * `react-server-dom-turbopack`; otherwise uses `react-server-dom-webpack`.\n * Each variant tries the primary path first (`/server`), falling back to\n * the `.edge` entry point.\n */\nexport async function importRSCServer(): Promise<RSCServerRuntime> {\n const [primary, fallback] = await Promise.all(\n process.env.TURBOPACK\n ? [\n tryImport<RSCServerRuntime>(\n () => import('react-server-dom-turbopack/server'),\n ),\n tryImport<RSCServerRuntime>(\n () => import('react-server-dom-turbopack/server.edge'),\n ),\n ]\n : [\n tryImport<RSCServerRuntime>(\n () => import('react-server-dom-webpack/server'),\n ),\n tryImport<RSCServerRuntime>(\n () => import('react-server-dom-webpack/server.edge'),\n ),\n ],\n );\n\n return {\n renderToReadableStream:\n primary.renderToReadableStream ?? fallback.renderToReadableStream,\n };\n}\n\nasync function tryImport<T>(importer: () => Promise<T>): Promise<T> {\n try {\n return await importer();\n } catch {\n return {} as T;\n }\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport type { ScriptDescriptor } from '#internal/host/shared/asset-descriptors';\nimport type { ConsumeLoaderPayload } from '#internal/host/shared/server-handoff';\nimport {\n getMissingSharedModulesMessage,\n type RemoteSharedModules,\n} from '#internal/host/shared/shared-broker';\nimport { buildHostShared } from '#internal/host/shared/shared-module-resolver';\nimport { applyOriginToNodes } from '#internal/runtime/html/apply-origin';\nimport {\n type ParsedRemoteComponent,\n parseRemoteComponentDocument,\n} from '#internal/runtime/html/parse-remote-html';\nimport { loadRemoteComponent } from '#internal/runtime/loaders/component-loader';\nimport { loadStaticRemoteComponent } from '#internal/runtime/loaders/static-loader';\nimport type { RemoteComponentMetadata } from '#internal/runtime/metadata';\nimport {\n collapseDoubleSlashes,\n REMOTE_COMPONENT_REGEX,\n} from '#internal/runtime/patterns';\nimport type { MountOrUnmountFunction } from '#internal/runtime/types';\nimport { escapeString } from '#internal/utils';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype SharedModuleMap = Record<string, (bundle?: string) => Promise<unknown>>;\n\n/**\n * Input for {@link runPipeline} — the full post-fetch pipeline that starts\n * from raw HTML.\n */\nexport interface PipelineInput {\n /** Resolved URL of the remote component. */\n url: URL;\n /** Raw HTML string returned by the remote. */\n html: string;\n /** Component name hint (may be refined during parsing). */\n name: string;\n /** Abort signal — the pipeline checks this between async steps. */\n signal: AbortSignal;\n /** Host-provided shared module factories (resolved or promise). */\n shared: Promise<SharedModuleMap> | SharedModuleMap;\n /** URL rewriter for client-side asset URLs. */\n resolveClientUrl?: InternalResolveClientUrl;\n /** Shadow root or element to mount into (for script-based components). */\n container?: ShadowRoot | HTMLElement | null;\n}\n\n/**\n * Input for {@link runPipelineFromParsed} — the pipeline entry point for\n * hosts that receive pre-parsed SSR data (e.g. the App Router client).\n */\nexport interface ParsedPipelineInput {\n /** Resolved URL of the remote component. */\n url: URL;\n /** Component name. */\n name: string;\n /** Abort signal. */\n signal: AbortSignal;\n /** Pre-resolved loader payload from the server component. */\n payload: ConsumeLoaderPayload;\n /** Host-provided shared module factories (resolved or promise). */\n shared: Promise<SharedModuleMap> | SharedModuleMap;\n /** Remote-requested shared modules. */\n remoteShared?: RemoteSharedModules;\n /** URL rewriter for client-side asset URLs. */\n resolveClientUrl?: InternalResolveClientUrl;\n /** Shadow root or element to mount into. */\n container?: ShadowRoot | HTMLElement | null;\n /** Optional RSC name override (used by App Router for scoped RSC data). */\n rscName?: string;\n}\n\n/**\n * Successful dynamic component load — the component is a React element tree\n * ready to render.\n */\nexport interface PipelineLoaded {\n status: 'loaded';\n component: React.ReactNode;\n metadata: RemoteComponentMetadata;\n parsed: ParsedRemoteComponent;\n doc: Document;\n}\n\n/**\n * Successful static component load — mount/unmount functions are returned\n * for the host to call.\n */\nexport interface PipelineStatic {\n status: 'static';\n mount: Set<MountOrUnmountFunction>;\n unmount: Set<MountOrUnmountFunction>;\n metadata: RemoteComponentMetadata;\n parsed: ParsedRemoteComponent;\n doc: Document;\n}\n\n/** The load was aborted before it could complete. */\nexport interface PipelineAborted {\n status: 'aborted';\n}\n\n/** The load failed with an error. */\nexport interface PipelineError {\n status: 'error';\n error: Error;\n}\n\nexport type PipelineResult =\n | PipelineLoaded\n | PipelineStatic\n | PipelineAborted\n | PipelineError;\n\n/**\n * Intermediate result from {@link preparePipeline}. Hosts that need to run\n * framework-specific logic between parse and load (e.g. inline script\n * execution in the React host) use this to split the pipeline into two\n * phases.\n */\nexport interface PreparedPipeline {\n doc: Document;\n parsed: ParsedRemoteComponent;\n /** Script descriptors ready to pass to `loadRemoteComponent`. */\n scriptDescriptors: ScriptDescriptor[];\n}\n\n// ---------------------------------------------------------------------------\n// Pipeline phases\n// ---------------------------------------------------------------------------\n\n/**\n * Phase 1: Parse HTML, validate shared modules, and normalize URLs.\n *\n * This is the synchronous/cheap portion of the pipeline. Hosts that need to\n * inject logic between parse and load (e.g. executing inline scripts) call\n * this directly, then call {@link loadPrepared} when ready.\n */\nexport function preparePipeline(input: {\n html: string;\n name: string;\n url: URL;\n shared: SharedModuleMap;\n remoteShared?: RemoteSharedModules;\n resolveClientUrl?: InternalResolveClientUrl;\n}): PreparedPipeline {\n const parser = new DOMParser();\n const doc = parser.parseFromString(input.html, 'text/html');\n\n const parsed = parseRemoteComponentDocument(doc, input.name, input.url);\n\n // Validate shared modules — surface errors early before any script loading.\n // Only check *remote* shared modules here. The host-side marker\n // (`__remote_components_missing_shared__` in `input.shared`) is a callable\n // error signal that the host may intentionally leave in place when\n // `withRemoteComponentsConfig` is not used — blocking on it would break\n // framework-agnostic hosts that don't configure shared modules.\n const remoteShared = input.remoteShared ?? parsed.remoteShared;\n const missingSharedModulesMessage =\n getMissingSharedModulesMessage(remoteShared);\n if (missingSharedModulesMessage) {\n throw new RemoteComponentsError(missingSharedModulesMessage);\n }\n\n applyOriginToNodes(doc, input.url, input.resolveClientUrl);\n\n const scriptDescriptors = buildScriptDescriptors(parsed.scripts, input.url);\n\n return { doc, parsed, scriptDescriptors };\n}\n\n/**\n * Phase 2: Load the component from a prepared pipeline result.\n *\n * For dynamic components, delegates to `loadRemoteComponent`. For static\n * components (`isRemoteComponent`), delegates to `loadStaticRemoteComponent`.\n */\nexport async function loadPrepared(input: {\n prepared: PreparedPipeline;\n url: URL;\n signal: AbortSignal;\n shared: Promise<SharedModuleMap> | SharedModuleMap;\n resolveClientUrl?: InternalResolveClientUrl;\n container?: ShadowRoot | HTMLElement | null;\n rscName?: string;\n}): Promise<PipelineResult> {\n const { prepared, url, signal, resolveClientUrl, container, rscName } = input;\n const { doc, parsed, scriptDescriptors } = prepared;\n\n if (signal.aborted) {\n return { status: 'aborted' };\n }\n\n const userShared = await input.shared;\n if (signal.aborted) {\n return { status: 'aborted' };\n }\n\n if (parsed.isRemoteComponent) {\n return loadStaticPath({\n parsed,\n doc,\n url,\n resolveClientUrl,\n });\n }\n\n return loadDynamicPath({\n parsed,\n doc,\n url,\n scriptDescriptors,\n shared: userShared,\n resolveClientUrl,\n container,\n rscName,\n });\n}\n\n// ---------------------------------------------------------------------------\n// Full pipeline entry points\n// ---------------------------------------------------------------------------\n\n/**\n * Full post-fetch pipeline: parse → validate → normalize → load.\n *\n * Use this when starting from a raw HTML string (React host, HTML host).\n */\nexport async function runPipeline(\n input: PipelineInput,\n): Promise<PipelineResult> {\n try {\n const userShared = await input.shared;\n if (input.signal.aborted) {\n return { status: 'aborted' };\n }\n\n const prepared = preparePipeline({\n html: input.html,\n name: input.name,\n url: input.url,\n shared: userShared,\n resolveClientUrl: input.resolveClientUrl,\n });\n\n return await loadPrepared({\n prepared,\n url: input.url,\n signal: input.signal,\n shared: userShared,\n resolveClientUrl: input.resolveClientUrl,\n container: input.container,\n });\n } catch (error) {\n return {\n status: 'error',\n error:\n error instanceof Error\n ? error\n : new RemoteComponentsError(String(error)),\n };\n }\n}\n\n/**\n * Pipeline entry point for pre-parsed SSR data (App Router client).\n *\n * Skips HTML parsing and goes straight to `loadRemoteComponent` with the\n * pre-resolved payload from the server component.\n */\nexport async function runPipelineFromParsed(\n input: ParsedPipelineInput,\n): Promise<\n | { status: 'loaded'; component: React.ReactNode }\n | PipelineAborted\n | PipelineError\n> {\n try {\n if (input.signal.aborted) {\n return { status: 'aborted' };\n }\n\n const remoteShared = input.remoteShared ?? input.payload.remoteShared ?? {};\n\n const missingSharedModulesMessage =\n getMissingSharedModulesMessage(remoteShared);\n if (missingSharedModulesMessage) {\n throw new RemoteComponentsError(missingSharedModulesMessage);\n }\n\n const result = await loadRemoteComponent({\n url: input.url,\n name: input.name,\n rscName: input.rscName,\n bundle: input.payload.bundle,\n route: input.payload.route,\n runtime: input.payload.runtime,\n data: input.payload.data,\n nextData: input.payload.nextData,\n scripts: input.payload.scripts,\n shared: input.shared,\n remoteShared,\n container: input.container,\n resolveClientUrl: input.resolveClientUrl,\n });\n\n if (input.signal.aborted) {\n return { status: 'aborted' };\n }\n\n if (result.error) {\n return { status: 'error', error: result.error };\n }\n return { status: 'loaded', component: result.component };\n } catch (error) {\n return {\n status: 'error',\n error:\n error instanceof Error\n ? error\n : new RemoteComponentsError(String(error)),\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Converts parsed `<script>` elements into the `ScriptDescriptor[]` format\n * expected by `loadRemoteComponent`. Handles the `[bundle] id` URL format\n * and collapses double slashes.\n */\nfunction buildScriptDescriptors(\n scripts: HTMLScriptElement[],\n url: URL,\n): ScriptDescriptor[] {\n return scripts.map((script) => {\n const scriptSrc =\n script.getAttribute('data-src') ||\n script.getAttribute('src') ||\n script.src;\n const { prefix, id: path } = REMOTE_COMPONENT_REGEX.exec(scriptSrc)\n ?.groups ?? {\n prefix: undefined,\n id: scriptSrc,\n };\n return {\n src: new URL(collapseDoubleSlashes(`${prefix ?? ''}${path}`), url).href,\n };\n });\n}\n\nasync function loadStaticPath(input: {\n parsed: ParsedRemoteComponent;\n doc: Document;\n url: URL;\n resolveClientUrl?: InternalResolveClientUrl;\n}): Promise<PipelineStatic> {\n const { parsed, doc, url, resolveClientUrl } = input;\n const scripts = Array.from(\n parsed.component.querySelectorAll<HTMLScriptElement>('script'),\n );\n const { mount, unmount } = await loadStaticRemoteComponent(\n scripts,\n url,\n resolveClientUrl,\n );\n return {\n status: 'static',\n mount,\n unmount,\n metadata: parsed.metadata,\n parsed,\n doc,\n };\n}\n\nasync function loadDynamicPath(input: {\n parsed: ParsedRemoteComponent;\n doc: Document;\n url: URL;\n scriptDescriptors: ScriptDescriptor[];\n shared: SharedModuleMap;\n resolveClientUrl?: InternalResolveClientUrl;\n container?: ShadowRoot | HTMLElement | null;\n rscName?: string;\n}): Promise<PipelineLoaded | PipelineError> {\n const {\n parsed,\n doc,\n url,\n scriptDescriptors,\n shared,\n resolveClientUrl,\n container,\n } = input;\n\n const rscName =\n input.rscName ??\n (parsed.rsc\n ? `__remote_component_rsc_${escapeString(url.href)}_${escapeString(parsed.name)}`\n : undefined);\n\n const rscData = parsed.rsc\n ? (parsed.rsc.textContent || '').split('\\n').filter(Boolean)\n : [];\n\n const result = await loadRemoteComponent({\n url,\n name: parsed.name,\n rscName,\n bundle: parsed.metadata.bundle,\n route: parsed.metadata.route,\n runtime: parsed.metadata.runtime,\n data: rscData,\n nextData: parsed.nextData,\n scripts: scriptDescriptors,\n shared: buildHostShared(shared, resolveClientUrl),\n remoteShared: parsed.remoteShared,\n container,\n resolveClientUrl,\n });\n\n if (result.error) {\n return { status: 'error', error: result.error };\n }\n return {\n status: 'loaded',\n component: result.component,\n metadata: parsed.metadata,\n parsed,\n doc,\n };\n}\n","/**\n * The lifecycle stages a host progresses through during a load cycle.\n *\n * ```\n * ┌─────────────────────────┐\n * │ (new load) │\n * ▼ │\n * idle ──▶ loading ──▶ loaded ─────────┘\n * ▲ │ │\n * │ ▼ │ (new load)\n * │ error ─────────┘\n * │\n * └── loading (abandoned / aborted)\n * ```\n *\n * - `idle` — No load has started, or a previous load was abandoned.\n * - `loading` — A fetch or hydration is in progress.\n * - `loaded` — The remote component rendered successfully.\n * - `error` — The load failed (the error itself is surfaced separately).\n *\n * Any non-idle stage transitions directly to `loading` when a new load starts.\n */\nexport type HostStage = 'idle' | 'loading' | 'loaded' | 'error';\n\n/**\n * Mutable state shared by every host implementation (HTML, React, Next.js\n * App Router).\n *\n * Each host stores a single `HostState` instance rather than scattering\n * individual properties/refs. This keeps the \"what changed since the last\n * load?\" tracking consistent across frameworks and makes it easy to test\n * state transitions in isolation.\n */\nexport interface HostState {\n /** Current lifecycle stage. */\n stage: HostStage;\n\n /** Source from the most-recent load. `undefined` before the first load. */\n prevSrc: string | URL | undefined;\n\n /** Resolved URL from the most-recent load. `undefined` before the first load. */\n prevUrl: URL | undefined;\n\n /** Component name from the most-recent load. `undefined` before the first load. */\n prevName: string | undefined;\n\n /** Whether the most-recent load was a remote component (vs. a plain page). */\n prevIsRemoteComponent: boolean;\n\n /**\n * `AbortController` for the in-flight load. Abort it to cancel a\n * superseded fetch. `undefined` when no load is active.\n */\n abortController: AbortController | undefined;\n}\n\n/** Creates a fresh `HostState` with all fields at their initial values. */\nexport function createHostState(): HostState {\n return {\n stage: 'idle',\n prevSrc: undefined,\n prevUrl: undefined,\n prevName: undefined,\n prevIsRemoteComponent: false,\n abortController: undefined,\n };\n}\n","/**\n * Extracts a component name from the URL hash of `src`, falling back to\n * `defaultName` when no hash is present.\n *\n * Both the HTML and React hosts use this to derive the component name\n * from patterns like `/components/header#my-component`.\n *\n * Parses the hash directly from the string rather than constructing a\n * full `URL`, so no SSR fallback base is needed.\n */\nexport function resolveNameFromSrc(\n src: string | URL | undefined,\n defaultName: string,\n): string {\n if (!src) {\n return defaultName;\n }\n\n const hash = typeof src === 'string' ? src : src.hash;\n const hashIndex = hash.indexOf('#');\n if (hashIndex < 0) {\n return defaultName;\n }\n\n const name = hash.slice(hashIndex + 1);\n return name || defaultName;\n}\n","/**\n * Intercepts client-side URL resolution for remote component resources.\n * Called before each asset (script, stylesheet, chunk, module, image) is fetched.\n *\n * Return a new URL string to redirect the fetch (e.g., through a proxy),\n * or undefined to use the original URL.\n *\n * @param remoteSrc - The `src` of the remote component being loaded\n * @param url - The asset URL about to be fetched\n *\n * @example\n * // Proxy all assets from the remote's origin through the host\n * const resolveClientUrl = (remoteSrc, url) => {\n * const remoteOrigin = new URL(remoteSrc).origin;\n * const parsed = new URL(url);\n * if (parsed.origin !== location.origin && parsed.origin === remoteOrigin) {\n * return `/rc-fetch-protected-remote?url=${encodeURIComponent(url)}`;\n * }\n * };\n */\nexport type ResolveClientUrl = (\n remoteSrc: string,\n url: string,\n) => string | undefined;\n\n/**\n * Internal bound resolver — `ResolveClientUrl` with `remoteSrc` already applied.\n * Used by internal loaders that don't need to know the remote src.\n */\nexport type InternalResolveClientUrl = (url: string) => string | undefined;\n\n/**\n * Binds a `ResolveClientUrl` to a specific `remoteSrc`, producing an\n * `InternalResolveClientUrl` that only needs the asset URL.\n *\n * Only invokes the callback for URLs whose origin matches the remote\n * component's origin. Third-party scripts (e.g. `vercel.live` toolbar)\n * are left untouched. To proxy additional domains in the future, a\n * field or flag can be added to the host configuration.\n */\nexport function withRemoteSrc(\n resolveClientUrl: ResolveClientUrl,\n remoteSrc: string,\n): InternalResolveClientUrl {\n const remoteOrigin = parseOrigin(remoteSrc);\n return (url) => {\n const urlOrigin = parseOrigin(url);\n if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {\n return undefined;\n }\n return resolveClientUrl(remoteSrc, url);\n };\n}\n\nfunction parseOrigin(url: string): string | undefined {\n try {\n return new URL(url).origin;\n } catch {\n return undefined;\n }\n}\n","import {\n type InternalResolveClientUrl,\n type ResolveClientUrl,\n withRemoteSrc,\n} from './resolve-client-url';\n\nexport function bindResolveClientUrl(\n prop: ResolveClientUrl | undefined,\n remoteSrc: string,\n): InternalResolveClientUrl | undefined {\n return prop ? withRemoteSrc(prop, remoteSrc) : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,eAAe,iBACb,KACA,MACmB;AACnB,MAAI;AACF,WAAO,MAAM,MAAM,KAAK,IAAI;AAAA,EAC9B,SAAS,OAAP;AACA,8BAA0B,wBAAwB,GAAG;AACrD,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,eACpB,KACA,gBAMA,UAAiC,CAAC,GACf;AACnB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,kBAAkB,IAAI,gBAAgB;AAAA,EACxC,IAAI;AACJ,QAAM,SAAS,gBAAgB;AAE/B,QAAM,cAA2B;AAAA,IAC/B;AAAA,IACA,OAAO,CAAC,WAAqB,gBAAgB,MAAM,MAAM;AAAA,EAC3D;AAGA,QAAM,OAAoB;AAAA,IACxB,QAAQ;AAAA,IACR,SAAS,mBAAmB;AAAA,IAC5B;AAAA,IACA,GAAG;AAAA,EACL;AAGA,QAAM,MACH,MAAM,YAAY,KAAK,MAAM,WAAW,KACxC,MAAM,iBAAiB,KAAK,IAAI;AAGnC,SAAQ,MAAM,aAAa,KAAK,KAAK,WAAW,KAAM;AACxD;;;ACvGO,SAAS,qBACd,KACA,gBACK;AACL,QAAM,WACJ,OAAO,aAAa,cAAc,SAAS,OAAO;AAEpD,MAAI,CAAC,KAAK;AACR,WAAO,IAAI,IAAI,QAAQ;AAAA,EACzB;AAEA,SAAO,OAAO,QAAQ,WAAW,IAAI,IAAI,KAAK,QAAQ,IAAI;AAC5D;;;ACYO,SAAS,iBACd,WACkB;AAClB,SAAO;AAAA,IACL,WAAW,KAAK;AACd,gBAAU,eAAe,GAAG;AAAA,IAC9B;AAAA,IACA,KAAK,KAAK;AACR,gBAAU,SAAS,GAAG;AAAA,IACxB;AAAA,IACA,MAAM,OAAO,MAAO;A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;AACR,MAAI,CAAC,KAAK;AACR,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AACjD,QAAM,YAAY,KAAK,QAAQ,GAAG;AAClC,MAAI,YAAY,GAAG;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,KAAK,MAAM,YAAY,CAAC;AACrC,SAAO,QAAQ;AACjB;;;ACcO,SAAS,cACd,kBACA,WAC0B;AAC1B,QAAM,eAAe,YAAY,SAAS;AAC1C,SAAO,CAAC,QAAQ;AACd,UAAM,YAAY,YAAY,GAAG;AACjC,QAAI,gBAAgB,aAAa,cAAc,cAAc;AAC3D,aAAO;AAAA,IACT;AACA,WAAO,iBAAiB,WAAW,GAAG;AAAA,EACxC;AACF;AAEA,SAAS,YAAY,KAAiC;AACpD,MAAI;AACF,WAAO,IAAI,IAAI,GAAG,EAAE;AAAA,EACtB,QAAE;AACA,WAAO;AAAA,EACT;AACF;;;ACtDO,SAAS,qBACd,MACA,WACsC;AACtC,SAAO,OAAO,cAAc,MAAM,SAAS,IAAI;AACjD;","names":[]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk4MLJE6UPcjs = require('./chunk-4MLJE6UP.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7OD5S534cjs = require('./chunk-7OD5S534.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkW5FSHVWUcjs = require('./chunk-W5FSHVWU.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunk3AX5WLZDcjs = require('./chunk-3AX5WLZD.cjs');
|
|
@@ -23,7 +23,8 @@ var _chunk3AX5WLZDcjs = require('./chunk-3AX5WLZD.cjs');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
var _chunkI7VKDF3Ecjs = require('./chunk-I7VKDF3E.cjs');
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
@@ -203,12 +204,14 @@ var ORIGIN_REWRITE_TAGS = [
|
|
|
203
204
|
var ID_SUFFIX_RSC = "_rsc";
|
|
204
205
|
var ID_SUFFIX_SSR = "_ssr";
|
|
205
206
|
var ID_SUFFIX_SHARED = "_shared";
|
|
207
|
+
var ID_SUFFIX_SHARED_MANIFEST = "_shared_manifest";
|
|
206
208
|
var DATA_BUNDLE = "data-bundle";
|
|
207
209
|
var DATA_ROUTE = "data-route";
|
|
208
210
|
var DATA_RUNTIME = "data-runtime";
|
|
209
211
|
var DATA_TYPE = "data-type";
|
|
210
212
|
var DATA_SRC = "data-src";
|
|
211
213
|
var DATA_REMOTE_COMPONENTS_SHARED = "data-remote-components-shared";
|
|
214
|
+
var DATA_REMOTE_COMPONENTS_SHARED_MANIFEST = "data-remote-components-shared-manifest";
|
|
212
215
|
var TAG_REMOTE_COMPONENT = "remote-component";
|
|
213
216
|
var NEXT_DATA_ID = "__NEXT_DATA__";
|
|
214
217
|
var REMOTE_NEXT_DATA_ID = "__REMOTE_NEXT_DATA__";
|
|
@@ -285,12 +288,12 @@ function toComponentType(value) {
|
|
|
285
288
|
return value && isComponentType(value) ? value : "unknown";
|
|
286
289
|
}
|
|
287
290
|
function buildMetadata(attrs, url) {
|
|
288
|
-
const id = attrs.id ||
|
|
289
|
-
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||
|
|
291
|
+
const id = attrs.id || _chunkI7VKDF3Ecjs.DEFAULT_COMPONENT_NAME;
|
|
292
|
+
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || _chunkI7VKDF3Ecjs.DEFAULT_BUNDLE_NAME;
|
|
290
293
|
return {
|
|
291
294
|
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
292
295
|
bundle,
|
|
293
|
-
route: attrs.route || url.pathname ||
|
|
296
|
+
route: attrs.route || url.pathname || _chunkI7VKDF3Ecjs.DEFAULT_ROUTE,
|
|
294
297
|
runtime: toRuntime(attrs.runtime),
|
|
295
298
|
id,
|
|
296
299
|
type: toComponentType(attrs.type)
|
|
@@ -319,17 +322,23 @@ function resolveComponentName(component, nextData, fallbackName) {
|
|
|
319
322
|
return { name, isRemoteComponent };
|
|
320
323
|
}
|
|
321
324
|
function extractRemoteShared(doc, name, nextData) {
|
|
325
|
+
const remoteSharedManifestEl = doc.querySelector(
|
|
326
|
+
`#${name}${ID_SUFFIX_SHARED_MANIFEST}[${DATA_REMOTE_COMPONENTS_SHARED_MANIFEST}]`
|
|
327
|
+
);
|
|
322
328
|
const remoteSharedEl = doc.querySelector(
|
|
323
329
|
`#${name}${ID_SUFFIX_SHARED}[${DATA_REMOTE_COMPONENTS_SHARED}]`
|
|
324
330
|
);
|
|
325
|
-
const remoteShared = _nullishCoalesce(_optionalChain([nextData, 'optionalAccess', _28 => _28.props, 'access', _29 => _29.__REMOTE_COMPONENT__, 'optionalAccess', _30 => _30.
|
|
326
|
-
|
|
331
|
+
const remoteShared = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([nextData, 'optionalAccess', _28 => _28.props, 'access', _29 => _29.__REMOTE_COMPONENT__, 'optionalAccess', _30 => _30.sharedManifest]), () => ( (_optionalChain([remoteSharedManifestEl, 'optionalAccess', _31 => _31.textContent]) ? JSON.parse(remoteSharedManifestEl.textContent) : void 0))), () => ( // @legacy(remote-components<=0.4.x): keep reading the historical shared
|
|
332
|
+
// map until remotes on 0.4.x are outside the compatibility window.
|
|
333
|
+
_optionalChain([nextData, 'optionalAccess', _32 => _32.props, 'access', _33 => _33.__REMOTE_COMPONENT__, 'optionalAccess', _34 => _34.shared]))), () => ( (_nullishCoalesce(JSON.parse(_nullishCoalesce(_optionalChain([remoteSharedEl, 'optionalAccess', _35 => _35.textContent]), () => ( "{}"))), () => ( {})))));
|
|
334
|
+
_optionalChain([remoteSharedManifestEl, 'optionalAccess', _36 => _36.remove, 'call', _37 => _37()]);
|
|
335
|
+
_optionalChain([remoteSharedEl, 'optionalAccess', _38 => _38.remove, 'call', _39 => _39()]);
|
|
327
336
|
return remoteShared;
|
|
328
337
|
}
|
|
329
338
|
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
330
339
|
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
331
340
|
throw new (0, _chunkBBXVML3Dcjs.RemoteComponentsError)(
|
|
332
|
-
`Remote Component not found on ${url}.${name !==
|
|
341
|
+
`Remote Component not found on ${url}.${name !== _chunkI7VKDF3Ecjs.DEFAULT_COMPONENT_NAME ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
333
342
|
);
|
|
334
343
|
}
|
|
335
344
|
}
|
|
@@ -358,11 +367,11 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
358
367
|
const metadata = buildMetadata(
|
|
359
368
|
{
|
|
360
369
|
name: resolvedName,
|
|
361
|
-
bundle: _optionalChain([component, 'optionalAccess',
|
|
362
|
-
route: _nullishCoalesce(_optionalChain([component, 'optionalAccess',
|
|
363
|
-
runtime: _nullishCoalesce(_nullishCoalesce(_optionalChain([component, 'optionalAccess',
|
|
364
|
-
id: _optionalChain([component, 'optionalAccess',
|
|
365
|
-
type: _optionalChain([component, 'optionalAccess',
|
|
370
|
+
bundle: _optionalChain([component, 'optionalAccess', _40 => _40.getAttribute, 'call', _41 => _41(DATA_BUNDLE)]) || _optionalChain([nextData, 'optionalAccess', _42 => _42.props, 'access', _43 => _43.__REMOTE_COMPONENT__, 'optionalAccess', _44 => _44.bundle]),
|
|
371
|
+
route: _nullishCoalesce(_optionalChain([component, 'optionalAccess', _45 => _45.getAttribute, 'call', _46 => _46(DATA_ROUTE)]), () => ( _optionalChain([nextData, 'optionalAccess', _47 => _47.page]))),
|
|
372
|
+
runtime: _nullishCoalesce(_nullishCoalesce(_optionalChain([component, 'optionalAccess', _48 => _48.getAttribute, 'call', _49 => _49(DATA_RUNTIME)]), () => ( _optionalChain([nextData, 'optionalAccess', _50 => _50.props, 'access', _51 => _51.__REMOTE_COMPONENT__, 'optionalAccess', _52 => _52.runtime]))), () => ( _chunkI7VKDF3Ecjs.RUNTIME_SCRIPT)),
|
|
373
|
+
id: _optionalChain([component, 'optionalAccess', _53 => _53.getAttribute, 'call', _54 => _54("id")]),
|
|
374
|
+
type: _optionalChain([component, 'optionalAccess', _55 => _55.getAttribute, 'call', _56 => _56(DATA_TYPE)])
|
|
366
375
|
},
|
|
367
376
|
url
|
|
368
377
|
);
|
|
@@ -430,7 +439,7 @@ async function loadRemoteComponent({
|
|
|
430
439
|
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
431
440
|
}
|
|
432
441
|
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
433
|
-
await
|
|
442
|
+
await _chunk4MLJE6UPcjs.loadScripts.call(void 0, scripts, resolveClientUrl);
|
|
434
443
|
}
|
|
435
444
|
const hostShared = await shared;
|
|
436
445
|
_chunkBBXVML3Dcjs.logDebug.call(void 0,
|
|
@@ -445,7 +454,7 @@ async function loadRemoteComponent({
|
|
|
445
454
|
"ComponentLoader",
|
|
446
455
|
`Remote shared modules requested: ${JSON.stringify(remoteShared)}`
|
|
447
456
|
);
|
|
448
|
-
const scope = await
|
|
457
|
+
const scope = await _chunk7OD5S534cjs.setupRemoteScope.call(void 0,
|
|
449
458
|
runtime,
|
|
450
459
|
scripts,
|
|
451
460
|
url,
|
|
@@ -453,14 +462,14 @@ async function loadRemoteComponent({
|
|
|
453
462
|
resolveClientUrl
|
|
454
463
|
);
|
|
455
464
|
if (runtime === "turbopack") {
|
|
456
|
-
await
|
|
465
|
+
await _chunkW5FSHVWUcjs.initializeSharedModules.call(void 0,
|
|
457
466
|
scope,
|
|
458
|
-
|
|
467
|
+
_chunkI7VKDF3Ecjs.buildCoreShared.call(void 0, hostShared),
|
|
459
468
|
remoteShared
|
|
460
469
|
);
|
|
461
470
|
}
|
|
462
471
|
if (bundle && runtime === "webpack") {
|
|
463
|
-
const resolve = await
|
|
472
|
+
const resolve = await _chunkI7VKDF3Ecjs.buildWebpackResolve.call(void 0,
|
|
464
473
|
hostShared,
|
|
465
474
|
remoteShared,
|
|
466
475
|
bundle,
|
|
@@ -473,7 +482,7 @@ async function loadRemoteComponent({
|
|
|
473
482
|
},
|
|
474
483
|
"ComponentLoader"
|
|
475
484
|
);
|
|
476
|
-
|
|
485
|
+
_chunkW5FSHVWUcjs.applySharedModules.call(void 0, bundle, resolve);
|
|
477
486
|
} else if (bundle && runtime === "turbopack") {
|
|
478
487
|
} else {
|
|
479
488
|
_chunkBBXVML3Dcjs.logWarn.call(void 0,
|
|
@@ -515,7 +524,7 @@ async function loadRSCComponent(rscName, data) {
|
|
|
515
524
|
return { component };
|
|
516
525
|
}
|
|
517
526
|
function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
518
|
-
const { Component, App } =
|
|
527
|
+
const { Component, App } = _chunkW5FSHVWUcjs.nextClientPagesLoader.call(void 0, bundle, route, container);
|
|
519
528
|
if (!Component) {
|
|
520
529
|
throw new (0, _chunkBBXVML3Dcjs.RemoteComponentsError)(
|
|
521
530
|
`Remote Component "${name}" is trying to load the component for route "${route}" but it is not available.`
|
|
@@ -531,10 +540,9 @@ function preparePipeline(input) {
|
|
|
531
540
|
const doc = parser.parseFromString(input.html, "text/html");
|
|
532
541
|
const parsed = parseRemoteComponentDocument(doc, input.name, input.url);
|
|
533
542
|
const remoteShared = _nullishCoalesce(input.remoteShared, () => ( parsed.remoteShared));
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
);
|
|
543
|
+
const missingSharedModulesMessage = _chunkI7VKDF3Ecjs.getMissingSharedModulesMessage.call(void 0, remoteShared);
|
|
544
|
+
if (missingSharedModulesMessage) {
|
|
545
|
+
throw new (0, _chunkBBXVML3Dcjs.RemoteComponentsError)(missingSharedModulesMessage);
|
|
538
546
|
}
|
|
539
547
|
applyOriginToNodes(doc, input.url, input.resolveClientUrl);
|
|
540
548
|
const scriptDescriptors = buildScriptDescriptors(parsed.scripts, input.url);
|
|
@@ -572,12 +580,12 @@ async function loadPrepared(input) {
|
|
|
572
580
|
function buildScriptDescriptors(scripts, url) {
|
|
573
581
|
return scripts.map((script) => {
|
|
574
582
|
const scriptSrc = script.getAttribute("data-src") || script.getAttribute("src") || script.src;
|
|
575
|
-
const { prefix, id: path } = _nullishCoalesce(_optionalChain([
|
|
583
|
+
const { prefix, id: path } = _nullishCoalesce(_optionalChain([_chunkI7VKDF3Ecjs.REMOTE_COMPONENT_REGEX, 'access', _57 => _57.exec, 'call', _58 => _58(scriptSrc), 'optionalAccess', _59 => _59.groups]), () => ( {
|
|
576
584
|
prefix: void 0,
|
|
577
585
|
id: scriptSrc
|
|
578
586
|
}));
|
|
579
587
|
return {
|
|
580
|
-
src: new URL(
|
|
588
|
+
src: new URL(_chunkI7VKDF3Ecjs.collapseDoubleSlashes.call(void 0, `${_nullishCoalesce(prefix, () => ( ""))}${path}`), url).href
|
|
581
589
|
};
|
|
582
590
|
});
|
|
583
591
|
}
|
|
@@ -610,7 +618,7 @@ async function loadDynamicPath(input) {
|
|
|
610
618
|
resolveClientUrl,
|
|
611
619
|
container
|
|
612
620
|
} = input;
|
|
613
|
-
const rscName = _nullishCoalesce(input.rscName, () => ( (parsed.rsc ? `__remote_component_rsc_${
|
|
621
|
+
const rscName = _nullishCoalesce(input.rscName, () => ( (parsed.rsc ? `__remote_component_rsc_${_chunkI7VKDF3Ecjs.escapeString.call(void 0, url.href)}_${_chunkI7VKDF3Ecjs.escapeString.call(void 0, parsed.name)}` : void 0)));
|
|
614
622
|
const rscData = parsed.rsc ? (parsed.rsc.textContent || "").split("\n").filter(Boolean) : [];
|
|
615
623
|
const result = await loadRemoteComponent({
|
|
616
624
|
url,
|
|
@@ -622,7 +630,7 @@ async function loadDynamicPath(input) {
|
|
|
622
630
|
data: rscData,
|
|
623
631
|
nextData: parsed.nextData,
|
|
624
632
|
scripts: scriptDescriptors,
|
|
625
|
-
shared:
|
|
633
|
+
shared: _chunkI7VKDF3Ecjs.buildHostShared.call(void 0, shared, resolveClientUrl),
|
|
626
634
|
remoteShared: parsed.remoteShared,
|
|
627
635
|
container,
|
|
628
636
|
resolveClientUrl
|
|
@@ -701,4 +709,4 @@ function bindResolveClientUrl(prop, remoteSrc) {
|
|
|
701
709
|
|
|
702
710
|
|
|
703
711
|
exports.fetchWithHooks = fetchWithHooks; exports.getClientOrServerUrl = getClientOrServerUrl; exports.makeReactEmitter = makeReactEmitter; exports.makeEventEmitter = makeEventEmitter; exports.createRSCStream = createRSCStream; exports.preparePipeline = preparePipeline; exports.loadPrepared = loadPrepared; exports.createHostState = createHostState; exports.resolveNameFromSrc = resolveNameFromSrc; exports.bindResolveClientUrl = bindResolveClientUrl;
|
|
704
|
-
//# sourceMappingURL=chunk-
|
|
712
|
+
//# sourceMappingURL=chunk-PNASFKWA.cjs.map
|