@shopify/hydrogen 0.23.0 → 0.25.1
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/CHANGELOG.md +173 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +2 -5
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +15 -14
- package/dist/esnext/components/BaseButton/BaseButton.client.d.ts +14 -0
- package/dist/esnext/components/BaseButton/BaseButton.client.js +15 -0
- package/dist/esnext/components/BaseButton/index.d.ts +1 -0
- package/dist/esnext/components/BaseButton/index.js +1 -0
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.d.ts +2 -5
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.js +5 -4
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.js +4 -4
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +5 -8
- package/dist/esnext/components/CartLineProvider/context.d.ts +10 -0
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +4 -5
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +16 -14
- package/dist/esnext/components/CartLines/CartLines.client.js +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +31 -38
- package/dist/esnext/components/CartProvider/cart-queries.d.ts +1 -1
- package/dist/esnext/components/CartProvider/cart-queries.js +11 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +11 -1
- package/dist/esnext/components/CartProvider/hooks.client.js +5 -8
- package/dist/esnext/components/CartProvider/types.d.ts +2 -0
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +13 -0
- package/dist/esnext/components/Image/Image.js +46 -20
- package/dist/esnext/components/Link/Link.client.js +1 -1
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +2 -2
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +6 -10
- package/dist/esnext/components/Metafield/Metafield.client.js +67 -31
- package/dist/esnext/components/Metafield/components/StarRating/StarRating.js +1 -1
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +2 -3
- package/dist/esnext/components/Money/Money.client.js +1 -1
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +22 -29
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +7 -7
- package/dist/esnext/components/Seo/CollectionSeo.client.js +2 -3
- package/dist/esnext/components/Seo/DefaultPageSeo.client.js +3 -3
- package/dist/esnext/components/Seo/NoIndexSeo.client.js +2 -2
- package/dist/esnext/components/Seo/PageSeo.client.js +2 -3
- package/dist/esnext/components/Seo/ProductSeo.client.js +9 -10
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +2 -3
- package/dist/esnext/components/Video/Video.js +2 -3
- package/dist/esnext/config.d.ts +4 -0
- package/dist/esnext/config.js +4 -0
- package/dist/esnext/constants.d.ts +2 -0
- package/dist/esnext/constants.js +2 -0
- package/dist/esnext/entry-client.js +5 -19
- package/dist/esnext/entry-server.d.ts +1 -17
- package/dist/esnext/entry-server.js +191 -50
- package/dist/esnext/foundation/Analytics/ClientAnalytics.js +4 -4
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.d.ts +4 -0
- package/dist/esnext/foundation/Analytics/{ServerAnalyticsRoute.server.js → ServerAnalyticsRoute.js} +5 -4
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.js +27 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.js +21 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.js +2 -3
- package/dist/esnext/foundation/BuiltInRoutes/BuiltInRoutes.d.ts +2 -0
- package/dist/esnext/foundation/BuiltInRoutes/BuiltInRoutes.js +23 -0
- package/dist/esnext/foundation/BuiltInRoutes/healthCheck.d.ts +1 -0
- package/dist/esnext/foundation/BuiltInRoutes/healthCheck.js +3 -0
- package/dist/esnext/foundation/Cache/cache-sub-request.js +2 -2
- package/dist/esnext/foundation/Cache/cache.js +2 -2
- package/dist/esnext/foundation/Cache/strategies/index.d.ts +4 -7
- package/dist/esnext/foundation/Cache/strategies/index.js +7 -49
- package/dist/esnext/foundation/Cookie/Cookie.js +5 -0
- package/dist/esnext/foundation/DevTools/DevTools.client.d.ts +3 -0
- package/dist/esnext/foundation/DevTools/DevTools.client.js +17 -0
- package/dist/esnext/foundation/DevTools/DevTools.server.d.ts +1 -0
- package/dist/esnext/foundation/DevTools/DevTools.server.js +14 -0
- package/dist/esnext/foundation/DevTools/components/GraphQL.client.d.ts +1 -0
- package/dist/esnext/foundation/DevTools/components/GraphQL.client.js +25 -0
- package/dist/esnext/foundation/DevTools/components/Heading.d.ts +5 -0
- package/dist/esnext/foundation/DevTools/components/Heading.js +12 -0
- package/dist/esnext/foundation/DevTools/components/Interface.client.d.ts +11 -0
- package/dist/esnext/foundation/DevTools/components/Interface.client.js +47 -0
- package/dist/esnext/foundation/DevTools/components/Panels.d.ts +8 -0
- package/dist/esnext/foundation/DevTools/components/Panels.js +60 -0
- package/dist/esnext/foundation/DevTools/components/Performance.client.d.ts +14 -0
- package/dist/esnext/foundation/DevTools/components/Performance.client.js +26 -0
- package/dist/esnext/foundation/DevTools/components/Settings.client.d.ts +7 -0
- package/dist/esnext/foundation/DevTools/components/Settings.client.js +20 -0
- package/dist/esnext/foundation/DevTools/components/Table.d.ts +9 -0
- package/dist/esnext/foundation/DevTools/components/Table.js +7 -0
- package/dist/esnext/foundation/DevTools/components/icons.d.ts +2 -0
- package/dist/esnext/foundation/DevTools/components/icons.js +13 -0
- package/dist/esnext/foundation/DevTools/components/index.d.ts +2 -0
- package/dist/esnext/foundation/DevTools/components/index.js +2 -0
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +4 -4
- package/dist/esnext/foundation/Html/Html.js +4 -7
- package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts +10 -4
- package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.js +69 -11
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +5 -7
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.js +22 -20
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +1 -2
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +1 -2
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +17 -22
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +3 -5
- package/dist/esnext/foundation/fetchSync/server/fetchSync.js +1 -1
- package/dist/esnext/foundation/useNavigate/useNavigate.js +3 -4
- package/dist/esnext/foundation/useQuery/hooks.d.ts +1 -0
- package/dist/esnext/foundation/useQuery/hooks.js +25 -17
- package/dist/esnext/foundation/useRequestContext/index.d.ts +15 -0
- package/dist/esnext/foundation/useRequestContext/index.js +23 -0
- package/dist/esnext/foundation/useServerProps/use-server-props.js +2 -2
- package/dist/esnext/foundation/useSession/useSession.js +1 -2
- package/dist/esnext/foundation/useUrl/useUrl.js +1 -2
- package/dist/esnext/framework/cache/in-memory.js +3 -3
- package/dist/esnext/framework/middleware.d.ts +1 -1
- package/dist/esnext/framework/middleware.js +3 -4
- package/dist/esnext/framework/plugin.d.ts +7 -3
- package/dist/esnext/framework/plugin.js +2 -1
- package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +70 -67
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -3
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +6 -4
- package/dist/esnext/framework/types.d.ts +5 -0
- package/dist/esnext/framework/types.js +1 -0
- package/dist/esnext/hooks/index.d.ts +0 -1
- package/dist/esnext/hooks/index.js +0 -1
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +10 -0
- package/dist/esnext/hooks/useMoney/hooks.js +53 -39
- package/dist/esnext/hooks/useProductOptions/helpers.js +6 -10
- package/dist/esnext/hooks/useProductOptions/types.d.ts +1 -1
- package/dist/esnext/hooks/useShopQuery/hooks.js +18 -12
- package/dist/esnext/index.d.ts +4 -5
- package/dist/esnext/index.js +2 -5
- package/dist/{node/entry-server.d.ts → esnext/shared-types.d.ts} +11 -7
- package/dist/esnext/shared-types.js +4 -0
- package/dist/esnext/storefront-api-types.d.ts +37 -443
- package/dist/esnext/streaming.server.d.ts +9 -18
- package/dist/esnext/streaming.server.js +2 -7
- package/dist/esnext/types.d.ts +9 -18
- package/dist/esnext/types.js +1 -1
- package/dist/esnext/utilities/apiRoutes.d.ts +7 -3
- package/dist/esnext/utilities/apiRoutes.js +6 -4
- package/dist/esnext/utilities/devtools.d.ts +1 -1
- package/dist/esnext/utilities/devtools.js +3 -3
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +1 -0
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +13 -6
- package/dist/esnext/utilities/graphql-tracker.js +6 -8
- package/dist/esnext/utilities/hash.d.ts +2 -2
- package/dist/esnext/utilities/hash.js +29 -6
- package/dist/esnext/utilities/image_size.d.ts +24 -3
- package/dist/esnext/utilities/image_size.js +53 -31
- package/dist/esnext/utilities/index.d.ts +1 -1
- package/dist/esnext/utilities/index.js +1 -1
- package/dist/esnext/utilities/load_script.js +1 -1
- package/dist/esnext/utilities/log/log-cache-api-status.js +3 -2
- package/dist/esnext/utilities/log/log-query-timeline.js +29 -10
- package/dist/esnext/utilities/log/log.js +1 -2
- package/dist/esnext/utilities/log/utils.js +1 -6
- package/dist/esnext/utilities/parseMetafield/index.d.ts +1 -0
- package/dist/esnext/utilities/parseMetafield/index.js +1 -0
- package/dist/esnext/utilities/parseMetafield/parseMetafield.d.ts +15 -0
- package/dist/esnext/utilities/{parseMetafieldValue/parseMetafieldValue.js → parseMetafield/parseMetafield.js} +28 -2
- package/dist/esnext/utilities/storefrontApi.js +9 -5
- package/dist/esnext/utilities/template.js +1 -2
- package/dist/esnext/utilities/web-api-polyfill.js +6 -0
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/framework/cache/in-memory.js +3 -3
- package/dist/node/framework/middleware.d.ts +1 -1
- package/dist/node/framework/middleware.js +3 -4
- package/dist/node/framework/plugin.d.ts +4 -3
- package/dist/node/framework/plugin.js +3 -2
- package/dist/node/framework/plugins/vite-plugin-client-imports.js +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +70 -67
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -3
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +2 -2
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +6 -4
- package/dist/node/framework/types.d.ts +5 -0
- package/dist/node/{components/CartProvider → framework}/types.js +0 -0
- package/dist/node/shared-types.d.ts +26 -0
- package/dist/node/shared-types.js +5 -0
- package/dist/node/utilities/web-api-polyfill.js +6 -0
- package/package.json +32 -26
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +100 -36
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +50 -13
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +28 -27
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +50 -13
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +28 -28
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +3 -5
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +100 -36
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +50 -13
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +50 -13
- package/client.d.ts +0 -1
- package/client.js +0 -1
- package/config.d.ts +0 -1
- package/config.js +0 -1
- package/dist/esnext/components/DevTools.client.d.ts +0 -1
- package/dist/esnext/components/DevTools.client.js +0 -129
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +0 -2
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.js +0 -25
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.js +0 -19
- package/dist/esnext/framework/Hydration/rsc.d.ts +0 -8
- package/dist/esnext/framework/Hydration/rsc.js +0 -102
- package/dist/esnext/hooks/useParsedMetafields/index.d.ts +0 -1
- package/dist/esnext/hooks/useParsedMetafields/index.js +0 -1
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +0 -21
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +0 -21
- package/dist/esnext/utilities/parseMetafieldValue/index.d.ts +0 -1
- package/dist/esnext/utilities/parseMetafieldValue/index.js +0 -1
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +0 -6
- package/dist/node/client.d.ts +0 -16
- package/dist/node/client.js +0 -43
- package/dist/node/components/AddToCartButton/AddToCartButton.client.d.ts +0 -23
- package/dist/node/components/AddToCartButton/AddToCartButton.client.js +0 -74
- package/dist/node/components/AddToCartButton/index.d.ts +0 -1
- package/dist/node/components/AddToCartButton/index.js +0 -5
- package/dist/node/components/BuyNowButton/BuyNowButton.client.d.ts +0 -18
- package/dist/node/components/BuyNowButton/BuyNowButton.client.js +0 -53
- package/dist/node/components/BuyNowButton/index.d.ts +0 -1
- package/dist/node/components/BuyNowButton/index.js +0 -5
- package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +0 -11
- package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.js +0 -44
- package/dist/node/components/CartCheckoutButton/index.d.ts +0 -1
- package/dist/node/components/CartCheckoutButton/index.js +0 -5
- package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +0 -14
- package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.js +0 -36
- package/dist/node/components/CartEstimatedCost/index.d.ts +0 -1
- package/dist/node/components/CartEstimatedCost/index.js +0 -5
- package/dist/node/components/CartLineImage/CartLineImage.client.d.ts +0 -9
- package/dist/node/components/CartLineImage/CartLineImage.client.js +0 -18
- package/dist/node/components/CartLineImage/index.d.ts +0 -1
- package/dist/node/components/CartLineImage/index.js +0 -5
- package/dist/node/components/CartLinePrice/CartLinePrice.client.d.ts +0 -12
- package/dist/node/components/CartLinePrice/CartLinePrice.client.js +0 -28
- package/dist/node/components/CartLinePrice/index.d.ts +0 -1
- package/dist/node/components/CartLinePrice/index.js +0 -5
- package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +0 -8
- package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.js +0 -19
- package/dist/node/components/CartLineProductTitle/index.d.ts +0 -1
- package/dist/node/components/CartLineProductTitle/index.js +0 -5
- package/dist/node/components/CartLineProvider/CartLineProvider.client.d.ts +0 -11
- package/dist/node/components/CartLineProvider/CartLineProvider.client.js +0 -15
- package/dist/node/components/CartLineProvider/context.d.ts +0 -26
- package/dist/node/components/CartLineProvider/context.js +0 -5
- package/dist/node/components/CartLineProvider/index.d.ts +0 -2
- package/dist/node/components/CartLineProvider/index.js +0 -7
- package/dist/node/components/CartLineQuantity/CartLineQuantity.client.d.ts +0 -8
- package/dist/node/components/CartLineQuantity/CartLineQuantity.client.js +0 -19
- package/dist/node/components/CartLineQuantity/index.d.ts +0 -1
- package/dist/node/components/CartLineQuantity/index.js +0 -5
- package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +0 -14
- package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +0 -31
- package/dist/node/components/CartLineQuantityAdjustButton/index.d.ts +0 -1
- package/dist/node/components/CartLineQuantityAdjustButton/index.js +0 -5
- package/dist/node/components/CartLines/CartLines.client.d.ts +0 -15
- package/dist/node/components/CartLines/CartLines.client.js +0 -44
- package/dist/node/components/CartLines/index.d.ts +0 -1
- package/dist/node/components/CartLines/index.js +0 -5
- package/dist/node/components/CartProvider/CartProvider.client.d.ts +0 -41
- package/dist/node/components/CartProvider/CartProvider.client.js +0 -550
- package/dist/node/components/CartProvider/cart-queries.d.ts +0 -10
- package/dist/node/components/CartProvider/cart-queries.js +0 -203
- package/dist/node/components/CartProvider/constants.d.ts +0 -2
- package/dist/node/components/CartProvider/constants.js +0 -5
- package/dist/node/components/CartProvider/context.d.ts +0 -2
- package/dist/node/components/CartProvider/context.js +0 -5
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.d.ts +0 -85
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartFragment.d.ts +0 -72
- package/dist/node/components/CartProvider/graphql/CartFragment.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +0 -86
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartQuery.d.ts +0 -81
- package/dist/node/components/CartProvider/graphql/CartQuery.js +0 -2
- package/dist/node/components/CartProvider/hooks.client.d.ts +0 -15
- package/dist/node/components/CartProvider/hooks.client.js +0 -90
- package/dist/node/components/CartProvider/index.d.ts +0 -4
- package/dist/node/components/CartProvider/index.js +0 -10
- package/dist/node/components/CartProvider/types.d.ts +0 -102
- package/dist/node/components/CartShopPayButton/CartShopPayButton.client.d.ts +0 -9
- package/dist/node/components/CartShopPayButton/CartShopPayButton.client.js +0 -46
- package/dist/node/components/CartShopPayButton/index.d.ts +0 -1
- package/dist/node/components/CartShopPayButton/index.js +0 -5
- package/dist/node/components/ExternalVideo/ExternalVideo.d.ts +0 -21
- package/dist/node/components/ExternalVideo/ExternalVideo.js +0 -21
- package/dist/node/components/ExternalVideo/index.d.ts +0 -1
- package/dist/node/components/ExternalVideo/index.js +0 -5
- package/dist/node/components/Image/Image.d.ts +0 -92
- package/dist/node/components/Image/Image.js +0 -137
- package/dist/node/components/Image/index.d.ts +0 -2
- package/dist/node/components/Image/index.js +0 -5
- package/dist/node/components/Link/Link.client.d.ts +0 -25
- package/dist/node/components/Link/Link.client.js +0 -165
- package/dist/node/components/Link/index.d.ts +0 -1
- package/dist/node/components/Link/index.js +0 -5
- package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +0 -6
- package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.js +0 -11
- package/dist/node/components/LocalizationProvider/LocalizationContext.client.d.ts +0 -6
- package/dist/node/components/LocalizationProvider/LocalizationContext.client.js +0 -5
- package/dist/node/components/LocalizationProvider/LocalizationProvider.server.d.ts +0 -33
- package/dist/node/components/LocalizationProvider/LocalizationProvider.server.js +0 -51
- package/dist/node/components/MediaFile/MediaFile.d.ts +0 -19
- package/dist/node/components/MediaFile/MediaFile.js +0 -39
- package/dist/node/components/MediaFile/index.d.ts +0 -1
- package/dist/node/components/MediaFile/index.js +0 -5
- package/dist/node/components/Metafield/Metafield.client.d.ts +0 -21
- package/dist/node/components/Metafield/Metafield.client.js +0 -75
- package/dist/node/components/Metafield/index.d.ts +0 -2
- package/dist/node/components/Metafield/index.js +0 -5
- package/dist/node/components/Metafield/types.d.ts +0 -4
- package/dist/node/components/Metafield/types.js +0 -2
- package/dist/node/components/ModelViewer/ModelViewer.client.d.ts +0 -128
- package/dist/node/components/ModelViewer/ModelViewer.client.js +0 -132
- package/dist/node/components/ModelViewer/index.d.ts +0 -1
- package/dist/node/components/ModelViewer/index.js +0 -5
- package/dist/node/components/Money/Money.client.d.ts +0 -25
- package/dist/node/components/Money/Money.client.js +0 -46
- package/dist/node/components/Money/index.d.ts +0 -1
- package/dist/node/components/Money/index.js +0 -5
- package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +0 -21
- package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.js +0 -167
- package/dist/node/components/ProductOptionsProvider/context.d.ts +0 -2
- package/dist/node/components/ProductOptionsProvider/context.js +0 -5
- package/dist/node/components/ProductOptionsProvider/index.d.ts +0 -2
- package/dist/node/components/ProductOptionsProvider/index.js +0 -7
- package/dist/node/components/ProductPrice/ProductPrice.client.d.ts +0 -18
- package/dist/node/components/ProductPrice/ProductPrice.client.js +0 -61
- package/dist/node/components/ProductPrice/index.d.ts +0 -1
- package/dist/node/components/ProductPrice/index.js +0 -5
- package/dist/node/components/Seo/CollectionSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/CollectionSeo.client.js +0 -22
- package/dist/node/components/Seo/DefaultPageSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/DefaultPageSeo.client.js +0 -25
- package/dist/node/components/Seo/DescriptionSeo.client.d.ts +0 -4
- package/dist/node/components/Seo/DescriptionSeo.client.js +0 -17
- package/dist/node/components/Seo/HomePageSeo.client.d.ts +0 -2
- package/dist/node/components/Seo/HomePageSeo.client.js +0 -32
- package/dist/node/components/Seo/ImageSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/ImageSeo.client.js +0 -17
- package/dist/node/components/Seo/NoIndexSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/NoIndexSeo.client.js +0 -17
- package/dist/node/components/Seo/PageSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/PageSeo.client.js +0 -20
- package/dist/node/components/Seo/ProductSeo.client.d.ts +0 -5
- package/dist/node/components/Seo/ProductSeo.client.js +0 -70
- package/dist/node/components/Seo/Seo.client.d.ts +0 -30
- package/dist/node/components/Seo/Seo.client.js +0 -38
- package/dist/node/components/Seo/TitleSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/TitleSeo.client.js +0 -17
- package/dist/node/components/Seo/TwitterSeo.client.d.ts +0 -2
- package/dist/node/components/Seo/TwitterSeo.client.js +0 -16
- package/dist/node/components/Seo/index.d.ts +0 -1
- package/dist/node/components/Seo/index.js +0 -5
- package/dist/node/components/Seo/seo-types.d.ts +0 -17
- package/dist/node/components/Seo/seo-types.js +0 -2
- package/dist/node/components/ShopPayButton/ShopPayButton.client.d.ts +0 -38
- package/dist/node/components/ShopPayButton/ShopPayButton.client.js +0 -60
- package/dist/node/components/ShopPayButton/index.d.ts +0 -1
- package/dist/node/components/ShopPayButton/index.js +0 -5
- package/dist/node/components/Video/Video.d.ts +0 -14
- package/dist/node/components/Video/Video.js +0 -31
- package/dist/node/components/Video/index.d.ts +0 -1
- package/dist/node/components/Video/index.js +0 -5
- package/dist/node/components/index.d.ts +0 -28
- package/dist/node/components/index.js +0 -59
- package/dist/node/components/types.d.ts +0 -71
- package/dist/node/components/types.js +0 -11
- package/dist/node/constants.d.ts +0 -7
- package/dist/node/constants.js +0 -10
- package/dist/node/entry-server.js +0 -495
- package/dist/node/foundation/Analytics/Analytics.client.d.ts +0 -3
- package/dist/node/foundation/Analytics/Analytics.client.js +0 -34
- package/dist/node/foundation/Analytics/Analytics.server.d.ts +0 -1
- package/dist/node/foundation/Analytics/Analytics.server.js +0 -77
- package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +0 -27
- package/dist/node/foundation/Analytics/ClientAnalytics.js +0 -102
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +0 -2
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +0 -39
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.d.ts +0 -7
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +0 -68
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.d.ts +0 -1
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +0 -27
- package/dist/node/foundation/Analytics/const.d.ts +0 -9
- package/dist/node/foundation/Analytics/const.js +0 -12
- package/dist/node/foundation/Analytics/hook.d.ts +0 -1
- package/dist/node/foundation/Analytics/hook.js +0 -13
- package/dist/node/foundation/Analytics/index.d.ts +0 -1
- package/dist/node/foundation/Analytics/index.js +0 -5
- package/dist/node/foundation/Analytics/types.d.ts +0 -5
- package/dist/node/foundation/Analytics/types.js +0 -2
- package/dist/node/foundation/Analytics/utils.d.ts +0 -3
- package/dist/node/foundation/Analytics/utils.js +0 -35
- package/dist/node/foundation/AnalyticsErrorBoundary.client.d.ts +0 -4
- package/dist/node/foundation/AnalyticsErrorBoundary.client.js +0 -14
- package/dist/node/foundation/Cache/cache-sub-request.d.ts +0 -17
- package/dist/node/foundation/Cache/cache-sub-request.js +0 -95
- package/dist/node/foundation/Cache/cache.d.ts +0 -17
- package/dist/node/foundation/Cache/cache.js +0 -135
- package/dist/node/foundation/Cache/strategies/index.d.ts +0 -10
- package/dist/node/foundation/Cache/strategies/index.js +0 -108
- package/dist/node/foundation/Head/Head.client.d.ts +0 -5
- package/dist/node/foundation/Head/Head.client.js +0 -17
- package/dist/node/foundation/Head/index.d.ts +0 -1
- package/dist/node/foundation/Head/index.js +0 -5
- package/dist/node/foundation/Html/Html.d.ts +0 -13
- package/dist/node/foundation/Html/Html.js +0 -107
- package/dist/node/foundation/HydrogenRequest/HydrogenRequest.server.d.ts +0 -62
- package/dist/node/foundation/HydrogenRequest/HydrogenRequest.server.js +0 -150
- package/dist/node/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +0 -23
- package/dist/node/foundation/HydrogenResponse/HydrogenResponse.server.js +0 -53
- package/dist/node/foundation/Redirect/Redirect.client.d.ts +0 -5
- package/dist/node/foundation/Redirect/Redirect.client.js +0 -18
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +0 -14
- package/dist/node/foundation/Router/BrowserRouter.client.js +0 -166
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +0 -41
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -90
- package/dist/node/foundation/ServerPropsProvider/index.d.ts +0 -2
- package/dist/node/foundation/ServerPropsProvider/index.js +0 -6
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +0 -23
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +0 -158
- package/dist/node/foundation/ServerRequestProvider/index.d.ts +0 -1
- package/dist/node/foundation/ServerRequestProvider/index.js +0 -17
- package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +0 -7
- package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.js +0 -35
- package/dist/node/foundation/ShopifyProvider/index.d.ts +0 -1
- package/dist/node/foundation/ShopifyProvider/index.js +0 -5
- package/dist/node/foundation/ShopifyProvider/types.d.ts +0 -13
- package/dist/node/foundation/ShopifyProvider/types.js +0 -2
- package/dist/node/foundation/fetchSync/client/fetchSync.d.ts +0 -10
- package/dist/node/foundation/fetchSync/client/fetchSync.js +0 -33
- package/dist/node/foundation/fetchSync/server/fetchSync.d.ts +0 -8
- package/dist/node/foundation/fetchSync/server/fetchSync.js +0 -33
- package/dist/node/foundation/fetchSync/types.d.ts +0 -5
- package/dist/node/foundation/fetchSync/types.js +0 -2
- package/dist/node/foundation/index.d.ts +0 -3
- package/dist/node/foundation/index.js +0 -10
- package/dist/node/foundation/runtime.d.ts +0 -2
- package/dist/node/foundation/runtime.js +0 -11
- package/dist/node/foundation/session/session.d.ts +0 -27
- package/dist/node/foundation/session/session.js +0 -43
- package/dist/node/foundation/ssr-interop.d.ts +0 -29
- package/dist/node/foundation/ssr-interop.js +0 -39
- package/dist/node/foundation/useNavigate/useNavigate.d.ts +0 -15
- package/dist/node/foundation/useNavigate/useNavigate.js +0 -25
- package/dist/node/foundation/useQuery/hooks.d.ts +0 -36
- package/dist/node/foundation/useQuery/hooks.js +0 -104
- package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.d.ts +0 -10
- package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.js +0 -34
- package/dist/node/foundation/useRouteParams/useRouteParams.d.ts +0 -4
- package/dist/node/foundation/useRouteParams/useRouteParams.js +0 -13
- package/dist/node/foundation/useServerProps/index.d.ts +0 -1
- package/dist/node/foundation/useServerProps/index.js +0 -5
- package/dist/node/foundation/useServerProps/use-server-props.d.ts +0 -21
- package/dist/node/foundation/useServerProps/use-server-props.js +0 -40
- package/dist/node/foundation/useSession/useSession.d.ts +0 -2
- package/dist/node/foundation/useSession/useSession.js +0 -12
- package/dist/node/foundation/useShop/index.d.ts +0 -1
- package/dist/node/foundation/useShop/index.js +0 -5
- package/dist/node/foundation/useShop/use-shop.d.ts +0 -6
- package/dist/node/foundation/useShop/use-shop.js +0 -18
- package/dist/node/foundation/useUrl/index.d.ts +0 -1
- package/dist/node/foundation/useUrl/index.js +0 -5
- package/dist/node/foundation/useUrl/useUrl.d.ts +0 -4
- package/dist/node/foundation/useUrl/useUrl.js +0 -32
- package/dist/node/framework/Hydration/rsc.d.ts +0 -8
- package/dist/node/framework/Hydration/rsc.js +0 -105
- package/dist/node/hooks/index.d.ts +0 -6
- package/dist/node/hooks/index.js +0 -28
- package/dist/node/hooks/useCart/index.d.ts +0 -1
- package/dist/node/hooks/useCart/index.js +0 -5
- package/dist/node/hooks/useCart/useCart.d.ts +0 -4
- package/dist/node/hooks/useCart/useCart.js +0 -19
- package/dist/node/hooks/useCartLine/index.d.ts +0 -1
- package/dist/node/hooks/useCartLine/index.js +0 -5
- package/dist/node/hooks/useCartLine/useCartLine.d.ts +0 -29
- package/dist/node/hooks/useCartLine/useCartLine.js +0 -16
- package/dist/node/hooks/useCountry/index.d.ts +0 -1
- package/dist/node/hooks/useCountry/index.js +0 -5
- package/dist/node/hooks/useCountry/useCountry.d.ts +0 -7
- package/dist/node/hooks/useCountry/useCountry.js +0 -21
- package/dist/node/hooks/useLoadScript/index.d.ts +0 -1
- package/dist/node/hooks/useLoadScript/index.js +0 -5
- package/dist/node/hooks/useLoadScript/useLoadScript.client.d.ts +0 -8
- package/dist/node/hooks/useLoadScript/useLoadScript.client.js +0 -27
- package/dist/node/hooks/useMeasurement/hooks.d.ts +0 -9
- package/dist/node/hooks/useMeasurement/hooks.js +0 -17
- package/dist/node/hooks/useMeasurement/index.d.ts +0 -1
- package/dist/node/hooks/useMeasurement/index.js +0 -5
- package/dist/node/hooks/useMoney/hooks.d.ts +0 -54
- package/dist/node/hooks/useMoney/hooks.js +0 -70
- package/dist/node/hooks/useMoney/index.d.ts +0 -1
- package/dist/node/hooks/useMoney/index.js +0 -5
- package/dist/node/hooks/useParsedMetafields/index.d.ts +0 -1
- package/dist/node/hooks/useParsedMetafields/index.js +0 -5
- package/dist/node/hooks/useParsedMetafields/useParsedMetafields.d.ts +0 -21
- package/dist/node/hooks/useParsedMetafields/useParsedMetafields.js +0 -25
- package/dist/node/hooks/useProductOptions/helpers.d.ts +0 -6
- package/dist/node/hooks/useProductOptions/helpers.js +0 -46
- package/dist/node/hooks/useProductOptions/index.d.ts +0 -2
- package/dist/node/hooks/useProductOptions/index.js +0 -20
- package/dist/node/hooks/useProductOptions/types.d.ts +0 -44
- package/dist/node/hooks/useProductOptions/types.js +0 -2
- package/dist/node/hooks/useProductOptions/useProductOptions.client.d.ts +0 -1
- package/dist/node/hooks/useProductOptions/useProductOptions.client.js +0 -13
- package/dist/node/hooks/useShopQuery/hooks.d.ts +0 -28
- package/dist/node/hooks/useShopQuery/hooks.js +0 -171
- package/dist/node/hooks/useShopQuery/index.d.ts +0 -1
- package/dist/node/hooks/useShopQuery/index.js +0 -5
- package/dist/node/storefront-api-types.d.ts +0 -6405
- package/dist/node/storefront-api-types.js +0 -1766
- package/dist/node/streaming.server.d.ts +0 -25
- package/dist/node/streaming.server.js +0 -28
- package/dist/node/types.d.ts +0 -114
- package/dist/node/types.js +0 -2
- package/dist/node/utilities/apiRoutes.d.ts +0 -37
- package/dist/node/utilities/apiRoutes.js +0 -157
- package/dist/node/utilities/bot-ua.d.ts +0 -4
- package/dist/node/utilities/bot-ua.js +0 -65
- package/dist/node/utilities/devtools.d.ts +0 -11
- package/dist/node/utilities/devtools.js +0 -15
- package/dist/node/utilities/error.d.ts +0 -1
- package/dist/node/utilities/error.js +0 -10
- package/dist/node/utilities/fetch.d.ts +0 -9
- package/dist/node/utilities/fetch.js +0 -37
- package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +0 -6
- package/dist/node/utilities/flattenConnection/flattenConnection.js +0 -15
- package/dist/node/utilities/flattenConnection/index.d.ts +0 -1
- package/dist/node/utilities/flattenConnection/index.js +0 -5
- package/dist/node/utilities/graphql-tag.d.ts +0 -1
- package/dist/node/utilities/graphql-tag.js +0 -10
- package/dist/node/utilities/graphql-tracker.d.ts +0 -17
- package/dist/node/utilities/graphql-tracker.js +0 -130
- package/dist/node/utilities/hash.d.ts +0 -2
- package/dist/node/utilities/hash.js +0 -11
- package/dist/node/utilities/html-encoding.d.ts +0 -1
- package/dist/node/utilities/html-encoding.js +0 -12
- package/dist/node/utilities/image_size.d.ts +0 -12
- package/dist/node/utilities/image_size.js +0 -68
- package/dist/node/utilities/index.d.ts +0 -12
- package/dist/node/utilities/index.js +0 -33
- package/dist/node/utilities/isBrowser/index.d.ts +0 -1
- package/dist/node/utilities/isBrowser/index.js +0 -5
- package/dist/node/utilities/isBrowser/isBrowser.d.ts +0 -4
- package/dist/node/utilities/isBrowser/isBrowser.js +0 -10
- package/dist/node/utilities/isServer/index.d.ts +0 -1
- package/dist/node/utilities/isServer/index.js +0 -5
- package/dist/node/utilities/isServer/isServer.d.ts +0 -4
- package/dist/node/utilities/isServer/isServer.js +0 -11
- package/dist/node/utilities/load_script.d.ts +0 -3
- package/dist/node/utilities/load_script.js +0 -27
- package/dist/node/utilities/log/index.d.ts +0 -4
- package/dist/node/utilities/log/index.js +0 -16
- package/dist/node/utilities/log/log-cache-api-status.d.ts +0 -1
- package/dist/node/utilities/log/log-cache-api-status.js +0 -17
- package/dist/node/utilities/log/log-cache-header.d.ts +0 -10
- package/dist/node/utilities/log/log-cache-header.js +0 -35
- package/dist/node/utilities/log/log-query-timeline.d.ts +0 -12
- package/dist/node/utilities/log/log-query-timeline.js +0 -88
- package/dist/node/utilities/log/log.d.ts +0 -28
- package/dist/node/utilities/log/log.js +0 -81
- package/dist/node/utilities/log/utils.d.ts +0 -3
- package/dist/node/utilities/log/utils.js +0 -21
- package/dist/node/utilities/matchPath.d.ts +0 -10
- package/dist/node/utilities/matchPath.js +0 -58
- package/dist/node/utilities/measurement.d.ts +0 -3
- package/dist/node/utilities/measurement.js +0 -103
- package/dist/node/utilities/parse.d.ts +0 -1
- package/dist/node/utilities/parse.js +0 -13
- package/dist/node/utilities/parseMetafieldValue/index.d.ts +0 -1
- package/dist/node/utilities/parseMetafieldValue/index.js +0 -5
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +0 -6
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +0 -40
- package/dist/node/utilities/storefrontApi.d.ts +0 -4
- package/dist/node/utilities/storefrontApi.js +0 -26
- package/dist/node/utilities/suspense.d.ts +0 -12
- package/dist/node/utilities/suspense.js +0 -64
- package/dist/node/utilities/template.d.ts +0 -9
- package/dist/node/utilities/template.js +0 -27
- package/dist/node/utilities/timing.d.ts +0 -7
- package/dist/node/utilities/timing.js +0 -18
- package/dist/node/utilities/video_parameters.d.ts +0 -47
- package/dist/node/utilities/video_parameters.js +0 -27
- package/dist/node/version.d.ts +0 -1
- package/dist/node/version.js +0 -4
- package/entry-client.d.ts +0 -1
- package/entry-client.js +0 -1
- package/entry-server.d.ts +0 -1
- package/entry-server.js +0 -1
- package/middleware.d.ts +0 -1
- package/middleware.js +0 -1
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -1
- package/web-polyfills.js +0 -1
|
@@ -1,550 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CartProvider = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const flattenConnection_1 = require("../../utilities/flattenConnection");
|
|
29
|
-
const cart_queries_1 = require("./cart-queries");
|
|
30
|
-
const storefront_api_types_1 = require("../../storefront-api-types");
|
|
31
|
-
const hooks_client_1 = require("./hooks.client");
|
|
32
|
-
const context_1 = require("./context");
|
|
33
|
-
const constants_1 = require("./constants");
|
|
34
|
-
const ClientAnalytics_1 = require("../../foundation/Analytics/ClientAnalytics");
|
|
35
|
-
function cartReducer(state, action) {
|
|
36
|
-
switch (action.type) {
|
|
37
|
-
case 'cartFetch': {
|
|
38
|
-
if (state.status === 'uninitialized') {
|
|
39
|
-
return {
|
|
40
|
-
status: 'fetching',
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
case 'cartCreate': {
|
|
46
|
-
if (state.status === 'uninitialized') {
|
|
47
|
-
return {
|
|
48
|
-
status: 'creating',
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case 'resolve': {
|
|
54
|
-
const resolvableStatuses = ['updating', 'fetching', 'creating'];
|
|
55
|
-
if (resolvableStatuses.includes(state.status)) {
|
|
56
|
-
return {
|
|
57
|
-
status: 'idle',
|
|
58
|
-
cart: action.cart,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case 'reject': {
|
|
64
|
-
if (state.status === 'fetching' || state.status === 'creating') {
|
|
65
|
-
return { status: 'uninitialized', error: action.error };
|
|
66
|
-
}
|
|
67
|
-
else if (state.status === 'updating') {
|
|
68
|
-
return {
|
|
69
|
-
status: 'idle',
|
|
70
|
-
cart: state.lastValidCart,
|
|
71
|
-
error: action.error,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'resetCart': {
|
|
77
|
-
if (state.status === 'fetching') {
|
|
78
|
-
return { status: 'uninitialized' };
|
|
79
|
-
}
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
case 'addLineItem': {
|
|
83
|
-
if (state.status === 'idle') {
|
|
84
|
-
return {
|
|
85
|
-
status: 'updating',
|
|
86
|
-
cart: state.cart,
|
|
87
|
-
lastValidCart: state.cart,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
case 'removeLineItem': {
|
|
93
|
-
if (state.status === 'idle') {
|
|
94
|
-
return {
|
|
95
|
-
status: 'updating',
|
|
96
|
-
cart: {
|
|
97
|
-
...state.cart,
|
|
98
|
-
lines: state.cart.lines.filter(({ id }) => !action.lines.includes(id)),
|
|
99
|
-
},
|
|
100
|
-
lastValidCart: state.cart,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
case 'updateLineItem': {
|
|
106
|
-
if (state.status === 'idle') {
|
|
107
|
-
return {
|
|
108
|
-
status: 'updating',
|
|
109
|
-
cart: {
|
|
110
|
-
...state.cart,
|
|
111
|
-
lines: state.cart.lines.map((line) => {
|
|
112
|
-
const updatedLine = action.lines.find(({ id }) => id === line.id);
|
|
113
|
-
if (updatedLine && updatedLine.quantity) {
|
|
114
|
-
return {
|
|
115
|
-
...line,
|
|
116
|
-
quantity: updatedLine.quantity,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return line;
|
|
120
|
-
}),
|
|
121
|
-
},
|
|
122
|
-
lastValidCart: state.cart,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
case 'noteUpdate': {
|
|
128
|
-
if (state.status === 'idle') {
|
|
129
|
-
return {
|
|
130
|
-
status: 'updating',
|
|
131
|
-
cart: state.cart,
|
|
132
|
-
lastValidCart: state.cart,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
case 'buyerIdentityUpdate': {
|
|
138
|
-
if (state.status === 'idle') {
|
|
139
|
-
return {
|
|
140
|
-
status: 'updating',
|
|
141
|
-
cart: state.cart,
|
|
142
|
-
lastValidCart: state.cart,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case 'cartAttributesUpdate': {
|
|
148
|
-
if (state.status === 'idle') {
|
|
149
|
-
return {
|
|
150
|
-
status: 'updating',
|
|
151
|
-
cart: state.cart,
|
|
152
|
-
lastValidCart: state.cart,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
case 'discountCodesUpdate': {
|
|
158
|
-
if (state.status === 'idle') {
|
|
159
|
-
return {
|
|
160
|
-
status: 'updating',
|
|
161
|
-
cart: state.cart,
|
|
162
|
-
lastValidCart: state.cart,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
throw new Error(`Cannot dispatch event (${action.type}) for current cart state (${state.status})`);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* The `CartProvider` component creates a context for using a cart. It creates a cart object and callbacks
|
|
172
|
-
* that can be accessed by any descendent component using the `useCart` hook and related hooks. It also carries out
|
|
173
|
-
* any callback props when a relevant action is performed. For example, if a `onLineAdd` callback is provided,
|
|
174
|
-
* then the callback will be called when a new line item is successfully added to the cart.
|
|
175
|
-
*
|
|
176
|
-
* The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
|
|
177
|
-
* You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
|
|
178
|
-
*/
|
|
179
|
-
function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment = cart_queries_1.defaultCartFragment, customerAccessToken, countryCode = storefront_api_types_1.CountryCode.Us, }) {
|
|
180
|
-
const initialStatus = cart
|
|
181
|
-
? { status: 'idle', cart: cartFromGraphQL(cart) }
|
|
182
|
-
: { status: 'uninitialized' };
|
|
183
|
-
const [state, dispatch] = (0, react_1.useReducer)((state, dispatch) => cartReducer(state, dispatch), initialStatus);
|
|
184
|
-
const fetchCart = (0, hooks_client_1.useCartFetch)();
|
|
185
|
-
const cartFetch = (0, react_1.useCallback)(async (cartId) => {
|
|
186
|
-
dispatch({ type: 'cartFetch' });
|
|
187
|
-
const { data } = await fetchCart({
|
|
188
|
-
query: (0, cart_queries_1.CartQuery)(cartFragment),
|
|
189
|
-
variables: {
|
|
190
|
-
id: cartId,
|
|
191
|
-
numCartLines,
|
|
192
|
-
country: countryCode,
|
|
193
|
-
},
|
|
194
|
-
});
|
|
195
|
-
if (!(data === null || data === void 0 ? void 0 : data.cart)) {
|
|
196
|
-
window.localStorage.removeItem(constants_1.CART_ID_STORAGE_KEY);
|
|
197
|
-
dispatch({ type: 'resetCart' });
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
dispatch({ type: 'resolve', cart: cartFromGraphQL(data.cart) });
|
|
201
|
-
}, [fetchCart, cartFragment, numCartLines, countryCode]);
|
|
202
|
-
const cartCreate = (0, react_1.useCallback)(async (cart) => {
|
|
203
|
-
var _a, _b, _c;
|
|
204
|
-
dispatch({ type: 'cartCreate' });
|
|
205
|
-
onCreate === null || onCreate === void 0 ? void 0 : onCreate();
|
|
206
|
-
if (countryCode && !((_a = cart.buyerIdentity) === null || _a === void 0 ? void 0 : _a.countryCode)) {
|
|
207
|
-
if (cart.buyerIdentity == null) {
|
|
208
|
-
cart.buyerIdentity = {};
|
|
209
|
-
}
|
|
210
|
-
cart.buyerIdentity.countryCode = countryCode;
|
|
211
|
-
}
|
|
212
|
-
if (customerAccessToken && !((_b = cart.buyerIdentity) === null || _b === void 0 ? void 0 : _b.customerAccessToken)) {
|
|
213
|
-
if (cart.buyerIdentity == null) {
|
|
214
|
-
cart.buyerIdentity = {};
|
|
215
|
-
}
|
|
216
|
-
cart.buyerIdentity.customerAccessToken = customerAccessToken;
|
|
217
|
-
}
|
|
218
|
-
const { data, error } = await fetchCart({
|
|
219
|
-
query: (0, cart_queries_1.CartCreate)(cartFragment),
|
|
220
|
-
variables: {
|
|
221
|
-
input: cart,
|
|
222
|
-
numCartLines,
|
|
223
|
-
country: countryCode,
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
if (error) {
|
|
227
|
-
dispatch({
|
|
228
|
-
type: 'reject',
|
|
229
|
-
error,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
if ((_c = data === null || data === void 0 ? void 0 : data.cartCreate) === null || _c === void 0 ? void 0 : _c.cart) {
|
|
233
|
-
if (cart.lines) {
|
|
234
|
-
ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.ADD_TO_CART, true, {
|
|
235
|
-
addedCartLines: cart.lines,
|
|
236
|
-
cart: data.cartCreate.cart,
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
dispatch({
|
|
240
|
-
type: 'resolve',
|
|
241
|
-
cart: cartFromGraphQL(data.cartCreate.cart),
|
|
242
|
-
});
|
|
243
|
-
window.localStorage.setItem(constants_1.CART_ID_STORAGE_KEY, data.cartCreate.cart.id);
|
|
244
|
-
}
|
|
245
|
-
}, [
|
|
246
|
-
onCreate,
|
|
247
|
-
countryCode,
|
|
248
|
-
fetchCart,
|
|
249
|
-
cartFragment,
|
|
250
|
-
numCartLines,
|
|
251
|
-
customerAccessToken,
|
|
252
|
-
]);
|
|
253
|
-
const addLineItem = (0, react_1.useCallback)(async (lines, state) => {
|
|
254
|
-
var _a;
|
|
255
|
-
if (state.status === 'idle') {
|
|
256
|
-
dispatch({ type: 'addLineItem' });
|
|
257
|
-
onLineAdd === null || onLineAdd === void 0 ? void 0 : onLineAdd();
|
|
258
|
-
const { data, error } = await fetchCart({
|
|
259
|
-
query: (0, cart_queries_1.CartLineAdd)(cartFragment),
|
|
260
|
-
variables: {
|
|
261
|
-
cartId: state.cart.id,
|
|
262
|
-
lines,
|
|
263
|
-
numCartLines,
|
|
264
|
-
country: countryCode,
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
if (error) {
|
|
268
|
-
dispatch({
|
|
269
|
-
type: 'reject',
|
|
270
|
-
error,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartLinesAdd) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
274
|
-
ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.ADD_TO_CART, true, {
|
|
275
|
-
addedCartLines: lines,
|
|
276
|
-
cart: data.cartLinesAdd.cart,
|
|
277
|
-
});
|
|
278
|
-
dispatch({
|
|
279
|
-
type: 'resolve',
|
|
280
|
-
cart: cartFromGraphQL(data.cartLinesAdd.cart),
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}, [onLineAdd, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
285
|
-
const removeLineItem = (0, react_1.useCallback)(async (lines, state) => {
|
|
286
|
-
var _a;
|
|
287
|
-
if (state.status === 'idle') {
|
|
288
|
-
dispatch({ type: 'removeLineItem', lines });
|
|
289
|
-
onLineRemove === null || onLineRemove === void 0 ? void 0 : onLineRemove();
|
|
290
|
-
const { data, error } = await fetchCart({
|
|
291
|
-
query: (0, cart_queries_1.CartLineRemove)(cartFragment),
|
|
292
|
-
variables: {
|
|
293
|
-
cartId: state.cart.id,
|
|
294
|
-
lines,
|
|
295
|
-
numCartLines,
|
|
296
|
-
country: countryCode,
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
|
-
if (error) {
|
|
300
|
-
dispatch({
|
|
301
|
-
type: 'reject',
|
|
302
|
-
error,
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartLinesRemove) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
306
|
-
ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.REMOVE_FROM_CART, true, {
|
|
307
|
-
removedCartLines: lines,
|
|
308
|
-
cart: data.cartLinesRemove.cart,
|
|
309
|
-
});
|
|
310
|
-
dispatch({
|
|
311
|
-
type: 'resolve',
|
|
312
|
-
cart: cartFromGraphQL(data.cartLinesRemove.cart),
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}, [onLineRemove, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
317
|
-
const updateLineItem = (0, react_1.useCallback)(async (lines, state) => {
|
|
318
|
-
var _a;
|
|
319
|
-
if (state.status === 'idle') {
|
|
320
|
-
dispatch({ type: 'updateLineItem', lines });
|
|
321
|
-
onLineUpdate === null || onLineUpdate === void 0 ? void 0 : onLineUpdate();
|
|
322
|
-
const { data, error } = await fetchCart({
|
|
323
|
-
query: (0, cart_queries_1.CartLineUpdate)(cartFragment),
|
|
324
|
-
variables: {
|
|
325
|
-
cartId: state.cart.id,
|
|
326
|
-
lines,
|
|
327
|
-
numCartLines,
|
|
328
|
-
country: countryCode,
|
|
329
|
-
},
|
|
330
|
-
});
|
|
331
|
-
if (error) {
|
|
332
|
-
dispatch({
|
|
333
|
-
type: 'reject',
|
|
334
|
-
error,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartLinesUpdate) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
338
|
-
ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.UPDATE_CART, true, {
|
|
339
|
-
updatedCartLines: lines,
|
|
340
|
-
oldCart: state.cart,
|
|
341
|
-
});
|
|
342
|
-
dispatch({
|
|
343
|
-
type: 'resolve',
|
|
344
|
-
cart: cartFromGraphQL(data.cartLinesUpdate.cart),
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}, [onLineUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
349
|
-
const noteUpdate = (0, react_1.useCallback)(async (note, state) => {
|
|
350
|
-
var _a;
|
|
351
|
-
if (state.status === 'idle') {
|
|
352
|
-
dispatch({ type: 'noteUpdate' });
|
|
353
|
-
onNoteUpdate === null || onNoteUpdate === void 0 ? void 0 : onNoteUpdate();
|
|
354
|
-
const { data, error } = await fetchCart({
|
|
355
|
-
query: (0, cart_queries_1.CartNoteUpdate)(cartFragment),
|
|
356
|
-
variables: {
|
|
357
|
-
cartId: state.cart.id,
|
|
358
|
-
note,
|
|
359
|
-
numCartLines,
|
|
360
|
-
country: countryCode,
|
|
361
|
-
},
|
|
362
|
-
});
|
|
363
|
-
if (error) {
|
|
364
|
-
dispatch({
|
|
365
|
-
type: 'reject',
|
|
366
|
-
error,
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartNoteUpdate) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
370
|
-
dispatch({
|
|
371
|
-
type: 'resolve',
|
|
372
|
-
cart: cartFromGraphQL(data.cartNoteUpdate.cart),
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}, [onNoteUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
377
|
-
const buyerIdentityUpdate = (0, react_1.useCallback)(async (buyerIdentity, state) => {
|
|
378
|
-
var _a;
|
|
379
|
-
if (state.status === 'idle') {
|
|
380
|
-
dispatch({ type: 'buyerIdentityUpdate' });
|
|
381
|
-
onBuyerIdentityUpdate === null || onBuyerIdentityUpdate === void 0 ? void 0 : onBuyerIdentityUpdate();
|
|
382
|
-
const { data, error } = await fetchCart({
|
|
383
|
-
query: (0, cart_queries_1.CartBuyerIdentityUpdate)(cartFragment),
|
|
384
|
-
variables: {
|
|
385
|
-
cartId: state.cart.id,
|
|
386
|
-
buyerIdentity,
|
|
387
|
-
numCartLines,
|
|
388
|
-
country: countryCode,
|
|
389
|
-
},
|
|
390
|
-
});
|
|
391
|
-
if (error) {
|
|
392
|
-
dispatch({
|
|
393
|
-
type: 'reject',
|
|
394
|
-
error,
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartBuyerIdentityUpdate) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
398
|
-
dispatch({
|
|
399
|
-
type: 'resolve',
|
|
400
|
-
cart: cartFromGraphQL(data.cartBuyerIdentityUpdate.cart),
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}, [onBuyerIdentityUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
405
|
-
const cartAttributesUpdate = (0, react_1.useCallback)(async (attributes, state) => {
|
|
406
|
-
var _a;
|
|
407
|
-
if (state.status === 'idle') {
|
|
408
|
-
dispatch({ type: 'cartAttributesUpdate' });
|
|
409
|
-
onAttributesUpdate === null || onAttributesUpdate === void 0 ? void 0 : onAttributesUpdate();
|
|
410
|
-
const { data, error } = await fetchCart({
|
|
411
|
-
query: (0, cart_queries_1.CartAttributesUpdate)(cartFragment),
|
|
412
|
-
variables: {
|
|
413
|
-
cartId: state.cart.id,
|
|
414
|
-
attributes,
|
|
415
|
-
numCartLines,
|
|
416
|
-
country: countryCode,
|
|
417
|
-
},
|
|
418
|
-
});
|
|
419
|
-
if (error) {
|
|
420
|
-
dispatch({
|
|
421
|
-
type: 'reject',
|
|
422
|
-
error,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartAttributesUpdate) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
426
|
-
dispatch({
|
|
427
|
-
type: 'resolve',
|
|
428
|
-
cart: cartFromGraphQL(data.cartAttributesUpdate.cart),
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}, [onAttributesUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
433
|
-
const discountCodesUpdate = (0, react_1.useCallback)(async (discountCodes, state) => {
|
|
434
|
-
var _a;
|
|
435
|
-
if (state.status === 'idle') {
|
|
436
|
-
dispatch({ type: 'discountCodesUpdate' });
|
|
437
|
-
onDiscountCodesUpdate === null || onDiscountCodesUpdate === void 0 ? void 0 : onDiscountCodesUpdate();
|
|
438
|
-
const { data, error } = await fetchCart({
|
|
439
|
-
query: (0, cart_queries_1.CartDiscountCodesUpdate)(cartFragment),
|
|
440
|
-
variables: {
|
|
441
|
-
cartId: state.cart.id,
|
|
442
|
-
discountCodes,
|
|
443
|
-
numCartLines,
|
|
444
|
-
country: countryCode,
|
|
445
|
-
},
|
|
446
|
-
});
|
|
447
|
-
if (error) {
|
|
448
|
-
dispatch({
|
|
449
|
-
type: 'reject',
|
|
450
|
-
error,
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.cartDiscountCodesUpdate) === null || _a === void 0 ? void 0 : _a.cart) {
|
|
454
|
-
ClientAnalytics_1.ClientAnalytics.publish(ClientAnalytics_1.ClientAnalytics.eventNames.DISCOUNT_CODE_UPDATED, true, {
|
|
455
|
-
updatedDiscountCodes: discountCodes,
|
|
456
|
-
cart: data.cartDiscountCodesUpdate.cart,
|
|
457
|
-
});
|
|
458
|
-
dispatch({
|
|
459
|
-
type: 'resolve',
|
|
460
|
-
cart: cartFromGraphQL(data.cartDiscountCodesUpdate.cart),
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}, [onDiscountCodesUpdate, fetchCart, cartFragment, numCartLines, countryCode]);
|
|
465
|
-
const didFetchCart = (0, react_1.useRef)(false);
|
|
466
|
-
(0, react_1.useEffect)(() => {
|
|
467
|
-
if (localStorage.getItem(constants_1.CART_ID_STORAGE_KEY) &&
|
|
468
|
-
state.status === 'uninitialized' &&
|
|
469
|
-
!didFetchCart.current) {
|
|
470
|
-
didFetchCart.current = true;
|
|
471
|
-
cartFetch(localStorage.getItem(constants_1.CART_ID_STORAGE_KEY));
|
|
472
|
-
}
|
|
473
|
-
}, [cartFetch, state]);
|
|
474
|
-
(0, react_1.useEffect)(() => {
|
|
475
|
-
if (state.status !== 'idle') {
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
buyerIdentityUpdate({ countryCode, customerAccessToken }, state);
|
|
479
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
480
|
-
}, [countryCode, customerAccessToken]);
|
|
481
|
-
const cartContextValue = (0, react_1.useMemo)(() => {
|
|
482
|
-
return {
|
|
483
|
-
...('cart' in state
|
|
484
|
-
? state.cart
|
|
485
|
-
: {
|
|
486
|
-
lines: [],
|
|
487
|
-
attributes: [],
|
|
488
|
-
...(cart ? cartFromGraphQL(cart) : {}),
|
|
489
|
-
}),
|
|
490
|
-
status: state.status,
|
|
491
|
-
error: 'error' in state ? state.error : undefined,
|
|
492
|
-
totalQuantity: 'cart' in state
|
|
493
|
-
? state.cart.lines.reduce((previous, current) => {
|
|
494
|
-
return previous + current.quantity;
|
|
495
|
-
}, 0)
|
|
496
|
-
: 0,
|
|
497
|
-
cartCreate,
|
|
498
|
-
linesAdd(lines) {
|
|
499
|
-
if ('cart' in state && state.cart.id) {
|
|
500
|
-
addLineItem(lines, state);
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
cartCreate({ lines });
|
|
504
|
-
}
|
|
505
|
-
},
|
|
506
|
-
linesRemove(lines) {
|
|
507
|
-
removeLineItem(lines, state);
|
|
508
|
-
},
|
|
509
|
-
linesUpdate(lines) {
|
|
510
|
-
updateLineItem(lines, state);
|
|
511
|
-
},
|
|
512
|
-
noteUpdate(note) {
|
|
513
|
-
noteUpdate(note, state);
|
|
514
|
-
},
|
|
515
|
-
buyerIdentityUpdate(buyerIdentity) {
|
|
516
|
-
buyerIdentityUpdate(buyerIdentity, state);
|
|
517
|
-
},
|
|
518
|
-
cartAttributesUpdate(attributes) {
|
|
519
|
-
cartAttributesUpdate(attributes, state);
|
|
520
|
-
},
|
|
521
|
-
discountCodesUpdate(discountCodes) {
|
|
522
|
-
discountCodesUpdate(discountCodes, state);
|
|
523
|
-
},
|
|
524
|
-
cartFragment,
|
|
525
|
-
};
|
|
526
|
-
}, [
|
|
527
|
-
state,
|
|
528
|
-
cart,
|
|
529
|
-
cartCreate,
|
|
530
|
-
cartFragment,
|
|
531
|
-
addLineItem,
|
|
532
|
-
removeLineItem,
|
|
533
|
-
updateLineItem,
|
|
534
|
-
noteUpdate,
|
|
535
|
-
buyerIdentityUpdate,
|
|
536
|
-
cartAttributesUpdate,
|
|
537
|
-
discountCodesUpdate,
|
|
538
|
-
]);
|
|
539
|
-
return (react_1.default.createElement(context_1.CartContext.Provider, { value: cartContextValue }, children));
|
|
540
|
-
}
|
|
541
|
-
exports.CartProvider = CartProvider;
|
|
542
|
-
function cartFromGraphQL(cart) {
|
|
543
|
-
var _a;
|
|
544
|
-
return {
|
|
545
|
-
...cart,
|
|
546
|
-
// @ts-expect-error While the cart still uses fragments, there will be a TS error here until we remove those fragments and get the type in-line
|
|
547
|
-
lines: (0, flattenConnection_1.flattenConnection)(cart.lines),
|
|
548
|
-
note: (_a = cart.note) !== null && _a !== void 0 ? _a : undefined,
|
|
549
|
-
};
|
|
550
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const CartLineAdd: (cartFragment: string) => string;
|
|
2
|
-
export declare const CartCreate: (cartFragment: string) => string;
|
|
3
|
-
export declare const CartLineRemove: (cartFragment: string) => string;
|
|
4
|
-
export declare const CartLineUpdate: (cartFragment: string) => string;
|
|
5
|
-
export declare const CartNoteUpdate: (cartFragment: string) => string;
|
|
6
|
-
export declare const CartBuyerIdentityUpdate: (cartFragment: string) => string;
|
|
7
|
-
export declare const CartAttributesUpdate: (cartFragment: string) => string;
|
|
8
|
-
export declare const CartDiscountCodesUpdate: (cartFragment: string) => string;
|
|
9
|
-
export declare const CartQuery: (cartFragment: string) => string;
|
|
10
|
-
export declare const defaultCartFragment = "\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|