@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
@@ -1,7 +1,9 @@
1
1
  import { useServerRequest } from '../ServerRequestProvider';
2
+ import { mergeDeep } from './utils';
2
3
  export function useServerAnalytics(data) {
3
4
  const request = useServerRequest();
4
- if (data)
5
- request.ctx.analyticsData = Object.assign({}, request.ctx.analyticsData, data);
5
+ if (data) {
6
+ request.ctx.analyticsData = mergeDeep(request.ctx.analyticsData, data);
7
+ }
6
8
  return request.ctx.analyticsData;
7
9
  }
@@ -1 +1,3 @@
1
1
  export declare function getNamedspacedEventname(eventname: string): string;
2
+ export declare function isObject(item: any): any;
3
+ export declare function mergeDeep(target: any, ...sources: any[]): any;
@@ -6,3 +6,24 @@ export function getNamedspacedEventname(eventname) {
6
6
  ? `c-${eventname}`
7
7
  : eventname;
8
8
  }
9
+ export function isObject(item) {
10
+ return item && typeof item === 'object' && !Array.isArray(item);
11
+ }
12
+ export function mergeDeep(target, ...sources) {
13
+ if (!sources.length)
14
+ return target;
15
+ const source = sources.shift();
16
+ if (isObject(target) && isObject(source)) {
17
+ for (const key in source) {
18
+ if (isObject(source[key])) {
19
+ if (!target[key])
20
+ Object.assign(target, { [key]: {} });
21
+ mergeDeep(target[key], source[key]);
22
+ }
23
+ else {
24
+ Object.assign(target, { [key]: source[key] });
25
+ }
26
+ }
27
+ }
28
+ return mergeDeep(target, ...sources);
29
+ }
@@ -1,4 +1,4 @@
1
- import type { QueryKey, CachingStrategy } from '../types';
1
+ import type { QueryKey, CachingStrategy } from '../../types';
2
2
  export declare function generateSubRequestCacheControlHeader(userCacheOptions?: CachingStrategy): string;
3
3
  /**
4
4
  * Get an item from the cache. If a match is found, returns a tuple
@@ -1,7 +1,7 @@
1
- import { getCache } from './runtime';
2
- import { hashKey } from '../utilities/hash';
1
+ import { getCache } from '../runtime';
2
+ import { hashKey } from '../../utilities/hash';
3
3
  import * as CacheApi from './cache';
4
- import { CacheSeconds } from './CachingStrategy';
4
+ import { CacheSeconds } from './strategies';
5
5
  /**
6
6
  * Wrapper Cache functions for sub queries
7
7
  */
@@ -1,4 +1,4 @@
1
- import type { CachingStrategy } from '../types';
1
+ import type { CachingStrategy } from '../../types';
2
2
  export declare function generateDefaultCacheControlHeader(userCacheOptions?: CachingStrategy): string;
3
3
  /**
4
4
  * Get an item from the cache. If a match is found, returns a tuple
@@ -1,6 +1,6 @@
1
- import { getCache } from './runtime';
2
- import { CacheSeconds, generateCacheControlHeader, } from '../framework/CachingStrategy';
3
- import { logCacheApiStatus } from '../utilities/log';
1
+ import { getCache } from '../runtime';
2
+ import { CacheSeconds, generateCacheControlHeader } from './strategies';
3
+ import { logCacheApiStatus } from '../../utilities/log';
4
4
  function getCacheControlSetting(userCacheOptions, options) {
5
5
  if (userCacheOptions && options) {
6
6
  return {
@@ -1,4 +1,4 @@
1
- import type { CachingStrategy, AllCacheOptions, NoStoreStrategy } from '../../types';
1
+ import type { CachingStrategy, AllCacheOptions, NoStoreStrategy } from '../../../types';
2
2
  export declare function generateCacheControlHeader(cacheOptions: CachingStrategy): string;
3
3
  export declare function NoStore(): NoStoreStrategy;
4
4
  export declare function CacheSeconds(overrideOptions?: CachingStrategy): AllCacheOptions;
@@ -1,9 +1,9 @@
1
1
  export declare type CookieOptions = {
2
- /** Whether to secure the cookie so that the browser only sends it over HTTPS. Some
3
- * browsers [don't work with secure cookies on localhost](https://owasp.org/www-community/controls/SecureCookieAttribute).
2
+ /** Whether to secure the cookie so that [client-side JavaScript can't read the cookie](https://owasp.org/www-community/HttpOnly).
4
3
  */
5
4
  httpOnly?: boolean;
6
- /** Whether to secure the cookie so that [client JavaScript is unable to read it](https://owasp.org/www-community/HttpOnly).
5
+ /** Whether to secure the cookie so that the browser only sends the cookie over HTTPS. Some
6
+ * browsers [don't work with secure cookies on localhost](https://owasp.org/www-community/controls/SecureCookieAttribute).
7
7
  */
8
8
  secure?: boolean;
9
9
  /** Declares that the cookie should be restricted to a first-party
@@ -1,11 +1,13 @@
1
1
  import { ReactNode } from 'react';
2
2
  import type { HelmetData as HeadData } from 'react-helmet-async';
3
+ import { ResolvedHydrogenConfig } from '../../types';
3
4
  declare type HtmlOptions = {
4
5
  children: ReactNode;
5
6
  template: string;
6
7
  htmlAttrs?: Record<string, string>;
7
8
  bodyAttrs?: Record<string, string>;
9
+ hydrogenConfig: ResolvedHydrogenConfig;
8
10
  };
9
- export declare function Html({ children, template, htmlAttrs, bodyAttrs }: HtmlOptions): JSX.Element;
11
+ export declare function Html({ children, template, htmlAttrs, bodyAttrs, hydrogenConfig, }: HtmlOptions): JSX.Element;
10
12
  export declare function applyHtmlHead(html: string, head: HeadData, template: string): string;
11
13
  export {};
@@ -21,7 +21,11 @@ function propsToAttrs(props) {
21
21
  .map(([key, value]) => `${key === REACT_ATTR_MAP.class ? 'class' : key}="${value}"`)
22
22
  .join(' ');
23
23
  }
24
- export function Html({ children, template, htmlAttrs, bodyAttrs }) {
24
+ const clientConfigOptions = [
25
+ 'strictMode',
26
+ 'showDevTools',
27
+ ];
28
+ export function Html({ children, template, htmlAttrs, bodyAttrs, hydrogenConfig, }) {
25
29
  let head = template.match(/<head>(.+?)<\/head>/s)[1] || '';
26
30
  // @ts-ignore
27
31
  if (import.meta.env.DEV) {
@@ -31,10 +35,19 @@ export function Html({ children, template, htmlAttrs, bodyAttrs }) {
31
35
  '<script></script>' + // Fix for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1737882
32
36
  head.replace(/>(\s*?import[\s\w]+?['"]\/@react-refresh)/, ' async="">$1');
33
37
  }
38
+ const clientConfig = {};
39
+ for (const key of clientConfigOptions) {
40
+ if (hydrogenConfig[key] != null) {
41
+ clientConfig[key] = hydrogenConfig[key];
42
+ }
43
+ }
44
+ const clientConfigAttr = Object.keys(clientConfig).length > 0
45
+ ? JSON.stringify(clientConfig)
46
+ : undefined;
34
47
  return (React.createElement("html", { ...attrsToProps(getHtmlAttrs(template)), ...htmlAttrs },
35
48
  React.createElement("head", { dangerouslySetInnerHTML: { __html: head } }),
36
49
  React.createElement("body", { ...attrsToProps(getBodyAttrs(template)), ...bodyAttrs },
37
- React.createElement("div", { id: "root" }, children))));
50
+ React.createElement("div", { id: "root", "data-client-config": clientConfigAttr }, children))));
38
51
  }
39
52
  export function applyHtmlHead(html, head, template) {
40
53
  const { bodyAttrs, htmlAttrs, ...headTags } = extractHeadElements(head, template);
@@ -1,9 +1,12 @@
1
- import type { ShopifyContextValue } from '../../foundation/ShopifyProvider/types';
1
+ import type { ShopifyContextValue } from '../ShopifyProvider/types';
2
2
  import type { QueryCacheControlHeaders } from '../../utilities/log/log-cache-header';
3
3
  import type { QueryTiming } from '../../utilities/log/log-query-timeline';
4
4
  import type { ResolvedHydrogenConfig, PreloadOptions, QueryKey } from '../../types';
5
5
  import { HelmetData as HeadData } from 'react-helmet-async';
6
- import { SessionSyncApi } from '../../foundation/session/session';
6
+ import { SessionSyncApi } from '../session/session';
7
+ export interface RuntimeContext {
8
+ waitUntil: (fn: Promise<any>) => void;
9
+ }
7
10
  export declare type PreloadQueryEntry = {
8
11
  key: QueryKey;
9
12
  fetcher: () => Promise<unknown>;
@@ -23,7 +26,7 @@ export declare type RouterContextData = {
23
26
  * - Adds a `cookies` map for easy access
24
27
  * - Adds a static constructor to convert a Node.js `IncomingMessage` to a Request.
25
28
  */
26
- export declare class ServerComponentRequest extends Request {
29
+ export declare class HydrogenRequest extends Request {
27
30
  cookies: Map<string, string>;
28
31
  id: string;
29
32
  time: number;
@@ -40,6 +43,7 @@ export declare class ServerComponentRequest extends Request {
40
43
  router: RouterContextData;
41
44
  buyerIpHeader?: string;
42
45
  session?: SessionSyncApi;
46
+ runtime?: RuntimeContext;
43
47
  [key: string]: any;
44
48
  };
45
49
  constructor(input: any);
@@ -20,7 +20,7 @@ const PRELOAD_ALL = '*';
20
20
  * - Adds a `cookies` map for easy access
21
21
  * - Adds a static constructor to convert a Node.js `IncomingMessage` to a Request.
22
22
  */
23
- export class ServerComponentRequest extends Request {
23
+ export class HydrogenRequest extends Request {
24
24
  constructor(input, init) {
25
25
  if (input instanceof Request) {
26
26
  super(input, init);
@@ -1,12 +1,14 @@
1
1
  import type { CachingStrategy } from '../../types';
2
2
  import React from 'react';
3
- export declare class ServerComponentResponse extends Response {
3
+ export declare class HydrogenResponse extends Response {
4
4
  private wait;
5
5
  private cacheOptions;
6
- customStatus?: {
7
- code?: number;
8
- text?: string;
9
- };
6
+ private customStatus?;
7
+ private customStatusText?;
8
+ get status(): number;
9
+ set status(number: number);
10
+ get statusText(): string;
11
+ set statusText(text: string);
10
12
  /**
11
13
  * Buffer the current response until all queries have resolved,
12
14
  * and prevent it from streaming back early.
@@ -15,11 +17,6 @@ export declare class ServerComponentResponse extends Response {
15
17
  canStream(): boolean;
16
18
  cache(options: CachingStrategy): void;
17
19
  get cacheControlHeader(): string;
18
- writeHead({ status, statusText, headers, }?: {
19
- status?: number;
20
- statusText?: string;
21
- headers?: Record<string, any>;
22
- }): void;
23
20
  redirect(location: string, status?: number): React.FunctionComponentElement<{
24
21
  to: string;
25
22
  }>;
@@ -1,12 +1,26 @@
1
- import { CacheSeconds, generateCacheControlHeader } from '../CachingStrategy';
2
- import Redirect from '../../foundation/Redirect/Redirect.client';
1
+ import { CacheSeconds, generateCacheControlHeader } from '../Cache/strategies';
2
+ import Redirect from '../Redirect/Redirect.client';
3
3
  import React from 'react';
4
- export class ServerComponentResponse extends Response {
4
+ export class HydrogenResponse extends Response {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.wait = false;
8
8
  this.cacheOptions = CacheSeconds();
9
9
  }
10
+ get status() {
11
+ var _a;
12
+ return (_a = this.customStatus) !== null && _a !== void 0 ? _a : super.status;
13
+ }
14
+ set status(number) {
15
+ this.customStatus = number;
16
+ }
17
+ get statusText() {
18
+ var _a;
19
+ return (_a = this.customStatusText) !== null && _a !== void 0 ? _a : super.statusText;
20
+ }
21
+ set statusText(text) {
22
+ this.customStatusText = text;
23
+ }
10
24
  /**
11
25
  * Buffer the current response until all queries have resolved,
12
26
  * and prevent it from streaming back early.
@@ -23,19 +37,9 @@ export class ServerComponentResponse extends Response {
23
37
  get cacheControlHeader() {
24
38
  return generateCacheControlHeader(this.cacheOptions);
25
39
  }
26
- writeHead({ status, statusText, headers, } = {}) {
27
- if (status || statusText) {
28
- this.customStatus = { code: status, text: statusText };
29
- }
30
- if (headers) {
31
- for (const [key, value] of Object.entries(headers)) {
32
- this.headers.set(key, value);
33
- }
34
- }
35
- }
36
40
  redirect(location, status = 307) {
37
- // writeHead is used for SSR, so that the server responds with a redirect
38
- this.writeHead({ status, headers: { location } });
41
+ this.status = status;
42
+ this.headers.set('location', location);
39
43
  // in the case of an RSC request, instead render a client component that will redirect
40
44
  return React.createElement(Redirect, { to: location });
41
45
  }
@@ -11,30 +11,37 @@ export const BrowserRouter = ({ history: pHistory, children }) => {
11
11
  /* eslint-disable react-hooks/rules-of-hooks */
12
12
  const history = useMemo(() => pHistory || createBrowserHistory(), [pHistory]);
13
13
  const [location, setLocation] = useState(history.location);
14
- const [locationChanged, setLocationChanged] = useState(false);
14
+ const [scrollNeedsRestoration, setScrollNeedsRestoration] = useState(false);
15
15
  const { pending, locationServerProps, setLocationServerProps } = useInternalServerProps();
16
16
  useScrollRestoration({
17
17
  location,
18
18
  pending,
19
19
  serverProps: locationServerProps,
20
- locationChanged,
21
- onFinishNavigating: () => setLocationChanged(false),
20
+ scrollNeedsRestoration,
21
+ onFinishNavigating: () => setScrollNeedsRestoration(false),
22
22
  });
23
23
  useLayoutEffect(() => {
24
- const unlisten = history.listen(({ location: newLocation }) => {
24
+ const unlisten = history.listen(({ location: newLocation, action }) => {
25
+ var _a;
25
26
  positions[location.key] = window.scrollY;
26
27
  setLocationServerProps({
27
28
  pathname: newLocation.pathname,
28
29
  search: newLocation.search,
29
30
  });
30
31
  setLocation(newLocation);
31
- setLocationChanged(true);
32
+ const state = ((_a = newLocation.state) !== null && _a !== void 0 ? _a : {});
33
+ /**
34
+ * "pop" navigations, like forward/backward buttons, always restore scroll position
35
+ * regardless of what the original forward navigation intent was.
36
+ */
37
+ const needsScrollRestoration = action === 'POP' || !!state.scroll;
38
+ setScrollNeedsRestoration(needsScrollRestoration);
32
39
  });
33
40
  return () => unlisten();
34
41
  }, [
35
42
  history,
36
43
  location,
37
- setLocationChanged,
44
+ setScrollNeedsRestoration,
38
45
  setLocation,
39
46
  setLocationServerProps,
40
47
  ]);
@@ -65,7 +72,7 @@ function useBeforeUnload(callback) {
65
72
  };
66
73
  }, [callback]);
67
74
  }
68
- function useScrollRestoration({ location, pending, serverProps, locationChanged, onFinishNavigating, }) {
75
+ function useScrollRestoration({ location, pending, serverProps, scrollNeedsRestoration, onFinishNavigating, }) {
69
76
  /**
70
77
  * Browsers have an API for scroll restoration. We wait for the page to load first,
71
78
  * in case the browser is able to restore scroll position automatically, and then
@@ -82,7 +89,7 @@ function useScrollRestoration({ location, pending, serverProps, locationChanged,
82
89
  }, []));
83
90
  useLayoutEffect(() => {
84
91
  // The app has just loaded
85
- if (isFirstLoad || !locationChanged) {
92
+ if (isFirstLoad || !scrollNeedsRestoration) {
86
93
  isFirstLoad = false;
87
94
  return;
88
95
  }
@@ -124,7 +131,7 @@ function useScrollRestoration({ location, pending, serverProps, locationChanged,
124
131
  pending,
125
132
  serverProps.pathname,
126
133
  serverProps.search,
127
- locationChanged,
134
+ scrollNeedsRestoration,
128
135
  onFinishNavigating,
129
136
  ]);
130
137
  }
@@ -1,6 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  declare global {
3
- var __DEV__: boolean;
3
+ var __HYDROGEN_DEV__: boolean;
4
+ var __HYDROGEN_TEST__: boolean;
4
5
  }
5
6
  export interface LocationServerProps {
6
7
  pathname: string;
@@ -35,7 +35,7 @@ export function ServerPropsProvider({ initialServerProps, setServerPropsForRsc,
35
35
  else {
36
36
  newValue = input;
37
37
  }
38
- if (__DEV__) {
38
+ if (__HYDROGEN_DEV__) {
39
39
  const privateProp = PRIVATE_PROPS.find((prop) => prop in newValue);
40
40
  if (privateProp) {
41
41
  console.warn(`Custom "${privateProp}" property in server state is ignored. Use a different name.`);
@@ -1,12 +1,12 @@
1
- import type { PreloadQueriesByURL, ServerComponentRequest } from '../../framework/Hydration/ServerComponentRequest.server';
1
+ import type { PreloadQueriesByURL, HydrogenRequest } from '../HydrogenRequest/HydrogenRequest.server';
2
2
  import type { QueryKey } from '../../types';
3
3
  declare type ServerRequestProviderProps = {
4
4
  isRSC: boolean;
5
- request: ServerComponentRequest;
5
+ request: HydrogenRequest;
6
6
  children: JSX.Element;
7
7
  };
8
8
  export declare function ServerRequestProvider({ isRSC, request, children, }: ServerRequestProviderProps): JSX.Element;
9
- export declare function useServerRequest(): ServerComponentRequest;
9
+ export declare function useServerRequest(): HydrogenRequest;
10
10
  declare type RequestCacheResult<T> = {
11
11
  data: T;
12
12
  error?: never;
@@ -19,5 +19,5 @@ declare type RequestCacheResult<T> = {
19
19
  * It will throw the promise if data is not ready.
20
20
  */
21
21
  export declare function useRequestCacheData<T>(key: QueryKey, fetcher: () => T | Promise<T>): RequestCacheResult<T>;
22
- export declare function preloadRequestCacheData(request: ServerComponentRequest, preloadQueries?: PreloadQueriesByURL): void;
22
+ export declare function preloadRequestCacheData(request: HydrogenRequest, preloadQueries?: PreloadQueriesByURL): void;
23
23
  export {};
@@ -18,7 +18,7 @@ function getCacheForType(resource) {
18
18
  React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
19
19
  .ReactCurrentDispatcher.current;
20
20
  // @ts-ignore
21
- if (__DEV__ && typeof jest !== 'undefined' && !dispatcher.getCacheForType) {
21
+ if (__HYDROGEN_TEST__ && !dispatcher.getCacheForType) {
22
22
  // Jest does not have access to the RSC runtime, mock it here:
23
23
  // @ts-ignore
24
24
  return ((_a = globalThis.__jestRscCache) !== null && _a !== void 0 ? _a : (globalThis.__jestRscCache = resource()));
@@ -52,7 +52,7 @@ export function useServerRequest() {
52
52
  }
53
53
  if (!request) {
54
54
  // @ts-ignore
55
- if (__DEV__ && typeof jest !== 'undefined') {
55
+ if (__HYDROGEN_TEST__) {
56
56
  // Unit tests are not wrapped in ServerRequestProvider.
57
57
  // This mocks it, instead of providing it in every test.
58
58
  return { ctx: {} };
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  declare global {
3
- var __DEV__: boolean;
3
+ var __HYDROGEN_DEV__: boolean;
4
4
  }
5
5
  export interface ServerState {
6
6
  pathname: string;
@@ -33,7 +33,7 @@ export function ServerStateProvider({ serverState, setServerState, children, })
33
33
  }
34
34
  if (!newValue)
35
35
  return { ...prev };
36
- if (__DEV__) {
36
+ if (__HYDROGEN_DEV__) {
37
37
  const privateProp = PRIVATE_PROPS.find((prop) => prop in newValue);
38
38
  if (privateProp) {
39
39
  console.warn(`Custom "${privateProp}" property in server state is ignored. Use a different name.`);
@@ -12,6 +12,7 @@ function makeShopifyContext(shopifyConfig) {
12
12
  storeDomain: (_b = shopifyConfig === null || shopifyConfig === void 0 ? void 0 : shopifyConfig.storeDomain) === null || _b === void 0 ? void 0 : _b.replace(/^https?:\/\//, ''),
13
13
  storefrontToken: shopifyConfig.storefrontToken,
14
14
  storefrontApiVersion: shopifyConfig.storefrontApiVersion,
15
+ multipassSecret: shopifyConfig.multipassSecret,
15
16
  };
16
17
  }
17
18
  export const SHOPIFY_PROVIDER_CONTEXT_KEY = Symbol.for('SHOPIFY_PROVIDER_RSC');
@@ -1,3 +1,3 @@
1
- export * from './ServerPropsProvider';
1
+ export { ServerPropsProvider, ServerPropsContext, type ServerProps, type ServerPropsContextValue, } from './ServerPropsProvider';
2
2
  export { useShop } from './useShop';
3
3
  export { useUrl } from './useUrl';
@@ -1,3 +1,3 @@
1
- export * from './ServerPropsProvider';
1
+ export { ServerPropsProvider, ServerPropsContext, } from './ServerPropsProvider';
2
2
  export { useShop } from './useShop';
3
3
  export { useUrl } from './useUrl';
@@ -0,0 +1,2 @@
1
+ export declare function setCache(cache?: Cache): void;
2
+ export declare function getCache(): Cache | undefined;
@@ -0,0 +1,6 @@
1
+ export function setCache(cache) {
2
+ globalThis.__cache = cache;
3
+ }
4
+ export function getCache() {
5
+ return globalThis.__cache;
6
+ }
@@ -1,6 +1,6 @@
1
1
  import { Logger } from '../../utilities/log';
2
- import type { ServerComponentResponse } from '../../framework/Hydration/ServerComponentResponse.server';
3
- import type { ServerComponentRequest } from '../../framework/Hydration/ServerComponentRequest.server';
2
+ import type { HydrogenResponse } from '../HydrogenResponse/HydrogenResponse.server';
3
+ import type { HydrogenRequest } from '../HydrogenRequest/HydrogenRequest.server';
4
4
  export declare type SessionSyncApi = {
5
5
  get: () => Record<string, string>;
6
6
  };
@@ -14,7 +14,7 @@ export declare type SessionStorageAdapter = {
14
14
  set: (request: Request, value: Record<string, string>) => Promise<string>;
15
15
  destroy: (request: Request) => Promise<string>;
16
16
  };
17
- export declare function getSyncSessionApi(request: ServerComponentRequest, componentResponse: ServerComponentResponse, log: Logger, session?: SessionStorageAdapter): {
17
+ export declare function getSyncSessionApi(request: HydrogenRequest, componentResponse: HydrogenResponse, log: Logger, session?: SessionStorageAdapter): {
18
18
  get(): any;
19
19
  };
20
20
  export declare const emptySessionImplementation: (log: Logger) => {
@@ -4,9 +4,9 @@
4
4
  * In the server, this file is transformed by Vite to inject server logic.
5
5
  * NOTE: Do not remove SSR-prefixed comments in this file.
6
6
  */
7
- import type { ServerComponentRequest } from '../framework/Hydration/ServerComponentRequest.server';
7
+ import type { HydrogenRequest } from './HydrogenRequest/HydrogenRequest.server';
8
8
  export declare const META_ENV_SSR = false;
9
- declare type ServerGetter<T> = (request: ServerComponentRequest) => T;
9
+ declare type ServerGetter<T> = (request: HydrogenRequest) => T;
10
10
  /**
11
11
  * Isomorphic hook to access context data. It gives access to the current request
12
12
  * when running on the server, and returns the provided client fallback in the browser.
@@ -5,6 +5,8 @@ declare type NavigationOptions = {
5
5
  reloadDocument?: boolean;
6
6
  /** The custom client state with the navigation. */
7
7
  clientState?: any;
8
+ /** Whether to emulate natural browser behavior and restore scroll position on navigation. Defaults to true. */
9
+ scroll?: any;
8
10
  };
9
11
  /**
10
12
  * The useNavigate hook imperatively navigates between routes.
@@ -5,10 +5,17 @@ import { useRouter } from '../Router/BrowserRouter.client';
5
5
  export function useNavigate() {
6
6
  const router = useRouter();
7
7
  return (path, options = { replace: false, reloadDocument: false }) => {
8
+ var _a;
9
+ const state = {
10
+ ...options === null || options === void 0 ? void 0 : options.clientState,
11
+ scroll: (_a = options === null || options === void 0 ? void 0 : options.scroll) !== null && _a !== void 0 ? _a : true,
12
+ };
8
13
  // @todo wait for RSC and then change focus for a11y?
9
- if (options === null || options === void 0 ? void 0 : options.replace)
10
- router.history.replace(path, (options === null || options === void 0 ? void 0 : options.clientState) || {});
11
- else
12
- router.history.push(path, (options === null || options === void 0 ? void 0 : options.clientState) || {});
14
+ if (options === null || options === void 0 ? void 0 : options.replace) {
15
+ router.history.replace(path, state);
16
+ }
17
+ else {
18
+ router.history.push(path, state);
19
+ }
13
20
  };
14
21
  }
@@ -1,8 +1,7 @@
1
1
  import { getLoggerWithContext, collectQueryCacheControlHeaders, collectQueryTimings, } from '../../utilities/log';
2
- import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '../../framework/cache-sub-request';
3
- import { runDelayedFunction } from '../../framework/runtime';
2
+ import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '../Cache/cache-sub-request';
4
3
  import { useRequestCacheData, useServerRequest } from '../ServerRequestProvider';
5
- import { CacheSeconds } from '../../framework/CachingStrategy';
4
+ import { CacheSeconds } from '../Cache/strategies';
6
5
  /**
7
6
  * The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
8
7
  * supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
@@ -44,6 +43,7 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
44
43
  * Attempt to read the query from cache. If it doesn't exist or if it's stale, regenerate it.
45
44
  */
46
45
  async function useCachedQueryFn() {
46
+ var _a, _b, _c, _d;
47
47
  // Call this hook before running any async stuff
48
48
  // to prevent losing the current React cycle.
49
49
  const request = useServerRequest();
@@ -60,8 +60,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
60
60
  */
61
61
  if (isStale(key, response)) {
62
62
  const lockKey = ['lock', ...(typeof key === 'string' ? [key] : key)];
63
- runDelayedFunction(async () => {
64
- const lockExists = await getItemFromCache(lockKey);
63
+ // Run revalidation asynchronously
64
+ const revalidatingPromise = getItemFromCache(lockKey).then(async (lockExists) => {
65
65
  if (lockExists)
66
66
  return;
67
67
  await setItemInCache(lockKey, true, CacheSeconds({
@@ -80,6 +80,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
80
80
  await deleteItemFromCache(lockKey);
81
81
  }
82
82
  });
83
+ // Asynchronously wait for it in workers
84
+ (_b = (_a = request.ctx.runtime) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.call(_a, revalidatingPromise);
83
85
  }
84
86
  return output;
85
87
  }
@@ -88,7 +90,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
88
90
  * Important: Do this async
89
91
  */
90
92
  if (shouldCacheResponse(newOutput)) {
91
- runDelayedFunction(() => setItemInCache(key, newOutput, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache));
93
+ const setItemInCachePromise = setItemInCache(key, newOutput, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
94
+ (_d = (_c = request.ctx.runtime) === null || _c === void 0 ? void 0 : _c.waitUntil) === null || _d === void 0 ? void 0 : _d.call(_c, setItemInCachePromise);
92
95
  }
93
96
  collectQueryCacheControlHeaders(request, key, generateSubRequestCacheControlHeader(resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache));
94
97
  return newOutput;
@@ -3,6 +3,7 @@
3
3
  import { createFromFetch, createFromReadableStream,
4
4
  // @ts-ignore
5
5
  } from '@shopify/hydrogen/vendor/react-server-dom-vite';
6
+ import { ClientAnalytics } from '../../client';
6
7
  import { RSC_PATHNAME } from '../../constants';
7
8
  let rscReader;
8
9
  // Hydrate an SSR response from <meta> tags placed in the DOM.
@@ -88,6 +89,7 @@ export function useServerResponse(state) {
88
89
  /* @ts-ignore */
89
90
  window.BOOMR.plugins.Hydrogen.trackSubPageLoadPerformance();
90
91
  }
92
+ ClientAnalytics.resetPageAnalyticsData();
91
93
  // Request a new flight response.
92
94
  response = createFromFetch(fetch(`${RSC_PATHNAME}?state=` + encodeURIComponent(key)));
93
95
  }
@@ -11,6 +11,7 @@ import inspect from 'vite-plugin-inspect';
11
11
  import react from '@vitejs/plugin-react';
12
12
  import cssModulesRsc from './plugins/vite-plugin-css-modules-rsc';
13
13
  import clientImports from './plugins/vite-plugin-client-imports';
14
+ import suppressWarnings from './plugins/vite-plugin-hydrogen-suppress-warnings';
14
15
  export default (pluginOptions = {}) => {
15
16
  return [
16
17
  process.env.VITE_INSPECT && inspect(),
@@ -25,6 +26,7 @@ export default (pluginOptions = {}) => {
25
26
  cssModulesRsc(),
26
27
  rsc(),
27
28
  platformEntry(),
29
+ suppressWarnings(),
28
30
  pluginOptions.purgeQueryCacheOnBuild && purgeQueryCache(),
29
31
  ];
30
32
  };