@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,7 +1,9 @@
|
|
|
1
1
|
import { useServerRequest } from '../ServerRequestProvider';
|
|
2
|
+
import { mergeDeep } from './utils';
|
|
2
3
|
export function useServerAnalytics(data) {
|
|
3
4
|
const request = useServerRequest();
|
|
4
|
-
if (data)
|
|
5
|
-
request.ctx.analyticsData =
|
|
5
|
+
if (data) {
|
|
6
|
+
request.ctx.analyticsData = mergeDeep(request.ctx.analyticsData, data);
|
|
7
|
+
}
|
|
6
8
|
return request.ctx.analyticsData;
|
|
7
9
|
}
|
|
@@ -6,3 +6,24 @@ export function getNamedspacedEventname(eventname) {
|
|
|
6
6
|
? `c-${eventname}`
|
|
7
7
|
: eventname;
|
|
8
8
|
}
|
|
9
|
+
export function isObject(item) {
|
|
10
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
11
|
+
}
|
|
12
|
+
export function mergeDeep(target, ...sources) {
|
|
13
|
+
if (!sources.length)
|
|
14
|
+
return target;
|
|
15
|
+
const source = sources.shift();
|
|
16
|
+
if (isObject(target) && isObject(source)) {
|
|
17
|
+
for (const key in source) {
|
|
18
|
+
if (isObject(source[key])) {
|
|
19
|
+
if (!target[key])
|
|
20
|
+
Object.assign(target, { [key]: {} });
|
|
21
|
+
mergeDeep(target[key], source[key]);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
Object.assign(target, { [key]: source[key] });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return mergeDeep(target, ...sources);
|
|
29
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryKey, CachingStrategy } from '
|
|
1
|
+
import type { QueryKey, CachingStrategy } from '../../types';
|
|
2
2
|
export declare function generateSubRequestCacheControlHeader(userCacheOptions?: CachingStrategy): string;
|
|
3
3
|
/**
|
|
4
4
|
* Get an item from the cache. If a match is found, returns a tuple
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getCache } from '
|
|
2
|
-
import { hashKey } from '
|
|
1
|
+
import { getCache } from '../runtime';
|
|
2
|
+
import { hashKey } from '../../utilities/hash';
|
|
3
3
|
import * as CacheApi from './cache';
|
|
4
|
-
import { CacheSeconds } from './
|
|
4
|
+
import { CacheSeconds } from './strategies';
|
|
5
5
|
/**
|
|
6
6
|
* Wrapper Cache functions for sub queries
|
|
7
7
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CachingStrategy } from '
|
|
1
|
+
import type { CachingStrategy } from '../../types';
|
|
2
2
|
export declare function generateDefaultCacheControlHeader(userCacheOptions?: CachingStrategy): string;
|
|
3
3
|
/**
|
|
4
4
|
* Get an item from the cache. If a match is found, returns a tuple
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getCache } from '
|
|
2
|
-
import { CacheSeconds, generateCacheControlHeader
|
|
3
|
-
import { logCacheApiStatus } from '
|
|
1
|
+
import { getCache } from '../runtime';
|
|
2
|
+
import { CacheSeconds, generateCacheControlHeader } from './strategies';
|
|
3
|
+
import { logCacheApiStatus } from '../../utilities/log';
|
|
4
4
|
function getCacheControlSetting(userCacheOptions, options) {
|
|
5
5
|
if (userCacheOptions && options) {
|
|
6
6
|
return {
|
package/dist/{node/framework/CachingStrategy → esnext/foundation/Cache/strategies}/index.d.ts
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { CachingStrategy, AllCacheOptions, NoStoreStrategy } from '
|
|
1
|
+
import type { CachingStrategy, AllCacheOptions, NoStoreStrategy } from '../../../types';
|
|
2
|
+
export declare const NO_STORE = "no-store";
|
|
2
3
|
export declare function generateCacheControlHeader(cacheOptions: CachingStrategy): string;
|
|
3
4
|
export declare function NoStore(): NoStoreStrategy;
|
|
4
5
|
export declare function CacheSeconds(overrideOptions?: CachingStrategy): AllCacheOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare type CookieOptions = {
|
|
2
|
-
/** Whether to secure the cookie so that
|
|
3
|
-
* browsers [don't work with secure cookies on localhost](https://owasp.org/www-community/controls/SecureCookieAttribute).
|
|
2
|
+
/** Whether to secure the cookie so that [client-side JavaScript can't read the cookie](https://owasp.org/www-community/HttpOnly).
|
|
4
3
|
*/
|
|
5
4
|
httpOnly?: boolean;
|
|
6
|
-
/** Whether to secure the cookie so that
|
|
5
|
+
/** Whether to secure the cookie so that the browser only sends the cookie over HTTPS. Some
|
|
6
|
+
* browsers [don't work with secure cookies on localhost](https://owasp.org/www-community/controls/SecureCookieAttribute).
|
|
7
7
|
*/
|
|
8
8
|
secure?: boolean;
|
|
9
9
|
/** Declares that the cookie should be restricted to a first-party
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import type { HelmetData as HeadData } from 'react-helmet-async';
|
|
3
|
+
import { ResolvedHydrogenConfig } from '../../types';
|
|
3
4
|
declare type HtmlOptions = {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
template: string;
|
|
6
7
|
htmlAttrs?: Record<string, string>;
|
|
7
8
|
bodyAttrs?: Record<string, string>;
|
|
9
|
+
hydrogenConfig: ResolvedHydrogenConfig;
|
|
8
10
|
};
|
|
9
|
-
export declare function Html({ children, template, htmlAttrs, bodyAttrs }: HtmlOptions): JSX.Element;
|
|
11
|
+
export declare function Html({ children, template, htmlAttrs, bodyAttrs, hydrogenConfig, }: HtmlOptions): JSX.Element;
|
|
10
12
|
export declare function applyHtmlHead(html: string, head: HeadData, template: string): string;
|
|
11
13
|
export {};
|
|
@@ -21,7 +21,11 @@ function propsToAttrs(props) {
|
|
|
21
21
|
.map(([key, value]) => `${key === REACT_ATTR_MAP.class ? 'class' : key}="${value}"`)
|
|
22
22
|
.join(' ');
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const clientConfigOptions = [
|
|
25
|
+
'strictMode',
|
|
26
|
+
'showDevTools',
|
|
27
|
+
];
|
|
28
|
+
export function Html({ children, template, htmlAttrs, bodyAttrs, hydrogenConfig, }) {
|
|
25
29
|
let head = template.match(/<head>(.+?)<\/head>/s)[1] || '';
|
|
26
30
|
// @ts-ignore
|
|
27
31
|
if (import.meta.env.DEV) {
|
|
@@ -31,10 +35,19 @@ export function Html({ children, template, htmlAttrs, bodyAttrs }) {
|
|
|
31
35
|
'<script></script>' + // Fix for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1737882
|
|
32
36
|
head.replace(/>(\s*?import[\s\w]+?['"]\/@react-refresh)/, ' async="">$1');
|
|
33
37
|
}
|
|
38
|
+
const clientConfig = {};
|
|
39
|
+
for (const key of clientConfigOptions) {
|
|
40
|
+
if (hydrogenConfig[key] != null) {
|
|
41
|
+
clientConfig[key] = hydrogenConfig[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const clientConfigAttr = Object.keys(clientConfig).length > 0
|
|
45
|
+
? JSON.stringify(clientConfig)
|
|
46
|
+
: undefined;
|
|
34
47
|
return (React.createElement("html", { ...attrsToProps(getHtmlAttrs(template)), ...htmlAttrs },
|
|
35
48
|
React.createElement("head", { dangerouslySetInnerHTML: { __html: head } }),
|
|
36
49
|
React.createElement("body", { ...attrsToProps(getBodyAttrs(template)), ...bodyAttrs },
|
|
37
|
-
React.createElement("div", { id: "root" }, children))));
|
|
50
|
+
React.createElement("div", { id: "root", "data-client-config": clientConfigAttr }, children))));
|
|
38
51
|
}
|
|
39
52
|
export function applyHtmlHead(html, head, template) {
|
|
40
53
|
const { bodyAttrs, htmlAttrs, ...headTags } = extractHeadElements(head, template);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { ShopifyContextValue } from '
|
|
1
|
+
import type { ShopifyContextValue } from '../ShopifyProvider/types';
|
|
2
2
|
import type { QueryCacheControlHeaders } from '../../utilities/log/log-cache-header';
|
|
3
3
|
import type { QueryTiming } from '../../utilities/log/log-query-timeline';
|
|
4
4
|
import type { ResolvedHydrogenConfig, PreloadOptions, QueryKey } from '../../types';
|
|
5
5
|
import { HelmetData as HeadData } from 'react-helmet-async';
|
|
6
|
-
import { SessionSyncApi } from '
|
|
6
|
+
import { SessionSyncApi } from '../session/session';
|
|
7
|
+
export interface RuntimeContext {
|
|
8
|
+
waitUntil: (fn: Promise<any>) => void;
|
|
9
|
+
}
|
|
7
10
|
export declare type PreloadQueryEntry = {
|
|
8
11
|
key: QueryKey;
|
|
9
12
|
fetcher: () => Promise<unknown>;
|
|
@@ -23,7 +26,7 @@ export declare type RouterContextData = {
|
|
|
23
26
|
* - Adds a `cookies` map for easy access
|
|
24
27
|
* - Adds a static constructor to convert a Node.js `IncomingMessage` to a Request.
|
|
25
28
|
*/
|
|
26
|
-
export declare class
|
|
29
|
+
export declare class HydrogenRequest extends Request {
|
|
27
30
|
cookies: Map<string, string>;
|
|
28
31
|
id: string;
|
|
29
32
|
time: number;
|
|
@@ -40,6 +43,8 @@ export declare class ServerComponentRequest extends Request {
|
|
|
40
43
|
router: RouterContextData;
|
|
41
44
|
buyerIpHeader?: string;
|
|
42
45
|
session?: SessionSyncApi;
|
|
46
|
+
runtime?: RuntimeContext;
|
|
47
|
+
scopes: Map<string, Record<string, any>>;
|
|
43
48
|
[key: string]: any;
|
|
44
49
|
};
|
|
45
50
|
constructor(input: any);
|
|
@@ -20,7 +20,7 @@ const PRELOAD_ALL = '*';
|
|
|
20
20
|
* - Adds a `cookies` map for easy access
|
|
21
21
|
* - Adds a static constructor to convert a Node.js `IncomingMessage` to a Request.
|
|
22
22
|
*/
|
|
23
|
-
export class
|
|
23
|
+
export class HydrogenRequest extends Request {
|
|
24
24
|
constructor(input, init) {
|
|
25
25
|
if (input instanceof Request) {
|
|
26
26
|
super(input, init);
|
|
@@ -48,6 +48,7 @@ export class ServerComponentRequest extends Request {
|
|
|
48
48
|
normalizedRscUrl: this.normalizedUrl,
|
|
49
49
|
},
|
|
50
50
|
preloadQueries: new Map(),
|
|
51
|
+
scopes: new Map(),
|
|
51
52
|
};
|
|
52
53
|
this.cookies = this.parseCookies();
|
|
53
54
|
}
|
|
@@ -67,7 +68,7 @@ export class ServerComponentRequest extends Request {
|
|
|
67
68
|
if (typeof query.preload === 'string' && query.preload === PRELOAD_ALL) {
|
|
68
69
|
saveToPreloadAllPreload(query);
|
|
69
70
|
}
|
|
70
|
-
else
|
|
71
|
+
else {
|
|
71
72
|
this.ctx.preloadQueries.set(hashKey(query.key), query);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { CachingStrategy } from '../../types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class HydrogenResponse extends Response {
|
|
4
4
|
private wait;
|
|
5
5
|
private cacheOptions;
|
|
6
|
-
customStatus
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
private customStatus?;
|
|
7
|
+
private customStatusText?;
|
|
8
|
+
get status(): number;
|
|
9
|
+
set status(number: number);
|
|
10
|
+
get statusText(): string;
|
|
11
|
+
set statusText(text: string);
|
|
10
12
|
/**
|
|
11
13
|
* Buffer the current response until all queries have resolved,
|
|
12
14
|
* and prevent it from streaming back early.
|
|
@@ -15,11 +17,6 @@ export declare class ServerComponentResponse extends Response {
|
|
|
15
17
|
canStream(): boolean;
|
|
16
18
|
cache(options: CachingStrategy): void;
|
|
17
19
|
get cacheControlHeader(): string;
|
|
18
|
-
writeHead({ status, statusText, headers, }?: {
|
|
19
|
-
status?: number;
|
|
20
|
-
statusText?: string;
|
|
21
|
-
headers?: Record<string, any>;
|
|
22
|
-
}): void;
|
|
23
20
|
redirect(location: string, status?: number): React.FunctionComponentElement<{
|
|
24
21
|
to: string;
|
|
25
22
|
}>;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import { CacheSeconds, generateCacheControlHeader } from '../
|
|
2
|
-
import Redirect from '
|
|
1
|
+
import { CacheSeconds, generateCacheControlHeader } from '../Cache/strategies';
|
|
2
|
+
import Redirect from '../Redirect/Redirect.client';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
export class
|
|
4
|
+
export class HydrogenResponse extends Response {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
7
|
this.wait = false;
|
|
8
8
|
this.cacheOptions = CacheSeconds();
|
|
9
9
|
}
|
|
10
|
+
get status() {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = this.customStatus) !== null && _a !== void 0 ? _a : super.status;
|
|
13
|
+
}
|
|
14
|
+
set status(number) {
|
|
15
|
+
this.customStatus = number;
|
|
16
|
+
}
|
|
17
|
+
get statusText() {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = this.customStatusText) !== null && _a !== void 0 ? _a : super.statusText;
|
|
20
|
+
}
|
|
21
|
+
set statusText(text) {
|
|
22
|
+
this.customStatusText = text;
|
|
23
|
+
}
|
|
10
24
|
/**
|
|
11
25
|
* Buffer the current response until all queries have resolved,
|
|
12
26
|
* and prevent it from streaming back early.
|
|
@@ -23,19 +37,9 @@ export class ServerComponentResponse extends Response {
|
|
|
23
37
|
get cacheControlHeader() {
|
|
24
38
|
return generateCacheControlHeader(this.cacheOptions);
|
|
25
39
|
}
|
|
26
|
-
writeHead({ status, statusText, headers, } = {}) {
|
|
27
|
-
if (status || statusText) {
|
|
28
|
-
this.customStatus = { code: status, text: statusText };
|
|
29
|
-
}
|
|
30
|
-
if (headers) {
|
|
31
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
32
|
-
this.headers.set(key, value);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
40
|
redirect(location, status = 307) {
|
|
37
|
-
|
|
38
|
-
this.
|
|
41
|
+
this.status = status;
|
|
42
|
+
this.headers.set('location', location);
|
|
39
43
|
// in the case of an RSC request, instead render a client component that will redirect
|
|
40
44
|
return React.createElement(Redirect, { to: location });
|
|
41
45
|
}
|
|
@@ -11,30 +11,37 @@ export const BrowserRouter = ({ history: pHistory, children }) => {
|
|
|
11
11
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
12
12
|
const history = useMemo(() => pHistory || createBrowserHistory(), [pHistory]);
|
|
13
13
|
const [location, setLocation] = useState(history.location);
|
|
14
|
-
const [
|
|
14
|
+
const [scrollNeedsRestoration, setScrollNeedsRestoration] = useState(false);
|
|
15
15
|
const { pending, locationServerProps, setLocationServerProps } = useInternalServerProps();
|
|
16
16
|
useScrollRestoration({
|
|
17
17
|
location,
|
|
18
18
|
pending,
|
|
19
19
|
serverProps: locationServerProps,
|
|
20
|
-
|
|
21
|
-
onFinishNavigating: () =>
|
|
20
|
+
scrollNeedsRestoration,
|
|
21
|
+
onFinishNavigating: () => setScrollNeedsRestoration(false),
|
|
22
22
|
});
|
|
23
23
|
useLayoutEffect(() => {
|
|
24
|
-
const unlisten = history.listen(({ location: newLocation }) => {
|
|
24
|
+
const unlisten = history.listen(({ location: newLocation, action }) => {
|
|
25
|
+
var _a;
|
|
25
26
|
positions[location.key] = window.scrollY;
|
|
26
27
|
setLocationServerProps({
|
|
27
28
|
pathname: newLocation.pathname,
|
|
28
29
|
search: newLocation.search,
|
|
29
30
|
});
|
|
30
31
|
setLocation(newLocation);
|
|
31
|
-
|
|
32
|
+
const state = ((_a = newLocation.state) !== null && _a !== void 0 ? _a : {});
|
|
33
|
+
/**
|
|
34
|
+
* "pop" navigations, like forward/backward buttons, always restore scroll position
|
|
35
|
+
* regardless of what the original forward navigation intent was.
|
|
36
|
+
*/
|
|
37
|
+
const needsScrollRestoration = action === 'POP' || !!state.scroll;
|
|
38
|
+
setScrollNeedsRestoration(needsScrollRestoration);
|
|
32
39
|
});
|
|
33
40
|
return () => unlisten();
|
|
34
41
|
}, [
|
|
35
42
|
history,
|
|
36
43
|
location,
|
|
37
|
-
|
|
44
|
+
setScrollNeedsRestoration,
|
|
38
45
|
setLocation,
|
|
39
46
|
setLocationServerProps,
|
|
40
47
|
]);
|
|
@@ -65,7 +72,7 @@ function useBeforeUnload(callback) {
|
|
|
65
72
|
};
|
|
66
73
|
}, [callback]);
|
|
67
74
|
}
|
|
68
|
-
function useScrollRestoration({ location, pending, serverProps,
|
|
75
|
+
function useScrollRestoration({ location, pending, serverProps, scrollNeedsRestoration, onFinishNavigating, }) {
|
|
69
76
|
/**
|
|
70
77
|
* Browsers have an API for scroll restoration. We wait for the page to load first,
|
|
71
78
|
* in case the browser is able to restore scroll position automatically, and then
|
|
@@ -82,7 +89,7 @@ function useScrollRestoration({ location, pending, serverProps, locationChanged,
|
|
|
82
89
|
}, []));
|
|
83
90
|
useLayoutEffect(() => {
|
|
84
91
|
// The app has just loaded
|
|
85
|
-
if (isFirstLoad || !
|
|
92
|
+
if (isFirstLoad || !scrollNeedsRestoration) {
|
|
86
93
|
isFirstLoad = false;
|
|
87
94
|
return;
|
|
88
95
|
}
|
|
@@ -124,7 +131,7 @@ function useScrollRestoration({ location, pending, serverProps, locationChanged,
|
|
|
124
131
|
pending,
|
|
125
132
|
serverProps.pathname,
|
|
126
133
|
serverProps.search,
|
|
127
|
-
|
|
134
|
+
scrollNeedsRestoration,
|
|
128
135
|
onFinishNavigating,
|
|
129
136
|
]);
|
|
130
137
|
}
|
|
@@ -35,7 +35,7 @@ export function ServerPropsProvider({ initialServerProps, setServerPropsForRsc,
|
|
|
35
35
|
else {
|
|
36
36
|
newValue = input;
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (__HYDROGEN_DEV__) {
|
|
39
39
|
const privateProp = PRIVATE_PROPS.find((prop) => prop in newValue);
|
|
40
40
|
if (privateProp) {
|
|
41
41
|
console.warn(`Custom "${privateProp}" property in server state is ignored. Use a different name.`);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { PreloadQueriesByURL,
|
|
1
|
+
import type { PreloadQueriesByURL, HydrogenRequest } from '../HydrogenRequest/HydrogenRequest.server';
|
|
2
2
|
import type { QueryKey } from '../../types';
|
|
3
3
|
declare type ServerRequestProviderProps = {
|
|
4
|
-
|
|
5
|
-
request: ServerComponentRequest;
|
|
4
|
+
request: HydrogenRequest;
|
|
6
5
|
children: JSX.Element;
|
|
7
6
|
};
|
|
8
|
-
export declare function ServerRequestProvider({
|
|
9
|
-
export declare function useServerRequest():
|
|
7
|
+
export declare function ServerRequestProvider({ request, children, }: ServerRequestProviderProps): JSX.Element;
|
|
8
|
+
export declare function useServerRequest(): HydrogenRequest;
|
|
10
9
|
declare type RequestCacheResult<T> = {
|
|
11
10
|
data: T;
|
|
12
11
|
error?: never;
|
|
@@ -19,5 +18,5 @@ declare type RequestCacheResult<T> = {
|
|
|
19
18
|
* It will throw the promise if data is not ready.
|
|
20
19
|
*/
|
|
21
20
|
export declare function useRequestCacheData<T>(key: QueryKey, fetcher: () => T | Promise<T>): RequestCacheResult<T>;
|
|
22
|
-
export declare function preloadRequestCacheData(request:
|
|
21
|
+
export declare function preloadRequestCacheData(request: HydrogenRequest, preloadQueries?: PreloadQueriesByURL): void;
|
|
23
22
|
export {};
|
|
@@ -9,24 +9,30 @@ function requestCacheRSC() {
|
|
|
9
9
|
return new Map();
|
|
10
10
|
}
|
|
11
11
|
requestCacheRSC.key = Symbol.for('HYDROGEN_REQUEST');
|
|
12
|
+
function getInternalReactDispatcher() {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
15
|
+
.ReactCurrentDispatcher.current;
|
|
16
|
+
}
|
|
17
|
+
function isRsc() {
|
|
18
|
+
// This method is only available during RSC
|
|
19
|
+
return __HYDROGEN_TEST__ || !!getInternalReactDispatcher().getCacheForType;
|
|
20
|
+
}
|
|
12
21
|
// Note: use this only during RSC/Flight rendering. The React dispatcher
|
|
13
22
|
// for SSR/Fizz rendering does not implement getCacheForType.
|
|
14
23
|
function getCacheForType(resource) {
|
|
15
24
|
var _a;
|
|
16
|
-
const dispatcher =
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
19
|
-
.ReactCurrentDispatcher.current;
|
|
25
|
+
const dispatcher = getInternalReactDispatcher();
|
|
20
26
|
// @ts-ignore
|
|
21
|
-
if (
|
|
27
|
+
if (__HYDROGEN_TEST__ && !dispatcher.getCacheForType) {
|
|
22
28
|
// Jest does not have access to the RSC runtime, mock it here:
|
|
23
29
|
// @ts-ignore
|
|
24
30
|
return ((_a = globalThis.__jestRscCache) !== null && _a !== void 0 ? _a : (globalThis.__jestRscCache = resource()));
|
|
25
31
|
}
|
|
26
32
|
return dispatcher.getCacheForType(resource);
|
|
27
33
|
}
|
|
28
|
-
export function ServerRequestProvider({
|
|
29
|
-
if (
|
|
34
|
+
export function ServerRequestProvider({ request, children, }) {
|
|
35
|
+
if (isRsc()) {
|
|
30
36
|
// Save the request object in a React cache that is
|
|
31
37
|
// scoped to this current rendering.
|
|
32
38
|
const requestCache = getCacheForType(requestCacheRSC);
|
|
@@ -38,21 +44,12 @@ export function ServerRequestProvider({ isRSC, request, children, }) {
|
|
|
38
44
|
return (React.createElement(RequestContextSSR.Provider, { value: request }, children));
|
|
39
45
|
}
|
|
40
46
|
export function useServerRequest() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
const cache = getCacheForType(requestCacheRSC);
|
|
46
|
-
request = cache ? cache.get(requestCacheRSC.key) : null;
|
|
47
|
-
}
|
|
48
|
-
catch (_a) {
|
|
49
|
-
// If RSC cache failed it means this is not an RSC request.
|
|
50
|
-
// Try getting SSR context instead:
|
|
51
|
-
request = useContext(RequestContextSSR); // eslint-disable-line react-hooks/rules-of-hooks
|
|
52
|
-
}
|
|
47
|
+
var _a;
|
|
48
|
+
const request = isRsc()
|
|
49
|
+
? (_a = getCacheForType(requestCacheRSC)) === null || _a === void 0 ? void 0 : _a.get(requestCacheRSC.key)
|
|
50
|
+
: useContext(RequestContextSSR); // eslint-disable-line react-hooks/rules-of-hooks
|
|
53
51
|
if (!request) {
|
|
54
|
-
|
|
55
|
-
if (__DEV__ && typeof jest !== 'undefined') {
|
|
52
|
+
if (__HYDROGEN_TEST__) {
|
|
56
53
|
// Unit tests are not wrapped in ServerRequestProvider.
|
|
57
54
|
// This mocks it, instead of providing it in every test.
|
|
58
55
|
return { ctx: {} };
|
|
@@ -33,7 +33,7 @@ export function ServerStateProvider({ serverState, setServerState, children, })
|
|
|
33
33
|
}
|
|
34
34
|
if (!newValue)
|
|
35
35
|
return { ...prev };
|
|
36
|
-
if (
|
|
36
|
+
if (__HYDROGEN_DEV__) {
|
|
37
37
|
const privateProp = PRIVATE_PROPS.find((prop) => prop in newValue);
|
|
38
38
|
if (privateProp) {
|
|
39
39
|
console.warn(`Custom "${privateProp}" property in server state is ignored. Use a different name.`);
|
|
@@ -12,6 +12,7 @@ function makeShopifyContext(shopifyConfig) {
|
|
|
12
12
|
storeDomain: (_b = shopifyConfig === null || shopifyConfig === void 0 ? void 0 : shopifyConfig.storeDomain) === null || _b === void 0 ? void 0 : _b.replace(/^https?:\/\//, ''),
|
|
13
13
|
storefrontToken: shopifyConfig.storefrontToken,
|
|
14
14
|
storefrontApiVersion: shopifyConfig.storefrontApiVersion,
|
|
15
|
+
multipassSecret: shopifyConfig.multipassSecret,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
export const SHOPIFY_PROVIDER_CONTEXT_KEY = Symbol.for('SHOPIFY_PROVIDER_RSC');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../../utilities/log';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { HydrogenResponse } from '../HydrogenResponse/HydrogenResponse.server';
|
|
3
|
+
import type { HydrogenRequest } from '../HydrogenRequest/HydrogenRequest.server';
|
|
4
4
|
export declare type SessionSyncApi = {
|
|
5
5
|
get: () => Record<string, string>;
|
|
6
6
|
};
|
|
@@ -14,7 +14,7 @@ export declare type SessionStorageAdapter = {
|
|
|
14
14
|
set: (request: Request, value: Record<string, string>) => Promise<string>;
|
|
15
15
|
destroy: (request: Request) => Promise<string>;
|
|
16
16
|
};
|
|
17
|
-
export declare function getSyncSessionApi(request:
|
|
17
|
+
export declare function getSyncSessionApi(request: HydrogenRequest, componentResponse: HydrogenResponse, log: Logger, session?: SessionStorageAdapter): {
|
|
18
18
|
get(): any;
|
|
19
19
|
};
|
|
20
20
|
export declare const emptySessionImplementation: (log: Logger) => {
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* In the server, this file is transformed by Vite to inject server logic.
|
|
5
5
|
* NOTE: Do not remove SSR-prefixed comments in this file.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { HydrogenRequest } from './HydrogenRequest/HydrogenRequest.server';
|
|
8
8
|
export declare const META_ENV_SSR = false;
|
|
9
|
-
declare type ServerGetter<T> = (request:
|
|
9
|
+
declare type ServerGetter<T> = (request: HydrogenRequest) => T;
|
|
10
10
|
/**
|
|
11
11
|
* Isomorphic hook to access context data. It gives access to the current request
|
|
12
12
|
* when running on the server, and returns the provided client fallback in the browser.
|
|
@@ -5,6 +5,8 @@ declare type NavigationOptions = {
|
|
|
5
5
|
reloadDocument?: boolean;
|
|
6
6
|
/** The custom client state with the navigation. */
|
|
7
7
|
clientState?: any;
|
|
8
|
+
/** Whether to emulate natural browser behavior and restore scroll position on navigation. Defaults to true. */
|
|
9
|
+
scroll?: any;
|
|
8
10
|
};
|
|
9
11
|
/**
|
|
10
12
|
* The useNavigate hook imperatively navigates between routes.
|
|
@@ -5,10 +5,17 @@ import { useRouter } from '../Router/BrowserRouter.client';
|
|
|
5
5
|
export function useNavigate() {
|
|
6
6
|
const router = useRouter();
|
|
7
7
|
return (path, options = { replace: false, reloadDocument: false }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const state = {
|
|
10
|
+
...options === null || options === void 0 ? void 0 : options.clientState,
|
|
11
|
+
scroll: (_a = options === null || options === void 0 ? void 0 : options.scroll) !== null && _a !== void 0 ? _a : true,
|
|
12
|
+
};
|
|
8
13
|
// @todo wait for RSC and then change focus for a11y?
|
|
9
|
-
if (options === null || options === void 0 ? void 0 : options.replace)
|
|
10
|
-
router.history.replace(path,
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
if (options === null || options === void 0 ? void 0 : options.replace) {
|
|
15
|
+
router.history.replace(path, state);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
router.history.push(path, state);
|
|
19
|
+
}
|
|
13
20
|
};
|
|
14
21
|
}
|