@shopify/hydrogen 2026.10.0-preview.4 → 2026.10.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 (437) hide show
  1. package/dist/cli/index.mjs +23 -12
  2. package/dist/client/client.d.mts +18 -15
  3. package/dist/client/client.mjs +8 -3
  4. package/dist/client/client.mjs.map +1 -1
  5. package/dist/client/errors.d.mts +35 -13
  6. package/dist/client/errors.mjs +23 -13
  7. package/dist/client/errors.mjs.map +1 -1
  8. package/dist/client/types.d.mts +140 -90
  9. package/dist/core/analytics/cart-tracker.d.mts +19 -10
  10. package/dist/core/analytics/cart-tracker.mjs +18 -10
  11. package/dist/core/analytics/cart-tracker.mjs.map +1 -1
  12. package/dist/core/analytics/events.d.mts +17 -11
  13. package/dist/core/analytics/events.mjs +13 -4
  14. package/dist/core/analytics/events.mjs.map +1 -1
  15. package/dist/core/analytics/types.d.mts +207 -118
  16. package/dist/core/analytics/utils/flatten-connection.d.mts +11 -9
  17. package/dist/core/analytics/utils/flatten-connection.mjs +7 -6
  18. package/dist/core/analytics/utils/flatten-connection.mjs.map +1 -1
  19. package/dist/core/cache/fetch-with-cache.d.mts +24 -4
  20. package/dist/core/cache/fetch-with-cache.mjs +17 -2
  21. package/dist/core/cache/fetch-with-cache.mjs.map +1 -1
  22. package/dist/core/cache/key.d.mts +2 -0
  23. package/dist/core/cache/key.mjs.map +1 -1
  24. package/dist/core/cache/run-with-cache.d.mts +56 -8
  25. package/dist/core/cache/run-with-cache.mjs +17 -6
  26. package/dist/core/cache/run-with-cache.mjs.map +1 -1
  27. package/dist/core/cache/store.d.mts +8 -6
  28. package/dist/core/cache/store.mjs.map +1 -1
  29. package/dist/core/cache/strategies.d.mts +27 -2
  30. package/dist/core/cache/strategies.mjs +6 -0
  31. package/dist/core/cache/strategies.mjs.map +1 -1
  32. package/dist/core/cart/actions.d.mts +37 -30
  33. package/dist/core/cart/actions.mjs +21 -9
  34. package/dist/core/cart/actions.mjs.map +1 -1
  35. package/dist/core/cart/attach-quantity-input.d.mts +8 -7
  36. package/dist/core/cart/attach-quantity-input.mjs +8 -7
  37. package/dist/core/cart/attach-quantity-input.mjs.map +1 -1
  38. package/dist/core/cart/buyer-identity-sync.d.mts +7 -6
  39. package/dist/core/cart/buyer-identity-sync.mjs.map +1 -1
  40. package/dist/core/cart/cart.d.mts +59 -46
  41. package/dist/core/cart/cart.mjs +46 -29
  42. package/dist/core/cart/cart.mjs.map +1 -1
  43. package/dist/core/cart/cookie.d.mts +8 -4
  44. package/dist/core/cart/cookie.mjs +8 -4
  45. package/dist/core/cart/cookie.mjs.map +1 -1
  46. package/dist/core/cart/form.d.mts +34 -20
  47. package/dist/core/cart/form.mjs +6 -4
  48. package/dist/core/cart/form.mjs.map +1 -1
  49. package/dist/core/cart/get-cart.d.mts +27 -15
  50. package/dist/core/cart/get-cart.mjs +13 -8
  51. package/dist/core/cart/get-cart.mjs.map +1 -1
  52. package/dist/core/cart/quantity.d.mts +16 -5
  53. package/dist/core/cart/quantity.mjs +16 -5
  54. package/dist/core/cart/quantity.mjs.map +1 -1
  55. package/dist/core/cart/queries.d.mts +25 -19
  56. package/dist/core/cart/queries.mjs +15 -1
  57. package/dist/core/cart/queries.mjs.map +1 -1
  58. package/dist/core/cart/server-handlers.d.mts +82 -45
  59. package/dist/core/cart/server-handlers.mjs +4 -0
  60. package/dist/core/cart/server-handlers.mjs.map +1 -1
  61. package/dist/core/cart/state.d.mts +110 -64
  62. package/dist/core/cart/state.mjs +24 -6
  63. package/dist/core/cart/state.mjs.map +1 -1
  64. package/dist/core/collection/collection.d.mts +52 -53
  65. package/dist/core/collection/collection.mjs +5 -3
  66. package/dist/core/collection/collection.mjs.map +1 -1
  67. package/dist/core/collection/reconciler.d.mts +23 -16
  68. package/dist/core/collection/reconciler.mjs +8 -4
  69. package/dist/core/collection/reconciler.mjs.map +1 -1
  70. package/dist/core/collection/state.d.mts +31 -26
  71. package/dist/core/collection/state.mjs +4 -3
  72. package/dist/core/collection/state.mjs.map +1 -1
  73. package/dist/core/collection/url.d.mts +70 -29
  74. package/dist/core/collection/url.mjs +63 -25
  75. package/dist/core/collection/url.mjs.map +1 -1
  76. package/dist/core/constants.d.mts +1 -0
  77. package/dist/core/constants.mjs +1 -0
  78. package/dist/core/constants.mjs.map +1 -1
  79. package/dist/core/logging/logging.d.mts +14 -8
  80. package/dist/core/logging/logging.mjs +15 -10
  81. package/dist/core/logging/logging.mjs.map +1 -1
  82. package/dist/core/logging/types.d.mts +28 -11
  83. package/dist/core/logging/types.mjs.map +1 -1
  84. package/dist/core/money/format.d.mts +6 -4
  85. package/dist/core/money/format.mjs +19 -9
  86. package/dist/core/money/format.mjs.map +1 -1
  87. package/dist/core/money/types.d.mts +41 -25
  88. package/dist/core/predictive-search/form.d.mts +37 -7
  89. package/dist/core/predictive-search/form.mjs +21 -3
  90. package/dist/core/predictive-search/form.mjs.map +1 -1
  91. package/dist/core/predictive-search/queries.d.mts +18 -30
  92. package/dist/core/predictive-search/queries.mjs +7 -3
  93. package/dist/core/predictive-search/queries.mjs.map +1 -1
  94. package/dist/core/predictive-search/search.d.mts +25 -27
  95. package/dist/core/predictive-search/search.mjs +20 -19
  96. package/dist/core/predictive-search/search.mjs.map +1 -1
  97. package/dist/core/predictive-search/server-handlers.d.mts +25 -26
  98. package/dist/core/predictive-search/server-handlers.mjs +4 -0
  99. package/dist/core/predictive-search/server-handlers.mjs.map +1 -1
  100. package/dist/core/predictive-search/store.d.mts +65 -24
  101. package/dist/core/predictive-search/store.mjs +12 -1
  102. package/dist/core/predictive-search/store.mjs.map +1 -1
  103. package/dist/core/predictive-search/url.d.mts +36 -37
  104. package/dist/core/predictive-search/url.mjs +14 -6
  105. package/dist/core/predictive-search/url.mjs.map +1 -1
  106. package/dist/core/product/form.d.mts +63 -16
  107. package/dist/core/product/form.mjs +8 -2
  108. package/dist/core/product/form.mjs.map +1 -1
  109. package/dist/core/product/options.d.mts +8 -10
  110. package/dist/core/product/options.mjs +8 -10
  111. package/dist/core/product/options.mjs.map +1 -1
  112. package/dist/core/product/product-form.d.mts +77 -29
  113. package/dist/core/product/product-form.mjs +32 -10
  114. package/dist/core/product/product-form.mjs.map +1 -1
  115. package/dist/core/product/state.d.mts +55 -32
  116. package/dist/core/product/url.d.mts +19 -13
  117. package/dist/core/product/url.mjs +10 -10
  118. package/dist/core/product/url.mjs.map +1 -1
  119. package/dist/core/request-context.d.mts +77 -19
  120. package/dist/core/request-context.mjs +5 -1
  121. package/dist/core/request-context.mjs.map +1 -1
  122. package/dist/core/request-routing/handle-shopify-redirects.d.mts +12 -4
  123. package/dist/core/request-routing/handle-shopify-redirects.mjs +9 -2
  124. package/dist/core/request-routing/handle-shopify-redirects.mjs.map +1 -1
  125. package/dist/core/request-routing/handle-shopify-routes.d.mts +5 -5
  126. package/dist/core/request-routing/handle-shopify-routes.mjs +7 -5
  127. package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -1
  128. package/dist/core/request-routing/interceptors/proxy.mjs +79 -43
  129. package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -1
  130. package/dist/core/request-routing/interceptors/ucp-profile-proxy.mjs +69 -0
  131. package/dist/core/request-routing/interceptors/ucp-profile-proxy.mjs.map +1 -0
  132. package/dist/core/request-routing/interceptors/url-redirects.mjs +6 -1
  133. package/dist/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
  134. package/dist/core/request-routing/interceptors/well-known.mjs +1 -1
  135. package/dist/core/request-routing/interceptors/well-known.mjs.map +1 -1
  136. package/dist/core/request-routing/registered-routes.d.mts +12 -0
  137. package/dist/core/request-routing/registered-routes.mjs +12 -0
  138. package/dist/core/request-routing/registered-routes.mjs.map +1 -1
  139. package/dist/core/request-routing/route-types.d.mts +43 -18
  140. package/dist/core/shop-pay/shop-pay.d.mts +71 -35
  141. package/dist/core/shop-pay/shop-pay.mjs +36 -10
  142. package/dist/core/shop-pay/shop-pay.mjs.map +1 -1
  143. package/dist/core/shopify-scripts/index.d.mts +15 -5
  144. package/dist/core/shopify-scripts/index.mjs +15 -5
  145. package/dist/core/shopify-scripts/index.mjs.map +1 -1
  146. package/dist/core/shopify-scripts/initialize.d.mts +12 -4
  147. package/dist/core/shopify-scripts/initialize.mjs +12 -4
  148. package/dist/core/shopify-scripts/initialize.mjs.map +1 -1
  149. package/dist/core/shopify-scripts/types.d.mts +58 -25
  150. package/dist/core/standard-routes/build.d.mts +11 -12
  151. package/dist/core/standard-routes/build.mjs +11 -12
  152. package/dist/core/standard-routes/build.mjs.map +1 -1
  153. package/dist/core/standard-routes/types.d.mts +30 -24
  154. package/dist/core/url.mjs +2 -1
  155. package/dist/core/url.mjs.map +1 -1
  156. package/dist/customer-account/client.d.mts +36 -69
  157. package/dist/customer-account/client.mjs +7 -8
  158. package/dist/customer-account/client.mjs.map +1 -1
  159. package/dist/customer-account/errors.d.mts +45 -36
  160. package/dist/customer-account/errors.mjs +21 -36
  161. package/dist/customer-account/errors.mjs.map +1 -1
  162. package/dist/customer-account/graphql.d.mts +11 -23
  163. package/dist/customer-account/graphql.mjs +3 -9
  164. package/dist/customer-account/graphql.mjs.map +1 -1
  165. package/dist/customer-account/session.d.mts +130 -100
  166. package/dist/customer-account/session.mjs +32 -10
  167. package/dist/customer-account/session.mjs.map +1 -1
  168. package/dist/customer-account/type-resolver.d.mts +7 -8
  169. package/dist/development/client/client.d.mts +18 -15
  170. package/dist/development/client/client.mjs +8 -3
  171. package/dist/development/client/client.mjs.map +1 -1
  172. package/dist/development/client/errors.d.mts +35 -13
  173. package/dist/development/client/errors.mjs +23 -13
  174. package/dist/development/client/errors.mjs.map +1 -1
  175. package/dist/development/client/types.d.mts +140 -90
  176. package/dist/development/core/analytics/cart-tracker.d.mts +19 -10
  177. package/dist/development/core/analytics/cart-tracker.mjs +18 -10
  178. package/dist/development/core/analytics/cart-tracker.mjs.map +1 -1
  179. package/dist/development/core/analytics/events.d.mts +17 -11
  180. package/dist/development/core/analytics/events.mjs +13 -4
  181. package/dist/development/core/analytics/events.mjs.map +1 -1
  182. package/dist/development/core/analytics/types.d.mts +207 -118
  183. package/dist/development/core/analytics/utils/flatten-connection.d.mts +11 -9
  184. package/dist/development/core/analytics/utils/flatten-connection.mjs +7 -6
  185. package/dist/development/core/analytics/utils/flatten-connection.mjs.map +1 -1
  186. package/dist/development/core/cache/fetch-with-cache.d.mts +24 -4
  187. package/dist/development/core/cache/fetch-with-cache.mjs +17 -2
  188. package/dist/development/core/cache/fetch-with-cache.mjs.map +1 -1
  189. package/dist/development/core/cache/key.d.mts +2 -0
  190. package/dist/development/core/cache/key.mjs.map +1 -1
  191. package/dist/development/core/cache/run-with-cache.d.mts +56 -8
  192. package/dist/development/core/cache/run-with-cache.mjs +17 -6
  193. package/dist/development/core/cache/run-with-cache.mjs.map +1 -1
  194. package/dist/development/core/cache/store.d.mts +8 -6
  195. package/dist/development/core/cache/store.mjs.map +1 -1
  196. package/dist/development/core/cache/strategies.d.mts +27 -2
  197. package/dist/development/core/cache/strategies.mjs +6 -0
  198. package/dist/development/core/cache/strategies.mjs.map +1 -1
  199. package/dist/development/core/cart/actions.d.mts +37 -30
  200. package/dist/development/core/cart/actions.mjs +21 -9
  201. package/dist/development/core/cart/actions.mjs.map +1 -1
  202. package/dist/development/core/cart/attach-quantity-input.d.mts +8 -7
  203. package/dist/development/core/cart/attach-quantity-input.mjs +8 -7
  204. package/dist/development/core/cart/attach-quantity-input.mjs.map +1 -1
  205. package/dist/development/core/cart/buyer-identity-sync.d.mts +6 -5
  206. package/dist/development/core/cart/buyer-identity-sync.mjs.map +1 -1
  207. package/dist/development/core/cart/cart.d.mts +59 -46
  208. package/dist/development/core/cart/cart.mjs +46 -29
  209. package/dist/development/core/cart/cart.mjs.map +1 -1
  210. package/dist/development/core/cart/cookie.d.mts +8 -4
  211. package/dist/development/core/cart/cookie.mjs +8 -4
  212. package/dist/development/core/cart/cookie.mjs.map +1 -1
  213. package/dist/development/core/cart/form.d.mts +34 -20
  214. package/dist/development/core/cart/form.mjs +6 -4
  215. package/dist/development/core/cart/form.mjs.map +1 -1
  216. package/dist/development/core/cart/get-cart.d.mts +27 -15
  217. package/dist/development/core/cart/get-cart.mjs +13 -8
  218. package/dist/development/core/cart/get-cart.mjs.map +1 -1
  219. package/dist/development/core/cart/quantity.d.mts +16 -5
  220. package/dist/development/core/cart/quantity.mjs +16 -5
  221. package/dist/development/core/cart/quantity.mjs.map +1 -1
  222. package/dist/development/core/cart/queries.d.mts +25 -19
  223. package/dist/development/core/cart/queries.mjs +15 -1
  224. package/dist/development/core/cart/queries.mjs.map +1 -1
  225. package/dist/development/core/cart/server-handlers.d.mts +82 -45
  226. package/dist/development/core/cart/server-handlers.mjs +4 -0
  227. package/dist/development/core/cart/server-handlers.mjs.map +1 -1
  228. package/dist/development/core/cart/state.d.mts +110 -64
  229. package/dist/development/core/cart/state.mjs +24 -6
  230. package/dist/development/core/cart/state.mjs.map +1 -1
  231. package/dist/development/core/collection/collection.d.mts +52 -53
  232. package/dist/development/core/collection/collection.mjs +5 -3
  233. package/dist/development/core/collection/collection.mjs.map +1 -1
  234. package/dist/development/core/collection/reconciler.d.mts +23 -16
  235. package/dist/development/core/collection/reconciler.mjs +8 -4
  236. package/dist/development/core/collection/reconciler.mjs.map +1 -1
  237. package/dist/development/core/collection/state.d.mts +31 -26
  238. package/dist/development/core/collection/state.mjs +4 -3
  239. package/dist/development/core/collection/state.mjs.map +1 -1
  240. package/dist/development/core/collection/url.d.mts +70 -29
  241. package/dist/development/core/collection/url.mjs +63 -25
  242. package/dist/development/core/collection/url.mjs.map +1 -1
  243. package/dist/development/core/constants.mjs.map +1 -1
  244. package/dist/development/core/logging/logging.d.mts +14 -8
  245. package/dist/development/core/logging/logging.mjs +15 -10
  246. package/dist/development/core/logging/logging.mjs.map +1 -1
  247. package/dist/development/core/logging/types.d.mts +28 -11
  248. package/dist/development/core/logging/types.mjs.map +1 -1
  249. package/dist/development/core/money/format.d.mts +6 -4
  250. package/dist/development/core/money/format.mjs +19 -9
  251. package/dist/development/core/money/format.mjs.map +1 -1
  252. package/dist/development/core/money/types.d.mts +41 -25
  253. package/dist/development/core/predictive-search/form.d.mts +37 -7
  254. package/dist/development/core/predictive-search/form.mjs +21 -3
  255. package/dist/development/core/predictive-search/form.mjs.map +1 -1
  256. package/dist/development/core/predictive-search/queries.d.mts +18 -30
  257. package/dist/development/core/predictive-search/queries.mjs +7 -3
  258. package/dist/development/core/predictive-search/queries.mjs.map +1 -1
  259. package/dist/development/core/predictive-search/search.d.mts +25 -27
  260. package/dist/development/core/predictive-search/search.mjs +20 -19
  261. package/dist/development/core/predictive-search/search.mjs.map +1 -1
  262. package/dist/development/core/predictive-search/server-handlers.d.mts +25 -26
  263. package/dist/development/core/predictive-search/server-handlers.mjs +4 -0
  264. package/dist/development/core/predictive-search/server-handlers.mjs.map +1 -1
  265. package/dist/development/core/predictive-search/store.d.mts +65 -24
  266. package/dist/development/core/predictive-search/store.mjs +12 -1
  267. package/dist/development/core/predictive-search/store.mjs.map +1 -1
  268. package/dist/development/core/predictive-search/url.d.mts +36 -37
  269. package/dist/development/core/predictive-search/url.mjs +14 -6
  270. package/dist/development/core/predictive-search/url.mjs.map +1 -1
  271. package/dist/development/core/product/form.d.mts +63 -16
  272. package/dist/development/core/product/form.mjs +8 -2
  273. package/dist/development/core/product/form.mjs.map +1 -1
  274. package/dist/development/core/product/options.d.mts +8 -10
  275. package/dist/development/core/product/options.mjs +8 -10
  276. package/dist/development/core/product/options.mjs.map +1 -1
  277. package/dist/development/core/product/product-form.d.mts +77 -29
  278. package/dist/development/core/product/product-form.mjs +32 -10
  279. package/dist/development/core/product/product-form.mjs.map +1 -1
  280. package/dist/development/core/product/state.d.mts +55 -32
  281. package/dist/development/core/product/url.d.mts +19 -13
  282. package/dist/development/core/product/url.mjs +10 -10
  283. package/dist/development/core/product/url.mjs.map +1 -1
  284. package/dist/development/core/request-context.d.mts +77 -19
  285. package/dist/development/core/request-context.mjs +5 -1
  286. package/dist/development/core/request-context.mjs.map +1 -1
  287. package/dist/development/core/request-routing/handle-shopify-redirects.d.mts +12 -4
  288. package/dist/development/core/request-routing/handle-shopify-redirects.mjs +9 -2
  289. package/dist/development/core/request-routing/handle-shopify-redirects.mjs.map +1 -1
  290. package/dist/development/core/request-routing/handle-shopify-routes.development.d.mts +9 -1
  291. package/dist/development/core/request-routing/handle-shopify-routes.development.mjs +7 -0
  292. package/dist/development/core/request-routing/handle-shopify-routes.development.mjs.map +1 -1
  293. package/dist/development/core/request-routing/handle-shopify-routes.mjs +7 -5
  294. package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -1
  295. package/dist/development/core/request-routing/interceptors/proxy.mjs +79 -43
  296. package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -1
  297. package/dist/development/core/request-routing/interceptors/ucp-profile-proxy.mjs +69 -0
  298. package/dist/development/core/request-routing/interceptors/ucp-profile-proxy.mjs.map +1 -0
  299. package/dist/development/core/request-routing/interceptors/url-redirects.mjs +6 -1
  300. package/dist/development/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
  301. package/dist/development/core/request-routing/interceptors/well-known.mjs +1 -1
  302. package/dist/development/core/request-routing/interceptors/well-known.mjs.map +1 -1
  303. package/dist/development/core/request-routing/registered-routes.d.mts +12 -0
  304. package/dist/development/core/request-routing/registered-routes.mjs +12 -0
  305. package/dist/development/core/request-routing/registered-routes.mjs.map +1 -1
  306. package/dist/development/core/request-routing/route-types.d.mts +43 -18
  307. package/dist/development/core/shop-pay/shop-pay.d.mts +71 -35
  308. package/dist/development/core/shop-pay/shop-pay.mjs +36 -10
  309. package/dist/development/core/shop-pay/shop-pay.mjs.map +1 -1
  310. package/dist/development/core/shopify-scripts/index.d.mts +15 -5
  311. package/dist/development/core/shopify-scripts/index.mjs +15 -5
  312. package/dist/development/core/shopify-scripts/index.mjs.map +1 -1
  313. package/dist/development/core/shopify-scripts/initialize.d.mts +12 -4
  314. package/dist/development/core/shopify-scripts/initialize.mjs +12 -4
  315. package/dist/development/core/shopify-scripts/initialize.mjs.map +1 -1
  316. package/dist/development/core/shopify-scripts/types.d.mts +58 -25
  317. package/dist/development/core/standard-routes/build.d.mts +11 -12
  318. package/dist/development/core/standard-routes/build.mjs +11 -12
  319. package/dist/development/core/standard-routes/build.mjs.map +1 -1
  320. package/dist/development/core/standard-routes/types.d.mts +30 -24
  321. package/dist/development/core/url.mjs +2 -1
  322. package/dist/development/core/url.mjs.map +1 -1
  323. package/dist/development/customer-account/session.d.mts +45 -54
  324. package/dist/development/customer-account/session.mjs +20 -4
  325. package/dist/development/customer-account/session.mjs.map +1 -1
  326. package/dist/development/globals.d.mts +20 -11
  327. package/dist/development/graphql/generated/storefront-api-types.d.mts +127 -1
  328. package/dist/development/graphql/graphql.d.mts +17 -16
  329. package/dist/development/graphql/graphql.mjs +7 -8
  330. package/dist/development/graphql/graphql.mjs.map +1 -1
  331. package/dist/development/graphql/type-resolver.d.mts +15 -8
  332. package/dist/development/react/cart.d.mts +78 -32
  333. package/dist/development/react/cart.mjs +56 -29
  334. package/dist/development/react/cart.mjs.map +1 -1
  335. package/dist/development/react/collection.d.mts +40 -22
  336. package/dist/development/react/collection.mjs +27 -7
  337. package/dist/development/react/collection.mjs.map +1 -1
  338. package/dist/development/react/predictive-search.d.mts +65 -50
  339. package/dist/development/react/predictive-search.mjs +23 -21
  340. package/dist/development/react/predictive-search.mjs.map +1 -1
  341. package/dist/development/react/product.d.mts +45 -16
  342. package/dist/development/react/product.mjs +13 -11
  343. package/dist/development/react/product.mjs.map +1 -1
  344. package/dist/development/react/shop-pay.d.mts +15 -0
  345. package/dist/development/react/shop-pay.mjs +9 -0
  346. package/dist/development/react/shop-pay.mjs.map +1 -1
  347. package/dist/development/react/shopify-scripts.d.mts +23 -2
  348. package/dist/development/react/shopify-scripts.mjs +9 -0
  349. package/dist/development/react/shopify-scripts.mjs.map +1 -1
  350. package/dist/development/vue/cart.d.mts +28 -23
  351. package/dist/development/vue/cart.mjs +42 -25
  352. package/dist/development/vue/cart.mjs.map +1 -1
  353. package/dist/development/vue/collection.d.mts +20 -12
  354. package/dist/development/vue/collection.mjs +15 -7
  355. package/dist/development/vue/collection.mjs.map +1 -1
  356. package/dist/development/vue/index.d.mts +2 -2
  357. package/dist/development/vue/index.mjs +2 -2
  358. package/dist/development/vue/predictive-search.d.mts +31 -36
  359. package/dist/development/vue/predictive-search.mjs +16 -22
  360. package/dist/development/vue/predictive-search.mjs.map +1 -1
  361. package/dist/development/vue/product.d.mts +16 -15
  362. package/dist/development/vue/product.mjs +11 -11
  363. package/dist/development/vue/product.mjs.map +1 -1
  364. package/dist/development/vue/shop-pay.d.mts +14 -17
  365. package/dist/development/vue/shop-pay.mjs +8 -0
  366. package/dist/development/vue/shop-pay.mjs.map +1 -1
  367. package/dist/development/vue/shopify-scripts.d.mts +11 -0
  368. package/dist/development/vue/shopify-scripts.mjs +6 -0
  369. package/dist/development/vue/shopify-scripts.mjs.map +1 -1
  370. package/dist/globals.d.mts +20 -11
  371. package/dist/graphql/generated/storefront-api-types.d.mts +127 -1
  372. package/dist/graphql/graphql.d.mts +17 -16
  373. package/dist/graphql/graphql.mjs +7 -8
  374. package/dist/graphql/graphql.mjs.map +1 -1
  375. package/dist/graphql/type-resolver.d.mts +15 -8
  376. package/dist/react/cart.d.mts +78 -32
  377. package/dist/react/cart.mjs +56 -29
  378. package/dist/react/cart.mjs.map +1 -1
  379. package/dist/react/collection.d.mts +40 -22
  380. package/dist/react/collection.mjs +27 -7
  381. package/dist/react/collection.mjs.map +1 -1
  382. package/dist/react/predictive-search.d.mts +65 -50
  383. package/dist/react/predictive-search.mjs +23 -21
  384. package/dist/react/predictive-search.mjs.map +1 -1
  385. package/dist/react/product.d.mts +45 -16
  386. package/dist/react/product.mjs +13 -11
  387. package/dist/react/product.mjs.map +1 -1
  388. package/dist/react/shop-pay.d.mts +15 -0
  389. package/dist/react/shop-pay.mjs +9 -0
  390. package/dist/react/shop-pay.mjs.map +1 -1
  391. package/dist/react/shopify-scripts.d.mts +23 -2
  392. package/dist/react/shopify-scripts.mjs +9 -0
  393. package/dist/react/shopify-scripts.mjs.map +1 -1
  394. package/dist/ts-plugin/index.cjs +6 -0
  395. package/dist/ts-plugin/index.cjs.map +1 -1
  396. package/dist/ts-plugin/index.d.cts +6 -0
  397. package/dist/vite/local-https.d.mts +51 -17
  398. package/dist/vite/local-https.mjs +26 -5
  399. package/dist/vite/local-https.mjs.map +1 -1
  400. package/dist/vue/cart.d.mts +28 -23
  401. package/dist/vue/cart.mjs +42 -25
  402. package/dist/vue/cart.mjs.map +1 -1
  403. package/dist/vue/collection.d.mts +20 -12
  404. package/dist/vue/collection.mjs +15 -7
  405. package/dist/vue/collection.mjs.map +1 -1
  406. package/dist/vue/index.d.mts +2 -2
  407. package/dist/vue/index.mjs +2 -2
  408. package/dist/vue/predictive-search.d.mts +31 -36
  409. package/dist/vue/predictive-search.mjs +16 -22
  410. package/dist/vue/predictive-search.mjs.map +1 -1
  411. package/dist/vue/product.d.mts +16 -15
  412. package/dist/vue/product.mjs +11 -11
  413. package/dist/vue/product.mjs.map +1 -1
  414. package/dist/vue/shop-pay.d.mts +14 -17
  415. package/dist/vue/shop-pay.mjs +8 -0
  416. package/dist/vue/shop-pay.mjs.map +1 -1
  417. package/dist/vue/shopify-scripts.d.mts +11 -0
  418. package/dist/vue/shopify-scripts.mjs +6 -0
  419. package/dist/vue/shopify-scripts.mjs.map +1 -1
  420. package/package.json +3 -1
  421. package/skills/hydrogen-analytics/SKILL.md +1 -1
  422. package/skills/hydrogen-cart-ui/SKILL.md +28 -2
  423. package/skills/hydrogen-collection-browser/SKILL.md +9 -1
  424. package/skills/hydrogen-collection-browser/references/nextjs.md +1 -1
  425. package/skills/hydrogen-collection-browser/references/nuxt.md +1 -1
  426. package/skills/hydrogen-collection-browser/references/react.md +151 -32
  427. package/skills/hydrogen-customer-account/SKILL.md +2 -0
  428. package/skills/hydrogen-request-handlers/SKILL.md +21 -11
  429. package/skills/hydrogen-setup/references/analytics.md +14 -8
  430. package/skills/hydrogen-setup/steps/1-inspect-app.md +2 -2
  431. package/skills/hydrogen-setup/steps/6-product-detail-page.md +21 -11
  432. package/skills/hydrogen-storefront-client/SKILL.md +1 -1
  433. package/skills/hydrogen-storefront-client/references/caching.md +2 -0
  434. package/skills/hydrogen-variant-form/SKILL.md +25 -7
  435. package/skills/hydrogen-variant-form/references/nextjs.md +39 -4
  436. package/skills/hydrogen-variant-form/references/nuxt.md +83 -42
  437. package/skills/hydrogen-variant-form/references/react.md +45 -9
@@ -1,22 +1,23 @@
1
1
  import { CartErrorCode, CartWarningCode } from "../../graphql/generated/storefront-api-types.mjs";
2
2
 
3
3
  //#region src/core/cart/state.d.ts
4
- /** Storefront API monetary value — an amount string and ISO 4217 currency code. */
4
+ /** A monetary value from the Storefront API. */
5
5
  interface Money {
6
- /** Decimal amount as a string (e.g. `"29.99"`). */
6
+ /** The decimal amount as a string, such as `29.99`. */
7
7
  amount: string;
8
- /** ISO 4217 currency code (e.g. `"USD"`, `"EUR"`). */
8
+ /** The ISO 4217 currency code, such as `USD`. */
9
9
  currencyCode: string;
10
10
  }
11
- /** Cart-level cost breakdown returned by the Storefront API. */
11
+ /** The cart's costs from the Storefront API. */
12
12
  interface CartCost {
13
13
  /** The amount, before taxes and cart-level discounts, for the customer to pay. */
14
14
  subtotalAmount: Money;
15
- /** Final amount the buyer pays at checkout. */
15
+ /** Final amount the customer pays at checkout. */
16
16
  totalAmount: Money;
17
17
  /** Estimated amount due at checkout, excluding deferred payments. Equals the subtotal when no deferred payments exist. */
18
18
  checkoutChargeAmount: Money;
19
19
  }
20
+ /** A cart line's costs from the Storefront API. */
20
21
  interface CartLineCost {
21
22
  /** Line total after all applicable discounts. */
22
23
  totalAmount: Money;
@@ -27,22 +28,24 @@ interface CartLineCost {
27
28
  /** Original compare-at unit price, or `null` when no comparison exists. */
28
29
  compareAtAmountPerQuantity: Money | null;
29
30
  }
30
- /** Product variant information attached to a {@link CartLine}. */
31
+ /** The product variant on a cart line. */
31
32
  interface CartLineMerchandise {
32
33
  /** Storefront API GID of the product variant. */
33
34
  id: string;
34
- /** Variant title (e.g. `"Small / Black"`). */
35
+ /** The variant title, such as `"Small / Black"`. */
35
36
  title?: string;
36
- /** Selected variant option name/value pairs (e.g. `{ name: "Size", value: "S" }`). */
37
+ /** The variant's selected options as name and value pairs. */
37
38
  selectedOptions?: Array<{
38
39
  name: string;
39
40
  value: string;
40
41
  }>;
42
+ /** The product that the variant belongs to. */
41
43
  product: {
42
44
  title: string;
43
45
  handle?: string;
44
46
  [key: string]: unknown;
45
47
  };
48
+ /** The variant image that the cart query selects. */
46
49
  image?: {
47
50
  id?: string | null;
48
51
  url: string;
@@ -51,25 +54,28 @@ interface CartLineMerchandise {
51
54
  height?: number | null;
52
55
  [key: string]: unknown;
53
56
  } | null;
57
+ /** Units available for sale. When your cart fragment selects the field, the store caps the quantity of a `set` submission at this number. */
54
58
  quantityAvailable?: number | null;
59
+ /** Extra variant fields from your custom cart fragment, unchanged. */
55
60
  [key: string]: unknown;
56
61
  }
57
62
  /**
58
63
  * A single line item in the cart.
59
64
  *
60
- * Each line represents a product variant at a given quantity. Lines may carry
61
- * custom {@link Attribute | attributes}, a selling plan allocation (subscriptions),
62
- * or nested {@link CartLine.lineComponents | line components} (bundles).
65
+ * Each line holds a product variant at a quantity. A line can carry custom
66
+ * attributes, a selling plan allocation for a subscription, or line components
67
+ * for a bundle.
63
68
  */
64
69
  interface CartLine {
65
- /** Storefront API GID of this cart line — used as the key in {@link CartPending.lines}. */
70
+ /** The cart line's Storefront API GID. Look up the line's pending state and errors with this ID. */
66
71
  id: string;
67
72
  /** Number of units of this merchandise in the cart. */
68
73
  quantity: number;
74
+ /** Custom key-value attributes attached to the line. */
69
75
  attributes?: Attribute[];
70
76
  /** Per-line cost breakdown from the Storefront API. */
71
77
  cost: CartLineCost;
72
- /** The product variant this line represents. */
78
+ /** The product variant on the line. */
73
79
  merchandise?: CartLineMerchandise;
74
80
  /** Subscription selling plan allocation, or `null` for one-time purchases. */
75
81
  sellingPlanAllocation?: {
@@ -77,6 +83,7 @@ interface CartLine {
77
83
  id: string;
78
84
  };
79
85
  } | null;
86
+ /** The parent line's ID when this line is a bundle component. */
80
87
  parentRelationship?: {
81
88
  parent: {
82
89
  id: string;
@@ -85,52 +92,65 @@ interface CartLine {
85
92
  /** Nested child lines when this line is a bundle parent. */
86
93
  lineComponents?: CartLine[];
87
94
  }
95
+ /** The cart's line items in the Storefront API connection shape. */
88
96
  interface CartLineConnection {
97
+ /** The cart lines that the cart query returns. */
89
98
  nodes: CartLine[];
99
+ /** Extra connection fields from your custom cart fragment, unchanged. */
90
100
  [key: string]: unknown;
91
101
  }
92
102
  /** A discount code applied to the cart. */
93
103
  interface DiscountCode {
104
+ /** The discount code text. Look up the code's pending state and errors with this value. */
94
105
  code: string;
95
- /** Whether the code is applicable to the cart's current contents. Set optimistically to `false` for newly added codes until the server confirms. */
106
+ /** Whether the code applies to the cart's current contents. A new code reads `false` until the server responds. */
96
107
  applicable: boolean;
97
108
  }
98
109
  /** A validation error returned by a Storefront API cart mutation. */
99
110
  interface CartUserError {
100
111
  /** Machine-readable error code, or `null` for unclassified errors. */
101
112
  code: CartErrorCode | null;
113
+ /** Human-readable error text from the Storefront API. */
102
114
  message: string;
103
- /** JSONPath to the input field that caused the error (e.g. `["lines", "0", "quantity"]`). */
115
+ /** The path to the input field that caused the error, such as `["lines", "0", "quantity"]`. */
104
116
  field?: string[];
105
117
  }
106
118
  /** A non-blocking warning returned by a Storefront API cart mutation. */
107
119
  interface CartWarning {
120
+ /** The warning code from the Storefront API. */
108
121
  code: CartWarningCode;
122
+ /** Human-readable warning text from the Storefront API. */
109
123
  message: string;
110
124
  }
111
- /** Errors and warnings from a single cart mutation response. */
125
+ /** Errors and warnings from one cart change. */
112
126
  interface CartErrorGroup {
127
+ /** Validation errors that the mutation returned. */
113
128
  userErrors: CartUserError[];
129
+ /** Non-blocking warnings that the mutation returned. */
114
130
  warnings: CartWarning[];
115
131
  }
116
- /** A network-level error encountered during a cart operation (e.g. non-2xx response, timeout). Aborted requests are not recorded. */
132
+ /**
133
+ * A failed cart request, such as a non-2xx response or a timeout. Canceled requests add no entry.
134
+ */
117
135
  interface CartNetworkEntry {
136
+ /** The error message, or a generic message when the failure has no message of its own. */
118
137
  message: string;
119
- /** HTTP status code when available. */
138
+ /** The HTTP status code, when the endpoint returned a non-2xx response. */
120
139
  status?: number;
121
140
  }
122
- /** A key-value pair attached to the cart or to an individual {@link CartLine}. */
141
+ /** A key-value pair attached to the cart or to an individual cart line. */
123
142
  interface Attribute {
143
+ /** The attribute name. Look up the attribute's errors with this name. */
124
144
  key: string;
145
+ /** The attribute value. */
125
146
  value: string | null;
126
147
  }
127
148
  /**
128
- * Tracks which parts of the cart have in-flight mutations.
149
+ * Shows which parts of the cart have changes in flight.
129
150
  *
130
- * `lines` and `discountCodes` are `Set<string>` keyed by line ID / discount code,
131
- * enabling per-item pending indicators rather than a single global spinner.
132
- * `cost` is a boolean because *any* line or discount change affects the total —
133
- * use it to show pending UI on price displays without computing optimistic amounts.
151
+ * Check a line ID or a discount code to show a pending indicator on that item.
152
+ * Check `cost` to show pending UI on prices, which update only when the server
153
+ * responds.
134
154
  *
135
155
  * @example
136
156
  * ```ts
@@ -148,64 +168,73 @@ interface Attribute {
148
168
  * ```
149
169
  */
150
170
  interface CartPending {
151
- /** Line IDs with in-flight add, quantity, or remove mutations. New lines use their `optimistic:` ID until the server confirms. */
171
+ /** Line IDs with an add, quantity change, or removal in flight. A new line has an ID that starts with `optimistic:` until the server confirms the line. */
152
172
  lines: Set<string>;
173
+ /** `true` while a note update is in flight. */
153
174
  note: boolean;
175
+ /** `true` while an attribute update is in flight. */
154
176
  attributes: boolean;
155
- /** Discount codes with in-flight apply/remove mutations. */
177
+ /** Discount codes with an apply or remove in flight. */
156
178
  discountCodes: Set<string>;
157
- /** `true` when any mutation may affect cart pricing — show pending UI on cost displays. */
179
+ /** `true` while a change that can affect cart prices is in flight. */
158
180
  cost?: boolean;
159
181
  }
160
182
  /**
161
- * Per-resource error tracking for the cart.
183
+ * The cart's errors, grouped by the part of the cart that they affect: lines, the note,
184
+ * attributes, discount codes, or the cart as a whole. Each group has a timestamp in
185
+ * milliseconds since the epoch. Use the timestamps to flag stale errors or dismiss
186
+ * errors after a timeout.
162
187
  *
163
- * Errors are bucketed by the resource they affect — `lines`, `note`, `attributes`,
164
- * `discountCodes`, or `cart` (for cross-cutting errors). Each bucket carries a
165
- * `*UpdatedAt` timestamp (ms since epoch) so the UI can show stale-error indicators
166
- * or auto-dismiss after a timeout.
167
- *
168
- * `network` collects transport-level failures (timeouts, 5xx) separately from
169
- * Storefront API user errors.
188
+ * Failed requests go in a network list, apart from Storefront API user errors.
170
189
  */
171
190
  interface CartErrorState {
172
- /** Cross-cutting cart errors not attributable to a specific resource. */
191
+ /** Errors that don't belong to a line, the note, an attribute, or a discount code. */
173
192
  cart: CartErrorGroup;
174
- /** Errors keyed by {@link CartLine.id}. */
193
+ /** Errors keyed by cart line ID. */
175
194
  lines: Map<string, CartErrorGroup>;
195
+ /** Errors for the cart note. */
176
196
  note: CartErrorGroup;
177
- /** Errors keyed by {@link Attribute.key}. */
197
+ /** Errors keyed by attribute name. */
178
198
  attributes: Map<string, CartErrorGroup>;
179
- /** Errors keyed by discount code string. */
199
+ /** Errors keyed by discount code. */
180
200
  discountCodes: Map<string, CartErrorGroup>;
201
+ /**
202
+ * Failed cart requests. A failed cart change adds an entry, with an HTTP status when the endpoint returned a non-2xx response. A failed refresh adds an entry with a generic message and no status. A failed first load or a failed load after a reset adds no entry.
203
+ */
181
204
  network: CartNetworkEntry[];
205
+ /** Time in milliseconds since the epoch when the store last recorded any error, or `0` before the first. */
182
206
  lastUpdatedAt: number;
207
+ /** Time in milliseconds since the epoch of the last line, discount code, or attribute error, or `0` before any. */
183
208
  cartUpdatedAt: number;
209
+ /** Time in milliseconds since the epoch when the store last recorded line errors, or `0` before any. */
184
210
  linesUpdatedAt: number;
211
+ /** Time in milliseconds since the epoch when the store last recorded note errors, or `0` before any. */
185
212
  noteUpdatedAt: number;
213
+ /** Time in milliseconds since the epoch when the store last recorded attribute errors, or `0` before any. */
186
214
  attributesUpdatedAt: number;
215
+ /** Time in milliseconds since the epoch when the store last recorded discount code errors, or `0` before any. */
187
216
  discountCodesUpdatedAt: number;
217
+ /** Time in milliseconds since the epoch when the store last recorded a network error, or `0` before any. */
188
218
  networkUpdatedAt: number;
189
219
  }
190
220
  /**
191
- * Cart data returned by the Storefront API.
221
+ * The customer's cart, in the shape that the Storefront API returns.
192
222
  *
193
- * This is the server's authoritative snapshot — prices, discount applicability,
194
- * and totals come exclusively from here, never from client-side computation.
195
- * The index signature allows custom cart query fields to pass through.
223
+ * Cart costs come only from the server. Extra fields from your custom cart
224
+ * fragment appear unchanged.
196
225
  */
197
226
  interface CartData {
198
- /** Storefront API Cart GID, or `null` when no cart exists yet. */
227
+ /** The cart's Storefront API GID, or `null` when no cart exists yet. */
199
228
  id: string | null;
200
- /** `Cart.updatedAt` (ISO 8601). Absent until the first server response. */
229
+ /** The cart's last update time in ISO 8601 format. Absent until the first server response. */
201
230
  updatedAt?: string;
202
- /** Shopify checkout URL. Changes when buyer identity or consent state changes. */
231
+ /** The Shopify checkout URL. The URL can change when the customer logs in or out, or changes tracking consent. */
203
232
  checkoutUrl?: string | null;
204
233
  /** Sum of all line quantities. */
205
234
  totalQuantity: number;
206
- /** Cart-level cost breakdown (subtotal, total, checkout charge). */
235
+ /** The cart's subtotal, total, and checkout charge. */
207
236
  cost: CartCost;
208
- /** Buyer-supplied cart note, or `null`/empty when unset. */
237
+ /** Customer-supplied cart note, or `null` or empty when unset. */
209
238
  note?: string | null;
210
239
  /** Cart-level custom attributes. */
211
240
  attributes: Attribute[];
@@ -213,15 +242,14 @@ interface CartData {
213
242
  lines: CartLineConnection;
214
243
  /** Discount codes applied to the cart, with their applicability. */
215
244
  discountCodes: DiscountCode[];
245
+ /** Extra cart fields from your custom cart fragment, unchanged. */
216
246
  [key: string]: unknown;
217
247
  }
218
248
  /**
219
- * Full observable state of the cart store.
249
+ * The cart, plus what's loading, pending, and failed.
220
250
  *
221
- * Framework adapters subscribe to this via `CartStore.subscribe` (or the
222
- * framework-specific hooks like `useCart`). The generic `TData` parameter
223
- * flows from your server handler configuration, so `data` is typed to match
224
- * your custom cart query.
251
+ * The cart hooks return values from this state. The data type matches the cart
252
+ * fragment in your cart server handlers.
225
253
  *
226
254
  * @example
227
255
  * ```ts
@@ -241,29 +269,47 @@ interface CartData {
241
269
  * ```
242
270
  */
243
271
  interface CartState<TData extends CartData = CartData> {
244
- /** The latest server-confirmed cart data, with optimistic projections applied on top. */
272
+ /** The cart, including changes that the server hasn't confirmed yet. */
245
273
  data: TData;
246
- /** `true` during a full-cart fetch — initial load, after `reset()`, or before connect with no `initialData`. */
274
+ /** `true` while the store loads the full cart: the first load, a load after `reset()`, or before `connect()` when the store has no initial data. */
247
275
  loading: boolean;
248
- /** Non-rejecting signal that resolves when the current full-cart load settles or is invalidated. */
276
+ /** Present while a full cart load runs. The promise resolves, and never rejects, when the load finishes or the store drops the load. */
249
277
  readonly readyPromise?: PromiseLike<void>;
250
- /** Per-resource in-flight mutation tracking. */
278
+ /** The parts of the cart with changes in flight. */
251
279
  pending: CartPending;
252
- /** `true` when a background revalidation is in flight (triggered by overlapping mutations or `refresh()`). */
280
+ /** `true` while the store reloads the cart in the background after overlapping cart changes or a `refresh()` call. */
253
281
  revalidating?: boolean;
254
- /** Per-resource error and warning state. */
282
+ /** Errors and warnings, grouped by the part of the cart that they affect. */
255
283
  errors: CartErrorState;
256
284
  }
257
- /** Creates an empty {@link CartErrorGroup} — no user errors, no warnings. */
285
+ /**
286
+ * Creates an empty error group with no user errors and no warnings.
287
+ *
288
+ * @returns A new error group with empty user error and warning arrays.
289
+ * @publicDocs
290
+ */
258
291
  declare function createEmptyErrorGroup(): CartErrorGroup;
259
- /** Creates an empty {@link CartErrorState} — all timestamps at `0`, all buckets empty. */
292
+ /**
293
+ * Creates a cart error state with no errors and every timestamp at `0`.
294
+ *
295
+ * Each call returns new groups, maps, and arrays.
296
+ *
297
+ * @returns A new, empty error state.
298
+ * @publicDocs
299
+ */
260
300
  declare function createEmptyCartErrors(): CartErrorState;
261
301
  /**
262
- * Frozen {@link CartData} representing an empty cart — `id: null`, zero quantities,
263
- * zero-amount costs. Used as the initial/fallback value before the first server response.
302
+ * Frozen cart data for an empty cart, with a `null` ID, zero quantities, and
303
+ * zero-amount costs. A cart store without initial data starts from this cart.
304
+ *
305
+ * @publicDocs
264
306
  */
265
307
  declare const EMPTY_CART_DATA: CartData;
266
- /** Shared empty {@link CartState} — backed by {@link EMPTY_CART_DATA}, defaults to `loading: true`. */
308
+ /**
309
+ * Shared empty cart state backed by the empty cart data, with loading set to `true`.
310
+ *
311
+ * @publicDocs
312
+ */
267
313
  declare const EMPTY_CART_STATE: CartState;
268
314
  //#endregion
269
315
  export { Attribute, CartCost, CartData, CartErrorGroup, CartErrorState, CartLine, CartLineConnection, CartLineCost, CartLineMerchandise, CartNetworkEntry, CartPending, CartState, CartUserError, CartWarning, DiscountCode, EMPTY_CART_DATA, EMPTY_CART_STATE, createEmptyCartErrors, createEmptyErrorGroup };
@@ -8,14 +8,26 @@ function createEmptyPending() {
8
8
  cost: false
9
9
  };
10
10
  }
11
- /** Creates an empty {@link CartErrorGroup} — no user errors, no warnings. */
11
+ /**
12
+ * Creates an empty error group with no user errors and no warnings.
13
+ *
14
+ * @returns A new error group with empty user error and warning arrays.
15
+ * @publicDocs
16
+ */
12
17
  function createEmptyErrorGroup() {
13
18
  return {
14
19
  userErrors: [],
15
20
  warnings: []
16
21
  };
17
22
  }
18
- /** Creates an empty {@link CartErrorState} — all timestamps at `0`, all buckets empty. */
23
+ /**
24
+ * Creates a cart error state with no errors and every timestamp at `0`.
25
+ *
26
+ * Each call returns new groups, maps, and arrays.
27
+ *
28
+ * @returns A new, empty error state.
29
+ * @publicDocs
30
+ */
19
31
  function createEmptyCartErrors() {
20
32
  return {
21
33
  cart: createEmptyErrorGroup(),
@@ -34,8 +46,10 @@ function createEmptyCartErrors() {
34
46
  };
35
47
  }
36
48
  /**
37
- * Frozen {@link CartData} representing an empty cart — `id: null`, zero quantities,
38
- * zero-amount costs. Used as the initial/fallback value before the first server response.
49
+ * Frozen cart data for an empty cart, with a `null` ID, zero quantities, and
50
+ * zero-amount costs. A cart store without initial data starts from this cart.
51
+ *
52
+ * @publicDocs
39
53
  */
40
54
  const EMPTY_CART_DATA = Object.freeze({
41
55
  id: null,
@@ -68,7 +82,7 @@ function createCartState(data, { loading = false } = {}) {
68
82
  errors: createEmptyCartErrors()
69
83
  };
70
84
  }
71
- /** Creates an empty {@link CartState} backed by {@link EMPTY_CART_DATA}. Defaults to `loading: true`. */
85
+ /** Creates an empty cart state backed by the empty cart data. Loading defaults to `true`. */
72
86
  function createEmptyCartState({ loading = true } = {}) {
73
87
  return createCartState({
74
88
  ...EMPTY_CART_DATA,
@@ -76,7 +90,11 @@ function createEmptyCartState({ loading = true } = {}) {
76
90
  discountCodes: []
77
91
  }, { loading });
78
92
  }
79
- /** Shared empty {@link CartState} — backed by {@link EMPTY_CART_DATA}, defaults to `loading: true`. */
93
+ /**
94
+ * Shared empty cart state backed by the empty cart data, with loading set to `true`.
95
+ *
96
+ * @publicDocs
97
+ */
80
98
  const EMPTY_CART_STATE = createEmptyCartState();
81
99
 
82
100
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/core/cart/state.ts"],"sourcesContent":["import type { CartErrorCode, CartWarningCode } from \"../../graphql/generated/storefront-api-types\";\n\n/** Storefront API monetary value — an amount string and ISO 4217 currency code. */\nexport interface Money {\n /** Decimal amount as a string (e.g. `\"29.99\"`). */\n amount: string;\n /** ISO 4217 currency code (e.g. `\"USD\"`, `\"EUR\"`). */\n currencyCode: string;\n}\n\n/** Cart-level cost breakdown returned by the Storefront API. */\nexport interface CartCost {\n /** The amount, before taxes and cart-level discounts, for the customer to pay. */\n subtotalAmount: Money;\n /** Final amount the buyer pays at checkout. */\n totalAmount: Money;\n /** Estimated amount due at checkout, excluding deferred payments. Equals the subtotal when no deferred payments exist. */\n checkoutChargeAmount: Money;\n}\n\nexport interface CartLineCost {\n /** Line total after all applicable discounts. */\n totalAmount: Money;\n /** Line subtotal before line-level discounts. */\n subtotalAmount: Money;\n /** Unit price for a single quantity of this line. */\n amountPerQuantity: Money;\n /** Original compare-at unit price, or `null` when no comparison exists. */\n compareAtAmountPerQuantity: Money | null;\n}\n\n/** Product variant information attached to a {@link CartLine}. */\nexport interface CartLineMerchandise {\n /** Storefront API GID of the product variant. */\n id: string;\n /** Variant title (e.g. `\"Small / Black\"`). */\n title?: string;\n /** Selected variant option name/value pairs (e.g. `{ name: \"Size\", value: \"S\" }`). */\n selectedOptions?: Array<{ name: string; value: string }>;\n product: {\n title: string;\n handle?: string;\n [key: string]: unknown;\n };\n image?: {\n id?: string | null;\n url: string;\n altText?: string | null;\n width?: number | null;\n height?: number | null;\n [key: string]: unknown;\n } | null;\n quantityAvailable?: number | null;\n [key: string]: unknown;\n}\n\n/**\n * A single line item in the cart.\n *\n * Each line represents a product variant at a given quantity. Lines may carry\n * custom {@link Attribute | attributes}, a selling plan allocation (subscriptions),\n * or nested {@link CartLine.lineComponents | line components} (bundles).\n */\nexport interface CartLine {\n /** Storefront API GID of this cart line — used as the key in {@link CartPending.lines}. */\n id: string;\n /** Number of units of this merchandise in the cart. */\n quantity: number;\n attributes?: Attribute[];\n /** Per-line cost breakdown from the Storefront API. */\n cost: CartLineCost;\n /** The product variant this line represents. */\n merchandise?: CartLineMerchandise;\n /** Subscription selling plan allocation, or `null` for one-time purchases. */\n sellingPlanAllocation?: { sellingPlan: { id: string } } | null;\n parentRelationship?: { parent: { id: string } } | null;\n /** Nested child lines when this line is a bundle parent. */\n lineComponents?: CartLine[];\n}\n\nexport interface CartLineConnection {\n nodes: CartLine[];\n [key: string]: unknown;\n}\n\n/** A discount code applied to the cart. */\nexport interface DiscountCode {\n code: string;\n /** Whether the code is applicable to the cart's current contents. Set optimistically to `false` for newly added codes until the server confirms. */\n applicable: boolean;\n}\n\n/** A validation error returned by a Storefront API cart mutation. */\nexport interface CartUserError {\n /** Machine-readable error code, or `null` for unclassified errors. */\n code: CartErrorCode | null;\n message: string;\n /** JSONPath to the input field that caused the error (e.g. `[\"lines\", \"0\", \"quantity\"]`). */\n field?: string[];\n}\n\n/** A non-blocking warning returned by a Storefront API cart mutation. */\nexport interface CartWarning {\n code: CartWarningCode;\n message: string;\n}\n\n/** Errors and warnings from a single cart mutation response. */\nexport interface CartErrorGroup {\n userErrors: CartUserError[];\n warnings: CartWarning[];\n}\n\n/** A network-level error encountered during a cart operation (e.g. non-2xx response, timeout). Aborted requests are not recorded. */\nexport interface CartNetworkEntry {\n message: string;\n /** HTTP status code when available. */\n status?: number;\n}\n\n/** A key-value pair attached to the cart or to an individual {@link CartLine}. */\nexport interface Attribute {\n key: string;\n value: string | null;\n}\n\n/**\n * Tracks which parts of the cart have in-flight mutations.\n *\n * `lines` and `discountCodes` are `Set<string>` keyed by line ID / discount code,\n * enabling per-item pending indicators rather than a single global spinner.\n * `cost` is a boolean because *any* line or discount change affects the total —\n * use it to show pending UI on price displays without computing optimistic amounts.\n *\n * @example\n * ```ts\n * const { pending } = store.getState();\n *\n * // Per-line-item pending indicator\n * if (pending.lines.has(lineId)) {\n * showSpinner(lineId);\n * }\n *\n * // Cart total is stale — show pending UI, don't compute a price\n * if (pending.cost) {\n * dimTotalDisplay();\n * }\n * ```\n */\nexport interface CartPending {\n /** Line IDs with in-flight add, quantity, or remove mutations. New lines use their `optimistic:` ID until the server confirms. */\n lines: Set<string>;\n note: boolean;\n attributes: boolean;\n /** Discount codes with in-flight apply/remove mutations. */\n discountCodes: Set<string>;\n /** `true` when any mutation may affect cart pricing — show pending UI on cost displays. */\n cost?: boolean;\n}\n\n/**\n * Per-resource error tracking for the cart.\n *\n * Errors are bucketed by the resource they affect — `lines`, `note`, `attributes`,\n * `discountCodes`, or `cart` (for cross-cutting errors). Each bucket carries a\n * `*UpdatedAt` timestamp (ms since epoch) so the UI can show stale-error indicators\n * or auto-dismiss after a timeout.\n *\n * `network` collects transport-level failures (timeouts, 5xx) separately from\n * Storefront API user errors.\n */\nexport interface CartErrorState {\n /** Cross-cutting cart errors not attributable to a specific resource. */\n cart: CartErrorGroup;\n /** Errors keyed by {@link CartLine.id}. */\n lines: Map<string, CartErrorGroup>;\n note: CartErrorGroup;\n /** Errors keyed by {@link Attribute.key}. */\n attributes: Map<string, CartErrorGroup>;\n /** Errors keyed by discount code string. */\n discountCodes: Map<string, CartErrorGroup>;\n network: CartNetworkEntry[];\n lastUpdatedAt: number;\n cartUpdatedAt: number;\n linesUpdatedAt: number;\n noteUpdatedAt: number;\n attributesUpdatedAt: number;\n discountCodesUpdatedAt: number;\n networkUpdatedAt: number;\n}\n\n/**\n * Cart data returned by the Storefront API.\n *\n * This is the server's authoritative snapshot — prices, discount applicability,\n * and totals come exclusively from here, never from client-side computation.\n * The index signature allows custom cart query fields to pass through.\n */\nexport interface CartData {\n /** Storefront API Cart GID, or `null` when no cart exists yet. */\n id: string | null;\n /** `Cart.updatedAt` (ISO 8601). Absent until the first server response. */\n updatedAt?: string;\n /** Shopify checkout URL. Changes when buyer identity or consent state changes. */\n checkoutUrl?: string | null;\n /** Sum of all line quantities. */\n totalQuantity: number;\n /** Cart-level cost breakdown (subtotal, total, checkout charge). */\n cost: CartCost;\n /** Buyer-supplied cart note, or `null`/empty when unset. */\n note?: string | null;\n /** Cart-level custom attributes. */\n attributes: Attribute[];\n /** The cart's line items. */\n lines: CartLineConnection;\n /** Discount codes applied to the cart, with their applicability. */\n discountCodes: DiscountCode[];\n [key: string]: unknown;\n}\n\n/**\n * Full observable state of the cart store.\n *\n * Framework adapters subscribe to this via `CartStore.subscribe` (or the\n * framework-specific hooks like `useCart`). The generic `TData` parameter\n * flows from your server handler configuration, so `data` is typed to match\n * your custom cart query.\n *\n * @example\n * ```ts\n * const state = store.getState();\n *\n * if (state.loading) {\n * // Initial cart load in progress — show skeleton\n * }\n *\n * if (state.pending.lines.size > 0) {\n * // One or more lines are mid-mutation — show per-line spinners\n * }\n *\n * if (state.errors.network.length > 0) {\n * // Network errors occurred — show retry prompt\n * }\n * ```\n */\nexport interface CartState<TData extends CartData = CartData> {\n /** The latest server-confirmed cart data, with optimistic projections applied on top. */\n data: TData;\n /** `true` during a full-cart fetch — initial load, after `reset()`, or before connect with no `initialData`. */\n loading: boolean;\n /** Non-rejecting signal that resolves when the current full-cart load settles or is invalidated. */\n readonly readyPromise?: PromiseLike<void>;\n /** Per-resource in-flight mutation tracking. */\n pending: CartPending;\n /** `true` when a background revalidation is in flight (triggered by overlapping mutations or `refresh()`). */\n revalidating?: boolean;\n /** Per-resource error and warning state. */\n errors: CartErrorState;\n}\n\nexport function createEmptyPending(): CartPending {\n return {\n lines: new Set(),\n note: false,\n attributes: false,\n discountCodes: new Set(),\n cost: false,\n };\n}\n\n/** Creates an empty {@link CartErrorGroup} — no user errors, no warnings. */\nexport function createEmptyErrorGroup(): CartErrorGroup {\n return { userErrors: [], warnings: [] };\n}\n\n/** Creates an empty {@link CartErrorState} — all timestamps at `0`, all buckets empty. */\nexport function createEmptyCartErrors(): CartErrorState {\n return {\n cart: createEmptyErrorGroup(),\n lines: new Map(),\n note: createEmptyErrorGroup(),\n attributes: new Map(),\n discountCodes: new Map(),\n network: [],\n lastUpdatedAt: 0,\n cartUpdatedAt: 0,\n linesUpdatedAt: 0,\n noteUpdatedAt: 0,\n attributesUpdatedAt: 0,\n discountCodesUpdatedAt: 0,\n networkUpdatedAt: 0,\n };\n}\n\n/**\n * Frozen {@link CartData} representing an empty cart — `id: null`, zero quantities,\n * zero-amount costs. Used as the initial/fallback value before the first server response.\n */\nexport const EMPTY_CART_DATA: CartData = Object.freeze({\n id: null,\n checkoutUrl: null,\n totalQuantity: 0,\n cost: Object.freeze({\n subtotalAmount: Object.freeze({ amount: \"0\", currencyCode: \"\" }),\n totalAmount: Object.freeze({ amount: \"0\", currencyCode: \"\" }),\n checkoutChargeAmount: Object.freeze({ amount: \"0\", currencyCode: \"\" }),\n }),\n note: \"\",\n attributes: [] as Attribute[],\n lines: Object.freeze({ nodes: [] as CartLine[] }),\n discountCodes: [] as DiscountCode[],\n});\n\nexport function createCartState<TData extends CartData>(\n data: TData,\n { loading = false }: { loading?: boolean } = {},\n): CartState<TData> {\n return {\n data,\n loading,\n pending: createEmptyPending(),\n errors: createEmptyCartErrors(),\n };\n}\n\n/** Creates an empty {@link CartState} backed by {@link EMPTY_CART_DATA}. Defaults to `loading: true`. */\nexport function createEmptyCartState({ loading = true }: { loading?: boolean } = {}): CartState {\n return createCartState(\n {\n ...EMPTY_CART_DATA,\n lines: { nodes: [] },\n discountCodes: [],\n },\n { loading },\n );\n}\n\n/** Shared empty {@link CartState} — backed by {@link EMPTY_CART_DATA}, defaults to `loading: true`. */\nexport const EMPTY_CART_STATE: CartState = createEmptyCartState();\n"],"mappings":";AAoQA,SAAgB,qBAAkC;AAChD,QAAO;EACL,uBAAO,IAAI,KAAK;EAChB,MAAM;EACN,YAAY;EACZ,+BAAe,IAAI,KAAK;EACxB,MAAM;EACP;;;AAIH,SAAgB,wBAAwC;AACtD,QAAO;EAAE,YAAY,EAAE;EAAE,UAAU,EAAE;EAAE;;;AAIzC,SAAgB,wBAAwC;AACtD,QAAO;EACL,MAAM,uBAAuB;EAC7B,uBAAO,IAAI,KAAK;EAChB,MAAM,uBAAuB;EAC7B,4BAAY,IAAI,KAAK;EACrB,+BAAe,IAAI,KAAK;EACxB,SAAS,EAAE;EACX,eAAe;EACf,eAAe;EACf,gBAAgB;EAChB,eAAe;EACf,qBAAqB;EACrB,wBAAwB;EACxB,kBAAkB;EACnB;;;;;;AAOH,MAAa,kBAA4B,OAAO,OAAO;CACrD,IAAI;CACJ,aAAa;CACb,eAAe;CACf,MAAM,OAAO,OAAO;EAClB,gBAAgB,OAAO,OAAO;GAAE,QAAQ;GAAK,cAAc;GAAI,CAAC;EAChE,aAAa,OAAO,OAAO;GAAE,QAAQ;GAAK,cAAc;GAAI,CAAC;EAC7D,sBAAsB,OAAO,OAAO;GAAE,QAAQ;GAAK,cAAc;GAAI,CAAC;EACvE,CAAC;CACF,MAAM;CACN,YAAY,EAAE;CACd,OAAO,OAAO,OAAO,EAAE,OAAO,EAAE,EAAgB,CAAC;CACjD,eAAe,EAAE;CAClB,CAAC;AAEF,SAAgB,gBACd,MACA,EAAE,UAAU,UAAiC,EAAE,EAC7B;AAClB,QAAO;EACL;EACA;EACA,SAAS,oBAAoB;EAC7B,QAAQ,uBAAuB;EAChC;;;AAIH,SAAgB,qBAAqB,EAAE,UAAU,SAAgC,EAAE,EAAa;AAC9F,QAAO,gBACL;EACE,GAAG;EACH,OAAO,EAAE,OAAO,EAAE,EAAE;EACpB,eAAe,EAAE;EAClB,EACD,EAAE,SAAS,CACZ;;;AAIH,MAAa,mBAA8B,sBAAsB"}
1
+ {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/core/cart/state.ts"],"sourcesContent":["import type { CartErrorCode, CartWarningCode } from \"../../graphql/generated/storefront-api-types\";\n\n/** A monetary value from the Storefront API. */\nexport interface Money {\n /** The decimal amount as a string, such as `29.99`. */\n amount: string;\n /** The ISO 4217 currency code, such as `USD`. */\n currencyCode: string;\n}\n\n/** The cart's costs from the Storefront API. */\nexport interface CartCost {\n /** The amount, before taxes and cart-level discounts, for the customer to pay. */\n subtotalAmount: Money;\n /** Final amount the customer pays at checkout. */\n totalAmount: Money;\n /** Estimated amount due at checkout, excluding deferred payments. Equals the subtotal when no deferred payments exist. */\n checkoutChargeAmount: Money;\n}\n\n/** A cart line's costs from the Storefront API. */\nexport interface CartLineCost {\n /** Line total after all applicable discounts. */\n totalAmount: Money;\n /** Line subtotal before line-level discounts. */\n subtotalAmount: Money;\n /** Unit price for a single quantity of this line. */\n amountPerQuantity: Money;\n /** Original compare-at unit price, or `null` when no comparison exists. */\n compareAtAmountPerQuantity: Money | null;\n}\n\n/** The product variant on a cart line. */\nexport interface CartLineMerchandise {\n /** Storefront API GID of the product variant. */\n id: string;\n /** The variant title, such as `\"Small / Black\"`. */\n title?: string;\n /** The variant's selected options as name and value pairs. */\n selectedOptions?: Array<{ name: string; value: string }>;\n /** The product that the variant belongs to. */\n product: {\n title: string;\n handle?: string;\n [key: string]: unknown;\n };\n /** The variant image that the cart query selects. */\n image?: {\n id?: string | null;\n url: string;\n altText?: string | null;\n width?: number | null;\n height?: number | null;\n [key: string]: unknown;\n } | null;\n /** Units available for sale. When your cart fragment selects the field, the store caps the quantity of a `set` submission at this number. */\n quantityAvailable?: number | null;\n /** Extra variant fields from your custom cart fragment, unchanged. */\n [key: string]: unknown;\n}\n\n/**\n * A single line item in the cart.\n *\n * Each line holds a product variant at a quantity. A line can carry custom\n * attributes, a selling plan allocation for a subscription, or line components\n * for a bundle.\n */\nexport interface CartLine {\n /** The cart line's Storefront API GID. Look up the line's pending state and errors with this ID. */\n id: string;\n /** Number of units of this merchandise in the cart. */\n quantity: number;\n /** Custom key-value attributes attached to the line. */\n attributes?: Attribute[];\n /** Per-line cost breakdown from the Storefront API. */\n cost: CartLineCost;\n /** The product variant on the line. */\n merchandise?: CartLineMerchandise;\n /** Subscription selling plan allocation, or `null` for one-time purchases. */\n sellingPlanAllocation?: { sellingPlan: { id: string } } | null;\n /** The parent line's ID when this line is a bundle component. */\n parentRelationship?: { parent: { id: string } } | null;\n /** Nested child lines when this line is a bundle parent. */\n lineComponents?: CartLine[];\n}\n\n/** The cart's line items in the Storefront API connection shape. */\nexport interface CartLineConnection {\n /** The cart lines that the cart query returns. */\n nodes: CartLine[];\n /** Extra connection fields from your custom cart fragment, unchanged. */\n [key: string]: unknown;\n}\n\n/** A discount code applied to the cart. */\nexport interface DiscountCode {\n /** The discount code text. Look up the code's pending state and errors with this value. */\n code: string;\n /** Whether the code applies to the cart's current contents. A new code reads `false` until the server responds. */\n applicable: boolean;\n}\n\n/** A validation error returned by a Storefront API cart mutation. */\nexport interface CartUserError {\n /** Machine-readable error code, or `null` for unclassified errors. */\n code: CartErrorCode | null;\n /** Human-readable error text from the Storefront API. */\n message: string;\n /** The path to the input field that caused the error, such as `[\"lines\", \"0\", \"quantity\"]`. */\n field?: string[];\n}\n\n/** A non-blocking warning returned by a Storefront API cart mutation. */\nexport interface CartWarning {\n /** The warning code from the Storefront API. */\n code: CartWarningCode;\n /** Human-readable warning text from the Storefront API. */\n message: string;\n}\n\n/** Errors and warnings from one cart change. */\nexport interface CartErrorGroup {\n /** Validation errors that the mutation returned. */\n userErrors: CartUserError[];\n /** Non-blocking warnings that the mutation returned. */\n warnings: CartWarning[];\n}\n\n/**\n * A failed cart request, such as a non-2xx response or a timeout. Canceled requests add no entry.\n */\nexport interface CartNetworkEntry {\n /** The error message, or a generic message when the failure has no message of its own. */\n message: string;\n /** The HTTP status code, when the endpoint returned a non-2xx response. */\n status?: number;\n}\n\n/** A key-value pair attached to the cart or to an individual cart line. */\nexport interface Attribute {\n /** The attribute name. Look up the attribute's errors with this name. */\n key: string;\n /** The attribute value. */\n value: string | null;\n}\n\n/**\n * Shows which parts of the cart have changes in flight.\n *\n * Check a line ID or a discount code to show a pending indicator on that item.\n * Check `cost` to show pending UI on prices, which update only when the server\n * responds.\n *\n * @example\n * ```ts\n * const { pending } = store.getState();\n *\n * // Per-line-item pending indicator\n * if (pending.lines.has(lineId)) {\n * showSpinner(lineId);\n * }\n *\n * // Cart total is stale — show pending UI, don't compute a price\n * if (pending.cost) {\n * dimTotalDisplay();\n * }\n * ```\n */\nexport interface CartPending {\n /** Line IDs with an add, quantity change, or removal in flight. A new line has an ID that starts with `optimistic:` until the server confirms the line. */\n lines: Set<string>;\n /** `true` while a note update is in flight. */\n note: boolean;\n /** `true` while an attribute update is in flight. */\n attributes: boolean;\n /** Discount codes with an apply or remove in flight. */\n discountCodes: Set<string>;\n /** `true` while a change that can affect cart prices is in flight. */\n cost?: boolean;\n}\n\n/**\n * The cart's errors, grouped by the part of the cart that they affect: lines, the note,\n * attributes, discount codes, or the cart as a whole. Each group has a timestamp in\n * milliseconds since the epoch. Use the timestamps to flag stale errors or dismiss\n * errors after a timeout.\n *\n * Failed requests go in a network list, apart from Storefront API user errors.\n */\nexport interface CartErrorState {\n /** Errors that don't belong to a line, the note, an attribute, or a discount code. */\n cart: CartErrorGroup;\n /** Errors keyed by cart line ID. */\n lines: Map<string, CartErrorGroup>;\n /** Errors for the cart note. */\n note: CartErrorGroup;\n /** Errors keyed by attribute name. */\n attributes: Map<string, CartErrorGroup>;\n /** Errors keyed by discount code. */\n discountCodes: Map<string, CartErrorGroup>;\n /**\n * Failed cart requests. A failed cart change adds an entry, with an HTTP status when the endpoint returned a non-2xx response. A failed refresh adds an entry with a generic message and no status. A failed first load or a failed load after a reset adds no entry.\n */\n network: CartNetworkEntry[];\n /** Time in milliseconds since the epoch when the store last recorded any error, or `0` before the first. */\n lastUpdatedAt: number;\n /** Time in milliseconds since the epoch of the last line, discount code, or attribute error, or `0` before any. */\n cartUpdatedAt: number;\n /** Time in milliseconds since the epoch when the store last recorded line errors, or `0` before any. */\n linesUpdatedAt: number;\n /** Time in milliseconds since the epoch when the store last recorded note errors, or `0` before any. */\n noteUpdatedAt: number;\n /** Time in milliseconds since the epoch when the store last recorded attribute errors, or `0` before any. */\n attributesUpdatedAt: number;\n /** Time in milliseconds since the epoch when the store last recorded discount code errors, or `0` before any. */\n discountCodesUpdatedAt: number;\n /** Time in milliseconds since the epoch when the store last recorded a network error, or `0` before any. */\n networkUpdatedAt: number;\n}\n\n/**\n * The customer's cart, in the shape that the Storefront API returns.\n *\n * Cart costs come only from the server. Extra fields from your custom cart\n * fragment appear unchanged.\n */\nexport interface CartData {\n /** The cart's Storefront API GID, or `null` when no cart exists yet. */\n id: string | null;\n /** The cart's last update time in ISO 8601 format. Absent until the first server response. */\n updatedAt?: string;\n /** The Shopify checkout URL. The URL can change when the customer logs in or out, or changes tracking consent. */\n checkoutUrl?: string | null;\n /** Sum of all line quantities. */\n totalQuantity: number;\n /** The cart's subtotal, total, and checkout charge. */\n cost: CartCost;\n /** Customer-supplied cart note, or `null` or empty when unset. */\n note?: string | null;\n /** Cart-level custom attributes. */\n attributes: Attribute[];\n /** The cart's line items. */\n lines: CartLineConnection;\n /** Discount codes applied to the cart, with their applicability. */\n discountCodes: DiscountCode[];\n /** Extra cart fields from your custom cart fragment, unchanged. */\n [key: string]: unknown;\n}\n\n/**\n * The cart, plus what's loading, pending, and failed.\n *\n * The cart hooks return values from this state. The data type matches the cart\n * fragment in your cart server handlers.\n *\n * @example\n * ```ts\n * const state = store.getState();\n *\n * if (state.loading) {\n * // Initial cart load in progress — show skeleton\n * }\n *\n * if (state.pending.lines.size > 0) {\n * // One or more lines are mid-mutation — show per-line spinners\n * }\n *\n * if (state.errors.network.length > 0) {\n * // Network errors occurred — show retry prompt\n * }\n * ```\n */\nexport interface CartState<TData extends CartData = CartData> {\n /** The cart, including changes that the server hasn't confirmed yet. */\n data: TData;\n /** `true` while the store loads the full cart: the first load, a load after `reset()`, or before `connect()` when the store has no initial data. */\n loading: boolean;\n /** Present while a full cart load runs. The promise resolves, and never rejects, when the load finishes or the store drops the load. */\n readonly readyPromise?: PromiseLike<void>;\n /** The parts of the cart with changes in flight. */\n pending: CartPending;\n /** `true` while the store reloads the cart in the background after overlapping cart changes or a `refresh()` call. */\n revalidating?: boolean;\n /** Errors and warnings, grouped by the part of the cart that they affect. */\n errors: CartErrorState;\n}\n\nexport function createEmptyPending(): CartPending {\n return {\n lines: new Set(),\n note: false,\n attributes: false,\n discountCodes: new Set(),\n cost: false,\n };\n}\n\n/**\n * Creates an empty error group with no user errors and no warnings.\n *\n * @returns A new error group with empty user error and warning arrays.\n * @publicDocs\n */\nexport function createEmptyErrorGroup(): CartErrorGroup {\n return { userErrors: [], warnings: [] };\n}\n\n/**\n * Creates a cart error state with no errors and every timestamp at `0`.\n *\n * Each call returns new groups, maps, and arrays.\n *\n * @returns A new, empty error state.\n * @publicDocs\n */\nexport function createEmptyCartErrors(): CartErrorState {\n return {\n cart: createEmptyErrorGroup(),\n lines: new Map(),\n note: createEmptyErrorGroup(),\n attributes: new Map(),\n discountCodes: new Map(),\n network: [],\n lastUpdatedAt: 0,\n cartUpdatedAt: 0,\n linesUpdatedAt: 0,\n noteUpdatedAt: 0,\n attributesUpdatedAt: 0,\n discountCodesUpdatedAt: 0,\n networkUpdatedAt: 0,\n };\n}\n\n/**\n * Frozen cart data for an empty cart, with a `null` ID, zero quantities, and\n * zero-amount costs. A cart store without initial data starts from this cart.\n *\n * @publicDocs\n */\nexport const EMPTY_CART_DATA: CartData = Object.freeze({\n id: null,\n checkoutUrl: null,\n totalQuantity: 0,\n cost: Object.freeze({\n subtotalAmount: Object.freeze({ amount: \"0\", currencyCode: \"\" }),\n totalAmount: Object.freeze({ amount: \"0\", currencyCode: \"\" }),\n checkoutChargeAmount: Object.freeze({ amount: \"0\", currencyCode: \"\" }),\n }),\n note: \"\",\n attributes: [] as Attribute[],\n lines: Object.freeze({ nodes: [] as CartLine[] }),\n discountCodes: [] as DiscountCode[],\n});\n\nexport function createCartState<TData extends CartData>(\n data: TData,\n { loading = false }: { loading?: boolean } = {},\n): CartState<TData> {\n return {\n data,\n loading,\n pending: createEmptyPending(),\n errors: createEmptyCartErrors(),\n };\n}\n\n/** Creates an empty cart state backed by the empty cart data. Loading defaults to `true`. */\nexport function createEmptyCartState({ loading = true }: { loading?: boolean } = {}): CartState {\n return createCartState(\n {\n ...EMPTY_CART_DATA,\n lines: { nodes: [] },\n discountCodes: [],\n },\n { loading },\n );\n}\n\n/**\n * Shared empty cart state backed by the empty cart data, with loading set to `true`.\n *\n * @publicDocs\n */\nexport const EMPTY_CART_STATE: CartState = createEmptyCartState();\n"],"mappings":";AAgSA,SAAgB,qBAAkC;AAChD,QAAO;EACL,uBAAO,IAAI,KAAK;EAChB,MAAM;EACN,YAAY;EACZ,+BAAe,IAAI,KAAK;EACxB,MAAM;EACP;;;;;;;;AASH,SAAgB,wBAAwC;AACtD,QAAO;EAAE,YAAY,EAAE;EAAE,UAAU,EAAE;EAAE;;;;;;;;;;AAWzC,SAAgB,wBAAwC;AACtD,QAAO;EACL,MAAM,uBAAuB;EAC7B,uBAAO,IAAI,KAAK;EAChB,MAAM,uBAAuB;EAC7B,4BAAY,IAAI,KAAK;EACrB,+BAAe,IAAI,KAAK;EACxB,SAAS,EAAE;EACX,eAAe;EACf,eAAe;EACf,gBAAgB;EAChB,eAAe;EACf,qBAAqB;EACrB,wBAAwB;EACxB,kBAAkB;EACnB;;;;;;;;AASH,MAAa,kBAA4B,OAAO,OAAO;CACrD,IAAI;CACJ,aAAa;CACb,eAAe;CACf,MAAM,OAAO,OAAO;EAClB,gBAAgB,OAAO,OAAO;GAAE,QAAQ;GAAK,cAAc;GAAI,CAAC;EAChE,aAAa,OAAO,OAAO;GAAE,QAAQ;GAAK,cAAc;GAAI,CAAC;EAC7D,sBAAsB,OAAO,OAAO;GAAE,QAAQ;GAAK,cAAc;GAAI,CAAC;EACvE,CAAC;CACF,MAAM;CACN,YAAY,EAAE;CACd,OAAO,OAAO,OAAO,EAAE,OAAO,EAAE,EAAgB,CAAC;CACjD,eAAe,EAAE;CAClB,CAAC;AAEF,SAAgB,gBACd,MACA,EAAE,UAAU,UAAiC,EAAE,EAC7B;AAClB,QAAO;EACL;EACA;EACA,SAAS,oBAAoB;EAC7B,QAAQ,uBAAuB;EAChC;;;AAIH,SAAgB,qBAAqB,EAAE,UAAU,SAAgC,EAAE,EAAa;AAC9F,QAAO,gBACL;EACE,GAAG;EACH,OAAO,EAAE,OAAO,EAAE,EAAE;EACpB,eAAe,EAAE;EAClB,EACD,EAAE,SAAS,CACZ;;;;;;;AAQH,MAAa,mBAA8B,sBAAsB"}