@shopify/hydrogen 0.7.0 → 0.8.2
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/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +1 -1
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.js +1 -1
- package/dist/esnext/components/CartLineProvider/context.d.ts +3 -3
- package/dist/esnext/components/CartLineQuantityAdjustButton/CartLineQuantityAdjustButton.js +4 -0
- package/dist/esnext/components/CartProvider/CartProvider.client.js +0 -1
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +1 -1
- package/dist/esnext/components/Image/Image.d.ts +1 -1
- package/dist/esnext/components/LocalizationProvider/index.d.ts +1 -0
- package/dist/esnext/components/LocalizationProvider/index.js +1 -0
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +1 -1
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +1 -1
- package/dist/esnext/components/Metafield/components/StarRating/StarRating.d.ts +1 -1
- package/dist/esnext/components/Metafield/index.d.ts +2 -2
- package/dist/esnext/components/Model3D/Model3D.client.d.ts +1 -1
- package/dist/esnext/components/Money/Money.client.d.ts +1 -1
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +1 -3
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -3
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +1 -1
- package/dist/esnext/components/ShopPayButton/ShopPayButton.client.js +1 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +2 -3
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +1 -2
- package/dist/esnext/components/Video/Video.d.ts +1 -1
- package/dist/esnext/components/index.d.ts +3 -2
- package/dist/esnext/components/index.js +1 -0
- package/dist/esnext/entry-client.js +4 -6
- package/dist/esnext/entry-server.js +77 -47
- package/dist/esnext/foundation/RenderCacheProvider/RenderCacheContext.d.ts +2 -0
- package/dist/esnext/foundation/RenderCacheProvider/RenderCacheContext.js +4 -0
- package/dist/esnext/foundation/RenderCacheProvider/RenderCacheProvider.d.ts +2 -0
- package/dist/esnext/foundation/RenderCacheProvider/RenderCacheProvider.js +5 -0
- package/dist/esnext/foundation/RenderCacheProvider/hook.d.ts +11 -0
- package/dist/esnext/foundation/RenderCacheProvider/hook.js +34 -0
- package/dist/esnext/foundation/RenderCacheProvider/index.d.ts +1 -0
- package/dist/esnext/foundation/RenderCacheProvider/index.js +1 -0
- package/dist/esnext/foundation/RenderCacheProvider/types.d.ts +18 -0
- package/dist/esnext/foundation/RenderCacheProvider/types.js +1 -0
- package/dist/esnext/foundation/Router/DefaultRoutes.d.ts +3 -1
- package/dist/esnext/foundation/Router/DefaultRoutes.js +2 -2
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.client.js +4 -2
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +2 -1
- package/dist/esnext/foundation/ShopifyProvider/ShopifyServerProvider.server.d.ts +1 -3
- package/dist/esnext/foundation/ShopifyProvider/ShopifyServerProvider.server.js +2 -4
- package/dist/esnext/foundation/ShopifyProvider/types.d.ts +0 -5
- package/dist/esnext/foundation/useQuery/hooks.d.ts +8 -6
- package/dist/esnext/foundation/useQuery/hooks.js +13 -14
- package/dist/esnext/foundation/useQuery/index.d.ts +0 -1
- package/dist/esnext/foundation/useQuery/index.js +0 -1
- package/dist/esnext/foundation/useServerState/use-server-state.d.ts +1 -1
- package/dist/esnext/foundation/useServerState/use-server-state.js +1 -1
- package/dist/esnext/foundation/useShop/use-shop.d.ts +1 -1
- package/dist/esnext/foundation/useShop/use-shop.js +1 -1
- package/dist/esnext/framework/ClientMarker/ClientMarker.js +0 -1
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +2 -0
- package/dist/esnext/framework/Hydration/writer.server.js +1 -0
- package/dist/esnext/framework/cache.d.ts +2 -2
- package/dist/esnext/framework/cache.js +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +13 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +7 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +15 -1
- package/dist/esnext/framework/plugins/vite-plugin-react-server-components-shim.js +1 -23
- package/dist/esnext/framework/server-components.js +25 -47
- package/dist/esnext/graphql/graphql-constants.d.ts +23 -23
- package/dist/esnext/handle-event.d.ts +1 -1
- package/dist/esnext/handle-event.js +68 -10
- package/dist/esnext/hooks/index.d.ts +1 -1
- package/dist/esnext/hooks/index.js +1 -1
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +3 -3
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +5 -5
- package/dist/esnext/hooks/useShopQuery/hooks.js +45 -17
- package/dist/esnext/index.d.ts +2 -1
- package/dist/esnext/index.js +2 -1
- package/dist/esnext/types.d.ts +2 -1
- package/dist/esnext/utilities/fetch.js +3 -6
- package/dist/esnext/utilities/index.d.ts +1 -0
- package/dist/esnext/utilities/index.js +1 -0
- package/dist/esnext/utilities/log/index.d.ts +1 -0
- package/dist/esnext/utilities/log/index.js +1 -0
- package/dist/esnext/utilities/log/log.d.ts +17 -0
- package/dist/esnext/utilities/log/log.js +70 -0
- package/dist/esnext/utilities/suspense.d.ts +2 -2
- package/dist/esnext/utilities/suspense.js +0 -6
- package/dist/esnext/utilities/timing.d.ts +7 -0
- package/dist/esnext/utilities/timing.js +14 -0
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/framework/ClientMarker/ClientMarker.js +2 -3
- package/dist/node/framework/Hydration/Cache.client.js +4 -4
- package/dist/node/framework/Hydration/HydrationContext.server.js +1 -1
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +2 -0
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +2 -2
- package/dist/node/framework/Hydration/react-utils.js +3 -3
- package/dist/node/framework/Hydration/wire.server.js +1 -1
- package/dist/node/framework/Hydration/writer.server.js +1 -0
- package/dist/node/framework/cache.d.ts +2 -2
- package/dist/node/framework/cache.js +5 -4
- package/dist/node/framework/middleware.js +2 -2
- package/dist/node/framework/plugin.js +5 -5
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +13 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +7 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +17 -3
- package/dist/node/framework/plugins/vite-plugin-react-server-components-shim.js +8 -30
- package/dist/node/framework/server-components.js +27 -49
- package/dist/node/handle-event.d.ts +1 -1
- package/dist/node/handle-event.js +72 -14
- package/dist/node/types.d.ts +2 -1
- package/dist/node/utilities/fetch.js +4 -7
- package/dist/node/utilities/index.d.ts +1 -0
- package/dist/node/utilities/index.js +3 -1
- package/dist/node/utilities/isServer/isServer.js +1 -1
- package/dist/node/utilities/suspense.d.ts +2 -2
- package/dist/node/utilities/suspense.js +0 -6
- package/dist/node/utilities/timing.d.ts +7 -0
- package/dist/node/utilities/timing.js +18 -0
- package/dist/node/utilities/video_parameters.js +1 -1
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/dist/worker/framework/Hydration/ServerComponentRequest.server.d.ts +1 -0
- package/dist/worker/framework/Hydration/ServerComponentRequest.server.js +2 -0
- package/dist/worker/framework/cache.d.ts +2 -2
- package/dist/worker/framework/cache.js +1 -1
- package/dist/worker/handle-event.d.ts +1 -1
- package/dist/worker/handle-event.js +68 -10
- package/dist/worker/types.d.ts +2 -1
- package/dist/worker/utilities/timing.d.ts +7 -0
- package/dist/worker/utilities/timing.js +14 -0
- package/package.json +10 -10
- package/dist/esnext/foundation/useQuery/QueryProvider.d.ts +0 -6
- package/dist/esnext/foundation/useQuery/QueryProvider.js +0 -13
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
*
|
|
100
100
|
*```
|
|
101
101
|
*/
|
|
102
|
-
export declare const CartAttributesUpdate:
|
|
102
|
+
export declare const CartAttributesUpdate = "\nmutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
103
103
|
/**
|
|
104
104
|
*```
|
|
105
105
|
*
|
|
@@ -206,7 +206,7 @@ export declare const CartAttributesUpdate: string;
|
|
|
206
206
|
*
|
|
207
207
|
*```
|
|
208
208
|
*/
|
|
209
|
-
export declare const CartBuyerIdentityUpdate:
|
|
209
|
+
export declare const CartBuyerIdentityUpdate = "\nmutation CartBuyerIdentityUpdate(\n $cartId: ID!\n $buyerIdentity: CartBuyerIdentityInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n) @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
210
210
|
/**
|
|
211
211
|
*```
|
|
212
212
|
*
|
|
@@ -308,7 +308,7 @@ export declare const CartBuyerIdentityUpdate: string;
|
|
|
308
308
|
*
|
|
309
309
|
*```
|
|
310
310
|
*/
|
|
311
|
-
export declare const CartCreate:
|
|
311
|
+
export declare const CartCreate = "\nmutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartCreate(input: $input) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
312
312
|
/**
|
|
313
313
|
*```
|
|
314
314
|
*
|
|
@@ -410,7 +410,7 @@ export declare const CartCreate: string;
|
|
|
410
410
|
*
|
|
411
411
|
*```
|
|
412
412
|
*/
|
|
413
|
-
export declare const CartDiscountCodesUpdate:
|
|
413
|
+
export declare const CartDiscountCodesUpdate = "\nmutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
414
414
|
/**
|
|
415
415
|
*```
|
|
416
416
|
* fragment CartFragment on Cart {
|
|
@@ -503,7 +503,7 @@ export declare const CartDiscountCodesUpdate: string;
|
|
|
503
503
|
*
|
|
504
504
|
*```
|
|
505
505
|
*/
|
|
506
|
-
export declare const CartFragment:
|
|
506
|
+
export declare const CartFragment = "fragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
507
507
|
/**
|
|
508
508
|
*```
|
|
509
509
|
*
|
|
@@ -605,7 +605,7 @@ export declare const CartFragment: string;
|
|
|
605
605
|
*
|
|
606
606
|
*```
|
|
607
607
|
*/
|
|
608
|
-
export declare const CartLineAdd:
|
|
608
|
+
export declare const CartLineAdd = "\nmutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
609
609
|
/**
|
|
610
610
|
*```
|
|
611
611
|
*
|
|
@@ -707,7 +707,7 @@ export declare const CartLineAdd: string;
|
|
|
707
707
|
*
|
|
708
708
|
*```
|
|
709
709
|
*/
|
|
710
|
-
export declare const CartLineRemove:
|
|
710
|
+
export declare const CartLineRemove = "\nmutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lines) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
711
711
|
/**
|
|
712
712
|
*```
|
|
713
713
|
*
|
|
@@ -809,7 +809,7 @@ export declare const CartLineRemove: string;
|
|
|
809
809
|
*
|
|
810
810
|
*```
|
|
811
811
|
*/
|
|
812
|
-
export declare const CartLineUpdate:
|
|
812
|
+
export declare const CartLineUpdate = "\nmutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
813
813
|
/**
|
|
814
814
|
*```
|
|
815
815
|
*
|
|
@@ -911,7 +911,7 @@ export declare const CartLineUpdate: string;
|
|
|
911
911
|
*
|
|
912
912
|
*```
|
|
913
913
|
*/
|
|
914
|
-
export declare const CartNoteUpdate:
|
|
914
|
+
export declare const CartNoteUpdate = "\nmutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart {\n ...CartFragment\n }\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
915
915
|
/**
|
|
916
916
|
*```
|
|
917
917
|
*
|
|
@@ -1011,7 +1011,7 @@ export declare const CartNoteUpdate: string;
|
|
|
1011
1011
|
*
|
|
1012
1012
|
*```
|
|
1013
1013
|
*/
|
|
1014
|
-
export declare const CartQuery:
|
|
1014
|
+
export declare const CartQuery = "\nquery CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFragment\n }\n}\n\nfragment CartFragment on Cart {\n id\n checkoutUrl\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPriceV2 {\n ...MoneyFragment\n }\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n estimatedCost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n}\n\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
1015
1015
|
/**
|
|
1016
1016
|
*```
|
|
1017
1017
|
* fragment ExternalVideoFragment on ExternalVideo {
|
|
@@ -1023,7 +1023,7 @@ export declare const CartQuery: string;
|
|
|
1023
1023
|
|
|
1024
1024
|
*```
|
|
1025
1025
|
*/
|
|
1026
|
-
export declare const ExternalVideoFragment
|
|
1026
|
+
export declare const ExternalVideoFragment = "fragment ExternalVideoFragment on ExternalVideo {\n id\n embeddedUrl\n host\n}\n\n";
|
|
1027
1027
|
/**
|
|
1028
1028
|
*```
|
|
1029
1029
|
* fragment ImageFragment on Image {
|
|
@@ -1037,7 +1037,7 @@ export declare const ExternalVideoFragment: string;
|
|
|
1037
1037
|
|
|
1038
1038
|
*```
|
|
1039
1039
|
*/
|
|
1040
|
-
export declare const ImageFragment
|
|
1040
|
+
export declare const ImageFragment = "fragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\n";
|
|
1041
1041
|
/**
|
|
1042
1042
|
*```
|
|
1043
1043
|
* query Localization {
|
|
@@ -1062,7 +1062,7 @@ export declare const ImageFragment: string;
|
|
|
1062
1062
|
|
|
1063
1063
|
*```
|
|
1064
1064
|
*/
|
|
1065
|
-
export declare const Localization
|
|
1065
|
+
export declare const Localization = "query Localization {\n localization {\n country {\n isoCode\n name\n currency {\n isoCode\n }\n }\n availableCountries {\n isoCode\n name\n currency {\n isoCode\n }\n }\n }\n}\n\n";
|
|
1066
1066
|
/**
|
|
1067
1067
|
*```
|
|
1068
1068
|
*
|
|
@@ -1126,7 +1126,7 @@ export declare const Localization: string;
|
|
|
1126
1126
|
*
|
|
1127
1127
|
*```
|
|
1128
1128
|
*/
|
|
1129
|
-
export declare const MediaFileFragment
|
|
1129
|
+
export declare const MediaFileFragment = "\nfragment MediaFileFragment on Media {\n ... on MediaImage {\n mediaContentType\n image {\n ...ImageFragment\n }\n }\n ... on Video {\n mediaContentType\n ...VideoFragment\n }\n ... on ExternalVideo {\n mediaContentType\n ...ExternalVideoFragment\n }\n ... on Model3d {\n mediaContentType\n ...Model3DFragment\n }\n}\n\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\nfragment VideoFragment on Video {\n id\n previewImage {\n url\n }\n sources {\n mimeType\n url\n }\n}\n\nfragment ExternalVideoFragment on ExternalVideo {\n id\n embeddedUrl\n host\n}\n\nfragment Model3DFragment on Model3d {\n id\n alt\n mediaContentType\n previewImage {\n url\n }\n sources {\n url\n }\n}\n";
|
|
1130
1130
|
/**
|
|
1131
1131
|
*```
|
|
1132
1132
|
*
|
|
@@ -1160,7 +1160,7 @@ export declare const MediaFileFragment: string;
|
|
|
1160
1160
|
*
|
|
1161
1161
|
*```
|
|
1162
1162
|
*/
|
|
1163
|
-
export declare const MetafieldFragment:
|
|
1163
|
+
export declare const MetafieldFragment = "\nfragment MetafieldFragment on Metafield {\n id\n type\n namespace\n key\n value\n createdAt\n updatedAt\n description\n reference @include(if: $includeReferenceMetafieldDetails) {\n __typename\n ... on MediaImage {\n id\n mediaContentType\n image {\n ...ImageFragment\n }\n }\n }\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n";
|
|
1164
1164
|
/**
|
|
1165
1165
|
*```
|
|
1166
1166
|
* fragment Model3DFragment on Model3d {
|
|
@@ -1178,7 +1178,7 @@ export declare const MetafieldFragment: string;
|
|
|
1178
1178
|
|
|
1179
1179
|
*```
|
|
1180
1180
|
*/
|
|
1181
|
-
export declare const Model3DFragment
|
|
1181
|
+
export declare const Model3DFragment = "fragment Model3DFragment on Model3d {\n id\n alt\n mediaContentType\n previewImage {\n url\n }\n sources {\n url\n }\n}\n\n";
|
|
1182
1182
|
/**
|
|
1183
1183
|
*```
|
|
1184
1184
|
* fragment MoneyFragment on MoneyV2 {
|
|
@@ -1188,7 +1188,7 @@ export declare const Model3DFragment: string;
|
|
|
1188
1188
|
|
|
1189
1189
|
*```
|
|
1190
1190
|
*/
|
|
1191
|
-
export declare const MoneyFragment
|
|
1191
|
+
export declare const MoneyFragment = "fragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\n";
|
|
1192
1192
|
/**
|
|
1193
1193
|
*```
|
|
1194
1194
|
*
|
|
@@ -1499,7 +1499,7 @@ export declare const MoneyFragment: string;
|
|
|
1499
1499
|
* }
|
|
1500
1500
|
*```
|
|
1501
1501
|
*/
|
|
1502
|
-
export declare const ProductProviderFragment:
|
|
1502
|
+
export declare const ProductProviderFragment = "\nfragment ProductProviderFragment on Product {\n compareAtPriceRange {\n maxVariantPrice {\n ...MoneyFragment\n }\n minVariantPrice {\n ...MoneyFragment\n }\n }\n descriptionHtml\n handle\n id\n media(first: $numProductMedia) {\n edges {\n node {\n ...MediaFileFragment\n }\n }\n }\n metafields(first: $numProductMetafields) {\n edges {\n node {\n ...MetafieldFragment\n }\n }\n }\n priceRange {\n maxVariantPrice {\n ...MoneyFragment\n }\n minVariantPrice {\n ...MoneyFragment\n }\n }\n title\n variants(first: $numProductVariants) {\n edges {\n node {\n ...VariantFragment\n }\n }\n }\n sellingPlanGroups(first: $numProductSellingPlanGroups) {\n edges {\n node {\n ...SellingPlanGroupsFragment\n }\n }\n }\n}\n\n\nfragment MediaFileFragment on Media {\n ... on MediaImage {\n mediaContentType\n image {\n ...ImageFragment\n }\n }\n ... on Video {\n mediaContentType\n ...VideoFragment\n }\n ... on ExternalVideo {\n mediaContentType\n ...ExternalVideoFragment\n }\n ... on Model3d {\n mediaContentType\n ...Model3DFragment\n }\n}\n\n\nfragment MetafieldFragment on Metafield {\n id\n type\n namespace\n key\n value\n createdAt\n updatedAt\n description\n reference @include(if: $includeReferenceMetafieldDetails) {\n __typename\n ... on MediaImage {\n id\n mediaContentType\n image {\n ...ImageFragment\n }\n }\n }\n}\n\nfragment VariantFragment on ProductVariant {\n id\n title\n availableForSale\n image {\n ...ImageFragment\n }\n ...UnitPriceFragment\n priceV2 {\n ...MoneyFragment\n }\n compareAtPriceV2 {\n ...MoneyFragment\n }\n selectedOptions {\n name\n value\n }\n metafields(first: $numProductVariantMetafields) {\n edges {\n node {\n ...MetafieldFragment\n }\n }\n }\n sellingPlanAllocations(first: $numProductVariantSellingPlanAllocations) {\n edges {\n node {\n priceAdjustments {\n compareAtPrice {\n ...MoneyFragment\n }\n perDeliveryPrice {\n ...MoneyFragment\n }\n price {\n ...MoneyFragment\n }\n unitPrice {\n ...MoneyFragment\n }\n }\n sellingPlan {\n ...SellingPlanFragment\n }\n }\n }\n }\n}\n\n\nfragment SellingPlanGroupsFragment on SellingPlanGroup {\n sellingPlans(first:$numProductSellingPlans) {\n edges {\n node {\n ...SellingPlanFragment\n }\n }\n }\n appName\n name\n options {\n name\n values\n }\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\nfragment VideoFragment on Video {\n id\n previewImage {\n url\n }\n sources {\n mimeType\n url\n }\n}\n\nfragment ExternalVideoFragment on ExternalVideo {\n id\n embeddedUrl\n host\n}\n\nfragment Model3DFragment on Model3d {\n id\n alt\n mediaContentType\n previewImage {\n url\n }\n sources {\n url\n }\n}\n\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\n\nfragment SellingPlanFragment on SellingPlan {\n id\n description\n name\n options {\n name\n value\n }\n priceAdjustments {\n orderCount\n adjustmentValue {\n ...on SellingPlanFixedAmountPriceAdjustment {\n adjustmentAmount {\n ...MoneyFragment\n }\n }\n ...on SellingPlanFixedPriceAdjustment {\n price {\n ...MoneyFragment\n }\n }\n ...on SellingPlanPercentagePriceAdjustment {\n adjustmentPercentage\n }\n }\n }\n recurringDeliveries\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\n\nfragment UnitPriceFragment on ProductVariant {\n unitPriceMeasurement {\n measuredType\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n unitPrice {\n ...MoneyFragment\n }\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\n\nfragment SellingPlanFragment on SellingPlan {\n id\n description\n name\n options {\n name\n value\n }\n priceAdjustments {\n orderCount\n adjustmentValue {\n ...on SellingPlanFixedAmountPriceAdjustment {\n adjustmentAmount {\n ...MoneyFragment\n }\n }\n ...on SellingPlanFixedPriceAdjustment {\n price {\n ...MoneyFragment\n }\n }\n ...on SellingPlanPercentagePriceAdjustment {\n adjustmentPercentage\n }\n }\n }\n recurringDeliveries\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}";
|
|
1503
1503
|
/**
|
|
1504
1504
|
*```
|
|
1505
1505
|
*
|
|
@@ -1521,7 +1521,7 @@ export declare const ProductProviderFragment: string;
|
|
|
1521
1521
|
* }
|
|
1522
1522
|
*```
|
|
1523
1523
|
*/
|
|
1524
|
-
export declare const UnitPriceFragment
|
|
1524
|
+
export declare const UnitPriceFragment = "\nfragment UnitPriceFragment on ProductVariant {\n unitPriceMeasurement {\n measuredType\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n unitPrice {\n ...MoneyFragment\n }\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}";
|
|
1525
1525
|
/**
|
|
1526
1526
|
*```
|
|
1527
1527
|
* fragment VideoFragment on Video {
|
|
@@ -1538,7 +1538,7 @@ export declare const UnitPriceFragment: string;
|
|
|
1538
1538
|
|
|
1539
1539
|
*```
|
|
1540
1540
|
*/
|
|
1541
|
-
export declare const VideoFragment
|
|
1541
|
+
export declare const VideoFragment = "fragment VideoFragment on Video {\n id\n previewImage {\n url\n }\n sources {\n mimeType\n url\n }\n}\n\n";
|
|
1542
1542
|
/**
|
|
1543
1543
|
*```
|
|
1544
1544
|
*
|
|
@@ -1576,7 +1576,7 @@ export declare const VideoFragment: string;
|
|
|
1576
1576
|
* }
|
|
1577
1577
|
*```
|
|
1578
1578
|
*/
|
|
1579
|
-
export declare const SellingPlanFragment
|
|
1579
|
+
export declare const SellingPlanFragment = "\nfragment SellingPlanFragment on SellingPlan {\n id\n description\n name\n options {\n name\n value\n }\n priceAdjustments {\n orderCount\n adjustmentValue {\n ...on SellingPlanFixedAmountPriceAdjustment {\n adjustmentAmount {\n ...MoneyFragment\n }\n }\n ...on SellingPlanFixedPriceAdjustment {\n price {\n ...MoneyFragment\n }\n }\n ...on SellingPlanPercentagePriceAdjustment {\n adjustmentPercentage\n }\n }\n }\n recurringDeliveries\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}";
|
|
1580
1580
|
/**
|
|
1581
1581
|
*```
|
|
1582
1582
|
*
|
|
@@ -1630,7 +1630,7 @@ export declare const SellingPlanFragment: string;
|
|
|
1630
1630
|
* }
|
|
1631
1631
|
*```
|
|
1632
1632
|
*/
|
|
1633
|
-
export declare const SellingPlanGroupsFragment
|
|
1633
|
+
export declare const SellingPlanGroupsFragment = "\nfragment SellingPlanGroupsFragment on SellingPlanGroup {\n sellingPlans(first:$numProductSellingPlans) {\n edges {\n node {\n ...SellingPlanFragment\n }\n }\n }\n appName\n name\n options {\n name\n values\n }\n}\n\nfragment SellingPlanFragment on SellingPlan {\n id\n description\n name\n options {\n name\n value\n }\n priceAdjustments {\n orderCount\n adjustmentValue {\n ...on SellingPlanFixedAmountPriceAdjustment {\n adjustmentAmount {\n ...MoneyFragment\n }\n }\n ...on SellingPlanFixedPriceAdjustment {\n price {\n ...MoneyFragment\n }\n }\n ...on SellingPlanPercentagePriceAdjustment {\n adjustmentPercentage\n }\n }\n }\n recurringDeliveries\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}";
|
|
1634
1634
|
/**
|
|
1635
1635
|
*```
|
|
1636
1636
|
*
|
|
@@ -1748,4 +1748,4 @@ export declare const SellingPlanGroupsFragment: string;
|
|
|
1748
1748
|
* }
|
|
1749
1749
|
*```
|
|
1750
1750
|
*/
|
|
1751
|
-
export declare const VariantFragment:
|
|
1751
|
+
export declare const VariantFragment = "\nfragment VariantFragment on ProductVariant {\n id\n title\n availableForSale\n image {\n ...ImageFragment\n }\n ...UnitPriceFragment\n priceV2 {\n ...MoneyFragment\n }\n compareAtPriceV2 {\n ...MoneyFragment\n }\n selectedOptions {\n name\n value\n }\n metafields(first: $numProductVariantMetafields) {\n edges {\n node {\n ...MetafieldFragment\n }\n }\n }\n sellingPlanAllocations(first: $numProductVariantSellingPlanAllocations) {\n edges {\n node {\n priceAdjustments {\n compareAtPrice {\n ...MoneyFragment\n }\n perDeliveryPrice {\n ...MoneyFragment\n }\n price {\n ...MoneyFragment\n }\n unitPrice {\n ...MoneyFragment\n }\n }\n sellingPlan {\n ...SellingPlanFragment\n }\n }\n }\n }\n}\n\n\nfragment SellingPlanFragment on SellingPlan {\n id\n description\n name\n options {\n name\n value\n }\n priceAdjustments {\n orderCount\n adjustmentValue {\n ...on SellingPlanFixedAmountPriceAdjustment {\n adjustmentAmount {\n ...MoneyFragment\n }\n }\n ...on SellingPlanFixedPriceAdjustment {\n price {\n ...MoneyFragment\n }\n }\n ...on SellingPlanPercentagePriceAdjustment {\n adjustmentPercentage\n }\n }\n }\n recurringDeliveries\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\n\nfragment UnitPriceFragment on ProductVariant {\n unitPriceMeasurement {\n measuredType\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n unitPrice {\n ...MoneyFragment\n }\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\nfragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import { ServerResponse } from 'http';
|
|
3
3
|
import type { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
4
4
|
import { RuntimeContext } from './framework/runtime';
|
|
5
5
|
interface HydrogenFetchEvent {
|
|
@@ -27,7 +27,8 @@ export default async function handleEvent(event, { request, entrypoint, indexTem
|
|
|
27
27
|
throw new Error(`entry-server.jsx could not be loaded. This likely occurred because of a Vite compilation error.\n` +
|
|
28
28
|
`Please check your server logs for more information.`);
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const userAgent = request.headers.get('user-agent');
|
|
31
|
+
const isStreamable = streamableResponse && !isBotUA(url, userAgent);
|
|
31
32
|
/**
|
|
32
33
|
* Stream back real-user responses, but for bots/etc,
|
|
33
34
|
* use `render` instead. This is because we need to inject <head>
|
|
@@ -35,7 +36,12 @@ export default async function handleEvent(event, { request, entrypoint, indexTem
|
|
|
35
36
|
*/
|
|
36
37
|
if (isStreamable) {
|
|
37
38
|
if (isReactHydrationRequest) {
|
|
38
|
-
hydrate(url, {
|
|
39
|
+
hydrate(url, {
|
|
40
|
+
context: {},
|
|
41
|
+
request,
|
|
42
|
+
response: streamableResponse,
|
|
43
|
+
dev,
|
|
44
|
+
});
|
|
39
45
|
}
|
|
40
46
|
else {
|
|
41
47
|
stream(url, {
|
|
@@ -48,7 +54,12 @@ export default async function handleEvent(event, { request, entrypoint, indexTem
|
|
|
48
54
|
}
|
|
49
55
|
return;
|
|
50
56
|
}
|
|
51
|
-
const { body, bodyAttributes, htmlAttributes, componentResponse, ...head } = await render(url, {
|
|
57
|
+
const { body, bodyAttributes, htmlAttributes, componentResponse, ...head } = await render(url, {
|
|
58
|
+
request,
|
|
59
|
+
context: {},
|
|
60
|
+
isReactHydrationRequest,
|
|
61
|
+
dev,
|
|
62
|
+
});
|
|
52
63
|
const headers = componentResponse.headers;
|
|
53
64
|
/**
|
|
54
65
|
* TODO: Also add `Vary` headers for `accept-language` and any other keys
|
|
@@ -86,13 +97,6 @@ export default async function handleEvent(event, { request, entrypoint, indexTem
|
|
|
86
97
|
}
|
|
87
98
|
return response;
|
|
88
99
|
}
|
|
89
|
-
function isStreamableRequest(url) {
|
|
90
|
-
/**
|
|
91
|
-
* TODO: Add UA detection.
|
|
92
|
-
*/
|
|
93
|
-
const isBot = url.searchParams.has('_bot');
|
|
94
|
-
return !isBot;
|
|
95
|
-
}
|
|
96
100
|
/**
|
|
97
101
|
* Generate the contents of the `head` tag, and update the existing `<title>` tag
|
|
98
102
|
* if one exists, and if a title is passed.
|
|
@@ -117,3 +121,57 @@ function generateHeadTag(head) {
|
|
|
117
121
|
return `<head>${headHtml}</head>`;
|
|
118
122
|
};
|
|
119
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Determines if the request is from a bot, using the URL and User Agent
|
|
126
|
+
*/
|
|
127
|
+
function isBotUA(url, userAgent) {
|
|
128
|
+
return (url.searchParams.has('_bot') || (!!userAgent && botUARegex.test(userAgent)));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* An alphabetized list of User Agents of known bots, combined from lists found at:
|
|
132
|
+
* https://github.com/vercel/next.js/blob/d87dc2b5a0b3fdbc0f6806a47be72bad59564bd0/packages/next/server/utils.ts#L18-L22
|
|
133
|
+
* https://github.com/GoogleChrome/rendertron/blob/6f681688737846b28754fbfdf5db173846a826df/middleware/src/middleware.ts#L24-L41
|
|
134
|
+
*/
|
|
135
|
+
const botUserAgents = [
|
|
136
|
+
'AdsBot-Google',
|
|
137
|
+
'applebot',
|
|
138
|
+
'Baiduspider',
|
|
139
|
+
'baiduspider',
|
|
140
|
+
'bingbot',
|
|
141
|
+
'Bingbot',
|
|
142
|
+
'BingPreview',
|
|
143
|
+
'bitlybot',
|
|
144
|
+
'Discordbot',
|
|
145
|
+
'DuckDuckBot',
|
|
146
|
+
'Embedly',
|
|
147
|
+
'facebookcatalog',
|
|
148
|
+
'facebookexternalhit',
|
|
149
|
+
'Google-PageRenderer',
|
|
150
|
+
'Googlebot',
|
|
151
|
+
'googleweblight',
|
|
152
|
+
'ia_archive',
|
|
153
|
+
'LinkedInBot',
|
|
154
|
+
'Mediapartners-Google',
|
|
155
|
+
'outbrain',
|
|
156
|
+
'pinterest',
|
|
157
|
+
'quora link preview',
|
|
158
|
+
'redditbot',
|
|
159
|
+
'rogerbot',
|
|
160
|
+
'showyoubot',
|
|
161
|
+
'SkypeUriPreview',
|
|
162
|
+
'Slackbot',
|
|
163
|
+
'Slurp',
|
|
164
|
+
'sogou',
|
|
165
|
+
'Storebot-Google',
|
|
166
|
+
'TelegramBot',
|
|
167
|
+
'tumblr',
|
|
168
|
+
'Twitterbot',
|
|
169
|
+
'vkShare',
|
|
170
|
+
'W3C_Validator',
|
|
171
|
+
'WhatsApp',
|
|
172
|
+
'yandex',
|
|
173
|
+
];
|
|
174
|
+
/**
|
|
175
|
+
* Creates a regex based on the botUserAgents array
|
|
176
|
+
*/
|
|
177
|
+
const botUARegex = new RegExp(botUserAgents.join('|'), 'i');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useProductOptions } from './useProductOptions';
|
|
2
2
|
export * from './useProductOptions/types';
|
|
3
|
-
export { useQuery
|
|
3
|
+
export { useQuery } from '../foundation/useQuery';
|
|
4
4
|
export { useMoney } from './useMoney';
|
|
5
5
|
export { useMeasurement } from './useMeasurement';
|
|
6
6
|
export { useParsedMetafields } from './useParsedMetafields';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useProductOptions } from './useProductOptions';
|
|
2
2
|
export * from './useProductOptions/types';
|
|
3
|
-
export { useQuery
|
|
3
|
+
export { useQuery } from '../foundation/useQuery';
|
|
4
4
|
export { useMoney } from './useMoney';
|
|
5
5
|
export { useMeasurement } from './useMeasurement';
|
|
6
6
|
export { useParsedMetafields } from './useParsedMetafields';
|
|
@@ -9,7 +9,7 @@ export declare function useCartLine(): {
|
|
|
9
9
|
} & Pick<import("../../graphql/types/types").Attribute, "key" | "value">)[];
|
|
10
10
|
merchandise: {
|
|
11
11
|
__typename?: "ProductVariant" | undefined;
|
|
12
|
-
} & Pick<import("../../graphql/types/types").ProductVariant, "
|
|
12
|
+
} & Pick<import("../../graphql/types/types").ProductVariant, "id" | "title" | "availableForSale" | "requiresShipping"> & {
|
|
13
13
|
compareAtPriceV2?: import("../../graphql/types/types").Maybe<{
|
|
14
14
|
__typename?: "MoneyV2" | undefined;
|
|
15
15
|
} & {
|
|
@@ -26,12 +26,12 @@ export declare function useCartLine(): {
|
|
|
26
26
|
__typename?: "Image" | undefined; /**
|
|
27
27
|
* The `useCartLine` hook provides access to the cart line object. It must be a descendent of a `CartProvider` component.
|
|
28
28
|
*/
|
|
29
|
-
} & Pick<import("../../graphql/types/types").Image, "
|
|
29
|
+
} & Pick<import("../../graphql/types/types").Image, "id" | "height" | "width" | "url" | "altText">> | undefined;
|
|
30
30
|
product: {
|
|
31
31
|
__typename?: "Product" | undefined;
|
|
32
32
|
} & Pick<import("../../graphql/types/types").Product, "title" | "handle">;
|
|
33
33
|
selectedOptions: ({
|
|
34
34
|
__typename?: "SelectedOption" | undefined;
|
|
35
|
-
} & Pick<import("../../graphql/types/types").SelectedOption, "
|
|
35
|
+
} & Pick<import("../../graphql/types/types").SelectedOption, "name" | "value">)[];
|
|
36
36
|
};
|
|
37
37
|
};
|
|
@@ -6,13 +6,13 @@ export interface UseShopQueryResponse<T> {
|
|
|
6
6
|
errors: any;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* The `useShopQuery` hook allows you to make server-only GraphQL queries to the Storefront API.
|
|
10
|
-
* \> Note:
|
|
11
|
-
* \> It must be a descendent of a `ShopifyProvider` component.
|
|
9
|
+
* The `useShopQuery` hook allows you to make server-only GraphQL queries to the Storefront API. It must be a descendent of a `ShopifyProvider` component.
|
|
12
10
|
*/
|
|
13
11
|
export declare function useShopQuery<T>({ query, variables, cache, }: {
|
|
14
|
-
/** A string of the GraphQL query.
|
|
15
|
-
|
|
12
|
+
/** A string of the GraphQL query.
|
|
13
|
+
* If no query is provided, useShopQuery will make no calls to the Storefront API.
|
|
14
|
+
*/
|
|
15
|
+
query?: ASTNode | string;
|
|
16
16
|
/** An object of the variables for the GraphQL query. */
|
|
17
17
|
variables?: Record<string, any>;
|
|
18
18
|
/** An object containing cache-control options for the sub-request. */
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
import { useShop } from '../../foundation/useShop';
|
|
2
|
+
import { log } from '../../utilities/log';
|
|
2
3
|
import { useQuery } from '../../foundation/useQuery';
|
|
3
4
|
import { isClient, fetchBuilder, graphqlRequestBody } from '../../utilities';
|
|
4
5
|
import { getConfig } from '../../framework/config';
|
|
5
6
|
/**
|
|
6
|
-
* The `useShopQuery` hook allows you to make server-only GraphQL queries to the Storefront API.
|
|
7
|
-
* \> Note:
|
|
8
|
-
* \> It must be a descendent of a `ShopifyProvider` component.
|
|
7
|
+
* The `useShopQuery` hook allows you to make server-only GraphQL queries to the Storefront API. It must be a descendent of a `ShopifyProvider` component.
|
|
9
8
|
*/
|
|
10
9
|
export function useShopQuery({ query, variables = {}, cache = {}, }) {
|
|
11
10
|
if (isClient()) {
|
|
12
11
|
throw new Error('Shopify Storefront API requests should only be made from the server.');
|
|
13
12
|
}
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
const body = query ? graphqlRequestBody(query, variables) : '';
|
|
14
|
+
const { request, key } = createShopRequest(body);
|
|
15
|
+
const { data, error: fetchError } = useQuery(key, query
|
|
16
|
+
? fetchBuilder(request)
|
|
17
|
+
: // If no query, avoid calling SFAPI & return nothing
|
|
18
|
+
async () => ({ data: undefined, errors: undefined }), { cache });
|
|
19
|
+
/**
|
|
20
|
+
* The fetch request itself failed, so we handle that differently than a GraphQL error
|
|
21
|
+
*/
|
|
22
|
+
if (fetchError) {
|
|
23
|
+
const errorMessage = `Failed to fetch the Storefront API. ${
|
|
24
|
+
// 403s to the SF API (almost?) always mean that your Shopify credentials are bad/wrong
|
|
25
|
+
fetchError.status === 403
|
|
26
|
+
? `You may have a bad value in 'shopify.config.js'`
|
|
27
|
+
: `${fetchError.statusText}`}`;
|
|
28
|
+
log.error(errorMessage);
|
|
29
|
+
if (getConfig().dev) {
|
|
30
|
+
throw new Error(errorMessage);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// in non-dev environments, we probably don't want super-detailed error messages for the user
|
|
34
|
+
throw new Error(`The fetch attempt failed; there was an issue connecting to the data source.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
26
37
|
/**
|
|
27
38
|
* GraphQL errors get printed to the console but ultimately
|
|
28
39
|
* get returned to the consumer.
|
|
@@ -30,12 +41,29 @@ export function useShopQuery({ query, variables = {}, cache = {}, }) {
|
|
|
30
41
|
if (data === null || data === void 0 ? void 0 : data.errors) {
|
|
31
42
|
const errors = data.errors instanceof Array ? data.errors : [data.errors];
|
|
32
43
|
for (const error of errors) {
|
|
33
|
-
console.error('GraphQL Error', error);
|
|
34
44
|
if (getConfig().dev) {
|
|
35
45
|
throw new Error(error.message);
|
|
36
46
|
}
|
|
47
|
+
else {
|
|
48
|
+
log.error('GraphQL Error', error);
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
|
-
|
|
51
|
+
log.error(`GraphQL errors: ${errors.length}`);
|
|
39
52
|
}
|
|
40
53
|
return data;
|
|
41
54
|
}
|
|
55
|
+
function createShopRequest(body) {
|
|
56
|
+
const { storeDomain, storefrontToken, graphqlApiVersion } = useShop();
|
|
57
|
+
const url = `https://${storeDomain}/api/${graphqlApiVersion}/graphql.json`;
|
|
58
|
+
return {
|
|
59
|
+
request: new Request(url, {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
headers: {
|
|
62
|
+
'X-Shopify-Storefront-Access-Token': storefrontToken,
|
|
63
|
+
'content-type': 'application/json',
|
|
64
|
+
},
|
|
65
|
+
body,
|
|
66
|
+
}),
|
|
67
|
+
key: [storeDomain, graphqlApiVersion, body],
|
|
68
|
+
};
|
|
69
|
+
}
|
package/dist/esnext/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './foundation/';
|
|
2
2
|
export * from './components/';
|
|
3
3
|
export * from './hooks/';
|
|
4
|
-
export { flattenConnection, fetchBuilder, graphqlRequestBody, decodeShopifyId, isClient, } from './utilities';
|
|
4
|
+
export { flattenConnection, fetchBuilder, graphqlRequestBody, decodeShopifyId, isClient, getTime, } from './utilities';
|
|
5
|
+
export { log, setLogger, Logger } from './utilities/log';
|
|
5
6
|
export { Helmet } from 'react-helmet-async';
|
|
6
7
|
export { LocalizationProvider } from './components/LocalizationProvider/LocalizationProvider.server';
|
|
7
8
|
export * from './hooks/useShopQuery';
|
package/dist/esnext/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './foundation/';
|
|
2
2
|
export * from './components/';
|
|
3
3
|
export * from './hooks/';
|
|
4
|
-
export { flattenConnection, fetchBuilder, graphqlRequestBody, decodeShopifyId, isClient, } from './utilities';
|
|
4
|
+
export { flattenConnection, fetchBuilder, graphqlRequestBody, decodeShopifyId, isClient, getTime, } from './utilities';
|
|
5
|
+
export { log, setLogger } from './utilities/log';
|
|
5
6
|
export { Helmet } from 'react-helmet-async';
|
|
6
7
|
// This is exported here because it contains a Server Component
|
|
7
8
|
export { LocalizationProvider } from './components/LocalizationProvider/LocalizationProvider.server';
|
package/dist/esnext/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import { ServerResponse } from 'http';
|
|
3
3
|
import type { ServerComponentResponse } from './framework/Hydration/ServerComponentResponse.server';
|
|
4
4
|
import type { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
5
5
|
import type { Metafield, Image, MediaContentType } from './graphql/types/types';
|
|
@@ -78,6 +78,7 @@ export interface Measurement {
|
|
|
78
78
|
unit: string;
|
|
79
79
|
value: number;
|
|
80
80
|
}
|
|
81
|
+
export declare type QueryKey = string | readonly unknown[];
|
|
81
82
|
export interface CacheOptions {
|
|
82
83
|
private?: boolean;
|
|
83
84
|
maxAge?: number;
|
|
@@ -38,6 +38,9 @@ export function fetchBuilder(request) {
|
|
|
38
38
|
headers,
|
|
39
39
|
method: clonedRequest.method,
|
|
40
40
|
});
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
throw response;
|
|
43
|
+
}
|
|
41
44
|
const data = await response.json();
|
|
42
45
|
return data;
|
|
43
46
|
};
|
|
@@ -50,12 +53,6 @@ export function graphqlRequestBody(query, variables) {
|
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
export function decodeShopifyId(id) {
|
|
53
|
-
if (!id.startsWith('gid://')) {
|
|
54
|
-
id =
|
|
55
|
-
typeof btoa !== 'undefined'
|
|
56
|
-
? btoa(id)
|
|
57
|
-
: Buffer.from(id, 'base64').toString('ascii');
|
|
58
|
-
}
|
|
59
56
|
if (!id.startsWith('gid://')) {
|
|
60
57
|
throw new Error('invalid Shopify ID');
|
|
61
58
|
}
|
|
@@ -8,3 +8,4 @@ export { isServer } from './isServer';
|
|
|
8
8
|
export { getMeasurementAsParts, getMeasurementAsString } from './measurement';
|
|
9
9
|
export { parseMetafieldValue } from './parseMetafieldValue';
|
|
10
10
|
export { fetchBuilder, graphqlRequestBody, decodeShopifyId } from './fetch';
|
|
11
|
+
export { getTime } from './timing';
|
|
@@ -8,3 +8,4 @@ export { isServer } from './isServer';
|
|
|
8
8
|
export { getMeasurementAsParts, getMeasurementAsString } from './measurement';
|
|
9
9
|
export { parseMetafieldValue } from './parseMetafieldValue';
|
|
10
10
|
export { fetchBuilder, graphqlRequestBody, decodeShopifyId } from './fetch';
|
|
11
|
+
export { getTime } from './timing';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { log, setLogger, Logger, logServerResponse, getLoggerFromContext, resetLogger, } from './log';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { log, setLogger, logServerResponse, getLoggerFromContext, resetLogger, } from './log';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ServerComponentRequest } from '../../framework/Hydration/ServerComponentRequest.server';
|
|
2
|
+
/** A utility for logging debugging, warning, and error information about the application.
|
|
3
|
+
* Use by importing `log` `@shopify/hydrogen` or by using a `log` prop passed to each page
|
|
4
|
+
* component. Using the latter is ideal, because it will ty your log to the current request in progress.
|
|
5
|
+
*/
|
|
6
|
+
export interface Logger {
|
|
7
|
+
trace: (...args: Array<any>) => void;
|
|
8
|
+
debug: (...args: Array<any>) => void;
|
|
9
|
+
warn: (...args: Array<any>) => void;
|
|
10
|
+
error: (...args: Array<any>) => void;
|
|
11
|
+
fatal: (...args: Array<any>) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function getLoggerFromContext(context: any): Logger;
|
|
14
|
+
export declare function setLogger(newLogger: Logger): void;
|
|
15
|
+
export declare function resetLogger(): void;
|
|
16
|
+
export declare const log: Logger;
|
|
17
|
+
export declare function logServerResponse(type: 'str' | 'rsc' | 'ssr', log: Logger, request: ServerComponentRequest, responseStatus: number): void;
|