remote-components 0.1.2 → 0.2.0

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