@shopify/hydrogen 2026.4.4 → 2026.10.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (754) hide show
  1. package/README.md +73 -13
  2. package/bin/hydrogen.mjs +7 -0
  3. package/dist/cli/index.mjs +330 -0
  4. package/dist/client/client.d.mts +34 -0
  5. package/dist/client/client.mjs +193 -0
  6. package/dist/client/client.mjs.map +1 -0
  7. package/dist/client/errors.d.mts +48 -0
  8. package/dist/client/errors.mjs +52 -0
  9. package/dist/client/errors.mjs.map +1 -0
  10. package/dist/client/index.d.mts +4 -0
  11. package/dist/client/types.d.mts +147 -0
  12. package/dist/core/analytics/cart-tracker.d.mts +8 -0
  13. package/dist/core/analytics/cart-tracker.mjs +144 -0
  14. package/dist/core/analytics/cart-tracker.mjs.map +1 -0
  15. package/dist/core/analytics/events.d.mts +15 -0
  16. package/dist/core/analytics/events.mjs +15 -0
  17. package/dist/core/analytics/events.mjs.map +1 -0
  18. package/dist/core/analytics/index.d.mts +3 -0
  19. package/dist/core/analytics/types.d.mts +143 -0
  20. package/dist/core/analytics/utils/flatten-connection.d.mts +19 -0
  21. package/dist/core/analytics/utils/flatten-connection.mjs +25 -0
  22. package/dist/core/analytics/utils/flatten-connection.mjs.map +1 -0
  23. package/dist/core/cache/cache-status.mjs +17 -0
  24. package/dist/core/cache/cache-status.mjs.map +1 -0
  25. package/dist/core/cache/fetch-with-cache.d.mts +43 -0
  26. package/dist/core/cache/fetch-with-cache.mjs +188 -0
  27. package/dist/core/cache/fetch-with-cache.mjs.map +1 -0
  28. package/dist/core/cache/key.d.mts +6 -0
  29. package/dist/core/cache/key.mjs +27 -0
  30. package/dist/core/cache/key.mjs.map +1 -0
  31. package/dist/core/cache/run-with-cache.d.mts +36 -0
  32. package/dist/core/cache/run-with-cache.mjs +114 -0
  33. package/dist/core/cache/run-with-cache.mjs.map +1 -0
  34. package/dist/core/cache/store.d.mts +19 -0
  35. package/dist/core/cache/store.mjs +62 -0
  36. package/dist/core/cache/store.mjs.map +1 -0
  37. package/dist/core/cache/strategies.d.mts +39 -0
  38. package/dist/core/cache/strategies.mjs +70 -0
  39. package/dist/core/cache/strategies.mjs.map +1 -0
  40. package/dist/core/cart/actions.d.mts +50 -0
  41. package/dist/core/cart/actions.mjs +240 -0
  42. package/dist/core/cart/actions.mjs.map +1 -0
  43. package/dist/core/cart/attach-quantity-input.d.mts +5 -0
  44. package/dist/core/cart/attach-quantity-input.mjs +17 -0
  45. package/dist/core/cart/attach-quantity-input.mjs.map +1 -0
  46. package/dist/core/cart/buyer-identity-sync.d.mts +23 -0
  47. package/dist/core/cart/buyer-identity-sync.mjs +9 -0
  48. package/dist/core/cart/buyer-identity-sync.mjs.map +1 -0
  49. package/dist/core/cart/cart.d.mts +32 -0
  50. package/dist/core/cart/cart.mjs +1687 -0
  51. package/dist/core/cart/cart.mjs.map +1 -0
  52. package/dist/core/cart/cookie.d.mts +5 -0
  53. package/dist/core/cart/cookie.mjs +28 -0
  54. package/dist/core/cart/cookie.mjs.map +1 -0
  55. package/dist/core/cart/form.d.mts +130 -0
  56. package/dist/core/cart/form.mjs +75 -0
  57. package/dist/core/cart/form.mjs.map +1 -0
  58. package/dist/core/cart/get-cart.d.mts +25 -0
  59. package/dist/core/cart/get-cart.mjs +32 -0
  60. package/dist/core/cart/get-cart.mjs.map +1 -0
  61. package/dist/core/cart/index.d.mts +10 -0
  62. package/dist/core/cart/quantity.d.mts +10 -0
  63. package/dist/core/cart/quantity.mjs +14 -0
  64. package/dist/core/cart/quantity.mjs.map +1 -0
  65. package/dist/core/cart/queries.d.mts +4296 -0
  66. package/dist/core/cart/queries.mjs +70 -0
  67. package/dist/core/cart/queries.mjs.map +1 -0
  68. package/dist/core/cart/server-handlers.d.mts +82 -0
  69. package/dist/core/cart/server-handlers.mjs +322 -0
  70. package/dist/core/cart/server-handlers.mjs.map +1 -0
  71. package/dist/core/cart/state.d.mts +137 -0
  72. package/dist/core/cart/state.mjs +76 -0
  73. package/dist/core/cart/state.mjs.map +1 -0
  74. package/dist/core/cart/sync-quantity-inputs.mjs +16 -0
  75. package/dist/core/cart/sync-quantity-inputs.mjs.map +1 -0
  76. package/dist/core/collection/collection.d.mts +134 -0
  77. package/dist/core/collection/collection.mjs +170 -0
  78. package/dist/core/collection/collection.mjs.map +1 -0
  79. package/dist/core/collection/index.d.mts +6 -0
  80. package/dist/core/collection/reconciler.d.mts +32 -0
  81. package/dist/core/collection/reconciler.mjs +89 -0
  82. package/dist/core/collection/reconciler.mjs.map +1 -0
  83. package/dist/core/collection/state.d.mts +66 -0
  84. package/dist/core/collection/state.mjs +20 -0
  85. package/dist/core/collection/state.mjs.map +1 -0
  86. package/dist/core/collection/url.d.mts +70 -0
  87. package/dist/core/collection/url.mjs +367 -0
  88. package/dist/core/collection/url.mjs.map +1 -0
  89. package/dist/core/constants.d.mts +5 -0
  90. package/dist/core/constants.mjs +8 -0
  91. package/dist/core/constants.mjs.map +1 -0
  92. package/dist/core/headers.mjs +44 -0
  93. package/dist/core/headers.mjs.map +1 -0
  94. package/dist/core/index.d.mts +55 -0
  95. package/dist/core/index.mjs +44 -0
  96. package/dist/core/logging/logging.d.mts +21 -0
  97. package/dist/core/logging/logging.mjs +99 -0
  98. package/dist/core/logging/logging.mjs.map +1 -0
  99. package/dist/core/logging/types.d.mts +40 -0
  100. package/dist/core/logging/types.mjs +18 -0
  101. package/dist/core/logging/types.mjs.map +1 -0
  102. package/dist/core/money/cache.mjs +25 -0
  103. package/dist/core/money/cache.mjs.map +1 -0
  104. package/dist/core/money/format.d.mts +15 -0
  105. package/dist/core/money/format.mjs +243 -0
  106. package/dist/core/money/format.mjs.map +1 -0
  107. package/dist/core/money/types.d.mts +47 -0
  108. package/dist/core/observable.mjs +46 -0
  109. package/dist/core/observable.mjs.map +1 -0
  110. package/dist/core/predictive-search/constants.d.mts +5 -0
  111. package/dist/core/predictive-search/constants.mjs +6 -0
  112. package/dist/core/predictive-search/constants.mjs.map +1 -0
  113. package/dist/core/predictive-search/form.d.mts +31 -0
  114. package/dist/core/predictive-search/form.mjs +31 -0
  115. package/dist/core/predictive-search/form.mjs.map +1 -0
  116. package/dist/core/predictive-search/index.d.mts +6 -0
  117. package/dist/core/predictive-search/queries.d.mts +118 -0
  118. package/dist/core/predictive-search/queries.mjs +81 -0
  119. package/dist/core/predictive-search/queries.mjs.map +1 -0
  120. package/dist/core/predictive-search/search.d.mts +32 -0
  121. package/dist/core/predictive-search/search.mjs +74 -0
  122. package/dist/core/predictive-search/search.mjs.map +1 -0
  123. package/dist/core/predictive-search/server-handlers.d.mts +36 -0
  124. package/dist/core/predictive-search/server-handlers.mjs +113 -0
  125. package/dist/core/predictive-search/server-handlers.mjs.map +1 -0
  126. package/dist/core/predictive-search/store.d.mts +44 -0
  127. package/dist/core/predictive-search/store.mjs +224 -0
  128. package/dist/core/predictive-search/store.mjs.map +1 -0
  129. package/dist/core/predictive-search/url.d.mts +41 -0
  130. package/dist/core/predictive-search/url.mjs +71 -0
  131. package/dist/core/predictive-search/url.mjs.map +1 -0
  132. package/dist/core/product/form.d.mts +63 -0
  133. package/dist/core/product/form.mjs +44 -0
  134. package/dist/core/product/form.mjs.map +1 -0
  135. package/dist/core/product/index.d.mts +4 -0
  136. package/dist/core/product/options.d.mts +40 -0
  137. package/dist/core/product/options.mjs +291 -0
  138. package/dist/core/product/options.mjs.map +1 -0
  139. package/dist/core/product/product-form.d.mts +72 -0
  140. package/dist/core/product/product-form.mjs +158 -0
  141. package/dist/core/product/product-form.mjs.map +1 -0
  142. package/dist/core/product/state.d.mts +68 -0
  143. package/dist/core/request-context.d.mts +70 -0
  144. package/dist/core/request-context.mjs +120 -0
  145. package/dist/core/request-context.mjs.map +1 -0
  146. package/dist/core/request-routing/handle-shopify-redirects.d.mts +17 -0
  147. package/dist/core/request-routing/handle-shopify-redirects.mjs +31 -0
  148. package/dist/core/request-routing/handle-shopify-redirects.mjs.map +1 -0
  149. package/dist/core/request-routing/handle-shopify-routes.d.mts +14 -0
  150. package/dist/core/request-routing/handle-shopify-routes.mjs +42 -0
  151. package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -0
  152. package/dist/core/request-routing/interceptors/admin-redirect.mjs +12 -0
  153. package/dist/core/request-routing/interceptors/admin-redirect.mjs.map +1 -0
  154. package/dist/core/request-routing/interceptors/agent-proxy.mjs +19 -0
  155. package/dist/core/request-routing/interceptors/agent-proxy.mjs.map +1 -0
  156. package/dist/core/request-routing/interceptors/ajax-api.mjs +16 -0
  157. package/dist/core/request-routing/interceptors/ajax-api.mjs.map +1 -0
  158. package/dist/core/request-routing/interceptors/api-proxy.mjs +20 -0
  159. package/dist/core/request-routing/interceptors/api-proxy.mjs.map +1 -0
  160. package/dist/core/request-routing/interceptors/checkout.mjs +58 -0
  161. package/dist/core/request-routing/interceptors/checkout.mjs.map +1 -0
  162. package/dist/core/request-routing/interceptors/mcp-proxy.mjs +23 -0
  163. package/dist/core/request-routing/interceptors/mcp-proxy.mjs.map +1 -0
  164. package/dist/core/request-routing/interceptors/proxy.mjs +68 -0
  165. package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -0
  166. package/dist/core/request-routing/interceptors/query-param-redirect.mjs +22 -0
  167. package/dist/core/request-routing/interceptors/query-param-redirect.mjs.map +1 -0
  168. package/dist/core/request-routing/interceptors/sfapi-proxy.mjs +27 -0
  169. package/dist/core/request-routing/interceptors/sfapi-proxy.mjs.map +1 -0
  170. package/dist/core/request-routing/interceptors/standard-routes.mjs +19 -0
  171. package/dist/core/request-routing/interceptors/standard-routes.mjs.map +1 -0
  172. package/dist/core/request-routing/interceptors/url-redirects.mjs +27 -0
  173. package/dist/core/request-routing/interceptors/url-redirects.mjs.map +1 -0
  174. package/dist/core/request-routing/interceptors/well-known.mjs +19 -0
  175. package/dist/core/request-routing/interceptors/well-known.mjs.map +1 -0
  176. package/dist/core/request-routing/registered-routes.d.mts +7 -0
  177. package/dist/core/request-routing/registered-routes.mjs +59 -0
  178. package/dist/core/request-routing/registered-routes.mjs.map +1 -0
  179. package/dist/core/request-routing/route-types.d.mts +51 -0
  180. package/dist/core/request-routing/safe-apply-response-headers.mjs +16 -0
  181. package/dist/core/request-routing/safe-apply-response-headers.mjs.map +1 -0
  182. package/dist/core/shop-pay/shop-pay.d.mts +102 -0
  183. package/dist/core/shop-pay/shop-pay.mjs +289 -0
  184. package/dist/core/shop-pay/shop-pay.mjs.map +1 -0
  185. package/dist/core/shopify-scripts/analytics.mjs +26 -0
  186. package/dist/core/shopify-scripts/analytics.mjs.map +1 -0
  187. package/dist/core/shopify-scripts/consent.mjs +17 -0
  188. package/dist/core/shopify-scripts/consent.mjs.map +1 -0
  189. package/dist/core/shopify-scripts/constants.mjs +19 -0
  190. package/dist/core/shopify-scripts/constants.mjs.map +1 -0
  191. package/dist/core/shopify-scripts/deprecated-cookies.mjs +97 -0
  192. package/dist/core/shopify-scripts/deprecated-cookies.mjs.map +1 -0
  193. package/dist/core/shopify-scripts/global.d.mts +1 -0
  194. package/dist/core/shopify-scripts/global.mjs +86 -0
  195. package/dist/core/shopify-scripts/global.mjs.map +1 -0
  196. package/dist/core/shopify-scripts/index.d.mts +27 -0
  197. package/dist/core/shopify-scripts/index.mjs +135 -0
  198. package/dist/core/shopify-scripts/index.mjs.map +1 -0
  199. package/dist/core/shopify-scripts/initialize.d.mts +18 -0
  200. package/dist/core/shopify-scripts/initialize.mjs +27 -0
  201. package/dist/core/shopify-scripts/initialize.mjs.map +1 -0
  202. package/dist/core/shopify-scripts/page-view.mjs +49 -0
  203. package/dist/core/shopify-scripts/page-view.mjs.map +1 -0
  204. package/dist/core/shopify-scripts/perfkit.mjs +33 -0
  205. package/dist/core/shopify-scripts/perfkit.mjs.map +1 -0
  206. package/dist/core/shopify-scripts/render.d.mts +1 -0
  207. package/dist/core/shopify-scripts/render.mjs +23 -0
  208. package/dist/core/shopify-scripts/render.mjs.map +1 -0
  209. package/dist/core/shopify-scripts/types.d.mts +76 -0
  210. package/dist/core/shopify-scripts/utils/cookie-domain.mjs +43 -0
  211. package/dist/core/shopify-scripts/utils/cookie-domain.mjs.map +1 -0
  212. package/dist/core/shopify-scripts/utils/inline-script.mjs +8 -0
  213. package/dist/core/shopify-scripts/utils/inline-script.mjs.map +1 -0
  214. package/dist/core/shopify-scripts/utils/navigation.mjs +46 -0
  215. package/dist/core/shopify-scripts/utils/navigation.mjs.map +1 -0
  216. package/dist/core/shopify-scripts/utils/tracking-values.mjs +65 -0
  217. package/dist/core/shopify-scripts/utils/tracking-values.mjs.map +1 -0
  218. package/dist/core/shopify-scripts/utils/uuid.mjs +17 -0
  219. package/dist/core/shopify-scripts/utils/uuid.mjs.map +1 -0
  220. package/dist/core/shopify-scripts/webmcp.mjs +22 -0
  221. package/dist/core/shopify-scripts/webmcp.mjs.map +1 -0
  222. package/dist/core/standard-routes/build.d.mts +34 -0
  223. package/dist/core/standard-routes/build.mjs +54 -0
  224. package/dist/core/standard-routes/build.mjs.map +1 -0
  225. package/dist/core/standard-routes/defaults.mjs +31 -0
  226. package/dist/core/standard-routes/defaults.mjs.map +1 -0
  227. package/dist/core/standard-routes/match.mjs +108 -0
  228. package/dist/core/standard-routes/match.mjs.map +1 -0
  229. package/dist/core/standard-routes/path.mjs +58 -0
  230. package/dist/core/standard-routes/path.mjs.map +1 -0
  231. package/dist/core/standard-routes/redirects.mjs +51 -0
  232. package/dist/core/standard-routes/redirects.mjs.map +1 -0
  233. package/dist/core/standard-routes/types.d.mts +95 -0
  234. package/dist/core/url.mjs +35 -0
  235. package/dist/core/url.mjs.map +1 -0
  236. package/dist/core/utils/load-script.mjs +34 -0
  237. package/dist/core/utils/load-script.mjs.map +1 -0
  238. package/dist/core/utils/parse-gid.mjs +33 -0
  239. package/dist/core/utils/parse-gid.mjs.map +1 -0
  240. package/dist/core/utils/record.mjs +8 -0
  241. package/dist/core/utils/record.mjs.map +1 -0
  242. package/dist/customer-account/client.d.mts +50 -0
  243. package/dist/customer-account/client.mjs +239 -0
  244. package/dist/customer-account/client.mjs.map +1 -0
  245. package/dist/customer-account/errors.d.mts +28 -0
  246. package/dist/customer-account/errors.mjs +39 -0
  247. package/dist/customer-account/errors.mjs.map +1 -0
  248. package/dist/customer-account/graphql.d.mts +29 -0
  249. package/dist/customer-account/graphql.mjs +39 -0
  250. package/dist/customer-account/graphql.mjs.map +1 -0
  251. package/dist/customer-account/index.d.mts +7 -0
  252. package/dist/customer-account/index.mjs +7 -0
  253. package/dist/customer-account/session.d.mts +117 -0
  254. package/dist/customer-account/session.mjs +733 -0
  255. package/dist/customer-account/session.mjs.map +1 -0
  256. package/dist/customer-account/type-resolver.d.mts +11 -0
  257. package/dist/customer-account-api-types.d.ts +3269 -3270
  258. package/dist/customer-account.schema.json +50753 -1
  259. package/dist/development/_virtual/_@oxc-project_runtime@0.127.0/helpers/taggedTemplateLiteral.mjs +7 -0
  260. package/dist/development/client/client.d.mts +34 -0
  261. package/dist/development/client/client.mjs +193 -0
  262. package/dist/development/client/client.mjs.map +1 -0
  263. package/dist/development/client/errors.d.mts +48 -0
  264. package/dist/development/client/errors.mjs +57 -0
  265. package/dist/development/client/errors.mjs.map +1 -0
  266. package/dist/development/client/index.d.mts +4 -0
  267. package/dist/development/client/types.d.mts +147 -0
  268. package/dist/development/core/analytics/cart-tracker.d.mts +8 -0
  269. package/dist/development/core/analytics/cart-tracker.mjs +144 -0
  270. package/dist/development/core/analytics/cart-tracker.mjs.map +1 -0
  271. package/dist/development/core/analytics/events.d.mts +15 -0
  272. package/dist/development/core/analytics/events.mjs +15 -0
  273. package/dist/development/core/analytics/events.mjs.map +1 -0
  274. package/dist/development/core/analytics/index.d.mts +3 -0
  275. package/dist/development/core/analytics/types.d.mts +143 -0
  276. package/dist/development/core/analytics/utils/flatten-connection.d.mts +19 -0
  277. package/dist/development/core/analytics/utils/flatten-connection.mjs +25 -0
  278. package/dist/development/core/analytics/utils/flatten-connection.mjs.map +1 -0
  279. package/dist/development/core/cache/cache-status.mjs +17 -0
  280. package/dist/development/core/cache/cache-status.mjs.map +1 -0
  281. package/dist/development/core/cache/fetch-with-cache.d.mts +43 -0
  282. package/dist/development/core/cache/fetch-with-cache.mjs +188 -0
  283. package/dist/development/core/cache/fetch-with-cache.mjs.map +1 -0
  284. package/dist/development/core/cache/key.d.mts +6 -0
  285. package/dist/development/core/cache/key.mjs +27 -0
  286. package/dist/development/core/cache/key.mjs.map +1 -0
  287. package/dist/development/core/cache/run-with-cache.d.mts +36 -0
  288. package/dist/development/core/cache/run-with-cache.mjs +114 -0
  289. package/dist/development/core/cache/run-with-cache.mjs.map +1 -0
  290. package/dist/development/core/cache/store.d.mts +19 -0
  291. package/dist/development/core/cache/store.mjs +62 -0
  292. package/dist/development/core/cache/store.mjs.map +1 -0
  293. package/dist/development/core/cache/strategies.d.mts +39 -0
  294. package/dist/development/core/cache/strategies.mjs +70 -0
  295. package/dist/development/core/cache/strategies.mjs.map +1 -0
  296. package/dist/development/core/cart/actions.d.mts +50 -0
  297. package/dist/development/core/cart/actions.mjs +240 -0
  298. package/dist/development/core/cart/actions.mjs.map +1 -0
  299. package/dist/development/core/cart/attach-quantity-input.d.mts +5 -0
  300. package/dist/development/core/cart/attach-quantity-input.mjs +17 -0
  301. package/dist/development/core/cart/attach-quantity-input.mjs.map +1 -0
  302. package/dist/development/core/cart/buyer-identity-sync.d.mts +19 -0
  303. package/dist/development/core/cart/buyer-identity-sync.mjs +6 -0
  304. package/dist/development/core/cart/buyer-identity-sync.mjs.map +1 -0
  305. package/dist/development/core/cart/cart.d.mts +32 -0
  306. package/dist/development/core/cart/cart.mjs +1687 -0
  307. package/dist/development/core/cart/cart.mjs.map +1 -0
  308. package/dist/development/core/cart/cookie.d.mts +5 -0
  309. package/dist/development/core/cart/cookie.mjs +28 -0
  310. package/dist/development/core/cart/cookie.mjs.map +1 -0
  311. package/dist/development/core/cart/form.d.mts +130 -0
  312. package/dist/development/core/cart/form.mjs +75 -0
  313. package/dist/development/core/cart/form.mjs.map +1 -0
  314. package/dist/development/core/cart/get-cart.d.mts +25 -0
  315. package/dist/development/core/cart/get-cart.mjs +32 -0
  316. package/dist/development/core/cart/get-cart.mjs.map +1 -0
  317. package/dist/development/core/cart/index.d.mts +10 -0
  318. package/dist/development/core/cart/quantity.d.mts +10 -0
  319. package/dist/development/core/cart/quantity.mjs +14 -0
  320. package/dist/development/core/cart/quantity.mjs.map +1 -0
  321. package/dist/development/core/cart/queries.d.mts +4296 -0
  322. package/dist/development/core/cart/queries.mjs +70 -0
  323. package/dist/development/core/cart/queries.mjs.map +1 -0
  324. package/dist/development/core/cart/server-handlers.d.mts +82 -0
  325. package/dist/development/core/cart/server-handlers.mjs +322 -0
  326. package/dist/development/core/cart/server-handlers.mjs.map +1 -0
  327. package/dist/development/core/cart/state.d.mts +137 -0
  328. package/dist/development/core/cart/state.mjs +76 -0
  329. package/dist/development/core/cart/state.mjs.map +1 -0
  330. package/dist/development/core/cart/sync-quantity-inputs.mjs +16 -0
  331. package/dist/development/core/cart/sync-quantity-inputs.mjs.map +1 -0
  332. package/dist/development/core/collection/collection.d.mts +134 -0
  333. package/dist/development/core/collection/collection.mjs +170 -0
  334. package/dist/development/core/collection/collection.mjs.map +1 -0
  335. package/dist/development/core/collection/index.d.mts +6 -0
  336. package/dist/development/core/collection/reconciler.d.mts +32 -0
  337. package/dist/development/core/collection/reconciler.mjs +89 -0
  338. package/dist/development/core/collection/reconciler.mjs.map +1 -0
  339. package/dist/development/core/collection/state.d.mts +66 -0
  340. package/dist/development/core/collection/state.mjs +20 -0
  341. package/dist/development/core/collection/state.mjs.map +1 -0
  342. package/dist/development/core/collection/url.d.mts +70 -0
  343. package/dist/development/core/collection/url.mjs +367 -0
  344. package/dist/development/core/collection/url.mjs.map +1 -0
  345. package/dist/development/core/constants.mjs +7 -0
  346. package/dist/development/core/constants.mjs.map +1 -0
  347. package/dist/development/core/development.d.mts +55 -0
  348. package/dist/development/core/development.mjs +44 -0
  349. package/dist/development/core/headers.mjs +44 -0
  350. package/dist/development/core/headers.mjs.map +1 -0
  351. package/dist/development/core/index.d.mts +53 -0
  352. package/dist/development/core/logging/logging.d.mts +21 -0
  353. package/dist/development/core/logging/logging.mjs +99 -0
  354. package/dist/development/core/logging/logging.mjs.map +1 -0
  355. package/dist/development/core/logging/types.d.mts +40 -0
  356. package/dist/development/core/logging/types.mjs +18 -0
  357. package/dist/development/core/logging/types.mjs.map +1 -0
  358. package/dist/development/core/money/cache.mjs +25 -0
  359. package/dist/development/core/money/cache.mjs.map +1 -0
  360. package/dist/development/core/money/format.d.mts +15 -0
  361. package/dist/development/core/money/format.mjs +243 -0
  362. package/dist/development/core/money/format.mjs.map +1 -0
  363. package/dist/development/core/money/types.d.mts +47 -0
  364. package/dist/development/core/observable.mjs +46 -0
  365. package/dist/development/core/observable.mjs.map +1 -0
  366. package/dist/development/core/predictive-search/constants.d.mts +5 -0
  367. package/dist/development/core/predictive-search/constants.mjs +6 -0
  368. package/dist/development/core/predictive-search/constants.mjs.map +1 -0
  369. package/dist/development/core/predictive-search/form.d.mts +31 -0
  370. package/dist/development/core/predictive-search/form.mjs +31 -0
  371. package/dist/development/core/predictive-search/form.mjs.map +1 -0
  372. package/dist/development/core/predictive-search/index.d.mts +6 -0
  373. package/dist/development/core/predictive-search/queries.d.mts +118 -0
  374. package/dist/development/core/predictive-search/queries.mjs +81 -0
  375. package/dist/development/core/predictive-search/queries.mjs.map +1 -0
  376. package/dist/development/core/predictive-search/search.d.mts +32 -0
  377. package/dist/development/core/predictive-search/search.mjs +74 -0
  378. package/dist/development/core/predictive-search/search.mjs.map +1 -0
  379. package/dist/development/core/predictive-search/server-handlers.d.mts +36 -0
  380. package/dist/development/core/predictive-search/server-handlers.mjs +113 -0
  381. package/dist/development/core/predictive-search/server-handlers.mjs.map +1 -0
  382. package/dist/development/core/predictive-search/store.d.mts +44 -0
  383. package/dist/development/core/predictive-search/store.mjs +224 -0
  384. package/dist/development/core/predictive-search/store.mjs.map +1 -0
  385. package/dist/development/core/predictive-search/url.d.mts +41 -0
  386. package/dist/development/core/predictive-search/url.mjs +71 -0
  387. package/dist/development/core/predictive-search/url.mjs.map +1 -0
  388. package/dist/development/core/product/form.d.mts +63 -0
  389. package/dist/development/core/product/form.mjs +44 -0
  390. package/dist/development/core/product/form.mjs.map +1 -0
  391. package/dist/development/core/product/index.d.mts +4 -0
  392. package/dist/development/core/product/options.d.mts +40 -0
  393. package/dist/development/core/product/options.mjs +291 -0
  394. package/dist/development/core/product/options.mjs.map +1 -0
  395. package/dist/development/core/product/product-form.d.mts +72 -0
  396. package/dist/development/core/product/product-form.mjs +158 -0
  397. package/dist/development/core/product/product-form.mjs.map +1 -0
  398. package/dist/development/core/product/state.d.mts +68 -0
  399. package/dist/development/core/request-context.d.mts +70 -0
  400. package/dist/development/core/request-context.mjs +120 -0
  401. package/dist/development/core/request-context.mjs.map +1 -0
  402. package/dist/development/core/request-routing/handle-shopify-redirects.d.mts +17 -0
  403. package/dist/development/core/request-routing/handle-shopify-redirects.mjs +31 -0
  404. package/dist/development/core/request-routing/handle-shopify-redirects.mjs.map +1 -0
  405. package/dist/development/core/request-routing/handle-shopify-routes.d.mts +1 -0
  406. package/dist/development/core/request-routing/handle-shopify-routes.development.d.mts +11 -0
  407. package/dist/development/core/request-routing/handle-shopify-routes.development.mjs +16 -0
  408. package/dist/development/core/request-routing/handle-shopify-routes.development.mjs.map +1 -0
  409. package/dist/development/core/request-routing/handle-shopify-routes.mjs +42 -0
  410. package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -0
  411. package/dist/development/core/request-routing/interceptors/admin-redirect.mjs +12 -0
  412. package/dist/development/core/request-routing/interceptors/admin-redirect.mjs.map +1 -0
  413. package/dist/development/core/request-routing/interceptors/agent-proxy.mjs +19 -0
  414. package/dist/development/core/request-routing/interceptors/agent-proxy.mjs.map +1 -0
  415. package/dist/development/core/request-routing/interceptors/ajax-api.mjs +16 -0
  416. package/dist/development/core/request-routing/interceptors/ajax-api.mjs.map +1 -0
  417. package/dist/development/core/request-routing/interceptors/api-proxy.mjs +20 -0
  418. package/dist/development/core/request-routing/interceptors/api-proxy.mjs.map +1 -0
  419. package/dist/development/core/request-routing/interceptors/checkout.mjs +58 -0
  420. package/dist/development/core/request-routing/interceptors/checkout.mjs.map +1 -0
  421. package/dist/development/core/request-routing/interceptors/graphiql.mjs +46 -0
  422. package/dist/development/core/request-routing/interceptors/graphiql.mjs.map +1 -0
  423. package/dist/development/core/request-routing/interceptors/mcp-proxy.mjs +23 -0
  424. package/dist/development/core/request-routing/interceptors/mcp-proxy.mjs.map +1 -0
  425. package/dist/development/core/request-routing/interceptors/proxy.mjs +68 -0
  426. package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -0
  427. package/dist/development/core/request-routing/interceptors/query-param-redirect.mjs +22 -0
  428. package/dist/development/core/request-routing/interceptors/query-param-redirect.mjs.map +1 -0
  429. package/dist/development/core/request-routing/interceptors/sfapi-proxy.mjs +27 -0
  430. package/dist/development/core/request-routing/interceptors/sfapi-proxy.mjs.map +1 -0
  431. package/dist/development/core/request-routing/interceptors/standard-routes.mjs +19 -0
  432. package/dist/development/core/request-routing/interceptors/standard-routes.mjs.map +1 -0
  433. package/dist/development/core/request-routing/interceptors/url-redirects.mjs +27 -0
  434. package/dist/development/core/request-routing/interceptors/url-redirects.mjs.map +1 -0
  435. package/dist/development/core/request-routing/interceptors/well-known.mjs +19 -0
  436. package/dist/development/core/request-routing/interceptors/well-known.mjs.map +1 -0
  437. package/dist/development/core/request-routing/registered-routes.d.mts +7 -0
  438. package/dist/development/core/request-routing/registered-routes.mjs +59 -0
  439. package/dist/development/core/request-routing/registered-routes.mjs.map +1 -0
  440. package/dist/development/core/request-routing/route-types.d.mts +51 -0
  441. package/dist/development/core/request-routing/safe-apply-response-headers.mjs +16 -0
  442. package/dist/development/core/request-routing/safe-apply-response-headers.mjs.map +1 -0
  443. package/dist/development/core/shop-pay/shop-pay.d.mts +102 -0
  444. package/dist/development/core/shop-pay/shop-pay.mjs +289 -0
  445. package/dist/development/core/shop-pay/shop-pay.mjs.map +1 -0
  446. package/dist/development/core/shopify-scripts/analytics.mjs +26 -0
  447. package/dist/development/core/shopify-scripts/analytics.mjs.map +1 -0
  448. package/dist/development/core/shopify-scripts/consent.mjs +17 -0
  449. package/dist/development/core/shopify-scripts/consent.mjs.map +1 -0
  450. package/dist/development/core/shopify-scripts/constants.mjs +19 -0
  451. package/dist/development/core/shopify-scripts/constants.mjs.map +1 -0
  452. package/dist/development/core/shopify-scripts/deprecated-cookies.mjs +97 -0
  453. package/dist/development/core/shopify-scripts/deprecated-cookies.mjs.map +1 -0
  454. package/dist/development/core/shopify-scripts/global.d.mts +1 -0
  455. package/dist/development/core/shopify-scripts/global.mjs +86 -0
  456. package/dist/development/core/shopify-scripts/global.mjs.map +1 -0
  457. package/dist/development/core/shopify-scripts/index.d.mts +27 -0
  458. package/dist/development/core/shopify-scripts/index.mjs +145 -0
  459. package/dist/development/core/shopify-scripts/index.mjs.map +1 -0
  460. package/dist/development/core/shopify-scripts/initialize.d.mts +18 -0
  461. package/dist/development/core/shopify-scripts/initialize.mjs +27 -0
  462. package/dist/development/core/shopify-scripts/initialize.mjs.map +1 -0
  463. package/dist/development/core/shopify-scripts/page-view.mjs +49 -0
  464. package/dist/development/core/shopify-scripts/page-view.mjs.map +1 -0
  465. package/dist/development/core/shopify-scripts/perfkit.mjs +33 -0
  466. package/dist/development/core/shopify-scripts/perfkit.mjs.map +1 -0
  467. package/dist/development/core/shopify-scripts/render.d.mts +1 -0
  468. package/dist/development/core/shopify-scripts/render.mjs +23 -0
  469. package/dist/development/core/shopify-scripts/render.mjs.map +1 -0
  470. package/dist/development/core/shopify-scripts/types.d.mts +76 -0
  471. package/dist/development/core/shopify-scripts/utils/cookie-domain.mjs +43 -0
  472. package/dist/development/core/shopify-scripts/utils/cookie-domain.mjs.map +1 -0
  473. package/dist/development/core/shopify-scripts/utils/inline-script.mjs +8 -0
  474. package/dist/development/core/shopify-scripts/utils/inline-script.mjs.map +1 -0
  475. package/dist/development/core/shopify-scripts/utils/navigation.mjs +46 -0
  476. package/dist/development/core/shopify-scripts/utils/navigation.mjs.map +1 -0
  477. package/dist/development/core/shopify-scripts/utils/tracking-values.mjs +65 -0
  478. package/dist/development/core/shopify-scripts/utils/tracking-values.mjs.map +1 -0
  479. package/dist/development/core/shopify-scripts/utils/uuid.mjs +17 -0
  480. package/dist/development/core/shopify-scripts/utils/uuid.mjs.map +1 -0
  481. package/dist/development/core/shopify-scripts/webmcp.mjs +22 -0
  482. package/dist/development/core/shopify-scripts/webmcp.mjs.map +1 -0
  483. package/dist/development/core/standard-routes/build.d.mts +34 -0
  484. package/dist/development/core/standard-routes/build.mjs +54 -0
  485. package/dist/development/core/standard-routes/build.mjs.map +1 -0
  486. package/dist/development/core/standard-routes/defaults.mjs +31 -0
  487. package/dist/development/core/standard-routes/defaults.mjs.map +1 -0
  488. package/dist/development/core/standard-routes/match.mjs +108 -0
  489. package/dist/development/core/standard-routes/match.mjs.map +1 -0
  490. package/dist/development/core/standard-routes/path.mjs +58 -0
  491. package/dist/development/core/standard-routes/path.mjs.map +1 -0
  492. package/dist/development/core/standard-routes/redirects.mjs +51 -0
  493. package/dist/development/core/standard-routes/redirects.mjs.map +1 -0
  494. package/dist/development/core/standard-routes/types.d.mts +95 -0
  495. package/dist/development/core/types.d.mts +11 -0
  496. package/dist/development/core/url.mjs +35 -0
  497. package/dist/development/core/url.mjs.map +1 -0
  498. package/dist/development/core/utils/load-script.mjs +34 -0
  499. package/dist/development/core/utils/load-script.mjs.map +1 -0
  500. package/dist/development/core/utils/parse-gid.mjs +33 -0
  501. package/dist/development/core/utils/parse-gid.mjs.map +1 -0
  502. package/dist/development/customer-account/session.d.mts +46 -0
  503. package/dist/development/customer-account/session.mjs +21 -0
  504. package/dist/development/customer-account/session.mjs.map +1 -0
  505. package/dist/development/globals.d.mts +64 -0
  506. package/dist/development/graphql/generated/customer-account-api-types.d.mts +13 -0
  507. package/dist/development/graphql/generated/graphql-env.d.mts +19280 -0
  508. package/dist/development/graphql/generated/storefront-api-types.d.mts +47 -0
  509. package/dist/development/graphql/graphql.d.mts +40 -0
  510. package/dist/development/graphql/graphql.mjs +16 -0
  511. package/dist/development/graphql/graphql.mjs.map +1 -0
  512. package/dist/development/graphql/index.d.mts +2 -0
  513. package/dist/development/graphql/scalars.d.mts +15 -0
  514. package/dist/development/graphql/type-resolver.d.mts +229 -0
  515. package/dist/development/react/cart.d.mts +40 -0
  516. package/dist/development/react/cart.mjs +150 -0
  517. package/dist/development/react/cart.mjs.map +1 -0
  518. package/dist/development/react/collection.d.mts +91 -0
  519. package/dist/development/react/collection.mjs +129 -0
  520. package/dist/development/react/collection.mjs.map +1 -0
  521. package/dist/development/react/index.d.mts +13 -0
  522. package/dist/development/react/index.mjs +10 -0
  523. package/dist/development/react/predictive-search.d.mts +49 -0
  524. package/dist/development/react/predictive-search.mjs +133 -0
  525. package/dist/development/react/predictive-search.mjs.map +1 -0
  526. package/dist/development/react/product.d.mts +72 -0
  527. package/dist/development/react/product.mjs +127 -0
  528. package/dist/development/react/product.mjs.map +1 -0
  529. package/dist/development/react/shop-pay.d.mts +9 -0
  530. package/dist/development/react/shop-pay.mjs +16 -0
  531. package/dist/development/react/shop-pay.mjs.map +1 -0
  532. package/dist/development/react/shopify-scripts.d.mts +20 -0
  533. package/dist/development/react/shopify-scripts.mjs +39 -0
  534. package/dist/development/react/shopify-scripts.mjs.map +1 -0
  535. package/dist/development/vendor/standard-actions.d.mts +134 -0
  536. package/dist/development/vendor/standard-events.d.mts +1107 -0
  537. package/dist/development/vue/cart.d.mts +42 -0
  538. package/dist/development/vue/cart.mjs +118 -0
  539. package/dist/development/vue/cart.mjs.map +1 -0
  540. package/dist/development/vue/collection.d.mts +46 -0
  541. package/dist/development/vue/collection.mjs +108 -0
  542. package/dist/development/vue/collection.mjs.map +1 -0
  543. package/dist/development/vue/index.d.mts +11 -0
  544. package/dist/development/vue/index.mjs +8 -0
  545. package/dist/development/vue/predictive-search.d.mts +124 -0
  546. package/dist/development/vue/predictive-search.mjs +171 -0
  547. package/dist/development/vue/predictive-search.mjs.map +1 -0
  548. package/dist/development/vue/product.d.mts +57 -0
  549. package/dist/development/vue/product.mjs +167 -0
  550. package/dist/development/vue/product.mjs.map +1 -0
  551. package/dist/development/vue/shop-pay.d.mts +25 -0
  552. package/dist/development/vue/shop-pay.mjs +35 -0
  553. package/dist/development/vue/shop-pay.mjs.map +1 -0
  554. package/dist/development/vue/shopify-scripts.d.mts +127 -0
  555. package/dist/development/vue/shopify-scripts.mjs +79 -0
  556. package/dist/development/vue/shopify-scripts.mjs.map +1 -0
  557. package/dist/globals.d.mts +64 -0
  558. package/dist/graphql/generated/customer-account-api-types.d.mts +13 -0
  559. package/dist/graphql/generated/customer-account-graphql-env.d.mts +22170 -0
  560. package/dist/graphql/generated/graphql-env.d.mts +19280 -0
  561. package/dist/graphql/generated/storefront-api-types.d.mts +47 -0
  562. package/dist/graphql/graphql.d.mts +40 -0
  563. package/dist/graphql/graphql.mjs +16 -0
  564. package/dist/graphql/graphql.mjs.map +1 -0
  565. package/dist/graphql/index.d.mts +2 -0
  566. package/dist/graphql/scalars.d.mts +26 -0
  567. package/dist/graphql/type-resolver.d.mts +229 -0
  568. package/dist/react/cart.d.mts +40 -0
  569. package/dist/react/cart.mjs +150 -0
  570. package/dist/react/cart.mjs.map +1 -0
  571. package/dist/react/collection.d.mts +91 -0
  572. package/dist/react/collection.mjs +129 -0
  573. package/dist/react/collection.mjs.map +1 -0
  574. package/dist/react/index.d.mts +13 -0
  575. package/dist/react/index.mjs +10 -0
  576. package/dist/react/predictive-search.d.mts +49 -0
  577. package/dist/react/predictive-search.mjs +133 -0
  578. package/dist/react/predictive-search.mjs.map +1 -0
  579. package/dist/react/product.d.mts +72 -0
  580. package/dist/react/product.mjs +127 -0
  581. package/dist/react/product.mjs.map +1 -0
  582. package/dist/react/shop-pay.d.mts +9 -0
  583. package/dist/react/shop-pay.mjs +16 -0
  584. package/dist/react/shop-pay.mjs.map +1 -0
  585. package/dist/react/shopify-scripts.d.mts +20 -0
  586. package/dist/react/shopify-scripts.mjs +39 -0
  587. package/dist/react/shopify-scripts.mjs.map +1 -0
  588. package/dist/storefront-api-types.d.ts +2351 -2390
  589. package/dist/storefront.schema.json +41534 -1
  590. package/dist/ts-plugin/index.cjs +68 -0
  591. package/dist/ts-plugin/index.cjs.map +1 -0
  592. package/dist/ts-plugin/index.d.cts +4 -0
  593. package/dist/vendor/standard-actions.d.mts +134 -0
  594. package/dist/vendor/standard-events.d.mts +1107 -0
  595. package/dist/vite/index.d.mts +2 -0
  596. package/dist/vite/index.mjs +3 -0
  597. package/dist/vite/local-https.d.mts +35 -0
  598. package/dist/vite/local-https.mjs +202 -0
  599. package/dist/vite/local-https.mjs.map +1 -0
  600. package/dist/vue/cart.d.mts +42 -0
  601. package/dist/vue/cart.mjs +118 -0
  602. package/dist/vue/cart.mjs.map +1 -0
  603. package/dist/vue/collection.d.mts +46 -0
  604. package/dist/vue/collection.mjs +108 -0
  605. package/dist/vue/collection.mjs.map +1 -0
  606. package/dist/vue/index.d.mts +11 -0
  607. package/dist/vue/index.mjs +8 -0
  608. package/dist/vue/predictive-search.d.mts +124 -0
  609. package/dist/vue/predictive-search.mjs +171 -0
  610. package/dist/vue/predictive-search.mjs.map +1 -0
  611. package/dist/vue/product.d.mts +57 -0
  612. package/dist/vue/product.mjs +167 -0
  613. package/dist/vue/product.mjs.map +1 -0
  614. package/dist/vue/shop-pay.d.mts +25 -0
  615. package/dist/vue/shop-pay.mjs +35 -0
  616. package/dist/vue/shop-pay.mjs.map +1 -0
  617. package/dist/vue/shopify-scripts.d.mts +127 -0
  618. package/dist/vue/shopify-scripts.mjs +79 -0
  619. package/dist/vue/shopify-scripts.mjs.map +1 -0
  620. package/package.json +116 -86
  621. package/skills/hydrogen-analytics/SKILL.md +80 -0
  622. package/skills/hydrogen-analytics/references/react.md +160 -0
  623. package/skills/hydrogen-analytics/references/vue.md +80 -0
  624. package/skills/hydrogen-cart-drawer/SKILL.md +248 -0
  625. package/skills/hydrogen-cart-drawer/references/accessibility.md +109 -0
  626. package/skills/hydrogen-cart-drawer/references/css.md +67 -0
  627. package/skills/hydrogen-cart-ui/SKILL.md +218 -0
  628. package/skills/hydrogen-cart-ui/references/nextjs.md +89 -0
  629. package/skills/hydrogen-cart-ui/references/react.md +263 -0
  630. package/skills/hydrogen-cart-ui/references/vue.md +204 -0
  631. package/skills/hydrogen-collection-browser/SKILL.md +80 -0
  632. package/skills/hydrogen-collection-browser/references/nextjs.md +118 -0
  633. package/skills/hydrogen-collection-browser/references/nuxt.md +108 -0
  634. package/skills/hydrogen-collection-browser/references/react.md +237 -0
  635. package/skills/hydrogen-customer-account/SKILL.md +107 -0
  636. package/skills/hydrogen-image/SKILL.md +65 -0
  637. package/skills/hydrogen-local-https/SKILL.md +144 -0
  638. package/skills/hydrogen-markets/SKILL.md +221 -0
  639. package/skills/hydrogen-markets/references/nextjs.md +157 -0
  640. package/skills/hydrogen-money/SKILL.md +67 -0
  641. package/skills/hydrogen-oxygen/SKILL.md +245 -0
  642. package/skills/hydrogen-oxygen/references/react-router.md +230 -0
  643. package/skills/hydrogen-predictive-search/SKILL.md +130 -0
  644. package/skills/hydrogen-predictive-search/references/react.md +32 -0
  645. package/skills/hydrogen-predictive-search/references/vue.md +40 -0
  646. package/skills/hydrogen-request-handlers/SKILL.md +90 -0
  647. package/skills/hydrogen-request-handlers/references/frameworks.md +174 -0
  648. package/skills/hydrogen-request-handlers/references/nextjs.md +136 -0
  649. package/skills/hydrogen-request-handlers/references/nuxt.md +214 -0
  650. package/skills/hydrogen-routing/SKILL.md +154 -0
  651. package/skills/hydrogen-setup/SKILL.md +50 -0
  652. package/skills/hydrogen-setup/references/analytics.md +624 -0
  653. package/skills/hydrogen-setup/steps/1-inspect-app.md +62 -0
  654. package/skills/hydrogen-setup/steps/10-analytics.md +10 -0
  655. package/skills/hydrogen-setup/steps/11-verify.md +31 -0
  656. package/skills/hydrogen-setup/steps/2-scaffold.md +86 -0
  657. package/skills/hydrogen-setup/steps/3-build-home-page.md +37 -0
  658. package/skills/hydrogen-setup/steps/4-collection-and-search.md +13 -0
  659. package/skills/hydrogen-setup/steps/5-cart.md +10 -0
  660. package/skills/hydrogen-setup/steps/6-product-detail-page.md +390 -0
  661. package/skills/hydrogen-setup/steps/7-shopify-runtime-scripts.md +69 -0
  662. package/skills/hydrogen-setup/steps/8-cart-drawer-and-navbar.md +35 -0
  663. package/skills/hydrogen-setup/steps/9-account-page.md +54 -0
  664. package/skills/hydrogen-shop-pay/SKILL.md +79 -0
  665. package/skills/hydrogen-shop-pay/references/core.md +66 -0
  666. package/skills/hydrogen-shop-pay/references/react.md +50 -0
  667. package/skills/hydrogen-shop-pay/references/vue.md +39 -0
  668. package/skills/hydrogen-smoke-test/SKILL.md +203 -0
  669. package/skills/hydrogen-storefront-client/SKILL.md +322 -0
  670. package/skills/hydrogen-storefront-client/references/astro.md +125 -0
  671. package/skills/hydrogen-storefront-client/references/caching.md +25 -0
  672. package/skills/hydrogen-storefront-client/references/nextjs.md +121 -0
  673. package/skills/hydrogen-storefront-client/references/nuxt.md +121 -0
  674. package/skills/hydrogen-storefront-client/references/query-validation.md +95 -0
  675. package/skills/hydrogen-storefront-client/references/react-router.md +81 -0
  676. package/skills/hydrogen-storefront-client/references/solidstart.md +131 -0
  677. package/skills/hydrogen-storefront-client/references/sveltekit.md +169 -0
  678. package/skills/hydrogen-variant-form/SKILL.md +250 -0
  679. package/skills/hydrogen-variant-form/references/nextjs.md +203 -0
  680. package/skills/hydrogen-variant-form/references/nuxt.md +95 -0
  681. package/skills/hydrogen-variant-form/references/react.md +71 -0
  682. package/dist/dev/get-virtual-routes-H72465VB.js +0 -74
  683. package/dist/dev/hydrogen-routes.d.ts +0 -5
  684. package/dist/dev/hydrogen-routes.js +0 -25
  685. package/dist/development/get-virtual-routes-ACFZHU42.js +0 -71
  686. package/dist/development/get-virtual-routes-ACFZHU42.js.map +0 -1
  687. package/dist/development/index.cjs +0 -6948
  688. package/dist/development/index.cjs.map +0 -1
  689. package/dist/development/index.js +0 -6601
  690. package/dist/development/index.js.map +0 -1
  691. package/dist/development/log-seo-tags-IG37ONQ2.js +0 -74
  692. package/dist/development/log-seo-tags-IG37ONQ2.js.map +0 -1
  693. package/dist/development/react-router-preset.d.ts +0 -45
  694. package/dist/development/react-router-preset.js +0 -49
  695. package/dist/development/react-router-preset.js.map +0 -1
  696. package/dist/index.cjs +0 -1
  697. package/dist/oxygen/index.d.ts +0 -197
  698. package/dist/oxygen/index.js +0 -107
  699. package/dist/production/get-virtual-routes-ZZEGQQDV.js +0 -3
  700. package/dist/production/get-virtual-routes-ZZEGQQDV.js.map +0 -1
  701. package/dist/production/index.cjs +0 -1019
  702. package/dist/production/index.cjs.map +0 -1
  703. package/dist/production/index.d.cts +0 -3260
  704. package/dist/production/index.d.ts +0 -3260
  705. package/dist/production/index.js +0 -1019
  706. package/dist/production/index.js.map +0 -1
  707. package/dist/production/log-seo-tags-TY72EQWZ.js +0 -2
  708. package/dist/production/log-seo-tags-TY72EQWZ.js.map +0 -1
  709. package/dist/production/react-router-preset.d.ts +0 -45
  710. package/dist/production/react-router-preset.js +0 -11
  711. package/dist/react-router.d.ts +0 -75
  712. package/dist/vite/chunk-4O5OI3OO.js +0 -127
  713. package/dist/vite/chunk-FAQ7TVHC.js +0 -9
  714. package/dist/vite/chunk-QXBQVDMY.js +0 -68
  715. package/dist/vite/compat-date.d.ts +0 -3
  716. package/dist/vite/compat-date.js +0 -6
  717. package/dist/vite/get-virtual-routes.d.ts +0 -21
  718. package/dist/vite/get-virtual-routes.js +0 -74
  719. package/dist/vite/hydrogen-middleware.d.ts +0 -9
  720. package/dist/vite/hydrogen-middleware.js +0 -7
  721. package/dist/vite/plugin.d.ts +0 -22
  722. package/dist/vite/plugin.js +0 -171
  723. package/dist/vite/request-events.d.ts +0 -144
  724. package/dist/vite/request-events.js +0 -10
  725. package/dist/vite/types.d.ts +0 -5
  726. package/dist/vite/types.js +0 -0
  727. package/dist/vite/virtual-routes/assets/debug-network.css +0 -609
  728. package/dist/vite/virtual-routes/assets/favicon-dark.svg +0 -20
  729. package/dist/vite/virtual-routes/assets/favicon.svg +0 -28
  730. package/dist/vite/virtual-routes/assets/inter-variable-font.woff2 +0 -0
  731. package/dist/vite/virtual-routes/assets/jetbrainsmono-variable-font.woff2 +0 -0
  732. package/dist/vite/virtual-routes/assets/styles.css +0 -249
  733. package/dist/vite/virtual-routes/components/FlameChartWrapper.jsx +0 -123
  734. package/dist/vite/virtual-routes/components/HydrogenLogoBaseBW.jsx +0 -32
  735. package/dist/vite/virtual-routes/components/HydrogenLogoBaseColor.jsx +0 -47
  736. package/dist/vite/virtual-routes/components/IconBanner.jsx +0 -292
  737. package/dist/vite/virtual-routes/components/IconClose.jsx +0 -38
  738. package/dist/vite/virtual-routes/components/IconDiscard.jsx +0 -44
  739. package/dist/vite/virtual-routes/components/IconError.jsx +0 -61
  740. package/dist/vite/virtual-routes/components/IconGithub.jsx +0 -23
  741. package/dist/vite/virtual-routes/components/IconTwitter.jsx +0 -21
  742. package/dist/vite/virtual-routes/components/Layout.jsx +0 -7
  743. package/dist/vite/virtual-routes/components/RequestDetails.jsx +0 -171
  744. package/dist/vite/virtual-routes/components/RequestTable.jsx +0 -91
  745. package/dist/vite/virtual-routes/components/RequestWaterfall.jsx +0 -151
  746. package/dist/vite/virtual-routes/layout.jsx +0 -33
  747. package/dist/vite/virtual-routes/lib/useDebugNetworkServer.jsx +0 -178
  748. package/dist/vite/virtual-routes/routes/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.jsx +0 -37
  749. package/dist/vite/virtual-routes/routes/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.tsx +0 -79
  750. package/dist/vite/virtual-routes/routes/graphiql.jsx +0 -5
  751. package/dist/vite/virtual-routes/routes/index.jsx +0 -265
  752. package/dist/vite/virtual-routes/routes/subrequest-profiler.jsx +0 -243
  753. package/dist/vite/virtual-routes/virtual-root-with-layout.jsx +0 -63
  754. package/dist/vite/virtual-routes/virtual-root.jsx +0 -67
@@ -0,0 +1,114 @@
1
+ import { hashCacheKey } from "./key.mjs";
2
+ import { NO_STORE, getCacheRetentionTtl } from "./strategies.mjs";
3
+ import { createNormalizedCacheStore } from "./store.mjs";
4
+
5
+ //#region src/core/cache/run-with-cache.ts
6
+ /**
7
+ * Internal control-flow error for adapters that need to escape the cache
8
+ * pipeline without being interpreted as an origin failure. `staleIfError`
9
+ * catches refresh failures, but it should not hide intentional bypasses.
10
+ */
11
+ var StaleFallbackDisabledError = class extends Error {};
12
+ function createRunWithCache({ cache, waitUntil }) {
13
+ const store = createNormalizedCacheStore(cache);
14
+ return async function runWithCache(options, run) {
15
+ if (options.strategy.mode === "no-store") return {
16
+ data: (await runAndValidate(run)).data,
17
+ cacheStatus: "bypass"
18
+ };
19
+ const cacheKey = await hashCacheKey(options.key);
20
+ let cached;
21
+ try {
22
+ cached = await store.get(cacheKey);
23
+ } catch {}
24
+ if (cached) {
25
+ const state = getCacheState(cached, options.strategy);
26
+ if (state === "fresh") return {
27
+ data: cached.value,
28
+ cacheStatus: "hit"
29
+ };
30
+ if (state === "stale") {
31
+ revalidateInBackground(cacheKey, options, run);
32
+ return {
33
+ data: cached.value,
34
+ cacheStatus: "hit"
35
+ };
36
+ }
37
+ if (state === "stale-if-error") return refreshWithStaleFallback(cacheKey, cached.value, options, run);
38
+ }
39
+ return runAndMaybeStore(cacheKey, options, run).result;
40
+ };
41
+ function revalidateInBackground(cacheKey, options, run) {
42
+ schedule(runAndMaybeStore(cacheKey, options, run, { scheduleCacheWrite: false }).complete);
43
+ }
44
+ async function refreshWithStaleFallback(cacheKey, staleValue, options, run) {
45
+ try {
46
+ return await runAndMaybeStore(cacheKey, options, run).result;
47
+ } catch (error) {
48
+ if (!shouldFallbackToStale(error)) throw error;
49
+ return {
50
+ data: staleValue,
51
+ cacheStatus: "hit"
52
+ };
53
+ }
54
+ }
55
+ function runAndMaybeStore(key, options, run, { scheduleCacheWrite = true } = {}) {
56
+ let storePromise = Promise.resolve();
57
+ const result = Promise.resolve().then(async () => {
58
+ const decision = await runAndValidate(run);
59
+ if (!shouldStore(options.strategy, decision)) return {
60
+ data: decision.data,
61
+ cacheStatus: "miss"
62
+ };
63
+ storePromise = storeDecision(key, options, decision).catch(() => {});
64
+ if (waitUntil && scheduleCacheWrite) schedule(storePromise);
65
+ else if (!waitUntil) await storePromise;
66
+ return {
67
+ data: decision.data,
68
+ cacheStatus: "miss"
69
+ };
70
+ });
71
+ return {
72
+ result,
73
+ complete: result.then(() => storePromise, () => void 0).then(() => void 0)
74
+ };
75
+ }
76
+ async function storeDecision(key, options, decision) {
77
+ await store.set(key, {
78
+ version: 1,
79
+ value: decision.data,
80
+ storedAt: Date.now(),
81
+ strategy: options.strategy
82
+ }, { strategy: options.strategy });
83
+ }
84
+ function schedule(promise) {
85
+ try {
86
+ waitUntil?.(promise);
87
+ } catch {}
88
+ }
89
+ }
90
+ function shouldStore(strategy, decision) {
91
+ return decision.shouldCache && getCacheRetentionTtl(strategy) > 0;
92
+ }
93
+ function shouldFallbackToStale(error) {
94
+ return !(error instanceof StaleFallbackDisabledError);
95
+ }
96
+ async function runAndValidate(run) {
97
+ const decision = await run();
98
+ if (typeof decision !== "object" || decision == null || !("data" in decision) || !("shouldCache" in decision) || typeof decision.shouldCache !== "boolean") throw new TypeError("runWithCache callback must return {data, shouldCache}.");
99
+ return decision;
100
+ }
101
+ function getCacheState(envelope, strategy) {
102
+ const age = Math.max(0, (Date.now() - envelope.storedAt) / 1e3);
103
+ const maxAge = strategy.maxAge ?? 0;
104
+ const staleWhileRevalidate = strategy.staleWhileRevalidate ?? 0;
105
+ const staleIfError = strategy.staleIfError ?? 0;
106
+ if (age <= maxAge) return "fresh";
107
+ if (age <= maxAge + staleWhileRevalidate) return "stale";
108
+ if (age <= maxAge + staleWhileRevalidate + staleIfError) return "stale-if-error";
109
+ return "expired";
110
+ }
111
+
112
+ //#endregion
113
+ export { StaleFallbackDisabledError, createRunWithCache };
114
+ //# sourceMappingURL=run-with-cache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-with-cache.mjs","names":[],"sources":["../../../src/core/cache/run-with-cache.ts"],"sourcesContent":["import { hashCacheKey, type CacheKey } from \"./key\";\nimport {\n type CacheEnvelope,\n type KeyValueCacheLike,\n type SerializableCacheValue,\n type WebCacheLike,\n createNormalizedCacheStore,\n} from \"./store\";\nimport { NO_STORE, type CachingStrategy, getCacheRetentionTtl } from \"./strategies\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type WaitUntil = (promise: Promise<unknown>) => void;\n\nexport type CacheInstance = WebCacheLike | KeyValueCacheLike;\n\nexport type CreateRunWithCacheOptions = {\n cache: CacheInstance;\n waitUntil?: WaitUntil;\n};\n\nexport type RunWithCacheOptions = {\n key: CacheKey;\n strategy: CachingStrategy;\n};\n\nexport type CacheDecision<T extends SerializableCacheValue> = {\n /**\n * Must be a JSON-serializable object. The cache store may persist this value\n * through `JSON.stringify`; nested serializability is the caller's contract.\n */\n data: T;\n shouldCache: boolean;\n};\n\nexport type RunWithCacheResult<T extends SerializableCacheValue> = {\n data: T;\n cacheStatus: \"hit\" | \"miss\" | \"bypass\";\n};\n\nexport type RunWithCache = <T extends SerializableCacheValue>(\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n) => Promise<RunWithCacheResult<T>>;\n\ntype CacheState = \"fresh\" | \"stale\" | \"stale-if-error\" | \"expired\";\n\n/**\n * `result` resolves as soon as user data is available; `complete` also waits for\n * any cache write so background revalidation can be scheduled as one operation.\n */\ntype CacheOperation<T extends SerializableCacheValue = SerializableCacheValue> = {\n result: Promise<RunWithCacheResult<T>>;\n complete: Promise<void>;\n};\n\ntype RunAndMaybeStoreOptions = {\n scheduleCacheWrite?: boolean;\n};\n\n/**\n * Internal control-flow error for adapters that need to escape the cache\n * pipeline without being interpreted as an origin failure. `staleIfError`\n * catches refresh failures, but it should not hide intentional bypasses.\n */\nexport class StaleFallbackDisabledError extends Error {}\n\nexport function createRunWithCache({ cache, waitUntil }: CreateRunWithCacheOptions): RunWithCache {\n const store = createNormalizedCacheStore(cache);\n\n return async function runWithCache<T extends SerializableCacheValue>(\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n ): Promise<RunWithCacheResult<T>> {\n if (options.strategy.mode === NO_STORE) {\n return { data: (await runAndValidate(run)).data, cacheStatus: \"bypass\" };\n }\n\n const cacheKey = await hashCacheKey(options.key);\n\n let cached: CacheEnvelope<T> | undefined;\n\n try {\n cached = await store.get<T>(cacheKey);\n } catch {}\n\n if (cached) {\n const state = getCacheState(cached, options.strategy);\n\n if (state === \"fresh\") return { data: cached.value, cacheStatus: \"hit\" };\n\n if (state === \"stale\") {\n revalidateInBackground(cacheKey, options, run);\n return { data: cached.value, cacheStatus: \"hit\" };\n }\n\n if (state === \"stale-if-error\") {\n return refreshWithStaleFallback(cacheKey, cached.value, options, run);\n }\n }\n\n return runAndMaybeStore(cacheKey, options, run).result;\n };\n\n function revalidateInBackground<T extends SerializableCacheValue>(\n cacheKey: string,\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n ) {\n const entry = runAndMaybeStore(cacheKey, options, run, { scheduleCacheWrite: false });\n schedule(entry.complete);\n }\n\n async function refreshWithStaleFallback<T extends SerializableCacheValue>(\n cacheKey: string,\n staleValue: T,\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n ): Promise<RunWithCacheResult<T>> {\n try {\n return await runAndMaybeStore(cacheKey, options, run).result;\n } catch (error) {\n if (!shouldFallbackToStale(error)) throw error;\n\n return { data: staleValue, cacheStatus: \"hit\" };\n }\n }\n\n function runAndMaybeStore<T extends SerializableCacheValue>(\n key: string,\n options: RunWithCacheOptions,\n run: () => MaybePromise<CacheDecision<T>>,\n { scheduleCacheWrite = true }: RunAndMaybeStoreOptions = {},\n ): CacheOperation<T> {\n // Assigned inside `result` once the callback has produced cacheable data.\n // `complete` reads the same variable later, so it follows the actual write\n // without making the foreground result wait when waitUntil is available.\n let storePromise: Promise<void> = Promise.resolve();\n\n const result = Promise.resolve().then(async (): Promise<RunWithCacheResult<T>> => {\n const decision = await runAndValidate(run);\n if (!shouldStore(options.strategy, decision)) {\n return { data: decision.data, cacheStatus: \"miss\" };\n }\n\n storePromise = storeDecision(key, options, decision).catch(() => {});\n\n if (waitUntil && scheduleCacheWrite) {\n schedule(storePromise);\n } else if (!waitUntil) {\n await storePromise;\n }\n\n return { data: decision.data, cacheStatus: \"miss\" };\n });\n\n return {\n result,\n complete: result\n .then(\n () => storePromise,\n () => undefined,\n )\n .then(() => undefined),\n };\n }\n\n async function storeDecision<T extends SerializableCacheValue>(\n key: string,\n options: RunWithCacheOptions,\n decision: CacheDecision<T>,\n ) {\n await store.set(\n key,\n {\n version: 1,\n value: decision.data,\n storedAt: Date.now(),\n strategy: options.strategy,\n },\n {\n strategy: options.strategy,\n },\n );\n }\n\n function schedule(promise: Promise<unknown>) {\n try {\n waitUntil?.(promise);\n } catch {}\n }\n}\n\nfunction shouldStore<T extends SerializableCacheValue>(\n strategy: CachingStrategy,\n decision: CacheDecision<T>,\n): boolean {\n return decision.shouldCache && getCacheRetentionTtl(strategy) > 0;\n}\n\nfunction shouldFallbackToStale(error: unknown): boolean {\n return !(error instanceof StaleFallbackDisabledError);\n}\n\nasync function runAndValidate<T extends SerializableCacheValue>(\n run: () => MaybePromise<CacheDecision<T>>,\n): Promise<CacheDecision<T>> {\n const decision = await run();\n\n if (\n typeof decision !== \"object\" ||\n decision == null ||\n !(\"data\" in decision) ||\n !(\"shouldCache\" in decision) ||\n typeof decision.shouldCache !== \"boolean\"\n ) {\n throw new TypeError(\"runWithCache callback must return {data, shouldCache}.\");\n }\n\n return decision;\n}\n\nfunction getCacheState<T extends SerializableCacheValue>(\n envelope: CacheEnvelope<T>,\n strategy: CachingStrategy,\n): CacheState {\n const age = Math.max(0, (Date.now() - envelope.storedAt) / 1000);\n const maxAge = strategy.maxAge ?? 0;\n const staleWhileRevalidate = strategy.staleWhileRevalidate ?? 0;\n const staleIfError = strategy.staleIfError ?? 0;\n\n if (age <= maxAge) return \"fresh\";\n if (age <= maxAge + staleWhileRevalidate) return \"stale\";\n if (age <= maxAge + staleWhileRevalidate + staleIfError) {\n return \"stale-if-error\";\n }\n\n return \"expired\";\n}\n"],"mappings":";;;;;;;;;;AAiEA,IAAa,6BAAb,cAAgD,MAAM;AAEtD,SAAgB,mBAAmB,EAAE,OAAO,aAAsD;CAChG,MAAM,QAAQ,2BAA2B,MAAM;AAE/C,QAAO,eAAe,aACpB,SACA,KACgC;AAChC,MAAI,QAAQ,SAAS,oBACnB,QAAO;GAAE,OAAO,MAAM,eAAe,IAAI,EAAE;GAAM,aAAa;GAAU;EAG1E,MAAM,WAAW,MAAM,aAAa,QAAQ,IAAI;EAEhD,IAAI;AAEJ,MAAI;AACF,YAAS,MAAM,MAAM,IAAO,SAAS;UAC/B;AAER,MAAI,QAAQ;GACV,MAAM,QAAQ,cAAc,QAAQ,QAAQ,SAAS;AAErD,OAAI,UAAU,QAAS,QAAO;IAAE,MAAM,OAAO;IAAO,aAAa;IAAO;AAExE,OAAI,UAAU,SAAS;AACrB,2BAAuB,UAAU,SAAS,IAAI;AAC9C,WAAO;KAAE,MAAM,OAAO;KAAO,aAAa;KAAO;;AAGnD,OAAI,UAAU,iBACZ,QAAO,yBAAyB,UAAU,OAAO,OAAO,SAAS,IAAI;;AAIzE,SAAO,iBAAiB,UAAU,SAAS,IAAI,CAAC;;CAGlD,SAAS,uBACP,UACA,SACA,KACA;AAEA,WADc,iBAAiB,UAAU,SAAS,KAAK,EAAE,oBAAoB,OAAO,CACtE,CAAC,SAAS;;CAG1B,eAAe,yBACb,UACA,YACA,SACA,KACgC;AAChC,MAAI;AACF,UAAO,MAAM,iBAAiB,UAAU,SAAS,IAAI,CAAC;WAC/C,OAAO;AACd,OAAI,CAAC,sBAAsB,MAAM,CAAE,OAAM;AAEzC,UAAO;IAAE,MAAM;IAAY,aAAa;IAAO;;;CAInD,SAAS,iBACP,KACA,SACA,KACA,EAAE,qBAAqB,SAAkC,EAAE,EACxC;EAInB,IAAI,eAA8B,QAAQ,SAAS;EAEnD,MAAM,SAAS,QAAQ,SAAS,CAAC,KAAK,YAA4C;GAChF,MAAM,WAAW,MAAM,eAAe,IAAI;AAC1C,OAAI,CAAC,YAAY,QAAQ,UAAU,SAAS,CAC1C,QAAO;IAAE,MAAM,SAAS;IAAM,aAAa;IAAQ;AAGrD,kBAAe,cAAc,KAAK,SAAS,SAAS,CAAC,YAAY,GAAG;AAEpE,OAAI,aAAa,mBACf,UAAS,aAAa;YACb,CAAC,UACV,OAAM;AAGR,UAAO;IAAE,MAAM,SAAS;IAAM,aAAa;IAAQ;IACnD;AAEF,SAAO;GACL;GACA,UAAU,OACP,WACO,oBACA,OACP,CACA,WAAW,OAAU;GACzB;;CAGH,eAAe,cACb,KACA,SACA,UACA;AACA,QAAM,MAAM,IACV,KACA;GACE,SAAS;GACT,OAAO,SAAS;GAChB,UAAU,KAAK,KAAK;GACpB,UAAU,QAAQ;GACnB,EACD,EACE,UAAU,QAAQ,UACnB,CACF;;CAGH,SAAS,SAAS,SAA2B;AAC3C,MAAI;AACF,eAAY,QAAQ;UACd;;;AAIZ,SAAS,YACP,UACA,UACS;AACT,QAAO,SAAS,eAAe,qBAAqB,SAAS,GAAG;;AAGlE,SAAS,sBAAsB,OAAyB;AACtD,QAAO,EAAE,iBAAiB;;AAG5B,eAAe,eACb,KAC2B;CAC3B,MAAM,WAAW,MAAM,KAAK;AAE5B,KACE,OAAO,aAAa,YACpB,YAAY,QACZ,EAAE,UAAU,aACZ,EAAE,iBAAiB,aACnB,OAAO,SAAS,gBAAgB,UAEhC,OAAM,IAAI,UAAU,yDAAyD;AAG/E,QAAO;;AAGT,SAAS,cACP,UACA,UACY;CACZ,MAAM,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,GAAG,SAAS,YAAY,IAAK;CAChE,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,uBAAuB,SAAS,wBAAwB;CAC9D,MAAM,eAAe,SAAS,gBAAgB;AAE9C,KAAI,OAAO,OAAQ,QAAO;AAC1B,KAAI,OAAO,SAAS,qBAAsB,QAAO;AACjD,KAAI,OAAO,SAAS,uBAAuB,aACzC,QAAO;AAGT,QAAO"}
@@ -0,0 +1,19 @@
1
+ //#region src/core/cache/store.d.ts
2
+ /**
3
+ * Cache values must be JSON-serializable because Web Cache stores serialize
4
+ * envelopes before persistence. Callers are responsible for returning data that
5
+ * can safely round-trip through `JSON.stringify`.
6
+ */
7
+ type SerializableCacheValue = Record<string, unknown>;
8
+ type WebCacheLike = Pick<Cache, "match" | "put" | "delete">;
9
+ type KeyValueCacheSetOptions = {
10
+ ttl?: number;
11
+ };
12
+ type KeyValueCacheLike = {
13
+ get(key: string): unknown | Promise<unknown>;
14
+ set(key: string, value: unknown, options?: KeyValueCacheSetOptions): unknown | Promise<unknown>;
15
+ delete?(key: string): unknown | Promise<unknown>;
16
+ };
17
+ //#endregion
18
+ export { KeyValueCacheLike, SerializableCacheValue, WebCacheLike };
19
+ //# sourceMappingURL=store.d.mts.map
@@ -0,0 +1,62 @@
1
+ import { getCacheRetentionTtl, getPlatformCacheControlHeader } from "./strategies.mjs";
2
+
3
+ //#region src/core/cache/store.ts
4
+ function createNormalizedCacheStore(cache) {
5
+ if (isWebCacheLike(cache)) return createWebCacheStore(cache);
6
+ if (isKeyValueCacheLike(cache)) return createKeyValueCacheStore(cache);
7
+ throw new TypeError("Expected a Web Cache API compatible store or a key/value cache store.");
8
+ }
9
+ function createWebCacheStore(cache) {
10
+ return {
11
+ async get(key) {
12
+ const response = await cache.match(createCacheRequest(key));
13
+ if (!response) return void 0;
14
+ const envelope = JSON.parse(await response.text());
15
+ return isCacheEnvelope(envelope) ? envelope : void 0;
16
+ },
17
+ async set(key, envelope, { strategy }) {
18
+ const response = new Response(JSON.stringify(envelope), { headers: {
19
+ "cache-control": getPlatformCacheControlHeader(strategy),
20
+ "content-type": "application/json"
21
+ } });
22
+ await cache.put(createCacheRequest(key), response);
23
+ },
24
+ async delete(key) {
25
+ await cache.delete(createCacheRequest(key));
26
+ }
27
+ };
28
+ }
29
+ function createKeyValueCacheStore(cache) {
30
+ return {
31
+ async get(key) {
32
+ const envelope = await cache.get(key);
33
+ return isCacheEnvelope(envelope) ? envelope : void 0;
34
+ },
35
+ async set(key, envelope, { strategy }) {
36
+ const ttl = Math.ceil(getCacheRetentionTtl(strategy));
37
+ await cache.set(key, envelope, { ttl });
38
+ },
39
+ async delete(key) {
40
+ await cache.delete?.(key);
41
+ }
42
+ };
43
+ }
44
+ function createCacheRequest(key) {
45
+ return new Request(`https://hydrogen.cache/${key}`);
46
+ }
47
+ function isWebCacheLike(cache) {
48
+ return typeof cache === "object" && cache != null && "match" in cache && "put" in cache && typeof cache.match === "function" && typeof cache.put === "function";
49
+ }
50
+ function isKeyValueCacheLike(cache) {
51
+ return typeof cache === "object" && cache != null && "get" in cache && "set" in cache && typeof cache.get === "function" && typeof cache.set === "function";
52
+ }
53
+ function isCacheEnvelope(value) {
54
+ return typeof value === "object" && value != null && "version" in value && value.version === 1 && "storedAt" in value && typeof value.storedAt === "number" && "strategy" in value && Boolean(value.strategy) && "value" in value && isSerializableCacheValue(value.value);
55
+ }
56
+ function isSerializableCacheValue(value) {
57
+ return typeof value === "object" && value != null && !Array.isArray(value);
58
+ }
59
+
60
+ //#endregion
61
+ export { createNormalizedCacheStore };
62
+ //# sourceMappingURL=store.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.mjs","names":[],"sources":["../../../src/core/cache/store.ts"],"sourcesContent":["import {\n type CachingStrategy,\n getPlatformCacheControlHeader,\n getCacheRetentionTtl,\n} from \"./strategies\";\n\n/**\n * Cache values must be JSON-serializable because Web Cache stores serialize\n * envelopes before persistence. Callers are responsible for returning data that\n * can safely round-trip through `JSON.stringify`.\n */\nexport type SerializableCacheValue = Record<string, unknown>;\n\nexport type CacheEnvelope<T extends SerializableCacheValue = SerializableCacheValue> = {\n version: 1;\n value: T;\n storedAt: number;\n strategy: CachingStrategy;\n};\n\nexport type WebCacheLike = Pick<Cache, \"match\" | \"put\" | \"delete\">;\n\nexport type KeyValueCacheSetOptions = {\n ttl?: number;\n};\n\nexport type KeyValueCacheLike = {\n get(key: string): unknown | Promise<unknown>;\n set(key: string, value: unknown, options?: KeyValueCacheSetOptions): unknown | Promise<unknown>;\n delete?(key: string): unknown | Promise<unknown>;\n};\n\ntype NormalizedCacheStore = {\n get<T extends SerializableCacheValue>(key: string): Promise<CacheEnvelope<T> | undefined>;\n set<T extends SerializableCacheValue>(\n key: string,\n envelope: CacheEnvelope<T>,\n options: NormalizedCacheSetOptions,\n ): Promise<void>;\n delete?(key: string): Promise<void>;\n};\n\ntype NormalizedCacheSetOptions = {\n strategy: CachingStrategy;\n};\n\nexport function createNormalizedCacheStore(\n cache: WebCacheLike | KeyValueCacheLike,\n): NormalizedCacheStore {\n if (isWebCacheLike(cache)) return createWebCacheStore(cache);\n if (isKeyValueCacheLike(cache)) return createKeyValueCacheStore(cache);\n\n throw new TypeError(\"Expected a Web Cache API compatible store or a key/value cache store.\");\n}\n\nfunction createWebCacheStore(cache: WebCacheLike): NormalizedCacheStore {\n return {\n async get<T extends SerializableCacheValue>(key: string) {\n const response = await cache.match(createCacheRequest(key));\n if (!response) return undefined;\n\n const envelope: unknown = JSON.parse(await response.text());\n return isCacheEnvelope<T>(envelope) ? envelope : undefined;\n },\n\n async set<T extends SerializableCacheValue>(\n key: string,\n envelope: CacheEnvelope<T>,\n { strategy }: NormalizedCacheSetOptions,\n ) {\n const response = new Response(JSON.stringify(envelope), {\n headers: {\n \"cache-control\": getPlatformCacheControlHeader(strategy),\n \"content-type\": \"application/json\",\n },\n });\n\n await cache.put(createCacheRequest(key), response);\n },\n\n async delete(key) {\n await cache.delete(createCacheRequest(key));\n },\n };\n}\n\nfunction createKeyValueCacheStore(cache: KeyValueCacheLike): NormalizedCacheStore {\n return {\n async get<T extends SerializableCacheValue>(key: string) {\n const envelope = await cache.get(key);\n return isCacheEnvelope<T>(envelope) ? envelope : undefined;\n },\n\n async set<T extends SerializableCacheValue>(\n key: string,\n envelope: CacheEnvelope<T>,\n { strategy }: NormalizedCacheSetOptions,\n ) {\n const ttl = Math.ceil(getCacheRetentionTtl(strategy));\n\n await cache.set(key, envelope, { ttl });\n },\n\n async delete(key) {\n await cache.delete?.(key);\n },\n };\n}\n\nfunction createCacheRequest(key: string) {\n return new Request(`https://hydrogen.cache/${key}`);\n}\n\nfunction isWebCacheLike(cache: unknown): cache is WebCacheLike {\n return (\n typeof cache === \"object\" &&\n cache != null &&\n \"match\" in cache &&\n \"put\" in cache &&\n typeof cache.match === \"function\" &&\n typeof cache.put === \"function\"\n );\n}\n\nfunction isKeyValueCacheLike(cache: unknown): cache is KeyValueCacheLike {\n return (\n typeof cache === \"object\" &&\n cache != null &&\n \"get\" in cache &&\n \"set\" in cache &&\n typeof cache.get === \"function\" &&\n typeof cache.set === \"function\"\n );\n}\n\nfunction isCacheEnvelope<T extends SerializableCacheValue>(\n value: unknown,\n): value is CacheEnvelope<T> {\n return (\n typeof value === \"object\" &&\n value != null &&\n \"version\" in value &&\n value.version === 1 &&\n \"storedAt\" in value &&\n typeof value.storedAt === \"number\" &&\n // Freshness uses the call-site strategy, but stored envelopes should still\n // look like the current shape so older or malformed entries do not become hits.\n \"strategy\" in value &&\n Boolean(value.strategy) &&\n \"value\" in value &&\n isSerializableCacheValue(value.value)\n );\n}\n\nfunction isSerializableCacheValue(value: unknown): value is SerializableCacheValue {\n return typeof value === \"object\" && value != null && !Array.isArray(value);\n}\n"],"mappings":";;;AA8CA,SAAgB,2BACd,OACsB;AACtB,KAAI,eAAe,MAAM,CAAE,QAAO,oBAAoB,MAAM;AAC5D,KAAI,oBAAoB,MAAM,CAAE,QAAO,yBAAyB,MAAM;AAEtE,OAAM,IAAI,UAAU,wEAAwE;;AAG9F,SAAS,oBAAoB,OAA2C;AACtE,QAAO;EACL,MAAM,IAAsC,KAAa;GACvD,MAAM,WAAW,MAAM,MAAM,MAAM,mBAAmB,IAAI,CAAC;AAC3D,OAAI,CAAC,SAAU,QAAO;GAEtB,MAAM,WAAoB,KAAK,MAAM,MAAM,SAAS,MAAM,CAAC;AAC3D,UAAO,gBAAmB,SAAS,GAAG,WAAW;;EAGnD,MAAM,IACJ,KACA,UACA,EAAE,YACF;GACA,MAAM,WAAW,IAAI,SAAS,KAAK,UAAU,SAAS,EAAE,EACtD,SAAS;IACP,iBAAiB,8BAA8B,SAAS;IACxD,gBAAgB;IACjB,EACF,CAAC;AAEF,SAAM,MAAM,IAAI,mBAAmB,IAAI,EAAE,SAAS;;EAGpD,MAAM,OAAO,KAAK;AAChB,SAAM,MAAM,OAAO,mBAAmB,IAAI,CAAC;;EAE9C;;AAGH,SAAS,yBAAyB,OAAgD;AAChF,QAAO;EACL,MAAM,IAAsC,KAAa;GACvD,MAAM,WAAW,MAAM,MAAM,IAAI,IAAI;AACrC,UAAO,gBAAmB,SAAS,GAAG,WAAW;;EAGnD,MAAM,IACJ,KACA,UACA,EAAE,YACF;GACA,MAAM,MAAM,KAAK,KAAK,qBAAqB,SAAS,CAAC;AAErD,SAAM,MAAM,IAAI,KAAK,UAAU,EAAE,KAAK,CAAC;;EAGzC,MAAM,OAAO,KAAK;AAChB,SAAM,MAAM,SAAS,IAAI;;EAE5B;;AAGH,SAAS,mBAAmB,KAAa;AACvC,QAAO,IAAI,QAAQ,0BAA0B,MAAM;;AAGrD,SAAS,eAAe,OAAuC;AAC7D,QACE,OAAO,UAAU,YACjB,SAAS,QACT,WAAW,SACX,SAAS,SACT,OAAO,MAAM,UAAU,cACvB,OAAO,MAAM,QAAQ;;AAIzB,SAAS,oBAAoB,OAA4C;AACvE,QACE,OAAO,UAAU,YACjB,SAAS,QACT,SAAS,SACT,SAAS,SACT,OAAO,MAAM,QAAQ,cACrB,OAAO,MAAM,QAAQ;;AAIzB,SAAS,gBACP,OAC2B;AAC3B,QACE,OAAO,UAAU,YACjB,SAAS,QACT,aAAa,SACb,MAAM,YAAY,KAClB,cAAc,SACd,OAAO,MAAM,aAAa,YAG1B,cAAc,SACd,QAAQ,MAAM,SAAS,IACvB,WAAW,SACX,yBAAyB,MAAM,MAAM;;AAIzC,SAAS,yBAAyB,OAAiD;AACjF,QAAO,OAAO,UAAU,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,MAAM"}
@@ -0,0 +1,39 @@
1
+ //#region src/core/cache/strategies.d.ts
2
+ declare const NO_STORE = "no-store";
3
+ declare const PUBLIC = "public";
4
+ declare const PRIVATE = "private";
5
+ type CacheMode = typeof PUBLIC | typeof PRIVATE | typeof NO_STORE;
6
+ type ExpirableCacheMode = typeof PUBLIC | typeof PRIVATE;
7
+ type CacheDuration = number | {
8
+ seconds?: number;
9
+ minutes?: number;
10
+ hours?: number;
11
+ days?: number;
12
+ };
13
+ interface CachingStrategy {
14
+ mode?: CacheMode;
15
+ maxAge?: number;
16
+ staleWhileRevalidate?: number;
17
+ staleIfError?: number;
18
+ }
19
+ type CacheOptions = {
20
+ mode?: ExpirableCacheMode;
21
+ maxAge?: CacheDuration;
22
+ staleWhileRevalidate?: CacheDuration;
23
+ staleIfError?: CacheDuration;
24
+ };
25
+ type NoStoreStrategy = CachingStrategy & {
26
+ mode: typeof NO_STORE;
27
+ };
28
+ declare const Cache: typeof createCache & {
29
+ none: typeof cacheNone;
30
+ short: typeof cacheShort;
31
+ long: typeof cacheLong;
32
+ };
33
+ declare function createCache(options: CacheOptions): CachingStrategy;
34
+ declare function cacheNone(): NoStoreStrategy;
35
+ declare function cacheShort(overrideOptions?: CacheOptions): CachingStrategy;
36
+ declare function cacheLong(overrideOptions?: CacheOptions): CachingStrategy;
37
+ //#endregion
38
+ export { Cache, CacheOptions, CachingStrategy };
39
+ //# sourceMappingURL=strategies.d.mts.map
@@ -0,0 +1,70 @@
1
+ //#region src/core/cache/strategies.ts
2
+ const NO_STORE = "no-store";
3
+ const PUBLIC = "public";
4
+ const PRIVATE = "private";
5
+ const Cache = Object.assign(createCache, {
6
+ none: cacheNone,
7
+ short: cacheShort,
8
+ long: cacheLong
9
+ });
10
+ function getCacheRetentionTtl(strategy) {
11
+ if (strategy.mode === "no-store") return 0;
12
+ return Math.max(0, (strategy.maxAge ?? 0) + (strategy.staleWhileRevalidate ?? 0) + (strategy.staleIfError ?? 0));
13
+ }
14
+ function getPlatformCacheControlHeader(strategy) {
15
+ const ttl = getCacheRetentionTtl(strategy);
16
+ if (ttl <= 0) return NO_STORE;
17
+ return `${strategy.mode ?? PUBLIC}, max-age=${Math.ceil(ttl)}`;
18
+ }
19
+ function createCache(options) {
20
+ return normalizeCacheOptions(options);
21
+ }
22
+ function cacheNone() {
23
+ return { mode: NO_STORE };
24
+ }
25
+ function cacheShort(overrideOptions) {
26
+ return normalizeCacheOptions({
27
+ mode: PUBLIC,
28
+ maxAge: 1,
29
+ staleWhileRevalidate: 9
30
+ }, overrideOptions);
31
+ }
32
+ function cacheLong(overrideOptions) {
33
+ return normalizeCacheOptions({
34
+ mode: PUBLIC,
35
+ maxAge: 3600,
36
+ staleWhileRevalidate: 82800
37
+ }, overrideOptions);
38
+ }
39
+ function normalizeCacheOptions(defaultsOrOptions, overrideOptions) {
40
+ const options = {
41
+ ...defaultsOrOptions,
42
+ ...overrideOptions
43
+ };
44
+ return {
45
+ ...normalizeMode(options),
46
+ ...normalizeDurationOption("maxAge", options.maxAge),
47
+ ...normalizeDurationOption("staleWhileRevalidate", options.staleWhileRevalidate),
48
+ ...normalizeDurationOption("staleIfError", options.staleIfError)
49
+ };
50
+ }
51
+ function normalizeMode(options) {
52
+ if (options.mode && options.mode !== PUBLIC && options.mode !== PRIVATE) throw new Error("'mode' must be either 'public' or 'private'");
53
+ return { mode: options.mode ?? PUBLIC };
54
+ }
55
+ function normalizeDurationOption(name, duration) {
56
+ if (duration == null) return {};
57
+ return { [name]: normalizeDuration(duration) };
58
+ }
59
+ function normalizeDuration(duration) {
60
+ if (typeof duration === "number") return validateDuration(duration);
61
+ return validateDuration((duration.seconds ?? 0) + (duration.minutes ?? 0) * 60 + (duration.hours ?? 0) * 3600 + (duration.days ?? 0) * 86400);
62
+ }
63
+ function validateDuration(duration) {
64
+ if (!Number.isFinite(duration) || duration < 0) throw new Error("Cache durations must be finite, non-negative numbers.");
65
+ return Math.ceil(duration);
66
+ }
67
+
68
+ //#endregion
69
+ export { Cache, NO_STORE, getCacheRetentionTtl, getPlatformCacheControlHeader };
70
+ //# sourceMappingURL=strategies.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategies.mjs","names":[],"sources":["../../../src/core/cache/strategies.ts"],"sourcesContent":["export const NO_STORE = \"no-store\";\n\nconst PUBLIC = \"public\";\nconst PRIVATE = \"private\";\n\nexport type CacheMode = typeof PUBLIC | typeof PRIVATE | typeof NO_STORE;\nexport type ExpirableCacheMode = typeof PUBLIC | typeof PRIVATE;\n\nexport type CacheDuration =\n | number\n | {\n seconds?: number;\n minutes?: number;\n hours?: number;\n days?: number;\n };\n\nexport interface CachingStrategy {\n mode?: CacheMode;\n maxAge?: number;\n staleWhileRevalidate?: number;\n staleIfError?: number;\n}\n\nexport type CacheOptions = {\n mode?: ExpirableCacheMode;\n maxAge?: CacheDuration;\n staleWhileRevalidate?: CacheDuration;\n staleIfError?: CacheDuration;\n};\n\ntype NoStoreStrategy = CachingStrategy & {\n mode: typeof NO_STORE;\n};\n\nexport const Cache = Object.assign(createCache, {\n none: cacheNone,\n short: cacheShort,\n long: cacheLong,\n});\n\nexport function getCacheRetentionTtl(strategy: CachingStrategy): number {\n if (strategy.mode === NO_STORE) return 0;\n\n return Math.max(\n 0,\n (strategy.maxAge ?? 0) + (strategy.staleWhileRevalidate ?? 0) + (strategy.staleIfError ?? 0),\n );\n}\n\nexport function getPlatformCacheControlHeader(strategy: CachingStrategy): string {\n const ttl = getCacheRetentionTtl(strategy);\n if (ttl <= 0) return NO_STORE;\n\n return `${strategy.mode ?? PUBLIC}, max-age=${Math.ceil(ttl)}`;\n}\n\nfunction createCache(options: CacheOptions): CachingStrategy {\n return normalizeCacheOptions(options);\n}\n\nfunction cacheNone(): NoStoreStrategy {\n return { mode: NO_STORE };\n}\n\nfunction cacheShort(overrideOptions?: CacheOptions): CachingStrategy {\n return normalizeCacheOptions(\n {\n mode: PUBLIC,\n maxAge: 1,\n staleWhileRevalidate: 9,\n },\n overrideOptions,\n );\n}\n\nfunction cacheLong(overrideOptions?: CacheOptions): CachingStrategy {\n return normalizeCacheOptions(\n {\n mode: PUBLIC,\n maxAge: 3600,\n staleWhileRevalidate: 82800,\n },\n overrideOptions,\n );\n}\n\nfunction normalizeCacheOptions(\n defaults: CacheOptions,\n overrideOptions?: CacheOptions,\n): CachingStrategy;\nfunction normalizeCacheOptions(options: CacheOptions): CachingStrategy;\nfunction normalizeCacheOptions(\n defaultsOrOptions: CacheOptions,\n overrideOptions?: CacheOptions,\n): CachingStrategy {\n const options = {\n ...defaultsOrOptions,\n ...overrideOptions,\n };\n\n return {\n ...normalizeMode(options),\n ...normalizeDurationOption(\"maxAge\", options.maxAge),\n ...normalizeDurationOption(\"staleWhileRevalidate\", options.staleWhileRevalidate),\n ...normalizeDurationOption(\"staleIfError\", options.staleIfError),\n };\n}\n\nfunction normalizeMode(options: CacheOptions): Pick<CachingStrategy, \"mode\"> {\n if (options.mode && options.mode !== PUBLIC && options.mode !== PRIVATE) {\n throw new Error(\"'mode' must be either 'public' or 'private'\");\n }\n\n return { mode: options.mode ?? PUBLIC };\n}\n\nfunction normalizeDurationOption(\n name: \"maxAge\" | \"staleWhileRevalidate\" | \"staleIfError\",\n duration: CacheDuration | undefined,\n): Pick<CachingStrategy, typeof name> {\n if (duration == null) return {};\n\n return { [name]: normalizeDuration(duration) };\n}\n\nfunction normalizeDuration(duration: CacheDuration): number {\n if (typeof duration === \"number\") return validateDuration(duration);\n\n return validateDuration(\n (duration.seconds ?? 0) +\n (duration.minutes ?? 0) * 60 +\n (duration.hours ?? 0) * 3600 +\n (duration.days ?? 0) * 86400,\n );\n}\n\nfunction validateDuration(duration: number): number {\n if (!Number.isFinite(duration) || duration < 0) {\n throw new Error(\"Cache durations must be finite, non-negative numbers.\");\n }\n\n return Math.ceil(duration);\n}\n"],"mappings":";AAAA,MAAa,WAAW;AAExB,MAAM,SAAS;AACf,MAAM,UAAU;AAgChB,MAAa,QAAQ,OAAO,OAAO,aAAa;CAC9C,MAAM;CACN,OAAO;CACP,MAAM;CACP,CAAC;AAEF,SAAgB,qBAAqB,UAAmC;AACtE,KAAI,SAAS,oBAAmB,QAAO;AAEvC,QAAO,KAAK,IACV,IACC,SAAS,UAAU,MAAM,SAAS,wBAAwB,MAAM,SAAS,gBAAgB,GAC3F;;AAGH,SAAgB,8BAA8B,UAAmC;CAC/E,MAAM,MAAM,qBAAqB,SAAS;AAC1C,KAAI,OAAO,EAAG,QAAO;AAErB,QAAO,GAAG,SAAS,QAAQ,OAAO,YAAY,KAAK,KAAK,IAAI;;AAG9D,SAAS,YAAY,SAAwC;AAC3D,QAAO,sBAAsB,QAAQ;;AAGvC,SAAS,YAA6B;AACpC,QAAO,EAAE,MAAM,UAAU;;AAG3B,SAAS,WAAW,iBAAiD;AACnE,QAAO,sBACL;EACE,MAAM;EACN,QAAQ;EACR,sBAAsB;EACvB,EACD,gBACD;;AAGH,SAAS,UAAU,iBAAiD;AAClE,QAAO,sBACL;EACE,MAAM;EACN,QAAQ;EACR,sBAAsB;EACvB,EACD,gBACD;;AAQH,SAAS,sBACP,mBACA,iBACiB;CACjB,MAAM,UAAU;EACd,GAAG;EACH,GAAG;EACJ;AAED,QAAO;EACL,GAAG,cAAc,QAAQ;EACzB,GAAG,wBAAwB,UAAU,QAAQ,OAAO;EACpD,GAAG,wBAAwB,wBAAwB,QAAQ,qBAAqB;EAChF,GAAG,wBAAwB,gBAAgB,QAAQ,aAAa;EACjE;;AAGH,SAAS,cAAc,SAAsD;AAC3E,KAAI,QAAQ,QAAQ,QAAQ,SAAS,UAAU,QAAQ,SAAS,QAC9D,OAAM,IAAI,MAAM,8CAA8C;AAGhE,QAAO,EAAE,MAAM,QAAQ,QAAQ,QAAQ;;AAGzC,SAAS,wBACP,MACA,UACoC;AACpC,KAAI,YAAY,KAAM,QAAO,EAAE;AAE/B,QAAO,GAAG,OAAO,kBAAkB,SAAS,EAAE;;AAGhD,SAAS,kBAAkB,UAAiC;AAC1D,KAAI,OAAO,aAAa,SAAU,QAAO,iBAAiB,SAAS;AAEnE,QAAO,kBACJ,SAAS,WAAW,MAClB,SAAS,WAAW,KAAK,MACzB,SAAS,SAAS,KAAK,QACvB,SAAS,QAAQ,KAAK,MAC1B;;AAGH,SAAS,iBAAiB,UAA0B;AAClD,KAAI,CAAC,OAAO,SAAS,SAAS,IAAI,WAAW,EAC3C,OAAM,IAAI,MAAM,wDAAwD;AAG1E,QAAO,KAAK,KAAK,SAAS"}
@@ -0,0 +1,50 @@
1
+ //#region src/core/cart/actions.d.ts
2
+ type CartAttributeInput = {
3
+ key: string;
4
+ value: string;
5
+ };
6
+ type CartLineAddInput = {
7
+ merchandiseId: string;
8
+ quantity: number;
9
+ attributes?: CartAttributeInput[];
10
+ sellingPlanId?: string;
11
+ };
12
+ type CartLineUpdateInput = {
13
+ id: string;
14
+ quantity: number;
15
+ attributes?: CartAttributeInput[];
16
+ sellingPlanId?: string;
17
+ };
18
+ type CartAction = {
19
+ intent: "add";
20
+ lines: CartLineAddInput[];
21
+ } | {
22
+ intent: "update";
23
+ lines: CartLineUpdateInput[];
24
+ } | {
25
+ intent: "remove";
26
+ lineIds: string[];
27
+ } | {
28
+ intent: "discount-update";
29
+ discountCodes: string[];
30
+ } | {
31
+ intent: "discount-apply";
32
+ code: string;
33
+ } | {
34
+ intent: "discount-remove";
35
+ code: string;
36
+ } | {
37
+ intent: "attributes-update";
38
+ attributes: CartAttributeInput[];
39
+ } | {
40
+ intent: "note-update";
41
+ note: string;
42
+ };
43
+ type ParsedCartRequest = {
44
+ action: CartAction;
45
+ cartId: string | null;
46
+ };
47
+ declare function parseCartRequest(request: Request): Promise<ParsedCartRequest>;
48
+ //#endregion
49
+ export { CartAction, CartAttributeInput, CartLineAddInput, CartLineUpdateInput, parseCartRequest };
50
+ //# sourceMappingURL=actions.d.mts.map
@@ -0,0 +1,240 @@
1
+ import { normalizeCartId } from "./cookie.mjs";
2
+ import { getCartAttributeFormEntries } from "./form.mjs";
3
+
4
+ //#region src/core/cart/actions.ts
5
+ var CartActionError = class extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "CartActionError";
9
+ }
10
+ };
11
+ async function parseCartRequest(request) {
12
+ const contentType = request.headers.get("content-type") ?? "";
13
+ if (contentType.includes("application/json")) return parseJsonBody(await request.json());
14
+ if (contentType.includes("application/x-www-form-urlencoded") || contentType.includes("multipart/form-data")) return {
15
+ action: parseFormData(await request.formData()),
16
+ cartId: null
17
+ };
18
+ throw new CartActionError(`Unsupported content-type: "${contentType}". Expected application/json or form data.`);
19
+ }
20
+ function parseJsonBody(body) {
21
+ assertObject(body);
22
+ const cartId = typeof body.cartId === "string" ? normalizeCartId(body.cartId) : null;
23
+ if ("note" in body && typeof body.note === "string") return {
24
+ action: {
25
+ intent: "note-update",
26
+ note: body.note
27
+ },
28
+ cartId
29
+ };
30
+ if ("discountCodes" in body && Array.isArray(body.discountCodes)) {
31
+ for (const code of body.discountCodes) assertString(code, "discountCodes entries");
32
+ return {
33
+ action: {
34
+ intent: "discount-update",
35
+ discountCodes: body.discountCodes
36
+ },
37
+ cartId
38
+ };
39
+ }
40
+ if ("attributes" in body && Array.isArray(body.attributes)) return {
41
+ action: {
42
+ intent: "attributes-update",
43
+ attributes: parseAttributes(body.attributes)
44
+ },
45
+ cartId
46
+ };
47
+ if (!("lines" in body) || !Array.isArray(body.lines)) throw new CartActionError("Request body must contain \"lines\", \"discountCodes\", \"attributes\", or \"note\".");
48
+ const lines = body.lines;
49
+ if (lines.length === 0) throw new CartActionError("Lines array must not be empty.");
50
+ return {
51
+ action: partitionLines(lines),
52
+ cartId
53
+ };
54
+ }
55
+ function partitionLines(rawLines) {
56
+ const adds = [];
57
+ const updates = [];
58
+ const removeIds = [];
59
+ for (const raw of rawLines) {
60
+ assertObject(raw);
61
+ const line = raw;
62
+ const hasId = "id" in line && typeof line.id === "string" && line.id !== "";
63
+ const hasMerchandiseId = "merchandiseId" in line && typeof line.merchandiseId === "string" && line.merchandiseId !== "";
64
+ assertNonNegativeInteger(line.quantity, "quantity");
65
+ const quantity = line.quantity;
66
+ if (!hasId && !hasMerchandiseId) throw new CartActionError("Each line must have either \"id\" (for update/remove) or \"merchandiseId\" (for add).");
67
+ if (hasId && line.id === "") throw new CartActionError("Line \"id\" must not be empty.");
68
+ const optionalFields = extractOptionalLineFields(line);
69
+ if (!hasId && hasMerchandiseId) adds.push({
70
+ merchandiseId: line.merchandiseId,
71
+ quantity,
72
+ ...optionalFields
73
+ });
74
+ else if (hasId && quantity === 0) removeIds.push(line.id);
75
+ else if (hasId) updates.push({
76
+ id: line.id,
77
+ quantity,
78
+ ...optionalFields
79
+ });
80
+ }
81
+ if ([
82
+ adds.length,
83
+ updates.length,
84
+ removeIds.length
85
+ ].filter((n) => n > 0).length > 1) throw new CartActionError("Mixed line operations are not allowed. Separate add, update, and remove into distinct requests.");
86
+ if (adds.length > 0) return {
87
+ intent: "add",
88
+ lines: adds
89
+ };
90
+ if (updates.length > 0) return {
91
+ intent: "update",
92
+ lines: updates
93
+ };
94
+ return {
95
+ intent: "remove",
96
+ lineIds: removeIds
97
+ };
98
+ }
99
+ function extractOptionalLineFields(line) {
100
+ const result = {};
101
+ if ("attributes" in line && Array.isArray(line.attributes)) result.attributes = line.attributes;
102
+ if ("sellingPlanId" in line && typeof line.sellingPlanId === "string") result.sellingPlanId = line.sellingPlanId;
103
+ return result;
104
+ }
105
+ const LINE_INTENTS = new Set([
106
+ "increase",
107
+ "decrease",
108
+ "remove",
109
+ "set"
110
+ ]);
111
+ const DISCOUNT_INTENTS = new Set(["discount-apply", "discount-remove"]);
112
+ function parseFormData(form) {
113
+ const intent = formString(form, "intent");
114
+ const merchandiseId = formString(form, "merchandiseId");
115
+ if (!intent && merchandiseId) return parseAddIntent(form, merchandiseId);
116
+ if (intent === "add") {
117
+ if (!merchandiseId) throw new CartActionError("Intent \"add\" requires a \"merchandiseId\" field.");
118
+ return parseAddIntent(form, merchandiseId);
119
+ }
120
+ if (!intent) throw new CartActionError("FormData must include an \"intent\" field or a \"merchandiseId\" field.");
121
+ if (LINE_INTENTS.has(intent)) return parseLineIntent(intent, form);
122
+ if (DISCOUNT_INTENTS.has(intent)) return parseDiscountIntent(intent, form);
123
+ if (intent === "note-update") return parseNoteIntent(form);
124
+ if (intent === "attributes-update") return parseAttributesIntent(form);
125
+ throw new CartActionError(`Unknown intent "${intent}". Expected one of: add, increase, decrease, remove, set, discount-apply, discount-remove, attributes-update, note-update.`);
126
+ }
127
+ function parseLineIntent(intent, form) {
128
+ const lineId = formString(form, "lineId");
129
+ if (!lineId) throw new CartActionError(`Intent "${intent}" requires a "lineId" field.`);
130
+ if (intent === "remove") return {
131
+ intent: "remove",
132
+ lineIds: [lineId]
133
+ };
134
+ const quantity = formInt(form, "quantity");
135
+ if (quantity === null) throw new CartActionError(`Intent "${intent}" requires a "quantity" field.`);
136
+ if (intent === "set") {
137
+ if (quantity <= 0) return {
138
+ intent: "remove",
139
+ lineIds: [lineId]
140
+ };
141
+ return {
142
+ intent: "update",
143
+ lines: [{
144
+ id: lineId,
145
+ quantity
146
+ }]
147
+ };
148
+ }
149
+ if (intent === "increase") return {
150
+ intent: "update",
151
+ lines: [{
152
+ id: lineId,
153
+ quantity: quantity + 1
154
+ }]
155
+ };
156
+ const decremented = quantity - 1;
157
+ if (decremented <= 0) return {
158
+ intent: "remove",
159
+ lineIds: [lineId]
160
+ };
161
+ return {
162
+ intent: "update",
163
+ lines: [{
164
+ id: lineId,
165
+ quantity: decremented
166
+ }]
167
+ };
168
+ }
169
+ function parseDiscountIntent(intent, form) {
170
+ const code = formString(form, "discountCode");
171
+ if (!code) throw new CartActionError(`Intent "${intent}" requires a "discountCode" field.`);
172
+ return {
173
+ intent,
174
+ code
175
+ };
176
+ }
177
+ function parseAddIntent(form, merchandiseId) {
178
+ const quantity = formInt(form, "quantity") ?? 1;
179
+ const sellingPlanId = formString(form, "sellingPlanId");
180
+ const line = {
181
+ merchandiseId,
182
+ quantity
183
+ };
184
+ if (sellingPlanId) line.sellingPlanId = sellingPlanId;
185
+ return {
186
+ intent: "add",
187
+ lines: [line]
188
+ };
189
+ }
190
+ function parseNoteIntent(form) {
191
+ const noteValue = form.get("note");
192
+ if (noteValue === null) throw new CartActionError("Intent \"note-update\" requires a \"note\" field.");
193
+ return {
194
+ intent: "note-update",
195
+ note: String(noteValue)
196
+ };
197
+ }
198
+ function parseAttributesIntent(form) {
199
+ return {
200
+ intent: "attributes-update",
201
+ attributes: parseAttributes(getCartAttributeFormEntries(form))
202
+ };
203
+ }
204
+ function parseAttributes(values) {
205
+ return values.map((value, index) => {
206
+ assertObject(value);
207
+ assertString(value.key, `attributes[${index}].key`);
208
+ assertString(value.value, `attributes[${index}].value`);
209
+ if (!value.key) throw new CartActionError(`Expected "attributes[${index}].key" not to be empty.`);
210
+ return {
211
+ key: value.key,
212
+ value: value.value
213
+ };
214
+ });
215
+ }
216
+ function assertObject(value) {
217
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new CartActionError("Expected an object.");
218
+ }
219
+ function assertString(value, label) {
220
+ if (typeof value !== "string") throw new CartActionError(`Expected "${label}" to be a string.`);
221
+ }
222
+ function assertNonNegativeInteger(value, label) {
223
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) throw new CartActionError(`Expected "${label}" to be a non-negative integer, got ${JSON.stringify(value)}.`);
224
+ }
225
+ function formString(form, key) {
226
+ const value = form.get(key);
227
+ if (value === null || typeof value !== "string") return null;
228
+ return value || null;
229
+ }
230
+ function formInt(form, key) {
231
+ const raw = form.get(key);
232
+ if (raw === null || typeof raw !== "string") return null;
233
+ const parsed = parseInt(raw, 10);
234
+ if (Number.isNaN(parsed)) return null;
235
+ return parsed;
236
+ }
237
+
238
+ //#endregion
239
+ export { parseCartRequest };
240
+ //# sourceMappingURL=actions.mjs.map