@shopify/hydrogen-react 2022.10.0 → 2022.10.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 (446) hide show
  1. package/dist/dev/AddToCartButton.js +70 -0
  2. package/dist/dev/AddToCartButton.js.map +1 -0
  3. package/dist/dev/AddToCartButton.mjs +70 -0
  4. package/dist/dev/AddToCartButton.mjs.map +1 -0
  5. package/dist/dev/BaseButton.js +31 -0
  6. package/dist/dev/BaseButton.js.map +1 -0
  7. package/dist/dev/BaseButton.mjs +31 -0
  8. package/dist/dev/BaseButton.mjs.map +1 -0
  9. package/dist/dev/BuyNowButton.js +45 -0
  10. package/dist/dev/BuyNowButton.js.map +1 -0
  11. package/dist/dev/BuyNowButton.mjs +45 -0
  12. package/dist/dev/BuyNowButton.mjs.map +1 -0
  13. package/dist/dev/CartCheckoutButton.js +30 -0
  14. package/dist/dev/CartCheckoutButton.js.map +1 -0
  15. package/dist/dev/CartCheckoutButton.mjs +30 -0
  16. package/dist/dev/CartCheckoutButton.mjs.map +1 -0
  17. package/dist/dev/CartProvider.js +35 -35
  18. package/dist/dev/CartProvider.js.map +1 -1
  19. package/dist/dev/{CartProvider.cjs → CartProvider.mjs} +36 -36
  20. package/dist/dev/{CartProvider.cjs.map → CartProvider.mjs.map} +1 -1
  21. package/dist/dev/ExternalVideo.js +5 -5
  22. package/dist/dev/ExternalVideo.js.map +1 -1
  23. package/dist/dev/{ExternalVideo.cjs → ExternalVideo.mjs} +6 -6
  24. package/dist/{prod/ExternalVideo.cjs.map → dev/ExternalVideo.mjs.map} +1 -1
  25. package/dist/dev/Image.js +12 -12
  26. package/dist/dev/Image.js.map +1 -1
  27. package/dist/dev/{Image.cjs → Image.mjs} +13 -13
  28. package/dist/dev/{Image.cjs.map → Image.mjs.map} +1 -1
  29. package/dist/dev/MediaFile.js +12 -12
  30. package/dist/dev/MediaFile.js.map +1 -1
  31. package/dist/dev/{MediaFile.cjs → MediaFile.mjs} +13 -13
  32. package/dist/dev/MediaFile.mjs.map +1 -0
  33. package/dist/dev/Metafield.js +38 -32
  34. package/dist/dev/Metafield.js.map +1 -1
  35. package/dist/dev/{Metafield.cjs → Metafield.mjs} +39 -33
  36. package/dist/dev/Metafield.mjs.map +1 -0
  37. package/dist/dev/ModelViewer.js +11 -11
  38. package/dist/dev/ModelViewer.js.map +1 -1
  39. package/dist/dev/{ModelViewer.cjs → ModelViewer.mjs} +12 -12
  40. package/dist/dev/{ModelViewer.cjs.map → ModelViewer.mjs.map} +1 -1
  41. package/dist/dev/Money.js +8 -8
  42. package/dist/dev/Money.js.map +1 -1
  43. package/dist/{prod/Money.cjs → dev/Money.mjs} +9 -9
  44. package/dist/dev/{Money.cjs.map → Money.mjs.map} +1 -1
  45. package/dist/dev/ProductPrice.js +9 -9
  46. package/dist/dev/ProductPrice.js.map +1 -1
  47. package/dist/{prod/ProductPrice.cjs → dev/ProductPrice.mjs} +10 -10
  48. package/dist/dev/ProductPrice.mjs.map +1 -0
  49. package/dist/dev/ProductProvider.js +25 -25
  50. package/dist/dev/ProductProvider.js.map +1 -1
  51. package/dist/{prod/ProductProvider.cjs → dev/ProductProvider.mjs} +26 -26
  52. package/dist/dev/{ProductProvider.cjs.map → ProductProvider.mjs.map} +1 -1
  53. package/dist/dev/ShopPayButton.js +13 -13
  54. package/dist/dev/ShopPayButton.js.map +1 -1
  55. package/dist/{prod/ShopPayButton.cjs → dev/ShopPayButton.mjs} +14 -14
  56. package/dist/{prod/ShopPayButton.cjs.map → dev/ShopPayButton.mjs.map} +1 -1
  57. package/dist/dev/ShopifyProvider.js +14 -14
  58. package/dist/dev/ShopifyProvider.js.map +1 -1
  59. package/dist/dev/ShopifyProvider.mjs +46 -0
  60. package/dist/dev/{ShopifyProvider.cjs.map → ShopifyProvider.mjs.map} +1 -1
  61. package/dist/dev/Video.js +9 -9
  62. package/dist/dev/Video.js.map +1 -1
  63. package/dist/dev/{Video.cjs → Video.mjs} +10 -10
  64. package/dist/dev/{Video.cjs.map → Video.mjs.map} +1 -1
  65. package/dist/dev/_virtual/index.js +3 -3
  66. package/dist/dev/_virtual/index.js.map +1 -1
  67. package/dist/dev/_virtual/index.mjs +5 -0
  68. package/dist/dev/_virtual/index.mjs.map +1 -0
  69. package/dist/dev/_virtual/use-sync-external-store-shim.development.js +3 -3
  70. package/dist/dev/_virtual/use-sync-external-store-shim.development.js.map +1 -1
  71. package/dist/dev/_virtual/use-sync-external-store-shim.development.mjs +5 -0
  72. package/dist/dev/_virtual/use-sync-external-store-shim.development.mjs.map +1 -0
  73. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +3 -3
  74. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +1 -1
  75. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.mjs +5 -0
  76. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.mjs.map +1 -0
  77. package/dist/dev/_virtual/with-selector.development.js +3 -3
  78. package/dist/dev/_virtual/with-selector.development.js.map +1 -1
  79. package/dist/dev/_virtual/with-selector.development.mjs +5 -0
  80. package/dist/dev/_virtual/with-selector.development.mjs.map +1 -0
  81. package/dist/dev/_virtual/with-selector.js +3 -3
  82. package/dist/dev/_virtual/with-selector.js.map +1 -1
  83. package/dist/dev/_virtual/with-selector.mjs +5 -0
  84. package/dist/dev/_virtual/with-selector.mjs.map +1 -0
  85. package/dist/dev/_virtual/with-selector.production.min.js +3 -3
  86. package/dist/dev/_virtual/with-selector.production.min.js.map +1 -1
  87. package/dist/dev/_virtual/with-selector.production.min.mjs +5 -0
  88. package/dist/dev/_virtual/with-selector.production.min.mjs.map +1 -0
  89. package/dist/dev/cart-constants.js +9 -9
  90. package/dist/dev/cart-constants.js.map +1 -1
  91. package/dist/dev/cart-constants.mjs +17 -0
  92. package/dist/dev/{cart-constants.cjs.map → cart-constants.mjs.map} +1 -1
  93. package/dist/dev/cart-hooks.js +15 -15
  94. package/dist/dev/cart-hooks.js.map +1 -1
  95. package/dist/dev/cart-hooks.mjs +48 -0
  96. package/dist/dev/{cart-hooks.cjs.map → cart-hooks.mjs.map} +1 -1
  97. package/dist/dev/cart-queries.js +11 -11
  98. package/dist/dev/cart-queries.js.map +1 -1
  99. package/dist/{prod/cart-queries.cjs → dev/cart-queries.mjs} +12 -12
  100. package/dist/dev/{cart-queries.cjs.map → cart-queries.mjs.map} +1 -1
  101. package/dist/dev/flatten-connection.js +3 -3
  102. package/dist/dev/flatten-connection.js.map +1 -1
  103. package/dist/dev/{flatten-connection.cjs → flatten-connection.mjs} +4 -4
  104. package/dist/dev/{flatten-connection.cjs.map → flatten-connection.mjs.map} +1 -1
  105. package/dist/dev/image-size.js +6 -6
  106. package/dist/dev/image-size.js.map +1 -1
  107. package/dist/dev/{image-size.cjs → image-size.mjs} +7 -7
  108. package/dist/{prod/image-size.cjs.map → dev/image-size.mjs.map} +1 -1
  109. package/dist/dev/index.js +45 -37
  110. package/dist/dev/index.js.map +1 -1
  111. package/dist/dev/index.mjs +46 -0
  112. package/dist/dev/index.mjs.map +1 -0
  113. package/dist/dev/load-script.js +7 -7
  114. package/dist/dev/load-script.js.map +1 -1
  115. package/dist/{prod/load-script.cjs → dev/load-script.mjs} +8 -8
  116. package/dist/dev/{load-script.cjs.map → load-script.mjs.map} +1 -1
  117. package/dist/dev/metafield-parser.js +103 -0
  118. package/dist/dev/metafield-parser.js.map +1 -0
  119. package/dist/dev/metafield-parser.mjs +103 -0
  120. package/dist/dev/metafield-parser.mjs.map +1 -0
  121. package/dist/dev/node_modules/@xstate/fsm/es/index.js +34 -35
  122. package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +1 -1
  123. package/dist/{prod/node_modules/@xstate/fsm/es/index.cjs → dev/node_modules/@xstate/fsm/es/index.mjs} +36 -35
  124. package/dist/dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -0
  125. package/dist/dev/node_modules/@xstate/react/es/fsm.js +21 -21
  126. package/dist/dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
  127. package/dist/{prod/node_modules/@xstate/react/es/fsm.cjs → dev/node_modules/@xstate/react/es/fsm.mjs} +22 -22
  128. package/dist/dev/node_modules/@xstate/react/es/{fsm.cjs.map → fsm.mjs.map} +1 -1
  129. package/dist/dev/node_modules/@xstate/react/es/useConstant.js +23 -5
  130. package/dist/dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  131. package/dist/dev/node_modules/@xstate/react/es/useConstant.mjs +12 -0
  132. package/dist/dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -0
  133. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +4 -5
  134. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -1
  135. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs +6 -0
  136. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/{use-isomorphic-layout-effect.browser.esm.cjs.map → use-isomorphic-layout-effect.browser.esm.mjs.map} +1 -1
  137. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +13 -11
  138. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  139. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/{with-selector.development.cjs → with-selector.development.mjs} +12 -14
  140. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map → dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map} +1 -1
  141. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +12 -10
  142. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  143. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/{with-selector.production.min.cjs → with-selector.production.min.mjs} +11 -13
  144. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -0
  145. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +11 -9
  146. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  147. package/dist/dev/node_modules/use-sync-external-store/cjs/{use-sync-external-store-shim.development.cjs → use-sync-external-store-shim.development.mjs} +10 -12
  148. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map → dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map} +1 -1
  149. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +11 -9
  150. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  151. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs → dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs} +10 -12
  152. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -0
  153. package/dist/dev/node_modules/use-sync-external-store/shim/index.js +12 -12
  154. package/dist/dev/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  155. package/dist/dev/node_modules/use-sync-external-store/shim/index.mjs +21 -0
  156. package/dist/dev/node_modules/use-sync-external-store/shim/{index.cjs.map → index.mjs.map} +1 -1
  157. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +7 -6
  158. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  159. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.mjs +11 -0
  160. package/dist/dev/node_modules/use-sync-external-store/shim/{with-selector.cjs.map → with-selector.mjs.map} +1 -1
  161. package/dist/dev/storefront-api-constants.js +3 -3
  162. package/dist/dev/storefront-api-constants.js.map +1 -1
  163. package/dist/dev/storefront-api-constants.mjs +5 -0
  164. package/dist/dev/storefront-api-constants.mjs.map +1 -0
  165. package/dist/dev/storefront-client.js +6 -6
  166. package/dist/dev/storefront-client.js.map +1 -1
  167. package/dist/dev/{storefront-client.cjs → storefront-client.mjs} +7 -7
  168. package/dist/dev/storefront-client.mjs.map +1 -0
  169. package/dist/dev/useCartAPIStateMachine.js +20 -20
  170. package/dist/dev/useCartAPIStateMachine.js.map +1 -1
  171. package/dist/{prod/useCartAPIStateMachine.cjs → dev/useCartAPIStateMachine.mjs} +21 -21
  172. package/dist/dev/{useCartAPIStateMachine.cjs.map → useCartAPIStateMachine.mjs.map} +1 -1
  173. package/dist/dev/useCartActions.js +26 -26
  174. package/dist/dev/useCartActions.js.map +1 -1
  175. package/dist/{prod/useCartActions.cjs → dev/useCartActions.mjs} +27 -27
  176. package/dist/dev/{useCartActions.cjs.map → useCartActions.mjs.map} +1 -1
  177. package/dist/dev/useMoney.js +10 -10
  178. package/dist/dev/useMoney.js.map +1 -1
  179. package/dist/{prod/useMoney.cjs → dev/useMoney.mjs} +11 -11
  180. package/dist/dev/{useMoney.cjs.map → useMoney.mjs.map} +1 -1
  181. package/dist/prod/AddToCartButton.js +70 -0
  182. package/dist/prod/AddToCartButton.js.map +1 -0
  183. package/dist/prod/AddToCartButton.mjs +70 -0
  184. package/dist/prod/AddToCartButton.mjs.map +1 -0
  185. package/dist/prod/BaseButton.js +31 -0
  186. package/dist/prod/BaseButton.js.map +1 -0
  187. package/dist/prod/BaseButton.mjs +31 -0
  188. package/dist/prod/BaseButton.mjs.map +1 -0
  189. package/dist/prod/BuyNowButton.js +45 -0
  190. package/dist/prod/BuyNowButton.js.map +1 -0
  191. package/dist/prod/BuyNowButton.mjs +45 -0
  192. package/dist/prod/BuyNowButton.mjs.map +1 -0
  193. package/dist/prod/CartCheckoutButton.js +30 -0
  194. package/dist/prod/CartCheckoutButton.js.map +1 -0
  195. package/dist/prod/CartCheckoutButton.mjs +30 -0
  196. package/dist/prod/CartCheckoutButton.mjs.map +1 -0
  197. package/dist/prod/CartProvider.js +35 -35
  198. package/dist/prod/CartProvider.js.map +1 -1
  199. package/dist/prod/{CartProvider.cjs → CartProvider.mjs} +36 -36
  200. package/dist/prod/{CartProvider.cjs.map → CartProvider.mjs.map} +1 -1
  201. package/dist/prod/ExternalVideo.js +5 -5
  202. package/dist/prod/ExternalVideo.js.map +1 -1
  203. package/dist/prod/{ExternalVideo.cjs → ExternalVideo.mjs} +6 -6
  204. package/dist/{dev/ExternalVideo.cjs.map → prod/ExternalVideo.mjs.map} +1 -1
  205. package/dist/prod/Image.js +12 -12
  206. package/dist/prod/Image.js.map +1 -1
  207. package/dist/prod/{Image.cjs → Image.mjs} +13 -13
  208. package/dist/prod/{Image.cjs.map → Image.mjs.map} +1 -1
  209. package/dist/prod/MediaFile.js +12 -12
  210. package/dist/prod/MediaFile.js.map +1 -1
  211. package/dist/prod/{MediaFile.cjs → MediaFile.mjs} +13 -13
  212. package/dist/prod/MediaFile.mjs.map +1 -0
  213. package/dist/prod/Metafield.js +32 -32
  214. package/dist/prod/Metafield.js.map +1 -1
  215. package/dist/prod/{Metafield.cjs → Metafield.mjs} +33 -33
  216. package/dist/prod/Metafield.mjs.map +1 -0
  217. package/dist/prod/ModelViewer.js +11 -11
  218. package/dist/prod/ModelViewer.js.map +1 -1
  219. package/dist/prod/{ModelViewer.cjs → ModelViewer.mjs} +12 -12
  220. package/dist/prod/{ModelViewer.cjs.map → ModelViewer.mjs.map} +1 -1
  221. package/dist/prod/Money.js +8 -8
  222. package/dist/prod/Money.js.map +1 -1
  223. package/dist/{dev/Money.cjs → prod/Money.mjs} +9 -9
  224. package/dist/prod/{Money.cjs.map → Money.mjs.map} +1 -1
  225. package/dist/prod/ProductPrice.js +9 -9
  226. package/dist/prod/ProductPrice.js.map +1 -1
  227. package/dist/{dev/ProductPrice.cjs → prod/ProductPrice.mjs} +10 -10
  228. package/dist/prod/ProductPrice.mjs.map +1 -0
  229. package/dist/prod/ProductProvider.js +25 -25
  230. package/dist/prod/ProductProvider.js.map +1 -1
  231. package/dist/{dev/ProductProvider.cjs → prod/ProductProvider.mjs} +26 -26
  232. package/dist/prod/{ProductProvider.cjs.map → ProductProvider.mjs.map} +1 -1
  233. package/dist/prod/ShopPayButton.js +13 -13
  234. package/dist/prod/ShopPayButton.js.map +1 -1
  235. package/dist/{dev/ShopPayButton.cjs → prod/ShopPayButton.mjs} +14 -14
  236. package/dist/{dev/ShopPayButton.cjs.map → prod/ShopPayButton.mjs.map} +1 -1
  237. package/dist/prod/ShopifyProvider.js +14 -14
  238. package/dist/prod/ShopifyProvider.js.map +1 -1
  239. package/dist/prod/ShopifyProvider.mjs +46 -0
  240. package/dist/prod/{ShopifyProvider.cjs.map → ShopifyProvider.mjs.map} +1 -1
  241. package/dist/prod/Video.js +9 -9
  242. package/dist/prod/Video.js.map +1 -1
  243. package/dist/prod/{Video.cjs → Video.mjs} +10 -10
  244. package/dist/prod/{Video.cjs.map → Video.mjs.map} +1 -1
  245. package/dist/prod/_virtual/index.js +3 -3
  246. package/dist/prod/_virtual/index.js.map +1 -1
  247. package/dist/prod/_virtual/index.mjs +5 -0
  248. package/dist/prod/_virtual/index.mjs.map +1 -0
  249. package/dist/prod/_virtual/use-sync-external-store-shim.development.js +3 -3
  250. package/dist/prod/_virtual/use-sync-external-store-shim.development.js.map +1 -1
  251. package/dist/prod/_virtual/use-sync-external-store-shim.development.mjs +5 -0
  252. package/dist/prod/_virtual/use-sync-external-store-shim.development.mjs.map +1 -0
  253. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +3 -3
  254. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +1 -1
  255. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.mjs +5 -0
  256. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.mjs.map +1 -0
  257. package/dist/prod/_virtual/with-selector.development.js +3 -3
  258. package/dist/prod/_virtual/with-selector.development.js.map +1 -1
  259. package/dist/prod/_virtual/with-selector.development.mjs +5 -0
  260. package/dist/prod/_virtual/with-selector.development.mjs.map +1 -0
  261. package/dist/prod/_virtual/with-selector.js +3 -3
  262. package/dist/prod/_virtual/with-selector.js.map +1 -1
  263. package/dist/prod/_virtual/with-selector.mjs +5 -0
  264. package/dist/prod/_virtual/with-selector.mjs.map +1 -0
  265. package/dist/prod/_virtual/with-selector.production.min.js +3 -3
  266. package/dist/prod/_virtual/with-selector.production.min.js.map +1 -1
  267. package/dist/prod/_virtual/with-selector.production.min.mjs +5 -0
  268. package/dist/prod/_virtual/with-selector.production.min.mjs.map +1 -0
  269. package/dist/prod/cart-constants.js +9 -9
  270. package/dist/prod/cart-constants.js.map +1 -1
  271. package/dist/prod/cart-constants.mjs +17 -0
  272. package/dist/prod/{cart-constants.cjs.map → cart-constants.mjs.map} +1 -1
  273. package/dist/prod/cart-hooks.js +15 -15
  274. package/dist/prod/cart-hooks.js.map +1 -1
  275. package/dist/prod/cart-hooks.mjs +48 -0
  276. package/dist/prod/{cart-hooks.cjs.map → cart-hooks.mjs.map} +1 -1
  277. package/dist/prod/cart-queries.js +11 -11
  278. package/dist/prod/cart-queries.js.map +1 -1
  279. package/dist/{dev/cart-queries.cjs → prod/cart-queries.mjs} +12 -12
  280. package/dist/prod/{cart-queries.cjs.map → cart-queries.mjs.map} +1 -1
  281. package/dist/prod/flatten-connection.js +3 -3
  282. package/dist/prod/flatten-connection.js.map +1 -1
  283. package/dist/prod/{flatten-connection.cjs → flatten-connection.mjs} +4 -4
  284. package/dist/prod/{flatten-connection.cjs.map → flatten-connection.mjs.map} +1 -1
  285. package/dist/prod/image-size.js +6 -6
  286. package/dist/prod/image-size.js.map +1 -1
  287. package/dist/prod/{image-size.cjs → image-size.mjs} +7 -7
  288. package/dist/{dev/image-size.cjs.map → prod/image-size.mjs.map} +1 -1
  289. package/dist/prod/index.js +45 -37
  290. package/dist/prod/index.js.map +1 -1
  291. package/dist/prod/index.mjs +46 -0
  292. package/dist/prod/index.mjs.map +1 -0
  293. package/dist/prod/load-script.js +7 -7
  294. package/dist/prod/load-script.js.map +1 -1
  295. package/dist/{dev/load-script.cjs → prod/load-script.mjs} +8 -8
  296. package/dist/prod/{load-script.cjs.map → load-script.mjs.map} +1 -1
  297. package/dist/prod/metafield-parser.js +114 -0
  298. package/dist/prod/metafield-parser.js.map +1 -0
  299. package/dist/prod/metafield-parser.mjs +114 -0
  300. package/dist/prod/metafield-parser.mjs.map +1 -0
  301. package/dist/prod/node_modules/@xstate/fsm/es/index.js +34 -35
  302. package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +1 -1
  303. package/dist/{dev/node_modules/@xstate/fsm/es/index.cjs → prod/node_modules/@xstate/fsm/es/index.mjs} +36 -35
  304. package/dist/prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -0
  305. package/dist/prod/node_modules/@xstate/react/es/fsm.js +21 -21
  306. package/dist/prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
  307. package/dist/{dev/node_modules/@xstate/react/es/fsm.cjs → prod/node_modules/@xstate/react/es/fsm.mjs} +22 -22
  308. package/dist/prod/node_modules/@xstate/react/es/{fsm.cjs.map → fsm.mjs.map} +1 -1
  309. package/dist/prod/node_modules/@xstate/react/es/useConstant.js +23 -5
  310. package/dist/prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  311. package/dist/prod/node_modules/@xstate/react/es/useConstant.mjs +12 -0
  312. package/dist/prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -0
  313. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +4 -5
  314. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -1
  315. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs +6 -0
  316. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/{use-isomorphic-layout-effect.browser.esm.cjs.map → use-isomorphic-layout-effect.browser.esm.mjs.map} +1 -1
  317. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +13 -11
  318. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  319. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/{with-selector.development.cjs → with-selector.development.mjs} +12 -14
  320. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map → prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map} +1 -1
  321. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +12 -10
  322. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  323. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/{with-selector.production.min.cjs → with-selector.production.min.mjs} +11 -13
  324. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -0
  325. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +11 -9
  326. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  327. package/dist/prod/node_modules/use-sync-external-store/cjs/{use-sync-external-store-shim.development.cjs → use-sync-external-store-shim.development.mjs} +10 -12
  328. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map → prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map} +1 -1
  329. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +11 -9
  330. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  331. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs → prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs} +10 -12
  332. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -0
  333. package/dist/prod/node_modules/use-sync-external-store/shim/index.js +12 -12
  334. package/dist/prod/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  335. package/dist/prod/node_modules/use-sync-external-store/shim/index.mjs +21 -0
  336. package/dist/prod/node_modules/use-sync-external-store/shim/{index.cjs.map → index.mjs.map} +1 -1
  337. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +7 -6
  338. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  339. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.mjs +11 -0
  340. package/dist/prod/node_modules/use-sync-external-store/shim/{with-selector.cjs.map → with-selector.mjs.map} +1 -1
  341. package/dist/prod/storefront-api-constants.js +3 -3
  342. package/dist/prod/storefront-api-constants.js.map +1 -1
  343. package/dist/prod/storefront-api-constants.mjs +5 -0
  344. package/dist/prod/storefront-api-constants.mjs.map +1 -0
  345. package/dist/prod/storefront-client.js +6 -6
  346. package/dist/prod/storefront-client.js.map +1 -1
  347. package/dist/prod/{storefront-client.cjs → storefront-client.mjs} +7 -7
  348. package/dist/prod/storefront-client.mjs.map +1 -0
  349. package/dist/prod/useCartAPIStateMachine.js +20 -20
  350. package/dist/prod/useCartAPIStateMachine.js.map +1 -1
  351. package/dist/{dev/useCartAPIStateMachine.cjs → prod/useCartAPIStateMachine.mjs} +21 -21
  352. package/dist/prod/{useCartAPIStateMachine.cjs.map → useCartAPIStateMachine.mjs.map} +1 -1
  353. package/dist/prod/useCartActions.js +26 -26
  354. package/dist/prod/useCartActions.js.map +1 -1
  355. package/dist/{dev/useCartActions.cjs → prod/useCartActions.mjs} +27 -27
  356. package/dist/prod/{useCartActions.cjs.map → useCartActions.mjs.map} +1 -1
  357. package/dist/prod/useMoney.js +10 -10
  358. package/dist/prod/useMoney.js.map +1 -1
  359. package/dist/{dev/useMoney.cjs → prod/useMoney.mjs} +11 -11
  360. package/dist/prod/{useMoney.cjs.map → useMoney.mjs.map} +1 -1
  361. package/dist/types/AddToCartButton.d.ts +22 -0
  362. package/dist/types/BaseButton.d.ts +15 -0
  363. package/dist/types/BuyNowButton.d.ts +15 -0
  364. package/dist/types/CartCheckoutButton.d.ts +12 -0
  365. package/dist/types/CartCost.d.ts +13 -0
  366. package/dist/types/MediaFile.d.ts +3 -1
  367. package/dist/types/Metafield.d.ts +3 -0
  368. package/dist/types/ProductPrice.d.ts +1 -2
  369. package/dist/types/index.d.cts +4 -0
  370. package/dist/types/index.d.ts +4 -0
  371. package/dist/types/metafield-parser.d.ts +222 -0
  372. package/dist/umd/hydrogen-react.dev.js +483 -204
  373. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  374. package/dist/umd/hydrogen-react.prod.js +17 -17
  375. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  376. package/package.json +25 -17
  377. package/dist/dev/MediaFile.cjs.map +0 -1
  378. package/dist/dev/Metafield.cjs.map +0 -1
  379. package/dist/dev/ProductPrice.cjs.map +0 -1
  380. package/dist/dev/ShopifyProvider.cjs +0 -46
  381. package/dist/dev/_virtual/index.cjs +0 -5
  382. package/dist/dev/_virtual/index.cjs.map +0 -1
  383. package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs +0 -5
  384. package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs.map +0 -1
  385. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs +0 -5
  386. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs.map +0 -1
  387. package/dist/dev/_virtual/with-selector.cjs +0 -5
  388. package/dist/dev/_virtual/with-selector.cjs.map +0 -1
  389. package/dist/dev/_virtual/with-selector.development.cjs +0 -5
  390. package/dist/dev/_virtual/with-selector.development.cjs.map +0 -1
  391. package/dist/dev/_virtual/with-selector.production.min.cjs +0 -5
  392. package/dist/dev/_virtual/with-selector.production.min.cjs.map +0 -1
  393. package/dist/dev/cart-constants.cjs +0 -17
  394. package/dist/dev/cart-hooks.cjs +0 -48
  395. package/dist/dev/index.cjs +0 -38
  396. package/dist/dev/index.cjs.map +0 -1
  397. package/dist/dev/node_modules/@xstate/fsm/es/index.cjs.map +0 -1
  398. package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs +0 -30
  399. package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs.map +0 -1
  400. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +0 -5
  401. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +0 -1
  402. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +0 -1
  403. package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs +0 -21
  404. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs +0 -12
  405. package/dist/dev/node_modules/worktop/cookie/index.cjs +0 -27
  406. package/dist/dev/node_modules/worktop/cookie/index.cjs.map +0 -1
  407. package/dist/dev/node_modules/worktop/cookie/index.js +0 -27
  408. package/dist/dev/node_modules/worktop/cookie/index.js.map +0 -1
  409. package/dist/dev/storefront-api-constants.cjs +0 -5
  410. package/dist/dev/storefront-api-constants.cjs.map +0 -1
  411. package/dist/dev/storefront-client.cjs.map +0 -1
  412. package/dist/prod/MediaFile.cjs.map +0 -1
  413. package/dist/prod/Metafield.cjs.map +0 -1
  414. package/dist/prod/ProductPrice.cjs.map +0 -1
  415. package/dist/prod/ShopifyProvider.cjs +0 -46
  416. package/dist/prod/_virtual/index.cjs +0 -5
  417. package/dist/prod/_virtual/index.cjs.map +0 -1
  418. package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs +0 -5
  419. package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs.map +0 -1
  420. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs +0 -5
  421. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs.map +0 -1
  422. package/dist/prod/_virtual/with-selector.cjs +0 -5
  423. package/dist/prod/_virtual/with-selector.cjs.map +0 -1
  424. package/dist/prod/_virtual/with-selector.development.cjs +0 -5
  425. package/dist/prod/_virtual/with-selector.development.cjs.map +0 -1
  426. package/dist/prod/_virtual/with-selector.production.min.cjs +0 -5
  427. package/dist/prod/_virtual/with-selector.production.min.cjs.map +0 -1
  428. package/dist/prod/cart-constants.cjs +0 -17
  429. package/dist/prod/cart-hooks.cjs +0 -48
  430. package/dist/prod/index.cjs +0 -38
  431. package/dist/prod/index.cjs.map +0 -1
  432. package/dist/prod/node_modules/@xstate/fsm/es/index.cjs.map +0 -1
  433. package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs +0 -30
  434. package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs.map +0 -1
  435. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +0 -5
  436. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +0 -1
  437. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +0 -1
  438. package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs +0 -21
  439. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs +0 -12
  440. package/dist/prod/node_modules/worktop/cookie/index.cjs +0 -27
  441. package/dist/prod/node_modules/worktop/cookie/index.cjs.map +0 -1
  442. package/dist/prod/node_modules/worktop/cookie/index.js +0 -27
  443. package/dist/prod/node_modules/worktop/cookie/index.js.map +0 -1
  444. package/dist/prod/storefront-api-constants.cjs +0 -5
  445. package/dist/prod/storefront-api-constants.cjs.map +0 -1
  446. package/dist/prod/storefront-client.cjs.map +0 -1
package/dist/dev/Image.js CHANGED
@@ -1,11 +1,13 @@
1
- import { getShopifyImageDimensions, shopifyImageLoader, IMG_SRC_SET_SIZES, addImageSizeParametersToUrl } from "./image-size.js";
2
- import { jsx } from "react/jsx-runtime";
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const imageSize = require("./image-size.js");
4
+ const jsxRuntime = require("react/jsx-runtime");
3
5
  function Image({
4
6
  data,
5
7
  width,
6
8
  height,
7
9
  loading,
8
- loader = shopifyImageLoader,
10
+ loader = imageSize.shopifyImageLoader,
9
11
  loaderOptions,
10
12
  widths,
11
13
  decoding = "async",
@@ -24,7 +26,7 @@ function Image({
24
26
  const {
25
27
  width: imgElementWidth,
26
28
  height: imgElementHeight
27
- } = getShopifyImageDimensions({
29
+ } = imageSize.getShopifyImageDimensions({
28
30
  data,
29
31
  loaderOptions,
30
32
  elementProps: {
@@ -56,7 +58,7 @@ function Image({
56
58
  height: imgElementHeight,
57
59
  loader
58
60
  });
59
- return /* @__PURE__ */ jsx("img", {
61
+ return /* @__PURE__ */ jsxRuntime.jsx("img", {
60
62
  id: (_f = data.id) != null ? _f : "",
61
63
  alt: (_h = (_g = data.altText) != null ? _g : rest.alt) != null ? _h : "",
62
64
  loading: loading != null ? loading : "lazy",
@@ -85,11 +87,11 @@ function internalImageSrcSet({
85
87
  if (width && height) {
86
88
  aspectRatio = Number(height) / Number(width);
87
89
  }
88
- let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;
89
- if (!hasCustomWidths && width && width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]) {
90
- setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);
90
+ let setSizes = hasCustomWidths ? widths : imageSize.IMG_SRC_SET_SIZES;
91
+ if (!hasCustomWidths && width && width < imageSize.IMG_SRC_SET_SIZES[imageSize.IMG_SRC_SET_SIZES.length - 1]) {
92
+ setSizes = imageSize.IMG_SRC_SET_SIZES.filter((size) => size <= width);
91
93
  }
92
- const srcGenerator = loader ? loader : addImageSizeParametersToUrl;
94
+ const srcGenerator = loader ? loader : imageSize.addImageSizeParametersToUrl;
93
95
  return setSizes.map((size) => `${srcGenerator({
94
96
  src,
95
97
  width: size,
@@ -98,7 +100,5 @@ function internalImageSrcSet({
98
100
  scale
99
101
  })} ${size}w`).join(", ");
100
102
  }
101
- export {
102
- Image
103
- };
103
+ exports.Image = Image;
104
104
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sources":["../../src/Image.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getShopifyImageDimensions,\n shopifyImageLoader,\n addImageSizeParametersToUrl,\n IMG_SRC_SET_SIZES,\n} from './image-size.js';\nimport type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type ShopifyLoaderOptions = {\n crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';\n scale?: 2 | 3;\n width?: HtmlImageProps['width'] | ImageType['width'];\n height?: HtmlImageProps['height'] | ImageType['height'];\n};\nexport type ShopifyLoaderParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n }\n>;\nexport type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {\n /** An object with fields that correspond to the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).\n * The `data` prop is required.\n */\n data: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A custom function that generates the image URL. Parameters passed in\n * are `ShopifyLoaderParams`\n */\n loader?: (params: ShopifyLoaderParams) => string;\n /** An object of `loader` function options. For example, if the `loader` function\n * requires a `scale` option, then the value can be a property of the\n * `loaderOptions` object (for example, `{scale: 2}`). The object shape is `ShopifyLoaderOptions`.\n */\n loaderOptions?: ShopifyLoaderOptions;\n /**\n * `src` isn't used, and should instead be passed as part of the `data` object\n */\n src?: never;\n /**\n * An array of pixel widths to overwrite the default generated srcset. For example, `[300, 600, 800]`.\n */\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n};\n\n/**\n * The `Image` component renders an image for the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image) by using the `data` prop. You can [customize this component](https://shopify.dev/api/hydrogen/components#customizing-hydrogen-components) using passthrough props.\n *\n * An image's width and height are determined using the following priority list:\n * 1. The width and height values for the `loaderOptions` prop\n * 2. The width and height values for bare props\n * 3. The width and height values for the `data` prop\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If `data.width` and `data.height` aren't available, then the aspect ratio cannot be determined and the missing\n * value will remain as `null`\n */\nexport function Image({\n data,\n width,\n height,\n loading,\n loader = shopifyImageLoader,\n loaderOptions,\n widths,\n decoding = 'async',\n ...rest\n}: ShopifyImageProps) {\n if (!data.url) {\n const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${\n data.id ?? 'no ID provided'\n }`;\n\n if (__HYDROGEN_DEV__) {\n throw new Error(missingUrlError);\n } else {\n console.error(missingUrlError);\n }\n\n return null;\n }\n\n if (__HYDROGEN_DEV__ && !data.altText && !rest.alt) {\n console.warn(\n `<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n const {width: imgElementWidth, height: imgElementHeight} =\n getShopifyImageDimensions({\n data,\n loaderOptions,\n elementProps: {\n width,\n height,\n },\n });\n\n if (__HYDROGEN_DEV__ && (!imgElementWidth || !imgElementHeight)) {\n console.warn(\n `<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n let finalSrc = data.url;\n\n if (loader) {\n finalSrc = loader({\n ...loaderOptions,\n src: data.url,\n width: imgElementWidth,\n height: imgElementHeight,\n });\n if (typeof finalSrc !== 'string' || !finalSrc) {\n throw new Error(\n `<Image/>: 'loader' did not return a valid string. Image: ${\n data.id ?? data.url\n }`\n );\n }\n }\n\n // determining what the intended width of the image is. For example, if the width is specified and lower than the image width, then that is the maximum image width\n // to prevent generating a srcset with widths bigger than needed or to generate images that would distort because of being larger than original\n const maxWidth =\n width && imgElementWidth && width < imgElementWidth\n ? width\n : imgElementWidth;\n const finalSrcset =\n rest.srcSet ??\n internalImageSrcSet({\n ...loaderOptions,\n widths,\n src: data.url,\n width: maxWidth,\n height: imgElementHeight,\n loader,\n });\n\n /* eslint-disable hydrogen/prefer-image-component */\n return (\n <img\n id={data.id ?? ''}\n alt={data.altText ?? rest.alt ?? ''}\n loading={loading ?? 'lazy'}\n {...rest}\n src={finalSrc}\n width={imgElementWidth ?? undefined}\n height={imgElementHeight ?? undefined}\n srcSet={finalSrcset}\n decoding={decoding}\n />\n );\n /* eslint-enable hydrogen/prefer-image-component */\n}\n\ntype InternalShopifySrcSetGeneratorsParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n loader?: (params: ShopifyLoaderParams) => string;\n }\n>;\nfunction internalImageSrcSet({\n src,\n width,\n crop,\n scale,\n widths,\n loader,\n height,\n}: InternalShopifySrcSetGeneratorsParams) {\n const hasCustomWidths = widths && Array.isArray(widths);\n if (hasCustomWidths && widths.some((size) => isNaN(size as number))) {\n throw new Error(\n `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`\n );\n }\n\n let aspectRatio = 1;\n if (width && height) {\n aspectRatio = Number(height) / Number(width);\n }\n\n let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;\n if (\n !hasCustomWidths &&\n width &&\n width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]\n ) {\n setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);\n }\n const srcGenerator = loader ? loader : addImageSizeParametersToUrl;\n return setSizes\n .map(\n (size) =>\n `${srcGenerator({\n src,\n width: size,\n // height is not applied if there is no crop\n // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size\n height: crop ? Number(size) * aspectRatio : undefined,\n crop,\n scale,\n })} ${size}w`\n )\n .join(', ');\n}\n"],"names":["Image","data","width","height","loading","loader","shopifyImageLoader","loaderOptions","widths","decoding","rest","url","missingUrlError","id","Error","altText","alt","console","warn","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","maxWidth","finalSrcset","srcSet","internalImageSrcSet","undefined","crop","scale","hasCustomWidths","Array","isArray","some","size","isNaN","aspectRatio","Number","setSizes","IMG_SRC_SET_SIZES","length","filter","srcGenerator","addImageSizeParametersToUrl","map","join"],"mappings":"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"}
1
+ {"version":3,"file":"Image.js","sources":["../../src/Image.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getShopifyImageDimensions,\n shopifyImageLoader,\n addImageSizeParametersToUrl,\n IMG_SRC_SET_SIZES,\n} from './image-size.js';\nimport type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type ShopifyLoaderOptions = {\n crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';\n scale?: 2 | 3;\n width?: HtmlImageProps['width'] | ImageType['width'];\n height?: HtmlImageProps['height'] | ImageType['height'];\n};\nexport type ShopifyLoaderParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n }\n>;\nexport type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {\n /** An object with fields that correspond to the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).\n * The `data` prop is required.\n */\n data: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A custom function that generates the image URL. Parameters passed in\n * are `ShopifyLoaderParams`\n */\n loader?: (params: ShopifyLoaderParams) => string;\n /** An object of `loader` function options. For example, if the `loader` function\n * requires a `scale` option, then the value can be a property of the\n * `loaderOptions` object (for example, `{scale: 2}`). The object shape is `ShopifyLoaderOptions`.\n */\n loaderOptions?: ShopifyLoaderOptions;\n /**\n * `src` isn't used, and should instead be passed as part of the `data` object\n */\n src?: never;\n /**\n * An array of pixel widths to overwrite the default generated srcset. For example, `[300, 600, 800]`.\n */\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n};\n\n/**\n * The `Image` component renders an image for the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image) by using the `data` prop. You can [customize this component](https://shopify.dev/api/hydrogen/components#customizing-hydrogen-components) using passthrough props.\n *\n * An image's width and height are determined using the following priority list:\n * 1. The width and height values for the `loaderOptions` prop\n * 2. The width and height values for bare props\n * 3. The width and height values for the `data` prop\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If `data.width` and `data.height` aren't available, then the aspect ratio cannot be determined and the missing\n * value will remain as `null`\n */\nexport function Image({\n data,\n width,\n height,\n loading,\n loader = shopifyImageLoader,\n loaderOptions,\n widths,\n decoding = 'async',\n ...rest\n}: ShopifyImageProps) {\n if (!data.url) {\n const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${\n data.id ?? 'no ID provided'\n }`;\n\n if (__HYDROGEN_DEV__) {\n throw new Error(missingUrlError);\n } else {\n console.error(missingUrlError);\n }\n\n return null;\n }\n\n if (__HYDROGEN_DEV__ && !data.altText && !rest.alt) {\n console.warn(\n `<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n const {width: imgElementWidth, height: imgElementHeight} =\n getShopifyImageDimensions({\n data,\n loaderOptions,\n elementProps: {\n width,\n height,\n },\n });\n\n if (__HYDROGEN_DEV__ && (!imgElementWidth || !imgElementHeight)) {\n console.warn(\n `<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n let finalSrc = data.url;\n\n if (loader) {\n finalSrc = loader({\n ...loaderOptions,\n src: data.url,\n width: imgElementWidth,\n height: imgElementHeight,\n });\n if (typeof finalSrc !== 'string' || !finalSrc) {\n throw new Error(\n `<Image/>: 'loader' did not return a valid string. Image: ${\n data.id ?? data.url\n }`\n );\n }\n }\n\n // determining what the intended width of the image is. For example, if the width is specified and lower than the image width, then that is the maximum image width\n // to prevent generating a srcset with widths bigger than needed or to generate images that would distort because of being larger than original\n const maxWidth =\n width && imgElementWidth && width < imgElementWidth\n ? width\n : imgElementWidth;\n const finalSrcset =\n rest.srcSet ??\n internalImageSrcSet({\n ...loaderOptions,\n widths,\n src: data.url,\n width: maxWidth,\n height: imgElementHeight,\n loader,\n });\n\n /* eslint-disable hydrogen/prefer-image-component */\n return (\n <img\n id={data.id ?? ''}\n alt={data.altText ?? rest.alt ?? ''}\n loading={loading ?? 'lazy'}\n {...rest}\n src={finalSrc}\n width={imgElementWidth ?? undefined}\n height={imgElementHeight ?? undefined}\n srcSet={finalSrcset}\n decoding={decoding}\n />\n );\n /* eslint-enable hydrogen/prefer-image-component */\n}\n\ntype InternalShopifySrcSetGeneratorsParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n loader?: (params: ShopifyLoaderParams) => string;\n }\n>;\nfunction internalImageSrcSet({\n src,\n width,\n crop,\n scale,\n widths,\n loader,\n height,\n}: InternalShopifySrcSetGeneratorsParams) {\n const hasCustomWidths = widths && Array.isArray(widths);\n if (hasCustomWidths && widths.some((size) => isNaN(size as number))) {\n throw new Error(\n `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`\n );\n }\n\n let aspectRatio = 1;\n if (width && height) {\n aspectRatio = Number(height) / Number(width);\n }\n\n let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;\n if (\n !hasCustomWidths &&\n width &&\n width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]\n ) {\n setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);\n }\n const srcGenerator = loader ? loader : addImageSizeParametersToUrl;\n return setSizes\n .map(\n (size) =>\n `${srcGenerator({\n src,\n width: size,\n // height is not applied if there is no crop\n // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size\n height: crop ? Number(size) * aspectRatio : undefined,\n crop,\n scale,\n })} ${size}w`\n )\n .join(', ');\n}\n"],"names":["Image","data","width","height","loading","loader","shopifyImageLoader","loaderOptions","widths","decoding","rest","url","missingUrlError","id","Error","altText","alt","console","warn","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","maxWidth","finalSrcset","srcSet","internalImageSrcSet","undefined","crop","scale","hasCustomWidths","Array","isArray","some","size","isNaN","aspectRatio","Number","setSizes","IMG_SRC_SET_SIZES","length","filter","srcGenerator","addImageSizeParametersToUrl","map","join"],"mappings":";;;;AA6DO,SAASA,MAAM;AAAA,EACpBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC,UAAAA;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,KACRC;AATiB,GAUA;;AAChB,MAAA,CAACT,KAAKU,KAAK;AACPC,UAAAA,kBAAmB,kEACvBX,UAAKY,OAALZ,YAAW;AAGS;AACd,YAAA,IAAIa,MAAMF,eAAV;AAAA,IAGP;AAAA,EAGF;AAED,MAAwB,CAACX,KAAKc,WAAW,CAACL,KAAKM,KAAK;AAClDC,YAAQC,KACL,iIACCjB,UAAKY,OAALZ,YAAWA,KAAKU,KAFpB;AAAA,EAKD;AAEK,QAAA;AAAA,IAACT,OAAOiB;AAAAA,IAAiBhB,QAAQiB;AAAAA,MACrCC,oCAA0B;AAAA,IACxBpB;AAAAA,IACAM;AAAAA,IACAe,cAAc;AAAA,MACZpB;AAAAA,MACAC;AAAAA,IAFY;AAAA,EAAA,CAHS;AAS3B,MAAyB,CAACgB,mBAAmB,CAACC,kBAAmB;AAC/DH,YAAQC,KACL,wHACCjB,UAAKY,OAALZ,YAAWA,KAAKU,KAFpB;AAAA,EAKD;AAED,MAAIY,WAAWtB,KAAKU;AAEpB,MAAIN,QAAQ;AACVkB,eAAWlB,OAAO;AAAA,MAChB,GAAGE;AAAAA,MACHiB,KAAKvB,KAAKU;AAAAA,MACVT,OAAOiB;AAAAA,MACPhB,QAAQiB;AAAAA,IAAAA,CAJO;AAMjB,QAAI,OAAOG,aAAa,YAAY,CAACA,UAAU;AAC7C,YAAM,IAAIT,MACP,6DACCb,UAAKY,OAALZ,YAAWA,KAAKU,KAFd;AAAA,IAKP;AAAA,EACF;AAID,QAAMc,WACJvB,SAASiB,mBAAmBjB,QAAQiB,kBAChCjB,QACAiB;AACAO,QAAAA,eACJhB,UAAKiB,WAALjB,YACAkB,oBAAoB;AAAA,IAClB,GAAGrB;AAAAA,IACHC;AAAAA,IACAgB,KAAKvB,KAAKU;AAAAA,IACVT,OAAOuB;AAAAA,IACPtB,QAAQiB;AAAAA,IACRf;AAAAA,EAAAA,CANiB;AAUrB,wCACE,OAAA;AAAA,IACE,KAAIJ,UAAKY,OAALZ,YAAW;AAAA,IACf,MAAKA,gBAAKc,YAALd,YAAgBS,KAAKM,QAArBf,YAA4B;AAAA,IACjC,SAASG,4BAAW;AAAA,IAHtB,GAIMM;AAAAA,IACJ,KAAKa;AAAAA,IACL,OAAOJ,4CAAmBU;AAAAA,IAC1B,QAAQT,8CAAoBS;AAAAA,IAC5B,QAAQH;AAAAA,IACR;AAAA,EAAA,CAVJ;AAcD;AASD,SAASE,oBAAoB;AAAA,EAC3BJ;AAAAA,EACAtB;AAAAA,EACA4B;AAAAA,EACAC;AAAAA,EACAvB;AAAAA,EACAH;AAAAA,EACAF;AAP2B,GAQa;AACxC,QAAM6B,kBAAkBxB,UAAUyB,MAAMC,QAAQ1B,MAAd;AAClC,MAAIwB,mBAAmBxB,OAAO2B,KAAMC,UAASC,MAAMD,IAAD,CAA3B,GAA8C;AAC7D,UAAA,IAAItB,MACP,8DAA6DU,KAD1D;AAAA,EAGP;AAED,MAAIc,cAAc;AAClB,MAAIpC,SAASC,QAAQ;AACnBmC,kBAAcC,OAAOpC,MAAD,IAAWoC,OAAOrC,KAAD;AAAA,EACtC;AAEGsC,MAAAA,WAAWR,kBAAkBxB,SAASiC;AAC1C,MACE,CAACT,mBACD9B,SACAA,QAAQuC,UAAkBA,kBAAAA,4BAAkBC,SAAS,IACrD;AACAF,eAAWC,UAAkBE,kBAAAA,OAAQP,CAASA,SAAAA,QAAQlC,KAA3C;AAAA,EACZ;AACK0C,QAAAA,eAAevC,SAASA,SAASwC;AACvC,SAAOL,SACJM,IACEV,CACE,SAAA,GAAEQ,aAAa;AAAA,IACdpB;AAAAA,IACAtB,OAAOkC;AAAAA,IAGPjC,QAAQ2B,OAAOS,OAAOH,IAAD,IAASE,cAAcT;AAAAA,IAC5CC;AAAAA,IACAC;AAAAA,EAAAA,CAPa,KAQTK,OAXL,EAaJW,KAAK,IAbD;AAcR;;"}
@@ -1,13 +1,11 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const imageSize = require("./image-size.cjs");
4
- const jsxRuntime = require("react/jsx-runtime");
1
+ import { getShopifyImageDimensions, shopifyImageLoader, IMG_SRC_SET_SIZES, addImageSizeParametersToUrl } from "./image-size.mjs";
2
+ import { jsx } from "react/jsx-runtime";
5
3
  function Image({
6
4
  data,
7
5
  width,
8
6
  height,
9
7
  loading,
10
- loader = imageSize.shopifyImageLoader,
8
+ loader = shopifyImageLoader,
11
9
  loaderOptions,
12
10
  widths,
13
11
  decoding = "async",
@@ -26,7 +24,7 @@ function Image({
26
24
  const {
27
25
  width: imgElementWidth,
28
26
  height: imgElementHeight
29
- } = imageSize.getShopifyImageDimensions({
27
+ } = getShopifyImageDimensions({
30
28
  data,
31
29
  loaderOptions,
32
30
  elementProps: {
@@ -58,7 +56,7 @@ function Image({
58
56
  height: imgElementHeight,
59
57
  loader
60
58
  });
61
- return /* @__PURE__ */ jsxRuntime.jsx("img", {
59
+ return /* @__PURE__ */ jsx("img", {
62
60
  id: (_f = data.id) != null ? _f : "",
63
61
  alt: (_h = (_g = data.altText) != null ? _g : rest.alt) != null ? _h : "",
64
62
  loading: loading != null ? loading : "lazy",
@@ -87,11 +85,11 @@ function internalImageSrcSet({
87
85
  if (width && height) {
88
86
  aspectRatio = Number(height) / Number(width);
89
87
  }
90
- let setSizes = hasCustomWidths ? widths : imageSize.IMG_SRC_SET_SIZES;
91
- if (!hasCustomWidths && width && width < imageSize.IMG_SRC_SET_SIZES[imageSize.IMG_SRC_SET_SIZES.length - 1]) {
92
- setSizes = imageSize.IMG_SRC_SET_SIZES.filter((size) => size <= width);
88
+ let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;
89
+ if (!hasCustomWidths && width && width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]) {
90
+ setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);
93
91
  }
94
- const srcGenerator = loader ? loader : imageSize.addImageSizeParametersToUrl;
92
+ const srcGenerator = loader ? loader : addImageSizeParametersToUrl;
95
93
  return setSizes.map((size) => `${srcGenerator({
96
94
  src,
97
95
  width: size,
@@ -100,5 +98,7 @@ function internalImageSrcSet({
100
98
  scale
101
99
  })} ${size}w`).join(", ");
102
100
  }
103
- exports.Image = Image;
104
- //# sourceMappingURL=Image.cjs.map
101
+ export {
102
+ Image
103
+ };
104
+ //# sourceMappingURL=Image.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.cjs","sources":["../../src/Image.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getShopifyImageDimensions,\n shopifyImageLoader,\n addImageSizeParametersToUrl,\n IMG_SRC_SET_SIZES,\n} from './image-size.js';\nimport type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type ShopifyLoaderOptions = {\n crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';\n scale?: 2 | 3;\n width?: HtmlImageProps['width'] | ImageType['width'];\n height?: HtmlImageProps['height'] | ImageType['height'];\n};\nexport type ShopifyLoaderParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n }\n>;\nexport type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {\n /** An object with fields that correspond to the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).\n * The `data` prop is required.\n */\n data: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A custom function that generates the image URL. Parameters passed in\n * are `ShopifyLoaderParams`\n */\n loader?: (params: ShopifyLoaderParams) => string;\n /** An object of `loader` function options. For example, if the `loader` function\n * requires a `scale` option, then the value can be a property of the\n * `loaderOptions` object (for example, `{scale: 2}`). The object shape is `ShopifyLoaderOptions`.\n */\n loaderOptions?: ShopifyLoaderOptions;\n /**\n * `src` isn't used, and should instead be passed as part of the `data` object\n */\n src?: never;\n /**\n * An array of pixel widths to overwrite the default generated srcset. For example, `[300, 600, 800]`.\n */\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n};\n\n/**\n * The `Image` component renders an image for the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image) by using the `data` prop. You can [customize this component](https://shopify.dev/api/hydrogen/components#customizing-hydrogen-components) using passthrough props.\n *\n * An image's width and height are determined using the following priority list:\n * 1. The width and height values for the `loaderOptions` prop\n * 2. The width and height values for bare props\n * 3. The width and height values for the `data` prop\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If `data.width` and `data.height` aren't available, then the aspect ratio cannot be determined and the missing\n * value will remain as `null`\n */\nexport function Image({\n data,\n width,\n height,\n loading,\n loader = shopifyImageLoader,\n loaderOptions,\n widths,\n decoding = 'async',\n ...rest\n}: ShopifyImageProps) {\n if (!data.url) {\n const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${\n data.id ?? 'no ID provided'\n }`;\n\n if (__HYDROGEN_DEV__) {\n throw new Error(missingUrlError);\n } else {\n console.error(missingUrlError);\n }\n\n return null;\n }\n\n if (__HYDROGEN_DEV__ && !data.altText && !rest.alt) {\n console.warn(\n `<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n const {width: imgElementWidth, height: imgElementHeight} =\n getShopifyImageDimensions({\n data,\n loaderOptions,\n elementProps: {\n width,\n height,\n },\n });\n\n if (__HYDROGEN_DEV__ && (!imgElementWidth || !imgElementHeight)) {\n console.warn(\n `<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n let finalSrc = data.url;\n\n if (loader) {\n finalSrc = loader({\n ...loaderOptions,\n src: data.url,\n width: imgElementWidth,\n height: imgElementHeight,\n });\n if (typeof finalSrc !== 'string' || !finalSrc) {\n throw new Error(\n `<Image/>: 'loader' did not return a valid string. Image: ${\n data.id ?? data.url\n }`\n );\n }\n }\n\n // determining what the intended width of the image is. For example, if the width is specified and lower than the image width, then that is the maximum image width\n // to prevent generating a srcset with widths bigger than needed or to generate images that would distort because of being larger than original\n const maxWidth =\n width && imgElementWidth && width < imgElementWidth\n ? width\n : imgElementWidth;\n const finalSrcset =\n rest.srcSet ??\n internalImageSrcSet({\n ...loaderOptions,\n widths,\n src: data.url,\n width: maxWidth,\n height: imgElementHeight,\n loader,\n });\n\n /* eslint-disable hydrogen/prefer-image-component */\n return (\n <img\n id={data.id ?? ''}\n alt={data.altText ?? rest.alt ?? ''}\n loading={loading ?? 'lazy'}\n {...rest}\n src={finalSrc}\n width={imgElementWidth ?? undefined}\n height={imgElementHeight ?? undefined}\n srcSet={finalSrcset}\n decoding={decoding}\n />\n );\n /* eslint-enable hydrogen/prefer-image-component */\n}\n\ntype InternalShopifySrcSetGeneratorsParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n loader?: (params: ShopifyLoaderParams) => string;\n }\n>;\nfunction internalImageSrcSet({\n src,\n width,\n crop,\n scale,\n widths,\n loader,\n height,\n}: InternalShopifySrcSetGeneratorsParams) {\n const hasCustomWidths = widths && Array.isArray(widths);\n if (hasCustomWidths && widths.some((size) => isNaN(size as number))) {\n throw new Error(\n `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`\n );\n }\n\n let aspectRatio = 1;\n if (width && height) {\n aspectRatio = Number(height) / Number(width);\n }\n\n let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;\n if (\n !hasCustomWidths &&\n width &&\n width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]\n ) {\n setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);\n }\n const srcGenerator = loader ? loader : addImageSizeParametersToUrl;\n return setSizes\n .map(\n (size) =>\n `${srcGenerator({\n src,\n width: size,\n // height is not applied if there is no crop\n // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size\n height: crop ? Number(size) * aspectRatio : undefined,\n crop,\n scale,\n })} ${size}w`\n )\n .join(', ');\n}\n"],"names":["Image","data","width","height","loading","loader","shopifyImageLoader","loaderOptions","widths","decoding","rest","url","missingUrlError","id","Error","altText","alt","console","warn","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","maxWidth","finalSrcset","srcSet","internalImageSrcSet","undefined","crop","scale","hasCustomWidths","Array","isArray","some","size","isNaN","aspectRatio","Number","setSizes","IMG_SRC_SET_SIZES","length","filter","srcGenerator","addImageSizeParametersToUrl","map","join"],"mappings":"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"}
1
+ {"version":3,"file":"Image.mjs","sources":["../../src/Image.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getShopifyImageDimensions,\n shopifyImageLoader,\n addImageSizeParametersToUrl,\n IMG_SRC_SET_SIZES,\n} from './image-size.js';\nimport type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type ShopifyLoaderOptions = {\n crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';\n scale?: 2 | 3;\n width?: HtmlImageProps['width'] | ImageType['width'];\n height?: HtmlImageProps['height'] | ImageType['height'];\n};\nexport type ShopifyLoaderParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n }\n>;\nexport type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {\n /** An object with fields that correspond to the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).\n * The `data` prop is required.\n */\n data: PartialDeep<ImageType, {recurseIntoArrays: true}>;\n /** A custom function that generates the image URL. Parameters passed in\n * are `ShopifyLoaderParams`\n */\n loader?: (params: ShopifyLoaderParams) => string;\n /** An object of `loader` function options. For example, if the `loader` function\n * requires a `scale` option, then the value can be a property of the\n * `loaderOptions` object (for example, `{scale: 2}`). The object shape is `ShopifyLoaderOptions`.\n */\n loaderOptions?: ShopifyLoaderOptions;\n /**\n * `src` isn't used, and should instead be passed as part of the `data` object\n */\n src?: never;\n /**\n * An array of pixel widths to overwrite the default generated srcset. For example, `[300, 600, 800]`.\n */\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n};\n\n/**\n * The `Image` component renders an image for the Storefront API's\n * [Image object](https://shopify.dev/api/storefront/reference/common-objects/image) by using the `data` prop. You can [customize this component](https://shopify.dev/api/hydrogen/components#customizing-hydrogen-components) using passthrough props.\n *\n * An image's width and height are determined using the following priority list:\n * 1. The width and height values for the `loaderOptions` prop\n * 2. The width and height values for bare props\n * 3. The width and height values for the `data` prop\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If `data.width` and `data.height` aren't available, then the aspect ratio cannot be determined and the missing\n * value will remain as `null`\n */\nexport function Image({\n data,\n width,\n height,\n loading,\n loader = shopifyImageLoader,\n loaderOptions,\n widths,\n decoding = 'async',\n ...rest\n}: ShopifyImageProps) {\n if (!data.url) {\n const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${\n data.id ?? 'no ID provided'\n }`;\n\n if (__HYDROGEN_DEV__) {\n throw new Error(missingUrlError);\n } else {\n console.error(missingUrlError);\n }\n\n return null;\n }\n\n if (__HYDROGEN_DEV__ && !data.altText && !rest.alt) {\n console.warn(\n `<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n const {width: imgElementWidth, height: imgElementHeight} =\n getShopifyImageDimensions({\n data,\n loaderOptions,\n elementProps: {\n width,\n height,\n },\n });\n\n if (__HYDROGEN_DEV__ && (!imgElementWidth || !imgElementHeight)) {\n console.warn(\n `<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. Image: ${\n data.id ?? data.url\n }`\n );\n }\n\n let finalSrc = data.url;\n\n if (loader) {\n finalSrc = loader({\n ...loaderOptions,\n src: data.url,\n width: imgElementWidth,\n height: imgElementHeight,\n });\n if (typeof finalSrc !== 'string' || !finalSrc) {\n throw new Error(\n `<Image/>: 'loader' did not return a valid string. Image: ${\n data.id ?? data.url\n }`\n );\n }\n }\n\n // determining what the intended width of the image is. For example, if the width is specified and lower than the image width, then that is the maximum image width\n // to prevent generating a srcset with widths bigger than needed or to generate images that would distort because of being larger than original\n const maxWidth =\n width && imgElementWidth && width < imgElementWidth\n ? width\n : imgElementWidth;\n const finalSrcset =\n rest.srcSet ??\n internalImageSrcSet({\n ...loaderOptions,\n widths,\n src: data.url,\n width: maxWidth,\n height: imgElementHeight,\n loader,\n });\n\n /* eslint-disable hydrogen/prefer-image-component */\n return (\n <img\n id={data.id ?? ''}\n alt={data.altText ?? rest.alt ?? ''}\n loading={loading ?? 'lazy'}\n {...rest}\n src={finalSrc}\n width={imgElementWidth ?? undefined}\n height={imgElementHeight ?? undefined}\n srcSet={finalSrcset}\n decoding={decoding}\n />\n );\n /* eslint-enable hydrogen/prefer-image-component */\n}\n\ntype InternalShopifySrcSetGeneratorsParams = Simplify<\n ShopifyLoaderOptions & {\n src: ImageType['url'];\n widths?: (HtmlImageProps['width'] | ImageType['width'])[];\n loader?: (params: ShopifyLoaderParams) => string;\n }\n>;\nfunction internalImageSrcSet({\n src,\n width,\n crop,\n scale,\n widths,\n loader,\n height,\n}: InternalShopifySrcSetGeneratorsParams) {\n const hasCustomWidths = widths && Array.isArray(widths);\n if (hasCustomWidths && widths.some((size) => isNaN(size as number))) {\n throw new Error(\n `<Image/>: the 'widths' must be an array of numbers. Image: ${src}`\n );\n }\n\n let aspectRatio = 1;\n if (width && height) {\n aspectRatio = Number(height) / Number(width);\n }\n\n let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;\n if (\n !hasCustomWidths &&\n width &&\n width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]\n ) {\n setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);\n }\n const srcGenerator = loader ? loader : addImageSizeParametersToUrl;\n return setSizes\n .map(\n (size) =>\n `${srcGenerator({\n src,\n width: size,\n // height is not applied if there is no crop\n // if there is crop, then height is applied as a ratio of the original width + height aspect ratio * size\n height: crop ? Number(size) * aspectRatio : undefined,\n crop,\n scale,\n })} ${size}w`\n )\n .join(', ');\n}\n"],"names":["Image","data","width","height","loading","loader","shopifyImageLoader","loaderOptions","widths","decoding","rest","url","missingUrlError","id","Error","altText","alt","console","warn","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","maxWidth","finalSrcset","srcSet","internalImageSrcSet","undefined","crop","scale","hasCustomWidths","Array","isArray","some","size","isNaN","aspectRatio","Number","setSizes","IMG_SRC_SET_SIZES","length","filter","srcGenerator","addImageSizeParametersToUrl","map","join"],"mappings":"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"}
@@ -1,8 +1,10 @@
1
- import { Image } from "./Image.js";
2
- import { Video } from "./Video.js";
3
- import { ExternalVideo } from "./ExternalVideo.js";
4
- import { ModelViewer } from "./ModelViewer.js";
5
- import { jsx } from "react/jsx-runtime";
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const Image = require("./Image.js");
4
+ const Video = require("./Video.js");
5
+ const ExternalVideo = require("./ExternalVideo.js");
6
+ const ModelViewer = require("./ModelViewer.js");
7
+ const jsxRuntime = require("react/jsx-runtime");
6
8
  function MediaFile({
7
9
  data,
8
10
  mediaOptions,
@@ -16,28 +18,28 @@ function MediaFile({
16
18
  throw new Error(noDataImage);
17
19
  }
18
20
  }
19
- return /* @__PURE__ */ jsx(Image, {
21
+ return /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
20
22
  ...passthroughProps,
21
23
  ...mediaOptions == null ? void 0 : mediaOptions.image,
22
24
  data: data.image
23
25
  });
24
26
  }
25
27
  case "Video": {
26
- return /* @__PURE__ */ jsx(Video, {
28
+ return /* @__PURE__ */ jsxRuntime.jsx(Video.Video, {
27
29
  ...passthroughProps,
28
30
  ...mediaOptions == null ? void 0 : mediaOptions.video,
29
31
  data
30
32
  });
31
33
  }
32
34
  case "ExternalVideo": {
33
- return /* @__PURE__ */ jsx(ExternalVideo, {
35
+ return /* @__PURE__ */ jsxRuntime.jsx(ExternalVideo.ExternalVideo, {
34
36
  ...passthroughProps,
35
37
  ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
36
38
  data
37
39
  });
38
40
  }
39
41
  case "Model3d": {
40
- return /* @__PURE__ */ jsx(ModelViewer, {
42
+ return /* @__PURE__ */ jsxRuntime.jsx(ModelViewer.ModelViewer, {
41
43
  ...passthroughProps,
42
44
  ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
43
45
  data
@@ -51,7 +53,5 @@ function MediaFile({
51
53
  }
52
54
  }
53
55
  }
54
- export {
55
- MediaFile
56
- };
56
+ exports.MediaFile = MediaFile;
57
57
  //# sourceMappingURL=MediaFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MediaFile.js","sources":["../../src/MediaFile.tsx"],"sourcesContent":["import {Image, type ShopifyImageProps} 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';\n\ninterface MediaFileProps {\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`, or `ExternalVideo` components. */\n mediaOptions?: {\n /** Props that will only apply when an `<Image />` is rendered */\n image: Omit<ShopifyImageProps, '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/**\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 */\nexport function MediaFile({\n data,\n mediaOptions,\n ...passthroughProps\n}: MediaFileProps) {\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 <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 correctly render the correct component for this media. Rendering 'null' by default`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typenameMissingMessage);\n } else {\n console.error(typenameMissingMessage);\n return null;\n }\n }\n }\n}\n"],"names":["MediaFile","data","mediaOptions","passthroughProps","__typename","image","noDataImage","Error","video","externalVideo","modelViewer","typenameMissingMessage"],"mappings":";;;;;AA+BO,SAASA,UAAU;AAAA,EACxBC;AAAAA,EACAC;AAAAA,KACGC;AAHqB,GAIP;AACjB,UAAQF,KAAKG,YAAb;AAAA,IACE,KAAK,cAAc;AACb,UAAA,CAACH,KAAKI,OAAO;AACf,cAAMC,cAAe;AACC;AACd,gBAAA,IAAIC,MAAMD,WAAV;AAAA,QAIP;AAAA,MACF;AAED,iCACG,OAAD;AAAA,QAAA,GACMH;AAAAA,QADN,GAEMD,6CAAcG;AAAAA,QAClB,MAAMJ,KAAKI;AAAAA,MAAAA,CAJf;AAAA,IAOD;AAAA,IACD,KAAK,SAAS;AACZ,iCACG,OAAD;AAAA,QAAA,GAAWF;AAAAA,QAAX,GAAiCD,6CAAcM;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,iCACG,eAAD;AAAA,QAAA,GACML;AAAAA,QADN,GAEMD,6CAAcO;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,iCACG,aAAD;AAAA,QAAA,GACMN;AAAAA,QADN,GAEMD,6CAAcQ;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AACV;AACd,cAAA,IAAIJ,MAAMI,sBAAV;AAAA,MAIP;AAAA,IACF;AAAA,EAnDH;AAqDD;"}
1
+ {"version":3,"file":"MediaFile.js","sources":["../../src/MediaFile.tsx"],"sourcesContent":["import {Image, type ShopifyImageProps} 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>;\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`, or `ExternalVideo` components. */\n mediaOptions?: {\n /** Props that will only apply when an `<Image />` is rendered */\n image: Omit<ShopifyImageProps, '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/**\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 */\nexport function MediaFile({\n data,\n mediaOptions,\n ...passthroughProps\n}: MediaFileProps) {\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 correctly render the correct component for this media. Rendering 'null' by default`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typenameMissingMessage);\n } else {\n console.error(typenameMissingMessage);\n return null;\n }\n }\n }\n}\n"],"names":["MediaFile","data","mediaOptions","passthroughProps","__typename","image","noDataImage","Error","Image","Video","video","ExternalVideo","externalVideo","ModelViewer","modelViewer","typenameMissingMessage"],"mappings":";;;;;;;AAmCO,SAASA,UAAU;AAAA,EACxBC;AAAAA,EACAC;AAAAA,KACGC;AAHqB,GAIP;AACjB,UAAQF,KAAKG,YAAb;AAAA,IACE,KAAK,cAAc;AACb,UAAA,CAACH,KAAKI,OAAO;AACf,cAAMC,cAAe;AACC;AACd,gBAAA,IAAIC,MAAMD,WAAV;AAAA,QAIP;AAAA,MACF;AAED,4CACGE,MAAAA,OAAD;AAAA,QAAA,GACML;AAAAA,QADN,GAEMD,6CAAcG;AAAAA,QAClB,MAAMJ,KAAKI;AAAAA,MAAAA,CAJf;AAAA,IAOD;AAAA,IACD,KAAK,SAAS;AACZ,4CACGI,MAAAA,OAAD;AAAA,QAAA,GAAWN;AAAAA,QAAX,GAAiCD,6CAAcQ;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,4CACGC,cAAAA,eAAD;AAAA,QAAA,GACMR;AAAAA,QADN,GAEMD,6CAAcU;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,4CAEGC,YAAAA;WACKV;AAAAA,QADN,GAEMD,6CAAcY;AAAAA,QAClB;AAAA,MAAA,CAHF;AAAA,IAMH;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AACV;AACd,cAAA,IAAIR,MAAMQ,sBAAV;AAAA,MAIP;AAAA,IACF;AAAA,EApDH;AAsDD;;"}
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const Image = require("./Image.cjs");
4
- const Video = require("./Video.cjs");
5
- const ExternalVideo = require("./ExternalVideo.cjs");
6
- const ModelViewer = require("./ModelViewer.cjs");
7
- const jsxRuntime = require("react/jsx-runtime");
1
+ import { Image } from "./Image.mjs";
2
+ import { Video } from "./Video.mjs";
3
+ import { ExternalVideo } from "./ExternalVideo.mjs";
4
+ import { ModelViewer } from "./ModelViewer.mjs";
5
+ import { jsx } from "react/jsx-runtime";
8
6
  function MediaFile({
9
7
  data,
10
8
  mediaOptions,
@@ -18,28 +16,28 @@ function MediaFile({
18
16
  throw new Error(noDataImage);
19
17
  }
20
18
  }
21
- return /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
19
+ return /* @__PURE__ */ jsx(Image, {
22
20
  ...passthroughProps,
23
21
  ...mediaOptions == null ? void 0 : mediaOptions.image,
24
22
  data: data.image
25
23
  });
26
24
  }
27
25
  case "Video": {
28
- return /* @__PURE__ */ jsxRuntime.jsx(Video.Video, {
26
+ return /* @__PURE__ */ jsx(Video, {
29
27
  ...passthroughProps,
30
28
  ...mediaOptions == null ? void 0 : mediaOptions.video,
31
29
  data
32
30
  });
33
31
  }
34
32
  case "ExternalVideo": {
35
- return /* @__PURE__ */ jsxRuntime.jsx(ExternalVideo.ExternalVideo, {
33
+ return /* @__PURE__ */ jsx(ExternalVideo, {
36
34
  ...passthroughProps,
37
35
  ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
38
36
  data
39
37
  });
40
38
  }
41
39
  case "Model3d": {
42
- return /* @__PURE__ */ jsxRuntime.jsx(ModelViewer.ModelViewer, {
40
+ return /* @__PURE__ */ jsx(ModelViewer, {
43
41
  ...passthroughProps,
44
42
  ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
45
43
  data
@@ -53,5 +51,7 @@ function MediaFile({
53
51
  }
54
52
  }
55
53
  }
56
- exports.MediaFile = MediaFile;
57
- //# sourceMappingURL=MediaFile.cjs.map
54
+ export {
55
+ MediaFile
56
+ };
57
+ //# sourceMappingURL=MediaFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaFile.mjs","sources":["../../src/MediaFile.tsx"],"sourcesContent":["import {Image, type ShopifyImageProps} 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>;\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`, or `ExternalVideo` components. */\n mediaOptions?: {\n /** Props that will only apply when an `<Image />` is rendered */\n image: Omit<ShopifyImageProps, '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/**\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 */\nexport function MediaFile({\n data,\n mediaOptions,\n ...passthroughProps\n}: MediaFileProps) {\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 correctly render the correct component for this media. Rendering 'null' by default`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typenameMissingMessage);\n } else {\n console.error(typenameMissingMessage);\n return null;\n }\n }\n }\n}\n"],"names":["MediaFile","data","mediaOptions","passthroughProps","__typename","image","noDataImage","Error","video","externalVideo","modelViewer","typenameMissingMessage"],"mappings":";;;;;AAmCO,SAASA,UAAU;AAAA,EACxBC;AAAAA,EACAC;AAAAA,KACGC;AAHqB,GAIP;AACjB,UAAQF,KAAKG,YAAb;AAAA,IACE,KAAK,cAAc;AACb,UAAA,CAACH,KAAKI,OAAO;AACf,cAAMC,cAAe;AACC;AACd,gBAAA,IAAIC,MAAMD,WAAV;AAAA,QAIP;AAAA,MACF;AAED,iCACG,OAAD;AAAA,QAAA,GACMH;AAAAA,QADN,GAEMD,6CAAcG;AAAAA,QAClB,MAAMJ,KAAKI;AAAAA,MAAAA,CAJf;AAAA,IAOD;AAAA,IACD,KAAK,SAAS;AACZ,iCACG,OAAD;AAAA,QAAA,GAAWF;AAAAA,QAAX,GAAiCD,6CAAcM;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,iCACG,eAAD;AAAA,QAAA,GACML;AAAAA,QADN,GAEMD,6CAAcO;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,iCAEG;WACKN;AAAAA,QADN,GAEMD,6CAAcQ;AAAAA,QAClB;AAAA,MAAA,CAHF;AAAA,IAMH;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AACV;AACd,cAAA,IAAIJ,MAAMI,sBAAV;AAAA,MAIP;AAAA,IACF;AAAA,EApDH;AAsDD;"}
@@ -1,9 +1,11 @@
1
- import { useMemo } from "react";
2
- import { useShop } from "./ShopifyProvider.js";
3
- import { Image } from "./Image.js";
4
- import { Video } from "./Video.js";
5
- import { flattenConnection } from "./flatten-connection.js";
6
- import { jsx } from "react/jsx-runtime";
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const require$$0 = require("react");
4
+ const ShopifyProvider = require("./ShopifyProvider.js");
5
+ const Image = require("./Image.js");
6
+ const Video = require("./Video.js");
7
+ const flattenConnection = require("./flatten-connection.js");
8
+ const jsxRuntime = require("react/jsx-runtime");
7
9
  function Metafield(props) {
8
10
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9
11
  const {
@@ -13,8 +15,8 @@ function Metafield(props) {
13
15
  } = props;
14
16
  const {
15
17
  locale
16
- } = useShop();
17
- const parsedMetafield = useMemo(() => parseMetafield(data), [data]);
18
+ } = ShopifyProvider.useShop();
19
+ const parsedMetafield = require$$0.useMemo(() => parseMetafield(data), [data]);
18
20
  if (!parsedMetafield) {
19
21
  const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;
20
22
  {
@@ -30,14 +32,14 @@ function Metafield(props) {
30
32
  switch (parsedMetafield.type) {
31
33
  case "date": {
32
34
  const Wrapper2 = as != null ? as : "time";
33
- return /* @__PURE__ */ jsx(Wrapper2, {
35
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
34
36
  ...passthroughProps,
35
37
  children: parsedMetafield.value.toLocaleDateString(locale)
36
38
  });
37
39
  }
38
40
  case "date_time": {
39
41
  const Wrapper2 = as != null ? as : "time";
40
- return /* @__PURE__ */ jsx(Wrapper2, {
42
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
41
43
  ...passthroughProps,
42
44
  children: parsedMetafield.value.toLocaleString(locale)
43
45
  });
@@ -46,21 +48,21 @@ function Metafield(props) {
46
48
  case "dimension":
47
49
  case "volume": {
48
50
  const Wrapper2 = as != null ? as : "span";
49
- return /* @__PURE__ */ jsx(Wrapper2, {
51
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
50
52
  ...passthroughProps,
51
53
  children: getMeasurementAsString(parsedMetafield.value, locale)
52
54
  });
53
55
  }
54
56
  case "rating": {
55
57
  const Wrapper2 = as != null ? as : "span";
56
- return /* @__PURE__ */ jsx(Wrapper2, {
58
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
57
59
  ...passthroughProps,
58
60
  children: parsedMetafield.value.value
59
61
  });
60
62
  }
61
63
  case "single_line_text_field": {
62
64
  const Wrapper2 = as != null ? as : "span";
63
- return /* @__PURE__ */ jsx(Wrapper2, {
65
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
64
66
  ...passthroughProps,
65
67
  dangerouslySetInnerHTML: {
66
68
  __html: parsedMetafield.value
@@ -69,7 +71,7 @@ function Metafield(props) {
69
71
  }
70
72
  case "multi_line_text_field": {
71
73
  const Wrapper2 = as != null ? as : "div";
72
- return /* @__PURE__ */ jsx(Wrapper2, {
74
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
73
75
  ...passthroughProps,
74
76
  dangerouslySetInnerHTML: {
75
77
  __html: parsedMetafield.value.split("\n").join("<br/>")
@@ -78,7 +80,7 @@ function Metafield(props) {
78
80
  }
79
81
  case "url": {
80
82
  const protocolLessUrl = new URL(parsedMetafield.value);
81
- return /* @__PURE__ */ jsx("a", {
83
+ return /* @__PURE__ */ jsxRuntime.jsx("a", {
82
84
  href: protocolLessUrl.href.replace(protocolLessUrl.protocol, ""),
83
85
  ...passthroughProps,
84
86
  children: parsedMetafield.value
@@ -86,7 +88,7 @@ function Metafield(props) {
86
88
  }
87
89
  case "json": {
88
90
  const Wrapper2 = as != null ? as : "span";
89
- return /* @__PURE__ */ jsx(Wrapper2, {
91
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
90
92
  ...passthroughProps,
91
93
  children: JSON.stringify(parsedMetafield.value)
92
94
  });
@@ -96,17 +98,17 @@ function Metafield(props) {
96
98
  case "page_reference": {
97
99
  const Wrapper2 = as != null ? as : "span";
98
100
  const ref = parsedMetafield.reference;
99
- return /* @__PURE__ */ jsx(Wrapper2, {
101
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
100
102
  ...passthroughProps,
101
103
  children: (_c = (_b = ref == null ? void 0 : ref.title) != null ? _b : ref == null ? void 0 : ref.id) != null ? _c : ""
102
104
  });
103
105
  }
104
106
  case "list.single_line_text_field": {
105
107
  const Wrapper2 = as != null ? as : "ul";
106
- const refArray = parsedMetafield.references ? flattenConnection(parsedMetafield.references) : [];
107
- return /* @__PURE__ */ jsx(Wrapper2, {
108
+ const refArray = parsedMetafield.references ? flattenConnection.flattenConnection(parsedMetafield.references) : [];
109
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
108
110
  ...passthroughProps,
109
- children: refArray.map((ref, index) => /* @__PURE__ */ jsx("li", {
111
+ children: refArray.map((ref, index) => /* @__PURE__ */ jsxRuntime.jsx("li", {
110
112
  children: ref
111
113
  }, `${ref != null ? ref : ""}-${index}`))
112
114
  });
@@ -114,22 +116,22 @@ function Metafield(props) {
114
116
  case "file_reference": {
115
117
  if (((_d = parsedMetafield.reference) == null ? void 0 : _d.__typename) === "MediaImage") {
116
118
  const ref = parsedMetafield.reference;
117
- return ref.image ? /* @__PURE__ */ jsx(Image, {
119
+ return ref.image ? /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
118
120
  data: ref.image,
119
121
  ...passthroughProps
120
122
  }) : null;
121
123
  } else if (((_e = parsedMetafield.reference) == null ? void 0 : _e.__typename) === "GenericFile") {
122
124
  const ref = parsedMetafield.reference;
123
- return ref.previewImage ? /* @__PURE__ */ jsx("a", {
125
+ return ref.previewImage ? /* @__PURE__ */ jsxRuntime.jsx("a", {
124
126
  href: (_g = (_f = parsedMetafield.reference) == null ? void 0 : _f.url) != null ? _g : "",
125
127
  ...passthroughProps,
126
- children: /* @__PURE__ */ jsx(Image, {
128
+ children: /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
127
129
  data: ref.previewImage
128
130
  })
129
131
  }) : null;
130
132
  } else if (((_h = parsedMetafield.reference) == null ? void 0 : _h.__typename) === "Video") {
131
133
  const ref = parsedMetafield.reference;
132
- return /* @__PURE__ */ jsx(Video, {
134
+ return /* @__PURE__ */ jsxRuntime.jsx(Video.Video, {
133
135
  ...passthroughProps,
134
136
  data: ref
135
137
  });
@@ -137,12 +139,15 @@ function Metafield(props) {
137
139
  }
138
140
  }
139
141
  const Wrapper = as != null ? as : "span";
140
- return /* @__PURE__ */ jsx(Wrapper, {
142
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper, {
141
143
  ...passthroughProps,
142
144
  children: (_i = parsedMetafield.value) == null ? void 0 : _i.toString()
143
145
  });
144
146
  }
145
147
  function parseMetafield(metafield) {
148
+ {
149
+ console.info(`'parseMetafield()' will have a breaking change in a future version; its behavior will match that of 'metafieldParser()'`);
150
+ }
146
151
  if (!metafield) {
147
152
  {
148
153
  console.warn(`'parseMetafield' was not passed any value for the 'metafield' argument`);
@@ -158,6 +163,9 @@ function parseMetafield(metafield) {
158
163
  };
159
164
  }
160
165
  function parseMetafieldValue(metafield) {
166
+ {
167
+ console.info(`'parseMetafieldValue()' will be removed in a future version`);
168
+ }
161
169
  if (!metafield) {
162
170
  return null;
163
171
  }
@@ -285,11 +293,9 @@ function convertToSupportedUnit(value, unit) {
285
293
  throw new Error(`Unit not supported: ${unit}`);
286
294
  }
287
295
  }
288
- export {
289
- Metafield,
290
- getMeasurementAsString,
291
- parseJSON,
292
- parseMetafield,
293
- parseMetafieldValue
294
- };
296
+ exports.Metafield = Metafield;
297
+ exports.getMeasurementAsString = getMeasurementAsString;
298
+ exports.parseJSON = parseJSON;
299
+ exports.parseMetafield = parseMetafield;
300
+ exports.parseMetafieldValue = parseMetafieldValue;
295
301
  //# sourceMappingURL=Metafield.js.map