remote-components 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{next/config.cjs → config/nextjs.cjs} +76 -101
- package/dist/config/nextjs.cjs.map +1 -0
- package/dist/{next/config.d.ts → config/nextjs.d.ts} +4 -4
- package/dist/{next/config.js → config/nextjs.js} +72 -97
- package/dist/config/nextjs.js.map +1 -0
- package/dist/{webpack.cjs → config/webpack.cjs} +13 -29
- package/dist/config/webpack.cjs.map +1 -0
- package/dist/{webpack.js → config/webpack.js} +12 -28
- package/dist/config/webpack.js.map +1 -0
- package/dist/{shared/remote → host/defaults}/app.cjs +2 -2
- package/dist/host/defaults/app.cjs.map +1 -0
- package/dist/host/defaults/app.js +8 -0
- package/dist/host/defaults/app.js.map +1 -0
- package/dist/{shared/remote → host/defaults}/pages.cjs +2 -2
- package/dist/host/defaults/pages.cjs.map +1 -0
- package/dist/host/defaults/pages.js +8 -0
- package/dist/host/defaults/pages.js.map +1 -0
- package/dist/{html/host.cjs → host/html.cjs} +1012 -1075
- package/dist/host/html.cjs.map +1 -0
- package/dist/{html/host.d.ts → host/html.d.ts} +0 -2
- package/dist/{html/host.js → host/html.js} +1009 -1071
- package/dist/host/html.js.map +1 -0
- package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +681 -617
- package/dist/host/nextjs/app/client-only.cjs.map +1 -0
- package/dist/host/nextjs/app/client-only.d.ts +16 -0
- package/dist/{next/host/client/index.js → host/nextjs/app/client-only.js} +682 -611
- package/dist/host/nextjs/app/client-only.js.map +1 -0
- package/dist/{next/host/app-router-server.cjs → host/nextjs/app.cjs} +11 -10
- package/dist/host/nextjs/app.cjs.map +1 -0
- package/dist/host/nextjs/app.d.ts +29 -0
- package/dist/{next/host/app-router-server.js → host/nextjs/app.js} +7 -6
- package/dist/host/nextjs/app.js.map +1 -0
- package/dist/{next/host/pages-router-client.cjs → host/nextjs/pages/client-only.cjs} +8 -8
- package/dist/host/nextjs/pages/client-only.cjs.map +1 -0
- package/dist/host/nextjs/pages/client-only.d.ts +31 -0
- package/dist/{next/host/pages-router-client.js → host/nextjs/pages/client-only.js} +4 -4
- package/dist/host/nextjs/pages/client-only.js.map +1 -0
- package/dist/{next/host/pages-router-server.cjs → host/nextjs/pages.cjs} +44 -55
- package/dist/host/nextjs/pages.cjs.map +1 -0
- package/dist/{next/host/pages-router-server.d.ts → host/nextjs/pages.d.ts} +11 -13
- package/dist/{next/host/pages-router-server.js → host/nextjs/pages.js} +38 -49
- package/dist/host/nextjs/pages.js.map +1 -0
- package/dist/host/proxy/client.cjs +57 -0
- package/dist/host/proxy/client.cjs.map +1 -0
- package/dist/host/proxy/client.d.ts +31 -0
- package/dist/host/proxy/client.js +30 -0
- package/dist/host/proxy/client.js.map +1 -0
- package/dist/{shared/host/proxy.cjs → host/proxy/protected-fetch.cjs} +6 -6
- package/dist/host/proxy/protected-fetch.cjs.map +1 -0
- package/dist/{shared/host/proxy.js → host/proxy/protected-fetch.js} +3 -3
- package/dist/host/proxy/protected-fetch.js.map +1 -0
- package/dist/{next → host}/proxy.cjs +12 -92
- package/dist/host/proxy.cjs.map +1 -0
- package/dist/host/proxy.d.ts +30 -0
- package/dist/{next → host}/proxy.js +11 -88
- package/dist/host/proxy.js.map +1 -0
- package/dist/{react/index.cjs → host/react.cjs} +515 -548
- package/dist/host/react.cjs.map +1 -0
- package/dist/{component-loader-21865da3.d.ts → host/react.d.ts} +141 -99
- package/dist/{react/index.js → host/react.js} +514 -545
- package/dist/host/react.js.map +1 -0
- package/dist/internal/{webpack/shared-modules.cjs → config/webpack/apply-shared-modules.cjs} +12 -15
- package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -0
- package/dist/internal/{webpack/shared-modules.js → config/webpack/apply-shared-modules.js} +9 -12
- package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -0
- package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.cjs +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -0
- package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.js +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -0
- package/dist/internal/{next/host/app-router-client.cjs → host/nextjs/app-client.cjs} +29 -24
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -0
- package/dist/internal/host/nextjs/app-client.d.ts +25 -0
- package/dist/internal/{next/host/app-router-client.js → host/nextjs/app-client.js} +19 -19
- package/dist/internal/host/nextjs/app-client.js.map +1 -0
- package/dist/internal/{next/host/app-router-compat.cjs → host/nextjs/app-compat.cjs} +5 -22
- package/dist/internal/host/nextjs/app-compat.cjs.map +1 -0
- package/dist/internal/{next/host/app-router-compat.d.ts → host/nextjs/app-compat.d.ts} +1 -7
- package/dist/internal/{next/host/app-router-compat.js → host/nextjs/app-compat.js} +2 -18
- package/dist/internal/host/nextjs/app-compat.js.map +1 -0
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -0
- package/dist/internal/host/nextjs/dom-flight.d.ts +39 -0
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -0
- package/dist/internal/host/nextjs/image-impl.cjs +60 -0
- package/dist/internal/host/nextjs/image-impl.cjs.map +1 -0
- package/dist/internal/host/nextjs/image-impl.d.ts +10 -0
- package/dist/internal/host/nextjs/image-impl.js +36 -0
- package/dist/internal/host/nextjs/image-impl.js.map +1 -0
- package/dist/internal/host/nextjs/image-shared.cjs +43 -0
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -0
- package/dist/internal/host/nextjs/image-shared.d.ts +9 -0
- package/dist/internal/host/nextjs/image-shared.js +19 -0
- package/dist/internal/host/nextjs/image-shared.js.map +1 -0
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.cjs +2 -2
- package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -0
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.d.ts +1 -1
- package/dist/internal/{next/host → host/nextjs}/remote-component-links.js +2 -2
- package/dist/internal/host/nextjs/remote-component-links.js.map +1 -0
- package/dist/internal/host/nextjs/skeleton.cjs.map +1 -0
- package/dist/internal/host/nextjs/skeleton.js.map +1 -0
- package/dist/internal/{react → host/react}/context.cjs +3 -3
- package/dist/internal/host/react/context.cjs.map +1 -0
- package/dist/internal/{react → host/react}/context.d.ts +4 -4
- package/dist/internal/{react → host/react}/context.js +2 -2
- package/dist/internal/host/react/context.js.map +1 -0
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.cjs +2 -2
- package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -0
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.d.ts +1 -1
- package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.js +2 -2
- package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -0
- package/dist/internal/host/server/fetch-headers.cjs.map +1 -0
- package/dist/internal/host/server/fetch-headers.js.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.cjs +6 -6
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.d.ts +6 -1
- package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.js +9 -9
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.cjs +11 -15
- package/dist/internal/host/server/fetch-with-hooks.cjs.map +1 -0
- package/dist/internal/host/server/fetch-with-hooks.d.ts +21 -0
- package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.js +11 -15
- package/dist/internal/host/server/fetch-with-hooks.js.map +1 -0
- package/dist/internal/host/server/get-client-or-server-url.cjs.map +1 -0
- package/dist/internal/host/server/get-client-or-server-url.js.map +1 -0
- package/dist/internal/{shared/client → host/server}/get-client-src.cjs +1 -1
- package/dist/internal/host/server/get-client-src.cjs.map +1 -0
- package/dist/internal/{shared/client → host/server}/get-client-src.js +1 -1
- package/dist/internal/host/server/get-client-src.js.map +1 -0
- package/dist/internal/host/server/get-ssr-relative-path-base-url.cjs.map +1 -0
- package/dist/internal/host/server/get-ssr-relative-path-base-url.js.map +1 -0
- package/dist/{next/remote/server.cjs → internal/host/server/types.cjs} +3 -15
- package/dist/internal/host/server/types.cjs.map +1 -0
- package/dist/internal/host/server/types.d.ts +33 -0
- package/dist/internal/host/server/types.js +1 -0
- package/dist/internal/host/server/types.js.map +1 -0
- package/dist/internal/host/shared/asset-descriptors.cjs +17 -0
- package/dist/internal/host/shared/asset-descriptors.cjs.map +1 -0
- package/dist/internal/host/shared/asset-descriptors.d.ts +21 -0
- package/dist/internal/host/shared/asset-descriptors.js +1 -0
- package/dist/internal/host/shared/asset-descriptors.js.map +1 -0
- package/dist/internal/host/shared/config.cjs +17 -0
- package/dist/internal/host/shared/config.cjs.map +1 -0
- package/dist/{host-config-58cdccea.d.ts → internal/host/shared/config.d.ts} +32 -19
- package/dist/internal/host/shared/config.js +1 -0
- package/dist/internal/host/shared/config.js.map +1 -0
- package/dist/internal/host/shared/fetch-interceptors.cjs +17 -0
- package/dist/internal/host/shared/fetch-interceptors.cjs.map +1 -0
- package/dist/{types-2b26a246.d.ts → internal/host/shared/fetch-interceptors.d.ts} +4 -87
- package/dist/internal/host/shared/fetch-interceptors.js +1 -0
- package/dist/internal/host/shared/fetch-interceptors.js.map +1 -0
- package/dist/internal/{shared/client → host/shared}/polyfill.cjs +7 -6
- package/dist/internal/host/shared/polyfill.cjs.map +1 -0
- package/dist/internal/{shared/client → host/shared}/polyfill.d.ts +2 -1
- package/dist/internal/{shared/client → host/shared}/polyfill.js +7 -6
- package/dist/internal/host/shared/polyfill.js.map +1 -0
- package/dist/internal/host/shared/resolved-data.cjs +17 -0
- package/dist/internal/host/shared/resolved-data.cjs.map +1 -0
- package/dist/internal/host/shared/resolved-data.d.ts +48 -0
- package/dist/internal/host/shared/resolved-data.js +1 -0
- package/dist/internal/host/shared/resolved-data.js.map +1 -0
- package/dist/internal/{shared/contract/host-state.cjs → host/shared/state.cjs} +4 -4
- package/dist/internal/host/shared/state.cjs.map +1 -0
- package/dist/internal/{shared/contract/host-state.js → host/shared/state.js} +1 -1
- package/dist/internal/host/shared/state.js.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.cjs.map +1 -0
- package/dist/internal/host/utils/resolve-name-from-src.js.map +1 -0
- package/dist/internal/{next/remote/render-client.cjs → remote/nextjs/app-client.cjs} +8 -8
- package/dist/internal/remote/nextjs/app-client.cjs.map +1 -0
- package/dist/internal/{next/remote/render-client.js → remote/nextjs/app-client.js} +4 -4
- package/dist/internal/remote/nextjs/app-client.js.map +1 -0
- package/dist/internal/runtime/constants.cjs +50 -0
- package/dist/internal/runtime/constants.cjs.map +1 -0
- package/dist/internal/runtime/constants.d.ts +10 -0
- package/dist/internal/runtime/constants.js +20 -0
- package/dist/internal/runtime/constants.js.map +1 -0
- package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs.map +1 -1
- package/dist/internal/{shared/client → runtime/html}/apply-origin.d.ts +1 -1
- package/dist/internal/{shared/client → runtime/html}/apply-origin.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +140 -0
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -0
- package/dist/internal/runtime/html/parse-remote-html.d.ts +88 -0
- package/dist/internal/runtime/html/parse-remote-html.js +110 -0
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -0
- package/dist/internal/runtime/html/set-attributes-from-props.cjs +68 -0
- package/dist/internal/runtime/html/set-attributes-from-props.cjs.map +1 -0
- package/dist/internal/runtime/html/set-attributes-from-props.d.ts +3 -0
- package/dist/internal/runtime/html/set-attributes-from-props.js +44 -0
- package/dist/internal/runtime/html/set-attributes-from-props.js.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.cjs +184 -0
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.d.ts +31 -0
- package/dist/internal/runtime/loaders/component-loader.js +150 -0
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -0
- package/dist/internal/runtime/loaders/script-loader.cjs +69 -0
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/script-loader.d.ts +10 -0
- package/dist/internal/runtime/loaders/script-loader.js +48 -0
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -0
- package/dist/internal/runtime/loaders/static-loader.cjs +177 -0
- package/dist/internal/runtime/loaders/static-loader.cjs.map +1 -0
- package/dist/internal/runtime/loaders/static-loader.d.ts +10 -0
- package/dist/internal/runtime/loaders/static-loader.js +153 -0
- package/dist/internal/runtime/loaders/static-loader.js.map +1 -0
- package/dist/internal/runtime/metadata.cjs +17 -0
- package/dist/internal/runtime/metadata.cjs.map +1 -0
- package/dist/internal/runtime/metadata.d.ts +16 -0
- package/dist/internal/runtime/metadata.js +1 -0
- package/dist/internal/runtime/metadata.js.map +1 -0
- package/dist/internal/runtime/rsc.cjs +92 -0
- package/dist/internal/runtime/rsc.cjs.map +1 -0
- package/dist/internal/runtime/rsc.d.ts +8 -0
- package/dist/internal/runtime/rsc.js +68 -0
- package/dist/internal/runtime/rsc.js.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +244 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.d.ts +11 -0
- package/dist/internal/runtime/turbopack/chunk-loader.js +227 -0
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -0
- package/dist/internal/runtime/turbopack/module.cjs +257 -0
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/module.d.ts +61 -0
- package/dist/internal/runtime/turbopack/module.js +233 -0
- package/dist/internal/runtime/turbopack/module.js.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.cjs +44 -0
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.d.ts +109 -0
- package/dist/internal/runtime/turbopack/patterns.js +15 -0
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs +152 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +17 -0
- package/dist/internal/runtime/turbopack/shared-modules.js +133 -0
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs +137 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +20 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.js +107 -0
- package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -0
- package/dist/internal/runtime/types.cjs +17 -0
- package/dist/internal/runtime/types.cjs.map +1 -0
- package/dist/internal/runtime/types.d.ts +40 -0
- package/dist/internal/runtime/types.js +1 -0
- package/dist/internal/runtime/types.js.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.cjs +2 -2
- package/dist/internal/runtime/url/default-resolve-client-url.cjs.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.d.ts +1 -1
- package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.js +1 -1
- package/dist/internal/runtime/url/default-resolve-client-url.js.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.cjs +1 -1
- package/dist/internal/runtime/url/protected-rc-fallback.cjs.map +1 -0
- package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.js +1 -1
- package/dist/internal/runtime/url/protected-rc-fallback.js.map +1 -0
- package/dist/internal/{shared/client/proxy-through-host.cjs → runtime/url/resolve-client-url.cjs} +4 -24
- package/dist/internal/runtime/url/resolve-client-url.cjs.map +1 -0
- package/dist/internal/{shared/client/proxy-through-host.d.ts → runtime/url/resolve-client-url.d.ts} +1 -25
- package/dist/internal/runtime/url/resolve-client-url.js +21 -0
- package/dist/internal/runtime/url/resolve-client-url.js.map +1 -0
- package/dist/internal/utils/abort.cjs.map +1 -0
- package/dist/internal/utils/abort.js.map +1 -0
- package/dist/internal/{shared → utils}/constants.cjs +3 -0
- package/dist/internal/utils/constants.cjs.map +1 -0
- package/dist/internal/utils/constants.d.ts +5 -0
- package/dist/internal/{shared → utils}/constants.js +2 -0
- package/dist/internal/utils/constants.js.map +1 -0
- package/dist/internal/{shared → utils}/error.cjs +4 -4
- package/dist/internal/utils/error.cjs.map +1 -0
- package/dist/internal/{shared → utils}/error.js +4 -4
- package/dist/internal/utils/error.js.map +1 -0
- package/dist/internal/{shared/utils → utils}/logger.cjs +3 -3
- package/dist/internal/utils/logger.cjs.map +1 -0
- package/dist/internal/{shared/utils → utils}/logger.d.ts +2 -2
- package/dist/internal/{shared/utils → utils}/logger.js +3 -3
- package/dist/internal/utils/logger.js.map +1 -0
- package/dist/internal/utils.cjs.map +1 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/{shared/host → remote/defaults}/app.cjs +2 -6
- package/dist/remote/defaults/app.cjs.map +1 -0
- package/dist/remote/defaults/app.js +8 -0
- package/dist/remote/defaults/app.js.map +1 -0
- package/dist/{shared/host → remote/defaults}/pages.cjs +2 -6
- package/dist/remote/defaults/pages.cjs.map +1 -0
- package/dist/remote/defaults/pages.js +8 -0
- package/dist/remote/defaults/pages.js.map +1 -0
- package/dist/{shared/remote → remote/defaults}/wrapper.cjs +12 -10
- package/dist/remote/defaults/wrapper.cjs.map +1 -0
- package/dist/remote/defaults/wrapper.js +27 -0
- package/dist/remote/defaults/wrapper.js.map +1 -0
- package/dist/{html/remote.cjs → remote/html.cjs} +16 -16
- package/dist/remote/html.cjs.map +1 -0
- package/dist/{html/remote.js → remote/html.js} +16 -16
- package/dist/remote/html.js.map +1 -0
- package/dist/{shared/remote/proxy.cjs → remote/middleware.cjs} +37 -12
- package/dist/remote/middleware.cjs.map +1 -0
- package/dist/remote/middleware.d.ts +27 -0
- package/dist/{shared/remote/proxy.js → remote/middleware.js} +32 -5
- package/dist/remote/middleware.js.map +1 -0
- package/dist/{internal/next/remote/render-server.cjs → remote/nextjs/app.cjs} +14 -16
- package/dist/remote/nextjs/app.cjs.map +1 -0
- package/dist/{internal/next/remote/render-server.d.ts → remote/nextjs/app.d.ts} +12 -13
- package/dist/{internal/next/remote/render-server.js → remote/nextjs/app.js} +9 -11
- package/dist/remote/nextjs/app.js.map +1 -0
- package/dist/{next/remote/pages-router.cjs → remote/nextjs/pages.cjs} +8 -8
- package/dist/remote/nextjs/pages.cjs.map +1 -0
- package/dist/{next/remote/pages-router.d.ts → remote/nextjs/pages.d.ts} +8 -8
- package/dist/{next/remote/pages-router.js → remote/nextjs/pages.js} +4 -4
- package/dist/remote/nextjs/pages.js.map +1 -0
- package/dist/server-handoff-8c89b856.d.ts +46 -0
- package/package.json +126 -157
- package/dist/html/host.cjs.map +0 -1
- package/dist/html/host.js.map +0 -1
- package/dist/html/remote.cjs.map +0 -1
- package/dist/html/remote.js.map +0 -1
- package/dist/internal/next/host/app-router-client.cjs.map +0 -1
- package/dist/internal/next/host/app-router-client.d.ts +0 -79
- package/dist/internal/next/host/app-router-client.js.map +0 -1
- package/dist/internal/next/host/app-router-compat.cjs.map +0 -1
- package/dist/internal/next/host/app-router-compat.js.map +0 -1
- package/dist/internal/next/host/remote-component-links.cjs.map +0 -1
- package/dist/internal/next/host/remote-component-links.js.map +0 -1
- package/dist/internal/next/remote/render-client.cjs.map +0 -1
- package/dist/internal/next/remote/render-client.js.map +0 -1
- package/dist/internal/next/remote/render-server.cjs.map +0 -1
- package/dist/internal/next/remote/render-server.js.map +0 -1
- package/dist/internal/react/context.cjs.map +0 -1
- package/dist/internal/react/context.js.map +0 -1
- package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +0 -1
- package/dist/internal/react/hooks/use-resolve-client-url.js.map +0 -1
- package/dist/internal/shared/client/default-resolve-client-url.cjs.map +0 -1
- package/dist/internal/shared/client/default-resolve-client-url.js.map +0 -1
- package/dist/internal/shared/client/get-client-src.cjs.map +0 -1
- package/dist/internal/shared/client/get-client-src.js.map +0 -1
- package/dist/internal/shared/client/polyfill.cjs.map +0 -1
- package/dist/internal/shared/client/polyfill.js.map +0 -1
- package/dist/internal/shared/client/protected-rc-fallback.cjs.map +0 -1
- package/dist/internal/shared/client/protected-rc-fallback.js.map +0 -1
- package/dist/internal/shared/client/proxy-through-host.cjs.map +0 -1
- package/dist/internal/shared/client/proxy-through-host.js +0 -40
- package/dist/internal/shared/client/proxy-through-host.js.map +0 -1
- package/dist/internal/shared/client/remote-component.cjs +0 -1436
- package/dist/internal/shared/client/remote-component.cjs.map +0 -1
- package/dist/internal/shared/client/remote-component.d.ts +0 -62
- package/dist/internal/shared/client/remote-component.js +0 -1385
- package/dist/internal/shared/client/remote-component.js.map +0 -1
- package/dist/internal/shared/constants.cjs.map +0 -1
- package/dist/internal/shared/constants.d.ts +0 -4
- package/dist/internal/shared/constants.js.map +0 -1
- package/dist/internal/shared/contract/host-state.cjs.map +0 -1
- package/dist/internal/shared/contract/host-state.js.map +0 -1
- package/dist/internal/shared/contract/resolve-name-from-src.cjs.map +0 -1
- package/dist/internal/shared/contract/resolve-name-from-src.js.map +0 -1
- package/dist/internal/shared/error.cjs.map +0 -1
- package/dist/internal/shared/error.js.map +0 -1
- package/dist/internal/shared/ssr/dom-flight.cjs.map +0 -1
- package/dist/internal/shared/ssr/dom-flight.d.ts +0 -2
- package/dist/internal/shared/ssr/dom-flight.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-headers.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-headers.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +0 -56
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +0 -1
- package/dist/internal/shared/ssr/get-client-or-server-url.cjs.map +0 -1
- package/dist/internal/shared/ssr/get-client-or-server-url.js.map +0 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +0 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +0 -1
- package/dist/internal/shared/ssr/skeleton.cjs.map +0 -1
- package/dist/internal/shared/ssr/skeleton.js.map +0 -1
- package/dist/internal/shared/utils/abort.cjs.map +0 -1
- package/dist/internal/shared/utils/abort.js.map +0 -1
- package/dist/internal/shared/utils/logger.cjs.map +0 -1
- package/dist/internal/shared/utils/logger.js.map +0 -1
- package/dist/internal/shared/utils.cjs.map +0 -1
- package/dist/internal/shared/utils.js.map +0 -1
- package/dist/internal/webpack/next-client-pages-loader.cjs.map +0 -1
- package/dist/internal/webpack/next-client-pages-loader.js.map +0 -1
- package/dist/internal/webpack/shared-modules.cjs.map +0 -1
- package/dist/internal/webpack/shared-modules.js.map +0 -1
- package/dist/next/config.cjs.map +0 -1
- package/dist/next/config.js.map +0 -1
- package/dist/next/host/app-router-server.cjs.map +0 -1
- package/dist/next/host/app-router-server.d.ts +0 -30
- package/dist/next/host/app-router-server.js.map +0 -1
- package/dist/next/host/client/index.cjs.map +0 -1
- package/dist/next/host/client/index.d.ts +0 -19
- package/dist/next/host/client/index.js.map +0 -1
- package/dist/next/host/pages-router-client.cjs.map +0 -1
- package/dist/next/host/pages-router-client.d.ts +0 -33
- package/dist/next/host/pages-router-client.js.map +0 -1
- package/dist/next/host/pages-router-server.cjs.map +0 -1
- package/dist/next/host/pages-router-server.js.map +0 -1
- package/dist/next/index.cjs +0 -53
- package/dist/next/index.cjs.map +0 -1
- package/dist/next/index.d.ts +0 -30
- package/dist/next/index.js +0 -19
- package/dist/next/index.js.map +0 -1
- package/dist/next/proxy.cjs.map +0 -1
- package/dist/next/proxy.d.ts +0 -56
- package/dist/next/proxy.js.map +0 -1
- package/dist/next/remote/pages-router.cjs.map +0 -1
- package/dist/next/remote/pages-router.js.map +0 -1
- package/dist/next/remote/server.cjs.map +0 -1
- package/dist/next/remote/server.d.ts +0 -5
- package/dist/next/remote/server.js +0 -5
- package/dist/next/remote/server.js.map +0 -1
- package/dist/proxy-through-host-a676a522.d.ts +0 -52
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -86
- package/dist/react/index.js.map +0 -1
- package/dist/shared/host/app.cjs.map +0 -1
- package/dist/shared/host/app.js +0 -12
- package/dist/shared/host/app.js.map +0 -1
- package/dist/shared/host/pages.cjs.map +0 -1
- package/dist/shared/host/pages.js +0 -12
- package/dist/shared/host/pages.js.map +0 -1
- package/dist/shared/host/proxy.cjs.map +0 -1
- package/dist/shared/host/proxy.js.map +0 -1
- package/dist/shared/remote/app.cjs.map +0 -1
- package/dist/shared/remote/app.js +0 -8
- package/dist/shared/remote/app.js.map +0 -1
- package/dist/shared/remote/pages.cjs.map +0 -1
- package/dist/shared/remote/pages.js +0 -8
- package/dist/shared/remote/pages.js.map +0 -1
- package/dist/shared/remote/proxy.cjs.map +0 -1
- package/dist/shared/remote/proxy.d.ts +0 -44
- package/dist/shared/remote/proxy.js.map +0 -1
- package/dist/shared/remote/wrapper.cjs.map +0 -1
- package/dist/shared/remote/wrapper.js +0 -25
- package/dist/shared/remote/wrapper.js.map +0 -1
- package/dist/webpack.cjs.map +0 -1
- package/dist/webpack.js.map +0 -1
- /package/dist/{webpack.d.ts → config/webpack.d.ts} +0 -0
- /package/dist/{shared/host → host/defaults}/app.d.ts +0 -0
- /package/dist/{shared/host → host/defaults}/pages.d.ts +0 -0
- /package/dist/{shared/host/proxy.d.ts → host/proxy/protected-fetch.d.ts} +0 -0
- /package/dist/internal/{webpack/shared-modules.d.ts → config/webpack/apply-shared-modules.d.ts} +0 -0
- /package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.js +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.js +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/fetch-headers.js +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.js +0 -0
- /package/dist/internal/{shared/client → host/server}/get-client-src.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.cjs +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.d.ts +0 -0
- /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.js +0 -0
- /package/dist/internal/{shared/contract/host-state.d.ts → host/shared/state.d.ts} +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.cjs +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.d.ts +0 -0
- /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.js +0 -0
- /package/dist/internal/{next/remote/render-client.d.ts → remote/nextjs/app-client.d.ts} +0 -0
- /package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs +0 -0
- /package/dist/internal/{shared/client → runtime/html}/apply-origin.js +0 -0
- /package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.d.ts +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.cjs +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.d.ts +0 -0
- /package/dist/internal/{shared/utils → utils}/abort.js +0 -0
- /package/dist/internal/{shared → utils}/error.d.ts +0 -0
- /package/dist/internal/{shared/utils.cjs → utils.cjs} +0 -0
- /package/dist/internal/{shared/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/internal/{shared/utils.js → utils.js} +0 -0
- /package/dist/{shared/remote → remote/defaults}/app.d.ts +0 -0
- /package/dist/{shared/remote → remote/defaults}/pages.d.ts +0 -0
- /package/dist/{shared/remote → remote/defaults}/wrapper.d.ts +0 -0
- /package/dist/{html/remote.d.ts → remote/html.d.ts} +0 -0
|
@@ -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
|
-
|
|
40
|
-
// src/react/index.tsx
|
|
41
|
-
var import_react3 = require("react");
|
|
42
|
-
var import_react_dom = require("react-dom");
|
|
43
44
|
|
|
44
|
-
// src/
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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,123 +175,7 @@ Docs: ${CORS_DOCS_URL}`
|
|
|
211
175
|
);
|
|
212
176
|
}
|
|
213
177
|
|
|
214
|
-
// src/
|
|
215
|
-
function escapeString(str) {
|
|
216
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
217
|
-
}
|
|
218
|
-
var attrToProp = {
|
|
219
|
-
fetchpriority: "fetchPriority",
|
|
220
|
-
crossorigin: "crossOrigin",
|
|
221
|
-
imagesrcset: "imageSrcSet",
|
|
222
|
-
imagesizes: "imageSizes",
|
|
223
|
-
srcset: "srcSet"
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// src/shared/client/const.ts
|
|
227
|
-
var DEFAULT_ROUTE = "/";
|
|
228
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
229
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
230
|
-
var RUNTIME_SCRIPT = "script";
|
|
231
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
232
|
-
function getBundleKey(bundle) {
|
|
233
|
-
return escapeString(bundle);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/shared/client/parse-remote-html.ts
|
|
237
|
-
function validateSingleComponent(doc, name, url) {
|
|
238
|
-
if (doc.querySelectorAll("div[data-bundle][data-route]").length > 1 && !doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
239
|
-
throw multipleRemoteComponentsError(url);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
function findComponentElement(doc, name) {
|
|
243
|
-
return doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) ?? doc.querySelector("div[data-bundle][data-route]") ?? doc.querySelector("div#__next") ?? doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
|
|
244
|
-
}
|
|
245
|
-
function parseNextData(doc) {
|
|
246
|
-
return JSON.parse(
|
|
247
|
-
(doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
function resolveComponentName(component, nextData, fallbackName) {
|
|
251
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
|
|
252
|
-
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
253
|
-
return { name, isRemoteComponent };
|
|
254
|
-
}
|
|
255
|
-
function extractComponentMetadata(component, nextData, name, url) {
|
|
256
|
-
return {
|
|
257
|
-
name,
|
|
258
|
-
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
259
|
-
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
260
|
-
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function extractRemoteShared(doc, name, nextData) {
|
|
264
|
-
const remoteSharedEl = doc.querySelector(
|
|
265
|
-
`#${name}_shared[data-remote-components-shared]`
|
|
266
|
-
);
|
|
267
|
-
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
268
|
-
remoteSharedEl?.remove();
|
|
269
|
-
return remoteShared;
|
|
270
|
-
}
|
|
271
|
-
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
272
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
273
|
-
throw new RemoteComponentsError(
|
|
274
|
-
`Remote Component not found on ${url}.${name !== "__vercel_remote_component" ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function extractLinks(doc, component) {
|
|
279
|
-
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
280
|
-
(link) => !component.contains(link)
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
function extractScripts(doc, component, isRemoteComponent) {
|
|
284
|
-
return Array.from(
|
|
285
|
-
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
286
|
-
"script[src],script[data-src]"
|
|
287
|
-
)
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
function parseRemoteComponentDocument(doc, name, url) {
|
|
291
|
-
validateSingleComponent(doc, name, url.href);
|
|
292
|
-
const component = findComponentElement(doc, name);
|
|
293
|
-
const nextData = parseNextData(doc);
|
|
294
|
-
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
295
|
-
component,
|
|
296
|
-
nextData,
|
|
297
|
-
name
|
|
298
|
-
);
|
|
299
|
-
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
300
|
-
const metadata = extractComponentMetadata(
|
|
301
|
-
component,
|
|
302
|
-
nextData,
|
|
303
|
-
resolvedName,
|
|
304
|
-
url
|
|
305
|
-
);
|
|
306
|
-
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
307
|
-
validateComponentFound(
|
|
308
|
-
component,
|
|
309
|
-
rsc,
|
|
310
|
-
nextData,
|
|
311
|
-
isRemoteComponent,
|
|
312
|
-
url.href,
|
|
313
|
-
resolvedName
|
|
314
|
-
);
|
|
315
|
-
const links = extractLinks(doc, component);
|
|
316
|
-
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
317
|
-
return {
|
|
318
|
-
component,
|
|
319
|
-
name: resolvedName,
|
|
320
|
-
isRemoteComponent,
|
|
321
|
-
metadata,
|
|
322
|
-
nextData,
|
|
323
|
-
rsc,
|
|
324
|
-
remoteShared,
|
|
325
|
-
links,
|
|
326
|
-
scripts
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/shared/utils/logger.ts
|
|
178
|
+
// src/utils/logger.ts
|
|
331
179
|
var PREFIX = "remote-components";
|
|
332
180
|
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
333
181
|
function logDebug(location2, message) {
|
|
@@ -353,13 +201,13 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
353
201
|
}
|
|
354
202
|
logWarn(
|
|
355
203
|
logLocation,
|
|
356
|
-
`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}`
|
|
357
205
|
);
|
|
358
206
|
} catch {
|
|
359
207
|
}
|
|
360
208
|
}
|
|
361
209
|
|
|
362
|
-
// src/shared/
|
|
210
|
+
// src/host/shared/polyfill.tsx
|
|
363
211
|
var import_jsx_runtime = (
|
|
364
212
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
365
213
|
require("react/jsx-runtime")
|
|
@@ -382,7 +230,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
|
382
230
|
const propSrc = src;
|
|
383
231
|
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
384
232
|
}
|
|
385
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
233
|
+
var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
|
|
386
234
|
fill: _fill,
|
|
387
235
|
loader: _loader,
|
|
388
236
|
quality: _quality,
|
|
@@ -399,21 +247,22 @@ var imageImpl = (bundle) => function RemoteImage({
|
|
|
399
247
|
bundle,
|
|
400
248
|
typeof src === "string" ? src : src.src
|
|
401
249
|
);
|
|
250
|
+
const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
402
251
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
403
252
|
"img",
|
|
404
253
|
{
|
|
405
254
|
decoding: "async",
|
|
406
255
|
style: { color: "transparent" },
|
|
407
256
|
...props,
|
|
408
|
-
src:
|
|
257
|
+
src: proxiedSrc,
|
|
409
258
|
suppressHydrationWarning: true
|
|
410
259
|
}
|
|
411
260
|
);
|
|
412
261
|
};
|
|
413
|
-
function sharedPolyfills(
|
|
262
|
+
function sharedPolyfills(shared2, resolveClientUrl) {
|
|
414
263
|
const self = globalThis;
|
|
415
264
|
const polyfill = {
|
|
416
|
-
"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({
|
|
417
266
|
useRouter() {
|
|
418
267
|
return {
|
|
419
268
|
push: (routerUrl) => {
|
|
@@ -444,7 +293,7 @@ function sharedPolyfills(shared) {
|
|
|
444
293
|
},
|
|
445
294
|
__esModule: true
|
|
446
295
|
})),
|
|
447
|
-
"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({
|
|
448
297
|
default: ({
|
|
449
298
|
scroll: _,
|
|
450
299
|
replace,
|
|
@@ -494,18 +343,18 @@ function sharedPolyfills(shared) {
|
|
|
494
343
|
},
|
|
495
344
|
__esModule: true
|
|
496
345
|
})),
|
|
497
|
-
"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({
|
|
498
347
|
default: () => {
|
|
499
348
|
throw new Error("Next.js <Form> component not implemented");
|
|
500
349
|
},
|
|
501
350
|
__esModule: true
|
|
502
351
|
})),
|
|
503
|
-
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ??
|
|
504
|
-
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),
|
|
505
354
|
__esModule: true
|
|
506
355
|
})),
|
|
507
|
-
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ??
|
|
508
|
-
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),
|
|
509
358
|
getImageProps: (_imgProps) => {
|
|
510
359
|
throw new Error(
|
|
511
360
|
"Next.js getImageProps() is not implemented in remote components"
|
|
@@ -513,13 +362,13 @@ function sharedPolyfills(shared) {
|
|
|
513
362
|
},
|
|
514
363
|
__esModule: true
|
|
515
364
|
})),
|
|
516
|
-
"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({
|
|
517
366
|
// TODO: implement <Script> component for non-Next.js host applications
|
|
518
367
|
// do not throw an error for now
|
|
519
368
|
default: () => null,
|
|
520
369
|
__esModule: true
|
|
521
370
|
})),
|
|
522
|
-
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ??
|
|
371
|
+
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared2?.["next/router"] ?? (() => (
|
|
523
372
|
// TODO: incomplete implementation
|
|
524
373
|
Promise.resolve({
|
|
525
374
|
useRouter() {
|
|
@@ -555,126 +404,377 @@ function sharedPolyfills(shared) {
|
|
|
555
404
|
return polyfill;
|
|
556
405
|
}
|
|
557
406
|
|
|
558
|
-
// src/
|
|
559
|
-
var
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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
|
+
}
|
|
564
439
|
|
|
565
|
-
// src/
|
|
566
|
-
function
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
nextCssEnd.setAttribute("data-route", route);
|
|
582
|
-
document.head.appendChild(nextCssEnd);
|
|
583
|
-
document.head.appendChild(nextCss);
|
|
584
|
-
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
585
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
586
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
587
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
588
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
589
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
590
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
591
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
592
|
-
) ?? ""] ?? -1;
|
|
593
|
-
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
594
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
595
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
596
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
597
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
598
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
599
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
600
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
601
|
-
) ?? ""] ?? -1;
|
|
602
|
-
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
603
|
-
throw new RemoteComponentsError(
|
|
604
|
-
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
605
|
-
);
|
|
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;
|
|
606
456
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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;
|
|
617
491
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
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);
|
|
643
615
|
}
|
|
644
|
-
});
|
|
645
|
-
const elements = [];
|
|
646
|
-
let node = nextCss.previousSibling;
|
|
647
|
-
while (node && node !== nextCssEnd) {
|
|
648
|
-
elements.push(node);
|
|
649
|
-
node.remove();
|
|
650
|
-
node = nextCss.previousSibling;
|
|
651
616
|
}
|
|
652
|
-
|
|
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;
|
|
653
756
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
658
|
-
});
|
|
757
|
+
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
758
|
+
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
759
|
+
el[attr] = Boolean(value);
|
|
659
760
|
} else {
|
|
660
|
-
|
|
661
|
-
elements.forEach((el) => {
|
|
662
|
-
document.head.appendChild(el);
|
|
663
|
-
});
|
|
761
|
+
el.setAttribute(attr, String(value));
|
|
664
762
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
763
|
+
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
764
|
+
el.setAttribute(attr, "");
|
|
765
|
+
el.removeAttribute(attr);
|
|
669
766
|
}
|
|
670
|
-
nextCss.remove();
|
|
671
|
-
nextCssEnd.remove();
|
|
672
|
-
return { Component, App };
|
|
673
767
|
}
|
|
674
|
-
return { Component: null, App: null };
|
|
675
768
|
}
|
|
676
769
|
|
|
677
|
-
// src/
|
|
770
|
+
// src/runtime/loaders/component-loader.ts
|
|
771
|
+
var React = __toESM(require("react"), 1);
|
|
772
|
+
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
773
|
+
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
774
|
+
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
775
|
+
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
776
|
+
|
|
777
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
678
778
|
function applySharedModules(bundle, resolve) {
|
|
679
779
|
logDebug(
|
|
680
780
|
"SharedModules",
|
|
@@ -694,28 +794,25 @@ function applySharedModules(bundle, resolve) {
|
|
|
694
794
|
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
695
795
|
);
|
|
696
796
|
for (const [key, value] of Object.entries(resolve)) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
700
|
-
}
|
|
797
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
798
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
701
799
|
if (ids.length === 0) {
|
|
702
800
|
logDebug(
|
|
703
801
|
"SharedModules",
|
|
704
802
|
`No matching module path found for shared module "${key}"`
|
|
705
803
|
);
|
|
706
804
|
}
|
|
707
|
-
for (
|
|
805
|
+
for (const id of ids) {
|
|
708
806
|
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
709
807
|
if (webpackBundle.m) {
|
|
710
|
-
|
|
711
|
-
|
|
808
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
809
|
+
if (resolvedId !== id) {
|
|
712
810
|
logDebug(
|
|
713
811
|
"SharedModules",
|
|
714
|
-
`Mapped module id: "${id}" -> "${
|
|
812
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
715
813
|
);
|
|
716
|
-
id = mappedId;
|
|
717
814
|
}
|
|
718
|
-
webpackBundle.m[
|
|
815
|
+
webpackBundle.m[resolvedId] = (module2) => {
|
|
719
816
|
module2.exports = value;
|
|
720
817
|
};
|
|
721
818
|
} else {
|
|
@@ -726,16 +823,128 @@ function applySharedModules(bundle, resolve) {
|
|
|
726
823
|
}
|
|
727
824
|
}
|
|
728
825
|
}
|
|
729
|
-
} else {
|
|
730
|
-
logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
|
|
731
|
-
logDebug(
|
|
732
|
-
"SharedModules",
|
|
733
|
-
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
734
|
-
);
|
|
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
|
|
836
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
837
|
+
const self = globalThis;
|
|
838
|
+
const nextCssOriginal = document.querySelector(
|
|
839
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
840
|
+
);
|
|
841
|
+
if (nextCssOriginal) {
|
|
842
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
843
|
+
}
|
|
844
|
+
const nextCss = document.createElement("noscript");
|
|
845
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
846
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
847
|
+
nextCss.setAttribute("data-route", route);
|
|
848
|
+
const nextCssEnd = document.createElement("noscript");
|
|
849
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
850
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
851
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
852
|
+
document.head.appendChild(nextCssEnd);
|
|
853
|
+
document.head.appendChild(nextCss);
|
|
854
|
+
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
855
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
856
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
857
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
858
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
859
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
860
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
861
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
862
|
+
) ?? ""] ?? -1;
|
|
863
|
+
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
864
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
865
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
866
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
867
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
868
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
869
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
870
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
871
|
+
) ?? ""] ?? -1;
|
|
872
|
+
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
873
|
+
throw new RemoteComponentsError(
|
|
874
|
+
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
878
|
+
const selfOriginal = self;
|
|
879
|
+
delete selfOriginal.__NEXT_P;
|
|
880
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
881
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
882
|
+
);
|
|
883
|
+
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
884
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
885
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
if (self.__NEXT_P) {
|
|
889
|
+
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
890
|
+
void 0,
|
|
891
|
+
() => ({ default: null })
|
|
892
|
+
];
|
|
893
|
+
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
894
|
+
void 0,
|
|
895
|
+
() => ({
|
|
896
|
+
default: null
|
|
897
|
+
})
|
|
898
|
+
];
|
|
899
|
+
const { default: Component } = componentLoader();
|
|
900
|
+
const { default: App } = appLoader();
|
|
901
|
+
if (!self.__remote_next_css__) {
|
|
902
|
+
self.__remote_next_css__ = {};
|
|
903
|
+
}
|
|
904
|
+
if (!self.__remote_next_css__[bundle]) {
|
|
905
|
+
const cssRE = /\.s?css$/;
|
|
906
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
907
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
908
|
+
});
|
|
909
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
910
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
911
|
+
if (id) {
|
|
912
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
const elements = [];
|
|
916
|
+
let node = nextCss.previousSibling;
|
|
917
|
+
while (node && node !== nextCssEnd) {
|
|
918
|
+
elements.push(node);
|
|
919
|
+
node.remove();
|
|
920
|
+
node = nextCss.previousSibling;
|
|
921
|
+
}
|
|
922
|
+
self.__remote_next_css__[bundle] = elements;
|
|
923
|
+
}
|
|
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 };
|
|
735
943
|
}
|
|
944
|
+
return { Component: null, App: null };
|
|
736
945
|
}
|
|
737
946
|
|
|
738
|
-
// src/
|
|
947
|
+
// src/runtime/rsc.ts
|
|
739
948
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
740
949
|
function fixPayload(payload) {
|
|
741
950
|
if (Array.isArray(payload)) {
|
|
@@ -801,56 +1010,18 @@ function createRSCStream(rscName, data) {
|
|
|
801
1010
|
});
|
|
802
1011
|
}
|
|
803
1012
|
|
|
804
|
-
// src/
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
// src/shared/client/script-loader.ts
|
|
808
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
809
|
-
await Promise.all(
|
|
810
|
-
scripts.map((script) => {
|
|
811
|
-
return new Promise((resolve, reject) => {
|
|
812
|
-
const newSrc = new URL(
|
|
813
|
-
// remove the remote component bundle name identifier from the script src
|
|
814
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
815
|
-
location.origin
|
|
816
|
-
).href;
|
|
817
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
818
|
-
const newScript = document.createElement("script");
|
|
819
|
-
newScript.onload = () => resolve();
|
|
820
|
-
newScript.onerror = () => {
|
|
821
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
822
|
-
if (isProxied) {
|
|
823
|
-
reject(
|
|
824
|
-
new RemoteComponentsError(
|
|
825
|
-
`Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
826
|
-
)
|
|
827
|
-
);
|
|
828
|
-
} else {
|
|
829
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
830
|
-
reject(
|
|
831
|
-
new RemoteComponentsError(
|
|
832
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
833
|
-
)
|
|
834
|
-
);
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
newScript.src = resolvedSrc;
|
|
838
|
-
newScript.async = true;
|
|
839
|
-
document.head.appendChild(newScript);
|
|
840
|
-
});
|
|
841
|
-
})
|
|
842
|
-
);
|
|
843
|
-
}
|
|
1013
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
1014
|
+
init_constants();
|
|
844
1015
|
|
|
845
|
-
// src/
|
|
1016
|
+
// src/runtime/turbopack/patterns.ts
|
|
846
1017
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
847
|
-
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]+)\)/;
|
|
848
1019
|
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
849
1020
|
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
850
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]+)\)\)\)\}/;
|
|
851
1022
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
852
1023
|
|
|
853
|
-
// src/
|
|
1024
|
+
// src/runtime/turbopack/chunk-loader.ts
|
|
854
1025
|
function createChunkLoader(runtime, resolveClientUrl) {
|
|
855
1026
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
856
1027
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
@@ -912,7 +1083,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
912
1083
|
if (isProxied) {
|
|
913
1084
|
reject(
|
|
914
1085
|
new RemoteComponentsError(
|
|
915
|
-
`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}`
|
|
916
1087
|
)
|
|
917
1088
|
);
|
|
918
1089
|
} else {
|
|
@@ -1062,7 +1233,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1062
1233
|
}
|
|
1063
1234
|
}
|
|
1064
1235
|
|
|
1065
|
-
// src/
|
|
1236
|
+
// src/runtime/turbopack/module.ts
|
|
1066
1237
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
1067
1238
|
const self = globalThis;
|
|
1068
1239
|
const bundleKey = getBundleKey(bundle);
|
|
@@ -1291,7 +1462,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1291
1462
|
};
|
|
1292
1463
|
}
|
|
1293
1464
|
|
|
1294
|
-
// src/
|
|
1465
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1295
1466
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1296
1467
|
const self = globalThis;
|
|
1297
1468
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1328,9 +1499,9 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1328
1499
|
}
|
|
1329
1500
|
}
|
|
1330
1501
|
if (sharedModuleInitializer) {
|
|
1331
|
-
const { shared } = await sharedModuleInitializer;
|
|
1502
|
+
const { shared: shared2 } = await sharedModuleInitializer;
|
|
1332
1503
|
const sharedModuleIds = extractSharedModuleIds(
|
|
1333
|
-
|
|
1504
|
+
shared2,
|
|
1334
1505
|
bundleKey,
|
|
1335
1506
|
self
|
|
1336
1507
|
);
|
|
@@ -1366,8 +1537,8 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1366
1537
|
})
|
|
1367
1538
|
);
|
|
1368
1539
|
}
|
|
1369
|
-
function extractSharedModuleIds(
|
|
1370
|
-
return Object.entries(
|
|
1540
|
+
function extractSharedModuleIds(shared2, bundleKey, self) {
|
|
1541
|
+
return Object.entries(shared2).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1371
1542
|
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1372
1543
|
if (asyncSharedModuleId) {
|
|
1373
1544
|
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
@@ -1411,8 +1582,8 @@ function getSharedModule(bundle, id) {
|
|
|
1411
1582
|
return null;
|
|
1412
1583
|
}
|
|
1413
1584
|
|
|
1414
|
-
// src/
|
|
1415
|
-
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) {
|
|
1416
1587
|
const self = globalThis;
|
|
1417
1588
|
if (!self.__remote_bundle_url__) {
|
|
1418
1589
|
self.__remote_bundle_url__ = {};
|
|
@@ -1449,7 +1620,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1449
1620
|
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1450
1621
|
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1451
1622
|
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1452
|
-
...
|
|
1623
|
+
...shared2
|
|
1453
1624
|
};
|
|
1454
1625
|
await initializeSharedModules(
|
|
1455
1626
|
bundle ?? "default",
|
|
@@ -1466,7 +1637,7 @@ function createModuleRequire(runtime) {
|
|
|
1466
1637
|
id
|
|
1467
1638
|
};
|
|
1468
1639
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1469
|
-
logDebug("
|
|
1640
|
+
logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
|
|
1470
1641
|
try {
|
|
1471
1642
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1472
1643
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
@@ -1482,7 +1653,7 @@ function createModuleRequire(runtime) {
|
|
|
1482
1653
|
throw new Error(`Module "${id}" not found.`);
|
|
1483
1654
|
} catch (requireError) {
|
|
1484
1655
|
logWarn(
|
|
1485
|
-
"
|
|
1656
|
+
"WebpackRuntime",
|
|
1486
1657
|
`Module require failed: ${String(requireError)}`
|
|
1487
1658
|
);
|
|
1488
1659
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
@@ -1494,7 +1665,7 @@ function createModuleRequire(runtime) {
|
|
|
1494
1665
|
);
|
|
1495
1666
|
}
|
|
1496
1667
|
try {
|
|
1497
|
-
logDebug("
|
|
1668
|
+
logDebug("WebpackRuntime", "Falling back to original webpack require");
|
|
1498
1669
|
return self.__original_webpack_require__(id);
|
|
1499
1670
|
} catch (originalError) {
|
|
1500
1671
|
throw new RemoteComponentsError(
|
|
@@ -1506,7 +1677,46 @@ function createModuleRequire(runtime) {
|
|
|
1506
1677
|
};
|
|
1507
1678
|
}
|
|
1508
1679
|
|
|
1509
|
-
// 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
|
|
1510
1720
|
async function loadRemoteComponent({
|
|
1511
1721
|
url,
|
|
1512
1722
|
name,
|
|
@@ -1517,7 +1727,7 @@ async function loadRemoteComponent({
|
|
|
1517
1727
|
data,
|
|
1518
1728
|
nextData,
|
|
1519
1729
|
scripts = [],
|
|
1520
|
-
shared = Promise.resolve({}),
|
|
1730
|
+
shared: shared2 = Promise.resolve({}),
|
|
1521
1731
|
remoteShared = {},
|
|
1522
1732
|
container,
|
|
1523
1733
|
resolveClientUrl
|
|
@@ -1531,7 +1741,7 @@ async function loadRemoteComponent({
|
|
|
1531
1741
|
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1532
1742
|
await loadScripts(scripts, resolveClientUrl);
|
|
1533
1743
|
}
|
|
1534
|
-
const hostShared = await
|
|
1744
|
+
const hostShared = await shared2;
|
|
1535
1745
|
logDebug(
|
|
1536
1746
|
"ComponentLoader",
|
|
1537
1747
|
`loadRemoteComponent: bundle="${bundle}", name="${name}"`
|
|
@@ -1609,17 +1819,19 @@ async function loadRemoteComponent({
|
|
|
1609
1819
|
};
|
|
1610
1820
|
}
|
|
1611
1821
|
}
|
|
1612
|
-
async function
|
|
1613
|
-
let createFromReadableStream;
|
|
1822
|
+
async function importCreateFromReadableStream() {
|
|
1614
1823
|
try {
|
|
1615
|
-
const { createFromReadableStream
|
|
1616
|
-
createFromReadableStream
|
|
1824
|
+
const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
|
|
1825
|
+
return createFromReadableStream;
|
|
1617
1826
|
} catch {
|
|
1618
1827
|
const {
|
|
1619
|
-
default: { createFromReadableStream
|
|
1828
|
+
default: { createFromReadableStream }
|
|
1620
1829
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1621
|
-
createFromReadableStream
|
|
1830
|
+
return createFromReadableStream;
|
|
1622
1831
|
}
|
|
1832
|
+
}
|
|
1833
|
+
async function loadRSCComponent(rscName, data) {
|
|
1834
|
+
const createFromReadableStream = await importCreateFromReadableStream();
|
|
1623
1835
|
if (typeof createFromReadableStream !== "function") {
|
|
1624
1836
|
throw new RemoteComponentsError(
|
|
1625
1837
|
'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
|
|
@@ -1640,68 +1852,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
1640
1852
|
return { component };
|
|
1641
1853
|
}
|
|
1642
1854
|
|
|
1643
|
-
// src/
|
|
1644
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1645
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
1646
|
-
return (url) => {
|
|
1647
|
-
const urlOrigin = parseOrigin(url);
|
|
1648
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
1649
|
-
return void 0;
|
|
1650
|
-
}
|
|
1651
|
-
return resolveClientUrl(remoteSrc, url);
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
|
-
function parseOrigin(url) {
|
|
1655
|
-
try {
|
|
1656
|
-
return new URL(url).origin;
|
|
1657
|
-
} catch {
|
|
1658
|
-
return void 0;
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
// src/shared/client/set-attributes-from-props.ts
|
|
1663
|
-
var DOMAttributeNames = {
|
|
1664
|
-
acceptCharset: "accept-charset",
|
|
1665
|
-
className: "class",
|
|
1666
|
-
htmlFor: "for",
|
|
1667
|
-
httpEquiv: "http-equiv",
|
|
1668
|
-
noModule: "noModule"
|
|
1669
|
-
};
|
|
1670
|
-
var ignoreProps = [
|
|
1671
|
-
"onLoad",
|
|
1672
|
-
"onReady",
|
|
1673
|
-
"dangerouslySetInnerHTML",
|
|
1674
|
-
"children",
|
|
1675
|
-
"onError",
|
|
1676
|
-
"strategy",
|
|
1677
|
-
"stylesheets"
|
|
1678
|
-
];
|
|
1679
|
-
function isBooleanScriptAttribute(attr) {
|
|
1680
|
-
return ["async", "defer", "noModule"].includes(attr);
|
|
1681
|
-
}
|
|
1682
|
-
function setAttributesFromProps(el, props) {
|
|
1683
|
-
for (const [p, value] of Object.entries(props)) {
|
|
1684
|
-
if (!Object.hasOwn(props, p))
|
|
1685
|
-
continue;
|
|
1686
|
-
if (ignoreProps.includes(p))
|
|
1687
|
-
continue;
|
|
1688
|
-
if (value === void 0) {
|
|
1689
|
-
continue;
|
|
1690
|
-
}
|
|
1691
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
1692
|
-
if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
|
|
1693
|
-
el[attr] = Boolean(value);
|
|
1694
|
-
} else {
|
|
1695
|
-
el.setAttribute(attr, String(value));
|
|
1696
|
-
}
|
|
1697
|
-
if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
|
|
1698
|
-
el.setAttribute(attr, "");
|
|
1699
|
-
el.removeAttribute(attr);
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// src/shared/client/static-loader.ts
|
|
1855
|
+
// src/runtime/loaders/static-loader.ts
|
|
1705
1856
|
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1706
1857
|
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1707
1858
|
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
@@ -1851,101 +2002,9 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1851
2002
|
);
|
|
1852
2003
|
}
|
|
1853
2004
|
|
|
1854
|
-
// src/
|
|
1855
|
-
function createHostState() {
|
|
1856
|
-
return {
|
|
1857
|
-
stage: "idle",
|
|
1858
|
-
prevSrc: void 0,
|
|
1859
|
-
prevUrl: void 0,
|
|
1860
|
-
prevName: void 0,
|
|
1861
|
-
prevIsRemoteComponent: false,
|
|
1862
|
-
abortController: void 0
|
|
1863
|
-
};
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
// src/shared/contract/resolve-name-from-src.ts
|
|
1867
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
1868
|
-
if (!src) {
|
|
1869
|
-
return defaultName;
|
|
1870
|
-
}
|
|
1871
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
1872
|
-
const hashIndex = hash.indexOf("#");
|
|
1873
|
-
if (hashIndex < 0) {
|
|
1874
|
-
return defaultName;
|
|
1875
|
-
}
|
|
1876
|
-
const name = hash.slice(hashIndex + 1);
|
|
1877
|
-
return name || defaultName;
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
// src/shared/ssr/fetch-headers.ts
|
|
1881
|
-
function remoteFetchHeaders() {
|
|
1882
|
-
return {
|
|
1883
|
-
/**
|
|
1884
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1885
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1886
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1887
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1888
|
-
*/
|
|
1889
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1890
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1891
|
-
} : {},
|
|
1892
|
-
Accept: "text/html"
|
|
1893
|
-
};
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1896
|
-
// src/shared/ssr/fetch-with-hooks.ts
|
|
1897
|
-
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1898
|
-
const {
|
|
1899
|
-
onRequest,
|
|
1900
|
-
onResponse,
|
|
1901
|
-
abortController = new AbortController()
|
|
1902
|
-
} = options;
|
|
1903
|
-
const signal = abortController.signal;
|
|
1904
|
-
const hookOptions = {
|
|
1905
|
-
signal,
|
|
1906
|
-
abort: (reason) => abortController.abort(reason)
|
|
1907
|
-
};
|
|
1908
|
-
const init = {
|
|
1909
|
-
method: "GET",
|
|
1910
|
-
headers: remoteFetchHeaders(),
|
|
1911
|
-
signal,
|
|
1912
|
-
...additionalInit
|
|
1913
|
-
};
|
|
1914
|
-
let res = await onRequest?.(url, init, hookOptions);
|
|
1915
|
-
if (!res) {
|
|
1916
|
-
try {
|
|
1917
|
-
res = await fetch(url, init);
|
|
1918
|
-
} catch (error) {
|
|
1919
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1920
|
-
throw error;
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
1924
|
-
if (transformedRes) {
|
|
1925
|
-
res = transformedRes;
|
|
1926
|
-
}
|
|
1927
|
-
return res;
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
// src/shared/ssr/get-client-or-server-url.ts
|
|
1931
|
-
function getClientOrServerUrl(src, serverFallback) {
|
|
1932
|
-
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
1933
|
-
if (!src) {
|
|
1934
|
-
return new URL(fallback);
|
|
1935
|
-
}
|
|
1936
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
2005
|
+
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1940
2006
|
var import_react = require("react");
|
|
1941
|
-
var import_context = require("#internal/react/context");
|
|
1942
|
-
|
|
1943
|
-
// src/shared/client/default-resolve-client-url.ts
|
|
1944
|
-
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1945
|
-
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
// src/react/hooks/use-resolve-client-url.ts
|
|
2007
|
+
var import_context = require("#internal/host/react/context");
|
|
1949
2008
|
function useResolveClientUrl(prop, urlHref) {
|
|
1950
2009
|
const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
|
|
1951
2010
|
const resolveClientUrl = prop ?? contextValue;
|
|
@@ -1955,7 +2014,7 @@ function useResolveClientUrl(prop, urlHref) {
|
|
|
1955
2014
|
);
|
|
1956
2015
|
}
|
|
1957
2016
|
|
|
1958
|
-
// src/react/hooks/use-shadow-root.ts
|
|
2017
|
+
// src/host/react/hooks/use-shadow-root.ts
|
|
1959
2018
|
var import_react2 = require("react");
|
|
1960
2019
|
function useShadowRoot({
|
|
1961
2020
|
isolate,
|
|
@@ -2004,7 +2063,7 @@ function useShadowRoot({
|
|
|
2004
2063
|
return { shadowRoot, shadowRootContainerRef };
|
|
2005
2064
|
}
|
|
2006
2065
|
|
|
2007
|
-
// src/react/utils/extract-remote-html.ts
|
|
2066
|
+
// src/host/react/utils/extract-remote-html.ts
|
|
2008
2067
|
var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
|
|
2009
2068
|
function getRemoteComponentHtml(html) {
|
|
2010
2069
|
if (typeof document === "undefined")
|
|
@@ -2026,21 +2085,20 @@ function getRemoteComponentHtml(html) {
|
|
|
2026
2085
|
return "";
|
|
2027
2086
|
}
|
|
2028
2087
|
|
|
2029
|
-
// src/react/index.tsx
|
|
2030
|
-
var
|
|
2031
|
-
var import_jsx_runtime2 = (
|
|
2088
|
+
// src/host/react/index.tsx
|
|
2089
|
+
var import_jsx_runtime3 = (
|
|
2032
2090
|
// TODO: remove wrapper div by converting HTML to RSC or React tree
|
|
2033
2091
|
require("react/jsx-runtime")
|
|
2034
2092
|
);
|
|
2035
2093
|
var import_react4 = require("react");
|
|
2036
|
-
function
|
|
2094
|
+
function ConsumeRemoteComponent({
|
|
2037
2095
|
src,
|
|
2038
2096
|
isolate,
|
|
2039
2097
|
mode = "open",
|
|
2040
2098
|
reset,
|
|
2041
2099
|
credentials = "same-origin",
|
|
2042
2100
|
name: nameProp = "__vercel_remote_component",
|
|
2043
|
-
shared = {},
|
|
2101
|
+
shared: shared2 = {},
|
|
2044
2102
|
children,
|
|
2045
2103
|
onBeforeLoad,
|
|
2046
2104
|
onLoad,
|
|
@@ -2055,7 +2113,9 @@ function RemoteComponent({
|
|
|
2055
2113
|
() => resolveNameFromSrc(src, nameProp),
|
|
2056
2114
|
[src, nameProp]
|
|
2057
2115
|
);
|
|
2058
|
-
const [data, setData] = (0, import_react3.useState)(
|
|
2116
|
+
const [data, setData] = (0, import_react3.useState)(
|
|
2117
|
+
null
|
|
2118
|
+
);
|
|
2059
2119
|
const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
2060
2120
|
const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
|
|
2061
2121
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
@@ -2272,11 +2332,10 @@ function RemoteComponent({
|
|
|
2272
2332
|
});
|
|
2273
2333
|
self.__next_s = prevNextScripts;
|
|
2274
2334
|
}
|
|
2275
|
-
|
|
2335
|
+
const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
|
|
2336
|
+
remoteName
|
|
2337
|
+
)}` : void 0;
|
|
2276
2338
|
if (rsc) {
|
|
2277
|
-
rscName = `__remote_component_rsc_${escapeString(
|
|
2278
|
-
id
|
|
2279
|
-
)}_${escapeString(remoteName)}`;
|
|
2280
2339
|
rsc.textContent = rsc.textContent?.replace(
|
|
2281
2340
|
new RegExp(`self\\["${remoteName}"\\]`, "g"),
|
|
2282
2341
|
`self["${rscName}"]`
|
|
@@ -2294,7 +2353,7 @@ function RemoteComponent({
|
|
|
2294
2353
|
componentHydrationHtml.current = `${Array.from(
|
|
2295
2354
|
doc.querySelectorAll("link,style")
|
|
2296
2355
|
).map((link) => link.outerHTML).join("")}${reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>` : ""}${component.innerHTML}`;
|
|
2297
|
-
const userShared = await
|
|
2356
|
+
const userShared = await shared2;
|
|
2298
2357
|
if ("__remote_components_missing_shared__" in userShared) {
|
|
2299
2358
|
userShared.__remote_components_missing_shared__().catch((e) => {
|
|
2300
2359
|
throw e;
|
|
@@ -2315,10 +2374,7 @@ function RemoteComponent({
|
|
|
2315
2374
|
}
|
|
2316
2375
|
setData(newData);
|
|
2317
2376
|
if (shadowRoot) {
|
|
2318
|
-
|
|
2319
|
-
if (reset) {
|
|
2320
|
-
shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
|
|
2321
|
-
}
|
|
2377
|
+
const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
|
|
2322
2378
|
shadowRoot.innerHTML = shadowRootHtml;
|
|
2323
2379
|
htmlRef.current = null;
|
|
2324
2380
|
setRemoteComponent(null);
|
|
@@ -2334,7 +2390,7 @@ function RemoteComponent({
|
|
|
2334
2390
|
onLoad?.(src);
|
|
2335
2391
|
} else if (isolate === false) {
|
|
2336
2392
|
setRemoteComponent(
|
|
2337
|
-
/* @__PURE__ */ (0,
|
|
2393
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2338
2394
|
"div",
|
|
2339
2395
|
{
|
|
2340
2396
|
dangerouslySetInnerHTML: { __html: component.innerHTML },
|
|
@@ -2386,7 +2442,7 @@ function RemoteComponent({
|
|
|
2386
2442
|
};
|
|
2387
2443
|
}),
|
|
2388
2444
|
shared: {
|
|
2389
|
-
...sharedPolyfills(userShared),
|
|
2445
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
2390
2446
|
...userShared
|
|
2391
2447
|
},
|
|
2392
2448
|
remoteShared,
|
|
@@ -2432,7 +2488,7 @@ function RemoteComponent({
|
|
|
2432
2488
|
isolate,
|
|
2433
2489
|
credentials,
|
|
2434
2490
|
name,
|
|
2435
|
-
|
|
2491
|
+
shared2,
|
|
2436
2492
|
shadowRoot,
|
|
2437
2493
|
reset,
|
|
2438
2494
|
id,
|
|
@@ -2447,13 +2503,13 @@ function RemoteComponent({
|
|
|
2447
2503
|
if (remoteComponent instanceof Error) {
|
|
2448
2504
|
throw remoteComponent;
|
|
2449
2505
|
}
|
|
2450
|
-
const metadataJson = /* @__PURE__ */ (0,
|
|
2506
|
+
const metadataJson = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
|
|
2451
2507
|
name: data?.name || name,
|
|
2452
2508
|
bundle: data?.bundle || "default",
|
|
2453
2509
|
route: data?.route || DEFAULT_ROUTE,
|
|
2454
2510
|
runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
2455
2511
|
}) });
|
|
2456
|
-
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;
|
|
2457
2513
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
|
|
2458
2514
|
"link",
|
|
2459
2515
|
{
|
|
@@ -2462,7 +2518,7 @@ function RemoteComponent({
|
|
|
2462
2518
|
key: JSON.stringify(link)
|
|
2463
2519
|
}
|
|
2464
2520
|
)) || null;
|
|
2465
|
-
const componentToRender = /* @__PURE__ */ (0,
|
|
2521
|
+
const componentToRender = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2466
2522
|
resetStyle,
|
|
2467
2523
|
linksToRender,
|
|
2468
2524
|
remoteComponent ?? children
|
|
@@ -2500,9 +2556,9 @@ function RemoteComponent({
|
|
|
2500
2556
|
if (shadowRemoteComponentHtml) {
|
|
2501
2557
|
shadowRemoteComponentHtml.remove();
|
|
2502
2558
|
}
|
|
2503
|
-
return /* @__PURE__ */ (0,
|
|
2559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2504
2560
|
metadataJson,
|
|
2505
|
-
/* @__PURE__ */ (0,
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2506
2562
|
"div",
|
|
2507
2563
|
{
|
|
2508
2564
|
"data-remote-component-id": `shadowroot_${keySuffix}`,
|
|
@@ -2511,8 +2567,8 @@ function RemoteComponent({
|
|
|
2511
2567
|
children: [
|
|
2512
2568
|
typeof document === "undefined" ? (
|
|
2513
2569
|
// eslint-disable-next-line react/no-unknown-property
|
|
2514
|
-
/* @__PURE__ */ (0,
|
|
2515
|
-
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)(
|
|
2516
2572
|
"div",
|
|
2517
2573
|
{
|
|
2518
2574
|
dangerouslySetInnerHTML: {
|
|
@@ -2534,12 +2590,12 @@ function RemoteComponent({
|
|
|
2534
2590
|
] })
|
|
2535
2591
|
) : null,
|
|
2536
2592
|
shadowRoot && remoteComponent ? (0, import_react_dom.createPortal)(
|
|
2537
|
-
/* @__PURE__ */ (0,
|
|
2538
|
-
/* @__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` }),
|
|
2539
2595
|
resetStyle,
|
|
2540
2596
|
linksToRender,
|
|
2541
2597
|
remoteComponent,
|
|
2542
|
-
/* @__PURE__ */ (0,
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2543
2599
|
] }),
|
|
2544
2600
|
shadowRoot
|
|
2545
2601
|
) : null
|
|
@@ -2549,33 +2605,16 @@ function RemoteComponent({
|
|
|
2549
2605
|
] });
|
|
2550
2606
|
}
|
|
2551
2607
|
htmlRef.current = null;
|
|
2552
|
-
return /* @__PURE__ */ (0,
|
|
2553
|
-
/* @__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` }),
|
|
2554
2610
|
metadataJson,
|
|
2555
2611
|
componentToRender,
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2612
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2557
2613
|
] });
|
|
2558
2614
|
}
|
|
2559
2615
|
|
|
2560
|
-
// src/
|
|
2561
|
-
var import_context3 = require("#internal/react/context");
|
|
2562
|
-
|
|
2563
|
-
// src/next/host/app-router-compat.tsx
|
|
2616
|
+
// src/host/nextjs/app-compat.tsx
|
|
2564
2617
|
var import_navigation = require("next/navigation");
|
|
2565
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2566
|
-
function imageImpl2(ImageComponent, bundle) {
|
|
2567
|
-
const component = function RemoteImage(props) {
|
|
2568
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2569
|
-
ImageComponent,
|
|
2570
|
-
{
|
|
2571
|
-
...props,
|
|
2572
|
-
src: applyBundleUrlToImagePropsSrc(bundle, props.src)
|
|
2573
|
-
}
|
|
2574
|
-
);
|
|
2575
|
-
};
|
|
2576
|
-
component.default = component;
|
|
2577
|
-
return component;
|
|
2578
|
-
}
|
|
2579
2618
|
var routerImpl = async () => {
|
|
2580
2619
|
const { useRouter } = await import("next/navigation");
|
|
2581
2620
|
return Promise.resolve({
|
|
@@ -2639,17 +2678,34 @@ var routerImpl = async () => {
|
|
|
2639
2678
|
});
|
|
2640
2679
|
};
|
|
2641
2680
|
|
|
2642
|
-
// 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
|
|
2643
2699
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2644
2700
|
async function tryImportShared() {
|
|
2645
2701
|
try {
|
|
2646
|
-
const { shared } = await
|
|
2647
|
-
return
|
|
2702
|
+
const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
2703
|
+
return shared2;
|
|
2648
2704
|
} catch {
|
|
2649
2705
|
return {};
|
|
2650
2706
|
}
|
|
2651
2707
|
}
|
|
2652
|
-
var sharedModules = async (userShared) => {
|
|
2708
|
+
var sharedModules = async (userShared, resolveClientUrl) => {
|
|
2653
2709
|
const [resolvedShared, resolvedUserShared] = await Promise.all([
|
|
2654
2710
|
tryImportShared(),
|
|
2655
2711
|
userShared ?? Promise.resolve({})
|
|
@@ -2657,20 +2713,28 @@ var sharedModules = async (userShared) => {
|
|
|
2657
2713
|
return {
|
|
2658
2714
|
...resolvedShared,
|
|
2659
2715
|
"next/router": routerImpl,
|
|
2660
|
-
|
|
2661
|
-
|
|
2716
|
+
...createNextImageSharedEntries(
|
|
2717
|
+
(bundle) => imageImpl2(Image.default, bundle ?? "default", resolveClientUrl)
|
|
2718
|
+
),
|
|
2662
2719
|
...resolvedUserShared
|
|
2663
2720
|
};
|
|
2664
2721
|
};
|
|
2665
|
-
function
|
|
2722
|
+
function ConsumeRemoteComponent2(props) {
|
|
2666
2723
|
if (typeof props.src !== "string" && !(props.src instanceof URL)) {
|
|
2667
2724
|
return props.children ?? null;
|
|
2668
2725
|
}
|
|
2669
|
-
|
|
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
|
+
);
|
|
2670
2735
|
}
|
|
2671
2736
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2672
2737
|
0 && (module.exports = {
|
|
2673
|
-
|
|
2674
|
-
RemoteComponentsProvider
|
|
2738
|
+
ConsumeRemoteComponent
|
|
2675
2739
|
});
|
|
2676
|
-
//# sourceMappingURL=
|
|
2740
|
+
//# sourceMappingURL=client-only.cjs.map
|