remote-components 0.1.2 → 0.2.1
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} +77 -102
- 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} +73 -98
- 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} +1019 -1080
- 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} +1016 -1076
- package/dist/host/html.js.map +1 -0
- package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +685 -623
- 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} +687 -618
- 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} +524 -555
- 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} +523 -552
- package/dist/host/react.js.map +1 -0
- package/dist/internal/{webpack/shared-modules.cjs → config/webpack/apply-shared-modules.cjs} +18 -17
- 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} +15 -14
- 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 +64 -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 +43 -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 +239 -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 +222 -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 +153 -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 +134 -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 +11 -4
- package/dist/internal/utils/error.cjs.map +1 -0
- package/dist/internal/{shared → utils}/error.d.ts +2 -1
- package/dist/internal/{shared → utils}/error.js +10 -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.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/react/index.tsx
|
|
1
|
+
// src/host/react/index.tsx
|
|
2
2
|
import {
|
|
3
3
|
startTransition,
|
|
4
4
|
useEffect,
|
|
@@ -10,76 +10,11 @@ import {
|
|
|
10
10
|
} from "react";
|
|
11
11
|
import { createPortal } from "react-dom";
|
|
12
12
|
|
|
13
|
-
// src/
|
|
14
|
-
var tagNames = [
|
|
15
|
-
"img",
|
|
16
|
-
"source",
|
|
17
|
-
"video",
|
|
18
|
-
"audio",
|
|
19
|
-
"track",
|
|
20
|
-
"iframe",
|
|
21
|
-
"embed",
|
|
22
|
-
"script",
|
|
23
|
-
"link"
|
|
24
|
-
];
|
|
25
|
-
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
26
|
-
if (url.origin !== location.origin) {
|
|
27
|
-
const nodes = doc.querySelectorAll(
|
|
28
|
-
tagNames.map(
|
|
29
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
30
|
-
).join(",")
|
|
31
|
-
);
|
|
32
|
-
nodes.forEach((node) => {
|
|
33
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
34
|
-
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
35
|
-
const isScript = node.tagName.toLowerCase() === "script";
|
|
36
|
-
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
37
|
-
}
|
|
38
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
39
|
-
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
40
|
-
node.setAttribute(
|
|
41
|
-
"href",
|
|
42
|
-
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (node.hasAttribute("srcset")) {
|
|
46
|
-
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
47
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
48
|
-
if (!urlPart)
|
|
49
|
-
return entry;
|
|
50
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
51
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
52
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
53
|
-
}).join(", ");
|
|
54
|
-
if (srcSet) {
|
|
55
|
-
node.setAttribute("srcset", srcSet);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (node.hasAttribute("imagesrcset")) {
|
|
59
|
-
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
60
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
61
|
-
if (!urlPart)
|
|
62
|
-
return entry;
|
|
63
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
64
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
65
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
66
|
-
}).join(", ");
|
|
67
|
-
if (srcSet) {
|
|
68
|
-
node.setAttribute("imagesrcset", srcSet);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/shared/constants.ts
|
|
13
|
+
// src/utils/constants.ts
|
|
76
14
|
var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
77
15
|
var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
78
16
|
|
|
79
|
-
// src/
|
|
80
|
-
function generateProtectedRcFallbackSrc(url) {
|
|
81
|
-
return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
|
|
82
|
-
}
|
|
17
|
+
// src/runtime/url/protected-rc-fallback.ts
|
|
83
18
|
function isProxiedUrl(url) {
|
|
84
19
|
try {
|
|
85
20
|
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
@@ -88,7 +23,7 @@ function isProxiedUrl(url) {
|
|
|
88
23
|
}
|
|
89
24
|
}
|
|
90
25
|
|
|
91
|
-
// src/
|
|
26
|
+
// src/utils/abort.ts
|
|
92
27
|
function isAbortError(error) {
|
|
93
28
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
94
29
|
return true;
|
|
@@ -100,7 +35,7 @@ function isAbortError(error) {
|
|
|
100
35
|
return false;
|
|
101
36
|
}
|
|
102
37
|
|
|
103
|
-
// src/
|
|
38
|
+
// src/utils/error.ts
|
|
104
39
|
var RemoteComponentsError = class extends Error {
|
|
105
40
|
code = "REMOTE_COMPONENTS_ERROR";
|
|
106
41
|
constructor(message, options) {
|
|
@@ -158,6 +93,11 @@ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
|
158
93
|
}
|
|
159
94
|
return fallback;
|
|
160
95
|
}
|
|
96
|
+
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
97
|
+
return new RemoteComponentsError(
|
|
98
|
+
`Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
161
101
|
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
162
102
|
if (status === 404) {
|
|
163
103
|
return new RemoteComponentsError(
|
|
@@ -166,7 +106,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
|
166
106
|
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
167
107
|
|
|
168
108
|
Proxying requires two pieces:
|
|
169
|
-
1. resolveClientUrl={
|
|
109
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
170
110
|
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
171
111
|
|
|
172
112
|
Docs: ${CORS_DOCS_URL}`
|
|
@@ -183,123 +123,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
183
123
|
);
|
|
184
124
|
}
|
|
185
125
|
|
|
186
|
-
// src/
|
|
187
|
-
function escapeString(str) {
|
|
188
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
189
|
-
}
|
|
190
|
-
var attrToProp = {
|
|
191
|
-
fetchpriority: "fetchPriority",
|
|
192
|
-
crossorigin: "crossOrigin",
|
|
193
|
-
imagesrcset: "imageSrcSet",
|
|
194
|
-
imagesizes: "imageSizes",
|
|
195
|
-
srcset: "srcSet"
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// src/shared/client/const.ts
|
|
199
|
-
var DEFAULT_ROUTE = "/";
|
|
200
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
201
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
202
|
-
var RUNTIME_SCRIPT = "script";
|
|
203
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
204
|
-
function getBundleKey(bundle) {
|
|
205
|
-
return escapeString(bundle);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// src/shared/client/parse-remote-html.ts
|
|
209
|
-
function validateSingleComponent(doc, name, url) {
|
|
210
|
-
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}"]`)) {
|
|
211
|
-
throw multipleRemoteComponentsError(url);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function findComponentElement(doc, name) {
|
|
215
|
-
return doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) ?? doc.querySelector("div[data-bundle][data-route]") ?? doc.querySelector("div#__next") ?? doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
|
|
216
|
-
}
|
|
217
|
-
function parseNextData(doc) {
|
|
218
|
-
return JSON.parse(
|
|
219
|
-
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
function resolveComponentName(component, nextData, fallbackName) {
|
|
223
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
224
|
-
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
225
|
-
return { name, isRemoteComponent };
|
|
226
|
-
}
|
|
227
|
-
function extractComponentMetadata(component, nextData, name, url) {
|
|
228
|
-
return {
|
|
229
|
-
name,
|
|
230
|
-
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
231
|
-
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
232
|
-
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function extractRemoteShared(doc, name, nextData) {
|
|
236
|
-
const remoteSharedEl = doc.querySelector(
|
|
237
|
-
`#${name}_shared[data-remote-components-shared]`
|
|
238
|
-
);
|
|
239
|
-
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
240
|
-
remoteSharedEl?.remove();
|
|
241
|
-
return remoteShared;
|
|
242
|
-
}
|
|
243
|
-
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
244
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
245
|
-
throw new RemoteComponentsError(
|
|
246
|
-
`Remote Component not found on ${url}.${name !== "__vercel_remote_component" ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
function extractLinks(doc, component) {
|
|
251
|
-
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
252
|
-
(link) => !component.contains(link)
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
function extractScripts(doc, component, isRemoteComponent) {
|
|
256
|
-
return Array.from(
|
|
257
|
-
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
258
|
-
"script[src],script[data-src]"
|
|
259
|
-
)
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
function parseRemoteComponentDocument(doc, name, url) {
|
|
263
|
-
validateSingleComponent(doc, name, url.href);
|
|
264
|
-
const component = findComponentElement(doc, name);
|
|
265
|
-
const nextData = parseNextData(doc);
|
|
266
|
-
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
267
|
-
component,
|
|
268
|
-
nextData,
|
|
269
|
-
name
|
|
270
|
-
);
|
|
271
|
-
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
272
|
-
const metadata = extractComponentMetadata(
|
|
273
|
-
component,
|
|
274
|
-
nextData,
|
|
275
|
-
resolvedName,
|
|
276
|
-
url
|
|
277
|
-
);
|
|
278
|
-
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
279
|
-
validateComponentFound(
|
|
280
|
-
component,
|
|
281
|
-
rsc,
|
|
282
|
-
nextData,
|
|
283
|
-
isRemoteComponent,
|
|
284
|
-
url.href,
|
|
285
|
-
resolvedName
|
|
286
|
-
);
|
|
287
|
-
const links = extractLinks(doc, component);
|
|
288
|
-
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
289
|
-
return {
|
|
290
|
-
component,
|
|
291
|
-
name: resolvedName,
|
|
292
|
-
isRemoteComponent,
|
|
293
|
-
metadata,
|
|
294
|
-
nextData,
|
|
295
|
-
rsc,
|
|
296
|
-
remoteShared,
|
|
297
|
-
links,
|
|
298
|
-
scripts
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// src/shared/utils/logger.ts
|
|
126
|
+
// src/utils/logger.ts
|
|
303
127
|
var PREFIX = "remote-components";
|
|
304
128
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
305
129
|
function logDebug(location2, message) {
|
|
@@ -325,13 +149,68 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
325
149
|
}
|
|
326
150
|
logWarn(
|
|
327
151
|
logLocation,
|
|
328
|
-
`Failed to fetch cross-origin resource "${parsed.href}".
|
|
152
|
+
`Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
|
|
329
153
|
);
|
|
330
154
|
} catch {
|
|
331
155
|
}
|
|
332
156
|
}
|
|
333
157
|
|
|
334
|
-
// src/
|
|
158
|
+
// src/host/server/fetch-headers.ts
|
|
159
|
+
function remoteFetchHeaders() {
|
|
160
|
+
return {
|
|
161
|
+
/**
|
|
162
|
+
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
163
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
164
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
165
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
166
|
+
*/
|
|
167
|
+
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
168
|
+
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
169
|
+
} : {},
|
|
170
|
+
Accept: "text/html"
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/host/server/fetch-with-hooks.ts
|
|
175
|
+
async function fetchWithWarning(url, init) {
|
|
176
|
+
try {
|
|
177
|
+
return await fetch(url, init);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
184
|
+
const {
|
|
185
|
+
onRequest,
|
|
186
|
+
onResponse,
|
|
187
|
+
abortController = new AbortController()
|
|
188
|
+
} = options;
|
|
189
|
+
const signal = abortController.signal;
|
|
190
|
+
const hookOptions = {
|
|
191
|
+
signal,
|
|
192
|
+
abort: (reason) => abortController.abort(reason)
|
|
193
|
+
};
|
|
194
|
+
const init = {
|
|
195
|
+
method: "GET",
|
|
196
|
+
headers: remoteFetchHeaders(),
|
|
197
|
+
signal,
|
|
198
|
+
...additionalInit
|
|
199
|
+
};
|
|
200
|
+
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
201
|
+
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/host/server/get-client-or-server-url.ts
|
|
205
|
+
function getClientOrServerUrl(src, serverFallback) {
|
|
206
|
+
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
207
|
+
if (!src) {
|
|
208
|
+
return new URL(fallback);
|
|
209
|
+
}
|
|
210
|
+
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/host/shared/polyfill.tsx
|
|
335
214
|
import { jsx } from "react/jsx-runtime";
|
|
336
215
|
function applyBundleUrlToSrc(bundle, src) {
|
|
337
216
|
const self = globalThis;
|
|
@@ -351,7 +230,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
351
230
|
const propSrc = src;
|
|
352
231
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
353
232
|
}
|
|
354
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
233
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
355
234
|
fill: _fill,
|
|
356
235
|
loader: _loader,
|
|
357
236
|
quality: _quality,
|
|
@@ -368,6 +247,7 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
368
247
|
bundle,
|
|
369
248
|
typeof src === "string" ? src : src.src
|
|
370
249
|
);
|
|
250
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
371
251
|
return (
|
|
372
252
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
373
253
|
/* @__PURE__ */ jsx(
|
|
@@ -376,13 +256,13 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
376
256
|
decoding: "async",
|
|
377
257
|
style: { color: "transparent" },
|
|
378
258
|
...props,
|
|
379
|
-
src:
|
|
259
|
+
src: proxiedSrc,
|
|
380
260
|
suppressHydrationWarning: true
|
|
381
261
|
}
|
|
382
262
|
)
|
|
383
263
|
);
|
|
384
264
|
};
|
|
385
|
-
function sharedPolyfills(shared) {
|
|
265
|
+
function sharedPolyfills(shared, resolveClientUrl) {
|
|
386
266
|
const self = globalThis;
|
|
387
267
|
const polyfill = {
|
|
388
268
|
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
@@ -473,11 +353,11 @@ function sharedPolyfills(shared) {
|
|
|
473
353
|
__esModule: true
|
|
474
354
|
})),
|
|
475
355
|
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
476
|
-
Image: imageImpl(bundle),
|
|
356
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
477
357
|
__esModule: true
|
|
478
358
|
})),
|
|
479
359
|
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
480
|
-
default: imageImpl(bundle),
|
|
360
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
481
361
|
getImageProps: (_imgProps) => {
|
|
482
362
|
throw new Error(
|
|
483
363
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -527,29 +407,338 @@ function sharedPolyfills(shared) {
|
|
|
527
407
|
return polyfill;
|
|
528
408
|
}
|
|
529
409
|
|
|
530
|
-
// src/shared/
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
410
|
+
// src/host/shared/state.ts
|
|
411
|
+
function createHostState() {
|
|
412
|
+
return {
|
|
413
|
+
stage: "idle",
|
|
414
|
+
prevSrc: void 0,
|
|
415
|
+
prevUrl: void 0,
|
|
416
|
+
prevName: void 0,
|
|
417
|
+
prevIsRemoteComponent: false,
|
|
418
|
+
abortController: void 0
|
|
419
|
+
};
|
|
420
|
+
}
|
|
536
421
|
|
|
537
|
-
// src/
|
|
538
|
-
function
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
542
|
-
);
|
|
543
|
-
if (nextCssOriginal) {
|
|
544
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
422
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
423
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
424
|
+
if (!src) {
|
|
425
|
+
return defaultName;
|
|
545
426
|
}
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
427
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
428
|
+
const hashIndex = hash.indexOf("#");
|
|
429
|
+
if (hashIndex < 0) {
|
|
430
|
+
return defaultName;
|
|
431
|
+
}
|
|
432
|
+
const name = hash.slice(hashIndex + 1);
|
|
433
|
+
return name || defaultName;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// src/utils/index.ts
|
|
437
|
+
function escapeString(str) {
|
|
438
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
439
|
+
}
|
|
440
|
+
var attrToProp = {
|
|
441
|
+
fetchpriority: "fetchPriority",
|
|
442
|
+
crossorigin: "crossOrigin",
|
|
443
|
+
imagesrcset: "imageSrcSet",
|
|
444
|
+
imagesizes: "imageSizes",
|
|
445
|
+
srcset: "srcSet"
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/runtime/constants.ts
|
|
449
|
+
var DEFAULT_ROUTE = "/";
|
|
450
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
451
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
452
|
+
var RUNTIME_SCRIPT = "script";
|
|
453
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
454
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
455
|
+
function getBundleKey(bundle) {
|
|
456
|
+
return escapeString(bundle);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/runtime/html/apply-origin.ts
|
|
460
|
+
var tagNames = [
|
|
461
|
+
"img",
|
|
462
|
+
"source",
|
|
463
|
+
"video",
|
|
464
|
+
"audio",
|
|
465
|
+
"track",
|
|
466
|
+
"iframe",
|
|
467
|
+
"embed",
|
|
468
|
+
"script",
|
|
469
|
+
"link"
|
|
470
|
+
];
|
|
471
|
+
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
472
|
+
if (url.origin !== location.origin) {
|
|
473
|
+
const nodes = doc.querySelectorAll(
|
|
474
|
+
tagNames.map(
|
|
475
|
+
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
476
|
+
).join(",")
|
|
477
|
+
);
|
|
478
|
+
nodes.forEach((node) => {
|
|
479
|
+
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
480
|
+
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
481
|
+
const isScript = node.tagName.toLowerCase() === "script";
|
|
482
|
+
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
483
|
+
}
|
|
484
|
+
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
485
|
+
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
486
|
+
node.setAttribute(
|
|
487
|
+
"href",
|
|
488
|
+
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
if (node.hasAttribute("srcset")) {
|
|
492
|
+
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
493
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
494
|
+
if (!urlPart)
|
|
495
|
+
return entry;
|
|
496
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
497
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
498
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
499
|
+
}).join(", ");
|
|
500
|
+
if (srcSet) {
|
|
501
|
+
node.setAttribute("srcset", srcSet);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (node.hasAttribute("imagesrcset")) {
|
|
505
|
+
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
506
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
507
|
+
if (!urlPart)
|
|
508
|
+
return entry;
|
|
509
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
510
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
511
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
512
|
+
}).join(", ");
|
|
513
|
+
if (srcSet) {
|
|
514
|
+
node.setAttribute("imagesrcset", srcSet);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// src/runtime/html/parse-remote-html.ts
|
|
522
|
+
function validateSingleComponent(doc, name, url) {
|
|
523
|
+
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}"]`)) {
|
|
524
|
+
throw multipleRemoteComponentsError(url);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
function findComponentElement(doc, name) {
|
|
528
|
+
return doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) ?? doc.querySelector("div[data-bundle][data-route]") ?? doc.querySelector("div#__next") ?? doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
|
|
529
|
+
}
|
|
530
|
+
function parseNextData(doc) {
|
|
531
|
+
return JSON.parse(
|
|
532
|
+
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
function resolveComponentName(component, nextData, fallbackName) {
|
|
536
|
+
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
537
|
+
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
538
|
+
return { name, isRemoteComponent };
|
|
539
|
+
}
|
|
540
|
+
function extractComponentMetadata(component, nextData, name, url) {
|
|
541
|
+
return {
|
|
542
|
+
name,
|
|
543
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
544
|
+
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
545
|
+
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function extractRemoteShared(doc, name, nextData) {
|
|
549
|
+
const remoteSharedEl = doc.querySelector(
|
|
550
|
+
`#${name}_shared[data-remote-components-shared]`
|
|
551
|
+
);
|
|
552
|
+
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
553
|
+
remoteSharedEl?.remove();
|
|
554
|
+
return remoteShared;
|
|
555
|
+
}
|
|
556
|
+
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
557
|
+
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
558
|
+
throw new RemoteComponentsError(
|
|
559
|
+
`Remote Component not found on ${url}.${name !== "__vercel_remote_component" ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function extractLinks(doc, component) {
|
|
564
|
+
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
565
|
+
(link) => !component.contains(link)
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
function extractScripts(doc, component, isRemoteComponent) {
|
|
569
|
+
return Array.from(
|
|
570
|
+
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
571
|
+
"script[src],script[data-src]"
|
|
572
|
+
)
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
function parseRemoteComponentDocument(doc, name, url) {
|
|
576
|
+
validateSingleComponent(doc, name, url.href);
|
|
577
|
+
const component = findComponentElement(doc, name);
|
|
578
|
+
const nextData = parseNextData(doc);
|
|
579
|
+
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
580
|
+
component,
|
|
581
|
+
nextData,
|
|
582
|
+
name
|
|
583
|
+
);
|
|
584
|
+
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
585
|
+
const metadata = extractComponentMetadata(
|
|
586
|
+
component,
|
|
587
|
+
nextData,
|
|
588
|
+
resolvedName,
|
|
589
|
+
url
|
|
590
|
+
);
|
|
591
|
+
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
592
|
+
validateComponentFound(
|
|
593
|
+
component,
|
|
594
|
+
rsc,
|
|
595
|
+
nextData,
|
|
596
|
+
isRemoteComponent,
|
|
597
|
+
url.href,
|
|
598
|
+
resolvedName
|
|
599
|
+
);
|
|
600
|
+
const links = extractLinks(doc, component);
|
|
601
|
+
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
602
|
+
return {
|
|
603
|
+
component,
|
|
604
|
+
name: resolvedName,
|
|
605
|
+
isRemoteComponent,
|
|
606
|
+
metadata,
|
|
607
|
+
nextData,
|
|
608
|
+
rsc,
|
|
609
|
+
remoteShared,
|
|
610
|
+
links,
|
|
611
|
+
scripts
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// src/runtime/html/set-attributes-from-props.ts
|
|
616
|
+
var DOMAttributeNames = {
|
|
617
|
+
acceptCharset: "accept-charset",
|
|
618
|
+
className: "class",
|
|
619
|
+
htmlFor: "for",
|
|
620
|
+
httpEquiv: "http-equiv",
|
|
621
|
+
noModule: "noModule"
|
|
622
|
+
};
|
|
623
|
+
var ignoreProps = [
|
|
624
|
+
"onLoad",
|
|
625
|
+
"onReady",
|
|
626
|
+
"dangerouslySetInnerHTML",
|
|
627
|
+
"children",
|
|
628
|
+
"onError",
|
|
629
|
+
"strategy",
|
|
630
|
+
"stylesheets"
|
|
631
|
+
];
|
|
632
|
+
function isBooleanScriptAttribute(attr) {
|
|
633
|
+
return ["async", "defer", "noModule"].includes(attr);
|
|
634
|
+
}
|
|
635
|
+
function setAttributesFromProps(el, props) {
|
|
636
|
+
for (const [p, value] of Object.entries(props)) {
|
|
637
|
+
if (!Object.hasOwn(props, p))
|
|
638
|
+
continue;
|
|
639
|
+
if (ignoreProps.includes(p))
|
|
640
|
+
continue;
|
|
641
|
+
if (value === void 0) {
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
645
|
+
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
646
|
+
el[attr] = Boolean(value);
|
|
647
|
+
} else {
|
|
648
|
+
el.setAttribute(attr, String(value));
|
|
649
|
+
}
|
|
650
|
+
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
651
|
+
el.setAttribute(attr, "");
|
|
652
|
+
el.removeAttribute(attr);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/runtime/loaders/component-loader.ts
|
|
658
|
+
import * as React from "react";
|
|
659
|
+
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
660
|
+
import * as JSXRuntime from "react/jsx-runtime";
|
|
661
|
+
import * as ReactDOM from "react-dom";
|
|
662
|
+
import * as ReactDOMClient from "react-dom/client";
|
|
663
|
+
|
|
664
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
665
|
+
var DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
666
|
+
function applySharedModules(bundle, resolve) {
|
|
667
|
+
logDebug(
|
|
668
|
+
"SharedModules",
|
|
669
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
670
|
+
);
|
|
671
|
+
logDebug(
|
|
672
|
+
"SharedModules",
|
|
673
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
674
|
+
);
|
|
675
|
+
const self = globalThis;
|
|
676
|
+
if (self.__remote_webpack_require__?.[bundle]) {
|
|
677
|
+
const modulePaths = Object.keys(
|
|
678
|
+
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
679
|
+
);
|
|
680
|
+
logDebug(
|
|
681
|
+
"SharedModules",
|
|
682
|
+
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
683
|
+
);
|
|
684
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
685
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
686
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
687
|
+
if (ids.length === 0) {
|
|
688
|
+
logDebug(
|
|
689
|
+
"SharedModules",
|
|
690
|
+
`No matching module path found for shared module "${key}"`
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
for (const id of ids) {
|
|
694
|
+
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
695
|
+
if (webpackBundle.m) {
|
|
696
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
697
|
+
if (resolvedId !== id) {
|
|
698
|
+
logDebug(
|
|
699
|
+
"SharedModules",
|
|
700
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
webpackBundle.m[resolvedId] = (module) => {
|
|
704
|
+
module.exports = value;
|
|
705
|
+
};
|
|
706
|
+
} else {
|
|
707
|
+
logWarn(
|
|
708
|
+
"SharedModules",
|
|
709
|
+
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
} else {
|
|
715
|
+
logWarn(
|
|
716
|
+
"SharedModules",
|
|
717
|
+
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
718
|
+
);
|
|
719
|
+
logDebug(
|
|
720
|
+
"SharedModules",
|
|
721
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
727
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
728
|
+
const self = globalThis;
|
|
729
|
+
const nextCssOriginal = document.querySelector(
|
|
730
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
731
|
+
);
|
|
732
|
+
if (nextCssOriginal) {
|
|
733
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
734
|
+
}
|
|
735
|
+
const nextCss = document.createElement("noscript");
|
|
736
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
737
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
738
|
+
nextCss.setAttribute("data-route", route);
|
|
739
|
+
const nextCssEnd = document.createElement("noscript");
|
|
740
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
741
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
553
742
|
nextCssEnd.setAttribute("data-route", route);
|
|
554
743
|
document.head.appendChild(nextCssEnd);
|
|
555
744
|
document.head.appendChild(nextCss);
|
|
@@ -614,100 +803,39 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
614
803
|
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
615
804
|
}
|
|
616
805
|
});
|
|
617
|
-
const elements = [];
|
|
618
|
-
let node = nextCss.previousSibling;
|
|
619
|
-
while (node && node !== nextCssEnd) {
|
|
620
|
-
elements.push(node);
|
|
621
|
-
node.remove();
|
|
622
|
-
node = nextCss.previousSibling;
|
|
623
|
-
}
|
|
624
|
-
self.__remote_next_css__[bundle] = elements;
|
|
625
|
-
}
|
|
626
|
-
if (styleContainer) {
|
|
627
|
-
const elements = self.__remote_next_css__[bundle];
|
|
628
|
-
elements.forEach((el) => {
|
|
629
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
630
|
-
});
|
|
631
|
-
} else {
|
|
632
|
-
const elements = self.__remote_next_css__[bundle];
|
|
633
|
-
elements.forEach((el) => {
|
|
634
|
-
document.head.appendChild(el);
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
delete self.__NEXT_P;
|
|
638
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
639
|
-
if (nextCssOriginal) {
|
|
640
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
641
|
-
}
|
|
642
|
-
nextCss.remove();
|
|
643
|
-
nextCssEnd.remove();
|
|
644
|
-
return { Component, App };
|
|
645
|
-
}
|
|
646
|
-
return { Component: null, App: null };
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
// src/shared/webpack/shared-modules.ts
|
|
650
|
-
function applySharedModules(bundle, resolve) {
|
|
651
|
-
logDebug(
|
|
652
|
-
"SharedModules",
|
|
653
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
654
|
-
);
|
|
655
|
-
logDebug(
|
|
656
|
-
"SharedModules",
|
|
657
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
658
|
-
);
|
|
659
|
-
const self = globalThis;
|
|
660
|
-
if (self.__remote_webpack_require__?.[bundle]) {
|
|
661
|
-
const modulePaths = Object.keys(
|
|
662
|
-
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
663
|
-
);
|
|
664
|
-
logDebug(
|
|
665
|
-
"SharedModules",
|
|
666
|
-
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
667
|
-
);
|
|
668
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
669
|
-
let ids = modulePaths.filter((p) => p === key);
|
|
670
|
-
if (ids.length === 0) {
|
|
671
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
672
|
-
}
|
|
673
|
-
if (ids.length === 0) {
|
|
674
|
-
logDebug(
|
|
675
|
-
"SharedModules",
|
|
676
|
-
`No matching module path found for shared module "${key}"`
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
for (let id of ids) {
|
|
680
|
-
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
681
|
-
if (webpackBundle.m) {
|
|
682
|
-
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
683
|
-
const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
684
|
-
logDebug(
|
|
685
|
-
"SharedModules",
|
|
686
|
-
`Mapped module id: "${id}" -> "${mappedId}"`
|
|
687
|
-
);
|
|
688
|
-
id = mappedId;
|
|
689
|
-
}
|
|
690
|
-
webpackBundle.m[id] = (module) => {
|
|
691
|
-
module.exports = value;
|
|
692
|
-
};
|
|
693
|
-
} else {
|
|
694
|
-
logWarn(
|
|
695
|
-
"SharedModules",
|
|
696
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
697
|
-
);
|
|
698
|
-
}
|
|
806
|
+
const elements = [];
|
|
807
|
+
let node = nextCss.previousSibling;
|
|
808
|
+
while (node && node !== nextCssEnd) {
|
|
809
|
+
elements.push(node);
|
|
810
|
+
node.remove();
|
|
811
|
+
node = nextCss.previousSibling;
|
|
699
812
|
}
|
|
813
|
+
self.__remote_next_css__[bundle] = elements;
|
|
700
814
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
815
|
+
if (styleContainer) {
|
|
816
|
+
const elements = self.__remote_next_css__[bundle];
|
|
817
|
+
elements.forEach((el) => {
|
|
818
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
819
|
+
});
|
|
820
|
+
} else {
|
|
821
|
+
const elements = self.__remote_next_css__[bundle];
|
|
822
|
+
elements.forEach((el) => {
|
|
823
|
+
document.head.appendChild(el);
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
delete self.__NEXT_P;
|
|
827
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
828
|
+
if (nextCssOriginal) {
|
|
829
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
830
|
+
}
|
|
831
|
+
nextCss.remove();
|
|
832
|
+
nextCssEnd.remove();
|
|
833
|
+
return { Component, App };
|
|
707
834
|
}
|
|
835
|
+
return { Component: null, App: null };
|
|
708
836
|
}
|
|
709
837
|
|
|
710
|
-
// src/
|
|
838
|
+
// src/runtime/rsc.ts
|
|
711
839
|
import { ReadableStream } from "web-streams-polyfill";
|
|
712
840
|
function fixPayload(payload) {
|
|
713
841
|
if (Array.isArray(payload)) {
|
|
@@ -773,56 +901,15 @@ function createRSCStream(rscName, data) {
|
|
|
773
901
|
});
|
|
774
902
|
}
|
|
775
903
|
|
|
776
|
-
// src/
|
|
777
|
-
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
778
|
-
|
|
779
|
-
// src/shared/client/script-loader.ts
|
|
780
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
781
|
-
await Promise.all(
|
|
782
|
-
scripts.map((script) => {
|
|
783
|
-
return new Promise((resolve, reject) => {
|
|
784
|
-
const newSrc = new URL(
|
|
785
|
-
// remove the remote component bundle name identifier from the script src
|
|
786
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
787
|
-
location.origin
|
|
788
|
-
).href;
|
|
789
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
790
|
-
const newScript = document.createElement("script");
|
|
791
|
-
newScript.onload = () => resolve();
|
|
792
|
-
newScript.onerror = () => {
|
|
793
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
794
|
-
if (isProxied) {
|
|
795
|
-
reject(
|
|
796
|
-
new RemoteComponentsError(
|
|
797
|
-
`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}`
|
|
798
|
-
)
|
|
799
|
-
);
|
|
800
|
-
} else {
|
|
801
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
802
|
-
reject(
|
|
803
|
-
new RemoteComponentsError(
|
|
804
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
805
|
-
)
|
|
806
|
-
);
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
newScript.src = resolvedSrc;
|
|
810
|
-
newScript.async = true;
|
|
811
|
-
document.head.appendChild(newScript);
|
|
812
|
-
});
|
|
813
|
-
})
|
|
814
|
-
);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
// src/shared/client/turbopack-patterns.ts
|
|
904
|
+
// src/runtime/turbopack/patterns.ts
|
|
818
905
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
819
|
-
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|
|
|
906
|
+
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
820
907
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
821
908
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
822
909
|
var 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]+)\)\)\)\}/;
|
|
823
910
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
824
911
|
|
|
825
|
-
// src/
|
|
912
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
826
913
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
827
914
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
828
915
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -882,11 +969,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
882
969
|
}).then(resolve).catch((error) => {
|
|
883
970
|
const isProxied = isProxiedUrl(resolvedUrl);
|
|
884
971
|
if (isProxied) {
|
|
885
|
-
reject(
|
|
886
|
-
new RemoteComponentsError(
|
|
887
|
-
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
888
|
-
)
|
|
889
|
-
);
|
|
972
|
+
reject(failedProxiedAssetError("chunk", url, resolvedUrl));
|
|
890
973
|
} else {
|
|
891
974
|
warnCrossOriginFetchError("ChunkLoader", url);
|
|
892
975
|
reject(error);
|
|
@@ -1034,7 +1117,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1034
1117
|
}
|
|
1035
1118
|
}
|
|
1036
1119
|
|
|
1037
|
-
// src/
|
|
1120
|
+
// src/runtime/turbopack/module.ts
|
|
1038
1121
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
1039
1122
|
const self = globalThis;
|
|
1040
1123
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1263,7 +1346,8 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1263
1346
|
};
|
|
1264
1347
|
}
|
|
1265
1348
|
|
|
1266
|
-
// src/
|
|
1349
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1350
|
+
var DEDUPLICATION_WARNING = "This module will not be deduplicated \u2014 the remote may load its own copy, which can cause duplicate instance errors (e.g. invalid hook calls if React is loaded twice).";
|
|
1267
1351
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1268
1352
|
const self = globalThis;
|
|
1269
1353
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1314,7 +1398,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1314
1398
|
} else {
|
|
1315
1399
|
logError(
|
|
1316
1400
|
"SharedModules",
|
|
1317
|
-
`Host shared module "${module}" not found for ID ${id}`
|
|
1401
|
+
`Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1318
1402
|
);
|
|
1319
1403
|
}
|
|
1320
1404
|
}
|
|
@@ -1331,7 +1415,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1331
1415
|
} else {
|
|
1332
1416
|
logError(
|
|
1333
1417
|
"SharedModules",
|
|
1334
|
-
`Shared module "${module}" not found for "${bundle}"`
|
|
1418
|
+
`Shared module "${module}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
|
|
1335
1419
|
);
|
|
1336
1420
|
}
|
|
1337
1421
|
}
|
|
@@ -1383,7 +1467,7 @@ function getSharedModule(bundle, id) {
|
|
|
1383
1467
|
return null;
|
|
1384
1468
|
}
|
|
1385
1469
|
|
|
1386
|
-
// src/
|
|
1470
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1387
1471
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1388
1472
|
const self = globalThis;
|
|
1389
1473
|
if (!self.__remote_bundle_url__) {
|
|
@@ -1438,7 +1522,7 @@ function createModuleRequire(runtime) {
|
|
|
1438
1522
|
id
|
|
1439
1523
|
};
|
|
1440
1524
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1441
|
-
logDebug("
|
|
1525
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1442
1526
|
try {
|
|
1443
1527
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1444
1528
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1454,7 +1538,7 @@ function createModuleRequire(runtime) {
|
|
|
1454
1538
|
throw new Error(`Module "${id}" not found.`);
|
|
1455
1539
|
} catch (requireError) {
|
|
1456
1540
|
logWarn(
|
|
1457
|
-
"
|
|
1541
|
+
"WebpackRuntime",
|
|
1458
1542
|
`Module require failed: ${String(requireError)}`
|
|
1459
1543
|
);
|
|
1460
1544
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1466,7 +1550,7 @@ function createModuleRequire(runtime) {
|
|
|
1466
1550
|
);
|
|
1467
1551
|
}
|
|
1468
1552
|
try {
|
|
1469
|
-
logDebug("
|
|
1553
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1470
1554
|
return self.__original_webpack_require__(id);
|
|
1471
1555
|
} catch (originalError) {
|
|
1472
1556
|
throw new RemoteComponentsError(
|
|
@@ -1478,7 +1562,41 @@ function createModuleRequire(runtime) {
|
|
|
1478
1562
|
};
|
|
1479
1563
|
}
|
|
1480
1564
|
|
|
1481
|
-
// src/
|
|
1565
|
+
// src/runtime/loaders/script-loader.ts
|
|
1566
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
1567
|
+
await Promise.all(
|
|
1568
|
+
scripts.map((script) => {
|
|
1569
|
+
return new Promise((resolve, reject) => {
|
|
1570
|
+
const newSrc = new URL(
|
|
1571
|
+
// remove the remote component bundle name identifier from the script src
|
|
1572
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1573
|
+
location.origin
|
|
1574
|
+
).href;
|
|
1575
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1576
|
+
const newScript = document.createElement("script");
|
|
1577
|
+
newScript.onload = () => resolve();
|
|
1578
|
+
newScript.onerror = () => {
|
|
1579
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1580
|
+
if (isProxied) {
|
|
1581
|
+
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
1582
|
+
} else {
|
|
1583
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1584
|
+
reject(
|
|
1585
|
+
new RemoteComponentsError(
|
|
1586
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1587
|
+
)
|
|
1588
|
+
);
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
newScript.src = resolvedSrc;
|
|
1592
|
+
newScript.async = true;
|
|
1593
|
+
document.head.appendChild(newScript);
|
|
1594
|
+
});
|
|
1595
|
+
})
|
|
1596
|
+
);
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
// src/runtime/loaders/component-loader.ts
|
|
1482
1600
|
async function loadRemoteComponent({
|
|
1483
1601
|
url,
|
|
1484
1602
|
name,
|
|
@@ -1581,17 +1699,19 @@ async function loadRemoteComponent({
|
|
|
1581
1699
|
};
|
|
1582
1700
|
}
|
|
1583
1701
|
}
|
|
1584
|
-
async function
|
|
1585
|
-
let createFromReadableStream;
|
|
1702
|
+
async function importCreateFromReadableStream() {
|
|
1586
1703
|
try {
|
|
1587
|
-
const { createFromReadableStream
|
|
1588
|
-
createFromReadableStream
|
|
1704
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1705
|
+
return createFromReadableStream;
|
|
1589
1706
|
} catch {
|
|
1590
1707
|
const {
|
|
1591
|
-
default: { createFromReadableStream
|
|
1708
|
+
default: { createFromReadableStream }
|
|
1592
1709
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1593
|
-
createFromReadableStream
|
|
1710
|
+
return createFromReadableStream;
|
|
1594
1711
|
}
|
|
1712
|
+
}
|
|
1713
|
+
async function loadRSCComponent(rscName, data) {
|
|
1714
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1595
1715
|
if (typeof createFromReadableStream !== "function") {
|
|
1596
1716
|
throw new RemoteComponentsError(
|
|
1597
1717
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1612,85 +1732,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1612
1732
|
return { component };
|
|
1613
1733
|
}
|
|
1614
1734
|
|
|
1615
|
-
// src/
|
|
1616
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1617
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
1618
|
-
return (url) => {
|
|
1619
|
-
const urlOrigin = parseOrigin(url);
|
|
1620
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
1621
|
-
return void 0;
|
|
1622
|
-
}
|
|
1623
|
-
return resolveClientUrl(remoteSrc, url);
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
function parseOrigin(url) {
|
|
1627
|
-
try {
|
|
1628
|
-
return new URL(url).origin;
|
|
1629
|
-
} catch {
|
|
1630
|
-
return void 0;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
var proxyClientRequestsThroughHost = (remoteSrc, url) => {
|
|
1634
|
-
if (typeof location === "undefined") {
|
|
1635
|
-
return void 0;
|
|
1636
|
-
}
|
|
1637
|
-
const remoteOrigin = new URL(remoteSrc, location.href).origin;
|
|
1638
|
-
if (remoteOrigin === location.origin) {
|
|
1639
|
-
return void 0;
|
|
1640
|
-
}
|
|
1641
|
-
try {
|
|
1642
|
-
const parsed = new URL(url, location.href);
|
|
1643
|
-
if (parsed.origin === remoteOrigin) {
|
|
1644
|
-
return generateProtectedRcFallbackSrc(url);
|
|
1645
|
-
}
|
|
1646
|
-
} catch {
|
|
1647
|
-
}
|
|
1648
|
-
return void 0;
|
|
1649
|
-
};
|
|
1650
|
-
|
|
1651
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1652
|
-
var DOMAttributeNames = {
|
|
1653
|
-
acceptCharset: "accept-charset",
|
|
1654
|
-
className: "class",
|
|
1655
|
-
htmlFor: "for",
|
|
1656
|
-
httpEquiv: "http-equiv",
|
|
1657
|
-
noModule: "noModule"
|
|
1658
|
-
};
|
|
1659
|
-
var ignoreProps = [
|
|
1660
|
-
"onLoad",
|
|
1661
|
-
"onReady",
|
|
1662
|
-
"dangerouslySetInnerHTML",
|
|
1663
|
-
"children",
|
|
1664
|
-
"onError",
|
|
1665
|
-
"strategy",
|
|
1666
|
-
"stylesheets"
|
|
1667
|
-
];
|
|
1668
|
-
function isBooleanScriptAttribute(attr) {
|
|
1669
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1670
|
-
}
|
|
1671
|
-
function setAttributesFromProps(el, props) {
|
|
1672
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1673
|
-
if (!Object.hasOwn(props, p))
|
|
1674
|
-
continue;
|
|
1675
|
-
if (ignoreProps.includes(p))
|
|
1676
|
-
continue;
|
|
1677
|
-
if (value === void 0) {
|
|
1678
|
-
continue;
|
|
1679
|
-
}
|
|
1680
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1681
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1682
|
-
el[attr] = Boolean(value);
|
|
1683
|
-
} else {
|
|
1684
|
-
el.setAttribute(attr, String(value));
|
|
1685
|
-
}
|
|
1686
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1687
|
-
el.setAttribute(attr, "");
|
|
1688
|
-
el.removeAttribute(attr);
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
// src/shared/client/static-loader.ts
|
|
1735
|
+
// src/runtime/loaders/static-loader.ts
|
|
1694
1736
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1695
1737
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1696
1738
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1840,101 +1882,35 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1840
1882
|
);
|
|
1841
1883
|
}
|
|
1842
1884
|
|
|
1843
|
-
// src/
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
stage: "idle",
|
|
1847
|
-
prevSrc: void 0,
|
|
1848
|
-
prevUrl: void 0,
|
|
1849
|
-
prevName: void 0,
|
|
1850
|
-
prevIsRemoteComponent: false,
|
|
1851
|
-
abortController: void 0
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
// src/shared/contract/resolve-name-from-src.ts
|
|
1856
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
1857
|
-
if (!src) {
|
|
1858
|
-
return defaultName;
|
|
1859
|
-
}
|
|
1860
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
1861
|
-
const hashIndex = hash.indexOf("#");
|
|
1862
|
-
if (hashIndex < 0) {
|
|
1863
|
-
return defaultName;
|
|
1864
|
-
}
|
|
1865
|
-
const name = hash.slice(hashIndex + 1);
|
|
1866
|
-
return name || defaultName;
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
// src/shared/ssr/fetch-headers.ts
|
|
1870
|
-
function remoteFetchHeaders() {
|
|
1871
|
-
return {
|
|
1872
|
-
/**
|
|
1873
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1874
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1875
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1876
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1877
|
-
*/
|
|
1878
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1879
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1880
|
-
} : {},
|
|
1881
|
-
Accept: "text/html"
|
|
1882
|
-
};
|
|
1883
|
-
}
|
|
1885
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1886
|
+
import { useMemo } from "react";
|
|
1887
|
+
import { useRemoteComponentsContext } from "#internal/host/react/context";
|
|
1884
1888
|
|
|
1885
|
-
// src/
|
|
1886
|
-
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
const signal = abortController.signal;
|
|
1893
|
-
const hookOptions = {
|
|
1894
|
-
signal,
|
|
1895
|
-
abort: (reason) => abortController.abort(reason)
|
|
1896
|
-
};
|
|
1897
|
-
const init = {
|
|
1898
|
-
method: "GET",
|
|
1899
|
-
headers: remoteFetchHeaders(),
|
|
1900
|
-
signal,
|
|
1901
|
-
...additionalInit
|
|
1902
|
-
};
|
|
1903
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1904
|
-
if (!res) {
|
|
1905
|
-
try {
|
|
1906
|
-
res = await fetch(url, init);
|
|
1907
|
-
} catch (error) {
|
|
1908
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1909
|
-
throw error;
|
|
1889
|
+
// src/runtime/url/resolve-client-url.ts
|
|
1890
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1891
|
+
const remoteOrigin = parseOrigin(remoteSrc);
|
|
1892
|
+
return (url) => {
|
|
1893
|
+
const urlOrigin = parseOrigin(url);
|
|
1894
|
+
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
1895
|
+
return void 0;
|
|
1910
1896
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
if (transformedRes) {
|
|
1914
|
-
res = transformedRes;
|
|
1915
|
-
}
|
|
1916
|
-
return res;
|
|
1897
|
+
return resolveClientUrl(remoteSrc, url);
|
|
1898
|
+
};
|
|
1917
1899
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
return new URL(fallback);
|
|
1900
|
+
function parseOrigin(url) {
|
|
1901
|
+
try {
|
|
1902
|
+
return new URL(url).origin;
|
|
1903
|
+
} catch {
|
|
1904
|
+
return void 0;
|
|
1924
1905
|
}
|
|
1925
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1926
1906
|
}
|
|
1927
1907
|
|
|
1928
|
-
// src/
|
|
1929
|
-
import { useMemo } from "react";
|
|
1930
|
-
import { useRemoteComponentsContext } from "#internal/react/context";
|
|
1931
|
-
|
|
1932
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1908
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
1933
1909
|
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1934
1910
|
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1935
1911
|
}
|
|
1936
1912
|
|
|
1937
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
1913
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1938
1914
|
function useResolveClientUrl(prop, urlHref) {
|
|
1939
1915
|
const { resolveClientUrl: contextValue } = useRemoteComponentsContext();
|
|
1940
1916
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1944,7 +1920,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1944
1920
|
);
|
|
1945
1921
|
}
|
|
1946
1922
|
|
|
1947
|
-
// src/react/hooks/use-shadow-root.ts
|
|
1923
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1948
1924
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
1949
1925
|
function useShadowRoot({
|
|
1950
1926
|
isolate,
|
|
@@ -1993,7 +1969,7 @@ function useShadowRoot({
|
|
|
1993
1969
|
return { shadowRoot, shadowRootContainerRef };
|
|
1994
1970
|
}
|
|
1995
1971
|
|
|
1996
|
-
// src/react/utils/extract-remote-html.ts
|
|
1972
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
1997
1973
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
1998
1974
|
function getRemoteComponentHtml(html) {
|
|
1999
1975
|
if (typeof document === "undefined")
|
|
@@ -2015,11 +1991,10 @@ function getRemoteComponentHtml(html) {
|
|
|
2015
1991
|
return "";
|
|
2016
1992
|
}
|
|
2017
1993
|
|
|
2018
|
-
// src/react/index.tsx
|
|
2019
|
-
import { RemoteComponentsProvider } from "#internal/react/context";
|
|
1994
|
+
// src/host/react/index.tsx
|
|
2020
1995
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2021
1996
|
import { createElement as createElement2 } from "react";
|
|
2022
|
-
function
|
|
1997
|
+
function ConsumeRemoteComponent({
|
|
2023
1998
|
src,
|
|
2024
1999
|
isolate,
|
|
2025
2000
|
mode = "open",
|
|
@@ -2041,7 +2016,9 @@ function RemoteComponent({
|
|
|
2041
2016
|
() => resolveNameFromSrc(src, nameProp),
|
|
2042
2017
|
[src, nameProp]
|
|
2043
2018
|
);
|
|
2044
|
-
const [data, setData] = useState2(
|
|
2019
|
+
const [data, setData] = useState2(
|
|
2020
|
+
null
|
|
2021
|
+
);
|
|
2045
2022
|
const url = useMemo2(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
2046
2023
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
2047
2024
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -2258,11 +2235,10 @@ function RemoteComponent({
|
|
|
2258
2235
|
});
|
|
2259
2236
|
self.__next_s = prevNextScripts;
|
|
2260
2237
|
}
|
|
2261
|
-
|
|
2238
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2239
|
+
remoteName
|
|
2240
|
+
)}` : void 0;
|
|
2262
2241
|
if (rsc) {
|
|
2263
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2264
|
-
id
|
|
2265
|
-
)}_${escapeString(remoteName)}`;
|
|
2266
2242
|
rsc.textContent = rsc.textContent?.replace(
|
|
2267
2243
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2268
2244
|
`self["${rscName}"]`
|
|
@@ -2301,10 +2277,7 @@ function RemoteComponent({
|
|
|
2301
2277
|
}
|
|
2302
2278
|
setData(newData);
|
|
2303
2279
|
if (shadowRoot) {
|
|
2304
|
-
|
|
2305
|
-
if (reset) {
|
|
2306
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2307
|
-
}
|
|
2280
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2308
2281
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2309
2282
|
htmlRef.current = null;
|
|
2310
2283
|
setRemoteComponent(null);
|
|
@@ -2373,7 +2346,7 @@ function RemoteComponent({
|
|
|
2373
2346
|
};
|
|
2374
2347
|
}),
|
|
2375
2348
|
shared: {
|
|
2376
|
-
...sharedPolyfills(userShared),
|
|
2349
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2377
2350
|
...userShared
|
|
2378
2351
|
},
|
|
2379
2352
|
remoteShared,
|
|
@@ -2544,8 +2517,6 @@ function RemoteComponent({
|
|
|
2544
2517
|
] });
|
|
2545
2518
|
}
|
|
2546
2519
|
export {
|
|
2547
|
-
|
|
2548
|
-
RemoteComponentsProvider,
|
|
2549
|
-
proxyClientRequestsThroughHost
|
|
2520
|
+
ConsumeRemoteComponent
|
|
2550
2521
|
};
|
|
2551
|
-
//# sourceMappingURL=
|
|
2522
|
+
//# sourceMappingURL=react.js.map
|