@shopify/hydrogen-react 2022.10.7 → 2023.1.4
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.
- package/README.md +41 -45
- package/dist/browser-dev/AddToCartButton.mjs +43 -40
- package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
- package/dist/browser-dev/BaseButton.mjs +13 -15
- package/dist/browser-dev/BaseButton.mjs.map +1 -1
- package/dist/browser-dev/BuyNowButton.mjs +19 -17
- package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
- package/dist/browser-dev/CartCheckoutButton.mjs +12 -15
- package/dist/browser-dev/CartCheckoutButton.mjs.map +1 -1
- package/dist/browser-dev/CartCost.mjs +25 -0
- package/dist/browser-dev/CartCost.mjs.map +1 -0
- package/dist/browser-dev/CartLinePrice.mjs +18 -0
- package/dist/browser-dev/CartLinePrice.mjs.map +1 -0
- package/dist/browser-dev/CartLineProvider.mjs +19 -0
- package/dist/browser-dev/CartLineProvider.mjs.map +1 -0
- package/dist/browser-dev/CartProvider.mjs +73 -67
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/ExternalVideo.mjs +13 -11
- package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
- package/dist/browser-dev/Image.mjs +41 -30
- package/dist/browser-dev/Image.mjs.map +1 -1
- package/dist/browser-dev/MediaFile.mjs +29 -21
- package/dist/browser-dev/MediaFile.mjs.map +1 -1
- package/dist/browser-dev/ModelViewer.mjs +138 -76
- package/dist/browser-dev/ModelViewer.mjs.map +1 -1
- package/dist/browser-dev/Money.mjs +12 -9
- package/dist/browser-dev/Money.mjs.map +1 -1
- package/dist/browser-dev/ProductPrice.mjs +12 -17
- package/dist/browser-dev/ProductPrice.mjs.map +1 -1
- package/dist/browser-dev/ProductProvider.mjs +102 -73
- package/dist/browser-dev/ProductProvider.mjs.map +1 -1
- package/dist/browser-dev/ShopPayButton.mjs +14 -24
- package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
- package/dist/browser-dev/ShopifyProvider.mjs +22 -38
- package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-dev/Video.mjs +30 -21
- package/dist/browser-dev/Video.mjs.map +1 -1
- package/dist/browser-dev/_virtual/index.mjs +11 -2
- package/dist/browser-dev/_virtual/index.mjs.map +1 -1
- package/dist/browser-dev/_virtual/with-selector.mjs +11 -2
- package/dist/browser-dev/_virtual/with-selector.mjs.map +1 -1
- package/dist/browser-dev/analytics-constants.mjs +43 -0
- package/dist/browser-dev/analytics-constants.mjs.map +1 -0
- package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/browser-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/browser-dev/analytics-utils.mjs +49 -0
- package/dist/browser-dev/analytics-utils.mjs.map +1 -0
- package/dist/browser-dev/analytics.mjs +159 -0
- package/dist/browser-dev/analytics.mjs.map +1 -0
- package/dist/browser-dev/cart-hooks.mjs +29 -34
- package/dist/browser-dev/cart-hooks.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs +50 -28
- package/dist/browser-dev/cart-queries.mjs.map +1 -1
- package/dist/browser-dev/codegen.helpers.mjs +1 -0
- package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
- package/dist/browser-dev/cookies-utils.mjs +50 -0
- package/dist/browser-dev/cookies-utils.mjs.map +1 -0
- package/dist/browser-dev/flatten-connection.mjs +7 -5
- package/dist/browser-dev/flatten-connection.mjs.map +1 -1
- package/dist/browser-dev/image-size.mjs +8 -8
- package/dist/browser-dev/image-size.mjs.map +1 -1
- package/dist/browser-dev/index.mjs +20 -6
- package/dist/browser-dev/index.mjs.map +1 -1
- package/dist/browser-dev/load-script.mjs.map +1 -1
- package/dist/browser-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/browser-dev/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/browser-dev/parse-metafield.mjs.map +1 -0
- package/dist/browser-dev/storefront-api-constants.mjs +1 -1
- package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-dev/storefront-client.mjs +19 -20
- package/dist/browser-dev/storefront-client.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs +111 -80
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs +150 -109
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-dev/useMoney.mjs +62 -36
- package/dist/browser-dev/useMoney.mjs.map +1 -1
- package/dist/browser-dev/useShopifyCookies.mjs +41 -0
- package/dist/browser-dev/useShopifyCookies.mjs.map +1 -0
- package/dist/browser-prod/AddToCartButton.mjs +43 -40
- package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
- package/dist/browser-prod/BaseButton.mjs +13 -15
- package/dist/browser-prod/BaseButton.mjs.map +1 -1
- package/dist/browser-prod/BuyNowButton.mjs +19 -17
- package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
- package/dist/browser-prod/CartCheckoutButton.mjs +12 -15
- package/dist/browser-prod/CartCheckoutButton.mjs.map +1 -1
- package/dist/browser-prod/CartCost.mjs +25 -0
- package/dist/browser-prod/CartCost.mjs.map +1 -0
- package/dist/browser-prod/CartLinePrice.mjs +18 -0
- package/dist/browser-prod/CartLinePrice.mjs.map +1 -0
- package/dist/browser-prod/CartLineProvider.mjs +19 -0
- package/dist/browser-prod/CartLineProvider.mjs.map +1 -0
- package/dist/browser-prod/CartProvider.mjs +73 -67
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/ExternalVideo.mjs +13 -11
- package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
- package/dist/browser-prod/Image.mjs +35 -28
- package/dist/browser-prod/Image.mjs.map +1 -1
- package/dist/browser-prod/MediaFile.mjs +29 -21
- package/dist/browser-prod/MediaFile.mjs.map +1 -1
- package/dist/browser-prod/ModelViewer.mjs +135 -75
- package/dist/browser-prod/ModelViewer.mjs.map +1 -1
- package/dist/browser-prod/Money.mjs +12 -9
- package/dist/browser-prod/Money.mjs.map +1 -1
- package/dist/browser-prod/ProductPrice.mjs +12 -17
- package/dist/browser-prod/ProductPrice.mjs.map +1 -1
- package/dist/browser-prod/ProductProvider.mjs +102 -73
- package/dist/browser-prod/ProductProvider.mjs.map +1 -1
- package/dist/browser-prod/ShopPayButton.mjs +14 -24
- package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
- package/dist/browser-prod/ShopifyProvider.mjs +22 -32
- package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-prod/Video.mjs +30 -21
- package/dist/browser-prod/Video.mjs.map +1 -1
- package/dist/browser-prod/_virtual/index.mjs +11 -2
- package/dist/browser-prod/_virtual/index.mjs.map +1 -1
- package/dist/browser-prod/_virtual/with-selector.mjs +11 -2
- package/dist/browser-prod/_virtual/with-selector.mjs.map +1 -1
- package/dist/browser-prod/analytics-constants.mjs +43 -0
- package/dist/browser-prod/analytics-constants.mjs.map +1 -0
- package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/browser-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/browser-prod/analytics-utils.mjs +49 -0
- package/dist/browser-prod/analytics-utils.mjs.map +1 -0
- package/dist/browser-prod/analytics.mjs +158 -0
- package/dist/browser-prod/analytics.mjs.map +1 -0
- package/dist/browser-prod/cart-hooks.mjs +29 -34
- package/dist/browser-prod/cart-hooks.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs +50 -28
- package/dist/browser-prod/cart-queries.mjs.map +1 -1
- package/dist/browser-prod/codegen.helpers.mjs +1 -0
- package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
- package/dist/browser-prod/cookies-utils.mjs +50 -0
- package/dist/browser-prod/cookies-utils.mjs.map +1 -0
- package/dist/browser-prod/flatten-connection.mjs +7 -5
- package/dist/browser-prod/flatten-connection.mjs.map +1 -1
- package/dist/browser-prod/image-size.mjs +8 -8
- package/dist/browser-prod/image-size.mjs.map +1 -1
- package/dist/browser-prod/index.mjs +20 -6
- package/dist/browser-prod/index.mjs.map +1 -1
- package/dist/browser-prod/load-script.mjs.map +1 -1
- package/dist/browser-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/browser-prod/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/browser-prod/parse-metafield.mjs.map +1 -0
- package/dist/browser-prod/storefront-api-constants.mjs +1 -1
- package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-prod/storefront-client.mjs +19 -20
- package/dist/browser-prod/storefront-client.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs +111 -80
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs +150 -109
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/useMoney.mjs +62 -36
- package/dist/browser-prod/useMoney.mjs.map +1 -1
- package/dist/browser-prod/useShopifyCookies.mjs +41 -0
- package/dist/browser-prod/useShopifyCookies.mjs.map +1 -0
- package/dist/node-dev/AddToCartButton.js +44 -41
- package/dist/node-dev/AddToCartButton.js.map +1 -1
- package/dist/node-dev/AddToCartButton.mjs +43 -40
- package/dist/node-dev/AddToCartButton.mjs.map +1 -1
- package/dist/node-dev/BaseButton.js +14 -16
- package/dist/node-dev/BaseButton.js.map +1 -1
- package/dist/node-dev/BaseButton.mjs +13 -15
- package/dist/node-dev/BaseButton.mjs.map +1 -1
- package/dist/node-dev/BuyNowButton.js +20 -18
- package/dist/node-dev/BuyNowButton.js.map +1 -1
- package/dist/node-dev/BuyNowButton.mjs +19 -17
- package/dist/node-dev/BuyNowButton.mjs.map +1 -1
- package/dist/node-dev/CartCheckoutButton.js +13 -16
- package/dist/node-dev/CartCheckoutButton.js.map +1 -1
- package/dist/node-dev/CartCheckoutButton.mjs +12 -15
- package/dist/node-dev/CartCheckoutButton.mjs.map +1 -1
- package/dist/node-dev/CartCost.js +25 -0
- package/dist/node-dev/CartCost.js.map +1 -0
- package/dist/node-dev/CartCost.mjs +25 -0
- package/dist/node-dev/CartCost.mjs.map +1 -0
- package/dist/node-dev/CartLinePrice.js +18 -0
- package/dist/node-dev/CartLinePrice.js.map +1 -0
- package/dist/node-dev/CartLinePrice.mjs +18 -0
- package/dist/node-dev/CartLinePrice.mjs.map +1 -0
- package/dist/node-dev/CartLineProvider.js +19 -0
- package/dist/node-dev/CartLineProvider.js.map +1 -0
- package/dist/node-dev/CartLineProvider.mjs +19 -0
- package/dist/node-dev/CartLineProvider.mjs.map +1 -0
- package/dist/node-dev/CartProvider.js +74 -68
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs +73 -67
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/ExternalVideo.js +14 -12
- package/dist/node-dev/ExternalVideo.js.map +1 -1
- package/dist/node-dev/ExternalVideo.mjs +13 -11
- package/dist/node-dev/ExternalVideo.mjs.map +1 -1
- package/dist/node-dev/Image.js +42 -31
- package/dist/node-dev/Image.js.map +1 -1
- package/dist/node-dev/Image.mjs +41 -30
- package/dist/node-dev/Image.mjs.map +1 -1
- package/dist/node-dev/MediaFile.js +30 -22
- package/dist/node-dev/MediaFile.js.map +1 -1
- package/dist/node-dev/MediaFile.mjs +29 -21
- package/dist/node-dev/MediaFile.mjs.map +1 -1
- package/dist/node-dev/ModelViewer.js +139 -77
- package/dist/node-dev/ModelViewer.js.map +1 -1
- package/dist/node-dev/ModelViewer.mjs +138 -76
- package/dist/node-dev/ModelViewer.mjs.map +1 -1
- package/dist/node-dev/Money.js +13 -10
- package/dist/node-dev/Money.js.map +1 -1
- package/dist/node-dev/Money.mjs +12 -9
- package/dist/node-dev/Money.mjs.map +1 -1
- package/dist/node-dev/ProductPrice.js +13 -18
- package/dist/node-dev/ProductPrice.js.map +1 -1
- package/dist/node-dev/ProductPrice.mjs +12 -17
- package/dist/node-dev/ProductPrice.mjs.map +1 -1
- package/dist/node-dev/ProductProvider.js +103 -74
- package/dist/node-dev/ProductProvider.js.map +1 -1
- package/dist/node-dev/ProductProvider.mjs +102 -73
- package/dist/node-dev/ProductProvider.mjs.map +1 -1
- package/dist/node-dev/ShopPayButton.js +14 -24
- package/dist/node-dev/ShopPayButton.js.map +1 -1
- package/dist/node-dev/ShopPayButton.mjs +14 -24
- package/dist/node-dev/ShopPayButton.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js +23 -39
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/ShopifyProvider.mjs +22 -38
- package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/node-dev/Video.js +31 -22
- package/dist/node-dev/Video.js.map +1 -1
- package/dist/node-dev/Video.mjs +30 -21
- package/dist/node-dev/Video.mjs.map +1 -1
- package/dist/node-dev/_virtual/index.js +11 -3
- package/dist/node-dev/_virtual/index.js.map +1 -1
- package/dist/node-dev/_virtual/index.mjs +11 -2
- package/dist/node-dev/_virtual/index.mjs.map +1 -1
- package/dist/node-dev/_virtual/use-sync-external-store-shim.development.js +1 -1
- package/dist/node-dev/_virtual/use-sync-external-store-shim.production.min.js +1 -1
- package/dist/node-dev/_virtual/with-selector.development.js +1 -1
- package/dist/node-dev/_virtual/with-selector.js +11 -3
- package/dist/node-dev/_virtual/with-selector.js.map +1 -1
- package/dist/node-dev/_virtual/with-selector.mjs +11 -2
- package/dist/node-dev/_virtual/with-selector.mjs.map +1 -1
- package/dist/node-dev/_virtual/with-selector.production.min.js +1 -1
- package/dist/node-dev/analytics-constants.js +43 -0
- package/dist/node-dev/analytics-constants.js.map +1 -0
- package/dist/node-dev/analytics-constants.mjs +43 -0
- package/dist/node-dev/analytics-constants.mjs.map +1 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js +145 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js.map +1 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js +58 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.js.map +1 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/node-dev/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/node-dev/analytics-utils.js +49 -0
- package/dist/node-dev/analytics-utils.js.map +1 -0
- package/dist/node-dev/analytics-utils.mjs +49 -0
- package/dist/node-dev/analytics-utils.mjs.map +1 -0
- package/dist/node-dev/analytics.js +159 -0
- package/dist/node-dev/analytics.js.map +1 -0
- package/dist/node-dev/analytics.mjs +159 -0
- package/dist/node-dev/analytics.mjs.map +1 -0
- package/dist/node-dev/cart-constants.js +1 -1
- package/dist/node-dev/cart-hooks.js +29 -34
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/cart-hooks.mjs +29 -34
- package/dist/node-dev/cart-hooks.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js +51 -29
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs +50 -28
- package/dist/node-dev/cart-queries.mjs.map +1 -1
- package/dist/node-dev/codegen.helpers.js +2 -1
- package/dist/node-dev/codegen.helpers.js.map +1 -1
- package/dist/node-dev/codegen.helpers.mjs +1 -0
- package/dist/node-dev/codegen.helpers.mjs.map +1 -1
- package/dist/node-dev/cookies-utils.js +50 -0
- package/dist/node-dev/cookies-utils.js.map +1 -0
- package/dist/node-dev/cookies-utils.mjs +50 -0
- package/dist/node-dev/cookies-utils.mjs.map +1 -0
- package/dist/node-dev/flatten-connection.js +8 -6
- package/dist/node-dev/flatten-connection.js.map +1 -1
- package/dist/node-dev/flatten-connection.mjs +7 -5
- package/dist/node-dev/flatten-connection.mjs.map +1 -1
- package/dist/node-dev/image-size.js +9 -9
- package/dist/node-dev/image-size.js.map +1 -1
- package/dist/node-dev/image-size.mjs +8 -8
- package/dist/node-dev/image-size.mjs.map +1 -1
- package/dist/node-dev/index.js +21 -7
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +20 -6
- package/dist/node-dev/index.mjs.map +1 -1
- package/dist/node-dev/load-script.js +1 -1
- package/dist/node-dev/load-script.js.map +1 -1
- package/dist/node-dev/load-script.mjs.map +1 -1
- package/dist/node-dev/node_modules/@xstate/fsm/es/index.js +1 -1
- package/dist/node-dev/node_modules/@xstate/fsm/es/index.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +2 -2
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +2 -4
- package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js +4 -4
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/node-dev/{metafield-parser.js → parse-metafield.js} +21 -13
- package/dist/node-dev/parse-metafield.js.map +1 -0
- package/dist/node-dev/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/node-dev/parse-metafield.mjs.map +1 -0
- package/dist/node-dev/storefront-api-constants.js +2 -2
- package/dist/node-dev/storefront-api-constants.js.map +1 -1
- package/dist/node-dev/storefront-api-constants.mjs +1 -1
- package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/node-dev/storefront-client.js +20 -21
- package/dist/node-dev/storefront-client.js.map +1 -1
- package/dist/node-dev/storefront-client.mjs +19 -20
- package/dist/node-dev/storefront-client.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +112 -81
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs +111 -80
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js +151 -110
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs +150 -109
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-dev/useMoney.js +63 -37
- package/dist/node-dev/useMoney.js.map +1 -1
- package/dist/node-dev/useMoney.mjs +62 -36
- package/dist/node-dev/useMoney.mjs.map +1 -1
- package/dist/node-dev/useShopifyCookies.js +41 -0
- package/dist/node-dev/useShopifyCookies.js.map +1 -0
- package/dist/node-dev/useShopifyCookies.mjs +41 -0
- package/dist/node-dev/useShopifyCookies.mjs.map +1 -0
- package/dist/node-prod/AddToCartButton.js +44 -41
- package/dist/node-prod/AddToCartButton.js.map +1 -1
- package/dist/node-prod/AddToCartButton.mjs +43 -40
- package/dist/node-prod/AddToCartButton.mjs.map +1 -1
- package/dist/node-prod/BaseButton.js +14 -16
- package/dist/node-prod/BaseButton.js.map +1 -1
- package/dist/node-prod/BaseButton.mjs +13 -15
- package/dist/node-prod/BaseButton.mjs.map +1 -1
- package/dist/node-prod/BuyNowButton.js +20 -18
- package/dist/node-prod/BuyNowButton.js.map +1 -1
- package/dist/node-prod/BuyNowButton.mjs +19 -17
- package/dist/node-prod/BuyNowButton.mjs.map +1 -1
- package/dist/node-prod/CartCheckoutButton.js +13 -16
- package/dist/node-prod/CartCheckoutButton.js.map +1 -1
- package/dist/node-prod/CartCheckoutButton.mjs +12 -15
- package/dist/node-prod/CartCheckoutButton.mjs.map +1 -1
- package/dist/node-prod/CartCost.js +25 -0
- package/dist/node-prod/CartCost.js.map +1 -0
- package/dist/node-prod/CartCost.mjs +25 -0
- package/dist/node-prod/CartCost.mjs.map +1 -0
- package/dist/node-prod/CartLinePrice.js +18 -0
- package/dist/node-prod/CartLinePrice.js.map +1 -0
- package/dist/node-prod/CartLinePrice.mjs +18 -0
- package/dist/node-prod/CartLinePrice.mjs.map +1 -0
- package/dist/node-prod/CartLineProvider.js +19 -0
- package/dist/node-prod/CartLineProvider.js.map +1 -0
- package/dist/node-prod/CartLineProvider.mjs +19 -0
- package/dist/node-prod/CartLineProvider.mjs.map +1 -0
- package/dist/node-prod/CartProvider.js +74 -68
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs +73 -67
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/ExternalVideo.js +14 -12
- package/dist/node-prod/ExternalVideo.js.map +1 -1
- package/dist/node-prod/ExternalVideo.mjs +13 -11
- package/dist/node-prod/ExternalVideo.mjs.map +1 -1
- package/dist/node-prod/Image.js +36 -29
- package/dist/node-prod/Image.js.map +1 -1
- package/dist/node-prod/Image.mjs +35 -28
- package/dist/node-prod/Image.mjs.map +1 -1
- package/dist/node-prod/MediaFile.js +30 -22
- package/dist/node-prod/MediaFile.js.map +1 -1
- package/dist/node-prod/MediaFile.mjs +29 -21
- package/dist/node-prod/MediaFile.mjs.map +1 -1
- package/dist/node-prod/ModelViewer.js +136 -76
- package/dist/node-prod/ModelViewer.js.map +1 -1
- package/dist/node-prod/ModelViewer.mjs +135 -75
- package/dist/node-prod/ModelViewer.mjs.map +1 -1
- package/dist/node-prod/Money.js +13 -10
- package/dist/node-prod/Money.js.map +1 -1
- package/dist/node-prod/Money.mjs +12 -9
- package/dist/node-prod/Money.mjs.map +1 -1
- package/dist/node-prod/ProductPrice.js +13 -18
- package/dist/node-prod/ProductPrice.js.map +1 -1
- package/dist/node-prod/ProductPrice.mjs +12 -17
- package/dist/node-prod/ProductPrice.mjs.map +1 -1
- package/dist/node-prod/ProductProvider.js +103 -74
- package/dist/node-prod/ProductProvider.js.map +1 -1
- package/dist/node-prod/ProductProvider.mjs +102 -73
- package/dist/node-prod/ProductProvider.mjs.map +1 -1
- package/dist/node-prod/ShopPayButton.js +14 -24
- package/dist/node-prod/ShopPayButton.js.map +1 -1
- package/dist/node-prod/ShopPayButton.mjs +14 -24
- package/dist/node-prod/ShopPayButton.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js +23 -33
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/ShopifyProvider.mjs +22 -32
- package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/node-prod/Video.js +31 -22
- package/dist/node-prod/Video.js.map +1 -1
- package/dist/node-prod/Video.mjs +30 -21
- package/dist/node-prod/Video.mjs.map +1 -1
- package/dist/node-prod/_virtual/index.js +11 -3
- package/dist/node-prod/_virtual/index.js.map +1 -1
- package/dist/node-prod/_virtual/index.mjs +11 -2
- package/dist/node-prod/_virtual/index.mjs.map +1 -1
- package/dist/node-prod/_virtual/use-sync-external-store-shim.development.js +1 -1
- package/dist/node-prod/_virtual/use-sync-external-store-shim.production.min.js +1 -1
- package/dist/node-prod/_virtual/with-selector.development.js +1 -1
- package/dist/node-prod/_virtual/with-selector.js +11 -3
- package/dist/node-prod/_virtual/with-selector.js.map +1 -1
- package/dist/node-prod/_virtual/with-selector.mjs +11 -2
- package/dist/node-prod/_virtual/with-selector.mjs.map +1 -1
- package/dist/node-prod/_virtual/with-selector.production.min.js +1 -1
- package/dist/node-prod/analytics-constants.js +43 -0
- package/dist/node-prod/analytics-constants.js.map +1 -0
- package/dist/node-prod/analytics-constants.mjs +43 -0
- package/dist/node-prod/analytics-constants.mjs.map +1 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js +145 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js.map +1 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs +145 -0
- package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs.map +1 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js +58 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.js.map +1 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs +58 -0
- package/dist/node-prod/analytics-schema-trekkie-storefront-page-view.mjs.map +1 -0
- package/dist/node-prod/analytics-utils.js +49 -0
- package/dist/node-prod/analytics-utils.js.map +1 -0
- package/dist/node-prod/analytics-utils.mjs +49 -0
- package/dist/node-prod/analytics-utils.mjs.map +1 -0
- package/dist/node-prod/analytics.js +158 -0
- package/dist/node-prod/analytics.js.map +1 -0
- package/dist/node-prod/analytics.mjs +158 -0
- package/dist/node-prod/analytics.mjs.map +1 -0
- package/dist/node-prod/cart-constants.js +1 -1
- package/dist/node-prod/cart-hooks.js +29 -34
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/cart-hooks.mjs +29 -34
- package/dist/node-prod/cart-hooks.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js +51 -29
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs +50 -28
- package/dist/node-prod/cart-queries.mjs.map +1 -1
- package/dist/node-prod/codegen.helpers.js +2 -1
- package/dist/node-prod/codegen.helpers.js.map +1 -1
- package/dist/node-prod/codegen.helpers.mjs +1 -0
- package/dist/node-prod/codegen.helpers.mjs.map +1 -1
- package/dist/node-prod/cookies-utils.js +50 -0
- package/dist/node-prod/cookies-utils.js.map +1 -0
- package/dist/node-prod/cookies-utils.mjs +50 -0
- package/dist/node-prod/cookies-utils.mjs.map +1 -0
- package/dist/node-prod/flatten-connection.js +8 -6
- package/dist/node-prod/flatten-connection.js.map +1 -1
- package/dist/node-prod/flatten-connection.mjs +7 -5
- package/dist/node-prod/flatten-connection.mjs.map +1 -1
- package/dist/node-prod/image-size.js +9 -9
- package/dist/node-prod/image-size.js.map +1 -1
- package/dist/node-prod/image-size.mjs +8 -8
- package/dist/node-prod/image-size.mjs.map +1 -1
- package/dist/node-prod/index.js +21 -7
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +20 -6
- package/dist/node-prod/index.mjs.map +1 -1
- package/dist/node-prod/load-script.js +1 -1
- package/dist/node-prod/load-script.js.map +1 -1
- package/dist/node-prod/load-script.mjs.map +1 -1
- package/dist/node-prod/node_modules/@xstate/fsm/es/index.js +1 -1
- package/dist/node-prod/node_modules/@xstate/fsm/es/index.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +2 -2
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +2 -2
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +2 -4
- package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +2 -4
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -4
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +2 -4
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -4
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js +4 -4
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +3 -3
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/node-prod/{metafield-parser.js → parse-metafield.js} +21 -13
- package/dist/node-prod/parse-metafield.js.map +1 -0
- package/dist/node-prod/{metafield-parser.mjs → parse-metafield.mjs} +20 -12
- package/dist/node-prod/parse-metafield.mjs.map +1 -0
- package/dist/node-prod/storefront-api-constants.js +2 -2
- package/dist/node-prod/storefront-api-constants.js.map +1 -1
- package/dist/node-prod/storefront-api-constants.mjs +1 -1
- package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/node-prod/storefront-client.js +20 -21
- package/dist/node-prod/storefront-client.js.map +1 -1
- package/dist/node-prod/storefront-client.mjs +19 -20
- package/dist/node-prod/storefront-client.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +112 -81
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs +111 -80
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js +151 -110
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs +150 -109
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/node-prod/useMoney.js +63 -37
- package/dist/node-prod/useMoney.js.map +1 -1
- package/dist/node-prod/useMoney.mjs +62 -36
- package/dist/node-prod/useMoney.mjs.map +1 -1
- package/dist/node-prod/useShopifyCookies.js +41 -0
- package/dist/node-prod/useShopifyCookies.js.map +1 -0
- package/dist/node-prod/useShopifyCookies.mjs +41 -0
- package/dist/node-prod/useShopifyCookies.mjs.map +1 -0
- package/dist/types/AddToCartButton.d.ts +3 -2
- package/dist/types/BuyNowButton.d.ts +7 -3
- package/dist/types/CartCheckoutButton.d.ts +6 -5
- package/dist/types/CartCost.d.ts +7 -5
- package/dist/types/CartLinePrice.d.ts +4 -4
- package/dist/types/CartLineProvider.d.ts +8 -6
- package/dist/types/CartProvider.d.ts +12 -2
- package/dist/types/ExternalVideo.d.ts +1 -2
- package/dist/types/Image.d.ts +5 -3
- package/dist/types/MediaFile.d.ts +12 -11
- package/dist/types/ModelViewer.d.ts +2 -2
- package/dist/types/ProductPrice.d.ts +1 -1
- package/dist/types/ProductProvider.d.ts +1 -1
- package/dist/types/ShopPayButton.d.ts +10 -10
- package/dist/types/ShopifyProvider.d.ts +36 -40
- package/dist/types/analytics-constants.d.ts +48 -0
- package/dist/types/analytics-schema-custom-storefront-customer-tracking.d.ts +3 -0
- package/dist/types/analytics-schema-trekkie-storefront-page-view.d.ts +2 -0
- package/dist/types/analytics-types.d.ts +108 -0
- package/dist/types/analytics-utils.d.ts +36 -0
- package/dist/types/analytics.d.ts +9 -0
- package/dist/types/cart-queries.d.ts +1 -1
- package/dist/types/cookies-utils.d.ts +4 -0
- package/dist/types/flatten-connection.d.ts +29 -9
- package/dist/types/index.d.cts +11 -4
- package/dist/types/index.d.ts +11 -4
- package/dist/types/{metafield-parser.d.ts → parse-metafield.d.ts} +11 -9
- package/dist/types/storefront-api-constants.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +121 -2
- package/dist/types/storefront-client.d.ts +14 -14
- package/dist/types/useCartActions.d.ts +1 -1
- package/dist/types/useShopifyCookies.d.ts +14 -0
- package/dist/umd/hydrogen-react.dev.js +1634 -1371
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +18 -25
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +24 -19
- package/storefront.schema.json +1 -1
- package/dist/browser-dev/Metafield.mjs +0 -301
- package/dist/browser-dev/Metafield.mjs.map +0 -1
- package/dist/browser-dev/metafield-parser.mjs.map +0 -1
- package/dist/browser-prod/Metafield.mjs +0 -288
- package/dist/browser-prod/Metafield.mjs.map +0 -1
- package/dist/browser-prod/metafield-parser.mjs.map +0 -1
- package/dist/node-dev/Metafield.js +0 -301
- package/dist/node-dev/Metafield.js.map +0 -1
- package/dist/node-dev/Metafield.mjs +0 -301
- package/dist/node-dev/Metafield.mjs.map +0 -1
- package/dist/node-dev/metafield-parser.js.map +0 -1
- package/dist/node-dev/metafield-parser.mjs.map +0 -1
- package/dist/node-prod/Metafield.js +0 -288
- package/dist/node-prod/Metafield.js.map +0 -1
- package/dist/node-prod/Metafield.mjs +0 -288
- package/dist/node-prod/Metafield.mjs.map +0 -1
- package/dist/node-prod/metafield-parser.js.map +0 -1
- package/dist/node-prod/metafield-parser.mjs.map +0 -1
- package/dist/types/Metafield.d.ts +0 -61
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const storefrontApiConstants = require("./storefront-api-constants.js");
|
|
4
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
5
|
-
const warnOnce = (string) => {
|
|
6
|
-
if (!warnings.has(string)) {
|
|
7
|
-
console.warn(string);
|
|
8
|
-
warnings.add(string);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
4
|
function createStorefrontClient({
|
|
12
5
|
storeDomain,
|
|
13
6
|
privateStorefrontToken,
|
|
@@ -17,7 +10,7 @@ function createStorefrontClient({
|
|
|
17
10
|
}) {
|
|
18
11
|
if (storefrontApiVersion !== storefrontApiConstants.SFAPI_VERSION) {
|
|
19
12
|
warnOnce(
|
|
20
|
-
`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen
|
|
13
|
+
`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${storefrontApiVersion}"; expected version "${storefrontApiConstants.SFAPI_VERSION}"`
|
|
21
14
|
);
|
|
22
15
|
}
|
|
23
16
|
if (!privateStorefrontToken && !globalThis.document) {
|
|
@@ -32,15 +25,13 @@ function createStorefrontClient({
|
|
|
32
25
|
}
|
|
33
26
|
return {
|
|
34
27
|
getShopifyDomain(overrideProps) {
|
|
35
|
-
|
|
36
|
-
return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com`;
|
|
28
|
+
return (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
|
|
37
29
|
},
|
|
38
30
|
getStorefrontApiUrl(overrideProps) {
|
|
39
|
-
|
|
40
|
-
return
|
|
31
|
+
const finalDomainUrl = (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
|
|
32
|
+
return `${finalDomainUrl}${finalDomainUrl.endsWith("/") ? "" : "/"}api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? storefrontApiVersion}/graphql.json`;
|
|
41
33
|
},
|
|
42
34
|
getPrivateTokenHeaders(overrideProps) {
|
|
43
|
-
var _a, _b, _c;
|
|
44
35
|
if (!privateStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.privateStorefrontToken)) {
|
|
45
36
|
throw new Error(
|
|
46
37
|
`StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`
|
|
@@ -51,41 +42,49 @@ function createStorefrontClient({
|
|
|
51
42
|
`StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`
|
|
52
43
|
);
|
|
53
44
|
}
|
|
54
|
-
const finalContentType = (
|
|
45
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType;
|
|
55
46
|
return {
|
|
47
|
+
// default to json
|
|
56
48
|
"content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
|
|
57
|
-
"X-SDK-Variant": "hydrogen-
|
|
49
|
+
"X-SDK-Variant": "hydrogen-react",
|
|
58
50
|
"X-SDK-Variant-Source": "react",
|
|
59
51
|
"X-SDK-Version": storefrontApiVersion,
|
|
60
|
-
"Shopify-Storefront-Private-Token": (
|
|
52
|
+
"Shopify-Storefront-Private-Token": (overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) ?? privateStorefrontToken ?? "",
|
|
61
53
|
...(overrideProps == null ? void 0 : overrideProps.buyerIp) ? { "Shopify-Storefront-Buyer-IP": overrideProps.buyerIp } : {}
|
|
62
54
|
};
|
|
63
55
|
},
|
|
64
56
|
getPublicTokenHeaders(overrideProps) {
|
|
65
|
-
var _a, _b, _c, _d;
|
|
66
57
|
if (!publicStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken)) {
|
|
67
58
|
throw new Error(
|
|
68
59
|
`StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`
|
|
69
60
|
);
|
|
70
61
|
}
|
|
71
|
-
const finalContentType = (
|
|
62
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType ?? "json";
|
|
72
63
|
return getPublicTokenHeadersRaw(
|
|
73
64
|
finalContentType,
|
|
74
65
|
storefrontApiVersion,
|
|
75
|
-
(
|
|
66
|
+
(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) ?? publicStorefrontToken ?? ""
|
|
76
67
|
);
|
|
77
68
|
}
|
|
78
69
|
};
|
|
79
70
|
}
|
|
80
71
|
function getPublicTokenHeadersRaw(contentType, storefrontApiVersion, accessToken) {
|
|
81
72
|
return {
|
|
73
|
+
// default to json
|
|
82
74
|
"content-type": contentType === "graphql" ? "application/graphql" : "application/json",
|
|
83
|
-
"X-SDK-Variant": "hydrogen-
|
|
75
|
+
"X-SDK-Variant": "hydrogen-react",
|
|
84
76
|
"X-SDK-Variant-Source": "react",
|
|
85
77
|
"X-SDK-Version": storefrontApiVersion,
|
|
86
78
|
"X-Shopify-Storefront-Access-Token": accessToken
|
|
87
79
|
};
|
|
88
80
|
}
|
|
81
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
82
|
+
const warnOnce = (string) => {
|
|
83
|
+
if (!warnings.has(string)) {
|
|
84
|
+
console.warn(string);
|
|
85
|
+
warnings.add(string);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
89
88
|
exports.createStorefrontClient = createStorefrontClient;
|
|
90
89
|
exports.getPublicTokenHeadersRaw = getPublicTokenHeadersRaw;
|
|
91
90
|
//# sourceMappingURL=storefront-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storefront-client.js","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\n\nconst warnings = new Set<string>();\nconst warnOnce = (string: string) => {\n if (!warnings.has(string)) {\n console.warn(string);\n warnings.add(string);\n }\n};\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 warnOnce(\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 warnOnce(\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 warnOnce(\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 getShopifyDomain(overrideProps) {\n return `https://${\n overrideProps?.storeDomain ?? storeDomain\n }.myshopify.com`;\n },\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 warnOnce(\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 =\n overrideProps?.contentType ?? contentType ?? 'json';\n\n return getPublicTokenHeadersRaw(\n finalContentType,\n storefrontApiVersion,\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? ''\n );\n },\n };\n}\n\nexport function getPublicTokenHeadersRaw(\n contentType: 'graphql' | 'json',\n storefrontApiVersion: string,\n accessToken: string\n) {\n return {\n // default to json\n 'content-type':\n contentType === 'graphql' ? 'application/graphql' : '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': accessToken,\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 myshopify.com domain.\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 `getShopifyDomain({...})`:\n *\n * - `storeDomain`\n */\n getShopifyDomain: (\n props?: Partial<Pick<StorefrontClientProps, 'storeDomain'>>\n ) => string;\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 public token which increases the chance of throttling but also can be exposed to clients. Server-side calls should prefer using `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 `getPublicTokenHeaders({...})`:\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":";;;AAEA,MAAM,+BAAe;AACrB,MAAM,WAAW,CAAC,WAAmB;AACnC,MAAI,CAAC,SAAS,IAAI,MAAM,GAAG;AACzB,YAAQ,KAAK,MAAM;AACnB,aAAS,IAAI,MAAM;AAAA,EACrB;AACF;AAOO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyBA,uBAAAA,eAAe;AAC1C;AAAA,MACE,4NAA4N,4CAA4CA,uBAAAA;AAAAA,IAAA;AAAA,EAE5Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AACvE;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AAC5D;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,iBAAiB,eAAe;;AACvB,aAAA,YACL,oDAAe,gBAAf,YAA8B;AAAA,IAElC;AAAA,IACA,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;AAC/C;AAAA,UACE;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,oBACJ,0DAAe,gBAAf,YAA8B,gBAA9B,YAA6C;AAExC,aAAA;AAAA,QACL;AAAA,QACA;AAAA,SACA,0DAAe,0BAAf,YAAwC,0BAAxC,YAAiE;AAAA,MAAA;AAAA,IAErE;AAAA,EAAA;AAEJ;AAEgB,SAAA,yBACd,aACA,sBACA,aACA;AACO,SAAA;AAAA,IAEL,gBACE,gBAAgB,YAAY,wBAAwB;AAAA,IACtD,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,IACjB,qCAAqC;AAAA,EAAA;AAEzC;;;"}
|
|
1
|
+
{"version":3,"file":"storefront-client.js","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\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 React 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\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 warnOnce(\n `StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen React 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 warnOnce(\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 warnOnce(\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 getShopifyDomain(overrideProps) {\n return overrideProps?.storeDomain ?? storeDomain;\n },\n getStorefrontApiUrl(overrideProps) {\n const finalDomainUrl = overrideProps?.storeDomain ?? storeDomain;\n return `${finalDomainUrl}${finalDomainUrl.endsWith('/') ? '' : '/'}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 warnOnce(\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-react',\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 =\n overrideProps?.contentType ?? contentType ?? 'json';\n\n return getPublicTokenHeadersRaw(\n finalContentType,\n storefrontApiVersion,\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? ''\n );\n },\n };\n}\n\nexport function getPublicTokenHeadersRaw(\n contentType: 'graphql' | 'json',\n storefrontApiVersion: string,\n accessToken: string\n) {\n return {\n // default to json\n 'content-type':\n contentType === 'graphql' ? 'application/graphql' : 'application/json',\n 'X-SDK-Variant': 'hydrogen-react',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'X-Shopify-Storefront-Access-Token': accessToken,\n };\n}\n\nconst warnings = new Set<string>();\nconst warnOnce = (string: string) => {\n if (!warnings.has(string)) {\n console.warn(string);\n warnings.add(string);\n }\n};\n\ntype OverrideTokenHeaderProps = Partial<\n Pick<StorefrontClientProps, 'contentType'>\n>;\n\ntype StorefrontClientReturn = {\n /**\n * Creates the fully-qualified URL to your myshopify.com domain.\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 `getShopifyDomain({...})`:\n *\n * - `storeDomain`\n */\n getShopifyDomain: (\n props?: Partial<Pick<StorefrontClientProps, 'storeDomain'>>\n ) => string;\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 public token which increases the chance of throttling but also can be exposed to clients. Server-side calls should prefer using `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 `getPublicTokenHeaders({...})`:\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":";;;AAwBO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyBA,uBAAAA,eAAe;AAC1C;AAAA,MACE,+NAA+N,4CAA4CA,uBAAAA;AAAAA,IAAA;AAAA,EAE/Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AACvE;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AAC5D;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,iBAAiB,eAAe;AAC9B,cAAO,+CAAe,gBAAe;AAAA,IACvC;AAAA,IACA,oBAAoB,eAAe;AAC3B,YAAA,kBAAiB,+CAAe,gBAAe;AAC9C,aAAA,GAAG,iBAAiB,eAAe,SAAS,GAAG,IAAI,KAAK,WAC7D,+CAAe,yBAAwB;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;AAC/C;AAAA,UACE;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,+CAAe,gBAAe;AAEhD,aAAA;AAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,qCACE,+CAAe,2BAA0B,0BAA0B;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,oBACJ,+CAAe,gBAAe,eAAe;AAExC,aAAA;AAAA,QACL;AAAA,QACA;AAAA,SACA,+CAAe,0BAAyB,yBAAyB;AAAA,MAAA;AAAA,IAErE;AAAA,EAAA;AAEJ;AAEgB,SAAA,yBACd,aACA,sBACA,aACA;AACO,SAAA;AAAA;AAAA,IAEL,gBACE,gBAAgB,YAAY,wBAAwB;AAAA,IACtD,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,IACjB,qCAAqC;AAAA,EAAA;AAEzC;AAEA,MAAM,+BAAe;AACrB,MAAM,WAAW,CAAC,WAAmB;AACnC,MAAI,CAAC,SAAS,IAAI,MAAM,GAAG;AACzB,YAAQ,KAAK,MAAM;AACnB,aAAS,IAAI,MAAM;AAAA,EACrB;AACF;;;"}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { SFAPI_VERSION } from "./storefront-api-constants.mjs";
|
|
2
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
3
|
-
const warnOnce = (string) => {
|
|
4
|
-
if (!warnings.has(string)) {
|
|
5
|
-
console.warn(string);
|
|
6
|
-
warnings.add(string);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
2
|
function createStorefrontClient({
|
|
10
3
|
storeDomain,
|
|
11
4
|
privateStorefrontToken,
|
|
@@ -15,7 +8,7 @@ function createStorefrontClient({
|
|
|
15
8
|
}) {
|
|
16
9
|
if (storefrontApiVersion !== SFAPI_VERSION) {
|
|
17
10
|
warnOnce(
|
|
18
|
-
`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen
|
|
11
|
+
`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${storefrontApiVersion}"; expected version "${SFAPI_VERSION}"`
|
|
19
12
|
);
|
|
20
13
|
}
|
|
21
14
|
if (!privateStorefrontToken && !globalThis.document) {
|
|
@@ -30,15 +23,13 @@ function createStorefrontClient({
|
|
|
30
23
|
}
|
|
31
24
|
return {
|
|
32
25
|
getShopifyDomain(overrideProps) {
|
|
33
|
-
|
|
34
|
-
return `https://${(_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain}.myshopify.com`;
|
|
26
|
+
return (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
|
|
35
27
|
},
|
|
36
28
|
getStorefrontApiUrl(overrideProps) {
|
|
37
|
-
|
|
38
|
-
return
|
|
29
|
+
const finalDomainUrl = (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
|
|
30
|
+
return `${finalDomainUrl}${finalDomainUrl.endsWith("/") ? "" : "/"}api/${(overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) ?? storefrontApiVersion}/graphql.json`;
|
|
39
31
|
},
|
|
40
32
|
getPrivateTokenHeaders(overrideProps) {
|
|
41
|
-
var _a, _b, _c;
|
|
42
33
|
if (!privateStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.privateStorefrontToken)) {
|
|
43
34
|
throw new Error(
|
|
44
35
|
`StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'`
|
|
@@ -49,41 +40,49 @@ function createStorefrontClient({
|
|
|
49
40
|
`StorefrontClient: it is recommended to pass in the 'buyerIp' property which improves analytics and data in the admin.`
|
|
50
41
|
);
|
|
51
42
|
}
|
|
52
|
-
const finalContentType = (
|
|
43
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType;
|
|
53
44
|
return {
|
|
45
|
+
// default to json
|
|
54
46
|
"content-type": finalContentType === "graphql" ? "application/graphql" : "application/json",
|
|
55
|
-
"X-SDK-Variant": "hydrogen-
|
|
47
|
+
"X-SDK-Variant": "hydrogen-react",
|
|
56
48
|
"X-SDK-Variant-Source": "react",
|
|
57
49
|
"X-SDK-Version": storefrontApiVersion,
|
|
58
|
-
"Shopify-Storefront-Private-Token": (
|
|
50
|
+
"Shopify-Storefront-Private-Token": (overrideProps == null ? void 0 : overrideProps.privateStorefrontToken) ?? privateStorefrontToken ?? "",
|
|
59
51
|
...(overrideProps == null ? void 0 : overrideProps.buyerIp) ? { "Shopify-Storefront-Buyer-IP": overrideProps.buyerIp } : {}
|
|
60
52
|
};
|
|
61
53
|
},
|
|
62
54
|
getPublicTokenHeaders(overrideProps) {
|
|
63
|
-
var _a, _b, _c, _d;
|
|
64
55
|
if (!publicStorefrontToken && !(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken)) {
|
|
65
56
|
throw new Error(
|
|
66
57
|
`StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'`
|
|
67
58
|
);
|
|
68
59
|
}
|
|
69
|
-
const finalContentType = (
|
|
60
|
+
const finalContentType = (overrideProps == null ? void 0 : overrideProps.contentType) ?? contentType ?? "json";
|
|
70
61
|
return getPublicTokenHeadersRaw(
|
|
71
62
|
finalContentType,
|
|
72
63
|
storefrontApiVersion,
|
|
73
|
-
(
|
|
64
|
+
(overrideProps == null ? void 0 : overrideProps.publicStorefrontToken) ?? publicStorefrontToken ?? ""
|
|
74
65
|
);
|
|
75
66
|
}
|
|
76
67
|
};
|
|
77
68
|
}
|
|
78
69
|
function getPublicTokenHeadersRaw(contentType, storefrontApiVersion, accessToken) {
|
|
79
70
|
return {
|
|
71
|
+
// default to json
|
|
80
72
|
"content-type": contentType === "graphql" ? "application/graphql" : "application/json",
|
|
81
|
-
"X-SDK-Variant": "hydrogen-
|
|
73
|
+
"X-SDK-Variant": "hydrogen-react",
|
|
82
74
|
"X-SDK-Variant-Source": "react",
|
|
83
75
|
"X-SDK-Version": storefrontApiVersion,
|
|
84
76
|
"X-Shopify-Storefront-Access-Token": accessToken
|
|
85
77
|
};
|
|
86
78
|
}
|
|
79
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
80
|
+
const warnOnce = (string) => {
|
|
81
|
+
if (!warnings.has(string)) {
|
|
82
|
+
console.warn(string);
|
|
83
|
+
warnings.add(string);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
87
86
|
export {
|
|
88
87
|
createStorefrontClient,
|
|
89
88
|
getPublicTokenHeadersRaw
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storefront-client.mjs","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\n\nconst warnings = new Set<string>();\nconst warnOnce = (string: string) => {\n if (!warnings.has(string)) {\n console.warn(string);\n warnings.add(string);\n }\n};\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 warnOnce(\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 warnOnce(\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 warnOnce(\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 getShopifyDomain(overrideProps) {\n return `https://${\n overrideProps?.storeDomain ?? storeDomain\n }.myshopify.com`;\n },\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 warnOnce(\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 =\n overrideProps?.contentType ?? contentType ?? 'json';\n\n return getPublicTokenHeadersRaw(\n finalContentType,\n storefrontApiVersion,\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? ''\n );\n },\n };\n}\n\nexport function getPublicTokenHeadersRaw(\n contentType: 'graphql' | 'json',\n storefrontApiVersion: string,\n accessToken: string\n) {\n return {\n // default to json\n 'content-type':\n contentType === 'graphql' ? 'application/graphql' : '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': accessToken,\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 myshopify.com domain.\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 `getShopifyDomain({...})`:\n *\n * - `storeDomain`\n */\n getShopifyDomain: (\n props?: Partial<Pick<StorefrontClientProps, 'storeDomain'>>\n ) => string;\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 public token which increases the chance of throttling but also can be exposed to clients. Server-side calls should prefer using `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 `getPublicTokenHeaders({...})`:\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":";AAEA,MAAM,+BAAe;AACrB,MAAM,WAAW,CAAC,WAAmB;AACnC,MAAI,CAAC,SAAS,IAAI,MAAM,GAAG;AACzB,YAAQ,KAAK,MAAM;AACnB,aAAS,IAAI,MAAM;AAAA,EACrB;AACF;AAOO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyB,eAAe;AAC1C;AAAA,MACE,4NAA4N,4CAA4C;AAAA,IAAA;AAAA,EAE5Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AACvE;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AAC5D;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,iBAAiB,eAAe;;AACvB,aAAA,YACL,oDAAe,gBAAf,YAA8B;AAAA,IAElC;AAAA,IACA,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;AAC/C;AAAA,UACE;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,oBACJ,0DAAe,gBAAf,YAA8B,gBAA9B,YAA6C;AAExC,aAAA;AAAA,QACL;AAAA,QACA;AAAA,SACA,0DAAe,0BAAf,YAAwC,0BAAxC,YAAiE;AAAA,MAAA;AAAA,IAErE;AAAA,EAAA;AAEJ;AAEgB,SAAA,yBACd,aACA,sBACA,aACA;AACO,SAAA;AAAA,IAEL,gBACE,gBAAgB,YAAY,wBAAwB;AAAA,IACtD,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,IACjB,qCAAqC;AAAA,EAAA;AAEzC;"}
|
|
1
|
+
{"version":3,"file":"storefront-client.mjs","sources":["../../src/storefront-client.ts"],"sourcesContent":["import {SFAPI_VERSION} from './storefront-api-constants.js';\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 React 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\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 warnOnce(\n `StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen React 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 warnOnce(\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 warnOnce(\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 getShopifyDomain(overrideProps) {\n return overrideProps?.storeDomain ?? storeDomain;\n },\n getStorefrontApiUrl(overrideProps) {\n const finalDomainUrl = overrideProps?.storeDomain ?? storeDomain;\n return `${finalDomainUrl}${finalDomainUrl.endsWith('/') ? '' : '/'}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 warnOnce(\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-react',\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 =\n overrideProps?.contentType ?? contentType ?? 'json';\n\n return getPublicTokenHeadersRaw(\n finalContentType,\n storefrontApiVersion,\n overrideProps?.publicStorefrontToken ?? publicStorefrontToken ?? ''\n );\n },\n };\n}\n\nexport function getPublicTokenHeadersRaw(\n contentType: 'graphql' | 'json',\n storefrontApiVersion: string,\n accessToken: string\n) {\n return {\n // default to json\n 'content-type':\n contentType === 'graphql' ? 'application/graphql' : 'application/json',\n 'X-SDK-Variant': 'hydrogen-react',\n 'X-SDK-Variant-Source': 'react',\n 'X-SDK-Version': storefrontApiVersion,\n 'X-Shopify-Storefront-Access-Token': accessToken,\n };\n}\n\nconst warnings = new Set<string>();\nconst warnOnce = (string: string) => {\n if (!warnings.has(string)) {\n console.warn(string);\n warnings.add(string);\n }\n};\n\ntype OverrideTokenHeaderProps = Partial<\n Pick<StorefrontClientProps, 'contentType'>\n>;\n\ntype StorefrontClientReturn = {\n /**\n * Creates the fully-qualified URL to your myshopify.com domain.\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 `getShopifyDomain({...})`:\n *\n * - `storeDomain`\n */\n getShopifyDomain: (\n props?: Partial<Pick<StorefrontClientProps, 'storeDomain'>>\n ) => string;\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 public token which increases the chance of throttling but also can be exposed to clients. Server-side calls should prefer using `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 `getPublicTokenHeaders({...})`:\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":";AAwBO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkD;AAChD,MAAI,yBAAyB,eAAe;AAC1C;AAAA,MACE,+NAA+N,4CAA4C;AAAA,IAAA;AAAA,EAE/Q;AAGA,MAAwB,CAAC,0BAA0B,CAAC,WAAW,UAAU;AACvE;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAGI,MAAoB,0BAA0B,YAAY;AAC5D;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AAAA,IACL,iBAAiB,eAAe;AAC9B,cAAO,+CAAe,gBAAe;AAAA,IACvC;AAAA,IACA,oBAAoB,eAAe;AAC3B,YAAA,kBAAiB,+CAAe,gBAAe;AAC9C,aAAA,GAAG,iBAAiB,eAAe,SAAS,GAAG,IAAI,KAAK,WAC7D,+CAAe,yBAAwB;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;AAC/C;AAAA,UACE;AAAA,QAAA;AAAA,MAEJ;AAEM,YAAA,oBAAmB,+CAAe,gBAAe;AAEhD,aAAA;AAAA;AAAA,QAEL,gBACE,qBAAqB,YACjB,wBACA;AAAA,QACN,iBAAiB;AAAA,QACjB,wBAAwB;AAAA,QACxB,iBAAiB;AAAA,QACjB,qCACE,+CAAe,2BAA0B,0BAA0B;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,oBACJ,+CAAe,gBAAe,eAAe;AAExC,aAAA;AAAA,QACL;AAAA,QACA;AAAA,SACA,+CAAe,0BAAyB,yBAAyB;AAAA,MAAA;AAAA,IAErE;AAAA,EAAA;AAEJ;AAEgB,SAAA,yBACd,aACA,sBACA,aACA;AACO,SAAA;AAAA;AAAA,IAEL,gBACE,gBAAgB,YAAY,wBAAwB;AAAA,IACtD,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,IACjB,qCAAqC;AAAA,EAAA;AAEzC;AAEA,MAAM,+BAAe;AACrB,MAAM,WAAW,CAAC,WAAmB;AACnC,MAAI,CAAC,SAAS,IAAI,MAAM,GAAG;AACzB,YAAQ,KAAK,MAAM;AACnB,aAAS,IAAI,MAAM;AAAA,EACrB;AACF;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fsm = require("./node_modules/@xstate/react/es/fsm.js");
|
|
4
4
|
const index = require("./node_modules/@xstate/fsm/es/index.js");
|
|
5
5
|
const flattenConnection = require("./flatten-connection.js");
|
|
@@ -7,43 +7,59 @@ const useCartActions = require("./useCartActions.js");
|
|
|
7
7
|
const require$$0 = require("react");
|
|
8
8
|
function invokeCart(action, options) {
|
|
9
9
|
return {
|
|
10
|
-
entry: [
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
entry: [
|
|
11
|
+
...(options == null ? void 0 : options.entryActions) || [],
|
|
12
|
+
index.assign({
|
|
13
|
+
lastValidCart: (context) => context == null ? void 0 : context.cart
|
|
14
|
+
}),
|
|
15
|
+
"onCartActionEntry",
|
|
16
|
+
"onCartActionOptimisticUI",
|
|
17
|
+
action
|
|
18
|
+
],
|
|
13
19
|
on: {
|
|
14
20
|
RESOLVE: {
|
|
15
21
|
target: (options == null ? void 0 : options.resolveTarget) || "idle",
|
|
16
|
-
actions: [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
actions: [
|
|
23
|
+
index.assign({
|
|
24
|
+
prevCart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
25
|
+
cart: (_, event) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cart;
|
|
28
|
+
},
|
|
29
|
+
rawCartResult: (_, event) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.rawCartResult;
|
|
32
|
+
},
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
+
errors: (_) => void 0
|
|
35
|
+
})
|
|
36
|
+
]
|
|
28
37
|
},
|
|
29
38
|
ERROR: {
|
|
30
39
|
target: (options == null ? void 0 : options.errorTarget) || "error",
|
|
31
|
-
actions: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
actions: [
|
|
41
|
+
index.assign({
|
|
42
|
+
prevCart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
43
|
+
cart: (context) => context == null ? void 0 : context.lastValidCart,
|
|
44
|
+
errors: (_, event) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.errors;
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
]
|
|
39
50
|
},
|
|
40
51
|
CART_COMPLETED: {
|
|
41
52
|
target: "cartCompleted",
|
|
42
53
|
actions: index.assign({
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
43
55
|
prevCart: (_) => void 0,
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
57
|
cart: (_) => void 0,
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
59
|
lastValidCart: (_) => void 0,
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
61
|
rawCartResult: (_) => void 0,
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
63
|
errors: (_) => void 0
|
|
48
64
|
})
|
|
49
65
|
}
|
|
@@ -60,10 +76,12 @@ const INITIALIZING_CART_EVENTS = {
|
|
|
60
76
|
},
|
|
61
77
|
CART_SET: {
|
|
62
78
|
target: "idle",
|
|
63
|
-
actions: [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
actions: [
|
|
80
|
+
index.assign({
|
|
81
|
+
rawCartResult: (_, event) => event.payload.cart,
|
|
82
|
+
cart: (_, event) => cartFromGraphQL(event.payload.cart)
|
|
83
|
+
})
|
|
84
|
+
]
|
|
67
85
|
}
|
|
68
86
|
};
|
|
69
87
|
const UPDATING_CART_EVENTS = {
|
|
@@ -107,16 +125,10 @@ function createCartMachine(initialCart) {
|
|
|
107
125
|
on: INITIALIZING_CART_EVENTS
|
|
108
126
|
},
|
|
109
127
|
idle: {
|
|
110
|
-
on: {
|
|
111
|
-
...INITIALIZING_CART_EVENTS,
|
|
112
|
-
...UPDATING_CART_EVENTS
|
|
113
|
-
}
|
|
128
|
+
on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
|
|
114
129
|
},
|
|
115
130
|
error: {
|
|
116
|
-
on: {
|
|
117
|
-
...INITIALIZING_CART_EVENTS,
|
|
118
|
-
...UPDATING_CART_EVENTS
|
|
119
|
-
}
|
|
131
|
+
on: { ...INITIALIZING_CART_EVENTS, ...UPDATING_CART_EVENTS }
|
|
120
132
|
},
|
|
121
133
|
cartFetching: invokeCart("cartFetchAction", {
|
|
122
134
|
errorTarget: "initializationError"
|
|
@@ -165,10 +177,7 @@ function useCartAPIStateMachine({
|
|
|
165
177
|
var _a;
|
|
166
178
|
if (event.type !== "CART_FETCH")
|
|
167
179
|
return;
|
|
168
|
-
const {
|
|
169
|
-
data,
|
|
170
|
-
errors
|
|
171
|
-
} = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
|
|
180
|
+
const { data, errors } = await cartFetch((_a = event == null ? void 0 : event.payload) == null ? void 0 : _a.cartId);
|
|
172
181
|
const resultEvent = eventFromFetchResult(event, data == null ? void 0 : data.cart, errors);
|
|
173
182
|
send(resultEvent);
|
|
174
183
|
},
|
|
@@ -176,88 +185,117 @@ function useCartAPIStateMachine({
|
|
|
176
185
|
var _a;
|
|
177
186
|
if (event.type !== "CART_CREATE")
|
|
178
187
|
return;
|
|
179
|
-
const {
|
|
180
|
-
|
|
188
|
+
const { data, errors } = await cartCreate(event == null ? void 0 : event.payload);
|
|
189
|
+
const resultEvent = eventFromFetchResult(
|
|
190
|
+
event,
|
|
191
|
+
(_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart,
|
|
181
192
|
errors
|
|
182
|
-
|
|
183
|
-
const resultEvent = eventFromFetchResult(event, (_a = data == null ? void 0 : data.cartCreate) == null ? void 0 : _a.cart, errors);
|
|
193
|
+
);
|
|
184
194
|
send(resultEvent);
|
|
185
195
|
},
|
|
186
196
|
cartLineAddAction: async (context, event) => {
|
|
187
197
|
var _a, _b;
|
|
188
198
|
if (event.type !== "CARTLINE_ADD" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
189
199
|
return;
|
|
190
|
-
const {
|
|
191
|
-
|
|
200
|
+
const { data, errors } = await cartLineAdd(
|
|
201
|
+
context.cart.id,
|
|
202
|
+
event.payload.lines
|
|
203
|
+
);
|
|
204
|
+
const resultEvent = eventFromFetchResult(
|
|
205
|
+
event,
|
|
206
|
+
(_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart,
|
|
192
207
|
errors
|
|
193
|
-
|
|
194
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesAdd) == null ? void 0 : _b.cart, errors);
|
|
208
|
+
);
|
|
195
209
|
send(resultEvent);
|
|
196
210
|
},
|
|
197
211
|
cartLineUpdateAction: async (context, event) => {
|
|
198
212
|
var _a, _b;
|
|
199
213
|
if (event.type !== "CARTLINE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
200
214
|
return;
|
|
201
|
-
const {
|
|
202
|
-
|
|
215
|
+
const { data, errors } = await cartLineUpdate(
|
|
216
|
+
context.cart.id,
|
|
217
|
+
event.payload.lines
|
|
218
|
+
);
|
|
219
|
+
const resultEvent = eventFromFetchResult(
|
|
220
|
+
event,
|
|
221
|
+
(_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart,
|
|
203
222
|
errors
|
|
204
|
-
|
|
205
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesUpdate) == null ? void 0 : _b.cart, errors);
|
|
223
|
+
);
|
|
206
224
|
send(resultEvent);
|
|
207
225
|
},
|
|
208
226
|
cartLineRemoveAction: async (context, event) => {
|
|
209
227
|
var _a, _b;
|
|
210
228
|
if (event.type !== "CARTLINE_REMOVE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
211
229
|
return;
|
|
212
|
-
const {
|
|
213
|
-
|
|
230
|
+
const { data, errors } = await cartLineRemove(
|
|
231
|
+
context.cart.id,
|
|
232
|
+
event.payload.lines
|
|
233
|
+
);
|
|
234
|
+
const resultEvent = eventFromFetchResult(
|
|
235
|
+
event,
|
|
236
|
+
(_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart,
|
|
214
237
|
errors
|
|
215
|
-
|
|
216
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartLinesRemove) == null ? void 0 : _b.cart, errors);
|
|
238
|
+
);
|
|
217
239
|
send(resultEvent);
|
|
218
240
|
},
|
|
219
241
|
noteUpdateAction: async (context, event) => {
|
|
220
242
|
var _a, _b;
|
|
221
243
|
if (event.type !== "NOTE_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
222
244
|
return;
|
|
223
|
-
const {
|
|
224
|
-
|
|
245
|
+
const { data, errors } = await noteUpdate(
|
|
246
|
+
context.cart.id,
|
|
247
|
+
event.payload.note
|
|
248
|
+
);
|
|
249
|
+
const resultEvent = eventFromFetchResult(
|
|
250
|
+
event,
|
|
251
|
+
(_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart,
|
|
225
252
|
errors
|
|
226
|
-
|
|
227
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartNoteUpdate) == null ? void 0 : _b.cart, errors);
|
|
253
|
+
);
|
|
228
254
|
send(resultEvent);
|
|
229
255
|
},
|
|
230
256
|
buyerIdentityUpdateAction: async (context, event) => {
|
|
231
257
|
var _a, _b;
|
|
232
258
|
if (event.type !== "BUYER_IDENTITY_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
233
259
|
return;
|
|
234
|
-
const {
|
|
235
|
-
|
|
260
|
+
const { data, errors } = await buyerIdentityUpdate(
|
|
261
|
+
context.cart.id,
|
|
262
|
+
event.payload.buyerIdentity
|
|
263
|
+
);
|
|
264
|
+
const resultEvent = eventFromFetchResult(
|
|
265
|
+
event,
|
|
266
|
+
(_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart,
|
|
236
267
|
errors
|
|
237
|
-
|
|
238
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartBuyerIdentityUpdate) == null ? void 0 : _b.cart, errors);
|
|
268
|
+
);
|
|
239
269
|
send(resultEvent);
|
|
240
270
|
},
|
|
241
271
|
cartAttributesUpdateAction: async (context, event) => {
|
|
242
272
|
var _a, _b;
|
|
243
273
|
if (event.type !== "CART_ATTRIBUTES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
244
274
|
return;
|
|
245
|
-
const {
|
|
246
|
-
|
|
275
|
+
const { data, errors } = await cartAttributesUpdate(
|
|
276
|
+
context.cart.id,
|
|
277
|
+
event.payload.attributes
|
|
278
|
+
);
|
|
279
|
+
const resultEvent = eventFromFetchResult(
|
|
280
|
+
event,
|
|
281
|
+
(_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart,
|
|
247
282
|
errors
|
|
248
|
-
|
|
249
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartAttributesUpdate) == null ? void 0 : _b.cart, errors);
|
|
283
|
+
);
|
|
250
284
|
send(resultEvent);
|
|
251
285
|
},
|
|
252
286
|
discountCodesUpdateAction: async (context, event) => {
|
|
253
287
|
var _a, _b;
|
|
254
288
|
if (event.type !== "DISCOUNT_CODES_UPDATE" || !((_a = context == null ? void 0 : context.cart) == null ? void 0 : _a.id))
|
|
255
289
|
return;
|
|
256
|
-
const {
|
|
257
|
-
|
|
290
|
+
const { data, errors } = await discountCodesUpdate(
|
|
291
|
+
context.cart.id,
|
|
292
|
+
event.payload.discountCodes
|
|
293
|
+
);
|
|
294
|
+
const resultEvent = eventFromFetchResult(
|
|
295
|
+
event,
|
|
296
|
+
(_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart,
|
|
258
297
|
errors
|
|
259
|
-
|
|
260
|
-
const resultEvent = eventFromFetchResult(event, (_b = data == null ? void 0 : data.cartDiscountCodesUpdate) == null ? void 0 : _b.cart, errors);
|
|
298
|
+
);
|
|
261
299
|
send(resultEvent);
|
|
262
300
|
},
|
|
263
301
|
...onCartActionEntry && {
|
|
@@ -284,22 +322,15 @@ function useCartAPIStateMachine({
|
|
|
284
322
|
return require$$0.useMemo(() => [state, send, service], [state, send, service]);
|
|
285
323
|
}
|
|
286
324
|
function cartFromGraphQL(cart) {
|
|
287
|
-
var _a;
|
|
288
325
|
return {
|
|
289
326
|
...cart,
|
|
290
327
|
lines: flattenConnection.flattenConnection(cart == null ? void 0 : cart.lines),
|
|
291
|
-
note:
|
|
328
|
+
note: cart.note ?? void 0
|
|
292
329
|
};
|
|
293
330
|
}
|
|
294
331
|
function eventFromFetchResult(cartActionEvent, cart, errors) {
|
|
295
332
|
if (errors) {
|
|
296
|
-
return {
|
|
297
|
-
type: "ERROR",
|
|
298
|
-
payload: {
|
|
299
|
-
errors,
|
|
300
|
-
cartActionEvent
|
|
301
|
-
}
|
|
302
|
-
};
|
|
333
|
+
return { type: "ERROR", payload: { errors, cartActionEvent } };
|
|
303
334
|
}
|
|
304
335
|
if (!cart) {
|
|
305
336
|
return {
|