@tenphi/tasty 0.0.0-snapshot.a8b0eee → 0.0.0-snapshot.a8da86e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -136
- package/dist/babel-types-C_7kRP38.d.ts +18 -0
- package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
- package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
- package/dist/chunks/build-config-Betc6IB6.js +60 -0
- package/dist/chunks/build-config-Betc6IB6.js.map +1 -0
- package/dist/{collector-Crs9kGJW.js → chunks/collector-DqqisglQ.js} +68 -101
- package/dist/chunks/collector-DqqisglQ.js.map +1 -0
- package/dist/chunks/config-engine-BPeROwq2.js +272 -0
- package/dist/chunks/config-engine-BPeROwq2.js.map +1 -0
- package/dist/chunks/css-definitions-IeuyJTGk.js +899 -0
- package/dist/chunks/css-definitions-IeuyJTGk.js.map +1 -0
- package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
- package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
- package/dist/chunks/debug-P1E2jkj7.js +502 -0
- package/dist/chunks/debug-P1E2jkj7.js.map +1 -0
- package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
- package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-XMBbGRes.js +582 -0
- package/dist/chunks/react-runtime-XMBbGRes.js.map +1 -0
- package/dist/chunks/runtime-engine-CsIMtulO.js +2415 -0
- package/dist/chunks/runtime-engine-CsIMtulO.js.map +1 -0
- package/dist/chunks/runtime-state-CyKzDioI.js +141 -0
- package/dist/chunks/runtime-state-CyKzDioI.js.map +1 -0
- package/dist/{merge-styles-BzQutdAK.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-RbokDN6A.js +5427 -0
- package/dist/chunks/style-engine-RbokDN6A.js.map +1 -0
- package/dist/{css-writer-CPy_cbFJ.js → chunks/zero-engine-DbtjMsfo.js} +81 -137
- package/dist/chunks/zero-engine-DbtjMsfo.js.map +1 -0
- package/dist/{collector-osfWTeRd.d.ts → collector-w4mBj5gd.d.ts} +64 -8
- package/dist/{config-BoZDUHW5.d.ts → config-CrZOfNJ5.d.ts} +489 -85
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/{index-B_k47mc_.d.ts → index-CYJtAI9a.d.ts} +664 -399
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -732
- package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +17 -0
- package/dist/ssr/astro-middleware-static.js +7 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +11 -8
- package/dist/ssr/astro-middleware.js +2 -14
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +40 -10
- package/dist/ssr/astro.js +163 -91
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +10 -18
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +134 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -9
- package/dist/ssr/next.js +29 -44
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -9
- package/dist/static/index.js +4 -22
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -2
- package/dist/static/inject.js.map +1 -1
- package/dist/{index-tcHuMPFt.d.ts → types-JEY8PVYP.d.ts} +874 -593
- package/dist/zero/babel.d.ts +5 -19
- package/dist/zero/babel.js +74 -144
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +57 -7
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +0 -31
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +17 -9
- package/docs/adoption.md +56 -31
- package/docs/ai-agents.md +250 -0
- package/docs/comparison.md +69 -40
- package/docs/configuration.md +487 -86
- package/docs/debug.md +26 -14
- package/docs/design-system.md +43 -24
- package/docs/dsl.md +558 -181
- package/docs/getting-started.md +64 -41
- package/docs/injector.md +120 -30
- package/docs/methodology.md +46 -40
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +87 -21
- package/docs/plugins.md +353 -0
- package/docs/react-api.md +151 -42
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +252 -86
- package/docs/styles.md +142 -25
- package/docs/tasty-static.md +174 -106
- package/package.json +127 -35
- package/tasty.config.ts +5 -0
- package/dist/async-storage-B7_o6FKt.js +0 -44
- package/dist/async-storage-B7_o6FKt.js.map +0 -1
- package/dist/collector-Crs9kGJW.js.map +0 -1
- package/dist/config-BaxtQMS3.js +0 -10464
- package/dist/config-BaxtQMS3.js.map +0 -1
- package/dist/context-CkSg-kDT.js +0 -24
- package/dist/context-CkSg-kDT.js.map +0 -1
- package/dist/core-CmxaoZ-N.js +0 -1598
- package/dist/core-CmxaoZ-N.js.map +0 -1
- package/dist/css-writer-CPy_cbFJ.js.map +0 -1
- package/dist/format-global-rules-Dbc_1tc3.js +0 -22
- package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
- package/dist/format-rules-CPirO_Mj.js +0 -143
- package/dist/format-rules-CPirO_Mj.js.map +0 -1
- package/dist/hydrate-CVn-A_3y.js +0 -45
- package/dist/hydrate-CVn-A_3y.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-vpzoVdUR.js +0 -588
- package/dist/keyframes-vpzoVdUR.js.map +0 -1
- package/dist/merge-styles-BzQutdAK.js.map +0 -1
- package/dist/resolve-recipes-DgH8A3Nn.js +0 -144
- package/dist/resolve-recipes-DgH8A3Nn.js.map +0 -1
|
@@ -1,5 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { C as SheetInfo, Et as StyleDetails, M as StyleResult, Ot as UnitHandler, S as RuleInfo, T as StyleRule, W as ConfigTokens, Y as Styles, _ as KeyframesSteps, a as FontFaceInput, b as RawCSSResult, c as GCConfig, d as InjectOptions, f as InjectResult, g as KeyframesResult, h as KeyframesInfo, i as FontFaceDescriptors, l as GCOptions, lt as StyleHandlerDefinition, n as CounterStyleDescriptors, o as FunctionDefinition, q as RecipeStyles, t as CacheMetrics, u as GlobalInjectResult, v as PropertyDefinition, w as StyleInjectorConfig, x as RootRegistry } from "./types-JEY8PVYP.js";
|
|
2
|
+
//#region src/config-resources.d.ts
|
|
3
|
+
declare function getGlobalFontFaces(): Record<string, FontFaceInput> | null;
|
|
4
|
+
declare function getGlobalCounterStyles(): Record<string, CounterStyleDescriptors> | null;
|
|
5
|
+
declare function getGlobalFunctions(): Record<string, FunctionDefinition> | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get global keyframes configuration.
|
|
8
|
+
* Returns null if no keyframes configured (fast path for zero-overhead).
|
|
9
|
+
*/
|
|
10
|
+
declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/prop-handlers.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Props middleware for tasty components.
|
|
15
|
+
*
|
|
16
|
+
* A prop handler receives a component's props and returns them, changed or not.
|
|
17
|
+
* That makes it the extension point for props that are *not* style properties:
|
|
18
|
+
* it can read a custom prop, strip it so it never reaches the DOM, and fold its
|
|
19
|
+
* meaning into `styles`, `mods`, `tokens`, `variant`, or `as`.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* configure({
|
|
23
|
+
* propHandlers: {
|
|
24
|
+
* glaze: (props) => {
|
|
25
|
+
* const { glaze, ...rest } = props;
|
|
26
|
+
* if (!glaze) return rest;
|
|
27
|
+
* return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Handlers run on every render of every tasty component, so the registry is a
|
|
34
|
+
* pre-composed chain that is `null` while nothing is registered — the cost when
|
|
35
|
+
* unused is one property load and one branch.
|
|
36
|
+
*/
|
|
37
|
+
/** Props object handed to a prop handler. Deliberately untyped: handlers see everything. */
|
|
38
|
+
type PropHandlerProps = Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Props middleware: props in, props out. Returning nothing means "unchanged".
|
|
41
|
+
*
|
|
42
|
+
* Must be a **pure function** and must not mutate its input. Style values are
|
|
43
|
+
* cached by object identity, so mutating a value object in place produces a stale
|
|
44
|
+
* class name and stale CSS. Return fresh (ideally frozen, ideally memoized)
|
|
45
|
+
* objects instead.
|
|
46
|
+
*/
|
|
47
|
+
type PropHandler = (props: PropHandlerProps) => PropHandlerProps | void | null;
|
|
48
|
+
/**
|
|
49
|
+
* How a prop handler is declared. The map key is both its name and, by default,
|
|
50
|
+
* the prop that triggers it.
|
|
51
|
+
*
|
|
52
|
+
* - `fn` — triggered when a prop matching the key is present
|
|
53
|
+
* - `['glaze', fn]` — triggered by the named prop
|
|
54
|
+
* - `[['glaze', 'tone'], fn]` — triggered by any of them
|
|
55
|
+
* - `['*', fn]` — unconditional; runs on every render of every component
|
|
56
|
+
*/
|
|
57
|
+
type PropHandlerDefinition = PropHandler | [string, PropHandler] | [string[], PropHandler];
|
|
58
|
+
//#endregion
|
|
3
59
|
//#region src/injector/sheet-manager.d.ts
|
|
4
60
|
declare class SheetManager {
|
|
5
61
|
private rootRegistries;
|
|
@@ -20,6 +76,19 @@ declare class SheetManager {
|
|
|
20
76
|
* abstracting away adopted vs style-element modes.
|
|
21
77
|
*/
|
|
22
78
|
getCSSSheet(sheetInfo: SheetInfo): CSSStyleSheet | null;
|
|
79
|
+
/**
|
|
80
|
+
* Record an inserted rule text at its rule index (text mode only).
|
|
81
|
+
*
|
|
82
|
+
* `textRules` mirrors the sheet's rule order. `textContent` cannot be edited
|
|
83
|
+
* rule-by-rule the way CSSOM can, so keeping the texts is what makes
|
|
84
|
+
* deletion possible at all in this mode.
|
|
85
|
+
*/
|
|
86
|
+
private trackTextRule;
|
|
87
|
+
/**
|
|
88
|
+
* Remove rule indices from a text-mode sheet and rewrite the element's text.
|
|
89
|
+
* Returns the indices that were actually removed.
|
|
90
|
+
*/
|
|
91
|
+
private deleteTextRules;
|
|
23
92
|
/**
|
|
24
93
|
* Determine the injection mode for a root.
|
|
25
94
|
* ShadowRoot uses adopted stylesheets when supported; Document uses <style> elements.
|
|
@@ -45,6 +114,8 @@ declare class SheetManager {
|
|
|
45
114
|
* Create a style element and append to document
|
|
46
115
|
*/
|
|
47
116
|
private createStyleElement;
|
|
117
|
+
/** Append a rule to a text-mode sheet while preserving its index mirror. */
|
|
118
|
+
private appendTextRule;
|
|
48
119
|
/**
|
|
49
120
|
* Insert CSS rules as a single block
|
|
50
121
|
*/
|
|
@@ -91,21 +162,29 @@ declare class SheetManager {
|
|
|
91
162
|
*/
|
|
92
163
|
private engineSupportsAtProperty;
|
|
93
164
|
/**
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
165
|
+
* Delete the given classes: their rules leave the sheets and every registry
|
|
166
|
+
* entry pointing at them is dropped.
|
|
167
|
+
*
|
|
168
|
+
* Deciding *what* is unused belongs to `StyleInjector.gc()`, which owns the
|
|
169
|
+
* DOM scan and the capacity policy. This only re-checks that each class is
|
|
170
|
+
* still safe to delete, and reports how many were.
|
|
171
|
+
*
|
|
172
|
+
* @returns Number of classes actually deleted.
|
|
99
173
|
*/
|
|
100
|
-
|
|
174
|
+
deleteClasses(registry: RootRegistry, classNames: Iterable<string>): number;
|
|
101
175
|
/**
|
|
102
176
|
* Get total number of rules across all sheets
|
|
103
177
|
*/
|
|
104
178
|
getTotalRuleCount(registry: RootRegistry): number;
|
|
179
|
+
/**
|
|
180
|
+
* The CSS of one managed sheet, or `null` when it holds none this can read —
|
|
181
|
+
* an empty style element, or a sheet the engine refuses to hand over.
|
|
182
|
+
*/
|
|
183
|
+
private readSheetCSS;
|
|
105
184
|
/**
|
|
106
185
|
* Get CSS text from all sheets (for SSR)
|
|
107
186
|
*/
|
|
108
|
-
|
|
187
|
+
getCSSText(registry: RootRegistry): string;
|
|
109
188
|
/**
|
|
110
189
|
* Get cache performance metrics
|
|
111
190
|
*/
|
|
@@ -169,6 +248,28 @@ declare class SheetManager {
|
|
|
169
248
|
/**
|
|
170
249
|
* Get the raw CSS content
|
|
171
250
|
*/
|
|
251
|
+
/**
|
|
252
|
+
* The CSS this injector owns in `root`, one entry per sheet, in the order the
|
|
253
|
+
* engine applies them.
|
|
254
|
+
*
|
|
255
|
+
* `getCSSText()` walks the managed sheets only, and raw CSS has its own —
|
|
256
|
+
* which sits before, after, or *between* them depending on how it got there:
|
|
257
|
+
* prepended to `adoptedStyleSheets`, or wherever in `<head>` the first raw
|
|
258
|
+
* injection happened to land, with every managed sheet opened afterwards
|
|
259
|
+
* following it. Reporting a fixed order would describe the opposite winner
|
|
260
|
+
* from the live page whenever two rules of equal specificity meet, so the raw
|
|
261
|
+
* sheet is spliced in at the position the DOM actually gives it.
|
|
262
|
+
*/
|
|
263
|
+
getOwnedCSSInOrder(registry: RootRegistry, root: Document | ShadowRoot): string[];
|
|
264
|
+
/**
|
|
265
|
+
* Top-level rules in the raw sheet.
|
|
266
|
+
*
|
|
267
|
+
* Read from the sheet the engine parsed, not from the text: a raw block is
|
|
268
|
+
* one string but any number of rules, and one rule — `@keyframes`, `@media` —
|
|
269
|
+
* can contain any number of blocks, so counting braces answers neither
|
|
270
|
+
* question.
|
|
271
|
+
*/
|
|
272
|
+
getRawRuleCount(root: Document | ShadowRoot): number;
|
|
172
273
|
getRawCSSText(root: Document | ShadowRoot): string;
|
|
173
274
|
}
|
|
174
275
|
//#endregion
|
|
@@ -177,12 +278,45 @@ declare class StyleInjector {
|
|
|
177
278
|
private sheetManager;
|
|
178
279
|
private config;
|
|
179
280
|
private globalRuleCounter;
|
|
180
|
-
|
|
281
|
+
/** Cancels the scheduled sweep, whichever timer scheduled it. */
|
|
282
|
+
private cancelPendingGC;
|
|
181
283
|
private namePrefix;
|
|
182
284
|
private classRegex;
|
|
183
285
|
private rscClassRegex;
|
|
184
286
|
/** @internal — exposed for debug utilities only */
|
|
185
287
|
get _sheetManager(): SheetManager;
|
|
288
|
+
/** Register inferable custom properties used by a set of declarations. */
|
|
289
|
+
private inferProperties;
|
|
290
|
+
/**
|
|
291
|
+
* Whether sheet writes should be queued instead of applied immediately.
|
|
292
|
+
*
|
|
293
|
+
* Only ever true on the client: SSR collects CSS as text and the RSC path
|
|
294
|
+
* returns it as strings, so neither has a live sheet to batch writes against.
|
|
295
|
+
*
|
|
296
|
+
* In the default `true` mode a write is only queued inside an open batch
|
|
297
|
+
* window — a commit in which `<TastyBatchProvider>` rendered and will
|
|
298
|
+
* therefore flush in its insertion effect, before any layout effect can
|
|
299
|
+
* measure. Everything else falls through to a synchronous write, so enabling
|
|
300
|
+
* the flag cannot make a `useLayoutEffect` read an unstyled element.
|
|
301
|
+
* `'always'` drops the gate and accepts that trade for wider coverage.
|
|
302
|
+
*/
|
|
303
|
+
private get batching();
|
|
304
|
+
/**
|
|
305
|
+
* Apply a sheet write now, or queue it when batching is on.
|
|
306
|
+
* Returns the queue handle when deferred, so the caller can cancel it if it
|
|
307
|
+
* disposes before the flush.
|
|
308
|
+
*/
|
|
309
|
+
private writeSheet;
|
|
310
|
+
/**
|
|
311
|
+
* Insert a global (non-class) rule, honouring batching.
|
|
312
|
+
*
|
|
313
|
+
* `onApplied` records the caller's dedupe bookkeeping. When the write is
|
|
314
|
+
* queued it runs eagerly, so a repeat call before the flush bails out instead
|
|
315
|
+
* of queueing the same rule twice — the same reasoning as
|
|
316
|
+
* `insertPropertyRule`'s eager marking. When written synchronously it runs
|
|
317
|
+
* only on success, preserving the existing retry-on-failure behaviour.
|
|
318
|
+
*/
|
|
319
|
+
private writeGlobalRule;
|
|
186
320
|
constructor(config?: StyleInjectorConfig);
|
|
187
321
|
/**
|
|
188
322
|
* Generate a deterministic class name from a cache key using content hash.
|
|
@@ -208,10 +342,7 @@ declare class StyleInjector {
|
|
|
208
342
|
/**
|
|
209
343
|
* Inject styles from StyleResult objects
|
|
210
344
|
*/
|
|
211
|
-
inject(rules: StyleResult[], options?:
|
|
212
|
-
root?: Document | ShadowRoot;
|
|
213
|
-
cacheKey?: string;
|
|
214
|
-
}): InjectResult;
|
|
345
|
+
inject(rules: StyleResult[], options?: InjectOptions): InjectResult;
|
|
215
346
|
/**
|
|
216
347
|
* Inject global styles (rules without a generated tasty class selector)
|
|
217
348
|
* This ensures we don't reserve a tasty class name (t{number}) for global rules,
|
|
@@ -235,32 +366,55 @@ declare class StyleInjector {
|
|
|
235
366
|
root?: Document | ShadowRoot;
|
|
236
367
|
}): string;
|
|
237
368
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
369
|
+
* Take a reference on local `@keyframes`, under the deterministic names the
|
|
370
|
+
* caller resolved.
|
|
371
|
+
*
|
|
372
|
+
* One reference per distinct set of steps, shared by every class that ends up
|
|
373
|
+
* animating it, so a repeat render takes nothing further. Ownership is
|
|
374
|
+
* assigned by `ownKeyframes()` once the rules exist to be inspected.
|
|
375
|
+
*/
|
|
376
|
+
holdKeyframes(steps: Record<string, KeyframesSteps>, names: Map<string, string>, options?: {
|
|
377
|
+
root?: Document | ShadowRoot;
|
|
378
|
+
}): Map<string, string>;
|
|
379
|
+
/**
|
|
380
|
+
* Record that `className` animates these keyframes, so the reference is
|
|
381
|
+
* released when the last such class is collected.
|
|
382
|
+
*
|
|
383
|
+
* Only classes whose rules actually reference the animation should be here:
|
|
384
|
+
* a class that merely rendered alongside one would otherwise keep the
|
|
385
|
+
* keyframes alive for as long as it lives.
|
|
386
|
+
*/
|
|
387
|
+
ownKeyframes(key: string, className: string, options?: {
|
|
388
|
+
root?: Document | ShadowRoot;
|
|
389
|
+
}): void;
|
|
390
|
+
/**
|
|
391
|
+
* Pin an already-injected cacheKey and return the handle that releases it.
|
|
392
|
+
* For callers that skipped the pipeline on a cache hit but still need the
|
|
393
|
+
* class held. Returns null if the cacheKey is not found.
|
|
242
394
|
*/
|
|
243
395
|
trackRef(cacheKey: string, options?: {
|
|
244
396
|
root?: Document | ShadowRoot;
|
|
245
397
|
}): InjectResult | null;
|
|
246
398
|
/**
|
|
247
|
-
*
|
|
399
|
+
* Release one pin on a className. At zero pins the class is not deleted — it
|
|
400
|
+
* stays cached and collectible, and `gc()` decides when it actually goes.
|
|
248
401
|
*/
|
|
249
|
-
private
|
|
402
|
+
private unpin;
|
|
250
403
|
/**
|
|
251
|
-
*
|
|
404
|
+
* Remove every style that is neither in the DOM nor referenced by an
|
|
405
|
+
* outstanding `inject()` handle, ignoring the GC capacity threshold.
|
|
252
406
|
*/
|
|
253
407
|
cleanup(root?: Document | ShadowRoot): void;
|
|
254
408
|
/**
|
|
255
409
|
* Get CSS text from all sheets (for SSR)
|
|
256
410
|
*/
|
|
257
|
-
|
|
411
|
+
getCSSText(options?: {
|
|
258
412
|
root?: Document | ShadowRoot;
|
|
259
413
|
}): string;
|
|
260
414
|
/**
|
|
261
415
|
* Get CSS only for the provided tasty classNames (e.g., ["t0","t3"])
|
|
262
416
|
*/
|
|
263
|
-
|
|
417
|
+
getCSSTextForClasses(classNames: Iterable<string>, options?: {
|
|
264
418
|
root?: Document | ShadowRoot;
|
|
265
419
|
}): string;
|
|
266
420
|
/**
|
|
@@ -322,11 +476,28 @@ declare class StyleInjector {
|
|
|
322
476
|
/**
|
|
323
477
|
* Inject a CSS @counter-style rule.
|
|
324
478
|
*
|
|
325
|
-
* Permanent and global — no dispose or ref-counting.
|
|
326
|
-
*
|
|
479
|
+
* Permanent and global — no dispose or ref-counting. Deduplicates by name.
|
|
480
|
+
* By default a definition overrides a previously injected one of the same
|
|
481
|
+
* name. Pass `weak: true` for global `configure()` definitions, which must
|
|
482
|
+
* never clobber an existing rule (so component-local definitions win
|
|
483
|
+
* regardless of injection order).
|
|
327
484
|
*/
|
|
328
485
|
counterStyle(name: string, descriptors: CounterStyleDescriptors, options?: {
|
|
329
486
|
root?: Document | ShadowRoot;
|
|
487
|
+
weak?: boolean;
|
|
488
|
+
}): void;
|
|
489
|
+
/**
|
|
490
|
+
* Inject a CSS @function rule (custom function).
|
|
491
|
+
*
|
|
492
|
+
* Permanent and global — no dispose or ref-counting. Deduplicates by function
|
|
493
|
+
* name. By default a definition overrides a previously injected one of the
|
|
494
|
+
* same name. Pass `weak: true` for global `configure()` definitions, which
|
|
495
|
+
* must never clobber an existing rule (so component-local definitions win
|
|
496
|
+
* regardless of injection order).
|
|
497
|
+
*/
|
|
498
|
+
func(name: string, definition: FunctionDefinition, options?: {
|
|
499
|
+
root?: Document | ShadowRoot;
|
|
500
|
+
weak?: boolean;
|
|
330
501
|
}): void;
|
|
331
502
|
/**
|
|
332
503
|
* Inject keyframes and return object with toString() and dispose()
|
|
@@ -340,33 +511,82 @@ declare class StyleInjector {
|
|
|
340
511
|
keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
|
|
341
512
|
root?: Document | ShadowRoot;
|
|
342
513
|
name?: string;
|
|
514
|
+
/**
|
|
515
|
+
* Give this name its own rule even if another name already carries
|
|
516
|
+
* the same steps. Without it two names with identical steps share
|
|
517
|
+
* one rule under whichever name arrived first — fine when the caller
|
|
518
|
+
* only wants the animation, wrong when the name has to be the one it
|
|
519
|
+
* asked for.
|
|
520
|
+
*/
|
|
521
|
+
distinctByName?: boolean;
|
|
343
522
|
}): KeyframesResult;
|
|
344
523
|
/**
|
|
345
524
|
* Dispose keyframes
|
|
346
525
|
*/
|
|
347
526
|
private disposeKeyframes;
|
|
348
527
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
528
|
+
* Count a render, and schedule a collection pass every `touchInterval` of
|
|
529
|
+
* them. Nothing else: what a class is worth keeping is decided by the sweep's
|
|
530
|
+
* own DOM scan, so rendering does not track usage at all.
|
|
531
|
+
*
|
|
532
|
+
* @deprecated The class name is ignored — pass anything, or stop calling it.
|
|
533
|
+
* Collection no longer records per-class usage, and scheduling does not need
|
|
534
|
+
* to know which class was rendered. A class handed back by `inject()` is
|
|
535
|
+
* marked wanted there, which is what reuse actually goes through.
|
|
354
536
|
*/
|
|
355
|
-
touch(
|
|
537
|
+
touch(_className: string, options?: {
|
|
356
538
|
root?: Document | ShadowRoot;
|
|
357
539
|
}): void;
|
|
358
540
|
/**
|
|
359
|
-
* Schedule a GC
|
|
360
|
-
*
|
|
541
|
+
* Schedule a GC in idle time. Runs GC on all active roots, and avoids
|
|
542
|
+
* double-scheduling.
|
|
543
|
+
*
|
|
544
|
+
* Idle only. Without `requestIdleCallback` nothing is collected
|
|
545
|
+
* automatically: running the sweep inline here would put it inside the render
|
|
546
|
+
* that touched the class, and collection is never urgent enough for that.
|
|
361
547
|
*/
|
|
362
548
|
private scheduleGC;
|
|
549
|
+
/**
|
|
550
|
+
* The one definition of "unused": this injector owns the class's rules, no
|
|
551
|
+
* element in `root` carries it, and nobody pinned it.
|
|
552
|
+
*
|
|
553
|
+
* `gc()` evicts from this set, `getMetrics()` counts it, and `tastyDebug`
|
|
554
|
+
* reports it — all through here, so the three can never disagree about what
|
|
555
|
+
* "unused" means. Entries carry their last `touch()` so callers can drop the
|
|
556
|
+
* oldest first; a class that was never touched sorts as oldest.
|
|
557
|
+
*/
|
|
558
|
+
/**
|
|
559
|
+
* Everything the injector holds falls into one of five bands, and only the
|
|
560
|
+
* last of them is ever deleted:
|
|
561
|
+
*
|
|
562
|
+
* 1. rendered — some element carries the class right now
|
|
563
|
+
* 2. not ours — queued for a batched write, pre-allocated, or server-rendered
|
|
564
|
+
* 3. hot — nothing carries it, but that was noticed less than `grace` ago
|
|
565
|
+
* 4. cached — cold, but within `capacity` when ordered by when it went cold
|
|
566
|
+
* 5. the rest
|
|
567
|
+
*
|
|
568
|
+
* This returns bands 4 and 5 together, most recently cold first; `gc()` draws
|
|
569
|
+
* the capacity line through them. Band 3 is what makes collection safe
|
|
570
|
+
* without a commit signal: a render can resolve a class and commit it a
|
|
571
|
+
* little later, and during that gap nothing on the page carries it.
|
|
572
|
+
*/
|
|
573
|
+
private collectUnused;
|
|
574
|
+
/**
|
|
575
|
+
* Class names this injector holds CSS for that nothing renders and nobody
|
|
576
|
+
* pinned — exactly what `gc({ force: true })` would delete. Unordered.
|
|
577
|
+
*/
|
|
578
|
+
getUnusedClasses(options?: {
|
|
579
|
+
root?: Document | ShadowRoot;
|
|
580
|
+
}): string[];
|
|
363
581
|
/**
|
|
364
582
|
* Synchronous garbage collection.
|
|
365
583
|
*
|
|
366
|
-
* 1. Quick upper-bound check: skip if
|
|
367
|
-
* 2. Scans the DOM for live tasty classNames
|
|
368
|
-
*
|
|
369
|
-
*
|
|
584
|
+
* 1. Quick upper-bound check: skip if the registry is smaller than capacity.
|
|
585
|
+
* 2. Scans the DOM for live tasty classNames — the DOM, not a ref count, is
|
|
586
|
+
* what says a class rendered by a component is still in use.
|
|
587
|
+
* 3. With `force: true`: deletes every unused class.
|
|
588
|
+
* Without `force`: keeps the `capacity` most recently touched and deletes
|
|
589
|
+
* the rest, oldest first.
|
|
370
590
|
*
|
|
371
591
|
* @returns Number of styles evicted.
|
|
372
592
|
*/
|
|
@@ -377,7 +597,38 @@ declare class StyleInjector {
|
|
|
377
597
|
destroy(root?: Document | ShadowRoot): void;
|
|
378
598
|
}
|
|
379
599
|
//#endregion
|
|
600
|
+
//#region src/functions/index.d.ts
|
|
601
|
+
/**
|
|
602
|
+
* A parse-time function: receives the parsed (comma-separated) argument groups
|
|
603
|
+
* and returns a CSS value string. This is the JS flavor of the unified
|
|
604
|
+
* `functions` config (bare-name keys), distinct from declarative `@function`
|
|
605
|
+
* definitions (`$$`-prefixed keys).
|
|
606
|
+
*/
|
|
607
|
+
type ParseFunction = (groups: StyleDetails[]) => string;
|
|
608
|
+
/**
|
|
609
|
+
* The unified `functions` map: keys are either bare names (parse functions,
|
|
610
|
+
* value is a function) or `$$name`/`$name`/`--name` (declarative CSS functions,
|
|
611
|
+
* value is a {@link FunctionDefinition} object).
|
|
612
|
+
*/
|
|
613
|
+
type FunctionsConfig = Record<string, FunctionDefinition | ParseFunction>;
|
|
614
|
+
//#endregion
|
|
380
615
|
//#region src/utils/color-space.d.ts
|
|
616
|
+
/**
|
|
617
|
+
* Color handling that survives into the emitted CSS.
|
|
618
|
+
*
|
|
619
|
+
* Tasty does not rewrite a color into a particular color space: opacity is
|
|
620
|
+
* applied with CSS relative color syntax, which reads the channels off whatever
|
|
621
|
+
* the browser resolves a value to, so a color is emitted exactly as authored.
|
|
622
|
+
* What is left here is how an alpha gets applied, and the one distinction that
|
|
623
|
+
* matters — replacing a token's alpha versus composing onto an inherited one.
|
|
624
|
+
*/
|
|
625
|
+
/**
|
|
626
|
+
* The color space a `#name` token's value used to be rewritten into.
|
|
627
|
+
*
|
|
628
|
+
* @deprecated Kept for the `colorSpace` config option, which no longer has any
|
|
629
|
+
* effect. Colors are emitted as authored and opacity is always applied in
|
|
630
|
+
* `oklch` through relative color syntax.
|
|
631
|
+
*/
|
|
381
632
|
type ColorSpace = 'rgb' | 'hsl' | 'oklch';
|
|
382
633
|
//#endregion
|
|
383
634
|
//#region src/utils/typography.d.ts
|
|
@@ -441,8 +692,12 @@ declare function generateTypographyTokens(presets: Record<string, TypographyPres
|
|
|
441
692
|
interface TastyPlugin {
|
|
442
693
|
/** Unique name for the plugin (used for debugging and conflict detection) */
|
|
443
694
|
name: string;
|
|
444
|
-
/**
|
|
445
|
-
|
|
695
|
+
/**
|
|
696
|
+
* Custom functions (unified map). Bare keys map to parse functions
|
|
697
|
+
* `(groups) => string`; `$$name` keys map to declarative CSS `@function`
|
|
698
|
+
* definitions. See {@link FunctionsConfig}.
|
|
699
|
+
*/
|
|
700
|
+
functions?: FunctionsConfig;
|
|
446
701
|
/** Custom units that transform numeric values (e.g., `2x` → `calc(2 * var(--gap))`) */
|
|
447
702
|
units?: Record<string, string | UnitHandler>;
|
|
448
703
|
/** Custom state aliases (e.g., `'@mobile': '@media(w < 768px)'`) */
|
|
@@ -461,11 +716,37 @@ interface TastyPlugin {
|
|
|
461
716
|
* ```
|
|
462
717
|
*/
|
|
463
718
|
handlers?: Record<string, StyleHandlerDefinition>;
|
|
719
|
+
/**
|
|
720
|
+
* Props middleware for every tasty component — props in, props out. The
|
|
721
|
+
* extension point for props that are not style properties: read a custom prop,
|
|
722
|
+
* strip it so it never reaches the DOM, and fold its meaning into `styles`,
|
|
723
|
+
* `mods`, `tokens`, `variant`, or `as`.
|
|
724
|
+
*
|
|
725
|
+
* Must be pure and must not mutate its input.
|
|
726
|
+
* See {@link TastyConfig.propHandlers}.
|
|
727
|
+
* @example
|
|
728
|
+
* ```ts
|
|
729
|
+
* propHandlers: {
|
|
730
|
+
* glaze: (props) => {
|
|
731
|
+
* const { glaze, ...rest } = props;
|
|
732
|
+
* if (!glaze) return rest;
|
|
733
|
+
* return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
|
|
734
|
+
* },
|
|
735
|
+
* }
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
propHandlers?: Record<string, PropHandlerDefinition>;
|
|
739
|
+
/**
|
|
740
|
+
* Style properties exposed as top-level props on every tasty component, in
|
|
741
|
+
* addition to the built-in base styles.
|
|
742
|
+
* See {@link TastyConfig.baseStyleProps}.
|
|
743
|
+
*/
|
|
744
|
+
baseStyleProps?: readonly string[];
|
|
464
745
|
/**
|
|
465
746
|
* Design tokens injected as CSS custom properties on `:root`.
|
|
466
747
|
* Values are parsed through the Tasty DSL. Supports state maps.
|
|
467
748
|
* - `$name` → `--name` CSS custom property
|
|
468
|
-
* - `#name` → `--name-color`
|
|
749
|
+
* - `#name` → `--name-color`
|
|
469
750
|
*/
|
|
470
751
|
tokens?: ConfigTokens;
|
|
471
752
|
/** Predefined tokens replaced during style parsing (`$name` or `#name`) */
|
|
@@ -492,6 +773,19 @@ interface TastyPlugin {
|
|
|
492
773
|
* Supports the full Tasty style syntax.
|
|
493
774
|
*/
|
|
494
775
|
globalStyles?: Record<string, Styles>;
|
|
776
|
+
/**
|
|
777
|
+
* Global CSS `@property` definitions. A plugin whose handler or prop handler
|
|
778
|
+
* emits a custom property usually wants one, so the property animates and
|
|
779
|
+
* inherits correctly instead of being treated as an untyped string.
|
|
780
|
+
* See {@link TastyConfig.properties}.
|
|
781
|
+
*/
|
|
782
|
+
properties?: Record<string, PropertyDefinition>;
|
|
783
|
+
/** Global keyframes, injected only when referenced. See {@link TastyConfig.keyframes}. */
|
|
784
|
+
keyframes?: Record<string, KeyframesSteps>;
|
|
785
|
+
/** Global `@font-face` definitions. See {@link TastyConfig.fontFaces}. */
|
|
786
|
+
fontFaces?: Record<string, FontFaceInput>;
|
|
787
|
+
/** Global `@counter-style` definitions. See {@link TastyConfig.counterStyles}. */
|
|
788
|
+
counterStyles?: Record<string, CounterStyleDescriptors>;
|
|
495
789
|
}
|
|
496
790
|
/**
|
|
497
791
|
* A factory function that creates a TastyPlugin.
|
|
@@ -502,13 +796,13 @@ interface TastyPlugin {
|
|
|
502
796
|
* // Plugin without options
|
|
503
797
|
* const okhslPlugin: TastyPluginFactory = () => ({
|
|
504
798
|
* name: 'okhsl',
|
|
505
|
-
*
|
|
799
|
+
* functions: { okhsl: okhslFunction },
|
|
506
800
|
* });
|
|
507
801
|
*
|
|
508
802
|
* // Plugin with options
|
|
509
803
|
* const debugPlugin: TastyPluginFactory<{ verbose: boolean }> = (options) => ({
|
|
510
804
|
* name: 'debug',
|
|
511
|
-
*
|
|
805
|
+
* functions: { debug: createDebugFunc(options.verbose) },
|
|
512
806
|
* });
|
|
513
807
|
* ```
|
|
514
808
|
*/
|
|
@@ -545,30 +839,92 @@ interface TastyConfig {
|
|
|
545
839
|
*/
|
|
546
840
|
units?: Record<string, string | UnitHandler>;
|
|
547
841
|
/**
|
|
548
|
-
* Custom functions
|
|
549
|
-
*
|
|
550
|
-
*
|
|
842
|
+
* Custom functions (merged with existing). A single map holds both flavors,
|
|
843
|
+
* discriminated by value type:
|
|
844
|
+
*
|
|
845
|
+
* - **Bare key + function value** — a parse-time function that processes the
|
|
846
|
+
* parsed argument groups and returns a CSS value. Called as `name(...)`.
|
|
847
|
+
* - **`$$name` key + object value** — a declarative CSS `@function`
|
|
848
|
+
* definition. Called as `$$name(...)` (→ native `--name(...)`).
|
|
849
|
+
*
|
|
850
|
+
* A key whose prefix does not match its value type (object under a bare key,
|
|
851
|
+
* or function under a `$$` key) is ignored with a dev warning.
|
|
852
|
+
*
|
|
853
|
+
* @example
|
|
854
|
+
* ```ts
|
|
855
|
+
* configure({
|
|
856
|
+
* functions: {
|
|
857
|
+
* double: (groups) => `calc(2 * ${groups[0].output})`, // parse function
|
|
858
|
+
* $$negative: { args: ['$value'], result: '(-1 * $value)' }, // CSS function
|
|
859
|
+
* },
|
|
860
|
+
* });
|
|
861
|
+
* ```
|
|
551
862
|
*/
|
|
552
|
-
|
|
863
|
+
functions?: FunctionsConfig;
|
|
553
864
|
/**
|
|
554
|
-
*
|
|
555
|
-
*
|
|
865
|
+
* @deprecated No longer has any effect; will be removed in the next major.
|
|
866
|
+
* Setting it warns in development.
|
|
556
867
|
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
868
|
+
* A `#name` token's value used to be rewritten into this color space so an
|
|
869
|
+
* opacity suffix had numeric channels to write an alpha into. Opacity now uses
|
|
870
|
+
* relative color syntax — `oklch(from var(--name-color) l c h / .5)` — which
|
|
871
|
+
* has the browser read the channels, so a color is emitted exactly as
|
|
872
|
+
* authored and there is nothing left for the setting to decide.
|
|
560
873
|
*
|
|
561
|
-
*
|
|
874
|
+
* To address a token's channels yourself, write relative color syntax against
|
|
875
|
+
* the token: `oklch(from var(--brand-color) calc(l * 1.2) c h)`. It works on
|
|
876
|
+
* every `<color>`, including the ones no conversion could evaluate.
|
|
562
877
|
*/
|
|
563
878
|
colorSpace?: ColorSpace;
|
|
564
879
|
/**
|
|
565
880
|
* Automatically infer and register CSS @property declarations
|
|
566
881
|
* from custom property values found in styles, keyframes, and global config.
|
|
567
882
|
* Covers all types: \<color\>, \<number\>, \<length\>, \<angle\>, \<percentage\>, \<time\>.
|
|
568
|
-
* When false, only explicitly declared @
|
|
883
|
+
* When false, only explicitly declared @property are registered.
|
|
569
884
|
* @default true
|
|
570
885
|
*/
|
|
571
886
|
autoPropertyTypes?: boolean;
|
|
887
|
+
/**
|
|
888
|
+
* Defer stylesheet writes and apply them in one batch instead of performing
|
|
889
|
+
* one `insertRule()` per component during render.
|
|
890
|
+
*
|
|
891
|
+
* Each `insertRule()` on a live sheet invalidates style for that sheet's
|
|
892
|
+
* scope. When components inject during React's render phase while other
|
|
893
|
+
* components read layout in the same pass, the two interleave and the browser
|
|
894
|
+
* is forced to recalculate style between every injection. Batching collapses
|
|
895
|
+
* that into one invalidation per flush.
|
|
896
|
+
*
|
|
897
|
+
* - `false` (default) — inject synchronously, one write per component.
|
|
898
|
+
* - `true` — batch, but only inside a *batch window*: a commit in which
|
|
899
|
+
* `<TastyBatchProvider>` rendered and will therefore flush in its
|
|
900
|
+
* `useInsertionEffect`, before any `useLayoutEffect` runs. Any injection
|
|
901
|
+
* outside a window — a deep update the provider did not re-render for, an
|
|
902
|
+
* injection from a layout effect, an event handler, an async callback — is
|
|
903
|
+
* written straight through. Enabling this can never make a layout effect
|
|
904
|
+
* measure an unstyled element. Requires `<TastyBatchProvider>`; without it
|
|
905
|
+
* nothing is batched (and dev mode says so once).
|
|
906
|
+
* - `'always'` — batch every injection, flushing on a microtask when no
|
|
907
|
+
* window is open. Wins on more commits, but a `useLayoutEffect` that
|
|
908
|
+
* measures a freshly mounted element can read its unstyled box, because
|
|
909
|
+
* microtasks run after the layout phase. Paint is unaffected: microtasks
|
|
910
|
+
* always drain before the browser paints.
|
|
911
|
+
*
|
|
912
|
+
* No effect during SSR or RSC: styles are collected as text there, the
|
|
913
|
+
* runtime injector never runs, and the provider is inert without a
|
|
914
|
+
* `document`. No effect on zero-runtime `tastyStatic` styles either — those
|
|
915
|
+
* are extracted at build time and never reach the injector.
|
|
916
|
+
*
|
|
917
|
+
* @default false
|
|
918
|
+
* @example
|
|
919
|
+
* ```tsx
|
|
920
|
+
* configure({ batchInjection: true });
|
|
921
|
+
*
|
|
922
|
+
* <TastyBatchProvider>
|
|
923
|
+
* <App />
|
|
924
|
+
* </TastyBatchProvider>
|
|
925
|
+
* ```
|
|
926
|
+
*/
|
|
927
|
+
batchInjection?: boolean | 'always';
|
|
572
928
|
/**
|
|
573
929
|
* Garbage collection configuration for unused styles.
|
|
574
930
|
* GC is triggered by touch count: every `touchInterval` touches, the
|
|
@@ -597,7 +953,7 @@ interface TastyConfig {
|
|
|
597
953
|
* `'ts'` (overridable via the same option) so its classes can't
|
|
598
954
|
* collide with runtime classes when both are loaded on the same page.
|
|
599
955
|
*
|
|
600
|
-
* Must match `^[a-zA-
|
|
956
|
+
* Must match `^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$`. Locked once styles
|
|
601
957
|
* have been generated.
|
|
602
958
|
*
|
|
603
959
|
* @default 't'
|
|
@@ -659,7 +1015,7 @@ interface TastyConfig {
|
|
|
659
1015
|
* const Spinner = tasty({
|
|
660
1016
|
* styles: {
|
|
661
1017
|
* transform: 'rotate($rotation)',
|
|
662
|
-
* transition: '$$rotation
|
|
1018
|
+
* transition: '$$rotation $transition', // outputs: --rotation var(--transition)
|
|
663
1019
|
* },
|
|
664
1020
|
* });
|
|
665
1021
|
* ```
|
|
@@ -673,7 +1029,7 @@ interface TastyConfig {
|
|
|
673
1029
|
* @example
|
|
674
1030
|
* ```ts
|
|
675
1031
|
* configure({
|
|
676
|
-
*
|
|
1032
|
+
* fontFaces: {
|
|
677
1033
|
* 'Brand Sans': [
|
|
678
1034
|
* { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
|
|
679
1035
|
* { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
|
|
@@ -683,7 +1039,7 @@ interface TastyConfig {
|
|
|
683
1039
|
* });
|
|
684
1040
|
* ```
|
|
685
1041
|
*/
|
|
686
|
-
|
|
1042
|
+
fontFaces?: Record<string, FontFaceInput>;
|
|
687
1043
|
/**
|
|
688
1044
|
* Global @counter-style definitions.
|
|
689
1045
|
* Keys are counter-style names, values are descriptor objects.
|
|
@@ -691,13 +1047,32 @@ interface TastyConfig {
|
|
|
691
1047
|
* @example
|
|
692
1048
|
* ```ts
|
|
693
1049
|
* configure({
|
|
694
|
-
*
|
|
1050
|
+
* counterStyles: {
|
|
695
1051
|
* thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' },
|
|
696
1052
|
* },
|
|
697
1053
|
* });
|
|
698
1054
|
* ```
|
|
699
1055
|
*/
|
|
700
|
-
|
|
1056
|
+
counterStyles?: Record<string, CounterStyleDescriptors>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Opt-in polyfills for not-yet-baseline CSS features. Each key toggles a
|
|
1059
|
+
* feature polyfill; all default to `false`.
|
|
1060
|
+
*
|
|
1061
|
+
* - `functions` — polyfill CSS `@function` by inlining every `$$name(...)`
|
|
1062
|
+
* call into plain CSS (calc/var/color-mix) at parse time instead of
|
|
1063
|
+
* emitting the native `@function` at-rule. Enables `@function` usage in
|
|
1064
|
+
* browsers that don't support it yet (Firefox/Safari). Note this is the
|
|
1065
|
+
* `functions` *feature toggle*, distinct from the top-level `functions`
|
|
1066
|
+
* definitions map.
|
|
1067
|
+
*
|
|
1068
|
+
* @example
|
|
1069
|
+
* ```ts
|
|
1070
|
+
* configure({ polyfills: { functions: true } });
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
1073
|
+
polyfills?: {
|
|
1074
|
+
functions?: boolean;
|
|
1075
|
+
};
|
|
701
1076
|
/**
|
|
702
1077
|
* Custom style handlers that transform style properties into CSS declarations.
|
|
703
1078
|
* Handlers replace built-in handlers for the same style name.
|
|
@@ -727,13 +1102,63 @@ interface TastyConfig {
|
|
|
727
1102
|
* ```
|
|
728
1103
|
*/
|
|
729
1104
|
handlers?: Record<string, StyleHandlerDefinition>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Props middleware for every tasty component. A prop handler receives the
|
|
1107
|
+
* component's props and returns them, changed or not — the extension point for
|
|
1108
|
+
* props that are not style properties.
|
|
1109
|
+
*
|
|
1110
|
+
* The map key is the handler's name and, by default, the prop that triggers it.
|
|
1111
|
+
* Use `['*', fn]` for an unconditional handler, or `[['a', 'b'], fn]` to trigger
|
|
1112
|
+
* on any of several props.
|
|
1113
|
+
*
|
|
1114
|
+
* Handlers must be pure and must not mutate their input: style values are cached
|
|
1115
|
+
* by object identity, so mutating one in place yields stale CSS. Memoize the
|
|
1116
|
+
* styles you build per input value.
|
|
1117
|
+
*
|
|
1118
|
+
* Not applicable to zero-runtime mode — `tastyStatic()` takes styles objects, not
|
|
1119
|
+
* props, so there is nothing for middleware to run on. Components rendered
|
|
1120
|
+
* through `tasty()` are unaffected and keep the runtime injector.
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```ts
|
|
1124
|
+
* configure({
|
|
1125
|
+
* propHandlers: {
|
|
1126
|
+
* glaze: (props) => {
|
|
1127
|
+
* const { glaze, ...rest } = props;
|
|
1128
|
+
* if (!glaze) return rest;
|
|
1129
|
+
* return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
|
|
1130
|
+
* },
|
|
1131
|
+
* },
|
|
1132
|
+
* });
|
|
1133
|
+
*
|
|
1134
|
+
* <Element glaze="purple" />
|
|
1135
|
+
* ```
|
|
1136
|
+
*/
|
|
1137
|
+
propHandlers?: Record<string, PropHandlerDefinition>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Style properties exposed as top-level props on **every** tasty component, in
|
|
1140
|
+
* addition to the built-in base styles, without each component listing them in
|
|
1141
|
+
* `styleProps`.
|
|
1142
|
+
*
|
|
1143
|
+
* Augment `TastyBaseStylePropNames` to type them. Each name costs one property
|
|
1144
|
+
* check per render of every component, so keep the list short; the effect is
|
|
1145
|
+
* app-global and cannot be scoped to a subtree.
|
|
1146
|
+
*
|
|
1147
|
+
* @example
|
|
1148
|
+
* ```ts
|
|
1149
|
+
* configure({ baseStyleProps: ['radius', 'shadow'] });
|
|
1150
|
+
*
|
|
1151
|
+
* <Card radius="1r" shadow />
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
baseStyleProps?: readonly string[];
|
|
730
1155
|
/**
|
|
731
1156
|
* Design tokens injected as CSS custom properties on `:root`.
|
|
732
1157
|
* Values are parsed through the Tasty DSL. Supports state maps
|
|
733
1158
|
* for responsive/theme-aware tokens.
|
|
734
1159
|
*
|
|
735
1160
|
* - `$name` keys become `--name` CSS custom properties
|
|
736
|
-
* - `#name` keys become `--name-color`
|
|
1161
|
+
* - `#name` keys become `--name-color` properties
|
|
737
1162
|
*
|
|
738
1163
|
* Tokens are injected once when the first style is rendered.
|
|
739
1164
|
*
|
|
@@ -782,7 +1207,7 @@ interface TastyConfig {
|
|
|
782
1207
|
/**
|
|
783
1208
|
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
784
1209
|
* Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
|
|
785
|
-
* tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@
|
|
1210
|
+
* tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@property`.
|
|
786
1211
|
*
|
|
787
1212
|
* Components reference recipes via: `recipe: 'name1 name2'` in their styles.
|
|
788
1213
|
* Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
|
|
@@ -859,32 +1284,11 @@ declare global {
|
|
|
859
1284
|
* Detect if we're running in a test environment
|
|
860
1285
|
*/
|
|
861
1286
|
declare function isTestEnvironment(): boolean;
|
|
862
|
-
/**
|
|
863
|
-
* Check if styles have been generated (configuration is locked)
|
|
864
|
-
*/
|
|
865
|
-
declare function hasStylesGenerated(): boolean;
|
|
866
1287
|
/**
|
|
867
1288
|
* Check if any global keyframes are configured.
|
|
868
|
-
*
|
|
1289
|
+
* Storage only ever holds a non-empty record, so no Object.keys() is needed.
|
|
869
1290
|
*/
|
|
870
1291
|
declare function hasGlobalKeyframes(): boolean;
|
|
871
|
-
/**
|
|
872
|
-
* Get global keyframes configuration.
|
|
873
|
-
* Returns null if no keyframes configured (fast path for zero-overhead).
|
|
874
|
-
*/
|
|
875
|
-
declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
|
|
876
|
-
/**
|
|
877
|
-
* Get global font-face configuration.
|
|
878
|
-
* Returns null if no font faces configured.
|
|
879
|
-
* Reads from globalThis first for cross-module SSR support.
|
|
880
|
-
*/
|
|
881
|
-
declare function getGlobalFontFace(): Record<string, FontFaceInput> | null;
|
|
882
|
-
/**
|
|
883
|
-
* Get global counter-style configuration.
|
|
884
|
-
* Returns null if no counter styles configured.
|
|
885
|
-
* Reads from globalThis first for cross-module SSR support.
|
|
886
|
-
*/
|
|
887
|
-
declare function getGlobalCounterStyle(): Record<string, CounterStyleDescriptors> | null;
|
|
888
1292
|
/**
|
|
889
1293
|
* Check if any global recipes are configured.
|
|
890
1294
|
* Fast path: returns false if no recipes were ever set.
|
|
@@ -941,5 +1345,5 @@ declare function getNamePrefix(): string;
|
|
|
941
1345
|
*/
|
|
942
1346
|
declare function resetConfig(): void;
|
|
943
1347
|
//#endregion
|
|
944
|
-
export {
|
|
945
|
-
//# sourceMappingURL=config-
|
|
1348
|
+
export { PropHandlerProps as C, getGlobalKeyframes as D, getGlobalFunctions as E, PropHandlerDefinition as S, getGlobalFontFaces as T, FunctionsConfig as _, getNamePrefix as a, SheetManager as b, isConfigLocked as c, TastyPlugin as d, TastyPluginFactory as f, ColorSpace as g, generateTypographyTokens as h, getGlobalRecipes as i, isTestEnvironment as l, TypographyTokenValue as m, configure as n, hasGlobalKeyframes as o, TypographyPreset as p, getConfig as r, hasGlobalRecipes as s, TastyConfig as t, resetConfig as u, ParseFunction as v, getGlobalCounterStyles as w, PropHandler as x, StyleInjector as y };
|
|
1349
|
+
//# sourceMappingURL=config-CrZOfNJ5.d.ts.map
|