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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. package/dist/{dev/AddToCartButton.mjs → browser-dev/AddToCartButton.js} +4 -4
  2. package/dist/{dev → browser-dev}/AddToCartButton.js.map +1 -1
  3. package/dist/{dev/BaseButton.mjs → browser-dev/BaseButton.js} +1 -1
  4. package/dist/{dev → browser-dev}/BaseButton.js.map +1 -1
  5. package/dist/{prod/BuyNowButton.mjs → browser-dev/BuyNowButton.js} +3 -3
  6. package/dist/{dev → browser-dev}/BuyNowButton.js.map +1 -1
  7. package/dist/{dev/CartCheckoutButton.mjs → browser-dev/CartCheckoutButton.js} +3 -3
  8. package/dist/{dev → browser-dev}/CartCheckoutButton.js.map +1 -1
  9. package/dist/{prod/CartProvider.mjs → browser-dev/CartProvider.js} +3 -3
  10. package/dist/{prod → browser-dev}/CartProvider.js.map +1 -1
  11. package/dist/{prod/ExternalVideo.mjs → browser-dev/ExternalVideo.js} +1 -1
  12. package/dist/{dev → browser-dev}/ExternalVideo.js.map +1 -1
  13. package/dist/{dev/Image.mjs → browser-dev/Image.js} +2 -2
  14. package/dist/{dev → browser-dev}/Image.js.map +1 -1
  15. package/dist/{dev/MediaFile.mjs → browser-dev/MediaFile.js} +5 -5
  16. package/dist/{dev → browser-dev}/MediaFile.js.map +1 -1
  17. package/dist/{dev/Metafield.mjs → browser-dev/Metafield.js} +5 -5
  18. package/dist/{dev → browser-dev}/Metafield.js.map +1 -1
  19. package/dist/{dev/ModelViewer.mjs → browser-dev/ModelViewer.js} +2 -2
  20. package/dist/{dev → browser-dev}/ModelViewer.js.map +1 -1
  21. package/dist/{dev/Money.mjs → browser-dev/Money.js} +2 -2
  22. package/dist/{dev → browser-dev}/Money.js.map +1 -1
  23. package/dist/{dev/ProductPrice.mjs → browser-dev/ProductPrice.js} +3 -3
  24. package/dist/{dev → browser-dev}/ProductPrice.js.map +1 -1
  25. package/dist/{dev/ProductProvider.mjs → browser-dev/ProductProvider.js} +2 -2
  26. package/dist/{prod → browser-dev}/ProductProvider.js.map +1 -1
  27. package/dist/{prod/ShopPayButton.mjs → browser-dev/ShopPayButton.js} +3 -3
  28. package/dist/{prod → browser-dev}/ShopPayButton.js.map +1 -1
  29. package/dist/{dev/ShopifyProvider.mjs → browser-dev/ShopifyProvider.js} +2 -2
  30. package/dist/{prod → browser-dev}/ShopifyProvider.js.map +1 -1
  31. package/dist/{dev/Video.mjs → browser-dev/Video.js} +2 -2
  32. package/dist/{prod → browser-dev}/Video.js.map +1 -1
  33. package/dist/{dev/_virtual/index.mjs → browser-dev/_virtual/index.js} +1 -1
  34. package/dist/{dev → browser-dev}/_virtual/index.js.map +1 -1
  35. package/dist/{dev/_virtual/use-sync-external-store-shim.development.mjs → browser-dev/_virtual/use-sync-external-store-shim.development.js} +1 -1
  36. package/dist/{dev → browser-dev}/_virtual/use-sync-external-store-shim.development.js.map +1 -1
  37. package/dist/{dev/_virtual/use-sync-external-store-shim.production.min.mjs → browser-dev/_virtual/use-sync-external-store-shim.production.min.js} +1 -1
  38. package/dist/browser-dev/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
  39. package/dist/{prod/_virtual/with-selector.development.mjs → browser-dev/_virtual/with-selector.development.js} +1 -1
  40. package/dist/{dev → browser-dev}/_virtual/with-selector.development.js.map +1 -1
  41. package/dist/{prod/_virtual/with-selector.mjs → browser-dev/_virtual/with-selector.js} +1 -1
  42. package/dist/{dev → browser-dev}/_virtual/with-selector.js.map +1 -1
  43. package/dist/{dev/_virtual/with-selector.production.min.mjs → browser-dev/_virtual/with-selector.production.min.js} +1 -1
  44. package/dist/{dev → browser-dev}/_virtual/with-selector.production.min.js.map +1 -1
  45. package/dist/{prod/cart-constants.mjs → browser-dev/cart-constants.js} +1 -1
  46. package/dist/{dev → browser-dev}/cart-constants.js.map +1 -1
  47. package/dist/{dev/cart-hooks.mjs → browser-dev/cart-hooks.js} +3 -3
  48. package/dist/{prod → browser-dev}/cart-hooks.js.map +1 -1
  49. package/dist/{dev/cart-queries.mjs → browser-dev/cart-queries.js} +1 -1
  50. package/dist/{dev → browser-dev}/cart-queries.js.map +1 -1
  51. package/dist/{dev/flatten-connection.mjs → browser-dev/flatten-connection.js} +1 -1
  52. package/dist/{dev → browser-dev}/flatten-connection.js.map +1 -1
  53. package/dist/{prod/image-size.mjs → browser-dev/image-size.js} +1 -1
  54. package/dist/{dev → browser-dev}/image-size.js.map +1 -1
  55. package/dist/browser-dev/index.js +46 -0
  56. package/dist/browser-dev/index.js.map +1 -0
  57. package/dist/{prod/load-script.mjs → browser-dev/load-script.js} +1 -1
  58. package/dist/{dev → browser-dev}/load-script.js.map +1 -1
  59. package/dist/{dev/metafield-parser.mjs → browser-dev/metafield-parser.js} +3 -3
  60. package/dist/{dev → browser-dev}/metafield-parser.js.map +1 -1
  61. package/dist/{dev/node_modules/@xstate/fsm/es/index.mjs → browser-dev/node_modules/@xstate/fsm/es/index.js} +1 -1
  62. package/dist/browser-dev/node_modules/@xstate/fsm/es/index.js.map +1 -0
  63. package/dist/{prod/node_modules/@xstate/react/es/fsm.mjs → browser-dev/node_modules/@xstate/react/es/fsm.js} +6 -6
  64. package/dist/{prod → browser-dev}/node_modules/@xstate/react/es/fsm.js.map +1 -1
  65. package/dist/{dev/node_modules/@xstate/react/es/useConstant.mjs → browser-dev/node_modules/@xstate/react/es/useConstant.js} +1 -1
  66. package/dist/{dev → browser-dev}/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  67. package/dist/{dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs → browser-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js} +1 -1
  68. package/dist/{dev → browser-dev}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -1
  69. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js} +3 -3
  70. package/dist/{prod → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  71. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js} +3 -3
  72. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
  73. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js} +2 -2
  74. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  75. package/dist/{dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs → browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js} +2 -2
  76. package/dist/{prod → browser-dev}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  77. package/dist/{dev/node_modules/use-sync-external-store/shim/index.mjs → browser-dev/node_modules/use-sync-external-store/shim/index.js} +4 -4
  78. package/dist/{prod → browser-dev}/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  79. package/dist/{prod/node_modules/use-sync-external-store/shim/with-selector.mjs → browser-dev/node_modules/use-sync-external-store/shim/with-selector.js} +4 -4
  80. package/dist/{dev → browser-dev}/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  81. package/dist/{prod/storefront-api-constants.mjs → browser-dev/storefront-api-constants.js} +1 -1
  82. package/dist/{dev → browser-dev}/storefront-api-constants.js.map +1 -1
  83. package/dist/{dev/storefront-client.mjs → browser-dev/storefront-client.js} +2 -2
  84. package/dist/{dev → browser-dev}/storefront-client.js.map +1 -1
  85. package/dist/{prod/useCartAPIStateMachine.mjs → browser-dev/useCartAPIStateMachine.js} +5 -5
  86. package/dist/{dev → browser-dev}/useCartAPIStateMachine.js.map +1 -1
  87. package/dist/{dev/useCartActions.mjs → browser-dev/useCartActions.js} +3 -3
  88. package/dist/{prod → browser-dev}/useCartActions.js.map +1 -1
  89. package/dist/{dev/useMoney.mjs → browser-dev/useMoney.js} +2 -2
  90. package/dist/{dev → browser-dev}/useMoney.js.map +1 -1
  91. package/dist/{prod/AddToCartButton.mjs → browser-prod/AddToCartButton.js} +4 -4
  92. package/dist/{prod → browser-prod}/AddToCartButton.js.map +1 -1
  93. package/dist/{prod/BaseButton.mjs → browser-prod/BaseButton.js} +1 -1
  94. package/dist/{prod → browser-prod}/BaseButton.js.map +1 -1
  95. package/dist/{dev/BuyNowButton.mjs → browser-prod/BuyNowButton.js} +3 -3
  96. package/dist/{prod → browser-prod}/BuyNowButton.js.map +1 -1
  97. package/dist/{prod/CartCheckoutButton.mjs → browser-prod/CartCheckoutButton.js} +3 -3
  98. package/dist/{prod → browser-prod}/CartCheckoutButton.js.map +1 -1
  99. package/dist/{dev/CartProvider.mjs → browser-prod/CartProvider.js} +3 -3
  100. package/dist/{dev → browser-prod}/CartProvider.js.map +1 -1
  101. package/dist/{dev/ExternalVideo.mjs → browser-prod/ExternalVideo.js} +1 -1
  102. package/dist/{prod → browser-prod}/ExternalVideo.js.map +1 -1
  103. package/dist/{prod/Image.mjs → browser-prod/Image.js} +2 -2
  104. package/dist/{prod → browser-prod}/Image.js.map +1 -1
  105. package/dist/{prod/MediaFile.mjs → browser-prod/MediaFile.js} +5 -5
  106. package/dist/{prod → browser-prod}/MediaFile.js.map +1 -1
  107. package/dist/{prod/Metafield.mjs → browser-prod/Metafield.js} +5 -5
  108. package/dist/{prod → browser-prod}/Metafield.js.map +1 -1
  109. package/dist/{prod/ModelViewer.mjs → browser-prod/ModelViewer.js} +2 -2
  110. package/dist/{prod → browser-prod}/ModelViewer.js.map +1 -1
  111. package/dist/{prod/Money.mjs → browser-prod/Money.js} +2 -2
  112. package/dist/{prod → browser-prod}/Money.js.map +1 -1
  113. package/dist/{prod/ProductPrice.mjs → browser-prod/ProductPrice.js} +3 -3
  114. package/dist/{prod → browser-prod}/ProductPrice.js.map +1 -1
  115. package/dist/{prod/ProductProvider.mjs → browser-prod/ProductProvider.js} +2 -2
  116. package/dist/{dev → browser-prod}/ProductProvider.js.map +1 -1
  117. package/dist/{dev/ShopPayButton.mjs → browser-prod/ShopPayButton.js} +3 -3
  118. package/dist/{dev → browser-prod}/ShopPayButton.js.map +1 -1
  119. package/dist/{prod/ShopifyProvider.mjs → browser-prod/ShopifyProvider.js} +2 -2
  120. package/dist/{dev → browser-prod}/ShopifyProvider.js.map +1 -1
  121. package/dist/{prod/Video.mjs → browser-prod/Video.js} +2 -2
  122. package/dist/{dev → browser-prod}/Video.js.map +1 -1
  123. package/dist/{prod/_virtual/index.mjs → browser-prod/_virtual/index.js} +1 -1
  124. package/dist/{prod → browser-prod}/_virtual/index.js.map +1 -1
  125. package/dist/{prod/_virtual/use-sync-external-store-shim.development.mjs → browser-prod/_virtual/use-sync-external-store-shim.development.js} +1 -1
  126. package/dist/{prod → browser-prod}/_virtual/use-sync-external-store-shim.development.js.map +1 -1
  127. package/dist/{prod/_virtual/use-sync-external-store-shim.production.min.mjs → browser-prod/_virtual/use-sync-external-store-shim.production.min.js} +1 -1
  128. package/dist/browser-prod/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
  129. package/dist/{dev/_virtual/with-selector.development.mjs → browser-prod/_virtual/with-selector.development.js} +1 -1
  130. package/dist/{prod → browser-prod}/_virtual/with-selector.development.js.map +1 -1
  131. package/dist/{dev/_virtual/with-selector.mjs → browser-prod/_virtual/with-selector.js} +1 -1
  132. package/dist/{prod → browser-prod}/_virtual/with-selector.js.map +1 -1
  133. package/dist/{prod/_virtual/with-selector.production.min.mjs → browser-prod/_virtual/with-selector.production.min.js} +1 -1
  134. package/dist/{prod → browser-prod}/_virtual/with-selector.production.min.js.map +1 -1
  135. package/dist/{dev/cart-constants.mjs → browser-prod/cart-constants.js} +1 -1
  136. package/dist/{prod → browser-prod}/cart-constants.js.map +1 -1
  137. package/dist/{prod/cart-hooks.mjs → browser-prod/cart-hooks.js} +3 -3
  138. package/dist/{dev → browser-prod}/cart-hooks.js.map +1 -1
  139. package/dist/{prod/cart-queries.mjs → browser-prod/cart-queries.js} +1 -1
  140. package/dist/{prod → browser-prod}/cart-queries.js.map +1 -1
  141. package/dist/{prod/flatten-connection.mjs → browser-prod/flatten-connection.js} +1 -1
  142. package/dist/{prod → browser-prod}/flatten-connection.js.map +1 -1
  143. package/dist/{dev/image-size.mjs → browser-prod/image-size.js} +1 -1
  144. package/dist/{prod → browser-prod}/image-size.js.map +1 -1
  145. package/dist/browser-prod/index.js +46 -0
  146. package/dist/browser-prod/index.js.map +1 -0
  147. package/dist/{dev/load-script.mjs → browser-prod/load-script.js} +1 -1
  148. package/dist/{prod → browser-prod}/load-script.js.map +1 -1
  149. package/dist/{prod/metafield-parser.mjs → browser-prod/metafield-parser.js} +3 -3
  150. package/dist/{prod → browser-prod}/metafield-parser.js.map +1 -1
  151. package/dist/{prod/node_modules/@xstate/fsm/es/index.mjs → browser-prod/node_modules/@xstate/fsm/es/index.js} +1 -1
  152. package/dist/browser-prod/node_modules/@xstate/fsm/es/index.js.map +1 -0
  153. package/dist/{dev/node_modules/@xstate/react/es/fsm.mjs → browser-prod/node_modules/@xstate/react/es/fsm.js} +6 -6
  154. package/dist/{dev → browser-prod}/node_modules/@xstate/react/es/fsm.js.map +1 -1
  155. package/dist/{prod/node_modules/@xstate/react/es/useConstant.mjs → browser-prod/node_modules/@xstate/react/es/useConstant.js} +1 -1
  156. package/dist/{prod → browser-prod}/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  157. package/dist/{prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs → browser-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js} +1 -1
  158. package/dist/{prod → browser-prod}/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -1
  159. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js} +3 -3
  160. package/dist/{dev → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  161. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js} +3 -3
  162. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
  163. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js} +2 -2
  164. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  165. package/dist/{prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs → browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js} +2 -2
  166. package/dist/{dev → browser-prod}/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  167. package/dist/{prod/node_modules/use-sync-external-store/shim/index.mjs → browser-prod/node_modules/use-sync-external-store/shim/index.js} +4 -4
  168. package/dist/{dev → browser-prod}/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  169. package/dist/{dev/node_modules/use-sync-external-store/shim/with-selector.mjs → browser-prod/node_modules/use-sync-external-store/shim/with-selector.js} +4 -4
  170. package/dist/{prod → browser-prod}/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  171. package/dist/{dev/storefront-api-constants.mjs → browser-prod/storefront-api-constants.js} +1 -1
  172. package/dist/{prod → browser-prod}/storefront-api-constants.js.map +1 -1
  173. package/dist/{prod/storefront-client.mjs → browser-prod/storefront-client.js} +2 -2
  174. package/dist/{prod → browser-prod}/storefront-client.js.map +1 -1
  175. package/dist/{dev/useCartAPIStateMachine.mjs → browser-prod/useCartAPIStateMachine.js} +5 -5
  176. package/dist/{prod → browser-prod}/useCartAPIStateMachine.js.map +1 -1
  177. package/dist/{prod/useCartActions.mjs → browser-prod/useCartActions.js} +3 -3
  178. package/dist/{dev → browser-prod}/useCartActions.js.map +1 -1
  179. package/dist/{prod/useMoney.mjs → browser-prod/useMoney.js} +2 -2
  180. package/dist/{prod → browser-prod}/useMoney.js.map +1 -1
  181. package/dist/{dev/AddToCartButton.js → node-dev/AddToCartButton.cjs} +8 -8
  182. package/dist/{prod/AddToCartButton.mjs.map → node-dev/AddToCartButton.cjs.map} +1 -1
  183. package/dist/node-dev/AddToCartButton.js +70 -0
  184. package/dist/node-dev/AddToCartButton.js.map +1 -0
  185. package/dist/{dev/BaseButton.js → node-dev/BaseButton.cjs} +3 -3
  186. package/dist/{dev/BaseButton.mjs.map → node-dev/BaseButton.cjs.map} +1 -1
  187. package/dist/node-dev/BaseButton.js +31 -0
  188. package/dist/node-dev/BaseButton.js.map +1 -0
  189. package/dist/{prod/BuyNowButton.js → node-dev/BuyNowButton.cjs} +7 -7
  190. package/dist/{dev/BuyNowButton.mjs.map → node-dev/BuyNowButton.cjs.map} +1 -1
  191. package/dist/node-dev/BuyNowButton.js +45 -0
  192. package/dist/node-dev/BuyNowButton.js.map +1 -0
  193. package/dist/{prod/CartCheckoutButton.js → node-dev/CartCheckoutButton.cjs} +6 -6
  194. package/dist/{dev/CartCheckoutButton.mjs.map → node-dev/CartCheckoutButton.cjs.map} +1 -1
  195. package/dist/node-dev/CartCheckoutButton.js +30 -0
  196. package/dist/node-dev/CartCheckoutButton.js.map +1 -0
  197. package/dist/{dev/CartProvider.js → node-dev/CartProvider.cjs} +23 -23
  198. package/dist/{prod/CartProvider.mjs.map → node-dev/CartProvider.cjs.map} +1 -1
  199. package/dist/node-dev/CartProvider.js +485 -0
  200. package/dist/node-dev/CartProvider.js.map +1 -0
  201. package/dist/{dev/ExternalVideo.js → node-dev/ExternalVideo.cjs} +1 -1
  202. package/dist/{prod/ExternalVideo.mjs.map → node-dev/ExternalVideo.cjs.map} +1 -1
  203. package/dist/node-dev/ExternalVideo.js +39 -0
  204. package/dist/node-dev/ExternalVideo.js.map +1 -0
  205. package/dist/{dev/Image.js → node-dev/Image.cjs} +2 -2
  206. package/dist/{dev/Image.mjs.map → node-dev/Image.cjs.map} +1 -1
  207. package/dist/node-dev/Image.js +104 -0
  208. package/dist/node-dev/Image.js.map +1 -0
  209. package/dist/{dev/MediaFile.js → node-dev/MediaFile.cjs} +5 -5
  210. package/dist/{dev/MediaFile.mjs.map → node-dev/MediaFile.cjs.map} +1 -1
  211. package/dist/node-dev/MediaFile.js +57 -0
  212. package/dist/node-dev/MediaFile.js.map +1 -0
  213. package/dist/{dev/Metafield.js → node-dev/Metafield.cjs} +7 -7
  214. package/dist/{dev/Metafield.mjs.map → node-dev/Metafield.cjs.map} +1 -1
  215. package/dist/node-dev/Metafield.js +301 -0
  216. package/dist/node-dev/Metafield.js.map +1 -0
  217. package/dist/{dev/ModelViewer.js → node-dev/ModelViewer.cjs} +6 -6
  218. package/dist/{dev/ModelViewer.mjs.map → node-dev/ModelViewer.cjs.map} +1 -1
  219. package/dist/node-dev/ModelViewer.js +145 -0
  220. package/dist/node-dev/ModelViewer.js.map +1 -0
  221. package/dist/{prod/Money.js → node-dev/Money.cjs} +2 -2
  222. package/dist/{dev/Money.mjs.map → node-dev/Money.cjs.map} +1 -1
  223. package/dist/node-dev/Money.js +40 -0
  224. package/dist/node-dev/Money.js.map +1 -0
  225. package/dist/{prod/ProductPrice.js → node-dev/ProductPrice.cjs} +3 -3
  226. package/dist/{dev/ProductPrice.mjs.map → node-dev/ProductPrice.cjs.map} +1 -1
  227. package/dist/node-dev/ProductPrice.js +61 -0
  228. package/dist/node-dev/ProductPrice.js.map +1 -0
  229. package/dist/{prod/ProductProvider.js → node-dev/ProductProvider.cjs} +16 -16
  230. package/dist/{dev/ProductProvider.mjs.map → node-dev/ProductProvider.cjs.map} +1 -1
  231. package/dist/node-dev/ProductProvider.js +161 -0
  232. package/dist/node-dev/ProductProvider.js.map +1 -0
  233. package/dist/{dev/ShopPayButton.js → node-dev/ShopPayButton.cjs} +3 -3
  234. package/dist/{prod/ShopPayButton.mjs.map → node-dev/ShopPayButton.cjs.map} +1 -1
  235. package/dist/node-dev/ShopPayButton.js +64 -0
  236. package/dist/node-dev/ShopPayButton.js.map +1 -0
  237. package/dist/{prod/ShopifyProvider.js → node-dev/ShopifyProvider.cjs} +6 -6
  238. package/dist/{dev/ShopifyProvider.mjs.map → node-dev/ShopifyProvider.cjs.map} +1 -1
  239. package/dist/node-dev/ShopifyProvider.js +46 -0
  240. package/dist/node-dev/ShopifyProvider.js.map +1 -0
  241. package/dist/{prod/Video.js → node-dev/Video.cjs} +4 -4
  242. package/dist/{dev/Video.mjs.map → node-dev/Video.cjs.map} +1 -1
  243. package/dist/node-dev/Video.js +44 -0
  244. package/dist/node-dev/Video.js.map +1 -0
  245. package/dist/{prod/cart-constants.js → node-dev/cart-constants.cjs} +1 -1
  246. package/dist/{dev/cart-constants.mjs.map → node-dev/cart-constants.cjs.map} +1 -1
  247. package/dist/node-dev/cart-constants.js +17 -0
  248. package/dist/node-dev/cart-constants.js.map +1 -0
  249. package/dist/{dev/cart-hooks.js → node-dev/cart-hooks.cjs} +5 -5
  250. package/dist/{prod/cart-hooks.mjs.map → node-dev/cart-hooks.cjs.map} +1 -1
  251. package/dist/node-dev/cart-hooks.js +48 -0
  252. package/dist/node-dev/cart-hooks.js.map +1 -0
  253. package/dist/{dev/cart-queries.js → node-dev/cart-queries.cjs} +1 -1
  254. package/dist/{dev/cart-queries.mjs.map → node-dev/cart-queries.cjs.map} +1 -1
  255. package/dist/node-dev/cart-queries.js +114 -0
  256. package/dist/node-dev/cart-queries.js.map +1 -0
  257. package/dist/{dev/flatten-connection.js → node-dev/flatten-connection.cjs} +1 -1
  258. package/dist/{dev/flatten-connection.mjs.map → node-dev/flatten-connection.cjs.map} +1 -1
  259. package/dist/node-dev/flatten-connection.js +29 -0
  260. package/dist/node-dev/flatten-connection.js.map +1 -0
  261. package/dist/{dev/image-size.js → node-dev/image-size.cjs} +1 -1
  262. package/dist/{prod/image-size.mjs.map → node-dev/image-size.cjs.map} +1 -1
  263. package/dist/node-dev/image-size.js +80 -0
  264. package/dist/node-dev/image-size.js.map +1 -0
  265. package/dist/{prod/index.js → node-dev/index.cjs} +20 -20
  266. package/dist/node-dev/index.cjs.map +1 -0
  267. package/dist/node-dev/index.js +46 -0
  268. package/dist/node-dev/index.js.map +1 -0
  269. package/dist/{prod/load-script.js → node-dev/load-script.cjs} +4 -4
  270. package/dist/{dev/load-script.mjs.map → node-dev/load-script.cjs.map} +1 -1
  271. package/dist/node-dev/load-script.js +52 -0
  272. package/dist/node-dev/load-script.js.map +1 -0
  273. package/dist/{dev/metafield-parser.js → node-dev/metafield-parser.cjs} +3 -3
  274. package/dist/{dev/metafield-parser.mjs.map → node-dev/metafield-parser.cjs.map} +1 -1
  275. package/dist/node-dev/metafield-parser.js +103 -0
  276. package/dist/node-dev/metafield-parser.js.map +1 -0
  277. package/dist/{prod/storefront-api-constants.js → node-dev/storefront-api-constants.cjs} +1 -1
  278. package/dist/node-dev/storefront-api-constants.cjs.map +1 -0
  279. package/dist/node-dev/storefront-api-constants.js +5 -0
  280. package/dist/node-dev/storefront-api-constants.js.map +1 -0
  281. package/dist/{dev/storefront-client.js → node-dev/storefront-client.cjs} +2 -2
  282. package/dist/{dev/storefront-client.mjs.map → node-dev/storefront-client.cjs.map} +1 -1
  283. package/dist/node-dev/storefront-client.js +72 -0
  284. package/dist/node-dev/storefront-client.js.map +1 -0
  285. package/dist/{prod/useCartAPIStateMachine.js → node-dev/useCartAPIStateMachine.cjs} +15 -15
  286. package/dist/{prod/useCartAPIStateMachine.mjs.map → node-dev/useCartAPIStateMachine.cjs.map} +1 -1
  287. package/dist/node-dev/useCartAPIStateMachine.js +326 -0
  288. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -0
  289. package/dist/{dev/useCartActions.js → node-dev/useCartActions.cjs} +14 -14
  290. package/dist/{dev/useCartActions.mjs.map → node-dev/useCartActions.cjs.map} +1 -1
  291. package/dist/node-dev/useCartActions.js +123 -0
  292. package/dist/node-dev/useCartActions.js.map +1 -0
  293. package/dist/{prod/useMoney.js → node-dev/useMoney.cjs} +7 -7
  294. package/dist/{dev/useMoney.mjs.map → node-dev/useMoney.cjs.map} +1 -1
  295. package/dist/node-dev/useMoney.js +72 -0
  296. package/dist/node-dev/useMoney.js.map +1 -0
  297. package/dist/{prod/AddToCartButton.js → node-prod/AddToCartButton.cjs} +8 -8
  298. package/dist/{dev/AddToCartButton.mjs.map → node-prod/AddToCartButton.cjs.map} +1 -1
  299. package/dist/node-prod/AddToCartButton.js +70 -0
  300. package/dist/node-prod/AddToCartButton.js.map +1 -0
  301. package/dist/{prod/BaseButton.js → node-prod/BaseButton.cjs} +3 -3
  302. package/dist/{prod/BaseButton.mjs.map → node-prod/BaseButton.cjs.map} +1 -1
  303. package/dist/node-prod/BaseButton.js +31 -0
  304. package/dist/node-prod/BaseButton.js.map +1 -0
  305. package/dist/{dev/BuyNowButton.js → node-prod/BuyNowButton.cjs} +7 -7
  306. package/dist/{prod/BuyNowButton.mjs.map → node-prod/BuyNowButton.cjs.map} +1 -1
  307. package/dist/node-prod/BuyNowButton.js +45 -0
  308. package/dist/node-prod/BuyNowButton.js.map +1 -0
  309. package/dist/{dev/CartCheckoutButton.js → node-prod/CartCheckoutButton.cjs} +6 -6
  310. package/dist/{prod/CartCheckoutButton.mjs.map → node-prod/CartCheckoutButton.cjs.map} +1 -1
  311. package/dist/node-prod/CartCheckoutButton.js +30 -0
  312. package/dist/node-prod/CartCheckoutButton.js.map +1 -0
  313. package/dist/{prod/CartProvider.js → node-prod/CartProvider.cjs} +23 -23
  314. package/dist/{dev/CartProvider.mjs.map → node-prod/CartProvider.cjs.map} +1 -1
  315. package/dist/node-prod/CartProvider.js +485 -0
  316. package/dist/node-prod/CartProvider.js.map +1 -0
  317. package/dist/{prod/ExternalVideo.js → node-prod/ExternalVideo.cjs} +1 -1
  318. package/dist/{dev/ExternalVideo.mjs.map → node-prod/ExternalVideo.cjs.map} +1 -1
  319. package/dist/node-prod/ExternalVideo.js +39 -0
  320. package/dist/node-prod/ExternalVideo.js.map +1 -0
  321. package/dist/{prod/Image.js → node-prod/Image.cjs} +2 -2
  322. package/dist/{prod/Image.mjs.map → node-prod/Image.cjs.map} +1 -1
  323. package/dist/node-prod/Image.js +99 -0
  324. package/dist/node-prod/Image.js.map +1 -0
  325. package/dist/{prod/MediaFile.js → node-prod/MediaFile.cjs} +5 -5
  326. package/dist/{prod/MediaFile.mjs.map → node-prod/MediaFile.cjs.map} +1 -1
  327. package/dist/node-prod/MediaFile.js +59 -0
  328. package/dist/node-prod/MediaFile.js.map +1 -0
  329. package/dist/{prod/Metafield.js → node-prod/Metafield.cjs} +7 -7
  330. package/dist/{prod/Metafield.mjs.map → node-prod/Metafield.cjs.map} +1 -1
  331. package/dist/node-prod/Metafield.js +288 -0
  332. package/dist/node-prod/Metafield.js.map +1 -0
  333. package/dist/{prod/ModelViewer.js → node-prod/ModelViewer.cjs} +6 -6
  334. package/dist/{prod/ModelViewer.mjs.map → node-prod/ModelViewer.cjs.map} +1 -1
  335. package/dist/node-prod/ModelViewer.js +143 -0
  336. package/dist/node-prod/ModelViewer.js.map +1 -0
  337. package/dist/{dev/Money.js → node-prod/Money.cjs} +2 -2
  338. package/dist/{prod/Money.mjs.map → node-prod/Money.cjs.map} +1 -1
  339. package/dist/node-prod/Money.js +40 -0
  340. package/dist/node-prod/Money.js.map +1 -0
  341. package/dist/{dev/ProductPrice.js → node-prod/ProductPrice.cjs} +3 -3
  342. package/dist/{prod/ProductPrice.mjs.map → node-prod/ProductPrice.cjs.map} +1 -1
  343. package/dist/node-prod/ProductPrice.js +61 -0
  344. package/dist/node-prod/ProductPrice.js.map +1 -0
  345. package/dist/{dev/ProductProvider.js → node-prod/ProductProvider.cjs} +16 -16
  346. package/dist/{prod/ProductProvider.mjs.map → node-prod/ProductProvider.cjs.map} +1 -1
  347. package/dist/node-prod/ProductProvider.js +161 -0
  348. package/dist/node-prod/ProductProvider.js.map +1 -0
  349. package/dist/{prod/ShopPayButton.js → node-prod/ShopPayButton.cjs} +3 -3
  350. package/dist/{dev/ShopPayButton.mjs.map → node-prod/ShopPayButton.cjs.map} +1 -1
  351. package/dist/node-prod/ShopPayButton.js +64 -0
  352. package/dist/node-prod/ShopPayButton.js.map +1 -0
  353. package/dist/{dev/ShopifyProvider.js → node-prod/ShopifyProvider.cjs} +6 -6
  354. package/dist/{prod/ShopifyProvider.mjs.map → node-prod/ShopifyProvider.cjs.map} +1 -1
  355. package/dist/node-prod/ShopifyProvider.js +46 -0
  356. package/dist/node-prod/ShopifyProvider.js.map +1 -0
  357. package/dist/{dev/Video.js → node-prod/Video.cjs} +4 -4
  358. package/dist/{prod/Video.mjs.map → node-prod/Video.cjs.map} +1 -1
  359. package/dist/node-prod/Video.js +44 -0
  360. package/dist/node-prod/Video.js.map +1 -0
  361. package/dist/{dev/cart-constants.js → node-prod/cart-constants.cjs} +1 -1
  362. package/dist/{prod/cart-constants.mjs.map → node-prod/cart-constants.cjs.map} +1 -1
  363. package/dist/node-prod/cart-constants.js +17 -0
  364. package/dist/node-prod/cart-constants.js.map +1 -0
  365. package/dist/{prod/cart-hooks.js → node-prod/cart-hooks.cjs} +5 -5
  366. package/dist/{dev/cart-hooks.mjs.map → node-prod/cart-hooks.cjs.map} +1 -1
  367. package/dist/node-prod/cart-hooks.js +48 -0
  368. package/dist/node-prod/cart-hooks.js.map +1 -0
  369. package/dist/{prod/cart-queries.js → node-prod/cart-queries.cjs} +1 -1
  370. package/dist/{prod/cart-queries.mjs.map → node-prod/cart-queries.cjs.map} +1 -1
  371. package/dist/node-prod/cart-queries.js +114 -0
  372. package/dist/node-prod/cart-queries.js.map +1 -0
  373. package/dist/{prod/flatten-connection.js → node-prod/flatten-connection.cjs} +1 -1
  374. package/dist/{prod/flatten-connection.mjs.map → node-prod/flatten-connection.cjs.map} +1 -1
  375. package/dist/node-prod/flatten-connection.js +25 -0
  376. package/dist/node-prod/flatten-connection.js.map +1 -0
  377. package/dist/{prod/image-size.js → node-prod/image-size.cjs} +1 -1
  378. package/dist/{dev/image-size.mjs.map → node-prod/image-size.cjs.map} +1 -1
  379. package/dist/node-prod/image-size.js +80 -0
  380. package/dist/node-prod/image-size.js.map +1 -0
  381. package/dist/{dev/index.js → node-prod/index.cjs} +20 -20
  382. package/dist/node-prod/index.cjs.map +1 -0
  383. package/dist/node-prod/index.js +46 -0
  384. package/dist/node-prod/index.js.map +1 -0
  385. package/dist/{dev/load-script.js → node-prod/load-script.cjs} +4 -4
  386. package/dist/{prod/load-script.mjs.map → node-prod/load-script.cjs.map} +1 -1
  387. package/dist/node-prod/load-script.js +52 -0
  388. package/dist/node-prod/load-script.js.map +1 -0
  389. package/dist/{prod/metafield-parser.js → node-prod/metafield-parser.cjs} +3 -3
  390. package/dist/{prod/metafield-parser.mjs.map → node-prod/metafield-parser.cjs.map} +1 -1
  391. package/dist/node-prod/metafield-parser.js +114 -0
  392. package/dist/node-prod/metafield-parser.js.map +1 -0
  393. package/dist/{dev/storefront-api-constants.js → node-prod/storefront-api-constants.cjs} +1 -1
  394. package/dist/node-prod/storefront-api-constants.cjs.map +1 -0
  395. package/dist/node-prod/storefront-api-constants.js +5 -0
  396. package/dist/node-prod/storefront-api-constants.js.map +1 -0
  397. package/dist/{prod/storefront-client.js → node-prod/storefront-client.cjs} +2 -2
  398. package/dist/{prod/storefront-client.mjs.map → node-prod/storefront-client.cjs.map} +1 -1
  399. package/dist/node-prod/storefront-client.js +57 -0
  400. package/dist/node-prod/storefront-client.js.map +1 -0
  401. package/dist/{dev/useCartAPIStateMachine.js → node-prod/useCartAPIStateMachine.cjs} +15 -15
  402. package/dist/{dev/useCartAPIStateMachine.mjs.map → node-prod/useCartAPIStateMachine.cjs.map} +1 -1
  403. package/dist/node-prod/useCartAPIStateMachine.js +326 -0
  404. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -0
  405. package/dist/{prod/useCartActions.js → node-prod/useCartActions.cjs} +14 -14
  406. package/dist/{prod/useCartActions.mjs.map → node-prod/useCartActions.cjs.map} +1 -1
  407. package/dist/node-prod/useCartActions.js +123 -0
  408. package/dist/node-prod/useCartActions.js.map +1 -0
  409. package/dist/{dev/useMoney.js → node-prod/useMoney.cjs} +7 -7
  410. package/dist/{prod/useMoney.mjs.map → node-prod/useMoney.cjs.map} +1 -1
  411. package/dist/node-prod/useMoney.js +72 -0
  412. package/dist/node-prod/useMoney.js.map +1 -0
  413. package/package.json +35 -20
  414. package/dist/dev/_virtual/index.js +0 -5
  415. package/dist/dev/_virtual/index.mjs.map +0 -1
  416. package/dist/dev/_virtual/use-sync-external-store-shim.development.js +0 -5
  417. package/dist/dev/_virtual/use-sync-external-store-shim.development.mjs.map +0 -1
  418. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +0 -5
  419. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +0 -1
  420. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.mjs.map +0 -1
  421. package/dist/dev/_virtual/with-selector.development.js +0 -5
  422. package/dist/dev/_virtual/with-selector.development.mjs.map +0 -1
  423. package/dist/dev/_virtual/with-selector.js +0 -5
  424. package/dist/dev/_virtual/with-selector.mjs.map +0 -1
  425. package/dist/dev/_virtual/with-selector.production.min.js +0 -5
  426. package/dist/dev/_virtual/with-selector.production.min.mjs.map +0 -1
  427. package/dist/dev/index.js.map +0 -1
  428. package/dist/dev/index.mjs +0 -46
  429. package/dist/dev/index.mjs.map +0 -1
  430. package/dist/dev/node_modules/@xstate/fsm/es/index.js +0 -158
  431. package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +0 -1
  432. package/dist/dev/node_modules/@xstate/fsm/es/index.mjs.map +0 -1
  433. package/dist/dev/node_modules/@xstate/react/es/fsm.js +0 -94
  434. package/dist/dev/node_modules/@xstate/react/es/fsm.mjs.map +0 -1
  435. package/dist/dev/node_modules/@xstate/react/es/useConstant.js +0 -30
  436. package/dist/dev/node_modules/@xstate/react/es/useConstant.mjs.map +0 -1
  437. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -5
  438. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +0 -1
  439. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -107
  440. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +0 -1
  441. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -74
  442. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -1
  443. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +0 -1
  444. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -138
  445. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +0 -1
  446. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -60
  447. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +0 -1
  448. package/dist/dev/node_modules/use-sync-external-store/shim/index.js +0 -21
  449. package/dist/dev/node_modules/use-sync-external-store/shim/index.mjs.map +0 -1
  450. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +0 -12
  451. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +0 -1
  452. package/dist/dev/storefront-api-constants.mjs.map +0 -1
  453. package/dist/prod/_virtual/index.js +0 -5
  454. package/dist/prod/_virtual/index.mjs.map +0 -1
  455. package/dist/prod/_virtual/use-sync-external-store-shim.development.js +0 -5
  456. package/dist/prod/_virtual/use-sync-external-store-shim.development.mjs.map +0 -1
  457. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +0 -5
  458. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +0 -1
  459. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.mjs.map +0 -1
  460. package/dist/prod/_virtual/with-selector.development.js +0 -5
  461. package/dist/prod/_virtual/with-selector.development.mjs.map +0 -1
  462. package/dist/prod/_virtual/with-selector.js +0 -5
  463. package/dist/prod/_virtual/with-selector.mjs.map +0 -1
  464. package/dist/prod/_virtual/with-selector.production.min.js +0 -5
  465. package/dist/prod/_virtual/with-selector.production.min.mjs.map +0 -1
  466. package/dist/prod/index.js.map +0 -1
  467. package/dist/prod/index.mjs +0 -46
  468. package/dist/prod/index.mjs.map +0 -1
  469. package/dist/prod/node_modules/@xstate/fsm/es/index.js +0 -158
  470. package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +0 -1
  471. package/dist/prod/node_modules/@xstate/fsm/es/index.mjs.map +0 -1
  472. package/dist/prod/node_modules/@xstate/react/es/fsm.js +0 -94
  473. package/dist/prod/node_modules/@xstate/react/es/fsm.mjs.map +0 -1
  474. package/dist/prod/node_modules/@xstate/react/es/useConstant.js +0 -30
  475. package/dist/prod/node_modules/@xstate/react/es/useConstant.mjs.map +0 -1
  476. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -5
  477. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +0 -1
  478. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -107
  479. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +0 -1
  480. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -74
  481. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -1
  482. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +0 -1
  483. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -138
  484. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +0 -1
  485. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -60
  486. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +0 -1
  487. package/dist/prod/node_modules/use-sync-external-store/shim/index.js +0 -21
  488. package/dist/prod/node_modules/use-sync-external-store/shim/index.mjs.map +0 -1
  489. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +0 -12
  490. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +0 -1
  491. package/dist/prod/storefront-api-constants.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"metafield-parser.mjs","sources":["../../src/metafield-parser.ts"],"sourcesContent":["import type {\n Collection,\n GenericFile,\n Metafield as MetafieldBaseType,\n MoneyV2,\n Page,\n Product,\n ProductVariant,\n} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\nimport {parseJSON} from './Metafield.js';\nimport {flattenConnection} from './flatten-connection.js';\n\n/**\n * A temporary function that will be renamed to `parseMetafield()` in a future release.\n *\n * A function that uses `metafield.type` to parse the Metafield's `value` or `reference` or `references` (depending on the `type`) and put it in `metafield.parsedValue`\n *\n * TypeScript developers can use the type `ParsedMetafields` from this package to get the returned object's type correct. For example:\n *\n * ```\n * metafieldParser<ParsedMetafields['boolean']>({type: 'boolean', value: 'false'}\n * ```\n */\nexport function metafieldParser<ReturnGeneric>(\n metafield: PartialDeep<MetafieldBaseType, {recurseIntoArrays: true}>\n): ReturnGeneric {\n if (!metafield.type) {\n const noTypeError = `metafieldParser(): The 'type' field is required in order to parse the Metafield.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noTypeError);\n } else {\n console.error(`${noTypeError} Returning 'parsedValue' of 'null'`);\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n\n switch (metafield.type) {\n case 'boolean':\n return {\n ...metafield,\n parsedValue: metafield.value === 'true',\n } as ReturnGeneric;\n\n case 'collection_reference':\n case 'file_reference':\n case 'page_reference':\n case 'product_reference':\n case 'variant_reference':\n return {\n ...metafield,\n parsedValue: metafield.reference,\n } as ReturnGeneric;\n\n case 'color':\n case 'multi_line_text_field':\n case 'single_line_text_field':\n case 'url':\n return {\n ...metafield,\n parsedValue: metafield.value,\n } as ReturnGeneric;\n\n // TODO: 'money' should probably be parsed even further to like `useMoney()`, but that logic needs to be extracted first so it's not a hook\n case 'dimension':\n case 'money':\n case 'json':\n case 'rating':\n case 'volume':\n case 'weight':\n case 'list.color':\n case 'list.dimension':\n case 'list.number_integer':\n case 'list.number_decimal':\n case 'list.rating':\n case 'list.single_line_text_field':\n case 'list.url':\n case 'list.volume':\n case 'list.weight': {\n let parsedValue = null;\n try {\n parsedValue = parseJSON(metafield.value ?? '');\n } catch (err) {\n const parseError = `metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(parseError);\n } else {\n console.error(`${parseError} Returning 'null' for 'parsedValue'`);\n }\n parsedValue = null;\n }\n return {\n ...metafield,\n parsedValue,\n } as ReturnGeneric;\n }\n\n case 'date':\n case 'date_time':\n return {\n ...metafield,\n parsedValue: new Date(metafield.value ?? ''),\n } as ReturnGeneric;\n\n case 'list.date':\n case 'list.date_time': {\n const jsonParseValue = parseJSON(metafield?.value ?? '') as string[];\n return {\n ...metafield,\n parsedValue: jsonParseValue.map((dateString) => new Date(dateString)),\n } as ReturnGeneric;\n }\n\n case 'number_decimal':\n case 'number_integer':\n return {\n ...metafield,\n parsedValue: Number(metafield.value),\n } as ReturnGeneric;\n\n case 'list.collection_reference':\n case 'list.file_reference':\n case 'list.page_reference':\n case 'list.product_reference':\n case 'list.variant_reference':\n return {\n ...metafield,\n parsedValue: flattenConnection(metafield.references ?? undefined),\n } as ReturnGeneric;\n\n default: {\n const typeNotFoundError = `metafieldParser(): the 'metafield.type' you passed in is not supported. Your type: \"${metafield.type}\". If you believe this is an error, please open an issue on GitHub.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typeNotFoundError);\n } else {\n console.error(\n `${typeNotFoundError} Returning 'parsedValue' of 'null'`\n );\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n }\n}\n\n// taken from https://shopify.dev/apps/metafields/types\nexport const allMetafieldTypesArray = [\n 'boolean',\n 'collection_reference',\n 'color',\n 'date',\n 'date_time',\n 'dimension',\n 'file_reference',\n 'json',\n 'money',\n 'multi_line_text_field',\n 'number_decimal',\n 'number_integer',\n 'page_reference',\n 'product_reference',\n 'rating',\n 'single_line_text_field',\n 'url',\n 'variant_reference',\n 'volume',\n 'weight',\n // list metafields\n 'list.collection_reference',\n 'list.color',\n 'list.date',\n 'list.date_time',\n 'list.dimension',\n 'list.file_reference',\n 'list.number_integer',\n 'list.number_decimal',\n 'list.page_reference',\n 'list.product_reference',\n 'list.rating',\n 'list.single_line_text_field',\n 'list.url',\n 'list.variant_reference',\n 'list.volume',\n 'list.weight',\n] as const;\n\n/** A union of all the supported `metafield.type`s */\nexport type MetafieldTypeTypes = typeof allMetafieldTypesArray[number];\n\n/**\n * A mapping of a Metafield's `type` to the TypeScript type that is returned from `metafieldParser()`\n * For example, when using `metafieldParser()`, the type will be correctly returned when used like the following:\n *\n * ```\n * const parsedMetafield = metafieldParser<ParsedMetafields['boolean']>(metafield);`\n * ```\n * `parsedMetafield.parsedValue`'s type is now `boolean`\n */\nexport type ParsedMetafields<ExtraTypeGeneric = void> = {\n /** A Metafield that's been parsed, with a `parsedValue` of `boolean` */\n boolean: Simplify<BooleanParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Collection` object (as defined by the Storefront API) */\n collection_reference: Simplify<CollectionParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n color: Simplify<ColorParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date_time: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n dimension: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `GenericFile` object (as defined by the Storefront API) */\n file_reference: Simplify<FileRefParsedMetafield>;\n /**\n * A Metafield that's been parsed, with a `parsedValue` of type `unknown`, unless you pass in the type as a generic. For example:\n *\n * ```\n * ParsedMetafields<MyJsonType>['json']\n * ```\n */\n json: Simplify<JsonParsedMetafield<ExtraTypeGeneric>>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Money` */\n money: Simplify<MoneyParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n multi_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_decimal: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_integer: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Page` object (as defined by the Storefront API) */\n page_reference: Simplify<PageParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Product` object (as defined by the Storefront API) */\n product_reference: Simplify<ProductParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Rating` */\n rating: Simplify<RatingParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n single_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n url: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `ProductVariant` object (as defined by the Storefront API) */\n variant_reference: Simplify<VariantParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n volume: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n weight: Simplify<MeasurementParsedMetafield>;\n // list metafields\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Collection` objects (as defined by the Storefront API) */\n 'list.collection_reference': Simplify<CollectionListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.color': Simplify<ColorListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date_time': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement` objects */\n 'list.dimension': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `GenericFile` objects (as defined by the Storefront API) */\n 'list.file_reference': Simplify<FileListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_integer': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_decimal': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Page` objects (as defined by the Storefront API) */\n 'list.page_reference': Simplify<PageListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Product` objects (as defined by the Storefront API) */\n 'list.product_reference': Simplify<ProductListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Rating`s */\n 'list.rating': Simplify<RatingListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.single_line_text_field': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.url': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `ProductVariant` objects (as defined by the Storefront API) */\n 'list.variant_reference': Simplify<VariantListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.volume': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.weight': Simplify<MeasurementListParsedMetafield>;\n};\n\ninterface ParsedBase extends MetafieldBaseType {\n type: MetafieldTypeTypes;\n parsedValue: unknown;\n}\n\ninterface BooleanParsedMetafield extends ParsedBase {\n type: 'boolean';\n parsedValue: boolean | null;\n}\ntype CollectionParsedRefMetafield = MetafieldBaseType & {\n type: 'collection_reference';\n parsedValue: Collection | null;\n};\ntype ColorParsedMetafield = MetafieldBaseType & {\n type: 'color';\n parsedValue: string | null;\n};\ntype DatesParsedMetafield = MetafieldBaseType & {\n type: 'date' | 'date_time';\n parsedValue: Date | null;\n};\n\ntype MeasurementParsedMetafield = MetafieldBaseType & {\n type: 'dimension' | 'weight' | 'volume';\n parsedValue: Measurement | null;\n};\n\ntype FileRefParsedMetafield = MetafieldBaseType & {\n type: 'file_reference';\n parsedValue: GenericFile | null;\n};\n\ntype JsonParsedMetafield<JsonTypeGeneric = void> = MetafieldBaseType & {\n type: 'json';\n parsedValue: JsonTypeGeneric extends void ? unknown : JsonTypeGeneric | null;\n};\n\ntype MoneyParsedMetafield = MetafieldBaseType & {\n type: 'money';\n parsedValue: MoneyV2 | null;\n};\n\ntype TextParsedMetafield = MetafieldBaseType & {\n type: 'single_line_text_field' | 'multi_line_text_field' | 'url';\n parsedValue: string | null;\n};\n\ntype NumberParsedMetafield = MetafieldBaseType & {\n type: 'number_decimal' | 'number_integer';\n parsedValue: number | null;\n};\n\ntype PageParsedRefMetafield = MetafieldBaseType & {\n type: 'page_reference';\n parsedValue: Page | null;\n};\n\ntype ProductParsedRefMetafield = MetafieldBaseType & {\n type: 'product_reference';\n parsedValue: Product | null;\n};\n\ntype RatingParsedMetafield = MetafieldBaseType & {\n type: 'rating';\n parsedValue: Rating | null;\n};\n\ntype VariantParsedRefMetafield = MetafieldBaseType & {\n type: 'variant_reference';\n parsedValue: ProductVariant | null;\n};\n\ntype CollectionListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.collection_reference';\n parsedValue: Array<Collection> | null;\n};\n\ntype ColorListParsedMetafield = MetafieldBaseType & {\n type: 'list.color';\n parsedValue: Array<string> | null;\n};\n\ntype DatesListParsedMetafield = MetafieldBaseType & {\n type: 'list.date' | 'list.date_time';\n parsedValue: Array<Date> | null;\n};\n\ntype MeasurementListParsedMetafield = MetafieldBaseType & {\n type: 'list.dimension' | 'list.weight' | 'list.volume';\n parsedValue: Array<Measurement> | null;\n};\n\ntype FileListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.file_reference';\n parsedValue: Array<GenericFile> | null;\n};\n\ntype TextListParsedMetafield = MetafieldBaseType & {\n type: 'list.single_line_text_field' | 'list.url';\n parsedValue: Array<string> | null;\n};\n\ntype NumberListParsedMetafield = MetafieldBaseType & {\n type: 'list.number_decimal' | 'list.number_integer';\n parsedValue: Array<number> | null;\n};\n\ntype PageListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.page_reference';\n parsedValue: Array<Page> | null;\n};\n\ntype ProductListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.product_reference';\n parsedValue: Array<Product> | null;\n};\n\ntype RatingListParsedMetafield = MetafieldBaseType & {\n type: 'list.rating';\n parsedValue: Array<Rating> | null;\n};\n\ntype VariantListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.variant_reference';\n parsedValue: Array<ProductVariant> | null;\n};\n\nexport type Measurement = {\n unit: string;\n value: number;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,gBACd,WACe;;AACX,MAAA,CAAC,UAAU,MAAM;AACnB,UAAM,cAAc;AACE;AACd,YAAA,IAAI,MAAM,WAAW;AAAA,IAO7B;AAAA,EACF;AAEA,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,UAAU;AAAA,MAAA;AAAA,IAGrC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAG3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAI3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,eAAe;AAClB,UAAI,cAAc;AACd,UAAA;AACY,sBAAA,WAAU,eAAU,UAAV,YAAmB,EAAE;AAAA,eACtC;AACP,cAAM,aAAa;AACG;AACd,gBAAA,IAAI,MAAM,UAAU;AAAA,QAG5B;AAAA,MAEF;AACO,aAAA;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,IAAI,MAAK,eAAU,UAAV,YAAmB,EAAE;AAAA,MAAA;AAAA,IAG/C,KAAK;AAAA,IACL,KAAK,kBAAkB;AACrB,YAAM,iBAAiB,WAAU,4CAAW,UAAX,YAAoB,EAAE;AAChD,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,eAAe,IAAI,CAAC,eAAe,IAAI,KAAK,UAAU,CAAC;AAAA,MAAA;AAAA,IAExE;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,OAAO,UAAU,KAAK;AAAA,MAAA;AAAA,IAGvC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,mBAAkB,eAAU,eAAV,YAAwB,MAAS;AAAA,MAAA;AAAA,IAGpE,SAAS;AACD,YAAA,oBAAoB,uFAAuF,UAAU;AACrG;AACd,cAAA,IAAI,MAAM,iBAAiB;AAAA,MASnC;AAAA,IACF;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"metafield-parser.cjs","sources":["../../src/metafield-parser.ts"],"sourcesContent":["import type {\n Collection,\n GenericFile,\n Metafield as MetafieldBaseType,\n MoneyV2,\n Page,\n Product,\n ProductVariant,\n} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\nimport {parseJSON} from './Metafield.js';\nimport {flattenConnection} from './flatten-connection.js';\n\n/**\n * A temporary function that will be renamed to `parseMetafield()` in a future release.\n *\n * A function that uses `metafield.type` to parse the Metafield's `value` or `reference` or `references` (depending on the `type`) and put it in `metafield.parsedValue`\n *\n * TypeScript developers can use the type `ParsedMetafields` from this package to get the returned object's type correct. For example:\n *\n * ```\n * metafieldParser<ParsedMetafields['boolean']>({type: 'boolean', value: 'false'}\n * ```\n */\nexport function metafieldParser<ReturnGeneric>(\n metafield: PartialDeep<MetafieldBaseType, {recurseIntoArrays: true}>\n): ReturnGeneric {\n if (!metafield.type) {\n const noTypeError = `metafieldParser(): The 'type' field is required in order to parse the Metafield.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noTypeError);\n } else {\n console.error(`${noTypeError} Returning 'parsedValue' of 'null'`);\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n\n switch (metafield.type) {\n case 'boolean':\n return {\n ...metafield,\n parsedValue: metafield.value === 'true',\n } as ReturnGeneric;\n\n case 'collection_reference':\n case 'file_reference':\n case 'page_reference':\n case 'product_reference':\n case 'variant_reference':\n return {\n ...metafield,\n parsedValue: metafield.reference,\n } as ReturnGeneric;\n\n case 'color':\n case 'multi_line_text_field':\n case 'single_line_text_field':\n case 'url':\n return {\n ...metafield,\n parsedValue: metafield.value,\n } as ReturnGeneric;\n\n // TODO: 'money' should probably be parsed even further to like `useMoney()`, but that logic needs to be extracted first so it's not a hook\n case 'dimension':\n case 'money':\n case 'json':\n case 'rating':\n case 'volume':\n case 'weight':\n case 'list.color':\n case 'list.dimension':\n case 'list.number_integer':\n case 'list.number_decimal':\n case 'list.rating':\n case 'list.single_line_text_field':\n case 'list.url':\n case 'list.volume':\n case 'list.weight': {\n let parsedValue = null;\n try {\n parsedValue = parseJSON(metafield.value ?? '');\n } catch (err) {\n const parseError = `metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(parseError);\n } else {\n console.error(`${parseError} Returning 'null' for 'parsedValue'`);\n }\n parsedValue = null;\n }\n return {\n ...metafield,\n parsedValue,\n } as ReturnGeneric;\n }\n\n case 'date':\n case 'date_time':\n return {\n ...metafield,\n parsedValue: new Date(metafield.value ?? ''),\n } as ReturnGeneric;\n\n case 'list.date':\n case 'list.date_time': {\n const jsonParseValue = parseJSON(metafield?.value ?? '') as string[];\n return {\n ...metafield,\n parsedValue: jsonParseValue.map((dateString) => new Date(dateString)),\n } as ReturnGeneric;\n }\n\n case 'number_decimal':\n case 'number_integer':\n return {\n ...metafield,\n parsedValue: Number(metafield.value),\n } as ReturnGeneric;\n\n case 'list.collection_reference':\n case 'list.file_reference':\n case 'list.page_reference':\n case 'list.product_reference':\n case 'list.variant_reference':\n return {\n ...metafield,\n parsedValue: flattenConnection(metafield.references ?? undefined),\n } as ReturnGeneric;\n\n default: {\n const typeNotFoundError = `metafieldParser(): the 'metafield.type' you passed in is not supported. Your type: \"${metafield.type}\". If you believe this is an error, please open an issue on GitHub.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typeNotFoundError);\n } else {\n console.error(\n `${typeNotFoundError} Returning 'parsedValue' of 'null'`\n );\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n }\n}\n\n// taken from https://shopify.dev/apps/metafields/types\nexport const allMetafieldTypesArray = [\n 'boolean',\n 'collection_reference',\n 'color',\n 'date',\n 'date_time',\n 'dimension',\n 'file_reference',\n 'json',\n 'money',\n 'multi_line_text_field',\n 'number_decimal',\n 'number_integer',\n 'page_reference',\n 'product_reference',\n 'rating',\n 'single_line_text_field',\n 'url',\n 'variant_reference',\n 'volume',\n 'weight',\n // list metafields\n 'list.collection_reference',\n 'list.color',\n 'list.date',\n 'list.date_time',\n 'list.dimension',\n 'list.file_reference',\n 'list.number_integer',\n 'list.number_decimal',\n 'list.page_reference',\n 'list.product_reference',\n 'list.rating',\n 'list.single_line_text_field',\n 'list.url',\n 'list.variant_reference',\n 'list.volume',\n 'list.weight',\n] as const;\n\n/** A union of all the supported `metafield.type`s */\nexport type MetafieldTypeTypes = typeof allMetafieldTypesArray[number];\n\n/**\n * A mapping of a Metafield's `type` to the TypeScript type that is returned from `metafieldParser()`\n * For example, when using `metafieldParser()`, the type will be correctly returned when used like the following:\n *\n * ```\n * const parsedMetafield = metafieldParser<ParsedMetafields['boolean']>(metafield);`\n * ```\n * `parsedMetafield.parsedValue`'s type is now `boolean`\n */\nexport type ParsedMetafields<ExtraTypeGeneric = void> = {\n /** A Metafield that's been parsed, with a `parsedValue` of `boolean` */\n boolean: Simplify<BooleanParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Collection` object (as defined by the Storefront API) */\n collection_reference: Simplify<CollectionParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n color: Simplify<ColorParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date_time: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n dimension: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `GenericFile` object (as defined by the Storefront API) */\n file_reference: Simplify<FileRefParsedMetafield>;\n /**\n * A Metafield that's been parsed, with a `parsedValue` of type `unknown`, unless you pass in the type as a generic. For example:\n *\n * ```\n * ParsedMetafields<MyJsonType>['json']\n * ```\n */\n json: Simplify<JsonParsedMetafield<ExtraTypeGeneric>>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Money` */\n money: Simplify<MoneyParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n multi_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_decimal: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_integer: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Page` object (as defined by the Storefront API) */\n page_reference: Simplify<PageParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Product` object (as defined by the Storefront API) */\n product_reference: Simplify<ProductParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Rating` */\n rating: Simplify<RatingParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n single_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n url: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `ProductVariant` object (as defined by the Storefront API) */\n variant_reference: Simplify<VariantParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n volume: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n weight: Simplify<MeasurementParsedMetafield>;\n // list metafields\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Collection` objects (as defined by the Storefront API) */\n 'list.collection_reference': Simplify<CollectionListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.color': Simplify<ColorListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date_time': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement` objects */\n 'list.dimension': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `GenericFile` objects (as defined by the Storefront API) */\n 'list.file_reference': Simplify<FileListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_integer': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_decimal': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Page` objects (as defined by the Storefront API) */\n 'list.page_reference': Simplify<PageListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Product` objects (as defined by the Storefront API) */\n 'list.product_reference': Simplify<ProductListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Rating`s */\n 'list.rating': Simplify<RatingListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.single_line_text_field': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.url': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `ProductVariant` objects (as defined by the Storefront API) */\n 'list.variant_reference': Simplify<VariantListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.volume': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.weight': Simplify<MeasurementListParsedMetafield>;\n};\n\ninterface ParsedBase extends MetafieldBaseType {\n type: MetafieldTypeTypes;\n parsedValue: unknown;\n}\n\ninterface BooleanParsedMetafield extends ParsedBase {\n type: 'boolean';\n parsedValue: boolean | null;\n}\ntype CollectionParsedRefMetafield = MetafieldBaseType & {\n type: 'collection_reference';\n parsedValue: Collection | null;\n};\ntype ColorParsedMetafield = MetafieldBaseType & {\n type: 'color';\n parsedValue: string | null;\n};\ntype DatesParsedMetafield = MetafieldBaseType & {\n type: 'date' | 'date_time';\n parsedValue: Date | null;\n};\n\ntype MeasurementParsedMetafield = MetafieldBaseType & {\n type: 'dimension' | 'weight' | 'volume';\n parsedValue: Measurement | null;\n};\n\ntype FileRefParsedMetafield = MetafieldBaseType & {\n type: 'file_reference';\n parsedValue: GenericFile | null;\n};\n\ntype JsonParsedMetafield<JsonTypeGeneric = void> = MetafieldBaseType & {\n type: 'json';\n parsedValue: JsonTypeGeneric extends void ? unknown : JsonTypeGeneric | null;\n};\n\ntype MoneyParsedMetafield = MetafieldBaseType & {\n type: 'money';\n parsedValue: MoneyV2 | null;\n};\n\ntype TextParsedMetafield = MetafieldBaseType & {\n type: 'single_line_text_field' | 'multi_line_text_field' | 'url';\n parsedValue: string | null;\n};\n\ntype NumberParsedMetafield = MetafieldBaseType & {\n type: 'number_decimal' | 'number_integer';\n parsedValue: number | null;\n};\n\ntype PageParsedRefMetafield = MetafieldBaseType & {\n type: 'page_reference';\n parsedValue: Page | null;\n};\n\ntype ProductParsedRefMetafield = MetafieldBaseType & {\n type: 'product_reference';\n parsedValue: Product | null;\n};\n\ntype RatingParsedMetafield = MetafieldBaseType & {\n type: 'rating';\n parsedValue: Rating | null;\n};\n\ntype VariantParsedRefMetafield = MetafieldBaseType & {\n type: 'variant_reference';\n parsedValue: ProductVariant | null;\n};\n\ntype CollectionListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.collection_reference';\n parsedValue: Array<Collection> | null;\n};\n\ntype ColorListParsedMetafield = MetafieldBaseType & {\n type: 'list.color';\n parsedValue: Array<string> | null;\n};\n\ntype DatesListParsedMetafield = MetafieldBaseType & {\n type: 'list.date' | 'list.date_time';\n parsedValue: Array<Date> | null;\n};\n\ntype MeasurementListParsedMetafield = MetafieldBaseType & {\n type: 'list.dimension' | 'list.weight' | 'list.volume';\n parsedValue: Array<Measurement> | null;\n};\n\ntype FileListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.file_reference';\n parsedValue: Array<GenericFile> | null;\n};\n\ntype TextListParsedMetafield = MetafieldBaseType & {\n type: 'list.single_line_text_field' | 'list.url';\n parsedValue: Array<string> | null;\n};\n\ntype NumberListParsedMetafield = MetafieldBaseType & {\n type: 'list.number_decimal' | 'list.number_integer';\n parsedValue: Array<number> | null;\n};\n\ntype PageListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.page_reference';\n parsedValue: Array<Page> | null;\n};\n\ntype ProductListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.product_reference';\n parsedValue: Array<Product> | null;\n};\n\ntype RatingListParsedMetafield = MetafieldBaseType & {\n type: 'list.rating';\n parsedValue: Array<Rating> | null;\n};\n\ntype VariantListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.variant_reference';\n parsedValue: Array<ProductVariant> | null;\n};\n\nexport type Measurement = {\n unit: string;\n value: number;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n"],"names":["parseJSON","flattenConnection"],"mappings":";;;;AAwBO,SAAS,gBACd,WACe;;AACX,MAAA,CAAC,UAAU,MAAM;AACnB,UAAM,cAAc;AACE;AACd,YAAA,IAAI,MAAM,WAAW;AAAA,IAO7B;AAAA,EACF;AAEA,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,UAAU;AAAA,MAAA;AAAA,IAGrC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAG3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAI3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,eAAe;AAClB,UAAI,cAAc;AACd,UAAA;AACY,sBAAAA,UAAAA,WAAU,eAAU,UAAV,YAAmB,EAAE;AAAA,eACtC;AACP,cAAM,aAAa;AACG;AACd,gBAAA,IAAI,MAAM,UAAU;AAAA,QAG5B;AAAA,MAEF;AACO,aAAA;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,IAAI,MAAK,eAAU,UAAV,YAAmB,EAAE;AAAA,MAAA;AAAA,IAG/C,KAAK;AAAA,IACL,KAAK,kBAAkB;AACrB,YAAM,iBAAiBA,UAAA,WAAU,4CAAW,UAAX,YAAoB,EAAE;AAChD,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,eAAe,IAAI,CAAC,eAAe,IAAI,KAAK,UAAU,CAAC;AAAA,MAAA;AAAA,IAExE;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,OAAO,UAAU,KAAK;AAAA,MAAA;AAAA,IAGvC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAaC,kBAAAA,mBAAkB,eAAU,eAAV,YAAwB,MAAS;AAAA,MAAA;AAAA,IAGpE,SAAS;AACD,YAAA,oBAAoB,uFAAuF,UAAU;AACrG;AACd,cAAA,IAAI,MAAM,iBAAiB;AAAA,MASnC;AAAA,IACF;AAAA,EACF;AACF;;"}
@@ -0,0 +1,103 @@
1
+ import { parseJSON } from "./Metafield.js";
2
+ import { flattenConnection } from "./flatten-connection.js";
3
+ function metafieldParser(metafield) {
4
+ var _a, _b, _c, _d;
5
+ if (!metafield.type) {
6
+ const noTypeError = `metafieldParser(): The 'type' field is required in order to parse the Metafield.`;
7
+ {
8
+ throw new Error(noTypeError);
9
+ }
10
+ }
11
+ switch (metafield.type) {
12
+ case "boolean":
13
+ return {
14
+ ...metafield,
15
+ parsedValue: metafield.value === "true"
16
+ };
17
+ case "collection_reference":
18
+ case "file_reference":
19
+ case "page_reference":
20
+ case "product_reference":
21
+ case "variant_reference":
22
+ return {
23
+ ...metafield,
24
+ parsedValue: metafield.reference
25
+ };
26
+ case "color":
27
+ case "multi_line_text_field":
28
+ case "single_line_text_field":
29
+ case "url":
30
+ return {
31
+ ...metafield,
32
+ parsedValue: metafield.value
33
+ };
34
+ case "dimension":
35
+ case "money":
36
+ case "json":
37
+ case "rating":
38
+ case "volume":
39
+ case "weight":
40
+ case "list.color":
41
+ case "list.dimension":
42
+ case "list.number_integer":
43
+ case "list.number_decimal":
44
+ case "list.rating":
45
+ case "list.single_line_text_field":
46
+ case "list.url":
47
+ case "list.volume":
48
+ case "list.weight": {
49
+ let parsedValue = null;
50
+ try {
51
+ parsedValue = parseJSON((_a = metafield.value) != null ? _a : "");
52
+ } catch (err) {
53
+ const parseError = `metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed.`;
54
+ {
55
+ throw new Error(parseError);
56
+ }
57
+ }
58
+ return {
59
+ ...metafield,
60
+ parsedValue
61
+ };
62
+ }
63
+ case "date":
64
+ case "date_time":
65
+ return {
66
+ ...metafield,
67
+ parsedValue: new Date((_b = metafield.value) != null ? _b : "")
68
+ };
69
+ case "list.date":
70
+ case "list.date_time": {
71
+ const jsonParseValue = parseJSON((_c = metafield == null ? void 0 : metafield.value) != null ? _c : "");
72
+ return {
73
+ ...metafield,
74
+ parsedValue: jsonParseValue.map((dateString) => new Date(dateString))
75
+ };
76
+ }
77
+ case "number_decimal":
78
+ case "number_integer":
79
+ return {
80
+ ...metafield,
81
+ parsedValue: Number(metafield.value)
82
+ };
83
+ case "list.collection_reference":
84
+ case "list.file_reference":
85
+ case "list.page_reference":
86
+ case "list.product_reference":
87
+ case "list.variant_reference":
88
+ return {
89
+ ...metafield,
90
+ parsedValue: flattenConnection((_d = metafield.references) != null ? _d : void 0)
91
+ };
92
+ default: {
93
+ const typeNotFoundError = `metafieldParser(): the 'metafield.type' you passed in is not supported. Your type: "${metafield.type}". If you believe this is an error, please open an issue on GitHub.`;
94
+ {
95
+ throw new Error(typeNotFoundError);
96
+ }
97
+ }
98
+ }
99
+ }
100
+ export {
101
+ metafieldParser
102
+ };
103
+ //# sourceMappingURL=metafield-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metafield-parser.js","sources":["../../src/metafield-parser.ts"],"sourcesContent":["import type {\n Collection,\n GenericFile,\n Metafield as MetafieldBaseType,\n MoneyV2,\n Page,\n Product,\n ProductVariant,\n} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\nimport {parseJSON} from './Metafield.js';\nimport {flattenConnection} from './flatten-connection.js';\n\n/**\n * A temporary function that will be renamed to `parseMetafield()` in a future release.\n *\n * A function that uses `metafield.type` to parse the Metafield's `value` or `reference` or `references` (depending on the `type`) and put it in `metafield.parsedValue`\n *\n * TypeScript developers can use the type `ParsedMetafields` from this package to get the returned object's type correct. For example:\n *\n * ```\n * metafieldParser<ParsedMetafields['boolean']>({type: 'boolean', value: 'false'}\n * ```\n */\nexport function metafieldParser<ReturnGeneric>(\n metafield: PartialDeep<MetafieldBaseType, {recurseIntoArrays: true}>\n): ReturnGeneric {\n if (!metafield.type) {\n const noTypeError = `metafieldParser(): The 'type' field is required in order to parse the Metafield.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noTypeError);\n } else {\n console.error(`${noTypeError} Returning 'parsedValue' of 'null'`);\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n\n switch (metafield.type) {\n case 'boolean':\n return {\n ...metafield,\n parsedValue: metafield.value === 'true',\n } as ReturnGeneric;\n\n case 'collection_reference':\n case 'file_reference':\n case 'page_reference':\n case 'product_reference':\n case 'variant_reference':\n return {\n ...metafield,\n parsedValue: metafield.reference,\n } as ReturnGeneric;\n\n case 'color':\n case 'multi_line_text_field':\n case 'single_line_text_field':\n case 'url':\n return {\n ...metafield,\n parsedValue: metafield.value,\n } as ReturnGeneric;\n\n // TODO: 'money' should probably be parsed even further to like `useMoney()`, but that logic needs to be extracted first so it's not a hook\n case 'dimension':\n case 'money':\n case 'json':\n case 'rating':\n case 'volume':\n case 'weight':\n case 'list.color':\n case 'list.dimension':\n case 'list.number_integer':\n case 'list.number_decimal':\n case 'list.rating':\n case 'list.single_line_text_field':\n case 'list.url':\n case 'list.volume':\n case 'list.weight': {\n let parsedValue = null;\n try {\n parsedValue = parseJSON(metafield.value ?? '');\n } catch (err) {\n const parseError = `metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(parseError);\n } else {\n console.error(`${parseError} Returning 'null' for 'parsedValue'`);\n }\n parsedValue = null;\n }\n return {\n ...metafield,\n parsedValue,\n } as ReturnGeneric;\n }\n\n case 'date':\n case 'date_time':\n return {\n ...metafield,\n parsedValue: new Date(metafield.value ?? ''),\n } as ReturnGeneric;\n\n case 'list.date':\n case 'list.date_time': {\n const jsonParseValue = parseJSON(metafield?.value ?? '') as string[];\n return {\n ...metafield,\n parsedValue: jsonParseValue.map((dateString) => new Date(dateString)),\n } as ReturnGeneric;\n }\n\n case 'number_decimal':\n case 'number_integer':\n return {\n ...metafield,\n parsedValue: Number(metafield.value),\n } as ReturnGeneric;\n\n case 'list.collection_reference':\n case 'list.file_reference':\n case 'list.page_reference':\n case 'list.product_reference':\n case 'list.variant_reference':\n return {\n ...metafield,\n parsedValue: flattenConnection(metafield.references ?? undefined),\n } as ReturnGeneric;\n\n default: {\n const typeNotFoundError = `metafieldParser(): the 'metafield.type' you passed in is not supported. Your type: \"${metafield.type}\". If you believe this is an error, please open an issue on GitHub.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typeNotFoundError);\n } else {\n console.error(\n `${typeNotFoundError} Returning 'parsedValue' of 'null'`\n );\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n }\n}\n\n// taken from https://shopify.dev/apps/metafields/types\nexport const allMetafieldTypesArray = [\n 'boolean',\n 'collection_reference',\n 'color',\n 'date',\n 'date_time',\n 'dimension',\n 'file_reference',\n 'json',\n 'money',\n 'multi_line_text_field',\n 'number_decimal',\n 'number_integer',\n 'page_reference',\n 'product_reference',\n 'rating',\n 'single_line_text_field',\n 'url',\n 'variant_reference',\n 'volume',\n 'weight',\n // list metafields\n 'list.collection_reference',\n 'list.color',\n 'list.date',\n 'list.date_time',\n 'list.dimension',\n 'list.file_reference',\n 'list.number_integer',\n 'list.number_decimal',\n 'list.page_reference',\n 'list.product_reference',\n 'list.rating',\n 'list.single_line_text_field',\n 'list.url',\n 'list.variant_reference',\n 'list.volume',\n 'list.weight',\n] as const;\n\n/** A union of all the supported `metafield.type`s */\nexport type MetafieldTypeTypes = typeof allMetafieldTypesArray[number];\n\n/**\n * A mapping of a Metafield's `type` to the TypeScript type that is returned from `metafieldParser()`\n * For example, when using `metafieldParser()`, the type will be correctly returned when used like the following:\n *\n * ```\n * const parsedMetafield = metafieldParser<ParsedMetafields['boolean']>(metafield);`\n * ```\n * `parsedMetafield.parsedValue`'s type is now `boolean`\n */\nexport type ParsedMetafields<ExtraTypeGeneric = void> = {\n /** A Metafield that's been parsed, with a `parsedValue` of `boolean` */\n boolean: Simplify<BooleanParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Collection` object (as defined by the Storefront API) */\n collection_reference: Simplify<CollectionParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n color: Simplify<ColorParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date_time: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n dimension: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `GenericFile` object (as defined by the Storefront API) */\n file_reference: Simplify<FileRefParsedMetafield>;\n /**\n * A Metafield that's been parsed, with a `parsedValue` of type `unknown`, unless you pass in the type as a generic. For example:\n *\n * ```\n * ParsedMetafields<MyJsonType>['json']\n * ```\n */\n json: Simplify<JsonParsedMetafield<ExtraTypeGeneric>>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Money` */\n money: Simplify<MoneyParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n multi_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_decimal: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_integer: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Page` object (as defined by the Storefront API) */\n page_reference: Simplify<PageParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Product` object (as defined by the Storefront API) */\n product_reference: Simplify<ProductParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Rating` */\n rating: Simplify<RatingParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n single_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n url: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `ProductVariant` object (as defined by the Storefront API) */\n variant_reference: Simplify<VariantParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n volume: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n weight: Simplify<MeasurementParsedMetafield>;\n // list metafields\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Collection` objects (as defined by the Storefront API) */\n 'list.collection_reference': Simplify<CollectionListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.color': Simplify<ColorListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date_time': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement` objects */\n 'list.dimension': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `GenericFile` objects (as defined by the Storefront API) */\n 'list.file_reference': Simplify<FileListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_integer': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_decimal': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Page` objects (as defined by the Storefront API) */\n 'list.page_reference': Simplify<PageListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Product` objects (as defined by the Storefront API) */\n 'list.product_reference': Simplify<ProductListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Rating`s */\n 'list.rating': Simplify<RatingListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.single_line_text_field': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.url': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `ProductVariant` objects (as defined by the Storefront API) */\n 'list.variant_reference': Simplify<VariantListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.volume': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.weight': Simplify<MeasurementListParsedMetafield>;\n};\n\ninterface ParsedBase extends MetafieldBaseType {\n type: MetafieldTypeTypes;\n parsedValue: unknown;\n}\n\ninterface BooleanParsedMetafield extends ParsedBase {\n type: 'boolean';\n parsedValue: boolean | null;\n}\ntype CollectionParsedRefMetafield = MetafieldBaseType & {\n type: 'collection_reference';\n parsedValue: Collection | null;\n};\ntype ColorParsedMetafield = MetafieldBaseType & {\n type: 'color';\n parsedValue: string | null;\n};\ntype DatesParsedMetafield = MetafieldBaseType & {\n type: 'date' | 'date_time';\n parsedValue: Date | null;\n};\n\ntype MeasurementParsedMetafield = MetafieldBaseType & {\n type: 'dimension' | 'weight' | 'volume';\n parsedValue: Measurement | null;\n};\n\ntype FileRefParsedMetafield = MetafieldBaseType & {\n type: 'file_reference';\n parsedValue: GenericFile | null;\n};\n\ntype JsonParsedMetafield<JsonTypeGeneric = void> = MetafieldBaseType & {\n type: 'json';\n parsedValue: JsonTypeGeneric extends void ? unknown : JsonTypeGeneric | null;\n};\n\ntype MoneyParsedMetafield = MetafieldBaseType & {\n type: 'money';\n parsedValue: MoneyV2 | null;\n};\n\ntype TextParsedMetafield = MetafieldBaseType & {\n type: 'single_line_text_field' | 'multi_line_text_field' | 'url';\n parsedValue: string | null;\n};\n\ntype NumberParsedMetafield = MetafieldBaseType & {\n type: 'number_decimal' | 'number_integer';\n parsedValue: number | null;\n};\n\ntype PageParsedRefMetafield = MetafieldBaseType & {\n type: 'page_reference';\n parsedValue: Page | null;\n};\n\ntype ProductParsedRefMetafield = MetafieldBaseType & {\n type: 'product_reference';\n parsedValue: Product | null;\n};\n\ntype RatingParsedMetafield = MetafieldBaseType & {\n type: 'rating';\n parsedValue: Rating | null;\n};\n\ntype VariantParsedRefMetafield = MetafieldBaseType & {\n type: 'variant_reference';\n parsedValue: ProductVariant | null;\n};\n\ntype CollectionListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.collection_reference';\n parsedValue: Array<Collection> | null;\n};\n\ntype ColorListParsedMetafield = MetafieldBaseType & {\n type: 'list.color';\n parsedValue: Array<string> | null;\n};\n\ntype DatesListParsedMetafield = MetafieldBaseType & {\n type: 'list.date' | 'list.date_time';\n parsedValue: Array<Date> | null;\n};\n\ntype MeasurementListParsedMetafield = MetafieldBaseType & {\n type: 'list.dimension' | 'list.weight' | 'list.volume';\n parsedValue: Array<Measurement> | null;\n};\n\ntype FileListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.file_reference';\n parsedValue: Array<GenericFile> | null;\n};\n\ntype TextListParsedMetafield = MetafieldBaseType & {\n type: 'list.single_line_text_field' | 'list.url';\n parsedValue: Array<string> | null;\n};\n\ntype NumberListParsedMetafield = MetafieldBaseType & {\n type: 'list.number_decimal' | 'list.number_integer';\n parsedValue: Array<number> | null;\n};\n\ntype PageListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.page_reference';\n parsedValue: Array<Page> | null;\n};\n\ntype ProductListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.product_reference';\n parsedValue: Array<Product> | null;\n};\n\ntype RatingListParsedMetafield = MetafieldBaseType & {\n type: 'list.rating';\n parsedValue: Array<Rating> | null;\n};\n\ntype VariantListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.variant_reference';\n parsedValue: Array<ProductVariant> | null;\n};\n\nexport type Measurement = {\n unit: string;\n value: number;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,gBACd,WACe;;AACX,MAAA,CAAC,UAAU,MAAM;AACnB,UAAM,cAAc;AACE;AACd,YAAA,IAAI,MAAM,WAAW;AAAA,IAO7B;AAAA,EACF;AAEA,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,UAAU;AAAA,MAAA;AAAA,IAGrC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAG3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAI3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,eAAe;AAClB,UAAI,cAAc;AACd,UAAA;AACY,sBAAA,WAAU,eAAU,UAAV,YAAmB,EAAE;AAAA,eACtC;AACP,cAAM,aAAa;AACG;AACd,gBAAA,IAAI,MAAM,UAAU;AAAA,QAG5B;AAAA,MAEF;AACO,aAAA;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,IAAI,MAAK,eAAU,UAAV,YAAmB,EAAE;AAAA,MAAA;AAAA,IAG/C,KAAK;AAAA,IACL,KAAK,kBAAkB;AACrB,YAAM,iBAAiB,WAAU,4CAAW,UAAX,YAAoB,EAAE;AAChD,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,eAAe,IAAI,CAAC,eAAe,IAAI,KAAK,UAAU,CAAC;AAAA,MAAA;AAAA,IAExE;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,OAAO,UAAU,KAAK;AAAA,MAAA;AAAA,IAGvC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,mBAAkB,eAAU,eAAV,YAAwB,MAAS;AAAA,MAAA;AAAA,IAGpE,SAAS;AACD,YAAA,oBAAoB,uFAAuF,UAAU;AACrG;AACd,cAAA,IAAI,MAAM,iBAAiB;AAAA,MASnC;AAAA,IACF;AAAA,EACF;AACF;"}
@@ -2,4 +2,4 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const SFAPI_VERSION = "2022-10";
4
4
  exports.SFAPI_VERSION = SFAPI_VERSION;
5
- //# sourceMappingURL=storefront-api-constants.js.map
5
+ //# sourceMappingURL=storefront-api-constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-api-constants.cjs","sources":["../../src/storefront-api-constants.ts"],"sourcesContent":["export const SFAPI_VERSION = '2022-10';\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAgB;;"}
@@ -0,0 +1,5 @@
1
+ const SFAPI_VERSION = "2022-10";
2
+ export {
3
+ SFAPI_VERSION
4
+ };
5
+ //# sourceMappingURL=storefront-api-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-api-constants.js","sources":["../../src/storefront-api-constants.ts"],"sourcesContent":["export const SFAPI_VERSION = '2022-10';\n"],"names":[],"mappings":"AAAO,MAAM,gBAAgB;"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const storefrontApiConstants = require("./storefront-api-constants.js");
3
+ const storefrontApiConstants = require("./storefront-api-constants.cjs");
4
4
  function createStorefrontClient({
5
5
  storeDomain,
6
6
  privateStorefrontToken,
@@ -69,4 +69,4 @@ function createStorefrontClient({
69
69
  };
70
70
  }
71
71
  exports.createStorefrontClient = createStorefrontClient;
72
- //# sourceMappingURL=storefront-client.js.map
72
+ //# sourceMappingURL=storefront-client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"storefront-client.mjs","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\n\n/**\n * The `createStorefrontClient()` function creates helpers that enable you to quickly query the Shopify Storefront API.\n *\n * When used on the server, it is recommended to use the `privateStorefrontToken` prop. When used on the client, it is recommended to use the `publicStorefrontToken` prop.\n */\nexport function createStorefrontClient({\n storeDomain,\n privateStorefrontToken,\n publicStorefrontToken,\n storefrontApiVersion,\n contentType,\n}: StorefrontClientProps): StorefrontClientReturn {\n if (storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: \"${storefrontApiVersion}\"; expected version \"${SFAPI_VERSION}\"`\n );\n }\n\n // only warn if not in a browser environment\n if (__HYDROGEN_DEV__ && !privateStorefrontToken && !globalThis.document) {\n console.warn(\n `StorefrontClient: Using a private storefront token is recommended for server environments. Refer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details. `\n );\n }\n\n // only warn if in a browser environment and you're using the privateStorefrontToken\n if (__HYDROGEN_DEV__ && privateStorefrontToken && globalThis) {\n console.warn(\n `StorefrontClient: You are attempting to use a private token in an environment where it can be easily accessed by anyone. This is a security risk; please use the public token and the 'publicStorefrontToken' prop`\n );\n }\n\n return {\n getStorefrontApiUrl(overrideProps) {\n return `https://${\n overrideProps?.storeDomain ?? storeDomain\n }.myshopify.com/api/${\n overrideProps?.storefrontApiVersion ?? storefrontApiVersion\n }/graphql.json`;\n },\n getPrivateTokenHeaders(overrideProps) {\n if (!privateStorefrontToken && !overrideProps?.privateStorefrontToken) {\n throw new Error(\n `StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`\n );\n }\n\n if (__HYDROGEN_DEV__ && !overrideProps?.buyerIp) {\n console.warn(\n `StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`\n );\n }\n\n const finalContentType = overrideProps?.contentType ?? contentType;\n\n return {\n // default to json\n 'content-type':\n finalContentType === 'graphql'\n ? 'application/graphql'\n : 'application/json',\n 'X-SDK-Variant': 'hydrogen-ui',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'Shopify-Storefront-Private-Token':\n overrideProps?.privateStorefrontToken ?? privateStorefrontToken ?? '',\n ...(overrideProps?.buyerIp\n ? {'Shopify-Storefront-Buyer-IP': overrideProps.buyerIp}\n : {}),\n };\n },\n getPublicTokenHeaders(overrideProps) {\n if (!publicStorefrontToken && !overrideProps?.publicStorefrontToken) {\n throw new Error(\n `StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`\n );\n }\n\n const finalContentType = overrideProps?.contentType ?? contentType;\n\n return {\n // default to json\n 'content-type':\n finalContentType === 'graphql'\n ? 'application/graphql'\n : 'application/json',\n 'X-SDK-Variant': 'hydrogen-ui',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'X-Shopify-Storefront-Access-Token':\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? '',\n };\n },\n };\n}\n\ntype StorefrontClientProps = {\n /** The host name of the domain (eg: `{shop}.myshopify.com`). */\n storeDomain: string;\n /** The Storefront API delegate access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) and [delegate access token](https://shopify.dev/apps/auth/oauth/delegate-access-tokens) documentation for more details. */\n privateStorefrontToken?: string;\n /** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n publicStorefrontToken?: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n /**\n * Customizes which `\"content-type\"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `\"json\"`. When fetching with a `body` that is a plain string, use `\"graphql\"`. Defaults to `\"json\"`\n *\n * Can also be customized on a call-by-call basis by passing in `'contentType'` to both `getPrivateTokenHeaders({...})` and `getPublicTokenHeaders({...})`, for example: `getPublicTokenHeaders({contentType: 'graphql'})`\n */\n contentType?: 'json' | 'graphql';\n};\n\ntype OverrideTokenHeaderProps = Partial<\n Pick<StorefrontClientProps, 'contentType'>\n>;\n\ntype StorefrontClientReturn = {\n /**\n * Creates the fully-qualified URL to your store's GraphQL endpoint.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getStorefrontApiUrl({...})`:\n *\n * - `storeDomain`\n * - `storefrontApiVersion`\n */\n getStorefrontApiUrl: (\n props?: Partial<\n Pick<StorefrontClientProps, 'storeDomain' | 'storefrontApiVersion'>\n >\n ) => string;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:\n *\n * - `contentType`\n * - `privateStorefrontToken`\n * - `buyerIp`\n *\n * Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.\n */\n getPrivateTokenHeaders: (\n props?: OverrideTokenHeaderProps &\n Pick<StorefrontClientProps, 'privateStorefrontToken'> & {\n /**\n * The client's IP address. Passing this to the Storefront API when using a server-to-server token will help improve your store's analytics data.\n */\n buyerIp?: string;\n }\n ) => Record<string, string>;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:\n *\n * - `contentType`\n * - `publicStorefrontToken`\n *\n * Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.\n */\n getPublicTokenHeaders: (\n props?: OverrideTokenHeaderProps &\n Pick<StorefrontClientProps, 'publicStorefrontToken'>\n ) => Record<string, string>;\n};\n"],"names":[],"mappings":";AAOO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyB,eAAe;AAClC,YAAA;AAAA,MACN,4NAA4N,4CAA4C;AAAA,IAAA;AAAA,EAE5Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AAC/D,YAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AACpD,YAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,oBAAoB,eAAe;;AACjC,aAAO,YACL,oDAAe,gBAAf,YAA8B,kCAE9B,oDAAe,yBAAf,YAAuC;AAAA,IAE3C;AAAA,IACA,uBAAuB,eAAe;;AACpC,UAAI,CAAC,0BAA0B,EAAC,+CAAe,yBAAwB;AACrE,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAEI,UAAoB,EAAC,+CAAe,UAAS;AACvC,gBAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,oDAAe,gBAAf,YAA8B;AAEhD,aAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,qCACE,0DAAe,2BAAf,YAAyC,2BAAzC,YAAmE;AAAA,QACrE,IAAI,+CAAe,WACf,EAAC,+BAA+B,cAAc,QAAA,IAC9C,CAAC;AAAA,MAAA;AAAA,IAET;AAAA,IACA,sBAAsB,eAAe;;AACnC,UAAI,CAAC,yBAAyB,EAAC,+CAAe,wBAAuB;AACnE,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,oDAAe,gBAAf,YAA8B;AAEhD,aAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,sCACE,0DAAe,0BAAf,YAAwC,0BAAxC,YAAiE;AAAA,MAAA;AAAA,IAEvE;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"storefront-client.cjs","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\n\n/**\n * The `createStorefrontClient()` function creates helpers that enable you to quickly query the Shopify Storefront API.\n *\n * When used on the server, it is recommended to use the `privateStorefrontToken` prop. When used on the client, it is recommended to use the `publicStorefrontToken` prop.\n */\nexport function createStorefrontClient({\n storeDomain,\n privateStorefrontToken,\n publicStorefrontToken,\n storefrontApiVersion,\n contentType,\n}: StorefrontClientProps): StorefrontClientReturn {\n if (storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: \"${storefrontApiVersion}\"; expected version \"${SFAPI_VERSION}\"`\n );\n }\n\n // only warn if not in a browser environment\n if (__HYDROGEN_DEV__ && !privateStorefrontToken && !globalThis.document) {\n console.warn(\n `StorefrontClient: Using a private storefront token is recommended for server environments. Refer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details. `\n );\n }\n\n // only warn if in a browser environment and you're using the privateStorefrontToken\n if (__HYDROGEN_DEV__ && privateStorefrontToken && globalThis) {\n console.warn(\n `StorefrontClient: You are attempting to use a private token in an environment where it can be easily accessed by anyone. This is a security risk; please use the public token and the 'publicStorefrontToken' prop`\n );\n }\n\n return {\n getStorefrontApiUrl(overrideProps) {\n return `https://${\n overrideProps?.storeDomain ?? storeDomain\n }.myshopify.com/api/${\n overrideProps?.storefrontApiVersion ?? storefrontApiVersion\n }/graphql.json`;\n },\n getPrivateTokenHeaders(overrideProps) {\n if (!privateStorefrontToken && !overrideProps?.privateStorefrontToken) {\n throw new Error(\n `StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`\n );\n }\n\n if (__HYDROGEN_DEV__ && !overrideProps?.buyerIp) {\n console.warn(\n `StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`\n );\n }\n\n const finalContentType = overrideProps?.contentType ?? contentType;\n\n return {\n // default to json\n 'content-type':\n finalContentType === 'graphql'\n ? 'application/graphql'\n : 'application/json',\n 'X-SDK-Variant': 'hydrogen-ui',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'Shopify-Storefront-Private-Token':\n overrideProps?.privateStorefrontToken ?? privateStorefrontToken ?? '',\n ...(overrideProps?.buyerIp\n ? {'Shopify-Storefront-Buyer-IP': overrideProps.buyerIp}\n : {}),\n };\n },\n getPublicTokenHeaders(overrideProps) {\n if (!publicStorefrontToken && !overrideProps?.publicStorefrontToken) {\n throw new Error(\n `StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`\n );\n }\n\n const finalContentType = overrideProps?.contentType ?? contentType;\n\n return {\n // default to json\n 'content-type':\n finalContentType === 'graphql'\n ? 'application/graphql'\n : 'application/json',\n 'X-SDK-Variant': 'hydrogen-ui',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'X-Shopify-Storefront-Access-Token':\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? '',\n };\n },\n };\n}\n\ntype StorefrontClientProps = {\n /** The host name of the domain (eg: `{shop}.myshopify.com`). */\n storeDomain: string;\n /** The Storefront API delegate access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) and [delegate access token](https://shopify.dev/apps/auth/oauth/delegate-access-tokens) documentation for more details. */\n privateStorefrontToken?: string;\n /** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n publicStorefrontToken?: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n /**\n * Customizes which `\"content-type\"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `\"json\"`. When fetching with a `body` that is a plain string, use `\"graphql\"`. Defaults to `\"json\"`\n *\n * Can also be customized on a call-by-call basis by passing in `'contentType'` to both `getPrivateTokenHeaders({...})` and `getPublicTokenHeaders({...})`, for example: `getPublicTokenHeaders({contentType: 'graphql'})`\n */\n contentType?: 'json' | 'graphql';\n};\n\ntype OverrideTokenHeaderProps = Partial<\n Pick<StorefrontClientProps, 'contentType'>\n>;\n\ntype StorefrontClientReturn = {\n /**\n * Creates the fully-qualified URL to your store's GraphQL endpoint.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getStorefrontApiUrl({...})`:\n *\n * - `storeDomain`\n * - `storefrontApiVersion`\n */\n getStorefrontApiUrl: (\n props?: Partial<\n Pick<StorefrontClientProps, 'storeDomain' | 'storefrontApiVersion'>\n >\n ) => string;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:\n *\n * - `contentType`\n * - `privateStorefrontToken`\n * - `buyerIp`\n *\n * Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.\n */\n getPrivateTokenHeaders: (\n props?: OverrideTokenHeaderProps &\n Pick<StorefrontClientProps, 'privateStorefrontToken'> & {\n /**\n * The client's IP address. Passing this to the Storefront API when using a server-to-server token will help improve your store's analytics data.\n */\n buyerIp?: string;\n }\n ) => Record<string, string>;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:\n *\n * - `contentType`\n * - `publicStorefrontToken`\n *\n * Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.\n */\n getPublicTokenHeaders: (\n props?: OverrideTokenHeaderProps &\n Pick<StorefrontClientProps, 'publicStorefrontToken'>\n ) => Record<string, string>;\n};\n"],"names":["SFAPI_VERSION"],"mappings":";;;AAOO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyBA,uBAAAA,eAAe;AAClC,YAAA;AAAA,MACN,4NAA4N,4CAA4CA,uBAAAA;AAAAA,IAAA;AAAA,EAE5Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AAC/D,YAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AACpD,YAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,oBAAoB,eAAe;;AACjC,aAAO,YACL,oDAAe,gBAAf,YAA8B,kCAE9B,oDAAe,yBAAf,YAAuC;AAAA,IAE3C;AAAA,IACA,uBAAuB,eAAe;;AACpC,UAAI,CAAC,0BAA0B,EAAC,+CAAe,yBAAwB;AACrE,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAEI,UAAoB,EAAC,+CAAe,UAAS;AACvC,gBAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,oDAAe,gBAAf,YAA8B;AAEhD,aAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,qCACE,0DAAe,2BAAf,YAAyC,2BAAzC,YAAmE;AAAA,QACrE,IAAI,+CAAe,WACf,EAAC,+BAA+B,cAAc,QAAA,IAC9C,CAAC;AAAA,MAAA;AAAA,IAET;AAAA,IACA,sBAAsB,eAAe;;AACnC,UAAI,CAAC,yBAAyB,EAAC,+CAAe,wBAAuB;AACnE,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,oDAAe,gBAAf,YAA8B;AAEhD,aAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,sCACE,0DAAe,0BAAf,YAAwC,0BAAxC,YAAiE;AAAA,MAAA;AAAA,IAEvE;AAAA,EAAA;AAEJ;;"}
@@ -0,0 +1,72 @@
1
+ import { SFAPI_VERSION } from "./storefront-api-constants.js";
2
+ function createStorefrontClient({
3
+ storeDomain,
4
+ privateStorefrontToken,
5
+ publicStorefrontToken,
6
+ storefrontApiVersion,
7
+ contentType
8
+ }) {
9
+ if (storefrontApiVersion !== SFAPI_VERSION) {
10
+ console.warn(
11
+ `StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${storefrontApiVersion}"; expected version "${SFAPI_VERSION}"`
12
+ );
13
+ }
14
+ if (!privateStorefrontToken && !globalThis.document) {
15
+ console.warn(
16
+ `StorefrontClient: Using a private storefront token is recommended for server environments. Refer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details. `
17
+ );
18
+ }
19
+ if (privateStorefrontToken && globalThis) {
20
+ console.warn(
21
+ `StorefrontClient: You are attempting to use a private token in an environment where it can be easily accessed by anyone. This is a security risk; please use the public token and the 'publicStorefrontToken' prop`
22
+ );
23
+ }
24
+ return {
25
+ getStorefrontApiUrl(overrideProps) {
26
+ var _a, _b;
27
+ return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com/api/${(_b = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _b : storefrontApiVersion}/graphql.json`;
28
+ },
29
+ getPrivateTokenHeaders(overrideProps) {
30
+ var _a, _b, _c;
31
+ if (!privateStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.privateStorefrontToken)) {
32
+ throw new Error(
33
+ `StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`
34
+ );
35
+ }
36
+ if (!(overrideProps == null ? void 0 : overrideProps.buyerIp)) {
37
+ console.warn(
38
+ `StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`
39
+ );
40
+ }
41
+ const finalContentType = (_a = overrideProps == null ? void 0 : overrideProps.contentType) != null ? _a : contentType;
42
+ return {
43
+ "content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
44
+ "X-SDK-Variant": "hydrogen-ui",
45
+ "X-SDK-Variant-Source": "react",
46
+ "X-SDK-Version": storefrontApiVersion,
47
+ "Shopify-Storefront-Private-Token": (_c = (_b = overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) != null ? _b : privateStorefrontToken) != null ? _c : "",
48
+ ...(overrideProps == null ? void 0 : overrideProps.buyerIp) ? { "Shopify-Storefront-Buyer-IP": overrideProps.buyerIp } : {}
49
+ };
50
+ },
51
+ getPublicTokenHeaders(overrideProps) {
52
+ var _a, _b, _c;
53
+ if (!publicStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken)) {
54
+ throw new Error(
55
+ `StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`
56
+ );
57
+ }
58
+ const finalContentType = (_a = overrideProps == null ? void 0 : overrideProps.contentType) != null ? _a : contentType;
59
+ return {
60
+ "content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
61
+ "X-SDK-Variant": "hydrogen-ui",
62
+ "X-SDK-Variant-Source": "react",
63
+ "X-SDK-Version": storefrontApiVersion,
64
+ "X-Shopify-Storefront-Access-Token": (_c = (_b = overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) != null ? _b : publicStorefrontToken) != null ? _c : ""
65
+ };
66
+ }
67
+ };
68
+ }
69
+ export {
70
+ createStorefrontClient
71
+ };
72
+ //# sourceMappingURL=storefront-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-client.js","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\n\n/**\n * The `createStorefrontClient()` function creates helpers that enable you to quickly query the Shopify Storefront API.\n *\n * When used on the server, it is recommended to use the `privateStorefrontToken` prop. When used on the client, it is recommended to use the `publicStorefrontToken` prop.\n */\nexport function createStorefrontClient({\n storeDomain,\n privateStorefrontToken,\n publicStorefrontToken,\n storefrontApiVersion,\n contentType,\n}: StorefrontClientProps): StorefrontClientReturn {\n if (storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: \"${storefrontApiVersion}\"; expected version \"${SFAPI_VERSION}\"`\n );\n }\n\n // only warn if not in a browser environment\n if (__HYDROGEN_DEV__ && !privateStorefrontToken && !globalThis.document) {\n console.warn(\n `StorefrontClient: Using a private storefront token is recommended for server environments. Refer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details. `\n );\n }\n\n // only warn if in a browser environment and you're using the privateStorefrontToken\n if (__HYDROGEN_DEV__ && privateStorefrontToken && globalThis) {\n console.warn(\n `StorefrontClient: You are attempting to use a private token in an environment where it can be easily accessed by anyone. This is a security risk; please use the public token and the 'publicStorefrontToken' prop`\n );\n }\n\n return {\n getStorefrontApiUrl(overrideProps) {\n return `https://${\n overrideProps?.storeDomain ?? storeDomain\n }.myshopify.com/api/${\n overrideProps?.storefrontApiVersion ?? storefrontApiVersion\n }/graphql.json`;\n },\n getPrivateTokenHeaders(overrideProps) {\n if (!privateStorefrontToken && !overrideProps?.privateStorefrontToken) {\n throw new Error(\n `StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`\n );\n }\n\n if (__HYDROGEN_DEV__ && !overrideProps?.buyerIp) {\n console.warn(\n `StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`\n );\n }\n\n const finalContentType = overrideProps?.contentType ?? contentType;\n\n return {\n // default to json\n 'content-type':\n finalContentType === 'graphql'\n ? 'application/graphql'\n : 'application/json',\n 'X-SDK-Variant': 'hydrogen-ui',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'Shopify-Storefront-Private-Token':\n overrideProps?.privateStorefrontToken ?? privateStorefrontToken ?? '',\n ...(overrideProps?.buyerIp\n ? {'Shopify-Storefront-Buyer-IP': overrideProps.buyerIp}\n : {}),\n };\n },\n getPublicTokenHeaders(overrideProps) {\n if (!publicStorefrontToken && !overrideProps?.publicStorefrontToken) {\n throw new Error(\n `StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`\n );\n }\n\n const finalContentType = overrideProps?.contentType ?? contentType;\n\n return {\n // default to json\n 'content-type':\n finalContentType === 'graphql'\n ? 'application/graphql'\n : 'application/json',\n 'X-SDK-Variant': 'hydrogen-ui',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'X-Shopify-Storefront-Access-Token':\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? '',\n };\n },\n };\n}\n\ntype StorefrontClientProps = {\n /** The host name of the domain (eg: `{shop}.myshopify.com`). */\n storeDomain: string;\n /** The Storefront API delegate access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) and [delegate access token](https://shopify.dev/apps/auth/oauth/delegate-access-tokens) documentation for more details. */\n privateStorefrontToken?: string;\n /** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n publicStorefrontToken?: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n /**\n * Customizes which `\"content-type\"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `\"json\"`. When fetching with a `body` that is a plain string, use `\"graphql\"`. Defaults to `\"json\"`\n *\n * Can also be customized on a call-by-call basis by passing in `'contentType'` to both `getPrivateTokenHeaders({...})` and `getPublicTokenHeaders({...})`, for example: `getPublicTokenHeaders({contentType: 'graphql'})`\n */\n contentType?: 'json' | 'graphql';\n};\n\ntype OverrideTokenHeaderProps = Partial<\n Pick<StorefrontClientProps, 'contentType'>\n>;\n\ntype StorefrontClientReturn = {\n /**\n * Creates the fully-qualified URL to your store's GraphQL endpoint.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getStorefrontApiUrl({...})`:\n *\n * - `storeDomain`\n * - `storefrontApiVersion`\n */\n getStorefrontApiUrl: (\n props?: Partial<\n Pick<StorefrontClientProps, 'storeDomain' | 'storefrontApiVersion'>\n >\n ) => string;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:\n *\n * - `contentType`\n * - `privateStorefrontToken`\n * - `buyerIp`\n *\n * Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.\n */\n getPrivateTokenHeaders: (\n props?: OverrideTokenHeaderProps &\n Pick<StorefrontClientProps, 'privateStorefrontToken'> & {\n /**\n * The client's IP address. Passing this to the Storefront API when using a server-to-server token will help improve your store's analytics data.\n */\n buyerIp?: string;\n }\n ) => Record<string, string>;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This method uses the private Server-to-Server token which reduces the chance of throttling but must not be exposed to clients. Server-side calls should prefer using this over `getPublicTokenHeaders()`.\n *\n * By default, it will use the config you passed in when calling `createStorefrontClient()`. However, you can override the following settings on each invocation of `getPrivateTokenHeaders({...})`:\n *\n * - `contentType`\n * - `publicStorefrontToken`\n *\n * Note that `contentType` defaults to what you configured in `createStorefrontClient({...})` and defaults to `'json'`, but a specific call may require using `graphql`. When using `JSON.stringify()` on the `body`, use `'json'`; otherwise, use `'graphql'`.\n */\n getPublicTokenHeaders: (\n props?: OverrideTokenHeaderProps &\n Pick<StorefrontClientProps, 'publicStorefrontToken'>\n ) => Record<string, string>;\n};\n"],"names":[],"mappings":";AAOO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyB,eAAe;AAClC,YAAA;AAAA,MACN,4NAA4N,4CAA4C;AAAA,IAAA;AAAA,EAE5Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AAC/D,YAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AACpD,YAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,oBAAoB,eAAe;;AACjC,aAAO,YACL,oDAAe,gBAAf,YAA8B,kCAE9B,oDAAe,yBAAf,YAAuC;AAAA,IAE3C;AAAA,IACA,uBAAuB,eAAe;;AACpC,UAAI,CAAC,0BAA0B,EAAC,+CAAe,yBAAwB;AACrE,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAEI,UAAoB,EAAC,+CAAe,UAAS;AACvC,gBAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,oDAAe,gBAAf,YAA8B;AAEhD,aAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,qCACE,0DAAe,2BAAf,YAAyC,2BAAzC,YAAmE;AAAA,QACrE,IAAI,+CAAe,WACf,EAAC,+BAA+B,cAAc,QAAA,IAC9C,CAAC;AAAA,MAAA;AAAA,IAET;AAAA,IACA,sBAAsB,eAAe;;AACnC,UAAI,CAAC,yBAAyB,EAAC,+CAAe,wBAAuB;AACnE,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,oDAAe,gBAAf,YAA8B;AAEhD,aAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,sCACE,0DAAe,0BAAf,YAAwC,0BAAxC,YAAiE;AAAA,MAAA;AAAA,IAEvE;AAAA,EAAA;AAEJ;"}
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const fsm = require("./node_modules/@xstate/react/es/fsm.js");
4
- const index = require("./node_modules/@xstate/fsm/es/index.js");
5
- const flattenConnection = require("./flatten-connection.js");
6
- const useCartActions = require("./useCartActions.js");
7
- const require$$0 = require("react");
3
+ const fsm$1 = require("@xstate/react/fsm");
4
+ const fsm = require("@xstate/fsm");
5
+ const flattenConnection = require("./flatten-connection.cjs");
6
+ const useCartActions = require("./useCartActions.cjs");
7
+ const react = require("react");
8
8
  function invokeCart(action, options) {
9
9
  return {
10
10
  entry: [...(options == null ? void 0 : options.entryActions) || [], "onCartActionEntry", "onCartActionOptimisticUI", action],
11
11
  on: {
12
12
  RESOLVE: {
13
13
  target: (options == null ? void 0 : options.resolveTarget) || "idle",
14
- actions: [index.assign({
14
+ actions: [fsm.assign({
15
15
  prevCart: (context) => context == null ? void 0 : context.cart,
16
16
  cart: (_, event) => {
17
17
  var _a;
@@ -26,7 +26,7 @@ function invokeCart(action, options) {
26
26
  },
27
27
  ERROR: {
28
28
  target: (options == null ? void 0 : options.errorTarget) || "error",
29
- actions: [index.assign({
29
+ actions: [fsm.assign({
30
30
  prevCart: (context) => context == null ? void 0 : context.cart,
31
31
  cart: (context) => context == null ? void 0 : context.lastValidCart,
32
32
  errors: (_, event) => {
@@ -37,7 +37,7 @@ function invokeCart(action, options) {
37
37
  },
38
38
  CART_COMPLETED: {
39
39
  target: "cartCompleted",
40
- actions: index.assign({
40
+ actions: fsm.assign({
41
41
  prevCart: (_) => void 0,
42
42
  cart: (_) => void 0,
43
43
  lastValidCart: (_) => void 0,
@@ -57,7 +57,7 @@ const INITIALIZING_CART_EVENTS = {
57
57
  },
58
58
  CART_SET: {
59
59
  target: "idle",
60
- actions: [index.assign({
60
+ actions: [fsm.assign({
61
61
  rawCartResult: (_, event) => event.payload.cart,
62
62
  cart: (_, event) => cartFromGraphQL(event.payload.cart)
63
63
  })]
@@ -87,7 +87,7 @@ const UPDATING_CART_EVENTS = {
87
87
  }
88
88
  };
89
89
  function createCartMachine(initialCart) {
90
- return index.createMachine({
90
+ return fsm.createMachine({
91
91
  id: "Cart",
92
92
  initial: initialCart ? "idle" : "uninitialized",
93
93
  context: {
@@ -155,8 +155,8 @@ function useCartAPIStateMachine({
155
155
  cartFragment,
156
156
  countryCode
157
157
  });
158
- const cartMachine = require$$0.useMemo(() => createCartMachine(cart), [cart]);
159
- const [state, send, service] = fsm.useMachine(cartMachine, {
158
+ const cartMachine = react.useMemo(() => createCartMachine(cart), [cart]);
159
+ const [state, send, service] = fsm$1.useMachine(cartMachine, {
160
160
  actions: {
161
161
  cartFetchAction: async (_, event) => {
162
162
  var _a;
@@ -265,7 +265,7 @@ function useCartAPIStateMachine({
265
265
  }
266
266
  },
267
267
  ...onCartActionOptimisticUI && {
268
- onCartActionOptimisticUI: index.assign((context, event) => {
268
+ onCartActionOptimisticUI: fsm.assign((context, event) => {
269
269
  return onCartActionOptimisticUI(context, event);
270
270
  })
271
271
  },
@@ -278,7 +278,7 @@ function useCartAPIStateMachine({
278
278
  }
279
279
  }
280
280
  });
281
- return require$$0.useMemo(() => [state, send, service], [state, send, service]);
281
+ return react.useMemo(() => [state, send, service], [state, send, service]);
282
282
  }
283
283
  function cartFromGraphQL(cart) {
284
284
  var _a;
@@ -323,4 +323,4 @@ function isCartFetchResultEvent(event) {
323
323
  }
324
324
  exports.cartFromGraphQL = cartFromGraphQL;
325
325
  exports.useCartAPIStateMachine = useCartAPIStateMachine;
326
- //# sourceMappingURL=useCartAPIStateMachine.js.map
326
+ //# sourceMappingURL=useCartAPIStateMachine.cjs.map