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
|
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
9
12
|
var __export = (target, all) => {
|
|
10
13
|
for (var name in all)
|
|
11
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,86 +31,46 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
31
|
));
|
|
29
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
33
|
|
|
31
|
-
// src/
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// src/utils/constants.ts
|
|
35
|
+
var RC_PROTECTED_REMOTE_FETCH_PATHNAME, MISSING_SHARED_MODULES_MESSAGE, CORS_DOCS_URL;
|
|
36
|
+
var init_constants = __esm({
|
|
37
|
+
"src/utils/constants.ts"() {
|
|
38
|
+
"use strict";
|
|
39
|
+
RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
40
|
+
MISSING_SHARED_MODULES_MESSAGE = "Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponentsConfig` on both host and remote?";
|
|
41
|
+
CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
42
|
+
}
|
|
36
43
|
});
|
|
37
|
-
module.exports = __toCommonJS(client_exports);
|
|
38
|
-
var Image = __toESM(require("next/image"), 1);
|
|
39
44
|
|
|
40
|
-
// src/
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"script",
|
|
54
|
-
"link"
|
|
55
|
-
];
|
|
56
|
-
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
57
|
-
if (url.origin !== location.origin) {
|
|
58
|
-
const nodes = doc.querySelectorAll(
|
|
59
|
-
tagNames.map(
|
|
60
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
61
|
-
).join(",")
|
|
62
|
-
);
|
|
63
|
-
nodes.forEach((node) => {
|
|
64
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
65
|
-
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
66
|
-
const isScript = node.tagName.toLowerCase() === "script";
|
|
67
|
-
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
68
|
-
}
|
|
69
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
70
|
-
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
71
|
-
node.setAttribute(
|
|
72
|
-
"href",
|
|
73
|
-
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
if (node.hasAttribute("srcset")) {
|
|
77
|
-
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
78
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
79
|
-
if (!urlPart)
|
|
80
|
-
return entry;
|
|
81
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
82
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
83
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
84
|
-
}).join(", ");
|
|
85
|
-
if (srcSet) {
|
|
86
|
-
node.setAttribute("srcset", srcSet);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (node.hasAttribute("imagesrcset")) {
|
|
90
|
-
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
91
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
92
|
-
if (!urlPart)
|
|
93
|
-
return entry;
|
|
94
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
95
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
96
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
97
|
-
}).join(", ");
|
|
98
|
-
if (srcSet) {
|
|
99
|
-
node.setAttribute("imagesrcset", srcSet);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
45
|
+
// src/host/defaults/app.ts
|
|
46
|
+
var app_exports = {};
|
|
47
|
+
__export(app_exports, {
|
|
48
|
+
shared: () => shared
|
|
49
|
+
});
|
|
50
|
+
var shared;
|
|
51
|
+
var init_app = __esm({
|
|
52
|
+
"src/host/defaults/app.ts"() {
|
|
53
|
+
"use strict";
|
|
54
|
+
init_constants();
|
|
55
|
+
shared = {
|
|
56
|
+
__remote_components_missing_shared__: () => Promise.reject(new Error(MISSING_SHARED_MODULES_MESSAGE))
|
|
57
|
+
};
|
|
103
58
|
}
|
|
104
|
-
}
|
|
59
|
+
});
|
|
105
60
|
|
|
106
|
-
// src/
|
|
107
|
-
var
|
|
108
|
-
|
|
61
|
+
// src/host/nextjs/app-client-only.tsx
|
|
62
|
+
var app_client_only_exports = {};
|
|
63
|
+
__export(app_client_only_exports, {
|
|
64
|
+
ConsumeRemoteComponent: () => ConsumeRemoteComponent2
|
|
65
|
+
});
|
|
66
|
+
module.exports = __toCommonJS(app_client_only_exports);
|
|
67
|
+
var Image = __toESM(require("next/image"), 1);
|
|
109
68
|
|
|
110
|
-
// src/
|
|
69
|
+
// src/utils/logger.ts
|
|
70
|
+
init_constants();
|
|
71
|
+
|
|
72
|
+
// src/runtime/url/protected-rc-fallback.ts
|
|
73
|
+
init_constants();
|
|
111
74
|
function isProxiedUrl(url) {
|
|
112
75
|
try {
|
|
113
76
|
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
@@ -116,7 +79,7 @@ function isProxiedUrl(url) {
|
|
|
116
79
|
}
|
|
117
80
|
}
|
|
118
81
|
|
|
119
|
-
// src/
|
|
82
|
+
// src/utils/abort.ts
|
|
120
83
|
function isAbortError(error) {
|
|
121
84
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
122
85
|
return true;
|
|
@@ -128,7 +91,8 @@ function isAbortError(error) {
|
|
|
128
91
|
return false;
|
|
129
92
|
}
|
|
130
93
|
|
|
131
|
-
// src/
|
|
94
|
+
// src/utils/error.ts
|
|
95
|
+
init_constants();
|
|
132
96
|
var RemoteComponentsError = class extends Error {
|
|
133
97
|
code = "REMOTE_COMPONENTS_ERROR";
|
|
134
98
|
constructor(message, options) {
|
|
@@ -194,7 +158,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
|
194
158
|
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
195
159
|
|
|
196
160
|
Proxying requires two pieces:
|
|
197
|
-
1. resolveClientUrl={
|
|
161
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
198
162
|
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
199
163
|
|
|
200
164
|
Docs: ${CORS_DOCS_URL}`
|
|
@@ -211,7 +175,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
211
175
|
);
|
|
212
176
|
}
|
|
213
177
|
|
|
214
|
-
// src/
|
|
178
|
+
// src/utils/logger.ts
|
|
215
179
|
var PREFIX = "remote-components";
|
|
216
180
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
217
181
|
function logDebug(location2, message) {
|
|
@@ -237,13 +201,13 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
237
201
|
}
|
|
238
202
|
logWarn(
|
|
239
203
|
logLocation,
|
|
240
|
-
`Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure
|
|
204
|
+
`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
205
|
);
|
|
242
206
|
} catch {
|
|
243
207
|
}
|
|
244
208
|
}
|
|
245
209
|
|
|
246
|
-
// src/shared/
|
|
210
|
+
// src/host/shared/polyfill.tsx
|
|
247
211
|
var import_jsx_runtime = (
|
|
248
212
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
249
213
|
require("react/jsx-runtime")
|
|
@@ -266,7 +230,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
266
230
|
const propSrc = src;
|
|
267
231
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
268
232
|
}
|
|
269
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
233
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
270
234
|
fill: _fill,
|
|
271
235
|
loader: _loader,
|
|
272
236
|
quality: _quality,
|
|
@@ -283,21 +247,22 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
283
247
|
bundle,
|
|
284
248
|
typeof src === "string" ? src : src.src
|
|
285
249
|
);
|
|
250
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
286
251
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
287
252
|
"img",
|
|
288
253
|
{
|
|
289
254
|
decoding: "async",
|
|
290
255
|
style: { color: "transparent" },
|
|
291
256
|
...props,
|
|
292
|
-
src:
|
|
257
|
+
src: proxiedSrc,
|
|
293
258
|
suppressHydrationWarning: true
|
|
294
259
|
}
|
|
295
260
|
);
|
|
296
261
|
};
|
|
297
|
-
function sharedPolyfills(
|
|
262
|
+
function sharedPolyfills(shared2, resolveClientUrl) {
|
|
298
263
|
const self = globalThis;
|
|
299
264
|
const polyfill = {
|
|
300
|
-
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ??
|
|
265
|
+
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared2?.["next/navigation"] ?? (() => Promise.resolve({
|
|
301
266
|
useRouter() {
|
|
302
267
|
return {
|
|
303
268
|
push: (routerUrl) => {
|
|
@@ -328,7 +293,7 @@ function sharedPolyfills(shared) {
|
|
|
328
293
|
},
|
|
329
294
|
__esModule: true
|
|
330
295
|
})),
|
|
331
|
-
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ??
|
|
296
|
+
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared2?.["next/link"] ?? (() => Promise.resolve({
|
|
332
297
|
default: ({
|
|
333
298
|
scroll: _,
|
|
334
299
|
replace,
|
|
@@ -378,18 +343,18 @@ function sharedPolyfills(shared) {
|
|
|
378
343
|
},
|
|
379
344
|
__esModule: true
|
|
380
345
|
})),
|
|
381
|
-
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ??
|
|
346
|
+
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared2?.["next/form"] ?? (() => Promise.resolve({
|
|
382
347
|
default: () => {
|
|
383
348
|
throw new Error("Next.js <Form> component not implemented");
|
|
384
349
|
},
|
|
385
350
|
__esModule: true
|
|
386
351
|
})),
|
|
387
|
-
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ??
|
|
388
|
-
Image: imageImpl(bundle),
|
|
352
|
+
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
353
|
+
Image: imageImpl(bundle, resolveClientUrl),
|
|
389
354
|
__esModule: true
|
|
390
355
|
})),
|
|
391
|
-
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ??
|
|
392
|
-
default: imageImpl(bundle),
|
|
356
|
+
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
357
|
+
default: imageImpl(bundle, resolveClientUrl),
|
|
393
358
|
getImageProps: (_imgProps) => {
|
|
394
359
|
throw new Error(
|
|
395
360
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -397,13 +362,13 @@ function sharedPolyfills(shared) {
|
|
|
397
362
|
},
|
|
398
363
|
__esModule: true
|
|
399
364
|
})),
|
|
400
|
-
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ??
|
|
365
|
+
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared2?.["next/script"] ?? (() => Promise.resolve({
|
|
401
366
|
// TODO: implement <Script> component for non-Next.js host applications
|
|
402
367
|
// do not throw an error for now
|
|
403
368
|
default: () => null,
|
|
404
369
|
__esModule: true
|
|
405
370
|
})),
|
|
406
|
-
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ??
|
|
371
|
+
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared2?.["next/router"] ?? (() => (
|
|
407
372
|
// TODO: incomplete implementation
|
|
408
373
|
Promise.resolve({
|
|
409
374
|
useRouter() {
|
|
@@ -439,14 +404,435 @@ function sharedPolyfills(shared) {
|
|
|
439
404
|
return polyfill;
|
|
440
405
|
}
|
|
441
406
|
|
|
442
|
-
// src/
|
|
407
|
+
// src/host/nextjs/image-impl.tsx
|
|
408
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
409
|
+
function createRemoteLoader(bundle, resolveClientUrl) {
|
|
410
|
+
return ({ src, width, quality }) => {
|
|
411
|
+
const self = globalThis;
|
|
412
|
+
const origin = self.__remote_bundle_url__?.[bundle]?.origin ?? "";
|
|
413
|
+
let imageUrl = src;
|
|
414
|
+
try {
|
|
415
|
+
const parsed = new URL(src);
|
|
416
|
+
if (origin && parsed.origin === origin) {
|
|
417
|
+
imageUrl = parsed.pathname + parsed.search;
|
|
418
|
+
}
|
|
419
|
+
} catch {
|
|
420
|
+
}
|
|
421
|
+
const { assetPrefix } = /^(?<assetPrefix>.*?)\/_next\//.exec(imageUrl)?.groups ?? {};
|
|
422
|
+
const url = `${origin}${assetPrefix ?? ""}/_next/image?url=${encodeURIComponent(imageUrl)}&w=${width}&q=${quality ?? 75}`;
|
|
423
|
+
return resolveClientUrl?.(url) ?? url;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function imageImpl2(ImageComponent, bundle, resolveClientUrl, useRemoteLoader) {
|
|
427
|
+
const remoteLoader = useRemoteLoader ? createRemoteLoader(bundle, resolveClientUrl) : void 0;
|
|
428
|
+
const component = function RemoteImage(props) {
|
|
429
|
+
if (remoteLoader) {
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImageComponent, { loader: remoteLoader, ...props });
|
|
431
|
+
}
|
|
432
|
+
const rawSrc = applyBundleUrlToImagePropsSrc(bundle, props.src);
|
|
433
|
+
const src = resolveClientUrl?.(rawSrc) ?? rawSrc;
|
|
434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImageComponent, { ...props, src });
|
|
435
|
+
};
|
|
436
|
+
component.default = component;
|
|
437
|
+
return component;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/runtime/url/resolve-client-url.ts
|
|
441
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
442
|
+
const remoteOrigin = parseOrigin(remoteSrc);
|
|
443
|
+
return (url) => {
|
|
444
|
+
const urlOrigin = parseOrigin(url);
|
|
445
|
+
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
446
|
+
return void 0;
|
|
447
|
+
}
|
|
448
|
+
return resolveClientUrl(remoteSrc, url);
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function parseOrigin(url) {
|
|
452
|
+
try {
|
|
453
|
+
return new URL(url).origin;
|
|
454
|
+
} catch {
|
|
455
|
+
return void 0;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
460
|
+
function bindResolveClientUrl(prop, remoteSrc) {
|
|
461
|
+
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/host/react/index.tsx
|
|
465
|
+
var import_react3 = require("react");
|
|
466
|
+
var import_react_dom = require("react-dom");
|
|
467
|
+
|
|
468
|
+
// src/host/server/fetch-headers.ts
|
|
469
|
+
function remoteFetchHeaders() {
|
|
470
|
+
return {
|
|
471
|
+
/**
|
|
472
|
+
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
473
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
474
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
475
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
476
|
+
*/
|
|
477
|
+
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
478
|
+
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
479
|
+
} : {},
|
|
480
|
+
Accept: "text/html"
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/host/server/fetch-with-hooks.ts
|
|
485
|
+
async function fetchWithWarning(url, init) {
|
|
486
|
+
try {
|
|
487
|
+
return await fetch(url, init);
|
|
488
|
+
} catch (error) {
|
|
489
|
+
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
490
|
+
throw error;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
494
|
+
const {
|
|
495
|
+
onRequest,
|
|
496
|
+
onResponse,
|
|
497
|
+
abortController = new AbortController()
|
|
498
|
+
} = options;
|
|
499
|
+
const signal = abortController.signal;
|
|
500
|
+
const hookOptions = {
|
|
501
|
+
signal,
|
|
502
|
+
abort: (reason) => abortController.abort(reason)
|
|
503
|
+
};
|
|
504
|
+
const init = {
|
|
505
|
+
method: "GET",
|
|
506
|
+
headers: remoteFetchHeaders(),
|
|
507
|
+
signal,
|
|
508
|
+
...additionalInit
|
|
509
|
+
};
|
|
510
|
+
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
511
|
+
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// src/host/server/get-client-or-server-url.ts
|
|
515
|
+
function getClientOrServerUrl(src, serverFallback) {
|
|
516
|
+
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
517
|
+
if (!src) {
|
|
518
|
+
return new URL(fallback);
|
|
519
|
+
}
|
|
520
|
+
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/host/shared/state.ts
|
|
524
|
+
function createHostState() {
|
|
525
|
+
return {
|
|
526
|
+
stage: "idle",
|
|
527
|
+
prevSrc: void 0,
|
|
528
|
+
prevUrl: void 0,
|
|
529
|
+
prevName: void 0,
|
|
530
|
+
prevIsRemoteComponent: false,
|
|
531
|
+
abortController: void 0
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
536
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
537
|
+
if (!src) {
|
|
538
|
+
return defaultName;
|
|
539
|
+
}
|
|
540
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
541
|
+
const hashIndex = hash.indexOf("#");
|
|
542
|
+
if (hashIndex < 0) {
|
|
543
|
+
return defaultName;
|
|
544
|
+
}
|
|
545
|
+
const name = hash.slice(hashIndex + 1);
|
|
546
|
+
return name || defaultName;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/utils/index.ts
|
|
550
|
+
function escapeString(str) {
|
|
551
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
552
|
+
}
|
|
553
|
+
var attrToProp = {
|
|
554
|
+
fetchpriority: "fetchPriority",
|
|
555
|
+
crossorigin: "crossOrigin",
|
|
556
|
+
imagesrcset: "imageSrcSet",
|
|
557
|
+
imagesizes: "imageSizes",
|
|
558
|
+
srcset: "srcSet"
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// src/runtime/constants.ts
|
|
562
|
+
var DEFAULT_ROUTE = "/";
|
|
563
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
564
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
565
|
+
var RUNTIME_SCRIPT = "script";
|
|
566
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
567
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
568
|
+
function getBundleKey(bundle) {
|
|
569
|
+
return escapeString(bundle);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/runtime/html/apply-origin.ts
|
|
573
|
+
var tagNames = [
|
|
574
|
+
"img",
|
|
575
|
+
"source",
|
|
576
|
+
"video",
|
|
577
|
+
"audio",
|
|
578
|
+
"track",
|
|
579
|
+
"iframe",
|
|
580
|
+
"embed",
|
|
581
|
+
"script",
|
|
582
|
+
"link"
|
|
583
|
+
];
|
|
584
|
+
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
585
|
+
if (url.origin !== location.origin) {
|
|
586
|
+
const nodes = doc.querySelectorAll(
|
|
587
|
+
tagNames.map(
|
|
588
|
+
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
589
|
+
).join(",")
|
|
590
|
+
);
|
|
591
|
+
nodes.forEach((node) => {
|
|
592
|
+
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
593
|
+
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
594
|
+
const isScript = node.tagName.toLowerCase() === "script";
|
|
595
|
+
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
596
|
+
}
|
|
597
|
+
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
598
|
+
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
599
|
+
node.setAttribute(
|
|
600
|
+
"href",
|
|
601
|
+
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
if (node.hasAttribute("srcset")) {
|
|
605
|
+
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
606
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
607
|
+
if (!urlPart)
|
|
608
|
+
return entry;
|
|
609
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
610
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
611
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
612
|
+
}).join(", ");
|
|
613
|
+
if (srcSet) {
|
|
614
|
+
node.setAttribute("srcset", srcSet);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (node.hasAttribute("imagesrcset")) {
|
|
618
|
+
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
619
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
620
|
+
if (!urlPart)
|
|
621
|
+
return entry;
|
|
622
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
623
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
624
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
625
|
+
}).join(", ");
|
|
626
|
+
if (srcSet) {
|
|
627
|
+
node.setAttribute("imagesrcset", srcSet);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// src/runtime/html/parse-remote-html.ts
|
|
635
|
+
function validateSingleComponent(doc, name, url) {
|
|
636
|
+
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}"]`)) {
|
|
637
|
+
throw multipleRemoteComponentsError(url);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function findComponentElement(doc, name) {
|
|
641
|
+
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])");
|
|
642
|
+
}
|
|
643
|
+
function parseNextData(doc) {
|
|
644
|
+
return JSON.parse(
|
|
645
|
+
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
function resolveComponentName(component, nextData, fallbackName) {
|
|
649
|
+
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
650
|
+
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
651
|
+
return { name, isRemoteComponent };
|
|
652
|
+
}
|
|
653
|
+
function extractComponentMetadata(component, nextData, name, url) {
|
|
654
|
+
return {
|
|
655
|
+
name,
|
|
656
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
657
|
+
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
658
|
+
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function extractRemoteShared(doc, name, nextData) {
|
|
662
|
+
const remoteSharedEl = doc.querySelector(
|
|
663
|
+
`#${name}_shared[data-remote-components-shared]`
|
|
664
|
+
);
|
|
665
|
+
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
666
|
+
remoteSharedEl?.remove();
|
|
667
|
+
return remoteShared;
|
|
668
|
+
}
|
|
669
|
+
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
670
|
+
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
671
|
+
throw new RemoteComponentsError(
|
|
672
|
+
`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>?`
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
function extractLinks(doc, component) {
|
|
677
|
+
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
678
|
+
(link) => !component.contains(link)
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
function extractScripts(doc, component, isRemoteComponent) {
|
|
682
|
+
return Array.from(
|
|
683
|
+
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
684
|
+
"script[src],script[data-src]"
|
|
685
|
+
)
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
function parseRemoteComponentDocument(doc, name, url) {
|
|
689
|
+
validateSingleComponent(doc, name, url.href);
|
|
690
|
+
const component = findComponentElement(doc, name);
|
|
691
|
+
const nextData = parseNextData(doc);
|
|
692
|
+
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
693
|
+
component,
|
|
694
|
+
nextData,
|
|
695
|
+
name
|
|
696
|
+
);
|
|
697
|
+
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
698
|
+
const metadata = extractComponentMetadata(
|
|
699
|
+
component,
|
|
700
|
+
nextData,
|
|
701
|
+
resolvedName,
|
|
702
|
+
url
|
|
703
|
+
);
|
|
704
|
+
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
705
|
+
validateComponentFound(
|
|
706
|
+
component,
|
|
707
|
+
rsc,
|
|
708
|
+
nextData,
|
|
709
|
+
isRemoteComponent,
|
|
710
|
+
url.href,
|
|
711
|
+
resolvedName
|
|
712
|
+
);
|
|
713
|
+
const links = extractLinks(doc, component);
|
|
714
|
+
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
715
|
+
return {
|
|
716
|
+
component,
|
|
717
|
+
name: resolvedName,
|
|
718
|
+
isRemoteComponent,
|
|
719
|
+
metadata,
|
|
720
|
+
nextData,
|
|
721
|
+
rsc,
|
|
722
|
+
remoteShared,
|
|
723
|
+
links,
|
|
724
|
+
scripts
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// src/runtime/html/set-attributes-from-props.ts
|
|
729
|
+
var DOMAttributeNames = {
|
|
730
|
+
acceptCharset: "accept-charset",
|
|
731
|
+
className: "class",
|
|
732
|
+
htmlFor: "for",
|
|
733
|
+
httpEquiv: "http-equiv",
|
|
734
|
+
noModule: "noModule"
|
|
735
|
+
};
|
|
736
|
+
var ignoreProps = [
|
|
737
|
+
"onLoad",
|
|
738
|
+
"onReady",
|
|
739
|
+
"dangerouslySetInnerHTML",
|
|
740
|
+
"children",
|
|
741
|
+
"onError",
|
|
742
|
+
"strategy",
|
|
743
|
+
"stylesheets"
|
|
744
|
+
];
|
|
745
|
+
function isBooleanScriptAttribute(attr) {
|
|
746
|
+
return ["async", "defer", "noModule"].includes(attr);
|
|
747
|
+
}
|
|
748
|
+
function setAttributesFromProps(el, props) {
|
|
749
|
+
for (const [p, value] of Object.entries(props)) {
|
|
750
|
+
if (!Object.hasOwn(props, p))
|
|
751
|
+
continue;
|
|
752
|
+
if (ignoreProps.includes(p))
|
|
753
|
+
continue;
|
|
754
|
+
if (value === void 0) {
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
758
|
+
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
759
|
+
el[attr] = Boolean(value);
|
|
760
|
+
} else {
|
|
761
|
+
el.setAttribute(attr, String(value));
|
|
762
|
+
}
|
|
763
|
+
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
764
|
+
el.setAttribute(attr, "");
|
|
765
|
+
el.removeAttribute(attr);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// src/runtime/loaders/component-loader.ts
|
|
443
771
|
var React = __toESM(require("react"), 1);
|
|
444
772
|
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
445
773
|
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
446
774
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
447
775
|
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
448
776
|
|
|
449
|
-
// src/
|
|
777
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
778
|
+
function applySharedModules(bundle, resolve) {
|
|
779
|
+
logDebug(
|
|
780
|
+
"SharedModules",
|
|
781
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
782
|
+
);
|
|
783
|
+
logDebug(
|
|
784
|
+
"SharedModules",
|
|
785
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
786
|
+
);
|
|
787
|
+
const self = globalThis;
|
|
788
|
+
if (self.__remote_webpack_require__?.[bundle]) {
|
|
789
|
+
const modulePaths = Object.keys(
|
|
790
|
+
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
791
|
+
);
|
|
792
|
+
logDebug(
|
|
793
|
+
"SharedModules",
|
|
794
|
+
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
795
|
+
);
|
|
796
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
797
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
798
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
799
|
+
if (ids.length === 0) {
|
|
800
|
+
logDebug(
|
|
801
|
+
"SharedModules",
|
|
802
|
+
`No matching module path found for shared module "${key}"`
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
for (const id of ids) {
|
|
806
|
+
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
807
|
+
if (webpackBundle.m) {
|
|
808
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
809
|
+
if (resolvedId !== id) {
|
|
810
|
+
logDebug(
|
|
811
|
+
"SharedModules",
|
|
812
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
webpackBundle.m[resolvedId] = (module2) => {
|
|
816
|
+
module2.exports = value;
|
|
817
|
+
};
|
|
818
|
+
} else {
|
|
819
|
+
logWarn(
|
|
820
|
+
"SharedModules",
|
|
821
|
+
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
} else {
|
|
827
|
+
logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
|
|
828
|
+
logDebug(
|
|
829
|
+
"SharedModules",
|
|
830
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
450
836
|
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
451
837
|
const self = globalThis;
|
|
452
838
|
const nextCssOriginal = document.querySelector(
|
|
@@ -528,98 +914,37 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
528
914
|
});
|
|
529
915
|
const elements = [];
|
|
530
916
|
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
|
-
);
|
|
610
|
-
}
|
|
917
|
+
while (node && node !== nextCssEnd) {
|
|
918
|
+
elements.push(node);
|
|
919
|
+
node.remove();
|
|
920
|
+
node = nextCss.previousSibling;
|
|
611
921
|
}
|
|
922
|
+
self.__remote_next_css__[bundle] = elements;
|
|
612
923
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
924
|
+
if (styleContainer) {
|
|
925
|
+
const elements = self.__remote_next_css__[bundle];
|
|
926
|
+
elements.forEach((el) => {
|
|
927
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
928
|
+
});
|
|
929
|
+
} else {
|
|
930
|
+
const elements = self.__remote_next_css__[bundle];
|
|
931
|
+
elements.forEach((el) => {
|
|
932
|
+
document.head.appendChild(el);
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
delete self.__NEXT_P;
|
|
936
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
937
|
+
if (nextCssOriginal) {
|
|
938
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
939
|
+
}
|
|
940
|
+
nextCss.remove();
|
|
941
|
+
nextCssEnd.remove();
|
|
942
|
+
return { Component, App };
|
|
619
943
|
}
|
|
944
|
+
return { Component: null, App: null };
|
|
620
945
|
}
|
|
621
946
|
|
|
622
|
-
// src/
|
|
947
|
+
// src/runtime/rsc.ts
|
|
623
948
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
624
949
|
function fixPayload(payload) {
|
|
625
950
|
if (Array.isArray(payload)) {
|
|
@@ -685,78 +1010,18 @@ function createRSCStream(rscName, data) {
|
|
|
685
1010
|
});
|
|
686
1011
|
}
|
|
687
1012
|
|
|
688
|
-
// src/
|
|
689
|
-
|
|
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
|
-
}
|
|
1013
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
1014
|
+
init_constants();
|
|
750
1015
|
|
|
751
|
-
// src/
|
|
1016
|
+
// src/runtime/turbopack/patterns.ts
|
|
752
1017
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
753
|
-
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|
|
|
1018
|
+
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
754
1019
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
755
1020
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
756
1021
|
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
1022
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
758
1023
|
|
|
759
|
-
// src/
|
|
1024
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
760
1025
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
761
1026
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
762
1027
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -818,7 +1083,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
818
1083
|
if (isProxied) {
|
|
819
1084
|
reject(
|
|
820
1085
|
new RemoteComponentsError(
|
|
821
|
-
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure
|
|
1086
|
+
`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
1087
|
)
|
|
823
1088
|
);
|
|
824
1089
|
} else {
|
|
@@ -968,7 +1233,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
968
1233
|
}
|
|
969
1234
|
}
|
|
970
1235
|
|
|
971
|
-
// src/
|
|
1236
|
+
// src/runtime/turbopack/module.ts
|
|
972
1237
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
973
1238
|
const self = globalThis;
|
|
974
1239
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1197,7 +1462,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1197
1462
|
};
|
|
1198
1463
|
}
|
|
1199
1464
|
|
|
1200
|
-
// src/
|
|
1465
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1201
1466
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1202
1467
|
const self = globalThis;
|
|
1203
1468
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1234,9 +1499,9 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1234
1499
|
}
|
|
1235
1500
|
}
|
|
1236
1501
|
if (sharedModuleInitializer) {
|
|
1237
|
-
const { shared } = await sharedModuleInitializer;
|
|
1502
|
+
const { shared: shared2 } = await sharedModuleInitializer;
|
|
1238
1503
|
const sharedModuleIds = extractSharedModuleIds(
|
|
1239
|
-
|
|
1504
|
+
shared2,
|
|
1240
1505
|
bundleKey,
|
|
1241
1506
|
self
|
|
1242
1507
|
);
|
|
@@ -1272,8 +1537,8 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1272
1537
|
})
|
|
1273
1538
|
);
|
|
1274
1539
|
}
|
|
1275
|
-
function extractSharedModuleIds(
|
|
1276
|
-
return Object.entries(
|
|
1540
|
+
function extractSharedModuleIds(shared2, bundleKey, self) {
|
|
1541
|
+
return Object.entries(shared2).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1277
1542
|
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1278
1543
|
if (asyncSharedModuleId) {
|
|
1279
1544
|
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
@@ -1317,8 +1582,8 @@ function getSharedModule(bundle, id) {
|
|
|
1317
1582
|
return null;
|
|
1318
1583
|
}
|
|
1319
1584
|
|
|
1320
|
-
// src/
|
|
1321
|
-
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle,
|
|
1585
|
+
// src/runtime/turbopack/webpack-runtime.ts
|
|
1586
|
+
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared2 = {}, remoteShared = {}, resolveClientUrl) {
|
|
1322
1587
|
const self = globalThis;
|
|
1323
1588
|
if (!self.__remote_bundle_url__) {
|
|
1324
1589
|
self.__remote_bundle_url__ = {};
|
|
@@ -1355,7 +1620,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1355
1620
|
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1356
1621
|
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1357
1622
|
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1358
|
-
...
|
|
1623
|
+
...shared2
|
|
1359
1624
|
};
|
|
1360
1625
|
await initializeSharedModules(
|
|
1361
1626
|
bundle ?? "default",
|
|
@@ -1372,7 +1637,7 @@ function createModuleRequire(runtime) {
|
|
|
1372
1637
|
id
|
|
1373
1638
|
};
|
|
1374
1639
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1375
|
-
logDebug("
|
|
1640
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1376
1641
|
try {
|
|
1377
1642
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1378
1643
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1388,7 +1653,7 @@ function createModuleRequire(runtime) {
|
|
|
1388
1653
|
throw new Error(`Module "${id}" not found.`);
|
|
1389
1654
|
} catch (requireError) {
|
|
1390
1655
|
logWarn(
|
|
1391
|
-
"
|
|
1656
|
+
"WebpackRuntime",
|
|
1392
1657
|
`Module require failed: ${String(requireError)}`
|
|
1393
1658
|
);
|
|
1394
1659
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1400,7 +1665,7 @@ function createModuleRequire(runtime) {
|
|
|
1400
1665
|
);
|
|
1401
1666
|
}
|
|
1402
1667
|
try {
|
|
1403
|
-
logDebug("
|
|
1668
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1404
1669
|
return self.__original_webpack_require__(id);
|
|
1405
1670
|
} catch (originalError) {
|
|
1406
1671
|
throw new RemoteComponentsError(
|
|
@@ -1412,7 +1677,46 @@ function createModuleRequire(runtime) {
|
|
|
1412
1677
|
};
|
|
1413
1678
|
}
|
|
1414
1679
|
|
|
1415
|
-
// src/
|
|
1680
|
+
// src/runtime/loaders/script-loader.ts
|
|
1681
|
+
init_constants();
|
|
1682
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
1683
|
+
await Promise.all(
|
|
1684
|
+
scripts.map((script) => {
|
|
1685
|
+
return new Promise((resolve, reject) => {
|
|
1686
|
+
const newSrc = new URL(
|
|
1687
|
+
// remove the remote component bundle name identifier from the script src
|
|
1688
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1689
|
+
location.origin
|
|
1690
|
+
).href;
|
|
1691
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1692
|
+
const newScript = document.createElement("script");
|
|
1693
|
+
newScript.onload = () => resolve();
|
|
1694
|
+
newScript.onerror = () => {
|
|
1695
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1696
|
+
if (isProxied) {
|
|
1697
|
+
reject(
|
|
1698
|
+
new RemoteComponentsError(
|
|
1699
|
+
`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}`
|
|
1700
|
+
)
|
|
1701
|
+
);
|
|
1702
|
+
} else {
|
|
1703
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1704
|
+
reject(
|
|
1705
|
+
new RemoteComponentsError(
|
|
1706
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1707
|
+
)
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
newScript.src = resolvedSrc;
|
|
1712
|
+
newScript.async = true;
|
|
1713
|
+
document.head.appendChild(newScript);
|
|
1714
|
+
});
|
|
1715
|
+
})
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
// src/runtime/loaders/component-loader.ts
|
|
1416
1720
|
async function loadRemoteComponent({
|
|
1417
1721
|
url,
|
|
1418
1722
|
name,
|
|
@@ -1423,7 +1727,7 @@ async function loadRemoteComponent({
|
|
|
1423
1727
|
data,
|
|
1424
1728
|
nextData,
|
|
1425
1729
|
scripts = [],
|
|
1426
|
-
shared = Promise.resolve({}),
|
|
1730
|
+
shared: shared2 = Promise.resolve({}),
|
|
1427
1731
|
remoteShared = {},
|
|
1428
1732
|
container,
|
|
1429
1733
|
resolveClientUrl
|
|
@@ -1437,7 +1741,7 @@ async function loadRemoteComponent({
|
|
|
1437
1741
|
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1438
1742
|
await loadScripts(scripts, resolveClientUrl);
|
|
1439
1743
|
}
|
|
1440
|
-
const hostShared = await
|
|
1744
|
+
const hostShared = await shared2;
|
|
1441
1745
|
logDebug(
|
|
1442
1746
|
"ComponentLoader",
|
|
1443
1747
|
`loadRemoteComponent: bundle="${bundle}", name="${name}"`
|
|
@@ -1515,17 +1819,19 @@ async function loadRemoteComponent({
|
|
|
1515
1819
|
};
|
|
1516
1820
|
}
|
|
1517
1821
|
}
|
|
1518
|
-
async function
|
|
1519
|
-
let createFromReadableStream;
|
|
1822
|
+
async function importCreateFromReadableStream() {
|
|
1520
1823
|
try {
|
|
1521
|
-
const { createFromReadableStream
|
|
1522
|
-
createFromReadableStream
|
|
1824
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1825
|
+
return createFromReadableStream;
|
|
1523
1826
|
} catch {
|
|
1524
1827
|
const {
|
|
1525
|
-
default: { createFromReadableStream
|
|
1828
|
+
default: { createFromReadableStream }
|
|
1526
1829
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1527
|
-
createFromReadableStream
|
|
1830
|
+
return createFromReadableStream;
|
|
1528
1831
|
}
|
|
1832
|
+
}
|
|
1833
|
+
async function loadRSCComponent(rscName, data) {
|
|
1834
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1529
1835
|
if (typeof createFromReadableStream !== "function") {
|
|
1530
1836
|
throw new RemoteComponentsError(
|
|
1531
1837
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1546,54 +1852,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1546
1852
|
return { component };
|
|
1547
1853
|
}
|
|
1548
1854
|
|
|
1549
|
-
// src/
|
|
1550
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1551
|
-
return (url) => resolveClientUrl(remoteSrc, url);
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1555
|
-
var DOMAttributeNames = {
|
|
1556
|
-
acceptCharset: "accept-charset",
|
|
1557
|
-
className: "class",
|
|
1558
|
-
htmlFor: "for",
|
|
1559
|
-
httpEquiv: "http-equiv",
|
|
1560
|
-
noModule: "noModule"
|
|
1561
|
-
};
|
|
1562
|
-
var ignoreProps = [
|
|
1563
|
-
"onLoad",
|
|
1564
|
-
"onReady",
|
|
1565
|
-
"dangerouslySetInnerHTML",
|
|
1566
|
-
"children",
|
|
1567
|
-
"onError",
|
|
1568
|
-
"strategy",
|
|
1569
|
-
"stylesheets"
|
|
1570
|
-
];
|
|
1571
|
-
function isBooleanScriptAttribute(attr) {
|
|
1572
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1573
|
-
}
|
|
1574
|
-
function setAttributesFromProps(el, props) {
|
|
1575
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1576
|
-
if (!Object.hasOwn(props, p))
|
|
1577
|
-
continue;
|
|
1578
|
-
if (ignoreProps.includes(p))
|
|
1579
|
-
continue;
|
|
1580
|
-
if (value === void 0) {
|
|
1581
|
-
continue;
|
|
1582
|
-
}
|
|
1583
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1584
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1585
|
-
el[attr] = Boolean(value);
|
|
1586
|
-
} else {
|
|
1587
|
-
el.setAttribute(attr, String(value));
|
|
1588
|
-
}
|
|
1589
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1590
|
-
el.setAttribute(attr, "");
|
|
1591
|
-
el.removeAttribute(attr);
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
// src/shared/client/static-loader.ts
|
|
1855
|
+
// src/runtime/loaders/static-loader.ts
|
|
1597
1856
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1598
1857
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1599
1858
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1743,75 +2002,9 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1743
2002
|
);
|
|
1744
2003
|
}
|
|
1745
2004
|
|
|
1746
|
-
// src/
|
|
1747
|
-
function remoteFetchHeaders() {
|
|
1748
|
-
return {
|
|
1749
|
-
/**
|
|
1750
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1751
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1752
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1753
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1754
|
-
*/
|
|
1755
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1756
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1757
|
-
} : {},
|
|
1758
|
-
Accept: "text/html"
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
// src/shared/ssr/fetch-with-hooks.ts
|
|
1763
|
-
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1764
|
-
const {
|
|
1765
|
-
onRequest,
|
|
1766
|
-
onResponse,
|
|
1767
|
-
abortController = new AbortController()
|
|
1768
|
-
} = options;
|
|
1769
|
-
const signal = abortController.signal;
|
|
1770
|
-
const hookOptions = {
|
|
1771
|
-
signal,
|
|
1772
|
-
abort: (reason) => abortController.abort(reason)
|
|
1773
|
-
};
|
|
1774
|
-
const init = {
|
|
1775
|
-
method: "GET",
|
|
1776
|
-
headers: remoteFetchHeaders(),
|
|
1777
|
-
signal,
|
|
1778
|
-
...additionalInit
|
|
1779
|
-
};
|
|
1780
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1781
|
-
if (!res) {
|
|
1782
|
-
try {
|
|
1783
|
-
res = await fetch(url, init);
|
|
1784
|
-
} catch (error) {
|
|
1785
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1786
|
-
throw error;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
1790
|
-
if (transformedRes) {
|
|
1791
|
-
res = transformedRes;
|
|
1792
|
-
}
|
|
1793
|
-
return res;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
// src/shared/ssr/get-client-or-server-url.ts
|
|
1797
|
-
function getClientOrServerUrl(src, serverFallback) {
|
|
1798
|
-
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
1799
|
-
if (!src) {
|
|
1800
|
-
return new URL(fallback);
|
|
1801
|
-
}
|
|
1802
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
2005
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1806
2006
|
var import_react = require("react");
|
|
1807
|
-
var import_context = require("#internal/react/context");
|
|
1808
|
-
|
|
1809
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1810
|
-
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1811
|
-
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
2007
|
+
var import_context = require("#internal/host/react/context");
|
|
1815
2008
|
function useResolveClientUrl(prop, urlHref) {
|
|
1816
2009
|
const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
|
|
1817
2010
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1821,7 +2014,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1821
2014
|
);
|
|
1822
2015
|
}
|
|
1823
2016
|
|
|
1824
|
-
// src/react/hooks/use-shadow-root.ts
|
|
2017
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1825
2018
|
var import_react2 = require("react");
|
|
1826
2019
|
function useShadowRoot({
|
|
1827
2020
|
isolate,
|
|
@@ -1870,7 +2063,7 @@ function useShadowRoot({
|
|
|
1870
2063
|
return { shadowRoot, shadowRootContainerRef };
|
|
1871
2064
|
}
|
|
1872
2065
|
|
|
1873
|
-
// src/react/utils/
|
|
2066
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
1874
2067
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
1875
2068
|
function getRemoteComponentHtml(html) {
|
|
1876
2069
|
if (typeof document === "undefined")
|
|
@@ -1892,21 +2085,20 @@ function getRemoteComponentHtml(html) {
|
|
|
1892
2085
|
return "";
|
|
1893
2086
|
}
|
|
1894
2087
|
|
|
1895
|
-
// src/react/index.tsx
|
|
1896
|
-
var
|
|
1897
|
-
var import_jsx_runtime2 = (
|
|
2088
|
+
// src/host/react/index.tsx
|
|
2089
|
+
var import_jsx_runtime3 = (
|
|
1898
2090
|
// TODO: remove wrapper div by converting HTML to RSC or React tree
|
|
1899
2091
|
require("react/jsx-runtime")
|
|
1900
2092
|
);
|
|
1901
2093
|
var import_react4 = require("react");
|
|
1902
|
-
function
|
|
2094
|
+
function ConsumeRemoteComponent({
|
|
1903
2095
|
src,
|
|
1904
2096
|
isolate,
|
|
1905
2097
|
mode = "open",
|
|
1906
2098
|
reset,
|
|
1907
2099
|
credentials = "same-origin",
|
|
1908
2100
|
name: nameProp = "__vercel_remote_component",
|
|
1909
|
-
shared = {},
|
|
2101
|
+
shared: shared2 = {},
|
|
1910
2102
|
children,
|
|
1911
2103
|
onBeforeLoad,
|
|
1912
2104
|
onLoad,
|
|
@@ -1917,21 +2109,13 @@ function RemoteComponent({
|
|
|
1917
2109
|
resolveClientUrl: _resolveClientUrl
|
|
1918
2110
|
}) {
|
|
1919
2111
|
const instanceId = (0, import_react3.useId)();
|
|
1920
|
-
const name = (0, import_react3.useMemo)(
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
return url2.hash.slice(1);
|
|
1928
|
-
}
|
|
1929
|
-
} else if (typeof src === "object" && "hash" in src && src.hash) {
|
|
1930
|
-
return src.hash.slice(1) || nameProp;
|
|
1931
|
-
}
|
|
1932
|
-
return nameProp;
|
|
1933
|
-
}, [src, nameProp]);
|
|
1934
|
-
const [data, setData] = (0, import_react3.useState)(null);
|
|
2112
|
+
const name = (0, import_react3.useMemo)(
|
|
2113
|
+
() => resolveNameFromSrc(src, nameProp),
|
|
2114
|
+
[src, nameProp]
|
|
2115
|
+
);
|
|
2116
|
+
const [data, setData] = (0, import_react3.useState)(
|
|
2117
|
+
null
|
|
2118
|
+
);
|
|
1935
2119
|
const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
1936
2120
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
1937
2121
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -1963,13 +2147,10 @@ function RemoteComponent({
|
|
|
1963
2147
|
return elements;
|
|
1964
2148
|
})() : []
|
|
1965
2149
|
);
|
|
1966
|
-
const
|
|
2150
|
+
const hostStateRef = (0, import_react3.useRef)(createHostState());
|
|
1967
2151
|
const componentHydrationHtml = (0, import_react3.useRef)(null);
|
|
1968
|
-
const prevIsRemoteComponentRef = (0, import_react3.useRef)(false);
|
|
1969
|
-
const prevUrlRef = (0, import_react3.useRef)(null);
|
|
1970
2152
|
const prevRemoteComponentContainerRef = (0, import_react3.useRef)(null);
|
|
1971
2153
|
const unmountRef = (0, import_react3.useRef)(null);
|
|
1972
|
-
const prevNameRef = (0, import_react3.useRef)(void 0);
|
|
1973
2154
|
(0, import_react3.useLayoutEffect)(() => {
|
|
1974
2155
|
const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
|
|
1975
2156
|
return () => {
|
|
@@ -2008,14 +2189,18 @@ function RemoteComponent({
|
|
|
2008
2189
|
}
|
|
2009
2190
|
}, [shadowRoot, remoteComponent, name]);
|
|
2010
2191
|
(0, import_react3.useEffect)(() => {
|
|
2011
|
-
if (src && src !==
|
|
2012
|
-
const previousSrc =
|
|
2013
|
-
const previousName =
|
|
2014
|
-
|
|
2192
|
+
if (src && src !== hostStateRef.current.prevSrc) {
|
|
2193
|
+
const previousSrc = hostStateRef.current.prevSrc;
|
|
2194
|
+
const previousName = hostStateRef.current.prevName;
|
|
2195
|
+
hostStateRef.current.prevSrc = src;
|
|
2015
2196
|
if (previousSrc !== null) {
|
|
2016
2197
|
htmlRef.current = null;
|
|
2017
2198
|
}
|
|
2199
|
+
hostStateRef.current.abortController?.abort();
|
|
2200
|
+
hostStateRef.current.abortController = new AbortController();
|
|
2201
|
+
const { signal } = hostStateRef.current.abortController;
|
|
2018
2202
|
onBeforeLoad?.(src);
|
|
2203
|
+
hostStateRef.current.stage = "loading";
|
|
2019
2204
|
(0, import_react3.startTransition)(async () => {
|
|
2020
2205
|
try {
|
|
2021
2206
|
let html = getRemoteComponentHtml(
|
|
@@ -2029,59 +2214,41 @@ function RemoteComponent({
|
|
|
2029
2214
|
resolveClientUrl?.(url.href) ?? url.href,
|
|
2030
2215
|
location.href
|
|
2031
2216
|
);
|
|
2032
|
-
const abortController = new AbortController();
|
|
2033
2217
|
const res = await fetchWithHooks(resolvedUrl, fetchInit, {
|
|
2034
2218
|
onRequest,
|
|
2035
2219
|
onResponse,
|
|
2036
|
-
abortController
|
|
2220
|
+
abortController: hostStateRef.current.abortController
|
|
2037
2221
|
});
|
|
2038
2222
|
if (!res || !res.ok) {
|
|
2039
2223
|
throw await errorFromFailedFetch(url.href, resolvedUrl, res);
|
|
2040
2224
|
}
|
|
2041
2225
|
const remoteHtml = await res.text();
|
|
2226
|
+
if (signal.aborted)
|
|
2227
|
+
return;
|
|
2042
2228
|
htmlRef.current = remoteHtml;
|
|
2043
2229
|
html = getRemoteComponentHtml(remoteHtml);
|
|
2044
2230
|
}
|
|
2231
|
+
if (signal.aborted)
|
|
2232
|
+
return;
|
|
2045
2233
|
const parser = new DOMParser();
|
|
2046
2234
|
const doc = parser.parseFromString(html, "text/html");
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
2050
|
-
throw multipleRemoteComponentsError(url.href);
|
|
2051
|
-
}
|
|
2052
|
-
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
|
|
2053
|
-
doc.querySelector("div[data-bundle][data-route]") ?? // fallback to Next.js Pages Router
|
|
2054
|
-
doc.querySelector("div#__next") ?? // fallback to the remote-component web component
|
|
2055
|
-
doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
|
|
2056
|
-
const nextData = JSON.parse(
|
|
2057
|
-
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
2058
|
-
);
|
|
2059
|
-
const remoteName = component?.getAttribute("id")?.replace(/_ssr$/, "") || (nextData ? "__next" : name);
|
|
2060
|
-
const rsc = doc.querySelector(`#${remoteName}_rsc`);
|
|
2061
|
-
const bundle = component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default";
|
|
2062
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
2063
|
-
const metadata = {
|
|
2235
|
+
const {
|
|
2236
|
+
component,
|
|
2064
2237
|
name: remoteName,
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
2075
|
-
throw new RemoteComponentsError(
|
|
2076
|
-
`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>?`
|
|
2077
|
-
);
|
|
2078
|
-
}
|
|
2079
|
-
if (prevIsRemoteComponentRef.current) {
|
|
2238
|
+
isRemoteComponent,
|
|
2239
|
+
metadata,
|
|
2240
|
+
nextData,
|
|
2241
|
+
rsc,
|
|
2242
|
+
remoteShared,
|
|
2243
|
+
links: linkElements,
|
|
2244
|
+
scripts: scriptElements
|
|
2245
|
+
} = parseRemoteComponentDocument(doc, name, url);
|
|
2246
|
+
if (hostStateRef.current.prevIsRemoteComponent) {
|
|
2080
2247
|
if (shadowRoot) {
|
|
2081
2248
|
shadowRoot.innerHTML = "";
|
|
2082
2249
|
}
|
|
2083
2250
|
const self = globalThis;
|
|
2084
|
-
const prevUrl =
|
|
2251
|
+
const prevUrl = hostStateRef.current.prevUrl;
|
|
2085
2252
|
if (prevUrl && self.__remote_script_entrypoint_unmount__?.[prevUrl.href]) {
|
|
2086
2253
|
const unmountPromises = Promise.all(
|
|
2087
2254
|
Array.from(unmountRef.current ?? []).map(
|
|
@@ -2094,15 +2261,11 @@ function RemoteComponent({
|
|
|
2094
2261
|
await unmountPromises;
|
|
2095
2262
|
}
|
|
2096
2263
|
}
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2264
|
+
hostStateRef.current.prevIsRemoteComponent = isRemoteComponent;
|
|
2265
|
+
hostStateRef.current.prevUrl = url;
|
|
2266
|
+
hostStateRef.current.prevName = remoteName;
|
|
2100
2267
|
applyOriginToNodes(doc, url, resolveClientUrl);
|
|
2101
|
-
const links =
|
|
2102
|
-
doc.querySelectorAll("link[href]")
|
|
2103
|
-
).filter((link) => {
|
|
2104
|
-
return !component.contains(link);
|
|
2105
|
-
}).map((link) => ({
|
|
2268
|
+
const links = linkElements.map((link) => ({
|
|
2106
2269
|
href: new URL(link.getAttribute("href") ?? link.href, url).href,
|
|
2107
2270
|
...link.getAttributeNames().reduce((acc, key) => {
|
|
2108
2271
|
if (key !== "href") {
|
|
@@ -2111,7 +2274,7 @@ function RemoteComponent({
|
|
|
2111
2274
|
return acc;
|
|
2112
2275
|
}, {})
|
|
2113
2276
|
}));
|
|
2114
|
-
const scripts =
|
|
2277
|
+
const scripts = scriptElements;
|
|
2115
2278
|
const inlineScripts = (isRemoteComponent ? component : doc).querySelectorAll(
|
|
2116
2279
|
"script:not([src]):not([data-src]):not([id*='_rsc']):not([id='__NEXT_DATA__']):not([id='__REMOTE_NEXT_DATA__'])"
|
|
2117
2280
|
);
|
|
@@ -2169,11 +2332,10 @@ function RemoteComponent({
|
|
|
2169
2332
|
});
|
|
2170
2333
|
self.__next_s = prevNextScripts;
|
|
2171
2334
|
}
|
|
2172
|
-
|
|
2335
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2336
|
+
remoteName
|
|
2337
|
+
)}` : void 0;
|
|
2173
2338
|
if (rsc) {
|
|
2174
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2175
|
-
id
|
|
2176
|
-
)}_${escapeString(remoteName)}`;
|
|
2177
2339
|
rsc.textContent = rsc.textContent?.replace(
|
|
2178
2340
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2179
2341
|
`self["${rscName}"]`
|
|
@@ -2191,7 +2353,7 @@ function RemoteComponent({
|
|
|
2191
2353
|
componentHydrationHtml.current = `${Array.from(
|
|
2192
2354
|
doc.querySelectorAll("link,style")
|
|
2193
2355
|
).map((link) => link.outerHTML).join("")}${reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>` : ""}${component.innerHTML}`;
|
|
2194
|
-
const userShared = await
|
|
2356
|
+
const userShared = await shared2;
|
|
2195
2357
|
if ("__remote_components_missing_shared__" in userShared) {
|
|
2196
2358
|
userShared.__remote_components_missing_shared__().catch((e) => {
|
|
2197
2359
|
throw e;
|
|
@@ -2202,7 +2364,7 @@ function RemoteComponent({
|
|
|
2202
2364
|
);
|
|
2203
2365
|
}
|
|
2204
2366
|
if (isRemoteComponent) {
|
|
2205
|
-
if (previousSrc !==
|
|
2367
|
+
if (previousSrc !== void 0) {
|
|
2206
2368
|
onChange?.({
|
|
2207
2369
|
previousSrc,
|
|
2208
2370
|
nextSrc: src,
|
|
@@ -2212,10 +2374,7 @@ function RemoteComponent({
|
|
|
2212
2374
|
}
|
|
2213
2375
|
setData(newData);
|
|
2214
2376
|
if (shadowRoot) {
|
|
2215
|
-
|
|
2216
|
-
if (reset) {
|
|
2217
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2218
|
-
}
|
|
2377
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2219
2378
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2220
2379
|
htmlRef.current = null;
|
|
2221
2380
|
setRemoteComponent(null);
|
|
@@ -2231,7 +2390,7 @@ function RemoteComponent({
|
|
|
2231
2390
|
onLoad?.(src);
|
|
2232
2391
|
} else if (isolate === false) {
|
|
2233
2392
|
setRemoteComponent(
|
|
2234
|
-
/* @__PURE__ */ (0,
|
|
2393
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2235
2394
|
"div",
|
|
2236
2395
|
{
|
|
2237
2396
|
dangerouslySetInnerHTML: { __html: component.innerHTML },
|
|
@@ -2253,12 +2412,13 @@ function RemoteComponent({
|
|
|
2253
2412
|
);
|
|
2254
2413
|
onLoad?.(src);
|
|
2255
2414
|
}
|
|
2415
|
+
hostStateRef.current.stage = "loaded";
|
|
2256
2416
|
} else {
|
|
2257
2417
|
const result = await loadRemoteComponent({
|
|
2258
2418
|
url,
|
|
2259
2419
|
name: remoteName,
|
|
2260
2420
|
rscName,
|
|
2261
|
-
bundle,
|
|
2421
|
+
bundle: metadata.bundle,
|
|
2262
2422
|
route: metadata.route,
|
|
2263
2423
|
runtime: metadata.runtime,
|
|
2264
2424
|
data: newData.data,
|
|
@@ -2282,7 +2442,7 @@ function RemoteComponent({
|
|
|
2282
2442
|
};
|
|
2283
2443
|
}),
|
|
2284
2444
|
shared: {
|
|
2285
|
-
...sharedPolyfills(userShared),
|
|
2445
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2286
2446
|
...userShared
|
|
2287
2447
|
},
|
|
2288
2448
|
remoteShared,
|
|
@@ -2293,7 +2453,7 @@ function RemoteComponent({
|
|
|
2293
2453
|
rsc.remove();
|
|
2294
2454
|
}
|
|
2295
2455
|
setData(newData);
|
|
2296
|
-
if (previousSrc !==
|
|
2456
|
+
if (previousSrc !== void 0) {
|
|
2297
2457
|
onChange?.({
|
|
2298
2458
|
previousSrc,
|
|
2299
2459
|
nextSrc: src,
|
|
@@ -2302,17 +2462,21 @@ function RemoteComponent({
|
|
|
2302
2462
|
});
|
|
2303
2463
|
}
|
|
2304
2464
|
if (result.error) {
|
|
2465
|
+
hostStateRef.current.stage = "error";
|
|
2305
2466
|
setRemoteComponent(result.error);
|
|
2306
2467
|
onError?.(result.error);
|
|
2307
2468
|
} else {
|
|
2469
|
+
hostStateRef.current.stage = "loaded";
|
|
2308
2470
|
setRemoteComponent(result.component);
|
|
2309
2471
|
onLoad?.(src);
|
|
2310
2472
|
}
|
|
2311
2473
|
}
|
|
2312
2474
|
} catch (error) {
|
|
2313
2475
|
if (isAbortError(error)) {
|
|
2476
|
+
hostStateRef.current.stage = "idle";
|
|
2314
2477
|
return;
|
|
2315
2478
|
}
|
|
2479
|
+
hostStateRef.current.stage = "error";
|
|
2316
2480
|
setRemoteComponent(error);
|
|
2317
2481
|
onError?.(error);
|
|
2318
2482
|
}
|
|
@@ -2324,7 +2488,7 @@ function RemoteComponent({
|
|
|
2324
2488
|
isolate,
|
|
2325
2489
|
credentials,
|
|
2326
2490
|
name,
|
|
2327
|
-
|
|
2491
|
+
shared2,
|
|
2328
2492
|
shadowRoot,
|
|
2329
2493
|
reset,
|
|
2330
2494
|
id,
|
|
@@ -2339,13 +2503,13 @@ function RemoteComponent({
|
|
|
2339
2503
|
if (remoteComponent instanceof Error) {
|
|
2340
2504
|
throw remoteComponent;
|
|
2341
2505
|
}
|
|
2342
|
-
const metadataJson = /* @__PURE__ */ (0,
|
|
2506
|
+
const metadataJson = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
|
|
2343
2507
|
name: data?.name || name,
|
|
2344
2508
|
bundle: data?.bundle || "default",
|
|
2345
2509
|
route: data?.route || DEFAULT_ROUTE,
|
|
2346
|
-
runtime:
|
|
2510
|
+
runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
2347
2511
|
}) });
|
|
2348
|
-
const resetStyle = reset ? /* @__PURE__ */ (0,
|
|
2512
|
+
const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
2349
2513
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
|
|
2350
2514
|
"link",
|
|
2351
2515
|
{
|
|
@@ -2354,7 +2518,7 @@ function RemoteComponent({
|
|
|
2354
2518
|
key: JSON.stringify(link)
|
|
2355
2519
|
}
|
|
2356
2520
|
)) || null;
|
|
2357
|
-
const componentToRender = /* @__PURE__ */ (0,
|
|
2521
|
+
const componentToRender = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2358
2522
|
resetStyle,
|
|
2359
2523
|
linksToRender,
|
|
2360
2524
|
remoteComponent ?? children
|
|
@@ -2362,7 +2526,7 @@ function RemoteComponent({
|
|
|
2362
2526
|
if (componentHydrationHtml.current && shadowRoot && !shadowRoot.innerHTML) {
|
|
2363
2527
|
shadowRoot.innerHTML = componentHydrationHtml.current;
|
|
2364
2528
|
componentHydrationHtml.current = null;
|
|
2365
|
-
if (
|
|
2529
|
+
if (hostStateRef.current.prevIsRemoteComponent) {
|
|
2366
2530
|
loadStaticRemoteComponent(
|
|
2367
2531
|
Array.from(shadowRoot.querySelectorAll("script")),
|
|
2368
2532
|
url,
|
|
@@ -2392,9 +2556,9 @@ function RemoteComponent({
|
|
|
2392
2556
|
if (shadowRemoteComponentHtml) {
|
|
2393
2557
|
shadowRemoteComponentHtml.remove();
|
|
2394
2558
|
}
|
|
2395
|
-
return /* @__PURE__ */ (0,
|
|
2559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2396
2560
|
metadataJson,
|
|
2397
|
-
/* @__PURE__ */ (0,
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2398
2562
|
"div",
|
|
2399
2563
|
{
|
|
2400
2564
|
"data-remote-component-id": `shadowroot_${keySuffix}`,
|
|
@@ -2403,8 +2567,8 @@ function RemoteComponent({
|
|
|
2403
2567
|
children: [
|
|
2404
2568
|
typeof document === "undefined" ? (
|
|
2405
2569
|
// eslint-disable-next-line react/no-unknown-property
|
|
2406
|
-
/* @__PURE__ */ (0,
|
|
2407
|
-
typeof document === "undefined" ? /* @__PURE__ */ (0,
|
|
2570
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("template", { shadowrootmode: mode, children: [
|
|
2571
|
+
typeof document === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2408
2572
|
"div",
|
|
2409
2573
|
{
|
|
2410
2574
|
dangerouslySetInnerHTML: {
|
|
@@ -2426,12 +2590,12 @@ function RemoteComponent({
|
|
|
2426
2590
|
] })
|
|
2427
2591
|
) : null,
|
|
2428
2592
|
shadowRoot && remoteComponent ? (0, import_react_dom.createPortal)(
|
|
2429
|
-
/* @__PURE__ */ (0,
|
|
2430
|
-
/* @__PURE__ */ (0,
|
|
2593
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_start` }),
|
|
2431
2595
|
resetStyle,
|
|
2432
2596
|
linksToRender,
|
|
2433
2597
|
remoteComponent,
|
|
2434
|
-
/* @__PURE__ */ (0,
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2435
2599
|
] }),
|
|
2436
2600
|
shadowRoot
|
|
2437
2601
|
) : null
|
|
@@ -2441,33 +2605,16 @@ function RemoteComponent({
|
|
|
2441
2605
|
] });
|
|
2442
2606
|
}
|
|
2443
2607
|
htmlRef.current = null;
|
|
2444
|
-
return /* @__PURE__ */ (0,
|
|
2445
|
-
/* @__PURE__ */ (0,
|
|
2608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_start` }),
|
|
2446
2610
|
metadataJson,
|
|
2447
2611
|
componentToRender,
|
|
2448
|
-
/* @__PURE__ */ (0,
|
|
2612
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2449
2613
|
] });
|
|
2450
2614
|
}
|
|
2451
2615
|
|
|
2452
|
-
// src/
|
|
2453
|
-
var import_context3 = require("#internal/react/context");
|
|
2454
|
-
|
|
2455
|
-
// src/next/host/app-router-compat.tsx
|
|
2616
|
+
// src/host/nextjs/app-compat.tsx
|
|
2456
2617
|
var import_navigation = require("next/navigation");
|
|
2457
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2458
|
-
function imageImpl2(ImageComponent, bundle) {
|
|
2459
|
-
const component = function RemoteImage(props) {
|
|
2460
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2461
|
-
ImageComponent,
|
|
2462
|
-
{
|
|
2463
|
-
...props,
|
|
2464
|
-
src: applyBundleUrlToImagePropsSrc(bundle, props.src)
|
|
2465
|
-
}
|
|
2466
|
-
);
|
|
2467
|
-
};
|
|
2468
|
-
component.default = component;
|
|
2469
|
-
return component;
|
|
2470
|
-
}
|
|
2471
2618
|
var routerImpl = async () => {
|
|
2472
2619
|
const { useRouter } = await import("next/navigation");
|
|
2473
2620
|
return Promise.resolve({
|
|
@@ -2531,17 +2678,34 @@ var routerImpl = async () => {
|
|
|
2531
2678
|
});
|
|
2532
2679
|
};
|
|
2533
2680
|
|
|
2534
|
-
// src/
|
|
2681
|
+
// src/host/nextjs/image-shared.ts
|
|
2682
|
+
function createNextImageSharedEntries(getWrappedImage, options) {
|
|
2683
|
+
const entries = {
|
|
2684
|
+
"next/image": (bundle) => Promise.resolve(getWrappedImage(bundle)),
|
|
2685
|
+
"next/dist/client/image-component": (bundle) => Promise.resolve({
|
|
2686
|
+
Image: getWrappedImage(bundle)
|
|
2687
|
+
})
|
|
2688
|
+
};
|
|
2689
|
+
if (options?.getImageProps) {
|
|
2690
|
+
entries["next/dist/api/image"] = (bundle) => Promise.resolve({
|
|
2691
|
+
default: getWrappedImage(bundle),
|
|
2692
|
+
getImageProps: options.getImageProps
|
|
2693
|
+
});
|
|
2694
|
+
}
|
|
2695
|
+
return entries;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
// src/host/nextjs/app-client-only.tsx
|
|
2535
2699
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2536
2700
|
async function tryImportShared() {
|
|
2537
2701
|
try {
|
|
2538
|
-
const { shared } = await
|
|
2539
|
-
return
|
|
2702
|
+
const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
2703
|
+
return shared2;
|
|
2540
2704
|
} catch {
|
|
2541
2705
|
return {};
|
|
2542
2706
|
}
|
|
2543
2707
|
}
|
|
2544
|
-
var sharedModules = async (userShared) => {
|
|
2708
|
+
var sharedModules = async (userShared, resolveClientUrl) => {
|
|
2545
2709
|
const [resolvedShared, resolvedUserShared] = await Promise.all([
|
|
2546
2710
|
tryImportShared(),
|
|
2547
2711
|
userShared ?? Promise.resolve({})
|
|
@@ -2549,20 +2713,28 @@ var sharedModules = async (userShared) => {
|
|
|
2549
2713
|
return {
|
|
2550
2714
|
...resolvedShared,
|
|
2551
2715
|
"next/router": routerImpl,
|
|
2552
|
-
|
|
2553
|
-
|
|
2716
|
+
...createNextImageSharedEntries(
|
|
2717
|
+
(bundle) => imageImpl2(Image.default, bundle ?? "default", resolveClientUrl)
|
|
2718
|
+
),
|
|
2554
2719
|
...resolvedUserShared
|
|
2555
2720
|
};
|
|
2556
2721
|
};
|
|
2557
|
-
function
|
|
2722
|
+
function ConsumeRemoteComponent2(props) {
|
|
2558
2723
|
if (typeof props.src !== "string" && !(props.src instanceof URL)) {
|
|
2559
2724
|
return props.children ?? null;
|
|
2560
2725
|
}
|
|
2561
|
-
|
|
2726
|
+
const src = typeof props.src === "string" ? props.src : props.src.href;
|
|
2727
|
+
const resolveClientUrl = props.resolveClientUrl ? bindResolveClientUrl(props.resolveClientUrl, src) : void 0;
|
|
2728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2729
|
+
ConsumeRemoteComponent,
|
|
2730
|
+
{
|
|
2731
|
+
...props,
|
|
2732
|
+
shared: sharedModules(props.shared, resolveClientUrl)
|
|
2733
|
+
}
|
|
2734
|
+
);
|
|
2562
2735
|
}
|
|
2563
2736
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2564
2737
|
0 && (module.exports = {
|
|
2565
|
-
|
|
2566
|
-
RemoteComponentsProvider
|
|
2738
|
+
ConsumeRemoteComponent
|
|
2567
2739
|
});
|
|
2568
|
-
//# sourceMappingURL=
|
|
2740
|
+
//# sourceMappingURL=client-only.cjs.map
|