@shopify/hydrogen-react 0.0.0-next-72f8a5c → 0.0.0-next-ea37299
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/dist/dev/CartProvider.js +35 -35
- package/dist/dev/CartProvider.js.map +1 -1
- package/dist/dev/{CartProvider.cjs → CartProvider.mjs} +36 -36
- package/dist/dev/{CartProvider.cjs.map → CartProvider.mjs.map} +1 -1
- package/dist/dev/ExternalVideo.js +5 -5
- package/dist/dev/ExternalVideo.js.map +1 -1
- package/dist/dev/{ExternalVideo.cjs → ExternalVideo.mjs} +6 -6
- package/dist/{prod/ExternalVideo.cjs.map → dev/ExternalVideo.mjs.map} +1 -1
- package/dist/dev/Image.js +12 -12
- package/dist/dev/Image.js.map +1 -1
- package/dist/dev/{Image.cjs → Image.mjs} +13 -13
- package/dist/dev/{Image.cjs.map → Image.mjs.map} +1 -1
- package/dist/dev/MediaFile.js +12 -12
- package/dist/dev/MediaFile.js.map +1 -1
- package/dist/dev/{MediaFile.cjs → MediaFile.mjs} +13 -13
- package/dist/dev/{MediaFile.cjs.map → MediaFile.mjs.map} +1 -1
- package/dist/dev/Metafield.js +32 -32
- package/dist/dev/Metafield.js.map +1 -1
- package/dist/dev/{Metafield.cjs → Metafield.mjs} +33 -33
- package/dist/dev/{Metafield.cjs.map → Metafield.mjs.map} +1 -1
- package/dist/dev/ModelViewer.js +11 -11
- package/dist/dev/ModelViewer.js.map +1 -1
- package/dist/dev/{ModelViewer.cjs → ModelViewer.mjs} +12 -12
- package/dist/dev/{ModelViewer.cjs.map → ModelViewer.mjs.map} +1 -1
- package/dist/dev/Money.js +8 -8
- package/dist/dev/Money.js.map +1 -1
- package/dist/{prod/Money.cjs → dev/Money.mjs} +9 -9
- package/dist/dev/{Money.cjs.map → Money.mjs.map} +1 -1
- package/dist/dev/ProductPrice.js +9 -9
- package/dist/dev/ProductPrice.js.map +1 -1
- package/dist/{prod/ProductPrice.cjs → dev/ProductPrice.mjs} +10 -10
- package/dist/dev/{ProductPrice.cjs.map → ProductPrice.mjs.map} +1 -1
- package/dist/dev/ProductProvider.js +25 -25
- package/dist/dev/ProductProvider.js.map +1 -1
- package/dist/{prod/ProductProvider.cjs → dev/ProductProvider.mjs} +26 -26
- package/dist/dev/{ProductProvider.cjs.map → ProductProvider.mjs.map} +1 -1
- package/dist/dev/ShopPayButton.js +13 -13
- package/dist/dev/ShopPayButton.js.map +1 -1
- package/dist/{prod/ShopPayButton.cjs → dev/ShopPayButton.mjs} +14 -14
- package/dist/{prod/ShopPayButton.cjs.map → dev/ShopPayButton.mjs.map} +1 -1
- package/dist/dev/ShopifyProvider.js +14 -14
- package/dist/dev/ShopifyProvider.js.map +1 -1
- package/dist/dev/ShopifyProvider.mjs +46 -0
- package/dist/dev/{ShopifyProvider.cjs.map → ShopifyProvider.mjs.map} +1 -1
- package/dist/dev/Video.js +9 -9
- package/dist/dev/Video.js.map +1 -1
- package/dist/dev/{Video.cjs → Video.mjs} +10 -10
- package/dist/dev/{Video.cjs.map → Video.mjs.map} +1 -1
- package/dist/dev/_virtual/index.js +5 -0
- package/dist/dev/_virtual/index.js.map +1 -0
- package/dist/dev/_virtual/index.mjs +5 -0
- package/dist/dev/_virtual/index.mjs.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.mjs +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.mjs.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.mjs +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.mjs.map +1 -0
- package/dist/dev/_virtual/with-selector.development.js +5 -0
- package/dist/dev/_virtual/with-selector.development.js.map +1 -0
- package/dist/dev/_virtual/with-selector.development.mjs +5 -0
- package/dist/dev/_virtual/with-selector.development.mjs.map +1 -0
- package/dist/dev/_virtual/with-selector.js +5 -0
- package/dist/dev/_virtual/with-selector.js.map +1 -0
- package/dist/dev/_virtual/with-selector.mjs +5 -0
- package/dist/dev/_virtual/with-selector.mjs.map +1 -0
- package/dist/dev/_virtual/with-selector.production.min.js +5 -0
- package/dist/dev/_virtual/with-selector.production.min.js.map +1 -0
- package/dist/dev/_virtual/with-selector.production.min.mjs +5 -0
- package/dist/dev/_virtual/with-selector.production.min.mjs.map +1 -0
- package/dist/dev/cart-constants.js +9 -9
- package/dist/dev/cart-constants.js.map +1 -1
- package/dist/dev/cart-constants.mjs +17 -0
- package/dist/dev/{cart-constants.cjs.map → cart-constants.mjs.map} +1 -1
- package/dist/dev/cart-hooks.js +15 -15
- package/dist/dev/cart-hooks.js.map +1 -1
- package/dist/dev/cart-hooks.mjs +48 -0
- package/dist/dev/{cart-hooks.cjs.map → cart-hooks.mjs.map} +1 -1
- package/dist/dev/cart-queries.js +11 -11
- package/dist/dev/cart-queries.js.map +1 -1
- package/dist/{prod/cart-queries.cjs → dev/cart-queries.mjs} +12 -12
- package/dist/dev/{cart-queries.cjs.map → cart-queries.mjs.map} +1 -1
- package/dist/dev/flatten-connection.js +3 -3
- package/dist/dev/flatten-connection.js.map +1 -1
- package/dist/dev/{flatten-connection.cjs → flatten-connection.mjs} +4 -4
- package/dist/dev/{flatten-connection.cjs.map → flatten-connection.mjs.map} +1 -1
- package/dist/dev/image-size.js +6 -6
- package/dist/dev/image-size.js.map +1 -1
- package/dist/dev/{image-size.cjs → image-size.mjs} +7 -7
- package/dist/dev/{image-size.cjs.map → image-size.mjs.map} +1 -1
- package/dist/dev/index.js +37 -37
- package/dist/dev/index.js.map +1 -1
- package/dist/dev/index.mjs +38 -0
- package/dist/dev/index.mjs.map +1 -0
- package/dist/dev/load-script.js +7 -7
- package/dist/dev/load-script.js.map +1 -1
- package/dist/{prod/load-script.cjs → dev/load-script.mjs} +8 -8
- package/dist/dev/{load-script.cjs.map → load-script.mjs.map} +1 -1
- package/dist/dev/node_modules/@xstate/fsm/es/index.js +158 -0
- package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +1 -0
- package/dist/dev/node_modules/@xstate/fsm/es/index.mjs +159 -0
- package/dist/dev/node_modules/@xstate/fsm/es/index.mjs.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.js +94 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.js.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.mjs +94 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.js +30 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.js.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.mjs +12 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +5 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs +6 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +107 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +105 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +74 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +72 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +138 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +136 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +60 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +58 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.js +21 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.mjs +21 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.mjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +12 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.mjs +11 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -0
- package/dist/dev/node_modules/worktop/cookie/index.js +27 -0
- package/dist/dev/node_modules/worktop/cookie/index.js.map +1 -0
- package/dist/dev/node_modules/worktop/cookie/index.mjs +27 -0
- package/dist/dev/node_modules/worktop/cookie/index.mjs.map +1 -0
- package/dist/dev/storefront-api-constants.js +3 -3
- package/dist/dev/storefront-api-constants.js.map +1 -1
- package/dist/dev/storefront-api-constants.mjs +5 -0
- package/dist/dev/storefront-api-constants.mjs.map +1 -0
- package/dist/dev/storefront-client.js +6 -6
- package/dist/dev/storefront-client.js.map +1 -1
- package/dist/dev/{storefront-client.cjs → storefront-client.mjs} +7 -7
- package/dist/dev/storefront-client.mjs.map +1 -0
- package/dist/dev/useCartAPIStateMachine.js +20 -20
- package/dist/dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/{prod/useCartAPIStateMachine.cjs → dev/useCartAPIStateMachine.mjs} +21 -21
- package/dist/{prod/useCartAPIStateMachine.cjs.map → dev/useCartAPIStateMachine.mjs.map} +1 -1
- package/dist/dev/useCartActions.js +26 -26
- package/dist/dev/useCartActions.js.map +1 -1
- package/dist/dev/{useCartActions.cjs → useCartActions.mjs} +27 -27
- package/dist/dev/{useCartActions.cjs.map → useCartActions.mjs.map} +1 -1
- package/dist/dev/useMoney.js +10 -10
- package/dist/dev/useMoney.js.map +1 -1
- package/dist/{prod/useMoney.cjs → dev/useMoney.mjs} +11 -11
- package/dist/{prod/useMoney.cjs.map → dev/useMoney.mjs.map} +1 -1
- package/dist/prod/CartProvider.js +35 -35
- package/dist/prod/CartProvider.js.map +1 -1
- package/dist/prod/{CartProvider.cjs → CartProvider.mjs} +36 -36
- package/dist/prod/{CartProvider.cjs.map → CartProvider.mjs.map} +1 -1
- package/dist/prod/ExternalVideo.js +5 -5
- package/dist/prod/ExternalVideo.js.map +1 -1
- package/dist/prod/{ExternalVideo.cjs → ExternalVideo.mjs} +6 -6
- package/dist/{dev/ExternalVideo.cjs.map → prod/ExternalVideo.mjs.map} +1 -1
- package/dist/prod/Image.js +12 -12
- package/dist/prod/Image.js.map +1 -1
- package/dist/prod/{Image.cjs → Image.mjs} +13 -13
- package/dist/prod/{Image.cjs.map → Image.mjs.map} +1 -1
- package/dist/prod/MediaFile.js +12 -12
- package/dist/prod/MediaFile.js.map +1 -1
- package/dist/prod/{MediaFile.cjs → MediaFile.mjs} +13 -13
- package/dist/prod/{MediaFile.cjs.map → MediaFile.mjs.map} +1 -1
- package/dist/prod/Metafield.js +32 -32
- package/dist/prod/Metafield.js.map +1 -1
- package/dist/prod/{Metafield.cjs → Metafield.mjs} +33 -33
- package/dist/prod/{Metafield.cjs.map → Metafield.mjs.map} +1 -1
- package/dist/prod/ModelViewer.js +11 -11
- package/dist/prod/ModelViewer.js.map +1 -1
- package/dist/prod/{ModelViewer.cjs → ModelViewer.mjs} +12 -12
- package/dist/prod/{ModelViewer.cjs.map → ModelViewer.mjs.map} +1 -1
- package/dist/prod/Money.js +8 -8
- package/dist/prod/Money.js.map +1 -1
- package/dist/{dev/Money.cjs → prod/Money.mjs} +9 -9
- package/dist/prod/{Money.cjs.map → Money.mjs.map} +1 -1
- package/dist/prod/ProductPrice.js +9 -9
- package/dist/prod/ProductPrice.js.map +1 -1
- package/dist/{dev/ProductPrice.cjs → prod/ProductPrice.mjs} +10 -10
- package/dist/prod/{ProductPrice.cjs.map → ProductPrice.mjs.map} +1 -1
- package/dist/prod/ProductProvider.js +25 -25
- package/dist/prod/ProductProvider.js.map +1 -1
- package/dist/{dev/ProductProvider.cjs → prod/ProductProvider.mjs} +26 -26
- package/dist/prod/{ProductProvider.cjs.map → ProductProvider.mjs.map} +1 -1
- package/dist/prod/ShopPayButton.js +13 -13
- package/dist/prod/ShopPayButton.js.map +1 -1
- package/dist/{dev/ShopPayButton.cjs → prod/ShopPayButton.mjs} +14 -14
- package/dist/{dev/ShopPayButton.cjs.map → prod/ShopPayButton.mjs.map} +1 -1
- package/dist/prod/ShopifyProvider.js +14 -14
- package/dist/prod/ShopifyProvider.js.map +1 -1
- package/dist/prod/ShopifyProvider.mjs +46 -0
- package/dist/prod/{ShopifyProvider.cjs.map → ShopifyProvider.mjs.map} +1 -1
- package/dist/prod/Video.js +9 -9
- package/dist/prod/Video.js.map +1 -1
- package/dist/prod/{Video.cjs → Video.mjs} +10 -10
- package/dist/prod/{Video.cjs.map → Video.mjs.map} +1 -1
- package/dist/prod/_virtual/index.js +5 -0
- package/dist/prod/_virtual/index.js.map +1 -0
- package/dist/prod/_virtual/index.mjs +5 -0
- package/dist/prod/_virtual/index.mjs.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.mjs +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.mjs.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.mjs +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.mjs.map +1 -0
- package/dist/prod/_virtual/with-selector.development.js +5 -0
- package/dist/prod/_virtual/with-selector.development.js.map +1 -0
- package/dist/prod/_virtual/with-selector.development.mjs +5 -0
- package/dist/prod/_virtual/with-selector.development.mjs.map +1 -0
- package/dist/prod/_virtual/with-selector.js +5 -0
- package/dist/prod/_virtual/with-selector.js.map +1 -0
- package/dist/prod/_virtual/with-selector.mjs +5 -0
- package/dist/prod/_virtual/with-selector.mjs.map +1 -0
- package/dist/prod/_virtual/with-selector.production.min.js +5 -0
- package/dist/prod/_virtual/with-selector.production.min.js.map +1 -0
- package/dist/prod/_virtual/with-selector.production.min.mjs +5 -0
- package/dist/prod/_virtual/with-selector.production.min.mjs.map +1 -0
- package/dist/prod/cart-constants.js +9 -9
- package/dist/prod/cart-constants.js.map +1 -1
- package/dist/prod/cart-constants.mjs +17 -0
- package/dist/prod/{cart-constants.cjs.map → cart-constants.mjs.map} +1 -1
- package/dist/prod/cart-hooks.js +15 -15
- package/dist/prod/cart-hooks.js.map +1 -1
- package/dist/prod/cart-hooks.mjs +48 -0
- package/dist/prod/{cart-hooks.cjs.map → cart-hooks.mjs.map} +1 -1
- package/dist/prod/cart-queries.js +11 -11
- package/dist/prod/cart-queries.js.map +1 -1
- package/dist/{dev/cart-queries.cjs → prod/cart-queries.mjs} +12 -12
- package/dist/prod/{cart-queries.cjs.map → cart-queries.mjs.map} +1 -1
- package/dist/prod/flatten-connection.js +3 -3
- package/dist/prod/flatten-connection.js.map +1 -1
- package/dist/prod/{flatten-connection.cjs → flatten-connection.mjs} +4 -4
- package/dist/prod/{flatten-connection.cjs.map → flatten-connection.mjs.map} +1 -1
- package/dist/prod/image-size.js +6 -6
- package/dist/prod/image-size.js.map +1 -1
- package/dist/prod/{image-size.cjs → image-size.mjs} +7 -7
- package/dist/prod/{image-size.cjs.map → image-size.mjs.map} +1 -1
- package/dist/prod/index.js +37 -37
- package/dist/prod/index.js.map +1 -1
- package/dist/prod/index.mjs +38 -0
- package/dist/prod/index.mjs.map +1 -0
- package/dist/prod/load-script.js +7 -7
- package/dist/prod/load-script.js.map +1 -1
- package/dist/{dev/load-script.cjs → prod/load-script.mjs} +8 -8
- package/dist/prod/{load-script.cjs.map → load-script.mjs.map} +1 -1
- package/dist/prod/node_modules/@xstate/fsm/es/index.js +158 -0
- package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +1 -0
- package/dist/prod/node_modules/@xstate/fsm/es/index.mjs +159 -0
- package/dist/prod/node_modules/@xstate/fsm/es/index.mjs.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.js +94 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.js.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.mjs +94 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.js +30 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.js.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.mjs +12 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +5 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs +6 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.mjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +107 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +105 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +74 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +72 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +138 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +136 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +60 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +58 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.js +21 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.mjs +21 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.mjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +12 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.mjs +11 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -0
- package/dist/prod/node_modules/worktop/cookie/index.js +27 -0
- package/dist/prod/node_modules/worktop/cookie/index.js.map +1 -0
- package/dist/prod/node_modules/worktop/cookie/index.mjs +27 -0
- package/dist/prod/node_modules/worktop/cookie/index.mjs.map +1 -0
- package/dist/prod/storefront-api-constants.js +3 -3
- package/dist/prod/storefront-api-constants.js.map +1 -1
- package/dist/prod/storefront-api-constants.mjs +5 -0
- package/dist/prod/storefront-api-constants.mjs.map +1 -0
- package/dist/prod/storefront-client.js +6 -6
- package/dist/prod/storefront-client.js.map +1 -1
- package/dist/prod/{storefront-client.cjs → storefront-client.mjs} +7 -7
- package/dist/prod/storefront-client.mjs.map +1 -0
- package/dist/prod/useCartAPIStateMachine.js +20 -20
- package/dist/prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/{dev/useCartAPIStateMachine.cjs → prod/useCartAPIStateMachine.mjs} +21 -21
- package/dist/{dev/useCartAPIStateMachine.cjs.map → prod/useCartAPIStateMachine.mjs.map} +1 -1
- package/dist/prod/useCartActions.js +26 -26
- package/dist/prod/useCartActions.js.map +1 -1
- package/dist/prod/{useCartActions.cjs → useCartActions.mjs} +27 -27
- package/dist/prod/{useCartActions.cjs.map → useCartActions.mjs.map} +1 -1
- package/dist/prod/useMoney.js +10 -10
- package/dist/prod/useMoney.js.map +1 -1
- package/dist/{dev/useMoney.cjs → prod/useMoney.mjs} +11 -11
- package/dist/{dev/useMoney.cjs.map → prod/useMoney.mjs.map} +1 -1
- package/dist/umd/hydrogen-react.dev.js +1 -1
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +1 -1
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +14 -14
- package/dist/dev/ShopifyProvider.cjs +0 -46
- package/dist/dev/cart-constants.cjs +0 -17
- package/dist/dev/cart-hooks.cjs +0 -48
- package/dist/dev/index.cjs +0 -38
- package/dist/dev/index.cjs.map +0 -1
- package/dist/dev/storefront-api-constants.cjs +0 -5
- package/dist/dev/storefront-api-constants.cjs.map +0 -1
- package/dist/dev/storefront-client.cjs.map +0 -1
- package/dist/prod/ShopifyProvider.cjs +0 -46
- package/dist/prod/cart-constants.cjs +0 -17
- package/dist/prod/cart-hooks.cjs +0 -48
- package/dist/prod/index.cjs +0 -38
- package/dist/prod/index.cjs.map +0 -1
- package/dist/prod/storefront-api-constants.cjs +0 -5
- package/dist/prod/storefront-api-constants.cjs.map +0 -1
- package/dist/prod/storefront-client.cjs.map +0 -1
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const cartQueries = require("./cart-queries.cjs");
|
|
5
|
-
const cartHooks = require("./cart-hooks.cjs");
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { CartQuery, CartCreate, CartLineAdd, CartLineUpdate, CartLineRemove, CartNoteUpdate, CartBuyerIdentityUpdate, CartAttributesUpdate, CartDiscountCodesUpdate } from "./cart-queries.mjs";
|
|
3
|
+
import { useCartFetch } from "./cart-hooks.mjs";
|
|
6
4
|
function useCartActions({
|
|
7
5
|
numCartLines,
|
|
8
6
|
cartFragment,
|
|
9
7
|
countryCode = "US"
|
|
10
8
|
}) {
|
|
11
|
-
const fetchCart =
|
|
12
|
-
const cartFetch =
|
|
9
|
+
const fetchCart = useCartFetch();
|
|
10
|
+
const cartFetch = useCallback((cartId) => {
|
|
13
11
|
return fetchCart({
|
|
14
|
-
query:
|
|
12
|
+
query: CartQuery(cartFragment),
|
|
15
13
|
variables: {
|
|
16
14
|
id: cartId,
|
|
17
15
|
numCartLines,
|
|
@@ -19,9 +17,9 @@ function useCartActions({
|
|
|
19
17
|
}
|
|
20
18
|
});
|
|
21
19
|
}, [fetchCart, cartFragment, numCartLines, countryCode]);
|
|
22
|
-
const cartCreate =
|
|
20
|
+
const cartCreate = useCallback((cart) => {
|
|
23
21
|
return fetchCart({
|
|
24
|
-
query:
|
|
22
|
+
query: CartCreate(cartFragment),
|
|
25
23
|
variables: {
|
|
26
24
|
input: cart,
|
|
27
25
|
numCartLines,
|
|
@@ -29,9 +27,9 @@ function useCartActions({
|
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
32
|
-
const cartLineAdd =
|
|
30
|
+
const cartLineAdd = useCallback((cartId, lines) => {
|
|
33
31
|
return fetchCart({
|
|
34
|
-
query:
|
|
32
|
+
query: CartLineAdd(cartFragment),
|
|
35
33
|
variables: {
|
|
36
34
|
cartId,
|
|
37
35
|
lines,
|
|
@@ -40,9 +38,9 @@ function useCartActions({
|
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
40
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
43
|
-
const cartLineUpdate =
|
|
41
|
+
const cartLineUpdate = useCallback((cartId, lines) => {
|
|
44
42
|
return fetchCart({
|
|
45
|
-
query:
|
|
43
|
+
query: CartLineUpdate(cartFragment),
|
|
46
44
|
variables: {
|
|
47
45
|
cartId,
|
|
48
46
|
lines,
|
|
@@ -51,9 +49,9 @@ function useCartActions({
|
|
|
51
49
|
}
|
|
52
50
|
});
|
|
53
51
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
54
|
-
const cartLineRemove =
|
|
52
|
+
const cartLineRemove = useCallback((cartId, lines) => {
|
|
55
53
|
return fetchCart({
|
|
56
|
-
query:
|
|
54
|
+
query: CartLineRemove(cartFragment),
|
|
57
55
|
variables: {
|
|
58
56
|
cartId,
|
|
59
57
|
lines,
|
|
@@ -62,9 +60,9 @@ function useCartActions({
|
|
|
62
60
|
}
|
|
63
61
|
});
|
|
64
62
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
65
|
-
const noteUpdate =
|
|
63
|
+
const noteUpdate = useCallback((cartId, note) => {
|
|
66
64
|
return fetchCart({
|
|
67
|
-
query:
|
|
65
|
+
query: CartNoteUpdate(cartFragment),
|
|
68
66
|
variables: {
|
|
69
67
|
cartId,
|
|
70
68
|
note,
|
|
@@ -73,9 +71,9 @@ function useCartActions({
|
|
|
73
71
|
}
|
|
74
72
|
});
|
|
75
73
|
}, [fetchCart, cartFragment, numCartLines, countryCode]);
|
|
76
|
-
const buyerIdentityUpdate =
|
|
74
|
+
const buyerIdentityUpdate = useCallback((cartId, buyerIdentity) => {
|
|
77
75
|
return fetchCart({
|
|
78
|
-
query:
|
|
76
|
+
query: CartBuyerIdentityUpdate(cartFragment),
|
|
79
77
|
variables: {
|
|
80
78
|
cartId,
|
|
81
79
|
buyerIdentity,
|
|
@@ -84,9 +82,9 @@ function useCartActions({
|
|
|
84
82
|
}
|
|
85
83
|
});
|
|
86
84
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
87
|
-
const cartAttributesUpdate =
|
|
85
|
+
const cartAttributesUpdate = useCallback((cartId, attributes) => {
|
|
88
86
|
return fetchCart({
|
|
89
|
-
query:
|
|
87
|
+
query: CartAttributesUpdate(cartFragment),
|
|
90
88
|
variables: {
|
|
91
89
|
cartId,
|
|
92
90
|
attributes,
|
|
@@ -95,9 +93,9 @@ function useCartActions({
|
|
|
95
93
|
}
|
|
96
94
|
});
|
|
97
95
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
98
|
-
const discountCodesUpdate =
|
|
96
|
+
const discountCodesUpdate = useCallback((cartId, discountCodes) => {
|
|
99
97
|
return fetchCart({
|
|
100
|
-
query:
|
|
98
|
+
query: CartDiscountCodesUpdate(cartFragment),
|
|
101
99
|
variables: {
|
|
102
100
|
cartId,
|
|
103
101
|
discountCodes,
|
|
@@ -106,7 +104,7 @@ function useCartActions({
|
|
|
106
104
|
}
|
|
107
105
|
});
|
|
108
106
|
}, [cartFragment, countryCode, fetchCart, numCartLines]);
|
|
109
|
-
return
|
|
107
|
+
return useMemo(() => ({
|
|
110
108
|
cartFetch,
|
|
111
109
|
cartCreate,
|
|
112
110
|
cartLineAdd,
|
|
@@ -119,5 +117,7 @@ function useCartActions({
|
|
|
119
117
|
cartFragment
|
|
120
118
|
}), [cartFetch, cartCreate, cartLineAdd, cartLineUpdate, cartLineRemove, noteUpdate, buyerIdentityUpdate, cartAttributesUpdate, discountCodesUpdate, cartFragment]);
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
export {
|
|
121
|
+
useCartActions
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=useCartActions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCartActions.
|
|
1
|
+
{"version":3,"file":"useCartActions.mjs","sources":["../../src/useCartActions.tsx"],"sourcesContent":["import {useCallback, useMemo} from 'react';\nimport {\n AttributeInput,\n CartBuyerIdentityInput,\n CartInput,\n CartLineInput,\n CartLineUpdateInput,\n CountryCode,\n Cart as CartType,\n MutationCartDiscountCodesUpdateArgs,\n MutationCartNoteUpdateArgs,\n} from './storefront-api-types.js';\nimport {\n CartAttributesUpdate,\n CartBuyerIdentityUpdate,\n CartCreate,\n CartDiscountCodesUpdate,\n CartLineAdd,\n CartLineRemove,\n CartLineUpdate,\n CartNoteUpdate,\n CartQuery,\n} from './cart-queries.js';\nimport {useCartFetch} from './cart-hooks.js';\nimport {PartialDeep} from 'type-fest';\n\ntype CartResponse = PartialDeep<CartType, {recurseIntoArrays: true}>;\n\n/**\n * The `useCartActions` hook returns helper graphql functions for Storefront Cart API\n *\n * See [cart API graphql mutations](https://shopify.dev/api/storefront/2022-10/objects/Cart)\n */\nexport function useCartActions({\n numCartLines,\n cartFragment,\n countryCode = 'US',\n}: {\n /** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */\n numCartLines?: number;\n /** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */\n cartFragment: string;\n /** The ISO country code for i18n. */\n countryCode?: CountryCode;\n}) {\n const fetchCart = useCartFetch();\n\n const cartFetch = useCallback(\n (cartId: string) => {\n return fetchCart<{cart: CartResponse}>({\n query: CartQuery(cartFragment),\n variables: {\n id: cartId,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [fetchCart, cartFragment, numCartLines, countryCode]\n );\n\n const cartCreate = useCallback(\n (cart: CartInput) => {\n return fetchCart<{cartCreate: {cart: CartResponse}}>({\n query: CartCreate(cartFragment),\n variables: {\n input: cart,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n const cartLineAdd = useCallback(\n (cartId: string, lines: CartLineInput[]) => {\n return fetchCart<{cartLinesAdd: {cart: CartResponse}}>({\n query: CartLineAdd(cartFragment),\n variables: {\n cartId,\n lines,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n const cartLineUpdate = useCallback(\n (cartId: string, lines: CartLineUpdateInput[]) => {\n return fetchCart<{cartLinesUpdate: {cart: CartResponse}}>({\n query: CartLineUpdate(cartFragment),\n variables: {\n cartId,\n lines,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n const cartLineRemove = useCallback(\n (cartId: string, lines: string[]) => {\n return fetchCart<{cartLinesRemove: {cart: CartResponse}}>({\n query: CartLineRemove(cartFragment),\n variables: {\n cartId,\n lines,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n const noteUpdate = useCallback(\n (cartId: string, note: MutationCartNoteUpdateArgs['note']) => {\n return fetchCart<{cartNoteUpdate: {cart: CartResponse}}>({\n query: CartNoteUpdate(cartFragment),\n variables: {\n cartId,\n note,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [fetchCart, cartFragment, numCartLines, countryCode]\n );\n\n const buyerIdentityUpdate = useCallback(\n (cartId: string, buyerIdentity: CartBuyerIdentityInput) => {\n return fetchCart<{cartBuyerIdentityUpdate: {cart: CartResponse}}>({\n query: CartBuyerIdentityUpdate(cartFragment),\n variables: {\n cartId,\n buyerIdentity,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n const cartAttributesUpdate = useCallback(\n (cartId: string, attributes: AttributeInput[]) => {\n return fetchCart<{cartAttributesUpdate: {cart: CartResponse}}>({\n query: CartAttributesUpdate(cartFragment),\n variables: {\n cartId,\n attributes,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n const discountCodesUpdate = useCallback(\n (\n cartId: string,\n discountCodes: MutationCartDiscountCodesUpdateArgs['discountCodes']\n ) => {\n return fetchCart<{cartDiscountCodesUpdate: {cart: CartResponse}}>({\n query: CartDiscountCodesUpdate(cartFragment),\n variables: {\n cartId,\n discountCodes,\n numCartLines,\n country: countryCode,\n },\n });\n },\n [cartFragment, countryCode, fetchCart, numCartLines]\n );\n\n return useMemo(\n () => ({\n cartFetch,\n cartCreate,\n cartLineAdd,\n cartLineUpdate,\n cartLineRemove,\n noteUpdate,\n buyerIdentityUpdate,\n cartAttributesUpdate,\n discountCodesUpdate,\n cartFragment,\n }),\n [\n cartFetch,\n cartCreate,\n cartLineAdd,\n cartLineUpdate,\n cartLineRemove,\n noteUpdate,\n buyerIdentityUpdate,\n cartAttributesUpdate,\n discountCodesUpdate,\n cartFragment,\n ]\n );\n}\n"],"names":["useCartActions","numCartLines","cartFragment","countryCode","fetchCart","useCartFetch","cartFetch","useCallback","cartId","query","CartQuery","variables","id","country","cartCreate","cart","CartCreate","input","cartLineAdd","lines","CartLineAdd","cartLineUpdate","CartLineUpdate","cartLineRemove","CartLineRemove","noteUpdate","note","CartNoteUpdate","buyerIdentityUpdate","buyerIdentity","CartBuyerIdentityUpdate","cartAttributesUpdate","attributes","CartAttributesUpdate","discountCodesUpdate","discountCodes","CartDiscountCodesUpdate","useMemo"],"mappings":"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"}
|
package/dist/dev/useMoney.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const ShopifyProvider = require("./ShopifyProvider.js");
|
|
3
5
|
function useMoney(money) {
|
|
4
6
|
const {
|
|
5
7
|
locale
|
|
6
|
-
} = useShop();
|
|
8
|
+
} = ShopifyProvider.useShop();
|
|
7
9
|
if (!locale) {
|
|
8
10
|
throw new Error(`useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`);
|
|
9
11
|
}
|
|
10
12
|
const amount = parseFloat(money.amount);
|
|
11
|
-
const options = useMemo(() => ({
|
|
13
|
+
const options = require$$0.useMemo(() => ({
|
|
12
14
|
style: "currency",
|
|
13
15
|
currency: money.currencyCode
|
|
14
16
|
}), [money.currencyCode]);
|
|
@@ -32,7 +34,7 @@ function useMoney(money) {
|
|
|
32
34
|
maximumFractionDigits: 0
|
|
33
35
|
});
|
|
34
36
|
const isPartCurrency = (part) => part.type === "currency";
|
|
35
|
-
const lazyFormatters = useMemo(() => ({
|
|
37
|
+
const lazyFormatters = require$$0.useMemo(() => ({
|
|
36
38
|
original: () => money,
|
|
37
39
|
currencyCode: () => money.currencyCode,
|
|
38
40
|
localizedString: () => defaultFormatter().format(amount),
|
|
@@ -53,7 +55,7 @@ function useMoney(money) {
|
|
|
53
55
|
},
|
|
54
56
|
amount: () => defaultFormatter().formatToParts(amount).filter((part) => ["decimal", "fraction", "group", "integer", "literal"].includes(part.type)).map((part) => part.value).join("")
|
|
55
57
|
}), [money, amount, nameFormatter, defaultFormatter, narrowSymbolFormatter, withoutCurrencyFormatter, withoutTrailingZerosFormatter, withoutTrailingZerosOrCurrencyFormatter]);
|
|
56
|
-
return useMemo(() => new Proxy(lazyFormatters, {
|
|
58
|
+
return require$$0.useMemo(() => new Proxy(lazyFormatters, {
|
|
57
59
|
get: (target, key) => {
|
|
58
60
|
var _a;
|
|
59
61
|
return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
|
|
@@ -61,12 +63,10 @@ function useMoney(money) {
|
|
|
61
63
|
}), [lazyFormatters]);
|
|
62
64
|
}
|
|
63
65
|
function useLazyFormatter(locale, options) {
|
|
64
|
-
return useMemo(() => {
|
|
66
|
+
return require$$0.useMemo(() => {
|
|
65
67
|
let memoized;
|
|
66
68
|
return () => memoized != null ? memoized : memoized = new Intl.NumberFormat(locale, options);
|
|
67
69
|
}, [locale, options]);
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
useMoney
|
|
71
|
-
};
|
|
71
|
+
exports.useMoney = useMoney;
|
|
72
72
|
//# sourceMappingURL=useMoney.js.map
|
package/dist/dev/useMoney.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoney.js","sources":["../../src/useMoney.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {CurrencyCode, MoneyV2} from './storefront-api-types.js';\n\nexport type UseMoneyValue = {\n /**\n * The currency code from the `MoneyV2` object.\n */\n currencyCode: CurrencyCode;\n /**\n * The name for the currency code, returned by `Intl.NumberFormat`.\n */\n currencyName?: string;\n /**\n * The currency symbol returned by `Intl.NumberFormat`.\n */\n currencySymbol?: string;\n /**\n * The currency narrow symbol returned by `Intl.NumberFormat`.\n */\n currencyNarrowSymbol?: string;\n /**\n * The localized amount, without any currency symbols or non-number types from the `Intl.NumberFormat.formatToParts` parts.\n */\n amount: string;\n /**\n * All parts returned by `Intl.NumberFormat.formatToParts`.\n */\n parts: Intl.NumberFormatPart[];\n /**\n * A string returned by `new Intl.NumberFormat` for the amount and currency code,\n * using the `locale` value in the [`LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).\n */\n localizedString: string;\n /**\n * The `MoneyV2` object provided as an argument to the hook.\n */\n original: MoneyV2;\n /**\n * A string with trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `$640`.\n * `$640.42` remains `$640.42`.\n */\n withoutTrailingZeros: string;\n /**\n * A string without currency and without trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `640`.\n * `$640.42` turns into `640.42`.\n */\n withoutTrailingZerosAndCurrency: string;\n};\n\n/**\n * The `useMoney` hook takes a [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) and returns a\n * default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by\n * [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\n * Uses `locale` from `ShopifyProvider`\n */\nexport function useMoney(money: MoneyV2): UseMoneyValue {\n const {locale} = useShop();\n\n if (!locale) {\n throw new Error(\n `useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`\n );\n }\n\n const amount = parseFloat(money.amount);\n\n const options = useMemo(\n () => ({\n style: 'currency',\n currency: money.currencyCode,\n }),\n [money.currencyCode]\n );\n\n const defaultFormatter = useLazyFormatter(locale, options);\n\n const nameFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'name',\n });\n\n const narrowSymbolFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'narrowSymbol',\n });\n\n const withoutTrailingZerosFormatter = useLazyFormatter(locale, {\n ...options,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const withoutCurrencyFormatter = useLazyFormatter(locale);\n\n const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const isPartCurrency = (part: Intl.NumberFormatPart) =>\n part.type === 'currency';\n\n // By wrapping these properties in functions, we only\n // create formatters if they are going to be used.\n const lazyFormatters = useMemo(\n () => ({\n original: () => money,\n currencyCode: () => money.currencyCode,\n\n localizedString: () => defaultFormatter().format(amount),\n\n parts: () => defaultFormatter().formatToParts(amount),\n\n withoutTrailingZeros: () =>\n amount % 1 === 0\n ? withoutTrailingZerosFormatter().format(amount)\n : defaultFormatter().format(amount),\n\n withoutTrailingZerosAndCurrency: () =>\n amount % 1 === 0\n ? withoutTrailingZerosOrCurrencyFormatter().format(amount)\n : withoutCurrencyFormatter().format(amount),\n\n currencyName: () =>\n nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"US dollars\"\n\n currencySymbol: () =>\n defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"USD\"\n\n currencyNarrowSymbol: () =>\n narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)\n ?.value ?? '', // e.g. \"$\"\n\n amount: () =>\n defaultFormatter()\n .formatToParts(amount)\n .filter((part) =>\n ['decimal', 'fraction', 'group', 'integer', 'literal'].includes(\n part.type\n )\n )\n .map((part) => part.value)\n .join(''),\n }),\n [\n money,\n amount,\n nameFormatter,\n defaultFormatter,\n narrowSymbolFormatter,\n withoutCurrencyFormatter,\n withoutTrailingZerosFormatter,\n withoutTrailingZerosOrCurrencyFormatter,\n ]\n );\n\n // Call functions automatically when the properties are accessed\n // to keep these functions as an implementation detail.\n return useMemo(\n () =>\n new Proxy(lazyFormatters as unknown as UseMoneyValue, {\n get: (target, key) => Reflect.get(target, key)?.call(null),\n }),\n [lazyFormatters]\n );\n}\n\nfunction useLazyFormatter(locale: string, options?: Intl.NumberFormatOptions) {\n return useMemo(() => {\n let memoized: Intl.NumberFormat;\n return () => (memoized ??= new Intl.NumberFormat(locale, options));\n }, [locale, options]);\n}\n"],"names":["useMoney","money","locale","useShop","Error","amount","parseFloat","options","useMemo","style","currency","currencyCode","defaultFormatter","useLazyFormatter","nameFormatter","currencyDisplay","narrowSymbolFormatter","withoutTrailingZerosFormatter","minimumFractionDigits","maximumFractionDigits","withoutCurrencyFormatter","withoutTrailingZerosOrCurrencyFormatter","isPartCurrency","part","type","lazyFormatters","original","localizedString","format","parts","formatToParts","withoutTrailingZeros","withoutTrailingZerosAndCurrency","currencyName","find","value","currencySymbol","currencyNarrowSymbol","filter","includes","map","join","Proxy","get","target","key","Reflect","call","memoized","Intl","NumberFormat"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMoney.js","sources":["../../src/useMoney.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {CurrencyCode, MoneyV2} from './storefront-api-types.js';\n\nexport type UseMoneyValue = {\n /**\n * The currency code from the `MoneyV2` object.\n */\n currencyCode: CurrencyCode;\n /**\n * The name for the currency code, returned by `Intl.NumberFormat`.\n */\n currencyName?: string;\n /**\n * The currency symbol returned by `Intl.NumberFormat`.\n */\n currencySymbol?: string;\n /**\n * The currency narrow symbol returned by `Intl.NumberFormat`.\n */\n currencyNarrowSymbol?: string;\n /**\n * The localized amount, without any currency symbols or non-number types from the `Intl.NumberFormat.formatToParts` parts.\n */\n amount: string;\n /**\n * All parts returned by `Intl.NumberFormat.formatToParts`.\n */\n parts: Intl.NumberFormatPart[];\n /**\n * A string returned by `new Intl.NumberFormat` for the amount and currency code,\n * using the `locale` value in the [`LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).\n */\n localizedString: string;\n /**\n * The `MoneyV2` object provided as an argument to the hook.\n */\n original: MoneyV2;\n /**\n * A string with trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `$640`.\n * `$640.42` remains `$640.42`.\n */\n withoutTrailingZeros: string;\n /**\n * A string without currency and without trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `640`.\n * `$640.42` turns into `640.42`.\n */\n withoutTrailingZerosAndCurrency: string;\n};\n\n/**\n * The `useMoney` hook takes a [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) and returns a\n * default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by\n * [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\n * Uses `locale` from `ShopifyProvider`\n */\nexport function useMoney(money: MoneyV2): UseMoneyValue {\n const {locale} = useShop();\n\n if (!locale) {\n throw new Error(\n `useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`\n );\n }\n\n const amount = parseFloat(money.amount);\n\n const options = useMemo(\n () => ({\n style: 'currency',\n currency: money.currencyCode,\n }),\n [money.currencyCode]\n );\n\n const defaultFormatter = useLazyFormatter(locale, options);\n\n const nameFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'name',\n });\n\n const narrowSymbolFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'narrowSymbol',\n });\n\n const withoutTrailingZerosFormatter = useLazyFormatter(locale, {\n ...options,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const withoutCurrencyFormatter = useLazyFormatter(locale);\n\n const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const isPartCurrency = (part: Intl.NumberFormatPart) =>\n part.type === 'currency';\n\n // By wrapping these properties in functions, we only\n // create formatters if they are going to be used.\n const lazyFormatters = useMemo(\n () => ({\n original: () => money,\n currencyCode: () => money.currencyCode,\n\n localizedString: () => defaultFormatter().format(amount),\n\n parts: () => defaultFormatter().formatToParts(amount),\n\n withoutTrailingZeros: () =>\n amount % 1 === 0\n ? withoutTrailingZerosFormatter().format(amount)\n : defaultFormatter().format(amount),\n\n withoutTrailingZerosAndCurrency: () =>\n amount % 1 === 0\n ? withoutTrailingZerosOrCurrencyFormatter().format(amount)\n : withoutCurrencyFormatter().format(amount),\n\n currencyName: () =>\n nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"US dollars\"\n\n currencySymbol: () =>\n defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"USD\"\n\n currencyNarrowSymbol: () =>\n narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)\n ?.value ?? '', // e.g. \"$\"\n\n amount: () =>\n defaultFormatter()\n .formatToParts(amount)\n .filter((part) =>\n ['decimal', 'fraction', 'group', 'integer', 'literal'].includes(\n part.type\n )\n )\n .map((part) => part.value)\n .join(''),\n }),\n [\n money,\n amount,\n nameFormatter,\n defaultFormatter,\n narrowSymbolFormatter,\n withoutCurrencyFormatter,\n withoutTrailingZerosFormatter,\n withoutTrailingZerosOrCurrencyFormatter,\n ]\n );\n\n // Call functions automatically when the properties are accessed\n // to keep these functions as an implementation detail.\n return useMemo(\n () =>\n new Proxy(lazyFormatters as unknown as UseMoneyValue, {\n get: (target, key) => Reflect.get(target, key)?.call(null),\n }),\n [lazyFormatters]\n );\n}\n\nfunction useLazyFormatter(locale: string, options?: Intl.NumberFormatOptions) {\n return useMemo(() => {\n let memoized: Intl.NumberFormat;\n return () => (memoized ??= new Intl.NumberFormat(locale, options));\n }, [locale, options]);\n}\n"],"names":["useMoney","money","locale","useShop","Error","amount","parseFloat","options","useMemo","style","currency","currencyCode","defaultFormatter","useLazyFormatter","nameFormatter","currencyDisplay","narrowSymbolFormatter","withoutTrailingZerosFormatter","minimumFractionDigits","maximumFractionDigits","withoutCurrencyFormatter","withoutTrailingZerosOrCurrencyFormatter","isPartCurrency","part","type","lazyFormatters","original","localizedString","format","parts","formatToParts","withoutTrailingZeros","withoutTrailingZerosAndCurrency","currencyName","find","value","currencySymbol","currencyNarrowSymbol","filter","includes","map","join","Proxy","get","target","key","Reflect","call","memoized","Intl","NumberFormat"],"mappings":"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"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const ShopifyProvider = require("./ShopifyProvider.cjs");
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useShop } from "./ShopifyProvider.mjs";
|
|
5
3
|
function useMoney(money) {
|
|
6
4
|
const {
|
|
7
5
|
locale
|
|
8
|
-
} =
|
|
6
|
+
} = useShop();
|
|
9
7
|
if (!locale) {
|
|
10
8
|
throw new Error(`useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`);
|
|
11
9
|
}
|
|
12
10
|
const amount = parseFloat(money.amount);
|
|
13
|
-
const options =
|
|
11
|
+
const options = useMemo(() => ({
|
|
14
12
|
style: "currency",
|
|
15
13
|
currency: money.currencyCode
|
|
16
14
|
}), [money.currencyCode]);
|
|
@@ -34,7 +32,7 @@ function useMoney(money) {
|
|
|
34
32
|
maximumFractionDigits: 0
|
|
35
33
|
});
|
|
36
34
|
const isPartCurrency = (part) => part.type === "currency";
|
|
37
|
-
const lazyFormatters =
|
|
35
|
+
const lazyFormatters = useMemo(() => ({
|
|
38
36
|
original: () => money,
|
|
39
37
|
currencyCode: () => money.currencyCode,
|
|
40
38
|
localizedString: () => defaultFormatter().format(amount),
|
|
@@ -55,7 +53,7 @@ function useMoney(money) {
|
|
|
55
53
|
},
|
|
56
54
|
amount: () => defaultFormatter().formatToParts(amount).filter((part) => ["decimal", "fraction", "group", "integer", "literal"].includes(part.type)).map((part) => part.value).join("")
|
|
57
55
|
}), [money, amount, nameFormatter, defaultFormatter, narrowSymbolFormatter, withoutCurrencyFormatter, withoutTrailingZerosFormatter, withoutTrailingZerosOrCurrencyFormatter]);
|
|
58
|
-
return
|
|
56
|
+
return useMemo(() => new Proxy(lazyFormatters, {
|
|
59
57
|
get: (target, key) => {
|
|
60
58
|
var _a;
|
|
61
59
|
return (_a = Reflect.get(target, key)) == null ? void 0 : _a.call(null);
|
|
@@ -63,10 +61,12 @@ function useMoney(money) {
|
|
|
63
61
|
}), [lazyFormatters]);
|
|
64
62
|
}
|
|
65
63
|
function useLazyFormatter(locale, options) {
|
|
66
|
-
return
|
|
64
|
+
return useMemo(() => {
|
|
67
65
|
let memoized;
|
|
68
66
|
return () => memoized != null ? memoized : memoized = new Intl.NumberFormat(locale, options);
|
|
69
67
|
}, [locale, options]);
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
export {
|
|
70
|
+
useMoney
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=useMoney.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoney.
|
|
1
|
+
{"version":3,"file":"useMoney.mjs","sources":["../../src/useMoney.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {CurrencyCode, MoneyV2} from './storefront-api-types.js';\n\nexport type UseMoneyValue = {\n /**\n * The currency code from the `MoneyV2` object.\n */\n currencyCode: CurrencyCode;\n /**\n * The name for the currency code, returned by `Intl.NumberFormat`.\n */\n currencyName?: string;\n /**\n * The currency symbol returned by `Intl.NumberFormat`.\n */\n currencySymbol?: string;\n /**\n * The currency narrow symbol returned by `Intl.NumberFormat`.\n */\n currencyNarrowSymbol?: string;\n /**\n * The localized amount, without any currency symbols or non-number types from the `Intl.NumberFormat.formatToParts` parts.\n */\n amount: string;\n /**\n * All parts returned by `Intl.NumberFormat.formatToParts`.\n */\n parts: Intl.NumberFormatPart[];\n /**\n * A string returned by `new Intl.NumberFormat` for the amount and currency code,\n * using the `locale` value in the [`LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).\n */\n localizedString: string;\n /**\n * The `MoneyV2` object provided as an argument to the hook.\n */\n original: MoneyV2;\n /**\n * A string with trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `$640`.\n * `$640.42` remains `$640.42`.\n */\n withoutTrailingZeros: string;\n /**\n * A string without currency and without trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `640`.\n * `$640.42` turns into `640.42`.\n */\n withoutTrailingZerosAndCurrency: string;\n};\n\n/**\n * The `useMoney` hook takes a [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) and returns a\n * default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by\n * [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\n * Uses `locale` from `ShopifyProvider`\n */\nexport function useMoney(money: MoneyV2): UseMoneyValue {\n const {locale} = useShop();\n\n if (!locale) {\n throw new Error(\n `useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`\n );\n }\n\n const amount = parseFloat(money.amount);\n\n const options = useMemo(\n () => ({\n style: 'currency',\n currency: money.currencyCode,\n }),\n [money.currencyCode]\n );\n\n const defaultFormatter = useLazyFormatter(locale, options);\n\n const nameFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'name',\n });\n\n const narrowSymbolFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'narrowSymbol',\n });\n\n const withoutTrailingZerosFormatter = useLazyFormatter(locale, {\n ...options,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const withoutCurrencyFormatter = useLazyFormatter(locale);\n\n const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const isPartCurrency = (part: Intl.NumberFormatPart) =>\n part.type === 'currency';\n\n // By wrapping these properties in functions, we only\n // create formatters if they are going to be used.\n const lazyFormatters = useMemo(\n () => ({\n original: () => money,\n currencyCode: () => money.currencyCode,\n\n localizedString: () => defaultFormatter().format(amount),\n\n parts: () => defaultFormatter().formatToParts(amount),\n\n withoutTrailingZeros: () =>\n amount % 1 === 0\n ? withoutTrailingZerosFormatter().format(amount)\n : defaultFormatter().format(amount),\n\n withoutTrailingZerosAndCurrency: () =>\n amount % 1 === 0\n ? withoutTrailingZerosOrCurrencyFormatter().format(amount)\n : withoutCurrencyFormatter().format(amount),\n\n currencyName: () =>\n nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"US dollars\"\n\n currencySymbol: () =>\n defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"USD\"\n\n currencyNarrowSymbol: () =>\n narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)\n ?.value ?? '', // e.g. \"$\"\n\n amount: () =>\n defaultFormatter()\n .formatToParts(amount)\n .filter((part) =>\n ['decimal', 'fraction', 'group', 'integer', 'literal'].includes(\n part.type\n )\n )\n .map((part) => part.value)\n .join(''),\n }),\n [\n money,\n amount,\n nameFormatter,\n defaultFormatter,\n narrowSymbolFormatter,\n withoutCurrencyFormatter,\n withoutTrailingZerosFormatter,\n withoutTrailingZerosOrCurrencyFormatter,\n ]\n );\n\n // Call functions automatically when the properties are accessed\n // to keep these functions as an implementation detail.\n return useMemo(\n () =>\n new Proxy(lazyFormatters as unknown as UseMoneyValue, {\n get: (target, key) => Reflect.get(target, key)?.call(null),\n }),\n [lazyFormatters]\n );\n}\n\nfunction useLazyFormatter(locale: string, options?: Intl.NumberFormatOptions) {\n return useMemo(() => {\n let memoized: Intl.NumberFormat;\n return () => (memoized ??= new Intl.NumberFormat(locale, options));\n }, [locale, options]);\n}\n"],"names":["useMoney","money","locale","useShop","Error","amount","parseFloat","options","useMemo","style","currency","currencyCode","defaultFormatter","useLazyFormatter","nameFormatter","currencyDisplay","narrowSymbolFormatter","withoutTrailingZerosFormatter","minimumFractionDigits","maximumFractionDigits","withoutCurrencyFormatter","withoutTrailingZerosOrCurrencyFormatter","isPartCurrency","part","type","lazyFormatters","original","localizedString","format","parts","formatToParts","withoutTrailingZeros","withoutTrailingZerosAndCurrency","currencyName","find","value","currencySymbol","currencyNarrowSymbol","filter","includes","map","join","Proxy","get","target","key","Reflect","call","memoized","Intl","NumberFormat"],"mappings":"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"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const useCartAPIStateMachine = require("./useCartAPIStateMachine.js");
|
|
5
|
+
const cartConstants = require("./cart-constants.js");
|
|
6
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
const CartContext = require$$0.createContext(null);
|
|
6
8
|
function useCart() {
|
|
7
|
-
const context = useContext(CartContext);
|
|
9
|
+
const context = require$$0.useContext(CartContext);
|
|
8
10
|
if (!context) {
|
|
9
11
|
throw new Error("Expected a Cart Context, but no Cart Context was found");
|
|
10
12
|
}
|
|
@@ -37,15 +39,15 @@ function CartProvider({
|
|
|
37
39
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
38
40
|
if (countryCode)
|
|
39
41
|
countryCode = countryCode.toUpperCase();
|
|
40
|
-
const [prevCountryCode, setPrevCountryCode] = useState(countryCode);
|
|
41
|
-
const [prevCustomerAccessToken, setPrevCustomerAccessToken] = useState(customerAccessToken);
|
|
42
|
-
const customerOverridesCountryCode = useRef(false);
|
|
42
|
+
const [prevCountryCode, setPrevCountryCode] = require$$0.useState(countryCode);
|
|
43
|
+
const [prevCustomerAccessToken, setPrevCustomerAccessToken] = require$$0.useState(customerAccessToken);
|
|
44
|
+
const customerOverridesCountryCode = require$$0.useRef(false);
|
|
43
45
|
if (prevCountryCode !== countryCode || prevCustomerAccessToken !== customerAccessToken) {
|
|
44
46
|
setPrevCountryCode(countryCode);
|
|
45
47
|
setPrevCustomerAccessToken(customerAccessToken);
|
|
46
48
|
customerOverridesCountryCode.current = false;
|
|
47
49
|
}
|
|
48
|
-
const [cartState, cartSend] = useCartAPIStateMachine({
|
|
50
|
+
const [cartState, cartSend] = useCartAPIStateMachine.useCartAPIStateMachine({
|
|
49
51
|
numCartLines,
|
|
50
52
|
data: cart,
|
|
51
53
|
cartFragment,
|
|
@@ -149,16 +151,16 @@ function CartProvider({
|
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
});
|
|
152
|
-
const cartReady = useRef(false);
|
|
154
|
+
const cartReady = require$$0.useRef(false);
|
|
153
155
|
const cartCompleted = cartState.matches("cartCompleted");
|
|
154
156
|
const countryChanged = (cartState.value === "idle" || cartState.value === "error" || cartState.value === "cartCompleted") && countryCode !== ((_c = (_b = (_a = cartState == null ? void 0 : cartState.context) == null ? void 0 : _a.cart) == null ? void 0 : _b.buyerIdentity) == null ? void 0 : _c.countryCode) && !cartState.context.errors;
|
|
155
|
-
const fetchingFromStorage = useRef(false);
|
|
156
|
-
useEffect(() => {
|
|
157
|
+
const fetchingFromStorage = require$$0.useRef(false);
|
|
158
|
+
require$$0.useEffect(() => {
|
|
157
159
|
if (!cartReady.current && !fetchingFromStorage.current) {
|
|
158
160
|
if (!cart && storageAvailable("localStorage")) {
|
|
159
161
|
fetchingFromStorage.current = true;
|
|
160
162
|
try {
|
|
161
|
-
const cartId = window.localStorage.getItem(CART_ID_STORAGE_KEY);
|
|
163
|
+
const cartId = window.localStorage.getItem(cartConstants.CART_ID_STORAGE_KEY);
|
|
162
164
|
if (cartId) {
|
|
163
165
|
cartSend({
|
|
164
166
|
type: "CART_FETCH",
|
|
@@ -175,7 +177,7 @@ function CartProvider({
|
|
|
175
177
|
cartReady.current = true;
|
|
176
178
|
}
|
|
177
179
|
}, [cart, cartReady, cartSend]);
|
|
178
|
-
useEffect(() => {
|
|
180
|
+
require$$0.useEffect(() => {
|
|
179
181
|
if (!countryChanged || customerOverridesCountryCode.current)
|
|
180
182
|
return;
|
|
181
183
|
cartSend({
|
|
@@ -188,32 +190,32 @@ function CartProvider({
|
|
|
188
190
|
}
|
|
189
191
|
});
|
|
190
192
|
}, [countryCode, customerAccessToken, countryChanged, customerOverridesCountryCode, cartSend]);
|
|
191
|
-
const onCartReadySend = useCallback((cartEvent) => {
|
|
193
|
+
const onCartReadySend = require$$0.useCallback((cartEvent) => {
|
|
192
194
|
if (!cartReady.current) {
|
|
193
195
|
return console.warn("Cart isn't ready yet");
|
|
194
196
|
}
|
|
195
197
|
cartSend(cartEvent);
|
|
196
198
|
}, [cartSend]);
|
|
197
|
-
useEffect(() => {
|
|
199
|
+
require$$0.useEffect(() => {
|
|
198
200
|
var _a2, _b2, _c2;
|
|
199
201
|
if (((_b2 = (_a2 = cartState == null ? void 0 : cartState.context) == null ? void 0 : _a2.cart) == null ? void 0 : _b2.id) && storageAvailable("localStorage")) {
|
|
200
202
|
try {
|
|
201
|
-
window.localStorage.setItem(CART_ID_STORAGE_KEY, (_c2 = cartState.context.cart) == null ? void 0 : _c2.id);
|
|
203
|
+
window.localStorage.setItem(cartConstants.CART_ID_STORAGE_KEY, (_c2 = cartState.context.cart) == null ? void 0 : _c2.id);
|
|
202
204
|
} catch (error) {
|
|
203
205
|
console.warn("Failed to save cartId to localStorage", error);
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
}, [(_e = (_d = cartState == null ? void 0 : cartState.context) == null ? void 0 : _d.cart) == null ? void 0 : _e.id]);
|
|
207
|
-
useEffect(() => {
|
|
209
|
+
require$$0.useEffect(() => {
|
|
208
210
|
if (cartCompleted && storageAvailable("localStorage")) {
|
|
209
211
|
try {
|
|
210
|
-
window.localStorage.removeItem(CART_ID_STORAGE_KEY);
|
|
212
|
+
window.localStorage.removeItem(cartConstants.CART_ID_STORAGE_KEY);
|
|
211
213
|
} catch (error) {
|
|
212
214
|
console.warn("Failed to delete cartId from localStorage", error);
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
}, [cartCompleted]);
|
|
216
|
-
const cartCreate = useCallback((cartInput) => {
|
|
218
|
+
const cartCreate = require$$0.useCallback((cartInput) => {
|
|
217
219
|
var _a2, _b2;
|
|
218
220
|
if (countryCode && !((_a2 = cartInput.buyerIdentity) == null ? void 0 : _a2.countryCode)) {
|
|
219
221
|
if (cartInput.buyerIdentity == null) {
|
|
@@ -233,7 +235,7 @@ function CartProvider({
|
|
|
233
235
|
});
|
|
234
236
|
}, [countryCode, customerAccessToken, onCartReadySend]);
|
|
235
237
|
const cartDisplayState = useDelayedStateUntilHydration(cartState);
|
|
236
|
-
const cartContextValue = useMemo(() => {
|
|
238
|
+
const cartContextValue = require$$0.useMemo(() => {
|
|
237
239
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
238
240
|
return {
|
|
239
241
|
...(_b2 = (_a2 = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _a2.cart) != null ? _b2 : {
|
|
@@ -310,7 +312,7 @@ function CartProvider({
|
|
|
310
312
|
cartFragment
|
|
311
313
|
};
|
|
312
314
|
}, [cartCreate, (_f = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _f.cart, (_g = cartDisplayState == null ? void 0 : cartDisplayState.context) == null ? void 0 : _g.errors, cartDisplayState.value, cartFragment, onCartReadySend]);
|
|
313
|
-
return /* @__PURE__ */ jsx(CartContext.Provider, {
|
|
315
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CartContext.Provider, {
|
|
314
316
|
value: cartContextValue,
|
|
315
317
|
children
|
|
316
318
|
});
|
|
@@ -339,17 +341,17 @@ function transposeStatus(status) {
|
|
|
339
341
|
}
|
|
340
342
|
}
|
|
341
343
|
function useDelayedStateUntilHydration(state) {
|
|
342
|
-
const [isPending, startTransition] = useTransition();
|
|
343
|
-
const [delayedState, setDelayedState] = useState(state);
|
|
344
|
-
const firstTimePending = useRef(false);
|
|
344
|
+
const [isPending, startTransition] = require$$0.useTransition();
|
|
345
|
+
const [delayedState, setDelayedState] = require$$0.useState(state);
|
|
346
|
+
const firstTimePending = require$$0.useRef(false);
|
|
345
347
|
if (isPending) {
|
|
346
348
|
firstTimePending.current = true;
|
|
347
349
|
}
|
|
348
|
-
const firstTimePendingFinished = useRef(false);
|
|
350
|
+
const firstTimePendingFinished = require$$0.useRef(false);
|
|
349
351
|
if (!isPending && firstTimePending.current) {
|
|
350
352
|
firstTimePendingFinished.current = true;
|
|
351
353
|
}
|
|
352
|
-
useEffect(() => {
|
|
354
|
+
require$$0.useEffect(() => {
|
|
353
355
|
startTransition(() => {
|
|
354
356
|
if (!firstTimePendingFinished.current) {
|
|
355
357
|
setDelayedState(state);
|
|
@@ -475,11 +477,9 @@ fragment ImageFragment on Image {
|
|
|
475
477
|
height
|
|
476
478
|
}
|
|
477
479
|
`;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
useCart
|
|
484
|
-
};
|
|
480
|
+
exports.CartContext = CartContext;
|
|
481
|
+
exports.CartProvider = CartProvider;
|
|
482
|
+
exports.defaultCartFragment = defaultCartFragment;
|
|
483
|
+
exports.storageAvailable = storageAvailable;
|
|
484
|
+
exports.useCart = useCart;
|
|
485
485
|
//# sourceMappingURL=CartProvider.js.map
|