remote-components 0.3.7 → 0.4.0

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.
Files changed (85) hide show
  1. package/dist/{chunk-LCXO7BUY.cjs → chunk-42TVDI3G.cjs} +5 -4
  2. package/dist/chunk-42TVDI3G.cjs.map +1 -0
  3. package/dist/chunk-5KTAEO52.cjs +28 -0
  4. package/dist/chunk-5KTAEO52.cjs.map +1 -0
  5. package/dist/{chunk-NZAB7REE.js → chunk-5WL3FP4V.js} +5 -5
  6. package/dist/{chunk-SZFCBE54.js → chunk-AKOMV2UF.js} +4 -3
  7. package/dist/chunk-AKOMV2UF.js.map +1 -0
  8. package/dist/{chunk-I47KE3EC.cjs → chunk-AYC2AWUG.cjs} +21 -21
  9. package/dist/{chunk-RJW3EZJP.cjs → chunk-EYALF655.cjs} +23 -23
  10. package/dist/{chunk-T64P7BAG.cjs → chunk-JJTCFQHE.cjs} +3 -3
  11. package/dist/{chunk-52BJ7VFA.js → chunk-MKO52FRO.js} +2 -2
  12. package/dist/{chunk-QKB74MLO.js → chunk-N3KPUFOB.js} +2 -2
  13. package/dist/chunk-N3SQTOSE.cjs +25 -0
  14. package/dist/chunk-N3SQTOSE.cjs.map +1 -0
  15. package/dist/{chunk-GBFUPMMI.js → chunk-NN5V3FVD.js} +25 -13
  16. package/dist/chunk-NN5V3FVD.js.map +1 -0
  17. package/dist/chunk-RHGEBXPL.js +25 -0
  18. package/dist/chunk-RHGEBXPL.js.map +1 -0
  19. package/dist/{chunk-X6W464D6.cjs → chunk-RLI4YTBJ.cjs} +17 -1
  20. package/dist/chunk-RLI4YTBJ.cjs.map +1 -0
  21. package/dist/{chunk-SJM7AAGU.js → chunk-SAGYPGIQ.js} +17 -1
  22. package/dist/chunk-SAGYPGIQ.js.map +1 -0
  23. package/dist/chunk-STIJO4AG.js +28 -0
  24. package/dist/chunk-STIJO4AG.js.map +1 -0
  25. package/dist/{chunk-AWWWK2ZY.cjs → chunk-Y4GMYUJT.cjs} +32 -20
  26. package/dist/chunk-Y4GMYUJT.cjs.map +1 -0
  27. package/dist/config/nextjs.cjs +6 -5
  28. package/dist/config/nextjs.cjs.map +1 -1
  29. package/dist/config/nextjs.js +3 -2
  30. package/dist/config/nextjs.js.map +1 -1
  31. package/dist/host/html.cjs +21 -20
  32. package/dist/host/html.cjs.map +1 -1
  33. package/dist/host/html.js +9 -8
  34. package/dist/host/html.js.map +1 -1
  35. package/dist/host/navigation.cjs +8 -0
  36. package/dist/host/navigation.cjs.map +1 -0
  37. package/dist/host/navigation.d.ts +30 -0
  38. package/dist/host/navigation.js +8 -0
  39. package/dist/host/navigation.js.map +1 -0
  40. package/dist/host/nextjs/app/client-only.cjs +14 -12
  41. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  42. package/dist/host/nextjs/app/client-only.d.ts +2 -1
  43. package/dist/host/nextjs/app/client-only.js +9 -7
  44. package/dist/host/nextjs/app/client-only.js.map +1 -1
  45. package/dist/host/react.cjs +12 -8
  46. package/dist/host/react.d.ts +2 -1
  47. package/dist/host/react.js +13 -9
  48. package/dist/{index-4c65355c.d.ts → index-d2ce8a3f.d.ts} +22 -2
  49. package/dist/internal/host/shared/navigate-event.cjs +51 -0
  50. package/dist/internal/host/shared/navigate-event.cjs.map +1 -0
  51. package/dist/internal/host/shared/navigate-event.d.ts +21 -0
  52. package/dist/internal/host/shared/navigate-event.js +26 -0
  53. package/dist/internal/host/shared/navigate-event.js.map +1 -0
  54. package/dist/internal/host/shared/polyfill.cjs +14 -0
  55. package/dist/internal/host/shared/polyfill.cjs.map +1 -1
  56. package/dist/internal/host/shared/polyfill.js +16 -0
  57. package/dist/internal/host/shared/polyfill.js.map +1 -1
  58. package/dist/internal/runtime/loaders/script-loader.cjs +2 -1
  59. package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
  60. package/dist/internal/runtime/loaders/script-loader.js +2 -1
  61. package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
  62. package/dist/navigate-event-baee0b63.d.ts +14 -0
  63. package/dist/{turbopack-5LW6V6IT.js → turbopack-DK6L7P3J.js} +5 -4
  64. package/dist/{turbopack-5LW6V6IT.js.map → turbopack-DK6L7P3J.js.map} +1 -1
  65. package/dist/{turbopack-KRKECGY2.cjs → turbopack-PSD4THQE.cjs} +12 -11
  66. package/dist/turbopack-PSD4THQE.cjs.map +1 -0
  67. package/dist/{webpack-NPZNXRNL.js → webpack-KSDNIXMS.js} +5 -4
  68. package/dist/{webpack-NPZNXRNL.js.map → webpack-KSDNIXMS.js.map} +1 -1
  69. package/dist/{webpack-TTZDARNY.cjs → webpack-SIFRCBIN.cjs} +12 -11
  70. package/dist/webpack-SIFRCBIN.cjs.map +1 -0
  71. package/package.json +9 -1
  72. package/dist/chunk-AWWWK2ZY.cjs.map +0 -1
  73. package/dist/chunk-GBFUPMMI.js.map +0 -1
  74. package/dist/chunk-LCXO7BUY.cjs.map +0 -1
  75. package/dist/chunk-SJM7AAGU.js.map +0 -1
  76. package/dist/chunk-SZFCBE54.js.map +0 -1
  77. package/dist/chunk-X6W464D6.cjs.map +0 -1
  78. package/dist/turbopack-KRKECGY2.cjs.map +0 -1
  79. package/dist/webpack-TTZDARNY.cjs.map +0 -1
  80. /package/dist/{chunk-NZAB7REE.js.map → chunk-5WL3FP4V.js.map} +0 -0
  81. /package/dist/{chunk-I47KE3EC.cjs.map → chunk-AYC2AWUG.cjs.map} +0 -0
  82. /package/dist/{chunk-RJW3EZJP.cjs.map → chunk-EYALF655.cjs.map} +0 -0
  83. /package/dist/{chunk-T64P7BAG.cjs.map → chunk-JJTCFQHE.cjs.map} +0 -0
  84. /package/dist/{chunk-52BJ7VFA.js.map → chunk-MKO52FRO.js.map} +0 -0
  85. /package/dist/{chunk-QKB74MLO.js.map → chunk-N3KPUFOB.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/host/html/index.tsx","../../src/host/html/attach-styles.ts","../../src/host/html/runtime/index.ts"],"sourcesContent":["import { startTransition, useLayoutEffect } from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport { fetchWithHooks } from '#internal/host/server/fetch-with-hooks';\nimport { getClientOrServerUrl } from '#internal/host/server/get-client-or-server-url';\nimport type {\n ConsumeClientConfig,\n ConsumeServerConfig,\n} from '#internal/host/shared/config';\nimport {\n type LifecycleEmitter,\n makeEventEmitter,\n} from '#internal/host/shared/lifecycle';\nimport { preparePipeline } from '#internal/host/shared/pipeline';\nimport type { HostState } from '#internal/host/shared/state';\nimport { createHostState } from '#internal/host/shared/state';\nimport { resolveNameFromSrc } from '#internal/host/utils/resolve-name-from-src';\nimport {\n DEFAULT_BUNDLE_NAME,\n DEFAULT_COMPONENT_NAME,\n} from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { createRSCStream } from '#internal/runtime/rsc';\nimport type { RSCKey } from '#internal/runtime/types';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport { escapeString } from '#internal/utils';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n errorFromFailedFetch,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport { logError } from '#internal/utils/logger';\nimport { attachStyles } from './attach-styles';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n /**\n * `<remote-component>` custom element — the HTML host implementation.\n *\n * Implements {@link ConsumeClientConfig}\n * via typed property accessors that reflect to/from DOM attributes.\n *\n * {@link ConsumeLifecycleCallbacks} are dispatched as DOM events:\n * `beforeload`, `load`, `error`, `change`.\n */\n class RemoteComponent extends HTMLElement implements ConsumeClientConfig {\n name: string = DEFAULT_COMPONENT_NAME;\n bundle: string = DEFAULT_BUNDLE_NAME;\n fallbackSlot?: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n hostState: HostState = createHostState();\n root?: ShadowRoot | null = null;\n reactRoot?: ReturnType<typeof hydrateRoot>;\n emitter: LifecycleEmitter = makeEventEmitter(this);\n onRequest?: ConsumeServerConfig['onRequest'];\n onResponse?: ConsumeServerConfig['onResponse'];\n resolveClientUrl?: ConsumeClientConfig['resolveClientUrl'];\n\n // -- ConsumeServerConfig property accessors (attribute-reflected) --\n\n get src(): string | URL | undefined {\n return this.getAttribute('src') ?? undefined;\n }\n\n set src(value: string | URL | undefined) {\n if (value == null) {\n this.removeAttribute('src');\n } else {\n this.setAttribute('src', String(value));\n }\n }\n\n /** Always `true` — the HTML host always isolates via Shadow DOM. */\n get isolate(): boolean {\n return true;\n }\n\n get mode(): 'open' | 'closed' | undefined {\n const attr = this.getAttribute('mode');\n return attr === 'closed' ? 'closed' : 'open';\n }\n\n set mode(value: 'open' | 'closed' | undefined) {\n if (value) {\n this.setAttribute('mode', value);\n }\n }\n\n get reset(): boolean | undefined {\n return this.getAttribute('reset') !== null;\n }\n\n set reset(value: boolean | undefined) {\n if (value) {\n this.setAttribute('reset', '');\n } else {\n this.removeAttribute('reset');\n }\n }\n\n get credentials(): RequestCredentials | undefined {\n return (this.getAttribute('credentials') ||\n 'same-origin') as RequestCredentials;\n }\n\n set credentials(value: RequestCredentials | undefined) {\n if (value) {\n this.setAttribute('credentials', value);\n } else {\n this.removeAttribute('credentials');\n }\n }\n\n static get observedAttributes() {\n return ['src', 'name', 'mode'];\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if ((name === 'src' || name === 'name') && oldValue !== newValue) {\n if (this.src) {\n this.load().catch((e) => {\n // AbortError is expected when loading is cancelled - don't log or dispatch\n if (isAbortError(e)) {\n return;\n }\n logError('HtmlHost', 'Error loading remote component.', e);\n this.emitter.error(e, this.src);\n this.hostState.stage = 'error';\n });\n }\n } else if (name === 'mode' && oldValue !== newValue && this.root) {\n // changing the shadow DOM mode is not supported\n // we need to recreate the shadow DOM and reload the component\n const newRoot = this.attachShadow({\n mode: newValue === 'closed' ? 'closed' : 'open',\n });\n // move all existing children to the new shadow root\n Array.from(this.root.children).forEach((child) => {\n newRoot.appendChild(child);\n });\n this.root = newRoot;\n // reload the remote component to apply the new shadow DOM\n this.load().catch((e) => {\n // AbortError is expected when loading is cancelled - don't log or dispatch\n if (isAbortError(e)) {\n return;\n }\n logError('HtmlHost', 'Error reloading remote component.', e);\n this.emitter.error(e, this.src);\n });\n }\n }\n\n async load() {\n // wait for the current call stack to finish\n await new Promise((resolve) => {\n (typeof queueMicrotask === 'function'\n ? queueMicrotask\n : requestAnimationFrame)(() => {\n resolve(undefined);\n });\n });\n\n // Abort any in-progress load so the latest src always wins.\n if (this.hostState.stage === 'loading') {\n this.hostState.abortController?.abort();\n this.hostState.stage = 'idle';\n // The aborted load may have already appended partial content to the shadow DOM\n // (styles, component children) before reaching an isCurrentLoad() check.\n // Clear it now so the new load starts from a clean state. Skip this when a\n // React root exists — that means a previous load completed successfully and\n // we'll take the startTransition re-render path instead.\n if (this.root && !this.reactRoot) {\n this.root.innerHTML = '';\n this.fouc = null;\n this.fallbackSlot = document.createElement('slot');\n this.root.appendChild(this.fallbackSlot);\n }\n }\n\n if (!this.root) {\n this.root = this.attachShadow({\n mode: this.mode === 'closed' ? 'closed' : 'open',\n });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.root.appendChild(this.fallbackSlot);\n }\n\n this.name = this.getAttribute('name') || this.name;\n\n this.hostState.stage = 'loading';\n const src = this.src;\n\n // Create AbortController for this load operation\n this.hostState.abortController = new AbortController();\n const signal = this.hostState.abortController.signal;\n\n // Returns true if this is still the active load — the signal hasn't been\n // aborted by a newer load() call, and the src hasn't changed in the meantime.\n // Checking the signal (not just the src) handles the case where the user\n // cycles back to the same src (e.g. styled → basic → styled): both loads\n // share the same src string, so a src-only check would pass for both,\n // causing double renders.\n const isCurrentLoad = () => !signal.aborted && this.src === src;\n\n // Resets stage to 'idle' for expected cancellations (AbortError). Real\n // errors are thrown and caught by attributeChangedCallback which sets\n // stage to 'error'. Only resets if no newer load() has superseded this\n // one — a new load replaces the abortController so the signal comparison\n // fails, preventing us from clobbering the new load's stage.\n const abandonLoad = () => {\n if (\n this.hostState.abortController?.signal === signal &&\n this.hostState.stage === 'loading'\n ) {\n this.hostState.stage = 'idle';\n }\n };\n\n this.emitter.beforeLoad(src ?? '');\n\n const remoteComponentChild =\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.querySelector('div[data-bundle][data-route]');\n\n if (!src && !remoteComponentChild) {\n throw new RemoteComponentsError('\"src\" attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (src) {\n url = getClientOrServerUrl(src, window.location.href);\n this.name = resolveNameFromSrc(src, this.name);\n }\n\n const resolveClientUrl = url\n ? bindResolveClientUrl(this.resolveClientUrl, url.href)\n : undefined;\n\n if (!remoteComponentChild && url) {\n // fetch the remote component\n const fetchInit = {\n credentials: this.credentials || 'same-origin',\n } as RequestInit;\n\n const resolvedUrl = new URL(\n resolveClientUrl?.(url.href) ?? url.href,\n window.location.href,\n );\n let res: Response;\n try {\n res = await fetchWithHooks(resolvedUrl, fetchInit, {\n onRequest: this.onRequest,\n onResponse: this.onResponse,\n abortController: this.hostState.abortController,\n });\n } catch (e) {\n if (isAbortError(e)) {\n return abandonLoad();\n }\n throw e;\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 - race with abort signal\n try {\n html = await res.text();\n } catch (e) {\n if (isAbortError(e)) {\n return abandonLoad();\n }\n throw e;\n }\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n }\n\n const effectiveUrl = url ?? new URL(window.location.href);\n const { doc, parsed } = preparePipeline({\n html,\n name: this.name,\n url: effectiveUrl,\n shared: {},\n resolveClientUrl,\n });\n const {\n component,\n name: resolvedName,\n isRemoteComponent,\n metadata: parsedMetadata,\n nextData,\n rsc,\n remoteShared,\n } = parsed;\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development' && !this.reactRoot) {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.root.appendChild(this.fouc);\n }\n\n this.name = resolvedName;\n this.bundle = parsedMetadata.bundle;\n\n if (url) {\n getNamespace().bundleUrls[this.bundle] = url;\n }\n\n // add remote component metadata information at the custom element\n const metadataEl = document.createElement('script');\n metadataEl.type = 'application/json';\n metadataEl.setAttribute('data-remote-component', '');\n const metadataObj = {\n name: this.name,\n bundle: this.bundle,\n route: parsedMetadata.route,\n runtime: parsedMetadata.runtime,\n };\n metadataEl.textContent = JSON.stringify(metadataObj);\n\n if (\n this.previousElementSibling?.getAttribute('data-remote-component') !==\n null\n ) {\n this.previousElementSibling?.remove();\n }\n this.parentElement?.insertBefore(metadataEl, this);\n\n if (this.hostState.prevIsRemoteComponent) {\n if (this.hostState.prevUrl) {\n const prevUrl = this.hostState.prevUrl;\n const nsUnmount = getNamespace();\n if (nsUnmount.unmountFns[prevUrl.href]) {\n // call unmount() for all registered unmount functions for the previous remote component\n await Promise.all(\n Array.from(nsUnmount.unmountFns[prevUrl.href] ?? []).map(\n async (unmount) => {\n try {\n await unmount(this.root);\n } catch (e) {\n logError(\n 'HtmlHost',\n `Error while calling unmount() for Remote Component from ${prevUrl.href}.`,\n e,\n );\n }\n },\n ),\n );\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n }\n }\n this.root.innerHTML = '';\n }\n // Dispatch change event if this is not the first load\n if (this.hostState.prevSrc !== undefined) {\n this.emitter.change({\n previousSrc: this.hostState.prevSrc ?? null,\n nextSrc: src ?? null,\n previousName: this.hostState.prevName,\n nextName: this.name,\n });\n }\n\n this.hostState.prevUrl = effectiveUrl;\n this.hostState.prevIsRemoteComponent = isRemoteComponent;\n this.hostState.prevSrc = src;\n this.hostState.prevName = this.name;\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n const remoteComponentSrc = this.src ? String(this.src) : null;\n\n // Bound function for attaching styles — used both initially and in React effects\n const doAttachStyles = () =>\n attachStyles({\n doc,\n component,\n links,\n signal: undefined, // Effects run after load, no abort needed\n baseUrl: url?.href,\n remoteComponentSrc,\n root: this.root ?? null,\n resolveClientUrl,\n });\n\n if (!this.reactRoot) {\n // ensure all styles are loaded before hydrating to prevent FOUC\n await attachStyles({\n doc,\n component,\n links,\n signal,\n baseUrl: url?.href,\n remoteComponentSrc,\n root: this.root,\n resolveClientUrl,\n });\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n }\n\n if (!this.reactRoot) {\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n if (!isRemoteComponent && el.tagName.toLowerCase() === 'script') {\n const newScript = document.createElement('script');\n // copy all attributes\n for (const attr of el.attributes) {\n if (attr.name === 'src') {\n const absoluteSrc = new URL(\n attr.value,\n url ?? window.location.origin,\n ).href;\n newScript.setAttribute(\n attr.name,\n resolveClientUrl?.(absoluteSrc) ?? absoluteSrc,\n );\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n newScript.textContent = el.textContent;\n if (remoteComponentSrc) {\n newScript.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n this.root?.appendChild(newScript);\n } else {\n const newEl = el.cloneNode(true) as HTMLElement;\n for (const attr of el.attributes) {\n if (attr.name.startsWith('on')) {\n newEl.setAttribute(attr.name, attr.value);\n }\n }\n this.root?.appendChild(newEl);\n }\n });\n }\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.fallbackSlot?.remove();\n\n // function to apply the reset styles to the shadow DOM\n const applyReset = () => {\n if (\n this.reset &&\n !this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n // all initial styles to reset inherited styles leaking from the host page\n const allInitial = document.createElement('link');\n allInitial.setAttribute('data-remote-components-reset', '');\n const css = `:host { all: initial; }`;\n const allInitialHref = URL.createObjectURL(\n new Blob([css], { type: 'text/css' }),\n );\n allInitial.href = allInitialHref;\n allInitial.rel = 'stylesheet';\n // we need to revoke the object URL after the stylesheet is loaded to free up memory\n allInitial.onload = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n allInitial.onerror = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n this.root?.prepend(allInitial);\n } else if (\n !this.reset &&\n this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n this.root\n .querySelector('link[data-remote-components-reset]')\n ?.remove();\n }\n };\n\n // apply the reset styles if required and not already applied\n if (!this.reactRoot) {\n applyReset();\n }\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n metadataObj.runtime as Runtime,\n effectiveUrl,\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n resolveClientUrl,\n );\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n\n const scripts = isRemoteComponent\n ? component.querySelectorAll<HTMLScriptElement>('script')\n : doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src],script[data-remote-component-entrypoint]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(Array.from(scripts), url, this.bundle, this.name);\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n\n // remove all script elements from the shadow DOM to prevent re-execution of scripts\n if (isRemoteComponent) {\n Array.from(component.children).forEach((child) => {\n if (child.tagName === 'SCRIPT') {\n child.remove();\n }\n });\n }\n\n // cleanup previous remote component instances when a new remote component is loaded\n // this is required when the src attribute is changed to load a new remote component\n const doCleanup = () => {\n if (this.root && remoteComponentSrc) {\n const selector = `[data-remote-component-src]:not([data-remote-component-src=\"${remoteComponentSrc}\"])`;\n const prevCleanup = [\n ...this.root.querySelectorAll(selector),\n ...document.body.querySelectorAll(selector),\n ] as HTMLElement[];\n\n if (prevCleanup.length > 0) {\n prevCleanup.forEach((prev) => {\n prev.remove();\n });\n }\n }\n };\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscName = `__remote_component_rsc_${escapeString(\n url.href,\n )}_${escapeString(this.name)}`;\n const rscClone = document.createElement('script');\n rscClone.id = `${rscName}_rsc`;\n rscClone.textContent =\n rsc.textContent?.replace(\n new RegExp(`self\\\\[\"${this.name}\"\\\\]`, 'g'),\n `self[\"${rscName}\"]`,\n ) ?? '';\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n initial,\n }: {\n name: string;\n initial: boolean;\n }) => {\n // convert the RSC flight data array into a ReadableStream\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const stream = createRSCStream(\n rscName,\n self[rscName as RSCKey] ?? [`0:[null]\\n`],\n );\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(stream) as React.ReactNode);\n\n useLayoutEffect(() => {\n // clear the RSC flight data from the global scope to free up memory\n if (self[name as RSCKey]) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete self[name as RSCKey];\n }\n const rscScript = document.getElementById(`${name}_rsc`);\n if (rscScript) {\n rscScript.remove();\n }\n\n doCleanup();\n applyReset();\n if (!initial) {\n doAttachStyles().catch((e: unknown) => {\n logError('HtmlHost', 'Error attaching styles.', e);\n });\n }\n if (isCurrentLoad()) {\n this.hostState.stage = 'loaded';\n }\n\n this.emitter.load(this.src ?? '');\n }, [initial, name]);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(\n <RemoteComponentFromReadableStream\n initial={false}\n name={this.name}\n />,\n );\n });\n return;\n }\n\n // hydrate the remote component using the RSC flight data\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromReadableStream initial name={this.name} />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle,\n nextData.page ?? '/',\n this.root,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n const RemoteComponentFromNext = ((\n NextApp: ReturnType<typeof nextClientPagesLoader>['App'],\n NextComponent: NonNullable<\n ReturnType<typeof nextClientPagesLoader>['Component']\n >,\n remoteComponent = this,\n ) =>\n function RemoteComponentNext({ initial }: { initial: boolean }) {\n useLayoutEffect(() => {\n doCleanup();\n if (!initial) {\n applyReset();\n doAttachStyles().catch((e: unknown) => {\n logError('HtmlHost', 'Error attaching styles.', e);\n });\n }\n if (isCurrentLoad()) {\n remoteComponent.hostState.stage = 'loaded';\n }\n\n remoteComponent.emitter.load(remoteComponent.src ?? '');\n }, [initial, remoteComponent]);\n\n return NextApp ? (\n <NextApp Component={NextComponent} {...nextData.props} />\n ) : (\n <NextComponent {...nextData.props} />\n );\n })(App, Component, this);\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(<RemoteComponentFromNext initial={false} />);\n doCleanup();\n if (isCurrentLoad()) {\n this.hostState.stage = 'loaded';\n }\n });\n return;\n }\n\n // hydrate the remote component using the Next.js pages router\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromNext initial />,\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.root.removeChild(this.fouc);\n }\n } else if (getNamespace().mountFns[url.href]) {\n // using script entrypoint when no RSC or Next.js data is available\n await Promise.all(\n Array.from(getNamespace().mountFns[url.href] ?? []).map(\n async (mount) => {\n try {\n await mount(this.root);\n } catch (e) {\n logError(\n 'HtmlHost',\n `Error while calling mount() for Remote Component from ${url.href}.`,\n e,\n );\n }\n },\n ),\n );\n\n this.emitter.load(this.src ?? '');\n } else {\n this.emitter.load(this.src ?? '');\n }\n\n if (isCurrentLoad()) {\n this.hostState.stage = 'loaded';\n }\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n\nexport function registerSharedModules(\n modules: Record<string, () => Promise<unknown>> = {},\n) {\n const ns = getNamespace();\n Object.entries(modules).forEach(([key, value]) => {\n ns.hostSharedModules[key] = value;\n });\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\ninterface AttachStylesOptions {\n /** The parsed document containing link and style elements */\n doc: Document;\n /** The component element to check if links are already contained */\n component: Element;\n /** Links from the document head */\n links: NodeListOf<HTMLLinkElement>;\n /** AbortSignal to cancel loading */\n signal: AbortSignal | undefined;\n /** Base URL for resolving relative hrefs */\n baseUrl: string | undefined;\n /** Source URL to set as data attribute */\n remoteComponentSrc: string | null;\n /** Root element to append styles to (ShadowRoot or Element) */\n root: ShadowRoot | Element | null;\n /** Callback to transform asset URLs before loading */\n resolveClientUrl?: InternalResolveClientUrl;\n}\n\n/**\n * Attaches link and style elements from a remote component document to the shadow root.\n * Handles abort signals efficiently with a single shared listener for all links.\n *\n * @throws DOMException with name 'AbortError' if signal is aborted\n * @throws RemoteComponentsError if a stylesheet fails to load\n */\nexport async function attachStyles({\n doc,\n component,\n links,\n signal,\n baseUrl,\n remoteComponentSrc,\n root,\n resolveClientUrl,\n}: AttachStylesOptions): Promise<void> {\n // Track appended links for cleanup on abort\n const appendedLinks: HTMLLinkElement[] = [];\n\n // Single shared abort promise - avoids N listeners for N links\n let abortReject: ((error: DOMException) => void) | null = null;\n const abortPromise = new Promise<never>((_, reject) => {\n abortReject = reject;\n });\n const abortHandler = () => {\n // Clean up all pending links on abort\n for (const link of appendedLinks) {\n link.onload = null;\n link.onerror = null;\n link.remove();\n }\n abortReject?.(new DOMException('Aborted', 'AbortError'));\n };\n signal?.addEventListener('abort', abortHandler, { once: true });\n\n try {\n // Attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links)\n .filter((link) => !component.contains(link))\n .map((link) => {\n const newLink = document.createElement('link');\n appendedLinks.push(newLink);\n\n const loadPromise = new Promise<void>((resolve, reject) => {\n if (link.rel === 'stylesheet') {\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 newLink.onload = () => resolve();\n newLink.onerror = () =>\n reject(\n new RemoteComponentsError(\n `Failed to load <link href=\"${link.href}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n } else {\n resolve();\n }\n });\n\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n const absoluteHref = new URL(\n attr.value,\n baseUrl ?? location.origin,\n ).href;\n newLink.setAttribute(\n attr.name,\n resolveClientUrl?.(absoluteHref) ?? absoluteHref,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n\n if (remoteComponentSrc) {\n newLink.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n\n // 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 root?.appendChild(newLink);\n\n // Race each link load against the shared abort promise\n return Promise.race([loadPromise, abortPromise]);\n }),\n );\n } finally {\n signal?.removeEventListener('abort', abortHandler);\n }\n\n // Attach inline styles from the document head\n const styles = doc.querySelectorAll<HTMLStyleElement>('style');\n for (const style of styles) {\n if (style.parentElement?.tagName.toLowerCase() === 'head') {\n const newStyle = document.createElement('style');\n newStyle.textContent = style.textContent;\n\n if (remoteComponentSrc) {\n newStyle.setAttribute('data-remote-component-src', remoteComponentSrc);\n }\n\n root?.appendChild(newStyle);\n }\n }\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\nexport type Runtime = 'webpack' | 'turbopack' | 'script' | 'unknown';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(\n url,\n bundle,\n shared,\n remoteShared,\n resolveClientUrl,\n );\n } else if (type === 'script') {\n const { scriptRuntime } = await import(`./script`);\n return scriptRuntime(resolveClientUrl);\n }\n throw new RemoteComponentsError(\n `Remote Components runtime \"${type}\" is not supported. Supported runtimes are \"webpack\", \"turbopack\", and \"script\".`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,mBAAmB;;;AC4B5B,eAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AAErC,QAAM,gBAAmC,CAAC;AAG1C,MAAI,cAAsD;AAC1D,QAAM,eAAe,IAAI,QAAe,CAAC,GAAG,WAAW;AACrD,kBAAc;AAAA,EAChB,CAAC;AACD,QAAM,eAAe,MAAM;AAEzB,eAAW,QAAQ,eAAe;AAChC,WAAK,SAAS;AACd,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D;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,aAAK,QAAQ,KAAK,KAAK,OAAO,EAAE;AAAA,MAClC,OAAO;AACL,aAAK,QAAQ,KAAK,KAAK,OAAO,EAAE;AAAA,MAClC;AAEA,UAAI,cAAc,GAAG;AACnB,aAAK,UAAU,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAGA,iBAAe,OAAO,oBAAoB,eAAe;AAC3D;AAEO,SAAS,sBACd,UAAkD,CAAC,GACnD;AACA,QAAM,KAAK,aAAa;AACxB,SAAO,QAAQ,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChD,OAAG,kBAAkB,GAAG,IAAI;AAAA,EAC9B,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/host/html/index.tsx","../../src/host/html/attach-styles.ts","../../src/host/html/runtime/index.ts"],"sourcesContent":["import { startTransition, useLayoutEffect } from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport { fetchWithHooks } from '#internal/host/server/fetch-with-hooks';\nimport { getClientOrServerUrl } from '#internal/host/server/get-client-or-server-url';\nimport type {\n ConsumeClientConfig,\n ConsumeServerConfig,\n} from '#internal/host/shared/config';\nimport {\n type LifecycleEmitter,\n makeEventEmitter,\n} from '#internal/host/shared/lifecycle';\nimport { preparePipeline } from '#internal/host/shared/pipeline';\nimport type { HostState } from '#internal/host/shared/state';\nimport { createHostState } from '#internal/host/shared/state';\nimport { resolveNameFromSrc } from '#internal/host/utils/resolve-name-from-src';\nimport {\n DEFAULT_BUNDLE_NAME,\n DEFAULT_COMPONENT_NAME,\n} from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { createRSCStream } from '#internal/runtime/rsc';\nimport type { RSCKey } from '#internal/runtime/types';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport { escapeString } from '#internal/utils';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n errorFromFailedFetch,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport { logError } from '#internal/utils/logger';\nimport { attachStyles } from './attach-styles';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n /**\n * `<remote-component>` custom element — the HTML host implementation.\n *\n * Implements {@link ConsumeClientConfig}\n * via typed property accessors that reflect to/from DOM attributes.\n *\n * {@link ConsumeLifecycleCallbacks} are dispatched as DOM events:\n * `beforeload`, `load`, `error`, `change`.\n */\n class RemoteComponent extends HTMLElement implements ConsumeClientConfig {\n name: string = DEFAULT_COMPONENT_NAME;\n bundle: string = DEFAULT_BUNDLE_NAME;\n fallbackSlot?: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n hostState: HostState = createHostState();\n root?: ShadowRoot | null = null;\n reactRoot?: ReturnType<typeof hydrateRoot>;\n emitter: LifecycleEmitter = makeEventEmitter(this);\n onRequest?: ConsumeServerConfig['onRequest'];\n onResponse?: ConsumeServerConfig['onResponse'];\n resolveClientUrl?: ConsumeClientConfig['resolveClientUrl'];\n\n // -- ConsumeServerConfig property accessors (attribute-reflected) --\n\n get src(): string | URL | undefined {\n return this.getAttribute('src') ?? undefined;\n }\n\n set src(value: string | URL | undefined) {\n if (value == null) {\n this.removeAttribute('src');\n } else {\n this.setAttribute('src', String(value));\n }\n }\n\n /** Always `true` — the HTML host always isolates via Shadow DOM. */\n get isolate(): boolean {\n return true;\n }\n\n get mode(): 'open' | 'closed' | undefined {\n const attr = this.getAttribute('mode');\n return attr === 'closed' ? 'closed' : 'open';\n }\n\n set mode(value: 'open' | 'closed' | undefined) {\n if (value) {\n this.setAttribute('mode', value);\n }\n }\n\n get reset(): boolean | undefined {\n return this.getAttribute('reset') !== null;\n }\n\n set reset(value: boolean | undefined) {\n if (value) {\n this.setAttribute('reset', '');\n } else {\n this.removeAttribute('reset');\n }\n }\n\n get credentials(): RequestCredentials | undefined {\n return (this.getAttribute('credentials') ||\n 'same-origin') as RequestCredentials;\n }\n\n set credentials(value: RequestCredentials | undefined) {\n if (value) {\n this.setAttribute('credentials', value);\n } else {\n this.removeAttribute('credentials');\n }\n }\n\n static get observedAttributes() {\n return ['src', 'name', 'mode'];\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if ((name === 'src' || name === 'name') && oldValue !== newValue) {\n if (this.src) {\n this.load().catch((e) => {\n // AbortError is expected when loading is cancelled - don't log or dispatch\n if (isAbortError(e)) {\n return;\n }\n logError('HtmlHost', 'Error loading remote component.', e);\n this.emitter.error(e, this.src);\n this.hostState.stage = 'error';\n });\n }\n } else if (name === 'mode' && oldValue !== newValue && this.root) {\n // changing the shadow DOM mode is not supported\n // we need to recreate the shadow DOM and reload the component\n const newRoot = this.attachShadow({\n mode: newValue === 'closed' ? 'closed' : 'open',\n });\n // move all existing children to the new shadow root\n Array.from(this.root.children).forEach((child) => {\n newRoot.appendChild(child);\n });\n this.root = newRoot;\n // reload the remote component to apply the new shadow DOM\n this.load().catch((e) => {\n // AbortError is expected when loading is cancelled - don't log or dispatch\n if (isAbortError(e)) {\n return;\n }\n logError('HtmlHost', 'Error reloading remote component.', e);\n this.emitter.error(e, this.src);\n });\n }\n }\n\n async load() {\n // wait for the current call stack to finish\n await new Promise((resolve) => {\n (typeof queueMicrotask === 'function'\n ? queueMicrotask\n : requestAnimationFrame)(() => {\n resolve(undefined);\n });\n });\n\n // Abort any in-progress load so the latest src always wins.\n if (this.hostState.stage === 'loading') {\n this.hostState.abortController?.abort();\n this.hostState.stage = 'idle';\n // The aborted load may have already appended partial content to the shadow DOM\n // (styles, component children) before reaching an isCurrentLoad() check.\n // Clear it now so the new load starts from a clean state. Skip this when a\n // React root exists — that means a previous load completed successfully and\n // we'll take the startTransition re-render path instead.\n if (this.root && !this.reactRoot) {\n this.root.innerHTML = '';\n this.fouc = null;\n this.fallbackSlot = document.createElement('slot');\n this.root.appendChild(this.fallbackSlot);\n }\n }\n\n if (!this.root) {\n this.root = this.attachShadow({\n mode: this.mode === 'closed' ? 'closed' : 'open',\n });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.root.appendChild(this.fallbackSlot);\n }\n\n this.name = this.getAttribute('name') || this.name;\n\n this.hostState.stage = 'loading';\n const src = this.src;\n\n // Create AbortController for this load operation\n this.hostState.abortController = new AbortController();\n const signal = this.hostState.abortController.signal;\n\n // Returns true if this is still the active load — the signal hasn't been\n // aborted by a newer load() call, and the src hasn't changed in the meantime.\n // Checking the signal (not just the src) handles the case where the user\n // cycles back to the same src (e.g. styled → basic → styled): both loads\n // share the same src string, so a src-only check would pass for both,\n // causing double renders.\n const isCurrentLoad = () => !signal.aborted && this.src === src;\n\n // Resets stage to 'idle' for expected cancellations (AbortError). Real\n // errors are thrown and caught by attributeChangedCallback which sets\n // stage to 'error'. Only resets if no newer load() has superseded this\n // one — a new load replaces the abortController so the signal comparison\n // fails, preventing us from clobbering the new load's stage.\n const abandonLoad = () => {\n if (\n this.hostState.abortController?.signal === signal &&\n this.hostState.stage === 'loading'\n ) {\n this.hostState.stage = 'idle';\n }\n };\n\n this.emitter.beforeLoad(src ?? '');\n\n const remoteComponentChild =\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.querySelector('div[data-bundle][data-route]');\n\n if (!src && !remoteComponentChild) {\n throw new RemoteComponentsError('\"src\" attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (src) {\n url = getClientOrServerUrl(src, window.location.href);\n this.name = resolveNameFromSrc(src, this.name);\n }\n\n const resolveClientUrl = url\n ? bindResolveClientUrl(this.resolveClientUrl, url.href)\n : undefined;\n\n if (!remoteComponentChild && url) {\n // fetch the remote component\n const fetchInit = {\n credentials: this.credentials || 'same-origin',\n } as RequestInit;\n\n const resolvedUrl = new URL(\n resolveClientUrl?.(url.href) ?? url.href,\n window.location.href,\n );\n let res: Response;\n try {\n res = await fetchWithHooks(resolvedUrl, fetchInit, {\n onRequest: this.onRequest,\n onResponse: this.onResponse,\n abortController: this.hostState.abortController,\n });\n } catch (e) {\n if (isAbortError(e)) {\n return abandonLoad();\n }\n throw e;\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 - race with abort signal\n try {\n html = await res.text();\n } catch (e) {\n if (isAbortError(e)) {\n return abandonLoad();\n }\n throw e;\n }\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n }\n\n const effectiveUrl = url ?? new URL(window.location.href);\n const { doc, parsed } = preparePipeline({\n html,\n name: this.name,\n url: effectiveUrl,\n shared: {},\n resolveClientUrl,\n });\n const {\n component,\n name: resolvedName,\n isRemoteComponent,\n metadata: parsedMetadata,\n nextData,\n rsc,\n remoteShared,\n } = parsed;\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development' && !this.reactRoot) {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.root.appendChild(this.fouc);\n }\n\n this.name = resolvedName;\n this.bundle = parsedMetadata.bundle;\n\n if (url) {\n getNamespace().bundleUrls[this.bundle] = url;\n }\n\n // add remote component metadata information at the custom element\n const metadataEl = document.createElement('script');\n metadataEl.type = 'application/json';\n metadataEl.setAttribute('data-remote-component', '');\n const metadataObj = {\n name: this.name,\n bundle: this.bundle,\n route: parsedMetadata.route,\n runtime: parsedMetadata.runtime,\n };\n metadataEl.textContent = JSON.stringify(metadataObj);\n\n if (\n this.previousElementSibling?.getAttribute('data-remote-component') !==\n null\n ) {\n this.previousElementSibling?.remove();\n }\n this.parentElement?.insertBefore(metadataEl, this);\n\n if (this.hostState.prevIsRemoteComponent) {\n if (this.hostState.prevUrl) {\n const prevUrl = this.hostState.prevUrl;\n const nsUnmount = getNamespace();\n if (nsUnmount.unmountFns[prevUrl.href]) {\n // call unmount() for all registered unmount functions for the previous remote component\n await Promise.all(\n Array.from(nsUnmount.unmountFns[prevUrl.href] ?? []).map(\n async (unmount) => {\n try {\n await unmount(this.root);\n } catch (e) {\n logError(\n 'HtmlHost',\n `Error while calling unmount() for Remote Component from ${prevUrl.href}.`,\n e,\n );\n }\n },\n ),\n );\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n }\n }\n this.root.innerHTML = '';\n }\n // Dispatch change event if this is not the first load\n if (this.hostState.prevSrc !== undefined) {\n this.emitter.change({\n previousSrc: this.hostState.prevSrc ?? null,\n nextSrc: src ?? null,\n previousName: this.hostState.prevName,\n nextName: this.name,\n });\n }\n\n this.hostState.prevUrl = effectiveUrl;\n this.hostState.prevIsRemoteComponent = isRemoteComponent;\n this.hostState.prevSrc = src;\n this.hostState.prevName = this.name;\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n const remoteComponentSrc = this.src ? String(this.src) : null;\n\n // Bound function for attaching styles — used both initially and in React effects\n const doAttachStyles = () =>\n attachStyles({\n doc,\n component,\n links,\n signal: undefined, // Effects run after load, no abort needed\n baseUrl: url?.href,\n remoteComponentSrc,\n root: this.root ?? null,\n resolveClientUrl,\n });\n\n if (!this.reactRoot) {\n // ensure all styles are loaded before hydrating to prevent FOUC\n await attachStyles({\n doc,\n component,\n links,\n signal,\n baseUrl: url?.href,\n remoteComponentSrc,\n root: this.root,\n resolveClientUrl,\n });\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n }\n\n if (!this.reactRoot) {\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n if (!isRemoteComponent && el.tagName.toLowerCase() === 'script') {\n const newScript = document.createElement('script');\n // copy all attributes\n for (const attr of el.attributes) {\n if (attr.name === 'src') {\n const absoluteSrc = new URL(\n attr.value,\n url ?? window.location.origin,\n ).href;\n newScript.setAttribute(\n attr.name,\n resolveClientUrl?.(absoluteSrc) ?? absoluteSrc,\n );\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n newScript.textContent = el.textContent;\n if (remoteComponentSrc) {\n newScript.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n this.root?.appendChild(newScript);\n } else {\n const newEl = el.cloneNode(true) as HTMLElement;\n for (const attr of el.attributes) {\n if (attr.name.startsWith('on')) {\n newEl.setAttribute(attr.name, attr.value);\n }\n }\n this.root?.appendChild(newEl);\n }\n });\n }\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.fallbackSlot?.remove();\n\n // function to apply the reset styles to the shadow DOM\n const applyReset = () => {\n if (\n this.reset &&\n !this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n // all initial styles to reset inherited styles leaking from the host page\n const allInitial = document.createElement('link');\n allInitial.setAttribute('data-remote-components-reset', '');\n const css = `:host { all: initial; }`;\n const allInitialHref = URL.createObjectURL(\n new Blob([css], { type: 'text/css' }),\n );\n allInitial.href = allInitialHref;\n allInitial.rel = 'stylesheet';\n // we need to revoke the object URL after the stylesheet is loaded to free up memory\n allInitial.onload = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n allInitial.onerror = () => {\n URL.revokeObjectURL(allInitialHref);\n allInitial.removeAttribute('onload');\n };\n this.root?.prepend(allInitial);\n } else if (\n !this.reset &&\n this.root?.querySelector('link[data-remote-components-reset]')\n ) {\n this.root\n .querySelector('link[data-remote-components-reset]')\n ?.remove();\n }\n };\n\n // apply the reset styles if required and not already applied\n if (!this.reactRoot) {\n applyReset();\n }\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n metadataObj.runtime as Runtime,\n effectiveUrl,\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n resolveClientUrl,\n );\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n\n const scripts = isRemoteComponent\n ? component.querySelectorAll<HTMLScriptElement>('script')\n : doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src],script[data-remote-component-entrypoint]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(Array.from(scripts), url, this.bundle, this.name);\n if (!isCurrentLoad()) {\n return abandonLoad();\n }\n\n // remove all script elements from the shadow DOM to prevent re-execution of scripts\n if (isRemoteComponent) {\n Array.from(component.children).forEach((child) => {\n if (child.tagName === 'SCRIPT') {\n child.remove();\n }\n });\n }\n\n // cleanup previous remote component instances when a new remote component is loaded\n // this is required when the src attribute is changed to load a new remote component\n const doCleanup = () => {\n if (this.root && remoteComponentSrc) {\n const selector = `[data-remote-component-src]:not([data-remote-component-src=\"${remoteComponentSrc}\"])`;\n const prevCleanup = [\n ...this.root.querySelectorAll(selector),\n ...document.body.querySelectorAll(selector),\n ] as HTMLElement[];\n\n if (prevCleanup.length > 0) {\n prevCleanup.forEach((prev) => {\n prev.remove();\n });\n }\n }\n };\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscName = `__remote_component_rsc_${escapeString(\n url.href,\n )}_${escapeString(this.name)}`;\n const rscClone = document.createElement('script');\n rscClone.id = `${rscName}_rsc`;\n rscClone.textContent =\n rsc.textContent?.replace(\n new RegExp(`self\\\\[\"${this.name}\"\\\\]`, 'g'),\n `self[\"${rscName}\"]`,\n ) ?? '';\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n initial,\n }: {\n name: string;\n initial: boolean;\n }) => {\n // convert the RSC flight data array into a ReadableStream\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const stream = createRSCStream(\n rscName,\n self[rscName as RSCKey] ?? [`0:[null]\\n`],\n );\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(stream) as React.ReactNode);\n\n useLayoutEffect(() => {\n // clear the RSC flight data from the global scope to free up memory\n if (self[name as RSCKey]) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete self[name as RSCKey];\n }\n const rscScript = document.getElementById(`${name}_rsc`);\n if (rscScript) {\n rscScript.remove();\n }\n\n doCleanup();\n applyReset();\n if (!initial) {\n doAttachStyles().catch((e: unknown) => {\n logError('HtmlHost', 'Error attaching styles.', e);\n });\n }\n if (isCurrentLoad()) {\n this.hostState.stage = 'loaded';\n }\n\n this.emitter.load(this.src ?? '');\n }, [initial, name]);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(\n <RemoteComponentFromReadableStream\n initial={false}\n name={this.name}\n />,\n );\n });\n return;\n }\n\n // hydrate the remote component using the RSC flight data\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromReadableStream initial name={this.name} />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle,\n nextData.page ?? '/',\n this.root,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n const RemoteComponentFromNext = ((\n NextApp: ReturnType<typeof nextClientPagesLoader>['App'],\n NextComponent: NonNullable<\n ReturnType<typeof nextClientPagesLoader>['Component']\n >,\n remoteComponent = this,\n ) =>\n function RemoteComponentNext({ initial }: { initial: boolean }) {\n useLayoutEffect(() => {\n doCleanup();\n if (!initial) {\n applyReset();\n doAttachStyles().catch((e: unknown) => {\n logError('HtmlHost', 'Error attaching styles.', e);\n });\n }\n if (isCurrentLoad()) {\n remoteComponent.hostState.stage = 'loaded';\n }\n\n remoteComponent.emitter.load(remoteComponent.src ?? '');\n }, [initial, remoteComponent]);\n\n return NextApp ? (\n <NextApp Component={NextComponent} {...nextData.props} />\n ) : (\n <NextComponent {...nextData.props} />\n );\n })(App, Component, this);\n\n // when we already have a React root, we just need to render the new component\n if (this.reactRoot) {\n const root = this.reactRoot;\n startTransition(() => {\n root.render(<RemoteComponentFromNext initial={false} />);\n doCleanup();\n if (isCurrentLoad()) {\n this.hostState.stage = 'loaded';\n }\n });\n return;\n }\n\n // hydrate the remote component using the Next.js pages router\n this.reactRoot = hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.root,\n <RemoteComponentFromNext initial />,\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.root.removeChild(this.fouc);\n }\n } else if (getNamespace().mountFns[url.href]) {\n // using script entrypoint when no RSC or Next.js data is available\n await Promise.all(\n Array.from(getNamespace().mountFns[url.href] ?? []).map(\n async (mount) => {\n try {\n await mount(this.root);\n } catch (e) {\n logError(\n 'HtmlHost',\n `Error while calling mount() for Remote Component from ${url.href}.`,\n e,\n );\n }\n },\n ),\n );\n\n this.emitter.load(this.src ?? '');\n } else {\n this.emitter.load(this.src ?? '');\n }\n\n if (isCurrentLoad()) {\n this.hostState.stage = 'loaded';\n }\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n\nexport function registerSharedModules(\n modules: Record<string, () => Promise<unknown>> = {},\n) {\n const ns = getNamespace();\n Object.entries(modules).forEach(([key, value]) => {\n ns.hostSharedModules[key] = value;\n });\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\ninterface AttachStylesOptions {\n /** The parsed document containing link and style elements */\n doc: Document;\n /** The component element to check if links are already contained */\n component: Element;\n /** Links from the document head */\n links: NodeListOf<HTMLLinkElement>;\n /** AbortSignal to cancel loading */\n signal: AbortSignal | undefined;\n /** Base URL for resolving relative hrefs */\n baseUrl: string | undefined;\n /** Source URL to set as data attribute */\n remoteComponentSrc: string | null;\n /** Root element to append styles to (ShadowRoot or Element) */\n root: ShadowRoot | Element | null;\n /** Callback to transform asset URLs before loading */\n resolveClientUrl?: InternalResolveClientUrl;\n}\n\n/**\n * Attaches link and style elements from a remote component document to the shadow root.\n * Handles abort signals efficiently with a single shared listener for all links.\n *\n * @throws DOMException with name 'AbortError' if signal is aborted\n * @throws RemoteComponentsError if a stylesheet fails to load\n */\nexport async function attachStyles({\n doc,\n component,\n links,\n signal,\n baseUrl,\n remoteComponentSrc,\n root,\n resolveClientUrl,\n}: AttachStylesOptions): Promise<void> {\n // Track appended links for cleanup on abort\n const appendedLinks: HTMLLinkElement[] = [];\n\n // Single shared abort promise - avoids N listeners for N links\n let abortReject: ((error: DOMException) => void) | null = null;\n const abortPromise = new Promise<never>((_, reject) => {\n abortReject = reject;\n });\n const abortHandler = () => {\n // Clean up all pending links on abort\n for (const link of appendedLinks) {\n link.onload = null;\n link.onerror = null;\n link.remove();\n }\n abortReject?.(new DOMException('Aborted', 'AbortError'));\n };\n signal?.addEventListener('abort', abortHandler, { once: true });\n\n try {\n // Attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links)\n .filter((link) => !component.contains(link))\n .map((link) => {\n const newLink = document.createElement('link');\n appendedLinks.push(newLink);\n\n const loadPromise = new Promise<void>((resolve, reject) => {\n if (link.rel === 'stylesheet') {\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 newLink.onload = () => resolve();\n newLink.onerror = () =>\n reject(\n new RemoteComponentsError(\n `Failed to load <link href=\"${link.href}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n } else {\n resolve();\n }\n });\n\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n const absoluteHref = new URL(\n attr.value,\n baseUrl ?? location.origin,\n ).href;\n newLink.setAttribute(\n attr.name,\n resolveClientUrl?.(absoluteHref) ?? absoluteHref,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n\n if (remoteComponentSrc) {\n newLink.setAttribute(\n 'data-remote-component-src',\n remoteComponentSrc,\n );\n }\n\n // 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 root?.appendChild(newLink);\n\n // Race each link load against the shared abort promise\n return Promise.race([loadPromise, abortPromise]);\n }),\n );\n } finally {\n signal?.removeEventListener('abort', abortHandler);\n }\n\n // Attach inline styles from the document head\n const styles = doc.querySelectorAll<HTMLStyleElement>('style');\n for (const style of styles) {\n if (style.parentElement?.tagName.toLowerCase() === 'head') {\n const newStyle = document.createElement('style');\n newStyle.textContent = style.textContent;\n\n if (remoteComponentSrc) {\n newStyle.setAttribute('data-remote-component-src', remoteComponentSrc);\n }\n\n root?.appendChild(newStyle);\n }\n }\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\nexport type Runtime = 'webpack' | 'turbopack' | 'script' | 'unknown';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(\n url,\n bundle,\n shared,\n remoteShared,\n resolveClientUrl,\n );\n } else if (type === 'script') {\n const { scriptRuntime } = await import(`./script`);\n return scriptRuntime(resolveClientUrl);\n }\n throw new RemoteComponentsError(\n `Remote Components runtime \"${type}\" is not supported. Supported runtimes are \"webpack\", \"turbopack\", and \"script\".`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,mBAAmB;;;AC4B5B,eAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AAErC,QAAM,gBAAmC,CAAC;AAG1C,MAAI,cAAsD;AAC1D,QAAM,eAAe,IAAI,QAAe,CAAC,GAAG,WAAW;AACrD,kBAAc;AAAA,EAChB,CAAC;AACD,QAAM,eAAe,MAAM;AAEzB,eAAW,QAAQ,eAAe;AAChC,WAAK,SAAS;AACd,WAAK,UAAU;AACf,WAAK,OAAO;AAAA,IACd;AACA,kBAAc,IAAI,aAAa,WAAW,YAAY,CAAC;AAAA,EACzD;AACA,UAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK,CAAC;AAE9D,MAAI;AAEF,UAAM,QAAQ;AAAA,MACZ,MAAM,KAAK,KAAK,EACb,OAAO,CAAC,SAAS,CAAC,UAAU,SAAS,IAAI,CAAC,EAC1C,IAAI,CAAC,SAAS;AACb,cAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,sBAAc,KAAK,OAAO;AAE1B,cAAM,cAAc,IAAI,QAAc,CAAC,SAAS,WAAW;AACzD,cAAI,KAAK,QAAQ,cAAc;AAE7B,oBAAQ,SAAS,MAAM,QAAQ;AAC/B,oBAAQ,UAAU,MAChB;AAAA,cACE,IAAI;AAAA,gBACF,8BAA8B,KAAK;AAAA,cACrC;AAAA,YACF;AAAA,UACJ,OAAO;AACL,oBAAQ;AAAA,UACV;AAAA,QACF,CAAC;AAED,mBAAW,QAAQ,KAAK,YAAY;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wBAAU;AACV,kBAAI,cAAc,GAAG;AACnB,qBAAK,UAAU,QAAQ;AAAA,cACzB;AAAA,YACF,CAAC;AACD;AAAA,UACF;AAGA,eAAK,YAAY;AAAA;AAAA;AAAA,YAGf,KAAK;AAAA,YACL,oBAAC,2BAAwB,SAAO,MAAC;AAAA,UACnC;AAAA,QACF;AAIA,YAAI,KAAK,MAAM;AACb,eAAK,KAAK,YAAY,KAAK,IAAI;AAAA,QACjC;AAAA,MACF,WAAW,aAAa,EAAE,SAAS,IAAI,IAAI,GAAG;AAE5C,cAAM,QAAQ;AAAA,UACZ,MAAM,KAAK,aAAa,EAAE,SAAS,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE;AAAA,YAClD,OAAO,UAAU;AACf,kBAAI;AACF,sBAAM,MAAM,KAAK,IAAI;AAAA,cACvB,SAAS,GAAP;AACA;AAAA,kBACE;AAAA,kBACA,yDAAyD,IAAI;AAAA,kBAC7D;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,aAAK,QAAQ,KAAK,KAAK,OAAO,EAAE;AAAA,MAClC,OAAO;AACL,aAAK,QAAQ,KAAK,KAAK,OAAO,EAAE;AAAA,MAClC;AAEA,UAAI,cAAc,GAAG;AACnB,aAAK,UAAU,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAGA,iBAAe,OAAO,oBAAoB,eAAe;AAC3D;AAEO,SAAS,sBACd,UAAkD,CAAC,GACnD;AACA,QAAM,KAAK,aAAa;AACxB,SAAO,QAAQ,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChD,OAAG,kBAAkB,GAAG,IAAI;AAAA,EAC9B,CAAC;AACH;","names":[]}
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkN3SQTOSEcjs = require('../chunk-N3SQTOSE.cjs');
4
+ require('../chunk-5KTAEO52.cjs');
5
+
6
+
7
+ exports.onRemoteNavigate = _chunkN3SQTOSEcjs.onRemoteNavigate;
8
+ //# sourceMappingURL=navigation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import { R as RemoteNavigateEvent } from '../navigate-event-baee0b63.js';
2
+
3
+ /**
4
+ * Subscribe to navigation requests from remote components. One subscription
5
+ * handles every `<ConsumeRemoteComponent>` on the page. SSR-safe: no-op when
6
+ * `window` is undefined.
7
+ *
8
+ * In React, prefer `useRemoteNavigate` from `remote-components/host/react` —
9
+ * it avoids re-registering the listener on every render.
10
+ *
11
+ * @example React Router
12
+ * ```ts
13
+ * useEffect(
14
+ * () =>
15
+ * onRemoteNavigate((e) =>
16
+ * navigate(e.pathname + e.search, { replace: e.type === 'replace' }),
17
+ * ),
18
+ * [navigate],
19
+ * );
20
+ * ```
21
+ *
22
+ * @example Plain HTML
23
+ * ```ts
24
+ * // Always replace — the polyfill already pushed/replaced the browser history entry.
25
+ * onRemoteNavigate((e) => window.location.replace(e.url));
26
+ * ```
27
+ */
28
+ declare function onRemoteNavigate(callback: (event: RemoteNavigateEvent) => void): () => void;
29
+
30
+ export { RemoteNavigateEvent, onRemoteNavigate };
@@ -0,0 +1,8 @@
1
+ import {
2
+ onRemoteNavigate
3
+ } from "../chunk-RHGEBXPL.js";
4
+ import "../chunk-STIJO4AG.js";
5
+ export {
6
+ onRemoteNavigate
7
+ };
8
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,24 +1,26 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
2
 
3
3
 
4
- var _chunkAWWWK2ZYcjs = require('../../../chunk-AWWWK2ZY.cjs');
4
+ var _chunkY4GMYUJTcjs = require('../../../chunk-Y4GMYUJT.cjs');
5
5
 
6
6
 
7
- var _chunkI47KE3ECcjs = require('../../../chunk-I47KE3EC.cjs');
8
- require('../../../chunk-LCXO7BUY.cjs');
9
- require('../../../chunk-RJW3EZJP.cjs');
10
- require('../../../chunk-T64P7BAG.cjs');
7
+ var _chunkAYC2AWUGcjs = require('../../../chunk-AYC2AWUG.cjs');
8
+ require('../../../chunk-42TVDI3G.cjs');
9
+ require('../../../chunk-EYALF655.cjs');
10
+ require('../../../chunk-JJTCFQHE.cjs');
11
11
  require('../../../chunk-TZT7DLO5.cjs');
12
+ require('../../../chunk-N3SQTOSE.cjs');
12
13
 
13
14
 
14
15
 
15
- var _chunkX6W464D6cjs = require('../../../chunk-X6W464D6.cjs');
16
+ var _chunkRLI4YTBJcjs = require('../../../chunk-RLI4YTBJ.cjs');
16
17
  require('../../../chunk-Z2SLBFQL.cjs');
18
+ require('../../../chunk-5KTAEO52.cjs');
17
19
 
18
20
 
19
21
  var _chunkRUWR74XQcjs = require('../../../chunk-RUWR74XQ.cjs');
20
- require('../../../chunk-TCFLEBQM.cjs');
21
22
  require('../../../chunk-KE7QPAQ4.cjs');
23
+ require('../../../chunk-TCFLEBQM.cjs');
22
24
  require('../../../chunk-SHFJ5OQA.cjs');
23
25
 
24
26
  // src/host/nextjs/app-client-only.tsx
@@ -29,8 +31,8 @@ var _react = require('react');
29
31
  function resolveForBundle(unbound, bundle) {
30
32
  if (!unbound)
31
33
  return void 0;
32
- const remoteSrc = _nullishCoalesce(_optionalChain([_chunkX6W464D6cjs.getScope.call(void 0, bundle), 'optionalAccess', _2 => _2.url, 'access', _3 => _3.href]), () => ( ""));
33
- return _chunkI47KE3ECcjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
34
+ const remoteSrc = _nullishCoalesce(_optionalChain([_chunkRLI4YTBJcjs.getScope.call(void 0, bundle), 'optionalAccess', _2 => _2.url, 'access', _3 => _3.href]), () => ( ""));
35
+ return _chunkAYC2AWUGcjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
34
36
  }
35
37
  function createImageLoaderSharedEntries({
36
38
  bound,
@@ -39,13 +41,13 @@ function createImageLoaderSharedEntries({
39
41
  const loaderEntry = (bundle) => {
40
42
  const resolveClientUrl = _nullishCoalesce(bound, () => ( resolveForBundle(unbound, bundle)));
41
43
  return Promise.resolve({
42
- default: _chunkX6W464D6cjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl),
44
+ default: _chunkRLI4YTBJcjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl),
43
45
  __esModule: true
44
46
  });
45
47
  };
46
48
  const imageEntry = async (bundle) => {
47
49
  const resolveClientUrl = _nullishCoalesce(bound, () => ( resolveForBundle(unbound, bundle)));
48
- const rawLoader = _chunkX6W464D6cjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl);
50
+ const rawLoader = _chunkRLI4YTBJcjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl);
49
51
  const remoteLoader = Object.assign(
50
52
  (p) => rawLoader({ ...p, config: { path: "/_next/image" } }),
51
53
  { __next_img_default: true }
@@ -189,7 +191,7 @@ function ConsumeRemoteComponent2(props) {
189
191
  return _nullishCoalesce(props.children, () => ( null));
190
192
  }
191
193
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
192
- _chunkAWWWK2ZYcjs.ConsumeRemoteComponent,
194
+ _chunkY4GMYUJTcjs.ConsumeRemoteComponent,
193
195
  {
194
196
  ...props,
195
197
  shared: sharedModules(props.shared, props.resolveClientUrl)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/host/nextjs/app-client-only.tsx","../../../../src/host/nextjs/image-shared.ts","../../../../src/host/nextjs/shared-import.ts","../../../../src/host/nextjs/app-compat.tsx"],"names":["ConsumeRemoteComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,eAAe;;;ACHxB,SAAS,eAAe,kBAAkB;AAW1C,SAAS,iBACP,SACA,QACsC;AACtC,MAAI,CAAC;AAAS,WAAO;AACrB,QAAM,YAAY,SAAS,MAAM,GAAG,IAAI,QAAQ;AAChD,SAAO,qBAAqB,SAAS,SAAS;AAChD;AAUO,SAAS,+BAA+B;AAAA,EAC7C;AAAA,EACA;AACF,IAGI,CAAC,GAAsC;AACzC,QAAM,cAAiC,CAAC,WAAmB;AACzD,UAAM,mBAAmB,SAAS,iBAAiB,SAAS,MAAM;AAClE,WAAO,QAAQ,QAAQ;AAAA,MACrB,SAAS,wBAAwB,QAAQ,gBAAgB;AAAA,MACzD,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAKA,QAAM,aAAgC,OAAO,WAAmB;AAC9D,UAAM,mBAAmB,SAAS,iBAAiB,SAAS,MAAM;AAClE,UAAM,YAAY,wBAAwB,QAAQ,gBAAgB;AAIlE,UAAM,eAAe,OAAO;AAAA,MAC1B,CAAC,MACC,UAAU,EAAE,GAAG,GAAG,QAAQ,EAAE,MAAM,eAAe,EAAE,CAAC;AAAA,MACtD,EAAE,oBAAoB,KAAc;AAAA,IACtC;AACA,UAAM,MAAM,MAAM,OAAO,YAAY;AACrC,UAAM,gBAAgB,IAAI;AAE1B,UAAM,cAAc;AAAA,MAAyC,CAAC,OAAO,QACnE,cAAc,eAAe;AAAA,QAC3B,GAAG;AAAA,QACH,QAAQ,MAAM,UAAU;AAAA,QACxB;AAAA,MACF,CAAC;AA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,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,QAAQ,cAAc,MAAM,QAAQ,MAAM,gBAAgB;AAAA;AAAA,EAC5D;AAEJ","sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport { createImageLoaderSharedEntries } from '#internal/host/nextjs/image-shared';\nimport { tryImportShared } from '#internal/host/nextjs/shared-import';\nimport { RemoteComponentsContext } from '#internal/host/react/context';\nimport type { ConsumeClientOnlyConfig } from '#internal/host/shared/config';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport {\n type ConsumeRemoteComponentProps,\n ConsumeRemoteComponent as ConsumeRemoteComponentReact,\n} from '#remote-components/host/react';\nimport { routerImpl } from './app-compat';\n\nconst sharedModules = async (\n userShared?: ConsumeRemoteComponentProps['shared'],\n resolveClientUrl?: ResolveClientUrl,\n) => {\n const [resolvedShared, resolvedUserShared] = await Promise.all([\n tryImportShared(),\n userShared ?? Promise.resolve({}),\n ]);\n return {\n ...resolvedShared,\n 'next/router': routerImpl,\n ...createImageLoaderSharedEntries({ unbound: resolveClientUrl }),\n ...resolvedUserShared,\n };\n};\n\n/**\n * Provider for Next.js App Router hosts. Provides real Next.js implementations\n * of `next/image`, `next/navigation`, `next/link`, etc. to all nested\n * `<ConsumeRemoteComponent>` instances.\n *\n * Works in both Server and Client Components — set it up once in your layout\n * and use `<ConsumeRemoteComponent>` from `remote-components/react` everywhere:\n *\n * ```tsx\n * import { RemoteComponentsClientProvider } from 'remote-components/host/nextjs/app/client-only';\n *\n * <RemoteComponentsClientProvider resolveClientUrl={proxyClientRequestsThroughHost}>\n * {children}\n * </RemoteComponentsClientProvider>\n * ```\n */\nexport function RemoteComponentsClientProvider({\n shared,\n resolveClientUrl,\n children,\n ...props\n}: ConsumeClientOnlyConfig & { children: React.ReactNode }) {\n const mergedShared = useMemo(\n () => sharedModules(shared, resolveClientUrl),\n [shared, resolveClientUrl],\n );\n return (\n <RemoteComponentsContext\n value={{ shared: mergedShared, resolveClientUrl, ...props }}\n >\n {children}\n </RemoteComponentsContext>\n );\n}\n\n/**\n * `ConsumeRemoteComponent` for Next.js App Router hosts. Provides real Next.js\n * implementations of `next/image`, `next/navigation`, `next/link`, etc.\n *\n * The provider approach is recommended because it works in both Server and Client\n * Components — set up `RemoteComponentsClientProvider` from this module once in\n * your layout, and use `<ConsumeRemoteComponent>` from `remote-components/react`\n * everywhere. Import this component only when adding a provider is not practical.\n */\nexport function ConsumeRemoteComponent(props: ConsumeRemoteComponentProps) {\n if (typeof props.src !== 'string' && !(props.src instanceof URL)) {\n return props.children ?? null;\n }\n\n return (\n <ConsumeRemoteComponentReact\n {...props}\n shared={sharedModules(props.shared, props.resolveClientUrl)}\n />\n );\n}\n","import { createElement, forwardRef } from 'react';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport type {\n InternalResolveClientUrl,\n ResolveClientUrl,\n} from '#internal/runtime/url/resolve-client-url';\n\ntype SharedImageModule = (bundle: string) => Promise<unknown>;\n\nfunction resolveForBundle(\n unbound: ResolveClientUrl | undefined,\n bundle: string,\n): InternalResolveClientUrl | undefined {\n if (!unbound) return undefined;\n const remoteSrc = getScope(bundle)?.url.href ?? '';\n return bindResolveClientUrl(unbound, remoteSrc);\n}\n\n/**\n * Creates shared module entries for image-related modules that route\n * optimization requests through the remote's `/_next/image` endpoint.\n *\n * Pass `bound` when the resolver already has `remoteSrc` applied (App Router).\n * Pass `unbound` when only the raw 2-arg `ResolveClientUrl` is available\n * (Pages Router, client-only provider).\n */\nexport function createImageLoaderSharedEntries({\n bound,\n unbound,\n}: {\n bound?: InternalResolveClientUrl;\n unbound?: ResolveClientUrl;\n} = {}): Record<string, SharedImageModule> {\n const loaderEntry: SharedImageModule = (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n return Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n });\n };\n\n // Cross-version compat: remotes <=0.2.x request `next/image` as a shared module.\n // Wraps the host's Image component with the remote image loader injected\n // via the `loader` prop. Can be removed once 0.2.x support is dropped.\n const imageEntry: SharedImageModule = async (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n const rawLoader = createRemoteImageLoader(bundle, resolveClientUrl);\n // Wrap to match Next.js `ImageLoader` signature (no `config` param).\n // The raw loader expects `{ config, src, width, quality }` but the public\n // `loader` prop is called with `{ src, width, quality }` only.\n const remoteLoader = Object.assign(\n (p: { src: string; width: number; quality?: number }) =>\n rawLoader({ ...p, config: { path: '/_next/image' } }),\n { __next_img_default: true as const },\n );\n const mod = await import('next/image');\n const OriginalImage = mod.default;\n type ImageProps = Parameters<typeof OriginalImage>[0];\n const RemoteImage = forwardRef<HTMLImageElement, ImageProps>((props, ref) =>\n createElement(OriginalImage, {\n ...props,\n loader: props.loader ?? remoteLoader,\n ref,\n }),\n );\n RemoteImage.displayName = 'RemoteImage';\n return { ...mod, default: RemoteImage, __esModule: true };\n };\n\n return {\n 'next/dist/shared/lib/image-loader': loaderEntry,\n 'next/dist/esm/shared/lib/image-loader': loaderEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/image': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/client/image-component': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/api/image': imageEntry,\n };\n}\n","export async function tryImportShared() {\n try {\n const { shared } = await import('#remote-components/host/defaults/app');\n return shared;\n } catch {\n return {};\n }\n}\n","import type { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport { logWarn } from '#internal/utils/logger';\n\nexport const routerImpl = async () => {\n const { useRouter } = await import('next/navigation');\n return Promise.resolve({\n useRouter: () => {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const query = Object.fromEntries(searchParams.entries());\n return {\n pathname,\n query,\n asPath: searchParams.toString()\n ? `${pathname}?${searchParams.toString()}`\n : pathname,\n push: (href: string, _: string, options?: NavigateOptions) => {\n router.push(href, options);\n return Promise.resolve(true);\n },\n replace: (href: string, _: string, options?: NavigateOptions) => {\n router.replace(href, options);\n return Promise.resolve(true);\n },\n refresh: () => Promise.resolve(router.refresh()),\n prefetch: async () => {\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.prefetch() in a remote component loaded in the Next.js App Router. prefetch() is a no-op in the App Router.',\n );\n return Promise.resolve();\n },\n back: () => {\n // there's no back() in the App Router\n if (typeof window !== 'undefined') {\n window.history.back();\n }\n },\n reload: () => {\n router.refresh();\n },\n beforePopState: () => {\n // there's no beforePopState() in the App Router\n },\n events: {\n on: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.on() in a remote component loaded in the Next.js App Router. events.on() is a no-op in the App Router.',\n );\n },\n off: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.off() in a remote component loaded in the Next.js App Router. events.off() is a no-op in the App Router.',\n );\n },\n emit: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.emit() in a remote component loaded in the Next.js App Router. events.emit() is a no-op in the App Router.',\n );\n },\n },\n };\n },\n });\n};\n"]}
1
+ {"version":3,"sources":["../../../../src/host/nextjs/app-client-only.tsx","../../../../src/host/nextjs/image-shared.ts","../../../../src/host/nextjs/shared-import.ts","../../../../src/host/nextjs/app-compat.tsx"],"names":["ConsumeRemoteComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,eAAe;;;ACHxB,SAAS,eAAe,kBAAkB;AAW1C,SAAS,iBACP,SACA,QACsC;AACtC,MAAI,CAAC;AAAS,WAAO;AACrB,QAAM,YAAY,SAAS,MAAM,GAAG,IAAI,QAAQ;AAChD,SAAO,qBAAqB,SAAS,S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gBAAgB,OACpB,YACA,qBACG;AACH,QAAM,CAAC,gBAAgB,kBAAkB,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC7D,gBAAgB;AAAA,IAChB,cAAc,QAAQ,QAAQ,CAAC,CAAC;AAAA,EAClC,CAAC;AACD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe;AAAA,IACf,GAAG,+BAA+B,EAAE,SAAS,iBAAiB,CAAC;AAAA,IAC/D,GAAG;AAAA,EACL;AACF;AAkBO,SAAS,+BAA+B;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA4D;AAC1D,QAAM,eAAe;AAAA,IACnB,MAAM,cAAc,QAAQ,gBAAgB;AAAA,IAC5C,CAAC,QAAQ,gBAAgB;AAAA,EAC3B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,QAAQ,cAAc,kBAAkB,GAAG,MAAM;AAAA,MAEzD;AAAA;AAAA,EACH;AAEJ;AAWO,SAASA,wBAAuB,OAAoC;AACzE,MAAI,OAAO,MAAM,QAAQ,YAAY,EAAE,MAAM,eAAe,MAAM;AAChE,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,QAAQ,cAAc,MAAM,QAAQ,MAAM,gBAAgB;AAAA;AAAA,EAC5D;AAEJ","sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport { createImageLoaderSharedEntries } from '#internal/host/nextjs/image-shared';\nimport { tryImportShared } from '#internal/host/nextjs/shared-import';\nimport { RemoteComponentsContext } from '#internal/host/react/context';\nimport type { ConsumeClientOnlyConfig } from '#internal/host/shared/config';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport {\n type ConsumeRemoteComponentProps,\n ConsumeRemoteComponent as ConsumeRemoteComponentReact,\n} from '#remote-components/host/react';\nimport { routerImpl } from './app-compat';\n\nconst sharedModules = async (\n userShared?: ConsumeRemoteComponentProps['shared'],\n resolveClientUrl?: ResolveClientUrl,\n) => {\n const [resolvedShared, resolvedUserShared] = await Promise.all([\n tryImportShared(),\n userShared ?? Promise.resolve({}),\n ]);\n return {\n ...resolvedShared,\n 'next/router': routerImpl,\n ...createImageLoaderSharedEntries({ unbound: resolveClientUrl }),\n ...resolvedUserShared,\n };\n};\n\n/**\n * Provider for Next.js App Router hosts. Provides real Next.js implementations\n * of `next/image`, `next/navigation`, `next/link`, etc. to all nested\n * `<ConsumeRemoteComponent>` instances.\n *\n * Works in both Server and Client Components — set it up once in your layout\n * and use `<ConsumeRemoteComponent>` from `remote-components/react` everywhere:\n *\n * ```tsx\n * import { RemoteComponentsClientProvider } from 'remote-components/host/nextjs/app/client-only';\n *\n * <RemoteComponentsClientProvider resolveClientUrl={proxyClientRequestsThroughHost}>\n * {children}\n * </RemoteComponentsClientProvider>\n * ```\n */\nexport function RemoteComponentsClientProvider({\n shared,\n resolveClientUrl,\n children,\n ...props\n}: ConsumeClientOnlyConfig & { children: React.ReactNode }) {\n const mergedShared = useMemo(\n () => sharedModules(shared, resolveClientUrl),\n [shared, resolveClientUrl],\n );\n return (\n <RemoteComponentsContext\n value={{ shared: mergedShared, resolveClientUrl, ...props }}\n >\n {children}\n </RemoteComponentsContext>\n );\n}\n\n/**\n * `ConsumeRemoteComponent` for Next.js App Router hosts. Provides real Next.js\n * implementations of `next/image`, `next/navigation`, `next/link`, etc.\n *\n * The provider approach is recommended because it works in both Server and Client\n * Components — set up `RemoteComponentsClientProvider` from this module once in\n * your layout, and use `<ConsumeRemoteComponent>` from `remote-components/react`\n * everywhere. Import this component only when adding a provider is not practical.\n */\nexport function ConsumeRemoteComponent(props: ConsumeRemoteComponentProps) {\n if (typeof props.src !== 'string' && !(props.src instanceof URL)) {\n return props.children ?? null;\n }\n\n return (\n <ConsumeRemoteComponentReact\n {...props}\n shared={sharedModules(props.shared, props.resolveClientUrl)}\n />\n );\n}\n","import { createElement, forwardRef } from 'react';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport type {\n InternalResolveClientUrl,\n ResolveClientUrl,\n} from '#internal/runtime/url/resolve-client-url';\n\ntype SharedImageModule = (bundle: string) => Promise<unknown>;\n\nfunction resolveForBundle(\n unbound: ResolveClientUrl | undefined,\n bundle: string,\n): InternalResolveClientUrl | undefined {\n if (!unbound) return undefined;\n const remoteSrc = getScope(bundle)?.url.href ?? '';\n return bindResolveClientUrl(unbound, remoteSrc);\n}\n\n/**\n * Creates shared module entries for image-related modules that route\n * optimization requests through the remote's `/_next/image` endpoint.\n *\n * Pass `bound` when the resolver already has `remoteSrc` applied (App Router).\n * Pass `unbound` when only the raw 2-arg `ResolveClientUrl` is available\n * (Pages Router, client-only provider).\n */\nexport function createImageLoaderSharedEntries({\n bound,\n unbound,\n}: {\n bound?: InternalResolveClientUrl;\n unbound?: ResolveClientUrl;\n} = {}): Record<string, SharedImageModule> {\n const loaderEntry: SharedImageModule = (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n return Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n });\n };\n\n // Cross-version compat: remotes <=0.2.x request `next/image` as a shared module.\n // Wraps the host's Image component with the remote image loader injected\n // via the `loader` prop. Can be removed once 0.2.x support is dropped.\n const imageEntry: SharedImageModule = async (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n const rawLoader = createRemoteImageLoader(bundle, resolveClientUrl);\n // Wrap to match Next.js `ImageLoader` signature (no `config` param).\n // The raw loader expects `{ config, src, width, quality }` but the public\n // `loader` prop is called with `{ src, width, quality }` only.\n const remoteLoader = Object.assign(\n (p: { src: string; width: number; quality?: number }) =>\n rawLoader({ ...p, config: { path: '/_next/image' } }),\n { __next_img_default: true as const },\n );\n const mod = await import('next/image');\n const OriginalImage = mod.default;\n type ImageProps = Parameters<typeof OriginalImage>[0];\n const RemoteImage = forwardRef<HTMLImageElement, ImageProps>((props, ref) =>\n createElement(OriginalImage, {\n ...props,\n loader: props.loader ?? remoteLoader,\n ref,\n }),\n );\n RemoteImage.displayName = 'RemoteImage';\n return { ...mod, default: RemoteImage, __esModule: true };\n };\n\n return {\n 'next/dist/shared/lib/image-loader': loaderEntry,\n 'next/dist/esm/shared/lib/image-loader': loaderEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/image': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/client/image-component': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/api/image': imageEntry,\n };\n}\n","export async function tryImportShared() {\n try {\n const { shared } = await import('#remote-components/host/defaults/app');\n return shared;\n } catch {\n return {};\n }\n}\n","import type { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport { logWarn } from '#internal/utils/logger';\n\nexport const routerImpl = async () => {\n const { useRouter } = await import('next/navigation');\n return Promise.resolve({\n useRouter: () => {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const query = Object.fromEntries(searchParams.entries());\n return {\n pathname,\n query,\n asPath: searchParams.toString()\n ? `${pathname}?${searchParams.toString()}`\n : pathname,\n push: (href: string, _: string, options?: NavigateOptions) => {\n router.push(href, options);\n return Promise.resolve(true);\n },\n replace: (href: string, _: string, options?: NavigateOptions) => {\n router.replace(href, options);\n return Promise.resolve(true);\n },\n refresh: () => Promise.resolve(router.refresh()),\n prefetch: async () => {\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.prefetch() in a remote component loaded in the Next.js App Router. prefetch() is a no-op in the App Router.',\n );\n return Promise.resolve();\n },\n back: () => {\n // there's no back() in the App Router\n if (typeof window !== 'undefined') {\n window.history.back();\n }\n },\n reload: () => {\n router.refresh();\n },\n beforePopState: () => {\n // there's no beforePopState() in the App Router\n },\n events: {\n on: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.on() in a remote component loaded in the Next.js App Router. events.on() is a no-op in the App Router.',\n );\n },\n off: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.off() in a remote component loaded in the Next.js App Router. events.off() is a no-op in the App Router.',\n );\n },\n emit: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.emit() in a remote component loaded in the Next.js App Router. events.emit() is a no-op in the App Router.',\n );\n },\n },\n };\n },\n });\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { C as ConsumeClientOnlyConfig, a as ConsumeRemoteComponentProps } from '../../../index-4c65355c.js';
3
+ import { C as ConsumeClientOnlyConfig, a as ConsumeRemoteComponentProps } from '../../../index-d2ce8a3f.js';
4
+ import '../../../navigate-event-baee0b63.js';
4
5
 
5
6
  /**
6
7
  * Provider for Next.js App Router hosts. Provides real Next.js implementations
@@ -1,24 +1,26 @@
1
1
  "use client";
2
2
  import {
3
3
  ConsumeRemoteComponent
4
- } from "../../../chunk-GBFUPMMI.js";
4
+ } from "../../../chunk-NN5V3FVD.js";
5
5
  import {
6
6
  bindResolveClientUrl
7
- } from "../../../chunk-NZAB7REE.js";
8
- import "../../../chunk-SZFCBE54.js";
9
- import "../../../chunk-QKB74MLO.js";
10
- import "../../../chunk-52BJ7VFA.js";
7
+ } from "../../../chunk-5WL3FP4V.js";
8
+ import "../../../chunk-AKOMV2UF.js";
9
+ import "../../../chunk-N3KPUFOB.js";
10
+ import "../../../chunk-MKO52FRO.js";
11
11
  import "../../../chunk-LQ7VQ74E.js";
12
+ import "../../../chunk-RHGEBXPL.js";
12
13
  import {
13
14
  createRemoteImageLoader,
14
15
  getScope
15
- } from "../../../chunk-SJM7AAGU.js";
16
+ } from "../../../chunk-SAGYPGIQ.js";
16
17
  import "../../../chunk-D5GNZB6O.js";
18
+ import "../../../chunk-STIJO4AG.js";
17
19
  import {
18
20
  logWarn
19
21
  } from "../../../chunk-S2A4TFLS.js";
20
- import "../../../chunk-GAXJTFBV.js";
21
22
  import "../../../chunk-X6YKUJKH.js";
23
+ import "../../../chunk-GAXJTFBV.js";
22
24
  import "../../../chunk-ENYGL5CO.js";
23
25
 
24
26
  // src/host/nextjs/app-client-only.tsx
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/host/nextjs/app-client-only.tsx","../../../../src/host/nextjs/image-shared.ts","../../../../src/host/nextjs/shared-import.ts","../../../../src/host/nextjs/app-compat.tsx"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport { createImageLoaderSharedEntries } from '#internal/host/nextjs/image-shared';\nimport { tryImportShared } from '#internal/host/nextjs/shared-import';\nimport { RemoteComponentsContext } from '#internal/host/react/context';\nimport type { ConsumeClientOnlyConfig } from '#internal/host/shared/config';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport {\n type ConsumeRemoteComponentProps,\n ConsumeRemoteComponent as ConsumeRemoteComponentReact,\n} from '#remote-components/host/react';\nimport { routerImpl } from './app-compat';\n\nconst sharedModules = async (\n userShared?: ConsumeRemoteComponentProps['shared'],\n resolveClientUrl?: ResolveClientUrl,\n) => {\n const [resolvedShared, resolvedUserShared] = await Promise.all([\n tryImportShared(),\n userShared ?? Promise.resolve({}),\n ]);\n return {\n ...resolvedShared,\n 'next/router': routerImpl,\n ...createImageLoaderSharedEntries({ unbound: resolveClientUrl }),\n ...resolvedUserShared,\n };\n};\n\n/**\n * Provider for Next.js App Router hosts. Provides real Next.js implementations\n * of `next/image`, `next/navigation`, `next/link`, etc. to all nested\n * `<ConsumeRemoteComponent>` instances.\n *\n * Works in both Server and Client Components — set it up once in your layout\n * and use `<ConsumeRemoteComponent>` from `remote-components/react` everywhere:\n *\n * ```tsx\n * import { RemoteComponentsClientProvider } from 'remote-components/host/nextjs/app/client-only';\n *\n * <RemoteComponentsClientProvider resolveClientUrl={proxyClientRequestsThroughHost}>\n * {children}\n * </RemoteComponentsClientProvider>\n * ```\n */\nexport function RemoteComponentsClientProvider({\n shared,\n resolveClientUrl,\n children,\n ...props\n}: ConsumeClientOnlyConfig & { children: React.ReactNode }) {\n const mergedShared = useMemo(\n () => sharedModules(shared, resolveClientUrl),\n [shared, resolveClientUrl],\n );\n return (\n <RemoteComponentsContext\n value={{ shared: mergedShared, resolveClientUrl, ...props }}\n >\n {children}\n </RemoteComponentsContext>\n );\n}\n\n/**\n * `ConsumeRemoteComponent` for Next.js App Router hosts. Provides real Next.js\n * implementations of `next/image`, `next/navigation`, `next/link`, etc.\n *\n * The provider approach is recommended because it works in both Server and Client\n * Components — set up `RemoteComponentsClientProvider` from this module once in\n * your layout, and use `<ConsumeRemoteComponent>` from `remote-components/react`\n * everywhere. Import this component only when adding a provider is not practical.\n */\nexport function ConsumeRemoteComponent(props: ConsumeRemoteComponentProps) {\n if (typeof props.src !== 'string' && !(props.src instanceof URL)) {\n return props.children ?? null;\n }\n\n return (\n <ConsumeRemoteComponentReact\n {...props}\n shared={sharedModules(props.shared, props.resolveClientUrl)}\n />\n );\n}\n","import { createElement, forwardRef } from 'react';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport type {\n InternalResolveClientUrl,\n ResolveClientUrl,\n} from '#internal/runtime/url/resolve-client-url';\n\ntype SharedImageModule = (bundle: string) => Promise<unknown>;\n\nfunction resolveForBundle(\n unbound: ResolveClientUrl | undefined,\n bundle: string,\n): InternalResolveClientUrl | undefined {\n if (!unbound) return undefined;\n const remoteSrc = getScope(bundle)?.url.href ?? '';\n return bindResolveClientUrl(unbound, remoteSrc);\n}\n\n/**\n * Creates shared module entries for image-related modules that route\n * optimization requests through the remote's `/_next/image` endpoint.\n *\n * Pass `bound` when the resolver already has `remoteSrc` applied (App Router).\n * Pass `unbound` when only the raw 2-arg `ResolveClientUrl` is available\n * (Pages Router, client-only provider).\n */\nexport function createImageLoaderSharedEntries({\n bound,\n unbound,\n}: {\n bound?: InternalResolveClientUrl;\n unbound?: ResolveClientUrl;\n} = {}): Record<string, SharedImageModule> {\n const loaderEntry: SharedImageModule = (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n return Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n });\n };\n\n // Cross-version compat: remotes <=0.2.x request `next/image` as a shared module.\n // Wraps the host's Image component with the remote image loader injected\n // via the `loader` prop. Can be removed once 0.2.x support is dropped.\n const imageEntry: SharedImageModule = async (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n const rawLoader = createRemoteImageLoader(bundle, resolveClientUrl);\n // Wrap to match Next.js `ImageLoader` signature (no `config` param).\n // The raw loader expects `{ config, src, width, quality }` but the public\n // `loader` prop is called with `{ src, width, quality }` only.\n const remoteLoader = Object.assign(\n (p: { src: string; width: number; quality?: number }) =>\n rawLoader({ ...p, config: { path: '/_next/image' } }),\n { __next_img_default: true as const },\n );\n const mod = await import('next/image');\n const OriginalImage = mod.default;\n type ImageProps = Parameters<typeof OriginalImage>[0];\n const RemoteImage = forwardRef<HTMLImageElement, ImageProps>((props, ref) =>\n createElement(OriginalImage, {\n ...props,\n loader: props.loader ?? remoteLoader,\n ref,\n }),\n );\n RemoteImage.displayName = 'RemoteImage';\n return { ...mod, default: RemoteImage, __esModule: true };\n };\n\n return {\n 'next/dist/shared/lib/image-loader': loaderEntry,\n 'next/dist/esm/shared/lib/image-loader': loaderEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/image': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/client/image-component': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/api/image': imageEntry,\n };\n}\n","export async function tryImportShared() {\n try {\n const { shared } = await import('#remote-components/host/defaults/app');\n return shared;\n } catch {\n return {};\n }\n}\n","import type { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport { logWarn } from '#internal/utils/logger';\n\nexport const routerImpl = async () => {\n const { useRouter } = await import('next/navigation');\n return Promise.resolve({\n useRouter: () => {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const query = Object.fromEntries(searchParams.entries());\n return {\n pathname,\n query,\n asPath: searchParams.toString()\n ? `${pathname}?${searchParams.toString()}`\n : pathname,\n push: (href: string, _: string, options?: NavigateOptions) => {\n router.push(href, options);\n return Promise.resolve(true);\n },\n replace: (href: string, _: string, options?: NavigateOptions) => {\n router.replace(href, options);\n return Promise.resolve(true);\n },\n refresh: () => Promise.resolve(router.refresh()),\n prefetch: async () => {\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.prefetch() in a remote component loaded in the Next.js App Router. prefetch() is a no-op in the App Router.',\n );\n return Promise.resolve();\n },\n back: () => {\n // there's no back() in the App Router\n if (typeof window !== 'undefined') {\n window.history.back();\n }\n },\n reload: () => {\n router.refresh();\n },\n beforePopState: () => {\n // there's no beforePopState() in the App Router\n },\n events: {\n on: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.on() in a remote component loaded in the Next.js App Router. events.on() is a no-op in the App Router.',\n );\n },\n off: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.off() in a remote component loaded in the Next.js App Router. events.off() is a no-op in the App Router.',\n );\n },\n emit: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.emit() in a remote component loaded in the Next.js App Router. events.emit() is a no-op in the App Router.',\n );\n },\n },\n };\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,eAAe;;;ACHxB,SAA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UACF;AAAA,UACA,MAAM,MAAM;AAEV;AAAA,cACE;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;AHdI;AA3CJ,IAAM,gBAAgB,OACpB,YACA,qBACG;AACH,QAAM,CAAC,gBAAgB,kBAAkB,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC7D,gBAAgB;AAAA,IAChB,cAAc,QAAQ,QAAQ,CAAC,CAAC;AAAA,EAClC,CAAC;AACD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe;AAAA,IACf,GAAG,+BAA+B,EAAE,SAAS,iBAAiB,CAAC;AAAA,IAC/D,GAAG;AAAA,EACL;AACF;AAkBO,SAAS,+BAA+B;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA4D;AAC1D,QAAM,eAAe;AAAA,IACnB,MAAM,cAAc,QAAQ,gBAAgB;AAAA,IAC5C,CAAC,QAAQ,gBAAgB;AAAA,EAC3B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,QAAQ,cAAc,kBAAkB,GAAG,MAAM;AAAA,MAEzD;AAAA;AAAA,EACH;AAEJ;AAWO,SAASA,wBAAuB,OAAoC;AACzE,MAAI,OAAO,MAAM,QAAQ,YAAY,EAAE,MAAM,eAAe,MAAM;AAChE,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,QAAQ,cAAc,MAAM,QAAQ,MAAM,gBAAgB;AAAA;AAAA,EAC5D;AAEJ;","names":["ConsumeRemoteComponent"]}
1
+ {"version":3,"sources":["../../../../src/host/nextjs/app-client-only.tsx","../../../../src/host/nextjs/image-shared.ts","../../../../src/host/nextjs/shared-import.ts","../../../../src/host/nextjs/app-compat.tsx"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport { createImageLoaderSharedEntries } from '#internal/host/nextjs/image-shared';\nimport { tryImportShared } from '#internal/host/nextjs/shared-import';\nimport { RemoteComponentsContext } from '#internal/host/react/context';\nimport type { ConsumeClientOnlyConfig } from '#internal/host/shared/config';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport {\n type ConsumeRemoteComponentProps,\n ConsumeRemoteComponent as ConsumeRemoteComponentReact,\n} from '#remote-components/host/react';\nimport { routerImpl } from './app-compat';\n\nconst sharedModules = async (\n userShared?: ConsumeRemoteComponentProps['shared'],\n resolveClientUrl?: ResolveClientUrl,\n) => {\n const [resolvedShared, resolvedUserShared] = await Promise.all([\n tryImportShared(),\n userShared ?? Promise.resolve({}),\n ]);\n return {\n ...resolvedShared,\n 'next/router': routerImpl,\n ...createImageLoaderSharedEntries({ unbound: resolveClientUrl }),\n ...resolvedUserShared,\n };\n};\n\n/**\n * Provider for Next.js App Router hosts. Provides real Next.js implementations\n * of `next/image`, `next/navigation`, `next/link`, etc. to all nested\n * `<ConsumeRemoteComponent>` instances.\n *\n * Works in both Server and Client Components — set it up once in your layout\n * and use `<ConsumeRemoteComponent>` from `remote-components/react` everywhere:\n *\n * ```tsx\n * import { RemoteComponentsClientProvider } from 'remote-components/host/nextjs/app/client-only';\n *\n * <RemoteComponentsClientProvider resolveClientUrl={proxyClientRequestsThroughHost}>\n * {children}\n * </RemoteComponentsClientProvider>\n * ```\n */\nexport function RemoteComponentsClientProvider({\n shared,\n resolveClientUrl,\n children,\n ...props\n}: ConsumeClientOnlyConfig & { children: React.ReactNode }) {\n const mergedShared = useMemo(\n () => sharedModules(shared, resolveClientUrl),\n [shared, resolveClientUrl],\n );\n return (\n <RemoteComponentsContext\n value={{ shared: mergedShared, resolveClientUrl, ...props }}\n >\n {children}\n </RemoteComponentsContext>\n );\n}\n\n/**\n * `ConsumeRemoteComponent` for Next.js App Router hosts. Provides real Next.js\n * implementations of `next/image`, `next/navigation`, `next/link`, etc.\n *\n * The provider approach is recommended because it works in both Server and Client\n * Components — set up `RemoteComponentsClientProvider` from this module once in\n * your layout, and use `<ConsumeRemoteComponent>` from `remote-components/react`\n * everywhere. Import this component only when adding a provider is not practical.\n */\nexport function ConsumeRemoteComponent(props: ConsumeRemoteComponentProps) {\n if (typeof props.src !== 'string' && !(props.src instanceof URL)) {\n return props.children ?? null;\n }\n\n return (\n <ConsumeRemoteComponentReact\n {...props}\n shared={sharedModules(props.shared, props.resolveClientUrl)}\n />\n );\n}\n","import { createElement, forwardRef } from 'react';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport type {\n InternalResolveClientUrl,\n ResolveClientUrl,\n} from '#internal/runtime/url/resolve-client-url';\n\ntype SharedImageModule = (bundle: string) => Promise<unknown>;\n\nfunction resolveForBundle(\n unbound: ResolveClientUrl | undefined,\n bundle: string,\n): InternalResolveClientUrl | undefined {\n if (!unbound) return undefined;\n const remoteSrc = getScope(bundle)?.url.href ?? '';\n return bindResolveClientUrl(unbound, remoteSrc);\n}\n\n/**\n * Creates shared module entries for image-related modules that route\n * optimization requests through the remote's `/_next/image` endpoint.\n *\n * Pass `bound` when the resolver already has `remoteSrc` applied (App Router).\n * Pass `unbound` when only the raw 2-arg `ResolveClientUrl` is available\n * (Pages Router, client-only provider).\n */\nexport function createImageLoaderSharedEntries({\n bound,\n unbound,\n}: {\n bound?: InternalResolveClientUrl;\n unbound?: ResolveClientUrl;\n} = {}): Record<string, SharedImageModule> {\n const loaderEntry: SharedImageModule = (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n return Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n });\n };\n\n // Cross-version compat: remotes <=0.2.x request `next/image` as a shared module.\n // Wraps the host's Image component with the remote image loader injected\n // via the `loader` prop. Can be removed once 0.2.x support is dropped.\n const imageEntry: SharedImageModule = async (bundle: string) => {\n const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);\n const rawLoader = createRemoteImageLoader(bundle, resolveClientUrl);\n // Wrap to match Next.js `ImageLoader` signature (no `config` param).\n // The raw loader expects `{ config, src, width, quality }` but the public\n // `loader` prop is called with `{ src, width, quality }` only.\n const remoteLoader = Object.assign(\n (p: { src: string; width: number; quality?: number }) =>\n rawLoader({ ...p, config: { path: '/_next/image' } }),\n { __next_img_default: true as const },\n );\n const mod = await import('next/image');\n const OriginalImage = mod.default;\n type ImageProps = Parameters<typeof OriginalImage>[0];\n const RemoteImage = forwardRef<HTMLImageElement, ImageProps>((props, ref) =>\n createElement(OriginalImage, {\n ...props,\n loader: props.loader ?? remoteLoader,\n ref,\n }),\n );\n RemoteImage.displayName = 'RemoteImage';\n return { ...mod, default: RemoteImage, __esModule: true };\n };\n\n return {\n 'next/dist/shared/lib/image-loader': loaderEntry,\n 'next/dist/esm/shared/lib/image-loader': loaderEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/image': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/client/image-component': imageEntry,\n // Can be removed once 0.2.x support is dropped.\n 'next/dist/api/image': imageEntry,\n };\n}\n","export async function tryImportShared() {\n try {\n const { shared } = await import('#remote-components/host/defaults/app');\n return shared;\n } catch {\n return {};\n }\n}\n","import type { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport { logWarn } from '#internal/utils/logger';\n\nexport const routerImpl = async () => {\n const { useRouter } = await import('next/navigation');\n return Promise.resolve({\n useRouter: () => {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const query = Object.fromEntries(searchParams.entries());\n return {\n pathname,\n query,\n asPath: searchParams.toString()\n ? `${pathname}?${searchParams.toString()}`\n : pathname,\n push: (href: string, _: string, options?: NavigateOptions) => {\n router.push(href, options);\n return Promise.resolve(true);\n },\n replace: (href: string, _: string, options?: NavigateOptions) => {\n router.replace(href, options);\n return Promise.resolve(true);\n },\n refresh: () => Promise.resolve(router.refresh()),\n prefetch: async () => {\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.prefetch() in a remote component loaded in the Next.js App Router. prefetch() is a no-op in the App Router.',\n );\n return Promise.resolve();\n },\n back: () => {\n // there's no back() in the App Router\n if (typeof window !== 'undefined') {\n window.history.back();\n }\n },\n reload: () => {\n router.refresh();\n },\n beforePopState: () => {\n // there's no beforePopState() in the App Router\n },\n events: {\n on: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.on() in a remote component loaded in the Next.js App Router. events.on() is a no-op in the App Router.',\n );\n },\n off: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.off() in a remote component loaded in the Next.js App Router. events.off() is a no-op in the App Router.',\n );\n },\n emit: () => {\n // there's no router.events in the App Router\n logWarn(\n 'NextAppRouterCompat',\n 'You are using router.events.emit() in a remote component loaded in the Next.js App Router. events.emit() is a no-op in the App Router.',\n );\n },\n },\n };\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,eAAe;;;ACHxB,SAAS,eAAe,kBAAkB;AAW1C,SAAS,iBACP,SACA,QACsC;AACtC,MAAI,CAAC;AAAS,WAAO;AACrB,QAAM,YAAY,SAAS,MAAM,GAAG,IAAI,QAAQ;AAChD,SAAO,qBAAqB,SAAS,SAAS;AAChD;AAUO,SAAS,+BAA+B;AAAA,EAC7C;AAAA,EACA;AACF,IAGI,CAAC,GAAsC;AACzC,QAAM,cAAiC,CAAC,WAAmB;AACzD,UAAM,mBAAmB,SAAS,iBAAiB,SAAS,MAAM;AAClE,WAAO,QAAQ,QAAQ;AAAA,MACrB,SAAS,wBAAwB,QAAQ,gBAAgB;AAAA,MACzD,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAKA,QAAM,aAAgC,OAAO,WAAmB;AAC9D,UAAM,mB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AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA4D;AAC1D,QAAM,eAAe;AAAA,IACnB,MAAM,cAAc,QAAQ,gBAAgB;AAAA,IAC5C,CAAC,QAAQ,gBAAgB;AAAA,EAC3B;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,QAAQ,cAAc,kBAAkB,GAAG,MAAM;AAAA,MAEzD;AAAA;AAAA,EACH;AAEJ;AAWO,SAASA,wBAAuB,OAAoC;AACzE,MAAI,OAAO,MAAM,QAAQ,YAAY,EAAE,MAAM,eAAe,MAAM;AAChE,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,QAAQ,cAAc,MAAM,QAAQ,MAAM,gBAAgB;AAAA;AAAA,EAC5D;AAEJ;","names":["ConsumeRemoteComponent"]}
@@ -1,18 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkAWWWK2ZYcjs = require('../chunk-AWWWK2ZY.cjs');
4
- require('../chunk-I47KE3EC.cjs');
5
- require('../chunk-LCXO7BUY.cjs');
6
- require('../chunk-RJW3EZJP.cjs');
7
- require('../chunk-T64P7BAG.cjs');
3
+
4
+ var _chunkY4GMYUJTcjs = require('../chunk-Y4GMYUJT.cjs');
5
+ require('../chunk-AYC2AWUG.cjs');
6
+ require('../chunk-42TVDI3G.cjs');
7
+ require('../chunk-EYALF655.cjs');
8
+ require('../chunk-JJTCFQHE.cjs');
8
9
  require('../chunk-TZT7DLO5.cjs');
9
- require('../chunk-X6W464D6.cjs');
10
+ require('../chunk-N3SQTOSE.cjs');
11
+ require('../chunk-RLI4YTBJ.cjs');
10
12
  require('../chunk-Z2SLBFQL.cjs');
13
+ require('../chunk-5KTAEO52.cjs');
11
14
  require('../chunk-RUWR74XQ.cjs');
12
- require('../chunk-TCFLEBQM.cjs');
13
15
  require('../chunk-KE7QPAQ4.cjs');
16
+ require('../chunk-TCFLEBQM.cjs');
14
17
  require('../chunk-SHFJ5OQA.cjs');
15
18
 
16
19
 
17
- exports.ConsumeRemoteComponent = _chunkAWWWK2ZYcjs.ConsumeRemoteComponent;
20
+
21
+ exports.ConsumeRemoteComponent = _chunkY4GMYUJTcjs.ConsumeRemoteComponent; exports.useRemoteNavigate = _chunkY4GMYUJTcjs.useRemoteNavigate;
18
22
  //# sourceMappingURL=react.cjs.map
@@ -1,2 +1,3 @@
1
1
  import 'react/jsx-runtime';
2
- export { b as ConsumeRemoteComponent, a as ConsumeRemoteComponentProps, H as HookOptions, O as OnRequestHook, c as OnResponseHook } from '../index-4c65355c.js';
2
+ export { b as ConsumeRemoteComponent, a as ConsumeRemoteComponentProps, H as HookOptions, O as OnRequestHook, c as OnResponseHook, u as useRemoteNavigate } from '../index-d2ce8a3f.js';
3
+ export { R as RemoteNavigateEvent } from '../navigate-event-baee0b63.js';