@shopify/hydrogen 0.22.1 → 0.23.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 (468) hide show
  1. package/CHANGELOG.md +207 -0
  2. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +5 -5
  3. package/dist/esnext/components/CartLines/{CartLines.d.ts → CartLines.client.d.ts} +0 -0
  4. package/dist/esnext/components/CartLines/{CartLines.js → CartLines.client.js} +0 -0
  5. package/dist/esnext/components/CartLines/index.d.ts +1 -1
  6. package/dist/esnext/components/CartLines/index.js +1 -1
  7. package/dist/esnext/components/DevTools.client.js +1 -1
  8. package/dist/esnext/components/Image/Image.d.ts +8 -0
  9. package/dist/esnext/components/Image/Image.js +58 -10
  10. package/dist/esnext/components/Link/Link.client.d.ts +2 -0
  11. package/dist/esnext/components/Link/Link.client.js +7 -4
  12. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +1 -1
  13. package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
  14. package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +140 -0
  15. package/dist/esnext/components/ProductOptionsProvider/context.d.ts +2 -0
  16. package/dist/esnext/components/{ProductProvider → ProductOptionsProvider}/context.js +0 -1
  17. package/dist/esnext/components/ProductOptionsProvider/index.d.ts +2 -0
  18. package/dist/esnext/components/ProductOptionsProvider/index.js +2 -0
  19. package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +5 -2
  20. package/dist/esnext/components/ProductPrice/ProductPrice.client.js +10 -12
  21. package/dist/esnext/components/index.d.ts +1 -1
  22. package/dist/esnext/components/index.js +1 -1
  23. package/dist/esnext/entry-client.js +106 -6
  24. package/dist/esnext/entry-server.d.ts +2 -15
  25. package/dist/esnext/entry-server.js +245 -321
  26. package/dist/esnext/foundation/Analytics/Analytics.client.js +15 -13
  27. package/dist/esnext/foundation/Analytics/Analytics.server.js +27 -20
  28. package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +4 -2
  29. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +15 -13
  30. package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
  31. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.d.ts +1 -0
  32. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/{PerformanceMetrics.server.js → ServerAnalyticsConnector.server.js} +7 -6
  33. package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.d.ts +1 -0
  34. package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.js +19 -0
  35. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.d.ts +3 -0
  36. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.js +190 -0
  37. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.d.ts +3 -0
  38. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.js +24 -0
  39. package/dist/esnext/foundation/Analytics/connectors/Shopify/const.d.ts +28 -0
  40. package/dist/esnext/foundation/Analytics/connectors/Shopify/const.js +51 -0
  41. package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.d.ts +3 -0
  42. package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.js +56 -0
  43. package/dist/esnext/foundation/Analytics/hook.js +4 -2
  44. package/dist/esnext/foundation/Analytics/utils.d.ts +2 -0
  45. package/dist/esnext/foundation/Analytics/utils.js +21 -0
  46. package/dist/{node/framework → esnext/foundation/Cache}/cache-sub-request.d.ts +1 -1
  47. package/dist/esnext/{framework → foundation/Cache}/cache-sub-request.js +3 -3
  48. package/dist/esnext/{framework → foundation/Cache}/cache.d.ts +1 -1
  49. package/dist/esnext/{framework → foundation/Cache}/cache.js +3 -3
  50. package/dist/{node/framework/CachingStrategy → esnext/foundation/Cache/strategies}/index.d.ts +1 -1
  51. package/dist/esnext/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +0 -0
  52. package/dist/esnext/foundation/Cookie/Cookie.d.ts +3 -3
  53. package/dist/{node/framework/Hydration → esnext/foundation/Html}/Html.d.ts +3 -1
  54. package/dist/esnext/{framework/Hydration → foundation/Html}/Html.js +15 -2
  55. package/dist/{node/framework/Hydration/ServerComponentRequest.server.d.ts → esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +7 -3
  56. package/dist/esnext/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +1 -1
  57. package/dist/{node/framework/Hydration/ServerComponentResponse.server.d.ts → esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +7 -10
  58. package/dist/esnext/{framework/Hydration/ServerComponentResponse.server.js → foundation/HydrogenResponse/HydrogenResponse.server.js} +19 -15
  59. package/dist/esnext/foundation/Router/BrowserRouter.client.js +16 -9
  60. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
  61. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
  62. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +4 -4
  63. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +2 -2
  64. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.d.ts +1 -1
  65. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +1 -1
  66. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +1 -0
  67. package/dist/esnext/foundation/index.d.ts +1 -1
  68. package/dist/esnext/foundation/index.js +1 -1
  69. package/dist/esnext/foundation/runtime.d.ts +2 -0
  70. package/dist/esnext/foundation/runtime.js +6 -0
  71. package/dist/esnext/foundation/session/session.d.ts +3 -3
  72. package/dist/esnext/foundation/ssr-interop.d.ts +2 -2
  73. package/dist/esnext/foundation/useNavigate/useNavigate.d.ts +2 -0
  74. package/dist/esnext/foundation/useNavigate/useNavigate.js +11 -4
  75. package/dist/esnext/foundation/useQuery/hooks.js +9 -6
  76. package/dist/esnext/framework/Hydration/rsc.js +2 -0
  77. package/dist/esnext/framework/plugin.js +2 -0
  78. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +5 -2
  79. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
  80. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +4 -12
  81. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.d.ts +3 -0
  82. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +19 -0
  83. package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -2
  84. package/dist/esnext/hooks/useProductOptions/types.d.ts +16 -14
  85. package/dist/esnext/hooks/useProductOptions/useProductOptions.client.d.ts +1 -15
  86. package/dist/esnext/hooks/useProductOptions/useProductOptions.client.js +8 -107
  87. package/dist/esnext/hooks/useShopQuery/hooks.js +12 -6
  88. package/dist/esnext/index.d.ts +6 -3
  89. package/dist/esnext/index.js +6 -3
  90. package/dist/esnext/streaming.server.d.ts +0 -1
  91. package/dist/esnext/streaming.server.js +0 -4
  92. package/dist/esnext/types.d.ts +32 -23
  93. package/dist/esnext/utilities/apiRoutes.d.ts +2 -2
  94. package/dist/esnext/utilities/graphql-tracker.js +1 -1
  95. package/dist/esnext/utilities/index.d.ts +1 -1
  96. package/dist/esnext/utilities/index.js +1 -1
  97. package/dist/esnext/utilities/isBrowser/index.d.ts +1 -0
  98. package/dist/esnext/utilities/isBrowser/index.js +1 -0
  99. package/dist/esnext/utilities/isBrowser/isBrowser.d.ts +4 -0
  100. package/dist/esnext/utilities/isBrowser/isBrowser.js +6 -0
  101. package/dist/esnext/utilities/isServer/isServer.js +2 -2
  102. package/dist/esnext/utilities/log/index.d.ts +1 -1
  103. package/dist/esnext/utilities/log/index.js +1 -1
  104. package/dist/esnext/utilities/log/log-cache-header.d.ts +4 -4
  105. package/dist/esnext/utilities/log/log-query-timeline.d.ts +3 -3
  106. package/dist/esnext/utilities/log/log.d.ts +17 -11
  107. package/dist/esnext/utilities/log/log.js +29 -20
  108. package/dist/esnext/version.d.ts +1 -1
  109. package/dist/esnext/version.js +1 -1
  110. package/dist/node/client.d.ts +16 -0
  111. package/dist/node/client.js +43 -0
  112. package/dist/node/components/AddToCartButton/AddToCartButton.client.d.ts +23 -0
  113. package/dist/node/components/AddToCartButton/AddToCartButton.client.js +74 -0
  114. package/dist/node/components/AddToCartButton/index.d.ts +1 -0
  115. package/dist/node/components/AddToCartButton/index.js +5 -0
  116. package/dist/node/components/BuyNowButton/BuyNowButton.client.d.ts +18 -0
  117. package/dist/node/components/BuyNowButton/BuyNowButton.client.js +53 -0
  118. package/dist/node/components/BuyNowButton/index.d.ts +1 -0
  119. package/dist/node/components/BuyNowButton/index.js +5 -0
  120. package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +11 -0
  121. package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.js +44 -0
  122. package/dist/node/components/CartCheckoutButton/index.d.ts +1 -0
  123. package/dist/node/components/CartCheckoutButton/index.js +5 -0
  124. package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +14 -0
  125. package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.js +36 -0
  126. package/dist/node/components/CartEstimatedCost/index.d.ts +1 -0
  127. package/dist/node/components/CartEstimatedCost/index.js +5 -0
  128. package/dist/node/components/CartLineImage/CartLineImage.client.d.ts +9 -0
  129. package/dist/node/components/CartLineImage/CartLineImage.client.js +18 -0
  130. package/dist/node/components/CartLineImage/index.d.ts +1 -0
  131. package/dist/node/components/CartLineImage/index.js +5 -0
  132. package/dist/node/components/CartLinePrice/CartLinePrice.client.d.ts +12 -0
  133. package/dist/node/components/CartLinePrice/CartLinePrice.client.js +28 -0
  134. package/dist/node/components/CartLinePrice/index.d.ts +1 -0
  135. package/dist/node/components/CartLinePrice/index.js +5 -0
  136. package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +8 -0
  137. package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.js +19 -0
  138. package/dist/node/components/CartLineProductTitle/index.d.ts +1 -0
  139. package/dist/node/components/CartLineProductTitle/index.js +5 -0
  140. package/dist/node/components/CartLineProvider/CartLineProvider.client.d.ts +11 -0
  141. package/dist/node/components/CartLineProvider/CartLineProvider.client.js +15 -0
  142. package/dist/node/components/CartLineProvider/context.d.ts +26 -0
  143. package/dist/node/components/CartLineProvider/context.js +5 -0
  144. package/dist/node/components/CartLineProvider/index.d.ts +2 -0
  145. package/dist/node/components/CartLineProvider/index.js +7 -0
  146. package/dist/node/components/CartLineQuantity/CartLineQuantity.client.d.ts +8 -0
  147. package/dist/node/components/CartLineQuantity/CartLineQuantity.client.js +19 -0
  148. package/dist/node/components/CartLineQuantity/index.d.ts +1 -0
  149. package/dist/node/components/CartLineQuantity/index.js +5 -0
  150. package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +14 -0
  151. package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +31 -0
  152. package/dist/node/components/CartLineQuantityAdjustButton/index.d.ts +1 -0
  153. package/dist/node/components/CartLineQuantityAdjustButton/index.js +5 -0
  154. package/dist/node/components/CartLines/CartLines.client.d.ts +15 -0
  155. package/dist/node/components/CartLines/CartLines.client.js +44 -0
  156. package/dist/node/components/CartLines/index.d.ts +1 -0
  157. package/dist/node/components/CartLines/index.js +5 -0
  158. package/dist/node/components/CartProvider/CartProvider.client.d.ts +41 -0
  159. package/dist/node/components/CartProvider/CartProvider.client.js +550 -0
  160. package/dist/node/components/CartProvider/cart-queries.d.ts +10 -0
  161. package/dist/node/components/CartProvider/cart-queries.js +203 -0
  162. package/dist/node/components/CartProvider/constants.d.ts +2 -0
  163. package/dist/node/components/CartProvider/constants.js +5 -0
  164. package/dist/node/components/CartProvider/context.d.ts +2 -0
  165. package/dist/node/components/CartProvider/context.js +5 -0
  166. package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +86 -0
  167. package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.js +2 -0
  168. package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +86 -0
  169. package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +2 -0
  170. package/dist/node/components/CartProvider/graphql/CartCreateMutation.d.ts +85 -0
  171. package/dist/node/components/CartProvider/graphql/CartCreateMutation.js +2 -0
  172. package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +86 -0
  173. package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +2 -0
  174. package/dist/node/components/CartProvider/graphql/CartFragment.d.ts +72 -0
  175. package/dist/node/components/CartProvider/graphql/CartFragment.js +2 -0
  176. package/dist/node/components/CartProvider/graphql/CartLineAddMutation.d.ts +86 -0
  177. package/dist/node/components/CartProvider/graphql/CartLineAddMutation.js +2 -0
  178. package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +86 -0
  179. package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.js +2 -0
  180. package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +86 -0
  181. package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.js +2 -0
  182. package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +86 -0
  183. package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.js +2 -0
  184. package/dist/node/components/CartProvider/graphql/CartQuery.d.ts +81 -0
  185. package/dist/node/components/CartProvider/graphql/CartQuery.js +2 -0
  186. package/dist/node/components/CartProvider/hooks.client.d.ts +15 -0
  187. package/dist/node/components/CartProvider/hooks.client.js +90 -0
  188. package/dist/node/components/CartProvider/index.d.ts +4 -0
  189. package/dist/node/components/CartProvider/index.js +10 -0
  190. package/dist/node/components/CartProvider/types.d.ts +102 -0
  191. package/dist/node/components/CartProvider/types.js +2 -0
  192. package/dist/node/components/CartShopPayButton/CartShopPayButton.client.d.ts +9 -0
  193. package/dist/node/components/CartShopPayButton/CartShopPayButton.client.js +46 -0
  194. package/dist/node/components/CartShopPayButton/index.d.ts +1 -0
  195. package/dist/node/components/CartShopPayButton/index.js +5 -0
  196. package/dist/node/components/ExternalVideo/ExternalVideo.d.ts +21 -0
  197. package/dist/node/components/ExternalVideo/ExternalVideo.js +21 -0
  198. package/dist/node/components/ExternalVideo/index.d.ts +1 -0
  199. package/dist/node/components/ExternalVideo/index.js +5 -0
  200. package/dist/node/components/Image/Image.d.ts +8 -0
  201. package/dist/node/components/Image/Image.js +57 -9
  202. package/dist/node/components/Link/Link.client.d.ts +25 -0
  203. package/dist/node/components/Link/Link.client.js +165 -0
  204. package/dist/node/components/Link/index.d.ts +1 -0
  205. package/dist/node/components/Link/index.js +5 -0
  206. package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +6 -0
  207. package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.js +11 -0
  208. package/dist/node/components/LocalizationProvider/LocalizationContext.client.d.ts +6 -0
  209. package/dist/node/components/LocalizationProvider/LocalizationContext.client.js +5 -0
  210. package/dist/node/components/LocalizationProvider/LocalizationProvider.server.d.ts +33 -0
  211. package/dist/node/components/LocalizationProvider/LocalizationProvider.server.js +51 -0
  212. package/dist/node/components/MediaFile/MediaFile.d.ts +19 -0
  213. package/dist/node/components/MediaFile/MediaFile.js +39 -0
  214. package/dist/node/components/MediaFile/index.d.ts +1 -0
  215. package/dist/node/components/MediaFile/index.js +5 -0
  216. package/dist/node/components/Metafield/Metafield.client.d.ts +21 -0
  217. package/dist/node/components/Metafield/Metafield.client.js +75 -0
  218. package/dist/node/components/Metafield/index.d.ts +2 -0
  219. package/dist/node/components/Metafield/index.js +5 -0
  220. package/dist/node/components/Metafield/types.d.ts +4 -0
  221. package/dist/node/components/Metafield/types.js +2 -0
  222. package/dist/node/components/ModelViewer/ModelViewer.client.d.ts +128 -0
  223. package/dist/node/components/ModelViewer/ModelViewer.client.js +132 -0
  224. package/dist/node/components/ModelViewer/index.d.ts +1 -0
  225. package/dist/node/components/ModelViewer/index.js +5 -0
  226. package/dist/node/components/Money/Money.client.d.ts +25 -0
  227. package/dist/node/components/Money/Money.client.js +46 -0
  228. package/dist/node/components/Money/index.d.ts +1 -0
  229. package/dist/node/components/Money/index.js +5 -0
  230. package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
  231. package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.js +167 -0
  232. package/dist/node/components/ProductOptionsProvider/context.d.ts +2 -0
  233. package/dist/node/components/ProductOptionsProvider/context.js +5 -0
  234. package/dist/node/components/ProductOptionsProvider/index.d.ts +2 -0
  235. package/dist/node/components/ProductOptionsProvider/index.js +7 -0
  236. package/dist/node/components/ProductPrice/ProductPrice.client.d.ts +18 -0
  237. package/dist/node/components/ProductPrice/ProductPrice.client.js +61 -0
  238. package/dist/node/components/ProductPrice/index.d.ts +1 -0
  239. package/dist/node/components/ProductPrice/index.js +5 -0
  240. package/dist/node/components/Seo/CollectionSeo.client.d.ts +3 -0
  241. package/dist/node/components/Seo/CollectionSeo.client.js +22 -0
  242. package/dist/node/components/Seo/DefaultPageSeo.client.d.ts +3 -0
  243. package/dist/node/components/Seo/DefaultPageSeo.client.js +25 -0
  244. package/dist/node/components/Seo/DescriptionSeo.client.d.ts +4 -0
  245. package/dist/node/components/Seo/DescriptionSeo.client.js +17 -0
  246. package/dist/node/components/Seo/HomePageSeo.client.d.ts +2 -0
  247. package/dist/node/components/Seo/HomePageSeo.client.js +32 -0
  248. package/dist/node/components/Seo/ImageSeo.client.d.ts +3 -0
  249. package/dist/node/components/Seo/ImageSeo.client.js +17 -0
  250. package/dist/node/components/Seo/NoIndexSeo.client.d.ts +3 -0
  251. package/dist/node/components/Seo/NoIndexSeo.client.js +17 -0
  252. package/dist/node/components/Seo/PageSeo.client.d.ts +3 -0
  253. package/dist/node/components/Seo/PageSeo.client.js +20 -0
  254. package/dist/node/components/Seo/ProductSeo.client.d.ts +5 -0
  255. package/dist/node/components/Seo/ProductSeo.client.js +70 -0
  256. package/dist/node/components/Seo/Seo.client.d.ts +30 -0
  257. package/dist/node/components/Seo/Seo.client.js +38 -0
  258. package/dist/node/components/Seo/TitleSeo.client.d.ts +3 -0
  259. package/dist/node/components/Seo/TitleSeo.client.js +17 -0
  260. package/dist/node/components/Seo/TwitterSeo.client.d.ts +2 -0
  261. package/dist/node/components/Seo/TwitterSeo.client.js +16 -0
  262. package/dist/node/components/Seo/index.d.ts +1 -0
  263. package/dist/node/components/Seo/index.js +5 -0
  264. package/dist/node/components/Seo/seo-types.d.ts +17 -0
  265. package/dist/node/components/Seo/seo-types.js +2 -0
  266. package/dist/node/components/ShopPayButton/ShopPayButton.client.d.ts +38 -0
  267. package/dist/node/components/ShopPayButton/ShopPayButton.client.js +60 -0
  268. package/dist/node/components/ShopPayButton/index.d.ts +1 -0
  269. package/dist/node/components/ShopPayButton/index.js +5 -0
  270. package/dist/node/components/Video/Video.d.ts +14 -0
  271. package/dist/node/components/Video/Video.js +31 -0
  272. package/dist/node/components/Video/index.d.ts +1 -0
  273. package/dist/node/components/Video/index.js +5 -0
  274. package/dist/node/components/index.d.ts +28 -0
  275. package/dist/node/components/index.js +59 -0
  276. package/dist/node/components/types.d.ts +71 -0
  277. package/dist/node/components/types.js +11 -0
  278. package/dist/node/entry-server.d.ts +2 -15
  279. package/dist/node/entry-server.js +244 -320
  280. package/dist/node/foundation/Analytics/Analytics.client.js +15 -13
  281. package/dist/node/foundation/Analytics/Analytics.server.js +27 -20
  282. package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +4 -2
  283. package/dist/node/foundation/Analytics/ClientAnalytics.js +14 -12
  284. package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
  285. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.d.ts +7 -0
  286. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +68 -0
  287. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.d.ts +1 -0
  288. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +27 -0
  289. package/dist/node/foundation/Analytics/hook.js +4 -2
  290. package/dist/node/foundation/Analytics/index.d.ts +1 -0
  291. package/dist/node/foundation/Analytics/index.js +5 -0
  292. package/dist/node/foundation/Analytics/utils.d.ts +2 -0
  293. package/dist/node/foundation/Analytics/utils.js +24 -1
  294. package/dist/{esnext/framework → node/foundation/Cache}/cache-sub-request.d.ts +1 -1
  295. package/dist/node/{framework → foundation/Cache}/cache-sub-request.js +4 -4
  296. package/dist/node/{framework → foundation/Cache}/cache.d.ts +1 -1
  297. package/dist/node/{framework → foundation/Cache}/cache.js +5 -5
  298. package/dist/{esnext/framework/CachingStrategy → node/foundation/Cache/strategies}/index.d.ts +1 -1
  299. package/dist/node/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +0 -0
  300. package/dist/node/foundation/Head/Head.client.d.ts +5 -0
  301. package/dist/node/foundation/Head/Head.client.js +17 -0
  302. package/dist/node/foundation/Head/index.d.ts +1 -0
  303. package/dist/node/foundation/Head/index.js +5 -0
  304. package/dist/{esnext/framework/Hydration → node/foundation/Html}/Html.d.ts +3 -1
  305. package/dist/node/{framework/Hydration → foundation/Html}/Html.js +15 -2
  306. package/dist/{esnext/framework/Hydration/ServerComponentRequest.server.d.ts → node/foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +7 -3
  307. package/dist/node/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +3 -3
  308. package/dist/{esnext/framework/Hydration/ServerComponentResponse.server.d.ts → node/foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +7 -10
  309. package/dist/node/{framework/Hydration/ServerComponentResponse.server.js → foundation/HydrogenResponse/HydrogenResponse.server.js} +23 -19
  310. package/dist/node/foundation/Router/BrowserRouter.client.js +16 -9
  311. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
  312. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
  313. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +4 -4
  314. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +2 -2
  315. package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +7 -0
  316. package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.js +35 -0
  317. package/dist/node/foundation/ShopifyProvider/index.d.ts +1 -0
  318. package/dist/node/foundation/ShopifyProvider/index.js +5 -0
  319. package/dist/node/foundation/fetchSync/client/fetchSync.d.ts +10 -0
  320. package/dist/node/foundation/fetchSync/client/fetchSync.js +33 -0
  321. package/dist/node/foundation/fetchSync/server/fetchSync.d.ts +8 -0
  322. package/dist/node/foundation/fetchSync/server/fetchSync.js +33 -0
  323. package/dist/node/foundation/fetchSync/types.d.ts +5 -0
  324. package/dist/node/foundation/fetchSync/types.js +2 -0
  325. package/dist/node/foundation/index.d.ts +3 -0
  326. package/dist/node/foundation/index.js +10 -0
  327. package/dist/node/foundation/runtime.d.ts +2 -0
  328. package/dist/node/foundation/runtime.js +11 -0
  329. package/dist/node/foundation/session/session.d.ts +3 -3
  330. package/dist/node/foundation/ssr-interop.d.ts +2 -2
  331. package/dist/node/foundation/useNavigate/useNavigate.d.ts +2 -0
  332. package/dist/node/foundation/useNavigate/useNavigate.js +11 -4
  333. package/dist/node/foundation/useQuery/hooks.d.ts +36 -0
  334. package/dist/node/foundation/useQuery/hooks.js +104 -0
  335. package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.d.ts +10 -0
  336. package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.js +34 -0
  337. package/dist/node/foundation/useRouteParams/useRouteParams.d.ts +4 -0
  338. package/dist/node/foundation/useRouteParams/useRouteParams.js +13 -0
  339. package/dist/node/foundation/useServerProps/index.d.ts +1 -0
  340. package/dist/node/foundation/useServerProps/index.js +5 -0
  341. package/dist/node/foundation/useSession/useSession.d.ts +2 -0
  342. package/dist/node/foundation/useSession/useSession.js +12 -0
  343. package/dist/node/foundation/useShop/index.d.ts +1 -0
  344. package/dist/node/foundation/useShop/index.js +5 -0
  345. package/dist/node/foundation/useShop/use-shop.d.ts +6 -0
  346. package/dist/node/foundation/useShop/use-shop.js +18 -0
  347. package/dist/node/foundation/useUrl/index.d.ts +1 -0
  348. package/dist/node/foundation/useUrl/index.js +5 -0
  349. package/dist/node/foundation/useUrl/useUrl.d.ts +4 -0
  350. package/dist/node/foundation/useUrl/useUrl.js +32 -0
  351. package/dist/node/framework/Hydration/rsc.js +2 -0
  352. package/dist/node/framework/plugin.js +2 -0
  353. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +5 -2
  354. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
  355. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +4 -12
  356. package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.d.ts +3 -0
  357. package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +21 -0
  358. package/dist/node/hooks/index.d.ts +6 -0
  359. package/dist/node/hooks/index.js +28 -0
  360. package/dist/node/hooks/useCart/index.d.ts +1 -0
  361. package/dist/node/hooks/useCart/index.js +5 -0
  362. package/dist/node/hooks/useCart/useCart.d.ts +4 -0
  363. package/dist/node/hooks/useCart/useCart.js +19 -0
  364. package/dist/node/hooks/useCartLine/index.d.ts +1 -0
  365. package/dist/node/hooks/useCartLine/index.js +5 -0
  366. package/dist/node/hooks/useCartLine/useCartLine.d.ts +29 -0
  367. package/dist/node/hooks/useCartLine/useCartLine.js +16 -0
  368. package/dist/node/hooks/useCountry/index.d.ts +1 -0
  369. package/dist/node/hooks/useCountry/index.js +5 -0
  370. package/dist/node/hooks/useCountry/useCountry.d.ts +7 -0
  371. package/dist/node/hooks/useCountry/useCountry.js +21 -0
  372. package/dist/node/hooks/useLoadScript/index.d.ts +1 -0
  373. package/dist/node/hooks/useLoadScript/index.js +5 -0
  374. package/dist/node/hooks/useLoadScript/useLoadScript.client.d.ts +8 -0
  375. package/dist/node/hooks/useLoadScript/useLoadScript.client.js +27 -0
  376. package/dist/node/hooks/useMeasurement/hooks.d.ts +9 -0
  377. package/dist/node/hooks/useMeasurement/hooks.js +17 -0
  378. package/dist/node/hooks/useMeasurement/index.d.ts +1 -0
  379. package/dist/node/hooks/useMeasurement/index.js +5 -0
  380. package/dist/node/hooks/useMoney/hooks.d.ts +54 -0
  381. package/dist/node/hooks/useMoney/hooks.js +70 -0
  382. package/dist/node/hooks/useMoney/index.d.ts +1 -0
  383. package/dist/node/hooks/useMoney/index.js +5 -0
  384. package/dist/node/hooks/useParsedMetafields/index.d.ts +1 -0
  385. package/dist/node/hooks/useParsedMetafields/index.js +5 -0
  386. package/dist/node/hooks/useParsedMetafields/useParsedMetafields.d.ts +21 -0
  387. package/dist/node/hooks/useParsedMetafields/useParsedMetafields.js +25 -0
  388. package/dist/node/hooks/useProductOptions/helpers.d.ts +6 -0
  389. package/dist/node/hooks/useProductOptions/helpers.js +46 -0
  390. package/dist/node/hooks/useProductOptions/index.d.ts +2 -0
  391. package/dist/node/hooks/useProductOptions/index.js +20 -0
  392. package/dist/node/hooks/useProductOptions/types.d.ts +44 -0
  393. package/dist/node/hooks/useProductOptions/types.js +2 -0
  394. package/dist/node/hooks/useProductOptions/useProductOptions.client.d.ts +1 -0
  395. package/dist/node/hooks/useProductOptions/useProductOptions.client.js +13 -0
  396. package/dist/node/hooks/useShopQuery/hooks.d.ts +28 -0
  397. package/dist/node/hooks/useShopQuery/hooks.js +171 -0
  398. package/dist/node/hooks/useShopQuery/index.d.ts +1 -0
  399. package/dist/node/hooks/useShopQuery/index.js +5 -0
  400. package/dist/node/streaming.server.d.ts +0 -1
  401. package/dist/node/streaming.server.js +1 -6
  402. package/dist/node/types.d.ts +32 -23
  403. package/dist/node/utilities/apiRoutes.d.ts +2 -2
  404. package/dist/node/utilities/devtools.d.ts +11 -0
  405. package/dist/node/utilities/devtools.js +15 -0
  406. package/dist/node/utilities/graphql-tag.d.ts +1 -0
  407. package/dist/node/utilities/graphql-tag.js +10 -0
  408. package/dist/node/utilities/graphql-tracker.d.ts +17 -0
  409. package/dist/node/utilities/graphql-tracker.js +130 -0
  410. package/dist/node/utilities/index.d.ts +1 -1
  411. package/dist/node/utilities/index.js +3 -3
  412. package/dist/node/utilities/isBrowser/index.d.ts +1 -0
  413. package/dist/node/utilities/isBrowser/index.js +5 -0
  414. package/dist/node/utilities/isBrowser/isBrowser.d.ts +4 -0
  415. package/dist/node/utilities/isBrowser/isBrowser.js +10 -0
  416. package/dist/node/utilities/isServer/isServer.js +2 -2
  417. package/dist/node/utilities/log/index.d.ts +1 -1
  418. package/dist/node/utilities/log/index.js +1 -3
  419. package/dist/node/utilities/log/log-cache-header.d.ts +4 -4
  420. package/dist/node/utilities/log/log-query-timeline.d.ts +3 -3
  421. package/dist/node/utilities/log/log.d.ts +17 -11
  422. package/dist/node/utilities/log/log.js +30 -23
  423. package/dist/node/version.d.ts +1 -1
  424. package/dist/node/version.js +1 -1
  425. package/package.json +3 -1
  426. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +203 -52
  427. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +77 -59
  428. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +30 -30
  429. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +199 -70
  430. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +38 -35
  431. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +9 -8
  432. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +3 -3
  433. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +3 -7
  434. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +204 -53
  435. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +77 -59
  436. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +199 -70
  437. package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +9 -8
  438. package/vendor/react-server-dom-vite/package.json +1 -1
  439. package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.d.ts +0 -8
  440. package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.js +0 -12
  441. package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +0 -24
  442. package/dist/esnext/components/ProductProvider/ProductProvider.client.js +0 -34
  443. package/dist/esnext/components/ProductProvider/context.d.ts +0 -29
  444. package/dist/esnext/components/ProductProvider/index.d.ts +0 -2
  445. package/dist/esnext/components/ProductProvider/index.js +0 -2
  446. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.d.ts +0 -1
  447. package/dist/esnext/framework/config.d.ts +0 -6
  448. package/dist/esnext/framework/config.js +0 -6
  449. package/dist/esnext/framework/runtime.d.ts +0 -13
  450. package/dist/esnext/framework/runtime.js +0 -27
  451. package/dist/esnext/hooks/useProduct/index.d.ts +0 -1
  452. package/dist/esnext/hooks/useProduct/index.js +0 -1
  453. package/dist/esnext/hooks/useProduct/useProduct.d.ts +0 -52
  454. package/dist/esnext/hooks/useProduct/useProduct.js +0 -43
  455. package/dist/esnext/utilities/isClient/index.d.ts +0 -1
  456. package/dist/esnext/utilities/isClient/index.js +0 -1
  457. package/dist/esnext/utilities/isClient/isClient.d.ts +0 -4
  458. package/dist/esnext/utilities/isClient/isClient.js +0 -6
  459. package/dist/node/framework/config.d.ts +0 -6
  460. package/dist/node/framework/config.js +0 -11
  461. package/dist/node/framework/runtime.d.ts +0 -13
  462. package/dist/node/framework/runtime.js +0 -35
  463. package/dist/node/utilities/defer.d.ts +0 -6
  464. package/dist/node/utilities/defer.js +0 -18
  465. package/dist/node/utilities/isClient/index.d.ts +0 -1
  466. package/dist/node/utilities/isClient/index.js +0 -5
  467. package/dist/node/utilities/isClient/isClient.d.ts +0 -4
  468. package/dist/node/utilities/isClient/isClient.js +0 -10
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { init, parse } from 'es-module-lexer';
12
12
  import MagicString from 'magic-string';
13
- import { normalizePath, transformWithEsbuild } from 'vite';
13
+ import { normalizePath, transformWithEsbuild, createServer } from 'vite';
14
14
  import { promises } from 'fs';
15
15
  import path from 'path';
16
16
 
@@ -88,59 +88,43 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
88
88
  };
89
89
  }
90
90
 
91
+ var assign = Object.assign;
92
+
91
93
  var rscViteFileRE = /\/react-server-dom-vite.js/;
92
94
  var noProxyRE = /[&?]no-proxy($|&)/;
95
+
96
+ var isClientComponent = function (id) {
97
+ return /\.client\.[jt]sx?($|\?)/.test(id);
98
+ };
99
+
93
100
  function ReactFlightVitePlugin() {
94
101
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
102
+ serverBuildEntries = _ref.serverBuildEntries,
95
103
  _ref$isServerComponen = _ref.isServerComponentImporterAllowed,
96
104
  isServerComponentImporterAllowed = _ref$isServerComponen === void 0 ? function (importer) {
97
105
  return false;
98
- } : _ref$isServerComponen,
99
- _ref$isClientComponen = _ref.isClientComponent,
100
- isClientComponent = _ref$isClientComponen === void 0 ? function (id) {
101
- return /\.client\.[jt]sx?($|\?)/.test(id);
102
- } : _ref$isClientComponen,
103
- findClientComponentsForClientBuild = _ref.findClientComponentsForClientBuild;
106
+ } : _ref$isServerComponen;
104
107
 
105
108
  var config;
106
109
  var server;
107
110
  var invalidateTimeout;
108
- var absoluteImporterPath;
111
+ var globImporterPath;
109
112
 
110
- function invalidateImporter() {
113
+ function invalidateGlobImporter() {
111
114
  clearTimeout(invalidateTimeout);
112
115
  invalidateTimeout = setTimeout(function () {
113
- return server.watcher.emit('change', absoluteImporterPath);
116
+ return server.watcher.emit('change', globImporterPath);
114
117
  }, 100);
115
118
  }
116
119
 
117
- function wrapIfClientComponent(id) {
118
- var handle = function (isClient) {
119
- if (!isClient) return null;
120
-
121
- if (server) {
122
- var moduleNode = server.moduleGraph.getModuleById(id);
123
-
124
- if (!moduleNode.__isClientComponent) {
125
- moduleNode.__isClientComponent = true;
126
- if (absoluteImporterPath) invalidateImporter();
127
- }
128
- }
129
-
130
- return proxyClientComponent(id.split('?')[0]);
131
- };
132
-
133
- var tmp = isClientComponent(id);
134
- return typeof tmp === 'boolean' ? handle(tmp) : tmp.then(handle);
135
- }
136
-
137
120
  return {
138
121
  name: 'vite-plugin-react-server-components',
139
122
  enforce: 'pre',
140
123
  configureServer: function (_server) {
141
124
  server = _server;
142
125
  },
143
- configResolved: function (_config) {
126
+ configResolved: async function (_config) {
127
+ await init;
144
128
  config = _config; // By pushing this plugin at the end of the existing array,
145
129
  // we enforce running it *after* Vite resolves import.meta.glob.
146
130
 
@@ -148,17 +132,34 @@ function ReactFlightVitePlugin() {
148
132
  },
149
133
  resolveId: function (source, importer) {
150
134
  if (!importer) return null;
135
+
136
+ if (noProxyRE.test(source)) {
137
+ var _source$split = source.split('?'),
138
+ id = _source$split[0],
139
+ query = _source$split[1];
140
+
141
+ return this.resolve(id, importer, {
142
+ skipSelf: true
143
+ }).then(function (result) {
144
+ if (!result) return null;
145
+ return assign({}, result, {
146
+ id: result.id + (query ? "?" + query : ''),
147
+ moduleSideEffects: false
148
+ });
149
+ });
150
+ }
151
151
  /**
152
152
  * Throw errors when non-Server Components try to load Server Components.
153
153
  */
154
154
 
155
+
155
156
  if (/\.server(\.[jt]sx?)?$/.test(source) && !(/(\.server\.[jt]sx?|index\.html)$/.test(importer) || isServerComponentImporterAllowed(importer, source))) {
156
157
  throw new Error("Cannot import " + source + " from \"" + importer + "\". " + 'By react-server convention, .server.js files can only be imported from other .server.js files. ' + 'That way nobody accidentally sends these to the client by indirectly importing it.');
157
158
  }
158
159
  },
159
160
  load: function (id) {
160
161
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
161
- if (!options.ssr || !shouldCheckClientComponent(id)) return;
162
+ if (!options.ssr || !isClientComponent(id) || noProxyRE.test(id)) return;
162
163
 
163
164
  if (server) {
164
165
  var mod = server.moduleGraph.idToModuleMap.get(id.replace('/@fs', ''));
@@ -171,14 +172,28 @@ function ReactFlightVitePlugin() {
171
172
  // so we don't need to create a module reference
172
173
  return;
173
174
  }
175
+ } // Mark module as a client component.
176
+
177
+
178
+ var moduleNode = server.moduleGraph.getModuleById(id);
179
+ if (!moduleNode.meta) moduleNode.meta = {};
180
+
181
+ if (!moduleNode.meta.isClientComponent) {
182
+ moduleNode.meta.isClientComponent = true;
183
+ if (globImporterPath) invalidateGlobImporter();
174
184
  }
175
185
  }
176
186
 
177
- return wrapIfClientComponent(id);
187
+ return proxyClientComponent(id.split('?')[0]);
178
188
  },
179
189
  transform: function (code, id) {
180
190
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
181
191
 
192
+ // Add more information for this module in the graph.
193
+ // It will be used later to discover client boundaries.
194
+ if (server && options.ssr && /\.[jt]sx?($|\?)/.test(id)) {
195
+ augmentModuleGraph(server.moduleGraph, id, code);
196
+ }
182
197
  /**
183
198
  * In order to allow dynamic component imports from RSC, we use Vite's import.meta.glob.
184
199
  * This hook replaces the glob placeholders with resolved paths to all client components.
@@ -188,6 +203,8 @@ function ReactFlightVitePlugin() {
188
203
  * If the paths are relative to the root instead, Vite won't add the querystring
189
204
  * and we will have duplicated files in the browser (with duplicated contexts, etc).
190
205
  */
206
+
207
+
191
208
  if (rscViteFileRE.test(id)) {
192
209
  var INJECTING_RE = /\{\s*__INJECTED_CLIENT_IMPORTERS__[:\s]*null[,\s]*\}\s*;/;
193
210
  var s = new MagicString(code);
@@ -227,16 +244,15 @@ function ReactFlightVitePlugin() {
227
244
  };
228
245
 
229
246
  if (config.command === 'serve') {
230
- absoluteImporterPath = id;
231
- return injectGlobs(findClientComponentsForDev(server));
247
+ globImporterPath = id;
248
+ return injectGlobs(findClientBoundaries(server.moduleGraph));
232
249
  }
233
250
 
234
- if (!findClientComponentsForClientBuild) {
235
- throw new Error('[react-server-dom-vite] Parameter findClientComponentsForClientBuild is required for client build');
251
+ if (!serverBuildEntries) {
252
+ throw new Error('[react-server-dom-vite] Parameter serverBuildEntries is required for client build');
236
253
  }
237
254
 
238
- var tmp = findClientComponentsForClientBuild(config);
239
- return Array.isArray(tmp) ? injectGlobs(tmp) : tmp.then(injectGlobs);
255
+ return findClientBoundariesForClientBuild(serverBuildEntries).then(injectGlobs);
240
256
  }
241
257
  }
242
258
  };
@@ -290,29 +306,31 @@ async function proxyClientComponent(filepath, src) {
290
306
  exportStatements.forEach(function (key) {
291
307
  var isDefault = key === DEFAULT_EXPORT;
292
308
  var componentName = isDefault ? getComponentFilename(filepath) : key;
293
- proxyCode += "export " + (isDefault ? DEFAULT_EXPORT : "const " + componentName + " =") + " wrapInClientProxy({ name: '" + componentName + "', id: '" + getComponentId(filepath) + "', value: allImports['" + key + "'], isDefault: " + // eslint-disable-next-line react-internal/safe-string-coercion
309
+ proxyCode += "export " + (isDefault ? DEFAULT_EXPORT : "const " + componentName + " =") + " /* @__PURE__ */wrapInClientProxy({ name: '" + componentName + "', id: '" + getComponentId(filepath) + "', value: allImports['" + key + "'], isDefault: " + // eslint-disable-next-line react-internal/safe-string-coercion
294
310
  String(isDefault) + " });\n";
295
311
  });
296
- return proxyCode;
297
- }
298
-
299
- function shouldCheckClientComponent(id) {
300
- return /\.[jt]sx?($|\?)/.test(id) && !noProxyRE.test(id);
312
+ return {
313
+ code: proxyCode,
314
+ moduleSideEffects: false
315
+ };
301
316
  }
302
317
 
303
- function findClientComponentsForDev(server) {
304
- var clientComponents = []; // eslint-disable-next-line no-for-of-loops/no-for-of-loops
318
+ function findClientBoundaries(moduleGraph) {
319
+ var clientBoundaries = []; // eslint-disable-next-line no-for-of-loops/no-for-of-loops
305
320
 
306
- var _iterator = _createForOfIteratorHelper(server.moduleGraph.fileToModulesMap.values()),
321
+ var _iterator = _createForOfIteratorHelper(moduleGraph.fileToModulesMap.values()),
307
322
  _step;
308
323
 
309
324
  try {
310
325
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
311
326
  var set = _step.value;
312
327
  var clientModule = Array.from(set).find(function (moduleNode) {
313
- return moduleNode.__isClientComponent;
328
+ return moduleNode.meta && moduleNode.meta.isClientComponent;
314
329
  });
315
- if (clientModule) clientComponents.push(clientModule.file);
330
+
331
+ if (clientModule && isDirectImportInServer(clientModule)) {
332
+ clientBoundaries.push(clientModule.file);
333
+ }
316
334
  }
317
335
  } catch (err) {
318
336
  _iterator.e(err);
@@ -320,7 +338,28 @@ function findClientComponentsForDev(server) {
320
338
  _iterator.f();
321
339
  }
322
340
 
323
- return clientComponents;
341
+ return clientBoundaries;
342
+ }
343
+
344
+ async function findClientBoundariesForClientBuild(serverEntries) {
345
+ // Viteception
346
+ var server = await createServer({
347
+ clearScreen: false,
348
+ server: {
349
+ middlewareMode: 'ssr'
350
+ }
351
+ });
352
+
353
+ try {
354
+ // Load server entries to discover client components
355
+ await Promise.all(serverEntries.map(server.ssrLoadModule));
356
+ } catch (error) {
357
+ error.message = 'Could not load server build entries: ' + error.message;
358
+ throw error;
359
+ }
360
+
361
+ await server.close();
362
+ return findClientBoundaries(server.moduleGraph);
324
363
  }
325
364
 
326
365
  var hashImportsPlugin = {
@@ -345,8 +384,120 @@ var hashImportsPlugin = {
345
384
  };
346
385
  }
347
386
  }
348
- }; // This can be used in custom findClientComponentsForClientBuild implementations
387
+ };
388
+ /**
389
+ * A client module should behave as a client boundary
390
+ * if it is imported by the server before encountering
391
+ * another boundary in the process.
392
+ * Traverse the module graph upwards to find non client
393
+ * components that import the current module.
394
+ */
395
+
396
+ function isDirectImportInServer(currentMod, originalMod) {
397
+ // TODO: this should use recursion in any module that exports
398
+ // the original one, not only in full facade files.
399
+ if (!originalMod || (currentMod.meta || {}).isFacade) {
400
+ return Array.from(currentMod.importers).some(function (importer) {
401
+ return (// eslint-disable-next-line no-unused-vars
402
+ isDirectImportInServer(importer, originalMod || currentMod)
403
+ );
404
+ });
405
+ } // Not enough information: safer to assume it is
406
+ // imported in server to create a new boundary.
407
+
408
+
409
+ if (!currentMod.meta || !originalMod.meta) return true; // If current module is a client component, stop checking
410
+ // parents since this can be the actual boundary.
411
+
412
+ if (isClientComponent(currentMod.file)) return false; // If current module is not a client component, assume
413
+ // it is a server component on a shared component
414
+ // that will be imported in the server to be safe.
415
+ // However, due to the lack of tree-shaking in the dev module graph,
416
+ // we need to manually make sure this module is importing something from
417
+ // the original module before marking it as client boundary.
418
+ // -- TODO: this only checks namedExports right now. It should
419
+ // consider default exports and variable renaming in facade modules.
420
+
421
+ return currentMod.meta.imports.some(function (imp) {
422
+ return imp.action === 'import' && (imp.from === originalMod.file || (imp.variables || []).some(function (_ref2) {
423
+ var name = _ref2[0];
424
+ return originalMod.meta.namedExports.includes(name);
425
+ }));
426
+ });
427
+ }
428
+
429
+ function resolveModPath(modPath, dirname, retryExtension) {
430
+ var absolutePath = '';
431
+
432
+ try {
433
+ absolutePath = modPath.startsWith('.') ? normalizePath(path.resolve(dirname, modPath)) : modPath;
434
+ return normalizePath(require.resolve(absolutePath + (retryExtension || '')));
435
+ } catch (error) {
436
+ if (!/\.[jt]sx?$/.test(absolutePath) && retryExtension !== '.tsx') {
437
+ // Node cannot infer .[jt]sx extensions.
438
+ // Append them here and retry a couple of times.
439
+ return resolveModPath(absolutePath, dirname, retryExtension ? '.tsx' : '.jsx');
440
+ }
441
+ }
442
+ }
443
+
444
+ function augmentModuleGraph(moduleGraph, id, code) {
445
+ var currentModule = moduleGraph.getModuleById(id);
446
+ if (!currentModule) return;
447
+
448
+ var _id$split = id.split('?'),
449
+ source = _id$split[0];
450
+
451
+ var dirname = normalizePath(path.dirname(source));
452
+
453
+ var _parse2 = parse(code),
454
+ rawImports = _parse2[0],
455
+ namedExports = _parse2[1],
456
+ isFacade = _parse2[2]; // This is currently not used but it should be considered
457
+ // to improve the crawling in `isDirectImportInServer`.
458
+
459
+
460
+ var imports = [];
461
+ rawImports.forEach(function (_ref3) {
462
+ var startMod = _ref3.s,
463
+ endMod = _ref3.e,
464
+ dynamicImportIndex = _ref3.d,
465
+ startStatement = _ref3.ss,
466
+ endStatement = _ref3.se;
467
+ if (dynamicImportIndex !== -1) return; // Skip dynamic imports for now
468
+
469
+ var modPath = code.slice(startMod, endMod);
470
+ var resolvedPath = resolveModPath(modPath.split('?')[0], dirname);
471
+ if (!resolvedPath) return; // Virtual modules or other exceptions
472
+
473
+ var _code$slice$split$0$s = code.slice(startStatement, endStatement).split(/\s+(from\s+)?['"]/m)[0].split(/\s+(.+)/m),
474
+ action = _code$slice$split$0$s[0],
475
+ _code$slice$split$0$s2 = _code$slice$split$0$s[1],
476
+ variables = _code$slice$split$0$s2 === void 0 ? '' : _code$slice$split$0$s2;
477
+
478
+ imports.push({
479
+ action: action,
480
+ // 'import' or 'export'
481
+ variables: variables // [['originalName', 'alias']]
482
+ .replace(/[{}]/gm, '').trim().split(/\s*,\s*/m).filter(Boolean).map(function (s) {
483
+ return s.split(/\s+as\s+/m);
484
+ }),
485
+ from: resolvedPath,
486
+ // '/absolute/path'
487
+ originalFrom: modPath // './path' or '3plib/subpath'
488
+
489
+ });
490
+ });
349
491
 
350
- ReactFlightVitePlugin.findClientComponentsFromServer = findClientComponentsForDev;
492
+ if (!currentModule.meta) {
493
+ currentModule.meta = {};
494
+ }
495
+
496
+ assign(currentModule.meta, {
497
+ isFacade: isFacade,
498
+ namedExports: namedExports,
499
+ imports: imports
500
+ });
501
+ }
351
502
 
352
503
  export default ReactFlightVitePlugin;
@@ -178,13 +178,15 @@ function processSymbolChunk(request, id, name) {
178
178
  // eslint-disable-next-line no-unused-vars
179
179
  var MODULE_TAG = Symbol.for('react.module.reference');
180
180
  function getModuleKey(reference) {
181
+ if (typeof reference === 'string') reference = globalThis.__STRING_REFERENCE_INDEX[reference];
181
182
  return reference.filepath + '#' + reference.name;
182
183
  }
183
- function getModuleReference(reference) {
184
- if (typeof reference === 'string') return globalThis.__STRING_REFERENCE_INDEX[reference];
185
- return reference && reference.$$typeof === MODULE_TAG ? reference : undefined;
184
+ function isModuleReference(reference) {
185
+ if (typeof reference === 'string') return !!globalThis.__STRING_REFERENCE_INDEX[reference];
186
+ return reference.$$typeof === MODULE_TAG;
186
187
  }
187
188
  function resolveModuleMetaData(config, moduleReference) {
189
+ if (typeof moduleReference === 'string') moduleReference = globalThis.__STRING_REFERENCE_INDEX[moduleReference];
188
190
  return {
189
191
  id: moduleReference.filepath,
190
192
  name: moduleReference.name
@@ -500,7 +502,7 @@ var startInlineScript = stringToPrecomputedChunk('<script>');
500
502
  var endInlineScript = stringToPrecomputedChunk('</script>');
501
503
  var startScriptSrc = stringToPrecomputedChunk('<script src="');
502
504
  var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
503
- var endAsyncScript = stringToPrecomputedChunk('" async=""></script>'); // Allows us to keep track of what we've already written so we can refer back to it.
505
+ var endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
504
506
 
505
507
  var textSeparator = stringToPrecomputedChunk('<!-- -->');
506
508
 
@@ -535,6 +537,10 @@ var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template
535
537
  var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
536
538
  var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
537
539
  var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
540
+ var clientRenderedSuspenseBoundaryError1 = stringToPrecomputedChunk('<template data-hash="');
541
+ var clientRenderedSuspenseBoundaryError1A = stringToPrecomputedChunk('" data-msg="');
542
+ var clientRenderedSuspenseBoundaryError1B = stringToPrecomputedChunk('" data-stack="');
543
+ var clientRenderedSuspenseBoundaryError2 = stringToPrecomputedChunk('"></template>');
538
544
  var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
539
545
  var startSegmentHTML2 = stringToPrecomputedChunk('">');
540
546
  var endSegmentHTML = stringToPrecomputedChunk('</div>');
@@ -564,7 +570,7 @@ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
564
570
  // const SUSPENSE_PENDING_START_DATA = '$?';
565
571
  // const SUSPENSE_FALLBACK_START_DATA = '$!';
566
572
  //
567
- // function clientRenderBoundary(suspenseBoundaryID) {
573
+ // function clientRenderBoundary(suspenseBoundaryID, errorHash, errorMsg, errorComponentStack) {
568
574
  // // Find the fallback's first element.
569
575
  // const suspenseIdNode = document.getElementById(suspenseBoundaryID);
570
576
  // if (!suspenseIdNode) {
@@ -576,6 +582,11 @@ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
576
582
  // const suspenseNode = suspenseIdNode.previousSibling;
577
583
  // // Tag it to be client rendered.
578
584
  // suspenseNode.data = SUSPENSE_FALLBACK_START_DATA;
585
+ // // assign error metadata to first sibling
586
+ // let dataset = suspenseIdNode.dataset;
587
+ // if (errorHash) dataset.hash = errorHash;
588
+ // if (errorMsg) dataset.msg = errorMsg;
589
+ // if (errorComponentStack) dataset.stack = errorComponentStack;
579
590
  // // Tell React to retry it if the parent already hydrated.
580
591
  // if (suspenseNode._reactRetry) {
581
592
  // suspenseNode._reactRetry();
@@ -659,7 +670,7 @@ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
659
670
 
660
671
  var completeSegmentFunction = 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)}';
661
672
  var completeBoundaryFunction = 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}}';
662
- var clientRenderFunction = 'function $RX(a){if(a=document.getElementById(a))a=a.previousSibling,a.data="$!",a._reactRetry&&a._reactRetry()}';
673
+ var clientRenderFunction = 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.hash=c),d&&(a.msg=d),e&&(a.stack=e),b._reactRetry&&b._reactRetry())}';
663
674
  var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegmentFunction + ';$RS("');
664
675
  var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
665
676
  var completeSegmentScript2 = stringToPrecomputedChunk('","');
@@ -670,7 +681,9 @@ var completeBoundaryScript2 = stringToPrecomputedChunk('","');
670
681
  var completeBoundaryScript3 = stringToPrecomputedChunk('")</script>');
671
682
  var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderFunction + ';$RX("');
672
683
  var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
673
- var clientRenderScript2 = stringToPrecomputedChunk('")</script>');
684
+ var clientRenderScript1A = stringToPrecomputedChunk('"');
685
+ var clientRenderScript2 = stringToPrecomputedChunk(')</script>');
686
+ var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(',');
674
687
 
675
688
  var rendererSigil;
676
689
 
@@ -998,13 +1011,13 @@ function attemptResolveElement(type, key, ref, props) {
998
1011
  throw new Error('Refs cannot be used in server components, nor passed to client components.');
999
1012
  }
1000
1013
 
1001
- if (getModuleReference(type)) {
1002
- // This is a reference to a client component.
1003
- return [REACT_ELEMENT_TYPE, type, key, props];
1004
- }
1005
-
1006
1014
  if (typeof type === 'function') {
1007
- // This is a server-side component.
1015
+ if (isModuleReference(type)) {
1016
+ // This is a reference to a client component.
1017
+ return [REACT_ELEMENT_TYPE, type, key, props];
1018
+ } // This is a server-side component.
1019
+
1020
+
1008
1021
  return type(props);
1009
1022
  } else if (typeof type === 'string') {
1010
1023
  // This is a host element. E.g. HTML.
@@ -1022,6 +1035,11 @@ function attemptResolveElement(type, key, ref, props) {
1022
1035
 
1023
1036
  return [REACT_ELEMENT_TYPE, type, key, props];
1024
1037
  } else if (type != null && typeof type === 'object') {
1038
+ if (isModuleReference(type)) {
1039
+ // This is a reference to a client component.
1040
+ return [REACT_ELEMENT_TYPE, type, key, props];
1041
+ }
1042
+
1025
1043
  switch (type.$$typeof) {
1026
1044
  case REACT_LAZY_TYPE:
1027
1045
  {
@@ -1348,59 +1366,56 @@ function resolveModelToJSON(request, parent, key, value) {
1348
1366
  }
1349
1367
  }
1350
1368
 
1351
- if (value === null) {
1352
- return null;
1369
+ if (value == null) {
1370
+ return value;
1353
1371
  }
1354
1372
 
1355
- var moduleReference = getModuleReference(value);
1356
-
1357
- if (moduleReference) {
1358
- var moduleKey = getModuleKey(moduleReference);
1359
- var writtenModules = request.writtenModules;
1360
- var existingId = writtenModules.get(moduleKey);
1361
-
1362
- if (existingId !== undefined) {
1363
- if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1364
- // If we're encoding the "type" of an element, we can refer
1365
- // to that by a lazy reference instead of directly since React
1366
- // knows how to deal with lazy values. This lets us suspend
1367
- // on this component rather than its parent until the code has
1368
- // loaded.
1369
- return serializeByRefID(existingId);
1370
- }
1371
-
1372
- return serializeByValueID(existingId);
1373
- }
1373
+ if (typeof value === 'object' || isModuleReference(value)) {
1374
+ if (isModuleReference(value)) {
1375
+ var moduleReference = value;
1376
+ var moduleKey = getModuleKey(moduleReference);
1377
+ var writtenModules = request.writtenModules;
1378
+ var existingId = writtenModules.get(moduleKey);
1379
+
1380
+ if (existingId !== undefined) {
1381
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1382
+ // If we're encoding the "type" of an element, we can refer
1383
+ // to that by a lazy reference instead of directly since React
1384
+ // knows how to deal with lazy values. This lets us suspend
1385
+ // on this component rather than its parent until the code has
1386
+ // loaded.
1387
+ return serializeByRefID(existingId);
1388
+ }
1374
1389
 
1375
- try {
1376
- var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1377
- request.pendingChunks++;
1378
- var moduleId = request.nextChunkId++;
1379
- emitModuleChunk(request, moduleId, moduleMetaData);
1380
- writtenModules.set(moduleKey, moduleId);
1381
-
1382
- if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1383
- // If we're encoding the "type" of an element, we can refer
1384
- // to that by a lazy reference instead of directly since React
1385
- // knows how to deal with lazy values. This lets us suspend
1386
- // on this component rather than its parent until the code has
1387
- // loaded.
1388
- return serializeByRefID(moduleId);
1390
+ return serializeByValueID(existingId);
1389
1391
  }
1390
1392
 
1391
- return serializeByValueID(moduleId);
1392
- } catch (x) {
1393
- request.pendingChunks++;
1393
+ try {
1394
+ var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1395
+ request.pendingChunks++;
1396
+ var moduleId = request.nextChunkId++;
1397
+ emitModuleChunk(request, moduleId, moduleMetaData);
1398
+ writtenModules.set(moduleKey, moduleId);
1399
+
1400
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1401
+ // If we're encoding the "type" of an element, we can refer
1402
+ // to that by a lazy reference instead of directly since React
1403
+ // knows how to deal with lazy values. This lets us suspend
1404
+ // on this component rather than its parent until the code has
1405
+ // loaded.
1406
+ return serializeByRefID(moduleId);
1407
+ }
1394
1408
 
1395
- var _errorId = request.nextChunkId++;
1409
+ return serializeByValueID(moduleId);
1410
+ } catch (x) {
1411
+ request.pendingChunks++;
1396
1412
 
1397
- emitErrorChunk(request, _errorId, x);
1398
- return serializeByValueID(_errorId);
1399
- }
1400
- }
1413
+ var _errorId = request.nextChunkId++;
1401
1414
 
1402
- if (typeof value === 'object') {
1403
- if (value.$$typeof === REACT_PROVIDER_TYPE) {
1415
+ emitErrorChunk(request, _errorId, x);
1416
+ return serializeByValueID(_errorId);
1417
+ }
1418
+ } else if (value.$$typeof === REACT_PROVIDER_TYPE) {
1404
1419
  var providerKey = value._context._globalName;
1405
1420
  var writtenProviders = request.writtenProviders;
1406
1421
  var providerId = writtenProviders.get(key);
@@ -1429,7 +1444,7 @@ function resolveModelToJSON(request, parent, key, value) {
1429
1444
  // Verify that this is a simple plain object.
1430
1445
  if (objectName(value) !== 'Object') {
1431
1446
  error('Only plain objects can be passed to client components from server components. ' + 'Built-ins like %s are not supported. ' + 'Remove %s from these props: %s', objectName(value), describeKeyForErrorMessage(key), describeObjectForErrorMessage(parent));
1432
- } else if (!isSimpleObject(value)) {
1447
+ } else if (typeof value === 'object' && !isSimpleObject(value)) {
1433
1448
  error('Only plain objects can be passed to client components from server components. ' + 'Classes or other objects with methods are not supported. ' + 'Remove %s from these props: %s', describeKeyForErrorMessage(key), describeObjectForErrorMessage(parent, key));
1434
1449
  } else if (Object.getOwnPropertySymbols) {
1435
1450
  var symbols = Object.getOwnPropertySymbols(value);
@@ -1738,6 +1753,9 @@ function renderToReadableStream(model, options, context) {
1738
1753
  startFlowing(request, controller);
1739
1754
  },
1740
1755
  cancel: function (reason) {}
1756
+ }, // $FlowFixMe size() methods are not allowed on byte streams.
1757
+ {
1758
+ highWaterMark: 0
1741
1759
  });
1742
1760
  return stream;
1743
1761
  }