@shopify/hydrogen 0.24.0 → 0.25.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 +144 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +2 -5
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +15 -14
- package/dist/esnext/components/BaseButton/BaseButton.client.d.ts +14 -0
- package/dist/esnext/components/BaseButton/BaseButton.client.js +15 -0
- package/dist/esnext/components/BaseButton/index.d.ts +1 -0
- package/dist/esnext/components/BaseButton/index.js +1 -0
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.d.ts +2 -5
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.js +5 -4
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.js +4 -4
- package/dist/esnext/components/CartLineProvider/context.d.ts +4 -4
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +4 -5
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +16 -14
- package/dist/esnext/components/CartLines/CartLines.client.js +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +31 -35
- package/dist/esnext/components/CartProvider/hooks.client.js +2 -3
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +13 -0
- package/dist/esnext/components/Image/Image.js +46 -20
- package/dist/esnext/components/Link/Link.client.js +1 -1
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +2 -2
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +6 -10
- package/dist/esnext/components/Metafield/Metafield.client.js +67 -31
- package/dist/esnext/components/Metafield/components/StarRating/StarRating.js +1 -1
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +2 -3
- package/dist/esnext/components/Money/Money.client.js +1 -1
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +16 -24
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +7 -7
- package/dist/esnext/components/Seo/CollectionSeo.client.js +2 -3
- package/dist/esnext/components/Seo/DefaultPageSeo.client.js +3 -3
- package/dist/esnext/components/Seo/NoIndexSeo.client.js +2 -2
- package/dist/esnext/components/Seo/PageSeo.client.js +2 -3
- package/dist/esnext/components/Seo/ProductSeo.client.js +9 -10
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +2 -3
- package/dist/esnext/components/Video/Video.js +2 -3
- package/dist/esnext/config.d.ts +4 -0
- package/dist/esnext/config.js +4 -0
- package/dist/esnext/constants.d.ts +2 -0
- package/dist/esnext/constants.js +2 -0
- package/dist/esnext/entry-client.js +5 -19
- package/dist/esnext/entry-server.d.ts +1 -17
- package/dist/esnext/entry-server.js +189 -48
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.d.ts +4 -0
- package/dist/esnext/foundation/Analytics/{ServerAnalyticsRoute.server.js → ServerAnalyticsRoute.js} +5 -4
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.js +27 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.js +21 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ShopifyAnalytics.server.js +2 -3
- package/dist/esnext/foundation/BuiltInRoutes/BuiltInRoutes.d.ts +2 -0
- package/dist/esnext/foundation/BuiltInRoutes/BuiltInRoutes.js +23 -0
- package/dist/esnext/foundation/BuiltInRoutes/healthCheck.d.ts +1 -0
- package/dist/esnext/foundation/BuiltInRoutes/healthCheck.js +3 -0
- package/dist/esnext/foundation/Cache/cache-sub-request.js +2 -2
- package/dist/esnext/foundation/Cache/cache.js +2 -2
- package/dist/esnext/foundation/Cache/strategies/index.d.ts +3 -7
- package/dist/esnext/foundation/Cache/strategies/index.js +6 -48
- package/dist/esnext/foundation/Cookie/Cookie.js +5 -0
- package/dist/esnext/foundation/DevTools/DevTools.client.d.ts +3 -0
- package/dist/esnext/foundation/DevTools/DevTools.client.js +17 -0
- package/dist/esnext/foundation/DevTools/DevTools.server.d.ts +1 -0
- package/dist/esnext/foundation/DevTools/DevTools.server.js +14 -0
- package/dist/esnext/foundation/DevTools/components/GraphQL.client.d.ts +1 -0
- package/dist/esnext/foundation/DevTools/components/GraphQL.client.js +25 -0
- package/dist/esnext/foundation/DevTools/components/Heading.d.ts +5 -0
- package/dist/esnext/foundation/DevTools/components/Heading.js +12 -0
- package/dist/esnext/foundation/DevTools/components/Interface.client.d.ts +11 -0
- package/dist/esnext/foundation/DevTools/components/Interface.client.js +47 -0
- package/dist/esnext/foundation/DevTools/components/Panels.d.ts +8 -0
- package/dist/esnext/foundation/DevTools/components/Panels.js +60 -0
- package/dist/esnext/foundation/DevTools/components/Performance.client.d.ts +14 -0
- package/dist/esnext/foundation/DevTools/components/Performance.client.js +26 -0
- package/dist/esnext/foundation/DevTools/components/Settings.client.d.ts +7 -0
- package/dist/esnext/foundation/DevTools/components/Settings.client.js +20 -0
- package/dist/esnext/foundation/DevTools/components/Table.d.ts +9 -0
- package/dist/esnext/foundation/DevTools/components/Table.js +7 -0
- package/dist/esnext/foundation/DevTools/components/icons.d.ts +2 -0
- package/dist/esnext/foundation/DevTools/components/icons.js +13 -0
- package/dist/esnext/foundation/DevTools/components/index.d.ts +2 -0
- package/dist/esnext/foundation/DevTools/components/index.js +2 -0
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +4 -4
- package/dist/esnext/foundation/Html/Html.js +4 -7
- package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts +9 -4
- package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.js +67 -10
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +5 -7
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.js +22 -20
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +1 -2
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +5 -7
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +3 -5
- package/dist/esnext/foundation/fetchSync/server/fetchSync.js +1 -1
- package/dist/esnext/foundation/useNavigate/useNavigate.js +3 -4
- package/dist/esnext/foundation/useQuery/hooks.js +15 -21
- package/dist/esnext/foundation/useServerProps/use-server-props.js +2 -2
- package/dist/esnext/foundation/useSession/useSession.js +1 -2
- package/dist/esnext/foundation/useUrl/useUrl.js +1 -2
- package/dist/esnext/framework/cache/in-memory.js +3 -3
- package/dist/esnext/framework/middleware.d.ts +1 -1
- package/dist/esnext/framework/middleware.js +3 -4
- package/dist/esnext/framework/plugin.d.ts +7 -3
- package/dist/esnext/framework/plugin.js +2 -1
- package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +70 -67
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -3
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +6 -4
- package/dist/esnext/framework/types.d.ts +5 -0
- package/dist/esnext/framework/types.js +1 -0
- package/dist/esnext/hooks/index.d.ts +0 -1
- package/dist/esnext/hooks/index.js +0 -1
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +4 -4
- package/dist/esnext/hooks/useMoney/hooks.js +53 -39
- package/dist/esnext/hooks/useProductOptions/helpers.js +6 -10
- package/dist/esnext/hooks/useShopQuery/hooks.js +18 -12
- package/dist/esnext/index.d.ts +1 -5
- package/dist/esnext/index.js +1 -5
- package/dist/{node/entry-server.d.ts → esnext/shared-types.d.ts} +11 -7
- package/dist/esnext/shared-types.js +4 -0
- package/dist/esnext/storefront-api-types.d.ts +37 -114
- package/dist/esnext/streaming.server.d.ts +9 -18
- package/dist/esnext/streaming.server.js +2 -7
- package/dist/esnext/types.d.ts +9 -18
- package/dist/esnext/types.js +1 -1
- package/dist/esnext/utilities/apiRoutes.d.ts +7 -3
- package/dist/esnext/utilities/apiRoutes.js +6 -4
- package/dist/esnext/utilities/devtools.d.ts +1 -1
- package/dist/esnext/utilities/devtools.js +3 -3
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +1 -0
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +13 -6
- package/dist/esnext/utilities/graphql-tracker.js +6 -8
- package/dist/esnext/utilities/hash.d.ts +2 -2
- package/dist/esnext/utilities/hash.js +29 -6
- package/dist/esnext/utilities/image_size.d.ts +24 -3
- package/dist/esnext/utilities/image_size.js +53 -31
- package/dist/esnext/utilities/index.d.ts +1 -1
- package/dist/esnext/utilities/index.js +1 -1
- package/dist/esnext/utilities/load_script.js +1 -1
- package/dist/esnext/utilities/log/log-cache-api-status.js +3 -2
- package/dist/esnext/utilities/log/log-query-timeline.js +29 -10
- package/dist/esnext/utilities/log/log.js +1 -2
- package/dist/esnext/utilities/log/utils.js +1 -6
- package/dist/esnext/utilities/parseMetafield/index.d.ts +1 -0
- package/dist/esnext/utilities/parseMetafield/index.js +1 -0
- package/dist/esnext/utilities/parseMetafield/parseMetafield.d.ts +15 -0
- package/dist/esnext/utilities/{parseMetafieldValue/parseMetafieldValue.js → parseMetafield/parseMetafield.js} +28 -2
- package/dist/esnext/utilities/storefrontApi.js +9 -5
- package/dist/esnext/utilities/template.js +1 -2
- package/dist/esnext/utilities/web-api-polyfill.js +6 -0
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/framework/cache/in-memory.js +3 -3
- package/dist/node/framework/middleware.d.ts +1 -1
- package/dist/node/framework/middleware.js +3 -4
- package/dist/node/framework/plugin.d.ts +4 -3
- package/dist/node/framework/plugin.js +3 -2
- package/dist/node/framework/plugins/vite-plugin-client-imports.js +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +70 -67
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -3
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +2 -2
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +6 -4
- package/dist/node/framework/types.d.ts +5 -0
- package/dist/node/{components/CartProvider → framework}/types.js +0 -0
- package/dist/node/shared-types.d.ts +26 -0
- package/dist/node/shared-types.js +5 -0
- package/dist/node/utilities/web-api-polyfill.js +6 -0
- package/package.json +32 -26
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +64 -30
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +50 -13
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +28 -27
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +50 -13
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +28 -28
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +3 -5
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +64 -30
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +50 -13
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +50 -13
- package/client.d.ts +0 -1
- package/client.js +0 -1
- package/config.d.ts +0 -1
- package/config.js +0 -1
- package/dist/esnext/components/DevTools.client.d.ts +0 -1
- package/dist/esnext/components/DevTools.client.js +0 -129
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +0 -2
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/ServerAnalyticsConnector.server.js +0 -25
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/connectors/Shopify/ServerAnalyticsConnector.server.js +0 -19
- package/dist/esnext/framework/Hydration/rsc.d.ts +0 -8
- package/dist/esnext/framework/Hydration/rsc.js +0 -102
- package/dist/esnext/hooks/useParsedMetafields/index.d.ts +0 -1
- package/dist/esnext/hooks/useParsedMetafields/index.js +0 -1
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +0 -21
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +0 -21
- package/dist/esnext/utilities/parseMetafieldValue/index.d.ts +0 -1
- package/dist/esnext/utilities/parseMetafieldValue/index.js +0 -1
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +0 -6
- package/dist/node/client.d.ts +0 -16
- package/dist/node/client.js +0 -43
- package/dist/node/components/AddToCartButton/AddToCartButton.client.d.ts +0 -23
- package/dist/node/components/AddToCartButton/AddToCartButton.client.js +0 -74
- package/dist/node/components/AddToCartButton/index.d.ts +0 -1
- package/dist/node/components/AddToCartButton/index.js +0 -5
- package/dist/node/components/BuyNowButton/BuyNowButton.client.d.ts +0 -18
- package/dist/node/components/BuyNowButton/BuyNowButton.client.js +0 -53
- package/dist/node/components/BuyNowButton/index.d.ts +0 -1
- package/dist/node/components/BuyNowButton/index.js +0 -5
- package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +0 -11
- package/dist/node/components/CartCheckoutButton/CartCheckoutButton.client.js +0 -44
- package/dist/node/components/CartCheckoutButton/index.d.ts +0 -1
- package/dist/node/components/CartCheckoutButton/index.js +0 -5
- package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +0 -14
- package/dist/node/components/CartEstimatedCost/CartEstimatedCost.client.js +0 -36
- package/dist/node/components/CartEstimatedCost/index.d.ts +0 -1
- package/dist/node/components/CartEstimatedCost/index.js +0 -5
- package/dist/node/components/CartLineImage/CartLineImage.client.d.ts +0 -9
- package/dist/node/components/CartLineImage/CartLineImage.client.js +0 -18
- package/dist/node/components/CartLineImage/index.d.ts +0 -1
- package/dist/node/components/CartLineImage/index.js +0 -5
- package/dist/node/components/CartLinePrice/CartLinePrice.client.d.ts +0 -12
- package/dist/node/components/CartLinePrice/CartLinePrice.client.js +0 -25
- package/dist/node/components/CartLinePrice/index.d.ts +0 -1
- package/dist/node/components/CartLinePrice/index.js +0 -5
- package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +0 -8
- package/dist/node/components/CartLineProductTitle/CartLineProductTitle.client.js +0 -19
- package/dist/node/components/CartLineProductTitle/index.d.ts +0 -1
- package/dist/node/components/CartLineProductTitle/index.js +0 -5
- package/dist/node/components/CartLineProvider/CartLineProvider.client.d.ts +0 -11
- package/dist/node/components/CartLineProvider/CartLineProvider.client.js +0 -15
- package/dist/node/components/CartLineProvider/context.d.ts +0 -36
- package/dist/node/components/CartLineProvider/context.js +0 -5
- package/dist/node/components/CartLineProvider/index.d.ts +0 -2
- package/dist/node/components/CartLineProvider/index.js +0 -7
- package/dist/node/components/CartLineQuantity/CartLineQuantity.client.d.ts +0 -8
- package/dist/node/components/CartLineQuantity/CartLineQuantity.client.js +0 -19
- package/dist/node/components/CartLineQuantity/index.d.ts +0 -1
- package/dist/node/components/CartLineQuantity/index.js +0 -5
- package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.d.ts +0 -14
- package/dist/node/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +0 -31
- package/dist/node/components/CartLineQuantityAdjustButton/index.d.ts +0 -1
- package/dist/node/components/CartLineQuantityAdjustButton/index.js +0 -5
- package/dist/node/components/CartLines/CartLines.client.d.ts +0 -15
- package/dist/node/components/CartLines/CartLines.client.js +0 -44
- package/dist/node/components/CartLines/index.d.ts +0 -1
- package/dist/node/components/CartLines/index.js +0 -5
- package/dist/node/components/CartProvider/CartProvider.client.d.ts +0 -41
- package/dist/node/components/CartProvider/CartProvider.client.js +0 -547
- package/dist/node/components/CartProvider/cart-queries.d.ts +0 -10
- package/dist/node/components/CartProvider/cart-queries.js +0 -214
- package/dist/node/components/CartProvider/constants.d.ts +0 -2
- package/dist/node/components/CartProvider/constants.js +0 -5
- package/dist/node/components/CartProvider/context.d.ts +0 -2
- package/dist/node/components/CartProvider/context.js +0 -5
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartAttributesUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.d.ts +0 -95
- package/dist/node/components/CartProvider/graphql/CartCreateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartFragment.d.ts +0 -82
- package/dist/node/components/CartProvider/graphql/CartFragment.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartLineAddMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartLineRemoveMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartLineUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +0 -96
- package/dist/node/components/CartProvider/graphql/CartNoteUpdateMutation.js +0 -2
- package/dist/node/components/CartProvider/graphql/CartQuery.d.ts +0 -91
- package/dist/node/components/CartProvider/graphql/CartQuery.js +0 -2
- package/dist/node/components/CartProvider/hooks.client.d.ts +0 -15
- package/dist/node/components/CartProvider/hooks.client.js +0 -88
- package/dist/node/components/CartProvider/index.d.ts +0 -4
- package/dist/node/components/CartProvider/index.js +0 -10
- package/dist/node/components/CartProvider/types.d.ts +0 -104
- package/dist/node/components/CartShopPayButton/CartShopPayButton.client.d.ts +0 -9
- package/dist/node/components/CartShopPayButton/CartShopPayButton.client.js +0 -46
- package/dist/node/components/CartShopPayButton/index.d.ts +0 -1
- package/dist/node/components/CartShopPayButton/index.js +0 -5
- package/dist/node/components/ExternalVideo/ExternalVideo.d.ts +0 -21
- package/dist/node/components/ExternalVideo/ExternalVideo.js +0 -21
- package/dist/node/components/ExternalVideo/index.d.ts +0 -1
- package/dist/node/components/ExternalVideo/index.js +0 -5
- package/dist/node/components/Image/Image.d.ts +0 -92
- package/dist/node/components/Image/Image.js +0 -137
- package/dist/node/components/Image/index.d.ts +0 -2
- package/dist/node/components/Image/index.js +0 -5
- package/dist/node/components/Link/Link.client.d.ts +0 -25
- package/dist/node/components/Link/Link.client.js +0 -165
- package/dist/node/components/Link/index.d.ts +0 -1
- package/dist/node/components/Link/index.js +0 -5
- package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.d.ts +0 -6
- package/dist/node/components/LocalizationProvider/LocalizationClientProvider.client.js +0 -11
- package/dist/node/components/LocalizationProvider/LocalizationContext.client.d.ts +0 -6
- package/dist/node/components/LocalizationProvider/LocalizationContext.client.js +0 -5
- package/dist/node/components/LocalizationProvider/LocalizationProvider.server.d.ts +0 -33
- package/dist/node/components/LocalizationProvider/LocalizationProvider.server.js +0 -51
- package/dist/node/components/MediaFile/MediaFile.d.ts +0 -19
- package/dist/node/components/MediaFile/MediaFile.js +0 -39
- package/dist/node/components/MediaFile/index.d.ts +0 -1
- package/dist/node/components/MediaFile/index.js +0 -5
- package/dist/node/components/Metafield/Metafield.client.d.ts +0 -21
- package/dist/node/components/Metafield/Metafield.client.js +0 -75
- package/dist/node/components/Metafield/index.d.ts +0 -2
- package/dist/node/components/Metafield/index.js +0 -5
- package/dist/node/components/Metafield/types.d.ts +0 -4
- package/dist/node/components/Metafield/types.js +0 -2
- package/dist/node/components/ModelViewer/ModelViewer.client.d.ts +0 -128
- package/dist/node/components/ModelViewer/ModelViewer.client.js +0 -132
- package/dist/node/components/ModelViewer/index.d.ts +0 -1
- package/dist/node/components/ModelViewer/index.js +0 -5
- package/dist/node/components/Money/Money.client.d.ts +0 -25
- package/dist/node/components/Money/Money.client.js +0 -46
- package/dist/node/components/Money/index.d.ts +0 -1
- package/dist/node/components/Money/index.js +0 -5
- package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.d.ts +0 -21
- package/dist/node/components/ProductOptionsProvider/ProductOptionsProvider.client.js +0 -168
- package/dist/node/components/ProductOptionsProvider/context.d.ts +0 -2
- package/dist/node/components/ProductOptionsProvider/context.js +0 -5
- package/dist/node/components/ProductOptionsProvider/index.d.ts +0 -2
- package/dist/node/components/ProductOptionsProvider/index.js +0 -7
- package/dist/node/components/ProductPrice/ProductPrice.client.d.ts +0 -18
- package/dist/node/components/ProductPrice/ProductPrice.client.js +0 -61
- package/dist/node/components/ProductPrice/index.d.ts +0 -1
- package/dist/node/components/ProductPrice/index.js +0 -5
- package/dist/node/components/Seo/CollectionSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/CollectionSeo.client.js +0 -22
- package/dist/node/components/Seo/DefaultPageSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/DefaultPageSeo.client.js +0 -25
- package/dist/node/components/Seo/DescriptionSeo.client.d.ts +0 -4
- package/dist/node/components/Seo/DescriptionSeo.client.js +0 -17
- package/dist/node/components/Seo/HomePageSeo.client.d.ts +0 -2
- package/dist/node/components/Seo/HomePageSeo.client.js +0 -32
- package/dist/node/components/Seo/ImageSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/ImageSeo.client.js +0 -17
- package/dist/node/components/Seo/NoIndexSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/NoIndexSeo.client.js +0 -17
- package/dist/node/components/Seo/PageSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/PageSeo.client.js +0 -20
- package/dist/node/components/Seo/ProductSeo.client.d.ts +0 -5
- package/dist/node/components/Seo/ProductSeo.client.js +0 -70
- package/dist/node/components/Seo/Seo.client.d.ts +0 -30
- package/dist/node/components/Seo/Seo.client.js +0 -38
- package/dist/node/components/Seo/TitleSeo.client.d.ts +0 -3
- package/dist/node/components/Seo/TitleSeo.client.js +0 -17
- package/dist/node/components/Seo/TwitterSeo.client.d.ts +0 -2
- package/dist/node/components/Seo/TwitterSeo.client.js +0 -16
- package/dist/node/components/Seo/index.d.ts +0 -1
- package/dist/node/components/Seo/index.js +0 -5
- package/dist/node/components/Seo/seo-types.d.ts +0 -17
- package/dist/node/components/Seo/seo-types.js +0 -2
- package/dist/node/components/ShopPayButton/ShopPayButton.client.d.ts +0 -38
- package/dist/node/components/ShopPayButton/ShopPayButton.client.js +0 -60
- package/dist/node/components/ShopPayButton/index.d.ts +0 -1
- package/dist/node/components/ShopPayButton/index.js +0 -5
- package/dist/node/components/Video/Video.d.ts +0 -14
- package/dist/node/components/Video/Video.js +0 -31
- package/dist/node/components/Video/index.d.ts +0 -1
- package/dist/node/components/Video/index.js +0 -5
- package/dist/node/components/index.d.ts +0 -28
- package/dist/node/components/index.js +0 -59
- package/dist/node/components/types.d.ts +0 -71
- package/dist/node/components/types.js +0 -11
- package/dist/node/constants.d.ts +0 -7
- package/dist/node/constants.js +0 -10
- package/dist/node/entry-server.js +0 -495
- package/dist/node/foundation/Analytics/Analytics.client.d.ts +0 -3
- package/dist/node/foundation/Analytics/Analytics.client.js +0 -34
- package/dist/node/foundation/Analytics/Analytics.server.d.ts +0 -1
- package/dist/node/foundation/Analytics/Analytics.server.js +0 -77
- package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +0 -27
- package/dist/node/foundation/Analytics/ClientAnalytics.js +0 -102
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +0 -2
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +0 -39
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.d.ts +0 -7
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +0 -68
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.d.ts +0 -1
- package/dist/node/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetricsDebug.client.js +0 -27
- package/dist/node/foundation/Analytics/const.d.ts +0 -9
- package/dist/node/foundation/Analytics/const.js +0 -12
- package/dist/node/foundation/Analytics/hook.d.ts +0 -1
- package/dist/node/foundation/Analytics/hook.js +0 -13
- package/dist/node/foundation/Analytics/index.d.ts +0 -1
- package/dist/node/foundation/Analytics/index.js +0 -5
- package/dist/node/foundation/Analytics/types.d.ts +0 -5
- package/dist/node/foundation/Analytics/types.js +0 -2
- package/dist/node/foundation/Analytics/utils.d.ts +0 -3
- package/dist/node/foundation/Analytics/utils.js +0 -35
- package/dist/node/foundation/AnalyticsErrorBoundary.client.d.ts +0 -4
- package/dist/node/foundation/AnalyticsErrorBoundary.client.js +0 -14
- package/dist/node/foundation/Cache/cache-sub-request.d.ts +0 -17
- package/dist/node/foundation/Cache/cache-sub-request.js +0 -95
- package/dist/node/foundation/Cache/cache.d.ts +0 -17
- package/dist/node/foundation/Cache/cache.js +0 -135
- package/dist/node/foundation/Cache/strategies/index.d.ts +0 -11
- package/dist/node/foundation/Cache/strategies/index.js +0 -108
- package/dist/node/foundation/Head/Head.client.d.ts +0 -5
- package/dist/node/foundation/Head/Head.client.js +0 -17
- package/dist/node/foundation/Head/index.d.ts +0 -1
- package/dist/node/foundation/Head/index.js +0 -5
- package/dist/node/foundation/Html/Html.d.ts +0 -13
- package/dist/node/foundation/Html/Html.js +0 -107
- package/dist/node/foundation/HydrogenRequest/HydrogenRequest.server.d.ts +0 -63
- package/dist/node/foundation/HydrogenRequest/HydrogenRequest.server.js +0 -151
- package/dist/node/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +0 -23
- package/dist/node/foundation/HydrogenResponse/HydrogenResponse.server.js +0 -53
- package/dist/node/foundation/Redirect/Redirect.client.d.ts +0 -5
- package/dist/node/foundation/Redirect/Redirect.client.js +0 -18
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +0 -14
- package/dist/node/foundation/Router/BrowserRouter.client.js +0 -166
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +0 -41
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -90
- package/dist/node/foundation/ServerPropsProvider/index.d.ts +0 -2
- package/dist/node/foundation/ServerPropsProvider/index.js +0 -6
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +0 -22
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +0 -155
- package/dist/node/foundation/ServerRequestProvider/index.d.ts +0 -1
- package/dist/node/foundation/ServerRequestProvider/index.js +0 -17
- package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.d.ts +0 -7
- package/dist/node/foundation/ShopifyProvider/ShopifyProvider.client.js +0 -35
- package/dist/node/foundation/ShopifyProvider/index.d.ts +0 -1
- package/dist/node/foundation/ShopifyProvider/index.js +0 -5
- package/dist/node/foundation/ShopifyProvider/types.d.ts +0 -13
- package/dist/node/foundation/ShopifyProvider/types.js +0 -2
- package/dist/node/foundation/fetchSync/client/fetchSync.d.ts +0 -10
- package/dist/node/foundation/fetchSync/client/fetchSync.js +0 -33
- package/dist/node/foundation/fetchSync/server/fetchSync.d.ts +0 -8
- package/dist/node/foundation/fetchSync/server/fetchSync.js +0 -33
- package/dist/node/foundation/fetchSync/types.d.ts +0 -5
- package/dist/node/foundation/fetchSync/types.js +0 -2
- package/dist/node/foundation/index.d.ts +0 -3
- package/dist/node/foundation/index.js +0 -10
- package/dist/node/foundation/runtime.d.ts +0 -2
- package/dist/node/foundation/runtime.js +0 -11
- package/dist/node/foundation/session/session.d.ts +0 -27
- package/dist/node/foundation/session/session.js +0 -43
- package/dist/node/foundation/ssr-interop.d.ts +0 -29
- package/dist/node/foundation/ssr-interop.js +0 -39
- package/dist/node/foundation/useNavigate/useNavigate.d.ts +0 -15
- package/dist/node/foundation/useNavigate/useNavigate.js +0 -25
- package/dist/node/foundation/useQuery/hooks.d.ts +0 -37
- package/dist/node/foundation/useQuery/hooks.js +0 -119
- package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.d.ts +0 -10
- package/dist/node/foundation/useRouteParams/RouteParamsProvider.client.js +0 -34
- package/dist/node/foundation/useRouteParams/useRouteParams.d.ts +0 -4
- package/dist/node/foundation/useRouteParams/useRouteParams.js +0 -13
- package/dist/node/foundation/useServerProps/index.d.ts +0 -1
- package/dist/node/foundation/useServerProps/index.js +0 -5
- package/dist/node/foundation/useServerProps/use-server-props.d.ts +0 -21
- package/dist/node/foundation/useServerProps/use-server-props.js +0 -40
- package/dist/node/foundation/useSession/useSession.d.ts +0 -2
- package/dist/node/foundation/useSession/useSession.js +0 -12
- package/dist/node/foundation/useShop/index.d.ts +0 -1
- package/dist/node/foundation/useShop/index.js +0 -5
- package/dist/node/foundation/useShop/use-shop.d.ts +0 -6
- package/dist/node/foundation/useShop/use-shop.js +0 -18
- package/dist/node/foundation/useUrl/index.d.ts +0 -1
- package/dist/node/foundation/useUrl/index.js +0 -5
- package/dist/node/foundation/useUrl/useUrl.d.ts +0 -4
- package/dist/node/foundation/useUrl/useUrl.js +0 -32
- package/dist/node/framework/Hydration/rsc.d.ts +0 -8
- package/dist/node/framework/Hydration/rsc.js +0 -105
- package/dist/node/hooks/index.d.ts +0 -6
- package/dist/node/hooks/index.js +0 -28
- package/dist/node/hooks/useCart/index.d.ts +0 -1
- package/dist/node/hooks/useCart/index.js +0 -5
- package/dist/node/hooks/useCart/useCart.d.ts +0 -4
- package/dist/node/hooks/useCart/useCart.js +0 -19
- package/dist/node/hooks/useCartLine/index.d.ts +0 -1
- package/dist/node/hooks/useCartLine/index.js +0 -5
- package/dist/node/hooks/useCartLine/useCartLine.d.ts +0 -39
- package/dist/node/hooks/useCartLine/useCartLine.js +0 -16
- package/dist/node/hooks/useCountry/index.d.ts +0 -1
- package/dist/node/hooks/useCountry/index.js +0 -5
- package/dist/node/hooks/useCountry/useCountry.d.ts +0 -7
- package/dist/node/hooks/useCountry/useCountry.js +0 -21
- package/dist/node/hooks/useLoadScript/index.d.ts +0 -1
- package/dist/node/hooks/useLoadScript/index.js +0 -5
- package/dist/node/hooks/useLoadScript/useLoadScript.client.d.ts +0 -8
- package/dist/node/hooks/useLoadScript/useLoadScript.client.js +0 -27
- package/dist/node/hooks/useMeasurement/hooks.d.ts +0 -9
- package/dist/node/hooks/useMeasurement/hooks.js +0 -17
- package/dist/node/hooks/useMeasurement/index.d.ts +0 -1
- package/dist/node/hooks/useMeasurement/index.js +0 -5
- package/dist/node/hooks/useMoney/hooks.d.ts +0 -54
- package/dist/node/hooks/useMoney/hooks.js +0 -70
- package/dist/node/hooks/useMoney/index.d.ts +0 -1
- package/dist/node/hooks/useMoney/index.js +0 -5
- package/dist/node/hooks/useParsedMetafields/index.d.ts +0 -1
- package/dist/node/hooks/useParsedMetafields/index.js +0 -5
- package/dist/node/hooks/useParsedMetafields/useParsedMetafields.d.ts +0 -21
- package/dist/node/hooks/useParsedMetafields/useParsedMetafields.js +0 -25
- package/dist/node/hooks/useProductOptions/helpers.d.ts +0 -6
- package/dist/node/hooks/useProductOptions/helpers.js +0 -46
- package/dist/node/hooks/useProductOptions/index.d.ts +0 -2
- package/dist/node/hooks/useProductOptions/index.js +0 -20
- package/dist/node/hooks/useProductOptions/types.d.ts +0 -44
- package/dist/node/hooks/useProductOptions/types.js +0 -2
- package/dist/node/hooks/useProductOptions/useProductOptions.client.d.ts +0 -1
- package/dist/node/hooks/useProductOptions/useProductOptions.client.js +0 -13
- package/dist/node/hooks/useShopQuery/hooks.d.ts +0 -28
- package/dist/node/hooks/useShopQuery/hooks.js +0 -171
- package/dist/node/hooks/useShopQuery/index.d.ts +0 -1
- package/dist/node/hooks/useShopQuery/index.js +0 -5
- package/dist/node/storefront-api-types.d.ts +0 -6076
- package/dist/node/storefront-api-types.js +0 -1766
- package/dist/node/streaming.server.d.ts +0 -25
- package/dist/node/streaming.server.js +0 -28
- package/dist/node/types.d.ts +0 -114
- package/dist/node/types.js +0 -2
- package/dist/node/utilities/apiRoutes.d.ts +0 -37
- package/dist/node/utilities/apiRoutes.js +0 -157
- package/dist/node/utilities/bot-ua.d.ts +0 -4
- package/dist/node/utilities/bot-ua.js +0 -65
- package/dist/node/utilities/devtools.d.ts +0 -11
- package/dist/node/utilities/devtools.js +0 -15
- package/dist/node/utilities/error.d.ts +0 -1
- package/dist/node/utilities/error.js +0 -10
- package/dist/node/utilities/fetch.d.ts +0 -9
- package/dist/node/utilities/fetch.js +0 -37
- package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +0 -6
- package/dist/node/utilities/flattenConnection/flattenConnection.js +0 -15
- package/dist/node/utilities/flattenConnection/index.d.ts +0 -1
- package/dist/node/utilities/flattenConnection/index.js +0 -5
- package/dist/node/utilities/graphql-tag.d.ts +0 -1
- package/dist/node/utilities/graphql-tag.js +0 -10
- package/dist/node/utilities/graphql-tracker.d.ts +0 -17
- package/dist/node/utilities/graphql-tracker.js +0 -130
- package/dist/node/utilities/hash.d.ts +0 -2
- package/dist/node/utilities/hash.js +0 -11
- package/dist/node/utilities/html-encoding.d.ts +0 -1
- package/dist/node/utilities/html-encoding.js +0 -12
- package/dist/node/utilities/image_size.d.ts +0 -12
- package/dist/node/utilities/image_size.js +0 -68
- package/dist/node/utilities/index.d.ts +0 -12
- package/dist/node/utilities/index.js +0 -33
- package/dist/node/utilities/isBrowser/index.d.ts +0 -1
- package/dist/node/utilities/isBrowser/index.js +0 -5
- package/dist/node/utilities/isBrowser/isBrowser.d.ts +0 -4
- package/dist/node/utilities/isBrowser/isBrowser.js +0 -10
- package/dist/node/utilities/isServer/index.d.ts +0 -1
- package/dist/node/utilities/isServer/index.js +0 -5
- package/dist/node/utilities/isServer/isServer.d.ts +0 -4
- package/dist/node/utilities/isServer/isServer.js +0 -11
- package/dist/node/utilities/load_script.d.ts +0 -3
- package/dist/node/utilities/load_script.js +0 -27
- package/dist/node/utilities/log/index.d.ts +0 -4
- package/dist/node/utilities/log/index.js +0 -16
- package/dist/node/utilities/log/log-cache-api-status.d.ts +0 -1
- package/dist/node/utilities/log/log-cache-api-status.js +0 -17
- package/dist/node/utilities/log/log-cache-header.d.ts +0 -10
- package/dist/node/utilities/log/log-cache-header.js +0 -35
- package/dist/node/utilities/log/log-query-timeline.d.ts +0 -12
- package/dist/node/utilities/log/log-query-timeline.js +0 -88
- package/dist/node/utilities/log/log.d.ts +0 -28
- package/dist/node/utilities/log/log.js +0 -81
- package/dist/node/utilities/log/utils.d.ts +0 -3
- package/dist/node/utilities/log/utils.js +0 -21
- package/dist/node/utilities/matchPath.d.ts +0 -10
- package/dist/node/utilities/matchPath.js +0 -58
- package/dist/node/utilities/measurement.d.ts +0 -3
- package/dist/node/utilities/measurement.js +0 -103
- package/dist/node/utilities/parse.d.ts +0 -1
- package/dist/node/utilities/parse.js +0 -13
- package/dist/node/utilities/parseMetafieldValue/index.d.ts +0 -1
- package/dist/node/utilities/parseMetafieldValue/index.js +0 -5
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +0 -6
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +0 -40
- package/dist/node/utilities/storefrontApi.d.ts +0 -4
- package/dist/node/utilities/storefrontApi.js +0 -26
- package/dist/node/utilities/suspense.d.ts +0 -12
- package/dist/node/utilities/suspense.js +0 -64
- package/dist/node/utilities/template.d.ts +0 -9
- package/dist/node/utilities/template.js +0 -27
- package/dist/node/utilities/timing.d.ts +0 -7
- package/dist/node/utilities/timing.js +0 -18
- package/dist/node/utilities/video_parameters.d.ts +0 -47
- package/dist/node/utilities/video_parameters.js +0 -27
- package/dist/node/version.d.ts +0 -1
- package/dist/node/version.js +0 -4
- package/entry-client.d.ts +0 -1
- package/entry-client.js +0 -1
- package/entry-server.d.ts +0 -1
- package/entry-server.js +0 -1
- package/middleware.d.ts +0 -1
- package/middleware.js +0 -1
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -1
- package/web-polyfills.js +0 -1
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HydrogenResponse = void 0;
|
|
7
|
-
const strategies_1 = require("../Cache/strategies");
|
|
8
|
-
const Redirect_client_1 = __importDefault(require("../Redirect/Redirect.client"));
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
|
-
class HydrogenResponse extends Response {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
this.wait = false;
|
|
14
|
-
this.cacheOptions = (0, strategies_1.CacheSeconds)();
|
|
15
|
-
}
|
|
16
|
-
get status() {
|
|
17
|
-
var _a;
|
|
18
|
-
return (_a = this.customStatus) !== null && _a !== void 0 ? _a : super.status;
|
|
19
|
-
}
|
|
20
|
-
set status(number) {
|
|
21
|
-
this.customStatus = number;
|
|
22
|
-
}
|
|
23
|
-
get statusText() {
|
|
24
|
-
var _a;
|
|
25
|
-
return (_a = this.customStatusText) !== null && _a !== void 0 ? _a : super.statusText;
|
|
26
|
-
}
|
|
27
|
-
set statusText(text) {
|
|
28
|
-
this.customStatusText = text;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Buffer the current response until all queries have resolved,
|
|
32
|
-
* and prevent it from streaming back early.
|
|
33
|
-
*/
|
|
34
|
-
doNotStream() {
|
|
35
|
-
this.wait = true;
|
|
36
|
-
}
|
|
37
|
-
canStream() {
|
|
38
|
-
return !this.wait;
|
|
39
|
-
}
|
|
40
|
-
cache(options) {
|
|
41
|
-
this.cacheOptions = options;
|
|
42
|
-
}
|
|
43
|
-
get cacheControlHeader() {
|
|
44
|
-
return (0, strategies_1.generateCacheControlHeader)(this.cacheOptions);
|
|
45
|
-
}
|
|
46
|
-
redirect(location, status = 307) {
|
|
47
|
-
this.status = status;
|
|
48
|
-
this.headers.set('location', location);
|
|
49
|
-
// in the case of an RSC request, instead render a client component that will redirect
|
|
50
|
-
return react_1.default.createElement(Redirect_client_1.default, { to: location });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.HydrogenResponse = HydrogenResponse;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const useNavigate_1 = require("../../foundation/useNavigate/useNavigate");
|
|
5
|
-
function Redirect({ to }) {
|
|
6
|
-
const navigate = (0, useNavigate_1.useNavigate)();
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
8
|
-
if (to.startsWith('http')) {
|
|
9
|
-
window.location.href = to;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
navigate(to);
|
|
13
|
-
}
|
|
14
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
-
}, []);
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
exports.default = Redirect;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BrowserHistory, Location } from 'history';
|
|
2
|
-
import React, { FC, ReactNode } from 'react';
|
|
3
|
-
declare type RouterContextValue = {
|
|
4
|
-
history: BrowserHistory;
|
|
5
|
-
location: Location;
|
|
6
|
-
};
|
|
7
|
-
export declare const RouterContext: React.Context<{} | RouterContextValue>;
|
|
8
|
-
export declare const BrowserRouter: FC<{
|
|
9
|
-
history?: BrowserHistory;
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function useRouter(): RouterContextValue;
|
|
13
|
-
export declare function useLocation(): Location;
|
|
14
|
-
export {};
|
|
@@ -1,166 +0,0 @@
|
|
|
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.useLocation = exports.useRouter = exports.BrowserRouter = exports.RouterContext = void 0;
|
|
27
|
-
const history_1 = require("history");
|
|
28
|
-
const react_1 = __importStar(require("react"));
|
|
29
|
-
const ssr_interop_1 = require("../ssr-interop");
|
|
30
|
-
const use_server_props_1 = require("../useServerProps/use-server-props");
|
|
31
|
-
exports.RouterContext = (0, react_1.createContext)({});
|
|
32
|
-
let isFirstLoad = true;
|
|
33
|
-
const positions = {};
|
|
34
|
-
const BrowserRouter = ({ history: pHistory, children }) => {
|
|
35
|
-
if (ssr_interop_1.META_ENV_SSR)
|
|
36
|
-
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
37
|
-
/* eslint-disable react-hooks/rules-of-hooks */
|
|
38
|
-
const history = (0, react_1.useMemo)(() => pHistory || (0, history_1.createBrowserHistory)(), [pHistory]);
|
|
39
|
-
const [location, setLocation] = (0, react_1.useState)(history.location);
|
|
40
|
-
const [scrollNeedsRestoration, setScrollNeedsRestoration] = (0, react_1.useState)(false);
|
|
41
|
-
const { pending, locationServerProps, setLocationServerProps } = (0, use_server_props_1.useInternalServerProps)();
|
|
42
|
-
useScrollRestoration({
|
|
43
|
-
location,
|
|
44
|
-
pending,
|
|
45
|
-
serverProps: locationServerProps,
|
|
46
|
-
scrollNeedsRestoration,
|
|
47
|
-
onFinishNavigating: () => setScrollNeedsRestoration(false),
|
|
48
|
-
});
|
|
49
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
50
|
-
const unlisten = history.listen(({ location: newLocation, action }) => {
|
|
51
|
-
var _a;
|
|
52
|
-
positions[location.key] = window.scrollY;
|
|
53
|
-
setLocationServerProps({
|
|
54
|
-
pathname: newLocation.pathname,
|
|
55
|
-
search: newLocation.search,
|
|
56
|
-
});
|
|
57
|
-
setLocation(newLocation);
|
|
58
|
-
const state = ((_a = newLocation.state) !== null && _a !== void 0 ? _a : {});
|
|
59
|
-
/**
|
|
60
|
-
* "pop" navigations, like forward/backward buttons, always restore scroll position
|
|
61
|
-
* regardless of what the original forward navigation intent was.
|
|
62
|
-
*/
|
|
63
|
-
const needsScrollRestoration = action === 'POP' || !!state.scroll;
|
|
64
|
-
setScrollNeedsRestoration(needsScrollRestoration);
|
|
65
|
-
});
|
|
66
|
-
return () => unlisten();
|
|
67
|
-
}, [
|
|
68
|
-
history,
|
|
69
|
-
location,
|
|
70
|
-
setScrollNeedsRestoration,
|
|
71
|
-
setLocation,
|
|
72
|
-
setLocationServerProps,
|
|
73
|
-
]);
|
|
74
|
-
/* eslint-enable react-hooks/rules-of-hooks */
|
|
75
|
-
return (react_1.default.createElement(exports.RouterContext.Provider, { value: {
|
|
76
|
-
history,
|
|
77
|
-
location,
|
|
78
|
-
} }, children));
|
|
79
|
-
};
|
|
80
|
-
exports.BrowserRouter = BrowserRouter;
|
|
81
|
-
function useRouter() {
|
|
82
|
-
const router = (0, react_1.useContext)(exports.RouterContext);
|
|
83
|
-
if (!router && ssr_interop_1.META_ENV_SSR) {
|
|
84
|
-
throw new Error('useRouter must be used within a <Router> component');
|
|
85
|
-
}
|
|
86
|
-
return router;
|
|
87
|
-
}
|
|
88
|
-
exports.useRouter = useRouter;
|
|
89
|
-
function useLocation() {
|
|
90
|
-
return useRouter().location;
|
|
91
|
-
}
|
|
92
|
-
exports.useLocation = useLocation;
|
|
93
|
-
/**
|
|
94
|
-
* Run a callback before browser unload.
|
|
95
|
-
*/
|
|
96
|
-
function useBeforeUnload(callback) {
|
|
97
|
-
react_1.default.useEffect(() => {
|
|
98
|
-
window.addEventListener('beforeunload', callback);
|
|
99
|
-
return () => {
|
|
100
|
-
window.removeEventListener('beforeunload', callback);
|
|
101
|
-
};
|
|
102
|
-
}, [callback]);
|
|
103
|
-
}
|
|
104
|
-
function useScrollRestoration({ location, pending, serverProps, scrollNeedsRestoration, onFinishNavigating, }) {
|
|
105
|
-
/**
|
|
106
|
-
* Browsers have an API for scroll restoration. We wait for the page to load first,
|
|
107
|
-
* in case the browser is able to restore scroll position automatically, and then
|
|
108
|
-
* set it to manual mode.
|
|
109
|
-
*/
|
|
110
|
-
(0, react_1.useEffect)(() => {
|
|
111
|
-
window.history.scrollRestoration = 'manual';
|
|
112
|
-
}, []);
|
|
113
|
-
/**
|
|
114
|
-
* If the page is reloading, allow the browser to handle its own scroll restoration.
|
|
115
|
-
*/
|
|
116
|
-
useBeforeUnload((0, react_1.useCallback)(() => {
|
|
117
|
-
window.history.scrollRestoration = 'auto';
|
|
118
|
-
}, []));
|
|
119
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
120
|
-
// The app has just loaded
|
|
121
|
-
if (isFirstLoad || !scrollNeedsRestoration) {
|
|
122
|
-
isFirstLoad = false;
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const position = positions[location.key];
|
|
126
|
-
/**
|
|
127
|
-
* When serverState gets updated, `pending` is true while the fetch is in progress.
|
|
128
|
-
* When that resolves, the serverState is updated. We should wait until the internal
|
|
129
|
-
* location pointer and serverState match, and pending is false, to do any scrolling.
|
|
130
|
-
*/
|
|
131
|
-
const finishedNavigating = !pending &&
|
|
132
|
-
location.pathname === serverProps.pathname &&
|
|
133
|
-
location.search === serverProps.search;
|
|
134
|
-
if (!finishedNavigating) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
// If there is a location hash, scroll to it
|
|
138
|
-
if (location.hash) {
|
|
139
|
-
const element = document.querySelector(location.hash);
|
|
140
|
-
if (element) {
|
|
141
|
-
element.scrollIntoView();
|
|
142
|
-
onFinishNavigating();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// If we have a matching position, scroll to it
|
|
147
|
-
if (position) {
|
|
148
|
-
window.scrollTo(0, position);
|
|
149
|
-
onFinishNavigating();
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
// Scroll to the top of new pages
|
|
153
|
-
window.scrollTo(0, 0);
|
|
154
|
-
onFinishNavigating();
|
|
155
|
-
}, [
|
|
156
|
-
location.pathname,
|
|
157
|
-
location.search,
|
|
158
|
-
location.hash,
|
|
159
|
-
location.key,
|
|
160
|
-
pending,
|
|
161
|
-
serverProps.pathname,
|
|
162
|
-
serverProps.search,
|
|
163
|
-
scrollNeedsRestoration,
|
|
164
|
-
onFinishNavigating,
|
|
165
|
-
]);
|
|
166
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
declare global {
|
|
3
|
-
var __HYDROGEN_DEV__: boolean;
|
|
4
|
-
var __HYDROGEN_TEST__: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface LocationServerProps {
|
|
7
|
-
pathname: string;
|
|
8
|
-
search: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ServerProps {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}
|
|
13
|
-
declare type ServerPropsSetterInput = ((prev: ServerProps) => Partial<ServerProps>) | Partial<ServerProps> | string;
|
|
14
|
-
export interface ServerPropsSetter {
|
|
15
|
-
(input: ServerPropsSetterInput, propValue?: any): void;
|
|
16
|
-
}
|
|
17
|
-
interface ProposedServerPropsSetter {
|
|
18
|
-
(input: ServerPropsSetterInput, propValue?: any): LocationServerProps;
|
|
19
|
-
}
|
|
20
|
-
interface BaseServerPropsContextValue {
|
|
21
|
-
pending: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface InternalServerPropsContextValue extends BaseServerPropsContextValue {
|
|
24
|
-
setLocationServerProps: ServerPropsSetter;
|
|
25
|
-
setServerProps: ServerPropsSetter;
|
|
26
|
-
serverProps: ServerProps;
|
|
27
|
-
locationServerProps: LocationServerProps;
|
|
28
|
-
getProposedLocationServerProps: ProposedServerPropsSetter;
|
|
29
|
-
}
|
|
30
|
-
export interface ServerPropsContextValue extends BaseServerPropsContextValue {
|
|
31
|
-
serverProps: ServerProps;
|
|
32
|
-
setServerProps: ServerPropsSetter;
|
|
33
|
-
}
|
|
34
|
-
export declare const ServerPropsContext: React.Context<InternalServerPropsContextValue>;
|
|
35
|
-
interface ServerPropsProviderProps {
|
|
36
|
-
initialServerProps: LocationServerProps;
|
|
37
|
-
setServerPropsForRsc: React.Dispatch<React.SetStateAction<LocationServerProps>>;
|
|
38
|
-
children: ReactNode;
|
|
39
|
-
}
|
|
40
|
-
export declare function ServerPropsProvider({ initialServerProps, setServerPropsForRsc, children, }: ServerPropsProviderProps): JSX.Element;
|
|
41
|
-
export {};
|
|
@@ -1,90 +0,0 @@
|
|
|
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.ServerPropsProvider = exports.ServerPropsContext = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const PRIVATE_PROPS = ['request', 'response'];
|
|
29
|
-
exports.ServerPropsContext = (0, react_1.createContext)(null);
|
|
30
|
-
function ServerPropsProvider({ initialServerProps, setServerPropsForRsc, children, }) {
|
|
31
|
-
const [locationServerProps, setLocationServerProps] = (0, react_1.useState)(initialServerProps);
|
|
32
|
-
const [serverProps, setServerProps] = (0, react_1.useState)({});
|
|
33
|
-
const [pending, startTransition] = (0, react_1.useTransition)();
|
|
34
|
-
const setServerPropsCallback = (0, react_1.useCallback)((input, propValue) => {
|
|
35
|
-
startTransition(() => {
|
|
36
|
-
setServerProps((prev) => getNewValue(prev, input, propValue));
|
|
37
|
-
setServerPropsForRsc((prev) => getNewValue(prev, input, propValue));
|
|
38
|
-
});
|
|
39
|
-
}, [setServerProps, setServerPropsForRsc]);
|
|
40
|
-
const setLocationServerPropsCallback = (0, react_1.useCallback)((input, propValue) => {
|
|
41
|
-
// Flush the existing user server state when location changes, leaving only the persisted state
|
|
42
|
-
startTransition(() => {
|
|
43
|
-
setServerPropsForRsc((prev) => getNewValue(prev, input, propValue));
|
|
44
|
-
setServerProps({});
|
|
45
|
-
setLocationServerProps((prev) => getNewValue(prev, input, propValue));
|
|
46
|
-
});
|
|
47
|
-
}, [setServerProps, setServerPropsForRsc, setLocationServerProps]);
|
|
48
|
-
const getProposedLocationServerPropsCallback = (0, react_1.useCallback)((input, propValue) => {
|
|
49
|
-
return getNewValue(locationServerProps, input, propValue);
|
|
50
|
-
}, [locationServerProps]);
|
|
51
|
-
function getNewValue(prev, input, propValue) {
|
|
52
|
-
let newValue;
|
|
53
|
-
if (typeof input === 'function') {
|
|
54
|
-
newValue = input(prev);
|
|
55
|
-
}
|
|
56
|
-
else if (typeof input === 'string') {
|
|
57
|
-
newValue = { [input]: propValue };
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
newValue = input;
|
|
61
|
-
}
|
|
62
|
-
if (__HYDROGEN_DEV__) {
|
|
63
|
-
const privateProp = PRIVATE_PROPS.find((prop) => prop in newValue);
|
|
64
|
-
if (privateProp) {
|
|
65
|
-
console.warn(`Custom "${privateProp}" property in server state is ignored. Use a different name.`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
...prev,
|
|
70
|
-
...newValue,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
const value = (0, react_1.useMemo)(() => ({
|
|
74
|
-
pending,
|
|
75
|
-
locationServerProps,
|
|
76
|
-
serverProps,
|
|
77
|
-
setServerProps: setServerPropsCallback,
|
|
78
|
-
setLocationServerProps: setLocationServerPropsCallback,
|
|
79
|
-
getProposedLocationServerProps: getProposedLocationServerPropsCallback,
|
|
80
|
-
}), [
|
|
81
|
-
pending,
|
|
82
|
-
locationServerProps,
|
|
83
|
-
serverProps,
|
|
84
|
-
setServerPropsCallback,
|
|
85
|
-
setLocationServerPropsCallback,
|
|
86
|
-
getProposedLocationServerPropsCallback,
|
|
87
|
-
]);
|
|
88
|
-
return (react_1.default.createElement(exports.ServerPropsContext.Provider, { value: value }, children));
|
|
89
|
-
}
|
|
90
|
-
exports.ServerPropsProvider = ServerPropsProvider;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerPropsContext = exports.ServerPropsProvider = void 0;
|
|
4
|
-
var ServerPropsProvider_1 = require("./ServerPropsProvider");
|
|
5
|
-
Object.defineProperty(exports, "ServerPropsProvider", { enumerable: true, get: function () { return ServerPropsProvider_1.ServerPropsProvider; } });
|
|
6
|
-
Object.defineProperty(exports, "ServerPropsContext", { enumerable: true, get: function () { return ServerPropsProvider_1.ServerPropsContext; } });
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PreloadQueriesByURL, HydrogenRequest } from '../HydrogenRequest/HydrogenRequest.server';
|
|
2
|
-
import type { QueryKey } from '../../types';
|
|
3
|
-
declare type ServerRequestProviderProps = {
|
|
4
|
-
request: HydrogenRequest;
|
|
5
|
-
children: JSX.Element;
|
|
6
|
-
};
|
|
7
|
-
export declare function ServerRequestProvider({ request, children, }: ServerRequestProviderProps): JSX.Element;
|
|
8
|
-
export declare function useServerRequest(): HydrogenRequest;
|
|
9
|
-
declare type RequestCacheResult<T> = {
|
|
10
|
-
data: T;
|
|
11
|
-
error?: never;
|
|
12
|
-
} | {
|
|
13
|
-
data?: never;
|
|
14
|
-
error: Response | Error;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Returns data stored in the request cache.
|
|
18
|
-
* It will throw the promise if data is not ready.
|
|
19
|
-
*/
|
|
20
|
-
export declare function useRequestCacheData<T>(key: QueryKey, fetcher: () => T | Promise<T>): RequestCacheResult<T>;
|
|
21
|
-
export declare function preloadRequestCacheData(request: HydrogenRequest, preloadQueries?: PreloadQueriesByURL): void;
|
|
22
|
-
export {};
|
|
@@ -1,155 +0,0 @@
|
|
|
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.preloadRequestCacheData = exports.useRequestCacheData = exports.useServerRequest = exports.ServerRequestProvider = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const timing_1 = require("../../utilities/timing");
|
|
29
|
-
const hash_1 = require("../../utilities/hash");
|
|
30
|
-
const log_1 = require("../../utilities/log");
|
|
31
|
-
// Context to inject current request in SSR
|
|
32
|
-
const RequestContextSSR = (0, react_1.createContext)(null);
|
|
33
|
-
// Cache to inject current request in RSC
|
|
34
|
-
function requestCacheRSC() {
|
|
35
|
-
return new Map();
|
|
36
|
-
}
|
|
37
|
-
requestCacheRSC.key = Symbol.for('HYDROGEN_REQUEST');
|
|
38
|
-
function getInternalReactDispatcher() {
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
return react_1.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
41
|
-
.ReactCurrentDispatcher.current;
|
|
42
|
-
}
|
|
43
|
-
function isRsc() {
|
|
44
|
-
// This method is only available during RSC
|
|
45
|
-
return __HYDROGEN_TEST__ || !!getInternalReactDispatcher().getCacheForType;
|
|
46
|
-
}
|
|
47
|
-
// Note: use this only during RSC/Flight rendering. The React dispatcher
|
|
48
|
-
// for SSR/Fizz rendering does not implement getCacheForType.
|
|
49
|
-
function getCacheForType(resource) {
|
|
50
|
-
var _a;
|
|
51
|
-
const dispatcher = getInternalReactDispatcher();
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
if (__HYDROGEN_TEST__ && !dispatcher.getCacheForType) {
|
|
54
|
-
// Jest does not have access to the RSC runtime, mock it here:
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
return ((_a = globalThis.__jestRscCache) !== null && _a !== void 0 ? _a : (globalThis.__jestRscCache = resource()));
|
|
57
|
-
}
|
|
58
|
-
return dispatcher.getCacheForType(resource);
|
|
59
|
-
}
|
|
60
|
-
function ServerRequestProvider({ request, children, }) {
|
|
61
|
-
if (isRsc()) {
|
|
62
|
-
// Save the request object in a React cache that is
|
|
63
|
-
// scoped to this current rendering.
|
|
64
|
-
const requestCache = getCacheForType(requestCacheRSC);
|
|
65
|
-
requestCache.set(requestCacheRSC.key, request);
|
|
66
|
-
return children;
|
|
67
|
-
}
|
|
68
|
-
// Use a normal provider in SSR to make the request object
|
|
69
|
-
// available in the current rendering.
|
|
70
|
-
return (react_1.default.createElement(RequestContextSSR.Provider, { value: request }, children));
|
|
71
|
-
}
|
|
72
|
-
exports.ServerRequestProvider = ServerRequestProvider;
|
|
73
|
-
function useServerRequest() {
|
|
74
|
-
var _a;
|
|
75
|
-
const request = isRsc()
|
|
76
|
-
? (_a = getCacheForType(requestCacheRSC)) === null || _a === void 0 ? void 0 : _a.get(requestCacheRSC.key)
|
|
77
|
-
: (0, react_1.useContext)(RequestContextSSR); // eslint-disable-line react-hooks/rules-of-hooks
|
|
78
|
-
if (!request) {
|
|
79
|
-
if (__HYDROGEN_TEST__) {
|
|
80
|
-
// Unit tests are not wrapped in ServerRequestProvider.
|
|
81
|
-
// This mocks it, instead of providing it in every test.
|
|
82
|
-
return { ctx: {} };
|
|
83
|
-
}
|
|
84
|
-
throw new Error('No ServerRequest Context found');
|
|
85
|
-
}
|
|
86
|
-
return request;
|
|
87
|
-
}
|
|
88
|
-
exports.useServerRequest = useServerRequest;
|
|
89
|
-
/**
|
|
90
|
-
* Returns data stored in the request cache.
|
|
91
|
-
* It will throw the promise if data is not ready.
|
|
92
|
-
*/
|
|
93
|
-
function useRequestCacheData(key, fetcher) {
|
|
94
|
-
const request = useServerRequest();
|
|
95
|
-
const cache = request.ctx.cache;
|
|
96
|
-
const cacheKey = (0, hash_1.hashKey)(key);
|
|
97
|
-
if (!cache.has(cacheKey)) {
|
|
98
|
-
let result;
|
|
99
|
-
let promise;
|
|
100
|
-
cache.set(cacheKey, () => {
|
|
101
|
-
if (result !== undefined) {
|
|
102
|
-
(0, log_1.collectQueryTimings)(request, key, 'rendered');
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
if (!promise) {
|
|
106
|
-
const startApiTime = (0, timing_1.getTime)();
|
|
107
|
-
const maybePromise = fetcher();
|
|
108
|
-
if (!(maybePromise instanceof Promise)) {
|
|
109
|
-
result = { data: maybePromise };
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
promise = maybePromise.then((data) => {
|
|
113
|
-
result = { data };
|
|
114
|
-
(0, log_1.collectQueryTimings)(request, key, 'resolved', (0, timing_1.getTime)() - startApiTime);
|
|
115
|
-
}, (error) => (result = { error }));
|
|
116
|
-
}
|
|
117
|
-
throw promise;
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
// Making sure the promise has returned data because it can be initated by a preload request,
|
|
121
|
-
// otherwise, we throw the promise
|
|
122
|
-
const result = cache.get(cacheKey).call();
|
|
123
|
-
if (result instanceof Promise)
|
|
124
|
-
throw result;
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
exports.useRequestCacheData = useRequestCacheData;
|
|
128
|
-
function preloadRequestCacheData(request, preloadQueries) {
|
|
129
|
-
const cache = request.ctx.cache;
|
|
130
|
-
preloadQueries === null || preloadQueries === void 0 ? void 0 : preloadQueries.forEach((preloadQuery, cacheKey) => {
|
|
131
|
-
(0, log_1.collectQueryTimings)(request, preloadQuery.key, 'preload');
|
|
132
|
-
if (!cache.has(cacheKey)) {
|
|
133
|
-
let result;
|
|
134
|
-
let promise;
|
|
135
|
-
cache.set(cacheKey, () => {
|
|
136
|
-
if (result !== undefined) {
|
|
137
|
-
(0, log_1.collectQueryTimings)(request, preloadQuery.key, 'rendered');
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
if (!promise) {
|
|
141
|
-
const startApiTime = (0, timing_1.getTime)();
|
|
142
|
-
promise = preloadQuery.fetcher().then((data) => {
|
|
143
|
-
result = { data };
|
|
144
|
-
(0, log_1.collectQueryTimings)(request, preloadQuery.key, 'resolved', (0, timing_1.getTime)() - startApiTime);
|
|
145
|
-
}, (error) => {
|
|
146
|
-
result = { error };
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
return promise;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
cache.get(cacheKey).call();
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
exports.preloadRequestCacheData = preloadRequestCacheData;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ServerRequestProvider';
|
|
@@ -1,17 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ServerRequestProvider"), exports);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ShopifyContextValue } from './types';
|
|
2
|
-
import React, { ReactNode } from 'react';
|
|
3
|
-
export declare const ShopifyContext: React.Context<ShopifyContextValue | null>;
|
|
4
|
-
export declare function ShopifyProviderClient({ children, shopifyConfig, }: {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
shopifyConfig: ShopifyContextValue;
|
|
7
|
-
}): JSX.Element;
|
|
@@ -1,35 +0,0 @@
|
|
|
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.ShopifyProviderClient = exports.ShopifyContext = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
exports.ShopifyContext = (0, react_1.createContext)(null);
|
|
29
|
-
function ShopifyProviderClient({ children, shopifyConfig, }) {
|
|
30
|
-
if (!shopifyConfig) {
|
|
31
|
-
throw new Error('The `shopifyConfig` prop should be passed to `ShopifyProvider`');
|
|
32
|
-
}
|
|
33
|
-
return (react_1.default.createElement(exports.ShopifyContext.Provider, { value: shopifyConfig }, children));
|
|
34
|
-
}
|
|
35
|
-
exports.ShopifyProviderClient = ShopifyProviderClient;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ShopifyContext } from './ShopifyProvider.client';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShopifyContext = void 0;
|
|
4
|
-
var ShopifyProvider_client_1 = require("./ShopifyProvider.client");
|
|
5
|
-
Object.defineProperty(exports, "ShopifyContext", { enumerable: true, get: function () { return ShopifyProvider_client_1.ShopifyContext; } });
|