@tenphi/tasty 0.0.0-snapshot.2b94253 → 0.0.0-snapshot.2cbc2f8
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/{collector-osfWTeRd.d.ts → collector-CpU85p2G.d.ts} +2 -2
- package/dist/{collector-Crs9kGJW.js → collector-OvXG7KWf.js} +3 -3
- package/dist/{collector-Crs9kGJW.js.map → collector-OvXG7KWf.js.map} +1 -1
- package/dist/{config-BoZDUHW5.d.ts → config-3h7BtX4l.d.ts} +2 -2
- package/dist/{config-BaxtQMS3.js → config-BfqoUnBb.js} +856 -370
- package/dist/config-BfqoUnBb.js.map +1 -0
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-CmxaoZ-N.js → core-DlcI4RnL.js} +7 -7
- package/dist/core-DlcI4RnL.js.map +1 -0
- package/dist/{css-writer-CPy_cbFJ.js → css-writer-C8h3QlRt.js} +3 -3
- package/dist/css-writer-C8h3QlRt.js.map +1 -0
- package/dist/{format-rules-CPirO_Mj.js → format-rules-D9CBkvVE.js} +2 -2
- package/dist/{format-rules-CPirO_Mj.js.map → format-rules-D9CBkvVE.js.map} +1 -1
- package/dist/{hydrate-CVn-A_3y.js → hydrate-sIvCdUlE.js} +2 -2
- package/dist/{hydrate-CVn-A_3y.js.map → hydrate-sIvCdUlE.js.map} +1 -1
- package/dist/{index-tcHuMPFt.d.ts → index-BsJz5xBF.d.ts} +2 -2
- package/dist/{index-B_k47mc_.d.ts → index-C_SRmAWj.d.ts} +193 -70
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-vpzoVdUR.js → keyframes-bg4yPrZL.js} +10 -3
- package/dist/keyframes-bg4yPrZL.js.map +1 -0
- package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-BzOwGOGC.d.ts} +2 -2
- package/dist/{merge-styles-BzQutdAK.js → merge-styles-CmWiXajN.js} +2 -2
- package/dist/{merge-styles-BzQutdAK.js.map → merge-styles-CmWiXajN.js.map} +1 -1
- package/dist/{resolve-recipes-DgH8A3Nn.js → resolve-recipes-OwLUM8jV.js} +3 -3
- package/dist/{resolve-recipes-DgH8A3Nn.js.map → resolve-recipes-OwLUM8jV.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +3 -3
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +4 -4
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.d.ts +1 -1
- package/dist/zero/index.js +1 -1
- package/docs/dsl.md +110 -1
- package/docs/pipeline.md +49 -4
- package/package.json +15 -6
- package/tasty.config.ts +1 -0
- package/dist/config-BaxtQMS3.js.map +0 -1
- package/dist/core-CmxaoZ-N.js.map +0 -1
- package/dist/css-writer-CPy_cbFJ.js.map +0 -1
- package/dist/keyframes-vpzoVdUR.js.map +0 -1
|
@@ -55,6 +55,223 @@ function canonicalFuncName(lowered) {
|
|
|
55
55
|
return CANONICAL_FUNC_CASE.get(lowered) ?? lowered;
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
+
//#region src/properties/index.ts
|
|
59
|
+
const PROPERTIES_KEY = "@properties";
|
|
60
|
+
/**
|
|
61
|
+
* Valid CSS custom property name pattern (after the -- prefix).
|
|
62
|
+
* Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.
|
|
63
|
+
*/
|
|
64
|
+
const VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;
|
|
65
|
+
/**
|
|
66
|
+
* Validate a CSS custom property name (the part after --).
|
|
67
|
+
* Returns true if the name is valid for use as a CSS custom property.
|
|
68
|
+
*/
|
|
69
|
+
function isValidPropertyName(name) {
|
|
70
|
+
return VALID_PROPERTY_NAME_PATTERN.test(name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if styles object has local @properties definition.
|
|
74
|
+
* Fast path: single property lookup.
|
|
75
|
+
*/
|
|
76
|
+
function hasLocalProperties(styles) {
|
|
77
|
+
return PROPERTIES_KEY in styles;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extract local @properties from styles object.
|
|
81
|
+
* Returns null if no local properties (fast path).
|
|
82
|
+
*/
|
|
83
|
+
function extractLocalProperties(styles) {
|
|
84
|
+
const properties = styles[PROPERTIES_KEY];
|
|
85
|
+
if (!properties || typeof properties !== "object") return null;
|
|
86
|
+
return properties;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parse a property token name and return the CSS property name and whether it's a color.
|
|
90
|
+
* Supports tasty token syntax and validates the property name.
|
|
91
|
+
*
|
|
92
|
+
* Token formats:
|
|
93
|
+
* - `$name` → { cssName: '--name', isColor: false }
|
|
94
|
+
* - `#name` → { cssName: '--name-color', isColor: true }
|
|
95
|
+
* - `--name` → { cssName: '--name', isColor: false } (legacy, auto-detect color by suffix)
|
|
96
|
+
* - `name` → { cssName: '--name', isColor: false } (legacy)
|
|
97
|
+
*
|
|
98
|
+
* @param token - The property token to parse
|
|
99
|
+
* @returns Parsed result with cssName, isColor, isValid, and optional error
|
|
100
|
+
*/
|
|
101
|
+
function parsePropertyToken(token) {
|
|
102
|
+
if (!token || typeof token !== "string") return {
|
|
103
|
+
cssName: "",
|
|
104
|
+
isColor: false,
|
|
105
|
+
isValid: false,
|
|
106
|
+
error: "Property token must be a non-empty string"
|
|
107
|
+
};
|
|
108
|
+
let name;
|
|
109
|
+
let isColor;
|
|
110
|
+
if (token.startsWith("$")) {
|
|
111
|
+
name = token.slice(1);
|
|
112
|
+
isColor = false;
|
|
113
|
+
} else if (token.startsWith("#")) {
|
|
114
|
+
name = token.slice(1);
|
|
115
|
+
isColor = true;
|
|
116
|
+
} else if (token.startsWith("--")) {
|
|
117
|
+
name = token.slice(2);
|
|
118
|
+
isColor = token.endsWith("-color");
|
|
119
|
+
} else {
|
|
120
|
+
name = token;
|
|
121
|
+
isColor = token.endsWith("-color");
|
|
122
|
+
}
|
|
123
|
+
if (!name) return {
|
|
124
|
+
cssName: "",
|
|
125
|
+
isColor,
|
|
126
|
+
isValid: false,
|
|
127
|
+
error: "Property name cannot be empty"
|
|
128
|
+
};
|
|
129
|
+
if (!isValidPropertyName(name)) return {
|
|
130
|
+
cssName: "",
|
|
131
|
+
isColor,
|
|
132
|
+
isValid: false,
|
|
133
|
+
error: `Invalid property name "${name}". Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.`
|
|
134
|
+
};
|
|
135
|
+
let cssName;
|
|
136
|
+
if (token.startsWith("#")) cssName = `--${name}-color`;
|
|
137
|
+
else cssName = `--${name}`;
|
|
138
|
+
return {
|
|
139
|
+
cssName,
|
|
140
|
+
isColor,
|
|
141
|
+
isValid: true
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Normalize a property definition to a consistent string representation.
|
|
146
|
+
* Used for comparing definitions to detect type conflicts.
|
|
147
|
+
*
|
|
148
|
+
* Only `syntax` and `inherits` are compared — `initialValue` is intentionally
|
|
149
|
+
* excluded because different components may set different defaults for the
|
|
150
|
+
* same typed property (e.g. auto-inferred `0px` vs explicit `6px`).
|
|
151
|
+
*
|
|
152
|
+
* Keys are sorted alphabetically to ensure consistent comparison:
|
|
153
|
+
* { inherits: true, syntax: '<color>' } === { syntax: '<color>', inherits: true }
|
|
154
|
+
*/
|
|
155
|
+
function normalizePropertyDefinition(def) {
|
|
156
|
+
const normalized = {};
|
|
157
|
+
if (def.inherits !== void 0) normalized.inherits = def.inherits;
|
|
158
|
+
if (def.syntax !== void 0) normalized.syntax = def.syntax;
|
|
159
|
+
return JSON.stringify(normalized);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get the effective property definition for a token.
|
|
163
|
+
* For color tokens (#name), auto-sets syntax to '<color>' and defaults initialValue to 'transparent'.
|
|
164
|
+
*
|
|
165
|
+
* @param token - Property token ($name, #name, --name, or plain name)
|
|
166
|
+
* @param userDefinition - User-provided definition options
|
|
167
|
+
* @returns Effective definition with cssName, definition, isValid, and optional error
|
|
168
|
+
*/
|
|
169
|
+
function getEffectiveDefinition(token, userDefinition) {
|
|
170
|
+
const parsed = parsePropertyToken(token);
|
|
171
|
+
if (!parsed.isValid) return {
|
|
172
|
+
cssName: "",
|
|
173
|
+
definition: userDefinition,
|
|
174
|
+
isColor: false,
|
|
175
|
+
isValid: false,
|
|
176
|
+
error: parsed.error
|
|
177
|
+
};
|
|
178
|
+
if (parsed.isColor) return {
|
|
179
|
+
cssName: parsed.cssName,
|
|
180
|
+
definition: {
|
|
181
|
+
syntax: "<color>",
|
|
182
|
+
inherits: userDefinition.inherits,
|
|
183
|
+
initialValue: userDefinition.initialValue ?? "transparent"
|
|
184
|
+
},
|
|
185
|
+
isColor: true,
|
|
186
|
+
isValid: true
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
cssName: parsed.cssName,
|
|
190
|
+
definition: userDefinition,
|
|
191
|
+
isColor: false,
|
|
192
|
+
isValid: true
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const UNIT_TO_SYNTAX = {};
|
|
196
|
+
const LENGTH_UNITS = [
|
|
197
|
+
"px",
|
|
198
|
+
"em",
|
|
199
|
+
"rem",
|
|
200
|
+
"vw",
|
|
201
|
+
"vh",
|
|
202
|
+
"vmin",
|
|
203
|
+
"vmax",
|
|
204
|
+
"ch",
|
|
205
|
+
"ex",
|
|
206
|
+
"cap",
|
|
207
|
+
"ic",
|
|
208
|
+
"lh",
|
|
209
|
+
"rlh",
|
|
210
|
+
"svw",
|
|
211
|
+
"svh",
|
|
212
|
+
"lvw",
|
|
213
|
+
"lvh",
|
|
214
|
+
"dvw",
|
|
215
|
+
"dvh",
|
|
216
|
+
"cqw",
|
|
217
|
+
"cqh",
|
|
218
|
+
"cqi",
|
|
219
|
+
"cqb",
|
|
220
|
+
"cqmin",
|
|
221
|
+
"cqmax"
|
|
222
|
+
];
|
|
223
|
+
const ANGLE_UNITS = [
|
|
224
|
+
"deg",
|
|
225
|
+
"rad",
|
|
226
|
+
"grad",
|
|
227
|
+
"turn"
|
|
228
|
+
];
|
|
229
|
+
const TIME_UNITS = ["ms", "s"];
|
|
230
|
+
for (const u of LENGTH_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
231
|
+
syntax: "<length-percentage>",
|
|
232
|
+
initialValue: "0px"
|
|
233
|
+
};
|
|
234
|
+
UNIT_TO_SYNTAX["%"] = {
|
|
235
|
+
syntax: "<length-percentage>",
|
|
236
|
+
initialValue: "0px"
|
|
237
|
+
};
|
|
238
|
+
for (const u of ANGLE_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
239
|
+
syntax: "<angle>",
|
|
240
|
+
initialValue: "0deg"
|
|
241
|
+
};
|
|
242
|
+
for (const u of TIME_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
243
|
+
syntax: "<time>",
|
|
244
|
+
initialValue: "0s"
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Infer CSS @property syntax from a concrete value.
|
|
248
|
+
* Detects numeric types: \<number\>, \<length-percentage\>, \<angle\>, \<time\>.
|
|
249
|
+
* Length and percentage values both map to \<length-percentage\> for maximum flexibility.
|
|
250
|
+
* Color properties are handled separately via the #name token convention
|
|
251
|
+
* (--name-color gets \<color\> syntax automatically in getEffectiveDefinition).
|
|
252
|
+
*
|
|
253
|
+
* @param value - The CSS value to infer from (e.g. '10px', '1', '45deg')
|
|
254
|
+
* @returns Inferred syntax and initial value, or null if not inferable
|
|
255
|
+
*/
|
|
256
|
+
function inferSyntaxFromValue(value) {
|
|
257
|
+
if (!value || typeof value !== "string") return null;
|
|
258
|
+
const trimmed = value.trim();
|
|
259
|
+
if (!trimmed) return null;
|
|
260
|
+
if (RE_NUMBER.test(trimmed)) {
|
|
261
|
+
if (parseFloat(trimmed) === 0) return null;
|
|
262
|
+
return {
|
|
263
|
+
syntax: "<number>",
|
|
264
|
+
initialValue: "0"
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const unitMatch = trimmed.match(RE_RAW_UNIT);
|
|
268
|
+
if (unitMatch) {
|
|
269
|
+
const mapping = UNIT_TO_SYNTAX[unitMatch[2]];
|
|
270
|
+
if (mapping) return mapping;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
58
275
|
//#region src/parser/lru.ts
|
|
59
276
|
var Lru = class {
|
|
60
277
|
limit;
|
|
@@ -236,7 +453,19 @@ const K2 = .03;
|
|
|
236
453
|
const K3 = (1 + K1) / (1 + K2);
|
|
237
454
|
const clamp$1 = (value, min, max) => Math.max(Math.min(value, max), min);
|
|
238
455
|
const constrainAngle = (angle) => (angle % 360 + 360) % 360;
|
|
456
|
+
const toe = (x) => .5 * (K3 * x - K1 + Math.sqrt((K3 * x - K1) * (K3 * x - K1) + 4 * K2 * K3 * x));
|
|
239
457
|
const toeInv = (x) => (x ** 2 + K1 * x) / (K3 * (x + K2));
|
|
458
|
+
const OKHST_REF_EPS = .05;
|
|
459
|
+
function yToL(y) {
|
|
460
|
+
return toe(Math.cbrt(Math.max(0, y)));
|
|
461
|
+
}
|
|
462
|
+
function yFromTone(t, eps = OKHST_REF_EPS) {
|
|
463
|
+
const den = Math.log(1 + eps) - Math.log(eps);
|
|
464
|
+
return Math.exp(t / 100 * den + Math.log(eps)) - eps;
|
|
465
|
+
}
|
|
466
|
+
function fromTone(t, eps = OKHST_REF_EPS) {
|
|
467
|
+
return yToL(yFromTone(t, eps));
|
|
468
|
+
}
|
|
240
469
|
const oklabToLinearSrgb = (lab) => {
|
|
241
470
|
const L = lab[0];
|
|
242
471
|
const a = lab[1];
|
|
@@ -528,6 +757,16 @@ function okhslToSrgb(h, s, l) {
|
|
|
528
757
|
];
|
|
529
758
|
}
|
|
530
759
|
/**
|
|
760
|
+
* OKHST to sRGB (0-1 range).
|
|
761
|
+
* @param h - Hue in degrees (0-360)
|
|
762
|
+
* @param s - Saturation (0-1)
|
|
763
|
+
* @param t - Tone (0-1)
|
|
764
|
+
* @returns sRGB values in 0-1 range, clamped to gamut
|
|
765
|
+
*/
|
|
766
|
+
function okhstToSrgb(h, s, t) {
|
|
767
|
+
return okhslToSrgb(h, clamp$1(s, 0, 1), clamp$1(fromTone(t * 100), 0, 1));
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
531
770
|
* OKLCH to sRGB (0-255 range).
|
|
532
771
|
* @param L - Lightness (0-1)
|
|
533
772
|
* @param C - Chroma (typically 0-0.4)
|
|
@@ -807,7 +1046,7 @@ function getRgbValuesFromRgbaString(str) {
|
|
|
807
1046
|
}
|
|
808
1047
|
/**
|
|
809
1048
|
* Convert any recognized color string to an `rgb()` CSS string.
|
|
810
|
-
* Handles hex, `okhsl()`, `hsl()`/`hsla()`, named CSS colors,
|
|
1049
|
+
* Handles hex, `okhsl()`, `okhst()`, `hsl()`/`hsla()`, named CSS colors,
|
|
811
1050
|
* and `rgb()`/`rgba()` pass-through.
|
|
812
1051
|
*/
|
|
813
1052
|
function strToRgb(color, _ignoreAlpha = false) {
|
|
@@ -816,6 +1055,7 @@ function strToRgb(color, _ignoreAlpha = false) {
|
|
|
816
1055
|
if (color.startsWith("#")) return hexToRgb(color);
|
|
817
1056
|
if (color.startsWith("oklch(")) return oklchStringToRgb(color);
|
|
818
1057
|
if (color.startsWith("okhsl(")) return okhslStringToRgb(color);
|
|
1058
|
+
if (color.startsWith("okhst(")) return okhstStringToRgb(color);
|
|
819
1059
|
if (color.startsWith("hsl")) return hslStringToRgb(color);
|
|
820
1060
|
const namedHex = getNamedColorHex().get(color.toLowerCase());
|
|
821
1061
|
if (namedHex) return hexToRgb(namedHex);
|
|
@@ -880,6 +1120,34 @@ function okhslStringToRgb(okhslStr) {
|
|
|
880
1120
|
return `rgb(${r255} ${g255} ${b255})`;
|
|
881
1121
|
}
|
|
882
1122
|
/**
|
|
1123
|
+
* Convert an `okhst()` color string to an `rgb()`/`rgba()` CSS string.
|
|
1124
|
+
* Supports deg/turn/rad hue units and percentage saturation/tone.
|
|
1125
|
+
*/
|
|
1126
|
+
function okhstStringToRgb(okhstStr) {
|
|
1127
|
+
const match = okhstStr.match(/okhst\(([^)]+)\)/i);
|
|
1128
|
+
if (!match) return null;
|
|
1129
|
+
const [colorPart, alphaPart] = match[1].trim().split("/");
|
|
1130
|
+
const parts = colorPart.trim().split(/[,\s]+/).filter(Boolean);
|
|
1131
|
+
if (parts.length < 3) return null;
|
|
1132
|
+
let h = parseFloat(parts[0]);
|
|
1133
|
+
const hueStr = parts[0].toLowerCase();
|
|
1134
|
+
if (hueStr.endsWith("turn")) h = parseFloat(hueStr) * 360;
|
|
1135
|
+
else if (hueStr.endsWith("rad")) h = parseFloat(hueStr) * 180 / Math.PI;
|
|
1136
|
+
else if (hueStr.endsWith("deg")) h = parseFloat(hueStr);
|
|
1137
|
+
const parsePercent = (val) => {
|
|
1138
|
+
const num = parseFloat(val);
|
|
1139
|
+
return val.includes("%") ? num / 100 : num;
|
|
1140
|
+
};
|
|
1141
|
+
const s = Math.max(0, Math.min(1, parsePercent(parts[1])));
|
|
1142
|
+
const t = Math.max(0, Math.min(1, parsePercent(parts[2])));
|
|
1143
|
+
const [r, g, b] = okhstToSrgb(h, s, t);
|
|
1144
|
+
const r255 = Math.round(Math.max(0, Math.min(1, r)) * 255);
|
|
1145
|
+
const g255 = Math.round(Math.max(0, Math.min(1, g)) * 255);
|
|
1146
|
+
const b255 = Math.round(Math.max(0, Math.min(1, b)) * 255);
|
|
1147
|
+
if (alphaPart) return `rgba(${r255}, ${g255}, ${b255}, ${parseFloat(alphaPart.trim())})`;
|
|
1148
|
+
return `rgb(${r255} ${g255} ${b255})`;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
883
1151
|
* Convert an `oklch()` color string to an `rgb()`/`rgba()` CSS string.
|
|
884
1152
|
* Supports deg/turn/rad hue units and percentage lightness.
|
|
885
1153
|
*/
|
|
@@ -1052,6 +1320,17 @@ function resolveToRgbaValues(color) {
|
|
|
1052
1320
|
parsed.alpha
|
|
1053
1321
|
];
|
|
1054
1322
|
}
|
|
1323
|
+
if (trimmed.startsWith("okhst(")) {
|
|
1324
|
+
const parsed = parseColorFuncArgs(trimmed, "okhst");
|
|
1325
|
+
if (!parsed) return null;
|
|
1326
|
+
const [r, g, b] = okhstToSrgb(parseHue(parsed.parts[0]), clamp01(parsePercent(parsed.parts[1])), clamp01(parsePercent(parsed.parts[2])));
|
|
1327
|
+
return [
|
|
1328
|
+
clamp01(r) * 255,
|
|
1329
|
+
clamp01(g) * 255,
|
|
1330
|
+
clamp01(b) * 255,
|
|
1331
|
+
parsed.alpha
|
|
1332
|
+
];
|
|
1333
|
+
}
|
|
1055
1334
|
const fallback = strToRgb(trimmed);
|
|
1056
1335
|
if (fallback) {
|
|
1057
1336
|
if (fallback !== trimmed) return resolveToRgbaValues(fallback);
|
|
@@ -1065,287 +1344,187 @@ function resolveToRgbaValues(color) {
|
|
|
1065
1344
|
}
|
|
1066
1345
|
return null;
|
|
1067
1346
|
}
|
|
1347
|
+
const SPACE_FUNCS = {
|
|
1348
|
+
rgb: ["rgb", "rgba"],
|
|
1349
|
+
hsl: ["hsl", "hsla"],
|
|
1350
|
+
oklch: ["oklch", "oklcha"]
|
|
1351
|
+
};
|
|
1352
|
+
const CANONICAL_FUNC = {
|
|
1353
|
+
rgb: "rgb",
|
|
1354
|
+
hsl: "hsl",
|
|
1355
|
+
oklch: "oklch"
|
|
1356
|
+
};
|
|
1068
1357
|
/**
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1358
|
+
* Parse a native CSS color function ONLY when its name matches the configured
|
|
1359
|
+
* output space. Splits arguments at the top level, preserving every token
|
|
1360
|
+
* (numbers, percentages, `var()`, `calc()`, `min()`, …) verbatim — no numeric
|
|
1361
|
+
* parsing or normalization is performed.
|
|
1362
|
+
*
|
|
1363
|
+
* Returns null when the input is not a same-space function (caller falls back
|
|
1364
|
+
* to the sRGB round-trip for genuine cross-space conversion / hex / named colors).
|
|
1365
|
+
*/
|
|
1366
|
+
function parseSameSpaceFunc(color, space) {
|
|
1367
|
+
const original = color.trim();
|
|
1368
|
+
const lower = original.toLowerCase();
|
|
1369
|
+
const funcs = SPACE_FUNCS[space];
|
|
1370
|
+
let funcName = null;
|
|
1371
|
+
for (const f of funcs) if (lower.startsWith(`${f}(`)) {
|
|
1372
|
+
funcName = f;
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
if (!funcName) return null;
|
|
1376
|
+
const start = funcName.length;
|
|
1377
|
+
const end = original.lastIndexOf(")");
|
|
1378
|
+
if (end < start) return null;
|
|
1379
|
+
const inner = original.slice(start + 1, end).trim();
|
|
1380
|
+
if (!inner) return null;
|
|
1381
|
+
const rawTokens = [];
|
|
1382
|
+
let depth = 0;
|
|
1383
|
+
let buf = "";
|
|
1384
|
+
for (const c of inner) if (c === "(") {
|
|
1385
|
+
depth++;
|
|
1386
|
+
buf += c;
|
|
1387
|
+
} else if (c === ")") {
|
|
1388
|
+
depth--;
|
|
1389
|
+
buf += c;
|
|
1390
|
+
} else if (depth === 0 && (c === " " || c === "," || c === " " || c === "\n")) {
|
|
1391
|
+
if (buf) {
|
|
1392
|
+
rawTokens.push(buf);
|
|
1393
|
+
buf = "";
|
|
1394
|
+
}
|
|
1395
|
+
} else buf += c;
|
|
1396
|
+
if (buf) rawTokens.push(buf);
|
|
1397
|
+
let alpha = null;
|
|
1398
|
+
const parts = [];
|
|
1399
|
+
for (let i = 0; i < rawTokens.length; i++) {
|
|
1400
|
+
const tok = rawTokens[i];
|
|
1401
|
+
if (tok === "/") {
|
|
1402
|
+
alpha = rawTokens[i + 1] ?? null;
|
|
1403
|
+
break;
|
|
1404
|
+
}
|
|
1405
|
+
parts.push(tok);
|
|
1081
1406
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
/**
|
|
1087
|
-
* Extract the decomposed components of a color in the configured color space.
|
|
1088
|
-
* Returns a space-separated string of components without the wrapping function.
|
|
1089
|
-
* Alpha is NOT included — components are used for alpha composition via `/ alpha`.
|
|
1090
|
-
*/
|
|
1091
|
-
function getColorSpaceComponents(color) {
|
|
1092
|
-
const cached = componentsCache.get(color);
|
|
1093
|
-
if (cached !== void 0) return cached;
|
|
1094
|
-
const rgba = resolveToRgbaValues(color);
|
|
1095
|
-
if (!rgba) return color;
|
|
1096
|
-
const result = rgbValuesToComponents(rgba[0], rgba[1], rgba[2], currentColorSpace);
|
|
1097
|
-
componentsCache.set(color, result);
|
|
1098
|
-
return result;
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Convert a color initial value (from @property definitions) to components
|
|
1102
|
-
* in the configured color space.
|
|
1103
|
-
*/
|
|
1104
|
-
function colorInitialValueToComponents(initialValue) {
|
|
1105
|
-
if (initialValue == null) return getDefaultComponents();
|
|
1106
|
-
const val = String(initialValue).trim().toLowerCase();
|
|
1107
|
-
if (val === "transparent" || val === "rgba(0,0,0,0)" || val === "") return getDefaultComponents();
|
|
1108
|
-
if (val === "white") return rgbValuesToComponents(255, 255, 255, currentColorSpace);
|
|
1109
|
-
if (val === "black") return rgbValuesToComponents(0, 0, 0, currentColorSpace);
|
|
1110
|
-
const rgbMatch = val.match(/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);
|
|
1111
|
-
if (rgbMatch) return rgbValuesToComponents(parseInt(rgbMatch[1]), parseInt(rgbMatch[2]), parseInt(rgbMatch[3]), currentColorSpace);
|
|
1112
|
-
return getDefaultComponents();
|
|
1113
|
-
}
|
|
1114
|
-
function getDefaultComponents() {
|
|
1115
|
-
switch (currentColorSpace) {
|
|
1116
|
-
case "rgb": return "0 0 0";
|
|
1117
|
-
case "hsl": return "0 0% 0%";
|
|
1118
|
-
case "oklch": return "0 0 0";
|
|
1407
|
+
if (alpha === null && parts.length === 4) {
|
|
1408
|
+
alpha = parts[3];
|
|
1409
|
+
parts.length = 3;
|
|
1119
1410
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
* Get the CSS @property syntax for the companion components variable.
|
|
1123
|
-
* RGB and OKLCH components are all plain numbers, so `<number>+` works.
|
|
1124
|
-
* HSL includes percentages (`h s% l%`), so `*` is the only safe choice.
|
|
1125
|
-
*/
|
|
1126
|
-
function getComponentPropertySyntax() {
|
|
1127
|
-
switch (currentColorSpace) {
|
|
1128
|
-
case "rgb":
|
|
1129
|
-
case "oklch": return "<number>+";
|
|
1130
|
-
default: return "*";
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
//#endregion
|
|
1134
|
-
//#region src/properties/index.ts
|
|
1135
|
-
const PROPERTIES_KEY = "@properties";
|
|
1136
|
-
/**
|
|
1137
|
-
* Valid CSS custom property name pattern (after the -- prefix).
|
|
1138
|
-
* Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.
|
|
1139
|
-
*/
|
|
1140
|
-
const VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;
|
|
1141
|
-
/**
|
|
1142
|
-
* Validate a CSS custom property name (the part after --).
|
|
1143
|
-
* Returns true if the name is valid for use as a CSS custom property.
|
|
1144
|
-
*/
|
|
1145
|
-
function isValidPropertyName(name) {
|
|
1146
|
-
return VALID_PROPERTY_NAME_PATTERN.test(name);
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Check if styles object has local @properties definition.
|
|
1150
|
-
* Fast path: single property lookup.
|
|
1151
|
-
*/
|
|
1152
|
-
function hasLocalProperties(styles) {
|
|
1153
|
-
return PROPERTIES_KEY in styles;
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Extract local @properties from styles object.
|
|
1157
|
-
* Returns null if no local properties (fast path).
|
|
1158
|
-
*/
|
|
1159
|
-
function extractLocalProperties(styles) {
|
|
1160
|
-
const properties = styles[PROPERTIES_KEY];
|
|
1161
|
-
if (!properties || typeof properties !== "object") return null;
|
|
1162
|
-
return properties;
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* Parse a property token name and return the CSS property name and whether it's a color.
|
|
1166
|
-
* Supports tasty token syntax and validates the property name.
|
|
1167
|
-
*
|
|
1168
|
-
* Token formats:
|
|
1169
|
-
* - `$name` → { cssName: '--name', isColor: false }
|
|
1170
|
-
* - `#name` → { cssName: '--name-color', isColor: true }
|
|
1171
|
-
* - `--name` → { cssName: '--name', isColor: false } (legacy, auto-detect color by suffix)
|
|
1172
|
-
* - `name` → { cssName: '--name', isColor: false } (legacy)
|
|
1173
|
-
*
|
|
1174
|
-
* @param token - The property token to parse
|
|
1175
|
-
* @returns Parsed result with cssName, isColor, isValid, and optional error
|
|
1176
|
-
*/
|
|
1177
|
-
function parsePropertyToken(token) {
|
|
1178
|
-
if (!token || typeof token !== "string") return {
|
|
1179
|
-
cssName: "",
|
|
1180
|
-
isColor: false,
|
|
1181
|
-
isValid: false,
|
|
1182
|
-
error: "Property token must be a non-empty string"
|
|
1183
|
-
};
|
|
1184
|
-
let name;
|
|
1185
|
-
let isColor;
|
|
1186
|
-
if (token.startsWith("$")) {
|
|
1187
|
-
name = token.slice(1);
|
|
1188
|
-
isColor = false;
|
|
1189
|
-
} else if (token.startsWith("#")) {
|
|
1190
|
-
name = token.slice(1);
|
|
1191
|
-
isColor = true;
|
|
1192
|
-
} else if (token.startsWith("--")) {
|
|
1193
|
-
name = token.slice(2);
|
|
1194
|
-
isColor = token.endsWith("-color");
|
|
1195
|
-
} else {
|
|
1196
|
-
name = token;
|
|
1197
|
-
isColor = token.endsWith("-color");
|
|
1198
|
-
}
|
|
1199
|
-
if (!name) return {
|
|
1200
|
-
cssName: "",
|
|
1201
|
-
isColor,
|
|
1202
|
-
isValid: false,
|
|
1203
|
-
error: "Property name cannot be empty"
|
|
1204
|
-
};
|
|
1205
|
-
if (!isValidPropertyName(name)) return {
|
|
1206
|
-
cssName: "",
|
|
1207
|
-
isColor,
|
|
1208
|
-
isValid: false,
|
|
1209
|
-
error: `Invalid property name "${name}". Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.`
|
|
1210
|
-
};
|
|
1211
|
-
let cssName;
|
|
1212
|
-
if (token.startsWith("#")) cssName = `--${name}-color`;
|
|
1213
|
-
else cssName = `--${name}`;
|
|
1411
|
+
if (parts.length !== 3) return null;
|
|
1412
|
+
if (parts.some((p) => !p)) return null;
|
|
1214
1413
|
return {
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
isValid: true
|
|
1414
|
+
parts,
|
|
1415
|
+
alpha
|
|
1218
1416
|
};
|
|
1219
1417
|
}
|
|
1418
|
+
function buildSameSpaceString(parsed, space) {
|
|
1419
|
+
const func = CANONICAL_FUNC[space];
|
|
1420
|
+
const body = parsed.parts.join(" ");
|
|
1421
|
+
return parsed.alpha != null ? `${func}(${body} / ${parsed.alpha})` : `${func}(${body})`;
|
|
1422
|
+
}
|
|
1220
1423
|
/**
|
|
1221
|
-
*
|
|
1222
|
-
* Used for comparing definitions to detect type conflicts.
|
|
1424
|
+
* Build the decomposed component list for a same-space value.
|
|
1223
1425
|
*
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1426
|
+
* Dynamic tokens (`var()` / `calc()` / …) are preserved verbatim — they can't
|
|
1427
|
+
* be parsed and must survive into the CSS output. Purely static components are
|
|
1428
|
+
* normalized to the canonical numeric form for the space so the companion
|
|
1429
|
+
* `--*-color-{space}` variable stays a valid `<number>+` value (rgb/oklch) —
|
|
1430
|
+
* WITHOUT round-tripping through sRGB, which would clamp wide-gamut oklch.
|
|
1227
1431
|
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1432
|
+
* Non-native, parse-time-only functions (`okhsl()` / `okhst()`) are always
|
|
1433
|
+
* resolved to a static `rgb(...%)` upstream, so this is the path that turns
|
|
1434
|
+
* their percentage channels back into 0-255 numbers.
|
|
1230
1435
|
*/
|
|
1231
|
-
function
|
|
1232
|
-
const
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1235
|
-
|
|
1436
|
+
function buildSameSpaceComponents(parsed, space) {
|
|
1437
|
+
const parts = parsed.parts;
|
|
1438
|
+
if (parts.some((p) => p.includes("("))) return parts.join(" ");
|
|
1439
|
+
switch (space) {
|
|
1440
|
+
case "rgb": return parts.map((p) => p.endsWith("%") ? formatRgbComponent(parseFloat(p) / 100 * 255) : p).join(" ");
|
|
1441
|
+
case "hsl": return parts.join(" ");
|
|
1442
|
+
case "oklch": {
|
|
1443
|
+
const [l, c, h] = parts;
|
|
1444
|
+
return [
|
|
1445
|
+
l.endsWith("%") ? formatNum(parseFloat(l) / 100, 5) : l,
|
|
1446
|
+
c,
|
|
1447
|
+
h
|
|
1448
|
+
].join(" ");
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1236
1451
|
}
|
|
1237
1452
|
/**
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
isColor: true,
|
|
1262
|
-
isValid: true
|
|
1263
|
-
};
|
|
1264
|
-
return {
|
|
1265
|
-
cssName: parsed.cssName,
|
|
1266
|
-
definition: userDefinition,
|
|
1267
|
-
isColor: false,
|
|
1268
|
-
isValid: true
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
const UNIT_TO_SYNTAX = {};
|
|
1272
|
-
const LENGTH_UNITS = [
|
|
1273
|
-
"px",
|
|
1274
|
-
"em",
|
|
1275
|
-
"rem",
|
|
1276
|
-
"vw",
|
|
1277
|
-
"vh",
|
|
1278
|
-
"vmin",
|
|
1279
|
-
"vmax",
|
|
1280
|
-
"ch",
|
|
1281
|
-
"ex",
|
|
1282
|
-
"cap",
|
|
1283
|
-
"ic",
|
|
1284
|
-
"lh",
|
|
1285
|
-
"rlh",
|
|
1286
|
-
"svw",
|
|
1287
|
-
"svh",
|
|
1288
|
-
"lvw",
|
|
1289
|
-
"lvh",
|
|
1290
|
-
"dvw",
|
|
1291
|
-
"dvh",
|
|
1292
|
-
"cqw",
|
|
1293
|
-
"cqh",
|
|
1294
|
-
"cqi",
|
|
1295
|
-
"cqb",
|
|
1296
|
-
"cqmin",
|
|
1297
|
-
"cqmax"
|
|
1298
|
-
];
|
|
1299
|
-
const ANGLE_UNITS = [
|
|
1300
|
-
"deg",
|
|
1301
|
-
"rad",
|
|
1302
|
-
"grad",
|
|
1303
|
-
"turn"
|
|
1304
|
-
];
|
|
1305
|
-
const TIME_UNITS = ["ms", "s"];
|
|
1306
|
-
for (const u of LENGTH_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
1307
|
-
syntax: "<length-percentage>",
|
|
1308
|
-
initialValue: "0px"
|
|
1309
|
-
};
|
|
1310
|
-
UNIT_TO_SYNTAX["%"] = {
|
|
1311
|
-
syntax: "<length-percentage>",
|
|
1312
|
-
initialValue: "0px"
|
|
1313
|
-
};
|
|
1314
|
-
for (const u of ANGLE_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
1315
|
-
syntax: "<angle>",
|
|
1316
|
-
initialValue: "0deg"
|
|
1317
|
-
};
|
|
1318
|
-
for (const u of TIME_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
1319
|
-
syntax: "<time>",
|
|
1320
|
-
initialValue: "0s"
|
|
1321
|
-
};
|
|
1453
|
+
* Convert any supported color string to the configured color space CSS format.
|
|
1454
|
+
* Preserves alpha channel when present in the input.
|
|
1455
|
+
* Returns null if the input cannot be parsed.
|
|
1456
|
+
*/
|
|
1457
|
+
function strToColorSpace(color) {
|
|
1458
|
+
if (!color) return void 0;
|
|
1459
|
+
const cached = colorSpaceCache.get(color);
|
|
1460
|
+
if (cached !== void 0) return cached;
|
|
1461
|
+
const sameSpace = parseSameSpaceFunc(color, currentColorSpace);
|
|
1462
|
+
if (sameSpace) {
|
|
1463
|
+
const result = buildSameSpaceString(sameSpace, currentColorSpace);
|
|
1464
|
+
colorSpaceCache.set(color, result);
|
|
1465
|
+
return result;
|
|
1466
|
+
}
|
|
1467
|
+
const rgba = resolveToRgbaValues(color);
|
|
1468
|
+
if (!rgba) {
|
|
1469
|
+
colorSpaceCache.set(color, null);
|
|
1470
|
+
return null;
|
|
1471
|
+
}
|
|
1472
|
+
const result = rgbValuesToColorString(rgba[0], rgba[1], rgba[2], currentColorSpace, rgba[3]);
|
|
1473
|
+
colorSpaceCache.set(color, result);
|
|
1474
|
+
return result;
|
|
1475
|
+
}
|
|
1322
1476
|
/**
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
* Color properties are handled separately via the #name token convention
|
|
1327
|
-
* (--name-color gets \<color\> syntax automatically in getEffectiveDefinition).
|
|
1328
|
-
*
|
|
1329
|
-
* @param value - The CSS value to infer from (e.g. '10px', '1', '45deg')
|
|
1330
|
-
* @returns Inferred syntax and initial value, or null if not inferable
|
|
1477
|
+
* Extract the decomposed components of a color in the configured color space.
|
|
1478
|
+
* Returns a space-separated string of components without the wrapping function.
|
|
1479
|
+
* Alpha is NOT included — components are used for alpha composition via `/ alpha`.
|
|
1331
1480
|
*/
|
|
1332
|
-
function
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
if (
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
initialValue: "0"
|
|
1341
|
-
};
|
|
1481
|
+
function getColorSpaceComponents(color) {
|
|
1482
|
+
const cached = componentsCache.get(color);
|
|
1483
|
+
if (cached !== void 0) return cached;
|
|
1484
|
+
const sameSpace = parseSameSpaceFunc(color, currentColorSpace);
|
|
1485
|
+
if (sameSpace) {
|
|
1486
|
+
const result = buildSameSpaceComponents(sameSpace, currentColorSpace);
|
|
1487
|
+
componentsCache.set(color, result);
|
|
1488
|
+
return result;
|
|
1342
1489
|
}
|
|
1343
|
-
const
|
|
1344
|
-
if (
|
|
1345
|
-
|
|
1346
|
-
|
|
1490
|
+
const rgba = resolveToRgbaValues(color);
|
|
1491
|
+
if (!rgba) return color;
|
|
1492
|
+
const result = rgbValuesToComponents(rgba[0], rgba[1], rgba[2], currentColorSpace);
|
|
1493
|
+
componentsCache.set(color, result);
|
|
1494
|
+
return result;
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Convert a color initial value (from @property definitions) to components
|
|
1498
|
+
* in the configured color space.
|
|
1499
|
+
*/
|
|
1500
|
+
function colorInitialValueToComponents(initialValue) {
|
|
1501
|
+
if (initialValue == null) return getDefaultComponents();
|
|
1502
|
+
const val = String(initialValue).trim().toLowerCase();
|
|
1503
|
+
if (val === "transparent" || val === "rgba(0,0,0,0)" || val === "") return getDefaultComponents();
|
|
1504
|
+
if (val === "white") return rgbValuesToComponents(255, 255, 255, currentColorSpace);
|
|
1505
|
+
if (val === "black") return rgbValuesToComponents(0, 0, 0, currentColorSpace);
|
|
1506
|
+
const rgbMatch = val.match(/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);
|
|
1507
|
+
if (rgbMatch) return rgbValuesToComponents(parseInt(rgbMatch[1]), parseInt(rgbMatch[2]), parseInt(rgbMatch[3]), currentColorSpace);
|
|
1508
|
+
return getDefaultComponents();
|
|
1509
|
+
}
|
|
1510
|
+
function getDefaultComponents() {
|
|
1511
|
+
switch (currentColorSpace) {
|
|
1512
|
+
case "rgb": return "0 0 0";
|
|
1513
|
+
case "hsl": return "0 0% 0%";
|
|
1514
|
+
case "oklch": return "0 0 0";
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Get the CSS @property syntax for the companion components variable.
|
|
1519
|
+
* RGB and OKLCH components are all plain numbers, so `<number>+` works.
|
|
1520
|
+
* HSL includes percentages (`h s% l%`), so `*` is the only safe choice.
|
|
1521
|
+
*/
|
|
1522
|
+
function getComponentPropertySyntax() {
|
|
1523
|
+
switch (currentColorSpace) {
|
|
1524
|
+
case "rgb":
|
|
1525
|
+
case "oklch": return "<number>+";
|
|
1526
|
+
default: return "*";
|
|
1347
1527
|
}
|
|
1348
|
-
return null;
|
|
1349
1528
|
}
|
|
1350
1529
|
//#endregion
|
|
1351
1530
|
//#region src/utils/hash.ts
|
|
@@ -1602,7 +1781,7 @@ function classify(raw, opts, recurse) {
|
|
|
1602
1781
|
if (baseToken in predefinedTokens) {
|
|
1603
1782
|
const resolvedValue = predefinedTokens[baseToken];
|
|
1604
1783
|
if (resolvedValue.startsWith("#")) return classify(`${resolvedValue.toLowerCase()}.${rawAlpha}`, opts, recurse);
|
|
1605
|
-
const funcMatch = resolvedValue.match(/^(rgba?|hsla?|hwb|oklab|oklch|lab|lch|color|okhsl|device-cmyk|gray|color-mix|color-contrast)\((.+)\)$/i);
|
|
1784
|
+
const funcMatch = resolvedValue.match(/^(rgba?|hsla?|hwb|oklab|oklch|lab|lch|color|okhsl|okhst|device-cmyk|gray|color-mix|color-contrast)\((.+)\)$/i);
|
|
1606
1785
|
if (funcMatch) {
|
|
1607
1786
|
const [, funcName, args] = funcMatch;
|
|
1608
1787
|
let alpha;
|
|
@@ -1983,20 +2162,7 @@ var StyleParser = class {
|
|
|
1983
2162
|
}
|
|
1984
2163
|
};
|
|
1985
2164
|
//#endregion
|
|
1986
|
-
//#region src/plugins/
|
|
1987
|
-
/**
|
|
1988
|
-
* OKHSL Plugin for Tasty
|
|
1989
|
-
*
|
|
1990
|
-
* Converts OKHSL color syntax to RGB notation.
|
|
1991
|
-
* Supports angle units: deg, turn, rad, or unitless (degrees).
|
|
1992
|
-
*
|
|
1993
|
-
* Examples:
|
|
1994
|
-
* okhsl(240.5 50% 50%)
|
|
1995
|
-
* okhsl(240.5deg 50% 50%)
|
|
1996
|
-
* okhsl(0.25turn 50% 50%)
|
|
1997
|
-
* okhsl(1.57rad 50% 50%)
|
|
1998
|
-
*/
|
|
1999
|
-
const conversionCache = new Lru(500);
|
|
2165
|
+
//#region src/plugins/color-func.ts
|
|
2000
2166
|
const clamp = (value, min, max) => Math.max(Math.min(value, max), min);
|
|
2001
2167
|
/**
|
|
2002
2168
|
* Parse an angle value with optional unit.
|
|
@@ -2022,32 +2188,56 @@ const parsePercentage = (value) => {
|
|
|
2022
2188
|
return value.includes("%") ? num / 100 : num;
|
|
2023
2189
|
};
|
|
2024
2190
|
/**
|
|
2191
|
+
* Creates a color function handler for the tasty parser.
|
|
2192
|
+
* @param name The name of the color space (e.g., 'okhsl', 'okhst')
|
|
2193
|
+
* @param channelLabel The label for the channels in warnings (e.g., 'H S L')
|
|
2194
|
+
* @param convert A function that converts the parsed H, C2, C3 values to sRGB [r, g, b] (0-1)
|
|
2195
|
+
*/
|
|
2196
|
+
function createColorFunc(name, channelLabel, convert) {
|
|
2197
|
+
const conversionCache = new Lru(500);
|
|
2198
|
+
return (groups) => {
|
|
2199
|
+
if (groups.length === 0 || groups[0].all.length < 3) {
|
|
2200
|
+
console.warn(`[${name}] Expected 3 values (${channelLabel}), got:`, groups);
|
|
2201
|
+
return "rgb(0% 0% 0%)";
|
|
2202
|
+
}
|
|
2203
|
+
const group = groups[0];
|
|
2204
|
+
const tokens = group.all;
|
|
2205
|
+
const alpha = group.parts.length > 1 && group.parts[1].all.length > 0 ? group.parts[1].output : void 0;
|
|
2206
|
+
const cacheKey = tokens.slice(0, 3).join(" ") + (alpha ? ` / ${alpha}` : "");
|
|
2207
|
+
const cached = conversionCache.get(cacheKey);
|
|
2208
|
+
if (cached) return cached;
|
|
2209
|
+
const h = parseAngle(tokens[0]);
|
|
2210
|
+
const c2 = parsePercentage(tokens[1]);
|
|
2211
|
+
const c3 = parsePercentage(tokens[2]);
|
|
2212
|
+
const [r, g, b] = convert(h, clamp(c2, 0, 1), clamp(c3, 0, 1));
|
|
2213
|
+
const format = (n) => {
|
|
2214
|
+
const pct = n * 100;
|
|
2215
|
+
return parseFloat(pct.toFixed(1)).toString() + "%";
|
|
2216
|
+
};
|
|
2217
|
+
const result = alpha ? `rgb(${format(r)} ${format(g)} ${format(b)} / ${alpha})` : `rgb(${format(r)} ${format(g)} ${format(b)})`;
|
|
2218
|
+
conversionCache.set(cacheKey, result);
|
|
2219
|
+
return result;
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
//#endregion
|
|
2223
|
+
//#region src/plugins/okhsl-plugin.ts
|
|
2224
|
+
/**
|
|
2225
|
+
* OKHSL Plugin for Tasty
|
|
2226
|
+
*
|
|
2227
|
+
* Converts OKHSL color syntax to RGB notation.
|
|
2228
|
+
* Supports angle units: deg, turn, rad, or unitless (degrees).
|
|
2229
|
+
*
|
|
2230
|
+
* Examples:
|
|
2231
|
+
* okhsl(240.5 50% 50%)
|
|
2232
|
+
* okhsl(240.5deg 50% 50%)
|
|
2233
|
+
* okhsl(0.25turn 50% 50%)
|
|
2234
|
+
* okhsl(1.57rad 50% 50%)
|
|
2235
|
+
*/
|
|
2236
|
+
/**
|
|
2025
2237
|
* The okhsl function handler for tasty parser.
|
|
2026
2238
|
* Receives parsed style groups and returns an RGB color string.
|
|
2027
2239
|
*/
|
|
2028
|
-
const okhslFunc = (
|
|
2029
|
-
if (groups.length === 0 || groups[0].all.length < 3) {
|
|
2030
|
-
console.warn("[okhsl] Expected 3 values (H S L), got:", groups);
|
|
2031
|
-
return "rgb(0% 0% 0%)";
|
|
2032
|
-
}
|
|
2033
|
-
const group = groups[0];
|
|
2034
|
-
const tokens = group.all;
|
|
2035
|
-
const alpha = group.parts.length > 1 && group.parts[1].all.length > 0 ? group.parts[1].output : void 0;
|
|
2036
|
-
const cacheKey = tokens.slice(0, 3).join(" ") + (alpha ? ` / ${alpha}` : "");
|
|
2037
|
-
const cached = conversionCache.get(cacheKey);
|
|
2038
|
-
if (cached) return cached;
|
|
2039
|
-
const h = parseAngle(tokens[0]);
|
|
2040
|
-
const s = parsePercentage(tokens[1]);
|
|
2041
|
-
const l = parsePercentage(tokens[2]);
|
|
2042
|
-
const [r, g, b] = okhslToSrgb(h, clamp(s, 0, 1), clamp(l, 0, 1));
|
|
2043
|
-
const format = (n) => {
|
|
2044
|
-
const pct = n * 100;
|
|
2045
|
-
return parseFloat(pct.toFixed(1)).toString() + "%";
|
|
2046
|
-
};
|
|
2047
|
-
const result = alpha ? `rgb(${format(r)} ${format(g)} ${format(b)} / ${alpha})` : `rgb(${format(r)} ${format(g)} ${format(b)})`;
|
|
2048
|
-
conversionCache.set(cacheKey, result);
|
|
2049
|
-
return result;
|
|
2050
|
-
};
|
|
2240
|
+
const okhslFunc = createColorFunc("okhsl", "H S L", okhslToSrgb);
|
|
2051
2241
|
/**
|
|
2052
2242
|
* OKHSL Plugin for Tasty.
|
|
2053
2243
|
*
|
|
@@ -2075,6 +2265,52 @@ const okhslPlugin = () => ({
|
|
|
2075
2265
|
funcs: { okhsl: okhslFunc }
|
|
2076
2266
|
});
|
|
2077
2267
|
//#endregion
|
|
2268
|
+
//#region src/plugins/okhst-plugin.ts
|
|
2269
|
+
/**
|
|
2270
|
+
* OKHST Plugin for Tasty
|
|
2271
|
+
*
|
|
2272
|
+
* Converts OKHST color syntax to RGB notation.
|
|
2273
|
+
* OKHST is OKHSL with the lightness axis replaced by a contrast-uniform tone axis.
|
|
2274
|
+
* Supports angle units: deg, turn, rad, or unitless (degrees).
|
|
2275
|
+
*
|
|
2276
|
+
* Examples:
|
|
2277
|
+
* okhst(240.5 50% 50%)
|
|
2278
|
+
* okhst(240.5deg 50% 50%)
|
|
2279
|
+
* okhst(0.25turn 50% 50%)
|
|
2280
|
+
* okhst(1.57rad 50% 50%)
|
|
2281
|
+
*/
|
|
2282
|
+
/**
|
|
2283
|
+
* The okhst function handler for tasty parser.
|
|
2284
|
+
* Receives parsed style groups and returns an RGB color string.
|
|
2285
|
+
*/
|
|
2286
|
+
const okhstFunc = createColorFunc("okhst", "H S T", okhstToSrgb);
|
|
2287
|
+
/**
|
|
2288
|
+
* OKHST Plugin for Tasty.
|
|
2289
|
+
*
|
|
2290
|
+
* Adds support for the `okhst()` color function in tasty styles.
|
|
2291
|
+
*
|
|
2292
|
+
* @example
|
|
2293
|
+
* ```ts
|
|
2294
|
+
* import { configure } from '@tenphi/tasty';
|
|
2295
|
+
* import { okhstPlugin } from '@tenphi/tasty';
|
|
2296
|
+
*
|
|
2297
|
+
* configure({
|
|
2298
|
+
* plugins: [okhstPlugin()],
|
|
2299
|
+
* });
|
|
2300
|
+
*
|
|
2301
|
+
* // Now you can use okhst in styles:
|
|
2302
|
+
* const Box = tasty({
|
|
2303
|
+
* styles: {
|
|
2304
|
+
* fill: 'okhst(240 50% 50%)',
|
|
2305
|
+
* },
|
|
2306
|
+
* });
|
|
2307
|
+
* ```
|
|
2308
|
+
*/
|
|
2309
|
+
const okhstPlugin = () => ({
|
|
2310
|
+
name: "okhst",
|
|
2311
|
+
funcs: { okhst: okhstFunc }
|
|
2312
|
+
});
|
|
2313
|
+
//#endregion
|
|
2078
2314
|
//#region src/utils/styles.ts
|
|
2079
2315
|
/**
|
|
2080
2316
|
* Normalize a color token value.
|
|
@@ -2101,7 +2337,7 @@ function isSimpleColorFast(val) {
|
|
|
2101
2337
|
case 114: return val.charCodeAt(1) === 103 && val.charCodeAt(2) === 98;
|
|
2102
2338
|
case 104: return val.charCodeAt(1) === 115 && val.charCodeAt(2) === 108;
|
|
2103
2339
|
case 108: return val.charCodeAt(1) === 99 && val.charCodeAt(2) === 104;
|
|
2104
|
-
case 111: return val.startsWith("oklch(") || val.startsWith("okhsl(");
|
|
2340
|
+
case 111: return val.startsWith("oklch(") || val.startsWith("okhsl(") || val.startsWith("okhst(");
|
|
2105
2341
|
case 118: return RE_VAR_COLOR.test(val);
|
|
2106
2342
|
case 99: return val === "currentColor" || val === "currentcolor";
|
|
2107
2343
|
case 116: return val === "transparent";
|
|
@@ -2134,7 +2370,10 @@ function getOrCreateParser() {
|
|
|
2134
2370
|
}
|
|
2135
2371
|
return __tastyParser;
|
|
2136
2372
|
}
|
|
2137
|
-
const __tastyFuncs = {
|
|
2373
|
+
const __tastyFuncs = {
|
|
2374
|
+
okhsl: okhslFunc,
|
|
2375
|
+
okhst: okhstFunc
|
|
2376
|
+
};
|
|
2138
2377
|
function customFunc(name, fn) {
|
|
2139
2378
|
__tastyFuncs[name] = fn;
|
|
2140
2379
|
getOrCreateParser().setFuncs(__tastyFuncs);
|
|
@@ -3783,7 +4022,7 @@ function resetHandlers() {
|
|
|
3783
4022
|
for (const key of Object.keys(STYLE_HANDLER_MAP$1)) delete STYLE_HANDLER_MAP$1[key];
|
|
3784
4023
|
for (const key of Object.keys(initialHandlerMapSnapshot)) STYLE_HANDLER_MAP$1[key] = [...initialHandlerMapSnapshot[key]];
|
|
3785
4024
|
}
|
|
3786
|
-
function defineCustomStyle
|
|
4025
|
+
function defineCustomStyle(names, handler) {
|
|
3787
4026
|
let handlerWithLookup;
|
|
3788
4027
|
if (typeof names === "function") {
|
|
3789
4028
|
handlerWithLookup = names;
|
|
@@ -3798,16 +4037,16 @@ function defineCustomStyle$1(names, handler) {
|
|
|
3798
4037
|
STYLE_HANDLER_MAP$1[name].push(handlerWithLookup);
|
|
3799
4038
|
});
|
|
3800
4039
|
}
|
|
3801
|
-
function defineStyleAlias
|
|
4040
|
+
function defineStyleAlias(styleName, cssStyleName, converter) {
|
|
3802
4041
|
const styleHandler = createStyle(styleName, cssStyleName, converter);
|
|
3803
4042
|
if (!STYLE_HANDLER_MAP$1[styleName]) STYLE_HANDLER_MAP$1[styleName] = [];
|
|
3804
4043
|
STYLE_HANDLER_MAP$1[styleName].push(styleHandler);
|
|
3805
4044
|
}
|
|
3806
4045
|
function predefine() {
|
|
3807
|
-
defineStyleAlias
|
|
3808
|
-
defineStyleAlias
|
|
3809
|
-
defineStyleAlias
|
|
3810
|
-
defineStyleAlias
|
|
4046
|
+
defineStyleAlias("gridAreas", "grid-template-areas");
|
|
4047
|
+
defineStyleAlias("gridColumns", "grid-template-columns", columnsConverter);
|
|
4048
|
+
defineStyleAlias("gridRows", "grid-template-rows", rowsConverter);
|
|
4049
|
+
defineStyleAlias("gridTemplate", "grid-template", (val) => {
|
|
3811
4050
|
if (typeof val !== "string") return;
|
|
3812
4051
|
return val.split("/").map((s, i) => (i ? columnsConverter : rowsConverter)(s)).join("/");
|
|
3813
4052
|
});
|
|
@@ -3833,12 +4072,12 @@ function predefine() {
|
|
|
3833
4072
|
scrollbarStyle,
|
|
3834
4073
|
fadeStyle,
|
|
3835
4074
|
insetStyle
|
|
3836
|
-
].forEach((handler) => defineCustomStyle
|
|
4075
|
+
].forEach((handler) => defineCustomStyle(handler));
|
|
3837
4076
|
captureInitialHandlerState();
|
|
3838
4077
|
return {
|
|
3839
4078
|
STYLE_HANDLER_MAP: STYLE_HANDLER_MAP$1,
|
|
3840
|
-
defineCustomStyle
|
|
3841
|
-
defineStyleAlias
|
|
4079
|
+
defineCustomStyle,
|
|
4080
|
+
defineStyleAlias
|
|
3842
4081
|
};
|
|
3843
4082
|
}
|
|
3844
4083
|
/**
|
|
@@ -3969,7 +4208,7 @@ const styleHandlers = {
|
|
|
3969
4208
|
};
|
|
3970
4209
|
//#endregion
|
|
3971
4210
|
//#region src/styles/index.ts
|
|
3972
|
-
const { STYLE_HANDLER_MAP
|
|
4211
|
+
const { STYLE_HANDLER_MAP } = predefine();
|
|
3973
4212
|
//#endregion
|
|
3974
4213
|
//#region src/injector/sheet-manager.ts
|
|
3975
4214
|
const supportsConstructableSheets = typeof CSSStyleSheet !== "undefined" && (() => {
|
|
@@ -6205,9 +6444,13 @@ function simplifyInner(node) {
|
|
|
6205
6444
|
return node;
|
|
6206
6445
|
}
|
|
6207
6446
|
if (node.kind === "compound") {
|
|
6447
|
+
const key = getConditionUniqueId(node);
|
|
6448
|
+
const cached = simplifyCache.get(key);
|
|
6449
|
+
if (cached) return cached;
|
|
6208
6450
|
const simplifiedChildren = node.children.map((c) => simplifyInner(c));
|
|
6209
|
-
|
|
6210
|
-
|
|
6451
|
+
const result = node.operator === "AND" ? simplifyAnd(simplifiedChildren) : simplifyOr(simplifiedChildren);
|
|
6452
|
+
simplifyCache.set(key, result);
|
|
6453
|
+
return result;
|
|
6211
6454
|
}
|
|
6212
6455
|
return node;
|
|
6213
6456
|
}
|
|
@@ -6225,13 +6468,23 @@ function simplifyAnd(children) {
|
|
|
6225
6468
|
if (hasRangeContradiction(terms)) return falseCondition();
|
|
6226
6469
|
if (hasAttributeConflict(terms)) return falseCondition();
|
|
6227
6470
|
if (hasContainerStyleConflict(terms)) return falseCondition();
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6471
|
+
const MAX_SIMPLIFY_PASSES = 4;
|
|
6472
|
+
for (let pass = 0; pass < MAX_SIMPLIFY_PASSES; pass++) {
|
|
6473
|
+
const lengthBefore = terms.length;
|
|
6474
|
+
const keyBefore = simplifyTermsKey(terms);
|
|
6475
|
+
terms = removeImpliedNegations(terms);
|
|
6476
|
+
terms = deduplicateTerms(terms);
|
|
6477
|
+
terms = mergeRanges(terms);
|
|
6478
|
+
terms = sortTerms(terms);
|
|
6479
|
+
terms = applyAbsorptionAnd(terms);
|
|
6480
|
+
terms = applyConsensusAnd(terms);
|
|
6481
|
+
terms = pruneContradictedOrBranches(terms);
|
|
6482
|
+
if (terms.length === 0) break;
|
|
6483
|
+
if (terms.length === 1) break;
|
|
6484
|
+
if (hasContradiction(terms)) return falseCondition();
|
|
6485
|
+
if (hasAttributeConflict(terms)) return falseCondition();
|
|
6486
|
+
if (terms.length === lengthBefore && simplifyTermsKey(terms) === keyBefore) break;
|
|
6487
|
+
}
|
|
6235
6488
|
if (terms.length === 0) return trueCondition();
|
|
6236
6489
|
if (terms.length === 1) return terms[0];
|
|
6237
6490
|
return {
|
|
@@ -6546,6 +6799,13 @@ function removeImpliedNegations(terms) {
|
|
|
6546
6799
|
const isImplied = buildImpliedNegationCheck(terms);
|
|
6547
6800
|
return terms.filter((t) => !isImplied(t));
|
|
6548
6801
|
}
|
|
6802
|
+
/**
|
|
6803
|
+
* Build a stable, order-insensitive key for a list of AND terms.
|
|
6804
|
+
* Used to detect fixpoint convergence in `simplifyAnd`.
|
|
6805
|
+
*/
|
|
6806
|
+
function simplifyTermsKey(terms) {
|
|
6807
|
+
return terms.map((t) => getConditionUniqueId(t)).sort().join("&");
|
|
6808
|
+
}
|
|
6549
6809
|
function deduplicateTerms(terms) {
|
|
6550
6810
|
const seen = /* @__PURE__ */ new Set();
|
|
6551
6811
|
const result = [];
|
|
@@ -7421,6 +7681,18 @@ function wrapInIsOrNot(args, negated) {
|
|
|
7421
7681
|
return `${negated ? ":not" : ":is"}(${args.sort().join(", ")})`;
|
|
7422
7682
|
}
|
|
7423
7683
|
/**
|
|
7684
|
+
* Wrap a non-empty selector fragment in `:where(...)` to zero its
|
|
7685
|
+
* specificity. Tasty anchors specificity solely on the doubled class
|
|
7686
|
+
* (`.tXX.tXX`) and `data-element` attributes; every stateful selector
|
|
7687
|
+
* (modifiers, pseudos, :is()/:not() groups, root/parent context) is wrapped
|
|
7688
|
+
* so it contributes nothing to specificity and the cascade is decided by
|
|
7689
|
+
* source order alone. Empty input passes through unchanged.
|
|
7690
|
+
*/
|
|
7691
|
+
function wrapWhere(inner) {
|
|
7692
|
+
if (!inner) return "";
|
|
7693
|
+
return `:where(${inner})`;
|
|
7694
|
+
}
|
|
7695
|
+
/**
|
|
7424
7696
|
* Convert a selector group to a CSS selector fragment.
|
|
7425
7697
|
*
|
|
7426
7698
|
* Single-branch groups are unwrapped (no :is() wrapper).
|
|
@@ -7524,7 +7796,7 @@ function rootGroupsToCSS(groups) {
|
|
|
7524
7796
|
if (optimized.length === 0) return void 0;
|
|
7525
7797
|
let prefix = ":root";
|
|
7526
7798
|
for (const group of optimized) prefix += selectorGroupToCSS(group);
|
|
7527
|
-
return prefix;
|
|
7799
|
+
return wrapWhere(prefix);
|
|
7528
7800
|
}
|
|
7529
7801
|
/**
|
|
7530
7802
|
* Convert parent groups to CSS selector fragments (for final output).
|
|
@@ -7536,7 +7808,8 @@ function parentGroupsToCSS(groups) {
|
|
|
7536
7808
|
for (const group of groups) {
|
|
7537
7809
|
const combinator = group.direct ? " > *" : " *";
|
|
7538
7810
|
const args = group.branches.map((branch) => branchToCSS(branch) + combinator);
|
|
7539
|
-
|
|
7811
|
+
const inner = group.negated ? `:not(${args.sort().join(", ")})` : args.sort().join(", ");
|
|
7812
|
+
result += wrapWhere(inner);
|
|
7540
7813
|
}
|
|
7541
7814
|
return result;
|
|
7542
7815
|
}
|
|
@@ -7868,6 +8141,14 @@ function andToCSS(children) {
|
|
|
7868
8141
|
};
|
|
7869
8142
|
}
|
|
7870
8143
|
/**
|
|
8144
|
+
* Check if a condition involves an `@supports` query (recursively).
|
|
8145
|
+
*/
|
|
8146
|
+
function branchHasSupports(node) {
|
|
8147
|
+
if (node.kind === "state") return node.type === "supports";
|
|
8148
|
+
if (isCompoundCondition(node)) return node.children.some(branchHasSupports);
|
|
8149
|
+
return false;
|
|
8150
|
+
}
|
|
8151
|
+
/**
|
|
7871
8152
|
* Make OR branches within AND children mutually exclusive.
|
|
7872
8153
|
*
|
|
7873
8154
|
* For an AND child that is OR(A, B), transforms it to OR(A, B & !A)
|
|
@@ -7884,9 +8165,10 @@ function makeOrBranchesExclusive(children) {
|
|
|
7884
8165
|
if (!isCompoundCondition(child) || child.operator !== "OR") return child;
|
|
7885
8166
|
if (child.children.length <= 1) return child;
|
|
7886
8167
|
if (!branchesProduceDifferentContexts(child.children)) return child;
|
|
8168
|
+
const sortedBranches = [...child.children].sort((a, b) => (branchHasSupports(a) ? 0 : 1) - (branchHasSupports(b) ? 0 : 1));
|
|
7887
8169
|
const exclusiveBranches = [];
|
|
7888
8170
|
const priorBranches = [];
|
|
7889
|
-
for (const branch of
|
|
8171
|
+
for (const branch of sortedBranches) {
|
|
7890
8172
|
if (priorBranches.length === 0) exclusiveBranches.push(branch);
|
|
7891
8173
|
else {
|
|
7892
8174
|
let exclusive = branch;
|
|
@@ -7936,7 +8218,69 @@ function branchesProduceDifferentContexts(branches) {
|
|
|
7936
8218
|
* so here we just collect all variants. Any remaining ORs in the condition
|
|
7937
8219
|
* tree (e.g., from De Morgan expansion) are handled as simple alternatives.
|
|
7938
8220
|
*/
|
|
8221
|
+
/**
|
|
8222
|
+
* Serialize a single negated own-element selector leaf (modifier or pseudo)
|
|
8223
|
+
* to its *positive* selector string, for use inside a combined `:not(...)`.
|
|
8224
|
+
*
|
|
8225
|
+
* Returns `null` when the node is not a negated, own-element selector leaf
|
|
8226
|
+
* (e.g. positive, or a media/container/parent/root/own/supports/starting
|
|
8227
|
+
* wrapper, or a compound), which means it cannot participate in De Morgan
|
|
8228
|
+
* recombination.
|
|
8229
|
+
*/
|
|
8230
|
+
function negatedSelectorLeafToPositiveSelector(node) {
|
|
8231
|
+
if (node.kind !== "state" || !node.negated) return null;
|
|
8232
|
+
if (node.type === "modifier") return modifierToCSS({
|
|
8233
|
+
attribute: node.attribute,
|
|
8234
|
+
value: node.value,
|
|
8235
|
+
operator: node.operator,
|
|
8236
|
+
negated: false
|
|
8237
|
+
});
|
|
8238
|
+
if (node.type === "pseudo") {
|
|
8239
|
+
const p = node.pseudo;
|
|
8240
|
+
if ((p.startsWith(":is(") || p.startsWith(":where(")) && !p.includes(",")) {
|
|
8241
|
+
const inner = p.slice(p.indexOf("(") + 1, -1);
|
|
8242
|
+
if (!/\s/.test(inner)) return inner;
|
|
8243
|
+
return `:is(${inner})`;
|
|
8244
|
+
}
|
|
8245
|
+
return p;
|
|
8246
|
+
}
|
|
8247
|
+
return null;
|
|
8248
|
+
}
|
|
8249
|
+
/**
|
|
8250
|
+
* De Morgan recombination for an OR whose every branch is a negated
|
|
8251
|
+
* own-element selector leaf:
|
|
8252
|
+
*
|
|
8253
|
+
* OR(¬a, ¬b, ¬c) ≡ ¬(a ∧ b ∧ c) → single `:not(a b c)`
|
|
8254
|
+
*
|
|
8255
|
+
* This keeps the catch-all/default exclusive condition (which has no
|
|
8256
|
+
* positive terms to prune against) from exploding into a Cartesian product
|
|
8257
|
+
* of OR branches at `andToCSS`. Returns `null` when recombination does not
|
|
8258
|
+
* apply, so genuine unions (e.g. `:hover | :focus`) fall through to the
|
|
8259
|
+
* normal per-branch materialization.
|
|
8260
|
+
*/
|
|
8261
|
+
function tryRecombineNegatedSelectorOr(children) {
|
|
8262
|
+
if (children.length < 2) return null;
|
|
8263
|
+
const positiveSelectors = [];
|
|
8264
|
+
for (const child of children) {
|
|
8265
|
+
const sel = negatedSelectorLeafToPositiveSelector(child);
|
|
8266
|
+
if (sel === null) return null;
|
|
8267
|
+
positiveSelectors.push(sel);
|
|
8268
|
+
}
|
|
8269
|
+
positiveSelectors.sort();
|
|
8270
|
+
const compound = positiveSelectors.join("");
|
|
8271
|
+
const v = emptyVariant();
|
|
8272
|
+
v.pseudoConditions.push({
|
|
8273
|
+
pseudo: `:is(${compound})`,
|
|
8274
|
+
negated: true
|
|
8275
|
+
});
|
|
8276
|
+
return {
|
|
8277
|
+
variants: [v],
|
|
8278
|
+
isImpossible: false
|
|
8279
|
+
};
|
|
8280
|
+
}
|
|
7939
8281
|
function orToCSS(children) {
|
|
8282
|
+
const recombined = tryRecombineNegatedSelectorOr(children);
|
|
8283
|
+
if (recombined !== null) return recombined;
|
|
7940
8284
|
const allVariants = [];
|
|
7941
8285
|
for (const child of children) {
|
|
7942
8286
|
const childCSS = conditionToCSSInner(child);
|
|
@@ -8135,6 +8479,21 @@ function buildAtRulesFromVariant(variant) {
|
|
|
8135
8479
|
return atRules;
|
|
8136
8480
|
}
|
|
8137
8481
|
//#endregion
|
|
8482
|
+
//#region src/pipeline/warnings.ts
|
|
8483
|
+
const defaultWarningHandler = (warning) => {
|
|
8484
|
+
console.warn(`[Tasty] ${warning.message}`);
|
|
8485
|
+
};
|
|
8486
|
+
let warningHandler = defaultWarningHandler;
|
|
8487
|
+
/**
|
|
8488
|
+
* Emit a structured pipeline warning via the configured handler.
|
|
8489
|
+
*/
|
|
8490
|
+
function emitWarning(code, message) {
|
|
8491
|
+
warningHandler({
|
|
8492
|
+
code,
|
|
8493
|
+
message
|
|
8494
|
+
});
|
|
8495
|
+
}
|
|
8496
|
+
//#endregion
|
|
8138
8497
|
//#region src/pipeline/exclusive.ts
|
|
8139
8498
|
/**
|
|
8140
8499
|
* Build exclusive conditions for a list of parsed style entries.
|
|
@@ -8163,9 +8522,18 @@ function buildAtRulesFromVariant(variant) {
|
|
|
8163
8522
|
function buildExclusiveConditions(entries) {
|
|
8164
8523
|
const result = [];
|
|
8165
8524
|
const priorConditions = [];
|
|
8525
|
+
const floors = [];
|
|
8166
8526
|
for (const entry of entries) {
|
|
8527
|
+
if (entry.floor) {
|
|
8528
|
+
floors.push(entry);
|
|
8529
|
+
continue;
|
|
8530
|
+
}
|
|
8167
8531
|
let exclusive = entry.condition;
|
|
8168
|
-
for (const prior of priorConditions)
|
|
8532
|
+
for (const prior of priorConditions) {
|
|
8533
|
+
if (prior.kind === "true") continue;
|
|
8534
|
+
if (entry.condition.kind !== "true" && simplifyCondition(and(entry.condition, prior)).kind === "false") continue;
|
|
8535
|
+
exclusive = and(exclusive, not(prior));
|
|
8536
|
+
}
|
|
8169
8537
|
const simplified = simplifyCondition(exclusive);
|
|
8170
8538
|
if (simplified.kind === "false") continue;
|
|
8171
8539
|
result.push({
|
|
@@ -8174,6 +8542,10 @@ function buildExclusiveConditions(entries) {
|
|
|
8174
8542
|
});
|
|
8175
8543
|
if (entry.condition.kind !== "true") priorConditions.push(entry.condition);
|
|
8176
8544
|
}
|
|
8545
|
+
for (const floor of floors) result.push({
|
|
8546
|
+
...floor,
|
|
8547
|
+
exclusiveCondition: floor.condition
|
|
8548
|
+
});
|
|
8177
8549
|
return result;
|
|
8178
8550
|
}
|
|
8179
8551
|
/**
|
|
@@ -8186,19 +8558,85 @@ function buildExclusiveConditions(entries) {
|
|
|
8186
8558
|
*/
|
|
8187
8559
|
function parseStyleEntries(styleKey, valueMap, parseCondition) {
|
|
8188
8560
|
const entries = [];
|
|
8189
|
-
|
|
8561
|
+
let floorEntry = null;
|
|
8562
|
+
Object.keys(valueMap).forEach((stateKey) => {
|
|
8190
8563
|
const value = valueMap[stateKey];
|
|
8564
|
+
if (stateKey === "_") {
|
|
8565
|
+
floorEntry = {
|
|
8566
|
+
styleKey,
|
|
8567
|
+
stateKey,
|
|
8568
|
+
value,
|
|
8569
|
+
condition: trueCondition(),
|
|
8570
|
+
priority: 0,
|
|
8571
|
+
floor: true
|
|
8572
|
+
};
|
|
8573
|
+
return;
|
|
8574
|
+
}
|
|
8575
|
+
if (isMisusedFallbackKey(stateKey)) {
|
|
8576
|
+
emitWarning("INVALID_FALLBACK_KEY", `Style key "${stateKey}" (in "${styleKey}") combines the fallback "_" with other state logic. "_" can only be used on its own as a map-wide fallback floor. The key has been ignored.`);
|
|
8577
|
+
return;
|
|
8578
|
+
}
|
|
8191
8579
|
const condition = stateKey === "" ? trueCondition() : parseCondition(stateKey);
|
|
8192
8580
|
entries.push({
|
|
8193
8581
|
styleKey,
|
|
8194
8582
|
stateKey,
|
|
8195
8583
|
value,
|
|
8196
8584
|
condition,
|
|
8197
|
-
priority:
|
|
8585
|
+
priority: 0
|
|
8198
8586
|
});
|
|
8199
8587
|
});
|
|
8200
|
-
|
|
8201
|
-
|
|
8588
|
+
if (floorEntry !== null) {
|
|
8589
|
+
const hasOtherStates = entries.some((e) => e.condition.kind !== "true");
|
|
8590
|
+
const hasDefault = entries.some((e) => e.condition.kind === "true");
|
|
8591
|
+
if (!hasOtherStates && hasDefault) {
|
|
8592
|
+
emitWarning("REDUNDANT_DEFAULT_STATE", `Style "${styleKey}" defines both a "_" fallback and a "" default with no other states. The "" default is redundant (always superseded by "_"); the "_" value is used and the "" default is ignored.`);
|
|
8593
|
+
entries.length = 0;
|
|
8594
|
+
}
|
|
8595
|
+
}
|
|
8596
|
+
const normalized = normalizeDefaultStates(entries, styleKey);
|
|
8597
|
+
const ordered = floorEntry !== null ? [floorEntry, ...normalized] : normalized;
|
|
8598
|
+
ordered.forEach((entry, index) => {
|
|
8599
|
+
entry.priority = index;
|
|
8600
|
+
});
|
|
8601
|
+
ordered.reverse();
|
|
8602
|
+
return ordered;
|
|
8603
|
+
}
|
|
8604
|
+
/**
|
|
8605
|
+
* Detect a misused standalone `_` fallback key: a key that is not exactly
|
|
8606
|
+
* `_` but contains `_` as a standalone atom among state-logic operators
|
|
8607
|
+
* (`&`, `|`, `^`, `,`) or grouping parens. A `_` embedded in a longer token
|
|
8608
|
+
* (e.g. a modifier named `_private`) is not a misuse.
|
|
8609
|
+
*/
|
|
8610
|
+
function isMisusedFallbackKey(stateKey) {
|
|
8611
|
+
if (stateKey === "_" || !stateKey.includes("_")) return false;
|
|
8612
|
+
return /(?:^|[\s&|^,(])_(?:[\s&|^,)]|$)/.test(stateKey);
|
|
8613
|
+
}
|
|
8614
|
+
/**
|
|
8615
|
+
* Resolve the bare `''` default state (`condition.kind === 'true'`) in a
|
|
8616
|
+
* style value map.
|
|
8617
|
+
*
|
|
8618
|
+
* The bare default only behaves correctly as the **first** (lowest-priority)
|
|
8619
|
+
* key. When it appears later, `buildExclusiveConditions` processes it first
|
|
8620
|
+
* (after the reverse), never adds it to the prior list, and never negates it
|
|
8621
|
+
* — so it silently overrides every state authored before it.
|
|
8622
|
+
*
|
|
8623
|
+
* This function, given entries in authored order, moves a misplaced bare
|
|
8624
|
+
* default to the front (lowest priority), preserving the relative order of
|
|
8625
|
+
* all other entries, and emits a `MISPLACED_DEFAULT_STATE` warning.
|
|
8626
|
+
*
|
|
8627
|
+
* The `_` fallback floor is pulled out before this runs (see
|
|
8628
|
+
* `parseStyleEntries`), so only the bare `''` default is considered here.
|
|
8629
|
+
*/
|
|
8630
|
+
function normalizeDefaultStates(entries, styleKey) {
|
|
8631
|
+
const defaultPos = entries.findIndex((e) => e.condition.kind === "true");
|
|
8632
|
+
if (defaultPos <= 0) return entries;
|
|
8633
|
+
const defaultEntry = entries[defaultPos];
|
|
8634
|
+
emitWarning("MISPLACED_DEFAULT_STATE", `Style "${styleKey}" defines the default state "${defaultEntry.stateKey}" after other states. A bare default ("") must be the first key, otherwise it overrides the states above it. It has been moved to the first position. Define default states first.`);
|
|
8635
|
+
return [
|
|
8636
|
+
defaultEntry,
|
|
8637
|
+
...entries.slice(0, defaultPos),
|
|
8638
|
+
...entries.slice(defaultPos + 1)
|
|
8639
|
+
];
|
|
8202
8640
|
}
|
|
8203
8641
|
/**
|
|
8204
8642
|
* Merge parsed entries that share the same value.
|
|
@@ -8321,8 +8759,9 @@ function extractCompoundStates(valueMap) {
|
|
|
8321
8759
|
const keys = Object.keys(valueMap);
|
|
8322
8760
|
if (keys.length < 3 || !keys.some((k) => k.includes("&"))) return valueMap;
|
|
8323
8761
|
const entries = keys.map((key) => {
|
|
8762
|
+
const atoms = splitTopLevelAnd(key);
|
|
8324
8763
|
return {
|
|
8325
|
-
atoms:
|
|
8764
|
+
atoms: atoms === null || atoms.includes("_") ? [key] : atoms,
|
|
8326
8765
|
value: valueMap[key]
|
|
8327
8766
|
};
|
|
8328
8767
|
});
|
|
@@ -8513,7 +8952,35 @@ function hasAtRuleContext(node) {
|
|
|
8513
8952
|
return false;
|
|
8514
8953
|
}
|
|
8515
8954
|
/**
|
|
8516
|
-
*
|
|
8955
|
+
* Check if a condition involves an `@supports` query.
|
|
8956
|
+
*
|
|
8957
|
+
* `@supports` is feature detection: anything ANDed with it (e.g. a
|
|
8958
|
+
* `@container scroll-state(...)` query that only exists when
|
|
8959
|
+
* `container-type: scroll-state` is supported) becomes *unknown* — not
|
|
8960
|
+
* simply false — when the feature is absent. So a negated supports branch
|
|
8961
|
+
* must be emitted first (as the bare "feature unsupported" fallback) and
|
|
8962
|
+
* every other negated branch must nest inside the supported scope.
|
|
8963
|
+
*/
|
|
8964
|
+
function hasSupportsContext(node) {
|
|
8965
|
+
if (node.kind === "state") return node.type === "supports";
|
|
8966
|
+
if (node.kind === "compound") return node.children.some(hasSupportsContext);
|
|
8967
|
+
return false;
|
|
8968
|
+
}
|
|
8969
|
+
/**
|
|
8970
|
+
* Rank an OR branch for exclusive expansion ordering. Lower rank is
|
|
8971
|
+
* processed first (becomes the more "outer" / less-constrained branch):
|
|
8972
|
+
* 0 — branch involves `@supports` (feature-detection guard)
|
|
8973
|
+
* 1 — branch involves another at-rule (media / container / starting)
|
|
8974
|
+
* 2 — branch is pure selector context (modifiers / pseudos)
|
|
8975
|
+
*/
|
|
8976
|
+
function orBranchRank(node) {
|
|
8977
|
+
if (hasSupportsContext(node)) return 0;
|
|
8978
|
+
if (hasAtRuleContext(node)) return 1;
|
|
8979
|
+
return 2;
|
|
8980
|
+
}
|
|
8981
|
+
/**
|
|
8982
|
+
* Sort OR branches to prioritize at-rule conditions first, with
|
|
8983
|
+
* `@supports` branches ahead of all other at-rules.
|
|
8517
8984
|
*
|
|
8518
8985
|
* This is critical for correct CSS generation. For `!A | !B` where A is at-rule
|
|
8519
8986
|
* and B is modifier, we want:
|
|
@@ -8523,15 +8990,18 @@ function hasAtRuleContext(node) {
|
|
|
8523
8990
|
* If we process in wrong order (!B first), we'd get:
|
|
8524
8991
|
* - Branch 0: !B (modifier negation WITHOUT at-rule context - WRONG!)
|
|
8525
8992
|
* - Branch 1: B & !A (at-rule negation with modifier - incomplete coverage)
|
|
8993
|
+
*
|
|
8994
|
+
* The extra `@supports`-first tier matters when a feature query guards a
|
|
8995
|
+
* dependent query. For `!(S & C) = !S | !C` (S = `@supports(...)`, C =
|
|
8996
|
+
* `@container scroll-state(...)`), `simplify` sorts the branches
|
|
8997
|
+
* alphabetically into `[!C, !S]`. Expanding in that order would emit `!C`
|
|
8998
|
+
* as a bare `@container (not scroll-state(...))` — meaningless where the
|
|
8999
|
+
* feature is unsupported, so the default would never apply there. Putting
|
|
9000
|
+
* `!S` first yields `!S | (S & !C)`: a bare supports fallback plus the
|
|
9001
|
+
* dependent negation nested in the supported scope.
|
|
8526
9002
|
*/
|
|
8527
9003
|
function sortOrBranchesForExpansion(branches) {
|
|
8528
|
-
return [...branches].sort((a, b) =>
|
|
8529
|
-
const aHasAtRule = hasAtRuleContext(a);
|
|
8530
|
-
const bHasAtRule = hasAtRuleContext(b);
|
|
8531
|
-
if (aHasAtRule && !bHasAtRule) return -1;
|
|
8532
|
-
if (!aHasAtRule && bHasAtRule) return 1;
|
|
8533
|
-
return 0;
|
|
8534
|
-
});
|
|
9004
|
+
return [...branches].sort((a, b) => orBranchRank(a) - orBranchRank(b));
|
|
8535
9005
|
}
|
|
8536
9006
|
/**
|
|
8537
9007
|
* Expand ORs in a single entry's exclusive condition
|
|
@@ -8596,21 +9066,6 @@ function transformSelectorContent(content) {
|
|
|
8596
9066
|
return content.replace(ELEMENT_NAME_RE, (_, prefix, name) => `${prefix}[data-element="${name}"]`);
|
|
8597
9067
|
}
|
|
8598
9068
|
//#endregion
|
|
8599
|
-
//#region src/pipeline/warnings.ts
|
|
8600
|
-
const defaultWarningHandler = (warning) => {
|
|
8601
|
-
console.warn(`[Tasty] ${warning.message}`);
|
|
8602
|
-
};
|
|
8603
|
-
let warningHandler = defaultWarningHandler;
|
|
8604
|
-
/**
|
|
8605
|
-
* Emit a structured pipeline warning via the configured handler.
|
|
8606
|
-
*/
|
|
8607
|
-
function emitWarning(code, message) {
|
|
8608
|
-
warningHandler({
|
|
8609
|
-
code,
|
|
8610
|
-
message
|
|
8611
|
-
});
|
|
8612
|
-
}
|
|
8613
|
-
//#endregion
|
|
8614
9069
|
//#region src/pipeline/parseStateKey.ts
|
|
8615
9070
|
/**
|
|
8616
9071
|
* State Key Parser
|
|
@@ -8827,7 +9282,15 @@ var Parser = class {
|
|
|
8827
9282
|
return createPseudoCondition(value, false, value);
|
|
8828
9283
|
}
|
|
8829
9284
|
if (value.startsWith(".")) return createPseudoCondition(value, false, value);
|
|
8830
|
-
if (value.startsWith("["))
|
|
9285
|
+
if (value.startsWith("[")) {
|
|
9286
|
+
const attrMatch = /^\[\s*([a-zA-Z_][\w-]*)\s*(?:(=|\^=|\$=|\*=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]+)))?\s*\]$/.exec(value);
|
|
9287
|
+
if (attrMatch) {
|
|
9288
|
+
const [, attribute, operator, dq, sq, bare] = attrMatch;
|
|
9289
|
+
if (operator === void 0) return createModifierCondition(attribute, void 0, "=", false, value);
|
|
9290
|
+
return createModifierCondition(attribute, dq ?? sq ?? bare, operator, false, value);
|
|
9291
|
+
}
|
|
9292
|
+
return createPseudoCondition(value, false, value);
|
|
9293
|
+
}
|
|
8831
9294
|
if (value.includes("=")) return this.parseValueModifier(value);
|
|
8832
9295
|
return this.parseBooleanModifier(value);
|
|
8833
9296
|
}
|
|
@@ -9117,7 +9580,17 @@ function runPipeline(styles, parserContext) {
|
|
|
9117
9580
|
const starting = [];
|
|
9118
9581
|
for (const rule of dedupedRules) if (rule.startingStyle) starting.push(rule);
|
|
9119
9582
|
else normal.push(rule);
|
|
9120
|
-
return normal.concat(starting);
|
|
9583
|
+
return stableSortByOrder(normal).concat(stableSortByOrder(starting));
|
|
9584
|
+
}
|
|
9585
|
+
/**
|
|
9586
|
+
* Stable sort CSS rules by their `order` hint ascending. Rules without an
|
|
9587
|
+
* `order` are treated as 0. `Array.prototype.sort` is stable (ES2019+,
|
|
9588
|
+
* Node >= 20), so equal-order rules keep their emission order — the `_`
|
|
9589
|
+
* fallback floor (low order) stays before the overrides that layer over it.
|
|
9590
|
+
*/
|
|
9591
|
+
function stableSortByOrder(rules) {
|
|
9592
|
+
if (rules.length <= 1) return rules;
|
|
9593
|
+
return [...rules].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
9121
9594
|
}
|
|
9122
9595
|
/**
|
|
9123
9596
|
* Process styles at a given nesting level.
|
|
@@ -9225,7 +9698,8 @@ function invokeHandler(handler, stateSnapshots, selectorSuffix) {
|
|
|
9225
9698
|
for (const suffix of suffixes) computedRules.push({
|
|
9226
9699
|
condition: snapshot.condition,
|
|
9227
9700
|
declarations,
|
|
9228
|
-
selectorSuffix: suffix
|
|
9701
|
+
selectorSuffix: suffix,
|
|
9702
|
+
order: snapshot.order
|
|
9229
9703
|
});
|
|
9230
9704
|
}
|
|
9231
9705
|
}
|
|
@@ -9320,7 +9794,7 @@ const VALID_TOKEN_PATTERNS = [
|
|
|
9320
9794
|
/^\*/,
|
|
9321
9795
|
/^[A-Z][a-zA-Z0-9]*/,
|
|
9322
9796
|
/^@/,
|
|
9323
|
-
|
|
9797
|
+
/^::?-?[a-z][a-z0-9-]*(?:\([^)]*\))?/,
|
|
9324
9798
|
/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/,
|
|
9325
9799
|
/^\[[^\]]+\]/,
|
|
9326
9800
|
/^[a-z][a-z0-9-]*/,
|
|
@@ -9643,10 +10117,15 @@ function computeStateCombinations(exclusiveByStyle, lookupStyles) {
|
|
|
9643
10117
|
const simplified = simplifyCondition(and(...combo.map((e) => e.exclusiveCondition)));
|
|
9644
10118
|
if (simplified.kind === "false") continue;
|
|
9645
10119
|
const values = {};
|
|
9646
|
-
|
|
10120
|
+
let order = 0;
|
|
10121
|
+
for (const entry of combo) {
|
|
10122
|
+
values[entry.styleKey] = entry.value;
|
|
10123
|
+
if (entry.priority > order) order = entry.priority;
|
|
10124
|
+
}
|
|
9647
10125
|
snapshots.push({
|
|
9648
10126
|
condition: simplified,
|
|
9649
|
-
values
|
|
10127
|
+
values,
|
|
10128
|
+
order
|
|
9650
10129
|
});
|
|
9651
10130
|
}
|
|
9652
10131
|
return snapshots;
|
|
@@ -9694,10 +10173,13 @@ function mergeByValue(rules) {
|
|
|
9694
10173
|
for (const [, groupRules] of groups) if (groupRules.length === 1) merged.push(groupRules[0]);
|
|
9695
10174
|
else {
|
|
9696
10175
|
const mergedCondition = simplifyCondition(or(...groupRules.map((r) => r.condition)));
|
|
10176
|
+
let order = groupRules[0].order;
|
|
10177
|
+
for (const r of groupRules) if (r.order < order) order = r.order;
|
|
9697
10178
|
merged.push({
|
|
9698
10179
|
condition: mergedCondition,
|
|
9699
10180
|
declarations: groupRules[0].declarations,
|
|
9700
|
-
selectorSuffix: groupRules[0].selectorSuffix
|
|
10181
|
+
selectorSuffix: groupRules[0].selectorSuffix,
|
|
10182
|
+
order
|
|
9701
10183
|
});
|
|
9702
10184
|
}
|
|
9703
10185
|
return merged;
|
|
@@ -9707,12 +10189,15 @@ function mergeByValue(rules) {
|
|
|
9707
10189
|
*/
|
|
9708
10190
|
function buildSelectorFromVariant(variant, selectorSuffix) {
|
|
9709
10191
|
let selector = "";
|
|
9710
|
-
|
|
9711
|
-
for (const group of variant.selectorGroups)
|
|
10192
|
+
let rootSegment = branchToCSS([...variant.modifierConditions, ...variant.pseudoConditions]);
|
|
10193
|
+
for (const group of variant.selectorGroups) rootSegment += selectorGroupToCSS(group);
|
|
10194
|
+
selector += wrapWhere(rootSegment);
|
|
9712
10195
|
if (variant.parentGroups.length > 0) selector += parentGroupsToCSS(variant.parentGroups);
|
|
9713
10196
|
selector += selectorSuffix;
|
|
9714
10197
|
const ownOptimized = optimizeGroups(variant.ownGroups);
|
|
9715
|
-
|
|
10198
|
+
let ownSegment = "";
|
|
10199
|
+
for (const group of ownOptimized) ownSegment += selectorGroupToCSS(group);
|
|
10200
|
+
selector += wrapWhere(ownSegment);
|
|
9716
10201
|
return selector;
|
|
9717
10202
|
}
|
|
9718
10203
|
/**
|
|
@@ -9747,7 +10232,8 @@ function materializeComputedRule(rule) {
|
|
|
9747
10232
|
const selectorFragments = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix));
|
|
9748
10233
|
const cssRule = {
|
|
9749
10234
|
selector: selectorFragments.length === 1 ? selectorFragments[0] : selectorFragments,
|
|
9750
|
-
declarations
|
|
10235
|
+
declarations,
|
|
10236
|
+
order: rule.order
|
|
9751
10237
|
};
|
|
9752
10238
|
if (group.atRules.length > 0) cssRule.atRules = group.atRules;
|
|
9753
10239
|
if (group.rootPrefix) cssRule.rootPrefix = group.rootPrefix;
|
|
@@ -10459,6 +10945,6 @@ function resetConfig() {
|
|
|
10459
10945
|
delete storage[GLOBAL_INJECTOR_KEY];
|
|
10460
10946
|
}
|
|
10461
10947
|
//#endregion
|
|
10462
|
-
export { parseColor as $, StyleInjector as A,
|
|
10948
|
+
export { parseColor as $, StyleInjector as A, extractLocalProperties as At, styleHandlers as B, parseStateKey as C, getComponentPropertySyntax as Ct, extractPredefinedStateRefs as D, hslToRgbValues as Dt, extractLocalPredefinedStates as E, hexToRgb as Et, fontFaceContentHash as F, CUSTOM_UNITS as G, warn as H, formatFontFaceRule as I, filterMods as J, DIRECTIONS as K, hasLocalFontFace as L, formatCounterStyleRule as M, hasLocalProperties as Mt, hasLocalCounterStyle as N, parsePropertyToken as Nt, getGlobalPredefinedStates as O, strToRgb as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getColorSpaceSuffix as St, createStateParserContext as T, getRgbValuesFromRgbaString as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, isDevEnv as _t, getGlobalCounterStyle as a, okhstPlugin as at, hasPipelineCacheEntry as b, getColorSpaceComponents as bt, getGlobalKeyframes as c, StyleParser as ct, getNamePrefix as d, DEFAULT_ZERO_NAME_PREFIX as dt, parseStyle as et, hasGlobalKeyframes as f, makeClassName as ft, isTestEnvironment as g, validateNamePrefix as gt, isConfigLocked as h, tastyClassRegex as ht, getGlobalConfigTokens as i, okhstFunc as it, extractLocalCounterStyle as j, getEffectiveDefinition as jt, setGlobalPredefinedStates as k, Lru as kt, getGlobalRecipes as l, Bucket as lt, hasStylesGenerated as m, makeKeyframeName as mt, getConfig as n, setGlobalPredefinedTokens as nt, getGlobalFontFace as o, okhslFunc as ot, hasGlobalRecipes as p, makeCounterStyleName as pt, customFunc as q, getEffectiveProperties as r, stringifyStyles as rt, getGlobalInjector as s, okhslPlugin as st, configure as t, resetGlobalPredefinedTokens as tt, getGlobalStyles as u, DEFAULT_NAME_PREFIX as ut, resetConfig as v, hashString as vt, camelToKebab as w, getNamedColorHex as wt, isSelector as x, getColorSpaceFunc as xt, generateTypographyTokens as y, colorInitialValueToComponents as yt, STYLE_HANDLER_MAP as z };
|
|
10463
10949
|
|
|
10464
|
-
//# sourceMappingURL=config-
|
|
10950
|
+
//# sourceMappingURL=config-BfqoUnBb.js.map
|