@pandacss/config 0.31.0 → 0.32.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/{chunk-5YOGLJPA.mjs → chunk-3MGBJU2R.mjs} +7 -1
- package/dist/{chunk-XG56JT63.mjs → chunk-MT2A5AKG.mjs} +75 -1
- package/dist/diff-config.js +7 -1
- package/dist/diff-config.mjs +1 -1
- package/dist/index.js +112 -23
- package/dist/index.mjs +19 -10
- package/dist/merge-config.js +75 -1
- package/dist/merge-config.mjs +1 -1
- package/package.json +6 -6
|
@@ -79,7 +79,13 @@ var artifactConfigDeps = {
|
|
|
79
79
|
"jsx-patterns": jsx.concat("patterns"),
|
|
80
80
|
"jsx-patterns-index": jsx.concat("patterns"),
|
|
81
81
|
"css-index": ["syntax"],
|
|
82
|
-
"package.json": ["emitPackage", "forceConsistentTypeExtension", "outExtension"]
|
|
82
|
+
"package.json": ["emitPackage", "forceConsistentTypeExtension", "outExtension"],
|
|
83
|
+
"types-styles": ["shorthands"],
|
|
84
|
+
"types-conditions": ["conditions"],
|
|
85
|
+
"types-jsx": jsx,
|
|
86
|
+
"types-entry": [],
|
|
87
|
+
"types-gen": [],
|
|
88
|
+
"types-gen-system": []
|
|
83
89
|
};
|
|
84
90
|
var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
85
91
|
if (!paths.length)
|
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
// src/merge-config.ts
|
|
2
2
|
import { mergeAndConcat } from "merge-anything";
|
|
3
3
|
|
|
4
|
+
// src/merge-hooks.ts
|
|
5
|
+
import { logger } from "@pandacss/logger";
|
|
6
|
+
var mergeHooks = (plugins) => {
|
|
7
|
+
const hooksFns = {};
|
|
8
|
+
plugins.forEach(({ name, hooks }) => {
|
|
9
|
+
Object.entries(hooks ?? {}).forEach(([key, value]) => {
|
|
10
|
+
if (!hooksFns[key]) {
|
|
11
|
+
hooksFns[key] = [];
|
|
12
|
+
}
|
|
13
|
+
hooksFns[key].push([name, value]);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
const mergedHooks = Object.fromEntries(
|
|
17
|
+
Object.entries(hooksFns).map(([key, entries]) => {
|
|
18
|
+
const fns = entries.map(([name, fn]) => tryCatch(name, fn));
|
|
19
|
+
if (key === "cssgen:done") {
|
|
20
|
+
return [key, reducers["cssgen:done"](fns)];
|
|
21
|
+
}
|
|
22
|
+
if (key === "codegen:prepare") {
|
|
23
|
+
return [key, reducers["codegen:prepare"](fns)];
|
|
24
|
+
}
|
|
25
|
+
return [key, syncHooks.includes(key) ? callAll(...fns) : callAllAsync(...fns)];
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
return mergedHooks;
|
|
29
|
+
};
|
|
30
|
+
var reducers = {
|
|
31
|
+
"cssgen:done": (fns) => (args) => {
|
|
32
|
+
let content = args.content;
|
|
33
|
+
for (const hookFn of fns) {
|
|
34
|
+
const result = hookFn({ ...args, content, original: args.content });
|
|
35
|
+
if (result !== void 0) {
|
|
36
|
+
content = result;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return content;
|
|
40
|
+
},
|
|
41
|
+
"codegen:prepare": (fns) => (args) => {
|
|
42
|
+
let artifacts = args.artifacts;
|
|
43
|
+
for (const hookFn of fns) {
|
|
44
|
+
const result = hookFn({ ...args, artifacts, original: args.artifacts });
|
|
45
|
+
if (result) {
|
|
46
|
+
artifacts = result;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return artifacts;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var syncHooks = ["context:created", "parser:before", "parser:after", "cssgen:done"];
|
|
53
|
+
var callAllAsync = (...fns) => async (...a) => {
|
|
54
|
+
for (const fn of fns) {
|
|
55
|
+
await fn?.(...a);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var callAll = (...fns) => (...a) => {
|
|
59
|
+
fns.forEach((fn) => fn?.(...a));
|
|
60
|
+
};
|
|
61
|
+
var tryCatch = (name, fn) => {
|
|
62
|
+
return (...args) => {
|
|
63
|
+
try {
|
|
64
|
+
return fn(...args);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
logger.error("hooks", `The error below comes from the plugin ${name}`);
|
|
67
|
+
console.error(e);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
4
72
|
// src/utils.ts
|
|
5
73
|
import { traverse } from "@pandacss/shared";
|
|
6
74
|
var isObject = (v) => Object.prototype.toString.call(v) === "[object Object]";
|
|
@@ -87,6 +155,11 @@ var compact = (obj) => {
|
|
|
87
155
|
}, {});
|
|
88
156
|
};
|
|
89
157
|
function mergeConfigs(configs) {
|
|
158
|
+
const [userConfig] = configs;
|
|
159
|
+
const pluginHooks = userConfig.plugins ?? [];
|
|
160
|
+
if (userConfig.hooks) {
|
|
161
|
+
pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
|
|
162
|
+
}
|
|
90
163
|
const mergedResult = assign(
|
|
91
164
|
{
|
|
92
165
|
conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
|
|
@@ -94,7 +167,8 @@ function mergeConfigs(configs) {
|
|
|
94
167
|
patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
|
|
95
168
|
utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
|
|
96
169
|
globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})),
|
|
97
|
-
staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {}))
|
|
170
|
+
staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})),
|
|
171
|
+
hooks: mergeHooks(pluginHooks)
|
|
98
172
|
},
|
|
99
173
|
...configs
|
|
100
174
|
);
|
package/dist/diff-config.js
CHANGED
|
@@ -113,7 +113,13 @@ var artifactConfigDeps = {
|
|
|
113
113
|
"jsx-patterns": jsx.concat("patterns"),
|
|
114
114
|
"jsx-patterns-index": jsx.concat("patterns"),
|
|
115
115
|
"css-index": ["syntax"],
|
|
116
|
-
"package.json": ["emitPackage", "forceConsistentTypeExtension", "outExtension"]
|
|
116
|
+
"package.json": ["emitPackage", "forceConsistentTypeExtension", "outExtension"],
|
|
117
|
+
"types-styles": ["shorthands"],
|
|
118
|
+
"types-conditions": ["conditions"],
|
|
119
|
+
"types-jsx": jsx,
|
|
120
|
+
"types-entry": [],
|
|
121
|
+
"types-gen": [],
|
|
122
|
+
"types-gen-system": []
|
|
117
123
|
};
|
|
118
124
|
var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
119
125
|
if (!paths.length)
|
package/dist/diff-config.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -183,7 +183,13 @@ var artifactConfigDeps = {
|
|
|
183
183
|
"jsx-patterns": jsx.concat("patterns"),
|
|
184
184
|
"jsx-patterns-index": jsx.concat("patterns"),
|
|
185
185
|
"css-index": ["syntax"],
|
|
186
|
-
"package.json": ["emitPackage", "forceConsistentTypeExtension", "outExtension"]
|
|
186
|
+
"package.json": ["emitPackage", "forceConsistentTypeExtension", "outExtension"],
|
|
187
|
+
"types-styles": ["shorthands"],
|
|
188
|
+
"types-conditions": ["conditions"],
|
|
189
|
+
"types-jsx": jsx,
|
|
190
|
+
"types-entry": [],
|
|
191
|
+
"types-gen": [],
|
|
192
|
+
"types-gen-system": []
|
|
187
193
|
};
|
|
188
194
|
var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
189
195
|
if (!paths.length)
|
|
@@ -376,6 +382,74 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compi
|
|
|
376
382
|
// src/merge-config.ts
|
|
377
383
|
var import_merge_anything = require("merge-anything");
|
|
378
384
|
|
|
385
|
+
// src/merge-hooks.ts
|
|
386
|
+
var import_logger2 = require("@pandacss/logger");
|
|
387
|
+
var mergeHooks = (plugins) => {
|
|
388
|
+
const hooksFns = {};
|
|
389
|
+
plugins.forEach(({ name, hooks }) => {
|
|
390
|
+
Object.entries(hooks ?? {}).forEach(([key, value]) => {
|
|
391
|
+
if (!hooksFns[key]) {
|
|
392
|
+
hooksFns[key] = [];
|
|
393
|
+
}
|
|
394
|
+
hooksFns[key].push([name, value]);
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
const mergedHooks = Object.fromEntries(
|
|
398
|
+
Object.entries(hooksFns).map(([key, entries]) => {
|
|
399
|
+
const fns = entries.map(([name, fn]) => tryCatch(name, fn));
|
|
400
|
+
if (key === "cssgen:done") {
|
|
401
|
+
return [key, reducers["cssgen:done"](fns)];
|
|
402
|
+
}
|
|
403
|
+
if (key === "codegen:prepare") {
|
|
404
|
+
return [key, reducers["codegen:prepare"](fns)];
|
|
405
|
+
}
|
|
406
|
+
return [key, syncHooks.includes(key) ? callAll(...fns) : callAllAsync(...fns)];
|
|
407
|
+
})
|
|
408
|
+
);
|
|
409
|
+
return mergedHooks;
|
|
410
|
+
};
|
|
411
|
+
var reducers = {
|
|
412
|
+
"cssgen:done": (fns) => (args) => {
|
|
413
|
+
let content = args.content;
|
|
414
|
+
for (const hookFn of fns) {
|
|
415
|
+
const result = hookFn({ ...args, content, original: args.content });
|
|
416
|
+
if (result !== void 0) {
|
|
417
|
+
content = result;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return content;
|
|
421
|
+
},
|
|
422
|
+
"codegen:prepare": (fns) => (args) => {
|
|
423
|
+
let artifacts = args.artifacts;
|
|
424
|
+
for (const hookFn of fns) {
|
|
425
|
+
const result = hookFn({ ...args, artifacts, original: args.artifacts });
|
|
426
|
+
if (result) {
|
|
427
|
+
artifacts = result;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return artifacts;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
var syncHooks = ["context:created", "parser:before", "parser:after", "cssgen:done"];
|
|
434
|
+
var callAllAsync = (...fns) => async (...a) => {
|
|
435
|
+
for (const fn of fns) {
|
|
436
|
+
await fn?.(...a);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
var callAll = (...fns) => (...a) => {
|
|
440
|
+
fns.forEach((fn) => fn?.(...a));
|
|
441
|
+
};
|
|
442
|
+
var tryCatch = (name, fn) => {
|
|
443
|
+
return (...args) => {
|
|
444
|
+
try {
|
|
445
|
+
return fn(...args);
|
|
446
|
+
} catch (e) {
|
|
447
|
+
import_logger2.logger.error("hooks", `The error below comes from the plugin ${name}`);
|
|
448
|
+
console.error(e);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
|
|
379
453
|
// src/utils.ts
|
|
380
454
|
var import_shared4 = require("@pandacss/shared");
|
|
381
455
|
var isObject = (v) => Object.prototype.toString.call(v) === "[object Object]";
|
|
@@ -462,6 +536,11 @@ var compact = (obj) => {
|
|
|
462
536
|
}, {});
|
|
463
537
|
};
|
|
464
538
|
function mergeConfigs(configs2) {
|
|
539
|
+
const [userConfig] = configs2;
|
|
540
|
+
const pluginHooks = userConfig.plugins ?? [];
|
|
541
|
+
if (userConfig.hooks) {
|
|
542
|
+
pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
|
|
543
|
+
}
|
|
465
544
|
const mergedResult = assign(
|
|
466
545
|
{
|
|
467
546
|
conditions: mergeExtensions(configs2.map((config) => config.conditions ?? {})),
|
|
@@ -469,7 +548,8 @@ function mergeConfigs(configs2) {
|
|
|
469
548
|
patterns: mergeExtensions(configs2.map((config) => config.patterns ?? {})),
|
|
470
549
|
utilities: mergeExtensions(configs2.map((config) => config.utilities ?? {})),
|
|
471
550
|
globalCss: mergeExtensions(configs2.map((config) => config.globalCss ?? {})),
|
|
472
|
-
staticCss: mergeExtensions(configs2.map((config) => config.staticCss ?? {}))
|
|
551
|
+
staticCss: mergeExtensions(configs2.map((config) => config.staticCss ?? {})),
|
|
552
|
+
hooks: mergeHooks(pluginHooks)
|
|
473
553
|
},
|
|
474
554
|
...configs2
|
|
475
555
|
);
|
|
@@ -496,8 +576,8 @@ async function getResolvedConfig(config, cwd) {
|
|
|
496
576
|
}
|
|
497
577
|
|
|
498
578
|
// src/resolve-config.ts
|
|
499
|
-
var
|
|
500
|
-
var
|
|
579
|
+
var import_logger4 = require("@pandacss/logger");
|
|
580
|
+
var import_shared9 = require("@pandacss/shared");
|
|
501
581
|
|
|
502
582
|
// src/bundled-preset.ts
|
|
503
583
|
var import_preset_base = require("@pandacss/preset-base");
|
|
@@ -514,8 +594,8 @@ var getBundledPreset = (preset) => {
|
|
|
514
594
|
};
|
|
515
595
|
|
|
516
596
|
// src/validate-config.ts
|
|
517
|
-
var
|
|
518
|
-
var
|
|
597
|
+
var import_logger3 = require("@pandacss/logger");
|
|
598
|
+
var import_shared8 = require("@pandacss/shared");
|
|
519
599
|
|
|
520
600
|
// src/validation/validate-artifact.ts
|
|
521
601
|
var validateArtifactNames = (names, addError) => {
|
|
@@ -551,13 +631,22 @@ var validateBreakpoints = (breakpoints, addError) => {
|
|
|
551
631
|
};
|
|
552
632
|
|
|
553
633
|
// src/validation/validate-condition.ts
|
|
634
|
+
var import_shared6 = require("@pandacss/shared");
|
|
554
635
|
var validateConditions = (conditions, addError) => {
|
|
555
636
|
if (!conditions)
|
|
556
637
|
return;
|
|
557
638
|
Object.values(conditions).forEach((condition) => {
|
|
558
|
-
if (
|
|
559
|
-
|
|
639
|
+
if ((0, import_shared6.isString)(condition)) {
|
|
640
|
+
if (!condition.startsWith("@") && !condition.includes("&")) {
|
|
641
|
+
addError("conditions", `Selectors should contain the \`&\` character: \`${condition}\``);
|
|
642
|
+
}
|
|
643
|
+
return;
|
|
560
644
|
}
|
|
645
|
+
condition.forEach((c) => {
|
|
646
|
+
if (!c.startsWith("@") && !c.includes("&")) {
|
|
647
|
+
addError("conditions", `Selectors should contain the \`&\` character: \`${c}\``);
|
|
648
|
+
}
|
|
649
|
+
});
|
|
561
650
|
});
|
|
562
651
|
};
|
|
563
652
|
|
|
@@ -592,7 +681,7 @@ var validateRecipes = (options) => {
|
|
|
592
681
|
};
|
|
593
682
|
|
|
594
683
|
// src/validation/validate-tokens.ts
|
|
595
|
-
var
|
|
684
|
+
var import_shared7 = require("@pandacss/shared");
|
|
596
685
|
|
|
597
686
|
// src/validation/utils.ts
|
|
598
687
|
var isValidToken = (token) => Object.hasOwnProperty.call(token, "value");
|
|
@@ -645,7 +734,7 @@ var validateTokens = (options) => {
|
|
|
645
734
|
const { tokenNames, semanticTokenNames, valueAtPath, refsByPath } = tokens2;
|
|
646
735
|
if (theme.tokens) {
|
|
647
736
|
const tokenPaths = /* @__PURE__ */ new Set();
|
|
648
|
-
(0,
|
|
737
|
+
(0, import_shared7.walkObject)(
|
|
649
738
|
theme.tokens,
|
|
650
739
|
(value, paths) => {
|
|
651
740
|
const path2 = paths.join(SEP);
|
|
@@ -671,7 +760,7 @@ var validateTokens = (options) => {
|
|
|
671
760
|
}
|
|
672
761
|
if (theme.semanticTokens) {
|
|
673
762
|
const tokenPaths = /* @__PURE__ */ new Set();
|
|
674
|
-
(0,
|
|
763
|
+
(0, import_shared7.walkObject)(
|
|
675
764
|
theme.semanticTokens,
|
|
676
765
|
(value, paths) => {
|
|
677
766
|
const path2 = paths.join(SEP);
|
|
@@ -680,7 +769,7 @@ var validateTokens = (options) => {
|
|
|
680
769
|
tokenPaths.add(path2);
|
|
681
770
|
if (!isValidToken(value))
|
|
682
771
|
return;
|
|
683
|
-
(0,
|
|
772
|
+
(0, import_shared7.walkObject)(value, (itemValue) => {
|
|
684
773
|
if (isTokenReference(itemValue)) {
|
|
685
774
|
const formattedPath = formatPath(path2);
|
|
686
775
|
if (!refsByPath.has(formattedPath)) {
|
|
@@ -701,7 +790,7 @@ var validateTokens = (options) => {
|
|
|
701
790
|
tokenPaths.forEach((path2) => {
|
|
702
791
|
const formattedPath = formatPath(path2);
|
|
703
792
|
const value = valueAtPath.get(path2);
|
|
704
|
-
if (!(0,
|
|
793
|
+
if (!(0, import_shared7.isObject)(value) && !path2.includes("value")) {
|
|
705
794
|
addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
|
|
706
795
|
}
|
|
707
796
|
});
|
|
@@ -741,9 +830,9 @@ var validateConfig = (config) => {
|
|
|
741
830
|
${Array.from(warnings).map((err) => "- " + err).join("\n")}
|
|
742
831
|
`;
|
|
743
832
|
if (config.validation === "error") {
|
|
744
|
-
throw new
|
|
833
|
+
throw new import_shared8.PandaError("CONFIG_ERROR", errors);
|
|
745
834
|
}
|
|
746
|
-
|
|
835
|
+
import_logger3.logger.warn("config", errors);
|
|
747
836
|
return warnings;
|
|
748
837
|
}
|
|
749
838
|
};
|
|
@@ -762,15 +851,15 @@ async function resolveConfig(result, cwd) {
|
|
|
762
851
|
presets.add(import_preset_panda.preset);
|
|
763
852
|
}
|
|
764
853
|
result.config.presets = Array.from(presets);
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
854
|
+
const mergedConfig = await getResolvedConfig(result.config, cwd);
|
|
855
|
+
const hooks = mergedConfig.hooks ?? {};
|
|
856
|
+
if (mergedConfig.logLevel) {
|
|
857
|
+
import_logger4.logger.level = mergedConfig.logLevel;
|
|
768
858
|
}
|
|
769
|
-
validateConfig(
|
|
770
|
-
const { hooks = {} } = result.config;
|
|
859
|
+
validateConfig(mergedConfig);
|
|
771
860
|
const loadConfigResult = {
|
|
772
861
|
...result,
|
|
773
|
-
config
|
|
862
|
+
config: mergedConfig
|
|
774
863
|
};
|
|
775
864
|
if (hooks["config:resolved"]) {
|
|
776
865
|
const result2 = await hooks["config:resolved"]({
|
|
@@ -783,8 +872,8 @@ async function resolveConfig(result, cwd) {
|
|
|
783
872
|
loadConfigResult.config = result2;
|
|
784
873
|
}
|
|
785
874
|
}
|
|
786
|
-
const serialized = (0,
|
|
787
|
-
const deserialize = () => (0,
|
|
875
|
+
const serialized = (0, import_shared9.stringifyJson)(loadConfigResult.config);
|
|
876
|
+
const deserialize = () => (0, import_shared9.parseJson)(serialized);
|
|
788
877
|
return { ...loadConfigResult, serialized, deserialize, hooks };
|
|
789
878
|
}
|
|
790
879
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mergeConfigs,
|
|
3
3
|
utils
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MT2A5AKG.mjs";
|
|
5
5
|
import {
|
|
6
6
|
diffConfigs
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3MGBJU2R.mjs";
|
|
8
8
|
import {
|
|
9
9
|
resolveTsPathPattern
|
|
10
10
|
} from "./chunk-RPIVZP2I.mjs";
|
|
@@ -269,13 +269,22 @@ var validateBreakpoints = (breakpoints, addError) => {
|
|
|
269
269
|
};
|
|
270
270
|
|
|
271
271
|
// src/validation/validate-condition.ts
|
|
272
|
+
import { isString } from "@pandacss/shared";
|
|
272
273
|
var validateConditions = (conditions, addError) => {
|
|
273
274
|
if (!conditions)
|
|
274
275
|
return;
|
|
275
276
|
Object.values(conditions).forEach((condition) => {
|
|
276
|
-
if (
|
|
277
|
-
|
|
277
|
+
if (isString(condition)) {
|
|
278
|
+
if (!condition.startsWith("@") && !condition.includes("&")) {
|
|
279
|
+
addError("conditions", `Selectors should contain the \`&\` character: \`${condition}\``);
|
|
280
|
+
}
|
|
281
|
+
return;
|
|
278
282
|
}
|
|
283
|
+
condition.forEach((c) => {
|
|
284
|
+
if (!c.startsWith("@") && !c.includes("&")) {
|
|
285
|
+
addError("conditions", `Selectors should contain the \`&\` character: \`${c}\``);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
279
288
|
});
|
|
280
289
|
};
|
|
281
290
|
|
|
@@ -480,15 +489,15 @@ async function resolveConfig(result, cwd) {
|
|
|
480
489
|
presets.add(presetPanda);
|
|
481
490
|
}
|
|
482
491
|
result.config.presets = Array.from(presets);
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
492
|
+
const mergedConfig = await getResolvedConfig(result.config, cwd);
|
|
493
|
+
const hooks = mergedConfig.hooks ?? {};
|
|
494
|
+
if (mergedConfig.logLevel) {
|
|
495
|
+
logger3.level = mergedConfig.logLevel;
|
|
486
496
|
}
|
|
487
|
-
validateConfig(
|
|
488
|
-
const { hooks = {} } = result.config;
|
|
497
|
+
validateConfig(mergedConfig);
|
|
489
498
|
const loadConfigResult = {
|
|
490
499
|
...result,
|
|
491
|
-
config
|
|
500
|
+
config: mergedConfig
|
|
492
501
|
};
|
|
493
502
|
if (hooks["config:resolved"]) {
|
|
494
503
|
const result2 = await hooks["config:resolved"]({
|
package/dist/merge-config.js
CHANGED
|
@@ -25,6 +25,74 @@ __export(merge_config_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(merge_config_exports);
|
|
26
26
|
var import_merge_anything = require("merge-anything");
|
|
27
27
|
|
|
28
|
+
// src/merge-hooks.ts
|
|
29
|
+
var import_logger = require("@pandacss/logger");
|
|
30
|
+
var mergeHooks = (plugins) => {
|
|
31
|
+
const hooksFns = {};
|
|
32
|
+
plugins.forEach(({ name, hooks }) => {
|
|
33
|
+
Object.entries(hooks ?? {}).forEach(([key, value]) => {
|
|
34
|
+
if (!hooksFns[key]) {
|
|
35
|
+
hooksFns[key] = [];
|
|
36
|
+
}
|
|
37
|
+
hooksFns[key].push([name, value]);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
const mergedHooks = Object.fromEntries(
|
|
41
|
+
Object.entries(hooksFns).map(([key, entries]) => {
|
|
42
|
+
const fns = entries.map(([name, fn]) => tryCatch(name, fn));
|
|
43
|
+
if (key === "cssgen:done") {
|
|
44
|
+
return [key, reducers["cssgen:done"](fns)];
|
|
45
|
+
}
|
|
46
|
+
if (key === "codegen:prepare") {
|
|
47
|
+
return [key, reducers["codegen:prepare"](fns)];
|
|
48
|
+
}
|
|
49
|
+
return [key, syncHooks.includes(key) ? callAll(...fns) : callAllAsync(...fns)];
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
return mergedHooks;
|
|
53
|
+
};
|
|
54
|
+
var reducers = {
|
|
55
|
+
"cssgen:done": (fns) => (args) => {
|
|
56
|
+
let content = args.content;
|
|
57
|
+
for (const hookFn of fns) {
|
|
58
|
+
const result = hookFn({ ...args, content, original: args.content });
|
|
59
|
+
if (result !== void 0) {
|
|
60
|
+
content = result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return content;
|
|
64
|
+
},
|
|
65
|
+
"codegen:prepare": (fns) => (args) => {
|
|
66
|
+
let artifacts = args.artifacts;
|
|
67
|
+
for (const hookFn of fns) {
|
|
68
|
+
const result = hookFn({ ...args, artifacts, original: args.artifacts });
|
|
69
|
+
if (result) {
|
|
70
|
+
artifacts = result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return artifacts;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var syncHooks = ["context:created", "parser:before", "parser:after", "cssgen:done"];
|
|
77
|
+
var callAllAsync = (...fns) => async (...a) => {
|
|
78
|
+
for (const fn of fns) {
|
|
79
|
+
await fn?.(...a);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var callAll = (...fns) => (...a) => {
|
|
83
|
+
fns.forEach((fn) => fn?.(...a));
|
|
84
|
+
};
|
|
85
|
+
var tryCatch = (name, fn) => {
|
|
86
|
+
return (...args) => {
|
|
87
|
+
try {
|
|
88
|
+
return fn(...args);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
import_logger.logger.error("hooks", `The error below comes from the plugin ${name}`);
|
|
91
|
+
console.error(e);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
28
96
|
// src/utils.ts
|
|
29
97
|
var import_shared = require("@pandacss/shared");
|
|
30
98
|
var isObject = (v) => Object.prototype.toString.call(v) === "[object Object]";
|
|
@@ -98,6 +166,11 @@ var compact = (obj) => {
|
|
|
98
166
|
}, {});
|
|
99
167
|
};
|
|
100
168
|
function mergeConfigs(configs) {
|
|
169
|
+
const [userConfig] = configs;
|
|
170
|
+
const pluginHooks = userConfig.plugins ?? [];
|
|
171
|
+
if (userConfig.hooks) {
|
|
172
|
+
pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
|
|
173
|
+
}
|
|
101
174
|
const mergedResult = assign(
|
|
102
175
|
{
|
|
103
176
|
conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
|
|
@@ -105,7 +178,8 @@ function mergeConfigs(configs) {
|
|
|
105
178
|
patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
|
|
106
179
|
utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
|
|
107
180
|
globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})),
|
|
108
|
-
staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {}))
|
|
181
|
+
staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})),
|
|
182
|
+
hooks: mergeHooks(pluginHooks)
|
|
109
183
|
},
|
|
110
184
|
...configs
|
|
111
185
|
);
|
package/dist/merge-config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"description": "Find and load panda config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"merge-anything": "5.1.7",
|
|
65
65
|
"microdiff": "1.3.2",
|
|
66
66
|
"typescript": "5.3.3",
|
|
67
|
-
"@pandacss/logger": "0.
|
|
68
|
-
"@pandacss/preset-base": "0.
|
|
69
|
-
"@pandacss/preset-panda": "0.
|
|
70
|
-
"@pandacss/shared": "0.
|
|
71
|
-
"@pandacss/types": "0.
|
|
67
|
+
"@pandacss/logger": "0.32.1",
|
|
68
|
+
"@pandacss/preset-base": "0.32.1",
|
|
69
|
+
"@pandacss/preset-panda": "0.32.1",
|
|
70
|
+
"@pandacss/shared": "0.32.1",
|
|
71
|
+
"@pandacss/types": "0.32.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"pkg-types": "1.0.3"
|