@tenphi/tasty 3.9.10 → 3.10.0

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.
Files changed (56) hide show
  1. package/dist/babel-types-C_7kRP38.d.ts +18 -0
  2. package/dist/chunks/build-config-l2Ys-AJr.js +60 -0
  3. package/dist/chunks/build-config-l2Ys-AJr.js.map +1 -0
  4. package/dist/chunks/{collector-D2ARGT2L.js → collector-CaNtsRtn.js} +8 -6
  5. package/dist/chunks/collector-CaNtsRtn.js.map +1 -0
  6. package/dist/chunks/{config-engine-DEmmPPdp.js → config-engine-CpExZO_T.js} +3 -3
  7. package/dist/chunks/{config-engine-DEmmPPdp.js.map → config-engine-CpExZO_T.js.map} +1 -1
  8. package/dist/chunks/{css-definitions-DotDkIXt.js → css-definitions-DAIJxzFY.js} +45 -22
  9. package/dist/chunks/{css-definitions-DotDkIXt.js.map → css-definitions-DAIJxzFY.js.map} +1 -1
  10. package/dist/chunks/{debug-D8pg9RGI.js → debug-CKy49GEr.js} +4 -4
  11. package/dist/chunks/{debug-D8pg9RGI.js.map → debug-CKy49GEr.js.map} +1 -1
  12. package/dist/chunks/{react-runtime-BpxlOTbO.js → react-runtime-oi6i3ELR.js} +27 -7
  13. package/dist/chunks/react-runtime-oi6i3ELR.js.map +1 -0
  14. package/dist/chunks/{runtime-engine-CKFXUH-A.js → runtime-engine-DoULyhPt.js} +22 -23
  15. package/dist/chunks/runtime-engine-DoULyhPt.js.map +1 -0
  16. package/dist/chunks/{runtime-state-BxaLhVdP.js → runtime-state-CZ2J5QiZ.js} +17 -3
  17. package/dist/chunks/runtime-state-CZ2J5QiZ.js.map +1 -0
  18. package/dist/chunks/{style-engine-BBbBuSkT.js → style-engine-CeKsjtIr.js} +194 -48
  19. package/dist/chunks/style-engine-CeKsjtIr.js.map +1 -0
  20. package/dist/chunks/{zero-engine-gJrKBRiw.js → zero-engine-fxKu8Jbn.js} +48 -28
  21. package/dist/chunks/zero-engine-fxKu8Jbn.js.map +1 -0
  22. package/dist/{config-CZWCzBr6.d.ts → config-CrZOfNJ5.d.ts} +8 -8
  23. package/dist/core/index.d.ts +2 -2
  24. package/dist/core/index.js +6 -6
  25. package/dist/{index-G9JuwM9p.d.ts → index-CYJtAI9a.d.ts} +2 -2
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +7 -7
  28. package/dist/ssr/astro.js +2 -2
  29. package/dist/ssr/index.js +2 -2
  30. package/dist/ssr/next-config.d.ts +1 -1
  31. package/dist/ssr/next-config.js +10 -4
  32. package/dist/ssr/next-config.js.map +1 -1
  33. package/dist/ssr/next.js +3 -3
  34. package/dist/zero/babel.d.ts +67 -2
  35. package/dist/zero/babel.js +21 -29
  36. package/dist/zero/babel.js.map +1 -1
  37. package/dist/zero/index.d.ts +39 -2
  38. package/dist/zero/index.js +24 -2
  39. package/dist/zero/index.js.map +1 -0
  40. package/dist/zero/next.d.ts +2 -1
  41. package/docs/configuration.md +1 -1
  42. package/docs/dsl.md +2 -0
  43. package/docs/pipeline.md +2 -2
  44. package/docs/react-api.md +7 -0
  45. package/docs/runtime-benchmarks.md +7 -7
  46. package/docs/tasty-static.md +33 -0
  47. package/package.json +7 -7
  48. package/dist/babel-rZcEwPLM.d.ts +0 -82
  49. package/dist/chunks/build-config-CL4eRu2z.js +0 -42
  50. package/dist/chunks/build-config-CL4eRu2z.js.map +0 -1
  51. package/dist/chunks/collector-D2ARGT2L.js.map +0 -1
  52. package/dist/chunks/react-runtime-BpxlOTbO.js.map +0 -1
  53. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +0 -1
  54. package/dist/chunks/runtime-state-BxaLhVdP.js.map +0 -1
  55. package/dist/chunks/style-engine-BBbBuSkT.js.map +0 -1
  56. package/dist/chunks/zero-engine-gJrKBRiw.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { L as DEFAULT_PROPERTIES } from "./css-definitions-DotDkIXt.js";
1
+ import { z as DEFAULT_PROPERTIES } from "./css-definitions-DAIJxzFY.js";
2
2
  //#region src/config-resources.ts
3
3
  let runtimeConfig = null;
4
4
  let globalFontFace = null;
@@ -7,12 +7,14 @@ let globalFunction = null;
7
7
  let globalProperties = null;
8
8
  let globalConfigTokens = null;
9
9
  let globalStyles = null;
10
+ let globalKeyframes = null;
10
11
  const GTKEY_TOKENS = "__tasty_cfg_tokens__";
11
12
  const GTKEY_FONT_FACE = "__tasty_cfg_font_face__";
12
13
  const GTKEY_COUNTER_STYLE = "__tasty_cfg_counter_style__";
13
14
  const GTKEY_FUNCTION = "__tasty_cfg_function__";
14
15
  const GTKEY_PROPERTIES = "__tasty_cfg_properties__";
15
16
  const GTKEY_GLOBAL_STYLES = "__tasty_cfg_global_styles__";
17
+ const GTKEY_KEYFRAMES = "__tasty_cfg_keyframes__";
16
18
  function setOnGlobalThis(key, value) {
17
19
  globalThis[key] = value;
18
20
  }
@@ -47,6 +49,9 @@ function getGlobalConfigTokens() {
47
49
  function getGlobalStyles() {
48
50
  return globalStyles ?? getFromGlobalThis(GTKEY_GLOBAL_STYLES) ?? null;
49
51
  }
52
+ function getGlobalKeyframes() {
53
+ return globalKeyframes ?? getFromGlobalThis(GTKEY_KEYFRAMES) ?? null;
54
+ }
50
55
  function mergeGlobalProperties(properties) {
51
56
  globalProperties = {
52
57
  ...globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {},
@@ -90,6 +95,13 @@ function mergeGlobalStyles(styles) {
90
95
  else globalStyles = { ...styles };
91
96
  setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);
92
97
  }
98
+ function mergeGlobalKeyframes(keyframes) {
99
+ globalKeyframes = {
100
+ ...getGlobalKeyframes() ?? {},
101
+ ...keyframes
102
+ };
103
+ setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);
104
+ }
93
105
  function resetConfigResources() {
94
106
  runtimeConfig = null;
95
107
  globalProperties = null;
@@ -98,6 +110,7 @@ function resetConfigResources() {
98
110
  globalFunction = null;
99
111
  globalConfigTokens = null;
100
112
  globalStyles = null;
113
+ globalKeyframes = null;
101
114
  const globalState = globalThis;
102
115
  delete globalState[GTKEY_TOKENS];
103
116
  delete globalState[GTKEY_FONT_FACE];
@@ -105,6 +118,7 @@ function resetConfigResources() {
105
118
  delete globalState[GTKEY_FUNCTION];
106
119
  delete globalState[GTKEY_PROPERTIES];
107
120
  delete globalState[GTKEY_GLOBAL_STYLES];
121
+ delete globalState[GTKEY_KEYFRAMES];
108
122
  }
109
123
  //#endregion
110
124
  //#region src/ssr/ssr-collector-ref.ts
@@ -122,6 +136,6 @@ function getRegisteredSSRCollector() {
122
136
  return getter ? getter() : null;
123
137
  }
124
138
  //#endregion
125
- export { resetConfigResources as _, getGlobalConfigTokens as a, getGlobalFunctions as c, mergeGlobalConfigTokens as d, mergeGlobalCounterStyles as f, mergeGlobalStyles as g, mergeGlobalProperties as h, getEffectiveProperties as i, getGlobalStyles as l, mergeGlobalFunctions as m, registerSSRCollectorGetter as n, getGlobalCounterStyles as o, mergeGlobalFontFaces as p, registerSSRCollectorGetterGlobal as r, getGlobalFontFaces as s, getRegisteredSSRCollector as t, getRuntimeConfigState as u, setRuntimeConfigState as v };
139
+ export { mergeGlobalProperties as _, getGlobalConfigTokens as a, setRuntimeConfigState as b, getGlobalFunctions as c, getRuntimeConfigState as d, mergeGlobalConfigTokens as f, mergeGlobalKeyframes as g, mergeGlobalFunctions as h, getEffectiveProperties as i, getGlobalKeyframes as l, mergeGlobalFontFaces as m, registerSSRCollectorGetter as n, getGlobalCounterStyles as o, mergeGlobalCounterStyles as p, registerSSRCollectorGetterGlobal as r, getGlobalFontFaces as s, getRegisteredSSRCollector as t, getGlobalStyles as u, mergeGlobalStyles as v, resetConfigResources as y };
126
140
 
127
- //# sourceMappingURL=runtime-state-BxaLhVdP.js.map
141
+ //# sourceMappingURL=runtime-state-CZ2J5QiZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-state-CZ2J5QiZ.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\nlet globalKeyframes: Record<string, KeyframesSteps> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\nconst GTKEY_KEYFRAMES = '__tasty_cfg_keyframes__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\n/**\n * Get global keyframes configuration.\n * Returns null if no keyframes configured (fast path for zero-overhead).\n */\nexport function getGlobalKeyframes(): Record<string, KeyframesSteps> | null {\n return (\n globalKeyframes ??\n getFromGlobalThis<Record<string, KeyframesSteps>>(GTKEY_KEYFRAMES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function mergeGlobalKeyframes(\n keyframes: Record<string, KeyframesSteps>,\n): void {\n globalKeyframes = { ...(getGlobalKeyframes() ?? {}), ...keyframes };\n setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n globalKeyframes = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n delete globalState[GTKEY_KEYFRAMES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":"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"}
@@ -87,6 +87,10 @@ function setGlobalPredefinedStates(states) {
87
87
  function getGlobalPredefinedStates() {
88
88
  return globalPredefinedStates;
89
89
  }
90
+ function clearGlobalPredefinedStates() {
91
+ globalPredefinedStates = {};
92
+ emittedWarnings.clear();
93
+ }
90
94
  const PREDEFINED_STATE_PATTERN = /@[A-Za-z][A-Za-z0-9-]*(?![A-Za-z0-9-:(])/g;
91
95
  function extractPredefinedStateRefs(value) {
92
96
  const matches = value.match(PREDEFINED_STATE_PATTERN);
@@ -299,6 +303,113 @@ function resetStyleChunks() {
299
303
  for (const [style, chunk] of builtinSnapshot) STYLE_TO_CHUNK.set(style, chunk);
300
304
  }
301
305
  //#endregion
306
+ //#region src/styles/createStyle.ts
307
+ const CACHE = {};
308
+ function createStyle(styleName, cssStyle, converter) {
309
+ const key = `${styleName}.${cssStyle ?? ""}`;
310
+ if (!CACHE[key]) {
311
+ const styleHandler = (styleMap) => {
312
+ let styleValue = styleMap[styleName];
313
+ if (styleValue == null || styleValue === false) return null;
314
+ let finalCssStyle;
315
+ const isColorToken = !cssStyle && typeof styleName === "string" && styleName.startsWith("#");
316
+ if (isColorToken) finalCssStyle = `--${normalizeDslName(styleName.slice(1))}-color`;
317
+ else if (!cssStyle && styleName[0] === "$") finalCssStyle = `--${normalizeDslName(styleName.slice(1))}`;
318
+ else finalCssStyle = cssStyle || toSnakeCase(styleName);
319
+ if (isColorToken) {
320
+ const normalized = normalizeColorTokenValue(styleValue);
321
+ if (normalized === null) return null;
322
+ styleValue = normalized;
323
+ }
324
+ if (converter) {
325
+ const converted = converter(styleValue);
326
+ if (converted) styleValue = converted;
327
+ else if (typeof styleValue !== "string") return null;
328
+ }
329
+ if (typeof styleValue === "string" && finalCssStyle.startsWith("--") && finalCssStyle.endsWith("-color")) {
330
+ styleValue = styleValue.trim();
331
+ return { [finalCssStyle]: parseColor(styleValue).color ?? "" };
332
+ }
333
+ const processed = parseStyle(styleValue);
334
+ return { [finalCssStyle]: processed.output };
335
+ };
336
+ styleHandler.__lookupStyles = [styleName];
337
+ CACHE[key] = styleHandler;
338
+ }
339
+ return CACHE[key];
340
+ }
341
+ //#endregion
342
+ //#region src/styles/animation.ts
343
+ const NON_NAME_KEYWORDS = new Set("none initial inherit unset revert revert-layer auto normal running paused reverse alternate alternate-reverse forwards backwards both infinite ease linear ease-in ease-out ease-in-out step-start step-end".split(" "));
344
+ const RE_NAME = /^(?:--|-?[a-zA-Z_\u0080-￿])[\w\-\u0080-￿]*$/;
345
+ function nameAt(value, start, end) {
346
+ const token = value.slice(start, end);
347
+ return RE_NAME.test(token) && !NON_NAME_KEYWORDS.has(token.toLowerCase()) ? {
348
+ name: token,
349
+ index: start
350
+ } : null;
351
+ }
352
+ function scanAnimationNames(value) {
353
+ const items = [];
354
+ let found = null;
355
+ let start = -1;
356
+ let depth = 0;
357
+ let quote = "";
358
+ for (let i = 0; i < value.length; i++) {
359
+ const ch = value[i];
360
+ if (quote) {
361
+ if (ch === "\\") i++;
362
+ else if (ch === quote) quote = "";
363
+ continue;
364
+ }
365
+ if (depth === 0 && (ch === "," || /\s/.test(ch))) {
366
+ if (start !== -1) found ??= nameAt(value, start, i);
367
+ start = -1;
368
+ if (ch === ",") {
369
+ items.push(found);
370
+ found = null;
371
+ }
372
+ continue;
373
+ }
374
+ if (start === -1) start = i;
375
+ if (ch === "\"" || ch === "'") quote = ch;
376
+ else if (ch === "\\") i++;
377
+ else if (ch === "(") depth++;
378
+ else if (ch === ")" && depth > 0) depth--;
379
+ }
380
+ if (start !== -1) found ??= nameAt(value, start, value.length);
381
+ items.push(found);
382
+ return items;
383
+ }
384
+ function restoreAnimationNameCase(authored, output) {
385
+ if (authored === output || authored === authored.toLowerCase()) return output;
386
+ const authoredNames = scanAnimationNames(authored);
387
+ const outputNames = scanAnimationNames(output);
388
+ if (authoredNames.length !== outputNames.length) return output;
389
+ let result = output;
390
+ for (let i = outputNames.length - 1; i >= 0; i--) {
391
+ const from = outputNames[i];
392
+ const to = authoredNames[i];
393
+ if (!from || !to || from.name === to.name) continue;
394
+ if (from.name !== to.name.toLowerCase()) continue;
395
+ result = result.slice(0, from.index) + to.name + result.slice(from.index + from.name.length);
396
+ }
397
+ return result;
398
+ }
399
+ function animationNameHandler(styleName, property) {
400
+ const base = createStyle(styleName);
401
+ const handler = (styleMap) => {
402
+ const result = base(styleMap);
403
+ const value = styleMap[styleName];
404
+ if (!result || typeof value !== "string") return result;
405
+ return { [property]: restoreAnimationNameCase(value, String(result[property])) };
406
+ };
407
+ handler.__lookupStyles = [styleName];
408
+ return handler;
409
+ }
410
+ const animationStyle = animationNameHandler("animation", "animation");
411
+ const animationNameStyle = animationNameHandler("animationName", "animation-name");
412
+ //#endregion
302
413
  //#region src/styles/const.ts
303
414
  const BORDER_STYLES = [
304
415
  "none",
@@ -565,42 +676,6 @@ function colorStyle({ color }) {
565
676
  }
566
677
  colorStyle.__lookupStyles = ["color"];
567
678
  //#endregion
568
- //#region src/styles/createStyle.ts
569
- const CACHE = {};
570
- function createStyle(styleName, cssStyle, converter) {
571
- const key = `${styleName}.${cssStyle ?? ""}`;
572
- if (!CACHE[key]) {
573
- const styleHandler = (styleMap) => {
574
- let styleValue = styleMap[styleName];
575
- if (styleValue == null || styleValue === false) return null;
576
- let finalCssStyle;
577
- const isColorToken = !cssStyle && typeof styleName === "string" && styleName.startsWith("#");
578
- if (isColorToken) finalCssStyle = `--${normalizeDslName(styleName.slice(1))}-color`;
579
- else if (!cssStyle && styleName[0] === "$") finalCssStyle = `--${normalizeDslName(styleName.slice(1))}`;
580
- else finalCssStyle = cssStyle || toSnakeCase(styleName);
581
- if (isColorToken) {
582
- const normalized = normalizeColorTokenValue(styleValue);
583
- if (normalized === null) return null;
584
- styleValue = normalized;
585
- }
586
- if (converter) {
587
- const converted = converter(styleValue);
588
- if (converted) styleValue = converted;
589
- else if (typeof styleValue !== "string") return null;
590
- }
591
- if (typeof styleValue === "string" && finalCssStyle.startsWith("--") && finalCssStyle.endsWith("-color")) {
592
- styleValue = styleValue.trim();
593
- return { [finalCssStyle]: parseColor(styleValue).color ?? "" };
594
- }
595
- const processed = parseStyle(styleValue);
596
- return { [finalCssStyle]: processed.output };
597
- };
598
- styleHandler.__lookupStyles = [styleName];
599
- CACHE[key] = styleHandler;
600
- }
601
- return CACHE[key];
602
- }
603
- //#endregion
604
679
  //#region src/styles/display.ts
605
680
  function applyTextOverflow(result, textOverflow, whiteSpace) {
606
681
  if (textOverflow === true || textOverflow === "initial") {
@@ -1723,6 +1798,8 @@ function predefine() {
1723
1798
  [
1724
1799
  displayStyle,
1725
1800
  transitionStyle,
1801
+ animationStyle,
1802
+ animationNameStyle,
1726
1803
  fillStyle,
1727
1804
  svgFillStyle,
1728
1805
  widthStyle,
@@ -1879,6 +1956,58 @@ const ELEMENT_NAME_RE = /(^|[\s>+~,(])([A-Z][a-zA-Z0-9]*)/g;
1879
1956
  function transformSelectorContent(content) {
1880
1957
  return content.replace(ELEMENT_NAME_RE, (_, prefix, name) => `${prefix}[data-element="${name}"]`);
1881
1958
  }
1959
+ const HTML_TYPE_RE = /^html(?![\w\-|\\\u0080-\uffff])/i;
1960
+ const LEGACY_PSEUDO_ELEMENT_RE = /^:(?:before|after|first-line|first-letter)$/i;
1961
+ function rootStateIndex(selector) {
1962
+ let isRoot = HTML_TYPE_RE.test(selector);
1963
+ let pseudoElementAt = -1;
1964
+ let squareDepth = 0;
1965
+ let parenDepth = 0;
1966
+ let quote = "";
1967
+ let rootFunctionParen = -1;
1968
+ let rootFunctionArgs = -1;
1969
+ for (let i = 0; i < selector.length; i++) {
1970
+ const char = selector[i];
1971
+ if (char === "\\") {
1972
+ i++;
1973
+ continue;
1974
+ }
1975
+ if (quote) {
1976
+ if (char === quote) quote = "";
1977
+ continue;
1978
+ }
1979
+ if (char === "\"" || char === "'") {
1980
+ quote = char;
1981
+ continue;
1982
+ }
1983
+ if (char === "[") squareDepth++;
1984
+ else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
1985
+ else if (char === "(") {
1986
+ if (i === rootFunctionParen && parenDepth === 0) rootFunctionArgs = i + 1;
1987
+ parenDepth++;
1988
+ } else if (char === ")") {
1989
+ parenDepth = Math.max(0, parenDepth - 1);
1990
+ if (parenDepth === 0 && rootFunctionArgs !== -1) {
1991
+ const args = splitSelectorsSafely(selector.slice(rootFunctionArgs, i));
1992
+ if (args.length > 0 && args.every((arg) => rootStateIndex(arg) === arg.length)) isRoot = true;
1993
+ rootFunctionArgs = -1;
1994
+ }
1995
+ }
1996
+ if (squareDepth > 0 || parenDepth > 0) continue;
1997
+ if (/[\s>+~,]/.test(char) || char === "/" && selector[i + 1] === "*") return -1;
1998
+ if (char !== ":" || pseudoElementAt !== -1) continue;
1999
+ if (selector[i + 1] === ":") {
2000
+ pseudoElementAt = i;
2001
+ continue;
2002
+ }
2003
+ const name = (/^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "").toLowerCase();
2004
+ if (name === ":root") isRoot = true;
2005
+ else if (LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
2006
+ else if ((name === ":is" || name === ":where") && selector[i + name.length] === "(") rootFunctionParen = i + name.length;
2007
+ }
2008
+ if (!isRoot) return -1;
2009
+ return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2010
+ }
1882
2011
  function splitSelectorsSafely(selectorList) {
1883
2012
  if (!selectorList.includes(",")) {
1884
2013
  const selector = selectorList.trim();
@@ -3207,13 +3336,16 @@ function optimizeGroups(groups) {
3207
3336
  }, facts);
3208
3337
  });
3209
3338
  }
3210
- function rootGroupsToCSS(groups) {
3339
+ function rootGroupsToStateCSS(groups) {
3211
3340
  if (groups.length === 0) return void 0;
3212
3341
  const optimized = optimizeGroups(groups);
3213
3342
  if (optimized.length === 0) return void 0;
3214
- let prefix = ":root";
3215
- for (const group of optimized) prefix += selectorGroupToCSS(group);
3216
- return wrapWhere(prefix);
3343
+ let state = "";
3344
+ for (const group of optimized) state += selectorGroupToCSS(group);
3345
+ return state;
3346
+ }
3347
+ function rootStateToPrefix(state) {
3348
+ return wrapWhere(`:root${state}`);
3217
3349
  }
3218
3350
  function parentGroupsToCSS(groups) {
3219
3351
  let result = "";
@@ -4422,6 +4554,9 @@ function parseStateKey(stateKey, options = {}) {
4422
4554
  parseCache.set(cacheKey, result);
4423
4555
  return result;
4424
4556
  }
4557
+ function clearParseCache() {
4558
+ parseCache.clear();
4559
+ }
4425
4560
  //#endregion
4426
4561
  //#region src/pipeline/index.ts
4427
4562
  const RE_UPPER_CASE = /[A-Z]/;
@@ -4870,7 +5005,8 @@ function materializeComputedRule(rule) {
4870
5005
  for (const variant of components.variants) {
4871
5006
  const atRules = buildAtRulesFromVariant(variant);
4872
5007
  const startingStyle = variant.startingStyle;
4873
- const rootPrefix = rootGroupsToCSS(variant.rootGroups);
5008
+ const rootState = rootGroupsToStateCSS(variant.rootGroups);
5009
+ const rootPrefix = rootState === void 0 ? void 0 : rootStateToPrefix(rootState);
4874
5010
  const key = atRules.sort().join("|||") + "###" + (rootPrefix || "") + "###" + (startingStyle ? "1" : "0");
4875
5011
  const group = byAtRules.get(key);
4876
5012
  if (group) group.variants.push(variant);
@@ -4878,6 +5014,7 @@ function materializeComputedRule(rule) {
4878
5014
  variants: [variant],
4879
5015
  atRules,
4880
5016
  rootPrefix,
5017
+ rootState,
4881
5018
  startingStyle: startingStyle || void 0
4882
5019
  });
4883
5020
  }
@@ -4890,7 +5027,10 @@ function materializeComputedRule(rule) {
4890
5027
  order: rule.order
4891
5028
  };
4892
5029
  if (group.atRules.length > 0) cssRule.atRules = group.atRules;
4893
- if (group.rootPrefix) cssRule.rootPrefix = group.rootPrefix;
5030
+ if (group.rootPrefix) {
5031
+ cssRule.rootPrefix = group.rootPrefix;
5032
+ cssRule.rootState = group.rootState;
5033
+ }
4894
5034
  if (group.startingStyle) cssRule.startingStyle = true;
4895
5035
  rules.push(cssRule);
4896
5036
  }
@@ -4920,17 +5060,23 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
4920
5060
  }
4921
5061
  if (directSelector) {
4922
5062
  const shouldDouble = options?.doubleSelector ?? false;
5063
+ const items = splitSelectorsSafely(classNameOrSelector);
5064
+ const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => ({
5065
+ base,
5066
+ rootAt: rootStateIndex(base)
5067
+ }));
4923
5068
  return mergeStyleResults(rules.map((rule) => {
4924
5069
  const result = {
4925
- selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).map((part) => {
4926
- let sel = part ? `${classNameOrSelector}${part}` : classNameOrSelector;
5070
+ selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part) => bases.map(({ base, rootAt }) => {
5071
+ const joinsRoot = rule.rootState !== void 0 && rootAt !== -1;
5072
+ let sel = joinsRoot ? `${base.slice(0, rootAt)}${wrapWhere(rule.rootState)}${base.slice(rootAt)}${part}` : `${base}${part}`;
4927
5073
  if (shouldDouble && sel.startsWith(".")) {
4928
5074
  const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
4929
5075
  if (classMatch) sel = classMatch[0] + sel;
4930
5076
  }
4931
- if (rule.rootPrefix) sel = `${rule.rootPrefix} ${sel}`;
5077
+ if (rule.rootPrefix && !joinsRoot) sel = `${rule.rootPrefix} ${sel}`;
4932
5078
  return sel;
4933
- }).join(", "),
5079
+ })).join(", "),
4934
5080
  declarations: rule.declarations
4935
5081
  };
4936
5082
  if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
@@ -5255,6 +5401,6 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
5255
5401
  return renderStyles(chunkName === CHUNK_NAMES.SUBCOMPONENTS ? buildSubcomponentFilteredStyles(styles, styleKeys) : buildFilteredStyles(styles, styleKeys), void 0, void 0, pipelineCacheKey);
5256
5402
  }
5257
5403
  //#endregion
5258
- export { createStyle as A, createStateParserContext as B, splitSelectorsSafely as C, registerHandler as D, normalizeHandlerDefinition as E, FONT_CHUNK_STYLES as F, markStylesGeneratedState as G, setGlobalPredefinedStates as H, LAYOUT_CHUNK_STYLES as I, setGlobalPolyfillsState as J, resetGlobalPolyfillsState as K, POSITION_CHUNK_STYLES as L, CHUNK_NAMES as M, DIMENSION_CHUNK_STYLES as N, resetHandlers as O, DISPLAY_CHUNK_STYLES as P, STYLE_TO_CHUNK as R, camelToKebab as S, defineHandler as T, hasStylesGenerated as U, getGlobalPredefinedStates as V, isFunctionsPolyfillEnabled as W, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, APPEARANCE_CHUNK_STYLES as j, styleHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, resetStylesGeneratedState as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, STYLE_HANDLER_MAP as w, parseStateKey as x, clearPipelineCache as y, resetStyleChunks as z };
5404
+ export { styleHandlers as A, STYLE_TO_CHUNK as B, camelToKebab as C, normalizeHandlerDefinition as D, defineHandler as E, DIMENSION_CHUNK_STYLES as F, setGlobalPredefinedStates as G, clearGlobalPredefinedStates as H, DISPLAY_CHUNK_STYLES as I, markStylesGeneratedState as J, hasStylesGenerated as K, FONT_CHUNK_STYLES as L, createStyle as M, APPEARANCE_CHUNK_STYLES as N, registerHandler as O, CHUNK_NAMES as P, LAYOUT_CHUNK_STYLES as R, parseStateKey as S, STYLE_HANDLER_MAP as T, createStateParserContext as U, resetStyleChunks as V, getGlobalPredefinedStates as W, resetStylesGeneratedState as X, resetGlobalPolyfillsState as Y, setGlobalPolyfillsState as Z, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, scanAnimationNames as j, resetHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, isFunctionsPolyfillEnabled as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, splitSelectorsSafely as w, clearParseCache as x, clearPipelineCache as y, POSITION_CHUNK_STYLES as z };
5259
5405
 
5260
- //# sourceMappingURL=style-engine-BBbBuSkT.js.map
5406
+ //# sourceMappingURL=style-engine-CeKsjtIr.js.map