@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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getLoggerWithContext, collectQueryCacheControlHeaders, collectQueryTimings, } from '../../utilities/log';
|
|
2
|
-
import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '
|
|
3
|
-
import { runDelayedFunction } from '../../framework/runtime';
|
|
2
|
+
import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '../Cache/cache-sub-request';
|
|
4
3
|
import { useRequestCacheData, useServerRequest } from '../ServerRequestProvider';
|
|
5
|
-
import { CacheSeconds } from '
|
|
4
|
+
import { CacheSeconds, NO_STORE } from '../Cache/strategies';
|
|
6
5
|
/**
|
|
7
6
|
* The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
|
|
8
7
|
* supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
|
|
@@ -25,7 +24,7 @@ queryOptions) {
|
|
|
25
24
|
];
|
|
26
25
|
const fetcher = cachedQueryFnBuilder(withCacheIdKey, queryFn, queryOptions);
|
|
27
26
|
collectQueryTimings(request, withCacheIdKey, 'requested');
|
|
28
|
-
if (queryOptions
|
|
27
|
+
if (shouldPreloadQuery(queryOptions)) {
|
|
29
28
|
request.savePreloadQuery({
|
|
30
29
|
preload: queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload,
|
|
31
30
|
key: withCacheIdKey,
|
|
@@ -34,6 +33,20 @@ queryOptions) {
|
|
|
34
33
|
}
|
|
35
34
|
return useRequestCacheData(withCacheIdKey, fetcher);
|
|
36
35
|
}
|
|
36
|
+
export function shouldPreloadQuery(queryOptions) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (!queryOptions)
|
|
39
|
+
return true;
|
|
40
|
+
const hasCacheOverride = typeof ((_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.cache) === null || _a === void 0 ? void 0 : _a.mode) !== 'undefined';
|
|
41
|
+
const hasPreloadOverride = typeof (queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload) !== 'undefined';
|
|
42
|
+
const cacheValue = (_b = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.cache) === null || _b === void 0 ? void 0 : _b.mode;
|
|
43
|
+
const preloadValue = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload;
|
|
44
|
+
// If preload is explicitly defined, then it takes precedence
|
|
45
|
+
if (hasPreloadOverride) {
|
|
46
|
+
return !!preloadValue;
|
|
47
|
+
}
|
|
48
|
+
return hasCacheOverride ? cacheValue !== NO_STORE : true;
|
|
49
|
+
}
|
|
37
50
|
function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
38
51
|
var _a;
|
|
39
52
|
const resolvedQueryOptions = {
|
|
@@ -44,6 +57,7 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
44
57
|
* Attempt to read the query from cache. If it doesn't exist or if it's stale, regenerate it.
|
|
45
58
|
*/
|
|
46
59
|
async function useCachedQueryFn() {
|
|
60
|
+
var _a, _b, _c, _d;
|
|
47
61
|
// Call this hook before running any async stuff
|
|
48
62
|
// to prevent losing the current React cycle.
|
|
49
63
|
const request = useServerRequest();
|
|
@@ -60,8 +74,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
60
74
|
*/
|
|
61
75
|
if (isStale(key, response)) {
|
|
62
76
|
const lockKey = ['lock', ...(typeof key === 'string' ? [key] : key)];
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
// Run revalidation asynchronously
|
|
78
|
+
const revalidatingPromise = getItemFromCache(lockKey).then(async (lockExists) => {
|
|
65
79
|
if (lockExists)
|
|
66
80
|
return;
|
|
67
81
|
await setItemInCache(lockKey, true, CacheSeconds({
|
|
@@ -80,6 +94,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
80
94
|
await deleteItemFromCache(lockKey);
|
|
81
95
|
}
|
|
82
96
|
});
|
|
97
|
+
// Asynchronously wait for it in workers
|
|
98
|
+
(_b = (_a = request.ctx.runtime) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.call(_a, revalidatingPromise);
|
|
83
99
|
}
|
|
84
100
|
return output;
|
|
85
101
|
}
|
|
@@ -88,7 +104,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
88
104
|
* Important: Do this async
|
|
89
105
|
*/
|
|
90
106
|
if (shouldCacheResponse(newOutput)) {
|
|
91
|
-
|
|
107
|
+
const setItemInCachePromise = setItemInCache(key, newOutput, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
|
|
108
|
+
(_d = (_c = request.ctx.runtime) === null || _c === void 0 ? void 0 : _c.waitUntil) === null || _d === void 0 ? void 0 : _d.call(_c, setItemInCachePromise);
|
|
92
109
|
}
|
|
93
110
|
collectQueryCacheControlHeaders(request, key, generateSubRequestCacheControlHeader(resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache));
|
|
94
111
|
return newOutput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type ScopedContext = Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* Provides access to the current request context.
|
|
4
|
+
* @param scope - An optional string used to scope the request context. It is recommended to
|
|
5
|
+
* prevent modifying the properties added by other plugins.
|
|
6
|
+
* @returns A request-scoped object that can be modified to provide and consume information
|
|
7
|
+
* across different React components in the tree.
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* import {useRequestContext} from '@shopify/hydrogen';
|
|
11
|
+
* useRequestContext('my-plugin-name');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function useRequestContext<T extends ScopedContext>(scope?: string): T;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { META_ENV_SSR, useEnvContext } from '../ssr-interop';
|
|
2
|
+
/**
|
|
3
|
+
* Provides access to the current request context.
|
|
4
|
+
* @param scope - An optional string used to scope the request context. It is recommended to
|
|
5
|
+
* prevent modifying the properties added by other plugins.
|
|
6
|
+
* @returns A request-scoped object that can be modified to provide and consume information
|
|
7
|
+
* across different React components in the tree.
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* import {useRequestContext} from '@shopify/hydrogen';
|
|
11
|
+
* useRequestContext('my-plugin-name');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function useRequestContext(scope = 'default') {
|
|
15
|
+
if (__HYDROGEN_DEV__ && !META_ENV_SSR) {
|
|
16
|
+
throw new Error('useRequestContext can only be used in the server');
|
|
17
|
+
}
|
|
18
|
+
const scopes = useEnvContext((req) => req.ctx.scopes);
|
|
19
|
+
if (!scopes.has(scope)) {
|
|
20
|
+
scopes.set(scope, Object.create(null));
|
|
21
|
+
}
|
|
22
|
+
return scopes.get(scope);
|
|
23
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { createFromFetch, createFromReadableStream,
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
} from '@shopify/hydrogen/vendor/react-server-dom-vite';
|
|
6
|
+
import { ClientAnalytics } from '../../client';
|
|
6
7
|
import { RSC_PATHNAME } from '../../constants';
|
|
7
8
|
let rscReader;
|
|
8
9
|
// Hydrate an SSR response from <meta> tags placed in the DOM.
|
|
@@ -88,6 +89,7 @@ export function useServerResponse(state) {
|
|
|
88
89
|
/* @ts-ignore */
|
|
89
90
|
window.BOOMR.plugins.Hydrogen.trackSubPageLoadPerformance();
|
|
90
91
|
}
|
|
92
|
+
ClientAnalytics.resetPageAnalyticsData();
|
|
91
93
|
// Request a new flight response.
|
|
92
94
|
response = createFromFetch(fetch(`${RSC_PATHNAME}?state=` + encodeURIComponent(key)));
|
|
93
95
|
}
|
|
@@ -11,6 +11,7 @@ import inspect from 'vite-plugin-inspect';
|
|
|
11
11
|
import react from '@vitejs/plugin-react';
|
|
12
12
|
import cssModulesRsc from './plugins/vite-plugin-css-modules-rsc';
|
|
13
13
|
import clientImports from './plugins/vite-plugin-client-imports';
|
|
14
|
+
import suppressWarnings from './plugins/vite-plugin-hydrogen-suppress-warnings';
|
|
14
15
|
export default (pluginOptions = {}) => {
|
|
15
16
|
return [
|
|
16
17
|
process.env.VITE_INSPECT && inspect(),
|
|
@@ -25,6 +26,7 @@ export default (pluginOptions = {}) => {
|
|
|
25
26
|
cssModulesRsc(),
|
|
26
27
|
rsc(),
|
|
27
28
|
platformEntry(),
|
|
29
|
+
suppressWarnings(),
|
|
28
30
|
pluginOptions.purgeQueryCacheOnBuild && purgeQueryCache(),
|
|
29
31
|
];
|
|
30
32
|
};
|
|
@@ -82,11 +82,14 @@ export default () => {
|
|
|
82
82
|
'react-server-dom-vite/client-proxy',
|
|
83
83
|
// https://github.com/vitejs/vite/issues/6215
|
|
84
84
|
'react/jsx-runtime',
|
|
85
|
+
// https://github.com/nfriedly/set-cookie-parser/issues/50
|
|
86
|
+
'set-cookie-parser',
|
|
85
87
|
],
|
|
86
88
|
},
|
|
87
89
|
define: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
__HYDROGEN_DEV__: env.mode !== 'production',
|
|
91
|
+
__HYDROGEN_WORKER__: isWorker,
|
|
92
|
+
__HYDROGEN_TEST__: false, // Used in unit tests
|
|
90
93
|
},
|
|
91
94
|
envPrefix: ['VITE_', 'PUBLIC_'],
|
|
92
95
|
base: process.env.HYDROGEN_ASSET_BASE_URL,
|
|
@@ -36,7 +36,7 @@ export default (pluginOptions) => {
|
|
|
36
36
|
headers: incomingMessage.headers,
|
|
37
37
|
});
|
|
38
38
|
// @ts-expect-error Manually set `normalizedUrl` which a developer expects to be available
|
|
39
|
-
// via `
|
|
39
|
+
// via `HydrogenRequest` during production runtime.
|
|
40
40
|
request.normalizedUrl = request.url;
|
|
41
41
|
const { shopify } = hydrogenConfig;
|
|
42
42
|
return typeof shopify === 'function' ? shopify(request) : shopify;
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
import reactServerDomVite from '@shopify/hydrogen/vendor/react-server-dom-vite/plugin';
|
|
3
3
|
import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware';
|
|
4
4
|
import { VIRTUAL_PROXY_HYDROGEN_ROUTES_ID } from './vite-plugin-hydrogen-virtual-files';
|
|
5
|
-
import { viteception } from '../viteception';
|
|
6
5
|
export default function () {
|
|
7
6
|
return reactServerDomVite({
|
|
7
|
+
serverBuildEntries: [
|
|
8
|
+
HYDROGEN_DEFAULT_SERVER_ENTRY,
|
|
9
|
+
VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
10
|
+
],
|
|
8
11
|
isServerComponentImporterAllowed(importer, source) {
|
|
9
12
|
return (
|
|
10
13
|
// Always allow the entry server (e.g. App.server.jsx) to be imported
|
|
@@ -15,16 +18,5 @@ export default function () {
|
|
|
15
18
|
// TODO: revisit this when RSC splits into two bundles
|
|
16
19
|
/\.test\.[tj]sx?$/.test(importer));
|
|
17
20
|
},
|
|
18
|
-
async findClientComponentsForClientBuild() {
|
|
19
|
-
const { server } = await viteception([
|
|
20
|
-
// Load server entry to discover client components early
|
|
21
|
-
HYDROGEN_DEFAULT_SERVER_ENTRY,
|
|
22
|
-
// Route globs are placed in a virtual module and need to
|
|
23
|
-
// be loaded to discover client components in routes
|
|
24
|
-
VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
25
|
-
]);
|
|
26
|
-
// At this point, the server has loaded all the components in the module graph
|
|
27
|
-
return reactServerDomVite.findClientComponentsFromServer(server);
|
|
28
|
-
},
|
|
29
21
|
});
|
|
30
22
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
return {
|
|
3
|
+
name: 'hydrogen:suppress-warnings',
|
|
4
|
+
configResolved(config) {
|
|
5
|
+
// TODO: Fix the actual issues that cause these warnings
|
|
6
|
+
const filterOut = (msg) => msg.startsWith("@shopify/hydrogen doesn't appear to be written in CJS") ||
|
|
7
|
+
(msg.includes('missing source files') &&
|
|
8
|
+
['kolorist'].some((lib) => msg.includes(lib)));
|
|
9
|
+
for (const method of ['warn', 'warnOnce']) {
|
|
10
|
+
const original = config.logger[method];
|
|
11
|
+
config.logger[method] = (msg, ...args) => {
|
|
12
|
+
if (filterOut(msg))
|
|
13
|
+
return;
|
|
14
|
+
return original(msg, ...args);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -7,15 +7,25 @@ export declare function useCartLine(): {
|
|
|
7
7
|
attributes: ({
|
|
8
8
|
__typename?: "Attribute" | undefined;
|
|
9
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
|
+
};
|
|
10
20
|
merchandise: {
|
|
11
21
|
__typename?: "ProductVariant" | undefined;
|
|
12
22
|
} & Pick<import("../../storefront-api-types").ProductVariant, "id" | "title" | "availableForSale" | "requiresShipping"> & {
|
|
13
23
|
compareAtPriceV2?: import("../../storefront-api-types").Maybe<{
|
|
14
24
|
__typename?: "MoneyV2" | undefined;
|
|
15
|
-
} & Pick<import("../../storefront-api-types").MoneyV2, "
|
|
25
|
+
} & Pick<import("../../storefront-api-types").MoneyV2, "amount" | "currencyCode">> | undefined;
|
|
16
26
|
priceV2: {
|
|
17
27
|
__typename?: "MoneyV2" | undefined;
|
|
18
|
-
} & Pick<import("../../storefront-api-types").MoneyV2, "
|
|
28
|
+
} & Pick<import("../../storefront-api-types").MoneyV2, "amount" | "currencyCode">;
|
|
19
29
|
image?: import("../../storefront-api-types").Maybe<{
|
|
20
30
|
__typename?: "Image" | undefined;
|
|
21
31
|
} & Pick<import("../../storefront-api-types").Image, "id" | "height" | "width" | "url" | "altText">> | undefined;
|
|
@@ -14,8 +14,8 @@ metafields?: PartialDeep<MetafieldConnection>): {
|
|
|
14
14
|
description?: import("../../storefront-api-types").Maybe<string> | undefined;
|
|
15
15
|
key?: string | undefined;
|
|
16
16
|
namespace?: string | undefined;
|
|
17
|
-
parentResource?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").
|
|
18
|
-
reference?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Video> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").MediaImage> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").ProductVariant> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").
|
|
17
|
+
parentResource?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Blog> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Article> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Customer> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").ProductVariant> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Order> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Collection> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Page> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Product> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Shop> | undefined;
|
|
18
|
+
reference?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Video> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").MediaImage> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").ProductVariant> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Page> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Product> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").GenericFile> | null | undefined;
|
|
19
19
|
type?: string | undefined;
|
|
20
20
|
updatedAt?: string | undefined;
|
|
21
21
|
}[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SelectedOption as SelectedOptionType, ProductVariant as ProductVariantType, ProductVariantConnection, SellingPlan as SellingPlanType, SellingPlanAllocation as SellingPlanAllocationType, SellingPlanGroup as SellingPlanGroupType,
|
|
1
|
+
import type { SelectedOption as SelectedOptionType, ProductVariant as ProductVariantType, ProductVariantConnection, SellingPlan as SellingPlanType, SellingPlanAllocation as SellingPlanAllocationType, SellingPlanGroup as SellingPlanGroupType, SellingPlanGroupConnection } from '../../storefront-api-types';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
export declare type SelectedOptions = {
|
|
3
4
|
[key: string]: string;
|
|
4
5
|
};
|
|
5
|
-
export declare type SelectVariantCallback = (variant: ProductVariantType) => void;
|
|
6
|
+
export declare type SelectVariantCallback = (variant: ProductVariantType | null) => void;
|
|
6
7
|
export declare type SelectOptionCallback = (name: SelectedOptionType['name'], value: SelectedOptionType['value']) => void;
|
|
7
8
|
export declare type SelectOptionsCallback = (options: SelectedOptions) => void;
|
|
8
9
|
export declare type OptionsInStockCallback = (name: SelectedOptionType['name'], value: SelectedOptionType['value']) => boolean;
|
|
@@ -11,7 +12,7 @@ export interface OptionWithValues {
|
|
|
11
12
|
name: SelectedOptionType['name'];
|
|
12
13
|
values: SelectedOptionType['value'][];
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
+
export declare type ProductOptionsHookValue = PartialDeep<{
|
|
15
16
|
/** An array of the variant `nodes` from the `VariantConnection`. */
|
|
16
17
|
variants: ProductVariantType[];
|
|
17
18
|
variantsConnection?: ProductVariantConnection;
|
|
@@ -19,17 +20,7 @@ export interface ProductOptionsHookValue {
|
|
|
19
20
|
options: OptionWithValues[];
|
|
20
21
|
/** The selected variant. */
|
|
21
22
|
selectedVariant?: ProductVariantType | null;
|
|
22
|
-
/** A callback to set the selected variant to the variant passed as an argument. */
|
|
23
|
-
setSelectedVariant: SelectVariantCallback;
|
|
24
23
|
selectedOptions: SelectedOptions;
|
|
25
|
-
/** A callback to set the selected option. */
|
|
26
|
-
setSelectedOption: SelectOptionCallback;
|
|
27
|
-
/** A callback to set multiple selected options at once. */
|
|
28
|
-
setSelectedOptions: SelectOptionsCallback;
|
|
29
|
-
/** A callback that returns a boolean indicating if the option is in stock. */
|
|
30
|
-
isOptionInStock: OptionsInStockCallback;
|
|
31
|
-
/** A callback to set the selected selling plan to the one passed as an argument. */
|
|
32
|
-
setSelectedSellingPlan: SelectedSellingPlanCallback;
|
|
33
24
|
/** The selected selling plan. */
|
|
34
25
|
selectedSellingPlan?: SellingPlanType;
|
|
35
26
|
/** The selected selling plan allocation. */
|
|
@@ -38,5 +29,16 @@ export interface ProductOptionsHookValue {
|
|
|
38
29
|
sellingPlanGroups?: (Omit<SellingPlanGroupType, 'sellingPlans'> & {
|
|
39
30
|
sellingPlans: SellingPlanType[];
|
|
40
31
|
})[];
|
|
41
|
-
sellingPlanGroupsConnection?:
|
|
42
|
-
}
|
|
32
|
+
sellingPlanGroupsConnection?: SellingPlanGroupConnection;
|
|
33
|
+
}> & {
|
|
34
|
+
/** A callback to set the selected variant to the variant passed as an argument. */
|
|
35
|
+
setSelectedVariant: SelectVariantCallback;
|
|
36
|
+
/** A callback to set the selected option. */
|
|
37
|
+
setSelectedOption: SelectOptionCallback;
|
|
38
|
+
/** A callback to set multiple selected options at once. */
|
|
39
|
+
setSelectedOptions: SelectOptionsCallback;
|
|
40
|
+
/** A callback to set the selected selling plan to the one passed as an argument. */
|
|
41
|
+
setSelectedSellingPlan: SelectedSellingPlanCallback;
|
|
42
|
+
/** A callback that returns a boolean indicating if the option is in stock. */
|
|
43
|
+
isOptionInStock: OptionsInStockCallback;
|
|
44
|
+
};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ProductVariantConnection, SellingPlanGroupConnection, ProductVariant as ProductVariantType } from '../../storefront-api-types';
|
|
3
|
-
import type { PartialDeep } from 'type-fest';
|
|
4
|
-
/**
|
|
5
|
-
* The `useProductOptions` hook returns an object that enables you to keep track of the
|
|
6
|
-
* selected variant and/or selling plan state, as well as callbacks for modifying the state.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useProductOptions({ variants: variantsConnection, sellingPlanGroups: sellingPlanGroupsConnection, initialVariantId: explicitVariantId, }: {
|
|
9
|
-
/** The product's `VariantConnection`. */
|
|
10
|
-
variants?: PartialDeep<ProductVariantConnection>;
|
|
11
|
-
/** The product's `SellingPlanGroups`. */
|
|
12
|
-
sellingPlanGroups?: PartialDeep<SellingPlanGroupConnection>;
|
|
13
|
-
/** The initially selected variant. */
|
|
14
|
-
initialVariantId?: ProductVariantType['id'] | null;
|
|
15
|
-
}): ProductOptionsHookValue;
|
|
1
|
+
export declare function useProductOptions(): import("./types").ProductOptionsHookValue;
|
|
@@ -1,108 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// The flattened variants
|
|
10
|
-
const variants = useMemo(() => (variantsConnection ? flattenConnection(variantsConnection) : []), [variantsConnection]);
|
|
11
|
-
// All the options available for a product, based on all the variants
|
|
12
|
-
const options = useMemo(() => getOptions(variants), [variants]);
|
|
13
|
-
// TODO: we have some weird variable shadowing going on here that probably needs to be looked at. This variable is the same name as a prop
|
|
14
|
-
const initialVariantId = explicitVariantId === null
|
|
15
|
-
? explicitVariantId
|
|
16
|
-
: variants.find((variant) => variant.id === explicitVariantId) ||
|
|
17
|
-
variants.find((variant) => variant.availableForSale) ||
|
|
18
|
-
variants[0];
|
|
19
|
-
/**
|
|
20
|
-
* Track the selectedVariant within the hook. If `initialVariantId`
|
|
21
|
-
* is passed, use that as an initial value.
|
|
22
|
-
*/
|
|
23
|
-
const [selectedVariant, setSelectedVariant] = useState(initialVariantId);
|
|
24
|
-
/**
|
|
25
|
-
* Track the selectedOptions within the hook. If a `initialVariantId`
|
|
26
|
-
* is passed, use that to select initial options.
|
|
27
|
-
*/
|
|
28
|
-
const [selectedOptions, setSelectedOptions] = useState((selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.selectedOptions)
|
|
29
|
-
? selectedVariant.selectedOptions.reduce((memo, optionSet) => {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
memo[(_a = optionSet === null || optionSet === void 0 ? void 0 : optionSet.name) !== null && _a !== void 0 ? _a : ''] = (_b = optionSet === null || optionSet === void 0 ? void 0 : optionSet.value) !== null && _b !== void 0 ? _b : '';
|
|
32
|
-
return memo;
|
|
33
|
-
}, {})
|
|
34
|
-
: {});
|
|
35
|
-
/**
|
|
36
|
-
* When the initialVariantId changes, we need to make sure we
|
|
37
|
-
* update the selected variant and selected options. If not,
|
|
38
|
-
* then the selected variant and options will reference incorrect
|
|
39
|
-
* values.
|
|
40
|
-
*/
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
const variant = getSelectedVariant(variants, selectedOptions);
|
|
43
|
-
setSelectedVariant(variant);
|
|
44
|
-
}, [selectedOptions, variants]);
|
|
45
|
-
/**
|
|
46
|
-
* Allow the developer to select an option.
|
|
47
|
-
*/
|
|
48
|
-
const setSelectedOption = useCallback((name, value) => {
|
|
49
|
-
setSelectedOptions((selectedOptions) => ({
|
|
50
|
-
...selectedOptions,
|
|
51
|
-
[name]: value,
|
|
52
|
-
}));
|
|
53
|
-
}, [setSelectedOptions]);
|
|
54
|
-
const isOptionInStock = useCallback((option, value) => {
|
|
55
|
-
var _a;
|
|
56
|
-
const proposedVariant = getSelectedVariant(variants, {
|
|
57
|
-
...selectedOptions,
|
|
58
|
-
...{ [option]: value },
|
|
59
|
-
});
|
|
60
|
-
return (_a = proposedVariant === null || proposedVariant === void 0 ? void 0 : proposedVariant.availableForSale) !== null && _a !== void 0 ? _a : true;
|
|
61
|
-
}, [selectedOptions, variants]);
|
|
62
|
-
const sellingPlanGroups = useMemo(() => sellingPlanGroupsConnection
|
|
63
|
-
? flattenConnection(sellingPlanGroupsConnection).map((sellingPlanGroup) => ({
|
|
64
|
-
...sellingPlanGroup,
|
|
65
|
-
sellingPlans: (sellingPlanGroup === null || sellingPlanGroup === void 0 ? void 0 : sellingPlanGroup.sellingPlans)
|
|
66
|
-
? flattenConnection(sellingPlanGroup.sellingPlans)
|
|
67
|
-
: [],
|
|
68
|
-
}))
|
|
69
|
-
: [], [sellingPlanGroupsConnection]);
|
|
70
|
-
/**
|
|
71
|
-
* Track the selectedSellingPlan within the hook. If `initialSellingPlanId`
|
|
72
|
-
* is passed, use that as an initial value. Look it up from the `selectedVariant`, since
|
|
73
|
-
* that is also a requirement.
|
|
74
|
-
*/
|
|
75
|
-
const [selectedSellingPlan, setSelectedSellingPlan] = useState(undefined);
|
|
76
|
-
const selectedSellingPlanAllocation = useMemo(() => {
|
|
77
|
-
if (!selectedVariant || !selectedSellingPlan) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (!selectedVariant.sellingPlanAllocations) {
|
|
81
|
-
throw new Error(`You must include sellingPlanAllocations in your variants in order to calculate selectedSellingPlanAllocation`);
|
|
82
|
-
}
|
|
83
|
-
return flattenConnection(selectedVariant.sellingPlanAllocations).find(
|
|
84
|
-
// @ts-ignore The types here are broken on main, need to come back and fix them sometime
|
|
85
|
-
(allocation) => allocation.sellingPlan.id === selectedSellingPlan.id);
|
|
86
|
-
}, [selectedVariant, selectedSellingPlan]);
|
|
87
|
-
return {
|
|
88
|
-
// @ts-ignore The types here are broken on main, need to come back and fix them sometime
|
|
89
|
-
variants,
|
|
90
|
-
// @ts-ignore The types here are broken on main, need to come back and fix them sometime
|
|
91
|
-
variantsConnection,
|
|
92
|
-
options,
|
|
93
|
-
// @ts-ignore The types here are broken on main, need to come back and fix them sometime
|
|
94
|
-
selectedVariant,
|
|
95
|
-
setSelectedVariant,
|
|
96
|
-
selectedOptions,
|
|
97
|
-
setSelectedOption,
|
|
98
|
-
setSelectedOptions,
|
|
99
|
-
isOptionInStock,
|
|
100
|
-
selectedSellingPlan,
|
|
101
|
-
setSelectedSellingPlan,
|
|
102
|
-
selectedSellingPlanAllocation,
|
|
103
|
-
// @ts-ignore The types here are broken on main, need to come back and fix them sometime
|
|
104
|
-
sellingPlanGroups,
|
|
105
|
-
// @ts-ignore The types here are broken on main, need to come back and fix them sometime
|
|
106
|
-
sellingPlanGroupsConnection,
|
|
107
|
-
};
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { ProductOptionsContext } from '../../components/ProductOptionsProvider/context';
|
|
3
|
+
export function useProductOptions() {
|
|
4
|
+
const context = useContext(ProductOptionsContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error(`'useProductOptions' must be a child of <ProductOptionsProvider/>`);
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
108
9
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useShop } from '../../foundation/useShop';
|
|
2
2
|
import { getLoggerWithContext } from '../../utilities/log';
|
|
3
3
|
import { graphqlRequestBody } from '../../utilities';
|
|
4
|
-
import { getConfig } from '../../framework/config';
|
|
5
4
|
import { useServerRequest } from '../../foundation/ServerRequestProvider';
|
|
6
5
|
import { injectGraphQLTracker } from '../../utilities/graphql-tracker';
|
|
7
6
|
import { sendMessageToClient } from '../../utilities/devtools';
|
|
@@ -40,15 +39,22 @@ export function useShopQuery({ query, variables = {}, cache, preload = false, })
|
|
|
40
39
|
const log = getLoggerWithContext(serverRequest);
|
|
41
40
|
const body = query ? graphqlRequestBody(query, variables) : '';
|
|
42
41
|
const { url, requestInit } = useCreateShopRequest(body); // eslint-disable-line react-hooks/rules-of-hooks
|
|
42
|
+
let text;
|
|
43
43
|
let data;
|
|
44
44
|
let useQueryError;
|
|
45
45
|
try {
|
|
46
|
-
|
|
46
|
+
text = fetchSync(url, {
|
|
47
47
|
...requestInit,
|
|
48
48
|
cache,
|
|
49
49
|
preload,
|
|
50
50
|
shouldCacheResponse,
|
|
51
|
-
}).
|
|
51
|
+
}).text();
|
|
52
|
+
try {
|
|
53
|
+
data = JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
useQueryError = new Error('Unable to parse response:\n' + text);
|
|
57
|
+
}
|
|
52
58
|
}
|
|
53
59
|
catch (error) {
|
|
54
60
|
// Pass-through thrown promise for Suspense functionality
|
|
@@ -64,7 +70,7 @@ export function useShopQuery({ query, variables = {}, cache, preload = false, })
|
|
|
64
70
|
const errorMessage = createErrorMessage(useQueryError);
|
|
65
71
|
log.error(errorMessage);
|
|
66
72
|
log.error(useQueryError);
|
|
67
|
-
if (
|
|
73
|
+
if (__HYDROGEN_DEV__ && !__HYDROGEN_TEST__) {
|
|
68
74
|
throw new Error(errorMessage);
|
|
69
75
|
}
|
|
70
76
|
else {
|
|
@@ -79,7 +85,7 @@ export function useShopQuery({ query, variables = {}, cache, preload = false, })
|
|
|
79
85
|
if (data === null || data === void 0 ? void 0 : data.errors) {
|
|
80
86
|
const errors = Array.isArray(data.errors) ? data.errors : [data.errors];
|
|
81
87
|
for (const error of errors) {
|
|
82
|
-
if (
|
|
88
|
+
if (__HYDROGEN_DEV__ && !__HYDROGEN_TEST__) {
|
|
83
89
|
throw new Error(error.message);
|
|
84
90
|
}
|
|
85
91
|
else {
|
|
@@ -88,7 +94,7 @@ export function useShopQuery({ query, variables = {}, cache, preload = false, })
|
|
|
88
94
|
}
|
|
89
95
|
log.error(`GraphQL errors: ${errors.length}`);
|
|
90
96
|
}
|
|
91
|
-
if (
|
|
97
|
+
if (__HYDROGEN_DEV__ &&
|
|
92
98
|
log.options().showUnusedQueryProperties &&
|
|
93
99
|
query &&
|
|
94
100
|
(data === null || data === void 0 ? void 0 : data.data)) {
|
package/dist/esnext/index.d.ts
CHANGED
|
@@ -16,12 +16,16 @@ export * from './foundation/useServerProps';
|
|
|
16
16
|
export { FileRoutes } from './foundation/FileRoutes/FileRoutes.server';
|
|
17
17
|
export { Route } from './foundation/Route/Route.server';
|
|
18
18
|
export { Router } from './foundation/Router/Router.server';
|
|
19
|
-
export { log,
|
|
19
|
+
export { log, type Logger } from './utilities/log';
|
|
20
20
|
export { LocalizationProvider } from './components/LocalizationProvider/LocalizationProvider.server';
|
|
21
21
|
export { ShopifyProvider } from './foundation/ShopifyProvider/ShopifyProvider.server';
|
|
22
|
-
export { generateCacheControlHeader, NoStore, CacheSeconds, CacheMinutes, CacheHours, CacheDays, CacheWeeks, CacheMonths, CacheCustom, } from './
|
|
22
|
+
export { generateCacheControlHeader, NoStore, CacheSeconds, CacheMinutes, CacheHours, CacheDays, CacheWeeks, CacheMonths, CacheCustom, } from './foundation/Cache/strategies';
|
|
23
|
+
export { useRequestContext } from './foundation/useRequestContext';
|
|
23
24
|
export { useServerAnalytics } from './foundation/Analytics/hook';
|
|
24
|
-
export
|
|
25
|
+
export { ShopifyAnalytics } from './foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server';
|
|
26
|
+
export { ShopifyAnalyticsConstants } from './foundation/Analytics/connectors/Shopify/const';
|
|
27
|
+
export * as ShopifyServerAnalyticsConnector from './foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server';
|
|
28
|
+
export * as PerformanceMetricsServerAnalyticsConnector from './foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server';
|
|
25
29
|
export { useSession } from './foundation/useSession/useSession';
|
|
26
30
|
export { CookieSessionStorage } from './foundation/CookieSessionStorage/CookieSessionStorage';
|
|
27
31
|
export { MemorySessionStorage } from './foundation/MemorySessionStorage/MemorySessionStorage';
|
|
@@ -35,3 +39,5 @@ export { CartQuery } from './components/CartProvider/cart-queries';
|
|
|
35
39
|
* Override the client version of `fetchSync` with the server version.
|
|
36
40
|
*/
|
|
37
41
|
export { fetchSync } from './foundation/fetchSync/server/fetchSync';
|
|
42
|
+
export { type HydrogenRequest } from './foundation/HydrogenRequest/HydrogenRequest.server';
|
|
43
|
+
export { type HydrogenResponse } from './foundation/HydrogenResponse/HydrogenResponse.server';
|
package/dist/esnext/index.js
CHANGED
|
@@ -16,12 +16,16 @@ export * from './foundation/useServerProps';
|
|
|
16
16
|
export { FileRoutes } from './foundation/FileRoutes/FileRoutes.server';
|
|
17
17
|
export { Route } from './foundation/Route/Route.server';
|
|
18
18
|
export { Router } from './foundation/Router/Router.server';
|
|
19
|
-
export { log
|
|
19
|
+
export { log } from './utilities/log';
|
|
20
20
|
export { LocalizationProvider } from './components/LocalizationProvider/LocalizationProvider.server';
|
|
21
21
|
export { ShopifyProvider } from './foundation/ShopifyProvider/ShopifyProvider.server';
|
|
22
|
-
export { generateCacheControlHeader, NoStore, CacheSeconds, CacheMinutes, CacheHours, CacheDays, CacheWeeks, CacheMonths, CacheCustom, } from './
|
|
22
|
+
export { generateCacheControlHeader, NoStore, CacheSeconds, CacheMinutes, CacheHours, CacheDays, CacheWeeks, CacheMonths, CacheCustom, } from './foundation/Cache/strategies';
|
|
23
|
+
export { useRequestContext } from './foundation/useRequestContext';
|
|
23
24
|
export { useServerAnalytics } from './foundation/Analytics/hook';
|
|
24
|
-
export
|
|
25
|
+
export { ShopifyAnalytics } from './foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server';
|
|
26
|
+
export { ShopifyAnalyticsConstants } from './foundation/Analytics/connectors/Shopify/const';
|
|
27
|
+
export * as ShopifyServerAnalyticsConnector from './foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server';
|
|
28
|
+
export * as PerformanceMetricsServerAnalyticsConnector from './foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server';
|
|
25
29
|
export { useSession } from './foundation/useSession/useSession';
|
|
26
30
|
export { CookieSessionStorage } from './foundation/CookieSessionStorage/CookieSessionStorage';
|
|
27
31
|
export { MemorySessionStorage } from './foundation/MemorySessionStorage/MemorySessionStorage';
|