@graphcommerce/next-config 8.1.0-canary.9 → 9.0.0-canary.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +261 -67
- package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +159 -3
- package/__tests__/config/utils/configToImportMeta.ts +0 -4
- package/__tests__/config/utils/mergeEnvIntoConfig.ts +20 -2
- package/__tests__/config/utils/rewriteLegancyEnv.ts +1 -1
- package/__tests__/interceptors/findPlugins.ts +366 -240
- package/__tests__/interceptors/generateInterceptors.ts +138 -59
- package/__tests__/interceptors/parseStructure.ts +132 -2
- package/__tests__/utils/resolveDependenciesSync.ts +39 -33
- package/dist/config/commands/exportConfig.js +1 -2
- package/dist/config/commands/generateConfig.js +1 -2
- package/dist/config/demoConfig.js +5 -0
- package/dist/config/loadConfig.js +1 -2
- package/dist/config/utils/configToImportMeta.js +1 -2
- package/dist/config/utils/diff.js +1 -1
- package/dist/config/utils/exportConfigToEnv.js +1 -2
- package/dist/config/utils/mergeEnvIntoConfig.js +12 -5
- package/dist/config/utils/replaceConfigInString.js +1 -2
- package/dist/config/utils/rewriteLegacyEnv.js +1 -2
- package/dist/generated/config.js +37 -16
- package/dist/interceptors/Visitor.js +1 -1
- package/dist/interceptors/commands/codegenInterceptors.js +1 -2
- package/dist/interceptors/extractExports.js +23 -20
- package/dist/interceptors/findOriginalSource.js +19 -4
- package/dist/interceptors/findPlugins.js +1 -2
- package/dist/interceptors/generateInterceptor.js +11 -12
- package/dist/interceptors/generateInterceptors.js +1 -2
- package/dist/interceptors/parseStructure.js +20 -7
- package/dist/interceptors/swc.js +2 -3
- package/dist/interceptors/writeInterceptors.js +8 -9
- package/dist/utils/isMonorepo.js +1 -2
- package/dist/utils/resolveDependenciesSync.js +3 -4
- package/dist/withGraphCommerce.js +22 -15
- package/package.json +10 -11
- package/src/config/demoConfig.ts +5 -0
- package/src/config/utils/mergeEnvIntoConfig.ts +9 -1
- package/src/generated/config.ts +109 -22
- package/src/interceptors/Visitor.ts +1 -1
- package/src/interceptors/extractExports.ts +21 -21
- package/src/interceptors/findOriginalSource.ts +17 -2
- package/src/interceptors/generateInterceptor.ts +4 -6
- package/src/interceptors/parseStructure.ts +25 -5
- package/src/interceptors/writeInterceptors.ts +7 -7
- package/src/utils/resolveDependenciesSync.ts +1 -1
- package/src/withGraphCommerce.ts +21 -13
|
@@ -5,6 +5,7 @@ exports.demoConfig = {
|
|
|
5
5
|
canonicalBaseUrl: 'https://graphcommerce.vercel.app',
|
|
6
6
|
hygraphEndpoint: 'https://eu-central-1.cdn.hygraph.com/content/ckhx7xadya6xs01yxdujt8i80/master',
|
|
7
7
|
magentoEndpoint: 'https://backend.reachdigital.dev/graphql',
|
|
8
|
+
magentoVersion: 246,
|
|
8
9
|
storefront: [
|
|
9
10
|
{ locale: 'en', magentoStoreCode: 'en_US', defaultLocale: true },
|
|
10
11
|
{
|
|
@@ -35,6 +36,7 @@ exports.demoConfig = {
|
|
|
35
36
|
],
|
|
36
37
|
productFiltersPro: true,
|
|
37
38
|
productFiltersLayout: 'DEFAULT',
|
|
39
|
+
productListPaginationVariant: 'COMPACT',
|
|
38
40
|
compareVariant: 'ICON',
|
|
39
41
|
robotsAllow: false,
|
|
40
42
|
demoMode: true,
|
|
@@ -44,4 +46,7 @@ exports.demoConfig = {
|
|
|
44
46
|
configurableVariantForSimple: true,
|
|
45
47
|
configurableVariantValues: { url: true, content: true, gallery: true },
|
|
46
48
|
recentlyViewedProducts: { enabled: true, maxCount: 20 },
|
|
49
|
+
breadcrumbs: false,
|
|
50
|
+
customerDeleteEnabled: true,
|
|
51
|
+
previewSecret: 'SECRET',
|
|
47
52
|
};
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.loadConfig =
|
|
17
|
+
exports.loadConfig = loadConfig;
|
|
18
18
|
/* eslint-disable no-console */
|
|
19
19
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
20
20
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
@@ -60,4 +60,3 @@ function loadConfig(cwd) {
|
|
|
60
60
|
throw error;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
exports.loadConfig = loadConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configToImportMeta =
|
|
3
|
+
exports.configToImportMeta = configToImportMeta;
|
|
4
4
|
function flattenKeys(value, initialPathPrefix, stringify) {
|
|
5
5
|
// Is a scalar:
|
|
6
6
|
if (value === null || value === undefined || typeof value === 'number') {
|
|
@@ -37,4 +37,3 @@ function flattenKeys(value, initialPathPrefix, stringify) {
|
|
|
37
37
|
function configToImportMeta(config, path = 'import.meta.graphCommerce', stringify = true) {
|
|
38
38
|
return flattenKeys(config, path, stringify);
|
|
39
39
|
}
|
|
40
|
-
exports.configToImportMeta = configToImportMeta;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = diff;
|
|
3
4
|
function isObject(val) {
|
|
4
5
|
return typeof val === 'object' && val !== null;
|
|
5
6
|
}
|
|
@@ -30,4 +31,3 @@ function diff(item1, item2) {
|
|
|
30
31
|
}
|
|
31
32
|
return item2 === item1 ? undefined : item2;
|
|
32
33
|
}
|
|
33
|
-
exports.default = diff;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exportConfigToEnv =
|
|
3
|
+
exports.exportConfigToEnv = exportConfigToEnv;
|
|
4
4
|
const mergeEnvIntoConfig_1 = require("./mergeEnvIntoConfig");
|
|
5
5
|
const fmt = (value) => {
|
|
6
6
|
let formattedValue = value;
|
|
@@ -29,4 +29,3 @@ function exportConfigToEnv(config) {
|
|
|
29
29
|
});
|
|
30
30
|
return env;
|
|
31
31
|
}
|
|
32
|
-
exports.exportConfigToEnv = exportConfigToEnv;
|
|
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.filterEnv = exports.dotNotation = exports.toEnvStr = void 0;
|
|
7
|
+
exports.configToEnvSchema = configToEnvSchema;
|
|
8
|
+
exports.mergeEnvIntoConfig = mergeEnvIntoConfig;
|
|
9
|
+
exports.formatAppliedEnv = formatAppliedEnv;
|
|
7
10
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
8
11
|
const utilities_1 = require("@apollo/client/utilities");
|
|
9
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -43,6 +46,8 @@ function configToEnvSchema(schema) {
|
|
|
43
46
|
node = node.unwrap();
|
|
44
47
|
if (node instanceof zod_1.ZodNullable)
|
|
45
48
|
node = node.unwrap();
|
|
49
|
+
if (node instanceof zod_1.ZodDefault)
|
|
50
|
+
node = node.removeDefault();
|
|
46
51
|
if (node instanceof zod_1.ZodObject) {
|
|
47
52
|
if (path.length > 0) {
|
|
48
53
|
envSchema[(0, exports.toEnvStr)(path)] = zod_1.z
|
|
@@ -73,7 +78,12 @@ function configToEnvSchema(schema) {
|
|
|
73
78
|
});
|
|
74
79
|
return;
|
|
75
80
|
}
|
|
76
|
-
if (node instanceof zod_1.
|
|
81
|
+
if (node instanceof zod_1.ZodNumber) {
|
|
82
|
+
envSchema[(0, exports.toEnvStr)(path)] = zod_1.z.coerce.number().optional();
|
|
83
|
+
envToDot[(0, exports.toEnvStr)(path)] = (0, exports.dotNotation)(path);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (node instanceof zod_1.ZodString || node instanceof zod_1.ZodEnum) {
|
|
77
87
|
envSchema[(0, exports.toEnvStr)(path)] = node.optional();
|
|
78
88
|
envToDot[(0, exports.toEnvStr)(path)] = (0, exports.dotNotation)(path);
|
|
79
89
|
return;
|
|
@@ -97,7 +107,6 @@ function configToEnvSchema(schema) {
|
|
|
97
107
|
walk(schema);
|
|
98
108
|
return [zod_1.z.object(envSchema), envToDot];
|
|
99
109
|
}
|
|
100
|
-
exports.configToEnvSchema = configToEnvSchema;
|
|
101
110
|
const filterEnv = (env) => Object.fromEntries(Object.entries(env).filter(([key]) => key.startsWith('GC_')));
|
|
102
111
|
exports.filterEnv = filterEnv;
|
|
103
112
|
function mergeEnvIntoConfig(schema, config, env) {
|
|
@@ -130,7 +139,6 @@ function mergeEnvIntoConfig(schema, config, env) {
|
|
|
130
139
|
});
|
|
131
140
|
return [newConfig, applyResult];
|
|
132
141
|
}
|
|
133
|
-
exports.mergeEnvIntoConfig = mergeEnvIntoConfig;
|
|
134
142
|
/**
|
|
135
143
|
* Prints the applied env variables to the console
|
|
136
144
|
*
|
|
@@ -176,4 +184,3 @@ function formatAppliedEnv(applyResult) {
|
|
|
176
184
|
header += ` - Loaded GraphCommerce env variables`;
|
|
177
185
|
return [header, ...lines].join('\n');
|
|
178
186
|
}
|
|
179
|
-
exports.formatAppliedEnv = formatAppliedEnv;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceConfigInString =
|
|
3
|
+
exports.replaceConfigInString = replaceConfigInString;
|
|
4
4
|
const configToImportMeta_1 = require("./configToImportMeta");
|
|
5
5
|
function replaceConfigInString(str, config) {
|
|
6
6
|
let result = str;
|
|
@@ -10,4 +10,3 @@ function replaceConfigInString(str, config) {
|
|
|
10
10
|
});
|
|
11
11
|
return result;
|
|
12
12
|
}
|
|
13
|
-
exports.replaceConfigInString = replaceConfigInString;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.rewriteLegacyEnv =
|
|
6
|
+
exports.rewriteLegacyEnv = rewriteLegacyEnv;
|
|
7
7
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
8
8
|
const mergeEnvIntoConfig_1 = require("./mergeEnvIntoConfig");
|
|
9
9
|
function rewriteLegacyEnv(schema, env, config = {}) {
|
|
@@ -113,4 +113,3 @@ function rewriteLegacyEnv(schema, env, config = {}) {
|
|
|
113
113
|
const [newConfig, envApplied] = (0, mergeEnvIntoConfig_1.mergeEnvIntoConfig)(schema, config, clonedEnv);
|
|
114
114
|
return [newConfig, [...applied, ...envApplied]];
|
|
115
115
|
}
|
|
116
|
-
exports.rewriteLegacyEnv = rewriteLegacyEnv;
|
package/dist/generated/config.js
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WebsitePermissionsSchema = exports.SidebarGalleryPaginationVariantSchema = exports.ProductFiltersLayoutSchema = exports.PaginationVariantSchema = exports.CustomerAccountPermissionsSchema = exports.CompareVariantSchema = exports.CartPermissionsSchema = exports.definedNonNullAnySchema = exports.isDefinedNonNullAny = void 0;
|
|
4
|
+
exports.DatalayerConfigSchema = DatalayerConfigSchema;
|
|
5
|
+
exports.GraphCommerceConfigSchema = GraphCommerceConfigSchema;
|
|
6
|
+
exports.GraphCommerceDebugConfigSchema = GraphCommerceDebugConfigSchema;
|
|
7
|
+
exports.GraphCommercePermissionsSchema = GraphCommercePermissionsSchema;
|
|
8
|
+
exports.GraphCommerceStorefrontConfigSchema = GraphCommerceStorefrontConfigSchema;
|
|
9
|
+
exports.MagentoConfigurableVariantValuesSchema = MagentoConfigurableVariantValuesSchema;
|
|
10
|
+
exports.RecentlyViewedProductsConfigSchema = RecentlyViewedProductsConfigSchema;
|
|
11
|
+
exports.SidebarGalleryConfigSchema = SidebarGalleryConfigSchema;
|
|
4
12
|
/* eslint-disable */
|
|
5
13
|
const zod_1 = require("zod");
|
|
6
14
|
const isDefinedNonNullAny = (v) => v !== undefined && v !== null;
|
|
7
15
|
exports.isDefinedNonNullAny = isDefinedNonNullAny;
|
|
8
16
|
exports.definedNonNullAnySchema = zod_1.z.any().refine((v) => (0, exports.isDefinedNonNullAny)(v));
|
|
17
|
+
exports.CartPermissionsSchema = zod_1.z.enum(['CUSTOMER_ONLY', 'DISABLED', 'ENABLED']);
|
|
9
18
|
exports.CompareVariantSchema = zod_1.z.enum(['CHECKBOX', 'ICON']);
|
|
19
|
+
exports.CustomerAccountPermissionsSchema = zod_1.z.enum(['DISABLED', 'DISABLE_REGISTRATION', 'ENABLED']);
|
|
20
|
+
exports.PaginationVariantSchema = zod_1.z.enum(['COMPACT', 'EXTENDED']);
|
|
10
21
|
exports.ProductFiltersLayoutSchema = zod_1.z.enum(['DEFAULT', 'SIDEBAR']);
|
|
11
22
|
exports.SidebarGalleryPaginationVariantSchema = zod_1.z.enum(['DOTS', 'THUMBNAILS_BOTTOM']);
|
|
23
|
+
exports.WebsitePermissionsSchema = zod_1.z.enum(['ENABLED']);
|
|
12
24
|
function DatalayerConfigSchema() {
|
|
13
25
|
return zod_1.z.object({
|
|
14
26
|
coreWebVitals: zod_1.z.boolean().nullish()
|
|
15
27
|
});
|
|
16
28
|
}
|
|
17
|
-
exports.DatalayerConfigSchema = DatalayerConfigSchema;
|
|
18
29
|
function GraphCommerceConfigSchema() {
|
|
19
30
|
return zod_1.z.object({
|
|
31
|
+
breadcrumbs: zod_1.z.boolean().default(false).nullish(),
|
|
20
32
|
canonicalBaseUrl: zod_1.z.string().min(1),
|
|
21
33
|
cartDisplayPricesInclTax: zod_1.z.boolean().nullish(),
|
|
22
34
|
compare: zod_1.z.boolean().nullish(),
|
|
23
|
-
compareVariant: exports.CompareVariantSchema.nullish(),
|
|
24
|
-
configurableVariantForSimple: zod_1.z.boolean().nullish(),
|
|
35
|
+
compareVariant: exports.CompareVariantSchema.default("ICON").nullish(),
|
|
36
|
+
configurableVariantForSimple: zod_1.z.boolean().default(false).nullish(),
|
|
25
37
|
configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(),
|
|
26
|
-
crossSellsHideCartItems: zod_1.z.boolean().nullish(),
|
|
27
|
-
crossSellsRedirectItems: zod_1.z.boolean().nullish(),
|
|
28
|
-
|
|
38
|
+
crossSellsHideCartItems: zod_1.z.boolean().default(false).nullish(),
|
|
39
|
+
crossSellsRedirectItems: zod_1.z.boolean().default(false).nullish(),
|
|
40
|
+
customerAddressNoteEnable: zod_1.z.boolean().nullish(),
|
|
41
|
+
customerCompanyFieldsEnable: zod_1.z.boolean().nullish(),
|
|
42
|
+
customerDeleteEnabled: zod_1.z.boolean().nullish(),
|
|
43
|
+
customerXMagentoCacheIdDisable: zod_1.z.boolean().nullish(),
|
|
29
44
|
dataLayer: DatalayerConfigSchema().nullish(),
|
|
30
45
|
debug: GraphCommerceDebugConfigSchema().nullish(),
|
|
31
|
-
demoMode: zod_1.z.boolean().nullish(),
|
|
46
|
+
demoMode: zod_1.z.boolean().default(true).nullish(),
|
|
32
47
|
enableGuestCheckoutLogin: zod_1.z.boolean().nullish(),
|
|
33
48
|
googleAnalyticsId: zod_1.z.string().nullish(),
|
|
34
49
|
googleRecaptchaKey: zod_1.z.string().nullish(),
|
|
@@ -36,13 +51,15 @@ function GraphCommerceConfigSchema() {
|
|
|
36
51
|
hygraphEndpoint: zod_1.z.string().min(1),
|
|
37
52
|
hygraphManagementApi: zod_1.z.string().nullish(),
|
|
38
53
|
hygraphProjectId: zod_1.z.string().nullish(),
|
|
39
|
-
hygraphWriteAccessEndpoint: zod_1.z.string().nullish(),
|
|
40
54
|
hygraphWriteAccessToken: zod_1.z.string().nullish(),
|
|
41
55
|
limitSsg: zod_1.z.boolean().nullish(),
|
|
42
56
|
magentoEndpoint: zod_1.z.string().min(1),
|
|
57
|
+
magentoVersion: zod_1.z.number(),
|
|
58
|
+
permissions: GraphCommercePermissionsSchema().nullish(),
|
|
43
59
|
previewSecret: zod_1.z.string().nullish(),
|
|
44
|
-
productFiltersLayout: exports.ProductFiltersLayoutSchema.nullish(),
|
|
60
|
+
productFiltersLayout: exports.ProductFiltersLayoutSchema.default("DEFAULT").nullish(),
|
|
45
61
|
productFiltersPro: zod_1.z.boolean().nullish(),
|
|
62
|
+
productListPaginationVariant: exports.PaginationVariantSchema.default("COMPACT").nullish(),
|
|
46
63
|
productRoute: zod_1.z.string().nullish(),
|
|
47
64
|
recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(),
|
|
48
65
|
robotsAllow: zod_1.z.boolean().nullish(),
|
|
@@ -52,7 +69,6 @@ function GraphCommerceConfigSchema() {
|
|
|
52
69
|
wishlistShowFeedbackMessage: zod_1.z.boolean().nullish()
|
|
53
70
|
});
|
|
54
71
|
}
|
|
55
|
-
exports.GraphCommerceConfigSchema = GraphCommerceConfigSchema;
|
|
56
72
|
function GraphCommerceDebugConfigSchema() {
|
|
57
73
|
return zod_1.z.object({
|
|
58
74
|
pluginStatus: zod_1.z.boolean().nullish(),
|
|
@@ -61,11 +77,19 @@ function GraphCommerceDebugConfigSchema() {
|
|
|
61
77
|
webpackDuplicatesPlugin: zod_1.z.boolean().nullish()
|
|
62
78
|
});
|
|
63
79
|
}
|
|
64
|
-
|
|
80
|
+
function GraphCommercePermissionsSchema() {
|
|
81
|
+
return zod_1.z.object({
|
|
82
|
+
cart: exports.CartPermissionsSchema.nullish(),
|
|
83
|
+
checkout: exports.CartPermissionsSchema.nullish(),
|
|
84
|
+
customerAccount: exports.CustomerAccountPermissionsSchema.nullish(),
|
|
85
|
+
website: exports.WebsitePermissionsSchema.nullish()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
65
88
|
function GraphCommerceStorefrontConfigSchema() {
|
|
66
89
|
return zod_1.z.object({
|
|
67
90
|
canonicalBaseUrl: zod_1.z.string().nullish(),
|
|
68
91
|
cartDisplayPricesInclTax: zod_1.z.boolean().nullish(),
|
|
92
|
+
customerCompanyFieldsEnable: zod_1.z.boolean().nullish(),
|
|
69
93
|
defaultLocale: zod_1.z.boolean().nullish(),
|
|
70
94
|
domain: zod_1.z.string().nullish(),
|
|
71
95
|
googleAnalyticsId: zod_1.z.string().nullish(),
|
|
@@ -75,10 +99,10 @@ function GraphCommerceStorefrontConfigSchema() {
|
|
|
75
99
|
linguiLocale: zod_1.z.string().nullish(),
|
|
76
100
|
locale: zod_1.z.string().min(1),
|
|
77
101
|
magentoStoreCode: zod_1.z.string().min(1),
|
|
102
|
+
permissions: GraphCommercePermissionsSchema().nullish(),
|
|
78
103
|
robotsAllow: zod_1.z.boolean().nullish()
|
|
79
104
|
});
|
|
80
105
|
}
|
|
81
|
-
exports.GraphCommerceStorefrontConfigSchema = GraphCommerceStorefrontConfigSchema;
|
|
82
106
|
function MagentoConfigurableVariantValuesSchema() {
|
|
83
107
|
return zod_1.z.object({
|
|
84
108
|
content: zod_1.z.boolean().nullish(),
|
|
@@ -86,17 +110,14 @@ function MagentoConfigurableVariantValuesSchema() {
|
|
|
86
110
|
url: zod_1.z.boolean().nullish()
|
|
87
111
|
});
|
|
88
112
|
}
|
|
89
|
-
exports.MagentoConfigurableVariantValuesSchema = MagentoConfigurableVariantValuesSchema;
|
|
90
113
|
function RecentlyViewedProductsConfigSchema() {
|
|
91
114
|
return zod_1.z.object({
|
|
92
115
|
enabled: zod_1.z.boolean().nullish(),
|
|
93
116
|
maxCount: zod_1.z.number().nullish()
|
|
94
117
|
});
|
|
95
118
|
}
|
|
96
|
-
exports.RecentlyViewedProductsConfigSchema = RecentlyViewedProductsConfigSchema;
|
|
97
119
|
function SidebarGalleryConfigSchema() {
|
|
98
120
|
return zod_1.z.object({
|
|
99
121
|
paginationVariant: exports.SidebarGalleryPaginationVariantSchema.nullish()
|
|
100
122
|
});
|
|
101
123
|
}
|
|
102
|
-
exports.SidebarGalleryConfigSchema = SidebarGalleryConfigSchema;
|
|
@@ -595,7 +595,7 @@ class Visitor {
|
|
|
595
595
|
return n;
|
|
596
596
|
}
|
|
597
597
|
visitTsFnParameters(params) {
|
|
598
|
-
return params
|
|
598
|
+
return params?.map(this.visitTsFnParameter.bind(this));
|
|
599
599
|
}
|
|
600
600
|
visitTsFnParameter(n) {
|
|
601
601
|
n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.codegenInterceptors =
|
|
6
|
+
exports.codegenInterceptors = codegenInterceptors;
|
|
7
7
|
const loadConfig_1 = require("../../config/loadConfig");
|
|
8
8
|
const resolveDependency_1 = require("../../utils/resolveDependency");
|
|
9
9
|
const findPlugins_1 = require("../findPlugins");
|
|
@@ -20,4 +20,3 @@ async function codegenInterceptors() {
|
|
|
20
20
|
// console.log('Generated interceptors in', generated - found, 'ms')
|
|
21
21
|
await (0, writeInterceptors_1.writeInterceptors)(generatedInterceptors);
|
|
22
22
|
}
|
|
23
|
-
exports.codegenInterceptors = codegenInterceptors;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RUNTIME_VALUE = exports.UnsupportedValueError = exports.NoSuchDeclarationError = void 0;
|
|
4
|
+
exports.extractExports = extractExports;
|
|
4
5
|
class NoSuchDeclarationError extends Error {
|
|
5
6
|
}
|
|
6
7
|
exports.NoSuchDeclarationError = NoSuchDeclarationError;
|
|
@@ -87,9 +88,8 @@ function extractValue(node, path, optional = false) {
|
|
|
87
88
|
case 'undefined':
|
|
88
89
|
return undefined;
|
|
89
90
|
default:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
throw new UnsupportedValueError(`Unknown identifier "${node.value}"`, path);
|
|
91
|
+
return exports.RUNTIME_VALUE;
|
|
92
|
+
// throw new UnsupportedValueError(`Unknown identifier "${node.value}"`, path)
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
else if (isArrayExpression(node)) {
|
|
@@ -100,9 +100,11 @@ function extractValue(node, path, optional = false) {
|
|
|
100
100
|
if (elem) {
|
|
101
101
|
if (elem.spread) {
|
|
102
102
|
// e.g. [ ...a ]
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
return exports.RUNTIME_VALUE;
|
|
104
|
+
// throw new UnsupportedValueError(
|
|
105
|
+
// 'Unsupported spread operator in the Array Expression',
|
|
106
|
+
// path,
|
|
107
|
+
// )
|
|
106
108
|
}
|
|
107
109
|
arr.push(extractValue(elem.expression, path && [...path, `[${i}]`], optional));
|
|
108
110
|
}
|
|
@@ -120,9 +122,11 @@ function extractValue(node, path, optional = false) {
|
|
|
120
122
|
for (const prop of node.properties) {
|
|
121
123
|
if (!isKeyValueProperty(prop)) {
|
|
122
124
|
// e.g. { ...a }
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
return exports.RUNTIME_VALUE;
|
|
126
|
+
// throw new UnsupportedValueError(
|
|
127
|
+
// 'Unsupported spread operator in the Object Expression',
|
|
128
|
+
// path,
|
|
129
|
+
// )
|
|
126
130
|
}
|
|
127
131
|
let key;
|
|
128
132
|
if (isIdentifier(prop.key)) {
|
|
@@ -134,9 +138,11 @@ function extractValue(node, path, optional = false) {
|
|
|
134
138
|
key = prop.key.value;
|
|
135
139
|
}
|
|
136
140
|
else {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
return exports.RUNTIME_VALUE;
|
|
142
|
+
// throw new UnsupportedValueError(
|
|
143
|
+
// `Unsupported key type "${prop.key.type}" in the Object Expression`,
|
|
144
|
+
// path,
|
|
145
|
+
// )
|
|
140
146
|
}
|
|
141
147
|
obj[key] = extractValue(prop.value, path && [...path, key]);
|
|
142
148
|
}
|
|
@@ -146,9 +152,8 @@ function extractValue(node, path, optional = false) {
|
|
|
146
152
|
// e.g. `abc`
|
|
147
153
|
if (node.expressions.length !== 0) {
|
|
148
154
|
// TODO: should we add support for `${'e'}d${'g'}'e'`?
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
throw new UnsupportedValueError('Unsupported template literal with expressions', path);
|
|
155
|
+
return exports.RUNTIME_VALUE;
|
|
156
|
+
// throw new UnsupportedValueError('Unsupported template literal with expressions', path)
|
|
152
157
|
}
|
|
153
158
|
// When TemplateLiteral has 0 expressions, the length of quasis is always 1.
|
|
154
159
|
// Because when parsing TemplateLiteral, the parser yields the first quasi,
|
|
@@ -163,9 +168,8 @@ function extractValue(node, path, optional = false) {
|
|
|
163
168
|
return cooked ?? raw;
|
|
164
169
|
}
|
|
165
170
|
else {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
throw new UnsupportedValueError(`Unsupported node type "${node.type}"`, path);
|
|
171
|
+
return exports.RUNTIME_VALUE;
|
|
172
|
+
// throw new UnsupportedValueError(`Unsupported node type "${node.type}"`, path)
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
function extractExports(module) {
|
|
@@ -198,4 +202,3 @@ function extractExports(module) {
|
|
|
198
202
|
}
|
|
199
203
|
return [exports, errors];
|
|
200
204
|
}
|
|
201
|
-
exports.extractExports = extractExports;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.findOriginalSource =
|
|
6
|
+
exports.findOriginalSource = findOriginalSource;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const swc_1 = require("./swc");
|
|
9
9
|
function parseAndFindExport(resolved, findExport, resolve) {
|
|
@@ -33,6 +33,22 @@ function parseAndFindExport(resolved, findExport, resolve) {
|
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
if (node.type === 'ExportNamedDeclaration') {
|
|
37
|
+
for (const specifier of node.specifiers) {
|
|
38
|
+
if (specifier.type === 'ExportSpecifier') {
|
|
39
|
+
if (specifier.exported?.value === findExport)
|
|
40
|
+
return resolved;
|
|
41
|
+
}
|
|
42
|
+
else if (specifier.type === 'ExportDefaultSpecifier') {
|
|
43
|
+
// todo
|
|
44
|
+
}
|
|
45
|
+
else if (specifier.type === 'ExportNamespaceSpecifier') {
|
|
46
|
+
// todo
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// todo: if (node.type === 'ExportDefaultDeclaration') {}
|
|
51
|
+
// todo: if (node.type === 'ExportDefaultExpression') {}
|
|
36
52
|
}
|
|
37
53
|
const exports = ast.body
|
|
38
54
|
.filter((node) => node.type === 'ExportAllDeclaration')
|
|
@@ -65,7 +81,7 @@ function findOriginalSource(plug, resolved, resolve) {
|
|
|
65
81
|
if (!resolved?.source)
|
|
66
82
|
return {
|
|
67
83
|
resolved: undefined,
|
|
68
|
-
error: new Error(`
|
|
84
|
+
error: new Error(`Plugin: Can not find module ${plug.targetModule} for ${plug.sourceModule}`),
|
|
69
85
|
};
|
|
70
86
|
// const cacheKey = `${plug.targetModule}#${plug.targetExport}`
|
|
71
87
|
// if (cachedResults.has(cacheKey)) {
|
|
@@ -78,10 +94,9 @@ function findOriginalSource(plug, resolved, resolve) {
|
|
|
78
94
|
if (!newResolved) {
|
|
79
95
|
return {
|
|
80
96
|
resolved: undefined,
|
|
81
|
-
error: new Error(`
|
|
97
|
+
error: new Error(`Plugin target not found ${plug.targetModule}#${plug.sourceExport} for plugin ${plug.sourceModule}#${plug.sourceExport}`),
|
|
82
98
|
};
|
|
83
99
|
}
|
|
84
100
|
// cachedResults.set(cacheKey, newResolved)
|
|
85
101
|
return { resolved: newResolved, error: undefined };
|
|
86
102
|
}
|
|
87
|
-
exports.findOriginalSource = findOriginalSource;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.findPlugins =
|
|
6
|
+
exports.findPlugins = findPlugins;
|
|
7
7
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
8
|
const core_1 = require("@swc/core");
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -69,4 +69,3 @@ function findPlugins(config, cwd = process.cwd()) {
|
|
|
69
69
|
}
|
|
70
70
|
return [plugins, errors];
|
|
71
71
|
}
|
|
72
|
-
exports.findPlugins = findPlugins;
|
|
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.SOURCE_END = exports.SOURCE_START = void 0;
|
|
7
|
+
exports.isPluginBaseConfig = isPluginBaseConfig;
|
|
8
|
+
exports.isReactPluginConfig = isReactPluginConfig;
|
|
9
|
+
exports.isMethodPluginConfig = isMethodPluginConfig;
|
|
10
|
+
exports.isReplacePluginConfig = isReplacePluginConfig;
|
|
11
|
+
exports.isPluginConfig = isPluginConfig;
|
|
12
|
+
exports.moveRelativeDown = moveRelativeDown;
|
|
13
|
+
exports.generateInterceptor = generateInterceptor;
|
|
7
14
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
15
|
const prettier_config_pwa_1 = __importDefault(require("@graphcommerce/prettier-config-pwa"));
|
|
9
16
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
@@ -16,36 +23,31 @@ function isPluginBaseConfig(plugin) {
|
|
|
16
23
|
typeof plugin.enabled === 'boolean' &&
|
|
17
24
|
typeof plugin.targetExport === 'string');
|
|
18
25
|
}
|
|
19
|
-
exports.isPluginBaseConfig = isPluginBaseConfig;
|
|
20
26
|
function isReactPluginConfig(plugin) {
|
|
21
27
|
if (!isPluginBaseConfig(plugin))
|
|
22
28
|
return false;
|
|
23
29
|
return plugin.type === 'component';
|
|
24
30
|
}
|
|
25
|
-
exports.isReactPluginConfig = isReactPluginConfig;
|
|
26
31
|
function isMethodPluginConfig(plugin) {
|
|
27
32
|
if (!isPluginBaseConfig(plugin))
|
|
28
33
|
return false;
|
|
29
34
|
return plugin.type === 'function';
|
|
30
35
|
}
|
|
31
|
-
exports.isMethodPluginConfig = isMethodPluginConfig;
|
|
32
36
|
function isReplacePluginConfig(plugin) {
|
|
33
37
|
if (!isPluginBaseConfig(plugin))
|
|
34
38
|
return false;
|
|
35
39
|
return plugin.type === 'replace';
|
|
36
40
|
}
|
|
37
|
-
exports.isReplacePluginConfig = isReplacePluginConfig;
|
|
38
41
|
function isPluginConfig(plugin) {
|
|
39
42
|
return isPluginBaseConfig(plugin);
|
|
40
43
|
}
|
|
41
|
-
exports.isPluginConfig = isPluginConfig;
|
|
42
44
|
exports.SOURCE_START = '/** Original source starts here (do not modify!): **/';
|
|
43
45
|
exports.SOURCE_END = '/** Original source ends here (do not modify!) **/';
|
|
44
46
|
const originalSuffix = 'Original';
|
|
45
47
|
const sourceSuffix = 'Plugin';
|
|
46
48
|
const interceptorSuffix = 'Interceptor';
|
|
47
49
|
const disabledSuffix = 'Disabled';
|
|
48
|
-
const name = (plugin) => `${plugin.sourceModule
|
|
50
|
+
const name = (plugin) => `${plugin.sourceExport}${plugin.sourceModule
|
|
49
51
|
.split('/')[plugin.sourceModule.split('/').length - 1].replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
50
52
|
const fileName = (plugin) => `${plugin.sourceModule}#${plugin.sourceExport}`;
|
|
51
53
|
const originalName = (n) => `${n}${originalSuffix}`;
|
|
@@ -61,7 +63,6 @@ function moveRelativeDown(plugins) {
|
|
|
61
63
|
return 0;
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
|
-
exports.moveRelativeDown = moveRelativeDown;
|
|
65
66
|
const generateIdentifyer = (s) => Math.abs(s.split('').reduce((a, b) => {
|
|
66
67
|
// eslint-disable-next-line no-param-reassign, no-bitwise
|
|
67
68
|
a = (a << 5) - a + b.charCodeAt(0);
|
|
@@ -121,8 +122,7 @@ async function generateInterceptor(interceptor, config, oldInterceptorSource) {
|
|
|
121
122
|
.join(' wrapping ');
|
|
122
123
|
if (isReplacePluginConfig(p)) {
|
|
123
124
|
new RenameVisitor_1.RenameVisitor([originalName(p.targetExport)], (s) => s.replace(originalSuffix, disabledSuffix)).visitModule(ast);
|
|
124
|
-
carryProps.push(
|
|
125
|
-
result = `type ${interceptorPropsName(name(p))} = React.ComponentProps<typeof ${sourceName(name(p))}>`;
|
|
125
|
+
carryProps.push(`React.ComponentProps<typeof ${sourceName(name(p))}>`);
|
|
126
126
|
pluginSee.push(`@see {${sourceName(name(p))}} for replacement of the original source (original source not used)`);
|
|
127
127
|
}
|
|
128
128
|
if (isReactPluginConfig(p)) {
|
|
@@ -154,7 +154,7 @@ async function generateInterceptor(interceptor, config, oldInterceptorSource) {
|
|
|
154
154
|
})
|
|
155
155
|
.filter((v) => !!v)
|
|
156
156
|
.join('\n');
|
|
157
|
-
const isComponent = plugins.every((p) =>
|
|
157
|
+
const isComponent = plugins.every((p) => isReactPluginConfig(p));
|
|
158
158
|
if (isComponent && plugins.some((p) => isMethodPluginConfig(p))) {
|
|
159
159
|
throw new Error(`Cannot mix React and Method plugins for ${base} in ${dependency}.`);
|
|
160
160
|
}
|
|
@@ -215,4 +215,3 @@ async function generateInterceptor(interceptor, config, oldInterceptorSource) {
|
|
|
215
215
|
}
|
|
216
216
|
return { ...interceptor, template: templateFormatted };
|
|
217
217
|
}
|
|
218
|
-
exports.generateInterceptor = generateInterceptor;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateInterceptors =
|
|
6
|
+
exports.generateInterceptors = generateInterceptors;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
9
9
|
const findOriginalSource_1 = require("./findOriginalSource");
|
|
@@ -53,4 +53,3 @@ async function generateInterceptors(plugins, resolve, config, force) {
|
|
|
53
53
|
];
|
|
54
54
|
})));
|
|
55
55
|
}
|
|
56
|
-
exports.generateInterceptors = generateInterceptors;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parseStructure =
|
|
6
|
+
exports.parseStructure = parseStructure;
|
|
7
7
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
8
|
const zod_1 = require("zod");
|
|
9
9
|
const extractExports_1 = require("./extractExports");
|
|
@@ -11,7 +11,7 @@ const pluginConfigParsed = zod_1.z.object({
|
|
|
11
11
|
type: zod_1.z.enum(['component', 'function', 'replace']),
|
|
12
12
|
module: zod_1.z.string(),
|
|
13
13
|
export: zod_1.z.string(),
|
|
14
|
-
ifConfig: zod_1.z.union([zod_1.z.string(), zod_1.z.tuple([zod_1.z.string(), zod_1.z.
|
|
14
|
+
ifConfig: zod_1.z.union([zod_1.z.string(), zod_1.z.tuple([zod_1.z.string(), zod_1.z.unknown()])]).optional(),
|
|
15
15
|
});
|
|
16
16
|
function nonNullable(value) {
|
|
17
17
|
return value !== null && value !== undefined;
|
|
@@ -27,7 +27,7 @@ function parseStructure(ast, gcConfig, sourceModule) {
|
|
|
27
27
|
exportVals.push('Plugin');
|
|
28
28
|
if (func && !moduleConfig)
|
|
29
29
|
exportVals.push('plugin');
|
|
30
|
-
|
|
30
|
+
const pluginConfigs = exportVals
|
|
31
31
|
.map((exportVal) => {
|
|
32
32
|
let config = isObject(moduleConfig) ? moduleConfig : {};
|
|
33
33
|
if (!moduleConfig && component) {
|
|
@@ -41,6 +41,7 @@ function parseStructure(ast, gcConfig, sourceModule) {
|
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
console.error(`Plugin configuration invalid! See ${sourceModule}`);
|
|
44
|
+
return null;
|
|
44
45
|
}
|
|
45
46
|
const parsed = pluginConfigParsed.safeParse(config);
|
|
46
47
|
if (!parsed.success) {
|
|
@@ -50,9 +51,15 @@ function parseStructure(ast, gcConfig, sourceModule) {
|
|
|
50
51
|
}
|
|
51
52
|
let enabled = true;
|
|
52
53
|
if (parsed.data.ifConfig) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
if (Array.isArray(parsed.data.ifConfig)) {
|
|
55
|
+
const isBoolean = typeof parsed.data.ifConfig[1] === 'boolean';
|
|
56
|
+
let confValue = (0, get_1.default)(gcConfig, parsed.data.ifConfig[0]);
|
|
57
|
+
confValue = isBoolean ? Boolean(confValue) : confValue;
|
|
58
|
+
enabled = confValue === parsed.data.ifConfig[1];
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
enabled = Boolean((0, get_1.default)(gcConfig, parsed.data.ifConfig));
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
const val = {
|
|
58
65
|
targetExport: exports.component || exports.func || parsed.data.export,
|
|
@@ -67,5 +74,11 @@ function parseStructure(ast, gcConfig, sourceModule) {
|
|
|
67
74
|
return val;
|
|
68
75
|
})
|
|
69
76
|
.filter(nonNullable);
|
|
77
|
+
const newPluginConfigs = pluginConfigs.reduce((acc, pluginConfig) => {
|
|
78
|
+
if (!acc.find((accPluginConfig) => accPluginConfig.sourceExport === pluginConfig.sourceExport)) {
|
|
79
|
+
acc.push(pluginConfig);
|
|
80
|
+
}
|
|
81
|
+
return acc;
|
|
82
|
+
}, []);
|
|
83
|
+
return newPluginConfigs;
|
|
70
84
|
}
|
|
71
|
-
exports.parseStructure = parseStructure;
|