@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
|
@@ -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
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getLoggerWithContext, collectQueryCacheControlHeaders, collectQueryTimings, } from '../../utilities/log';
|
|
2
|
-
import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '
|
|
3
|
-
import { runDelayedFunction } from '../../framework/runtime';
|
|
2
|
+
import { deleteItemFromCache, generateSubRequestCacheControlHeader, getItemFromCache, isStale, setItemInCache, } from '../Cache/cache-sub-request';
|
|
4
3
|
import { useRequestCacheData, useServerRequest } from '../ServerRequestProvider';
|
|
5
|
-
import { CacheSeconds } from '
|
|
4
|
+
import { CacheSeconds } from '../Cache/strategies';
|
|
6
5
|
/**
|
|
7
6
|
* The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
|
|
8
7
|
* supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
|
|
@@ -44,6 +43,7 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
44
43
|
* Attempt to read the query from cache. If it doesn't exist or if it's stale, regenerate it.
|
|
45
44
|
*/
|
|
46
45
|
async function useCachedQueryFn() {
|
|
46
|
+
var _a, _b, _c, _d;
|
|
47
47
|
// Call this hook before running any async stuff
|
|
48
48
|
// to prevent losing the current React cycle.
|
|
49
49
|
const request = useServerRequest();
|
|
@@ -60,8 +60,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
60
60
|
*/
|
|
61
61
|
if (isStale(key, response)) {
|
|
62
62
|
const lockKey = ['lock', ...(typeof key === 'string' ? [key] : key)];
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// Run revalidation asynchronously
|
|
64
|
+
const revalidatingPromise = getItemFromCache(lockKey).then(async (lockExists) => {
|
|
65
65
|
if (lockExists)
|
|
66
66
|
return;
|
|
67
67
|
await setItemInCache(lockKey, true, CacheSeconds({
|
|
@@ -80,6 +80,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
80
80
|
await deleteItemFromCache(lockKey);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
+
// Asynchronously wait for it in workers
|
|
84
|
+
(_b = (_a = request.ctx.runtime) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.call(_a, revalidatingPromise);
|
|
83
85
|
}
|
|
84
86
|
return output;
|
|
85
87
|
}
|
|
@@ -88,7 +90,8 @@ function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
|
88
90
|
* Important: Do this async
|
|
89
91
|
*/
|
|
90
92
|
if (shouldCacheResponse(newOutput)) {
|
|
91
|
-
|
|
93
|
+
const setItemInCachePromise = setItemInCache(key, newOutput, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
|
|
94
|
+
(_d = (_c = request.ctx.runtime) === null || _c === void 0 ? void 0 : _c.waitUntil) === null || _d === void 0 ? void 0 : _d.call(_c, setItemInCachePromise);
|
|
92
95
|
}
|
|
93
96
|
collectQueryCacheControlHeaders(request, key, generateSubRequestCacheControlHeader(resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache));
|
|
94
97
|
return newOutput;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
2
|
declare type RouteParamsContextValue = {
|
|
3
3
|
routeParams: Record<string, string>;
|
|
4
4
|
};
|
|
5
5
|
export declare const RouteParamsContext: React.Context<RouteParamsContextValue>;
|
|
6
6
|
export declare const RouteParamsProvider: FC<{
|
|
7
7
|
routeParams: Record<string, string>;
|
|
8
|
+
children: ReactNode;
|
|
8
9
|
}>;
|
|
9
10
|
export {};
|
|
@@ -2,6 +2,6 @@ import React, { createContext } from 'react';
|
|
|
2
2
|
export const RouteParamsContext = createContext({
|
|
3
3
|
routeParams: {},
|
|
4
4
|
});
|
|
5
|
-
export const RouteParamsProvider = ({ children, routeParams
|
|
5
|
+
export const RouteParamsProvider = ({ children, routeParams }) => {
|
|
6
6
|
return (React.createElement(RouteParamsContext.Provider, { value: { routeParams } }, children));
|
|
7
7
|
};
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
import { createFromFetch, createFromReadableStream,
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
} from '@shopify/hydrogen/vendor/react-server-dom-vite';
|
|
6
|
+
import { ClientAnalytics } from '../../client';
|
|
6
7
|
import { RSC_PATHNAME } from '../../constants';
|
|
7
|
-
import { htmlDecode } from '../../utilities';
|
|
8
8
|
let rscReader;
|
|
9
9
|
// Hydrate an SSR response from <meta> tags placed in the DOM.
|
|
10
10
|
const flightChunks = [];
|
|
11
11
|
const FLIGHT_ATTRIBUTE = 'data-flight';
|
|
12
12
|
function addElementToFlightChunks(el) {
|
|
13
|
+
// We don't need to decode, because `.getAttribute` already decodes
|
|
13
14
|
const chunk = el.getAttribute(FLIGHT_ATTRIBUTE);
|
|
14
15
|
if (chunk) {
|
|
15
|
-
flightChunks.push(
|
|
16
|
+
flightChunks.push(chunk);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
// Get initial payload
|
|
@@ -88,6 +89,7 @@ export function useServerResponse(state) {
|
|
|
88
89
|
/* @ts-ignore */
|
|
89
90
|
window.BOOMR.plugins.Hydrogen.trackSubPageLoadPerformance();
|
|
90
91
|
}
|
|
92
|
+
ClientAnalytics.resetPageAnalyticsData();
|
|
91
93
|
// Request a new flight response.
|
|
92
94
|
response = createFromFetch(fetch(`${RSC_PATHNAME}?state=` + encodeURIComponent(key)));
|
|
93
95
|
}
|
|
@@ -49,26 +49,12 @@ export function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypo
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
entrypointError = null;
|
|
52
|
-
|
|
52
|
+
await handleRequest(request, {
|
|
53
53
|
dev,
|
|
54
54
|
cache,
|
|
55
55
|
indexTemplate,
|
|
56
56
|
streamableResponse: response,
|
|
57
57
|
});
|
|
58
|
-
/**
|
|
59
|
-
* If a `Response` was returned, that means it was not streamed.
|
|
60
|
-
* Convert the response into a proper Node.js response.
|
|
61
|
-
*/
|
|
62
|
-
if (eventResponse) {
|
|
63
|
-
eventResponse.headers.forEach((value, key) => {
|
|
64
|
-
response.setHeader(key, value);
|
|
65
|
-
});
|
|
66
|
-
response.statusCode = eventResponse.status;
|
|
67
|
-
if (eventResponse.body) {
|
|
68
|
-
response.write(eventResponse.body);
|
|
69
|
-
}
|
|
70
|
-
response.end();
|
|
71
|
-
}
|
|
72
58
|
}
|
|
73
59
|
catch (e) {
|
|
74
60
|
if (dev && devServer)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import hydrogenConfig from './plugins/vite-plugin-hydrogen-config';
|
|
2
2
|
import hydrogenMiddleware from './plugins/vite-plugin-hydrogen-middleware';
|
|
3
3
|
import hydrogenClientMiddleware from './plugins/vite-plugin-hydrogen-client-middleware';
|
|
4
|
+
import hydrogenVirtualFiles from './plugins/vite-plugin-hydrogen-virtual-files';
|
|
4
5
|
import platformEntry from './plugins/vite-plugin-platform-entry';
|
|
5
6
|
import rsc from './plugins/vite-plugin-hydrogen-rsc';
|
|
6
7
|
import ssrInterop from './plugins/vite-plugin-ssr-interop';
|
|
@@ -10,6 +11,7 @@ import inspect from 'vite-plugin-inspect';
|
|
|
10
11
|
import react from '@vitejs/plugin-react';
|
|
11
12
|
import cssModulesRsc from './plugins/vite-plugin-css-modules-rsc';
|
|
12
13
|
import clientImports from './plugins/vite-plugin-client-imports';
|
|
14
|
+
import suppressWarnings from './plugins/vite-plugin-hydrogen-suppress-warnings';
|
|
13
15
|
export default (pluginOptions = {}) => {
|
|
14
16
|
return [
|
|
15
17
|
process.env.VITE_INSPECT && inspect(),
|
|
@@ -17,12 +19,14 @@ export default (pluginOptions = {}) => {
|
|
|
17
19
|
hydrogenClientMiddleware(),
|
|
18
20
|
clientImports(),
|
|
19
21
|
hydrogenMiddleware(pluginOptions),
|
|
22
|
+
hydrogenVirtualFiles(pluginOptions),
|
|
20
23
|
react(),
|
|
21
24
|
hydrationAutoImport(),
|
|
22
25
|
ssrInterop(),
|
|
23
26
|
cssModulesRsc(),
|
|
24
27
|
rsc(),
|
|
25
28
|
platformEntry(),
|
|
29
|
+
suppressWarnings(),
|
|
26
30
|
pluginOptions.purgeQueryCacheOnBuild && purgeQueryCache(),
|
|
27
31
|
];
|
|
28
32
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Plugin } from 'vite';
|
|
2
|
-
declare const _default: () => Plugin;
|
|
3
2
|
/**
|
|
4
3
|
* This dev server middleware prevents Vite from applying immutable cache control headers to client
|
|
5
4
|
* components. These client components are part of the user's local source, but since they are
|
|
6
5
|
* referenced via import globs in the `react-dom-server-vite` NPM package, Vite assumes they
|
|
7
6
|
* are 3P deps that can be cached. This middleware responds to the requests early with `no-cache`.
|
|
8
7
|
*/
|
|
8
|
+
declare const _default: () => Plugin;
|
|
9
9
|
export default _default;
|
|
@@ -12,7 +12,7 @@ export default () => {
|
|
|
12
12
|
format: 'es',
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
if (
|
|
15
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
16
16
|
/**
|
|
17
17
|
* Ofuscate production asset name - To prevent ad blocker logics that blocks
|
|
18
18
|
* certain files due to how it is named.
|
|
@@ -82,11 +82,14 @@ export default () => {
|
|
|
82
82
|
'react-server-dom-vite/client-proxy',
|
|
83
83
|
// https://github.com/vitejs/vite/issues/6215
|
|
84
84
|
'react/jsx-runtime',
|
|
85
|
+
// https://github.com/nfriedly/set-cookie-parser/issues/50
|
|
86
|
+
'set-cookie-parser',
|
|
85
87
|
],
|
|
86
88
|
},
|
|
87
89
|
define: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
__HYDROGEN_DEV__: env.mode !== 'production',
|
|
91
|
+
__HYDROGEN_WORKER__: isWorker,
|
|
92
|
+
__HYDROGEN_TEST__: false, // Used in unit tests
|
|
90
93
|
},
|
|
91
94
|
envPrefix: ['VITE_', 'PUBLIC_'],
|
|
92
95
|
base: process.env.HYDROGEN_ASSET_BASE_URL,
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { loadEnv
|
|
1
|
+
import { loadEnv } from 'vite';
|
|
2
2
|
import bodyParser from 'body-parser';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { promises as fs } from 'fs';
|
|
5
5
|
import { hydrogenMiddleware, graphiqlMiddleware } from '../middleware';
|
|
6
6
|
import { InMemoryCache } from '../cache/in-memory';
|
|
7
|
+
import { VIRTUAL_PROXY_HYDROGEN_CONFIG_ID } from './vite-plugin-hydrogen-virtual-files';
|
|
7
8
|
export const HYDROGEN_DEFAULT_SERVER_ENTRY = process.env.HYDROGEN_SERVER_ENTRY || '/src/App.server';
|
|
8
|
-
const virtualModuleId = 'virtual:hydrogen-config';
|
|
9
|
-
const virtualProxyModuleId = virtualModuleId + ':proxy';
|
|
10
9
|
export default (pluginOptions) => {
|
|
11
|
-
let config;
|
|
12
10
|
return {
|
|
13
|
-
name: '
|
|
14
|
-
configResolved(_config) {
|
|
15
|
-
config = _config;
|
|
16
|
-
},
|
|
11
|
+
name: 'hydrogen:middleware',
|
|
17
12
|
/**
|
|
18
13
|
* By adding a middleware to the Vite dev server, we can handle SSR without needing
|
|
19
14
|
* a custom node script. It works by handling any requests for `text/html` documents,
|
|
@@ -33,7 +28,7 @@ export default (pluginOptions) => {
|
|
|
33
28
|
dev: true,
|
|
34
29
|
getShopifyConfig: async (incomingMessage) => {
|
|
35
30
|
var _a;
|
|
36
|
-
const { default: hydrogenConfig } = await server.ssrLoadModule(
|
|
31
|
+
const { default: hydrogenConfig } = await server.ssrLoadModule(VIRTUAL_PROXY_HYDROGEN_CONFIG_ID);
|
|
37
32
|
// @ts-ignore
|
|
38
33
|
const { address = 'localhost', port = '3000' } = ((_a = server.httpServer) === null || _a === void 0 ? void 0 : _a.address()) || {};
|
|
39
34
|
const url = new URL(`http://${address}:${port}${incomingMessage.url}`);
|
|
@@ -41,11 +36,10 @@ export default (pluginOptions) => {
|
|
|
41
36
|
headers: incomingMessage.headers,
|
|
42
37
|
});
|
|
43
38
|
// @ts-expect-error Manually set `normalizedUrl` which a developer expects to be available
|
|
44
|
-
// via `
|
|
39
|
+
// via `HydrogenRequest` during production runtime.
|
|
45
40
|
request.normalizedUrl = request.url;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
: hydrogenConfig.shopify;
|
|
41
|
+
const { shopify } = hydrogenConfig;
|
|
42
|
+
return typeof shopify === 'function' ? shopify(request) : shopify;
|
|
49
43
|
},
|
|
50
44
|
}));
|
|
51
45
|
server.middlewares.use(bodyParser.raw({ type: '*/*' }));
|
|
@@ -59,26 +53,6 @@ export default (pluginOptions) => {
|
|
|
59
53
|
: undefined,
|
|
60
54
|
}));
|
|
61
55
|
},
|
|
62
|
-
async resolveId(source, importer) {
|
|
63
|
-
if (source === virtualModuleId) {
|
|
64
|
-
const configPath = await findHydrogenConfigPath(config.root, pluginOptions.configPath);
|
|
65
|
-
return this.resolve(configPath, importer, {
|
|
66
|
-
skipSelf: true,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (source === virtualProxyModuleId) {
|
|
70
|
-
// Virtual modules convention
|
|
71
|
-
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
72
|
-
return '\0' + virtualProxyModuleId;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
async load(id) {
|
|
76
|
-
if (id === '\0' + virtualProxyModuleId) {
|
|
77
|
-
// Likely due to a bug in Vite, but the config cannot be loaded
|
|
78
|
-
// directly using ssrLoadModule. It needs to be proxied as follows:
|
|
79
|
-
return `import hc from 'virtual:hydrogen-config'; export default hc;`;
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
56
|
};
|
|
83
57
|
};
|
|
84
58
|
async function polyfillOxygenEnv(config) {
|
|
@@ -93,18 +67,3 @@ async function polyfillOxygenEnv(config) {
|
|
|
93
67
|
}
|
|
94
68
|
globalThis.Oxygen = { env };
|
|
95
69
|
}
|
|
96
|
-
async function findHydrogenConfigPath(root, userProvidedPath) {
|
|
97
|
-
let configPath = userProvidedPath;
|
|
98
|
-
if (!configPath) {
|
|
99
|
-
// Find the config file in the project root
|
|
100
|
-
const files = await fs.readdir(root);
|
|
101
|
-
configPath = files.find((file) => /^hydrogen\.config\.[jt]s$/.test(file));
|
|
102
|
-
}
|
|
103
|
-
if (configPath) {
|
|
104
|
-
configPath = normalizePath(configPath);
|
|
105
|
-
if (!configPath.startsWith('/'))
|
|
106
|
-
configPath = path.resolve(root, configPath);
|
|
107
|
-
}
|
|
108
|
-
return (configPath ||
|
|
109
|
-
require.resolve('@shopify/hydrogen/dist/esnext/utilities/empty-hydrogen-config.js'));
|
|
110
|
-
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import reactServerDomVite from '@shopify/hydrogen/vendor/react-server-dom-vite/plugin';
|
|
3
3
|
import { HYDROGEN_DEFAULT_SERVER_ENTRY } from './vite-plugin-hydrogen-middleware';
|
|
4
|
-
import {
|
|
4
|
+
import { VIRTUAL_PROXY_HYDROGEN_ROUTES_ID } from './vite-plugin-hydrogen-virtual-files';
|
|
5
5
|
export default function () {
|
|
6
6
|
return reactServerDomVite({
|
|
7
|
+
serverBuildEntries: [
|
|
8
|
+
HYDROGEN_DEFAULT_SERVER_ENTRY,
|
|
9
|
+
VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
10
|
+
],
|
|
7
11
|
isServerComponentImporterAllowed(importer, source) {
|
|
8
12
|
return (
|
|
9
13
|
// Always allow the entry server (e.g. App.server.jsx) to be imported
|
|
@@ -14,22 +18,5 @@ export default function () {
|
|
|
14
18
|
// TODO: revisit this when RSC splits into two bundles
|
|
15
19
|
/\.test\.[tj]sx?$/.test(importer));
|
|
16
20
|
},
|
|
17
|
-
async findClientComponentsForClientBuild() {
|
|
18
|
-
// In client build, we create a local server to discover client compoents.
|
|
19
|
-
const server = await createServer({
|
|
20
|
-
clearScreen: false,
|
|
21
|
-
server: { middlewareMode: 'ssr' },
|
|
22
|
-
});
|
|
23
|
-
await Promise.all([
|
|
24
|
-
// Load server entry to discover client components early
|
|
25
|
-
server.ssrLoadModule(HYDROGEN_DEFAULT_SERVER_ENTRY),
|
|
26
|
-
// Route globs are placed in hydrogen.config.js and need to
|
|
27
|
-
// be loaded to discover client components in routes
|
|
28
|
-
server.ssrLoadModule('virtual:hydrogen-config:proxy'),
|
|
29
|
-
]);
|
|
30
|
-
await server.close();
|
|
31
|
-
// At this point, the server has loaded all the components in the module graph
|
|
32
|
-
return reactServerDomVite.findClientComponentsFromServer(server);
|
|
33
|
-
},
|
|
34
21
|
});
|
|
35
22
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
return {
|
|
3
|
+
name: 'hydrogen:suppress-warnings',
|
|
4
|
+
configResolved(config) {
|
|
5
|
+
// TODO: Fix the actual issues that cause these warnings
|
|
6
|
+
const filterOut = (msg) => msg.startsWith("@shopify/hydrogen doesn't appear to be written in CJS") ||
|
|
7
|
+
(msg.includes('missing source files') &&
|
|
8
|
+
['kolorist'].some((lib) => msg.includes(lib)));
|
|
9
|
+
for (const method of ['warn', 'warnOnce']) {
|
|
10
|
+
const original = config.logger[method];
|
|
11
|
+
config.logger[method] = (msg, ...args) => {
|
|
12
|
+
if (filterOut(msg))
|
|
13
|
+
return;
|
|
14
|
+
return original(msg, ...args);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import type { HydrogenVitePluginOptions } from '../../types';
|
|
3
|
+
export declare const HYDROGEN_DEFAULT_SERVER_ENTRY: string;
|
|
4
|
+
export declare const VIRTUAL_PROXY_HYDROGEN_CONFIG_ID: string;
|
|
5
|
+
export declare const VIRTUAL_PROXY_HYDROGEN_ROUTES_ID: string;
|
|
6
|
+
declare const _default: (pluginOptions: HydrogenVitePluginOptions) => Plugin;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { normalizePath } from 'vite';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import { viteception } from '../viteception';
|
|
5
|
+
export const HYDROGEN_DEFAULT_SERVER_ENTRY = process.env.HYDROGEN_SERVER_ENTRY || '/src/App.server';
|
|
6
|
+
// The character ":" breaks Vite with Node >= 16.15. Use "_" instead
|
|
7
|
+
const VIRTUAL_PREFIX = 'virtual__';
|
|
8
|
+
const PROXY_PREFIX = 'proxy__';
|
|
9
|
+
const HYDROGEN_CONFIG_ID = 'hydrogen.config.ts';
|
|
10
|
+
const VIRTUAL_HYDROGEN_CONFIG_ID = VIRTUAL_PREFIX + HYDROGEN_CONFIG_ID;
|
|
11
|
+
export const VIRTUAL_PROXY_HYDROGEN_CONFIG_ID = VIRTUAL_PREFIX + PROXY_PREFIX + HYDROGEN_CONFIG_ID;
|
|
12
|
+
const HYDROGEN_ROUTES_ID = 'hydrogen-routes.server.jsx';
|
|
13
|
+
const VIRTUAL_HYDROGEN_ROUTES_ID = VIRTUAL_PREFIX + HYDROGEN_ROUTES_ID;
|
|
14
|
+
export const VIRTUAL_PROXY_HYDROGEN_ROUTES_ID = VIRTUAL_PREFIX + PROXY_PREFIX + HYDROGEN_ROUTES_ID;
|
|
15
|
+
export default (pluginOptions) => {
|
|
16
|
+
let config;
|
|
17
|
+
let server;
|
|
18
|
+
return {
|
|
19
|
+
name: 'hydrogen:virtual-files',
|
|
20
|
+
configResolved(_config) {
|
|
21
|
+
config = _config;
|
|
22
|
+
},
|
|
23
|
+
configureServer(_server) {
|
|
24
|
+
server = _server;
|
|
25
|
+
},
|
|
26
|
+
resolveId(source, importer) {
|
|
27
|
+
if (source === VIRTUAL_HYDROGEN_CONFIG_ID) {
|
|
28
|
+
return findHydrogenConfigPath(config.root, pluginOptions.configPath).then((hcPath) =>
|
|
29
|
+
// This direct dependency on a real file
|
|
30
|
+
// makes HMR work for the virtual module.
|
|
31
|
+
this.resolve(hcPath, importer, { skipSelf: true }));
|
|
32
|
+
}
|
|
33
|
+
if ([
|
|
34
|
+
VIRTUAL_PROXY_HYDROGEN_CONFIG_ID,
|
|
35
|
+
VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
36
|
+
VIRTUAL_HYDROGEN_ROUTES_ID,
|
|
37
|
+
].includes(source)) {
|
|
38
|
+
// Virtual modules convention
|
|
39
|
+
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
40
|
+
return '\0' + source;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
load(id) {
|
|
44
|
+
// Likely due to a bug in Vite, but virtual modules cannot be loaded
|
|
45
|
+
// directly using ssrLoadModule from a Vite plugin. It needs to be proxied as follows:
|
|
46
|
+
if (id === '\0' + VIRTUAL_PROXY_HYDROGEN_CONFIG_ID) {
|
|
47
|
+
return `import hc from '${VIRTUAL_HYDROGEN_CONFIG_ID}'; export default hc;`;
|
|
48
|
+
}
|
|
49
|
+
if (id === '\0' + VIRTUAL_PROXY_HYDROGEN_ROUTES_ID) {
|
|
50
|
+
return `import hr from '${VIRTUAL_HYDROGEN_ROUTES_ID}'; export default hr;`;
|
|
51
|
+
}
|
|
52
|
+
if (id === '\0' + VIRTUAL_HYDROGEN_ROUTES_ID) {
|
|
53
|
+
return importHydrogenConfig().then((hc) => {
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
|
+
let routesPath = (_b = (typeof hc.routes === 'string' ? hc.routes : (_a = hc.routes) === null || _a === void 0 ? void 0 : _a.files)) !== null && _b !== void 0 ? _b : '/src/routes';
|
|
56
|
+
if (routesPath.startsWith('./')) {
|
|
57
|
+
routesPath = routesPath.slice(1);
|
|
58
|
+
}
|
|
59
|
+
if (!routesPath.includes('*')) {
|
|
60
|
+
if (!routesPath.endsWith('/')) {
|
|
61
|
+
routesPath += '/';
|
|
62
|
+
}
|
|
63
|
+
routesPath += '**/*.server.[jt](s|sx)';
|
|
64
|
+
}
|
|
65
|
+
const [dirPrefix] = routesPath.split('/*');
|
|
66
|
+
let code = `export default {\n dirPrefix: '${dirPrefix}',\n basePath: '${(_d = (_c = hc.routes) === null || _c === void 0 ? void 0 : _c.basePath) !== null && _d !== void 0 ? _d : ''}',\n files: import.meta.globEager('${routesPath}')\n};`;
|
|
67
|
+
if (config.command === 'serve') {
|
|
68
|
+
// Add dependency on Hydrogen config for HMR
|
|
69
|
+
code += `\nimport '${VIRTUAL_HYDROGEN_CONFIG_ID}';`;
|
|
70
|
+
}
|
|
71
|
+
return { code };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
async function importHydrogenConfig() {
|
|
77
|
+
if (server) {
|
|
78
|
+
const loaded = await server.ssrLoadModule(VIRTUAL_PROXY_HYDROGEN_CONFIG_ID);
|
|
79
|
+
return loaded.default;
|
|
80
|
+
}
|
|
81
|
+
const { loaded } = await viteception([VIRTUAL_PROXY_HYDROGEN_CONFIG_ID]);
|
|
82
|
+
return loaded[0].default;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
async function findHydrogenConfigPath(root, userProvidedPath) {
|
|
86
|
+
let configPath = userProvidedPath;
|
|
87
|
+
if (!configPath) {
|
|
88
|
+
// Find the config file in the project root
|
|
89
|
+
const files = await fs.readdir(root);
|
|
90
|
+
configPath = files.find((file) => /^hydrogen\.config\.[jt]s$/.test(file));
|
|
91
|
+
}
|
|
92
|
+
if (configPath) {
|
|
93
|
+
configPath = normalizePath(configPath);
|
|
94
|
+
if (!configPath.startsWith('/'))
|
|
95
|
+
configPath = path.resolve(root, configPath);
|
|
96
|
+
}
|
|
97
|
+
return (configPath ||
|
|
98
|
+
require.resolve('@shopify/hydrogen/dist/esnext/utilities/empty-hydrogen-config.js'));
|
|
99
|
+
}
|
|
@@ -31,10 +31,10 @@ export default () => {
|
|
|
31
31
|
},
|
|
32
32
|
transform(code, id) {
|
|
33
33
|
if (normalizePath(id).includes('/hydrogen/dist/esnext/platforms/')) {
|
|
34
|
-
code = code
|
|
35
|
-
.replace('__SERVER_ENTRY__', HYDROGEN_DEFAULT_SERVER_ENTRY)
|
|
36
|
-
.replace('__INDEX_TEMPLATE__', normalizePath(path.resolve(config.root, config.build.outDir, '..', 'client', 'index.html')));
|
|
37
34
|
const ms = new MagicString(code);
|
|
35
|
+
ms.replace('__SERVER_ENTRY__', HYDROGEN_DEFAULT_SERVER_ENTRY);
|
|
36
|
+
const indexTemplatePath = normalizePath(path.resolve(config.root, config.build.outDir, '..', 'client', 'index.html'));
|
|
37
|
+
ms.replace('__INDEX_TEMPLATE__', indexTemplatePath);
|
|
38
38
|
return {
|
|
39
39
|
code: ms.toString(),
|
|
40
40
|
map: ms.generateMap({ file: id, source: id }),
|
|
@@ -51,7 +51,7 @@ export default () => {
|
|
|
51
51
|
// default export instead of exporting an
|
|
52
52
|
// object containing a 'default' property.
|
|
53
53
|
if (value.type === 'chunk' && !isESM) {
|
|
54
|
-
value.code =
|
|
54
|
+
value.code += `\nmodule.exports = exports.default || exports;`;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createServer } from 'vite';
|
|
2
|
+
export async function viteception(paths) {
|
|
3
|
+
const isWorker = process.env.WORKER;
|
|
4
|
+
delete process.env.WORKER;
|
|
5
|
+
const server = await createServer({
|
|
6
|
+
clearScreen: false,
|
|
7
|
+
server: { middlewareMode: 'ssr' },
|
|
8
|
+
});
|
|
9
|
+
if (isWorker) {
|
|
10
|
+
process.env.WORKER = isWorker;
|
|
11
|
+
}
|
|
12
|
+
const loaded = await Promise.all(paths.map((path) => server.ssrLoadModule(path)));
|
|
13
|
+
await server.close();
|
|
14
|
+
return { server, loaded };
|
|
15
|
+
}
|
|
@@ -14,8 +14,8 @@ metafields?: PartialDeep<MetafieldConnection>): {
|
|
|
14
14
|
description?: import("../../storefront-api-types").Maybe<string> | undefined;
|
|
15
15
|
key?: string | undefined;
|
|
16
16
|
namespace?: string | undefined;
|
|
17
|
-
parentResource?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").
|
|
18
|
-
reference?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Video> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").MediaImage> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").ProductVariant> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").
|
|
17
|
+
parentResource?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Blog> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Article> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Customer> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").ProductVariant> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Order> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Collection> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Page> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Product> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Shop> | undefined;
|
|
18
|
+
reference?: import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Video> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").MediaImage> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").ProductVariant> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Page> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").Product> | import("type-fest/source/partial-deep").PartialObjectDeep<import("../../storefront-api-types").GenericFile> | null | undefined;
|
|
19
19
|
type?: string | undefined;
|
|
20
20
|
updatedAt?: string | undefined;
|
|
21
21
|
}[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { SelectedOption as SelectedOptionType, ProductVariant as ProductVariantType, ProductVariantConnection, SellingPlan as SellingPlanType, SellingPlanAllocation as SellingPlanAllocationType, SellingPlanGroup as SellingPlanGroupType,
|
|
1
|
+
import type { SelectedOption as SelectedOptionType, ProductVariant as ProductVariantType, ProductVariantConnection, SellingPlan as SellingPlanType, SellingPlanAllocation as SellingPlanAllocationType, SellingPlanGroup as SellingPlanGroupType, SellingPlanGroupConnection } from '../../storefront-api-types';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
export declare type SelectedOptions = {
|
|
3
4
|
[key: string]: string;
|
|
4
5
|
};
|
|
@@ -11,7 +12,7 @@ export interface OptionWithValues {
|
|
|
11
12
|
name: SelectedOptionType['name'];
|
|
12
13
|
values: SelectedOptionType['value'][];
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
+
export declare type ProductOptionsHookValue = PartialDeep<{
|
|
15
16
|
/** An array of the variant `nodes` from the `VariantConnection`. */
|
|
16
17
|
variants: ProductVariantType[];
|
|
17
18
|
variantsConnection?: ProductVariantConnection;
|
|
@@ -19,17 +20,7 @@ export interface ProductOptionsHookValue {
|
|
|
19
20
|
options: OptionWithValues[];
|
|
20
21
|
/** The selected variant. */
|
|
21
22
|
selectedVariant?: ProductVariantType | null;
|
|
22
|
-
/** A callback to set the selected variant to the variant passed as an argument. */
|
|
23
|
-
setSelectedVariant: SelectVariantCallback;
|
|
24
23
|
selectedOptions: SelectedOptions;
|
|
25
|
-
/** A callback to set the selected option. */
|
|
26
|
-
setSelectedOption: SelectOptionCallback;
|
|
27
|
-
/** A callback to set multiple selected options at once. */
|
|
28
|
-
setSelectedOptions: SelectOptionsCallback;
|
|
29
|
-
/** A callback that returns a boolean indicating if the option is in stock. */
|
|
30
|
-
isOptionInStock: OptionsInStockCallback;
|
|
31
|
-
/** A callback to set the selected selling plan to the one passed as an argument. */
|
|
32
|
-
setSelectedSellingPlan: SelectedSellingPlanCallback;
|
|
33
24
|
/** The selected selling plan. */
|
|
34
25
|
selectedSellingPlan?: SellingPlanType;
|
|
35
26
|
/** The selected selling plan allocation. */
|
|
@@ -38,5 +29,16 @@ export interface ProductOptionsHookValue {
|
|
|
38
29
|
sellingPlanGroups?: (Omit<SellingPlanGroupType, 'sellingPlans'> & {
|
|
39
30
|
sellingPlans: SellingPlanType[];
|
|
40
31
|
})[];
|
|
41
|
-
sellingPlanGroupsConnection?:
|
|
42
|
-
}
|
|
32
|
+
sellingPlanGroupsConnection?: SellingPlanGroupConnection;
|
|
33
|
+
}> & {
|
|
34
|
+
/** A callback to set the selected variant to the variant passed as an argument. */
|
|
35
|
+
setSelectedVariant: SelectVariantCallback;
|
|
36
|
+
/** A callback to set the selected option. */
|
|
37
|
+
setSelectedOption: SelectOptionCallback;
|
|
38
|
+
/** A callback to set multiple selected options at once. */
|
|
39
|
+
setSelectedOptions: SelectOptionsCallback;
|
|
40
|
+
/** A callback to set the selected selling plan to the one passed as an argument. */
|
|
41
|
+
setSelectedSellingPlan: SelectedSellingPlanCallback;
|
|
42
|
+
/** A callback that returns a boolean indicating if the option is in stock. */
|
|
43
|
+
isOptionInStock: OptionsInStockCallback;
|
|
44
|
+
};
|