@shopify/hydrogen-react 2022.10.2 → 2022.10.3

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 (591) hide show
  1. package/README.md +49 -0
  2. package/dist/{dev → browser-dev}/AddToCartButton.mjs +0 -0
  3. package/dist/browser-dev/AddToCartButton.mjs.map +1 -0
  4. package/dist/{dev → browser-dev}/BaseButton.mjs +0 -0
  5. package/dist/{dev → browser-dev}/BaseButton.mjs.map +0 -0
  6. package/dist/{dev → browser-dev}/BuyNowButton.mjs +0 -0
  7. package/dist/{dev → browser-dev}/BuyNowButton.mjs.map +0 -0
  8. package/dist/{dev → browser-dev}/CartCheckoutButton.mjs +0 -0
  9. package/dist/{dev → browser-dev}/CartCheckoutButton.mjs.map +0 -0
  10. package/dist/{dev → browser-dev}/CartProvider.mjs +0 -0
  11. package/dist/{dev → browser-dev}/CartProvider.mjs.map +0 -0
  12. package/dist/{dev → browser-dev}/ExternalVideo.mjs +0 -0
  13. package/dist/{dev → browser-dev}/ExternalVideo.mjs.map +0 -0
  14. package/dist/{dev → browser-dev}/Image.mjs +0 -0
  15. package/dist/{dev → browser-dev}/Image.mjs.map +0 -0
  16. package/dist/{dev → browser-dev}/MediaFile.mjs +0 -0
  17. package/dist/{dev → browser-dev}/MediaFile.mjs.map +0 -0
  18. package/dist/{dev → browser-dev}/Metafield.mjs +0 -0
  19. package/dist/{dev → browser-dev}/Metafield.mjs.map +0 -0
  20. package/dist/{dev → browser-dev}/ModelViewer.mjs +0 -0
  21. package/dist/{dev → browser-dev}/ModelViewer.mjs.map +0 -0
  22. package/dist/{dev → browser-dev}/Money.mjs +0 -0
  23. package/dist/{dev → browser-dev}/Money.mjs.map +0 -0
  24. package/dist/{dev → browser-dev}/ProductPrice.mjs +0 -0
  25. package/dist/{dev → browser-dev}/ProductPrice.mjs.map +0 -0
  26. package/dist/{dev → browser-dev}/ProductProvider.mjs +0 -0
  27. package/dist/{dev → browser-dev}/ProductProvider.mjs.map +0 -0
  28. package/dist/{dev → browser-dev}/ShopPayButton.mjs +0 -0
  29. package/dist/{dev → browser-dev}/ShopPayButton.mjs.map +0 -0
  30. package/dist/{prod → browser-dev}/ShopifyProvider.mjs +23 -5
  31. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -0
  32. package/dist/{dev → browser-dev}/Video.mjs +0 -0
  33. package/dist/{dev → browser-dev}/Video.mjs.map +0 -0
  34. package/dist/{dev → browser-dev}/_virtual/index.mjs +0 -0
  35. package/dist/{dev → browser-dev}/_virtual/index.mjs.map +0 -0
  36. package/dist/{dev → browser-dev}/_virtual/use-sync-external-store-shim.development.mjs +0 -0
  37. package/dist/{dev → browser-dev}/_virtual/use-sync-external-store-shim.development.mjs.map +0 -0
  38. package/dist/{dev → browser-dev}/_virtual/use-sync-external-store-shim.production.min.mjs +0 -0
  39. package/dist/{dev → browser-dev}/_virtual/use-sync-external-store-shim.production.min.mjs.map +0 -0
  40. package/dist/{dev → browser-dev}/_virtual/with-selector.development.mjs +0 -0
  41. package/dist/{dev → browser-dev}/_virtual/with-selector.development.mjs.map +0 -0
  42. package/dist/{dev → browser-dev}/_virtual/with-selector.mjs +0 -0
  43. package/dist/{dev → browser-dev}/_virtual/with-selector.mjs.map +0 -0
  44. package/dist/{dev → browser-dev}/_virtual/with-selector.production.min.mjs +0 -0
  45. package/dist/{dev → browser-dev}/_virtual/with-selector.production.min.mjs.map +0 -0
  46. package/dist/{prod → browser-dev}/cart-constants.mjs +1 -3
  47. package/dist/browser-dev/cart-constants.mjs.map +1 -0
  48. package/dist/{dev → browser-dev}/cart-hooks.mjs +9 -13
  49. package/dist/browser-dev/cart-hooks.mjs.map +1 -0
  50. package/dist/{dev → browser-dev}/cart-queries.mjs +0 -0
  51. package/dist/{dev → browser-dev}/cart-queries.mjs.map +0 -0
  52. package/dist/browser-dev/codegen.helpers.mjs +12 -0
  53. package/dist/browser-dev/codegen.helpers.mjs.map +1 -0
  54. package/dist/{dev → browser-dev}/flatten-connection.mjs +0 -0
  55. package/dist/{dev → browser-dev}/flatten-connection.mjs.map +0 -0
  56. package/dist/{dev → browser-dev}/image-size.mjs +0 -0
  57. package/dist/{dev → browser-dev}/image-size.mjs.map +0 -0
  58. package/dist/{prod → browser-dev}/index.mjs +2 -0
  59. package/dist/browser-dev/index.mjs.map +1 -0
  60. package/dist/{dev → browser-dev}/load-script.mjs +0 -0
  61. package/dist/{dev → browser-dev}/load-script.mjs.map +0 -0
  62. package/dist/{dev → browser-dev}/metafield-parser.mjs +0 -0
  63. package/dist/{dev → browser-dev}/metafield-parser.mjs.map +0 -0
  64. package/dist/{dev → browser-dev}/node_modules/@xstate/fsm/es/index.mjs +0 -0
  65. package/dist/{dev → browser-dev}/node_modules/@xstate/fsm/es/index.mjs.map +0 -0
  66. package/dist/{dev → browser-dev}/node_modules/@xstate/react/es/fsm.mjs +0 -0
  67. package/dist/{dev → browser-dev}/node_modules/@xstate/react/es/fsm.mjs.map +0 -0
  68. package/dist/{dev → browser-dev}/node_modules/@xstate/react/es/useConstant.mjs +0 -0
  69. package/dist/{dev → browser-dev}/node_modules/@xstate/react/es/useConstant.mjs.map +0 -0
  70. package/dist/{dev → browser-dev}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs +0 -0
  71. package/dist/{dev → browser-dev}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +0 -0
  72. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +0 -0
  73. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +0 -0
  74. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +0 -0
  75. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +0 -0
  76. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +0 -0
  77. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +0 -0
  78. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +0 -0
  79. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +0 -0
  80. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/shim/index.mjs +0 -0
  81. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/shim/index.mjs.map +0 -0
  82. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/shim/with-selector.mjs +0 -0
  83. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/shim/with-selector.mjs.map +0 -0
  84. package/dist/{dev → browser-dev}/storefront-api-constants.mjs +0 -0
  85. package/dist/{dev → browser-dev}/storefront-api-constants.mjs.map +0 -0
  86. package/dist/{dev → browser-dev}/storefront-client.mjs +22 -10
  87. package/dist/browser-dev/storefront-client.mjs.map +1 -0
  88. package/dist/{dev → browser-dev}/useCartAPIStateMachine.mjs +0 -0
  89. package/dist/{dev → browser-dev}/useCartAPIStateMachine.mjs.map +0 -0
  90. package/dist/{dev → browser-dev}/useCartActions.mjs +0 -0
  91. package/dist/{dev → browser-dev}/useCartActions.mjs.map +0 -0
  92. package/dist/{dev → browser-dev}/useMoney.mjs +0 -0
  93. package/dist/{dev → browser-dev}/useMoney.mjs.map +0 -0
  94. package/dist/{prod → browser-prod}/AddToCartButton.mjs +0 -0
  95. package/dist/browser-prod/AddToCartButton.mjs.map +1 -0
  96. package/dist/{prod → browser-prod}/BaseButton.mjs +0 -0
  97. package/dist/{prod → browser-prod}/BaseButton.mjs.map +0 -0
  98. package/dist/{prod → browser-prod}/BuyNowButton.mjs +0 -0
  99. package/dist/{prod → browser-prod}/BuyNowButton.mjs.map +0 -0
  100. package/dist/{prod → browser-prod}/CartCheckoutButton.mjs +0 -0
  101. package/dist/{prod → browser-prod}/CartCheckoutButton.mjs.map +0 -0
  102. package/dist/{prod → browser-prod}/CartProvider.mjs +0 -0
  103. package/dist/{prod → browser-prod}/CartProvider.mjs.map +0 -0
  104. package/dist/{prod → browser-prod}/ExternalVideo.mjs +0 -0
  105. package/dist/{prod → browser-prod}/ExternalVideo.mjs.map +0 -0
  106. package/dist/{prod → browser-prod}/Image.mjs +0 -0
  107. package/dist/{prod → browser-prod}/Image.mjs.map +0 -0
  108. package/dist/{prod → browser-prod}/MediaFile.mjs +0 -0
  109. package/dist/{prod → browser-prod}/MediaFile.mjs.map +0 -0
  110. package/dist/{prod → browser-prod}/Metafield.mjs +0 -0
  111. package/dist/{prod → browser-prod}/Metafield.mjs.map +0 -0
  112. package/dist/{prod → browser-prod}/ModelViewer.mjs +0 -0
  113. package/dist/{prod → browser-prod}/ModelViewer.mjs.map +0 -0
  114. package/dist/{prod → browser-prod}/Money.mjs +0 -0
  115. package/dist/{prod → browser-prod}/Money.mjs.map +0 -0
  116. package/dist/{prod → browser-prod}/ProductPrice.mjs +0 -0
  117. package/dist/{prod → browser-prod}/ProductPrice.mjs.map +0 -0
  118. package/dist/{prod → browser-prod}/ProductProvider.mjs +0 -0
  119. package/dist/{prod → browser-prod}/ProductProvider.mjs.map +0 -0
  120. package/dist/{prod → browser-prod}/ShopPayButton.mjs +0 -0
  121. package/dist/{prod → browser-prod}/ShopPayButton.mjs.map +0 -0
  122. package/dist/{dev → browser-prod}/ShopifyProvider.mjs +23 -5
  123. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -0
  124. package/dist/{prod → browser-prod}/Video.mjs +0 -0
  125. package/dist/{prod → browser-prod}/Video.mjs.map +0 -0
  126. package/dist/{prod → browser-prod}/_virtual/index.mjs +0 -0
  127. package/dist/{prod → browser-prod}/_virtual/index.mjs.map +0 -0
  128. package/dist/{prod → browser-prod}/_virtual/use-sync-external-store-shim.development.mjs +0 -0
  129. package/dist/{prod → browser-prod}/_virtual/use-sync-external-store-shim.development.mjs.map +0 -0
  130. package/dist/{prod → browser-prod}/_virtual/use-sync-external-store-shim.production.min.mjs +0 -0
  131. package/dist/{prod → browser-prod}/_virtual/use-sync-external-store-shim.production.min.mjs.map +0 -0
  132. package/dist/{prod → browser-prod}/_virtual/with-selector.development.mjs +0 -0
  133. package/dist/{prod → browser-prod}/_virtual/with-selector.development.mjs.map +0 -0
  134. package/dist/{prod → browser-prod}/_virtual/with-selector.mjs +0 -0
  135. package/dist/{prod → browser-prod}/_virtual/with-selector.mjs.map +0 -0
  136. package/dist/{prod → browser-prod}/_virtual/with-selector.production.min.mjs +0 -0
  137. package/dist/{prod → browser-prod}/_virtual/with-selector.production.min.mjs.map +0 -0
  138. package/dist/{dev → browser-prod}/cart-constants.mjs +1 -3
  139. package/dist/browser-prod/cart-constants.mjs.map +1 -0
  140. package/dist/{prod → browser-prod}/cart-hooks.mjs +9 -13
  141. package/dist/browser-prod/cart-hooks.mjs.map +1 -0
  142. package/dist/{prod → browser-prod}/cart-queries.mjs +0 -0
  143. package/dist/{prod → browser-prod}/cart-queries.mjs.map +0 -0
  144. package/dist/browser-prod/codegen.helpers.mjs +12 -0
  145. package/dist/browser-prod/codegen.helpers.mjs.map +1 -0
  146. package/dist/{prod → browser-prod}/flatten-connection.mjs +0 -0
  147. package/dist/{prod → browser-prod}/flatten-connection.mjs.map +0 -0
  148. package/dist/{prod → browser-prod}/image-size.mjs +0 -0
  149. package/dist/{prod → browser-prod}/image-size.mjs.map +0 -0
  150. package/dist/{dev → browser-prod}/index.mjs +2 -0
  151. package/dist/browser-prod/index.mjs.map +1 -0
  152. package/dist/{prod → browser-prod}/load-script.mjs +0 -0
  153. package/dist/{prod → browser-prod}/load-script.mjs.map +0 -0
  154. package/dist/{prod → browser-prod}/metafield-parser.mjs +0 -0
  155. package/dist/{prod → browser-prod}/metafield-parser.mjs.map +0 -0
  156. package/dist/{prod → browser-prod}/node_modules/@xstate/fsm/es/index.mjs +0 -0
  157. package/dist/{prod → browser-prod}/node_modules/@xstate/fsm/es/index.mjs.map +0 -0
  158. package/dist/{prod → browser-prod}/node_modules/@xstate/react/es/fsm.mjs +0 -0
  159. package/dist/{prod → browser-prod}/node_modules/@xstate/react/es/fsm.mjs.map +0 -0
  160. package/dist/{prod → browser-prod}/node_modules/@xstate/react/es/useConstant.mjs +0 -0
  161. package/dist/{prod → browser-prod}/node_modules/@xstate/react/es/useConstant.mjs.map +0 -0
  162. package/dist/{prod → browser-prod}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs +0 -0
  163. package/dist/{prod → browser-prod}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +0 -0
  164. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +0 -0
  165. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +0 -0
  166. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +0 -0
  167. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +0 -0
  168. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +0 -0
  169. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +0 -0
  170. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +0 -0
  171. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +0 -0
  172. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/shim/index.mjs +0 -0
  173. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/shim/index.mjs.map +0 -0
  174. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/shim/with-selector.mjs +0 -0
  175. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/shim/with-selector.mjs.map +0 -0
  176. package/dist/{prod → browser-prod}/storefront-api-constants.mjs +0 -0
  177. package/dist/{prod → browser-prod}/storefront-api-constants.mjs.map +0 -0
  178. package/dist/{prod → browser-prod}/storefront-client.mjs +22 -10
  179. package/dist/browser-prod/storefront-client.mjs.map +1 -0
  180. package/dist/{prod → browser-prod}/useCartAPIStateMachine.mjs +0 -0
  181. package/dist/{prod → browser-prod}/useCartAPIStateMachine.mjs.map +0 -0
  182. package/dist/{prod → browser-prod}/useCartActions.mjs +0 -0
  183. package/dist/{prod → browser-prod}/useCartActions.mjs.map +0 -0
  184. package/dist/{prod → browser-prod}/useMoney.mjs +0 -0
  185. package/dist/{prod → browser-prod}/useMoney.mjs.map +0 -0
  186. package/dist/{dev → node-dev}/AddToCartButton.js +0 -0
  187. package/dist/node-dev/AddToCartButton.js.map +1 -0
  188. package/dist/node-dev/AddToCartButton.mjs +70 -0
  189. package/dist/node-dev/AddToCartButton.mjs.map +1 -0
  190. package/dist/{dev → node-dev}/BaseButton.js +0 -0
  191. package/dist/{dev → node-dev}/BaseButton.js.map +0 -0
  192. package/dist/node-dev/BaseButton.mjs +31 -0
  193. package/dist/node-dev/BaseButton.mjs.map +1 -0
  194. package/dist/{dev → node-dev}/BuyNowButton.js +0 -0
  195. package/dist/{dev → node-dev}/BuyNowButton.js.map +0 -0
  196. package/dist/node-dev/BuyNowButton.mjs +45 -0
  197. package/dist/node-dev/BuyNowButton.mjs.map +1 -0
  198. package/dist/{dev → node-dev}/CartCheckoutButton.js +0 -0
  199. package/dist/{dev → node-dev}/CartCheckoutButton.js.map +0 -0
  200. package/dist/node-dev/CartCheckoutButton.mjs +30 -0
  201. package/dist/node-dev/CartCheckoutButton.mjs.map +1 -0
  202. package/dist/{dev → node-dev}/CartProvider.js +0 -0
  203. package/dist/{dev → node-dev}/CartProvider.js.map +0 -0
  204. package/dist/node-dev/CartProvider.mjs +485 -0
  205. package/dist/node-dev/CartProvider.mjs.map +1 -0
  206. package/dist/{dev → node-dev}/ExternalVideo.js +0 -0
  207. package/dist/{dev → node-dev}/ExternalVideo.js.map +0 -0
  208. package/dist/node-dev/ExternalVideo.mjs +39 -0
  209. package/dist/node-dev/ExternalVideo.mjs.map +1 -0
  210. package/dist/{dev → node-dev}/Image.js +0 -0
  211. package/dist/{dev → node-dev}/Image.js.map +0 -0
  212. package/dist/node-dev/Image.mjs +104 -0
  213. package/dist/node-dev/Image.mjs.map +1 -0
  214. package/dist/{dev → node-dev}/MediaFile.js +0 -0
  215. package/dist/{dev → node-dev}/MediaFile.js.map +0 -0
  216. package/dist/node-dev/MediaFile.mjs +57 -0
  217. package/dist/node-dev/MediaFile.mjs.map +1 -0
  218. package/dist/{dev → node-dev}/Metafield.js +0 -0
  219. package/dist/{dev → node-dev}/Metafield.js.map +0 -0
  220. package/dist/node-dev/Metafield.mjs +301 -0
  221. package/dist/node-dev/Metafield.mjs.map +1 -0
  222. package/dist/{dev → node-dev}/ModelViewer.js +0 -0
  223. package/dist/{dev → node-dev}/ModelViewer.js.map +0 -0
  224. package/dist/node-dev/ModelViewer.mjs +145 -0
  225. package/dist/node-dev/ModelViewer.mjs.map +1 -0
  226. package/dist/{dev → node-dev}/Money.js +0 -0
  227. package/dist/{dev → node-dev}/Money.js.map +0 -0
  228. package/dist/node-dev/Money.mjs +40 -0
  229. package/dist/node-dev/Money.mjs.map +1 -0
  230. package/dist/{dev → node-dev}/ProductPrice.js +0 -0
  231. package/dist/{dev → node-dev}/ProductPrice.js.map +0 -0
  232. package/dist/node-dev/ProductPrice.mjs +61 -0
  233. package/dist/node-dev/ProductPrice.mjs.map +1 -0
  234. package/dist/{dev → node-dev}/ProductProvider.js +0 -0
  235. package/dist/{dev → node-dev}/ProductProvider.js.map +0 -0
  236. package/dist/node-dev/ProductProvider.mjs +161 -0
  237. package/dist/node-dev/ProductProvider.mjs.map +1 -0
  238. package/dist/{dev → node-dev}/ShopPayButton.js +0 -0
  239. package/dist/{dev → node-dev}/ShopPayButton.js.map +0 -0
  240. package/dist/node-dev/ShopPayButton.mjs +64 -0
  241. package/dist/node-dev/ShopPayButton.mjs.map +1 -0
  242. package/dist/{prod → node-dev}/ShopifyProvider.js +23 -5
  243. package/dist/node-dev/ShopifyProvider.js.map +1 -0
  244. package/dist/node-dev/ShopifyProvider.mjs +64 -0
  245. package/dist/node-dev/ShopifyProvider.mjs.map +1 -0
  246. package/dist/{dev → node-dev}/Video.js +0 -0
  247. package/dist/{dev → node-dev}/Video.js.map +0 -0
  248. package/dist/node-dev/Video.mjs +44 -0
  249. package/dist/node-dev/Video.mjs.map +1 -0
  250. package/dist/{dev → node-dev}/_virtual/index.js +0 -0
  251. package/dist/{dev → node-dev}/_virtual/index.js.map +0 -0
  252. package/dist/node-dev/_virtual/index.mjs +5 -0
  253. package/dist/{dev → node-dev/_virtual}/index.mjs.map +1 -1
  254. package/dist/{dev → node-dev}/_virtual/use-sync-external-store-shim.development.js +0 -0
  255. package/dist/{dev → node-dev}/_virtual/use-sync-external-store-shim.development.js.map +0 -0
  256. package/dist/node-dev/_virtual/use-sync-external-store-shim.development.mjs +5 -0
  257. package/dist/node-dev/_virtual/use-sync-external-store-shim.development.mjs.map +1 -0
  258. package/dist/{dev → node-dev}/_virtual/use-sync-external-store-shim.production.min.js +0 -0
  259. package/dist/{dev → node-dev}/_virtual/use-sync-external-store-shim.production.min.js.map +0 -0
  260. package/dist/node-dev/_virtual/use-sync-external-store-shim.production.min.mjs +5 -0
  261. package/dist/node-dev/_virtual/use-sync-external-store-shim.production.min.mjs.map +1 -0
  262. package/dist/{dev → node-dev}/_virtual/with-selector.development.js +0 -0
  263. package/dist/{dev → node-dev}/_virtual/with-selector.development.js.map +0 -0
  264. package/dist/node-dev/_virtual/with-selector.development.mjs +5 -0
  265. package/dist/node-dev/_virtual/with-selector.development.mjs.map +1 -0
  266. package/dist/{dev → node-dev}/_virtual/with-selector.js +0 -0
  267. package/dist/{dev → node-dev}/_virtual/with-selector.js.map +0 -0
  268. package/dist/node-dev/_virtual/with-selector.mjs +5 -0
  269. package/dist/node-dev/_virtual/with-selector.mjs.map +1 -0
  270. package/dist/{dev → node-dev}/_virtual/with-selector.production.min.js +0 -0
  271. package/dist/{dev → node-dev}/_virtual/with-selector.production.min.js.map +0 -0
  272. package/dist/node-dev/_virtual/with-selector.production.min.mjs +5 -0
  273. package/dist/node-dev/_virtual/with-selector.production.min.mjs.map +1 -0
  274. package/dist/{dev → node-dev}/cart-constants.js +0 -2
  275. package/dist/node-dev/cart-constants.js.map +1 -0
  276. package/dist/node-dev/cart-constants.mjs +15 -0
  277. package/dist/node-dev/cart-constants.mjs.map +1 -0
  278. package/dist/{dev → node-dev}/cart-hooks.js +8 -12
  279. package/dist/node-dev/cart-hooks.js.map +1 -0
  280. package/dist/node-dev/cart-hooks.mjs +44 -0
  281. package/dist/node-dev/cart-hooks.mjs.map +1 -0
  282. package/dist/{dev → node-dev}/cart-queries.js +0 -0
  283. package/dist/{dev → node-dev}/cart-queries.js.map +0 -0
  284. package/dist/node-dev/cart-queries.mjs +114 -0
  285. package/dist/node-dev/cart-queries.mjs.map +1 -0
  286. package/dist/node-dev/codegen.helpers.js +12 -0
  287. package/dist/node-dev/codegen.helpers.js.map +1 -0
  288. package/dist/node-dev/codegen.helpers.mjs +12 -0
  289. package/dist/node-dev/codegen.helpers.mjs.map +1 -0
  290. package/dist/{dev → node-dev}/flatten-connection.js +0 -0
  291. package/dist/{dev → node-dev}/flatten-connection.js.map +0 -0
  292. package/dist/node-dev/flatten-connection.mjs +29 -0
  293. package/dist/node-dev/flatten-connection.mjs.map +1 -0
  294. package/dist/{dev → node-dev}/image-size.js +0 -0
  295. package/dist/{dev → node-dev}/image-size.js.map +0 -0
  296. package/dist/node-dev/image-size.mjs +80 -0
  297. package/dist/node-dev/image-size.mjs.map +1 -0
  298. package/dist/{dev → node-dev}/index.js +2 -0
  299. package/dist/{dev → node-dev}/index.js.map +1 -1
  300. package/dist/node-dev/index.mjs +48 -0
  301. package/dist/node-dev/index.mjs.map +1 -0
  302. package/dist/{dev → node-dev}/load-script.js +0 -0
  303. package/dist/{dev → node-dev}/load-script.js.map +0 -0
  304. package/dist/node-dev/load-script.mjs +52 -0
  305. package/dist/node-dev/load-script.mjs.map +1 -0
  306. package/dist/{dev → node-dev}/metafield-parser.js +0 -0
  307. package/dist/{dev → node-dev}/metafield-parser.js.map +0 -0
  308. package/dist/node-dev/metafield-parser.mjs +103 -0
  309. package/dist/node-dev/metafield-parser.mjs.map +1 -0
  310. package/dist/{dev → node-dev}/node_modules/@xstate/fsm/es/index.js +0 -0
  311. package/dist/{dev → node-dev}/node_modules/@xstate/fsm/es/index.js.map +0 -0
  312. package/dist/node-dev/node_modules/@xstate/fsm/es/index.mjs +159 -0
  313. package/dist/node-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -0
  314. package/dist/{dev → node-dev}/node_modules/@xstate/react/es/fsm.js +2 -2
  315. package/dist/{dev → node-dev}/node_modules/@xstate/react/es/fsm.js.map +1 -1
  316. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +94 -0
  317. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -0
  318. package/dist/{dev → node-dev}/node_modules/@xstate/react/es/useConstant.js +0 -0
  319. package/dist/{dev → node-dev}/node_modules/@xstate/react/es/useConstant.js.map +0 -0
  320. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs +12 -0
  321. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -0
  322. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +5 -0
  323. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -0
  324. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.mjs +6 -0
  325. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.mjs.map +1 -0
  326. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -0
  327. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -0
  328. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +105 -0
  329. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -0
  330. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -0
  331. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -0
  332. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +72 -0
  333. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -0
  334. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -0
  335. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -0
  336. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +136 -0
  337. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -0
  338. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -0
  339. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +0 -0
  340. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +58 -0
  341. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -0
  342. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/shim/index.js +0 -0
  343. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/shim/index.js.map +0 -0
  344. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +21 -0
  345. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs.map +1 -0
  346. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/shim/with-selector.js +0 -0
  347. package/dist/{dev → node-dev}/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -0
  348. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +11 -0
  349. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -0
  350. package/dist/{dev → node-dev}/storefront-api-constants.js +0 -0
  351. package/dist/{dev → node-dev}/storefront-api-constants.js.map +0 -0
  352. package/dist/node-dev/storefront-api-constants.mjs +5 -0
  353. package/dist/node-dev/storefront-api-constants.mjs.map +1 -0
  354. package/dist/{dev → node-dev}/storefront-client.js +21 -9
  355. package/dist/node-dev/storefront-client.js.map +1 -0
  356. package/dist/node-dev/storefront-client.mjs +84 -0
  357. package/dist/node-dev/storefront-client.mjs.map +1 -0
  358. package/dist/{dev → node-dev}/useCartAPIStateMachine.js +0 -0
  359. package/dist/{dev → node-dev}/useCartAPIStateMachine.js.map +0 -0
  360. package/dist/node-dev/useCartAPIStateMachine.mjs +326 -0
  361. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -0
  362. package/dist/{dev → node-dev}/useCartActions.js +0 -0
  363. package/dist/{dev → node-dev}/useCartActions.js.map +0 -0
  364. package/dist/node-dev/useCartActions.mjs +123 -0
  365. package/dist/node-dev/useCartActions.mjs.map +1 -0
  366. package/dist/{dev → node-dev}/useMoney.js +0 -0
  367. package/dist/{dev → node-dev}/useMoney.js.map +0 -0
  368. package/dist/node-dev/useMoney.mjs +72 -0
  369. package/dist/node-dev/useMoney.mjs.map +1 -0
  370. package/dist/{prod → node-prod}/AddToCartButton.js +0 -0
  371. package/dist/node-prod/AddToCartButton.js.map +1 -0
  372. package/dist/node-prod/AddToCartButton.mjs +70 -0
  373. package/dist/node-prod/AddToCartButton.mjs.map +1 -0
  374. package/dist/{prod → node-prod}/BaseButton.js +0 -0
  375. package/dist/{prod → node-prod}/BaseButton.js.map +0 -0
  376. package/dist/node-prod/BaseButton.mjs +31 -0
  377. package/dist/node-prod/BaseButton.mjs.map +1 -0
  378. package/dist/{prod → node-prod}/BuyNowButton.js +0 -0
  379. package/dist/{prod → node-prod}/BuyNowButton.js.map +0 -0
  380. package/dist/node-prod/BuyNowButton.mjs +45 -0
  381. package/dist/node-prod/BuyNowButton.mjs.map +1 -0
  382. package/dist/{prod → node-prod}/CartCheckoutButton.js +0 -0
  383. package/dist/{prod → node-prod}/CartCheckoutButton.js.map +0 -0
  384. package/dist/node-prod/CartCheckoutButton.mjs +30 -0
  385. package/dist/node-prod/CartCheckoutButton.mjs.map +1 -0
  386. package/dist/{prod → node-prod}/CartProvider.js +0 -0
  387. package/dist/{prod → node-prod}/CartProvider.js.map +0 -0
  388. package/dist/node-prod/CartProvider.mjs +485 -0
  389. package/dist/node-prod/CartProvider.mjs.map +1 -0
  390. package/dist/{prod → node-prod}/ExternalVideo.js +0 -0
  391. package/dist/{prod → node-prod}/ExternalVideo.js.map +0 -0
  392. package/dist/node-prod/ExternalVideo.mjs +39 -0
  393. package/dist/node-prod/ExternalVideo.mjs.map +1 -0
  394. package/dist/{prod → node-prod}/Image.js +0 -0
  395. package/dist/{prod → node-prod}/Image.js.map +0 -0
  396. package/dist/node-prod/Image.mjs +99 -0
  397. package/dist/node-prod/Image.mjs.map +1 -0
  398. package/dist/{prod → node-prod}/MediaFile.js +0 -0
  399. package/dist/{prod → node-prod}/MediaFile.js.map +0 -0
  400. package/dist/node-prod/MediaFile.mjs +59 -0
  401. package/dist/node-prod/MediaFile.mjs.map +1 -0
  402. package/dist/{prod → node-prod}/Metafield.js +0 -0
  403. package/dist/{prod → node-prod}/Metafield.js.map +0 -0
  404. package/dist/node-prod/Metafield.mjs +288 -0
  405. package/dist/node-prod/Metafield.mjs.map +1 -0
  406. package/dist/{prod → node-prod}/ModelViewer.js +0 -0
  407. package/dist/{prod → node-prod}/ModelViewer.js.map +0 -0
  408. package/dist/node-prod/ModelViewer.mjs +143 -0
  409. package/dist/node-prod/ModelViewer.mjs.map +1 -0
  410. package/dist/{prod → node-prod}/Money.js +0 -0
  411. package/dist/{prod → node-prod}/Money.js.map +0 -0
  412. package/dist/node-prod/Money.mjs +40 -0
  413. package/dist/node-prod/Money.mjs.map +1 -0
  414. package/dist/{prod → node-prod}/ProductPrice.js +0 -0
  415. package/dist/{prod → node-prod}/ProductPrice.js.map +0 -0
  416. package/dist/node-prod/ProductPrice.mjs +61 -0
  417. package/dist/node-prod/ProductPrice.mjs.map +1 -0
  418. package/dist/{prod → node-prod}/ProductProvider.js +0 -0
  419. package/dist/{prod → node-prod}/ProductProvider.js.map +0 -0
  420. package/dist/node-prod/ProductProvider.mjs +161 -0
  421. package/dist/node-prod/ProductProvider.mjs.map +1 -0
  422. package/dist/{prod → node-prod}/ShopPayButton.js +0 -0
  423. package/dist/{prod → node-prod}/ShopPayButton.js.map +0 -0
  424. package/dist/node-prod/ShopPayButton.mjs +64 -0
  425. package/dist/node-prod/ShopPayButton.mjs.map +1 -0
  426. package/dist/{dev → node-prod}/ShopifyProvider.js +23 -5
  427. package/dist/node-prod/ShopifyProvider.js.map +1 -0
  428. package/dist/node-prod/ShopifyProvider.mjs +64 -0
  429. package/dist/node-prod/ShopifyProvider.mjs.map +1 -0
  430. package/dist/{prod → node-prod}/Video.js +0 -0
  431. package/dist/{prod → node-prod}/Video.js.map +0 -0
  432. package/dist/node-prod/Video.mjs +44 -0
  433. package/dist/node-prod/Video.mjs.map +1 -0
  434. package/dist/{prod → node-prod}/_virtual/index.js +0 -0
  435. package/dist/{prod → node-prod}/_virtual/index.js.map +0 -0
  436. package/dist/node-prod/_virtual/index.mjs +5 -0
  437. package/dist/{prod → node-prod/_virtual}/index.mjs.map +1 -1
  438. package/dist/{prod → node-prod}/_virtual/use-sync-external-store-shim.development.js +0 -0
  439. package/dist/{prod → node-prod}/_virtual/use-sync-external-store-shim.development.js.map +0 -0
  440. package/dist/node-prod/_virtual/use-sync-external-store-shim.development.mjs +5 -0
  441. package/dist/node-prod/_virtual/use-sync-external-store-shim.development.mjs.map +1 -0
  442. package/dist/{prod → node-prod}/_virtual/use-sync-external-store-shim.production.min.js +0 -0
  443. package/dist/{prod → node-prod}/_virtual/use-sync-external-store-shim.production.min.js.map +0 -0
  444. package/dist/node-prod/_virtual/use-sync-external-store-shim.production.min.mjs +5 -0
  445. package/dist/node-prod/_virtual/use-sync-external-store-shim.production.min.mjs.map +1 -0
  446. package/dist/{prod → node-prod}/_virtual/with-selector.development.js +0 -0
  447. package/dist/{prod → node-prod}/_virtual/with-selector.development.js.map +0 -0
  448. package/dist/node-prod/_virtual/with-selector.development.mjs +5 -0
  449. package/dist/node-prod/_virtual/with-selector.development.mjs.map +1 -0
  450. package/dist/{prod → node-prod}/_virtual/with-selector.js +0 -0
  451. package/dist/{prod → node-prod}/_virtual/with-selector.js.map +0 -0
  452. package/dist/node-prod/_virtual/with-selector.mjs +5 -0
  453. package/dist/node-prod/_virtual/with-selector.mjs.map +1 -0
  454. package/dist/{prod → node-prod}/_virtual/with-selector.production.min.js +0 -0
  455. package/dist/{prod → node-prod}/_virtual/with-selector.production.min.js.map +0 -0
  456. package/dist/node-prod/_virtual/with-selector.production.min.mjs +5 -0
  457. package/dist/node-prod/_virtual/with-selector.production.min.mjs.map +1 -0
  458. package/dist/{prod → node-prod}/cart-constants.js +0 -2
  459. package/dist/node-prod/cart-constants.js.map +1 -0
  460. package/dist/node-prod/cart-constants.mjs +15 -0
  461. package/dist/node-prod/cart-constants.mjs.map +1 -0
  462. package/dist/{prod → node-prod}/cart-hooks.js +8 -12
  463. package/dist/node-prod/cart-hooks.js.map +1 -0
  464. package/dist/node-prod/cart-hooks.mjs +44 -0
  465. package/dist/node-prod/cart-hooks.mjs.map +1 -0
  466. package/dist/{prod → node-prod}/cart-queries.js +0 -0
  467. package/dist/{prod → node-prod}/cart-queries.js.map +0 -0
  468. package/dist/node-prod/cart-queries.mjs +114 -0
  469. package/dist/node-prod/cart-queries.mjs.map +1 -0
  470. package/dist/node-prod/codegen.helpers.js +12 -0
  471. package/dist/node-prod/codegen.helpers.js.map +1 -0
  472. package/dist/node-prod/codegen.helpers.mjs +12 -0
  473. package/dist/node-prod/codegen.helpers.mjs.map +1 -0
  474. package/dist/{prod → node-prod}/flatten-connection.js +0 -0
  475. package/dist/{prod → node-prod}/flatten-connection.js.map +0 -0
  476. package/dist/node-prod/flatten-connection.mjs +25 -0
  477. package/dist/node-prod/flatten-connection.mjs.map +1 -0
  478. package/dist/{prod → node-prod}/image-size.js +0 -0
  479. package/dist/{prod → node-prod}/image-size.js.map +0 -0
  480. package/dist/node-prod/image-size.mjs +80 -0
  481. package/dist/node-prod/image-size.mjs.map +1 -0
  482. package/dist/{prod → node-prod}/index.js +2 -0
  483. package/dist/{prod → node-prod}/index.js.map +1 -1
  484. package/dist/node-prod/index.mjs +48 -0
  485. package/dist/node-prod/index.mjs.map +1 -0
  486. package/dist/{prod → node-prod}/load-script.js +0 -0
  487. package/dist/{prod → node-prod}/load-script.js.map +0 -0
  488. package/dist/node-prod/load-script.mjs +52 -0
  489. package/dist/node-prod/load-script.mjs.map +1 -0
  490. package/dist/{prod → node-prod}/metafield-parser.js +0 -0
  491. package/dist/{prod → node-prod}/metafield-parser.js.map +0 -0
  492. package/dist/node-prod/metafield-parser.mjs +114 -0
  493. package/dist/node-prod/metafield-parser.mjs.map +1 -0
  494. package/dist/{prod → node-prod}/node_modules/@xstate/fsm/es/index.js +0 -0
  495. package/dist/{prod → node-prod}/node_modules/@xstate/fsm/es/index.js.map +0 -0
  496. package/dist/node-prod/node_modules/@xstate/fsm/es/index.mjs +159 -0
  497. package/dist/node-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -0
  498. package/dist/{prod → node-prod}/node_modules/@xstate/react/es/fsm.js +2 -2
  499. package/dist/{prod → node-prod}/node_modules/@xstate/react/es/fsm.js.map +1 -1
  500. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +94 -0
  501. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -0
  502. package/dist/{prod → node-prod}/node_modules/@xstate/react/es/useConstant.js +0 -0
  503. package/dist/{prod → node-prod}/node_modules/@xstate/react/es/useConstant.js.map +0 -0
  504. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs +12 -0
  505. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -0
  506. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +5 -0
  507. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -0
  508. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.mjs +6 -0
  509. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.mjs.map +1 -0
  510. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -0
  511. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -0
  512. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +105 -0
  513. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -0
  514. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -0
  515. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -0
  516. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +72 -0
  517. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -0
  518. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -0
  519. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -0
  520. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +136 -0
  521. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -0
  522. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -0
  523. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +0 -0
  524. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +58 -0
  525. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -0
  526. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/shim/index.js +0 -0
  527. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/shim/index.js.map +0 -0
  528. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +21 -0
  529. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs.map +1 -0
  530. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/shim/with-selector.js +0 -0
  531. package/dist/{prod → node-prod}/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -0
  532. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +11 -0
  533. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -0
  534. package/dist/{prod → node-prod}/storefront-api-constants.js +0 -0
  535. package/dist/{prod → node-prod}/storefront-api-constants.js.map +0 -0
  536. package/dist/node-prod/storefront-api-constants.mjs +5 -0
  537. package/dist/node-prod/storefront-api-constants.mjs.map +1 -0
  538. package/dist/{prod → node-prod}/storefront-client.js +21 -9
  539. package/dist/node-prod/storefront-client.js.map +1 -0
  540. package/dist/node-prod/storefront-client.mjs +69 -0
  541. package/dist/node-prod/storefront-client.mjs.map +1 -0
  542. package/dist/{prod → node-prod}/useCartAPIStateMachine.js +0 -0
  543. package/dist/{prod → node-prod}/useCartAPIStateMachine.js.map +0 -0
  544. package/dist/node-prod/useCartAPIStateMachine.mjs +326 -0
  545. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -0
  546. package/dist/{prod → node-prod}/useCartActions.js +0 -0
  547. package/dist/{prod → node-prod}/useCartActions.js.map +0 -0
  548. package/dist/node-prod/useCartActions.mjs +123 -0
  549. package/dist/node-prod/useCartActions.mjs.map +1 -0
  550. package/dist/{prod → node-prod}/useMoney.js +0 -0
  551. package/dist/{prod → node-prod}/useMoney.js.map +0 -0
  552. package/dist/node-prod/useMoney.mjs +72 -0
  553. package/dist/node-prod/useMoney.mjs.map +1 -0
  554. package/dist/types/AddToCartButton.d.ts +1 -2
  555. package/dist/types/CartLineProvider.d.ts +16 -0
  556. package/dist/types/ShopifyProvider.d.ts +35 -2
  557. package/dist/types/cart-constants.d.ts +0 -1
  558. package/dist/types/codegen.helpers.d.ts +9 -0
  559. package/dist/types/index.d.cts +1 -0
  560. package/dist/types/index.d.ts +1 -0
  561. package/dist/types/storefront-api-types.d.ts +1 -1
  562. package/dist/types/storefront-client.d.ts +17 -2
  563. package/dist/umd/hydrogen-react.dev.js +118 -86
  564. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  565. package/dist/umd/hydrogen-react.prod.js +15 -15
  566. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  567. package/package.json +35 -20
  568. package/dist/dev/AddToCartButton.js.map +0 -1
  569. package/dist/dev/AddToCartButton.mjs.map +0 -1
  570. package/dist/dev/ShopifyProvider.js.map +0 -1
  571. package/dist/dev/ShopifyProvider.mjs.map +0 -1
  572. package/dist/dev/cart-constants.js.map +0 -1
  573. package/dist/dev/cart-constants.mjs.map +0 -1
  574. package/dist/dev/cart-hooks.js.map +0 -1
  575. package/dist/dev/cart-hooks.mjs.map +0 -1
  576. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -5
  577. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +0 -1
  578. package/dist/dev/storefront-client.js.map +0 -1
  579. package/dist/dev/storefront-client.mjs.map +0 -1
  580. package/dist/prod/AddToCartButton.js.map +0 -1
  581. package/dist/prod/AddToCartButton.mjs.map +0 -1
  582. package/dist/prod/ShopifyProvider.js.map +0 -1
  583. package/dist/prod/ShopifyProvider.mjs.map +0 -1
  584. package/dist/prod/cart-constants.js.map +0 -1
  585. package/dist/prod/cart-constants.mjs.map +0 -1
  586. package/dist/prod/cart-hooks.js.map +0 -1
  587. package/dist/prod/cart-hooks.mjs.map +0 -1
  588. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -5
  589. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +0 -1
  590. package/dist/prod/storefront-client.js.map +0 -1
  591. package/dist/prod/storefront-client.mjs.map +0 -1
@@ -0,0 +1,143 @@
1
+ import { useState, useCallback, useEffect } from "react";
2
+ import { useLoadScript } from "./load-script.mjs";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function ModelViewer(props) {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
6
+ const [modelViewer, setModelViewer] = useState(void 0);
7
+ const callbackRef = useCallback((node) => {
8
+ setModelViewer(node);
9
+ }, []);
10
+ const {
11
+ data,
12
+ children,
13
+ className,
14
+ ...passthroughProps
15
+ } = props;
16
+ const modelViewerLoadedStatus = useLoadScript("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js", {
17
+ module: true
18
+ });
19
+ useEffect(() => {
20
+ if (!modelViewer) {
21
+ return;
22
+ }
23
+ if (passthroughProps.onError)
24
+ modelViewer.addEventListener("error", passthroughProps.onError);
25
+ if (passthroughProps.onLoad)
26
+ modelViewer.addEventListener("load", passthroughProps.onLoad);
27
+ if (passthroughProps.onPreload)
28
+ modelViewer.addEventListener("preload", passthroughProps.onPreload);
29
+ if (passthroughProps.onModelVisibility)
30
+ modelViewer.addEventListener("model-visibility", passthroughProps.onModelVisibility);
31
+ if (passthroughProps.onProgress)
32
+ modelViewer.addEventListener("progress", passthroughProps.onProgress);
33
+ if (passthroughProps.onArStatus)
34
+ modelViewer.addEventListener("ar-status", passthroughProps.onArStatus);
35
+ if (passthroughProps.onArTracking)
36
+ modelViewer.addEventListener("ar-tracking", passthroughProps.onArTracking);
37
+ if (passthroughProps.onQuickLookButtonTapped)
38
+ modelViewer.addEventListener("quick-look-button-tapped", passthroughProps.onQuickLookButtonTapped);
39
+ if (passthroughProps.onCameraChange)
40
+ modelViewer.addEventListener("camera-change", passthroughProps.onCameraChange);
41
+ if (passthroughProps.onEnvironmentChange)
42
+ modelViewer.addEventListener("environment-change", passthroughProps.onEnvironmentChange);
43
+ if (passthroughProps.onPlay)
44
+ modelViewer.addEventListener("play", passthroughProps.onPlay);
45
+ if (passthroughProps.onPause)
46
+ modelViewer.addEventListener("ar-status", passthroughProps.onPause);
47
+ if (passthroughProps.onSceneGraphReady)
48
+ modelViewer.addEventListener("scene-graph-ready", passthroughProps.onSceneGraphReady);
49
+ return () => {
50
+ if (modelViewer == null) {
51
+ return;
52
+ }
53
+ if (passthroughProps.onError)
54
+ modelViewer.removeEventListener("error", passthroughProps.onError);
55
+ if (passthroughProps.onLoad)
56
+ modelViewer.removeEventListener("load", passthroughProps.onLoad);
57
+ if (passthroughProps.onPreload)
58
+ modelViewer.removeEventListener("preload", passthroughProps.onPreload);
59
+ if (passthroughProps.onModelVisibility)
60
+ modelViewer.removeEventListener("model-visibility", passthroughProps.onModelVisibility);
61
+ if (passthroughProps.onProgress)
62
+ modelViewer.removeEventListener("progress", passthroughProps.onProgress);
63
+ if (passthroughProps.onArStatus)
64
+ modelViewer.removeEventListener("ar-status", passthroughProps.onArStatus);
65
+ if (passthroughProps.onArTracking)
66
+ modelViewer.removeEventListener("ar-tracking", passthroughProps.onArTracking);
67
+ if (passthroughProps.onQuickLookButtonTapped)
68
+ modelViewer.removeEventListener("quick-look-button-tapped", passthroughProps.onQuickLookButtonTapped);
69
+ if (passthroughProps.onCameraChange)
70
+ modelViewer.removeEventListener("camera-change", passthroughProps.onCameraChange);
71
+ if (passthroughProps.onEnvironmentChange)
72
+ modelViewer.removeEventListener("environment-change", passthroughProps.onEnvironmentChange);
73
+ if (passthroughProps.onPlay)
74
+ modelViewer.removeEventListener("play", passthroughProps.onPlay);
75
+ if (passthroughProps.onPause)
76
+ modelViewer.removeEventListener("ar-status", passthroughProps.onPause);
77
+ if (passthroughProps.onSceneGraphReady)
78
+ modelViewer.removeEventListener("scene-graph-ready", passthroughProps.onSceneGraphReady);
79
+ };
80
+ }, [modelViewer, passthroughProps.onArStatus, passthroughProps.onArTracking, passthroughProps.onCameraChange, passthroughProps.onEnvironmentChange, passthroughProps.onError, passthroughProps.onLoad, passthroughProps.onModelVisibility, passthroughProps.onPause, passthroughProps.onPlay, passthroughProps.onPreload, passthroughProps.onProgress, passthroughProps.onQuickLookButtonTapped, passthroughProps.onSceneGraphReady]);
81
+ if (modelViewerLoadedStatus !== "done") {
82
+ return null;
83
+ }
84
+ if (!((_b = (_a = data.sources) == null ? void 0 : _a[0]) == null ? void 0 : _b.url)) {
85
+ const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;
86
+ {
87
+ console.error(sourcesUrlError);
88
+ return null;
89
+ }
90
+ }
91
+ return /* @__PURE__ */ jsx("model-viewer", {
92
+ ref: callbackRef,
93
+ ...passthroughProps,
94
+ className,
95
+ id: (_c = passthroughProps.id) != null ? _c : data.id,
96
+ src: data.sources[0].url,
97
+ alt: (_d = data.alt) != null ? _d : null,
98
+ "camera-controls": (_e = passthroughProps.cameraControls) != null ? _e : true,
99
+ poster: (_g = passthroughProps.poster || ((_f = data.previewImage) == null ? void 0 : _f.url)) != null ? _g : null,
100
+ autoplay: (_h = passthroughProps.autoplay) != null ? _h : true,
101
+ loading: passthroughProps.loading,
102
+ reveal: passthroughProps.reveal,
103
+ ar: passthroughProps.ar,
104
+ "ar-modes": passthroughProps.arModes,
105
+ "ar-scale": passthroughProps.arScale,
106
+ "ar-placement": passthroughProps.arPlacement,
107
+ "ios-src": passthroughProps.iosSrc,
108
+ "touch-action": passthroughProps.touchAction,
109
+ "disable-zoom": passthroughProps.disableZoom,
110
+ "orbit-sensitivity": passthroughProps.orbitSensitivity,
111
+ "auto-rotate": passthroughProps.autoRotate,
112
+ "auto-rotate-delay": passthroughProps.autoRotateDelay,
113
+ "rotation-per-second": passthroughProps.rotationPerSecond,
114
+ "interaction-policy": passthroughProps.interactionPolicy,
115
+ "interaction-prompt": passthroughProps.interactionPrompt,
116
+ "interaction-prompt-style": passthroughProps.interactionPromptStyle,
117
+ "interaction-prompt-threshold": passthroughProps.interactionPromptThreshold,
118
+ "camera-orbit": passthroughProps.cameraOrbit,
119
+ "camera-target": passthroughProps.cameraTarget,
120
+ "field-of-view": passthroughProps.fieldOfView,
121
+ "max-camera-orbit": passthroughProps.maxCameraOrbit,
122
+ "min-camera-orbit": passthroughProps.minCameraOrbit,
123
+ "max-field-of-view": passthroughProps.maxFieldOfView,
124
+ "min-field-of-view": passthroughProps.minFieldOfView,
125
+ bounds: passthroughProps.bounds,
126
+ "interpolation-decay": (_i = passthroughProps.interpolationDecay) != null ? _i : 100,
127
+ "skybox-image": passthroughProps.skyboxImage,
128
+ "environment-image": passthroughProps.environmentImage,
129
+ exposure: passthroughProps.exposure,
130
+ "shadow-intensity": (_j = passthroughProps.shadowIntensity) != null ? _j : 0,
131
+ "shadow-softness": (_k = passthroughProps.shadowSoftness) != null ? _k : 0,
132
+ "animation-name": passthroughProps.animationName,
133
+ "animation-crossfade-duration": passthroughProps.animationCrossfadeDuration,
134
+ "variant-name": passthroughProps.variantName,
135
+ orientation: passthroughProps.orientation,
136
+ scale: passthroughProps.scale,
137
+ children
138
+ });
139
+ }
140
+ export {
141
+ ModelViewer
142
+ };
143
+ //# sourceMappingURL=ModelViewer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelViewer.mjs","sources":["../../src/ModelViewer.tsx"],"sourcesContent":["import {useState, useEffect, useCallback} from 'react';\nimport {useLoadScript} from './load-script.js';\nimport type {Model3d} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ModelViewerElement} from '@google/model-viewer/lib/model-viewer.js';\n\ntype PropsWeControl = 'src';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'model-viewer': PartialDeep<\n ModelViewerElement,\n {recurseIntoArrays: true}\n >;\n }\n }\n}\n\ntype ModelViewerProps = Omit<\n PartialDeep<JSX.IntrinsicElements['model-viewer'], {recurseIntoArrays: true}>,\n PropsWeControl\n> & {\n /** An object with fields that correspond to the Storefront API's [Model3D object](https://shopify.dev/api/storefront/latest/objects/model3d). */\n data: PartialDeep<Model3d, {recurseIntoArrays: true}>;\n /** The callback to invoke when the 'error' event is triggered. Refer to [error in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-error). */\n onError?: (event: Event) => void;\n /** The callback to invoke when the `load` event is triggered. Refer to [load in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-load). */\n onLoad?: (event: Event) => void;\n /** The callback to invoke when the 'preload' event is triggered. Refer to [preload in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-preload). */\n onPreload?: (event: Event) => void;\n /** The callback to invoke when the 'model-visibility' event is triggered. Refer to [model-visibility in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-modelVisibility). */\n onModelVisibility?: (event: Event) => void;\n /** The callback to invoke when the 'progress' event is triggered. Refer to [progress in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-loading-events-progress). */\n onProgress?: (event: Event) => void;\n /** The callback to invoke when the 'ar-status' event is triggered. Refer to [ar-status in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arStatus). */\n onArStatus?: (event: Event) => void;\n /** The callback to invoke when the 'ar-tracking' event is triggered. Refer to [ar-tracking in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-arTracking). */\n onArTracking?: (event: Event) => void;\n /** The callback to invoke when the 'quick-look-button-tapped' event is triggered. Refer to [quick-look-button-tapped in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-events-quickLookButtonTapped). */\n onQuickLookButtonTapped?: (event: Event) => void;\n /** The callback to invoke when the 'camera-change' event is triggered. Refer to [camera-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-events-cameraChange). */\n onCameraChange?: (event: Event) => void;\n /** The callback to invoke when the 'environment-change' event is triggered. Refer to [environment-change in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-lightingandenv-events-environmentChange). */\n onEnvironmentChange?: (event: Event) => void;\n /** The callback to invoke when the 'play' event is triggered. Refer to [play in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-play). */\n onPlay?: (event: Event) => void;\n /** The callback to invoke when the 'pause' event is triggered. Refer to [pause in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-animation-events-pause). */\n onPause?: (event: Event) => void;\n /** The callback to invoke when the 'scene-graph-ready' event is triggered. Refer to [scene-graph-ready in the <model-viewer> documentation](https://modelviewer.dev/docs/index.html#entrydocs-scenegraph-events-sceneGraphReady). */\n onSceneGraphReady?: (event: Event) => void;\n};\n\n/**\n * The `ModelViewer` component renders a 3D model (with the `model-viewer` custom element) for\n * the Storefront API's [Model3d object](https://shopify.dev/api/storefront/reference/products/model3d).\n *\n * The `model-viewer` custom element is lazily downloaded through a dynamically-injected `<script type=\"module\">` tag when the `<ModelViewer />` component is rendered\n *\n * ModelViewer is using version `1.21.1` of the `@google/model-viewer` library.\n */\nexport function ModelViewer(props: ModelViewerProps) {\n const [modelViewer, setModelViewer] = useState<undefined | HTMLElement>(\n undefined\n );\n const callbackRef = useCallback((node: HTMLElement) => {\n setModelViewer(node);\n }, []);\n const {data, children, className, ...passthroughProps} = props;\n\n const modelViewerLoadedStatus = useLoadScript(\n 'https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js',\n {\n module: true,\n }\n );\n\n useEffect(() => {\n if (!modelViewer) {\n return;\n }\n if (passthroughProps.onError)\n modelViewer.addEventListener('error', passthroughProps.onError);\n if (passthroughProps.onLoad)\n modelViewer.addEventListener('load', passthroughProps.onLoad);\n if (passthroughProps.onPreload)\n modelViewer.addEventListener('preload', passthroughProps.onPreload);\n if (passthroughProps.onModelVisibility)\n modelViewer.addEventListener(\n 'model-visibility',\n passthroughProps.onModelVisibility\n );\n if (passthroughProps.onProgress)\n modelViewer.addEventListener('progress', passthroughProps.onProgress);\n if (passthroughProps.onArStatus)\n modelViewer.addEventListener('ar-status', passthroughProps.onArStatus);\n if (passthroughProps.onArTracking)\n modelViewer.addEventListener(\n 'ar-tracking',\n passthroughProps.onArTracking\n );\n if (passthroughProps.onQuickLookButtonTapped)\n modelViewer.addEventListener(\n 'quick-look-button-tapped',\n passthroughProps.onQuickLookButtonTapped\n );\n if (passthroughProps.onCameraChange)\n modelViewer.addEventListener(\n 'camera-change',\n passthroughProps.onCameraChange\n );\n if (passthroughProps.onEnvironmentChange)\n modelViewer.addEventListener(\n 'environment-change',\n passthroughProps.onEnvironmentChange\n );\n if (passthroughProps.onPlay)\n modelViewer.addEventListener('play', passthroughProps.onPlay);\n if (passthroughProps.onPause)\n modelViewer.addEventListener('ar-status', passthroughProps.onPause);\n if (passthroughProps.onSceneGraphReady)\n modelViewer.addEventListener(\n 'scene-graph-ready',\n passthroughProps.onSceneGraphReady\n );\n\n return () => {\n if (modelViewer == null) {\n return;\n }\n if (passthroughProps.onError)\n modelViewer.removeEventListener('error', passthroughProps.onError);\n if (passthroughProps.onLoad)\n modelViewer.removeEventListener('load', passthroughProps.onLoad);\n if (passthroughProps.onPreload)\n modelViewer.removeEventListener('preload', passthroughProps.onPreload);\n if (passthroughProps.onModelVisibility)\n modelViewer.removeEventListener(\n 'model-visibility',\n passthroughProps.onModelVisibility\n );\n if (passthroughProps.onProgress)\n modelViewer.removeEventListener(\n 'progress',\n passthroughProps.onProgress\n );\n if (passthroughProps.onArStatus)\n modelViewer.removeEventListener(\n 'ar-status',\n passthroughProps.onArStatus\n );\n if (passthroughProps.onArTracking)\n modelViewer.removeEventListener(\n 'ar-tracking',\n passthroughProps.onArTracking\n );\n if (passthroughProps.onQuickLookButtonTapped)\n modelViewer.removeEventListener(\n 'quick-look-button-tapped',\n passthroughProps.onQuickLookButtonTapped\n );\n if (passthroughProps.onCameraChange)\n modelViewer.removeEventListener(\n 'camera-change',\n passthroughProps.onCameraChange\n );\n if (passthroughProps.onEnvironmentChange)\n modelViewer.removeEventListener(\n 'environment-change',\n passthroughProps.onEnvironmentChange\n );\n if (passthroughProps.onPlay)\n modelViewer.removeEventListener('play', passthroughProps.onPlay);\n if (passthroughProps.onPause)\n modelViewer.removeEventListener('ar-status', passthroughProps.onPause);\n if (passthroughProps.onSceneGraphReady)\n modelViewer.removeEventListener(\n 'scene-graph-ready',\n passthroughProps.onSceneGraphReady\n );\n };\n }, [\n modelViewer,\n passthroughProps.onArStatus,\n passthroughProps.onArTracking,\n passthroughProps.onCameraChange,\n passthroughProps.onEnvironmentChange,\n passthroughProps.onError,\n passthroughProps.onLoad,\n passthroughProps.onModelVisibility,\n passthroughProps.onPause,\n passthroughProps.onPlay,\n passthroughProps.onPreload,\n passthroughProps.onProgress,\n passthroughProps.onQuickLookButtonTapped,\n passthroughProps.onSceneGraphReady,\n ]);\n\n if (modelViewerLoadedStatus !== 'done') {\n // TODO: What do we want to display while the model-viewer library loads?\n return null;\n }\n\n if (!data.sources?.[0]?.url) {\n const sourcesUrlError = `<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(sourcesUrlError);\n } else {\n console.error(sourcesUrlError);\n return null;\n }\n }\n\n if (__HYDROGEN_DEV__ && !data.alt) {\n console.warn(\n `<ModelViewer/> requires the 'data.alt' prop for accessibility`\n );\n }\n\n return (\n <model-viewer\n // @ts-expect-error ref should exist\n ref={callbackRef}\n {...passthroughProps}\n className={className}\n id={passthroughProps.id ?? data.id}\n src={data.sources[0].url}\n alt={data.alt ?? null}\n camera-controls={passthroughProps.cameraControls ?? true}\n poster={(passthroughProps.poster || data.previewImage?.url) ?? null}\n autoplay={passthroughProps.autoplay ?? true}\n loading={passthroughProps.loading}\n reveal={passthroughProps.reveal}\n ar={passthroughProps.ar}\n ar-modes={passthroughProps.arModes}\n ar-scale={passthroughProps.arScale}\n // @ts-expect-error arPlacement should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-augmentedreality-attributes-arPlacement\n ar-placement={passthroughProps.arPlacement}\n ios-src={passthroughProps.iosSrc}\n touch-action={passthroughProps.touchAction}\n disable-zoom={passthroughProps.disableZoom}\n orbit-sensitivity={passthroughProps.orbitSensitivity}\n auto-rotate={passthroughProps.autoRotate}\n auto-rotate-delay={passthroughProps.autoRotateDelay}\n // @ts-expect-error rotationPerSecond should exist as a type, not sure why it doesn't. https://modelviewer.dev/docs/index.html#entrydocs-stagingandcameras-attributes-rotationPerSecond\n rotation-per-second={passthroughProps.rotationPerSecond}\n interaction-policy={passthroughProps.interactionPolicy}\n interaction-prompt={passthroughProps.interactionPrompt}\n interaction-prompt-style={passthroughProps.interactionPromptStyle}\n interaction-prompt-threshold={passthroughProps.interactionPromptThreshold}\n camera-orbit={passthroughProps.cameraOrbit}\n camera-target={passthroughProps.cameraTarget}\n field-of-view={passthroughProps.fieldOfView}\n max-camera-orbit={passthroughProps.maxCameraOrbit}\n min-camera-orbit={passthroughProps.minCameraOrbit}\n max-field-of-view={passthroughProps.maxFieldOfView}\n min-field-of-view={passthroughProps.minFieldOfView}\n bounds={passthroughProps.bounds}\n interpolation-decay={passthroughProps.interpolationDecay ?? 100}\n skybox-image={passthroughProps.skyboxImage}\n environment-image={passthroughProps.environmentImage}\n exposure={passthroughProps.exposure}\n shadow-intensity={passthroughProps.shadowIntensity ?? 0}\n shadow-softness={passthroughProps.shadowSoftness ?? 0}\n animation-name={passthroughProps.animationName}\n animation-crossfade-duration={passthroughProps.animationCrossfadeDuration}\n variant-name={passthroughProps.variantName}\n orientation={passthroughProps.orientation}\n scale={passthroughProps.scale}\n >\n {children}\n </model-viewer>\n );\n}\n"],"names":["ModelViewer","props","modelViewer","setModelViewer","useState","undefined","callbackRef","useCallback","node","data","children","className","passthroughProps","modelViewerLoadedStatus","useLoadScript","module","useEffect","onError","addEventListener","onLoad","onPreload","onModelVisibility","onProgress","onArStatus","onArTracking","onQuickLookButtonTapped","onCameraChange","onEnvironmentChange","onPlay","onPause","onSceneGraphReady","removeEventListener","sources","url","sourcesUrlError","console","error","id","alt","cameraControls","poster","previewImage","autoplay","loading","reveal","ar","arModes","arScale","arPlacement","iosSrc","touchAction","disableZoom","orbitSensitivity","autoRotate","autoRotateDelay","rotationPerSecond","interactionPolicy","interactionPrompt","interactionPromptStyle","interactionPromptThreshold","cameraOrbit","cameraTarget","fieldOfView","maxCameraOrbit","minCameraOrbit","maxFieldOfView","minFieldOfView","bounds","interpolationDecay","skyboxImage","environmentImage","exposure","shadowIntensity","shadowSoftness","animationName","animationCrossfadeDuration","variantName","orientation","scale"],"mappings":";;;AA8DO,SAASA,YAAYC,OAAyB;;AACnD,QAAM,CAACC,aAAaC,cAAd,IAAgCC,SACpCC,MAD4C;AAGxCC,QAAAA,cAAcC,YAAY,CAACC,SAA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,IAChC,iBAAejD,iBAAiBkD;AAAAA,IAChC,oBAAkBlD,iBAAiBmD;AAAAA,IACnC,oBAAkBnD,iBAAiBoD;AAAAA,IACnC,qBAAmBpD,iBAAiBqD;AAAAA,IACpC,qBAAmBrD,iBAAiBsD;AAAAA,IACpC,QAAQtD,iBAAiBuD;AAAAA,IACzB,wBAAqBvD,sBAAiBwD,uBAAjBxD,YAAuC;AAAA,IAC5D,gBAAcA,iBAAiByD;AAAAA,IAC/B,qBAAmBzD,iBAAiB0D;AAAAA,IACpC,UAAU1D,iBAAiB2D;AAAAA,IAC3B,qBAAkB3D,sBAAiB4D,oBAAjB5D,YAAoC;AAAA,IACtD,oBAAiBA,sBAAiB6D,mBAAjB7D,YAAmC;AAAA,IACpD,kBAAgBA,iBAAiB8D;AAAAA,IACjC,gCAA8B9D,iBAAiB+D;AAAAA,IAC/C,gBAAc/D,iBAAiBgE;AAAAA,IAC/B,aAAahE,iBAAiBiE;AAAAA,IAC9B,OAAOjE,iBAAiBkE;AAAAA,IAhD1B;AAAA,EAAA,CADF;AAsDD;"}
File without changes
File without changes
@@ -0,0 +1,40 @@
1
+ import { useMoney } from "./useMoney.mjs";
2
+ import { jsxs, Fragment } from "react/jsx-runtime";
3
+ function Money({
4
+ data,
5
+ as,
6
+ withoutCurrency,
7
+ withoutTrailingZeros,
8
+ measurement,
9
+ measurementSeparator = "/",
10
+ ...passthroughProps
11
+ }) {
12
+ if (!isMoney(data)) {
13
+ throw new Error(`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`);
14
+ }
15
+ const moneyObject = useMoney(data);
16
+ const Wrapper = as != null ? as : "div";
17
+ let output = moneyObject.localizedString;
18
+ if (withoutCurrency || withoutTrailingZeros) {
19
+ if (withoutCurrency && !withoutTrailingZeros) {
20
+ output = moneyObject.amount;
21
+ } else if (!withoutCurrency && withoutTrailingZeros) {
22
+ output = moneyObject.withoutTrailingZeros;
23
+ } else {
24
+ output = moneyObject.withoutTrailingZerosAndCurrency;
25
+ }
26
+ }
27
+ return /* @__PURE__ */ jsxs(Wrapper, {
28
+ ...passthroughProps,
29
+ children: [output, measurement && measurement.referenceUnit && /* @__PURE__ */ jsxs(Fragment, {
30
+ children: [measurementSeparator, measurement.referenceUnit]
31
+ })]
32
+ });
33
+ }
34
+ function isMoney(maybeMoney) {
35
+ return typeof maybeMoney.amount === "string" && !!maybeMoney.amount && typeof maybeMoney.currencyCode === "string" && !!maybeMoney.currencyCode;
36
+ }
37
+ export {
38
+ Money
39
+ };
40
+ //# sourceMappingURL=Money.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Money.mjs","sources":["../../src/Money.tsx"],"sourcesContent":["import {type ReactNode} from 'react';\nimport {useMoney} from './useMoney.js';\nimport type {MoneyV2, UnitPriceMeasurement} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ninterface CustomProps<ComponentGeneric extends React.ElementType> {\n /** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */\n as?: ComponentGeneric;\n /** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */\n data: PartialDeep<MoneyV2, {recurseIntoArrays: true}>;\n /** Whether to remove the currency symbol from the output. */\n withoutCurrency?: boolean;\n /** Whether to remove trailing zeros (fractional money) from the output. */\n withoutTrailingZeros?: boolean;\n /** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */\n measurement?: PartialDeep<UnitPriceMeasurement, {recurseIntoArrays: true}>;\n /** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */\n measurementSeparator?: ReactNode;\n}\n\n// This article helps understand the typing here https://www.benmvp.com/blog/polymorphic-react-components-typescript/ Ben is the best :)\nexport type MoneyProps<ComponentGeneric extends React.ElementType> =\n CustomProps<ComponentGeneric> &\n Omit<\n React.ComponentPropsWithoutRef<ComponentGeneric>,\n keyof CustomProps<ComponentGeneric>\n >;\n\n/**\n * The `Money` component renders a string of the Storefront API's\n * [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the\n * `locale` in the `ShopifyProvider` component.\n */\nexport function Money<ComponentGeneric extends React.ElementType>({\n data,\n as,\n withoutCurrency,\n withoutTrailingZeros,\n measurement,\n measurementSeparator = '/',\n ...passthroughProps\n}: MoneyProps<ComponentGeneric>) {\n if (!isMoney(data)) {\n throw new Error(\n `<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`\n );\n }\n const moneyObject = useMoney(data);\n const Wrapper = as ?? 'div';\n\n let output = moneyObject.localizedString;\n\n if (withoutCurrency || withoutTrailingZeros) {\n if (withoutCurrency && !withoutTrailingZeros) {\n output = moneyObject.amount;\n } else if (!withoutCurrency && withoutTrailingZeros) {\n output = moneyObject.withoutTrailingZeros;\n } else {\n // both\n output = moneyObject.withoutTrailingZerosAndCurrency;\n }\n }\n\n return (\n <Wrapper {...passthroughProps}>\n {output}\n {measurement && measurement.referenceUnit && (\n <>\n {measurementSeparator}\n {measurement.referenceUnit}\n </>\n )}\n </Wrapper>\n );\n}\n\n// required in order to narrow the money object down and make TS happy\nfunction isMoney(\n maybeMoney: PartialDeep<MoneyV2, {recurseIntoArrays: true}>\n): maybeMoney is MoneyV2 {\n return (\n typeof maybeMoney.amount === 'string' &&\n !!maybeMoney.amount &&\n typeof maybeMoney.currencyCode === 'string' &&\n !!maybeMoney.currencyCode\n );\n}\n"],"names":["Money","data","as","withoutCurrency","withoutTrailingZeros","measurement","measurementSeparator","passthroughProps","isMoney","Error","moneyObject","useMoney","Wrapper","output","localizedString","amount","withoutTrailingZerosAndCurrency","referenceUnit","_Fragment","maybeMoney","currencyCode"],"mappings":";;AAiCO,SAASA,MAAkD;AAAA,EAChEC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,uBAAuB;AAAA,KACpBC;AAP6D,GAQjC;AAC3B,MAAA,CAACC,QAAQP,IAAD,GAAQ;AACZ,UAAA,IAAIQ,MACP,yEADG;AAAA,EAGP;AACKC,QAAAA,cAAcC,SAASV,IAAD;AAC5B,QAAMW,UAAUV,kBAAM;AAEtB,MAAIW,SAASH,YAAYI;AAEzB,MAAIX,mBAAmBC,sBAAsB;AACvCD,QAAAA,mBAAmB,CAACC,sBAAsB;AAC5CS,eAASH,YAAYK;AAAAA,IAAAA,WACZ,CAACZ,mBAAmBC,sBAAsB;AACnDS,eAASH,YAAYN;AAAAA,IAAAA,OAChB;AAELS,eAASH,YAAYM;AAAAA,IACtB;AAAA,EACF;AAED,8BACG,SAAD;AAAA,IAAA,GAAaT;AAAAA,IAAb,UAAA,CACGM,QACAR,eAAeA,YAAYY,sCAC1BC,UAAA;AAAA,MAAA,UAAA,CACGZ,sBACAD,YAAYY,aAFf;AAAA,IAAA,CAHJ,CAAA;AAAA,EAAA,CADF;AAWD;AAGD,SAAST,QACPW,YACuB;AACvB,SACE,OAAOA,WAAWJ,WAAW,YAC7B,CAAC,CAACI,WAAWJ,UACb,OAAOI,WAAWC,iBAAiB,YACnC,CAAC,CAACD,WAAWC;AAEhB;"}
File without changes
File without changes
@@ -0,0 +1,61 @@
1
+ import { Money } from "./Money.mjs";
2
+ import { flattenConnection } from "./flatten-connection.mjs";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function ProductPrice(props) {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6
+ const {
7
+ priceType = "regular",
8
+ variantId,
9
+ valueType = "min",
10
+ data: product,
11
+ ...passthroughProps
12
+ } = props;
13
+ if (product == null) {
14
+ throw new Error(`<ProductPrice/> requires a product as the 'data' prop`);
15
+ }
16
+ let price;
17
+ let measurement;
18
+ const variant = variantId ? (_b = flattenConnection((_a = product == null ? void 0 : product.variants) != null ? _a : {}).find((variant2) => (variant2 == null ? void 0 : variant2.id) === variantId)) != null ? _b : null : null;
19
+ if (priceType === "compareAt") {
20
+ if (variantId && variant) {
21
+ if (((_c = variant.compareAtPriceV2) == null ? void 0 : _c.amount) === ((_d = variant.priceV2) == null ? void 0 : _d.amount)) {
22
+ return null;
23
+ }
24
+ price = variant.compareAtPriceV2;
25
+ } else if (valueType === "max") {
26
+ price = (_e = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _e.maxVariantPrice;
27
+ } else {
28
+ price = (_f = product == null ? void 0 : product.compareAtPriceRange) == null ? void 0 : _f.minVariantPrice;
29
+ }
30
+ } else {
31
+ if (variantId && variant) {
32
+ price = variant.priceV2;
33
+ if (valueType === "unit") {
34
+ price = variant.unitPrice;
35
+ measurement = variant.unitPriceMeasurement;
36
+ }
37
+ } else if (valueType === "max") {
38
+ price = (_g = product.priceRange) == null ? void 0 : _g.maxVariantPrice;
39
+ } else {
40
+ price = (_h = product.priceRange) == null ? void 0 : _h.minVariantPrice;
41
+ }
42
+ }
43
+ if (!price) {
44
+ return null;
45
+ }
46
+ if (measurement) {
47
+ return /* @__PURE__ */ jsx(Money, {
48
+ ...passthroughProps,
49
+ data: price,
50
+ measurement
51
+ });
52
+ }
53
+ return /* @__PURE__ */ jsx(Money, {
54
+ ...passthroughProps,
55
+ data: price
56
+ });
57
+ }
58
+ export {
59
+ ProductPrice
60
+ };
61
+ //# sourceMappingURL=ProductPrice.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductPrice.mjs","sources":["../../src/ProductPrice.tsx"],"sourcesContent":["import type {\n MoneyV2,\n UnitPriceMeasurement,\n Product,\n} from './storefront-api-types.js';\nimport {Money, type MoneyProps} from './Money.js';\nimport type {PartialDeep} from 'type-fest';\nimport {flattenConnection} from './flatten-connection.js';\n\nexport interface ProductPriceProps {\n /** A [Product object](https://shopify.dev/api/storefront/reference/products/product). */\n data: PartialDeep<Product, {recurseIntoArrays: true}>;\n /** The type of price. Valid values: `regular` (default) or `compareAt`. */\n priceType?: 'regular' | 'compareAt';\n /** The type of value. Valid values: `min` (default), `max` or `unit`. */\n valueType?: 'max' | 'min' | 'unit';\n /** The ID of the variant. */\n variantId?: string;\n}\n\n/**\n * The `ProductPrice` component renders a `Money` component with the product\n * [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.\n */\nexport function ProductPrice<ComponentGeneric extends React.ElementType>(\n props: ProductPriceProps &\n Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>\n) {\n const {\n priceType = 'regular',\n variantId,\n valueType = 'min',\n data: product,\n ...passthroughProps\n } = props;\n\n if (product == null) {\n throw new Error(`<ProductPrice/> requires a product as the 'data' prop`);\n }\n\n let price: Partial<MoneyV2> | undefined | null;\n let measurement: Partial<UnitPriceMeasurement> | undefined | null;\n\n const variant = variantId\n ? flattenConnection(product?.variants ?? {}).find(\n (variant) => variant?.id === variantId\n ) ?? null\n : null;\n\n if (priceType === 'compareAt') {\n if (variantId && variant) {\n if (variant.compareAtPriceV2?.amount === variant.priceV2?.amount) {\n return null;\n }\n price = variant.compareAtPriceV2;\n } else if (valueType === 'max') {\n price = product?.compareAtPriceRange?.maxVariantPrice;\n } else {\n price = product?.compareAtPriceRange?.minVariantPrice;\n }\n } else {\n if (variantId && variant) {\n price = variant.priceV2;\n if (valueType === 'unit') {\n price = variant.unitPrice;\n measurement = variant.unitPriceMeasurement;\n }\n } else if (valueType === 'max') {\n price = product.priceRange?.maxVariantPrice;\n } else {\n price = product.priceRange?.minVariantPrice;\n }\n }\n\n if (!price) {\n return null;\n }\n\n if (measurement) {\n return (\n <Money {...passthroughProps} data={price} measurement={measurement} />\n );\n }\n\n return <Money {...passthroughProps} data={price} />;\n}\n"],"names":["ProductPrice","props","priceType","variantId","valueType","data","product","passthroughProps","Error","price","measurement","variant","flattenConnection","variants","find","id","compareAtPriceV2","amount","priceV2","compareAtPriceRange","maxVariantPrice","minVariantPrice","unitPrice","unitPriceMeasurement","priceRange"],"mappings":";;;AAwBO,SAASA,aACdC,OAEA;;AACM,QAAA;AAAA,IACJC,YAAY;AAAA,IACZC;AAAAA,IACAC,YAAY;AAAA,IACZC,MAAMC;AAAAA,OACHC;AAAAA,EACDN,IAAAA;AAEJ,MAAIK,WAAW,MAAM;AACb,UAAA,IAAIE,MAAO,uDAAX;AAAA,EACP;AAEGC,MAAAA;AACAC,MAAAA;AAEJ,QAAMC,UAAUR,aACZS,wBAAkBN,wCAASO,aAATP,YAAqB,CAAA,CAAtB,EAA0BQ,KACxCH,CAAAA,cAAYA,qCAASI,QAAOZ,SAD/B,MAAAS,YAEK,OACL;AAEJ,MAAIV,cAAc,aAAa;AAC7B,QAAIC,aAAaQ,SAAS;AACxB,YAAIA,aAAQK,qBAARL,mBAA0BM,cAAWN,aAAQO,YAARP,mBAAiBM,SAAQ;AACzD,eAAA;AAAA,MACR;AACDR,cAAQE,QAAQK;AAAAA,IAAAA,WACPZ,cAAc,OAAO;AAC9BK,eAAQH,wCAASa,wBAATb,mBAA8Bc;AAAAA,IAAAA,OACjC;AACLX,eAAQH,wCAASa,wBAATb,mBAA8Be;AAAAA,IACvC;AAAA,EAAA,OACI;AACL,QAAIlB,aAAaQ,SAAS;AACxBF,cAAQE,QAAQO;AAChB,UAAId,cAAc,QAAQ;AACxBK,gBAAQE,QAAQW;AAChBZ,sBAAcC,QAAQY;AAAAA,MACvB;AAAA,IAAA,WACQnB,cAAc,OAAO;AAC9BK,eAAQH,aAAQkB,eAARlB,mBAAoBc;AAAAA,IAAAA,OACvB;AACLX,eAAQH,aAAQkB,eAARlB,mBAAoBe;AAAAA,IAC7B;AAAA,EACF;AAED,MAAI,CAACZ,OAAO;AACH,WAAA;AAAA,EACR;AAED,MAAIC,aAAa;AACf,+BACG,OAAD;AAAA,MAAA,GAAWH;AAAAA,MAAkB,MAAME;AAAAA,MAAO;AAAA,IAAA,CAD5C;AAAA,EAGD;AAED,6BAAQ,OAAD;AAAA,IAAA,GAAWF;AAAAA,IAAkB,MAAME;AAAAA,EAAAA,CAA1C;AACD;"}
File without changes
File without changes
@@ -0,0 +1,161 @@
1
+ import { createContext, useMemo, useState, useEffect, useCallback, useContext } from "react";
2
+ import { flattenConnection } from "./flatten-connection.mjs";
3
+ import { jsx } from "react/jsx-runtime";
4
+ const ProductOptionsContext = createContext(null);
5
+ function ProductProvider({
6
+ children,
7
+ data: product,
8
+ initialVariantId: explicitVariantId
9
+ }) {
10
+ const variants = useMemo(() => {
11
+ var _a;
12
+ return flattenConnection((_a = product.variants) != null ? _a : {});
13
+ }, [product.variants]);
14
+ if (!isProductVariantArray(variants)) {
15
+ throw new Error(`<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'`);
16
+ }
17
+ const options = useMemo(() => getOptions(variants), [variants]);
18
+ const [selectedVariant, setSelectedVariant] = useState(() => getVariantBasedOnIdProp(explicitVariantId, variants));
19
+ const [selectedOptions, setSelectedOptions] = useState(() => getSelectedOptions(selectedVariant));
20
+ useEffect(() => {
21
+ const newSelectedVariant = getVariantBasedOnIdProp(explicitVariantId, variants);
22
+ setSelectedVariant(newSelectedVariant);
23
+ setSelectedOptions(getSelectedOptions(newSelectedVariant));
24
+ }, [explicitVariantId, variants]);
25
+ const setSelectedOption = useCallback((name, value2) => {
26
+ setSelectedOptions((selectedOptions2) => {
27
+ const opts = {
28
+ ...selectedOptions2,
29
+ [name]: value2
30
+ };
31
+ setSelectedVariant(getSelectedVariant(variants, opts));
32
+ return opts;
33
+ });
34
+ }, [setSelectedOptions, variants]);
35
+ const isOptionInStock = useCallback((option, value2) => {
36
+ var _a;
37
+ const proposedVariant = getSelectedVariant(variants, {
38
+ ...selectedOptions,
39
+ ...{
40
+ [option]: value2
41
+ }
42
+ });
43
+ return (_a = proposedVariant == null ? void 0 : proposedVariant.availableForSale) != null ? _a : true;
44
+ }, [selectedOptions, variants]);
45
+ const sellingPlanGroups = useMemo(() => {
46
+ var _a;
47
+ return flattenConnection((_a = product.sellingPlanGroups) != null ? _a : {}).map((sellingPlanGroup) => {
48
+ var _a2;
49
+ return {
50
+ ...sellingPlanGroup,
51
+ sellingPlans: flattenConnection((_a2 = sellingPlanGroup == null ? void 0 : sellingPlanGroup.sellingPlans) != null ? _a2 : {})
52
+ };
53
+ });
54
+ }, [product.sellingPlanGroups]);
55
+ const [selectedSellingPlan, setSelectedSellingPlan] = useState(void 0);
56
+ const selectedSellingPlanAllocation = useMemo(() => {
57
+ var _a, _b;
58
+ if (!selectedVariant || !selectedSellingPlan) {
59
+ return;
60
+ }
61
+ if (!((_a = selectedVariant.sellingPlanAllocations) == null ? void 0 : _a.nodes) && !((_b = selectedVariant.sellingPlanAllocations) == null ? void 0 : _b.edges)) {
62
+ throw new Error(`<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation`);
63
+ }
64
+ return flattenConnection(selectedVariant.sellingPlanAllocations).find((allocation) => {
65
+ var _a2;
66
+ return ((_a2 = allocation == null ? void 0 : allocation.sellingPlan) == null ? void 0 : _a2.id) === selectedSellingPlan.id;
67
+ });
68
+ }, [selectedVariant, selectedSellingPlan]);
69
+ const value = useMemo(() => ({
70
+ variants,
71
+ variantsConnection: product.variants,
72
+ options,
73
+ selectedVariant,
74
+ setSelectedVariant,
75
+ selectedOptions,
76
+ setSelectedOption,
77
+ setSelectedOptions,
78
+ isOptionInStock,
79
+ selectedSellingPlan,
80
+ setSelectedSellingPlan,
81
+ selectedSellingPlanAllocation,
82
+ sellingPlanGroups,
83
+ sellingPlanGroupsConnection: product.sellingPlanGroups
84
+ }), [isOptionInStock, options, product.sellingPlanGroups, product.variants, selectedOptions, selectedSellingPlan, selectedSellingPlanAllocation, selectedVariant, sellingPlanGroups, setSelectedOption, variants]);
85
+ return /* @__PURE__ */ jsx(ProductOptionsContext.Provider, {
86
+ value,
87
+ children
88
+ });
89
+ }
90
+ function useProduct() {
91
+ const context = useContext(ProductOptionsContext);
92
+ if (!context) {
93
+ throw new Error(`'useProduct' must be a child of <ProductProvider />`);
94
+ }
95
+ return context;
96
+ }
97
+ function getSelectedVariant(variants, choices) {
98
+ var _a, _b;
99
+ if (!variants.length || ((_b = (_a = variants == null ? void 0 : variants[0]) == null ? void 0 : _a.selectedOptions) == null ? void 0 : _b.length) !== Object.keys(choices).length) {
100
+ return;
101
+ }
102
+ return variants == null ? void 0 : variants.find((variant) => {
103
+ return Object.entries(choices).every(([name, value]) => {
104
+ var _a2;
105
+ return (_a2 = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a2.some((option) => (option == null ? void 0 : option.name) === name && (option == null ? void 0 : option.value) === value);
106
+ });
107
+ });
108
+ }
109
+ function getOptions(variants) {
110
+ const map = variants.reduce((memo, variant) => {
111
+ var _a;
112
+ if (!variant.selectedOptions) {
113
+ throw new Error(`'getOptions' requires 'variant.selectedOptions'`);
114
+ }
115
+ (_a = variant == null ? void 0 : variant.selectedOptions) == null ? void 0 : _a.forEach((opt) => {
116
+ var _a2, _b, _c, _d;
117
+ memo[(_a2 = opt == null ? void 0 : opt.name) != null ? _a2 : ""] = memo[(_b = opt == null ? void 0 : opt.name) != null ? _b : ""] || /* @__PURE__ */ new Set();
118
+ memo[(_c = opt == null ? void 0 : opt.name) != null ? _c : ""].add((_d = opt == null ? void 0 : opt.value) != null ? _d : "");
119
+ });
120
+ return memo;
121
+ }, {});
122
+ return Object.keys(map).map((option) => {
123
+ return {
124
+ name: option,
125
+ values: Array.from(map[option])
126
+ };
127
+ });
128
+ }
129
+ function getVariantBasedOnIdProp(explicitVariantId, variants) {
130
+ if (explicitVariantId) {
131
+ const foundVariant = variants.find((variant) => (variant == null ? void 0 : variant.id) === explicitVariantId);
132
+ if (!foundVariant) {
133
+ console.warn(`<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID`);
134
+ }
135
+ return foundVariant;
136
+ }
137
+ if (explicitVariantId === null) {
138
+ return null;
139
+ }
140
+ if (explicitVariantId === void 0) {
141
+ return variants.find((variant) => variant == null ? void 0 : variant.availableForSale) || variants[0];
142
+ }
143
+ }
144
+ function getSelectedOptions(selectedVariant) {
145
+ return (selectedVariant == null ? void 0 : selectedVariant.selectedOptions) ? selectedVariant.selectedOptions.reduce((memo, optionSet) => {
146
+ var _a, _b;
147
+ memo[(_a = optionSet == null ? void 0 : optionSet.name) != null ? _a : ""] = (_b = optionSet == null ? void 0 : optionSet.value) != null ? _b : "";
148
+ return memo;
149
+ }, {}) : {};
150
+ }
151
+ function isProductVariantArray(maybeVariantArray) {
152
+ if (!maybeVariantArray || !Array.isArray(maybeVariantArray)) {
153
+ return false;
154
+ }
155
+ return true;
156
+ }
157
+ export {
158
+ ProductProvider,
159
+ useProduct
160
+ };
161
+ //# sourceMappingURL=ProductProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductProvider.mjs","sources":["../../src/ProductProvider.tsx"],"sourcesContent":["import {\n useMemo,\n useState,\n useEffect,\n useCallback,\n createContext,\n useContext,\n} from 'react';\nimport type {\n SelectedOption as SelectedOptionType,\n SellingPlan,\n SellingPlanAllocation,\n Product,\n ProductVariant as ProductVariantType,\n ProductVariantConnection,\n SellingPlan as SellingPlanType,\n SellingPlanAllocation as SellingPlanAllocationType,\n SellingPlanGroup as SellingPlanGroupType,\n SellingPlanGroupConnection,\n} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport {flattenConnection} from './flatten-connection.js';\n\nconst ProductOptionsContext = createContext<ProductHookValue | null>(null);\n\ntype InitialVariantId = ProductVariantType['id'] | null;\n\ninterface ProductProviderProps {\n /** A [Product object](https://shopify.dev/api/storefront/reference/products/product). */\n data: PartialDeep<Product, {recurseIntoArrays: true}>;\n /** A `ReactNode` element. */\n children: React.ReactNode;\n /**\n * The initially selected variant.\n * The following logic applies to `initialVariantId`:\n * 1. If `initialVariantId` is provided, then it's used even if it's out of stock.\n * 2. If `initialVariantId` is provided but is `null`, then no variant is used.\n * 3. If nothing is passed to `initialVariantId` then the first available / in-stock variant is used.\n * 4. If nothing is passed to `initialVariantId` and no variants are in stock, then the first variant is used.\n */\n initialVariantId?: InitialVariantId;\n}\n\n/**\n * `<ProductProvider />` is a context provider that enables use of the `useProduct()` hook.\n *\n * It helps manage selected options and variants for a product.\n */\nexport function ProductProvider({\n children,\n data: product,\n initialVariantId: explicitVariantId,\n}: ProductProviderProps) {\n // The flattened variants\n const variants = useMemo(\n () => flattenConnection(product.variants ?? {}),\n [product.variants]\n );\n\n if (!isProductVariantArray(variants)) {\n throw new Error(\n `<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'`\n );\n }\n\n // All the options available for a product, based on all the variants\n const options = useMemo(() => getOptions(variants), [variants]);\n\n /**\n * Track the selectedVariant within the provider.\n */\n const [selectedVariant, setSelectedVariant] = useState<\n | PartialDeep<ProductVariantType, {recurseIntoArrays: true}>\n | undefined\n | null\n >(() => getVariantBasedOnIdProp(explicitVariantId, variants));\n\n /**\n * Track the selectedOptions within the provider. If a `initialVariantId`\n * is passed, use that to select initial options.\n */\n const [selectedOptions, setSelectedOptions] = useState<SelectedOptions>(() =>\n getSelectedOptions(selectedVariant)\n );\n\n /**\n * When the initialVariantId changes, we need to make sure we\n * update the selected variant and selected options. If not,\n * then the selected variant and options will reference incorrect\n * values.\n */\n useEffect(() => {\n const newSelectedVariant = getVariantBasedOnIdProp(\n explicitVariantId,\n variants\n );\n setSelectedVariant(newSelectedVariant);\n setSelectedOptions(getSelectedOptions(newSelectedVariant));\n }, [explicitVariantId, variants]);\n\n /**\n * Allow the developer to select an option.\n */\n const setSelectedOption = useCallback(\n (name: string, value: string) => {\n setSelectedOptions((selectedOptions) => {\n const opts = {...selectedOptions, [name]: value};\n setSelectedVariant(getSelectedVariant(variants, opts));\n return opts;\n });\n },\n [setSelectedOptions, variants]\n );\n\n const isOptionInStock = useCallback(\n (option: string, value: string) => {\n const proposedVariant = getSelectedVariant(variants, {\n ...selectedOptions,\n ...{[option]: value},\n });\n\n return proposedVariant?.availableForSale ?? true;\n },\n [selectedOptions, variants]\n );\n\n const sellingPlanGroups = useMemo(\n () =>\n flattenConnection(product.sellingPlanGroups ?? {}).map(\n (sellingPlanGroup) => ({\n ...sellingPlanGroup,\n sellingPlans: flattenConnection(sellingPlanGroup?.sellingPlans ?? {}),\n })\n ),\n [product.sellingPlanGroups]\n );\n\n /**\n * Track the selectedSellingPlan within the hook. If `initialSellingPlanId`\n * is passed, use that as an initial value. Look it up from the `selectedVariant`, since\n * that is also a requirement.\n */\n const [selectedSellingPlan, setSelectedSellingPlan] = useState<\n PartialDeep<SellingPlan, {recurseIntoArrays: true}> | undefined\n >(undefined);\n\n const selectedSellingPlanAllocation = useMemo<\n PartialDeep<SellingPlanAllocation, {recurseIntoArrays: true}> | undefined\n >(() => {\n if (!selectedVariant || !selectedSellingPlan) {\n return;\n }\n\n if (\n !selectedVariant.sellingPlanAllocations?.nodes &&\n !selectedVariant.sellingPlanAllocations?.edges\n ) {\n throw new Error(\n `<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation`\n );\n }\n\n return flattenConnection(selectedVariant.sellingPlanAllocations).find(\n (allocation) => allocation?.sellingPlan?.id === selectedSellingPlan.id\n );\n }, [selectedVariant, selectedSellingPlan]);\n\n const value = useMemo<ProductHookValue>(\n () => ({\n variants,\n variantsConnection: product.variants,\n options,\n selectedVariant,\n setSelectedVariant,\n selectedOptions,\n setSelectedOption,\n setSelectedOptions,\n isOptionInStock,\n selectedSellingPlan,\n setSelectedSellingPlan,\n selectedSellingPlanAllocation,\n sellingPlanGroups,\n sellingPlanGroupsConnection: product.sellingPlanGroups,\n }),\n [\n isOptionInStock,\n options,\n product.sellingPlanGroups,\n product.variants,\n selectedOptions,\n selectedSellingPlan,\n selectedSellingPlanAllocation,\n selectedVariant,\n sellingPlanGroups,\n setSelectedOption,\n variants,\n ]\n );\n\n return (\n <ProductOptionsContext.Provider value={value}>\n {children}\n </ProductOptionsContext.Provider>\n );\n}\n\n/**\n * Provides access to the context value provided by `<ProductProvider />`. Must be a descendent of `<ProductProvider />`.\n */\nexport function useProduct() {\n const context = useContext(ProductOptionsContext);\n\n if (!context) {\n throw new Error(`'useProduct' must be a child of <ProductProvider />`);\n }\n\n return context;\n}\n\nfunction getSelectedVariant(\n variants: PartialDeep<ProductVariantType, {recurseIntoArrays: true}>[],\n choices: SelectedOptions\n): PartialDeep<ProductVariantType, {recurseIntoArrays: true}> | undefined {\n /**\n * Ensure the user has selected all the required options, not just some.\n */\n if (\n !variants.length ||\n variants?.[0]?.selectedOptions?.length !== Object.keys(choices).length\n ) {\n return;\n }\n\n return variants?.find((variant) => {\n return Object.entries(choices).every(([name, value]) => {\n return variant?.selectedOptions?.some(\n (option) => option?.name === name && option?.value === value\n );\n });\n });\n}\n\nfunction getOptions(\n variants: PartialDeep<ProductVariantType, {recurseIntoArrays: true}>[]\n): OptionWithValues[] {\n const map = variants.reduce((memo, variant) => {\n if (!variant.selectedOptions) {\n throw new Error(`'getOptions' requires 'variant.selectedOptions'`);\n }\n variant?.selectedOptions?.forEach((opt) => {\n memo[opt?.name ?? ''] = memo[opt?.name ?? ''] || new Set();\n memo[opt?.name ?? ''].add(opt?.value ?? '');\n });\n\n return memo;\n }, {} as Record<string, Set<string>>);\n\n return Object.keys(map).map((option) => {\n return {\n name: option,\n values: Array.from(map[option]),\n };\n });\n}\n\nfunction getVariantBasedOnIdProp(\n explicitVariantId: InitialVariantId | undefined,\n variants: Array<\n PartialDeep<ProductVariantType, {recurseIntoArrays: true}> | undefined\n >\n) {\n // get the initial variant based on the logic outlined in the comments for 'initialVariantId' above\n // * 1. If `initialVariantId` is provided, then it's used even if it's out of stock.\n if (explicitVariantId) {\n const foundVariant = variants.find(\n (variant) => variant?.id === explicitVariantId\n );\n if (!foundVariant) {\n console.warn(\n `<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID`\n );\n }\n return foundVariant;\n }\n // * 2. If `initialVariantId` is provided but is `null`, then no variant is used.\n if (explicitVariantId === null) {\n return null;\n }\n // * 3. If nothing is passed to `initialVariantId` then the first available / in-stock variant is used.\n // * 4. If nothing is passed to `initialVariantId` and no variants are in stock, then the first variant is used.\n if (explicitVariantId === undefined) {\n return variants.find((variant) => variant?.availableForSale) || variants[0];\n }\n}\n\nfunction getSelectedOptions(\n selectedVariant:\n | PartialDeep<ProductVariantType, {recurseIntoArrays: true}>\n | undefined\n | null\n): SelectedOptions {\n return selectedVariant?.selectedOptions\n ? selectedVariant.selectedOptions.reduce<SelectedOptions>(\n (memo, optionSet) => {\n memo[optionSet?.name ?? ''] = optionSet?.value ?? '';\n return memo;\n },\n {}\n )\n : {};\n}\n\nfunction isProductVariantArray(\n maybeVariantArray:\n | (PartialDeep<ProductVariantType, {recurseIntoArrays: true}> | undefined)[]\n | undefined\n): maybeVariantArray is PartialDeep<\n ProductVariantType,\n {recurseIntoArrays: true}\n>[] {\n if (!maybeVariantArray || !Array.isArray(maybeVariantArray)) {\n return false;\n }\n\n return true;\n}\n\nexport interface OptionWithValues {\n name: SelectedOptionType['name'];\n values: SelectedOptionType['value'][];\n}\n\ntype ProductHookValue = PartialDeep<\n {\n /** An array of the variant `nodes` from the `VariantConnection`. */\n variants: ProductVariantType[];\n variantsConnection?: ProductVariantConnection;\n /** An array of the product's options and values. */\n options: OptionWithValues[];\n /** The selected variant. */\n selectedVariant?: ProductVariantType | null;\n selectedOptions: SelectedOptions;\n /** The selected selling plan. */\n selectedSellingPlan?: SellingPlanType;\n /** The selected selling plan allocation. */\n selectedSellingPlanAllocation?: SellingPlanAllocationType;\n /** The selling plan groups. */\n sellingPlanGroups?: (Omit<SellingPlanGroupType, 'sellingPlans'> & {\n sellingPlans: SellingPlanType[];\n })[];\n sellingPlanGroupsConnection?: SellingPlanGroupConnection;\n },\n {recurseIntoArrays: true}\n> & {\n /** A callback to set the selected variant to the variant passed as an argument. */\n setSelectedVariant: (\n variant: PartialDeep<ProductVariantType, {recurseIntoArrays: true}> | null\n ) => void;\n /** A callback to set the selected option. */\n setSelectedOption: (\n name: SelectedOptionType['name'],\n value: SelectedOptionType['value']\n ) => void;\n /** A callback to set multiple selected options at once. */\n setSelectedOptions: (options: SelectedOptions) => void;\n /** A callback to set the selected selling plan to the one passed as an argument. */\n setSelectedSellingPlan: (\n sellingPlan: PartialDeep<SellingPlanType, {recurseIntoArrays: true}>\n ) => void;\n /** A callback that returns a boolean indicating if the option is in stock. */\n isOptionInStock: (\n name: SelectedOptionType['name'],\n value: SelectedOptionType['value']\n ) => boolean;\n};\n\nexport type SelectedOptions = {\n [key: string]: string;\n};\n"],"names":["ProductOptionsContext","createContext","ProductProvider","children","data","product","initialVariantId","explicitVariantId","variants","useMemo","flattenConnection","isProductVariantArray","Error","options","getOptions","selectedVariant","setSelectedVariant","useState","getVariantBasedOnIdProp","selectedOptions","setSelectedOptions","getSelectedOptions","useEffect","newSelectedVariant","setSelectedOption","useCallback","name","value","opts","getSelectedVariant","isOptionInStock","option","proposedVariant","availableForSale","sellingPlanGroups","map","sellingPlanGroup","sellingPlans","selectedSellingPlan","setSelectedSellingPlan","undefined","selectedSellingPlanAllocation","sellingPlanAllocations","nodes","edges","find","allocation","sellingPlan","id","variantsConnection","sellingPlanGroupsConnection","_jsx","useProduct","context","useContext","choices","length","Object","keys","variant","entries","every","some","reduce","memo","forEach","opt","Set","add","values","Array","from","foundVariant","console","warn","optionSet","maybeVariantArray","isArray"],"mappings":";;;AAuBA,MAAMA,wBAAwBC,cAAuC,IAA1B;AAyBpC,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC,MAAMC;AAAAA,EACNC,kBAAkBC;AAHY,GAIP;AAEvB,QAAMC,WAAWC,QACf,MAAMC;;AAAAA,8BAAkBL,aAAQG,aAARH,YAAoB,CAAA,CAArB;AAAA,KACvB,CAACA,QAAQG,QAAT,CAFsB;AAKpB,MAAA,CAACG,sBAAsBH,QAAD,GAAY;AAC9B,UAAA,IAAII,MACP,kFADG;AAAA,EAGP;AAGKC,QAAAA,UAAUJ,QAAQ,MAAMK,WAAWN,QAAD,GAAY,CAACA,QAAD,CAA7B;AAKjB,QAAA,CAACO,iBAAiBC,kBA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vB,WAAA;AAAA,EACR;AAGD,MAAIA,sBAAsBiC,QAAW;AACnC,WAAOhC,SAASqC,KAAMc,CAAAA,YAAYA,mCAAS1B,gBAApC,KAAyDzB,SAAS;AAAA,EAC1E;AACF;AAED,SAASa,mBACPN,iBAIiB;AACjB,UAAOA,mDAAiBI,mBACpBJ,gBAAgBI,gBAAgB4C,OAC9B,CAACC,MAAMW,cAAc;;AACnBX,UAAKW,4CAAWjD,SAAXiD,YAAmB,OAAMA,4CAAWhD,UAAXgD,YAAoB;AAC3CX,WAAAA;AAAAA,EAAAA,GAET,CAAA,CALF,IAOA;AACL;AAED,SAASrD,sBACPiE,mBAME;AACF,MAAI,CAACA,qBAAqB,CAACN,MAAMO,QAAQD,iBAAd,GAAkC;AACpD,WAAA;AAAA,EACR;AAEM,SAAA;AACR;"}
File without changes
File without changes
@@ -0,0 +1,64 @@
1
+ import { useShop } from "./ShopifyProvider.mjs";
2
+ import { useLoadScript } from "./load-script.mjs";
3
+ import { jsx } from "react/jsx-runtime";
4
+ const SHOPJS_URL = "https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";
5
+ function ShopPayButton({
6
+ variantIds,
7
+ className,
8
+ variantIdsAndQuantities,
9
+ width
10
+ }) {
11
+ const {
12
+ storeDomain
13
+ } = useShop();
14
+ const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);
15
+ let ids;
16
+ if (variantIds && variantIdsAndQuantities) {
17
+ throw new Error(DoublePropsErrorMessage);
18
+ }
19
+ if (variantIds) {
20
+ ids = variantIds.reduce((prev, curr) => {
21
+ const bareId = getIdFromGid(curr);
22
+ if (bareId) {
23
+ prev.push(bareId);
24
+ }
25
+ return prev;
26
+ }, []);
27
+ } else if (variantIdsAndQuantities) {
28
+ ids = variantIdsAndQuantities.reduce((prev, curr) => {
29
+ var _a;
30
+ const bareId = getIdFromGid(curr == null ? void 0 : curr.id);
31
+ if (bareId) {
32
+ prev.push(`${bareId}:${(_a = curr == null ? void 0 : curr.quantity) != null ? _a : 1}`);
33
+ }
34
+ return prev;
35
+ }, []);
36
+ } else {
37
+ throw new Error(MissingPropsErrorMessage);
38
+ }
39
+ const style = width ? {
40
+ "--shop-pay-button-width": width
41
+ } : void 0;
42
+ return /* @__PURE__ */ jsx("div", {
43
+ className,
44
+ style,
45
+ children: shopPayLoadedStatus === "done" && /* @__PURE__ */ jsx("shop-pay-button", {
46
+ "store-url": `https://${storeDomain}`,
47
+ variants: ids.join(",")
48
+ })
49
+ });
50
+ }
51
+ function getIdFromGid(id) {
52
+ if (!id)
53
+ return;
54
+ return id.split("/").pop();
55
+ }
56
+ const MissingPropsErrorMessage = `You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton`;
57
+ const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;
58
+ export {
59
+ DoublePropsErrorMessage,
60
+ MissingPropsErrorMessage,
61
+ ShopPayButton,
62
+ getIdFromGid
63
+ };
64
+ //# sourceMappingURL=ShopPayButton.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button\n store-url={`https://${storeDomain}`}\n variants={ids.join(',')}\n />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAJ4B,GAKP;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAtB;AACMC,QAAAA,sBAAsBC,cAAcT,UAAD;AAErCU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAV;AAAA,EACP;AAED,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAD;AAC3B,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAV;AAAA,MACD;AACMF,aAAAA;AAAAA,IACR,GAAE,CANG,CAAA;AAAA,aAOGV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAP;AAC3B,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAzC;AAAA,MACD;AACMD,aAAAA;AAAAA,IACR,GAAE,CANG,CAAA;AAAA,EAAA,OAOD;AACC,UAAA,IAAIH,MAAMU,wBAAV;AAAA,EACP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