@shopify/hydrogen 0.19.0 → 0.22.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 (191) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/config.d.ts +1 -0
  3. package/dist/esnext/client.d.ts +1 -0
  4. package/dist/esnext/client.js +1 -0
  5. package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +1 -1
  6. package/dist/esnext/components/CartLineImage/CartLineImage.client.d.ts +4 -7
  7. package/dist/esnext/components/CartLineImage/CartLineImage.client.js +1 -2
  8. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +1 -1
  9. package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +9 -4
  10. package/dist/esnext/components/CartProvider/CartProvider.client.js +42 -30
  11. package/dist/esnext/components/CartProvider/cart-queries.d.ts +10 -9
  12. package/dist/esnext/components/CartProvider/cart-queries.js +58 -743
  13. package/dist/esnext/components/CartProvider/hooks.client.js +4 -2
  14. package/dist/esnext/components/CartProvider/types.d.ts +2 -0
  15. package/dist/esnext/components/Image/Image.d.ts +77 -39
  16. package/dist/esnext/components/Image/Image.js +57 -54
  17. package/dist/esnext/components/Image/index.d.ts +1 -0
  18. package/dist/esnext/components/MediaFile/MediaFile.d.ts +2 -2
  19. package/dist/esnext/components/MediaFile/MediaFile.js +5 -4
  20. package/dist/esnext/components/Money/Money.client.d.ts +11 -5
  21. package/dist/esnext/components/Money/Money.client.js +16 -3
  22. package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +1 -2
  23. package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -2
  24. package/dist/esnext/components/Seo/NoIndexSeo.client.d.ts +3 -0
  25. package/dist/esnext/components/Seo/NoIndexSeo.client.js +10 -0
  26. package/dist/esnext/components/Seo/Seo.client.d.ts +4 -0
  27. package/dist/esnext/components/Seo/Seo.client.js +3 -0
  28. package/dist/esnext/components/Video/Video.d.ts +3 -3
  29. package/dist/esnext/components/Video/Video.js +7 -4
  30. package/dist/esnext/components/index.d.ts +0 -3
  31. package/dist/esnext/components/index.js +0 -3
  32. package/dist/esnext/config.d.ts +3 -3
  33. package/dist/esnext/entry-client.js +0 -3
  34. package/dist/esnext/entry-server.d.ts +14 -2
  35. package/dist/esnext/entry-server.js +97 -73
  36. package/dist/esnext/foundation/Analytics/Analytics.client.js +1 -1
  37. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +2 -2
  38. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +2 -2
  39. package/dist/esnext/foundation/Analytics/index.d.ts +0 -1
  40. package/dist/esnext/foundation/Analytics/index.js +0 -1
  41. package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +5 -10
  42. package/dist/esnext/foundation/Router/BrowserRouter.client.d.ts +2 -1
  43. package/dist/esnext/foundation/Router/BrowserRouter.client.js +1 -1
  44. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -2
  45. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -3
  46. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +0 -1
  47. package/dist/esnext/foundation/fetchSync/server/fetchSync.d.ts +1 -1
  48. package/dist/esnext/foundation/fetchSync/server/fetchSync.js +1 -1
  49. package/dist/esnext/foundation/useQuery/hooks.js +8 -9
  50. package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +2 -1
  51. package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +1 -1
  52. package/dist/esnext/framework/Hydration/Html.js +3 -1
  53. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +2 -2
  54. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +1 -10
  55. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +2 -20
  56. package/dist/esnext/framework/Hydration/rsc.js +55 -7
  57. package/dist/esnext/framework/cache/in-memory.js +0 -6
  58. package/dist/esnext/framework/cache-sub-request.d.ts +17 -0
  59. package/dist/esnext/framework/cache-sub-request.js +64 -0
  60. package/dist/esnext/framework/cache.d.ts +6 -6
  61. package/dist/esnext/framework/cache.js +36 -33
  62. package/dist/esnext/framework/middleware.js +1 -15
  63. package/dist/esnext/framework/plugin.js +7 -30
  64. package/dist/esnext/framework/plugins/vite-plugin-client-imports.d.ts +2 -0
  65. package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +25 -0
  66. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.d.ts +1 -1
  67. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +73 -3
  68. package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.js +1 -4
  69. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
  70. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +7 -5
  71. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
  72. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +8 -50
  73. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -0
  74. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +30 -0
  75. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
  76. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +99 -0
  77. package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +4 -4
  78. package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.js +6 -3
  79. package/dist/esnext/framework/viteception.d.ts +4 -0
  80. package/dist/esnext/framework/viteception.js +15 -0
  81. package/dist/esnext/hooks/useShopQuery/hooks.d.ts +1 -2
  82. package/dist/esnext/hooks/useShopQuery/hooks.js +0 -1
  83. package/dist/esnext/index.d.ts +24 -9
  84. package/dist/esnext/index.js +24 -13
  85. package/dist/esnext/storefront-api-types.d.ts +6 -4
  86. package/dist/esnext/storefront-api-types.js +5 -3
  87. package/dist/esnext/streaming.server.d.ts +3 -1
  88. package/dist/esnext/types.d.ts +13 -5
  89. package/dist/esnext/utilities/apiRoutes.d.ts +4 -5
  90. package/dist/esnext/utilities/apiRoutes.js +2 -8
  91. package/dist/esnext/utilities/fetch.d.ts +1 -2
  92. package/dist/esnext/utilities/fetch.js +1 -3
  93. package/dist/esnext/utilities/graphql-tag.d.ts +1 -0
  94. package/dist/esnext/utilities/graphql-tag.js +6 -0
  95. package/dist/esnext/utilities/graphql-tracker.d.ts +1 -1
  96. package/dist/esnext/utilities/graphql-tracker.js +4 -0
  97. package/dist/esnext/utilities/html-encoding.d.ts +1 -0
  98. package/dist/esnext/utilities/html-encoding.js +8 -0
  99. package/dist/esnext/utilities/image_size.d.ts +4 -22
  100. package/dist/esnext/utilities/image_size.js +15 -33
  101. package/dist/esnext/utilities/index.d.ts +2 -1
  102. package/dist/esnext/utilities/index.js +2 -1
  103. package/dist/esnext/utilities/log/log-cache-api-status.js +5 -1
  104. package/dist/esnext/version.d.ts +1 -1
  105. package/dist/esnext/version.js +1 -1
  106. package/dist/node/components/Image/Image.d.ts +84 -0
  107. package/dist/node/components/Image/Image.js +89 -0
  108. package/dist/node/components/Image/index.d.ts +2 -0
  109. package/dist/node/components/Image/index.js +5 -0
  110. package/dist/node/entry-server.d.ts +14 -2
  111. package/dist/node/entry-server.js +97 -73
  112. package/dist/node/foundation/Analytics/Analytics.client.js +6 -6
  113. package/dist/node/foundation/Analytics/ClientAnalytics.js +2 -2
  114. package/dist/node/foundation/Router/BrowserRouter.client.d.ts +2 -1
  115. package/dist/node/foundation/Router/BrowserRouter.client.js +1 -1
  116. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -2
  117. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -3
  118. package/dist/node/framework/Hydration/Html.js +3 -1
  119. package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +2 -2
  120. package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +1 -10
  121. package/dist/node/framework/Hydration/ServerComponentResponse.server.js +2 -20
  122. package/dist/node/framework/Hydration/rsc.js +55 -7
  123. package/dist/node/framework/cache/in-memory.js +0 -6
  124. package/dist/node/framework/cache-sub-request.d.ts +17 -0
  125. package/dist/node/framework/cache-sub-request.js +95 -0
  126. package/dist/node/framework/cache.d.ts +6 -6
  127. package/dist/node/framework/cache.js +38 -35
  128. package/dist/node/framework/middleware.js +1 -15
  129. package/dist/node/framework/plugin.js +7 -53
  130. package/dist/node/framework/plugins/vite-plugin-client-imports.d.ts +2 -0
  131. package/dist/node/framework/plugins/vite-plugin-client-imports.js +28 -0
  132. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.d.ts +1 -1
  133. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +76 -3
  134. package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.js +1 -4
  135. package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
  136. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +7 -5
  137. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
  138. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +7 -49
  139. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -0
  140. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +36 -0
  141. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
  142. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +105 -0
  143. package/dist/node/framework/plugins/vite-plugin-platform-entry.js +4 -4
  144. package/dist/node/framework/plugins/vite-plugin-ssr-interop.js +6 -3
  145. package/dist/node/framework/viteception.d.ts +4 -0
  146. package/dist/node/framework/viteception.js +19 -0
  147. package/dist/node/storefront-api-types.d.ts +6 -4
  148. package/dist/node/storefront-api-types.js +5 -3
  149. package/dist/node/streaming.server.d.ts +3 -1
  150. package/dist/node/types.d.ts +13 -5
  151. package/dist/node/utilities/apiRoutes.d.ts +4 -5
  152. package/dist/node/utilities/apiRoutes.js +2 -8
  153. package/dist/node/utilities/fetch.d.ts +1 -2
  154. package/dist/node/utilities/fetch.js +1 -3
  155. package/dist/node/utilities/html-encoding.d.ts +1 -0
  156. package/dist/node/utilities/html-encoding.js +12 -0
  157. package/dist/node/utilities/image_size.d.ts +4 -22
  158. package/dist/node/utilities/image_size.js +16 -58
  159. package/dist/node/utilities/index.d.ts +2 -1
  160. package/dist/node/utilities/index.js +3 -2
  161. package/dist/node/utilities/log/log-cache-api-status.js +5 -1
  162. package/dist/node/version.d.ts +1 -1
  163. package/dist/node/version.js +1 -1
  164. package/entry-server.d.ts +1 -1
  165. package/package.json +6 -5
  166. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +214 -28
  167. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +2 -0
  168. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +214 -28
  169. package/vendor/react-server-dom-vite/package.json +2 -1
  170. package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +0 -13
  171. package/dist/esnext/components/ProductDescription/ProductDescription.client.js +0 -16
  172. package/dist/esnext/components/ProductDescription/index.d.ts +0 -1
  173. package/dist/esnext/components/ProductDescription/index.js +0 -1
  174. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +0 -21
  175. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +0 -42
  176. package/dist/esnext/components/ProductMetafield/index.d.ts +0 -2
  177. package/dist/esnext/components/ProductMetafield/index.js +0 -1
  178. package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +0 -13
  179. package/dist/esnext/components/ProductTitle/ProductTitle.client.js +0 -16
  180. package/dist/esnext/components/ProductTitle/index.d.ts +0 -1
  181. package/dist/esnext/components/ProductTitle/index.js +0 -1
  182. package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +0 -15
  183. package/dist/esnext/components/UnitPrice/UnitPrice.client.js +0 -22
  184. package/dist/esnext/components/UnitPrice/index.d.ts +0 -1
  185. package/dist/esnext/components/UnitPrice/index.js +0 -1
  186. package/dist/esnext/utilities/findRoutePrefix.d.ts +0 -1
  187. package/dist/esnext/utilities/findRoutePrefix.js +0 -17
  188. package/dist/node/foundation/Analytics/index.d.ts +0 -2
  189. package/dist/node/foundation/Analytics/index.js +0 -7
  190. package/dist/node/utilities/findRoutePrefix.d.ts +0 -1
  191. package/dist/node/utilities/findRoutePrefix.js +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,208 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#930](https://github.com/Shopify/hydrogen/pull/930) [`750baf8f`](https://github.com/Shopify/hydrogen/commit/750baf8ff069d0e06fb92e78a142049a1ce2b1ae) Thanks [@michenly](https://github.com/michenly)! - With the introduction of authenticated pages, we also now provide the ability to prevent pages from being indexed by bots. You can do so by passing `noindex` to the `Seo` component:
8
+
9
+ ```jsx
10
+ <Seo type="noindex" data={{title: 'Login'}} />
11
+ ```
12
+
13
+ * [#1313](https://github.com/Shopify/hydrogen/pull/1313) [`ed1933e3`](https://github.com/Shopify/hydrogen/commit/ed1933e339927322d8008034982b05ff4590e6d8) Thanks [@frandiox](https://github.com/frandiox)! - **Breaking change**: The `routes` property in `hydrogen.config.js` file has been simplified. It is now a string that represents the path to the routes from the project root:
14
+
15
+ ```diff
16
+ // hydrogen.config.js
17
+
18
+ export default defineConfig({
19
+ - routes: import('./src/routes/**/*.server.[jt](s|sx)'),
20
+ + routes: '/src/routes',
21
+ });
22
+ ```
23
+
24
+ Its default value is `/src/routes` so this property can be removed when using this directory.
25
+
26
+ In the object syntax version, `dirPrefix` is removed and `files` becomes a string:
27
+
28
+ ```diff
29
+ // hydrogen.config.js
30
+
31
+ export default defineConfig({
32
+ routes: {
33
+ - files: import('./src/routes/**/*.server.[jt](s|sx)'),
34
+ - dirPrefix: './src/routes',
35
+ + files: '/src/routes',
36
+ basePath: '/',
37
+ },
38
+ });
39
+ ```
40
+
41
+ - [#1332](https://github.com/Shopify/hydrogen/pull/1332) [`5ec1bc62`](https://github.com/Shopify/hydrogen/commit/5ec1bc62cf9e4348aa389d4154f8c80dccfb96bb) Thanks [@frandiox](https://github.com/frandiox)! - A new `gql` utility is exported from `@shopify/hydrogen` that replaces `graphql-tag` dependency when using `useShopQuery`. It helps reducing bundle size in production when compared to the original `graphql-tag`.
42
+
43
+ Before:
44
+
45
+ ```js
46
+ import gql from 'graphql-tag';
47
+
48
+ // ...
49
+
50
+ useShopQuery({
51
+ query: gql`...`,
52
+ // ...
53
+ });
54
+ ```
55
+
56
+ After:
57
+
58
+ ```js
59
+ import {gql} from '@shopify/hydrogen';
60
+
61
+ // ...
62
+
63
+ useShopQuery({
64
+ query: gql`...`,
65
+ // ...
66
+ });
67
+ ```
68
+
69
+ * [#1340](https://github.com/Shopify/hydrogen/pull/1340) [`631832ec`](https://github.com/Shopify/hydrogen/commit/631832ecaef26b918e774515ada6b80668ec5e4e) Thanks [@jplhomer](https://github.com/jplhomer)! - **Breaking change**: The `response.send()` function has been removed. Use `export async function api()` to send custom responses instead.
70
+
71
+ ### Patch Changes
72
+
73
+ - [#1371](https://github.com/Shopify/hydrogen/pull/1371) [`84a2fd09`](https://github.com/Shopify/hydrogen/commit/84a2fd09b7150b1d5e1f92b786f4a6af09e18739) Thanks [@frehner](https://github.com/frehner)! - Made updates to `<Image/>`:
74
+
75
+ - Fixed some TypeScript type issues with Image.
76
+ - `data.url` and `alt` are now required props in Typescript, but won't break the actual component if you don't pass them.
77
+
78
+ * [#1348](https://github.com/Shopify/hydrogen/pull/1348) [`211093e5`](https://github.com/Shopify/hydrogen/commit/211093e5f1a9e2ad115eb667746bfa2c6dd05b82) Thanks [@developit](https://github.com/developit)! - Fix HTML double-decoding in flight response
79
+
80
+ - [#1345](https://github.com/Shopify/hydrogen/pull/1345) [`331ff3c0`](https://github.com/Shopify/hydrogen/commit/331ff3c0f58143df3e7c542116f9a94838710352) Thanks [@frandiox](https://github.com/frandiox)! - Reduce the amount of user app files downloaded in the browser.
81
+
82
+ * [#1322](https://github.com/Shopify/hydrogen/pull/1322) [`36bd77c4`](https://github.com/Shopify/hydrogen/commit/36bd77c4619ec071ea11b764bb16b5670b0afa6b) Thanks [@frandiox](https://github.com/frandiox)! - Fix server hanging in Node.js environment when not using Hydrogen Middleware.
83
+
84
+ - [#1360](https://github.com/Shopify/hydrogen/pull/1360) [`d9b0d03b`](https://github.com/Shopify/hydrogen/commit/d9b0d03b64d2207b314d15fc0acf6a5143610b92) Thanks [@blittle](https://github.com/blittle)! - Fix a problem where encoded html content props passed from server to client components would get double decoded, and break hydration on app load.
85
+
86
+ * [#1355](https://github.com/Shopify/hydrogen/pull/1355) [`c45a45e8`](https://github.com/Shopify/hydrogen/commit/c45a45e895b8407da04c6b4608e7f16170452c24) Thanks [@jplhomer](https://github.com/jplhomer)! - Ensure all Hydrogen components are exported properly
87
+
88
+ - [#1339](https://github.com/Shopify/hydrogen/pull/1339) [`fef4cb84`](https://github.com/Shopify/hydrogen/commit/fef4cb8496d985d37b6113865ac1252f78058aaa) Thanks [@jplhomer](https://github.com/jplhomer)! - Use `import.meta.env.DEV` instead of `process.env.LOCAL_DEV` to hash asset filenames and show performance metrics debugging
89
+
90
+ * [#1320](https://github.com/Shopify/hydrogen/pull/1320) [`7e9df897`](https://github.com/Shopify/hydrogen/commit/7e9df897465012cd0cf374a1a35deb2ca8a16fc3) Thanks [@jplhomer](https://github.com/jplhomer)! - Properly log errors during flight responses
91
+
92
+ - [#1363](https://github.com/Shopify/hydrogen/pull/1363) [`0941d3be`](https://github.com/Shopify/hydrogen/commit/0941d3be12b52edc045b898864435f591fc2c42e) Thanks [@frandiox](https://github.com/frandiox)! - Remove some server utilities from client build.
93
+
94
+ ## 0.21.0
95
+
96
+ ### Minor Changes
97
+
98
+ - [#1327](https://github.com/Shopify/hydrogen/pull/1327) [`ce56311f`](https://github.com/Shopify/hydrogen/commit/ce56311fc1b63df22f77b199980439548f76997a) Thanks [@frehner](https://github.com/frehner)! - **Breaking Change**: `<Money />` updates and `<UnitPrice />` Removed.
99
+
100
+ - `<UnitPrice/>` has been removed
101
+ - `<Money/>` has two new props: `measurement` and `measurementSeparator` which do the work that `UnitPrice` used to do
102
+ - The TypeScript types for `<Money/>` have been improved and should provide a better typed experience now
103
+
104
+ * [#1216](https://github.com/Shopify/hydrogen/pull/1216) [`771786a6`](https://github.com/Shopify/hydrogen/commit/771786a6475c4caadb1abe5f6644e2b5c2abc021) Thanks [@wizardlyhel](https://github.com/wizardlyhel)! - Fixes an issue where cached sub-requests were not revalidating properly.
105
+
106
+ - [#1304](https://github.com/Shopify/hydrogen/pull/1304) [`aa196150`](https://github.com/Shopify/hydrogen/commit/aa19615024de4fe16d548429665a863e9aae0248) Thanks [@frehner](https://github.com/frehner)! - Removed `<ProductTitle/>` and `<ProductDescription/>` components. To migrate, use `{product.title}` and `{product.description}` instead.
107
+
108
+ * [#1335](https://github.com/Shopify/hydrogen/pull/1335) [`0d90f92b`](https://github.com/Shopify/hydrogen/commit/0d90f92b448b0c4d99be3e5f5fa25d0b70a8315e) Thanks [@blittle](https://github.com/blittle)! - **Breaking Change**
109
+
110
+ The `<ProductMetafield />` component has been removed. Instead, directly use the `<Metafield>` component.
111
+
112
+ ### Patch Changes
113
+
114
+ - [#1311](https://github.com/Shopify/hydrogen/pull/1311) [`3e3fd72f`](https://github.com/Shopify/hydrogen/commit/3e3fd72f7016c0993deceefc121306cf957ef564) Thanks [@jplhomer](https://github.com/jplhomer)! - Client components no longer need to use `@shopify/hydrogen/client` as the import path. All Hydrogen components can now be imported from `@shopify/hydrogen` regardless of their context.
115
+
116
+ * [#1259](https://github.com/Shopify/hydrogen/pull/1259) [`110e9aca`](https://github.com/Shopify/hydrogen/commit/110e9aca385d553e3a87fea406f8bd8a43a0788f) Thanks [@blittle](https://github.com/blittle)! - You can now easily disable streaming on any page conditionally with the `enableStreaming` option inside `hydrogen.config.js`:
117
+
118
+ ```ts
119
+ import {CookieSessionStorage} from '@shopify/hydrogen';
120
+ import {defineConfig} from '@shopify/hydrogen/config';
121
+
122
+ export default defineConfig({
123
+ routes: import.meta.globEager('./src/routes/**/*.server.[jt](s|sx)'),
124
+ shopify: {
125
+ defaultLocale: 'en-us',
126
+ storeDomain: 'hydrogen-preview.myshopify.com',
127
+ storefrontToken: '3b580e70970c4528da70c98e097c2fa0',
128
+ storefrontApiVersion: '2022-07',
129
+ },
130
+ enableStreaming: (req) => req.headers.get('user-agent') !== 'custom bot',
131
+ });
132
+ ```
133
+
134
+ By default all pages are stream rendered except for SEO bots. There shouldn't be many reasons to disable streaming, unless there is a custom bot not covered by Hydrogen's bot detection.
135
+
136
+ - [#1318](https://github.com/Shopify/hydrogen/pull/1318) [`668a24da`](https://github.com/Shopify/hydrogen/commit/668a24daebf180747a002c8020c2e712f5d9a458) Thanks [@blittle](https://github.com/blittle)! - Buffer RSC flight responses. There isn't any benefit to streaming them, because we start a transition on page navigation. Buffering also fixes caching problems on the flight response.
137
+
138
+ * [#1293](https://github.com/Shopify/hydrogen/pull/1293) [`e378ed61`](https://github.com/Shopify/hydrogen/commit/e378ed6199553f64d9e73ad27f9409ef501aa724) Thanks [@jplhomer](https://github.com/jplhomer)! - Reverts [#1272](https://github.com/Shopify/hydrogen/pull/1272) and properly escapes terminating script sequences
139
+
140
+ - [#1283](https://github.com/Shopify/hydrogen/pull/1283) [`eea82cb0`](https://github.com/Shopify/hydrogen/commit/eea82cb02064471d274e534c557caa5d3527bc93) Thanks [@jplhomer](https://github.com/jplhomer)! - Hydrogen has been updated to use the latest stable version of React.
141
+
142
+ To update an existing Hydrogen app:
143
+
144
+ ```bash
145
+ yarn add react@latest react-dom@latest
146
+ ```
147
+
148
+ ## 0.20.0
149
+
150
+ ### Minor Changes
151
+
152
+ - [#1257](https://github.com/Shopify/hydrogen/pull/1257) [`5cd7a672`](https://github.com/Shopify/hydrogen/commit/5cd7a6727befe1e06f35b9ec68d4c81a8858d46f) Thanks [@frandiox](https://github.com/frandiox)! - Support for CSS Modules has been improved. It now behaves closer to the default behavior in Vite where styles are collected automatically.
153
+
154
+ Remove the `StyleTag` component that was needed before:
155
+
156
+ ```diff
157
+ export default function MyComponent() {
158
+ return (
159
+ <div>
160
+ - <myStyles.StyleTag />
161
+ <h1>Title</h1>
162
+ </div>
163
+ );
164
+ }
165
+ ```
166
+
167
+ Optionally, update your wildcard imports to default or named imports:
168
+
169
+ ```diff
170
+ -import * as myStyles from './my.module.css';
171
+ +import myStyles from './my.module.css';
172
+ // Or
173
+ +import {red, green, blue} from './my.module.css';
174
+ ```
175
+
176
+ * [#1271](https://github.com/Shopify/hydrogen/pull/1271) [`9d0359b8`](https://github.com/Shopify/hydrogen/commit/9d0359b87b0cfa04f12ffa9376e5b8ad72c560a3) Thanks [@frehner](https://github.com/frehner)! - ## `<Image/>`
177
+
178
+ The `<Image/>` component and related utility functions were reworked and the following changes apply:
179
+
180
+ - `useImageUrl` is no longer available; use `shopifyImageLoader` instead, which is available to run both server- and client-side.
181
+ - The TypeScript experience with `<Image/>` is improved; props will be validated better, and `loader` and `loaderOptions` will be better typed
182
+ - When using the `src` prop, `width` and `height` are now required
183
+ - When using the `data` prop, `data.width` and `data.height` or `width` and `height` props are required
184
+ - The `src` and `data` props are mutually exclusive
185
+ - The `loader` prop now receives a singular param as an object
186
+ - `options` has been merged with `loaderOptions`. When using the `data` prop, `loaderOptions` will be the options for Shopify CDN images. When using the `src` prop, `loaderOptions` will be whatever you define them to be.
187
+ - The TypeScript type `ImageSizeOptions` is now named `ShopifyLoaderOptions`
188
+ - The TypeScript type `ImageLoaderOptions` is now named `ShopifyLoaderParams`
189
+ - The `priority` prop was removed; use the HTML-standard `loading` prop instead
190
+
191
+ ## `<Video/>`
192
+
193
+ - The `<Video/>` component's `options` props was renamed to `imagePreviewOptions` to add clarity as to what the options were for.
194
+ - `imagePreviewOptions` matches the (newly updated) shape of `<Image/>`'s `loaderOptions`
195
+
196
+ - [#1290](https://github.com/Shopify/hydrogen/pull/1290) [`437b1616`](https://github.com/Shopify/hydrogen/commit/437b1616fcfa15d8b4b2c033b364b2f74b99d6e4) Thanks [@jplhomer](https://github.com/jplhomer)! - Allow cart queries to be customized by adding a new `cartFragment` prop to `CartProvider`. [Learn more](https://shopify.dev/api/hydrogen/components/cart/cartprovider#cart-fragment).
197
+
198
+ ### Patch Changes
199
+
200
+ - [#1247](https://github.com/Shopify/hydrogen/pull/1247) [`ee64873e`](https://github.com/Shopify/hydrogen/commit/ee64873ece372f9be2d6eb08b0594a91f4ed135a) Thanks [@frandiox](https://github.com/frandiox)! - Improve the way client components are discovered in order to reduce bundle sizes.
201
+
202
+ * [#1276](https://github.com/Shopify/hydrogen/pull/1276) [`c6ce6a43`](https://github.com/Shopify/hydrogen/commit/c6ce6a43bbb944b67aec5fdc7e5566768846dac5) Thanks [@frandiox](https://github.com/frandiox)! - Fix page loading in Firefox during development ([known bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1737882)).
203
+
204
+ - [#1286](https://github.com/Shopify/hydrogen/pull/1286) [`53270249`](https://github.com/Shopify/hydrogen/commit/5327024995ff7b8823ddb8ea835b3a5b95175841) Thanks [@jplhomer](https://github.com/jplhomer)! - Fix some sourcemap warnings in server console
205
+
3
206
  ## 0.19.0
4
207
 
5
208
  ### Minor Changes
package/config.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/esnext/config';
@@ -6,6 +6,7 @@ export * from './foundation/ServerPropsProvider';
6
6
  export * from './foundation/useUrl';
7
7
  export { Head } from './foundation/Head';
8
8
  export * from './utilities';
9
+ export { gql } from './utilities/graphql-tag';
9
10
  export { ClientAnalytics } from './foundation/Analytics';
10
11
  export { useRouteParams } from './foundation/useRouteParams/useRouteParams';
11
12
  export { useNavigate } from './foundation/useNavigate/useNavigate';
@@ -6,6 +6,7 @@ export * from './foundation/ServerPropsProvider';
6
6
  export * from './foundation/useUrl';
7
7
  export { Head } from './foundation/Head';
8
8
  export * from './utilities';
9
+ export { gql } from './utilities/graphql-tag';
9
10
  export { ClientAnalytics } from './foundation/Analytics';
10
11
  export { useRouteParams } from './foundation/useRouteParams/useRouteParams';
11
12
  export { useNavigate } from './foundation/useNavigate/useNavigate';
@@ -11,4 +11,4 @@ export interface CartEstimatedCostProps {
11
11
  * cost associated with the `amountType` prop. If no `amountType` prop is specified, then it defaults to `totalAmount`.
12
12
  * If `children` is a function, then it will pass down the render props provided by the parent component.
13
13
  */
14
- export declare function CartEstimatedCost<TTag extends keyof JSX.IntrinsicElements>(props: Omit<React.ComponentProps<typeof Money>, 'data'> & CartEstimatedCostProps): JSX.Element | null;
14
+ export declare function CartEstimatedCost(props: Omit<React.ComponentProps<typeof Money>, 'data'> & CartEstimatedCostProps): JSX.Element | null;
@@ -1,12 +1,9 @@
1
- import React from 'react';
2
- import { Image } from '../Image';
3
- import { ImageSizeOptions } from '../../utilities';
4
- declare type PropsWeControl = 'data' | 'options';
1
+ import { type ShopifyImageProps } from '../Image';
2
+ import type { Simplify } from 'type-fest';
3
+ declare type PropsWeControl = 'data';
5
4
  /**
6
5
  * The `CartLineImage` component renders an `Image` component for the cart line merchandise's image.
7
6
  * It must be a descendent of a `CartLineProvider` component.
8
7
  */
9
- export declare function CartLineImage(props: Omit<React.ComponentProps<typeof Image>, PropsWeControl> & {
10
- options?: ImageSizeOptions;
11
- }): JSX.Element | null;
8
+ export declare function CartLineImage(props: Simplify<Omit<ShopifyImageProps, PropsWeControl>>): JSX.Element | null;
12
9
  export {};
@@ -7,6 +7,5 @@ import { Image } from '../Image';
7
7
  */
8
8
  export function CartLineImage(props) {
9
9
  const cartLine = useCartLine();
10
- const { options, ...passthroughProps } = props;
11
- return cartLine.merchandise.image ? (React.createElement(Image, { ...passthroughProps, data: cartLine.merchandise.image, options: options })) : null;
10
+ return cartLine.merchandise.image ? (React.createElement(Image, { ...props, data: cartLine.merchandise.image })) : null;
12
11
  }
@@ -8,5 +8,5 @@ interface CartLinePriceProps {
8
8
  * The `CartLinePrice` component renders a `Money` component for the cart line merchandise's price or
9
9
  * compare at price. It must be a descendent of a `CartLineProvider` component.
10
10
  */
11
- export declare function CartLinePrice<TTag extends keyof JSX.IntrinsicElements>(props: Omit<React.ComponentProps<typeof Money>, 'data'> & CartLinePriceProps): JSX.Element | null;
11
+ export declare function CartLinePrice(props: Omit<React.ComponentProps<typeof Money>, 'data'> & CartLinePriceProps): JSX.Element | null;
12
12
  export {};
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { CartBuyerIdentityInput, CountryCode } from '../../storefront-api-types';
2
3
  import { CartFragmentFragment } from './graphql/CartFragment';
3
4
  /**
4
5
  * The `CartProvider` component creates a context for using a cart. It creates a cart object and callbacks
@@ -9,7 +10,7 @@ import { CartFragmentFragment } from './graphql/CartFragment';
9
10
  * The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
10
11
  * You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
11
12
  */
12
- export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, }: {
13
+ export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment, customerAccessToken, countryCode, }: {
13
14
  /** Any `ReactNode` elements. */
14
15
  children: React.ReactNode;
15
16
  numCartLines?: number;
@@ -29,8 +30,12 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
29
30
  onAttributesUpdate?: () => void;
30
31
  /** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */
31
32
  onDiscountCodesUpdate?: () => void;
32
- /**
33
- * An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart).
34
- */
33
+ /** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart). */
35
34
  data?: CartFragmentFragment;
35
+ /** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
36
+ cartFragment?: string;
37
+ /** A customer access token that's accessible on the server if there's a customer login. */
38
+ customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];
39
+ /** The ISO country code for i18n. */
40
+ countryCode?: CountryCode;
36
41
  }): JSX.Element;
@@ -1,11 +1,11 @@
1
1
  import React, { useEffect, useCallback, useReducer, useMemo, useRef, } from 'react';
2
- import { flattenConnection } from '../../utilities';
3
- import { CartLineAdd, CartCreate, CartLineRemove, CartLineUpdate, CartNoteUpdate, CartBuyerIdentityUpdate, CartAttributesUpdate, CartDiscountCodesUpdate, CartQuery, } from './cart-queries';
2
+ import { flattenConnection } from '../../utilities/flattenConnection';
3
+ import { CartLineAdd, CartCreate, CartLineRemove, CartLineUpdate, CartNoteUpdate, CartBuyerIdentityUpdate, CartAttributesUpdate, CartDiscountCodesUpdate, CartQuery, defaultCartFragment, } from './cart-queries';
4
+ import { CountryCode, } from '../../storefront-api-types';
4
5
  import { useCartFetch } from './hooks.client';
5
6
  import { CartContext } from './context';
6
7
  import { CART_ID_STORAGE_KEY } from './constants';
7
- import { useServerProps } from '../../foundation/useServerProps';
8
- import { ClientAnalytics } from '../../foundation/Analytics';
8
+ import { ClientAnalytics } from '../../foundation/Analytics/ClientAnalytics';
9
9
  function cartReducer(state, action) {
10
10
  switch (action.type) {
11
11
  case 'cartFetch': {
@@ -150,10 +150,7 @@ function cartReducer(state, action) {
150
150
  * The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
151
151
  * You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
152
152
  */
153
- export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, }) {
154
- var _a;
155
- const { serverProps } = useServerProps();
156
- const countryCode = (_a = serverProps === null || serverProps === void 0 ? void 0 : serverProps.country) === null || _a === void 0 ? void 0 : _a.isoCode;
153
+ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment = defaultCartFragment, customerAccessToken, countryCode = CountryCode.Us, }) {
157
154
  const initialStatus = cart
158
155
  ? { status: 'idle', cart: cartFromGraphQL(cart) }
159
156
  : { status: 'uninitialized' };
@@ -162,7 +159,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
162
159
  const cartFetch = useCallback(async (cartId) => {
163
160
  dispatch({ type: 'cartFetch' });
164
161
  const { data } = await fetchCart({
165
- query: CartQuery,
162
+ query: CartQuery(cartFragment),
166
163
  variables: {
167
164
  id: cartId,
168
165
  numCartLines,
@@ -175,9 +172,9 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
175
172
  return;
176
173
  }
177
174
  dispatch({ type: 'resolve', cart: cartFromGraphQL(data.cart) });
178
- }, [fetchCart, numCartLines, countryCode]);
175
+ }, [fetchCart, cartFragment, numCartLines, countryCode]);
179
176
  const cartCreate = useCallback(async (cart) => {
180
- var _a, _b;
177
+ var _a, _b, _c;
181
178
  dispatch({ type: 'cartCreate' });
182
179
  onCreate === null || onCreate === void 0 ? void 0 : onCreate();
183
180
  if (countryCode && !((_a = cart.buyerIdentity) === null || _a === void 0 ? void 0 : _a.countryCode)) {
@@ -186,8 +183,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
186
183
  }
187
184
  cart.buyerIdentity.countryCode = countryCode;
188
185
  }
186
+ if (customerAccessToken && !((_b = cart.buyerIdentity) === null || _b === void 0 ? void 0 : _b.customerAccessToken)) {
187
+ if (cart.buyerIdentity == null) {
188
+ cart.buyerIdentity = {};
189
+ }
190
+ cart.buyerIdentity.customerAccessToken = customerAccessToken;
191
+ }
189
192
  const { data, error } = await fetchCart({
190
- query: CartCreate,
193
+ query: CartCreate(cartFragment),
191
194
  variables: {
192
195
  input: cart,
193
196
  numCartLines,
@@ -200,7 +203,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
200
203
  error,
201
204
  });
202
205
  }
203
- if ((_b = data === null || data === void 0 ? void 0 : data.cartCreate) === null || _b === void 0 ? void 0 : _b.cart) {
206
+ if ((_c = data === null || data === void 0 ? void 0 : data.cartCreate) === null || _c === void 0 ? void 0 : _c.cart) {
204
207
  if (cart.lines) {
205
208
  ClientAnalytics.publish(ClientAnalytics.eventNames.ADD_TO_CART, true, {
206
209
  addedCartLines: cart.lines,
@@ -213,14 +216,21 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
213
216
  });
214
217
  window.localStorage.setItem(CART_ID_STORAGE_KEY, data.cartCreate.cart.id);
215
218
  }
216
- }, [onCreate, fetchCart, numCartLines, countryCode]);
219
+ }, [
220
+ onCreate,
221
+ countryCode,
222
+ fetchCart,
223
+ cartFragment,
224
+ numCartLines,
225
+ customerAccessToken,
226
+ ]);
217
227
  const addLineItem = useCallback(async (lines, state) => {
218
228
  var _a;
219
229
  if (state.status === 'idle') {
220
230
  dispatch({ type: 'addLineItem' });
221
231
  onLineAdd === null || onLineAdd === void 0 ? void 0 : onLineAdd();
222
232
  const { data, error } = await fetchCart({
223
- query: CartLineAdd,
233
+ query: CartLineAdd(cartFragment),
224
234
  variables: {
225
235
  cartId: state.cart.id,
226
236
  lines,
@@ -245,14 +255,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
245
255
  });
246
256
  }
247
257
  }
248
- }, [fetchCart, numCartLines, onLineAdd, countryCode]);
258
+ }, [onLineAdd, fetchCart, cartFragment, numCartLines, countryCode]);
249
259
  const removeLineItem = useCallback(async (lines, state) => {
250
260
  var _a;
251
261
  if (state.status === 'idle') {
252
262
  dispatch({ type: 'removeLineItem', lines });
253
263
  onLineRemove === null || onLineRemove === void 0 ? void 0 : onLineRemove();
254
264
  const { data, error } = await fetchCart({
255
- query: CartLineRemove,
265
+ query: CartLineRemove(cartFragment),
256
266
  variables: {
257
267
  cartId: state.cart.id,
258
268
  lines,
@@ -277,14 +287,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
277
287
  });
278
288
  }
279
289
  }
280
- }, [fetchCart, onLineRemove, numCartLines, countryCode]);
290
+ }, [onLineRemove, fetchCart, cartFragment, numCartLines, countryCode]);
281
291
  const updateLineItem = useCallback(async (lines, state) => {
282
292
  var _a;
283
293
  if (state.status === 'idle') {
284
294
  dispatch({ type: 'updateLineItem', lines });
285
295
  onLineUpdate === null || onLineUpdate === void 0 ? void 0 : onLineUpdate();
286
296
  const { data, error } = await fetchCart({
287
- query: CartLineUpdate,
297
+ query: CartLineUpdate(cartFragment),
288
298
  variables: {
289
299
  cartId: state.cart.id,
290
300
  lines,
@@ -309,14 +319,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
309
319
  });
310
320
  }
311
321
  }
312
- }, [fetchCart, onLineUpdate, numCartLines, countryCode]);
322
+ }, [onLineUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
313
323
  const noteUpdate = useCallback(async (note, state) => {
314
324
  var _a;
315
325
  if (state.status === 'idle') {
316
326
  dispatch({ type: 'noteUpdate' });
317
327
  onNoteUpdate === null || onNoteUpdate === void 0 ? void 0 : onNoteUpdate();
318
328
  const { data, error } = await fetchCart({
319
- query: CartNoteUpdate,
329
+ query: CartNoteUpdate(cartFragment),
320
330
  variables: {
321
331
  cartId: state.cart.id,
322
332
  note,
@@ -337,14 +347,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
337
347
  });
338
348
  }
339
349
  }
340
- }, [fetchCart, onNoteUpdate, numCartLines, countryCode]);
350
+ }, [onNoteUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
341
351
  const buyerIdentityUpdate = useCallback(async (buyerIdentity, state) => {
342
352
  var _a;
343
353
  if (state.status === 'idle') {
344
354
  dispatch({ type: 'buyerIdentityUpdate' });
345
355
  onBuyerIdentityUpdate === null || onBuyerIdentityUpdate === void 0 ? void 0 : onBuyerIdentityUpdate();
346
356
  const { data, error } = await fetchCart({
347
- query: CartBuyerIdentityUpdate,
357
+ query: CartBuyerIdentityUpdate(cartFragment),
348
358
  variables: {
349
359
  cartId: state.cart.id,
350
360
  buyerIdentity,
@@ -365,14 +375,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
365
375
  });
366
376
  }
367
377
  }
368
- }, [fetchCart, onBuyerIdentityUpdate, numCartLines, countryCode]);
378
+ }, [onBuyerIdentityUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
369
379
  const cartAttributesUpdate = useCallback(async (attributes, state) => {
370
380
  var _a;
371
381
  if (state.status === 'idle') {
372
382
  dispatch({ type: 'cartAttributesUpdate' });
373
383
  onAttributesUpdate === null || onAttributesUpdate === void 0 ? void 0 : onAttributesUpdate();
374
384
  const { data, error } = await fetchCart({
375
- query: CartAttributesUpdate,
385
+ query: CartAttributesUpdate(cartFragment),
376
386
  variables: {
377
387
  cartId: state.cart.id,
378
388
  attributes,
@@ -393,14 +403,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
393
403
  });
394
404
  }
395
405
  }
396
- }, [fetchCart, onAttributesUpdate, numCartLines, countryCode]);
406
+ }, [onAttributesUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
397
407
  const discountCodesUpdate = useCallback(async (discountCodes, state) => {
398
408
  var _a;
399
409
  if (state.status === 'idle') {
400
410
  dispatch({ type: 'discountCodesUpdate' });
401
411
  onDiscountCodesUpdate === null || onDiscountCodesUpdate === void 0 ? void 0 : onDiscountCodesUpdate();
402
412
  const { data, error } = await fetchCart({
403
- query: CartDiscountCodesUpdate,
413
+ query: CartDiscountCodesUpdate(cartFragment),
404
414
  variables: {
405
415
  cartId: state.cart.id,
406
416
  discountCodes,
@@ -425,7 +435,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
425
435
  });
426
436
  }
427
437
  }
428
- }, [fetchCart, onDiscountCodesUpdate, numCartLines, countryCode]);
438
+ }, [onDiscountCodesUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
429
439
  const didFetchCart = useRef(false);
430
440
  useEffect(() => {
431
441
  if (localStorage.getItem(CART_ID_STORAGE_KEY) &&
@@ -439,9 +449,9 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
439
449
  if (state.status !== 'idle') {
440
450
  return;
441
451
  }
442
- buyerIdentityUpdate({ countryCode }, state);
452
+ buyerIdentityUpdate({ countryCode, customerAccessToken }, state);
443
453
  // eslint-disable-next-line react-hooks/exhaustive-deps
444
- }, [countryCode]);
454
+ }, [countryCode, customerAccessToken]);
445
455
  const cartContextValue = useMemo(() => {
446
456
  return {
447
457
  ...('cart' in state
@@ -485,11 +495,13 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
485
495
  discountCodesUpdate(discountCodes) {
486
496
  discountCodesUpdate(discountCodes, state);
487
497
  },
498
+ cartFragment,
488
499
  };
489
500
  }, [
490
501
  state,
491
502
  cart,
492
503
  cartCreate,
504
+ cartFragment,
493
505
  addLineItem,
494
506
  removeLineItem,
495
507
  updateLineItem,
@@ -1,9 +1,10 @@
1
- export declare const CartLineAdd = "\nmutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
2
- export declare const CartCreate = "\nmutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartCreate(input: $input) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
3
- export declare const CartLineRemove = "\nmutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lines) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
4
- export declare const CartLineUpdate = "\nmutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
5
- export declare const CartNoteUpdate = "\nmutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
6
- export declare const CartBuyerIdentityUpdate = "\nmutation CartBuyerIdentityUpdate(\n $cartId: ID!\n $buyerIdentity: CartBuyerIdentityInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n) @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
7
- export declare const CartAttributesUpdate = "\nmutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
8
- export declare const CartDiscountCodesUpdate = "\nmutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
9
- export declare const CartQuery = "\nquery CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFragment\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
1
+ export declare const CartLineAdd: (cartFragment: string) => string;
2
+ export declare const CartCreate: (cartFragment: string) => string;
3
+ export declare const CartLineRemove: (cartFragment: string) => string;
4
+ export declare const CartLineUpdate: (cartFragment: string) => string;
5
+ export declare const CartNoteUpdate: (cartFragment: string) => string;
6
+ export declare const CartBuyerIdentityUpdate: (cartFragment: string) => string;
7
+ export declare const CartAttributesUpdate: (cartFragment: string) => string;
8
+ export declare const CartDiscountCodesUpdate: (cartFragment: string) => string;
9
+ export declare const CartQuery: (cartFragment: string) => string;
10
+ export declare const defaultCartFragment = "\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";