@shopify/hydrogen-react 2026.4.1 → 2026.4.2

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 (595) hide show
  1. package/dist/browser-dev/AddToCartButton.mjs +60 -71
  2. package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
  3. package/dist/browser-dev/BaseButton.mjs +20 -26
  4. package/dist/browser-dev/BaseButton.mjs.map +1 -1
  5. package/dist/browser-dev/BuyNowButton.mjs +40 -45
  6. package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
  7. package/dist/browser-dev/CartCheckoutButton.mjs +28 -23
  8. package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
  9. package/dist/browser-dev/CartCost.mjs +26 -22
  10. package/dist/browser-dev/CartCost.mjs.map +1 -1
  11. package/dist/browser-dev/CartLineProvider.mjs +23 -18
  12. package/dist/browser-dev/CartLineProvider.mjs.map +1 -1
  13. package/dist/browser-dev/CartLineQuantity.mjs +18 -9
  14. package/dist/browser-dev/CartLineQuantity.mjs.map +1 -1
  15. package/dist/browser-dev/CartLineQuantityAdjustButton.mjs +48 -45
  16. package/dist/browser-dev/CartLineQuantityAdjustButton.mjs.map +1 -1
  17. package/dist/browser-dev/CartProvider.mjs +315 -385
  18. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  19. package/dist/browser-dev/ExternalVideo.mjs +35 -47
  20. package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
  21. package/dist/browser-dev/Image.mjs +335 -340
  22. package/dist/browser-dev/Image.mjs.map +1 -1
  23. package/dist/browser-dev/MediaFile.mjs +39 -61
  24. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  25. package/dist/browser-dev/ModelViewer.mjs +115 -139
  26. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  27. package/dist/browser-dev/Money.mjs +53 -39
  28. package/dist/browser-dev/Money.mjs.map +1 -1
  29. package/dist/browser-dev/ProductPrice.mjs +44 -61
  30. package/dist/browser-dev/ProductPrice.mjs.map +1 -1
  31. package/dist/browser-dev/ProductProvider.mjs +147 -179
  32. package/dist/browser-dev/ProductProvider.mjs.map +1 -1
  33. package/dist/browser-dev/RichText.components.mjs +36 -46
  34. package/dist/browser-dev/RichText.components.mjs.map +1 -1
  35. package/dist/browser-dev/RichText.mjs +111 -154
  36. package/dist/browser-dev/RichText.mjs.map +1 -1
  37. package/dist/browser-dev/ShopPayButton.mjs +53 -81
  38. package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
  39. package/dist/browser-dev/ShopifyProvider.mjs +71 -84
  40. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
  41. package/dist/browser-dev/Video.mjs +35 -52
  42. package/dist/browser-dev/Video.mjs.map +1 -1
  43. package/dist/browser-dev/analytics-constants.mjs +41 -43
  44. package/dist/browser-dev/analytics-constants.mjs.map +1 -1
  45. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  46. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  47. package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  48. package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  49. package/dist/browser-dev/analytics-utils.mjs +78 -56
  50. package/dist/browser-dev/analytics-utils.mjs.map +1 -1
  51. package/dist/browser-dev/analytics.mjs +112 -155
  52. package/dist/browser-dev/analytics.mjs.map +1 -1
  53. package/dist/browser-dev/cart-constants.mjs +11 -15
  54. package/dist/browser-dev/cart-constants.mjs.map +1 -1
  55. package/dist/browser-dev/cart-hooks.mjs +42 -57
  56. package/dist/browser-dev/cart-hooks.mjs.map +1 -1
  57. package/dist/browser-dev/cart-queries.mjs +28 -66
  58. package/dist/browser-dev/cart-queries.mjs.map +1 -1
  59. package/dist/browser-dev/codegen.helpers.mjs +31 -20
  60. package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
  61. package/dist/browser-dev/cookies-utils.mjs +44 -42
  62. package/dist/browser-dev/cookies-utils.mjs.map +1 -1
  63. package/dist/browser-dev/flatten-connection.mjs +23 -29
  64. package/dist/browser-dev/flatten-connection.mjs.map +1 -1
  65. package/dist/browser-dev/getProductOptions.mjs +248 -226
  66. package/dist/browser-dev/getProductOptions.mjs.map +1 -1
  67. package/dist/browser-dev/index.mjs +15 -70
  68. package/dist/browser-dev/load-script.mjs +38 -49
  69. package/dist/browser-dev/load-script.mjs.map +1 -1
  70. package/dist/browser-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  71. package/dist/browser-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  72. package/dist/browser-dev/optionValueDecoder.mjs +104 -86
  73. package/dist/browser-dev/optionValueDecoder.mjs.map +1 -1
  74. package/dist/browser-dev/packages/hydrogen-react/package.mjs +6 -0
  75. package/dist/browser-dev/packages/hydrogen-react/package.mjs.map +1 -0
  76. package/dist/browser-dev/parse-metafield.mjs +122 -134
  77. package/dist/browser-dev/parse-metafield.mjs.map +1 -1
  78. package/dist/browser-dev/storefront-api-constants.mjs +6 -5
  79. package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
  80. package/dist/browser-dev/storefront-client.mjs +62 -102
  81. package/dist/browser-dev/storefront-client.mjs.map +1 -1
  82. package/dist/browser-dev/tracking-utils.mjs +68 -88
  83. package/dist/browser-dev/tracking-utils.mjs.map +1 -1
  84. package/dist/browser-dev/useCartAPIStateMachine.mjs +188 -346
  85. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  86. package/dist/browser-dev/useCartActions.mjs +197 -172
  87. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  88. package/dist/browser-dev/useMachine.mjs +50 -62
  89. package/dist/browser-dev/useMachine.mjs.map +1 -1
  90. package/dist/browser-dev/useMoney.mjs +176 -154
  91. package/dist/browser-dev/useMoney.mjs.map +1 -1
  92. package/dist/browser-dev/useSelectedOptionInUrlParam.mjs +17 -27
  93. package/dist/browser-dev/useSelectedOptionInUrlParam.mjs.map +1 -1
  94. package/dist/browser-dev/useShopifyCookies.mjs +123 -138
  95. package/dist/browser-dev/useShopifyCookies.mjs.map +1 -1
  96. package/dist/browser-prod/AddToCartButton.mjs +60 -71
  97. package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
  98. package/dist/browser-prod/BaseButton.mjs +20 -26
  99. package/dist/browser-prod/BaseButton.mjs.map +1 -1
  100. package/dist/browser-prod/BuyNowButton.mjs +40 -45
  101. package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
  102. package/dist/browser-prod/CartCheckoutButton.mjs +28 -23
  103. package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
  104. package/dist/browser-prod/CartCost.mjs +26 -22
  105. package/dist/browser-prod/CartCost.mjs.map +1 -1
  106. package/dist/browser-prod/CartLineProvider.mjs +23 -18
  107. package/dist/browser-prod/CartLineProvider.mjs.map +1 -1
  108. package/dist/browser-prod/CartLineQuantity.mjs +18 -9
  109. package/dist/browser-prod/CartLineQuantity.mjs.map +1 -1
  110. package/dist/browser-prod/CartLineQuantityAdjustButton.mjs +48 -45
  111. package/dist/browser-prod/CartLineQuantityAdjustButton.mjs.map +1 -1
  112. package/dist/browser-prod/CartProvider.mjs +315 -385
  113. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  114. package/dist/browser-prod/ExternalVideo.mjs +35 -47
  115. package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
  116. package/dist/browser-prod/Image.mjs +326 -325
  117. package/dist/browser-prod/Image.mjs.map +1 -1
  118. package/dist/browser-prod/MediaFile.mjs +44 -63
  119. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  120. package/dist/browser-prod/ModelViewer.mjs +117 -135
  121. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  122. package/dist/browser-prod/Money.mjs +53 -39
  123. package/dist/browser-prod/Money.mjs.map +1 -1
  124. package/dist/browser-prod/ProductPrice.mjs +44 -61
  125. package/dist/browser-prod/ProductPrice.mjs.map +1 -1
  126. package/dist/browser-prod/ProductProvider.mjs +147 -179
  127. package/dist/browser-prod/ProductProvider.mjs.map +1 -1
  128. package/dist/browser-prod/RichText.components.mjs +36 -46
  129. package/dist/browser-prod/RichText.components.mjs.map +1 -1
  130. package/dist/browser-prod/RichText.mjs +111 -154
  131. package/dist/browser-prod/RichText.mjs.map +1 -1
  132. package/dist/browser-prod/ShopPayButton.mjs +53 -81
  133. package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
  134. package/dist/browser-prod/ShopifyProvider.mjs +71 -84
  135. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
  136. package/dist/browser-prod/Video.mjs +35 -52
  137. package/dist/browser-prod/Video.mjs.map +1 -1
  138. package/dist/browser-prod/analytics-constants.mjs +41 -43
  139. package/dist/browser-prod/analytics-constants.mjs.map +1 -1
  140. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  141. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  142. package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  143. package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  144. package/dist/browser-prod/analytics-utils.mjs +78 -56
  145. package/dist/browser-prod/analytics-utils.mjs.map +1 -1
  146. package/dist/browser-prod/analytics.mjs +111 -153
  147. package/dist/browser-prod/analytics.mjs.map +1 -1
  148. package/dist/browser-prod/cart-constants.mjs +11 -15
  149. package/dist/browser-prod/cart-constants.mjs.map +1 -1
  150. package/dist/browser-prod/cart-hooks.mjs +42 -57
  151. package/dist/browser-prod/cart-hooks.mjs.map +1 -1
  152. package/dist/browser-prod/cart-queries.mjs +28 -66
  153. package/dist/browser-prod/cart-queries.mjs.map +1 -1
  154. package/dist/browser-prod/codegen.helpers.mjs +31 -20
  155. package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
  156. package/dist/browser-prod/cookies-utils.mjs +44 -42
  157. package/dist/browser-prod/cookies-utils.mjs.map +1 -1
  158. package/dist/browser-prod/flatten-connection.mjs +23 -25
  159. package/dist/browser-prod/flatten-connection.mjs.map +1 -1
  160. package/dist/browser-prod/getProductOptions.mjs +248 -226
  161. package/dist/browser-prod/getProductOptions.mjs.map +1 -1
  162. package/dist/browser-prod/index.mjs +15 -70
  163. package/dist/browser-prod/load-script.mjs +38 -49
  164. package/dist/browser-prod/load-script.mjs.map +1 -1
  165. package/dist/browser-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  166. package/dist/browser-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  167. package/dist/browser-prod/optionValueDecoder.mjs +104 -86
  168. package/dist/browser-prod/optionValueDecoder.mjs.map +1 -1
  169. package/dist/browser-prod/packages/hydrogen-react/package.mjs +6 -0
  170. package/dist/browser-prod/packages/hydrogen-react/package.mjs.map +1 -0
  171. package/dist/browser-prod/parse-metafield.mjs +134 -146
  172. package/dist/browser-prod/parse-metafield.mjs.map +1 -1
  173. package/dist/browser-prod/storefront-api-constants.mjs +6 -5
  174. package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
  175. package/dist/browser-prod/storefront-client.mjs +56 -84
  176. package/dist/browser-prod/storefront-client.mjs.map +1 -1
  177. package/dist/browser-prod/tracking-utils.mjs +68 -88
  178. package/dist/browser-prod/tracking-utils.mjs.map +1 -1
  179. package/dist/browser-prod/useCartAPIStateMachine.mjs +188 -346
  180. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  181. package/dist/browser-prod/useCartActions.mjs +197 -172
  182. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  183. package/dist/browser-prod/useMachine.mjs +50 -62
  184. package/dist/browser-prod/useMachine.mjs.map +1 -1
  185. package/dist/browser-prod/useMoney.mjs +176 -154
  186. package/dist/browser-prod/useMoney.mjs.map +1 -1
  187. package/dist/browser-prod/useSelectedOptionInUrlParam.mjs +17 -27
  188. package/dist/browser-prod/useSelectedOptionInUrlParam.mjs.map +1 -1
  189. package/dist/browser-prod/useShopifyCookies.mjs +123 -138
  190. package/dist/browser-prod/useShopifyCookies.mjs.map +1 -1
  191. package/dist/node-dev/AddToCartButton.js +64 -73
  192. package/dist/node-dev/AddToCartButton.js.map +1 -1
  193. package/dist/node-dev/AddToCartButton.mjs +60 -71
  194. package/dist/node-dev/AddToCartButton.mjs.map +1 -1
  195. package/dist/node-dev/BaseButton.js +21 -26
  196. package/dist/node-dev/BaseButton.js.map +1 -1
  197. package/dist/node-dev/BaseButton.mjs +20 -26
  198. package/dist/node-dev/BaseButton.mjs.map +1 -1
  199. package/dist/node-dev/BuyNowButton.js +42 -46
  200. package/dist/node-dev/BuyNowButton.js.map +1 -1
  201. package/dist/node-dev/BuyNowButton.mjs +40 -45
  202. package/dist/node-dev/BuyNowButton.mjs.map +1 -1
  203. package/dist/node-dev/CartCheckoutButton.js +30 -24
  204. package/dist/node-dev/CartCheckoutButton.js.map +1 -1
  205. package/dist/node-dev/CartCheckoutButton.mjs +28 -23
  206. package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
  207. package/dist/node-dev/CartCost.js +27 -22
  208. package/dist/node-dev/CartCost.js.map +1 -1
  209. package/dist/node-dev/CartCost.mjs +26 -22
  210. package/dist/node-dev/CartCost.mjs.map +1 -1
  211. package/dist/node-dev/CartLineProvider.js +24 -17
  212. package/dist/node-dev/CartLineProvider.js.map +1 -1
  213. package/dist/node-dev/CartLineProvider.mjs +23 -18
  214. package/dist/node-dev/CartLineProvider.mjs.map +1 -1
  215. package/dist/node-dev/CartLineQuantity.js +19 -9
  216. package/dist/node-dev/CartLineQuantity.js.map +1 -1
  217. package/dist/node-dev/CartLineQuantity.mjs +18 -9
  218. package/dist/node-dev/CartLineQuantity.mjs.map +1 -1
  219. package/dist/node-dev/CartLineQuantityAdjustButton.js +50 -46
  220. package/dist/node-dev/CartLineQuantityAdjustButton.js.map +1 -1
  221. package/dist/node-dev/CartLineQuantityAdjustButton.mjs +48 -45
  222. package/dist/node-dev/CartLineQuantityAdjustButton.mjs.map +1 -1
  223. package/dist/node-dev/CartProvider.js +317 -385
  224. package/dist/node-dev/CartProvider.js.map +1 -1
  225. package/dist/node-dev/CartProvider.mjs +315 -385
  226. package/dist/node-dev/CartProvider.mjs.map +1 -1
  227. package/dist/node-dev/ExternalVideo.js +36 -47
  228. package/dist/node-dev/ExternalVideo.js.map +1 -1
  229. package/dist/node-dev/ExternalVideo.mjs +35 -47
  230. package/dist/node-dev/ExternalVideo.mjs.map +1 -1
  231. package/dist/node-dev/Image.js +337 -355
  232. package/dist/node-dev/Image.js.map +1 -1
  233. package/dist/node-dev/Image.mjs +335 -340
  234. package/dist/node-dev/Image.mjs.map +1 -1
  235. package/dist/node-dev/MediaFile.js +42 -63
  236. package/dist/node-dev/MediaFile.js.map +1 -1
  237. package/dist/node-dev/MediaFile.mjs +39 -61
  238. package/dist/node-dev/MediaFile.mjs.map +1 -1
  239. package/dist/node-dev/ModelViewer.js +116 -139
  240. package/dist/node-dev/ModelViewer.js.map +1 -1
  241. package/dist/node-dev/ModelViewer.mjs +115 -139
  242. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  243. package/dist/node-dev/Money.js +54 -39
  244. package/dist/node-dev/Money.js.map +1 -1
  245. package/dist/node-dev/Money.mjs +53 -39
  246. package/dist/node-dev/Money.mjs.map +1 -1
  247. package/dist/node-dev/ProductPrice.js +45 -61
  248. package/dist/node-dev/ProductPrice.js.map +1 -1
  249. package/dist/node-dev/ProductPrice.mjs +44 -61
  250. package/dist/node-dev/ProductPrice.mjs.map +1 -1
  251. package/dist/node-dev/ProductProvider.js +148 -178
  252. package/dist/node-dev/ProductProvider.js.map +1 -1
  253. package/dist/node-dev/ProductProvider.mjs +147 -179
  254. package/dist/node-dev/ProductProvider.mjs.map +1 -1
  255. package/dist/node-dev/RichText.components.js +37 -46
  256. package/dist/node-dev/RichText.components.js.map +1 -1
  257. package/dist/node-dev/RichText.components.mjs +36 -46
  258. package/dist/node-dev/RichText.components.mjs.map +1 -1
  259. package/dist/node-dev/RichText.js +112 -154
  260. package/dist/node-dev/RichText.js.map +1 -1
  261. package/dist/node-dev/RichText.mjs +111 -154
  262. package/dist/node-dev/RichText.mjs.map +1 -1
  263. package/dist/node-dev/ShopPayButton.js +54 -81
  264. package/dist/node-dev/ShopPayButton.js.map +1 -1
  265. package/dist/node-dev/ShopPayButton.mjs +53 -81
  266. package/dist/node-dev/ShopPayButton.mjs.map +1 -1
  267. package/dist/node-dev/ShopifyProvider.js +73 -83
  268. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  269. package/dist/node-dev/ShopifyProvider.mjs +71 -84
  270. package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
  271. package/dist/node-dev/Video.js +36 -52
  272. package/dist/node-dev/Video.js.map +1 -1
  273. package/dist/node-dev/Video.mjs +35 -52
  274. package/dist/node-dev/Video.mjs.map +1 -1
  275. package/dist/node-dev/_virtual/_rolldown/runtime.js +23 -0
  276. package/dist/node-dev/analytics-constants.js +40 -39
  277. package/dist/node-dev/analytics-constants.js.map +1 -1
  278. package/dist/node-dev/analytics-constants.mjs +41 -43
  279. package/dist/node-dev/analytics-constants.mjs.map +1 -1
  280. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js +128 -210
  281. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js.map +1 -1
  282. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  283. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  284. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js +40 -51
  285. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js.map +1 -1
  286. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  287. package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  288. package/dist/node-dev/analytics-utils.js +77 -52
  289. package/dist/node-dev/analytics-utils.js.map +1 -1
  290. package/dist/node-dev/analytics-utils.mjs +78 -56
  291. package/dist/node-dev/analytics-utils.mjs.map +1 -1
  292. package/dist/node-dev/analytics.js +114 -156
  293. package/dist/node-dev/analytics.js.map +1 -1
  294. package/dist/node-dev/analytics.mjs +112 -155
  295. package/dist/node-dev/analytics.mjs.map +1 -1
  296. package/dist/node-dev/cart-constants.js +10 -9
  297. package/dist/node-dev/cart-constants.js.map +1 -1
  298. package/dist/node-dev/cart-constants.mjs +11 -15
  299. package/dist/node-dev/cart-constants.mjs.map +1 -1
  300. package/dist/node-dev/cart-hooks.js +43 -57
  301. package/dist/node-dev/cart-hooks.js.map +1 -1
  302. package/dist/node-dev/cart-hooks.mjs +42 -57
  303. package/dist/node-dev/cart-hooks.mjs.map +1 -1
  304. package/dist/node-dev/cart-queries.js +27 -56
  305. package/dist/node-dev/cart-queries.js.map +1 -1
  306. package/dist/node-dev/cart-queries.mjs +28 -66
  307. package/dist/node-dev/cart-queries.mjs.map +1 -1
  308. package/dist/node-dev/codegen.helpers.js +30 -18
  309. package/dist/node-dev/codegen.helpers.js.map +1 -1
  310. package/dist/node-dev/codegen.helpers.mjs +31 -20
  311. package/dist/node-dev/codegen.helpers.mjs.map +1 -1
  312. package/dist/node-dev/cookies-utils.js +45 -42
  313. package/dist/node-dev/cookies-utils.js.map +1 -1
  314. package/dist/node-dev/cookies-utils.mjs +44 -42
  315. package/dist/node-dev/cookies-utils.mjs.map +1 -1
  316. package/dist/node-dev/flatten-connection.js +22 -28
  317. package/dist/node-dev/flatten-connection.js.map +1 -1
  318. package/dist/node-dev/flatten-connection.mjs +23 -29
  319. package/dist/node-dev/flatten-connection.mjs.map +1 -1
  320. package/dist/node-dev/getProductOptions.js +248 -224
  321. package/dist/node-dev/getProductOptions.js.map +1 -1
  322. package/dist/node-dev/getProductOptions.mjs +248 -226
  323. package/dist/node-dev/getProductOptions.mjs.map +1 -1
  324. package/dist/node-dev/index.js +88 -90
  325. package/dist/node-dev/index.mjs +15 -70
  326. package/dist/node-dev/load-script.js +38 -48
  327. package/dist/node-dev/load-script.js.map +1 -1
  328. package/dist/node-dev/load-script.mjs +38 -49
  329. package/dist/node-dev/load-script.mjs.map +1 -1
  330. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js +185 -124
  331. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js.map +1 -1
  332. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  333. package/dist/node-dev/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  334. package/dist/node-dev/optionValueDecoder.js +103 -84
  335. package/dist/node-dev/optionValueDecoder.js.map +1 -1
  336. package/dist/node-dev/optionValueDecoder.mjs +104 -86
  337. package/dist/node-dev/optionValueDecoder.mjs.map +1 -1
  338. package/dist/node-dev/packages/hydrogen-react/package.js +6 -0
  339. package/dist/node-dev/packages/hydrogen-react/package.js.map +1 -0
  340. package/dist/node-dev/packages/hydrogen-react/package.mjs +6 -0
  341. package/dist/node-dev/packages/hydrogen-react/package.mjs.map +1 -0
  342. package/dist/node-dev/parse-metafield.js +122 -134
  343. package/dist/node-dev/parse-metafield.js.map +1 -1
  344. package/dist/node-dev/parse-metafield.mjs +122 -134
  345. package/dist/node-dev/parse-metafield.mjs.map +1 -1
  346. package/dist/node-dev/storefront-api-constants.js +5 -4
  347. package/dist/node-dev/storefront-api-constants.js.map +1 -1
  348. package/dist/node-dev/storefront-api-constants.mjs +6 -5
  349. package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
  350. package/dist/node-dev/storefront-client.js +62 -101
  351. package/dist/node-dev/storefront-client.js.map +1 -1
  352. package/dist/node-dev/storefront-client.mjs +62 -102
  353. package/dist/node-dev/storefront-client.mjs.map +1 -1
  354. package/dist/node-dev/tracking-utils.js +67 -85
  355. package/dist/node-dev/tracking-utils.js.map +1 -1
  356. package/dist/node-dev/tracking-utils.mjs +68 -88
  357. package/dist/node-dev/tracking-utils.mjs.map +1 -1
  358. package/dist/node-dev/useCartAPIStateMachine.js +192 -349
  359. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  360. package/dist/node-dev/useCartAPIStateMachine.mjs +188 -346
  361. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  362. package/dist/node-dev/useCartActions.js +198 -172
  363. package/dist/node-dev/useCartActions.js.map +1 -1
  364. package/dist/node-dev/useCartActions.mjs +197 -172
  365. package/dist/node-dev/useCartActions.mjs.map +1 -1
  366. package/dist/node-dev/useMachine.js +50 -61
  367. package/dist/node-dev/useMachine.js.map +1 -1
  368. package/dist/node-dev/useMachine.mjs +50 -62
  369. package/dist/node-dev/useMachine.mjs.map +1 -1
  370. package/dist/node-dev/useMoney.js +177 -154
  371. package/dist/node-dev/useMoney.js.map +1 -1
  372. package/dist/node-dev/useMoney.mjs +176 -154
  373. package/dist/node-dev/useMoney.mjs.map +1 -1
  374. package/dist/node-dev/useSelectedOptionInUrlParam.js +18 -27
  375. package/dist/node-dev/useSelectedOptionInUrlParam.js.map +1 -1
  376. package/dist/node-dev/useSelectedOptionInUrlParam.mjs +17 -27
  377. package/dist/node-dev/useSelectedOptionInUrlParam.mjs.map +1 -1
  378. package/dist/node-dev/useShopifyCookies.js +124 -138
  379. package/dist/node-dev/useShopifyCookies.js.map +1 -1
  380. package/dist/node-dev/useShopifyCookies.mjs +123 -138
  381. package/dist/node-dev/useShopifyCookies.mjs.map +1 -1
  382. package/dist/node-prod/AddToCartButton.js +64 -73
  383. package/dist/node-prod/AddToCartButton.js.map +1 -1
  384. package/dist/node-prod/AddToCartButton.mjs +60 -71
  385. package/dist/node-prod/AddToCartButton.mjs.map +1 -1
  386. package/dist/node-prod/BaseButton.js +21 -26
  387. package/dist/node-prod/BaseButton.js.map +1 -1
  388. package/dist/node-prod/BaseButton.mjs +20 -26
  389. package/dist/node-prod/BaseButton.mjs.map +1 -1
  390. package/dist/node-prod/BuyNowButton.js +42 -46
  391. package/dist/node-prod/BuyNowButton.js.map +1 -1
  392. package/dist/node-prod/BuyNowButton.mjs +40 -45
  393. package/dist/node-prod/BuyNowButton.mjs.map +1 -1
  394. package/dist/node-prod/CartCheckoutButton.js +30 -24
  395. package/dist/node-prod/CartCheckoutButton.js.map +1 -1
  396. package/dist/node-prod/CartCheckoutButton.mjs +28 -23
  397. package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
  398. package/dist/node-prod/CartCost.js +27 -22
  399. package/dist/node-prod/CartCost.js.map +1 -1
  400. package/dist/node-prod/CartCost.mjs +26 -22
  401. package/dist/node-prod/CartCost.mjs.map +1 -1
  402. package/dist/node-prod/CartLineProvider.js +24 -17
  403. package/dist/node-prod/CartLineProvider.js.map +1 -1
  404. package/dist/node-prod/CartLineProvider.mjs +23 -18
  405. package/dist/node-prod/CartLineProvider.mjs.map +1 -1
  406. package/dist/node-prod/CartLineQuantity.js +19 -9
  407. package/dist/node-prod/CartLineQuantity.js.map +1 -1
  408. package/dist/node-prod/CartLineQuantity.mjs +18 -9
  409. package/dist/node-prod/CartLineQuantity.mjs.map +1 -1
  410. package/dist/node-prod/CartLineQuantityAdjustButton.js +50 -46
  411. package/dist/node-prod/CartLineQuantityAdjustButton.js.map +1 -1
  412. package/dist/node-prod/CartLineQuantityAdjustButton.mjs +48 -45
  413. package/dist/node-prod/CartLineQuantityAdjustButton.mjs.map +1 -1
  414. package/dist/node-prod/CartProvider.js +317 -385
  415. package/dist/node-prod/CartProvider.js.map +1 -1
  416. package/dist/node-prod/CartProvider.mjs +315 -385
  417. package/dist/node-prod/CartProvider.mjs.map +1 -1
  418. package/dist/node-prod/ExternalVideo.js +36 -47
  419. package/dist/node-prod/ExternalVideo.js.map +1 -1
  420. package/dist/node-prod/ExternalVideo.mjs +35 -47
  421. package/dist/node-prod/ExternalVideo.mjs.map +1 -1
  422. package/dist/node-prod/Image.js +328 -340
  423. package/dist/node-prod/Image.js.map +1 -1
  424. package/dist/node-prod/Image.mjs +326 -325
  425. package/dist/node-prod/Image.mjs.map +1 -1
  426. package/dist/node-prod/MediaFile.js +47 -65
  427. package/dist/node-prod/MediaFile.js.map +1 -1
  428. package/dist/node-prod/MediaFile.mjs +44 -63
  429. package/dist/node-prod/MediaFile.mjs.map +1 -1
  430. package/dist/node-prod/ModelViewer.js +118 -135
  431. package/dist/node-prod/ModelViewer.js.map +1 -1
  432. package/dist/node-prod/ModelViewer.mjs +117 -135
  433. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  434. package/dist/node-prod/Money.js +54 -39
  435. package/dist/node-prod/Money.js.map +1 -1
  436. package/dist/node-prod/Money.mjs +53 -39
  437. package/dist/node-prod/Money.mjs.map +1 -1
  438. package/dist/node-prod/ProductPrice.js +45 -61
  439. package/dist/node-prod/ProductPrice.js.map +1 -1
  440. package/dist/node-prod/ProductPrice.mjs +44 -61
  441. package/dist/node-prod/ProductPrice.mjs.map +1 -1
  442. package/dist/node-prod/ProductProvider.js +148 -178
  443. package/dist/node-prod/ProductProvider.js.map +1 -1
  444. package/dist/node-prod/ProductProvider.mjs +147 -179
  445. package/dist/node-prod/ProductProvider.mjs.map +1 -1
  446. package/dist/node-prod/RichText.components.js +37 -46
  447. package/dist/node-prod/RichText.components.js.map +1 -1
  448. package/dist/node-prod/RichText.components.mjs +36 -46
  449. package/dist/node-prod/RichText.components.mjs.map +1 -1
  450. package/dist/node-prod/RichText.js +112 -154
  451. package/dist/node-prod/RichText.js.map +1 -1
  452. package/dist/node-prod/RichText.mjs +111 -154
  453. package/dist/node-prod/RichText.mjs.map +1 -1
  454. package/dist/node-prod/ShopPayButton.js +54 -81
  455. package/dist/node-prod/ShopPayButton.js.map +1 -1
  456. package/dist/node-prod/ShopPayButton.mjs +53 -81
  457. package/dist/node-prod/ShopPayButton.mjs.map +1 -1
  458. package/dist/node-prod/ShopifyProvider.js +73 -83
  459. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  460. package/dist/node-prod/ShopifyProvider.mjs +71 -84
  461. package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
  462. package/dist/node-prod/Video.js +36 -52
  463. package/dist/node-prod/Video.js.map +1 -1
  464. package/dist/node-prod/Video.mjs +35 -52
  465. package/dist/node-prod/Video.mjs.map +1 -1
  466. package/dist/node-prod/_virtual/_rolldown/runtime.js +23 -0
  467. package/dist/node-prod/analytics-constants.js +40 -39
  468. package/dist/node-prod/analytics-constants.js.map +1 -1
  469. package/dist/node-prod/analytics-constants.mjs +41 -43
  470. package/dist/node-prod/analytics-constants.mjs.map +1 -1
  471. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js +128 -210
  472. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js.map +1 -1
  473. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs +127 -214
  474. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -1
  475. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js +40 -51
  476. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js.map +1 -1
  477. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs +39 -50
  478. package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -1
  479. package/dist/node-prod/analytics-utils.js +77 -52
  480. package/dist/node-prod/analytics-utils.js.map +1 -1
  481. package/dist/node-prod/analytics-utils.mjs +78 -56
  482. package/dist/node-prod/analytics-utils.mjs.map +1 -1
  483. package/dist/node-prod/analytics.js +113 -154
  484. package/dist/node-prod/analytics.js.map +1 -1
  485. package/dist/node-prod/analytics.mjs +111 -153
  486. package/dist/node-prod/analytics.mjs.map +1 -1
  487. package/dist/node-prod/cart-constants.js +10 -9
  488. package/dist/node-prod/cart-constants.js.map +1 -1
  489. package/dist/node-prod/cart-constants.mjs +11 -15
  490. package/dist/node-prod/cart-constants.mjs.map +1 -1
  491. package/dist/node-prod/cart-hooks.js +43 -57
  492. package/dist/node-prod/cart-hooks.js.map +1 -1
  493. package/dist/node-prod/cart-hooks.mjs +42 -57
  494. package/dist/node-prod/cart-hooks.mjs.map +1 -1
  495. package/dist/node-prod/cart-queries.js +27 -56
  496. package/dist/node-prod/cart-queries.js.map +1 -1
  497. package/dist/node-prod/cart-queries.mjs +28 -66
  498. package/dist/node-prod/cart-queries.mjs.map +1 -1
  499. package/dist/node-prod/codegen.helpers.js +30 -18
  500. package/dist/node-prod/codegen.helpers.js.map +1 -1
  501. package/dist/node-prod/codegen.helpers.mjs +31 -20
  502. package/dist/node-prod/codegen.helpers.mjs.map +1 -1
  503. package/dist/node-prod/cookies-utils.js +45 -42
  504. package/dist/node-prod/cookies-utils.js.map +1 -1
  505. package/dist/node-prod/cookies-utils.mjs +44 -42
  506. package/dist/node-prod/cookies-utils.mjs.map +1 -1
  507. package/dist/node-prod/flatten-connection.js +22 -24
  508. package/dist/node-prod/flatten-connection.js.map +1 -1
  509. package/dist/node-prod/flatten-connection.mjs +23 -25
  510. package/dist/node-prod/flatten-connection.mjs.map +1 -1
  511. package/dist/node-prod/getProductOptions.js +248 -224
  512. package/dist/node-prod/getProductOptions.js.map +1 -1
  513. package/dist/node-prod/getProductOptions.mjs +248 -226
  514. package/dist/node-prod/getProductOptions.mjs.map +1 -1
  515. package/dist/node-prod/index.js +88 -90
  516. package/dist/node-prod/index.mjs +15 -70
  517. package/dist/node-prod/load-script.js +38 -48
  518. package/dist/node-prod/load-script.js.map +1 -1
  519. package/dist/node-prod/load-script.mjs +38 -49
  520. package/dist/node-prod/load-script.mjs.map +1 -1
  521. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js +185 -124
  522. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.js.map +1 -1
  523. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs +175 -123
  524. package/dist/node-prod/node_modules/.pnpm/@xstate_fsm@2.0.0/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
  525. package/dist/node-prod/optionValueDecoder.js +103 -84
  526. package/dist/node-prod/optionValueDecoder.js.map +1 -1
  527. package/dist/node-prod/optionValueDecoder.mjs +104 -86
  528. package/dist/node-prod/optionValueDecoder.mjs.map +1 -1
  529. package/dist/node-prod/packages/hydrogen-react/package.js +6 -0
  530. package/dist/node-prod/packages/hydrogen-react/package.js.map +1 -0
  531. package/dist/node-prod/packages/hydrogen-react/package.mjs +6 -0
  532. package/dist/node-prod/packages/hydrogen-react/package.mjs.map +1 -0
  533. package/dist/node-prod/parse-metafield.js +134 -146
  534. package/dist/node-prod/parse-metafield.js.map +1 -1
  535. package/dist/node-prod/parse-metafield.mjs +134 -146
  536. package/dist/node-prod/parse-metafield.mjs.map +1 -1
  537. package/dist/node-prod/storefront-api-constants.js +5 -4
  538. package/dist/node-prod/storefront-api-constants.js.map +1 -1
  539. package/dist/node-prod/storefront-api-constants.mjs +6 -5
  540. package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
  541. package/dist/node-prod/storefront-client.js +56 -83
  542. package/dist/node-prod/storefront-client.js.map +1 -1
  543. package/dist/node-prod/storefront-client.mjs +56 -84
  544. package/dist/node-prod/storefront-client.mjs.map +1 -1
  545. package/dist/node-prod/tracking-utils.js +67 -85
  546. package/dist/node-prod/tracking-utils.js.map +1 -1
  547. package/dist/node-prod/tracking-utils.mjs +68 -88
  548. package/dist/node-prod/tracking-utils.mjs.map +1 -1
  549. package/dist/node-prod/useCartAPIStateMachine.js +192 -349
  550. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  551. package/dist/node-prod/useCartAPIStateMachine.mjs +188 -346
  552. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  553. package/dist/node-prod/useCartActions.js +198 -172
  554. package/dist/node-prod/useCartActions.js.map +1 -1
  555. package/dist/node-prod/useCartActions.mjs +197 -172
  556. package/dist/node-prod/useCartActions.mjs.map +1 -1
  557. package/dist/node-prod/useMachine.js +50 -61
  558. package/dist/node-prod/useMachine.js.map +1 -1
  559. package/dist/node-prod/useMachine.mjs +50 -62
  560. package/dist/node-prod/useMachine.mjs.map +1 -1
  561. package/dist/node-prod/useMoney.js +177 -154
  562. package/dist/node-prod/useMoney.js.map +1 -1
  563. package/dist/node-prod/useMoney.mjs +176 -154
  564. package/dist/node-prod/useMoney.mjs.map +1 -1
  565. package/dist/node-prod/useSelectedOptionInUrlParam.js +18 -27
  566. package/dist/node-prod/useSelectedOptionInUrlParam.js.map +1 -1
  567. package/dist/node-prod/useSelectedOptionInUrlParam.mjs +17 -27
  568. package/dist/node-prod/useSelectedOptionInUrlParam.mjs.map +1 -1
  569. package/dist/node-prod/useShopifyCookies.js +124 -138
  570. package/dist/node-prod/useShopifyCookies.js.map +1 -1
  571. package/dist/node-prod/useShopifyCookies.mjs +123 -138
  572. package/dist/node-prod/useShopifyCookies.mjs.map +1 -1
  573. package/dist/umd/hydrogen-react.dev.js +3930 -4418
  574. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  575. package/dist/umd/hydrogen-react.prod.js +35 -49
  576. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  577. package/package.json +5 -5
  578. package/dist/browser-dev/index.mjs.map +0 -1
  579. package/dist/browser-dev/packages/hydrogen-react/package.json.mjs +0 -5
  580. package/dist/browser-dev/packages/hydrogen-react/package.json.mjs.map +0 -1
  581. package/dist/browser-prod/index.mjs.map +0 -1
  582. package/dist/browser-prod/packages/hydrogen-react/package.json.mjs +0 -5
  583. package/dist/browser-prod/packages/hydrogen-react/package.json.mjs.map +0 -1
  584. package/dist/node-dev/index.js.map +0 -1
  585. package/dist/node-dev/index.mjs.map +0 -1
  586. package/dist/node-dev/packages/hydrogen-react/package.json.js +0 -5
  587. package/dist/node-dev/packages/hydrogen-react/package.json.js.map +0 -1
  588. package/dist/node-dev/packages/hydrogen-react/package.json.mjs +0 -5
  589. package/dist/node-dev/packages/hydrogen-react/package.json.mjs.map +0 -1
  590. package/dist/node-prod/index.js.map +0 -1
  591. package/dist/node-prod/index.mjs.map +0 -1
  592. package/dist/node-prod/packages/hydrogen-react/package.json.js +0 -5
  593. package/dist/node-prod/packages/hydrogen-react/package.json.js.map +0 -1
  594. package/dist/node-prod/packages/hydrogen-react/package.json.mjs +0 -5
  595. package/dist/node-prod/packages/hydrogen-react/package.json.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Image.mjs","sources":["../../src/Image.tsx"],"sourcesContent":["/* eslint-disable eslint-comments/disable-enable-pair */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport * as React from 'react';\nimport type {PartialDeep} from 'type-fest';\nimport type {Image as ImageType} from './storefront-api-types.js';\n\n/*\n * An optional prop you can use to change the\n * default srcSet generation behaviour\n */\ntype SrcSetOptions = {\n /** The number of sizes to generate */\n intervals: number;\n /** The smallest image size */\n startingWidth: number;\n /** The increment by which to increase for each size, in pixels */\n incrementSize: number;\n /** The size used for placeholder fallback images */\n placeholderWidth: number;\n};\n\ntype NormalizedProps = {\n alt: string;\n aspectRatio: string | undefined;\n height: string;\n src: string | undefined;\n width: string;\n};\n\nexport type LoaderParams = {\n /** The base URL of the image */\n src?: ImageType['url'];\n /** The URL param that controls width */\n width?: number;\n /** The URL param that controls height */\n height?: number;\n /** The URL param that controls the cropping region */\n crop?: Crop;\n};\n\nexport type Loader = (params: LoaderParams) => string;\n\n/*\n * @TODO: Expand to include focal point support; and/or switch this to be an SF API type\n */\ntype Crop = 'center' | 'top' | 'bottom' | 'left' | 'right';\n\n/** @publicDocs */\nexport type HydrogenImageProps = React.ComponentPropsWithRef<'img'> &\n HydrogenImageBaseProps;\n\ntype HydrogenImageBaseProps = {\n /** The aspect ratio of the image, in the format of `width/height`.\n *\n * @example\n * ```\n * <Image data={productImage} aspectRatio=\"4/5\" />\n * ```\n */\n aspectRatio?: string;\n /** The crop position of the image.\n *\n * @remarks\n * In the event that AspectRatio is set, without specifying a crop,\n * the Shopify CDN won't return the expected image.\n *\n * @defaultValue `center`\n */\n crop?: Crop;\n /** Data mapping to the [Storefront API `Image`](https://shopify.dev/docs/api/storefront/2026-04/objects/Image) object. Must be an Image object.\n *\n * @example\n * ```\n * import {IMAGE_FRAGMENT, Image} from '@shopify/hydrogen';\n *\n * export const IMAGE_QUERY = `#graphql\n * ${IMAGE_FRAGMENT}\n * query {\n * product {\n * featuredImage {\n * ...Image\n * }\n * }\n * }`\n *\n * <Image\n * data={productImage}\n * sizes=\"(min-width: 45em) 50vw, 100vw\"\n * aspectRatio=\"4/5\"\n * />\n * ```\n *\n * Image: {@link https://shopify.dev/api/storefront/reference/common-objects/image}\n */\n data?: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A function that returns a URL string for an image.\n *\n * @remarks\n * By default, this uses Shopify’s CDN {@link https://cdn.shopify.com/} but you can provide\n * your own function to use a another provider, as long as they support URL based image transformations.\n */\n loader?: Loader;\n /** An optional prop you can use to change the default srcSet generation behaviour */\n srcSetOptions?: SrcSetOptions;\n};\n\n/**\n * A Storefront API GraphQL fragment that can be used to query for an image.\n */\nexport const IMAGE_FRAGMENT = `#graphql\n fragment Image on Image {\n altText\n url\n width\n height\n }\n`;\n\n/**\n * Hydrogen’s Image component is a wrapper around the HTML image element.\n * It supports the same props as the HTML `img` element, but automatically\n * generates the srcSet and sizes attributes for you. For most use cases,\n * you’ll want to set the `aspectRatio` prop to ensure the image is sized\n * correctly.\n *\n * @remarks\n * - `decoding` is set to `async` by default.\n * - `loading` is set to `lazy` by default.\n * - `alt` will automatically be set to the `altText` from the Storefront API if passed in the `data` prop\n * - `src` will automatically be set to the `url` from the Storefront API if passed in the `data` prop\n *\n * @example\n * A responsive image with a 4:5 aspect ratio:\n * ```\n * <Image\n * data={product.featuredImage}\n * aspectRatio=\"4/5\"\n * sizes=\"(min-width: 45em) 40vw, 100vw\"\n * />\n * ```\n * @example\n * A fixed size image:\n * ```\n * <Image\n * data={product.featuredImage}\n * width={100}\n * height={100}\n * />\n * ```\n *\n * {@link https://shopify.dev/docs/api/hydrogen-react/components/image}\n * @publicDocs\n */\nexport const Image = React.forwardRef<HTMLImageElement, HydrogenImageProps>(\n (\n {\n alt,\n aspectRatio,\n crop = 'center',\n data,\n decoding = 'async',\n height = 'auto',\n loader = shopifyLoader,\n loading = 'lazy',\n sizes,\n src,\n srcSetOptions = {\n intervals: 15,\n startingWidth: 200,\n incrementSize: 200,\n placeholderWidth: 100,\n },\n width = '100%',\n ...passthroughProps\n },\n ref,\n ) => {\n /*\n * Gets normalized values for width, height from data prop\n */\n const normalizedData = React.useMemo(() => {\n /* Only use data width if height is also set */\n const dataWidth: number | undefined =\n data?.width && data?.height ? data?.width : undefined;\n\n const dataHeight: number | undefined =\n data?.width && data?.height ? data?.height : undefined;\n\n return {\n width: dataWidth,\n height: dataHeight,\n unitsMatch: Boolean(unitsMatch(dataWidth, dataHeight)),\n };\n }, [data]);\n\n /*\n * Gets normalized values for width, height, src, alt, and aspectRatio props\n * supporting the presence of `data` in addition to flat props.\n */\n const normalizedProps = React.useMemo(() => {\n const nWidthProp: string | number = width || '100%';\n const widthParts = getUnitValueParts(nWidthProp.toString());\n const nWidth = `${widthParts.number}${widthParts.unit}`;\n\n const autoHeight = height === undefined || height === null;\n const heightParts = autoHeight\n ? null\n : getUnitValueParts(height.toString());\n\n const fixedHeight = heightParts\n ? `${heightParts.number}${heightParts.unit}`\n : '';\n\n const nHeight = autoHeight ? 'auto' : fixedHeight;\n\n const nSrc: string | undefined = src || data?.url;\n\n if (__HYDROGEN_DEV__ && !nSrc) {\n console.warn(\n `No src or data.url provided to Image component.`,\n passthroughProps?.key || '',\n );\n }\n\n const nAlt: string = data?.altText && !alt ? data?.altText : alt || '';\n\n const nAspectRatio: string | undefined = aspectRatio\n ? aspectRatio\n : normalizedData.unitsMatch\n ? [\n getNormalizedFixedUnit(normalizedData.width),\n getNormalizedFixedUnit(normalizedData.height),\n ].join('/')\n : undefined;\n\n return {\n width: nWidth,\n height: nHeight,\n src: nSrc,\n alt: nAlt,\n aspectRatio: nAspectRatio,\n };\n }, [\n width,\n height,\n src,\n data,\n alt,\n aspectRatio,\n normalizedData,\n passthroughProps?.key,\n ]);\n\n const {intervals, startingWidth, incrementSize, placeholderWidth} =\n srcSetOptions;\n\n /*\n * This function creates an array of widths to be used in srcSet\n */\n const imageWidths = React.useMemo(() => {\n return generateImageWidths(\n width,\n intervals,\n startingWidth,\n incrementSize,\n );\n }, [width, intervals, startingWidth, incrementSize]);\n\n const fixedWidth = isFixedWidth(normalizedProps.width);\n\n if (__HYDROGEN_DEV__ && !sizes && !fixedWidth) {\n console.warn(\n [\n 'No sizes prop provided to Image component,',\n 'you may be loading unnecessarily large images.',\n `Image used is ${\n src || data?.url || passthroughProps?.key || 'unknown'\n }`,\n ].join(' '),\n );\n }\n\n /*\n * We check to see whether the image is fixed width or not,\n * if fixed, we still provide a srcSet, but only to account for\n * different pixel densities.\n */\n if (fixedWidth) {\n return (\n <FixedWidthImage\n aspectRatio={aspectRatio}\n crop={crop}\n decoding={decoding}\n height={height}\n imageWidths={imageWidths}\n loader={loader}\n loading={loading}\n normalizedProps={normalizedProps}\n passthroughProps={passthroughProps}\n ref={ref}\n width={width}\n data={data}\n />\n );\n } else {\n return (\n <FluidImage\n aspectRatio={aspectRatio}\n crop={crop}\n decoding={decoding}\n imageWidths={imageWidths}\n loader={loader}\n loading={loading}\n normalizedProps={normalizedProps}\n passthroughProps={passthroughProps}\n placeholderWidth={placeholderWidth}\n ref={ref}\n sizes={sizes}\n data={data}\n />\n );\n }\n },\n);\n\ntype FixedImageExludedProps =\n | 'data'\n | 'loader'\n | 'loaderOptions'\n | 'sizes'\n | 'srcSetOptions'\n | 'widths';\n\ntype FixedWidthImageProps = Omit<HydrogenImageProps, FixedImageExludedProps> &\n Pick<HydrogenImageBaseProps, 'data'> & {\n loader: Loader;\n passthroughProps: React.ImgHTMLAttributes<HTMLImageElement>;\n normalizedProps: NormalizedProps;\n imageWidths: number[];\n ref: React.Ref<HTMLImageElement>;\n };\n\nconst FixedWidthImage = React.forwardRef<\n HTMLImageElement,\n FixedWidthImageProps\n>(\n (\n {\n aspectRatio,\n crop,\n decoding,\n height,\n imageWidths,\n loader = shopifyLoader,\n loading,\n normalizedProps,\n passthroughProps,\n width,\n data,\n },\n ref,\n ) => {\n const fixed = React.useMemo(() => {\n const intWidth: number | undefined = getNormalizedFixedUnit(width);\n const intHeight: number | undefined = getNormalizedFixedUnit(height);\n\n /*\n * The aspect ratio for fixed width images is taken from the explicitly\n * set prop, but if that's not present, and both width and height are\n * set, we calculate the aspect ratio from the width and height—as\n * long as they share the same unit type (e.g. both are 'px').\n */\n const fixedAspectRatio = aspectRatio\n ? aspectRatio\n : unitsMatch(normalizedProps.width, normalizedProps.height)\n ? [intWidth, intHeight].join('/')\n : normalizedProps.aspectRatio\n ? normalizedProps.aspectRatio\n : undefined;\n\n /*\n * The Sizes Array generates an array of all the parts\n * that make up the srcSet, including the width, height, and crop\n */\n const sizesArray =\n imageWidths === undefined\n ? undefined\n : generateSizes(imageWidths, fixedAspectRatio, crop, {\n width: data?.width ?? undefined,\n height: data?.height ?? undefined,\n });\n\n const fixedHeight = intHeight\n ? intHeight\n : fixedAspectRatio && intWidth\n ? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1)\n : undefined;\n\n const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);\n const src = loader({\n src: normalizedProps.src,\n width: intWidth,\n height: fixedHeight,\n crop: normalizedProps.height === 'auto' ? undefined : crop,\n });\n\n return {\n width: intWidth,\n aspectRatio: fixedAspectRatio,\n height: fixedHeight,\n srcSet,\n src,\n };\n }, [\n aspectRatio,\n crop,\n data,\n height,\n imageWidths,\n loader,\n normalizedProps,\n width,\n ]);\n\n return (\n <img\n ref={ref}\n alt={normalizedProps.alt}\n decoding={decoding}\n height={fixed.height}\n loading={loading}\n src={fixed.src}\n srcSet={fixed.srcSet}\n width={fixed.width}\n style={{\n aspectRatio: fixed.aspectRatio,\n ...passthroughProps.style,\n }}\n {...passthroughProps}\n />\n );\n },\n);\n\ntype FluidImageExcludedProps =\n | 'data'\n | 'width'\n | 'height'\n | 'loader'\n | 'loaderOptions'\n | 'srcSetOptions';\n\ntype FluidImageProps = Omit<HydrogenImageProps, FluidImageExcludedProps> &\n Pick<HydrogenImageBaseProps, 'data'> & {\n imageWidths: number[];\n loader: Loader;\n normalizedProps: NormalizedProps;\n passthroughProps: React.ImgHTMLAttributes<HTMLImageElement>;\n placeholderWidth: number;\n ref: React.Ref<HTMLImageElement>;\n };\n\nconst FluidImage = React.forwardRef<HTMLImageElement, FluidImageProps>(\n (\n {\n crop,\n decoding,\n imageWidths,\n loader = shopifyLoader,\n loading,\n normalizedProps,\n passthroughProps,\n placeholderWidth,\n sizes,\n data,\n },\n ref,\n ) => {\n const fluid = React.useMemo(() => {\n const sizesArray =\n imageWidths === undefined\n ? undefined\n : generateSizes(imageWidths, normalizedProps.aspectRatio, crop, {\n width: data?.width ?? undefined,\n height: data?.height ?? undefined,\n });\n\n const placeholderHeight =\n normalizedProps.aspectRatio && placeholderWidth\n ? placeholderWidth *\n (parseAspectRatio(normalizedProps.aspectRatio) ?? 1)\n : undefined;\n\n const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);\n\n const src = loader({\n src: normalizedProps.src,\n width: placeholderWidth,\n height: placeholderHeight,\n crop,\n });\n\n return {\n placeholderHeight,\n srcSet,\n src,\n };\n }, [crop, data, imageWidths, loader, normalizedProps, placeholderWidth]);\n\n return (\n <img\n ref={ref}\n alt={normalizedProps.alt}\n decoding={decoding}\n height={fluid.placeholderHeight}\n loading={loading}\n sizes={sizes}\n src={fluid.src}\n srcSet={fluid.srcSet}\n width={placeholderWidth}\n {...passthroughProps}\n style={{\n width: normalizedProps.width,\n aspectRatio: normalizedProps.aspectRatio,\n ...passthroughProps.style,\n }}\n />\n );\n },\n);\n\n/**\n * The shopifyLoader function is a simple utility function that takes a src, width,\n * height, and crop and returns a string that can be used as the src for an image.\n * It can be used with the Hydrogen Image component or with the next/image component.\n * (or any others that accept equivalent configuration)\n * @param src - The source URL of the image, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg`\n * @param width - The width of the image, e.g. `100`\n * @param height - The height of the image, e.g. `100`\n * @param crop - The crop of the image, e.g. `center`\n * @returns A Shopify image URL with the correct query parameters, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=100&height=100&crop=center`\n *\n * @example\n * ```\n * shopifyLoader({\n * src: 'https://cdn.shopify.com/static/sample-images/garnished.jpeg',\n * width: 100,\n * height: 100,\n * crop: 'center',\n * })\n * ```\n */\nconst PLACEHOLDER_DOMAIN = 'https://placeholder.shopify.com';\nexport function shopifyLoader({src, width, height, crop}: LoaderParams) {\n if (!src) {\n return '';\n }\n\n const url = new URL(src, PLACEHOLDER_DOMAIN);\n\n if (width) {\n url.searchParams.append('width', Math.round(width).toString());\n }\n\n if (height) {\n url.searchParams.append('height', Math.round(height).toString());\n }\n\n if (crop) {\n url.searchParams.append('crop', crop);\n }\n return url.href.replace(PLACEHOLDER_DOMAIN, '');\n}\n\n/**\n * Checks whether the width and height share the same unit type\n * @param width - The width of the image, e.g. 100% | 10px\n * @param height - The height of the image, e.g. auto | 100px\n * @returns Whether the width and height share the same unit type (boolean)\n */\nfunction unitsMatch(\n width: string | number = '100%',\n height: string | number = 'auto',\n): boolean {\n return (\n getUnitValueParts(width.toString()).unit ===\n getUnitValueParts(height.toString()).unit\n );\n}\n\n/**\n * Given a CSS size, returns the unit and number parts of the value\n * @param value - The CSS size, e.g. 100px\n * @returns The unit and number parts of the value, e.g. \\{unit: 'px', number: 100\\}\n */\nfunction getUnitValueParts(value: string): {unit: string; number: number} {\n const unit = value.replace(/[0-9.]/g, '');\n const number = parseFloat(value.replace(unit, ''));\n\n return {\n unit: unit === '' ? (number === undefined ? 'auto' : 'px') : unit,\n number,\n };\n}\n\n/**\n * Given a value, returns the width of the image as an integer in pixels\n * @param value - The width of the image, e.g. 16px | 1rem | 1em | 16\n * @returns The width of the image in pixels, e.g. 16, or undefined if the value is not a fixed unit\n */\nfunction getNormalizedFixedUnit(value?: string | number): number | undefined {\n if (value === undefined) {\n return;\n }\n\n const {unit, number} = getUnitValueParts(value.toString());\n\n switch (unit) {\n case 'em':\n return number * 16;\n case 'rem':\n return number * 16;\n case 'px':\n return number;\n case '':\n return number;\n default:\n return;\n }\n}\n\n/**\n * This function checks whether a width is fixed or not.\n * @param width - The width of the image, e.g. 100 | '100px' | '100em' | '100rem'\n * @returns Whether the width is fixed or not\n */\nfunction isFixedWidth(width: string | number): boolean {\n const fixedEndings = /\\d(px|em|rem)$/;\n return typeof width === 'number' || fixedEndings.test(width);\n}\n\n/**\n * This function generates a srcSet for Shopify images.\n * @param src - The source URL of the image, e.g. https://cdn.shopify.com/static/sample-images/garnished.jpeg\n * @param sizesArray - An array of objects containing the `width`, `height`, and `crop` of the image, e.g. [\\{width: 200, height: 200, crop: 'center'\\}, \\{width: 400, height: 400, crop: 'center'\\}]\n * @param loader - A function that takes a Shopify image URL and returns a Shopify image URL with the correct query parameters\n * @returns A srcSet for Shopify images, e.g. 'https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=200&height=200&crop=center 200w, https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=400&height=400&crop=center 400w'\n */\nexport function generateSrcSet(\n src?: string,\n sizesArray?: Array<{width?: number; height?: number; crop?: Crop}>,\n loader: Loader = shopifyLoader,\n): string {\n if (!src) {\n return '';\n }\n\n if (sizesArray?.length === 0 || !sizesArray) {\n return src;\n }\n\n return sizesArray\n .map(\n (size, i) =>\n `${loader({\n src,\n width: size.width,\n height: size.height,\n crop: size.crop,\n })} ${sizesArray.length === 3 ? `${i + 1}x` : `${size.width ?? 0}w`}`,\n )\n .join(`, `);\n}\n\n/**\n * This function generates an array of sizes for Shopify images, for both fixed and responsive images.\n * @param width - The CSS width of the image\n * @param intervals - The number of intervals to generate\n * @param startingWidth - The starting width of the image\n * @param incrementSize - The size of each interval\n * @returns An array of widths\n */\nexport function generateImageWidths(\n width: string | number = '100%',\n intervals: number,\n startingWidth: number,\n incrementSize: number,\n): number[] {\n const responsive = Array.from(\n {length: intervals},\n (_, i) => i * incrementSize + startingWidth,\n );\n\n const fixed = Array.from(\n {length: 3},\n (_, i) => (i + 1) * (getNormalizedFixedUnit(width) ?? 0),\n );\n\n return isFixedWidth(width) ? fixed : responsive;\n}\n\n/**\n * Simple utility function to convert an aspect ratio CSS string to a decimal, currently only supports values like `1/1`, not `0.5`, or `auto`\n * @param aspectRatio - The aspect ratio of the image, e.g. `1/1`\n * @returns The aspect ratio as a number, e.g. `0.5`\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio}\n */\nexport function parseAspectRatio(aspectRatio?: string): number | undefined {\n if (!aspectRatio) return;\n const [width, height] = aspectRatio.split('/');\n return 1 / (Number(width) / Number(height));\n}\n\n// Generate data needed for Imagery loader\nexport function generateSizes(\n imageWidths?: number[],\n aspectRatio?: string,\n crop: Crop = 'center',\n sourceDimensions?: {width?: number; height?: number},\n):\n | {\n width: number;\n height: number | undefined;\n crop: Crop;\n }[]\n | undefined {\n if (!imageWidths) return;\n return imageWidths\n .map((width: number) => {\n return {\n width,\n height: aspectRatio\n ? width * (parseAspectRatio(aspectRatio) ?? 1)\n : undefined,\n crop,\n };\n })\n .filter(({width, height}) => {\n if (sourceDimensions?.width && width > sourceDimensions.width) {\n return false;\n }\n\n if (\n sourceDimensions?.height &&\n height &&\n height > sourceDimensions.height\n ) {\n return false;\n }\n\n return true;\n });\n /*\n Given:\n ([100, 200], 1/1, 'center')\n Returns:\n [{width: 100, height: 100, crop: 'center'},\n {width: 200, height: 200, crop: 'center'}]\n */\n}\n"],"names":[],"mappings":";;AA6GO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CvB,MAAM,QAAQ,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AAK;AAAA,IAAA,CACZ,CAAC,IAAI,WAAW,WAAW,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,SAAS,CAAC,GAAG;AAAA,EAAA,EAEtE,KAAK,IAAI;AACd;AAUO,SAAS,oBACd,QAAyB,QACzB,WACA,eACA,eACU;AACV,QAAM,aAAa,MAAM;AAAA,IACvB,EAAC,QAAQ,UAAA;AAAA,IACT,CAAC,GAAG,MAAM,IAAI,gBAAgB;AAAA,EAAA;AAGhC,QAAM,QAAQ,MAAM;AAAA,IAClB,EAAC,QAAQ,EAAA;AAAA,IACT,CAAC,GAAG,OAAO,IAAI,MAAM,uBAAuB,KAAK,KAAK;AAAA,EAAA;AAGxD,SAAO,aAAa,KAAK,IAAI,QAAQ;AACvC;AASO,SAAS,iBAAiB,aAA0C;AACzE,MAAI,CAAC,YAAa;AAClB,QAAM,CAAC,OAAO,MAAM,IAAI,YAAY,MAAM,GAAG;AAC7C,SAAO,KAAK,OAAO,KAAK,IAAI,OAAO,MAAM;AAC3C;AAGO,SAAS,cACd,aACA,aACA,OAAa,UACb,kBAOY;AACZ,MAAI,CAAC,YAAa;AAClB,SAAO,YACJ,IAAI,CAAC,UAAkB;AACtB,WAAO;AAAA,MACL;AAAA,MACA,QAAQ,cACJ,SAAS,iBAAiB,WAAW,KAAK,KAC1C;AAAA,MACJ;AAAA,IAAA;AAAA,EAEJ,CAAC,EACA,OAAO,CAAC,EAAC,OAAO,aAAY;AAC3B,SAAI,qDAAkB,UAAS,QAAQ,iBAAiB,OAAO;AAC7D,aAAO;AAAA,IACT;AAEA,SACE,qDAAkB,WAClB,UACA,SAAS,iBAAiB,QAC1B;AACA,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,CAAC;AAQL;"}
1
+ {"version":3,"file":"Image.mjs","names":[],"sources":["../../src/Image.tsx"],"sourcesContent":["/* eslint-disable eslint-comments/disable-enable-pair */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport * as React from 'react';\nimport type {PartialDeep} from 'type-fest';\nimport type {Image as ImageType} from './storefront-api-types.js';\n\n/*\n * An optional prop you can use to change the\n * default srcSet generation behaviour\n */\ntype SrcSetOptions = {\n /** The number of sizes to generate */\n intervals: number;\n /** The smallest image size */\n startingWidth: number;\n /** The increment by which to increase for each size, in pixels */\n incrementSize: number;\n /** The size used for placeholder fallback images */\n placeholderWidth: number;\n};\n\ntype NormalizedProps = {\n alt: string;\n aspectRatio: string | undefined;\n height: string;\n src: string | undefined;\n width: string;\n};\n\nexport type LoaderParams = {\n /** The base URL of the image */\n src?: ImageType['url'];\n /** The URL param that controls width */\n width?: number;\n /** The URL param that controls height */\n height?: number;\n /** The URL param that controls the cropping region */\n crop?: Crop;\n};\n\nexport type Loader = (params: LoaderParams) => string;\n\n/*\n * @TODO: Expand to include focal point support; and/or switch this to be an SF API type\n */\ntype Crop = 'center' | 'top' | 'bottom' | 'left' | 'right';\n\n/** @publicDocs */\nexport type HydrogenImageProps = React.ComponentPropsWithRef<'img'> &\n HydrogenImageBaseProps;\n\ntype HydrogenImageBaseProps = {\n /** The aspect ratio of the image, in the format of `width/height`.\n *\n * @example\n * ```\n * <Image data={productImage} aspectRatio=\"4/5\" />\n * ```\n */\n aspectRatio?: string;\n /** The crop position of the image.\n *\n * @remarks\n * In the event that AspectRatio is set, without specifying a crop,\n * the Shopify CDN won't return the expected image.\n *\n * @defaultValue `center`\n */\n crop?: Crop;\n /** Data mapping to the [Storefront API `Image`](https://shopify.dev/docs/api/storefront/2026-04/objects/Image) object. Must be an Image object.\n *\n * @example\n * ```\n * import {IMAGE_FRAGMENT, Image} from '@shopify/hydrogen';\n *\n * export const IMAGE_QUERY = `#graphql\n * ${IMAGE_FRAGMENT}\n * query {\n * product {\n * featuredImage {\n * ...Image\n * }\n * }\n * }`\n *\n * <Image\n * data={productImage}\n * sizes=\"(min-width: 45em) 50vw, 100vw\"\n * aspectRatio=\"4/5\"\n * />\n * ```\n *\n * Image: {@link https://shopify.dev/api/storefront/reference/common-objects/image}\n */\n data?: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A function that returns a URL string for an image.\n *\n * @remarks\n * By default, this uses Shopify’s CDN {@link https://cdn.shopify.com/} but you can provide\n * your own function to use a another provider, as long as they support URL based image transformations.\n */\n loader?: Loader;\n /** An optional prop you can use to change the default srcSet generation behaviour */\n srcSetOptions?: SrcSetOptions;\n};\n\n/**\n * A Storefront API GraphQL fragment that can be used to query for an image.\n */\nexport const IMAGE_FRAGMENT = `#graphql\n fragment Image on Image {\n altText\n url\n width\n height\n }\n`;\n\n/**\n * Hydrogen’s Image component is a wrapper around the HTML image element.\n * It supports the same props as the HTML `img` element, but automatically\n * generates the srcSet and sizes attributes for you. For most use cases,\n * you’ll want to set the `aspectRatio` prop to ensure the image is sized\n * correctly.\n *\n * @remarks\n * - `decoding` is set to `async` by default.\n * - `loading` is set to `lazy` by default.\n * - `alt` will automatically be set to the `altText` from the Storefront API if passed in the `data` prop\n * - `src` will automatically be set to the `url` from the Storefront API if passed in the `data` prop\n *\n * @example\n * A responsive image with a 4:5 aspect ratio:\n * ```\n * <Image\n * data={product.featuredImage}\n * aspectRatio=\"4/5\"\n * sizes=\"(min-width: 45em) 40vw, 100vw\"\n * />\n * ```\n * @example\n * A fixed size image:\n * ```\n * <Image\n * data={product.featuredImage}\n * width={100}\n * height={100}\n * />\n * ```\n *\n * {@link https://shopify.dev/docs/api/hydrogen-react/components/image}\n * @publicDocs\n */\nexport const Image = React.forwardRef<HTMLImageElement, HydrogenImageProps>(\n (\n {\n alt,\n aspectRatio,\n crop = 'center',\n data,\n decoding = 'async',\n height = 'auto',\n loader = shopifyLoader,\n loading = 'lazy',\n sizes,\n src,\n srcSetOptions = {\n intervals: 15,\n startingWidth: 200,\n incrementSize: 200,\n placeholderWidth: 100,\n },\n width = '100%',\n ...passthroughProps\n },\n ref,\n ) => {\n /*\n * Gets normalized values for width, height from data prop\n */\n const normalizedData = React.useMemo(() => {\n /* Only use data width if height is also set */\n const dataWidth: number | undefined =\n data?.width && data?.height ? data?.width : undefined;\n\n const dataHeight: number | undefined =\n data?.width && data?.height ? data?.height : undefined;\n\n return {\n width: dataWidth,\n height: dataHeight,\n unitsMatch: Boolean(unitsMatch(dataWidth, dataHeight)),\n };\n }, [data]);\n\n /*\n * Gets normalized values for width, height, src, alt, and aspectRatio props\n * supporting the presence of `data` in addition to flat props.\n */\n const normalizedProps = React.useMemo(() => {\n const nWidthProp: string | number = width || '100%';\n const widthParts = getUnitValueParts(nWidthProp.toString());\n const nWidth = `${widthParts.number}${widthParts.unit}`;\n\n const autoHeight = height === undefined || height === null;\n const heightParts = autoHeight\n ? null\n : getUnitValueParts(height.toString());\n\n const fixedHeight = heightParts\n ? `${heightParts.number}${heightParts.unit}`\n : '';\n\n const nHeight = autoHeight ? 'auto' : fixedHeight;\n\n const nSrc: string | undefined = src || data?.url;\n\n if (__HYDROGEN_DEV__ && !nSrc) {\n console.warn(\n `No src or data.url provided to Image component.`,\n passthroughProps?.key || '',\n );\n }\n\n const nAlt: string = data?.altText && !alt ? data?.altText : alt || '';\n\n const nAspectRatio: string | undefined = aspectRatio\n ? aspectRatio\n : normalizedData.unitsMatch\n ? [\n getNormalizedFixedUnit(normalizedData.width),\n getNormalizedFixedUnit(normalizedData.height),\n ].join('/')\n : undefined;\n\n return {\n width: nWidth,\n height: nHeight,\n src: nSrc,\n alt: nAlt,\n aspectRatio: nAspectRatio,\n };\n }, [\n width,\n height,\n src,\n data,\n alt,\n aspectRatio,\n normalizedData,\n passthroughProps?.key,\n ]);\n\n const {intervals, startingWidth, incrementSize, placeholderWidth} =\n srcSetOptions;\n\n /*\n * This function creates an array of widths to be used in srcSet\n */\n const imageWidths = React.useMemo(() => {\n return generateImageWidths(\n width,\n intervals,\n startingWidth,\n incrementSize,\n );\n }, [width, intervals, startingWidth, incrementSize]);\n\n const fixedWidth = isFixedWidth(normalizedProps.width);\n\n if (__HYDROGEN_DEV__ && !sizes && !fixedWidth) {\n console.warn(\n [\n 'No sizes prop provided to Image component,',\n 'you may be loading unnecessarily large images.',\n `Image used is ${\n src || data?.url || passthroughProps?.key || 'unknown'\n }`,\n ].join(' '),\n );\n }\n\n /*\n * We check to see whether the image is fixed width or not,\n * if fixed, we still provide a srcSet, but only to account for\n * different pixel densities.\n */\n if (fixedWidth) {\n return (\n <FixedWidthImage\n aspectRatio={aspectRatio}\n crop={crop}\n decoding={decoding}\n height={height}\n imageWidths={imageWidths}\n loader={loader}\n loading={loading}\n normalizedProps={normalizedProps}\n passthroughProps={passthroughProps}\n ref={ref}\n width={width}\n data={data}\n />\n );\n } else {\n return (\n <FluidImage\n aspectRatio={aspectRatio}\n crop={crop}\n decoding={decoding}\n imageWidths={imageWidths}\n loader={loader}\n loading={loading}\n normalizedProps={normalizedProps}\n passthroughProps={passthroughProps}\n placeholderWidth={placeholderWidth}\n ref={ref}\n sizes={sizes}\n data={data}\n />\n );\n }\n },\n);\n\ntype FixedImageExludedProps =\n | 'data'\n | 'loader'\n | 'loaderOptions'\n | 'sizes'\n | 'srcSetOptions'\n | 'widths';\n\ntype FixedWidthImageProps = Omit<HydrogenImageProps, FixedImageExludedProps> &\n Pick<HydrogenImageBaseProps, 'data'> & {\n loader: Loader;\n passthroughProps: React.ImgHTMLAttributes<HTMLImageElement>;\n normalizedProps: NormalizedProps;\n imageWidths: number[];\n ref: React.Ref<HTMLImageElement>;\n };\n\nconst FixedWidthImage = React.forwardRef<\n HTMLImageElement,\n FixedWidthImageProps\n>(\n (\n {\n aspectRatio,\n crop,\n decoding,\n height,\n imageWidths,\n loader = shopifyLoader,\n loading,\n normalizedProps,\n passthroughProps,\n width,\n data,\n },\n ref,\n ) => {\n const fixed = React.useMemo(() => {\n const intWidth: number | undefined = getNormalizedFixedUnit(width);\n const intHeight: number | undefined = getNormalizedFixedUnit(height);\n\n /*\n * The aspect ratio for fixed width images is taken from the explicitly\n * set prop, but if that's not present, and both width and height are\n * set, we calculate the aspect ratio from the width and height—as\n * long as they share the same unit type (e.g. both are 'px').\n */\n const fixedAspectRatio = aspectRatio\n ? aspectRatio\n : unitsMatch(normalizedProps.width, normalizedProps.height)\n ? [intWidth, intHeight].join('/')\n : normalizedProps.aspectRatio\n ? normalizedProps.aspectRatio\n : undefined;\n\n /*\n * The Sizes Array generates an array of all the parts\n * that make up the srcSet, including the width, height, and crop\n */\n const sizesArray =\n imageWidths === undefined\n ? undefined\n : generateSizes(imageWidths, fixedAspectRatio, crop, {\n width: data?.width ?? undefined,\n height: data?.height ?? undefined,\n });\n\n const fixedHeight = intHeight\n ? intHeight\n : fixedAspectRatio && intWidth\n ? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1)\n : undefined;\n\n const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);\n const src = loader({\n src: normalizedProps.src,\n width: intWidth,\n height: fixedHeight,\n crop: normalizedProps.height === 'auto' ? undefined : crop,\n });\n\n return {\n width: intWidth,\n aspectRatio: fixedAspectRatio,\n height: fixedHeight,\n srcSet,\n src,\n };\n }, [\n aspectRatio,\n crop,\n data,\n height,\n imageWidths,\n loader,\n normalizedProps,\n width,\n ]);\n\n return (\n <img\n ref={ref}\n alt={normalizedProps.alt}\n decoding={decoding}\n height={fixed.height}\n loading={loading}\n src={fixed.src}\n srcSet={fixed.srcSet}\n width={fixed.width}\n style={{\n aspectRatio: fixed.aspectRatio,\n ...passthroughProps.style,\n }}\n {...passthroughProps}\n />\n );\n },\n);\n\ntype FluidImageExcludedProps =\n | 'data'\n | 'width'\n | 'height'\n | 'loader'\n | 'loaderOptions'\n | 'srcSetOptions';\n\ntype FluidImageProps = Omit<HydrogenImageProps, FluidImageExcludedProps> &\n Pick<HydrogenImageBaseProps, 'data'> & {\n imageWidths: number[];\n loader: Loader;\n normalizedProps: NormalizedProps;\n passthroughProps: React.ImgHTMLAttributes<HTMLImageElement>;\n placeholderWidth: number;\n ref: React.Ref<HTMLImageElement>;\n };\n\nconst FluidImage = React.forwardRef<HTMLImageElement, FluidImageProps>(\n (\n {\n crop,\n decoding,\n imageWidths,\n loader = shopifyLoader,\n loading,\n normalizedProps,\n passthroughProps,\n placeholderWidth,\n sizes,\n data,\n },\n ref,\n ) => {\n const fluid = React.useMemo(() => {\n const sizesArray =\n imageWidths === undefined\n ? undefined\n : generateSizes(imageWidths, normalizedProps.aspectRatio, crop, {\n width: data?.width ?? undefined,\n height: data?.height ?? undefined,\n });\n\n const placeholderHeight =\n normalizedProps.aspectRatio && placeholderWidth\n ? placeholderWidth *\n (parseAspectRatio(normalizedProps.aspectRatio) ?? 1)\n : undefined;\n\n const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);\n\n const src = loader({\n src: normalizedProps.src,\n width: placeholderWidth,\n height: placeholderHeight,\n crop,\n });\n\n return {\n placeholderHeight,\n srcSet,\n src,\n };\n }, [crop, data, imageWidths, loader, normalizedProps, placeholderWidth]);\n\n return (\n <img\n ref={ref}\n alt={normalizedProps.alt}\n decoding={decoding}\n height={fluid.placeholderHeight}\n loading={loading}\n sizes={sizes}\n src={fluid.src}\n srcSet={fluid.srcSet}\n width={placeholderWidth}\n {...passthroughProps}\n style={{\n width: normalizedProps.width,\n aspectRatio: normalizedProps.aspectRatio,\n ...passthroughProps.style,\n }}\n />\n );\n },\n);\n\n/**\n * The shopifyLoader function is a simple utility function that takes a src, width,\n * height, and crop and returns a string that can be used as the src for an image.\n * It can be used with the Hydrogen Image component or with the next/image component.\n * (or any others that accept equivalent configuration)\n * @param src - The source URL of the image, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg`\n * @param width - The width of the image, e.g. `100`\n * @param height - The height of the image, e.g. `100`\n * @param crop - The crop of the image, e.g. `center`\n * @returns A Shopify image URL with the correct query parameters, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=100&height=100&crop=center`\n *\n * @example\n * ```\n * shopifyLoader({\n * src: 'https://cdn.shopify.com/static/sample-images/garnished.jpeg',\n * width: 100,\n * height: 100,\n * crop: 'center',\n * })\n * ```\n */\nconst PLACEHOLDER_DOMAIN = 'https://placeholder.shopify.com';\nexport function shopifyLoader({src, width, height, crop}: LoaderParams) {\n if (!src) {\n return '';\n }\n\n const url = new URL(src, PLACEHOLDER_DOMAIN);\n\n if (width) {\n url.searchParams.append('width', Math.round(width).toString());\n }\n\n if (height) {\n url.searchParams.append('height', Math.round(height).toString());\n }\n\n if (crop) {\n url.searchParams.append('crop', crop);\n }\n return url.href.replace(PLACEHOLDER_DOMAIN, '');\n}\n\n/**\n * Checks whether the width and height share the same unit type\n * @param width - The width of the image, e.g. 100% | 10px\n * @param height - The height of the image, e.g. auto | 100px\n * @returns Whether the width and height share the same unit type (boolean)\n */\nfunction unitsMatch(\n width: string | number = '100%',\n height: string | number = 'auto',\n): boolean {\n return (\n getUnitValueParts(width.toString()).unit ===\n getUnitValueParts(height.toString()).unit\n );\n}\n\n/**\n * Given a CSS size, returns the unit and number parts of the value\n * @param value - The CSS size, e.g. 100px\n * @returns The unit and number parts of the value, e.g. \\{unit: 'px', number: 100\\}\n */\nfunction getUnitValueParts(value: string): {unit: string; number: number} {\n const unit = value.replace(/[0-9.]/g, '');\n const number = parseFloat(value.replace(unit, ''));\n\n return {\n unit: unit === '' ? (number === undefined ? 'auto' : 'px') : unit,\n number,\n };\n}\n\n/**\n * Given a value, returns the width of the image as an integer in pixels\n * @param value - The width of the image, e.g. 16px | 1rem | 1em | 16\n * @returns The width of the image in pixels, e.g. 16, or undefined if the value is not a fixed unit\n */\nfunction getNormalizedFixedUnit(value?: string | number): number | undefined {\n if (value === undefined) {\n return;\n }\n\n const {unit, number} = getUnitValueParts(value.toString());\n\n switch (unit) {\n case 'em':\n return number * 16;\n case 'rem':\n return number * 16;\n case 'px':\n return number;\n case '':\n return number;\n default:\n return;\n }\n}\n\n/**\n * This function checks whether a width is fixed or not.\n * @param width - The width of the image, e.g. 100 | '100px' | '100em' | '100rem'\n * @returns Whether the width is fixed or not\n */\nfunction isFixedWidth(width: string | number): boolean {\n const fixedEndings = /\\d(px|em|rem)$/;\n return typeof width === 'number' || fixedEndings.test(width);\n}\n\n/**\n * This function generates a srcSet for Shopify images.\n * @param src - The source URL of the image, e.g. https://cdn.shopify.com/static/sample-images/garnished.jpeg\n * @param sizesArray - An array of objects containing the `width`, `height`, and `crop` of the image, e.g. [\\{width: 200, height: 200, crop: 'center'\\}, \\{width: 400, height: 400, crop: 'center'\\}]\n * @param loader - A function that takes a Shopify image URL and returns a Shopify image URL with the correct query parameters\n * @returns A srcSet for Shopify images, e.g. 'https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=200&height=200&crop=center 200w, https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=400&height=400&crop=center 400w'\n */\nexport function generateSrcSet(\n src?: string,\n sizesArray?: Array<{width?: number; height?: number; crop?: Crop}>,\n loader: Loader = shopifyLoader,\n): string {\n if (!src) {\n return '';\n }\n\n if (sizesArray?.length === 0 || !sizesArray) {\n return src;\n }\n\n return sizesArray\n .map(\n (size, i) =>\n `${loader({\n src,\n width: size.width,\n height: size.height,\n crop: size.crop,\n })} ${sizesArray.length === 3 ? `${i + 1}x` : `${size.width ?? 0}w`}`,\n )\n .join(`, `);\n}\n\n/**\n * This function generates an array of sizes for Shopify images, for both fixed and responsive images.\n * @param width - The CSS width of the image\n * @param intervals - The number of intervals to generate\n * @param startingWidth - The starting width of the image\n * @param incrementSize - The size of each interval\n * @returns An array of widths\n */\nexport function generateImageWidths(\n width: string | number = '100%',\n intervals: number,\n startingWidth: number,\n incrementSize: number,\n): number[] {\n const responsive = Array.from(\n {length: intervals},\n (_, i) => i * incrementSize + startingWidth,\n );\n\n const fixed = Array.from(\n {length: 3},\n (_, i) => (i + 1) * (getNormalizedFixedUnit(width) ?? 0),\n );\n\n return isFixedWidth(width) ? fixed : responsive;\n}\n\n/**\n * Simple utility function to convert an aspect ratio CSS string to a decimal, currently only supports values like `1/1`, not `0.5`, or `auto`\n * @param aspectRatio - The aspect ratio of the image, e.g. `1/1`\n * @returns The aspect ratio as a number, e.g. `0.5`\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio}\n */\nexport function parseAspectRatio(aspectRatio?: string): number | undefined {\n if (!aspectRatio) return;\n const [width, height] = aspectRatio.split('/');\n return 1 / (Number(width) / Number(height));\n}\n\n// Generate data needed for Imagery loader\nexport function generateSizes(\n imageWidths?: number[],\n aspectRatio?: string,\n crop: Crop = 'center',\n sourceDimensions?: {width?: number; height?: number},\n):\n | {\n width: number;\n height: number | undefined;\n crop: Crop;\n }[]\n | undefined {\n if (!imageWidths) return;\n return imageWidths\n .map((width: number) => {\n return {\n width,\n height: aspectRatio\n ? width * (parseAspectRatio(aspectRatio) ?? 1)\n : undefined,\n crop,\n };\n })\n .filter(({width, height}) => {\n if (sourceDimensions?.width && width > sourceDimensions.width) {\n return false;\n }\n\n if (\n sourceDimensions?.height &&\n height &&\n height > sourceDimensions.height\n ) {\n return false;\n }\n\n return true;\n });\n /*\n Given:\n ([100, 200], 1/1, 'center')\n Returns:\n [{width: 100, height: 100, crop: 'center'},\n {width: 200, height: 200, crop: 'center'}]\n */\n}\n"],"mappings":";;;;;;AA6GA,IAAa,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C9B,IAAa,QAAQ,MAAM,YAEvB,EACE,KACA,aACA,OAAO,UACP,MACA,WAAW,SACX,SAAS,QACT,SAAS,eACT,UAAU,QACV,OACA,KACA,gBAAgB;CACd,WAAW;CACX,eAAe;CACf,eAAe;CACf,kBAAkB;CACnB,EACD,QAAQ,QACR,GAAG,oBAEL,QACG;CAIH,MAAM,iBAAiB,MAAM,cAAc;EAEzC,MAAM,YACJ,MAAM,SAAS,MAAM,SAAS,MAAM,QAAQ,KAAA;EAE9C,MAAM,aACJ,MAAM,SAAS,MAAM,SAAS,MAAM,SAAS,KAAA;AAE/C,SAAO;GACL,OAAO;GACP,QAAQ;GACR,YAAY,QAAQ,WAAW,WAAW,WAAW,CAAC;GACvD;IACA,CAAC,KAAK,CAAC;CAMV,MA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C1C,KAAA;GACJ;GACD;GACD,CACD,QAAQ,EAAC,OAAO,aAAY;AAC3B,MAAI,kBAAkB,SAAS,QAAQ,iBAAiB,MACtD,QAAO;AAGT,MACE,kBAAkB,UAClB,UACA,SAAS,iBAAiB,OAE1B,QAAO;AAGT,SAAO;GACP"}
@@ -1,67 +1,48 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { ExternalVideo } from "./ExternalVideo.mjs";
2
2
  import { Image } from "./Image.mjs";
3
3
  import { Video } from "./Video.mjs";
4
- import { ExternalVideo } from "./ExternalVideo.mjs";
5
4
  import { ModelViewer } from "./ModelViewer.mjs";
6
- function MediaFile({
7
- data,
8
- mediaOptions,
9
- ...passthroughProps
10
- }) {
11
- switch (data.__typename) {
12
- case "MediaImage": {
13
- if (!data.image) {
14
- const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;
15
- {
16
- console.warn(noDataImage);
17
- return null;
18
- }
19
- }
20
- return /* @__PURE__ */ jsx(
21
- Image,
22
- {
23
- ...passthroughProps,
24
- ...mediaOptions == null ? void 0 : mediaOptions.image,
25
- data: data.image
26
- }
27
- );
28
- }
29
- case "Video": {
30
- return /* @__PURE__ */ jsx(Video, { ...passthroughProps, ...mediaOptions == null ? void 0 : mediaOptions.video, data });
31
- }
32
- case "ExternalVideo": {
33
- return /* @__PURE__ */ jsx(
34
- ExternalVideo,
35
- {
36
- ...passthroughProps,
37
- ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
38
- data
39
- }
40
- );
41
- }
42
- case "Model3d": {
43
- return (
44
- // @ts-expect-error There are issues with the inferred HTML attribute types here for ModelViewer (and contentEditable), but I think that's a little bit beyond me at the moment
45
- /* @__PURE__ */ jsx(
46
- ModelViewer,
47
- {
48
- ...passthroughProps,
49
- ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
50
- data
51
- }
52
- )
53
- );
54
- }
55
- default: {
56
- const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media.`;
57
- {
58
- console.error(`${typenameMissingMessage} Rendering 'null' by default`);
59
- return null;
60
- }
61
- }
62
- }
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/MediaFile.tsx
7
+ /**
8
+ * The `MediaFile` component renders the media for the Storefront API's
9
+ * [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a
10
+ * `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `__typename` of the `data` prop.
11
+ * @publicDocs
12
+ */
13
+ function MediaFile({ data, mediaOptions, ...passthroughProps }) {
14
+ switch (data.__typename) {
15
+ case "MediaImage":
16
+ if (!data.image) {
17
+ console.warn(`<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`);
18
+ return null;
19
+ }
20
+ return /* @__PURE__ */ jsx(Image, {
21
+ ...passthroughProps,
22
+ ...mediaOptions?.image,
23
+ data: data.image
24
+ });
25
+ case "Video": return /* @__PURE__ */ jsx(Video, {
26
+ ...passthroughProps,
27
+ ...mediaOptions?.video,
28
+ data
29
+ });
30
+ case "ExternalVideo": return /* @__PURE__ */ jsx(ExternalVideo, {
31
+ ...passthroughProps,
32
+ ...mediaOptions?.externalVideo,
33
+ data
34
+ });
35
+ case "Model3d": return /* @__PURE__ */ jsx(ModelViewer, {
36
+ ...passthroughProps,
37
+ ...mediaOptions?.modelViewer,
38
+ data
39
+ });
40
+ default:
41
+ console.error(`<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media. Rendering 'null' by default`);
42
+ return null;
43
+ }
63
44
  }
64
- export {
65
- MediaFile
66
- };
67
- //# sourceMappingURL=MediaFile.mjs.map
45
+ //#endregion
46
+ export { MediaFile };
47
+
48
+ //# sourceMappingURL=MediaFile.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MediaFile.mjs","sources":["../../src/MediaFile.tsx"],"sourcesContent":["import {Image, type HydrogenImageProps} from './Image.js';\nimport {Video} from './Video.js';\nimport {ExternalVideo} from './ExternalVideo.js';\nimport {ModelViewer} from './ModelViewer.js';\nimport type {MediaEdge as MediaEdgeType} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ntype BaseProps = React.HTMLAttributes<\n HTMLImageElement | HTMLVideoElement | HTMLIFrameElement | ModelViewerElement\n>;\n/**\n * MediaFile renders an `Image`, `Video`, `ExternalVideo`, or `ModelViewer` component. Use the `mediaOptions` prop to customize the props sent to each of these components.\n * @publicDocs */\nexport interface MediaFileProps extends BaseProps {\n /** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */\n data: PartialDeep<MediaEdgeType['node'], {recurseIntoArrays: true}>;\n /** The options for the `Image`, `Video`, `ExternalVideo`, or `ModelViewer` components. */\n mediaOptions?: MediaOptions;\n}\n\ntype MediaOptions = {\n /** Props that will only apply when an `<Image />` is rendered */\n image?: Omit<HydrogenImageProps, 'data'>;\n /** Props that will only apply when a `<Video />` is rendered */\n video?: Omit<React.ComponentProps<typeof Video>, 'data'>;\n /** Props that will only apply when an `<ExternalVideo />` is rendered */\n externalVideo?: Omit<\n React.ComponentProps<typeof ExternalVideo>['options'],\n 'data'\n >;\n /** Props that will only apply when a `<ModelViewer />` is rendered */\n modelViewer?: Omit<typeof ModelViewer, 'data'>;\n};\n\n/**\n * The `MediaFile` component renders the media for the Storefront API's\n * [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a\n * `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `__typename` of the `data` prop.\n * @publicDocs\n */\nexport function MediaFile({\n data,\n mediaOptions,\n ...passthroughProps\n}: MediaFileProps): JSX.Element | null {\n switch (data.__typename) {\n case 'MediaImage': {\n if (!data.image) {\n const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noDataImage);\n } else {\n console.warn(noDataImage);\n return null;\n }\n }\n\n return (\n <Image\n {...passthroughProps}\n {...mediaOptions?.image}\n data={data.image}\n />\n );\n }\n case 'Video': {\n return (\n <Video {...passthroughProps} {...mediaOptions?.video} data={data} />\n );\n }\n case 'ExternalVideo': {\n return (\n <ExternalVideo\n {...passthroughProps}\n {...mediaOptions?.externalVideo}\n data={data}\n />\n );\n }\n case 'Model3d': {\n return (\n // @ts-expect-error There are issues with the inferred HTML attribute types here for ModelViewer (and contentEditable), but I think that's a little bit beyond me at the moment\n <ModelViewer\n {...passthroughProps}\n {...mediaOptions?.modelViewer}\n data={data}\n />\n );\n }\n default: {\n const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typenameMissingMessage);\n } else {\n console.error(`${typenameMissingMessage} Rendering 'null' by default`);\n return null;\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAyCO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuC;AACrC,UAAQ,KAAK,YAAA;AAAA,IACX,KAAK,cAAc;AACjB,UAAI,CAAC,KAAK,OAAO;AACf,cAAM,cAAc;AAGb;AACL,kBAAQ,KAAK,WAAW;AACxB,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,aACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACH,GAAG,6CAAc;AAAA,UAClB,MAAM,KAAK;AAAA,QAAA;AAAA,MAAA;AAAA,IAGjB;AAAA,IACA,KAAK,SAAS;AACZ,iCACG,OAAA,EAAO,GAAG,kBAAmB,GAAG,6CAAc,OAAO,MAAY;AAAA,IAEtE;AAAA,IACA,KAAK,iBAAiB;AACpB,aACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACH,GAAG,6CAAc;AAAA,UAClB;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAAA,IACA,KAAK,WAAW;AACd;AAAA;AAAA,QAEE;AAAA,UAAC;AAAA,UAAA;AAAA,YACE,GAAG;AAAA,YACH,GAAG,6CAAc;AAAA,YAClB;AAAA,UAAA;AAAA,QAAA;AAAA;AAAA,IAGN;AAAA,IACA,SAAS;AACP,YAAM,yBAAyB;AAGxB;AACL,gBAAQ,MAAM,GAAG,sBAAsB,+BAA+B;AACtE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"MediaFile.mjs","names":[],"sources":["../../src/MediaFile.tsx"],"sourcesContent":["import {Image, type HydrogenImageProps} from './Image.js';\nimport {Video} from './Video.js';\nimport {ExternalVideo} from './ExternalVideo.js';\nimport {ModelViewer} from './ModelViewer.js';\nimport type {MediaEdge as MediaEdgeType} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ntype BaseProps = React.HTMLAttributes<\n HTMLImageElement | HTMLVideoElement | HTMLIFrameElement | ModelViewerElement\n>;\n/**\n * MediaFile renders an `Image`, `Video`, `ExternalVideo`, or `ModelViewer` component. Use the `mediaOptions` prop to customize the props sent to each of these components.\n * @publicDocs */\nexport interface MediaFileProps extends BaseProps {\n /** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */\n data: PartialDeep<MediaEdgeType['node'], {recurseIntoArrays: true}>;\n /** The options for the `Image`, `Video`, `ExternalVideo`, or `ModelViewer` components. */\n mediaOptions?: MediaOptions;\n}\n\ntype MediaOptions = {\n /** Props that will only apply when an `<Image />` is rendered */\n image?: Omit<HydrogenImageProps, 'data'>;\n /** Props that will only apply when a `<Video />` is rendered */\n video?: Omit<React.ComponentProps<typeof Video>, 'data'>;\n /** Props that will only apply when an `<ExternalVideo />` is rendered */\n externalVideo?: Omit<\n React.ComponentProps<typeof ExternalVideo>['options'],\n 'data'\n >;\n /** Props that will only apply when a `<ModelViewer />` is rendered */\n modelViewer?: Omit<typeof ModelViewer, 'data'>;\n};\n\n/**\n * The `MediaFile` component renders the media for the Storefront API's\n * [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a\n * `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `__typename` of the `data` prop.\n * @publicDocs\n */\nexport function MediaFile({\n data,\n mediaOptions,\n ...passthroughProps\n}: MediaFileProps): JSX.Element | null {\n switch (data.__typename) {\n case 'MediaImage': {\n if (!data.image) {\n const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noDataImage);\n } else {\n console.warn(noDataImage);\n return null;\n }\n }\n\n return (\n <Image\n {...passthroughProps}\n {...mediaOptions?.image}\n data={data.image}\n />\n );\n }\n case 'Video': {\n return (\n <Video {...passthroughProps} {...mediaOptions?.video} data={data} />\n );\n }\n case 'ExternalVideo': {\n return (\n <ExternalVideo\n {...passthroughProps}\n {...mediaOptions?.externalVideo}\n data={data}\n />\n );\n }\n case 'Model3d': {\n return (\n // @ts-expect-error There are issues with the inferred HTML attribute types here for ModelViewer (and contentEditable), but I think that's a little bit beyond me at the moment\n <ModelViewer\n {...passthroughProps}\n {...mediaOptions?.modelViewer}\n data={data}\n />\n );\n }\n default: {\n const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typenameMissingMessage);\n } else {\n console.error(`${typenameMissingMessage} Rendering 'null' by default`);\n return null;\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyCA,SAAgB,UAAU,EACxB,MACA,cACA,GAAG,oBACkC;AACrC,SAAQ,KAAK,YAAb;EACE,KAAK;AACH,OAAI,CAAC,KAAK,OAAO;AAKb,YAAQ,KAJU,yGAIO;AACzB,WAAO;;AAIX,UACE,oBAAC,OAAD;IACE,GAAI;IACJ,GAAI,cAAc;IAClB,MAAM,KAAK;IACX,CAAA;EAGN,KAAK,QACH,QACE,oBAAC,OAAD;GAAO,GAAI;GAAkB,GAAI,cAAc;GAAa;GAAQ,CAAA;EAGxE,KAAK,gBACH,QACE,oBAAC,eAAD;GACE,GAAI;GACJ,GAAI,cAAc;GACZ;GACN,CAAA;EAGN,KAAK,UACH,QAEE,oBAAC,aAAD;GACE,GAAI;GACJ,GAAI,cAAc;GACZ;GACN,CAAA;EAGN;AAKI,WAAQ,MAAM,kLAAyD;AACvE,UAAO"}
@@ -1,138 +1,120 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useState, useCallback, useEffect } from "react";
3
1
  import { useLoadScript } from "./load-script.mjs";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/ModelViewer.tsx
5
+ /**
6
+ * The `ModelViewer` component renders a 3D model (with the `model-viewer` custom element) for
7
+ * the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).
8
+ *
9
+ * The `model-viewer` custom element is lazily downloaded through a dynamically-injected `<script type="module">` tag when the `<ModelViewer />` component is rendered
10
+ *
11
+ * ModelViewer is using version `1.21.1` of the `@google/model-viewer` library.
12
+ * @publicDocs
13
+ */
4
14
  function ModelViewer(props) {
5
- var _a, _b, _c;
6
- const [modelViewer, setModelViewer] = useState(
7
- void 0
8
- );
9
- const callbackRef = useCallback((node) => {
10
- setModelViewer(node);
11
- }, []);
12
- const { data, children, className, ...passthroughProps } = props;
13
- const modelViewerLoadedStatus = useLoadScript(
14
- "https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",
15
- {
16
- module: true
17
- }
18
- );
19
- useEffect(() => {
20
- const hydrogenEventListener = {
21
- error: passthroughProps.onError,
22
- load: passthroughProps.onLoad,
23
- preload: passthroughProps.onPreload,
24
- "model-visibility": passthroughProps.onModelVisibility,
25
- progress: passthroughProps.onProgress,
26
- "ar-status": passthroughProps.onArStatus,
27
- "ar-tracking": passthroughProps.onArTracking,
28
- "quick-look-button-tapped": passthroughProps.onQuickLookButtonTapped,
29
- "camera-change": passthroughProps.onCameraChange,
30
- "environment-change": passthroughProps.onEnvironmentChange,
31
- play: passthroughProps.onPlay,
32
- pause: passthroughProps.onPause,
33
- "scene-graph-ready": passthroughProps.onSceneGraphReady
34
- };
35
- if (!modelViewer) {
36
- return;
37
- }
38
- Object.entries(hydrogenEventListener).forEach(
39
- ([eventName, callbackFunc]) => {
40
- if (callbackFunc) {
41
- modelViewer.addEventListener(eventName, callbackFunc);
42
- }
43
- }
44
- );
45
- return () => {
46
- if (modelViewer == null) {
47
- return;
48
- }
49
- Object.entries(hydrogenEventListener).forEach(
50
- ([eventName, callbackFunc]) => {
51
- if (callbackFunc) {
52
- modelViewer.removeEventListener(eventName, callbackFunc);
53
- }
54
- }
55
- );
56
- };
57
- }, [
58
- modelViewer,
59
- passthroughProps.onArStatus,
60
- passthroughProps.onArTracking,
61
- passthroughProps.onCameraChange,
62
- passthroughProps.onEnvironmentChange,
63
- passthroughProps.onError,
64
- passthroughProps.onLoad,
65
- passthroughProps.onModelVisibility,
66
- passthroughProps.onPause,
67
- passthroughProps.onPlay,
68
- passthroughProps.onPreload,
69
- passthroughProps.onProgress,
70
- passthroughProps.onQuickLookButtonTapped,
71
- passthroughProps.onSceneGraphReady
72
- ]);
73
- if (modelViewerLoadedStatus !== "done") {
74
- return null;
75
- }
76
- if (!((_b = (_a = data.sources) == null ? void 0 : _a[0]) == null ? void 0 : _b.url)) {
77
- const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;
78
- {
79
- console.error(sourcesUrlError);
80
- return null;
81
- }
82
- }
83
- return /* @__PURE__ */ jsx(
84
- "model-viewer",
85
- {
86
- ref: callbackRef,
87
- ...passthroughProps,
88
- class: className,
89
- id: passthroughProps.id ?? data.id,
90
- src: data.sources[0].url,
91
- alt: data.alt ?? null,
92
- "camera-controls": passthroughProps.cameraControls ?? true,
93
- poster: (passthroughProps.poster || ((_c = data.previewImage) == null ? void 0 : _c.url)) ?? null,
94
- autoplay: passthroughProps.autoplay ?? true,
95
- loading: passthroughProps.loading,
96
- reveal: passthroughProps.reveal,
97
- ar: passthroughProps.ar,
98
- "ar-modes": passthroughProps.arModes,
99
- "ar-scale": passthroughProps.arScale,
100
- "ar-placement": passthroughProps.arPlacement,
101
- "ios-src": passthroughProps.iosSrc,
102
- "touch-action": passthroughProps.touchAction,
103
- "disable-zoom": passthroughProps.disableZoom,
104
- "orbit-sensitivity": passthroughProps.orbitSensitivity,
105
- "auto-rotate": passthroughProps.autoRotate,
106
- "auto-rotate-delay": passthroughProps.autoRotateDelay,
107
- "rotation-per-second": passthroughProps.rotationPerSecond,
108
- "interaction-policy": passthroughProps.interactionPolicy,
109
- "interaction-prompt": passthroughProps.interactionPrompt,
110
- "interaction-prompt-style": passthroughProps.interactionPromptStyle,
111
- "interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
112
- "camera-orbit": passthroughProps.cameraOrbit,
113
- "camera-target": passthroughProps.cameraTarget,
114
- "field-of-view": passthroughProps.fieldOfView,
115
- "max-camera-orbit": passthroughProps.maxCameraOrbit,
116
- "min-camera-orbit": passthroughProps.minCameraOrbit,
117
- "max-field-of-view": passthroughProps.maxFieldOfView,
118
- "min-field-of-view": passthroughProps.minFieldOfView,
119
- bounds: passthroughProps.bounds,
120
- "interpolation-decay": passthroughProps.interpolationDecay ?? 100,
121
- "skybox-image": passthroughProps.skyboxImage,
122
- "environment-image": passthroughProps.environmentImage,
123
- exposure: passthroughProps.exposure,
124
- "shadow-intensity": passthroughProps.shadowIntensity ?? 0,
125
- "shadow-softness": passthroughProps.shadowSoftness ?? 0,
126
- "animation-name": passthroughProps.animationName,
127
- "animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
128
- "variant-name": passthroughProps.variantName,
129
- orientation: passthroughProps.orientation,
130
- scale: passthroughProps.scale,
131
- children
132
- }
133
- );
15
+ const [modelViewer, setModelViewer] = useState(void 0);
16
+ const callbackRef = useCallback((node) => {
17
+ setModelViewer(node);
18
+ }, []);
19
+ const { data, children, className, ...passthroughProps } = props;
20
+ const modelViewerLoadedStatus = useLoadScript("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js", { module: true });
21
+ useEffect(() => {
22
+ const hydrogenEventListener = {
23
+ error: passthroughProps.onError,
24
+ load: passthroughProps.onLoad,
25
+ preload: passthroughProps.onPreload,
26
+ "model-visibility": passthroughProps.onModelVisibility,
27
+ progress: passthroughProps.onProgress,
28
+ "ar-status": passthroughProps.onArStatus,
29
+ "ar-tracking": passthroughProps.onArTracking,
30
+ "quick-look-button-tapped": passthroughProps.onQuickLookButtonTapped,
31
+ "camera-change": passthroughProps.onCameraChange,
32
+ "environment-change": passthroughProps.onEnvironmentChange,
33
+ play: passthroughProps.onPlay,
34
+ pause: passthroughProps.onPause,
35
+ "scene-graph-ready": passthroughProps.onSceneGraphReady
36
+ };
37
+ if (!modelViewer) return;
38
+ Object.entries(hydrogenEventListener).forEach(([eventName, callbackFunc]) => {
39
+ if (callbackFunc) modelViewer.addEventListener(eventName, callbackFunc);
40
+ });
41
+ return () => {
42
+ if (modelViewer == null) return;
43
+ Object.entries(hydrogenEventListener).forEach(([eventName, callbackFunc]) => {
44
+ if (callbackFunc) modelViewer.removeEventListener(eventName, callbackFunc);
45
+ });
46
+ };
47
+ }, [
48
+ modelViewer,
49
+ passthroughProps.onArStatus,
50
+ passthroughProps.onArTracking,
51
+ passthroughProps.onCameraChange,
52
+ passthroughProps.onEnvironmentChange,
53
+ passthroughProps.onError,
54
+ passthroughProps.onLoad,
55
+ passthroughProps.onModelVisibility,
56
+ passthroughProps.onPause,
57
+ passthroughProps.onPlay,
58
+ passthroughProps.onPreload,
59
+ passthroughProps.onProgress,
60
+ passthroughProps.onQuickLookButtonTapped,
61
+ passthroughProps.onSceneGraphReady
62
+ ]);
63
+ if (modelViewerLoadedStatus !== "done") return null;
64
+ if (!data.sources?.[0]?.url) {
65
+ console.error(`<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`);
66
+ return null;
67
+ }
68
+ return /* @__PURE__ */ jsx("model-viewer", {
69
+ ref: callbackRef,
70
+ ...passthroughProps,
71
+ class: className,
72
+ id: passthroughProps.id ?? data.id,
73
+ src: data.sources[0].url,
74
+ alt: data.alt ?? null,
75
+ "camera-controls": passthroughProps.cameraControls ?? true,
76
+ poster: (passthroughProps.poster || data.previewImage?.url) ?? null,
77
+ autoplay: passthroughProps.autoplay ?? true,
78
+ loading: passthroughProps.loading,
79
+ reveal: passthroughProps.reveal,
80
+ ar: passthroughProps.ar,
81
+ "ar-modes": passthroughProps.arModes,
82
+ "ar-scale": passthroughProps.arScale,
83
+ "ar-placement": passthroughProps.arPlacement,
84
+ "ios-src": passthroughProps.iosSrc,
85
+ "touch-action": passthroughProps.touchAction,
86
+ "disable-zoom": passthroughProps.disableZoom,
87
+ "orbit-sensitivity": passthroughProps.orbitSensitivity,
88
+ "auto-rotate": passthroughProps.autoRotate,
89
+ "auto-rotate-delay": passthroughProps.autoRotateDelay,
90
+ "rotation-per-second": passthroughProps.rotationPerSecond,
91
+ "interaction-policy": passthroughProps.interactionPolicy,
92
+ "interaction-prompt": passthroughProps.interactionPrompt,
93
+ "interaction-prompt-style": passthroughProps.interactionPromptStyle,
94
+ "interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
95
+ "camera-orbit": passthroughProps.cameraOrbit,
96
+ "camera-target": passthroughProps.cameraTarget,
97
+ "field-of-view": passthroughProps.fieldOfView,
98
+ "max-camera-orbit": passthroughProps.maxCameraOrbit,
99
+ "min-camera-orbit": passthroughProps.minCameraOrbit,
100
+ "max-field-of-view": passthroughProps.maxFieldOfView,
101
+ "min-field-of-view": passthroughProps.minFieldOfView,
102
+ bounds: passthroughProps.bounds,
103
+ "interpolation-decay": passthroughProps.interpolationDecay ?? 100,
104
+ "skybox-image": passthroughProps.skyboxImage,
105
+ "environment-image": passthroughProps.environmentImage,
106
+ exposure: passthroughProps.exposure,
107
+ "shadow-intensity": passthroughProps.shadowIntensity ?? 0,
108
+ "shadow-softness": passthroughProps.shadowSoftness ?? 0,
109
+ "animation-name": passthroughProps.animationName,
110
+ "animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
111
+ "variant-name": passthroughProps.variantName,
112
+ orientation: passthroughProps.orientation,
113
+ scale: passthroughProps.scale,
114
+ children
115
+ });
134
116
  }
135
- export {
136
- ModelViewer
137
- };
138
- //# sourceMappingURL=ModelViewer.mjs.map
117
+ //#endregion
118
+ export { ModelViewer };
119
+
120
+ //# sourceMappingURL=ModelViewer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModelViewer.mjs","sources":["../../src/ModelViewer.tsx"],"sourcesContent":["import {useState, useEffect, useCallback} from 'react';\nimport {useLoadScript} from './load-script.js';\nimport type {Model3d} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': PartialDeep<\n ModelViewerElement,\n {recurseIntoArrays: true}\n >;\n }\n }\n}\n\ntype ModelViewerProps = Omit<\n PartialDeep<JSX.IntrinsicElements['model-viewer'], {recurseIntoArrays: true}>,\n 'src'\n> &\n ModelViewerBaseProps;\n\ntype ModelViewerBaseProps = {\n /** An object with fields that correspond to the Storefront API's [Model3D object](https://shopify.dev/api/storefront/2026-04/objects/model3d). */\n data: PartialDeep<Model3d, {recurseIntoArrays: true}>;\n /** The callback to invoke when the 'error' event is triggered. Refer to [error in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-error). */\n onError?: (event: Event) => void;\n /** The callback to invoke when the `load` event is triggered. Refer to [load in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-load). */\n onLoad?: (event: Event) => void;\n /** The callback to invoke when the 'preload' event is triggered. Refer to [preload in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-preload). */\n onPreload?: (event: Event) => void;\n /** The callback to invoke when the 'model-visibility' event is triggered. Refer to [model-visibility in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-modelVisibility). */\n onModelVisibility?: (event: Event) => void;\n /** The callback to invoke when the 'progress' event is triggered. Refer to [progress in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-progress). */\n onProgress?: (event: Event) => void;\n /** The callback to invoke when the 'ar-status' event is triggered. Refer to [ar-status in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arStatus). */\n onArStatus?: (event: Event) => void;\n /** The callback to invoke when the 'ar-tracking' event is triggered. Refer to [ar-tracking in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arTracking). */\n onArTracking?: (event: Event) => void;\n /** The callback to invoke when the 'quick-look-button-tapped' event is triggered. Refer to [quick-look-button-tapped in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-quickLookButtonTapped). */\n onQuickLookButtonTapped?: (event: Event) => void;\n /** The callback to invoke when the 'camera-change' event is triggered. Refer to [camera-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-events-cameraChange). */\n onCameraChange?: (event: Event) => void;\n /** The callback to invoke when the 'environment-change' event is triggered. Refer to [environment-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-lightingandenv-events-environmentChange). */\n onEnvironmentChange?: (event: Event) => void;\n /** The callback to invoke when the 'play' event is triggered. Refer to [play in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-play). */\n onPlay?: (event: Event) => void;\n /** The callback to invoke when the 'pause' event is triggered. Refer to [pause in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-pause). */\n onPause?: (event: Event) => void;\n /** The callback to invoke when the 'scene-graph-ready' event is triggered. Refer to [scene-graph-ready in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-scenegraph-events-sceneGraphReady). */\n onSceneGraphReady?: (event: Event) => void;\n};\n\n/**\n * The `ModelViewer` component renders a 3D model (with the `model-viewer` custom element) for\n * the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).\n *\n * The `model-viewer` custom element is lazily downloaded through a dynamically-injected `<script type=\"module\">` tag when the `<ModelViewer />` component is rendered\n *\n * ModelViewer is using version `1.21.1` of the `@google/model-viewer` library.\n * @publicDocs\n */\nexport function ModelViewer(props: ModelViewerProps): JSX.Element | null {\n const [modelViewer, setModelViewer] = useState<undefined | HTMLElement>(\n undefined,\n );\n const callbackRef = useCallback((node: HTMLElement) => {\n setModelViewer(node);\n }, []);\n const {data, children, className, ...passthroughProps} = props;\n\n const modelViewerLoadedStatus = useLoadScript(\n 'https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js',\n {\n module: true,\n },\n );\n\n useEffect(() => {\n const hydrogenEventListener = {\n error: passthroughProps.onError,\n load: passthroughProps.onLoad,\n preload: passthroughProps.onPreload,\n 'model-visibility': passthroughProps.onModelVisibility,\n progress: passthroughProps.onProgress,\n 'ar-status': passthroughProps.onArStatus,\n 'ar-tracking': passthroughProps.onArTracking,\n 'quick-look-button-tapped': passthroughProps.onQuickLookButtonTapped,\n 'camera-change': passthroughProps.onCameraChange,\n 'environment-change': passthroughProps.onEnvironmentChange,\n play: passthroughProps.onPlay,\n pause: passthroughProps.onPause,\n 'scene-graph-ready': passthroughProps.onSceneGraphReady,\n };\n\n if (!modelViewer) {\n return;\n }\n Object.entries(hydrogenEventListener).forEach(\n ([eventName, callbackFunc]) => {\n if (callbackFunc) {\n modelViewer.addEventListener(eventName, callbackFunc);\n }\n },\n );\n\n return (): void => {\n if (modelViewer == null) {\n return;\n }\n Object.entries(hydrogenEventListener).forEach(\n ([eventName, callbackFunc]) => {\n if (callbackFunc) {\n modelViewer.removeEventListener(eventName, callbackFunc);\n }\n },\n );\n };\n }, [\n modelViewer,\n passthroughProps.onArStatus,\n passthroughProps.onArTracking,\n passthroughProps.onCameraChange,\n passthroughProps.onEnvironmentChange,\n passthroughProps.onError,\n passthroughProps.onLoad,\n passthroughProps.onModelVisibility,\n passthroughProps.onPause,\n passthroughProps.onPlay,\n passthroughProps.onPreload,\n passthroughProps.onProgress,\n passthroughProps.onQuickLookButtonTapped,\n passthroughProps.onSceneGraphReady,\n ]);\n\n if (modelViewerLoadedStatus !== 'done') {\n // TODO: What do we want to display while the model-viewer library loads?\n return null;\n }\n\n if (!data.sources?.[0]?.url) {\n const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(sourcesUrlError);\n } else {\n console.error(sourcesUrlError);\n return null;\n }\n }\n\n if (__HYDROGEN_DEV__ && !data.alt) {\n console.warn(\n `<ModelViewer/> requires the 'data.alt' prop for accessibility`,\n );\n }\n\n return (\n <model-viewer\n ref={callbackRef}\n {...passthroughProps}\n // @ts-expect-error src should exist\n // @eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n class={className}\n id={passthroughProps.id ?? data.id}\n src={data.sources[0].url}\n alt={data.alt ?? null}\n camera-controls={passthroughProps.cameraControls ?? true}\n poster={(passthroughProps.poster || data.previewImage?.url) ?? null}\n autoplay={passthroughProps.autoplay ?? true}\n loading={passthroughProps.loading}\n reveal={passthroughProps.reveal}\n ar={passthroughProps.ar}\n ar-modes={passthroughProps.arModes}\n ar-scale={passthroughProps.arScale}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ar-placement={passthroughProps.arPlacement}\n ios-src={passthroughProps.iosSrc}\n touch-action={passthroughProps.touchAction}\n disable-zoom={passthroughProps.disableZoom}\n orbit-sensitivity={passthroughProps.orbitSensitivity}\n auto-rotate={passthroughProps.autoRotate}\n auto-rotate-delay={passthroughProps.autoRotateDelay}\n // @ts-expect-error rotationPerSecond should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-attributes-rotationPerSecond\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n rotation-per-second={passthroughProps.rotationPerSecond}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n interaction-policy={(passthroughProps as any).interactionPolicy}\n interaction-prompt={passthroughProps.interactionPrompt}\n interaction-prompt-style={passthroughProps.interactionPromptStyle}\n interaction-prompt-threshold={passthroughProps.interactionPromptThreshold}\n camera-orbit={passthroughProps.cameraOrbit}\n camera-target={passthroughProps.cameraTarget}\n field-of-view={passthroughProps.fieldOfView}\n max-camera-orbit={passthroughProps.maxCameraOrbit}\n min-camera-orbit={passthroughProps.minCameraOrbit}\n max-field-of-view={passthroughProps.maxFieldOfView}\n min-field-of-view={passthroughProps.minFieldOfView}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bounds={(passthroughProps as any).bounds}\n interpolation-decay={passthroughProps.interpolationDecay ?? 100}\n skybox-image={passthroughProps.skyboxImage}\n environment-image={passthroughProps.environmentImage}\n exposure={passthroughProps.exposure}\n shadow-intensity={passthroughProps.shadowIntensity ?? 0}\n shadow-softness={passthroughProps.shadowSoftness ?? 0}\n animation-name={passthroughProps.animationName}\n animation-crossfade-duration={passthroughProps.animationCrossfadeDuration}\n variant-name={passthroughProps.variantName}\n orientation={passthroughProps.orientation}\n scale={passthroughProps.scale}\n >\n {children}\n </model-viewer>\n );\n}\n"],"names":[],"mappings":";;;AAgEO,SAAS,YAAY,OAA6C;;AACvE,QAAM,CAAC,aAAa,cAAc,IAAI;AAAA,IACpC;AAAA,EAAA;AAEF,QAAM,cAAc,YAAY,CAAC,SAAsB;AACrD,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAA,CAAE;AACL,QAAM,EAAC,MAAM,UAAU,WAAW,GAAG,qBAAoB;AAEzD,QA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pC,QAAS,iBAAyB;AAAA,MAClC,uBAAqB,iBAAiB,sBAAsB;AAAA,MAC5D,gBAAc,iBAAiB;AAAA,MAC/B,qBAAmB,iBAAiB;AAAA,MACpC,UAAU,iBAAiB;AAAA,MAC3B,oBAAkB,iBAAiB,mBAAmB;AAAA,MACtD,mBAAiB,iBAAiB,kBAAkB;AAAA,MACpD,kBAAgB,iBAAiB;AAAA,MACjC,gCAA8B,iBAAiB;AAAA,MAC/C,gBAAc,iBAAiB;AAAA,MAC/B,aAAa,iBAAiB;AAAA,MAC9B,OAAO,iBAAiB;AAAA,MAEvB;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"ModelViewer.mjs","names":[],"sources":["../../src/ModelViewer.tsx"],"sourcesContent":["import {useState, useEffect, useCallback} from 'react';\nimport {useLoadScript} from './load-script.js';\nimport type {Model3d} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': PartialDeep<\n ModelViewerElement,\n {recurseIntoArrays: true}\n >;\n }\n }\n}\n\ntype ModelViewerProps = Omit<\n PartialDeep<JSX.IntrinsicElements['model-viewer'], {recurseIntoArrays: true}>,\n 'src'\n> &\n ModelViewerBaseProps;\n\ntype ModelViewerBaseProps = {\n /** An object with fields that correspond to the Storefront API's [Model3D object](https://shopify.dev/api/storefront/2026-04/objects/model3d). */\n data: PartialDeep<Model3d, {recurseIntoArrays: true}>;\n /** The callback to invoke when the 'error' event is triggered. Refer to [error in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-error). */\n onError?: (event: Event) => void;\n /** The callback to invoke when the `load` event is triggered. Refer to [load in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-load). */\n onLoad?: (event: Event) => void;\n /** The callback to invoke when the 'preload' event is triggered. Refer to [preload in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-preload). */\n onPreload?: (event: Event) => void;\n /** The callback to invoke when the 'model-visibility' event is triggered. Refer to [model-visibility in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-modelVisibility). */\n onModelVisibility?: (event: Event) => void;\n /** The callback to invoke when the 'progress' event is triggered. Refer to [progress in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-progress). */\n onProgress?: (event: Event) => void;\n /** The callback to invoke when the 'ar-status' event is triggered. Refer to [ar-status in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arStatus). */\n onArStatus?: (event: Event) => void;\n /** The callback to invoke when the 'ar-tracking' event is triggered. Refer to [ar-tracking in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arTracking). */\n onArTracking?: (event: Event) => void;\n /** The callback to invoke when the 'quick-look-button-tapped' event is triggered. Refer to [quick-look-button-tapped in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-quickLookButtonTapped). */\n onQuickLookButtonTapped?: (event: Event) => void;\n /** The callback to invoke when the 'camera-change' event is triggered. Refer to [camera-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-events-cameraChange). */\n onCameraChange?: (event: Event) => void;\n /** The callback to invoke when the 'environment-change' event is triggered. Refer to [environment-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-lightingandenv-events-environmentChange). */\n onEnvironmentChange?: (event: Event) => void;\n /** The callback to invoke when the 'play' event is triggered. Refer to [play in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-play). */\n onPlay?: (event: Event) => void;\n /** The callback to invoke when the 'pause' event is triggered. Refer to [pause in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-pause). */\n onPause?: (event: Event) => void;\n /** The callback to invoke when the 'scene-graph-ready' event is triggered. Refer to [scene-graph-ready in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-scenegraph-events-sceneGraphReady). */\n onSceneGraphReady?: (event: Event) => void;\n};\n\n/**\n * The `ModelViewer` component renders a 3D model (with the `model-viewer` custom element) for\n * the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).\n *\n * The `model-viewer` custom element is lazily downloaded through a dynamically-injected `<script type=\"module\">` tag when the `<ModelViewer />` component is rendered\n *\n * ModelViewer is using version `1.21.1` of the `@google/model-viewer` library.\n * @publicDocs\n */\nexport function ModelViewer(props: ModelViewerProps): JSX.Element | null {\n const [modelViewer, setModelViewer] = useState<undefined | HTMLElement>(\n undefined,\n );\n const callbackRef = useCallback((node: HTMLElement) => {\n setModelViewer(node);\n }, []);\n const {data, children, className, ...passthroughProps} = props;\n\n const modelViewerLoadedStatus = useLoadScript(\n 'https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js',\n {\n module: true,\n },\n );\n\n useEffect(() => {\n const hydrogenEventListener = {\n error: passthroughProps.onError,\n load: passthroughProps.onLoad,\n preload: passthroughProps.onPreload,\n 'model-visibility': passthroughProps.onModelVisibility,\n progress: passthroughProps.onProgress,\n 'ar-status': passthroughProps.onArStatus,\n 'ar-tracking': passthroughProps.onArTracking,\n 'quick-look-button-tapped': passthroughProps.onQuickLookButtonTapped,\n 'camera-change': passthroughProps.onCameraChange,\n 'environment-change': passthroughProps.onEnvironmentChange,\n play: passthroughProps.onPlay,\n pause: passthroughProps.onPause,\n 'scene-graph-ready': passthroughProps.onSceneGraphReady,\n };\n\n if (!modelViewer) {\n return;\n }\n Object.entries(hydrogenEventListener).forEach(\n ([eventName, callbackFunc]) => {\n if (callbackFunc) {\n modelViewer.addEventListener(eventName, callbackFunc);\n }\n },\n );\n\n return (): void => {\n if (modelViewer == null) {\n return;\n }\n Object.entries(hydrogenEventListener).forEach(\n ([eventName, callbackFunc]) => {\n if (callbackFunc) {\n modelViewer.removeEventListener(eventName, callbackFunc);\n }\n },\n );\n };\n }, [\n modelViewer,\n passthroughProps.onArStatus,\n passthroughProps.onArTracking,\n passthroughProps.onCameraChange,\n passthroughProps.onEnvironmentChange,\n passthroughProps.onError,\n passthroughProps.onLoad,\n passthroughProps.onModelVisibility,\n passthroughProps.onPause,\n passthroughProps.onPlay,\n passthroughProps.onPreload,\n passthroughProps.onProgress,\n passthroughProps.onQuickLookButtonTapped,\n passthroughProps.onSceneGraphReady,\n ]);\n\n if (modelViewerLoadedStatus !== 'done') {\n // TODO: What do we want to display while the model-viewer library loads?\n return null;\n }\n\n if (!data.sources?.[0]?.url) {\n const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(sourcesUrlError);\n } else {\n console.error(sourcesUrlError);\n return null;\n }\n }\n\n if (__HYDROGEN_DEV__ && !data.alt) {\n console.warn(\n `<ModelViewer/> requires the 'data.alt' prop for accessibility`,\n );\n }\n\n return (\n <model-viewer\n ref={callbackRef}\n {...passthroughProps}\n // @ts-expect-error src should exist\n // @eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n class={className}\n id={passthroughProps.id ?? data.id}\n src={data.sources[0].url}\n alt={data.alt ?? null}\n camera-controls={passthroughProps.cameraControls ?? true}\n poster={(passthroughProps.poster || data.previewImage?.url) ?? null}\n autoplay={passthroughProps.autoplay ?? true}\n loading={passthroughProps.loading}\n reveal={passthroughProps.reveal}\n ar={passthroughProps.ar}\n ar-modes={passthroughProps.arModes}\n ar-scale={passthroughProps.arScale}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ar-placement={passthroughProps.arPlacement}\n ios-src={passthroughProps.iosSrc}\n touch-action={passthroughProps.touchAction}\n disable-zoom={passthroughProps.disableZoom}\n orbit-sensitivity={passthroughProps.orbitSensitivity}\n auto-rotate={passthroughProps.autoRotate}\n auto-rotate-delay={passthroughProps.autoRotateDelay}\n // @ts-expect-error rotationPerSecond should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-attributes-rotationPerSecond\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n rotation-per-second={passthroughProps.rotationPerSecond}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n interaction-policy={(passthroughProps as any).interactionPolicy}\n interaction-prompt={passthroughProps.interactionPrompt}\n interaction-prompt-style={passthroughProps.interactionPromptStyle}\n interaction-prompt-threshold={passthroughProps.interactionPromptThreshold}\n camera-orbit={passthroughProps.cameraOrbit}\n camera-target={passthroughProps.cameraTarget}\n field-of-view={passthroughProps.fieldOfView}\n max-camera-orbit={passthroughProps.maxCameraOrbit}\n min-camera-orbit={passthroughProps.minCameraOrbit}\n max-field-of-view={passthroughProps.maxFieldOfView}\n min-field-of-view={passthroughProps.minFieldOfView}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bounds={(passthroughProps as any).bounds}\n interpolation-decay={passthroughProps.interpolationDecay ?? 100}\n skybox-image={passthroughProps.skyboxImage}\n environment-image={passthroughProps.environmentImage}\n exposure={passthroughProps.exposure}\n shadow-intensity={passthroughProps.shadowIntensity ?? 0}\n shadow-softness={passthroughProps.shadowSoftness ?? 0}\n animation-name={passthroughProps.animationName}\n animation-crossfade-duration={passthroughProps.animationCrossfadeDuration}\n variant-name={passthroughProps.variantName}\n orientation={passthroughProps.orientation}\n scale={passthroughProps.scale}\n >\n {children}\n </model-viewer>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgEA,SAAgB,YAAY,OAA6C;CACvE,MAAM,CAAC,aAAa,kBAAkB,SACpC,KAAA,EACD;CACD,MAAM,cAAc,aAAa,SAAsB;AACrD,iBAAe,KAAK;IACnB,EAAE,CAAC;CACN,MAAM,EAAC,MAAM,UAAU,WAAW,GAAG,qBAAoB;CAEzD,MAAM,0BAA0B,cAC9B,2EACA,EACE,QAAQ,MACT,CACF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