@shopify/hydrogen-react 0.0.0-next-585a03d → 0.0.0-next-32f1381

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 (491) hide show
  1. package/dist/{dev/AddToCartButton.mjs → browser-dev/AddToCartButton.js} +4 -4
  2. package/dist/{dev → browser-dev}/AddToCartButton.js.map +1 -1
  3. package/dist/{dev/BaseButton.mjs → browser-dev/BaseButton.js} +1 -1
  4. package/dist/{dev → browser-dev}/BaseButton.js.map +1 -1
  5. package/dist/{prod/BuyNowButton.mjs → browser-dev/BuyNowButton.js} +3 -3
  6. package/dist/{dev → browser-dev}/BuyNowButton.js.map +1 -1
  7. package/dist/{dev/CartCheckoutButton.mjs → browser-dev/CartCheckoutButton.js} +3 -3
  8. package/dist/{dev → browser-dev}/CartCheckoutButton.js.map +1 -1
  9. package/dist/{prod/CartProvider.mjs → browser-dev/CartProvider.js} +3 -3
  10. package/dist/{prod → browser-dev}/CartProvider.js.map +1 -1
  11. package/dist/{prod/ExternalVideo.mjs → browser-dev/ExternalVideo.js} +1 -1
  12. package/dist/{dev → browser-dev}/ExternalVideo.js.map +1 -1
  13. package/dist/{dev/Image.mjs → browser-dev/Image.js} +2 -2
  14. package/dist/{dev → browser-dev}/Image.js.map +1 -1
  15. package/dist/{dev/MediaFile.mjs → browser-dev/MediaFile.js} +5 -5
  16. package/dist/{dev → browser-dev}/MediaFile.js.map +1 -1
  17. package/dist/{dev/Metafield.mjs → browser-dev/Metafield.js} +5 -5
  18. package/dist/{dev → browser-dev}/Metafield.js.map +1 -1
  19. package/dist/{dev/ModelViewer.mjs → browser-dev/ModelViewer.js} +2 -2
  20. package/dist/{dev → browser-dev}/ModelViewer.js.map +1 -1
  21. package/dist/{dev/Money.mjs → browser-dev/Money.js} +2 -2
  22. package/dist/{dev → browser-dev}/Money.js.map +1 -1
  23. package/dist/{dev/ProductPrice.mjs → browser-dev/ProductPrice.js} +3 -3
  24. package/dist/{dev → browser-dev}/ProductPrice.js.map +1 -1
  25. package/dist/{dev/ProductProvider.mjs → browser-dev/ProductProvider.js} +2 -2
  26. package/dist/{prod → browser-dev}/ProductProvider.js.map +1 -1
  27. package/dist/{prod/ShopPayButton.mjs → browser-dev/ShopPayButton.js} +3 -3
  28. package/dist/{prod → browser-dev}/ShopPayButton.js.map +1 -1
  29. package/dist/{dev/ShopifyProvider.mjs → browser-dev/ShopifyProvider.js} +2 -2
  30. package/dist/{prod → browser-dev}/ShopifyProvider.js.map +1 -1
  31. package/dist/{dev/Video.mjs → browser-dev/Video.js} +2 -2
  32. package/dist/{prod → browser-dev}/Video.js.map +1 -1
  33. package/dist/{dev/_virtual/index.mjs → browser-dev/_virtual/index.js} +1 -1
  34. package/dist/{dev → browser-dev}/_virtual/index.js.map +1 -1
  35. package/dist/{dev/_virtual/use-sync-external-store-shim.development.mjs → browser-dev/_virtual/use-sync-external-store-shim.development.js} +1 -1
  36. package/dist/{dev → browser-dev}/_virtual/use-sync-external-store-shim.development.js.map +1 -1
  37. package/dist/{dev/_virtual/use-sync-external-store-shim.production.min.mjs → browser-dev/_virtual/use-sync-external-store-shim.production.min.js} +1 -1
  38. package/dist/browser-dev/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
  39. package/dist/{prod/_virtual/with-selector.development.mjs → browser-dev/_virtual/with-selector.development.js} +1 -1
  40. package/dist/{dev → browser-dev}/_virtual/with-selector.development.js.map +1 -1
  41. package/dist/{prod/_virtual/with-selector.mjs → browser-dev/_virtual/with-selector.js} +1 -1
  42. package/dist/{dev → browser-dev}/_virtual/with-selector.js.map +1 -1
  43. package/dist/{dev/_virtual/with-selector.production.min.mjs → browser-dev/_virtual/with-selector.production.min.js} +1 -1
  44. package/dist/{dev → browser-dev}/_virtual/with-selector.production.min.js.map +1 -1
  45. package/dist/{prod/cart-constants.mjs → browser-dev/cart-constants.js} +1 -1
  46. package/dist/{dev → browser-dev}/cart-constants.js.map +1 -1
  47. package/dist/{dev/cart-hooks.mjs → browser-dev/cart-hooks.js} +3 -3
  48. package/dist/{prod → browser-dev}/cart-hooks.js.map +1 -1
  49. package/dist/{dev/cart-queries.mjs → browser-dev/cart-queries.js} +1 -1
  50. package/dist/{dev → browser-dev}/cart-queries.js.map +1 -1
  51. package/dist/{dev/flatten-connection.mjs → browser-dev/flatten-connection.js} +1 -1
  52. package/dist/{dev → browser-dev}/flatten-connection.js.map +1 -1
  53. package/dist/{prod/image-size.mjs → browser-dev/image-size.js} +1 -1
  54. package/dist/{dev → browser-dev}/image-size.js.map +1 -1
  55. package/dist/browser-dev/index.js +46 -0
  56. package/dist/browser-dev/index.js.map +1 -0
  57. package/dist/{prod/load-script.mjs → browser-dev/load-script.js} +1 -1
  58. package/dist/{dev → browser-dev}/load-script.js.map +1 -1
  59. package/dist/{dev/metafield-parser.mjs → browser-dev/metafield-parser.js} +3 -3
  60. package/dist/{dev → browser-dev}/metafield-parser.js.map +1 -1
  61. package/dist/{dev/node_modules/@xstate/fsm/es/index.mjs → browser-dev/node_modules/@xstate/fsm/es/index.js} +1 -1
  62. package/dist/browser-dev/node_modules/@xstate/fsm/es/index.js.map +1 -0
  63. package/dist/{prod/node_modules/@xstate/react/es/fsm.mjs → browser-dev/node_modules/@xstate/react/es/fsm.js} +6 -6
  64. package/dist/{prod → browser-dev}/node_modules/@xstate/react/es/fsm.js.map +1 -1
  65. package/dist/{dev/node_modules/@xstate/react/es/useConstant.mjs → browser-dev/node_modules/@xstate/react/es/useConstant.js} +1 -1
  66. package/dist/{dev → browser-dev}/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  67. package/dist/{dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs → browser-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js} +1 -1
  68. package/dist/{dev → browser-dev}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -1
  69. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js} +3 -3
  70. package/dist/{prod → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  71. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js} +3 -3
  72. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
  73. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js} +2 -2
  74. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  75. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js} +2 -2
  76. package/dist/{prod → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  77. package/dist/{dev/node_modules/use-sync-external-store/shim/index.mjs → browser-dev/node_modules/use-sync-external-store/shim/index.js} +4 -4
  78. package/dist/{prod → browser-dev}/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  79. package/dist/{prod/node_modules/use-sync-external-store/shim/with-selector.mjs → browser-dev/node_modules/use-sync-external-store/shim/with-selector.js} +4 -4
  80. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  81. package/dist/{prod/storefront-api-constants.mjs → browser-dev/storefront-api-constants.js} +1 -1
  82. package/dist/{dev → browser-dev}/storefront-api-constants.js.map +1 -1
  83. package/dist/{dev/storefront-client.mjs → browser-dev/storefront-client.js} +2 -2
  84. package/dist/{dev → browser-dev}/storefront-client.js.map +1 -1
  85. package/dist/{prod/useCartAPIStateMachine.mjs → browser-dev/useCartAPIStateMachine.js} +5 -5
  86. package/dist/{dev → browser-dev}/useCartAPIStateMachine.js.map +1 -1
  87. package/dist/{dev/useCartActions.mjs → browser-dev/useCartActions.js} +3 -3
  88. package/dist/{prod → browser-dev}/useCartActions.js.map +1 -1
  89. package/dist/{dev/useMoney.mjs → browser-dev/useMoney.js} +2 -2
  90. package/dist/{dev → browser-dev}/useMoney.js.map +1 -1
  91. package/dist/{prod/AddToCartButton.mjs → browser-prod/AddToCartButton.js} +4 -4
  92. package/dist/{prod → browser-prod}/AddToCartButton.js.map +1 -1
  93. package/dist/{prod/BaseButton.mjs → browser-prod/BaseButton.js} +1 -1
  94. package/dist/{prod → browser-prod}/BaseButton.js.map +1 -1
  95. package/dist/{dev/BuyNowButton.mjs → browser-prod/BuyNowButton.js} +3 -3
  96. package/dist/{prod → browser-prod}/BuyNowButton.js.map +1 -1
  97. package/dist/{prod/CartCheckoutButton.mjs → browser-prod/CartCheckoutButton.js} +3 -3
  98. package/dist/{prod → browser-prod}/CartCheckoutButton.js.map +1 -1
  99. package/dist/{dev/CartProvider.mjs → browser-prod/CartProvider.js} +3 -3
  100. package/dist/{dev → browser-prod}/CartProvider.js.map +1 -1
  101. package/dist/{dev/ExternalVideo.mjs → browser-prod/ExternalVideo.js} +1 -1
  102. package/dist/{prod → browser-prod}/ExternalVideo.js.map +1 -1
  103. package/dist/{prod/Image.mjs → browser-prod/Image.js} +2 -2
  104. package/dist/{prod → browser-prod}/Image.js.map +1 -1
  105. package/dist/{prod/MediaFile.mjs → browser-prod/MediaFile.js} +5 -5
  106. package/dist/{prod → browser-prod}/MediaFile.js.map +1 -1
  107. package/dist/{prod/Metafield.mjs → browser-prod/Metafield.js} +5 -5
  108. package/dist/{prod → browser-prod}/Metafield.js.map +1 -1
  109. package/dist/{prod/ModelViewer.mjs → browser-prod/ModelViewer.js} +2 -2
  110. package/dist/{prod → browser-prod}/ModelViewer.js.map +1 -1
  111. package/dist/{prod/Money.mjs → browser-prod/Money.js} +2 -2
  112. package/dist/{prod → browser-prod}/Money.js.map +1 -1
  113. package/dist/{prod/ProductPrice.mjs → browser-prod/ProductPrice.js} +3 -3
  114. package/dist/{prod → browser-prod}/ProductPrice.js.map +1 -1
  115. package/dist/{prod/ProductProvider.mjs → browser-prod/ProductProvider.js} +2 -2
  116. package/dist/{dev → browser-prod}/ProductProvider.js.map +1 -1
  117. package/dist/{dev/ShopPayButton.mjs → browser-prod/ShopPayButton.js} +3 -3
  118. package/dist/{dev → browser-prod}/ShopPayButton.js.map +1 -1
  119. package/dist/{prod/ShopifyProvider.mjs → browser-prod/ShopifyProvider.js} +2 -2
  120. package/dist/{dev → browser-prod}/ShopifyProvider.js.map +1 -1
  121. package/dist/{prod/Video.mjs → browser-prod/Video.js} +2 -2
  122. package/dist/{dev → browser-prod}/Video.js.map +1 -1
  123. package/dist/{prod/_virtual/index.mjs → browser-prod/_virtual/index.js} +1 -1
  124. package/dist/{prod → browser-prod}/_virtual/index.js.map +1 -1
  125. package/dist/{prod/_virtual/use-sync-external-store-shim.development.mjs → browser-prod/_virtual/use-sync-external-store-shim.development.js} +1 -1
  126. package/dist/{prod → browser-prod}/_virtual/use-sync-external-store-shim.development.js.map +1 -1
  127. package/dist/{prod/_virtual/use-sync-external-store-shim.production.min.mjs → browser-prod/_virtual/use-sync-external-store-shim.production.min.js} +1 -1
  128. package/dist/browser-prod/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
  129. package/dist/{dev/_virtual/with-selector.development.mjs → browser-prod/_virtual/with-selector.development.js} +1 -1
  130. package/dist/{prod → browser-prod}/_virtual/with-selector.development.js.map +1 -1
  131. package/dist/{dev/_virtual/with-selector.mjs → browser-prod/_virtual/with-selector.js} +1 -1
  132. package/dist/{prod → browser-prod}/_virtual/with-selector.js.map +1 -1
  133. package/dist/{prod/_virtual/with-selector.production.min.mjs → browser-prod/_virtual/with-selector.production.min.js} +1 -1
  134. package/dist/{prod → browser-prod}/_virtual/with-selector.production.min.js.map +1 -1
  135. package/dist/{dev/cart-constants.mjs → browser-prod/cart-constants.js} +1 -1
  136. package/dist/{prod → browser-prod}/cart-constants.js.map +1 -1
  137. package/dist/{prod/cart-hooks.mjs → browser-prod/cart-hooks.js} +3 -3
  138. package/dist/{dev → browser-prod}/cart-hooks.js.map +1 -1
  139. package/dist/{prod/cart-queries.mjs → browser-prod/cart-queries.js} +1 -1
  140. package/dist/{prod → browser-prod}/cart-queries.js.map +1 -1
  141. package/dist/{prod/flatten-connection.mjs → browser-prod/flatten-connection.js} +1 -1
  142. package/dist/{prod → browser-prod}/flatten-connection.js.map +1 -1
  143. package/dist/{dev/image-size.mjs → browser-prod/image-size.js} +1 -1
  144. package/dist/{prod → browser-prod}/image-size.js.map +1 -1
  145. package/dist/browser-prod/index.js +46 -0
  146. package/dist/browser-prod/index.js.map +1 -0
  147. package/dist/{dev/load-script.mjs → browser-prod/load-script.js} +1 -1
  148. package/dist/{prod → browser-prod}/load-script.js.map +1 -1
  149. package/dist/{prod/metafield-parser.mjs → browser-prod/metafield-parser.js} +3 -3
  150. package/dist/{prod → browser-prod}/metafield-parser.js.map +1 -1
  151. package/dist/{prod/node_modules/@xstate/fsm/es/index.mjs → browser-prod/node_modules/@xstate/fsm/es/index.js} +1 -1
  152. package/dist/browser-prod/node_modules/@xstate/fsm/es/index.js.map +1 -0
  153. package/dist/{dev/node_modules/@xstate/react/es/fsm.mjs → browser-prod/node_modules/@xstate/react/es/fsm.js} +6 -6
  154. package/dist/{dev → browser-prod}/node_modules/@xstate/react/es/fsm.js.map +1 -1
  155. package/dist/{prod/node_modules/@xstate/react/es/useConstant.mjs → browser-prod/node_modules/@xstate/react/es/useConstant.js} +1 -1
  156. package/dist/{prod → browser-prod}/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  157. package/dist/{prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs → browser-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js} +1 -1
  158. package/dist/{prod → browser-prod}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -1
  159. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js} +3 -3
  160. package/dist/{dev → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  161. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js} +3 -3
  162. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
  163. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js} +2 -2
  164. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  165. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js} +2 -2
  166. package/dist/{dev → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  167. package/dist/{prod/node_modules/use-sync-external-store/shim/index.mjs → browser-prod/node_modules/use-sync-external-store/shim/index.js} +4 -4
  168. package/dist/{dev → browser-prod}/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  169. package/dist/{dev/node_modules/use-sync-external-store/shim/with-selector.mjs → browser-prod/node_modules/use-sync-external-store/shim/with-selector.js} +4 -4
  170. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  171. package/dist/{dev/storefront-api-constants.mjs → browser-prod/storefront-api-constants.js} +1 -1
  172. package/dist/{prod → browser-prod}/storefront-api-constants.js.map +1 -1
  173. package/dist/{prod/storefront-client.mjs → browser-prod/storefront-client.js} +2 -2
  174. package/dist/{prod → browser-prod}/storefront-client.js.map +1 -1
  175. package/dist/{dev/useCartAPIStateMachine.mjs → browser-prod/useCartAPIStateMachine.js} +5 -5
  176. package/dist/{prod → browser-prod}/useCartAPIStateMachine.js.map +1 -1
  177. package/dist/{prod/useCartActions.mjs → browser-prod/useCartActions.js} +3 -3
  178. package/dist/{dev → browser-prod}/useCartActions.js.map +1 -1
  179. package/dist/{prod/useMoney.mjs → browser-prod/useMoney.js} +2 -2
  180. package/dist/{prod → browser-prod}/useMoney.js.map +1 -1
  181. package/dist/{dev/AddToCartButton.js → node-dev/AddToCartButton.cjs} +8 -8
  182. package/dist/{prod/AddToCartButton.mjs.map → node-dev/AddToCartButton.cjs.map} +1 -1
  183. package/dist/node-dev/AddToCartButton.js +70 -0
  184. package/dist/node-dev/AddToCartButton.js.map +1 -0
  185. package/dist/{dev/BaseButton.js → node-dev/BaseButton.cjs} +3 -3
  186. package/dist/{dev/BaseButton.mjs.map → node-dev/BaseButton.cjs.map} +1 -1
  187. package/dist/node-dev/BaseButton.js +31 -0
  188. package/dist/node-dev/BaseButton.js.map +1 -0
  189. package/dist/{prod/BuyNowButton.js → node-dev/BuyNowButton.cjs} +7 -7
  190. package/dist/{dev/BuyNowButton.mjs.map → node-dev/BuyNowButton.cjs.map} +1 -1
  191. package/dist/node-dev/BuyNowButton.js +45 -0
  192. package/dist/node-dev/BuyNowButton.js.map +1 -0
  193. package/dist/{prod/CartCheckoutButton.js → node-dev/CartCheckoutButton.cjs} +6 -6
  194. package/dist/{dev/CartCheckoutButton.mjs.map → node-dev/CartCheckoutButton.cjs.map} +1 -1
  195. package/dist/node-dev/CartCheckoutButton.js +30 -0
  196. package/dist/node-dev/CartCheckoutButton.js.map +1 -0
  197. package/dist/{dev/CartProvider.js → node-dev/CartProvider.cjs} +23 -23
  198. package/dist/{prod/CartProvider.mjs.map → node-dev/CartProvider.cjs.map} +1 -1
  199. package/dist/node-dev/CartProvider.js +485 -0
  200. package/dist/node-dev/CartProvider.js.map +1 -0
  201. package/dist/{dev/ExternalVideo.js → node-dev/ExternalVideo.cjs} +1 -1
  202. package/dist/{prod/ExternalVideo.mjs.map → node-dev/ExternalVideo.cjs.map} +1 -1
  203. package/dist/node-dev/ExternalVideo.js +39 -0
  204. package/dist/node-dev/ExternalVideo.js.map +1 -0
  205. package/dist/{dev/Image.js → node-dev/Image.cjs} +2 -2
  206. package/dist/{dev/Image.mjs.map → node-dev/Image.cjs.map} +1 -1
  207. package/dist/node-dev/Image.js +104 -0
  208. package/dist/node-dev/Image.js.map +1 -0
  209. package/dist/{dev/MediaFile.js → node-dev/MediaFile.cjs} +5 -5
  210. package/dist/{dev/MediaFile.mjs.map → node-dev/MediaFile.cjs.map} +1 -1
  211. package/dist/node-dev/MediaFile.js +57 -0
  212. package/dist/node-dev/MediaFile.js.map +1 -0
  213. package/dist/{dev/Metafield.js → node-dev/Metafield.cjs} +7 -7
  214. package/dist/{dev/Metafield.mjs.map → node-dev/Metafield.cjs.map} +1 -1
  215. package/dist/node-dev/Metafield.js +301 -0
  216. package/dist/node-dev/Metafield.js.map +1 -0
  217. package/dist/{dev/ModelViewer.js → node-dev/ModelViewer.cjs} +6 -6
  218. package/dist/{dev/ModelViewer.mjs.map → node-dev/ModelViewer.cjs.map} +1 -1
  219. package/dist/node-dev/ModelViewer.js +145 -0
  220. package/dist/node-dev/ModelViewer.js.map +1 -0
  221. package/dist/{prod/Money.js → node-dev/Money.cjs} +2 -2
  222. package/dist/{dev/Money.mjs.map → node-dev/Money.cjs.map} +1 -1
  223. package/dist/node-dev/Money.js +40 -0
  224. package/dist/node-dev/Money.js.map +1 -0
  225. package/dist/{prod/ProductPrice.js → node-dev/ProductPrice.cjs} +3 -3
  226. package/dist/{dev/ProductPrice.mjs.map → node-dev/ProductPrice.cjs.map} +1 -1
  227. package/dist/node-dev/ProductPrice.js +61 -0
  228. package/dist/node-dev/ProductPrice.js.map +1 -0
  229. package/dist/{prod/ProductProvider.js → node-dev/ProductProvider.cjs} +16 -16
  230. package/dist/{dev/ProductProvider.mjs.map → node-dev/ProductProvider.cjs.map} +1 -1
  231. package/dist/node-dev/ProductProvider.js +161 -0
  232. package/dist/node-dev/ProductProvider.js.map +1 -0
  233. package/dist/{dev/ShopPayButton.js → node-dev/ShopPayButton.cjs} +3 -3
  234. package/dist/{prod/ShopPayButton.mjs.map → node-dev/ShopPayButton.cjs.map} +1 -1
  235. package/dist/node-dev/ShopPayButton.js +64 -0
  236. package/dist/node-dev/ShopPayButton.js.map +1 -0
  237. package/dist/{prod/ShopifyProvider.js → node-dev/ShopifyProvider.cjs} +6 -6
  238. package/dist/{dev/ShopifyProvider.mjs.map → node-dev/ShopifyProvider.cjs.map} +1 -1
  239. package/dist/node-dev/ShopifyProvider.js +46 -0
  240. package/dist/node-dev/ShopifyProvider.js.map +1 -0
  241. package/dist/{prod/Video.js → node-dev/Video.cjs} +4 -4
  242. package/dist/{dev/Video.mjs.map → node-dev/Video.cjs.map} +1 -1
  243. package/dist/node-dev/Video.js +44 -0
  244. package/dist/node-dev/Video.js.map +1 -0
  245. package/dist/{prod/cart-constants.js → node-dev/cart-constants.cjs} +1 -1
  246. package/dist/{dev/cart-constants.mjs.map → node-dev/cart-constants.cjs.map} +1 -1
  247. package/dist/node-dev/cart-constants.js +17 -0
  248. package/dist/node-dev/cart-constants.js.map +1 -0
  249. package/dist/{dev/cart-hooks.js → node-dev/cart-hooks.cjs} +5 -5
  250. package/dist/{prod/cart-hooks.mjs.map → node-dev/cart-hooks.cjs.map} +1 -1
  251. package/dist/node-dev/cart-hooks.js +48 -0
  252. package/dist/node-dev/cart-hooks.js.map +1 -0
  253. package/dist/{dev/cart-queries.js → node-dev/cart-queries.cjs} +1 -1
  254. package/dist/{dev/cart-queries.mjs.map → node-dev/cart-queries.cjs.map} +1 -1
  255. package/dist/node-dev/cart-queries.js +114 -0
  256. package/dist/node-dev/cart-queries.js.map +1 -0
  257. package/dist/{dev/flatten-connection.js → node-dev/flatten-connection.cjs} +1 -1
  258. package/dist/{dev/flatten-connection.mjs.map → node-dev/flatten-connection.cjs.map} +1 -1
  259. package/dist/node-dev/flatten-connection.js +29 -0
  260. package/dist/node-dev/flatten-connection.js.map +1 -0
  261. package/dist/{dev/image-size.js → node-dev/image-size.cjs} +1 -1
  262. package/dist/{prod/image-size.mjs.map → node-dev/image-size.cjs.map} +1 -1
  263. package/dist/node-dev/image-size.js +80 -0
  264. package/dist/node-dev/image-size.js.map +1 -0
  265. package/dist/{prod/index.js → node-dev/index.cjs} +20 -20
  266. package/dist/node-dev/index.cjs.map +1 -0
  267. package/dist/node-dev/index.js +46 -0
  268. package/dist/node-dev/index.js.map +1 -0
  269. package/dist/{prod/load-script.js → node-dev/load-script.cjs} +4 -4
  270. package/dist/{dev/load-script.mjs.map → node-dev/load-script.cjs.map} +1 -1
  271. package/dist/node-dev/load-script.js +52 -0
  272. package/dist/node-dev/load-script.js.map +1 -0
  273. package/dist/{dev/metafield-parser.js → node-dev/metafield-parser.cjs} +3 -3
  274. package/dist/{dev/metafield-parser.mjs.map → node-dev/metafield-parser.cjs.map} +1 -1
  275. package/dist/node-dev/metafield-parser.js +103 -0
  276. package/dist/node-dev/metafield-parser.js.map +1 -0
  277. package/dist/{prod/storefront-api-constants.js → node-dev/storefront-api-constants.cjs} +1 -1
  278. package/dist/node-dev/storefront-api-constants.cjs.map +1 -0
  279. package/dist/node-dev/storefront-api-constants.js +5 -0
  280. package/dist/node-dev/storefront-api-constants.js.map +1 -0
  281. package/dist/{dev/storefront-client.js → node-dev/storefront-client.cjs} +2 -2
  282. package/dist/{dev/storefront-client.mjs.map → node-dev/storefront-client.cjs.map} +1 -1
  283. package/dist/node-dev/storefront-client.js +72 -0
  284. package/dist/node-dev/storefront-client.js.map +1 -0
  285. package/dist/{prod/useCartAPIStateMachine.js → node-dev/useCartAPIStateMachine.cjs} +15 -15
  286. package/dist/{prod/useCartAPIStateMachine.mjs.map → node-dev/useCartAPIStateMachine.cjs.map} +1 -1
  287. package/dist/node-dev/useCartAPIStateMachine.js +326 -0
  288. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -0
  289. package/dist/{dev/useCartActions.js → node-dev/useCartActions.cjs} +14 -14
  290. package/dist/{dev/useCartActions.mjs.map → node-dev/useCartActions.cjs.map} +1 -1
  291. package/dist/node-dev/useCartActions.js +123 -0
  292. package/dist/node-dev/useCartActions.js.map +1 -0
  293. package/dist/{prod/useMoney.js → node-dev/useMoney.cjs} +7 -7
  294. package/dist/{dev/useMoney.mjs.map → node-dev/useMoney.cjs.map} +1 -1
  295. package/dist/node-dev/useMoney.js +72 -0
  296. package/dist/node-dev/useMoney.js.map +1 -0
  297. package/dist/{prod/AddToCartButton.js → node-prod/AddToCartButton.cjs} +8 -8
  298. package/dist/{dev/AddToCartButton.mjs.map → node-prod/AddToCartButton.cjs.map} +1 -1
  299. package/dist/node-prod/AddToCartButton.js +70 -0
  300. package/dist/node-prod/AddToCartButton.js.map +1 -0
  301. package/dist/{prod/BaseButton.js → node-prod/BaseButton.cjs} +3 -3
  302. package/dist/{prod/BaseButton.mjs.map → node-prod/BaseButton.cjs.map} +1 -1
  303. package/dist/node-prod/BaseButton.js +31 -0
  304. package/dist/node-prod/BaseButton.js.map +1 -0
  305. package/dist/{dev/BuyNowButton.js → node-prod/BuyNowButton.cjs} +7 -7
  306. package/dist/{prod/BuyNowButton.mjs.map → node-prod/BuyNowButton.cjs.map} +1 -1
  307. package/dist/node-prod/BuyNowButton.js +45 -0
  308. package/dist/node-prod/BuyNowButton.js.map +1 -0
  309. package/dist/{dev/CartCheckoutButton.js → node-prod/CartCheckoutButton.cjs} +6 -6
  310. package/dist/{prod/CartCheckoutButton.mjs.map → node-prod/CartCheckoutButton.cjs.map} +1 -1
  311. package/dist/node-prod/CartCheckoutButton.js +30 -0
  312. package/dist/node-prod/CartCheckoutButton.js.map +1 -0
  313. package/dist/{prod/CartProvider.js → node-prod/CartProvider.cjs} +23 -23
  314. package/dist/{dev/CartProvider.mjs.map → node-prod/CartProvider.cjs.map} +1 -1
  315. package/dist/node-prod/CartProvider.js +485 -0
  316. package/dist/node-prod/CartProvider.js.map +1 -0
  317. package/dist/{prod/ExternalVideo.js → node-prod/ExternalVideo.cjs} +1 -1
  318. package/dist/{dev/ExternalVideo.mjs.map → node-prod/ExternalVideo.cjs.map} +1 -1
  319. package/dist/node-prod/ExternalVideo.js +39 -0
  320. package/dist/node-prod/ExternalVideo.js.map +1 -0
  321. package/dist/{prod/Image.js → node-prod/Image.cjs} +2 -2
  322. package/dist/{prod/Image.mjs.map → node-prod/Image.cjs.map} +1 -1
  323. package/dist/node-prod/Image.js +99 -0
  324. package/dist/node-prod/Image.js.map +1 -0
  325. package/dist/{prod/MediaFile.js → node-prod/MediaFile.cjs} +5 -5
  326. package/dist/{prod/MediaFile.mjs.map → node-prod/MediaFile.cjs.map} +1 -1
  327. package/dist/node-prod/MediaFile.js +59 -0
  328. package/dist/node-prod/MediaFile.js.map +1 -0
  329. package/dist/{prod/Metafield.js → node-prod/Metafield.cjs} +7 -7
  330. package/dist/{prod/Metafield.mjs.map → node-prod/Metafield.cjs.map} +1 -1
  331. package/dist/node-prod/Metafield.js +288 -0
  332. package/dist/node-prod/Metafield.js.map +1 -0
  333. package/dist/{prod/ModelViewer.js → node-prod/ModelViewer.cjs} +6 -6
  334. package/dist/{prod/ModelViewer.mjs.map → node-prod/ModelViewer.cjs.map} +1 -1
  335. package/dist/node-prod/ModelViewer.js +143 -0
  336. package/dist/node-prod/ModelViewer.js.map +1 -0
  337. package/dist/{dev/Money.js → node-prod/Money.cjs} +2 -2
  338. package/dist/{prod/Money.mjs.map → node-prod/Money.cjs.map} +1 -1
  339. package/dist/node-prod/Money.js +40 -0
  340. package/dist/node-prod/Money.js.map +1 -0
  341. package/dist/{dev/ProductPrice.js → node-prod/ProductPrice.cjs} +3 -3
  342. package/dist/{prod/ProductPrice.mjs.map → node-prod/ProductPrice.cjs.map} +1 -1
  343. package/dist/node-prod/ProductPrice.js +61 -0
  344. package/dist/node-prod/ProductPrice.js.map +1 -0
  345. package/dist/{dev/ProductProvider.js → node-prod/ProductProvider.cjs} +16 -16
  346. package/dist/{prod/ProductProvider.mjs.map → node-prod/ProductProvider.cjs.map} +1 -1
  347. package/dist/node-prod/ProductProvider.js +161 -0
  348. package/dist/node-prod/ProductProvider.js.map +1 -0
  349. package/dist/{prod/ShopPayButton.js → node-prod/ShopPayButton.cjs} +3 -3
  350. package/dist/{dev/ShopPayButton.mjs.map → node-prod/ShopPayButton.cjs.map} +1 -1
  351. package/dist/node-prod/ShopPayButton.js +64 -0
  352. package/dist/node-prod/ShopPayButton.js.map +1 -0
  353. package/dist/{dev/ShopifyProvider.js → node-prod/ShopifyProvider.cjs} +6 -6
  354. package/dist/{prod/ShopifyProvider.mjs.map → node-prod/ShopifyProvider.cjs.map} +1 -1
  355. package/dist/node-prod/ShopifyProvider.js +46 -0
  356. package/dist/node-prod/ShopifyProvider.js.map +1 -0
  357. package/dist/{dev/Video.js → node-prod/Video.cjs} +4 -4
  358. package/dist/{prod/Video.mjs.map → node-prod/Video.cjs.map} +1 -1
  359. package/dist/node-prod/Video.js +44 -0
  360. package/dist/node-prod/Video.js.map +1 -0
  361. package/dist/{dev/cart-constants.js → node-prod/cart-constants.cjs} +1 -1
  362. package/dist/{prod/cart-constants.mjs.map → node-prod/cart-constants.cjs.map} +1 -1
  363. package/dist/node-prod/cart-constants.js +17 -0
  364. package/dist/node-prod/cart-constants.js.map +1 -0
  365. package/dist/{prod/cart-hooks.js → node-prod/cart-hooks.cjs} +5 -5
  366. package/dist/{dev/cart-hooks.mjs.map → node-prod/cart-hooks.cjs.map} +1 -1
  367. package/dist/node-prod/cart-hooks.js +48 -0
  368. package/dist/node-prod/cart-hooks.js.map +1 -0
  369. package/dist/{prod/cart-queries.js → node-prod/cart-queries.cjs} +1 -1
  370. package/dist/{prod/cart-queries.mjs.map → node-prod/cart-queries.cjs.map} +1 -1
  371. package/dist/node-prod/cart-queries.js +114 -0
  372. package/dist/node-prod/cart-queries.js.map +1 -0
  373. package/dist/{prod/flatten-connection.js → node-prod/flatten-connection.cjs} +1 -1
  374. package/dist/{prod/flatten-connection.mjs.map → node-prod/flatten-connection.cjs.map} +1 -1
  375. package/dist/node-prod/flatten-connection.js +25 -0
  376. package/dist/node-prod/flatten-connection.js.map +1 -0
  377. package/dist/{prod/image-size.js → node-prod/image-size.cjs} +1 -1
  378. package/dist/{dev/image-size.mjs.map → node-prod/image-size.cjs.map} +1 -1
  379. package/dist/node-prod/image-size.js +80 -0
  380. package/dist/node-prod/image-size.js.map +1 -0
  381. package/dist/{dev/index.js → node-prod/index.cjs} +20 -20
  382. package/dist/node-prod/index.cjs.map +1 -0
  383. package/dist/node-prod/index.js +46 -0
  384. package/dist/node-prod/index.js.map +1 -0
  385. package/dist/{dev/load-script.js → node-prod/load-script.cjs} +4 -4
  386. package/dist/{prod/load-script.mjs.map → node-prod/load-script.cjs.map} +1 -1
  387. package/dist/node-prod/load-script.js +52 -0
  388. package/dist/node-prod/load-script.js.map +1 -0
  389. package/dist/{prod/metafield-parser.js → node-prod/metafield-parser.cjs} +3 -3
  390. package/dist/{prod/metafield-parser.mjs.map → node-prod/metafield-parser.cjs.map} +1 -1
  391. package/dist/node-prod/metafield-parser.js +114 -0
  392. package/dist/node-prod/metafield-parser.js.map +1 -0
  393. package/dist/{dev/storefront-api-constants.js → node-prod/storefront-api-constants.cjs} +1 -1
  394. package/dist/node-prod/storefront-api-constants.cjs.map +1 -0
  395. package/dist/node-prod/storefront-api-constants.js +5 -0
  396. package/dist/node-prod/storefront-api-constants.js.map +1 -0
  397. package/dist/{prod/storefront-client.js → node-prod/storefront-client.cjs} +2 -2
  398. package/dist/{prod/storefront-client.mjs.map → node-prod/storefront-client.cjs.map} +1 -1
  399. package/dist/node-prod/storefront-client.js +57 -0
  400. package/dist/node-prod/storefront-client.js.map +1 -0
  401. package/dist/{dev/useCartAPIStateMachine.js → node-prod/useCartAPIStateMachine.cjs} +15 -15
  402. package/dist/{dev/useCartAPIStateMachine.mjs.map → node-prod/useCartAPIStateMachine.cjs.map} +1 -1
  403. package/dist/node-prod/useCartAPIStateMachine.js +326 -0
  404. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -0
  405. package/dist/{prod/useCartActions.js → node-prod/useCartActions.cjs} +14 -14
  406. package/dist/{prod/useCartActions.mjs.map → node-prod/useCartActions.cjs.map} +1 -1
  407. package/dist/node-prod/useCartActions.js +123 -0
  408. package/dist/node-prod/useCartActions.js.map +1 -0
  409. package/dist/{dev/useMoney.js → node-prod/useMoney.cjs} +7 -7
  410. package/dist/{prod/useMoney.mjs.map → node-prod/useMoney.cjs.map} +1 -1
  411. package/dist/node-prod/useMoney.js +72 -0
  412. package/dist/node-prod/useMoney.js.map +1 -0
  413. package/package.json +35 -20
  414. package/dist/dev/_virtual/index.js +0 -5
  415. package/dist/dev/_virtual/index.mjs.map +0 -1
  416. package/dist/dev/_virtual/use-sync-external-store-shim.development.js +0 -5
  417. package/dist/dev/_virtual/use-sync-external-store-shim.development.mjs.map +0 -1
  418. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +0 -5
  419. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +0 -1
  420. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.mjs.map +0 -1
  421. package/dist/dev/_virtual/with-selector.development.js +0 -5
  422. package/dist/dev/_virtual/with-selector.development.mjs.map +0 -1
  423. package/dist/dev/_virtual/with-selector.js +0 -5
  424. package/dist/dev/_virtual/with-selector.mjs.map +0 -1
  425. package/dist/dev/_virtual/with-selector.production.min.js +0 -5
  426. package/dist/dev/_virtual/with-selector.production.min.mjs.map +0 -1
  427. package/dist/dev/index.js.map +0 -1
  428. package/dist/dev/index.mjs +0 -46
  429. package/dist/dev/index.mjs.map +0 -1
  430. package/dist/dev/node_modules/@xstate/fsm/es/index.js +0 -158
  431. package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +0 -1
  432. package/dist/dev/node_modules/@xstate/fsm/es/index.mjs.map +0 -1
  433. package/dist/dev/node_modules/@xstate/react/es/fsm.js +0 -94
  434. package/dist/dev/node_modules/@xstate/react/es/fsm.mjs.map +0 -1
  435. package/dist/dev/node_modules/@xstate/react/es/useConstant.js +0 -30
  436. package/dist/dev/node_modules/@xstate/react/es/useConstant.mjs.map +0 -1
  437. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -5
  438. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +0 -1
  439. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -107
  440. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +0 -1
  441. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -74
  442. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -1
  443. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +0 -1
  444. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -138
  445. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +0 -1
  446. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -60
  447. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +0 -1
  448. package/dist/dev/node_modules/use-sync-external-store/shim/index.js +0 -21
  449. package/dist/dev/node_modules/use-sync-external-store/shim/index.mjs.map +0 -1
  450. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +0 -12
  451. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +0 -1
  452. package/dist/dev/storefront-api-constants.mjs.map +0 -1
  453. package/dist/prod/_virtual/index.js +0 -5
  454. package/dist/prod/_virtual/index.mjs.map +0 -1
  455. package/dist/prod/_virtual/use-sync-external-store-shim.development.js +0 -5
  456. package/dist/prod/_virtual/use-sync-external-store-shim.development.mjs.map +0 -1
  457. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +0 -5
  458. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +0 -1
  459. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.mjs.map +0 -1
  460. package/dist/prod/_virtual/with-selector.development.js +0 -5
  461. package/dist/prod/_virtual/with-selector.development.mjs.map +0 -1
  462. package/dist/prod/_virtual/with-selector.js +0 -5
  463. package/dist/prod/_virtual/with-selector.mjs.map +0 -1
  464. package/dist/prod/_virtual/with-selector.production.min.js +0 -5
  465. package/dist/prod/_virtual/with-selector.production.min.mjs.map +0 -1
  466. package/dist/prod/index.js.map +0 -1
  467. package/dist/prod/index.mjs +0 -46
  468. package/dist/prod/index.mjs.map +0 -1
  469. package/dist/prod/node_modules/@xstate/fsm/es/index.js +0 -158
  470. package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +0 -1
  471. package/dist/prod/node_modules/@xstate/fsm/es/index.mjs.map +0 -1
  472. package/dist/prod/node_modules/@xstate/react/es/fsm.js +0 -94
  473. package/dist/prod/node_modules/@xstate/react/es/fsm.mjs.map +0 -1
  474. package/dist/prod/node_modules/@xstate/react/es/useConstant.js +0 -30
  475. package/dist/prod/node_modules/@xstate/react/es/useConstant.mjs.map +0 -1
  476. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -5
  477. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +0 -1
  478. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -107
  479. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +0 -1
  480. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -74
  481. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -1
  482. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +0 -1
  483. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -138
  484. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +0 -1
  485. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -60
  486. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +0 -1
  487. package/dist/prod/node_modules/use-sync-external-store/shim/index.js +0 -21
  488. package/dist/prod/node_modules/use-sync-external-store/shim/index.mjs.map +0 -1
  489. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +0 -12
  490. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +0 -1
  491. package/dist/prod/storefront-api-constants.mjs.map +0 -1
@@ -1 +1 @@
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","console","error","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","Error","maxWidth","finalSrcset","srcSet","internalImageSrcSet","altText","alt","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;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,KACRC;AATiB,GAUA;;AAChB,MAAA,CAACT,KAAKU,KAAK;AACPC,UAAAA,kBAAmB,kEACvBX,UAAKY,OAALZ,YAAW;AAKN;AACLa,cAAQC,MAAMH,eAAd;AAAA,IACD;AAEM,WAAA;AAAA,EACR;AAUK,QAAA;AAAA,IAACV,OAAOc;AAA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AmBxB,OAAO2B,KAAMC,UAASC,MAAMD,IAAD,CAA3B,GAA8C;AAC7D,UAAA,IAAId,MACP,8DAA6DD,KAD1D;AAAA,EAGP;AAED,MAAIiB,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,kBAAkBA,kBAAkBC,SAAS,IACrD;AACAF,eAAWC,kBAAkBE,OAAQP,CAASA,SAAAA,QAAQlC,KAA3C;AAAA,EACZ;AACK0C,QAAAA,eAAevC,SAASA,SAASwC;AACvC,SAAOL,SACJM,IACEV,CACE,SAAA,GAAEQ,aAAa;AAAA,IACdvB;AAAAA,IACAnB,OAAOkC;AAAAA,IAGPjC,QAAQ2B,OAAOS,OAAOH,IAAD,IAASE,cAAcT;AAAAA,IAC5CC;AAAAA,IACAC;AAAAA,EAAAA,CAPa,KAQTK,OAXL,EAaJW,KAAK,IAbD;AAcR;"}
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","console","error","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","Error","maxWidth","finalSrcset","srcSet","internalImageSrcSet","altText","alt","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;AAKN;AACLa,cAAQC,MAAMH,eAAd;AAAA,IACD;AAEM,WAAA;AAAA,EACR;AAUK,QAAA;AAAA,IAACV,OAAOc;AAAAA,IAAiBb,QAAQc;AAAAA,MACrCC,oCAA0B;AAAA,IACxBjB;AAAAA,IACAM;AAAAA,IACAY,cA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6DD,KAD1D;AAAA,EAGP;AAED,MAAIiB,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,IACdvB;AAAAA,IACAnB,OAAOkC;AAAAA,IAGPjC,QAAQ2B,OAAOS,OAAOH,IAAD,IAASE,cAAcT;AAAAA,IAC5CC;AAAAA,IACAC;AAAAA,EAAAA,CAPa,KAQTK,OAXL,EAaJW,KAAK,IAbD;AAcR;;"}
@@ -0,0 +1,99 @@
1
+ import { getShopifyImageDimensions, shopifyImageLoader, IMG_SRC_SET_SIZES, addImageSizeParametersToUrl } from "./image-size.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ function Image({
4
+ data,
5
+ width,
6
+ height,
7
+ loading,
8
+ loader = shopifyImageLoader,
9
+ loaderOptions,
10
+ widths,
11
+ decoding = "async",
12
+ ...rest
13
+ }) {
14
+ var _a, _b, _c, _d, _e, _f;
15
+ if (!data.url) {
16
+ const missingUrlError = `<Image/>: the 'data' prop requires the 'url' property. Image: ${(_a = data.id) != null ? _a : "no ID provided"}`;
17
+ {
18
+ console.error(missingUrlError);
19
+ }
20
+ return null;
21
+ }
22
+ const {
23
+ width: imgElementWidth,
24
+ height: imgElementHeight
25
+ } = getShopifyImageDimensions({
26
+ data,
27
+ loaderOptions,
28
+ elementProps: {
29
+ width,
30
+ height
31
+ }
32
+ });
33
+ let finalSrc = data.url;
34
+ if (loader) {
35
+ finalSrc = loader({
36
+ ...loaderOptions,
37
+ src: data.url,
38
+ width: imgElementWidth,
39
+ height: imgElementHeight
40
+ });
41
+ if (typeof finalSrc !== "string" || !finalSrc) {
42
+ throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(_b = data.id) != null ? _b : data.url}`);
43
+ }
44
+ }
45
+ const maxWidth = width && imgElementWidth && width < imgElementWidth ? width : imgElementWidth;
46
+ const finalSrcset = (_c = rest.srcSet) != null ? _c : internalImageSrcSet({
47
+ ...loaderOptions,
48
+ widths,
49
+ src: data.url,
50
+ width: maxWidth,
51
+ height: imgElementHeight,
52
+ loader
53
+ });
54
+ return /* @__PURE__ */ jsx("img", {
55
+ id: (_d = data.id) != null ? _d : "",
56
+ alt: (_f = (_e = data.altText) != null ? _e : rest.alt) != null ? _f : "",
57
+ loading: loading != null ? loading : "lazy",
58
+ ...rest,
59
+ src: finalSrc,
60
+ width: imgElementWidth != null ? imgElementWidth : void 0,
61
+ height: imgElementHeight != null ? imgElementHeight : void 0,
62
+ srcSet: finalSrcset,
63
+ decoding
64
+ });
65
+ }
66
+ function internalImageSrcSet({
67
+ src,
68
+ width,
69
+ crop,
70
+ scale,
71
+ widths,
72
+ loader,
73
+ height
74
+ }) {
75
+ const hasCustomWidths = widths && Array.isArray(widths);
76
+ if (hasCustomWidths && widths.some((size) => isNaN(size))) {
77
+ throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${src}`);
78
+ }
79
+ let aspectRatio = 1;
80
+ if (width && height) {
81
+ aspectRatio = Number(height) / Number(width);
82
+ }
83
+ let setSizes = hasCustomWidths ? widths : IMG_SRC_SET_SIZES;
84
+ if (!hasCustomWidths && width && width < IMG_SRC_SET_SIZES[IMG_SRC_SET_SIZES.length - 1]) {
85
+ setSizes = IMG_SRC_SET_SIZES.filter((size) => size <= width);
86
+ }
87
+ const srcGenerator = loader ? loader : addImageSizeParametersToUrl;
88
+ return setSizes.map((size) => `${srcGenerator({
89
+ src,
90
+ width: size,
91
+ height: crop ? Number(size) * aspectRatio : void 0,
92
+ crop,
93
+ scale
94
+ })} ${size}w`).join(", ");
95
+ }
96
+ export {
97
+ Image
98
+ };
99
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +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","console","error","imgElementWidth","imgElementHeight","getShopifyImageDimensions","elementProps","finalSrc","src","Error","maxWidth","finalSrcset","srcSet","internalImageSrcSet","altText","alt","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;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,KACRC;AATiB,GAUA;;AAChB,MAAA,CAACT,KAAKU,KAAK;AACPC,UAAAA,kBAAmB,kEACvBX,UAAKY,OAALZ,YAAW;AAKN;AACLa,cAAQC,MAAMH,eAAd;AAAA,IACD;AAEM,WAAA;AAAA,EACR;AAUK,QAAA;AAAA,IAACV,OAAOc;AAAAA,IAAiBb,QAAQc;AAAAA,MACrCC,0BAA0B;AAAA,IACxBjB;AAAAA,IACAM;AAAAA,IACAY,cAAc;AAAA,MACZjB;AAAAA,MACAC;AAAAA,IAFY;AAAA,EAAA,CAHS;AAiB3B,MAAIiB,WAAWnB,KAAKU;AAEpB,MAAIN,QAAQ;AACVe,eAAWf,OAAO;AAAA,MAChB,GAAGE;AAAAA,MACHc,KAAKpB,KAAKU;AAAAA,MACVT,OAAOc;AAAAA,MACPb,QAAQc;AAAAA,IAAAA,CAJO;AAMjB,QAAI,OAAOG,aAAa,YAAY,CAACA,UAAU;AAC7C,YAAM,IAAIE,MACP,6DACCrB,UAAKY,OAALZ,YAAWA,KAAKU,KAFd;AAAA,IAKP;AAAA,EACF;AAID,QAAMY,WACJrB,SAASc,mBAAmBd,QAAQc,kBAChCd,QACAc;AACAQ,QAAAA,eACJd,UAAKe,WAALf,YACAgB,oBAAoB;AAAA,IAClB,GAAGnB;AAAAA,IACHC;AAAAA,IACAa,KAAKpB,KAAKU;AAAAA,IACVT,OAAOqB;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,KAAK,IAbD;AAcR;"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
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");
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
7
  const jsxRuntime = require("react/jsx-runtime");
8
8
  function MediaFile({
9
9
  data,
@@ -56,4 +56,4 @@ function MediaFile({
56
56
  }
57
57
  }
58
58
  exports.MediaFile = MediaFile;
59
- //# sourceMappingURL=MediaFile.js.map
59
+ //# sourceMappingURL=MediaFile.cjs.map
@@ -1 +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","console","warn","video","externalVideo","modelViewer","typenameMissingMessage","error"],"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;AAGd;AACLC,kBAAQC,KAAKF,WAAb;AACO,iBAAA;AAAA,QACR;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,6CAAcO;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,iCACG,eAAD;AAAA,QAAA,GACMN;AAAAA,QADN,GAEMD,6CAAcQ;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,iCAEG;WACKP;AAAAA,QADN,GAEMD,6CAAcS;AAAAA,QAClB;AAAA,MAAA,CAHF;AAAA,IAMH;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AAGzB;AACLL,gBAAQM,MAAMD,sBAAd;AACO,eAAA;AAAA,MACR;AAAA,IACF;AAAA,EApDH;AAsDD;"}
1
+ {"version":3,"file":"MediaFile.cjs","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","console","warn","Image","Video","video","ExternalVideo","externalVideo","ModelViewer","modelViewer","typenameMissingMessage","error"],"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;AAGd;AACLC,kBAAQC,KAAKF,WAAb;AACO,iBAAA;AAAA,QACR;AAAA,MACF;AAED,4CACGG,MAAAA,OAAD;AAAA,QAAA,GACMN;AAAAA,QADN,GAEMD,6CAAcG;AAAAA,QAClB,MAAMJ,KAAKI;AAAAA,MAAAA,CAJf;AAAA,IAOD;AAAA,IACD,KAAK,SAAS;AACZ,4CACGK,MAAAA,OAAD;AAAA,QAAA,GAAWP;AAAAA,QAAX,GAAiCD,6CAAcS;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,4CACGC,cAAAA,eAAD;AAAA,QAAA,GACMT;AAAAA,QADN,GAEMD,6CAAcW;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,4CAEGC,YAAAA;WACKX;AAAAA,QADN,GAEMD,6CAAca;AAAAA,QAClB;AAAA,MAAA,CAHF;AAAA,IAMH;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AAGzB;AACLT,gBAAQU,MAAMD,sBAAd;AACO,eAAA;AAAA,MACR;AAAA,IACF;AAAA,EApDH;AAsDD;;"}
@@ -0,0 +1,59 @@
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";
6
+ function MediaFile({
7
+ data,
8
+ mediaOptions,
9
+ ...passthroughProps
10
+ }) {
11
+ switch (data.__typename) {
12
+ case "MediaImage": {
13
+ if (!data.image) {
14
+ const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;
15
+ {
16
+ console.warn(noDataImage);
17
+ return null;
18
+ }
19
+ }
20
+ return /* @__PURE__ */ jsx(Image, {
21
+ ...passthroughProps,
22
+ ...mediaOptions == null ? void 0 : mediaOptions.image,
23
+ data: data.image
24
+ });
25
+ }
26
+ case "Video": {
27
+ return /* @__PURE__ */ jsx(Video, {
28
+ ...passthroughProps,
29
+ ...mediaOptions == null ? void 0 : mediaOptions.video,
30
+ data
31
+ });
32
+ }
33
+ case "ExternalVideo": {
34
+ return /* @__PURE__ */ jsx(ExternalVideo, {
35
+ ...passthroughProps,
36
+ ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
37
+ data
38
+ });
39
+ }
40
+ case "Model3d": {
41
+ return /* @__PURE__ */ jsx(ModelViewer, {
42
+ ...passthroughProps,
43
+ ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
44
+ data
45
+ });
46
+ }
47
+ default: {
48
+ 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`;
49
+ {
50
+ console.error(typenameMissingMessage);
51
+ return null;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ export {
57
+ MediaFile
58
+ };
59
+ //# sourceMappingURL=MediaFile.js.map
@@ -0,0 +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';\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","console","warn","video","externalVideo","modelViewer","typenameMissingMessage","error"],"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;AAGd;AACLC,kBAAQC,KAAKF,WAAb;AACO,iBAAA;AAAA,QACR;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,6CAAcO;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,iCACG,eAAD;AAAA,QAAA,GACMN;AAAAA,QADN,GAEMD,6CAAcQ;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,iCAEG;WACKP;AAAAA,QADN,GAEMD,6CAAcS;AAAAA,QAClB;AAAA,MAAA,CAHF;AAAA,IAMH;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AAGzB;AACLL,gBAAQM,MAAMD,sBAAd;AACO,eAAA;AAAA,MACR;AAAA,IACF;AAAA,EApDH;AAsDD;"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
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");
3
+ const react = require("react");
4
+ const ShopifyProvider = require("./ShopifyProvider.cjs");
5
+ const Image = require("./Image.cjs");
6
+ const Video = require("./Video.cjs");
7
+ const flattenConnection = require("./flatten-connection.cjs");
8
8
  const jsxRuntime = require("react/jsx-runtime");
9
9
  function Metafield(props) {
10
10
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -16,7 +16,7 @@ function Metafield(props) {
16
16
  const {
17
17
  locale
18
18
  } = ShopifyProvider.useShop();
19
- const parsedMetafield = require$$0.useMemo(() => parseMetafield(data), [data]);
19
+ const parsedMetafield = react.useMemo(() => parseMetafield(data), [data]);
20
20
  if (!parsedMetafield) {
21
21
  const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;
22
22
  {
@@ -285,4 +285,4 @@ exports.getMeasurementAsString = getMeasurementAsString;
285
285
  exports.parseJSON = parseJSON;
286
286
  exports.parseMetafield = parseMetafield;
287
287
  exports.parseMetafieldValue = parseMetafieldValue;
288
- //# sourceMappingURL=Metafield.js.map
288
+ //# sourceMappingURL=Metafield.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Metafield.mjs","sources":["../../src/Metafield.tsx"],"sourcesContent":["import {type ElementType, useMemo, type ComponentPropsWithoutRef} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {Image} from './Image.js';\nimport type {\n MediaImage,\n Page,\n ProductVariant,\n Product,\n GenericFile,\n Video as VideoType,\n Metafield as MetafieldType,\n} from './storefront-api-types.js';\nimport {Video} from './Video.js';\nimport {flattenConnection} from './flatten-connection.js';\nimport type {PartialDeep, JsonValue} from 'type-fest';\n\ninterface BaseProps<ComponentGeneric extends ElementType> {\n /** An object with fields that correspond to the Storefront API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield). */\n data: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null;\n /** An HTML tag or React component to be rendered as the base element wrapper. The default value varies depending on [metafield.type](https://shopify.dev/apps/metafields/types). */\n as?: ComponentGeneric;\n}\n\nexport type MetafieldProps<ComponentGeneric extends ElementType> =\n ComponentPropsWithoutRef<ComponentGeneric> & BaseProps<ComponentGeneric>;\n\n/**\n * The `Metafield` component renders the value of a Storefront\n * API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield).\n * Relies on the `locale` property of the `useShop()` hook, so it must be a desendent of `<ShopifyProvider/>`\n *\n * Renders a smart default of the Metafield's `value`. For more information, refer to the [Default output](#default-output) section.\n */\nexport function Metafield<ComponentGeneric extends ElementType>(\n props: MetafieldProps<ComponentGeneric>\n) {\n const {data, as, ...passthroughProps} = props;\n const {locale} = useShop();\n\n const parsedMetafield = useMemo(() => parseMetafield(data), [data]);\n\n if (!parsedMetafield) {\n const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noDataPropWarning);\n } else {\n console.warn(noDataPropWarning);\n }\n return null;\n }\n\n if (parsedMetafield.value === null || parsedMetafield.value === undefined) {\n const noValueWarning = `<Metafield/>: No metafield value for metafield ${\n parsedMetafield.id ?? parsedMetafield.key\n }. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noValueWarning);\n } else {\n console.warn(noValueWarning);\n }\n return null;\n }\n\n switch (parsedMetafield.type) {\n case 'date': {\n const Wrapper = as ?? 'time';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Date).toLocaleDateString(locale)}\n </Wrapper>\n );\n }\n case 'date_time': {\n const Wrapper = as ?? 'time';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Date).toLocaleString(locale)}\n </Wrapper>\n );\n }\n case 'weight':\n case 'dimension':\n case 'volume': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {getMeasurementAsString(parsedMetafield.value as Measurement, locale)}\n </Wrapper>\n );\n }\n case 'rating': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Rating).value}\n </Wrapper>\n );\n }\n case 'single_line_text_field': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper\n {...passthroughProps}\n dangerouslySetInnerHTML={{__html: parsedMetafield.value as string}}\n />\n );\n }\n case 'multi_line_text_field': {\n const Wrapper = as ?? 'div';\n return (\n <Wrapper\n {...passthroughProps}\n dangerouslySetInnerHTML={{\n __html: (parsedMetafield.value as string).split('\\n').join('<br/>'),\n }}\n />\n );\n }\n case 'url': {\n const protocolLessUrl = new URL(parsedMetafield.value as string);\n return (\n <a\n href={protocolLessUrl.href.replace(protocolLessUrl.protocol, '')}\n {...passthroughProps}\n >\n {parsedMetafield.value as string}\n </a>\n );\n }\n case 'json': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {JSON.stringify(parsedMetafield.value)}\n </Wrapper>\n );\n }\n case 'product_reference':\n case 'variant_reference':\n case 'page_reference': {\n const Wrapper = as ?? 'span';\n const ref = parsedMetafield.reference as Page | ProductVariant | Product;\n return (\n <Wrapper {...passthroughProps}>{ref?.title ?? ref?.id ?? ''}</Wrapper>\n );\n }\n case 'list.single_line_text_field': {\n const Wrapper = as ?? 'ul';\n\n const refArray = parsedMetafield.references\n ? (flattenConnection(parsedMetafield.references) as string[])\n : [];\n return (\n <Wrapper {...passthroughProps}>\n {refArray.map((ref, index) => (\n // there's no unique way to identify these strings, so we do our best by combining the string with the index for the key\n // eslint-disable-next-line react/no-array-index-key\n <li key={`${ref ?? ''}-${index}`}>{ref}</li>\n ))}\n </Wrapper>\n );\n }\n case 'file_reference': {\n if (parsedMetafield.reference?.__typename === 'MediaImage') {\n const ref = parsedMetafield.reference as MediaImage;\n return ref.image ? (\n <Image data={ref.image} {...passthroughProps} />\n ) : null;\n } else if (parsedMetafield.reference?.__typename === 'GenericFile') {\n const ref = parsedMetafield.reference as GenericFile;\n return ref.previewImage ? (\n <a href={parsedMetafield.reference?.url ?? ''} {...passthroughProps}>\n <Image data={ref.previewImage} />\n </a>\n ) : null;\n } else if (parsedMetafield.reference?.__typename === 'Video') {\n const ref = parsedMetafield.reference as VideoType;\n return <Video {...passthroughProps} data={ref} />;\n }\n }\n }\n\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>{parsedMetafield.value?.toString()}</Wrapper>\n );\n}\n\n/**\n * The `parseMetafield` utility transforms a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield)\n * into a new object whose `values` have been parsed according to the metafield `type`.\n * If the metafield is `null`, then it returns `null` back.\n *\n * Note that `parseMetafield()` will have a breaking change in a future version; it will change to behave like `metafieldParser()`.\n */\nexport function parseMetafield(\n /** A [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield) or null */\n metafield: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null\n): PartialDeep<ParsedMetafield, {recurseIntoArrays: true}> | null {\n if (__HYDROGEN_DEV__) {\n console.info(\n `'parseMetafield()' will have a breaking change in a future version; its behavior will match that of 'metafieldParser()'`\n );\n }\n\n if (!metafield) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `'parseMetafield' was not passed any value for the 'metafield' argument`\n );\n }\n return null;\n }\n if (\n __HYDROGEN_DEV__ &&\n (metafield.value === null || metafield.value === undefined)\n ) {\n console.warn(\n `'parseMetafield()' was passed ${metafield.value} for 'metafield.value'`\n );\n }\n\n return {\n ...metafield,\n value: parseMetafieldValue(metafield),\n };\n}\n\n/**\n * The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.\n * @deprecated `parseMetafieldValue()` is unsupported and will be removed in a future version.\n */\nexport function parseMetafieldValue(\n metafield: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null\n): ParsedMetafield['value'] {\n if (__HYDROGEN_DEV__) {\n console.info(`'parseMetafieldValue()' will be removed in a future version`);\n }\n\n if (!metafield) {\n return null;\n }\n\n if (metafield.value === null || metafield.value === undefined) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `'parseMetafieldValue()' was passed ${metafield.value} for 'metafield.value'`\n );\n }\n return metafield.value;\n }\n\n switch (metafield.type) {\n case 'boolean':\n return metafield.value === 'true';\n case 'number_integer':\n return parseInt(metafield.value);\n case 'number_decimal':\n return parseFloat(metafield.value);\n case 'date':\n case 'date_time':\n return new Date(metafield.value);\n case 'json':\n case 'weight':\n case 'dimension':\n case 'volume':\n case 'rating':\n return parseJSON(metafield.value);\n case 'color':\n case 'single_line_text_field':\n case 'multi_line_text_field':\n case 'product_reference':\n case 'page_reference':\n case 'variant_reference':\n case 'file_reference':\n case 'url':\n default:\n return metafield.value;\n }\n}\n\n/**\n * Parses a JSON string while preventing prototype injection attacks.\n */\nexport function parseJSON(json: string) {\n if (String(json).includes('__proto__')) {\n return JSON.parse(json, (k, v) => {\n if (k !== '__proto__') return v;\n });\n }\n\n return JSON.parse(json);\n}\n\nconst UNIT_MAPPING: Record<string, string> = {\n // Dimension\n mm: 'millimeter',\n cm: 'centimeter',\n m: 'meter',\n in: 'inch',\n ft: 'foot',\n yd: 'yard',\n // Volume\n ml: 'milliliter',\n l: 'liter',\n us_fl_oz: 'fluid-ounce',\n us_gal: 'gallon',\n // Weight\n kg: 'kilogram',\n g: 'gram',\n lb: 'pound',\n oz: 'ounce',\n};\n\nexport function getMeasurementAsString(\n measurement: Measurement,\n locale = 'en-us',\n options: Intl.NumberFormatOptions = {}\n) {\n let measure: Measurement = {\n value: measurement.value,\n unit: UNIT_MAPPING[measurement.unit],\n };\n\n if (measure.unit == null) {\n measure = convertToSupportedUnit(measurement.value, measurement.unit);\n }\n\n return new Intl.NumberFormat(locale, {\n ...options,\n unit: measure.unit,\n style: 'unit',\n }).format(measure.value);\n}\n\nfunction convertToSupportedUnit(value: number, unit: string): Measurement {\n switch (unit) {\n case 'cl':\n return {\n value: value / 1000,\n unit: 'liter',\n };\n case 'm3':\n return {\n value: value * 1000,\n unit: 'liter',\n };\n case 'us_pt':\n return {\n value: value * 0.125,\n unit: 'gallon',\n };\n case 'us_qt':\n return {\n value: value * 0.5,\n unit: 'gallon',\n };\n case 'us_oz':\n return {\n value: value / 128,\n unit: 'gallon',\n };\n case 'imp_pt':\n return {\n value: value / 6.661, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_qt':\n return {\n value: value / 3.331, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_gal':\n return {\n value: value / 1.201, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_fl_oz':\n return {\n value: value * 0.96076, // approximate conversion\n unit: 'fluid-ounce',\n };\n default:\n throw new Error(`Unit not supported: ${unit}`);\n }\n}\n\ntype ParsedMetafield = Omit<\n PartialDeep<MetafieldType, {recurseIntoArrays: true}>,\n 'value'\n> & {\n value?: string | number | boolean | JsonValue | Date | Rating | Measurement;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n\ninterface Measurement {\n unit: string;\n value: number;\n}\n"],"names":["Metafield","props","data","as","passthroughProps","locale","useShop","parsedMetafield","useMemo","parseMetafield","noDataPropWarning","console","warn","value","undefined","noValueWarning","id","key","type","Wrapper","toLocaleDateString","toLocaleString","getMeasurementAsString","__html","split","join","protocolLessUrl","URL","href","replace","protocol","JSON","stringify","ref","reference","title","refArray","references","flattenConnection","map","index","__typename","image","_jsx","previewImage","url","toString","metafield","parseMetafieldValue","parseInt","parseFloat","Date","parseJSON","json","String","includes","parse","k","v","UNIT_MAPPING","mm","cm","m","in","ft","yd","ml","l","us_fl_oz","us_gal","kg","g","lb","oz","measurement","options","measure","unit","convertToSupportedUnit","Intl","NumberFormat","style","format","Error"],"mappings":";;;;;;AAiCO,SAASA,UACdC,OACA;;AACM,QAAA;AAAA,IAACC;AAAAA,IAAMC;AAAAA,OAAOC;AAAAA,EAAoBH,IAAAA;AAClC,QAAA;AAAA,IAACI;AAAAA,MAAUC,QAAjB;AAEMC,QAAAA,kBAAkBC,QAAQ,MAAMC,eAAeP,IAAD,GAAQ,CAACA,IAAD,CAA7B;AAE/B,MAAI,CAACK,iBAAiB;AACpB,UAAMG,oBAAqB;AAGpB;AACLC,cAAQC,KAAKF,iBAAb;AAAA,IACD;AACM,WAAA;AAAA,EACR;AAED,MAAIH,gBAAgBM,UAAU,QAAQN,gBAAgBM,UAAUC,QAAW;AACzE,UAAMC,iBAAkB,mDACtBR,qBAAgBS,OAAhBT,YAAsBA,gBAAgBU;AAIjC;AACLN,cAAQC,KAAKG,cAAb;AAAA,IACD;AACM,WAAA;AAAA,EACR;AAED,UAAQR,gBAAgBW,MAAxB;AAAA,IACE,KAAK,QAAQ;AACX,YAAMC,WAAUhB,kBAAM;AACtB,iCACGgB,UAAD;AAAA,QAAA,GAAaf;AAAAA,QAAb,UACIG,gBAAgBM,MAAeO,mBAAmBf,MAAnD;AAAA,MAAA,CAFL;AAAA,IAKD;AAAA,IACD,KAAK,aAAa;AAChB,YAAMc,WAAUhB,kBAAM;AACtB,iCACGgB,UAAD;AAAA,QAAA,GAAaf;AAAAA,QAAb,UACIG,gBAAgBM,MAAeQ,eAAehB,MAA/C;AAAA,MAAA,CAFL;AAAA,IAKD;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,UAAU;AACb,YAAMc,WAAUhB,kBAAM;AACtB,iCACGgB,UAAD;AAAA,QAAA,GAAaf;AAAAA,QAAb,UACGkB,uBAAuBf,gBAAgBM,OAAsBR,MAAvC;AAAA,MAAA,CAF3B;AAAA,IAKD;AAAA,IACD,KAAK,UAAU;AACb,YAAMc,WAAUhB,kBAAM;A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EV,KAAK;AACI,aAAA;AAAA,QACLhE,OAAOA,QAAQ;AAAA,QACfgE,MAAM;AAAA,MAAA;AAAA,IAEV,KAAK;AACI,aAAA;AAAA,QACLhE,OAAOA,QAAQ;AAAA,QACfgE,MAAM;AAAA,MAAA;AAAA,IAEV,KAAK;AACI,aAAA;AAAA,QACLhE,OAAOA,QAAQ;AAAA,QACfgE,MAAM;AAAA,MAAA;AAAA,IAEV;AACQ,YAAA,IAAIM,MAAO,uBAAsBN,MAAjC;AAAA,EA/CV;AAiDD;"}
1
+ {"version":3,"file":"Metafield.cjs","sources":["../../src/Metafield.tsx"],"sourcesContent":["import {type ElementType, useMemo, type ComponentPropsWithoutRef} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {Image} from './Image.js';\nimport type {\n MediaImage,\n Page,\n ProductVariant,\n Product,\n GenericFile,\n Video as VideoType,\n Metafield as MetafieldType,\n} from './storefront-api-types.js';\nimport {Video} from './Video.js';\nimport {flattenConnection} from './flatten-connection.js';\nimport type {PartialDeep, JsonValue} from 'type-fest';\n\ninterface BaseProps<ComponentGeneric extends ElementType> {\n /** An object with fields that correspond to the Storefront API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield). */\n data: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null;\n /** An HTML tag or React component to be rendered as the base element wrapper. The default value varies depending on [metafield.type](https://shopify.dev/apps/metafields/types). */\n as?: ComponentGeneric;\n}\n\nexport type MetafieldProps<ComponentGeneric extends ElementType> =\n ComponentPropsWithoutRef<ComponentGeneric> & BaseProps<ComponentGeneric>;\n\n/**\n * The `Metafield` component renders the value of a Storefront\n * API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield).\n * Relies on the `locale` property of the `useShop()` hook, so it must be a desendent of `<ShopifyProvider/>`\n *\n * Renders a smart default of the Metafield's `value`. For more information, refer to the [Default output](#default-output) section.\n */\nexport function Metafield<ComponentGeneric extends ElementType>(\n props: MetafieldProps<ComponentGeneric>\n) {\n const {data, as, ...passthroughProps} = props;\n const {locale} = useShop();\n\n const parsedMetafield = useMemo(() => parseMetafield(data), [data]);\n\n if (!parsedMetafield) {\n const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noDataPropWarning);\n } else {\n console.warn(noDataPropWarning);\n }\n return null;\n }\n\n if (parsedMetafield.value === null || parsedMetafield.value === undefined) {\n const noValueWarning = `<Metafield/>: No metafield value for metafield ${\n parsedMetafield.id ?? parsedMetafield.key\n }. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noValueWarning);\n } else {\n console.warn(noValueWarning);\n }\n return null;\n }\n\n switch (parsedMetafield.type) {\n case 'date': {\n const Wrapper = as ?? 'time';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Date).toLocaleDateString(locale)}\n </Wrapper>\n );\n }\n case 'date_time': {\n const Wrapper = as ?? 'time';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Date).toLocaleString(locale)}\n </Wrapper>\n );\n }\n case 'weight':\n case 'dimension':\n case 'volume': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {getMeasurementAsString(parsedMetafield.value as Measurement, locale)}\n </Wrapper>\n );\n }\n case 'rating': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Rating).value}\n </Wrapper>\n );\n }\n case 'single_line_text_field': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper\n {...passthroughProps}\n dangerouslySetInnerHTML={{__html: parsedMetafield.value as string}}\n />\n );\n }\n case 'multi_line_text_field': {\n const Wrapper = as ?? 'div';\n return (\n <Wrapper\n {...passthroughProps}\n dangerouslySetInnerHTML={{\n __html: (parsedMetafield.value as string).split('\\n').join('<br/>'),\n }}\n />\n );\n }\n case 'url': {\n const protocolLessUrl = new URL(parsedMetafield.value as string);\n return (\n <a\n href={protocolLessUrl.href.replace(protocolLessUrl.protocol, '')}\n {...passthroughProps}\n >\n {parsedMetafield.value as string}\n </a>\n );\n }\n case 'json': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {JSON.stringify(parsedMetafield.value)}\n </Wrapper>\n );\n }\n case 'product_reference':\n case 'variant_reference':\n case 'page_reference': {\n const Wrapper = as ?? 'span';\n const ref = parsedMetafield.reference as Page | ProductVariant | Product;\n return (\n <Wrapper {...passthroughProps}>{ref?.title ?? ref?.id ?? ''}</Wrapper>\n );\n }\n case 'list.single_line_text_field': {\n const Wrapper = as ?? 'ul';\n\n const refArray = parsedMetafield.references\n ? (flattenConnection(parsedMetafield.references) as string[])\n : [];\n return (\n <Wrapper {...passthroughProps}>\n {refArray.map((ref, index) => (\n // there's no unique way to identify these strings, so we do our best by combining the string with the index for the key\n // eslint-disable-next-line react/no-array-index-key\n <li key={`${ref ?? ''}-${index}`}>{ref}</li>\n ))}\n </Wrapper>\n );\n }\n case 'file_reference': {\n if (parsedMetafield.reference?.__typename === 'MediaImage') {\n const ref = parsedMetafield.reference as MediaImage;\n return ref.image ? (\n <Image data={ref.image} {...passthroughProps} />\n ) : null;\n } else if (parsedMetafield.reference?.__typename === 'GenericFile') {\n const ref = parsedMetafield.reference as GenericFile;\n return ref.previewImage ? (\n <a href={parsedMetafield.reference?.url ?? ''} {...passthroughProps}>\n <Image data={ref.previewImage} />\n </a>\n ) : null;\n } else if (parsedMetafield.reference?.__typename === 'Video') {\n const ref = parsedMetafield.reference as VideoType;\n return <Video {...passthroughProps} data={ref} />;\n }\n }\n }\n\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>{parsedMetafield.value?.toString()}</Wrapper>\n );\n}\n\n/**\n * The `parseMetafield` utility transforms a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield)\n * into a new object whose `values` have been parsed according to the metafield `type`.\n * If the metafield is `null`, then it returns `null` back.\n *\n * Note that `parseMetafield()` will have a breaking change in a future version; it will change to behave like `metafieldParser()`.\n */\nexport function parseMetafield(\n /** A [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield) or null */\n metafield: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null\n): PartialDeep<ParsedMetafield, {recurseIntoArrays: true}> | null {\n if (__HYDROGEN_DEV__) {\n console.info(\n `'parseMetafield()' will have a breaking change in a future version; its behavior will match that of 'metafieldParser()'`\n );\n }\n\n if (!metafield) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `'parseMetafield' was not passed any value for the 'metafield' argument`\n );\n }\n return null;\n }\n if (\n __HYDROGEN_DEV__ &&\n (metafield.value === null || metafield.value === undefined)\n ) {\n console.warn(\n `'parseMetafield()' was passed ${metafield.value} for 'metafield.value'`\n );\n }\n\n return {\n ...metafield,\n value: parseMetafieldValue(metafield),\n };\n}\n\n/**\n * The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.\n * @deprecated `parseMetafieldValue()` is unsupported and will be removed in a future version.\n */\nexport function parseMetafieldValue(\n metafield: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null\n): ParsedMetafield['value'] {\n if (__HYDROGEN_DEV__) {\n console.info(`'parseMetafieldValue()' will be removed in a future version`);\n }\n\n if (!metafield) {\n return null;\n }\n\n if (metafield.value === null || metafield.value === undefined) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `'parseMetafieldValue()' was passed ${metafield.value} for 'metafield.value'`\n );\n }\n return metafield.value;\n }\n\n switch (metafield.type) {\n case 'boolean':\n return metafield.value === 'true';\n case 'number_integer':\n return parseInt(metafield.value);\n case 'number_decimal':\n return parseFloat(metafield.value);\n case 'date':\n case 'date_time':\n return new Date(metafield.value);\n case 'json':\n case 'weight':\n case 'dimension':\n case 'volume':\n case 'rating':\n return parseJSON(metafield.value);\n case 'color':\n case 'single_line_text_field':\n case 'multi_line_text_field':\n case 'product_reference':\n case 'page_reference':\n case 'variant_reference':\n case 'file_reference':\n case 'url':\n default:\n return metafield.value;\n }\n}\n\n/**\n * Parses a JSON string while preventing prototype injection attacks.\n */\nexport function parseJSON(json: string) {\n if (String(json).includes('__proto__')) {\n return JSON.parse(json, (k, v) => {\n if (k !== '__proto__') return v;\n });\n }\n\n return JSON.parse(json);\n}\n\nconst UNIT_MAPPING: Record<string, string> = {\n // Dimension\n mm: 'millimeter',\n cm: 'centimeter',\n m: 'meter',\n in: 'inch',\n ft: 'foot',\n yd: 'yard',\n // Volume\n ml: 'milliliter',\n l: 'liter',\n us_fl_oz: 'fluid-ounce',\n us_gal: 'gallon',\n // Weight\n kg: 'kilogram',\n g: 'gram',\n lb: 'pound',\n oz: 'ounce',\n};\n\nexport function getMeasurementAsString(\n measurement: Measurement,\n locale = 'en-us',\n options: Intl.NumberFormatOptions = {}\n) {\n let measure: Measurement = {\n value: measurement.value,\n unit: UNIT_MAPPING[measurement.unit],\n };\n\n if (measure.unit == null) {\n measure = convertToSupportedUnit(measurement.value, measurement.unit);\n }\n\n return new Intl.NumberFormat(locale, {\n ...options,\n unit: measure.unit,\n style: 'unit',\n }).format(measure.value);\n}\n\nfunction convertToSupportedUnit(value: number, unit: string): Measurement {\n switch (unit) {\n case 'cl':\n return {\n value: value / 1000,\n unit: 'liter',\n };\n case 'm3':\n return {\n value: value * 1000,\n unit: 'liter',\n };\n case 'us_pt':\n return {\n value: value * 0.125,\n unit: 'gallon',\n };\n case 'us_qt':\n return {\n value: value * 0.5,\n unit: 'gallon',\n };\n case 'us_oz':\n return {\n value: value / 128,\n unit: 'gallon',\n };\n case 'imp_pt':\n return {\n value: value / 6.661, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_qt':\n return {\n value: value / 3.331, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_gal':\n return {\n value: value / 1.201, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_fl_oz':\n return {\n value: value * 0.96076, // approximate conversion\n unit: 'fluid-ounce',\n };\n default:\n throw new Error(`Unit not supported: ${unit}`);\n }\n}\n\ntype ParsedMetafield = Omit<\n PartialDeep<MetafieldType, {recurseIntoArrays: true}>,\n 'value'\n> & {\n value?: string | number | boolean | JsonValue | Date | Rating | Measurement;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n\ninterface Measurement {\n unit: string;\n value: number;\n}\n"],"names":["Metafield","props","data","as","passthroughProps","locale","useShop","parsedMetafield","useMemo","parseMetafield","noDataPropWarning","console","warn","value","undefined","noValueWarning","id","key","type","Wrapper","toLocaleDateString","toLocaleString","getMeasurementAsString","__html","split","join","protocolLessUrl","URL","href","replace","protocol","JSON","stringify","ref","reference","title","refArray","references","flattenConnection","map","index","__typename","image","_jsx","Image","previewImage","url","Video","toString","metafield","parseMetafieldValue","parseInt","parseFloat","Date","parseJSON","json","String","includes","parse","k","v","UNIT_MAPPING","mm","cm","m","in","ft","yd","ml","l","us_fl_oz","us_gal","kg","g","lb","oz","measurement","options","measure","unit","convertToSupportedUnit","Intl","NumberFormat","style","format","Error"],"mappings":";;;;;;;;AAiCO,SAASA,UACdC,OACA;;AACM,QAAA;AAAA,IAACC;AAAAA,IAAMC;AAAAA,OAAOC;AAAAA,EAAoBH,IAAAA;AAClC,QAAA;AAAA,IAACI;AAAAA,MAAUC,gBAAjB,QAAA;AAEMC,QAAAA,kBAAkBC,MAAAA,QAAQ,MAAMC,eAAeP,IAAD,GAAQ,CAACA,IAAD,CAA7B;AAE/B,MAAI,CAACK,iBAAiB;AACpB,UAAMG,oBAAqB;AAGpB;AACLC,cAAQC,KAAKF,iBAAb;AAAA,IACD;AACM,WAAA;AAAA,EACR;AAED,MAAIH,gBAAgBM,UAAU,QAAQN,gBAAgBM,UAAUC,QAAW;AACzE,UAAMC,iBAAkB,mDACtBR,qBAAgBS,OAAhBT,YAAsBA,gBAAgBU;AAIjC;AACLN,cAAQC,KAAKG,cAAb;AAAA,IACD;AAC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