@tenphi/tasty 0.0.0-snapshot.b6cc3cd → 0.0.0-snapshot.b70adcb

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 (102) hide show
  1. package/README.md +147 -129
  2. package/dist/astro-DmdDJ6uY.js +301 -0
  3. package/dist/astro-DmdDJ6uY.js.map +1 -0
  4. package/dist/{babel-D8dm92E_.d.ts → babel-BOfdfseh.d.ts} +2 -2
  5. package/dist/collector-B0ehMgiy.js +530 -0
  6. package/dist/collector-B0ehMgiy.js.map +1 -0
  7. package/dist/{collector-BFuqdF2F.d.ts → collector-DlH0WfI4.d.ts} +94 -11
  8. package/dist/{config-DH7I0Ggx.d.ts → config-CJKXZDrM.d.ts} +183 -40
  9. package/dist/{config-BrDt11hO.js → config-pEfUVSK_.js} +918 -1134
  10. package/dist/config-pEfUVSK_.js.map +1 -0
  11. package/dist/core/index.d.ts +5 -5
  12. package/dist/core/index.js +6 -6
  13. package/dist/{core-YWn1zgh4.js → core-k3upKydI.js} +454 -151
  14. package/dist/core-k3upKydI.js.map +1 -0
  15. package/dist/css-resources-Cyl_axbI.js +149 -0
  16. package/dist/css-resources-Cyl_axbI.js.map +1 -0
  17. package/dist/{css-writer-CQYbT4g_.js → css-writer-mJs2wklg.js} +3 -3
  18. package/dist/{css-writer-CQYbT4g_.js.map → css-writer-mJs2wklg.js.map} +1 -1
  19. package/dist/{format-rules-DdmLdntR.js → format-rules-13uxeuU9.js} +25 -50
  20. package/dist/format-rules-13uxeuU9.js.map +1 -0
  21. package/dist/{hydrate-D2ivfS-B.js → hydrate-C3iKO38t.js} +3 -3
  22. package/dist/{hydrate-D2ivfS-B.js.map → hydrate-C3iKO38t.js.map} +1 -1
  23. package/dist/{index-LC3O3Jj4.d.ts → index-C8RFYeFW.d.ts} +87 -16
  24. package/dist/{index-DljBkZhV.d.ts → index-Do1d1v9f.d.ts} +66 -22
  25. package/dist/index.d.ts +5 -5
  26. package/dist/index.js +45 -28
  27. package/dist/index.js.map +1 -1
  28. package/dist/{keyframes-CoLLjBcd.js → keyframes-gFeuFSzE.js} +132 -21
  29. package/dist/keyframes-gFeuFSzE.js.map +1 -0
  30. package/dist/{merge-styles-Cx_6ySBv.d.ts → merge-styles-BQv7d3fx.d.ts} +2 -2
  31. package/dist/{merge-styles-bdh7-1uh.js → merge-styles-p0pofQ3S.js} +2 -2
  32. package/dist/{merge-styles-bdh7-1uh.js.map → merge-styles-p0pofQ3S.js.map} +1 -1
  33. package/dist/precompile/index.d.ts +11 -0
  34. package/dist/precompile/index.js +82 -0
  35. package/dist/precompile/index.js.map +1 -0
  36. package/dist/precompile/register.d.ts +13 -0
  37. package/dist/precompile/register.js +2 -0
  38. package/dist/register-DRrc1VWt.js +340 -0
  39. package/dist/register-DRrc1VWt.js.map +1 -0
  40. package/dist/{resolve-recipes-9JYSgubn.js → resolve-recipes-CldVRsBq.js} +3 -3
  41. package/dist/{resolve-recipes-9JYSgubn.js.map → resolve-recipes-CldVRsBq.js.map} +1 -1
  42. package/dist/ssr/astro-client.js +1 -1
  43. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  44. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  45. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  46. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  47. package/dist/ssr/astro-middleware-extract.js +9 -0
  48. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  49. package/dist/ssr/astro-middleware-static.d.ts +3 -1
  50. package/dist/ssr/astro-middleware-static.js +1 -1
  51. package/dist/ssr/astro-middleware.d.ts +3 -1
  52. package/dist/ssr/astro-middleware.js +1 -1
  53. package/dist/ssr/astro.d.ts +45 -3
  54. package/dist/ssr/astro.js +1 -156
  55. package/dist/ssr/index.d.ts +2 -2
  56. package/dist/ssr/index.js +3 -3
  57. package/dist/ssr/index.js.map +1 -1
  58. package/dist/ssr/next-config.d.ts +66 -0
  59. package/dist/ssr/next-config.js +115 -0
  60. package/dist/ssr/next-config.js.map +1 -0
  61. package/dist/ssr/next.d.ts +9 -2
  62. package/dist/ssr/next.js +26 -9
  63. package/dist/ssr/next.js.map +1 -1
  64. package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
  65. package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
  66. package/dist/static/index.d.ts +2 -2
  67. package/dist/static/index.js +1 -1
  68. package/dist/types-_uR064Sd.d.ts +129 -0
  69. package/dist/zero/babel.d.ts +1 -1
  70. package/dist/zero/babel.js +4 -4
  71. package/dist/zero/babel.js.map +1 -1
  72. package/dist/zero/index.d.ts +1 -1
  73. package/dist/zero/index.js +1 -1
  74. package/dist/zero/next.d.ts +1 -1
  75. package/docs/README.md +15 -8
  76. package/docs/adoption.md +56 -31
  77. package/docs/ai-agents.md +78 -77
  78. package/docs/comparison.md +69 -40
  79. package/docs/configuration.md +164 -101
  80. package/docs/debug.md +21 -8
  81. package/docs/design-system.md +41 -22
  82. package/docs/dsl.md +263 -198
  83. package/docs/getting-started.md +60 -39
  84. package/docs/injector.md +63 -26
  85. package/docs/methodology.md +43 -37
  86. package/docs/migration-v3.md +49 -49
  87. package/docs/pipeline.md +1 -4
  88. package/docs/plugins.md +37 -33
  89. package/docs/precompile.md +213 -0
  90. package/docs/react-api.md +66 -45
  91. package/docs/runtime-benchmarks.md +287 -0
  92. package/docs/ssr.md +219 -61
  93. package/docs/styles.md +9 -2
  94. package/docs/tasty-static.md +137 -104
  95. package/package.json +52 -12
  96. package/dist/collector-Di3C8btw.js +0 -304
  97. package/dist/collector-Di3C8btw.js.map +0 -1
  98. package/dist/config-BrDt11hO.js.map +0 -1
  99. package/dist/core-YWn1zgh4.js.map +0 -1
  100. package/dist/format-rules-DdmLdntR.js.map +0 -1
  101. package/dist/keyframes-CoLLjBcd.js.map +0 -1
  102. package/dist/ssr/astro.js.map +0 -1
@@ -1,8 +1,37 @@
1
- import { n as StyleResult } from "./index-LC3O3Jj4.js";
1
+ import { n as StyleResult } from "./index-C8RFYeFW.js";
2
+ import { c as TastyPrecompiledChunk, f as TastyStyleArtifactSource, l as TastyPrecompiledDependencies } from "./types-_uR064Sd.js";
2
3
 
3
4
  //#region src/ssr/collector.d.ts
5
+ type ServerStyleArtifactKind = 'property' | 'font-face' | 'counter-style' | 'function' | 'raw' | 'global' | 'chunk' | 'keyframes';
6
+ interface ServerStyleArtifact {
7
+ /** Stable identifier derived from the artifact kind, logical key, and CSS. */
8
+ id: string;
9
+ kind: ServerStyleArtifactKind;
10
+ css: string;
11
+ /** Zero-based position in the collector's final cascade order. */
12
+ order: number;
13
+ /** Origin of the rule. */
14
+ source: TastyStyleArtifactSource;
15
+ }
16
+ interface CollectArtifactOptions {
17
+ source?: TastyStyleArtifactSource;
18
+ }
19
+ interface CollectPropertyOptions extends CollectArtifactOptions {
20
+ cssName?: string;
21
+ normalizedDefinition?: string;
22
+ rscKey?: string;
23
+ }
24
+ interface CollectKeyframesOptions extends CollectArtifactOptions {
25
+ contentKey?: string;
26
+ rscKeys?: readonly string[];
27
+ }
28
+ interface CollectCounterStyleOptions extends CollectArtifactOptions {
29
+ weak?: boolean;
30
+ rscKeys?: readonly string[];
31
+ }
4
32
  declare class ServerStyleCollector {
5
33
  private chunks;
34
+ private chunkRuleCounts;
6
35
  private cacheKeyToClassName;
7
36
  private flushedKeys;
8
37
  private propertyRules;
@@ -23,6 +52,21 @@ declare class ServerStyleCollector {
23
52
  private counterStyleCounter;
24
53
  private internalsCollected;
25
54
  private namePrefix;
55
+ private artifactSources;
56
+ private precompiledChunks;
57
+ private precompiledProperties;
58
+ private precompiledKeyframes;
59
+ private precompiledFontFaces;
60
+ private precompiledCounterStyles;
61
+ private precompiledFunctions;
62
+ private precompiledRSCKeys;
63
+ private appliedPrecompiledRevision;
64
+ private externalProperties;
65
+ private externalKeyframes;
66
+ private externalFontFaces;
67
+ private externalCounterStyles;
68
+ private externalFunctions;
69
+ private precompileRecording;
26
70
  /**
27
71
  * @param namePrefix - Optional override for the configured prefix.
28
72
  * Defaults to the value from `configure({ namePrefix })` (or `'t'`).
@@ -31,7 +75,32 @@ declare class ServerStyleCollector {
31
75
  * so misconfiguration fails before any CSS is collected.
32
76
  */
33
77
  constructor(namePrefix?: string);
78
+ private sourceKey;
79
+ private setSource;
80
+ /**
81
+ * Pick up manifests registered after this collector was constructed.
82
+ *
83
+ * Deliberately not called from the constructor. Reading the registered
84
+ * dependencies is what validates the catalogs against the host's
85
+ * configuration, and registration is a side-effect import that routinely
86
+ * runs before the host's own `configure()` call — so a collector built in
87
+ * between would validate against defaults and permanently drop a catalog
88
+ * that matches once configuration is installed.
89
+ *
90
+ * Instead every method that consults an `external*` set calls this first, so
91
+ * the seed lands at whichever style-producing operation happens to come
92
+ * first. That gate belongs here rather than at the call sites: the standalone
93
+ * at-rule hooks (`useKeyframes`, `useCounterStyle`, `useFontFace`) go
94
+ * straight to `collect*` and never reach `collectInternals()`, so a catalog's
95
+ * standalone rule would otherwise be emitted a second time during SSR.
96
+ * After the first call this is an integer comparison.
97
+ */
98
+ applyRegisteredPrecompiledDependencies(): void;
34
99
  private generateClassName;
100
+ /** @internal Enable build-time chunk lookup metadata collection. */
101
+ enablePrecompileRecording(): void;
102
+ /** @internal Whether this collector is producing a catalog artifact. */
103
+ isPrecompileRecording(): boolean;
35
104
  /**
36
105
  * Collect internal @property rules and :root token defaults.
37
106
  * Mirrors markStylesGenerated() from the client-side injector.
@@ -55,14 +124,16 @@ declare class ServerStyleCollector {
55
124
  * Called by useStyles during server render.
56
125
  */
57
126
  collectChunk(cacheKey: string, className: string, rules: StyleResult[]): void;
127
+ /** Record the pre-render lookup key corresponding to a collected chunk. */
128
+ recordPrecompiledChunk(lookupKey: string, className: string, animations: readonly string[]): void;
58
129
  /**
59
130
  * Record a @property rule. Deduplicated by name.
60
131
  */
61
- collectProperty(name: string, css: string): void;
132
+ collectProperty(name: string, css: string, options?: CollectPropertyOptions): void;
62
133
  /**
63
134
  * Record a @keyframes rule. Deduplicated by name.
64
135
  */
65
- collectKeyframes(name: string, css: string): void;
136
+ collectKeyframes(name: string, css: string, options?: CollectKeyframesOptions): void;
66
137
  /**
67
138
  * Allocate a keyframe name for SSR. Uses provided name or generates one.
68
139
  */
@@ -70,15 +141,13 @@ declare class ServerStyleCollector {
70
141
  /**
71
142
  * Record a @font-face rule. Deduplicated by key (content hash).
72
143
  */
73
- collectFontFace(key: string, css: string): void;
144
+ collectFontFace(key: string, css: string, options?: CollectArtifactOptions): void;
74
145
  /**
75
146
  * Record a @counter-style rule. Deduplicated by name and overrides an
76
147
  * existing rule by default. Pass `weak: true` for global `configure()`
77
148
  * definitions, which never clobber an existing rule.
78
149
  */
79
- collectCounterStyle(name: string, css: string, options?: {
80
- weak?: boolean;
81
- }): void;
150
+ collectCounterStyle(name: string, css: string, options?: CollectCounterStyleOptions): void;
82
151
  /**
83
152
  * Record a @function rule. Deduplicated by CSS function name and overrides an
84
153
  * existing rule by default. Pass `weak: true` for global `configure()`
@@ -86,6 +155,7 @@ declare class ServerStyleCollector {
86
155
  */
87
156
  collectFunction(name: string, css: string, options?: {
88
157
  weak?: boolean;
158
+ source?: TastyStyleArtifactSource;
89
159
  }): void;
90
160
  /**
91
161
  * Allocate a counter-style name for SSR. Uses provided name or generates one.
@@ -97,14 +167,27 @@ declare class ServerStyleCollector {
97
167
  * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
98
168
  * write must win to match the client's update-tracking behavior.
99
169
  */
100
- collectGlobalStyles(key: string, css: string, replace?: boolean): void;
170
+ collectGlobalStyles(key: string, css: string, replace?: boolean, options?: CollectArtifactOptions): void;
101
171
  /**
102
172
  * Record raw CSS text (from useRawCSS). Deduplicated by key.
103
173
  *
104
174
  * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
105
175
  * write must win to match the client's update-tracking behavior.
106
176
  */
107
- collectRawCSS(key: string, css: string, replace?: boolean): void;
177
+ collectRawCSS(key: string, css: string, replace?: boolean, options?: CollectArtifactOptions): void;
178
+ getPrecompiledChunks(): TastyPrecompiledChunk[];
179
+ getPrecompiledDependencies(): TastyPrecompiledDependencies;
180
+ /** @internal Structural top-level rule count for component artifacts. */
181
+ getPrecompiledRuleCount(): number;
182
+ /**
183
+ * Return the collected CSS as structured, ordered artifacts.
184
+ *
185
+ * Artifact boundaries are part of the collector output so build tools never
186
+ * need to split or parse CSS text. IDs include the logical collection key
187
+ * and content, making them stable across equivalent page renders while a CSS
188
+ * change always produces a different ID.
189
+ */
190
+ getArtifacts(): ServerStyleArtifact[];
108
191
  /**
109
192
  * Extract all CSS collected so far as a single string.
110
193
  * Includes @property and @keyframes rules.
@@ -141,5 +224,5 @@ declare class ServerStyleCollector {
141
224
  */
142
225
  declare function createServerStyleCollector(namePrefix?: string): ServerStyleCollector;
143
226
  //#endregion
144
- export { createServerStyleCollector as n, ServerStyleCollector as t };
145
- //# sourceMappingURL=collector-BFuqdF2F.d.ts.map
227
+ export { createServerStyleCollector as i, ServerStyleArtifactKind as n, ServerStyleCollector as r, ServerStyleArtifact as t };
228
+ //# sourceMappingURL=collector-DlH0WfI4.d.ts.map
@@ -1,4 +1,5 @@
1
- import { Dt as SheetInfo, Et as RuleInfo, Ot as StyleInjectorConfig, P as StyleHandlerDefinition, St as PropertyDefinition, Tt as RootRegistry, b as Styles, bt as KeyframesResult, dt as FunctionDefinition, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as UnitHandler, kt as StyleRule, lt as FontFaceDescriptors, mt as GCOptions, n as StyleResult, nt as StyleDetails, ot as CacheMetrics, pt as GCConfig, st as CounterStyleDescriptors, ut as FontFaceInput, v as RecipeStyles, wt as RawCSSResult, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-LC3O3Jj4.js";
1
+ import { At as StyleRule, Ct as PropertyDefinition, Dt as RuleInfo, Et as RootRegistry, Ot as SheetInfo, P as StyleHandlerDefinition, St as KeyframesSteps, Tt as RawCSSResult, _t as InjectResult, b as Styles, bt as KeyframesInfo, dt as FunctionDefinition, gt as InjectOptions, h as ConfigTokens, ht as GlobalInjectResult, it as UnitHandler, kt as StyleInjectorConfig, lt as FontFaceDescriptors, mt as GCOptions, n as StyleResult, nt as StyleDetails, ot as CacheMetrics, pt as GCConfig, st as CounterStyleDescriptors, ut as FontFaceInput, v as RecipeStyles, xt as KeyframesResult } from "./index-C8RFYeFW.js";
2
+ import { l as TastyPrecompiledDependencies } from "./types-_uR064Sd.js";
2
3
 
3
4
  //#region src/prop-handlers.d.ts
4
5
  /**
@@ -151,17 +152,25 @@ declare class SheetManager {
151
152
  */
152
153
  private engineSupportsAtProperty;
153
154
  /**
154
- * Force cleanup of unused styles
155
- */
156
- forceCleanup(registry: RootRegistry): void;
157
- /**
158
- * Perform bulk cleanup of all unused styles (refCount = 0).
155
+ * Delete the given classes: their rules leave the sheets and every registry
156
+ * entry pointing at them is dropped.
157
+ *
158
+ * Deciding *what* is unused belongs to `StyleInjector.gc()`, which owns the
159
+ * DOM scan and the capacity policy. This only re-checks that each class is
160
+ * still safe to delete, and reports how many were.
161
+ *
162
+ * @returns Number of classes actually deleted.
159
163
  */
160
- private performBulkCleanup;
164
+ deleteClasses(registry: RootRegistry, classNames: Iterable<string>): number;
161
165
  /**
162
166
  * Get total number of rules across all sheets
163
167
  */
164
168
  getTotalRuleCount(registry: RootRegistry): number;
169
+ /**
170
+ * The CSS of one managed sheet, or `null` when it holds none this can read —
171
+ * an empty style element, or a sheet the engine refuses to hand over.
172
+ */
173
+ private readSheetCSS;
165
174
  /**
166
175
  * Get CSS text from all sheets (for SSR)
167
176
  */
@@ -229,6 +238,28 @@ declare class SheetManager {
229
238
  /**
230
239
  * Get the raw CSS content
231
240
  */
241
+ /**
242
+ * The CSS this injector owns in `root`, one entry per sheet, in the order the
243
+ * engine applies them.
244
+ *
245
+ * `getCSSText()` walks the managed sheets only, and raw CSS has its own —
246
+ * which sits before, after, or *between* them depending on how it got there:
247
+ * prepended to `adoptedStyleSheets`, or wherever in `<head>` the first raw
248
+ * injection happened to land, with every managed sheet opened afterwards
249
+ * following it. Reporting a fixed order would describe the opposite winner
250
+ * from the live page whenever two rules of equal specificity meet, so the raw
251
+ * sheet is spliced in at the position the DOM actually gives it.
252
+ */
253
+ getOwnedCSSInOrder(registry: RootRegistry, root: Document | ShadowRoot): string[];
254
+ /**
255
+ * Top-level rules in the raw sheet.
256
+ *
257
+ * Read from the sheet the engine parsed, not from the text: a raw block is
258
+ * one string but any number of rules, and one rule — `@keyframes`, `@media` —
259
+ * can contain any number of blocks, so counting braces answers neither
260
+ * question.
261
+ */
262
+ getRawRuleCount(root: Document | ShadowRoot): number;
232
263
  getRawCSSText(root: Document | ShadowRoot): string;
233
264
  }
234
265
  //#endregion
@@ -237,12 +268,20 @@ declare class StyleInjector {
237
268
  private sheetManager;
238
269
  private config;
239
270
  private globalRuleCounter;
240
- private pendingGCHandle;
271
+ /** Cancels the scheduled sweep, whichever timer scheduled it. */
272
+ private cancelPendingGC;
241
273
  private namePrefix;
242
274
  private classRegex;
243
275
  private rscClassRegex;
276
+ private precompiledRevision;
244
277
  /** @internal — exposed for debug utilities only */
245
278
  get _sheetManager(): SheetManager;
279
+ /**
280
+ * Seed deduplication metadata for rules supplied by an immutable external
281
+ * stylesheet. This records no owned sheet entries and performs no CSS work.
282
+ * @internal
283
+ */
284
+ registerPrecompiledDependencies(dependencies: TastyPrecompiledDependencies, revision: number): void;
246
285
  /**
247
286
  * Whether sheet writes should be queued instead of applied immediately.
248
287
  *
@@ -285,6 +324,17 @@ declare class StyleInjector {
285
324
  * if so, wire the cacheKey mapping. Returns true on hit.
286
325
  */
287
326
  private tryHydratedHit;
327
+ /**
328
+ * Resolve an already-owned or server-hydrated class before its declarations
329
+ * are rendered. A miss does not reserve a class or mutate the rule cache.
330
+ * @internal
331
+ */
332
+ prepareClassName(cacheKey: string, options?: {
333
+ root?: Document | ShadowRoot;
334
+ }): {
335
+ className: string;
336
+ isExisting: boolean;
337
+ };
288
338
  /**
289
339
  * Allocate a className for a cacheKey without injecting styles yet.
290
340
  * This allows separating className allocation (render phase) from style injection (insertion phase).
@@ -298,10 +348,7 @@ declare class StyleInjector {
298
348
  /**
299
349
  * Inject styles from StyleResult objects
300
350
  */
301
- inject(rules: StyleResult[], options?: {
302
- root?: Document | ShadowRoot;
303
- cacheKey?: string;
304
- }): InjectResult;
351
+ inject(rules: StyleResult[], options?: InjectOptions): InjectResult;
305
352
  /**
306
353
  * Inject global styles (rules without a generated tasty class selector)
307
354
  * This ensures we don't reserve a tasty class name (t{number}) for global rules,
@@ -325,20 +372,47 @@ declare class StyleInjector {
325
372
  root?: Document | ShadowRoot;
326
373
  }): string;
327
374
  /**
328
- * Increment refCount for an already-injected cacheKey and return a dispose.
329
- * Used by useStyles on cache hits (hydration or runtime reuse) where
330
- * the pipeline was skipped but refCount tracking is still needed.
331
- * Returns null if the cacheKey is not found.
375
+ * Take a reference on local `@keyframes`, under the deterministic names the
376
+ * caller resolved.
377
+ *
378
+ * One reference per distinct set of steps, shared by every class that ends up
379
+ * animating it, so a repeat render takes nothing further. Ownership is
380
+ * assigned by `ownKeyframes()` once the rules exist to be inspected.
381
+ */
382
+ holdKeyframes(steps: Record<string, KeyframesSteps>, names: Map<string, string>, options?: {
383
+ root?: Document | ShadowRoot;
384
+ }): Map<string, string>;
385
+ /**
386
+ * Record that `className` animates these keyframes, so the reference is
387
+ * released when the last such class is collected.
388
+ *
389
+ * Only classes whose rules actually reference the animation should be here:
390
+ * a class that merely rendered alongside one would otherwise keep the
391
+ * keyframes alive for as long as it lives.
392
+ */
393
+ ownKeyframes(key: string, className: string, options?: {
394
+ root?: Document | ShadowRoot;
395
+ }): void;
396
+ /** Record a chunk lookup served by an immutable external stylesheet. */
397
+ recordPrecompiledHit(className: string, options?: {
398
+ root?: Document | ShadowRoot;
399
+ }): void;
400
+ /**
401
+ * Pin an already-injected cacheKey and return the handle that releases it.
402
+ * For callers that skipped the pipeline on a cache hit but still need the
403
+ * class held. Returns null if the cacheKey is not found.
332
404
  */
333
405
  trackRef(cacheKey: string, options?: {
334
406
  root?: Document | ShadowRoot;
335
407
  }): InjectResult | null;
336
408
  /**
337
- * Dispose of a className (decrements refCount only).
409
+ * Release one pin on a className. At zero pins the class is not deleted — it
410
+ * stays cached and collectible, and `gc()` decides when it actually goes.
338
411
  */
339
- private dispose;
412
+ private unpin;
340
413
  /**
341
- * Force bulk cleanup of unused styles
414
+ * Remove every style that is neither in the DOM nor referenced by an
415
+ * outstanding `inject()` handle, ignoring the GC capacity threshold.
342
416
  */
343
417
  cleanup(root?: Document | ShadowRoot): void;
344
418
  /**
@@ -447,33 +521,82 @@ declare class StyleInjector {
447
521
  keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
448
522
  root?: Document | ShadowRoot;
449
523
  name?: string;
524
+ /**
525
+ * Give this name its own rule even if another name already carries
526
+ * the same steps. Without it two names with identical steps share
527
+ * one rule under whichever name arrived first — fine when the caller
528
+ * only wants the animation, wrong when the name has to be the one it
529
+ * asked for.
530
+ */
531
+ distinctByName?: boolean;
450
532
  }): KeyframesResult;
451
533
  /**
452
534
  * Dispose keyframes
453
535
  */
454
536
  private disposeKeyframes;
455
537
  /**
456
- * Record a render-time usage hit for one or more classNames.
457
- * Handles space-separated multi-chunk classNames.
458
- * When the global touch counter reaches `touchInterval`, schedules a GC
459
- * via `requestIdleCallback`.
460
- * No-op on the server.
538
+ * Count a render, and schedule a collection pass every `touchInterval` of
539
+ * them. Nothing else: what a class is worth keeping is decided by the sweep's
540
+ * own DOM scan, so rendering does not track usage at all.
541
+ *
542
+ * @deprecated The class name is ignored — pass anything, or stop calling it.
543
+ * Collection no longer records per-class usage, and scheduling does not need
544
+ * to know which class was rendered. A class handed back by `inject()` is
545
+ * marked wanted there, which is what reuse actually goes through.
461
546
  */
462
- touch(className: string, options?: {
547
+ touch(_className: string, options?: {
463
548
  root?: Document | ShadowRoot;
464
549
  }): void;
465
550
  /**
466
- * Schedule a GC via `requestIdleCallback` (or synchronously as fallback).
467
- * Runs GC on all active roots. Avoids double-scheduling via `pendingGCHandle`.
551
+ * Schedule a GC in idle time. Runs GC on all active roots, and avoids
552
+ * double-scheduling.
553
+ *
554
+ * Idle only. Without `requestIdleCallback` nothing is collected
555
+ * automatically: running the sweep inline here would put it inside the render
556
+ * that touched the class, and collection is never urgent enough for that.
468
557
  */
469
558
  private scheduleGC;
559
+ /**
560
+ * The one definition of "unused": this injector owns the class's rules, no
561
+ * element in `root` carries it, and nobody pinned it.
562
+ *
563
+ * `gc()` evicts from this set, `getMetrics()` counts it, and `tastyDebug`
564
+ * reports it — all through here, so the three can never disagree about what
565
+ * "unused" means. Entries carry their last `touch()` so callers can drop the
566
+ * oldest first; a class that was never touched sorts as oldest.
567
+ */
568
+ /**
569
+ * Everything the injector holds falls into one of five bands, and only the
570
+ * last of them is ever deleted:
571
+ *
572
+ * 1. rendered — some element carries the class right now
573
+ * 2. not ours — queued for a batched write, pre-allocated, or server-rendered
574
+ * 3. hot — nothing carries it, but that was noticed less than `grace` ago
575
+ * 4. cached — cold, but within `capacity` when ordered by when it went cold
576
+ * 5. the rest
577
+ *
578
+ * This returns bands 4 and 5 together, most recently cold first; `gc()` draws
579
+ * the capacity line through them. Band 3 is what makes collection safe
580
+ * without a commit signal: a render can resolve a class and commit it a
581
+ * little later, and during that gap nothing on the page carries it.
582
+ */
583
+ private collectUnused;
584
+ /**
585
+ * Class names this injector holds CSS for that nothing renders and nobody
586
+ * pinned — exactly what `gc({ force: true })` would delete. Unordered.
587
+ */
588
+ getUnusedClasses(options?: {
589
+ root?: Document | ShadowRoot;
590
+ }): string[];
470
591
  /**
471
592
  * Synchronous garbage collection.
472
593
  *
473
- * 1. Quick upper-bound check: skip if unused count can't exceed capacity.
474
- * 2. Scans the DOM for live tasty classNames (safety guard).
475
- * 3. With `force: true`: deletes all unused entries inline.
476
- * Without `force`: collects unused, sorts oldest-first, evicts over capacity.
594
+ * 1. Quick upper-bound check: skip if the registry is smaller than capacity.
595
+ * 2. Scans the DOM for live tasty classNames — the DOM, not a ref count, is
596
+ * what says a class rendered by a component is still in use.
597
+ * 3. With `force: true`: deletes every unused class.
598
+ * Without `force`: keeps the `capacity` most recently touched and deletes
599
+ * the rest, oldest first.
477
600
  *
478
601
  * @returns Number of styles evicted.
479
602
  */
@@ -500,6 +623,22 @@ type ParseFunction = (groups: StyleDetails[]) => string;
500
623
  type FunctionsConfig = Record<string, FunctionDefinition | ParseFunction>;
501
624
  //#endregion
502
625
  //#region src/utils/color-space.d.ts
626
+ /**
627
+ * Color handling that survives into the emitted CSS.
628
+ *
629
+ * Tasty does not rewrite a color into a particular color space: opacity is
630
+ * applied with CSS relative color syntax, which reads the channels off whatever
631
+ * the browser resolves a value to, so a color is emitted exactly as authored.
632
+ * What is left here is how an alpha gets applied, and the one distinction that
633
+ * matters — replacing a token's alpha versus composing onto an inherited one.
634
+ */
635
+ /**
636
+ * The color space a `#name` token's value used to be rewritten into.
637
+ *
638
+ * @deprecated Kept for the `colorSpace` config option, which no longer has any
639
+ * effect. Colors are emitted as authored and opacity is always applied in
640
+ * `oklch` through relative color syntax.
641
+ */
503
642
  type ColorSpace = 'rgb' | 'hsl' | 'oklch';
504
643
  //#endregion
505
644
  //#region src/utils/typography.d.ts
@@ -617,7 +756,7 @@ interface TastyPlugin {
617
756
  * Design tokens injected as CSS custom properties on `:root`.
618
757
  * Values are parsed through the Tasty DSL. Supports state maps.
619
758
  * - `$name` → `--name` CSS custom property
620
- * - `#name` → `--name-color` and `--name-color-{colorSpace}`
759
+ * - `#name` → `--name-color`
621
760
  */
622
761
  tokens?: ConfigTokens;
623
762
  /** Predefined tokens replaced during style parsing (`$name` or `#name`) */
@@ -733,14 +872,18 @@ interface TastyConfig {
733
872
  */
734
873
  functions?: FunctionsConfig;
735
874
  /**
736
- * Color space used for decomposed color token companion variables.
737
- * Controls the CSS function and suffix for alpha composition.
875
+ * @deprecated No longer has any effect; will be removed in the next major.
876
+ * Setting it warns in development.
738
877
  *
739
- * - `'rgb'` — suffix `-rgb`, e.g. `rgb(var(--name-color-rgb) / .5)`
740
- * - `'hsl'` — suffix `-hsl`, e.g. `hsl(var(--name-color-hsl) / .5)`
741
- * - `'oklch'` — suffix `-oklch`, e.g. `oklch(var(--name-color-oklch) / .5)`
878
+ * A `#name` token's value used to be rewritten into this color space so an
879
+ * opacity suffix had numeric channels to write an alpha into. Opacity now uses
880
+ * relative color syntax — `oklch(from var(--name-color) l c h / .5)` — which
881
+ * has the browser read the channels, so a color is emitted exactly as
882
+ * authored and there is nothing left for the setting to decide.
742
883
  *
743
- * @default 'oklch'
884
+ * To address a token's channels yourself, write relative color syntax against
885
+ * the token: `oklch(from var(--brand-color) calc(l * 1.2) c h)`. It works on
886
+ * every `<color>`, including the ones no conversion could evaluate.
744
887
  */
745
888
  colorSpace?: ColorSpace;
746
889
  /**
@@ -1025,7 +1168,7 @@ interface TastyConfig {
1025
1168
  * for responsive/theme-aware tokens.
1026
1169
  *
1027
1170
  * - `$name` keys become `--name` CSS custom properties
1028
- * - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties
1171
+ * - `#name` keys become `--name-color` properties
1029
1172
  *
1030
1173
  * Tokens are injected once when the first style is rendered.
1031
1174
  *
@@ -1240,4 +1383,4 @@ declare function getNamePrefix(): string;
1240
1383
  declare function resetConfig(): void;
1241
1384
  //#endregion
1242
1385
  export { ParseFunction as C, PropHandlerDefinition as D, PropHandler as E, PropHandlerProps as O, FunctionsConfig as S, SheetManager as T, TastyPluginFactory as _, getGlobalFontFaces as a, generateTypographyTokens as b, getGlobalRecipes as c, hasGlobalRecipes as d, hasStylesGenerated as f, TastyPlugin as g, resetConfig as h, getGlobalCounterStyles as i, getNamePrefix as l, isTestEnvironment as m, configure as n, getGlobalFunctions as o, isConfigLocked as p, getConfig as r, getGlobalKeyframes as s, TastyConfig as t, hasGlobalKeyframes as u, TypographyPreset as v, StyleInjector as w, ColorSpace as x, TypographyTokenValue as y };
1243
- //# sourceMappingURL=config-DH7I0Ggx.d.ts.map
1386
+ //# sourceMappingURL=config-CJKXZDrM.d.ts.map