remote-components 0.1.2 → 0.2.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.
- package/dist/{next/config.cjs → config/nextjs.cjs} +76 -101
- package/dist/config/nextjs.cjs.map +1 -0
- package/dist/{next/config.d.ts → config/nextjs.d.ts} +4 -4
- package/dist/{next/config.js → config/nextjs.js} +72 -97
- package/dist/config/nextjs.js.map +1 -0
- package/dist/{webpack.cjs → config/webpack.cjs} +13 -29
- package/dist/config/webpack.cjs.map +1 -0
- package/dist/{webpack.js → config/webpack.js} +12 -28
- package/dist/config/webpack.js.map +1 -0
- package/dist/{shared/remote → host/defaults}/app.cjs +2 -2
- package/dist/host/defaults/app.cjs.map +1 -0
- package/dist/host/defaults/app.js +8 -0
- package/dist/host/defaults/app.js.map +1 -0
- package/dist/{shared/remote → host/defaults}/pages.cjs +2 -2
- package/dist/host/defaults/pages.cjs.map +1 -0
- package/dist/host/defaults/pages.js +8 -0
- package/dist/host/defaults/pages.js.map +1 -0
- package/dist/{html/host.cjs → host/html.cjs} +1012 -1075
- package/dist/host/html.cjs.map +1 -0
- package/dist/{html/host.d.ts → host/html.d.ts} +0 -2
- package/dist/{html/host.js → host/html.js} +1009 -1071
- package/dist/host/html.js.map +1 -0
- package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +681 -617
- package/dist/host/nextjs/app/client-only.cjs.map +1 -0
- package/dist/host/nextjs/app/client-only.d.ts +16 -0
- package/dist/{next/host/client/index.js → host/nextjs/app/client-only.js} +682 -611
- package/dist/host/nextjs/app/client-only.js.map +1 -0
- package/dist/{next/host/app-router-server.cjs → host/nextjs/app.cjs} +11 -10
- package/dist/host/nextjs/app.cjs.map +1 -0
- package/dist/host/nextjs/app.d.ts +29 -0
- package/dist/{next/host/app-router-server.js → host/nextjs/app.js} +7 -6
- package/dist/host/nextjs/app.js.map +1 -0
- package/dist/{next/host/pages-router-client.cjs → host/nextjs/pages/client-only.cjs} +8 -8
- package/dist/host/nextjs/pages/client-only.cjs.map +1 -0
- package/dist/host/nextjs/pages/client-only.d.ts +31 -0
- package/dist/{next/host/pages-router-client.js → host/nextjs/pages/client-only.js} +4 -4
- package/dist/host/nextjs/pages/client-only.js.map +1 -0
- package/dist/{next/host/pages-router-server.cjs → host/nextjs/pages.cjs} +44 -55
- package/dist/host/nextjs/pages.cjs.map +1 -0
- package/dist/{next/host/pages-router-server.d.ts → host/nextjs/pages.d.ts} +11 -13
- package/dist/{next/host/pages-router-server.js → host/nextjs/pages.js} +38 -49
- package/dist/host/nextjs/pages.js.map +1 -0
- package/dist/host/proxy/client.cjs +57 -0
- package/dist/host/proxy/client.cjs.map +1 -0
- package/dist/host/proxy/client.d.ts +31 -0
- package/dist/host/proxy/client.js +30 -0
- package/dist/host/proxy/client.js.map +1 -0
- package/dist/{shared/host/proxy.cjs → host/proxy/protected-fetch.cjs} +6 -6
- package/dist/host/proxy/protected-fetch.cjs.map +1 -0
- package/dist/{shared/host/proxy.js → host/proxy/protected-fetch.js} +3 -3
- package/dist/host/proxy/protected-fetch.js.map +1 -0
- package/dist/{next → host}/proxy.cjs +12 -92
- package/dist/host/proxy.cjs.map +1 -0
- package/dist/host/proxy.d.ts +30 -0
- package/dist/{next → host}/proxy.js +11 -88
- package/dist/host/proxy.js.map +1 -0
- package/dist/{react/index.cjs → host/react.cjs} +515 -548
- package/dist/host/react.cjs.map +1 -0
- package/dist/{component-loader-21865da3.d.ts → host/react.d.ts} +141 -99
- package/dist/{react/index.js → host/react.js} +514 -545
- package/dist/host/react.js.map +1 -0
- package/dist/internal/{webpack/shared-modules.cjs → config/webpack/apply-shared-modules.cjs} +12 -15
- package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -0
- package/dist/internal/{webpack/shared-modules.js → config/webpack/apply-shared-modules.js} +9 -12
- package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -0
- package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.cjs +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -0
- package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.js +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -0
- package/dist/internal/{next/host/app-router-client.cjs → host/nextjs/app-client.cjs} +29 -24
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -0
- package/dist/internal/host/nextjs/app-client.d.ts +25 -0
- package/dist/internal/{next/host/app-router-client.js → host/nextjs/app-client.js} +19 -19
- package/dist/internal/host/nextjs/app-client.js.map +1 -0
- package/dist/internal/{next/host/app-router-compat.cjs → host/nextjs/app-compat.cjs} +5 -22
- package/dist/internal/host/nextjs/app-compat.cjs.map +1 -0
- package/dist/internal/{next/host/app-router-compat.d.ts → host/nextjs/app-compat.d.ts} +1 -7
- package/dist/internal/{next/host/app-router-compat.js → host/nextjs/app-compat.js} +2 -18
- package/dist/internal/host/nextjs/app-compat.js.map +1 -0
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -0
- package/dist/internal/host/nextjs/dom-flight.d.ts +39 -0
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -0
- package/dist/internal/host/nextjs/image-impl.cjs +60 -0
- package/dist/internal/host/nextjs/image-impl.cjs.map +1 -0
- package/dist/internal/host/nextjs/image-impl.d.ts +10 -0
- package/dist/internal/host/nextjs/image-impl.js +36 -0
- package/dist/internal/host/nextjs/image-impl.js.map +1 -0
- package/dist/internal/host/nextjs/image-shared.cjs +43 -0
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -0
- package/dist/internal/host/nextjs/image-shared.d.ts +9 -0
- package/dist/internal/host/nextjs/image-shared.js +19 -0
- package/dist/internal/host/nextjs/image-shared.js.map +1 -0
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.cjs +2 -2
- package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -0
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.d.ts +1 -1
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.js +2 -2
- package/dist/internal/host/nextjs/remote-component-links.js.map +1 -0
- package/dist/internal/host/nextjs/skeleton.cjs.map +1 -0
- package/dist/internal/host/nextjs/skeleton.js.map +1 -0
- package/dist/internal/{react → host/react}/context.cjs +3 -3
- package/dist/internal/host/react/context.cjs.map +1 -0
- package/dist/internal/{react → host/react}/context.d.ts +4 -4
- package/dist/internal/{react → host/react}/context.js +2 -2
- package/dist/internal/host/react/context.js.map +1 -0
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.cjs +2 -2
- package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -0
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.d.ts +1 -1
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.js +2 -2
- package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -0
- package/dist/internal/host/server/fetch-headers.cjs.map +1 -0
- package/dist/internal/host/server/fetch-headers.js.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.cjs +6 -6
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.d.ts +6 -1
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.js +9 -9
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.cjs +11 -15
- package/dist/internal/host/server/fetch-with-hooks.cjs.map +1 -0
- package/dist/internal/host/server/fetch-with-hooks.d.ts +21 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.js +11 -15
- package/dist/internal/host/server/fetch-with-hooks.js.map +1 -0
- package/dist/internal/host/server/get-client-or-server-url.cjs.map +1 -0
- package/dist/internal/host/server/get-client-or-server-url.js.map +1 -0
- package/dist/internal/{shared/client → host/server}/get-client-src.cjs +1 -1
- package/dist/internal/host/server/get-client-src.cjs.map +1 -0
- package/dist/internal/{shared/client → host/server}/get-client-src.js +1 -1
- package/dist/internal/host/server/get-client-src.js.map +1 -0
- package/dist/internal/host/server/get-ssr-relative-path-base-url.cjs.map +1 -0
- package/dist/internal/host/server/get-ssr-relative-path-base-url.js.map +1 -0
- package/dist/{next/remote/server.cjs → internal/host/server/types.cjs} +3 -15
- package/dist/internal/host/server/types.cjs.map +1 -0
- package/dist/internal/host/server/types.d.ts +33 -0
- package/dist/internal/host/server/types.js +1 -0
- package/dist/internal/host/server/types.js.map +1 -0
- package/dist/internal/host/shared/asset-descriptors.cjs +17 -0
- package/dist/internal/host/shared/asset-descriptors.cjs.map +1 -0
- package/dist/internal/host/shared/asset-descriptors.d.ts +21 -0
- package/dist/internal/host/shared/asset-descriptors.js +1 -0
- package/dist/internal/host/shared/asset-descriptors.js.map +1 -0
- package/dist/internal/host/shared/config.cjs +17 -0
- package/dist/internal/host/shared/config.cjs.map +1 -0
- package/dist/{host-config-58cdccea.d.ts → internal/host/shared/config.d.ts} +32 -19
- package/dist/internal/host/shared/config.js +1 -0
- package/dist/internal/host/shared/config.js.map +1 -0
- package/dist/internal/host/shared/fetch-interceptors.cjs +17 -0
- package/dist/internal/host/shared/fetch-interceptors.cjs.map +1 -0
- package/dist/{types-2b26a246.d.ts → internal/host/shared/fetch-interceptors.d.ts} +4 -87
- package/dist/internal/host/shared/fetch-interceptors.js +1 -0
- package/dist/internal/host/shared/fetch-interceptors.js.map +1 -0
- package/dist/internal/{shared/client → host/shared}/polyfill.cjs +7 -6
- package/dist/internal/host/shared/polyfill.cjs.map +1 -0
- package/dist/internal/{shared/client → host/shared}/polyfill.d.ts +2 -1
- package/dist/internal/{shared/client → host/shared}/polyfill.js +7 -6
- package/dist/internal/host/shared/polyfill.js.map +1 -0
- package/dist/internal/host/shared/resolved-data.cjs +17 -0
- package/dist/internal/host/shared/resolved-data.cjs.map +1 -0
- package/dist/internal/host/shared/resolved-data.d.ts +48 -0
- package/dist/internal/host/shared/resolved-data.js +1 -0
- package/dist/internal/host/shared/resolved-data.js.map +1 -0
- package/dist/internal/{shared/contract/host-state.cjs → host/shared/state.cjs} +4 -4
- package/dist/internal/host/shared/state.cjs.map +1 -0
- package/dist/internal/{shared/contract/host-state.js → host/shared/state.js} +1 -1
- package/dist/internal/host/shared/state.js.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.cjs.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.js.map +1 -0
- package/dist/internal/{next/remote/render-client.cjs → remote/nextjs/app-client.cjs} +8 -8
- package/dist/internal/remote/nextjs/app-client.cjs.map +1 -0
- package/dist/internal/{next/remote/render-client.js → remote/nextjs/app-client.js} +4 -4
- package/dist/internal/remote/nextjs/app-client.js.map +1 -0
- package/dist/internal/runtime/constants.cjs +50 -0
- package/dist/internal/runtime/constants.cjs.map +1 -0
- package/dist/internal/runtime/constants.d.ts +10 -0
- package/dist/internal/runtime/constants.js +20 -0
- package/dist/internal/runtime/constants.js.map +1 -0
- package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs.map +1 -1
- package/dist/internal/{shared/client → runtime/html}/apply-origin.d.ts +1 -1
- package/dist/internal/{shared/client → runtime/html}/apply-origin.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +140 -0
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -0
- package/dist/internal/runtime/html/parse-remote-html.d.ts +88 -0
- package/dist/internal/runtime/html/parse-remote-html.js +110 -0
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -0
- package/dist/internal/runtime/html/set-attributes-from-props.cjs +68 -0
- package/dist/internal/runtime/html/set-attributes-from-props.cjs.map +1 -0
- package/dist/internal/runtime/html/set-attributes-from-props.d.ts +3 -0
- package/dist/internal/runtime/html/set-attributes-from-props.js +44 -0
- package/dist/internal/runtime/html/set-attributes-from-props.js.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.cjs +184 -0
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.d.ts +31 -0
- package/dist/internal/runtime/loaders/component-loader.js +150 -0
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -0
- package/dist/internal/runtime/loaders/script-loader.cjs +69 -0
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/script-loader.d.ts +10 -0
- package/dist/internal/runtime/loaders/script-loader.js +48 -0
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -0
- package/dist/internal/runtime/loaders/static-loader.cjs +177 -0
- package/dist/internal/runtime/loaders/static-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/static-loader.d.ts +10 -0
- package/dist/internal/runtime/loaders/static-loader.js +153 -0
- package/dist/internal/runtime/loaders/static-loader.js.map +1 -0
- package/dist/internal/runtime/metadata.cjs +17 -0
- package/dist/internal/runtime/metadata.cjs.map +1 -0
- package/dist/internal/runtime/metadata.d.ts +16 -0
- package/dist/internal/runtime/metadata.js +1 -0
- package/dist/internal/runtime/metadata.js.map +1 -0
- package/dist/internal/runtime/rsc.cjs +92 -0
- package/dist/internal/runtime/rsc.cjs.map +1 -0
- package/dist/internal/runtime/rsc.d.ts +8 -0
- package/dist/internal/runtime/rsc.js +68 -0
- package/dist/internal/runtime/rsc.js.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +244 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.d.ts +11 -0
- package/dist/internal/runtime/turbopack/chunk-loader.js +227 -0
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -0
- package/dist/internal/runtime/turbopack/module.cjs +257 -0
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/module.d.ts +61 -0
- package/dist/internal/runtime/turbopack/module.js +233 -0
- package/dist/internal/runtime/turbopack/module.js.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.cjs +44 -0
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.d.ts +109 -0
- package/dist/internal/runtime/turbopack/patterns.js +15 -0
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs +152 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +17 -0
- package/dist/internal/runtime/turbopack/shared-modules.js +133 -0
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs +137 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +20 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.js +107 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -0
- package/dist/internal/runtime/types.cjs +17 -0
- package/dist/internal/runtime/types.cjs.map +1 -0
- package/dist/internal/runtime/types.d.ts +40 -0
- package/dist/internal/runtime/types.js +1 -0
- package/dist/internal/runtime/types.js.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.cjs +2 -2
- package/dist/internal/runtime/url/default-resolve-client-url.cjs.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.d.ts +1 -1
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.js +1 -1
- package/dist/internal/runtime/url/default-resolve-client-url.js.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.cjs +1 -1
- package/dist/internal/runtime/url/protected-rc-fallback.cjs.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.js +1 -1
- package/dist/internal/runtime/url/protected-rc-fallback.js.map +1 -0
- package/dist/internal/{shared/client/proxy-through-host.cjs → runtime/url/resolve-client-url.cjs} +4 -24
- package/dist/internal/runtime/url/resolve-client-url.cjs.map +1 -0
- package/dist/internal/{shared/client/proxy-through-host.d.ts → runtime/url/resolve-client-url.d.ts} +1 -25
- package/dist/internal/runtime/url/resolve-client-url.js +21 -0
- package/dist/internal/runtime/url/resolve-client-url.js.map +1 -0
- package/dist/internal/utils/abort.cjs.map +1 -0
- package/dist/internal/utils/abort.js.map +1 -0
- package/dist/internal/{shared → utils}/constants.cjs +3 -0
- package/dist/internal/utils/constants.cjs.map +1 -0
- package/dist/internal/utils/constants.d.ts +5 -0
- package/dist/internal/{shared → utils}/constants.js +2 -0
- package/dist/internal/utils/constants.js.map +1 -0
- package/dist/internal/{shared → utils}/error.cjs +4 -4
- package/dist/internal/utils/error.cjs.map +1 -0
- package/dist/internal/{shared → utils}/error.js +4 -4
- package/dist/internal/utils/error.js.map +1 -0
- package/dist/internal/{shared/utils → utils}/logger.cjs +3 -3
- package/dist/internal/utils/logger.cjs.map +1 -0
- package/dist/internal/{shared/utils → utils}/logger.d.ts +2 -2
- package/dist/internal/{shared/utils → utils}/logger.js +3 -3
- package/dist/internal/utils/logger.js.map +1 -0
- package/dist/internal/utils.cjs.map +1 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/{shared/host → remote/defaults}/app.cjs +2 -6
- package/dist/remote/defaults/app.cjs.map +1 -0
- package/dist/remote/defaults/app.js +8 -0
- package/dist/remote/defaults/app.js.map +1 -0
- package/dist/{shared/host → remote/defaults}/pages.cjs +2 -6
- package/dist/remote/defaults/pages.cjs.map +1 -0
- package/dist/remote/defaults/pages.js +8 -0
- package/dist/remote/defaults/pages.js.map +1 -0
- package/dist/{shared/remote → remote/defaults}/wrapper.cjs +12 -10
- package/dist/remote/defaults/wrapper.cjs.map +1 -0
- package/dist/remote/defaults/wrapper.js +27 -0
- package/dist/remote/defaults/wrapper.js.map +1 -0
- package/dist/{html/remote.cjs → remote/html.cjs} +16 -16
- package/dist/remote/html.cjs.map +1 -0
- package/dist/{html/remote.js → remote/html.js} +16 -16
- package/dist/remote/html.js.map +1 -0
- package/dist/{shared/remote/proxy.cjs → remote/middleware.cjs} +37 -12
- package/dist/remote/middleware.cjs.map +1 -0
- package/dist/remote/middleware.d.ts +27 -0
- package/dist/{shared/remote/proxy.js → remote/middleware.js} +32 -5
- package/dist/remote/middleware.js.map +1 -0
- package/dist/{internal/next/remote/render-server.cjs → remote/nextjs/app.cjs} +14 -16
- package/dist/remote/nextjs/app.cjs.map +1 -0
- package/dist/{internal/next/remote/render-server.d.ts → remote/nextjs/app.d.ts} +12 -13
- package/dist/{internal/next/remote/render-server.js → remote/nextjs/app.js} +9 -11
- package/dist/remote/nextjs/app.js.map +1 -0
- package/dist/{next/remote/pages-router.cjs → remote/nextjs/pages.cjs} +8 -8
- package/dist/remote/nextjs/pages.cjs.map +1 -0
- package/dist/{next/remote/pages-router.d.ts → remote/nextjs/pages.d.ts} +8 -8
- package/dist/{next/remote/pages-router.js → remote/nextjs/pages.js} +4 -4
- package/dist/remote/nextjs/pages.js.map +1 -0
- package/dist/server-handoff-8c89b856.d.ts +46 -0
- package/package.json +126 -157
- package/dist/html/host.cjs.map +0 -1
- package/dist/html/host.js.map +0 -1
- package/dist/html/remote.cjs.map +0 -1
- package/dist/html/remote.js.map +0 -1
- package/dist/internal/next/host/app-router-client.cjs.map +0 -1
- package/dist/internal/next/host/app-router-client.d.ts +0 -79
- package/dist/internal/next/host/app-router-client.js.map +0 -1
- package/dist/internal/next/host/app-router-compat.cjs.map +0 -1
- package/dist/internal/next/host/app-router-compat.js.map +0 -1
- package/dist/internal/next/host/remote-component-links.cjs.map +0 -1
- package/dist/internal/next/host/remote-component-links.js.map +0 -1
- package/dist/internal/next/remote/render-client.cjs.map +0 -1
- package/dist/internal/next/remote/render-client.js.map +0 -1
- package/dist/internal/next/remote/render-server.cjs.map +0 -1
- package/dist/internal/next/remote/render-server.js.map +0 -1
- package/dist/internal/react/context.cjs.map +0 -1
- package/dist/internal/react/context.js.map +0 -1
- package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +0 -1
- package/dist/internal/react/hooks/use-resolve-client-url.js.map +0 -1
- package/dist/internal/shared/client/default-resolve-client-url.cjs.map +0 -1
- package/dist/internal/shared/client/default-resolve-client-url.js.map +0 -1
- package/dist/internal/shared/client/get-client-src.cjs.map +0 -1
- package/dist/internal/shared/client/get-client-src.js.map +0 -1
- package/dist/internal/shared/client/polyfill.cjs.map +0 -1
- package/dist/internal/shared/client/polyfill.js.map +0 -1
- package/dist/internal/shared/client/protected-rc-fallback.cjs.map +0 -1
- package/dist/internal/shared/client/protected-rc-fallback.js.map +0 -1
- package/dist/internal/shared/client/proxy-through-host.cjs.map +0 -1
- package/dist/internal/shared/client/proxy-through-host.js +0 -40
- package/dist/internal/shared/client/proxy-through-host.js.map +0 -1
- package/dist/internal/shared/client/remote-component.cjs +0 -1436
- package/dist/internal/shared/client/remote-component.cjs.map +0 -1
- package/dist/internal/shared/client/remote-component.d.ts +0 -62
- package/dist/internal/shared/client/remote-component.js +0 -1385
- package/dist/internal/shared/client/remote-component.js.map +0 -1
- package/dist/internal/shared/constants.cjs.map +0 -1
- package/dist/internal/shared/constants.d.ts +0 -4
- package/dist/internal/shared/constants.js.map +0 -1
- package/dist/internal/shared/contract/host-state.cjs.map +0 -1
- package/dist/internal/shared/contract/host-state.js.map +0 -1
- package/dist/internal/shared/contract/resolve-name-from-src.cjs.map +0 -1
- package/dist/internal/shared/contract/resolve-name-from-src.js.map +0 -1
- package/dist/internal/shared/error.cjs.map +0 -1
- package/dist/internal/shared/error.js.map +0 -1
- package/dist/internal/shared/ssr/dom-flight.cjs.map +0 -1
- package/dist/internal/shared/ssr/dom-flight.d.ts +0 -2
- package/dist/internal/shared/ssr/dom-flight.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-headers.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-headers.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +0 -56
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +0 -1
- package/dist/internal/shared/ssr/get-client-or-server-url.cjs.map +0 -1
- package/dist/internal/shared/ssr/get-client-or-server-url.js.map +0 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +0 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +0 -1
- package/dist/internal/shared/ssr/skeleton.cjs.map +0 -1
- package/dist/internal/shared/ssr/skeleton.js.map +0 -1
- package/dist/internal/shared/utils/abort.cjs.map +0 -1
- package/dist/internal/shared/utils/abort.js.map +0 -1
- package/dist/internal/shared/utils/logger.cjs.map +0 -1
- package/dist/internal/shared/utils/logger.js.map +0 -1
- package/dist/internal/shared/utils.cjs.map +0 -1
- package/dist/internal/shared/utils.js.map +0 -1
- package/dist/internal/webpack/next-client-pages-loader.cjs.map +0 -1
- package/dist/internal/webpack/next-client-pages-loader.js.map +0 -1
- package/dist/internal/webpack/shared-modules.cjs.map +0 -1
- package/dist/internal/webpack/shared-modules.js.map +0 -1
- package/dist/next/config.cjs.map +0 -1
- package/dist/next/config.js.map +0 -1
- package/dist/next/host/app-router-server.cjs.map +0 -1
- package/dist/next/host/app-router-server.d.ts +0 -30
- package/dist/next/host/app-router-server.js.map +0 -1
- package/dist/next/host/client/index.cjs.map +0 -1
- package/dist/next/host/client/index.d.ts +0 -19
- package/dist/next/host/client/index.js.map +0 -1
- package/dist/next/host/pages-router-client.cjs.map +0 -1
- package/dist/next/host/pages-router-client.d.ts +0 -33
- package/dist/next/host/pages-router-client.js.map +0 -1
- package/dist/next/host/pages-router-server.cjs.map +0 -1
- package/dist/next/host/pages-router-server.js.map +0 -1
- package/dist/next/index.cjs +0 -53
- package/dist/next/index.cjs.map +0 -1
- package/dist/next/index.d.ts +0 -30
- package/dist/next/index.js +0 -19
- package/dist/next/index.js.map +0 -1
- package/dist/next/proxy.cjs.map +0 -1
- package/dist/next/proxy.d.ts +0 -56
- package/dist/next/proxy.js.map +0 -1
- package/dist/next/remote/pages-router.cjs.map +0 -1
- package/dist/next/remote/pages-router.js.map +0 -1
- package/dist/next/remote/server.cjs.map +0 -1
- package/dist/next/remote/server.d.ts +0 -5
- package/dist/next/remote/server.js +0 -5
- package/dist/next/remote/server.js.map +0 -1
- package/dist/proxy-through-host-a676a522.d.ts +0 -52
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -86
- package/dist/react/index.js.map +0 -1
- package/dist/shared/host/app.cjs.map +0 -1
- package/dist/shared/host/app.js +0 -12
- package/dist/shared/host/app.js.map +0 -1
- package/dist/shared/host/pages.cjs.map +0 -1
- package/dist/shared/host/pages.js +0 -12
- package/dist/shared/host/pages.js.map +0 -1
- package/dist/shared/host/proxy.cjs.map +0 -1
- package/dist/shared/host/proxy.js.map +0 -1
- package/dist/shared/remote/app.cjs.map +0 -1
- package/dist/shared/remote/app.js +0 -8
- package/dist/shared/remote/app.js.map +0 -1
- package/dist/shared/remote/pages.cjs.map +0 -1
- package/dist/shared/remote/pages.js +0 -8
- package/dist/shared/remote/pages.js.map +0 -1
- package/dist/shared/remote/proxy.cjs.map +0 -1
- package/dist/shared/remote/proxy.d.ts +0 -44
- package/dist/shared/remote/proxy.js.map +0 -1
- package/dist/shared/remote/wrapper.cjs.map +0 -1
- package/dist/shared/remote/wrapper.js +0 -25
- package/dist/shared/remote/wrapper.js.map +0 -1
- package/dist/webpack.cjs.map +0 -1
- package/dist/webpack.js.map +0 -1
- /package/dist/{webpack.d.ts → config/webpack.d.ts} +0 -0
- /package/dist/{shared/host → host/defaults}/app.d.ts +0 -0
- /package/dist/{shared/host → host/defaults}/pages.d.ts +0 -0
- /package/dist/{shared/host/proxy.d.ts → host/proxy/protected-fetch.d.ts} +0 -0
- /package/dist/internal/{webpack/shared-modules.d.ts → config/webpack/apply-shared-modules.d.ts} +0 -0
- /package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.js +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.js +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.js +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.js +0 -0
- /package/dist/internal/{shared/client → host/server}/get-client-src.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.js +0 -0
- /package/dist/internal/{shared/contract/host-state.d.ts → host/shared/state.d.ts} +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.cjs +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.d.ts +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.js +0 -0
- /package/dist/internal/{next/remote/render-client.d.ts → remote/nextjs/app-client.d.ts} +0 -0
- /package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs +0 -0
- /package/dist/internal/{shared/client → runtime/html}/apply-origin.js +0 -0
- /package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.d.ts +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.cjs +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.d.ts +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.js +0 -0
- /package/dist/internal/{shared → utils}/error.d.ts +0 -0
- /package/dist/internal/{shared/utils.cjs → utils.cjs} +0 -0
- /package/dist/internal/{shared/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/internal/{shared/utils.js → utils.js} +0 -0
- /package/dist/{shared/remote → remote/defaults}/app.d.ts +0 -0
- /package/dist/{shared/remote → remote/defaults}/pages.d.ts +0 -0
- /package/dist/{shared/remote → remote/defaults}/wrapper.d.ts +0 -0
- /package/dist/{html/remote.d.ts → remote/html.d.ts} +0 -0
|
@@ -30,20 +30,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/
|
|
33
|
+
// src/utils/constants.ts
|
|
34
34
|
var RC_PROTECTED_REMOTE_FETCH_PATHNAME, CORS_DOCS_URL;
|
|
35
35
|
var init_constants = __esm({
|
|
36
|
-
"src/
|
|
36
|
+
"src/utils/constants.ts"() {
|
|
37
37
|
"use strict";
|
|
38
38
|
RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
39
39
|
CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// src/
|
|
44
|
-
function generateProtectedRcFallbackSrc(url) {
|
|
45
|
-
return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
|
|
46
|
-
}
|
|
43
|
+
// src/runtime/url/protected-rc-fallback.ts
|
|
47
44
|
function isProxiedUrl(url) {
|
|
48
45
|
try {
|
|
49
46
|
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
@@ -52,13 +49,13 @@ function isProxiedUrl(url) {
|
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
var init_protected_rc_fallback = __esm({
|
|
55
|
-
"src/
|
|
52
|
+
"src/runtime/url/protected-rc-fallback.ts"() {
|
|
56
53
|
"use strict";
|
|
57
54
|
init_constants();
|
|
58
55
|
}
|
|
59
56
|
});
|
|
60
57
|
|
|
61
|
-
// src/
|
|
58
|
+
// src/utils/abort.ts
|
|
62
59
|
function isAbortError(error) {
|
|
63
60
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
64
61
|
return true;
|
|
@@ -70,12 +67,12 @@ function isAbortError(error) {
|
|
|
70
67
|
return false;
|
|
71
68
|
}
|
|
72
69
|
var init_abort = __esm({
|
|
73
|
-
"src/
|
|
70
|
+
"src/utils/abort.ts"() {
|
|
74
71
|
"use strict";
|
|
75
72
|
}
|
|
76
73
|
});
|
|
77
74
|
|
|
78
|
-
// src/
|
|
75
|
+
// src/utils/error.ts
|
|
79
76
|
function multipleRemoteComponentsError(url) {
|
|
80
77
|
return new RemoteComponentsError(
|
|
81
78
|
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
@@ -134,7 +131,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
|
134
131
|
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
135
132
|
|
|
136
133
|
Proxying requires two pieces:
|
|
137
|
-
1. resolveClientUrl={
|
|
134
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
138
135
|
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
139
136
|
|
|
140
137
|
Docs: ${CORS_DOCS_URL}`
|
|
@@ -152,11 +149,11 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
152
149
|
}
|
|
153
150
|
var RemoteComponentsError;
|
|
154
151
|
var init_error = __esm({
|
|
155
|
-
"src/
|
|
152
|
+
"src/utils/error.ts"() {
|
|
156
153
|
"use strict";
|
|
157
154
|
init_protected_rc_fallback();
|
|
158
|
-
init_constants();
|
|
159
155
|
init_abort();
|
|
156
|
+
init_constants();
|
|
160
157
|
RemoteComponentsError = class extends Error {
|
|
161
158
|
code = "REMOTE_COMPONENTS_ERROR";
|
|
162
159
|
constructor(message, options) {
|
|
@@ -167,34 +164,7 @@ var init_error = __esm({
|
|
|
167
164
|
}
|
|
168
165
|
});
|
|
169
166
|
|
|
170
|
-
// src/
|
|
171
|
-
function escapeString(str) {
|
|
172
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
173
|
-
}
|
|
174
|
-
var init_utils = __esm({
|
|
175
|
-
"src/shared/utils/index.ts"() {
|
|
176
|
-
"use strict";
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// src/shared/client/const.ts
|
|
181
|
-
function getBundleKey(bundle) {
|
|
182
|
-
return escapeString(bundle);
|
|
183
|
-
}
|
|
184
|
-
var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT, REMOTE_COMPONENT_REGEX;
|
|
185
|
-
var init_const = __esm({
|
|
186
|
-
"src/shared/client/const.ts"() {
|
|
187
|
-
"use strict";
|
|
188
|
-
init_utils();
|
|
189
|
-
DEFAULT_ROUTE = "/";
|
|
190
|
-
RUNTIME_WEBPACK = "webpack";
|
|
191
|
-
RUNTIME_TURBOPACK = "turbopack";
|
|
192
|
-
RUNTIME_SCRIPT = "script";
|
|
193
|
-
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// src/shared/utils/logger.ts
|
|
167
|
+
// src/utils/logger.ts
|
|
198
168
|
function logDebug(location2, message) {
|
|
199
169
|
if (DEBUG) {
|
|
200
170
|
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
@@ -218,14 +188,14 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
218
188
|
}
|
|
219
189
|
logWarn(
|
|
220
190
|
logLocation,
|
|
221
|
-
`Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure
|
|
191
|
+
`Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure withRemoteComponentsHostProxy middleware is configured in your host and that the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
222
192
|
);
|
|
223
193
|
} catch {
|
|
224
194
|
}
|
|
225
195
|
}
|
|
226
196
|
var PREFIX, DEBUG;
|
|
227
197
|
var init_logger = __esm({
|
|
228
|
-
"src/
|
|
198
|
+
"src/utils/logger.ts"() {
|
|
229
199
|
"use strict";
|
|
230
200
|
init_constants();
|
|
231
201
|
init_error();
|
|
@@ -234,7 +204,99 @@ var init_logger = __esm({
|
|
|
234
204
|
}
|
|
235
205
|
});
|
|
236
206
|
|
|
237
|
-
// src/
|
|
207
|
+
// src/utils/index.ts
|
|
208
|
+
function escapeString(str) {
|
|
209
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
210
|
+
}
|
|
211
|
+
var init_utils = __esm({
|
|
212
|
+
"src/utils/index.ts"() {
|
|
213
|
+
"use strict";
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// src/runtime/constants.ts
|
|
218
|
+
function getBundleKey(bundle) {
|
|
219
|
+
return escapeString(bundle);
|
|
220
|
+
}
|
|
221
|
+
var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT, REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE;
|
|
222
|
+
var init_constants2 = __esm({
|
|
223
|
+
"src/runtime/constants.ts"() {
|
|
224
|
+
"use strict";
|
|
225
|
+
init_utils();
|
|
226
|
+
DEFAULT_ROUTE = "/";
|
|
227
|
+
RUNTIME_WEBPACK = "webpack";
|
|
228
|
+
RUNTIME_TURBOPACK = "turbopack";
|
|
229
|
+
RUNTIME_SCRIPT = "script";
|
|
230
|
+
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
231
|
+
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
236
|
+
function applySharedModules(bundle, resolve) {
|
|
237
|
+
logDebug(
|
|
238
|
+
"SharedModules",
|
|
239
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
240
|
+
);
|
|
241
|
+
logDebug(
|
|
242
|
+
"SharedModules",
|
|
243
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
244
|
+
);
|
|
245
|
+
const self = globalThis;
|
|
246
|
+
if (self.__remote_webpack_require__?.[bundle]) {
|
|
247
|
+
const modulePaths = Object.keys(
|
|
248
|
+
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
249
|
+
);
|
|
250
|
+
logDebug(
|
|
251
|
+
"SharedModules",
|
|
252
|
+
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
253
|
+
);
|
|
254
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
255
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
256
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
257
|
+
if (ids.length === 0) {
|
|
258
|
+
logDebug(
|
|
259
|
+
"SharedModules",
|
|
260
|
+
`No matching module path found for shared module "${key}"`
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
for (const id of ids) {
|
|
264
|
+
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
265
|
+
if (webpackBundle.m) {
|
|
266
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
267
|
+
if (resolvedId !== id) {
|
|
268
|
+
logDebug(
|
|
269
|
+
"SharedModules",
|
|
270
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
webpackBundle.m[resolvedId] = (module2) => {
|
|
274
|
+
module2.exports = value;
|
|
275
|
+
};
|
|
276
|
+
} else {
|
|
277
|
+
logWarn(
|
|
278
|
+
"SharedModules",
|
|
279
|
+
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
|
|
286
|
+
logDebug(
|
|
287
|
+
"SharedModules",
|
|
288
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
var init_apply_shared_modules = __esm({
|
|
293
|
+
"src/config/webpack/apply-shared-modules.ts"() {
|
|
294
|
+
"use strict";
|
|
295
|
+
init_logger();
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
238
300
|
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
239
301
|
const self = globalThis;
|
|
240
302
|
const nextCssOriginal = document.querySelector(
|
|
@@ -346,170 +408,396 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
346
408
|
return { Component: null, App: null };
|
|
347
409
|
}
|
|
348
410
|
var init_next_client_pages_loader = __esm({
|
|
349
|
-
"src/
|
|
411
|
+
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
350
412
|
"use strict";
|
|
351
413
|
init_error();
|
|
352
414
|
}
|
|
353
415
|
});
|
|
354
416
|
|
|
355
|
-
// src/shared/
|
|
356
|
-
function
|
|
357
|
-
logDebug(
|
|
358
|
-
"SharedModules",
|
|
359
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
360
|
-
);
|
|
361
|
-
logDebug(
|
|
362
|
-
"SharedModules",
|
|
363
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
364
|
-
);
|
|
417
|
+
// src/host/shared/polyfill.tsx
|
|
418
|
+
function applyBundleUrlToSrc(bundle, src) {
|
|
365
419
|
const self = globalThis;
|
|
366
|
-
if (self.
|
|
367
|
-
|
|
368
|
-
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
369
|
-
);
|
|
370
|
-
logDebug(
|
|
371
|
-
"SharedModules",
|
|
372
|
-
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
373
|
-
);
|
|
374
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
375
|
-
let ids = modulePaths.filter((p) => p === key);
|
|
376
|
-
if (ids.length === 0) {
|
|
377
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
378
|
-
}
|
|
379
|
-
if (ids.length === 0) {
|
|
380
|
-
logDebug(
|
|
381
|
-
"SharedModules",
|
|
382
|
-
`No matching module path found for shared module "${key}"`
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
for (let id of ids) {
|
|
386
|
-
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
387
|
-
if (webpackBundle.m) {
|
|
388
|
-
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
389
|
-
const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
390
|
-
logDebug(
|
|
391
|
-
"SharedModules",
|
|
392
|
-
`Mapped module id: "${id}" -> "${mappedId}"`
|
|
393
|
-
);
|
|
394
|
-
id = mappedId;
|
|
395
|
-
}
|
|
396
|
-
webpackBundle.m[id] = (module2) => {
|
|
397
|
-
module2.exports = value;
|
|
398
|
-
};
|
|
399
|
-
} else {
|
|
400
|
-
logWarn(
|
|
401
|
-
"SharedModules",
|
|
402
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
} else {
|
|
408
|
-
logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
|
|
409
|
-
logDebug(
|
|
410
|
-
"SharedModules",
|
|
411
|
-
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
412
|
-
);
|
|
420
|
+
if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
|
|
421
|
+
return src;
|
|
413
422
|
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
"use strict";
|
|
418
|
-
init_logger();
|
|
423
|
+
const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
|
|
424
|
+
if (!path) {
|
|
425
|
+
return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
|
|
419
426
|
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
"src/shared/client/webpack-patterns.ts"() {
|
|
426
|
-
"use strict";
|
|
427
|
-
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
427
|
+
return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
|
|
428
|
+
}
|
|
429
|
+
function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
430
|
+
if (typeof src === "string") {
|
|
431
|
+
return applyBundleUrlToSrc(bundle, src);
|
|
428
432
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (isProxied) {
|
|
447
|
-
reject(
|
|
448
|
-
new RemoteComponentsError(
|
|
449
|
-
`Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
450
|
-
)
|
|
451
|
-
);
|
|
452
|
-
} else {
|
|
453
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
454
|
-
reject(
|
|
455
|
-
new RemoteComponentsError(
|
|
456
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
457
|
-
)
|
|
458
|
-
);
|
|
433
|
+
const propSrc = src;
|
|
434
|
+
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
435
|
+
}
|
|
436
|
+
function sharedPolyfills(shared, resolveClientUrl) {
|
|
437
|
+
const self = globalThis;
|
|
438
|
+
const polyfill = {
|
|
439
|
+
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
440
|
+
useRouter() {
|
|
441
|
+
return {
|
|
442
|
+
push: (routerUrl) => {
|
|
443
|
+
history.pushState({}, "", routerUrl);
|
|
444
|
+
},
|
|
445
|
+
replace: (routerUrl) => {
|
|
446
|
+
history.replaceState({}, "", routerUrl);
|
|
447
|
+
},
|
|
448
|
+
back: () => {
|
|
449
|
+
history.back();
|
|
459
450
|
}
|
|
460
451
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
452
|
+
},
|
|
453
|
+
usePathname() {
|
|
454
|
+
return location.pathname;
|
|
455
|
+
},
|
|
456
|
+
useParams() {
|
|
457
|
+
return {};
|
|
458
|
+
},
|
|
459
|
+
useSearchParams() {
|
|
460
|
+
return new URLSearchParams(location.search);
|
|
461
|
+
},
|
|
462
|
+
useSelectedLayoutSegment() {
|
|
463
|
+
return null;
|
|
464
|
+
},
|
|
465
|
+
useSelectedLayoutSegments() {
|
|
466
|
+
return [];
|
|
467
|
+
},
|
|
468
|
+
__esModule: true
|
|
469
|
+
})),
|
|
470
|
+
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
471
|
+
default: ({
|
|
472
|
+
scroll: _,
|
|
473
|
+
replace,
|
|
474
|
+
prefetch,
|
|
475
|
+
onNavigate,
|
|
476
|
+
children,
|
|
477
|
+
...props
|
|
478
|
+
}) => {
|
|
479
|
+
if (prefetch) {
|
|
480
|
+
logWarn(
|
|
481
|
+
"Polyfill",
|
|
482
|
+
"Next.js Link prefetch is not supported in remote components"
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
486
|
+
"a",
|
|
487
|
+
{
|
|
488
|
+
...props,
|
|
489
|
+
href: props.href,
|
|
490
|
+
onClick: (e) => {
|
|
491
|
+
e.preventDefault();
|
|
492
|
+
let preventDefaulted = false;
|
|
493
|
+
e.preventDefault = () => {
|
|
494
|
+
preventDefaulted = true;
|
|
495
|
+
e.defaultPrevented = true;
|
|
496
|
+
};
|
|
497
|
+
if (typeof props.onClick === "function") {
|
|
498
|
+
props.onClick(e);
|
|
499
|
+
}
|
|
500
|
+
onNavigate?.(e);
|
|
501
|
+
if (preventDefaulted) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (replace) {
|
|
505
|
+
history.replaceState({}, "", props.href);
|
|
506
|
+
} else {
|
|
507
|
+
history.pushState({}, "", props.href);
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
suppressHydrationWarning: true,
|
|
511
|
+
children: children ?? null
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
},
|
|
515
|
+
useLinkStatus() {
|
|
516
|
+
return { pending: false };
|
|
517
|
+
},
|
|
518
|
+
__esModule: true
|
|
519
|
+
})),
|
|
520
|
+
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
521
|
+
default: () => {
|
|
522
|
+
throw new Error("Next.js <Form> component not implemented");
|
|
523
|
+
},
|
|
524
|
+
__esModule: true
|
|
525
|
+
})),
|
|
526
|
+
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
527
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
528
|
+
__esModule: true
|
|
529
|
+
})),
|
|
530
|
+
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
531
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
532
|
+
getImageProps: (_imgProps) => {
|
|
533
|
+
throw new Error(
|
|
534
|
+
"Next.js getImageProps() is not implemented in remote components"
|
|
535
|
+
);
|
|
536
|
+
},
|
|
537
|
+
__esModule: true
|
|
538
|
+
})),
|
|
539
|
+
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
540
|
+
// TODO: implement <Script> component for non-Next.js host applications
|
|
541
|
+
// do not throw an error for now
|
|
542
|
+
default: () => null,
|
|
543
|
+
__esModule: true
|
|
544
|
+
})),
|
|
545
|
+
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
546
|
+
// TODO: incomplete implementation
|
|
547
|
+
Promise.resolve({
|
|
548
|
+
useRouter() {
|
|
549
|
+
return {
|
|
550
|
+
push: (routerUrl) => {
|
|
551
|
+
history.pushState({}, "", routerUrl);
|
|
552
|
+
},
|
|
553
|
+
replace: (routerUrl) => {
|
|
554
|
+
history.replaceState({}, "", routerUrl);
|
|
555
|
+
},
|
|
556
|
+
back: () => {
|
|
557
|
+
history.back();
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
},
|
|
561
|
+
__esModule: true
|
|
562
|
+
})
|
|
563
|
+
)),
|
|
564
|
+
"next/dist/build/polyfills/process": () => Promise.resolve({
|
|
565
|
+
default: {
|
|
566
|
+
env: {
|
|
567
|
+
NODE_ENV: "production"
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
__esModule: true
|
|
571
|
+
})
|
|
572
|
+
};
|
|
573
|
+
polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
|
|
574
|
+
polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
|
|
575
|
+
polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
|
|
576
|
+
polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
|
|
577
|
+
polyfill["next/script"] = polyfill["next/dist/client/script"];
|
|
578
|
+
return polyfill;
|
|
579
|
+
}
|
|
580
|
+
var import_jsx_runtime, imageImpl;
|
|
581
|
+
var init_polyfill = __esm({
|
|
582
|
+
"src/host/shared/polyfill.tsx"() {
|
|
583
|
+
"use strict";
|
|
584
|
+
init_logger();
|
|
585
|
+
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
586
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
587
|
+
imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
588
|
+
fill: _fill,
|
|
589
|
+
loader: _loader,
|
|
590
|
+
quality: _quality,
|
|
591
|
+
priority: _priority,
|
|
592
|
+
loading: _loading,
|
|
593
|
+
placeholder: _placeholder,
|
|
594
|
+
blurDataURL: _blurDataURL,
|
|
595
|
+
unoptimized: _unoptimized,
|
|
596
|
+
overrideSrc: _overrideSrc,
|
|
597
|
+
src,
|
|
598
|
+
...props
|
|
599
|
+
}) {
|
|
600
|
+
const newSrc = applyBundleUrlToImagePropsSrc(
|
|
601
|
+
bundle,
|
|
602
|
+
typeof src === "string" ? src : src.src
|
|
603
|
+
);
|
|
604
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
606
|
+
"img",
|
|
607
|
+
{
|
|
608
|
+
decoding: "async",
|
|
609
|
+
style: { color: "transparent" },
|
|
610
|
+
...props,
|
|
611
|
+
src: proxiedSrc,
|
|
612
|
+
suppressHydrationWarning: true
|
|
613
|
+
}
|
|
614
|
+
);
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
// src/runtime/loaders/script-loader.ts
|
|
620
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
621
|
+
await Promise.all(
|
|
622
|
+
scripts.map((script) => {
|
|
623
|
+
return new Promise((resolve, reject) => {
|
|
624
|
+
const newSrc = new URL(
|
|
625
|
+
// remove the remote component bundle name identifier from the script src
|
|
626
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
627
|
+
location.origin
|
|
628
|
+
).href;
|
|
629
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
630
|
+
const newScript = document.createElement("script");
|
|
631
|
+
newScript.onload = () => resolve();
|
|
632
|
+
newScript.onerror = () => {
|
|
633
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
634
|
+
if (isProxied) {
|
|
635
|
+
reject(
|
|
636
|
+
new RemoteComponentsError(
|
|
637
|
+
`Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHostProxy middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
638
|
+
)
|
|
639
|
+
);
|
|
640
|
+
} else {
|
|
641
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
642
|
+
reject(
|
|
643
|
+
new RemoteComponentsError(
|
|
644
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
645
|
+
)
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
newScript.src = resolvedSrc;
|
|
650
|
+
newScript.async = true;
|
|
651
|
+
document.head.appendChild(newScript);
|
|
652
|
+
});
|
|
653
|
+
})
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
var init_script_loader = __esm({
|
|
657
|
+
"src/runtime/loaders/script-loader.ts"() {
|
|
658
|
+
"use strict";
|
|
659
|
+
init_constants2();
|
|
660
|
+
init_protected_rc_fallback();
|
|
661
|
+
init_constants();
|
|
662
|
+
init_error();
|
|
663
|
+
init_logger();
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
// src/host/html/runtime/webpack.ts
|
|
668
|
+
var webpack_exports = {};
|
|
669
|
+
__export(webpack_exports, {
|
|
670
|
+
webpackRuntime: () => webpackRuntime
|
|
671
|
+
});
|
|
672
|
+
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
673
|
+
const self = globalThis;
|
|
674
|
+
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
675
|
+
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
676
|
+
}
|
|
677
|
+
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
678
|
+
if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
|
|
679
|
+
self.__webpack_require__ = (remoteId) => {
|
|
680
|
+
const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
|
|
681
|
+
const match = re.exec(remoteId);
|
|
682
|
+
const remoteBundle = match?.groups?.bundle;
|
|
683
|
+
const id = match?.groups?.id;
|
|
684
|
+
if (!(id && remoteBundle)) {
|
|
685
|
+
throw new RemoteComponentsError(
|
|
686
|
+
`Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
|
|
690
|
+
throw new RemoteComponentsError(
|
|
691
|
+
`Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
return self.__remote_webpack_require__[remoteBundle](id);
|
|
695
|
+
};
|
|
696
|
+
self.__webpack_chunk_load__ = () => {
|
|
697
|
+
return Promise.resolve([]);
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
const {
|
|
701
|
+
default: { createFromReadableStream }
|
|
702
|
+
} = await import("react-server-dom-webpack/client.browser");
|
|
703
|
+
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
704
|
+
const scriptSrcs = scripts.flatMap((script) => {
|
|
705
|
+
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
706
|
+
script.parentElement?.removeChild(script);
|
|
707
|
+
if (!scriptSrc)
|
|
708
|
+
return [];
|
|
709
|
+
return [
|
|
710
|
+
{
|
|
711
|
+
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
712
|
+
}
|
|
713
|
+
];
|
|
714
|
+
});
|
|
715
|
+
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
716
|
+
const hostShared = {
|
|
717
|
+
...sharedPolyfills(shared, resolveClientUrl),
|
|
718
|
+
...self.__remote_component_host_shared_modules__,
|
|
719
|
+
...shared
|
|
720
|
+
};
|
|
721
|
+
const resolve = {
|
|
722
|
+
"/react/index.js": (await import("react")).default,
|
|
723
|
+
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
724
|
+
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
725
|
+
"/react-dom/index.js": (await import("react-dom")).default,
|
|
726
|
+
"/react-dom/client.js": (await import("react-dom/client")).default,
|
|
727
|
+
...Object.entries(remoteShared ?? {}).reduce(
|
|
728
|
+
(acc, [key, value]) => {
|
|
729
|
+
if (typeof hostShared[value] !== "undefined") {
|
|
730
|
+
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
731
|
+
}
|
|
732
|
+
return acc;
|
|
733
|
+
},
|
|
734
|
+
{}
|
|
735
|
+
)
|
|
736
|
+
};
|
|
737
|
+
await Promise.all(
|
|
738
|
+
Object.entries(resolve).map(async ([key, value]) => {
|
|
739
|
+
if (typeof value === "function") {
|
|
740
|
+
resolve[key] = await value(remoteBundle);
|
|
741
|
+
}
|
|
742
|
+
return Promise.resolve(value);
|
|
743
|
+
})
|
|
744
|
+
);
|
|
745
|
+
applySharedModules(remoteBundle, resolve);
|
|
746
|
+
}
|
|
747
|
+
return {
|
|
748
|
+
self,
|
|
749
|
+
createFromReadableStream,
|
|
750
|
+
applySharedModules,
|
|
751
|
+
nextClientPagesLoader,
|
|
752
|
+
preloadScripts
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
var init_webpack = __esm({
|
|
756
|
+
"src/host/html/runtime/webpack.ts"() {
|
|
757
|
+
"use strict";
|
|
758
|
+
init_apply_shared_modules();
|
|
759
|
+
init_next_client_pages_loader();
|
|
760
|
+
init_polyfill();
|
|
761
|
+
init_constants2();
|
|
762
|
+
init_script_loader();
|
|
763
|
+
init_error();
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
// src/runtime/turbopack/patterns.ts
|
|
768
|
+
var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
|
|
769
|
+
var init_patterns = __esm({
|
|
770
|
+
"src/runtime/turbopack/patterns.ts"() {
|
|
771
|
+
"use strict";
|
|
772
|
+
REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
773
|
+
REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
774
|
+
ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
775
|
+
ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
776
|
+
ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb>parentImport|t)=>Promise\.all\(\["[^"]+"\]\.map\((?<mapCb>chunk|t)=>\k<ctx>\.l\(\k<mapCb>\)\)\)\.then\(\(\)=>\k<vCb>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
777
|
+
TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
782
|
+
function createChunkLoader(runtime, resolveClientUrl) {
|
|
783
|
+
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
784
|
+
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
785
|
+
const self = globalThis;
|
|
786
|
+
const {
|
|
787
|
+
bundle,
|
|
788
|
+
id: path,
|
|
789
|
+
prefix
|
|
790
|
+
} = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {
|
|
791
|
+
bundle: scriptBundle ?? "",
|
|
792
|
+
id: chunkId
|
|
793
|
+
};
|
|
794
|
+
logDebug(
|
|
795
|
+
"ChunkLoader",
|
|
796
|
+
`Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
|
|
797
|
+
);
|
|
798
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
799
|
+
logDebug("ChunkLoader", `Remote runtime: "${remoteRuntime}"`);
|
|
800
|
+
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
513
801
|
logDebug("ChunkLoader", "Skipping chunk load - webpack runtime detected");
|
|
514
802
|
return Promise.resolve(void 0);
|
|
515
803
|
}
|
|
@@ -552,7 +840,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
552
840
|
if (isProxied) {
|
|
553
841
|
reject(
|
|
554
842
|
new RemoteComponentsError(
|
|
555
|
-
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure
|
|
843
|
+
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
556
844
|
)
|
|
557
845
|
);
|
|
558
846
|
} else {
|
|
@@ -702,18 +990,18 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
702
990
|
}
|
|
703
991
|
}
|
|
704
992
|
var init_chunk_loader = __esm({
|
|
705
|
-
"src/
|
|
993
|
+
"src/runtime/turbopack/chunk-loader.ts"() {
|
|
706
994
|
"use strict";
|
|
995
|
+
init_constants2();
|
|
996
|
+
init_protected_rc_fallback();
|
|
707
997
|
init_constants();
|
|
708
998
|
init_error();
|
|
709
999
|
init_logger();
|
|
710
|
-
|
|
711
|
-
init_protected_rc_fallback();
|
|
712
|
-
init_turbopack_patterns();
|
|
1000
|
+
init_patterns();
|
|
713
1001
|
}
|
|
714
1002
|
});
|
|
715
1003
|
|
|
716
|
-
// src/
|
|
1004
|
+
// src/runtime/turbopack/module.ts
|
|
717
1005
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
718
1006
|
const self = globalThis;
|
|
719
1007
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -919,729 +1207,272 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
919
1207
|
// chunk loader
|
|
920
1208
|
l(url) {
|
|
921
1209
|
const flatModules = Array.isArray(modules) ? modules : [];
|
|
922
|
-
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
923
|
-
if (moduleInitIndex !== -1) {
|
|
924
|
-
const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
925
|
-
if (scriptIndex !== -1) {
|
|
926
|
-
const script = flatModules[scriptIndex];
|
|
927
|
-
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
928
|
-
const nextIndex = scriptSrc.indexOf("/_next");
|
|
929
|
-
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
930
|
-
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
931
|
-
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
throw new Error(
|
|
935
|
-
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
936
|
-
);
|
|
937
|
-
},
|
|
938
|
-
// global object for this bundle
|
|
939
|
-
g: self.__remote_components_turbopack_global__?.[bundle],
|
|
940
|
-
m: moduleExports,
|
|
941
|
-
e: exports
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
var init_turbopack_module = __esm({
|
|
945
|
-
"src/shared/client/turbopack-module.ts"() {
|
|
946
|
-
"use strict";
|
|
947
|
-
init_logger();
|
|
948
|
-
init_const();
|
|
949
|
-
}
|
|
950
|
-
});
|
|
951
|
-
|
|
952
|
-
// src/shared/client/shared-modules.ts
|
|
953
|
-
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
954
|
-
const self = globalThis;
|
|
955
|
-
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
956
|
-
if (!self.__remote_shared_modules__[bundle]) {
|
|
957
|
-
self.__remote_shared_modules__[bundle] = {};
|
|
958
|
-
}
|
|
959
|
-
const bundleKey = getBundleKey(bundle);
|
|
960
|
-
let modules = self[`TURBOPACK_${bundleKey}`];
|
|
961
|
-
if (modules && typeof modules === "object" && "__chunks__" in modules) {
|
|
962
|
-
const chunks = modules.__chunks__;
|
|
963
|
-
modules = chunks.flat();
|
|
964
|
-
}
|
|
965
|
-
let sharedModuleInitializer = null;
|
|
966
|
-
if (modules) {
|
|
967
|
-
const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
|
|
968
|
-
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
969
|
-
if (typeof idOrFunc !== "function") {
|
|
970
|
-
return false;
|
|
971
|
-
}
|
|
972
|
-
const funcCode = idOrFunc.toString();
|
|
973
|
-
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
974
|
-
});
|
|
975
|
-
if (sharedModuleInitializerIndex > 0) {
|
|
976
|
-
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
977
|
-
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
978
|
-
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
979
|
-
if (sharedModuleId) {
|
|
980
|
-
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
981
|
-
bundle,
|
|
982
|
-
sharedModuleId,
|
|
983
|
-
`[${bundle}] ${sharedModuleInitializerId}`
|
|
984
|
-
);
|
|
985
|
-
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
if (sharedModuleInitializer) {
|
|
989
|
-
const { shared } = await sharedModuleInitializer;
|
|
990
|
-
const sharedModuleIds = extractSharedModuleIds(
|
|
991
|
-
shared,
|
|
992
|
-
bundleKey,
|
|
993
|
-
self
|
|
994
|
-
);
|
|
995
|
-
return Promise.all(
|
|
996
|
-
Object.entries(sharedModuleIds).map(async ([id, module2]) => {
|
|
997
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
998
|
-
if (hostShared[module2]) {
|
|
999
|
-
self.__remote_shared_modules__[bundle][id] = await hostShared[module2](bundle);
|
|
1000
|
-
} else {
|
|
1001
|
-
logError(
|
|
1002
|
-
"SharedModules",
|
|
1003
|
-
`Host shared module "${module2}" not found for ID ${id}`
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
})
|
|
1008
|
-
);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return Promise.all(
|
|
1012
|
-
Object.entries(remoteShared).map(async ([id, module2]) => {
|
|
1013
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1014
|
-
if (hostShared[module2]) {
|
|
1015
|
-
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1016
|
-
self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module2](bundle);
|
|
1017
|
-
} else {
|
|
1018
|
-
logError(
|
|
1019
|
-
"SharedModules",
|
|
1020
|
-
`Shared module "${module2}" not found for "${bundle}"`
|
|
1021
|
-
);
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
})
|
|
1025
|
-
);
|
|
1026
|
-
}
|
|
1027
|
-
function extractSharedModuleIds(shared, bundleKey, self) {
|
|
1028
|
-
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1029
|
-
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1030
|
-
if (asyncSharedModuleId) {
|
|
1031
|
-
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1032
|
-
let asyncSharedModule;
|
|
1033
|
-
let turbopackModules = self[`TURBOPACK_${bundleKey}`];
|
|
1034
|
-
if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
|
|
1035
|
-
const chunks = turbopackModules.__chunks__;
|
|
1036
|
-
turbopackModules = chunks.flat();
|
|
1037
|
-
}
|
|
1038
|
-
const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
|
|
1039
|
-
key2,
|
|
1040
|
-
value2
|
|
1041
|
-
]) : [];
|
|
1042
|
-
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
1043
|
-
asyncSharedModuleIdNumber
|
|
1044
|
-
);
|
|
1045
|
-
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1046
|
-
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
1047
|
-
}
|
|
1048
|
-
if (asyncSharedModule) {
|
|
1049
|
-
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1050
|
-
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1051
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1052
|
-
"__remote_shared_module_",
|
|
1053
|
-
""
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
return acc;
|
|
1058
|
-
}, {});
|
|
1059
|
-
}
|
|
1060
|
-
function getSharedModule(bundle, id) {
|
|
1061
|
-
const self = globalThis;
|
|
1062
|
-
for (const [key, value] of Object.entries(
|
|
1063
|
-
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
1064
|
-
)) {
|
|
1065
|
-
if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
|
|
1066
|
-
return value;
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
return null;
|
|
1070
|
-
}
|
|
1071
|
-
var init_shared_modules2 = __esm({
|
|
1072
|
-
"src/shared/client/shared-modules.ts"() {
|
|
1073
|
-
"use strict";
|
|
1074
|
-
init_logger();
|
|
1075
|
-
init_const();
|
|
1076
|
-
init_turbopack_module();
|
|
1077
|
-
init_turbopack_patterns();
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
|
-
// src/shared/client/webpack-adapter.ts
|
|
1082
|
-
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1083
|
-
const self = globalThis;
|
|
1084
|
-
if (!self.__remote_bundle_url__) {
|
|
1085
|
-
self.__remote_bundle_url__ = {};
|
|
1086
|
-
}
|
|
1087
|
-
self.__remote_bundle_url__[bundle ?? "default"] = url;
|
|
1088
|
-
self.__webpack_get_script_filename__ = () => null;
|
|
1089
|
-
if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
|
|
1090
|
-
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1091
|
-
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1092
|
-
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1093
|
-
}
|
|
1094
|
-
self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
|
|
1095
|
-
self.__webpack_require__ = createModuleRequire(runtime);
|
|
1096
|
-
self.__webpack_require_type__ = runtime;
|
|
1097
|
-
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1098
|
-
const remoteBundle = bundle ?? "default";
|
|
1099
|
-
self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
|
|
1100
|
-
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
if (runtime === RUNTIME_TURBOPACK) {
|
|
1104
|
-
await Promise.all(
|
|
1105
|
-
scripts.map((script) => {
|
|
1106
|
-
if (script.src) {
|
|
1107
|
-
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
1108
|
-
}
|
|
1109
|
-
return Promise.resolve(void 0);
|
|
1110
|
-
})
|
|
1111
|
-
);
|
|
1112
|
-
}
|
|
1113
|
-
const coreShared = {
|
|
1114
|
-
react: async () => (await import("react")).default,
|
|
1115
|
-
"react-dom": async () => (await import("react-dom")).default,
|
|
1116
|
-
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1117
|
-
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1118
|
-
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1119
|
-
...shared
|
|
1120
|
-
};
|
|
1121
|
-
await initializeSharedModules(
|
|
1122
|
-
bundle ?? "default",
|
|
1123
|
-
// include all core modules as shared
|
|
1124
|
-
coreShared,
|
|
1125
|
-
remoteShared
|
|
1126
|
-
);
|
|
1127
|
-
}
|
|
1128
|
-
function createModuleRequire(runtime) {
|
|
1129
|
-
return (id) => {
|
|
1130
|
-
const self = globalThis;
|
|
1131
|
-
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1132
|
-
bundle: "default",
|
|
1133
|
-
id
|
|
1134
|
-
};
|
|
1135
|
-
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1136
|
-
logDebug("WebpackAdapter", `remoteRuntime: "${remoteRuntime}"`);
|
|
1137
|
-
try {
|
|
1138
|
-
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1139
|
-
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1140
|
-
}
|
|
1141
|
-
const sharedModuleId = moduleId ?? id;
|
|
1142
|
-
const sharedModule = getSharedModule(bundle ?? "default", sharedModuleId);
|
|
1143
|
-
if (sharedModule) {
|
|
1144
|
-
return sharedModule;
|
|
1145
|
-
}
|
|
1146
|
-
if (bundle && moduleId) {
|
|
1147
|
-
return handleTurbopackModule(bundle, moduleId, id);
|
|
1210
|
+
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
1211
|
+
if (moduleInitIndex !== -1) {
|
|
1212
|
+
const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
1213
|
+
if (scriptIndex !== -1) {
|
|
1214
|
+
const script = flatModules[scriptIndex];
|
|
1215
|
+
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1216
|
+
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1217
|
+
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1218
|
+
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
1219
|
+
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
1220
|
+
}
|
|
1148
1221
|
}
|
|
1149
|
-
throw new Error(
|
|
1150
|
-
|
|
1151
|
-
logWarn(
|
|
1152
|
-
"WebpackAdapter",
|
|
1153
|
-
`Module require failed: ${String(requireError)}`
|
|
1222
|
+
throw new Error(
|
|
1223
|
+
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1154
1224
|
);
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
try {
|
|
1164
|
-
logDebug("WebpackAdapter", "Falling back to original webpack require");
|
|
1165
|
-
return self.__original_webpack_require__(id);
|
|
1166
|
-
} catch (originalError) {
|
|
1167
|
-
throw new RemoteComponentsError(
|
|
1168
|
-
`Module "${id}" not found in remote component bundle "${bundle}".`,
|
|
1169
|
-
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1170
|
-
);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1225
|
+
},
|
|
1226
|
+
// global object for this bundle
|
|
1227
|
+
g: self.__remote_components_turbopack_global__?.[bundle],
|
|
1228
|
+
m: moduleExports,
|
|
1229
|
+
e: exports
|
|
1173
1230
|
};
|
|
1174
1231
|
}
|
|
1175
|
-
var
|
|
1176
|
-
"src/
|
|
1232
|
+
var init_module = __esm({
|
|
1233
|
+
"src/runtime/turbopack/module.ts"() {
|
|
1177
1234
|
"use strict";
|
|
1178
|
-
|
|
1235
|
+
init_constants2();
|
|
1179
1236
|
init_logger();
|
|
1180
|
-
init_chunk_loader();
|
|
1181
|
-
init_const();
|
|
1182
|
-
init_shared_modules2();
|
|
1183
|
-
init_turbopack_module();
|
|
1184
1237
|
}
|
|
1185
1238
|
});
|
|
1186
1239
|
|
|
1187
|
-
// src/
|
|
1188
|
-
async function
|
|
1189
|
-
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1190
|
-
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
1191
|
-
const response = await fetch(fetchUrl);
|
|
1192
|
-
if (!response.ok)
|
|
1193
|
-
throw new Error(`Proxied fetch failed: ${response.status}`);
|
|
1194
|
-
const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
|
|
1195
|
-
/\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
|
|
1196
|
-
(_, keyword, quote, relativePath) => {
|
|
1197
|
-
const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
|
|
1198
|
-
const resolvedImportUrl = new URL(
|
|
1199
|
-
resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
|
|
1200
|
-
location.href
|
|
1201
|
-
).href;
|
|
1202
|
-
return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
|
|
1203
|
-
}
|
|
1204
|
-
);
|
|
1205
|
-
const moduleBlobUrl = URL.createObjectURL(
|
|
1206
|
-
new Blob([content], { type: "text/javascript" })
|
|
1207
|
-
);
|
|
1208
|
-
const wrapperContent = [
|
|
1209
|
-
`import*as m from${JSON.stringify(moduleBlobUrl)};`,
|
|
1210
|
-
`globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
|
|
1211
|
-
`globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
|
|
1212
|
-
].join("");
|
|
1213
|
-
const wrapperBlobUrl = URL.createObjectURL(
|
|
1214
|
-
new Blob([wrapperContent], { type: "text/javascript" })
|
|
1215
|
-
);
|
|
1216
|
-
const scriptEl = document.createElement("script");
|
|
1217
|
-
scriptEl.type = "module";
|
|
1218
|
-
scriptEl.src = wrapperBlobUrl;
|
|
1219
|
-
try {
|
|
1220
|
-
await new Promise((resolve, reject) => {
|
|
1221
|
-
scriptEl.onload = () => resolve();
|
|
1222
|
-
scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
|
|
1223
|
-
document.head.appendChild(scriptEl);
|
|
1224
|
-
});
|
|
1225
|
-
} finally {
|
|
1226
|
-
scriptEl.remove();
|
|
1227
|
-
URL.revokeObjectURL(moduleBlobUrl);
|
|
1228
|
-
URL.revokeObjectURL(wrapperBlobUrl);
|
|
1229
|
-
}
|
|
1230
|
-
const registry = globalThis.__rc_module_registry__;
|
|
1231
|
-
const mod = registry?.[absoluteSrc] ?? {};
|
|
1232
|
-
if (registry)
|
|
1233
|
-
delete registry[absoluteSrc];
|
|
1234
|
-
return mod;
|
|
1235
|
-
}
|
|
1236
|
-
async function importDirectly(absoluteSrc) {
|
|
1237
|
-
try {
|
|
1238
|
-
return await import(
|
|
1239
|
-
/* @vite-ignore */
|
|
1240
|
-
/* webpackIgnore: true */
|
|
1241
|
-
absoluteSrc
|
|
1242
|
-
);
|
|
1243
|
-
} catch (importError) {
|
|
1244
|
-
if (!absoluteSrc.startsWith("blob:")) {
|
|
1245
|
-
warnCrossOriginFetchError("StaticLoader", absoluteSrc);
|
|
1246
|
-
}
|
|
1247
|
-
throw importError;
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
function resolveScriptSrc(script, url) {
|
|
1251
|
-
const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
1252
|
-
if (!rawSrc && script.textContent) {
|
|
1253
|
-
return URL.createObjectURL(
|
|
1254
|
-
new Blob(
|
|
1255
|
-
[script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
|
|
1256
|
-
{ type: "text/javascript" }
|
|
1257
|
-
)
|
|
1258
|
-
);
|
|
1259
|
-
}
|
|
1260
|
-
return rawSrc;
|
|
1261
|
-
}
|
|
1262
|
-
async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
1240
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1241
|
+
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1263
1242
|
const self = globalThis;
|
|
1264
|
-
|
|
1265
|
-
|
|
1243
|
+
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
1244
|
+
if (!self.__remote_shared_modules__[bundle]) {
|
|
1245
|
+
self.__remote_shared_modules__[bundle] = {};
|
|
1266
1246
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1247
|
+
const bundleKey = getBundleKey(bundle);
|
|
1248
|
+
let modules = self[`TURBOPACK_${bundleKey}`];
|
|
1249
|
+
if (modules && typeof modules === "object" && "__chunks__" in modules) {
|
|
1250
|
+
const chunks = modules.__chunks__;
|
|
1251
|
+
modules = chunks.flat();
|
|
1269
1252
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1253
|
+
let sharedModuleInitializer = null;
|
|
1254
|
+
if (modules) {
|
|
1255
|
+
const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
|
|
1256
|
+
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1257
|
+
if (typeof idOrFunc !== "function") {
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1260
|
+
const funcCode = idOrFunc.toString();
|
|
1261
|
+
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1262
|
+
});
|
|
1263
|
+
if (sharedModuleInitializerIndex > 0) {
|
|
1264
|
+
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1265
|
+
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1266
|
+
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1267
|
+
if (sharedModuleId) {
|
|
1268
|
+
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1269
|
+
bundle,
|
|
1270
|
+
sharedModuleId,
|
|
1271
|
+
`[${bundle}] ${sharedModuleInitializerId}`
|
|
1272
|
+
);
|
|
1273
|
+
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
if (sharedModuleInitializer) {
|
|
1277
|
+
const { shared } = await sharedModuleInitializer;
|
|
1278
|
+
const sharedModuleIds = extractSharedModuleIds(
|
|
1279
|
+
shared,
|
|
1280
|
+
bundleKey,
|
|
1281
|
+
self
|
|
1282
|
+
);
|
|
1283
|
+
return Promise.all(
|
|
1284
|
+
Object.entries(sharedModuleIds).map(async ([id, module2]) => {
|
|
1285
|
+
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1286
|
+
if (hostShared[module2]) {
|
|
1287
|
+
self.__remote_shared_modules__[bundle][id] = await hostShared[module2](bundle);
|
|
1288
|
+
} else {
|
|
1289
|
+
logError(
|
|
1290
|
+
"SharedModules",
|
|
1291
|
+
`Host shared module "${module2}" not found for ID ${id}`
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1297
1294
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1295
|
+
})
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
return Promise.all(
|
|
1300
|
+
Object.entries(remoteShared).map(async ([id, module2]) => {
|
|
1301
|
+
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1302
|
+
if (hostShared[module2]) {
|
|
1303
|
+
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1304
|
+
self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module2](bundle);
|
|
1305
|
+
} else {
|
|
1306
|
+
logError(
|
|
1307
|
+
"SharedModules",
|
|
1308
|
+
`Shared module "${module2}" not found for "${bundle}"`
|
|
1301
1309
|
);
|
|
1302
1310
|
}
|
|
1303
|
-
return {
|
|
1304
|
-
mount: mod.mount || mod.default?.mount,
|
|
1305
|
-
unmount: mod.unmount || mod.default?.unmount
|
|
1306
|
-
};
|
|
1307
|
-
} catch (e) {
|
|
1308
|
-
logError(
|
|
1309
|
-
"StaticLoader",
|
|
1310
|
-
`Error loading remote component script from "${script.src || url.href}".`,
|
|
1311
|
-
e
|
|
1312
|
-
);
|
|
1313
|
-
return {
|
|
1314
|
-
mount: void 0,
|
|
1315
|
-
unmount: void 0
|
|
1316
|
-
};
|
|
1317
1311
|
}
|
|
1318
1312
|
})
|
|
1319
1313
|
);
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1314
|
+
}
|
|
1315
|
+
function extractSharedModuleIds(shared, bundleKey, self) {
|
|
1316
|
+
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1317
|
+
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1318
|
+
if (asyncSharedModuleId) {
|
|
1319
|
+
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1320
|
+
let asyncSharedModule;
|
|
1321
|
+
let turbopackModules = self[`TURBOPACK_${bundleKey}`];
|
|
1322
|
+
if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
|
|
1323
|
+
const chunks = turbopackModules.__chunks__;
|
|
1324
|
+
turbopackModules = chunks.flat();
|
|
1324
1325
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1326
|
+
const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
|
|
1327
|
+
key2,
|
|
1328
|
+
value2
|
|
1329
|
+
]) : [];
|
|
1330
|
+
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
1331
|
+
asyncSharedModuleIdNumber
|
|
1332
|
+
);
|
|
1333
|
+
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1334
|
+
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
1335
|
+
}
|
|
1336
|
+
if (asyncSharedModule) {
|
|
1337
|
+
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1338
|
+
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1339
|
+
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1340
|
+
"__remote_shared_module_",
|
|
1341
|
+
""
|
|
1342
|
+
);
|
|
1327
1343
|
}
|
|
1328
|
-
return acc;
|
|
1329
|
-
},
|
|
1330
|
-
{
|
|
1331
|
-
mount: /* @__PURE__ */ new Set(),
|
|
1332
|
-
unmount: /* @__PURE__ */ new Set()
|
|
1333
1344
|
}
|
|
1334
|
-
|
|
1345
|
+
return acc;
|
|
1346
|
+
}, {});
|
|
1335
1347
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1348
|
+
function getSharedModule(bundle, id) {
|
|
1349
|
+
const self = globalThis;
|
|
1350
|
+
for (const [key, value] of Object.entries(
|
|
1351
|
+
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
1352
|
+
)) {
|
|
1353
|
+
if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
|
|
1354
|
+
return value;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return null;
|
|
1358
|
+
}
|
|
1359
|
+
var init_shared_modules = __esm({
|
|
1360
|
+
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1338
1361
|
"use strict";
|
|
1362
|
+
init_constants2();
|
|
1339
1363
|
init_logger();
|
|
1364
|
+
init_module();
|
|
1365
|
+
init_patterns();
|
|
1340
1366
|
}
|
|
1341
1367
|
});
|
|
1342
1368
|
|
|
1343
|
-
// src/
|
|
1344
|
-
function
|
|
1369
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1370
|
+
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1345
1371
|
const self = globalThis;
|
|
1346
|
-
if (self.__remote_bundle_url__
|
|
1347
|
-
|
|
1348
|
-
}
|
|
1349
|
-
const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
|
|
1350
|
-
if (!path) {
|
|
1351
|
-
return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
|
|
1372
|
+
if (!self.__remote_bundle_url__) {
|
|
1373
|
+
self.__remote_bundle_url__ = {};
|
|
1352
1374
|
}
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1375
|
+
self.__remote_bundle_url__[bundle ?? "default"] = url;
|
|
1376
|
+
self.__webpack_get_script_filename__ = () => null;
|
|
1377
|
+
if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
|
|
1378
|
+
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1379
|
+
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1380
|
+
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1381
|
+
}
|
|
1382
|
+
self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
|
|
1383
|
+
self.__webpack_require__ = createModuleRequire(runtime);
|
|
1384
|
+
self.__webpack_require_type__ = runtime;
|
|
1385
|
+
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1386
|
+
const remoteBundle = bundle ?? "default";
|
|
1387
|
+
self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
|
|
1388
|
+
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
1389
|
+
}
|
|
1358
1390
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
const polyfill = {
|
|
1365
|
-
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
1366
|
-
useRouter() {
|
|
1367
|
-
return {
|
|
1368
|
-
push: (routerUrl) => {
|
|
1369
|
-
history.pushState({}, "", routerUrl);
|
|
1370
|
-
},
|
|
1371
|
-
replace: (routerUrl) => {
|
|
1372
|
-
history.replaceState({}, "", routerUrl);
|
|
1373
|
-
},
|
|
1374
|
-
back: () => {
|
|
1375
|
-
history.back();
|
|
1376
|
-
}
|
|
1377
|
-
};
|
|
1378
|
-
},
|
|
1379
|
-
usePathname() {
|
|
1380
|
-
return location.pathname;
|
|
1381
|
-
},
|
|
1382
|
-
useParams() {
|
|
1383
|
-
return {};
|
|
1384
|
-
},
|
|
1385
|
-
useSearchParams() {
|
|
1386
|
-
return new URLSearchParams(location.search);
|
|
1387
|
-
},
|
|
1388
|
-
useSelectedLayoutSegment() {
|
|
1389
|
-
return null;
|
|
1390
|
-
},
|
|
1391
|
-
useSelectedLayoutSegments() {
|
|
1392
|
-
return [];
|
|
1393
|
-
},
|
|
1394
|
-
__esModule: true
|
|
1395
|
-
})),
|
|
1396
|
-
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
1397
|
-
default: ({
|
|
1398
|
-
scroll: _,
|
|
1399
|
-
replace,
|
|
1400
|
-
prefetch,
|
|
1401
|
-
onNavigate,
|
|
1402
|
-
children,
|
|
1403
|
-
...props
|
|
1404
|
-
}) => {
|
|
1405
|
-
if (prefetch) {
|
|
1406
|
-
logWarn(
|
|
1407
|
-
"Polyfill",
|
|
1408
|
-
"Next.js Link prefetch is not supported in remote components"
|
|
1409
|
-
);
|
|
1391
|
+
if (runtime === RUNTIME_TURBOPACK) {
|
|
1392
|
+
await Promise.all(
|
|
1393
|
+
scripts.map((script) => {
|
|
1394
|
+
if (script.src) {
|
|
1395
|
+
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
1410
1396
|
}
|
|
1411
|
-
return
|
|
1412
|
-
"a",
|
|
1413
|
-
{
|
|
1414
|
-
...props,
|
|
1415
|
-
href: props.href,
|
|
1416
|
-
onClick: (e) => {
|
|
1417
|
-
e.preventDefault();
|
|
1418
|
-
let preventDefaulted = false;
|
|
1419
|
-
e.preventDefault = () => {
|
|
1420
|
-
preventDefaulted = true;
|
|
1421
|
-
e.defaultPrevented = true;
|
|
1422
|
-
};
|
|
1423
|
-
if (typeof props.onClick === "function") {
|
|
1424
|
-
props.onClick(e);
|
|
1425
|
-
}
|
|
1426
|
-
onNavigate?.(e);
|
|
1427
|
-
if (preventDefaulted) {
|
|
1428
|
-
return;
|
|
1429
|
-
}
|
|
1430
|
-
if (replace) {
|
|
1431
|
-
history.replaceState({}, "", props.href);
|
|
1432
|
-
} else {
|
|
1433
|
-
history.pushState({}, "", props.href);
|
|
1434
|
-
}
|
|
1435
|
-
},
|
|
1436
|
-
suppressHydrationWarning: true,
|
|
1437
|
-
children: children ?? null
|
|
1438
|
-
}
|
|
1439
|
-
);
|
|
1440
|
-
},
|
|
1441
|
-
useLinkStatus() {
|
|
1442
|
-
return { pending: false };
|
|
1443
|
-
},
|
|
1444
|
-
__esModule: true
|
|
1445
|
-
})),
|
|
1446
|
-
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
1447
|
-
default: () => {
|
|
1448
|
-
throw new Error("Next.js <Form> component not implemented");
|
|
1449
|
-
},
|
|
1450
|
-
__esModule: true
|
|
1451
|
-
})),
|
|
1452
|
-
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
1453
|
-
Image: imageImpl(bundle),
|
|
1454
|
-
__esModule: true
|
|
1455
|
-
})),
|
|
1456
|
-
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
1457
|
-
default: imageImpl(bundle),
|
|
1458
|
-
getImageProps: (_imgProps) => {
|
|
1459
|
-
throw new Error(
|
|
1460
|
-
"Next.js getImageProps() is not implemented in remote components"
|
|
1461
|
-
);
|
|
1462
|
-
},
|
|
1463
|
-
__esModule: true
|
|
1464
|
-
})),
|
|
1465
|
-
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
1466
|
-
// TODO: implement <Script> component for non-Next.js host applications
|
|
1467
|
-
// do not throw an error for now
|
|
1468
|
-
default: () => null,
|
|
1469
|
-
__esModule: true
|
|
1470
|
-
})),
|
|
1471
|
-
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
1472
|
-
// TODO: incomplete implementation
|
|
1473
|
-
Promise.resolve({
|
|
1474
|
-
useRouter() {
|
|
1475
|
-
return {
|
|
1476
|
-
push: (routerUrl) => {
|
|
1477
|
-
history.pushState({}, "", routerUrl);
|
|
1478
|
-
},
|
|
1479
|
-
replace: (routerUrl) => {
|
|
1480
|
-
history.replaceState({}, "", routerUrl);
|
|
1481
|
-
},
|
|
1482
|
-
back: () => {
|
|
1483
|
-
history.back();
|
|
1484
|
-
}
|
|
1485
|
-
};
|
|
1486
|
-
},
|
|
1487
|
-
__esModule: true
|
|
1397
|
+
return Promise.resolve(void 0);
|
|
1488
1398
|
})
|
|
1489
|
-
)
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
const coreShared = {
|
|
1402
|
+
react: async () => (await import("react")).default,
|
|
1403
|
+
"react-dom": async () => (await import("react-dom")).default,
|
|
1404
|
+
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1405
|
+
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1406
|
+
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1407
|
+
...shared
|
|
1498
1408
|
};
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1409
|
+
await initializeSharedModules(
|
|
1410
|
+
bundle ?? "default",
|
|
1411
|
+
// include all core modules as shared
|
|
1412
|
+
coreShared,
|
|
1413
|
+
remoteShared
|
|
1414
|
+
);
|
|
1505
1415
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
{
|
|
1533
|
-
decoding: "async",
|
|
1534
|
-
style: { color: "transparent" },
|
|
1535
|
-
...props,
|
|
1536
|
-
src: newSrc,
|
|
1537
|
-
suppressHydrationWarning: true
|
|
1538
|
-
}
|
|
1416
|
+
function createModuleRequire(runtime) {
|
|
1417
|
+
return (id) => {
|
|
1418
|
+
const self = globalThis;
|
|
1419
|
+
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1420
|
+
bundle: "default",
|
|
1421
|
+
id
|
|
1422
|
+
};
|
|
1423
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1424
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1425
|
+
try {
|
|
1426
|
+
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1427
|
+
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1428
|
+
}
|
|
1429
|
+
const sharedModuleId = moduleId ?? id;
|
|
1430
|
+
const sharedModule = getSharedModule(bundle ?? "default", sharedModuleId);
|
|
1431
|
+
if (sharedModule) {
|
|
1432
|
+
return sharedModule;
|
|
1433
|
+
}
|
|
1434
|
+
if (bundle && moduleId) {
|
|
1435
|
+
return handleTurbopackModule(bundle, moduleId, id);
|
|
1436
|
+
}
|
|
1437
|
+
throw new Error(`Module "${id}" not found.`);
|
|
1438
|
+
} catch (requireError) {
|
|
1439
|
+
logWarn(
|
|
1440
|
+
"WebpackRuntime",
|
|
1441
|
+
`Module require failed: ${String(requireError)}`
|
|
1539
1442
|
);
|
|
1540
|
-
|
|
1541
|
-
}
|
|
1542
|
-
});
|
|
1543
|
-
|
|
1544
|
-
// src/html/host/runtime/webpack.ts
|
|
1545
|
-
var webpack_exports = {};
|
|
1546
|
-
__export(webpack_exports, {
|
|
1547
|
-
webpackRuntime: () => webpackRuntime
|
|
1548
|
-
});
|
|
1549
|
-
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
1550
|
-
const self = globalThis;
|
|
1551
|
-
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
1552
|
-
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
1553
|
-
}
|
|
1554
|
-
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1555
|
-
if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
|
|
1556
|
-
self.__webpack_require__ = (remoteId) => {
|
|
1557
|
-
const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
|
|
1558
|
-
const match = re.exec(remoteId);
|
|
1559
|
-
const remoteBundle = match?.groups?.bundle;
|
|
1560
|
-
const id = match?.groups?.id;
|
|
1561
|
-
if (!(id && remoteBundle)) {
|
|
1443
|
+
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1562
1444
|
throw new RemoteComponentsError(
|
|
1563
|
-
`
|
|
1445
|
+
`Module "${id}" not found in remote component bundle "${bundle}".`,
|
|
1446
|
+
{
|
|
1447
|
+
cause: requireError instanceof Error ? requireError : void 0
|
|
1448
|
+
}
|
|
1564
1449
|
);
|
|
1565
1450
|
}
|
|
1566
|
-
|
|
1451
|
+
try {
|
|
1452
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1453
|
+
return self.__original_webpack_require__(id);
|
|
1454
|
+
} catch (originalError) {
|
|
1567
1455
|
throw new RemoteComponentsError(
|
|
1568
|
-
`
|
|
1456
|
+
`Module "${id}" not found in remote component bundle "${bundle}".`,
|
|
1457
|
+
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1569
1458
|
);
|
|
1570
1459
|
}
|
|
1571
|
-
|
|
1572
|
-
};
|
|
1573
|
-
self.__webpack_chunk_load__ = () => {
|
|
1574
|
-
return Promise.resolve([]);
|
|
1575
|
-
};
|
|
1576
|
-
}
|
|
1577
|
-
const {
|
|
1578
|
-
default: { createFromReadableStream }
|
|
1579
|
-
} = await import("react-server-dom-webpack/client.browser");
|
|
1580
|
-
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
1581
|
-
const scriptSrcs = scripts.flatMap((script) => {
|
|
1582
|
-
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
1583
|
-
script.parentElement?.removeChild(script);
|
|
1584
|
-
if (!scriptSrc)
|
|
1585
|
-
return [];
|
|
1586
|
-
return [
|
|
1587
|
-
{
|
|
1588
|
-
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
1589
|
-
}
|
|
1590
|
-
];
|
|
1591
|
-
});
|
|
1592
|
-
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
1593
|
-
const hostShared = {
|
|
1594
|
-
...sharedPolyfills(shared),
|
|
1595
|
-
...self.__remote_component_host_shared_modules__,
|
|
1596
|
-
...shared
|
|
1597
|
-
};
|
|
1598
|
-
const resolve = {
|
|
1599
|
-
"/react/index.js": (await import("react")).default,
|
|
1600
|
-
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
1601
|
-
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
1602
|
-
"/react-dom/index.js": (await import("react-dom")).default,
|
|
1603
|
-
"/react-dom/client.js": (await import("react-dom/client")).default,
|
|
1604
|
-
...Object.entries(remoteShared ?? {}).reduce(
|
|
1605
|
-
(acc, [key, value]) => {
|
|
1606
|
-
if (typeof hostShared[value] !== "undefined") {
|
|
1607
|
-
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
1608
|
-
}
|
|
1609
|
-
return acc;
|
|
1610
|
-
},
|
|
1611
|
-
{}
|
|
1612
|
-
)
|
|
1613
|
-
};
|
|
1614
|
-
await Promise.all(
|
|
1615
|
-
Object.entries(resolve).map(async ([key, value]) => {
|
|
1616
|
-
if (typeof value === "function") {
|
|
1617
|
-
resolve[key] = await value(remoteBundle);
|
|
1618
|
-
}
|
|
1619
|
-
return Promise.resolve(value);
|
|
1620
|
-
})
|
|
1621
|
-
);
|
|
1622
|
-
applySharedModules(remoteBundle, resolve);
|
|
1623
|
-
}
|
|
1624
|
-
return {
|
|
1625
|
-
self,
|
|
1626
|
-
createFromReadableStream,
|
|
1627
|
-
applySharedModules,
|
|
1628
|
-
nextClientPagesLoader,
|
|
1629
|
-
preloadScripts
|
|
1460
|
+
}
|
|
1630
1461
|
};
|
|
1631
1462
|
}
|
|
1632
|
-
var
|
|
1633
|
-
"src/
|
|
1463
|
+
var init_webpack_runtime = __esm({
|
|
1464
|
+
"src/runtime/turbopack/webpack-runtime.ts"() {
|
|
1634
1465
|
"use strict";
|
|
1635
|
-
|
|
1636
|
-
init_script_loader();
|
|
1637
|
-
init_webpack_patterns();
|
|
1466
|
+
init_constants2();
|
|
1638
1467
|
init_error();
|
|
1639
|
-
|
|
1468
|
+
init_logger();
|
|
1469
|
+
init_chunk_loader();
|
|
1470
|
+
init_module();
|
|
1640
1471
|
init_shared_modules();
|
|
1641
1472
|
}
|
|
1642
1473
|
});
|
|
1643
1474
|
|
|
1644
|
-
// src/html/
|
|
1475
|
+
// src/host/html/runtime/turbopack.ts
|
|
1645
1476
|
var turbopack_exports = {};
|
|
1646
1477
|
__export(turbopack_exports, {
|
|
1647
1478
|
turbopackRuntime: () => turbopackRuntime
|
|
@@ -1649,7 +1480,7 @@ __export(turbopack_exports, {
|
|
|
1649
1480
|
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1650
1481
|
const self = globalThis;
|
|
1651
1482
|
const hostShared = {
|
|
1652
|
-
...sharedPolyfills(shared),
|
|
1483
|
+
...sharedPolyfills(shared, resolveClientUrl),
|
|
1653
1484
|
...self.__remote_component_host_shared_modules__,
|
|
1654
1485
|
...shared,
|
|
1655
1486
|
...self.__remote_component_shared__
|
|
@@ -1663,41 +1494,197 @@ async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClient
|
|
|
1663
1494
|
remoteShared,
|
|
1664
1495
|
resolveClientUrl
|
|
1665
1496
|
);
|
|
1666
|
-
const {
|
|
1667
|
-
default: { createFromReadableStream }
|
|
1668
|
-
} = await import("react-server-dom-webpack/client.browser");
|
|
1669
|
-
function preloadScripts(scripts, __) {
|
|
1670
|
-
return setupWebpackRuntime(
|
|
1671
|
-
"turbopack",
|
|
1672
|
-
scripts.map((script) => ({
|
|
1673
|
-
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1674
|
-
})),
|
|
1675
|
-
url,
|
|
1676
|
-
bundle,
|
|
1677
|
-
hostShared,
|
|
1678
|
-
remoteShared,
|
|
1679
|
-
resolveClientUrl
|
|
1680
|
-
);
|
|
1681
|
-
}
|
|
1682
|
-
return {
|
|
1683
|
-
self,
|
|
1684
|
-
createFromReadableStream,
|
|
1685
|
-
applySharedModules,
|
|
1686
|
-
nextClientPagesLoader,
|
|
1687
|
-
preloadScripts
|
|
1688
|
-
};
|
|
1497
|
+
const {
|
|
1498
|
+
default: { createFromReadableStream }
|
|
1499
|
+
} = await import("react-server-dom-webpack/client.browser");
|
|
1500
|
+
function preloadScripts(scripts, __) {
|
|
1501
|
+
return setupWebpackRuntime(
|
|
1502
|
+
"turbopack",
|
|
1503
|
+
scripts.map((script) => ({
|
|
1504
|
+
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1505
|
+
})),
|
|
1506
|
+
url,
|
|
1507
|
+
bundle,
|
|
1508
|
+
hostShared,
|
|
1509
|
+
remoteShared,
|
|
1510
|
+
resolveClientUrl
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
return {
|
|
1514
|
+
self,
|
|
1515
|
+
createFromReadableStream,
|
|
1516
|
+
applySharedModules,
|
|
1517
|
+
nextClientPagesLoader,
|
|
1518
|
+
preloadScripts
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
var init_turbopack = __esm({
|
|
1522
|
+
"src/host/html/runtime/turbopack.ts"() {
|
|
1523
|
+
"use strict";
|
|
1524
|
+
init_apply_shared_modules();
|
|
1525
|
+
init_next_client_pages_loader();
|
|
1526
|
+
init_polyfill();
|
|
1527
|
+
init_webpack_runtime();
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
// src/runtime/loaders/static-loader.ts
|
|
1532
|
+
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1533
|
+
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1534
|
+
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
1535
|
+
const response = await fetch(fetchUrl);
|
|
1536
|
+
if (!response.ok)
|
|
1537
|
+
throw new Error(`Proxied fetch failed: ${response.status}`);
|
|
1538
|
+
const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
|
|
1539
|
+
/\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
|
|
1540
|
+
(_, keyword, quote, relativePath) => {
|
|
1541
|
+
const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
|
|
1542
|
+
const resolvedImportUrl = new URL(
|
|
1543
|
+
resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
|
|
1544
|
+
location.href
|
|
1545
|
+
).href;
|
|
1546
|
+
return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
|
|
1547
|
+
}
|
|
1548
|
+
);
|
|
1549
|
+
const moduleBlobUrl = URL.createObjectURL(
|
|
1550
|
+
new Blob([content], { type: "text/javascript" })
|
|
1551
|
+
);
|
|
1552
|
+
const wrapperContent = [
|
|
1553
|
+
`import*as m from${JSON.stringify(moduleBlobUrl)};`,
|
|
1554
|
+
`globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
|
|
1555
|
+
`globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
|
|
1556
|
+
].join("");
|
|
1557
|
+
const wrapperBlobUrl = URL.createObjectURL(
|
|
1558
|
+
new Blob([wrapperContent], { type: "text/javascript" })
|
|
1559
|
+
);
|
|
1560
|
+
const scriptEl = document.createElement("script");
|
|
1561
|
+
scriptEl.type = "module";
|
|
1562
|
+
scriptEl.src = wrapperBlobUrl;
|
|
1563
|
+
try {
|
|
1564
|
+
await new Promise((resolve, reject) => {
|
|
1565
|
+
scriptEl.onload = () => resolve();
|
|
1566
|
+
scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
|
|
1567
|
+
document.head.appendChild(scriptEl);
|
|
1568
|
+
});
|
|
1569
|
+
} finally {
|
|
1570
|
+
scriptEl.remove();
|
|
1571
|
+
URL.revokeObjectURL(moduleBlobUrl);
|
|
1572
|
+
URL.revokeObjectURL(wrapperBlobUrl);
|
|
1573
|
+
}
|
|
1574
|
+
const registry = globalThis.__rc_module_registry__;
|
|
1575
|
+
const mod = registry?.[absoluteSrc] ?? {};
|
|
1576
|
+
if (registry)
|
|
1577
|
+
delete registry[absoluteSrc];
|
|
1578
|
+
return mod;
|
|
1579
|
+
}
|
|
1580
|
+
async function importDirectly(absoluteSrc) {
|
|
1581
|
+
try {
|
|
1582
|
+
return await import(
|
|
1583
|
+
/* @vite-ignore */
|
|
1584
|
+
/* webpackIgnore: true */
|
|
1585
|
+
absoluteSrc
|
|
1586
|
+
);
|
|
1587
|
+
} catch (importError) {
|
|
1588
|
+
if (!absoluteSrc.startsWith("blob:")) {
|
|
1589
|
+
warnCrossOriginFetchError("StaticLoader", absoluteSrc);
|
|
1590
|
+
}
|
|
1591
|
+
throw importError;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
function resolveScriptSrc(script, url) {
|
|
1595
|
+
const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
1596
|
+
if (!rawSrc && script.textContent) {
|
|
1597
|
+
return URL.createObjectURL(
|
|
1598
|
+
new Blob(
|
|
1599
|
+
[script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
|
|
1600
|
+
{ type: "text/javascript" }
|
|
1601
|
+
)
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
return rawSrc;
|
|
1605
|
+
}
|
|
1606
|
+
async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
1607
|
+
const self = globalThis;
|
|
1608
|
+
if (self.__remote_script_entrypoint_mount__?.[url.href]) {
|
|
1609
|
+
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
1610
|
+
}
|
|
1611
|
+
if (self.__remote_script_entrypoint_unmount__?.[url.href]) {
|
|
1612
|
+
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
1613
|
+
}
|
|
1614
|
+
const mountUnmountSets = await Promise.all(
|
|
1615
|
+
scripts.map(async (script) => {
|
|
1616
|
+
try {
|
|
1617
|
+
const src = resolveScriptSrc(script, url);
|
|
1618
|
+
const absoluteSrc = new URL(src, url).href;
|
|
1619
|
+
const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
|
|
1620
|
+
if (src.startsWith("blob:")) {
|
|
1621
|
+
URL.revokeObjectURL(src);
|
|
1622
|
+
}
|
|
1623
|
+
if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
|
|
1624
|
+
if (!self.__remote_script_entrypoint_mount__) {
|
|
1625
|
+
self.__remote_script_entrypoint_mount__ = {};
|
|
1626
|
+
}
|
|
1627
|
+
if (!self.__remote_script_entrypoint_mount__[url.href]) {
|
|
1628
|
+
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
1629
|
+
}
|
|
1630
|
+
self.__remote_script_entrypoint_mount__[url.href]?.add(
|
|
1631
|
+
mod.mount || mod.default?.mount || (() => {
|
|
1632
|
+
})
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1635
|
+
if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
|
|
1636
|
+
if (!self.__remote_script_entrypoint_unmount__) {
|
|
1637
|
+
self.__remote_script_entrypoint_unmount__ = {};
|
|
1638
|
+
}
|
|
1639
|
+
if (!self.__remote_script_entrypoint_unmount__[url.href]) {
|
|
1640
|
+
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
1641
|
+
}
|
|
1642
|
+
self.__remote_script_entrypoint_unmount__[url.href]?.add(
|
|
1643
|
+
mod.unmount || mod.default?.unmount || (() => {
|
|
1644
|
+
})
|
|
1645
|
+
);
|
|
1646
|
+
}
|
|
1647
|
+
return {
|
|
1648
|
+
mount: mod.mount || mod.default?.mount,
|
|
1649
|
+
unmount: mod.unmount || mod.default?.unmount
|
|
1650
|
+
};
|
|
1651
|
+
} catch (e) {
|
|
1652
|
+
logError(
|
|
1653
|
+
"StaticLoader",
|
|
1654
|
+
`Error loading remote component script from "${script.src || url.href}".`,
|
|
1655
|
+
e
|
|
1656
|
+
);
|
|
1657
|
+
return {
|
|
1658
|
+
mount: void 0,
|
|
1659
|
+
unmount: void 0
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
})
|
|
1663
|
+
);
|
|
1664
|
+
return mountUnmountSets.reduce(
|
|
1665
|
+
(acc, { mount, unmount }) => {
|
|
1666
|
+
if (typeof mount === "function") {
|
|
1667
|
+
acc.mount.add(mount);
|
|
1668
|
+
}
|
|
1669
|
+
if (typeof unmount === "function") {
|
|
1670
|
+
acc.unmount.add(unmount);
|
|
1671
|
+
}
|
|
1672
|
+
return acc;
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
mount: /* @__PURE__ */ new Set(),
|
|
1676
|
+
unmount: /* @__PURE__ */ new Set()
|
|
1677
|
+
}
|
|
1678
|
+
);
|
|
1689
1679
|
}
|
|
1690
|
-
var
|
|
1691
|
-
"src/
|
|
1680
|
+
var init_static_loader = __esm({
|
|
1681
|
+
"src/runtime/loaders/static-loader.ts"() {
|
|
1692
1682
|
"use strict";
|
|
1693
|
-
|
|
1694
|
-
init_webpack_adapter();
|
|
1695
|
-
init_next_client_pages_loader();
|
|
1696
|
-
init_shared_modules();
|
|
1683
|
+
init_logger();
|
|
1697
1684
|
}
|
|
1698
1685
|
});
|
|
1699
1686
|
|
|
1700
|
-
// src/html/
|
|
1687
|
+
// src/host/html/runtime/script.ts
|
|
1701
1688
|
var script_exports = {};
|
|
1702
1689
|
__export(script_exports, {
|
|
1703
1690
|
scriptRuntime: () => scriptRuntime
|
|
@@ -1716,23 +1703,106 @@ function scriptRuntime(resolveClientUrl) {
|
|
|
1716
1703
|
};
|
|
1717
1704
|
}
|
|
1718
1705
|
var init_script = __esm({
|
|
1719
|
-
"src/html/
|
|
1706
|
+
"src/host/html/runtime/script.ts"() {
|
|
1720
1707
|
"use strict";
|
|
1721
1708
|
init_static_loader();
|
|
1722
1709
|
}
|
|
1723
1710
|
});
|
|
1724
1711
|
|
|
1725
|
-
// src/html/
|
|
1726
|
-
var
|
|
1727
|
-
__export(
|
|
1728
|
-
proxyClientRequestsThroughHost: () => proxyClientRequestsThroughHost,
|
|
1712
|
+
// src/host/html/index.tsx
|
|
1713
|
+
var html_exports = {};
|
|
1714
|
+
__export(html_exports, {
|
|
1729
1715
|
registerSharedModules: () => registerSharedModules
|
|
1730
1716
|
});
|
|
1731
|
-
module.exports = __toCommonJS(
|
|
1717
|
+
module.exports = __toCommonJS(html_exports);
|
|
1732
1718
|
var import_react = require("react");
|
|
1733
1719
|
var import_client = require("react-dom/client");
|
|
1734
1720
|
|
|
1735
|
-
// src/
|
|
1721
|
+
// src/host/server/fetch-with-hooks.ts
|
|
1722
|
+
init_logger();
|
|
1723
|
+
|
|
1724
|
+
// src/host/server/fetch-headers.ts
|
|
1725
|
+
function remoteFetchHeaders() {
|
|
1726
|
+
return {
|
|
1727
|
+
/**
|
|
1728
|
+
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1729
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1730
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1731
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1732
|
+
*/
|
|
1733
|
+
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1734
|
+
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1735
|
+
} : {},
|
|
1736
|
+
Accept: "text/html"
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
// src/host/server/fetch-with-hooks.ts
|
|
1741
|
+
async function fetchWithWarning(url, init) {
|
|
1742
|
+
try {
|
|
1743
|
+
return await fetch(url, init);
|
|
1744
|
+
} catch (error) {
|
|
1745
|
+
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1746
|
+
throw error;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1750
|
+
const {
|
|
1751
|
+
onRequest,
|
|
1752
|
+
onResponse,
|
|
1753
|
+
abortController = new AbortController()
|
|
1754
|
+
} = options;
|
|
1755
|
+
const signal = abortController.signal;
|
|
1756
|
+
const hookOptions = {
|
|
1757
|
+
signal,
|
|
1758
|
+
abort: (reason) => abortController.abort(reason)
|
|
1759
|
+
};
|
|
1760
|
+
const init = {
|
|
1761
|
+
method: "GET",
|
|
1762
|
+
headers: remoteFetchHeaders(),
|
|
1763
|
+
signal,
|
|
1764
|
+
...additionalInit
|
|
1765
|
+
};
|
|
1766
|
+
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
1767
|
+
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// src/host/server/get-client-or-server-url.ts
|
|
1771
|
+
function getClientOrServerUrl(src, serverFallback) {
|
|
1772
|
+
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
1773
|
+
if (!src) {
|
|
1774
|
+
return new URL(fallback);
|
|
1775
|
+
}
|
|
1776
|
+
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// src/host/shared/state.ts
|
|
1780
|
+
function createHostState() {
|
|
1781
|
+
return {
|
|
1782
|
+
stage: "idle",
|
|
1783
|
+
prevSrc: void 0,
|
|
1784
|
+
prevUrl: void 0,
|
|
1785
|
+
prevName: void 0,
|
|
1786
|
+
prevIsRemoteComponent: false,
|
|
1787
|
+
abortController: void 0
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
1792
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
1793
|
+
if (!src) {
|
|
1794
|
+
return defaultName;
|
|
1795
|
+
}
|
|
1796
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
1797
|
+
const hashIndex = hash.indexOf("#");
|
|
1798
|
+
if (hashIndex < 0) {
|
|
1799
|
+
return defaultName;
|
|
1800
|
+
}
|
|
1801
|
+
const name = hash.slice(hashIndex + 1);
|
|
1802
|
+
return name || defaultName;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// src/runtime/html/apply-origin.ts
|
|
1736
1806
|
var tagNames = [
|
|
1737
1807
|
"img",
|
|
1738
1808
|
"source",
|
|
@@ -1794,51 +1864,9 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
|
1794
1864
|
}
|
|
1795
1865
|
}
|
|
1796
1866
|
|
|
1797
|
-
// src/
|
|
1798
|
-
|
|
1799
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1800
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
1801
|
-
return (url) => {
|
|
1802
|
-
const urlOrigin = parseOrigin(url);
|
|
1803
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
1804
|
-
return void 0;
|
|
1805
|
-
}
|
|
1806
|
-
return resolveClientUrl(remoteSrc, url);
|
|
1807
|
-
};
|
|
1808
|
-
}
|
|
1809
|
-
function parseOrigin(url) {
|
|
1810
|
-
try {
|
|
1811
|
-
return new URL(url).origin;
|
|
1812
|
-
} catch {
|
|
1813
|
-
return void 0;
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
var proxyClientRequestsThroughHost = (remoteSrc, url) => {
|
|
1817
|
-
if (typeof location === "undefined") {
|
|
1818
|
-
return void 0;
|
|
1819
|
-
}
|
|
1820
|
-
const remoteOrigin = new URL(remoteSrc, location.href).origin;
|
|
1821
|
-
if (remoteOrigin === location.origin) {
|
|
1822
|
-
return void 0;
|
|
1823
|
-
}
|
|
1824
|
-
try {
|
|
1825
|
-
const parsed = new URL(url, location.href);
|
|
1826
|
-
if (parsed.origin === remoteOrigin) {
|
|
1827
|
-
return generateProtectedRcFallbackSrc(url);
|
|
1828
|
-
}
|
|
1829
|
-
} catch {
|
|
1830
|
-
}
|
|
1831
|
-
return void 0;
|
|
1832
|
-
};
|
|
1833
|
-
|
|
1834
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1835
|
-
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1836
|
-
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
// src/shared/client/parse-remote-html.ts
|
|
1867
|
+
// src/runtime/html/parse-remote-html.ts
|
|
1868
|
+
init_constants2();
|
|
1840
1869
|
init_error();
|
|
1841
|
-
init_const();
|
|
1842
1870
|
function validateSingleComponent(doc, name, url) {
|
|
1843
1871
|
if (doc.querySelectorAll("div[data-bundle][data-route]").length > 1 && !doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
1844
1872
|
throw multipleRemoteComponentsError(url);
|
|
@@ -1932,21 +1960,7 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
1932
1960
|
};
|
|
1933
1961
|
}
|
|
1934
1962
|
|
|
1935
|
-
// src/
|
|
1936
|
-
init_error();
|
|
1937
|
-
|
|
1938
|
-
// src/shared/client/component-loader.ts
|
|
1939
|
-
var React = __toESM(require("react"), 1);
|
|
1940
|
-
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
1941
|
-
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
1942
|
-
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
1943
|
-
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
1944
|
-
init_error();
|
|
1945
|
-
init_logger();
|
|
1946
|
-
init_next_client_pages_loader();
|
|
1947
|
-
init_shared_modules();
|
|
1948
|
-
|
|
1949
|
-
// src/shared/client/rsc.ts
|
|
1963
|
+
// src/runtime/rsc.ts
|
|
1950
1964
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
1951
1965
|
function fixPayload(payload) {
|
|
1952
1966
|
if (Array.isArray(payload)) {
|
|
@@ -2012,113 +2026,37 @@ function createRSCStream(rscName, data) {
|
|
|
2012
2026
|
});
|
|
2013
2027
|
}
|
|
2014
2028
|
|
|
2015
|
-
// src/
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
// src/shared/contract/host-state.ts
|
|
2026
|
-
function createHostState() {
|
|
2027
|
-
return {
|
|
2028
|
-
stage: "idle",
|
|
2029
|
-
prevSrc: void 0,
|
|
2030
|
-
prevUrl: void 0,
|
|
2031
|
-
prevName: void 0,
|
|
2032
|
-
prevIsRemoteComponent: false,
|
|
2033
|
-
abortController: void 0
|
|
2034
|
-
};
|
|
2035
|
-
}
|
|
2036
|
-
|
|
2037
|
-
// src/shared/contract/resolve-name-from-src.ts
|
|
2038
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
2039
|
-
if (!src) {
|
|
2040
|
-
return defaultName;
|
|
2041
|
-
}
|
|
2042
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
2043
|
-
const hashIndex = hash.indexOf("#");
|
|
2044
|
-
if (hashIndex < 0) {
|
|
2045
|
-
return defaultName;
|
|
2046
|
-
}
|
|
2047
|
-
const name = hash.slice(hashIndex + 1);
|
|
2048
|
-
return name || defaultName;
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
// src/html/host/index.tsx
|
|
2052
|
-
init_error();
|
|
2053
|
-
|
|
2054
|
-
// src/shared/ssr/fetch-with-hooks.ts
|
|
2055
|
-
init_logger();
|
|
2056
|
-
|
|
2057
|
-
// src/shared/ssr/fetch-headers.ts
|
|
2058
|
-
function remoteFetchHeaders() {
|
|
2059
|
-
return {
|
|
2060
|
-
/**
|
|
2061
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
2062
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
2063
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
2064
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
2065
|
-
*/
|
|
2066
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
2067
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
2068
|
-
} : {},
|
|
2069
|
-
Accept: "text/html"
|
|
2029
|
+
// src/runtime/url/resolve-client-url.ts
|
|
2030
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
2031
|
+
const remoteOrigin = parseOrigin(remoteSrc);
|
|
2032
|
+
return (url) => {
|
|
2033
|
+
const urlOrigin = parseOrigin(url);
|
|
2034
|
+
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
2035
|
+
return void 0;
|
|
2036
|
+
}
|
|
2037
|
+
return resolveClientUrl(remoteSrc, url);
|
|
2070
2038
|
};
|
|
2071
2039
|
}
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
onResponse,
|
|
2078
|
-
abortController = new AbortController()
|
|
2079
|
-
} = options;
|
|
2080
|
-
const signal = abortController.signal;
|
|
2081
|
-
const hookOptions = {
|
|
2082
|
-
signal,
|
|
2083
|
-
abort: (reason) => abortController.abort(reason)
|
|
2084
|
-
};
|
|
2085
|
-
const init = {
|
|
2086
|
-
method: "GET",
|
|
2087
|
-
headers: remoteFetchHeaders(),
|
|
2088
|
-
signal,
|
|
2089
|
-
...additionalInit
|
|
2090
|
-
};
|
|
2091
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
2092
|
-
if (!res) {
|
|
2093
|
-
try {
|
|
2094
|
-
res = await fetch(url, init);
|
|
2095
|
-
} catch (error) {
|
|
2096
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
2097
|
-
throw error;
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
2101
|
-
if (transformedRes) {
|
|
2102
|
-
res = transformedRes;
|
|
2040
|
+
function parseOrigin(url) {
|
|
2041
|
+
try {
|
|
2042
|
+
return new URL(url).origin;
|
|
2043
|
+
} catch {
|
|
2044
|
+
return void 0;
|
|
2103
2045
|
}
|
|
2104
|
-
return res;
|
|
2105
2046
|
}
|
|
2106
2047
|
|
|
2107
|
-
// src/
|
|
2108
|
-
function
|
|
2109
|
-
|
|
2110
|
-
if (!src) {
|
|
2111
|
-
return new URL(fallback);
|
|
2112
|
-
}
|
|
2113
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
2048
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
2049
|
+
function bindResolveClientUrl(prop, remoteSrc) {
|
|
2050
|
+
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
2114
2051
|
}
|
|
2115
2052
|
|
|
2116
|
-
// src/html/
|
|
2053
|
+
// src/host/html/index.tsx
|
|
2117
2054
|
init_utils();
|
|
2118
2055
|
init_abort();
|
|
2056
|
+
init_error();
|
|
2119
2057
|
init_logger();
|
|
2120
2058
|
|
|
2121
|
-
// src/html/
|
|
2059
|
+
// src/host/html/attach-styles.ts
|
|
2122
2060
|
init_error();
|
|
2123
2061
|
async function attachStyles({
|
|
2124
2062
|
doc,
|
|
@@ -2201,7 +2139,7 @@ async function attachStyles({
|
|
|
2201
2139
|
}
|
|
2202
2140
|
}
|
|
2203
2141
|
|
|
2204
|
-
// src/html/
|
|
2142
|
+
// src/host/html/runtime/index.ts
|
|
2205
2143
|
init_error();
|
|
2206
2144
|
async function getRuntime(type, url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
2207
2145
|
if (typeof globalThis.process === "undefined") {
|
|
@@ -2235,7 +2173,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2235
2173
|
);
|
|
2236
2174
|
}
|
|
2237
2175
|
|
|
2238
|
-
// src/html/
|
|
2176
|
+
// src/host/html/index.tsx
|
|
2239
2177
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2240
2178
|
if (typeof HTMLElement !== "undefined") {
|
|
2241
2179
|
class RemoteComponent extends HTMLElement {
|
|
@@ -2250,7 +2188,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2250
2188
|
onRequest;
|
|
2251
2189
|
onResponse;
|
|
2252
2190
|
resolveClientUrl;
|
|
2253
|
-
// --
|
|
2191
|
+
// -- ConsumeServerConfig property accessors (attribute-reflected) --
|
|
2254
2192
|
get src() {
|
|
2255
2193
|
return this.getAttribute("src") ?? void 0;
|
|
2256
2194
|
}
|
|
@@ -2828,7 +2766,6 @@ function registerSharedModules(modules = {}) {
|
|
|
2828
2766
|
}
|
|
2829
2767
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2830
2768
|
0 && (module.exports = {
|
|
2831
|
-
proxyClientRequestsThroughHost,
|
|
2832
2769
|
registerSharedModules
|
|
2833
2770
|
});
|
|
2834
|
-
//# sourceMappingURL=
|
|
2771
|
+
//# sourceMappingURL=html.cjs.map
|