remote-components 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (469) 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} +1270 -1201
  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} +1266 -1196
  22. package/dist/host/html.js.map +1 -0
  23. package/dist/{next/host/client/index.cjs → host/nextjs/app/client-only.cjs} +690 -518
  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} +693 -514
  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/host/nextjs/pages.d.ts +77 -0
  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/{internal/shared/client/proxy-through-host.cjs → host/proxy/client.cjs} +19 -13
  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} +552 -477
  58. package/dist/host/react.cjs.map +1 -0
  59. package/dist/host/react.d.ts +366 -0
  60. package/dist/{react/index.js → host/react.js} +551 -474
  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} +36 -29
  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} +27 -25
  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/internal/host/server/types.cjs +17 -0
  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/internal/host/shared/config.d.ts +100 -0
  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-cbe44b51.d.ts → internal/host/shared/fetch-interceptors.d.ts} +7 -73
  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/{next/remote/server.cjs → internal/host/shared/state.cjs} +16 -7
  161. package/dist/internal/host/shared/state.cjs.map +1 -0
  162. package/dist/internal/host/shared/state.d.ts +53 -0
  163. package/dist/internal/host/shared/state.js +14 -0
  164. package/dist/internal/host/shared/state.js.map +1 -0
  165. package/dist/internal/host/utils/resolve-name-from-src.cjs +40 -0
  166. package/dist/internal/host/utils/resolve-name-from-src.cjs.map +1 -0
  167. package/dist/internal/host/utils/resolve-name-from-src.d.ts +13 -0
  168. package/dist/internal/host/utils/resolve-name-from-src.js +16 -0
  169. package/dist/internal/host/utils/resolve-name-from-src.js.map +1 -0
  170. package/dist/internal/{next/remote/render-client.cjs → remote/nextjs/app-client.cjs} +8 -8
  171. package/dist/internal/remote/nextjs/app-client.cjs.map +1 -0
  172. package/dist/internal/{next/remote/render-client.js → remote/nextjs/app-client.js} +4 -4
  173. package/dist/internal/remote/nextjs/app-client.js.map +1 -0
  174. package/dist/internal/runtime/constants.cjs +50 -0
  175. package/dist/internal/runtime/constants.cjs.map +1 -0
  176. package/dist/internal/runtime/constants.d.ts +10 -0
  177. package/dist/internal/runtime/constants.js +20 -0
  178. package/dist/internal/runtime/constants.js.map +1 -0
  179. package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs.map +1 -1
  180. package/dist/internal/{shared/client → runtime/html}/apply-origin.d.ts +1 -1
  181. package/dist/internal/{shared/client → runtime/html}/apply-origin.js.map +1 -1
  182. package/dist/internal/runtime/html/parse-remote-html.cjs +140 -0
  183. package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -0
  184. package/dist/internal/runtime/html/parse-remote-html.d.ts +88 -0
  185. package/dist/internal/runtime/html/parse-remote-html.js +110 -0
  186. package/dist/internal/runtime/html/parse-remote-html.js.map +1 -0
  187. package/dist/internal/runtime/html/set-attributes-from-props.cjs +68 -0
  188. package/dist/internal/runtime/html/set-attributes-from-props.cjs.map +1 -0
  189. package/dist/internal/runtime/html/set-attributes-from-props.d.ts +3 -0
  190. package/dist/internal/runtime/html/set-attributes-from-props.js +44 -0
  191. package/dist/internal/runtime/html/set-attributes-from-props.js.map +1 -0
  192. package/dist/internal/runtime/loaders/component-loader.cjs +184 -0
  193. package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -0
  194. package/dist/internal/runtime/loaders/component-loader.d.ts +31 -0
  195. package/dist/internal/runtime/loaders/component-loader.js +150 -0
  196. package/dist/internal/runtime/loaders/component-loader.js.map +1 -0
  197. package/dist/internal/runtime/loaders/script-loader.cjs +69 -0
  198. package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -0
  199. package/dist/internal/runtime/loaders/script-loader.d.ts +10 -0
  200. package/dist/internal/runtime/loaders/script-loader.js +48 -0
  201. package/dist/internal/runtime/loaders/script-loader.js.map +1 -0
  202. package/dist/internal/runtime/loaders/static-loader.cjs +177 -0
  203. package/dist/internal/runtime/loaders/static-loader.cjs.map +1 -0
  204. package/dist/internal/runtime/loaders/static-loader.d.ts +10 -0
  205. package/dist/internal/runtime/loaders/static-loader.js +153 -0
  206. package/dist/internal/runtime/loaders/static-loader.js.map +1 -0
  207. package/dist/internal/runtime/metadata.cjs +17 -0
  208. package/dist/internal/runtime/metadata.cjs.map +1 -0
  209. package/dist/internal/runtime/metadata.d.ts +16 -0
  210. package/dist/internal/runtime/metadata.js +1 -0
  211. package/dist/internal/runtime/metadata.js.map +1 -0
  212. package/dist/internal/runtime/rsc.cjs +92 -0
  213. package/dist/internal/runtime/rsc.cjs.map +1 -0
  214. package/dist/internal/runtime/rsc.d.ts +8 -0
  215. package/dist/internal/runtime/rsc.js +68 -0
  216. package/dist/internal/runtime/rsc.js.map +1 -0
  217. package/dist/internal/runtime/turbopack/chunk-loader.cjs +244 -0
  218. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -0
  219. package/dist/internal/runtime/turbopack/chunk-loader.d.ts +11 -0
  220. package/dist/internal/runtime/turbopack/chunk-loader.js +227 -0
  221. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -0
  222. package/dist/internal/runtime/turbopack/module.cjs +257 -0
  223. package/dist/internal/runtime/turbopack/module.cjs.map +1 -0
  224. package/dist/internal/runtime/turbopack/module.d.ts +61 -0
  225. package/dist/internal/runtime/turbopack/module.js +233 -0
  226. package/dist/internal/runtime/turbopack/module.js.map +1 -0
  227. package/dist/internal/runtime/turbopack/patterns.cjs +44 -0
  228. package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -0
  229. package/dist/internal/runtime/turbopack/patterns.d.ts +109 -0
  230. package/dist/internal/runtime/turbopack/patterns.js +15 -0
  231. package/dist/internal/runtime/turbopack/patterns.js.map +1 -0
  232. package/dist/internal/runtime/turbopack/shared-modules.cjs +152 -0
  233. package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -0
  234. package/dist/internal/runtime/turbopack/shared-modules.d.ts +17 -0
  235. package/dist/internal/runtime/turbopack/shared-modules.js +133 -0
  236. package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -0
  237. package/dist/internal/runtime/turbopack/webpack-runtime.cjs +137 -0
  238. package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -0
  239. package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +20 -0
  240. package/dist/internal/runtime/turbopack/webpack-runtime.js +107 -0
  241. package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -0
  242. package/dist/internal/runtime/types.cjs +17 -0
  243. package/dist/internal/runtime/types.cjs.map +1 -0
  244. package/dist/internal/runtime/types.d.ts +40 -0
  245. package/dist/internal/runtime/types.js +1 -0
  246. package/dist/internal/runtime/types.js.map +1 -0
  247. package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.cjs +2 -2
  248. package/dist/internal/runtime/url/default-resolve-client-url.cjs.map +1 -0
  249. package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.d.ts +1 -1
  250. package/dist/internal/{shared/client → runtime/url}/default-resolve-client-url.js +1 -1
  251. package/dist/internal/runtime/url/default-resolve-client-url.js.map +1 -0
  252. package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.cjs +1 -1
  253. package/dist/internal/runtime/url/protected-rc-fallback.cjs.map +1 -0
  254. package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.js +1 -1
  255. package/dist/internal/runtime/url/protected-rc-fallback.js.map +1 -0
  256. package/dist/internal/runtime/url/resolve-client-url.cjs +45 -0
  257. package/dist/internal/runtime/url/resolve-client-url.cjs.map +1 -0
  258. package/dist/internal/{shared/client/proxy-through-host.d.ts → runtime/url/resolve-client-url.d.ts} +6 -25
  259. package/dist/internal/runtime/url/resolve-client-url.js +21 -0
  260. package/dist/internal/runtime/url/resolve-client-url.js.map +1 -0
  261. package/dist/internal/utils/abort.cjs.map +1 -0
  262. package/dist/internal/utils/abort.js.map +1 -0
  263. package/dist/internal/{shared → utils}/constants.cjs +3 -0
  264. package/dist/internal/utils/constants.cjs.map +1 -0
  265. package/dist/internal/utils/constants.d.ts +5 -0
  266. package/dist/internal/{shared → utils}/constants.js +2 -0
  267. package/dist/internal/utils/constants.js.map +1 -0
  268. package/dist/internal/{shared → utils}/error.cjs +4 -4
  269. package/dist/internal/utils/error.cjs.map +1 -0
  270. package/dist/internal/{shared → utils}/error.js +4 -4
  271. package/dist/internal/utils/error.js.map +1 -0
  272. package/dist/internal/{shared/utils → utils}/logger.cjs +3 -3
  273. package/dist/internal/utils/logger.cjs.map +1 -0
  274. package/dist/internal/{shared/utils → utils}/logger.d.ts +2 -2
  275. package/dist/internal/{shared/utils → utils}/logger.js +3 -3
  276. package/dist/internal/utils/logger.js.map +1 -0
  277. package/dist/internal/utils.cjs.map +1 -0
  278. package/dist/internal/utils.js.map +1 -0
  279. package/dist/{shared/host → remote/defaults}/app.cjs +2 -6
  280. package/dist/remote/defaults/app.cjs.map +1 -0
  281. package/dist/remote/defaults/app.js +8 -0
  282. package/dist/remote/defaults/app.js.map +1 -0
  283. package/dist/{shared/host → remote/defaults}/pages.cjs +2 -6
  284. package/dist/remote/defaults/pages.cjs.map +1 -0
  285. package/dist/remote/defaults/pages.js +8 -0
  286. package/dist/remote/defaults/pages.js.map +1 -0
  287. package/dist/{shared/remote → remote/defaults}/wrapper.cjs +12 -10
  288. package/dist/remote/defaults/wrapper.cjs.map +1 -0
  289. package/dist/remote/defaults/wrapper.js +27 -0
  290. package/dist/remote/defaults/wrapper.js.map +1 -0
  291. package/dist/{html/remote.cjs → remote/html.cjs} +16 -16
  292. package/dist/remote/html.cjs.map +1 -0
  293. package/dist/{html/remote.js → remote/html.js} +16 -16
  294. package/dist/remote/html.js.map +1 -0
  295. package/dist/{shared/remote/proxy.cjs → remote/middleware.cjs} +37 -12
  296. package/dist/remote/middleware.cjs.map +1 -0
  297. package/dist/remote/middleware.d.ts +27 -0
  298. package/dist/{shared/remote/proxy.js → remote/middleware.js} +32 -5
  299. package/dist/remote/middleware.js.map +1 -0
  300. package/dist/{internal/next/remote/render-server.cjs → remote/nextjs/app.cjs} +14 -16
  301. package/dist/remote/nextjs/app.cjs.map +1 -0
  302. package/dist/remote/nextjs/app.d.ts +45 -0
  303. package/dist/{internal/next/remote/render-server.js → remote/nextjs/app.js} +9 -11
  304. package/dist/remote/nextjs/app.js.map +1 -0
  305. package/dist/{next/remote/pages-router.cjs → remote/nextjs/pages.cjs} +8 -8
  306. package/dist/remote/nextjs/pages.cjs.map +1 -0
  307. package/dist/{next/remote/pages-router.d.ts → remote/nextjs/pages.d.ts} +8 -8
  308. package/dist/{next/remote/pages-router.js → remote/nextjs/pages.js} +4 -4
  309. package/dist/remote/nextjs/pages.js.map +1 -0
  310. package/dist/server-handoff-8c89b856.d.ts +46 -0
  311. package/package.json +126 -157
  312. package/dist/component-loader-76eb1b8b.d.ts +0 -200
  313. package/dist/html/host.cjs.map +0 -1
  314. package/dist/html/host.js.map +0 -1
  315. package/dist/html/remote.cjs.map +0 -1
  316. package/dist/html/remote.js.map +0 -1
  317. package/dist/internal/next/host/app-router-client.cjs.map +0 -1
  318. package/dist/internal/next/host/app-router-client.d.ts +0 -66
  319. package/dist/internal/next/host/app-router-client.js.map +0 -1
  320. package/dist/internal/next/host/app-router-compat.cjs.map +0 -1
  321. package/dist/internal/next/host/app-router-compat.js.map +0 -1
  322. package/dist/internal/next/host/remote-component-links.cjs.map +0 -1
  323. package/dist/internal/next/host/remote-component-links.js.map +0 -1
  324. package/dist/internal/next/remote/render-client.cjs.map +0 -1
  325. package/dist/internal/next/remote/render-client.js.map +0 -1
  326. package/dist/internal/next/remote/render-server.cjs.map +0 -1
  327. package/dist/internal/next/remote/render-server.d.ts +0 -47
  328. package/dist/internal/next/remote/render-server.js.map +0 -1
  329. package/dist/internal/react/context.cjs.map +0 -1
  330. package/dist/internal/react/context.js.map +0 -1
  331. package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +0 -1
  332. package/dist/internal/react/hooks/use-resolve-client-url.js.map +0 -1
  333. package/dist/internal/shared/client/default-resolve-client-url.cjs.map +0 -1
  334. package/dist/internal/shared/client/default-resolve-client-url.js.map +0 -1
  335. package/dist/internal/shared/client/get-client-src.cjs.map +0 -1
  336. package/dist/internal/shared/client/get-client-src.js.map +0 -1
  337. package/dist/internal/shared/client/polyfill.cjs.map +0 -1
  338. package/dist/internal/shared/client/polyfill.js.map +0 -1
  339. package/dist/internal/shared/client/protected-rc-fallback.cjs.map +0 -1
  340. package/dist/internal/shared/client/protected-rc-fallback.js.map +0 -1
  341. package/dist/internal/shared/client/proxy-through-host.cjs.map +0 -1
  342. package/dist/internal/shared/client/proxy-through-host.js +0 -26
  343. package/dist/internal/shared/client/proxy-through-host.js.map +0 -1
  344. package/dist/internal/shared/client/remote-component.cjs +0 -1436
  345. package/dist/internal/shared/client/remote-component.cjs.map +0 -1
  346. package/dist/internal/shared/client/remote-component.d.ts +0 -62
  347. package/dist/internal/shared/client/remote-component.js +0 -1385
  348. package/dist/internal/shared/client/remote-component.js.map +0 -1
  349. package/dist/internal/shared/constants.cjs.map +0 -1
  350. package/dist/internal/shared/constants.d.ts +0 -4
  351. package/dist/internal/shared/constants.js.map +0 -1
  352. package/dist/internal/shared/error.cjs.map +0 -1
  353. package/dist/internal/shared/error.js.map +0 -1
  354. package/dist/internal/shared/ssr/dom-flight.cjs.map +0 -1
  355. package/dist/internal/shared/ssr/dom-flight.d.ts +0 -2
  356. package/dist/internal/shared/ssr/dom-flight.js.map +0 -1
  357. package/dist/internal/shared/ssr/fetch-headers.cjs.map +0 -1
  358. package/dist/internal/shared/ssr/fetch-headers.js.map +0 -1
  359. package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +0 -1
  360. package/dist/internal/shared/ssr/fetch-remote-component.js.map +0 -1
  361. package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +0 -1
  362. package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +0 -56
  363. package/dist/internal/shared/ssr/fetch-with-hooks.js.map +0 -1
  364. package/dist/internal/shared/ssr/get-client-or-server-url.cjs.map +0 -1
  365. package/dist/internal/shared/ssr/get-client-or-server-url.js.map +0 -1
  366. package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +0 -1
  367. package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +0 -1
  368. package/dist/internal/shared/ssr/skeleton.cjs.map +0 -1
  369. package/dist/internal/shared/ssr/skeleton.js.map +0 -1
  370. package/dist/internal/shared/utils/abort.cjs.map +0 -1
  371. package/dist/internal/shared/utils/abort.js.map +0 -1
  372. package/dist/internal/shared/utils/logger.cjs.map +0 -1
  373. package/dist/internal/shared/utils/logger.js.map +0 -1
  374. package/dist/internal/shared/utils.cjs.map +0 -1
  375. package/dist/internal/shared/utils.js.map +0 -1
  376. package/dist/internal/webpack/next-client-pages-loader.cjs.map +0 -1
  377. package/dist/internal/webpack/next-client-pages-loader.js.map +0 -1
  378. package/dist/internal/webpack/shared-modules.cjs.map +0 -1
  379. package/dist/internal/webpack/shared-modules.js.map +0 -1
  380. package/dist/next/config.cjs.map +0 -1
  381. package/dist/next/config.js.map +0 -1
  382. package/dist/next/host/app-router-server.cjs.map +0 -1
  383. package/dist/next/host/app-router-server.d.ts +0 -60
  384. package/dist/next/host/app-router-server.js.map +0 -1
  385. package/dist/next/host/client/index.cjs.map +0 -1
  386. package/dist/next/host/client/index.d.ts +0 -19
  387. package/dist/next/host/client/index.js.map +0 -1
  388. package/dist/next/host/pages-router-client.cjs.map +0 -1
  389. package/dist/next/host/pages-router-client.d.ts +0 -56
  390. package/dist/next/host/pages-router-client.js.map +0 -1
  391. package/dist/next/host/pages-router-server.cjs.map +0 -1
  392. package/dist/next/host/pages-router-server.d.ts +0 -104
  393. package/dist/next/host/pages-router-server.js.map +0 -1
  394. package/dist/next/index.cjs +0 -53
  395. package/dist/next/index.cjs.map +0 -1
  396. package/dist/next/index.d.ts +0 -56
  397. package/dist/next/index.js +0 -19
  398. package/dist/next/index.js.map +0 -1
  399. package/dist/next/proxy.cjs.map +0 -1
  400. package/dist/next/proxy.d.ts +0 -56
  401. package/dist/next/proxy.js.map +0 -1
  402. package/dist/next/remote/pages-router.cjs.map +0 -1
  403. package/dist/next/remote/pages-router.js.map +0 -1
  404. package/dist/next/remote/server.cjs.map +0 -1
  405. package/dist/next/remote/server.d.ts +0 -1
  406. package/dist/next/remote/server.js +0 -5
  407. package/dist/next/remote/server.js.map +0 -1
  408. package/dist/proxy-through-host-a676a522.d.ts +0 -52
  409. package/dist/react/index.cjs.map +0 -1
  410. package/dist/react/index.d.ts +0 -123
  411. package/dist/react/index.js.map +0 -1
  412. package/dist/shared/host/app.cjs.map +0 -1
  413. package/dist/shared/host/app.js +0 -12
  414. package/dist/shared/host/app.js.map +0 -1
  415. package/dist/shared/host/pages.cjs.map +0 -1
  416. package/dist/shared/host/pages.js +0 -12
  417. package/dist/shared/host/pages.js.map +0 -1
  418. package/dist/shared/host/proxy.cjs.map +0 -1
  419. package/dist/shared/host/proxy.js.map +0 -1
  420. package/dist/shared/remote/app.cjs.map +0 -1
  421. package/dist/shared/remote/app.js +0 -8
  422. package/dist/shared/remote/app.js.map +0 -1
  423. package/dist/shared/remote/pages.cjs.map +0 -1
  424. package/dist/shared/remote/pages.js +0 -8
  425. package/dist/shared/remote/pages.js.map +0 -1
  426. package/dist/shared/remote/proxy.cjs.map +0 -1
  427. package/dist/shared/remote/proxy.d.ts +0 -44
  428. package/dist/shared/remote/proxy.js.map +0 -1
  429. package/dist/shared/remote/wrapper.cjs.map +0 -1
  430. package/dist/shared/remote/wrapper.js +0 -25
  431. package/dist/shared/remote/wrapper.js.map +0 -1
  432. package/dist/webpack.cjs.map +0 -1
  433. package/dist/webpack.js.map +0 -1
  434. /package/dist/{webpack.d.ts → config/webpack.d.ts} +0 -0
  435. /package/dist/{shared/host → host/defaults}/app.d.ts +0 -0
  436. /package/dist/{shared/host → host/defaults}/pages.d.ts +0 -0
  437. /package/dist/{shared/host/proxy.d.ts → host/proxy/protected-fetch.d.ts} +0 -0
  438. /package/dist/internal/{webpack/shared-modules.d.ts → config/webpack/apply-shared-modules.d.ts} +0 -0
  439. /package/dist/internal/{webpack → config/webpack}/next-client-pages-loader.d.ts +0 -0
  440. /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.cjs +0 -0
  441. /package/dist/internal/{shared/ssr → host/nextjs}/dom-flight.js +0 -0
  442. /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.cjs +0 -0
  443. /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.d.ts +0 -0
  444. /package/dist/internal/{shared/ssr → host/nextjs}/skeleton.js +0 -0
  445. /package/dist/internal/{shared/ssr → host/server}/fetch-headers.cjs +0 -0
  446. /package/dist/internal/{shared/ssr → host/server}/fetch-headers.d.ts +0 -0
  447. /package/dist/internal/{shared/ssr → host/server}/fetch-headers.js +0 -0
  448. /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.cjs +0 -0
  449. /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.d.ts +0 -0
  450. /package/dist/internal/{shared/ssr → host/server}/get-client-or-server-url.js +0 -0
  451. /package/dist/internal/{shared/client → host/server}/get-client-src.d.ts +0 -0
  452. /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.cjs +0 -0
  453. /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.d.ts +0 -0
  454. /package/dist/internal/{shared/ssr → host/server}/get-ssr-relative-path-base-url.js +0 -0
  455. /package/dist/internal/{next/remote/render-client.d.ts → remote/nextjs/app-client.d.ts} +0 -0
  456. /package/dist/internal/{shared/client → runtime/html}/apply-origin.cjs +0 -0
  457. /package/dist/internal/{shared/client → runtime/html}/apply-origin.js +0 -0
  458. /package/dist/internal/{shared/client → runtime/url}/protected-rc-fallback.d.ts +0 -0
  459. /package/dist/internal/{shared/utils → utils}/abort.cjs +0 -0
  460. /package/dist/internal/{shared/utils → utils}/abort.d.ts +0 -0
  461. /package/dist/internal/{shared/utils → utils}/abort.js +0 -0
  462. /package/dist/internal/{shared → utils}/error.d.ts +0 -0
  463. /package/dist/internal/{shared/utils.cjs → utils.cjs} +0 -0
  464. /package/dist/internal/{shared/utils.d.ts → utils.d.ts} +0 -0
  465. /package/dist/internal/{shared/utils.js → utils.js} +0 -0
  466. /package/dist/{shared/remote → remote/defaults}/app.d.ts +0 -0
  467. /package/dist/{shared/remote → remote/defaults}/pages.d.ts +0 -0
  468. /package/dist/{shared/remote → remote/defaults}/wrapper.d.ts +0 -0
  469. /package/dist/{html/remote.d.ts → remote/html.d.ts} +0 -0
@@ -1,1385 +0,0 @@
1
- // src/shared/constants.ts
2
- var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
3
- var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
4
-
5
- // src/shared/client/protected-rc-fallback.ts
6
- function generateProtectedRcFallbackSrc(url) {
7
- return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
8
- }
9
- function isProxiedUrl(url) {
10
- try {
11
- return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
12
- } catch {
13
- return false;
14
- }
15
- }
16
-
17
- // src/shared/error.ts
18
- var RemoteComponentsError = class extends Error {
19
- code = "REMOTE_COMPONENTS_ERROR";
20
- constructor(message, options) {
21
- super(message, options);
22
- this.name = "RemoteComponentsError";
23
- }
24
- };
25
-
26
- // src/shared/client/component-loader.ts
27
- import * as React from "react";
28
- import * as JSXDevRuntime from "react/jsx-dev-runtime";
29
- import * as JSXRuntime from "react/jsx-runtime";
30
- import * as ReactDOM from "react-dom";
31
- import * as ReactDOMClient from "react-dom/client";
32
-
33
- // src/shared/utils/logger.ts
34
- var PREFIX = "remote-components";
35
- var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
36
- function logDebug(location2, message) {
37
- if (DEBUG) {
38
- console.debug(`[${PREFIX}:${location2}]: ${message}`);
39
- }
40
- }
41
- function logWarn(location2, message) {
42
- console.warn(`[${PREFIX}:${location2}]: ${message}`);
43
- }
44
- function logError(location2, message, cause) {
45
- console.error(
46
- new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
47
- cause
48
- })
49
- );
50
- }
51
- function warnCrossOriginFetchError(logLocation, url) {
52
- try {
53
- const parsed = typeof url === "string" ? new URL(url) : url;
54
- if (typeof location === "undefined" || parsed.origin === location.origin) {
55
- return;
56
- }
57
- logWarn(
58
- logLocation,
59
- `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}`
60
- );
61
- } catch {
62
- }
63
- }
64
-
65
- // src/shared/webpack/next-client-pages-loader.ts
66
- function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
67
- const self = globalThis;
68
- const nextCssOriginal = document.querySelector(
69
- `[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
70
- );
71
- if (nextCssOriginal) {
72
- nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
73
- }
74
- const nextCss = document.createElement("noscript");
75
- nextCss.id = "__next_css__DO_NOT_USE__";
76
- nextCss.setAttribute("data-bundle", bundle);
77
- nextCss.setAttribute("data-route", route);
78
- const nextCssEnd = document.createElement("noscript");
79
- nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
80
- nextCssEnd.setAttribute("data-bundle", bundle);
81
- nextCssEnd.setAttribute("data-route", route);
82
- document.head.appendChild(nextCssEnd);
83
- document.head.appendChild(nextCss);
84
- const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
85
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
86
- ) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
87
- (key) => key.includes("/next/dist/client/page-loader.js")
88
- ) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
89
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
90
- ) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
91
- (key) => key.includes("/next/dist/client/page-loader.js")
92
- ) ?? ""] ?? -1;
93
- const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
94
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
95
- ) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
96
- (key) => key.includes("/next/dist/client/page-loader.js")
97
- ) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
98
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
99
- ) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
100
- (key) => key.includes("/next/dist/client/page-loader.js")
101
- ) ?? ""] ?? -1;
102
- if (!(componentLoaderChunk && appLoaderChunk)) {
103
- throw new RemoteComponentsError(
104
- `Next.js client pages loader not found in bundle "${bundle}".`
105
- );
106
- }
107
- const __NEXT_P_ORIGINAL = self.__NEXT_P;
108
- const selfOriginal = self;
109
- delete selfOriginal.__NEXT_P;
110
- self.__remote_webpack_require__?.[bundle]?.(
111
- self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
112
- );
113
- if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
114
- self.__remote_webpack_require__?.[bundle]?.(
115
- self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
116
- );
117
- }
118
- if (self.__NEXT_P) {
119
- const [, componentLoader] = self.__NEXT_P[0] ?? [
120
- void 0,
121
- () => ({ default: null })
122
- ];
123
- const [, appLoader] = self.__NEXT_P[2] ?? [
124
- void 0,
125
- () => ({
126
- default: null
127
- })
128
- ];
129
- const { default: Component } = componentLoader();
130
- const { default: App } = appLoader();
131
- if (!self.__remote_next_css__) {
132
- self.__remote_next_css__ = {};
133
- }
134
- if (!self.__remote_next_css__[bundle]) {
135
- const cssRE = /\.s?css$/;
136
- Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
137
- self.__remote_webpack_require__?.[bundle]?.(id);
138
- });
139
- Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
140
- const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
141
- if (id) {
142
- self.__remote_webpack_require__?.[bundle]?.(id);
143
- }
144
- });
145
- const elements = [];
146
- let node = nextCss.previousSibling;
147
- while (node && node !== nextCssEnd) {
148
- elements.push(node);
149
- node.remove();
150
- node = nextCss.previousSibling;
151
- }
152
- self.__remote_next_css__[bundle] = elements;
153
- }
154
- if (styleContainer) {
155
- const elements = self.__remote_next_css__[bundle];
156
- elements.forEach((el) => {
157
- styleContainer.appendChild(el.cloneNode(true));
158
- });
159
- } else {
160
- const elements = self.__remote_next_css__[bundle];
161
- elements.forEach((el) => {
162
- document.head.appendChild(el);
163
- });
164
- }
165
- delete self.__NEXT_P;
166
- self.__NEXT_P = __NEXT_P_ORIGINAL;
167
- if (nextCssOriginal) {
168
- nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
169
- }
170
- nextCss.remove();
171
- nextCssEnd.remove();
172
- return { Component, App };
173
- }
174
- return { Component: null, App: null };
175
- }
176
-
177
- // src/shared/webpack/shared-modules.ts
178
- function applySharedModules(bundle, resolve) {
179
- logDebug(
180
- "SharedModules",
181
- `applySharedModules called for bundle: "${bundle}"`
182
- );
183
- logDebug(
184
- "SharedModules",
185
- `Shared modules to resolve: ${Object.keys(resolve)}`
186
- );
187
- const self = globalThis;
188
- if (self.__remote_webpack_require__?.[bundle]) {
189
- const modulePaths = Object.keys(
190
- self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
191
- );
192
- logDebug(
193
- "SharedModules",
194
- `Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
195
- );
196
- for (const [key, value] of Object.entries(resolve)) {
197
- let ids = modulePaths.filter((p) => p === key);
198
- if (ids.length === 0) {
199
- ids = modulePaths.filter((p) => p.includes(key));
200
- }
201
- if (ids.length === 0) {
202
- logDebug(
203
- "SharedModules",
204
- `No matching module path found for shared module "${key}"`
205
- );
206
- }
207
- for (let id of ids) {
208
- const webpackBundle = self.__remote_webpack_require__[bundle];
209
- if (webpackBundle.m) {
210
- if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
211
- const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
212
- logDebug(
213
- "SharedModules",
214
- `Mapped module id: "${id}" -> "${mappedId}"`
215
- );
216
- id = mappedId;
217
- }
218
- webpackBundle.m[id] = (module) => {
219
- module.exports = value;
220
- };
221
- } else {
222
- logWarn(
223
- "SharedModules",
224
- `webpackBundle.m is not available for bundle "${bundle}"`
225
- );
226
- }
227
- }
228
- }
229
- } else {
230
- logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
231
- logDebug(
232
- "SharedModules",
233
- `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
234
- );
235
- }
236
- }
237
-
238
- // src/shared/client/rsc.ts
239
- import { ReadableStream } from "web-streams-polyfill";
240
- function fixPayload(payload) {
241
- if (Array.isArray(payload)) {
242
- if (payload[0] === "$") {
243
- fixPayload(payload[3]);
244
- if (payload.length === 4) {
245
- payload.push(null, null, 1);
246
- }
247
- } else {
248
- for (const item of payload) {
249
- fixPayload(item);
250
- }
251
- }
252
- } else if (typeof payload === "object" && payload !== null) {
253
- for (const key in payload) {
254
- fixPayload(payload[key]);
255
- }
256
- }
257
- }
258
- function createRSCStream(rscName, data) {
259
- return new ReadableStream({
260
- type: "bytes",
261
- start(controller) {
262
- const encoder = new TextEncoder();
263
- const self = globalThis;
264
- if (data.length > 0) {
265
- data.forEach((chunk) => {
266
- const lines = chunk.split("\n");
267
- for (const line of lines) {
268
- const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
269
- if (match?.groups?.rsc) {
270
- self[rscName] = self[rscName] ?? [];
271
- self[rscName].push(JSON.parse(`"${match.groups.rsc}"`));
272
- }
273
- }
274
- });
275
- }
276
- const allChunks = (self[rscName] ?? [`0:[null]
277
- `]).join("");
278
- self[rscName] = null;
279
- allChunks.split("\n").forEach((chunk) => {
280
- if (chunk.length > 0) {
281
- const { before, id, prefix, payload } = /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
282
- chunk
283
- )?.groups ?? {};
284
- if (payload) {
285
- const jsonPayload = JSON.parse(payload);
286
- fixPayload(jsonPayload);
287
- const reconstruct = `${before ?? ""}${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
288
- controller.enqueue(encoder.encode(`${reconstruct}
289
- `));
290
- } else {
291
- controller.enqueue(encoder.encode(`${chunk}
292
- `));
293
- }
294
- } else {
295
- controller.enqueue(encoder.encode(`${chunk}
296
- `));
297
- }
298
- });
299
- controller.close();
300
- }
301
- });
302
- }
303
-
304
- // src/shared/client/webpack-patterns.ts
305
- var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
306
-
307
- // src/shared/client/script-loader.ts
308
- async function loadScripts(scripts, resolveClientUrl) {
309
- await Promise.all(
310
- scripts.map((script) => {
311
- return new Promise((resolve, reject) => {
312
- const newSrc = new URL(
313
- // remove the remote component bundle name identifier from the script src
314
- script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
315
- location.origin
316
- ).href;
317
- const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
318
- const newScript = document.createElement("script");
319
- newScript.onload = () => resolve();
320
- newScript.onerror = () => {
321
- const isProxied = isProxiedUrl(resolvedSrc);
322
- if (isProxied) {
323
- reject(
324
- new RemoteComponentsError(
325
- `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}`
326
- )
327
- );
328
- } else {
329
- warnCrossOriginFetchError("ScriptLoader", newSrc);
330
- reject(
331
- new RemoteComponentsError(
332
- `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
333
- )
334
- );
335
- }
336
- };
337
- newScript.src = resolvedSrc;
338
- newScript.async = true;
339
- document.head.appendChild(newScript);
340
- });
341
- })
342
- );
343
- }
344
-
345
- // src/shared/utils/index.ts
346
- function escapeString(str) {
347
- return str.replace(/[^a-z0-9]/g, "_");
348
- }
349
-
350
- // src/shared/client/const.ts
351
- var DEFAULT_ROUTE = "/";
352
- var RUNTIME_WEBPACK = "webpack";
353
- var RUNTIME_TURBOPACK = "turbopack";
354
- var RUNTIME_SCRIPT = "script";
355
- var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
356
- function getBundleKey(bundle) {
357
- return escapeString(bundle);
358
- }
359
-
360
- // src/shared/client/turbopack-patterns.ts
361
- var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
362
- var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|e)\.A\((?<sharedModuleId>[0-9]+)\)/;
363
- var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
364
- var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
365
- var ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb>parentImport|t)=>Promise\.all\(\["[^"]+"\]\.map\((?<mapCb>chunk|t)=>\k<ctx>\.l\(\k<mapCb>\)\)\)\.then\(\(\)=>\k<vCb>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
366
- var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
367
-
368
- // src/shared/client/chunk-loader.ts
369
- function createChunkLoader(runtime, resolveClientUrl) {
370
- return function __turbopack_chunk_load__(chunkId, scriptBundle) {
371
- logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
372
- const self = globalThis;
373
- const {
374
- bundle,
375
- id: path,
376
- prefix
377
- } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {
378
- bundle: scriptBundle ?? "",
379
- id: chunkId
380
- };
381
- logDebug(
382
- "ChunkLoader",
383
- `Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
384
- );
385
- const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
386
- logDebug("ChunkLoader", `Remote runtime: "${remoteRuntime}"`);
387
- if (remoteRuntime === RUNTIME_WEBPACK) {
388
- logDebug("ChunkLoader", "Skipping chunk load - webpack runtime detected");
389
- return Promise.resolve(void 0);
390
- }
391
- const url = new URL(
392
- path ? `${prefix ?? ""}${path}`.replace(
393
- /(?<char>[^:])(?<double>\/\/)/g,
394
- "$1/"
395
- ) : "/",
396
- self.__remote_bundle_url__?.[bundle ?? "default"] ?? new URL(location.origin)
397
- ).href;
398
- if (url.endsWith(".css")) {
399
- logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
400
- return;
401
- }
402
- if (!self.__remote_components_turbopack_chunk_loader_promise__) {
403
- self.__remote_components_turbopack_chunk_loader_promise__ = {};
404
- }
405
- if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
406
- logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
407
- return self.__remote_components_turbopack_chunk_loader_promise__[url];
408
- }
409
- const resolvedUrl = resolveClientUrl?.(url) ?? url;
410
- logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
411
- self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
412
- fetch(resolvedUrl).then((res) => res.text()).then((code) => {
413
- const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
414
- if (hasTurbopack) {
415
- return handleTurbopackChunk(code, bundle ?? "", url);
416
- }
417
- logDebug(
418
- "ChunkLoader",
419
- `Chunk does not contain globalThis.TURBOPACK or self.TURBOPACK: "${url}"`
420
- );
421
- logDebug(
422
- "ChunkLoader",
423
- `First 500 chars of chunk: ${code.slice(0, 500)}`
424
- );
425
- }).then(resolve).catch((error) => {
426
- const isProxied = isProxiedUrl(resolvedUrl);
427
- if (isProxied) {
428
- reject(
429
- new RemoteComponentsError(
430
- `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}`
431
- )
432
- );
433
- } else {
434
- warnCrossOriginFetchError("ChunkLoader", url);
435
- reject(error);
436
- }
437
- });
438
- });
439
- return self.__remote_components_turbopack_chunk_loader_promise__[url];
440
- };
441
- }
442
- async function handleTurbopackChunk(code, bundle, url) {
443
- logDebug(
444
- "ChunkLoader",
445
- `Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
446
- );
447
- if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
448
- logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
449
- const preloadLinks = document.querySelectorAll(
450
- `link[rel="preload"][href="${new URL(url).pathname}"]`
451
- );
452
- preloadLinks.forEach((preloadLink) => preloadLink.remove());
453
- return;
454
- }
455
- const self = globalThis;
456
- const bundleKey = getBundleKey(bundle);
457
- logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
458
- const transformedCode = code.replace(
459
- /globalThis\[\s*["']TURBOPACK["']\s*\]/g,
460
- `globalThis["TURBOPACK_${bundleKey}"]`
461
- ).replace(
462
- /self\[\s*["']TURBOPACK["']\s*\]/g,
463
- `self["TURBOPACK_${bundleKey}"]`
464
- ).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${bundleKey}`).replace(
465
- /TURBOPACK_WORKER_LOCATION/g,
466
- `TURBOPACK_WORKER_LOCATION_${bundleKey}`
467
- ).replace(
468
- /TURBOPACK_NEXT_CHUNK_URLS/g,
469
- `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`
470
- ).replace(
471
- /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
472
- `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`
473
- ).replace(/__next_require__/g, `__${bundleKey}_next_require__`).replace(
474
- /\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
475
- `//# sourceMappingURL=${new URL(
476
- ".",
477
- new URL(
478
- url,
479
- self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin)
480
- )
481
- ).href}$1$2.js.map`
482
- );
483
- if (!self[`TURBOPACK_${bundleKey}`]) {
484
- const chunkData = [];
485
- const turbopackObject = {
486
- push: (item) => {
487
- logDebug(
488
- "ChunkLoader",
489
- `TURBOPACK_${bundleKey}.push() called with item type: ${Array.isArray(item) ? "array" : typeof item}`
490
- );
491
- if (Array.isArray(item)) {
492
- chunkData.push(item);
493
- logDebug(
494
- "ChunkLoader",
495
- `TURBOPACK_${bundleKey} now has ${chunkData.length} chunks`
496
- );
497
- } else {
498
- chunkData.push([item]);
499
- }
500
- return chunkData.length;
501
- },
502
- // Store chunks for later access
503
- __chunks__: chunkData
504
- };
505
- self[`TURBOPACK_${bundleKey}`] = turbopackObject;
506
- }
507
- logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
508
- await new Promise((scriptResolve, scriptReject) => {
509
- const blob = new Blob([transformedCode], {
510
- type: "application/javascript; charset=UTF-8"
511
- });
512
- const scriptUrl = URL.createObjectURL(blob);
513
- const script = document.createElement("script");
514
- script.setAttribute("data-turbopack-src", url);
515
- script.src = scriptUrl;
516
- script.async = true;
517
- script.onload = () => {
518
- URL.revokeObjectURL(scriptUrl);
519
- logDebug(
520
- "ChunkLoader",
521
- `Script loaded successfully for bundle "${bundle}"`
522
- );
523
- const turbopackBundle = self[`TURBOPACK_${bundleKey}`];
524
- logDebug(
525
- "ChunkLoader",
526
- `TURBOPACK_${bundleKey} type: ${typeof turbopackBundle}, isArray: ${Array.isArray(turbopackBundle)}, keys: ${turbopackBundle ? Object.keys(turbopackBundle).slice(0, 10).join(", ") : "none"}`
527
- );
528
- if (turbopackBundle && typeof turbopackBundle === "object") {
529
- logDebug(
530
- "ChunkLoader",
531
- `TURBOPACK_${bundleKey} length/size: ${Array.isArray(turbopackBundle) ? turbopackBundle.length : Object.keys(turbopackBundle).length}`
532
- );
533
- }
534
- scriptResolve(void 0);
535
- script.remove();
536
- };
537
- script.onerror = () => {
538
- URL.revokeObjectURL(scriptUrl);
539
- scriptReject(
540
- new RemoteComponentsError(
541
- `Failed to load <script src="${script.src}"> for Remote Component. Check the URL is correct.`
542
- )
543
- );
544
- script.remove();
545
- };
546
- document.head.appendChild(script);
547
- });
548
- const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`];
549
- logDebug(
550
- "ChunkLoader",
551
- `Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
552
- );
553
- const loadChunkLists = [];
554
- while (chunkLists?.length) {
555
- const { chunks } = chunkLists.shift() ?? { chunks: [] };
556
- if (chunks.length > 0) {
557
- logDebug(
558
- "ChunkLoader",
559
- `Loading ${chunks.length} additional chunks for bundle "${bundle}": [${chunks.join(", ")}]`
560
- );
561
- chunks.forEach((id) => {
562
- const chunkLoadResult = self.__webpack_chunk_load__?.(
563
- `[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
564
- );
565
- if (chunkLoadResult) {
566
- loadChunkLists.push(chunkLoadResult);
567
- }
568
- });
569
- }
570
- }
571
- if (loadChunkLists.length > 0) {
572
- logDebug(
573
- "ChunkLoader",
574
- `Waiting for ${loadChunkLists.length} additional chunks to load`
575
- );
576
- await Promise.all(loadChunkLists);
577
- }
578
- }
579
-
580
- // src/shared/client/turbopack-module.ts
581
- function handleTurbopackModule(bundle, moduleId, id) {
582
- const self = globalThis;
583
- const bundleKey = getBundleKey(bundle);
584
- const raw = self[`TURBOPACK_${bundleKey}`];
585
- let modules;
586
- if (raw && typeof raw === "object" && "__chunks__" in raw) {
587
- modules = raw.__chunks__.flat();
588
- } else if (Array.isArray(raw)) {
589
- modules = raw.flat();
590
- } else {
591
- modules = raw;
592
- }
593
- if (!self.__remote_components_turbopack_modules__) {
594
- self.__remote_components_turbopack_modules__ = {};
595
- }
596
- if (!self.__remote_components_turbopack_modules__[bundle]) {
597
- self.__remote_components_turbopack_modules__[bundle] = {};
598
- }
599
- if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {
600
- return self.__remote_components_turbopack_modules__[bundle][moduleId];
601
- }
602
- if (!modules) {
603
- logError("TurbopackModule", `TURBOPACK_${bundleKey} is undefined`);
604
- }
605
- const moduleInit = findModuleInit(modules, moduleId);
606
- const exports = {};
607
- const moduleExports = { exports };
608
- if (typeof moduleInit !== "function") {
609
- throw new Error(
610
- `Module ${id} not found in bundle ${bundle} with id ${moduleId}`
611
- );
612
- }
613
- self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
614
- if (!self.__remote_components_turbopack_global__) {
615
- self.__remote_components_turbopack_global__ = {};
616
- }
617
- if (!self.__remote_components_turbopack_global__[bundle]) {
618
- self.__remote_components_turbopack_global__[bundle] = {};
619
- }
620
- moduleInit(
621
- createTurbopackContext(
622
- bundle,
623
- exports,
624
- moduleExports,
625
- modules,
626
- moduleInit,
627
- id,
628
- self
629
- ),
630
- moduleExports,
631
- exports
632
- );
633
- if (self.__remote_components_turbopack_modules__[bundle][moduleId] !== moduleExports.exports) {
634
- self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
635
- }
636
- return moduleExports.exports;
637
- }
638
- function findModuleInit(modules, moduleId) {
639
- if (!modules || typeof modules !== "object")
640
- return;
641
- if (!Array.isArray(modules)) {
642
- const key = moduleId in modules ? moduleId : Object.keys(modules).find((k) => k.startsWith(moduleId));
643
- return key !== void 0 ? modules[key] : void 0;
644
- }
645
- const flat = modules.flat();
646
- let idx = flat.findIndex((e) => String(e) === String(moduleId));
647
- if (idx < 0) {
648
- idx = flat.findIndex(
649
- (e) => typeof e === "string" && e.startsWith(moduleId)
650
- );
651
- }
652
- if (idx >= 0) {
653
- return flat.slice(idx + 1).find((e) => typeof e === "function");
654
- }
655
- return flat.find(
656
- (e) => Boolean(e && typeof e === "object" && moduleId in e)
657
- )?.[moduleId];
658
- }
659
- function createTurbopackContext(bundle, exports, moduleExports, modules, moduleInit, id, self) {
660
- return {
661
- // HMR not implemented for Remote Components
662
- k: {
663
- register() {
664
- },
665
- registerExports() {
666
- },
667
- signature() {
668
- return (fn) => fn;
669
- }
670
- },
671
- // ESM exports setup
672
- s(bindings, esmId) {
673
- let mod = exports;
674
- if (typeof esmId === "string" || typeof esmId === "number") {
675
- if (!self.__remote_components_turbopack_modules__) {
676
- self.__remote_components_turbopack_modules__ = {};
677
- }
678
- if (!self.__remote_components_turbopack_modules__[bundle]) {
679
- self.__remote_components_turbopack_modules__[bundle] = {};
680
- }
681
- if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {
682
- self.__remote_components_turbopack_modules__[bundle][esmId] = {};
683
- }
684
- mod = self.__remote_components_turbopack_modules__[bundle][esmId];
685
- }
686
- Object.defineProperty(mod, "__esModule", { value: true });
687
- if (Array.isArray(bindings)) {
688
- let i = 0;
689
- while (i < bindings.length) {
690
- const propName = bindings[i++];
691
- const tagOrFunc = bindings[i++];
692
- if (typeof tagOrFunc === "number") {
693
- Object.defineProperty(mod, propName, {
694
- value: bindings[i++],
695
- enumerable: true,
696
- writable: false
697
- });
698
- } else {
699
- const getterFn = tagOrFunc;
700
- if (typeof bindings[i] === "function") {
701
- const setterFn = bindings[i++];
702
- Object.defineProperty(mod, propName, {
703
- get: getterFn,
704
- set: setterFn,
705
- enumerable: true
706
- });
707
- } else {
708
- Object.defineProperty(mod, propName, {
709
- get: getterFn,
710
- enumerable: true
711
- });
712
- }
713
- }
714
- }
715
- }
716
- },
717
- // import
718
- i(importId) {
719
- let mod;
720
- if (typeof importId === "string") {
721
- const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
722
- importId
723
- )?.groups ?? {};
724
- const normalizedId = importId.replace(
725
- /\s+<export(?<specifier>.*)>$/,
726
- ""
727
- );
728
- mod = self.__webpack_require__?.(`[${bundle}] ${normalizedId}`);
729
- if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
730
- if (exportSource === "*") {
731
- mod[exportName] = mod;
732
- } else {
733
- mod[exportName] = mod[exportSource];
734
- }
735
- }
736
- } else {
737
- mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
738
- }
739
- if (typeof mod !== "object" || mod === null) {
740
- mod = { default: mod };
741
- } else if (!("default" in mod) && mod.toString() !== "[object Module]") {
742
- try {
743
- mod.default = mod;
744
- } catch {
745
- }
746
- }
747
- return mod;
748
- },
749
- // require
750
- r(requireId) {
751
- return self.__webpack_require__?.(`[${bundle}] ${requireId}`);
752
- },
753
- // value exports
754
- v(value) {
755
- if (typeof value === "function") {
756
- exports.default = value((vid) => {
757
- return self.__webpack_require__?.(`[${bundle}] ${vid}`);
758
- });
759
- } else {
760
- moduleExports.exports = value;
761
- }
762
- },
763
- // async module initializer
764
- async a(mod) {
765
- let result;
766
- await mod(
767
- () => {
768
- },
769
- (value) => result = value
770
- );
771
- exports.default = result;
772
- },
773
- // async module loader
774
- async A(Aid) {
775
- const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`);
776
- return mod.default(
777
- (parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
778
- );
779
- },
780
- // dynamic import tracking — no-op for remote components
781
- j() {
782
- },
783
- // chunk loader
784
- l(url) {
785
- const flatModules = Array.isArray(modules) ? modules : [];
786
- const moduleInitIndex = flatModules.indexOf(moduleInit);
787
- if (moduleInitIndex !== -1) {
788
- const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
789
- if (scriptIndex !== -1) {
790
- const script = flatModules[scriptIndex];
791
- const scriptSrc = script.getAttribute("data-turbopack-src") || "";
792
- const nextIndex = scriptSrc.indexOf("/_next");
793
- const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
794
- const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
795
- return self.__webpack_chunk_load__?.(bundleUrl, bundle);
796
- }
797
- }
798
- throw new Error(
799
- `Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
800
- );
801
- },
802
- // global object for this bundle
803
- g: self.__remote_components_turbopack_global__?.[bundle],
804
- m: moduleExports,
805
- e: exports
806
- };
807
- }
808
-
809
- // src/shared/client/shared-modules.ts
810
- async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
811
- const self = globalThis;
812
- self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
813
- if (!self.__remote_shared_modules__[bundle]) {
814
- self.__remote_shared_modules__[bundle] = {};
815
- }
816
- const bundleKey = getBundleKey(bundle);
817
- let modules = self[`TURBOPACK_${bundleKey}`];
818
- if (modules && typeof modules === "object" && "__chunks__" in modules) {
819
- const chunks = modules.__chunks__;
820
- modules = chunks.flat();
821
- }
822
- let sharedModuleInitializer = null;
823
- if (modules) {
824
- const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
825
- const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
826
- if (typeof idOrFunc !== "function") {
827
- return false;
828
- }
829
- const funcCode = idOrFunc.toString();
830
- return REMOTE_SHARED_MARKER_RE.test(funcCode);
831
- });
832
- if (sharedModuleInitializerIndex > 0) {
833
- const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
834
- const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
835
- const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
836
- if (sharedModuleId) {
837
- const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
838
- bundle,
839
- sharedModuleId,
840
- `[${bundle}] ${sharedModuleInitializerId}`
841
- );
842
- sharedModuleInitializer = sharedModuleInitializerInstance;
843
- }
844
- }
845
- if (sharedModuleInitializer) {
846
- const { shared } = await sharedModuleInitializer;
847
- const sharedModuleIds = extractSharedModuleIds(
848
- shared,
849
- bundleKey,
850
- self
851
- );
852
- return Promise.all(
853
- Object.entries(sharedModuleIds).map(async ([id, module]) => {
854
- if (self.__remote_shared_modules__?.[bundle]) {
855
- if (hostShared[module]) {
856
- self.__remote_shared_modules__[bundle][id] = await hostShared[module](bundle);
857
- } else {
858
- logError(
859
- "SharedModules",
860
- `Host shared module "${module}" not found for ID ${id}`
861
- );
862
- }
863
- }
864
- })
865
- );
866
- }
867
- }
868
- return Promise.all(
869
- Object.entries(remoteShared).map(async ([id, module]) => {
870
- if (self.__remote_shared_modules__?.[bundle]) {
871
- if (hostShared[module]) {
872
- const normalizedId = id.replace("[app-ssr]", "[app-client]");
873
- self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module](bundle);
874
- } else {
875
- logError(
876
- "SharedModules",
877
- `Shared module "${module}" not found for "${bundle}"`
878
- );
879
- }
880
- }
881
- })
882
- );
883
- }
884
- function extractSharedModuleIds(shared, bundleKey, self) {
885
- return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
886
- const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
887
- if (asyncSharedModuleId) {
888
- const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
889
- let asyncSharedModule;
890
- let turbopackModules = self[`TURBOPACK_${bundleKey}`];
891
- if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
892
- const chunks = turbopackModules.__chunks__;
893
- turbopackModules = chunks.flat();
894
- }
895
- const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
896
- key2,
897
- value2
898
- ]) : [];
899
- const asyncSharedModuleIdIndex = newAllModules.indexOf(
900
- asyncSharedModuleIdNumber
901
- );
902
- if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
903
- asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
904
- }
905
- if (asyncSharedModule) {
906
- const asyncSharedModuleCode = asyncSharedModule.toString();
907
- const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
908
- acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
909
- "__remote_shared_module_",
910
- ""
911
- );
912
- }
913
- }
914
- return acc;
915
- }, {});
916
- }
917
- function getSharedModule(bundle, id) {
918
- const self = globalThis;
919
- for (const [key, value] of Object.entries(
920
- self.__remote_shared_modules__?.[bundle] ?? {}
921
- )) {
922
- if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
923
- return value;
924
- }
925
- }
926
- return null;
927
- }
928
-
929
- // src/shared/client/webpack-adapter.ts
930
- async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
931
- const self = globalThis;
932
- if (!self.__remote_bundle_url__) {
933
- self.__remote_bundle_url__ = {};
934
- }
935
- self.__remote_bundle_url__[bundle ?? "default"] = url;
936
- self.__webpack_get_script_filename__ = () => null;
937
- if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
938
- if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
939
- self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
940
- self.__original_webpack_require__ = self.__webpack_require__;
941
- }
942
- self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
943
- self.__webpack_require__ = createModuleRequire(runtime);
944
- self.__webpack_require_type__ = runtime;
945
- if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
946
- const remoteBundle = bundle ?? "default";
947
- self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
948
- self.__remote_webpack_require__[remoteBundle].type = "turbopack";
949
- }
950
- }
951
- if (runtime === RUNTIME_TURBOPACK) {
952
- await Promise.all(
953
- scripts.map((script) => {
954
- if (script.src) {
955
- return self.__webpack_chunk_load__?.(script.src, bundle);
956
- }
957
- return Promise.resolve(void 0);
958
- })
959
- );
960
- }
961
- const coreShared = {
962
- react: async () => (await import("react")).default,
963
- "react-dom": async () => (await import("react-dom")).default,
964
- "react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
965
- "react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
966
- "react-dom/client": async () => (await import("react-dom/client")).default,
967
- ...shared
968
- };
969
- await initializeSharedModules(
970
- bundle ?? "default",
971
- // include all core modules as shared
972
- coreShared,
973
- remoteShared
974
- );
975
- }
976
- function createModuleRequire(runtime) {
977
- return (id) => {
978
- const self = globalThis;
979
- const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
980
- bundle: "default",
981
- id
982
- };
983
- const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
984
- logDebug("WebpackAdapter", `remoteRuntime: "${remoteRuntime}"`);
985
- try {
986
- if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
987
- return self.__remote_webpack_require__?.[bundle]?.(moduleId);
988
- }
989
- const sharedModuleId = moduleId ?? id;
990
- const sharedModule = getSharedModule(bundle ?? "default", sharedModuleId);
991
- if (sharedModule) {
992
- return sharedModule;
993
- }
994
- if (bundle && moduleId) {
995
- return handleTurbopackModule(bundle, moduleId, id);
996
- }
997
- throw new Error(`Module "${id}" not found.`);
998
- } catch (requireError) {
999
- logWarn(
1000
- "WebpackAdapter",
1001
- `Module require failed: ${String(requireError)}`
1002
- );
1003
- if (typeof self.__original_webpack_require__ !== "function") {
1004
- throw new RemoteComponentsError(
1005
- `Module "${id}" not found in remote component bundle "${bundle}".`,
1006
- {
1007
- cause: requireError instanceof Error ? requireError : void 0
1008
- }
1009
- );
1010
- }
1011
- try {
1012
- logDebug("WebpackAdapter", "Falling back to original webpack require");
1013
- return self.__original_webpack_require__(id);
1014
- } catch (originalError) {
1015
- throw new RemoteComponentsError(
1016
- `Module "${id}" not found in remote component bundle "${bundle}".`,
1017
- { cause: originalError instanceof Error ? originalError : void 0 }
1018
- );
1019
- }
1020
- }
1021
- };
1022
- }
1023
-
1024
- // src/shared/client/component-loader.ts
1025
- async function loadRemoteComponent({
1026
- url,
1027
- name,
1028
- rscName,
1029
- bundle,
1030
- route = "/",
1031
- runtime = "webpack",
1032
- data,
1033
- nextData,
1034
- scripts = [],
1035
- shared = Promise.resolve({}),
1036
- remoteShared = {},
1037
- container,
1038
- resolveClientUrl
1039
- }) {
1040
- try {
1041
- if (runtime === "webpack") {
1042
- const self = globalThis;
1043
- if (!self.__DISABLE_WEBPACK_EXEC__) {
1044
- self.__DISABLE_WEBPACK_EXEC__ = {};
1045
- }
1046
- self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
1047
- await loadScripts(scripts, resolveClientUrl);
1048
- }
1049
- const hostShared = await shared;
1050
- logDebug(
1051
- "ComponentLoader",
1052
- `loadRemoteComponent: bundle="${bundle}", name="${name}"`
1053
- );
1054
- logDebug(
1055
- "ComponentLoader",
1056
- `Host shared modules available: ${Object.keys(hostShared)}`
1057
- );
1058
- logDebug(
1059
- "ComponentLoader",
1060
- `Remote shared modules requested: ${JSON.stringify(remoteShared)}`
1061
- );
1062
- await setupWebpackRuntime(
1063
- runtime,
1064
- scripts,
1065
- url,
1066
- bundle,
1067
- hostShared,
1068
- remoteShared,
1069
- resolveClientUrl
1070
- );
1071
- if (bundle) {
1072
- const resolve = {
1073
- "/react/index.js": React,
1074
- "/react/jsx-dev-runtime.js": JSXDevRuntime,
1075
- "/react/jsx-runtime.js": JSXRuntime,
1076
- "/react-dom/index.js": ReactDOM,
1077
- "/react-dom/client.js": ReactDOMClient,
1078
- ...Object.entries(remoteShared).reduce(
1079
- (acc, [key, value]) => {
1080
- if (typeof hostShared[value] !== "undefined") {
1081
- acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
1082
- } else {
1083
- logDebug(
1084
- "ComponentLoader",
1085
- `Remote requests "${value}" but host doesn't provide it`
1086
- );
1087
- }
1088
- return acc;
1089
- },
1090
- {}
1091
- )
1092
- };
1093
- await Promise.all(
1094
- Object.entries(resolve).map(async ([key, value]) => {
1095
- if (typeof value === "function") {
1096
- resolve[key] = await value(bundle);
1097
- }
1098
- return Promise.resolve(value);
1099
- })
1100
- );
1101
- applySharedModules(bundle, resolve);
1102
- } else {
1103
- logWarn(
1104
- "ComponentLoader",
1105
- "No bundle specified, skipping shared module setup"
1106
- );
1107
- }
1108
- if (data.length > 0) {
1109
- return await loadRSCComponent(rscName ?? name, data);
1110
- } else if (nextData) {
1111
- return loadNextPagesComponent(bundle, route, nextData, name, container);
1112
- }
1113
- return loadRSCComponent(rscName ?? name, [`0:[null]
1114
- `]);
1115
- } catch (error) {
1116
- return {
1117
- component: null,
1118
- error: new RemoteComponentsError(
1119
- `Failed to load remote component "${name}".`,
1120
- {
1121
- cause: error instanceof Error ? error : new Error(String(error))
1122
- }
1123
- )
1124
- };
1125
- }
1126
- }
1127
- async function loadRSCComponent(rscName, data) {
1128
- let createFromReadableStream;
1129
- try {
1130
- const { createFromReadableStream: _createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
1131
- createFromReadableStream = _createFromReadableStream;
1132
- } catch {
1133
- const {
1134
- default: { createFromReadableStream: _createFromReadableStream }
1135
- } = await import("react-server-dom-webpack/client.browser");
1136
- createFromReadableStream = _createFromReadableStream;
1137
- }
1138
- if (typeof createFromReadableStream !== "function") {
1139
- throw new RemoteComponentsError(
1140
- 'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
1141
- );
1142
- }
1143
- const stream = createRSCStream(rscName, data);
1144
- const component = createFromReadableStream(stream);
1145
- return { component };
1146
- }
1147
- function loadNextPagesComponent(bundle, route, nextData, name, container) {
1148
- const { Component, App } = nextClientPagesLoader(bundle, route, container);
1149
- if (!Component) {
1150
- throw new RemoteComponentsError(
1151
- `Remote Component "${name}" is trying to load the component for route "${route}" but it is not available.`
1152
- );
1153
- }
1154
- const component = App ? React.createElement(App, { Component, ...nextData.props }) : React.createElement(Component, nextData.props);
1155
- return { component };
1156
- }
1157
-
1158
- // src/shared/client/proxy-through-host.ts
1159
- var proxyClientRequestsThroughHost = (remoteSrc, url) => {
1160
- if (typeof location === "undefined") {
1161
- return void 0;
1162
- }
1163
- const remoteOrigin = new URL(remoteSrc, location.href).origin;
1164
- if (remoteOrigin === location.origin) {
1165
- return void 0;
1166
- }
1167
- try {
1168
- const parsed = new URL(url, location.href);
1169
- if (parsed.origin === remoteOrigin) {
1170
- return generateProtectedRcFallbackSrc(url);
1171
- }
1172
- } catch {
1173
- }
1174
- return void 0;
1175
- };
1176
-
1177
- // src/shared/client/set-attributes-from-props.ts
1178
- var DOMAttributeNames = {
1179
- acceptCharset: "accept-charset",
1180
- className: "class",
1181
- htmlFor: "for",
1182
- httpEquiv: "http-equiv",
1183
- noModule: "noModule"
1184
- };
1185
- var ignoreProps = [
1186
- "onLoad",
1187
- "onReady",
1188
- "dangerouslySetInnerHTML",
1189
- "children",
1190
- "onError",
1191
- "strategy",
1192
- "stylesheets"
1193
- ];
1194
- function isBooleanScriptAttribute(attr) {
1195
- return ["async", "defer", "noModule"].includes(attr);
1196
- }
1197
- function setAttributesFromProps(el, props) {
1198
- for (const [p, value] of Object.entries(props)) {
1199
- if (!Object.hasOwn(props, p))
1200
- continue;
1201
- if (ignoreProps.includes(p))
1202
- continue;
1203
- if (value === void 0) {
1204
- continue;
1205
- }
1206
- const attr = DOMAttributeNames[p] || p.toLowerCase();
1207
- if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
1208
- el[attr] = Boolean(value);
1209
- } else {
1210
- el.setAttribute(attr, String(value));
1211
- }
1212
- if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
1213
- el.setAttribute(attr, "");
1214
- el.removeAttribute(attr);
1215
- }
1216
- }
1217
- }
1218
-
1219
- // src/shared/client/static-loader.ts
1220
- async function importViaCallback(absoluteSrc, resolveClientUrl) {
1221
- const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
1222
- const fetchUrl = new URL(resolvedUrl, location.href).href;
1223
- const response = await fetch(fetchUrl);
1224
- if (!response.ok)
1225
- throw new Error(`Proxied fetch failed: ${response.status}`);
1226
- const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
1227
- /\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
1228
- (_, keyword, quote, relativePath) => {
1229
- const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
1230
- const resolvedImportUrl = new URL(
1231
- resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
1232
- location.href
1233
- ).href;
1234
- return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
1235
- }
1236
- );
1237
- const moduleBlobUrl = URL.createObjectURL(
1238
- new Blob([content], { type: "text/javascript" })
1239
- );
1240
- const wrapperContent = [
1241
- `import*as m from${JSON.stringify(moduleBlobUrl)};`,
1242
- `globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
1243
- `globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
1244
- ].join("");
1245
- const wrapperBlobUrl = URL.createObjectURL(
1246
- new Blob([wrapperContent], { type: "text/javascript" })
1247
- );
1248
- const scriptEl = document.createElement("script");
1249
- scriptEl.type = "module";
1250
- scriptEl.src = wrapperBlobUrl;
1251
- try {
1252
- await new Promise((resolve, reject) => {
1253
- scriptEl.onload = () => resolve();
1254
- scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
1255
- document.head.appendChild(scriptEl);
1256
- });
1257
- } finally {
1258
- scriptEl.remove();
1259
- URL.revokeObjectURL(moduleBlobUrl);
1260
- URL.revokeObjectURL(wrapperBlobUrl);
1261
- }
1262
- const registry = globalThis.__rc_module_registry__;
1263
- const mod = registry?.[absoluteSrc] ?? {};
1264
- if (registry)
1265
- delete registry[absoluteSrc];
1266
- return mod;
1267
- }
1268
- async function importDirectly(absoluteSrc) {
1269
- try {
1270
- return await import(
1271
- /* @vite-ignore */
1272
- /* webpackIgnore: true */
1273
- absoluteSrc
1274
- );
1275
- } catch (importError) {
1276
- if (!absoluteSrc.startsWith("blob:")) {
1277
- warnCrossOriginFetchError("StaticLoader", absoluteSrc);
1278
- }
1279
- throw importError;
1280
- }
1281
- }
1282
- function resolveScriptSrc(script, url) {
1283
- const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
1284
- if (!rawSrc && script.textContent) {
1285
- return URL.createObjectURL(
1286
- new Blob(
1287
- [script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
1288
- { type: "text/javascript" }
1289
- )
1290
- );
1291
- }
1292
- return rawSrc;
1293
- }
1294
- async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1295
- const self = globalThis;
1296
- if (self.__remote_script_entrypoint_mount__?.[url.href]) {
1297
- self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
1298
- }
1299
- if (self.__remote_script_entrypoint_unmount__?.[url.href]) {
1300
- self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
1301
- }
1302
- const mountUnmountSets = await Promise.all(
1303
- scripts.map(async (script) => {
1304
- try {
1305
- const src = resolveScriptSrc(script, url);
1306
- const absoluteSrc = new URL(src, url).href;
1307
- const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
1308
- if (src.startsWith("blob:")) {
1309
- URL.revokeObjectURL(src);
1310
- }
1311
- if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
1312
- if (!self.__remote_script_entrypoint_mount__) {
1313
- self.__remote_script_entrypoint_mount__ = {};
1314
- }
1315
- if (!self.__remote_script_entrypoint_mount__[url.href]) {
1316
- self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
1317
- }
1318
- self.__remote_script_entrypoint_mount__[url.href]?.add(
1319
- mod.mount || mod.default?.mount || (() => {
1320
- })
1321
- );
1322
- }
1323
- if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
1324
- if (!self.__remote_script_entrypoint_unmount__) {
1325
- self.__remote_script_entrypoint_unmount__ = {};
1326
- }
1327
- if (!self.__remote_script_entrypoint_unmount__[url.href]) {
1328
- self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
1329
- }
1330
- self.__remote_script_entrypoint_unmount__[url.href]?.add(
1331
- mod.unmount || mod.default?.unmount || (() => {
1332
- })
1333
- );
1334
- }
1335
- return {
1336
- mount: mod.mount || mod.default?.mount,
1337
- unmount: mod.unmount || mod.default?.unmount
1338
- };
1339
- } catch (e) {
1340
- logError(
1341
- "StaticLoader",
1342
- `Error loading remote component script from "${script.src || url.href}".`,
1343
- e
1344
- );
1345
- return {
1346
- mount: void 0,
1347
- unmount: void 0
1348
- };
1349
- }
1350
- })
1351
- );
1352
- return mountUnmountSets.reduce(
1353
- (acc, { mount, unmount }) => {
1354
- if (typeof mount === "function") {
1355
- acc.mount.add(mount);
1356
- }
1357
- if (typeof unmount === "function") {
1358
- acc.unmount.add(unmount);
1359
- }
1360
- return acc;
1361
- },
1362
- {
1363
- mount: /* @__PURE__ */ new Set(),
1364
- unmount: /* @__PURE__ */ new Set()
1365
- }
1366
- );
1367
- }
1368
- export {
1369
- DEFAULT_ROUTE,
1370
- REMOTE_COMPONENT_REGEX,
1371
- RUNTIME_SCRIPT,
1372
- RUNTIME_TURBOPACK,
1373
- RUNTIME_WEBPACK,
1374
- RemoteComponentsError,
1375
- createRSCStream,
1376
- fixPayload,
1377
- getBundleKey,
1378
- loadRemoteComponent,
1379
- loadScripts,
1380
- loadStaticRemoteComponent,
1381
- proxyClientRequestsThroughHost,
1382
- setAttributesFromProps,
1383
- setupWebpackRuntime
1384
- };
1385
- //# sourceMappingURL=remote-component.js.map