@shopify/hydrogen 0.21.0 → 0.23.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 +304 -0
- package/dist/esnext/client.d.ts +1 -0
- package/dist/esnext/client.js +1 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +5 -5
- 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.d.ts +7 -4
- package/dist/esnext/components/CartProvider/CartProvider.client.js +22 -12
- package/dist/esnext/components/DevTools.client.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +11 -3
- package/dist/esnext/components/Image/Image.js +64 -13
- 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/MediaFile/MediaFile.js +3 -2
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +21 -0
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +140 -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/Seo/NoIndexSeo.client.d.ts +3 -0
- package/dist/esnext/components/Seo/NoIndexSeo.client.js +10 -0
- package/dist/esnext/components/Seo/Seo.client.d.ts +4 -0
- package/dist/esnext/components/Seo/Seo.client.js +3 -0
- package/dist/esnext/components/index.d.ts +1 -1
- package/dist/esnext/components/index.js +1 -1
- package/dist/esnext/config.d.ts +3 -3
- package/dist/esnext/entry-client.js +106 -9
- package/dist/esnext/entry-server.d.ts +3 -16
- package/dist/esnext/entry-server.js +281 -331
- package/dist/esnext/foundation/Analytics/Analytics.client.js +16 -14
- 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 +17 -15
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +7 -5
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +2 -2
- 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/index.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/index.js +0 -1
- 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 +1 -1
- package/dist/esnext/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +0 -0
- package/dist/esnext/foundation/Cookie/Cookie.d.ts +3 -3
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +5 -10
- 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} +9 -5
- package/dist/esnext/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +1 -1
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +23 -0
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.js +46 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.d.ts +2 -1
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +17 -10
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -3
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +4 -4
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +2 -2
- 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 -1
- 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.js +9 -6
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +2 -1
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +1 -1
- package/dist/esnext/framework/Hydration/rsc.js +4 -2
- package/dist/esnext/framework/middleware.js +1 -15
- package/dist/esnext/framework/plugin.js +4 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +6 -3
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +7 -48
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +5 -18
- 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/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +99 -0
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +4 -4
- package/dist/esnext/framework/viteception.d.ts +4 -0
- package/dist/esnext/framework/viteception.js +15 -0
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -2
- package/dist/esnext/hooks/useProductOptions/types.d.ts +16 -14
- 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.d.ts +1 -2
- package/dist/esnext/hooks/useShopQuery/hooks.js +12 -7
- package/dist/esnext/index.d.ts +30 -16
- package/dist/esnext/index.js +30 -20
- package/dist/esnext/storefront-api-types.d.ts +1 -1
- package/dist/esnext/streaming.server.d.ts +3 -2
- package/dist/esnext/streaming.server.js +0 -4
- package/dist/esnext/types.d.ts +43 -27
- package/dist/esnext/utilities/apiRoutes.d.ts +5 -6
- package/dist/esnext/utilities/apiRoutes.js +2 -8
- package/dist/esnext/utilities/fetch.d.ts +1 -2
- package/dist/esnext/utilities/fetch.js +1 -3
- package/dist/esnext/utilities/graphql-tag.d.ts +1 -0
- package/dist/esnext/utilities/graphql-tag.js +6 -0
- package/dist/esnext/utilities/graphql-tracker.d.ts +1 -1
- package/dist/esnext/utilities/graphql-tracker.js +4 -0
- package/dist/esnext/utilities/html-encoding.d.ts +0 -1
- package/dist/esnext/utilities/html-encoding.js +0 -8
- package/dist/esnext/utilities/index.d.ts +2 -2
- package/dist/esnext/utilities/index.js +2 -2
- 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 +28 -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 +26 -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 +550 -0
- package/dist/node/components/CartProvider/cart-queries.d.ts +10 -0
- package/dist/node/components/CartProvider/cart-queries.js +203 -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 +86 -0
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +86 -0
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.d.ts +85 -0
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +86 -0
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartFragment.d.ts +72 -0
- package/dist/node/components/CartProvider/graphql/CartFragment.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.d.ts +86 -0
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +86 -0
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +86 -0
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +86 -0
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.js +2 -0
- package/dist/node/components/CartProvider/graphql/CartQuery.d.ts +81 -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 +90 -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 +102 -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 +11 -3
- package/dist/node/components/Image/Image.js +63 -12
- 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 +167 -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 +3 -16
- package/dist/node/entry-server.js +280 -330
- package/dist/node/foundation/Analytics/Analytics.client.js +19 -17
- 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 +16 -14
- 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 +0 -1
- package/dist/node/foundation/Analytics/index.js +1 -3
- 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 +1 -1
- package/dist/node/{framework/CachingStrategy → foundation/Cache/strategies}/index.js +0 -0
- 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} +9 -5
- package/dist/node/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +3 -3
- package/dist/node/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +23 -0
- package/dist/node/foundation/HydrogenResponse/HydrogenResponse.server.js +53 -0
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +2 -1
- package/dist/node/foundation/Router/BrowserRouter.client.js +17 -10
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -3
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +4 -4
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +2 -2
- 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 +36 -0
- package/dist/node/foundation/useQuery/hooks.js +104 -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 +4 -2
- package/dist/node/framework/middleware.js +1 -15
- package/dist/node/framework/plugin.js +4 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +6 -3
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +6 -47
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +5 -18
- 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/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +105 -0
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +4 -4
- package/dist/node/framework/viteception.d.ts +4 -0
- package/dist/node/framework/viteception.js +19 -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 +29 -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 +1 -1
- package/dist/node/streaming.server.d.ts +3 -2
- package/dist/node/streaming.server.js +1 -6
- package/dist/node/types.d.ts +43 -27
- package/dist/node/utilities/apiRoutes.d.ts +5 -6
- package/dist/node/utilities/apiRoutes.js +2 -8
- package/dist/node/utilities/devtools.d.ts +11 -0
- package/dist/node/utilities/devtools.js +15 -0
- package/dist/node/utilities/fetch.d.ts +1 -2
- package/dist/node/utilities/fetch.js +1 -3
- 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/html-encoding.d.ts +0 -1
- package/dist/node/utilities/html-encoding.js +1 -10
- package/dist/node/utilities/index.d.ts +2 -2
- package/dist/node/utilities/index.js +3 -4
- 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 +6 -3
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +219 -51
- 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 +220 -52
- 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/Hydration/ServerComponentResponse.server.d.ts +0 -35
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +0 -61
- 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/findRoutePrefix.d.ts +0 -1
- package/dist/esnext/utilities/findRoutePrefix.js +0 -17
- 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/Hydration/ServerComponentResponse.server.d.ts +0 -35
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +0 -68
- 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/findRoutePrefix.d.ts +0 -1
- package/dist/node/utilities/findRoutePrefix.js +0 -21
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,309 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1389](https://github.com/Shopify/hydrogen/pull/1389) [`9a21108f`](https://github.com/Shopify/hydrogen/commit/9a21108f6ff89474db9ff8bec26733fcbe744bdc) Thanks [@blittle](https://github.com/blittle)! - **Breaking change**
|
|
8
|
+
|
|
9
|
+
The utility `isClient` has been renamed to `isBrowser`. This is because the utility really checks if the running context is a browser, _not_ if the context is a client component.
|
|
10
|
+
|
|
11
|
+
All client components by default also run on the server when they are server rendered. If you don't want that to happen, use the `isBrowser()` hook. Remember that anything not server rendered will be unavailable for SEO bots.
|
|
12
|
+
|
|
13
|
+
* [#1431](https://github.com/Shopify/hydrogen/pull/1431) [`6975bdb9`](https://github.com/Shopify/hydrogen/commit/6975bdb90cfdc03562d21cec09150c52ff31ff78) Thanks [@jplhomer](https://github.com/jplhomer)! - Add `scroll` prop to `Link` and `navigate` to allow the scroll restoration behavior to be disabled.
|
|
14
|
+
|
|
15
|
+
By default, when a `<Link>` component is clicked, Hydrogen emulates default browser behavior and attempts to restore the scroll position previously used in the visitor's session. For new pages, this defaults to scrolling to the top of the page.
|
|
16
|
+
|
|
17
|
+
However, if you are building a user interface that should fetch a new server components request and update the URL but not modify scroll position, then you can disable scroll restoration using the `scroll` prop:
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import {Link} from '@shopify/hydrogen';
|
|
21
|
+
export default function Index({request}) {
|
|
22
|
+
const url = new URL(request.normalizedUrl);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<p>Current param is: {url.searchParams.get('param')}</p>
|
|
27
|
+
<Link to="/?param=foo" scroll={false}>
|
|
28
|
+
Update param to foo
|
|
29
|
+
</Link>
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- [#1325](https://github.com/Shopify/hydrogen/pull/1325) [`572c18d1`](https://github.com/Shopify/hydrogen/commit/572c18d1893b212cfc3f1be3043a67dcca251629) Thanks [@wizardlyhel](https://github.com/wizardlyhel)! - - Fix clientAnalytics not waiting for all server analytics data before sending page view event
|
|
36
|
+
|
|
37
|
+
- Fix server analytics connector erroring out after more than 1 server analytics connectors are attached
|
|
38
|
+
- Shopify analytics components
|
|
39
|
+
|
|
40
|
+
# Updates to server analytics connectors
|
|
41
|
+
|
|
42
|
+
The server analytics connector interface has updated to
|
|
43
|
+
|
|
44
|
+
```jsx
|
|
45
|
+
export function request(
|
|
46
|
+
requestUrl: string,
|
|
47
|
+
requestHeader: Headers,
|
|
48
|
+
data?: any,
|
|
49
|
+
contentType?: string
|
|
50
|
+
): void {
|
|
51
|
+
// Do something with the analytic event.
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
# Introducing Shopify analytics
|
|
56
|
+
|
|
57
|
+
Optional analytics components that allows you to send ecommerce related analytics to
|
|
58
|
+
Shopify. Adding the Shopify analytics components will allow the Shopify admin - Analytics
|
|
59
|
+
dashboard to work.
|
|
60
|
+
|
|
61
|
+
For information, see [Shopify Analytics](https://shopify.dev/api/hydrogen/components/framework/shopifyanalytics)
|
|
62
|
+
|
|
63
|
+
* [#1334](https://github.com/Shopify/hydrogen/pull/1334) [`58e039d4`](https://github.com/Shopify/hydrogen/commit/58e039d45cf69b670628f9f7ea62cb7c2d8425d9) Thanks [@blittle](https://github.com/blittle)! - With the introduction of authenticated pages, we also now provide the ability to prevent pages from being indexed by bots. You can do so by passing `noindex` to the `Seo` component:
|
|
64
|
+
|
|
65
|
+
```jsx
|
|
66
|
+
<Seo type="noindex" data={{title: 'Login'}} />
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- [#1397](https://github.com/Shopify/hydrogen/pull/1397) [`fbd185ab`](https://github.com/Shopify/hydrogen/commit/fbd185ab47e7335992b7844af0ef0b0aea6d70a5) Thanks [@frehner](https://github.com/frehner)! - ## `<ProductProvider/>` and `<ProductOptionsProvider/>`
|
|
70
|
+
|
|
71
|
+
- `<ProductProvider/>` has been removed
|
|
72
|
+
- `<ProductPrice/>` was the only component left that used it; now it requires a `data` prop that takes in the product object
|
|
73
|
+
- `<ProductOptionsProvider/>` now maintains and provides the state that `useProductOptions` used to keep track of by itself. This change enables you to use multiple `useProductOptions` hook calls and have them share the same state (such as selected variant, options, etc.)
|
|
74
|
+
|
|
75
|
+
* [#1403](https://github.com/Shopify/hydrogen/pull/1403) [`979f8177`](https://github.com/Shopify/hydrogen/commit/979f81775a4bfa83276030da07cb012e6cb08e2f) Thanks [@frandiox](https://github.com/frandiox)! - **Breaking change**: The `setLogger` and `setLoggerOptions` utilities have been removed. The same information can now be passed under the `logger` property in Hydrogen config:
|
|
76
|
+
|
|
77
|
+
```diff
|
|
78
|
+
// App.server.jsx
|
|
79
|
+
|
|
80
|
+
-import {setLogger, setLoggerOptions} from '@shopify/hydrogen';
|
|
81
|
+
|
|
82
|
+
-setLogger({
|
|
83
|
+
- trace() {},
|
|
84
|
+
- error() {},
|
|
85
|
+
- // ...
|
|
86
|
+
-});
|
|
87
|
+
|
|
88
|
+
-setLoggerOptions({
|
|
89
|
+
- showQueryTiming: true,
|
|
90
|
+
- showCacheControlHeader: true,
|
|
91
|
+
- // ...
|
|
92
|
+
-});
|
|
93
|
+
|
|
94
|
+
function App() {
|
|
95
|
+
// ...
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default renderHydrogen(App);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```diff
|
|
102
|
+
// hydrogen.config.js
|
|
103
|
+
|
|
104
|
+
export default defineConfig({
|
|
105
|
+
// ...
|
|
106
|
+
+ logger: {
|
|
107
|
+
+ trace() {},
|
|
108
|
+
+ error() {},
|
|
109
|
+
+ showQueryTiming: true,
|
|
110
|
+
+ showCacheControlHeader: true,
|
|
111
|
+
+ // ...
|
|
112
|
+
+ },
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- [#1433](https://github.com/Shopify/hydrogen/pull/1433) [`cd354d3a`](https://github.com/Shopify/hydrogen/commit/cd354d3a6205b5a8ef14426040121ac620c8c158) Thanks [@frandiox](https://github.com/frandiox)! - The `response.writeHead` method has been removed, while `response.status` and `response.statusText` are now writable.
|
|
117
|
+
|
|
118
|
+
```diff
|
|
119
|
+
function App({response}) {
|
|
120
|
+
- response.writeHead({
|
|
121
|
+
- headers: {'custom-header': 'value'},
|
|
122
|
+
- status: 404,
|
|
123
|
+
- });
|
|
124
|
+
+ response.headers.set('custom-header', 'value');
|
|
125
|
+
+ response.status = 404;
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
* [#1418](https://github.com/Shopify/hydrogen/pull/1418) [`512cb009`](https://github.com/Shopify/hydrogen/commit/512cb009fadeb1907fafa2cef8b568081799335f) Thanks [@frandiox](https://github.com/frandiox)! - **Breaking change**: The client configuration, including the `strictMode` option, has been moved from custom client entry handlers to the Hydrogen configuration file. If you had a custom client entry file just to pass client options, you can remove it and do the same in `hydrogen.config.js`:
|
|
130
|
+
|
|
131
|
+
```diff
|
|
132
|
+
// Custom client entry handler
|
|
133
|
+
|
|
134
|
+
-renderHydrogen(ClientWrapper, {strictMode: false});
|
|
135
|
+
+renderHydrogen(ClientWrapper);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```diff
|
|
139
|
+
// hydrogen.config.jsx
|
|
140
|
+
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
+ strictMode: false,
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
To remove a custom client entry handler in case it's not needed anymore, delete the custom file and change `index.html`:
|
|
147
|
+
|
|
148
|
+
```diff
|
|
149
|
+
<body>
|
|
150
|
+
<div id="root"></div>
|
|
151
|
+
- <script type="module" src="/src/custom-client-entry"></script>
|
|
152
|
+
+ <script type="module" src="/@shopify/hydrogen/entry-client"></script>
|
|
153
|
+
</body>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- [#1401](https://github.com/Shopify/hydrogen/pull/1401) [`335b70ce`](https://github.com/Shopify/hydrogen/commit/335b70ce67f9f137875fcd18f32e00c1b1b4c533) Thanks [@frandiox](https://github.com/frandiox)! - **Breaking change**: The `enableStreaming` config option has been deprecated. The same feature can be done directly in the app:
|
|
157
|
+
|
|
158
|
+
```diff
|
|
159
|
+
// hydrogen.config.js
|
|
160
|
+
|
|
161
|
+
export default defineConfig({
|
|
162
|
+
shopify: {
|
|
163
|
+
// ...
|
|
164
|
+
},
|
|
165
|
+
- enableStreaming: (req) => {
|
|
166
|
+
- return req.headers.get('user-agent') !== 'custom bot';
|
|
167
|
+
- },
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```diff
|
|
172
|
+
// App.server.jsx
|
|
173
|
+
|
|
174
|
+
-function App() {
|
|
175
|
+
+function App({request, response}) {
|
|
176
|
+
+ if (request.headers.get('user-agent') === 'custom bot') {
|
|
177
|
+
+ response.doNotStream();
|
|
178
|
+
+ }
|
|
179
|
+
|
|
180
|
+
return <Suspense fallback={'Loading...'}>{/*...*/}</Suspense>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export default renderHydrogen(App);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- [#1425](https://github.com/Shopify/hydrogen/pull/1425) [`e213aa86`](https://github.com/Shopify/hydrogen/commit/e213aa8656b17bf649fef714befa99b9618aae45) Thanks [@frandiox](https://github.com/frandiox)! - Rename internal Hydrogen global variables that could conflict with third party libraries that use the same names.
|
|
189
|
+
|
|
190
|
+
* [#1361](https://github.com/Shopify/hydrogen/pull/1361) [`cf2ef664`](https://github.com/Shopify/hydrogen/commit/cf2ef664cd1e91bc53fc34698ac23797c398e74f) Thanks [@frandiox](https://github.com/frandiox)! - Improve component bundling to reduce the total amount of JS files downloaded in the browser.
|
|
191
|
+
|
|
192
|
+
- [#1452](https://github.com/Shopify/hydrogen/pull/1452) [`ed1586a7`](https://github.com/Shopify/hydrogen/commit/ed1586a758fd36bddcc422a75db8a7971ce946d5) Thanks [@frandiox](https://github.com/frandiox)! - Reduce CPU consumption when rendering React Server Components.
|
|
193
|
+
|
|
194
|
+
* [#1399](https://github.com/Shopify/hydrogen/pull/1399) [`583ce40c`](https://github.com/Shopify/hydrogen/commit/583ce40c97391bb22e6e15e736e6237e9a1ea085) Thanks [@frandiox](https://github.com/frandiox)! - Confusing warnings that are not actionable have been removed.
|
|
195
|
+
|
|
196
|
+
- [#1460](https://github.com/Shopify/hydrogen/pull/1460) [`18056879`](https://github.com/Shopify/hydrogen/commit/18056879f1ea1dc54f146184bfdd4f01f24df636) Thanks [@wizardlyhel](https://github.com/wizardlyhel)! - Fix doc links
|
|
197
|
+
|
|
198
|
+
* [#1444](https://github.com/Shopify/hydrogen/pull/1444) [`0b4ee487`](https://github.com/Shopify/hydrogen/commit/0b4ee4876998923f206f6d28b1a3ef95c9616e59) Thanks [@blittle](https://github.com/blittle)! - Propagate a better error message when the response from the storefront API is not JSON parseable
|
|
199
|
+
|
|
200
|
+
- [#1227](https://github.com/Shopify/hydrogen/pull/1227) [`8eae0a07`](https://github.com/Shopify/hydrogen/commit/8eae0a07ab02e61ac8742e42488825090ca0aa37) Thanks [@jplhomer](https://github.com/jplhomer)! - Enable streaming by default for all platforms
|
|
201
|
+
|
|
202
|
+
* [#1427](https://github.com/Shopify/hydrogen/pull/1427) [`7115d7d8`](https://github.com/Shopify/hydrogen/commit/7115d7d8dc291b7e5b4dda200baf8a906a005cc8) Thanks [@jplhomer](https://github.com/jplhomer)! - Properly support Node v18
|
|
203
|
+
|
|
204
|
+
- [#1424](https://github.com/Shopify/hydrogen/pull/1424) [`446c12bf`](https://github.com/Shopify/hydrogen/commit/446c12bffa08eadccfd27afe8b5f34c77a61d134) Thanks [@frandiox](https://github.com/frandiox)! - Custom loggers can return promises from their methods. Hydrogen will await for them after the current request is over but before the runtime instance ends.
|
|
205
|
+
|
|
206
|
+
* [#1423](https://github.com/Shopify/hydrogen/pull/1423) [`aaf9efa4`](https://github.com/Shopify/hydrogen/commit/aaf9efa45dc9453e95be8e3020c259368ac5f4d0) Thanks [@frandiox](https://github.com/frandiox)! - Workers context (e.g. `waitUntil`) is now scoped to the current request instead of globally available.
|
|
207
|
+
|
|
208
|
+
- [#1330](https://github.com/Shopify/hydrogen/pull/1330) [`c7dc6440`](https://github.com/Shopify/hydrogen/commit/c7dc644059206e7080c33d9f7e0096c168ae593e) Thanks [@ejfranco06](https://github.com/ejfranco06)! - [#1245] - Generate a default srcset for an image returned by the Shopify CDN on the Image component and allow using a custom set of `widths.`
|
|
209
|
+
|
|
210
|
+
## 0.22.1
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- [#1394](https://github.com/Shopify/hydrogen/pull/1394) [`3a681ac2`](https://github.com/Shopify/hydrogen/commit/3a681ac289cc7850f79bc080a445bc6c0b6926fb) Thanks [@jplhomer](https://github.com/jplhomer)! - Make graphql-tag a dependency instead of a devDependency
|
|
215
|
+
|
|
216
|
+
## 0.22.0
|
|
217
|
+
|
|
218
|
+
### Minor Changes
|
|
219
|
+
|
|
220
|
+
- [#930](https://github.com/Shopify/hydrogen/pull/930) [`750baf8f`](https://github.com/Shopify/hydrogen/commit/750baf8ff069d0e06fb92e78a142049a1ce2b1ae) Thanks [@michenly](https://github.com/michenly)! - With the introduction of authenticated pages, we also now provide the ability to prevent pages from being indexed by bots. You can do so by passing `noindex` to the `Seo` component:
|
|
221
|
+
|
|
222
|
+
```jsx
|
|
223
|
+
<Seo type="noindex" data={{title: 'Login'}} />
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
* [#1313](https://github.com/Shopify/hydrogen/pull/1313) [`ed1933e3`](https://github.com/Shopify/hydrogen/commit/ed1933e339927322d8008034982b05ff4590e6d8) Thanks [@frandiox](https://github.com/frandiox)! - **Breaking change**: The `routes` property in `hydrogen.config.js` file has been simplified. It is now a string that represents the path to the routes from the project root:
|
|
227
|
+
|
|
228
|
+
```diff
|
|
229
|
+
// hydrogen.config.js
|
|
230
|
+
|
|
231
|
+
export default defineConfig({
|
|
232
|
+
- routes: import('./src/routes/**/*.server.[jt](s|sx)'),
|
|
233
|
+
+ routes: '/src/routes',
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Its default value is `/src/routes` so this property can be removed when using this directory.
|
|
238
|
+
|
|
239
|
+
In the object syntax version, `dirPrefix` is removed and `files` becomes a string:
|
|
240
|
+
|
|
241
|
+
```diff
|
|
242
|
+
// hydrogen.config.js
|
|
243
|
+
|
|
244
|
+
export default defineConfig({
|
|
245
|
+
routes: {
|
|
246
|
+
- files: import('./src/routes/**/*.server.[jt](s|sx)'),
|
|
247
|
+
- dirPrefix: './src/routes',
|
|
248
|
+
+ files: '/src/routes',
|
|
249
|
+
basePath: '/',
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
- [#1332](https://github.com/Shopify/hydrogen/pull/1332) [`5ec1bc62`](https://github.com/Shopify/hydrogen/commit/5ec1bc62cf9e4348aa389d4154f8c80dccfb96bb) Thanks [@frandiox](https://github.com/frandiox)! - A new `gql` utility is exported from `@shopify/hydrogen` that replaces `graphql-tag` dependency when using `useShopQuery`. It helps reducing bundle size in production when compared to the original `graphql-tag`.
|
|
255
|
+
|
|
256
|
+
Before:
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
import gql from 'graphql-tag';
|
|
260
|
+
|
|
261
|
+
// ...
|
|
262
|
+
|
|
263
|
+
useShopQuery({
|
|
264
|
+
query: gql`...`,
|
|
265
|
+
// ...
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
After:
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
import {gql} from '@shopify/hydrogen';
|
|
273
|
+
|
|
274
|
+
// ...
|
|
275
|
+
|
|
276
|
+
useShopQuery({
|
|
277
|
+
query: gql`...`,
|
|
278
|
+
// ...
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
* [#1340](https://github.com/Shopify/hydrogen/pull/1340) [`631832ec`](https://github.com/Shopify/hydrogen/commit/631832ecaef26b918e774515ada6b80668ec5e4e) Thanks [@jplhomer](https://github.com/jplhomer)! - **Breaking change**: The `response.send()` function has been removed. Use `export async function api()` to send custom responses instead.
|
|
283
|
+
|
|
284
|
+
### Patch Changes
|
|
285
|
+
|
|
286
|
+
- [#1371](https://github.com/Shopify/hydrogen/pull/1371) [`84a2fd09`](https://github.com/Shopify/hydrogen/commit/84a2fd09b7150b1d5e1f92b786f4a6af09e18739) Thanks [@frehner](https://github.com/frehner)! - Made updates to `<Image/>`:
|
|
287
|
+
|
|
288
|
+
- Fixed some TypeScript type issues with Image.
|
|
289
|
+
- `data.url` and `alt` are now required props in Typescript, but won't break the actual component if you don't pass them.
|
|
290
|
+
|
|
291
|
+
* [#1348](https://github.com/Shopify/hydrogen/pull/1348) [`211093e5`](https://github.com/Shopify/hydrogen/commit/211093e5f1a9e2ad115eb667746bfa2c6dd05b82) Thanks [@developit](https://github.com/developit)! - Fix HTML double-decoding in flight response
|
|
292
|
+
|
|
293
|
+
- [#1345](https://github.com/Shopify/hydrogen/pull/1345) [`331ff3c0`](https://github.com/Shopify/hydrogen/commit/331ff3c0f58143df3e7c542116f9a94838710352) Thanks [@frandiox](https://github.com/frandiox)! - Reduce the amount of user app files downloaded in the browser.
|
|
294
|
+
|
|
295
|
+
* [#1322](https://github.com/Shopify/hydrogen/pull/1322) [`36bd77c4`](https://github.com/Shopify/hydrogen/commit/36bd77c4619ec071ea11b764bb16b5670b0afa6b) Thanks [@frandiox](https://github.com/frandiox)! - Fix server hanging in Node.js environment when not using Hydrogen Middleware.
|
|
296
|
+
|
|
297
|
+
- [#1360](https://github.com/Shopify/hydrogen/pull/1360) [`d9b0d03b`](https://github.com/Shopify/hydrogen/commit/d9b0d03b64d2207b314d15fc0acf6a5143610b92) Thanks [@blittle](https://github.com/blittle)! - Fix a problem where encoded html content props passed from server to client components would get double decoded, and break hydration on app load.
|
|
298
|
+
|
|
299
|
+
* [#1355](https://github.com/Shopify/hydrogen/pull/1355) [`c45a45e8`](https://github.com/Shopify/hydrogen/commit/c45a45e895b8407da04c6b4608e7f16170452c24) Thanks [@jplhomer](https://github.com/jplhomer)! - Ensure all Hydrogen components are exported properly
|
|
300
|
+
|
|
301
|
+
- [#1339](https://github.com/Shopify/hydrogen/pull/1339) [`fef4cb84`](https://github.com/Shopify/hydrogen/commit/fef4cb8496d985d37b6113865ac1252f78058aaa) Thanks [@jplhomer](https://github.com/jplhomer)! - Use `import.meta.env.DEV` instead of `process.env.LOCAL_DEV` to hash asset filenames and show performance metrics debugging
|
|
302
|
+
|
|
303
|
+
* [#1320](https://github.com/Shopify/hydrogen/pull/1320) [`7e9df897`](https://github.com/Shopify/hydrogen/commit/7e9df897465012cd0cf374a1a35deb2ca8a16fc3) Thanks [@jplhomer](https://github.com/jplhomer)! - Properly log errors during flight responses
|
|
304
|
+
|
|
305
|
+
- [#1363](https://github.com/Shopify/hydrogen/pull/1363) [`0941d3be`](https://github.com/Shopify/hydrogen/commit/0941d3be12b52edc045b898864435f591fc2c42e) Thanks [@frandiox](https://github.com/frandiox)! - Remove some server utilities from client build.
|
|
306
|
+
|
|
3
307
|
## 0.21.0
|
|
4
308
|
|
|
5
309
|
### Minor Changes
|
package/dist/esnext/client.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './foundation/ServerPropsProvider';
|
|
|
6
6
|
export * from './foundation/useUrl';
|
|
7
7
|
export { Head } from './foundation/Head';
|
|
8
8
|
export * from './utilities';
|
|
9
|
+
export { gql } from './utilities/graphql-tag';
|
|
9
10
|
export { ClientAnalytics } from './foundation/Analytics';
|
|
10
11
|
export { useRouteParams } from './foundation/useRouteParams/useRouteParams';
|
|
11
12
|
export { useNavigate } from './foundation/useNavigate/useNavigate';
|
package/dist/esnext/client.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './foundation/ServerPropsProvider';
|
|
|
6
6
|
export * from './foundation/useUrl';
|
|
7
7
|
export { Head } from './foundation/Head';
|
|
8
8
|
export * from './utilities';
|
|
9
|
+
export { gql } from './utilities/graphql-tag';
|
|
9
10
|
export { ClientAnalytics } from './foundation/Analytics';
|
|
10
11
|
export { useRouteParams } from './foundation/useRouteParams/useRouteParams';
|
|
11
12
|
export { useNavigate } from './foundation/useNavigate/useNavigate';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { useCart } from '../CartProvider';
|
|
3
|
-
import {
|
|
3
|
+
import { useProductOptions } from '../ProductOptionsProvider';
|
|
4
4
|
/**
|
|
5
5
|
* The `AddToCartButton` component renders a button that adds an item to the cart when pressed.
|
|
6
6
|
* It must be a descendent of the `CartProvider` component.
|
|
7
7
|
*/
|
|
8
8
|
export function AddToCartButton(props) {
|
|
9
|
-
var _a
|
|
9
|
+
var _a;
|
|
10
10
|
const [addingItem, setAddingItem] = useState(false);
|
|
11
11
|
const { variantId: explicitVariantId, quantity = 1, attributes, children, accessibleAddingToCartLabel, ...passthroughProps } = props;
|
|
12
12
|
const { status, linesAdd } = useCart();
|
|
13
|
-
const
|
|
14
|
-
const variantId = (
|
|
13
|
+
const { selectedVariant } = useProductOptions();
|
|
14
|
+
const variantId = (_a = explicitVariantId !== null && explicitVariantId !== void 0 ? explicitVariantId : selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.id) !== null && _a !== void 0 ? _a : '';
|
|
15
15
|
const disabled = explicitVariantId === null ||
|
|
16
16
|
variantId === '' ||
|
|
17
|
-
|
|
17
|
+
selectedVariant === null ||
|
|
18
18
|
addingItem ||
|
|
19
19
|
passthroughProps.disabled;
|
|
20
20
|
useEffect(() => {
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CartLines } from './CartLines';
|
|
1
|
+
export { CartLines } from './CartLines.client';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CartLines } from './CartLines';
|
|
1
|
+
export { CartLines } from './CartLines.client';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CartBuyerIdentityInput, CountryCode } from '../../storefront-api-types';
|
|
2
3
|
import { CartFragmentFragment } from './graphql/CartFragment';
|
|
3
4
|
/**
|
|
4
5
|
* The `CartProvider` component creates a context for using a cart. It creates a cart object and callbacks
|
|
@@ -9,7 +10,7 @@ import { CartFragmentFragment } from './graphql/CartFragment';
|
|
|
9
10
|
* The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
|
|
10
11
|
* You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
|
|
11
12
|
*/
|
|
12
|
-
export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment, }: {
|
|
13
|
+
export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment, customerAccessToken, countryCode, }: {
|
|
13
14
|
/** Any `ReactNode` elements. */
|
|
14
15
|
children: React.ReactNode;
|
|
15
16
|
numCartLines?: number;
|
|
@@ -29,10 +30,12 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
|
|
|
29
30
|
onAttributesUpdate?: () => void;
|
|
30
31
|
/** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */
|
|
31
32
|
onDiscountCodesUpdate?: () => void;
|
|
32
|
-
/**
|
|
33
|
-
* An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart).
|
|
34
|
-
*/
|
|
33
|
+
/** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart). */
|
|
35
34
|
data?: CartFragmentFragment;
|
|
36
35
|
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
|
|
37
36
|
cartFragment?: string;
|
|
37
|
+
/** A customer access token that's accessible on the server if there's a customer login. */
|
|
38
|
+
customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];
|
|
39
|
+
/** The ISO country code for i18n. */
|
|
40
|
+
countryCode?: CountryCode;
|
|
38
41
|
}): JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, useCallback, useReducer, useMemo, useRef, } from 'react';
|
|
2
|
-
import { flattenConnection } from '../../utilities';
|
|
2
|
+
import { flattenConnection } from '../../utilities/flattenConnection';
|
|
3
3
|
import { CartLineAdd, CartCreate, CartLineRemove, CartLineUpdate, CartNoteUpdate, CartBuyerIdentityUpdate, CartAttributesUpdate, CartDiscountCodesUpdate, CartQuery, defaultCartFragment, } from './cart-queries';
|
|
4
|
+
import { CountryCode, } from '../../storefront-api-types';
|
|
4
5
|
import { useCartFetch } from './hooks.client';
|
|
5
6
|
import { CartContext } from './context';
|
|
6
7
|
import { CART_ID_STORAGE_KEY } from './constants';
|
|
7
|
-
import {
|
|
8
|
-
import { ClientAnalytics } from '../../foundation/Analytics';
|
|
8
|
+
import { ClientAnalytics } from '../../foundation/Analytics/ClientAnalytics';
|
|
9
9
|
function cartReducer(state, action) {
|
|
10
10
|
switch (action.type) {
|
|
11
11
|
case 'cartFetch': {
|
|
@@ -150,10 +150,7 @@ function cartReducer(state, action) {
|
|
|
150
150
|
* The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
|
|
151
151
|
* You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
|
|
152
152
|
*/
|
|
153
|
-
export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment = defaultCartFragment, }) {
|
|
154
|
-
var _a;
|
|
155
|
-
const { serverProps } = useServerProps();
|
|
156
|
-
const countryCode = (_a = serverProps === null || serverProps === void 0 ? void 0 : serverProps.country) === null || _a === void 0 ? void 0 : _a.isoCode;
|
|
153
|
+
export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment = defaultCartFragment, customerAccessToken, countryCode = CountryCode.Us, }) {
|
|
157
154
|
const initialStatus = cart
|
|
158
155
|
? { status: 'idle', cart: cartFromGraphQL(cart) }
|
|
159
156
|
: { status: 'uninitialized' };
|
|
@@ -177,7 +174,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
|
|
|
177
174
|
dispatch({ type: 'resolve', cart: cartFromGraphQL(data.cart) });
|
|
178
175
|
}, [fetchCart, cartFragment, numCartLines, countryCode]);
|
|
179
176
|
const cartCreate = useCallback(async (cart) => {
|
|
180
|
-
var _a, _b;
|
|
177
|
+
var _a, _b, _c;
|
|
181
178
|
dispatch({ type: 'cartCreate' });
|
|
182
179
|
onCreate === null || onCreate === void 0 ? void 0 : onCreate();
|
|
183
180
|
if (countryCode && !((_a = cart.buyerIdentity) === null || _a === void 0 ? void 0 : _a.countryCode)) {
|
|
@@ -186,6 +183,12 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
|
|
|
186
183
|
}
|
|
187
184
|
cart.buyerIdentity.countryCode = countryCode;
|
|
188
185
|
}
|
|
186
|
+
if (customerAccessToken && !((_b = cart.buyerIdentity) === null || _b === void 0 ? void 0 : _b.customerAccessToken)) {
|
|
187
|
+
if (cart.buyerIdentity == null) {
|
|
188
|
+
cart.buyerIdentity = {};
|
|
189
|
+
}
|
|
190
|
+
cart.buyerIdentity.customerAccessToken = customerAccessToken;
|
|
191
|
+
}
|
|
189
192
|
const { data, error } = await fetchCart({
|
|
190
193
|
query: CartCreate(cartFragment),
|
|
191
194
|
variables: {
|
|
@@ -200,7 +203,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
|
|
|
200
203
|
error,
|
|
201
204
|
});
|
|
202
205
|
}
|
|
203
|
-
if ((
|
|
206
|
+
if ((_c = data === null || data === void 0 ? void 0 : data.cartCreate) === null || _c === void 0 ? void 0 : _c.cart) {
|
|
204
207
|
if (cart.lines) {
|
|
205
208
|
ClientAnalytics.publish(ClientAnalytics.eventNames.ADD_TO_CART, true, {
|
|
206
209
|
addedCartLines: cart.lines,
|
|
@@ -213,7 +216,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
|
|
|
213
216
|
});
|
|
214
217
|
window.localStorage.setItem(CART_ID_STORAGE_KEY, data.cartCreate.cart.id);
|
|
215
218
|
}
|
|
216
|
-
}, [
|
|
219
|
+
}, [
|
|
220
|
+
onCreate,
|
|
221
|
+
countryCode,
|
|
222
|
+
fetchCart,
|
|
223
|
+
cartFragment,
|
|
224
|
+
numCartLines,
|
|
225
|
+
customerAccessToken,
|
|
226
|
+
]);
|
|
217
227
|
const addLineItem = useCallback(async (lines, state) => {
|
|
218
228
|
var _a;
|
|
219
229
|
if (state.status === 'idle') {
|
|
@@ -439,9 +449,9 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
|
|
|
439
449
|
if (state.status !== 'idle') {
|
|
440
450
|
return;
|
|
441
451
|
}
|
|
442
|
-
buyerIdentityUpdate({ countryCode }, state);
|
|
452
|
+
buyerIdentityUpdate({ countryCode, customerAccessToken }, state);
|
|
443
453
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
444
|
-
}, [countryCode]);
|
|
454
|
+
}, [countryCode, customerAccessToken]);
|
|
445
455
|
const cartContextValue = useMemo(() => {
|
|
446
456
|
return {
|
|
447
457
|
...('cart' in state
|
|
@@ -55,7 +55,7 @@ export default function DevTools() {
|
|
|
55
55
|
React.createElement("path", { d: "M64.9548 106.281L27.1377 86.1894L40.0714 79.3723L54.6329 87.1049L66.851 80.6638L52.2895 72.9313L65.2231 66.0979L103.04 86.1894L90.1065 93.0064L76.35 85.6989L64.114 92.1563L77.8884 99.4638L64.9548 106.281Z", fill: "white" }),
|
|
56
56
|
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M65.2247 25L105.178 46.2267L90.105 54.1716L76.3488 46.8642L66.2525 52.1924L80.028 59.5005L64.9532 67.446L25 46.2196L40.0734 38.2748L54.6349 46.0073L64.713 40.6944L50.1533 32.9628L65.2247 25ZM54.4262 32.9673L68.9896 40.7008L54.6315 48.27L40.0699 40.5374L29.276 46.2267L64.9569 65.1833L75.7495 59.4947L61.9761 52.1878L76.3518 44.6012L90.1087 51.9088L100.902 46.2196L65.2221 27.2634L54.4262 32.9673Z", fill: "white" })));
|
|
57
57
|
if (import.meta.env.DEV && hasMounted) {
|
|
58
|
-
return (React.createElement("div", { style: {
|
|
58
|
+
return (React.createElement("div", { id: "hydrogen-dev-tools", style: {
|
|
59
59
|
position: 'fixed',
|
|
60
60
|
right: open ? 0 : '2em',
|
|
61
61
|
left: open ? 0 : '2em',
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { Image as ImageType } from '../../storefront-api-types';
|
|
3
3
|
import type { PartialDeep, Simplify, SetRequired } from 'type-fest';
|
|
4
4
|
declare type HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
5
|
-
declare type ImageProps<GenericLoaderOpts> =
|
|
5
|
+
declare type ImageProps<GenericLoaderOpts> = ShopifyImageProps | ExternalImageProps<GenericLoaderOpts>;
|
|
6
6
|
export declare function Image<GenericLoaderOpts>(props: ImageProps<GenericLoaderOpts>): JSX.Element;
|
|
7
7
|
export declare type ShopifyLoaderOptions = {
|
|
8
8
|
crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
@@ -19,7 +19,7 @@ export declare type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {
|
|
|
19
19
|
* The `data` prop is required if `src` isn't used, but both props shouldn't be used
|
|
20
20
|
* at the same time. If both `src` and `data` are passed, then `data` takes priority.
|
|
21
21
|
*/
|
|
22
|
-
data: PartialDeep<ImageType>;
|
|
22
|
+
data: SetRequired<PartialDeep<ImageType>, 'url'>;
|
|
23
23
|
/** A custom function that generates the image URL. Parameters passed in
|
|
24
24
|
* are either `ShopifyLoaderParams` if using the `data` prop, or the
|
|
25
25
|
* `LoaderOptions` object that you pass to `loaderOptions`.
|
|
@@ -37,6 +37,10 @@ export declare type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {
|
|
|
37
37
|
* 'src' shouldn't be passed when 'data' is used.
|
|
38
38
|
*/
|
|
39
39
|
src?: never;
|
|
40
|
+
/**
|
|
41
|
+
* An array of pixel widths to overwrite the default generated srcset. For example, `[300, 600, 800]`.
|
|
42
|
+
*/
|
|
43
|
+
widths?: (HtmlImageProps['width'] | ImageType['width'])[];
|
|
40
44
|
};
|
|
41
45
|
declare type LoaderProps<GenericLoaderOpts> = {
|
|
42
46
|
/** A URL string. This string can be an absolute path or a relative path depending
|
|
@@ -62,7 +66,7 @@ declare type LoaderProps<GenericLoaderOpts> = {
|
|
|
62
66
|
*/
|
|
63
67
|
loaderOptions?: GenericLoaderOpts;
|
|
64
68
|
};
|
|
65
|
-
declare type ExternalImageProps<GenericLoaderOpts> = SetRequired<HtmlImageProps, 'src' | 'width' | 'height'> & {
|
|
69
|
+
declare type ExternalImageProps<GenericLoaderOpts> = SetRequired<HtmlImageProps, 'src' | 'width' | 'height' | 'alt'> & {
|
|
66
70
|
/** A custom function that generates the image URL. Parameters passed in
|
|
67
71
|
* are either `ShopifyLoaderParams` if using the `data` prop, or the
|
|
68
72
|
* `LoaderOptions` object that you pass to `loaderOptions`.
|
|
@@ -80,5 +84,9 @@ declare type ExternalImageProps<GenericLoaderOpts> = SetRequired<HtmlImageProps,
|
|
|
80
84
|
* 'data' shouldn't be passed when 'src' is used.
|
|
81
85
|
*/
|
|
82
86
|
data?: never;
|
|
87
|
+
/**
|
|
88
|
+
* An array of pixel widths to generate a srcset. For example, `[300, 600, 800]`.
|
|
89
|
+
*/
|
|
90
|
+
widths?: HtmlImageProps['width'][];
|
|
83
91
|
};
|
|
84
92
|
export {};
|