@shopify/hydrogen 0.22.0 → 0.24.0
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 +240 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +5 -5
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +5 -8
- package/dist/esnext/components/CartLineProvider/context.d.ts +12 -2
- package/dist/esnext/components/CartLines/{CartLines.d.ts → CartLines.client.d.ts} +0 -0
- package/dist/esnext/components/CartLines/{CartLines.js → CartLines.client.js} +0 -0
- package/dist/esnext/components/CartLines/index.d.ts +1 -1
- package/dist/esnext/components/CartLines/index.js +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +2 -5
- 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 +3 -5
- package/dist/esnext/components/CartProvider/types.d.ts +2 -0
- package/dist/esnext/components/DevTools.client.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +8 -0
- package/dist/esnext/components/Image/Image.js +58 -10
- package/dist/esnext/components/Link/Link.client.d.ts +2 -0
- package/dist/esnext/components/Link/Link.client.js +7 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +1 -1
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +141 -0
- package/dist/esnext/components/ProductOptionsProvider/context.d.ts +2 -0
- package/dist/esnext/components/{ProductProvider → ProductOptionsProvider}/context.js +0 -1
- package/dist/esnext/components/ProductOptionsProvider/index.d.ts +2 -0
- package/dist/esnext/components/ProductOptionsProvider/index.js +2 -0
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +5 -2
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +10 -12
- package/dist/esnext/components/index.d.ts +1 -1
- package/dist/esnext/components/index.js +1 -1
- package/dist/esnext/entry-client.js +106 -6
- package/dist/esnext/entry-server.d.ts +2 -15
- package/dist/esnext/entry-server.js +246 -322
- package/dist/esnext/foundation/Analytics/Analytics.client.js +15 -13
- package/dist/esnext/foundation/Analytics/Analytics.server.js +27 -20
- package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +4 -2
- package/dist/esnext/foundation/Analytics/ClientAnalytics.js +16 -14
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.d.ts +1 -0
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/{PerformanceMetrics.server.js → ServerAnalyticsConnector.server.js} +7 -6
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.d.ts +1 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.js +19 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.client.js +190 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.js +24 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/const.d.ts +28 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/const.js +51 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.js +56 -0
- package/dist/esnext/foundation/Analytics/hook.js +4 -2
- package/dist/esnext/foundation/Analytics/utils.d.ts +2 -0
- package/dist/esnext/foundation/Analytics/utils.js +21 -0
- package/dist/{node/framework → esnext/foundation/Cache}/cache-sub-request.d.ts +1 -1
- package/dist/esnext/{framework → foundation/Cache}/cache-sub-request.js +3 -3
- package/dist/esnext/{framework → foundation/Cache}/cache.d.ts +1 -1
- package/dist/esnext/{framework → foundation/Cache}/cache.js +3 -3
- package/dist/{node/framework/CachingStrategy → esnext/foundation/Cache/strategies}/index.d.ts +2 -1
- package/dist/esnext/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +1 -1
- package/dist/esnext/foundation/Cookie/Cookie.d.ts +3 -3
- package/dist/{node/framework/Hydration → esnext/foundation/Html}/Html.d.ts +3 -1
- package/dist/esnext/{framework/Hydration → foundation/Html}/Html.js +15 -2
- package/dist/{node/framework/Hydration/ServerComponentRequest.server.d.ts → esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +8 -3
- package/dist/esnext/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +3 -2
- package/dist/{node/framework/Hydration/ServerComponentResponse.server.d.ts → esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +7 -10
- package/dist/esnext/{framework/Hydration/ServerComponentResponse.server.js → foundation/HydrogenResponse/HydrogenResponse.server.js} +19 -15
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +16 -9
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +5 -6
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -21
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.d.ts +1 -1
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +1 -1
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +1 -0
- package/dist/esnext/foundation/index.d.ts +1 -1
- package/dist/esnext/foundation/index.js +1 -1
- package/dist/esnext/foundation/runtime.d.ts +2 -0
- package/dist/esnext/foundation/runtime.js +6 -0
- package/dist/esnext/foundation/session/session.d.ts +3 -3
- package/dist/esnext/foundation/ssr-interop.d.ts +2 -2
- package/dist/esnext/foundation/useNavigate/useNavigate.d.ts +2 -0
- package/dist/esnext/foundation/useNavigate/useNavigate.js +11 -4
- package/dist/esnext/foundation/useQuery/hooks.d.ts +1 -0
- package/dist/esnext/foundation/useQuery/hooks.js +24 -7
- package/dist/esnext/foundation/useRequestContext/index.d.ts +15 -0
- package/dist/esnext/foundation/useRequestContext/index.js +23 -0
- package/dist/esnext/framework/Hydration/rsc.js +2 -0
- package/dist/esnext/framework/plugin.js +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +5 -2
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +4 -12
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +19 -0
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +12 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -2
- package/dist/esnext/hooks/useProductOptions/types.d.ts +17 -15
- package/dist/esnext/hooks/useProductOptions/useProductOptions.client.d.ts +1 -15
- package/dist/esnext/hooks/useProductOptions/useProductOptions.client.js +8 -107
- package/dist/esnext/hooks/useShopQuery/hooks.js +12 -6
- package/dist/esnext/index.d.ts +9 -3
- package/dist/esnext/index.js +7 -3
- package/dist/esnext/storefront-api-types.d.ts +10 -339
- package/dist/esnext/streaming.server.d.ts +0 -1
- package/dist/esnext/streaming.server.js +0 -4
- package/dist/esnext/types.d.ts +32 -23
- package/dist/esnext/utilities/apiRoutes.d.ts +2 -2
- package/dist/esnext/utilities/graphql-tracker.js +1 -1
- package/dist/esnext/utilities/index.d.ts +1 -1
- package/dist/esnext/utilities/index.js +1 -1
- package/dist/esnext/utilities/isBrowser/index.d.ts +1 -0
- package/dist/esnext/utilities/isBrowser/index.js +1 -0
- package/dist/esnext/utilities/isBrowser/isBrowser.d.ts +4 -0
- package/dist/esnext/utilities/isBrowser/isBrowser.js +6 -0
- package/dist/esnext/utilities/isServer/isServer.js +2 -2
- package/dist/esnext/utilities/log/index.d.ts +1 -1
- package/dist/esnext/utilities/log/index.js +1 -1
- package/dist/esnext/utilities/log/log-cache-header.d.ts +4 -4
- package/dist/esnext/utilities/log/log-query-timeline.d.ts +3 -3
- package/dist/esnext/utilities/log/log.d.ts +17 -11
- package/dist/esnext/utilities/log/log.js +29 -20
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/client.d.ts +16 -0
- package/dist/node/client.js +43 -0
- package/dist/node/components/AddToCartButton/AddToCartButton.client.d.ts +23 -0
- package/dist/node/components/AddToCartButton/AddToCartButton.client.js +74 -0
- package/dist/node/components/AddToCartButton/index.d.ts +1 -0
- package/dist/node/components/AddToCartButton/index.js +5 -0
- package/dist/node/components/BuyNowButton/BuyNowButton.client.d.ts +18 -0
- package/dist/node/components/BuyNowButton/BuyNowButton.client.js +53 -0
- package/dist/node/components/BuyNowButton/index.d.ts +1 -0
- package/dist/node/components/BuyNowButton/index.js +5 -0
- package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +11 -0
- package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.js +44 -0
- package/dist/node/components/CartCheckoutButton/index.d.ts +1 -0
- package/dist/node/components/CartCheckoutButton/index.js +5 -0
- package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +14 -0
- package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.js +36 -0
- package/dist/node/components/CartEstimatedCost/index.d.ts +1 -0
- package/dist/node/components/CartEstimatedCost/index.js +5 -0
- package/dist/node/components/CartLineImage/CartLineImage.client.d.ts +9 -0
- package/dist/node/components/CartLineImage/CartLineImage.client.js +18 -0
- package/dist/node/components/CartLineImage/index.d.ts +1 -0
- package/dist/node/components/CartLineImage/index.js +5 -0
- package/dist/node/components/CartLinePrice/CartLinePrice.client.d.ts +12 -0
- package/dist/node/components/CartLinePrice/CartLinePrice.client.js +25 -0
- package/dist/node/components/CartLinePrice/index.d.ts +1 -0
- package/dist/node/components/CartLinePrice/index.js +5 -0
- package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +8 -0
- package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.js +19 -0
- package/dist/node/components/CartLineProductTitle/index.d.ts +1 -0
- package/dist/node/components/CartLineProductTitle/index.js +5 -0
- package/dist/node/components/CartLineProvider/CartLineProvider.client.d.ts +11 -0
- package/dist/node/components/CartLineProvider/CartLineProvider.client.js +15 -0
- package/dist/node/components/CartLineProvider/context.d.ts +36 -0
- package/dist/node/components/CartLineProvider/context.js +5 -0
- package/dist/node/components/CartLineProvider/index.d.ts +2 -0
- package/dist/node/components/CartLineProvider/index.js +7 -0
- package/dist/node/components/CartLineQuantity/CartLineQuantity.client.d.ts +8 -0
- package/dist/node/components/CartLineQuantity/CartLineQuantity.client.js +19 -0
- package/dist/node/components/CartLineQuantity/index.d.ts +1 -0
- package/dist/node/components/CartLineQuantity/index.js +5 -0
- package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +14 -0
- package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +31 -0
- package/dist/node/components/CartLineQuantityAdjustButton/index.d.ts +1 -0
- package/dist/node/components/CartLineQuantityAdjustButton/index.js +5 -0
- package/dist/node/components/CartLines/CartLines.client.d.ts +15 -0
- package/dist/node/components/CartLines/CartLines.client.js +44 -0
- package/dist/node/components/CartLines/index.d.ts +1 -0
- package/dist/node/components/CartLines/index.js +5 -0
- package/dist/node/components/CartProvider/CartProvider.client.d.ts +41 -0
- package/dist/node/components/CartProvider/CartProvider.client.js +547 -0
- package/dist/node/components/CartProvider/cart-queries.d.ts +10 -0
- package/dist/node/components/CartProvider/cart-queries.js +214 -0
- package/dist/node/components/CartProvider/constants.d.ts +2 -0
- package/dist/node/components/CartProvider/constants.js +5 -0
- package/dist/node/components/CartProvider/context.d.ts +2 -0
- package/dist/node/components/CartProvider/context.js +5 -0
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.d.ts +95 -0
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartFragment.d.ts +82 -0
- package/dist/node/components/CartProvider/graphql/CartFragment.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +96 -0
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartQuery.d.ts +91 -0
- package/dist/node/components/CartProvider/graphql/CartQuery.js +2 -0
- package/dist/node/components/CartProvider/hooks.client.d.ts +15 -0
- package/dist/node/components/CartProvider/hooks.client.js +88 -0
- package/dist/node/components/CartProvider/index.d.ts +4 -0
- package/dist/node/components/CartProvider/index.js +10 -0
- package/dist/node/components/CartProvider/types.d.ts +104 -0
- package/dist/node/components/CartProvider/types.js +2 -0
- package/dist/node/components/CartShopPayButton/CartShopPayButton.client.d.ts +9 -0
- package/dist/node/components/CartShopPayButton/CartShopPayButton.client.js +46 -0
- package/dist/node/components/CartShopPayButton/index.d.ts +1 -0
- package/dist/node/components/CartShopPayButton/index.js +5 -0
- package/dist/node/components/ExternalVideo/ExternalVideo.d.ts +21 -0
- package/dist/node/components/ExternalVideo/ExternalVideo.js +21 -0
- package/dist/node/components/ExternalVideo/index.d.ts +1 -0
- package/dist/node/components/ExternalVideo/index.js +5 -0
- package/dist/node/components/Image/Image.d.ts +8 -0
- package/dist/node/components/Image/Image.js +57 -9
- package/dist/node/components/Link/Link.client.d.ts +25 -0
- package/dist/node/components/Link/Link.client.js +165 -0
- package/dist/node/components/Link/index.d.ts +1 -0
- package/dist/node/components/Link/index.js +5 -0
- package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +6 -0
- package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.js +11 -0
- package/dist/node/components/LocalizationProvider/LocalizationContext.client.d.ts +6 -0
- package/dist/node/components/LocalizationProvider/LocalizationContext.client.js +5 -0
- package/dist/node/components/LocalizationProvider/LocalizationProvider.server.d.ts +33 -0
- package/dist/node/components/LocalizationProvider/LocalizationProvider.server.js +51 -0
- package/dist/node/components/MediaFile/MediaFile.d.ts +19 -0
- package/dist/node/components/MediaFile/MediaFile.js +39 -0
- package/dist/node/components/MediaFile/index.d.ts +1 -0
- package/dist/node/components/MediaFile/index.js +5 -0
- package/dist/node/components/Metafield/Metafield.client.d.ts +21 -0
- package/dist/node/components/Metafield/Metafield.client.js +75 -0
- package/dist/node/components/Metafield/index.d.ts +2 -0
- package/dist/node/components/Metafield/index.js +5 -0
- package/dist/node/components/Metafield/types.d.ts +4 -0
- package/dist/node/components/Metafield/types.js +2 -0
- package/dist/node/components/ModelViewer/ModelViewer.client.d.ts +128 -0
- package/dist/node/components/ModelViewer/ModelViewer.client.js +132 -0
- package/dist/node/components/ModelViewer/index.d.ts +1 -0
- package/dist/node/components/ModelViewer/index.js +5 -0
- package/dist/node/components/Money/Money.client.d.ts +25 -0
- package/dist/node/components/Money/Money.client.js +46 -0
- package/dist/node/components/Money/index.d.ts +1 -0
- package/dist/node/components/Money/index.js +5 -0
- package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
- package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.js +168 -0
- package/dist/node/components/ProductOptionsProvider/context.d.ts +2 -0
- package/dist/node/components/ProductOptionsProvider/context.js +5 -0
- package/dist/node/components/ProductOptionsProvider/index.d.ts +2 -0
- package/dist/node/components/ProductOptionsProvider/index.js +7 -0
- package/dist/node/components/ProductPrice/ProductPrice.client.d.ts +18 -0
- package/dist/node/components/ProductPrice/ProductPrice.client.js +61 -0
- package/dist/node/components/ProductPrice/index.d.ts +1 -0
- package/dist/node/components/ProductPrice/index.js +5 -0
- package/dist/node/components/Seo/CollectionSeo.client.d.ts +3 -0
- package/dist/node/components/Seo/CollectionSeo.client.js +22 -0
- package/dist/node/components/Seo/DefaultPageSeo.client.d.ts +3 -0
- package/dist/node/components/Seo/DefaultPageSeo.client.js +25 -0
- package/dist/node/components/Seo/DescriptionSeo.client.d.ts +4 -0
- package/dist/node/components/Seo/DescriptionSeo.client.js +17 -0
- package/dist/node/components/Seo/HomePageSeo.client.d.ts +2 -0
- package/dist/node/components/Seo/HomePageSeo.client.js +32 -0
- package/dist/node/components/Seo/ImageSeo.client.d.ts +3 -0
- package/dist/node/components/Seo/ImageSeo.client.js +17 -0
- package/dist/node/components/Seo/NoIndexSeo.client.d.ts +3 -0
- package/dist/node/components/Seo/NoIndexSeo.client.js +17 -0
- package/dist/node/components/Seo/PageSeo.client.d.ts +3 -0
- package/dist/node/components/Seo/PageSeo.client.js +20 -0
- package/dist/node/components/Seo/ProductSeo.client.d.ts +5 -0
- package/dist/node/components/Seo/ProductSeo.client.js +70 -0
- package/dist/node/components/Seo/Seo.client.d.ts +30 -0
- package/dist/node/components/Seo/Seo.client.js +38 -0
- package/dist/node/components/Seo/TitleSeo.client.d.ts +3 -0
- package/dist/node/components/Seo/TitleSeo.client.js +17 -0
- package/dist/node/components/Seo/TwitterSeo.client.d.ts +2 -0
- package/dist/node/components/Seo/TwitterSeo.client.js +16 -0
- package/dist/node/components/Seo/index.d.ts +1 -0
- package/dist/node/components/Seo/index.js +5 -0
- package/dist/node/components/Seo/seo-types.d.ts +17 -0
- package/dist/node/components/Seo/seo-types.js +2 -0
- package/dist/node/components/ShopPayButton/ShopPayButton.client.d.ts +38 -0
- package/dist/node/components/ShopPayButton/ShopPayButton.client.js +60 -0
- package/dist/node/components/ShopPayButton/index.d.ts +1 -0
- package/dist/node/components/ShopPayButton/index.js +5 -0
- package/dist/node/components/Video/Video.d.ts +14 -0
- package/dist/node/components/Video/Video.js +31 -0
- package/dist/node/components/Video/index.d.ts +1 -0
- package/dist/node/components/Video/index.js +5 -0
- package/dist/node/components/index.d.ts +28 -0
- package/dist/node/components/index.js +59 -0
- package/dist/node/components/types.d.ts +71 -0
- package/dist/node/components/types.js +11 -0
- package/dist/node/entry-server.d.ts +2 -15
- package/dist/node/entry-server.js +245 -321
- package/dist/node/foundation/Analytics/Analytics.client.js +15 -13
- package/dist/node/foundation/Analytics/Analytics.server.js +27 -20
- package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +4 -2
- package/dist/node/foundation/Analytics/ClientAnalytics.js +15 -13
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.d.ts +7 -0
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +68 -0
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.d.ts +1 -0
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +27 -0
- package/dist/node/foundation/Analytics/hook.js +4 -2
- package/dist/node/foundation/Analytics/index.d.ts +1 -0
- package/dist/node/foundation/Analytics/index.js +5 -0
- package/dist/node/foundation/Analytics/utils.d.ts +2 -0
- package/dist/node/foundation/Analytics/utils.js +24 -1
- package/dist/{esnext/framework → node/foundation/Cache}/cache-sub-request.d.ts +1 -1
- package/dist/node/{framework → foundation/Cache}/cache-sub-request.js +4 -4
- package/dist/node/{framework → foundation/Cache}/cache.d.ts +1 -1
- package/dist/node/{framework → foundation/Cache}/cache.js +5 -5
- package/dist/{esnext/framework/CachingStrategy → node/foundation/Cache/strategies}/index.d.ts +2 -1
- package/dist/node/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +3 -3
- package/dist/node/foundation/Head/Head.client.d.ts +5 -0
- package/dist/node/foundation/Head/Head.client.js +17 -0
- package/dist/node/foundation/Head/index.d.ts +1 -0
- package/dist/node/foundation/Head/index.js +5 -0
- package/dist/{esnext/framework/Hydration → node/foundation/Html}/Html.d.ts +3 -1
- package/dist/node/{framework/Hydration → foundation/Html}/Html.js +15 -2
- package/dist/{esnext/framework/Hydration/ServerComponentRequest.server.d.ts → node/foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +8 -3
- package/dist/node/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +5 -4
- package/dist/{esnext/framework/Hydration/ServerComponentResponse.server.d.ts → node/foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +7 -10
- package/dist/node/{framework/Hydration/ServerComponentResponse.server.js → foundation/HydrogenResponse/HydrogenResponse.server.js} +23 -19
- package/dist/node/foundation/Router/BrowserRouter.client.js +16 -9
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +5 -6
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -21
- package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +7 -0
- package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.js +35 -0
- package/dist/node/foundation/ShopifyProvider/index.d.ts +1 -0
- package/dist/node/foundation/ShopifyProvider/index.js +5 -0
- package/dist/node/foundation/fetchSync/client/fetchSync.d.ts +10 -0
- package/dist/node/foundation/fetchSync/client/fetchSync.js +33 -0
- package/dist/node/foundation/fetchSync/server/fetchSync.d.ts +8 -0
- package/dist/node/foundation/fetchSync/server/fetchSync.js +33 -0
- package/dist/node/foundation/fetchSync/types.d.ts +5 -0
- package/dist/node/foundation/fetchSync/types.js +2 -0
- package/dist/node/foundation/index.d.ts +3 -0
- package/dist/node/foundation/index.js +10 -0
- package/dist/node/foundation/runtime.d.ts +2 -0
- package/dist/node/foundation/runtime.js +11 -0
- package/dist/node/foundation/session/session.d.ts +3 -3
- package/dist/node/foundation/ssr-interop.d.ts +2 -2
- package/dist/node/foundation/useNavigate/useNavigate.d.ts +2 -0
- package/dist/node/foundation/useNavigate/useNavigate.js +11 -4
- package/dist/node/foundation/useQuery/hooks.d.ts +37 -0
- package/dist/node/foundation/useQuery/hooks.js +119 -0
- package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.d.ts +10 -0
- package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.js +34 -0
- package/dist/node/foundation/useRouteParams/useRouteParams.d.ts +4 -0
- package/dist/node/foundation/useRouteParams/useRouteParams.js +13 -0
- package/dist/node/foundation/useServerProps/index.d.ts +1 -0
- package/dist/node/foundation/useServerProps/index.js +5 -0
- package/dist/node/foundation/useSession/useSession.d.ts +2 -0
- package/dist/node/foundation/useSession/useSession.js +12 -0
- package/dist/node/foundation/useShop/index.d.ts +1 -0
- package/dist/node/foundation/useShop/index.js +5 -0
- package/dist/node/foundation/useShop/use-shop.d.ts +6 -0
- package/dist/node/foundation/useShop/use-shop.js +18 -0
- package/dist/node/foundation/useUrl/index.d.ts +1 -0
- package/dist/node/foundation/useUrl/index.js +5 -0
- package/dist/node/foundation/useUrl/useUrl.d.ts +4 -0
- package/dist/node/foundation/useUrl/useUrl.js +32 -0
- package/dist/node/framework/Hydration/rsc.js +2 -0
- package/dist/node/framework/plugin.js +2 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +5 -2
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +4 -12
- package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +21 -0
- package/dist/node/hooks/index.d.ts +6 -0
- package/dist/node/hooks/index.js +28 -0
- package/dist/node/hooks/useCart/index.d.ts +1 -0
- package/dist/node/hooks/useCart/index.js +5 -0
- package/dist/node/hooks/useCart/useCart.d.ts +4 -0
- package/dist/node/hooks/useCart/useCart.js +19 -0
- package/dist/node/hooks/useCartLine/index.d.ts +1 -0
- package/dist/node/hooks/useCartLine/index.js +5 -0
- package/dist/node/hooks/useCartLine/useCartLine.d.ts +39 -0
- package/dist/node/hooks/useCartLine/useCartLine.js +16 -0
- package/dist/node/hooks/useCountry/index.d.ts +1 -0
- package/dist/node/hooks/useCountry/index.js +5 -0
- package/dist/node/hooks/useCountry/useCountry.d.ts +7 -0
- package/dist/node/hooks/useCountry/useCountry.js +21 -0
- package/dist/node/hooks/useLoadScript/index.d.ts +1 -0
- package/dist/node/hooks/useLoadScript/index.js +5 -0
- package/dist/node/hooks/useLoadScript/useLoadScript.client.d.ts +8 -0
- package/dist/node/hooks/useLoadScript/useLoadScript.client.js +27 -0
- package/dist/node/hooks/useMeasurement/hooks.d.ts +9 -0
- package/dist/node/hooks/useMeasurement/hooks.js +17 -0
- package/dist/node/hooks/useMeasurement/index.d.ts +1 -0
- package/dist/node/hooks/useMeasurement/index.js +5 -0
- package/dist/node/hooks/useMoney/hooks.d.ts +54 -0
- package/dist/node/hooks/useMoney/hooks.js +70 -0
- package/dist/node/hooks/useMoney/index.d.ts +1 -0
- package/dist/node/hooks/useMoney/index.js +5 -0
- package/dist/node/hooks/useParsedMetafields/index.d.ts +1 -0
- package/dist/node/hooks/useParsedMetafields/index.js +5 -0
- package/dist/node/hooks/useParsedMetafields/useParsedMetafields.d.ts +21 -0
- package/dist/node/hooks/useParsedMetafields/useParsedMetafields.js +25 -0
- package/dist/node/hooks/useProductOptions/helpers.d.ts +6 -0
- package/dist/node/hooks/useProductOptions/helpers.js +46 -0
- package/dist/node/hooks/useProductOptions/index.d.ts +2 -0
- package/dist/node/hooks/useProductOptions/index.js +20 -0
- package/dist/node/hooks/useProductOptions/types.d.ts +44 -0
- package/dist/node/hooks/useProductOptions/types.js +2 -0
- package/dist/node/hooks/useProductOptions/useProductOptions.client.d.ts +1 -0
- package/dist/node/hooks/useProductOptions/useProductOptions.client.js +13 -0
- package/dist/node/hooks/useShopQuery/hooks.d.ts +28 -0
- package/dist/node/hooks/useShopQuery/hooks.js +171 -0
- package/dist/node/hooks/useShopQuery/index.d.ts +1 -0
- package/dist/node/hooks/useShopQuery/index.js +5 -0
- package/dist/node/storefront-api-types.d.ts +10 -339
- package/dist/node/streaming.server.d.ts +0 -1
- package/dist/node/streaming.server.js +1 -6
- package/dist/node/types.d.ts +32 -23
- package/dist/node/utilities/apiRoutes.d.ts +2 -2
- package/dist/node/utilities/devtools.d.ts +11 -0
- package/dist/node/utilities/devtools.js +15 -0
- package/dist/node/utilities/graphql-tag.d.ts +1 -0
- package/dist/node/utilities/graphql-tag.js +10 -0
- package/dist/node/utilities/graphql-tracker.d.ts +17 -0
- package/dist/node/utilities/graphql-tracker.js +130 -0
- package/dist/node/utilities/index.d.ts +1 -1
- package/dist/node/utilities/index.js +3 -3
- package/dist/node/utilities/isBrowser/index.d.ts +1 -0
- package/dist/node/utilities/isBrowser/index.js +5 -0
- package/dist/node/utilities/isBrowser/isBrowser.d.ts +4 -0
- package/dist/node/utilities/isBrowser/isBrowser.js +10 -0
- package/dist/node/utilities/isServer/isServer.js +2 -2
- package/dist/node/utilities/log/index.d.ts +1 -1
- package/dist/node/utilities/log/index.js +1 -3
- package/dist/node/utilities/log/log-cache-header.d.ts +4 -4
- package/dist/node/utilities/log/log-query-timeline.d.ts +3 -3
- package/dist/node/utilities/log/log.d.ts +17 -11
- package/dist/node/utilities/log/log.js +30 -23
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +4 -2
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +234 -53
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +77 -59
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +30 -30
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +199 -70
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +38 -35
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +9 -8
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +3 -3
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +3 -7
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +235 -54
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +77 -59
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +199 -70
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +9 -8
- package/vendor/react-server-dom-vite/package.json +1 -1
- package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.d.ts +0 -8
- package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.js +0 -12
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +0 -24
- package/dist/esnext/components/ProductProvider/ProductProvider.client.js +0 -34
- package/dist/esnext/components/ProductProvider/context.d.ts +0 -29
- package/dist/esnext/components/ProductProvider/index.d.ts +0 -2
- package/dist/esnext/components/ProductProvider/index.js +0 -2
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.d.ts +0 -1
- package/dist/esnext/framework/config.d.ts +0 -6
- package/dist/esnext/framework/config.js +0 -6
- package/dist/esnext/framework/runtime.d.ts +0 -13
- package/dist/esnext/framework/runtime.js +0 -27
- package/dist/esnext/hooks/useProduct/index.d.ts +0 -1
- package/dist/esnext/hooks/useProduct/index.js +0 -1
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +0 -52
- package/dist/esnext/hooks/useProduct/useProduct.js +0 -43
- package/dist/esnext/utilities/isClient/index.d.ts +0 -1
- package/dist/esnext/utilities/isClient/index.js +0 -1
- package/dist/esnext/utilities/isClient/isClient.d.ts +0 -4
- package/dist/esnext/utilities/isClient/isClient.js +0 -6
- package/dist/node/framework/config.d.ts +0 -6
- package/dist/node/framework/config.js +0 -11
- package/dist/node/framework/runtime.d.ts +0 -13
- package/dist/node/framework/runtime.js +0 -35
- package/dist/node/utilities/defer.d.ts +0 -6
- package/dist/node/utilities/defer.js +0 -18
- package/dist/node/utilities/isClient/index.d.ts +0 -1
- package/dist/node/utilities/isClient/index.js +0 -5
- package/dist/node/utilities/isClient/isClient.d.ts +0 -4
- package/dist/node/utilities/isClient/isClient.js +0 -10
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldPreloadQuery = exports.useQuery = void 0;
|
|
4
|
+
const log_1 = require("../../utilities/log");
|
|
5
|
+
const cache_sub_request_1 = require("../Cache/cache-sub-request");
|
|
6
|
+
const ServerRequestProvider_1 = require("../ServerRequestProvider");
|
|
7
|
+
const strategies_1 = require("../Cache/strategies");
|
|
8
|
+
/**
|
|
9
|
+
* The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
|
|
10
|
+
* supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
|
|
11
|
+
* hook to call any third-party APIs from a server component.
|
|
12
|
+
*
|
|
13
|
+
* \> Note:
|
|
14
|
+
* \> If you're making a simple fetch call on the server, then we recommend using the [`fetchSync`](https://shopify.dev/api/hydrogen/hooks/global/fetchsync) hook instead.
|
|
15
|
+
*/
|
|
16
|
+
function useQuery(
|
|
17
|
+
/** A string or array to uniquely identify the current query. */
|
|
18
|
+
key,
|
|
19
|
+
/** An asynchronous query function like `fetch` which returns data. */
|
|
20
|
+
queryFn,
|
|
21
|
+
/** The options to manage the cache behavior of the sub-request. */
|
|
22
|
+
queryOptions) {
|
|
23
|
+
const request = (0, ServerRequestProvider_1.useServerRequest)();
|
|
24
|
+
const withCacheIdKey = [
|
|
25
|
+
'__QUERY_CACHE_ID__',
|
|
26
|
+
...(typeof key === 'string' ? [key] : key),
|
|
27
|
+
];
|
|
28
|
+
const fetcher = cachedQueryFnBuilder(withCacheIdKey, queryFn, queryOptions);
|
|
29
|
+
(0, log_1.collectQueryTimings)(request, withCacheIdKey, 'requested');
|
|
30
|
+
if (shouldPreloadQuery(queryOptions)) {
|
|
31
|
+
request.savePreloadQuery({
|
|
32
|
+
preload: queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload,
|
|
33
|
+
key: withCacheIdKey,
|
|
34
|
+
fetcher,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return (0, ServerRequestProvider_1.useRequestCacheData)(withCacheIdKey, fetcher);
|
|
38
|
+
}
|
|
39
|
+
exports.useQuery = useQuery;
|
|
40
|
+
function shouldPreloadQuery(queryOptions) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if (!queryOptions)
|
|
43
|
+
return true;
|
|
44
|
+
const hasCacheOverride = typeof ((_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.cache) === null || _a === void 0 ? void 0 : _a.mode) !== 'undefined';
|
|
45
|
+
const hasPreloadOverride = typeof (queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload) !== 'undefined';
|
|
46
|
+
const cacheValue = (_b = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.cache) === null || _b === void 0 ? void 0 : _b.mode;
|
|
47
|
+
const preloadValue = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload;
|
|
48
|
+
// If preload is explicitly defined, then it takes precedence
|
|
49
|
+
if (hasPreloadOverride) {
|
|
50
|
+
return !!preloadValue;
|
|
51
|
+
}
|
|
52
|
+
return hasCacheOverride ? cacheValue !== strategies_1.NO_STORE : true;
|
|
53
|
+
}
|
|
54
|
+
exports.shouldPreloadQuery = shouldPreloadQuery;
|
|
55
|
+
function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
56
|
+
var _a;
|
|
57
|
+
const resolvedQueryOptions = {
|
|
58
|
+
...(queryOptions !== null && queryOptions !== void 0 ? queryOptions : {}),
|
|
59
|
+
};
|
|
60
|
+
const shouldCacheResponse = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.shouldCacheResponse) !== null && _a !== void 0 ? _a : (() => true);
|
|
61
|
+
/**
|
|
62
|
+
* Attempt to read the query from cache. If it doesn't exist or if it's stale, regenerate it.
|
|
63
|
+
*/
|
|
64
|
+
async function useCachedQueryFn() {
|
|
65
|
+
var _a, _b, _c, _d;
|
|
66
|
+
// Call this hook before running any async stuff
|
|
67
|
+
// to prevent losing the current React cycle.
|
|
68
|
+
const request = (0, ServerRequestProvider_1.useServerRequest)();
|
|
69
|
+
const log = (0, log_1.getLoggerWithContext)(request);
|
|
70
|
+
const cacheResponse = await (0, cache_sub_request_1.getItemFromCache)(key);
|
|
71
|
+
async function generateNewOutput() {
|
|
72
|
+
return await queryFn();
|
|
73
|
+
}
|
|
74
|
+
if (cacheResponse) {
|
|
75
|
+
const [output, response] = cacheResponse;
|
|
76
|
+
(0, log_1.collectQueryCacheControlHeaders)(request, key, response.headers.get('cache-control'));
|
|
77
|
+
/**
|
|
78
|
+
* Important: Do this async
|
|
79
|
+
*/
|
|
80
|
+
if ((0, cache_sub_request_1.isStale)(key, response)) {
|
|
81
|
+
const lockKey = ['lock', ...(typeof key === 'string' ? [key] : key)];
|
|
82
|
+
// Run revalidation asynchronously
|
|
83
|
+
const revalidatingPromise = (0, cache_sub_request_1.getItemFromCache)(lockKey).then(async (lockExists) => {
|
|
84
|
+
if (lockExists)
|
|
85
|
+
return;
|
|
86
|
+
await (0, cache_sub_request_1.setItemInCache)(lockKey, true, (0, strategies_1.CacheSeconds)({
|
|
87
|
+
maxAge: 10,
|
|
88
|
+
}));
|
|
89
|
+
try {
|
|
90
|
+
const output = await generateNewOutput();
|
|
91
|
+
if (shouldCacheResponse(output)) {
|
|
92
|
+
await (0, cache_sub_request_1.setItemInCache)(key, output, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
log.error(`Error generating async response: ${e.message}`);
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
await (0, cache_sub_request_1.deleteItemFromCache)(lockKey);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
// Asynchronously wait for it in workers
|
|
103
|
+
(_b = (_a = request.ctx.runtime) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.call(_a, revalidatingPromise);
|
|
104
|
+
}
|
|
105
|
+
return output;
|
|
106
|
+
}
|
|
107
|
+
const newOutput = await generateNewOutput();
|
|
108
|
+
/**
|
|
109
|
+
* Important: Do this async
|
|
110
|
+
*/
|
|
111
|
+
if (shouldCacheResponse(newOutput)) {
|
|
112
|
+
const setItemInCachePromise = (0, cache_sub_request_1.setItemInCache)(key, newOutput, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
|
|
113
|
+
(_d = (_c = request.ctx.runtime) === null || _c === void 0 ? void 0 : _c.waitUntil) === null || _d === void 0 ? void 0 : _d.call(_c, setItemInCachePromise);
|
|
114
|
+
}
|
|
115
|
+
(0, log_1.collectQueryCacheControlHeaders)(request, key, (0, cache_sub_request_1.generateSubRequestCacheControlHeader)(resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache));
|
|
116
|
+
return newOutput;
|
|
117
|
+
}
|
|
118
|
+
return useCachedQueryFn;
|
|
119
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
declare type RouteParamsContextValue = {
|
|
3
|
+
routeParams: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
export declare const RouteParamsContext: React.Context<RouteParamsContextValue>;
|
|
6
|
+
export declare const RouteParamsProvider: FC<{
|
|
7
|
+
routeParams: Record<string, string>;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
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.RouteParamsProvider = exports.RouteParamsContext = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
exports.RouteParamsContext = (0, react_1.createContext)({
|
|
29
|
+
routeParams: {},
|
|
30
|
+
});
|
|
31
|
+
const RouteParamsProvider = ({ children, routeParams }) => {
|
|
32
|
+
return (react_1.default.createElement(exports.RouteParamsContext.Provider, { value: { routeParams } }, children));
|
|
33
|
+
};
|
|
34
|
+
exports.RouteParamsProvider = RouteParamsProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRouteParams = void 0;
|
|
4
|
+
const ssr_interop_1 = require("../ssr-interop");
|
|
5
|
+
const RouteParamsProvider_client_1 = require("./RouteParamsProvider.client");
|
|
6
|
+
/**
|
|
7
|
+
* The `useRouteParams` hook retrieves the parameters of an active route. The hook is available in both server and client components.
|
|
8
|
+
*/
|
|
9
|
+
function useRouteParams() {
|
|
10
|
+
const router = (0, ssr_interop_1.useEnvContext)((req) => req.ctx.router, RouteParamsProvider_client_1.RouteParamsContext);
|
|
11
|
+
return router.routeParams;
|
|
12
|
+
}
|
|
13
|
+
exports.useRouteParams = useRouteParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useServerProps } from './use-server-props';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useServerProps = void 0;
|
|
4
|
+
var use_server_props_1 = require("./use-server-props");
|
|
5
|
+
Object.defineProperty(exports, "useServerProps", { enumerable: true, get: function () { return use_server_props_1.useServerProps; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSession = void 0;
|
|
4
|
+
const ServerRequestProvider_1 = require("../ServerRequestProvider");
|
|
5
|
+
/** The `useSession` hook reads session data in server components. */
|
|
6
|
+
const useSession = function () {
|
|
7
|
+
var _a;
|
|
8
|
+
const request = (0, ServerRequestProvider_1.useServerRequest)();
|
|
9
|
+
const session = ((_a = request.ctx.session) === null || _a === void 0 ? void 0 : _a.get()) || {};
|
|
10
|
+
return session;
|
|
11
|
+
};
|
|
12
|
+
exports.useSession = useSession;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useShop } from './use-shop';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `useShop` hook provides access to values within
|
|
3
|
+
* [the `shopify` property in the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
|
|
4
|
+
* The `useShop` hook must be a descendent of a `ShopifyProvider` component.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useShop(): import("../ShopifyProvider/types").ShopifyContextValue;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useShop = void 0;
|
|
4
|
+
const ShopifyProvider_1 = require("../ShopifyProvider");
|
|
5
|
+
const ssr_interop_1 = require("../ssr-interop");
|
|
6
|
+
/**
|
|
7
|
+
* The `useShop` hook provides access to values within
|
|
8
|
+
* [the `shopify` property in the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
|
|
9
|
+
* The `useShop` hook must be a descendent of a `ShopifyProvider` component.
|
|
10
|
+
*/
|
|
11
|
+
function useShop() {
|
|
12
|
+
const config = (0, ssr_interop_1.useEnvContext)((req) => req.ctx.shopifyConfig, ShopifyProvider_1.ShopifyContext);
|
|
13
|
+
if (!config) {
|
|
14
|
+
throw new Error('No Shopify Context found');
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
exports.useShop = useShop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useUrl } from './useUrl';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUrl = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const parse_1 = require("../../utilities/parse");
|
|
7
|
+
const BrowserRouter_client_1 = require("../Router/BrowserRouter.client");
|
|
8
|
+
const ssr_interop_1 = require("../ssr-interop");
|
|
9
|
+
/**
|
|
10
|
+
* The `useUrl` hook retrieves the current URL in a server or client component.
|
|
11
|
+
*/
|
|
12
|
+
function useUrl() {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
if (ssr_interop_1.META_ENV_SSR) {
|
|
15
|
+
const serverUrl = new URL((0, ssr_interop_1.useEnvContext)((req) => req.url) // eslint-disable-line react-hooks/rules-of-hooks
|
|
16
|
+
);
|
|
17
|
+
if (serverUrl.pathname === constants_1.RSC_PATHNAME) {
|
|
18
|
+
const state = (0, parse_1.parseJSON)(serverUrl.searchParams.get('state') || '{}');
|
|
19
|
+
const parsedUrl = `${serverUrl.origin}${(_a = state.pathname) !== null && _a !== void 0 ? _a : ''}${(_b = state.search) !== null && _b !== void 0 ? _b : ''}`;
|
|
20
|
+
return new URL(parsedUrl);
|
|
21
|
+
}
|
|
22
|
+
return new URL(serverUrl);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* We return a `URL` object instead of passing through `location` because
|
|
26
|
+
* the URL object contains important info like hostname, etc.
|
|
27
|
+
*/
|
|
28
|
+
const location = (0, BrowserRouter_client_1.useLocation)(); // eslint-disable-line react-hooks/rules-of-hooks
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
return (0, react_1.useMemo)(() => new URL(window.location.href), [location]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
31
|
+
}
|
|
32
|
+
exports.useUrl = useUrl;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.useRefresh = exports.useServerResponse = void 0;
|
|
6
6
|
const react_server_dom_vite_1 = require("@shopify/hydrogen/vendor/react-server-dom-vite");
|
|
7
|
+
const client_1 = require("../../client");
|
|
7
8
|
const constants_1 = require("../../constants");
|
|
8
9
|
let rscReader;
|
|
9
10
|
// Hydrate an SSR response from <meta> tags placed in the DOM.
|
|
@@ -89,6 +90,7 @@ function useServerResponse(state) {
|
|
|
89
90
|
/* @ts-ignore */
|
|
90
91
|
window.BOOMR.plugins.Hydrogen.trackSubPageLoadPerformance();
|
|
91
92
|
}
|
|
93
|
+
client_1.ClientAnalytics.resetPageAnalyticsData();
|
|
92
94
|
// Request a new flight response.
|
|
93
95
|
response = (0, react_server_dom_vite_1.createFromFetch)(fetch(`${constants_1.RSC_PATHNAME}?state=` + encodeURIComponent(key)));
|
|
94
96
|
}
|
|
@@ -16,6 +16,7 @@ const vite_plugin_inspect_1 = __importDefault(require("vite-plugin-inspect"));
|
|
|
16
16
|
const plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
|
|
17
17
|
const vite_plugin_css_modules_rsc_1 = __importDefault(require("./plugins/vite-plugin-css-modules-rsc"));
|
|
18
18
|
const vite_plugin_client_imports_1 = __importDefault(require("./plugins/vite-plugin-client-imports"));
|
|
19
|
+
const vite_plugin_hydrogen_suppress_warnings_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-suppress-warnings"));
|
|
19
20
|
exports.default = (pluginOptions = {}) => {
|
|
20
21
|
return [
|
|
21
22
|
process.env.VITE_INSPECT && (0, vite_plugin_inspect_1.default)(),
|
|
@@ -30,6 +31,7 @@ exports.default = (pluginOptions = {}) => {
|
|
|
30
31
|
(0, vite_plugin_css_modules_rsc_1.default)(),
|
|
31
32
|
(0, vite_plugin_hydrogen_rsc_1.default)(),
|
|
32
33
|
(0, vite_plugin_platform_entry_1.default)(),
|
|
34
|
+
(0, vite_plugin_hydrogen_suppress_warnings_1.default)(),
|
|
33
35
|
pluginOptions.purgeQueryCacheOnBuild && (0, vite_plugin_purge_query_cache_1.default)(),
|
|
34
36
|
];
|
|
35
37
|
};
|
|
@@ -84,11 +84,14 @@ exports.default = () => {
|
|
|
84
84
|
'react-server-dom-vite/client-proxy',
|
|
85
85
|
// https://github.com/vitejs/vite/issues/6215
|
|
86
86
|
'react/jsx-runtime',
|
|
87
|
+
// https://github.com/nfriedly/set-cookie-parser/issues/50
|
|
88
|
+
'set-cookie-parser',
|
|
87
89
|
],
|
|
88
90
|
},
|
|
89
91
|
define: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
__HYDROGEN_DEV__: env.mode !== 'production',
|
|
93
|
+
__HYDROGEN_WORKER__: isWorker,
|
|
94
|
+
__HYDROGEN_TEST__: false, // Used in unit tests
|
|
92
95
|
},
|
|
93
96
|
envPrefix: ['VITE_', 'PUBLIC_'],
|
|
94
97
|
base: process.env.HYDROGEN_ASSET_BASE_URL,
|
|
@@ -42,7 +42,7 @@ exports.default = (pluginOptions) => {
|
|
|
42
42
|
headers: incomingMessage.headers,
|
|
43
43
|
});
|
|
44
44
|
// @ts-expect-error Manually set `normalizedUrl` which a developer expects to be available
|
|
45
|
-
// via `
|
|
45
|
+
// via `HydrogenRequest` during production runtime.
|
|
46
46
|
request.normalizedUrl = request.url;
|
|
47
47
|
const { shopify } = hydrogenConfig;
|
|
48
48
|
return typeof shopify === 'function' ? shopify(request) : shopify;
|
|
@@ -7,9 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const plugin_1 = __importDefault(require("@shopify/hydrogen/vendor/react-server-dom-vite/plugin"));
|
|
8
8
|
const vite_plugin_hydrogen_middleware_1 = require("./vite-plugin-hydrogen-middleware");
|
|
9
9
|
const vite_plugin_hydrogen_virtual_files_1 = require("./vite-plugin-hydrogen-virtual-files");
|
|
10
|
-
const viteception_1 = require("../viteception");
|
|
11
10
|
function default_1() {
|
|
12
11
|
return (0, plugin_1.default)({
|
|
12
|
+
serverBuildEntries: [
|
|
13
|
+
vite_plugin_hydrogen_middleware_1.HYDROGEN_DEFAULT_SERVER_ENTRY,
|
|
14
|
+
vite_plugin_hydrogen_virtual_files_1.VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
15
|
+
],
|
|
13
16
|
isServerComponentImporterAllowed(importer, source) {
|
|
14
17
|
return (
|
|
15
18
|
// Always allow the entry server (e.g. App.server.jsx) to be imported
|
|
@@ -20,17 +23,6 @@ function default_1() {
|
|
|
20
23
|
// TODO: revisit this when RSC splits into two bundles
|
|
21
24
|
/\.test\.[tj]sx?$/.test(importer));
|
|
22
25
|
},
|
|
23
|
-
async findClientComponentsForClientBuild() {
|
|
24
|
-
const { server } = await (0, viteception_1.viteception)([
|
|
25
|
-
// Load server entry to discover client components early
|
|
26
|
-
vite_plugin_hydrogen_middleware_1.HYDROGEN_DEFAULT_SERVER_ENTRY,
|
|
27
|
-
// Route globs are placed in a virtual module and need to
|
|
28
|
-
// be loaded to discover client components in routes
|
|
29
|
-
vite_plugin_hydrogen_virtual_files_1.VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
30
|
-
]);
|
|
31
|
-
// At this point, the server has loaded all the components in the module graph
|
|
32
|
-
return plugin_1.default.findClientComponentsFromServer(server);
|
|
33
|
-
},
|
|
34
26
|
});
|
|
35
27
|
}
|
|
36
28
|
exports.default = default_1;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = () => {
|
|
4
|
+
return {
|
|
5
|
+
name: 'hydrogen:suppress-warnings',
|
|
6
|
+
configResolved(config) {
|
|
7
|
+
// TODO: Fix the actual issues that cause these warnings
|
|
8
|
+
const filterOut = (msg) => msg.startsWith("@shopify/hydrogen doesn't appear to be written in CJS") ||
|
|
9
|
+
(msg.includes('missing source files') &&
|
|
10
|
+
['kolorist'].some((lib) => msg.includes(lib)));
|
|
11
|
+
for (const method of ['warn', 'warnOnce']) {
|
|
12
|
+
const original = config.logger[method];
|
|
13
|
+
config.logger[method] = (msg, ...args) => {
|
|
14
|
+
if (filterOut(msg))
|
|
15
|
+
return;
|
|
16
|
+
return original(msg, ...args);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useProductOptions } from './useProductOptions';
|
|
2
|
+
export * from './useProductOptions/types';
|
|
3
|
+
export { useMoney } from './useMoney';
|
|
4
|
+
export { useMeasurement } from './useMeasurement';
|
|
5
|
+
export { useParsedMetafields } from './useParsedMetafields';
|
|
6
|
+
export { useLoadScript } from './useLoadScript';
|
|
@@ -0,0 +1,28 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.useLoadScript = exports.useParsedMetafields = exports.useMeasurement = exports.useMoney = exports.useProductOptions = void 0;
|
|
18
|
+
var useProductOptions_1 = require("./useProductOptions");
|
|
19
|
+
Object.defineProperty(exports, "useProductOptions", { enumerable: true, get: function () { return useProductOptions_1.useProductOptions; } });
|
|
20
|
+
__exportStar(require("./useProductOptions/types"), exports);
|
|
21
|
+
var useMoney_1 = require("./useMoney");
|
|
22
|
+
Object.defineProperty(exports, "useMoney", { enumerable: true, get: function () { return useMoney_1.useMoney; } });
|
|
23
|
+
var useMeasurement_1 = require("./useMeasurement");
|
|
24
|
+
Object.defineProperty(exports, "useMeasurement", { enumerable: true, get: function () { return useMeasurement_1.useMeasurement; } });
|
|
25
|
+
var useParsedMetafields_1 = require("./useParsedMetafields");
|
|
26
|
+
Object.defineProperty(exports, "useParsedMetafields", { enumerable: true, get: function () { return useParsedMetafields_1.useParsedMetafields; } });
|
|
27
|
+
var useLoadScript_1 = require("./useLoadScript");
|
|
28
|
+
Object.defineProperty(exports, "useLoadScript", { enumerable: true, get: function () { return useLoadScript_1.useLoadScript; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCart } from './useCart';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useCart = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const context_1 = require("../../components/CartProvider/context");
|
|
9
|
+
/**
|
|
10
|
+
* The `useCart` hook provides access to the cart object. It must be a descendent of a `CartProvider` component.
|
|
11
|
+
*/
|
|
12
|
+
function useCart() {
|
|
13
|
+
const context = react_1.default.useContext(context_1.CartContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error('Expected a Cart Context, but no Cart Context was found');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
exports.useCart = useCart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCartLine } from './useCartLine';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCartLine = void 0;
|
|
4
|
+
var useCartLine_1 = require("./useCartLine");
|
|
5
|
+
Object.defineProperty(exports, "useCartLine", { enumerable: true, get: function () { return useCartLine_1.useCartLine; } });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `useCartLine` hook provides access to the cart line object. It must be a descendent of a `CartProvider` component.
|
|
3
|
+
*/
|
|
4
|
+
export declare function useCartLine(): {
|
|
5
|
+
__typename?: "CartLine" | undefined;
|
|
6
|
+
} & Pick<import("../../storefront-api-types").CartLine, "id" | "quantity"> & {
|
|
7
|
+
attributes: ({
|
|
8
|
+
__typename?: "Attribute" | undefined;
|
|
9
|
+
} & Pick<import("../../storefront-api-types").Attribute, "key" | "value">)[];
|
|
10
|
+
estimatedCost: {
|
|
11
|
+
__typename?: "CartLineEstimatedCost" | undefined;
|
|
12
|
+
} & {
|
|
13
|
+
totalAmount: {
|
|
14
|
+
__typename?: "MoneyV2" | undefined;
|
|
15
|
+
} & Pick<import("../../storefront-api-types").MoneyV2, "amount" | "currencyCode">;
|
|
16
|
+
compareAtAmount?: import("../../storefront-api-types").Maybe<{
|
|
17
|
+
__typename?: "MoneyV2" | undefined;
|
|
18
|
+
} & Pick<import("../../storefront-api-types").MoneyV2, "amount" | "currencyCode">> | undefined;
|
|
19
|
+
};
|
|
20
|
+
merchandise: {
|
|
21
|
+
__typename?: "ProductVariant" | undefined;
|
|
22
|
+
} & Pick<import("../../storefront-api-types").ProductVariant, "id" | "title" | "availableForSale" | "requiresShipping"> & {
|
|
23
|
+
compareAtPriceV2?: import("../../storefront-api-types").Maybe<{
|
|
24
|
+
__typename?: "MoneyV2" | undefined;
|
|
25
|
+
} & Pick<import("../../storefront-api-types").MoneyV2, "amount" | "currencyCode">> | undefined;
|
|
26
|
+
priceV2: {
|
|
27
|
+
__typename?: "MoneyV2" | undefined;
|
|
28
|
+
} & Pick<import("../../storefront-api-types").MoneyV2, "amount" | "currencyCode">;
|
|
29
|
+
image?: import("../../storefront-api-types").Maybe<{
|
|
30
|
+
__typename?: "Image" | undefined;
|
|
31
|
+
} & Pick<import("../../storefront-api-types").Image, "id" | "height" | "width" | "url" | "altText">> | undefined;
|
|
32
|
+
product: {
|
|
33
|
+
__typename?: "Product" | undefined;
|
|
34
|
+
} & Pick<import("../../storefront-api-types").Product, "title" | "handle">;
|
|
35
|
+
selectedOptions: ({
|
|
36
|
+
__typename?: "SelectedOption" | undefined;
|
|
37
|
+
} & Pick<import("../../storefront-api-types").SelectedOption, "name" | "value">)[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCartLine = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("../../components/CartLineProvider/context");
|
|
6
|
+
/**
|
|
7
|
+
* The `useCartLine` hook provides access to the cart line object. It must be a descendent of a `CartProvider` component.
|
|
8
|
+
*/
|
|
9
|
+
function useCartLine() {
|
|
10
|
+
const context = (0, react_1.useContext)(context_1.CartLineContext);
|
|
11
|
+
if (context == null) {
|
|
12
|
+
throw new Error('Expected a cart line context but none was found');
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
16
|
+
exports.useCartLine = useCartLine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCountry } from './useCountry';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCountry = void 0;
|
|
4
|
+
var useCountry_1 = require("./useCountry");
|
|
5
|
+
Object.defineProperty(exports, "useCountry", { enumerable: true, get: function () { return useCountry_1.useCountry; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `useCountry` hook returns a tuple of the current localization country and a function for updating it.
|
|
3
|
+
* It must be a descendent of a `LocalizationProvider` component.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useCountry(): (({
|
|
6
|
+
__typename?: "Country" | undefined;
|
|
7
|
+
} & Pick<import("../../storefront-api-types").Country, "name" | "isoCode">) | undefined)[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCountry = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const LocalizationContext_client_1 = require("../../components/LocalizationProvider/LocalizationContext.client");
|
|
6
|
+
function useLocalization() {
|
|
7
|
+
const context = (0, react_1.useContext)(LocalizationContext_client_1.LocalizationContext);
|
|
8
|
+
if (context == null) {
|
|
9
|
+
throw new Error('No Localization Context available');
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The `useCountry` hook returns a tuple of the current localization country and a function for updating it.
|
|
15
|
+
* It must be a descendent of a `LocalizationProvider` component.
|
|
16
|
+
*/
|
|
17
|
+
function useCountry() {
|
|
18
|
+
const context = useLocalization();
|
|
19
|
+
return [context.country];
|
|
20
|
+
}
|
|
21
|
+
exports.useCountry = useCountry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLoadScript } from './useLoadScript.client';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLoadScript = void 0;
|
|
4
|
+
var useLoadScript_client_1 = require("./useLoadScript.client");
|
|
5
|
+
Object.defineProperty(exports, "useLoadScript", { enumerable: true, get: function () { return useLoadScript_client_1.useLoadScript; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { loadScript } from '../../utilities/load_script';
|
|
2
|
+
declare type LoadScriptParams = Parameters<typeof loadScript>;
|
|
3
|
+
/**
|
|
4
|
+
* The `useLoadScript` hook loads an external script tag on the client-side.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useLoadScript(url: LoadScriptParams[0], options?: LoadScriptParams[1]): ScriptState;
|
|
7
|
+
declare type ScriptState = 'loading' | 'done' | 'error';
|
|
8
|
+
export {};
|