remote-components 0.4.12 → 0.4.14
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-CLO56ON2.js → chunk-EIEIT5PG.js} +82 -4
- package/dist/chunk-EIEIT5PG.js.map +1 -0
- package/dist/{chunk-BEGVH64U.js → chunk-GG32LZD3.js} +2 -2
- package/dist/{chunk-SULMNRMJ.cjs → chunk-JKDPK6L5.cjs} +23 -23
- package/dist/{chunk-XWRB6CEA.cjs → chunk-MAVMKFFL.cjs} +3 -3
- package/dist/{chunk-RZGFQTX6.js → chunk-PNKSHWZ3.js} +8 -8
- package/dist/{chunk-HXCW3WDT.cjs → chunk-T2JJIQUJ.cjs} +25 -25
- package/dist/{chunk-TGE3K3TR.cjs → chunk-TIS6PXSQ.cjs} +18 -18
- package/dist/{chunk-YSJ4FKGI.cjs → chunk-WCZKEWRM.cjs} +97 -19
- package/dist/chunk-WCZKEWRM.cjs.map +1 -0
- package/dist/{chunk-3PR3SWYZ.js → chunk-WWHNG5YP.js} +38 -3
- package/dist/chunk-WWHNG5YP.js.map +1 -0
- package/dist/{chunk-M6ACTSVB.js → chunk-XLGLCKZZ.js} +2 -2
- package/dist/{chunk-24LEEDHP.js → chunk-YKCU7RFM.js} +3 -3
- package/dist/{chunk-6PZEDIAK.cjs → chunk-ZPJ5J24T.cjs} +47 -12
- package/dist/chunk-ZPJ5J24T.cjs.map +1 -0
- package/dist/config/nextjs.cjs +10 -10
- package/dist/config/nextjs.js +7 -7
- package/dist/config/tailwind.cjs +53 -0
- package/dist/config/tailwind.cjs.map +1 -0
- package/dist/config/tailwind.d.ts +21 -0
- package/dist/config/tailwind.js +53 -0
- package/dist/config/tailwind.js.map +1 -0
- package/dist/host/html.cjs +20 -20
- package/dist/host/html.js +8 -8
- package/dist/host/nextjs/app/client-only.cjs +21 -12
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +18 -9
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +2 -0
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +2 -0
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/nextjs/pages.cjs +14 -7
- package/dist/host/nextjs/pages.cjs.map +1 -1
- package/dist/host/nextjs/pages.d.ts +2 -0
- package/dist/host/nextjs/pages.js +14 -7
- package/dist/host/nextjs/pages.js.map +1 -1
- package/dist/host/react.cjs +8 -8
- package/dist/host/react.js +7 -7
- package/dist/internal/host/nextjs/app-client.cjs +15 -6
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.d.ts +3 -2
- package/dist/internal/host/nextjs/app-client.js +15 -6
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +1 -0
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.d.ts +1 -0
- package/dist/internal/host/nextjs/dom-flight.js +1 -0
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
- package/dist/internal/host/nextjs/image-shared.cjs +11 -2
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
- package/dist/internal/host/nextjs/image-shared.d.ts +3 -1
- package/dist/internal/host/nextjs/image-shared.js +11 -2
- package/dist/internal/host/nextjs/image-shared.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +58 -3
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.d.ts +1 -0
- package/dist/internal/host/server/fetch-remote-component.js +61 -3
- 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 +2 -0
- package/dist/internal/host/shared/next-image-deployment-id.cjs +50 -0
- package/dist/internal/host/shared/next-image-deployment-id.cjs.map +1 -0
- package/dist/internal/host/shared/next-image-deployment-id.d.ts +14 -0
- package/dist/internal/host/shared/next-image-deployment-id.js +25 -0
- package/dist/internal/host/shared/next-image-deployment-id.js.map +1 -0
- package/dist/internal/host/shared/pipeline.d.ts +2 -1
- package/dist/internal/host/shared/remote-image-loader.cjs +16 -2
- package/dist/internal/host/shared/remote-image-loader.cjs.map +1 -1
- package/dist/internal/host/shared/remote-image-loader.d.ts +2 -1
- package/dist/internal/host/shared/remote-image-loader.js +19 -2
- package/dist/internal/host/shared/remote-image-loader.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.d.ts +1 -0
- package/dist/internal/runtime/loaders/component-loader.d.ts +2 -1
- package/dist/remote/react/utils/portal.cjs +58 -0
- package/dist/remote/react/utils/portal.cjs.map +1 -0
- package/dist/remote/react/utils/portal.d.ts +12 -0
- package/dist/remote/react/utils/portal.js +58 -0
- package/dist/remote/react/utils/portal.js.map +1 -0
- package/dist/{server-handoff-9e905049.d.ts → server-handoff-006f9cb5.d.ts} +2 -0
- package/dist/{turbopack-43N2UJNN.js → turbopack-HK7DVYUG.js} +4 -4
- package/dist/{turbopack-5VGMYUL4.cjs → turbopack-YZOIO55D.cjs} +11 -11
- package/dist/{webpack-LXE2UWTA.js → webpack-2HP73JL7.js} +4 -4
- package/dist/{webpack-FSN5UBA2.cjs → webpack-W2MODB73.cjs} +11 -11
- package/package.json +18 -1
- package/dist/chunk-3PR3SWYZ.js.map +0 -1
- package/dist/chunk-6PZEDIAK.cjs.map +0 -1
- package/dist/chunk-CLO56ON2.js.map +0 -1
- package/dist/chunk-YSJ4FKGI.cjs.map +0 -1
- /package/dist/{chunk-BEGVH64U.js.map → chunk-GG32LZD3.js.map} +0 -0
- /package/dist/{chunk-SULMNRMJ.cjs.map → chunk-JKDPK6L5.cjs.map} +0 -0
- /package/dist/{chunk-XWRB6CEA.cjs.map → chunk-MAVMKFFL.cjs.map} +0 -0
- /package/dist/{chunk-RZGFQTX6.js.map → chunk-PNKSHWZ3.js.map} +0 -0
- /package/dist/{chunk-HXCW3WDT.cjs.map → chunk-T2JJIQUJ.cjs.map} +0 -0
- /package/dist/{chunk-TGE3K3TR.cjs.map → chunk-TIS6PXSQ.cjs.map} +0 -0
- /package/dist/{chunk-M6ACTSVB.js.map → chunk-XLGLCKZZ.js.map} +0 -0
- /package/dist/{chunk-24LEEDHP.js.map → chunk-YKCU7RFM.js.map} +0 -0
- /package/dist/{turbopack-43N2UJNN.js.map → turbopack-HK7DVYUG.js.map} +0 -0
- /package/dist/{turbopack-5VGMYUL4.cjs.map → turbopack-YZOIO55D.cjs.map} +0 -0
- /package/dist/{webpack-LXE2UWTA.js.map → webpack-2HP73JL7.js.map} +0 -0
- /package/dist/{webpack-FSN5UBA2.cjs.map → webpack-W2MODB73.cjs.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/react/index.tsx","../src/runtime/html/set-attributes-from-props.ts","../src/host/react/hooks/use-resolve-client-url.ts","../src/host/react/hooks/use-shadow-root.ts","../src/host/react/utils/extract-remote-html.ts","../src/host/react/hooks/use-remote-navigate.ts"],"names":["useEffect","useLayoutEffect","useMemo","useRef","useState","useRemoteComponentsContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA,mBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,OACK;AACP,SAAS,cAAc,eAAe;AACtC,SAAS,8BAAAC,mCAAkC;;;ACR3C,IAAM,oBAA4C;AAAA,EAChD,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,UAAU;AACZ;AAEA,IAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,yBACP,MACwC;AACxC,SAAO,CAAC,SAAS,SAAS,UAAU,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Ac;AAAA,UACxC,IAAI,cAAc,MAAM,QAAQ;AAAA,UAChC,KAAK;AAAA,UACL,OAAO,gBAAgB,EAAE,SAAS,OAAO,IAAI;AAAA,UAE5C;AAAA,mBAAO,aAAa;AAAA;AAAA,cAEnB,qBAAC,cAAS,gBAAgB,MACvB;AAAA,uBAAO,aAAa,cACnB;AAAA,kBAAC;AAAA;AAAA,oBACC,yBAAyB;AAAA,sBACvB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oDAOwB;AAAA;AAAA;AAAA;AAAA,oBAIlC;AAAA;AAAA,gBACF,IACE;AAAA,gBACH;AAAA,gBACA;AAAA,gBACA;AAAA,iBACH;AAAA,gBACE;AAAA,YACH,cAAc,kBACX;AAAA,cACE,iCACE;AAAA,oCAAC,cAAS,IAAI,GAAG,cAAc;AAAA,gBAC9B;AAAA,gBACA;AAAA,gBACA;AAAA,gBACD,oBAAC,cAAS,IAAI,GAAG,YAAY,KAAK,gBAAgB;AAAA,iBACpD;AAAA,cACA;AAAA,YACF,IACA;AAAA;AAAA;AAAA,MACN;AAAA,OACF;AAAA,EAEJ;AACA,UAAQ,UAAU;AAGlB,SACE,iCACE;AAAA,wBAAC,cAAS,IAAI,GAAG,cAAc;AAAA,IAC9B;AAAA,IACA;AAAA,IACD,oBAAC,cAAS,IAAI,GAAG,YAAY,KAAK,gBAAgB;AAAA,KACpD;AAEJ","sourcesContent":["import {\n startTransition,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal, preload } from 'react-dom';\nimport { useRemoteComponentsContext } from '#internal/host/react/context';\nimport { fetchWithHooks } from '#internal/host/server/fetch-with-hooks';\nimport { getClientOrServerUrl } from '#internal/host/server/get-client-or-server-url';\nimport type { ConsumeRemoteComponentConfig } from '#internal/host/shared/config';\nimport { makeReactEmitter } from '#internal/host/shared/lifecycle';\nimport { loadPrepared, preparePipeline } from '#internal/host/shared/pipeline';\nimport type { ConsumeServerData } from '#internal/host/shared/server-handoff';\nimport { createHostState } from '#internal/host/shared/state';\nimport { resolveNameFromSrc } from '#internal/host/utils/resolve-name-from-src';\nimport {\n DEFAULT_COMPONENT_NAME,\n DEFAULT_ROUTE,\n RUNTIME_SCRIPT,\n RUNTIME_WEBPACK,\n} from '#internal/runtime/constants';\nimport { setAttributesFromProps } from '#internal/runtime/html/set-attributes-from-props';\nimport { loadStaticRemoteComponent } from '#internal/runtime/loaders/static-loader';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { attrToProp, escapeString } from '#internal/utils';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n errorFromFailedFetch,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport type { MountOrUnmountFunction } from '#remote-components/runtime/types';\nimport { useResolveClientUrl } from './hooks/use-resolve-client-url';\nimport { useShadowRoot } from './hooks/use-shadow-root';\nimport {\n DUMMY_FALLBACK,\n getRemoteComponentHtml,\n} from './utils/extract-remote-html';\n\n/**\n * Props for the React remote component host.\n *\n * Extends {@link ConsumeRemoteComponentConfig} with `children` for loading\n * fallback content.\n *\n * To react to navigations originating from embedded remote components, set up\n * a single top-level subscription with `onRemoteNavigate` from\n * `remote-components/host/navigation` and route the event to your host's\n * router.\n */\nexport interface ConsumeRemoteComponentProps\n extends ConsumeRemoteComponentConfig {\n /** Loading fallback content displayed while the remote component is being fetched. */\n children?: React.ReactNode;\n}\n\n/**\n * ConsumeRemoteComponent is a React component that fetches and renders a remote component.\n * It supports SSR and can isolate the remote component in a shadow DOM.\n *\n * @param props - The properties for the remote component.\n * @returns A React component that renders the remote component.\n *\n * @example\n *\n * Use the `<ConsumeRemoteComponent>` in your React application to consume a remote component from a remote application:\n *\n * ```tsx\n * import { ConsumeRemoteComponent } from 'remote-components/host/react';\n *\n * export default function App() {\n * return (\n * <>\n * <h1>Welcome to My App</h1>\n * <p>This page consumes a remote component from another application.</p>\n * <ConsumeRemoteComponent src=\"/nextjs-app-remote/components/header\" />\n * </>\n * );\n * }\n * ```\n *\n * To share modules, you can provide a shared module map with references to the shared modules:\n *\n * ```tsx\n * <ConsumeRemoteComponent\n * src=\"/nextjs-app-remote/components/header\"\n * shared={{\n * '@/components/provider': () => import('@/components/host-provider')\n * }}\n * />\n * ```\n */\nexport function ConsumeRemoteComponent({\n src,\n isolate,\n mode = 'open',\n reset,\n credentials: credentialsProp,\n name: nameProp = DEFAULT_COMPONENT_NAME,\n shared: sharedProp,\n children,\n onBeforeLoad,\n onLoad,\n onError,\n onChange,\n onRequest,\n onResponse,\n resolveClientUrl: resolveClientUrlProp,\n}: ConsumeRemoteComponentProps) {\n const instanceId = useId();\n\n const { credentials: contextCredentials, shared: contextShared } =\n useRemoteComponentsContext();\n const credentials = credentialsProp ?? contextCredentials ?? 'same-origin';\n const shared = sharedProp ?? contextShared ?? {};\n const emitter = useMemo(\n () => makeReactEmitter({ onBeforeLoad, onLoad, onError, onChange }),\n [onBeforeLoad, onLoad, onError, onChange],\n );\n\n const name = useMemo(\n () => resolveNameFromSrc(src, nameProp),\n [src, nameProp],\n );\n\n const [data, setData] = useState<Omit<ConsumeServerData, 'children'> | null>(\n null,\n );\n\n const url = useMemo(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);\n\n const resolveClientUrl = useResolveClientUrl(resolveClientUrlProp, url.href);\n\n // for relative src paths, use just the pathname as the unique id.\n // for static urls, use the full url as the unique id as the path may not be unique.\n // this id needs to be the same for server and client side rendering.\n // note that if this needs to be more unique, can pass through the bundle as an id prop and ammend it to this id.\n const id =\n url.origin ===\n (typeof location !== 'undefined' ? location.origin : DUMMY_FALLBACK)\n ? url.pathname\n : url.href;\n\n //instanceId prevents multiple components with the same src from sharing a shadow root\n const keySuffix = `${escapeString(id)}_${escapeString(\n data?.name ?? name,\n )}_${escapeString(instanceId)}`;\n\n const [remoteComponent, setRemoteComponent] = useState<\n React.ReactNode | Error\n >(null);\n\n const { shadowRoot, shadowRootContainerRef } = useShadowRoot({\n isolate,\n mode,\n keySuffix,\n });\n\n const htmlRef = useRef<string | null>(\n typeof document !== 'undefined'\n ? (document.querySelector(\n `[data-remote-component-id=\"shadowroot_${keySuffix}\"]`,\n )?.shadowRoot?.innerHTML ??\n document.getElementById(`__REMOTE_COMPONENT${name}`)?.innerHTML ??\n document.querySelector(`div[data-bundle][data-route][id^=\"${name}\"]`)\n ?.innerHTML ??\n document.querySelector('div[data-bundle][data-route]')?.innerHTML)\n : null,\n );\n // True when the shadow root already had SSR/declarative-shadow-DOM content at\n // mount — its styles are already present, so the FOUC-hiding below stays off.\n const initialSsrContentRef = useRef(htmlRef.current != null);\n\n // False until the remote's forwarded stylesheets load. A client-only shadow\n // root has no SSR style baseline, so the component would paint unstyled (FOUC)\n // before its `<link>`s load; we hide the host and show the `children`\n // placeholder until then. Starts \"not ready\" for client isolated loads so the\n // placeholder covers the whole fetch + style load, from first paint.\n const [stylesReady, setStylesReady] = useState(\n () =>\n !(\n typeof document !== 'undefined' &&\n isolate !== false &&\n Boolean(src) &&\n !initialSsrContentRef.current\n ),\n );\n\n const endTemplateRef = useRef<HTMLTemplateElement | null>(null);\n // collect initial content that needs to be removed after remote component renders\n const childrenRef = useRef(\n typeof document !== 'undefined'\n ? (() => {\n let el = document.querySelector(`template[id=\"${name}_start\"]`);\n const elements = [];\n while (el && el.id !== `${name}_end`) {\n if (\n el.id !== `${name}_start` &&\n !el.getAttribute('data-remote-component')\n ) {\n elements.push(el);\n }\n el = el.nextElementSibling as HTMLTemplateElement | null;\n }\n return elements;\n })()\n : [],\n );\n const hostStateRef = useRef(createHostState());\n const componentHydrationHtml = useRef<string | null>(null);\n const prevRemoteComponentContainerRef = useRef<HTMLDivElement | null>(null);\n const unmountRef = useRef<Set<MountOrUnmountFunction> | null>(null);\n\n // Clean up the shadow root cache on unmount to prevent memory leaks\n useLayoutEffect(() => {\n return () => {\n delete getNamespace().shadowRoots[keySuffix];\n };\n }, [keySuffix]);\n\n useLayoutEffect(() => {\n // Clear initial content after remote component renders\n if (childrenRef.current.length > 0 && remoteComponent) {\n childrenRef.current.forEach((el) => {\n el.remove();\n });\n childrenRef.current = [];\n }\n }, [remoteComponent]);\n\n useLayoutEffect(() => {\n if (shadowRoot && remoteComponent) {\n const resetStyles = shadowRoot.querySelectorAll(\n 'style[data-remote-components-reset]',\n );\n // ensure we only have one reset style in the shadow root\n if (resetStyles.length > 1) {\n resetStyles.forEach((style, index) => {\n if (\n index > 0 &&\n style.getAttribute('data-remote-components-reset') !== 'react'\n ) {\n style.remove();\n }\n });\n }\n\n // clear the html ref after hydration\n htmlRef.current = null;\n\n // clear all nodes except links and styles until the start marker\n // the marker gets only rendered on hydration\n let el: ChildNode | null = shadowRoot.childNodes[0] ?? null;\n while (el && (!('id' in el) || el.id !== `${name}_start`)) {\n const nextEl = el.nextSibling;\n if (el.nodeName !== 'LINK' && el.nodeName !== 'STYLE') {\n el.parentNode?.removeChild(el);\n }\n el = nextEl;\n }\n }\n }, [shadowRoot, remoteComponent, name]);\n\n // Reveal the hidden host once the remote's stylesheets are loaded. This reads\n // each `<link>`'s actual state rather than relying solely on `onLoad`, because\n // a `load` event does NOT fire for a stylesheet the browser already has cached\n // (e.g. on back-navigation, which reuses the same `<link>`) — so an onLoad-only\n // gate would stay hidden forever. An already-loaded link has a non-null\n // `.sheet`; for the rest we wait for `load`/`error` (error too, so a failed\n // sheet can't pin the host hidden). Runs whenever a load produces new `data`.\n useLayoutEffect(() => {\n const currentSrc = src ? (typeof src === 'string' ? src : src.href) : null;\n if (\n stylesReady ||\n initialSsrContentRef.current ||\n !shadowRoot ||\n !data ||\n data.src !== currentSrc\n ) {\n return;\n }\n const expectedStylesheets = (data.links ?? []).filter(\n (link) => link.rel === 'stylesheet',\n );\n if (expectedStylesheets.length === 0) {\n setStylesReady(true);\n return;\n }\n const expectedHrefs = new Set(\n expectedStylesheets.map((link) => new URL(link.href as string, url).href),\n );\n const links = Array.from(\n shadowRoot.querySelectorAll<HTMLLinkElement>('link[rel=\"stylesheet\"]'),\n ).filter((link) => expectedHrefs.has(link.href));\n // The expected links may not have been portaled into the shadow root yet.\n if (links.length < expectedHrefs.size) {\n return;\n }\n // Defensive: if the expected set collapsed to nothing, reveal rather than\n // risk pinning the host hidden.\n if (links.length === 0) {\n setStylesReady(true);\n return;\n }\n let pending = links.length;\n let settled = false;\n const onSettled = () => {\n pending -= 1;\n if (!settled && pending <= 0) {\n settled = true;\n setStylesReady(true);\n }\n };\n const cleanups = links.map((link) => {\n if (link.sheet) {\n onSettled();\n return () => {};\n }\n link.addEventListener('load', onSettled, { once: true });\n link.addEventListener('error', onSettled, { once: true });\n return () => {\n link.removeEventListener('load', onSettled);\n link.removeEventListener('error', onSettled);\n };\n });\n return () => {\n for (const cleanup of cleanups) {\n cleanup();\n }\n };\n }, [shadowRoot, data, stylesReady, src, url]);\n\n useEffect(() => {\n if (src && src !== hostStateRef.current.prevSrc) {\n const previousSrc = hostStateRef.current.prevSrc;\n const previousName = hostStateRef.current.prevName;\n hostStateRef.current.prevSrc = src;\n\n if (previousSrc !== null) {\n htmlRef.current = null;\n }\n\n // Abort any in-progress load so the latest src always wins.\n hostStateRef.current.abortController?.abort();\n hostStateRef.current.abortController = new AbortController();\n const { signal } = hostStateRef.current.abortController;\n\n emitter.beforeLoad(src);\n hostStateRef.current.stage = 'loading';\n\n // Re-show the placeholder for the whole of this load on client isolated renders.\n if (isolate !== false && !initialSsrContentRef.current) {\n setStylesReady(false);\n }\n\n startTransition(async () => {\n try {\n let html = getRemoteComponentHtml(\n htmlRef.current ??\n (endTemplateRef.current?.previousElementSibling?.tagName === 'div'\n ? endTemplateRef.current.previousElementSibling.innerHTML\n : ''),\n );\n\n if (!html && src) {\n // fetch the remote component\n const fetchInit = {\n credentials,\n } as RequestInit;\n\n const resolvedUrl = new URL(\n resolveClientUrl?.(url.href) ?? url.href,\n location.href,\n );\n const res = await fetchWithHooks(resolvedUrl, fetchInit, {\n onRequest,\n onResponse,\n abortController: hostStateRef.current.abortController,\n });\n\n if (!res || !res.ok) {\n throw await errorFromFailedFetch(url.href, resolvedUrl, res);\n }\n\n // get the full HTML content as a string\n const remoteHtml = await res.text();\n if (signal.aborted) return;\n htmlRef.current = remoteHtml;\n html = getRemoteComponentHtml(remoteHtml);\n }\n\n if (signal.aborted) return;\n\n const userShared = await shared;\n if (signal.aborted) return;\n\n const prepared = preparePipeline({\n html,\n name,\n url,\n shared: userShared,\n resolveClientUrl,\n });\n const { doc, parsed } = prepared;\n const {\n component,\n name: remoteName,\n isRemoteComponent,\n metadata,\n rsc,\n remoteShared,\n links: linkElements,\n } = parsed;\n\n if (hostStateRef.current.prevIsRemoteComponent) {\n if (shadowRoot) {\n shadowRoot.innerHTML = '';\n }\n const prevUrl = hostStateRef.current.prevUrl;\n if (prevUrl && getNamespace().unmountFns[prevUrl.href]) {\n const unmountPromises = Promise.all(\n Array.from(unmountRef.current ?? []).map(async (unmount) =>\n unmount(\n shadowRoot ?? prevRemoteComponentContainerRef.current,\n ),\n ),\n );\n unmountRef.current = null;\n await unmountPromises;\n }\n }\n hostStateRef.current.prevIsRemoteComponent = isRemoteComponent;\n hostStateRef.current.prevUrl = url;\n hostStateRef.current.prevName = remoteName;\n\n const links = linkElements.map((link) => ({\n href: new URL(link.getAttribute('href') ?? link.href, url).href,\n ...link\n .getAttributeNames()\n .reduce<Record<string, string>>((acc, key) => {\n if (key !== 'href') {\n acc[attrToProp[key] ?? key] = link.getAttribute(key) ?? '';\n }\n return acc;\n }, {}),\n }));\n\n const stylesheetLinks = Array.from(linkElements).filter(\n (link) => link.getAttribute('rel') === 'stylesheet',\n );\n\n // Preload the stylesheets now, before the remote's scripts are fetched\n // and evaluated below. The CSS download then overlaps that (much\n // larger) work instead of starting only when the shadow `<link>`s\n // render — so the reveal isn't waiting on CSS queued behind the JS.\n // The browser matches each preload to the later shadow `<link>` by\n // URL, so there's no double fetch. Matches the Next App Router host.\n if (typeof preload === 'function') {\n for (const link of stylesheetLinks) {\n preload(\n new URL(link.getAttribute('href') ?? link.href, url).href,\n {\n as: 'style',\n fetchPriority: 'high',\n },\n );\n }\n }\n\n // handle inline scripts in the remote component\n const inlineScripts = (\n isRemoteComponent ? component : doc\n ).querySelectorAll(\n \"script:not([src]):not([data-src]):not([id*='_rsc']):not([id='__NEXT_DATA__']):not([id='__REMOTE_NEXT_DATA__'])\",\n );\n\n if (!isRemoteComponent) {\n // Next.js Script support\n const self = globalThis as typeof globalThis & {\n __next_s: [string, Record<string, string>][];\n };\n const prevNextScripts = self.__next_s;\n const nextScripts = [] as [string, Record<string, string>][];\n // eslint-disable-next-line camelcase\n self.__next_s = nextScripts;\n\n // TODO: needs to be cancellable with a singular listener for the abort signal https://linear.app/vercel/issue/MFES-1253/handle-abortcontroller-clean-up-scenarios\n await Promise.all(\n Array.from(inlineScripts)\n .filter(\n (script) =>\n !(\n script.id.endsWith('_shared') &&\n script.getAttribute('type') === 'application/json' &&\n typeof script.getAttribute(\n 'data-remote-components-shared',\n ) === 'string'\n ),\n )\n .map((script) => {\n return new Promise((resolve) => {\n // only handle inline scripts with content, but not Next.js RSC scripts\n if (\n script.textContent &&\n !script.textContent.includes('self.__next_f=') &&\n !script.textContent.includes('self.__next_f.push')\n ) {\n // if script is inline javascript, then execute using blob\n if (\n !script.getAttribute('type') ||\n script.getAttribute('type') === 'text/javascript' ||\n script.getAttribute('type') === 'application/javascript'\n ) {\n const newScript = document.createElement('script');\n\n // scripts loaded from external sources needs this workaround\n const blob = new Blob([script.textContent], {\n type: 'application/javascript',\n });\n const blobUrl = URL.createObjectURL(blob);\n\n newScript.onload = () => {\n resolve(undefined);\n // script executed and safe to remove\n URL.revokeObjectURL(blobUrl);\n newScript.remove();\n };\n // on error we still want to resolve to not block the remote component loading\n newScript.onerror = () => {\n URL.revokeObjectURL(blobUrl);\n newScript.remove();\n resolve(undefined);\n };\n\n newScript.src = blobUrl;\n // TODO: needs to be cancellable https://linear.app/vercel/issue/MFES-1253/handle-abortcontroller-clean-up-scenarios\n document.body.appendChild(newScript);\n } else {\n resolve(undefined);\n document.body.appendChild(script);\n }\n } else {\n resolve(undefined);\n }\n });\n }),\n );\n // process the remote component Next.js Script container\n nextScripts.forEach(([scriptSrc, props]) => {\n const script = document.createElement('script');\n // when we have a script src, apply it (inline scripts have `0` as src)\n if (scriptSrc) {\n script.src = scriptSrc;\n }\n // apply Script props\n if (typeof props.children === 'string') {\n script.textContent = props.children;\n }\n setAttributesFromProps(script, props);\n document.head.appendChild(script);\n });\n // restore previous Next.js Script container\n // eslint-disable-next-line camelcase\n self.__next_s = prevNextScripts;\n }\n\n const rscName = rsc\n ? `__remote_component_rsc_${escapeString(id)}_${escapeString(\n remoteName,\n )}`\n : undefined;\n if (rsc) {\n rsc.textContent =\n rsc.textContent?.replace(\n new RegExp(`self\\\\[\"${remoteName}\"\\\\]`, 'g'),\n `self[\"${rscName}\"]`,\n ) ?? '';\n document.body.appendChild(rsc);\n }\n\n const newData = {\n ...metadata,\n links,\n remoteShared,\n src: typeof src === 'string' ? src : src.href,\n serverUrl: url.href,\n data: rsc\n ? (rsc.textContent || '').split('\\n').filter(Boolean)\n : [],\n };\n\n componentHydrationHtml.current = `${Array.from(\n doc.querySelectorAll('link,style'),\n )\n .map((link) => link.outerHTML)\n .join('')}${\n reset\n ? `<style data-remote-components-reset=\"\">:host { all: initial; }</style>`\n : ''\n }${component.innerHTML}`;\n\n if (isRemoteComponent) {\n // Only call onChange when not on first load (matching HTML implementation)\n if (previousSrc !== undefined) {\n emitter.change({\n previousSrc: previousSrc ?? null,\n nextSrc: src,\n previousName,\n nextName: remoteName,\n });\n }\n setData(newData);\n if (shadowRoot) {\n const shadowRootHtml = reset\n ? `<style data-remote-components-reset=\"\">:host { all: initial; }</style>${component.innerHTML}`\n : component.innerHTML;\n shadowRoot.innerHTML = shadowRootHtml;\n htmlRef.current = null;\n setRemoteComponent(null);\n const { mount, unmount } = await loadStaticRemoteComponent(\n Array.from(shadowRoot.querySelectorAll('script')),\n url,\n resolveClientUrl,\n );\n unmountRef.current = unmount;\n await Promise.all(\n Array.from(mount).map((mountFn) => mountFn(shadowRoot)),\n );\n emitter.load(src);\n } else if (isolate === false) {\n setRemoteComponent(\n // TODO: remove wrapper div by converting HTML to RSC or React tree\n <div\n dangerouslySetInnerHTML={{ __html: component.innerHTML }}\n ref={prevRemoteComponentContainerRef}\n />,\n );\n htmlRef.current = null;\n const { mount, unmount } = await loadStaticRemoteComponent(\n Array.from(component.querySelectorAll('script')),\n url,\n resolveClientUrl,\n );\n unmountRef.current = unmount;\n await Promise.all(\n Array.from(mount).map((mountFn) =>\n mountFn(prevRemoteComponentContainerRef.current),\n ),\n );\n emitter.load(src);\n }\n // Static remotes inject styles directly (no portal links → `onLoad`\n // never fires), so reveal now; the gate only covers the dynamic path.\n setStylesReady(true);\n hostStateRef.current.stage = 'loaded';\n } else {\n const result = await loadPrepared({\n prepared,\n url,\n signal,\n shared: userShared,\n resolveClientUrl,\n container: shadowRoot,\n rscName,\n });\n if (rsc) {\n rsc.remove();\n }\n\n setData(newData);\n // Only call onChange when not on first load (matching HTML implementation)\n if (previousSrc !== undefined) {\n emitter.change({\n previousSrc: previousSrc ?? null,\n nextSrc: src,\n previousName,\n nextName: remoteName,\n });\n }\n if (result.status === 'aborted') {\n return;\n }\n if (result.status === 'error') {\n hostStateRef.current.stage = 'error';\n setRemoteComponent(result.error);\n emitter.error(result.error);\n } else if (result.status === 'loaded') {\n hostStateRef.current.stage = 'loaded';\n setRemoteComponent(result.component);\n emitter.load(src);\n }\n }\n } catch (error) {\n // AbortError is expected when loading is cancelled - exit cleanly\n if (isAbortError(error)) {\n hostStateRef.current.stage = 'idle';\n return;\n }\n hostStateRef.current.stage = 'error';\n setRemoteComponent(error as Error);\n emitter.error(error);\n }\n });\n }\n }, [\n url,\n src,\n isolate,\n credentials,\n name,\n shared,\n shadowRoot,\n reset,\n id,\n emitter.beforeLoad,\n emitter.load,\n emitter.error,\n emitter.change,\n onRequest,\n onResponse,\n resolveClientUrl,\n ]);\n\n if (remoteComponent instanceof Error) {\n throw remoteComponent;\n }\n\n const metadataJson = (\n <script data-remote-component type=\"application/json\">\n {JSON.stringify({\n name: data?.name || name,\n bundle: data?.bundle || 'default',\n route: data?.route || DEFAULT_ROUTE,\n runtime: hostStateRef.current.prevIsRemoteComponent\n ? RUNTIME_SCRIPT\n : data?.runtime || RUNTIME_WEBPACK,\n })}\n </script>\n );\n const resetStyle = reset ? (\n <style data-remote-components-reset=\"react\">{`:host { all: initial; }`}</style>\n ) : null;\n const linksToRender: React.ReactNode[] | null =\n data?.links?.map((link) => (\n <link\n {...link}\n href={new URL(link.href as string, url).href}\n key={JSON.stringify(link)}\n />\n )) || null;\n const componentToRender = (\n <>\n {resetStyle}\n {linksToRender}\n {remoteComponent ?? children}\n </>\n );\n\n if (componentHydrationHtml.current && shadowRoot && !shadowRoot.innerHTML) {\n shadowRoot.innerHTML = componentHydrationHtml.current;\n componentHydrationHtml.current = null;\n\n if (hostStateRef.current.prevIsRemoteComponent) {\n // ensure we load static resources when hydrating a remote component in shadow DOM\n loadStaticRemoteComponent(\n Array.from(shadowRoot.querySelectorAll('script')),\n url,\n resolveClientUrl,\n )\n .then(({ mount }) => {\n return Promise.all(\n Array.from(mount).map((mountFn) => mountFn(shadowRoot)),\n );\n })\n .then(() => {\n if (src) {\n emitter.load(src);\n }\n })\n .catch((e) => {\n const error = new RemoteComponentsError(\n `Error mounting remote component from \"${url.href}\"`,\n {\n cause: e,\n },\n );\n setRemoteComponent(error);\n emitter.error(error);\n });\n }\n }\n\n if (isolate !== false) {\n const shadowRemoteComponentHtml =\n shadowRoot?.querySelector(`#__REMOTE_COMPONENT${name}`) ??\n shadowRoot?.querySelector('div[data-bundle][data-route]');\n if (shadowRemoteComponentHtml) {\n shadowRemoteComponentHtml.remove();\n }\n\n // While stylesheets are pending, `display: none` the shadow host (its\n // `<link>`s still load, so `onLoad` fires) and render the `children`\n // placeholder in the light DOM, where the host page styles it.\n const hideForStyles = !initialSsrContentRef.current && !stylesReady;\n\n return (\n <>\n {metadataJson}\n {hideForStyles ? children : null}\n <div\n data-remote-component-id={`shadowroot_${keySuffix}`}\n id={`shadowroot_${data?.name ?? name}`}\n ref={shadowRootContainerRef}\n style={hideForStyles ? { display: 'none' } : undefined}\n >\n {typeof document === 'undefined' ? (\n // eslint-disable-next-line react/no-unknown-property\n <template shadowrootmode={mode}>\n {typeof document === 'undefined' ? (\n <div\n dangerouslySetInnerHTML={{\n __html: `<img\n alt=\"\" decoding=\"async\" style=\"display:none\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==\"\n onload=\"(function(el){\n // Capture the shadow root during SSR hydration so the client-side\n // useShadowRoot hook can find it.\n const root = el.getRootNode();\n globalThis.__remote_components_shadowroot_${keySuffix}=root;\n el.parentElement.remove();\n })(this)\"\n />`,\n }}\n />\n ) : null}\n {resetStyle}\n {linksToRender}\n {children}\n </template>\n ) : null}\n {shadowRoot && remoteComponent\n ? createPortal(\n <>\n <template id={`${name}_start`} />\n {resetStyle}\n {linksToRender}\n {remoteComponent}\n <template id={`${name}_end`} ref={endTemplateRef} />\n </>,\n shadowRoot,\n )\n : null}\n </div>\n </>\n );\n }\n htmlRef.current = null;\n\n // render start/end markers for the remote component\n return (\n <>\n <template id={`${name}_start`} />\n {metadataJson}\n {componentToRender}\n <template id={`${name}_end`} ref={endTemplateRef} />\n </>\n );\n}\n\nexport type {\n HookOptions,\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nexport type { RemoteNavigateEvent } from '#internal/host/shared/navigate-event';\nexport { useRemoteNavigate } from './hooks/use-remote-navigate';\n","// extracted from Next.js source at https://github.com/vercel/next.js/blob/canary/packages/next/src/client/set-attributes-from-props.ts\n\nconst DOMAttributeNames: Record<string, string> = {\n acceptCharset: 'accept-charset',\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n noModule: 'noModule',\n};\n\nconst ignoreProps = [\n 'onLoad',\n 'onReady',\n 'dangerouslySetInnerHTML',\n 'children',\n 'onError',\n 'strategy',\n 'stylesheets',\n];\n\nfunction isBooleanScriptAttribute(\n attr: string,\n): attr is 'async' | 'defer' | 'noModule' {\n return ['async', 'defer', 'noModule'].includes(attr);\n}\n\nexport function setAttributesFromProps(el: HTMLElement, props: object) {\n for (const [p, value] of Object.entries(props)) {\n if (!Object.hasOwn(props, p)) continue;\n if (ignoreProps.includes(p)) continue;\n\n // we don't render undefined props to the DOM\n if (value === undefined) {\n continue;\n }\n\n const attr = DOMAttributeNames[p] || p.toLowerCase();\n\n if (el.tagName === 'SCRIPT' && isBooleanScriptAttribute(attr)) {\n // Correctly assign boolean script attributes\n // https://github.com/vercel/next.js/pull/20748\n (el as HTMLScriptElement)[attr] = Boolean(value);\n } else {\n el.setAttribute(attr, String(value));\n }\n\n // Remove falsy non-zero boolean attributes so they are correctly interpreted\n // (e.g. if we set them to false, this coerces to the string \"false\", which the browser interprets as true)\n if (\n value === false ||\n (el.tagName === 'SCRIPT' &&\n isBooleanScriptAttribute(attr) &&\n (!value || value === 'false'))\n ) {\n // Call setAttribute before, as we need to set and unset the attribute to override force async:\n // https://html.spec.whatwg.org/multipage/scripting.html#script-force-async\n el.setAttribute(attr, '');\n el.removeAttribute(attr);\n }\n }\n}\n","import { useMemo } from 'react';\nimport { useRemoteComponentsContext } from '#internal/host/react/context';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\nexport function useResolveClientUrl(\n prop: ResolveClientUrl | undefined,\n urlHref: string,\n) {\n const { resolveClientUrl: contextValue } = useRemoteComponentsContext();\n const raw = prop ?? contextValue;\n return useMemo(() => bindResolveClientUrl(raw, urlHref), [raw, urlHref]);\n}\n","import { useLayoutEffect, useRef, useState } from 'react';\nimport { getNamespace } from '#internal/runtime/namespace';\n\ninterface UseShadowRootOptions {\n /** Whether CSS isolation is enabled */\n isolate: boolean | undefined;\n /** Shadow DOM mode */\n mode: 'open' | 'closed';\n /** Unique key suffix for identifying this shadow root */\n keySuffix: string;\n}\n\ninterface UseShadowRootResult {\n /** The shadow root element, or null if not isolated */\n shadowRoot: ShadowRoot | null;\n /** Ref to attach to the shadow host container element */\n shadowRootContainerRef: React.RefObject<HTMLDivElement | null>;\n}\n\n/**\n * Manages shadow root lifecycle for CSS isolation.\n *\n * Handles:\n * - Initial shadow root discovery from SSR or declarative shadow DOM\n * - Creating shadow root as fallback for browsers without declarative shadow DOM support\n * - Cleanup when isolation is disabled\n * - Re-attachment when isolation is re-enabled\n */\nexport function useShadowRoot({\n isolate,\n mode,\n keySuffix,\n}: UseShadowRootOptions): UseShadowRootResult {\n const shadowRootContainerRef = useRef<HTMLDivElement | null>(null);\n\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(() => {\n const shadowRoots = getNamespace().shadowRoots;\n const ssrShadowRoot =\n typeof document !== 'undefined'\n ? (document.querySelector(\n `[data-remote-component-id=\"shadowroot_${keySuffix}\"]`,\n )?.shadowRoot ??\n shadowRoots[keySuffix] ??\n null)\n : null;\n // Clear the reference after reading it\n shadowRoots[keySuffix] = null;\n return ssrShadowRoot;\n });\n\n useLayoutEffect(() => {\n const shadowRoots = getNamespace().shadowRoots;\n if (\n isolate !== false &&\n typeof document !== 'undefined' &&\n (!shadowRoot || !shadowRoot.isConnected)\n ) {\n let shadowRootElement: ShadowRoot | null = null;\n const element = document.querySelector(\n `[data-remote-component-id=\"shadowroot_${keySuffix}\"]`,\n );\n shadowRootElement = shadowRoots[keySuffix] ?? element?.shadowRoot ?? null;\n\n if (!shadowRootElement && element) {\n // Create a shadow root if it doesn't exist.\n // This is a fallback for browsers that don't support declarative shadow DOM.\n try {\n shadowRootElement = element.attachShadow({ mode });\n shadowRoots[keySuffix] = shadowRootElement;\n } catch {\n // Do nothing if attachShadow fails because of existing shadow root\n }\n }\n\n if (shadowRootElement) {\n // Remove all nodes from the shadow root except links (preserves stylesheets)\n shadowRootElement.querySelectorAll('*:not(link)').forEach((node) => {\n node.remove();\n });\n setShadowRoot(shadowRootElement);\n }\n } else if (isolate === false && shadowRoot) {\n shadowRoots[keySuffix] = null;\n setShadowRoot(null);\n }\n }, [isolate, shadowRoot, mode, keySuffix]);\n\n return { shadowRoot, shadowRootContainerRef };\n}\n","import { DEFAULT_COMPONENT_NAME } from '#internal/runtime/constants';\n\n/**\n * Dummy URL used as a fallback base for URL parsing when no real base URL is available.\n * This is used during SSR or when location is not defined.\n */\nexport const DUMMY_FALLBACK = 'http://remote-components-dummy-fallback';\n\n/**\n * Extracts the relevant HTML content from a remote component response.\n *\n * Handles multiple remote component formats:\n * - Next.js Pages Router SSR wrapper (`div[id^=\"__REMOTE_COMPONENT\"]`)\n * - App Router remote components (`div[data-bundle][data-route]`)\n * - Next.js pages (`div#__next`)\n * - Web component format (`remote-component:not([src])`)\n *\n * @param html - Raw HTML string from the remote component response\n * @returns Extracted HTML content with links and scripts, or empty string if not found\n */\nexport function getRemoteComponentHtml(html: string): string {\n if (typeof document === 'undefined') return html;\n\n const parser = new DOMParser();\n const temp = parser.parseFromString(html, 'text/html');\n\n // Used by the Next.js Pages Router remote as a wrapper\n const ssrRemoteComponentContainer = temp.querySelector(\n 'div[id^=\"__REMOTE_COMPONENT\"]',\n );\n if (ssrRemoteComponentContainer) {\n return ssrRemoteComponentContainer.innerHTML;\n }\n\n // Remote component content from various sources\n const remoteComponentContainer = temp.querySelectorAll(\n `div[data-bundle][data-route][data-runtime][id^=\"${DEFAULT_COMPONENT_NAME}\"],div[data-bundle][data-route],div#__next,remote-component:not([src])`,\n );\n if (remoteComponentContainer.length > 0) {\n return `${Array.from(temp.querySelectorAll('link,script'))\n .map((link) => link.outerHTML)\n .join('')}${Array.from(remoteComponentContainer)\n .map((container) => container.outerHTML)\n .join('')}`;\n }\n\n return '';\n}\n","import { useEffect, useRef } from 'react';\nimport { onRemoteNavigate } from '#internal/host/navigation';\nimport type { RemoteNavigateEvent } from '#internal/host/shared/navigate-event';\n\n/**\n * Subscribe to remote component navigations. The callback is captured in a ref\n * so the listener is registered once — no `useCallback` or dep array needed.\n *\n * @example React Router\n * ```tsx\n * const navigate = useNavigate();\n * // Always replace — the polyfill already pushed/replaced the browser history entry.\n * useRemoteNavigate((e) => navigate(e.pathname + e.search, { replace: true }));\n * ```\n */\nexport function useRemoteNavigate(\n callback: (event: RemoteNavigateEvent) => void,\n): void {\n const callbackRef = useRef(callback);\n // Written during render (not in an effect) — the standard useCallbackRef\n // pattern. Safe under concurrent rendering: navigation events are user-driven\n // and can't fire mid-render.\n callbackRef.current = callback;\n useEffect(() => onRemoteNavigate((event) => callbackRef.current(event)), []);\n}\n"]}
|
|
@@ -126,6 +126,28 @@ function collapseDoubleSlashes(path) {
|
|
|
126
126
|
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
// src/host/shared/next-image-deployment-id.ts
|
|
130
|
+
function isNextDeploymentAssetSrc(src) {
|
|
131
|
+
return typeof src === "string" && src.startsWith("/") && !src.startsWith("//");
|
|
132
|
+
}
|
|
133
|
+
function extractDeploymentIdFromSrc(src) {
|
|
134
|
+
const queryIndex = src.indexOf("?");
|
|
135
|
+
if (queryIndex === -1) {
|
|
136
|
+
return { deploymentId: void 0, src };
|
|
137
|
+
}
|
|
138
|
+
const params = new URLSearchParams(src.slice(queryIndex + 1));
|
|
139
|
+
const deploymentId = params.get("dpl") || void 0;
|
|
140
|
+
if (!deploymentId) {
|
|
141
|
+
return { deploymentId: void 0, src };
|
|
142
|
+
}
|
|
143
|
+
params.delete("dpl");
|
|
144
|
+
const remaining = params.toString();
|
|
145
|
+
return {
|
|
146
|
+
deploymentId,
|
|
147
|
+
src: `${src.slice(0, queryIndex)}${remaining ? `?${remaining}` : ""}`
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
129
151
|
// src/runtime/turbopack/remote-scope.ts
|
|
130
152
|
function getRegistry() {
|
|
131
153
|
return getNamespace().scopes;
|
|
@@ -183,7 +205,13 @@ function parseRemoteId(id) {
|
|
|
183
205
|
}
|
|
184
206
|
|
|
185
207
|
// src/host/shared/remote-image-loader.ts
|
|
186
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
208
|
+
function createRemoteImageLoader(bundle, resolveClientUrl, ssrImageDeploymentIds) {
|
|
209
|
+
const ssrImageDeploymentIdMap = ssrImageDeploymentIds ? new Map(
|
|
210
|
+
ssrImageDeploymentIds.map(({ src, deploymentId }) => [
|
|
211
|
+
src,
|
|
212
|
+
deploymentId
|
|
213
|
+
])
|
|
214
|
+
) : void 0;
|
|
187
215
|
const loader = Object.assign(
|
|
188
216
|
({
|
|
189
217
|
config,
|
|
@@ -195,7 +223,14 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
195
223
|
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
196
224
|
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
197
225
|
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
198
|
-
|
|
226
|
+
if (!isNextDeploymentAssetSrc(src)) {
|
|
227
|
+
const url2 = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
228
|
+
return resolveClientUrl?.(url2) ?? url2;
|
|
229
|
+
}
|
|
230
|
+
const extracted = extractDeploymentIdFromSrc(src);
|
|
231
|
+
const deploymentId = extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);
|
|
232
|
+
const deploymentParam = deploymentId ? `&dpl=${encodeURIComponent(deploymentId)}` : "";
|
|
233
|
+
const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;
|
|
199
234
|
return resolveClientUrl?.(url) ?? url;
|
|
200
235
|
},
|
|
201
236
|
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
@@ -431,4 +466,4 @@ export {
|
|
|
431
466
|
buildCoreShared,
|
|
432
467
|
buildHostShared
|
|
433
468
|
};
|
|
434
|
-
//# sourceMappingURL=chunk-
|
|
469
|
+
//# sourceMappingURL=chunk-WWHNG5YP.js.map
|
|
@@ -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/host/shared/next-image-deployment-id.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\n// @legacy(remote-components<=0.4.x): remove this map shape once all supported\n// remotes emit sharedManifest. The provider path should then consume only\n// SharedModuleManifest requirements.\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","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","export interface NextImageDeploymentId {\n src: string;\n deploymentId: string;\n}\n\nexport function isNextDeploymentAssetSrc(src: string | null): src is string {\n return (\n typeof src === 'string' && src.startsWith('/') && !src.startsWith('//')\n );\n}\n\nexport function extractDeploymentIdFromSrc(src: string) {\n const queryIndex = src.indexOf('?');\n if (queryIndex === -1) {\n return { deploymentId: undefined, src };\n }\n\n const params = new URLSearchParams(src.slice(queryIndex + 1));\n const deploymentId = params.get('dpl') || undefined;\n if (!deploymentId) {\n return { deploymentId: undefined, src };\n }\n\n params.delete('dpl');\n const remaining = params.toString();\n return {\n deploymentId,\n src: `${src.slice(0, queryIndex)}${remaining ? `?${remaining}` : ''}`,\n };\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 {\n extractDeploymentIdFromSrc,\n isNextDeploymentAssetSrc,\n type NextImageDeploymentId,\n} from '#internal/host/shared/next-image-deployment-id';\nimport { 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 ssrImageDeploymentIds?: readonly NextImageDeploymentId[],\n) {\n const ssrImageDeploymentIdMap = ssrImageDeploymentIds\n ? new Map(\n ssrImageDeploymentIds.map(({ src, deploymentId }) => [\n src,\n deploymentId,\n ]),\n )\n : undefined;\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\n if (!isNextDeploymentAssetSrc(src)) {\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n }\n\n const extracted = extractDeploymentIdFromSrc(src);\n const deploymentId =\n extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);\n const deploymentParam = deploymentId\n ? `&dpl=${encodeURIComponent(deploymentId)}`\n : '';\n const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;\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 type { SharedModuleFactory } from '#internal/host/shared/shared-broker';\n\n/**\n * The core React packages that are always shared between host and remote.\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 shared-module manifest ID.\n * These IDs are emitted into sharedManifest for the default React entries.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_SHARED_MODULE_IDS: 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 shared-module ID string literals. Derived from\n * CORE_REACT_SHARED_MODULE_IDS but excludes `react-dom/client` to match the\n * existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_SHARED_MODULE_IDS)\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\n * client-only shared global. Pass `includePagesClientSharedGlobal: true` to\n * include it at the end.\n */\nexport function buildHostShared(\n userShared?: Record<string, SharedModuleFactory>,\n resolveClientUrl?: InternalResolveClientUrl,\n options?: { includePagesClientSharedGlobal?: 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?.includePagesClientSharedGlobal) {\n Object.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|
failedProxiedAssetError,
|
|
@@ -55,4 +55,4 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
55
55
|
export {
|
|
56
56
|
loadScripts
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-XLGLCKZZ.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createChunkDispatcher,
|
|
3
3
|
loadChunkWithScope,
|
|
4
4
|
requireModule
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GG32LZD3.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-WWHNG5YP.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-YKCU7RFM.js.map
|
|
@@ -126,6 +126,28 @@ function collapseDoubleSlashes(path) {
|
|
|
126
126
|
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
// src/host/shared/next-image-deployment-id.ts
|
|
130
|
+
function isNextDeploymentAssetSrc(src) {
|
|
131
|
+
return typeof src === "string" && src.startsWith("/") && !src.startsWith("//");
|
|
132
|
+
}
|
|
133
|
+
function extractDeploymentIdFromSrc(src) {
|
|
134
|
+
const queryIndex = src.indexOf("?");
|
|
135
|
+
if (queryIndex === -1) {
|
|
136
|
+
return { deploymentId: void 0, src };
|
|
137
|
+
}
|
|
138
|
+
const params = new URLSearchParams(src.slice(queryIndex + 1));
|
|
139
|
+
const deploymentId = params.get("dpl") || void 0;
|
|
140
|
+
if (!deploymentId) {
|
|
141
|
+
return { deploymentId: void 0, src };
|
|
142
|
+
}
|
|
143
|
+
params.delete("dpl");
|
|
144
|
+
const remaining = params.toString();
|
|
145
|
+
return {
|
|
146
|
+
deploymentId,
|
|
147
|
+
src: `${src.slice(0, queryIndex)}${remaining ? `?${remaining}` : ""}`
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
129
151
|
// src/runtime/turbopack/remote-scope.ts
|
|
130
152
|
function getRegistry() {
|
|
131
153
|
return _chunkZ2SLBFQLcjs.getNamespace.call(void 0, ).scopes;
|
|
@@ -183,7 +205,13 @@ function parseRemoteId(id) {
|
|
|
183
205
|
}
|
|
184
206
|
|
|
185
207
|
// src/host/shared/remote-image-loader.ts
|
|
186
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
208
|
+
function createRemoteImageLoader(bundle, resolveClientUrl, ssrImageDeploymentIds) {
|
|
209
|
+
const ssrImageDeploymentIdMap = ssrImageDeploymentIds ? new Map(
|
|
210
|
+
ssrImageDeploymentIds.map(({ src, deploymentId }) => [
|
|
211
|
+
src,
|
|
212
|
+
deploymentId
|
|
213
|
+
])
|
|
214
|
+
) : void 0;
|
|
187
215
|
const loader = Object.assign(
|
|
188
216
|
({
|
|
189
217
|
config,
|
|
@@ -195,8 +223,15 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
195
223
|
const remoteOrigin = _nullishCoalesce(_optionalChain([getScope, 'call', _6 => _6(bundle), 'optionalAccess', _7 => _7.url, 'access', _8 => _8.origin]), () => ( ""));
|
|
196
224
|
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
197
225
|
const basePath = isCrossOrigin ? `${remoteOrigin}${_nullishCoalesce(config.path, () => ( "/_next/image"))}` : _nullishCoalesce(config.path, () => ( `${remoteOrigin}/_next/image`));
|
|
198
|
-
|
|
199
|
-
|
|
226
|
+
if (!isNextDeploymentAssetSrc(src)) {
|
|
227
|
+
const url2 = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
228
|
+
return _nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _9 => _9(url2)]), () => ( url2));
|
|
229
|
+
}
|
|
230
|
+
const extracted = extractDeploymentIdFromSrc(src);
|
|
231
|
+
const deploymentId = _nullishCoalesce(extracted.deploymentId, () => ( _optionalChain([ssrImageDeploymentIdMap, 'optionalAccess', _10 => _10.get, 'call', _11 => _11(extracted.src)])));
|
|
232
|
+
const deploymentParam = deploymentId ? `&dpl=${encodeURIComponent(deploymentId)}` : "";
|
|
233
|
+
const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;
|
|
234
|
+
return _nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _12 => _12(url)]), () => ( url));
|
|
200
235
|
},
|
|
201
236
|
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
202
237
|
// one), enabling srcSet generation with device/image sizes from the config.
|
|
@@ -215,7 +250,7 @@ function dispatchRemoteNavigate(detail) {
|
|
|
215
250
|
function sharedPolyfills(shared, resolveClientUrl) {
|
|
216
251
|
const hostShared = _chunkZ2SLBFQLcjs.getNamespace.call(void 0, ).hostSharedModules;
|
|
217
252
|
const polyfill = {
|
|
218
|
-
"next/dist/client/components/navigation": _nullishCoalesce(_nullishCoalesce(hostShared["next/navigation"], () => ( _optionalChain([shared, 'optionalAccess',
|
|
253
|
+
"next/dist/client/components/navigation": _nullishCoalesce(_nullishCoalesce(hostShared["next/navigation"], () => ( _optionalChain([shared, 'optionalAccess', _13 => _13["next/navigation"]]))), () => ( (() => Promise.resolve({
|
|
219
254
|
useRouter() {
|
|
220
255
|
return {
|
|
221
256
|
push: (routerUrl) => {
|
|
@@ -248,7 +283,7 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
248
283
|
},
|
|
249
284
|
__esModule: true
|
|
250
285
|
})))),
|
|
251
|
-
"next/dist/client/app-dir/link": _nullishCoalesce(_nullishCoalesce(hostShared["next/link"], () => ( _optionalChain([shared, 'optionalAccess',
|
|
286
|
+
"next/dist/client/app-dir/link": _nullishCoalesce(_nullishCoalesce(hostShared["next/link"], () => ( _optionalChain([shared, 'optionalAccess', _14 => _14["next/link"]]))), () => ( (() => Promise.resolve({
|
|
252
287
|
default: ({
|
|
253
288
|
scroll: _,
|
|
254
289
|
replace,
|
|
@@ -278,7 +313,7 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
278
313
|
if (typeof props.onClick === "function") {
|
|
279
314
|
props.onClick(e);
|
|
280
315
|
}
|
|
281
|
-
_optionalChain([onNavigate, 'optionalCall',
|
|
316
|
+
_optionalChain([onNavigate, 'optionalCall', _15 => _15(e)]);
|
|
282
317
|
if (preventDefaulted) {
|
|
283
318
|
return;
|
|
284
319
|
}
|
|
@@ -302,7 +337,7 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
302
337
|
},
|
|
303
338
|
__esModule: true
|
|
304
339
|
})))),
|
|
305
|
-
"next/dist/client/app-dir/form": _nullishCoalesce(_nullishCoalesce(hostShared["next/form"], () => ( _optionalChain([shared, 'optionalAccess',
|
|
340
|
+
"next/dist/client/app-dir/form": _nullishCoalesce(_nullishCoalesce(hostShared["next/form"], () => ( _optionalChain([shared, 'optionalAccess', _16 => _16["next/form"]]))), () => ( (() => Promise.resolve({
|
|
306
341
|
default: () => {
|
|
307
342
|
throw new Error("Next.js <Form> component not implemented");
|
|
308
343
|
},
|
|
@@ -313,17 +348,17 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
313
348
|
// This gives us full next/image fidelity (fill, priority, srcSet, blur
|
|
314
349
|
// placeholders, error handling) while routing image optimization through the
|
|
315
350
|
// remote app's /_next/image endpoint.
|
|
316
|
-
"next/dist/shared/lib/image-loader": _nullishCoalesce(_nullishCoalesce(hostShared["next/dist/shared/lib/image-loader"], () => ( _optionalChain([shared, 'optionalAccess',
|
|
351
|
+
"next/dist/shared/lib/image-loader": _nullishCoalesce(_nullishCoalesce(hostShared["next/dist/shared/lib/image-loader"], () => ( _optionalChain([shared, 'optionalAccess', _17 => _17["next/dist/shared/lib/image-loader"]]))), () => ( ((bundle) => Promise.resolve({
|
|
317
352
|
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
318
353
|
__esModule: true
|
|
319
354
|
})))),
|
|
320
|
-
"next/dist/client/script": _nullishCoalesce(_nullishCoalesce(hostShared["next/script"], () => ( _optionalChain([shared, 'optionalAccess',
|
|
355
|
+
"next/dist/client/script": _nullishCoalesce(_nullishCoalesce(hostShared["next/script"], () => ( _optionalChain([shared, 'optionalAccess', _18 => _18["next/script"]]))), () => ( (() => Promise.resolve({
|
|
321
356
|
// TODO: implement <Script> component for non-Next.js host applications
|
|
322
357
|
// do not throw an error for now
|
|
323
358
|
default: () => null,
|
|
324
359
|
__esModule: true
|
|
325
360
|
})))),
|
|
326
|
-
"next/router": _nullishCoalesce(_nullishCoalesce(hostShared["next/router"], () => ( _optionalChain([shared, 'optionalAccess',
|
|
361
|
+
"next/router": _nullishCoalesce(_nullishCoalesce(hostShared["next/router"], () => ( _optionalChain([shared, 'optionalAccess', _19 => _19["next/router"]]))), () => ( (() => (
|
|
327
362
|
// TODO: incomplete implementation
|
|
328
363
|
Promise.resolve({
|
|
329
364
|
useRouter() {
|
|
@@ -396,7 +431,7 @@ function buildHostShared(userShared, resolveClientUrl, options) {
|
|
|
396
431
|
...self.__remote_component_host_shared_modules__,
|
|
397
432
|
...userShared
|
|
398
433
|
};
|
|
399
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
434
|
+
if (_optionalChain([options, 'optionalAccess', _20 => _20.includePagesClientSharedGlobal])) {
|
|
400
435
|
Object.assign(result, self.__remote_component_shared__);
|
|
401
436
|
}
|
|
402
437
|
return result;
|
|
@@ -431,4 +466,4 @@ function buildHostShared(userShared, resolveClientUrl, options) {
|
|
|
431
466
|
|
|
432
467
|
|
|
433
468
|
exports.SHARED_MODULE_MANIFEST_PROTOCOL = SHARED_MODULE_MANIFEST_PROTOCOL; exports.isSharedModuleManifest = isSharedModuleManifest; exports.getMissingSharedModulesMessage = getMissingSharedModulesMessage; exports.createSharedModulePlan = createSharedModulePlan; exports.resolveSharedModulePlan = resolveSharedModulePlan; exports.escapeString = escapeString; exports.attrToProp = attrToProp; exports.DEFAULT_BUNDLE_NAME = DEFAULT_BUNDLE_NAME; exports.DEFAULT_COMPONENT_NAME = DEFAULT_COMPONENT_NAME; exports.DEFAULT_ROUTE = DEFAULT_ROUTE; exports.RUNTIME_WEBPACK = RUNTIME_WEBPACK; exports.RUNTIME_TURBOPACK = RUNTIME_TURBOPACK; exports.RUNTIME_SCRIPT = RUNTIME_SCRIPT; exports.REMOTE_COMPONENT_REGEX = REMOTE_COMPONENT_REGEX; exports.NEXT_BUNDLE_PATH_RE = NEXT_BUNDLE_PATH_RE; exports.collapseDoubleSlashes = collapseDoubleSlashes; exports.createScope = createScope; exports.registerScope = registerScope; exports.getScope = getScope; exports.formatRemoteId = formatRemoteId; exports.parseRemoteId = parseRemoteId; exports.createRemoteImageLoader = createRemoteImageLoader; exports.CORE_REACT_SHARED_KEYS = CORE_REACT_SHARED_KEYS; exports.CORE_REACT_SHARED_MODULE_IDS = CORE_REACT_SHARED_MODULE_IDS; exports.VENDOR_SHARED = VENDOR_SHARED; exports.buildCoreShared = buildCoreShared; exports.buildHostShared = buildHostShared;
|
|
434
|
-
//# sourceMappingURL=chunk-
|
|
469
|
+
//# sourceMappingURL=chunk-ZPJ5J24T.cjs.map
|
|
@@ -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/host/shared/next-image-deployment-id.ts","../src/runtime/turbopack/remote-scope.ts","../src/host/shared/remote-image-loader.ts","../src/host/shared/polyfill.tsx","../src/host/shared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,IAAI,SACxB,yBACF;AAEA,SAAO;AACT;;;ACvMO,IAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,+BAAuD;AAAA,EAClE,OAAO;AAAA,EACP,yBAAyB;AAAA,EACzB,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,oBAAoB;AACtB;AAQO,IAAM,gBAAwC,OAAO;AAAA,EAC1D,OAAO,QAAQ,4BAA4B,EACxC,OAAO,CAAC,CAAC,GAAG,MAAM,QAAQ,kBAAkB,EAC5C,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC;AAC5C;AAQO,SAAS,gBACd,YACqC;AACrC,SAAO;AAAA,IACL,OAAO,aAAa,MAAM,OAAO,OAAO,GAAG;AAAA,IAC3C,aAAa,aAAa,MAAM,OAAO,WAAW,GAAG;AAAA,IACrD,yBAAyB,aACtB,MAAM,OAAO,uBAAuB,GAAG;AAAA,IAC1C,qBAAqB,aAClB,MAAM,OAAO,mBAAmB,GAAG;AAAA,IACtC,oBAAoB,aAAa,MAAM,OAAO,kBAAkB,GAAG;AAAA,IACnE,GAAG;AAAA,EACL;AACF;AAoBO,SAAS,gBACd,YACA,kBACA,SACqC;AACrC,QAAM,OAAO;AACb,QAAM,SAA8C;AAAA,IAClD,GAAG,gBAAgB,YAAY,gBAAgB;AAAA,IAC/C,GAAG,KAAK;AAAA,IACR,GAAG;AAAA,EACL;AACA,MAAI,SAAS,gCAAgC;AAC3C,WAAO,OAAO,QAAQ,KAAK,2BAA2B;AAAA,EACxD;AACA,SAAO;AACT","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\n// @legacy(remote-components<=0.4.x): remove this map shape once all supported\n// remotes emit sharedManifest. The provider path should then consume only\n// SharedModuleManifest requirements.\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","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","export interface NextImageDeploymentId {\n src: string;\n deploymentId: string;\n}\n\nexport function isNextDeploymentAssetSrc(src: string | null): src is string {\n return (\n typeof src === 'string' && src.startsWith('/') && !src.startsWith('//')\n );\n}\n\nexport function extractDeploymentIdFromSrc(src: string) {\n const queryIndex = src.indexOf('?');\n if (queryIndex === -1) {\n return { deploymentId: undefined, src };\n }\n\n const params = new URLSearchParams(src.slice(queryIndex + 1));\n const deploymentId = params.get('dpl') || undefined;\n if (!deploymentId) {\n return { deploymentId: undefined, src };\n }\n\n params.delete('dpl');\n const remaining = params.toString();\n return {\n deploymentId,\n src: `${src.slice(0, queryIndex)}${remaining ? `?${remaining}` : ''}`,\n };\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 {\n extractDeploymentIdFromSrc,\n isNextDeploymentAssetSrc,\n type NextImageDeploymentId,\n} from '#internal/host/shared/next-image-deployment-id';\nimport { 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 ssrImageDeploymentIds?: readonly NextImageDeploymentId[],\n) {\n const ssrImageDeploymentIdMap = ssrImageDeploymentIds\n ? new Map(\n ssrImageDeploymentIds.map(({ src, deploymentId }) => [\n src,\n deploymentId,\n ]),\n )\n : undefined;\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\n if (!isNextDeploymentAssetSrc(src)) {\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n }\n\n const extracted = extractDeploymentIdFromSrc(src);\n const deploymentId =\n extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);\n const deploymentParam = deploymentId\n ? `&dpl=${encodeURIComponent(deploymentId)}`\n : '';\n const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;\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 type { SharedModuleFactory } from '#internal/host/shared/shared-broker';\n\n/**\n * The core React packages that are always shared between host and remote.\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 shared-module manifest ID.\n * These IDs are emitted into sharedManifest for the default React entries.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_SHARED_MODULE_IDS: 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 shared-module ID string literals. Derived from\n * CORE_REACT_SHARED_MODULE_IDS but excludes `react-dom/client` to match the\n * existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_SHARED_MODULE_IDS)\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\n * client-only shared global. Pass `includePagesClientSharedGlobal: true` to\n * include it at the end.\n */\nexport function buildHostShared(\n userShared?: Record<string, SharedModuleFactory>,\n resolveClientUrl?: InternalResolveClientUrl,\n options?: { includePagesClientSharedGlobal?: 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?.includePagesClientSharedGlobal) {\n Object.assign(result, self.__remote_component_shared__);\n }\n return result;\n}\n"]}
|