@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useQuery = void 0;
|
|
4
|
+
const log_1 = require("../../utilities/log");
|
|
5
|
+
const cache_sub_request_1 = require("../Cache/cache-sub-request");
|
|
6
|
+
const ServerRequestProvider_1 = require("../ServerRequestProvider");
|
|
7
|
+
const strategies_1 = require("../Cache/strategies");
|
|
8
|
+
/**
|
|
9
|
+
* The `useQuery` hook executes an asynchronous operation like `fetch` in a way that
|
|
10
|
+
* supports [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html). You can use this
|
|
11
|
+
* hook to call any third-party APIs from a server component.
|
|
12
|
+
*
|
|
13
|
+
* \> Note:
|
|
14
|
+
* \> If you're making a simple fetch call on the server, then we recommend using the [`fetchSync`](https://shopify.dev/api/hydrogen/hooks/global/fetchsync) hook instead.
|
|
15
|
+
*/
|
|
16
|
+
function useQuery(
|
|
17
|
+
/** A string or array to uniquely identify the current query. */
|
|
18
|
+
key,
|
|
19
|
+
/** An asynchronous query function like `fetch` which returns data. */
|
|
20
|
+
queryFn,
|
|
21
|
+
/** The options to manage the cache behavior of the sub-request. */
|
|
22
|
+
queryOptions) {
|
|
23
|
+
const request = (0, ServerRequestProvider_1.useServerRequest)();
|
|
24
|
+
const withCacheIdKey = [
|
|
25
|
+
'__QUERY_CACHE_ID__',
|
|
26
|
+
...(typeof key === 'string' ? [key] : key),
|
|
27
|
+
];
|
|
28
|
+
const fetcher = cachedQueryFnBuilder(withCacheIdKey, queryFn, queryOptions);
|
|
29
|
+
(0, log_1.collectQueryTimings)(request, withCacheIdKey, 'requested');
|
|
30
|
+
if (queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload) {
|
|
31
|
+
request.savePreloadQuery({
|
|
32
|
+
preload: queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.preload,
|
|
33
|
+
key: withCacheIdKey,
|
|
34
|
+
fetcher,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return (0, ServerRequestProvider_1.useRequestCacheData)(withCacheIdKey, fetcher);
|
|
38
|
+
}
|
|
39
|
+
exports.useQuery = useQuery;
|
|
40
|
+
function cachedQueryFnBuilder(key, queryFn, queryOptions) {
|
|
41
|
+
var _a;
|
|
42
|
+
const resolvedQueryOptions = {
|
|
43
|
+
...(queryOptions !== null && queryOptions !== void 0 ? queryOptions : {}),
|
|
44
|
+
};
|
|
45
|
+
const shouldCacheResponse = (_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.shouldCacheResponse) !== null && _a !== void 0 ? _a : (() => true);
|
|
46
|
+
/**
|
|
47
|
+
* Attempt to read the query from cache. If it doesn't exist or if it's stale, regenerate it.
|
|
48
|
+
*/
|
|
49
|
+
async function useCachedQueryFn() {
|
|
50
|
+
var _a, _b, _c, _d;
|
|
51
|
+
// Call this hook before running any async stuff
|
|
52
|
+
// to prevent losing the current React cycle.
|
|
53
|
+
const request = (0, ServerRequestProvider_1.useServerRequest)();
|
|
54
|
+
const log = (0, log_1.getLoggerWithContext)(request);
|
|
55
|
+
const cacheResponse = await (0, cache_sub_request_1.getItemFromCache)(key);
|
|
56
|
+
async function generateNewOutput() {
|
|
57
|
+
return await queryFn();
|
|
58
|
+
}
|
|
59
|
+
if (cacheResponse) {
|
|
60
|
+
const [output, response] = cacheResponse;
|
|
61
|
+
(0, log_1.collectQueryCacheControlHeaders)(request, key, response.headers.get('cache-control'));
|
|
62
|
+
/**
|
|
63
|
+
* Important: Do this async
|
|
64
|
+
*/
|
|
65
|
+
if ((0, cache_sub_request_1.isStale)(key, response)) {
|
|
66
|
+
const lockKey = ['lock', ...(typeof key === 'string' ? [key] : key)];
|
|
67
|
+
// Run revalidation asynchronously
|
|
68
|
+
const revalidatingPromise = (0, cache_sub_request_1.getItemFromCache)(lockKey).then(async (lockExists) => {
|
|
69
|
+
if (lockExists)
|
|
70
|
+
return;
|
|
71
|
+
await (0, cache_sub_request_1.setItemInCache)(lockKey, true, (0, strategies_1.CacheSeconds)({
|
|
72
|
+
maxAge: 10,
|
|
73
|
+
}));
|
|
74
|
+
try {
|
|
75
|
+
const output = await generateNewOutput();
|
|
76
|
+
if (shouldCacheResponse(output)) {
|
|
77
|
+
await (0, cache_sub_request_1.setItemInCache)(key, output, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
log.error(`Error generating async response: ${e.message}`);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await (0, cache_sub_request_1.deleteItemFromCache)(lockKey);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
// Asynchronously wait for it in workers
|
|
88
|
+
(_b = (_a = request.ctx.runtime) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.call(_a, revalidatingPromise);
|
|
89
|
+
}
|
|
90
|
+
return output;
|
|
91
|
+
}
|
|
92
|
+
const newOutput = await generateNewOutput();
|
|
93
|
+
/**
|
|
94
|
+
* Important: Do this async
|
|
95
|
+
*/
|
|
96
|
+
if (shouldCacheResponse(newOutput)) {
|
|
97
|
+
const setItemInCachePromise = (0, cache_sub_request_1.setItemInCache)(key, newOutput, resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache);
|
|
98
|
+
(_d = (_c = request.ctx.runtime) === null || _c === void 0 ? void 0 : _c.waitUntil) === null || _d === void 0 ? void 0 : _d.call(_c, setItemInCachePromise);
|
|
99
|
+
}
|
|
100
|
+
(0, log_1.collectQueryCacheControlHeaders)(request, key, (0, cache_sub_request_1.generateSubRequestCacheControlHeader)(resolvedQueryOptions === null || resolvedQueryOptions === void 0 ? void 0 : resolvedQueryOptions.cache));
|
|
101
|
+
return newOutput;
|
|
102
|
+
}
|
|
103
|
+
return useCachedQueryFn;
|
|
104
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
declare type RouteParamsContextValue = {
|
|
3
|
+
routeParams: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
export declare const RouteParamsContext: React.Context<RouteParamsContextValue>;
|
|
6
|
+
export declare const RouteParamsProvider: FC<{
|
|
7
|
+
routeParams: Record<string, string>;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RouteParamsProvider = exports.RouteParamsContext = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
exports.RouteParamsContext = (0, react_1.createContext)({
|
|
29
|
+
routeParams: {},
|
|
30
|
+
});
|
|
31
|
+
const RouteParamsProvider = ({ children, routeParams }) => {
|
|
32
|
+
return (react_1.default.createElement(exports.RouteParamsContext.Provider, { value: { routeParams } }, children));
|
|
33
|
+
};
|
|
34
|
+
exports.RouteParamsProvider = RouteParamsProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRouteParams = void 0;
|
|
4
|
+
const ssr_interop_1 = require("../ssr-interop");
|
|
5
|
+
const RouteParamsProvider_client_1 = require("./RouteParamsProvider.client");
|
|
6
|
+
/**
|
|
7
|
+
* The `useRouteParams` hook retrieves the parameters of an active route. The hook is available in both server and client components.
|
|
8
|
+
*/
|
|
9
|
+
function useRouteParams() {
|
|
10
|
+
const router = (0, ssr_interop_1.useEnvContext)((req) => req.ctx.router, RouteParamsProvider_client_1.RouteParamsContext);
|
|
11
|
+
return router.routeParams;
|
|
12
|
+
}
|
|
13
|
+
exports.useRouteParams = useRouteParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useServerProps } from './use-server-props';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useServerProps = void 0;
|
|
4
|
+
var use_server_props_1 = require("./use-server-props");
|
|
5
|
+
Object.defineProperty(exports, "useServerProps", { enumerable: true, get: function () { return use_server_props_1.useServerProps; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSession = void 0;
|
|
4
|
+
const ServerRequestProvider_1 = require("../ServerRequestProvider");
|
|
5
|
+
/** The `useSession` hook reads session data in server components. */
|
|
6
|
+
const useSession = function () {
|
|
7
|
+
var _a;
|
|
8
|
+
const request = (0, ServerRequestProvider_1.useServerRequest)();
|
|
9
|
+
const session = ((_a = request.ctx.session) === null || _a === void 0 ? void 0 : _a.get()) || {};
|
|
10
|
+
return session;
|
|
11
|
+
};
|
|
12
|
+
exports.useSession = useSession;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useShop } from './use-shop';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `useShop` hook provides access to values within
|
|
3
|
+
* [the `shopify` property in the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
|
|
4
|
+
* The `useShop` hook must be a descendent of a `ShopifyProvider` component.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useShop(): import("../ShopifyProvider/types").ShopifyContextValue;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useShop = void 0;
|
|
4
|
+
const ShopifyProvider_1 = require("../ShopifyProvider");
|
|
5
|
+
const ssr_interop_1 = require("../ssr-interop");
|
|
6
|
+
/**
|
|
7
|
+
* The `useShop` hook provides access to values within
|
|
8
|
+
* [the `shopify` property in the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
|
|
9
|
+
* The `useShop` hook must be a descendent of a `ShopifyProvider` component.
|
|
10
|
+
*/
|
|
11
|
+
function useShop() {
|
|
12
|
+
const config = (0, ssr_interop_1.useEnvContext)((req) => req.ctx.shopifyConfig, ShopifyProvider_1.ShopifyContext);
|
|
13
|
+
if (!config) {
|
|
14
|
+
throw new Error('No Shopify Context found');
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
exports.useShop = useShop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useUrl } from './useUrl';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUrl = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const parse_1 = require("../../utilities/parse");
|
|
7
|
+
const BrowserRouter_client_1 = require("../Router/BrowserRouter.client");
|
|
8
|
+
const ssr_interop_1 = require("../ssr-interop");
|
|
9
|
+
/**
|
|
10
|
+
* The `useUrl` hook retrieves the current URL in a server or client component.
|
|
11
|
+
*/
|
|
12
|
+
function useUrl() {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
if (ssr_interop_1.META_ENV_SSR) {
|
|
15
|
+
const serverUrl = new URL((0, ssr_interop_1.useEnvContext)((req) => req.url) // eslint-disable-line react-hooks/rules-of-hooks
|
|
16
|
+
);
|
|
17
|
+
if (serverUrl.pathname === constants_1.RSC_PATHNAME) {
|
|
18
|
+
const state = (0, parse_1.parseJSON)(serverUrl.searchParams.get('state') || '{}');
|
|
19
|
+
const parsedUrl = `${serverUrl.origin}${(_a = state.pathname) !== null && _a !== void 0 ? _a : ''}${(_b = state.search) !== null && _b !== void 0 ? _b : ''}`;
|
|
20
|
+
return new URL(parsedUrl);
|
|
21
|
+
}
|
|
22
|
+
return new URL(serverUrl);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* We return a `URL` object instead of passing through `location` because
|
|
26
|
+
* the URL object contains important info like hostname, etc.
|
|
27
|
+
*/
|
|
28
|
+
const location = (0, BrowserRouter_client_1.useLocation)(); // eslint-disable-line react-hooks/rules-of-hooks
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
return (0, react_1.useMemo)(() => new URL(window.location.href), [location]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
31
|
+
}
|
|
32
|
+
exports.useUrl = useUrl;
|
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.useRefresh = exports.useServerResponse = void 0;
|
|
6
6
|
const react_server_dom_vite_1 = require("@shopify/hydrogen/vendor/react-server-dom-vite");
|
|
7
|
+
const client_1 = require("../../client");
|
|
7
8
|
const constants_1 = require("../../constants");
|
|
8
|
-
const utilities_1 = require("../../utilities");
|
|
9
9
|
let rscReader;
|
|
10
10
|
// Hydrate an SSR response from <meta> tags placed in the DOM.
|
|
11
11
|
const flightChunks = [];
|
|
12
12
|
const FLIGHT_ATTRIBUTE = 'data-flight';
|
|
13
13
|
function addElementToFlightChunks(el) {
|
|
14
|
+
// We don't need to decode, because `.getAttribute` already decodes
|
|
14
15
|
const chunk = el.getAttribute(FLIGHT_ATTRIBUTE);
|
|
15
16
|
if (chunk) {
|
|
16
|
-
flightChunks.push(
|
|
17
|
+
flightChunks.push(chunk);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
// Get initial payload
|
|
@@ -89,6 +90,7 @@ function useServerResponse(state) {
|
|
|
89
90
|
/* @ts-ignore */
|
|
90
91
|
window.BOOMR.plugins.Hydrogen.trackSubPageLoadPerformance();
|
|
91
92
|
}
|
|
93
|
+
client_1.ClientAnalytics.resetPageAnalyticsData();
|
|
92
94
|
// Request a new flight response.
|
|
93
95
|
response = (0, react_server_dom_vite_1.createFromFetch)(fetch(`${constants_1.RSC_PATHNAME}?state=` + encodeURIComponent(key)));
|
|
94
96
|
}
|
|
@@ -75,26 +75,12 @@ function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypoint, de
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
entrypointError = null;
|
|
78
|
-
|
|
78
|
+
await handleRequest(request, {
|
|
79
79
|
dev,
|
|
80
80
|
cache,
|
|
81
81
|
indexTemplate,
|
|
82
82
|
streamableResponse: response,
|
|
83
83
|
});
|
|
84
|
-
/**
|
|
85
|
-
* If a `Response` was returned, that means it was not streamed.
|
|
86
|
-
* Convert the response into a proper Node.js response.
|
|
87
|
-
*/
|
|
88
|
-
if (eventResponse) {
|
|
89
|
-
eventResponse.headers.forEach((value, key) => {
|
|
90
|
-
response.setHeader(key, value);
|
|
91
|
-
});
|
|
92
|
-
response.statusCode = eventResponse.status;
|
|
93
|
-
if (eventResponse.body) {
|
|
94
|
-
response.write(eventResponse.body);
|
|
95
|
-
}
|
|
96
|
-
response.end();
|
|
97
|
-
}
|
|
98
84
|
}
|
|
99
85
|
catch (e) {
|
|
100
86
|
if (dev && devServer)
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const vite_plugin_hydrogen_config_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-config"));
|
|
7
7
|
const vite_plugin_hydrogen_middleware_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-middleware"));
|
|
8
8
|
const vite_plugin_hydrogen_client_middleware_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-client-middleware"));
|
|
9
|
+
const vite_plugin_hydrogen_virtual_files_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-virtual-files"));
|
|
9
10
|
const vite_plugin_platform_entry_1 = __importDefault(require("./plugins/vite-plugin-platform-entry"));
|
|
10
11
|
const vite_plugin_hydrogen_rsc_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-rsc"));
|
|
11
12
|
const vite_plugin_ssr_interop_1 = __importDefault(require("./plugins/vite-plugin-ssr-interop"));
|
|
@@ -15,6 +16,7 @@ const vite_plugin_inspect_1 = __importDefault(require("vite-plugin-inspect"));
|
|
|
15
16
|
const plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
|
|
16
17
|
const vite_plugin_css_modules_rsc_1 = __importDefault(require("./plugins/vite-plugin-css-modules-rsc"));
|
|
17
18
|
const vite_plugin_client_imports_1 = __importDefault(require("./plugins/vite-plugin-client-imports"));
|
|
19
|
+
const vite_plugin_hydrogen_suppress_warnings_1 = __importDefault(require("./plugins/vite-plugin-hydrogen-suppress-warnings"));
|
|
18
20
|
exports.default = (pluginOptions = {}) => {
|
|
19
21
|
return [
|
|
20
22
|
process.env.VITE_INSPECT && (0, vite_plugin_inspect_1.default)(),
|
|
@@ -22,12 +24,14 @@ exports.default = (pluginOptions = {}) => {
|
|
|
22
24
|
(0, vite_plugin_hydrogen_client_middleware_1.default)(),
|
|
23
25
|
(0, vite_plugin_client_imports_1.default)(),
|
|
24
26
|
(0, vite_plugin_hydrogen_middleware_1.default)(pluginOptions),
|
|
27
|
+
(0, vite_plugin_hydrogen_virtual_files_1.default)(pluginOptions),
|
|
25
28
|
(0, plugin_react_1.default)(),
|
|
26
29
|
(0, vite_plugin_hydration_auto_import_1.default)(),
|
|
27
30
|
(0, vite_plugin_ssr_interop_1.default)(),
|
|
28
31
|
(0, vite_plugin_css_modules_rsc_1.default)(),
|
|
29
32
|
(0, vite_plugin_hydrogen_rsc_1.default)(),
|
|
30
33
|
(0, vite_plugin_platform_entry_1.default)(),
|
|
34
|
+
(0, vite_plugin_hydrogen_suppress_warnings_1.default)(),
|
|
31
35
|
pluginOptions.purgeQueryCacheOnBuild && (0, vite_plugin_purge_query_cache_1.default)(),
|
|
32
36
|
];
|
|
33
37
|
};
|
|
@@ -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;
|
|
@@ -14,7 +14,7 @@ exports.default = () => {
|
|
|
14
14
|
format: 'es',
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
17
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
18
18
|
/**
|
|
19
19
|
* Ofuscate production asset name - To prevent ad blocker logics that blocks
|
|
20
20
|
* certain files due to how it is named.
|
|
@@ -84,11 +84,14 @@ exports.default = () => {
|
|
|
84
84
|
'react-server-dom-vite/client-proxy',
|
|
85
85
|
// https://github.com/vitejs/vite/issues/6215
|
|
86
86
|
'react/jsx-runtime',
|
|
87
|
+
// https://github.com/nfriedly/set-cookie-parser/issues/50
|
|
88
|
+
'set-cookie-parser',
|
|
87
89
|
],
|
|
88
90
|
},
|
|
89
91
|
define: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
__HYDROGEN_DEV__: env.mode !== 'production',
|
|
93
|
+
__HYDROGEN_WORKER__: isWorker,
|
|
94
|
+
__HYDROGEN_TEST__: false, // Used in unit tests
|
|
92
95
|
},
|
|
93
96
|
envPrefix: ['VITE_', 'PUBLIC_'],
|
|
94
97
|
base: process.env.HYDROGEN_ASSET_BASE_URL,
|
|
@@ -10,16 +10,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const middleware_1 = require("../middleware");
|
|
12
12
|
const in_memory_1 = require("../cache/in-memory");
|
|
13
|
+
const vite_plugin_hydrogen_virtual_files_1 = require("./vite-plugin-hydrogen-virtual-files");
|
|
13
14
|
exports.HYDROGEN_DEFAULT_SERVER_ENTRY = process.env.HYDROGEN_SERVER_ENTRY || '/src/App.server';
|
|
14
|
-
const virtualModuleId = 'virtual:hydrogen-config';
|
|
15
|
-
const virtualProxyModuleId = virtualModuleId + ':proxy';
|
|
16
15
|
exports.default = (pluginOptions) => {
|
|
17
|
-
let config;
|
|
18
16
|
return {
|
|
19
|
-
name: '
|
|
20
|
-
configResolved(_config) {
|
|
21
|
-
config = _config;
|
|
22
|
-
},
|
|
17
|
+
name: 'hydrogen:middleware',
|
|
23
18
|
/**
|
|
24
19
|
* By adding a middleware to the Vite dev server, we can handle SSR without needing
|
|
25
20
|
* a custom node script. It works by handling any requests for `text/html` documents,
|
|
@@ -39,7 +34,7 @@ exports.default = (pluginOptions) => {
|
|
|
39
34
|
dev: true,
|
|
40
35
|
getShopifyConfig: async (incomingMessage) => {
|
|
41
36
|
var _a;
|
|
42
|
-
const { default: hydrogenConfig } = await server.ssrLoadModule(
|
|
37
|
+
const { default: hydrogenConfig } = await server.ssrLoadModule(vite_plugin_hydrogen_virtual_files_1.VIRTUAL_PROXY_HYDROGEN_CONFIG_ID);
|
|
43
38
|
// @ts-ignore
|
|
44
39
|
const { address = 'localhost', port = '3000' } = ((_a = server.httpServer) === null || _a === void 0 ? void 0 : _a.address()) || {};
|
|
45
40
|
const url = new URL(`http://${address}:${port}${incomingMessage.url}`);
|
|
@@ -47,11 +42,10 @@ exports.default = (pluginOptions) => {
|
|
|
47
42
|
headers: incomingMessage.headers,
|
|
48
43
|
});
|
|
49
44
|
// @ts-expect-error Manually set `normalizedUrl` which a developer expects to be available
|
|
50
|
-
// via `
|
|
45
|
+
// via `HydrogenRequest` during production runtime.
|
|
51
46
|
request.normalizedUrl = request.url;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: hydrogenConfig.shopify;
|
|
47
|
+
const { shopify } = hydrogenConfig;
|
|
48
|
+
return typeof shopify === 'function' ? shopify(request) : shopify;
|
|
55
49
|
},
|
|
56
50
|
}));
|
|
57
51
|
server.middlewares.use(body_parser_1.default.raw({ type: '*/*' }));
|
|
@@ -65,26 +59,6 @@ exports.default = (pluginOptions) => {
|
|
|
65
59
|
: undefined,
|
|
66
60
|
}));
|
|
67
61
|
},
|
|
68
|
-
async resolveId(source, importer) {
|
|
69
|
-
if (source === virtualModuleId) {
|
|
70
|
-
const configPath = await findHydrogenConfigPath(config.root, pluginOptions.configPath);
|
|
71
|
-
return this.resolve(configPath, importer, {
|
|
72
|
-
skipSelf: true,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (source === virtualProxyModuleId) {
|
|
76
|
-
// Virtual modules convention
|
|
77
|
-
// https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
|
|
78
|
-
return '\0' + virtualProxyModuleId;
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
async load(id) {
|
|
82
|
-
if (id === '\0' + virtualProxyModuleId) {
|
|
83
|
-
// Likely due to a bug in Vite, but the config cannot be loaded
|
|
84
|
-
// directly using ssrLoadModule. It needs to be proxied as follows:
|
|
85
|
-
return `import hc from 'virtual:hydrogen-config'; export default hc;`;
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
62
|
};
|
|
89
63
|
};
|
|
90
64
|
async function polyfillOxygenEnv(config) {
|
|
@@ -99,18 +73,3 @@ async function polyfillOxygenEnv(config) {
|
|
|
99
73
|
}
|
|
100
74
|
globalThis.Oxygen = { env };
|
|
101
75
|
}
|
|
102
|
-
async function findHydrogenConfigPath(root, userProvidedPath) {
|
|
103
|
-
let configPath = userProvidedPath;
|
|
104
|
-
if (!configPath) {
|
|
105
|
-
// Find the config file in the project root
|
|
106
|
-
const files = await fs_1.promises.readdir(root);
|
|
107
|
-
configPath = files.find((file) => /^hydrogen\.config\.[jt]s$/.test(file));
|
|
108
|
-
}
|
|
109
|
-
if (configPath) {
|
|
110
|
-
configPath = (0, vite_1.normalizePath)(configPath);
|
|
111
|
-
if (!configPath.startsWith('/'))
|
|
112
|
-
configPath = path_1.default.resolve(root, configPath);
|
|
113
|
-
}
|
|
114
|
-
return (configPath ||
|
|
115
|
-
require.resolve('@shopify/hydrogen/dist/esnext/utilities/empty-hydrogen-config.js'));
|
|
116
|
-
}
|
|
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
const plugin_1 = __importDefault(require("@shopify/hydrogen/vendor/react-server-dom-vite/plugin"));
|
|
8
8
|
const vite_plugin_hydrogen_middleware_1 = require("./vite-plugin-hydrogen-middleware");
|
|
9
|
-
const
|
|
9
|
+
const vite_plugin_hydrogen_virtual_files_1 = require("./vite-plugin-hydrogen-virtual-files");
|
|
10
10
|
function default_1() {
|
|
11
11
|
return (0, plugin_1.default)({
|
|
12
|
+
serverBuildEntries: [
|
|
13
|
+
vite_plugin_hydrogen_middleware_1.HYDROGEN_DEFAULT_SERVER_ENTRY,
|
|
14
|
+
vite_plugin_hydrogen_virtual_files_1.VIRTUAL_PROXY_HYDROGEN_ROUTES_ID,
|
|
15
|
+
],
|
|
12
16
|
isServerComponentImporterAllowed(importer, source) {
|
|
13
17
|
return (
|
|
14
18
|
// Always allow the entry server (e.g. App.server.jsx) to be imported
|
|
@@ -19,23 +23,6 @@ function default_1() {
|
|
|
19
23
|
// TODO: revisit this when RSC splits into two bundles
|
|
20
24
|
/\.test\.[tj]sx?$/.test(importer));
|
|
21
25
|
},
|
|
22
|
-
async findClientComponentsForClientBuild() {
|
|
23
|
-
// In client build, we create a local server to discover client compoents.
|
|
24
|
-
const server = await (0, vite_1.createServer)({
|
|
25
|
-
clearScreen: false,
|
|
26
|
-
server: { middlewareMode: 'ssr' },
|
|
27
|
-
});
|
|
28
|
-
await Promise.all([
|
|
29
|
-
// Load server entry to discover client components early
|
|
30
|
-
server.ssrLoadModule(vite_plugin_hydrogen_middleware_1.HYDROGEN_DEFAULT_SERVER_ENTRY),
|
|
31
|
-
// Route globs are placed in hydrogen.config.js and need to
|
|
32
|
-
// be loaded to discover client components in routes
|
|
33
|
-
server.ssrLoadModule('virtual:hydrogen-config:proxy'),
|
|
34
|
-
]);
|
|
35
|
-
await server.close();
|
|
36
|
-
// At this point, the server has loaded all the components in the module graph
|
|
37
|
-
return plugin_1.default.findClientComponentsFromServer(server);
|
|
38
|
-
},
|
|
39
26
|
});
|
|
40
27
|
}
|
|
41
28
|
exports.default = default_1;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = () => {
|
|
4
|
+
return {
|
|
5
|
+
name: 'hydrogen:suppress-warnings',
|
|
6
|
+
configResolved(config) {
|
|
7
|
+
// TODO: Fix the actual issues that cause these warnings
|
|
8
|
+
const filterOut = (msg) => msg.startsWith("@shopify/hydrogen doesn't appear to be written in CJS") ||
|
|
9
|
+
(msg.includes('missing source files') &&
|
|
10
|
+
['kolorist'].some((lib) => msg.includes(lib)));
|
|
11
|
+
for (const method of ['warn', 'warnOnce']) {
|
|
12
|
+
const original = config.logger[method];
|
|
13
|
+
config.logger[method] = (msg, ...args) => {
|
|
14
|
+
if (filterOut(msg))
|
|
15
|
+
return;
|
|
16
|
+
return original(msg, ...args);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,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;
|