@shopify/hydrogen 1.1.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/README.md +1 -1
  2. package/dist/esnext/FileSessionStorage.d.ts +1 -1
  3. package/dist/esnext/FileSessionStorage.js +1 -1
  4. package/dist/esnext/client.d.ts +16 -16
  5. package/dist/esnext/client.js +16 -16
  6. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +5 -2
  7. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +6 -5
  8. package/dist/esnext/components/AddToCartButton/index.d.ts +1 -1
  9. package/dist/esnext/components/AddToCartButton/index.js +1 -1
  10. package/dist/esnext/components/BaseButton/BaseButton.client.d.ts +7 -5
  11. package/dist/esnext/components/BaseButton/BaseButton.client.js +5 -4
  12. package/dist/esnext/components/BaseButton/index.d.ts +1 -1
  13. package/dist/esnext/components/BaseButton/index.js +1 -1
  14. package/dist/esnext/components/BuyNowButton/BuyNowButton.client.d.ts +3 -2
  15. package/dist/esnext/components/BuyNowButton/BuyNowButton.client.js +2 -2
  16. package/dist/esnext/components/BuyNowButton/index.d.ts +1 -1
  17. package/dist/esnext/components/BuyNowButton/index.js +1 -1
  18. package/dist/esnext/components/CartCheckoutButton/CartCheckoutButton.client.js +1 -1
  19. package/dist/esnext/components/CartCheckoutButton/index.d.ts +1 -1
  20. package/dist/esnext/components/CartCheckoutButton/index.js +1 -1
  21. package/dist/esnext/components/CartCost/CartCost.client.d.ts +1 -1
  22. package/dist/esnext/components/CartCost/CartCost.client.js +2 -2
  23. package/dist/esnext/components/CartCost/index.d.ts +1 -1
  24. package/dist/esnext/components/CartCost/index.js +1 -1
  25. package/dist/esnext/components/CartLineImage/CartLineImage.client.d.ts +1 -1
  26. package/dist/esnext/components/CartLineImage/CartLineImage.client.js +2 -2
  27. package/dist/esnext/components/CartLineImage/index.d.ts +1 -1
  28. package/dist/esnext/components/CartLineImage/index.js +1 -1
  29. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +1 -1
  30. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +2 -2
  31. package/dist/esnext/components/CartLinePrice/index.d.ts +1 -1
  32. package/dist/esnext/components/CartLinePrice/index.js +1 -1
  33. package/dist/esnext/components/CartLineProductTitle/CartLineProductTitle.client.js +1 -1
  34. package/dist/esnext/components/CartLineProductTitle/index.d.ts +1 -1
  35. package/dist/esnext/components/CartLineProductTitle/index.js +1 -1
  36. package/dist/esnext/components/CartLineProvider/CartLineProvider.client.d.ts +1 -1
  37. package/dist/esnext/components/CartLineProvider/CartLineProvider.client.js +1 -1
  38. package/dist/esnext/components/CartLineProvider/context.d.ts +13 -13
  39. package/dist/esnext/components/CartLineProvider/index.d.ts +2 -2
  40. package/dist/esnext/components/CartLineProvider/index.js +2 -2
  41. package/dist/esnext/components/CartLineQuantity/CartLineQuantity.client.js +1 -1
  42. package/dist/esnext/components/CartLineQuantity/index.d.ts +1 -1
  43. package/dist/esnext/components/CartLineQuantity/index.js +1 -1
  44. package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +7 -8
  45. package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +3 -3
  46. package/dist/esnext/components/CartLineQuantityAdjustButton/index.d.ts +1 -1
  47. package/dist/esnext/components/CartLineQuantityAdjustButton/index.js +1 -1
  48. package/dist/esnext/components/CartLines/CartLines.client.d.ts +1 -1
  49. package/dist/esnext/components/CartLines/CartLines.client.js +2 -2
  50. package/dist/esnext/components/CartLines/index.d.ts +1 -1
  51. package/dist/esnext/components/CartLines/index.js +1 -1
  52. package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +2 -2
  53. package/dist/esnext/components/CartProvider/CartProvider.client.js +13 -7
  54. package/dist/esnext/components/CartProvider/cart-queries.d.ts +1 -1
  55. package/dist/esnext/components/CartProvider/cart-queries.js +1 -0
  56. package/dist/esnext/components/CartProvider/context.d.ts +1 -1
  57. package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +1 -1
  58. package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +1 -1
  59. package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +1 -1
  60. package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +1 -1
  61. package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +1 -1
  62. package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +1 -1
  63. package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +1 -1
  64. package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +1 -1
  65. package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +1 -1
  66. package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +1 -1
  67. package/dist/esnext/components/CartProvider/hooks.client.d.ts +2 -2
  68. package/dist/esnext/components/CartProvider/hooks.client.js +4 -4
  69. package/dist/esnext/components/CartProvider/index.d.ts +4 -4
  70. package/dist/esnext/components/CartProvider/index.js +3 -3
  71. package/dist/esnext/components/CartProvider/types.d.ts +2 -2
  72. package/dist/esnext/components/CartShopPayButton/CartShopPayButton.client.d.ts +1 -1
  73. package/dist/esnext/components/CartShopPayButton/CartShopPayButton.client.js +2 -2
  74. package/dist/esnext/components/CartShopPayButton/index.d.ts +1 -1
  75. package/dist/esnext/components/CartShopPayButton/index.js +1 -1
  76. package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +2 -2
  77. package/dist/esnext/components/ExternalVideo/ExternalVideo.js +3 -3
  78. package/dist/esnext/components/ExternalVideo/index.d.ts +1 -1
  79. package/dist/esnext/components/ExternalVideo/index.js +1 -1
  80. package/dist/esnext/components/Image/Image.d.ts +2 -2
  81. package/dist/esnext/components/Image/Image.js +5 -5
  82. package/dist/esnext/components/Image/index.d.ts +2 -2
  83. package/dist/esnext/components/Image/index.js +1 -1
  84. package/dist/esnext/components/Link/Link.client.js +5 -5
  85. package/dist/esnext/components/Link/index.d.ts +1 -1
  86. package/dist/esnext/components/Link/index.js +1 -1
  87. package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +1 -1
  88. package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +1 -1
  89. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +1 -1
  90. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +5 -5
  91. package/dist/esnext/components/LocalizationProvider/index.d.ts +1 -1
  92. package/dist/esnext/components/LocalizationProvider/index.js +1 -1
  93. package/dist/esnext/components/MediaFile/MediaFile.d.ts +4 -4
  94. package/dist/esnext/components/MediaFile/MediaFile.js +4 -4
  95. package/dist/esnext/components/MediaFile/index.d.ts +1 -1
  96. package/dist/esnext/components/MediaFile/index.js +1 -1
  97. package/dist/esnext/components/Metafield/Metafield.client.d.ts +2 -2
  98. package/dist/esnext/components/Metafield/Metafield.client.js +6 -6
  99. package/dist/esnext/components/Metafield/components/StarRating/StarRating.d.ts +1 -1
  100. package/dist/esnext/components/Metafield/components/StarRating/index.d.ts +1 -1
  101. package/dist/esnext/components/Metafield/components/StarRating/index.js +1 -1
  102. package/dist/esnext/components/Metafield/components/index.d.ts +1 -1
  103. package/dist/esnext/components/Metafield/components/index.js +1 -1
  104. package/dist/esnext/components/Metafield/index.d.ts +2 -2
  105. package/dist/esnext/components/Metafield/index.js +1 -1
  106. package/dist/esnext/components/Metafield/types.d.ts +1 -1
  107. package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +2 -2
  108. package/dist/esnext/components/ModelViewer/ModelViewer.client.js +1 -1
  109. package/dist/esnext/components/ModelViewer/index.d.ts +1 -1
  110. package/dist/esnext/components/ModelViewer/index.js +1 -1
  111. package/dist/esnext/components/Money/Money.client.d.ts +1 -1
  112. package/dist/esnext/components/Money/Money.client.js +1 -1
  113. package/dist/esnext/components/Money/index.d.ts +1 -1
  114. package/dist/esnext/components/Money/index.js +1 -1
  115. package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +1 -1
  116. package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +3 -3
  117. package/dist/esnext/components/ProductOptionsProvider/context.d.ts +1 -1
  118. package/dist/esnext/components/ProductOptionsProvider/index.d.ts +1 -1
  119. package/dist/esnext/components/ProductOptionsProvider/index.js +1 -1
  120. package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +2 -2
  121. package/dist/esnext/components/ProductPrice/ProductPrice.client.js +2 -2
  122. package/dist/esnext/components/ProductPrice/index.d.ts +1 -1
  123. package/dist/esnext/components/ProductPrice/index.js +1 -1
  124. package/dist/esnext/components/Seo/CollectionSeo.client.d.ts +1 -1
  125. package/dist/esnext/components/Seo/CollectionSeo.client.js +4 -4
  126. package/dist/esnext/components/Seo/DefaultPageSeo.client.d.ts +1 -1
  127. package/dist/esnext/components/Seo/DefaultPageSeo.client.js +5 -5
  128. package/dist/esnext/components/Seo/DescriptionSeo.client.d.ts +1 -1
  129. package/dist/esnext/components/Seo/DescriptionSeo.client.js +1 -1
  130. package/dist/esnext/components/Seo/HomePageSeo.client.d.ts +1 -1
  131. package/dist/esnext/components/Seo/HomePageSeo.client.js +3 -3
  132. package/dist/esnext/components/Seo/ImageSeo.client.d.ts +1 -1
  133. package/dist/esnext/components/Seo/ImageSeo.client.js +1 -1
  134. package/dist/esnext/components/Seo/NoIndexSeo.client.d.ts +1 -1
  135. package/dist/esnext/components/Seo/NoIndexSeo.client.js +2 -2
  136. package/dist/esnext/components/Seo/PageSeo.client.d.ts +1 -1
  137. package/dist/esnext/components/Seo/PageSeo.client.js +3 -3
  138. package/dist/esnext/components/Seo/ProductSeo.client.d.ts +1 -1
  139. package/dist/esnext/components/Seo/ProductSeo.client.js +6 -6
  140. package/dist/esnext/components/Seo/Seo.client.d.ts +4 -4
  141. package/dist/esnext/components/Seo/Seo.client.js +7 -7
  142. package/dist/esnext/components/Seo/TitleSeo.client.d.ts +1 -1
  143. package/dist/esnext/components/Seo/TitleSeo.client.js +1 -1
  144. package/dist/esnext/components/Seo/TwitterSeo.client.d.ts +1 -1
  145. package/dist/esnext/components/Seo/TwitterSeo.client.js +1 -1
  146. package/dist/esnext/components/Seo/index.d.ts +1 -1
  147. package/dist/esnext/components/Seo/index.js +1 -1
  148. package/dist/esnext/components/Seo/seo-types.d.ts +1 -1
  149. package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +2 -2
  150. package/dist/esnext/components/ShopPayButton/index.d.ts +1 -1
  151. package/dist/esnext/components/ShopPayButton/index.js +1 -1
  152. package/dist/esnext/components/Video/Video.d.ts +7 -2
  153. package/dist/esnext/components/Video/Video.js +3 -3
  154. package/dist/esnext/components/Video/index.d.ts +1 -1
  155. package/dist/esnext/components/Video/index.js +1 -1
  156. package/dist/esnext/components/index.d.ts +27 -27
  157. package/dist/esnext/components/index.js +25 -25
  158. package/dist/esnext/config.d.ts +5 -5
  159. package/dist/esnext/config.js +4 -4
  160. package/dist/esnext/constants.d.ts +1 -0
  161. package/dist/esnext/constants.js +1 -0
  162. package/dist/esnext/entry-client.d.ts +1 -1
  163. package/dist/esnext/entry-client.js +35 -14
  164. package/dist/esnext/entry-server.d.ts +1 -1
  165. package/dist/esnext/entry-server.js +76 -51
  166. package/dist/esnext/experimental.d.ts +2 -0
  167. package/dist/esnext/experimental.js +2 -0
  168. package/dist/esnext/foundation/Analytics/Analytics.client.js +1 -1
  169. package/dist/esnext/foundation/Analytics/Analytics.server.js +5 -5
  170. package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +1 -1
  171. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +4 -4
  172. package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.d.ts +1 -1
  173. package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.js +1 -1
  174. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +3 -3
  175. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +1 -1
  176. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.js +1 -1
  177. package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.js +1 -1
  178. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.js +3 -3
  179. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.js +9 -9
  180. package/dist/esnext/foundation/Analytics/hook.js +2 -2
  181. package/dist/esnext/foundation/Analytics/index.d.ts +1 -1
  182. package/dist/esnext/foundation/Analytics/index.js +1 -1
  183. package/dist/esnext/foundation/Analytics/utils.js +1 -1
  184. package/dist/esnext/foundation/BuiltInRoutes/BuiltInRoutes.d.ts +1 -1
  185. package/dist/esnext/foundation/BuiltInRoutes/BuiltInRoutes.js +3 -3
  186. package/dist/esnext/foundation/Cache/cache-sub-request.d.ts +1 -1
  187. package/dist/esnext/foundation/Cache/cache-sub-request.js +4 -4
  188. package/dist/esnext/foundation/Cache/cache.d.ts +1 -1
  189. package/dist/esnext/foundation/Cache/cache.js +3 -4
  190. package/dist/esnext/foundation/Cache/strategies/index.d.ts +1 -1
  191. package/dist/esnext/foundation/Cookie/Cookie.js +2 -2
  192. package/dist/esnext/foundation/CookieSessionStorage/CookieSessionStorage.d.ts +2 -2
  193. package/dist/esnext/foundation/CookieSessionStorage/CookieSessionStorage.js +2 -1
  194. package/dist/esnext/foundation/DevTools/DevTools.client.js +1 -1
  195. package/dist/esnext/foundation/DevTools/DevTools.server.js +4 -3
  196. package/dist/esnext/foundation/DevTools/components/Interface.client.js +1 -1
  197. package/dist/esnext/foundation/DevTools/components/Panels.d.ts +2 -2
  198. package/dist/esnext/foundation/DevTools/components/Panels.js +3 -3
  199. package/dist/esnext/foundation/DevTools/components/Performance.client.js +1 -1
  200. package/dist/esnext/foundation/DevTools/components/Settings.client.d.ts +2 -1
  201. package/dist/esnext/foundation/DevTools/components/Settings.client.js +1 -1
  202. package/dist/esnext/foundation/DevTools/components/index.d.ts +2 -2
  203. package/dist/esnext/foundation/DevTools/components/index.js +2 -2
  204. package/dist/esnext/foundation/FileRoutes/FileRoutes.server.d.ts +1 -1
  205. package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +5 -5
  206. package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.d.ts +3 -3
  207. package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.js +2 -2
  208. package/dist/esnext/foundation/Form/Form.client.d.ts +11 -0
  209. package/dist/esnext/foundation/Form/Form.client.js +51 -0
  210. package/dist/esnext/foundation/Head/Head.client.js +1 -1
  211. package/dist/esnext/foundation/Head/index.d.ts +1 -1
  212. package/dist/esnext/foundation/Head/index.js +1 -1
  213. package/dist/esnext/foundation/Html/Html.d.ts +1 -1
  214. package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts +6 -5
  215. package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.js +5 -4
  216. package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +2 -4
  217. package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.js +4 -18
  218. package/dist/esnext/foundation/MemorySessionStorage/MemorySessionStorage.d.ts +2 -2
  219. package/dist/esnext/foundation/MemorySessionStorage/MemorySessionStorage.js +1 -1
  220. package/dist/esnext/foundation/Redirect/Redirect.client.js +1 -1
  221. package/dist/esnext/foundation/Route/Route.server.js +3 -3
  222. package/dist/esnext/foundation/Router/BrowserRouter.client.js +2 -2
  223. package/dist/esnext/foundation/Router/Router.server.js +1 -1
  224. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +3 -1
  225. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +4 -4
  226. package/dist/esnext/foundation/ServerPropsProvider/index.d.ts +1 -1
  227. package/dist/esnext/foundation/ServerPropsProvider/index.js +1 -1
  228. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +2 -2
  229. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +3 -3
  230. package/dist/esnext/foundation/ServerRequestProvider/index.d.ts +1 -1
  231. package/dist/esnext/foundation/ServerRequestProvider/index.js +1 -1
  232. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +1 -1
  233. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.d.ts +2 -2
  234. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +7 -6
  235. package/dist/esnext/foundation/ShopifyProvider/index.d.ts +1 -1
  236. package/dist/esnext/foundation/ShopifyProvider/index.js +1 -1
  237. package/dist/esnext/foundation/ShopifyProvider/types.d.ts +4 -3
  238. package/dist/esnext/foundation/fetchSync/ResponseSync.js +2 -2
  239. package/dist/esnext/foundation/fetchSync/client/fetchSync.d.ts +1 -1
  240. package/dist/esnext/foundation/fetchSync/client/fetchSync.js +2 -2
  241. package/dist/esnext/foundation/fetchSync/server/fetchSync.d.ts +2 -2
  242. package/dist/esnext/foundation/fetchSync/server/fetchSync.js +3 -3
  243. package/dist/esnext/foundation/index.d.ts +3 -3
  244. package/dist/esnext/foundation/index.js +3 -3
  245. package/dist/esnext/foundation/session/session-types.d.ts +15 -0
  246. package/dist/esnext/foundation/session/session-types.js +1 -0
  247. package/dist/esnext/foundation/session/session.d.ts +7 -16
  248. package/dist/esnext/foundation/session/session.js +17 -1
  249. package/dist/esnext/foundation/ssr-interop.d.ts +2 -2
  250. package/dist/esnext/foundation/ssr-interop.js +2 -2
  251. package/dist/esnext/foundation/useNavigate/useNavigate.js +2 -2
  252. package/dist/esnext/foundation/useQuery/hooks.d.ts +4 -1
  253. package/dist/esnext/foundation/useQuery/hooks.js +5 -5
  254. package/dist/esnext/foundation/useQuery/index.d.ts +1 -1
  255. package/dist/esnext/foundation/useQuery/index.js +1 -1
  256. package/dist/esnext/foundation/useRequestContext/index.js +1 -1
  257. package/dist/esnext/foundation/useRouteParams/useRouteParams.js +2 -2
  258. package/dist/esnext/foundation/useServerProps/index.d.ts +1 -1
  259. package/dist/esnext/foundation/useServerProps/index.js +1 -1
  260. package/dist/esnext/foundation/useServerProps/use-server-props.d.ts +1 -1
  261. package/dist/esnext/foundation/useServerProps/use-server-props.js +1 -1
  262. package/dist/esnext/foundation/useSession/useSession.d.ts +1 -0
  263. package/dist/esnext/foundation/useSession/useSession.js +14 -1
  264. package/dist/esnext/foundation/useShop/index.d.ts +1 -1
  265. package/dist/esnext/foundation/useShop/index.js +1 -1
  266. package/dist/esnext/foundation/useShop/use-shop.d.ts +1 -1
  267. package/dist/esnext/foundation/useShop/use-shop.js +2 -2
  268. package/dist/esnext/foundation/useUrl/index.d.ts +1 -1
  269. package/dist/esnext/foundation/useUrl/index.js +1 -1
  270. package/dist/esnext/foundation/useUrl/useUrl.js +4 -4
  271. package/dist/esnext/framework/load-config.js +2 -2
  272. package/dist/esnext/framework/middleware.d.ts +1 -1
  273. package/dist/esnext/framework/middleware.js +2 -2
  274. package/dist/esnext/framework/plugin.d.ts +1 -1
  275. package/dist/esnext/framework/plugin.js +17 -15
  276. package/dist/esnext/framework/plugins/vite-plugin-assets-version.d.ts +2 -0
  277. package/dist/esnext/framework/plugins/vite-plugin-assets-version.js +8 -0
  278. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +1 -1
  279. package/dist/esnext/framework/plugins/vite-plugin-css-rsc.d.ts +2 -0
  280. package/dist/esnext/framework/plugins/vite-plugin-css-rsc.js +108 -0
  281. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.d.ts +2 -1
  282. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +8 -4
  283. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
  284. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +3 -3
  285. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -1
  286. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +2 -2
  287. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +1 -1
  288. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +35 -7
  289. package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +1 -1
  290. package/dist/esnext/framework/types.d.ts +14 -0
  291. package/dist/esnext/hooks/index.d.ts +6 -6
  292. package/dist/esnext/hooks/index.js +6 -6
  293. package/dist/esnext/hooks/useCart/index.d.ts +1 -1
  294. package/dist/esnext/hooks/useCart/index.js +1 -1
  295. package/dist/esnext/hooks/useCart/useCart.d.ts +1 -1
  296. package/dist/esnext/hooks/useCart/useCart.js +1 -1
  297. package/dist/esnext/hooks/useCartLine/index.d.ts +1 -1
  298. package/dist/esnext/hooks/useCartLine/index.js +1 -1
  299. package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +13 -13
  300. package/dist/esnext/hooks/useCartLine/useCartLine.js +1 -1
  301. package/dist/esnext/hooks/useLoadScript/index.d.ts +1 -1
  302. package/dist/esnext/hooks/useLoadScript/index.js +1 -1
  303. package/dist/esnext/hooks/useLoadScript/useLoadScript.client.d.ts +1 -1
  304. package/dist/esnext/hooks/useLoadScript/useLoadScript.client.js +1 -1
  305. package/dist/esnext/hooks/useLocalization/useLocalization.d.ts +2 -3
  306. package/dist/esnext/hooks/useLocalization/useLocalization.js +2 -2
  307. package/dist/esnext/hooks/useMeasurement/hooks.d.ts +1 -1
  308. package/dist/esnext/hooks/useMeasurement/hooks.js +2 -2
  309. package/dist/esnext/hooks/useMeasurement/index.d.ts +1 -1
  310. package/dist/esnext/hooks/useMeasurement/index.js +1 -1
  311. package/dist/esnext/hooks/useMoney/hooks.d.ts +1 -1
  312. package/dist/esnext/hooks/useMoney/hooks.js +1 -1
  313. package/dist/esnext/hooks/useMoney/index.d.ts +1 -1
  314. package/dist/esnext/hooks/useMoney/index.js +1 -1
  315. package/dist/esnext/hooks/useProductOptions/helpers.d.ts +2 -2
  316. package/dist/esnext/hooks/useProductOptions/index.d.ts +2 -2
  317. package/dist/esnext/hooks/useProductOptions/index.js +2 -2
  318. package/dist/esnext/hooks/useProductOptions/types.d.ts +1 -1
  319. package/dist/esnext/hooks/useProductOptions/useProductOptions.client.d.ts +1 -1
  320. package/dist/esnext/hooks/useProductOptions/useProductOptions.client.js +1 -1
  321. package/dist/esnext/hooks/useShopQuery/hooks.d.ts +1 -1
  322. package/dist/esnext/hooks/useShopQuery/hooks.js +16 -11
  323. package/dist/esnext/hooks/useShopQuery/index.d.ts +1 -1
  324. package/dist/esnext/hooks/useShopQuery/index.js +1 -1
  325. package/dist/esnext/index.d.ts +26 -26
  326. package/dist/esnext/index.js +22 -22
  327. package/dist/esnext/node.d.ts +1 -1
  328. package/dist/esnext/node.js +1 -1
  329. package/dist/esnext/platforms/index.d.ts +1 -1
  330. package/dist/esnext/platforms/index.js +1 -1
  331. package/dist/esnext/platforms/node.d.ts +1 -1
  332. package/dist/esnext/platforms/node.js +4 -4
  333. package/dist/esnext/platforms/virtual.d.ts +1 -1
  334. package/dist/esnext/platforms/virtual.js +0 -2
  335. package/dist/esnext/platforms/worker-event.js +1 -1
  336. package/dist/esnext/platforms/worker.js +1 -1
  337. package/dist/esnext/shared-types.d.ts +3 -0
  338. package/dist/esnext/storefront-api-types.d.ts +38 -31
  339. package/dist/esnext/storefront-api-types.js +4 -2
  340. package/dist/esnext/types.d.ts +8 -7
  341. package/dist/esnext/types.js +1 -1
  342. package/dist/esnext/utilities/apiRoutes.d.ts +4 -4
  343. package/dist/esnext/utilities/apiRoutes.js +51 -6
  344. package/dist/esnext/utilities/error.js +1 -1
  345. package/dist/esnext/utilities/fetch.js +5 -2
  346. package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +1 -1
  347. package/dist/esnext/utilities/flattenConnection/index.d.ts +1 -1
  348. package/dist/esnext/utilities/flattenConnection/index.js +1 -1
  349. package/dist/esnext/utilities/hash.d.ts +1 -1
  350. package/dist/esnext/utilities/hash.js +1 -1
  351. package/dist/esnext/utilities/image_size.d.ts +1 -1
  352. package/dist/esnext/utilities/index.d.ts +12 -12
  353. package/dist/esnext/utilities/index.js +12 -12
  354. package/dist/esnext/utilities/isBrowser/index.d.ts +1 -1
  355. package/dist/esnext/utilities/isBrowser/index.js +1 -1
  356. package/dist/esnext/utilities/isServer/index.d.ts +1 -1
  357. package/dist/esnext/utilities/isServer/index.js +1 -1
  358. package/dist/esnext/utilities/isServer/isServer.js +1 -1
  359. package/dist/esnext/utilities/load_script.d.ts +1 -0
  360. package/dist/esnext/utilities/load_script.js +6 -1
  361. package/dist/esnext/utilities/locale/index.d.ts +1 -0
  362. package/dist/esnext/utilities/locale/index.js +1 -0
  363. package/dist/esnext/utilities/locale/locale.d.ts +7 -0
  364. package/dist/esnext/utilities/locale/locale.js +22 -0
  365. package/dist/esnext/utilities/log/index.d.ts +4 -4
  366. package/dist/esnext/utilities/log/index.js +4 -4
  367. package/dist/esnext/utilities/log/log-cache-api-status.js +1 -1
  368. package/dist/esnext/utilities/log/log-cache-header.d.ts +4 -4
  369. package/dist/esnext/utilities/log/log-cache-header.js +3 -3
  370. package/dist/esnext/utilities/log/log-query-timeline.d.ts +3 -3
  371. package/dist/esnext/utilities/log/log-query-timeline.js +13 -10
  372. package/dist/esnext/utilities/log/log.d.ts +1 -1
  373. package/dist/esnext/utilities/log/log.js +10 -4
  374. package/dist/esnext/utilities/log/utils.d.ts +1 -1
  375. package/dist/esnext/utilities/log/utils.js +1 -1
  376. package/dist/esnext/utilities/measurement.d.ts +1 -1
  377. package/dist/esnext/utilities/parseMetafield/index.d.ts +1 -1
  378. package/dist/esnext/utilities/parseMetafield/index.js +1 -1
  379. package/dist/esnext/utilities/parseMetafield/parseMetafield.d.ts +2 -2
  380. package/dist/esnext/utilities/parseMetafield/parseMetafield.js +1 -1
  381. package/dist/esnext/utilities/storefrontApi.js +1 -1
  382. package/dist/esnext/utilities/suspense.d.ts +1 -1
  383. package/dist/esnext/utilities/suspense.js +1 -1
  384. package/dist/esnext/version.d.ts +1 -1
  385. package/dist/esnext/version.js +1 -1
  386. package/dist/node/foundation/session/session-types.d.ts +15 -0
  387. package/dist/node/foundation/session/session-types.js +2 -0
  388. package/dist/node/framework/load-config.js +3 -3
  389. package/dist/node/framework/middleware.d.ts +1 -1
  390. package/dist/node/framework/middleware.js +3 -3
  391. package/dist/node/framework/plugin.d.ts +1 -1
  392. package/dist/node/framework/plugin.js +26 -24
  393. package/dist/node/framework/plugins/vite-plugin-assets-version.d.ts +2 -0
  394. package/dist/node/framework/plugins/vite-plugin-assets-version.js +11 -0
  395. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +3 -3
  396. package/dist/node/framework/plugins/vite-plugin-css-rsc.d.ts +2 -0
  397. package/dist/node/framework/plugins/vite-plugin-css-rsc.js +114 -0
  398. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.d.ts +2 -1
  399. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +11 -4
  400. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
  401. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +7 -7
  402. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -1
  403. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +5 -5
  404. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +1 -1
  405. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +35 -7
  406. package/dist/node/framework/plugins/vite-plugin-platform-entry.js +2 -2
  407. package/dist/node/framework/types.d.ts +14 -0
  408. package/dist/node/shared-types.d.ts +3 -0
  409. package/package.json +15 -3
  410. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +10 -2
  411. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +10 -2
  412. package/dist/esnext/framework/plugins/vite-plugin-purge-query-cache.d.ts +0 -3
  413. package/dist/esnext/framework/plugins/vite-plugin-purge-query-cache.js +0 -11
  414. package/dist/node/framework/plugins/vite-plugin-purge-query-cache.d.ts +0 -3
  415. package/dist/node/framework/plugins/vite-plugin-purge-query-cache.js +0 -16
@@ -5,7 +5,7 @@
5
5
  * NOTE: Do not remove SSR-prefixed comments in this file.
6
6
  */
7
7
  import { useContext } from 'react';
8
- //@SSR import {useServerRequest} from './ServerRequestProvider';
8
+ //@SSR import {useServerRequest} from './ServerRequestProvider/index.js';
9
9
  // This is replaced by Vite to import.meta.env.SSR
10
10
  export const META_ENV_SSR = false;
11
11
  const reactContextType = Symbol.for('react.context');
@@ -23,7 +23,7 @@ const reactContextType = Symbol.for('react.context');
23
23
  * The returned type depends on what the server getter returns.
24
24
  * @example
25
25
  * ```js
26
- * import {MyClientContext} from './my-client-react-context-provider';
26
+ * import {MyClientContext} from './my-client-react-context-provider.js';
27
27
  * useEnvContext(req => req.ctx.myServerContext, MyClientContext)
28
28
  * ```
29
29
  */
@@ -1,5 +1,5 @@
1
- import { useRouter } from '../Router/BrowserRouter.client';
2
- import { useBasePath } from '../useRouteParams/RouteParamsProvider.client';
1
+ import { useRouter } from '../Router/BrowserRouter.client.js';
2
+ import { useBasePath } from '../useRouteParams/RouteParamsProvider.client.js';
3
3
  /**
4
4
  * The useNavigate hook imperatively navigates between routes.
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { CachingStrategy, PreloadOptions, QueryKey } from '../../types';
1
+ import type { CachingStrategy, PreloadOptions, QueryKey } from '../../types.js';
2
2
  export interface HydrogenUseQueryOptions {
3
3
  /** The [caching strategy](https://shopify.dev/custom-storefronts/hydrogen/framework/cache#caching-strategies) to help you
4
4
  * determine which cache control header to set.
@@ -13,6 +13,9 @@ export interface HydrogenUseQueryOptions {
13
13
  */
14
14
  shouldCacheResponse?: (body: any) => boolean;
15
15
  }
16
+ declare global {
17
+ var __HYDROGEN_CACHE_ID__: string;
18
+ }
16
19
  /**
17
20
  * The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
18
21
  * supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
@@ -1,7 +1,7 @@
1
- import { getLoggerWithContext, collectQueryCacheControlHeaders, collectQueryTimings, } from '../../utilities/log';
2
- import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '../Cache/cache-sub-request';
3
- import { useRequestCacheData, useServerRequest } from '../ServerRequestProvider';
4
- import { CacheShort, NO_STORE } from '../Cache/strategies';
1
+ import { getLoggerWithContext, collectQueryCacheControlHeaders, collectQueryTimings, } from '../../utilities/log/index.js';
2
+ import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '../Cache/cache-sub-request.js';
3
+ import { useRequestCacheData, useServerRequest, } from '../ServerRequestProvider/index.js';
4
+ import { CacheShort, NO_STORE } from '../Cache/strategies/index.js';
5
5
  /**
6
6
  * The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
7
7
  * supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
@@ -19,7 +19,7 @@ queryFn,
19
19
  queryOptions) {
20
20
  const request = useServerRequest();
21
21
  const withCacheIdKey = [
22
- '__QUERY_CACHE_ID__',
22
+ __HYDROGEN_CACHE_ID__,
23
23
  ...(typeof key === 'string' ? [key] : key),
24
24
  ];
25
25
  const fetcher = cachedQueryFnBuilder(withCacheIdKey, queryFn, queryOptions);
@@ -1 +1 @@
1
- export { useQuery } from './hooks';
1
+ export { useQuery, type HydrogenUseQueryOptions, shouldPreloadQuery, } from './hooks.js';
@@ -1 +1 @@
1
- export { useQuery } from './hooks';
1
+ export { useQuery, shouldPreloadQuery, } from './hooks.js';
@@ -1,4 +1,4 @@
1
- import { META_ENV_SSR, useEnvContext } from '../ssr-interop';
1
+ import { META_ENV_SSR, useEnvContext } from '../ssr-interop.js';
2
2
  /**
3
3
  * Provides access to the current request context.
4
4
  * @param scope - An optional string used to scope the request context. It is recommended to
@@ -1,5 +1,5 @@
1
- import { useEnvContext } from '../ssr-interop';
2
- import { RouteParamsContext } from './RouteParamsProvider.client';
1
+ import { useEnvContext } from '../ssr-interop.js';
2
+ import { RouteParamsContext } from './RouteParamsProvider.client.js';
3
3
  /**
4
4
  * The `useRouteParams` hook retrieves the parameters of an active route. The hook is available in both server and client components.
5
5
  */
@@ -1 +1 @@
1
- export { useServerProps } from './use-server-props';
1
+ export { useServerProps } from './use-server-props.js';
@@ -1 +1 @@
1
- export { useServerProps } from './use-server-props';
1
+ export { useServerProps } from './use-server-props.js';
@@ -1,4 +1,4 @@
1
- import { ServerPropsContextValue, InternalServerPropsContextValue } from '../ServerPropsProvider/ServerPropsProvider';
1
+ import { ServerPropsContextValue, InternalServerPropsContextValue } from '../ServerPropsProvider/ServerPropsProvider.js';
2
2
  /**
3
3
  * The `useServerProps` hook allows you to manage the [server props](https://shopify.dev/custom-storefronts/hydrogen/framework/server-props) passed to your server components when using Hydrogen as a React Server Component framework. The server props get cleared when you navigate from one route to another.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { useContext } from 'react';
2
- import { ServerPropsContext, } from '../ServerPropsProvider/ServerPropsProvider';
2
+ import { ServerPropsContext, } from '../ServerPropsProvider/ServerPropsProvider.js';
3
3
  /**
4
4
  * The `useServerProps` hook allows you to manage the [server props](https://shopify.dev/custom-storefronts/hydrogen/framework/server-props) passed to your server components when using Hydrogen as a React Server Component framework. The server props get cleared when you navigate from one route to another.
5
5
  *
@@ -1,2 +1,3 @@
1
1
  /** The `useSession` hook reads session data in server components. */
2
2
  export declare const useSession: () => Record<string, string>;
3
+ export declare const useFlashSession: (key: string) => string;
@@ -1,7 +1,20 @@
1
- import { useServerRequest } from '../ServerRequestProvider';
1
+ import { useServerRequest } from '../ServerRequestProvider/index.js';
2
2
  /** The `useSession` hook reads session data in server components. */
3
3
  export const useSession = function () {
4
4
  const request = useServerRequest();
5
5
  const session = request.ctx.session?.get() || {};
6
6
  return session;
7
7
  };
8
+ export const useFlashSession = function (key) {
9
+ const request = useServerRequest();
10
+ const data = request.ctx.session?.get() || {};
11
+ let value = data[key];
12
+ if (value) {
13
+ delete data[key];
14
+ request.ctx.flashSession[key] = value;
15
+ }
16
+ request.ctx.session?.set(data);
17
+ value = request.ctx.flashSession[key];
18
+ delete request.ctx.flashSession[key];
19
+ return value;
20
+ };
@@ -1 +1 @@
1
- export { useShop } from './use-shop';
1
+ export { useShop } from './use-shop.js';
@@ -1 +1 @@
1
- export { useShop } from './use-shop';
1
+ export { useShop } from './use-shop.js';
@@ -3,4 +3,4 @@
3
3
  * [the `shopify` property in the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
4
4
  * The `useShop` hook must be a descendent of a `ShopifyProvider` component.
5
5
  */
6
- export declare function useShop(): import("../ShopifyProvider/types").ShopifyContextValue;
6
+ export declare function useShop(): import("../ShopifyProvider/types.js").ShopifyContextValue;
@@ -1,5 +1,5 @@
1
- import { ShopifyContext } from '../ShopifyProvider';
2
- import { useEnvContext } from '../ssr-interop';
1
+ import { ShopifyContext } from '../ShopifyProvider/index.js';
2
+ import { useEnvContext } from '../ssr-interop.js';
3
3
  /**
4
4
  * The `useShop` hook provides access to values within
5
5
  * [the `shopify` property in the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
@@ -1 +1 @@
1
- export { useUrl } from './useUrl';
1
+ export { useUrl } from './useUrl.js';
@@ -1 +1 @@
1
- export { useUrl } from './useUrl';
1
+ export { useUrl } from './useUrl.js';
@@ -1,8 +1,8 @@
1
1
  import { useContext, useMemo } from 'react';
2
- import { RSC_PATHNAME } from '../../constants';
3
- import { parseJSON } from '../../utilities/parse';
4
- import { RouterContext } from '../Router/BrowserRouter.client';
5
- import { useEnvContext, META_ENV_SSR } from '../ssr-interop';
2
+ import { RSC_PATHNAME } from '../../constants.js';
3
+ import { parseJSON } from '../../utilities/parse.js';
4
+ import { RouterContext } from '../Router/BrowserRouter.client.js';
5
+ import { useEnvContext, META_ENV_SSR } from '../ssr-interop.js';
6
6
  /**
7
7
  * The `useUrl` hook retrieves the current URL in a server or client component.
8
8
  */
@@ -1,6 +1,6 @@
1
1
  // Provide Hydrogen config loader to external tools like the CLI
2
- import { VIRTUAL_PROXY_HYDROGEN_CONFIG_ID } from './plugins/vite-plugin-hydrogen-virtual-files';
3
- import { viteception } from './viteception';
2
+ import { VIRTUAL_PROXY_HYDROGEN_CONFIG_ID } from './plugins/vite-plugin-hydrogen-virtual-files.js';
3
+ import { viteception } from './viteception.js';
4
4
  export async function loadConfig(options = { root: process.cwd() }) {
5
5
  const { loaded } = await viteception([VIRTUAL_PROXY_HYDROGEN_CONFIG_ID], options);
6
6
  return { configuration: loaded[0].default };
@@ -1,4 +1,4 @@
1
- import type { ShopifyConfig } from '../shared-types';
1
+ import type { ShopifyConfig } from '../shared-types.js';
2
2
  import type { IncomingMessage, NextFunction } from 'connect';
3
3
  import type { ServerResponse } from 'http';
4
4
  import type { ViteDevServer } from 'vite';
@@ -1,4 +1,4 @@
1
- import { graphiqlHtml } from './graphiql';
1
+ import { graphiqlHtml } from './graphiql.js';
2
2
  export function graphiqlMiddleware({ getShopifyConfig, dev, }) {
3
3
  return async function (request, response, next) {
4
4
  if (dev && isGraphiqlRequest(request)) {
@@ -24,7 +24,7 @@ export function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypo
24
24
  * which is needed for proxy requests and server-side API requests.
25
25
  */
26
26
  const webPolyfills = !globalThis.fetch || !globalThis.ReadableStream
27
- ? import('../utilities/web-api-polyfill')
27
+ ? import('../utilities/web-api-polyfill.js')
28
28
  : undefined;
29
29
  return async function (request, response, next) {
30
30
  try {
@@ -1,4 +1,4 @@
1
- import type { HydrogenVitePluginOptions } from './types';
1
+ import type { HydrogenVitePluginOptions } from './types.js';
2
2
  import type { Plugin } from 'vite';
3
3
  declare const hydrogenPlugin: {
4
4
  (pluginOptions?: HydrogenVitePluginOptions): Plugin[];
@@ -1,21 +1,22 @@
1
- import hydrogenConfig from './plugins/vite-plugin-hydrogen-config';
2
- import hydrogenMiddleware from './plugins/vite-plugin-hydrogen-middleware';
3
- import hydrogenClientMiddleware from './plugins/vite-plugin-hydrogen-client-middleware';
4
- import hydrogenVirtualFiles from './plugins/vite-plugin-hydrogen-virtual-files';
5
- import platformEntry from './plugins/vite-plugin-platform-entry';
6
- import rsc from './plugins/vite-plugin-hydrogen-rsc';
7
- import ssrInterop from './plugins/vite-plugin-ssr-interop';
8
- import purgeQueryCache from './plugins/vite-plugin-purge-query-cache';
9
- import hydrationAutoImport from './plugins/vite-plugin-hydration-auto-import';
1
+ import hydrogenConfig from './plugins/vite-plugin-hydrogen-config.js';
2
+ import hydrogenMiddleware from './plugins/vite-plugin-hydrogen-middleware.js';
3
+ import hydrogenClientMiddleware from './plugins/vite-plugin-hydrogen-client-middleware.js';
4
+ import hydrogenVirtualFiles from './plugins/vite-plugin-hydrogen-virtual-files.js';
5
+ import platformEntry from './plugins/vite-plugin-platform-entry.js';
6
+ import rsc from './plugins/vite-plugin-hydrogen-rsc.js';
7
+ import ssrInterop from './plugins/vite-plugin-ssr-interop.js';
8
+ import hydrationAutoImport from './plugins/vite-plugin-hydration-auto-import.js';
10
9
  import inspect from 'vite-plugin-inspect';
11
10
  import react from '@vitejs/plugin-react';
12
- import cssModulesRsc from './plugins/vite-plugin-css-modules-rsc';
13
- import clientImports from './plugins/vite-plugin-client-imports';
14
- import suppressWarnings from './plugins/vite-plugin-hydrogen-suppress-warnings';
11
+ import cssRsc from './plugins/vite-plugin-css-rsc.js';
12
+ import cssModulesRsc from './plugins/vite-plugin-css-modules-rsc.js';
13
+ import clientImports from './plugins/vite-plugin-client-imports.js';
14
+ import suppressWarnings from './plugins/vite-plugin-hydrogen-suppress-warnings.js';
15
+ import assetsVersion from './plugins/vite-plugin-assets-version.js';
15
16
  const hydrogenPlugin = (pluginOptions = {}) => {
16
17
  return [
17
18
  process.env.VITE_INSPECT && inspect(),
18
- hydrogenConfig(),
19
+ hydrogenConfig(pluginOptions),
19
20
  hydrogenClientMiddleware(),
20
21
  clientImports(),
21
22
  hydrogenMiddleware(pluginOptions),
@@ -23,11 +24,12 @@ const hydrogenPlugin = (pluginOptions = {}) => {
23
24
  react(),
24
25
  hydrationAutoImport(),
25
26
  ssrInterop(),
26
- cssModulesRsc(),
27
+ pluginOptions.experimental?.css === 'global' ? cssRsc() : cssModulesRsc(),
27
28
  rsc(pluginOptions),
28
29
  platformEntry(),
29
30
  suppressWarnings(),
30
- pluginOptions.purgeQueryCacheOnBuild && purgeQueryCache(),
31
+ pluginOptions.assetHashVersion &&
32
+ assetsVersion(pluginOptions.assetHashVersion),
31
33
  ];
32
34
  };
33
35
  export default hydrogenPlugin; // For ESM
@@ -0,0 +1,2 @@
1
+ import { Plugin } from 'vite';
2
+ export default function assetsVersion(version?: string): Plugin;
@@ -0,0 +1,8 @@
1
+ export default function assetsVersion(version) {
2
+ return {
3
+ name: 'hydrogen:augment-with-version',
4
+ augmentChunkHash() {
5
+ return version ?? '';
6
+ },
7
+ };
8
+ }
@@ -1,4 +1,4 @@
1
- import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware';
1
+ import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware.js';
2
2
  import MagicString from 'magic-string';
3
3
  import path from 'path';
4
4
  const cssModuleRE = /\.module\.(s?css|sass|less|stylus)/;
@@ -0,0 +1,2 @@
1
+ import { Plugin } from 'vite';
2
+ export default function cssRsc(): Plugin;
@@ -0,0 +1,108 @@
1
+ import path from 'path';
2
+ import MagicString from 'magic-string';
3
+ import { normalizePath } from 'vite';
4
+ const VITE_CSS_CHUNK_NAME = 'style.css';
5
+ const INJECT_STYLES_COMMENT = '<!--__INJECT_STYLES__-->';
6
+ // Keep this in the outer scope to share it
7
+ // across client <> server builds.
8
+ let clientBuildPath;
9
+ export default function cssRsc() {
10
+ let config;
11
+ return {
12
+ name: 'hydrogen:css-rsc',
13
+ enforce: 'post',
14
+ config() {
15
+ // Disable CSS code split to avoid preloading styles
16
+ // that are already included in index.html
17
+ return { build: { cssCodeSplit: false } };
18
+ },
19
+ configResolved(_config) {
20
+ config = _config;
21
+ },
22
+ transform(code, id, options) {
23
+ if (options?.ssr && id.includes('index.html?raw')) {
24
+ // Mark the client build index.html to inject styles later
25
+ const s = new MagicString(code);
26
+ s.replace('</head>', INJECT_STYLES_COMMENT + '</head>');
27
+ return {
28
+ code: s.toString(),
29
+ map: s.generateMap({ file: id, source: id }),
30
+ };
31
+ }
32
+ },
33
+ transformIndexHtml(html, { server }) {
34
+ // Add discovered styles during dev
35
+ if (server) {
36
+ const tags = [];
37
+ const foundCssFiles = new Set();
38
+ for (const [key, value] of server.moduleGraph.idToModuleMap.entries()) {
39
+ if (
40
+ // Note: Some CSS-in-JS libraries use `.css.js`
41
+ // extension and we should match it here:
42
+ /\.(css|sass|scss|stylus|less)(\.|\?|$)/.test(normalizePath(key).split('/').pop())) {
43
+ let { url, file, lastHMRTimestamp, importers } = value;
44
+ if (!foundCssFiles.has(file) &&
45
+ !Array.from(importers).some((importer) => foundCssFiles.has(importer.file))) {
46
+ foundCssFiles.add(file);
47
+ // Vite is adding hash and timestamp to the CSS files downloaded
48
+ // from client components. Adding the same query string params
49
+ // here prevents this file from being downloaded twice.
50
+ if (lastHMRTimestamp) {
51
+ const timestampQuery = `?t=${lastHMRTimestamp}`;
52
+ // The timestamp needs to be the first query string param.
53
+ url = url.includes('?')
54
+ ? url.replace('?', timestampQuery + '&')
55
+ : url + timestampQuery;
56
+ }
57
+ tags.push(value.type === 'css'
58
+ ? { tag: 'link', attrs: { rel: 'stylesheet', href: url } }
59
+ : { tag: 'script', attrs: { type: 'module', src: url } });
60
+ }
61
+ }
62
+ }
63
+ return tags;
64
+ }
65
+ },
66
+ generateBundle(options, bundle, isWrite) {
67
+ if (config.build?.ssr) {
68
+ // -- Server build
69
+ if (!clientBuildPath) {
70
+ // Default value
71
+ clientBuildPath = normalizePath(path.resolve(config.root, config.build.outDir, '..', 'client'));
72
+ }
73
+ const relativeClientPath = normalizePath(path.relative(normalizePath(path.resolve(config.root, config.build.outDir)), clientBuildPath));
74
+ let cssAssetFileName = '';
75
+ const cssAsset = Object.values(bundle).find((file) => file.type === 'asset' && file.name === VITE_CSS_CHUNK_NAME);
76
+ const outputChunk = Object.values(bundle).find((file) => file.type === 'chunk' && file.isEntry);
77
+ if (cssAsset) {
78
+ cssAssetFileName = cssAsset.fileName;
79
+ // Move the CSS file to the client build assets
80
+ cssAsset.fileName = normalizePath(path.join(relativeClientPath, cssAsset.fileName));
81
+ }
82
+ let assetPrefix = process.env.HYDROGEN_ASSET_BASE_URL || '/';
83
+ if (!assetPrefix.endsWith('/'))
84
+ assetPrefix += '/';
85
+ // Add a reference to the CSS file in indexTemplate
86
+ outputChunk.code = outputChunk.code.replace(INJECT_STYLES_COMMENT, cssAssetFileName &&
87
+ `<link rel="stylesheet" href="${assetPrefix + cssAssetFileName}">`);
88
+ }
89
+ else {
90
+ // -- Client build
91
+ // Save outDir from client build in the outer scope
92
+ // to read it during the server build. The CLI runs Vite in
93
+ // the same process so the scope is shared across builds.
94
+ clientBuildPath = normalizePath(path.resolve(config.root, config.build.outDir));
95
+ const indexHtml = bundle['index.html'];
96
+ const cssAsset = Object.values(bundle).find((file) => file.type === 'asset' && file.name === VITE_CSS_CHUNK_NAME);
97
+ if (cssAsset) {
98
+ // The client build CSS is incomplete because it only includes
99
+ // CSS imported in client components (server components are not
100
+ // discovered in this build). Remove it from this build and
101
+ // let it be added by the server build after this.
102
+ delete bundle[cssAsset.fileName];
103
+ indexHtml.source = indexHtml.source.replace(new RegExp(`\\s*<link[^<>]+${cssAsset.fileName.replace('.', '\\.')}.*?>`, ''), '');
104
+ }
105
+ }
106
+ },
107
+ };
108
+ }
@@ -1,3 +1,4 @@
1
1
  import { Plugin } from 'vite';
2
- declare const _default: () => Plugin;
2
+ import type { HydrogenVitePluginOptions } from '../types.js';
3
+ declare const _default: (pluginOptions: HydrogenVitePluginOptions) => Plugin;
3
4
  export default _default;
@@ -1,4 +1,5 @@
1
- export default () => {
1
+ import Crypto from 'crypto';
2
+ export default (pluginOptions) => {
2
3
  const rollupOptions = {
3
4
  output: {},
4
5
  };
@@ -23,7 +24,7 @@ export default () => {
23
24
  };
24
25
  }
25
26
  return {
26
- name: 'vite-plugin-hydrogen-config',
27
+ name: 'hydrogen:config',
27
28
  config: async (config, env) => ({
28
29
  resolve: {
29
30
  alias: {
@@ -48,7 +49,7 @@ export default () => {
48
49
  * Tell Vite to bundle everything when we're building for Workers.
49
50
  * Otherwise, bundle RSC plugin as a workaround to apply the vendor alias above.
50
51
  */
51
- noExternal: isWorker || [/react-server-dom-vite/],
52
+ noExternal: isWorker || [/react-server-dom-vite/, /@shopify\/hydrogen/],
52
53
  target: isWorker ? 'webworker' : 'node',
53
54
  },
54
55
  // Reload when updating local Hydrogen lib
@@ -93,7 +94,10 @@ export default () => {
93
94
  define: {
94
95
  __HYDROGEN_DEV__: env.mode !== 'production',
95
96
  __HYDROGEN_WORKER__: isWorker,
96
- __HYDROGEN_TEST__: false, // Used in unit tests
97
+ __HYDROGEN_TEST__: false,
98
+ __HYDROGEN_CACHE_ID__: pluginOptions.purgeQueryCacheOnBuild
99
+ ? `"${Crypto.randomBytes(8).toString('hex').slice(0, 8)}"`
100
+ : '"__QUERY_CACHE_ID__"',
97
101
  },
98
102
  envPrefix: ['VITE_', 'PUBLIC_'],
99
103
  base: process.env.HYDROGEN_ASSET_BASE_URL,
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import type { HydrogenVitePluginOptions } from '../types';
2
+ import type { HydrogenVitePluginOptions } from '../types.js';
3
3
  export declare const HYDROGEN_DEFAULT_SERVER_ENTRY: string;
4
4
  declare const _default: (pluginOptions: HydrogenVitePluginOptions) => Plugin;
5
5
  export default _default;
@@ -2,9 +2,9 @@ import { loadEnv } from 'vite';
2
2
  import bodyParser from 'body-parser';
3
3
  import path from 'path';
4
4
  import { promises as fs } from 'fs';
5
- import { hydrogenMiddleware, graphiqlMiddleware } from '../middleware';
6
- import { InMemoryCache } from '../cache/in-memory';
7
- import { VIRTUAL_PROXY_HYDROGEN_CONFIG_ID } from './vite-plugin-hydrogen-virtual-files';
5
+ import { hydrogenMiddleware, graphiqlMiddleware } from '../middleware.js';
6
+ import { InMemoryCache } from '../cache/in-memory.js';
7
+ import { VIRTUAL_PROXY_HYDROGEN_CONFIG_ID } from './vite-plugin-hydrogen-virtual-files.js';
8
8
  export const HYDROGEN_DEFAULT_SERVER_ENTRY = process.env.HYDROGEN_SERVER_ENTRY || '/src/App.server';
9
9
  export default (pluginOptions) => {
10
10
  return {
@@ -1,2 +1,2 @@
1
- import { HydrogenVitePluginOptions } from '../types';
1
+ import { HydrogenVitePluginOptions } from '../types.js';
2
2
  export default function (options?: HydrogenVitePluginOptions): any;
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
2
  import reactServerDomVite from '@shopify/hydrogen/vendor/react-server-dom-vite/plugin.js';
3
- import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware';
4
- import { VIRTUAL_PROXY_HYDROGEN_ROUTES_ID } from './vite-plugin-hydrogen-virtual-files';
3
+ import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware.js';
4
+ import { VIRTUAL_PROXY_HYDROGEN_ROUTES_ID } from './vite-plugin-hydrogen-virtual-files.js';
5
5
  export default function (options) {
6
6
  return reactServerDomVite({
7
7
  serverBuildEntries: [
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import type { HydrogenVitePluginOptions } from '../types';
2
+ import type { HydrogenVitePluginOptions } from '../types.js';
3
3
  export declare const HYDROGEN_DEFAULT_SERVER_ENTRY: string;
4
4
  export declare const VIRTUAL_PROXY_HYDROGEN_CONFIG_ID: string;
5
5
  export declare const VIRTUAL_PROXY_HYDROGEN_ROUTES_ID: string;
@@ -1,11 +1,14 @@
1
1
  import { normalizePath } from 'vite';
2
2
  import path from 'path';
3
3
  import { promises as fs } from 'fs';
4
- import { viteception } from '../viteception';
4
+ import { viteception } from '../viteception.js';
5
+ import MagicString from 'magic-string';
5
6
  export const HYDROGEN_DEFAULT_SERVER_ENTRY = process.env.HYDROGEN_SERVER_ENTRY || '/src/App.server';
6
7
  // The character ":" breaks Vite with Node >= 16.15. Use "_" instead
7
8
  const VIRTUAL_PREFIX = 'virtual__';
8
9
  const PROXY_PREFIX = 'proxy__';
10
+ const ERROR_FILE = 'error.jsx';
11
+ const VIRTUAL_ERROR_FILE = VIRTUAL_PREFIX + ERROR_FILE;
9
12
  const HYDROGEN_CONFIG_ID = 'hydrogen.config.ts';
10
13
  const VIRTUAL_HYDROGEN_CONFIG_ID = VIRTUAL_PREFIX + HYDROGEN_CONFIG_ID;
11
14
  export const VIRTUAL_PROXY_HYDROGEN_CONFIG_ID = VIRTUAL_PREFIX + PROXY_PREFIX + HYDROGEN_CONFIG_ID;
@@ -15,6 +18,7 @@ export const VIRTUAL_PROXY_HYDROGEN_ROUTES_ID = VIRTUAL_PREFIX + PROXY_PREFIX +
15
18
  export default (pluginOptions) => {
16
19
  let config;
17
20
  let server;
21
+ let resolvedConfigPath;
18
22
  return {
19
23
  name: 'hydrogen:virtual-files',
20
24
  configResolved(_config) {
@@ -25,15 +29,18 @@ export default (pluginOptions) => {
25
29
  },
26
30
  resolveId(source, importer) {
27
31
  if (source === VIRTUAL_HYDROGEN_CONFIG_ID) {
28
- return findHydrogenConfigPath(config.root, pluginOptions.configPath).then((hcPath) =>
29
- // This direct dependency on a real file
30
- // makes HMR work for the virtual module.
31
- this.resolve(hcPath, importer, { skipSelf: true }));
32
+ return findHydrogenConfigPath(config.root, pluginOptions.configPath).then((hcPath) => {
33
+ resolvedConfigPath = normalizePath(hcPath);
34
+ // This direct dependency on a real file
35
+ // makes HMR work for the virtual module.
36
+ return this.resolve(hcPath, importer, { skipSelf: true });
37
+ });
32
38
  }
33
39
  if ([
34
40
  VIRTUAL_PROXY_HYDROGEN_CONFIG_ID,
35
41
  VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
36
42
  VIRTUAL_HYDROGEN_ROUTES_ID,
43
+ VIRTUAL_ERROR_FILE,
37
44
  ].includes(source)) {
38
45
  // Virtual modules convention
39
46
  // https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
@@ -44,7 +51,7 @@ export default (pluginOptions) => {
44
51
  // Likely due to a bug in Vite, but virtual modules cannot be loaded
45
52
  // directly using ssrLoadModule from a Vite plugin. It needs to be proxied as follows:
46
53
  if (id === '\0' + VIRTUAL_PROXY_HYDROGEN_CONFIG_ID) {
47
- return `import hc from '${VIRTUAL_HYDROGEN_CONFIG_ID}'; export default hc;`;
54
+ return `import hc from '${VIRTUAL_HYDROGEN_CONFIG_ID}'; export default typeof hc === 'function' ? hc() : hc;`;
48
55
  }
49
56
  if (id === '\0' + VIRTUAL_PROXY_HYDROGEN_ROUTES_ID) {
50
57
  return `import hr from '${VIRTUAL_HYDROGEN_ROUTES_ID}'; export default hr;`;
@@ -71,6 +78,25 @@ export default (pluginOptions) => {
71
78
  return { code };
72
79
  });
73
80
  }
81
+ if (id === '\0' + VIRTUAL_ERROR_FILE) {
82
+ return importHydrogenConfig().then((hc) => {
83
+ const errorPath = hc.serverErrorPage ?? '/src/Error.{jsx,tsx}';
84
+ const code = `const errorPage = import.meta.glob("${errorPath}");\n export default Object.values(errorPage)[0];`;
85
+ return { code };
86
+ });
87
+ }
88
+ },
89
+ transform(code, id) {
90
+ if (id === resolvedConfigPath) {
91
+ const s = new MagicString(code);
92
+ // Wrap in function to avoid evaluating `Oxygen.env`
93
+ // in the config until we have polyfilled it properly.
94
+ s.replace(/export\s+default\s+(\w+)\s*\(/g, (all, m1) => all.replace(m1, `() => ${m1}`));
95
+ return {
96
+ code: s.toString(),
97
+ map: s.generateMap({ file: id, source: id }),
98
+ };
99
+ }
74
100
  },
75
101
  };
76
102
  async function importHydrogenConfig() {
@@ -78,7 +104,9 @@ export default (pluginOptions) => {
78
104
  const loaded = await server.ssrLoadModule(VIRTUAL_PROXY_HYDROGEN_CONFIG_ID);
79
105
  return loaded.default;
80
106
  }
81
- const { loaded } = await viteception([VIRTUAL_PROXY_HYDROGEN_CONFIG_ID]);
107
+ const { loaded } = await viteception([VIRTUAL_PROXY_HYDROGEN_CONFIG_ID], {
108
+ root: config.root,
109
+ });
82
110
  return loaded[0].default;
83
111
  }
84
112
  };
@@ -1,5 +1,5 @@
1
1
  import { normalizePath } from 'vite';
2
- import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware';
2
+ import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware.js';
3
3
  import MagicString from 'magic-string';
4
4
  import path from 'path';
5
5
  import fs from 'fs';