@shopify/hydrogen 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +1 -1
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +3 -3
- package/dist/esnext/components/Metafield/Metafield.client.js +8 -0
- package/dist/esnext/components/Metafield/MetafieldFragment.d.ts +16 -1
- package/dist/esnext/components/Model3D/Model3D.client.d.ts +2 -0
- package/dist/esnext/components/Model3D/Model3D.client.js +1 -1
- package/dist/esnext/components/ProductProvider/context.d.ts +2 -2
- package/dist/esnext/components/ProductProvider/types.d.ts +2 -2
- package/dist/esnext/components/SelectedVariantAddToCartButton/SelectedVariantAddToCartButton.client.d.ts +1 -1
- package/dist/esnext/components/SelectedVariantAddToCartButton/SelectedVariantAddToCartButton.client.js +1 -1
- package/dist/esnext/entry-server.js +43 -19
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.client.d.ts +19 -11
- package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.client.js +21 -20
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +1 -1
- package/dist/esnext/foundation/ShopifyProvider/ShopifyServerProvider.server.js +1 -1
- package/dist/esnext/{hooks → foundation}/useQuery/QueryProvider.d.ts +0 -0
- package/dist/esnext/{hooks → foundation}/useQuery/QueryProvider.js +0 -0
- package/dist/esnext/{hooks → foundation}/useQuery/hooks.d.ts +0 -0
- package/dist/esnext/{hooks → foundation}/useQuery/hooks.js +13 -3
- package/dist/esnext/{hooks → foundation}/useQuery/index.d.ts +0 -0
- package/dist/esnext/{hooks → foundation}/useQuery/index.js +0 -0
- package/dist/esnext/foundation/useServerState/use-server-state.d.ts +1 -1
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +10 -0
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +13 -0
- package/dist/esnext/framework/middleware.d.ts +5 -1
- package/dist/esnext/framework/middleware.js +10 -5
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +4 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +7 -1
- package/dist/esnext/framework/plugins/vite-plugin-react-server-components-shim.js +11 -1
- package/dist/esnext/graphql/graphql-constants.d.ts +51 -14
- package/dist/esnext/graphql/graphql-constants.js +89 -15
- package/dist/esnext/handle-event.js +8 -4
- package/dist/esnext/hooks/index.d.ts +1 -1
- package/dist/esnext/hooks/index.js +1 -1
- package/dist/esnext/hooks/useMoney/hooks.js +2 -16
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -3
- package/dist/esnext/hooks/useProductOptions/types.d.ts +2 -3
- package/dist/esnext/hooks/useShopQuery/hooks.js +1 -1
- package/dist/esnext/types.d.ts +19 -3
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +0 -7
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +0 -7
- package/dist/esnext/utilities/isClient/isClient.d.ts +0 -4
- package/dist/esnext/utilities/isClient/isClient.js +0 -4
- package/dist/esnext/utilities/isServer/isServer.d.ts +0 -4
- package/dist/esnext/utilities/isServer/isServer.js +0 -4
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +2 -33
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.js +0 -31
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +10 -0
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +13 -0
- package/dist/node/framework/middleware.d.ts +5 -1
- package/dist/node/framework/middleware.js +13 -6
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +4 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +8 -2
- package/dist/node/framework/plugins/vite-plugin-react-server-components-shim.js +11 -1
- package/dist/node/handle-event.js +8 -4
- package/dist/node/types.d.ts +19 -3
- package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +0 -7
- package/dist/node/utilities/flattenConnection/flattenConnection.js +0 -7
- package/dist/node/utilities/isClient/isClient.d.ts +0 -4
- package/dist/node/utilities/isClient/isClient.js +0 -4
- package/dist/node/utilities/isServer/isServer.d.ts +0 -4
- package/dist/node/utilities/isServer/isServer.js +0 -4
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +2 -33
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +0 -31
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/dist/worker/framework/Hydration/ServerComponentResponse.server.d.ts +10 -0
- package/dist/worker/framework/Hydration/ServerComponentResponse.server.js +13 -0
- package/dist/worker/handle-event.js +8 -4
- package/dist/worker/types.d.ts +19 -3
- package/package.json +7 -5
|
@@ -1128,20 +1128,38 @@ export declare const Localization: string;
|
|
|
1128
1128
|
*/
|
|
1129
1129
|
export declare const MediaFileFragment: string;
|
|
1130
1130
|
/**
|
|
1131
|
-
*```
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1131
|
+
*```
|
|
1132
|
+
*
|
|
1133
|
+
* fragment MetafieldFragment on Metafield {
|
|
1134
|
+
* id
|
|
1135
|
+
* type
|
|
1136
|
+
* namespace
|
|
1137
|
+
* key
|
|
1138
|
+
* value
|
|
1139
|
+
* createdAt
|
|
1140
|
+
* updatedAt
|
|
1141
|
+
* description
|
|
1142
|
+
* reference @include(if: $includeReferenceMetafieldDetails) {
|
|
1143
|
+
* __typename
|
|
1144
|
+
* ... on MediaImage {
|
|
1145
|
+
* id
|
|
1146
|
+
* mediaContentType
|
|
1147
|
+
* image {
|
|
1148
|
+
* ...ImageFragment
|
|
1149
|
+
* }
|
|
1150
|
+
* }
|
|
1151
|
+
* }
|
|
1152
|
+
* }
|
|
1153
|
+
* fragment ImageFragment on Image {
|
|
1154
|
+
* id
|
|
1155
|
+
* url
|
|
1156
|
+
* altText
|
|
1157
|
+
* width
|
|
1158
|
+
* height
|
|
1159
|
+
* }
|
|
1160
|
+
*
|
|
1161
|
+
*```
|
|
1162
|
+
*/
|
|
1145
1163
|
export declare const MetafieldFragment: string;
|
|
1146
1164
|
/**
|
|
1147
1165
|
*```
|
|
@@ -1247,6 +1265,7 @@ export declare const MoneyFragment: string;
|
|
|
1247
1265
|
* }
|
|
1248
1266
|
* }
|
|
1249
1267
|
*
|
|
1268
|
+
*
|
|
1250
1269
|
* fragment MetafieldFragment on Metafield {
|
|
1251
1270
|
* id
|
|
1252
1271
|
* type
|
|
@@ -1256,6 +1275,16 @@ export declare const MoneyFragment: string;
|
|
|
1256
1275
|
* createdAt
|
|
1257
1276
|
* updatedAt
|
|
1258
1277
|
* description
|
|
1278
|
+
* reference @include(if: $includeReferenceMetafieldDetails) {
|
|
1279
|
+
* __typename
|
|
1280
|
+
* ... on MediaImage {
|
|
1281
|
+
* id
|
|
1282
|
+
* mediaContentType
|
|
1283
|
+
* image {
|
|
1284
|
+
* ...ImageFragment
|
|
1285
|
+
* }
|
|
1286
|
+
* }
|
|
1287
|
+
* }
|
|
1259
1288
|
* }
|
|
1260
1289
|
*
|
|
1261
1290
|
* fragment VariantFragment on ProductVariant {
|
|
@@ -1365,6 +1394,14 @@ export declare const MoneyFragment: string;
|
|
|
1365
1394
|
* }
|
|
1366
1395
|
* }
|
|
1367
1396
|
*
|
|
1397
|
+
* fragment ImageFragment on Image {
|
|
1398
|
+
* id
|
|
1399
|
+
* url
|
|
1400
|
+
* altText
|
|
1401
|
+
* width
|
|
1402
|
+
* height
|
|
1403
|
+
* }
|
|
1404
|
+
*
|
|
1368
1405
|
*
|
|
1369
1406
|
* fragment SellingPlanFragment on SellingPlan {
|
|
1370
1407
|
* id
|
|
@@ -2173,21 +2173,40 @@ fragment Model3DFragment on Model3d {
|
|
|
2173
2173
|
}
|
|
2174
2174
|
`;
|
|
2175
2175
|
/**
|
|
2176
|
-
*```
|
|
2177
|
-
*
|
|
2178
|
-
*
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2181
|
-
*
|
|
2182
|
-
*
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2176
|
+
*```
|
|
2177
|
+
*
|
|
2178
|
+
* fragment MetafieldFragment on Metafield {
|
|
2179
|
+
* id
|
|
2180
|
+
* type
|
|
2181
|
+
* namespace
|
|
2182
|
+
* key
|
|
2183
|
+
* value
|
|
2184
|
+
* createdAt
|
|
2185
|
+
* updatedAt
|
|
2186
|
+
* description
|
|
2187
|
+
* reference @include(if: $includeReferenceMetafieldDetails) {
|
|
2188
|
+
* __typename
|
|
2189
|
+
* ... on MediaImage {
|
|
2190
|
+
* id
|
|
2191
|
+
* mediaContentType
|
|
2192
|
+
* image {
|
|
2193
|
+
* ...ImageFragment
|
|
2194
|
+
* }
|
|
2195
|
+
* }
|
|
2196
|
+
* }
|
|
2197
|
+
* }
|
|
2198
|
+
* fragment ImageFragment on Image {
|
|
2199
|
+
* id
|
|
2200
|
+
* url
|
|
2201
|
+
* altText
|
|
2202
|
+
* width
|
|
2203
|
+
* height
|
|
2204
|
+
* }
|
|
2205
|
+
*
|
|
2206
|
+
*```
|
|
2207
|
+
*/
|
|
2208
|
+
export const MetafieldFragment = `
|
|
2209
|
+
fragment MetafieldFragment on Metafield {
|
|
2191
2210
|
id
|
|
2192
2211
|
type
|
|
2193
2212
|
namespace
|
|
@@ -2196,6 +2215,23 @@ export const MetafieldFragment = `fragment MetafieldFragment on Metafield {
|
|
|
2196
2215
|
createdAt
|
|
2197
2216
|
updatedAt
|
|
2198
2217
|
description
|
|
2218
|
+
reference @include(if: $includeReferenceMetafieldDetails) {
|
|
2219
|
+
__typename
|
|
2220
|
+
... on MediaImage {
|
|
2221
|
+
id
|
|
2222
|
+
mediaContentType
|
|
2223
|
+
image {
|
|
2224
|
+
...ImageFragment
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
fragment ImageFragment on Image {
|
|
2230
|
+
id
|
|
2231
|
+
url
|
|
2232
|
+
altText
|
|
2233
|
+
width
|
|
2234
|
+
height
|
|
2199
2235
|
}
|
|
2200
2236
|
`;
|
|
2201
2237
|
/**
|
|
@@ -2318,6 +2354,7 @@ export const MoneyFragment = `fragment MoneyFragment on MoneyV2 {
|
|
|
2318
2354
|
* }
|
|
2319
2355
|
* }
|
|
2320
2356
|
*
|
|
2357
|
+
*
|
|
2321
2358
|
* fragment MetafieldFragment on Metafield {
|
|
2322
2359
|
* id
|
|
2323
2360
|
* type
|
|
@@ -2327,6 +2364,16 @@ export const MoneyFragment = `fragment MoneyFragment on MoneyV2 {
|
|
|
2327
2364
|
* createdAt
|
|
2328
2365
|
* updatedAt
|
|
2329
2366
|
* description
|
|
2367
|
+
* reference @include(if: $includeReferenceMetafieldDetails) {
|
|
2368
|
+
* __typename
|
|
2369
|
+
* ... on MediaImage {
|
|
2370
|
+
* id
|
|
2371
|
+
* mediaContentType
|
|
2372
|
+
* image {
|
|
2373
|
+
* ...ImageFragment
|
|
2374
|
+
* }
|
|
2375
|
+
* }
|
|
2376
|
+
* }
|
|
2330
2377
|
* }
|
|
2331
2378
|
*
|
|
2332
2379
|
* fragment VariantFragment on ProductVariant {
|
|
@@ -2436,6 +2483,14 @@ export const MoneyFragment = `fragment MoneyFragment on MoneyV2 {
|
|
|
2436
2483
|
* }
|
|
2437
2484
|
* }
|
|
2438
2485
|
*
|
|
2486
|
+
* fragment ImageFragment on Image {
|
|
2487
|
+
* id
|
|
2488
|
+
* url
|
|
2489
|
+
* altText
|
|
2490
|
+
* width
|
|
2491
|
+
* height
|
|
2492
|
+
* }
|
|
2493
|
+
*
|
|
2439
2494
|
*
|
|
2440
2495
|
* fragment SellingPlanFragment on SellingPlan {
|
|
2441
2496
|
* id
|
|
@@ -2607,6 +2662,7 @@ fragment MediaFileFragment on Media {
|
|
|
2607
2662
|
}
|
|
2608
2663
|
}
|
|
2609
2664
|
|
|
2665
|
+
|
|
2610
2666
|
fragment MetafieldFragment on Metafield {
|
|
2611
2667
|
id
|
|
2612
2668
|
type
|
|
@@ -2616,6 +2672,16 @@ fragment MetafieldFragment on Metafield {
|
|
|
2616
2672
|
createdAt
|
|
2617
2673
|
updatedAt
|
|
2618
2674
|
description
|
|
2675
|
+
reference @include(if: $includeReferenceMetafieldDetails) {
|
|
2676
|
+
__typename
|
|
2677
|
+
... on MediaImage {
|
|
2678
|
+
id
|
|
2679
|
+
mediaContentType
|
|
2680
|
+
image {
|
|
2681
|
+
...ImageFragment
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2619
2685
|
}
|
|
2620
2686
|
|
|
2621
2687
|
fragment VariantFragment on ProductVariant {
|
|
@@ -2725,6 +2791,14 @@ fragment Model3DFragment on Model3d {
|
|
|
2725
2791
|
}
|
|
2726
2792
|
}
|
|
2727
2793
|
|
|
2794
|
+
fragment ImageFragment on Image {
|
|
2795
|
+
id
|
|
2796
|
+
url
|
|
2797
|
+
altText
|
|
2798
|
+
width
|
|
2799
|
+
height
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2728
2802
|
|
|
2729
2803
|
fragment SellingPlanFragment on SellingPlan {
|
|
2730
2804
|
id
|
|
@@ -2,7 +2,7 @@ import { getCacheControlHeader } from './framework/cache';
|
|
|
2
2
|
import { setContext, setCache } from './framework/runtime';
|
|
3
3
|
import { setConfig } from './framework/config';
|
|
4
4
|
export default async function handleEvent(event, { request, entrypoint, indexTemplate, assetHandler, streamableResponse, dev, cache, context, }) {
|
|
5
|
-
var _a, _b, _c;
|
|
5
|
+
var _a, _b, _c, _d, _e;
|
|
6
6
|
const url = new URL(request.url);
|
|
7
7
|
/**
|
|
8
8
|
* Inject the cache & context into the module loader so we can pull it out for subrequests.
|
|
@@ -56,15 +56,17 @@ export default async function handleEvent(event, { request, entrypoint, indexTem
|
|
|
56
56
|
*/
|
|
57
57
|
headers.set(getCacheControlHeader({ dev }), componentResponse.cacheControlHeader);
|
|
58
58
|
if (componentResponse.customBody) {
|
|
59
|
+
const { status, customStatus } = componentResponse;
|
|
59
60
|
return new Response(await componentResponse.customBody, {
|
|
60
|
-
status: (_a =
|
|
61
|
+
status: (_b = (_a = customStatus === null || customStatus === void 0 ? void 0 : customStatus.code) !== null && _a !== void 0 ? _a : status) !== null && _b !== void 0 ? _b : 200,
|
|
62
|
+
statusText: customStatus === null || customStatus === void 0 ? void 0 : customStatus.text,
|
|
61
63
|
headers,
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
let response;
|
|
65
67
|
if (isReactHydrationRequest) {
|
|
66
68
|
response = new Response(body, {
|
|
67
|
-
status: (
|
|
69
|
+
status: (_c = componentResponse.status) !== null && _c !== void 0 ? _c : 200,
|
|
68
70
|
headers,
|
|
69
71
|
});
|
|
70
72
|
}
|
|
@@ -75,8 +77,10 @@ export default async function handleEvent(event, { request, entrypoint, indexTem
|
|
|
75
77
|
.replace('<body', bodyAttributes ? `<body ${bodyAttributes}` : '$&')
|
|
76
78
|
.replace('<html', htmlAttributes ? `<html ${htmlAttributes}` : '$&');
|
|
77
79
|
headers.append('content-type', 'text/html');
|
|
80
|
+
const { status, customStatus } = componentResponse;
|
|
78
81
|
response = new Response(html, {
|
|
79
|
-
status: (
|
|
82
|
+
status: (_e = (_d = customStatus === null || customStatus === void 0 ? void 0 : customStatus.code) !== null && _d !== void 0 ? _d : status) !== null && _e !== void 0 ? _e : 200,
|
|
83
|
+
statusText: customStatus === null || customStatus === void 0 ? void 0 : customStatus.text,
|
|
80
84
|
headers,
|
|
81
85
|
});
|
|
82
86
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useProductOptions } from './useProductOptions';
|
|
2
2
|
export * from './useProductOptions/types';
|
|
3
|
-
export { useQuery, QueryProvider } from '
|
|
3
|
+
export { useQuery, QueryProvider } 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, QueryProvider } from '
|
|
3
|
+
export { useQuery, QueryProvider } from '../foundation/useQuery';
|
|
4
4
|
export { useMoney } from './useMoney';
|
|
5
5
|
export { useMeasurement } from './useMeasurement';
|
|
6
6
|
export { useParsedMetafields } from './useParsedMetafields';
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useShop } from '../../foundation/useShop';
|
|
3
|
-
// TODO: Remove this when Oxygen supports Intl properly (oxygen-sws#527)
|
|
4
|
-
const NARROW_SYMBOL_MAP = {
|
|
5
|
-
USD: '$',
|
|
6
|
-
AUD: '$',
|
|
7
|
-
CAD: '$',
|
|
8
|
-
NZD: '$',
|
|
9
|
-
EUR: '€',
|
|
10
|
-
GBP: '£',
|
|
11
|
-
INR: '₹',
|
|
12
|
-
RUB: '₽',
|
|
13
|
-
CNY: '¥',
|
|
14
|
-
JPY: '¥',
|
|
15
|
-
BRL: 'R$',
|
|
16
|
-
};
|
|
17
3
|
/**
|
|
18
4
|
* The `useMoney` hook takes a [`MoneyV2` object](/api/storefront/reference/common-objects/moneyv2) and returns a
|
|
19
5
|
* default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by
|
|
@@ -37,12 +23,12 @@ export function useMoney(money) {
|
|
|
37
23
|
currencyDisplay: 'narrowSymbol',
|
|
38
24
|
}).formatToParts(amount);
|
|
39
25
|
const moneyValue = useMemo(() => {
|
|
40
|
-
var _a, _b, _c, _d, _e, _f
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41
27
|
return ({
|
|
42
28
|
currencyCode: money.currencyCode,
|
|
43
29
|
currencyName: (_b = (_a = nameParts.find((part) => part.type === 'currency')) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : money.currencyCode,
|
|
44
30
|
currencySymbol: (_d = (_c = baseParts.find((part) => part.type === 'currency')) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : money.currencyCode,
|
|
45
|
-
currencyNarrowSymbol: (
|
|
31
|
+
currencyNarrowSymbol: (_f = (_e = narrowParts.find((part) => part.type === 'currency')) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : '',
|
|
46
32
|
parts: baseParts,
|
|
47
33
|
localizedString: value,
|
|
48
34
|
amount: baseParts
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GraphQLConnection, ParsedMetafield } from '../../types';
|
|
2
|
-
import { Metafield } from '../../graphql/types/types';
|
|
1
|
+
import { GraphQLConnection, ParsedMetafield, RawMetafield } from '../../types';
|
|
3
2
|
/**
|
|
4
3
|
* The `useParsedMetafields` hook transforms a [MetafieldConnection](/api/storefront/reference/common-objects/metafieldconnection)
|
|
5
4
|
* in an array of metafields whose `values` have been parsed according to the metafield `type`.
|
|
6
5
|
*/
|
|
7
|
-
export declare function useParsedMetafields(metafields: GraphQLConnection<
|
|
6
|
+
export declare function useParsedMetafields(metafields: GraphQLConnection<RawMetafield> | undefined): ParsedMetafield[];
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GraphQLConnection } from '../../types';
|
|
1
|
+
import { GraphQLConnection, RawMetafield } from '../../types';
|
|
3
2
|
import { SellingPlanFragmentFragment } from './SellingPlanFragment';
|
|
4
3
|
import { SellingPlanGroupsFragmentFragment } from './SellingPlanGroupsFragment';
|
|
5
4
|
import { VariantFragmentFragment } from './VariantFragment';
|
|
6
5
|
export declare type Variant = Omit<Partial<VariantFragmentFragment>, 'id' | 'selectedOptions' | 'metafields' | 'sellingPlanAllocations'> & {
|
|
7
6
|
id: VariantFragmentFragment['id'];
|
|
8
7
|
selectedOptions: VariantFragmentFragment['selectedOptions'];
|
|
9
|
-
metafields?: GraphQLConnection<Partial<
|
|
8
|
+
metafields?: GraphQLConnection<Partial<RawMetafield>>;
|
|
10
9
|
sellingPlanAllocations?: GraphQLConnection<SellingPlanAllocation>;
|
|
11
10
|
};
|
|
12
11
|
export declare type SellingPlanGroup = Omit<Partial<SellingPlanGroupsFragmentFragment>, 'options'> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useShop } from '../../foundation/useShop';
|
|
2
|
-
import { useQuery } from '
|
|
2
|
+
import { useQuery } from '../../foundation/useQuery';
|
|
3
3
|
import { isClient, fetchBuilder, graphqlRequestBody } from '../../utilities';
|
|
4
4
|
import { getConfig } from '../../framework/config';
|
|
5
5
|
/**
|
package/dist/esnext/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { ServerResponse } from 'http';
|
|
3
3
|
import type { ServerComponentResponse } from './framework/Hydration/ServerComponentResponse.server';
|
|
4
4
|
import type { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
5
|
-
import type { Metafield } from './graphql/types/types';
|
|
5
|
+
import type { Metafield, Image, MediaContentType } from './graphql/types/types';
|
|
6
6
|
export declare type Renderer = (url: URL, options: {
|
|
7
7
|
request: ServerComponentRequest;
|
|
8
8
|
context?: Record<string, any>;
|
|
@@ -50,9 +50,24 @@ export interface GraphQLConnection<T> {
|
|
|
50
50
|
node: T;
|
|
51
51
|
}[];
|
|
52
52
|
}
|
|
53
|
-
export
|
|
54
|
-
|
|
53
|
+
export interface MediaImage {
|
|
54
|
+
__typename?: string;
|
|
55
|
+
id?: string;
|
|
56
|
+
mediaContentType?: MediaContentType;
|
|
57
|
+
image?: Pick<Image, 'altText' | 'url' | 'id' | 'width' | 'height'>;
|
|
58
|
+
}
|
|
59
|
+
interface ProductVariant {
|
|
60
|
+
__typename?: string;
|
|
61
|
+
}
|
|
62
|
+
interface Product {
|
|
63
|
+
__typename?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare type RawMetafield = Omit<Partial<Metafield>, 'reference'> & {
|
|
66
|
+
reference?: MediaImage | ProductVariant | Product | null;
|
|
67
|
+
};
|
|
68
|
+
export declare type ParsedMetafield = Omit<Partial<Metafield>, 'value' | 'reference'> & {
|
|
55
69
|
value?: string | number | boolean | Record<any, string> | Date | Rating | Measurement;
|
|
70
|
+
reference?: MediaImage | ProductVariant | Product | null;
|
|
56
71
|
};
|
|
57
72
|
export interface Rating {
|
|
58
73
|
value: number;
|
|
@@ -72,3 +87,4 @@ export interface CacheOptions {
|
|
|
72
87
|
export interface HydrogenVitePluginOptions {
|
|
73
88
|
devCache?: boolean;
|
|
74
89
|
}
|
|
90
|
+
export {};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { GraphQLConnection } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](api/storefront/reference/products/product#connections)) into a flat array of nodes.
|
|
4
|
-
* ## Arguments
|
|
5
|
-
* | Description | Required |
|
|
6
|
-
* | ------------| --------- |
|
|
7
|
-
* | A connection object with the field `edges` whose value is an array of objects corresponding to `{node: Value}`. For example, any of the [Product connections](api/storefront/reference/products/product#connections) | Yes |
|
|
8
|
-
*
|
|
9
|
-
* ## Return type
|
|
10
|
-
* A flat array whose elements correspond to the `node` value in each element of the original `edges` array.
|
|
11
4
|
*/
|
|
12
5
|
export declare function flattenConnection<T>(connection: GraphQLConnection<T>): T[];
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](api/storefront/reference/products/product#connections)) into a flat array of nodes.
|
|
3
|
-
* ## Arguments
|
|
4
|
-
* | Description | Required |
|
|
5
|
-
* | ------------| --------- |
|
|
6
|
-
* | A connection object with the field `edges` whose value is an array of objects corresponding to `{node: Value}`. For example, any of the [Product connections](api/storefront/reference/products/product#connections) | Yes |
|
|
7
|
-
*
|
|
8
|
-
* ## Return type
|
|
9
|
-
* A flat array whose elements correspond to the `node` value in each element of the original `edges` array.
|
|
10
3
|
*/
|
|
11
4
|
export function flattenConnection(connection) {
|
|
12
5
|
var _a;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
/** The `isClient` utility is a function that returns a boolean indicating
|
|
2
2
|
* if the code was run on the client.
|
|
3
|
-
* ## Arguments
|
|
4
|
-
* None
|
|
5
|
-
* ## Return type
|
|
6
|
-
* A `boolean` indicating if the code was run on the client.
|
|
7
3
|
*/
|
|
8
4
|
export declare function isClient(): boolean;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/** The `isClient` utility is a function that returns a boolean indicating
|
|
2
2
|
* if the code was run on the client.
|
|
3
|
-
* ## Arguments
|
|
4
|
-
* None
|
|
5
|
-
* ## Return type
|
|
6
|
-
* A `boolean` indicating if the code was run on the client.
|
|
7
3
|
*/
|
|
8
4
|
export function isClient() {
|
|
9
5
|
return typeof window !== 'undefined';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
/** The `isServer` utility is a function that returns a `boolean` indicating
|
|
2
2
|
* if the code was run on the server.
|
|
3
|
-
* ## Arguments
|
|
4
|
-
* None
|
|
5
|
-
* ## Return type
|
|
6
|
-
* A `boolean` indicating if the code was run on the server.
|
|
7
3
|
*/
|
|
8
4
|
export declare function isServer(): boolean;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { isClient } from '../isClient';
|
|
2
2
|
/** The `isServer` utility is a function that returns a `boolean` indicating
|
|
3
3
|
* if the code was run on the server.
|
|
4
|
-
* ## Arguments
|
|
5
|
-
* None
|
|
6
|
-
* ## Return type
|
|
7
|
-
* A `boolean` indicating if the code was run on the server.
|
|
8
4
|
*/
|
|
9
5
|
export function isServer() {
|
|
10
6
|
return !isClient();
|
|
@@ -1,36 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RawMetafield } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The `parseMetafieldValue` function parses a [Metafield](/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
4
|
-
*
|
|
5
|
-
* ## Arguments
|
|
6
|
-
*
|
|
7
|
-
* | Description | Required |
|
|
8
|
-
* | ------------------------------------------------------------------------- | -------- |
|
|
9
|
-
* | A [Metafield object](/api/storefront/reference/common-objects/metafield). | Yes |
|
|
10
|
-
*
|
|
11
|
-
* ## Return type
|
|
12
|
-
*
|
|
13
|
-
* Depending on the `type` specified in the passed [Metafield](/api/storefront/reference/common-objects/metafield), the following type is returned:
|
|
14
|
-
*
|
|
15
|
-
* | Metafield `type` | `value` type |
|
|
16
|
-
* | ------------------------ | --------------------------------------------------------------------------------------------- |
|
|
17
|
-
* | `date` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
18
|
-
* | `date_time` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
19
|
-
* | `boolean` | boolean |
|
|
20
|
-
* | `number_integer` | int |
|
|
21
|
-
* | `number_decimal` | float |
|
|
22
|
-
* | `json` | An object |
|
|
23
|
-
* | `weight` | An object with `value` and `unit` keys |
|
|
24
|
-
* | `dimension` | An object with `value` and `unit` keys |
|
|
25
|
-
* | `volume` | An object with `value` and `unit` keys |
|
|
26
|
-
* | `rating` | An object with `scale_min`, `scale_max`, and `value` keys |
|
|
27
|
-
* | `color` | string |
|
|
28
|
-
* | `single_line_text_field` | string |
|
|
29
|
-
* | `multi_line_text_field` | string |
|
|
30
|
-
* | `product_reference` | string |
|
|
31
|
-
* | `file_reference` | string |
|
|
32
|
-
* | `page_reference` | string |
|
|
33
|
-
* | `variant_reference` | string |
|
|
34
|
-
* | `url` | string |
|
|
35
4
|
*/
|
|
36
|
-
export declare function parseMetafieldValue(metafield: Partial<
|
|
5
|
+
export declare function parseMetafieldValue(metafield: Partial<RawMetafield>): any;
|
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `parseMetafieldValue` function parses a [Metafield](/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
3
|
-
*
|
|
4
|
-
* ## Arguments
|
|
5
|
-
*
|
|
6
|
-
* | Description | Required |
|
|
7
|
-
* | ------------------------------------------------------------------------- | -------- |
|
|
8
|
-
* | A [Metafield object](/api/storefront/reference/common-objects/metafield). | Yes |
|
|
9
|
-
*
|
|
10
|
-
* ## Return type
|
|
11
|
-
*
|
|
12
|
-
* Depending on the `type` specified in the passed [Metafield](/api/storefront/reference/common-objects/metafield), the following type is returned:
|
|
13
|
-
*
|
|
14
|
-
* | Metafield `type` | `value` type |
|
|
15
|
-
* | ------------------------ | --------------------------------------------------------------------------------------------- |
|
|
16
|
-
* | `date` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
17
|
-
* | `date_time` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
18
|
-
* | `boolean` | boolean |
|
|
19
|
-
* | `number_integer` | int |
|
|
20
|
-
* | `number_decimal` | float |
|
|
21
|
-
* | `json` | An object |
|
|
22
|
-
* | `weight` | An object with `value` and `unit` keys |
|
|
23
|
-
* | `dimension` | An object with `value` and `unit` keys |
|
|
24
|
-
* | `volume` | An object with `value` and `unit` keys |
|
|
25
|
-
* | `rating` | An object with `scale_min`, `scale_max`, and `value` keys |
|
|
26
|
-
* | `color` | string |
|
|
27
|
-
* | `single_line_text_field` | string |
|
|
28
|
-
* | `multi_line_text_field` | string |
|
|
29
|
-
* | `product_reference` | string |
|
|
30
|
-
* | `file_reference` | string |
|
|
31
|
-
* | `page_reference` | string |
|
|
32
|
-
* | `variant_reference` | string |
|
|
33
|
-
* | `url` | string |
|
|
34
3
|
*/
|
|
35
4
|
export function parseMetafieldValue(metafield) {
|
|
36
5
|
if (metafield.value == null) {
|
package/dist/esnext/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.
|
|
1
|
+
export declare const LIB_VERSION = "0.7.0";
|
package/dist/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '0.
|
|
1
|
+
export const LIB_VERSION = '0.7.0';
|
|
@@ -2,6 +2,10 @@ import { CacheOptions } from '../../types';
|
|
|
2
2
|
export declare class ServerComponentResponse extends Response {
|
|
3
3
|
private wait;
|
|
4
4
|
private cacheOptions?;
|
|
5
|
+
customStatus?: {
|
|
6
|
+
code?: number;
|
|
7
|
+
text?: string;
|
|
8
|
+
};
|
|
5
9
|
/**
|
|
6
10
|
* Allow custom body to be a string or a Promise.
|
|
7
11
|
*/
|
|
@@ -14,6 +18,12 @@ export declare class ServerComponentResponse extends Response {
|
|
|
14
18
|
canStream(): boolean;
|
|
15
19
|
cache(options: CacheOptions): void;
|
|
16
20
|
get cacheControlHeader(): string;
|
|
21
|
+
writeHead({ status, statusText, headers, }?: {
|
|
22
|
+
status?: number;
|
|
23
|
+
statusText?: string;
|
|
24
|
+
headers?: Record<string, any>;
|
|
25
|
+
}): void;
|
|
26
|
+
redirect(location: string, status?: number): void;
|
|
17
27
|
/**
|
|
18
28
|
* Send the response from a Server Component. Renders React components to string,
|
|
19
29
|
* and returns `null` to make React happy.
|
|
@@ -33,6 +33,19 @@ class ServerComponentResponse extends Response {
|
|
|
33
33
|
};
|
|
34
34
|
return cache_1.generateCacheControlHeader(options);
|
|
35
35
|
}
|
|
36
|
+
writeHead({ status, statusText, headers, } = {}) {
|
|
37
|
+
if (status || statusText) {
|
|
38
|
+
this.customStatus = { code: status, text: statusText };
|
|
39
|
+
}
|
|
40
|
+
if (headers) {
|
|
41
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
42
|
+
this.headers.set(key, value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
redirect(location, status = 307) {
|
|
47
|
+
this.writeHead({ status, headers: { location } });
|
|
48
|
+
}
|
|
36
49
|
/**
|
|
37
50
|
* Send the response from a Server Component. Renders React components to string,
|
|
38
51
|
* and returns `null` to make React happy.
|
|
@@ -10,9 +10,13 @@ declare type HydrogenMiddlewareArgs = {
|
|
|
10
10
|
devServer?: ViteDevServer;
|
|
11
11
|
cache?: Cache;
|
|
12
12
|
};
|
|
13
|
+
export declare function graphiqlMiddleware({ shopifyConfig, dev, }: {
|
|
14
|
+
shopifyConfig: ShopifyConfig;
|
|
15
|
+
dev: boolean;
|
|
16
|
+
}): (request: IncomingMessage, response: http.ServerResponse, next: NextFunction) => Promise<void>;
|
|
13
17
|
/**
|
|
14
18
|
* Provides middleware to Node.js Express-like servers. Used by the Hydrogen
|
|
15
19
|
* Vite dev server plugin as well as production Node.js implementation.
|
|
16
20
|
*/
|
|
17
|
-
export
|
|
21
|
+
export declare function hydrogenMiddleware({ dev, cache, indexTemplate, getServerEntrypoint, devServer, }: HydrogenMiddlewareArgs): (request: IncomingMessage, response: http.ServerResponse, next: NextFunction) => Promise<void>;
|
|
18
22
|
export {};
|