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
@@ -1,87 +1,49 @@
1
1
  "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
2
11
 
3
- // src/next/host/client/index.tsx
4
- import * as Image from "next/image";
5
-
6
- // src/react/index.tsx
7
- import {
8
- startTransition,
9
- useEffect,
10
- useId,
11
- useLayoutEffect as useLayoutEffect2,
12
- useMemo as useMemo2,
13
- useRef as useRef2,
14
- useState as useState2
15
- } from "react";
16
- import { createPortal } from "react-dom";
12
+ // src/utils/constants.ts
13
+ var RC_PROTECTED_REMOTE_FETCH_PATHNAME, MISSING_SHARED_MODULES_MESSAGE, CORS_DOCS_URL;
14
+ var init_constants = __esm({
15
+ "src/utils/constants.ts"() {
16
+ "use strict";
17
+ RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
18
+ MISSING_SHARED_MODULES_MESSAGE = "Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponentsConfig` on both host and remote?";
19
+ CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
20
+ }
21
+ });
17
22
 
18
- // src/shared/client/apply-origin.ts
19
- var tagNames = [
20
- "img",
21
- "source",
22
- "video",
23
- "audio",
24
- "track",
25
- "iframe",
26
- "embed",
27
- "script",
28
- "link"
29
- ];
30
- function applyOriginToNodes(doc, url, resolveClientUrl) {
31
- if (url.origin !== location.origin) {
32
- const nodes = doc.querySelectorAll(
33
- tagNames.map(
34
- (type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
35
- ).join(",")
36
- );
37
- nodes.forEach((node) => {
38
- if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
39
- const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
40
- const isScript = node.tagName.toLowerCase() === "script";
41
- node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
42
- }
43
- if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
44
- const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
45
- node.setAttribute(
46
- "href",
47
- resolveClientUrl?.(absoluteHref) ?? absoluteHref
48
- );
49
- }
50
- if (node.hasAttribute("srcset")) {
51
- const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
52
- const [urlPart, descriptor] = entry.trim().split(/\s+/);
53
- if (!urlPart)
54
- return entry;
55
- const absoluteUrl = new URL(urlPart, url).href;
56
- const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
57
- return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
58
- }).join(", ");
59
- if (srcSet) {
60
- node.setAttribute("srcset", srcSet);
61
- }
62
- }
63
- if (node.hasAttribute("imagesrcset")) {
64
- const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
65
- const [urlPart, descriptor] = entry.trim().split(/\s+/);
66
- if (!urlPart)
67
- return entry;
68
- const absoluteUrl = new URL(urlPart, url).href;
69
- const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
70
- return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
71
- }).join(", ");
72
- if (srcSet) {
73
- node.setAttribute("imagesrcset", srcSet);
74
- }
75
- }
76
- });
23
+ // src/host/defaults/app.ts
24
+ var app_exports = {};
25
+ __export(app_exports, {
26
+ shared: () => shared
27
+ });
28
+ var shared;
29
+ var init_app = __esm({
30
+ "src/host/defaults/app.ts"() {
31
+ "use strict";
32
+ init_constants();
33
+ shared = {
34
+ __remote_components_missing_shared__: () => Promise.reject(new Error(MISSING_SHARED_MODULES_MESSAGE))
35
+ };
77
36
  }
78
- }
37
+ });
38
+
39
+ // src/host/nextjs/app-client-only.tsx
40
+ import * as Image from "next/image";
79
41
 
80
- // src/shared/constants.ts
81
- var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
82
- var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
42
+ // src/utils/logger.ts
43
+ init_constants();
83
44
 
84
- // src/shared/client/protected-rc-fallback.ts
45
+ // src/runtime/url/protected-rc-fallback.ts
46
+ init_constants();
85
47
  function isProxiedUrl(url) {
86
48
  try {
87
49
  return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
@@ -90,7 +52,7 @@ function isProxiedUrl(url) {
90
52
  }
91
53
  }
92
54
 
93
- // src/shared/utils/abort.ts
55
+ // src/utils/abort.ts
94
56
  function isAbortError(error) {
95
57
  if (error instanceof DOMException && error.name === "AbortError") {
96
58
  return true;
@@ -102,7 +64,8 @@ function isAbortError(error) {
102
64
  return false;
103
65
  }
104
66
 
105
- // src/shared/error.ts
67
+ // src/utils/error.ts
68
+ init_constants();
106
69
  var RemoteComponentsError = class extends Error {
107
70
  code = "REMOTE_COMPONENTS_ERROR";
108
71
  constructor(message, options) {
@@ -168,7 +131,7 @@ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
168
131
  The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
169
132
 
170
133
  Proxying requires two pieces:
171
- 1. resolveClientUrl={proxyClientRequestsThroughHost} on <RemoteComponent>
134
+ 1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
172
135
  2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
173
136
 
174
137
  Docs: ${CORS_DOCS_URL}`
@@ -185,123 +148,7 @@ Docs: ${CORS_DOCS_URL}`
185
148
  );
186
149
  }
187
150
 
188
- // src/shared/utils/index.ts
189
- function escapeString(str) {
190
- return str.replace(/[^a-z0-9]/g, "_");
191
- }
192
- var attrToProp = {
193
- fetchpriority: "fetchPriority",
194
- crossorigin: "crossOrigin",
195
- imagesrcset: "imageSrcSet",
196
- imagesizes: "imageSizes",
197
- srcset: "srcSet"
198
- };
199
-
200
- // src/shared/client/const.ts
201
- var DEFAULT_ROUTE = "/";
202
- var RUNTIME_WEBPACK = "webpack";
203
- var RUNTIME_TURBOPACK = "turbopack";
204
- var RUNTIME_SCRIPT = "script";
205
- var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
206
- function getBundleKey(bundle) {
207
- return escapeString(bundle);
208
- }
209
-
210
- // src/shared/client/parse-remote-html.ts
211
- function validateSingleComponent(doc, name, url) {
212
- 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}"]`)) {
213
- throw multipleRemoteComponentsError(url);
214
- }
215
- }
216
- function findComponentElement(doc, name) {
217
- return doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) ?? doc.querySelector("div[data-bundle][data-route]") ?? doc.querySelector("div#__next") ?? doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
218
- }
219
- function parseNextData(doc) {
220
- return JSON.parse(
221
- (doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
222
- );
223
- }
224
- function resolveComponentName(component, nextData, fallbackName) {
225
- const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
226
- const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
227
- return { name, isRemoteComponent };
228
- }
229
- function extractComponentMetadata(component, nextData, name, url) {
230
- return {
231
- name,
232
- bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
233
- route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
234
- runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
235
- };
236
- }
237
- function extractRemoteShared(doc, name, nextData) {
238
- const remoteSharedEl = doc.querySelector(
239
- `#${name}_shared[data-remote-components-shared]`
240
- );
241
- const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
242
- remoteSharedEl?.remove();
243
- return remoteShared;
244
- }
245
- function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
246
- if (!component || !(rsc || nextData || isRemoteComponent)) {
247
- throw new RemoteComponentsError(
248
- `Remote Component not found on ${url}.${name !== "__vercel_remote_component" ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
249
- );
250
- }
251
- }
252
- function extractLinks(doc, component) {
253
- return Array.from(doc.querySelectorAll("link[href]")).filter(
254
- (link) => !component.contains(link)
255
- );
256
- }
257
- function extractScripts(doc, component, isRemoteComponent) {
258
- return Array.from(
259
- (isRemoteComponent ? component : doc).querySelectorAll(
260
- "script[src],script[data-src]"
261
- )
262
- );
263
- }
264
- function parseRemoteComponentDocument(doc, name, url) {
265
- validateSingleComponent(doc, name, url.href);
266
- const component = findComponentElement(doc, name);
267
- const nextData = parseNextData(doc);
268
- const { name: resolvedName, isRemoteComponent } = resolveComponentName(
269
- component,
270
- nextData,
271
- name
272
- );
273
- const rsc = doc.querySelector(`#${resolvedName}_rsc`);
274
- const metadata = extractComponentMetadata(
275
- component,
276
- nextData,
277
- resolvedName,
278
- url
279
- );
280
- const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
281
- validateComponentFound(
282
- component,
283
- rsc,
284
- nextData,
285
- isRemoteComponent,
286
- url.href,
287
- resolvedName
288
- );
289
- const links = extractLinks(doc, component);
290
- const scripts = extractScripts(doc, component, isRemoteComponent);
291
- return {
292
- component,
293
- name: resolvedName,
294
- isRemoteComponent,
295
- metadata,
296
- nextData,
297
- rsc,
298
- remoteShared,
299
- links,
300
- scripts
301
- };
302
- }
303
-
304
- // src/shared/utils/logger.ts
151
+ // src/utils/logger.ts
305
152
  var PREFIX = "remote-components";
306
153
  var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
307
154
  function logDebug(location2, message) {
@@ -327,13 +174,13 @@ function warnCrossOriginFetchError(logLocation, url) {
327
174
  }
328
175
  logWarn(
329
176
  logLocation,
330
- `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}`
177
+ `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}`
331
178
  );
332
179
  } catch {
333
180
  }
334
181
  }
335
182
 
336
- // src/shared/client/polyfill.tsx
183
+ // src/host/shared/polyfill.tsx
337
184
  import { jsx } from "react/jsx-runtime";
338
185
  function applyBundleUrlToSrc(bundle, src) {
339
186
  const self = globalThis;
@@ -353,7 +200,7 @@ function applyBundleUrlToImagePropsSrc(bundle, src) {
353
200
  const propSrc = src;
354
201
  return applyBundleUrlToSrc(bundle, propSrc.src);
355
202
  }
356
- var imageImpl = (bundle) => function RemoteImage({
203
+ var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
357
204
  fill: _fill,
358
205
  loader: _loader,
359
206
  quality: _quality,
@@ -370,6 +217,7 @@ var imageImpl = (bundle) => function RemoteImage({
370
217
  bundle,
371
218
  typeof src === "string" ? src : src.src
372
219
  );
220
+ const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
373
221
  return (
374
222
  // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
375
223
  /* @__PURE__ */ jsx(
@@ -378,16 +226,16 @@ var imageImpl = (bundle) => function RemoteImage({
378
226
  decoding: "async",
379
227
  style: { color: "transparent" },
380
228
  ...props,
381
- src: newSrc,
229
+ src: proxiedSrc,
382
230
  suppressHydrationWarning: true
383
231
  }
384
232
  )
385
233
  );
386
234
  };
387
- function sharedPolyfills(shared) {
235
+ function sharedPolyfills(shared2, resolveClientUrl) {
388
236
  const self = globalThis;
389
237
  const polyfill = {
390
- "next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
238
+ "next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared2?.["next/navigation"] ?? (() => Promise.resolve({
391
239
  useRouter() {
392
240
  return {
393
241
  push: (routerUrl) => {
@@ -418,7 +266,7 @@ function sharedPolyfills(shared) {
418
266
  },
419
267
  __esModule: true
420
268
  })),
421
- "next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
269
+ "next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared2?.["next/link"] ?? (() => Promise.resolve({
422
270
  default: ({
423
271
  scroll: _,
424
272
  replace,
@@ -468,18 +316,18 @@ function sharedPolyfills(shared) {
468
316
  },
469
317
  __esModule: true
470
318
  })),
471
- "next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
319
+ "next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared2?.["next/form"] ?? (() => Promise.resolve({
472
320
  default: () => {
473
321
  throw new Error("Next.js <Form> component not implemented");
474
322
  },
475
323
  __esModule: true
476
324
  })),
477
- "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
478
- Image: imageImpl(bundle),
325
+ "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
326
+ Image: imageImpl(bundle, resolveClientUrl),
479
327
  __esModule: true
480
328
  })),
481
- "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
482
- default: imageImpl(bundle),
329
+ "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
330
+ default: imageImpl(bundle, resolveClientUrl),
483
331
  getImageProps: (_imgProps) => {
484
332
  throw new Error(
485
333
  "Next.js getImageProps() is not implemented in remote components"
@@ -487,13 +335,13 @@ function sharedPolyfills(shared) {
487
335
  },
488
336
  __esModule: true
489
337
  })),
490
- "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
338
+ "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared2?.["next/script"] ?? (() => Promise.resolve({
491
339
  // TODO: implement <Script> component for non-Next.js host applications
492
340
  // do not throw an error for now
493
341
  default: () => null,
494
342
  __esModule: true
495
343
  })),
496
- "next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
344
+ "next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared2?.["next/router"] ?? (() => (
497
345
  // TODO: incomplete implementation
498
346
  Promise.resolve({
499
347
  useRouter() {
@@ -529,50 +377,479 @@ function sharedPolyfills(shared) {
529
377
  return polyfill;
530
378
  }
531
379
 
532
- // src/shared/client/component-loader.ts
533
- import * as React from "react";
534
- import * as JSXDevRuntime from "react/jsx-dev-runtime";
535
- import * as JSXRuntime from "react/jsx-runtime";
536
- import * as ReactDOM from "react-dom";
537
- import * as ReactDOMClient from "react-dom/client";
380
+ // src/host/nextjs/image-impl.tsx
381
+ import { jsx as jsx2 } from "react/jsx-runtime";
382
+ function createRemoteLoader(bundle, resolveClientUrl) {
383
+ return ({ src, width, quality }) => {
384
+ const self = globalThis;
385
+ const origin = self.__remote_bundle_url__?.[bundle]?.origin ?? "";
386
+ let imageUrl = src;
387
+ try {
388
+ const parsed = new URL(src);
389
+ if (origin && parsed.origin === origin) {
390
+ imageUrl = parsed.pathname + parsed.search;
391
+ }
392
+ } catch {
393
+ }
394
+ const { assetPrefix } = /^(?<assetPrefix>.*?)\/_next\//.exec(imageUrl)?.groups ?? {};
395
+ const url = `${origin}${assetPrefix ?? ""}/_next/image?url=${encodeURIComponent(imageUrl)}&w=${width}&q=${quality ?? 75}`;
396
+ return resolveClientUrl?.(url) ?? url;
397
+ };
398
+ }
399
+ function imageImpl2(ImageComponent, bundle, resolveClientUrl, useRemoteLoader) {
400
+ const remoteLoader = useRemoteLoader ? createRemoteLoader(bundle, resolveClientUrl) : void 0;
401
+ const component = function RemoteImage(props) {
402
+ if (remoteLoader) {
403
+ return /* @__PURE__ */ jsx2(ImageComponent, { loader: remoteLoader, ...props });
404
+ }
405
+ const rawSrc = applyBundleUrlToImagePropsSrc(bundle, props.src);
406
+ const src = resolveClientUrl?.(rawSrc) ?? rawSrc;
407
+ return /* @__PURE__ */ jsx2(ImageComponent, { ...props, src });
408
+ };
409
+ component.default = component;
410
+ return component;
411
+ }
538
412
 
539
- // src/shared/webpack/next-client-pages-loader.ts
540
- function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
541
- const self = globalThis;
542
- const nextCssOriginal = document.querySelector(
543
- `[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
544
- );
545
- if (nextCssOriginal) {
546
- nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
413
+ // src/runtime/url/resolve-client-url.ts
414
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
415
+ const remoteOrigin = parseOrigin(remoteSrc);
416
+ return (url) => {
417
+ const urlOrigin = parseOrigin(url);
418
+ if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
419
+ return void 0;
420
+ }
421
+ return resolveClientUrl(remoteSrc, url);
422
+ };
423
+ }
424
+ function parseOrigin(url) {
425
+ try {
426
+ return new URL(url).origin;
427
+ } catch {
428
+ return void 0;
547
429
  }
548
- const nextCss = document.createElement("noscript");
549
- nextCss.id = "__next_css__DO_NOT_USE__";
550
- nextCss.setAttribute("data-bundle", bundle);
551
- nextCss.setAttribute("data-route", route);
552
- const nextCssEnd = document.createElement("noscript");
553
- nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
554
- nextCssEnd.setAttribute("data-bundle", bundle);
555
- nextCssEnd.setAttribute("data-route", route);
556
- document.head.appendChild(nextCssEnd);
557
- document.head.appendChild(nextCss);
558
- const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
559
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
560
- ) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
561
- (key) => key.includes("/next/dist/client/page-loader.js")
562
- ) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
563
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
564
- ) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
565
- (key) => key.includes("/next/dist/client/page-loader.js")
566
- ) ?? ""] ?? -1;
567
- const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
568
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
569
- ) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
570
- (key) => key.includes("/next/dist/client/page-loader.js")
571
- ) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
572
- (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
573
- ) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
574
- (key) => key.includes("/next/dist/client/page-loader.js")
575
- ) ?? ""] ?? -1;
430
+ }
431
+
432
+ // src/runtime/url/default-resolve-client-url.ts
433
+ function bindResolveClientUrl(prop, remoteSrc) {
434
+ return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
435
+ }
436
+
437
+ // src/host/react/index.tsx
438
+ import {
439
+ startTransition,
440
+ useEffect,
441
+ useId,
442
+ useLayoutEffect as useLayoutEffect2,
443
+ useMemo as useMemo2,
444
+ useRef as useRef2,
445
+ useState as useState2
446
+ } from "react";
447
+ import { createPortal } from "react-dom";
448
+
449
+ // src/host/server/fetch-headers.ts
450
+ function remoteFetchHeaders() {
451
+ return {
452
+ /**
453
+ * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
454
+ * If the remote component uses vercel deployment protection, ensure the host and remote vercel
455
+ * projects share a common automation bypass secret, and the shared secret is used as the
456
+ * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
457
+ */
458
+ ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
459
+ "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
460
+ } : {},
461
+ Accept: "text/html"
462
+ };
463
+ }
464
+
465
+ // src/host/server/fetch-with-hooks.ts
466
+ async function fetchWithWarning(url, init) {
467
+ try {
468
+ return await fetch(url, init);
469
+ } catch (error) {
470
+ warnCrossOriginFetchError("FetchRemoteComponent", url);
471
+ throw error;
472
+ }
473
+ }
474
+ async function fetchWithHooks(url, additionalInit, options = {}) {
475
+ const {
476
+ onRequest,
477
+ onResponse,
478
+ abortController = new AbortController()
479
+ } = options;
480
+ const signal = abortController.signal;
481
+ const hookOptions = {
482
+ signal,
483
+ abort: (reason) => abortController.abort(reason)
484
+ };
485
+ const init = {
486
+ method: "GET",
487
+ headers: remoteFetchHeaders(),
488
+ signal,
489
+ ...additionalInit
490
+ };
491
+ const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
492
+ return await onResponse?.(url, res, hookOptions) ?? res;
493
+ }
494
+
495
+ // src/host/server/get-client-or-server-url.ts
496
+ function getClientOrServerUrl(src, serverFallback) {
497
+ const fallback = typeof location !== "undefined" ? location.href : serverFallback;
498
+ if (!src) {
499
+ return new URL(fallback);
500
+ }
501
+ return typeof src === "string" ? new URL(src, fallback) : src;
502
+ }
503
+
504
+ // src/host/shared/state.ts
505
+ function createHostState() {
506
+ return {
507
+ stage: "idle",
508
+ prevSrc: void 0,
509
+ prevUrl: void 0,
510
+ prevName: void 0,
511
+ prevIsRemoteComponent: false,
512
+ abortController: void 0
513
+ };
514
+ }
515
+
516
+ // src/host/utils/resolve-name-from-src.ts
517
+ function resolveNameFromSrc(src, defaultName) {
518
+ if (!src) {
519
+ return defaultName;
520
+ }
521
+ const hash = typeof src === "string" ? src : src.hash;
522
+ const hashIndex = hash.indexOf("#");
523
+ if (hashIndex < 0) {
524
+ return defaultName;
525
+ }
526
+ const name = hash.slice(hashIndex + 1);
527
+ return name || defaultName;
528
+ }
529
+
530
+ // src/utils/index.ts
531
+ function escapeString(str) {
532
+ return str.replace(/[^a-z0-9]/g, "_");
533
+ }
534
+ var attrToProp = {
535
+ fetchpriority: "fetchPriority",
536
+ crossorigin: "crossOrigin",
537
+ imagesrcset: "imageSrcSet",
538
+ imagesizes: "imageSizes",
539
+ srcset: "srcSet"
540
+ };
541
+
542
+ // src/runtime/constants.ts
543
+ var DEFAULT_ROUTE = "/";
544
+ var RUNTIME_WEBPACK = "webpack";
545
+ var RUNTIME_TURBOPACK = "turbopack";
546
+ var RUNTIME_SCRIPT = "script";
547
+ var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
548
+ var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
549
+ function getBundleKey(bundle) {
550
+ return escapeString(bundle);
551
+ }
552
+
553
+ // src/runtime/html/apply-origin.ts
554
+ var tagNames = [
555
+ "img",
556
+ "source",
557
+ "video",
558
+ "audio",
559
+ "track",
560
+ "iframe",
561
+ "embed",
562
+ "script",
563
+ "link"
564
+ ];
565
+ function applyOriginToNodes(doc, url, resolveClientUrl) {
566
+ if (url.origin !== location.origin) {
567
+ const nodes = doc.querySelectorAll(
568
+ tagNames.map(
569
+ (type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
570
+ ).join(",")
571
+ );
572
+ nodes.forEach((node) => {
573
+ if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
574
+ const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
575
+ const isScript = node.tagName.toLowerCase() === "script";
576
+ node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
577
+ }
578
+ if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
579
+ const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
580
+ node.setAttribute(
581
+ "href",
582
+ resolveClientUrl?.(absoluteHref) ?? absoluteHref
583
+ );
584
+ }
585
+ if (node.hasAttribute("srcset")) {
586
+ const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
587
+ const [urlPart, descriptor] = entry.trim().split(/\s+/);
588
+ if (!urlPart)
589
+ return entry;
590
+ const absoluteUrl = new URL(urlPart, url).href;
591
+ const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
592
+ return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
593
+ }).join(", ");
594
+ if (srcSet) {
595
+ node.setAttribute("srcset", srcSet);
596
+ }
597
+ }
598
+ if (node.hasAttribute("imagesrcset")) {
599
+ const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
600
+ const [urlPart, descriptor] = entry.trim().split(/\s+/);
601
+ if (!urlPart)
602
+ return entry;
603
+ const absoluteUrl = new URL(urlPart, url).href;
604
+ const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
605
+ return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
606
+ }).join(", ");
607
+ if (srcSet) {
608
+ node.setAttribute("imagesrcset", srcSet);
609
+ }
610
+ }
611
+ });
612
+ }
613
+ }
614
+
615
+ // src/runtime/html/parse-remote-html.ts
616
+ function validateSingleComponent(doc, name, url) {
617
+ 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}"]`)) {
618
+ throw multipleRemoteComponentsError(url);
619
+ }
620
+ }
621
+ function findComponentElement(doc, name) {
622
+ return doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) ?? doc.querySelector("div[data-bundle][data-route]") ?? doc.querySelector("div#__next") ?? doc.querySelector(`remote-component[name="${name}"]:not([src])`) ?? doc.querySelector("remote-component:not([src])");
623
+ }
624
+ function parseNextData(doc) {
625
+ return JSON.parse(
626
+ (doc.querySelector("#__NEXT_DATA__") ?? doc.querySelector("#__REMOTE_NEXT_DATA__"))?.textContent ?? "null"
627
+ );
628
+ }
629
+ function resolveComponentName(component, nextData, fallbackName) {
630
+ const isRemoteComponent = component?.tagName.toLowerCase() === "remote-component";
631
+ const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
632
+ return { name, isRemoteComponent };
633
+ }
634
+ function extractComponentMetadata(component, nextData, name, url) {
635
+ return {
636
+ name,
637
+ bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
638
+ route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
639
+ runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
640
+ };
641
+ }
642
+ function extractRemoteShared(doc, name, nextData) {
643
+ const remoteSharedEl = doc.querySelector(
644
+ `#${name}_shared[data-remote-components-shared]`
645
+ );
646
+ const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
647
+ remoteSharedEl?.remove();
648
+ return remoteShared;
649
+ }
650
+ function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
651
+ if (!component || !(rsc || nextData || isRemoteComponent)) {
652
+ throw new RemoteComponentsError(
653
+ `Remote Component not found on ${url}.${name !== "__vercel_remote_component" ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
654
+ );
655
+ }
656
+ }
657
+ function extractLinks(doc, component) {
658
+ return Array.from(doc.querySelectorAll("link[href]")).filter(
659
+ (link) => !component.contains(link)
660
+ );
661
+ }
662
+ function extractScripts(doc, component, isRemoteComponent) {
663
+ return Array.from(
664
+ (isRemoteComponent ? component : doc).querySelectorAll(
665
+ "script[src],script[data-src]"
666
+ )
667
+ );
668
+ }
669
+ function parseRemoteComponentDocument(doc, name, url) {
670
+ validateSingleComponent(doc, name, url.href);
671
+ const component = findComponentElement(doc, name);
672
+ const nextData = parseNextData(doc);
673
+ const { name: resolvedName, isRemoteComponent } = resolveComponentName(
674
+ component,
675
+ nextData,
676
+ name
677
+ );
678
+ const rsc = doc.querySelector(`#${resolvedName}_rsc`);
679
+ const metadata = extractComponentMetadata(
680
+ component,
681
+ nextData,
682
+ resolvedName,
683
+ url
684
+ );
685
+ const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
686
+ validateComponentFound(
687
+ component,
688
+ rsc,
689
+ nextData,
690
+ isRemoteComponent,
691
+ url.href,
692
+ resolvedName
693
+ );
694
+ const links = extractLinks(doc, component);
695
+ const scripts = extractScripts(doc, component, isRemoteComponent);
696
+ return {
697
+ component,
698
+ name: resolvedName,
699
+ isRemoteComponent,
700
+ metadata,
701
+ nextData,
702
+ rsc,
703
+ remoteShared,
704
+ links,
705
+ scripts
706
+ };
707
+ }
708
+
709
+ // src/runtime/html/set-attributes-from-props.ts
710
+ var DOMAttributeNames = {
711
+ acceptCharset: "accept-charset",
712
+ className: "class",
713
+ htmlFor: "for",
714
+ httpEquiv: "http-equiv",
715
+ noModule: "noModule"
716
+ };
717
+ var ignoreProps = [
718
+ "onLoad",
719
+ "onReady",
720
+ "dangerouslySetInnerHTML",
721
+ "children",
722
+ "onError",
723
+ "strategy",
724
+ "stylesheets"
725
+ ];
726
+ function isBooleanScriptAttribute(attr) {
727
+ return ["async", "defer", "noModule"].includes(attr);
728
+ }
729
+ function setAttributesFromProps(el, props) {
730
+ for (const [p, value] of Object.entries(props)) {
731
+ if (!Object.hasOwn(props, p))
732
+ continue;
733
+ if (ignoreProps.includes(p))
734
+ continue;
735
+ if (value === void 0) {
736
+ continue;
737
+ }
738
+ const attr = DOMAttributeNames[p] || p.toLowerCase();
739
+ if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
740
+ el[attr] = Boolean(value);
741
+ } else {
742
+ el.setAttribute(attr, String(value));
743
+ }
744
+ if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
745
+ el.setAttribute(attr, "");
746
+ el.removeAttribute(attr);
747
+ }
748
+ }
749
+ }
750
+
751
+ // src/runtime/loaders/component-loader.ts
752
+ import * as React from "react";
753
+ import * as JSXDevRuntime from "react/jsx-dev-runtime";
754
+ import * as JSXRuntime from "react/jsx-runtime";
755
+ import * as ReactDOM from "react-dom";
756
+ import * as ReactDOMClient from "react-dom/client";
757
+
758
+ // src/config/webpack/apply-shared-modules.ts
759
+ function applySharedModules(bundle, resolve) {
760
+ logDebug(
761
+ "SharedModules",
762
+ `applySharedModules called for bundle: "${bundle}"`
763
+ );
764
+ logDebug(
765
+ "SharedModules",
766
+ `Shared modules to resolve: ${Object.keys(resolve)}`
767
+ );
768
+ const self = globalThis;
769
+ if (self.__remote_webpack_require__?.[bundle]) {
770
+ const modulePaths = Object.keys(
771
+ self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
772
+ );
773
+ logDebug(
774
+ "SharedModules",
775
+ `Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
776
+ );
777
+ for (const [key, value] of Object.entries(resolve)) {
778
+ const exactIds = modulePaths.filter((p) => p === key);
779
+ const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
780
+ if (ids.length === 0) {
781
+ logDebug(
782
+ "SharedModules",
783
+ `No matching module path found for shared module "${key}"`
784
+ );
785
+ }
786
+ for (const id of ids) {
787
+ const webpackBundle = self.__remote_webpack_require__[bundle];
788
+ if (webpackBundle.m) {
789
+ const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
790
+ if (resolvedId !== id) {
791
+ logDebug(
792
+ "SharedModules",
793
+ `Mapped module id: "${id}" -> "${resolvedId}"`
794
+ );
795
+ }
796
+ webpackBundle.m[resolvedId] = (module) => {
797
+ module.exports = value;
798
+ };
799
+ } else {
800
+ logWarn(
801
+ "SharedModules",
802
+ `webpackBundle.m is not available for bundle "${bundle}"`
803
+ );
804
+ }
805
+ }
806
+ }
807
+ } else {
808
+ logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
809
+ logDebug(
810
+ "SharedModules",
811
+ `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
812
+ );
813
+ }
814
+ }
815
+
816
+ // src/config/webpack/next-client-pages-loader.ts
817
+ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
818
+ const self = globalThis;
819
+ const nextCssOriginal = document.querySelector(
820
+ `[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
821
+ );
822
+ if (nextCssOriginal) {
823
+ nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
824
+ }
825
+ const nextCss = document.createElement("noscript");
826
+ nextCss.id = "__next_css__DO_NOT_USE__";
827
+ nextCss.setAttribute("data-bundle", bundle);
828
+ nextCss.setAttribute("data-route", route);
829
+ const nextCssEnd = document.createElement("noscript");
830
+ nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
831
+ nextCssEnd.setAttribute("data-bundle", bundle);
832
+ nextCssEnd.setAttribute("data-route", route);
833
+ document.head.appendChild(nextCssEnd);
834
+ document.head.appendChild(nextCss);
835
+ const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
836
+ (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
837
+ ) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
838
+ (key) => key.includes("/next/dist/client/page-loader.js")
839
+ ) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
840
+ (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
841
+ ) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
842
+ (key) => key.includes("/next/dist/client/page-loader.js")
843
+ ) ?? ""] ?? -1;
844
+ const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
845
+ (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
846
+ ) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
847
+ (key) => key.includes("/next/dist/client/page-loader.js")
848
+ ) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
849
+ (key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
850
+ ) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
851
+ (key) => key.includes("/next/dist/client/page-loader.js")
852
+ ) ?? ""] ?? -1;
576
853
  if (!(componentLoaderChunk && appLoaderChunk)) {
577
854
  throw new RemoteComponentsError(
578
855
  `Next.js client pages loader not found in bundle "${bundle}".`
@@ -626,90 +903,29 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
626
903
  self.__remote_next_css__[bundle] = elements;
627
904
  }
628
905
  if (styleContainer) {
629
- const elements = self.__remote_next_css__[bundle];
630
- elements.forEach((el) => {
631
- styleContainer.appendChild(el.cloneNode(true));
632
- });
633
- } else {
634
- const elements = self.__remote_next_css__[bundle];
635
- elements.forEach((el) => {
636
- document.head.appendChild(el);
637
- });
638
- }
639
- delete self.__NEXT_P;
640
- self.__NEXT_P = __NEXT_P_ORIGINAL;
641
- if (nextCssOriginal) {
642
- nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
643
- }
644
- nextCss.remove();
645
- nextCssEnd.remove();
646
- return { Component, App };
647
- }
648
- return { Component: null, App: null };
649
- }
650
-
651
- // src/shared/webpack/shared-modules.ts
652
- function applySharedModules(bundle, resolve) {
653
- logDebug(
654
- "SharedModules",
655
- `applySharedModules called for bundle: "${bundle}"`
656
- );
657
- logDebug(
658
- "SharedModules",
659
- `Shared modules to resolve: ${Object.keys(resolve)}`
660
- );
661
- const self = globalThis;
662
- if (self.__remote_webpack_require__?.[bundle]) {
663
- const modulePaths = Object.keys(
664
- self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
665
- );
666
- logDebug(
667
- "SharedModules",
668
- `Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
669
- );
670
- for (const [key, value] of Object.entries(resolve)) {
671
- let ids = modulePaths.filter((p) => p === key);
672
- if (ids.length === 0) {
673
- ids = modulePaths.filter((p) => p.includes(key));
674
- }
675
- if (ids.length === 0) {
676
- logDebug(
677
- "SharedModules",
678
- `No matching module path found for shared module "${key}"`
679
- );
680
- }
681
- for (let id of ids) {
682
- const webpackBundle = self.__remote_webpack_require__[bundle];
683
- if (webpackBundle.m) {
684
- if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
685
- const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
686
- logDebug(
687
- "SharedModules",
688
- `Mapped module id: "${id}" -> "${mappedId}"`
689
- );
690
- id = mappedId;
691
- }
692
- webpackBundle.m[id] = (module) => {
693
- module.exports = value;
694
- };
695
- } else {
696
- logWarn(
697
- "SharedModules",
698
- `webpackBundle.m is not available for bundle "${bundle}"`
699
- );
700
- }
701
- }
906
+ const elements = self.__remote_next_css__[bundle];
907
+ elements.forEach((el) => {
908
+ styleContainer.appendChild(el.cloneNode(true));
909
+ });
910
+ } else {
911
+ const elements = self.__remote_next_css__[bundle];
912
+ elements.forEach((el) => {
913
+ document.head.appendChild(el);
914
+ });
702
915
  }
703
- } else {
704
- logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
705
- logDebug(
706
- "SharedModules",
707
- `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
708
- );
916
+ delete self.__NEXT_P;
917
+ self.__NEXT_P = __NEXT_P_ORIGINAL;
918
+ if (nextCssOriginal) {
919
+ nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
920
+ }
921
+ nextCss.remove();
922
+ nextCssEnd.remove();
923
+ return { Component, App };
709
924
  }
925
+ return { Component: null, App: null };
710
926
  }
711
927
 
712
- // src/shared/client/rsc.ts
928
+ // src/runtime/rsc.ts
713
929
  import { ReadableStream } from "web-streams-polyfill";
714
930
  function fixPayload(payload) {
715
931
  if (Array.isArray(payload)) {
@@ -775,56 +991,18 @@ function createRSCStream(rscName, data) {
775
991
  });
776
992
  }
777
993
 
778
- // src/shared/client/webpack-patterns.ts
779
- var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
780
-
781
- // src/shared/client/script-loader.ts
782
- async function loadScripts(scripts, resolveClientUrl) {
783
- await Promise.all(
784
- scripts.map((script) => {
785
- return new Promise((resolve, reject) => {
786
- const newSrc = new URL(
787
- // remove the remote component bundle name identifier from the script src
788
- script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
789
- location.origin
790
- ).href;
791
- const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
792
- const newScript = document.createElement("script");
793
- newScript.onload = () => resolve();
794
- newScript.onerror = () => {
795
- const isProxied = isProxiedUrl(resolvedSrc);
796
- if (isProxied) {
797
- reject(
798
- new RemoteComponentsError(
799
- `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}`
800
- )
801
- );
802
- } else {
803
- warnCrossOriginFetchError("ScriptLoader", newSrc);
804
- reject(
805
- new RemoteComponentsError(
806
- `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
807
- )
808
- );
809
- }
810
- };
811
- newScript.src = resolvedSrc;
812
- newScript.async = true;
813
- document.head.appendChild(newScript);
814
- });
815
- })
816
- );
817
- }
994
+ // src/runtime/turbopack/chunk-loader.ts
995
+ init_constants();
818
996
 
819
- // src/shared/client/turbopack-patterns.ts
997
+ // src/runtime/turbopack/patterns.ts
820
998
  var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
821
- var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|e)\.A\((?<sharedModuleId>[0-9]+)\)/;
999
+ var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
822
1000
  var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
823
1001
  var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
824
1002
  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]+)\)\)\)\}/;
825
1003
  var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
826
1004
 
827
- // src/shared/client/chunk-loader.ts
1005
+ // src/runtime/turbopack/chunk-loader.ts
828
1006
  function createChunkLoader(runtime, resolveClientUrl) {
829
1007
  return function __turbopack_chunk_load__(chunkId, scriptBundle) {
830
1008
  logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
@@ -886,7 +1064,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
886
1064
  if (isProxied) {
887
1065
  reject(
888
1066
  new RemoteComponentsError(
889
- `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}`
1067
+ `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}`
890
1068
  )
891
1069
  );
892
1070
  } else {
@@ -1036,7 +1214,7 @@ async function handleTurbopackChunk(code, bundle, url) {
1036
1214
  }
1037
1215
  }
1038
1216
 
1039
- // src/shared/client/turbopack-module.ts
1217
+ // src/runtime/turbopack/module.ts
1040
1218
  function handleTurbopackModule(bundle, moduleId, id) {
1041
1219
  const self = globalThis;
1042
1220
  const bundleKey = getBundleKey(bundle);
@@ -1265,7 +1443,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
1265
1443
  };
1266
1444
  }
1267
1445
 
1268
- // src/shared/client/shared-modules.ts
1446
+ // src/runtime/turbopack/shared-modules.ts
1269
1447
  async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
1270
1448
  const self = globalThis;
1271
1449
  self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
@@ -1302,9 +1480,9 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
1302
1480
  }
1303
1481
  }
1304
1482
  if (sharedModuleInitializer) {
1305
- const { shared } = await sharedModuleInitializer;
1483
+ const { shared: shared2 } = await sharedModuleInitializer;
1306
1484
  const sharedModuleIds = extractSharedModuleIds(
1307
- shared,
1485
+ shared2,
1308
1486
  bundleKey,
1309
1487
  self
1310
1488
  );
@@ -1340,8 +1518,8 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
1340
1518
  })
1341
1519
  );
1342
1520
  }
1343
- function extractSharedModuleIds(shared, bundleKey, self) {
1344
- return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
1521
+ function extractSharedModuleIds(shared2, bundleKey, self) {
1522
+ return Object.entries(shared2).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
1345
1523
  const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
1346
1524
  if (asyncSharedModuleId) {
1347
1525
  const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
@@ -1385,8 +1563,8 @@ function getSharedModule(bundle, id) {
1385
1563
  return null;
1386
1564
  }
1387
1565
 
1388
- // src/shared/client/webpack-adapter.ts
1389
- async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
1566
+ // src/runtime/turbopack/webpack-runtime.ts
1567
+ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared2 = {}, remoteShared = {}, resolveClientUrl) {
1390
1568
  const self = globalThis;
1391
1569
  if (!self.__remote_bundle_url__) {
1392
1570
  self.__remote_bundle_url__ = {};
@@ -1423,7 +1601,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1423
1601
  "react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
1424
1602
  "react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
1425
1603
  "react-dom/client": async () => (await import("react-dom/client")).default,
1426
- ...shared
1604
+ ...shared2
1427
1605
  };
1428
1606
  await initializeSharedModules(
1429
1607
  bundle ?? "default",
@@ -1440,7 +1618,7 @@ function createModuleRequire(runtime) {
1440
1618
  id
1441
1619
  };
1442
1620
  const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
1443
- logDebug("WebpackAdapter", `remoteRuntime: "${remoteRuntime}"`);
1621
+ logDebug("WebpackRuntime", `remoteRuntime: "${remoteRuntime}"`);
1444
1622
  try {
1445
1623
  if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
1446
1624
  return self.__remote_webpack_require__?.[bundle]?.(moduleId);
@@ -1456,7 +1634,7 @@ function createModuleRequire(runtime) {
1456
1634
  throw new Error(`Module "${id}" not found.`);
1457
1635
  } catch (requireError) {
1458
1636
  logWarn(
1459
- "WebpackAdapter",
1637
+ "WebpackRuntime",
1460
1638
  `Module require failed: ${String(requireError)}`
1461
1639
  );
1462
1640
  if (typeof self.__original_webpack_require__ !== "function") {
@@ -1468,7 +1646,7 @@ function createModuleRequire(runtime) {
1468
1646
  );
1469
1647
  }
1470
1648
  try {
1471
- logDebug("WebpackAdapter", "Falling back to original webpack require");
1649
+ logDebug("WebpackRuntime", "Falling back to original webpack require");
1472
1650
  return self.__original_webpack_require__(id);
1473
1651
  } catch (originalError) {
1474
1652
  throw new RemoteComponentsError(
@@ -1480,7 +1658,46 @@ function createModuleRequire(runtime) {
1480
1658
  };
1481
1659
  }
1482
1660
 
1483
- // src/shared/client/component-loader.ts
1661
+ // src/runtime/loaders/script-loader.ts
1662
+ init_constants();
1663
+ async function loadScripts(scripts, resolveClientUrl) {
1664
+ await Promise.all(
1665
+ scripts.map((script) => {
1666
+ return new Promise((resolve, reject) => {
1667
+ const newSrc = new URL(
1668
+ // remove the remote component bundle name identifier from the script src
1669
+ script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
1670
+ location.origin
1671
+ ).href;
1672
+ const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
1673
+ const newScript = document.createElement("script");
1674
+ newScript.onload = () => resolve();
1675
+ newScript.onerror = () => {
1676
+ const isProxied = isProxiedUrl(resolvedSrc);
1677
+ if (isProxied) {
1678
+ reject(
1679
+ new RemoteComponentsError(
1680
+ `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}`
1681
+ )
1682
+ );
1683
+ } else {
1684
+ warnCrossOriginFetchError("ScriptLoader", newSrc);
1685
+ reject(
1686
+ new RemoteComponentsError(
1687
+ `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
1688
+ )
1689
+ );
1690
+ }
1691
+ };
1692
+ newScript.src = resolvedSrc;
1693
+ newScript.async = true;
1694
+ document.head.appendChild(newScript);
1695
+ });
1696
+ })
1697
+ );
1698
+ }
1699
+
1700
+ // src/runtime/loaders/component-loader.ts
1484
1701
  async function loadRemoteComponent({
1485
1702
  url,
1486
1703
  name,
@@ -1491,7 +1708,7 @@ async function loadRemoteComponent({
1491
1708
  data,
1492
1709
  nextData,
1493
1710
  scripts = [],
1494
- shared = Promise.resolve({}),
1711
+ shared: shared2 = Promise.resolve({}),
1495
1712
  remoteShared = {},
1496
1713
  container,
1497
1714
  resolveClientUrl
@@ -1505,7 +1722,7 @@ async function loadRemoteComponent({
1505
1722
  self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
1506
1723
  await loadScripts(scripts, resolveClientUrl);
1507
1724
  }
1508
- const hostShared = await shared;
1725
+ const hostShared = await shared2;
1509
1726
  logDebug(
1510
1727
  "ComponentLoader",
1511
1728
  `loadRemoteComponent: bundle="${bundle}", name="${name}"`
@@ -1583,17 +1800,19 @@ async function loadRemoteComponent({
1583
1800
  };
1584
1801
  }
1585
1802
  }
1586
- async function loadRSCComponent(rscName, data) {
1587
- let createFromReadableStream;
1803
+ async function importCreateFromReadableStream() {
1588
1804
  try {
1589
- const { createFromReadableStream: _createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
1590
- createFromReadableStream = _createFromReadableStream;
1805
+ const { createFromReadableStream } = await import("next/dist/compiled/react-server-dom-webpack/client.browser");
1806
+ return createFromReadableStream;
1591
1807
  } catch {
1592
1808
  const {
1593
- default: { createFromReadableStream: _createFromReadableStream }
1809
+ default: { createFromReadableStream }
1594
1810
  } = await import("react-server-dom-webpack/client.browser");
1595
- createFromReadableStream = _createFromReadableStream;
1811
+ return createFromReadableStream;
1596
1812
  }
1813
+ }
1814
+ async function loadRSCComponent(rscName, data) {
1815
+ const createFromReadableStream = await importCreateFromReadableStream();
1597
1816
  if (typeof createFromReadableStream !== "function") {
1598
1817
  throw new RemoteComponentsError(
1599
1818
  'Failed to import "react-server-dom-webpack". Is Next.js installed correctly?'
@@ -1614,68 +1833,7 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
1614
1833
  return { component };
1615
1834
  }
1616
1835
 
1617
- // src/shared/client/proxy-through-host.ts
1618
- function withRemoteSrc(resolveClientUrl, remoteSrc) {
1619
- const remoteOrigin = parseOrigin(remoteSrc);
1620
- return (url) => {
1621
- const urlOrigin = parseOrigin(url);
1622
- if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
1623
- return void 0;
1624
- }
1625
- return resolveClientUrl(remoteSrc, url);
1626
- };
1627
- }
1628
- function parseOrigin(url) {
1629
- try {
1630
- return new URL(url).origin;
1631
- } catch {
1632
- return void 0;
1633
- }
1634
- }
1635
-
1636
- // src/shared/client/set-attributes-from-props.ts
1637
- var DOMAttributeNames = {
1638
- acceptCharset: "accept-charset",
1639
- className: "class",
1640
- htmlFor: "for",
1641
- httpEquiv: "http-equiv",
1642
- noModule: "noModule"
1643
- };
1644
- var ignoreProps = [
1645
- "onLoad",
1646
- "onReady",
1647
- "dangerouslySetInnerHTML",
1648
- "children",
1649
- "onError",
1650
- "strategy",
1651
- "stylesheets"
1652
- ];
1653
- function isBooleanScriptAttribute(attr) {
1654
- return ["async", "defer", "noModule"].includes(attr);
1655
- }
1656
- function setAttributesFromProps(el, props) {
1657
- for (const [p, value] of Object.entries(props)) {
1658
- if (!Object.hasOwn(props, p))
1659
- continue;
1660
- if (ignoreProps.includes(p))
1661
- continue;
1662
- if (value === void 0) {
1663
- continue;
1664
- }
1665
- const attr = DOMAttributeNames[p] || p.toLowerCase();
1666
- if (el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr)) {
1667
- el[attr] = Boolean(value);
1668
- } else {
1669
- el.setAttribute(attr, String(value));
1670
- }
1671
- if (value === false || el.tagName === "SCRIPT" && isBooleanScriptAttribute(attr) && (!value || value === "false")) {
1672
- el.setAttribute(attr, "");
1673
- el.removeAttribute(attr);
1674
- }
1675
- }
1676
- }
1677
-
1678
- // src/shared/client/static-loader.ts
1836
+ // src/runtime/loaders/static-loader.ts
1679
1837
  async function importViaCallback(absoluteSrc, resolveClientUrl) {
1680
1838
  const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
1681
1839
  const fetchUrl = new URL(resolvedUrl, location.href).href;
@@ -1825,101 +1983,9 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1825
1983
  );
1826
1984
  }
1827
1985
 
1828
- // src/shared/contract/host-state.ts
1829
- function createHostState() {
1830
- return {
1831
- stage: "idle",
1832
- prevSrc: void 0,
1833
- prevUrl: void 0,
1834
- prevName: void 0,
1835
- prevIsRemoteComponent: false,
1836
- abortController: void 0
1837
- };
1838
- }
1839
-
1840
- // src/shared/contract/resolve-name-from-src.ts
1841
- function resolveNameFromSrc(src, defaultName) {
1842
- if (!src) {
1843
- return defaultName;
1844
- }
1845
- const hash = typeof src === "string" ? src : src.hash;
1846
- const hashIndex = hash.indexOf("#");
1847
- if (hashIndex < 0) {
1848
- return defaultName;
1849
- }
1850
- const name = hash.slice(hashIndex + 1);
1851
- return name || defaultName;
1852
- }
1853
-
1854
- // src/shared/ssr/fetch-headers.ts
1855
- function remoteFetchHeaders() {
1856
- return {
1857
- /**
1858
- * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
1859
- * If the remote component uses vercel deployment protection, ensure the host and remote vercel
1860
- * projects share a common automation bypass secret, and the shared secret is used as the
1861
- * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
1862
- */
1863
- ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
1864
- "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
1865
- } : {},
1866
- Accept: "text/html"
1867
- };
1868
- }
1869
-
1870
- // src/shared/ssr/fetch-with-hooks.ts
1871
- async function fetchWithHooks(url, additionalInit, options = {}) {
1872
- const {
1873
- onRequest,
1874
- onResponse,
1875
- abortController = new AbortController()
1876
- } = options;
1877
- const signal = abortController.signal;
1878
- const hookOptions = {
1879
- signal,
1880
- abort: (reason) => abortController.abort(reason)
1881
- };
1882
- const init = {
1883
- method: "GET",
1884
- headers: remoteFetchHeaders(),
1885
- signal,
1886
- ...additionalInit
1887
- };
1888
- let res = await onRequest?.(url, init, hookOptions);
1889
- if (!res) {
1890
- try {
1891
- res = await fetch(url, init);
1892
- } catch (error) {
1893
- warnCrossOriginFetchError("FetchRemoteComponent", url);
1894
- throw error;
1895
- }
1896
- }
1897
- const transformedRes = await onResponse?.(url, res, hookOptions);
1898
- if (transformedRes) {
1899
- res = transformedRes;
1900
- }
1901
- return res;
1902
- }
1903
-
1904
- // src/shared/ssr/get-client-or-server-url.ts
1905
- function getClientOrServerUrl(src, serverFallback) {
1906
- const fallback = typeof location !== "undefined" ? location.href : serverFallback;
1907
- if (!src) {
1908
- return new URL(fallback);
1909
- }
1910
- return typeof src === "string" ? new URL(src, fallback) : src;
1911
- }
1912
-
1913
- // src/react/hooks/use-resolve-client-url.ts
1986
+ // src/host/react/hooks/use-resolve-client-url.ts
1914
1987
  import { useMemo } from "react";
1915
- import { useRemoteComponentsContext } from "#internal/react/context";
1916
-
1917
- // src/shared/client/default-resolve-client-url.ts
1918
- function bindResolveClientUrl(prop, remoteSrc) {
1919
- return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
1920
- }
1921
-
1922
- // src/react/hooks/use-resolve-client-url.ts
1988
+ import { useRemoteComponentsContext } from "#internal/host/react/context";
1923
1989
  function useResolveClientUrl(prop, urlHref) {
1924
1990
  const { resolveClientUrl: contextValue } = useRemoteComponentsContext();
1925
1991
  const resolveClientUrl = prop ?? contextValue;
@@ -1929,7 +1995,7 @@ function useResolveClientUrl(prop, urlHref) {
1929
1995
  );
1930
1996
  }
1931
1997
 
1932
- // src/react/hooks/use-shadow-root.ts
1998
+ // src/host/react/hooks/use-shadow-root.ts
1933
1999
  import { useLayoutEffect, useRef, useState } from "react";
1934
2000
  function useShadowRoot({
1935
2001
  isolate,
@@ -1978,7 +2044,7 @@ function useShadowRoot({
1978
2044
  return { shadowRoot, shadowRootContainerRef };
1979
2045
  }
1980
2046
 
1981
- // src/react/utils/extract-remote-html.ts
2047
+ // src/host/react/utils/extract-remote-html.ts
1982
2048
  var DUMMY_FALLBACK = "http://remote-components-dummy-fallback";
1983
2049
  function getRemoteComponentHtml(html) {
1984
2050
  if (typeof document === "undefined")
@@ -2000,18 +2066,17 @@ function getRemoteComponentHtml(html) {
2000
2066
  return "";
2001
2067
  }
2002
2068
 
2003
- // src/react/index.tsx
2004
- import { RemoteComponentsProvider } from "#internal/react/context";
2005
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
2069
+ // src/host/react/index.tsx
2070
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
2006
2071
  import { createElement as createElement2 } from "react";
2007
- function RemoteComponent({
2072
+ function ConsumeRemoteComponent({
2008
2073
  src,
2009
2074
  isolate,
2010
2075
  mode = "open",
2011
2076
  reset,
2012
2077
  credentials = "same-origin",
2013
2078
  name: nameProp = "__vercel_remote_component",
2014
- shared = {},
2079
+ shared: shared2 = {},
2015
2080
  children,
2016
2081
  onBeforeLoad,
2017
2082
  onLoad,
@@ -2026,7 +2091,9 @@ function RemoteComponent({
2026
2091
  () => resolveNameFromSrc(src, nameProp),
2027
2092
  [src, nameProp]
2028
2093
  );
2029
- const [data, setData] = useState2(null);
2094
+ const [data, setData] = useState2(
2095
+ null
2096
+ );
2030
2097
  const url = useMemo2(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
2031
2098
  const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
2032
2099
  const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
@@ -2243,11 +2310,10 @@ function RemoteComponent({
2243
2310
  });
2244
2311
  self.__next_s = prevNextScripts;
2245
2312
  }
2246
- let rscName;
2313
+ const rscName = rsc ? `__remote_component_rsc_${escapeString(id)}_${escapeString(
2314
+ remoteName
2315
+ )}` : void 0;
2247
2316
  if (rsc) {
2248
- rscName = `__remote_component_rsc_${escapeString(
2249
- id
2250
- )}_${escapeString(remoteName)}`;
2251
2317
  rsc.textContent = rsc.textContent?.replace(
2252
2318
  new RegExp(`self\\["${remoteName}"\\]`, "g"),
2253
2319
  `self["${rscName}"]`
@@ -2265,7 +2331,7 @@ function RemoteComponent({
2265
2331
  componentHydrationHtml.current = `${Array.from(
2266
2332
  doc.querySelectorAll("link,style")
2267
2333
  ).map((link) => link.outerHTML).join("")}${reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>` : ""}${component.innerHTML}`;
2268
- const userShared = await shared;
2334
+ const userShared = await shared2;
2269
2335
  if ("__remote_components_missing_shared__" in userShared) {
2270
2336
  userShared.__remote_components_missing_shared__().catch((e) => {
2271
2337
  throw e;
@@ -2286,10 +2352,7 @@ function RemoteComponent({
2286
2352
  }
2287
2353
  setData(newData);
2288
2354
  if (shadowRoot) {
2289
- let shadowRootHtml = component.innerHTML;
2290
- if (reset) {
2291
- shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
2292
- }
2355
+ const shadowRootHtml = reset ? `<style data-remote-components-reset="">:host { all: initial; }</style>${component.innerHTML}` : component.innerHTML;
2293
2356
  shadowRoot.innerHTML = shadowRootHtml;
2294
2357
  htmlRef.current = null;
2295
2358
  setRemoteComponent(null);
@@ -2306,7 +2369,7 @@ function RemoteComponent({
2306
2369
  } else if (isolate === false) {
2307
2370
  setRemoteComponent(
2308
2371
  // TODO: remove wrapper div by converting HTML to RSC or React tree
2309
- /* @__PURE__ */ jsx2(
2372
+ /* @__PURE__ */ jsx3(
2310
2373
  "div",
2311
2374
  {
2312
2375
  dangerouslySetInnerHTML: { __html: component.innerHTML },
@@ -2358,7 +2421,7 @@ function RemoteComponent({
2358
2421
  };
2359
2422
  }),
2360
2423
  shared: {
2361
- ...sharedPolyfills(userShared),
2424
+ ...sharedPolyfills(userShared, resolveClientUrl),
2362
2425
  ...userShared
2363
2426
  },
2364
2427
  remoteShared,
@@ -2404,7 +2467,7 @@ function RemoteComponent({
2404
2467
  isolate,
2405
2468
  credentials,
2406
2469
  name,
2407
- shared,
2470
+ shared2,
2408
2471
  shadowRoot,
2409
2472
  reset,
2410
2473
  id,
@@ -2419,13 +2482,13 @@ function RemoteComponent({
2419
2482
  if (remoteComponent instanceof Error) {
2420
2483
  throw remoteComponent;
2421
2484
  }
2422
- const metadataJson = /* @__PURE__ */ jsx2("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
2485
+ const metadataJson = /* @__PURE__ */ jsx3("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
2423
2486
  name: data?.name || name,
2424
2487
  bundle: data?.bundle || "default",
2425
2488
  route: data?.route || DEFAULT_ROUTE,
2426
2489
  runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
2427
2490
  }) });
2428
- const resetStyle = reset ? /* @__PURE__ */ jsx2("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
2491
+ const resetStyle = reset ? /* @__PURE__ */ jsx3("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
2429
2492
  const linksToRender = data?.links?.map((link) => /* @__PURE__ */ createElement2(
2430
2493
  "link",
2431
2494
  {
@@ -2484,7 +2547,7 @@ function RemoteComponent({
2484
2547
  typeof document === "undefined" ? (
2485
2548
  // eslint-disable-next-line react/no-unknown-property
2486
2549
  /* @__PURE__ */ jsxs("template", { shadowrootmode: mode, children: [
2487
- typeof document === "undefined" ? /* @__PURE__ */ jsx2(
2550
+ typeof document === "undefined" ? /* @__PURE__ */ jsx3(
2488
2551
  "div",
2489
2552
  {
2490
2553
  dangerouslySetInnerHTML: {
@@ -2507,11 +2570,11 @@ function RemoteComponent({
2507
2570
  ) : null,
2508
2571
  shadowRoot && remoteComponent ? createPortal(
2509
2572
  /* @__PURE__ */ jsxs(Fragment, { children: [
2510
- /* @__PURE__ */ jsx2("template", { id: `${name}_start` }),
2573
+ /* @__PURE__ */ jsx3("template", { id: `${name}_start` }),
2511
2574
  resetStyle,
2512
2575
  linksToRender,
2513
2576
  remoteComponent,
2514
- /* @__PURE__ */ jsx2("template", { id: `${name}_end`, ref: endTemplateRef })
2577
+ /* @__PURE__ */ jsx3("template", { id: `${name}_end`, ref: endTemplateRef })
2515
2578
  ] }),
2516
2579
  shadowRoot
2517
2580
  ) : null
@@ -2522,32 +2585,15 @@ function RemoteComponent({
2522
2585
  }
2523
2586
  htmlRef.current = null;
2524
2587
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2525
- /* @__PURE__ */ jsx2("template", { id: `${name}_start` }),
2588
+ /* @__PURE__ */ jsx3("template", { id: `${name}_start` }),
2526
2589
  metadataJson,
2527
2590
  componentToRender,
2528
- /* @__PURE__ */ jsx2("template", { id: `${name}_end`, ref: endTemplateRef })
2591
+ /* @__PURE__ */ jsx3("template", { id: `${name}_end`, ref: endTemplateRef })
2529
2592
  ] });
2530
2593
  }
2531
2594
 
2532
- // src/next/host/client/index.tsx
2533
- import { RemoteComponentsProvider as RemoteComponentsProvider2 } from "#internal/react/context";
2534
-
2535
- // src/next/host/app-router-compat.tsx
2595
+ // src/host/nextjs/app-compat.tsx
2536
2596
  import { usePathname, useSearchParams } from "next/navigation";
2537
- import { jsx as jsx3 } from "react/jsx-runtime";
2538
- function imageImpl2(ImageComponent, bundle) {
2539
- const component = function RemoteImage(props) {
2540
- return /* @__PURE__ */ jsx3(
2541
- ImageComponent,
2542
- {
2543
- ...props,
2544
- src: applyBundleUrlToImagePropsSrc(bundle, props.src)
2545
- }
2546
- );
2547
- };
2548
- component.default = component;
2549
- return component;
2550
- }
2551
2597
  var routerImpl = async () => {
2552
2598
  const { useRouter } = await import("next/navigation");
2553
2599
  return Promise.resolve({
@@ -2611,17 +2657,34 @@ var routerImpl = async () => {
2611
2657
  });
2612
2658
  };
2613
2659
 
2614
- // src/next/host/client/index.tsx
2660
+ // src/host/nextjs/image-shared.ts
2661
+ function createNextImageSharedEntries(getWrappedImage, options) {
2662
+ const entries = {
2663
+ "next/image": (bundle) => Promise.resolve(getWrappedImage(bundle)),
2664
+ "next/dist/client/image-component": (bundle) => Promise.resolve({
2665
+ Image: getWrappedImage(bundle)
2666
+ })
2667
+ };
2668
+ if (options?.getImageProps) {
2669
+ entries["next/dist/api/image"] = (bundle) => Promise.resolve({
2670
+ default: getWrappedImage(bundle),
2671
+ getImageProps: options.getImageProps
2672
+ });
2673
+ }
2674
+ return entries;
2675
+ }
2676
+
2677
+ // src/host/nextjs/app-client-only.tsx
2615
2678
  import { jsx as jsx4 } from "react/jsx-runtime";
2616
2679
  async function tryImportShared() {
2617
2680
  try {
2618
- const { shared } = await import("remote-components/shared/host/app");
2619
- return shared;
2681
+ const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
2682
+ return shared2;
2620
2683
  } catch {
2621
2684
  return {};
2622
2685
  }
2623
2686
  }
2624
- var sharedModules = async (userShared) => {
2687
+ var sharedModules = async (userShared, resolveClientUrl) => {
2625
2688
  const [resolvedShared, resolvedUserShared] = await Promise.all([
2626
2689
  tryImportShared(),
2627
2690
  userShared ?? Promise.resolve({})
@@ -2629,19 +2692,27 @@ var sharedModules = async (userShared) => {
2629
2692
  return {
2630
2693
  ...resolvedShared,
2631
2694
  "next/router": routerImpl,
2632
- "next/image": (bundle) => Promise.resolve(imageImpl2(Image.default, bundle ?? "default")),
2633
- "next/dist/client/image-component": (bundle) => Promise.resolve({ Image: imageImpl2(Image.default, bundle ?? "default") }),
2695
+ ...createNextImageSharedEntries(
2696
+ (bundle) => imageImpl2(Image.default, bundle ?? "default", resolveClientUrl)
2697
+ ),
2634
2698
  ...resolvedUserShared
2635
2699
  };
2636
2700
  };
2637
- function RemoteComponent2(props) {
2701
+ function ConsumeRemoteComponent2(props) {
2638
2702
  if (typeof props.src !== "string" && !(props.src instanceof URL)) {
2639
2703
  return props.children ?? null;
2640
2704
  }
2641
- return /* @__PURE__ */ jsx4(RemoteComponent, { ...props, shared: sharedModules(props.shared) });
2705
+ const src = typeof props.src === "string" ? props.src : props.src.href;
2706
+ const resolveClientUrl = props.resolveClientUrl ? bindResolveClientUrl(props.resolveClientUrl, src) : void 0;
2707
+ return /* @__PURE__ */ jsx4(
2708
+ ConsumeRemoteComponent,
2709
+ {
2710
+ ...props,
2711
+ shared: sharedModules(props.shared, resolveClientUrl)
2712
+ }
2713
+ );
2642
2714
  }
2643
2715
  export {
2644
- RemoteComponent2 as RemoteComponent,
2645
- RemoteComponentsProvider2 as RemoteComponentsProvider
2716
+ ConsumeRemoteComponent2 as ConsumeRemoteComponent
2646
2717
  };
2647
- //# sourceMappingURL=index.js.map
2718
+ //# sourceMappingURL=client-only.js.map