@shopify/hydrogen 0.7.0 → 0.7.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/dist/esnext/components/CartLineProvider/context.d.ts +3 -3
- 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/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/ProductProvider/ProductProvider.client.d.ts +1 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +1 -1
- package/dist/esnext/components/Video/Video.d.ts +1 -1
- package/dist/esnext/components/index.d.ts +2 -2
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +2 -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/framework/ClientMarker/ClientMarker.js +0 -1
- package/dist/esnext/framework/Hydration/writer.server.js +1 -0
- package/dist/esnext/framework/plugins/vite-plugin-react-server-components-shim.js +0 -10
- package/dist/esnext/framework/server-components.js +25 -47
- package/dist/esnext/graphql/graphql-constants.d.ts +23 -23
- package/dist/esnext/hooks/useCartLine/useCartLine.d.ts +3 -3
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +4 -2
- package/dist/esnext/hooks/useShopQuery/hooks.js +5 -2
- 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/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.js +3 -3
- package/dist/node/framework/middleware.js +2 -2
- package/dist/node/framework/plugin.js +5 -5
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -2
- package/dist/node/framework/plugins/vite-plugin-react-server-components-shim.js +7 -17
- package/dist/node/framework/server-components.js +27 -49
- package/dist/node/handle-event.js +4 -4
- package/dist/node/utilities/fetch.js +1 -1
- package/dist/node/utilities/isServer/isServer.js +1 -1
- 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/package.json +4 -4
|
@@ -6,7 +6,7 @@ export declare const CartLineContext: import("react").Context<({
|
|
|
6
6
|
} & Pick<import("../../graphql/types/types").Attribute, "key" | "value">)[];
|
|
7
7
|
merchandise: {
|
|
8
8
|
__typename?: "ProductVariant" | undefined;
|
|
9
|
-
} & Pick<import("../../graphql/types/types").ProductVariant, "
|
|
9
|
+
} & Pick<import("../../graphql/types/types").ProductVariant, "id" | "title" | "availableForSale" | "requiresShipping"> & {
|
|
10
10
|
compareAtPriceV2?: import("../../graphql/types/types").Maybe<{
|
|
11
11
|
__typename?: "MoneyV2" | undefined;
|
|
12
12
|
} & {
|
|
@@ -21,12 +21,12 @@ export declare const CartLineContext: import("react").Context<({
|
|
|
21
21
|
__typename?: "Image" | undefined;
|
|
22
22
|
} & {
|
|
23
23
|
__typename?: "Image" | undefined;
|
|
24
|
-
} & Pick<import("../../graphql/types/types").Image, "
|
|
24
|
+
} & Pick<import("../../graphql/types/types").Image, "id" | "height" | "width" | "url" | "altText">> | undefined;
|
|
25
25
|
product: {
|
|
26
26
|
__typename?: "Product" | undefined;
|
|
27
27
|
} & Pick<import("../../graphql/types/types").Product, "title" | "handle">;
|
|
28
28
|
selectedOptions: ({
|
|
29
29
|
__typename?: "SelectedOption" | undefined;
|
|
30
|
-
} & Pick<import("../../graphql/types/types").SelectedOption, "
|
|
30
|
+
} & Pick<import("../../graphql/types/types").SelectedOption, "name" | "value">)[];
|
|
31
31
|
};
|
|
32
32
|
}) | null>;
|
|
@@ -417,7 +417,6 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
|
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
419
|
buyerIdentityUpdate({ countryCode }, state);
|
|
420
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
421
420
|
}, [countryCode]);
|
|
422
421
|
const cartContextValue = useMemo(() => {
|
|
423
422
|
return {
|
|
@@ -22,5 +22,5 @@ export declare function ExternalVideo<TTag extends React.ElementType = 'iframe'>
|
|
|
22
22
|
export declare namespace ExternalVideo {
|
|
23
23
|
var Fragment: string;
|
|
24
24
|
}
|
|
25
|
-
export declare const ExternalVideoFragment
|
|
25
|
+
export declare const ExternalVideoFragment = "fragment ExternalVideoFragment on ExternalVideo {\n id\n embeddedUrl\n host\n}\n\n";
|
|
26
26
|
export {};
|
|
@@ -38,5 +38,5 @@ export declare function Image<TTag extends React.ElementType = 'img'>(props: Pro
|
|
|
38
38
|
export declare namespace Image {
|
|
39
39
|
var Fragment: string;
|
|
40
40
|
}
|
|
41
|
-
export declare const ImageFragment
|
|
41
|
+
export declare const ImageFragment = "fragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n}\n\n";
|
|
42
42
|
export {};
|
|
@@ -24,5 +24,5 @@ export declare function MediaFile({ media, options, ...passthroughProps }: Media
|
|
|
24
24
|
export declare namespace MediaFile {
|
|
25
25
|
var Fragment: string;
|
|
26
26
|
}
|
|
27
|
-
export declare const MediaFileFragment
|
|
27
|
+
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";
|
|
28
28
|
export {};
|
|
@@ -22,4 +22,4 @@ export declare function Metafield<TTag extends ElementType>(props: Props<TTag> &
|
|
|
22
22
|
export declare namespace Metafield {
|
|
23
23
|
var Fragment: string;
|
|
24
24
|
}
|
|
25
|
-
export declare const MetafieldFragment:
|
|
25
|
+
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";
|
|
@@ -8,5 +8,5 @@ export interface StarRatingProps {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function StarRating<TTag extends ElementType>(props: Props<TTag> & StarRatingProps): JSX.Element;
|
|
10
10
|
export declare function Star({ percentFilled }: {
|
|
11
|
-
percentFilled:
|
|
11
|
+
percentFilled: number;
|
|
12
12
|
}): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Metafield, MetafieldFragment } from './Metafield.client';
|
|
2
|
-
export { MetafieldType } from './types';
|
|
3
|
-
export { MetafieldFragmentFragment } from './MetafieldFragment';
|
|
2
|
+
export type { MetafieldType } from './types';
|
|
3
|
+
export type { MetafieldFragmentFragment } from './MetafieldFragment';
|
|
@@ -134,5 +134,5 @@ export declare function Model3D<TTag extends ElementType>(props: Props<TTag, Pro
|
|
|
134
134
|
export declare namespace Model3D {
|
|
135
135
|
var Fragment: string;
|
|
136
136
|
}
|
|
137
|
-
export declare const Model3DFragment
|
|
137
|
+
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";
|
|
138
138
|
export {};
|
|
@@ -19,4 +19,4 @@ export declare function Money<TTag extends ElementType>(props: Props<TTag> & Mon
|
|
|
19
19
|
export declare namespace Money {
|
|
20
20
|
var Fragment: string;
|
|
21
21
|
}
|
|
22
|
-
export declare const MoneyFragment
|
|
22
|
+
export declare const MoneyFragment = "fragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n}\n";
|
|
@@ -15,4 +15,4 @@ export declare function ProductProvider({ children, product, initialVariantId, }
|
|
|
15
15
|
export declare namespace ProductProvider {
|
|
16
16
|
var Fragment: string;
|
|
17
17
|
}
|
|
18
|
-
export declare const ProductProviderFragment:
|
|
18
|
+
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}";
|
|
@@ -23,4 +23,4 @@ export declare function UnitPrice<TTag extends ElementType>(props: Props<TTag> &
|
|
|
23
23
|
export declare namespace UnitPrice {
|
|
24
24
|
var Fragment: string;
|
|
25
25
|
}
|
|
26
|
-
export declare const UnitPriceFragment
|
|
26
|
+
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}";
|
|
@@ -19,4 +19,4 @@ export declare function Video<TTag extends React.ElementType = 'video'>(props: P
|
|
|
19
19
|
export declare namespace Video {
|
|
20
20
|
var Fragment: string;
|
|
21
21
|
}
|
|
22
|
-
export declare const VideoFragment
|
|
22
|
+
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";
|
|
@@ -15,8 +15,8 @@ export type { Model3DProps } from './Model3D';
|
|
|
15
15
|
export { Model3D } from './Model3D';
|
|
16
16
|
export type { MoneyProps } from './Money';
|
|
17
17
|
export { Money } from './Money';
|
|
18
|
-
export { Metafield
|
|
19
|
-
export type { MetafieldType } from './Metafield';
|
|
18
|
+
export { Metafield } from './Metafield';
|
|
19
|
+
export type { MetafieldType, MetafieldFragmentFragment } from './Metafield';
|
|
20
20
|
export { CartLineProvider, useCartLine } from './CartLineProvider';
|
|
21
21
|
export { CartLineImage } from './CartLineImage';
|
|
22
22
|
export { CartLinePrice } from './CartLinePrice';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ServerStateProvider, ServerStateContext,
|
|
1
|
+
export { ServerStateProvider, ServerStateContext, } from './ServerStateProvider.client';
|
|
2
|
+
export type { ServerState, ServerStateContextValue, } from './ServerStateProvider.client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `useServerState` hook allows you to [manage server state](/
|
|
2
|
+
* The `useServerState` hook allows you to [manage server state](/custom-storefronts/hydrogen/framework/server-state) when using Hydrogen as a React Server Component framework.
|
|
3
3
|
*
|
|
4
4
|
* ## Return value
|
|
5
5
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { ServerStateContext } from '../ServerStateProvider';
|
|
3
3
|
/**
|
|
4
|
-
* The `useServerState` hook allows you to [manage server state](/
|
|
4
|
+
* The `useServerState` hook allows you to [manage server state](/custom-storefronts/hydrogen/framework/server-state) when using Hydrogen as a React Server Component framework.
|
|
5
5
|
*
|
|
6
6
|
* ## Return value
|
|
7
7
|
*
|
|
@@ -12,7 +12,6 @@ export function wrapInClientMarker(meta) {
|
|
|
12
12
|
// Use object syntax here to make sure the function name
|
|
13
13
|
// comes from the meta params for better error stacks.
|
|
14
14
|
const wrappedComponent = {
|
|
15
|
-
// eslint-disable-next-line react/display-name
|
|
16
15
|
[name]: (props) => React.createElement(ClientMarker, { ...{ props, meta } }),
|
|
17
16
|
}[name];
|
|
18
17
|
// Relay component properties such as `Image.Fragment`
|
|
@@ -2,7 +2,6 @@ import { normalizePath } from 'vite';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { proxyClientComponent } from '../server-components';
|
|
4
4
|
import { resolve } from './resolver';
|
|
5
|
-
import { promises as fs } from 'fs';
|
|
6
5
|
export default () => {
|
|
7
6
|
let config;
|
|
8
7
|
return {
|
|
@@ -42,15 +41,6 @@ export default () => {
|
|
|
42
41
|
if (/\.client\.[jt]sx?$/.test(id)) {
|
|
43
42
|
return proxyClientComponent({ id });
|
|
44
43
|
}
|
|
45
|
-
// Temporary fix for sourcemap warnings in client components. This can be fixed in @vitejs/react-plugin.
|
|
46
|
-
// `react-ssr-prepass` sourcemap seems to be broken and crashes in workers/Jest.
|
|
47
|
-
if (id.endsWith('?no-proxy') ||
|
|
48
|
-
id.includes('dist/react-ssr-prepass.es.js')) {
|
|
49
|
-
return {
|
|
50
|
-
code: await fs.readFile(id.split('?')[0], 'utf-8'),
|
|
51
|
-
map: { mappings: '' },
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
44
|
return null;
|
|
55
45
|
},
|
|
56
46
|
transform(code, id) {
|
|
@@ -2,9 +2,8 @@ import { init, parse } from 'es-module-lexer';
|
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import { transformWithEsbuild } from 'vite';
|
|
4
4
|
import MagicString from 'magic-string';
|
|
5
|
+
const DEFAULT_EXPORT = 'default';
|
|
5
6
|
export async function proxyClientComponent({ id, src, }) {
|
|
6
|
-
var _a;
|
|
7
|
-
const defaultComponentName = (_a = id.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
|
|
8
7
|
// Modify the import ID to avoid infinite wraps
|
|
9
8
|
const importFrom = `${id}?no-proxy`;
|
|
10
9
|
await init;
|
|
@@ -13,56 +12,35 @@ export async function proxyClientComponent({ id, src, }) {
|
|
|
13
12
|
}
|
|
14
13
|
const { code } = await transformWithEsbuild(src, id);
|
|
15
14
|
const [, exportStatements] = parse(code);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
acc.components.push(i);
|
|
26
|
-
}
|
|
15
|
+
// Classify exports in components to wrap vs. everything else (e.g. GQL Fragments)
|
|
16
|
+
const otherExports = [];
|
|
17
|
+
const componentExports = [];
|
|
18
|
+
for (const key of exportStatements) {
|
|
19
|
+
if (key !== DEFAULT_EXPORT &&
|
|
20
|
+
/^use[A-Z]|Fragment$|Context$|^[A-Z_]+$/.test(key)) {
|
|
21
|
+
otherExports.push(key);
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!hasDefaultExport && namedImports.components.length === 0) {
|
|
31
|
-
return `export * from '${importFrom}';\n`;
|
|
32
|
-
}
|
|
33
|
-
const s = new MagicString(`import {wrapInClientMarker} from '@shopify/hydrogen/marker';`);
|
|
34
|
-
s.append('\nimport ');
|
|
35
|
-
if (hasDefaultExport) {
|
|
36
|
-
s.append(defaultComponentName);
|
|
37
|
-
if (namedImports.components.length > 0) {
|
|
38
|
-
s.append(', ');
|
|
23
|
+
else {
|
|
24
|
+
componentExports.push(key);
|
|
39
25
|
}
|
|
40
26
|
}
|
|
41
|
-
if (
|
|
42
|
-
|
|
27
|
+
if (componentExports.length === 0) {
|
|
28
|
+
return `export * from '${importFrom}';\n`;
|
|
43
29
|
}
|
|
44
|
-
s
|
|
30
|
+
const s = new MagicString(`import {wrapInClientMarker} from '@shopify/hydrogen/marker';\n` +
|
|
31
|
+
`import * as allImports from '${importFrom}';\n\n`);
|
|
45
32
|
// Re-export other stuff directly without wrapping
|
|
46
|
-
if (
|
|
47
|
-
s.append(`export {${
|
|
33
|
+
if (otherExports.length > 0) {
|
|
34
|
+
s.append(`export {${otherExports.join(', ')}} from '${importFrom}';\n`);
|
|
48
35
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
componentName: name,
|
|
59
|
-
isDefault: false,
|
|
60
|
-
})));
|
|
36
|
+
// Wrap components in Client Marker
|
|
37
|
+
componentExports.forEach((key) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const isDefault = key === DEFAULT_EXPORT;
|
|
40
|
+
const componentName = isDefault
|
|
41
|
+
? (_a = id.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift()
|
|
42
|
+
: key;
|
|
43
|
+
s.append(`export ${isDefault ? DEFAULT_EXPORT : `const ${componentName} =`} wrapInClientMarker({ name: '${componentName}', id: '${id}', component: allImports['${key}'], named: ${!isDefault} });\n`);
|
|
44
|
+
});
|
|
61
45
|
return s.toString();
|
|
62
46
|
}
|
|
63
|
-
function generateComponentExport({ id, isDefault, componentName, }) {
|
|
64
|
-
const component = isDefault
|
|
65
|
-
? componentName
|
|
66
|
-
: `namedImports['${componentName}']`;
|
|
67
|
-
return `export ${isDefault ? 'default' : `const ${componentName} =`} wrapInClientMarker({ name: '${componentName}', id: '${id}', component: ${component}, named: ${!isDefault} });\n`;
|
|
68
|
-
}
|
|
@@ -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}";
|
|
@@ -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
|
};
|
|
@@ -11,8 +11,10 @@ export interface UseShopQueryResponse<T> {
|
|
|
11
11
|
* \> It must be a descendent of a `ShopifyProvider` component.
|
|
12
12
|
*/
|
|
13
13
|
export declare function useShopQuery<T>({ query, variables, cache, }: {
|
|
14
|
-
/** A string of the GraphQL query.
|
|
15
|
-
|
|
14
|
+
/** A string of the GraphQL query.
|
|
15
|
+
* If no query is provided, useShopQuery will make no calls to the Storefront API.
|
|
16
|
+
*/
|
|
17
|
+
query?: ASTNode | string;
|
|
16
18
|
/** An object of the variables for the GraphQL query. */
|
|
17
19
|
variables?: Record<string, any>;
|
|
18
20
|
/** An object containing cache-control options for the sub-request. */
|
|
@@ -12,7 +12,7 @@ export function useShopQuery({ query, variables = {}, cache = {}, }) {
|
|
|
12
12
|
throw new Error('Shopify Storefront API requests should only be made from the server.');
|
|
13
13
|
}
|
|
14
14
|
const { storeDomain, storefrontToken, graphqlApiVersion } = useShop();
|
|
15
|
-
const body = graphqlRequestBody(query, variables);
|
|
15
|
+
const body = query ? graphqlRequestBody(query, variables) : "";
|
|
16
16
|
const url = `https://${storeDomain}/api/${graphqlApiVersion}/graphql.json`;
|
|
17
17
|
const request = new Request(url, {
|
|
18
18
|
method: 'POST',
|
|
@@ -22,7 +22,10 @@ export function useShopQuery({ query, variables = {}, cache = {}, }) {
|
|
|
22
22
|
},
|
|
23
23
|
body,
|
|
24
24
|
});
|
|
25
|
-
const { data } = useQuery([storeDomain, graphqlApiVersion, body],
|
|
25
|
+
const { data } = useQuery([storeDomain, graphqlApiVersion, body], query
|
|
26
|
+
? fetchBuilder(request)
|
|
27
|
+
// If no query, avoid calling SFAPI & return nothing
|
|
28
|
+
: async () => ({ data: undefined, errors: undefined }), { cache });
|
|
26
29
|
/**
|
|
27
30
|
* GraphQL errors get printed to the console but ultimately
|
|
28
31
|
* get returned to the consumer.
|
package/dist/esnext/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.7.
|
|
1
|
+
export declare const LIB_VERSION = "0.7.1";
|
package/dist/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '0.7.
|
|
1
|
+
export const LIB_VERSION = '0.7.1';
|
|
@@ -34,7 +34,6 @@ function wrapInClientMarker(meta) {
|
|
|
34
34
|
// Use object syntax here to make sure the function name
|
|
35
35
|
// comes from the meta params for better error stacks.
|
|
36
36
|
const wrappedComponent = {
|
|
37
|
-
// eslint-disable-next-line react/display-name
|
|
38
37
|
[name]: (props) => react_1.default.createElement(ClientMarker, { ...{ props, meta } }),
|
|
39
38
|
}[name];
|
|
40
39
|
// Relay component properties such as `Image.Fragment`
|
|
@@ -48,7 +47,7 @@ function wrapInClientMarker(meta) {
|
|
|
48
47
|
}
|
|
49
48
|
exports.wrapInClientMarker = wrapInClientMarker;
|
|
50
49
|
function ClientMarker({ props: allProps, meta: { name, id, component: Component, named }, }) {
|
|
51
|
-
const isHydrating = react_1.useContext(HydrationContext_server_1.HydrationContext);
|
|
50
|
+
const isHydrating = (0, react_1.useContext)(HydrationContext_server_1.HydrationContext);
|
|
52
51
|
if (!isHydrating)
|
|
53
52
|
return react_1.default.createElement(Component, { ...allProps });
|
|
54
53
|
let { children, ...props } = allProps;
|
|
@@ -58,7 +57,7 @@ function ClientMarker({ props: allProps, meta: { name, id, component: Component,
|
|
|
58
57
|
* serialize props to JSON below, and React element Functions
|
|
59
58
|
* cannot be serialized.
|
|
60
59
|
*/
|
|
61
|
-
props = react_utils_1.renderReactProps(props);
|
|
60
|
+
props = (0, react_utils_1.renderReactProps)(props);
|
|
62
61
|
/**
|
|
63
62
|
* Components ending in *Provider are special components to
|
|
64
63
|
* Hydrogen's RSC implementation. They are rendered during
|
|
@@ -31,7 +31,7 @@ exports.useServerResponse = useServerResponse;
|
|
|
31
31
|
* promise events to the Suspense boundary until the content has loaded.
|
|
32
32
|
*/
|
|
33
33
|
function createFromFetch(fetchPromise) {
|
|
34
|
-
return utilities_1.wrapPromise(fetchPromise
|
|
34
|
+
return (0, utilities_1.wrapPromise)(fetchPromise
|
|
35
35
|
.then((response) => {
|
|
36
36
|
if (!response.ok) {
|
|
37
37
|
throw new Error(`Hydration request failed: ${response.statusText}`);
|
|
@@ -68,7 +68,7 @@ async function convertHydrationResponseToReactComponents(response) {
|
|
|
68
68
|
return null;
|
|
69
69
|
// Assume it's an array of tuples, defined in the component as a fragment.
|
|
70
70
|
if (!isReactTuple(item)) {
|
|
71
|
-
return react_1.createElement(react_1.Fragment, {
|
|
71
|
+
return (0, react_1.createElement)(react_1.Fragment, {
|
|
72
72
|
children: item.map(wireSyntaxToReactElement),
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -105,7 +105,7 @@ async function convertHydrationResponseToReactComponents(response) {
|
|
|
105
105
|
const mod = modules[type.replace('@', 'M')];
|
|
106
106
|
type = module.named ? mod[module.name] : mod.default;
|
|
107
107
|
}
|
|
108
|
-
return react_1.createElement(type, { ...allProps, key });
|
|
108
|
+
return (0, react_1.createElement)(type, { ...allProps, key });
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* The manifest is listed as `J0` for some reason. This is how React does it.
|
|
@@ -133,7 +133,7 @@ async function eagerLoadModules(manifest) {
|
|
|
133
133
|
if (moduleCache.has(module.id)) {
|
|
134
134
|
return moduleCache.get(module.id);
|
|
135
135
|
}
|
|
136
|
-
const mod = await client_imports_1.default(module.id);
|
|
136
|
+
const mod = await (0, client_imports_1.default)(module.id);
|
|
137
137
|
moduleCache.set(module.id, mod);
|
|
138
138
|
return mod;
|
|
139
139
|
})
|
|
@@ -31,7 +31,7 @@ class ServerComponentResponse extends Response {
|
|
|
31
31
|
...DEFAULT_CACHE_OPTIONS,
|
|
32
32
|
...((_a = this.cacheOptions) !== null && _a !== void 0 ? _a : {}),
|
|
33
33
|
};
|
|
34
|
-
return cache_1.generateCacheControlHeader(options);
|
|
34
|
+
return (0, cache_1.generateCacheControlHeader)(options);
|
|
35
35
|
}
|
|
36
36
|
writeHead({ status, statusText, headers, } = {}) {
|
|
37
37
|
if (status || statusText) {
|
|
@@ -53,7 +53,7 @@ class ServerComponentResponse extends Response {
|
|
|
53
53
|
send(body) {
|
|
54
54
|
if (typeof body === 'object' &&
|
|
55
55
|
body.$$typeof === Symbol.for('react.element')) {
|
|
56
|
-
this.customBody = server_1.renderToString(body);
|
|
56
|
+
this.customBody = (0, server_1.renderToString)(body);
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
this.customBody = body;
|
|
@@ -45,7 +45,7 @@ function renderReactProp(prop) {
|
|
|
45
45
|
* set expectations as thus when passing components as
|
|
46
46
|
* props within Server Components.
|
|
47
47
|
*/
|
|
48
|
-
return parseReactFromString(server_1.renderToString(prop));
|
|
48
|
+
return parseReactFromString((0, server_1.renderToString)(prop));
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
return {
|
|
@@ -57,8 +57,8 @@ function renderReactProp(prop) {
|
|
|
57
57
|
return prop;
|
|
58
58
|
}
|
|
59
59
|
function parseReactFromString(input, options = {}) {
|
|
60
|
-
return dom_to_react_1.default(
|
|
60
|
+
return (0, dom_to_react_1.default)(
|
|
61
61
|
// @ts-ignore
|
|
62
|
-
html_dom_parser_1.default(input, { lowerCaseTags: false, lowerCaseAttributeNames: false }), options);
|
|
62
|
+
(0, html_dom_parser_1.default)(input, { lowerCaseTags: false, lowerCaseAttributeNames: false }), options);
|
|
63
63
|
}
|
|
64
64
|
exports.parseReactFromString = parseReactFromString;
|
|
@@ -8,7 +8,7 @@ const react_utils_1 = require("./react-utils");
|
|
|
8
8
|
*/
|
|
9
9
|
function generateWireSyntaxFromRenderedHtml(html) {
|
|
10
10
|
const clientComponents = new ClientComponents_server_1.ClientComponents();
|
|
11
|
-
const wireModel = react_utils_1.parseReactFromString(html, {
|
|
11
|
+
const wireModel = (0, react_utils_1.parseReactFromString)(html, {
|
|
12
12
|
library: {
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
createElement: convertToWireSyntax,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HydrationWriter = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
4
5
|
/**
|
|
5
6
|
* HydrationWriter is an implementation of `WritableStream` which
|
|
6
7
|
* keeps track of chunks emitted from React's `pipeToNodeWritable`.
|
|
@@ -45,7 +45,7 @@ function getKeyUrl(key) {
|
|
|
45
45
|
* as the response itself so it can be checked for staleness.
|
|
46
46
|
*/
|
|
47
47
|
async function getItemFromCache(key) {
|
|
48
|
-
const cache = runtime_1.getCache();
|
|
48
|
+
const cache = (0, runtime_1.getCache)();
|
|
49
49
|
if (!cache) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -61,7 +61,7 @@ exports.getItemFromCache = getItemFromCache;
|
|
|
61
61
|
* Put an item into the cache.
|
|
62
62
|
*/
|
|
63
63
|
async function setItemInCache(key, value, userCacheOptions) {
|
|
64
|
-
const cache = runtime_1.getCache();
|
|
64
|
+
const cache = (0, runtime_1.getCache)();
|
|
65
65
|
if (!cache) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
@@ -83,7 +83,7 @@ async function setItemInCache(key, value, userCacheOptions) {
|
|
|
83
83
|
}
|
|
84
84
|
exports.setItemInCache = setItemInCache;
|
|
85
85
|
async function deleteItemFromCache(key) {
|
|
86
|
-
const cache = runtime_1.getCache();
|
|
86
|
+
const cache = (0, runtime_1.getCache)();
|
|
87
87
|
if (!cache)
|
|
88
88
|
return;
|
|
89
89
|
const url = getKeyUrl(hashKey(key));
|
|
@@ -74,7 +74,7 @@ function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypoint, de
|
|
|
74
74
|
* polyfill has loaded above.
|
|
75
75
|
*/
|
|
76
76
|
const { ServerComponentRequest } = await Promise.resolve().then(() => __importStar(require('./Hydration/ServerComponentRequest.server')));
|
|
77
|
-
const eventResponse = await handle_event_1.default(
|
|
77
|
+
const eventResponse = await (0, handle_event_1.default)(
|
|
78
78
|
/**
|
|
79
79
|
* Mimic a `FetchEvent`
|
|
80
80
|
*/
|
|
@@ -143,5 +143,5 @@ async function respondWithGraphiql(response, shopifyConfig) {
|
|
|
143
143
|
}
|
|
144
144
|
const { storeDomain, storefrontToken, graphqlApiVersion } = shopifyConfig;
|
|
145
145
|
response.setHeader('Content-Type', 'text/html');
|
|
146
|
-
response.end(graphiql_1.graphiqlHtml(storeDomain === null || storeDomain === void 0 ? void 0 : storeDomain.replace(/^https?:\/\//, ''), storefrontToken, graphqlApiVersion));
|
|
146
|
+
response.end((0, graphiql_1.graphiqlHtml)(storeDomain === null || storeDomain === void 0 ? void 0 : storeDomain.replace(/^https?:\/\//, ''), storefrontToken, graphqlApiVersion));
|
|
147
147
|
}
|
|
@@ -10,10 +10,10 @@ const vite_plugin_inspect_1 = __importDefault(require("vite-plugin-inspect"));
|
|
|
10
10
|
const plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
|
|
11
11
|
exports.default = (shopifyConfig, pluginOptions) => {
|
|
12
12
|
return [
|
|
13
|
-
process.env.VITE_INSPECT && vite_plugin_inspect_1.default(),
|
|
14
|
-
vite_plugin_hydrogen_config_1.default(),
|
|
15
|
-
vite_plugin_hydrogen_middleware_1.default(shopifyConfig, pluginOptions),
|
|
16
|
-
vite_plugin_react_server_components_shim_1.default(),
|
|
17
|
-
plugin_react_1.default(),
|
|
13
|
+
process.env.VITE_INSPECT && (0, vite_plugin_inspect_1.default)(),
|
|
14
|
+
(0, vite_plugin_hydrogen_config_1.default)(),
|
|
15
|
+
(0, vite_plugin_hydrogen_middleware_1.default)(shopifyConfig, pluginOptions),
|
|
16
|
+
(0, vite_plugin_react_server_components_shim_1.default)(),
|
|
17
|
+
(0, plugin_react_1.default)(),
|
|
18
18
|
];
|
|
19
19
|
};
|
|
@@ -24,11 +24,11 @@ exports.default = (shopifyConfig, pluginOptions) => {
|
|
|
24
24
|
}
|
|
25
25
|
// The default vite middleware rewrites the URL `/graphqil` to `/index.html`
|
|
26
26
|
// By running this middleware first, we avoid that.
|
|
27
|
-
server.middlewares.use(middleware_1.graphiqlMiddleware({
|
|
27
|
+
server.middlewares.use((0, middleware_1.graphiqlMiddleware)({
|
|
28
28
|
shopifyConfig,
|
|
29
29
|
dev: true,
|
|
30
30
|
}));
|
|
31
|
-
return () => server.middlewares.use(middleware_1.hydrogenMiddleware({
|
|
31
|
+
return () => server.middlewares.use((0, middleware_1.hydrogenMiddleware)({
|
|
32
32
|
dev: true,
|
|
33
33
|
shopifyConfig,
|
|
34
34
|
indexTemplate: getIndexTemplate,
|
|
@@ -7,7 +7,6 @@ const vite_1 = require("vite");
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const server_components_1 = require("../server-components");
|
|
9
9
|
const resolver_1 = require("./resolver");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
10
|
exports.default = () => {
|
|
12
11
|
let config;
|
|
13
12
|
return {
|
|
@@ -45,16 +44,7 @@ exports.default = () => {
|
|
|
45
44
|
return null;
|
|
46
45
|
// Wrapped components won't match this becase they end in ?no-proxy
|
|
47
46
|
if (/\.client\.[jt]sx?$/.test(id)) {
|
|
48
|
-
return server_components_1.proxyClientComponent({ id });
|
|
49
|
-
}
|
|
50
|
-
// Temporary fix for sourcemap warnings in client components. This can be fixed in @vitejs/react-plugin.
|
|
51
|
-
// `react-ssr-prepass` sourcemap seems to be broken and crashes in workers/Jest.
|
|
52
|
-
if (id.endsWith('?no-proxy') ||
|
|
53
|
-
id.includes('dist/react-ssr-prepass.es.js')) {
|
|
54
|
-
return {
|
|
55
|
-
code: await fs_1.promises.readFile(id.split('?')[0], 'utf-8'),
|
|
56
|
-
map: { mappings: '' },
|
|
57
|
-
};
|
|
47
|
+
return (0, server_components_1.proxyClientComponent)({ id });
|
|
58
48
|
}
|
|
59
49
|
return null;
|
|
60
50
|
},
|
|
@@ -71,19 +61,19 @@ exports.default = () => {
|
|
|
71
61
|
*/
|
|
72
62
|
if (id.includes('/Hydration/client-imports')) {
|
|
73
63
|
// eslint-disable-next-line node/no-missing-require
|
|
74
|
-
const hydrogenPath = path_1.default.dirname(resolver_1.resolve('@shopify/hydrogen'));
|
|
64
|
+
const hydrogenPath = path_1.default.dirname((0, resolver_1.resolve)('@shopify/hydrogen'));
|
|
75
65
|
const importerPath = path_1.default.join(hydrogenPath, 'framework', 'Hydration');
|
|
76
|
-
const importerToRootPath = vite_1.normalizePath(path_1.default.relative(importerPath, config.root));
|
|
66
|
+
const importerToRootPath = (0, vite_1.normalizePath)(path_1.default.relative(importerPath, config.root));
|
|
77
67
|
const [importerToRootNested] = importerToRootPath.match(/(\.\.\/)+(\.\.)?/) || [];
|
|
78
68
|
const userPrefix = path_1.default.normalize(path_1.default.join(importerPath, importerToRootNested.replace(/\/?$/, path_1.default.sep)));
|
|
79
69
|
const userGlob = path_1.default.join(importerToRootPath, 'src', '**/*.client.[jt]sx');
|
|
80
70
|
const libPrefix = hydrogenPath + path_1.default.sep;
|
|
81
71
|
const libGlob = path_1.default.join(path_1.default.relative(importerPath, hydrogenPath), 'components', '**/*.client.js');
|
|
82
72
|
return code
|
|
83
|
-
.replace('__USER_COMPONENTS_PREFIX__', vite_1.normalizePath(userPrefix))
|
|
84
|
-
.replace('__USER_COMPONENTS_GLOB__', vite_1.normalizePath(userGlob))
|
|
85
|
-
.replace('__LIB_COMPONENTS_PREFIX__', vite_1.normalizePath(libPrefix))
|
|
86
|
-
.replace('__LIB_COMPONENTS_GLOB__', vite_1.normalizePath(libGlob));
|
|
73
|
+
.replace('__USER_COMPONENTS_PREFIX__', (0, vite_1.normalizePath)(userPrefix))
|
|
74
|
+
.replace('__USER_COMPONENTS_GLOB__', (0, vite_1.normalizePath)(userGlob))
|
|
75
|
+
.replace('__LIB_COMPONENTS_PREFIX__', (0, vite_1.normalizePath)(libPrefix))
|
|
76
|
+
.replace('__LIB_COMPONENTS_GLOB__', (0, vite_1.normalizePath)(libGlob));
|
|
87
77
|
}
|
|
88
78
|
},
|
|
89
79
|
};
|
|
@@ -8,68 +8,46 @@ const es_module_lexer_1 = require("es-module-lexer");
|
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const vite_1 = require("vite");
|
|
10
10
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
11
|
+
const DEFAULT_EXPORT = 'default';
|
|
11
12
|
async function proxyClientComponent({ id, src, }) {
|
|
12
|
-
var _a;
|
|
13
|
-
const defaultComponentName = (_a = id.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
|
|
14
13
|
// Modify the import ID to avoid infinite wraps
|
|
15
14
|
const importFrom = `${id}?no-proxy`;
|
|
16
15
|
await es_module_lexer_1.init;
|
|
17
16
|
if (!src) {
|
|
18
17
|
src = await fs_1.promises.readFile(id, 'utf-8');
|
|
19
18
|
}
|
|
20
|
-
const { code } = await vite_1.transformWithEsbuild(src, id);
|
|
21
|
-
const [, exportStatements] = es_module_lexer_1.parse(code);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
acc.components.push(i);
|
|
32
|
-
}
|
|
19
|
+
const { code } = await (0, vite_1.transformWithEsbuild)(src, id);
|
|
20
|
+
const [, exportStatements] = (0, es_module_lexer_1.parse)(code);
|
|
21
|
+
// Classify exports in components to wrap vs. everything else (e.g. GQL Fragments)
|
|
22
|
+
const otherExports = [];
|
|
23
|
+
const componentExports = [];
|
|
24
|
+
for (const key of exportStatements) {
|
|
25
|
+
if (key !== DEFAULT_EXPORT &&
|
|
26
|
+
/^use[A-Z]|Fragment$|Context$|^[A-Z_]+$/.test(key)) {
|
|
27
|
+
otherExports.push(key);
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!hasDefaultExport && namedImports.components.length === 0) {
|
|
37
|
-
return `export * from '${importFrom}';\n`;
|
|
38
|
-
}
|
|
39
|
-
const s = new magic_string_1.default(`import {wrapInClientMarker} from '@shopify/hydrogen/marker';`);
|
|
40
|
-
s.append('\nimport ');
|
|
41
|
-
if (hasDefaultExport) {
|
|
42
|
-
s.append(defaultComponentName);
|
|
43
|
-
if (namedImports.components.length > 0) {
|
|
44
|
-
s.append(', ');
|
|
29
|
+
else {
|
|
30
|
+
componentExports.push(key);
|
|
45
31
|
}
|
|
46
32
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
33
|
+
if (componentExports.length === 0) {
|
|
34
|
+
return `export * from '${importFrom}';\n`;
|
|
49
35
|
}
|
|
50
|
-
s.
|
|
36
|
+
const s = new magic_string_1.default(`import {wrapInClientMarker} from '@shopify/hydrogen/marker';\n` +
|
|
37
|
+
`import * as allImports from '${importFrom}';\n\n`);
|
|
51
38
|
// Re-export other stuff directly without wrapping
|
|
52
|
-
if (
|
|
53
|
-
s.append(`export {${
|
|
39
|
+
if (otherExports.length > 0) {
|
|
40
|
+
s.append(`export {${otherExports.join(', ')}} from '${importFrom}';\n`);
|
|
54
41
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
componentName: name,
|
|
65
|
-
isDefault: false,
|
|
66
|
-
})));
|
|
42
|
+
// Wrap components in Client Marker
|
|
43
|
+
componentExports.forEach((key) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const isDefault = key === DEFAULT_EXPORT;
|
|
46
|
+
const componentName = isDefault
|
|
47
|
+
? (_a = id.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift()
|
|
48
|
+
: key;
|
|
49
|
+
s.append(`export ${isDefault ? DEFAULT_EXPORT : `const ${componentName} =`} wrapInClientMarker({ name: '${componentName}', id: '${id}', component: allImports['${key}'], named: ${!isDefault} });\n`);
|
|
50
|
+
});
|
|
67
51
|
return s.toString();
|
|
68
52
|
}
|
|
69
53
|
exports.proxyClientComponent = proxyClientComponent;
|
|
70
|
-
function generateComponentExport({ id, isDefault, componentName, }) {
|
|
71
|
-
const component = isDefault
|
|
72
|
-
? componentName
|
|
73
|
-
: `namedImports['${componentName}']`;
|
|
74
|
-
return `export ${isDefault ? 'default' : `const ${componentName} =`} wrapInClientMarker({ name: '${componentName}', id: '${id}', component: ${component}, named: ${!isDefault} });\n`;
|
|
75
|
-
}
|
|
@@ -9,9 +9,9 @@ async function handleEvent(event, { request, entrypoint, indexTemplate, assetHan
|
|
|
9
9
|
/**
|
|
10
10
|
* Inject the cache & context into the module loader so we can pull it out for subrequests.
|
|
11
11
|
*/
|
|
12
|
-
runtime_1.setCache(cache);
|
|
13
|
-
runtime_1.setContext(context);
|
|
14
|
-
config_1.setConfig({ dev });
|
|
12
|
+
(0, runtime_1.setCache)(cache);
|
|
13
|
+
(0, runtime_1.setContext)(context);
|
|
14
|
+
(0, config_1.setConfig)({ dev });
|
|
15
15
|
const isReactHydrationRequest = url.pathname === '/react';
|
|
16
16
|
const template = typeof indexTemplate === 'function'
|
|
17
17
|
? await indexTemplate(url.toString())
|
|
@@ -56,7 +56,7 @@ async function handleEvent(event, { request, entrypoint, indexTemplate, assetHan
|
|
|
56
56
|
* TODO: Also add `Vary` headers for `accept-language` and any other keys
|
|
57
57
|
* we want to shard our full-page cache for all Hydrogen storefronts.
|
|
58
58
|
*/
|
|
59
|
-
headers.set(cache_1.getCacheControlHeader({ dev }), componentResponse.cacheControlHeader);
|
|
59
|
+
headers.set((0, cache_1.getCacheControlHeader)({ dev }), componentResponse.cacheControlHeader);
|
|
60
60
|
if (componentResponse.customBody) {
|
|
61
61
|
const { status, customStatus } = componentResponse;
|
|
62
62
|
return new Response(await componentResponse.customBody, {
|
|
@@ -47,7 +47,7 @@ function fetchBuilder(request) {
|
|
|
47
47
|
}
|
|
48
48
|
exports.fetchBuilder = fetchBuilder;
|
|
49
49
|
function graphqlRequestBody(query, variables) {
|
|
50
|
-
const queryString = typeof query === 'string' ? query : graphql_1.print(query);
|
|
50
|
+
const queryString = typeof query === 'string' ? query : (0, graphql_1.print)(query);
|
|
51
51
|
return JSON.stringify({
|
|
52
52
|
query: queryString,
|
|
53
53
|
variables,
|
|
@@ -17,7 +17,7 @@ function addParametersToEmbeddedVideoUrl(url, parameters) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.addParametersToEmbeddedVideoUrl = addParametersToEmbeddedVideoUrl;
|
|
19
19
|
function useEmbeddedVideoUrl(url, parameters) {
|
|
20
|
-
return react_1.useMemo(() => {
|
|
20
|
+
return (0, react_1.useMemo)(() => {
|
|
21
21
|
if (!parameters) {
|
|
22
22
|
return url;
|
|
23
23
|
}
|
package/dist/node/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.7.
|
|
1
|
+
export declare const LIB_VERSION = "0.7.1";
|
package/dist/node/version.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.7.
|
|
7
|
+
"version": "0.7.1",
|
|
8
8
|
"description": "Modern custom Shopify storefronts",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"main": "dist/esnext/index.js",
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"vite": "^2.6.14"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@vitejs/plugin-react": "^1.0
|
|
86
|
+
"@vitejs/plugin-react": "^1.1.0",
|
|
87
87
|
"connect": "^3.7.0",
|
|
88
88
|
"es-module-lexer": "^0.9.0",
|
|
89
89
|
"fast-glob": "^3.2.5",
|
|
90
|
-
"graphql": "^
|
|
90
|
+
"graphql": "^16.0.1",
|
|
91
91
|
"html-dom-parser": "^1.0.1",
|
|
92
92
|
"html-react-parser": "^1.2.6",
|
|
93
93
|
"isomorphic-dompurify": "^0.13.0",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"react-ssr-prepass": "^1.4.0",
|
|
100
100
|
"vite-plugin-inspect": "^0.3.6"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "34baabab8643e8f0754844760de8a481c9d67971"
|
|
103
103
|
}
|