remote-components 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{next/config.cjs → config/nextjs.cjs} +76 -101
- package/dist/config/nextjs.cjs.map +1 -0
- package/dist/{next/config.d.ts → config/nextjs.d.ts} +4 -4
- package/dist/{next/config.js → config/nextjs.js} +72 -97
- package/dist/config/nextjs.js.map +1 -0
- package/dist/{webpack.cjs → config/webpack.cjs} +13 -29
- package/dist/config/webpack.cjs.map +1 -0
- package/dist/{webpack.js → config/webpack.js} +12 -28
- package/dist/config/webpack.js.map +1 -0
- package/dist/{shared/remote → host/defaults}/app.cjs +2 -2
- package/dist/host/defaults/app.cjs.map +1 -0
- package/dist/host/defaults/app.js +8 -0
- package/dist/host/defaults/app.js.map +1 -0
- package/dist/{shared/remote → host/defaults}/pages.cjs +2 -2
- package/dist/host/defaults/pages.cjs.map +1 -0
- package/dist/host/defaults/pages.js +8 -0
- package/dist/host/defaults/pages.js.map +1 -0
- package/dist/{html/host.cjs → host/html.cjs} +1012 -1075
- package/dist/host/html.cjs.map +1 -0
- package/dist/{html/host.d.ts → host/html.d.ts} +0 -2
- package/dist/{html/host.js → host/html.js} +1009 -1071
- package/dist/host/html.js.map +1 -0
- package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +681 -617
- package/dist/host/nextjs/app/client-only.cjs.map +1 -0
- package/dist/host/nextjs/app/client-only.d.ts +16 -0
- package/dist/{next/host/client/index.js → host/nextjs/app/client-only.js} +682 -611
- package/dist/host/nextjs/app/client-only.js.map +1 -0
- package/dist/{next/host/app-router-server.cjs → host/nextjs/app.cjs} +11 -10
- package/dist/host/nextjs/app.cjs.map +1 -0
- package/dist/host/nextjs/app.d.ts +29 -0
- package/dist/{next/host/app-router-server.js → host/nextjs/app.js} +7 -6
- package/dist/host/nextjs/app.js.map +1 -0
- package/dist/{next/host/pages-router-client.cjs → host/nextjs/pages/client-only.cjs} +8 -8
- package/dist/host/nextjs/pages/client-only.cjs.map +1 -0
- package/dist/host/nextjs/pages/client-only.d.ts +31 -0
- package/dist/{next/host/pages-router-client.js → host/nextjs/pages/client-only.js} +4 -4
- package/dist/host/nextjs/pages/client-only.js.map +1 -0
- package/dist/{next/host/pages-router-server.cjs → host/nextjs/pages.cjs} +44 -55
- package/dist/host/nextjs/pages.cjs.map +1 -0
- package/dist/{next/host/pages-router-server.d.ts → host/nextjs/pages.d.ts} +11 -13
- package/dist/{next/host/pages-router-server.js → host/nextjs/pages.js} +38 -49
- package/dist/host/nextjs/pages.js.map +1 -0
- package/dist/host/proxy/client.cjs +57 -0
- package/dist/host/proxy/client.cjs.map +1 -0
- package/dist/host/proxy/client.d.ts +31 -0
- package/dist/host/proxy/client.js +30 -0
- package/dist/host/proxy/client.js.map +1 -0
- package/dist/{shared/host/proxy.cjs → host/proxy/protected-fetch.cjs} +6 -6
- package/dist/host/proxy/protected-fetch.cjs.map +1 -0
- package/dist/{shared/host/proxy.js → host/proxy/protected-fetch.js} +3 -3
- package/dist/host/proxy/protected-fetch.js.map +1 -0
- package/dist/{next → host}/proxy.cjs +12 -92
- package/dist/host/proxy.cjs.map +1 -0
- package/dist/host/proxy.d.ts +30 -0
- package/dist/{next → host}/proxy.js +11 -88
- package/dist/host/proxy.js.map +1 -0
- package/dist/{react/index.cjs → host/react.cjs} +515 -548
- package/dist/host/react.cjs.map +1 -0
- package/dist/{component-loader-21865da3.d.ts → host/react.d.ts} +141 -99
- package/dist/{react/index.js → host/react.js} +514 -545
- package/dist/host/react.js.map +1 -0
- package/dist/internal/{webpack/shared-modules.cjs → config/webpack/apply-shared-modules.cjs} +12 -15
- package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -0
- package/dist/internal/{webpack/shared-modules.js → config/webpack/apply-shared-modules.js} +9 -12
- package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -0
- package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.cjs +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -0
- package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.js +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -0
- package/dist/internal/{next/host/app-router-client.cjs → host/nextjs/app-client.cjs} +29 -24
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -0
- package/dist/internal/host/nextjs/app-client.d.ts +25 -0
- package/dist/internal/{next/host/app-router-client.js → host/nextjs/app-client.js} +19 -19
- package/dist/internal/host/nextjs/app-client.js.map +1 -0
- package/dist/internal/{next/host/app-router-compat.cjs → host/nextjs/app-compat.cjs} +5 -22
- package/dist/internal/host/nextjs/app-compat.cjs.map +1 -0
- package/dist/internal/{next/host/app-router-compat.d.ts → host/nextjs/app-compat.d.ts} +1 -7
- package/dist/internal/{next/host/app-router-compat.js → host/nextjs/app-compat.js} +2 -18
- package/dist/internal/host/nextjs/app-compat.js.map +1 -0
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -0
- package/dist/internal/host/nextjs/dom-flight.d.ts +39 -0
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -0
- package/dist/internal/host/nextjs/image-impl.cjs +60 -0
- package/dist/internal/host/nextjs/image-impl.cjs.map +1 -0
- package/dist/internal/host/nextjs/image-impl.d.ts +10 -0
- package/dist/internal/host/nextjs/image-impl.js +36 -0
- package/dist/internal/host/nextjs/image-impl.js.map +1 -0
- package/dist/internal/host/nextjs/image-shared.cjs +43 -0
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -0
- package/dist/internal/host/nextjs/image-shared.d.ts +9 -0
- package/dist/internal/host/nextjs/image-shared.js +19 -0
- package/dist/internal/host/nextjs/image-shared.js.map +1 -0
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.cjs +2 -2
- package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -0
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.d.ts +1 -1
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.js +2 -2
- package/dist/internal/host/nextjs/remote-component-links.js.map +1 -0
- package/dist/internal/host/nextjs/skeleton.cjs.map +1 -0
- package/dist/internal/host/nextjs/skeleton.js.map +1 -0
- package/dist/internal/{react → host/react}/context.cjs +3 -3
- package/dist/internal/host/react/context.cjs.map +1 -0
- package/dist/internal/{react → host/react}/context.d.ts +4 -4
- package/dist/internal/{react → host/react}/context.js +2 -2
- package/dist/internal/host/react/context.js.map +1 -0
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.cjs +2 -2
- package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -0
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.d.ts +1 -1
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.js +2 -2
- package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -0
- package/dist/internal/host/server/fetch-headers.cjs.map +1 -0
- package/dist/internal/host/server/fetch-headers.js.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.cjs +6 -6
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.d.ts +6 -1
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.js +9 -9
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.cjs +11 -15
- package/dist/internal/host/server/fetch-with-hooks.cjs.map +1 -0
- package/dist/internal/host/server/fetch-with-hooks.d.ts +21 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.js +11 -15
- package/dist/internal/host/server/fetch-with-hooks.js.map +1 -0
- package/dist/internal/host/server/get-client-or-server-url.cjs.map +1 -0
- package/dist/internal/host/server/get-client-or-server-url.js.map +1 -0
- package/dist/internal/{shared/client → host/server}/get-client-src.cjs +1 -1
- package/dist/internal/host/server/get-client-src.cjs.map +1 -0
- package/dist/internal/{shared/client → host/server}/get-client-src.js +1 -1
- package/dist/internal/host/server/get-client-src.js.map +1 -0
- package/dist/internal/host/server/get-ssr-relative-path-base-url.cjs.map +1 -0
- package/dist/internal/host/server/get-ssr-relative-path-base-url.js.map +1 -0
- package/dist/{next/remote/server.cjs → internal/host/server/types.cjs} +3 -15
- package/dist/internal/host/server/types.cjs.map +1 -0
- package/dist/internal/host/server/types.d.ts +33 -0
- package/dist/internal/host/server/types.js +1 -0
- package/dist/internal/host/server/types.js.map +1 -0
- package/dist/internal/host/shared/asset-descriptors.cjs +17 -0
- package/dist/internal/host/shared/asset-descriptors.cjs.map +1 -0
- package/dist/internal/host/shared/asset-descriptors.d.ts +21 -0
- package/dist/internal/host/shared/asset-descriptors.js +1 -0
- package/dist/internal/host/shared/asset-descriptors.js.map +1 -0
- package/dist/internal/host/shared/config.cjs +17 -0
- package/dist/internal/host/shared/config.cjs.map +1 -0
- package/dist/{host-config-58cdccea.d.ts → internal/host/shared/config.d.ts} +32 -19
- package/dist/internal/host/shared/config.js +1 -0
- package/dist/internal/host/shared/config.js.map +1 -0
- package/dist/internal/host/shared/fetch-interceptors.cjs +17 -0
- package/dist/internal/host/shared/fetch-interceptors.cjs.map +1 -0
- package/dist/{types-2b26a246.d.ts → internal/host/shared/fetch-interceptors.d.ts} +4 -87
- package/dist/internal/host/shared/fetch-interceptors.js +1 -0
- package/dist/internal/host/shared/fetch-interceptors.js.map +1 -0
- package/dist/internal/{shared/client → host/shared}/polyfill.cjs +7 -6
- package/dist/internal/host/shared/polyfill.cjs.map +1 -0
- package/dist/internal/{shared/client → host/shared}/polyfill.d.ts +2 -1
- package/dist/internal/{shared/client → host/shared}/polyfill.js +7 -6
- package/dist/internal/host/shared/polyfill.js.map +1 -0
- package/dist/internal/host/shared/resolved-data.cjs +17 -0
- package/dist/internal/host/shared/resolved-data.cjs.map +1 -0
- package/dist/internal/host/shared/resolved-data.d.ts +48 -0
- package/dist/internal/host/shared/resolved-data.js +1 -0
- package/dist/internal/host/shared/resolved-data.js.map +1 -0
- package/dist/internal/{shared/contract/host-state.cjs → host/shared/state.cjs} +4 -4
- package/dist/internal/host/shared/state.cjs.map +1 -0
- package/dist/internal/{shared/contract/host-state.js → host/shared/state.js} +1 -1
- package/dist/internal/host/shared/state.js.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.cjs.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.js.map +1 -0
- package/dist/internal/{next/remote/render-client.cjs → remote/nextjs/app-client.cjs} +8 -8
- package/dist/internal/remote/nextjs/app-client.cjs.map +1 -0
- package/dist/internal/{next/remote/render-client.js → remote/nextjs/app-client.js} +4 -4
- package/dist/internal/remote/nextjs/app-client.js.map +1 -0
- package/dist/internal/runtime/constants.cjs +50 -0
- package/dist/internal/runtime/constants.cjs.map +1 -0
- package/dist/internal/runtime/constants.d.ts +10 -0
- package/dist/internal/runtime/constants.js +20 -0
- package/dist/internal/runtime/constants.js.map +1 -0
- package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs.map +1 -1
- package/dist/internal/{shared/client → runtime/html}/apply-origin.d.ts +1 -1
- package/dist/internal/{shared/client → runtime/html}/apply-origin.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +140 -0
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -0
- package/dist/internal/runtime/html/parse-remote-html.d.ts +88 -0
- package/dist/internal/runtime/html/parse-remote-html.js +110 -0
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -0
- package/dist/internal/runtime/html/set-attributes-from-props.cjs +68 -0
- package/dist/internal/runtime/html/set-attributes-from-props.cjs.map +1 -0
- package/dist/internal/runtime/html/set-attributes-from-props.d.ts +3 -0
- package/dist/internal/runtime/html/set-attributes-from-props.js +44 -0
- package/dist/internal/runtime/html/set-attributes-from-props.js.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.cjs +184 -0
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.d.ts +31 -0
- package/dist/internal/runtime/loaders/component-loader.js +150 -0
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -0
- package/dist/internal/runtime/loaders/script-loader.cjs +69 -0
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/script-loader.d.ts +10 -0
- package/dist/internal/runtime/loaders/script-loader.js +48 -0
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -0
- package/dist/internal/runtime/loaders/static-loader.cjs +177 -0
- package/dist/internal/runtime/loaders/static-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/static-loader.d.ts +10 -0
- package/dist/internal/runtime/loaders/static-loader.js +153 -0
- package/dist/internal/runtime/loaders/static-loader.js.map +1 -0
- package/dist/internal/runtime/metadata.cjs +17 -0
- package/dist/internal/runtime/metadata.cjs.map +1 -0
- package/dist/internal/runtime/metadata.d.ts +16 -0
- package/dist/internal/runtime/metadata.js +1 -0
- package/dist/internal/runtime/metadata.js.map +1 -0
- package/dist/internal/runtime/rsc.cjs +92 -0
- package/dist/internal/runtime/rsc.cjs.map +1 -0
- package/dist/internal/runtime/rsc.d.ts +8 -0
- package/dist/internal/runtime/rsc.js +68 -0
- package/dist/internal/runtime/rsc.js.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +244 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.d.ts +11 -0
- package/dist/internal/runtime/turbopack/chunk-loader.js +227 -0
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -0
- package/dist/internal/runtime/turbopack/module.cjs +257 -0
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/module.d.ts +61 -0
- package/dist/internal/runtime/turbopack/module.js +233 -0
- package/dist/internal/runtime/turbopack/module.js.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.cjs +44 -0
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.d.ts +109 -0
- package/dist/internal/runtime/turbopack/patterns.js +15 -0
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs +152 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +17 -0
- package/dist/internal/runtime/turbopack/shared-modules.js +133 -0
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs +137 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +20 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.js +107 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -0
- package/dist/internal/runtime/types.cjs +17 -0
- package/dist/internal/runtime/types.cjs.map +1 -0
- package/dist/internal/runtime/types.d.ts +40 -0
- package/dist/internal/runtime/types.js +1 -0
- package/dist/internal/runtime/types.js.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.cjs +2 -2
- package/dist/internal/runtime/url/default-resolve-client-url.cjs.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.d.ts +1 -1
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.js +1 -1
- package/dist/internal/runtime/url/default-resolve-client-url.js.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.cjs +1 -1
- package/dist/internal/runtime/url/protected-rc-fallback.cjs.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.js +1 -1
- package/dist/internal/runtime/url/protected-rc-fallback.js.map +1 -0
- package/dist/internal/{shared/client/proxy-through-host.cjs → runtime/url/resolve-client-url.cjs} +4 -24
- package/dist/internal/runtime/url/resolve-client-url.cjs.map +1 -0
- package/dist/internal/{shared/client/proxy-through-host.d.ts → runtime/url/resolve-client-url.d.ts} +1 -25
- package/dist/internal/runtime/url/resolve-client-url.js +21 -0
- package/dist/internal/runtime/url/resolve-client-url.js.map +1 -0
- package/dist/internal/utils/abort.cjs.map +1 -0
- package/dist/internal/utils/abort.js.map +1 -0
- package/dist/internal/{shared → utils}/constants.cjs +3 -0
- package/dist/internal/utils/constants.cjs.map +1 -0
- package/dist/internal/utils/constants.d.ts +5 -0
- package/dist/internal/{shared → utils}/constants.js +2 -0
- package/dist/internal/utils/constants.js.map +1 -0
- package/dist/internal/{shared → utils}/error.cjs +4 -4
- package/dist/internal/utils/error.cjs.map +1 -0
- package/dist/internal/{shared → utils}/error.js +4 -4
- package/dist/internal/utils/error.js.map +1 -0
- package/dist/internal/{shared/utils → utils}/logger.cjs +3 -3
- package/dist/internal/utils/logger.cjs.map +1 -0
- package/dist/internal/{shared/utils → utils}/logger.d.ts +2 -2
- package/dist/internal/{shared/utils → utils}/logger.js +3 -3
- package/dist/internal/utils/logger.js.map +1 -0
- package/dist/internal/utils.cjs.map +1 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/{shared/host → remote/defaults}/app.cjs +2 -6
- package/dist/remote/defaults/app.cjs.map +1 -0
- package/dist/remote/defaults/app.js +8 -0
- package/dist/remote/defaults/app.js.map +1 -0
- package/dist/{shared/host → remote/defaults}/pages.cjs +2 -6
- package/dist/remote/defaults/pages.cjs.map +1 -0
- package/dist/remote/defaults/pages.js +8 -0
- package/dist/remote/defaults/pages.js.map +1 -0
- package/dist/{shared/remote → remote/defaults}/wrapper.cjs +12 -10
- package/dist/remote/defaults/wrapper.cjs.map +1 -0
- package/dist/remote/defaults/wrapper.js +27 -0
- package/dist/remote/defaults/wrapper.js.map +1 -0
- package/dist/{html/remote.cjs → remote/html.cjs} +16 -16
- package/dist/remote/html.cjs.map +1 -0
- package/dist/{html/remote.js → remote/html.js} +16 -16
- package/dist/remote/html.js.map +1 -0
- package/dist/{shared/remote/proxy.cjs → remote/middleware.cjs} +37 -12
- package/dist/remote/middleware.cjs.map +1 -0
- package/dist/remote/middleware.d.ts +27 -0
- package/dist/{shared/remote/proxy.js → remote/middleware.js} +32 -5
- package/dist/remote/middleware.js.map +1 -0
- package/dist/{internal/next/remote/render-server.cjs → remote/nextjs/app.cjs} +14 -16
- package/dist/remote/nextjs/app.cjs.map +1 -0
- package/dist/{internal/next/remote/render-server.d.ts → remote/nextjs/app.d.ts} +12 -13
- package/dist/{internal/next/remote/render-server.js → remote/nextjs/app.js} +9 -11
- package/dist/remote/nextjs/app.js.map +1 -0
- package/dist/{next/remote/pages-router.cjs → remote/nextjs/pages.cjs} +8 -8
- package/dist/remote/nextjs/pages.cjs.map +1 -0
- package/dist/{next/remote/pages-router.d.ts → remote/nextjs/pages.d.ts} +8 -8
- package/dist/{next/remote/pages-router.js → remote/nextjs/pages.js} +4 -4
- package/dist/remote/nextjs/pages.js.map +1 -0
- package/dist/server-handoff-8c89b856.d.ts +46 -0
- package/package.json +126 -157
- package/dist/html/host.cjs.map +0 -1
- package/dist/html/host.js.map +0 -1
- package/dist/html/remote.cjs.map +0 -1
- package/dist/html/remote.js.map +0 -1
- package/dist/internal/next/host/app-router-client.cjs.map +0 -1
- package/dist/internal/next/host/app-router-client.d.ts +0 -79
- package/dist/internal/next/host/app-router-client.js.map +0 -1
- package/dist/internal/next/host/app-router-compat.cjs.map +0 -1
- package/dist/internal/next/host/app-router-compat.js.map +0 -1
- package/dist/internal/next/host/remote-component-links.cjs.map +0 -1
- package/dist/internal/next/host/remote-component-links.js.map +0 -1
- package/dist/internal/next/remote/render-client.cjs.map +0 -1
- package/dist/internal/next/remote/render-client.js.map +0 -1
- package/dist/internal/next/remote/render-server.cjs.map +0 -1
- package/dist/internal/next/remote/render-server.js.map +0 -1
- package/dist/internal/react/context.cjs.map +0 -1
- package/dist/internal/react/context.js.map +0 -1
- package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +0 -1
- package/dist/internal/react/hooks/use-resolve-client-url.js.map +0 -1
- package/dist/internal/shared/client/default-resolve-client-url.cjs.map +0 -1
- package/dist/internal/shared/client/default-resolve-client-url.js.map +0 -1
- package/dist/internal/shared/client/get-client-src.cjs.map +0 -1
- package/dist/internal/shared/client/get-client-src.js.map +0 -1
- package/dist/internal/shared/client/polyfill.cjs.map +0 -1
- package/dist/internal/shared/client/polyfill.js.map +0 -1
- package/dist/internal/shared/client/protected-rc-fallback.cjs.map +0 -1
- package/dist/internal/shared/client/protected-rc-fallback.js.map +0 -1
- package/dist/internal/shared/client/proxy-through-host.cjs.map +0 -1
- package/dist/internal/shared/client/proxy-through-host.js +0 -40
- package/dist/internal/shared/client/proxy-through-host.js.map +0 -1
- package/dist/internal/shared/client/remote-component.cjs +0 -1436
- package/dist/internal/shared/client/remote-component.cjs.map +0 -1
- package/dist/internal/shared/client/remote-component.d.ts +0 -62
- package/dist/internal/shared/client/remote-component.js +0 -1385
- package/dist/internal/shared/client/remote-component.js.map +0 -1
- package/dist/internal/shared/constants.cjs.map +0 -1
- package/dist/internal/shared/constants.d.ts +0 -4
- package/dist/internal/shared/constants.js.map +0 -1
- package/dist/internal/shared/contract/host-state.cjs.map +0 -1
- package/dist/internal/shared/contract/host-state.js.map +0 -1
- package/dist/internal/shared/contract/resolve-name-from-src.cjs.map +0 -1
- package/dist/internal/shared/contract/resolve-name-from-src.js.map +0 -1
- package/dist/internal/shared/error.cjs.map +0 -1
- package/dist/internal/shared/error.js.map +0 -1
- package/dist/internal/shared/ssr/dom-flight.cjs.map +0 -1
- package/dist/internal/shared/ssr/dom-flight.d.ts +0 -2
- package/dist/internal/shared/ssr/dom-flight.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-headers.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-headers.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +0 -56
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +0 -1
- package/dist/internal/shared/ssr/get-client-or-server-url.cjs.map +0 -1
- package/dist/internal/shared/ssr/get-client-or-server-url.js.map +0 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +0 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +0 -1
- package/dist/internal/shared/ssr/skeleton.cjs.map +0 -1
- package/dist/internal/shared/ssr/skeleton.js.map +0 -1
- package/dist/internal/shared/utils/abort.cjs.map +0 -1
- package/dist/internal/shared/utils/abort.js.map +0 -1
- package/dist/internal/shared/utils/logger.cjs.map +0 -1
- package/dist/internal/shared/utils/logger.js.map +0 -1
- package/dist/internal/shared/utils.cjs.map +0 -1
- package/dist/internal/shared/utils.js.map +0 -1
- package/dist/internal/webpack/next-client-pages-loader.cjs.map +0 -1
- package/dist/internal/webpack/next-client-pages-loader.js.map +0 -1
- package/dist/internal/webpack/shared-modules.cjs.map +0 -1
- package/dist/internal/webpack/shared-modules.js.map +0 -1
- package/dist/next/config.cjs.map +0 -1
- package/dist/next/config.js.map +0 -1
- package/dist/next/host/app-router-server.cjs.map +0 -1
- package/dist/next/host/app-router-server.d.ts +0 -30
- package/dist/next/host/app-router-server.js.map +0 -1
- package/dist/next/host/client/index.cjs.map +0 -1
- package/dist/next/host/client/index.d.ts +0 -19
- package/dist/next/host/client/index.js.map +0 -1
- package/dist/next/host/pages-router-client.cjs.map +0 -1
- package/dist/next/host/pages-router-client.d.ts +0 -33
- package/dist/next/host/pages-router-client.js.map +0 -1
- package/dist/next/host/pages-router-server.cjs.map +0 -1
- package/dist/next/host/pages-router-server.js.map +0 -1
- package/dist/next/index.cjs +0 -53
- package/dist/next/index.cjs.map +0 -1
- package/dist/next/index.d.ts +0 -30
- package/dist/next/index.js +0 -19
- package/dist/next/index.js.map +0 -1
- package/dist/next/proxy.cjs.map +0 -1
- package/dist/next/proxy.d.ts +0 -56
- package/dist/next/proxy.js.map +0 -1
- package/dist/next/remote/pages-router.cjs.map +0 -1
- package/dist/next/remote/pages-router.js.map +0 -1
- package/dist/next/remote/server.cjs.map +0 -1
- package/dist/next/remote/server.d.ts +0 -5
- package/dist/next/remote/server.js +0 -5
- package/dist/next/remote/server.js.map +0 -1
- package/dist/proxy-through-host-a676a522.d.ts +0 -52
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -86
- package/dist/react/index.js.map +0 -1
- package/dist/shared/host/app.cjs.map +0 -1
- package/dist/shared/host/app.js +0 -12
- package/dist/shared/host/app.js.map +0 -1
- package/dist/shared/host/pages.cjs.map +0 -1
- package/dist/shared/host/pages.js +0 -12
- package/dist/shared/host/pages.js.map +0 -1
- package/dist/shared/host/proxy.cjs.map +0 -1
- package/dist/shared/host/proxy.js.map +0 -1
- package/dist/shared/remote/app.cjs.map +0 -1
- package/dist/shared/remote/app.js +0 -8
- package/dist/shared/remote/app.js.map +0 -1
- package/dist/shared/remote/pages.cjs.map +0 -1
- package/dist/shared/remote/pages.js +0 -8
- package/dist/shared/remote/pages.js.map +0 -1
- package/dist/shared/remote/proxy.cjs.map +0 -1
- package/dist/shared/remote/proxy.d.ts +0 -44
- package/dist/shared/remote/proxy.js.map +0 -1
- package/dist/shared/remote/wrapper.cjs.map +0 -1
- package/dist/shared/remote/wrapper.js +0 -25
- package/dist/shared/remote/wrapper.js.map +0 -1
- package/dist/webpack.cjs.map +0 -1
- package/dist/webpack.js.map +0 -1
- /package/dist/{webpack.d.ts → config/webpack.d.ts} +0 -0
- /package/dist/{shared/host → host/defaults}/app.d.ts +0 -0
- /package/dist/{shared/host → host/defaults}/pages.d.ts +0 -0
- /package/dist/{shared/host/proxy.d.ts → host/proxy/protected-fetch.d.ts} +0 -0
- /package/dist/internal/{webpack/shared-modules.d.ts → config/webpack/apply-shared-modules.d.ts} +0 -0
- /package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.js +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.js +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.js +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.js +0 -0
- /package/dist/internal/{shared/client → host/server}/get-client-src.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.js +0 -0
- /package/dist/internal/{shared/contract/host-state.d.ts → host/shared/state.d.ts} +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.cjs +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.d.ts +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.js +0 -0
- /package/dist/internal/{next/remote/render-client.d.ts → remote/nextjs/app-client.d.ts} +0 -0
- /package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs +0 -0
- /package/dist/internal/{shared/client → runtime/html}/apply-origin.js +0 -0
- /package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.d.ts +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.cjs +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.d.ts +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.js +0 -0
- /package/dist/internal/{shared → utils}/error.d.ts +0 -0
- /package/dist/internal/{shared/utils.cjs → utils.cjs} +0 -0
- /package/dist/internal/{shared/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/internal/{shared/utils.js → utils.js} +0 -0
- /package/dist/{shared/remote → remote/defaults}/app.d.ts +0 -0
- /package/dist/{shared/remote → remote/defaults}/pages.d.ts +0 -0
- /package/dist/{shared/remote → remote/defaults}/wrapper.d.ts +0 -0
- /package/dist/{html/remote.d.ts → remote/html.d.ts} +0 -0
|
@@ -27,87 +27,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/react/index.tsx
|
|
30
|
+
// src/host/react/index.tsx
|
|
31
31
|
var react_exports = {};
|
|
32
32
|
__export(react_exports, {
|
|
33
|
-
|
|
34
|
-
RemoteComponentsProvider: () => import_context2.RemoteComponentsProvider,
|
|
35
|
-
proxyClientRequestsThroughHost: () => proxyClientRequestsThroughHost
|
|
33
|
+
ConsumeRemoteComponent: () => ConsumeRemoteComponent
|
|
36
34
|
});
|
|
37
35
|
module.exports = __toCommonJS(react_exports);
|
|
38
36
|
var import_react3 = require("react");
|
|
39
37
|
var import_react_dom = require("react-dom");
|
|
40
38
|
|
|
41
|
-
// src/
|
|
42
|
-
var tagNames = [
|
|
43
|
-
"img",
|
|
44
|
-
"source",
|
|
45
|
-
"video",
|
|
46
|
-
"audio",
|
|
47
|
-
"track",
|
|
48
|
-
"iframe",
|
|
49
|
-
"embed",
|
|
50
|
-
"script",
|
|
51
|
-
"link"
|
|
52
|
-
];
|
|
53
|
-
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
54
|
-
if (url.origin !== location.origin) {
|
|
55
|
-
const nodes = doc.querySelectorAll(
|
|
56
|
-
tagNames.map(
|
|
57
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
58
|
-
).join(",")
|
|
59
|
-
);
|
|
60
|
-
nodes.forEach((node) => {
|
|
61
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
62
|
-
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
63
|
-
const isScript = node.tagName.toLowerCase() === "script";
|
|
64
|
-
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
65
|
-
}
|
|
66
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
67
|
-
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
68
|
-
node.setAttribute(
|
|
69
|
-
"href",
|
|
70
|
-
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
if (node.hasAttribute("srcset")) {
|
|
74
|
-
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
75
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
76
|
-
if (!urlPart)
|
|
77
|
-
return entry;
|
|
78
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
79
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
80
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
81
|
-
}).join(", ");
|
|
82
|
-
if (srcSet) {
|
|
83
|
-
node.setAttribute("srcset", srcSet);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (node.hasAttribute("imagesrcset")) {
|
|
87
|
-
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
88
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
89
|
-
if (!urlPart)
|
|
90
|
-
return entry;
|
|
91
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
92
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
93
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
94
|
-
}).join(", ");
|
|
95
|
-
if (srcSet) {
|
|
96
|
-
node.setAttribute("imagesrcset", srcSet);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/shared/constants.ts
|
|
39
|
+
// src/utils/constants.ts
|
|
104
40
|
var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
105
41
|
var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
106
42
|
|
|
107
|
-
// src/
|
|
108
|
-
function generateProtectedRcFallbackSrc(url) {
|
|
109
|
-
return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
|
|
110
|
-
}
|
|
43
|
+
// src/runtime/url/protected-rc-fallback.ts
|
|
111
44
|
function isProxiedUrl(url) {
|
|
112
45
|
try {
|
|
113
46
|
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
@@ -116,7 +49,7 @@ function isProxiedUrl(url) {
|
|
|
116
49
|
}
|
|
117
50
|
}
|
|
118
51
|
|
|
119
|
-
// src/
|
|
52
|
+
// src/utils/abort.ts
|
|
120
53
|
function isAbortError(error) {
|
|
121
54
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
122
55
|
return true;
|
|
@@ -128,7 +61,7 @@ function isAbortError(error) {
|
|
|
128
61
|
return false;
|
|
129
62
|
}
|
|
130
63
|
|
|
131
|
-
// src/
|
|
64
|
+
// src/utils/error.ts
|
|
132
65
|
var RemoteComponentsError = class extends Error {
|
|
133
66
|
code = "REMOTE_COMPONENTS_ERROR";
|
|
134
67
|
constructor(message, options) {
|
|
@@ -194,7 +127,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
|
194
127
|
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
195
128
|
|
|
196
129
|
Proxying requires two pieces:
|
|
197
|
-
1. resolveClientUrl={
|
|
130
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
198
131
|
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
199
132
|
|
|
200
133
|
Docs: ${CORS_DOCS_URL}`
|
|
@@ -211,123 +144,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
211
144
|
);
|
|
212
145
|
}
|
|
213
146
|
|
|
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
|
|
147
|
+
// src/utils/logger.ts
|
|
331
148
|
var PREFIX = "remote-components";
|
|
332
149
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
333
150
|
function logDebug(location2, message) {
|
|
@@ -353,13 +170,68 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
353
170
|
}
|
|
354
171
|
logWarn(
|
|
355
172
|
logLocation,
|
|
356
|
-
`Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure
|
|
173
|
+
`Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure withRemoteComponentsHostProxy middleware is configured in your host and that the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
357
174
|
);
|
|
358
175
|
} catch {
|
|
359
176
|
}
|
|
360
177
|
}
|
|
361
178
|
|
|
362
|
-
// src/
|
|
179
|
+
// src/host/server/fetch-headers.ts
|
|
180
|
+
function remoteFetchHeaders() {
|
|
181
|
+
return {
|
|
182
|
+
/**
|
|
183
|
+
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
184
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
185
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
186
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
187
|
+
*/
|
|
188
|
+
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
189
|
+
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
190
|
+
} : {},
|
|
191
|
+
Accept: "text/html"
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/host/server/fetch-with-hooks.ts
|
|
196
|
+
async function fetchWithWarning(url, init) {
|
|
197
|
+
try {
|
|
198
|
+
return await fetch(url, init);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
205
|
+
const {
|
|
206
|
+
onRequest,
|
|
207
|
+
onResponse,
|
|
208
|
+
abortController = new AbortController()
|
|
209
|
+
} = options;
|
|
210
|
+
const signal = abortController.signal;
|
|
211
|
+
const hookOptions = {
|
|
212
|
+
signal,
|
|
213
|
+
abort: (reason) => abortController.abort(reason)
|
|
214
|
+
};
|
|
215
|
+
const init = {
|
|
216
|
+
method: "GET",
|
|
217
|
+
headers: remoteFetchHeaders(),
|
|
218
|
+
signal,
|
|
219
|
+
...additionalInit
|
|
220
|
+
};
|
|
221
|
+
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
222
|
+
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/host/server/get-client-or-server-url.ts
|
|
226
|
+
function getClientOrServerUrl(src, serverFallback) {
|
|
227
|
+
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
228
|
+
if (!src) {
|
|
229
|
+
return new URL(fallback);
|
|
230
|
+
}
|
|
231
|
+
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/host/shared/polyfill.tsx
|
|
363
235
|
var import_jsx_runtime = (
|
|
364
236
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
365
237
|
require("react/jsx-runtime")
|
|
@@ -382,7 +254,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
382
254
|
const propSrc = src;
|
|
383
255
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
384
256
|
}
|
|
385
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
257
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
386
258
|
fill: _fill,
|
|
387
259
|
loader: _loader,
|
|
388
260
|
quality: _quality,
|
|
@@ -399,18 +271,19 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
399
271
|
bundle,
|
|
400
272
|
typeof src === "string" ? src : src.src
|
|
401
273
|
);
|
|
274
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
402
275
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
403
276
|
"img",
|
|
404
277
|
{
|
|
405
278
|
decoding: "async",
|
|
406
279
|
style: { color: "transparent" },
|
|
407
280
|
...props,
|
|
408
|
-
src:
|
|
281
|
+
src: proxiedSrc,
|
|
409
282
|
suppressHydrationWarning: true
|
|
410
283
|
}
|
|
411
284
|
);
|
|
412
285
|
};
|
|
413
|
-
function sharedPolyfills(shared) {
|
|
286
|
+
function sharedPolyfills(shared, resolveClientUrl) {
|
|
414
287
|
const self = globalThis;
|
|
415
288
|
const polyfill = {
|
|
416
289
|
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
@@ -501,11 +374,11 @@ function sharedPolyfills(shared) {
|
|
|
501
374
|
__esModule: true
|
|
502
375
|
})),
|
|
503
376
|
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
504
|
-
Image: imageImpl(bundle),
|
|
377
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
505
378
|
__esModule: true
|
|
506
379
|
})),
|
|
507
380
|
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
508
|
-
default: imageImpl(bundle),
|
|
381
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
509
382
|
getImageProps: (_imgProps) => {
|
|
510
383
|
throw new Error(
|
|
511
384
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -555,32 +428,337 @@ function sharedPolyfills(shared) {
|
|
|
555
428
|
return polyfill;
|
|
556
429
|
}
|
|
557
430
|
|
|
558
|
-
// src/shared/
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
431
|
+
// src/host/shared/state.ts
|
|
432
|
+
function createHostState() {
|
|
433
|
+
return {
|
|
434
|
+
stage: "idle",
|
|
435
|
+
prevSrc: void 0,
|
|
436
|
+
prevUrl: void 0,
|
|
437
|
+
prevName: void 0,
|
|
438
|
+
prevIsRemoteComponent: false,
|
|
439
|
+
abortController: void 0
|
|
440
|
+
};
|
|
441
|
+
}
|
|
564
442
|
|
|
565
|
-
// src/
|
|
566
|
-
function
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
570
|
-
);
|
|
571
|
-
if (nextCssOriginal) {
|
|
572
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
443
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
444
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
445
|
+
if (!src) {
|
|
446
|
+
return defaultName;
|
|
573
447
|
}
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
448
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
449
|
+
const hashIndex = hash.indexOf("#");
|
|
450
|
+
if (hashIndex < 0) {
|
|
451
|
+
return defaultName;
|
|
452
|
+
}
|
|
453
|
+
const name = hash.slice(hashIndex + 1);
|
|
454
|
+
return name || defaultName;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// src/utils/index.ts
|
|
458
|
+
function escapeString(str) {
|
|
459
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
460
|
+
}
|
|
461
|
+
var attrToProp = {
|
|
462
|
+
fetchpriority: "fetchPriority",
|
|
463
|
+
crossorigin: "crossOrigin",
|
|
464
|
+
imagesrcset: "imageSrcSet",
|
|
465
|
+
imagesizes: "imageSizes",
|
|
466
|
+
srcset: "srcSet"
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
// src/runtime/constants.ts
|
|
470
|
+
var DEFAULT_ROUTE = "/";
|
|
471
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
472
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
473
|
+
var RUNTIME_SCRIPT = "script";
|
|
474
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
475
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
476
|
+
function getBundleKey(bundle) {
|
|
477
|
+
return escapeString(bundle);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// src/runtime/html/apply-origin.ts
|
|
481
|
+
var tagNames = [
|
|
482
|
+
"img",
|
|
483
|
+
"source",
|
|
484
|
+
"video",
|
|
485
|
+
"audio",
|
|
486
|
+
"track",
|
|
487
|
+
"iframe",
|
|
488
|
+
"embed",
|
|
489
|
+
"script",
|
|
490
|
+
"link"
|
|
491
|
+
];
|
|
492
|
+
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
493
|
+
if (url.origin !== location.origin) {
|
|
494
|
+
const nodes = doc.querySelectorAll(
|
|
495
|
+
tagNames.map(
|
|
496
|
+
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
497
|
+
).join(",")
|
|
498
|
+
);
|
|
499
|
+
nodes.forEach((node) => {
|
|
500
|
+
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
501
|
+
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
502
|
+
const isScript = node.tagName.toLowerCase() === "script";
|
|
503
|
+
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
504
|
+
}
|
|
505
|
+
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
506
|
+
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
507
|
+
node.setAttribute(
|
|
508
|
+
"href",
|
|
509
|
+
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
if (node.hasAttribute("srcset")) {
|
|
513
|
+
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
514
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
515
|
+
if (!urlPart)
|
|
516
|
+
return entry;
|
|
517
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
518
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
519
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
520
|
+
}).join(", ");
|
|
521
|
+
if (srcSet) {
|
|
522
|
+
node.setAttribute("srcset", srcSet);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (node.hasAttribute("imagesrcset")) {
|
|
526
|
+
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
527
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
528
|
+
if (!urlPart)
|
|
529
|
+
return entry;
|
|
530
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
531
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
532
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
533
|
+
}).join(", ");
|
|
534
|
+
if (srcSet) {
|
|
535
|
+
node.setAttribute("imagesrcset", srcSet);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// src/runtime/html/parse-remote-html.ts
|
|
543
|
+
function validateSingleComponent(doc, name, url) {
|
|
544
|
+
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}"]`)) {
|
|
545
|
+
throw multipleRemoteComponentsError(url);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function findComponentElement(doc, name) {
|
|
549
|
+
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])");
|
|
550
|
+
}
|
|
551
|
+
function parseNextData(doc) {
|
|
552
|
+
return JSON.parse(
|
|
553
|
+
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
function resolveComponentName(component, nextData, fallbackName) {
|
|
557
|
+
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
558
|
+
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
559
|
+
return { name, isRemoteComponent };
|
|
560
|
+
}
|
|
561
|
+
function extractComponentMetadata(component, nextData, name, url) {
|
|
562
|
+
return {
|
|
563
|
+
name,
|
|
564
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
565
|
+
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
566
|
+
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function extractRemoteShared(doc, name, nextData) {
|
|
570
|
+
const remoteSharedEl = doc.querySelector(
|
|
571
|
+
`#${name}_shared[data-remote-components-shared]`
|
|
572
|
+
);
|
|
573
|
+
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
574
|
+
remoteSharedEl?.remove();
|
|
575
|
+
return remoteShared;
|
|
576
|
+
}
|
|
577
|
+
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
578
|
+
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
579
|
+
throw new RemoteComponentsError(
|
|
580
|
+
`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>?`
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
function extractLinks(doc, component) {
|
|
585
|
+
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
586
|
+
(link) => !component.contains(link)
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
function extractScripts(doc, component, isRemoteComponent) {
|
|
590
|
+
return Array.from(
|
|
591
|
+
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
592
|
+
"script[src],script[data-src]"
|
|
593
|
+
)
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
function parseRemoteComponentDocument(doc, name, url) {
|
|
597
|
+
validateSingleComponent(doc, name, url.href);
|
|
598
|
+
const component = findComponentElement(doc, name);
|
|
599
|
+
const nextData = parseNextData(doc);
|
|
600
|
+
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
601
|
+
component,
|
|
602
|
+
nextData,
|
|
603
|
+
name
|
|
604
|
+
);
|
|
605
|
+
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
606
|
+
const metadata = extractComponentMetadata(
|
|
607
|
+
component,
|
|
608
|
+
nextData,
|
|
609
|
+
resolvedName,
|
|
610
|
+
url
|
|
611
|
+
);
|
|
612
|
+
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
613
|
+
validateComponentFound(
|
|
614
|
+
component,
|
|
615
|
+
rsc,
|
|
616
|
+
nextData,
|
|
617
|
+
isRemoteComponent,
|
|
618
|
+
url.href,
|
|
619
|
+
resolvedName
|
|
620
|
+
);
|
|
621
|
+
const links = extractLinks(doc, component);
|
|
622
|
+
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
623
|
+
return {
|
|
624
|
+
component,
|
|
625
|
+
name: resolvedName,
|
|
626
|
+
isRemoteComponent,
|
|
627
|
+
metadata,
|
|
628
|
+
nextData,
|
|
629
|
+
rsc,
|
|
630
|
+
remoteShared,
|
|
631
|
+
links,
|
|
632
|
+
scripts
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// src/runtime/html/set-attributes-from-props.ts
|
|
637
|
+
var DOMAttributeNames = {
|
|
638
|
+
acceptCharset: "accept-charset",
|
|
639
|
+
className: "class",
|
|
640
|
+
htmlFor: "for",
|
|
641
|
+
httpEquiv: "http-equiv",
|
|
642
|
+
noModule: "noModule"
|
|
643
|
+
};
|
|
644
|
+
var ignoreProps = [
|
|
645
|
+
"onLoad",
|
|
646
|
+
"onReady",
|
|
647
|
+
"dangerouslySetInnerHTML",
|
|
648
|
+
"children",
|
|
649
|
+
"onError",
|
|
650
|
+
"strategy",
|
|
651
|
+
"stylesheets"
|
|
652
|
+
];
|
|
653
|
+
function isBooleanScriptAttribute(attr) {
|
|
654
|
+
return ["async", "defer", "noModule"].includes(attr);
|
|
655
|
+
}
|
|
656
|
+
function setAttributesFromProps(el, props) {
|
|
657
|
+
for (const [p, value] of Object.entries(props)) {
|
|
658
|
+
if (!Object.hasOwn(props, p))
|
|
659
|
+
continue;
|
|
660
|
+
if (ignoreProps.includes(p))
|
|
661
|
+
continue;
|
|
662
|
+
if (value === void 0) {
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
666
|
+
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
667
|
+
el[attr] = Boolean(value);
|
|
668
|
+
} else {
|
|
669
|
+
el.setAttribute(attr, String(value));
|
|
670
|
+
}
|
|
671
|
+
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
672
|
+
el.setAttribute(attr, "");
|
|
673
|
+
el.removeAttribute(attr);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// src/runtime/loaders/component-loader.ts
|
|
679
|
+
var React = __toESM(require("react"), 1);
|
|
680
|
+
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
681
|
+
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
682
|
+
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
683
|
+
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
684
|
+
|
|
685
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
686
|
+
function applySharedModules(bundle, resolve) {
|
|
687
|
+
logDebug(
|
|
688
|
+
"SharedModules",
|
|
689
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
690
|
+
);
|
|
691
|
+
logDebug(
|
|
692
|
+
"SharedModules",
|
|
693
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
694
|
+
);
|
|
695
|
+
const self = globalThis;
|
|
696
|
+
if (self.__remote_webpack_require__?.[bundle]) {
|
|
697
|
+
const modulePaths = Object.keys(
|
|
698
|
+
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
699
|
+
);
|
|
700
|
+
logDebug(
|
|
701
|
+
"SharedModules",
|
|
702
|
+
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
703
|
+
);
|
|
704
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
705
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
706
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
707
|
+
if (ids.length === 0) {
|
|
708
|
+
logDebug(
|
|
709
|
+
"SharedModules",
|
|
710
|
+
`No matching module path found for shared module "${key}"`
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
for (const id of ids) {
|
|
714
|
+
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
715
|
+
if (webpackBundle.m) {
|
|
716
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
717
|
+
if (resolvedId !== id) {
|
|
718
|
+
logDebug(
|
|
719
|
+
"SharedModules",
|
|
720
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
webpackBundle.m[resolvedId] = (module2) => {
|
|
724
|
+
module2.exports = value;
|
|
725
|
+
};
|
|
726
|
+
} else {
|
|
727
|
+
logWarn(
|
|
728
|
+
"SharedModules",
|
|
729
|
+
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
} else {
|
|
735
|
+
logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
|
|
736
|
+
logDebug(
|
|
737
|
+
"SharedModules",
|
|
738
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
744
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
745
|
+
const self = globalThis;
|
|
746
|
+
const nextCssOriginal = document.querySelector(
|
|
747
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
748
|
+
);
|
|
749
|
+
if (nextCssOriginal) {
|
|
750
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
751
|
+
}
|
|
752
|
+
const nextCss = document.createElement("noscript");
|
|
753
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
754
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
755
|
+
nextCss.setAttribute("data-route", route);
|
|
756
|
+
const nextCssEnd = document.createElement("noscript");
|
|
757
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
758
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
759
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
760
|
+
document.head.appendChild(nextCssEnd);
|
|
761
|
+
document.head.appendChild(nextCss);
|
|
584
762
|
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
585
763
|
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
586
764
|
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
@@ -646,96 +824,35 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
646
824
|
let node = nextCss.previousSibling;
|
|
647
825
|
while (node && node !== nextCssEnd) {
|
|
648
826
|
elements.push(node);
|
|
649
|
-
node.remove();
|
|
650
|
-
node = nextCss.previousSibling;
|
|
651
|
-
}
|
|
652
|
-
self.__remote_next_css__[bundle] = elements;
|
|
653
|
-
}
|
|
654
|
-
if (styleContainer) {
|
|
655
|
-
const elements = self.__remote_next_css__[bundle];
|
|
656
|
-
elements.forEach((el) => {
|
|
657
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
658
|
-
});
|
|
659
|
-
} else {
|
|
660
|
-
const elements = self.__remote_next_css__[bundle];
|
|
661
|
-
elements.forEach((el) => {
|
|
662
|
-
document.head.appendChild(el);
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
delete self.__NEXT_P;
|
|
666
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
667
|
-
if (nextCssOriginal) {
|
|
668
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
669
|
-
}
|
|
670
|
-
nextCss.remove();
|
|
671
|
-
nextCssEnd.remove();
|
|
672
|
-
return { Component, App };
|
|
673
|
-
}
|
|
674
|
-
return { Component: null, App: null };
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// src/shared/webpack/shared-modules.ts
|
|
678
|
-
function applySharedModules(bundle, resolve) {
|
|
679
|
-
logDebug(
|
|
680
|
-
"SharedModules",
|
|
681
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
682
|
-
);
|
|
683
|
-
logDebug(
|
|
684
|
-
"SharedModules",
|
|
685
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
686
|
-
);
|
|
687
|
-
const self = globalThis;
|
|
688
|
-
if (self.__remote_webpack_require__?.[bundle]) {
|
|
689
|
-
const modulePaths = Object.keys(
|
|
690
|
-
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
691
|
-
);
|
|
692
|
-
logDebug(
|
|
693
|
-
"SharedModules",
|
|
694
|
-
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
695
|
-
);
|
|
696
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
697
|
-
let ids = modulePaths.filter((p) => p === key);
|
|
698
|
-
if (ids.length === 0) {
|
|
699
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
700
|
-
}
|
|
701
|
-
if (ids.length === 0) {
|
|
702
|
-
logDebug(
|
|
703
|
-
"SharedModules",
|
|
704
|
-
`No matching module path found for shared module "${key}"`
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
for (let id of ids) {
|
|
708
|
-
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
709
|
-
if (webpackBundle.m) {
|
|
710
|
-
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
711
|
-
const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
712
|
-
logDebug(
|
|
713
|
-
"SharedModules",
|
|
714
|
-
`Mapped module id: "${id}" -> "${mappedId}"`
|
|
715
|
-
);
|
|
716
|
-
id = mappedId;
|
|
717
|
-
}
|
|
718
|
-
webpackBundle.m[id] = (module2) => {
|
|
719
|
-
module2.exports = value;
|
|
720
|
-
};
|
|
721
|
-
} else {
|
|
722
|
-
logWarn(
|
|
723
|
-
"SharedModules",
|
|
724
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
725
|
-
);
|
|
726
|
-
}
|
|
827
|
+
node.remove();
|
|
828
|
+
node = nextCss.previousSibling;
|
|
727
829
|
}
|
|
830
|
+
self.__remote_next_css__[bundle] = elements;
|
|
728
831
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
832
|
+
if (styleContainer) {
|
|
833
|
+
const elements = self.__remote_next_css__[bundle];
|
|
834
|
+
elements.forEach((el) => {
|
|
835
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
836
|
+
});
|
|
837
|
+
} else {
|
|
838
|
+
const elements = self.__remote_next_css__[bundle];
|
|
839
|
+
elements.forEach((el) => {
|
|
840
|
+
document.head.appendChild(el);
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
delete self.__NEXT_P;
|
|
844
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
845
|
+
if (nextCssOriginal) {
|
|
846
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
847
|
+
}
|
|
848
|
+
nextCss.remove();
|
|
849
|
+
nextCssEnd.remove();
|
|
850
|
+
return { Component, App };
|
|
735
851
|
}
|
|
852
|
+
return { Component: null, App: null };
|
|
736
853
|
}
|
|
737
854
|
|
|
738
|
-
// src/
|
|
855
|
+
// src/runtime/rsc.ts
|
|
739
856
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
740
857
|
function fixPayload(payload) {
|
|
741
858
|
if (Array.isArray(payload)) {
|
|
@@ -801,56 +918,15 @@ function createRSCStream(rscName, data) {
|
|
|
801
918
|
});
|
|
802
919
|
}
|
|
803
920
|
|
|
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
|
|
921
|
+
// src/runtime/turbopack/patterns.ts
|
|
846
922
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
847
|
-
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|
|
|
923
|
+
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
848
924
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
849
925
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
850
926
|
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
927
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
852
928
|
|
|
853
|
-
// src/
|
|
929
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
854
930
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
855
931
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
856
932
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -912,7 +988,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
912
988
|
if (isProxied) {
|
|
913
989
|
reject(
|
|
914
990
|
new RemoteComponentsError(
|
|
915
|
-
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure
|
|
991
|
+
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
916
992
|
)
|
|
917
993
|
);
|
|
918
994
|
} else {
|
|
@@ -1062,7 +1138,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1062
1138
|
}
|
|
1063
1139
|
}
|
|
1064
1140
|
|
|
1065
|
-
// src/
|
|
1141
|
+
// src/runtime/turbopack/module.ts
|
|
1066
1142
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
1067
1143
|
const self = globalThis;
|
|
1068
1144
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1291,7 +1367,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1291
1367
|
};
|
|
1292
1368
|
}
|
|
1293
1369
|
|
|
1294
|
-
// src/
|
|
1370
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1295
1371
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1296
1372
|
const self = globalThis;
|
|
1297
1373
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1411,7 +1487,7 @@ function getSharedModule(bundle, id) {
|
|
|
1411
1487
|
return null;
|
|
1412
1488
|
}
|
|
1413
1489
|
|
|
1414
|
-
// src/
|
|
1490
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1415
1491
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1416
1492
|
const self = globalThis;
|
|
1417
1493
|
if (!self.__remote_bundle_url__) {
|
|
@@ -1466,7 +1542,7 @@ function createModuleRequire(runtime) {
|
|
|
1466
1542
|
id
|
|
1467
1543
|
};
|
|
1468
1544
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1469
|
-
logDebug("
|
|
1545
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1470
1546
|
try {
|
|
1471
1547
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1472
1548
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1482,7 +1558,7 @@ function createModuleRequire(runtime) {
|
|
|
1482
1558
|
throw new Error(`Module "${id}" not found.`);
|
|
1483
1559
|
} catch (requireError) {
|
|
1484
1560
|
logWarn(
|
|
1485
|
-
"
|
|
1561
|
+
"WebpackRuntime",
|
|
1486
1562
|
`Module require failed: ${String(requireError)}`
|
|
1487
1563
|
);
|
|
1488
1564
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1494,7 +1570,7 @@ function createModuleRequire(runtime) {
|
|
|
1494
1570
|
);
|
|
1495
1571
|
}
|
|
1496
1572
|
try {
|
|
1497
|
-
logDebug("
|
|
1573
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1498
1574
|
return self.__original_webpack_require__(id);
|
|
1499
1575
|
} catch (originalError) {
|
|
1500
1576
|
throw new RemoteComponentsError(
|
|
@@ -1506,7 +1582,45 @@ function createModuleRequire(runtime) {
|
|
|
1506
1582
|
};
|
|
1507
1583
|
}
|
|
1508
1584
|
|
|
1509
|
-
// src/
|
|
1585
|
+
// src/runtime/loaders/script-loader.ts
|
|
1586
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
1587
|
+
await Promise.all(
|
|
1588
|
+
scripts.map((script) => {
|
|
1589
|
+
return new Promise((resolve, reject) => {
|
|
1590
|
+
const newSrc = new URL(
|
|
1591
|
+
// remove the remote component bundle name identifier from the script src
|
|
1592
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1593
|
+
location.origin
|
|
1594
|
+
).href;
|
|
1595
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1596
|
+
const newScript = document.createElement("script");
|
|
1597
|
+
newScript.onload = () => resolve();
|
|
1598
|
+
newScript.onerror = () => {
|
|
1599
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1600
|
+
if (isProxied) {
|
|
1601
|
+
reject(
|
|
1602
|
+
new RemoteComponentsError(
|
|
1603
|
+
`Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHostProxy middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
1604
|
+
)
|
|
1605
|
+
);
|
|
1606
|
+
} else {
|
|
1607
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1608
|
+
reject(
|
|
1609
|
+
new RemoteComponentsError(
|
|
1610
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1611
|
+
)
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
newScript.src = resolvedSrc;
|
|
1616
|
+
newScript.async = true;
|
|
1617
|
+
document.head.appendChild(newScript);
|
|
1618
|
+
});
|
|
1619
|
+
})
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// src/runtime/loaders/component-loader.ts
|
|
1510
1624
|
async function loadRemoteComponent({
|
|
1511
1625
|
url,
|
|
1512
1626
|
name,
|
|
@@ -1609,17 +1723,19 @@ async function loadRemoteComponent({
|
|
|
1609
1723
|
};
|
|
1610
1724
|
}
|
|
1611
1725
|
}
|
|
1612
|
-
async function
|
|
1613
|
-
let createFromReadableStream;
|
|
1726
|
+
async function importCreateFromReadableStream() {
|
|
1614
1727
|
try {
|
|
1615
|
-
const { createFromReadableStream
|
|
1616
|
-
createFromReadableStream
|
|
1728
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1729
|
+
return createFromReadableStream;
|
|
1617
1730
|
} catch {
|
|
1618
1731
|
const {
|
|
1619
|
-
default: { createFromReadableStream
|
|
1732
|
+
default: { createFromReadableStream }
|
|
1620
1733
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1621
|
-
createFromReadableStream
|
|
1734
|
+
return createFromReadableStream;
|
|
1622
1735
|
}
|
|
1736
|
+
}
|
|
1737
|
+
async function loadRSCComponent(rscName, data) {
|
|
1738
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1623
1739
|
if (typeof createFromReadableStream !== "function") {
|
|
1624
1740
|
throw new RemoteComponentsError(
|
|
1625
1741
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1640,85 +1756,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1640
1756
|
return { component };
|
|
1641
1757
|
}
|
|
1642
1758
|
|
|
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
|
-
var proxyClientRequestsThroughHost = (remoteSrc, url) => {
|
|
1662
|
-
if (typeof location === "undefined") {
|
|
1663
|
-
return void 0;
|
|
1664
|
-
}
|
|
1665
|
-
const remoteOrigin = new URL(remoteSrc, location.href).origin;
|
|
1666
|
-
if (remoteOrigin === location.origin) {
|
|
1667
|
-
return void 0;
|
|
1668
|
-
}
|
|
1669
|
-
try {
|
|
1670
|
-
const parsed = new URL(url, location.href);
|
|
1671
|
-
if (parsed.origin === remoteOrigin) {
|
|
1672
|
-
return generateProtectedRcFallbackSrc(url);
|
|
1673
|
-
}
|
|
1674
|
-
} catch {
|
|
1675
|
-
}
|
|
1676
|
-
return void 0;
|
|
1677
|
-
};
|
|
1678
|
-
|
|
1679
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1680
|
-
var DOMAttributeNames = {
|
|
1681
|
-
acceptCharset: "accept-charset",
|
|
1682
|
-
className: "class",
|
|
1683
|
-
htmlFor: "for",
|
|
1684
|
-
httpEquiv: "http-equiv",
|
|
1685
|
-
noModule: "noModule"
|
|
1686
|
-
};
|
|
1687
|
-
var ignoreProps = [
|
|
1688
|
-
"onLoad",
|
|
1689
|
-
"onReady",
|
|
1690
|
-
"dangerouslySetInnerHTML",
|
|
1691
|
-
"children",
|
|
1692
|
-
"onError",
|
|
1693
|
-
"strategy",
|
|
1694
|
-
"stylesheets"
|
|
1695
|
-
];
|
|
1696
|
-
function isBooleanScriptAttribute(attr) {
|
|
1697
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1698
|
-
}
|
|
1699
|
-
function setAttributesFromProps(el, props) {
|
|
1700
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1701
|
-
if (!Object.hasOwn(props, p))
|
|
1702
|
-
continue;
|
|
1703
|
-
if (ignoreProps.includes(p))
|
|
1704
|
-
continue;
|
|
1705
|
-
if (value === void 0) {
|
|
1706
|
-
continue;
|
|
1707
|
-
}
|
|
1708
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1709
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1710
|
-
el[attr] = Boolean(value);
|
|
1711
|
-
} else {
|
|
1712
|
-
el.setAttribute(attr, String(value));
|
|
1713
|
-
}
|
|
1714
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1715
|
-
el.setAttribute(attr, "");
|
|
1716
|
-
el.removeAttribute(attr);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
// src/shared/client/static-loader.ts
|
|
1759
|
+
// src/runtime/loaders/static-loader.ts
|
|
1722
1760
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1723
1761
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1724
1762
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1868,101 +1906,35 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1868
1906
|
);
|
|
1869
1907
|
}
|
|
1870
1908
|
|
|
1871
|
-
// src/
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
stage: "idle",
|
|
1875
|
-
prevSrc: void 0,
|
|
1876
|
-
prevUrl: void 0,
|
|
1877
|
-
prevName: void 0,
|
|
1878
|
-
prevIsRemoteComponent: false,
|
|
1879
|
-
abortController: void 0
|
|
1880
|
-
};
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1883
|
-
// src/shared/contract/resolve-name-from-src.ts
|
|
1884
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
1885
|
-
if (!src) {
|
|
1886
|
-
return defaultName;
|
|
1887
|
-
}
|
|
1888
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
1889
|
-
const hashIndex = hash.indexOf("#");
|
|
1890
|
-
if (hashIndex < 0) {
|
|
1891
|
-
return defaultName;
|
|
1892
|
-
}
|
|
1893
|
-
const name = hash.slice(hashIndex + 1);
|
|
1894
|
-
return name || defaultName;
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
// src/shared/ssr/fetch-headers.ts
|
|
1898
|
-
function remoteFetchHeaders() {
|
|
1899
|
-
return {
|
|
1900
|
-
/**
|
|
1901
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1902
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1903
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1904
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1905
|
-
*/
|
|
1906
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1907
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1908
|
-
} : {},
|
|
1909
|
-
Accept: "text/html"
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1909
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1910
|
+
var import_react = require("react");
|
|
1911
|
+
var import_context = require("#internal/host/react/context");
|
|
1912
1912
|
|
|
1913
|
-
// src/
|
|
1914
|
-
|
|
1915
|
-
const
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
const signal = abortController.signal;
|
|
1921
|
-
const hookOptions = {
|
|
1922
|
-
signal,
|
|
1923
|
-
abort: (reason) => abortController.abort(reason)
|
|
1924
|
-
};
|
|
1925
|
-
const init = {
|
|
1926
|
-
method: "GET",
|
|
1927
|
-
headers: remoteFetchHeaders(),
|
|
1928
|
-
signal,
|
|
1929
|
-
...additionalInit
|
|
1930
|
-
};
|
|
1931
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1932
|
-
if (!res) {
|
|
1933
|
-
try {
|
|
1934
|
-
res = await fetch(url, init);
|
|
1935
|
-
} catch (error) {
|
|
1936
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1937
|
-
throw error;
|
|
1913
|
+
// src/runtime/url/resolve-client-url.ts
|
|
1914
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1915
|
+
const remoteOrigin = parseOrigin(remoteSrc);
|
|
1916
|
+
return (url) => {
|
|
1917
|
+
const urlOrigin = parseOrigin(url);
|
|
1918
|
+
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
1919
|
+
return void 0;
|
|
1938
1920
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
if (transformedRes) {
|
|
1942
|
-
res = transformedRes;
|
|
1943
|
-
}
|
|
1944
|
-
return res;
|
|
1921
|
+
return resolveClientUrl(remoteSrc, url);
|
|
1922
|
+
};
|
|
1945
1923
|
}
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
return new URL(fallback);
|
|
1924
|
+
function parseOrigin(url) {
|
|
1925
|
+
try {
|
|
1926
|
+
return new URL(url).origin;
|
|
1927
|
+
} catch {
|
|
1928
|
+
return void 0;
|
|
1952
1929
|
}
|
|
1953
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1954
1930
|
}
|
|
1955
1931
|
|
|
1956
|
-
// src/
|
|
1957
|
-
var import_react = require("react");
|
|
1958
|
-
var import_context = require("#internal/react/context");
|
|
1959
|
-
|
|
1960
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1932
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
1961
1933
|
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1962
1934
|
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1963
1935
|
}
|
|
1964
1936
|
|
|
1965
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
1937
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1966
1938
|
function useResolveClientUrl(prop, urlHref) {
|
|
1967
1939
|
const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
|
|
1968
1940
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1972,7 +1944,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1972
1944
|
);
|
|
1973
1945
|
}
|
|
1974
1946
|
|
|
1975
|
-
// src/react/hooks/use-shadow-root.ts
|
|
1947
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1976
1948
|
var import_react2 = require("react");
|
|
1977
1949
|
function useShadowRoot({
|
|
1978
1950
|
isolate,
|
|
@@ -2021,7 +1993,7 @@ function useShadowRoot({
|
|
|
2021
1993
|
return { shadowRoot, shadowRootContainerRef };
|
|
2022
1994
|
}
|
|
2023
1995
|
|
|
2024
|
-
// src/react/utils/extract-remote-html.ts
|
|
1996
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
2025
1997
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
2026
1998
|
function getRemoteComponentHtml(html) {
|
|
2027
1999
|
if (typeof document === "undefined")
|
|
@@ -2043,14 +2015,13 @@ function getRemoteComponentHtml(html) {
|
|
|
2043
2015
|
return "";
|
|
2044
2016
|
}
|
|
2045
2017
|
|
|
2046
|
-
// src/react/index.tsx
|
|
2047
|
-
var import_context2 = require("#internal/react/context");
|
|
2018
|
+
// src/host/react/index.tsx
|
|
2048
2019
|
var import_jsx_runtime2 = (
|
|
2049
2020
|
// TODO: remove wrapper div by converting HTML to RSC or React tree
|
|
2050
2021
|
require("react/jsx-runtime")
|
|
2051
2022
|
);
|
|
2052
2023
|
var import_react4 = require("react");
|
|
2053
|
-
function
|
|
2024
|
+
function ConsumeRemoteComponent({
|
|
2054
2025
|
src,
|
|
2055
2026
|
isolate,
|
|
2056
2027
|
mode = "open",
|
|
@@ -2072,7 +2043,9 @@ function RemoteComponent({
|
|
|
2072
2043
|
() => resolveNameFromSrc(src, nameProp),
|
|
2073
2044
|
[src, nameProp]
|
|
2074
2045
|
);
|
|
2075
|
-
const [data, setData] = (0, import_react3.useState)(
|
|
2046
|
+
const [data, setData] = (0, import_react3.useState)(
|
|
2047
|
+
null
|
|
2048
|
+
);
|
|
2076
2049
|
const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
2077
2050
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
2078
2051
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -2289,11 +2262,10 @@ function RemoteComponent({
|
|
|
2289
2262
|
});
|
|
2290
2263
|
self.__next_s = prevNextScripts;
|
|
2291
2264
|
}
|
|
2292
|
-
|
|
2265
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2266
|
+
remoteName
|
|
2267
|
+
)}` : void 0;
|
|
2293
2268
|
if (rsc) {
|
|
2294
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2295
|
-
id
|
|
2296
|
-
)}_${escapeString(remoteName)}`;
|
|
2297
2269
|
rsc.textContent = rsc.textContent?.replace(
|
|
2298
2270
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2299
2271
|
`self["${rscName}"]`
|
|
@@ -2332,10 +2304,7 @@ function RemoteComponent({
|
|
|
2332
2304
|
}
|
|
2333
2305
|
setData(newData);
|
|
2334
2306
|
if (shadowRoot) {
|
|
2335
|
-
|
|
2336
|
-
if (reset) {
|
|
2337
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2338
|
-
}
|
|
2307
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2339
2308
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2340
2309
|
htmlRef.current = null;
|
|
2341
2310
|
setRemoteComponent(null);
|
|
@@ -2403,7 +2372,7 @@ function RemoteComponent({
|
|
|
2403
2372
|
};
|
|
2404
2373
|
}),
|
|
2405
2374
|
shared: {
|
|
2406
|
-
...sharedPolyfills(userShared),
|
|
2375
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2407
2376
|
...userShared
|
|
2408
2377
|
},
|
|
2409
2378
|
remoteShared,
|
|
@@ -2575,8 +2544,6 @@ function RemoteComponent({
|
|
|
2575
2544
|
}
|
|
2576
2545
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2577
2546
|
0 && (module.exports = {
|
|
2578
|
-
|
|
2579
|
-
RemoteComponentsProvider,
|
|
2580
|
-
proxyClientRequestsThroughHost
|
|
2547
|
+
ConsumeRemoteComponent
|
|
2581
2548
|
});
|
|
2582
|
-
//# sourceMappingURL=
|
|
2549
|
+
//# sourceMappingURL=react.cjs.map
|