@tenphi/tasty 0.0.0-snapshot.cb3b623 → 0.0.0-snapshot.cca2ea6

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 (92) hide show
  1. package/README.md +176 -131
  2. package/dist/{async-storage-B7_o6FKt.js → async-storage-DKK-wTD4.js} +1 -1
  3. package/dist/{async-storage-B7_o6FKt.js.map → async-storage-DKK-wTD4.js.map} +1 -1
  4. package/dist/babel-CHy3n_M7.d.ts +83 -0
  5. package/dist/{collector-osfWTeRd.d.ts → collector-0YO-P1vW.d.ts} +44 -7
  6. package/dist/{collector-BZe0AMUR.js → collector-Eve9-4dP.js} +76 -15
  7. package/dist/collector-Eve9-4dP.js.map +1 -0
  8. package/dist/{config-LDodmgVz.js → config-Bwerr9rW.js} +3914 -2020
  9. package/dist/config-Bwerr9rW.js.map +1 -0
  10. package/dist/{config-BoZDUHW5.d.ts → config-DRp9aYRG.d.ts} +436 -63
  11. package/dist/{context-CkSg-kDT.js → context-CA8YKeMn.js} +1 -1
  12. package/dist/{context-CkSg-kDT.js.map → context-CA8YKeMn.js.map} +1 -1
  13. package/dist/core/index.d.ts +5 -5
  14. package/dist/core/index.js +6 -6
  15. package/dist/{core-CQfmSOQW.js → core-C9nPCkW6.js} +202 -219
  16. package/dist/core-C9nPCkW6.js.map +1 -0
  17. package/dist/{css-writer-BjqQ_6-j.js → css-writer-7SOcy4BM.js} +54 -15
  18. package/dist/css-writer-7SOcy4BM.js.map +1 -0
  19. package/dist/{format-global-rules-Dbc_1tc3.js → format-global-rules-DklyaXv-.js} +1 -1
  20. package/dist/{format-global-rules-Dbc_1tc3.js.map → format-global-rules-DklyaXv-.js.map} +1 -1
  21. package/dist/{format-rules-CkZinBt0.js → format-rules-Cb8LAho6.js} +4 -17
  22. package/dist/format-rules-Cb8LAho6.js.map +1 -0
  23. package/dist/{hydrate-M5WHyrmy.js → hydrate-DfL38fk5.js} +4 -12
  24. package/dist/{hydrate-M5WHyrmy.js.map → hydrate-DfL38fk5.js.map} +1 -1
  25. package/dist/{index-J7y6BV89.d.ts → index-B1A0pcCf.d.ts} +496 -201
  26. package/dist/{index-tcHuMPFt.d.ts → index-BmogEzTo.d.ts} +358 -69
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +250 -60
  29. package/dist/index.js.map +1 -1
  30. package/dist/{keyframes-Bp3MU20J.js → keyframes-CygCEfJG.js} +97 -192
  31. package/dist/keyframes-CygCEfJG.js.map +1 -0
  32. package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-BcLl1u_d.d.ts} +2 -2
  33. package/dist/{merge-styles-DQW8Anlk.js → merge-styles-Bh_wsNk_.js} +2 -2
  34. package/dist/{merge-styles-DQW8Anlk.js.map → merge-styles-Bh_wsNk_.js.map} +1 -1
  35. package/dist/{resolve-recipes-BIxxAwSm.js → resolve-recipes-Da6piP7f.js} +3 -3
  36. package/dist/{resolve-recipes-BIxxAwSm.js.map → resolve-recipes-Da6piP7f.js.map} +1 -1
  37. package/dist/ssr/astro-client.js +1 -1
  38. package/dist/ssr/astro-client.js.map +1 -1
  39. package/dist/ssr/astro-middleware-static.d.ts +16 -0
  40. package/dist/ssr/astro-middleware-static.js +18 -0
  41. package/dist/ssr/astro-middleware-static.js.map +1 -0
  42. package/dist/ssr/astro-middleware.d.ts +8 -6
  43. package/dist/ssr/astro-middleware.js +10 -10
  44. package/dist/ssr/astro-middleware.js.map +1 -1
  45. package/dist/ssr/astro.d.ts +1 -5
  46. package/dist/ssr/astro.js +29 -21
  47. package/dist/ssr/astro.js.map +1 -1
  48. package/dist/ssr/index.d.ts +2 -9
  49. package/dist/ssr/index.js +5 -5
  50. package/dist/ssr/index.js.map +1 -1
  51. package/dist/ssr/next.d.ts +2 -3
  52. package/dist/ssr/next.js +6 -7
  53. package/dist/ssr/next.js.map +1 -1
  54. package/dist/static/index.d.ts +2 -2
  55. package/dist/static/index.js +4 -4
  56. package/dist/static/index.js.map +1 -1
  57. package/dist/static/inject.js.map +1 -1
  58. package/dist/zero/babel.d.ts +2 -81
  59. package/dist/zero/babel.js +27 -23
  60. package/dist/zero/babel.js.map +1 -1
  61. package/dist/zero/index.d.ts +16 -2
  62. package/dist/zero/index.js +2 -2
  63. package/dist/zero/next.d.ts +1 -1
  64. package/dist/zero/next.js +1 -1
  65. package/dist/zero/next.js.map +1 -1
  66. package/docs/README.md +17 -9
  67. package/docs/adoption.md +56 -31
  68. package/docs/ai-agents.md +224 -0
  69. package/docs/comparison.md +69 -40
  70. package/docs/configuration.md +470 -85
  71. package/docs/debug.md +11 -9
  72. package/docs/design-system.md +43 -24
  73. package/docs/dsl.md +508 -177
  74. package/docs/getting-started.md +60 -39
  75. package/docs/injector.md +120 -30
  76. package/docs/methodology.md +44 -38
  77. package/docs/migration-v3.md +285 -0
  78. package/docs/pipeline.md +53 -11
  79. package/docs/plugins.md +353 -0
  80. package/docs/react-api.md +142 -42
  81. package/docs/runtime-benchmarks.md +178 -0
  82. package/docs/ssr.md +90 -83
  83. package/docs/styles.md +56 -9
  84. package/docs/tasty-static.md +140 -105
  85. package/package.json +46 -20
  86. package/tasty.config.ts +5 -0
  87. package/dist/collector-BZe0AMUR.js.map +0 -1
  88. package/dist/config-LDodmgVz.js.map +0 -1
  89. package/dist/core-CQfmSOQW.js.map +0 -1
  90. package/dist/css-writer-BjqQ_6-j.js.map +0 -1
  91. package/dist/format-rules-CkZinBt0.js.map +0 -1
  92. package/dist/keyframes-Bp3MU20J.js.map +0 -1
@@ -1,104 +1,35 @@
1
- import { A as StyleInjector, Ct as getColorSpaceFunc, F as fontFaceContentHash, I as formatFontFaceRule, L as hasLocalFontFace, M as formatCounterStyleRule, N as hasLocalCounterStyle, P as extractLocalFontFace, Q as normalizeColorTokenValue, St as getColorSpaceComponents, U as createStyle, W as PropertyTypeResolver, _ as markStylesGenerated, _t as extractLocalProperties, bt as parsePropertyToken, c as getGlobalKeyframes, d as getNamePrefix, et as parseStyle, f as hasGlobalKeyframes, g as isTestEnvironment, gt as hashString, ht as isDevEnv, j as extractLocalCounterStyle, jt as Lru, n as getConfig, pt as tastyClassRegex, s as getGlobalInjector, ut as makeClassName, w as camelToKebab, wt as getColorSpaceSuffix, yt as hasLocalProperties, z as STYLE_HANDLER_MAP } from "./config-LDodmgVz.js";
2
- import { a as mergeKeyframes, c as generateChunkCacheKey, d as categorizeStyleKeys, i as hasLocalKeyframes, l as CHUNK_NAMES, n as extractLocalKeyframes, o as replaceAnimationNames, r as filterUsedKeyframes, s as renderStylesForChunk, t as extractAnimationNamesFromStyles } from "./keyframes-Bp3MU20J.js";
3
- import { n as formatPropertyCSS, r as getRegisteredSSRCollector, t as formatRules } from "./format-rules-CkZinBt0.js";
4
- import { t as resolveRecipes } from "./resolve-recipes-BIxxAwSm.js";
1
+ import { Bt as getGlobalParseFunctions, G as StyleInjector, Gt as parseStyle, It as registerLocalFunctionPolyfills, J as hasLocalCounterStyle, K as extractLocalCounterStyle, Mt as formatFunctionRule, Nt as hasLocalFunctions, Pt as parseFunctionName, Q as hasLocalFontFace, Qt as isDevEnv, Ut as normalizeColorTokenValue, Vt as getGlobalParser, X as fontFaceContentHash, Y as extractLocalFontFace, Z as formatFontFaceRule, _ as isFunctionsPolyfillEnabled, _t as hashString, bt as hasLocalProperties, c as getGlobalInjector, en as Lru, et as STYLE_HANDLER_MAP, f as getNamePrefix, ft as makeClassName, ht as tastyClassRegex, it as PropertyTypeResolver, jt as extractLocalFunctions, l as getGlobalKeyframes, n as getConfig, p as hasGlobalKeyframes, q as formatCounterStyleRule, rt as createStyle, sn as normalizeDslName, tn as overrideColorAlpha, v as isTestEnvironment, vt as extractLocalProperties, wt as CHUNK_NAMES, xt as parsePropertyToken, y as markStylesGenerated, z as camelToKebab } from "./config-Bwerr9rW.js";
2
+ import { a as mergeKeyframes, c as generateChunkCacheKey, i as hasLocalKeyframes, l as categorizeStyleKeys, n as extractLocalKeyframes, o as replaceAnimationNames, r as filterUsedKeyframes, s as renderStylesForChunk, t as extractAnimationNamesFromStyles } from "./keyframes-CygCEfJG.js";
3
+ import { n as formatPropertyCSS, r as getRegisteredSSRCollector, t as formatRules } from "./format-rules-Cb8LAho6.js";
4
+ import { t as resolveRecipes } from "./resolve-recipes-Da6piP7f.js";
5
5
  import { cache } from "react";
6
- //#region src/styles/list.ts
7
- const BASE_STYLES = [
8
- "display",
9
- "font",
10
- "preset",
11
- "hide",
12
- "whiteSpace",
13
- "opacity",
14
- "transition"
15
- ];
16
- const POSITION_STYLES = [
17
- "gridArea",
18
- "order",
19
- "gridColumn",
20
- "gridRow",
21
- "placeSelf",
22
- "alignSelf",
23
- "justifySelf",
24
- "zIndex",
25
- "margin",
26
- "inset",
27
- "position",
28
- "scrollMargin"
29
- ];
30
- const BLOCK_INNER_STYLES = [
31
- "padding",
32
- "paddingInline",
33
- "paddingBlock",
34
- "overflow",
35
- "scrollbar",
36
- "textAlign"
37
- ];
38
- const BLOCK_OUTER_STYLES = [
39
- "border",
40
- "radius",
41
- "shadow",
42
- "outline"
43
- ];
44
- const BLOCK_STYLES = [...BLOCK_INNER_STYLES, ...BLOCK_OUTER_STYLES];
45
- const COLOR_STYLES = [
46
- "color",
47
- "fill",
48
- "fade",
49
- "image"
50
- ];
51
- const TEXT_STYLES = [
52
- "textTransform",
53
- "fontWeight",
54
- "fontStyle"
55
- ];
56
- const DIMENSION_STYLES = [
57
- "width",
58
- "height",
59
- "flexBasis",
60
- "flexGrow",
61
- "flexShrink",
62
- "flex"
63
- ];
64
- const FLOW_STYLES = [
65
- "flow",
66
- "place",
67
- "placeItems",
68
- "placeContent",
69
- "alignItems",
70
- "alignContent",
71
- "justifyItems",
72
- "justifyContent",
73
- "align",
74
- "justify",
75
- "gap",
76
- "columnGap",
77
- "rowGap",
78
- "gridColumns",
79
- "gridRows",
80
- "gridTemplate",
81
- "gridAreas"
82
- ];
83
- const CONTAINER_STYLES = [
84
- ...BASE_STYLES,
85
- ...COLOR_STYLES,
86
- ...DIMENSION_STYLES,
87
- ...POSITION_STYLES,
88
- ...BLOCK_STYLES,
89
- ...FLOW_STYLES
90
- ];
91
- const OUTER_STYLES = [
92
- ...POSITION_STYLES,
93
- ...DIMENSION_STYLES,
94
- ...BLOCK_OUTER_STYLES
95
- ];
96
- const INNER_STYLES = [
97
- ...BASE_STYLES,
98
- ...COLOR_STYLES,
99
- ...BLOCK_INNER_STYLES,
100
- ...FLOW_STYLES
101
- ];
6
+ //#region src/utils/function-color.ts
7
+ const RE_FUNC_NAME = /^([a-z][a-z0-9-]*)\s*\(/i;
8
+ const RE_COLOR_OUT = /^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\(|^#|^var\(--/i;
9
+ /**
10
+ * Resolve a `name(...)` value produced by a registered custom parse function
11
+ * into its concrete color output.
12
+ *
13
+ * A color function is just a `functions` entry whose output is an already
14
+ * supported color (`rgb`, `hsl`, `#…`, `oklch`, …). This helper delegates the
15
+ * value to the global parser (which already runs the registered parse function)
16
+ * and returns the result only when it looks like a color. Returns `null` when
17
+ * `str` is not a registered custom function or its output is not a color.
18
+ *
19
+ * This is the generic replacement for the previously hardcoded okhsl/okhst
20
+ * conversion branches scattered across `strToRgb`, `resolveToRgbaValues`, and
21
+ * the `#token.alpha` injection path.
22
+ */
23
+ function resolveFunctionColor(str) {
24
+ const m = RE_FUNC_NAME.exec(str);
25
+ if (!m) return null;
26
+ const name = m[1].toLowerCase();
27
+ getGlobalParser();
28
+ if (!(name in getGlobalParseFunctions())) return null;
29
+ const out = getGlobalParser().process(str).output;
30
+ if (!out || !RE_COLOR_OUT.test(out)) return null;
31
+ return out;
32
+ }
102
33
  //#endregion
103
34
  //#region src/injector/chunk-sheet-registry.ts
104
35
  /**
@@ -265,23 +196,42 @@ function fontFace(family, descriptors, options) {
265
196
  /**
266
197
  * Inject a CSS @counter-style rule.
267
198
  *
268
- * Permanent and global — no dispose or ref-counting.
269
- * Deduplicates by name (first definition wins).
199
+ * Permanent and global — no dispose or ref-counting. Deduplicates by name and
200
+ * overrides an existing rule by default. Pass `weak: true` for global
201
+ * `configure()` definitions, which never clobber an existing rule.
270
202
  */
271
203
  function counterStyle(name, descriptors, options) {
272
204
  return getGlobalInjector().counterStyle(name, descriptors, options);
273
205
  }
274
206
  /**
207
+ * Inject a CSS @function rule (custom function).
208
+ *
209
+ * Permanent and global — no dispose or ref-counting. Deduplicates by function
210
+ * name and overrides an existing rule by default. Pass `weak: true` for global
211
+ * `configure()` definitions, which never clobber an existing rule.
212
+ *
213
+ * @param name - The function name (`$$name`, `$name`, or `--name`)
214
+ * @param definition - Function definition (args, returns, result, local vars)
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * func('$$negative', { args: ['$value'], result: '(-1 * $value)' });
219
+ * ```
220
+ */
221
+ function func(name, definition, options) {
222
+ return getGlobalInjector().func(name, definition, options);
223
+ }
224
+ /**
275
225
  * Get CSS text from all sheets (for SSR)
276
226
  */
277
- function getCssText(options) {
278
- return getGlobalInjector().getCssText(options);
227
+ function getCSSText(options) {
228
+ return getGlobalInjector().getCSSText(options);
279
229
  }
280
230
  /**
281
231
  * Collect only CSS used by a rendered subtree (like jest-styled-components).
282
232
  * Pass the container returned by render(...).
283
233
  */
284
- function getCssTextForNode(node, options) {
234
+ function getCSSTextForNode(node, options) {
285
235
  const classRegex = tastyClassRegex(getNamePrefix());
286
236
  const classSet = /* @__PURE__ */ new Set();
287
237
  const readClasses = (el) => {
@@ -292,27 +242,39 @@ function getCssTextForNode(node, options) {
292
242
  if (node.getAttribute) readClasses(node);
293
243
  const elements = node.querySelectorAll ? node.querySelectorAll("[class]") : [];
294
244
  if (elements) elements.forEach(readClasses);
295
- return getGlobalInjector().getCssTextForClasses(classSet, options);
245
+ return getGlobalInjector().getCSSTextForClasses(classSet, options);
296
246
  }
297
247
  /**
298
- * Force cleanup of unused rules
248
+ * Hold the local `@keyframes` a set of classes animates, and report what they
249
+ * ended up being called. One reference per distinct set of steps, released when
250
+ * the last class animating it is collected.
251
+ */
252
+ function holdKeyframes(classNames, steps, options) {
253
+ return getGlobalInjector().holdKeyframes(classNames, steps, options);
254
+ }
255
+ /**
256
+ * Remove every injected rule that is neither in the DOM nor held by an
257
+ * outstanding `inject()` handle. Equivalent to `gc({ force: true })`.
299
258
  */
300
259
  function cleanup(root) {
301
260
  return getGlobalInjector().cleanup(root);
302
261
  }
303
262
  /**
304
- * Record a render-time usage hit for one or more classNames.
305
- * Used internally by computeStyles and tasty() to track usage for GC.
306
- * When the global touch counter reaches `touchInterval`, schedules GC.
263
+ * Count a render, so that a collection pass is scheduled every
264
+ * `gc.touchInterval` of them. Used internally by computeStyles and tasty().
265
+ *
266
+ * @deprecated The class name is ignored — collection asks the DOM what is
267
+ * rendered rather than recording usage per class, so scheduling does not need
268
+ * to know which class was involved. The argument is kept for compatibility.
307
269
  */
308
270
  function touch(className, options) {
309
271
  if (!getConfig().gc) return;
310
272
  getGlobalInjector().touch(className, options);
311
273
  }
312
274
  /**
313
- * Synchronous garbage collection of unused styles.
314
- * Evicts the oldest unused styles when usageMap exceeds capacity.
315
- * With `{ force: true }`, removes ALL unused styles regardless of capacity.
275
+ * Synchronous garbage collection of unused styles — those no element carries
276
+ * and no `inject()` handle references. Evicts the oldest ones once they exceed
277
+ * capacity. With `{ force: true }`, removes all of them regardless of capacity.
316
278
  *
317
279
  * @returns Number of styles evicted.
318
280
  */
@@ -320,12 +282,6 @@ function gc(options) {
320
282
  return getGlobalInjector().gc(options);
321
283
  }
322
284
  /**
323
- * Check if we're currently running in a test environment
324
- */
325
- function getIsTestEnvironment() {
326
- return isTestEnvironment();
327
- }
328
- /**
329
285
  * Get the global injector instance for debugging
330
286
  */
331
287
  const injector = { get instance() {
@@ -368,6 +324,7 @@ const getRSCCache = cache(() => ({
368
324
  emittedKeys: /* @__PURE__ */ new Set(),
369
325
  internalsEmitted: false,
370
326
  pendingCSS: [],
327
+ keyToIndex: /* @__PURE__ */ new Map(),
371
328
  generatedNames: /* @__PURE__ */ new Map()
372
329
  }));
373
330
  function rscAllocateClassName(rscCache, cacheKey) {
@@ -391,15 +348,28 @@ function flushPendingCSS(rscCache) {
391
348
  if (rscCache.pendingCSS.length === 0) return "";
392
349
  const css = rscCache.pendingCSS.join("\n");
393
350
  rscCache.pendingCSS.length = 0;
351
+ rscCache.keyToIndex.clear();
394
352
  return css;
395
353
  }
396
354
  /**
397
355
  * Push CSS into the RSC pending buffer with dedup via emittedKeys.
398
356
  * Returns true if the CSS was added, false if it was already emitted.
357
+ *
358
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last write
359
+ * must win to match the client's update-tracking behavior. If the slot has
360
+ * already been flushed into a `<style>` tag the new CSS is appended instead,
361
+ * which still wins by cascade order.
399
362
  */
400
- function pushRSCCSS(rscCache, key, css) {
401
- if (rscCache.emittedKeys.has(key)) return false;
363
+ function pushRSCCSS(rscCache, key, css, replace) {
364
+ if (replace) {
365
+ const pendingIndex = rscCache.keyToIndex.get(key);
366
+ if (pendingIndex !== void 0) {
367
+ rscCache.pendingCSS[pendingIndex] = css;
368
+ return true;
369
+ }
370
+ } else if (rscCache.emittedKeys.has(key)) return false;
402
371
  rscCache.emittedKeys.add(key);
372
+ rscCache.keyToIndex.set(key, rscCache.pendingCSS.length);
403
373
  rscCache.pendingCSS.push(css);
404
374
  return true;
405
375
  }
@@ -429,7 +399,7 @@ function getStyleTarget() {
429
399
  function scanAndEmitAutoProperties(rules, styles, emit) {
430
400
  const registered = /* @__PURE__ */ new Set();
431
401
  if (styles) {
432
- const localProps = styles["@properties"];
402
+ const localProps = styles["@property"];
433
403
  if (localProps && typeof localProps === "object") for (const token of Object.keys(localProps)) {
434
404
  const parsed = parsePropertyToken(token);
435
405
  if (parsed.isValid) registered.add(parsed.cssName);
@@ -455,7 +425,7 @@ function scanAndEmitAutoProperties(rules, styles, emit) {
455
425
  *
456
426
  * @param rules - Rendered style rules containing CSS declarations
457
427
  * @param collector - SSR collector to emit @property CSS into
458
- * @param styles - Original styles object (used to skip explicit @properties)
428
+ * @param styles - Original styles object (used to skip explicit @property)
459
429
  */
460
430
  function collectAutoInferredProperties(rules, collector, styles) {
461
431
  scanAndEmitAutoProperties(rules, styles, (name, css) => {
@@ -626,13 +596,23 @@ function collectAncillaryRSC(rscCache, styles) {
626
596
  }
627
597
  }
628
598
  }
599
+ if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
600
+ const localFunctions = extractLocalFunctions(styles);
601
+ if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) {
602
+ const key = `__func:${parseFunctionName(name)}`;
603
+ if (!rscCache.emittedKeys.has(key)) {
604
+ rscCache.emittedKeys.add(key);
605
+ parts.push(formatFunctionRule(name, definition));
606
+ }
607
+ }
608
+ }
629
609
  return parts.join("\n");
630
610
  }
631
611
  /**
632
612
  * Process all chunks in RSC mode: render CSS to strings, allocate classNames,
633
613
  * and return combined { className, css }.
634
614
  */
635
- function computeStylesRSC(styles, chunkMap) {
615
+ function computeStylesRSC(styles, chunkMap, stableStyles) {
636
616
  const rscCache = getRSCCache();
637
617
  const cssParts = [];
638
618
  const classNames = [];
@@ -642,7 +622,7 @@ function computeStylesRSC(styles, chunkMap) {
642
622
  if (internalsCSS) cssParts.push(internalsCSS);
643
623
  for (const [chunkName, chunkStyleKeys] of chunkMap) {
644
624
  if (chunkStyleKeys.length === 0) continue;
645
- const { className, isNew } = rscAllocateClassName(rscCache, generateChunkCacheKey(styles, chunkName, chunkStyleKeys));
625
+ const { className, isNew } = rscAllocateClassName(rscCache, generateChunkCacheKey(styles, chunkName, chunkStyleKeys, stableStyles));
646
626
  classNames.push(className);
647
627
  if (isNew) {
648
628
  const renderResult = renderStylesForChunk(styles, chunkName, chunkStyleKeys);
@@ -676,9 +656,9 @@ function getUsedKeyframes(styles) {
676
656
  /**
677
657
  * Process a chunk on the SSR path: allocate via collector, render, collect CSS.
678
658
  */
679
- function processChunkSSR(collector, styles, chunkName, styleKeys) {
659
+ function processChunkSSR(collector, styles, chunkName, styleKeys, stableStyles) {
680
660
  if (styleKeys.length === 0) return null;
681
- const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
661
+ const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys, stableStyles);
682
662
  const { className, isNewAllocation } = collector.allocateClassName(cacheKey);
683
663
  if (isNewAllocation) {
684
664
  const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);
@@ -706,14 +686,15 @@ function processChunkSSR(collector, styles, chunkName, styleKeys) {
706
686
  * Process a chunk on the client: render, allocate className, and inject
707
687
  * CSS synchronously. The injector's cache makes this idempotent.
708
688
  */
709
- function processChunkSync(styles, chunkName, styleKeys, root) {
689
+ function processChunkSync(styles, chunkName, styleKeys, stableStyles, root) {
710
690
  if (styleKeys.length === 0) return null;
711
- const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
691
+ const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys, stableStyles);
712
692
  const renderResult = renderStylesForChunk(styles, chunkName, styleKeys, cacheKey);
713
693
  if (renderResult.rules.length === 0) return null;
714
694
  const { className } = inject(renderResult.rules, {
715
695
  cacheKey,
716
- root
696
+ root,
697
+ pin: false
717
698
  });
718
699
  return {
719
700
  name: chunkName,
@@ -724,24 +705,6 @@ function processChunkSync(styles, chunkName, styleKeys, root) {
724
705
  };
725
706
  }
726
707
  /**
727
- * Inject keyframes synchronously and return a name replacement map.
728
- * On the client, keyframes are injected into the DOM.
729
- */
730
- function injectKeyframesSync(usedKeyframes, root) {
731
- let nameMap = null;
732
- for (const [name, steps] of Object.entries(usedKeyframes)) {
733
- const injectedName = keyframes(steps, {
734
- name,
735
- root
736
- }).toString();
737
- if (injectedName !== name) {
738
- if (!nameMap) nameMap = /* @__PURE__ */ new Map();
739
- nameMap.set(name, injectedName);
740
- }
741
- }
742
- return nameMap;
743
- }
744
- /**
745
708
  * Inject chunk rules synchronously, replacing animation names if needed.
746
709
  */
747
710
  function injectChunkRulesSync(chunks, nameMap, root) {
@@ -750,7 +713,8 @@ function injectChunkRulesSync(chunks, nameMap, root) {
750
713
  declarations: replaceAnimationNames(rule.declarations, nameMap)
751
714
  })) : chunk.renderResult.rules, {
752
715
  cacheKey: chunk.cacheKey,
753
- root
716
+ root,
717
+ pin: false
754
718
  });
755
719
  }
756
720
  /**
@@ -775,6 +739,10 @@ function injectAncillarySync(styles, root) {
775
739
  const localCounterStyle = extractLocalCounterStyle(styles);
776
740
  if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) counterStyle(name, descriptors, { root });
777
741
  }
742
+ if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
743
+ const localFunctions = extractLocalFunctions(styles);
744
+ if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) func(name, definition, { root });
745
+ }
778
746
  }
779
747
  /**
780
748
  * Collect all ancillary rules into the SSR collector.
@@ -810,6 +778,13 @@ function collectAncillarySSR(collector, styles, chunks) {
810
778
  collector.collectCounterStyle(name, css);
811
779
  }
812
780
  }
781
+ if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
782
+ const localFunctions = extractLocalFunctions(styles);
783
+ if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) {
784
+ const css = formatFunctionRule(name, definition);
785
+ collector.collectFunction(parseFunctionName(name), css);
786
+ }
787
+ }
813
788
  if (getConfig().autoPropertyTypes !== false) {
814
789
  const allRules = chunks.flatMap((c) => c.renderResult.rules);
815
790
  if (allRules.length > 0) collectAutoInferredProperties(allRules, collector, styles);
@@ -833,26 +808,28 @@ function collectAncillarySSR(collector, styles, chunks) {
833
808
  function computeStyles(styles, options) {
834
809
  if (!styles || !hasKeys(styles)) return EMPTY_RESULT;
835
810
  const resolved = resolveRecipes(styles);
811
+ const stableStyles = options?.stableStyles === true && resolved === styles;
812
+ if (isFunctionsPolyfillEnabled() && hasLocalFunctions(resolved)) registerLocalFunctionPolyfills(resolved);
836
813
  const chunkMap = categorizeStyleKeys(resolved);
837
814
  const collector = options?.ssrCollector !== void 0 ? options.ssrCollector : getRegisteredSSRCollector();
838
815
  const chunks = [];
839
816
  if (collector) {
840
817
  collector.collectInternals();
841
818
  for (const [chunkName, chunkStyleKeys] of chunkMap) {
842
- const chunk = processChunkSSR(collector, resolved, chunkName, chunkStyleKeys);
819
+ const chunk = processChunkSSR(collector, resolved, chunkName, chunkStyleKeys, stableStyles);
843
820
  if (chunk) chunks.push(chunk);
844
821
  }
845
822
  collectAncillarySSR(collector, resolved, chunks);
846
- } else if (typeof document === "undefined") return computeStylesRSC(resolved, chunkMap);
823
+ } else if (typeof document === "undefined") return computeStylesRSC(resolved, chunkMap, stableStyles);
847
824
  else {
848
825
  const root = options?.root;
849
826
  injectAncillarySync(resolved, root);
850
827
  const usedKf = getUsedKeyframes(resolved);
851
- const nameMap = usedKf ? injectKeyframesSync(usedKf, root) : null;
852
828
  for (const [chunkName, chunkStyleKeys] of chunkMap) {
853
- const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys, root);
829
+ const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys, stableStyles, root);
854
830
  if (chunk) chunks.push(chunk);
855
831
  }
832
+ const nameMap = usedKf ? holdKeyframes(chunks.map((chunk) => chunk.className), usedKf, { root }) : null;
856
833
  if (nameMap) injectChunkRulesSync(chunks, nameMap, root);
857
834
  for (const chunk of chunks) touch(chunk.className, { root });
858
835
  }
@@ -905,7 +882,7 @@ function filterBaseProps(props, opts = {}) {
905
882
  //#endregion
906
883
  //#region src/utils/colors.ts
907
884
  function color(name, opacity = 1) {
908
- if (opacity !== 1) return `${getColorSpaceFunc()}(var(--${name}-color-${getColorSpaceSuffix()}) / ${opacity})`;
885
+ if (opacity !== 1) return overrideColorAlpha(`var(--${name}-color)`, String(opacity));
909
886
  return `var(--${name}-color)`;
910
887
  }
911
888
  //#endregion
@@ -935,7 +912,7 @@ function modAttrs(map) {
935
912
  if (value === true) attrs[attrName] = "";
936
913
  else if (typeof value === "string") attrs[attrName] = value;
937
914
  else if (typeof value === "number") attrs[attrName] = String(value);
938
- else console.warn(`Tasty: Invalid mod value for "${key}". Expected boolean, string, or number, got ${typeof value}`);
915
+ else console.warn(`[Tasty] Invalid mod value for "${key}". Expected boolean, string, or number, got ${typeof value}`);
939
916
  return attrs;
940
917
  }, {}) : null;
941
918
  }
@@ -1062,28 +1039,13 @@ const dotize = {
1062
1039
  //#endregion
1063
1040
  //#region src/utils/process-tokens.ts
1064
1041
  /**
1065
- * Extract color components in the configured color space.
1066
- * Returns a CSS variable reference for token colors, or decomposed
1067
- * components as a space-separated string.
1068
- */
1069
- function extractColorSpaceValue(colorValue, parsedOutput) {
1070
- const suffix = getColorSpaceSuffix();
1071
- const varMatch = parsedOutput.match(/var\(--([a-z0-9-]+)-color\)/);
1072
- if (varMatch) return `var(--${varMatch[1]}-color-${suffix})`;
1073
- const components = getColorSpaceComponents(colorValue);
1074
- if (components !== colorValue) return components;
1075
- const componentsFromParsed = getColorSpaceComponents(parsedOutput);
1076
- if (componentsFromParsed !== parsedOutput) return componentsFromParsed;
1077
- return parsedOutput;
1078
- }
1079
- /**
1080
1042
  * Check if a value is a valid token value (string, number, or boolean - not object).
1081
1043
  * Returns false for `false` values (they mean "skip this token").
1082
1044
  */
1083
1045
  function isValidTokenValue(value) {
1084
1046
  if (value === void 0 || value === null || value === false) return false;
1085
1047
  if (typeof value === "object") {
1086
- console.warn("Tasty: Object values are not allowed in tokens prop. Tokens do not support state-based styling. Use a primitive value instead.");
1048
+ console.warn("[Tasty] Object values are not allowed in tokens prop. Tokens do not support state-based styling. Use a primitive value instead.");
1087
1049
  return false;
1088
1050
  }
1089
1051
  return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -1100,9 +1062,24 @@ function processTokenValue(value) {
1100
1062
  return parseStyle(value).output;
1101
1063
  }
1102
1064
  /**
1065
+ * Resolve one `$name` / `#name` entry to the custom property it declares and
1066
+ * the value to declare, or `null` when the entry declares nothing.
1067
+ *
1068
+ * The two sigils differ only in the property name they build and in how `true`
1069
+ * is read: for a custom property it is the empty value, for a color it is
1070
+ * `transparent`.
1071
+ */
1072
+ function resolveTokenEntry(key, value) {
1073
+ const name = `--${normalizeDslName(key.slice(1))}`;
1074
+ if (key[0] === "$") return [name, processTokenValue(value === true ? "" : value)];
1075
+ const colorValue = normalizeColorTokenValue(value);
1076
+ if (colorValue === null) return null;
1077
+ return [`${name}-color`, processTokenValue(colorValue)];
1078
+ }
1079
+ /**
1103
1080
  * Process tokens object into inline style properties.
1104
- * - $name -> --name with parsed value
1105
- * - #name -> --name-color AND --name-color-{colorSpace} with parsed values
1081
+ * - `$name` -> `--name` with the parsed value
1082
+ * - `#name` -> `--name-color` with the parsed value
1106
1083
  *
1107
1084
  * @param tokens - The tokens object to process
1108
1085
  * @returns CSSProperties object or undefined if no tokens to process
@@ -1115,24 +1092,11 @@ function processTokens(tokens) {
1115
1092
  for (const key of keys) {
1116
1093
  const value = tokens[key];
1117
1094
  if (!isValidTokenValue(value)) continue;
1118
- if (key.startsWith("$")) {
1119
- const propName = `--${key.slice(1)}`;
1120
- const processedValue = processTokenValue(value === true ? "" : value);
1121
- if (!result) result = {};
1122
- result[propName] = processedValue;
1123
- } else if (key.startsWith("#")) {
1124
- const colorName = key.slice(1);
1125
- const suffix = getColorSpaceSuffix();
1126
- const effectiveValue = normalizeColorTokenValue(value);
1127
- if (effectiveValue === null) continue;
1128
- const originalValue = typeof effectiveValue === "number" ? String(effectiveValue) : effectiveValue;
1129
- const lowerValue = originalValue.toLowerCase();
1130
- const processedValue = processTokenValue(effectiveValue);
1131
- if (!result) result = {};
1132
- result[`--${colorName}-color`] = processedValue;
1133
- if (/^#current(?:\.|$)/i.test(lowerValue)) continue;
1134
- result[`--${colorName}-color-${suffix}`] = extractColorSpaceValue(originalValue, processedValue);
1135
- }
1095
+ if (key[0] !== "$" && key[0] !== "#") continue;
1096
+ const entry = resolveTokenEntry(key, value);
1097
+ if (!entry) continue;
1098
+ if (!result) result = {};
1099
+ result[entry[0]] = entry[1];
1136
1100
  }
1137
1101
  return result;
1138
1102
  }
@@ -1150,13 +1114,6 @@ function sortTastyClasses(classes) {
1150
1114
  function getRegistry(root = document) {
1151
1115
  return injector.instance._sheetManager?.getRegistry(root);
1152
1116
  }
1153
- function getUnusedClasses(root = document) {
1154
- const registry = getRegistry(root);
1155
- if (!registry) return [];
1156
- const result = [];
1157
- for (const [cls, rc] of registry.refCounts) if (rc === 0) result.push(cls);
1158
- return sortTastyClasses(result);
1159
- }
1160
1117
  function findDomTastyClasses(root = document) {
1161
1118
  const classes = /* @__PURE__ */ new Set();
1162
1119
  const elements = root.querySelectorAll?.("[class]") || [];
@@ -1169,6 +1126,25 @@ function findDomTastyClasses(root = document) {
1169
1126
  });
1170
1127
  return sortTastyClasses(classes);
1171
1128
  }
1129
+ /**
1130
+ * Injected classes that no element carries and nobody pinned — the exact set
1131
+ * `gc({ force: true })` would delete.
1132
+ *
1133
+ * Deliberately borrowed from the injector rather than recomputed here: the two
1134
+ * drifted apart once before, when this file still read "unused" off the pin
1135
+ * counts the render path had stopped maintaining.
1136
+ */
1137
+ function getUnusedClasses(root = document) {
1138
+ return sortTastyClasses(injector.instance.getUnusedClasses({ root }));
1139
+ }
1140
+ /** Every class this injector holds CSS for in `root`. */
1141
+ function getOwnedClasses(root = document) {
1142
+ const registry = getRegistry(root);
1143
+ if (!registry) return [];
1144
+ const owned = [];
1145
+ for (const [className, info] of registry.rules) if (info.sheetIndex >= 0) owned.push(className);
1146
+ return sortTastyClasses(owned);
1147
+ }
1172
1148
  function prettifyCSS(css) {
1173
1149
  if (!css || !css.trim()) return "";
1174
1150
  const out = [];
@@ -1251,7 +1227,7 @@ function buildChunkBreakdown(root = document) {
1251
1227
  ruleCount: 0
1252
1228
  };
1253
1229
  byChunk[chunk].classes.push(className);
1254
- const css = injector.instance.getCssTextForClasses([className], { root });
1230
+ const css = injector.instance.getCSSTextForClasses([className], { root });
1255
1231
  byChunk[chunk].cssSize += css.length;
1256
1232
  byChunk[chunk].ruleCount += countRules(css);
1257
1233
  }
@@ -1369,34 +1345,34 @@ const tastyDebug = {
1369
1345
  const src = getSourceCssForClasses([target], root);
1370
1346
  if (src) css = src;
1371
1347
  else {
1372
- if (!raw) console.warn("tastyDebug: source CSS not available (requires dev mode or TASTY_DEBUG=true). Falling back to live CSSOM.");
1373
- css = injector.instance.getCssTextForClasses([target], { root });
1348
+ if (!raw) console.warn("[Tasty] source CSS not available (requires dev mode or TASTY_DEBUG=true). Falling back to live CSSOM.");
1349
+ css = injector.instance.getCSSTextForClasses([target], { root });
1374
1350
  }
1375
1351
  } else if (source && Array.isArray(target)) {
1376
1352
  const src = getSourceCssForClasses(target, root);
1377
1353
  if (src) css = src;
1378
1354
  else {
1379
- if (!raw) console.warn("tastyDebug: source CSS not available. Falling back to live CSSOM.");
1380
- css = injector.instance.getCssTextForClasses(target, { root });
1355
+ if (!raw) console.warn("[Tasty] source CSS not available. Falling back to live CSSOM.");
1356
+ css = injector.instance.getCSSTextForClasses(target, { root });
1381
1357
  }
1382
- } else if (typeof target === "string") if (target === "all") css = injector.instance.getCssText({ root });
1358
+ } else if (typeof target === "string") if (target === "all") css = injector.instance.getCSSText({ root });
1383
1359
  else if (target === "global") {
1384
1360
  css = getGlobalTypeCSS("global", root).css;
1385
1361
  return css;
1386
1362
  } else if (target === "active") {
1387
1363
  const active = findDomTastyClasses(root);
1388
- css = injector.instance.getCssTextForClasses(active, { root });
1364
+ css = injector.instance.getCSSTextForClasses(active, { root });
1389
1365
  } else if (target === "unused") {
1390
1366
  const unused = getUnusedClasses(root);
1391
- css = injector.instance.getCssTextForClasses(unused, { root });
1367
+ css = injector.instance.getCSSTextForClasses(unused, { root });
1392
1368
  } else if (target === "page") css = getPageCSS(root);
1393
- else if (classRegex.test(target)) css = injector.instance.getCssTextForClasses([target], { root });
1369
+ else if (classRegex.test(target)) css = injector.instance.getCSSTextForClasses([target], { root });
1394
1370
  else {
1395
1371
  const el = root.querySelector?.(target);
1396
- if (el) css = getCssTextForNode(el, { root });
1372
+ if (el) css = getCSSTextForNode(el, { root });
1397
1373
  }
1398
- else if (Array.isArray(target)) css = injector.instance.getCssTextForClasses(target, { root });
1399
- else if (target instanceof Element) css = getCssTextForNode(target, { root });
1374
+ else if (Array.isArray(target)) css = injector.instance.getCSSTextForClasses(target, { root });
1375
+ else if (target instanceof Element) css = getCSSTextForNode(target, { root });
1400
1376
  const result = prettify ? prettifyCSS(css) : css;
1401
1377
  if (!raw) {
1402
1378
  const label = Array.isArray(target) ? `[${target.join(", ")}]` : target;
@@ -1419,7 +1395,7 @@ const tastyDebug = {
1419
1395
  size: 0,
1420
1396
  rules: 0
1421
1397
  };
1422
- if (!raw) console.warn("tastyDebug.inspect: element not found");
1398
+ if (!raw) console.warn("[Tasty] debug.inspect: element not found");
1423
1399
  return empty;
1424
1400
  }
1425
1401
  const classList = element.getAttribute("class") || "";
@@ -1429,7 +1405,7 @@ const tastyDebug = {
1429
1405
  className,
1430
1406
  chunkName: getChunkForClass(className, root)
1431
1407
  }));
1432
- const css = getCssTextForNode(element, { root });
1408
+ const css = getCSSTextForNode(element, { root });
1433
1409
  const rules = countRules(css);
1434
1410
  const result = {
1435
1411
  element,
@@ -1455,23 +1431,29 @@ const tastyDebug = {
1455
1431
  const { root = document, raw = false } = opts || {};
1456
1432
  const activeClasses = findDomTastyClasses(root);
1457
1433
  const unusedClasses = getUnusedClasses(root);
1458
- const totalStyledClasses = [...activeClasses, ...unusedClasses];
1459
- const activeCSS = injector.instance.getCssTextForClasses(activeClasses, { root });
1460
- const unusedCSS = injector.instance.getCssTextForClasses(unusedClasses, { root });
1461
- const allCSS = injector.instance.getCssText({ root });
1434
+ const ownedClasses = getOwnedClasses(root);
1435
+ const totalStyledClasses = sortTastyClasses(new Set([...activeClasses, ...ownedClasses]));
1436
+ const unusedSet = new Set(unusedClasses);
1437
+ const activeSet = new Set(activeClasses);
1438
+ const hotClasses = ownedClasses.filter((className) => !activeSet.has(className) && !unusedSet.has(className));
1439
+ const hotCSS = injector.instance.getCSSTextForClasses(hotClasses, { root });
1440
+ const activeCSS = injector.instance.getCSSTextForClasses(activeClasses, { root });
1441
+ const unusedCSS = injector.instance.getCSSTextForClasses(unusedClasses, { root });
1442
+ const allCSS = injector.instance.getCSSText({ root });
1462
1443
  const activeRuleCount = countRules(activeCSS);
1463
1444
  const unusedRuleCount = countRules(unusedCSS);
1464
1445
  const globalData = getGlobalTypeCSS("global", root);
1465
1446
  const rawData = getGlobalTypeCSS("raw", root);
1466
1447
  const kfData = getGlobalTypeCSS("keyframes", root);
1467
1448
  const propData = getGlobalTypeCSS("property", root);
1468
- const totalRuleCount = activeRuleCount + unusedRuleCount + globalData.ruleCount + rawData.ruleCount + kfData.ruleCount + propData.ruleCount;
1449
+ const totalRuleCount = activeRuleCount + unusedRuleCount + countRules(hotCSS) + globalData.ruleCount + rawData.ruleCount + kfData.ruleCount + propData.ruleCount;
1469
1450
  const metrics = injector.instance.getMetrics({ root });
1470
1451
  const defs = getDefs(root);
1471
1452
  const chunkBreakdown = buildChunkBreakdown(root);
1472
1453
  const summary = {
1473
1454
  activeClasses,
1474
1455
  unusedClasses,
1456
+ hotClasses,
1475
1457
  totalStyledClasses,
1476
1458
  activeCSSSize: activeCSS.length,
1477
1459
  unusedCSSSize: unusedCSS.length,
@@ -1496,6 +1478,7 @@ const tastyDebug = {
1496
1478
  console.group("Tasty Summary");
1497
1479
  console.log(`Active: ${activeClasses.length} classes, ${activeRuleCount} rules, ${fmtSize(activeCSS.length)}`);
1498
1480
  console.log(`Unused: ${unusedClasses.length} classes, ${unusedRuleCount} rules, ${fmtSize(unusedCSS.length)}`);
1481
+ if (hotClasses.length) console.log(`Held: ${hotClasses.length} classes, ${countRules(hotCSS)} rules, ${fmtSize(hotCSS.length)} (not rendered, not yet collectable)`);
1499
1482
  console.log(`Global: ${globalData.ruleCount} rules, ${fmtSize(globalData.size)}`);
1500
1483
  if (rawData.ruleCount) console.log(`Raw: ${rawData.ruleCount} rules, ${fmtSize(rawData.size)}`);
1501
1484
  if (kfData.ruleCount) console.log(`Keyframes: ${kfData.ruleCount} rules, ${fmtSize(kfData.size)}`);
@@ -1593,6 +1576,6 @@ function getPageCSS(root = document) {
1593
1576
  }
1594
1577
  if (typeof window !== "undefined" && isDevEnv()) tastyDebug.install();
1595
1578
  //#endregion
1596
- export { property as A, DIMENSION_STYLES as B, getRawCSSText as C, injector as D, injectRawCSS as E, BLOCK_INNER_STYLES as F, TEXT_STYLES as G, INNER_STYLES as H, BLOCK_OUTER_STYLES as I, BLOCK_STYLES as L, ChunkSheetRegistry as M, chunkSheetRegistry as N, isPropertyDefined as O, BASE_STYLES as P, COLOR_STYLES as R, getIsTestEnvironment as S, injectGlobal as T, OUTER_STYLES as U, FLOW_STYLES as V, POSITION_STYLES as W, destroy as _, color as a, getCssText as b, hasKeys as c, collectAutoInferredPropertiesRSC as d, getStyleTarget as f, createInjector as g, counterStyle as h, _modAttrs as i, touch as j, keyframes as k, formatKeyframesCSS as l, cleanup as m, processTokens as n, filterBaseProps as o, pushRSCCSS as p, dotize as r, computeStyles as s, tastyDebug as t, collectAutoInferredProperties as u, fontFace as v, inject as w, getCssTextForNode as x, gc as y, CONTAINER_STYLES as z };
1579
+ export { keyframes as A, getRawCSSText as C, injectRawCSS as D, injectGlobal as E, resolveFunctionColor as F, touch as M, ChunkSheetRegistry as N, injector as O, chunkSheetRegistry as P, getCSSTextForNode as S, inject as T, destroy as _, color as a, gc as b, hasKeys as c, collectAutoInferredPropertiesRSC as d, getStyleTarget as f, createInjector as g, counterStyle as h, _modAttrs as i, property as j, isPropertyDefined as k, formatKeyframesCSS as l, cleanup as m, processTokens as n, filterBaseProps as o, pushRSCCSS as p, dotize as r, computeStyles as s, tastyDebug as t, collectAutoInferredProperties as u, fontFace as v, holdKeyframes as w, getCSSText as x, func as y };
1597
1580
 
1598
- //# sourceMappingURL=core-CQfmSOQW.js.map
1581
+ //# sourceMappingURL=core-C9nPCkW6.js.map