@tenphi/tasty 0.0.0-snapshot.b317d64 → 0.0.0-snapshot.b327cbd
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/README.md +413 -376
- package/dist/{babel-types-C_7kRP38.d.ts → babel-types-Dc5zghyE.d.ts} +2 -2
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/{build-config-BDLYGmKn.js → build-config--0qoqt_P.js} +5 -5
- package/dist/chunks/{build-config-BDLYGmKn.js.map → build-config--0qoqt_P.js.map} +1 -1
- package/dist/chunks/{collector-DqcB0UUT.js → collector-zp5BrLF0.js} +4 -4
- package/dist/chunks/{collector-DqcB0UUT.js.map → collector-zp5BrLF0.js.map} +1 -1
- package/dist/chunks/{config-engine-CGIMO2PV.js → config-engine-BaLq8HrX.js} +5 -5
- package/dist/chunks/config-engine-BaLq8HrX.js.map +1 -0
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/{css-definitions-BibU6ZnP.js → css-definitions-CfXZ3tU9.js} +88 -82
- package/dist/chunks/css-definitions-CfXZ3tU9.js.map +1 -0
- package/dist/chunks/{debug-Dy36S1sU.js → debug--OC-WA-Q.js} +6 -6
- package/dist/chunks/{debug-Dy36S1sU.js.map → debug--OC-WA-Q.js.map} +1 -1
- package/dist/chunks/{dsl-DRhFWQzo.js → dsl-CsFl9LGn.js} +132 -52
- package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
- package/dist/chunks/{react-runtime-BljxMd6C.js → react-runtime-DnZ6M1Iv.js} +171 -62
- package/dist/chunks/react-runtime-DnZ6M1Iv.js.map +1 -0
- package/dist/chunks/{runtime-engine-CPYI2bA8.js → runtime-engine-J9X_h-Pw.js} +56 -36
- package/dist/chunks/runtime-engine-J9X_h-Pw.js.map +1 -0
- package/dist/chunks/{runtime-state-C0u1jp-Q.js → runtime-state-o_v3Bj7b.js} +14 -3
- package/dist/chunks/runtime-state-o_v3Bj7b.js.map +1 -0
- package/dist/chunks/{style-engine-D35rvcdB.js → style-engine-D6lC3O3G.js} +325 -119
- package/dist/chunks/style-engine-D6lC3O3G.js.map +1 -0
- package/dist/chunks/{zero-engine-b--JCZad.js → zero-engine-BnjoV04F.js} +22 -7
- package/dist/chunks/zero-engine-BnjoV04F.js.map +1 -0
- package/dist/{collector-w4mBj5gd.d.ts → collector-D2OT6I2G.d.ts} +2 -2
- package/dist/{config-CrZOfNJ5.d.ts → config-C4ftFxgI.d.ts} +34 -16
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +7 -7
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-CYJtAI9a.d.ts → index-DxQNRj50.d.ts} +65 -21
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -8
- package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-D39qBtox.d.ts} +2 -2
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +3 -22
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +6 -17
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +3 -3
- package/dist/static/index.d.ts +2 -2
- package/dist/{types-JEY8PVYP.d.ts → types-CYQIhUg1.d.ts} +10 -8
- package/dist/zero/babel.d.ts +9 -3
- package/dist/zero/babel.js +34 -23
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +25 -6
- package/dist/zero/index.js +5 -4
- package/dist/zero/index.js.map +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +3 -7
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +44 -35
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +186 -68
- package/docs/debug.md +3 -2
- package/docs/design-system.md +129 -15
- package/docs/dsl.md +278 -116
- package/docs/getting-started.md +81 -24
- package/docs/injector.md +41 -40
- package/docs/llms.txt +31 -0
- package/docs/methodology.md +46 -21
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +21 -18
- package/docs/plugins.md +21 -41
- package/docs/react-api.md +70 -14
- package/docs/runtime-benchmarks.md +4 -4
- package/docs/ssr.md +92 -66
- package/docs/styles.md +81 -15
- package/docs/tasty-static.md +143 -58
- package/harness/dev.harnesspm/rules/usage.md +12 -0
- package/harness/dev.harnesspm/scripts/render.mjs +329 -0
- package/harness/dev.harnesspm/scripts/styles.mjs +409 -0
- package/harness/plugin.json +20 -0
- package/package.json +54 -38
- package/tasty.config.ts +1 -0
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/config-engine-CGIMO2PV.js.map +0 -1
- package/dist/chunks/css-definitions-BibU6ZnP.js.map +0 -1
- package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
- package/dist/chunks/react-runtime-BljxMd6C.js.map +0 -1
- package/dist/chunks/runtime-engine-CPYI2bA8.js.map +0 -1
- package/dist/chunks/runtime-state-C0u1jp-Q.js.map +0 -1
- package/dist/chunks/style-engine-D35rvcdB.js.map +0 -1
- package/dist/chunks/zero-engine-b--JCZad.js.map +0 -1
|
@@ -73,10 +73,10 @@ function normalizeDslName(name) {
|
|
|
73
73
|
const lower = first.toLowerCase();
|
|
74
74
|
return lower === first ? name : lower + name.slice(1);
|
|
75
75
|
}
|
|
76
|
-
const RE_DSL_IDENTIFIER = /(
|
|
76
|
+
const RE_DSL_IDENTIFIER = /(\$\$?|##?|--)([a-zA-Z_][a-zA-Z0-9_-]*)/g;
|
|
77
77
|
function foldDslCase(src) {
|
|
78
78
|
const folded = src.toLowerCase();
|
|
79
|
-
if (folded === src || !src.includes("$") && !src.includes("#")) return folded;
|
|
79
|
+
if (folded === src || !src.includes("$") && !src.includes("#") && !src.includes("--")) return folded;
|
|
80
80
|
RE_DSL_IDENTIFIER.lastIndex = 0;
|
|
81
81
|
let out = "";
|
|
82
82
|
let last = 0;
|
|
@@ -84,7 +84,7 @@ function foldDslCase(src) {
|
|
|
84
84
|
while (match = RE_DSL_IDENTIFIER.exec(src)) {
|
|
85
85
|
const [whole, prefix, body] = match;
|
|
86
86
|
out += src.slice(last, match.index).toLowerCase();
|
|
87
|
-
out += prefix + (prefix[0] === "#" && RE_HEX.test(body.toLowerCase()) ? body.toLowerCase() : normalizeDslName(body));
|
|
87
|
+
out += prefix + (prefix === "--" ? body : prefix[0] === "#" && RE_HEX.test(body.toLowerCase()) ? body.toLowerCase() : normalizeDslName(body));
|
|
88
88
|
last = match.index + whole.length;
|
|
89
89
|
}
|
|
90
90
|
return out + src.slice(last).toLowerCase();
|
|
@@ -379,6 +379,11 @@ function getNamedColorHex() {
|
|
|
379
379
|
for (let i = 0; i < names.length; i++) colors.set(names[i], `#${hex.slice(i * 6, i * 6 + 6)}`);
|
|
380
380
|
return _namedColorHex = colors;
|
|
381
381
|
}
|
|
382
|
+
const SYSTEM_COLORS = new Set("accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext".split(" "));
|
|
383
|
+
function isColorKeyword(name) {
|
|
384
|
+
const lower = name.toLowerCase();
|
|
385
|
+
return getNamedColorHex().has(lower) || SYSTEM_COLORS.has(lower);
|
|
386
|
+
}
|
|
382
387
|
function hexToRgb(hex) {
|
|
383
388
|
const matched = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (_m, r, g, b) => "#" + r + r + g + g + b + b).substring(1).match(/.{2}/g);
|
|
384
389
|
if (!matched) return null;
|
|
@@ -458,20 +463,26 @@ function oklchStringToRgb(oklchStr) {
|
|
|
458
463
|
}
|
|
459
464
|
//#endregion
|
|
460
465
|
//#region src/utils/color-space.ts
|
|
461
|
-
function overrideColorAlpha(color, alpha) {
|
|
462
|
-
return `oklch(from ${color} l c h / ${alpha})`;
|
|
463
|
-
}
|
|
464
466
|
function mixColorAlpha(color, percentage) {
|
|
465
467
|
return `color-mix(in oklab, ${color} ${percentage}, transparent)`;
|
|
466
468
|
}
|
|
467
|
-
const
|
|
468
|
-
function
|
|
469
|
-
const match = value.match(
|
|
469
|
+
const RE_ALPHA_MIX = /^color-mix\(in oklab,\s*(.+) (\S+%|calc\(.+ \* 100%\)),\s*transparent\)$/;
|
|
470
|
+
function parseAlphaMix(value) {
|
|
471
|
+
const match = value.match(RE_ALPHA_MIX);
|
|
470
472
|
return match ? {
|
|
471
473
|
color: match[1],
|
|
472
|
-
|
|
474
|
+
percentage: match[2]
|
|
473
475
|
} : null;
|
|
474
476
|
}
|
|
477
|
+
const ZERO_ALPHA = String.raw`(?:0+(?:\.0*)?|\.0+)%?|none`;
|
|
478
|
+
const RE_SLASH_ZERO_ALPHA = new RegExp(String.raw`\/\s*(?:${ZERO_ALPHA})\s*\)$`, "i");
|
|
479
|
+
const RE_LEGACY_ZERO_ALPHA = new RegExp(String.raw`^(?:rgba|hsla)\([^(),]*,[^(),]*,[^(),]*,\s*(?:${ZERO_ALPHA})\s*\)$`, "i");
|
|
480
|
+
function isTransparent(color) {
|
|
481
|
+
return color === "transparent" || parseAlphaMix(color)?.percentage === "0%" || RE_SLASH_ZERO_ALPHA.test(color) || RE_LEGACY_ZERO_ALPHA.test(color);
|
|
482
|
+
}
|
|
483
|
+
function alphaToPercentage(alpha) {
|
|
484
|
+
return `${Number(((Number.isNaN(alpha) ? 1 : Math.min(1, Math.max(0, alpha))) * 100).toFixed(6))}%`;
|
|
485
|
+
}
|
|
475
486
|
//#endregion
|
|
476
487
|
//#region src/parser/types.ts
|
|
477
488
|
const makeEmptyPart = () => ({
|
|
@@ -492,28 +503,51 @@ const makeEmptyDetails = () => ({
|
|
|
492
503
|
});
|
|
493
504
|
//#endregion
|
|
494
505
|
//#region src/parser/classify.ts
|
|
495
|
-
function alphaSuffixToAlpha(rawAlpha) {
|
|
496
|
-
if (rawAlpha.startsWith("$")) return `var(--${rawAlpha.slice(1)})`;
|
|
497
|
-
if (rawAlpha === "0") return "0";
|
|
498
|
-
return `.${rawAlpha}`;
|
|
499
|
-
}
|
|
500
|
-
function fadeColor(color, rawAlpha) {
|
|
501
|
-
return overrideColorAlpha(color, alphaSuffixToAlpha(rawAlpha));
|
|
502
|
-
}
|
|
503
506
|
function alphaSuffixToPercentage(rawAlpha) {
|
|
504
507
|
if (rawAlpha.startsWith("$")) return `calc(var(--${rawAlpha.slice(1)}) * 100%)`;
|
|
505
508
|
if (rawAlpha === "0") return "0%";
|
|
506
509
|
const digits = rawAlpha.length === 1 ? `${rawAlpha}0` : rawAlpha;
|
|
507
510
|
const whole = String(Number(digits.slice(0, 2)));
|
|
508
|
-
const fraction = digits.slice(2);
|
|
511
|
+
const fraction = digits.slice(2).replace(/0+$/, "");
|
|
509
512
|
return `${fraction ? `${whole}.${fraction}` : whole}%`;
|
|
510
513
|
}
|
|
511
|
-
function
|
|
512
|
-
return mixColorAlpha(
|
|
514
|
+
function fadeColor(color, rawAlpha) {
|
|
515
|
+
return mixColorAlpha(color, alphaSuffixToPercentage(rawAlpha));
|
|
516
|
+
}
|
|
517
|
+
const ALPHA_SUFFIX = String.raw`(\$[a-z_][a-z0-9-_]*|[0-9]+)`;
|
|
518
|
+
const RE_CURRENT_ALPHA = new RegExp(`^#current\\.${ALPHA_SUFFIX}$`, "i");
|
|
519
|
+
const RE_TOKEN_ALPHA = new RegExp(`^(#[a-z0-9-]+)\\.${ALPHA_SUFFIX}$`, "i");
|
|
520
|
+
const RE_COLOR_LAYER = new RegExp(`^(#[a-z0-9-]+)(?:\\.${ALPHA_SUFFIX})?$`, "i");
|
|
521
|
+
function layerColors(token, opts, recurse) {
|
|
522
|
+
const operands = token.split("+").map((part) => part.match(RE_COLOR_LAYER));
|
|
523
|
+
if (operands.some((match) => !match)) return null;
|
|
524
|
+
const colorOf = (input) => {
|
|
525
|
+
const { bucket, processed } = classify(input, opts, recurse);
|
|
526
|
+
return bucket === 0 || bucket === 3 ? processed : null;
|
|
527
|
+
};
|
|
528
|
+
const [base, ...layers] = operands;
|
|
529
|
+
let result = colorOf(base[0]);
|
|
530
|
+
if (result === null) return null;
|
|
531
|
+
for (const [layerInput, name, rawAlpha] of layers) {
|
|
532
|
+
const color = colorOf(name);
|
|
533
|
+
if (color === null) return null;
|
|
534
|
+
if (isTransparent(color)) continue;
|
|
535
|
+
if (rawAlpha === void 0) {
|
|
536
|
+
warnOnceDev(`compound-color-opaque:${token}`, `"${token}": "${layerInput}" has no opacity, so it covers everything before it and the color is just "${layerInput}". Give the layer an opacity, such as "${layerInput}.04".`);
|
|
537
|
+
result = color;
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
const opacity = alphaSuffixToPercentage(rawAlpha);
|
|
541
|
+
if (opacity === "0%") continue;
|
|
542
|
+
result = isTransparent(result) ? mixColorAlpha(color, opacity) : `color-mix(in srgb, ${color} ${opacity}, ${result})`;
|
|
543
|
+
}
|
|
544
|
+
return result;
|
|
513
545
|
}
|
|
514
546
|
function hasColorArgs(parsed) {
|
|
515
|
-
|
|
516
|
-
|
|
547
|
+
return parsed.groups.some((group) => group.colors.length > 0);
|
|
548
|
+
}
|
|
549
|
+
function isSingleColor(group) {
|
|
550
|
+
return !!group && group.all.length === 1 && group.colors.length === 1;
|
|
517
551
|
}
|
|
518
552
|
function resolveUntilStable(value, opts, recurse, maxIterations = 10) {
|
|
519
553
|
let current = value;
|
|
@@ -607,14 +641,26 @@ function classify(raw, opts, recurse) {
|
|
|
607
641
|
processed: `--${rest}-color`
|
|
608
642
|
};
|
|
609
643
|
}
|
|
644
|
+
if (token[0] === "#" && token.includes("+")) {
|
|
645
|
+
const layered = layerColors(token, opts, recurse);
|
|
646
|
+
if (layered !== null) return {
|
|
647
|
+
bucket: 0,
|
|
648
|
+
processed: layered
|
|
649
|
+
};
|
|
650
|
+
warnOnceDev(`compound-color-invalid:${token}`, `"${token}" is not a compound color and is ignored: every part joined by "+" must be a color token with an optional opacity, such as "#surface+#dark.04".`);
|
|
651
|
+
return {
|
|
652
|
+
bucket: 2,
|
|
653
|
+
processed: ""
|
|
654
|
+
};
|
|
655
|
+
}
|
|
610
656
|
if (token === "#current") return {
|
|
611
657
|
bucket: 0,
|
|
612
658
|
processed: "currentcolor"
|
|
613
659
|
};
|
|
614
|
-
const currentAlphaMatch = token.match(
|
|
660
|
+
const currentAlphaMatch = token.match(RE_CURRENT_ALPHA);
|
|
615
661
|
if (currentAlphaMatch) return {
|
|
616
662
|
bucket: 0,
|
|
617
|
-
processed:
|
|
663
|
+
processed: fadeColor("currentcolor", currentAlphaMatch[1])
|
|
618
664
|
};
|
|
619
665
|
if (token[0] === "$" || token[0] === "#") {
|
|
620
666
|
const predefinedTokens = getGlobalPredefinedTokens();
|
|
@@ -625,21 +671,33 @@ function classify(raw, opts, recurse) {
|
|
|
625
671
|
return classify(foldDslCase(tokenValue), opts, recurse);
|
|
626
672
|
}
|
|
627
673
|
if (token[0] === "#") {
|
|
628
|
-
const alphaMatch = token.match(
|
|
674
|
+
const alphaMatch = token.match(RE_TOKEN_ALPHA);
|
|
629
675
|
if (alphaMatch) {
|
|
630
676
|
const [, baseToken, rawAlpha] = alphaMatch;
|
|
631
677
|
const baseKey = baseToken.toLowerCase();
|
|
632
678
|
if (baseKey in predefinedTokens) {
|
|
633
679
|
const resolvedValue = predefinedTokens[baseKey];
|
|
680
|
+
if (resolvedValue.trim().toLowerCase() === "transparent") return {
|
|
681
|
+
bucket: 0,
|
|
682
|
+
processed: "transparent"
|
|
683
|
+
};
|
|
684
|
+
const fadeWhole = () => {
|
|
685
|
+
const { bucket, processed } = classify(foldDslCase(resolvedValue), opts, recurse);
|
|
686
|
+
return bucket === 0 || bucket === 3 ? {
|
|
687
|
+
bucket: 0,
|
|
688
|
+
processed: fadeColor(processed, rawAlpha)
|
|
689
|
+
} : {
|
|
690
|
+
bucket: 2,
|
|
691
|
+
processed: ""
|
|
692
|
+
};
|
|
693
|
+
};
|
|
694
|
+
if (resolvedValue.startsWith("#") && resolvedValue.includes("+")) return fadeWhole();
|
|
634
695
|
if (resolvedValue.startsWith("#")) return classify(`${foldDslCase(resolvedValue)}.${rawAlpha}`, opts, recurse);
|
|
635
696
|
const funcMatch = resolvedValue.match(RE_FUNC_CALL);
|
|
636
697
|
if (funcMatch) {
|
|
637
698
|
const [, funcName, args] = funcMatch;
|
|
638
699
|
const lowerFunc = funcName.toLowerCase();
|
|
639
|
-
if (DERIVED_COLOR_FUNCS.has(lowerFunc)) return
|
|
640
|
-
bucket: 0,
|
|
641
|
-
processed: fadeColor(classify(foldDslCase(resolvedValue), opts, recurse).processed, rawAlpha)
|
|
642
|
-
};
|
|
700
|
+
if (DERIVED_COLOR_FUNCS.has(lowerFunc)) return fadeWhole();
|
|
643
701
|
const isCustomFunc = !!(opts.functions && lowerFunc in opts.functions && !COLOR_FUNCS.has(lowerFunc) && !COLOR_FUNCS.has(funcName.replace(/a$/i, "").toLowerCase()));
|
|
644
702
|
const normalizedFunc = isCustomFunc ? lowerFunc : funcName.replace(/a$/i, "").toLowerCase();
|
|
645
703
|
if (!(COLOR_FUNCS.has(normalizedFunc) || COLOR_FUNCS.has(lowerFunc) || isCustomFunc)) return classify(`${resolvedValue}.${rawAlpha}`, opts, recurse);
|
|
@@ -698,6 +756,11 @@ function classify(raw, opts, recurse) {
|
|
|
698
756
|
processed: constructed
|
|
699
757
|
};
|
|
700
758
|
}
|
|
759
|
+
const keyword = resolvedValue.trim().toLowerCase();
|
|
760
|
+
if (keyword === "currentcolor" || isColorKeyword(keyword)) return {
|
|
761
|
+
bucket: 0,
|
|
762
|
+
processed: fadeColor(keyword, rawAlpha)
|
|
763
|
+
};
|
|
701
764
|
return classify(`${resolvedValue}.${rawAlpha}`, opts, recurse);
|
|
702
765
|
}
|
|
703
766
|
}
|
|
@@ -724,12 +787,13 @@ function classify(raw, opts, recurse) {
|
|
|
724
787
|
}
|
|
725
788
|
}
|
|
726
789
|
if (token[0] === "#" && token.length > 1) {
|
|
727
|
-
const alphaMatch = token.match(
|
|
790
|
+
const alphaMatch = token.match(RE_TOKEN_ALPHA);
|
|
728
791
|
if (alphaMatch) {
|
|
729
|
-
const [,
|
|
792
|
+
const [, baseToken, rawAlpha] = alphaMatch;
|
|
793
|
+
const base = baseToken.slice(1);
|
|
730
794
|
return {
|
|
731
795
|
bucket: 0,
|
|
732
|
-
processed: fadeColor(`var(--${base}-color)`, rawAlpha)
|
|
796
|
+
processed: fadeColor(RE_HEX.test(base) ? `var(--${base}-color, #${base})` : `var(--${base}-color)`, rawAlpha)
|
|
733
797
|
};
|
|
734
798
|
}
|
|
735
799
|
const name = token.slice(1);
|
|
@@ -762,10 +826,10 @@ function classify(raw, opts, recurse) {
|
|
|
762
826
|
functions: void 0
|
|
763
827
|
}, recurse);
|
|
764
828
|
}
|
|
765
|
-
const
|
|
829
|
+
const parsedInner = recurse(inner);
|
|
766
830
|
return {
|
|
767
|
-
bucket: 1,
|
|
768
|
-
processed: `${canonicalFuncName(fname)}(${
|
|
831
|
+
bucket: fname === "var" && parsedInner.groups.length === 2 && isSingleColor(parsedInner.groups[1]) ? 0 : 1,
|
|
832
|
+
processed: `${canonicalFuncName(fname)}(${parsedInner.output})`
|
|
769
833
|
};
|
|
770
834
|
}
|
|
771
835
|
if (token.startsWith("(") && token.endsWith(")")) {
|
|
@@ -782,10 +846,10 @@ function classify(raw, opts, recurse) {
|
|
|
782
846
|
const match = token.slice(1, -1).match(/^\$([a-z_][a-zA-Z0-9-_]*)\s*,\s*(.*)$/);
|
|
783
847
|
if (match) {
|
|
784
848
|
const [, name, fallback] = match;
|
|
785
|
-
const
|
|
849
|
+
const parsedFallback = recurse(fallback);
|
|
786
850
|
return {
|
|
787
|
-
bucket: name.endsWith("-color") ? 3 : 1,
|
|
788
|
-
processed: `var(--${name}, ${
|
|
851
|
+
bucket: name.endsWith("-color") ? 3 : parsedFallback.groups.length === 1 && isSingleColor(parsedFallback.groups[0]) ? 0 : 1,
|
|
852
|
+
processed: `var(--${name}, ${parsedFallback.output})`
|
|
789
853
|
};
|
|
790
854
|
}
|
|
791
855
|
}
|
|
@@ -835,7 +899,7 @@ function classify(raw, opts, recurse) {
|
|
|
835
899
|
bucket: 1,
|
|
836
900
|
processed: token
|
|
837
901
|
};
|
|
838
|
-
if (token === "transparent" || token === "currentcolor") return {
|
|
902
|
+
if (token === "transparent" || token === "currentcolor" || isColorKeyword(token)) return {
|
|
839
903
|
bucket: 0,
|
|
840
904
|
processed: token
|
|
841
905
|
};
|
|
@@ -985,6 +1049,16 @@ function scan(src, cb) {
|
|
|
985
1049
|
}
|
|
986
1050
|
//#endregion
|
|
987
1051
|
//#region src/parser/parser.ts
|
|
1052
|
+
function warnSpacedCompound(src, tokens) {
|
|
1053
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
1054
|
+
const prev = tokens[i - 1];
|
|
1055
|
+
const tok = tokens[i];
|
|
1056
|
+
if (prev[0] === "#" && (tok.startsWith("+#") || tok === "+" && tokens[i + 1]?.[0] === "#" || prev.endsWith("+") && tok[0] === "#")) {
|
|
1057
|
+
warnOnceDev(`compound-color-spaced:${src}`, `"${src}": a "+" joins colors only without spaces around it. Write "${src.replace(/(#[^\s,()+#]+)\s*\+\s*(?=#)/g, "$1+")}".`);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
988
1062
|
var StyleParser = class {
|
|
989
1063
|
opts;
|
|
990
1064
|
cache;
|
|
@@ -1048,8 +1122,10 @@ var StyleParser = class {
|
|
|
1048
1122
|
parts = [];
|
|
1049
1123
|
}
|
|
1050
1124
|
};
|
|
1125
|
+
const tokens = [];
|
|
1051
1126
|
scan(stripped, (tok, isComma, isSlash) => {
|
|
1052
1127
|
if (tok) {
|
|
1128
|
+
tokens.push(tok);
|
|
1053
1129
|
if (currentGroup.input) currentGroup.input += ` ${tok}`;
|
|
1054
1130
|
else currentGroup.input = tok;
|
|
1055
1131
|
const { bucket, processed } = classify(tok, this.opts, (sub) => this.process(sub));
|
|
@@ -1059,6 +1135,7 @@ var StyleParser = class {
|
|
|
1059
1135
|
if (isComma) endGroup();
|
|
1060
1136
|
});
|
|
1061
1137
|
if (currentPart.all.length || parts.length || !groups.length) endGroup(false);
|
|
1138
|
+
warnSpacedCompound(src, tokens);
|
|
1062
1139
|
const result = {
|
|
1063
1140
|
output: groups.length === 1 ? groups[0].output : groups.map((group) => group.output).join(", "),
|
|
1064
1141
|
groups
|
|
@@ -1190,7 +1267,7 @@ function isSimpleColorFast(val) {
|
|
|
1190
1267
|
break;
|
|
1191
1268
|
case 116: if (val === "transparent") return true;
|
|
1192
1269
|
}
|
|
1193
|
-
return
|
|
1270
|
+
return isColorKeyword(val);
|
|
1194
1271
|
}
|
|
1195
1272
|
let colorWarningCount = 0;
|
|
1196
1273
|
const MAX_COLOR_WARNINGS = 10;
|
|
@@ -1235,7 +1312,8 @@ function getGlobalParser() {
|
|
|
1235
1312
|
function getGlobalParseFunctions() {
|
|
1236
1313
|
return __tastyParseFunctions;
|
|
1237
1314
|
}
|
|
1238
|
-
|
|
1315
|
+
const DEFAULT_PREDEFINED_TOKENS = { "#clear": "transparent" };
|
|
1316
|
+
let __globalPredefinedTokens = { ...DEFAULT_PREDEFINED_TOKENS };
|
|
1239
1317
|
function setGlobalPredefinedTokens(tokens) {
|
|
1240
1318
|
const normalizedTokens = {};
|
|
1241
1319
|
for (const [key, value] of Object.entries(tokens)) {
|
|
@@ -1247,17 +1325,17 @@ function setGlobalPredefinedTokens(tokens) {
|
|
|
1247
1325
|
}
|
|
1248
1326
|
normalizedTokens[lowerKey] = value;
|
|
1249
1327
|
}
|
|
1250
|
-
__globalPredefinedTokens =
|
|
1328
|
+
__globalPredefinedTokens = {
|
|
1251
1329
|
...__globalPredefinedTokens,
|
|
1252
1330
|
...normalizedTokens
|
|
1253
|
-
}
|
|
1331
|
+
};
|
|
1254
1332
|
getOrCreateParser().clearCache();
|
|
1255
1333
|
}
|
|
1256
1334
|
function getGlobalPredefinedTokens() {
|
|
1257
1335
|
return __globalPredefinedTokens;
|
|
1258
1336
|
}
|
|
1259
1337
|
function resetGlobalPredefinedTokens() {
|
|
1260
|
-
__globalPredefinedTokens =
|
|
1338
|
+
__globalPredefinedTokens = { ...DEFAULT_PREDEFINED_TOKENS };
|
|
1261
1339
|
getOrCreateParser().clearCache();
|
|
1262
1340
|
}
|
|
1263
1341
|
function parseStyle(value) {
|
|
@@ -1272,6 +1350,9 @@ function resolveCustomProperties(value) {
|
|
|
1272
1350
|
if (!RE_CUSTOM_PROPERTY_REF.test(value)) return value;
|
|
1273
1351
|
return parseStyle(value).output || value;
|
|
1274
1352
|
}
|
|
1353
|
+
function isDroppedValue(value) {
|
|
1354
|
+
return parseStyle(value).groups.every((group) => group.all.length === 0);
|
|
1355
|
+
}
|
|
1275
1356
|
function parseColor(val, ignoreError = false) {
|
|
1276
1357
|
if (typeof val !== "string") val = String(val ?? "");
|
|
1277
1358
|
val = val.trim();
|
|
@@ -1291,14 +1372,13 @@ function parseColor(val, ignoreError = false) {
|
|
|
1291
1372
|
}
|
|
1292
1373
|
firstColor = extractedColor;
|
|
1293
1374
|
}
|
|
1294
|
-
const faded =
|
|
1375
|
+
const faded = parseAlphaMix(firstColor);
|
|
1295
1376
|
const baseColor = faded ? faded.color : firstColor;
|
|
1296
1377
|
const nameMatch = baseColor.match(COLOR_VAR_PATTERN);
|
|
1297
1378
|
let opacity;
|
|
1298
1379
|
if (faded) {
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
if (!isNaN(v)) opacity = alpha.endsWith("%") ? v : v * 100;
|
|
1380
|
+
const v = parseFloat(faded.percentage);
|
|
1381
|
+
if (!isNaN(v)) opacity = v;
|
|
1302
1382
|
} else if (baseColor.startsWith("rgb") || baseColor.startsWith("hsl") || baseColor.startsWith("lch") || baseColor.startsWith("oklch")) {
|
|
1303
1383
|
const alphaMatch = baseColor.match(RGB_ALPHA_PATTERN);
|
|
1304
1384
|
if (alphaMatch) {
|
|
@@ -1369,10 +1449,10 @@ function resolveFunctionColor(str) {
|
|
|
1369
1449
|
//#endregion
|
|
1370
1450
|
//#region src/utils/colors.ts
|
|
1371
1451
|
function color(name, opacity = 1) {
|
|
1372
|
-
if (opacity !== 1) return
|
|
1452
|
+
if (opacity !== 1) return mixColorAlpha(`var(--${name}-color)`, alphaToPercentage(opacity));
|
|
1373
1453
|
return `var(--${name}-color)`;
|
|
1374
1454
|
}
|
|
1375
1455
|
//#endregion
|
|
1376
|
-
export {
|
|
1456
|
+
export { getRgbValuesFromRgbaString as A, createColorFunc as C, isTransparent as D, makeEmptyDetails as E, normalizeDslName as F, toSnakeCase as I, CSS_WIDE_KEYWORDS as L, hslToRgbValues as M, isColorKeyword as N, parseAlphaMix as O, strToRgb as P, RE_NUMBER as R, okhslPlugin as S, Lru as T, setGlobalPredefinedTokens as _, customFunction as a, okhstPlugin as b, getGlobalParser as c, normalizeColorTokenValue as d, parseColor as f, resolveCustomProperties as g, resetGlobalPredefinedTokens as h, DIRECTIONS as i, hexToRgb as j, getNamedColorHex as k, getGlobalPredefinedTokens as l, resetGlobalParseFunctions as m, resolveFunctionColor as n, filterMods as o, parseStyle as p, CUSTOM_UNITS as r, getGlobalParseFunctions as s, color as t, isDroppedValue as u, stringifyStyles as v, StyleParser as w, okhslFunction as x, okhstFunction as y, RE_RAW_UNIT as z };
|
|
1377
1457
|
|
|
1378
|
-
//# sourceMappingURL=dsl-
|
|
1458
|
+
//# sourceMappingURL=dsl-CsFl9LGn.js.map
|