remote-components 0.1.0 → 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} +1270 -1201
- 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} +1266 -1196
- package/dist/host/html.js.map +1 -0
- package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +690 -518
- 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} +693 -514
- 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/host/nextjs/pages.d.ts +77 -0
- 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/{internal/shared/client/proxy-through-host.cjs → host/proxy/client.cjs} +19 -13
- 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} +552 -477
- package/dist/host/react.cjs.map +1 -0
- package/dist/host/react.d.ts +366 -0
- package/dist/{react/index.js → host/react.js} +551 -474
- 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} +36 -29
- 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} +27 -25
- 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/internal/host/server/types.cjs +17 -0
- 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/internal/host/shared/config.d.ts +100 -0
- 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-cbe44b51.d.ts → internal/host/shared/fetch-interceptors.d.ts} +7 -73
- 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/{next/remote/server.cjs → internal/host/shared/state.cjs} +16 -7
- package/dist/internal/host/shared/state.cjs.map +1 -0
- package/dist/internal/host/shared/state.d.ts +53 -0
- package/dist/internal/host/shared/state.js +14 -0
- package/dist/internal/host/shared/state.js.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.cjs +40 -0
- package/dist/internal/host/utils/resolve-name-from-src.cjs.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.d.ts +13 -0
- package/dist/internal/host/utils/resolve-name-from-src.js +16 -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/runtime/url/resolve-client-url.cjs +45 -0
- 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} +6 -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/remote/nextjs/app.d.ts +45 -0
- 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/component-loader-76eb1b8b.d.ts +0 -200
- 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 -66
- 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.d.ts +0 -47
- 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 -26
- 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/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 -60
- 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 -56
- 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.d.ts +0 -104
- 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 -56
- 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 -1
- 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 -123
- 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/{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,7 +144,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
211
144
|
);
|
|
212
145
|
}
|
|
213
146
|
|
|
214
|
-
// src/
|
|
147
|
+
// src/utils/logger.ts
|
|
215
148
|
var PREFIX = "remote-components";
|
|
216
149
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
217
150
|
function logDebug(location2, message) {
|
|
@@ -237,13 +170,68 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
237
170
|
}
|
|
238
171
|
logWarn(
|
|
239
172
|
logLocation,
|
|
240
|
-
`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}`
|
|
241
174
|
);
|
|
242
175
|
} catch {
|
|
243
176
|
}
|
|
244
177
|
}
|
|
245
178
|
|
|
246
|
-
// 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
|
|
247
235
|
var import_jsx_runtime = (
|
|
248
236
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
249
237
|
require("react/jsx-runtime")
|
|
@@ -266,7 +254,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
266
254
|
const propSrc = src;
|
|
267
255
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
268
256
|
}
|
|
269
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
257
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
270
258
|
fill: _fill,
|
|
271
259
|
loader: _loader,
|
|
272
260
|
quality: _quality,
|
|
@@ -283,18 +271,19 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
283
271
|
bundle,
|
|
284
272
|
typeof src === "string" ? src : src.src
|
|
285
273
|
);
|
|
274
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
286
275
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
287
276
|
"img",
|
|
288
277
|
{
|
|
289
278
|
decoding: "async",
|
|
290
279
|
style: { color: "transparent" },
|
|
291
280
|
...props,
|
|
292
|
-
src:
|
|
281
|
+
src: proxiedSrc,
|
|
293
282
|
suppressHydrationWarning: true
|
|
294
283
|
}
|
|
295
284
|
);
|
|
296
285
|
};
|
|
297
|
-
function sharedPolyfills(shared) {
|
|
286
|
+
function sharedPolyfills(shared, resolveClientUrl) {
|
|
298
287
|
const self = globalThis;
|
|
299
288
|
const polyfill = {
|
|
300
289
|
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
@@ -385,11 +374,11 @@ function sharedPolyfills(shared) {
|
|
|
385
374
|
__esModule: true
|
|
386
375
|
})),
|
|
387
376
|
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
388
|
-
Image: imageImpl(bundle),
|
|
377
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
389
378
|
__esModule: true
|
|
390
379
|
})),
|
|
391
380
|
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
392
|
-
default: imageImpl(bundle),
|
|
381
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
393
382
|
getImageProps: (_imgProps) => {
|
|
394
383
|
throw new Error(
|
|
395
384
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -439,14 +428,319 @@ function sharedPolyfills(shared) {
|
|
|
439
428
|
return polyfill;
|
|
440
429
|
}
|
|
441
430
|
|
|
442
|
-
// src/shared/
|
|
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
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
444
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
445
|
+
if (!src) {
|
|
446
|
+
return defaultName;
|
|
447
|
+
}
|
|
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
|
|
443
679
|
var React = __toESM(require("react"), 1);
|
|
444
680
|
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
445
681
|
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
446
682
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
447
683
|
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
448
684
|
|
|
449
|
-
// src/
|
|
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
|
|
450
744
|
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
451
745
|
const self = globalThis;
|
|
452
746
|
const nextCssOriginal = document.querySelector(
|
|
@@ -515,111 +809,50 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
515
809
|
if (!self.__remote_next_css__) {
|
|
516
810
|
self.__remote_next_css__ = {};
|
|
517
811
|
}
|
|
518
|
-
if (!self.__remote_next_css__[bundle]) {
|
|
519
|
-
const cssRE = /\.s?css$/;
|
|
520
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
521
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
522
|
-
});
|
|
523
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
524
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
525
|
-
if (id) {
|
|
526
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
const elements = [];
|
|
530
|
-
let node = nextCss.previousSibling;
|
|
531
|
-
while (node && node !== nextCssEnd) {
|
|
532
|
-
elements.push(node);
|
|
533
|
-
node.remove();
|
|
534
|
-
node = nextCss.previousSibling;
|
|
535
|
-
}
|
|
536
|
-
self.__remote_next_css__[bundle] = elements;
|
|
537
|
-
}
|
|
538
|
-
if (styleContainer) {
|
|
539
|
-
const elements = self.__remote_next_css__[bundle];
|
|
540
|
-
elements.forEach((el) => {
|
|
541
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
542
|
-
});
|
|
543
|
-
} else {
|
|
544
|
-
const elements = self.__remote_next_css__[bundle];
|
|
545
|
-
elements.forEach((el) => {
|
|
546
|
-
document.head.appendChild(el);
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
delete self.__NEXT_P;
|
|
550
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
551
|
-
if (nextCssOriginal) {
|
|
552
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
553
|
-
}
|
|
554
|
-
nextCss.remove();
|
|
555
|
-
nextCssEnd.remove();
|
|
556
|
-
return { Component, App };
|
|
557
|
-
}
|
|
558
|
-
return { Component: null, App: null };
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// src/shared/webpack/shared-modules.ts
|
|
562
|
-
function applySharedModules(bundle, resolve) {
|
|
563
|
-
logDebug(
|
|
564
|
-
"SharedModules",
|
|
565
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
566
|
-
);
|
|
567
|
-
logDebug(
|
|
568
|
-
"SharedModules",
|
|
569
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
570
|
-
);
|
|
571
|
-
const self = globalThis;
|
|
572
|
-
if (self.__remote_webpack_require__?.[bundle]) {
|
|
573
|
-
const modulePaths = Object.keys(
|
|
574
|
-
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
575
|
-
);
|
|
576
|
-
logDebug(
|
|
577
|
-
"SharedModules",
|
|
578
|
-
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
579
|
-
);
|
|
580
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
581
|
-
let ids = modulePaths.filter((p) => p === key);
|
|
582
|
-
if (ids.length === 0) {
|
|
583
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
584
|
-
}
|
|
585
|
-
if (ids.length === 0) {
|
|
586
|
-
logDebug(
|
|
587
|
-
"SharedModules",
|
|
588
|
-
`No matching module path found for shared module "${key}"`
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
for (let id of ids) {
|
|
592
|
-
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
593
|
-
if (webpackBundle.m) {
|
|
594
|
-
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
595
|
-
const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
596
|
-
logDebug(
|
|
597
|
-
"SharedModules",
|
|
598
|
-
`Mapped module id: "${id}" -> "${mappedId}"`
|
|
599
|
-
);
|
|
600
|
-
id = mappedId;
|
|
601
|
-
}
|
|
602
|
-
webpackBundle.m[id] = (module2) => {
|
|
603
|
-
module2.exports = value;
|
|
604
|
-
};
|
|
605
|
-
} else {
|
|
606
|
-
logWarn(
|
|
607
|
-
"SharedModules",
|
|
608
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
609
|
-
);
|
|
812
|
+
if (!self.__remote_next_css__[bundle]) {
|
|
813
|
+
const cssRE = /\.s?css$/;
|
|
814
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
815
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
816
|
+
});
|
|
817
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
818
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
819
|
+
if (id) {
|
|
820
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
610
821
|
}
|
|
822
|
+
});
|
|
823
|
+
const elements = [];
|
|
824
|
+
let node = nextCss.previousSibling;
|
|
825
|
+
while (node && node !== nextCssEnd) {
|
|
826
|
+
elements.push(node);
|
|
827
|
+
node.remove();
|
|
828
|
+
node = nextCss.previousSibling;
|
|
611
829
|
}
|
|
830
|
+
self.__remote_next_css__[bundle] = elements;
|
|
612
831
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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 };
|
|
619
851
|
}
|
|
852
|
+
return { Component: null, App: null };
|
|
620
853
|
}
|
|
621
854
|
|
|
622
|
-
// src/
|
|
855
|
+
// src/runtime/rsc.ts
|
|
623
856
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
624
857
|
function fixPayload(payload) {
|
|
625
858
|
if (Array.isArray(payload)) {
|
|
@@ -685,78 +918,15 @@ function createRSCStream(rscName, data) {
|
|
|
685
918
|
});
|
|
686
919
|
}
|
|
687
920
|
|
|
688
|
-
// src/
|
|
689
|
-
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
690
|
-
|
|
691
|
-
// src/shared/client/script-loader.ts
|
|
692
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
693
|
-
await Promise.all(
|
|
694
|
-
scripts.map((script) => {
|
|
695
|
-
return new Promise((resolve, reject) => {
|
|
696
|
-
const newSrc = new URL(
|
|
697
|
-
// remove the remote component bundle name identifier from the script src
|
|
698
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
699
|
-
location.origin
|
|
700
|
-
).href;
|
|
701
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
702
|
-
const newScript = document.createElement("script");
|
|
703
|
-
newScript.onload = () => resolve();
|
|
704
|
-
newScript.onerror = () => {
|
|
705
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
706
|
-
if (isProxied) {
|
|
707
|
-
reject(
|
|
708
|
-
new RemoteComponentsError(
|
|
709
|
-
`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}`
|
|
710
|
-
)
|
|
711
|
-
);
|
|
712
|
-
} else {
|
|
713
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
714
|
-
reject(
|
|
715
|
-
new RemoteComponentsError(
|
|
716
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
717
|
-
)
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
newScript.src = resolvedSrc;
|
|
722
|
-
newScript.async = true;
|
|
723
|
-
document.head.appendChild(newScript);
|
|
724
|
-
});
|
|
725
|
-
})
|
|
726
|
-
);
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// src/shared/utils/index.ts
|
|
730
|
-
function escapeString(str) {
|
|
731
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
732
|
-
}
|
|
733
|
-
var attrToProp = {
|
|
734
|
-
fetchpriority: "fetchPriority",
|
|
735
|
-
crossorigin: "crossOrigin",
|
|
736
|
-
imagesrcset: "imageSrcSet",
|
|
737
|
-
imagesizes: "imageSizes",
|
|
738
|
-
srcset: "srcSet"
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
// src/shared/client/const.ts
|
|
742
|
-
var DEFAULT_ROUTE = "/";
|
|
743
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
744
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
745
|
-
var RUNTIME_SCRIPT = "script";
|
|
746
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
747
|
-
function getBundleKey(bundle) {
|
|
748
|
-
return escapeString(bundle);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// src/shared/client/turbopack-patterns.ts
|
|
921
|
+
// src/runtime/turbopack/patterns.ts
|
|
752
922
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
753
|
-
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]+)\)/;
|
|
754
924
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
755
925
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
756
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]+)\)\)\)\}/;
|
|
757
927
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
758
928
|
|
|
759
|
-
// src/
|
|
929
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
760
930
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
761
931
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
762
932
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -818,7 +988,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
818
988
|
if (isProxied) {
|
|
819
989
|
reject(
|
|
820
990
|
new RemoteComponentsError(
|
|
821
|
-
`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}`
|
|
822
992
|
)
|
|
823
993
|
);
|
|
824
994
|
} else {
|
|
@@ -968,7 +1138,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
968
1138
|
}
|
|
969
1139
|
}
|
|
970
1140
|
|
|
971
|
-
// src/
|
|
1141
|
+
// src/runtime/turbopack/module.ts
|
|
972
1142
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
973
1143
|
const self = globalThis;
|
|
974
1144
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1197,7 +1367,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1197
1367
|
};
|
|
1198
1368
|
}
|
|
1199
1369
|
|
|
1200
|
-
// src/
|
|
1370
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1201
1371
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1202
1372
|
const self = globalThis;
|
|
1203
1373
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1317,7 +1487,7 @@ function getSharedModule(bundle, id) {
|
|
|
1317
1487
|
return null;
|
|
1318
1488
|
}
|
|
1319
1489
|
|
|
1320
|
-
// src/
|
|
1490
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1321
1491
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1322
1492
|
const self = globalThis;
|
|
1323
1493
|
if (!self.__remote_bundle_url__) {
|
|
@@ -1372,7 +1542,7 @@ function createModuleRequire(runtime) {
|
|
|
1372
1542
|
id
|
|
1373
1543
|
};
|
|
1374
1544
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1375
|
-
logDebug("
|
|
1545
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1376
1546
|
try {
|
|
1377
1547
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1378
1548
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1388,7 +1558,7 @@ function createModuleRequire(runtime) {
|
|
|
1388
1558
|
throw new Error(`Module "${id}" not found.`);
|
|
1389
1559
|
} catch (requireError) {
|
|
1390
1560
|
logWarn(
|
|
1391
|
-
"
|
|
1561
|
+
"WebpackRuntime",
|
|
1392
1562
|
`Module require failed: ${String(requireError)}`
|
|
1393
1563
|
);
|
|
1394
1564
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1400,7 +1570,7 @@ function createModuleRequire(runtime) {
|
|
|
1400
1570
|
);
|
|
1401
1571
|
}
|
|
1402
1572
|
try {
|
|
1403
|
-
logDebug("
|
|
1573
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1404
1574
|
return self.__original_webpack_require__(id);
|
|
1405
1575
|
} catch (originalError) {
|
|
1406
1576
|
throw new RemoteComponentsError(
|
|
@@ -1412,7 +1582,45 @@ function createModuleRequire(runtime) {
|
|
|
1412
1582
|
};
|
|
1413
1583
|
}
|
|
1414
1584
|
|
|
1415
|
-
// 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
|
|
1416
1624
|
async function loadRemoteComponent({
|
|
1417
1625
|
url,
|
|
1418
1626
|
name,
|
|
@@ -1515,17 +1723,19 @@ async function loadRemoteComponent({
|
|
|
1515
1723
|
};
|
|
1516
1724
|
}
|
|
1517
1725
|
}
|
|
1518
|
-
async function
|
|
1519
|
-
let createFromReadableStream;
|
|
1726
|
+
async function importCreateFromReadableStream() {
|
|
1520
1727
|
try {
|
|
1521
|
-
const { createFromReadableStream
|
|
1522
|
-
createFromReadableStream
|
|
1728
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1729
|
+
return createFromReadableStream;
|
|
1523
1730
|
} catch {
|
|
1524
1731
|
const {
|
|
1525
|
-
default: { createFromReadableStream
|
|
1732
|
+
default: { createFromReadableStream }
|
|
1526
1733
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1527
|
-
createFromReadableStream
|
|
1734
|
+
return createFromReadableStream;
|
|
1528
1735
|
}
|
|
1736
|
+
}
|
|
1737
|
+
async function loadRSCComponent(rscName, data) {
|
|
1738
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1529
1739
|
if (typeof createFromReadableStream !== "function") {
|
|
1530
1740
|
throw new RemoteComponentsError(
|
|
1531
1741
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1546,71 +1756,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1546
1756
|
return { component };
|
|
1547
1757
|
}
|
|
1548
1758
|
|
|
1549
|
-
// src/
|
|
1550
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1551
|
-
return (url) => resolveClientUrl(remoteSrc, url);
|
|
1552
|
-
}
|
|
1553
|
-
var proxyClientRequestsThroughHost = (remoteSrc, url) => {
|
|
1554
|
-
if (typeof location === "undefined") {
|
|
1555
|
-
return void 0;
|
|
1556
|
-
}
|
|
1557
|
-
const remoteOrigin = new URL(remoteSrc, location.href).origin;
|
|
1558
|
-
if (remoteOrigin === location.origin) {
|
|
1559
|
-
return void 0;
|
|
1560
|
-
}
|
|
1561
|
-
try {
|
|
1562
|
-
const parsed = new URL(url, location.href);
|
|
1563
|
-
if (parsed.origin === remoteOrigin) {
|
|
1564
|
-
return generateProtectedRcFallbackSrc(url);
|
|
1565
|
-
}
|
|
1566
|
-
} catch {
|
|
1567
|
-
}
|
|
1568
|
-
return void 0;
|
|
1569
|
-
};
|
|
1570
|
-
|
|
1571
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1572
|
-
var DOMAttributeNames = {
|
|
1573
|
-
acceptCharset: "accept-charset",
|
|
1574
|
-
className: "class",
|
|
1575
|
-
htmlFor: "for",
|
|
1576
|
-
httpEquiv: "http-equiv",
|
|
1577
|
-
noModule: "noModule"
|
|
1578
|
-
};
|
|
1579
|
-
var ignoreProps = [
|
|
1580
|
-
"onLoad",
|
|
1581
|
-
"onReady",
|
|
1582
|
-
"dangerouslySetInnerHTML",
|
|
1583
|
-
"children",
|
|
1584
|
-
"onError",
|
|
1585
|
-
"strategy",
|
|
1586
|
-
"stylesheets"
|
|
1587
|
-
];
|
|
1588
|
-
function isBooleanScriptAttribute(attr) {
|
|
1589
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1590
|
-
}
|
|
1591
|
-
function setAttributesFromProps(el, props) {
|
|
1592
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1593
|
-
if (!Object.hasOwn(props, p))
|
|
1594
|
-
continue;
|
|
1595
|
-
if (ignoreProps.includes(p))
|
|
1596
|
-
continue;
|
|
1597
|
-
if (value === void 0) {
|
|
1598
|
-
continue;
|
|
1599
|
-
}
|
|
1600
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1601
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1602
|
-
el[attr] = Boolean(value);
|
|
1603
|
-
} else {
|
|
1604
|
-
el.setAttribute(attr, String(value));
|
|
1605
|
-
}
|
|
1606
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1607
|
-
el.setAttribute(attr, "");
|
|
1608
|
-
el.removeAttribute(attr);
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
// src/shared/client/static-loader.ts
|
|
1759
|
+
// src/runtime/loaders/static-loader.ts
|
|
1614
1760
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1615
1761
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1616
1762
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1760,75 +1906,35 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1760
1906
|
);
|
|
1761
1907
|
}
|
|
1762
1908
|
|
|
1763
|
-
// src/
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
/**
|
|
1767
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1768
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1769
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1770
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1771
|
-
*/
|
|
1772
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1773
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1774
|
-
} : {},
|
|
1775
|
-
Accept: "text/html"
|
|
1776
|
-
};
|
|
1777
|
-
}
|
|
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");
|
|
1778
1912
|
|
|
1779
|
-
// src/
|
|
1780
|
-
|
|
1781
|
-
const
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
const signal = abortController.signal;
|
|
1787
|
-
const hookOptions = {
|
|
1788
|
-
signal,
|
|
1789
|
-
abort: (reason) => abortController.abort(reason)
|
|
1790
|
-
};
|
|
1791
|
-
const init = {
|
|
1792
|
-
method: "GET",
|
|
1793
|
-
headers: remoteFetchHeaders(),
|
|
1794
|
-
signal,
|
|
1795
|
-
...additionalInit
|
|
1796
|
-
};
|
|
1797
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1798
|
-
if (!res) {
|
|
1799
|
-
try {
|
|
1800
|
-
res = await fetch(url, init);
|
|
1801
|
-
} catch (error) {
|
|
1802
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1803
|
-
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;
|
|
1804
1920
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
if (transformedRes) {
|
|
1808
|
-
res = transformedRes;
|
|
1809
|
-
}
|
|
1810
|
-
return res;
|
|
1921
|
+
return resolveClientUrl(remoteSrc, url);
|
|
1922
|
+
};
|
|
1811
1923
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
return new URL(fallback);
|
|
1924
|
+
function parseOrigin(url) {
|
|
1925
|
+
try {
|
|
1926
|
+
return new URL(url).origin;
|
|
1927
|
+
} catch {
|
|
1928
|
+
return void 0;
|
|
1818
1929
|
}
|
|
1819
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1820
1930
|
}
|
|
1821
1931
|
|
|
1822
|
-
// src/
|
|
1823
|
-
var import_react = require("react");
|
|
1824
|
-
var import_context = require("#internal/react/context");
|
|
1825
|
-
|
|
1826
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1932
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
1827
1933
|
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1828
1934
|
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1829
1935
|
}
|
|
1830
1936
|
|
|
1831
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
1937
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1832
1938
|
function useResolveClientUrl(prop, urlHref) {
|
|
1833
1939
|
const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
|
|
1834
1940
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1838,7 +1944,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1838
1944
|
);
|
|
1839
1945
|
}
|
|
1840
1946
|
|
|
1841
|
-
// src/react/hooks/use-shadow-root.ts
|
|
1947
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1842
1948
|
var import_react2 = require("react");
|
|
1843
1949
|
function useShadowRoot({
|
|
1844
1950
|
isolate,
|
|
@@ -1887,7 +1993,7 @@ function useShadowRoot({
|
|
|
1887
1993
|
return { shadowRoot, shadowRootContainerRef };
|
|
1888
1994
|
}
|
|
1889
1995
|
|
|
1890
|
-
// src/react/utils/
|
|
1996
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
1891
1997
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
1892
1998
|
function getRemoteComponentHtml(html) {
|
|
1893
1999
|
if (typeof document === "undefined")
|
|
@@ -1909,14 +2015,13 @@ function getRemoteComponentHtml(html) {
|
|
|
1909
2015
|
return "";
|
|
1910
2016
|
}
|
|
1911
2017
|
|
|
1912
|
-
// src/react/index.tsx
|
|
1913
|
-
var import_context2 = require("#internal/react/context");
|
|
2018
|
+
// src/host/react/index.tsx
|
|
1914
2019
|
var import_jsx_runtime2 = (
|
|
1915
2020
|
// TODO: remove wrapper div by converting HTML to RSC or React tree
|
|
1916
2021
|
require("react/jsx-runtime")
|
|
1917
2022
|
);
|
|
1918
2023
|
var import_react4 = require("react");
|
|
1919
|
-
function
|
|
2024
|
+
function ConsumeRemoteComponent({
|
|
1920
2025
|
src,
|
|
1921
2026
|
isolate,
|
|
1922
2027
|
mode = "open",
|
|
@@ -1934,21 +2039,13 @@ function RemoteComponent({
|
|
|
1934
2039
|
resolveClientUrl: _resolveClientUrl
|
|
1935
2040
|
}) {
|
|
1936
2041
|
const instanceId = (0, import_react3.useId)();
|
|
1937
|
-
const name = (0, import_react3.useMemo)(
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
return url2.hash.slice(1);
|
|
1945
|
-
}
|
|
1946
|
-
} else if (typeof src === "object" && "hash" in src && src.hash) {
|
|
1947
|
-
return src.hash.slice(1) || nameProp;
|
|
1948
|
-
}
|
|
1949
|
-
return nameProp;
|
|
1950
|
-
}, [src, nameProp]);
|
|
1951
|
-
const [data, setData] = (0, import_react3.useState)(null);
|
|
2042
|
+
const name = (0, import_react3.useMemo)(
|
|
2043
|
+
() => resolveNameFromSrc(src, nameProp),
|
|
2044
|
+
[src, nameProp]
|
|
2045
|
+
);
|
|
2046
|
+
const [data, setData] = (0, import_react3.useState)(
|
|
2047
|
+
null
|
|
2048
|
+
);
|
|
1952
2049
|
const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
1953
2050
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
1954
2051
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -1980,13 +2077,10 @@ function RemoteComponent({
|
|
|
1980
2077
|
return elements;
|
|
1981
2078
|
})() : []
|
|
1982
2079
|
);
|
|
1983
|
-
const
|
|
2080
|
+
const hostStateRef = (0, import_react3.useRef)(createHostState());
|
|
1984
2081
|
const componentHydrationHtml = (0, import_react3.useRef)(null);
|
|
1985
|
-
const prevIsRemoteComponentRef = (0, import_react3.useRef)(false);
|
|
1986
|
-
const prevUrlRef = (0, import_react3.useRef)(null);
|
|
1987
2082
|
const prevRemoteComponentContainerRef = (0, import_react3.useRef)(null);
|
|
1988
2083
|
const unmountRef = (0, import_react3.useRef)(null);
|
|
1989
|
-
const prevNameRef = (0, import_react3.useRef)(void 0);
|
|
1990
2084
|
(0, import_react3.useLayoutEffect)(() => {
|
|
1991
2085
|
const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
|
|
1992
2086
|
return () => {
|
|
@@ -2025,14 +2119,18 @@ function RemoteComponent({
|
|
|
2025
2119
|
}
|
|
2026
2120
|
}, [shadowRoot, remoteComponent, name]);
|
|
2027
2121
|
(0, import_react3.useEffect)(() => {
|
|
2028
|
-
if (src && src !==
|
|
2029
|
-
const previousSrc =
|
|
2030
|
-
const previousName =
|
|
2031
|
-
|
|
2122
|
+
if (src && src !== hostStateRef.current.prevSrc) {
|
|
2123
|
+
const previousSrc = hostStateRef.current.prevSrc;
|
|
2124
|
+
const previousName = hostStateRef.current.prevName;
|
|
2125
|
+
hostStateRef.current.prevSrc = src;
|
|
2032
2126
|
if (previousSrc !== null) {
|
|
2033
2127
|
htmlRef.current = null;
|
|
2034
2128
|
}
|
|
2129
|
+
hostStateRef.current.abortController?.abort();
|
|
2130
|
+
hostStateRef.current.abortController = new AbortController();
|
|
2131
|
+
const { signal } = hostStateRef.current.abortController;
|
|
2035
2132
|
onBeforeLoad?.(src);
|
|
2133
|
+
hostStateRef.current.stage = "loading";
|
|
2036
2134
|
(0, import_react3.startTransition)(async () => {
|
|
2037
2135
|
try {
|
|
2038
2136
|
let html = getRemoteComponentHtml(
|
|
@@ -2046,59 +2144,41 @@ function RemoteComponent({
|
|
|
2046
2144
|
resolveClientUrl?.(url.href) ?? url.href,
|
|
2047
2145
|
location.href
|
|
2048
2146
|
);
|
|
2049
|
-
const abortController = new AbortController();
|
|
2050
2147
|
const res = await fetchWithHooks(resolvedUrl, fetchInit, {
|
|
2051
2148
|
onRequest,
|
|
2052
2149
|
onResponse,
|
|
2053
|
-
abortController
|
|
2150
|
+
abortController: hostStateRef.current.abortController
|
|
2054
2151
|
});
|
|
2055
2152
|
if (!res || !res.ok) {
|
|
2056
2153
|
throw await errorFromFailedFetch(url.href, resolvedUrl, res);
|
|
2057
2154
|
}
|
|
2058
2155
|
const remoteHtml = await res.text();
|
|
2156
|
+
if (signal.aborted)
|
|
2157
|
+
return;
|
|
2059
2158
|
htmlRef.current = remoteHtml;
|
|
2060
2159
|
html = getRemoteComponentHtml(remoteHtml);
|
|
2061
2160
|
}
|
|
2161
|
+
if (signal.aborted)
|
|
2162
|
+
return;
|
|
2062
2163
|
const parser = new DOMParser();
|
|
2063
2164
|
const doc = parser.parseFromString(html, "text/html");
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
2067
|
-
throw multipleRemoteComponentsError(url.href);
|
|
2068
|
-
}
|
|
2069
|
-
const component = doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) ?? // fallback to the first element with the data-bundle and data-route attributes when not using a named remote component
|
|
2070
|
-
doc.querySelector("div[data-bundle][data-route]") ?? // fallback to Next.js Pages Router
|
|
2071
|
-
doc.querySelector("div#__next") ?? // fallback to the remote-component web component
|
|
2072
|
-
doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
|
|
2073
|
-
const nextData = JSON.parse(
|
|
2074
|
-
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
2075
|
-
);
|
|
2076
|
-
const remoteName = component?.getAttribute("id")?.replace(/_ssr$/, "") || (nextData ? "__next" : name);
|
|
2077
|
-
const rsc = doc.querySelector(`#${remoteName}_rsc`);
|
|
2078
|
-
const bundle = component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default";
|
|
2079
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
2080
|
-
const metadata = {
|
|
2165
|
+
const {
|
|
2166
|
+
component,
|
|
2081
2167
|
name: remoteName,
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
2092
|
-
throw new RemoteComponentsError(
|
|
2093
|
-
`Remote Component not found on ${url.href}.${remoteName !== "__vercel_remote_component" ? `The name for the <RemoteComponent> is "${remoteName}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
2094
|
-
);
|
|
2095
|
-
}
|
|
2096
|
-
if (prevIsRemoteComponentRef.current) {
|
|
2168
|
+
isRemoteComponent,
|
|
2169
|
+
metadata,
|
|
2170
|
+
nextData,
|
|
2171
|
+
rsc,
|
|
2172
|
+
remoteShared,
|
|
2173
|
+
links: linkElements,
|
|
2174
|
+
scripts: scriptElements
|
|
2175
|
+
} = parseRemoteComponentDocument(doc, name, url);
|
|
2176
|
+
if (hostStateRef.current.prevIsRemoteComponent) {
|
|
2097
2177
|
if (shadowRoot) {
|
|
2098
2178
|
shadowRoot.innerHTML = "";
|
|
2099
2179
|
}
|
|
2100
2180
|
const self = globalThis;
|
|
2101
|
-
const prevUrl =
|
|
2181
|
+
const prevUrl = hostStateRef.current.prevUrl;
|
|
2102
2182
|
if (prevUrl && self.__remote_script_entrypoint_unmount__?.[prevUrl.href]) {
|
|
2103
2183
|
const unmountPromises = Promise.all(
|
|
2104
2184
|
Array.from(unmountRef.current ?? []).map(
|
|
@@ -2111,15 +2191,11 @@ function RemoteComponent({
|
|
|
2111
2191
|
await unmountPromises;
|
|
2112
2192
|
}
|
|
2113
2193
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2194
|
+
hostStateRef.current.prevIsRemoteComponent = isRemoteComponent;
|
|
2195
|
+
hostStateRef.current.prevUrl = url;
|
|
2196
|
+
hostStateRef.current.prevName = remoteName;
|
|
2117
2197
|
applyOriginToNodes(doc, url, resolveClientUrl);
|
|
2118
|
-
const links =
|
|
2119
|
-
doc.querySelectorAll("link[href]")
|
|
2120
|
-
).filter((link) => {
|
|
2121
|
-
return !component.contains(link);
|
|
2122
|
-
}).map((link) => ({
|
|
2198
|
+
const links = linkElements.map((link) => ({
|
|
2123
2199
|
href: new URL(link.getAttribute("href") ?? link.href, url).href,
|
|
2124
2200
|
...link.getAttributeNames().reduce((acc, key) => {
|
|
2125
2201
|
if (key !== "href") {
|
|
@@ -2128,7 +2204,7 @@ function RemoteComponent({
|
|
|
2128
2204
|
return acc;
|
|
2129
2205
|
}, {})
|
|
2130
2206
|
}));
|
|
2131
|
-
const scripts =
|
|
2207
|
+
const scripts = scriptElements;
|
|
2132
2208
|
const inlineScripts = (isRemoteComponent ? component : doc).querySelectorAll(
|
|
2133
2209
|
"script:not([src]):not([data-src]):not([id*='_rsc']):not([id='__NEXT_DATA__']):not([id='__REMOTE_NEXT_DATA__'])"
|
|
2134
2210
|
);
|
|
@@ -2186,11 +2262,10 @@ function RemoteComponent({
|
|
|
2186
2262
|
});
|
|
2187
2263
|
self.__next_s = prevNextScripts;
|
|
2188
2264
|
}
|
|
2189
|
-
|
|
2265
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2266
|
+
remoteName
|
|
2267
|
+
)}` : void 0;
|
|
2190
2268
|
if (rsc) {
|
|
2191
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2192
|
-
id
|
|
2193
|
-
)}_${escapeString(remoteName)}`;
|
|
2194
2269
|
rsc.textContent = rsc.textContent?.replace(
|
|
2195
2270
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2196
2271
|
`self["${rscName}"]`
|
|
@@ -2219,7 +2294,7 @@ function RemoteComponent({
|
|
|
2219
2294
|
);
|
|
2220
2295
|
}
|
|
2221
2296
|
if (isRemoteComponent) {
|
|
2222
|
-
if (previousSrc !==
|
|
2297
|
+
if (previousSrc !== void 0) {
|
|
2223
2298
|
onChange?.({
|
|
2224
2299
|
previousSrc,
|
|
2225
2300
|
nextSrc: src,
|
|
@@ -2229,10 +2304,7 @@ function RemoteComponent({
|
|
|
2229
2304
|
}
|
|
2230
2305
|
setData(newData);
|
|
2231
2306
|
if (shadowRoot) {
|
|
2232
|
-
|
|
2233
|
-
if (reset) {
|
|
2234
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2235
|
-
}
|
|
2307
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2236
2308
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2237
2309
|
htmlRef.current = null;
|
|
2238
2310
|
setRemoteComponent(null);
|
|
@@ -2270,12 +2342,13 @@ function RemoteComponent({
|
|
|
2270
2342
|
);
|
|
2271
2343
|
onLoad?.(src);
|
|
2272
2344
|
}
|
|
2345
|
+
hostStateRef.current.stage = "loaded";
|
|
2273
2346
|
} else {
|
|
2274
2347
|
const result = await loadRemoteComponent({
|
|
2275
2348
|
url,
|
|
2276
2349
|
name: remoteName,
|
|
2277
2350
|
rscName,
|
|
2278
|
-
bundle,
|
|
2351
|
+
bundle: metadata.bundle,
|
|
2279
2352
|
route: metadata.route,
|
|
2280
2353
|
runtime: metadata.runtime,
|
|
2281
2354
|
data: newData.data,
|
|
@@ -2299,7 +2372,7 @@ function RemoteComponent({
|
|
|
2299
2372
|
};
|
|
2300
2373
|
}),
|
|
2301
2374
|
shared: {
|
|
2302
|
-
...sharedPolyfills(userShared),
|
|
2375
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2303
2376
|
...userShared
|
|
2304
2377
|
},
|
|
2305
2378
|
remoteShared,
|
|
@@ -2310,7 +2383,7 @@ function RemoteComponent({
|
|
|
2310
2383
|
rsc.remove();
|
|
2311
2384
|
}
|
|
2312
2385
|
setData(newData);
|
|
2313
|
-
if (previousSrc !==
|
|
2386
|
+
if (previousSrc !== void 0) {
|
|
2314
2387
|
onChange?.({
|
|
2315
2388
|
previousSrc,
|
|
2316
2389
|
nextSrc: src,
|
|
@@ -2319,17 +2392,21 @@ function RemoteComponent({
|
|
|
2319
2392
|
});
|
|
2320
2393
|
}
|
|
2321
2394
|
if (result.error) {
|
|
2395
|
+
hostStateRef.current.stage = "error";
|
|
2322
2396
|
setRemoteComponent(result.error);
|
|
2323
2397
|
onError?.(result.error);
|
|
2324
2398
|
} else {
|
|
2399
|
+
hostStateRef.current.stage = "loaded";
|
|
2325
2400
|
setRemoteComponent(result.component);
|
|
2326
2401
|
onLoad?.(src);
|
|
2327
2402
|
}
|
|
2328
2403
|
}
|
|
2329
2404
|
} catch (error) {
|
|
2330
2405
|
if (isAbortError(error)) {
|
|
2406
|
+
hostStateRef.current.stage = "idle";
|
|
2331
2407
|
return;
|
|
2332
2408
|
}
|
|
2409
|
+
hostStateRef.current.stage = "error";
|
|
2333
2410
|
setRemoteComponent(error);
|
|
2334
2411
|
onError?.(error);
|
|
2335
2412
|
}
|
|
@@ -2360,7 +2437,7 @@ function RemoteComponent({
|
|
|
2360
2437
|
name: data?.name || name,
|
|
2361
2438
|
bundle: data?.bundle || "default",
|
|
2362
2439
|
route: data?.route || DEFAULT_ROUTE,
|
|
2363
|
-
runtime:
|
|
2440
|
+
runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
2364
2441
|
}) });
|
|
2365
2442
|
const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
2366
2443
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
|
|
@@ -2379,7 +2456,7 @@ function RemoteComponent({
|
|
|
2379
2456
|
if (componentHydrationHtml.current && shadowRoot && !shadowRoot.innerHTML) {
|
|
2380
2457
|
shadowRoot.innerHTML = componentHydrationHtml.current;
|
|
2381
2458
|
componentHydrationHtml.current = null;
|
|
2382
|
-
if (
|
|
2459
|
+
if (hostStateRef.current.prevIsRemoteComponent) {
|
|
2383
2460
|
loadStaticRemoteComponent(
|
|
2384
2461
|
Array.from(shadowRoot.querySelectorAll("script")),
|
|
2385
2462
|
url,
|
|
@@ -2467,8 +2544,6 @@ function RemoteComponent({
|
|
|
2467
2544
|
}
|
|
2468
2545
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2469
2546
|
0 && (module.exports = {
|
|
2470
|
-
|
|
2471
|
-
RemoteComponentsProvider,
|
|
2472
|
-
proxyClientRequestsThroughHost
|
|
2547
|
+
ConsumeRemoteComponent
|
|
2473
2548
|
});
|
|
2474
|
-
//# sourceMappingURL=
|
|
2549
|
+
//# sourceMappingURL=react.cjs.map
|