@pandacss/config 0.36.1 → 0.37.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-IMFODN4N.mjs → chunk-GR4POVOJ.mjs} +19 -1
- package/dist/index.js +85 -28
- package/dist/index.mjs +57 -18
- package/dist/merge-config.js +19 -1
- package/dist/merge-config.mjs +1 -1
- package/package.json +6 -6
|
@@ -52,6 +52,18 @@ var reducers = {
|
|
|
52
52
|
}
|
|
53
53
|
return content;
|
|
54
54
|
}),
|
|
55
|
+
"parser:preprocess": createReducer((fns) => (_args) => {
|
|
56
|
+
const args = Object.assign({}, _args);
|
|
57
|
+
const original = _args.data;
|
|
58
|
+
let data = args.data;
|
|
59
|
+
for (const hookFn of fns) {
|
|
60
|
+
const result = hookFn(Object.assign(args, { data, original }));
|
|
61
|
+
if (result !== void 0) {
|
|
62
|
+
data = result;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}),
|
|
55
67
|
"cssgen:done": createReducer((fns) => (_args) => {
|
|
56
68
|
const args = Object.assign({}, _args);
|
|
57
69
|
const original = _args.content;
|
|
@@ -77,7 +89,13 @@ var reducers = {
|
|
|
77
89
|
return artifacts;
|
|
78
90
|
})
|
|
79
91
|
};
|
|
80
|
-
var syncHooks = [
|
|
92
|
+
var syncHooks = [
|
|
93
|
+
"context:created",
|
|
94
|
+
"parser:before",
|
|
95
|
+
"parser:preprocess",
|
|
96
|
+
"parser:after",
|
|
97
|
+
"cssgen:done"
|
|
98
|
+
];
|
|
81
99
|
var callAllAsync = (...fns) => async (...a) => {
|
|
82
100
|
for (const fn of fns) {
|
|
83
101
|
await fn?.(...a);
|
package/dist/index.js
CHANGED
|
@@ -435,6 +435,18 @@ var reducers = {
|
|
|
435
435
|
}
|
|
436
436
|
return content;
|
|
437
437
|
}),
|
|
438
|
+
"parser:preprocess": createReducer((fns) => (_args) => {
|
|
439
|
+
const args = Object.assign({}, _args);
|
|
440
|
+
const original = _args.data;
|
|
441
|
+
let data = args.data;
|
|
442
|
+
for (const hookFn of fns) {
|
|
443
|
+
const result = hookFn(Object.assign(args, { data, original }));
|
|
444
|
+
if (result !== void 0) {
|
|
445
|
+
data = result;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return data;
|
|
449
|
+
}),
|
|
438
450
|
"cssgen:done": createReducer((fns) => (_args) => {
|
|
439
451
|
const args = Object.assign({}, _args);
|
|
440
452
|
const original = _args.content;
|
|
@@ -460,7 +472,13 @@ var reducers = {
|
|
|
460
472
|
return artifacts;
|
|
461
473
|
})
|
|
462
474
|
};
|
|
463
|
-
var syncHooks = [
|
|
475
|
+
var syncHooks = [
|
|
476
|
+
"context:created",
|
|
477
|
+
"parser:before",
|
|
478
|
+
"parser:preprocess",
|
|
479
|
+
"parser:after",
|
|
480
|
+
"cssgen:done"
|
|
481
|
+
];
|
|
464
482
|
var callAllAsync = (...fns) => async (...a) => {
|
|
465
483
|
for (const fn of fns) {
|
|
466
484
|
await fn?.(...a);
|
|
@@ -582,7 +600,7 @@ async function getResolvedConfig(config, cwd) {
|
|
|
582
600
|
|
|
583
601
|
// src/resolve-config.ts
|
|
584
602
|
var import_logger4 = require("@pandacss/logger");
|
|
585
|
-
var
|
|
603
|
+
var import_shared10 = require("@pandacss/shared");
|
|
586
604
|
|
|
587
605
|
// src/bundled-preset.ts
|
|
588
606
|
var import_preset_base = require("@pandacss/preset-base");
|
|
@@ -600,21 +618,21 @@ var getBundledPreset = (preset) => {
|
|
|
600
618
|
|
|
601
619
|
// src/validate-config.ts
|
|
602
620
|
var import_logger3 = require("@pandacss/logger");
|
|
603
|
-
var
|
|
621
|
+
var import_shared9 = require("@pandacss/shared");
|
|
604
622
|
|
|
605
623
|
// src/validation/validate-artifact.ts
|
|
606
624
|
var validateArtifactNames = (names, addError) => {
|
|
607
625
|
names.recipes.forEach((recipeName) => {
|
|
608
626
|
if (names.slotRecipes.has(recipeName)) {
|
|
609
|
-
addError("recipes", `This recipe name is already used in \`
|
|
627
|
+
addError("recipes", `This recipe name is already used in \`theme.slotRecipes\`: ${recipeName}`);
|
|
610
628
|
}
|
|
611
629
|
if (names.patterns.has(recipeName)) {
|
|
612
|
-
addError("recipes", `This recipe name is already used in \`
|
|
630
|
+
addError("recipes", `This recipe name is already used in \`patterns\`: \`${recipeName}\``);
|
|
613
631
|
}
|
|
614
632
|
});
|
|
615
633
|
names.slotRecipes.forEach((recipeName) => {
|
|
616
634
|
if (names.patterns.has(recipeName)) {
|
|
617
|
-
addError("recipes", `This recipe name is already used in \`
|
|
635
|
+
addError("recipes", `This recipe name is already used in \`patterns\`: ${recipeName}`);
|
|
618
636
|
}
|
|
619
637
|
});
|
|
620
638
|
};
|
|
@@ -686,16 +704,42 @@ var validateRecipes = (options) => {
|
|
|
686
704
|
};
|
|
687
705
|
|
|
688
706
|
// src/validation/validate-tokens.ts
|
|
689
|
-
var
|
|
707
|
+
var import_shared8 = require("@pandacss/shared");
|
|
690
708
|
|
|
691
709
|
// src/validation/utils.ts
|
|
710
|
+
var import_shared7 = require("@pandacss/shared");
|
|
711
|
+
var REFERENCE_REGEX = /({([^}]*)})/g;
|
|
712
|
+
var curlyBracketRegex = /[{}]/g;
|
|
692
713
|
var isValidToken = (token) => Object.hasOwnProperty.call(token, "value");
|
|
693
|
-
var isTokenReference = (value) => typeof value === "string" &&
|
|
714
|
+
var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
|
|
694
715
|
var formatPath = (path2) => path2;
|
|
695
716
|
var SEP = ".";
|
|
717
|
+
function getReferences(value) {
|
|
718
|
+
if (typeof value !== "string")
|
|
719
|
+
return [];
|
|
720
|
+
const matches = value.match(REFERENCE_REGEX);
|
|
721
|
+
if (!matches)
|
|
722
|
+
return [];
|
|
723
|
+
return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
|
|
724
|
+
return value2.trim().split("/")[0];
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
var serializeTokenValue = (value) => {
|
|
728
|
+
if ((0, import_shared7.isString)(value)) {
|
|
729
|
+
return value;
|
|
730
|
+
}
|
|
731
|
+
if ((0, import_shared7.isObject)(value)) {
|
|
732
|
+
return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
|
|
733
|
+
}
|
|
734
|
+
if (Array.isArray(value)) {
|
|
735
|
+
return value.map((v) => serializeTokenValue(v)).join(" ");
|
|
736
|
+
}
|
|
737
|
+
return value.toString();
|
|
738
|
+
};
|
|
696
739
|
|
|
697
740
|
// src/validation/validate-token-references.ts
|
|
698
|
-
var validateTokenReferences = (
|
|
741
|
+
var validateTokenReferences = (props) => {
|
|
742
|
+
const { valueAtPath, refsByPath, addError, typeByPath } = props;
|
|
699
743
|
refsByPath.forEach((refs, path2) => {
|
|
700
744
|
if (refs.has(path2)) {
|
|
701
745
|
addError("tokens", `Self token reference: \`${path2}\``);
|
|
@@ -709,7 +753,8 @@ var validateTokenReferences = (valueAtPath, refsByPath, addError) => {
|
|
|
709
753
|
}
|
|
710
754
|
const value = valueAtPath.get(currentPath);
|
|
711
755
|
if (!value) {
|
|
712
|
-
|
|
756
|
+
const configKey = typeByPath.get(path2);
|
|
757
|
+
addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path2}\``);
|
|
713
758
|
}
|
|
714
759
|
if (isTokenReference(value) && !refsByPath.has(value)) {
|
|
715
760
|
addError("tokens", `Unknown token reference: \`${currentPath}\` used in \`${value}\``);
|
|
@@ -740,10 +785,10 @@ var validateTokens = (options) => {
|
|
|
740
785
|
} = options;
|
|
741
786
|
if (!theme)
|
|
742
787
|
return;
|
|
743
|
-
const { tokenNames, semanticTokenNames, valueAtPath, refsByPath } = tokens2;
|
|
788
|
+
const { tokenNames, semanticTokenNames, valueAtPath, refsByPath, typeByPath } = tokens2;
|
|
744
789
|
if (theme.tokens) {
|
|
745
790
|
const tokenPaths = /* @__PURE__ */ new Set();
|
|
746
|
-
(0,
|
|
791
|
+
(0, import_shared8.walkObject)(
|
|
747
792
|
theme.tokens,
|
|
748
793
|
(value, paths) => {
|
|
749
794
|
const path2 = paths.join(SEP);
|
|
@@ -759,9 +804,10 @@ var validateTokens = (options) => {
|
|
|
759
804
|
}
|
|
760
805
|
);
|
|
761
806
|
tokenPaths.forEach((path2) => {
|
|
762
|
-
const
|
|
807
|
+
const itemValue = valueAtPath.get(path2);
|
|
763
808
|
const formattedPath = formatPath(path2);
|
|
764
|
-
|
|
809
|
+
typeByPath.set(formattedPath, "tokens");
|
|
810
|
+
if (!isValidToken(itemValue)) {
|
|
765
811
|
addError("tokens", `Token must contain 'value': \`theme.tokens.${formattedPath}\``);
|
|
766
812
|
return;
|
|
767
813
|
}
|
|
@@ -769,14 +815,21 @@ var validateTokens = (options) => {
|
|
|
769
815
|
addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
|
|
770
816
|
return;
|
|
771
817
|
}
|
|
772
|
-
|
|
818
|
+
const valueStr = serializeTokenValue(itemValue.value || itemValue);
|
|
819
|
+
if (isTokenReference(valueStr)) {
|
|
773
820
|
refsByPath.set(formattedPath, /* @__PURE__ */ new Set([]));
|
|
774
821
|
}
|
|
822
|
+
const references = refsByPath.get(formattedPath);
|
|
823
|
+
if (!references)
|
|
824
|
+
return;
|
|
825
|
+
getReferences(valueStr).forEach((reference) => {
|
|
826
|
+
references.add(reference);
|
|
827
|
+
});
|
|
775
828
|
});
|
|
776
829
|
}
|
|
777
830
|
if (theme.semanticTokens) {
|
|
778
831
|
const tokenPaths = /* @__PURE__ */ new Set();
|
|
779
|
-
(0,
|
|
832
|
+
(0, import_shared8.walkObject)(
|
|
780
833
|
theme.semanticTokens,
|
|
781
834
|
(value, paths) => {
|
|
782
835
|
const path2 = paths.join(SEP);
|
|
@@ -788,22 +841,25 @@ var validateTokens = (options) => {
|
|
|
788
841
|
}
|
|
789
842
|
if (!isValidToken(value))
|
|
790
843
|
return;
|
|
791
|
-
(0,
|
|
844
|
+
(0, import_shared8.walkObject)(value, (itemValue, paths2) => {
|
|
792
845
|
const valuePath = paths2.join(SEP);
|
|
793
846
|
const formattedPath = formatPath(path2);
|
|
847
|
+
typeByPath.set(formattedPath, "semanticTokens");
|
|
794
848
|
const fullPath = formattedPath + "." + paths2.join(SEP);
|
|
795
849
|
if (valuePath.includes("value" + SEP + "value")) {
|
|
796
850
|
addError("tokens", `You used \`value\` twice resulting in an invalid token \`theme.tokens.${fullPath}\``);
|
|
797
851
|
}
|
|
798
|
-
|
|
852
|
+
const valueStr = serializeTokenValue(itemValue.value || itemValue);
|
|
853
|
+
if (isTokenReference(valueStr)) {
|
|
799
854
|
if (!refsByPath.has(formattedPath)) {
|
|
800
855
|
refsByPath.set(formattedPath, /* @__PURE__ */ new Set());
|
|
801
856
|
}
|
|
802
857
|
const references = refsByPath.get(formattedPath);
|
|
803
858
|
if (!references)
|
|
804
859
|
return;
|
|
805
|
-
|
|
806
|
-
|
|
860
|
+
getReferences(valueStr).forEach((reference) => {
|
|
861
|
+
references.add(reference);
|
|
862
|
+
});
|
|
807
863
|
}
|
|
808
864
|
});
|
|
809
865
|
},
|
|
@@ -818,12 +874,12 @@ var validateTokens = (options) => {
|
|
|
818
874
|
addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
|
|
819
875
|
return;
|
|
820
876
|
}
|
|
821
|
-
if (!(0,
|
|
877
|
+
if (!(0, import_shared8.isObject)(value) && !path2.includes("value")) {
|
|
822
878
|
addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
|
|
823
879
|
}
|
|
824
880
|
});
|
|
825
|
-
validateTokenReferences(valueAtPath, refsByPath, addError);
|
|
826
881
|
}
|
|
882
|
+
validateTokenReferences({ valueAtPath, refsByPath, addError, typeByPath });
|
|
827
883
|
};
|
|
828
884
|
|
|
829
885
|
// src/validate-config.ts
|
|
@@ -845,7 +901,8 @@ var validateConfig = (config) => {
|
|
|
845
901
|
tokenNames: /* @__PURE__ */ new Set(),
|
|
846
902
|
semanticTokenNames: /* @__PURE__ */ new Set(),
|
|
847
903
|
valueAtPath: /* @__PURE__ */ new Map(),
|
|
848
|
-
refsByPath: /* @__PURE__ */ new Map()
|
|
904
|
+
refsByPath: /* @__PURE__ */ new Map(),
|
|
905
|
+
typeByPath: /* @__PURE__ */ new Map()
|
|
849
906
|
};
|
|
850
907
|
if (config.theme) {
|
|
851
908
|
validateTokens({ config, tokens: tokens2, addError });
|
|
@@ -858,7 +915,7 @@ var validateConfig = (config) => {
|
|
|
858
915
|
${Array.from(warnings).map((err) => "- " + err).join("\n")}
|
|
859
916
|
`;
|
|
860
917
|
if (config.validation === "error") {
|
|
861
|
-
throw new
|
|
918
|
+
throw new import_shared9.PandaError("CONFIG_ERROR", errors);
|
|
862
919
|
}
|
|
863
920
|
import_logger3.logger.warn("config", errors);
|
|
864
921
|
return warnings;
|
|
@@ -867,8 +924,8 @@ ${Array.from(warnings).map((err) => "- " + err).join("\n")}
|
|
|
867
924
|
|
|
868
925
|
// src/resolve-config.ts
|
|
869
926
|
var hookUtils = {
|
|
870
|
-
omit:
|
|
871
|
-
traverse:
|
|
927
|
+
omit: import_shared10.omit,
|
|
928
|
+
traverse: import_shared10.traverse
|
|
872
929
|
};
|
|
873
930
|
async function resolveConfig(result, cwd) {
|
|
874
931
|
const presets = /* @__PURE__ */ new Set();
|
|
@@ -904,8 +961,8 @@ async function resolveConfig(result, cwd) {
|
|
|
904
961
|
loadConfigResult.config = result2;
|
|
905
962
|
}
|
|
906
963
|
}
|
|
907
|
-
const serialized = (0,
|
|
908
|
-
const deserialize = () => (0,
|
|
964
|
+
const serialized = (0, import_shared10.stringifyJson)(loadConfigResult.config);
|
|
965
|
+
const deserialize = () => (0, import_shared10.parseJson)(serialized);
|
|
909
966
|
return { ...loadConfigResult, serialized, deserialize, hooks };
|
|
910
967
|
}
|
|
911
968
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mergeConfigs
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GR4POVOJ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
diffConfigs
|
|
6
6
|
} from "./chunk-D3CL3VYD.mjs";
|
|
@@ -238,15 +238,15 @@ import { PandaError as PandaError3 } from "@pandacss/shared";
|
|
|
238
238
|
var validateArtifactNames = (names, addError) => {
|
|
239
239
|
names.recipes.forEach((recipeName) => {
|
|
240
240
|
if (names.slotRecipes.has(recipeName)) {
|
|
241
|
-
addError("recipes", `This recipe name is already used in \`
|
|
241
|
+
addError("recipes", `This recipe name is already used in \`theme.slotRecipes\`: ${recipeName}`);
|
|
242
242
|
}
|
|
243
243
|
if (names.patterns.has(recipeName)) {
|
|
244
|
-
addError("recipes", `This recipe name is already used in \`
|
|
244
|
+
addError("recipes", `This recipe name is already used in \`patterns\`: \`${recipeName}\``);
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
names.slotRecipes.forEach((recipeName) => {
|
|
248
248
|
if (names.patterns.has(recipeName)) {
|
|
249
|
-
addError("recipes", `This recipe name is already used in \`
|
|
249
|
+
addError("recipes", `This recipe name is already used in \`patterns\`: ${recipeName}`);
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
};
|
|
@@ -318,16 +318,42 @@ var validateRecipes = (options) => {
|
|
|
318
318
|
};
|
|
319
319
|
|
|
320
320
|
// src/validation/validate-tokens.ts
|
|
321
|
-
import { isObject, walkObject } from "@pandacss/shared";
|
|
321
|
+
import { isObject as isObject2, walkObject } from "@pandacss/shared";
|
|
322
322
|
|
|
323
323
|
// src/validation/utils.ts
|
|
324
|
+
import { isObject, isString as isString2 } from "@pandacss/shared";
|
|
325
|
+
var REFERENCE_REGEX = /({([^}]*)})/g;
|
|
326
|
+
var curlyBracketRegex = /[{}]/g;
|
|
324
327
|
var isValidToken = (token) => Object.hasOwnProperty.call(token, "value");
|
|
325
|
-
var isTokenReference = (value) => typeof value === "string" &&
|
|
328
|
+
var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
|
|
326
329
|
var formatPath = (path2) => path2;
|
|
327
330
|
var SEP = ".";
|
|
331
|
+
function getReferences(value) {
|
|
332
|
+
if (typeof value !== "string")
|
|
333
|
+
return [];
|
|
334
|
+
const matches = value.match(REFERENCE_REGEX);
|
|
335
|
+
if (!matches)
|
|
336
|
+
return [];
|
|
337
|
+
return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
|
|
338
|
+
return value2.trim().split("/")[0];
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
var serializeTokenValue = (value) => {
|
|
342
|
+
if (isString2(value)) {
|
|
343
|
+
return value;
|
|
344
|
+
}
|
|
345
|
+
if (isObject(value)) {
|
|
346
|
+
return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
|
|
347
|
+
}
|
|
348
|
+
if (Array.isArray(value)) {
|
|
349
|
+
return value.map((v) => serializeTokenValue(v)).join(" ");
|
|
350
|
+
}
|
|
351
|
+
return value.toString();
|
|
352
|
+
};
|
|
328
353
|
|
|
329
354
|
// src/validation/validate-token-references.ts
|
|
330
|
-
var validateTokenReferences = (
|
|
355
|
+
var validateTokenReferences = (props) => {
|
|
356
|
+
const { valueAtPath, refsByPath, addError, typeByPath } = props;
|
|
331
357
|
refsByPath.forEach((refs, path2) => {
|
|
332
358
|
if (refs.has(path2)) {
|
|
333
359
|
addError("tokens", `Self token reference: \`${path2}\``);
|
|
@@ -341,7 +367,8 @@ var validateTokenReferences = (valueAtPath, refsByPath, addError) => {
|
|
|
341
367
|
}
|
|
342
368
|
const value = valueAtPath.get(currentPath);
|
|
343
369
|
if (!value) {
|
|
344
|
-
|
|
370
|
+
const configKey = typeByPath.get(path2);
|
|
371
|
+
addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path2}\``);
|
|
345
372
|
}
|
|
346
373
|
if (isTokenReference(value) && !refsByPath.has(value)) {
|
|
347
374
|
addError("tokens", `Unknown token reference: \`${currentPath}\` used in \`${value}\``);
|
|
@@ -372,7 +399,7 @@ var validateTokens = (options) => {
|
|
|
372
399
|
} = options;
|
|
373
400
|
if (!theme)
|
|
374
401
|
return;
|
|
375
|
-
const { tokenNames, semanticTokenNames, valueAtPath, refsByPath } = tokens;
|
|
402
|
+
const { tokenNames, semanticTokenNames, valueAtPath, refsByPath, typeByPath } = tokens;
|
|
376
403
|
if (theme.tokens) {
|
|
377
404
|
const tokenPaths = /* @__PURE__ */ new Set();
|
|
378
405
|
walkObject(
|
|
@@ -391,9 +418,10 @@ var validateTokens = (options) => {
|
|
|
391
418
|
}
|
|
392
419
|
);
|
|
393
420
|
tokenPaths.forEach((path2) => {
|
|
394
|
-
const
|
|
421
|
+
const itemValue = valueAtPath.get(path2);
|
|
395
422
|
const formattedPath = formatPath(path2);
|
|
396
|
-
|
|
423
|
+
typeByPath.set(formattedPath, "tokens");
|
|
424
|
+
if (!isValidToken(itemValue)) {
|
|
397
425
|
addError("tokens", `Token must contain 'value': \`theme.tokens.${formattedPath}\``);
|
|
398
426
|
return;
|
|
399
427
|
}
|
|
@@ -401,9 +429,16 @@ var validateTokens = (options) => {
|
|
|
401
429
|
addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
|
|
402
430
|
return;
|
|
403
431
|
}
|
|
404
|
-
|
|
432
|
+
const valueStr = serializeTokenValue(itemValue.value || itemValue);
|
|
433
|
+
if (isTokenReference(valueStr)) {
|
|
405
434
|
refsByPath.set(formattedPath, /* @__PURE__ */ new Set([]));
|
|
406
435
|
}
|
|
436
|
+
const references = refsByPath.get(formattedPath);
|
|
437
|
+
if (!references)
|
|
438
|
+
return;
|
|
439
|
+
getReferences(valueStr).forEach((reference) => {
|
|
440
|
+
references.add(reference);
|
|
441
|
+
});
|
|
407
442
|
});
|
|
408
443
|
}
|
|
409
444
|
if (theme.semanticTokens) {
|
|
@@ -423,19 +458,22 @@ var validateTokens = (options) => {
|
|
|
423
458
|
walkObject(value, (itemValue, paths2) => {
|
|
424
459
|
const valuePath = paths2.join(SEP);
|
|
425
460
|
const formattedPath = formatPath(path2);
|
|
461
|
+
typeByPath.set(formattedPath, "semanticTokens");
|
|
426
462
|
const fullPath = formattedPath + "." + paths2.join(SEP);
|
|
427
463
|
if (valuePath.includes("value" + SEP + "value")) {
|
|
428
464
|
addError("tokens", `You used \`value\` twice resulting in an invalid token \`theme.tokens.${fullPath}\``);
|
|
429
465
|
}
|
|
430
|
-
|
|
466
|
+
const valueStr = serializeTokenValue(itemValue.value || itemValue);
|
|
467
|
+
if (isTokenReference(valueStr)) {
|
|
431
468
|
if (!refsByPath.has(formattedPath)) {
|
|
432
469
|
refsByPath.set(formattedPath, /* @__PURE__ */ new Set());
|
|
433
470
|
}
|
|
434
471
|
const references = refsByPath.get(formattedPath);
|
|
435
472
|
if (!references)
|
|
436
473
|
return;
|
|
437
|
-
|
|
438
|
-
|
|
474
|
+
getReferences(valueStr).forEach((reference) => {
|
|
475
|
+
references.add(reference);
|
|
476
|
+
});
|
|
439
477
|
}
|
|
440
478
|
});
|
|
441
479
|
},
|
|
@@ -450,12 +488,12 @@ var validateTokens = (options) => {
|
|
|
450
488
|
addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
|
|
451
489
|
return;
|
|
452
490
|
}
|
|
453
|
-
if (!
|
|
491
|
+
if (!isObject2(value) && !path2.includes("value")) {
|
|
454
492
|
addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
|
|
455
493
|
}
|
|
456
494
|
});
|
|
457
|
-
validateTokenReferences(valueAtPath, refsByPath, addError);
|
|
458
495
|
}
|
|
496
|
+
validateTokenReferences({ valueAtPath, refsByPath, addError, typeByPath });
|
|
459
497
|
};
|
|
460
498
|
|
|
461
499
|
// src/validate-config.ts
|
|
@@ -477,7 +515,8 @@ var validateConfig = (config) => {
|
|
|
477
515
|
tokenNames: /* @__PURE__ */ new Set(),
|
|
478
516
|
semanticTokenNames: /* @__PURE__ */ new Set(),
|
|
479
517
|
valueAtPath: /* @__PURE__ */ new Map(),
|
|
480
|
-
refsByPath: /* @__PURE__ */ new Map()
|
|
518
|
+
refsByPath: /* @__PURE__ */ new Map(),
|
|
519
|
+
typeByPath: /* @__PURE__ */ new Map()
|
|
481
520
|
};
|
|
482
521
|
if (config.theme) {
|
|
483
522
|
validateTokens({ config, tokens, addError });
|
package/dist/merge-config.js
CHANGED
|
@@ -76,6 +76,18 @@ var reducers = {
|
|
|
76
76
|
}
|
|
77
77
|
return content;
|
|
78
78
|
}),
|
|
79
|
+
"parser:preprocess": createReducer((fns) => (_args) => {
|
|
80
|
+
const args = Object.assign({}, _args);
|
|
81
|
+
const original = _args.data;
|
|
82
|
+
let data = args.data;
|
|
83
|
+
for (const hookFn of fns) {
|
|
84
|
+
const result = hookFn(Object.assign(args, { data, original }));
|
|
85
|
+
if (result !== void 0) {
|
|
86
|
+
data = result;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return data;
|
|
90
|
+
}),
|
|
79
91
|
"cssgen:done": createReducer((fns) => (_args) => {
|
|
80
92
|
const args = Object.assign({}, _args);
|
|
81
93
|
const original = _args.content;
|
|
@@ -101,7 +113,13 @@ var reducers = {
|
|
|
101
113
|
return artifacts;
|
|
102
114
|
})
|
|
103
115
|
};
|
|
104
|
-
var syncHooks = [
|
|
116
|
+
var syncHooks = [
|
|
117
|
+
"context:created",
|
|
118
|
+
"parser:before",
|
|
119
|
+
"parser:preprocess",
|
|
120
|
+
"parser:after",
|
|
121
|
+
"cssgen:done"
|
|
122
|
+
];
|
|
105
123
|
var callAllAsync = (...fns) => async (...a) => {
|
|
106
124
|
for (const fn of fns) {
|
|
107
125
|
await fn?.(...a);
|
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.37.1",
|
|
4
4
|
"description": "Find and load panda config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"merge-anything": "5.1.7",
|
|
74
74
|
"microdiff": "1.3.2",
|
|
75
75
|
"typescript": "5.3.3",
|
|
76
|
-
"@pandacss/logger": "0.
|
|
77
|
-
"@pandacss/preset-base": "0.
|
|
78
|
-
"@pandacss/preset-panda": "0.
|
|
79
|
-
"@pandacss/shared": "0.
|
|
80
|
-
"@pandacss/types": "0.
|
|
76
|
+
"@pandacss/logger": "0.37.1",
|
|
77
|
+
"@pandacss/preset-base": "0.37.1",
|
|
78
|
+
"@pandacss/preset-panda": "0.37.1",
|
|
79
|
+
"@pandacss/shared": "0.37.1",
|
|
80
|
+
"@pandacss/types": "0.37.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"pkg-types": "1.0.3"
|