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
|
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
9
12
|
var __export = (target, all) => {
|
|
10
13
|
for (var name in all)
|
|
11
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,86 +31,46 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
31
|
));
|
|
29
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
33
|
|
|
31
|
-
// src/
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// src/utils/constants.ts
|
|
35
|
+
var RC_PROTECTED_REMOTE_FETCH_PATHNAME, MISSING_SHARED_MODULES_MESSAGE, CORS_DOCS_URL;
|
|
36
|
+
var init_constants = __esm({
|
|
37
|
+
"src/utils/constants.ts"() {
|
|
38
|
+
"use strict";
|
|
39
|
+
RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
40
|
+
MISSING_SHARED_MODULES_MESSAGE = "Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponentsConfig` on both host and remote?";
|
|
41
|
+
CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
42
|
+
}
|
|
36
43
|
});
|
|
37
|
-
module.exports = __toCommonJS(client_exports);
|
|
38
|
-
var Image = __toESM(require("next/image"), 1);
|
|
39
|
-
|
|
40
|
-
// src/react/index.tsx
|
|
41
|
-
var import_react3 = require("react");
|
|
42
|
-
var import_react_dom = require("react-dom");
|
|
43
44
|
|
|
44
|
-
// src/
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (url.origin !== location.origin) {
|
|
58
|
-
const nodes = doc.querySelectorAll(
|
|
59
|
-
tagNames.map(
|
|
60
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
61
|
-
).join(",")
|
|
62
|
-
);
|
|
63
|
-
nodes.forEach((node) => {
|
|
64
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
65
|
-
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
66
|
-
const isScript = node.tagName.toLowerCase() === "script";
|
|
67
|
-
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
68
|
-
}
|
|
69
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
70
|
-
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
71
|
-
node.setAttribute(
|
|
72
|
-
"href",
|
|
73
|
-
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
if (node.hasAttribute("srcset")) {
|
|
77
|
-
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
78
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
79
|
-
if (!urlPart)
|
|
80
|
-
return entry;
|
|
81
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
82
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
83
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
84
|
-
}).join(", ");
|
|
85
|
-
if (srcSet) {
|
|
86
|
-
node.setAttribute("srcset", srcSet);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (node.hasAttribute("imagesrcset")) {
|
|
90
|
-
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
91
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
92
|
-
if (!urlPart)
|
|
93
|
-
return entry;
|
|
94
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
95
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
96
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
97
|
-
}).join(", ");
|
|
98
|
-
if (srcSet) {
|
|
99
|
-
node.setAttribute("imagesrcset", srcSet);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
45
|
+
// src/host/defaults/app.ts
|
|
46
|
+
var app_exports = {};
|
|
47
|
+
__export(app_exports, {
|
|
48
|
+
shared: () => shared
|
|
49
|
+
});
|
|
50
|
+
var shared;
|
|
51
|
+
var init_app = __esm({
|
|
52
|
+
"src/host/defaults/app.ts"() {
|
|
53
|
+
"use strict";
|
|
54
|
+
init_constants();
|
|
55
|
+
shared = {
|
|
56
|
+
__remote_components_missing_shared__: () => Promise.reject(new Error(MISSING_SHARED_MODULES_MESSAGE))
|
|
57
|
+
};
|
|
103
58
|
}
|
|
104
|
-
}
|
|
59
|
+
});
|
|
105
60
|
|
|
106
|
-
// src/
|
|
107
|
-
var
|
|
108
|
-
|
|
61
|
+
// src/host/nextjs/app-client-only.tsx
|
|
62
|
+
var app_client_only_exports = {};
|
|
63
|
+
__export(app_client_only_exports, {
|
|
64
|
+
ConsumeRemoteComponent: () => ConsumeRemoteComponent2
|
|
65
|
+
});
|
|
66
|
+
module.exports = __toCommonJS(app_client_only_exports);
|
|
67
|
+
var Image = __toESM(require("next/image"), 1);
|
|
109
68
|
|
|
110
|
-
// src/
|
|
69
|
+
// src/utils/logger.ts
|
|
70
|
+
init_constants();
|
|
71
|
+
|
|
72
|
+
// src/runtime/url/protected-rc-fallback.ts
|
|
73
|
+
init_constants();
|
|
111
74
|
function isProxiedUrl(url) {
|
|
112
75
|
try {
|
|
113
76
|
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
@@ -116,7 +79,7 @@ function isProxiedUrl(url) {
|
|
|
116
79
|
}
|
|
117
80
|
}
|
|
118
81
|
|
|
119
|
-
// src/
|
|
82
|
+
// src/utils/abort.ts
|
|
120
83
|
function isAbortError(error) {
|
|
121
84
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
122
85
|
return true;
|
|
@@ -128,7 +91,8 @@ function isAbortError(error) {
|
|
|
128
91
|
return false;
|
|
129
92
|
}
|
|
130
93
|
|
|
131
|
-
// src/
|
|
94
|
+
// src/utils/error.ts
|
|
95
|
+
init_constants();
|
|
132
96
|
var RemoteComponentsError = class extends Error {
|
|
133
97
|
code = "REMOTE_COMPONENTS_ERROR";
|
|
134
98
|
constructor(message, options) {
|
|
@@ -186,6 +150,11 @@ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
|
186
150
|
}
|
|
187
151
|
return fallback;
|
|
188
152
|
}
|
|
153
|
+
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
154
|
+
return new RemoteComponentsError(
|
|
155
|
+
`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}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
189
158
|
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
190
159
|
if (status === 404) {
|
|
191
160
|
return new RemoteComponentsError(
|
|
@@ -194,7 +163,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
|
194
163
|
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
195
164
|
|
|
196
165
|
Proxying requires two pieces:
|
|
197
|
-
1. resolveClientUrl={
|
|
166
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
198
167
|
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
199
168
|
|
|
200
169
|
Docs: ${CORS_DOCS_URL}`
|
|
@@ -211,123 +180,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
211
180
|
);
|
|
212
181
|
}
|
|
213
182
|
|
|
214
|
-
// src/
|
|
215
|
-
function escapeString(str) {
|
|
216
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
217
|
-
}
|
|
218
|
-
var attrToProp = {
|
|
219
|
-
fetchpriority: "fetchPriority",
|
|
220
|
-
crossorigin: "crossOrigin",
|
|
221
|
-
imagesrcset: "imageSrcSet",
|
|
222
|
-
imagesizes: "imageSizes",
|
|
223
|
-
srcset: "srcSet"
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// src/shared/client/const.ts
|
|
227
|
-
var DEFAULT_ROUTE = "/";
|
|
228
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
229
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
230
|
-
var RUNTIME_SCRIPT = "script";
|
|
231
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
232
|
-
function getBundleKey(bundle) {
|
|
233
|
-
return escapeString(bundle);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/shared/client/parse-remote-html.ts
|
|
237
|
-
function validateSingleComponent(doc, name, url) {
|
|
238
|
-
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}"]`)) {
|
|
239
|
-
throw multipleRemoteComponentsError(url);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
function findComponentElement(doc, name) {
|
|
243
|
-
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])");
|
|
244
|
-
}
|
|
245
|
-
function parseNextData(doc) {
|
|
246
|
-
return JSON.parse(
|
|
247
|
-
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
function resolveComponentName(component, nextData, fallbackName) {
|
|
251
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
252
|
-
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
253
|
-
return { name, isRemoteComponent };
|
|
254
|
-
}
|
|
255
|
-
function extractComponentMetadata(component, nextData, name, url) {
|
|
256
|
-
return {
|
|
257
|
-
name,
|
|
258
|
-
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
259
|
-
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
260
|
-
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function extractRemoteShared(doc, name, nextData) {
|
|
264
|
-
const remoteSharedEl = doc.querySelector(
|
|
265
|
-
`#${name}_shared[data-remote-components-shared]`
|
|
266
|
-
);
|
|
267
|
-
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
268
|
-
remoteSharedEl?.remove();
|
|
269
|
-
return remoteShared;
|
|
270
|
-
}
|
|
271
|
-
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
272
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
273
|
-
throw new RemoteComponentsError(
|
|
274
|
-
`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>?`
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function extractLinks(doc, component) {
|
|
279
|
-
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
280
|
-
(link) => !component.contains(link)
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
function extractScripts(doc, component, isRemoteComponent) {
|
|
284
|
-
return Array.from(
|
|
285
|
-
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
286
|
-
"script[src],script[data-src]"
|
|
287
|
-
)
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
function parseRemoteComponentDocument(doc, name, url) {
|
|
291
|
-
validateSingleComponent(doc, name, url.href);
|
|
292
|
-
const component = findComponentElement(doc, name);
|
|
293
|
-
const nextData = parseNextData(doc);
|
|
294
|
-
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
295
|
-
component,
|
|
296
|
-
nextData,
|
|
297
|
-
name
|
|
298
|
-
);
|
|
299
|
-
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
300
|
-
const metadata = extractComponentMetadata(
|
|
301
|
-
component,
|
|
302
|
-
nextData,
|
|
303
|
-
resolvedName,
|
|
304
|
-
url
|
|
305
|
-
);
|
|
306
|
-
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
307
|
-
validateComponentFound(
|
|
308
|
-
component,
|
|
309
|
-
rsc,
|
|
310
|
-
nextData,
|
|
311
|
-
isRemoteComponent,
|
|
312
|
-
url.href,
|
|
313
|
-
resolvedName
|
|
314
|
-
);
|
|
315
|
-
const links = extractLinks(doc, component);
|
|
316
|
-
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
317
|
-
return {
|
|
318
|
-
component,
|
|
319
|
-
name: resolvedName,
|
|
320
|
-
isRemoteComponent,
|
|
321
|
-
metadata,
|
|
322
|
-
nextData,
|
|
323
|
-
rsc,
|
|
324
|
-
remoteShared,
|
|
325
|
-
links,
|
|
326
|
-
scripts
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/shared/utils/logger.ts
|
|
183
|
+
// src/utils/logger.ts
|
|
331
184
|
var PREFIX = "remote-components";
|
|
332
185
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
333
186
|
function logDebug(location2, message) {
|
|
@@ -353,13 +206,13 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
353
206
|
}
|
|
354
207
|
logWarn(
|
|
355
208
|
logLocation,
|
|
356
|
-
`Failed to fetch cross-origin resource "${parsed.href}".
|
|
209
|
+
`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}`
|
|
357
210
|
);
|
|
358
211
|
} catch {
|
|
359
212
|
}
|
|
360
213
|
}
|
|
361
214
|
|
|
362
|
-
// src/shared/
|
|
215
|
+
// src/host/shared/polyfill.tsx
|
|
363
216
|
var import_jsx_runtime = (
|
|
364
217
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
365
218
|
require("react/jsx-runtime")
|
|
@@ -382,7 +235,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
382
235
|
const propSrc = src;
|
|
383
236
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
384
237
|
}
|
|
385
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
238
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
386
239
|
fill: _fill,
|
|
387
240
|
loader: _loader,
|
|
388
241
|
quality: _quality,
|
|
@@ -399,21 +252,22 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
399
252
|
bundle,
|
|
400
253
|
typeof src === "string" ? src : src.src
|
|
401
254
|
);
|
|
255
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
402
256
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
403
257
|
"img",
|
|
404
258
|
{
|
|
405
259
|
decoding: "async",
|
|
406
260
|
style: { color: "transparent" },
|
|
407
261
|
...props,
|
|
408
|
-
src:
|
|
262
|
+
src: proxiedSrc,
|
|
409
263
|
suppressHydrationWarning: true
|
|
410
264
|
}
|
|
411
265
|
);
|
|
412
266
|
};
|
|
413
|
-
function sharedPolyfills(
|
|
267
|
+
function sharedPolyfills(shared2, resolveClientUrl) {
|
|
414
268
|
const self = globalThis;
|
|
415
269
|
const polyfill = {
|
|
416
|
-
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ??
|
|
270
|
+
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared2?.["next/navigation"] ?? (() => Promise.resolve({
|
|
417
271
|
useRouter() {
|
|
418
272
|
return {
|
|
419
273
|
push: (routerUrl) => {
|
|
@@ -444,7 +298,7 @@ function sharedPolyfills(shared) {
|
|
|
444
298
|
},
|
|
445
299
|
__esModule: true
|
|
446
300
|
})),
|
|
447
|
-
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ??
|
|
301
|
+
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared2?.["next/link"] ?? (() => Promise.resolve({
|
|
448
302
|
default: ({
|
|
449
303
|
scroll: _,
|
|
450
304
|
replace,
|
|
@@ -494,18 +348,18 @@ function sharedPolyfills(shared) {
|
|
|
494
348
|
},
|
|
495
349
|
__esModule: true
|
|
496
350
|
})),
|
|
497
|
-
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ??
|
|
351
|
+
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared2?.["next/form"] ?? (() => Promise.resolve({
|
|
498
352
|
default: () => {
|
|
499
353
|
throw new Error("Next.js <Form> component not implemented");
|
|
500
354
|
},
|
|
501
355
|
__esModule: true
|
|
502
356
|
})),
|
|
503
|
-
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ??
|
|
504
|
-
Image: imageImpl(bundle),
|
|
357
|
+
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
358
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
505
359
|
__esModule: true
|
|
506
360
|
})),
|
|
507
|
-
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ??
|
|
508
|
-
default: imageImpl(bundle),
|
|
361
|
+
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
362
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
509
363
|
getImageProps: (_imgProps) => {
|
|
510
364
|
throw new Error(
|
|
511
365
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -513,13 +367,13 @@ function sharedPolyfills(shared) {
|
|
|
513
367
|
},
|
|
514
368
|
__esModule: true
|
|
515
369
|
})),
|
|
516
|
-
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ??
|
|
370
|
+
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared2?.["next/script"] ?? (() => Promise.resolve({
|
|
517
371
|
// TODO: implement <Script> component for non-Next.js host applications
|
|
518
372
|
// do not throw an error for now
|
|
519
373
|
default: () => null,
|
|
520
374
|
__esModule: true
|
|
521
375
|
})),
|
|
522
|
-
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ??
|
|
376
|
+
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared2?.["next/router"] ?? (() => (
|
|
523
377
|
// TODO: incomplete implementation
|
|
524
378
|
Promise.resolve({
|
|
525
379
|
useRouter() {
|
|
@@ -555,126 +409,378 @@ function sharedPolyfills(shared) {
|
|
|
555
409
|
return polyfill;
|
|
556
410
|
}
|
|
557
411
|
|
|
558
|
-
// src/
|
|
559
|
-
var
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
412
|
+
// src/host/nextjs/image-impl.tsx
|
|
413
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
414
|
+
function createRemoteLoader(bundle, resolveClientUrl) {
|
|
415
|
+
return ({ src, width, quality }) => {
|
|
416
|
+
const self = globalThis;
|
|
417
|
+
const origin = self.__remote_bundle_url__?.[bundle]?.origin ?? "";
|
|
418
|
+
let imageUrl = src;
|
|
419
|
+
try {
|
|
420
|
+
const parsed = new URL(src);
|
|
421
|
+
if (origin && parsed.origin === origin) {
|
|
422
|
+
imageUrl = parsed.pathname + parsed.search;
|
|
423
|
+
}
|
|
424
|
+
} catch {
|
|
425
|
+
}
|
|
426
|
+
const { assetPrefix } = /^(?<assetPrefix>.*?)\/_next\//.exec(imageUrl)?.groups ?? {};
|
|
427
|
+
const url = `${origin}${assetPrefix ?? ""}/_next/image?url=${encodeURIComponent(imageUrl)}&w=${width}&q=${quality ?? 75}`;
|
|
428
|
+
return resolveClientUrl?.(url) ?? url;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function imageImpl2(ImageComponent, bundle, resolveClientUrl, useRemoteLoader) {
|
|
432
|
+
const remoteLoader = useRemoteLoader ? createRemoteLoader(bundle, resolveClientUrl) : void 0;
|
|
433
|
+
const component = function RemoteImage(props) {
|
|
434
|
+
if (remoteLoader) {
|
|
435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImageComponent, { loader: remoteLoader, ...props });
|
|
436
|
+
}
|
|
437
|
+
const rawSrc = applyBundleUrlToImagePropsSrc(bundle, props.src);
|
|
438
|
+
const src = resolveClientUrl?.(rawSrc) ?? rawSrc;
|
|
439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImageComponent, { ...props, src });
|
|
440
|
+
};
|
|
441
|
+
component.default = component;
|
|
442
|
+
return component;
|
|
443
|
+
}
|
|
564
444
|
|
|
565
|
-
// src/
|
|
566
|
-
function
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
445
|
+
// src/runtime/url/resolve-client-url.ts
|
|
446
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
447
|
+
const remoteOrigin = parseOrigin(remoteSrc);
|
|
448
|
+
return (url) => {
|
|
449
|
+
const urlOrigin = parseOrigin(url);
|
|
450
|
+
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
451
|
+
return void 0;
|
|
452
|
+
}
|
|
453
|
+
return resolveClientUrl(remoteSrc, url);
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function parseOrigin(url) {
|
|
457
|
+
try {
|
|
458
|
+
return new URL(url).origin;
|
|
459
|
+
} catch {
|
|
460
|
+
return void 0;
|
|
573
461
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
465
|
+
function bindResolveClientUrl(prop, remoteSrc) {
|
|
466
|
+
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// src/host/react/index.tsx
|
|
470
|
+
var import_react3 = require("react");
|
|
471
|
+
var import_react_dom = require("react-dom");
|
|
472
|
+
|
|
473
|
+
// src/host/server/fetch-headers.ts
|
|
474
|
+
function remoteFetchHeaders() {
|
|
475
|
+
return {
|
|
476
|
+
/**
|
|
477
|
+
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
478
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
479
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
480
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
481
|
+
*/
|
|
482
|
+
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
483
|
+
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
484
|
+
} : {},
|
|
485
|
+
Accept: "text/html"
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/host/server/fetch-with-hooks.ts
|
|
490
|
+
async function fetchWithWarning(url, init) {
|
|
491
|
+
try {
|
|
492
|
+
return await fetch(url, init);
|
|
493
|
+
} catch (error) {
|
|
494
|
+
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
495
|
+
throw error;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
499
|
+
const {
|
|
500
|
+
onRequest,
|
|
501
|
+
onResponse,
|
|
502
|
+
abortController = new AbortController()
|
|
503
|
+
} = options;
|
|
504
|
+
const signal = abortController.signal;
|
|
505
|
+
const hookOptions = {
|
|
506
|
+
signal,
|
|
507
|
+
abort: (reason) => abortController.abort(reason)
|
|
508
|
+
};
|
|
509
|
+
const init = {
|
|
510
|
+
method: "GET",
|
|
511
|
+
headers: remoteFetchHeaders(),
|
|
512
|
+
signal,
|
|
513
|
+
...additionalInit
|
|
514
|
+
};
|
|
515
|
+
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
516
|
+
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// src/host/server/get-client-or-server-url.ts
|
|
520
|
+
function getClientOrServerUrl(src, serverFallback) {
|
|
521
|
+
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
522
|
+
if (!src) {
|
|
523
|
+
return new URL(fallback);
|
|
524
|
+
}
|
|
525
|
+
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// src/host/shared/state.ts
|
|
529
|
+
function createHostState() {
|
|
530
|
+
return {
|
|
531
|
+
stage: "idle",
|
|
532
|
+
prevSrc: void 0,
|
|
533
|
+
prevUrl: void 0,
|
|
534
|
+
prevName: void 0,
|
|
535
|
+
prevIsRemoteComponent: false,
|
|
536
|
+
abortController: void 0
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
541
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
542
|
+
if (!src) {
|
|
543
|
+
return defaultName;
|
|
544
|
+
}
|
|
545
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
546
|
+
const hashIndex = hash.indexOf("#");
|
|
547
|
+
if (hashIndex < 0) {
|
|
548
|
+
return defaultName;
|
|
549
|
+
}
|
|
550
|
+
const name = hash.slice(hashIndex + 1);
|
|
551
|
+
return name || defaultName;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/utils/index.ts
|
|
555
|
+
function escapeString(str) {
|
|
556
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
557
|
+
}
|
|
558
|
+
var attrToProp = {
|
|
559
|
+
fetchpriority: "fetchPriority",
|
|
560
|
+
crossorigin: "crossOrigin",
|
|
561
|
+
imagesrcset: "imageSrcSet",
|
|
562
|
+
imagesizes: "imageSizes",
|
|
563
|
+
srcset: "srcSet"
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/runtime/constants.ts
|
|
567
|
+
var DEFAULT_ROUTE = "/";
|
|
568
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
569
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
570
|
+
var RUNTIME_SCRIPT = "script";
|
|
571
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
572
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
573
|
+
function getBundleKey(bundle) {
|
|
574
|
+
return escapeString(bundle);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/runtime/html/apply-origin.ts
|
|
578
|
+
var tagNames = [
|
|
579
|
+
"img",
|
|
580
|
+
"source",
|
|
581
|
+
"video",
|
|
582
|
+
"audio",
|
|
583
|
+
"track",
|
|
584
|
+
"iframe",
|
|
585
|
+
"embed",
|
|
586
|
+
"script",
|
|
587
|
+
"link"
|
|
588
|
+
];
|
|
589
|
+
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
590
|
+
if (url.origin !== location.origin) {
|
|
591
|
+
const nodes = doc.querySelectorAll(
|
|
592
|
+
tagNames.map(
|
|
593
|
+
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
594
|
+
).join(",")
|
|
605
595
|
);
|
|
596
|
+
nodes.forEach((node) => {
|
|
597
|
+
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
598
|
+
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
599
|
+
const isScript = node.tagName.toLowerCase() === "script";
|
|
600
|
+
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
601
|
+
}
|
|
602
|
+
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
603
|
+
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
604
|
+
node.setAttribute(
|
|
605
|
+
"href",
|
|
606
|
+
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
if (node.hasAttribute("srcset")) {
|
|
610
|
+
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
611
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
612
|
+
if (!urlPart)
|
|
613
|
+
return entry;
|
|
614
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
615
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
616
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
617
|
+
}).join(", ");
|
|
618
|
+
if (srcSet) {
|
|
619
|
+
node.setAttribute("srcset", srcSet);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (node.hasAttribute("imagesrcset")) {
|
|
623
|
+
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
624
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
625
|
+
if (!urlPart)
|
|
626
|
+
return entry;
|
|
627
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
628
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
629
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
630
|
+
}).join(", ");
|
|
631
|
+
if (srcSet) {
|
|
632
|
+
node.setAttribute("imagesrcset", srcSet);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
});
|
|
606
636
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/runtime/html/parse-remote-html.ts
|
|
640
|
+
function validateSingleComponent(doc, name, url) {
|
|
641
|
+
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}"]`)) {
|
|
642
|
+
throw multipleRemoteComponentsError(url);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function findComponentElement(doc, name) {
|
|
646
|
+
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])");
|
|
647
|
+
}
|
|
648
|
+
function parseNextData(doc) {
|
|
649
|
+
return JSON.parse(
|
|
650
|
+
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
612
651
|
);
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
652
|
+
}
|
|
653
|
+
function resolveComponentName(component, nextData, fallbackName) {
|
|
654
|
+
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
655
|
+
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
656
|
+
return { name, isRemoteComponent };
|
|
657
|
+
}
|
|
658
|
+
function extractComponentMetadata(component, nextData, name, url) {
|
|
659
|
+
return {
|
|
660
|
+
name,
|
|
661
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
662
|
+
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
663
|
+
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function extractRemoteShared(doc, name, nextData) {
|
|
667
|
+
const remoteSharedEl = doc.querySelector(
|
|
668
|
+
`#${name}_shared[data-remote-components-shared]`
|
|
669
|
+
);
|
|
670
|
+
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
671
|
+
remoteSharedEl?.remove();
|
|
672
|
+
return remoteShared;
|
|
673
|
+
}
|
|
674
|
+
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
675
|
+
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
676
|
+
throw new RemoteComponentsError(
|
|
677
|
+
`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>?`
|
|
616
678
|
);
|
|
617
679
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
680
|
+
}
|
|
681
|
+
function extractLinks(doc, component) {
|
|
682
|
+
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
683
|
+
(link) => !component.contains(link)
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
function extractScripts(doc, component, isRemoteComponent) {
|
|
687
|
+
return Array.from(
|
|
688
|
+
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
689
|
+
"script[src],script[data-src]"
|
|
690
|
+
)
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
function parseRemoteComponentDocument(doc, name, url) {
|
|
694
|
+
validateSingleComponent(doc, name, url.href);
|
|
695
|
+
const component = findComponentElement(doc, name);
|
|
696
|
+
const nextData = parseNextData(doc);
|
|
697
|
+
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
698
|
+
component,
|
|
699
|
+
nextData,
|
|
700
|
+
name
|
|
701
|
+
);
|
|
702
|
+
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
703
|
+
const metadata = extractComponentMetadata(
|
|
704
|
+
component,
|
|
705
|
+
nextData,
|
|
706
|
+
resolvedName,
|
|
707
|
+
url
|
|
708
|
+
);
|
|
709
|
+
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
710
|
+
validateComponentFound(
|
|
711
|
+
component,
|
|
712
|
+
rsc,
|
|
713
|
+
nextData,
|
|
714
|
+
isRemoteComponent,
|
|
715
|
+
url.href,
|
|
716
|
+
resolvedName
|
|
717
|
+
);
|
|
718
|
+
const links = extractLinks(doc, component);
|
|
719
|
+
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
720
|
+
return {
|
|
721
|
+
component,
|
|
722
|
+
name: resolvedName,
|
|
723
|
+
isRemoteComponent,
|
|
724
|
+
metadata,
|
|
725
|
+
nextData,
|
|
726
|
+
rsc,
|
|
727
|
+
remoteShared,
|
|
728
|
+
links,
|
|
729
|
+
scripts
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// src/runtime/html/set-attributes-from-props.ts
|
|
734
|
+
var DOMAttributeNames = {
|
|
735
|
+
acceptCharset: "accept-charset",
|
|
736
|
+
className: "class",
|
|
737
|
+
htmlFor: "for",
|
|
738
|
+
httpEquiv: "http-equiv",
|
|
739
|
+
noModule: "noModule"
|
|
740
|
+
};
|
|
741
|
+
var ignoreProps = [
|
|
742
|
+
"onLoad",
|
|
743
|
+
"onReady",
|
|
744
|
+
"dangerouslySetInnerHTML",
|
|
745
|
+
"children",
|
|
746
|
+
"onError",
|
|
747
|
+
"strategy",
|
|
748
|
+
"stylesheets"
|
|
749
|
+
];
|
|
750
|
+
function isBooleanScriptAttribute(attr) {
|
|
751
|
+
return ["async", "defer", "noModule"].includes(attr);
|
|
752
|
+
}
|
|
753
|
+
function setAttributesFromProps(el, props) {
|
|
754
|
+
for (const [p, value] of Object.entries(props)) {
|
|
755
|
+
if (!Object.hasOwn(props, p))
|
|
756
|
+
continue;
|
|
757
|
+
if (ignoreProps.includes(p))
|
|
758
|
+
continue;
|
|
759
|
+
if (value === void 0) {
|
|
760
|
+
continue;
|
|
653
761
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
658
|
-
});
|
|
762
|
+
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
763
|
+
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
764
|
+
el[attr] = Boolean(value);
|
|
659
765
|
} else {
|
|
660
|
-
|
|
661
|
-
elements.forEach((el) => {
|
|
662
|
-
document.head.appendChild(el);
|
|
663
|
-
});
|
|
766
|
+
el.setAttribute(attr, String(value));
|
|
664
767
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
768
|
+
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
769
|
+
el.setAttribute(attr, "");
|
|
770
|
+
el.removeAttribute(attr);
|
|
669
771
|
}
|
|
670
|
-
nextCss.remove();
|
|
671
|
-
nextCssEnd.remove();
|
|
672
|
-
return { Component, App };
|
|
673
772
|
}
|
|
674
|
-
return { Component: null, App: null };
|
|
675
773
|
}
|
|
676
774
|
|
|
677
|
-
// src/
|
|
775
|
+
// src/runtime/loaders/component-loader.ts
|
|
776
|
+
var React = __toESM(require("react"), 1);
|
|
777
|
+
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
778
|
+
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
779
|
+
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
780
|
+
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
781
|
+
|
|
782
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
783
|
+
var DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
678
784
|
function applySharedModules(bundle, resolve) {
|
|
679
785
|
logDebug(
|
|
680
786
|
"SharedModules",
|
|
@@ -694,48 +800,160 @@ function applySharedModules(bundle, resolve) {
|
|
|
694
800
|
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
695
801
|
);
|
|
696
802
|
for (const [key, value] of Object.entries(resolve)) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
700
|
-
}
|
|
803
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
804
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
701
805
|
if (ids.length === 0) {
|
|
702
806
|
logDebug(
|
|
703
807
|
"SharedModules",
|
|
704
808
|
`No matching module path found for shared module "${key}"`
|
|
705
809
|
);
|
|
706
810
|
}
|
|
707
|
-
for (
|
|
811
|
+
for (const id of ids) {
|
|
708
812
|
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
709
813
|
if (webpackBundle.m) {
|
|
710
|
-
|
|
711
|
-
|
|
814
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
815
|
+
if (resolvedId !== id) {
|
|
712
816
|
logDebug(
|
|
713
817
|
"SharedModules",
|
|
714
|
-
`Mapped module id: "${id}" -> "${
|
|
818
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
715
819
|
);
|
|
716
|
-
id = mappedId;
|
|
717
820
|
}
|
|
718
|
-
webpackBundle.m[
|
|
821
|
+
webpackBundle.m[resolvedId] = (module2) => {
|
|
719
822
|
module2.exports = value;
|
|
720
823
|
};
|
|
721
824
|
} else {
|
|
722
825
|
logWarn(
|
|
723
826
|
"SharedModules",
|
|
724
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
827
|
+
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
725
828
|
);
|
|
726
829
|
}
|
|
727
830
|
}
|
|
728
831
|
}
|
|
729
|
-
} else {
|
|
730
|
-
logWarn(
|
|
731
|
-
|
|
732
|
-
"
|
|
733
|
-
|
|
734
|
-
|
|
832
|
+
} else {
|
|
833
|
+
logWarn(
|
|
834
|
+
"SharedModules",
|
|
835
|
+
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
836
|
+
);
|
|
837
|
+
logDebug(
|
|
838
|
+
"SharedModules",
|
|
839
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
845
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
846
|
+
const self = globalThis;
|
|
847
|
+
const nextCssOriginal = document.querySelector(
|
|
848
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
849
|
+
);
|
|
850
|
+
if (nextCssOriginal) {
|
|
851
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
852
|
+
}
|
|
853
|
+
const nextCss = document.createElement("noscript");
|
|
854
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
855
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
856
|
+
nextCss.setAttribute("data-route", route);
|
|
857
|
+
const nextCssEnd = document.createElement("noscript");
|
|
858
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
859
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
860
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
861
|
+
document.head.appendChild(nextCssEnd);
|
|
862
|
+
document.head.appendChild(nextCss);
|
|
863
|
+
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
864
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
865
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
866
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
867
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
868
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
869
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
870
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
871
|
+
) ?? ""] ?? -1;
|
|
872
|
+
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
873
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
874
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
875
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
876
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
877
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
878
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
879
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
880
|
+
) ?? ""] ?? -1;
|
|
881
|
+
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
882
|
+
throw new RemoteComponentsError(
|
|
883
|
+
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
887
|
+
const selfOriginal = self;
|
|
888
|
+
delete selfOriginal.__NEXT_P;
|
|
889
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
890
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
891
|
+
);
|
|
892
|
+
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
893
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
894
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
if (self.__NEXT_P) {
|
|
898
|
+
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
899
|
+
void 0,
|
|
900
|
+
() => ({ default: null })
|
|
901
|
+
];
|
|
902
|
+
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
903
|
+
void 0,
|
|
904
|
+
() => ({
|
|
905
|
+
default: null
|
|
906
|
+
})
|
|
907
|
+
];
|
|
908
|
+
const { default: Component } = componentLoader();
|
|
909
|
+
const { default: App } = appLoader();
|
|
910
|
+
if (!self.__remote_next_css__) {
|
|
911
|
+
self.__remote_next_css__ = {};
|
|
912
|
+
}
|
|
913
|
+
if (!self.__remote_next_css__[bundle]) {
|
|
914
|
+
const cssRE = /\.s?css$/;
|
|
915
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
916
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
917
|
+
});
|
|
918
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
919
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
920
|
+
if (id) {
|
|
921
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
const elements = [];
|
|
925
|
+
let node = nextCss.previousSibling;
|
|
926
|
+
while (node && node !== nextCssEnd) {
|
|
927
|
+
elements.push(node);
|
|
928
|
+
node.remove();
|
|
929
|
+
node = nextCss.previousSibling;
|
|
930
|
+
}
|
|
931
|
+
self.__remote_next_css__[bundle] = elements;
|
|
932
|
+
}
|
|
933
|
+
if (styleContainer) {
|
|
934
|
+
const elements = self.__remote_next_css__[bundle];
|
|
935
|
+
elements.forEach((el) => {
|
|
936
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
937
|
+
});
|
|
938
|
+
} else {
|
|
939
|
+
const elements = self.__remote_next_css__[bundle];
|
|
940
|
+
elements.forEach((el) => {
|
|
941
|
+
document.head.appendChild(el);
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
delete self.__NEXT_P;
|
|
945
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
946
|
+
if (nextCssOriginal) {
|
|
947
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
948
|
+
}
|
|
949
|
+
nextCss.remove();
|
|
950
|
+
nextCssEnd.remove();
|
|
951
|
+
return { Component, App };
|
|
735
952
|
}
|
|
953
|
+
return { Component: null, App: null };
|
|
736
954
|
}
|
|
737
955
|
|
|
738
|
-
// src/
|
|
956
|
+
// src/runtime/rsc.ts
|
|
739
957
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
740
958
|
function fixPayload(payload) {
|
|
741
959
|
if (Array.isArray(payload)) {
|
|
@@ -801,56 +1019,15 @@ function createRSCStream(rscName, data) {
|
|
|
801
1019
|
});
|
|
802
1020
|
}
|
|
803
1021
|
|
|
804
|
-
// src/
|
|
805
|
-
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
806
|
-
|
|
807
|
-
// src/shared/client/script-loader.ts
|
|
808
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
809
|
-
await Promise.all(
|
|
810
|
-
scripts.map((script) => {
|
|
811
|
-
return new Promise((resolve, reject) => {
|
|
812
|
-
const newSrc = new URL(
|
|
813
|
-
// remove the remote component bundle name identifier from the script src
|
|
814
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
815
|
-
location.origin
|
|
816
|
-
).href;
|
|
817
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
818
|
-
const newScript = document.createElement("script");
|
|
819
|
-
newScript.onload = () => resolve();
|
|
820
|
-
newScript.onerror = () => {
|
|
821
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
822
|
-
if (isProxied) {
|
|
823
|
-
reject(
|
|
824
|
-
new RemoteComponentsError(
|
|
825
|
-
`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}`
|
|
826
|
-
)
|
|
827
|
-
);
|
|
828
|
-
} else {
|
|
829
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
830
|
-
reject(
|
|
831
|
-
new RemoteComponentsError(
|
|
832
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
833
|
-
)
|
|
834
|
-
);
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
newScript.src = resolvedSrc;
|
|
838
|
-
newScript.async = true;
|
|
839
|
-
document.head.appendChild(newScript);
|
|
840
|
-
});
|
|
841
|
-
})
|
|
842
|
-
);
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
// src/shared/client/turbopack-patterns.ts
|
|
1022
|
+
// src/runtime/turbopack/patterns.ts
|
|
846
1023
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
847
|
-
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|
|
|
1024
|
+
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
848
1025
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
849
1026
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
850
1027
|
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]+)\)\)\)\}/;
|
|
851
1028
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
852
1029
|
|
|
853
|
-
// src/
|
|
1030
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
854
1031
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
855
1032
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
856
1033
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -910,11 +1087,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
910
1087
|
}).then(resolve).catch((error) => {
|
|
911
1088
|
const isProxied = isProxiedUrl(resolvedUrl);
|
|
912
1089
|
if (isProxied) {
|
|
913
|
-
reject(
|
|
914
|
-
new RemoteComponentsError(
|
|
915
|
-
`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}`
|
|
916
|
-
)
|
|
917
|
-
);
|
|
1090
|
+
reject(failedProxiedAssetError("chunk", url, resolvedUrl));
|
|
918
1091
|
} else {
|
|
919
1092
|
warnCrossOriginFetchError("ChunkLoader", url);
|
|
920
1093
|
reject(error);
|
|
@@ -1062,7 +1235,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1062
1235
|
}
|
|
1063
1236
|
}
|
|
1064
1237
|
|
|
1065
|
-
// src/
|
|
1238
|
+
// src/runtime/turbopack/module.ts
|
|
1066
1239
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
1067
1240
|
const self = globalThis;
|
|
1068
1241
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1291,7 +1464,8 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1291
1464
|
};
|
|
1292
1465
|
}
|
|
1293
1466
|
|
|
1294
|
-
// src/
|
|
1467
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1468
|
+
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).";
|
|
1295
1469
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1296
1470
|
const self = globalThis;
|
|
1297
1471
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1328,9 +1502,9 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1328
1502
|
}
|
|
1329
1503
|
}
|
|
1330
1504
|
if (sharedModuleInitializer) {
|
|
1331
|
-
const { shared } = await sharedModuleInitializer;
|
|
1505
|
+
const { shared: shared2 } = await sharedModuleInitializer;
|
|
1332
1506
|
const sharedModuleIds = extractSharedModuleIds(
|
|
1333
|
-
|
|
1507
|
+
shared2,
|
|
1334
1508
|
bundleKey,
|
|
1335
1509
|
self
|
|
1336
1510
|
);
|
|
@@ -1342,7 +1516,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1342
1516
|
} else {
|
|
1343
1517
|
logError(
|
|
1344
1518
|
"SharedModules",
|
|
1345
|
-
`Host shared module "${module2}" not found for ID ${id}`
|
|
1519
|
+
`Host shared module "${module2}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1346
1520
|
);
|
|
1347
1521
|
}
|
|
1348
1522
|
}
|
|
@@ -1359,15 +1533,15 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1359
1533
|
} else {
|
|
1360
1534
|
logError(
|
|
1361
1535
|
"SharedModules",
|
|
1362
|
-
`Shared module "${module2}" not found for "${bundle}"`
|
|
1536
|
+
`Shared module "${module2}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
|
|
1363
1537
|
);
|
|
1364
1538
|
}
|
|
1365
1539
|
}
|
|
1366
1540
|
})
|
|
1367
1541
|
);
|
|
1368
1542
|
}
|
|
1369
|
-
function extractSharedModuleIds(
|
|
1370
|
-
return Object.entries(
|
|
1543
|
+
function extractSharedModuleIds(shared2, bundleKey, self) {
|
|
1544
|
+
return Object.entries(shared2).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1371
1545
|
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1372
1546
|
if (asyncSharedModuleId) {
|
|
1373
1547
|
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
@@ -1411,8 +1585,8 @@ function getSharedModule(bundle, id) {
|
|
|
1411
1585
|
return null;
|
|
1412
1586
|
}
|
|
1413
1587
|
|
|
1414
|
-
// src/
|
|
1415
|
-
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle,
|
|
1588
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1589
|
+
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared2 = {}, remoteShared = {}, resolveClientUrl) {
|
|
1416
1590
|
const self = globalThis;
|
|
1417
1591
|
if (!self.__remote_bundle_url__) {
|
|
1418
1592
|
self.__remote_bundle_url__ = {};
|
|
@@ -1449,7 +1623,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1449
1623
|
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1450
1624
|
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1451
1625
|
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1452
|
-
...
|
|
1626
|
+
...shared2
|
|
1453
1627
|
};
|
|
1454
1628
|
await initializeSharedModules(
|
|
1455
1629
|
bundle ?? "default",
|
|
@@ -1466,7 +1640,7 @@ function createModuleRequire(runtime) {
|
|
|
1466
1640
|
id
|
|
1467
1641
|
};
|
|
1468
1642
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1469
|
-
logDebug("
|
|
1643
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1470
1644
|
try {
|
|
1471
1645
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1472
1646
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1482,7 +1656,7 @@ function createModuleRequire(runtime) {
|
|
|
1482
1656
|
throw new Error(`Module "${id}" not found.`);
|
|
1483
1657
|
} catch (requireError) {
|
|
1484
1658
|
logWarn(
|
|
1485
|
-
"
|
|
1659
|
+
"WebpackRuntime",
|
|
1486
1660
|
`Module require failed: ${String(requireError)}`
|
|
1487
1661
|
);
|
|
1488
1662
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1494,7 +1668,7 @@ function createModuleRequire(runtime) {
|
|
|
1494
1668
|
);
|
|
1495
1669
|
}
|
|
1496
1670
|
try {
|
|
1497
|
-
logDebug("
|
|
1671
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1498
1672
|
return self.__original_webpack_require__(id);
|
|
1499
1673
|
} catch (originalError) {
|
|
1500
1674
|
throw new RemoteComponentsError(
|
|
@@ -1506,7 +1680,41 @@ function createModuleRequire(runtime) {
|
|
|
1506
1680
|
};
|
|
1507
1681
|
}
|
|
1508
1682
|
|
|
1509
|
-
// src/
|
|
1683
|
+
// src/runtime/loaders/script-loader.ts
|
|
1684
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
1685
|
+
await Promise.all(
|
|
1686
|
+
scripts.map((script) => {
|
|
1687
|
+
return new Promise((resolve, reject) => {
|
|
1688
|
+
const newSrc = new URL(
|
|
1689
|
+
// remove the remote component bundle name identifier from the script src
|
|
1690
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1691
|
+
location.origin
|
|
1692
|
+
).href;
|
|
1693
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1694
|
+
const newScript = document.createElement("script");
|
|
1695
|
+
newScript.onload = () => resolve();
|
|
1696
|
+
newScript.onerror = () => {
|
|
1697
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1698
|
+
if (isProxied) {
|
|
1699
|
+
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
1700
|
+
} else {
|
|
1701
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1702
|
+
reject(
|
|
1703
|
+
new RemoteComponentsError(
|
|
1704
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1705
|
+
)
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
newScript.src = resolvedSrc;
|
|
1710
|
+
newScript.async = true;
|
|
1711
|
+
document.head.appendChild(newScript);
|
|
1712
|
+
});
|
|
1713
|
+
})
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// src/runtime/loaders/component-loader.ts
|
|
1510
1718
|
async function loadRemoteComponent({
|
|
1511
1719
|
url,
|
|
1512
1720
|
name,
|
|
@@ -1517,7 +1725,7 @@ async function loadRemoteComponent({
|
|
|
1517
1725
|
data,
|
|
1518
1726
|
nextData,
|
|
1519
1727
|
scripts = [],
|
|
1520
|
-
shared = Promise.resolve({}),
|
|
1728
|
+
shared: shared2 = Promise.resolve({}),
|
|
1521
1729
|
remoteShared = {},
|
|
1522
1730
|
container,
|
|
1523
1731
|
resolveClientUrl
|
|
@@ -1531,7 +1739,7 @@ async function loadRemoteComponent({
|
|
|
1531
1739
|
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1532
1740
|
await loadScripts(scripts, resolveClientUrl);
|
|
1533
1741
|
}
|
|
1534
|
-
const hostShared = await
|
|
1742
|
+
const hostShared = await shared2;
|
|
1535
1743
|
logDebug(
|
|
1536
1744
|
"ComponentLoader",
|
|
1537
1745
|
`loadRemoteComponent: bundle="${bundle}", name="${name}"`
|
|
@@ -1609,17 +1817,19 @@ async function loadRemoteComponent({
|
|
|
1609
1817
|
};
|
|
1610
1818
|
}
|
|
1611
1819
|
}
|
|
1612
|
-
async function
|
|
1613
|
-
let createFromReadableStream;
|
|
1820
|
+
async function importCreateFromReadableStream() {
|
|
1614
1821
|
try {
|
|
1615
|
-
const { createFromReadableStream
|
|
1616
|
-
createFromReadableStream
|
|
1822
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1823
|
+
return createFromReadableStream;
|
|
1617
1824
|
} catch {
|
|
1618
1825
|
const {
|
|
1619
|
-
default: { createFromReadableStream
|
|
1826
|
+
default: { createFromReadableStream }
|
|
1620
1827
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1621
|
-
createFromReadableStream
|
|
1828
|
+
return createFromReadableStream;
|
|
1622
1829
|
}
|
|
1830
|
+
}
|
|
1831
|
+
async function loadRSCComponent(rscName, data) {
|
|
1832
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1623
1833
|
if (typeof createFromReadableStream !== "function") {
|
|
1624
1834
|
throw new RemoteComponentsError(
|
|
1625
1835
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1640,68 +1850,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1640
1850
|
return { component };
|
|
1641
1851
|
}
|
|
1642
1852
|
|
|
1643
|
-
// src/
|
|
1644
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1645
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
1646
|
-
return (url) => {
|
|
1647
|
-
const urlOrigin = parseOrigin(url);
|
|
1648
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
1649
|
-
return void 0;
|
|
1650
|
-
}
|
|
1651
|
-
return resolveClientUrl(remoteSrc, url);
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
|
-
function parseOrigin(url) {
|
|
1655
|
-
try {
|
|
1656
|
-
return new URL(url).origin;
|
|
1657
|
-
} catch {
|
|
1658
|
-
return void 0;
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1663
|
-
var DOMAttributeNames = {
|
|
1664
|
-
acceptCharset: "accept-charset",
|
|
1665
|
-
className: "class",
|
|
1666
|
-
htmlFor: "for",
|
|
1667
|
-
httpEquiv: "http-equiv",
|
|
1668
|
-
noModule: "noModule"
|
|
1669
|
-
};
|
|
1670
|
-
var ignoreProps = [
|
|
1671
|
-
"onLoad",
|
|
1672
|
-
"onReady",
|
|
1673
|
-
"dangerouslySetInnerHTML",
|
|
1674
|
-
"children",
|
|
1675
|
-
"onError",
|
|
1676
|
-
"strategy",
|
|
1677
|
-
"stylesheets"
|
|
1678
|
-
];
|
|
1679
|
-
function isBooleanScriptAttribute(attr) {
|
|
1680
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1681
|
-
}
|
|
1682
|
-
function setAttributesFromProps(el, props) {
|
|
1683
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1684
|
-
if (!Object.hasOwn(props, p))
|
|
1685
|
-
continue;
|
|
1686
|
-
if (ignoreProps.includes(p))
|
|
1687
|
-
continue;
|
|
1688
|
-
if (value === void 0) {
|
|
1689
|
-
continue;
|
|
1690
|
-
}
|
|
1691
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1692
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1693
|
-
el[attr] = Boolean(value);
|
|
1694
|
-
} else {
|
|
1695
|
-
el.setAttribute(attr, String(value));
|
|
1696
|
-
}
|
|
1697
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1698
|
-
el.setAttribute(attr, "");
|
|
1699
|
-
el.removeAttribute(attr);
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// src/shared/client/static-loader.ts
|
|
1853
|
+
// src/runtime/loaders/static-loader.ts
|
|
1705
1854
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1706
1855
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1707
1856
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1851,101 +2000,9 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1851
2000
|
);
|
|
1852
2001
|
}
|
|
1853
2002
|
|
|
1854
|
-
// src/
|
|
1855
|
-
function createHostState() {
|
|
1856
|
-
return {
|
|
1857
|
-
stage: "idle",
|
|
1858
|
-
prevSrc: void 0,
|
|
1859
|
-
prevUrl: void 0,
|
|
1860
|
-
prevName: void 0,
|
|
1861
|
-
prevIsRemoteComponent: false,
|
|
1862
|
-
abortController: void 0
|
|
1863
|
-
};
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
// src/shared/contract/resolve-name-from-src.ts
|
|
1867
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
1868
|
-
if (!src) {
|
|
1869
|
-
return defaultName;
|
|
1870
|
-
}
|
|
1871
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
1872
|
-
const hashIndex = hash.indexOf("#");
|
|
1873
|
-
if (hashIndex < 0) {
|
|
1874
|
-
return defaultName;
|
|
1875
|
-
}
|
|
1876
|
-
const name = hash.slice(hashIndex + 1);
|
|
1877
|
-
return name || defaultName;
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
// src/shared/ssr/fetch-headers.ts
|
|
1881
|
-
function remoteFetchHeaders() {
|
|
1882
|
-
return {
|
|
1883
|
-
/**
|
|
1884
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1885
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1886
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1887
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1888
|
-
*/
|
|
1889
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1890
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1891
|
-
} : {},
|
|
1892
|
-
Accept: "text/html"
|
|
1893
|
-
};
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1896
|
-
// src/shared/ssr/fetch-with-hooks.ts
|
|
1897
|
-
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1898
|
-
const {
|
|
1899
|
-
onRequest,
|
|
1900
|
-
onResponse,
|
|
1901
|
-
abortController = new AbortController()
|
|
1902
|
-
} = options;
|
|
1903
|
-
const signal = abortController.signal;
|
|
1904
|
-
const hookOptions = {
|
|
1905
|
-
signal,
|
|
1906
|
-
abort: (reason) => abortController.abort(reason)
|
|
1907
|
-
};
|
|
1908
|
-
const init = {
|
|
1909
|
-
method: "GET",
|
|
1910
|
-
headers: remoteFetchHeaders(),
|
|
1911
|
-
signal,
|
|
1912
|
-
...additionalInit
|
|
1913
|
-
};
|
|
1914
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1915
|
-
if (!res) {
|
|
1916
|
-
try {
|
|
1917
|
-
res = await fetch(url, init);
|
|
1918
|
-
} catch (error) {
|
|
1919
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1920
|
-
throw error;
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
1924
|
-
if (transformedRes) {
|
|
1925
|
-
res = transformedRes;
|
|
1926
|
-
}
|
|
1927
|
-
return res;
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
// src/shared/ssr/get-client-or-server-url.ts
|
|
1931
|
-
function getClientOrServerUrl(src, serverFallback) {
|
|
1932
|
-
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
1933
|
-
if (!src) {
|
|
1934
|
-
return new URL(fallback);
|
|
1935
|
-
}
|
|
1936
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
2003
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1940
2004
|
var import_react = require("react");
|
|
1941
|
-
var import_context = require("#internal/react/context");
|
|
1942
|
-
|
|
1943
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1944
|
-
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1945
|
-
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
2005
|
+
var import_context = require("#internal/host/react/context");
|
|
1949
2006
|
function useResolveClientUrl(prop, urlHref) {
|
|
1950
2007
|
const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
|
|
1951
2008
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1955,7 +2012,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1955
2012
|
);
|
|
1956
2013
|
}
|
|
1957
2014
|
|
|
1958
|
-
// src/react/hooks/use-shadow-root.ts
|
|
2015
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1959
2016
|
var import_react2 = require("react");
|
|
1960
2017
|
function useShadowRoot({
|
|
1961
2018
|
isolate,
|
|
@@ -2004,7 +2061,7 @@ function useShadowRoot({
|
|
|
2004
2061
|
return { shadowRoot, shadowRootContainerRef };
|
|
2005
2062
|
}
|
|
2006
2063
|
|
|
2007
|
-
// src/react/utils/extract-remote-html.ts
|
|
2064
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
2008
2065
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
2009
2066
|
function getRemoteComponentHtml(html) {
|
|
2010
2067
|
if (typeof document === "undefined")
|
|
@@ -2026,21 +2083,20 @@ function getRemoteComponentHtml(html) {
|
|
|
2026
2083
|
return "";
|
|
2027
2084
|
}
|
|
2028
2085
|
|
|
2029
|
-
// src/react/index.tsx
|
|
2030
|
-
var
|
|
2031
|
-
var import_jsx_runtime2 = (
|
|
2086
|
+
// src/host/react/index.tsx
|
|
2087
|
+
var import_jsx_runtime3 = (
|
|
2032
2088
|
// TODO: remove wrapper div by converting HTML to RSC or React tree
|
|
2033
2089
|
require("react/jsx-runtime")
|
|
2034
2090
|
);
|
|
2035
2091
|
var import_react4 = require("react");
|
|
2036
|
-
function
|
|
2092
|
+
function ConsumeRemoteComponent({
|
|
2037
2093
|
src,
|
|
2038
2094
|
isolate,
|
|
2039
2095
|
mode = "open",
|
|
2040
2096
|
reset,
|
|
2041
2097
|
credentials = "same-origin",
|
|
2042
2098
|
name: nameProp = "__vercel_remote_component",
|
|
2043
|
-
shared = {},
|
|
2099
|
+
shared: shared2 = {},
|
|
2044
2100
|
children,
|
|
2045
2101
|
onBeforeLoad,
|
|
2046
2102
|
onLoad,
|
|
@@ -2055,7 +2111,9 @@ function RemoteComponent({
|
|
|
2055
2111
|
() => resolveNameFromSrc(src, nameProp),
|
|
2056
2112
|
[src, nameProp]
|
|
2057
2113
|
);
|
|
2058
|
-
const [data, setData] = (0, import_react3.useState)(
|
|
2114
|
+
const [data, setData] = (0, import_react3.useState)(
|
|
2115
|
+
null
|
|
2116
|
+
);
|
|
2059
2117
|
const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
2060
2118
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
2061
2119
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -2272,11 +2330,10 @@ function RemoteComponent({
|
|
|
2272
2330
|
});
|
|
2273
2331
|
self.__next_s = prevNextScripts;
|
|
2274
2332
|
}
|
|
2275
|
-
|
|
2333
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2334
|
+
remoteName
|
|
2335
|
+
)}` : void 0;
|
|
2276
2336
|
if (rsc) {
|
|
2277
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2278
|
-
id
|
|
2279
|
-
)}_${escapeString(remoteName)}`;
|
|
2280
2337
|
rsc.textContent = rsc.textContent?.replace(
|
|
2281
2338
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2282
2339
|
`self["${rscName}"]`
|
|
@@ -2294,7 +2351,7 @@ function RemoteComponent({
|
|
|
2294
2351
|
componentHydrationHtml.current = `${Array.from(
|
|
2295
2352
|
doc.querySelectorAll("link,style")
|
|
2296
2353
|
).map((link) => link.outerHTML).join("")}${reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>` : ""}${component.innerHTML}`;
|
|
2297
|
-
const userShared = await
|
|
2354
|
+
const userShared = await shared2;
|
|
2298
2355
|
if ("__remote_components_missing_shared__" in userShared) {
|
|
2299
2356
|
userShared.__remote_components_missing_shared__().catch((e) => {
|
|
2300
2357
|
throw e;
|
|
@@ -2315,10 +2372,7 @@ function RemoteComponent({
|
|
|
2315
2372
|
}
|
|
2316
2373
|
setData(newData);
|
|
2317
2374
|
if (shadowRoot) {
|
|
2318
|
-
|
|
2319
|
-
if (reset) {
|
|
2320
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2321
|
-
}
|
|
2375
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2322
2376
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2323
2377
|
htmlRef.current = null;
|
|
2324
2378
|
setRemoteComponent(null);
|
|
@@ -2334,7 +2388,7 @@ function RemoteComponent({
|
|
|
2334
2388
|
onLoad?.(src);
|
|
2335
2389
|
} else if (isolate === false) {
|
|
2336
2390
|
setRemoteComponent(
|
|
2337
|
-
/* @__PURE__ */ (0,
|
|
2391
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2338
2392
|
"div",
|
|
2339
2393
|
{
|
|
2340
2394
|
dangerouslySetInnerHTML: { __html: component.innerHTML },
|
|
@@ -2386,7 +2440,7 @@ function RemoteComponent({
|
|
|
2386
2440
|
};
|
|
2387
2441
|
}),
|
|
2388
2442
|
shared: {
|
|
2389
|
-
...sharedPolyfills(userShared),
|
|
2443
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2390
2444
|
...userShared
|
|
2391
2445
|
},
|
|
2392
2446
|
remoteShared,
|
|
@@ -2432,7 +2486,7 @@ function RemoteComponent({
|
|
|
2432
2486
|
isolate,
|
|
2433
2487
|
credentials,
|
|
2434
2488
|
name,
|
|
2435
|
-
|
|
2489
|
+
shared2,
|
|
2436
2490
|
shadowRoot,
|
|
2437
2491
|
reset,
|
|
2438
2492
|
id,
|
|
@@ -2447,13 +2501,13 @@ function RemoteComponent({
|
|
|
2447
2501
|
if (remoteComponent instanceof Error) {
|
|
2448
2502
|
throw remoteComponent;
|
|
2449
2503
|
}
|
|
2450
|
-
const metadataJson = /* @__PURE__ */ (0,
|
|
2504
|
+
const metadataJson = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
|
|
2451
2505
|
name: data?.name || name,
|
|
2452
2506
|
bundle: data?.bundle || "default",
|
|
2453
2507
|
route: data?.route || DEFAULT_ROUTE,
|
|
2454
2508
|
runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
2455
2509
|
}) });
|
|
2456
|
-
const resetStyle = reset ? /* @__PURE__ */ (0,
|
|
2510
|
+
const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
2457
2511
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
|
|
2458
2512
|
"link",
|
|
2459
2513
|
{
|
|
@@ -2462,7 +2516,7 @@ function RemoteComponent({
|
|
|
2462
2516
|
key: JSON.stringify(link)
|
|
2463
2517
|
}
|
|
2464
2518
|
)) || null;
|
|
2465
|
-
const componentToRender = /* @__PURE__ */ (0,
|
|
2519
|
+
const componentToRender = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2466
2520
|
resetStyle,
|
|
2467
2521
|
linksToRender,
|
|
2468
2522
|
remoteComponent ?? children
|
|
@@ -2500,9 +2554,9 @@ function RemoteComponent({
|
|
|
2500
2554
|
if (shadowRemoteComponentHtml) {
|
|
2501
2555
|
shadowRemoteComponentHtml.remove();
|
|
2502
2556
|
}
|
|
2503
|
-
return /* @__PURE__ */ (0,
|
|
2557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2504
2558
|
metadataJson,
|
|
2505
|
-
/* @__PURE__ */ (0,
|
|
2559
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2506
2560
|
"div",
|
|
2507
2561
|
{
|
|
2508
2562
|
"data-remote-component-id": `shadowroot_${keySuffix}`,
|
|
@@ -2511,8 +2565,8 @@ function RemoteComponent({
|
|
|
2511
2565
|
children: [
|
|
2512
2566
|
typeof document === "undefined" ? (
|
|
2513
2567
|
// eslint-disable-next-line react/no-unknown-property
|
|
2514
|
-
/* @__PURE__ */ (0,
|
|
2515
|
-
typeof document === "undefined" ? /* @__PURE__ */ (0,
|
|
2568
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("template", { shadowrootmode: mode, children: [
|
|
2569
|
+
typeof document === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2516
2570
|
"div",
|
|
2517
2571
|
{
|
|
2518
2572
|
dangerouslySetInnerHTML: {
|
|
@@ -2534,12 +2588,12 @@ function RemoteComponent({
|
|
|
2534
2588
|
] })
|
|
2535
2589
|
) : null,
|
|
2536
2590
|
shadowRoot && remoteComponent ? (0, import_react_dom.createPortal)(
|
|
2537
|
-
/* @__PURE__ */ (0,
|
|
2538
|
-
/* @__PURE__ */ (0,
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_start` }),
|
|
2539
2593
|
resetStyle,
|
|
2540
2594
|
linksToRender,
|
|
2541
2595
|
remoteComponent,
|
|
2542
|
-
/* @__PURE__ */ (0,
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2543
2597
|
] }),
|
|
2544
2598
|
shadowRoot
|
|
2545
2599
|
) : null
|
|
@@ -2549,33 +2603,16 @@ function RemoteComponent({
|
|
|
2549
2603
|
] });
|
|
2550
2604
|
}
|
|
2551
2605
|
htmlRef.current = null;
|
|
2552
|
-
return /* @__PURE__ */ (0,
|
|
2553
|
-
/* @__PURE__ */ (0,
|
|
2606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2607
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_start` }),
|
|
2554
2608
|
metadataJson,
|
|
2555
2609
|
componentToRender,
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2610
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2557
2611
|
] });
|
|
2558
2612
|
}
|
|
2559
2613
|
|
|
2560
|
-
// src/
|
|
2561
|
-
var import_context3 = require("#internal/react/context");
|
|
2562
|
-
|
|
2563
|
-
// src/next/host/app-router-compat.tsx
|
|
2614
|
+
// src/host/nextjs/app-compat.tsx
|
|
2564
2615
|
var import_navigation = require("next/navigation");
|
|
2565
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2566
|
-
function imageImpl2(ImageComponent, bundle) {
|
|
2567
|
-
const component = function RemoteImage(props) {
|
|
2568
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2569
|
-
ImageComponent,
|
|
2570
|
-
{
|
|
2571
|
-
...props,
|
|
2572
|
-
src: applyBundleUrlToImagePropsSrc(bundle, props.src)
|
|
2573
|
-
}
|
|
2574
|
-
);
|
|
2575
|
-
};
|
|
2576
|
-
component.default = component;
|
|
2577
|
-
return component;
|
|
2578
|
-
}
|
|
2579
2616
|
var routerImpl = async () => {
|
|
2580
2617
|
const { useRouter } = await import("next/navigation");
|
|
2581
2618
|
return Promise.resolve({
|
|
@@ -2639,17 +2676,34 @@ var routerImpl = async () => {
|
|
|
2639
2676
|
});
|
|
2640
2677
|
};
|
|
2641
2678
|
|
|
2642
|
-
// src/
|
|
2679
|
+
// src/host/nextjs/image-shared.ts
|
|
2680
|
+
function createNextImageSharedEntries(getWrappedImage, options) {
|
|
2681
|
+
const entries = {
|
|
2682
|
+
"next/image": (bundle) => Promise.resolve(getWrappedImage(bundle)),
|
|
2683
|
+
"next/dist/client/image-component": (bundle) => Promise.resolve({
|
|
2684
|
+
Image: getWrappedImage(bundle)
|
|
2685
|
+
})
|
|
2686
|
+
};
|
|
2687
|
+
if (options?.getImageProps) {
|
|
2688
|
+
entries["next/dist/api/image"] = (bundle) => Promise.resolve({
|
|
2689
|
+
default: getWrappedImage(bundle),
|
|
2690
|
+
getImageProps: options.getImageProps
|
|
2691
|
+
});
|
|
2692
|
+
}
|
|
2693
|
+
return entries;
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
// src/host/nextjs/app-client-only.tsx
|
|
2643
2697
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2644
2698
|
async function tryImportShared() {
|
|
2645
2699
|
try {
|
|
2646
|
-
const { shared } = await
|
|
2647
|
-
return
|
|
2700
|
+
const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
2701
|
+
return shared2;
|
|
2648
2702
|
} catch {
|
|
2649
2703
|
return {};
|
|
2650
2704
|
}
|
|
2651
2705
|
}
|
|
2652
|
-
var sharedModules = async (userShared) => {
|
|
2706
|
+
var sharedModules = async (userShared, resolveClientUrl) => {
|
|
2653
2707
|
const [resolvedShared, resolvedUserShared] = await Promise.all([
|
|
2654
2708
|
tryImportShared(),
|
|
2655
2709
|
userShared ?? Promise.resolve({})
|
|
@@ -2657,20 +2711,28 @@ var sharedModules = async (userShared) => {
|
|
|
2657
2711
|
return {
|
|
2658
2712
|
...resolvedShared,
|
|
2659
2713
|
"next/router": routerImpl,
|
|
2660
|
-
|
|
2661
|
-
|
|
2714
|
+
...createNextImageSharedEntries(
|
|
2715
|
+
(bundle) => imageImpl2(Image.default, bundle ?? "default", resolveClientUrl)
|
|
2716
|
+
),
|
|
2662
2717
|
...resolvedUserShared
|
|
2663
2718
|
};
|
|
2664
2719
|
};
|
|
2665
|
-
function
|
|
2720
|
+
function ConsumeRemoteComponent2(props) {
|
|
2666
2721
|
if (typeof props.src !== "string" && !(props.src instanceof URL)) {
|
|
2667
2722
|
return props.children ?? null;
|
|
2668
2723
|
}
|
|
2669
|
-
|
|
2724
|
+
const src = typeof props.src === "string" ? props.src : props.src.href;
|
|
2725
|
+
const resolveClientUrl = props.resolveClientUrl ? bindResolveClientUrl(props.resolveClientUrl, src) : void 0;
|
|
2726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2727
|
+
ConsumeRemoteComponent,
|
|
2728
|
+
{
|
|
2729
|
+
...props,
|
|
2730
|
+
shared: sharedModules(props.shared, resolveClientUrl)
|
|
2731
|
+
}
|
|
2732
|
+
);
|
|
2670
2733
|
}
|
|
2671
2734
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2672
2735
|
0 && (module.exports = {
|
|
2673
|
-
|
|
2674
|
-
RemoteComponentsProvider
|
|
2736
|
+
ConsumeRemoteComponent
|
|
2675
2737
|
});
|
|
2676
|
-
//# sourceMappingURL=
|
|
2738
|
+
//# sourceMappingURL=client-only.cjs.map
|