@shopify/hydrogen 0.22.0 → 0.24.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 (491) hide show
  1. package/CHANGELOG.md +240 -0
  2. package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +5 -5
  3. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +5 -8
  4. package/dist/esnext/components/CartLineProvider/context.d.ts +12 -2
  5. package/dist/esnext/components/CartLines/{CartLines.d.ts → CartLines.client.d.ts} +0 -0
  6. package/dist/esnext/components/CartLines/{CartLines.js → CartLines.client.js} +0 -0
  7. package/dist/esnext/components/CartLines/index.d.ts +1 -1
  8. package/dist/esnext/components/CartLines/index.js +1 -1
  9. package/dist/esnext/components/CartProvider/CartProvider.client.js +2 -5
  10. package/dist/esnext/components/CartProvider/cart-queries.d.ts +1 -1
  11. package/dist/esnext/components/CartProvider/cart-queries.js +11 -0
  12. package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +11 -1
  13. package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +11 -1
  14. package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +11 -1
  15. package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +11 -1
  16. package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +11 -1
  17. package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +11 -1
  18. package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +11 -1
  19. package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +11 -1
  20. package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +11 -1
  21. package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +11 -1
  22. package/dist/esnext/components/CartProvider/hooks.client.js +3 -5
  23. package/dist/esnext/components/CartProvider/types.d.ts +2 -0
  24. package/dist/esnext/components/DevTools.client.js +1 -1
  25. package/dist/esnext/components/Image/Image.d.ts +8 -0
  26. package/dist/esnext/components/Image/Image.js +58 -10
  27. package/dist/esnext/components/Link/Link.client.d.ts +2 -0
  28. package/dist/esnext/components/Link/Link.client.js +7 -4
  29. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +1 -1
  30. package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
  31. package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +141 -0
  32. package/dist/esnext/components/ProductOptionsProvider/context.d.ts +2 -0
  33. package/dist/esnext/components/{ProductProvider → ProductOptionsProvider}/context.js +0 -1
  34. package/dist/esnext/components/ProductOptionsProvider/index.d.ts +2 -0
  35. package/dist/esnext/components/ProductOptionsProvider/index.js +2 -0
  36. package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +5 -2
  37. package/dist/esnext/components/ProductPrice/ProductPrice.client.js +10 -12
  38. package/dist/esnext/components/index.d.ts +1 -1
  39. package/dist/esnext/components/index.js +1 -1
  40. package/dist/esnext/entry-client.js +106 -6
  41. package/dist/esnext/entry-server.d.ts +2 -15
  42. package/dist/esnext/entry-server.js +246 -322
  43. package/dist/esnext/foundation/Analytics/Analytics.client.js +15 -13
  44. package/dist/esnext/foundation/Analytics/Analytics.server.js +27 -20
  45. package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +4 -2
  46. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +16 -14
  47. package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
  48. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.d.ts +1 -0
  49. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/{PerformanceMetrics.server.js → ServerAnalyticsConnector.server.js} +7 -6
  50. package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.d.ts +1 -0
  51. package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.js +19 -0
  52. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.d.ts +3 -0
  53. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.js +190 -0
  54. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.d.ts +3 -0
  55. package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.js +24 -0
  56. package/dist/esnext/foundation/Analytics/connectors/Shopify/const.d.ts +28 -0
  57. package/dist/esnext/foundation/Analytics/connectors/Shopify/const.js +51 -0
  58. package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.d.ts +3 -0
  59. package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.js +56 -0
  60. package/dist/esnext/foundation/Analytics/hook.js +4 -2
  61. package/dist/esnext/foundation/Analytics/utils.d.ts +2 -0
  62. package/dist/esnext/foundation/Analytics/utils.js +21 -0
  63. package/dist/{node/framework → esnext/foundation/Cache}/cache-sub-request.d.ts +1 -1
  64. package/dist/esnext/{framework → foundation/Cache}/cache-sub-request.js +3 -3
  65. package/dist/esnext/{framework → foundation/Cache}/cache.d.ts +1 -1
  66. package/dist/esnext/{framework → foundation/Cache}/cache.js +3 -3
  67. package/dist/{node/framework/CachingStrategy → esnext/foundation/Cache/strategies}/index.d.ts +2 -1
  68. package/dist/esnext/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +1 -1
  69. package/dist/esnext/foundation/Cookie/Cookie.d.ts +3 -3
  70. package/dist/{node/framework/Hydration → esnext/foundation/Html}/Html.d.ts +3 -1
  71. package/dist/esnext/{framework/Hydration → foundation/Html}/Html.js +15 -2
  72. package/dist/{node/framework/Hydration/ServerComponentRequest.server.d.ts → esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +8 -3
  73. package/dist/esnext/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +3 -2
  74. package/dist/{node/framework/Hydration/ServerComponentResponse.server.d.ts → esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +7 -10
  75. package/dist/esnext/{framework/Hydration/ServerComponentResponse.server.js → foundation/HydrogenResponse/HydrogenResponse.server.js} +19 -15
  76. package/dist/esnext/foundation/Router/BrowserRouter.client.js +16 -9
  77. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
  78. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
  79. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +5 -6
  80. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -21
  81. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.d.ts +1 -1
  82. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +1 -1
  83. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +1 -0
  84. package/dist/esnext/foundation/index.d.ts +1 -1
  85. package/dist/esnext/foundation/index.js +1 -1
  86. package/dist/esnext/foundation/runtime.d.ts +2 -0
  87. package/dist/esnext/foundation/runtime.js +6 -0
  88. package/dist/esnext/foundation/session/session.d.ts +3 -3
  89. package/dist/esnext/foundation/ssr-interop.d.ts +2 -2
  90. package/dist/esnext/foundation/useNavigate/useNavigate.d.ts +2 -0
  91. package/dist/esnext/foundation/useNavigate/useNavigate.js +11 -4
  92. package/dist/esnext/foundation/useQuery/hooks.d.ts +1 -0
  93. package/dist/esnext/foundation/useQuery/hooks.js +24 -7
  94. package/dist/esnext/foundation/useRequestContext/index.d.ts +15 -0
  95. package/dist/esnext/foundation/useRequestContext/index.js +23 -0
  96. package/dist/esnext/framework/Hydration/rsc.js +2 -0
  97. package/dist/esnext/framework/plugin.js +2 -0
  98. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +5 -2
  99. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
  100. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +4 -12
  101. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.d.ts +3 -0
  102. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +19 -0
  103. package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +12 -2
  104. package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -2
  105. package/dist/esnext/hooks/useProductOptions/types.d.ts +17 -15
  106. package/dist/esnext/hooks/useProductOptions/useProductOptions.client.d.ts +1 -15
  107. package/dist/esnext/hooks/useProductOptions/useProductOptions.client.js +8 -107
  108. package/dist/esnext/hooks/useShopQuery/hooks.js +12 -6
  109. package/dist/esnext/index.d.ts +9 -3
  110. package/dist/esnext/index.js +7 -3
  111. package/dist/esnext/storefront-api-types.d.ts +10 -339
  112. package/dist/esnext/streaming.server.d.ts +0 -1
  113. package/dist/esnext/streaming.server.js +0 -4
  114. package/dist/esnext/types.d.ts +32 -23
  115. package/dist/esnext/utilities/apiRoutes.d.ts +2 -2
  116. package/dist/esnext/utilities/graphql-tracker.js +1 -1
  117. package/dist/esnext/utilities/index.d.ts +1 -1
  118. package/dist/esnext/utilities/index.js +1 -1
  119. package/dist/esnext/utilities/isBrowser/index.d.ts +1 -0
  120. package/dist/esnext/utilities/isBrowser/index.js +1 -0
  121. package/dist/esnext/utilities/isBrowser/isBrowser.d.ts +4 -0
  122. package/dist/esnext/utilities/isBrowser/isBrowser.js +6 -0
  123. package/dist/esnext/utilities/isServer/isServer.js +2 -2
  124. package/dist/esnext/utilities/log/index.d.ts +1 -1
  125. package/dist/esnext/utilities/log/index.js +1 -1
  126. package/dist/esnext/utilities/log/log-cache-header.d.ts +4 -4
  127. package/dist/esnext/utilities/log/log-query-timeline.d.ts +3 -3
  128. package/dist/esnext/utilities/log/log.d.ts +17 -11
  129. package/dist/esnext/utilities/log/log.js +29 -20
  130. package/dist/esnext/version.d.ts +1 -1
  131. package/dist/esnext/version.js +1 -1
  132. package/dist/node/client.d.ts +16 -0
  133. package/dist/node/client.js +43 -0
  134. package/dist/node/components/AddToCartButton/AddToCartButton.client.d.ts +23 -0
  135. package/dist/node/components/AddToCartButton/AddToCartButton.client.js +74 -0
  136. package/dist/node/components/AddToCartButton/index.d.ts +1 -0
  137. package/dist/node/components/AddToCartButton/index.js +5 -0
  138. package/dist/node/components/BuyNowButton/BuyNowButton.client.d.ts +18 -0
  139. package/dist/node/components/BuyNowButton/BuyNowButton.client.js +53 -0
  140. package/dist/node/components/BuyNowButton/index.d.ts +1 -0
  141. package/dist/node/components/BuyNowButton/index.js +5 -0
  142. package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +11 -0
  143. package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.js +44 -0
  144. package/dist/node/components/CartCheckoutButton/index.d.ts +1 -0
  145. package/dist/node/components/CartCheckoutButton/index.js +5 -0
  146. package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +14 -0
  147. package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.js +36 -0
  148. package/dist/node/components/CartEstimatedCost/index.d.ts +1 -0
  149. package/dist/node/components/CartEstimatedCost/index.js +5 -0
  150. package/dist/node/components/CartLineImage/CartLineImage.client.d.ts +9 -0
  151. package/dist/node/components/CartLineImage/CartLineImage.client.js +18 -0
  152. package/dist/node/components/CartLineImage/index.d.ts +1 -0
  153. package/dist/node/components/CartLineImage/index.js +5 -0
  154. package/dist/node/components/CartLinePrice/CartLinePrice.client.d.ts +12 -0
  155. package/dist/node/components/CartLinePrice/CartLinePrice.client.js +25 -0
  156. package/dist/node/components/CartLinePrice/index.d.ts +1 -0
  157. package/dist/node/components/CartLinePrice/index.js +5 -0
  158. package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +8 -0
  159. package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.js +19 -0
  160. package/dist/node/components/CartLineProductTitle/index.d.ts +1 -0
  161. package/dist/node/components/CartLineProductTitle/index.js +5 -0
  162. package/dist/node/components/CartLineProvider/CartLineProvider.client.d.ts +11 -0
  163. package/dist/node/components/CartLineProvider/CartLineProvider.client.js +15 -0
  164. package/dist/node/components/CartLineProvider/context.d.ts +36 -0
  165. package/dist/node/components/CartLineProvider/context.js +5 -0
  166. package/dist/node/components/CartLineProvider/index.d.ts +2 -0
  167. package/dist/node/components/CartLineProvider/index.js +7 -0
  168. package/dist/node/components/CartLineQuantity/CartLineQuantity.client.d.ts +8 -0
  169. package/dist/node/components/CartLineQuantity/CartLineQuantity.client.js +19 -0
  170. package/dist/node/components/CartLineQuantity/index.d.ts +1 -0
  171. package/dist/node/components/CartLineQuantity/index.js +5 -0
  172. package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +14 -0
  173. package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +31 -0
  174. package/dist/node/components/CartLineQuantityAdjustButton/index.d.ts +1 -0
  175. package/dist/node/components/CartLineQuantityAdjustButton/index.js +5 -0
  176. package/dist/node/components/CartLines/CartLines.client.d.ts +15 -0
  177. package/dist/node/components/CartLines/CartLines.client.js +44 -0
  178. package/dist/node/components/CartLines/index.d.ts +1 -0
  179. package/dist/node/components/CartLines/index.js +5 -0
  180. package/dist/node/components/CartProvider/CartProvider.client.d.ts +41 -0
  181. package/dist/node/components/CartProvider/CartProvider.client.js +547 -0
  182. package/dist/node/components/CartProvider/cart-queries.d.ts +10 -0
  183. package/dist/node/components/CartProvider/cart-queries.js +214 -0
  184. package/dist/node/components/CartProvider/constants.d.ts +2 -0
  185. package/dist/node/components/CartProvider/constants.js +5 -0
  186. package/dist/node/components/CartProvider/context.d.ts +2 -0
  187. package/dist/node/components/CartProvider/context.js +5 -0
  188. package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +96 -0
  189. package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.js +2 -0
  190. package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +96 -0
  191. package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +2 -0
  192. package/dist/node/components/CartProvider/graphql/CartCreateMutation.d.ts +95 -0
  193. package/dist/node/components/CartProvider/graphql/CartCreateMutation.js +2 -0
  194. package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +96 -0
  195. package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +2 -0
  196. package/dist/node/components/CartProvider/graphql/CartFragment.d.ts +82 -0
  197. package/dist/node/components/CartProvider/graphql/CartFragment.js +2 -0
  198. package/dist/node/components/CartProvider/graphql/CartLineAddMutation.d.ts +96 -0
  199. package/dist/node/components/CartProvider/graphql/CartLineAddMutation.js +2 -0
  200. package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +96 -0
  201. package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.js +2 -0
  202. package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +96 -0
  203. package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.js +2 -0
  204. package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +96 -0
  205. package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.js +2 -0
  206. package/dist/node/components/CartProvider/graphql/CartQuery.d.ts +91 -0
  207. package/dist/node/components/CartProvider/graphql/CartQuery.js +2 -0
  208. package/dist/node/components/CartProvider/hooks.client.d.ts +15 -0
  209. package/dist/node/components/CartProvider/hooks.client.js +88 -0
  210. package/dist/node/components/CartProvider/index.d.ts +4 -0
  211. package/dist/node/components/CartProvider/index.js +10 -0
  212. package/dist/node/components/CartProvider/types.d.ts +104 -0
  213. package/dist/node/components/CartProvider/types.js +2 -0
  214. package/dist/node/components/CartShopPayButton/CartShopPayButton.client.d.ts +9 -0
  215. package/dist/node/components/CartShopPayButton/CartShopPayButton.client.js +46 -0
  216. package/dist/node/components/CartShopPayButton/index.d.ts +1 -0
  217. package/dist/node/components/CartShopPayButton/index.js +5 -0
  218. package/dist/node/components/ExternalVideo/ExternalVideo.d.ts +21 -0
  219. package/dist/node/components/ExternalVideo/ExternalVideo.js +21 -0
  220. package/dist/node/components/ExternalVideo/index.d.ts +1 -0
  221. package/dist/node/components/ExternalVideo/index.js +5 -0
  222. package/dist/node/components/Image/Image.d.ts +8 -0
  223. package/dist/node/components/Image/Image.js +57 -9
  224. package/dist/node/components/Link/Link.client.d.ts +25 -0
  225. package/dist/node/components/Link/Link.client.js +165 -0
  226. package/dist/node/components/Link/index.d.ts +1 -0
  227. package/dist/node/components/Link/index.js +5 -0
  228. package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +6 -0
  229. package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.js +11 -0
  230. package/dist/node/components/LocalizationProvider/LocalizationContext.client.d.ts +6 -0
  231. package/dist/node/components/LocalizationProvider/LocalizationContext.client.js +5 -0
  232. package/dist/node/components/LocalizationProvider/LocalizationProvider.server.d.ts +33 -0
  233. package/dist/node/components/LocalizationProvider/LocalizationProvider.server.js +51 -0
  234. package/dist/node/components/MediaFile/MediaFile.d.ts +19 -0
  235. package/dist/node/components/MediaFile/MediaFile.js +39 -0
  236. package/dist/node/components/MediaFile/index.d.ts +1 -0
  237. package/dist/node/components/MediaFile/index.js +5 -0
  238. package/dist/node/components/Metafield/Metafield.client.d.ts +21 -0
  239. package/dist/node/components/Metafield/Metafield.client.js +75 -0
  240. package/dist/node/components/Metafield/index.d.ts +2 -0
  241. package/dist/node/components/Metafield/index.js +5 -0
  242. package/dist/node/components/Metafield/types.d.ts +4 -0
  243. package/dist/node/components/Metafield/types.js +2 -0
  244. package/dist/node/components/ModelViewer/ModelViewer.client.d.ts +128 -0
  245. package/dist/node/components/ModelViewer/ModelViewer.client.js +132 -0
  246. package/dist/node/components/ModelViewer/index.d.ts +1 -0
  247. package/dist/node/components/ModelViewer/index.js +5 -0
  248. package/dist/node/components/Money/Money.client.d.ts +25 -0
  249. package/dist/node/components/Money/Money.client.js +46 -0
  250. package/dist/node/components/Money/index.d.ts +1 -0
  251. package/dist/node/components/Money/index.js +5 -0
  252. package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
  253. package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.js +168 -0
  254. package/dist/node/components/ProductOptionsProvider/context.d.ts +2 -0
  255. package/dist/node/components/ProductOptionsProvider/context.js +5 -0
  256. package/dist/node/components/ProductOptionsProvider/index.d.ts +2 -0
  257. package/dist/node/components/ProductOptionsProvider/index.js +7 -0
  258. package/dist/node/components/ProductPrice/ProductPrice.client.d.ts +18 -0
  259. package/dist/node/components/ProductPrice/ProductPrice.client.js +61 -0
  260. package/dist/node/components/ProductPrice/index.d.ts +1 -0
  261. package/dist/node/components/ProductPrice/index.js +5 -0
  262. package/dist/node/components/Seo/CollectionSeo.client.d.ts +3 -0
  263. package/dist/node/components/Seo/CollectionSeo.client.js +22 -0
  264. package/dist/node/components/Seo/DefaultPageSeo.client.d.ts +3 -0
  265. package/dist/node/components/Seo/DefaultPageSeo.client.js +25 -0
  266. package/dist/node/components/Seo/DescriptionSeo.client.d.ts +4 -0
  267. package/dist/node/components/Seo/DescriptionSeo.client.js +17 -0
  268. package/dist/node/components/Seo/HomePageSeo.client.d.ts +2 -0
  269. package/dist/node/components/Seo/HomePageSeo.client.js +32 -0
  270. package/dist/node/components/Seo/ImageSeo.client.d.ts +3 -0
  271. package/dist/node/components/Seo/ImageSeo.client.js +17 -0
  272. package/dist/node/components/Seo/NoIndexSeo.client.d.ts +3 -0
  273. package/dist/node/components/Seo/NoIndexSeo.client.js +17 -0
  274. package/dist/node/components/Seo/PageSeo.client.d.ts +3 -0
  275. package/dist/node/components/Seo/PageSeo.client.js +20 -0
  276. package/dist/node/components/Seo/ProductSeo.client.d.ts +5 -0
  277. package/dist/node/components/Seo/ProductSeo.client.js +70 -0
  278. package/dist/node/components/Seo/Seo.client.d.ts +30 -0
  279. package/dist/node/components/Seo/Seo.client.js +38 -0
  280. package/dist/node/components/Seo/TitleSeo.client.d.ts +3 -0
  281. package/dist/node/components/Seo/TitleSeo.client.js +17 -0
  282. package/dist/node/components/Seo/TwitterSeo.client.d.ts +2 -0
  283. package/dist/node/components/Seo/TwitterSeo.client.js +16 -0
  284. package/dist/node/components/Seo/index.d.ts +1 -0
  285. package/dist/node/components/Seo/index.js +5 -0
  286. package/dist/node/components/Seo/seo-types.d.ts +17 -0
  287. package/dist/node/components/Seo/seo-types.js +2 -0
  288. package/dist/node/components/ShopPayButton/ShopPayButton.client.d.ts +38 -0
  289. package/dist/node/components/ShopPayButton/ShopPayButton.client.js +60 -0
  290. package/dist/node/components/ShopPayButton/index.d.ts +1 -0
  291. package/dist/node/components/ShopPayButton/index.js +5 -0
  292. package/dist/node/components/Video/Video.d.ts +14 -0
  293. package/dist/node/components/Video/Video.js +31 -0
  294. package/dist/node/components/Video/index.d.ts +1 -0
  295. package/dist/node/components/Video/index.js +5 -0
  296. package/dist/node/components/index.d.ts +28 -0
  297. package/dist/node/components/index.js +59 -0
  298. package/dist/node/components/types.d.ts +71 -0
  299. package/dist/node/components/types.js +11 -0
  300. package/dist/node/entry-server.d.ts +2 -15
  301. package/dist/node/entry-server.js +245 -321
  302. package/dist/node/foundation/Analytics/Analytics.client.js +15 -13
  303. package/dist/node/foundation/Analytics/Analytics.server.js +27 -20
  304. package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +4 -2
  305. package/dist/node/foundation/Analytics/ClientAnalytics.js +15 -13
  306. package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
  307. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.d.ts +7 -0
  308. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +68 -0
  309. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.d.ts +1 -0
  310. package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +27 -0
  311. package/dist/node/foundation/Analytics/hook.js +4 -2
  312. package/dist/node/foundation/Analytics/index.d.ts +1 -0
  313. package/dist/node/foundation/Analytics/index.js +5 -0
  314. package/dist/node/foundation/Analytics/utils.d.ts +2 -0
  315. package/dist/node/foundation/Analytics/utils.js +24 -1
  316. package/dist/{esnext/framework → node/foundation/Cache}/cache-sub-request.d.ts +1 -1
  317. package/dist/node/{framework → foundation/Cache}/cache-sub-request.js +4 -4
  318. package/dist/node/{framework → foundation/Cache}/cache.d.ts +1 -1
  319. package/dist/node/{framework → foundation/Cache}/cache.js +5 -5
  320. package/dist/{esnext/framework/CachingStrategy → node/foundation/Cache/strategies}/index.d.ts +2 -1
  321. package/dist/node/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +3 -3
  322. package/dist/node/foundation/Head/Head.client.d.ts +5 -0
  323. package/dist/node/foundation/Head/Head.client.js +17 -0
  324. package/dist/node/foundation/Head/index.d.ts +1 -0
  325. package/dist/node/foundation/Head/index.js +5 -0
  326. package/dist/{esnext/framework/Hydration → node/foundation/Html}/Html.d.ts +3 -1
  327. package/dist/node/{framework/Hydration → foundation/Html}/Html.js +15 -2
  328. package/dist/{esnext/framework/Hydration/ServerComponentRequest.server.d.ts → node/foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +8 -3
  329. package/dist/node/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +5 -4
  330. package/dist/{esnext/framework/Hydration/ServerComponentResponse.server.d.ts → node/foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +7 -10
  331. package/dist/node/{framework/Hydration/ServerComponentResponse.server.js → foundation/HydrogenResponse/HydrogenResponse.server.js} +23 -19
  332. package/dist/node/foundation/Router/BrowserRouter.client.js +16 -9
  333. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
  334. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
  335. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +5 -6
  336. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -21
  337. package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +7 -0
  338. package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.js +35 -0
  339. package/dist/node/foundation/ShopifyProvider/index.d.ts +1 -0
  340. package/dist/node/foundation/ShopifyProvider/index.js +5 -0
  341. package/dist/node/foundation/fetchSync/client/fetchSync.d.ts +10 -0
  342. package/dist/node/foundation/fetchSync/client/fetchSync.js +33 -0
  343. package/dist/node/foundation/fetchSync/server/fetchSync.d.ts +8 -0
  344. package/dist/node/foundation/fetchSync/server/fetchSync.js +33 -0
  345. package/dist/node/foundation/fetchSync/types.d.ts +5 -0
  346. package/dist/node/foundation/fetchSync/types.js +2 -0
  347. package/dist/node/foundation/index.d.ts +3 -0
  348. package/dist/node/foundation/index.js +10 -0
  349. package/dist/node/foundation/runtime.d.ts +2 -0
  350. package/dist/node/foundation/runtime.js +11 -0
  351. package/dist/node/foundation/session/session.d.ts +3 -3
  352. package/dist/node/foundation/ssr-interop.d.ts +2 -2
  353. package/dist/node/foundation/useNavigate/useNavigate.d.ts +2 -0
  354. package/dist/node/foundation/useNavigate/useNavigate.js +11 -4
  355. package/dist/node/foundation/useQuery/hooks.d.ts +37 -0
  356. package/dist/node/foundation/useQuery/hooks.js +119 -0
  357. package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.d.ts +10 -0
  358. package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.js +34 -0
  359. package/dist/node/foundation/useRouteParams/useRouteParams.d.ts +4 -0
  360. package/dist/node/foundation/useRouteParams/useRouteParams.js +13 -0
  361. package/dist/node/foundation/useServerProps/index.d.ts +1 -0
  362. package/dist/node/foundation/useServerProps/index.js +5 -0
  363. package/dist/node/foundation/useSession/useSession.d.ts +2 -0
  364. package/dist/node/foundation/useSession/useSession.js +12 -0
  365. package/dist/node/foundation/useShop/index.d.ts +1 -0
  366. package/dist/node/foundation/useShop/index.js +5 -0
  367. package/dist/node/foundation/useShop/use-shop.d.ts +6 -0
  368. package/dist/node/foundation/useShop/use-shop.js +18 -0
  369. package/dist/node/foundation/useUrl/index.d.ts +1 -0
  370. package/dist/node/foundation/useUrl/index.js +5 -0
  371. package/dist/node/foundation/useUrl/useUrl.d.ts +4 -0
  372. package/dist/node/foundation/useUrl/useUrl.js +32 -0
  373. package/dist/node/framework/Hydration/rsc.js +2 -0
  374. package/dist/node/framework/plugin.js +2 -0
  375. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +5 -2
  376. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
  377. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +4 -12
  378. package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.d.ts +3 -0
  379. package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +21 -0
  380. package/dist/node/hooks/index.d.ts +6 -0
  381. package/dist/node/hooks/index.js +28 -0
  382. package/dist/node/hooks/useCart/index.d.ts +1 -0
  383. package/dist/node/hooks/useCart/index.js +5 -0
  384. package/dist/node/hooks/useCart/useCart.d.ts +4 -0
  385. package/dist/node/hooks/useCart/useCart.js +19 -0
  386. package/dist/node/hooks/useCartLine/index.d.ts +1 -0
  387. package/dist/node/hooks/useCartLine/index.js +5 -0
  388. package/dist/node/hooks/useCartLine/useCartLine.d.ts +39 -0
  389. package/dist/node/hooks/useCartLine/useCartLine.js +16 -0
  390. package/dist/node/hooks/useCountry/index.d.ts +1 -0
  391. package/dist/node/hooks/useCountry/index.js +5 -0
  392. package/dist/node/hooks/useCountry/useCountry.d.ts +7 -0
  393. package/dist/node/hooks/useCountry/useCountry.js +21 -0
  394. package/dist/node/hooks/useLoadScript/index.d.ts +1 -0
  395. package/dist/node/hooks/useLoadScript/index.js +5 -0
  396. package/dist/node/hooks/useLoadScript/useLoadScript.client.d.ts +8 -0
  397. package/dist/node/hooks/useLoadScript/useLoadScript.client.js +27 -0
  398. package/dist/node/hooks/useMeasurement/hooks.d.ts +9 -0
  399. package/dist/node/hooks/useMeasurement/hooks.js +17 -0
  400. package/dist/node/hooks/useMeasurement/index.d.ts +1 -0
  401. package/dist/node/hooks/useMeasurement/index.js +5 -0
  402. package/dist/node/hooks/useMoney/hooks.d.ts +54 -0
  403. package/dist/node/hooks/useMoney/hooks.js +70 -0
  404. package/dist/node/hooks/useMoney/index.d.ts +1 -0
  405. package/dist/node/hooks/useMoney/index.js +5 -0
  406. package/dist/node/hooks/useParsedMetafields/index.d.ts +1 -0
  407. package/dist/node/hooks/useParsedMetafields/index.js +5 -0
  408. package/dist/node/hooks/useParsedMetafields/useParsedMetafields.d.ts +21 -0
  409. package/dist/node/hooks/useParsedMetafields/useParsedMetafields.js +25 -0
  410. package/dist/node/hooks/useProductOptions/helpers.d.ts +6 -0
  411. package/dist/node/hooks/useProductOptions/helpers.js +46 -0
  412. package/dist/node/hooks/useProductOptions/index.d.ts +2 -0
  413. package/dist/node/hooks/useProductOptions/index.js +20 -0
  414. package/dist/node/hooks/useProductOptions/types.d.ts +44 -0
  415. package/dist/node/hooks/useProductOptions/types.js +2 -0
  416. package/dist/node/hooks/useProductOptions/useProductOptions.client.d.ts +1 -0
  417. package/dist/node/hooks/useProductOptions/useProductOptions.client.js +13 -0
  418. package/dist/node/hooks/useShopQuery/hooks.d.ts +28 -0
  419. package/dist/node/hooks/useShopQuery/hooks.js +171 -0
  420. package/dist/node/hooks/useShopQuery/index.d.ts +1 -0
  421. package/dist/node/hooks/useShopQuery/index.js +5 -0
  422. package/dist/node/storefront-api-types.d.ts +10 -339
  423. package/dist/node/streaming.server.d.ts +0 -1
  424. package/dist/node/streaming.server.js +1 -6
  425. package/dist/node/types.d.ts +32 -23
  426. package/dist/node/utilities/apiRoutes.d.ts +2 -2
  427. package/dist/node/utilities/devtools.d.ts +11 -0
  428. package/dist/node/utilities/devtools.js +15 -0
  429. package/dist/node/utilities/graphql-tag.d.ts +1 -0
  430. package/dist/node/utilities/graphql-tag.js +10 -0
  431. package/dist/node/utilities/graphql-tracker.d.ts +17 -0
  432. package/dist/node/utilities/graphql-tracker.js +130 -0
  433. package/dist/node/utilities/index.d.ts +1 -1
  434. package/dist/node/utilities/index.js +3 -3
  435. package/dist/node/utilities/isBrowser/index.d.ts +1 -0
  436. package/dist/node/utilities/isBrowser/index.js +5 -0
  437. package/dist/node/utilities/isBrowser/isBrowser.d.ts +4 -0
  438. package/dist/node/utilities/isBrowser/isBrowser.js +10 -0
  439. package/dist/node/utilities/isServer/isServer.js +2 -2
  440. package/dist/node/utilities/log/index.d.ts +1 -1
  441. package/dist/node/utilities/log/index.js +1 -3
  442. package/dist/node/utilities/log/log-cache-header.d.ts +4 -4
  443. package/dist/node/utilities/log/log-query-timeline.d.ts +3 -3
  444. package/dist/node/utilities/log/log.d.ts +17 -11
  445. package/dist/node/utilities/log/log.js +30 -23
  446. package/dist/node/version.d.ts +1 -1
  447. package/dist/node/version.js +1 -1
  448. package/package.json +4 -2
  449. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +234 -53
  450. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +77 -59
  451. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +30 -30
  452. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +199 -70
  453. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +38 -35
  454. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +9 -8
  455. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +3 -3
  456. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +3 -7
  457. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +235 -54
  458. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +77 -59
  459. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +199 -70
  460. package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +9 -8
  461. package/vendor/react-server-dom-vite/package.json +1 -1
  462. package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.d.ts +0 -8
  463. package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.js +0 -12
  464. package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +0 -24
  465. package/dist/esnext/components/ProductProvider/ProductProvider.client.js +0 -34
  466. package/dist/esnext/components/ProductProvider/context.d.ts +0 -29
  467. package/dist/esnext/components/ProductProvider/index.d.ts +0 -2
  468. package/dist/esnext/components/ProductProvider/index.js +0 -2
  469. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.d.ts +0 -1
  470. package/dist/esnext/framework/config.d.ts +0 -6
  471. package/dist/esnext/framework/config.js +0 -6
  472. package/dist/esnext/framework/runtime.d.ts +0 -13
  473. package/dist/esnext/framework/runtime.js +0 -27
  474. package/dist/esnext/hooks/useProduct/index.d.ts +0 -1
  475. package/dist/esnext/hooks/useProduct/index.js +0 -1
  476. package/dist/esnext/hooks/useProduct/useProduct.d.ts +0 -52
  477. package/dist/esnext/hooks/useProduct/useProduct.js +0 -43
  478. package/dist/esnext/utilities/isClient/index.d.ts +0 -1
  479. package/dist/esnext/utilities/isClient/index.js +0 -1
  480. package/dist/esnext/utilities/isClient/isClient.d.ts +0 -4
  481. package/dist/esnext/utilities/isClient/isClient.js +0 -6
  482. package/dist/node/framework/config.d.ts +0 -6
  483. package/dist/node/framework/config.js +0 -11
  484. package/dist/node/framework/runtime.d.ts +0 -13
  485. package/dist/node/framework/runtime.js +0 -35
  486. package/dist/node/utilities/defer.d.ts +0 -6
  487. package/dist/node/utilities/defer.js +0 -18
  488. package/dist/node/utilities/isClient/index.d.ts +0 -1
  489. package/dist/node/utilities/isClient/index.js +0 -5
  490. package/dist/node/utilities/isClient/isClient.d.ts +0 -4
  491. package/dist/node/utilities/isClient/isClient.js +0 -10
@@ -6,16 +6,12 @@ const ClientAnalytics_1 = require("./ClientAnalytics");
6
6
  function Analytics({ analyticsDataFromServer, }) {
7
7
  (0, react_1.useEffect)(() => {
8
8
  const urlParams = new URLSearchParams(window.location.search);
9
- if (urlParams.has('utm_source')) {
10
- ClientAnalytics_1.ClientAnalytics.pushToPageAnalyticsData({
11
- id: urlParams.get('utm_id'),
12
- source: urlParams.get('utm_source'),
13
- campaign: urlParams.get('utm_campaign'),
14
- medium: urlParams.get('utm_medium'),
15
- content: urlParams.get('utm_content'),
16
- term: urlParams.get('utm_term'),
17
- }, 'utm');
18
- }
9
+ addUTMData(urlParams, 'id');
10
+ addUTMData(urlParams, 'source');
11
+ addUTMData(urlParams, 'campaign');
12
+ addUTMData(urlParams, 'medium');
13
+ addUTMData(urlParams, 'content');
14
+ addUTMData(urlParams, 'term');
19
15
  ClientAnalytics_1.ClientAnalytics.pushToPageAnalyticsData(analyticsDataFromServer);
20
16
  ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.PAGE_VIEW, true);
21
17
  if (analyticsDataFromServer.publishEventsOnNavigate) {
@@ -23,10 +19,16 @@ function Analytics({ analyticsDataFromServer, }) {
23
19
  ClientAnalytics_1.ClientAnalytics.publish(eventName, true);
24
20
  });
25
21
  }
26
- return function cleanup() {
27
- ClientAnalytics_1.ClientAnalytics.resetPageAnalyticsData();
28
- };
29
22
  }, [analyticsDataFromServer]);
30
23
  return null;
31
24
  }
32
25
  exports.Analytics = Analytics;
26
+ function addUTMData(urlParams, key) {
27
+ if (urlParams.has(`utm_${key}`)) {
28
+ ClientAnalytics_1.ClientAnalytics.pushToPageAnalyticsData({
29
+ utm: {
30
+ [key]: urlParams.get(`utm_${key}`),
31
+ },
32
+ });
33
+ }
34
+ }
@@ -32,29 +32,20 @@ const hook_1 = require("./hook");
32
32
  const Analytics_client_1 = require("./Analytics.client");
33
33
  const ServerRequestProvider_1 = require("../ServerRequestProvider");
34
34
  const AnalyticsErrorBoundary_client_1 = __importDefault(require("../AnalyticsErrorBoundary.client"));
35
- const DELAY_KEY = 'analytics-delay';
35
+ const utilities_1 = require("../../utilities");
36
+ const DELAY_KEY_1 = 'analytics-delay-1';
37
+ const DELAY_KEY_2 = 'analytics-delay-2';
36
38
  function Analytics() {
37
39
  const cache = (0, ServerRequestProvider_1.useServerRequest)().ctx.cache;
38
40
  // If render cache is empty, create a 50 ms delay so that React doesn't resolve this
39
41
  // component too early and potentially cause a mismatch in hydration
40
- if (cache.size === 0 && !cache.has(DELAY_KEY)) {
41
- let result;
42
- let promise;
43
- cache.set(DELAY_KEY, () => {
44
- if (result !== undefined) {
45
- return result;
46
- }
47
- if (!promise) {
48
- promise = new Promise((resolve) => {
49
- setTimeout(() => {
50
- result = true;
51
- resolve(true);
52
- }, 50);
53
- });
54
- }
55
- throw promise;
56
- });
42
+ if (cache.size === 0 && !cache.has(DELAY_KEY_1)) {
43
+ analyticsDelay(cache, DELAY_KEY_1, 50);
57
44
  }
45
+ // If this delay is created, execute it
46
+ cache.has(DELAY_KEY_1) && cache.get(DELAY_KEY_1).read();
47
+ // clean up this key so that it won't be saved to the preload cache
48
+ cache.delete(DELAY_KEY_1);
58
49
  // Make sure all queries have returned before rendering the Analytics server component
59
50
  cache.forEach((cacheFn) => {
60
51
  if (cacheFn && typeof cacheFn === 'function') {
@@ -63,8 +54,24 @@ function Analytics() {
63
54
  throw result;
64
55
  }
65
56
  });
66
- const analyticsData = (0, hook_1.useServerAnalytics)();
57
+ // If all queries has returned (could be from cached queries),
58
+ // delay Analytic component by another 1ms (put this component
59
+ // to the end of the render queue) so that other scheduled
60
+ // render work can be processed by React's concurrent render first
61
+ if (cache.size > 1 && !cache.has(DELAY_KEY_2)) {
62
+ analyticsDelay(cache, DELAY_KEY_2, 1);
63
+ }
64
+ cache.has(DELAY_KEY_2) && cache.get(DELAY_KEY_2).read();
65
+ cache.delete(DELAY_KEY_2);
67
66
  return (React.createElement(AnalyticsErrorBoundary_client_1.default, null,
68
- React.createElement(Analytics_client_1.Analytics, { analyticsDataFromServer: analyticsData })));
67
+ React.createElement(Analytics_client_1.Analytics, { analyticsDataFromServer: (0, hook_1.useServerAnalytics)() })));
69
68
  }
70
69
  exports.Analytics = Analytics;
70
+ function analyticsDelay(cache, delayKey, delay) {
71
+ const delayPromise = (0, utilities_1.wrapPromise)(new Promise((resolve) => {
72
+ setTimeout(() => {
73
+ resolve(true);
74
+ }, delay);
75
+ }));
76
+ cache.set(delayKey, delayPromise);
77
+ }
@@ -1,10 +1,11 @@
1
1
  import type { Subscriber, SubscriberFunction } from './types';
2
- declare function pushToPageAnalyticsData(data: any, namespace?: string): void;
2
+ declare function pushToPageAnalyticsData(data: any): void;
3
3
  declare function getPageAnalyticsData(): any;
4
4
  declare function resetPageAnalyticsData(): void;
5
- declare function publish(eventname: string, guardDup?: boolean, payload?: any): void;
5
+ declare function publish(eventname: string, guardDup?: boolean, payload?: {}): void;
6
6
  declare function subscribe(eventname: string, callbackFunction: SubscriberFunction): Subscriber;
7
7
  declare function pushToServer(init?: RequestInit, searchParam?: string): Promise<Response>;
8
+ declare function hasSentFirstPageView(): Boolean;
8
9
  export declare const ClientAnalytics: {
9
10
  pushToPageAnalyticsData: typeof pushToPageAnalyticsData;
10
11
  getPageAnalyticsData: typeof getPageAnalyticsData;
@@ -21,5 +22,6 @@ export declare const ClientAnalytics: {
21
22
  DISCOUNT_CODE_UPDATED: string;
22
23
  PERFORMANCE: string;
23
24
  };
25
+ hasSentFirstPageView: typeof hasSentFirstPageView;
24
26
  };
25
27
  export {};
@@ -7,6 +7,7 @@ const constants_1 = require("../../constants");
7
7
  const ssr_interop_1 = require("../ssr-interop");
8
8
  const subscribers = {};
9
9
  let pageAnalyticsData = {};
10
+ let isFirstPageViewSent = false;
10
11
  const guardDupEvents = {};
11
12
  const USAGE_ERROR = 'ClientAnalytics should only be used within the useEffect callback or event handlers';
12
13
  function isInvokedFromServer() {
@@ -16,15 +17,10 @@ function isInvokedFromServer() {
16
17
  }
17
18
  return false;
18
19
  }
19
- function pushToPageAnalyticsData(data, namespace) {
20
+ function pushToPageAnalyticsData(data) {
20
21
  if (isInvokedFromServer())
21
22
  return;
22
- if (namespace) {
23
- pageAnalyticsData[namespace] = Object.assign({}, pageAnalyticsData[namespace] || {}, data);
24
- }
25
- else {
26
- pageAnalyticsData = Object.assign({}, pageAnalyticsData, data);
27
- }
23
+ pageAnalyticsData = (0, utils_1.mergeDeep)(pageAnalyticsData, data);
28
24
  }
29
25
  function getPageAnalyticsData() {
30
26
  if (isInvokedFromServer())
@@ -36,12 +32,10 @@ function resetPageAnalyticsData() {
36
32
  return;
37
33
  pageAnalyticsData = {};
38
34
  }
39
- function publish(eventname, guardDup = false, payload) {
35
+ function publish(eventname, guardDup = false, payload = {}) {
40
36
  if (isInvokedFromServer())
41
37
  return;
42
38
  const namedspacedEventname = (0, utils_1.getNamedspacedEventname)(eventname);
43
- const subs = subscribers[namedspacedEventname];
44
- const combinedPayload = Object.assign({}, pageAnalyticsData, payload);
45
39
  // De-dup events due to re-renders
46
40
  if (guardDup) {
47
41
  const eventGuardTimeout = guardDupEvents[namedspacedEventname];
@@ -49,15 +43,19 @@ function publish(eventname, guardDup = false, payload) {
49
43
  clearTimeout(eventGuardTimeout);
50
44
  }
51
45
  const namespacedTimeout = setTimeout(() => {
52
- publishEvent(subs, combinedPayload);
46
+ publishEvent(namedspacedEventname, (0, utils_1.mergeDeep)(pageAnalyticsData, payload));
53
47
  }, 100);
54
48
  guardDupEvents[namedspacedEventname] = namespacedTimeout;
55
49
  }
56
50
  else {
57
- publishEvent(subs, combinedPayload);
51
+ publishEvent(namedspacedEventname, (0, utils_1.mergeDeep)(pageAnalyticsData, payload));
58
52
  }
59
53
  }
60
- function publishEvent(subs, payload) {
54
+ function publishEvent(eventname, payload) {
55
+ const subs = subscribers[eventname];
56
+ if (!isFirstPageViewSent && eventname === const_1.eventNames.PAGE_VIEW) {
57
+ isFirstPageViewSent = true;
58
+ }
61
59
  if (subs) {
62
60
  Object.keys(subs).forEach((key) => {
63
61
  subs[key](payload);
@@ -89,6 +87,9 @@ function pushToServer(init, searchParam) {
89
87
  },
90
88
  }, init));
91
89
  }
90
+ function hasSentFirstPageView() {
91
+ return isFirstPageViewSent;
92
+ }
92
93
  exports.ClientAnalytics = {
93
94
  pushToPageAnalyticsData,
94
95
  getPageAnalyticsData,
@@ -97,4 +98,5 @@ exports.ClientAnalytics = {
97
98
  subscribe,
98
99
  pushToServer,
99
100
  eventNames: const_1.eventNames,
101
+ hasSentFirstPageView,
100
102
  };
@@ -3,16 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ServerAnalyticsRoute = void 0;
4
4
  const log_1 = require("../../utilities/log");
5
5
  function ServerAnalyticsRoute(request, serverAnalyticsConnectors) {
6
- if (request.headers.get('Content-Length') === '0') {
6
+ const requestHeader = request.headers;
7
+ const requestUrl = request.url;
8
+ if (requestHeader.get('Content-Length') === '0') {
7
9
  serverAnalyticsConnectors === null || serverAnalyticsConnectors === void 0 ? void 0 : serverAnalyticsConnectors.forEach((connector) => {
8
- connector.request(request);
10
+ connector.request(requestUrl, request.headers);
9
11
  });
10
12
  }
11
- else if (request.headers.get('Content-Type') === 'application/json') {
13
+ else if (requestHeader.get('Content-Type') === 'application/json') {
12
14
  Promise.resolve(request.json())
13
15
  .then((data) => {
14
16
  serverAnalyticsConnectors === null || serverAnalyticsConnectors === void 0 ? void 0 : serverAnalyticsConnectors.forEach((connector) => {
15
- connector.request(request, data, 'json');
17
+ connector.request(requestUrl, requestHeader, data, 'json');
16
18
  });
17
19
  })
18
20
  .catch((error) => {
@@ -23,7 +25,7 @@ function ServerAnalyticsRoute(request, serverAnalyticsConnectors) {
23
25
  Promise.resolve(request.text())
24
26
  .then((data) => {
25
27
  serverAnalyticsConnectors === null || serverAnalyticsConnectors === void 0 ? void 0 : serverAnalyticsConnectors.forEach((connector) => {
26
- connector.request(request, data, 'text');
28
+ connector.request(requestUrl, requestHeader, data, 'text');
27
29
  });
28
30
  })
29
31
  .catch((error) => {
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ interface Window {
3
+ BOOMR: any;
4
+ BOOMR_onload: any;
5
+ }
6
+ }
7
+ export declare function PerformanceMetrics(): null;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PerformanceMetrics = void 0;
4
+ const react_1 = require("react");
5
+ const load_script_1 = require("../../../../utilities/load_script");
6
+ const ClientAnalytics_1 = require("../../ClientAnalytics");
7
+ const useShop_1 = require("../../../useShop");
8
+ const URL = 'https://cdn.shopify.com/shopifycloud/boomerang/shopify-boomerang-hydrogen.min.js';
9
+ function PerformanceMetrics() {
10
+ const { storeDomain } = (0, useShop_1.useShop)();
11
+ (0, react_1.useEffect)(() => {
12
+ try {
13
+ (function () {
14
+ if (window.BOOMR &&
15
+ (window.BOOMR.version || window.BOOMR.snippetExecuted)) {
16
+ return;
17
+ }
18
+ // Executes only on first mount
19
+ window.BOOMR = window.BOOMR || {};
20
+ window.BOOMR.hydrogenPerformanceEvent = (data) => {
21
+ ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.PERFORMANCE, true, data);
22
+ ClientAnalytics_1.ClientAnalytics.pushToServer({
23
+ body: JSON.stringify(data),
24
+ }, ClientAnalytics_1.ClientAnalytics.eventNames.PERFORMANCE);
25
+ };
26
+ window.BOOMR.storeDomain = storeDomain;
27
+ function boomerangSaveLoadTime(e) {
28
+ window.BOOMR_onload = (e && e.timeStamp) || Date.now();
29
+ }
30
+ // @ts-ignore
31
+ function boomerangInit(e) {
32
+ e.detail.BOOMR.init();
33
+ e.detail.BOOMR.t_end = Date.now();
34
+ }
35
+ if (window.addEventListener) {
36
+ window.addEventListener('load', boomerangSaveLoadTime, false);
37
+ // @ts-ignore
38
+ }
39
+ else if (window.attachEvent) {
40
+ // @ts-ignore
41
+ window.attachEvent('onload', boomerangSaveLoadTime);
42
+ }
43
+ if (document.addEventListener) {
44
+ document.addEventListener('onBoomerangLoaded', boomerangInit);
45
+ // @ts-ignore
46
+ }
47
+ else if (document.attachEvent) {
48
+ // @ts-ignore
49
+ document.attachEvent('onpropertychange', function (e) {
50
+ if (!e)
51
+ e = event;
52
+ if (e.propertyName === 'onBoomerangLoaded')
53
+ boomerangInit(e);
54
+ });
55
+ }
56
+ })();
57
+ (0, load_script_1.loadScript)(URL).catch(() => {
58
+ // ignore if boomerang doesn't load
59
+ // most likely because of an ad blocker
60
+ });
61
+ }
62
+ catch (err) {
63
+ // Do nothing
64
+ }
65
+ }, [storeDomain]);
66
+ return null;
67
+ }
68
+ exports.PerformanceMetrics = PerformanceMetrics;
@@ -0,0 +1 @@
1
+ export declare function PerformanceMetricsDebug(): null;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PerformanceMetricsDebug = void 0;
4
+ const react_1 = require("react");
5
+ const index_1 = require("../../index");
6
+ const PAD = 10;
7
+ let isInit = false;
8
+ function PerformanceMetricsDebug() {
9
+ (0, react_1.useEffect)(() => {
10
+ if (!isInit) {
11
+ isInit = true;
12
+ index_1.ClientAnalytics.subscribe(index_1.ClientAnalytics.eventNames.PERFORMANCE, (data) => {
13
+ console.group(`Performance - ${data.page_load_type} load`);
14
+ logMetricIf('TTFB:', data.response_start - data.navigation_start);
15
+ logMetricIf('FCP:', data.first_contentful_paint);
16
+ logMetricIf('LCP:', data.largest_contentful_paint);
17
+ logMetricIf('Duration:', data.response_end - data.navigation_start);
18
+ console.groupEnd();
19
+ });
20
+ }
21
+ });
22
+ return null;
23
+ }
24
+ exports.PerformanceMetricsDebug = PerformanceMetricsDebug;
25
+ function logMetricIf(lable, data) {
26
+ data && console.log(`${lable.padEnd(PAD)}${Math.round(data)} ms`);
27
+ }
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useServerAnalytics = void 0;
4
4
  const ServerRequestProvider_1 = require("../ServerRequestProvider");
5
+ const utils_1 = require("./utils");
5
6
  function useServerAnalytics(data) {
6
7
  const request = (0, ServerRequestProvider_1.useServerRequest)();
7
- if (data)
8
- request.ctx.analyticsData = Object.assign({}, request.ctx.analyticsData, data);
8
+ if (data) {
9
+ request.ctx.analyticsData = (0, utils_1.mergeDeep)(request.ctx.analyticsData, data);
10
+ }
9
11
  return request.ctx.analyticsData;
10
12
  }
11
13
  exports.useServerAnalytics = useServerAnalytics;
@@ -0,0 +1 @@
1
+ export { ClientAnalytics } from './ClientAnalytics';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientAnalytics = void 0;
4
+ var ClientAnalytics_1 = require("./ClientAnalytics");
5
+ Object.defineProperty(exports, "ClientAnalytics", { enumerable: true, get: function () { return ClientAnalytics_1.ClientAnalytics; } });
@@ -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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNamedspacedEventname = void 0;
3
+ exports.mergeDeep = exports.isObject = exports.getNamedspacedEventname = void 0;
4
4
  const const_1 = require("./const");
5
5
  const RESERVED_EVENT_NAMES = Object.values(const_1.eventNames);
6
6
  function getNamedspacedEventname(eventname) {
@@ -10,3 +10,26 @@ function getNamedspacedEventname(eventname) {
10
10
  : eventname;
11
11
  }
12
12
  exports.getNamedspacedEventname = getNamedspacedEventname;
13
+ function isObject(item) {
14
+ return item && typeof item === 'object' && !Array.isArray(item);
15
+ }
16
+ exports.isObject = isObject;
17
+ function mergeDeep(target, ...sources) {
18
+ if (!sources.length)
19
+ return target;
20
+ const source = sources.shift();
21
+ if (isObject(target) && isObject(source)) {
22
+ for (const key in source) {
23
+ if (isObject(source[key])) {
24
+ if (!target[key])
25
+ Object.assign(target, { [key]: {} });
26
+ mergeDeep(target[key], source[key]);
27
+ }
28
+ else {
29
+ Object.assign(target, { [key]: source[key] });
30
+ }
31
+ }
32
+ }
33
+ return mergeDeep(target, ...sources);
34
+ }
35
+ exports.mergeDeep = mergeDeep;
@@ -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
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.isStale = exports.deleteItemFromCache = exports.setItemInCache = exports.getItemFromCache = exports.generateSubRequestCacheControlHeader = void 0;
27
- const runtime_1 = require("./runtime");
28
- const hash_1 = require("../utilities/hash");
27
+ const runtime_1 = require("../runtime");
28
+ const hash_1 = require("../../utilities/hash");
29
29
  const CacheApi = __importStar(require("./cache"));
30
- const CachingStrategy_1 = require("./CachingStrategy");
30
+ const strategies_1 = require("./strategies");
31
31
  /**
32
32
  * Wrapper Cache functions for sub queries
33
33
  */
@@ -38,7 +38,7 @@ function getKeyUrl(key) {
38
38
  return `https://shopify.dev/?${key}`;
39
39
  }
40
40
  function getCacheOption(userCacheOptions) {
41
- return userCacheOptions || (0, CachingStrategy_1.CacheSeconds)();
41
+ return userCacheOptions || (0, strategies_1.CacheSeconds)();
42
42
  }
43
43
  function generateSubRequestCacheControlHeader(userCacheOptions) {
44
44
  return CacheApi.generateDefaultCacheControlHeader(getCacheOption(userCacheOptions));
@@ -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,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isStale = exports.deleteItemFromCache = exports.setItemInCache = exports.getItemFromCache = exports.generateDefaultCacheControlHeader = void 0;
4
- const runtime_1 = require("./runtime");
5
- const CachingStrategy_1 = require("../framework/CachingStrategy");
6
- const log_1 = require("../utilities/log");
4
+ const runtime_1 = require("../runtime");
5
+ const strategies_1 = require("./strategies");
6
+ const log_1 = require("../../utilities/log");
7
7
  function getCacheControlSetting(userCacheOptions, options) {
8
8
  if (userCacheOptions && options) {
9
9
  return {
@@ -12,11 +12,11 @@ function getCacheControlSetting(userCacheOptions, options) {
12
12
  };
13
13
  }
14
14
  else {
15
- return userCacheOptions || (0, CachingStrategy_1.CacheSeconds)();
15
+ return userCacheOptions || (0, strategies_1.CacheSeconds)();
16
16
  }
17
17
  }
18
18
  function generateDefaultCacheControlHeader(userCacheOptions) {
19
- return (0, CachingStrategy_1.generateCacheControlHeader)(getCacheControlSetting(userCacheOptions));
19
+ return (0, strategies_1.generateCacheControlHeader)(getCacheControlSetting(userCacheOptions));
20
20
  }
21
21
  exports.generateDefaultCacheControlHeader = generateDefaultCacheControlHeader;
22
22
  /**
@@ -1,4 +1,5 @@
1
- import type { CachingStrategy, AllCacheOptions, NoStoreStrategy } from '../../types';
1
+ import type { CachingStrategy, AllCacheOptions, NoStoreStrategy } from '../../../types';
2
+ export declare const NO_STORE = "no-store";
2
3
  export declare function generateCacheControlHeader(cacheOptions: CachingStrategy): string;
3
4
  export declare function NoStore(): NoStoreStrategy;
4
5
  export declare function CacheSeconds(overrideOptions?: CachingStrategy): AllCacheOptions;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CacheCustom = exports.CacheMonths = exports.CacheWeeks = exports.CacheDays = exports.CacheHours = exports.CacheMinutes = exports.CacheSeconds = exports.NoStore = exports.generateCacheControlHeader = void 0;
3
+ exports.CacheCustom = exports.CacheMonths = exports.CacheWeeks = exports.CacheDays = exports.CacheHours = exports.CacheMinutes = exports.CacheSeconds = exports.NoStore = exports.generateCacheControlHeader = exports.NO_STORE = void 0;
4
4
  const PUBLIC = 'public';
5
5
  const PRIVATE = 'private';
6
- const NO_STORE = 'no-store';
6
+ exports.NO_STORE = 'no-store';
7
7
  const optionMapping = {
8
8
  maxAge: 'max-age',
9
9
  staleWhileRevalidate: 'stale-while-revalidate',
@@ -25,7 +25,7 @@ function generateCacheControlHeader(cacheOptions) {
25
25
  exports.generateCacheControlHeader = generateCacheControlHeader;
26
26
  function NoStore() {
27
27
  return {
28
- mode: NO_STORE,
28
+ mode: exports.NO_STORE,
29
29
  };
30
30
  }
31
31
  exports.NoStore = NoStore;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { HelmetProps as HeadProps } from 'react-helmet-async';
3
+ export declare function Head({ children, ...props }: HeadProps & {
4
+ children: React.ReactNode;
5
+ }): JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Head = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_helmet_async_1 = require("react-helmet-async");
9
+ const ssr_interop_1 = require("../ssr-interop");
10
+ const clientHeadData = new react_helmet_async_1.HelmetData({});
11
+ function Head({ children, ...props }) {
12
+ const headData = (0, ssr_interop_1.useEnvContext)((req) => req.ctx.head, clientHeadData);
13
+ return (
14
+ // @ts-ignore
15
+ react_1.default.createElement(react_helmet_async_1.Helmet, { ...props, helmetData: headData }, children));
16
+ }
17
+ exports.Head = Head;
@@ -0,0 +1 @@
1
+ export { Head } from './Head.client';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Head = void 0;
4
+ var Head_client_1 = require("./Head.client");
5
+ Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return Head_client_1.Head; } });
@@ -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 {};
@@ -27,7 +27,11 @@ function propsToAttrs(props) {
27
27
  .map(([key, value]) => `${key === REACT_ATTR_MAP.class ? 'class' : key}="${value}"`)
28
28
  .join(' ');
29
29
  }
30
- function Html({ children, template, htmlAttrs, bodyAttrs }) {
30
+ const clientConfigOptions = [
31
+ 'strictMode',
32
+ 'showDevTools',
33
+ ];
34
+ function Html({ children, template, htmlAttrs, bodyAttrs, hydrogenConfig, }) {
31
35
  let head = template.match(/<head>(.+?)<\/head>/s)[1] || '';
32
36
  // @ts-ignore
33
37
  if (import.meta.env.DEV) {
@@ -37,10 +41,19 @@ function Html({ children, template, htmlAttrs, bodyAttrs }) {
37
41
  '<script></script>' + // Fix for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1737882
38
42
  head.replace(/>(\s*?import[\s\w]+?['"]\/@react-refresh)/, ' async="">$1');
39
43
  }
44
+ const clientConfig = {};
45
+ for (const key of clientConfigOptions) {
46
+ if (hydrogenConfig[key] != null) {
47
+ clientConfig[key] = hydrogenConfig[key];
48
+ }
49
+ }
50
+ const clientConfigAttr = Object.keys(clientConfig).length > 0
51
+ ? JSON.stringify(clientConfig)
52
+ : undefined;
40
53
  return (react_1.default.createElement("html", { ...attrsToProps(getHtmlAttrs(template)), ...htmlAttrs },
41
54
  react_1.default.createElement("head", { dangerouslySetInnerHTML: { __html: head } }),
42
55
  react_1.default.createElement("body", { ...attrsToProps(getBodyAttrs(template)), ...bodyAttrs },
43
- react_1.default.createElement("div", { id: "root" }, children))));
56
+ react_1.default.createElement("div", { id: "root", "data-client-config": clientConfigAttr }, children))));
44
57
  }
45
58
  exports.Html = Html;
46
59
  function applyHtmlHead(html, 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,8 @@ export declare class ServerComponentRequest extends Request {
40
43
  router: RouterContextData;
41
44
  buyerIpHeader?: string;
42
45
  session?: SessionSyncApi;
46
+ runtime?: RuntimeContext;
47
+ scopes: Map<string, Record<string, any>>;
43
48
  [key: string]: any;
44
49
  };
45
50
  constructor(input: any);