@shopify/hydrogen 0.22.1 → 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 +378 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +2 -5
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +18 -17
- 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/CartLinePrice/CartLinePrice.client.js +5 -8
- package/dist/esnext/components/CartLineProvider/context.d.ts +10 -0
- 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.d.ts → CartLines.client.d.ts} +0 -0
- package/dist/esnext/components/CartLines/{CartLines.js → CartLines.client.js} +1 -1
- package/dist/esnext/components/CartLines/index.d.ts +1 -1
- package/dist/esnext/components/CartLines/index.js +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +31 -38
- package/dist/esnext/components/CartProvider/cart-queries.d.ts +1 -1
- package/dist/esnext/components/CartProvider/cart-queries.js +11 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +11 -1
- package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +11 -1
- package/dist/esnext/components/CartProvider/hooks.client.js +5 -8
- package/dist/esnext/components/CartProvider/types.d.ts +2 -0
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +21 -0
- package/dist/esnext/components/Image/Image.js +88 -14
- package/dist/esnext/components/Link/Link.client.d.ts +2 -0
- package/dist/esnext/components/Link/Link.client.js +8 -5
- 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.d.ts +21 -0
- package/dist/esnext/components/ProductOptionsProvider/ProductOptionsProvider.client.js +133 -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/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/components/index.d.ts +1 -1
- package/dist/esnext/components/index.js +1 -1
- 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 +107 -21
- package/dist/esnext/entry-server.d.ts +2 -31
- package/dist/esnext/entry-server.js +400 -335
- package/dist/esnext/foundation/Analytics/Analytics.client.js +15 -13
- package/dist/esnext/foundation/Analytics/Analytics.server.js +27 -20
- package/dist/esnext/foundation/Analytics/ClientAnalytics.d.ts +4 -2
- package/dist/esnext/foundation/Analytics/ClientAnalytics.js +16 -14
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.d.ts +4 -0
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.js +36 -0
- 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.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 +23 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/const.d.ts +28 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/const.js +51 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.d.ts +3 -0
- package/dist/esnext/foundation/Analytics/connectors/Shopify/utils.js +56 -0
- package/dist/esnext/foundation/Analytics/hook.js +4 -2
- package/dist/esnext/foundation/Analytics/utils.d.ts +2 -0
- package/dist/esnext/foundation/Analytics/utils.js +21 -0
- package/dist/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/{node/framework → esnext/foundation/Cache}/cache-sub-request.d.ts +1 -1
- package/dist/esnext/{framework → foundation/Cache}/cache-sub-request.js +4 -4
- package/dist/esnext/{framework → foundation/Cache}/cache.d.ts +1 -1
- package/dist/esnext/{framework → foundation/Cache}/cache.js +4 -4
- package/dist/esnext/foundation/Cache/strategies/index.d.ts +7 -0
- package/dist/esnext/foundation/Cache/strategies/index.js +54 -0
- package/dist/esnext/foundation/Cookie/Cookie.d.ts +3 -3
- 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/{node/framework/Hydration → esnext/foundation/Html}/Html.d.ts +3 -1
- package/dist/esnext/{framework/Hydration → foundation/Html}/Html.js +15 -5
- package/dist/esnext/{framework/Hydration/ServerComponentRequest.server.d.ts → foundation/HydrogenRequest/HydrogenRequest.server.d.ts} +14 -4
- package/dist/esnext/{framework/Hydration/ServerComponentRequest.server.js → foundation/HydrogenRequest/HydrogenRequest.server.js} +70 -12
- package/dist/esnext/{framework/Hydration/ServerComponentResponse.server.d.ts → foundation/HydrogenResponse/HydrogenResponse.server.d.ts} +6 -11
- package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.js +48 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +15 -9
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +2 -1
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -1
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +5 -6
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +19 -24
- 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 +4 -5
- package/dist/esnext/foundation/fetchSync/server/fetchSync.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 +10 -4
- package/dist/esnext/foundation/useQuery/hooks.d.ts +1 -0
- package/dist/esnext/foundation/useQuery/hooks.js +29 -18
- package/dist/esnext/foundation/useRequestContext/index.d.ts +15 -0
- package/dist/esnext/foundation/useRequestContext/index.js +23 -0
- 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 +4 -1
- package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +70 -64
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +3 -4
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +5 -13
- 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 +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 +10 -0
- package/dist/esnext/hooks/useMoney/hooks.js +53 -39
- package/dist/esnext/hooks/useProductOptions/helpers.js +6 -10
- package/dist/esnext/hooks/useProductOptions/types.d.ts +17 -15
- package/dist/esnext/hooks/useProductOptions/useProductOptions.client.d.ts +1 -15
- package/dist/esnext/hooks/useProductOptions/useProductOptions.client.js +8 -107
- package/dist/esnext/hooks/useShopQuery/hooks.js +30 -18
- package/dist/esnext/index.d.ts +7 -5
- package/dist/esnext/index.js +5 -5
- package/dist/esnext/shared-types.d.ts +26 -0
- package/dist/esnext/shared-types.js +4 -0
- package/dist/esnext/storefront-api-types.d.ts +37 -443
- package/dist/esnext/streaming.server.d.ts +9 -19
- package/dist/esnext/streaming.server.js +2 -11
- package/dist/esnext/types.d.ts +40 -40
- package/dist/esnext/types.js +1 -1
- package/dist/esnext/utilities/apiRoutes.d.ts +8 -4
- 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 +7 -9
- 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 +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/load_script.js +1 -1
- 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-api-status.js +3 -2
- 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-query-timeline.js +29 -10
- package/dist/esnext/utilities/log/log.d.ts +17 -11
- package/dist/esnext/utilities/log/log.js +28 -20
- 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 +5 -2
- package/dist/node/framework/plugins/vite-plugin-client-imports.js +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +70 -64
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +3 -4
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +6 -14
- 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 +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/{foundation/Analytics → 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 +34 -26
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +275 -60
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +119 -64
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +33 -32
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +241 -75
- 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 -9
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +276 -61
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +119 -64
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +241 -75
- 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/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/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/ServerAnalyticsRoute.server.d.ts +0 -2
- package/dist/esnext/foundation/Analytics/ServerAnalyticsRoute.server.js +0 -33
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.server.js +0 -24
- package/dist/esnext/framework/CachingStrategy/index.d.ts +0 -10
- package/dist/esnext/framework/CachingStrategy/index.js +0 -96
- package/dist/esnext/framework/Hydration/Html.d.ts +0 -11
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +0 -42
- package/dist/esnext/framework/Hydration/rsc.d.ts +0 -8
- package/dist/esnext/framework/Hydration/rsc.js +0 -100
- package/dist/esnext/framework/cache-sub-request.d.ts +0 -17
- 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/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/hooks/useProduct/index.d.ts +0 -1
- package/dist/esnext/hooks/useProduct/index.js +0 -1
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +0 -52
- package/dist/esnext/hooks/useProduct/useProduct.js +0 -43
- package/dist/esnext/utilities/isClient/index.d.ts +0 -1
- package/dist/esnext/utilities/isClient/index.js +0 -1
- package/dist/esnext/utilities/isClient/isClient.d.ts +0 -4
- package/dist/esnext/utilities/isClient/isClient.js +0 -6
- package/dist/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/components/Image/Image.d.ts +0 -84
- package/dist/node/components/Image/Image.js +0 -89
- package/dist/node/components/Image/index.d.ts +0 -2
- package/dist/node/components/Image/index.js +0 -5
- package/dist/node/constants.d.ts +0 -7
- package/dist/node/constants.js +0 -10
- package/dist/node/entry-server.d.ts +0 -35
- package/dist/node/entry-server.js +0 -571
- package/dist/node/foundation/Analytics/Analytics.client.d.ts +0 -3
- package/dist/node/foundation/Analytics/Analytics.client.js +0 -32
- package/dist/node/foundation/Analytics/Analytics.server.d.ts +0 -1
- package/dist/node/foundation/Analytics/Analytics.server.js +0 -70
- package/dist/node/foundation/Analytics/ClientAnalytics.d.ts +0 -25
- package/dist/node/foundation/Analytics/ClientAnalytics.js +0 -100
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.d.ts +0 -2
- package/dist/node/foundation/Analytics/ServerAnalyticsRoute.server.js +0 -37
- 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 -11
- package/dist/node/foundation/Analytics/types.d.ts +0 -5
- package/dist/node/foundation/Analytics/utils.d.ts +0 -1
- package/dist/node/foundation/Analytics/utils.js +0 -12
- package/dist/node/foundation/AnalyticsErrorBoundary.client.d.ts +0 -4
- package/dist/node/foundation/AnalyticsErrorBoundary.client.js +0 -14
- 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 -159
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +0 -40
- 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 -23
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +0 -158
- package/dist/node/foundation/ServerRequestProvider/index.d.ts +0 -1
- package/dist/node/foundation/ServerRequestProvider/index.js +0 -17
- package/dist/node/foundation/ShopifyProvider/types.d.ts +0 -13
- package/dist/node/foundation/ShopifyProvider/types.js +0 -2
- 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 -13
- package/dist/node/foundation/useNavigate/useNavigate.js +0 -18
- 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/framework/CachingStrategy/index.d.ts +0 -10
- package/dist/node/framework/CachingStrategy/index.js +0 -108
- package/dist/node/framework/Hydration/Html.js +0 -94
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +0 -58
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +0 -150
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +0 -26
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +0 -49
- package/dist/node/framework/Hydration/rsc.d.ts +0 -8
- package/dist/node/framework/Hydration/rsc.js +0 -103
- package/dist/node/framework/cache-sub-request.js +0 -95
- package/dist/node/framework/cache.d.ts +0 -17
- package/dist/node/framework/cache.js +0 -135
- 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/storefront-api-types.d.ts +0 -6405
- package/dist/node/storefront-api-types.js +0 -1766
- package/dist/node/streaming.server.d.ts +0 -26
- package/dist/node/streaming.server.js +0 -33
- package/dist/node/types.d.ts +0 -105
- 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/defer.d.ts +0 -6
- package/dist/node/utilities/defer.js +0 -18
- 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/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/isClient/index.d.ts +0 -1
- package/dist/node/utilities/isClient/index.js +0 -5
- package/dist/node/utilities/isClient/isClient.d.ts +0 -4
- package/dist/node/utilities/isClient/isClient.js +0 -10
- package/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 -18
- 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 -22
- package/dist/node/utilities/log/log.js +0 -74
- 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,26 +0,0 @@
|
|
|
1
|
-
import type { Writable } from 'stream';
|
|
2
|
-
export declare const rscRenderToReadableStream: (App: JSX.Element, options?: {
|
|
3
|
-
onError?: ((error: Error) => void) | undefined;
|
|
4
|
-
} | undefined) => ReadableStream<Uint8Array>;
|
|
5
|
-
export declare const createFromReadableStream: (rs: ReadableStream<Uint8Array>) => {
|
|
6
|
-
readRoot: () => JSX.Element;
|
|
7
|
-
};
|
|
8
|
-
declare type StreamOptions = {
|
|
9
|
-
nonce?: string;
|
|
10
|
-
bootstrapScripts?: string[];
|
|
11
|
-
bootstrapModules?: string[];
|
|
12
|
-
onError?: (error: Error) => void;
|
|
13
|
-
};
|
|
14
|
-
export declare const ssrRenderToPipeableStream: (App: JSX.Element, options: StreamOptions & {
|
|
15
|
-
onAllReady?: (() => void) | undefined;
|
|
16
|
-
onShellReady?: (() => void) | undefined;
|
|
17
|
-
onShellError?: ((error: Error) => void) | undefined;
|
|
18
|
-
}) => {
|
|
19
|
-
pipe: Writable['pipe'];
|
|
20
|
-
};
|
|
21
|
-
export declare const ssrRenderToReadableStream: (App: JSX.Element, options: StreamOptions) => Promise<ReadableStream<Uint8Array> & {
|
|
22
|
-
allReady: Promise<void>;
|
|
23
|
-
}>;
|
|
24
|
-
export declare function isStreamingSupported(): Promise<boolean>;
|
|
25
|
-
export declare function bufferReadableStream(reader: ReadableStreamDefaultReader, cb?: (chunk: string) => void): Promise<string>;
|
|
26
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bufferReadableStream = exports.isStreamingSupported = exports.ssrRenderToReadableStream = exports.ssrRenderToPipeableStream = exports.createFromReadableStream = exports.rscRenderToReadableStream = void 0;
|
|
4
|
-
const server_1 = require("react-dom/server");
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const writer_browser_server_1 = require("@shopify/hydrogen/vendor/react-server-dom-vite/writer.browser.server");
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const react_server_dom_vite_1 = require("@shopify/hydrogen/vendor/react-server-dom-vite");
|
|
9
|
-
exports.rscRenderToReadableStream = writer_browser_server_1.renderToReadableStream;
|
|
10
|
-
exports.createFromReadableStream = react_server_dom_vite_1.createFromReadableStream;
|
|
11
|
-
exports.ssrRenderToPipeableStream = server_1.renderToPipeableStream;
|
|
12
|
-
exports.ssrRenderToReadableStream = server_1.renderToReadableStream;
|
|
13
|
-
async function isStreamingSupported() {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
return Boolean((_b = (_a = globalThis.Oxygen) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.HYDROGEN_ENABLE_WORKER_STREAMING);
|
|
16
|
-
}
|
|
17
|
-
exports.isStreamingSupported = isStreamingSupported;
|
|
18
|
-
async function bufferReadableStream(reader, cb) {
|
|
19
|
-
const decoder = new TextDecoder();
|
|
20
|
-
let result = '';
|
|
21
|
-
while (true) {
|
|
22
|
-
const { done, value } = await reader.read();
|
|
23
|
-
if (done)
|
|
24
|
-
break;
|
|
25
|
-
const stringValue = typeof value === 'string' ? value : decoder.decode(value);
|
|
26
|
-
result += stringValue;
|
|
27
|
-
if (cb) {
|
|
28
|
-
cb(stringValue);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
exports.bufferReadableStream = bufferReadableStream;
|
package/dist/node/types.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { ServerResponse } from 'http';
|
|
3
|
-
import type { Logger } from './utilities/log/log';
|
|
4
|
-
import type { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
5
|
-
import type { ServerComponentResponse } from './framework/Hydration/ServerComponentResponse.server';
|
|
6
|
-
import type { Metafield, ProductVariant, Product, MediaImage } from './storefront-api-types';
|
|
7
|
-
import type { SessionStorageAdapter } from './foundation/session/session';
|
|
8
|
-
declare type CommonOptions = {
|
|
9
|
-
App: any;
|
|
10
|
-
routes?: ImportGlobEagerOutput;
|
|
11
|
-
request: ServerComponentRequest;
|
|
12
|
-
componentResponse: ServerComponentResponse;
|
|
13
|
-
log: Logger;
|
|
14
|
-
dev?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare type RendererOptions = CommonOptions & {
|
|
17
|
-
template: string;
|
|
18
|
-
nonce?: string;
|
|
19
|
-
};
|
|
20
|
-
export declare type StreamerOptions = CommonOptions & {
|
|
21
|
-
response?: ServerResponse;
|
|
22
|
-
template: string;
|
|
23
|
-
nonce?: string;
|
|
24
|
-
};
|
|
25
|
-
export declare type HydratorOptions = CommonOptions & {
|
|
26
|
-
response?: ServerResponse;
|
|
27
|
-
isStreamable: boolean;
|
|
28
|
-
};
|
|
29
|
-
export declare type ShopifyConfig = {
|
|
30
|
-
defaultLocale?: string;
|
|
31
|
-
storeDomain: string;
|
|
32
|
-
storefrontToken: string;
|
|
33
|
-
storefrontApiVersion: string;
|
|
34
|
-
};
|
|
35
|
-
export declare type Hook = (params: {
|
|
36
|
-
url: URL;
|
|
37
|
-
} & Record<string, any>) => any | Promise<any>;
|
|
38
|
-
export declare type ImportGlobEagerOutput = Record<string, Record<'default' | 'api', any>>;
|
|
39
|
-
export declare type InlineHydrogenRoutes = string | {
|
|
40
|
-
files: string;
|
|
41
|
-
basePath?: string;
|
|
42
|
-
};
|
|
43
|
-
export declare type ResolvedHydrogenRoutes = {
|
|
44
|
-
files: ImportGlobEagerOutput;
|
|
45
|
-
dirPrefix: string;
|
|
46
|
-
basePath: string;
|
|
47
|
-
};
|
|
48
|
-
declare type ConfigFetcher<T> = (request: ServerComponentRequest) => T | Promise<T>;
|
|
49
|
-
export declare type ShopifyConfigFetcher = ConfigFetcher<ShopifyConfig>;
|
|
50
|
-
export declare type ServerAnalyticsConnector = {
|
|
51
|
-
request: (request: Request, data?: any, contentType?: 'json' | 'text') => void;
|
|
52
|
-
};
|
|
53
|
-
export declare type InlineHydrogenConfig = {
|
|
54
|
-
routes?: InlineHydrogenRoutes;
|
|
55
|
-
shopify?: ShopifyConfig | ShopifyConfigFetcher;
|
|
56
|
-
serverAnalyticsConnectors?: Array<ServerAnalyticsConnector>;
|
|
57
|
-
session?: (log: Logger) => SessionStorageAdapter;
|
|
58
|
-
enableStreaming?: (request: ServerComponentRequest) => boolean;
|
|
59
|
-
};
|
|
60
|
-
export declare type ResolvedHydrogenConfig = Omit<InlineHydrogenConfig, 'routes'> & {
|
|
61
|
-
routes: ResolvedHydrogenRoutes;
|
|
62
|
-
};
|
|
63
|
-
export declare type ClientHandlerConfig = {
|
|
64
|
-
/** React's StrictMode is on by default for your client side app; if you want to turn it off (not recommended), you can pass `false` */
|
|
65
|
-
strictMode?: boolean;
|
|
66
|
-
showDevTools?: boolean;
|
|
67
|
-
};
|
|
68
|
-
export declare type ClientHandler = (App: React.ElementType, config: ClientHandlerConfig) => Promise<void>;
|
|
69
|
-
export interface GraphQLConnection<T> {
|
|
70
|
-
edges?: {
|
|
71
|
-
node: T;
|
|
72
|
-
}[];
|
|
73
|
-
}
|
|
74
|
-
export declare type ParsedMetafield = Omit<Partial<Metafield>, 'value' | 'reference'> & {
|
|
75
|
-
value?: string | number | boolean | Record<any, string> | Date | Rating | Measurement;
|
|
76
|
-
reference?: MediaImage | ProductVariant | Product | null;
|
|
77
|
-
};
|
|
78
|
-
export interface Rating {
|
|
79
|
-
value: number;
|
|
80
|
-
scale_min: number;
|
|
81
|
-
scale_max: number;
|
|
82
|
-
}
|
|
83
|
-
export interface Measurement {
|
|
84
|
-
unit: string;
|
|
85
|
-
value: number;
|
|
86
|
-
}
|
|
87
|
-
export declare type QueryKey = string | readonly unknown[];
|
|
88
|
-
export declare type NoStoreStrategy = {
|
|
89
|
-
mode: string;
|
|
90
|
-
};
|
|
91
|
-
export interface AllCacheOptions {
|
|
92
|
-
mode?: string;
|
|
93
|
-
maxAge?: number;
|
|
94
|
-
staleWhileRevalidate?: number;
|
|
95
|
-
sMaxAge?: number;
|
|
96
|
-
staleIfError?: number;
|
|
97
|
-
}
|
|
98
|
-
export declare type CachingStrategy = AllCacheOptions;
|
|
99
|
-
export interface HydrogenVitePluginOptions {
|
|
100
|
-
devCache?: boolean;
|
|
101
|
-
purgeQueryCacheOnBuild?: boolean;
|
|
102
|
-
configPath?: string;
|
|
103
|
-
}
|
|
104
|
-
export declare type PreloadOptions = boolean | string;
|
|
105
|
-
export {};
|
package/dist/node/types.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { InlineHydrogenConfig, ResolvedHydrogenRoutes } from '../types';
|
|
2
|
-
import type { ServerComponentRequest } from '../framework/Hydration/ServerComponentRequest.server';
|
|
3
|
-
import { SessionApi, SessionStorageAdapter } from '../foundation/session/session';
|
|
4
|
-
declare type RouteParams = Record<string, string>;
|
|
5
|
-
declare type RequestOptions = {
|
|
6
|
-
params: RouteParams;
|
|
7
|
-
queryShop: (args: QueryShopArgs) => Promise<any>;
|
|
8
|
-
session: SessionApi | null;
|
|
9
|
-
};
|
|
10
|
-
declare type ResourceGetter = (request: Request, requestOptions: RequestOptions) => Promise<Response | Object | String>;
|
|
11
|
-
interface HydrogenApiRoute {
|
|
12
|
-
path: string;
|
|
13
|
-
resource: ResourceGetter;
|
|
14
|
-
hasServerComponent: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare type ApiRouteMatch = {
|
|
17
|
-
resource: ResourceGetter;
|
|
18
|
-
hasServerComponent: boolean;
|
|
19
|
-
params: RouteParams;
|
|
20
|
-
};
|
|
21
|
-
export declare function extractPathFromRoutesKey(routesKey: string, dirPrefix: string | RegExp): string;
|
|
22
|
-
export declare function getApiRoutes({ files: routes, basePath: topLevelPath, dirPrefix, }: Partial<ResolvedHydrogenRoutes>): Array<HydrogenApiRoute>;
|
|
23
|
-
export declare function getApiRouteFromURL(url: URL, routes: Array<HydrogenApiRoute>): ApiRouteMatch | null;
|
|
24
|
-
/** The `queryShop` utility is a function that helps you query the Storefront API.
|
|
25
|
-
* It's similar to the `useShopQuery` hook, which is available in server components.
|
|
26
|
-
* To use `queryShop`, pass `shopifyConfig` to `renderHydrogen` inside `App.server.jsx`.
|
|
27
|
-
*/
|
|
28
|
-
interface QueryShopArgs {
|
|
29
|
-
/** A string of the GraphQL query.
|
|
30
|
-
* If no query is provided, then the `useShopQuery` makes no calls to the Storefront API.
|
|
31
|
-
*/
|
|
32
|
-
query: string;
|
|
33
|
-
/** An object of the variables for the GraphQL query. */
|
|
34
|
-
variables?: Record<string, any>;
|
|
35
|
-
}
|
|
36
|
-
export declare function renderApiRoute(request: ServerComponentRequest, route: ApiRouteMatch, shopifyConfig: InlineHydrogenConfig['shopify'], session?: SessionStorageAdapter): Promise<Response | Request>;
|
|
37
|
-
export {};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderApiRoute = exports.getApiRouteFromURL = exports.getApiRoutes = exports.extractPathFromRoutesKey = void 0;
|
|
4
|
-
const matchPath_1 = require("./matchPath");
|
|
5
|
-
const log_1 = require("../utilities/log/");
|
|
6
|
-
const fetch_1 = require("./fetch");
|
|
7
|
-
const storefrontApi_1 = require("./storefrontApi");
|
|
8
|
-
const session_1 = require("../foundation/session/session");
|
|
9
|
-
let memoizedApiRoutes = [];
|
|
10
|
-
let memoizedRawRoutes = {};
|
|
11
|
-
function extractPathFromRoutesKey(routesKey, dirPrefix) {
|
|
12
|
-
let path = routesKey
|
|
13
|
-
.replace(dirPrefix, '')
|
|
14
|
-
.replace(/\.server\.(t|j)sx?$/, '')
|
|
15
|
-
/**
|
|
16
|
-
* Replace /index with /
|
|
17
|
-
*/
|
|
18
|
-
.replace(/\/index$/i, '/')
|
|
19
|
-
/**
|
|
20
|
-
* Only lowercase the first letter. This allows the developer to use camelCase
|
|
21
|
-
* dynamic paths while ensuring their standard routes are normalized to lowercase.
|
|
22
|
-
*/
|
|
23
|
-
.replace(/\b[A-Z]/, (firstLetter) => firstLetter.toLowerCase())
|
|
24
|
-
/**
|
|
25
|
-
* Convert /[handle].jsx and /[...handle].jsx to /:handle.jsx for react-router-dom
|
|
26
|
-
*/
|
|
27
|
-
.replace(/\[(?:[.]{3})?(\w+?)\]/g, (_match, param) => `:${param}`);
|
|
28
|
-
if (path.endsWith('/') && path !== '/') {
|
|
29
|
-
path = path.substring(0, path.length - 1);
|
|
30
|
-
}
|
|
31
|
-
return path;
|
|
32
|
-
}
|
|
33
|
-
exports.extractPathFromRoutesKey = extractPathFromRoutesKey;
|
|
34
|
-
function getApiRoutes({ files: routes, basePath: topLevelPath = '', dirPrefix = '', }) {
|
|
35
|
-
if (!routes || memoizedRawRoutes === routes)
|
|
36
|
-
return memoizedApiRoutes;
|
|
37
|
-
const topLevelPrefix = topLevelPath.replace('*', '').replace(/\/$/, '');
|
|
38
|
-
const keys = Object.keys(routes);
|
|
39
|
-
const apiRoutes = keys
|
|
40
|
-
.filter((key) => routes[key].api)
|
|
41
|
-
.map((key) => {
|
|
42
|
-
const path = extractPathFromRoutesKey(key, dirPrefix);
|
|
43
|
-
/**
|
|
44
|
-
* Catch-all routes [...handle].jsx don't need an exact match
|
|
45
|
-
* https://reactrouter.com/core/api/Route/exact-bool
|
|
46
|
-
*/
|
|
47
|
-
const exact = !/\[(?:[.]{3})(\w+?)\]/.test(key);
|
|
48
|
-
return {
|
|
49
|
-
path: topLevelPrefix + path,
|
|
50
|
-
resource: routes[key].api,
|
|
51
|
-
hasServerComponent: !!routes[key].default,
|
|
52
|
-
exact,
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
memoizedApiRoutes = [
|
|
56
|
-
...apiRoutes.filter((route) => !route.path.includes(':')),
|
|
57
|
-
...apiRoutes.filter((route) => route.path.includes(':')),
|
|
58
|
-
];
|
|
59
|
-
memoizedRawRoutes = routes;
|
|
60
|
-
return memoizedApiRoutes;
|
|
61
|
-
}
|
|
62
|
-
exports.getApiRoutes = getApiRoutes;
|
|
63
|
-
function getApiRouteFromURL(url, routes) {
|
|
64
|
-
let foundRoute, foundRouteDetails;
|
|
65
|
-
for (let i = 0; i < routes.length; i++) {
|
|
66
|
-
foundRouteDetails = (0, matchPath_1.matchPath)(url.pathname, routes[i]);
|
|
67
|
-
if (foundRouteDetails) {
|
|
68
|
-
foundRoute = routes[i];
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!foundRoute)
|
|
73
|
-
return null;
|
|
74
|
-
return {
|
|
75
|
-
resource: foundRoute.resource,
|
|
76
|
-
params: foundRouteDetails.params,
|
|
77
|
-
hasServerComponent: foundRoute.hasServerComponent,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
exports.getApiRouteFromURL = getApiRouteFromURL;
|
|
81
|
-
function queryShopBuilder(shopifyConfigGetter, request) {
|
|
82
|
-
return async function queryShop({ query, variables, }) {
|
|
83
|
-
const shopifyConfig = typeof shopifyConfigGetter === 'function'
|
|
84
|
-
? await shopifyConfigGetter(request)
|
|
85
|
-
: shopifyConfigGetter;
|
|
86
|
-
if (!shopifyConfig) {
|
|
87
|
-
throw new Error('Shopify connection info was not found in Hydrogen config');
|
|
88
|
-
}
|
|
89
|
-
const { storeDomain, storefrontApiVersion, storefrontToken } = shopifyConfig;
|
|
90
|
-
const buyerIp = request.getBuyerIp();
|
|
91
|
-
const extraHeaders = (0, storefrontApi_1.getStorefrontApiRequestHeaders)({
|
|
92
|
-
buyerIp,
|
|
93
|
-
storefrontToken,
|
|
94
|
-
});
|
|
95
|
-
const fetcher = (0, fetch_1.fetchBuilder)(`https://${storeDomain}/api/${storefrontApiVersion}/graphql.json`, {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
body: (0, fetch_1.graphqlRequestBody)(query, variables),
|
|
98
|
-
headers: {
|
|
99
|
-
'Content-Type': 'application/json',
|
|
100
|
-
...extraHeaders,
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
return await fetcher();
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
async function renderApiRoute(request, route, shopifyConfig, session) {
|
|
107
|
-
var _a;
|
|
108
|
-
let response;
|
|
109
|
-
const log = (0, log_1.getLoggerWithContext)(request);
|
|
110
|
-
let cookieToSet = '';
|
|
111
|
-
try {
|
|
112
|
-
response = await route.resource(request, {
|
|
113
|
-
params: route.params,
|
|
114
|
-
queryShop: queryShopBuilder(shopifyConfig, request),
|
|
115
|
-
session: session
|
|
116
|
-
? {
|
|
117
|
-
async get() {
|
|
118
|
-
return session.get(request);
|
|
119
|
-
},
|
|
120
|
-
async set(key, value) {
|
|
121
|
-
const data = await session.get(request);
|
|
122
|
-
data[key] = value;
|
|
123
|
-
cookieToSet = await session.set(request, data);
|
|
124
|
-
},
|
|
125
|
-
async destroy() {
|
|
126
|
-
cookieToSet = await session.destroy(request);
|
|
127
|
-
},
|
|
128
|
-
}
|
|
129
|
-
: (0, session_1.emptySessionImplementation)(log),
|
|
130
|
-
});
|
|
131
|
-
if (!(response instanceof Response || response instanceof Request)) {
|
|
132
|
-
if (typeof response === 'string' || response instanceof String) {
|
|
133
|
-
response = new Response(response);
|
|
134
|
-
}
|
|
135
|
-
else if (typeof response === 'object') {
|
|
136
|
-
response = new Response(JSON.stringify(response), {
|
|
137
|
-
headers: {
|
|
138
|
-
'Content-Type': 'application/json',
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (!response) {
|
|
144
|
-
response = new Response(null);
|
|
145
|
-
}
|
|
146
|
-
if (cookieToSet) {
|
|
147
|
-
response.headers.set('Set-Cookie', cookieToSet);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (e) {
|
|
151
|
-
log.error(e);
|
|
152
|
-
response = new Response('Error processing: ' + request.url, { status: 500 });
|
|
153
|
-
}
|
|
154
|
-
(0, log_1.logServerResponse)('api', request, (_a = response.status) !== null && _a !== void 0 ? _a : 200);
|
|
155
|
-
return response;
|
|
156
|
-
}
|
|
157
|
-
exports.renderApiRoute = renderApiRoute;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBotUA = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* An alphabetized list of User Agents of known bots, combined from lists found at:
|
|
6
|
-
* https://github.com/vercel/next.js/blob/d87dc2b5a0b3fdbc0f6806a47be72bad59564bd0/packages/next/server/utils.ts#L18-L22
|
|
7
|
-
* https://github.com/GoogleChrome/rendertron/blob/6f681688737846b28754fbfdf5db173846a826df/middleware/src/middleware.ts#L24-L41
|
|
8
|
-
*/
|
|
9
|
-
const botUserAgents = [
|
|
10
|
-
'AdsBot-Google',
|
|
11
|
-
'applebot',
|
|
12
|
-
'Baiduspider',
|
|
13
|
-
'baiduspider',
|
|
14
|
-
'Bytespider',
|
|
15
|
-
'360Spider',
|
|
16
|
-
'PetalBot',
|
|
17
|
-
'Yisouspider',
|
|
18
|
-
'bingbot',
|
|
19
|
-
'Bingbot',
|
|
20
|
-
'BingPreview',
|
|
21
|
-
'bitlybot',
|
|
22
|
-
'Discordbot',
|
|
23
|
-
'DuckDuckBot',
|
|
24
|
-
'Embedly',
|
|
25
|
-
'facebookcatalog',
|
|
26
|
-
'facebookexternalhit',
|
|
27
|
-
'Google-PageRenderer',
|
|
28
|
-
'Googlebot',
|
|
29
|
-
'googleweblight',
|
|
30
|
-
'ia_archive',
|
|
31
|
-
'LinkedInBot',
|
|
32
|
-
'Mediapartners-Google',
|
|
33
|
-
'outbrain',
|
|
34
|
-
'pinterest',
|
|
35
|
-
'quora link preview',
|
|
36
|
-
'redditbot',
|
|
37
|
-
'rogerbot',
|
|
38
|
-
'showyoubot',
|
|
39
|
-
'SkypeUriPreview',
|
|
40
|
-
'Slackbot',
|
|
41
|
-
'Slurp',
|
|
42
|
-
'sogou',
|
|
43
|
-
'Storebot-Google',
|
|
44
|
-
'TelegramBot',
|
|
45
|
-
'tumblr',
|
|
46
|
-
'Twitterbot',
|
|
47
|
-
'vkShare',
|
|
48
|
-
'W3C_Validator',
|
|
49
|
-
'WhatsApp',
|
|
50
|
-
'yandex',
|
|
51
|
-
// SEO Tools
|
|
52
|
-
'Seoradar',
|
|
53
|
-
'W3C html2txt',
|
|
54
|
-
];
|
|
55
|
-
/**
|
|
56
|
-
* Creates a regex based on the botUserAgents array
|
|
57
|
-
*/
|
|
58
|
-
const botUARegex = new RegExp(botUserAgents.join('|'), 'i');
|
|
59
|
-
/**
|
|
60
|
-
* Determines if the request is from a bot, using the URL and User Agent
|
|
61
|
-
*/
|
|
62
|
-
function isBotUA(url, userAgent) {
|
|
63
|
-
return (url.searchParams.has('_bot') || (!!userAgent && botUARegex.test(userAgent)));
|
|
64
|
-
}
|
|
65
|
-
exports.isBotUA = isBotUA;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defer = void 0;
|
|
4
|
-
function defer() {
|
|
5
|
-
const deferred = { status: 'pending' };
|
|
6
|
-
deferred.promise = new Promise((resolve, reject) => {
|
|
7
|
-
deferred.resolve = (value) => {
|
|
8
|
-
deferred.status = 'resolved';
|
|
9
|
-
return resolve(value);
|
|
10
|
-
};
|
|
11
|
-
deferred.reject = (error) => {
|
|
12
|
-
deferred.status = 'rejected';
|
|
13
|
-
return reject(error);
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
return deferred;
|
|
17
|
-
}
|
|
18
|
-
exports.defer = defer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getErrorMarkup(error: Error): string;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getErrorMarkup = void 0;
|
|
4
|
-
function getErrorMarkup(error) {
|
|
5
|
-
return `<script type="module">
|
|
6
|
-
import {ErrorOverlay} from '/@vite/client';
|
|
7
|
-
document.body.appendChild(new ErrorOverlay(${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(/</g, '\\u003c')}));
|
|
8
|
-
</script>`;
|
|
9
|
-
}
|
|
10
|
-
exports.getErrorMarkup = getErrorMarkup;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare type FetchInit = {
|
|
2
|
-
body?: string;
|
|
3
|
-
method?: string;
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
};
|
|
6
|
-
export declare function fetchBuilder<T>(url: string, options?: FetchInit): () => Promise<T>;
|
|
7
|
-
export declare function graphqlRequestBody(query: string, variables?: Record<string, any>): string;
|
|
8
|
-
export declare function decodeShopifyId(id: string): string;
|
|
9
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeShopifyId = exports.graphqlRequestBody = exports.fetchBuilder = void 0;
|
|
4
|
-
const version_1 = require("../version");
|
|
5
|
-
const defaultHeaders = {
|
|
6
|
-
'content-type': 'application/json',
|
|
7
|
-
'user-agent': `Hydrogen ${version_1.LIB_VERSION}`,
|
|
8
|
-
};
|
|
9
|
-
function fetchBuilder(url, options = {}) {
|
|
10
|
-
const requestInit = {
|
|
11
|
-
...options,
|
|
12
|
-
headers: { ...defaultHeaders, ...options.headers },
|
|
13
|
-
};
|
|
14
|
-
return async () => {
|
|
15
|
-
const response = await fetch(url, requestInit);
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
throw response;
|
|
18
|
-
}
|
|
19
|
-
const data = await response.json();
|
|
20
|
-
return data;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.fetchBuilder = fetchBuilder;
|
|
24
|
-
function graphqlRequestBody(query, variables) {
|
|
25
|
-
return JSON.stringify({
|
|
26
|
-
query,
|
|
27
|
-
variables,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
exports.graphqlRequestBody = graphqlRequestBody;
|
|
31
|
-
function decodeShopifyId(id) {
|
|
32
|
-
if (!id.startsWith('gid://')) {
|
|
33
|
-
throw new Error('invalid Shopify ID');
|
|
34
|
-
}
|
|
35
|
-
return id;
|
|
36
|
-
}
|
|
37
|
-
exports.decodeShopifyId = decodeShopifyId;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { GraphQLConnection } from '../../types';
|
|
2
|
-
import type { PartialDeep } from 'type-fest';
|
|
3
|
-
/**
|
|
4
|
-
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](https://shopify.dev/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
5
|
-
*/
|
|
6
|
-
export declare function flattenConnection<T>(connection: PartialDeep<GraphQLConnection<T>>): PartialDeep<T>[];
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenConnection = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](https://shopify.dev/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
6
|
-
*/
|
|
7
|
-
function flattenConnection(connection) {
|
|
8
|
-
return (connection.edges || []).map((edge) => {
|
|
9
|
-
if (!(edge === null || edge === void 0 ? void 0 : edge.node)) {
|
|
10
|
-
throw new Error('Connection edges must contain nodes');
|
|
11
|
-
}
|
|
12
|
-
return edge.node;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
exports.flattenConnection = flattenConnection;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { flattenConnection } from './flattenConnection';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenConnection = void 0;
|
|
4
|
-
var flattenConnection_1 = require("./flattenConnection");
|
|
5
|
-
Object.defineProperty(exports, "flattenConnection", { enumerable: true, get: function () { return flattenConnection_1.flattenConnection; } });
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hashKey = void 0;
|
|
4
|
-
function hashKey(key) {
|
|
5
|
-
const rawKey = key instanceof Array ? key : [key];
|
|
6
|
-
/**
|
|
7
|
-
* TODO: Smarter hash
|
|
8
|
-
*/
|
|
9
|
-
return rawKey.map((k) => JSON.stringify(k)).join('');
|
|
10
|
-
}
|
|
11
|
-
exports.hashKey = hashKey;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function htmlEncode(html: string): string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.htmlEncode = void 0;
|
|
4
|
-
function htmlEncode(html) {
|
|
5
|
-
return html
|
|
6
|
-
.replace(/&/g, '&')
|
|
7
|
-
.replace(/</g, '<')
|
|
8
|
-
.replace(/>/g, '>')
|
|
9
|
-
.replace(/"/g, '"')
|
|
10
|
-
.replace(/'/g, ''');
|
|
11
|
-
}
|
|
12
|
-
exports.htmlEncode = htmlEncode;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Image as ImageType } from '../storefront-api-types';
|
|
2
|
-
import type { PartialDeep } from 'type-fest';
|
|
3
|
-
import type { ShopifyLoaderOptions, ShopifyLoaderParams } from '../components/Image';
|
|
4
|
-
/**
|
|
5
|
-
* Adds image size parameters to an image URL hosted by Shopify's CDN
|
|
6
|
-
*/
|
|
7
|
-
export declare function addImageSizeParametersToUrl({ src, width, height, crop, scale, }: ShopifyLoaderParams): string;
|
|
8
|
-
export declare function shopifyImageLoader(params: ShopifyLoaderParams): string;
|
|
9
|
-
export declare function getShopifyImageDimensions(image: Pick<PartialDeep<ImageType>, 'altText' | 'url' | 'id' | 'width' | 'height'>, options?: ShopifyLoaderOptions): {
|
|
10
|
-
width: import("../storefront-api-types").Maybe<number> | undefined;
|
|
11
|
-
height: import("../storefront-api-types").Maybe<number> | undefined;
|
|
12
|
-
};
|