@tenphi/tasty 0.0.0-snapshot.4edfcbd → 0.0.0-snapshot.4fb5b7d
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 +440 -372
- package/dist/babel-types-BOABQvEI.d.ts +16 -0
- package/dist/chunks/async-storage-CzSKAyrI.js +36 -0
- package/dist/chunks/async-storage-CzSKAyrI.js.map +1 -0
- package/dist/chunks/build-config-CKiw8Irz.js +59 -0
- package/dist/chunks/build-config-CKiw8Irz.js.map +1 -0
- package/dist/{collector-C-keQH9m.js → chunks/collector-EKAsDdmQ.js} +69 -103
- package/dist/chunks/collector-EKAsDdmQ.js.map +1 -0
- package/dist/chunks/config-engine-Br1Z5kEh.js +269 -0
- package/dist/chunks/config-engine-Br1Z5kEh.js.map +1 -0
- package/dist/chunks/config-file-BX3F_61U.js +24 -0
- package/dist/chunks/config-file-BX3F_61U.js.map +1 -0
- package/dist/chunks/css-definitions-CuohiBRl.js +896 -0
- package/dist/chunks/css-definitions-CuohiBRl.js.map +1 -0
- package/dist/chunks/css-resources-C0zT36nQ.js +141 -0
- package/dist/chunks/css-resources-C0zT36nQ.js.map +1 -0
- package/dist/chunks/debug-I3LGrxPm.js +501 -0
- package/dist/chunks/debug-I3LGrxPm.js.map +1 -0
- package/dist/chunks/dsl-BAwiOznp.js +1442 -0
- package/dist/chunks/dsl-BAwiOznp.js.map +1 -0
- package/dist/chunks/hydration-DEmoq1sQ.js +39 -0
- package/dist/chunks/hydration-DEmoq1sQ.js.map +1 -0
- package/dist/chunks/react-runtime-CrZHuNgA.js +678 -0
- package/dist/chunks/react-runtime-CrZHuNgA.js.map +1 -0
- package/dist/chunks/runtime-engine-BUiX_aR8.js +2418 -0
- package/dist/chunks/runtime-engine-BUiX_aR8.js.map +1 -0
- package/dist/chunks/runtime-state-BqEnurQk.js +150 -0
- package/dist/chunks/runtime-state-BqEnurQk.js.map +1 -0
- package/dist/{merge-styles-Cd2vBl9b.js → chunks/shared-utils-CYgOs2mp.js} +58 -57
- package/dist/chunks/shared-utils-CYgOs2mp.js.map +1 -0
- package/dist/chunks/style-engine-D8FKtEaC.js +5549 -0
- package/dist/chunks/style-engine-D8FKtEaC.js.map +1 -0
- package/dist/{css-writer-BWvwQzz0.js → chunks/zero-engine-C17ezpgd.js} +97 -140
- package/dist/chunks/zero-engine-C17ezpgd.js.map +1 -0
- package/dist/{collector-osfWTeRd.d.ts → collector-BN6hCWIx.d.ts} +62 -10
- package/dist/{config-BoZDUHW5.d.ts → config-Chmu-PnP.d.ts} +508 -104
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/hydrate-CTh8SGd9.d.ts +20 -0
- package/dist/{index-B_k47mc_.d.ts → index-szujmf6W.d.ts} +687 -494
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -732
- package/dist/merge-styles-Cx25bpax.d.ts +4 -0
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +2 -16
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +8 -0
- package/dist/ssr/astro-middleware-extract-static.js +8 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +8 -0
- package/dist/ssr/astro-middleware-extract.js +8 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +15 -0
- package/dist/ssr/astro-middleware-static.js +6 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +11 -10
- package/dist/ssr/astro-middleware.js +3 -16
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +40 -12
- package/dist/ssr/astro.js +163 -93
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +1 -0
- package/dist/ssr/index.d.ts +5 -34
- package/dist/ssr/index.js +7 -8
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +63 -0
- package/dist/ssr/next-config.js +122 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -11
- package/dist/ssr/next.js +30 -46
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -13
- package/dist/static/index.js +6 -26
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -4
- package/dist/static/inject.js +1 -2
- package/dist/static/inject.js.map +1 -1
- package/dist/{index-tcHuMPFt.d.ts → types-DbMN-Yyn.d.ts} +851 -592
- package/dist/zero/babel.d.ts +12 -22
- package/dist/zero/babel.js +98 -160
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +74 -11
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +5 -7
- package/dist/zero/next.js +4 -40
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +20 -9
- package/docs/adoption.md +69 -36
- package/docs/ai-agents.md +259 -0
- package/docs/comparison.md +77 -47
- package/docs/configuration.md +617 -98
- package/docs/debug.md +28 -15
- package/docs/design-system.md +154 -33
- package/docs/dsl.md +715 -194
- package/docs/getting-started.md +130 -50
- package/docs/injector.md +160 -69
- package/docs/methodology.md +82 -51
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +102 -33
- package/docs/plugins.md +333 -0
- package/docs/react-api.md +215 -50
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +310 -118
- package/docs/styles.md +225 -42
- package/docs/tasty-static.md +289 -136
- package/package.json +146 -41
- package/tasty.config.ts +6 -0
- package/dist/async-storage-B7_o6FKt.js +0 -44
- package/dist/async-storage-B7_o6FKt.js.map +0 -1
- package/dist/collector-C-keQH9m.js.map +0 -1
- package/dist/config-BBiyxMCe.js +0 -10559
- package/dist/config-BBiyxMCe.js.map +0 -1
- package/dist/context-CkSg-kDT.js +0 -24
- package/dist/context-CkSg-kDT.js.map +0 -1
- package/dist/core-BO4319td.js +0 -1598
- package/dist/core-BO4319td.js.map +0 -1
- package/dist/css-writer-BWvwQzz0.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-BSjeH4Z7.js +0 -143
- package/dist/format-rules-BSjeH4Z7.js.map +0 -1
- package/dist/hydrate-CcvrP4qJ.js +0 -45
- package/dist/hydrate-CcvrP4qJ.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-BUQhdOSJ.js +0 -588
- package/dist/keyframes-BUQhdOSJ.js.map +0 -1
- package/dist/merge-styles-BMWcH6MF.d.ts +0 -7
- package/dist/merge-styles-Cd2vBl9b.js.map +0 -1
- package/dist/resolve-recipes-C1nrvnYh.js +0 -144
- package/dist/resolve-recipes-C1nrvnYh.js.map +0 -1
|
@@ -1,288 +1,5 @@
|
|
|
1
1
|
import { Properties } from "csstype";
|
|
2
|
-
|
|
3
|
-
//#region src/properties/property-type-resolver.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* PropertyTypeResolver
|
|
6
|
-
*
|
|
7
|
-
* Automatically infers CSS @property types from custom property values.
|
|
8
|
-
* Supports deferred resolution for var() reference chains of arbitrary depth.
|
|
9
|
-
*/
|
|
10
|
-
declare class PropertyTypeResolver {
|
|
11
|
-
/** propName → the prop it depends on */
|
|
12
|
-
private pendingDeps;
|
|
13
|
-
/** propName → list of props waiting on it */
|
|
14
|
-
private reverseDeps;
|
|
15
|
-
/**
|
|
16
|
-
* Scan CSS declarations and auto-register @property for custom properties
|
|
17
|
-
* whose types can be inferred from their values.
|
|
18
|
-
*/
|
|
19
|
-
scanDeclarations(declarations: string, isPropertyDefined: (name: string) => boolean, registerProperty: (name: string, syntax: string, initialValue: string) => void): void;
|
|
20
|
-
private addDependency;
|
|
21
|
-
private resolve;
|
|
22
|
-
private isComplexValue;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/injector/types.d.ts
|
|
26
|
-
declare global {
|
|
27
|
-
interface Window {
|
|
28
|
-
__TASTY__?: string[];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
interface InjectResult {
|
|
32
|
-
className: string;
|
|
33
|
-
dispose: () => void;
|
|
34
|
-
}
|
|
35
|
-
interface GlobalInjectResult {
|
|
36
|
-
dispose: () => void;
|
|
37
|
-
}
|
|
38
|
-
type DisposeFunction = () => void;
|
|
39
|
-
interface StyleInjectorConfig {
|
|
40
|
-
nonce?: string;
|
|
41
|
-
maxRulesPerSheet?: number;
|
|
42
|
-
forceTextInjection?: boolean;
|
|
43
|
-
/** Enable development mode features: performance metrics and debug information storage */
|
|
44
|
-
devMode?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Global predefined states for advanced state mapping.
|
|
47
|
-
* These are state aliases that can be used in any component.
|
|
48
|
-
* Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
|
|
49
|
-
*/
|
|
50
|
-
states?: Record<string, string>;
|
|
51
|
-
/**
|
|
52
|
-
* Automatically infer and register CSS @property declarations
|
|
53
|
-
* from custom property values. When false, only explicit @properties are used.
|
|
54
|
-
* @default true
|
|
55
|
-
*/
|
|
56
|
-
autoPropertyTypes?: boolean;
|
|
57
|
-
/** Garbage collection configuration for unused styles */
|
|
58
|
-
gc?: GCConfig;
|
|
59
|
-
/**
|
|
60
|
-
* Prefix prepended to every generated identifier.
|
|
61
|
-
* Mirrors the `namePrefix` field on the public `TastyConfig` so that
|
|
62
|
-
* standalone injector consumers can configure it directly.
|
|
63
|
-
* @default 't'
|
|
64
|
-
*/
|
|
65
|
-
namePrefix?: string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Per-className usage tracking for GC.
|
|
69
|
-
*/
|
|
70
|
-
interface StyleUsage {
|
|
71
|
-
lastTouchedAt: number;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Configuration for the style garbage collector.
|
|
75
|
-
*
|
|
76
|
-
* GC is triggered by touch count rather than timers: every `touchInterval`
|
|
77
|
-
* touches, an idle callback is scheduled to evict unused styles above
|
|
78
|
-
* `capacity`, oldest first.
|
|
79
|
-
*/
|
|
80
|
-
interface GCConfig {
|
|
81
|
-
/**
|
|
82
|
-
* Number of touch events between GC cycles.
|
|
83
|
-
* @default 1000
|
|
84
|
-
*/
|
|
85
|
-
touchInterval?: number;
|
|
86
|
-
/**
|
|
87
|
-
* Maximum number of unused styles to retain.
|
|
88
|
-
* GC evicts the oldest unused styles when this limit is exceeded.
|
|
89
|
-
* Actively referenced styles (refCount > 0) and DOM-live styles
|
|
90
|
-
* do not count against this limit.
|
|
91
|
-
* @default 1000
|
|
92
|
-
*/
|
|
93
|
-
capacity?: number;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Per-call options for gc().
|
|
97
|
-
*/
|
|
98
|
-
interface GCOptions {
|
|
99
|
-
root?: Document | ShadowRoot;
|
|
100
|
-
/** Bypass capacity threshold and remove ALL unused styles. */
|
|
101
|
-
force?: boolean;
|
|
102
|
-
}
|
|
103
|
-
interface RuleInfo {
|
|
104
|
-
className: string;
|
|
105
|
-
ruleIndex: number;
|
|
106
|
-
sheetIndex: number;
|
|
107
|
-
/** Dev-only: full CSS texts inserted for this class; omitted in production */
|
|
108
|
-
cssText?: string[];
|
|
109
|
-
/** Inclusive end index of the contiguous block of inserted rules for this className */
|
|
110
|
-
endRuleIndex?: number;
|
|
111
|
-
/** NEW: exact indices of all inserted rules for this className */
|
|
112
|
-
indices?: number[];
|
|
113
|
-
}
|
|
114
|
-
type InjectionMode = 'style-element' | 'adopted';
|
|
115
|
-
interface SheetInfo {
|
|
116
|
-
/** HTMLStyleElement used in style-element mode; null in adopted mode. */
|
|
117
|
-
sheet: HTMLStyleElement | null;
|
|
118
|
-
/** Constructable CSSStyleSheet used in adopted mode (ShadowRoot targets) */
|
|
119
|
-
constructableSheet?: CSSStyleSheet;
|
|
120
|
-
ruleCount: number;
|
|
121
|
-
holes: number[];
|
|
122
|
-
}
|
|
123
|
-
interface CleanupStats {
|
|
124
|
-
timestamp: number;
|
|
125
|
-
classesDeleted: number;
|
|
126
|
-
cssSize: number;
|
|
127
|
-
rulesDeleted: number;
|
|
128
|
-
}
|
|
129
|
-
interface CacheMetrics {
|
|
130
|
-
hits: number;
|
|
131
|
-
misses: number;
|
|
132
|
-
bulkCleanups: number;
|
|
133
|
-
totalInsertions: number;
|
|
134
|
-
totalUnused: number;
|
|
135
|
-
stylesCleanedUp: number;
|
|
136
|
-
cleanupHistory: CleanupStats[];
|
|
137
|
-
startTime: number;
|
|
138
|
-
unusedHits?: number;
|
|
139
|
-
}
|
|
140
|
-
interface RootRegistry {
|
|
141
|
-
sheets: SheetInfo[];
|
|
142
|
-
refCounts: Map<string, number>;
|
|
143
|
-
rules: Map<string, RuleInfo>;
|
|
144
|
-
/** Cache key to className mapping to avoid dual storage of RuleInfo objects */
|
|
145
|
-
cacheKeyToClassName: Map<string, string>;
|
|
146
|
-
/** Deduplication set of fully materialized CSS rules inserted into sheets */
|
|
147
|
-
ruleTextSet: Set<string>;
|
|
148
|
-
/** Performance metrics (optional) */
|
|
149
|
-
metrics?: CacheMetrics;
|
|
150
|
-
/** Keyframes cache by content hash -> entry */
|
|
151
|
-
keyframesCache: Map<string, KeyframesCacheEntry>;
|
|
152
|
-
/** Keyframes name to content hash mapping for collision detection */
|
|
153
|
-
keyframesNameToContent: Map<string, string>;
|
|
154
|
-
/** Counter for generating keyframes names like k0, k1, k2... */
|
|
155
|
-
keyframesCounter: number;
|
|
156
|
-
/** Map of injected @property names to their normalized declarations for tracking */
|
|
157
|
-
injectedProperties: Map<string, string>;
|
|
158
|
-
/** Content hashes of injected @font-face rules for deduplication */
|
|
159
|
-
injectedFontFaces: Set<string>;
|
|
160
|
-
/** Names of injected @counter-style rules for deduplication */
|
|
161
|
-
injectedCounterStyles: Set<string>;
|
|
162
|
-
/** Global rules tracking for index adjustment */
|
|
163
|
-
globalRules: Map<string, RuleInfo>;
|
|
164
|
-
/** Resolver for auto-inferring @property types from declaration values */
|
|
165
|
-
propertyTypeResolver: PropertyTypeResolver;
|
|
166
|
-
/** Per-className usage tracking for GC */
|
|
167
|
-
usageMap: Map<string, StyleUsage>;
|
|
168
|
-
/** Touch counter for scheduling GC (per-root) */
|
|
169
|
-
touchCount: number;
|
|
170
|
-
/** How many entries from `window.__TASTY__` have been synced into this registry */
|
|
171
|
-
serverClassSyncIndex: number;
|
|
172
|
-
/** Whether `<style data-tasty-rsc>` tags have been scanned for class names */
|
|
173
|
-
rscStylesScanned: boolean;
|
|
174
|
-
/** Whether this root uses adoptedStyleSheets or <style> elements */
|
|
175
|
-
injectionMode: InjectionMode;
|
|
176
|
-
/**
|
|
177
|
-
* Lazy feature-test for `@property` support, cached per registry.
|
|
178
|
-
* - `undefined`: not yet probed.
|
|
179
|
-
* - `true`: engine supports `@property`; rejections indicate user-authored
|
|
180
|
-
* invalid rules and should warn.
|
|
181
|
-
* - `false`: engine doesn't support `@property` (e.g., jsdom); rejections
|
|
182
|
-
* are expected and warnings are suppressed.
|
|
183
|
-
*/
|
|
184
|
-
atPropertySupported?: boolean;
|
|
185
|
-
}
|
|
186
|
-
type StyleRule = StyleResult;
|
|
187
|
-
interface KeyframesInfo {
|
|
188
|
-
name: string;
|
|
189
|
-
sheetIndex: number;
|
|
190
|
-
ruleIndex: number;
|
|
191
|
-
/** Dev-only: full CSS text of the @keyframes rule; omitted in production */
|
|
192
|
-
cssText?: string;
|
|
193
|
-
}
|
|
194
|
-
type KeyframeStep = string | Record<string, string | number>;
|
|
195
|
-
type KeyframesSteps = Record<string, KeyframeStep>;
|
|
196
|
-
interface KeyframesResult {
|
|
197
|
-
toString(): string;
|
|
198
|
-
dispose: () => void;
|
|
199
|
-
}
|
|
200
|
-
interface KeyframesCacheEntry {
|
|
201
|
-
name: string;
|
|
202
|
-
refCount: number;
|
|
203
|
-
info: KeyframesInfo;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Definition for a CSS @property at-rule.
|
|
207
|
-
* Used to define custom property syntax, inheritance, and initial value.
|
|
208
|
-
*/
|
|
209
|
-
interface PropertyDefinition {
|
|
210
|
-
/** CSS syntax string (e.g., '<color>', '<angle>', '<number>') */
|
|
211
|
-
syntax?: string;
|
|
212
|
-
/** Whether the property inherits (default: true) */
|
|
213
|
-
inherits?: boolean;
|
|
214
|
-
/** Initial value for the property */
|
|
215
|
-
initialValue?: string | number;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Descriptors for a CSS @font-face at-rule.
|
|
219
|
-
*/
|
|
220
|
-
interface FontFaceDescriptors {
|
|
221
|
-
/** Required. URL(s) to the font file(s). */
|
|
222
|
-
src: string;
|
|
223
|
-
/** Font weight or range. Default: 'normal'. */
|
|
224
|
-
fontWeight?: string | number;
|
|
225
|
-
/** Font style. Default: 'normal'. */
|
|
226
|
-
fontStyle?: 'normal' | 'italic' | 'oblique' | (string & {});
|
|
227
|
-
/** Font stretch. Default: 'normal'. */
|
|
228
|
-
fontStretch?: string;
|
|
229
|
-
/** Loading behavior. Default: 'auto'. */
|
|
230
|
-
fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
231
|
-
/** Unicode range to cover. */
|
|
232
|
-
unicodeRange?: string;
|
|
233
|
-
/** Ascent metric override. */
|
|
234
|
-
ascentOverride?: string;
|
|
235
|
-
/** Descent metric override. */
|
|
236
|
-
descentOverride?: string;
|
|
237
|
-
/** Line gap metric override. */
|
|
238
|
-
lineGapOverride?: string;
|
|
239
|
-
/** Size adjustment factor. */
|
|
240
|
-
sizeAdjust?: string;
|
|
241
|
-
/** OpenType feature settings. */
|
|
242
|
-
fontFeatureSettings?: string;
|
|
243
|
-
/** Font variation axis settings. */
|
|
244
|
-
fontVariationSettings?: string;
|
|
245
|
-
}
|
|
246
|
-
/** Single descriptor or array of descriptors for multiple weights/styles. */
|
|
247
|
-
type FontFaceInput = FontFaceDescriptors | FontFaceDescriptors[];
|
|
248
|
-
/**
|
|
249
|
-
* Descriptors for a CSS @counter-style at-rule.
|
|
250
|
-
*/
|
|
251
|
-
interface CounterStyleDescriptors {
|
|
252
|
-
/** Required. Numbering algorithm. */
|
|
253
|
-
system: 'cyclic' | 'numeric' | 'alphabetic' | 'symbolic' | 'additive' | 'fixed' | (string & {});
|
|
254
|
-
/** Symbols for non-additive systems. */
|
|
255
|
-
symbols?: string;
|
|
256
|
-
/** Symbol-value pairs for additive system. */
|
|
257
|
-
additiveSymbols?: string;
|
|
258
|
-
/** String prepended to the marker. Default: "". */
|
|
259
|
-
prefix?: string;
|
|
260
|
-
/** String appended to the marker. Default: ". ". */
|
|
261
|
-
suffix?: string;
|
|
262
|
-
/** Negative-value wrapping (e.g., '"(" ")"'). */
|
|
263
|
-
negative?: string;
|
|
264
|
-
/** Counter range (e.g., 'infinite infinite'). */
|
|
265
|
-
range?: string;
|
|
266
|
-
/** Minimum marker width and pad symbol (e.g., '3 "0"'). */
|
|
267
|
-
pad?: string;
|
|
268
|
-
/** Fallback counter style name. */
|
|
269
|
-
fallback?: string;
|
|
270
|
-
/** Speech synthesis hint. */
|
|
271
|
-
speakAs?: string;
|
|
272
|
-
}
|
|
273
|
-
interface RawCSSResult {
|
|
274
|
-
dispose: () => void;
|
|
275
|
-
}
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/utils/css-types.d.ts
|
|
278
2
|
interface CSSProperties extends Properties<string | number> {}
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region src/parser/types.d.ts
|
|
281
|
-
declare enum Bucket {
|
|
282
|
-
Color = 0,
|
|
283
|
-
Value = 1,
|
|
284
|
-
Mod = 2
|
|
285
|
-
}
|
|
286
3
|
/**
|
|
287
4
|
* A part within a group, representing a slash-separated segment.
|
|
288
5
|
* For example, in `'2px solid #red / 4px'`, there are two parts:
|
|
@@ -321,18 +38,16 @@ interface ProcessedStyle {
|
|
|
321
38
|
}
|
|
322
39
|
type UnitHandler = (scalar: number) => string;
|
|
323
40
|
interface ParserOptions {
|
|
324
|
-
|
|
41
|
+
functions?: Record<string, (parsed: StyleDetails[]) => string>;
|
|
325
42
|
units?: Record<string, string | UnitHandler>;
|
|
326
43
|
cacheSize?: number;
|
|
327
44
|
}
|
|
328
|
-
//#endregion
|
|
329
|
-
//#region src/parser/parser.d.ts
|
|
330
45
|
declare class StyleParser {
|
|
331
46
|
private opts;
|
|
332
47
|
private cache;
|
|
333
48
|
constructor(opts?: ParserOptions);
|
|
334
49
|
process(src: string): ProcessedStyle;
|
|
335
|
-
|
|
50
|
+
setFunctions(functions: Required<ParserOptions>['functions']): void;
|
|
336
51
|
setUnits(units: Required<ParserOptions>['units']): void;
|
|
337
52
|
updateOptions(patch: Partial<ParserOptions>): void;
|
|
338
53
|
/**
|
|
@@ -346,52 +61,6 @@ declare class StyleParser {
|
|
|
346
61
|
*/
|
|
347
62
|
getUnits(): ParserOptions['units'];
|
|
348
63
|
}
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/utils/color-math.d.ts
|
|
351
|
-
/**
|
|
352
|
-
* Consolidated color conversion math.
|
|
353
|
-
*
|
|
354
|
-
* Single source of truth for all color space conversions used across the
|
|
355
|
-
* library: sRGB gamma, HSL, OKLab, OKLCH, OKHSL, hex parsing, named
|
|
356
|
-
* colors, and CSS string converters.
|
|
357
|
-
*
|
|
358
|
-
* This module has zero internal imports — it is a leaf dependency.
|
|
359
|
-
*
|
|
360
|
-
* Reference: https://bottosson.github.io/posts/oklab/
|
|
361
|
-
*/
|
|
362
|
-
type Vec3 = [number, number, number];
|
|
363
|
-
/**
|
|
364
|
-
* HSL to RGB.
|
|
365
|
-
* Algorithm from CSS Color 4 spec.
|
|
366
|
-
*
|
|
367
|
-
* @param h - Hue in degrees (0-360)
|
|
368
|
-
* @param s - Saturation (0-1)
|
|
369
|
-
* @param l - Lightness (0-1)
|
|
370
|
-
* @returns RGB values in 0-255 range (may have fractional values)
|
|
371
|
-
*/
|
|
372
|
-
declare function hslToRgbValues(h: number, s: number, l: number): Vec3;
|
|
373
|
-
declare function getNamedColorHex(): Map<string, string>;
|
|
374
|
-
/**
|
|
375
|
-
* Convert hex color string to `rgb()` CSS string.
|
|
376
|
-
* Supports 3, 4, 6, and 8 character hex values (with or without `#`).
|
|
377
|
-
*/
|
|
378
|
-
declare function hexToRgb(hex: string): string | null;
|
|
379
|
-
/**
|
|
380
|
-
* Extract RGB values from an `rgb()`/`rgba()` string.
|
|
381
|
-
* Supports comma-separated, space-separated, fractional, percentage,
|
|
382
|
-
* and slash alpha notation.
|
|
383
|
-
*
|
|
384
|
-
* @returns Array of RGB values (0-255 range), converting percentages as needed.
|
|
385
|
-
*/
|
|
386
|
-
declare function getRgbValuesFromRgbaString(str: string): number[];
|
|
387
|
-
/**
|
|
388
|
-
* Convert any recognized color string to an `rgb()` CSS string.
|
|
389
|
-
* Handles hex, `okhsl()`, `hsl()`/`hsla()`, named CSS colors,
|
|
390
|
-
* and `rgb()`/`rgba()` pass-through.
|
|
391
|
-
*/
|
|
392
|
-
declare function strToRgb(color: string, _ignoreAlpha?: boolean): string | null | undefined;
|
|
393
|
-
//#endregion
|
|
394
|
-
//#region src/utils/styles.d.ts
|
|
395
64
|
type StyleValue<T = string> = T | boolean | number | null | undefined;
|
|
396
65
|
/**
|
|
397
66
|
* Normalize a color token value.
|
|
@@ -409,12 +78,45 @@ type StyleValueStateMap<T = string> = Record<string, StyleValue<T> | '@inherit'>
|
|
|
409
78
|
* Use this for component props that accept style values.
|
|
410
79
|
*/
|
|
411
80
|
type StylePropValue<T = string> = StyleValue<T> | StyleValueStateMap<T>;
|
|
81
|
+
/**
|
|
82
|
+
* One dependency value as a style handler receives it: already resolved for a
|
|
83
|
+
* single state, but still the **raw authored DSL string** (`'2x'`, `'#purple.5'`).
|
|
84
|
+
* Handlers parse it themselves via {@link parseStyle} / {@link parseColor}.
|
|
85
|
+
*/
|
|
86
|
+
type ResolvedStyleValue = StyleValue<string>;
|
|
87
|
+
/**
|
|
88
|
+
* The dependency map a handler receives — one resolved value per style name in
|
|
89
|
+
* its `__lookupStyles`.
|
|
90
|
+
*/
|
|
91
|
+
type StyleHandlerProps<TDeps extends string = string> = Partial<Record<TDeps, ResolvedStyleValue>>;
|
|
92
|
+
/**
|
|
93
|
+
* One set of CSS declarations returned by a style handler.
|
|
94
|
+
*
|
|
95
|
+
* Keys are **kebab-case** CSS property names (`'background-color'`, not
|
|
96
|
+
* `backgroundColor`) or `--custom-property` names. Values are stringified, so
|
|
97
|
+
* numbers are accepted. `$` is reserved as a selector suffix.
|
|
98
|
+
*/
|
|
412
99
|
type CSSMap = {
|
|
100
|
+
/** Selector suffix (or suffixes) these declarations apply to, e.g. `'& > *'`. */
|
|
413
101
|
$?: string | string[];
|
|
414
|
-
} & Record<string, string | string[]>;
|
|
102
|
+
} & Record<string, string | number | (string | number)[] | undefined>;
|
|
415
103
|
type StyleHandlerResult = CSSMap | CSSMap[] | null | void;
|
|
416
|
-
type RawStyleHandler = (
|
|
417
|
-
type StyleHandler = RawStyleHandler & {
|
|
104
|
+
type RawStyleHandler<TProps extends object = StyleHandlerProps> = (props: TProps) => StyleHandlerResult;
|
|
105
|
+
type StyleHandler<TProps extends object = StyleHandlerProps> = RawStyleHandler<TProps> & {
|
|
106
|
+
__lookupStyles: string[];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* The handler type used by the registry (`STYLE_HANDLER_MAP`), with parameter
|
|
110
|
+
* variance erased.
|
|
111
|
+
*
|
|
112
|
+
* Handlers declare narrow, hand-written dependency types — `({ fill }: { fill?:
|
|
113
|
+
* string }) => …` — which under `strictFunctionTypes` are not assignable to a
|
|
114
|
+
* wider parameter type. The registry stores handlers of many different dependency
|
|
115
|
+
* shapes together, so it needs the erased form. Prefer {@link StyleHandler} (or
|
|
116
|
+
* {@link defineHandler}) when writing a handler; this type is for code that
|
|
117
|
+
* inspects the registry.
|
|
118
|
+
*/
|
|
119
|
+
type AnyStyleHandler = ((props: any) => StyleHandlerResult) & {
|
|
418
120
|
__lookupStyles: string[];
|
|
419
121
|
};
|
|
420
122
|
/**
|
|
@@ -422,8 +124,11 @@ type StyleHandler = RawStyleHandler & {
|
|
|
422
124
|
* - Function only: lookup styles inferred from key name
|
|
423
125
|
* - Single property tuple: ['styleName', handler]
|
|
424
126
|
* - Multi-property tuple: [['style1', 'style2'], handler]
|
|
127
|
+
*
|
|
128
|
+
* Use {@link defineHandler} to have the dependency names inferred into the
|
|
129
|
+
* handler's parameter type instead of annotating it by hand.
|
|
425
130
|
*/
|
|
426
|
-
type StyleHandlerDefinition = RawStyleHandler | [
|
|
131
|
+
type StyleHandlerDefinition<TDeps extends string = string> = RawStyleHandler<StyleHandlerProps<TDeps>> | [TDeps, RawStyleHandler<StyleHandlerProps<TDeps>>] | [readonly TDeps[], RawStyleHandler<StyleHandlerProps<TDeps>>];
|
|
427
132
|
interface ParsedColor {
|
|
428
133
|
color?: string;
|
|
429
134
|
name?: string;
|
|
@@ -439,36 +144,15 @@ declare const CUSTOM_UNITS: {
|
|
|
439
144
|
sf: (num: number) => string;
|
|
440
145
|
};
|
|
441
146
|
declare const DIRECTIONS: string[];
|
|
442
|
-
declare function customFunc(name: string, fn: (groups: StyleDetails[]) => string): void;
|
|
443
147
|
/**
|
|
444
148
|
* Get the global StyleParser instance.
|
|
445
149
|
* Used by configure() to apply parser configuration.
|
|
446
150
|
*/
|
|
447
151
|
declare function getGlobalParser(): StyleParser;
|
|
448
152
|
/**
|
|
449
|
-
* Get the current
|
|
450
|
-
* Used by configure() to merge with new functions.
|
|
153
|
+
* Get the current global predefined tokens, including built-in defaults.
|
|
451
154
|
*/
|
|
452
|
-
declare function
|
|
453
|
-
/**
|
|
454
|
-
* Set global predefined tokens.
|
|
455
|
-
* Called from configure() after processing token values.
|
|
456
|
-
* Merges with existing tokens (new tokens override existing ones with same key).
|
|
457
|
-
* Keys are normalized to lowercase (parser lowercases input before classification).
|
|
458
|
-
* @internal
|
|
459
|
-
*/
|
|
460
|
-
declare function setGlobalPredefinedTokens(tokens: Record<string, string>): void;
|
|
461
|
-
/**
|
|
462
|
-
* Get the current global predefined tokens.
|
|
463
|
-
* Returns null if no tokens are configured.
|
|
464
|
-
*/
|
|
465
|
-
declare function getGlobalPredefinedTokens(): Record<string, string> | null;
|
|
466
|
-
/**
|
|
467
|
-
* Reset global predefined tokens.
|
|
468
|
-
* Used for testing.
|
|
469
|
-
* @internal
|
|
470
|
-
*/
|
|
471
|
-
declare function resetGlobalPredefinedTokens(): void;
|
|
155
|
+
declare function getGlobalPredefinedTokens(): Record<string, string>;
|
|
472
156
|
/**
|
|
473
157
|
*
|
|
474
158
|
* @param {String} value
|
|
@@ -481,10 +165,8 @@ declare function parseStyle(value: StyleValue): ProcessedStyle;
|
|
|
481
165
|
* Optimized to avoid heavy parseStyle calls for simple color patterns.
|
|
482
166
|
*/
|
|
483
167
|
declare function parseColor(val: string, ignoreError?: boolean): ParsedColor;
|
|
484
|
-
declare function filterMods(mods: string[], allowedMods: string[]): string[];
|
|
168
|
+
declare function filterMods(mods: string[], allowedMods: readonly string[]): string[];
|
|
485
169
|
declare function stringifyStyles(styles: unknown): string;
|
|
486
|
-
//#endregion
|
|
487
|
-
//#region src/styles/types.d.ts
|
|
488
170
|
/**
|
|
489
171
|
* Extensible interface for named color tokens.
|
|
490
172
|
* Augment this interface to register project-specific color names
|
|
@@ -524,7 +206,11 @@ type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
|
524
206
|
type OpaquePercentage = '' | `.${Digit}` | `.${Digit}${Digit}` | '.100';
|
|
525
207
|
type ColorValue = `#${NamedColor}${OpaquePercentage}` | `rgb(${string})` | `hsl(${string})` | `okhsl(${string})` | `oklch(${string})` | (string & {});
|
|
526
208
|
type NoType = false | null | undefined;
|
|
527
|
-
interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font' | 'outline' | 'type' | 'gap' | 'padding' | 'margin' | 'width' | 'height' | 'border' | 'transition' | 'placeContent' | 'placeItems' | 'scrollMargin' | 'scrollMarginTop' | 'scrollMarginRight' | 'scrollMarginBottom' | 'scrollMarginLeft' | '
|
|
209
|
+
interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font' | 'outline' | 'type' | 'gap' | 'padding' | 'margin' | 'width' | 'height' | 'blockSize' | 'inlineSize' | 'border' | 'transition' | 'placeContent' | 'placeItems' | 'scrollMargin' | 'scrollMarginTop' | 'scrollMarginRight' | 'scrollMarginBottom' | 'scrollMarginLeft' | 'scrollPadding' | 'scrollPaddingTop' | 'scrollPaddingRight' | 'scrollPaddingBottom' | 'scrollPaddingLeft' | 'overscrollBehaviorBlock' | 'overscrollBehaviorInline' | 'overscrollBehaviorX' | 'overscrollBehaviorY'> {
|
|
210
|
+
overscrollBehaviorBlock?: CSSProperties['overscrollBehaviorBlock'] | 'chain';
|
|
211
|
+
overscrollBehaviorInline?: CSSProperties['overscrollBehaviorInline'] | 'chain';
|
|
212
|
+
overscrollBehaviorX?: CSSProperties['overscrollBehaviorX'] | 'chain';
|
|
213
|
+
overscrollBehaviorY?: CSSProperties['overscrollBehaviorY'] | 'chain';
|
|
528
214
|
/**
|
|
529
215
|
* @deprecated Use `flow` style instead.
|
|
530
216
|
*/
|
|
@@ -540,7 +226,7 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
540
226
|
/**
|
|
541
227
|
* Set the background color of the element. Shortcut for `background-color` with enhanced support for Tasty color tokens and syntaxes.
|
|
542
228
|
*
|
|
543
|
-
*
|
|
229
|
+
* To paint one color over another, use a compound color: `#surface+#dark.04` is `#dark` at 4% opacity over `#surface`, as one background color.
|
|
544
230
|
*
|
|
545
231
|
* Examples:
|
|
546
232
|
* - `fill="#purple.10"` // purple background with 10% opacity
|
|
@@ -550,8 +236,11 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
550
236
|
* - `fill="hsl(200 100% 50%)"` // HSL color
|
|
551
237
|
* - `fill="okhsl(200 100% 50%)"` // perceptually uniform OKHSL color
|
|
552
238
|
* - `fill="oklch(0.7 0.15 200)"` // OKLCH color
|
|
553
|
-
* - `fill="#
|
|
554
|
-
* - `fill=
|
|
239
|
+
* - `fill="#surface+#dark.04"` // `#dark` at 4% opacity over `#surface`, as one color
|
|
240
|
+
* - `fill="#dark 4%, #surface"` // deprecated: two colors mixed with a comma, the same color as `#surface+#dark.04`
|
|
241
|
+
* - `fill="#surface #dark.04"` // deprecated: the second color as an overlay layer
|
|
242
|
+
*
|
|
243
|
+
* `fill={false}` sets no fill. `fill={true}` names no color and is ignored.
|
|
555
244
|
*/
|
|
556
245
|
fill?: ColorValue | boolean;
|
|
557
246
|
/**
|
|
@@ -605,9 +294,12 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
605
294
|
/**
|
|
606
295
|
* The fade style applies gradient-based fading masks to the edges of an element. Replaces complex CSS mask gradients with a simple, declarative API.
|
|
607
296
|
*
|
|
608
|
-
* Syntax: `[width] [
|
|
297
|
+
* Syntax: `[width] [direction...] [#from-color] [#to-color]`
|
|
609
298
|
*
|
|
610
|
-
* Multiple groups can be separated by commas to specify different
|
|
299
|
+
* Multiple groups can be separated by commas to specify different widths and
|
|
300
|
+
* colors per direction. A group that names edges takes a single width, applied
|
|
301
|
+
* to every edge it names; a group that names none covers all four edges and
|
|
302
|
+
* keeps plain CSS shorthand order.
|
|
611
303
|
*
|
|
612
304
|
* Color tokens (optional):
|
|
613
305
|
* - First color: transparent start of gradient (default: `rgb(0 0 0 / 0)`)
|
|
@@ -616,14 +308,16 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
616
308
|
* Examples:
|
|
617
309
|
* - `fade="top"` // fade only top edge with default width
|
|
618
310
|
* - `fade="2x left right"` // fade left and right edges with 2x width
|
|
311
|
+
* - `fade={true}` // all edges at the design-system default width
|
|
619
312
|
* - `fade="1x top"` // fade only top edge with 1x width
|
|
620
|
-
* - `fade="3x 1x
|
|
313
|
+
* - `fade="3x 1x"` // all edges: top/bottom 3x, left/right 1x
|
|
314
|
+
* - `fade="3x top, 1x bottom"` // top: 3x width, bottom: 1x width
|
|
621
315
|
* - `fade="2x #transparent #dark"` // custom colors for gradient mask
|
|
622
316
|
* - `fade="1x top #clear #solid"` // top edge with custom mask colors
|
|
623
317
|
* - `fade="top #red #blue, bottom #green #yellow"` // different colors per direction
|
|
624
318
|
* - `fade="2x top #a #b, 1x bottom #c #d"` // different widths and colors per direction
|
|
625
319
|
*/
|
|
626
|
-
fade?: 'top' | 'right' | 'bottom' | 'left' | string;
|
|
320
|
+
fade?: 'top' | 'right' | 'bottom' | 'left' | string | boolean;
|
|
627
321
|
/**
|
|
628
322
|
* Scrollbar styling using standard CSS properties (`scrollbar-width`, `scrollbar-color`, `scrollbar-gutter`).
|
|
629
323
|
*
|
|
@@ -660,23 +354,39 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
660
354
|
/**
|
|
661
355
|
* Shorthand for element padding. Supports custom units, directional modifiers, and design-system-driven defaults.
|
|
662
356
|
*
|
|
357
|
+
* A group that names directions takes a single value, applied to every
|
|
358
|
+
* direction it names — use comma groups for per-side values.
|
|
359
|
+
*
|
|
663
360
|
* Examples:
|
|
664
361
|
* - `padding="2x 1x"` // top/bottom: 2x, left/right: 1x
|
|
665
362
|
* - `padding="2x top"` // only top padding: 2x
|
|
666
363
|
* - `padding="1x left right"` // left and right padding: 1x
|
|
364
|
+
* - `padding="2x top, 4x right"` // top: 2x, right: 4x, bottom/left: 0
|
|
667
365
|
* - `padding={true}` // default padding on all sides
|
|
668
366
|
*/
|
|
669
367
|
padding?: CSSProperties['padding'] | string | boolean;
|
|
368
|
+
/** Logical block-axis padding with `start`/`end` modifiers. */
|
|
369
|
+
blockPadding?: CSSProperties['paddingBlock'] | string | boolean;
|
|
370
|
+
/** Logical inline-axis padding with `start`/`end` modifiers. */
|
|
371
|
+
inlinePadding?: CSSProperties['paddingInline'] | string | boolean;
|
|
670
372
|
/**
|
|
671
373
|
* Shorthand for element margin. Supports custom units, directional modifiers, and design-system-driven defaults.
|
|
672
374
|
*
|
|
375
|
+
* A group that names directions takes a single value, applied to every
|
|
376
|
+
* direction it names — use comma groups for per-side values.
|
|
377
|
+
*
|
|
673
378
|
* Examples:
|
|
674
379
|
* - `margin="2x 1x"` // top/bottom: 2x, left/right: 1x
|
|
675
380
|
* - `margin="2x top"` // only top margin: 2x
|
|
676
381
|
* - `margin="1x left right"` // left and right margin: 1x
|
|
382
|
+
* - `margin="2x top, 4x right"` // top: 2x, right: 4x, bottom/left: 0
|
|
677
383
|
* - `margin={true}` // default margin on all sides
|
|
678
384
|
*/
|
|
679
385
|
margin?: CSSProperties['margin'] | string | boolean;
|
|
386
|
+
/** Logical block-axis margin with `start`/`end` modifiers. */
|
|
387
|
+
blockMargin?: CSSProperties['marginBlock'] | string | boolean;
|
|
388
|
+
/** Logical inline-axis margin with `start`/`end` modifiers. */
|
|
389
|
+
inlineMargin?: CSSProperties['marginInline'] | string | boolean;
|
|
680
390
|
/**
|
|
681
391
|
* Concise shorthand for setting element width, including min-width and max-width. Supports custom units and advanced sizing keywords.
|
|
682
392
|
*
|
|
@@ -708,6 +418,16 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
708
418
|
* - `height={true}` // height: auto
|
|
709
419
|
*/
|
|
710
420
|
height?: CSSProperties['height'] | string | boolean;
|
|
421
|
+
/**
|
|
422
|
+
* Logical block size with the same enhanced min/max/fixed syntax as `width`.
|
|
423
|
+
* Emits native `block-size`, `min-block-size`, and `max-block-size` declarations.
|
|
424
|
+
*/
|
|
425
|
+
blockSize?: CSSProperties['blockSize'] | string | boolean;
|
|
426
|
+
/**
|
|
427
|
+
* Logical inline size with the same enhanced min/max/fixed syntax as `width`.
|
|
428
|
+
* Emits native `inline-size`, `min-inline-size`, and `max-inline-size` declarations.
|
|
429
|
+
*/
|
|
430
|
+
inlineSize?: CSSProperties['inlineSize'] | string | boolean;
|
|
711
431
|
/**
|
|
712
432
|
* Shorthand for border width, style, and color. Supports directional modifiers and design-system defaults.
|
|
713
433
|
*
|
|
@@ -722,8 +442,17 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
722
442
|
* - `border="dotted #danger left right"` // left/right: 1bw dotted danger
|
|
723
443
|
* - `border="1bw #red, 2bw #blue top"` // all sides red 1bw, top overridden to blue 2bw
|
|
724
444
|
* - `border="1bw, dashed top bottom, #purple left right"` // base 1bw, dashed on top/bottom, purple on left/right
|
|
445
|
+
* - `border="1bw $my-style"` // custom property in the style slot
|
|
446
|
+
*
|
|
447
|
+
* A `$name` reference fills the first free slot — width, then style, then
|
|
448
|
+
* color. Colors are authored as `#name`; to point the color slot at a raw
|
|
449
|
+
* custom property directly, name it `$name-color`.
|
|
725
450
|
*/
|
|
726
451
|
border?: CSSProperties['border'] | string | boolean;
|
|
452
|
+
/** Logical block-axis border with `start`/`end` modifiers. */
|
|
453
|
+
blockBorder?: CSSProperties['borderBlock'] | string | boolean;
|
|
454
|
+
/** Logical inline-axis border with `start`/`end` modifiers. */
|
|
455
|
+
inlineBorder?: CSSProperties['borderInline'] | string | boolean;
|
|
727
456
|
/**
|
|
728
457
|
* Powerful shorthand for CSS transitions using semantic names and design tokens. Supports grouped transitions for common UI effects.
|
|
729
458
|
*
|
|
@@ -731,10 +460,10 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
731
460
|
* Multiple transitions: separated by commas
|
|
732
461
|
*
|
|
733
462
|
* Examples:
|
|
734
|
-
* - `transition="fill
|
|
735
|
-
* - `transition="fade
|
|
736
|
-
* - `transition="theme
|
|
737
|
-
* - `transition="preset
|
|
463
|
+
* - `transition="fill, radius"` // transitions background-color and border-radius
|
|
464
|
+
* - `transition="fade $transition ease-in"` // transitions mask with explicit timing token
|
|
465
|
+
* - `transition="theme"` // transitions all theme-related properties
|
|
466
|
+
* - `transition="preset"` // transitions typography properties
|
|
738
467
|
*/
|
|
739
468
|
transition?: CSSProperties['transition'] | string;
|
|
740
469
|
/**
|
|
@@ -760,14 +489,17 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
760
489
|
* Syntax: `[value] [modifiers]` | `[shape]` | `true`
|
|
761
490
|
*
|
|
762
491
|
* Shapes: `round` (fully rounded), `ellipse` (50%), `leaf`, `backleaf` (asymmetric), `inherit` (inherit from parent)
|
|
763
|
-
*
|
|
492
|
+
* Edge modifiers: `top`, `right`, `bottom`, `left` — the corner pair along that edge
|
|
493
|
+
* Corner modifiers: `top-left`, `top-right`, `bottom-right`, `bottom-left` — a single corner
|
|
764
494
|
*
|
|
765
495
|
* Examples:
|
|
766
|
-
* - `radius="2r"` // border-radius:
|
|
496
|
+
* - `radius="2r"` // border-radius: 12px
|
|
767
497
|
* - `radius={true}` // default radius (1r)
|
|
768
498
|
* - `radius="round"` // fully rounded (9999rem)
|
|
769
499
|
* - `radius="leaf"` // asymmetric leaf shape
|
|
770
|
-
* - `radius="1r top"` // round
|
|
500
|
+
* - `radius="1r top"` // round both top corners
|
|
501
|
+
* - `radius="top-right"` // round only the top-right corner (1r)
|
|
502
|
+
* - `radius="4px top-left"` // round only the top-left corner
|
|
771
503
|
* - `radius="inherit"` // inherit border-radius from parent
|
|
772
504
|
* - `radius="inherit right"` // inherit only right corners (uses longhand properties)
|
|
773
505
|
*/
|
|
@@ -837,6 +569,11 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
837
569
|
* - `outline="2ow dashed #purple"` // 2ow dashed purple outline
|
|
838
570
|
* - `outline="2ow #danger / 1x"` // 2ow solid danger outline, 1x offset
|
|
839
571
|
* - `outline={true}` // default outline (1ow solid)
|
|
572
|
+
* - `outline="2ow $my-style"` // custom property in the style slot
|
|
573
|
+
*
|
|
574
|
+
* A `$name` reference fills the first free slot — width, then style, then
|
|
575
|
+
* color. Colors are authored as `#name`; to point the color slot at a raw
|
|
576
|
+
* custom property directly, name it `$name-color`.
|
|
840
577
|
*/
|
|
841
578
|
outline?: string | boolean;
|
|
842
579
|
/**
|
|
@@ -913,6 +650,7 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
913
650
|
* Examples:
|
|
914
651
|
* - `scrollMargin="2x"` // scroll-margin on all sides: 2x
|
|
915
652
|
* - `scrollMargin="2x top"` // only top scroll-margin: 2x
|
|
653
|
+
* - `scrollMargin="2x top, 4x bottom"` // top: 2x, bottom: 4x
|
|
916
654
|
* - `scrollMargin={true}` // default scroll-margin on all sides
|
|
917
655
|
*/
|
|
918
656
|
scrollMargin?: CSSProperties['scrollMargin'] | string | boolean;
|
|
@@ -920,8 +658,23 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
920
658
|
scrollMarginRight?: string | number | boolean;
|
|
921
659
|
scrollMarginBottom?: string | number | boolean;
|
|
922
660
|
scrollMarginLeft?: string | number | boolean;
|
|
923
|
-
|
|
924
|
-
|
|
661
|
+
/** Logical block-axis scroll margin with `start`/`end` modifiers. */
|
|
662
|
+
blockScrollMargin?: CSSProperties['scrollMarginBlock'] | string | boolean;
|
|
663
|
+
/** Logical inline-axis scroll margin with `start`/`end` modifiers. */
|
|
664
|
+
inlineScrollMargin?: CSSProperties['scrollMarginInline'] | string | boolean;
|
|
665
|
+
/**
|
|
666
|
+
* Shorthand for physical scroll padding. Supports custom units and the same
|
|
667
|
+
* physical direction modifiers as `padding`.
|
|
668
|
+
*/
|
|
669
|
+
scrollPadding?: CSSProperties['scrollPadding'] | string | boolean;
|
|
670
|
+
scrollPaddingTop?: string | number | boolean;
|
|
671
|
+
scrollPaddingRight?: string | number | boolean;
|
|
672
|
+
scrollPaddingBottom?: string | number | boolean;
|
|
673
|
+
scrollPaddingLeft?: string | number | boolean;
|
|
674
|
+
/** Logical block-axis scroll padding with `start`/`end` modifiers. */
|
|
675
|
+
blockScrollPadding?: CSSProperties['scrollPaddingBlock'] | string | boolean;
|
|
676
|
+
/** Logical inline-axis scroll padding with `start`/`end` modifiers. */
|
|
677
|
+
inlineScrollPadding?: CSSProperties['scrollPaddingInline'] | string | boolean;
|
|
925
678
|
/**
|
|
926
679
|
* Shorthand for `top`, `right`, `bottom`, and `left` offsets. Supports custom units, directional modifiers, and positioning.
|
|
927
680
|
*
|
|
@@ -929,9 +682,24 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
929
682
|
* - `inset="0"` // all sides: 0
|
|
930
683
|
* - `inset="2x top"` // only top offset: 2x
|
|
931
684
|
* - `inset="1x left right"` // left and right offsets: 1x
|
|
685
|
+
* - `inset="2x top, 4x right"` // top: 2x, right: 4x, bottom/left: auto
|
|
686
|
+
* - `inset="bottom dock"` // bottom-anchored, full width: auto 0 0 0
|
|
932
687
|
* - `inset={true}` // all sides: 0
|
|
688
|
+
*
|
|
689
|
+
* A group that names directions takes a single value, applied to every
|
|
690
|
+
* direction it names — use comma groups for per-side values.
|
|
691
|
+
*
|
|
692
|
+
* The `dock` modifier pins the named edge and spans its full length, applying
|
|
693
|
+
* the value to the two perpendicular sides as well. `dock` is the one case
|
|
694
|
+
* where a directional group takes two values: the second applies to those
|
|
695
|
+
* spanned sides, so `inset="2x 4x bottom dock"` pins the bottom at `2x` and
|
|
696
|
+
* insets the sides by `4x`. Without `dock` a second value is ignored.
|
|
933
697
|
*/
|
|
934
|
-
inset?: 'top' | 'right' | 'bottom' | 'left' | string | CSSProperties['inset'];
|
|
698
|
+
inset?: 'top' | 'right' | 'bottom' | 'left' | 'dock' | string | CSSProperties['inset'];
|
|
699
|
+
/** Logical block-axis inset with `start`/`end` modifiers. */
|
|
700
|
+
blockInset?: CSSProperties['insetBlock'] | string | boolean;
|
|
701
|
+
/** Logical inline-axis inset with `start`/`end` modifiers. */
|
|
702
|
+
inlineInset?: CSSProperties['insetInline'] | string | boolean;
|
|
935
703
|
/**
|
|
936
704
|
* Local keyframes definitions for this component.
|
|
937
705
|
* Keys are animation names, values are keyframes step definitions.
|
|
@@ -951,28 +719,42 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
951
719
|
* - `#name` for color properties → `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
|
|
952
720
|
*
|
|
953
721
|
* Examples:
|
|
954
|
-
* - `'@
|
|
955
|
-
* - `'@
|
|
722
|
+
* - `'@property': { '$rotation': { syntax: '<angle>', inherits: false, initialValue: '45deg' } }`
|
|
723
|
+
* - `'@property': { '#theme': { initialValue: 'purple' } }` // syntax: '<color>' is auto-set
|
|
956
724
|
*/
|
|
957
|
-
'@
|
|
725
|
+
'@property'?: Record<string, PropertyDefinition>;
|
|
958
726
|
/**
|
|
959
727
|
* Local @font-face definitions for this component.
|
|
960
728
|
* Keys are font-family names, values are descriptors or arrays of descriptors
|
|
961
729
|
* (for multiple weights/styles of the same family).
|
|
962
730
|
*
|
|
963
731
|
* Examples:
|
|
964
|
-
* - `'@
|
|
965
|
-
* - `'@
|
|
732
|
+
* - `'@font-face': { Icons: { src: 'url("/fonts/icons.woff2") format("woff2")', fontDisplay: 'block' } }`
|
|
733
|
+
* - `'@font-face': { 'Brand Sans': [{ src: '...', fontWeight: 400 }, { src: '...', fontWeight: 700 }] }`
|
|
966
734
|
*/
|
|
967
|
-
'@
|
|
735
|
+
'@font-face'?: Record<string, FontFaceInput>;
|
|
968
736
|
/**
|
|
969
737
|
* Local @counter-style definitions for this component.
|
|
970
738
|
* Keys are counter-style names, values are descriptor objects.
|
|
971
739
|
*
|
|
972
740
|
* Examples:
|
|
973
|
-
* - `'@
|
|
741
|
+
* - `'@counter-style': { thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' } }`
|
|
742
|
+
*/
|
|
743
|
+
'@counter-style'?: Record<string, CounterStyleDescriptors>;
|
|
744
|
+
/**
|
|
745
|
+
* Local @function definitions (CSS custom functions) for this component.
|
|
746
|
+
* Keys are function names using `$$name` (the literal callable `--name`),
|
|
747
|
+
* matching the call site `$$name(...)`. Values are function definitions.
|
|
748
|
+
*
|
|
749
|
+
* Local variables are declared directly as `$name` keys on the descriptor;
|
|
750
|
+
* `result`, local-var values, and parameter defaults are parsed through the
|
|
751
|
+
* Tasty DSL (units, color tokens, auto-calc, fallbacks).
|
|
752
|
+
*
|
|
753
|
+
* Examples:
|
|
754
|
+
* - `'@function': { '$$negative': { args: ['$value'], result: '(-1 * $value)' } }`
|
|
755
|
+
* - `'@function': { '$$shadow': { args: { '$color': { syntax: '<color>', default: 'inherit' } }, returns: '<color>', '$offset': '2px', result: '$offset $offset ($color, black)' } }`
|
|
974
756
|
*/
|
|
975
|
-
'@
|
|
757
|
+
'@function'?: Record<string, FunctionDefinition>;
|
|
976
758
|
/**
|
|
977
759
|
* Apply one or more predefined style recipes by name.
|
|
978
760
|
* Recipes are defined globally via `configure({ recipes: { ... } })`.
|
|
@@ -993,8 +775,8 @@ type SuffixForSelector = '&' | '.' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | '
|
|
|
993
775
|
type Selector = `${SuffixForSelector}${string}`;
|
|
994
776
|
type NotSelector = Exclude<string, Selector | keyof StylesInterface>;
|
|
995
777
|
/** Special style keys that should not be wrapped in StyleValue/StyleValueStateMap */
|
|
996
|
-
type SpecialStyleKeys = '@keyframes' | '@
|
|
997
|
-
type StylesWithoutSelectors = { [key in keyof StylesInterface as key extends SpecialStyleKeys ? never : key]?: StyleValue<StylesInterface[key]> | StyleValueStateMap<StylesInterface[key]
|
|
778
|
+
type SpecialStyleKeys = '@keyframes' | '@property' | '@font-face' | '@counter-style' | '@function' | 'recipe';
|
|
779
|
+
type StylesWithoutSelectors = { [key in keyof StylesInterface as key extends SpecialStyleKeys ? never : key]?: StyleValue<StylesInterface[key]> | StyleValueStateMap<StylesInterface[key]>; };
|
|
998
780
|
/**
|
|
999
781
|
* Index signature for recipe-specific arbitrary keys.
|
|
1000
782
|
* Supports local predefined states (`@name`), vendor-prefixed CSS properties (`-webkit-*`),
|
|
@@ -1004,283 +786,760 @@ type StylesWithoutSelectors = { [key in keyof StylesInterface as key extends Spe
|
|
|
1004
786
|
type RecipeIndexSignature = Record<string, StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined>>;
|
|
1005
787
|
/**
|
|
1006
788
|
* Style type for recipe definitions.
|
|
1007
|
-
* Like StylesWithoutSelectors but also allows `@keyframes`, `@
|
|
789
|
+
* Like StylesWithoutSelectors but also allows `@keyframes`, `@property`,
|
|
1008
790
|
* local predefined states, and vendor-prefixed CSS properties.
|
|
1009
791
|
* Excludes `recipe` to prevent recursive references.
|
|
1010
792
|
*/
|
|
1011
793
|
type RecipeStyles = StylesWithoutSelectors & RecipeIndexSignature & {
|
|
1012
794
|
'@keyframes'?: StylesInterface['@keyframes'];
|
|
1013
|
-
'@
|
|
1014
|
-
'@
|
|
1015
|
-
'@
|
|
795
|
+
'@property'?: StylesInterface['@property'];
|
|
796
|
+
'@font-face'?: StylesInterface['@font-face'];
|
|
797
|
+
'@counter-style'?: StylesInterface['@counter-style'];
|
|
798
|
+
'@function'?: StylesInterface['@function'];
|
|
1016
799
|
};
|
|
1017
800
|
/** Special properties that are not regular style values */
|
|
1018
801
|
interface SpecialStyleProperties {
|
|
1019
802
|
'@keyframes'?: StylesInterface['@keyframes'];
|
|
1020
|
-
'@
|
|
1021
|
-
'@
|
|
1022
|
-
'@
|
|
803
|
+
'@property'?: StylesInterface['@property'];
|
|
804
|
+
'@font-face'?: StylesInterface['@font-face'];
|
|
805
|
+
'@counter-style'?: StylesInterface['@counter-style'];
|
|
806
|
+
'@function'?: StylesInterface['@function'];
|
|
1023
807
|
recipe?: StylesInterface['recipe'];
|
|
1024
808
|
}
|
|
1025
809
|
/** Index signature for arbitrary style keys (sub-elements, CSS variables, etc.) */
|
|
1026
810
|
interface StylesIndexSignature {
|
|
1027
|
-
[key: string]: StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined> | Styles | false | StylesInterface['@keyframes'] | StylesInterface['@
|
|
811
|
+
[key: string]: StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined> | Styles | false | StylesInterface['@keyframes'] | StylesInterface['@property'] | StylesInterface['@font-face'] | StylesInterface['@counter-style'] | StylesInterface['@function'];
|
|
1028
812
|
/**
|
|
1029
813
|
* Selector combinator: `undefined` (descendant, default), `'>'` (child), `'+'` (adjacent), `'~'` (sibling).
|
|
1030
814
|
* Can chain with capitalized names: `'> Body > Row >'`. Spaces required around combinators.
|
|
1031
815
|
*/
|
|
1032
816
|
$?: string;
|
|
1033
817
|
}
|
|
1034
|
-
type Styles = StylesWithoutSelectors & SpecialStyleProperties & StylesIndexSignature;
|
|
818
|
+
type Styles = StylesWithoutSelectors & SpecialStyleProperties & StylesIndexSignature;
|
|
819
|
+
/**
|
|
820
|
+
* Value type for design tokens passed to `configure({ tokens })`.
|
|
821
|
+
* Can be a direct value or a state map for responsive/theme-aware tokens.
|
|
822
|
+
*/
|
|
823
|
+
type ConfigTokenValue = string | number | boolean | Record<string, string | number | boolean | undefined | null | '@inherit'>;
|
|
824
|
+
/**
|
|
825
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
826
|
+
* Keys must start with `$` (value tokens) or `#` (color tokens).
|
|
827
|
+
*
|
|
828
|
+
* - `$name` keys become `--name` CSS custom properties
|
|
829
|
+
* - `#name` keys become `--name-color` properties
|
|
830
|
+
*/
|
|
831
|
+
type ConfigTokens = Record<`$${string}` | `#${string}`, ConfigTokenValue>;
|
|
832
|
+
/**
|
|
833
|
+
* ConditionNode Types and Helpers
|
|
834
|
+
*
|
|
835
|
+
* Core data structures for representing style conditions as an abstract syntax tree.
|
|
836
|
+
* Used throughout the pipeline for parsing, simplification, and CSS generation.
|
|
837
|
+
*/
|
|
838
|
+
/**
|
|
839
|
+
* Base interface for all state conditions (leaf nodes)
|
|
840
|
+
*/
|
|
841
|
+
interface BaseStateCondition {
|
|
842
|
+
kind: 'state';
|
|
843
|
+
negated: boolean;
|
|
844
|
+
raw: string;
|
|
845
|
+
uniqueId: string;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Modifier condition: [data-attr] or [data-attr="value"]
|
|
849
|
+
*/
|
|
850
|
+
interface ModifierCondition extends BaseStateCondition {
|
|
851
|
+
type: 'modifier';
|
|
852
|
+
attribute: string;
|
|
853
|
+
value?: string;
|
|
854
|
+
operator?: '=' | '^=' | '$=' | '*=';
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Pseudo-class condition: :hover, :focus-visible
|
|
858
|
+
*/
|
|
859
|
+
interface PseudoCondition extends BaseStateCondition {
|
|
860
|
+
type: 'pseudo';
|
|
861
|
+
pseudo: string;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Numeric bound for dimension queries
|
|
865
|
+
*/
|
|
866
|
+
interface NumericBound {
|
|
867
|
+
value: string;
|
|
868
|
+
valueNumeric: number | null;
|
|
869
|
+
inclusive: boolean;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Media query condition
|
|
873
|
+
*/
|
|
874
|
+
interface MediaCondition extends BaseStateCondition {
|
|
875
|
+
type: 'media';
|
|
876
|
+
subtype: 'dimension' | 'feature' | 'type';
|
|
877
|
+
dimension?: 'width' | 'height' | 'inline-size' | 'block-size';
|
|
878
|
+
lowerBound?: NumericBound;
|
|
879
|
+
upperBound?: NumericBound;
|
|
880
|
+
feature?: string;
|
|
881
|
+
featureValue?: string;
|
|
882
|
+
mediaType?: 'print' | 'screen' | 'all' | 'speech';
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Container query condition
|
|
886
|
+
*/
|
|
887
|
+
interface ContainerCondition extends BaseStateCondition {
|
|
888
|
+
type: 'container';
|
|
889
|
+
subtype: 'dimension' | 'style' | 'raw';
|
|
890
|
+
containerName?: string;
|
|
891
|
+
dimension?: 'width' | 'height' | 'inline-size' | 'block-size';
|
|
892
|
+
lowerBound?: NumericBound;
|
|
893
|
+
upperBound?: NumericBound;
|
|
894
|
+
property?: string;
|
|
895
|
+
propertyValue?: string;
|
|
896
|
+
rawCondition?: string;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Root state condition: @root(theme=dark)
|
|
900
|
+
*/
|
|
901
|
+
interface RootCondition extends BaseStateCondition {
|
|
902
|
+
type: 'root';
|
|
903
|
+
innerCondition: ConditionNode;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Parent state condition: @parent(hovered), @parent(theme=dark, >)
|
|
907
|
+
*/
|
|
908
|
+
interface ParentCondition extends BaseStateCondition {
|
|
909
|
+
type: 'parent';
|
|
910
|
+
innerCondition: ConditionNode;
|
|
911
|
+
direct: boolean;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Own state condition: @own(hovered)
|
|
915
|
+
*/
|
|
916
|
+
interface OwnCondition extends BaseStateCondition {
|
|
917
|
+
type: 'own';
|
|
918
|
+
innerCondition: ConditionNode;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Starting style condition: @starting
|
|
922
|
+
*/
|
|
923
|
+
interface StartingCondition extends BaseStateCondition {
|
|
924
|
+
type: 'starting';
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Supports query condition: @supports(display: grid), @supports($, :has(*))
|
|
928
|
+
*/
|
|
929
|
+
interface SupportsCondition extends BaseStateCondition {
|
|
930
|
+
type: 'supports';
|
|
931
|
+
subtype: 'feature' | 'selector';
|
|
932
|
+
condition: string;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Union of all state condition types
|
|
936
|
+
*/
|
|
937
|
+
type StateCondition = ModifierCondition | PseudoCondition | MediaCondition | ContainerCondition | RootCondition | ParentCondition | OwnCondition | StartingCondition | SupportsCondition;
|
|
938
|
+
/**
|
|
939
|
+
* Compound node: combines conditions with AND/OR
|
|
940
|
+
*/
|
|
941
|
+
interface CompoundCondition {
|
|
942
|
+
kind: 'compound';
|
|
943
|
+
operator: 'AND' | 'OR';
|
|
944
|
+
children: ConditionNode[];
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* True condition (matches everything)
|
|
948
|
+
*/
|
|
949
|
+
interface TrueCondition {
|
|
950
|
+
kind: 'true';
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* False condition (matches nothing - skip this rule)
|
|
954
|
+
*/
|
|
955
|
+
interface FalseCondition {
|
|
956
|
+
kind: 'false';
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Union of all condition node types
|
|
960
|
+
*/
|
|
961
|
+
type ConditionNode = StateCondition | CompoundCondition | TrueCondition | FalseCondition;
|
|
962
|
+
/**
|
|
963
|
+
* Parsed advanced state information
|
|
964
|
+
*/
|
|
965
|
+
interface ParsedAdvancedState {
|
|
966
|
+
type: 'media' | 'container' | 'root' | 'parent' | 'own' | 'starting' | 'predefined' | 'modifier';
|
|
967
|
+
condition: string;
|
|
968
|
+
containerName?: string;
|
|
969
|
+
raw: string;
|
|
970
|
+
mediaType?: string;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Context for state parsing operations
|
|
974
|
+
*/
|
|
975
|
+
interface StateParserContext {
|
|
976
|
+
localPredefinedStates: Record<string, string>;
|
|
977
|
+
globalPredefinedStates: Record<string, string>;
|
|
978
|
+
isSubElement?: boolean;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* At-rule context for CSS generation
|
|
982
|
+
*/
|
|
983
|
+
interface AtRuleContext {
|
|
984
|
+
media?: string[];
|
|
985
|
+
container?: {
|
|
986
|
+
name?: string;
|
|
987
|
+
condition: string;
|
|
988
|
+
}[];
|
|
989
|
+
startingStyle?: boolean;
|
|
990
|
+
rootStates?: string[];
|
|
991
|
+
negatedRootStates?: string[];
|
|
992
|
+
}
|
|
1035
993
|
/**
|
|
1036
|
-
*
|
|
1037
|
-
* Can be a direct value or a state map for responsive/theme-aware tokens.
|
|
994
|
+
* Configure global predefined states
|
|
1038
995
|
*/
|
|
1039
|
-
|
|
996
|
+
declare function setGlobalPredefinedStates(states: Record<string, string>): void;
|
|
1040
997
|
/**
|
|
1041
|
-
*
|
|
1042
|
-
* Keys must start with `$` (value tokens) or `#` (color tokens).
|
|
1043
|
-
*
|
|
1044
|
-
* - `$name` keys become `--name` CSS custom properties
|
|
1045
|
-
* - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties
|
|
998
|
+
* Get global predefined states
|
|
1046
999
|
*/
|
|
1047
|
-
|
|
1048
|
-
//#endregion
|
|
1049
|
-
//#region src/pipeline/conditions.d.ts
|
|
1000
|
+
declare function getGlobalPredefinedStates(): Record<string, string>;
|
|
1050
1001
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
* Core data structures for representing style conditions as an abstract syntax tree.
|
|
1054
|
-
* Used throughout the pipeline for parsing, simplification, and CSS generation.
|
|
1002
|
+
* Create a state parser context from styles
|
|
1055
1003
|
*/
|
|
1004
|
+
declare function createStateParserContext(styles?: Styles, isSubElement?: boolean): StateParserContext;
|
|
1005
|
+
interface ParseStateKeyOptions {
|
|
1006
|
+
context?: StateParserContext;
|
|
1007
|
+
isSubElement?: boolean;
|
|
1008
|
+
}
|
|
1056
1009
|
/**
|
|
1057
|
-
*
|
|
1010
|
+
* Parse a state key string into a ConditionNode
|
|
1058
1011
|
*/
|
|
1059
|
-
|
|
1060
|
-
kind: 'state';
|
|
1061
|
-
negated: boolean;
|
|
1062
|
-
raw: string;
|
|
1063
|
-
uniqueId: string;
|
|
1064
|
-
}
|
|
1012
|
+
declare function parseStateKey(stateKey: string, options?: ParseStateKeyOptions): ConditionNode;
|
|
1065
1013
|
/**
|
|
1066
|
-
*
|
|
1014
|
+
* Matches the old StyleResult interface for backward compatibility
|
|
1067
1015
|
*/
|
|
1068
|
-
interface
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1016
|
+
interface StyleResult {
|
|
1017
|
+
selector: string;
|
|
1018
|
+
declarations: string;
|
|
1019
|
+
atRules?: string[];
|
|
1020
|
+
needsClassName?: boolean;
|
|
1021
|
+
rootPrefix?: string;
|
|
1022
|
+
/** When true, declarations are wrapped in @starting-style { ... } inside the selector rule */
|
|
1023
|
+
startingStyle?: boolean;
|
|
1073
1024
|
}
|
|
1074
1025
|
/**
|
|
1075
|
-
*
|
|
1026
|
+
* Matches the old RenderResult interface for backward compatibility
|
|
1076
1027
|
*/
|
|
1077
|
-
interface
|
|
1078
|
-
|
|
1079
|
-
|
|
1028
|
+
interface RenderResult {
|
|
1029
|
+
rules: StyleResult[];
|
|
1030
|
+
className?: string;
|
|
1080
1031
|
}
|
|
1081
1032
|
/**
|
|
1082
|
-
*
|
|
1033
|
+
* Options for renderStyles when using direct selector mode.
|
|
1083
1034
|
*/
|
|
1084
|
-
interface
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1035
|
+
interface RenderStylesOptions {
|
|
1036
|
+
/**
|
|
1037
|
+
* Whether to double the class selector for increased specificity.
|
|
1038
|
+
* When true, `.myClass` becomes `.myClass.myClass` for higher specificity.
|
|
1039
|
+
*
|
|
1040
|
+
* @default false - User-provided selectors are not doubled.
|
|
1041
|
+
*
|
|
1042
|
+
* Note: This only applies when a classNameOrSelector is provided.
|
|
1043
|
+
* When renderStyles returns RenderResult with needsClassName=true,
|
|
1044
|
+
* the injector handles doubling automatically.
|
|
1045
|
+
*/
|
|
1046
|
+
doubleSelector?: boolean;
|
|
1088
1047
|
}
|
|
1089
1048
|
/**
|
|
1090
|
-
*
|
|
1049
|
+
* Render styles to CSS rules.
|
|
1050
|
+
*
|
|
1051
|
+
* When called without classNameOrSelector, returns RenderResult with needsClassName=true.
|
|
1052
|
+
* When called with a selector/className string, returns StyleResult[] for direct injection.
|
|
1091
1053
|
*/
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1054
|
+
declare function renderStyles(styles?: Styles, classNameOrSelector?: undefined, options?: undefined, pipelineCacheKey?: string): RenderResult;
|
|
1055
|
+
declare function renderStyles(styles: Styles | undefined, classNameOrSelector: string, options?: RenderStylesOptions): StyleResult[];
|
|
1056
|
+
/**
|
|
1057
|
+
* PropertyTypeResolver
|
|
1058
|
+
*
|
|
1059
|
+
* Automatically infers CSS @property types from custom property values.
|
|
1060
|
+
* Supports deferred resolution for var() reference chains of arbitrary depth.
|
|
1061
|
+
*/
|
|
1062
|
+
declare class PropertyTypeResolver {
|
|
1063
|
+
/** propName → the prop it depends on */
|
|
1064
|
+
private pendingDeps;
|
|
1065
|
+
/** propName → list of props waiting on it */
|
|
1066
|
+
private reverseDeps;
|
|
1067
|
+
/**
|
|
1068
|
+
* Scan CSS declarations and auto-register @property for custom properties
|
|
1069
|
+
* whose types can be inferred from their values.
|
|
1070
|
+
*/
|
|
1071
|
+
scanDeclarations(declarations: string, isPropertyDefined: (name: string) => boolean, registerProperty: (name: string, syntax: string, initialValue: string) => void): void;
|
|
1072
|
+
private addDependency;
|
|
1073
|
+
private resolve;
|
|
1074
|
+
private isComplexValue;
|
|
1101
1075
|
}
|
|
1102
1076
|
/**
|
|
1103
|
-
*
|
|
1077
|
+
* Deferred CSSOM writes ("batched injection").
|
|
1078
|
+
*
|
|
1079
|
+
* Every `insertRule()` on a live stylesheet invalidates style for the sheet's
|
|
1080
|
+
* scope, so Blink recalculates style the next time anything reads layout or
|
|
1081
|
+
* computed style. When components inject during React's render phase and other
|
|
1082
|
+
* components read layout in the same pass, the two interleave:
|
|
1083
|
+
*
|
|
1084
|
+
* inject -> read (forced recalc) -> inject -> read (forced recalc) -> ...
|
|
1085
|
+
*
|
|
1086
|
+
* Batching moves every sheet write out from between those reads. Writes are
|
|
1087
|
+
* queued in FIFO order and drained in one go, so the tree is invalidated once
|
|
1088
|
+
* per flush instead of once per component.
|
|
1089
|
+
*
|
|
1090
|
+
* ## Ordering
|
|
1091
|
+
*
|
|
1092
|
+
* A single queue holds *all* writes — component rules, global rules, keyframes,
|
|
1093
|
+
* `@property`, `@font-face`, `@counter-style`, `@function` and raw CSS. Draining
|
|
1094
|
+
* it in insertion order keeps the sheet byte-identical to unbatched output,
|
|
1095
|
+
* which matters because equal-specificity rules resolve by document order.
|
|
1096
|
+
*
|
|
1097
|
+
* ## Batch windows — why queuing is safe
|
|
1098
|
+
*
|
|
1099
|
+
* Deferring a write past React's layout phase would let a `useLayoutEffect`
|
|
1100
|
+
* measure an element whose rules are not in the sheet yet, reading the unstyled
|
|
1101
|
+
* box. `<TastyBatchProvider>` closes that hole by opening a *window* during its
|
|
1102
|
+
* render and closing it — flushing — in its `useInsertionEffect`, which React
|
|
1103
|
+
* runs in the mutation phase, before any layout effect:
|
|
1104
|
+
*
|
|
1105
|
+
* provider renders -> window OPEN
|
|
1106
|
+
* children render -> injections queued
|
|
1107
|
+
* provider insertionEffect -> FLUSH, window CLOSED
|
|
1108
|
+
* layout effects run -> rules are in the sheet
|
|
1109
|
+
*
|
|
1110
|
+
* So in the default (`batchInjection: true`) mode a write is only ever queued
|
|
1111
|
+
* inside a commit whose flush is already guaranteed by that same commit. Every
|
|
1112
|
+
* injection outside a window — a deep update the provider did not re-render
|
|
1113
|
+
* for, a `useLayoutEffect` that injects, an event handler, an async callback —
|
|
1114
|
+
* is written straight through, exactly as with batching off.
|
|
1115
|
+
*
|
|
1116
|
+
* `batchInjection: 'always'` opts out of the gate and queues unconditionally.
|
|
1117
|
+
* That wins on more commits, at the cost of the measurement hazard above.
|
|
1118
|
+
*
|
|
1119
|
+
* ## Flush points (earliest wins)
|
|
1120
|
+
*
|
|
1121
|
+
* 1. `<TastyBatchProvider>`'s `useInsertionEffect` — closes the window.
|
|
1122
|
+
* 2. A microtask — a backstop for a render that was aborted or suspended and
|
|
1123
|
+
* therefore never reached its insertion effect. An aborted render mounts
|
|
1124
|
+
* nothing, so nothing can measure what it queued. Microtasks also always
|
|
1125
|
+
* drain before paint, so styles are never visually missing.
|
|
1126
|
+
* 3. `flushStyles()` — explicit, and called internally by every injector read
|
|
1127
|
+
* API (`getCSSText`, `cleanup`, `gc`, `destroy`, ...).
|
|
1104
1128
|
*/
|
|
1105
|
-
interface
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
property?: string;
|
|
1113
|
-
propertyValue?: string;
|
|
1114
|
-
rawCondition?: string;
|
|
1129
|
+
interface QueuedWrite {
|
|
1130
|
+
/** Perform the deferred sheet write. */
|
|
1131
|
+
run: () => void;
|
|
1132
|
+
/** Set when the owner disposed before the write happened. */
|
|
1133
|
+
cancelled: boolean;
|
|
1134
|
+
/** Set once the write has been applied (or skipped as cancelled). */
|
|
1135
|
+
done: boolean;
|
|
1115
1136
|
}
|
|
1137
|
+
/** Whether any write is still waiting to hit a stylesheet. */
|
|
1138
|
+
declare function hasPendingStyleWrites(): boolean;
|
|
1116
1139
|
/**
|
|
1117
|
-
*
|
|
1140
|
+
* Drain every pending sheet write, in insertion order.
|
|
1141
|
+
*
|
|
1142
|
+
* Safe to call when the queue is empty (the common case, so the guard comes
|
|
1143
|
+
* first) and safe to call re-entrantly: a nested `flushStyles()` is a no-op,
|
|
1144
|
+
* and work a draining write triggers is written in place by
|
|
1145
|
+
* `enqueueStyleWrite` rather than queued behind the rest of the batch.
|
|
1118
1146
|
*/
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1147
|
+
declare function flushStyles(): void;
|
|
1148
|
+
/**
|
|
1149
|
+
* Drop every pending write without applying it. Test helper — production code
|
|
1150
|
+
* should call `flushStyles()` instead.
|
|
1151
|
+
*/
|
|
1152
|
+
declare function resetStyleBatch(): void;
|
|
1153
|
+
declare global {
|
|
1154
|
+
interface Window {
|
|
1155
|
+
__TASTY__?: string[];
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
interface InjectResult {
|
|
1159
|
+
className: string;
|
|
1160
|
+
dispose: () => void;
|
|
1161
|
+
}
|
|
1162
|
+
interface GlobalInjectResult {
|
|
1163
|
+
dispose: () => void;
|
|
1164
|
+
}
|
|
1165
|
+
type DisposeFunction = () => void;
|
|
1166
|
+
interface StyleInjectorConfig {
|
|
1167
|
+
nonce?: string;
|
|
1168
|
+
maxRulesPerSheet?: number;
|
|
1169
|
+
forceTextInjection?: boolean;
|
|
1170
|
+
/** Enable development mode features: performance metrics and debug information storage */
|
|
1171
|
+
devMode?: boolean;
|
|
1172
|
+
/**
|
|
1173
|
+
* Global predefined states for advanced state mapping.
|
|
1174
|
+
* These are state aliases that can be used in any component.
|
|
1175
|
+
* Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
|
|
1176
|
+
*/
|
|
1177
|
+
states?: Record<string, string>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Automatically infer and register CSS @property declarations
|
|
1180
|
+
* from custom property values. When false, only explicit @property are used.
|
|
1181
|
+
* @default true
|
|
1182
|
+
*/
|
|
1183
|
+
autoPropertyTypes?: boolean;
|
|
1184
|
+
/** Garbage collection configuration for unused styles */
|
|
1185
|
+
gc?: GCConfig;
|
|
1186
|
+
/**
|
|
1187
|
+
* Prefix prepended to every generated identifier.
|
|
1188
|
+
* Mirrors the `namePrefix` field on the public `TastyConfig` so that
|
|
1189
|
+
* standalone injector consumers can configure it directly.
|
|
1190
|
+
* @default 't'
|
|
1191
|
+
*/
|
|
1192
|
+
namePrefix?: string;
|
|
1193
|
+
/**
|
|
1194
|
+
* Defer stylesheet writes and apply them in one batch instead of one
|
|
1195
|
+
* `insertRule()` per component. Mirrors `batchInjection` on the public
|
|
1196
|
+
* `TastyConfig`.
|
|
1197
|
+
* @default false
|
|
1198
|
+
*/
|
|
1199
|
+
batchInjection?: boolean | 'always';
|
|
1122
1200
|
}
|
|
1123
1201
|
/**
|
|
1124
|
-
*
|
|
1202
|
+
* Per-className usage tracking for GC.
|
|
1125
1203
|
*/
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1204
|
+
/**
|
|
1205
|
+
* @deprecated Nothing reads this any more. Collection asks the DOM what is
|
|
1206
|
+
* rendered rather than tracking usage per class, so there is no usage record
|
|
1207
|
+
* to describe. Kept so existing imports keep type-checking.
|
|
1208
|
+
*/
|
|
1209
|
+
interface StyleUsage {
|
|
1210
|
+
lastTouchedAt: number;
|
|
1130
1211
|
}
|
|
1131
1212
|
/**
|
|
1132
|
-
*
|
|
1213
|
+
* Configuration for the style garbage collector.
|
|
1214
|
+
*
|
|
1215
|
+
* GC is triggered by touch count rather than timers: every `touchInterval`
|
|
1216
|
+
* touches, an idle callback is scheduled to evict unused styles above
|
|
1217
|
+
* `capacity`, oldest first.
|
|
1133
1218
|
*/
|
|
1134
|
-
interface
|
|
1135
|
-
|
|
1136
|
-
|
|
1219
|
+
interface GCConfig {
|
|
1220
|
+
/**
|
|
1221
|
+
* How long a class is left alone after collection first notices nothing is
|
|
1222
|
+
* carrying it, in milliseconds (default 10,000).
|
|
1223
|
+
*
|
|
1224
|
+
* Rendering is not commit-aware: a render can resolve a class and commit it a
|
|
1225
|
+
* little later, and in between nothing on the page carries it. Rather than
|
|
1226
|
+
* try to tell that apart from a class that is finished — which cannot be done
|
|
1227
|
+
* from outside React — collection simply does not touch anything that was in
|
|
1228
|
+
* use recently. A render would have to stay pending for the whole window to
|
|
1229
|
+
* lose its rules, and it gets them back on its next render.
|
|
1230
|
+
*/
|
|
1231
|
+
grace?: number;
|
|
1232
|
+
/**
|
|
1233
|
+
* Number of touch events between automatic GC cycles.
|
|
1234
|
+
* @default 1000
|
|
1235
|
+
*/
|
|
1236
|
+
touchInterval?: number;
|
|
1237
|
+
/**
|
|
1238
|
+
* Maximum number of unused styles to retain.
|
|
1239
|
+
* GC evicts the oldest unused styles when this limit is exceeded.
|
|
1240
|
+
* Pinned styles and DOM-live styles
|
|
1241
|
+
* do not count against this limit.
|
|
1242
|
+
* @default 1000
|
|
1243
|
+
*/
|
|
1244
|
+
capacity?: number;
|
|
1137
1245
|
}
|
|
1138
1246
|
/**
|
|
1139
|
-
*
|
|
1247
|
+
* Per-call options for inject().
|
|
1140
1248
|
*/
|
|
1141
|
-
interface
|
|
1142
|
-
|
|
1249
|
+
interface InjectOptions {
|
|
1250
|
+
root?: Document | ShadowRoot;
|
|
1251
|
+
/** Reuse the class already injected for this key instead of writing again. */
|
|
1252
|
+
cacheKey?: string;
|
|
1253
|
+
/**
|
|
1254
|
+
* Pin the injected class (default `true`). A pinned class is never evicted by
|
|
1255
|
+
* `gc()`, and the returned `dispose()` releases the pin. Pass `false` when the
|
|
1256
|
+
* caller keeps no handle and the DOM is the only record that the class is in
|
|
1257
|
+
* use — the render path does this, because a hook-free render has no unmount
|
|
1258
|
+
* signal to dispose on.
|
|
1259
|
+
*/
|
|
1260
|
+
pin?: boolean;
|
|
1143
1261
|
}
|
|
1144
1262
|
/**
|
|
1145
|
-
*
|
|
1263
|
+
* Per-call options for gc().
|
|
1146
1264
|
*/
|
|
1147
|
-
interface
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1265
|
+
interface GCOptions {
|
|
1266
|
+
root?: Document | ShadowRoot;
|
|
1267
|
+
/** Bypass capacity threshold and remove ALL unused styles. */
|
|
1268
|
+
force?: boolean;
|
|
1269
|
+
}
|
|
1270
|
+
interface RuleInfo {
|
|
1271
|
+
className: string;
|
|
1272
|
+
ruleIndex: number;
|
|
1273
|
+
sheetIndex: number;
|
|
1274
|
+
/** Dev-only: full CSS texts inserted for this class; omitted in production */
|
|
1275
|
+
cssText?: string[];
|
|
1276
|
+
/** Inclusive end index of the contiguous block of inserted rules for this className */
|
|
1277
|
+
endRuleIndex?: number;
|
|
1278
|
+
/** NEW: exact indices of all inserted rules for this className */
|
|
1279
|
+
indices?: number[];
|
|
1280
|
+
}
|
|
1281
|
+
type InjectionMode = 'style-element' | 'adopted';
|
|
1282
|
+
interface SheetInfo {
|
|
1283
|
+
/** HTMLStyleElement used in style-element mode; null in adopted mode. */
|
|
1284
|
+
sheet: HTMLStyleElement | null;
|
|
1285
|
+
/** Constructable CSSStyleSheet used in adopted mode (ShadowRoot targets) */
|
|
1286
|
+
constructableSheet?: CSSStyleSheet;
|
|
1287
|
+
ruleCount: number;
|
|
1288
|
+
holes: number[];
|
|
1289
|
+
/**
|
|
1290
|
+
* True when this sheet is written through `textContent` instead of CSSOM.
|
|
1291
|
+
* Decided once at sheet creation so a sheet is never half CSSOM / half text.
|
|
1292
|
+
*/
|
|
1293
|
+
textMode?: boolean;
|
|
1294
|
+
/**
|
|
1295
|
+
* Inserted rule texts in rule-index order. Maintained only in text mode —
|
|
1296
|
+
* it is what makes deletion possible there, since `textContent` cannot be
|
|
1297
|
+
* edited rule-by-rule and has to be rebuilt.
|
|
1298
|
+
*/
|
|
1299
|
+
textRules?: string[];
|
|
1300
|
+
}
|
|
1301
|
+
interface CleanupStats {
|
|
1302
|
+
timestamp: number;
|
|
1303
|
+
classesDeleted: number;
|
|
1304
|
+
cssSize: number;
|
|
1305
|
+
rulesDeleted: number;
|
|
1151
1306
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
children: ConditionNode[];
|
|
1307
|
+
interface CacheMetrics {
|
|
1308
|
+
hits: number;
|
|
1309
|
+
misses: number;
|
|
1310
|
+
bulkCleanups: number;
|
|
1311
|
+
totalInsertions: number;
|
|
1312
|
+
totalUnused: number;
|
|
1313
|
+
stylesCleanedUp: number;
|
|
1314
|
+
cleanupHistory: CleanupStats[];
|
|
1315
|
+
startTime: number;
|
|
1316
|
+
unusedHits?: number;
|
|
1163
1317
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
*/
|
|
1167
|
-
|
|
1168
|
-
|
|
1318
|
+
interface RootRegistry {
|
|
1319
|
+
sheets: SheetInfo[];
|
|
1320
|
+
/** className -> outstanding `inject()` references; 0 means nobody holds a handle */
|
|
1321
|
+
pinCounts: Map<string, number>;
|
|
1322
|
+
rules: Map<string, RuleInfo>;
|
|
1323
|
+
/** Cache key to className mapping to avoid dual storage of RuleInfo objects */
|
|
1324
|
+
cacheKeyToClassName: Map<string, string>;
|
|
1325
|
+
/** Deduplication set of fully materialized CSS rules inserted into sheets */
|
|
1326
|
+
ruleTextSet: Set<string>;
|
|
1327
|
+
/** Performance metrics (optional) */
|
|
1328
|
+
metrics?: CacheMetrics;
|
|
1329
|
+
/** Keyframes cache by content hash -> entry */
|
|
1330
|
+
keyframesCache: Map<string, KeyframesCacheEntry>;
|
|
1331
|
+
/** Keyframes name to content hash mapping for collision detection */
|
|
1332
|
+
keyframesNameToContent: Map<string, string>;
|
|
1333
|
+
/** Counter for generating keyframes names like k0, k1, k2... */
|
|
1334
|
+
keyframesCounter: number;
|
|
1335
|
+
/** Map of injected @property names to their normalized declarations for tracking */
|
|
1336
|
+
injectedProperties: Map<string, string>;
|
|
1337
|
+
/** Content hashes of injected @font-face rules for deduplication */
|
|
1338
|
+
injectedFontFaces: Set<string>;
|
|
1339
|
+
/**
|
|
1340
|
+
* Injected @counter-style rules. Maps the name to whether it was injected
|
|
1341
|
+
* "strong" (`true`, the default — overrides) or "weak" (`false`, global
|
|
1342
|
+
* `configure()` definitions that never clobber an existing rule).
|
|
1343
|
+
*/
|
|
1344
|
+
injectedCounterStyles: Map<string, boolean>;
|
|
1345
|
+
/**
|
|
1346
|
+
* Injected @function rules. Maps the CSS function name to whether it was
|
|
1347
|
+
* injected "strong" (`true`, the default — overrides) or "weak" (`false`,
|
|
1348
|
+
* global `configure()` definitions that never clobber an existing rule).
|
|
1349
|
+
*/
|
|
1350
|
+
injectedFunctions: Map<string, boolean>;
|
|
1351
|
+
/** Global rules tracking for index adjustment */
|
|
1352
|
+
globalRules: Map<string, RuleInfo>;
|
|
1353
|
+
/** Resolver for auto-inferring @property types from declaration values */
|
|
1354
|
+
propertyTypeResolver: PropertyTypeResolver;
|
|
1355
|
+
/**
|
|
1356
|
+
* className -> when the class was first noticed to be carrying nothing:
|
|
1357
|
+
* injection, or the first sweep that looked and did not find it on an
|
|
1358
|
+
* element. Cleared the moment a sweep finds it rendered again.
|
|
1359
|
+
*
|
|
1360
|
+
* Deliberately "when it was noticed", not "when it stopped being rendered".
|
|
1361
|
+
* Nothing observes the moment an element leaves, so a class that unmounted
|
|
1362
|
+
* just before a sweep and one that unmounted just after the previous sweep
|
|
1363
|
+
* would otherwise be treated differently — and the first would lose its
|
|
1364
|
+
* grace window entirely. Starting the clock at the sighting gives every
|
|
1365
|
+
* class the same full window, whenever it actually went.
|
|
1366
|
+
*
|
|
1367
|
+
* Written only by the sweep's own DOM scan and at injection, so rendering
|
|
1368
|
+
* never pays for it.
|
|
1369
|
+
*/
|
|
1370
|
+
unusedSince: Map<string, number>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Local `@keyframes` a class animates, by the name they were authored under.
|
|
1373
|
+
*
|
|
1374
|
+
* One reference is held per distinct set of steps, however many renders ask
|
|
1375
|
+
* for it, and the classes that animate it own that reference between them.
|
|
1376
|
+
* The last of them to be deleted releases it, so keyframes cannot outlive
|
|
1377
|
+
* every rule that referred to them, and repeat renders cannot pile up
|
|
1378
|
+
* references nobody gives back.
|
|
1379
|
+
*/
|
|
1380
|
+
localKeyframes: Map<string, {
|
|
1381
|
+
name: string;
|
|
1382
|
+
dispose: () => void;
|
|
1383
|
+
owners: Set<string>;
|
|
1384
|
+
}>;
|
|
1385
|
+
/** Renders since the last scheduled sweep (per-root) */
|
|
1386
|
+
touchCount: number;
|
|
1387
|
+
/** How many entries from `window.__TASTY__` have been synced into this registry */
|
|
1388
|
+
serverClassSyncIndex: number;
|
|
1389
|
+
/** Whether `<style data-tasty-rsc>` tags have been scanned for class names */
|
|
1390
|
+
rscStylesScanned: boolean;
|
|
1391
|
+
/** Whether this root uses adoptedStyleSheets or <style> elements */
|
|
1392
|
+
injectionMode: InjectionMode;
|
|
1393
|
+
/**
|
|
1394
|
+
* Lazy feature-test for `@property` support, cached per registry.
|
|
1395
|
+
* - `undefined`: not yet probed.
|
|
1396
|
+
* - `true`: engine supports `@property`; rejections indicate user-authored
|
|
1397
|
+
* invalid rules and should warn.
|
|
1398
|
+
* - `false`: engine doesn't support `@property` (e.g., jsdom); rejections
|
|
1399
|
+
* are expected and warnings are suppressed.
|
|
1400
|
+
*/
|
|
1401
|
+
atPropertySupported?: boolean;
|
|
1169
1402
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1403
|
+
type StyleRule = StyleResult;
|
|
1404
|
+
interface KeyframesInfo {
|
|
1405
|
+
name: string;
|
|
1406
|
+
sheetIndex: number;
|
|
1407
|
+
ruleIndex: number;
|
|
1408
|
+
/** Dev-only: full CSS text of the @keyframes rule; omitted in production */
|
|
1409
|
+
cssText?: string;
|
|
1175
1410
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
//#region src/states/index.d.ts
|
|
1182
|
-
/**
|
|
1183
|
-
* Parsed advanced state information
|
|
1184
|
-
*/
|
|
1185
|
-
interface ParsedAdvancedState {
|
|
1186
|
-
type: 'media' | 'container' | 'root' | 'parent' | 'own' | 'starting' | 'predefined' | 'modifier';
|
|
1187
|
-
condition: string;
|
|
1188
|
-
containerName?: string;
|
|
1189
|
-
raw: string;
|
|
1190
|
-
mediaType?: string;
|
|
1411
|
+
type KeyframeStep = string | Record<string, string | number>;
|
|
1412
|
+
type KeyframesSteps = Record<string, KeyframeStep>;
|
|
1413
|
+
interface KeyframesResult {
|
|
1414
|
+
toString(): string;
|
|
1415
|
+
dispose: () => void;
|
|
1191
1416
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1417
|
+
interface KeyframesCacheEntry {
|
|
1418
|
+
name: string;
|
|
1419
|
+
refCount: number;
|
|
1420
|
+
info: KeyframesInfo;
|
|
1421
|
+
/**
|
|
1422
|
+
* Queued sheet write, when `batchInjection` deferred the insertion. Present
|
|
1423
|
+
* only between `keyframes()` and the flush; disposing in that window cancels
|
|
1424
|
+
* the write instead of deleting a rule that was never inserted.
|
|
1425
|
+
*/
|
|
1426
|
+
pending?: QueuedWrite;
|
|
1199
1427
|
}
|
|
1200
1428
|
/**
|
|
1201
|
-
*
|
|
1429
|
+
* Definition for a CSS @property at-rule.
|
|
1430
|
+
* Used to define custom property syntax, inheritance, and initial value.
|
|
1202
1431
|
*/
|
|
1203
|
-
interface
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
rootStates?: string[];
|
|
1211
|
-
negatedRootStates?: string[];
|
|
1432
|
+
interface PropertyDefinition {
|
|
1433
|
+
/** CSS syntax string (e.g., '<color>', '<angle>', '<number>') */
|
|
1434
|
+
syntax?: string;
|
|
1435
|
+
/** Whether the property inherits (default: true) */
|
|
1436
|
+
inherits?: boolean;
|
|
1437
|
+
/** Initial value for the property */
|
|
1438
|
+
initialValue?: string | number;
|
|
1212
1439
|
}
|
|
1213
1440
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
|
|
1216
|
-
declare function setGlobalPredefinedStates(states: Record<string, string>): void;
|
|
1217
|
-
/**
|
|
1218
|
-
* Get global predefined states
|
|
1219
|
-
*/
|
|
1220
|
-
declare function getGlobalPredefinedStates(): Record<string, string>;
|
|
1221
|
-
/**
|
|
1222
|
-
* Create a state parser context from styles
|
|
1441
|
+
* Options for registering a CSS `@property`.
|
|
1442
|
+
* Extends {@link PropertyDefinition} with an optional injection root.
|
|
1223
1443
|
*/
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
interface ParseStateKeyOptions {
|
|
1228
|
-
context?: StateParserContext;
|
|
1229
|
-
isSubElement?: boolean;
|
|
1444
|
+
interface PropertyOptions extends PropertyDefinition {
|
|
1445
|
+
/** Shadow root or document to inject into */
|
|
1446
|
+
root?: Document | ShadowRoot;
|
|
1230
1447
|
}
|
|
1231
1448
|
/**
|
|
1232
|
-
*
|
|
1449
|
+
* A single parameter for a CSS @function at-rule.
|
|
1450
|
+
*
|
|
1451
|
+
* - `true` — a bare parameter with no type or default.
|
|
1452
|
+
* - `string` — a CSS type shorthand (e.g. `'<length>'`, `'<color>'`).
|
|
1453
|
+
* - object — full form with optional `syntax` (type) and `default` value.
|
|
1233
1454
|
*/
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1455
|
+
type FunctionParameter = true | string | {
|
|
1456
|
+
syntax?: string;
|
|
1457
|
+
default?: string | number;
|
|
1458
|
+
};
|
|
1237
1459
|
/**
|
|
1238
|
-
*
|
|
1460
|
+
* Definition for a CSS @function at-rule (custom function).
|
|
1461
|
+
*
|
|
1462
|
+
* The descriptor body reads like a mini styles object: any `$name` key declares
|
|
1463
|
+
* a local variable (`--name`) whose value is parsed through the Tasty DSL.
|
|
1464
|
+
* `result` is the only required field.
|
|
1465
|
+
*
|
|
1466
|
+
* @example
|
|
1467
|
+
* ```ts
|
|
1468
|
+
* // @function --negative(--value) { result: calc(-1 * var(--value)); }
|
|
1469
|
+
* { args: ['$value'], result: '(-1 * $value)' }
|
|
1470
|
+
* ```
|
|
1239
1471
|
*/
|
|
1240
|
-
interface
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1472
|
+
interface FunctionDefinition {
|
|
1473
|
+
/**
|
|
1474
|
+
* Ordered parameters. Array form lists bare parameter names (`['$value']`);
|
|
1475
|
+
* object form maps each parameter name to its type/default.
|
|
1476
|
+
*/
|
|
1477
|
+
args?: string[] | Record<string, FunctionParameter>;
|
|
1478
|
+
/** Optional return type, e.g. `'<color>'`. */
|
|
1479
|
+
returns?: string;
|
|
1480
|
+
/** The `result:` descriptor value (parsed through the Tasty DSL). Required. */
|
|
1481
|
+
result: string;
|
|
1482
|
+
/** Local variables: any `$name` key declares `--name` in the body. */
|
|
1483
|
+
[localVar: `$${string}`]: string | number | undefined;
|
|
1248
1484
|
}
|
|
1249
1485
|
/**
|
|
1250
|
-
*
|
|
1486
|
+
* Descriptors for a CSS @font-face at-rule.
|
|
1251
1487
|
*/
|
|
1252
|
-
interface
|
|
1253
|
-
|
|
1254
|
-
|
|
1488
|
+
interface FontFaceDescriptors {
|
|
1489
|
+
/** Required. URL(s) to the font file(s). */
|
|
1490
|
+
src: string;
|
|
1491
|
+
/** Font weight or range. Default: 'normal'. */
|
|
1492
|
+
fontWeight?: string | number;
|
|
1493
|
+
/** Font style. Default: 'normal'. */
|
|
1494
|
+
fontStyle?: 'normal' | 'italic' | 'oblique' | (string & {});
|
|
1495
|
+
/** Font stretch. Default: 'normal'. */
|
|
1496
|
+
fontStretch?: string;
|
|
1497
|
+
/** Loading behavior. Default: 'auto'. */
|
|
1498
|
+
fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
1499
|
+
/** Unicode range to cover. */
|
|
1500
|
+
unicodeRange?: string;
|
|
1501
|
+
/** Ascent metric override. */
|
|
1502
|
+
ascentOverride?: string;
|
|
1503
|
+
/** Descent metric override. */
|
|
1504
|
+
descentOverride?: string;
|
|
1505
|
+
/** Line gap metric override. */
|
|
1506
|
+
lineGapOverride?: string;
|
|
1507
|
+
/** Size adjustment factor. */
|
|
1508
|
+
sizeAdjust?: string;
|
|
1509
|
+
/** OpenType feature settings. */
|
|
1510
|
+
fontFeatureSettings?: string;
|
|
1511
|
+
/** Font variation axis settings. */
|
|
1512
|
+
fontVariationSettings?: string;
|
|
1255
1513
|
}
|
|
1514
|
+
/** Single descriptor or array of descriptors for multiple weights/styles. */
|
|
1515
|
+
type FontFaceInput = FontFaceDescriptors | FontFaceDescriptors[];
|
|
1256
1516
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
*/
|
|
1259
|
-
declare function isSelector(key: string): boolean;
|
|
1260
|
-
/**
|
|
1261
|
-
* Options for renderStyles when using direct selector mode.
|
|
1517
|
+
* Descriptors for a CSS @counter-style at-rule.
|
|
1262
1518
|
*/
|
|
1263
|
-
interface
|
|
1264
|
-
/**
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1519
|
+
interface CounterStyleDescriptors {
|
|
1520
|
+
/** Required. Numbering algorithm. */
|
|
1521
|
+
system: 'cyclic' | 'numeric' | 'alphabetic' | 'symbolic' | 'additive' | 'fixed' | (string & {});
|
|
1522
|
+
/** Symbols for non-additive systems. */
|
|
1523
|
+
symbols?: string;
|
|
1524
|
+
/** Symbol-value pairs for additive system. */
|
|
1525
|
+
additiveSymbols?: string;
|
|
1526
|
+
/** String prepended to the marker. Default: "". */
|
|
1527
|
+
prefix?: string;
|
|
1528
|
+
/** String appended to the marker. Default: ". ". */
|
|
1529
|
+
suffix?: string;
|
|
1530
|
+
/** Negative-value wrapping (e.g., '"(" ")"'). */
|
|
1531
|
+
negative?: string;
|
|
1532
|
+
/** Counter range (e.g., 'infinite infinite'). */
|
|
1533
|
+
range?: string;
|
|
1534
|
+
/** Minimum marker width and pad symbol (e.g., '3 "0"'). */
|
|
1535
|
+
pad?: string;
|
|
1536
|
+
/** Fallback counter style name. */
|
|
1537
|
+
fallback?: string;
|
|
1538
|
+
/** Speech synthesis hint. */
|
|
1539
|
+
speakAs?: string;
|
|
1275
1540
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
*/
|
|
1282
|
-
declare function renderStyles(styles?: Styles, classNameOrSelector?: undefined, options?: undefined, pipelineCacheKey?: string): RenderResult;
|
|
1283
|
-
declare function renderStyles(styles: Styles | undefined, classNameOrSelector: string, options?: RenderStylesOptions): StyleResult[];
|
|
1284
|
-
//#endregion
|
|
1285
|
-
export { strToRgb as $, RawStyleHandler as A, getGlobalFuncs as B, SuffixForSelector as C, RawCSSResult as Ct, CUSTOM_UNITS as D, StyleInjectorConfig as Dt, CSSMap as E, SheetInfo as Et, StylePropValue as F, parseStyle as G, getGlobalPredefinedTokens as H, StyleValue as I, stringifyStyles as J, resetGlobalPredefinedTokens as K, StyleValueStateMap as L, StyleHandlerDefinition as M, StyleHandlerResult as N, DIRECTIONS as O, StyleRule as Ot, StyleMap as P, hslToRgbValues as Q, customFunc as R, StylesWithoutSelectors as S, PropertyDefinition as St, TastyPresetNames as T, RuleInfo as Tt, normalizeColorTokenValue as U, getGlobalParser as V, parseColor as W, getRgbValuesFromRgbaString as X, getNamedColorHex as Y, hexToRgb as Z, NotSelector as _, InjectionMode as _t, ParseStateKeyOptions as a, StyleDetailsPart as at, Styles as b, KeyframesResult as bt, ParsedAdvancedState as c, CacheMetrics as ct, getGlobalPredefinedStates as d, FontFaceDescriptors as dt, StyleParser as et, setGlobalPredefinedStates as f, FontFaceInput as ft, NoType as g, InjectResult as gt, ConfigTokens as h, GlobalInjectResult as ht, renderStyles as i, StyleDetails as it, StyleHandler as j, ParsedColor as k, StyleUsage as kt, StateParserContext as l, CounterStyleDescriptors as lt, ConfigTokenValue as m, GCOptions as mt, StyleResult as n, ParserOptions as nt, parseStateKey as o, UnitHandler as ot, ConditionNode as p, GCConfig as pt, setGlobalPredefinedTokens as q, isSelector as r, ProcessedStyle as rt, AtRuleContext as s, CSSProperties as st, RenderResult as t, Bucket as tt, createStateParserContext as u, DisposeFunction as ut, RecipeStyles as v, KeyframesCacheEntry as vt, TastyNamedColors as w, RootRegistry as wt, StylesInterface as x, KeyframesSteps as xt, Selector as y, KeyframesInfo as yt, filterMods as z };
|
|
1286
|
-
//# sourceMappingURL=index-tcHuMPFt.d.ts.map
|
|
1541
|
+
interface RawCSSResult {
|
|
1542
|
+
dispose: () => void;
|
|
1543
|
+
}
|
|
1544
|
+
export { TastyNamedColors as $, resetStyleBatch as A, getGlobalPredefinedStates as B, SheetInfo as C, StyleParser as Ct, QueuedWrite as D, StyleDetailsPart as Dt, StyleUsage as E, StyleDetails as Et, parseStateKey as F, NoType as G, ConditionNode as H, AtRuleContext as I, Selector as J, NotSelector as K, ParsedAdvancedState as L, StyleResult as M, renderStyles as N, flushStyles as O, UnitHandler as Ot, ParseStateKeyOptions as P, SuffixForSelector as Q, StateParserContext as R, RuleInfo as S, stringifyStyles as St, StyleRule as T, ProcessedStyle as Tt, ConfigTokenValue as U, setGlobalPredefinedStates as V, ConfigTokens as W, StylesInterface as X, Styles as Y, StylesWithoutSelectors as Z, KeyframesSteps as _, getGlobalParser as _t, FontFaceInput as a, ParsedColor as at, RawCSSResult as b, parseColor as bt, GCConfig as c, StyleHandler as ct, InjectOptions as d, StyleHandlerResult as dt, TastyPresetNames as et, InjectResult as f, StyleMap as ft, KeyframesResult as g, filterMods as gt, KeyframesInfo as h, StyleValueStateMap as ht, FontFaceDescriptors as i, DIRECTIONS as it, RenderResult as j, hasPendingStyleWrites as k, CSSProperties as kt, GCOptions as l, StyleHandlerDefinition as lt, KeyframesCacheEntry as m, StyleValue as mt, CounterStyleDescriptors as n, CSSMap as nt, FunctionDefinition as o, RawStyleHandler as ot, InjectionMode as p, StylePropValue as pt, RecipeStyles as q, DisposeFunction as r, CUSTOM_UNITS as rt, FunctionParameter as s, ResolvedStyleValue as st, CacheMetrics as t, AnyStyleHandler as tt, GlobalInjectResult as u, StyleHandlerProps as ut, PropertyDefinition as v, getGlobalPredefinedTokens as vt, StyleInjectorConfig as w, ParserOptions as wt, RootRegistry as x, parseStyle as xt, PropertyOptions as y, normalizeColorTokenValue as yt, createStateParserContext as z };
|
|
1545
|
+
//# sourceMappingURL=types-DbMN-Yyn.d.ts.map
|