@tenphi/tasty 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
- package/dist/async-storage-B7_o6FKt.js.map +1 -0
- package/dist/{ssr/collector.js → collector-DrgDE7QB.js} +5 -10
- package/dist/collector-DrgDE7QB.js.map +1 -0
- package/dist/{ssr/collector.d.ts → collector-LuU1vZ68.d.ts} +3 -3
- package/dist/config-_aQ_PZ-P.js +10131 -0
- package/dist/config-_aQ_PZ-P.js.map +1 -0
- package/dist/config-vuCRkBWX.d.ts +884 -0
- package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
- package/dist/context-CkSg-kDT.js.map +1 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +6 -27
- package/dist/core-BqO8pplb.js +1592 -0
- package/dist/core-BqO8pplb.js.map +1 -0
- package/dist/{zero/extractor.js → css-writer-D--REwtp.js} +74 -11
- package/dist/css-writer-D--REwtp.js.map +1 -0
- package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
- package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
- package/dist/format-rules-xwteB7a1.js +143 -0
- package/dist/format-rules-xwteB7a1.js.map +1 -0
- package/dist/{ssr/hydrate.js → hydrate-BvPT4ndL.js} +3 -3
- package/dist/hydrate-BvPT4ndL.js.map +1 -0
- package/dist/index-ZRxZWzlj.d.ts +1602 -0
- package/dist/{styles/types.d.ts → index-dUtwpOux.d.ts} +707 -5
- package/dist/index.d.ts +5 -51
- package/dist/index.js +732 -36
- package/dist/index.js.map +1 -0
- package/dist/keyframes-ClPFWy33.js +587 -0
- package/dist/keyframes-ClPFWy33.js.map +1 -0
- package/dist/{utils/merge-styles.js → merge-styles-BUQsEpbv.js} +3 -4
- package/dist/merge-styles-BUQsEpbv.js.map +1 -0
- package/dist/{utils/merge-styles.d.ts → merge-styles-CtDJMhpJ.d.ts} +3 -3
- package/dist/{utils/resolve-recipes.js → resolve-recipes-C0-AMzCz.js} +4 -6
- package/dist/resolve-recipes-C0-AMzCz.js.map +1 -0
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/index.d.ts +44 -4
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +6 -6
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -3
- package/dist/static/index.js.map +1 -0
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +10 -6
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +67 -3
- package/dist/zero/index.js +1 -2
- package/docs/injector.md +2 -2
- package/package.json +10 -9
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js +0 -453
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -389
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -749
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize-contradictions.js +0 -125
- package/dist/pipeline/materialize-contradictions.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1038
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -725
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js +0 -73
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
|
@@ -0,0 +1,884 @@
|
|
|
1
|
+
import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-dUtwpOux.js";
|
|
2
|
+
|
|
3
|
+
//#region src/injector/sheet-manager.d.ts
|
|
4
|
+
declare class SheetManager {
|
|
5
|
+
private rootRegistries;
|
|
6
|
+
/** Strong set of active roots so background GC can iterate them all */
|
|
7
|
+
private activeRoots;
|
|
8
|
+
private config;
|
|
9
|
+
/** Dedicated style elements for raw CSS per root */
|
|
10
|
+
private rawStyleElements;
|
|
11
|
+
/** Constructable sheets for raw CSS in adopted mode */
|
|
12
|
+
private rawConstructableSheets;
|
|
13
|
+
/** Tracking for raw CSS blocks per root */
|
|
14
|
+
private rawCSSBlocks;
|
|
15
|
+
/** Counter for generating unique raw CSS IDs */
|
|
16
|
+
private rawCSSCounter;
|
|
17
|
+
constructor(config: StyleInjectorConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the underlying CSSStyleSheet from a SheetInfo,
|
|
20
|
+
* abstracting away adopted vs style-element modes.
|
|
21
|
+
*/
|
|
22
|
+
getCSSSheet(sheetInfo: SheetInfo): CSSStyleSheet | null;
|
|
23
|
+
/**
|
|
24
|
+
* Determine the injection mode for a root.
|
|
25
|
+
* ShadowRoot uses adopted stylesheets when supported; Document uses <style> elements.
|
|
26
|
+
*/
|
|
27
|
+
private detectInjectionMode;
|
|
28
|
+
/**
|
|
29
|
+
* Get or create registry for a root (Document or ShadowRoot)
|
|
30
|
+
*/
|
|
31
|
+
getRegistry(root: Document | ShadowRoot): RootRegistry;
|
|
32
|
+
/** Return all roots with active registries (for background GC sweep). */
|
|
33
|
+
getActiveRoots(): Iterable<Document | ShadowRoot>;
|
|
34
|
+
/** Check whether any roots have active registries. */
|
|
35
|
+
hasActiveRoots(): boolean;
|
|
36
|
+
/** Remove registries for ShadowRoots whose host has been detached from the DOM. */
|
|
37
|
+
pruneDisconnectedRoots(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new stylesheet for the registry.
|
|
40
|
+
* In adopted mode (ShadowRoot), creates a constructable CSSStyleSheet and
|
|
41
|
+
* pushes it to adoptedStyleSheets. Otherwise creates a <style> element.
|
|
42
|
+
*/
|
|
43
|
+
createSheet(registry: RootRegistry, root: Document | ShadowRoot): SheetInfo;
|
|
44
|
+
/**
|
|
45
|
+
* Create a style element and append to document
|
|
46
|
+
*/
|
|
47
|
+
private createStyleElement;
|
|
48
|
+
/**
|
|
49
|
+
* Insert CSS rules as a single block
|
|
50
|
+
*/
|
|
51
|
+
insertRule(registry: RootRegistry, flattenedRules: StyleRule[], className: string, root: Document | ShadowRoot): RuleInfo | null;
|
|
52
|
+
/**
|
|
53
|
+
* Insert global CSS rules
|
|
54
|
+
*/
|
|
55
|
+
insertGlobalRule(registry: RootRegistry, flattenedRules: StyleRule[], globalKey: string, root: Document | ShadowRoot): RuleInfo | null;
|
|
56
|
+
/**
|
|
57
|
+
* Delete a global CSS rule by key
|
|
58
|
+
*/
|
|
59
|
+
deleteGlobalRule(registry: RootRegistry, globalKey: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Adjust rule indices after deletion to account for shifting
|
|
62
|
+
*/
|
|
63
|
+
private adjustIndicesAfterDeletion;
|
|
64
|
+
/**
|
|
65
|
+
* Delete a CSS rule from the sheet
|
|
66
|
+
*/
|
|
67
|
+
deleteRule(registry: RootRegistry, ruleInfo: RuleInfo): void;
|
|
68
|
+
/**
|
|
69
|
+
* Find a sheet with available space or return null
|
|
70
|
+
*/
|
|
71
|
+
private findAvailableSheet;
|
|
72
|
+
/**
|
|
73
|
+
* Find an available rule index in the sheet
|
|
74
|
+
*/
|
|
75
|
+
findAvailableRuleIndex(sheet: SheetInfo): number;
|
|
76
|
+
/**
|
|
77
|
+
* Force cleanup of unused styles
|
|
78
|
+
*/
|
|
79
|
+
forceCleanup(registry: RootRegistry): void;
|
|
80
|
+
/**
|
|
81
|
+
* Perform bulk cleanup of all unused styles (refCount = 0).
|
|
82
|
+
*/
|
|
83
|
+
private performBulkCleanup;
|
|
84
|
+
/**
|
|
85
|
+
* Get total number of rules across all sheets
|
|
86
|
+
*/
|
|
87
|
+
getTotalRuleCount(registry: RootRegistry): number;
|
|
88
|
+
/**
|
|
89
|
+
* Get CSS text from all sheets (for SSR)
|
|
90
|
+
*/
|
|
91
|
+
getCssText(registry: RootRegistry): string;
|
|
92
|
+
/**
|
|
93
|
+
* Get cache performance metrics
|
|
94
|
+
*/
|
|
95
|
+
getMetrics(registry: RootRegistry): CacheMetrics | null;
|
|
96
|
+
/**
|
|
97
|
+
* Reset cache performance metrics
|
|
98
|
+
*/
|
|
99
|
+
resetMetrics(registry: RootRegistry): void;
|
|
100
|
+
/**
|
|
101
|
+
* Convert keyframes steps to CSS string.
|
|
102
|
+
* Public so the SSR collector can format keyframes without DOM access.
|
|
103
|
+
* Returns both the CSS text and a combined declarations string for property type scanning.
|
|
104
|
+
*/
|
|
105
|
+
stepsToCSS(steps: KeyframesSteps): {
|
|
106
|
+
css: string;
|
|
107
|
+
declarations: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Insert keyframes rule.
|
|
111
|
+
* Returns the KeyframesInfo and the raw declarations string for property type scanning.
|
|
112
|
+
*/
|
|
113
|
+
insertKeyframes(registry: RootRegistry, steps: KeyframesSteps, name: string, root: Document | ShadowRoot): {
|
|
114
|
+
info: KeyframesInfo;
|
|
115
|
+
declarations: string;
|
|
116
|
+
} | null;
|
|
117
|
+
/**
|
|
118
|
+
* Delete keyframes rule
|
|
119
|
+
*/
|
|
120
|
+
deleteKeyframes(registry: RootRegistry, info: KeyframesInfo): void;
|
|
121
|
+
/**
|
|
122
|
+
* Clean up resources for a root
|
|
123
|
+
*/
|
|
124
|
+
cleanup(root: Document | ShadowRoot): void;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a root uses adopted injection mode.
|
|
127
|
+
*/
|
|
128
|
+
private isAdoptedMode;
|
|
129
|
+
/**
|
|
130
|
+
* Get or create a constructable CSSStyleSheet for raw CSS in adopted mode.
|
|
131
|
+
* The raw sheet is prepended to adoptedStyleSheets so it precedes tasty rules.
|
|
132
|
+
*/
|
|
133
|
+
private getOrCreateRawAdoptedSheet;
|
|
134
|
+
/**
|
|
135
|
+
* Get or create a dedicated style element for raw CSS
|
|
136
|
+
* Raw CSS is kept separate from tasty-managed sheets to avoid index conflicts
|
|
137
|
+
*/
|
|
138
|
+
private getOrCreateRawStyleElement;
|
|
139
|
+
/**
|
|
140
|
+
* Inject raw CSS text directly without parsing
|
|
141
|
+
* Returns a dispose function to remove the injected CSS
|
|
142
|
+
*/
|
|
143
|
+
injectRawCSS(css: string, root: Document | ShadowRoot): RawCSSResult;
|
|
144
|
+
/**
|
|
145
|
+
* Rebuild the raw CSS constructable sheet from all tracked blocks.
|
|
146
|
+
*/
|
|
147
|
+
private rebuildRawAdoptedSheet;
|
|
148
|
+
/**
|
|
149
|
+
* Remove a raw CSS block by ID
|
|
150
|
+
*/
|
|
151
|
+
private disposeRawCSS;
|
|
152
|
+
/**
|
|
153
|
+
* Get the raw CSS content
|
|
154
|
+
*/
|
|
155
|
+
getRawCSSText(root: Document | ShadowRoot): string;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/injector/injector.d.ts
|
|
159
|
+
declare class StyleInjector {
|
|
160
|
+
private sheetManager;
|
|
161
|
+
private config;
|
|
162
|
+
private globalRuleCounter;
|
|
163
|
+
private pendingGCHandle;
|
|
164
|
+
/** @internal — exposed for debug utilities only */
|
|
165
|
+
get _sheetManager(): SheetManager;
|
|
166
|
+
constructor(config?: StyleInjectorConfig);
|
|
167
|
+
/**
|
|
168
|
+
* Check if `className` was hydrated from server-rendered styles and,
|
|
169
|
+
* if so, wire the cacheKey mapping. Returns true on hit.
|
|
170
|
+
*/
|
|
171
|
+
private tryHydratedHit;
|
|
172
|
+
/**
|
|
173
|
+
* Allocate a className for a cacheKey without injecting styles yet.
|
|
174
|
+
* This allows separating className allocation (render phase) from style injection (insertion phase).
|
|
175
|
+
*/
|
|
176
|
+
allocateClassName(cacheKey: string, options?: {
|
|
177
|
+
root?: Document | ShadowRoot;
|
|
178
|
+
}): {
|
|
179
|
+
className: string;
|
|
180
|
+
isNewAllocation: boolean;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Inject styles from StyleResult objects
|
|
184
|
+
*/
|
|
185
|
+
inject(rules: StyleResult[], options?: {
|
|
186
|
+
root?: Document | ShadowRoot;
|
|
187
|
+
cacheKey?: string;
|
|
188
|
+
}): InjectResult;
|
|
189
|
+
/**
|
|
190
|
+
* Inject global styles (rules without a generated tasty class selector)
|
|
191
|
+
* This ensures we don't reserve a tasty class name (t{number}) for global rules,
|
|
192
|
+
* which could otherwise collide with element-level styles and break lookups.
|
|
193
|
+
*/
|
|
194
|
+
injectGlobal(rules: StyleResult[], options?: {
|
|
195
|
+
root?: Document | ShadowRoot;
|
|
196
|
+
}): GlobalInjectResult;
|
|
197
|
+
/**
|
|
198
|
+
* Inject raw CSS text directly without parsing
|
|
199
|
+
* This is a low-overhead alternative to createGlobalStyle for raw CSS
|
|
200
|
+
* The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking
|
|
201
|
+
*/
|
|
202
|
+
injectRawCSS(css: string, options?: {
|
|
203
|
+
root?: Document | ShadowRoot;
|
|
204
|
+
}): RawCSSResult;
|
|
205
|
+
/**
|
|
206
|
+
* Get raw CSS text for SSR
|
|
207
|
+
*/
|
|
208
|
+
getRawCSSText(options?: {
|
|
209
|
+
root?: Document | ShadowRoot;
|
|
210
|
+
}): string;
|
|
211
|
+
/**
|
|
212
|
+
* Increment refCount for an already-injected cacheKey and return a dispose.
|
|
213
|
+
* Used by useStyles on cache hits (hydration or runtime reuse) where
|
|
214
|
+
* the pipeline was skipped but refCount tracking is still needed.
|
|
215
|
+
* Returns null if the cacheKey is not found.
|
|
216
|
+
*/
|
|
217
|
+
trackRef(cacheKey: string, options?: {
|
|
218
|
+
root?: Document | ShadowRoot;
|
|
219
|
+
}): InjectResult | null;
|
|
220
|
+
/**
|
|
221
|
+
* Dispose of a className (decrements refCount only).
|
|
222
|
+
*/
|
|
223
|
+
private dispose;
|
|
224
|
+
/**
|
|
225
|
+
* Force bulk cleanup of unused styles
|
|
226
|
+
*/
|
|
227
|
+
cleanup(root?: Document | ShadowRoot): void;
|
|
228
|
+
/**
|
|
229
|
+
* Get CSS text from all sheets (for SSR)
|
|
230
|
+
*/
|
|
231
|
+
getCssText(options?: {
|
|
232
|
+
root?: Document | ShadowRoot;
|
|
233
|
+
}): string;
|
|
234
|
+
/**
|
|
235
|
+
* Get CSS only for the provided tasty classNames (e.g., ["t0","t3"])
|
|
236
|
+
*/
|
|
237
|
+
getCssTextForClasses(classNames: Iterable<string>, options?: {
|
|
238
|
+
root?: Document | ShadowRoot;
|
|
239
|
+
}): string;
|
|
240
|
+
/**
|
|
241
|
+
* Get cache performance metrics
|
|
242
|
+
*/
|
|
243
|
+
getMetrics(options?: {
|
|
244
|
+
root?: Document | ShadowRoot;
|
|
245
|
+
}): CacheMetrics | null;
|
|
246
|
+
/**
|
|
247
|
+
* Reset cache performance metrics
|
|
248
|
+
*/
|
|
249
|
+
resetMetrics(options?: {
|
|
250
|
+
root?: Document | ShadowRoot;
|
|
251
|
+
}): void;
|
|
252
|
+
/**
|
|
253
|
+
* Define a CSS @property custom property.
|
|
254
|
+
*
|
|
255
|
+
* Accepts tasty token syntax for the property name:
|
|
256
|
+
* - `$name` → defines `--name`
|
|
257
|
+
* - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
|
|
258
|
+
* - `--name` → defines `--name` (legacy format)
|
|
259
|
+
*
|
|
260
|
+
* Example:
|
|
261
|
+
* @property --rotation { syntax: "<angle>"; inherits: false; initial-value: 45deg; }
|
|
262
|
+
*
|
|
263
|
+
* Note: No caching or dispose — this defines a global property.
|
|
264
|
+
*
|
|
265
|
+
* If the same property is registered with different options, a warning is emitted
|
|
266
|
+
* but the original definition is preserved (CSS @property cannot be redefined).
|
|
267
|
+
*/
|
|
268
|
+
property(name: string, options?: PropertyDefinition & {
|
|
269
|
+
root?: Document | ShadowRoot;
|
|
270
|
+
}): void;
|
|
271
|
+
/**
|
|
272
|
+
* Check whether a given @property name was already injected by this injector.
|
|
273
|
+
*
|
|
274
|
+
* Accepts tasty token syntax:
|
|
275
|
+
* - `$name` → checks `--name`
|
|
276
|
+
* - `#name` → checks `--name-color`
|
|
277
|
+
* - `--name` → checks `--name` (legacy format)
|
|
278
|
+
*/
|
|
279
|
+
isPropertyDefined(name: string, options?: {
|
|
280
|
+
root?: Document | ShadowRoot;
|
|
281
|
+
}): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Inject a CSS @font-face rule.
|
|
284
|
+
*
|
|
285
|
+
* Permanent and global — no dispose or ref-counting.
|
|
286
|
+
* Deduplicates by content hash (family + descriptors).
|
|
287
|
+
*/
|
|
288
|
+
fontFace(family: string, descriptors: FontFaceDescriptors, options?: {
|
|
289
|
+
root?: Document | ShadowRoot;
|
|
290
|
+
}): void;
|
|
291
|
+
/**
|
|
292
|
+
* Inject a CSS @counter-style rule.
|
|
293
|
+
*
|
|
294
|
+
* Permanent and global — no dispose or ref-counting.
|
|
295
|
+
* Deduplicates by name (first definition wins).
|
|
296
|
+
*/
|
|
297
|
+
counterStyle(name: string, descriptors: CounterStyleDescriptors, options?: {
|
|
298
|
+
root?: Document | ShadowRoot;
|
|
299
|
+
}): void;
|
|
300
|
+
/**
|
|
301
|
+
* Inject keyframes and return object with toString() and dispose()
|
|
302
|
+
*
|
|
303
|
+
* Keyframes are cached by content (steps). If the same content is injected
|
|
304
|
+
* multiple times with different provided names, the first injected name is reused.
|
|
305
|
+
*
|
|
306
|
+
* If the same name is provided with different content (collision), a unique
|
|
307
|
+
* name is generated to avoid overwriting the existing keyframes.
|
|
308
|
+
*/
|
|
309
|
+
keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
|
|
310
|
+
root?: Document | ShadowRoot;
|
|
311
|
+
name?: string;
|
|
312
|
+
}): KeyframesResult;
|
|
313
|
+
/**
|
|
314
|
+
* Dispose keyframes
|
|
315
|
+
*/
|
|
316
|
+
private disposeKeyframes;
|
|
317
|
+
private static readonly TASTY_CLASS_RE;
|
|
318
|
+
/**
|
|
319
|
+
* Record a render-time usage hit for one or more classNames.
|
|
320
|
+
* Handles space-separated multi-chunk classNames.
|
|
321
|
+
* When the global touch counter reaches `touchInterval`, schedules a GC
|
|
322
|
+
* via `requestIdleCallback`.
|
|
323
|
+
* No-op on the server.
|
|
324
|
+
*/
|
|
325
|
+
touch(className: string, options?: {
|
|
326
|
+
root?: Document | ShadowRoot;
|
|
327
|
+
}): void;
|
|
328
|
+
/**
|
|
329
|
+
* Schedule a GC via `requestIdleCallback` (or synchronously as fallback).
|
|
330
|
+
* Runs GC on all active roots. Avoids double-scheduling via `pendingGCHandle`.
|
|
331
|
+
*/
|
|
332
|
+
private scheduleGC;
|
|
333
|
+
/**
|
|
334
|
+
* Synchronous garbage collection.
|
|
335
|
+
*
|
|
336
|
+
* 1. Quick upper-bound check: skip if unused count can't exceed capacity.
|
|
337
|
+
* 2. Scans the DOM for live tasty classNames (safety guard).
|
|
338
|
+
* 3. With `force: true`: deletes all unused entries inline.
|
|
339
|
+
* Without `force`: collects unused, sorts oldest-first, evicts over capacity.
|
|
340
|
+
*
|
|
341
|
+
* @returns Number of styles evicted.
|
|
342
|
+
*/
|
|
343
|
+
gc(options?: GCOptions): number;
|
|
344
|
+
/**
|
|
345
|
+
* Destroy all resources for a root
|
|
346
|
+
*/
|
|
347
|
+
destroy(root?: Document | ShadowRoot): void;
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/utils/color-space.d.ts
|
|
351
|
+
type ColorSpace = 'rgb' | 'hsl' | 'oklch';
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/utils/typography.d.ts
|
|
354
|
+
/**
|
|
355
|
+
* A typography token value: plain value or a state map for responsive/theme-aware presets.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* // Plain value
|
|
359
|
+
* fontWeight: '400'
|
|
360
|
+
* // State map
|
|
361
|
+
* fontWeight: { '': '400', '@dark': '300' }
|
|
362
|
+
*/
|
|
363
|
+
type TypographyTokenValue = string | number | Record<string, string | number | undefined | null | '@inherit'>;
|
|
364
|
+
/**
|
|
365
|
+
* Typography preset configuration.
|
|
366
|
+
* Each preset defines font properties that get expanded into CSS custom properties.
|
|
367
|
+
* All fields accept plain values or state maps for responsive/theme-aware tokens.
|
|
368
|
+
*
|
|
369
|
+
* Use with `generateTypographyTokens()` to create typography tokens for your design system.
|
|
370
|
+
*/
|
|
371
|
+
interface TypographyPreset {
|
|
372
|
+
fontSize: TypographyTokenValue;
|
|
373
|
+
lineHeight: TypographyTokenValue;
|
|
374
|
+
letterSpacing?: TypographyTokenValue;
|
|
375
|
+
fontWeight: TypographyTokenValue;
|
|
376
|
+
boldFontWeight?: TypographyTokenValue;
|
|
377
|
+
iconSize?: TypographyTokenValue;
|
|
378
|
+
textTransform?: TypographyTokenValue;
|
|
379
|
+
fontFamily?: TypographyTokenValue;
|
|
380
|
+
fontStyle?: TypographyTokenValue;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Generate typography tokens with $ prefix for CSS custom properties.
|
|
384
|
+
*
|
|
385
|
+
* Each preset generates the following CSS custom properties:
|
|
386
|
+
* - `${name}-font-size`
|
|
387
|
+
* - `${name}-line-height`
|
|
388
|
+
* - `${name}-letter-spacing`
|
|
389
|
+
* - `${name}-font-weight`
|
|
390
|
+
* - `${name}-bold-font-weight` (if defined)
|
|
391
|
+
* - `${name}-icon-size` (if defined)
|
|
392
|
+
* - `${name}-text-transform` (if defined)
|
|
393
|
+
* - `${name}-font-family` (if defined)
|
|
394
|
+
* - `${name}-font-style` (if defined)
|
|
395
|
+
*
|
|
396
|
+
* @param presets - Typography presets object
|
|
397
|
+
* @returns ConfigTokens object with $ prefixed keys
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* const customTokens = generateTypographyTokens({
|
|
401
|
+
* myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
|
|
402
|
+
* body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
|
|
403
|
+
* });
|
|
404
|
+
*/
|
|
405
|
+
declare function generateTypographyTokens(presets: Record<string, TypographyPreset>): ConfigTokens;
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/plugins/types.d.ts
|
|
408
|
+
/**
|
|
409
|
+
* A tasty plugin that extends the style system with custom functions, units, states, or handlers.
|
|
410
|
+
*/
|
|
411
|
+
interface TastyPlugin {
|
|
412
|
+
/** Unique name for the plugin (used for debugging and conflict detection) */
|
|
413
|
+
name: string;
|
|
414
|
+
/** Custom functions that transform parsed style groups into CSS values */
|
|
415
|
+
funcs?: Record<string, (groups: StyleDetails[]) => string>;
|
|
416
|
+
/** Custom units that transform numeric values (e.g., `2x` → `calc(2 * var(--gap))`) */
|
|
417
|
+
units?: Record<string, string | UnitHandler>;
|
|
418
|
+
/** Custom state aliases (e.g., `'@mobile': '@media(w < 768px)'`) */
|
|
419
|
+
states?: Record<string, string>;
|
|
420
|
+
/**
|
|
421
|
+
* Custom style handlers that transform style properties into CSS declarations.
|
|
422
|
+
* Handlers replace built-in handlers for the same style name.
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* handlers: {
|
|
426
|
+
* // Simple handler - lookup style inferred from key
|
|
427
|
+
* fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
|
|
428
|
+
* // Multi-property handler
|
|
429
|
+
* spacing: [['gap', 'padding'], ({ gap, padding }) => ({ ... })],
|
|
430
|
+
* }
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
handlers?: Record<string, StyleHandlerDefinition>;
|
|
434
|
+
/**
|
|
435
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
436
|
+
* Values are parsed through the Tasty DSL. Supports state maps.
|
|
437
|
+
* - `$name` → `--name` CSS custom property
|
|
438
|
+
* - `#name` → `--name-color` and `--name-color-{colorSpace}`
|
|
439
|
+
*/
|
|
440
|
+
tokens?: ConfigTokens;
|
|
441
|
+
/** Predefined tokens replaced during style parsing (`$name` or `#name`) */
|
|
442
|
+
replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
|
|
443
|
+
/**
|
|
444
|
+
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
445
|
+
* Recipe values are flat tasty styles (no sub-element keys).
|
|
446
|
+
* @example
|
|
447
|
+
* ```ts
|
|
448
|
+
* recipes: {
|
|
449
|
+
* card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
450
|
+
* elevated: { shadow: '2x 2x 4x #shadow' },
|
|
451
|
+
* }
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
recipes?: Record<string, RecipeStyles>;
|
|
455
|
+
/**
|
|
456
|
+
* Typography presets — shorthand for `generateTypographyTokens()`.
|
|
457
|
+
* Generated tokens are merged under explicit `tokens` (tokens win on conflict).
|
|
458
|
+
*/
|
|
459
|
+
presets?: Record<string, TypographyPreset>;
|
|
460
|
+
/**
|
|
461
|
+
* Global Tasty styles keyed by CSS selector.
|
|
462
|
+
* Supports the full Tasty style syntax.
|
|
463
|
+
*/
|
|
464
|
+
globalStyles?: Record<string, Styles>;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* A factory function that creates a TastyPlugin.
|
|
468
|
+
* Can optionally accept configuration options.
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* // Plugin without options
|
|
473
|
+
* const okhslPlugin: TastyPluginFactory = () => ({
|
|
474
|
+
* name: 'okhsl',
|
|
475
|
+
* funcs: { okhsl: okhslFunc },
|
|
476
|
+
* });
|
|
477
|
+
*
|
|
478
|
+
* // Plugin with options
|
|
479
|
+
* const debugPlugin: TastyPluginFactory<{ verbose: boolean }> = (options) => ({
|
|
480
|
+
* name: 'debug',
|
|
481
|
+
* funcs: { debug: createDebugFunc(options.verbose) },
|
|
482
|
+
* });
|
|
483
|
+
* ```
|
|
484
|
+
*/
|
|
485
|
+
type TastyPluginFactory<TOptions = void> = TOptions extends void ? () => TastyPlugin : (options: TOptions) => TastyPlugin;
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/config.d.ts
|
|
488
|
+
/**
|
|
489
|
+
* Configuration options for the Tasty style system
|
|
490
|
+
*/
|
|
491
|
+
interface TastyConfig {
|
|
492
|
+
/** CSP nonce for style elements */
|
|
493
|
+
nonce?: string;
|
|
494
|
+
/** Maximum rules per stylesheet (default: 8192) */
|
|
495
|
+
maxRulesPerSheet?: number;
|
|
496
|
+
/** Force text injection mode, auto-detected in test environments (default: auto) */
|
|
497
|
+
forceTextInjection?: boolean;
|
|
498
|
+
/** Enable development mode features: performance metrics and debug info (default: auto) */
|
|
499
|
+
devMode?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Global predefined states for advanced state mapping.
|
|
502
|
+
* These are state aliases that can be used in any component.
|
|
503
|
+
* Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
|
|
504
|
+
*/
|
|
505
|
+
states?: Record<string, string>;
|
|
506
|
+
/**
|
|
507
|
+
* Parser LRU cache size (default: 1000).
|
|
508
|
+
* Larger values improve performance for apps with many unique style values.
|
|
509
|
+
*/
|
|
510
|
+
parserCacheSize?: number;
|
|
511
|
+
/**
|
|
512
|
+
* Custom units for the style parser (merged with built-in units).
|
|
513
|
+
* Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
|
|
514
|
+
* @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
|
|
515
|
+
*/
|
|
516
|
+
units?: Record<string, string | UnitHandler>;
|
|
517
|
+
/**
|
|
518
|
+
* Custom functions for the style parser (merged with existing).
|
|
519
|
+
* Functions process parsed style groups and return CSS values.
|
|
520
|
+
* @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
|
|
521
|
+
*/
|
|
522
|
+
funcs?: Record<string, (groups: StyleDetails[]) => string>;
|
|
523
|
+
/**
|
|
524
|
+
* Color space used for decomposed color token companion variables.
|
|
525
|
+
* Controls the CSS function and suffix for alpha composition.
|
|
526
|
+
*
|
|
527
|
+
* - `'rgb'` — suffix `-rgb`, e.g. `rgb(var(--name-color-rgb) / .5)`
|
|
528
|
+
* - `'hsl'` — suffix `-hsl`, e.g. `hsl(var(--name-color-hsl) / .5)`
|
|
529
|
+
* - `'oklch'` — suffix `-oklch`, e.g. `oklch(var(--name-color-oklch) / .5)`
|
|
530
|
+
*
|
|
531
|
+
* @default 'oklch'
|
|
532
|
+
*/
|
|
533
|
+
colorSpace?: ColorSpace;
|
|
534
|
+
/**
|
|
535
|
+
* Automatically infer and register CSS @property declarations
|
|
536
|
+
* from custom property values found in styles, keyframes, and global config.
|
|
537
|
+
* Covers all types: \<color\>, \<number\>, \<length\>, \<angle\>, \<percentage\>, \<time\>.
|
|
538
|
+
* When false, only explicitly declared @properties are registered.
|
|
539
|
+
* @default true
|
|
540
|
+
*/
|
|
541
|
+
autoPropertyTypes?: boolean;
|
|
542
|
+
/**
|
|
543
|
+
* Garbage collection configuration for unused styles.
|
|
544
|
+
* GC is triggered by touch count: every `touchInterval` touches, the
|
|
545
|
+
* oldest unused styles are evicted when their count exceeds `capacity`.
|
|
546
|
+
* @example
|
|
547
|
+
* ```ts
|
|
548
|
+
* configure({
|
|
549
|
+
* gc: { touchInterval: 1000, capacity: 1000 },
|
|
550
|
+
* });
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
gc?: GCConfig;
|
|
554
|
+
/**
|
|
555
|
+
* Plugins that extend tasty with custom functions, units, or states.
|
|
556
|
+
* Plugins are processed in order, with later plugins overriding earlier ones.
|
|
557
|
+
* @example
|
|
558
|
+
* ```ts
|
|
559
|
+
* import { okhslPlugin } from '@tenphi/tasty';
|
|
560
|
+
*
|
|
561
|
+
* configure({
|
|
562
|
+
* plugins: [okhslPlugin()],
|
|
563
|
+
* });
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
plugins?: TastyPlugin[];
|
|
567
|
+
/**
|
|
568
|
+
* Global keyframes definitions that can be referenced by animation names in styles.
|
|
569
|
+
* Keys are animation names, values are keyframes step definitions.
|
|
570
|
+
* Keyframes are only injected when actually used in styles.
|
|
571
|
+
* @example
|
|
572
|
+
* ```ts
|
|
573
|
+
* configure({
|
|
574
|
+
* keyframes: {
|
|
575
|
+
* fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
|
|
576
|
+
* pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
|
|
577
|
+
* },
|
|
578
|
+
* });
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
keyframes?: Record<string, KeyframesSteps>;
|
|
582
|
+
/**
|
|
583
|
+
* Global CSS @property definitions for custom properties.
|
|
584
|
+
* Keys use tasty token syntax ($name for properties, #name for colors).
|
|
585
|
+
*
|
|
586
|
+
* Tasty ships with `DEFAULT_PROPERTIES` (e.g. `$gap`, `$radius`, `#white`,
|
|
587
|
+
* `#black`, `#clear`, `#border`, etc.) that are always included.
|
|
588
|
+
* Properties you specify here are merged on top, so you can override any
|
|
589
|
+
* default by using the same key.
|
|
590
|
+
*
|
|
591
|
+
* For color tokens (#name), `syntax: '<color>'` is auto-set and
|
|
592
|
+
* `initialValue` defaults to `'transparent'` if not specified.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```ts
|
|
596
|
+
* configure({
|
|
597
|
+
* properties: {
|
|
598
|
+
* '$rotation': { syntax: '<angle>', initialValue: '0deg' },
|
|
599
|
+
* '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
|
|
600
|
+
* '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
|
|
601
|
+
* // Override a default property:
|
|
602
|
+
* '$gap': { syntax: '<length>', inherits: true, initialValue: '8px' },
|
|
603
|
+
* },
|
|
604
|
+
* });
|
|
605
|
+
*
|
|
606
|
+
* // Now use in styles - properties are registered when component renders:
|
|
607
|
+
* const Spinner = tasty({
|
|
608
|
+
* styles: {
|
|
609
|
+
* transform: 'rotate($rotation)',
|
|
610
|
+
* transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
|
|
611
|
+
* },
|
|
612
|
+
* });
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
properties?: Record<string, PropertyDefinition>;
|
|
616
|
+
/**
|
|
617
|
+
* Global @font-face definitions.
|
|
618
|
+
* Keys are font-family names, values are descriptors or arrays of descriptors
|
|
619
|
+
* (for multiple weights/styles of the same family).
|
|
620
|
+
* Injected eagerly when styles are first generated.
|
|
621
|
+
* @example
|
|
622
|
+
* ```ts
|
|
623
|
+
* configure({
|
|
624
|
+
* fontFace: {
|
|
625
|
+
* 'Brand Sans': [
|
|
626
|
+
* { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
|
|
627
|
+
* { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
|
|
628
|
+
* ],
|
|
629
|
+
* Icons: { src: 'url("/fonts/icons.woff2") format("woff2")', fontDisplay: 'block' },
|
|
630
|
+
* },
|
|
631
|
+
* });
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
634
|
+
fontFace?: Record<string, FontFaceInput>;
|
|
635
|
+
/**
|
|
636
|
+
* Global @counter-style definitions.
|
|
637
|
+
* Keys are counter-style names, values are descriptor objects.
|
|
638
|
+
* Injected eagerly when styles are first generated.
|
|
639
|
+
* @example
|
|
640
|
+
* ```ts
|
|
641
|
+
* configure({
|
|
642
|
+
* counterStyle: {
|
|
643
|
+
* thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' },
|
|
644
|
+
* },
|
|
645
|
+
* });
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
counterStyle?: Record<string, CounterStyleDescriptors>;
|
|
649
|
+
/**
|
|
650
|
+
* Custom style handlers that transform style properties into CSS declarations.
|
|
651
|
+
* Handlers replace built-in handlers for the same style name.
|
|
652
|
+
* @example
|
|
653
|
+
* ```ts
|
|
654
|
+
* import { styleHandlers } from '@tenphi/tasty';
|
|
655
|
+
*
|
|
656
|
+
* configure({
|
|
657
|
+
* handlers: {
|
|
658
|
+
* // Override fill with custom behavior
|
|
659
|
+
* fill: ({ fill }) => {
|
|
660
|
+
* if (fill?.startsWith('gradient:')) {
|
|
661
|
+
* return { background: fill.slice(9) };
|
|
662
|
+
* }
|
|
663
|
+
* return styleHandlers.fill({ fill });
|
|
664
|
+
* },
|
|
665
|
+
* // Add new custom style
|
|
666
|
+
* elevation: ({ elevation }) => {
|
|
667
|
+
* const level = parseInt(elevation) || 1;
|
|
668
|
+
* return {
|
|
669
|
+
* 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
|
|
670
|
+
* 'z-index': String(level * 100),
|
|
671
|
+
* };
|
|
672
|
+
* },
|
|
673
|
+
* },
|
|
674
|
+
* });
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
677
|
+
handlers?: Record<string, StyleHandlerDefinition>;
|
|
678
|
+
/**
|
|
679
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
680
|
+
* Values are parsed through the Tasty DSL. Supports state maps
|
|
681
|
+
* for responsive/theme-aware tokens.
|
|
682
|
+
*
|
|
683
|
+
* - `$name` keys become `--name` CSS custom properties
|
|
684
|
+
* - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties
|
|
685
|
+
*
|
|
686
|
+
* Tokens are injected once when the first style is rendered.
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* configure({
|
|
691
|
+
* tokens: {
|
|
692
|
+
* '$gap': '4px',
|
|
693
|
+
* '#primary': {
|
|
694
|
+
* '': '#purple',
|
|
695
|
+
* '@dark': '#light-purple',
|
|
696
|
+
* },
|
|
697
|
+
* },
|
|
698
|
+
* });
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
701
|
+
tokens?: ConfigTokens;
|
|
702
|
+
/**
|
|
703
|
+
* Predefined tokens that are replaced during style parsing (parse-time substitution).
|
|
704
|
+
* Use `$name` for custom properties and `#name` for color tokens.
|
|
705
|
+
* Values are substituted inline before CSS generation, unlike `tokens` which
|
|
706
|
+
* inject CSS custom properties on `:root`.
|
|
707
|
+
*
|
|
708
|
+
* For color tokens (#name), boolean `true` is converted to `transparent`.
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```ts
|
|
712
|
+
* configure({
|
|
713
|
+
* replaceTokens: {
|
|
714
|
+
* $spacing: '2x',
|
|
715
|
+
* '#accent': '#purple',
|
|
716
|
+
* '#overlay': true, // → transparent
|
|
717
|
+
* },
|
|
718
|
+
* });
|
|
719
|
+
*
|
|
720
|
+
* // Now use in styles - tokens are replaced at parse time:
|
|
721
|
+
* const Card = tasty({
|
|
722
|
+
* styles: {
|
|
723
|
+
* padding: '$spacing', // → calc(2 * var(--gap))
|
|
724
|
+
* fill: '#accent', // → var(--purple-color)
|
|
725
|
+
* },
|
|
726
|
+
* });
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
replaceTokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
|
|
730
|
+
/**
|
|
731
|
+
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
732
|
+
* Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
|
|
733
|
+
* tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
|
|
734
|
+
*
|
|
735
|
+
* Components reference recipes via: `recipe: 'name1 name2'` in their styles.
|
|
736
|
+
* Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
|
|
737
|
+
* Use `none` to skip base recipes: `recipe: 'none / post1'`.
|
|
738
|
+
* Resolution order: `base_recipes → component styles → post_recipes`.
|
|
739
|
+
*
|
|
740
|
+
* Recipes cannot reference other recipes.
|
|
741
|
+
*
|
|
742
|
+
* @example
|
|
743
|
+
* ```ts
|
|
744
|
+
* configure({
|
|
745
|
+
* recipes: {
|
|
746
|
+
* card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
747
|
+
* elevated: { shadow: '2x 2x 4x #shadow' },
|
|
748
|
+
* },
|
|
749
|
+
* });
|
|
750
|
+
*
|
|
751
|
+
* // Usage in styles:
|
|
752
|
+
* const Card = tasty({
|
|
753
|
+
* styles: {
|
|
754
|
+
* recipe: 'card elevated',
|
|
755
|
+
* color: '#text', // Overrides recipe values
|
|
756
|
+
* },
|
|
757
|
+
* });
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
recipes?: Record<string, RecipeStyles>;
|
|
761
|
+
/**
|
|
762
|
+
* Typography presets — shorthand for `generateTypographyTokens()`.
|
|
763
|
+
* Accepts the same input and internally generates typography tokens
|
|
764
|
+
* that are merged into `tokens`. Explicit `tokens` override preset-generated ones.
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* ```ts
|
|
768
|
+
* configure({
|
|
769
|
+
* presets: {
|
|
770
|
+
* h1: { fontSize: '32px', lineHeight: '1.2', fontWeight: '700' },
|
|
771
|
+
* t2: { fontSize: '16px', lineHeight: '1.5', fontWeight: '400' },
|
|
772
|
+
* },
|
|
773
|
+
* tokens: {
|
|
774
|
+
* // Overrides the preset-generated $t2-font-weight
|
|
775
|
+
* '$t2-font-weight': { '': '400', '@dark': '300' },
|
|
776
|
+
* },
|
|
777
|
+
* });
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
presets?: Record<string, TypographyPreset>;
|
|
781
|
+
/**
|
|
782
|
+
* Global Tasty styles keyed by CSS selector.
|
|
783
|
+
* Each entry applies the full Tasty style syntax (style properties,
|
|
784
|
+
* tokens, state maps, selector-based sub-styling) to the given selector.
|
|
785
|
+
* Injected alongside `:root` tokens when the first style is rendered.
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* ```ts
|
|
789
|
+
* configure({
|
|
790
|
+
* globalStyles: {
|
|
791
|
+
* body: { fill: '#surface', color: '#text', preset: 't2', margin: 0 },
|
|
792
|
+
* html: { overflow: 'hidden' },
|
|
793
|
+
* },
|
|
794
|
+
* });
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
globalStyles?: Record<string, Styles>;
|
|
798
|
+
}
|
|
799
|
+
declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
|
|
800
|
+
declare global {
|
|
801
|
+
interface Window {
|
|
802
|
+
[GLOBAL_INJECTOR_KEY]?: StyleInjector;
|
|
803
|
+
}
|
|
804
|
+
var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Detect if we're running in a test environment
|
|
808
|
+
*/
|
|
809
|
+
declare function isTestEnvironment(): boolean;
|
|
810
|
+
/**
|
|
811
|
+
* Check if styles have been generated (configuration is locked)
|
|
812
|
+
*/
|
|
813
|
+
declare function hasStylesGenerated(): boolean;
|
|
814
|
+
/**
|
|
815
|
+
* Check if any global keyframes are configured.
|
|
816
|
+
* Uses a pre-computed flag to avoid Object.keys() allocation on every call.
|
|
817
|
+
*/
|
|
818
|
+
declare function hasGlobalKeyframes(): boolean;
|
|
819
|
+
/**
|
|
820
|
+
* Get global keyframes configuration.
|
|
821
|
+
* Returns null if no keyframes configured (fast path for zero-overhead).
|
|
822
|
+
*/
|
|
823
|
+
declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
|
|
824
|
+
/**
|
|
825
|
+
* Get global font-face configuration.
|
|
826
|
+
* Returns null if no font faces configured.
|
|
827
|
+
* Reads from globalThis first for cross-module SSR support.
|
|
828
|
+
*/
|
|
829
|
+
declare function getGlobalFontFace(): Record<string, FontFaceInput> | null;
|
|
830
|
+
/**
|
|
831
|
+
* Get global counter-style configuration.
|
|
832
|
+
* Returns null if no counter styles configured.
|
|
833
|
+
* Reads from globalThis first for cross-module SSR support.
|
|
834
|
+
*/
|
|
835
|
+
declare function getGlobalCounterStyle(): Record<string, CounterStyleDescriptors> | null;
|
|
836
|
+
/**
|
|
837
|
+
* Check if any global recipes are configured.
|
|
838
|
+
* Fast path: returns false if no recipes were ever set.
|
|
839
|
+
*/
|
|
840
|
+
declare function hasGlobalRecipes(): boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Get global recipes configuration.
|
|
843
|
+
* Returns null if no recipes configured (fast path for zero-overhead).
|
|
844
|
+
*/
|
|
845
|
+
declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
|
|
846
|
+
/**
|
|
847
|
+
* Check if configuration is locked (styles have been generated)
|
|
848
|
+
*/
|
|
849
|
+
declare function isConfigLocked(): boolean;
|
|
850
|
+
/**
|
|
851
|
+
* Configure the Tasty style system.
|
|
852
|
+
*
|
|
853
|
+
* Must be called BEFORE any styles are generated (before first render that uses tasty).
|
|
854
|
+
* After styles are generated, configuration is locked and calls to configure() will
|
|
855
|
+
* emit a warning and be ignored.
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* ```ts
|
|
859
|
+
* import { configure } from '@tenphi/tasty';
|
|
860
|
+
*
|
|
861
|
+
* // Configure before app renders
|
|
862
|
+
* configure({
|
|
863
|
+
* nonce: 'abc123',
|
|
864
|
+
* states: {
|
|
865
|
+
* '@mobile': '@media(w < 768px)',
|
|
866
|
+
* '@dark': '@root(theme=dark)',
|
|
867
|
+
* },
|
|
868
|
+
* });
|
|
869
|
+
* ```
|
|
870
|
+
*/
|
|
871
|
+
declare function configure(config?: Partial<TastyConfig>): void;
|
|
872
|
+
/**
|
|
873
|
+
* Get the current configuration.
|
|
874
|
+
* If not configured, returns default configuration.
|
|
875
|
+
*/
|
|
876
|
+
declare function getConfig(): TastyConfig;
|
|
877
|
+
/**
|
|
878
|
+
* Reset configuration (for testing only).
|
|
879
|
+
* Clears the global injector and allows reconfiguration.
|
|
880
|
+
*/
|
|
881
|
+
declare function resetConfig(): void;
|
|
882
|
+
//#endregion
|
|
883
|
+
export { TypographyTokenValue as _, getGlobalFontFace as a, StyleInjector as b, hasGlobalKeyframes as c, isConfigLocked as d, isTestEnvironment as f, TypographyPreset as g, TastyPluginFactory as h, getGlobalCounterStyle as i, hasGlobalRecipes as l, TastyPlugin as m, configure as n, getGlobalKeyframes as o, resetConfig as p, getConfig as r, getGlobalRecipes as s, TastyConfig as t, hasStylesGenerated as u, generateTypographyTokens as v, SheetManager as x, ColorSpace as y };
|
|
884
|
+
//# sourceMappingURL=config-vuCRkBWX.d.ts.map
|