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