@shopify/hydrogen 0.11.1 → 0.13.1
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 +500 -3
- package/dist/esnext/client.d.ts +2 -0
- package/dist/esnext/client.js +2 -0
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +3 -4
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +9 -22
- package/dist/esnext/components/AddToCartButton/index.d.ts +1 -1
- package/dist/esnext/components/BuyNowButton/BuyNowButton.client.d.ts +4 -5
- package/dist/esnext/components/BuyNowButton/index.d.ts +1 -1
- package/dist/esnext/components/BuyNowButton/index.js +1 -1
- package/dist/esnext/components/CartCheckoutButton/CartCheckoutButton.client.d.ts +2 -3
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +3 -3
- package/dist/esnext/components/CartLineImage/CartLineImage.client.d.ts +5 -3
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +5 -5
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +1 -1
- package/dist/esnext/components/CartLineProductTitle/CartLineProductTitle.client.d.ts +1 -3
- package/dist/esnext/components/CartLineProvider/context.d.ts +10 -16
- package/dist/esnext/components/CartLineQuantity/CartLineQuantity.client.d.ts +1 -3
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +8 -2
- package/dist/esnext/components/CartProvider/cart-queries.d.ts +9 -0
- package/dist/esnext/components/CartProvider/cart-queries.js +876 -0
- package/dist/esnext/components/CartProvider/graphql/CartAttributesUpdateMutation.d.ts +72 -5
- package/dist/esnext/components/CartProvider/graphql/CartBuyerIdentityUpdateMutation.d.ts +72 -5
- package/dist/esnext/components/CartProvider/graphql/CartCreateMutation.d.ts +72 -5
- package/dist/esnext/components/CartProvider/graphql/CartDiscountCodesUpdateMutation.d.ts +73 -6
- package/dist/esnext/components/CartProvider/graphql/CartFragment.d.ts +13 -11
- package/dist/esnext/components/CartProvider/graphql/CartLineAddMutation.d.ts +72 -5
- package/dist/esnext/components/CartProvider/graphql/CartLineRemoveMutation.d.ts +72 -5
- package/dist/esnext/components/CartProvider/graphql/CartLineUpdateMutation.d.ts +72 -5
- package/dist/esnext/components/CartProvider/graphql/CartNoteUpdateMutation.d.ts +73 -6
- package/dist/esnext/components/CartProvider/graphql/CartQuery.d.ts +72 -5
- package/dist/esnext/components/CartProvider/hooks.d.ts +1 -1
- package/dist/esnext/components/CartProvider/hooks.js +4 -1
- package/dist/esnext/components/CartProvider/types.d.ts +1 -1
- package/dist/esnext/components/CartShopPayButton/CartShopPayButton.client.d.ts +3 -2
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +8 -13
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +7 -7
- package/dist/esnext/components/ExternalVideo/index.d.ts +1 -1
- package/dist/esnext/components/ExternalVideo/index.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +14 -16
- package/dist/esnext/components/Image/Image.js +17 -17
- package/dist/esnext/components/Image/index.d.ts +1 -1
- package/dist/esnext/components/Image/index.js +1 -1
- package/dist/esnext/components/Link/Link.client.d.ts +4 -5
- package/dist/esnext/components/Link/Link.client.js +5 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +1 -3
- package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +0 -1
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +4 -5
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +15 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationQuery.d.ts +5 -8
- package/dist/esnext/components/LocalizationProvider/index.d.ts +0 -1
- package/dist/esnext/components/LocalizationProvider/index.js +0 -1
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +10 -21
- package/dist/esnext/components/MediaFile/MediaFile.js +7 -5
- package/dist/esnext/components/MediaFile/index.d.ts +1 -1
- package/dist/esnext/components/MediaFile/index.js +1 -1
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +2 -6
- package/dist/esnext/components/Metafield/Metafield.client.js +8 -8
- package/dist/esnext/components/Metafield/components/StarRating/StarRating.d.ts +1 -3
- package/dist/esnext/components/Metafield/index.d.ts +1 -2
- package/dist/esnext/components/Metafield/index.js +1 -1
- package/dist/esnext/components/Metafield/types.d.ts +1 -1
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +58 -66
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +10 -7
- package/dist/esnext/components/ModelViewer/index.d.ts +1 -1
- package/dist/esnext/components/Money/Money.client.d.ts +8 -12
- package/dist/esnext/components/Money/Money.client.js +1 -4
- package/dist/esnext/components/Money/index.d.ts +1 -1
- package/dist/esnext/components/Money/index.js +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +7 -2
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +4 -3
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +3 -3
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +5 -5
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +2 -2
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +8 -8
- package/dist/esnext/components/ProductProvider/ProductProvider.client.js +2 -4
- package/dist/esnext/components/ProductProvider/context.d.ts +23 -14
- package/dist/esnext/components/ProductProvider/index.d.ts +1 -1
- package/dist/esnext/components/ProductProvider/index.js +1 -1
- package/dist/esnext/components/Seo/CollectionSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/CollectionSeo.client.js +3 -3
- package/dist/esnext/components/Seo/DefaultPageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/DefaultPageSeo.client.js +2 -2
- package/dist/esnext/components/Seo/DescriptionSeo.client.d.ts +3 -3
- package/dist/esnext/components/Seo/DescriptionSeo.client.js +1 -1
- package/dist/esnext/components/Seo/HomePageSeo.client.d.ts +1 -1
- package/dist/esnext/components/Seo/ImageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/PageSeo.client.d.ts +3 -2
- package/dist/esnext/components/Seo/PageSeo.client.js +2 -2
- package/dist/esnext/components/Seo/ProductSeo.client.d.ts +5 -2
- package/dist/esnext/components/Seo/ProductSeo.client.js +10 -5
- package/dist/esnext/components/Seo/Seo.client.d.ts +11 -7
- package/dist/esnext/components/Seo/Seo.client.js +8 -14
- package/dist/esnext/components/Seo/TitleSeo.client.d.ts +3 -4
- package/dist/esnext/components/Seo/TwitterSeo.client.d.ts +1 -1
- package/dist/esnext/components/Seo/seo-types.d.ts +17 -0
- package/dist/esnext/components/{ExternalVideo/ExternalVideoFragment.js → Seo/seo-types.js} +0 -0
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.d.ts +2 -1
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +1 -9
- package/dist/esnext/components/ShopPayButton/index.d.ts +1 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +8 -13
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +9 -4
- package/dist/esnext/components/UnitPrice/index.d.ts +1 -1
- package/dist/esnext/components/UnitPrice/index.js +1 -1
- package/dist/esnext/components/Video/Video.d.ts +8 -16
- package/dist/esnext/components/Video/Video.js +11 -6
- package/dist/esnext/components/Video/index.d.ts +1 -2
- package/dist/esnext/components/Video/index.js +1 -1
- package/dist/esnext/components/index.d.ts +3 -16
- package/dist/esnext/components/index.js +2 -5
- package/dist/esnext/entry-client.js +27 -8
- package/dist/esnext/entry-server.d.ts +2 -1
- package/dist/esnext/entry-server.js +127 -160
- package/dist/esnext/foundation/Boomerang/Boomerang.client.d.ts +3 -1
- package/dist/esnext/foundation/Boomerang/Boomerang.client.js +17 -3
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.d.ts +22 -0
- package/dist/esnext/foundation/{Router/DefaultRoutes.js → FileRoutes/FileRoutes.server.js} +24 -23
- package/dist/esnext/foundation/Redirect/Redirect.client.d.ts +5 -0
- package/dist/esnext/foundation/Redirect/Redirect.client.js +14 -0
- package/dist/esnext/foundation/Route/Route.server.d.ts +12 -0
- package/dist/esnext/foundation/Route/Route.server.js +33 -0
- package/dist/esnext/foundation/Router/{Router.client.d.ts → BrowserRouter.client.d.ts} +3 -2
- package/dist/esnext/foundation/Router/{Router.client.js → BrowserRouter.client.js} +11 -7
- package/dist/esnext/foundation/Router/Router.server.d.ts +10 -0
- package/dist/esnext/foundation/Router/Router.server.js +8 -0
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +19 -24
- package/dist/esnext/foundation/ServerStateProvider/{ServerStateProvider.client.d.ts → ServerStateProvider.d.ts} +0 -0
- package/dist/esnext/foundation/ServerStateProvider/{ServerStateProvider.client.js → ServerStateProvider.js} +0 -0
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +2 -2
- package/dist/esnext/foundation/ServerStateProvider/index.js +1 -1
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.client.js +3 -0
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +3 -0
- package/dist/esnext/foundation/ShopifyProvider/index.d.ts +0 -1
- package/dist/esnext/foundation/ShopifyProvider/index.js +0 -1
- package/dist/esnext/foundation/index.d.ts +0 -2
- package/dist/esnext/foundation/index.js +0 -2
- package/dist/esnext/{hooks → foundation}/useNavigate/useNavigate.d.ts +6 -3
- package/dist/esnext/{hooks → foundation}/useNavigate/useNavigate.js +4 -1
- package/dist/esnext/foundation/useQuery/hooks.d.ts +5 -4
- package/dist/esnext/foundation/useQuery/hooks.js +13 -4
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +9 -0
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +7 -0
- package/dist/esnext/foundation/useRouteParams/useRouteParams.d.ts +4 -0
- package/dist/esnext/foundation/useRouteParams/useRouteParams.js +9 -0
- package/dist/esnext/foundation/useUrl/useUrl.js +1 -1
- package/dist/esnext/framework/Hydration/Html.d.ts +2 -0
- package/dist/esnext/framework/Hydration/Html.js +71 -2
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +13 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +28 -7
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +4 -1
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +5 -0
- package/dist/esnext/framework/Hydration/rsc.js +1 -1
- package/dist/esnext/framework/cache/in-memory.d.ts +1 -0
- package/dist/esnext/framework/cache/in-memory.js +15 -5
- package/dist/esnext/framework/middleware.js +25 -3
- package/dist/esnext/framework/plugin.js +6 -1
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.d.ts +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +28 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +61 -77
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +1 -1
- 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 -18
- package/dist/esnext/hooks/useCountry/useCountry.d.ts +4 -4
- package/dist/esnext/hooks/useMoney/hooks.d.ts +3 -3
- package/dist/esnext/hooks/useMoney/hooks.js +2 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +17 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +7 -3
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +36 -138
- package/dist/esnext/hooks/useProductOptions/helpers.d.ts +6 -4
- package/dist/esnext/hooks/useProductOptions/helpers.js +13 -6
- package/dist/esnext/hooks/useProductOptions/types.d.ts +15 -35
- package/dist/esnext/hooks/useProductOptions/useProductOptions.d.ts +6 -5
- package/dist/esnext/hooks/useProductOptions/useProductOptions.js +13 -3
- package/dist/esnext/hooks/useShopQuery/hooks.js +79 -21
- package/dist/esnext/index.d.ts +8 -2
- package/dist/esnext/index.js +8 -2
- package/dist/esnext/platforms/node.d.ts +2 -3
- package/dist/esnext/platforms/node.js +5 -3
- package/dist/esnext/platforms/worker-event.d.ts +0 -8
- package/dist/esnext/platforms/worker-event.js +2 -23
- package/dist/esnext/platforms/worker.d.ts +14 -0
- package/dist/esnext/platforms/worker.js +25 -0
- package/dist/esnext/{graphql/types/types.d.ts → storefront-api-types.d.ts} +2016 -1593
- package/dist/esnext/{graphql/types/types.js → storefront-api-types.js} +1025 -732
- package/dist/esnext/streaming.server.d.ts +9 -6
- package/dist/esnext/streaming.server.js +2 -27
- package/dist/esnext/types.d.ts +3 -18
- package/dist/esnext/utilities/apiRoutes.d.ts +19 -3
- package/dist/esnext/utilities/apiRoutes.js +27 -5
- package/dist/esnext/utilities/devtools.d.ts +11 -0
- package/dist/esnext/utilities/devtools.js +11 -0
- package/dist/esnext/utilities/fetch.d.ts +7 -1
- package/dist/esnext/utilities/fetch.js +9 -18
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +3 -2
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +6 -2
- package/dist/esnext/utilities/graphql-tracker.d.ts +17 -0
- package/dist/esnext/utilities/graphql-tracker.js +119 -0
- package/dist/esnext/utilities/image_size.d.ts +5 -4
- package/dist/esnext/utilities/log/log-query-timeline.d.ts +1 -1
- package/dist/esnext/utilities/log/log-query-timeline.js +1 -2
- package/dist/esnext/utilities/log/log.d.ts +1 -0
- package/dist/esnext/utilities/log/utils.js +3 -0
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +3 -2
- package/dist/esnext/utilities/video_parameters.js +0 -4
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/entry-server.d.ts +2 -1
- package/dist/node/entry-server.js +129 -158
- package/dist/node/foundation/Redirect/Redirect.client.d.ts +5 -0
- package/dist/node/foundation/Redirect/Redirect.client.js +17 -0
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +13 -0
- package/dist/node/foundation/Router/BrowserRouter.client.js +77 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +24 -25
- package/dist/node/foundation/ServerRequestProvider/index.js +5 -1
- package/dist/node/foundation/ServerStateProvider/{ServerStateProvider.client.d.ts → ServerStateProvider.d.ts} +0 -0
- package/dist/node/foundation/ServerStateProvider/{ServerStateProvider.client.js → ServerStateProvider.js} +5 -1
- package/dist/node/foundation/ServerStateProvider/index.d.ts +2 -2
- package/dist/node/foundation/ServerStateProvider/index.js +3 -3
- package/dist/node/foundation/ssr-interop.d.ts +29 -0
- package/dist/node/foundation/ssr-interop.js +39 -0
- package/dist/node/foundation/useNavigate/useNavigate.d.ts +13 -0
- package/dist/node/foundation/useNavigate/useNavigate.js +18 -0
- package/dist/node/foundation/useServerState/index.d.ts +1 -0
- package/dist/node/foundation/useServerState/index.js +5 -0
- package/dist/node/foundation/useServerState/use-server-state.d.ts +16 -0
- package/dist/node/foundation/useServerState/use-server-state.js +24 -0
- package/dist/node/framework/Hydration/Html.d.ts +2 -0
- package/dist/node/framework/Hydration/Html.js +73 -3
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +13 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +28 -7
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +4 -1
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +8 -0
- package/dist/node/framework/Hydration/rsc.js +1 -1
- package/dist/node/framework/cache/in-memory.d.ts +1 -0
- package/dist/node/framework/cache/in-memory.js +15 -5
- package/dist/node/framework/middleware.js +30 -4
- package/dist/node/framework/plugin.js +11 -2
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.d.ts +2 -0
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +31 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +61 -77
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +1 -1
- package/dist/node/{graphql/types/types.d.ts → storefront-api-types.d.ts} +2016 -1593
- package/dist/node/{graphql/types/types.js → storefront-api-types.js} +1026 -733
- package/dist/node/streaming.server.d.ts +9 -6
- package/dist/node/streaming.server.js +3 -29
- package/dist/node/types.d.ts +3 -18
- package/dist/node/utilities/apiRoutes.d.ts +19 -3
- package/dist/node/utilities/apiRoutes.js +29 -7
- package/dist/node/utilities/fetch.d.ts +10 -0
- package/dist/node/utilities/fetch.js +39 -0
- package/dist/node/utilities/log/log-query-timeline.d.ts +1 -1
- package/dist/node/utilities/log/log-query-timeline.js +1 -2
- package/dist/node/utilities/log/log.d.ts +1 -0
- package/dist/node/utilities/log/utils.js +3 -0
- package/dist/node/utilities/web-api-polyfill.js +5 -1
- package/dist/node/version.d.ts +1 -0
- package/dist/node/version.js +4 -0
- package/package.json +21 -21
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +43 -104
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +1566 -848
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +36 -421
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +1523 -864
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +35 -437
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +507 -517
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +10 -246
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +18 -25
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +47 -108
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +1033 -306
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +965 -293
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +98 -108
- package/vendor/react-server-dom-vite/package.json +0 -2
- package/dist/esnext/components/ExternalVideo/ExternalVideoFragment.d.ts +0 -4
- package/dist/esnext/components/Image/ImageFragment.d.ts +0 -4
- package/dist/esnext/components/Image/ImageFragment.js +0 -1
- package/dist/esnext/components/MediaFile/MediaFileFragment.d.ts +0 -22
- package/dist/esnext/components/MediaFile/MediaFileFragment.js +0 -1
- package/dist/esnext/components/Metafield/MetafieldFragment.d.ts +0 -19
- package/dist/esnext/components/Metafield/MetafieldFragment.js +0 -1
- package/dist/esnext/components/ModelViewer/Model3DFragment.d.ts +0 -11
- package/dist/esnext/components/ModelViewer/Model3DFragment.js +0 -1
- package/dist/esnext/components/Money/MoneyFragment.d.ts +0 -4
- package/dist/esnext/components/Money/MoneyFragment.js +0 -1
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.d.ts +0 -80
- package/dist/esnext/components/ProductProvider/ProductProviderFragment.js +0 -1
- package/dist/esnext/components/ProductProvider/types.d.ts +0 -19
- package/dist/esnext/components/ProductProvider/types.js +0 -1
- package/dist/esnext/components/RawHtml/RawHtml.d.ts +0 -19
- package/dist/esnext/components/RawHtml/RawHtml.js +0 -21
- package/dist/esnext/components/RawHtml/index.d.ts +0 -1
- package/dist/esnext/components/RawHtml/index.js +0 -1
- package/dist/esnext/components/Router/index.d.ts +0 -1
- package/dist/esnext/components/Router/index.js +0 -1
- package/dist/esnext/components/Seo/types.d.ts +0 -67
- package/dist/esnext/components/Seo/types.js +0 -1
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.d.ts +0 -12
- package/dist/esnext/components/UnitPrice/UnitPriceFragment.js +0 -1
- package/dist/esnext/components/Video/VideoFragment.d.ts +0 -11
- package/dist/esnext/components/Video/VideoFragment.js +0 -1
- package/dist/esnext/foundation/Boomerang/BoomerangPageTemplate.client.d.ts +0 -3
- package/dist/esnext/foundation/Boomerang/BoomerangPageTemplate.client.js +0 -14
- package/dist/esnext/foundation/Router/DefaultRoutes.d.ts +0 -22
- package/dist/esnext/foundation/Router/index.d.ts +0 -1
- package/dist/esnext/foundation/Router/index.js +0 -1
- package/dist/esnext/graphql/graphql-constants.d.ts +0 -1751
- package/dist/esnext/graphql/graphql-constants.js +0 -3364
- package/dist/esnext/hooks/useAvailableCountries/index.d.ts +0 -1
- package/dist/esnext/hooks/useAvailableCountries/index.js +0 -1
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.d.ts +0 -11
- package/dist/esnext/hooks/useAvailableCountries/useAvailableCountries.js +0 -17
- package/dist/esnext/hooks/useNavigate/index.d.ts +0 -1
- package/dist/esnext/hooks/useNavigate/index.js +0 -1
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.d.ts +0 -28
- package/dist/esnext/hooks/useProductOptions/SellingPlanFragment.js +0 -1
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.d.ts +0 -20
- package/dist/esnext/hooks/useProductOptions/SellingPlanGroupsFragment.js +0 -1
- package/dist/esnext/hooks/useProductOptions/VariantFragment.d.ts +0 -64
- package/dist/esnext/hooks/useProductOptions/VariantFragment.js +0 -1
|
@@ -5,17 +5,20 @@ export declare const createFromReadableStream: (rs: ReadableStream<Uint8Array>)
|
|
|
5
5
|
};
|
|
6
6
|
declare type StreamOptions = {
|
|
7
7
|
nonce?: string;
|
|
8
|
-
onCompleteShell?: () => void;
|
|
9
|
-
onCompleteAll?: () => void;
|
|
10
|
-
onError?: (error: Error) => void;
|
|
11
8
|
bootstrapScripts?: string[];
|
|
12
9
|
bootstrapModules?: string[];
|
|
10
|
+
onError?: (error: Error) => void;
|
|
13
11
|
};
|
|
14
|
-
export declare const ssrRenderToPipeableStream: (App: JSX.Element, options: StreamOptions
|
|
12
|
+
export declare const ssrRenderToPipeableStream: (App: JSX.Element, options: StreamOptions & {
|
|
13
|
+
onAllReady?: (() => void) | undefined;
|
|
14
|
+
onShellReady?: (() => void) | undefined;
|
|
15
|
+
onShellError?: ((error: Error) => void) | undefined;
|
|
16
|
+
}) => {
|
|
15
17
|
pipe: Writable['pipe'];
|
|
16
18
|
};
|
|
17
|
-
export declare const ssrRenderToReadableStream: (App: JSX.Element, options: StreamOptions) => ReadableStream<Uint8Array
|
|
18
|
-
|
|
19
|
+
export declare const ssrRenderToReadableStream: (App: JSX.Element, options: StreamOptions) => Promise<ReadableStream<Uint8Array> & {
|
|
20
|
+
allReady: Promise<void>;
|
|
21
|
+
}>;
|
|
19
22
|
export declare function isStreamingSupported(): Promise<boolean>;
|
|
20
23
|
export declare function bufferReadableStream(reader: ReadableStreamDefaultReader, cb?: (chunk: string) => void): Promise<string>;
|
|
21
24
|
export {};
|
|
@@ -12,34 +12,9 @@ export const rscRenderToReadableStream = _rscRenderToReadableStream;
|
|
|
12
12
|
export const createFromReadableStream = _createFromReadableStream;
|
|
13
13
|
export const ssrRenderToPipeableStream = _ssrRenderToPipeableStream;
|
|
14
14
|
export const ssrRenderToReadableStream = _ssrRenderToReadableStream;
|
|
15
|
-
export function supportsReadableStream() {
|
|
16
|
-
try {
|
|
17
|
-
new ReadableStream();
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
catch (_) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
let cachedStreamingSupport;
|
|
25
15
|
export async function isStreamingSupported() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const rs = new ReadableStream({
|
|
29
|
-
start(controller) {
|
|
30
|
-
controller.close();
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
// This will throw in CFW until streaming
|
|
34
|
-
// is supported. It works in Miniflare.
|
|
35
|
-
await new Response(rs).text();
|
|
36
|
-
cachedStreamingSupport = true;
|
|
37
|
-
}
|
|
38
|
-
catch (_) {
|
|
39
|
-
cachedStreamingSupport = false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return cachedStreamingSupport;
|
|
16
|
+
var _a, _b;
|
|
17
|
+
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);
|
|
43
18
|
}
|
|
44
19
|
export async function bufferReadableStream(reader, cb) {
|
|
45
20
|
const decoder = new TextDecoder();
|
package/dist/esnext/types.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import type { ServerResponse } from 'http';
|
|
|
3
3
|
import type { Logger } from './utilities/log/log';
|
|
4
4
|
import type { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
5
5
|
import type { ServerComponentResponse } from './framework/Hydration/ServerComponentResponse.server';
|
|
6
|
-
import type { Metafield,
|
|
6
|
+
import type { Metafield, ProductVariant, Product, MediaImage } from './storefront-api-types';
|
|
7
7
|
declare type CommonOptions = {
|
|
8
8
|
App: any;
|
|
9
|
-
|
|
9
|
+
routes?: ImportGlobEagerOutput;
|
|
10
10
|
request: ServerComponentRequest;
|
|
11
11
|
componentResponse: ServerComponentResponse;
|
|
12
12
|
log: Logger;
|
|
@@ -36,7 +36,7 @@ export declare type Hook = (params: {
|
|
|
36
36
|
} & Record<string, any>) => any | Promise<any>;
|
|
37
37
|
export declare type ImportGlobEagerOutput = Record<string, Record<'default' | 'api', any>>;
|
|
38
38
|
export declare type ServerHandlerConfig = {
|
|
39
|
-
|
|
39
|
+
routes?: ImportGlobEagerOutput;
|
|
40
40
|
shopifyConfig: ShopifyConfig;
|
|
41
41
|
};
|
|
42
42
|
export declare type ClientHandlerConfig = {
|
|
@@ -50,21 +50,6 @@ export interface GraphQLConnection<T> {
|
|
|
50
50
|
node: T;
|
|
51
51
|
}[];
|
|
52
52
|
}
|
|
53
|
-
export interface MediaImage {
|
|
54
|
-
__typename?: string;
|
|
55
|
-
id?: string;
|
|
56
|
-
mediaContentType?: MediaContentType;
|
|
57
|
-
data?: Pick<Image, 'altText' | 'url' | 'id' | 'width' | 'height'>;
|
|
58
|
-
}
|
|
59
|
-
interface ProductVariant {
|
|
60
|
-
__typename?: string;
|
|
61
|
-
}
|
|
62
|
-
interface Product {
|
|
63
|
-
__typename?: string;
|
|
64
|
-
}
|
|
65
|
-
export declare type RawMetafield = Omit<Partial<Metafield>, 'reference'> & {
|
|
66
|
-
reference?: MediaImage | ProductVariant | Product | null;
|
|
67
|
-
};
|
|
68
53
|
export declare type ParsedMetafield = Omit<Partial<Metafield>, 'value' | 'reference'> & {
|
|
69
54
|
value?: string | number | boolean | Record<any, string> | Date | Rating | Measurement;
|
|
70
55
|
reference?: MediaImage | ProductVariant | Product | null;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ImportGlobEagerOutput } from '../types';
|
|
1
|
+
import { ImportGlobEagerOutput, ShopifyConfig } from '../types';
|
|
2
|
+
import type { ASTNode } from 'graphql';
|
|
2
3
|
declare type RouteParams = Record<string, string>;
|
|
3
4
|
declare type RequestOptions = {
|
|
4
5
|
params: RouteParams;
|
|
6
|
+
queryShop: (args: QueryShopArgs) => Promise<any>;
|
|
5
7
|
};
|
|
6
8
|
declare type ResourceGetter = (request: Request, requestOptions: RequestOptions) => Promise<Response | Object | String>;
|
|
7
9
|
interface HydrogenApiRoute {
|
|
@@ -14,7 +16,21 @@ export declare type ApiRouteMatch = {
|
|
|
14
16
|
hasServerComponent: boolean;
|
|
15
17
|
params: RouteParams;
|
|
16
18
|
};
|
|
17
|
-
export declare function
|
|
19
|
+
export declare function getApiRoutes(pages: ImportGlobEagerOutput | undefined, topLevelPath?: string): Array<HydrogenApiRoute>;
|
|
18
20
|
export declare function getApiRouteFromURL(url: URL, routes: Array<HydrogenApiRoute>): ApiRouteMatch | null;
|
|
19
|
-
|
|
21
|
+
/** The `queryShop` utility is a function that helps you query the Storefront API.
|
|
22
|
+
* It's similar to the `useShopQuery` hook, which is available in server components.
|
|
23
|
+
* To use `queryShop`, pass `shopifyConfig` to `renderHydrogen` inside `App.server.jsx`.
|
|
24
|
+
*/
|
|
25
|
+
interface QueryShopArgs {
|
|
26
|
+
/** A string of the GraphQL query.
|
|
27
|
+
* If no query is provided, then the `useShopQuery` makes no calls to the Storefront API.
|
|
28
|
+
*/
|
|
29
|
+
query: ASTNode | string;
|
|
30
|
+
/** An object of the variables for the GraphQL query. */
|
|
31
|
+
variables?: Record<string, any>;
|
|
32
|
+
/** A string corresponding to a valid locale identifier like `en-us` used to make the request. */
|
|
33
|
+
locale?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function renderApiRoute(request: Request, route: ApiRouteMatch, shopifyConfig: ShopifyConfig): Promise<Response>;
|
|
20
36
|
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { matchPath } from './matchPath';
|
|
2
2
|
import { getLoggerWithContext, logServerResponse } from '../utilities/log/';
|
|
3
|
+
import { fetchBuilder, graphqlRequestBody } from './fetch';
|
|
3
4
|
let memoizedRoutes = [];
|
|
4
5
|
let memoizedPages = {};
|
|
5
|
-
export function
|
|
6
|
+
export function getApiRoutes(pages, topLevelPath = '*') {
|
|
6
7
|
if (!pages || memoizedPages === pages)
|
|
7
8
|
return memoizedRoutes;
|
|
8
9
|
const topLevelPrefix = topLevelPath.replace('*', '').replace(/\/$/, '');
|
|
9
10
|
const routes = Object.keys(pages)
|
|
10
11
|
.filter((key) => pages[key].api)
|
|
11
12
|
.map((key) => {
|
|
12
|
-
|
|
13
|
-
.replace('./
|
|
13
|
+
let path = key
|
|
14
|
+
.replace('./routes', '')
|
|
14
15
|
.replace(/\.server\.(t|j)sx?$/, '')
|
|
15
16
|
/**
|
|
16
17
|
* Replace /index with /
|
|
@@ -25,6 +26,8 @@ export function getApiRoutesFromPages(pages, topLevelPath = '*') {
|
|
|
25
26
|
* Convert /[handle].jsx and /[...handle].jsx to /:handle.jsx for react-router-dom
|
|
26
27
|
*/
|
|
27
28
|
.replace(/\[(?:[.]{3})?(\w+?)\]/g, (_match, param) => `:${param}`);
|
|
29
|
+
if (path.endsWith('/') && path !== '/')
|
|
30
|
+
path = path.substring(0, path.length - 1);
|
|
28
31
|
/**
|
|
29
32
|
* Catch-all routes [...handle].jsx don't need an exact match
|
|
30
33
|
* https://reactrouter.com/core/api/Route/exact-bool
|
|
@@ -61,11 +64,30 @@ export function getApiRouteFromURL(url, routes) {
|
|
|
61
64
|
hasServerComponent: foundRoute.hasServerComponent,
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
|
-
|
|
67
|
+
function queryShopBuilder(shopifyConfig) {
|
|
68
|
+
return async function queryShop({ query, variables, locale, }) {
|
|
69
|
+
var _a;
|
|
70
|
+
const { storeDomain, storefrontApiVersion, storefrontToken, defaultLocale } = shopifyConfig;
|
|
71
|
+
const fetcher = fetchBuilder(`https://${storeDomain}/api/${storefrontApiVersion}/graphql.json`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
body: graphqlRequestBody(query, variables),
|
|
74
|
+
headers: {
|
|
75
|
+
'X-Shopify-Storefront-Access-Token': storefrontToken,
|
|
76
|
+
'Accept-Language': (_a = locale) !== null && _a !== void 0 ? _a : defaultLocale,
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return await fetcher();
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export async function renderApiRoute(request, route, shopifyConfig) {
|
|
65
84
|
let response;
|
|
66
85
|
const log = getLoggerWithContext(request);
|
|
67
86
|
try {
|
|
68
|
-
response = await route.resource(request, {
|
|
87
|
+
response = await route.resource(request, {
|
|
88
|
+
params: route.params,
|
|
89
|
+
queryShop: queryShopBuilder(shopifyConfig),
|
|
90
|
+
});
|
|
69
91
|
if (!(response instanceof Response)) {
|
|
70
92
|
if (typeof response === 'string' || response instanceof String) {
|
|
71
93
|
response = new Response(response);
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { ASTNode } from 'graphql';
|
|
2
|
-
|
|
2
|
+
declare type FetchInit = {
|
|
3
|
+
body?: string;
|
|
4
|
+
method?: string;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare function fetchBuilder<T>(url: string, options?: FetchInit): () => Promise<T>;
|
|
3
8
|
export declare function graphqlRequestBody(query: ASTNode | string, variables?: Record<string, any>): string;
|
|
4
9
|
export declare function decodeShopifyId(id: string): string;
|
|
10
|
+
export {};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { print } from 'graphql';
|
|
2
2
|
import { LIB_VERSION } from '../version';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const defaultHeaders = {
|
|
4
|
+
'content-type': 'application/json',
|
|
5
|
+
'user-agent': `Hydrogen ${LIB_VERSION}`,
|
|
6
|
+
};
|
|
7
|
+
export function fetchBuilder(url, options = {}) {
|
|
8
|
+
const requestInit = {
|
|
9
|
+
...options,
|
|
10
|
+
headers: { ...defaultHeaders, ...options.headers },
|
|
7
11
|
};
|
|
8
|
-
for (const [property, value] of Object.entries(defaultHeaders)) {
|
|
9
|
-
if (!request.headers.has(property)) {
|
|
10
|
-
request.headers.append(property, value);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
12
|
return async () => {
|
|
14
|
-
const response = await fetch(
|
|
13
|
+
const response = await fetch(url, requestInit);
|
|
15
14
|
if (!response.ok) {
|
|
16
15
|
throw response;
|
|
17
16
|
}
|
|
@@ -27,14 +26,6 @@ export function graphqlRequestBody(query, variables) {
|
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
export function decodeShopifyId(id) {
|
|
30
|
-
// Start fix: for SFAPI 2022-01. Remove when upgrading to 2022-04
|
|
31
|
-
if (!id.startsWith('gid://')) {
|
|
32
|
-
id =
|
|
33
|
-
typeof btoa !== 'undefined'
|
|
34
|
-
? btoa(id)
|
|
35
|
-
: Buffer.from(id, 'base64').toString('ascii');
|
|
36
|
-
}
|
|
37
|
-
// End fix
|
|
38
29
|
if (!id.startsWith('gid://')) {
|
|
39
30
|
throw new Error('invalid Shopify ID');
|
|
40
31
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GraphQLConnection } from '../../types';
|
|
1
|
+
import type { GraphQLConnection } from '../../types';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
/**
|
|
3
4
|
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
4
5
|
*/
|
|
5
|
-
export declare function flattenConnection<T>(connection: GraphQLConnection<T
|
|
6
|
+
export declare function flattenConnection<T>(connection: PartialDeep<GraphQLConnection<T>>): PartialDeep<T>[];
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
3
3
|
*/
|
|
4
4
|
export function flattenConnection(connection) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
return (connection.edges || []).map((edge) => {
|
|
6
|
+
if (!(edge === null || edge === void 0 ? void 0 : edge.node)) {
|
|
7
|
+
throw new Error('Connection edges must contain nodes');
|
|
8
|
+
}
|
|
9
|
+
return edge.node;
|
|
10
|
+
});
|
|
7
11
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ASTNode } from 'graphql';
|
|
2
|
+
export declare const TIMEOUT_MS = 2000;
|
|
3
|
+
declare type TrackerParams = {
|
|
4
|
+
query: ASTNode;
|
|
5
|
+
data: {
|
|
6
|
+
data: unknown;
|
|
7
|
+
};
|
|
8
|
+
onUnusedData?: (params: {
|
|
9
|
+
queryName: string;
|
|
10
|
+
properties: string[];
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function injectGraphQLTracker({ query, data, onUnusedData, }: TrackerParams): (check?: (params: {
|
|
14
|
+
queryName: string;
|
|
15
|
+
properties: string[];
|
|
16
|
+
}) => void) => void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export const TIMEOUT_MS = 2000;
|
|
2
|
+
export function injectGraphQLTracker({ query, data, onUnusedData, }) {
|
|
3
|
+
var _a;
|
|
4
|
+
const info = convertQueryToResolveInfo(query);
|
|
5
|
+
// E.g. ['shop.stuff.myString']
|
|
6
|
+
const requestedFields = getFieldList(info.nodes, info.fragments);
|
|
7
|
+
// Remove the last key of each path to avoid proxying primitive
|
|
8
|
+
// values. Reverse order to avoid accessing already defined
|
|
9
|
+
// proxies (i.e. handle child properties before parent properties)
|
|
10
|
+
// E.g. `shop.stuff.myString` => `shop.stuff`
|
|
11
|
+
const uniqueFieldPaths = [
|
|
12
|
+
...new Set(requestedFields.map((path) => path.split('.').slice(0, -1).join('.'))),
|
|
13
|
+
].reverse();
|
|
14
|
+
const queryName = ((_a = findOperationDefinition(query).name) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
15
|
+
// Record fields that are read in the proxy to compare later.
|
|
16
|
+
const readFieldsMap = {};
|
|
17
|
+
let isCheckedOnce = false;
|
|
18
|
+
const checkFields = (check = onUnusedData) => {
|
|
19
|
+
isCheckedOnce = true;
|
|
20
|
+
const properties = requestedFields
|
|
21
|
+
.filter((prop) => !readFieldsMap[prop] && !prop.endsWith('.__typename'))
|
|
22
|
+
.map((prop) => prop.replace(/\.edges\./g, '.').replace(/\.node\./g, '.'));
|
|
23
|
+
if (properties.length > 0) {
|
|
24
|
+
return check({ queryName, properties });
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
let readTimeout;
|
|
28
|
+
uniqueFieldPaths.forEach((fieldPath) => deepTransform(data, 'data.' + fieldPath, (value) => {
|
|
29
|
+
if (typeof value !== 'object' || value === null)
|
|
30
|
+
return value;
|
|
31
|
+
return new Proxy(value, {
|
|
32
|
+
get(target, prop) {
|
|
33
|
+
if (typeof prop === 'string') {
|
|
34
|
+
const fullPath = fieldPath + '.' + prop;
|
|
35
|
+
if (!readFieldsMap[fullPath]) {
|
|
36
|
+
readFieldsMap[fullPath] = true;
|
|
37
|
+
if (onUnusedData && !isCheckedOnce) {
|
|
38
|
+
clearTimeout(readTimeout);
|
|
39
|
+
readTimeout = setTimeout(checkFields, TIMEOUT_MS);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return target[prop];
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}));
|
|
47
|
+
return checkFields;
|
|
48
|
+
}
|
|
49
|
+
function findOperationDefinition(query) {
|
|
50
|
+
return query.definitions.find((def) => def.kind === 'OperationDefinition');
|
|
51
|
+
}
|
|
52
|
+
function convertQueryToResolveInfo(query) {
|
|
53
|
+
var _a;
|
|
54
|
+
return {
|
|
55
|
+
// Root of the selection nodes
|
|
56
|
+
nodes: (_a = findOperationDefinition(query)) === null || _a === void 0 ? void 0 : _a.selectionSet.selections,
|
|
57
|
+
// Collection of all the fragments in this query
|
|
58
|
+
fragments: query.definitions.reduce((acc, current) => {
|
|
59
|
+
if (current.kind === 'FragmentDefinition') {
|
|
60
|
+
acc[current.name.value] = current;
|
|
61
|
+
}
|
|
62
|
+
return acc;
|
|
63
|
+
}, {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Extracts the selection fields from a query AST as a list of dot-separated paths.
|
|
68
|
+
* @param selectionNodes - Selection nodes from the AST
|
|
69
|
+
* @param fragments - Fragments from the AST
|
|
70
|
+
* @param path - Accummulated path for recursion
|
|
71
|
+
* @returns A plain JS array representing the selection fields
|
|
72
|
+
*/
|
|
73
|
+
function getFieldList(nodes, fragments = {}, path = '') {
|
|
74
|
+
return nodes.reduce((acc, node) => {
|
|
75
|
+
var _a, _b, _c, _d, _e;
|
|
76
|
+
let nextPath = path;
|
|
77
|
+
let nextNodes;
|
|
78
|
+
if (node.kind === 'FragmentSpread') {
|
|
79
|
+
nextNodes = fragments[node.name.value].selectionSet.selections;
|
|
80
|
+
}
|
|
81
|
+
else if (node.kind === 'InlineFragment') {
|
|
82
|
+
nextNodes = (_a = node.selectionSet) === null || _a === void 0 ? void 0 : _a.selections;
|
|
83
|
+
}
|
|
84
|
+
else if (node.kind === 'Field') {
|
|
85
|
+
nextNodes = (_b = node.selectionSet) === null || _b === void 0 ? void 0 : _b.selections;
|
|
86
|
+
const name = (_d = (_c = node.alias) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : (_e = node.name) === null || _e === void 0 ? void 0 : _e.value;
|
|
87
|
+
nextPath = path ? `${path}.${name}` : name;
|
|
88
|
+
if (!nextNodes)
|
|
89
|
+
acc.push(nextPath); // This is a leaf
|
|
90
|
+
}
|
|
91
|
+
if (nextNodes)
|
|
92
|
+
acc.push(...getFieldList(nextNodes, fragments, nextPath));
|
|
93
|
+
return acc;
|
|
94
|
+
}, []);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Transform a nested property in a given object (in place).
|
|
98
|
+
* @param input - Object to transform
|
|
99
|
+
* @param path - Dot-separated path to the nested property
|
|
100
|
+
* @param valueTransform - Transformer function
|
|
101
|
+
*/
|
|
102
|
+
function deepTransform(input, path, valueTransform) {
|
|
103
|
+
const keys = Array.isArray(path) ? path : path.split('.');
|
|
104
|
+
let obj = input;
|
|
105
|
+
let key;
|
|
106
|
+
for (let index = 0; !!obj && index < keys.length; index++) {
|
|
107
|
+
key = keys[index];
|
|
108
|
+
if (index === keys.length - 1) {
|
|
109
|
+
// Last property, transform value
|
|
110
|
+
obj[key] = valueTransform(obj[key]);
|
|
111
|
+
}
|
|
112
|
+
else if (Array.isArray(obj[key])) {
|
|
113
|
+
// We've found an array in the middle, run this recursively
|
|
114
|
+
const subKeys = keys.slice(index + 1);
|
|
115
|
+
obj[key].forEach((v) => deepTransform(v, subKeys, valueTransform));
|
|
116
|
+
}
|
|
117
|
+
obj = obj[key];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Image as ImageType } from '../
|
|
1
|
+
import type { Image as ImageType } from '../storefront-api-types';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
export declare type Width = string | 'original';
|
|
3
4
|
export declare type Height = string | 'original';
|
|
4
5
|
export declare type Crop = 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
@@ -23,7 +24,7 @@ export interface ImageLoaderOptions {
|
|
|
23
24
|
export declare function addImageSizeParametersToUrl(url: string, { width, height, crop, scale, format }: ImageSizeOptions): string;
|
|
24
25
|
export declare function shopifyImageLoader({ src, options }: ImageLoaderOptions): string;
|
|
25
26
|
export declare function useImageUrl(src?: string, options?: ImageSizeOptions): string | undefined;
|
|
26
|
-
export declare function getShopifyImageDimensions(image: Pick<ImageType
|
|
27
|
-
width: import("../
|
|
28
|
-
height: import("../
|
|
27
|
+
export declare function getShopifyImageDimensions(image: Pick<PartialDeep<ImageType>, 'altText' | 'url' | 'id' | 'width' | 'height'>, options?: ImageSizeOptions): {
|
|
28
|
+
width: import("../storefront-api-types").Maybe<number> | undefined;
|
|
29
|
+
height: import("../storefront-api-types").Maybe<number> | undefined;
|
|
29
30
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerComponentRequest } from '../../framework/Hydration/ServerComponentRequest.server';
|
|
2
2
|
import { QueryKey } from '../../types';
|
|
3
3
|
import type { RenderType } from './log';
|
|
4
|
-
export declare type TimingType = 'requested' | 'resolved' | 'rendered' | 'preload'
|
|
4
|
+
export declare type TimingType = 'requested' | 'resolved' | 'rendered' | 'preload';
|
|
5
5
|
export declare type QueryTiming = {
|
|
6
6
|
name: string;
|
|
7
7
|
timingType: TimingType;
|
|
@@ -9,7 +9,6 @@ const TIMING_MAPPING = {
|
|
|
9
9
|
rendered: 'Rendered',
|
|
10
10
|
resolved: 'Resolved',
|
|
11
11
|
preload: 'Preload',
|
|
12
|
-
expired: 'Expired',
|
|
13
12
|
};
|
|
14
13
|
export function collectQueryTimings(request, queryKey, timingType, duration) {
|
|
15
14
|
request.ctx.queryTimings.push({
|
|
@@ -45,7 +44,7 @@ export function logQueryTimings(type, request) {
|
|
|
45
44
|
}
|
|
46
45
|
const loadColor = query.timingType === 'preload' ? green : color;
|
|
47
46
|
const duration = query.duration;
|
|
48
|
-
log.debug(color(`│ ${`${(query.timestamp - requestStartTime).toFixed(2)}ms`.padEnd(10)} ${loadColor(TIMING_MAPPING[query.timingType].padEnd(10))} ${query.name}${query.timingType === 'resolved'
|
|
47
|
+
log.debug(color(`│ ${`${(query.timestamp - requestStartTime).toFixed(2)}ms`.padEnd(10)} ${loadColor(TIMING_MAPPING[query.timingType].padEnd(10))} ${query.name}${query.timingType === 'resolved'
|
|
49
48
|
? ` (Took ${duration === null || duration === void 0 ? void 0 : duration.toFixed(2)}ms)`
|
|
50
49
|
: ''}`));
|
|
51
50
|
// SSR + RSC render path generates 2 `load` and `render` for each query
|
|
@@ -11,6 +11,7 @@ export declare type LoggerOptions = {
|
|
|
11
11
|
showCacheControlHeader?: boolean;
|
|
12
12
|
showCacheApiStatus?: boolean;
|
|
13
13
|
showQueryTiming?: boolean;
|
|
14
|
+
showUnusedQueryProperties?: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare type RenderType = 'str' | 'rsc' | 'ssr' | 'api';
|
|
16
17
|
export declare const log: Logger;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export function findQueryName(key) {
|
|
2
2
|
const decodeKey = decodeURIComponent(key);
|
|
3
|
+
if (key.length < 100) {
|
|
4
|
+
return key.replace('"__QUERY_CACHE_ID__"', '').replace(/"/g, '');
|
|
5
|
+
}
|
|
3
6
|
const match = decodeKey.match(/query ([^\s\()]*)\s?(|\(\{)/);
|
|
4
7
|
if (match && match.length > 1) {
|
|
5
8
|
return match[1];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Metafield } from '../../storefront-api-types';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
/**
|
|
3
4
|
* The `parseMetafieldValue` function parses a [Metafield](/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
4
5
|
*/
|
|
5
|
-
export declare function parseMetafieldValue(metafield:
|
|
6
|
+
export declare function parseMetafieldValue(metafield: PartialDeep<Metafield>): any;
|
|
@@ -13,10 +13,6 @@ export function addParametersToEmbeddedVideoUrl(url, parameters) {
|
|
|
13
13
|
return `${url}?${params}`;
|
|
14
14
|
}
|
|
15
15
|
export function useEmbeddedVideoUrl(url, parameters) {
|
|
16
|
-
// Ensure a youtube shortened url is changed to an iFrame compatible embed link.
|
|
17
|
-
// TODO: Fix is needed for SFAPI version 2022-01. Starting 2022-04 embeddedUrl has been marked as deprecated and replaced with
|
|
18
|
-
// embedUrl. When the pinned SFAPI version is 2022-04 line can be removed in favor of changes on PR #455
|
|
19
|
-
url = url.replace(/youtu\.be/, 'www.youtube.com/embed');
|
|
20
16
|
return useMemo(() => {
|
|
21
17
|
if (!parameters) {
|
|
22
18
|
return url;
|
package/dist/esnext/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.
|
|
1
|
+
export declare const LIB_VERSION = "0.13.1";
|
package/dist/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '0.
|
|
1
|
+
export const LIB_VERSION = '0.13.1';
|
|
@@ -14,9 +14,10 @@ interface RequestHandlerOptions {
|
|
|
14
14
|
dev?: boolean;
|
|
15
15
|
context?: RuntimeContext;
|
|
16
16
|
nonce?: string;
|
|
17
|
+
buyerIpHeader?: string;
|
|
17
18
|
}
|
|
18
19
|
export interface RequestHandler {
|
|
19
20
|
(request: Request | IncomingMessage, options: RequestHandlerOptions): Promise<Response | undefined>;
|
|
20
21
|
}
|
|
21
|
-
export declare const renderHydrogen: (App: any, {
|
|
22
|
+
export declare const renderHydrogen: (App: any, { shopifyConfig, routes }: ServerHandlerConfig) => RequestHandler;
|
|
22
23
|
export default renderHydrogen;
|