remote-components 0.1.2 → 0.2.1

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.
Files changed (470) hide show
  1. package/dist/{next/config.cjs → config/nextjs.cjs} +77 -102
  2. package/dist/config/nextjs.cjs.map +1 -0
  3. package/dist/{next/config.d.ts → config/nextjs.d.ts} +4 -4
  4. package/dist/{next/config.js → config/nextjs.js} +73 -98
  5. package/dist/config/nextjs.js.map +1 -0
  6. package/dist/{webpack.cjs → config/webpack.cjs} +13 -29
  7. package/dist/config/webpack.cjs.map +1 -0
  8. package/dist/{webpack.js → config/webpack.js} +12 -28
  9. package/dist/config/webpack.js.map +1 -0
  10. package/dist/{shared/remote → host/defaults}/app.cjs +2 -2
  11. package/dist/host/defaults/app.cjs.map +1 -0
  12. package/dist/host/defaults/app.js +8 -0
  13. package/dist/host/defaults/app.js.map +1 -0
  14. package/dist/{shared/remote → host/defaults}/pages.cjs +2 -2
  15. package/dist/host/defaults/pages.cjs.map +1 -0
  16. package/dist/host/defaults/pages.js +8 -0
  17. package/dist/host/defaults/pages.js.map +1 -0
  18. package/dist/{html/host.cjs → host/html.cjs} +1019 -1080
  19. package/dist/host/html.cjs.map +1 -0
  20. package/dist/{html/host.d.ts → host/html.d.ts} +0 -2
  21. package/dist/{html/host.js → host/html.js} +1016 -1076
  22. package/dist/host/html.js.map +1 -0
  23. package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +685 -623
  24. package/dist/host/nextjs/app/client-only.cjs.map +1 -0
  25. package/dist/host/nextjs/app/client-only.d.ts +16 -0
  26. package/dist/{next/host/client/index.js → host/nextjs/app/client-only.js} +687 -618
  27. package/dist/host/nextjs/app/client-only.js.map +1 -0
  28. package/dist/{next/host/app-router-server.cjs → host/nextjs/app.cjs} +11 -10
  29. package/dist/host/nextjs/app.cjs.map +1 -0
  30. package/dist/host/nextjs/app.d.ts +29 -0
  31. package/dist/{next/host/app-router-server.js → host/nextjs/app.js} +7 -6
  32. package/dist/host/nextjs/app.js.map +1 -0
  33. package/dist/{next/host/pages-router-client.cjs → host/nextjs/pages/client-only.cjs} +8 -8
  34. package/dist/host/nextjs/pages/client-only.cjs.map +1 -0
  35. package/dist/host/nextjs/pages/client-only.d.ts +31 -0
  36. package/dist/{next/host/pages-router-client.js → host/nextjs/pages/client-only.js} +4 -4
  37. package/dist/host/nextjs/pages/client-only.js.map +1 -0
  38. package/dist/{next/host/pages-router-server.cjs → host/nextjs/pages.cjs} +44 -55
  39. package/dist/host/nextjs/pages.cjs.map +1 -0
  40. package/dist/{next/host/pages-router-server.d.ts → host/nextjs/pages.d.ts} +11 -13
  41. package/dist/{next/host/pages-router-server.js → host/nextjs/pages.js} +38 -49
  42. package/dist/host/nextjs/pages.js.map +1 -0
  43. package/dist/host/proxy/client.cjs +57 -0
  44. package/dist/host/proxy/client.cjs.map +1 -0
  45. package/dist/host/proxy/client.d.ts +31 -0
  46. package/dist/host/proxy/client.js +30 -0
  47. package/dist/host/proxy/client.js.map +1 -0
  48. package/dist/{shared/host/proxy.cjs → host/proxy/protected-fetch.cjs} +6 -6
  49. package/dist/host/proxy/protected-fetch.cjs.map +1 -0
  50. package/dist/{shared/host/proxy.js → host/proxy/protected-fetch.js} +3 -3
  51. package/dist/host/proxy/protected-fetch.js.map +1 -0
  52. package/dist/{next → host}/proxy.cjs +12 -92
  53. package/dist/host/proxy.cjs.map +1 -0
  54. package/dist/host/proxy.d.ts +30 -0
  55. package/dist/{next → host}/proxy.js +11 -88
  56. package/dist/host/proxy.js.map +1 -0
  57. package/dist/{react/index.cjs → host/react.cjs} +524 -555
  58. package/dist/host/react.cjs.map +1 -0
  59. package/dist/{component-loader-21865da3.d.ts → host/react.d.ts} +141 -99
  60. package/dist/{react/index.js → host/react.js} +523 -552
  61. package/dist/host/react.js.map +1 -0
  62. package/dist/internal/{webpack/shared-modules.cjs → config/webpack/apply-shared-modules.cjs} +18 -17
  63. package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -0
  64. package/dist/internal/{webpack/shared-modules.js → config/webpack/apply-shared-modules.js} +15 -14
  65. package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -0
  66. package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.cjs +1 -1
  67. package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -0
  68. package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.js +1 -1
  69. package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -0
  70. package/dist/internal/{next/host/app-router-client.cjs → host/nextjs/app-client.cjs} +29 -24
  71. package/dist/internal/host/nextjs/app-client.cjs.map +1 -0
  72. package/dist/internal/host/nextjs/app-client.d.ts +25 -0
  73. package/dist/internal/{next/host/app-router-client.js → host/nextjs/app-client.js} +19 -19
  74. package/dist/internal/host/nextjs/app-client.js.map +1 -0
  75. package/dist/internal/{next/host/app-router-compat.cjs → host/nextjs/app-compat.cjs} +5 -22
  76. package/dist/internal/host/nextjs/app-compat.cjs.map +1 -0
  77. package/dist/internal/{next/host/app-router-compat.d.ts → host/nextjs/app-compat.d.ts} +1 -7
  78. package/dist/internal/{next/host/app-router-compat.js → host/nextjs/app-compat.js} +2 -18
  79. package/dist/internal/host/nextjs/app-compat.js.map +1 -0
  80. package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -0
  81. package/dist/internal/host/nextjs/dom-flight.d.ts +39 -0
  82. package/dist/internal/host/nextjs/dom-flight.js.map +1 -0
  83. package/dist/internal/host/nextjs/image-impl.cjs +60 -0
  84. package/dist/internal/host/nextjs/image-impl.cjs.map +1 -0
  85. package/dist/internal/host/nextjs/image-impl.d.ts +10 -0
  86. package/dist/internal/host/nextjs/image-impl.js +36 -0
  87. package/dist/internal/host/nextjs/image-impl.js.map +1 -0
  88. package/dist/internal/host/nextjs/image-shared.cjs +43 -0
  89. package/dist/internal/host/nextjs/image-shared.cjs.map +1 -0
  90. package/dist/internal/host/nextjs/image-shared.d.ts +9 -0
  91. package/dist/internal/host/nextjs/image-shared.js +19 -0
  92. package/dist/internal/host/nextjs/image-shared.js.map +1 -0
  93. package/dist/internal/{next/host → host/nextjs}/remote-component-links.cjs +2 -2
  94. package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -0
  95. package/dist/internal/{next/host → host/nextjs}/remote-component-links.d.ts +1 -1
  96. package/dist/internal/{next/host → host/nextjs}/remote-component-links.js +2 -2
  97. package/dist/internal/host/nextjs/remote-component-links.js.map +1 -0
  98. package/dist/internal/host/nextjs/skeleton.cjs.map +1 -0
  99. package/dist/internal/host/nextjs/skeleton.js.map +1 -0
  100. package/dist/internal/{react → host/react}/context.cjs +3 -3
  101. package/dist/internal/host/react/context.cjs.map +1 -0
  102. package/dist/internal/{react → host/react}/context.d.ts +4 -4
  103. package/dist/internal/{react → host/react}/context.js +2 -2
  104. package/dist/internal/host/react/context.js.map +1 -0
  105. package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.cjs +2 -2
  106. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -0
  107. package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.d.ts +1 -1
  108. package/dist/internal/{react → host/react}/hooks/use-resolve-client-url.js +2 -2
  109. package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -0
  110. package/dist/internal/host/server/fetch-headers.cjs.map +1 -0
  111. package/dist/internal/host/server/fetch-headers.js.map +1 -0
  112. package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.cjs +6 -6
  113. package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -0
  114. package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.d.ts +6 -1
  115. package/dist/internal/{shared/ssr → host/server}/fetch-remote-component.js +9 -9
  116. package/dist/internal/host/server/fetch-remote-component.js.map +1 -0
  117. package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.cjs +11 -15
  118. package/dist/internal/host/server/fetch-with-hooks.cjs.map +1 -0
  119. package/dist/internal/host/server/fetch-with-hooks.d.ts +21 -0
  120. package/dist/internal/{shared/ssr → host/server}/fetch-with-hooks.js +11 -15
  121. package/dist/internal/host/server/fetch-with-hooks.js.map +1 -0
  122. package/dist/internal/host/server/get-client-or-server-url.cjs.map +1 -0
  123. package/dist/internal/host/server/get-client-or-server-url.js.map +1 -0
  124. package/dist/internal/{shared/client → host/server}/get-client-src.cjs +1 -1
  125. package/dist/internal/host/server/get-client-src.cjs.map +1 -0
  126. package/dist/internal/{shared/client → host/server}/get-client-src.js +1 -1
  127. package/dist/internal/host/server/get-client-src.js.map +1 -0
  128. package/dist/internal/host/server/get-ssr-relative-path-base-url.cjs.map +1 -0
  129. package/dist/internal/host/server/get-ssr-relative-path-base-url.js.map +1 -0
  130. package/dist/{next/remote/server.cjs → internal/host/server/types.cjs} +3 -15
  131. package/dist/internal/host/server/types.cjs.map +1 -0
  132. package/dist/internal/host/server/types.d.ts +33 -0
  133. package/dist/internal/host/server/types.js +1 -0
  134. package/dist/internal/host/server/types.js.map +1 -0
  135. package/dist/internal/host/shared/asset-descriptors.cjs +17 -0
  136. package/dist/internal/host/shared/asset-descriptors.cjs.map +1 -0
  137. package/dist/internal/host/shared/asset-descriptors.d.ts +21 -0
  138. package/dist/internal/host/shared/asset-descriptors.js +1 -0
  139. package/dist/internal/host/shared/asset-descriptors.js.map +1 -0
  140. package/dist/internal/host/shared/config.cjs +17 -0
  141. package/dist/internal/host/shared/config.cjs.map +1 -0
  142. package/dist/{host-config-58cdccea.d.ts → internal/host/shared/config.d.ts} +32 -19
  143. package/dist/internal/host/shared/config.js +1 -0
  144. package/dist/internal/host/shared/config.js.map +1 -0
  145. package/dist/internal/host/shared/fetch-interceptors.cjs +17 -0
  146. package/dist/internal/host/shared/fetch-interceptors.cjs.map +1 -0
  147. package/dist/{types-2b26a246.d.ts → internal/host/shared/fetch-interceptors.d.ts} +4 -87
  148. package/dist/internal/host/shared/fetch-interceptors.js +1 -0
  149. package/dist/internal/host/shared/fetch-interceptors.js.map +1 -0
  150. package/dist/internal/{shared/client → host/shared}/polyfill.cjs +7 -6
  151. package/dist/internal/host/shared/polyfill.cjs.map +1 -0
  152. package/dist/internal/{shared/client → host/shared}/polyfill.d.ts +2 -1
  153. package/dist/internal/{shared/client → host/shared}/polyfill.js +7 -6
  154. package/dist/internal/host/shared/polyfill.js.map +1 -0
  155. package/dist/internal/host/shared/resolved-data.cjs +17 -0
  156. package/dist/internal/host/shared/resolved-data.cjs.map +1 -0
  157. package/dist/internal/host/shared/resolved-data.d.ts +48 -0
  158. package/dist/internal/host/shared/resolved-data.js +1 -0
  159. package/dist/internal/host/shared/resolved-data.js.map +1 -0
  160. package/dist/internal/{shared/contract/host-state.cjs → host/shared/state.cjs} +4 -4
  161. package/dist/internal/host/shared/state.cjs.map +1 -0
  162. package/dist/internal/{shared/contract/host-state.js → host/shared/state.js} +1 -1
  163. package/dist/internal/host/shared/state.js.map +1 -0
  164. package/dist/internal/host/utils/resolve-name-from-src.cjs.map +1 -0
  165. package/dist/internal/host/utils/resolve-name-from-src.js.map +1 -0
  166. package/dist/internal/{next/remote/render-client.cjs → remote/nextjs/app-client.cjs} +8 -8
  167. package/dist/internal/remote/nextjs/app-client.cjs.map +1 -0
  168. package/dist/internal/{next/remote/render-client.js → remote/nextjs/app-client.js} +4 -4
  169. package/dist/internal/remote/nextjs/app-client.js.map +1 -0
  170. package/dist/internal/runtime/constants.cjs +50 -0
  171. package/dist/internal/runtime/constants.cjs.map +1 -0
  172. package/dist/internal/runtime/constants.d.ts +10 -0
  173. package/dist/internal/runtime/constants.js +20 -0
  174. package/dist/internal/runtime/constants.js.map +1 -0
  175. package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs.map +1 -1
  176. package/dist/internal/{shared/client → runtime/html}/apply-origin.d.ts +1 -1
  177. package/dist/internal/{shared/client → runtime/html}/apply-origin.js.map +1 -1
  178. package/dist/internal/runtime/html/parse-remote-html.cjs +140 -0
  179. package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -0
  180. package/dist/internal/runtime/html/parse-remote-html.d.ts +88 -0
  181. package/dist/internal/runtime/html/parse-remote-html.js +110 -0
  182. package/dist/internal/runtime/html/parse-remote-html.js.map +1 -0
  183. package/dist/internal/runtime/html/set-attributes-from-props.cjs +68 -0
  184. package/dist/internal/runtime/html/set-attributes-from-props.cjs.map +1 -0
  185. package/dist/internal/runtime/html/set-attributes-from-props.d.ts +3 -0
  186. package/dist/internal/runtime/html/set-attributes-from-props.js +44 -0
  187. package/dist/internal/runtime/html/set-attributes-from-props.js.map +1 -0
  188. package/dist/internal/runtime/loaders/component-loader.cjs +184 -0
  189. package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -0
  190. package/dist/internal/runtime/loaders/component-loader.d.ts +31 -0
  191. package/dist/internal/runtime/loaders/component-loader.js +150 -0
  192. package/dist/internal/runtime/loaders/component-loader.js.map +1 -0
  193. package/dist/internal/runtime/loaders/script-loader.cjs +64 -0
  194. package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -0
  195. package/dist/internal/runtime/loaders/script-loader.d.ts +10 -0
  196. package/dist/internal/runtime/loaders/script-loader.js +43 -0
  197. package/dist/internal/runtime/loaders/script-loader.js.map +1 -0
  198. package/dist/internal/runtime/loaders/static-loader.cjs +177 -0
  199. package/dist/internal/runtime/loaders/static-loader.cjs.map +1 -0
  200. package/dist/internal/runtime/loaders/static-loader.d.ts +10 -0
  201. package/dist/internal/runtime/loaders/static-loader.js +153 -0
  202. package/dist/internal/runtime/loaders/static-loader.js.map +1 -0
  203. package/dist/internal/runtime/metadata.cjs +17 -0
  204. package/dist/internal/runtime/metadata.cjs.map +1 -0
  205. package/dist/internal/runtime/metadata.d.ts +16 -0
  206. package/dist/internal/runtime/metadata.js +1 -0
  207. package/dist/internal/runtime/metadata.js.map +1 -0
  208. package/dist/internal/runtime/rsc.cjs +92 -0
  209. package/dist/internal/runtime/rsc.cjs.map +1 -0
  210. package/dist/internal/runtime/rsc.d.ts +8 -0
  211. package/dist/internal/runtime/rsc.js +68 -0
  212. package/dist/internal/runtime/rsc.js.map +1 -0
  213. package/dist/internal/runtime/turbopack/chunk-loader.cjs +239 -0
  214. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -0
  215. package/dist/internal/runtime/turbopack/chunk-loader.d.ts +11 -0
  216. package/dist/internal/runtime/turbopack/chunk-loader.js +222 -0
  217. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -0
  218. package/dist/internal/runtime/turbopack/module.cjs +257 -0
  219. package/dist/internal/runtime/turbopack/module.cjs.map +1 -0
  220. package/dist/internal/runtime/turbopack/module.d.ts +61 -0
  221. package/dist/internal/runtime/turbopack/module.js +233 -0
  222. package/dist/internal/runtime/turbopack/module.js.map +1 -0
  223. package/dist/internal/runtime/turbopack/patterns.cjs +44 -0
  224. package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -0
  225. package/dist/internal/runtime/turbopack/patterns.d.ts +109 -0
  226. package/dist/internal/runtime/turbopack/patterns.js +15 -0
  227. package/dist/internal/runtime/turbopack/patterns.js.map +1 -0
  228. package/dist/internal/runtime/turbopack/shared-modules.cjs +153 -0
  229. package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -0
  230. package/dist/internal/runtime/turbopack/shared-modules.d.ts +17 -0
  231. package/dist/internal/runtime/turbopack/shared-modules.js +134 -0
  232. package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -0
  233. package/dist/internal/runtime/turbopack/webpack-runtime.cjs +137 -0
  234. package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -0
  235. package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +20 -0
  236. package/dist/internal/runtime/turbopack/webpack-runtime.js +107 -0
  237. package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -0
  238. package/dist/internal/runtime/types.cjs +17 -0
  239. package/dist/internal/runtime/types.cjs.map +1 -0
  240. package/dist/internal/runtime/types.d.ts +40 -0
  241. package/dist/internal/runtime/types.js +1 -0
  242. package/dist/internal/runtime/types.js.map +1 -0
  243. package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.cjs +2 -2
  244. package/dist/internal/runtime/url/default-resolve-client-url.cjs.map +1 -0
  245. package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.d.ts +1 -1
  246. package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.js +1 -1
  247. package/dist/internal/runtime/url/default-resolve-client-url.js.map +1 -0
  248. package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.cjs +1 -1
  249. package/dist/internal/runtime/url/protected-rc-fallback.cjs.map +1 -0
  250. package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.js +1 -1
  251. package/dist/internal/runtime/url/protected-rc-fallback.js.map +1 -0
  252. package/dist/internal/{shared/client/proxy-through-host.cjs → runtime/url/resolve-client-url.cjs} +4 -24
  253. package/dist/internal/runtime/url/resolve-client-url.cjs.map +1 -0
  254. package/dist/internal/{shared/client/proxy-through-host.d.ts → runtime/url/resolve-client-url.d.ts} +1 -25
  255. package/dist/internal/runtime/url/resolve-client-url.js +21 -0
  256. package/dist/internal/runtime/url/resolve-client-url.js.map +1 -0
  257. package/dist/internal/utils/abort.cjs.map +1 -0
  258. package/dist/internal/utils/abort.js.map +1 -0
  259. package/dist/internal/{shared → utils}/constants.cjs +3 -0
  260. package/dist/internal/utils/constants.cjs.map +1 -0
  261. package/dist/internal/utils/constants.d.ts +5 -0
  262. package/dist/internal/{shared → utils}/constants.js +2 -0
  263. package/dist/internal/utils/constants.js.map +1 -0
  264. package/dist/internal/{shared → utils}/error.cjs +11 -4
  265. package/dist/internal/utils/error.cjs.map +1 -0
  266. package/dist/internal/{shared → utils}/error.d.ts +2 -1
  267. package/dist/internal/{shared → utils}/error.js +10 -4
  268. package/dist/internal/utils/error.js.map +1 -0
  269. package/dist/internal/{shared/utils → utils}/logger.cjs +3 -3
  270. package/dist/internal/utils/logger.cjs.map +1 -0
  271. package/dist/internal/{shared/utils → utils}/logger.d.ts +2 -2
  272. package/dist/internal/{shared/utils → utils}/logger.js +3 -3
  273. package/dist/internal/utils/logger.js.map +1 -0
  274. package/dist/internal/utils.cjs.map +1 -0
  275. package/dist/internal/utils.js.map +1 -0
  276. package/dist/{shared/host → remote/defaults}/app.cjs +2 -6
  277. package/dist/remote/defaults/app.cjs.map +1 -0
  278. package/dist/remote/defaults/app.js +8 -0
  279. package/dist/remote/defaults/app.js.map +1 -0
  280. package/dist/{shared/host → remote/defaults}/pages.cjs +2 -6
  281. package/dist/remote/defaults/pages.cjs.map +1 -0
  282. package/dist/remote/defaults/pages.js +8 -0
  283. package/dist/remote/defaults/pages.js.map +1 -0
  284. package/dist/{shared/remote → remote/defaults}/wrapper.cjs +12 -10
  285. package/dist/remote/defaults/wrapper.cjs.map +1 -0
  286. package/dist/remote/defaults/wrapper.js +27 -0
  287. package/dist/remote/defaults/wrapper.js.map +1 -0
  288. package/dist/{html/remote.cjs → remote/html.cjs} +16 -16
  289. package/dist/remote/html.cjs.map +1 -0
  290. package/dist/{html/remote.js → remote/html.js} +16 -16
  291. package/dist/remote/html.js.map +1 -0
  292. package/dist/{shared/remote/proxy.cjs → remote/middleware.cjs} +37 -12
  293. package/dist/remote/middleware.cjs.map +1 -0
  294. package/dist/remote/middleware.d.ts +27 -0
  295. package/dist/{shared/remote/proxy.js → remote/middleware.js} +32 -5
  296. package/dist/remote/middleware.js.map +1 -0
  297. package/dist/{internal/next/remote/render-server.cjs → remote/nextjs/app.cjs} +14 -16
  298. package/dist/remote/nextjs/app.cjs.map +1 -0
  299. package/dist/{internal/next/remote/render-server.d.ts → remote/nextjs/app.d.ts} +12 -13
  300. package/dist/{internal/next/remote/render-server.js → remote/nextjs/app.js} +9 -11
  301. package/dist/remote/nextjs/app.js.map +1 -0
  302. package/dist/{next/remote/pages-router.cjs → remote/nextjs/pages.cjs} +8 -8
  303. package/dist/remote/nextjs/pages.cjs.map +1 -0
  304. package/dist/{next/remote/pages-router.d.ts → remote/nextjs/pages.d.ts} +8 -8
  305. package/dist/{next/remote/pages-router.js → remote/nextjs/pages.js} +4 -4
  306. package/dist/remote/nextjs/pages.js.map +1 -0
  307. package/dist/server-handoff-8c89b856.d.ts +46 -0
  308. package/package.json +126 -157
  309. package/dist/html/host.cjs.map +0 -1
  310. package/dist/html/host.js.map +0 -1
  311. package/dist/html/remote.cjs.map +0 -1
  312. package/dist/html/remote.js.map +0 -1
  313. package/dist/internal/next/host/app-router-client.cjs.map +0 -1
  314. package/dist/internal/next/host/app-router-client.d.ts +0 -79
  315. package/dist/internal/next/host/app-router-client.js.map +0 -1
  316. package/dist/internal/next/host/app-router-compat.cjs.map +0 -1
  317. package/dist/internal/next/host/app-router-compat.js.map +0 -1
  318. package/dist/internal/next/host/remote-component-links.cjs.map +0 -1
  319. package/dist/internal/next/host/remote-component-links.js.map +0 -1
  320. package/dist/internal/next/remote/render-client.cjs.map +0 -1
  321. package/dist/internal/next/remote/render-client.js.map +0 -1
  322. package/dist/internal/next/remote/render-server.cjs.map +0 -1
  323. package/dist/internal/next/remote/render-server.js.map +0 -1
  324. package/dist/internal/react/context.cjs.map +0 -1
  325. package/dist/internal/react/context.js.map +0 -1
  326. package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +0 -1
  327. package/dist/internal/react/hooks/use-resolve-client-url.js.map +0 -1
  328. package/dist/internal/shared/client/default-resolve-client-url.cjs.map +0 -1
  329. package/dist/internal/shared/client/default-resolve-client-url.js.map +0 -1
  330. package/dist/internal/shared/client/get-client-src.cjs.map +0 -1
  331. package/dist/internal/shared/client/get-client-src.js.map +0 -1
  332. package/dist/internal/shared/client/polyfill.cjs.map +0 -1
  333. package/dist/internal/shared/client/polyfill.js.map +0 -1
  334. package/dist/internal/shared/client/protected-rc-fallback.cjs.map +0 -1
  335. package/dist/internal/shared/client/protected-rc-fallback.js.map +0 -1
  336. package/dist/internal/shared/client/proxy-through-host.cjs.map +0 -1
  337. package/dist/internal/shared/client/proxy-through-host.js +0 -40
  338. package/dist/internal/shared/client/proxy-through-host.js.map +0 -1
  339. package/dist/internal/shared/client/remote-component.cjs +0 -1436
  340. package/dist/internal/shared/client/remote-component.cjs.map +0 -1
  341. package/dist/internal/shared/client/remote-component.d.ts +0 -62
  342. package/dist/internal/shared/client/remote-component.js +0 -1385
  343. package/dist/internal/shared/client/remote-component.js.map +0 -1
  344. package/dist/internal/shared/constants.cjs.map +0 -1
  345. package/dist/internal/shared/constants.d.ts +0 -4
  346. package/dist/internal/shared/constants.js.map +0 -1
  347. package/dist/internal/shared/contract/host-state.cjs.map +0 -1
  348. package/dist/internal/shared/contract/host-state.js.map +0 -1
  349. package/dist/internal/shared/contract/resolve-name-from-src.cjs.map +0 -1
  350. package/dist/internal/shared/contract/resolve-name-from-src.js.map +0 -1
  351. package/dist/internal/shared/error.cjs.map +0 -1
  352. package/dist/internal/shared/error.js.map +0 -1
  353. package/dist/internal/shared/ssr/dom-flight.cjs.map +0 -1
  354. package/dist/internal/shared/ssr/dom-flight.d.ts +0 -2
  355. package/dist/internal/shared/ssr/dom-flight.js.map +0 -1
  356. package/dist/internal/shared/ssr/fetch-headers.cjs.map +0 -1
  357. package/dist/internal/shared/ssr/fetch-headers.js.map +0 -1
  358. package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +0 -1
  359. package/dist/internal/shared/ssr/fetch-remote-component.js.map +0 -1
  360. package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +0 -1
  361. package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +0 -56
  362. package/dist/internal/shared/ssr/fetch-with-hooks.js.map +0 -1
  363. package/dist/internal/shared/ssr/get-client-or-server-url.cjs.map +0 -1
  364. package/dist/internal/shared/ssr/get-client-or-server-url.js.map +0 -1
  365. package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +0 -1
  366. package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +0 -1
  367. package/dist/internal/shared/ssr/skeleton.cjs.map +0 -1
  368. package/dist/internal/shared/ssr/skeleton.js.map +0 -1
  369. package/dist/internal/shared/utils/abort.cjs.map +0 -1
  370. package/dist/internal/shared/utils/abort.js.map +0 -1
  371. package/dist/internal/shared/utils/logger.cjs.map +0 -1
  372. package/dist/internal/shared/utils/logger.js.map +0 -1
  373. package/dist/internal/shared/utils.cjs.map +0 -1
  374. package/dist/internal/shared/utils.js.map +0 -1
  375. package/dist/internal/webpack/next-client-pages-loader.cjs.map +0 -1
  376. package/dist/internal/webpack/next-client-pages-loader.js.map +0 -1
  377. package/dist/internal/webpack/shared-modules.cjs.map +0 -1
  378. package/dist/internal/webpack/shared-modules.js.map +0 -1
  379. package/dist/next/config.cjs.map +0 -1
  380. package/dist/next/config.js.map +0 -1
  381. package/dist/next/host/app-router-server.cjs.map +0 -1
  382. package/dist/next/host/app-router-server.d.ts +0 -30
  383. package/dist/next/host/app-router-server.js.map +0 -1
  384. package/dist/next/host/client/index.cjs.map +0 -1
  385. package/dist/next/host/client/index.d.ts +0 -19
  386. package/dist/next/host/client/index.js.map +0 -1
  387. package/dist/next/host/pages-router-client.cjs.map +0 -1
  388. package/dist/next/host/pages-router-client.d.ts +0 -33
  389. package/dist/next/host/pages-router-client.js.map +0 -1
  390. package/dist/next/host/pages-router-server.cjs.map +0 -1
  391. package/dist/next/host/pages-router-server.js.map +0 -1
  392. package/dist/next/index.cjs +0 -53
  393. package/dist/next/index.cjs.map +0 -1
  394. package/dist/next/index.d.ts +0 -30
  395. package/dist/next/index.js +0 -19
  396. package/dist/next/index.js.map +0 -1
  397. package/dist/next/proxy.cjs.map +0 -1
  398. package/dist/next/proxy.d.ts +0 -56
  399. package/dist/next/proxy.js.map +0 -1
  400. package/dist/next/remote/pages-router.cjs.map +0 -1
  401. package/dist/next/remote/pages-router.js.map +0 -1
  402. package/dist/next/remote/server.cjs.map +0 -1
  403. package/dist/next/remote/server.d.ts +0 -5
  404. package/dist/next/remote/server.js +0 -5
  405. package/dist/next/remote/server.js.map +0 -1
  406. package/dist/proxy-through-host-a676a522.d.ts +0 -52
  407. package/dist/react/index.cjs.map +0 -1
  408. package/dist/react/index.d.ts +0 -86
  409. package/dist/react/index.js.map +0 -1
  410. package/dist/shared/host/app.cjs.map +0 -1
  411. package/dist/shared/host/app.js +0 -12
  412. package/dist/shared/host/app.js.map +0 -1
  413. package/dist/shared/host/pages.cjs.map +0 -1
  414. package/dist/shared/host/pages.js +0 -12
  415. package/dist/shared/host/pages.js.map +0 -1
  416. package/dist/shared/host/proxy.cjs.map +0 -1
  417. package/dist/shared/host/proxy.js.map +0 -1
  418. package/dist/shared/remote/app.cjs.map +0 -1
  419. package/dist/shared/remote/app.js +0 -8
  420. package/dist/shared/remote/app.js.map +0 -1
  421. package/dist/shared/remote/pages.cjs.map +0 -1
  422. package/dist/shared/remote/pages.js +0 -8
  423. package/dist/shared/remote/pages.js.map +0 -1
  424. package/dist/shared/remote/proxy.cjs.map +0 -1
  425. package/dist/shared/remote/proxy.d.ts +0 -44
  426. package/dist/shared/remote/proxy.js.map +0 -1
  427. package/dist/shared/remote/wrapper.cjs.map +0 -1
  428. package/dist/shared/remote/wrapper.js +0 -25
  429. package/dist/shared/remote/wrapper.js.map +0 -1
  430. package/dist/webpack.cjs.map +0 -1
  431. package/dist/webpack.js.map +0 -1
  432. /package/dist/{webpack.d.ts → config/webpack.d.ts} +0 -0
  433. /package/dist/{shared/host → host/defaults}/app.d.ts +0 -0
  434. /package/dist/{shared/host → host/defaults}/pages.d.ts +0 -0
  435. /package/dist/{shared/host/proxy.d.ts → host/proxy/protected-fetch.d.ts} +0 -0
  436. /package/dist/internal/{webpack/shared-modules.d.ts → config/webpack/apply-shared-modules.d.ts} +0 -0
  437. /package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.d.ts +0 -0
  438. /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.cjs +0 -0
  439. /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.js +0 -0
  440. /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.cjs +0 -0
  441. /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.d.ts +0 -0
  442. /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.js +0 -0
  443. /package/dist/internal/{shared/ssr → host/server}/fetch-headers.cjs +0 -0
  444. /package/dist/internal/{shared/ssr → host/server}/fetch-headers.d.ts +0 -0
  445. /package/dist/internal/{shared/ssr → host/server}/fetch-headers.js +0 -0
  446. /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.cjs +0 -0
  447. /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.d.ts +0 -0
  448. /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.js +0 -0
  449. /package/dist/internal/{shared/client → host/server}/get-client-src.d.ts +0 -0
  450. /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.cjs +0 -0
  451. /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.d.ts +0 -0
  452. /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.js +0 -0
  453. /package/dist/internal/{shared/contract/host-state.d.ts → host/shared/state.d.ts} +0 -0
  454. /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.cjs +0 -0
  455. /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.d.ts +0 -0
  456. /package/dist/internal/{shared/contract → host/utils}/resolve-name-from-src.js +0 -0
  457. /package/dist/internal/{next/remote/render-client.d.ts → remote/nextjs/app-client.d.ts} +0 -0
  458. /package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs +0 -0
  459. /package/dist/internal/{shared/client → runtime/html}/apply-origin.js +0 -0
  460. /package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.d.ts +0 -0
  461. /package/dist/internal/{shared/utils → utils}/abort.cjs +0 -0
  462. /package/dist/internal/{shared/utils → utils}/abort.d.ts +0 -0
  463. /package/dist/internal/{shared/utils → utils}/abort.js +0 -0
  464. /package/dist/internal/{shared/utils.cjs → utils.cjs} +0 -0
  465. /package/dist/internal/{shared/utils.d.ts → utils.d.ts} +0 -0
  466. /package/dist/internal/{shared/utils.js → utils.js} +0 -0
  467. /package/dist/{shared/remote → remote/defaults}/app.d.ts +0 -0
  468. /package/dist/{shared/remote → remote/defaults}/pages.d.ts +0 -0
  469. /package/dist/{shared/remote → remote/defaults}/wrapper.d.ts +0 -0
  470. /package/dist/{html/remote.d.ts → remote/html.d.ts} +0 -0
@@ -30,20 +30,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // src/shared/constants.ts
33
+ // src/utils/constants.ts
34
34
  var RC_PROTECTED_REMOTE_FETCH_PATHNAME, CORS_DOCS_URL;
35
35
  var init_constants = __esm({
36
- "src/shared/constants.ts"() {
36
+ "src/utils/constants.ts"() {
37
37
  "use strict";
38
38
  RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
39
39
  CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
40
40
  }
41
41
  });
42
42
 
43
- // src/shared/client/protected-rc-fallback.ts
44
- function generateProtectedRcFallbackSrc(url) {
45
- return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
46
- }
43
+ // src/runtime/url/protected-rc-fallback.ts
47
44
  function isProxiedUrl(url) {
48
45
  try {
49
46
  return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
@@ -52,13 +49,13 @@ function isProxiedUrl(url) {
52
49
  }
53
50
  }
54
51
  var init_protected_rc_fallback = __esm({
55
- "src/shared/client/protected-rc-fallback.ts"() {
52
+ "src/runtime/url/protected-rc-fallback.ts"() {
56
53
  "use strict";
57
54
  init_constants();
58
55
  }
59
56
  });
60
57
 
61
- // src/shared/utils/abort.ts
58
+ // src/utils/abort.ts
62
59
  function isAbortError(error) {
63
60
  if (error instanceof DOMException && error.name === "AbortError") {
64
61
  return true;
@@ -70,12 +67,12 @@ function isAbortError(error) {
70
67
  return false;
71
68
  }
72
69
  var init_abort = __esm({
73
- "src/shared/utils/abort.ts"() {
70
+ "src/utils/abort.ts"() {
74
71
  "use strict";
75
72
  }
76
73
  });
77
74
 
78
- // src/shared/error.ts
75
+ // src/utils/error.ts
79
76
  function multipleRemoteComponentsError(url) {
80
77
  return new RemoteComponentsError(
81
78
  `Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
@@ -126,6 +123,11 @@ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
126
123
  }
127
124
  return fallback;
128
125
  }
126
+ function failedProxiedAssetError(kind, url, resolvedUrl) {
127
+ return new RemoteComponentsError(
128
+ `Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
129
+ );
130
+ }
129
131
  function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
130
132
  if (status === 404) {
131
133
  return new RemoteComponentsError(
@@ -134,7 +136,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
134
136
  The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
135
137
 
136
138
  Proxying requires two pieces:
137
- 1. resolveClientUrl={proxyClientRequestsThroughHost} on <RemoteComponent>
139
+ 1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
138
140
  2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
139
141
 
140
142
  Docs: ${CORS_DOCS_URL}`
@@ -152,11 +154,11 @@ Docs: ${CORS_DOCS_URL}`
152
154
  }
153
155
  var RemoteComponentsError;
154
156
  var init_error = __esm({
155
- "src/shared/error.ts"() {
157
+ "src/utils/error.ts"() {
156
158
  "use strict";
157
159
  init_protected_rc_fallback();
158
- init_constants();
159
160
  init_abort();
161
+ init_constants();
160
162
  RemoteComponentsError = class extends Error {
161
163
  code = "REMOTE_COMPONENTS_ERROR";
162
164
  constructor(message, options) {
@@ -167,34 +169,7 @@ var init_error = __esm({
167
169
  }
168
170
  });
169
171
 
170
- // src/shared/utils/index.ts
171
- function escapeString(str) {
172
- return str.replace(/[^a-z0-9]/g, "_");
173
- }
174
- var init_utils = __esm({
175
- "src/shared/utils/index.ts"() {
176
- "use strict";
177
- }
178
- });
179
-
180
- // src/shared/client/const.ts
181
- function getBundleKey(bundle) {
182
- return escapeString(bundle);
183
- }
184
- var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT, REMOTE_COMPONENT_REGEX;
185
- var init_const = __esm({
186
- "src/shared/client/const.ts"() {
187
- "use strict";
188
- init_utils();
189
- DEFAULT_ROUTE = "/";
190
- RUNTIME_WEBPACK = "webpack";
191
- RUNTIME_TURBOPACK = "turbopack";
192
- RUNTIME_SCRIPT = "script";
193
- REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
194
- }
195
- });
196
-
197
- // src/shared/utils/logger.ts
172
+ // src/utils/logger.ts
198
173
  function logDebug(location2, message) {
199
174
  if (DEBUG) {
200
175
  console.debug(`[${PREFIX}:${location2}]: ${message}`);
@@ -218,14 +193,14 @@ function warnCrossOriginFetchError(logLocation, url) {
218
193
  }
219
194
  logWarn(
220
195
  logLocation,
221
- `Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure withRemoteComponentsHost middleware is configured in your host and that the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
196
+ `Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
222
197
  );
223
198
  } catch {
224
199
  }
225
200
  }
226
201
  var PREFIX, DEBUG;
227
202
  var init_logger = __esm({
228
- "src/shared/utils/logger.ts"() {
203
+ "src/utils/logger.ts"() {
229
204
  "use strict";
230
205
  init_constants();
231
206
  init_error();
@@ -234,7 +209,104 @@ var init_logger = __esm({
234
209
  }
235
210
  });
236
211
 
237
- // src/shared/webpack/next-client-pages-loader.ts
212
+ // src/utils/index.ts
213
+ function escapeString(str) {
214
+ return str.replace(/[^a-z0-9]/g, "_");
215
+ }
216
+ var init_utils = __esm({
217
+ "src/utils/index.ts"() {
218
+ "use strict";
219
+ }
220
+ });
221
+
222
+ // src/runtime/constants.ts
223
+ function getBundleKey(bundle) {
224
+ return escapeString(bundle);
225
+ }
226
+ var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT, REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE;
227
+ var init_constants2 = __esm({
228
+ "src/runtime/constants.ts"() {
229
+ "use strict";
230
+ init_utils();
231
+ DEFAULT_ROUTE = "/";
232
+ RUNTIME_WEBPACK = "webpack";
233
+ RUNTIME_TURBOPACK = "turbopack";
234
+ RUNTIME_SCRIPT = "script";
235
+ REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
236
+ NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
237
+ }
238
+ });
239
+
240
+ // src/config/webpack/apply-shared-modules.ts
241
+ function applySharedModules(bundle, resolve) {
242
+ logDebug(
243
+ "SharedModules",
244
+ `applySharedModules called for bundle: "${bundle}"`
245
+ );
246
+ logDebug(
247
+ "SharedModules",
248
+ `Shared modules to resolve: ${Object.keys(resolve)}`
249
+ );
250
+ const self = globalThis;
251
+ if (self.__remote_webpack_require__?.[bundle]) {
252
+ const modulePaths = Object.keys(
253
+ self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
254
+ );
255
+ logDebug(
256
+ "SharedModules",
257
+ `Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
258
+ );
259
+ for (const [key, value] of Object.entries(resolve)) {
260
+ const exactIds = modulePaths.filter((p) => p === key);
261
+ const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
262
+ if (ids.length === 0) {
263
+ logDebug(
264
+ "SharedModules",
265
+ `No matching module path found for shared module "${key}"`
266
+ );
267
+ }
268
+ for (const id of ids) {
269
+ const webpackBundle = self.__remote_webpack_require__[bundle];
270
+ if (webpackBundle.m) {
271
+ const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
272
+ if (resolvedId !== id) {
273
+ logDebug(
274
+ "SharedModules",
275
+ `Mapped module id: "${id}" -> "${resolvedId}"`
276
+ );
277
+ }
278
+ webpackBundle.m[resolvedId] = (module2) => {
279
+ module2.exports = value;
280
+ };
281
+ } else {
282
+ logWarn(
283
+ "SharedModules",
284
+ `webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
285
+ );
286
+ }
287
+ }
288
+ }
289
+ } else {
290
+ logWarn(
291
+ "SharedModules",
292
+ `No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
293
+ );
294
+ logDebug(
295
+ "SharedModules",
296
+ `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
297
+ );
298
+ }
299
+ }
300
+ var DEDUPLICATION_SKIPPED;
301
+ var init_apply_shared_modules = __esm({
302
+ "src/config/webpack/apply-shared-modules.ts"() {
303
+ "use strict";
304
+ init_logger();
305
+ DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
306
+ }
307
+ });
308
+
309
+ // src/config/webpack/next-client-pages-loader.ts
238
310
  function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
239
311
  const self = globalThis;
240
312
  const nextCssOriginal = document.querySelector(
@@ -346,168 +418,389 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
346
418
  return { Component: null, App: null };
347
419
  }
348
420
  var init_next_client_pages_loader = __esm({
349
- "src/shared/webpack/next-client-pages-loader.ts"() {
421
+ "src/config/webpack/next-client-pages-loader.ts"() {
350
422
  "use strict";
351
423
  init_error();
352
424
  }
353
425
  });
354
426
 
355
- // src/shared/webpack/shared-modules.ts
356
- function applySharedModules(bundle, resolve) {
357
- logDebug(
358
- "SharedModules",
359
- `applySharedModules called for bundle: "${bundle}"`
360
- );
361
- logDebug(
362
- "SharedModules",
363
- `Shared modules to resolve: ${Object.keys(resolve)}`
364
- );
427
+ // src/host/shared/polyfill.tsx
428
+ function applyBundleUrlToSrc(bundle, src) {
365
429
  const self = globalThis;
366
- if (self.__remote_webpack_require__?.[bundle]) {
367
- const modulePaths = Object.keys(
368
- self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
369
- );
370
- logDebug(
371
- "SharedModules",
372
- `Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
373
- );
374
- for (const [key, value] of Object.entries(resolve)) {
375
- let ids = modulePaths.filter((p) => p === key);
376
- if (ids.length === 0) {
377
- ids = modulePaths.filter((p) => p.includes(key));
378
- }
379
- if (ids.length === 0) {
380
- logDebug(
381
- "SharedModules",
382
- `No matching module path found for shared module "${key}"`
383
- );
384
- }
385
- for (let id of ids) {
386
- const webpackBundle = self.__remote_webpack_require__[bundle];
387
- if (webpackBundle.m) {
388
- if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
389
- const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
390
- logDebug(
391
- "SharedModules",
392
- `Mapped module id: "${id}" -> "${mappedId}"`
393
- );
394
- id = mappedId;
395
- }
396
- webpackBundle.m[id] = (module2) => {
397
- module2.exports = value;
398
- };
399
- } else {
400
- logWarn(
401
- "SharedModules",
402
- `webpackBundle.m is not available for bundle "${bundle}"`
403
- );
404
- }
405
- }
406
- }
407
- } else {
408
- logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
409
- logDebug(
410
- "SharedModules",
411
- `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
412
- );
430
+ if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
431
+ return src;
413
432
  }
414
- }
415
- var init_shared_modules = __esm({
416
- "src/shared/webpack/shared-modules.ts"() {
417
- "use strict";
418
- init_logger();
433
+ const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
434
+ if (!path) {
435
+ return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
419
436
  }
420
- });
421
-
422
- // src/shared/client/webpack-patterns.ts
423
- var NEXT_BUNDLE_PATH_RE;
424
- var init_webpack_patterns = __esm({
425
- "src/shared/client/webpack-patterns.ts"() {
426
- "use strict";
427
- NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
437
+ return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
438
+ }
439
+ function applyBundleUrlToImagePropsSrc(bundle, src) {
440
+ if (typeof src === "string") {
441
+ return applyBundleUrlToSrc(bundle, src);
428
442
  }
429
- });
430
-
431
- // src/shared/client/script-loader.ts
432
- async function loadScripts(scripts, resolveClientUrl) {
433
- await Promise.all(
434
- scripts.map((script) => {
435
- return new Promise((resolve, reject) => {
436
- const newSrc = new URL(
437
- // remove the remote component bundle name identifier from the script src
438
- script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
439
- location.origin
440
- ).href;
441
- const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
442
- const newScript = document.createElement("script");
443
- newScript.onload = () => resolve();
444
- newScript.onerror = () => {
445
- const isProxied = isProxiedUrl(resolvedSrc);
446
- if (isProxied) {
447
- reject(
448
- new RemoteComponentsError(
449
- `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}`
450
- )
451
- );
452
- } else {
453
- warnCrossOriginFetchError("ScriptLoader", newSrc);
454
- reject(
455
- new RemoteComponentsError(
456
- `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
457
- )
458
- );
443
+ const propSrc = src;
444
+ return applyBundleUrlToSrc(bundle, propSrc.src);
445
+ }
446
+ function sharedPolyfills(shared, resolveClientUrl) {
447
+ const self = globalThis;
448
+ const polyfill = {
449
+ "next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
450
+ useRouter() {
451
+ return {
452
+ push: (routerUrl) => {
453
+ history.pushState({}, "", routerUrl);
454
+ },
455
+ replace: (routerUrl) => {
456
+ history.replaceState({}, "", routerUrl);
457
+ },
458
+ back: () => {
459
+ history.back();
459
460
  }
460
461
  };
461
- newScript.src = resolvedSrc;
462
- newScript.async = true;
463
- document.head.appendChild(newScript);
464
- });
465
- })
466
- );
467
- }
468
- var init_script_loader = __esm({
469
- "src/shared/client/script-loader.ts"() {
470
- "use strict";
471
- init_constants();
472
- init_error();
473
- init_logger();
474
- init_protected_rc_fallback();
475
- init_webpack_patterns();
476
- }
477
- });
478
-
479
- // src/shared/client/turbopack-patterns.ts
480
- var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
481
- var init_turbopack_patterns = __esm({
482
- "src/shared/client/turbopack-patterns.ts"() {
483
- "use strict";
484
- REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
485
- REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|e)\.A\((?<sharedModuleId>[0-9]+)\)/;
486
- ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
487
- ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
488
- 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]+)\)\)\)\}/;
489
- TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
490
- }
491
- });
492
-
493
- // src/shared/client/chunk-loader.ts
494
- function createChunkLoader(runtime, resolveClientUrl) {
495
- return function __turbopack_chunk_load__(chunkId, scriptBundle) {
496
- logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
497
- const self = globalThis;
498
- const {
499
- bundle,
500
- id: path,
501
- prefix
502
- } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {
503
- bundle: scriptBundle ?? "",
504
- id: chunkId
505
- };
506
- logDebug(
507
- "ChunkLoader",
508
- `Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
509
- );
510
- const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
462
+ },
463
+ usePathname() {
464
+ return location.pathname;
465
+ },
466
+ useParams() {
467
+ return {};
468
+ },
469
+ useSearchParams() {
470
+ return new URLSearchParams(location.search);
471
+ },
472
+ useSelectedLayoutSegment() {
473
+ return null;
474
+ },
475
+ useSelectedLayoutSegments() {
476
+ return [];
477
+ },
478
+ __esModule: true
479
+ })),
480
+ "next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
481
+ default: ({
482
+ scroll: _,
483
+ replace,
484
+ prefetch,
485
+ onNavigate,
486
+ children,
487
+ ...props
488
+ }) => {
489
+ if (prefetch) {
490
+ logWarn(
491
+ "Polyfill",
492
+ "Next.js Link prefetch is not supported in remote components"
493
+ );
494
+ }
495
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
496
+ "a",
497
+ {
498
+ ...props,
499
+ href: props.href,
500
+ onClick: (e) => {
501
+ e.preventDefault();
502
+ let preventDefaulted = false;
503
+ e.preventDefault = () => {
504
+ preventDefaulted = true;
505
+ e.defaultPrevented = true;
506
+ };
507
+ if (typeof props.onClick === "function") {
508
+ props.onClick(e);
509
+ }
510
+ onNavigate?.(e);
511
+ if (preventDefaulted) {
512
+ return;
513
+ }
514
+ if (replace) {
515
+ history.replaceState({}, "", props.href);
516
+ } else {
517
+ history.pushState({}, "", props.href);
518
+ }
519
+ },
520
+ suppressHydrationWarning: true,
521
+ children: children ?? null
522
+ }
523
+ );
524
+ },
525
+ useLinkStatus() {
526
+ return { pending: false };
527
+ },
528
+ __esModule: true
529
+ })),
530
+ "next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
531
+ default: () => {
532
+ throw new Error("Next.js <Form> component not implemented");
533
+ },
534
+ __esModule: true
535
+ })),
536
+ "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
537
+ Image: imageImpl(bundle, resolveClientUrl),
538
+ __esModule: true
539
+ })),
540
+ "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
541
+ default: imageImpl(bundle, resolveClientUrl),
542
+ getImageProps: (_imgProps) => {
543
+ throw new Error(
544
+ "Next.js getImageProps() is not implemented in remote components"
545
+ );
546
+ },
547
+ __esModule: true
548
+ })),
549
+ "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
550
+ // TODO: implement <Script> component for non-Next.js host applications
551
+ // do not throw an error for now
552
+ default: () => null,
553
+ __esModule: true
554
+ })),
555
+ "next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
556
+ // TODO: incomplete implementation
557
+ Promise.resolve({
558
+ useRouter() {
559
+ return {
560
+ push: (routerUrl) => {
561
+ history.pushState({}, "", routerUrl);
562
+ },
563
+ replace: (routerUrl) => {
564
+ history.replaceState({}, "", routerUrl);
565
+ },
566
+ back: () => {
567
+ history.back();
568
+ }
569
+ };
570
+ },
571
+ __esModule: true
572
+ })
573
+ )),
574
+ "next/dist/build/polyfills/process": () => Promise.resolve({
575
+ default: {
576
+ env: {
577
+ NODE_ENV: "production"
578
+ }
579
+ },
580
+ __esModule: true
581
+ })
582
+ };
583
+ polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
584
+ polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
585
+ polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
586
+ polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
587
+ polyfill["next/script"] = polyfill["next/dist/client/script"];
588
+ return polyfill;
589
+ }
590
+ var import_jsx_runtime, imageImpl;
591
+ var init_polyfill = __esm({
592
+ "src/host/shared/polyfill.tsx"() {
593
+ "use strict";
594
+ init_logger();
595
+ // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
596
+ import_jsx_runtime = require("react/jsx-runtime");
597
+ imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
598
+ fill: _fill,
599
+ loader: _loader,
600
+ quality: _quality,
601
+ priority: _priority,
602
+ loading: _loading,
603
+ placeholder: _placeholder,
604
+ blurDataURL: _blurDataURL,
605
+ unoptimized: _unoptimized,
606
+ overrideSrc: _overrideSrc,
607
+ src,
608
+ ...props
609
+ }) {
610
+ const newSrc = applyBundleUrlToImagePropsSrc(
611
+ bundle,
612
+ typeof src === "string" ? src : src.src
613
+ );
614
+ const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
615
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
616
+ "img",
617
+ {
618
+ decoding: "async",
619
+ style: { color: "transparent" },
620
+ ...props,
621
+ src: proxiedSrc,
622
+ suppressHydrationWarning: true
623
+ }
624
+ );
625
+ };
626
+ }
627
+ });
628
+
629
+ // src/runtime/loaders/script-loader.ts
630
+ async function loadScripts(scripts, resolveClientUrl) {
631
+ await Promise.all(
632
+ scripts.map((script) => {
633
+ return new Promise((resolve, reject) => {
634
+ const newSrc = new URL(
635
+ // remove the remote component bundle name identifier from the script src
636
+ script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
637
+ location.origin
638
+ ).href;
639
+ const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
640
+ const newScript = document.createElement("script");
641
+ newScript.onload = () => resolve();
642
+ newScript.onerror = () => {
643
+ const isProxied = isProxiedUrl(resolvedSrc);
644
+ if (isProxied) {
645
+ reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
646
+ } else {
647
+ warnCrossOriginFetchError("ScriptLoader", newSrc);
648
+ reject(
649
+ new RemoteComponentsError(
650
+ `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
651
+ )
652
+ );
653
+ }
654
+ };
655
+ newScript.src = resolvedSrc;
656
+ newScript.async = true;
657
+ document.head.appendChild(newScript);
658
+ });
659
+ })
660
+ );
661
+ }
662
+ var init_script_loader = __esm({
663
+ "src/runtime/loaders/script-loader.ts"() {
664
+ "use strict";
665
+ init_constants2();
666
+ init_protected_rc_fallback();
667
+ init_error();
668
+ init_logger();
669
+ }
670
+ });
671
+
672
+ // src/host/html/runtime/webpack.ts
673
+ var webpack_exports = {};
674
+ __export(webpack_exports, {
675
+ webpackRuntime: () => webpackRuntime
676
+ });
677
+ async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
678
+ const self = globalThis;
679
+ if (!self.__DISABLE_WEBPACK_EXEC__) {
680
+ self.__DISABLE_WEBPACK_EXEC__ = {};
681
+ }
682
+ self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
683
+ if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
684
+ self.__webpack_require__ = (remoteId) => {
685
+ const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
686
+ const match = re.exec(remoteId);
687
+ const remoteBundle = match?.groups?.bundle;
688
+ const id = match?.groups?.id;
689
+ if (!(id && remoteBundle)) {
690
+ throw new RemoteComponentsError(
691
+ `Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
692
+ );
693
+ }
694
+ if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
695
+ throw new RemoteComponentsError(
696
+ `Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
697
+ );
698
+ }
699
+ return self.__remote_webpack_require__[remoteBundle](id);
700
+ };
701
+ self.__webpack_chunk_load__ = () => {
702
+ return Promise.resolve([]);
703
+ };
704
+ }
705
+ const {
706
+ default: { createFromReadableStream }
707
+ } = await import("react-server-dom-webpack/client.browser");
708
+ async function preloadScripts(scripts, url, remoteBundle, _) {
709
+ const scriptSrcs = scripts.flatMap((script) => {
710
+ const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
711
+ script.parentElement?.removeChild(script);
712
+ if (!scriptSrc)
713
+ return [];
714
+ return [
715
+ {
716
+ src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
717
+ }
718
+ ];
719
+ });
720
+ await loadScripts(scriptSrcs, resolveClientUrl);
721
+ const hostShared = {
722
+ ...sharedPolyfills(shared, resolveClientUrl),
723
+ ...self.__remote_component_host_shared_modules__,
724
+ ...shared
725
+ };
726
+ const resolve = {
727
+ "/react/index.js": (await import("react")).default,
728
+ "/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
729
+ "/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
730
+ "/react-dom/index.js": (await import("react-dom")).default,
731
+ "/react-dom/client.js": (await import("react-dom/client")).default,
732
+ ...Object.entries(remoteShared ?? {}).reduce(
733
+ (acc, [key, value]) => {
734
+ if (typeof hostShared[value] !== "undefined") {
735
+ acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
736
+ }
737
+ return acc;
738
+ },
739
+ {}
740
+ )
741
+ };
742
+ await Promise.all(
743
+ Object.entries(resolve).map(async ([key, value]) => {
744
+ if (typeof value === "function") {
745
+ resolve[key] = await value(remoteBundle);
746
+ }
747
+ return Promise.resolve(value);
748
+ })
749
+ );
750
+ applySharedModules(remoteBundle, resolve);
751
+ }
752
+ return {
753
+ self,
754
+ createFromReadableStream,
755
+ applySharedModules,
756
+ nextClientPagesLoader,
757
+ preloadScripts
758
+ };
759
+ }
760
+ var init_webpack = __esm({
761
+ "src/host/html/runtime/webpack.ts"() {
762
+ "use strict";
763
+ init_apply_shared_modules();
764
+ init_next_client_pages_loader();
765
+ init_polyfill();
766
+ init_constants2();
767
+ init_script_loader();
768
+ init_error();
769
+ }
770
+ });
771
+
772
+ // src/runtime/turbopack/patterns.ts
773
+ var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
774
+ var init_patterns = __esm({
775
+ "src/runtime/turbopack/patterns.ts"() {
776
+ "use strict";
777
+ REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
778
+ REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
779
+ ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
780
+ ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
781
+ 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]+)\)\)\)\}/;
782
+ TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
783
+ }
784
+ });
785
+
786
+ // src/runtime/turbopack/chunk-loader.ts
787
+ function createChunkLoader(runtime, resolveClientUrl) {
788
+ return function __turbopack_chunk_load__(chunkId, scriptBundle) {
789
+ logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
790
+ const self = globalThis;
791
+ const {
792
+ bundle,
793
+ id: path,
794
+ prefix
795
+ } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {
796
+ bundle: scriptBundle ?? "",
797
+ id: chunkId
798
+ };
799
+ logDebug(
800
+ "ChunkLoader",
801
+ `Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
802
+ );
803
+ const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
511
804
  logDebug("ChunkLoader", `Remote runtime: "${remoteRuntime}"`);
512
805
  if (remoteRuntime === RUNTIME_WEBPACK) {
513
806
  logDebug("ChunkLoader", "Skipping chunk load - webpack runtime detected");
@@ -550,11 +843,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
550
843
  }).then(resolve).catch((error) => {
551
844
  const isProxied = isProxiedUrl(resolvedUrl);
552
845
  if (isProxied) {
553
- reject(
554
- new RemoteComponentsError(
555
- `Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
556
- )
557
- );
846
+ reject(failedProxiedAssetError("chunk", url, resolvedUrl));
558
847
  } else {
559
848
  warnCrossOriginFetchError("ChunkLoader", url);
560
849
  reject(error);
@@ -702,18 +991,17 @@ async function handleTurbopackChunk(code, bundle, url) {
702
991
  }
703
992
  }
704
993
  var init_chunk_loader = __esm({
705
- "src/shared/client/chunk-loader.ts"() {
994
+ "src/runtime/turbopack/chunk-loader.ts"() {
706
995
  "use strict";
707
- init_constants();
996
+ init_constants2();
997
+ init_protected_rc_fallback();
708
998
  init_error();
709
999
  init_logger();
710
- init_const();
711
- init_protected_rc_fallback();
712
- init_turbopack_patterns();
1000
+ init_patterns();
713
1001
  }
714
1002
  });
715
1003
 
716
- // src/shared/client/turbopack-module.ts
1004
+ // src/runtime/turbopack/module.ts
717
1005
  function handleTurbopackModule(bundle, moduleId, id) {
718
1006
  const self = globalThis;
719
1007
  const bundleKey = getBundleKey(bundle);
@@ -917,731 +1205,276 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
917
1205
  j() {
918
1206
  },
919
1207
  // chunk loader
920
- l(url) {
921
- const flatModules = Array.isArray(modules) ? modules : [];
922
- const moduleInitIndex = flatModules.indexOf(moduleInit);
923
- if (moduleInitIndex !== -1) {
924
- const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
925
- if (scriptIndex !== -1) {
926
- const script = flatModules[scriptIndex];
927
- const scriptSrc = script.getAttribute("data-turbopack-src") || "";
928
- const nextIndex = scriptSrc.indexOf("/_next");
929
- const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
930
- const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
931
- return self.__webpack_chunk_load__?.(bundleUrl, bundle);
932
- }
933
- }
934
- throw new Error(
935
- `Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
936
- );
937
- },
938
- // global object for this bundle
939
- g: self.__remote_components_turbopack_global__?.[bundle],
940
- m: moduleExports,
941
- e: exports
942
- };
943
- }
944
- var init_turbopack_module = __esm({
945
- "src/shared/client/turbopack-module.ts"() {
946
- "use strict";
947
- init_logger();
948
- init_const();
949
- }
950
- });
951
-
952
- // src/shared/client/shared-modules.ts
953
- async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
954
- const self = globalThis;
955
- self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
956
- if (!self.__remote_shared_modules__[bundle]) {
957
- self.__remote_shared_modules__[bundle] = {};
958
- }
959
- const bundleKey = getBundleKey(bundle);
960
- let modules = self[`TURBOPACK_${bundleKey}`];
961
- if (modules && typeof modules === "object" && "__chunks__" in modules) {
962
- const chunks = modules.__chunks__;
963
- modules = chunks.flat();
964
- }
965
- let sharedModuleInitializer = null;
966
- if (modules) {
967
- const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
968
- const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
969
- if (typeof idOrFunc !== "function") {
970
- return false;
971
- }
972
- const funcCode = idOrFunc.toString();
973
- return REMOTE_SHARED_MARKER_RE.test(funcCode);
974
- });
975
- if (sharedModuleInitializerIndex > 0) {
976
- const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
977
- const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
978
- const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
979
- if (sharedModuleId) {
980
- const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
981
- bundle,
982
- sharedModuleId,
983
- `[${bundle}] ${sharedModuleInitializerId}`
984
- );
985
- sharedModuleInitializer = sharedModuleInitializerInstance;
986
- }
987
- }
988
- if (sharedModuleInitializer) {
989
- const { shared } = await sharedModuleInitializer;
990
- const sharedModuleIds = extractSharedModuleIds(
991
- shared,
992
- bundleKey,
993
- self
994
- );
995
- return Promise.all(
996
- Object.entries(sharedModuleIds).map(async ([id, module2]) => {
997
- if (self.__remote_shared_modules__?.[bundle]) {
998
- if (hostShared[module2]) {
999
- self.__remote_shared_modules__[bundle][id] = await hostShared[module2](bundle);
1000
- } else {
1001
- logError(
1002
- "SharedModules",
1003
- `Host shared module "${module2}" not found for ID ${id}`
1004
- );
1005
- }
1006
- }
1007
- })
1008
- );
1009
- }
1010
- }
1011
- return Promise.all(
1012
- Object.entries(remoteShared).map(async ([id, module2]) => {
1013
- if (self.__remote_shared_modules__?.[bundle]) {
1014
- if (hostShared[module2]) {
1015
- const normalizedId = id.replace("[app-ssr]", "[app-client]");
1016
- self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module2](bundle);
1017
- } else {
1018
- logError(
1019
- "SharedModules",
1020
- `Shared module "${module2}" not found for "${bundle}"`
1021
- );
1022
- }
1023
- }
1024
- })
1025
- );
1026
- }
1027
- function extractSharedModuleIds(shared, bundleKey, self) {
1028
- return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
1029
- const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
1030
- if (asyncSharedModuleId) {
1031
- const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
1032
- let asyncSharedModule;
1033
- let turbopackModules = self[`TURBOPACK_${bundleKey}`];
1034
- if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
1035
- const chunks = turbopackModules.__chunks__;
1036
- turbopackModules = chunks.flat();
1037
- }
1038
- const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
1039
- key2,
1040
- value2
1041
- ]) : [];
1042
- const asyncSharedModuleIdIndex = newAllModules.indexOf(
1043
- asyncSharedModuleIdNumber
1044
- );
1045
- if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
1046
- asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
1047
- }
1048
- if (asyncSharedModule) {
1049
- const asyncSharedModuleCode = asyncSharedModule.toString();
1050
- const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
1051
- acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
1052
- "__remote_shared_module_",
1053
- ""
1054
- );
1055
- }
1056
- }
1057
- return acc;
1058
- }, {});
1059
- }
1060
- function getSharedModule(bundle, id) {
1061
- const self = globalThis;
1062
- for (const [key, value] of Object.entries(
1063
- self.__remote_shared_modules__?.[bundle] ?? {}
1064
- )) {
1065
- if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
1066
- return value;
1067
- }
1068
- }
1069
- return null;
1070
- }
1071
- var init_shared_modules2 = __esm({
1072
- "src/shared/client/shared-modules.ts"() {
1073
- "use strict";
1074
- init_logger();
1075
- init_const();
1076
- init_turbopack_module();
1077
- init_turbopack_patterns();
1078
- }
1079
- });
1080
-
1081
- // src/shared/client/webpack-adapter.ts
1082
- async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
1083
- const self = globalThis;
1084
- if (!self.__remote_bundle_url__) {
1085
- self.__remote_bundle_url__ = {};
1086
- }
1087
- self.__remote_bundle_url__[bundle ?? "default"] = url;
1088
- self.__webpack_get_script_filename__ = () => null;
1089
- if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
1090
- if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
1091
- self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
1092
- self.__original_webpack_require__ = self.__webpack_require__;
1093
- }
1094
- self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
1095
- self.__webpack_require__ = createModuleRequire(runtime);
1096
- self.__webpack_require_type__ = runtime;
1097
- if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
1098
- const remoteBundle = bundle ?? "default";
1099
- self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
1100
- self.__remote_webpack_require__[remoteBundle].type = "turbopack";
1101
- }
1102
- }
1103
- if (runtime === RUNTIME_TURBOPACK) {
1104
- await Promise.all(
1105
- scripts.map((script) => {
1106
- if (script.src) {
1107
- return self.__webpack_chunk_load__?.(script.src, bundle);
1108
- }
1109
- return Promise.resolve(void 0);
1110
- })
1111
- );
1112
- }
1113
- const coreShared = {
1114
- react: async () => (await import("react")).default,
1115
- "react-dom": async () => (await import("react-dom")).default,
1116
- "react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
1117
- "react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
1118
- "react-dom/client": async () => (await import("react-dom/client")).default,
1119
- ...shared
1120
- };
1121
- await initializeSharedModules(
1122
- bundle ?? "default",
1123
- // include all core modules as shared
1124
- coreShared,
1125
- remoteShared
1126
- );
1127
- }
1128
- function createModuleRequire(runtime) {
1129
- return (id) => {
1130
- const self = globalThis;
1131
- const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
1132
- bundle: "default",
1133
- id
1134
- };
1135
- const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
1136
- logDebug("WebpackAdapter", `remoteRuntime: "${remoteRuntime}"`);
1137
- try {
1138
- if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
1139
- return self.__remote_webpack_require__?.[bundle]?.(moduleId);
1140
- }
1141
- const sharedModuleId = moduleId ?? id;
1142
- const sharedModule = getSharedModule(bundle ?? "default", sharedModuleId);
1143
- if (sharedModule) {
1144
- return sharedModule;
1145
- }
1146
- if (bundle && moduleId) {
1147
- return handleTurbopackModule(bundle, moduleId, id);
1208
+ l(url) {
1209
+ const flatModules = Array.isArray(modules) ? modules : [];
1210
+ const moduleInitIndex = flatModules.indexOf(moduleInit);
1211
+ if (moduleInitIndex !== -1) {
1212
+ const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
1213
+ if (scriptIndex !== -1) {
1214
+ const script = flatModules[scriptIndex];
1215
+ const scriptSrc = script.getAttribute("data-turbopack-src") || "";
1216
+ const nextIndex = scriptSrc.indexOf("/_next");
1217
+ const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
1218
+ const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
1219
+ return self.__webpack_chunk_load__?.(bundleUrl, bundle);
1220
+ }
1148
1221
  }
1149
- throw new Error(`Module "${id}" not found.`);
1150
- } catch (requireError) {
1151
- logWarn(
1152
- "WebpackAdapter",
1153
- `Module require failed: ${String(requireError)}`
1222
+ throw new Error(
1223
+ `Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
1154
1224
  );
1155
- if (typeof self.__original_webpack_require__ !== "function") {
1156
- throw new RemoteComponentsError(
1157
- `Module "${id}" not found in remote component bundle "${bundle}".`,
1158
- {
1159
- cause: requireError instanceof Error ? requireError : void 0
1160
- }
1161
- );
1162
- }
1163
- try {
1164
- logDebug("WebpackAdapter", "Falling back to original webpack require");
1165
- return self.__original_webpack_require__(id);
1166
- } catch (originalError) {
1167
- throw new RemoteComponentsError(
1168
- `Module "${id}" not found in remote component bundle "${bundle}".`,
1169
- { cause: originalError instanceof Error ? originalError : void 0 }
1170
- );
1171
- }
1172
- }
1225
+ },
1226
+ // global object for this bundle
1227
+ g: self.__remote_components_turbopack_global__?.[bundle],
1228
+ m: moduleExports,
1229
+ e: exports
1173
1230
  };
1174
1231
  }
1175
- var init_webpack_adapter = __esm({
1176
- "src/shared/client/webpack-adapter.ts"() {
1232
+ var init_module = __esm({
1233
+ "src/runtime/turbopack/module.ts"() {
1177
1234
  "use strict";
1178
- init_error();
1235
+ init_constants2();
1179
1236
  init_logger();
1180
- init_chunk_loader();
1181
- init_const();
1182
- init_shared_modules2();
1183
- init_turbopack_module();
1184
1237
  }
1185
1238
  });
1186
1239
 
1187
- // src/shared/client/static-loader.ts
1188
- async function importViaCallback(absoluteSrc, resolveClientUrl) {
1189
- const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
1190
- const fetchUrl = new URL(resolvedUrl, location.href).href;
1191
- const response = await fetch(fetchUrl);
1192
- if (!response.ok)
1193
- throw new Error(`Proxied fetch failed: ${response.status}`);
1194
- const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
1195
- /\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
1196
- (_, keyword, quote, relativePath) => {
1197
- const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
1198
- const resolvedImportUrl = new URL(
1199
- resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
1200
- location.href
1201
- ).href;
1202
- return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
1203
- }
1204
- );
1205
- const moduleBlobUrl = URL.createObjectURL(
1206
- new Blob([content], { type: "text/javascript" })
1207
- );
1208
- const wrapperContent = [
1209
- `import*as m from${JSON.stringify(moduleBlobUrl)};`,
1210
- `globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
1211
- `globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
1212
- ].join("");
1213
- const wrapperBlobUrl = URL.createObjectURL(
1214
- new Blob([wrapperContent], { type: "text/javascript" })
1215
- );
1216
- const scriptEl = document.createElement("script");
1217
- scriptEl.type = "module";
1218
- scriptEl.src = wrapperBlobUrl;
1219
- try {
1220
- await new Promise((resolve, reject) => {
1221
- scriptEl.onload = () => resolve();
1222
- scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
1223
- document.head.appendChild(scriptEl);
1224
- });
1225
- } finally {
1226
- scriptEl.remove();
1227
- URL.revokeObjectURL(moduleBlobUrl);
1228
- URL.revokeObjectURL(wrapperBlobUrl);
1229
- }
1230
- const registry = globalThis.__rc_module_registry__;
1231
- const mod = registry?.[absoluteSrc] ?? {};
1232
- if (registry)
1233
- delete registry[absoluteSrc];
1234
- return mod;
1235
- }
1236
- async function importDirectly(absoluteSrc) {
1237
- try {
1238
- return await import(
1239
- /* @vite-ignore */
1240
- /* webpackIgnore: true */
1241
- absoluteSrc
1242
- );
1243
- } catch (importError) {
1244
- if (!absoluteSrc.startsWith("blob:")) {
1245
- warnCrossOriginFetchError("StaticLoader", absoluteSrc);
1246
- }
1247
- throw importError;
1248
- }
1249
- }
1250
- function resolveScriptSrc(script, url) {
1251
- const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
1252
- if (!rawSrc && script.textContent) {
1253
- return URL.createObjectURL(
1254
- new Blob(
1255
- [script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
1256
- { type: "text/javascript" }
1257
- )
1258
- );
1259
- }
1260
- return rawSrc;
1261
- }
1262
- async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1240
+ // src/runtime/turbopack/shared-modules.ts
1241
+ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
1263
1242
  const self = globalThis;
1264
- if (self.__remote_script_entrypoint_mount__?.[url.href]) {
1265
- self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
1243
+ self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
1244
+ if (!self.__remote_shared_modules__[bundle]) {
1245
+ self.__remote_shared_modules__[bundle] = {};
1266
1246
  }
1267
- if (self.__remote_script_entrypoint_unmount__?.[url.href]) {
1268
- self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
1247
+ const bundleKey = getBundleKey(bundle);
1248
+ let modules = self[`TURBOPACK_${bundleKey}`];
1249
+ if (modules && typeof modules === "object" && "__chunks__" in modules) {
1250
+ const chunks = modules.__chunks__;
1251
+ modules = chunks.flat();
1269
1252
  }
1270
- const mountUnmountSets = await Promise.all(
1271
- scripts.map(async (script) => {
1272
- try {
1273
- const src = resolveScriptSrc(script, url);
1274
- const absoluteSrc = new URL(src, url).href;
1275
- const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
1276
- if (src.startsWith("blob:")) {
1277
- URL.revokeObjectURL(src);
1278
- }
1279
- if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
1280
- if (!self.__remote_script_entrypoint_mount__) {
1281
- self.__remote_script_entrypoint_mount__ = {};
1282
- }
1283
- if (!self.__remote_script_entrypoint_mount__[url.href]) {
1284
- self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
1285
- }
1286
- self.__remote_script_entrypoint_mount__[url.href]?.add(
1287
- mod.mount || mod.default?.mount || (() => {
1288
- })
1289
- );
1290
- }
1291
- if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
1292
- if (!self.__remote_script_entrypoint_unmount__) {
1293
- self.__remote_script_entrypoint_unmount__ = {};
1294
- }
1295
- if (!self.__remote_script_entrypoint_unmount__[url.href]) {
1296
- self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
1253
+ let sharedModuleInitializer = null;
1254
+ if (modules) {
1255
+ const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
1256
+ const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
1257
+ if (typeof idOrFunc !== "function") {
1258
+ return false;
1259
+ }
1260
+ const funcCode = idOrFunc.toString();
1261
+ return REMOTE_SHARED_MARKER_RE.test(funcCode);
1262
+ });
1263
+ if (sharedModuleInitializerIndex > 0) {
1264
+ const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
1265
+ const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
1266
+ const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
1267
+ if (sharedModuleId) {
1268
+ const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
1269
+ bundle,
1270
+ sharedModuleId,
1271
+ `[${bundle}] ${sharedModuleInitializerId}`
1272
+ );
1273
+ sharedModuleInitializer = sharedModuleInitializerInstance;
1274
+ }
1275
+ }
1276
+ if (sharedModuleInitializer) {
1277
+ const { shared } = await sharedModuleInitializer;
1278
+ const sharedModuleIds = extractSharedModuleIds(
1279
+ shared,
1280
+ bundleKey,
1281
+ self
1282
+ );
1283
+ return Promise.all(
1284
+ Object.entries(sharedModuleIds).map(async ([id, module2]) => {
1285
+ if (self.__remote_shared_modules__?.[bundle]) {
1286
+ if (hostShared[module2]) {
1287
+ self.__remote_shared_modules__[bundle][id] = await hostShared[module2](bundle);
1288
+ } else {
1289
+ logError(
1290
+ "SharedModules",
1291
+ `Host shared module "${module2}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
1292
+ );
1293
+ }
1297
1294
  }
1298
- self.__remote_script_entrypoint_unmount__[url.href]?.add(
1299
- mod.unmount || mod.default?.unmount || (() => {
1300
- })
1295
+ })
1296
+ );
1297
+ }
1298
+ }
1299
+ return Promise.all(
1300
+ Object.entries(remoteShared).map(async ([id, module2]) => {
1301
+ if (self.__remote_shared_modules__?.[bundle]) {
1302
+ if (hostShared[module2]) {
1303
+ const normalizedId = id.replace("[app-ssr]", "[app-client]");
1304
+ self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module2](bundle);
1305
+ } else {
1306
+ logError(
1307
+ "SharedModules",
1308
+ `Shared module "${module2}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
1301
1309
  );
1302
1310
  }
1303
- return {
1304
- mount: mod.mount || mod.default?.mount,
1305
- unmount: mod.unmount || mod.default?.unmount
1306
- };
1307
- } catch (e) {
1308
- logError(
1309
- "StaticLoader",
1310
- `Error loading remote component script from "${script.src || url.href}".`,
1311
- e
1312
- );
1313
- return {
1314
- mount: void 0,
1315
- unmount: void 0
1316
- };
1317
1311
  }
1318
1312
  })
1319
1313
  );
1320
- return mountUnmountSets.reduce(
1321
- (acc, { mount, unmount }) => {
1322
- if (typeof mount === "function") {
1323
- acc.mount.add(mount);
1314
+ }
1315
+ function extractSharedModuleIds(shared, bundleKey, self) {
1316
+ return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
1317
+ const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
1318
+ if (asyncSharedModuleId) {
1319
+ const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
1320
+ let asyncSharedModule;
1321
+ let turbopackModules = self[`TURBOPACK_${bundleKey}`];
1322
+ if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
1323
+ const chunks = turbopackModules.__chunks__;
1324
+ turbopackModules = chunks.flat();
1324
1325
  }
1325
- if (typeof unmount === "function") {
1326
- acc.unmount.add(unmount);
1326
+ const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
1327
+ key2,
1328
+ value2
1329
+ ]) : [];
1330
+ const asyncSharedModuleIdIndex = newAllModules.indexOf(
1331
+ asyncSharedModuleIdNumber
1332
+ );
1333
+ if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
1334
+ asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
1335
+ }
1336
+ if (asyncSharedModule) {
1337
+ const asyncSharedModuleCode = asyncSharedModule.toString();
1338
+ const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
1339
+ acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
1340
+ "__remote_shared_module_",
1341
+ ""
1342
+ );
1327
1343
  }
1328
- return acc;
1329
- },
1330
- {
1331
- mount: /* @__PURE__ */ new Set(),
1332
- unmount: /* @__PURE__ */ new Set()
1333
1344
  }
1334
- );
1345
+ return acc;
1346
+ }, {});
1335
1347
  }
1336
- var init_static_loader = __esm({
1337
- "src/shared/client/static-loader.ts"() {
1348
+ function getSharedModule(bundle, id) {
1349
+ const self = globalThis;
1350
+ for (const [key, value] of Object.entries(
1351
+ self.__remote_shared_modules__?.[bundle] ?? {}
1352
+ )) {
1353
+ if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
1354
+ return value;
1355
+ }
1356
+ }
1357
+ return null;
1358
+ }
1359
+ var DEDUPLICATION_WARNING;
1360
+ var init_shared_modules = __esm({
1361
+ "src/runtime/turbopack/shared-modules.ts"() {
1338
1362
  "use strict";
1363
+ init_constants2();
1339
1364
  init_logger();
1365
+ init_module();
1366
+ init_patterns();
1367
+ DEDUPLICATION_WARNING = "This module will not be deduplicated \u2014 the remote may load its own copy, which can cause duplicate instance errors (e.g. invalid hook calls if React is loaded twice).";
1340
1368
  }
1341
1369
  });
1342
1370
 
1343
- // src/shared/client/polyfill.tsx
1344
- function applyBundleUrlToSrc(bundle, src) {
1371
+ // src/runtime/turbopack/webpack-runtime.ts
1372
+ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
1345
1373
  const self = globalThis;
1346
- if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
1347
- return src;
1348
- }
1349
- const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
1350
- if (!path) {
1351
- return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
1374
+ if (!self.__remote_bundle_url__) {
1375
+ self.__remote_bundle_url__ = {};
1352
1376
  }
1353
- return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
1354
- }
1355
- function applyBundleUrlToImagePropsSrc(bundle, src) {
1356
- if (typeof src === "string") {
1357
- return applyBundleUrlToSrc(bundle, src);
1377
+ self.__remote_bundle_url__[bundle ?? "default"] = url;
1378
+ self.__webpack_get_script_filename__ = () => null;
1379
+ if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
1380
+ if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
1381
+ self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
1382
+ self.__original_webpack_require__ = self.__webpack_require__;
1383
+ }
1384
+ self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
1385
+ self.__webpack_require__ = createModuleRequire(runtime);
1386
+ self.__webpack_require_type__ = runtime;
1387
+ if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
1388
+ const remoteBundle = bundle ?? "default";
1389
+ self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
1390
+ self.__remote_webpack_require__[remoteBundle].type = "turbopack";
1391
+ }
1358
1392
  }
1359
- const propSrc = src;
1360
- return applyBundleUrlToSrc(bundle, propSrc.src);
1361
- }
1362
- function sharedPolyfills(shared) {
1363
- const self = globalThis;
1364
- const polyfill = {
1365
- "next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
1366
- useRouter() {
1367
- return {
1368
- push: (routerUrl) => {
1369
- history.pushState({}, "", routerUrl);
1370
- },
1371
- replace: (routerUrl) => {
1372
- history.replaceState({}, "", routerUrl);
1373
- },
1374
- back: () => {
1375
- history.back();
1376
- }
1377
- };
1378
- },
1379
- usePathname() {
1380
- return location.pathname;
1381
- },
1382
- useParams() {
1383
- return {};
1384
- },
1385
- useSearchParams() {
1386
- return new URLSearchParams(location.search);
1387
- },
1388
- useSelectedLayoutSegment() {
1389
- return null;
1390
- },
1391
- useSelectedLayoutSegments() {
1392
- return [];
1393
- },
1394
- __esModule: true
1395
- })),
1396
- "next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
1397
- default: ({
1398
- scroll: _,
1399
- replace,
1400
- prefetch,
1401
- onNavigate,
1402
- children,
1403
- ...props
1404
- }) => {
1405
- if (prefetch) {
1406
- logWarn(
1407
- "Polyfill",
1408
- "Next.js Link prefetch is not supported in remote components"
1409
- );
1393
+ if (runtime === RUNTIME_TURBOPACK) {
1394
+ await Promise.all(
1395
+ scripts.map((script) => {
1396
+ if (script.src) {
1397
+ return self.__webpack_chunk_load__?.(script.src, bundle);
1410
1398
  }
1411
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1412
- "a",
1413
- {
1414
- ...props,
1415
- href: props.href,
1416
- onClick: (e) => {
1417
- e.preventDefault();
1418
- let preventDefaulted = false;
1419
- e.preventDefault = () => {
1420
- preventDefaulted = true;
1421
- e.defaultPrevented = true;
1422
- };
1423
- if (typeof props.onClick === "function") {
1424
- props.onClick(e);
1425
- }
1426
- onNavigate?.(e);
1427
- if (preventDefaulted) {
1428
- return;
1429
- }
1430
- if (replace) {
1431
- history.replaceState({}, "", props.href);
1432
- } else {
1433
- history.pushState({}, "", props.href);
1434
- }
1435
- },
1436
- suppressHydrationWarning: true,
1437
- children: children ?? null
1438
- }
1439
- );
1440
- },
1441
- useLinkStatus() {
1442
- return { pending: false };
1443
- },
1444
- __esModule: true
1445
- })),
1446
- "next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
1447
- default: () => {
1448
- throw new Error("Next.js <Form> component not implemented");
1449
- },
1450
- __esModule: true
1451
- })),
1452
- "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
1453
- Image: imageImpl(bundle),
1454
- __esModule: true
1455
- })),
1456
- "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
1457
- default: imageImpl(bundle),
1458
- getImageProps: (_imgProps) => {
1459
- throw new Error(
1460
- "Next.js getImageProps() is not implemented in remote components"
1461
- );
1462
- },
1463
- __esModule: true
1464
- })),
1465
- "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
1466
- // TODO: implement <Script> component for non-Next.js host applications
1467
- // do not throw an error for now
1468
- default: () => null,
1469
- __esModule: true
1470
- })),
1471
- "next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
1472
- // TODO: incomplete implementation
1473
- Promise.resolve({
1474
- useRouter() {
1475
- return {
1476
- push: (routerUrl) => {
1477
- history.pushState({}, "", routerUrl);
1478
- },
1479
- replace: (routerUrl) => {
1480
- history.replaceState({}, "", routerUrl);
1481
- },
1482
- back: () => {
1483
- history.back();
1484
- }
1485
- };
1486
- },
1487
- __esModule: true
1399
+ return Promise.resolve(void 0);
1488
1400
  })
1489
- )),
1490
- "next/dist/build/polyfills/process": () => Promise.resolve({
1491
- default: {
1492
- env: {
1493
- NODE_ENV: "production"
1494
- }
1495
- },
1496
- __esModule: true
1497
- })
1401
+ );
1402
+ }
1403
+ const coreShared = {
1404
+ react: async () => (await import("react")).default,
1405
+ "react-dom": async () => (await import("react-dom")).default,
1406
+ "react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
1407
+ "react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
1408
+ "react-dom/client": async () => (await import("react-dom/client")).default,
1409
+ ...shared
1498
1410
  };
1499
- polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
1500
- polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
1501
- polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
1502
- polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
1503
- polyfill["next/script"] = polyfill["next/dist/client/script"];
1504
- return polyfill;
1411
+ await initializeSharedModules(
1412
+ bundle ?? "default",
1413
+ // include all core modules as shared
1414
+ coreShared,
1415
+ remoteShared
1416
+ );
1505
1417
  }
1506
- var import_jsx_runtime, imageImpl;
1507
- var init_polyfill = __esm({
1508
- "src/shared/client/polyfill.tsx"() {
1509
- "use strict";
1510
- init_logger();
1511
- // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
1512
- import_jsx_runtime = require("react/jsx-runtime");
1513
- imageImpl = (bundle) => function RemoteImage({
1514
- fill: _fill,
1515
- loader: _loader,
1516
- quality: _quality,
1517
- priority: _priority,
1518
- loading: _loading,
1519
- placeholder: _placeholder,
1520
- blurDataURL: _blurDataURL,
1521
- unoptimized: _unoptimized,
1522
- overrideSrc: _overrideSrc,
1523
- src,
1524
- ...props
1525
- }) {
1526
- const newSrc = applyBundleUrlToImagePropsSrc(
1527
- bundle,
1528
- typeof src === "string" ? src : src.src
1529
- );
1530
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1531
- "img",
1532
- {
1533
- decoding: "async",
1534
- style: { color: "transparent" },
1535
- ...props,
1536
- src: newSrc,
1537
- suppressHydrationWarning: true
1538
- }
1418
+ function createModuleRequire(runtime) {
1419
+ return (id) => {
1420
+ const self = globalThis;
1421
+ const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
1422
+ bundle: "default",
1423
+ id
1424
+ };
1425
+ const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
1426
+ logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
1427
+ try {
1428
+ if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
1429
+ return self.__remote_webpack_require__?.[bundle]?.(moduleId);
1430
+ }
1431
+ const sharedModuleId = moduleId ?? id;
1432
+ const sharedModule = getSharedModule(bundle ?? "default", sharedModuleId);
1433
+ if (sharedModule) {
1434
+ return sharedModule;
1435
+ }
1436
+ if (bundle && moduleId) {
1437
+ return handleTurbopackModule(bundle, moduleId, id);
1438
+ }
1439
+ throw new Error(`Module "${id}" not found.`);
1440
+ } catch (requireError) {
1441
+ logWarn(
1442
+ "WebpackRuntime",
1443
+ `Module require failed: ${String(requireError)}`
1539
1444
  );
1540
- };
1541
- }
1542
- });
1543
-
1544
- // src/html/host/runtime/webpack.ts
1545
- var webpack_exports = {};
1546
- __export(webpack_exports, {
1547
- webpackRuntime: () => webpackRuntime
1548
- });
1549
- async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
1550
- const self = globalThis;
1551
- if (!self.__DISABLE_WEBPACK_EXEC__) {
1552
- self.__DISABLE_WEBPACK_EXEC__ = {};
1553
- }
1554
- self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
1555
- if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
1556
- self.__webpack_require__ = (remoteId) => {
1557
- const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
1558
- const match = re.exec(remoteId);
1559
- const remoteBundle = match?.groups?.bundle;
1560
- const id = match?.groups?.id;
1561
- if (!(id && remoteBundle)) {
1445
+ if (typeof self.__original_webpack_require__ !== "function") {
1562
1446
  throw new RemoteComponentsError(
1563
- `Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponents\` on both host and remote?`
1447
+ `Module "${id}" not found in remote component bundle "${bundle}".`,
1448
+ {
1449
+ cause: requireError instanceof Error ? requireError : void 0
1450
+ }
1564
1451
  );
1565
1452
  }
1566
- if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
1453
+ try {
1454
+ logDebug("WebpackRuntime", "Falling back to original webpack require");
1455
+ return self.__original_webpack_require__(id);
1456
+ } catch (originalError) {
1567
1457
  throw new RemoteComponentsError(
1568
- `Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponents\` on both host and remote?`
1458
+ `Module "${id}" not found in remote component bundle "${bundle}".`,
1459
+ { cause: originalError instanceof Error ? originalError : void 0 }
1569
1460
  );
1570
1461
  }
1571
- return self.__remote_webpack_require__[remoteBundle](id);
1572
- };
1573
- self.__webpack_chunk_load__ = () => {
1574
- return Promise.resolve([]);
1575
- };
1576
- }
1577
- const {
1578
- default: { createFromReadableStream }
1579
- } = await import("react-server-dom-webpack/client.browser");
1580
- async function preloadScripts(scripts, url, remoteBundle, _) {
1581
- const scriptSrcs = scripts.flatMap((script) => {
1582
- const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
1583
- script.parentElement?.removeChild(script);
1584
- if (!scriptSrc)
1585
- return [];
1586
- return [
1587
- {
1588
- src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
1589
- }
1590
- ];
1591
- });
1592
- await loadScripts(scriptSrcs, resolveClientUrl);
1593
- const hostShared = {
1594
- ...sharedPolyfills(shared),
1595
- ...self.__remote_component_host_shared_modules__,
1596
- ...shared
1597
- };
1598
- const resolve = {
1599
- "/react/index.js": (await import("react")).default,
1600
- "/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
1601
- "/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
1602
- "/react-dom/index.js": (await import("react-dom")).default,
1603
- "/react-dom/client.js": (await import("react-dom/client")).default,
1604
- ...Object.entries(remoteShared ?? {}).reduce(
1605
- (acc, [key, value]) => {
1606
- if (typeof hostShared[value] !== "undefined") {
1607
- acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
1608
- }
1609
- return acc;
1610
- },
1611
- {}
1612
- )
1613
- };
1614
- await Promise.all(
1615
- Object.entries(resolve).map(async ([key, value]) => {
1616
- if (typeof value === "function") {
1617
- resolve[key] = await value(remoteBundle);
1618
- }
1619
- return Promise.resolve(value);
1620
- })
1621
- );
1622
- applySharedModules(remoteBundle, resolve);
1623
- }
1624
- return {
1625
- self,
1626
- createFromReadableStream,
1627
- applySharedModules,
1628
- nextClientPagesLoader,
1629
- preloadScripts
1462
+ }
1630
1463
  };
1631
1464
  }
1632
- var init_webpack = __esm({
1633
- "src/html/host/runtime/webpack.ts"() {
1465
+ var init_webpack_runtime = __esm({
1466
+ "src/runtime/turbopack/webpack-runtime.ts"() {
1634
1467
  "use strict";
1635
- init_polyfill();
1636
- init_script_loader();
1637
- init_webpack_patterns();
1468
+ init_constants2();
1638
1469
  init_error();
1639
- init_next_client_pages_loader();
1470
+ init_logger();
1471
+ init_chunk_loader();
1472
+ init_module();
1640
1473
  init_shared_modules();
1641
1474
  }
1642
1475
  });
1643
1476
 
1644
- // src/html/host/runtime/turbopack.ts
1477
+ // src/host/html/runtime/turbopack.ts
1645
1478
  var turbopack_exports = {};
1646
1479
  __export(turbopack_exports, {
1647
1480
  turbopackRuntime: () => turbopackRuntime
@@ -1649,7 +1482,7 @@ __export(turbopack_exports, {
1649
1482
  async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
1650
1483
  const self = globalThis;
1651
1484
  const hostShared = {
1652
- ...sharedPolyfills(shared),
1485
+ ...sharedPolyfills(shared, resolveClientUrl),
1653
1486
  ...self.__remote_component_host_shared_modules__,
1654
1487
  ...shared,
1655
1488
  ...self.__remote_component_shared__
@@ -1663,41 +1496,197 @@ async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClient
1663
1496
  remoteShared,
1664
1497
  resolveClientUrl
1665
1498
  );
1666
- const {
1667
- default: { createFromReadableStream }
1668
- } = await import("react-server-dom-webpack/client.browser");
1669
- function preloadScripts(scripts, __) {
1670
- return setupWebpackRuntime(
1671
- "turbopack",
1672
- scripts.map((script) => ({
1673
- src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
1674
- })),
1675
- url,
1676
- bundle,
1677
- hostShared,
1678
- remoteShared,
1679
- resolveClientUrl
1680
- );
1681
- }
1682
- return {
1683
- self,
1684
- createFromReadableStream,
1685
- applySharedModules,
1686
- nextClientPagesLoader,
1687
- preloadScripts
1688
- };
1499
+ const {
1500
+ default: { createFromReadableStream }
1501
+ } = await import("react-server-dom-webpack/client.browser");
1502
+ function preloadScripts(scripts, __) {
1503
+ return setupWebpackRuntime(
1504
+ "turbopack",
1505
+ scripts.map((script) => ({
1506
+ src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
1507
+ })),
1508
+ url,
1509
+ bundle,
1510
+ hostShared,
1511
+ remoteShared,
1512
+ resolveClientUrl
1513
+ );
1514
+ }
1515
+ return {
1516
+ self,
1517
+ createFromReadableStream,
1518
+ applySharedModules,
1519
+ nextClientPagesLoader,
1520
+ preloadScripts
1521
+ };
1522
+ }
1523
+ var init_turbopack = __esm({
1524
+ "src/host/html/runtime/turbopack.ts"() {
1525
+ "use strict";
1526
+ init_apply_shared_modules();
1527
+ init_next_client_pages_loader();
1528
+ init_polyfill();
1529
+ init_webpack_runtime();
1530
+ }
1531
+ });
1532
+
1533
+ // src/runtime/loaders/static-loader.ts
1534
+ async function importViaCallback(absoluteSrc, resolveClientUrl) {
1535
+ const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
1536
+ const fetchUrl = new URL(resolvedUrl, location.href).href;
1537
+ const response = await fetch(fetchUrl);
1538
+ if (!response.ok)
1539
+ throw new Error(`Proxied fetch failed: ${response.status}`);
1540
+ const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
1541
+ /\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
1542
+ (_, keyword, quote, relativePath) => {
1543
+ const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
1544
+ const resolvedImportUrl = new URL(
1545
+ resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
1546
+ location.href
1547
+ ).href;
1548
+ return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
1549
+ }
1550
+ );
1551
+ const moduleBlobUrl = URL.createObjectURL(
1552
+ new Blob([content], { type: "text/javascript" })
1553
+ );
1554
+ const wrapperContent = [
1555
+ `import*as m from${JSON.stringify(moduleBlobUrl)};`,
1556
+ `globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
1557
+ `globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
1558
+ ].join("");
1559
+ const wrapperBlobUrl = URL.createObjectURL(
1560
+ new Blob([wrapperContent], { type: "text/javascript" })
1561
+ );
1562
+ const scriptEl = document.createElement("script");
1563
+ scriptEl.type = "module";
1564
+ scriptEl.src = wrapperBlobUrl;
1565
+ try {
1566
+ await new Promise((resolve, reject) => {
1567
+ scriptEl.onload = () => resolve();
1568
+ scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
1569
+ document.head.appendChild(scriptEl);
1570
+ });
1571
+ } finally {
1572
+ scriptEl.remove();
1573
+ URL.revokeObjectURL(moduleBlobUrl);
1574
+ URL.revokeObjectURL(wrapperBlobUrl);
1575
+ }
1576
+ const registry = globalThis.__rc_module_registry__;
1577
+ const mod = registry?.[absoluteSrc] ?? {};
1578
+ if (registry)
1579
+ delete registry[absoluteSrc];
1580
+ return mod;
1581
+ }
1582
+ async function importDirectly(absoluteSrc) {
1583
+ try {
1584
+ return await import(
1585
+ /* @vite-ignore */
1586
+ /* webpackIgnore: true */
1587
+ absoluteSrc
1588
+ );
1589
+ } catch (importError) {
1590
+ if (!absoluteSrc.startsWith("blob:")) {
1591
+ warnCrossOriginFetchError("StaticLoader", absoluteSrc);
1592
+ }
1593
+ throw importError;
1594
+ }
1595
+ }
1596
+ function resolveScriptSrc(script, url) {
1597
+ const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
1598
+ if (!rawSrc && script.textContent) {
1599
+ return URL.createObjectURL(
1600
+ new Blob(
1601
+ [script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
1602
+ { type: "text/javascript" }
1603
+ )
1604
+ );
1605
+ }
1606
+ return rawSrc;
1607
+ }
1608
+ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1609
+ const self = globalThis;
1610
+ if (self.__remote_script_entrypoint_mount__?.[url.href]) {
1611
+ self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
1612
+ }
1613
+ if (self.__remote_script_entrypoint_unmount__?.[url.href]) {
1614
+ self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
1615
+ }
1616
+ const mountUnmountSets = await Promise.all(
1617
+ scripts.map(async (script) => {
1618
+ try {
1619
+ const src = resolveScriptSrc(script, url);
1620
+ const absoluteSrc = new URL(src, url).href;
1621
+ const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
1622
+ if (src.startsWith("blob:")) {
1623
+ URL.revokeObjectURL(src);
1624
+ }
1625
+ if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
1626
+ if (!self.__remote_script_entrypoint_mount__) {
1627
+ self.__remote_script_entrypoint_mount__ = {};
1628
+ }
1629
+ if (!self.__remote_script_entrypoint_mount__[url.href]) {
1630
+ self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
1631
+ }
1632
+ self.__remote_script_entrypoint_mount__[url.href]?.add(
1633
+ mod.mount || mod.default?.mount || (() => {
1634
+ })
1635
+ );
1636
+ }
1637
+ if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
1638
+ if (!self.__remote_script_entrypoint_unmount__) {
1639
+ self.__remote_script_entrypoint_unmount__ = {};
1640
+ }
1641
+ if (!self.__remote_script_entrypoint_unmount__[url.href]) {
1642
+ self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
1643
+ }
1644
+ self.__remote_script_entrypoint_unmount__[url.href]?.add(
1645
+ mod.unmount || mod.default?.unmount || (() => {
1646
+ })
1647
+ );
1648
+ }
1649
+ return {
1650
+ mount: mod.mount || mod.default?.mount,
1651
+ unmount: mod.unmount || mod.default?.unmount
1652
+ };
1653
+ } catch (e) {
1654
+ logError(
1655
+ "StaticLoader",
1656
+ `Error loading remote component script from "${script.src || url.href}".`,
1657
+ e
1658
+ );
1659
+ return {
1660
+ mount: void 0,
1661
+ unmount: void 0
1662
+ };
1663
+ }
1664
+ })
1665
+ );
1666
+ return mountUnmountSets.reduce(
1667
+ (acc, { mount, unmount }) => {
1668
+ if (typeof mount === "function") {
1669
+ acc.mount.add(mount);
1670
+ }
1671
+ if (typeof unmount === "function") {
1672
+ acc.unmount.add(unmount);
1673
+ }
1674
+ return acc;
1675
+ },
1676
+ {
1677
+ mount: /* @__PURE__ */ new Set(),
1678
+ unmount: /* @__PURE__ */ new Set()
1679
+ }
1680
+ );
1689
1681
  }
1690
- var init_turbopack = __esm({
1691
- "src/html/host/runtime/turbopack.ts"() {
1682
+ var init_static_loader = __esm({
1683
+ "src/runtime/loaders/static-loader.ts"() {
1692
1684
  "use strict";
1693
- init_polyfill();
1694
- init_webpack_adapter();
1695
- init_next_client_pages_loader();
1696
- init_shared_modules();
1685
+ init_logger();
1697
1686
  }
1698
1687
  });
1699
1688
 
1700
- // src/html/host/runtime/script.ts
1689
+ // src/host/html/runtime/script.ts
1701
1690
  var script_exports = {};
1702
1691
  __export(script_exports, {
1703
1692
  scriptRuntime: () => scriptRuntime
@@ -1716,23 +1705,106 @@ function scriptRuntime(resolveClientUrl) {
1716
1705
  };
1717
1706
  }
1718
1707
  var init_script = __esm({
1719
- "src/html/host/runtime/script.ts"() {
1708
+ "src/host/html/runtime/script.ts"() {
1720
1709
  "use strict";
1721
1710
  init_static_loader();
1722
1711
  }
1723
1712
  });
1724
1713
 
1725
- // src/html/host/index.tsx
1726
- var host_exports = {};
1727
- __export(host_exports, {
1728
- proxyClientRequestsThroughHost: () => proxyClientRequestsThroughHost,
1714
+ // src/host/html/index.tsx
1715
+ var html_exports = {};
1716
+ __export(html_exports, {
1729
1717
  registerSharedModules: () => registerSharedModules
1730
1718
  });
1731
- module.exports = __toCommonJS(host_exports);
1719
+ module.exports = __toCommonJS(html_exports);
1732
1720
  var import_react = require("react");
1733
1721
  var import_client = require("react-dom/client");
1734
1722
 
1735
- // src/shared/client/apply-origin.ts
1723
+ // src/host/server/fetch-with-hooks.ts
1724
+ init_logger();
1725
+
1726
+ // src/host/server/fetch-headers.ts
1727
+ function remoteFetchHeaders() {
1728
+ return {
1729
+ /**
1730
+ * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
1731
+ * If the remote component uses vercel deployment protection, ensure the host and remote vercel
1732
+ * projects share a common automation bypass secret, and the shared secret is used as the
1733
+ * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
1734
+ */
1735
+ ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
1736
+ "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
1737
+ } : {},
1738
+ Accept: "text/html"
1739
+ };
1740
+ }
1741
+
1742
+ // src/host/server/fetch-with-hooks.ts
1743
+ async function fetchWithWarning(url, init) {
1744
+ try {
1745
+ return await fetch(url, init);
1746
+ } catch (error) {
1747
+ warnCrossOriginFetchError("FetchRemoteComponent", url);
1748
+ throw error;
1749
+ }
1750
+ }
1751
+ async function fetchWithHooks(url, additionalInit, options = {}) {
1752
+ const {
1753
+ onRequest,
1754
+ onResponse,
1755
+ abortController = new AbortController()
1756
+ } = options;
1757
+ const signal = abortController.signal;
1758
+ const hookOptions = {
1759
+ signal,
1760
+ abort: (reason) => abortController.abort(reason)
1761
+ };
1762
+ const init = {
1763
+ method: "GET",
1764
+ headers: remoteFetchHeaders(),
1765
+ signal,
1766
+ ...additionalInit
1767
+ };
1768
+ const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
1769
+ return await onResponse?.(url, res, hookOptions) ?? res;
1770
+ }
1771
+
1772
+ // src/host/server/get-client-or-server-url.ts
1773
+ function getClientOrServerUrl(src, serverFallback) {
1774
+ const fallback = typeof location !== "undefined" ? location.href : serverFallback;
1775
+ if (!src) {
1776
+ return new URL(fallback);
1777
+ }
1778
+ return typeof src === "string" ? new URL(src, fallback) : src;
1779
+ }
1780
+
1781
+ // src/host/shared/state.ts
1782
+ function createHostState() {
1783
+ return {
1784
+ stage: "idle",
1785
+ prevSrc: void 0,
1786
+ prevUrl: void 0,
1787
+ prevName: void 0,
1788
+ prevIsRemoteComponent: false,
1789
+ abortController: void 0
1790
+ };
1791
+ }
1792
+
1793
+ // src/host/utils/resolve-name-from-src.ts
1794
+ function resolveNameFromSrc(src, defaultName) {
1795
+ if (!src) {
1796
+ return defaultName;
1797
+ }
1798
+ const hash = typeof src === "string" ? src : src.hash;
1799
+ const hashIndex = hash.indexOf("#");
1800
+ if (hashIndex < 0) {
1801
+ return defaultName;
1802
+ }
1803
+ const name = hash.slice(hashIndex + 1);
1804
+ return name || defaultName;
1805
+ }
1806
+
1807
+ // src/runtime/html/apply-origin.ts
1736
1808
  var tagNames = [
1737
1809
  "img",
1738
1810
  "source",
@@ -1794,51 +1866,9 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
1794
1866
  }
1795
1867
  }
1796
1868
 
1797
- // src/shared/client/proxy-through-host.ts
1798
- init_protected_rc_fallback();
1799
- function withRemoteSrc(resolveClientUrl, remoteSrc) {
1800
- const remoteOrigin = parseOrigin(remoteSrc);
1801
- return (url) => {
1802
- const urlOrigin = parseOrigin(url);
1803
- if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
1804
- return void 0;
1805
- }
1806
- return resolveClientUrl(remoteSrc, url);
1807
- };
1808
- }
1809
- function parseOrigin(url) {
1810
- try {
1811
- return new URL(url).origin;
1812
- } catch {
1813
- return void 0;
1814
- }
1815
- }
1816
- var proxyClientRequestsThroughHost = (remoteSrc, url) => {
1817
- if (typeof location === "undefined") {
1818
- return void 0;
1819
- }
1820
- const remoteOrigin = new URL(remoteSrc, location.href).origin;
1821
- if (remoteOrigin === location.origin) {
1822
- return void 0;
1823
- }
1824
- try {
1825
- const parsed = new URL(url, location.href);
1826
- if (parsed.origin === remoteOrigin) {
1827
- return generateProtectedRcFallbackSrc(url);
1828
- }
1829
- } catch {
1830
- }
1831
- return void 0;
1832
- };
1833
-
1834
- // src/shared/client/default-resolve-client-url.ts
1835
- function bindResolveClientUrl(prop, remoteSrc) {
1836
- return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
1837
- }
1838
-
1839
- // src/shared/client/parse-remote-html.ts
1869
+ // src/runtime/html/parse-remote-html.ts
1870
+ init_constants2();
1840
1871
  init_error();
1841
- init_const();
1842
1872
  function validateSingleComponent(doc, name, url) {
1843
1873
  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}"]`)) {
1844
1874
  throw multipleRemoteComponentsError(url);
@@ -1932,21 +1962,7 @@ function parseRemoteComponentDocument(doc, name, url) {
1932
1962
  };
1933
1963
  }
1934
1964
 
1935
- // src/shared/client/remote-component.ts
1936
- init_error();
1937
-
1938
- // src/shared/client/component-loader.ts
1939
- var React = __toESM(require("react"), 1);
1940
- var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
1941
- var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
1942
- var ReactDOM = __toESM(require("react-dom"), 1);
1943
- var ReactDOMClient = __toESM(require("react-dom/client"), 1);
1944
- init_error();
1945
- init_logger();
1946
- init_next_client_pages_loader();
1947
- init_shared_modules();
1948
-
1949
- // src/shared/client/rsc.ts
1965
+ // src/runtime/rsc.ts
1950
1966
  var import_web_streams_polyfill = require("web-streams-polyfill");
1951
1967
  function fixPayload(payload) {
1952
1968
  if (Array.isArray(payload)) {
@@ -2012,113 +2028,37 @@ function createRSCStream(rscName, data) {
2012
2028
  });
2013
2029
  }
2014
2030
 
2015
- // src/shared/client/component-loader.ts
2016
- init_script_loader();
2017
- init_webpack_adapter();
2018
-
2019
- // src/shared/client/remote-component.ts
2020
- init_const();
2021
- init_script_loader();
2022
- init_static_loader();
2023
- init_webpack_adapter();
2024
-
2025
- // src/shared/contract/host-state.ts
2026
- function createHostState() {
2027
- return {
2028
- stage: "idle",
2029
- prevSrc: void 0,
2030
- prevUrl: void 0,
2031
- prevName: void 0,
2032
- prevIsRemoteComponent: false,
2033
- abortController: void 0
2034
- };
2035
- }
2036
-
2037
- // src/shared/contract/resolve-name-from-src.ts
2038
- function resolveNameFromSrc(src, defaultName) {
2039
- if (!src) {
2040
- return defaultName;
2041
- }
2042
- const hash = typeof src === "string" ? src : src.hash;
2043
- const hashIndex = hash.indexOf("#");
2044
- if (hashIndex < 0) {
2045
- return defaultName;
2046
- }
2047
- const name = hash.slice(hashIndex + 1);
2048
- return name || defaultName;
2049
- }
2050
-
2051
- // src/html/host/index.tsx
2052
- init_error();
2053
-
2054
- // src/shared/ssr/fetch-with-hooks.ts
2055
- init_logger();
2056
-
2057
- // src/shared/ssr/fetch-headers.ts
2058
- function remoteFetchHeaders() {
2059
- return {
2060
- /**
2061
- * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
2062
- * If the remote component uses vercel deployment protection, ensure the host and remote vercel
2063
- * projects share a common automation bypass secret, and the shared secret is used as the
2064
- * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
2065
- */
2066
- ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
2067
- "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
2068
- } : {},
2069
- Accept: "text/html"
2031
+ // src/runtime/url/resolve-client-url.ts
2032
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
2033
+ const remoteOrigin = parseOrigin(remoteSrc);
2034
+ return (url) => {
2035
+ const urlOrigin = parseOrigin(url);
2036
+ if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
2037
+ return void 0;
2038
+ }
2039
+ return resolveClientUrl(remoteSrc, url);
2070
2040
  };
2071
2041
  }
2072
-
2073
- // src/shared/ssr/fetch-with-hooks.ts
2074
- async function fetchWithHooks(url, additionalInit, options = {}) {
2075
- const {
2076
- onRequest,
2077
- onResponse,
2078
- abortController = new AbortController()
2079
- } = options;
2080
- const signal = abortController.signal;
2081
- const hookOptions = {
2082
- signal,
2083
- abort: (reason) => abortController.abort(reason)
2084
- };
2085
- const init = {
2086
- method: "GET",
2087
- headers: remoteFetchHeaders(),
2088
- signal,
2089
- ...additionalInit
2090
- };
2091
- let res = await onRequest?.(url, init, hookOptions);
2092
- if (!res) {
2093
- try {
2094
- res = await fetch(url, init);
2095
- } catch (error) {
2096
- warnCrossOriginFetchError("FetchRemoteComponent", url);
2097
- throw error;
2098
- }
2099
- }
2100
- const transformedRes = await onResponse?.(url, res, hookOptions);
2101
- if (transformedRes) {
2102
- res = transformedRes;
2042
+ function parseOrigin(url) {
2043
+ try {
2044
+ return new URL(url).origin;
2045
+ } catch {
2046
+ return void 0;
2103
2047
  }
2104
- return res;
2105
2048
  }
2106
2049
 
2107
- // src/shared/ssr/get-client-or-server-url.ts
2108
- function getClientOrServerUrl(src, serverFallback) {
2109
- const fallback = typeof location !== "undefined" ? location.href : serverFallback;
2110
- if (!src) {
2111
- return new URL(fallback);
2112
- }
2113
- return typeof src === "string" ? new URL(src, fallback) : src;
2050
+ // src/runtime/url/default-resolve-client-url.ts
2051
+ function bindResolveClientUrl(prop, remoteSrc) {
2052
+ return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
2114
2053
  }
2115
2054
 
2116
- // src/html/host/index.tsx
2055
+ // src/host/html/index.tsx
2117
2056
  init_utils();
2118
2057
  init_abort();
2058
+ init_error();
2119
2059
  init_logger();
2120
2060
 
2121
- // src/html/host/attach-styles.ts
2061
+ // src/host/html/attach-styles.ts
2122
2062
  init_error();
2123
2063
  async function attachStyles({
2124
2064
  doc,
@@ -2201,7 +2141,7 @@ async function attachStyles({
2201
2141
  }
2202
2142
  }
2203
2143
 
2204
- // src/html/host/runtime/index.ts
2144
+ // src/host/html/runtime/index.ts
2205
2145
  init_error();
2206
2146
  async function getRuntime(type, url, bundle, shared, remoteShared, resolveClientUrl) {
2207
2147
  if (typeof globalThis.process === "undefined") {
@@ -2235,7 +2175,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
2235
2175
  );
2236
2176
  }
2237
2177
 
2238
- // src/html/host/index.tsx
2178
+ // src/host/html/index.tsx
2239
2179
  var import_jsx_runtime2 = require("react/jsx-runtime");
2240
2180
  if (typeof HTMLElement !== "undefined") {
2241
2181
  class RemoteComponent extends HTMLElement {
@@ -2250,7 +2190,7 @@ if (typeof HTMLElement !== "undefined") {
2250
2190
  onRequest;
2251
2191
  onResponse;
2252
2192
  resolveClientUrl;
2253
- // -- HostConfig property accessors (attribute-reflected) --
2193
+ // -- ConsumeServerConfig property accessors (attribute-reflected) --
2254
2194
  get src() {
2255
2195
  return this.getAttribute("src") ?? void 0;
2256
2196
  }
@@ -2828,7 +2768,6 @@ function registerSharedModules(modules = {}) {
2828
2768
  }
2829
2769
  // Annotate the CommonJS export names for ESM import in node:
2830
2770
  0 && (module.exports = {
2831
- proxyClientRequestsThroughHost,
2832
2771
  registerSharedModules
2833
2772
  });
2834
- //# sourceMappingURL=host.cjs.map
2773
+ //# sourceMappingURL=html.cjs.map