@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
@@ -2,11 +2,19 @@ import { InitializeShopifyScriptsOptions } from "./types.mjs";
2
2
 
3
3
  //#region src/core/shopify-scripts/initialize.d.ts
4
4
  /**
5
- * Initializes Shopify browser script behavior for frameworks without a Hydrogen binding.
5
+ * Starts Shopify's scripts in the browser for frameworks without a Hydrogen binding. Call it after
6
+ * hydration, with the consent configuration that you passed to `getShopifyScriptTags`.
6
7
  *
7
- * This is the browser hydration half of `getShopifyScriptTags()`: framework bindings combine both
8
- * into a `ShopifyScripts` component, while custom integrations can render script tags during SSR
9
- * and call this helper from their browser lifecycle.
8
+ * The function sets up `window.Shopify.routes`, and sends a page view event on load and after each
9
+ * navigation that changes the path or query. In the custom banner consent mode, Hydrogen calls your
10
+ * setup callback after the Customer Privacy API loads. A custom banner configuration without a
11
+ * setup callback logs a warning, and analytics events stay blocked. When the browser supports
12
+ * WebMCP, the function also loads Shopify's WebMCP tools. Set `webMcp` to `false` to skip them.
13
+ *
14
+ * @param options - The consent configuration, the route settings, and whether to load WebMCP tools.
15
+ * @returns A promise that resolves after the WebMCP tools load or fail to load, or right away when the function skips WebMCP.
16
+ *
17
+ * @publicDocs
10
18
  */
11
19
  declare function initializeShopifyScripts({
12
20
  consent,
@@ -7,11 +7,19 @@ import { loadShopifyWebMcpTools } from "./webmcp.mjs";
7
7
  //#region src/core/shopify-scripts/initialize.ts
8
8
  const log = getLogger("consent");
9
9
  /**
10
- * Initializes Shopify browser script behavior for frameworks without a Hydrogen binding.
10
+ * Starts Shopify's scripts in the browser for frameworks without a Hydrogen binding. Call it after
11
+ * hydration, with the consent configuration that you passed to `getShopifyScriptTags`.
11
12
  *
12
- * This is the browser hydration half of `getShopifyScriptTags()`: framework bindings combine both
13
- * into a `ShopifyScripts` component, while custom integrations can render script tags during SSR
14
- * and call this helper from their browser lifecycle.
13
+ * The function sets up `window.Shopify.routes`, and sends a page view event on load and after each
14
+ * navigation that changes the path or query. In the custom banner consent mode, Hydrogen calls your
15
+ * setup callback after the Customer Privacy API loads. A custom banner configuration without a
16
+ * setup callback logs a warning, and analytics events stay blocked. When the browser supports
17
+ * WebMCP, the function also loads Shopify's WebMCP tools. Set `webMcp` to `false` to skip them.
18
+ *
19
+ * @param options - The consent configuration, the route settings, and whether to load WebMCP tools.
20
+ * @returns A promise that resolves after the WebMCP tools load or fail to load, or right away when the function skips WebMCP.
21
+ *
22
+ * @publicDocs
15
23
  */
16
24
  function initializeShopifyScripts({ consent, navigate, routes, webMcp = true }) {
17
25
  configureShopifyRouting({
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/initialize.ts"],"sourcesContent":["import { initializeCustomConsent } from \"../analytics/custom-consent\";\nimport { getLogger } from \"../logging\";\nimport { configureShopifyRouting } from \"./global\";\nimport { initializeShopifyPageViewEvents } from \"./page-view\";\nimport type { InitializeShopifyScriptsOptions } from \"./types\";\nimport { loadShopifyWebMcpTools } from \"./webmcp\";\n\nconst log = getLogger(\"consent\");\n\n/**\n * Initializes Shopify browser script behavior for frameworks without a Hydrogen binding.\n *\n * This is the browser hydration half of `getShopifyScriptTags()`: framework bindings combine both\n * into a `ShopifyScripts` component, while custom integrations can render script tags during SSR\n * and call this helper from their browser lifecycle.\n */\nexport function initializeShopifyScripts({\n consent,\n navigate,\n routes,\n webMcp = true,\n}: InitializeShopifyScriptsOptions): Promise<boolean | void> {\n configureShopifyRouting({ navigate, routes });\n initializeShopifyPageViewEvents();\n\n if (consent?.mode === \"custom-banner\") {\n if (typeof consent.setup !== \"function\") {\n log.warn(\n \"custom-banner requires a consent.setup callback; analytics delivery remains blocked until setup completes\",\n );\n } else {\n try {\n initializeCustomConsent(consent.setup);\n } catch (error) {\n log.error(\"custom consent initialization failed\", { error });\n }\n }\n }\n\n if (!webMcp) return Promise.resolve();\n\n return loadShopifyWebMcpTools();\n}\n"],"mappings":";;;;;;;AAOA,MAAM,MAAM,UAAU,UAAU;;;;;;;;AAShC,SAAgB,yBAAyB,EACvC,SACA,UACA,QACA,SAAS,QACkD;AAC3D,yBAAwB;EAAE;EAAU;EAAQ,CAAC;AAC7C,kCAAiC;AAEjC,KAAI,SAAS,SAAS,gBACpB,KAAI,OAAO,QAAQ,UAAU,WAC3B,KAAI,KACF,4GACD;KAED,KAAI;AACF,0BAAwB,QAAQ,MAAM;UAC/B,OAAO;AACd,MAAI,MAAM,wCAAwC,EAAE,OAAO,CAAC;;AAKlE,KAAI,CAAC,OAAQ,QAAO,QAAQ,SAAS;AAErC,QAAO,wBAAwB"}
1
+ {"version":3,"file":"initialize.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/initialize.ts"],"sourcesContent":["import { initializeCustomConsent } from \"../analytics/custom-consent\";\nimport { getLogger } from \"../logging\";\nimport { configureShopifyRouting } from \"./global\";\nimport { initializeShopifyPageViewEvents } from \"./page-view\";\nimport type { InitializeShopifyScriptsOptions } from \"./types\";\nimport { loadShopifyWebMcpTools } from \"./webmcp\";\n\nconst log = getLogger(\"consent\");\n\n/**\n * Starts Shopify's scripts in the browser for frameworks without a Hydrogen binding. Call it after\n * hydration, with the consent configuration that you passed to `getShopifyScriptTags`.\n *\n * The function sets up `window.Shopify.routes`, and sends a page view event on load and after each\n * navigation that changes the path or query. In the custom banner consent mode, Hydrogen calls your\n * setup callback after the Customer Privacy API loads. A custom banner configuration without a\n * setup callback logs a warning, and analytics events stay blocked. When the browser supports\n * WebMCP, the function also loads Shopify's WebMCP tools. Set `webMcp` to `false` to skip them.\n *\n * @param options - The consent configuration, the route settings, and whether to load WebMCP tools.\n * @returns A promise that resolves after the WebMCP tools load or fail to load, or right away when the function skips WebMCP.\n *\n * @publicDocs\n */\nexport function initializeShopifyScripts({\n consent,\n navigate,\n routes,\n webMcp = true,\n}: InitializeShopifyScriptsOptions): Promise<boolean | void> {\n configureShopifyRouting({ navigate, routes });\n initializeShopifyPageViewEvents();\n\n if (consent?.mode === \"custom-banner\") {\n if (typeof consent.setup !== \"function\") {\n log.warn(\n \"custom-banner requires a consent.setup callback; analytics delivery remains blocked until setup completes\",\n );\n } else {\n try {\n initializeCustomConsent(consent.setup);\n } catch (error) {\n log.error(\"custom consent initialization failed\", { error });\n }\n }\n }\n\n if (!webMcp) return Promise.resolve();\n\n return loadShopifyWebMcpTools();\n}\n"],"mappings":";;;;;;;AAOA,MAAM,MAAM,UAAU,UAAU;;;;;;;;;;;;;;;;AAiBhC,SAAgB,yBAAyB,EACvC,SACA,UACA,QACA,SAAS,QACkD;AAC3D,yBAAwB;EAAE;EAAU;EAAQ,CAAC;AAC7C,kCAAiC;AAEjC,KAAI,SAAS,SAAS,gBACpB,KAAI,OAAO,QAAQ,UAAU,WAC3B,KAAI,KACF,4GACD;KAED,KAAI;AACF,0BAAwB,QAAQ,MAAM;UAC/B,OAAO;AACd,MAAI,MAAM,wCAAwC,EAAE,OAAO,CAAC;;AAKlE,KAAI,CAAC,OAAQ,QAAO,QAAQ,SAAS;AAErC,QAAO,wBAAwB"}
@@ -4,17 +4,23 @@ import { ShopifyGlobal } from "../../globals.mjs";
4
4
  import { ConsentConfig, ShopAnalyticsChannel, StorefrontAnalyticsConfig } from "../analytics/types.mjs";
5
5
 
6
6
  //#region src/core/shopify-scripts/types.d.ts
7
+ /** The sales channel and custom data for the analytics bus. */
7
8
  type ShopifyScriptsAnalyticsConfig = {
8
- channel?: ShopAnalyticsChannel;
9
+ /** The sales channel that Shopify attributes analytics to. Defaults to `hydrogen`. */channel?: ShopAnalyticsChannel; /** Extra values that analytics destinations can read from the bus configuration. */
9
10
  customData?: StorefrontAnalyticsConfig["customData"];
10
11
  };
11
- type ShopifyScriptsI18n = Pick<I18nConfig, "country" | "language"> & Partial<Pick<I18nConfig, "pathPrefix">> & {
12
+ /** The locale that Shopify's scripts read from the browser's Shopify global. */
13
+ interface ShopifyScriptsI18n extends Pick<I18nConfig, "country" | "language">, Partial<Pick<I18nConfig, "pathPrefix">> {
14
+ /** The active currency code. Hydrogen converts it to uppercase. */
12
15
  currency?: string;
13
- };
16
+ }
17
+ /** The values of the HTML `crossorigin` attribute. */
14
18
  type ShopifyCrossOrigin = "" | "anonymous" | "use-credentials";
19
+ /** Custom `data-*` HTML attributes with string values. */
15
20
  type ShopifyDataAttributes = {
16
21
  [name: `data-${string}`]: string;
17
22
  };
23
+ /** The HTML attributes of a generated script tag, with lowercase attribute names. */
18
24
  type ShopifyScriptTagAttributes = ShopifyDataAttributes & Partial<{
19
25
  async: boolean;
20
26
  crossorigin: ShopifyCrossOrigin;
@@ -24,58 +30,85 @@ type ShopifyScriptTagAttributes = ShopifyDataAttributes & Partial<{
24
30
  src: string;
25
31
  type: string;
26
32
  }>;
33
+ /** The HTML attributes of a generated link tag. */
27
34
  type ShopifyLinkTagAttributes = Partial<{
28
- as: "script";
29
- crossorigin: ShopifyCrossOrigin;
30
- href: string;
35
+ /** The resource type for a prefetch link. Always `script`. */as: "script"; /** The CORS mode for fetching the linked resource. */
36
+ crossorigin: ShopifyCrossOrigin; /** The URL of the origin to preconnect to, or the script to prefetch. */
37
+ href: string; /** Whether the link preconnects to an origin or prefetches a script. */
31
38
  rel: "preconnect" | "prefetch";
32
39
  }>;
40
+ /** A script tag to render in the document head. */
33
41
  type ShopifyScriptDescriptor = {
34
- tagName: "script";
35
- attributes?: ShopifyScriptTagAttributes;
42
+ /** Always `script` for a script tag. */tagName: "script"; /** The script tag's HTML attributes, such as its source URL and nonce. */
43
+ attributes?: ShopifyScriptTagAttributes; /** The inline script content, for scripts that have no source URL. */
36
44
  innerHTML?: string;
37
45
  };
46
+ /** A link tag to render in the document head. */
38
47
  type ShopifyLinkDescriptor = {
39
- tagName: "link";
40
- attributes: ShopifyLinkTagAttributes;
48
+ /** Always `link` for a link tag. */tagName: "link";
49
+ attributes: ShopifyLinkTagAttributes; /** Link tags have no content. */
41
50
  innerHTML?: never;
42
51
  };
52
+ /** A script or link tag to render in the document head. */
43
53
  type ShopifyScriptTagDescriptor = ShopifyScriptDescriptor | ShopifyLinkDescriptor;
54
+ /** The generated link and script tags, as separate lists and as one combined list. */
44
55
  type ShopifyScriptTagDescriptors = {
45
56
  /** Link descriptors for framework head APIs that split links from scripts. */readonly links: readonly ShopifyLinkDescriptor[]; /** Script descriptors for framework head APIs that split scripts from links. */
46
57
  readonly scripts: readonly ShopifyScriptDescriptor[]; /** All generated descriptors as a mixed list, with links before scripts. */
47
58
  readonly tags: readonly ShopifyScriptTagDescriptor[];
48
59
  };
60
+ /** The shop identifiers that Shopify's scripts and analytics use. */
49
61
  type ShopifyScriptsShop = {
50
- shopId: string;
51
- storefrontId: string; /** The shop's permanent `*.myshopify.com` domain, exposed as `window.Shopify.shop`. */
62
+ /** The shop's ID, as a numeric string or a Shop GID. */shopId: string; /** The Hydrogen storefront's ID. Hydrogen leaves it out of Headless channel analytics. */
63
+ storefrontId: string; /** The shop's permanent `*.myshopify.com` domain. Hydrogen sets it as `window.Shopify.shop`. */
52
64
  myshopifyDomain: string;
53
65
  };
66
+ /** The shop details and the features whose scripts to load. */
54
67
  type ShopifyScriptTagsOptions = {
55
68
  /**
56
- * Loads the customer account component. Render `<shopify-account>` where you want the account UI to appear.
57
- * @see {@link https://shopify.dev/docs/api/storefront-web-components/components/shopify-account | shopify-account}
69
+ * Loads the customer account component. Render `shopify-account` where you want the account UI to appear.
70
+ * @see [shopify-account](https://shopify.dev/docs/api/storefront-web-components/components/shopify-account)
58
71
  */
59
- account?: boolean;
60
- analytics?: ShopifyScriptsAnalyticsConfig;
61
- consent?: ConsentConfig;
72
+ account?: boolean; /** The sales channel and custom data for the analytics bus. */
73
+ analytics?: ShopifyScriptsAnalyticsConfig; /** Which consent script to load and how the analytics bus waits for consent. */
74
+ consent?: ConsentConfig; /** Development-only debugging tools. */
62
75
  debug?: {
63
76
  /** Loads Shopify's standard events inspector in development builds. */standardEventsInspector?: boolean;
64
- };
65
- i18n?: ShopifyScriptsI18n; /** Loads Inbox. Render `<shopify-chat>` where you want the chat UI to appear. */
77
+ }; /** The country, language, currency, and path prefix for Shopify's scripts. Defaults to US English. */
78
+ i18n?: ShopifyScriptsI18n; /** Loads Inbox. Render `shopify-chat` where you want the chat UI to appear. */
66
79
  inbox?: boolean;
67
- nonce?: string;
68
- shop: ShopifyScriptsShop;
80
+ /**
81
+ * Adds a `nonce` attribute to every script tag.
82
+ */
83
+ nonce?: string; /** The shop's IDs and permanent domain. */
84
+ shop: ShopifyScriptsShop; /** Loads Shopify's storefront analytics script. Defaults to `true`. */
69
85
  shopifyAnalytics?: boolean;
70
86
  };
87
+ /**
88
+ * Route settings for Shopify's scripts: the storefront's route templates and a callback for
89
+ * client-side navigation.
90
+ */
71
91
  type ShopifyRoutesOptions = {
72
- navigate?: ShopifyGlobal["routes"]["navigate"];
92
+ /**
93
+ * Navigates to a URL after Shopify's scripts resolve it to your app's route. Defaults to a full
94
+ * page load. Checkout, cart permalink, buy permalink, and customer account paths always use a full page load.
95
+ */
96
+ navigate?: ShopifyGlobal["routes"]["navigate"]; /** Your app's custom route templates, which Shopify's scripts use to match and resolve storefront URLs. */
73
97
  routes?: ShopifyRouteTemplates;
74
98
  };
75
- type InitializeShopifyScriptsOptions = ShopifyRoutesOptions & {
76
- /** Pass the same consent configuration used to render the script tags. Setup runs once per bus. */consent?: ConsentConfig;
99
+ /** The route, consent, and WebMCP settings for starting Shopify's scripts in the browser. */
100
+ interface InitializeShopifyScriptsOptions extends ShopifyRoutesOptions {
101
+ /** The consent configuration that you passed to the script tags. The bus runs the setup callback once. */
102
+ consent?: ConsentConfig;
103
+ /** Loads Shopify WebMCP tools when the browser supports WebMCP. Defaults to `true`. */
77
104
  webMcp?: boolean;
78
- };
105
+ }
106
+ /**
107
+ * Options for both `getShopifyScriptTags` and `initializeShopifyScripts`. Build one object and pass
108
+ * it to both functions.
109
+ *
110
+ * @publicDocs
111
+ */
79
112
  type ShopifyScriptsOptions = ShopifyScriptTagsOptions & InitializeShopifyScriptsOptions;
80
113
  //#endregion
81
114
  export { InitializeShopifyScriptsOptions, ShopifyRoutesOptions, ShopifyScriptTagDescriptor, ShopifyScriptTagDescriptors, ShopifyScriptTagsOptions, ShopifyScriptsAnalyticsConfig, ShopifyScriptsI18n, ShopifyScriptsOptions, ShopifyScriptsShop };
@@ -2,21 +2,19 @@ import { ShopifyRouteTemplates } from "./types.mjs";
2
2
 
3
3
  //#region src/core/standard-routes/build.d.ts
4
4
  /**
5
- * Creates a typed map of custom route templates for Shopify standard storefront routes.
5
+ * Tells Hydrogen where your app serves products, collections, and other Shopify resources. Pass
6
+ * the returned object to `handleShopifyRoutes`, `handleShopifyRedirects`, the `ShopifyScripts` `routes`
7
+ * option, and the predictive search URL helpers.
6
8
  *
7
- * Use the returned object anywhere Hydrogen needs to understand the app's URL shape for
8
- * Shopify resources and utility pages: `handleShopifyRedirects({routeTemplates})`, `ShopifyScripts`
9
- * `routes={routeTemplates}`, and predictive search URL helpers.
9
+ * Add a key only for a route that your app serves at a non-standard path. Hydrogen uses Shopify's
10
+ * default path for each key that you leave out. Pass an empty object when your app serves every
11
+ * route at its default path. Each template starts with `/` and includes the handle placeholders
12
+ * for its route. Leave the locale path prefix out of templates. Hydrogen adds the prefix for you.
10
13
  *
11
- * Each key represents a Shopify standard route identity, while each value is the app's custom
12
- * pathname template. Templates must start with `/` and include the required named handle
13
- * placeholders for routes that identify a resource. Do not include an i18n path prefix in the
14
- * template; Hydrogen applies `i18n.pathPrefix` separately when resolving routes. Pass an empty
15
- * object when the app uses standard storefront routes so there is still one app-owned routing
16
- * manifest to update if routes change later. When matching the current page, standard storefront
17
- * routes retain their page-template identities even if a configured template resolves another
18
- * route to the same pathname.
14
+ * TypeScript checks the shape of each template. The function returns the object that you pass.
19
15
  *
16
+ * @param routes The non-standard paths that your app serves, keyed by standard route name.
17
+ * @returns The route templates, typed for Hydrogen's route, redirect, and URL helpers.
20
18
  * @example
21
19
  * ```ts
22
20
  * const routeTemplates = createShopifyRouteTemplates({
@@ -27,6 +25,7 @@ import { ShopifyRouteTemplates } from "./types.mjs";
27
25
  * policy: "/legal/:policyHandle",
28
26
  * });
29
27
  * ```
28
+ * @publicDocs
30
29
  */
31
30
  declare function createShopifyRouteTemplates<const TRoutes extends ShopifyRouteTemplates>(routes: TRoutes): TRoutes;
32
31
  //#endregion
@@ -3,21 +3,19 @@ import { prependPathPrefix } from "./path.mjs";
3
3
 
4
4
  //#region src/core/standard-routes/build.ts
5
5
  /**
6
- * Creates a typed map of custom route templates for Shopify standard storefront routes.
6
+ * Tells Hydrogen where your app serves products, collections, and other Shopify resources. Pass
7
+ * the returned object to `handleShopifyRoutes`, `handleShopifyRedirects`, the `ShopifyScripts` `routes`
8
+ * option, and the predictive search URL helpers.
7
9
  *
8
- * Use the returned object anywhere Hydrogen needs to understand the app's URL shape for
9
- * Shopify resources and utility pages: `handleShopifyRedirects({routeTemplates})`, `ShopifyScripts`
10
- * `routes={routeTemplates}`, and predictive search URL helpers.
10
+ * Add a key only for a route that your app serves at a non-standard path. Hydrogen uses Shopify's
11
+ * default path for each key that you leave out. Pass an empty object when your app serves every
12
+ * route at its default path. Each template starts with `/` and includes the handle placeholders
13
+ * for its route. Leave the locale path prefix out of templates. Hydrogen adds the prefix for you.
11
14
  *
12
- * Each key represents a Shopify standard route identity, while each value is the app's custom
13
- * pathname template. Templates must start with `/` and include the required named handle
14
- * placeholders for routes that identify a resource. Do not include an i18n path prefix in the
15
- * template; Hydrogen applies `i18n.pathPrefix` separately when resolving routes. Pass an empty
16
- * object when the app uses standard storefront routes so there is still one app-owned routing
17
- * manifest to update if routes change later. When matching the current page, standard storefront
18
- * routes retain their page-template identities even if a configured template resolves another
19
- * route to the same pathname.
15
+ * TypeScript checks the shape of each template. The function returns the object that you pass.
20
16
  *
17
+ * @param routes The non-standard paths that your app serves, keyed by standard route name.
18
+ * @returns The route templates, typed for Hydrogen's route, redirect, and URL helpers.
21
19
  * @example
22
20
  * ```ts
23
21
  * const routeTemplates = createShopifyRouteTemplates({
@@ -28,6 +26,7 @@ import { prependPathPrefix } from "./path.mjs";
28
26
  * policy: "/legal/:policyHandle",
29
27
  * });
30
28
  * ```
29
+ * @publicDocs
31
30
  */
32
31
  function createShopifyRouteTemplates(routes) {
33
32
  return routes;
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","names":[],"sources":["../../../../src/core/standard-routes/build.ts"],"sourcesContent":["import { DEFAULT_STANDARD_ROUTES, isStandardRouteParamName } from \"./defaults\";\nimport { prependPathPrefix } from \"./path\";\nimport type {\n ShopifyRouteTemplates,\n StandardRouteName,\n StandardRouteOptions,\n StandardRouteParams,\n StandardRouteParamsByName,\n} from \"./types\";\n\n/**\n * Creates a typed map of custom route templates for Shopify standard storefront routes.\n *\n * Use the returned object anywhere Hydrogen needs to understand the app's URL shape for\n * Shopify resources and utility pages: `handleShopifyRedirects({routeTemplates})`, `ShopifyScripts`\n * `routes={routeTemplates}`, and predictive search URL helpers.\n *\n * Each key represents a Shopify standard route identity, while each value is the app's custom\n * pathname template. Templates must start with `/` and include the required named handle\n * placeholders for routes that identify a resource. Do not include an i18n path prefix in the\n * template; Hydrogen applies `i18n.pathPrefix` separately when resolving routes. Pass an empty\n * object when the app uses standard storefront routes so there is still one app-owned routing\n * manifest to update if routes change later. When matching the current page, standard storefront\n * routes retain their page-template identities even if a configured template resolves another\n * route to the same pathname.\n *\n * @example\n * ```ts\n * const routeTemplates = createShopifyRouteTemplates({\n * product: \"/p/:productHandle\",\n * collection: \"/c/:collectionHandle\",\n * article: \"/journal/:blogHandle/:articleHandle\",\n * cart: \"/basket\",\n * policy: \"/legal/:policyHandle\",\n * });\n * ```\n */\nexport function createShopifyRouteTemplates<const TRoutes extends ShopifyRouteTemplates>(\n routes: TRoutes,\n): TRoutes {\n return routes;\n}\n\nexport function getStandardRoute<const TRoute extends StandardRouteName>(\n routeTemplates: ShopifyRouteTemplates,\n route: TRoute,\n params: StandardRouteParamsByName[TRoute],\n options: StandardRouteOptions = {},\n): string {\n const target = routeTemplates[route] ?? DEFAULT_STANDARD_ROUTES[route][0];\n\n return buildStandardRouteTarget(target, params, options.pathPrefix);\n}\n\n/**\n * Builds a pathname from a route template, handle params, and optional i18n path prefix.\n */\nexport function buildStandardRouteTarget(\n template: string,\n params: StandardRouteParams,\n pathPrefix: string | undefined,\n): string {\n return prependPathPrefix(interpolateRouteTemplate(template, params), pathPrefix);\n}\n\nfunction interpolateRouteTemplate(template: string, params: StandardRouteParams): string {\n return template.replace(/:([A-Za-z][A-Za-z0-9_]*)/g, (placeholder, name: string) => {\n if (!isStandardRouteParamName(name)) return placeholder;\n\n const value = params[name];\n return value === undefined ? placeholder : encodeURIComponent(value);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,4BACd,QACS;AACT,QAAO;;AAGT,SAAgB,iBACd,gBACA,OACA,QACA,UAAgC,EAAE,EAC1B;AAGR,QAAO,yBAFQ,eAAe,UAAU,wBAAwB,OAAO,IAE/B,QAAQ,QAAQ,WAAW;;;;;AAMrE,SAAgB,yBACd,UACA,QACA,YACQ;AACR,QAAO,kBAAkB,yBAAyB,UAAU,OAAO,EAAE,WAAW;;AAGlF,SAAS,yBAAyB,UAAkB,QAAqC;AACvF,QAAO,SAAS,QAAQ,8BAA8B,aAAa,SAAiB;AAClF,MAAI,CAAC,yBAAyB,KAAK,CAAE,QAAO;EAE5C,MAAM,QAAQ,OAAO;AACrB,SAAO,UAAU,SAAY,cAAc,mBAAmB,MAAM;GACpE"}
1
+ {"version":3,"file":"build.mjs","names":[],"sources":["../../../../src/core/standard-routes/build.ts"],"sourcesContent":["import { DEFAULT_STANDARD_ROUTES, isStandardRouteParamName } from \"./defaults\";\nimport { prependPathPrefix } from \"./path\";\nimport type {\n ShopifyRouteTemplates,\n StandardRouteName,\n StandardRouteOptions,\n StandardRouteParams,\n StandardRouteParamsByName,\n} from \"./types\";\n\n/**\n * Tells Hydrogen where your app serves products, collections, and other Shopify resources. Pass\n * the returned object to `handleShopifyRoutes`, `handleShopifyRedirects`, the `ShopifyScripts` `routes`\n * option, and the predictive search URL helpers.\n *\n * Add a key only for a route that your app serves at a non-standard path. Hydrogen uses Shopify's\n * default path for each key that you leave out. Pass an empty object when your app serves every\n * route at its default path. Each template starts with `/` and includes the handle placeholders\n * for its route. Leave the locale path prefix out of templates. Hydrogen adds the prefix for you.\n *\n * TypeScript checks the shape of each template. The function returns the object that you pass.\n *\n * @param routes The non-standard paths that your app serves, keyed by standard route name.\n * @returns The route templates, typed for Hydrogen's route, redirect, and URL helpers.\n * @example\n * ```ts\n * const routeTemplates = createShopifyRouteTemplates({\n * product: \"/p/:productHandle\",\n * collection: \"/c/:collectionHandle\",\n * article: \"/journal/:blogHandle/:articleHandle\",\n * cart: \"/basket\",\n * policy: \"/legal/:policyHandle\",\n * });\n * ```\n * @publicDocs\n */\nexport function createShopifyRouteTemplates<const TRoutes extends ShopifyRouteTemplates>(\n routes: TRoutes,\n): TRoutes {\n return routes;\n}\n\nexport function getStandardRoute<const TRoute extends StandardRouteName>(\n routeTemplates: ShopifyRouteTemplates,\n route: TRoute,\n params: StandardRouteParamsByName[TRoute],\n options: StandardRouteOptions = {},\n): string {\n const target = routeTemplates[route] ?? DEFAULT_STANDARD_ROUTES[route][0];\n\n return buildStandardRouteTarget(target, params, options.pathPrefix);\n}\n\n/**\n * Builds a pathname from a route template, handle params, and optional i18n path prefix.\n */\nexport function buildStandardRouteTarget(\n template: string,\n params: StandardRouteParams,\n pathPrefix: string | undefined,\n): string {\n return prependPathPrefix(interpolateRouteTemplate(template, params), pathPrefix);\n}\n\nfunction interpolateRouteTemplate(template: string, params: StandardRouteParams): string {\n return template.replace(/:([A-Za-z][A-Za-z0-9_]*)/g, (placeholder, name: string) => {\n if (!isStandardRouteParamName(name)) return placeholder;\n\n const value = params[name];\n return value === undefined ? placeholder : encodeURIComponent(value);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,4BACd,QACS;AACT,QAAO;;AAGT,SAAgB,iBACd,gBACA,OACA,QACA,UAAgC,EAAE,EAC1B;AAGR,QAAO,yBAFQ,eAAe,UAAU,wBAAwB,OAAO,IAE/B,QAAQ,QAAQ,WAAW;;;;;AAMrE,SAAgB,yBACd,UACA,QACA,YACQ;AACR,QAAO,kBAAkB,yBAAyB,UAAU,OAAO,EAAE,WAAW;;AAGlF,SAAS,yBAAyB,UAAkB,QAAqC;AACvF,QAAO,SAAS,QAAQ,8BAA8B,aAAa,SAAiB;AAClF,MAAI,CAAC,yBAAyB,KAAK,CAAE,QAAO;EAE5C,MAAM,QAAQ,OAAO;AACrB,SAAO,UAAU,SAAY,cAAc,mBAAmB,MAAM;GACpE"}
@@ -1,75 +1,78 @@
1
1
  //#region src/core/standard-routes/types.d.ts
2
+ /** A path template that starts with `/` and includes the named handle placeholder. */
2
3
  type StandardRouteTemplateWithParam<Param extends string> = `/${string}:${Param}` | `/${string}:${Param}/${string}`;
4
+ /** A path template that starts with `/`. */
3
5
  type StandardRouteTemplate = `/${string}`;
6
+ /** Your app's custom path templates for Shopify standard storefront routes, keyed by route name. */
4
7
  type ShopifyRouteTemplates = {
5
8
  /**
6
- * Redirects Shopify article routes, for example
7
- * `/blogs/news/snowboard-guide`, to the app's custom article route.
9
+ * The app's article path. Hydrogen redirects Shopify article paths, such as
10
+ * `/blogs/news/snowboard-guide`, to this template.
8
11
  *
9
12
  * @example "/journal/:blogHandle/:articleHandle"
10
13
  */
11
14
  article?: StandardRouteTemplateWithParam<"blogHandle"> & StandardRouteTemplateWithParam<"articleHandle">;
12
15
  /**
13
- * Redirects Shopify blog routes, for example `/blogs/news`, to the app's
14
- * custom blog route.
16
+ * The app's blog path. Hydrogen redirects Shopify blog paths, such as
17
+ * `/blogs/news`, to this template.
15
18
  *
16
19
  * @example "/journal/:blogHandle"
17
20
  */
18
21
  blog?: StandardRouteTemplateWithParam<"blogHandle">;
19
22
  /**
20
- * Redirects Shopify's `/cart` route to the app's custom cart route.
23
+ * The app's cart path. Hydrogen redirects Shopify's `/cart` path to this template.
21
24
  *
22
25
  * @example "/basket"
23
26
  */
24
27
  cart?: StandardRouteTemplate;
25
28
  /**
26
- * Redirects Shopify collection routes, for example `/collections/winter`,
27
- * to the app's custom collection route.
29
+ * The app's collection path. Hydrogen redirects Shopify collection paths, such as
30
+ * `/collections/winter`, to this template.
28
31
  *
29
32
  * @example "/c/:collectionHandle"
30
33
  */
31
34
  collection?: StandardRouteTemplateWithParam<"collectionHandle">;
32
35
  /**
33
- * Redirects Shopify's collection-listing routes, `/collections` and the
34
- * legacy `/products`, to the app's custom collection-listing route.
36
+ * The app's collection list path. Hydrogen redirects Shopify's `/collections`
37
+ * path and the legacy `/products` path to this template.
35
38
  *
36
39
  * @example "/catalog"
37
40
  */
38
41
  collectionList?: StandardRouteTemplate;
39
42
  /**
40
- * Redirects Shopify page routes, for example `/pages/about-us`, to the app's
41
- * custom page route.
43
+ * The app's page path. Hydrogen redirects Shopify page paths, such as
44
+ * `/pages/about-us`, to this template.
42
45
  *
43
46
  * @example "/content/:pageHandle"
44
47
  */
45
48
  page?: StandardRouteTemplateWithParam<"pageHandle">;
46
49
  /**
47
- * Redirects Shopify policy routes, for example `/policies/privacy-policy`,
48
- * to the app's custom policy route.
50
+ * The app's policy path. Hydrogen redirects Shopify policy paths, such as
51
+ * `/policies/privacy-policy`, to this template.
49
52
  *
50
53
  * @example "/legal/:policyHandle"
51
54
  */
52
55
  policy?: StandardRouteTemplateWithParam<"policyHandle">;
53
56
  /**
54
- * Redirects Shopify product routes, for example `/products/snowboard`,
55
- * to the app's custom product route.
57
+ * The app's product path. Hydrogen redirects Shopify product paths, such as
58
+ * `/products/snowboard`, to this template.
56
59
  *
57
60
  * @example "/p/:productHandle"
58
61
  */
59
62
  product?: StandardRouteTemplateWithParam<"productHandle">;
60
63
  /**
61
- * Redirects Shopify collection-scoped product routes, for example
62
- * `/collections/winter/products/snowboard`, to the app's custom product route.
64
+ * The app's path for products inside a collection. Hydrogen redirects Shopify
65
+ * paths such as `/collections/winter/products/snowboard` to this template.
63
66
  *
64
- * Must include `:productHandle`. May include `:collectionHandle` when the
65
- * app's custom product route is also collection-scoped.
67
+ * The template must include `:productHandle`. Add `:collectionHandle` when the
68
+ * app's product path also names the collection.
66
69
  *
67
70
  * @example "/p/:productHandle"
68
71
  * @example "/c/:collectionHandle/p/:productHandle"
69
72
  */
70
73
  productInCollection?: StandardRouteTemplateWithParam<"productHandle">;
71
74
  /**
72
- * Redirects Shopify's `/search` route to the app's custom search route.
75
+ * The app's search path. Hydrogen redirects Shopify's `/search` path to this template.
73
76
  *
74
77
  * @example "/find"
75
78
  */
@@ -77,14 +80,17 @@ type ShopifyRouteTemplates = {
77
80
  };
78
81
  type StandardRouteName = keyof ShopifyRouteTemplates;
79
82
  type ShopifyStandardRouteName = StandardRouteName | "index";
83
+ /** The page template name for a standard route. Collection-scoped products use `product`, and the collection list uses `list-collections`. */
80
84
  type ShopifyPageTemplateName<TRoute extends ShopifyStandardRouteName = ShopifyStandardRouteName> = TRoute extends "productInCollection" ? "product" : TRoute extends "collectionList" ? "list-collections" : TRoute;
81
85
  type StandardRouteParamName = "articleHandle" | "blogHandle" | "collectionHandle" | "pageHandle" | "policyHandle" | "productHandle";
86
+ /** The handle values that fill a route template's placeholders, keyed by placeholder name. */
82
87
  type StandardRouteParams = Partial<Record<StandardRouteParamName, string>>;
88
+ /** The standard route that a storefront URL matches, with its handles, page template name, and templates. */
83
89
  type ShopifyStandardRouteMatch<TRoute extends ShopifyStandardRouteName = ShopifyStandardRouteName> = {
84
- standardPathname: string;
85
- params: StandardRouteParams;
86
- route: TRoute;
87
- pageTemplateName: ShopifyPageTemplateName<TRoute>;
90
+ /** Shopify's default path for the matched resource, with the locale path prefix applied. */standardPathname: string; /** The decoded handle values from the matched URL. */
91
+ params: StandardRouteParams; /** The standard route name that the URL matched, or `index` for the home page. */
92
+ route: TRoute; /** The page template name for the matched route, such as `product` or `list-collections`. */
93
+ pageTemplateName: ShopifyPageTemplateName<TRoute>; /** Shopify's default template for the matched route and your app's custom template, which falls back to the default. */
88
94
  templates: {
89
95
  standard: string;
90
96
  custom: string;
@@ -24,6 +24,7 @@ const CUSTOMER_ACCOUNT_HANDOFF_PATHS = new Set(Object.values(CUSTOMER_ACCOUNT_PA
24
24
  function isHydrogenServerHandoffPath(pathname) {
25
25
  return CHECKOUT_RE.test(pathname) || CART_PERMALINK_RE.test(pathname) || BUY_PERMALINK_RE.test(pathname) || CUSTOMER_ACCOUNT_HANDOFF_PATHS.has(pathname);
26
26
  }
27
+ const UCP_RE = /^\/\.well-known\/ucp$/;
27
28
  /**
28
29
  * Allowlisted `.well-known` resources proxied to the Online Store origin:
29
30
  * - `apple-developer-merchantid-domain-association` — Apple Pay domain verification.
@@ -57,5 +58,5 @@ function normalizeStoreDomain(domain) {
57
58
  }
58
59
 
59
60
  //#endregion
60
- export { AJAX_CART_RE, BUY_PERMALINK_RE, CHECKOUT_RE, CUSTOMER_ACCOUNT_PATHS, MCP_RE, SFAPI_RE, SHOPIFY_API_PROXY_PREFIX, SHOPIFY_API_PROXY_RE, UCP_MCP_RE, WELL_KNOWN_RE, getSameOriginPath, isHydrogenServerHandoffPath, normalizeStoreDomain };
61
+ export { AJAX_CART_RE, BUY_PERMALINK_RE, CHECKOUT_RE, CUSTOMER_ACCOUNT_PATHS, MCP_RE, SFAPI_RE, SHOPIFY_API_PROXY_PREFIX, SHOPIFY_API_PROXY_RE, UCP_MCP_RE, UCP_RE, WELL_KNOWN_RE, getSameOriginPath, isHydrogenServerHandoffPath, normalizeStoreDomain };
61
62
  //# sourceMappingURL=url.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.mjs","names":[],"sources":["../../../src/core/url.ts"],"sourcesContent":["export const SFAPI_RE = /^\\/api\\/(unstable|2\\d{3}-\\d{2})\\/graphql\\.json$/;\nexport const SHOPIFY_API_PROXY_PREFIX = \"/__shopify\";\nexport const SHOPIFY_API_PROXY_RE = /^\\/__shopify(?:\\/|$)/;\nexport const MCP_RE = /^\\/api\\/mcp$/;\nexport const UCP_MCP_RE = /^\\/api\\/ucp\\/mcp$/;\nexport const CHECKOUT_RE = /^\\/checkout$/;\nexport const CART_PERMALINK_RE = /^\\/cart\\/\\d+:\\d+(?:,\\d+:\\d+)*$/;\nconst BUY_ITEM_PAIR = String.raw`(?:[A-Za-z0-9._-]+|~[A-Za-z0-9_-]+):[1-9]\\d*`;\n// Items are required so a storefront's own /buy pages keep routing to the app.\nexport const BUY_PERMALINK_RE = new RegExp(`^/buy/${BUY_ITEM_PAIR}(?:,${BUY_ITEM_PAIR})*$`);\nexport const CUSTOMER_ACCOUNT_PATHS = {\n authorize: \"/account/authorize\",\n login: \"/account/login\",\n logout: \"/account/logout\",\n refresh: \"/account/refresh\",\n} as const;\n\nconst CUSTOMER_ACCOUNT_HANDOFF_PATHS: ReadonlySet<string> = new Set(\n Object.values(CUSTOMER_ACCOUNT_PATHS),\n);\n\n/**\n * Returns whether the pathname conventionally represents a Hydrogen document-level server handoff.\n *\n * Keep this aligned with the routes intercepted before framework routing. API and protocol\n * interceptors are intentionally excluded because they are not browser navigation destinations.\n */\nexport function isHydrogenServerHandoffPath(pathname: string): boolean {\n return (\n CHECKOUT_RE.test(pathname) ||\n CART_PERMALINK_RE.test(pathname) ||\n BUY_PERMALINK_RE.test(pathname) ||\n CUSTOMER_ACCOUNT_HANDOFF_PATHS.has(pathname)\n );\n}\n\n/**\n * Allowlisted `.well-known` resources proxied to the Online Store origin:\n * - `apple-developer-merchantid-domain-association` — Apple Pay domain verification.\n * - `shopify/fec/produce` — Frontend Event Collector ingress. On the Online\n * Store the myshopify.com edge forwards this first-party path to the\n * collector; headless storefronts have no such edge, so Hydrogen proxies it\n * to the same origin (used by WebMCP's Event Refinery client).\n */\nexport const WELL_KNOWN_RE =\n /^\\/\\.well-known\\/(?:apple-developer-merchantid-domain-association|shopify\\/fec\\/produce)$/;\nexport const AJAX_CART_RE =\n /^(?:\\/[a-z]{2}(?:-[a-z]{2})?)?\\/cart(?:\\.(?:js|json)|\\/(?:add|update|change|clear)(?:\\.(?:js|json))?)$/i;\n\n/**\n * Normalizes `target` to a path on `origin` that is safe to use as a redirect location.\n * Returns `undefined` unless `target` is a path starting with `/` or an absolute URL,\n * stays on `origin`, and its normalized pathname does not start with `//`.\n */\nexport function getSameOriginPath(\n target: string | null | undefined,\n origin: string,\n): string | undefined {\n if (!target) return undefined;\n\n try {\n // Parse absolute URLs without a base so scheme-relative forms like `https:evil.example`\n // resolve to their own host, as a browser would, instead of onto `origin`.\n const url = target.startsWith(\"/\") ? new URL(target, origin) : new URL(target);\n if (url.origin !== origin) return undefined;\n const path = `${url.pathname}${url.search}${url.hash}`;\n // The parsed pathname can itself start with `//` (e.g. from `/x/..//evil`),\n // which a redirect would resolve as a protocol-relative URL to another host.\n return path.startsWith(\"//\") ? undefined : path;\n } catch {\n return undefined;\n }\n}\n\nexport function normalizeStoreDomain(domain: string): string {\n if (!domain) {\n throw new Error(\"Storefront `storeDomain` is required.\");\n }\n\n if (domain.startsWith(\"http://\") || domain.startsWith(\"https://\")) {\n return domain.replace(/\\/+$/, \"\");\n }\n return `https://${domain}`.replace(/\\/+$/, \"\");\n}\n"],"mappings":";AAAA,MAAa,WAAW;AACxB,MAAa,2BAA2B;AACxC,MAAa,uBAAuB;AACpC,MAAa,SAAS;AACtB,MAAa,aAAa;AAC1B,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAM,gBAAgB,OAAO,GAAG;AAEhC,MAAa,mBAAmB,IAAI,OAAO,SAAS,cAAc,MAAM,cAAc,KAAK;AAC3F,MAAa,yBAAyB;CACpC,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACV;AAED,MAAM,iCAAsD,IAAI,IAC9D,OAAO,OAAO,uBAAuB,CACtC;;;;;;;AAQD,SAAgB,4BAA4B,UAA2B;AACrE,QACE,YAAY,KAAK,SAAS,IAC1B,kBAAkB,KAAK,SAAS,IAChC,iBAAiB,KAAK,SAAS,IAC/B,+BAA+B,IAAI,SAAS;;;;;;;;;;AAYhD,MAAa,gBACX;AACF,MAAa,eACX;;;;;;AAOF,SAAgB,kBACd,QACA,QACoB;AACpB,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI;EAGF,MAAM,MAAM,OAAO,WAAW,IAAI,GAAG,IAAI,IAAI,QAAQ,OAAO,GAAG,IAAI,IAAI,OAAO;AAC9E,MAAI,IAAI,WAAW,OAAQ,QAAO;EAClC,MAAM,OAAO,GAAG,IAAI,WAAW,IAAI,SAAS,IAAI;AAGhD,SAAO,KAAK,WAAW,KAAK,GAAG,SAAY;SACrC;AACN;;;AAIJ,SAAgB,qBAAqB,QAAwB;AAC3D,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,wCAAwC;AAG1D,KAAI,OAAO,WAAW,UAAU,IAAI,OAAO,WAAW,WAAW,CAC/D,QAAO,OAAO,QAAQ,QAAQ,GAAG;AAEnC,QAAO,WAAW,SAAS,QAAQ,QAAQ,GAAG"}
1
+ {"version":3,"file":"url.mjs","names":[],"sources":["../../../src/core/url.ts"],"sourcesContent":["export const SFAPI_RE = /^\\/api\\/(unstable|2\\d{3}-\\d{2})\\/graphql\\.json$/;\nexport const SHOPIFY_API_PROXY_PREFIX = \"/__shopify\";\nexport const SHOPIFY_API_PROXY_RE = /^\\/__shopify(?:\\/|$)/;\nexport const MCP_RE = /^\\/api\\/mcp$/;\nexport const UCP_MCP_RE = /^\\/api\\/ucp\\/mcp$/;\nexport const CHECKOUT_RE = /^\\/checkout$/;\nexport const CART_PERMALINK_RE = /^\\/cart\\/\\d+:\\d+(?:,\\d+:\\d+)*$/;\nconst BUY_ITEM_PAIR = String.raw`(?:[A-Za-z0-9._-]+|~[A-Za-z0-9_-]+):[1-9]\\d*`;\n// Items are required so a storefront's own /buy pages keep routing to the app.\nexport const BUY_PERMALINK_RE = new RegExp(`^/buy/${BUY_ITEM_PAIR}(?:,${BUY_ITEM_PAIR})*$`);\nexport const CUSTOMER_ACCOUNT_PATHS = {\n authorize: \"/account/authorize\",\n login: \"/account/login\",\n logout: \"/account/logout\",\n refresh: \"/account/refresh\",\n} as const;\n\nconst CUSTOMER_ACCOUNT_HANDOFF_PATHS: ReadonlySet<string> = new Set(\n Object.values(CUSTOMER_ACCOUNT_PATHS),\n);\n\n/**\n * Returns whether the pathname conventionally represents a Hydrogen document-level server handoff.\n *\n * Keep this aligned with the routes intercepted before framework routing. API and protocol\n * interceptors are intentionally excluded because they are not browser navigation destinations.\n */\nexport function isHydrogenServerHandoffPath(pathname: string): boolean {\n return (\n CHECKOUT_RE.test(pathname) ||\n CART_PERMALINK_RE.test(pathname) ||\n BUY_PERMALINK_RE.test(pathname) ||\n CUSTOMER_ACCOUNT_HANDOFF_PATHS.has(pathname)\n );\n}\n\n// UCP profiles need JSON validation and caching separate from the other well-known resources.\nexport const UCP_RE = /^\\/\\.well-known\\/ucp$/;\n\n/**\n * Allowlisted `.well-known` resources proxied to the Online Store origin:\n * - `apple-developer-merchantid-domain-association` — Apple Pay domain verification.\n * - `shopify/fec/produce` — Frontend Event Collector ingress. On the Online\n * Store the myshopify.com edge forwards this first-party path to the\n * collector; headless storefronts have no such edge, so Hydrogen proxies it\n * to the same origin (used by WebMCP's Event Refinery client).\n */\nexport const WELL_KNOWN_RE =\n /^\\/\\.well-known\\/(?:apple-developer-merchantid-domain-association|shopify\\/fec\\/produce)$/;\nexport const AJAX_CART_RE =\n /^(?:\\/[a-z]{2}(?:-[a-z]{2})?)?\\/cart(?:\\.(?:js|json)|\\/(?:add|update|change|clear)(?:\\.(?:js|json))?)$/i;\n\n/**\n * Normalizes `target` to a path on `origin` that is safe to use as a redirect location.\n * Returns `undefined` unless `target` is a path starting with `/` or an absolute URL,\n * stays on `origin`, and its normalized pathname does not start with `//`.\n */\nexport function getSameOriginPath(\n target: string | null | undefined,\n origin: string,\n): string | undefined {\n if (!target) return undefined;\n\n try {\n // Parse absolute URLs without a base so scheme-relative forms like `https:evil.example`\n // resolve to their own host, as a browser would, instead of onto `origin`.\n const url = target.startsWith(\"/\") ? new URL(target, origin) : new URL(target);\n if (url.origin !== origin) return undefined;\n const path = `${url.pathname}${url.search}${url.hash}`;\n // The parsed pathname can itself start with `//` (e.g. from `/x/..//evil`),\n // which a redirect would resolve as a protocol-relative URL to another host.\n return path.startsWith(\"//\") ? undefined : path;\n } catch {\n return undefined;\n }\n}\n\nexport function normalizeStoreDomain(domain: string): string {\n if (!domain) {\n throw new Error(\"Storefront `storeDomain` is required.\");\n }\n\n if (domain.startsWith(\"http://\") || domain.startsWith(\"https://\")) {\n return domain.replace(/\\/+$/, \"\");\n }\n return `https://${domain}`.replace(/\\/+$/, \"\");\n}\n"],"mappings":";AAAA,MAAa,WAAW;AACxB,MAAa,2BAA2B;AACxC,MAAa,uBAAuB;AACpC,MAAa,SAAS;AACtB,MAAa,aAAa;AAC1B,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAM,gBAAgB,OAAO,GAAG;AAEhC,MAAa,mBAAmB,IAAI,OAAO,SAAS,cAAc,MAAM,cAAc,KAAK;AAC3F,MAAa,yBAAyB;CACpC,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACV;AAED,MAAM,iCAAsD,IAAI,IAC9D,OAAO,OAAO,uBAAuB,CACtC;;;;;;;AAQD,SAAgB,4BAA4B,UAA2B;AACrE,QACE,YAAY,KAAK,SAAS,IAC1B,kBAAkB,KAAK,SAAS,IAChC,iBAAiB,KAAK,SAAS,IAC/B,+BAA+B,IAAI,SAAS;;AAKhD,MAAa,SAAS;;;;;;;;;AAUtB,MAAa,gBACX;AACF,MAAa,eACX;;;;;;AAOF,SAAgB,kBACd,QACA,QACoB;AACpB,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI;EAGF,MAAM,MAAM,OAAO,WAAW,IAAI,GAAG,IAAI,IAAI,QAAQ,OAAO,GAAG,IAAI,IAAI,OAAO;AAC9E,MAAI,IAAI,WAAW,OAAQ,QAAO;EAClC,MAAM,OAAO,GAAG,IAAI,WAAW,IAAI,SAAS,IAAI;AAGhD,SAAO,KAAK,WAAW,KAAK,GAAG,SAAY;SACrC;AACN;;;AAIJ,SAAgB,qBAAqB,QAAwB;AAC3D,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,wCAAwC;AAG1D,KAAI,OAAO,WAAW,UAAU,IAAI,OAAO,WAAW,WAAW,CAC/D,QAAO,OAAO,QAAQ,QAAQ,GAAG;AAEnC,QAAO,WAAW,SAAS,QAAQ,QAAQ,GAAG"}