@tenphi/tasty 0.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/LICENSE +21 -0
- package/README.md +236 -0
- package/dist/_virtual/_rolldown/runtime.mjs +7 -0
- package/dist/chunks/cacheKey.d.ts +1 -0
- package/dist/chunks/cacheKey.js +70 -0
- package/dist/chunks/cacheKey.js.map +1 -0
- package/dist/chunks/cacheKey.mjs +70 -0
- package/dist/chunks/cacheKey.mjs.map +1 -0
- package/dist/chunks/definitions.d.ts +37 -0
- package/dist/chunks/definitions.js +260 -0
- package/dist/chunks/definitions.js.map +1 -0
- package/dist/chunks/definitions.mjs +260 -0
- package/dist/chunks/definitions.mjs.map +1 -0
- package/dist/chunks/index.d.ts +3 -0
- package/dist/chunks/renderChunk.d.ts +2 -0
- package/dist/chunks/renderChunk.js +61 -0
- package/dist/chunks/renderChunk.js.map +1 -0
- package/dist/chunks/renderChunk.mjs +61 -0
- package/dist/chunks/renderChunk.mjs.map +1 -0
- package/dist/config.d.ts +279 -0
- package/dist/config.js +400 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +231 -0
- package/dist/config.mjs.map +1 -0
- package/dist/css-writer.d.mts +45 -0
- package/dist/css-writer.mjs +74 -0
- package/dist/css-writer.mjs.map +1 -0
- package/dist/debug.d.ts +204 -0
- package/dist/debug.js +733 -0
- package/dist/debug.js.map +1 -0
- package/dist/extractor.d.mts +24 -0
- package/dist/extractor.mjs +150 -0
- package/dist/extractor.mjs.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useGlobalStyles.d.ts +27 -0
- package/dist/hooks/useGlobalStyles.js +56 -0
- package/dist/hooks/useGlobalStyles.js.map +1 -0
- package/dist/hooks/useKeyframes.d.ts +56 -0
- package/dist/hooks/useKeyframes.js +54 -0
- package/dist/hooks/useKeyframes.js.map +1 -0
- package/dist/hooks/useProperty.d.ts +79 -0
- package/dist/hooks/useProperty.js +91 -0
- package/dist/hooks/useProperty.js.map +1 -0
- package/dist/hooks/useRawCSS.d.ts +53 -0
- package/dist/hooks/useRawCSS.js +28 -0
- package/dist/hooks/useRawCSS.js.map +1 -0
- package/dist/hooks/useStyles.d.ts +40 -0
- package/dist/hooks/useStyles.js +169 -0
- package/dist/hooks/useStyles.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +30 -0
- package/dist/injector/index.d.ts +157 -0
- package/dist/injector/index.js +154 -0
- package/dist/injector/index.js.map +1 -0
- package/dist/injector/injector.d.ts +139 -0
- package/dist/injector/injector.js +404 -0
- package/dist/injector/injector.js.map +1 -0
- package/dist/injector/injector.mjs +404 -0
- package/dist/injector/injector.mjs.map +1 -0
- package/dist/injector/sheet-manager.d.ts +127 -0
- package/dist/injector/sheet-manager.js +714 -0
- package/dist/injector/sheet-manager.js.map +1 -0
- package/dist/injector/sheet-manager.mjs +714 -0
- package/dist/injector/sheet-manager.mjs.map +1 -0
- package/dist/injector/types.d.mts +18 -0
- package/dist/injector/types.d.ts +135 -0
- package/dist/keyframes/index.js +206 -0
- package/dist/keyframes/index.js.map +1 -0
- package/dist/keyframes/index.mjs +156 -0
- package/dist/keyframes/index.mjs.map +1 -0
- package/dist/parser/classify.js +319 -0
- package/dist/parser/classify.js.map +1 -0
- package/dist/parser/classify.mjs +319 -0
- package/dist/parser/classify.mjs.map +1 -0
- package/dist/parser/const.js +33 -0
- package/dist/parser/const.js.map +1 -0
- package/dist/parser/const.mjs +33 -0
- package/dist/parser/const.mjs.map +1 -0
- package/dist/parser/lru.js +109 -0
- package/dist/parser/lru.js.map +1 -0
- package/dist/parser/lru.mjs +109 -0
- package/dist/parser/lru.mjs.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +116 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/parser.mjs +116 -0
- package/dist/parser/parser.mjs.map +1 -0
- package/dist/parser/tokenizer.js +69 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/tokenizer.mjs +69 -0
- package/dist/parser/tokenizer.mjs.map +1 -0
- package/dist/parser/types.d.mts +37 -0
- package/dist/parser/types.d.ts +46 -0
- package/dist/parser/types.js +46 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/parser/types.mjs +46 -0
- package/dist/parser/types.mjs.map +1 -0
- package/dist/pipeline/conditions.js +377 -0
- package/dist/pipeline/conditions.js.map +1 -0
- package/dist/pipeline/conditions.mjs +377 -0
- package/dist/pipeline/conditions.mjs.map +1 -0
- package/dist/pipeline/exclusive.d.ts +1 -0
- package/dist/pipeline/exclusive.js +231 -0
- package/dist/pipeline/exclusive.js.map +1 -0
- package/dist/pipeline/exclusive.mjs +231 -0
- package/dist/pipeline/exclusive.mjs.map +1 -0
- package/dist/pipeline/index.d.ts +53 -0
- package/dist/pipeline/index.js +641 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/index.mjs +635 -0
- package/dist/pipeline/index.mjs.map +1 -0
- package/dist/pipeline/materialize.js +821 -0
- package/dist/pipeline/materialize.js.map +1 -0
- package/dist/pipeline/materialize.mjs +821 -0
- package/dist/pipeline/materialize.mjs.map +1 -0
- package/dist/pipeline/parseStateKey.d.ts +1 -0
- package/dist/pipeline/parseStateKey.js +418 -0
- package/dist/pipeline/parseStateKey.js.map +1 -0
- package/dist/pipeline/parseStateKey.mjs +418 -0
- package/dist/pipeline/parseStateKey.mjs.map +1 -0
- package/dist/pipeline/simplify.js +557 -0
- package/dist/pipeline/simplify.js.map +1 -0
- package/dist/pipeline/simplify.mjs +557 -0
- package/dist/pipeline/simplify.mjs.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/okhsl-plugin.d.ts +35 -0
- package/dist/plugins/okhsl-plugin.js +371 -0
- package/dist/plugins/okhsl-plugin.js.map +1 -0
- package/dist/plugins/okhsl-plugin.mjs +345 -0
- package/dist/plugins/okhsl-plugin.mjs.map +1 -0
- package/dist/plugins/types.d.mts +49 -0
- package/dist/plugins/types.d.ts +69 -0
- package/dist/properties/index.js +158 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/index.mjs +141 -0
- package/dist/properties/index.mjs.map +1 -0
- package/dist/states/index.d.ts +45 -0
- package/dist/states/index.js +389 -0
- package/dist/states/index.js.map +1 -0
- package/dist/states/index.mjs +161 -0
- package/dist/states/index.mjs.map +1 -0
- package/dist/static/index.d.ts +5 -0
- package/dist/static/index.js +5 -0
- package/dist/static/tastyStatic.d.ts +46 -0
- package/dist/static/tastyStatic.js +31 -0
- package/dist/static/tastyStatic.js.map +1 -0
- package/dist/static/types.d.ts +49 -0
- package/dist/static/types.js +24 -0
- package/dist/static/types.js.map +1 -0
- package/dist/styles/align.d.ts +15 -0
- package/dist/styles/align.js +14 -0
- package/dist/styles/align.js.map +1 -0
- package/dist/styles/align.mjs +14 -0
- package/dist/styles/align.mjs.map +1 -0
- package/dist/styles/border.d.ts +25 -0
- package/dist/styles/border.js +114 -0
- package/dist/styles/border.js.map +1 -0
- package/dist/styles/border.mjs +114 -0
- package/dist/styles/border.mjs.map +1 -0
- package/dist/styles/color.d.ts +14 -0
- package/dist/styles/color.js +23 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/color.mjs +23 -0
- package/dist/styles/color.mjs.map +1 -0
- package/dist/styles/createStyle.js +77 -0
- package/dist/styles/createStyle.js.map +1 -0
- package/dist/styles/createStyle.mjs +77 -0
- package/dist/styles/createStyle.mjs.map +1 -0
- package/dist/styles/dimension.js +97 -0
- package/dist/styles/dimension.js.map +1 -0
- package/dist/styles/dimension.mjs +97 -0
- package/dist/styles/dimension.mjs.map +1 -0
- package/dist/styles/display.d.ts +37 -0
- package/dist/styles/display.js +67 -0
- package/dist/styles/display.js.map +1 -0
- package/dist/styles/display.mjs +67 -0
- package/dist/styles/display.mjs.map +1 -0
- package/dist/styles/fade.d.ts +15 -0
- package/dist/styles/fade.js +58 -0
- package/dist/styles/fade.js.map +1 -0
- package/dist/styles/fade.mjs +58 -0
- package/dist/styles/fade.mjs.map +1 -0
- package/dist/styles/fill.d.ts +44 -0
- package/dist/styles/fill.js +51 -0
- package/dist/styles/fill.js.map +1 -0
- package/dist/styles/fill.mjs +51 -0
- package/dist/styles/fill.mjs.map +1 -0
- package/dist/styles/flow.d.ts +16 -0
- package/dist/styles/flow.js +12 -0
- package/dist/styles/flow.js.map +1 -0
- package/dist/styles/flow.mjs +12 -0
- package/dist/styles/flow.mjs.map +1 -0
- package/dist/styles/gap.d.ts +31 -0
- package/dist/styles/gap.js +37 -0
- package/dist/styles/gap.js.map +1 -0
- package/dist/styles/gap.mjs +37 -0
- package/dist/styles/gap.mjs.map +1 -0
- package/dist/styles/height.d.ts +17 -0
- package/dist/styles/height.js +20 -0
- package/dist/styles/height.js.map +1 -0
- package/dist/styles/height.mjs +20 -0
- package/dist/styles/height.mjs.map +1 -0
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +9 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/index.mjs +9 -0
- package/dist/styles/index.mjs.map +1 -0
- package/dist/styles/inset.d.ts +50 -0
- package/dist/styles/inset.js +142 -0
- package/dist/styles/inset.js.map +1 -0
- package/dist/styles/inset.mjs +142 -0
- package/dist/styles/inset.mjs.map +1 -0
- package/dist/styles/justify.d.ts +15 -0
- package/dist/styles/justify.js +14 -0
- package/dist/styles/justify.js.map +1 -0
- package/dist/styles/justify.mjs +14 -0
- package/dist/styles/justify.mjs.map +1 -0
- package/dist/styles/list.d.ts +16 -0
- package/dist/styles/list.js +98 -0
- package/dist/styles/list.js.map +1 -0
- package/dist/styles/margin.d.ts +28 -0
- package/dist/styles/margin.js +96 -0
- package/dist/styles/margin.js.map +1 -0
- package/dist/styles/margin.mjs +96 -0
- package/dist/styles/margin.mjs.map +1 -0
- package/dist/styles/outline.d.ts +29 -0
- package/dist/styles/outline.js +65 -0
- package/dist/styles/outline.js.map +1 -0
- package/dist/styles/outline.mjs +65 -0
- package/dist/styles/outline.mjs.map +1 -0
- package/dist/styles/padding.d.ts +28 -0
- package/dist/styles/padding.js +96 -0
- package/dist/styles/padding.js.map +1 -0
- package/dist/styles/padding.mjs +96 -0
- package/dist/styles/padding.mjs.map +1 -0
- package/dist/styles/predefined.d.ts +74 -0
- package/dist/styles/predefined.js +241 -0
- package/dist/styles/predefined.js.map +1 -0
- package/dist/styles/predefined.mjs +232 -0
- package/dist/styles/predefined.mjs.map +1 -0
- package/dist/styles/preset.d.ts +47 -0
- package/dist/styles/preset.js +126 -0
- package/dist/styles/preset.js.map +1 -0
- package/dist/styles/preset.mjs +126 -0
- package/dist/styles/preset.mjs.map +1 -0
- package/dist/styles/radius.d.ts +14 -0
- package/dist/styles/radius.js +51 -0
- package/dist/styles/radius.js.map +1 -0
- package/dist/styles/radius.mjs +51 -0
- package/dist/styles/radius.mjs.map +1 -0
- package/dist/styles/scrollbar.d.ts +21 -0
- package/dist/styles/scrollbar.js +105 -0
- package/dist/styles/scrollbar.js.map +1 -0
- package/dist/styles/scrollbar.mjs +105 -0
- package/dist/styles/scrollbar.mjs.map +1 -0
- package/dist/styles/shadow.d.ts +14 -0
- package/dist/styles/shadow.js +24 -0
- package/dist/styles/shadow.js.map +1 -0
- package/dist/styles/shadow.mjs +24 -0
- package/dist/styles/shadow.mjs.map +1 -0
- package/dist/styles/styledScrollbar.d.ts +47 -0
- package/dist/styles/styledScrollbar.js +38 -0
- package/dist/styles/styledScrollbar.js.map +1 -0
- package/dist/styles/styledScrollbar.mjs +38 -0
- package/dist/styles/styledScrollbar.mjs.map +1 -0
- package/dist/styles/transition.d.ts +14 -0
- package/dist/styles/transition.js +138 -0
- package/dist/styles/transition.js.map +1 -0
- package/dist/styles/transition.mjs +138 -0
- package/dist/styles/transition.mjs.map +1 -0
- package/dist/styles/types.d.mts +492 -0
- package/dist/styles/types.d.ts +496 -0
- package/dist/styles/width.d.ts +17 -0
- package/dist/styles/width.js +20 -0
- package/dist/styles/width.js.map +1 -0
- package/dist/styles/width.mjs +20 -0
- package/dist/styles/width.mjs.map +1 -0
- package/dist/tasty.d.ts +983 -0
- package/dist/tasty.js +191 -0
- package/dist/tasty.js.map +1 -0
- package/dist/tokens/typography.d.ts +19 -0
- package/dist/tokens/typography.js +237 -0
- package/dist/tokens/typography.js.map +1 -0
- package/dist/types.d.ts +182 -0
- package/dist/utils/cache-wrapper.js +26 -0
- package/dist/utils/cache-wrapper.js.map +1 -0
- package/dist/utils/cache-wrapper.mjs +26 -0
- package/dist/utils/cache-wrapper.mjs.map +1 -0
- package/dist/utils/case-converter.js +8 -0
- package/dist/utils/case-converter.js.map +1 -0
- package/dist/utils/case-converter.mjs +8 -0
- package/dist/utils/case-converter.mjs.map +1 -0
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.js +9 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/dotize.d.ts +26 -0
- package/dist/utils/dotize.js +122 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/filter-base-props.d.ts +15 -0
- package/dist/utils/filter-base-props.js +45 -0
- package/dist/utils/filter-base-props.js.map +1 -0
- package/dist/utils/get-display-name.d.ts +7 -0
- package/dist/utils/get-display-name.js +10 -0
- package/dist/utils/get-display-name.js.map +1 -0
- package/dist/utils/hsl-to-rgb.js +38 -0
- package/dist/utils/hsl-to-rgb.js.map +1 -0
- package/dist/utils/hsl-to-rgb.mjs +38 -0
- package/dist/utils/hsl-to-rgb.mjs.map +1 -0
- package/dist/utils/is-dev-env.js +19 -0
- package/dist/utils/is-dev-env.js.map +1 -0
- package/dist/utils/is-dev-env.mjs +19 -0
- package/dist/utils/is-dev-env.mjs.map +1 -0
- package/dist/utils/merge-styles.d.ts +7 -0
- package/dist/utils/merge-styles.js +146 -0
- package/dist/utils/merge-styles.js.map +1 -0
- package/dist/utils/merge-styles.mjs +146 -0
- package/dist/utils/merge-styles.mjs.map +1 -0
- package/dist/utils/mod-attrs.d.ts +8 -0
- package/dist/utils/mod-attrs.js +21 -0
- package/dist/utils/mod-attrs.js.map +1 -0
- package/dist/utils/okhsl-to-rgb.js +296 -0
- package/dist/utils/okhsl-to-rgb.js.map +1 -0
- package/dist/utils/okhsl-to-rgb.mjs +296 -0
- package/dist/utils/okhsl-to-rgb.mjs.map +1 -0
- package/dist/utils/process-tokens.d.ts +31 -0
- package/dist/utils/process-tokens.js +171 -0
- package/dist/utils/process-tokens.js.map +1 -0
- package/dist/utils/process-tokens.mjs +28 -0
- package/dist/utils/process-tokens.mjs.map +1 -0
- package/dist/utils/resolve-recipes.d.ts +17 -0
- package/dist/utils/resolve-recipes.js +143 -0
- package/dist/utils/resolve-recipes.js.map +1 -0
- package/dist/utils/resolve-recipes.mjs +143 -0
- package/dist/utils/resolve-recipes.mjs.map +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/string.mjs +8 -0
- package/dist/utils/string.mjs.map +1 -0
- package/dist/utils/styles.d.mts +18 -0
- package/dist/utils/styles.d.ts +183 -0
- package/dist/utils/styles.js +585 -0
- package/dist/utils/styles.js.map +1 -0
- package/dist/utils/styles.mjs +346 -0
- package/dist/utils/styles.mjs.map +1 -0
- package/dist/utils/typography.d.ts +36 -0
- package/dist/utils/typography.js +53 -0
- package/dist/utils/typography.js.map +1 -0
- package/dist/utils/warnings.d.ts +16 -0
- package/dist/utils/warnings.js +16 -0
- package/dist/utils/warnings.js.map +1 -0
- package/dist/zero/babel.d.mts +108 -0
- package/dist/zero/babel.mjs +282 -0
- package/dist/zero/babel.mjs.map +1 -0
- package/dist/zero/index.d.mts +3 -0
- package/dist/zero/index.mjs +4 -0
- package/dist/zero/next.d.mts +60 -0
- package/dist/zero/next.mjs +78 -0
- package/dist/zero/next.mjs.map +1 -0
- package/package.json +127 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { CacheMetrics, DisposeFunction, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./types.js";
|
|
2
|
+
import { StyleResult } from "../pipeline/index.js";
|
|
3
|
+
import { SheetManager } from "./sheet-manager.js";
|
|
4
|
+
import { StyleInjector } from "./injector.js";
|
|
5
|
+
|
|
6
|
+
//#region src/injector/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Allocate a className for a cacheKey without injecting styles yet
|
|
9
|
+
*/
|
|
10
|
+
declare function allocateClassName(cacheKey: string, options?: {
|
|
11
|
+
root?: Document | ShadowRoot;
|
|
12
|
+
}): {
|
|
13
|
+
className: string;
|
|
14
|
+
isNewAllocation: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Inject styles and return className with dispose function
|
|
18
|
+
*/
|
|
19
|
+
declare function inject(rules: StyleResult[], options?: {
|
|
20
|
+
root?: Document | ShadowRoot;
|
|
21
|
+
cacheKey?: string;
|
|
22
|
+
}): InjectResult;
|
|
23
|
+
/**
|
|
24
|
+
* Inject global rules that should not reserve tasty class names
|
|
25
|
+
*/
|
|
26
|
+
declare function injectGlobal(rules: StyleResult[], options?: {
|
|
27
|
+
root?: Document | ShadowRoot;
|
|
28
|
+
}): GlobalInjectResult;
|
|
29
|
+
/**
|
|
30
|
+
* Inject raw CSS text directly without parsing
|
|
31
|
+
* This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.
|
|
32
|
+
* The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* // Inject raw CSS
|
|
37
|
+
* const { dispose } = injectRawCSS(`
|
|
38
|
+
* body { margin: 0; padding: 0; }
|
|
39
|
+
* .my-class { color: red; }
|
|
40
|
+
* `);
|
|
41
|
+
*
|
|
42
|
+
* // Later, remove the injected CSS
|
|
43
|
+
* dispose();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function injectRawCSS(css: string, options?: {
|
|
47
|
+
root?: Document | ShadowRoot;
|
|
48
|
+
}): {
|
|
49
|
+
dispose: () => void;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Get raw CSS text for SSR
|
|
53
|
+
*/
|
|
54
|
+
declare function getRawCSSText(options?: {
|
|
55
|
+
root?: Document | ShadowRoot;
|
|
56
|
+
}): string;
|
|
57
|
+
/**
|
|
58
|
+
* Inject keyframes and return object with toString() and dispose()
|
|
59
|
+
*/
|
|
60
|
+
declare function keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
|
|
61
|
+
root?: Document | ShadowRoot;
|
|
62
|
+
name?: string;
|
|
63
|
+
}): KeyframesResult;
|
|
64
|
+
interface PropertyOptions {
|
|
65
|
+
/**
|
|
66
|
+
* CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>')
|
|
67
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax
|
|
68
|
+
*/
|
|
69
|
+
syntax?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the property inherits from parent elements
|
|
72
|
+
* @default true
|
|
73
|
+
*/
|
|
74
|
+
inherits?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Initial value for the property
|
|
77
|
+
*/
|
|
78
|
+
initialValue?: string | number;
|
|
79
|
+
/**
|
|
80
|
+
* Shadow root or document to inject into
|
|
81
|
+
*/
|
|
82
|
+
root?: Document | ShadowRoot;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Define a CSS @property custom property.
|
|
86
|
+
* This enables advanced features like animating custom properties.
|
|
87
|
+
*
|
|
88
|
+
* Note: @property rules are global and persistent once defined.
|
|
89
|
+
* Re-registering the same property name is a no-op.
|
|
90
|
+
*
|
|
91
|
+
* @param name - The custom property name (must start with --)
|
|
92
|
+
* @param options - Property configuration
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* // Define a color property that can be animated
|
|
97
|
+
* property('--my-color', {
|
|
98
|
+
* syntax: '<color>',
|
|
99
|
+
* initialValue: 'red',
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* // Define an angle property
|
|
103
|
+
* property('--rotation', {
|
|
104
|
+
* syntax: '<angle>',
|
|
105
|
+
* inherits: false,
|
|
106
|
+
* initialValue: '0deg',
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare function property(name: string, options?: PropertyOptions): void;
|
|
111
|
+
/**
|
|
112
|
+
* Check if a CSS @property has already been defined
|
|
113
|
+
*
|
|
114
|
+
* @param name - The custom property name to check
|
|
115
|
+
* @param options - Options including root
|
|
116
|
+
*/
|
|
117
|
+
declare function isPropertyDefined(name: string, options?: {
|
|
118
|
+
root?: Document | ShadowRoot;
|
|
119
|
+
}): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Get CSS text from all sheets (for SSR)
|
|
122
|
+
*/
|
|
123
|
+
declare function getCssText(options?: {
|
|
124
|
+
root?: Document | ShadowRoot;
|
|
125
|
+
}): string;
|
|
126
|
+
/**
|
|
127
|
+
* Collect only CSS used by a rendered subtree (like jest-styled-components).
|
|
128
|
+
* Pass the container returned by render(...).
|
|
129
|
+
*/
|
|
130
|
+
declare function getCssTextForNode(node: ParentNode | Element | DocumentFragment, options?: {
|
|
131
|
+
root?: Document | ShadowRoot;
|
|
132
|
+
}): string;
|
|
133
|
+
/**
|
|
134
|
+
* Force cleanup of unused rules
|
|
135
|
+
*/
|
|
136
|
+
declare function cleanup(root?: Document | ShadowRoot): void;
|
|
137
|
+
/**
|
|
138
|
+
* Check if we're currently running in a test environment
|
|
139
|
+
*/
|
|
140
|
+
declare function getIsTestEnvironment(): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Get the global injector instance for debugging
|
|
143
|
+
*/
|
|
144
|
+
declare const injector: {
|
|
145
|
+
readonly instance: StyleInjector;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Destroy all resources and clean up
|
|
149
|
+
*/
|
|
150
|
+
declare function destroy(root?: Document | ShadowRoot): void;
|
|
151
|
+
/**
|
|
152
|
+
* Create a new isolated injector instance
|
|
153
|
+
*/
|
|
154
|
+
declare function createInjector(config?: Partial<StyleInjectorConfig>): StyleInjector;
|
|
155
|
+
//#endregion
|
|
156
|
+
export { PropertyOptions, allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property };
|
|
157
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { SheetManager } from "./sheet-manager.js";
|
|
2
|
+
import { StyleInjector } from "./injector.js";
|
|
3
|
+
import { getConfig, getGlobalInjector, isTestEnvironment, markStylesGenerated } from "../config.js";
|
|
4
|
+
|
|
5
|
+
//#region src/injector/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Allocate a className for a cacheKey without injecting styles yet
|
|
8
|
+
*/
|
|
9
|
+
function allocateClassName(cacheKey, options) {
|
|
10
|
+
return getGlobalInjector().allocateClassName(cacheKey, options);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Inject styles and return className with dispose function
|
|
14
|
+
*/
|
|
15
|
+
function inject(rules, options) {
|
|
16
|
+
markStylesGenerated();
|
|
17
|
+
return getGlobalInjector().inject(rules, options);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inject global rules that should not reserve tasty class names
|
|
21
|
+
*/
|
|
22
|
+
function injectGlobal(rules, options) {
|
|
23
|
+
return getGlobalInjector().injectGlobal(rules, options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Inject raw CSS text directly without parsing
|
|
27
|
+
* This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.
|
|
28
|
+
* The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Inject raw CSS
|
|
33
|
+
* const { dispose } = injectRawCSS(`
|
|
34
|
+
* body { margin: 0; padding: 0; }
|
|
35
|
+
* .my-class { color: red; }
|
|
36
|
+
* `);
|
|
37
|
+
*
|
|
38
|
+
* // Later, remove the injected CSS
|
|
39
|
+
* dispose();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function injectRawCSS(css, options) {
|
|
43
|
+
return getGlobalInjector().injectRawCSS(css, options);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get raw CSS text for SSR
|
|
47
|
+
*/
|
|
48
|
+
function getRawCSSText(options) {
|
|
49
|
+
return getGlobalInjector().getRawCSSText(options);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Inject keyframes and return object with toString() and dispose()
|
|
53
|
+
*/
|
|
54
|
+
function keyframes(steps, nameOrOptions) {
|
|
55
|
+
return getGlobalInjector().keyframes(steps, nameOrOptions);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Define a CSS @property custom property.
|
|
59
|
+
* This enables advanced features like animating custom properties.
|
|
60
|
+
*
|
|
61
|
+
* Note: @property rules are global and persistent once defined.
|
|
62
|
+
* Re-registering the same property name is a no-op.
|
|
63
|
+
*
|
|
64
|
+
* @param name - The custom property name (must start with --)
|
|
65
|
+
* @param options - Property configuration
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* // Define a color property that can be animated
|
|
70
|
+
* property('--my-color', {
|
|
71
|
+
* syntax: '<color>',
|
|
72
|
+
* initialValue: 'red',
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Define an angle property
|
|
76
|
+
* property('--rotation', {
|
|
77
|
+
* syntax: '<angle>',
|
|
78
|
+
* inherits: false,
|
|
79
|
+
* initialValue: '0deg',
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
function property(name, options) {
|
|
84
|
+
return getGlobalInjector().property(name, options);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if a CSS @property has already been defined
|
|
88
|
+
*
|
|
89
|
+
* @param name - The custom property name to check
|
|
90
|
+
* @param options - Options including root
|
|
91
|
+
*/
|
|
92
|
+
function isPropertyDefined(name, options) {
|
|
93
|
+
return getGlobalInjector().isPropertyDefined(name, options);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get CSS text from all sheets (for SSR)
|
|
97
|
+
*/
|
|
98
|
+
function getCssText(options) {
|
|
99
|
+
return getGlobalInjector().getCssText(options);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Collect only CSS used by a rendered subtree (like jest-styled-components).
|
|
103
|
+
* Pass the container returned by render(...).
|
|
104
|
+
*/
|
|
105
|
+
function getCssTextForNode(node, options) {
|
|
106
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
107
|
+
const readClasses = (el) => {
|
|
108
|
+
const cls = el.getAttribute("class");
|
|
109
|
+
if (!cls) return;
|
|
110
|
+
for (const token of cls.split(/\s+/)) if (/^t\d+$/.test(token)) classSet.add(token);
|
|
111
|
+
};
|
|
112
|
+
if (node.getAttribute) readClasses(node);
|
|
113
|
+
const elements = node.querySelectorAll ? node.querySelectorAll("[class]") : [];
|
|
114
|
+
if (elements) elements.forEach(readClasses);
|
|
115
|
+
return getGlobalInjector().getCssTextForClasses(classSet, options);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Force cleanup of unused rules
|
|
119
|
+
*/
|
|
120
|
+
function cleanup(root) {
|
|
121
|
+
return getGlobalInjector().cleanup(root);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if we're currently running in a test environment
|
|
125
|
+
*/
|
|
126
|
+
function getIsTestEnvironment() {
|
|
127
|
+
return isTestEnvironment();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get the global injector instance for debugging
|
|
131
|
+
*/
|
|
132
|
+
const injector = { get instance() {
|
|
133
|
+
return getGlobalInjector();
|
|
134
|
+
} };
|
|
135
|
+
/**
|
|
136
|
+
* Destroy all resources and clean up
|
|
137
|
+
*/
|
|
138
|
+
function destroy(root) {
|
|
139
|
+
return getGlobalInjector().destroy(root);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new isolated injector instance
|
|
143
|
+
*/
|
|
144
|
+
function createInjector(config = {}) {
|
|
145
|
+
return new StyleInjector({
|
|
146
|
+
...getConfig(),
|
|
147
|
+
forceTextInjection: config.forceTextInjection ?? isTestEnvironment(),
|
|
148
|
+
...config
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
export { allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property };
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/injector/index.ts"],"sourcesContent":["import {\n getConfig,\n getGlobalInjector,\n isTestEnvironment,\n markStylesGenerated,\n} from '../config';\nimport type { StyleResult } from '../pipeline';\n\nimport { StyleInjector } from './injector';\nimport type {\n GlobalInjectResult,\n InjectResult,\n KeyframesResult,\n KeyframesSteps,\n StyleInjectorConfig,\n} from './types';\n\n/**\n * Allocate a className for a cacheKey without injecting styles yet\n */\nexport function allocateClassName(\n cacheKey: string,\n options?: { root?: Document | ShadowRoot },\n): { className: string; isNewAllocation: boolean } {\n return getGlobalInjector().allocateClassName(cacheKey, options);\n}\n\n/**\n * Inject styles and return className with dispose function\n */\nexport function inject(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot; cacheKey?: string },\n): InjectResult {\n // Mark that styles have been generated (prevents configuration changes)\n markStylesGenerated();\n\n return getGlobalInjector().inject(rules, options);\n}\n\n/**\n * Inject global rules that should not reserve tasty class names\n */\nexport function injectGlobal(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot },\n): GlobalInjectResult {\n return getGlobalInjector().injectGlobal(rules, options);\n}\n\n/**\n * Inject raw CSS text directly without parsing\n * This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.\n * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.\n *\n * @example\n * ```tsx\n * // Inject raw CSS\n * const { dispose } = injectRawCSS(`\n * body { margin: 0; padding: 0; }\n * .my-class { color: red; }\n * `);\n *\n * // Later, remove the injected CSS\n * dispose();\n * ```\n */\nexport function injectRawCSS(\n css: string,\n options?: { root?: Document | ShadowRoot },\n): { dispose: () => void } {\n return getGlobalInjector().injectRawCSS(css, options);\n}\n\n/**\n * Get raw CSS text for SSR\n */\nexport function getRawCSSText(options?: {\n root?: Document | ShadowRoot;\n}): string {\n return getGlobalInjector().getRawCSSText(options);\n}\n\n/**\n * Inject keyframes and return object with toString() and dispose()\n */\nexport function keyframes(\n steps: KeyframesSteps,\n nameOrOptions?: string | { root?: Document | ShadowRoot; name?: string },\n): KeyframesResult {\n return getGlobalInjector().keyframes(steps, nameOrOptions);\n}\n\nexport interface PropertyOptions {\n /**\n * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>')\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax\n */\n syntax?: string;\n /**\n * Whether the property inherits from parent elements\n * @default true\n */\n inherits?: boolean;\n /**\n * Initial value for the property\n */\n initialValue?: string | number;\n /**\n * Shadow root or document to inject into\n */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Define a CSS @property custom property.\n * This enables advanced features like animating custom properties.\n *\n * Note: @property rules are global and persistent once defined.\n * Re-registering the same property name is a no-op.\n *\n * @param name - The custom property name (must start with --)\n * @param options - Property configuration\n *\n * @example\n * ```ts\n * // Define a color property that can be animated\n * property('--my-color', {\n * syntax: '<color>',\n * initialValue: 'red',\n * });\n *\n * // Define an angle property\n * property('--rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n * ```\n */\nexport function property(name: string, options?: PropertyOptions): void {\n return getGlobalInjector().property(name, options);\n}\n\n/**\n * Check if a CSS @property has already been defined\n *\n * @param name - The custom property name to check\n * @param options - Options including root\n */\nexport function isPropertyDefined(\n name: string,\n options?: { root?: Document | ShadowRoot },\n): boolean {\n return getGlobalInjector().isPropertyDefined(name, options);\n}\n\n/**\n * Get CSS text from all sheets (for SSR)\n */\nexport function getCssText(options?: { root?: Document | ShadowRoot }): string {\n return getGlobalInjector().getCssText(options);\n}\n\n/**\n * Collect only CSS used by a rendered subtree (like jest-styled-components).\n * Pass the container returned by render(...).\n */\nexport function getCssTextForNode(\n node: ParentNode | Element | DocumentFragment,\n options?: { root?: Document | ShadowRoot },\n): string {\n // Collect tasty-generated class names (t<number>) from the subtree\n const classSet = new Set<string>();\n\n const readClasses = (el: Element) => {\n const cls = el.getAttribute('class');\n if (!cls) return;\n for (const token of cls.split(/\\s+/)) {\n if (/^t\\d+$/.test(token)) classSet.add(token);\n }\n };\n\n // Include node itself if it's an Element\n if ((node as Element).getAttribute) {\n readClasses(node as Element);\n }\n // Walk descendants\n const elements = (node as ParentNode).querySelectorAll\n ? (node as ParentNode).querySelectorAll('[class]')\n : ([] as unknown as NodeListOf<Element>);\n if (elements) elements.forEach(readClasses);\n\n return getGlobalInjector().getCssTextForClasses(classSet, options);\n}\n\n/**\n * Force cleanup of unused rules\n */\nexport function cleanup(root?: Document | ShadowRoot): void {\n return getGlobalInjector().cleanup(root);\n}\n\n/**\n * Check if we're currently running in a test environment\n */\nexport function getIsTestEnvironment(): boolean {\n return isTestEnvironment();\n}\n\n/**\n * Get the global injector instance for debugging\n */\nexport const injector = {\n get instance() {\n return getGlobalInjector();\n },\n};\n\n/**\n * Destroy all resources and clean up\n */\nexport function destroy(root?: Document | ShadowRoot): void {\n return getGlobalInjector().destroy(root);\n}\n\n/**\n * Create a new isolated injector instance\n */\nexport function createInjector(\n config: Partial<StyleInjectorConfig> = {},\n): StyleInjector {\n const defaultConfig = getConfig();\n\n const fullConfig: StyleInjectorConfig = {\n ...defaultConfig,\n // Auto-enable forceTextInjection in test environments\n forceTextInjection: config.forceTextInjection ?? isTestEnvironment(),\n ...config,\n };\n\n return new StyleInjector(fullConfig);\n}\n\n// Re-export types\nexport type {\n StyleInjectorConfig,\n InjectResult,\n DisposeFunction,\n RuleInfo,\n SheetInfo,\n RootRegistry,\n StyleRule,\n KeyframesInfo,\n KeyframesResult,\n KeyframesSteps,\n KeyframesCacheEntry,\n CacheMetrics,\n RawCSSResult,\n PropertyDefinition,\n} from './types';\n\nexport { StyleInjector } from './injector';\nexport { SheetManager } from './sheet-manager';\n"],"mappings":";;;;;;;;AAoBA,SAAgB,kBACd,UACA,SACiD;AACjD,QAAO,mBAAmB,CAAC,kBAAkB,UAAU,QAAQ;;;;;AAMjE,SAAgB,OACd,OACA,SACc;AAEd,sBAAqB;AAErB,QAAO,mBAAmB,CAAC,OAAO,OAAO,QAAQ;;;;;AAMnD,SAAgB,aACd,OACA,SACoB;AACpB,QAAO,mBAAmB,CAAC,aAAa,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;AAoBzD,SAAgB,aACd,KACA,SACyB;AACzB,QAAO,mBAAmB,CAAC,aAAa,KAAK,QAAQ;;;;;AAMvD,SAAgB,cAAc,SAEnB;AACT,QAAO,mBAAmB,CAAC,cAAc,QAAQ;;;;;AAMnD,SAAgB,UACd,OACA,eACiB;AACjB,QAAO,mBAAmB,CAAC,UAAU,OAAO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkD5D,SAAgB,SAAS,MAAc,SAAiC;AACtE,QAAO,mBAAmB,CAAC,SAAS,MAAM,QAAQ;;;;;;;;AASpD,SAAgB,kBACd,MACA,SACS;AACT,QAAO,mBAAmB,CAAC,kBAAkB,MAAM,QAAQ;;;;;AAM7D,SAAgB,WAAW,SAAoD;AAC7E,QAAO,mBAAmB,CAAC,WAAW,QAAQ;;;;;;AAOhD,SAAgB,kBACd,MACA,SACQ;CAER,MAAM,2BAAW,IAAI,KAAa;CAElC,MAAM,eAAe,OAAgB;EACnC,MAAM,MAAM,GAAG,aAAa,QAAQ;AACpC,MAAI,CAAC,IAAK;AACV,OAAK,MAAM,SAAS,IAAI,MAAM,MAAM,CAClC,KAAI,SAAS,KAAK,MAAM,CAAE,UAAS,IAAI,MAAM;;AAKjD,KAAK,KAAiB,aACpB,aAAY,KAAgB;CAG9B,MAAM,WAAY,KAAoB,mBACjC,KAAoB,iBAAiB,UAAU,GAC/C,EAAE;AACP,KAAI,SAAU,UAAS,QAAQ,YAAY;AAE3C,QAAO,mBAAmB,CAAC,qBAAqB,UAAU,QAAQ;;;;;AAMpE,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,uBAAgC;AAC9C,QAAO,mBAAmB;;;;;AAM5B,MAAa,WAAW,EACtB,IAAI,WAAW;AACb,QAAO,mBAAmB;GAE7B;;;;AAKD,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,eACd,SAAuC,EAAE,EAC1B;AAUf,QAAO,IAAI,cAP6B;EACtC,GAHoB,WAAW;EAK/B,oBAAoB,OAAO,sBAAsB,mBAAmB;EACpE,GAAG;EACJ,CAEmC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { CacheMetrics, GlobalInjectResult, InjectResult, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, StyleInjectorConfig } from "./types.js";
|
|
2
|
+
import { StyleResult } from "../pipeline/index.js";
|
|
3
|
+
import { SheetManager } from "./sheet-manager.js";
|
|
4
|
+
|
|
5
|
+
//#region src/injector/injector.d.ts
|
|
6
|
+
declare class StyleInjector {
|
|
7
|
+
private sheetManager;
|
|
8
|
+
private config;
|
|
9
|
+
private cleanupScheduled;
|
|
10
|
+
private globalRuleCounter;
|
|
11
|
+
/** @internal — exposed for debug utilities only */
|
|
12
|
+
get _sheetManager(): SheetManager;
|
|
13
|
+
constructor(config?: StyleInjectorConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Allocate a className for a cacheKey without injecting styles yet.
|
|
16
|
+
* This allows separating className allocation (render phase) from style injection (insertion phase).
|
|
17
|
+
*/
|
|
18
|
+
allocateClassName(cacheKey: string, options?: {
|
|
19
|
+
root?: Document | ShadowRoot;
|
|
20
|
+
}): {
|
|
21
|
+
className: string;
|
|
22
|
+
isNewAllocation: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Inject styles from StyleResult objects
|
|
26
|
+
*/
|
|
27
|
+
inject(rules: StyleResult[], options?: {
|
|
28
|
+
root?: Document | ShadowRoot;
|
|
29
|
+
cacheKey?: string;
|
|
30
|
+
}): InjectResult;
|
|
31
|
+
/**
|
|
32
|
+
* Inject global styles (rules without a generated tasty class selector)
|
|
33
|
+
* This ensures we don't reserve a tasty class name (t{number}) for global rules,
|
|
34
|
+
* which could otherwise collide with element-level styles and break lookups.
|
|
35
|
+
*/
|
|
36
|
+
injectGlobal(rules: StyleResult[], options?: {
|
|
37
|
+
root?: Document | ShadowRoot;
|
|
38
|
+
}): GlobalInjectResult;
|
|
39
|
+
/**
|
|
40
|
+
* Inject raw CSS text directly without parsing
|
|
41
|
+
* This is a low-overhead alternative to createGlobalStyle for raw CSS
|
|
42
|
+
* The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking
|
|
43
|
+
*/
|
|
44
|
+
injectRawCSS(css: string, options?: {
|
|
45
|
+
root?: Document | ShadowRoot;
|
|
46
|
+
}): RawCSSResult;
|
|
47
|
+
/**
|
|
48
|
+
* Get raw CSS text for SSR
|
|
49
|
+
*/
|
|
50
|
+
getRawCSSText(options?: {
|
|
51
|
+
root?: Document | ShadowRoot;
|
|
52
|
+
}): string;
|
|
53
|
+
/**
|
|
54
|
+
* Dispose of a className
|
|
55
|
+
*/
|
|
56
|
+
private dispose;
|
|
57
|
+
/**
|
|
58
|
+
* Force bulk cleanup of unused styles
|
|
59
|
+
*/
|
|
60
|
+
cleanup(root?: Document | ShadowRoot): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get CSS text from all sheets (for SSR)
|
|
63
|
+
*/
|
|
64
|
+
getCssText(options?: {
|
|
65
|
+
root?: Document | ShadowRoot;
|
|
66
|
+
}): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get CSS only for the provided tasty classNames (e.g., ["t0","t3"])
|
|
69
|
+
*/
|
|
70
|
+
getCssTextForClasses(classNames: Iterable<string>, options?: {
|
|
71
|
+
root?: Document | ShadowRoot;
|
|
72
|
+
}): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get cache performance metrics
|
|
75
|
+
*/
|
|
76
|
+
getMetrics(options?: {
|
|
77
|
+
root?: Document | ShadowRoot;
|
|
78
|
+
}): CacheMetrics | null;
|
|
79
|
+
/**
|
|
80
|
+
* Reset cache performance metrics
|
|
81
|
+
*/
|
|
82
|
+
resetMetrics(options?: {
|
|
83
|
+
root?: Document | ShadowRoot;
|
|
84
|
+
}): void;
|
|
85
|
+
/**
|
|
86
|
+
* Define a CSS @property custom property.
|
|
87
|
+
*
|
|
88
|
+
* Accepts tasty token syntax for the property name:
|
|
89
|
+
* - `$name` → defines `--name`
|
|
90
|
+
* - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
|
|
91
|
+
* - `--name` → defines `--name` (legacy format)
|
|
92
|
+
*
|
|
93
|
+
* Example:
|
|
94
|
+
* @property --rotation { syntax: "<angle>"; inherits: false; initial-value: 45deg; }
|
|
95
|
+
*
|
|
96
|
+
* Note: No caching or dispose — this defines a global property.
|
|
97
|
+
*
|
|
98
|
+
* If the same property is registered with different options, a warning is emitted
|
|
99
|
+
* but the original definition is preserved (CSS @property cannot be redefined).
|
|
100
|
+
*/
|
|
101
|
+
property(name: string, options?: PropertyDefinition & {
|
|
102
|
+
root?: Document | ShadowRoot;
|
|
103
|
+
}): void;
|
|
104
|
+
/**
|
|
105
|
+
* Check whether a given @property name was already injected by this injector.
|
|
106
|
+
*
|
|
107
|
+
* Accepts tasty token syntax:
|
|
108
|
+
* - `$name` → checks `--name`
|
|
109
|
+
* - `#name` → checks `--name-color`
|
|
110
|
+
* - `--name` → checks `--name` (legacy format)
|
|
111
|
+
*/
|
|
112
|
+
isPropertyDefined(name: string, options?: {
|
|
113
|
+
root?: Document | ShadowRoot;
|
|
114
|
+
}): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Inject keyframes and return object with toString() and dispose()
|
|
117
|
+
*
|
|
118
|
+
* Keyframes are cached by content (steps). If the same content is injected
|
|
119
|
+
* multiple times with different provided names, the first injected name is reused.
|
|
120
|
+
*
|
|
121
|
+
* If the same name is provided with different content (collision), a unique
|
|
122
|
+
* name is generated to avoid overwriting the existing keyframes.
|
|
123
|
+
*/
|
|
124
|
+
keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
|
|
125
|
+
root?: Document | ShadowRoot;
|
|
126
|
+
name?: string;
|
|
127
|
+
}): KeyframesResult;
|
|
128
|
+
/**
|
|
129
|
+
* Dispose keyframes
|
|
130
|
+
*/
|
|
131
|
+
private disposeKeyframes;
|
|
132
|
+
/**
|
|
133
|
+
* Destroy all resources for a root
|
|
134
|
+
*/
|
|
135
|
+
destroy(root?: Document | ShadowRoot): void;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
export { StyleInjector };
|
|
139
|
+
//# sourceMappingURL=injector.d.ts.map
|