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
|
@@ -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,7 +118,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
183
118
|
);
|
|
184
119
|
}
|
|
185
120
|
|
|
186
|
-
// src/
|
|
121
|
+
// src/utils/logger.ts
|
|
187
122
|
var PREFIX = "remote-components";
|
|
188
123
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
189
124
|
function logDebug(location2, message) {
|
|
@@ -209,13 +144,68 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
209
144
|
}
|
|
210
145
|
logWarn(
|
|
211
146
|
logLocation,
|
|
212
|
-
`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}`
|
|
213
148
|
);
|
|
214
149
|
} catch {
|
|
215
150
|
}
|
|
216
151
|
}
|
|
217
152
|
|
|
218
|
-
// 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
|
|
219
209
|
import { jsx } from "react/jsx-runtime";
|
|
220
210
|
function applyBundleUrlToSrc(bundle, src) {
|
|
221
211
|
const self = globalThis;
|
|
@@ -235,7 +225,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
235
225
|
const propSrc = src;
|
|
236
226
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
237
227
|
}
|
|
238
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
228
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
239
229
|
fill: _fill,
|
|
240
230
|
loader: _loader,
|
|
241
231
|
quality: _quality,
|
|
@@ -252,6 +242,7 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
252
242
|
bundle,
|
|
253
243
|
typeof src === "string" ? src : src.src
|
|
254
244
|
);
|
|
245
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
255
246
|
return (
|
|
256
247
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
257
248
|
/* @__PURE__ */ jsx(
|
|
@@ -260,13 +251,13 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
260
251
|
decoding: "async",
|
|
261
252
|
style: { color: "transparent" },
|
|
262
253
|
...props,
|
|
263
|
-
src:
|
|
254
|
+
src: proxiedSrc,
|
|
264
255
|
suppressHydrationWarning: true
|
|
265
256
|
}
|
|
266
257
|
)
|
|
267
258
|
);
|
|
268
259
|
};
|
|
269
|
-
function sharedPolyfills(shared) {
|
|
260
|
+
function sharedPolyfills(shared, resolveClientUrl) {
|
|
270
261
|
const self = globalThis;
|
|
271
262
|
const polyfill = {
|
|
272
263
|
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
@@ -357,11 +348,11 @@ function sharedPolyfills(shared) {
|
|
|
357
348
|
__esModule: true
|
|
358
349
|
})),
|
|
359
350
|
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
360
|
-
Image: imageImpl(bundle),
|
|
351
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
361
352
|
__esModule: true
|
|
362
353
|
})),
|
|
363
354
|
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
364
|
-
default: imageImpl(bundle),
|
|
355
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
365
356
|
getImageProps: (_imgProps) => {
|
|
366
357
|
throw new Error(
|
|
367
358
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -411,14 +402,319 @@ function sharedPolyfills(shared) {
|
|
|
411
402
|
return polyfill;
|
|
412
403
|
}
|
|
413
404
|
|
|
414
|
-
// src/shared/
|
|
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
|
+
}
|
|
416
|
+
|
|
417
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
418
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
419
|
+
if (!src) {
|
|
420
|
+
return defaultName;
|
|
421
|
+
}
|
|
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
|
|
415
653
|
import * as React from "react";
|
|
416
654
|
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
417
655
|
import * as JSXRuntime from "react/jsx-runtime";
|
|
418
656
|
import * as ReactDOM from "react-dom";
|
|
419
657
|
import * as ReactDOMClient from "react-dom/client";
|
|
420
658
|
|
|
421
|
-
// src/
|
|
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
|
|
422
718
|
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
423
719
|
const self = globalThis;
|
|
424
720
|
const nextCssOriginal = document.querySelector(
|
|
@@ -487,111 +783,50 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
487
783
|
if (!self.__remote_next_css__) {
|
|
488
784
|
self.__remote_next_css__ = {};
|
|
489
785
|
}
|
|
490
|
-
if (!self.__remote_next_css__[bundle]) {
|
|
491
|
-
const cssRE = /\.s?css$/;
|
|
492
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
493
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
494
|
-
});
|
|
495
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
496
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
497
|
-
if (id) {
|
|
498
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
const elements = [];
|
|
502
|
-
let node = nextCss.previousSibling;
|
|
503
|
-
while (node && node !== nextCssEnd) {
|
|
504
|
-
elements.push(node);
|
|
505
|
-
node.remove();
|
|
506
|
-
node = nextCss.previousSibling;
|
|
507
|
-
}
|
|
508
|
-
self.__remote_next_css__[bundle] = elements;
|
|
509
|
-
}
|
|
510
|
-
if (styleContainer) {
|
|
511
|
-
const elements = self.__remote_next_css__[bundle];
|
|
512
|
-
elements.forEach((el) => {
|
|
513
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
514
|
-
});
|
|
515
|
-
} else {
|
|
516
|
-
const elements = self.__remote_next_css__[bundle];
|
|
517
|
-
elements.forEach((el) => {
|
|
518
|
-
document.head.appendChild(el);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
delete self.__NEXT_P;
|
|
522
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
523
|
-
if (nextCssOriginal) {
|
|
524
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
525
|
-
}
|
|
526
|
-
nextCss.remove();
|
|
527
|
-
nextCssEnd.remove();
|
|
528
|
-
return { Component, App };
|
|
529
|
-
}
|
|
530
|
-
return { Component: null, App: null };
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// src/shared/webpack/shared-modules.ts
|
|
534
|
-
function applySharedModules(bundle, resolve) {
|
|
535
|
-
logDebug(
|
|
536
|
-
"SharedModules",
|
|
537
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
538
|
-
);
|
|
539
|
-
logDebug(
|
|
540
|
-
"SharedModules",
|
|
541
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
542
|
-
);
|
|
543
|
-
const self = globalThis;
|
|
544
|
-
if (self.__remote_webpack_require__?.[bundle]) {
|
|
545
|
-
const modulePaths = Object.keys(
|
|
546
|
-
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
547
|
-
);
|
|
548
|
-
logDebug(
|
|
549
|
-
"SharedModules",
|
|
550
|
-
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
551
|
-
);
|
|
552
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
553
|
-
let ids = modulePaths.filter((p) => p === key);
|
|
554
|
-
if (ids.length === 0) {
|
|
555
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
556
|
-
}
|
|
557
|
-
if (ids.length === 0) {
|
|
558
|
-
logDebug(
|
|
559
|
-
"SharedModules",
|
|
560
|
-
`No matching module path found for shared module "${key}"`
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
|
-
for (let id of ids) {
|
|
564
|
-
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
565
|
-
if (webpackBundle.m) {
|
|
566
|
-
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
567
|
-
const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
568
|
-
logDebug(
|
|
569
|
-
"SharedModules",
|
|
570
|
-
`Mapped module id: "${id}" -> "${mappedId}"`
|
|
571
|
-
);
|
|
572
|
-
id = mappedId;
|
|
573
|
-
}
|
|
574
|
-
webpackBundle.m[id] = (module) => {
|
|
575
|
-
module.exports = value;
|
|
576
|
-
};
|
|
577
|
-
} else {
|
|
578
|
-
logWarn(
|
|
579
|
-
"SharedModules",
|
|
580
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
581
|
-
);
|
|
786
|
+
if (!self.__remote_next_css__[bundle]) {
|
|
787
|
+
const cssRE = /\.s?css$/;
|
|
788
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
789
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
790
|
+
});
|
|
791
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
792
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
793
|
+
if (id) {
|
|
794
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
582
795
|
}
|
|
796
|
+
});
|
|
797
|
+
const elements = [];
|
|
798
|
+
let node = nextCss.previousSibling;
|
|
799
|
+
while (node && node !== nextCssEnd) {
|
|
800
|
+
elements.push(node);
|
|
801
|
+
node.remove();
|
|
802
|
+
node = nextCss.previousSibling;
|
|
583
803
|
}
|
|
804
|
+
self.__remote_next_css__[bundle] = elements;
|
|
584
805
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
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 };
|
|
591
825
|
}
|
|
826
|
+
return { Component: null, App: null };
|
|
592
827
|
}
|
|
593
828
|
|
|
594
|
-
// src/
|
|
829
|
+
// src/runtime/rsc.ts
|
|
595
830
|
import { ReadableStream } from "web-streams-polyfill";
|
|
596
831
|
function fixPayload(payload) {
|
|
597
832
|
if (Array.isArray(payload)) {
|
|
@@ -657,78 +892,15 @@ function createRSCStream(rscName, data) {
|
|
|
657
892
|
});
|
|
658
893
|
}
|
|
659
894
|
|
|
660
|
-
// src/
|
|
661
|
-
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
662
|
-
|
|
663
|
-
// src/shared/client/script-loader.ts
|
|
664
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
665
|
-
await Promise.all(
|
|
666
|
-
scripts.map((script) => {
|
|
667
|
-
return new Promise((resolve, reject) => {
|
|
668
|
-
const newSrc = new URL(
|
|
669
|
-
// remove the remote component bundle name identifier from the script src
|
|
670
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
671
|
-
location.origin
|
|
672
|
-
).href;
|
|
673
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
674
|
-
const newScript = document.createElement("script");
|
|
675
|
-
newScript.onload = () => resolve();
|
|
676
|
-
newScript.onerror = () => {
|
|
677
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
678
|
-
if (isProxied) {
|
|
679
|
-
reject(
|
|
680
|
-
new RemoteComponentsError(
|
|
681
|
-
`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}`
|
|
682
|
-
)
|
|
683
|
-
);
|
|
684
|
-
} else {
|
|
685
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
686
|
-
reject(
|
|
687
|
-
new RemoteComponentsError(
|
|
688
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
689
|
-
)
|
|
690
|
-
);
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
newScript.src = resolvedSrc;
|
|
694
|
-
newScript.async = true;
|
|
695
|
-
document.head.appendChild(newScript);
|
|
696
|
-
});
|
|
697
|
-
})
|
|
698
|
-
);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// src/shared/utils/index.ts
|
|
702
|
-
function escapeString(str) {
|
|
703
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
704
|
-
}
|
|
705
|
-
var attrToProp = {
|
|
706
|
-
fetchpriority: "fetchPriority",
|
|
707
|
-
crossorigin: "crossOrigin",
|
|
708
|
-
imagesrcset: "imageSrcSet",
|
|
709
|
-
imagesizes: "imageSizes",
|
|
710
|
-
srcset: "srcSet"
|
|
711
|
-
};
|
|
712
|
-
|
|
713
|
-
// src/shared/client/const.ts
|
|
714
|
-
var DEFAULT_ROUTE = "/";
|
|
715
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
716
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
717
|
-
var RUNTIME_SCRIPT = "script";
|
|
718
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
719
|
-
function getBundleKey(bundle) {
|
|
720
|
-
return escapeString(bundle);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// src/shared/client/turbopack-patterns.ts
|
|
895
|
+
// src/runtime/turbopack/patterns.ts
|
|
724
896
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
725
|
-
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]+)\)/;
|
|
726
898
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
727
899
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
728
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]+)\)\)\)\}/;
|
|
729
901
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
730
902
|
|
|
731
|
-
// src/
|
|
903
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
732
904
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
733
905
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
734
906
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -790,7 +962,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
790
962
|
if (isProxied) {
|
|
791
963
|
reject(
|
|
792
964
|
new RemoteComponentsError(
|
|
793
|
-
`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}`
|
|
794
966
|
)
|
|
795
967
|
);
|
|
796
968
|
} else {
|
|
@@ -940,7 +1112,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
940
1112
|
}
|
|
941
1113
|
}
|
|
942
1114
|
|
|
943
|
-
// src/
|
|
1115
|
+
// src/runtime/turbopack/module.ts
|
|
944
1116
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
945
1117
|
const self = globalThis;
|
|
946
1118
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1169,7 +1341,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1169
1341
|
};
|
|
1170
1342
|
}
|
|
1171
1343
|
|
|
1172
|
-
// src/
|
|
1344
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1173
1345
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1174
1346
|
const self = globalThis;
|
|
1175
1347
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1289,7 +1461,7 @@ function getSharedModule(bundle, id) {
|
|
|
1289
1461
|
return null;
|
|
1290
1462
|
}
|
|
1291
1463
|
|
|
1292
|
-
// src/
|
|
1464
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1293
1465
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1294
1466
|
const self = globalThis;
|
|
1295
1467
|
if (!self.__remote_bundle_url__) {
|
|
@@ -1344,7 +1516,7 @@ function createModuleRequire(runtime) {
|
|
|
1344
1516
|
id
|
|
1345
1517
|
};
|
|
1346
1518
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1347
|
-
logDebug("
|
|
1519
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1348
1520
|
try {
|
|
1349
1521
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1350
1522
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1360,7 +1532,7 @@ function createModuleRequire(runtime) {
|
|
|
1360
1532
|
throw new Error(`Module "${id}" not found.`);
|
|
1361
1533
|
} catch (requireError) {
|
|
1362
1534
|
logWarn(
|
|
1363
|
-
"
|
|
1535
|
+
"WebpackRuntime",
|
|
1364
1536
|
`Module require failed: ${String(requireError)}`
|
|
1365
1537
|
);
|
|
1366
1538
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1372,7 +1544,7 @@ function createModuleRequire(runtime) {
|
|
|
1372
1544
|
);
|
|
1373
1545
|
}
|
|
1374
1546
|
try {
|
|
1375
|
-
logDebug("
|
|
1547
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1376
1548
|
return self.__original_webpack_require__(id);
|
|
1377
1549
|
} catch (originalError) {
|
|
1378
1550
|
throw new RemoteComponentsError(
|
|
@@ -1384,7 +1556,45 @@ function createModuleRequire(runtime) {
|
|
|
1384
1556
|
};
|
|
1385
1557
|
}
|
|
1386
1558
|
|
|
1387
|
-
// 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
|
|
1388
1598
|
async function loadRemoteComponent({
|
|
1389
1599
|
url,
|
|
1390
1600
|
name,
|
|
@@ -1487,17 +1697,19 @@ async function loadRemoteComponent({
|
|
|
1487
1697
|
};
|
|
1488
1698
|
}
|
|
1489
1699
|
}
|
|
1490
|
-
async function
|
|
1491
|
-
let createFromReadableStream;
|
|
1700
|
+
async function importCreateFromReadableStream() {
|
|
1492
1701
|
try {
|
|
1493
|
-
const { createFromReadableStream
|
|
1494
|
-
createFromReadableStream
|
|
1702
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1703
|
+
return createFromReadableStream;
|
|
1495
1704
|
} catch {
|
|
1496
1705
|
const {
|
|
1497
|
-
default: { createFromReadableStream
|
|
1706
|
+
default: { createFromReadableStream }
|
|
1498
1707
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1499
|
-
createFromReadableStream
|
|
1708
|
+
return createFromReadableStream;
|
|
1500
1709
|
}
|
|
1710
|
+
}
|
|
1711
|
+
async function loadRSCComponent(rscName, data) {
|
|
1712
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1501
1713
|
if (typeof createFromReadableStream !== "function") {
|
|
1502
1714
|
throw new RemoteComponentsError(
|
|
1503
1715
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1518,71 +1730,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1518
1730
|
return { component };
|
|
1519
1731
|
}
|
|
1520
1732
|
|
|
1521
|
-
// src/
|
|
1522
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1523
|
-
return (url) => resolveClientUrl(remoteSrc, url);
|
|
1524
|
-
}
|
|
1525
|
-
var proxyClientRequestsThroughHost = (remoteSrc, url) => {
|
|
1526
|
-
if (typeof location === "undefined") {
|
|
1527
|
-
return void 0;
|
|
1528
|
-
}
|
|
1529
|
-
const remoteOrigin = new URL(remoteSrc, location.href).origin;
|
|
1530
|
-
if (remoteOrigin === location.origin) {
|
|
1531
|
-
return void 0;
|
|
1532
|
-
}
|
|
1533
|
-
try {
|
|
1534
|
-
const parsed = new URL(url, location.href);
|
|
1535
|
-
if (parsed.origin === remoteOrigin) {
|
|
1536
|
-
return generateProtectedRcFallbackSrc(url);
|
|
1537
|
-
}
|
|
1538
|
-
} catch {
|
|
1539
|
-
}
|
|
1540
|
-
return void 0;
|
|
1541
|
-
};
|
|
1542
|
-
|
|
1543
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1544
|
-
var DOMAttributeNames = {
|
|
1545
|
-
acceptCharset: "accept-charset",
|
|
1546
|
-
className: "class",
|
|
1547
|
-
htmlFor: "for",
|
|
1548
|
-
httpEquiv: "http-equiv",
|
|
1549
|
-
noModule: "noModule"
|
|
1550
|
-
};
|
|
1551
|
-
var ignoreProps = [
|
|
1552
|
-
"onLoad",
|
|
1553
|
-
"onReady",
|
|
1554
|
-
"dangerouslySetInnerHTML",
|
|
1555
|
-
"children",
|
|
1556
|
-
"onError",
|
|
1557
|
-
"strategy",
|
|
1558
|
-
"stylesheets"
|
|
1559
|
-
];
|
|
1560
|
-
function isBooleanScriptAttribute(attr) {
|
|
1561
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1562
|
-
}
|
|
1563
|
-
function setAttributesFromProps(el, props) {
|
|
1564
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1565
|
-
if (!Object.hasOwn(props, p))
|
|
1566
|
-
continue;
|
|
1567
|
-
if (ignoreProps.includes(p))
|
|
1568
|
-
continue;
|
|
1569
|
-
if (value === void 0) {
|
|
1570
|
-
continue;
|
|
1571
|
-
}
|
|
1572
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1573
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1574
|
-
el[attr] = Boolean(value);
|
|
1575
|
-
} else {
|
|
1576
|
-
el.setAttribute(attr, String(value));
|
|
1577
|
-
}
|
|
1578
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1579
|
-
el.setAttribute(attr, "");
|
|
1580
|
-
el.removeAttribute(attr);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// src/shared/client/static-loader.ts
|
|
1733
|
+
// src/runtime/loaders/static-loader.ts
|
|
1586
1734
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1587
1735
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1588
1736
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1732,75 +1880,35 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1732
1880
|
);
|
|
1733
1881
|
}
|
|
1734
1882
|
|
|
1735
|
-
// src/
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
/**
|
|
1739
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1740
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1741
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1742
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1743
|
-
*/
|
|
1744
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1745
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1746
|
-
} : {},
|
|
1747
|
-
Accept: "text/html"
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1883
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1884
|
+
import { useMemo } from "react";
|
|
1885
|
+
import { useRemoteComponentsContext } from "#internal/host/react/context";
|
|
1750
1886
|
|
|
1751
|
-
// src/
|
|
1752
|
-
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
const signal = abortController.signal;
|
|
1759
|
-
const hookOptions = {
|
|
1760
|
-
signal,
|
|
1761
|
-
abort: (reason) => abortController.abort(reason)
|
|
1762
|
-
};
|
|
1763
|
-
const init = {
|
|
1764
|
-
method: "GET",
|
|
1765
|
-
headers: remoteFetchHeaders(),
|
|
1766
|
-
signal,
|
|
1767
|
-
...additionalInit
|
|
1768
|
-
};
|
|
1769
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1770
|
-
if (!res) {
|
|
1771
|
-
try {
|
|
1772
|
-
res = await fetch(url, init);
|
|
1773
|
-
} catch (error) {
|
|
1774
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1775
|
-
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;
|
|
1776
1894
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
if (transformedRes) {
|
|
1780
|
-
res = transformedRes;
|
|
1781
|
-
}
|
|
1782
|
-
return res;
|
|
1895
|
+
return resolveClientUrl(remoteSrc, url);
|
|
1896
|
+
};
|
|
1783
1897
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
return new URL(fallback);
|
|
1898
|
+
function parseOrigin(url) {
|
|
1899
|
+
try {
|
|
1900
|
+
return new URL(url).origin;
|
|
1901
|
+
} catch {
|
|
1902
|
+
return void 0;
|
|
1790
1903
|
}
|
|
1791
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1792
1904
|
}
|
|
1793
1905
|
|
|
1794
|
-
// src/
|
|
1795
|
-
import { useMemo } from "react";
|
|
1796
|
-
import { useRemoteComponentsContext } from "#internal/react/context";
|
|
1797
|
-
|
|
1798
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1906
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
1799
1907
|
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1800
1908
|
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1801
1909
|
}
|
|
1802
1910
|
|
|
1803
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
1911
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1804
1912
|
function useResolveClientUrl(prop, urlHref) {
|
|
1805
1913
|
const { resolveClientUrl: contextValue } = useRemoteComponentsContext();
|
|
1806
1914
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1810,7 +1918,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1810
1918
|
);
|
|
1811
1919
|
}
|
|
1812
1920
|
|
|
1813
|
-
// src/react/hooks/use-shadow-root.ts
|
|
1921
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1814
1922
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
1815
1923
|
function useShadowRoot({
|
|
1816
1924
|
isolate,
|
|
@@ -1859,7 +1967,7 @@ function useShadowRoot({
|
|
|
1859
1967
|
return { shadowRoot, shadowRootContainerRef };
|
|
1860
1968
|
}
|
|
1861
1969
|
|
|
1862
|
-
// src/react/utils/
|
|
1970
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
1863
1971
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
1864
1972
|
function getRemoteComponentHtml(html) {
|
|
1865
1973
|
if (typeof document === "undefined")
|
|
@@ -1881,11 +1989,10 @@ function getRemoteComponentHtml(html) {
|
|
|
1881
1989
|
return "";
|
|
1882
1990
|
}
|
|
1883
1991
|
|
|
1884
|
-
// src/react/index.tsx
|
|
1885
|
-
import { RemoteComponentsProvider } from "#internal/react/context";
|
|
1992
|
+
// src/host/react/index.tsx
|
|
1886
1993
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1887
1994
|
import { createElement as createElement2 } from "react";
|
|
1888
|
-
function
|
|
1995
|
+
function ConsumeRemoteComponent({
|
|
1889
1996
|
src,
|
|
1890
1997
|
isolate,
|
|
1891
1998
|
mode = "open",
|
|
@@ -1903,21 +2010,13 @@ function RemoteComponent({
|
|
|
1903
2010
|
resolveClientUrl: _resolveClientUrl
|
|
1904
2011
|
}) {
|
|
1905
2012
|
const instanceId = useId();
|
|
1906
|
-
const name = useMemo2(
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
return url2.hash.slice(1);
|
|
1914
|
-
}
|
|
1915
|
-
} else if (typeof src === "object" && "hash" in src && src.hash) {
|
|
1916
|
-
return src.hash.slice(1) || nameProp;
|
|
1917
|
-
}
|
|
1918
|
-
return nameProp;
|
|
1919
|
-
}, [src, nameProp]);
|
|
1920
|
-
const [data, setData] = useState2(null);
|
|
2013
|
+
const name = useMemo2(
|
|
2014
|
+
() => resolveNameFromSrc(src, nameProp),
|
|
2015
|
+
[src, nameProp]
|
|
2016
|
+
);
|
|
2017
|
+
const [data, setData] = useState2(
|
|
2018
|
+
null
|
|
2019
|
+
);
|
|
1921
2020
|
const url = useMemo2(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
1922
2021
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
1923
2022
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -1949,13 +2048,10 @@ function RemoteComponent({
|
|
|
1949
2048
|
return elements;
|
|
1950
2049
|
})() : []
|
|
1951
2050
|
);
|
|
1952
|
-
const
|
|
2051
|
+
const hostStateRef = useRef2(createHostState());
|
|
1953
2052
|
const componentHydrationHtml = useRef2(null);
|
|
1954
|
-
const prevIsRemoteComponentRef = useRef2(false);
|
|
1955
|
-
const prevUrlRef = useRef2(null);
|
|
1956
2053
|
const prevRemoteComponentContainerRef = useRef2(null);
|
|
1957
2054
|
const unmountRef = useRef2(null);
|
|
1958
|
-
const prevNameRef = useRef2(void 0);
|
|
1959
2055
|
useLayoutEffect2(() => {
|
|
1960
2056
|
const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
|
|
1961
2057
|
return () => {
|
|
@@ -1994,14 +2090,18 @@ function RemoteComponent({
|
|
|
1994
2090
|
}
|
|
1995
2091
|
}, [shadowRoot, remoteComponent, name]);
|
|
1996
2092
|
useEffect(() => {
|
|
1997
|
-
if (src && src !==
|
|
1998
|
-
const previousSrc =
|
|
1999
|
-
const previousName =
|
|
2000
|
-
|
|
2093
|
+
if (src && src !== hostStateRef.current.prevSrc) {
|
|
2094
|
+
const previousSrc = hostStateRef.current.prevSrc;
|
|
2095
|
+
const previousName = hostStateRef.current.prevName;
|
|
2096
|
+
hostStateRef.current.prevSrc = src;
|
|
2001
2097
|
if (previousSrc !== null) {
|
|
2002
2098
|
htmlRef.current = null;
|
|
2003
2099
|
}
|
|
2100
|
+
hostStateRef.current.abortController?.abort();
|
|
2101
|
+
hostStateRef.current.abortController = new AbortController();
|
|
2102
|
+
const { signal } = hostStateRef.current.abortController;
|
|
2004
2103
|
onBeforeLoad?.(src);
|
|
2104
|
+
hostStateRef.current.stage = "loading";
|
|
2005
2105
|
startTransition(async () => {
|
|
2006
2106
|
try {
|
|
2007
2107
|
let html = getRemoteComponentHtml(
|
|
@@ -2015,59 +2115,41 @@ function RemoteComponent({
|
|
|
2015
2115
|
resolveClientUrl?.(url.href) ?? url.href,
|
|
2016
2116
|
location.href
|
|
2017
2117
|
);
|
|
2018
|
-
const abortController = new AbortController();
|
|
2019
2118
|
const res = await fetchWithHooks(resolvedUrl, fetchInit, {
|
|
2020
2119
|
onRequest,
|
|
2021
2120
|
onResponse,
|
|
2022
|
-
abortController
|
|
2121
|
+
abortController: hostStateRef.current.abortController
|
|
2023
2122
|
});
|
|
2024
2123
|
if (!res || !res.ok) {
|
|
2025
2124
|
throw await errorFromFailedFetch(url.href, resolvedUrl, res);
|
|
2026
2125
|
}
|
|
2027
2126
|
const remoteHtml = await res.text();
|
|
2127
|
+
if (signal.aborted)
|
|
2128
|
+
return;
|
|
2028
2129
|
htmlRef.current = remoteHtml;
|
|
2029
2130
|
html = getRemoteComponentHtml(remoteHtml);
|
|
2030
2131
|
}
|
|
2132
|
+
if (signal.aborted)
|
|
2133
|
+
return;
|
|
2031
2134
|
const parser = new DOMParser();
|
|
2032
2135
|
const doc = parser.parseFromString(html, "text/html");
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
2036
|
-
throw multipleRemoteComponentsError(url.href);
|
|
2037
|
-
}
|
|
2038
|
-
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
|
|
2039
|
-
doc.querySelector("div[data-bundle][data-route]") ?? // fallback to Next.js Pages Router
|
|
2040
|
-
doc.querySelector("div#__next") ?? // fallback to the remote-component web component
|
|
2041
|
-
doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
|
|
2042
|
-
const nextData = JSON.parse(
|
|
2043
|
-
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
2044
|
-
);
|
|
2045
|
-
const remoteName = component?.getAttribute("id")?.replace(/_ssr$/, "") || (nextData ? "__next" : name);
|
|
2046
|
-
const rsc = doc.querySelector(`#${remoteName}_rsc`);
|
|
2047
|
-
const bundle = component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default";
|
|
2048
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
2049
|
-
const metadata = {
|
|
2136
|
+
const {
|
|
2137
|
+
component,
|
|
2050
2138
|
name: remoteName,
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
2061
|
-
throw new RemoteComponentsError(
|
|
2062
|
-
`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>?`
|
|
2063
|
-
);
|
|
2064
|
-
}
|
|
2065
|
-
if (prevIsRemoteComponentRef.current) {
|
|
2139
|
+
isRemoteComponent,
|
|
2140
|
+
metadata,
|
|
2141
|
+
nextData,
|
|
2142
|
+
rsc,
|
|
2143
|
+
remoteShared,
|
|
2144
|
+
links: linkElements,
|
|
2145
|
+
scripts: scriptElements
|
|
2146
|
+
} = parseRemoteComponentDocument(doc, name, url);
|
|
2147
|
+
if (hostStateRef.current.prevIsRemoteComponent) {
|
|
2066
2148
|
if (shadowRoot) {
|
|
2067
2149
|
shadowRoot.innerHTML = "";
|
|
2068
2150
|
}
|
|
2069
2151
|
const self = globalThis;
|
|
2070
|
-
const prevUrl =
|
|
2152
|
+
const prevUrl = hostStateRef.current.prevUrl;
|
|
2071
2153
|
if (prevUrl && self.__remote_script_entrypoint_unmount__?.[prevUrl.href]) {
|
|
2072
2154
|
const unmountPromises = Promise.all(
|
|
2073
2155
|
Array.from(unmountRef.current ?? []).map(
|
|
@@ -2080,15 +2162,11 @@ function RemoteComponent({
|
|
|
2080
2162
|
await unmountPromises;
|
|
2081
2163
|
}
|
|
2082
2164
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2165
|
+
hostStateRef.current.prevIsRemoteComponent = isRemoteComponent;
|
|
2166
|
+
hostStateRef.current.prevUrl = url;
|
|
2167
|
+
hostStateRef.current.prevName = remoteName;
|
|
2086
2168
|
applyOriginToNodes(doc, url, resolveClientUrl);
|
|
2087
|
-
const links =
|
|
2088
|
-
doc.querySelectorAll("link[href]")
|
|
2089
|
-
).filter((link) => {
|
|
2090
|
-
return !component.contains(link);
|
|
2091
|
-
}).map((link) => ({
|
|
2169
|
+
const links = linkElements.map((link) => ({
|
|
2092
2170
|
href: new URL(link.getAttribute("href") ?? link.href, url).href,
|
|
2093
2171
|
...link.getAttributeNames().reduce((acc, key) => {
|
|
2094
2172
|
if (key !== "href") {
|
|
@@ -2097,7 +2175,7 @@ function RemoteComponent({
|
|
|
2097
2175
|
return acc;
|
|
2098
2176
|
}, {})
|
|
2099
2177
|
}));
|
|
2100
|
-
const scripts =
|
|
2178
|
+
const scripts = scriptElements;
|
|
2101
2179
|
const inlineScripts = (isRemoteComponent ? component : doc).querySelectorAll(
|
|
2102
2180
|
"script:not([src]):not([data-src]):not([id*='_rsc']):not([id='__NEXT_DATA__']):not([id='__REMOTE_NEXT_DATA__'])"
|
|
2103
2181
|
);
|
|
@@ -2155,11 +2233,10 @@ function RemoteComponent({
|
|
|
2155
2233
|
});
|
|
2156
2234
|
self.__next_s = prevNextScripts;
|
|
2157
2235
|
}
|
|
2158
|
-
|
|
2236
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2237
|
+
remoteName
|
|
2238
|
+
)}` : void 0;
|
|
2159
2239
|
if (rsc) {
|
|
2160
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2161
|
-
id
|
|
2162
|
-
)}_${escapeString(remoteName)}`;
|
|
2163
2240
|
rsc.textContent = rsc.textContent?.replace(
|
|
2164
2241
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2165
2242
|
`self["${rscName}"]`
|
|
@@ -2188,7 +2265,7 @@ function RemoteComponent({
|
|
|
2188
2265
|
);
|
|
2189
2266
|
}
|
|
2190
2267
|
if (isRemoteComponent) {
|
|
2191
|
-
if (previousSrc !==
|
|
2268
|
+
if (previousSrc !== void 0) {
|
|
2192
2269
|
onChange?.({
|
|
2193
2270
|
previousSrc,
|
|
2194
2271
|
nextSrc: src,
|
|
@@ -2198,10 +2275,7 @@ function RemoteComponent({
|
|
|
2198
2275
|
}
|
|
2199
2276
|
setData(newData);
|
|
2200
2277
|
if (shadowRoot) {
|
|
2201
|
-
|
|
2202
|
-
if (reset) {
|
|
2203
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2204
|
-
}
|
|
2278
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2205
2279
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2206
2280
|
htmlRef.current = null;
|
|
2207
2281
|
setRemoteComponent(null);
|
|
@@ -2240,12 +2314,13 @@ function RemoteComponent({
|
|
|
2240
2314
|
);
|
|
2241
2315
|
onLoad?.(src);
|
|
2242
2316
|
}
|
|
2317
|
+
hostStateRef.current.stage = "loaded";
|
|
2243
2318
|
} else {
|
|
2244
2319
|
const result = await loadRemoteComponent({
|
|
2245
2320
|
url,
|
|
2246
2321
|
name: remoteName,
|
|
2247
2322
|
rscName,
|
|
2248
|
-
bundle,
|
|
2323
|
+
bundle: metadata.bundle,
|
|
2249
2324
|
route: metadata.route,
|
|
2250
2325
|
runtime: metadata.runtime,
|
|
2251
2326
|
data: newData.data,
|
|
@@ -2269,7 +2344,7 @@ function RemoteComponent({
|
|
|
2269
2344
|
};
|
|
2270
2345
|
}),
|
|
2271
2346
|
shared: {
|
|
2272
|
-
...sharedPolyfills(userShared),
|
|
2347
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2273
2348
|
...userShared
|
|
2274
2349
|
},
|
|
2275
2350
|
remoteShared,
|
|
@@ -2280,7 +2355,7 @@ function RemoteComponent({
|
|
|
2280
2355
|
rsc.remove();
|
|
2281
2356
|
}
|
|
2282
2357
|
setData(newData);
|
|
2283
|
-
if (previousSrc !==
|
|
2358
|
+
if (previousSrc !== void 0) {
|
|
2284
2359
|
onChange?.({
|
|
2285
2360
|
previousSrc,
|
|
2286
2361
|
nextSrc: src,
|
|
@@ -2289,17 +2364,21 @@ function RemoteComponent({
|
|
|
2289
2364
|
});
|
|
2290
2365
|
}
|
|
2291
2366
|
if (result.error) {
|
|
2367
|
+
hostStateRef.current.stage = "error";
|
|
2292
2368
|
setRemoteComponent(result.error);
|
|
2293
2369
|
onError?.(result.error);
|
|
2294
2370
|
} else {
|
|
2371
|
+
hostStateRef.current.stage = "loaded";
|
|
2295
2372
|
setRemoteComponent(result.component);
|
|
2296
2373
|
onLoad?.(src);
|
|
2297
2374
|
}
|
|
2298
2375
|
}
|
|
2299
2376
|
} catch (error) {
|
|
2300
2377
|
if (isAbortError(error)) {
|
|
2378
|
+
hostStateRef.current.stage = "idle";
|
|
2301
2379
|
return;
|
|
2302
2380
|
}
|
|
2381
|
+
hostStateRef.current.stage = "error";
|
|
2303
2382
|
setRemoteComponent(error);
|
|
2304
2383
|
onError?.(error);
|
|
2305
2384
|
}
|
|
@@ -2330,7 +2409,7 @@ function RemoteComponent({
|
|
|
2330
2409
|
name: data?.name || name,
|
|
2331
2410
|
bundle: data?.bundle || "default",
|
|
2332
2411
|
route: data?.route || DEFAULT_ROUTE,
|
|
2333
|
-
runtime:
|
|
2412
|
+
runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
2334
2413
|
}) });
|
|
2335
2414
|
const resetStyle = reset ? /* @__PURE__ */ jsx2("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
2336
2415
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ createElement2(
|
|
@@ -2349,7 +2428,7 @@ function RemoteComponent({
|
|
|
2349
2428
|
if (componentHydrationHtml.current && shadowRoot && !shadowRoot.innerHTML) {
|
|
2350
2429
|
shadowRoot.innerHTML = componentHydrationHtml.current;
|
|
2351
2430
|
componentHydrationHtml.current = null;
|
|
2352
|
-
if (
|
|
2431
|
+
if (hostStateRef.current.prevIsRemoteComponent) {
|
|
2353
2432
|
loadStaticRemoteComponent(
|
|
2354
2433
|
Array.from(shadowRoot.querySelectorAll("script")),
|
|
2355
2434
|
url,
|
|
@@ -2436,8 +2515,6 @@ function RemoteComponent({
|
|
|
2436
2515
|
] });
|
|
2437
2516
|
}
|
|
2438
2517
|
export {
|
|
2439
|
-
|
|
2440
|
-
RemoteComponentsProvider,
|
|
2441
|
-
proxyClientRequestsThroughHost
|
|
2518
|
+
ConsumeRemoteComponent
|
|
2442
2519
|
};
|
|
2443
|
-
//# sourceMappingURL=
|
|
2520
|
+
//# sourceMappingURL=react.js.map
|