@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,61 @@
|
|
|
1
|
+
import { extractLocalPredefinedStates } from "../states/index.mjs";
|
|
2
|
+
import { renderStyles } from "../pipeline/index.mjs";
|
|
3
|
+
import { CHUNK_NAMES } from "./definitions.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/chunks/renderChunk.ts
|
|
6
|
+
/**
|
|
7
|
+
* Render styles for a specific chunk.
|
|
8
|
+
*
|
|
9
|
+
* Creates a filtered styles object containing only the keys for this chunk,
|
|
10
|
+
* then delegates to the existing renderStyles function.
|
|
11
|
+
*
|
|
12
|
+
* IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')
|
|
13
|
+
* are always included in the filtered styles, regardless of which chunk is
|
|
14
|
+
* being rendered. This ensures that state references like '@mobile' in any
|
|
15
|
+
* chunk can be properly resolved by the pipeline.
|
|
16
|
+
*
|
|
17
|
+
* @param styles - The full styles object
|
|
18
|
+
* @param chunkName - Name of the chunk being rendered
|
|
19
|
+
* @param styleKeys - Keys of styles belonging to this chunk
|
|
20
|
+
* @returns RenderResult with rules for this chunk
|
|
21
|
+
*/
|
|
22
|
+
function renderStylesForChunk(styles, chunkName, styleKeys) {
|
|
23
|
+
if (styleKeys.length === 0) return {
|
|
24
|
+
rules: [],
|
|
25
|
+
className: ""
|
|
26
|
+
};
|
|
27
|
+
if (chunkName === CHUNK_NAMES.SUBCOMPONENTS) return renderSubcomponentsChunk(styles, styleKeys);
|
|
28
|
+
const localPredefinedStates = extractLocalPredefinedStates(styles);
|
|
29
|
+
const filteredStyles = {};
|
|
30
|
+
for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
|
|
31
|
+
for (const key of styleKeys) {
|
|
32
|
+
const value = styles[key];
|
|
33
|
+
if (value !== void 0) filteredStyles[key] = value;
|
|
34
|
+
}
|
|
35
|
+
return renderStyles(filteredStyles);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Render the subcomponents chunk.
|
|
39
|
+
*
|
|
40
|
+
* Subcomponents (selectors like Label, &::before, etc.) contain nested
|
|
41
|
+
* style objects that need to be preserved in their entirety.
|
|
42
|
+
*
|
|
43
|
+
* @param styles - The full styles object
|
|
44
|
+
* @param selectorKeys - Keys of selectors in this chunk
|
|
45
|
+
* @returns RenderResult with rules for all subcomponents
|
|
46
|
+
*/
|
|
47
|
+
function renderSubcomponentsChunk(styles, selectorKeys) {
|
|
48
|
+
const localPredefinedStates = extractLocalPredefinedStates(styles);
|
|
49
|
+
const filteredStyles = {};
|
|
50
|
+
for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
|
|
51
|
+
for (const key of selectorKeys) {
|
|
52
|
+
const value = styles[key];
|
|
53
|
+
if (value !== void 0) filteredStyles[key] = value;
|
|
54
|
+
}
|
|
55
|
+
if (styles.$ !== void 0) filteredStyles.$ = styles.$;
|
|
56
|
+
return renderStyles(filteredStyles);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { renderStylesForChunk };
|
|
61
|
+
//# sourceMappingURL=renderChunk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderChunk.mjs","names":[],"sources":["../../src/chunks/renderChunk.ts"],"sourcesContent":["/**\n * Chunk-specific style rendering.\n *\n * Renders styles for a specific chunk by filtering the styles object\n * to only include relevant keys before passing to renderStyles.\n */\n\nimport type { RenderResult} from '../pipeline';\nimport { renderStyles } from '../pipeline';\nimport { extractLocalPredefinedStates } from '../states';\nimport type { Styles } from '../styles/types';\n\nimport { CHUNK_NAMES } from './definitions';\n\n/**\n * Render styles for a specific chunk.\n *\n * Creates a filtered styles object containing only the keys for this chunk,\n * then delegates to the existing renderStyles function.\n *\n * IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')\n * are always included in the filtered styles, regardless of which chunk is\n * being rendered. This ensures that state references like '@mobile' in any\n * chunk can be properly resolved by the pipeline.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk being rendered\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns RenderResult with rules for this chunk\n */\nexport function renderStylesForChunk(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): RenderResult {\n // Empty chunk - return empty result\n if (styleKeys.length === 0) {\n return { rules: [], className: '' };\n }\n\n // For subcomponents, we need to preserve the nested structure\n if (chunkName === CHUNK_NAMES.SUBCOMPONENTS) {\n return renderSubcomponentsChunk(styles, styleKeys);\n }\n\n // Extract local predefined states from the full styles object\n // These must be included for state resolution to work across chunks\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n\n // For regular chunks, create a filtered styles object\n // This is memory-efficient: we only create a shallow copy with filtered keys\n const filteredStyles: Styles = {};\n\n // First, add local predefined states so they're available for resolution\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n // Then add the chunk's style keys\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n // Delegate to existing renderStyles\n return renderStyles(filteredStyles);\n}\n\n/**\n * Render the subcomponents chunk.\n *\n * Subcomponents (selectors like Label, &::before, etc.) contain nested\n * style objects that need to be preserved in their entirety.\n *\n * @param styles - The full styles object\n * @param selectorKeys - Keys of selectors in this chunk\n * @returns RenderResult with rules for all subcomponents\n */\nfunction renderSubcomponentsChunk(\n styles: Styles,\n selectorKeys: string[],\n): RenderResult {\n // Extract local predefined states from the full styles object\n // These must be included for state resolution to work in nested styles\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n\n // Create a styles object containing only the selector keys\n const filteredStyles: Styles = {};\n\n // First, add local predefined states so they're available for resolution\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n // Then add the selector keys\n for (const key of selectorKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n // Also copy the $ helper if present (used for selector combinators)\n if (styles.$ !== undefined) {\n filteredStyles.$ = styles.$;\n }\n\n // Delegate to existing renderStyles\n return renderStyles(filteredStyles);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,qBACd,QACA,WACA,WACc;AAEd,KAAI,UAAU,WAAW,EACvB,QAAO;EAAE,OAAO,EAAE;EAAE,WAAW;EAAI;AAIrC,KAAI,cAAc,YAAY,cAC5B,QAAO,yBAAyB,QAAQ,UAAU;CAKpD,MAAM,wBAAwB,6BAA6B,OAAO;CAIlE,MAAM,iBAAyB,EAAE;AAGjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAIxB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAK1B,QAAO,aAAa,eAAe;;;;;;;;;;;;AAarC,SAAS,yBACP,QACA,cACc;CAGd,MAAM,wBAAwB,6BAA6B,OAAO;CAGlE,MAAM,iBAAyB,EAAE;AAGjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAIxB,MAAK,MAAM,OAAO,cAAc;EAC9B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAK1B,KAAI,OAAO,MAAM,OACf,gBAAe,IAAI,OAAO;AAI5B,QAAO,aAAa,eAAe"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { KeyframesSteps, PropertyDefinition } from "./injector/types.js";
|
|
2
|
+
import { StyleDetails, UnitHandler } from "./parser/types.js";
|
|
3
|
+
import { StyleHandlerDefinition } from "./utils/styles.js";
|
|
4
|
+
import { RecipeStyles } from "./styles/types.js";
|
|
5
|
+
import { StyleInjector } from "./injector/injector.js";
|
|
6
|
+
import { TastyPlugin } from "./plugins/types.js";
|
|
7
|
+
|
|
8
|
+
//#region src/config.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for the Tasty style system
|
|
11
|
+
*/
|
|
12
|
+
interface TastyConfig {
|
|
13
|
+
/** CSP nonce for style elements */
|
|
14
|
+
nonce?: string;
|
|
15
|
+
/** Maximum rules per stylesheet (default: 8192) */
|
|
16
|
+
maxRulesPerSheet?: number;
|
|
17
|
+
/** Threshold for bulk cleanup of unused styles (default: 500) */
|
|
18
|
+
unusedStylesThreshold?: number;
|
|
19
|
+
/** Delay before bulk cleanup in ms, ignored if idleCleanup is true (default: 5000) */
|
|
20
|
+
bulkCleanupDelay?: number;
|
|
21
|
+
/** Use requestIdleCallback for cleanup when available (default: true) */
|
|
22
|
+
idleCleanup?: boolean;
|
|
23
|
+
/** Force text injection mode, auto-detected in test environments (default: auto) */
|
|
24
|
+
forceTextInjection?: boolean;
|
|
25
|
+
/** Enable development mode features: performance metrics and debug info (default: auto) */
|
|
26
|
+
devMode?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Ratio of unused styles to delete per bulk cleanup run (0..1).
|
|
29
|
+
* Defaults to 0.5 (oldest half) to reduce risk of removing styles
|
|
30
|
+
* that may be restored shortly after being marked unused.
|
|
31
|
+
*/
|
|
32
|
+
bulkCleanupBatchRatio?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Minimum age (in ms) a style must remain unused before eligible for deletion.
|
|
35
|
+
* Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
|
|
36
|
+
*/
|
|
37
|
+
unusedStylesMinAgeMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Global predefined states for advanced state mapping.
|
|
40
|
+
* These are state aliases that can be used in any component.
|
|
41
|
+
* Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
|
|
42
|
+
*/
|
|
43
|
+
states?: Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Parser LRU cache size (default: 1000).
|
|
46
|
+
* Larger values improve performance for apps with many unique style values.
|
|
47
|
+
*/
|
|
48
|
+
parserCacheSize?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Custom units for the style parser (merged with built-in units).
|
|
51
|
+
* Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
|
|
52
|
+
* @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
|
|
53
|
+
*/
|
|
54
|
+
units?: Record<string, string | UnitHandler>;
|
|
55
|
+
/**
|
|
56
|
+
* Custom functions for the style parser (merged with existing).
|
|
57
|
+
* Functions process parsed style groups and return CSS values.
|
|
58
|
+
* @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
|
|
59
|
+
*/
|
|
60
|
+
funcs?: Record<string, (groups: StyleDetails[]) => string>;
|
|
61
|
+
/**
|
|
62
|
+
* Plugins that extend tasty with custom functions, units, or states.
|
|
63
|
+
* Plugins are processed in order, with later plugins overriding earlier ones.
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { okhslPlugin } from '@tenphi/tasty';
|
|
67
|
+
*
|
|
68
|
+
* configure({
|
|
69
|
+
* plugins: [okhslPlugin()],
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
plugins?: TastyPlugin[];
|
|
74
|
+
/**
|
|
75
|
+
* Global keyframes definitions that can be referenced by animation names in styles.
|
|
76
|
+
* Keys are animation names, values are keyframes step definitions.
|
|
77
|
+
* Keyframes are only injected when actually used in styles.
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* configure({
|
|
81
|
+
* keyframes: {
|
|
82
|
+
* fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
|
|
83
|
+
* pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
|
|
84
|
+
* },
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
keyframes?: Record<string, KeyframesSteps>;
|
|
89
|
+
/**
|
|
90
|
+
* Global CSS @property definitions for custom properties.
|
|
91
|
+
* Keys use tasty token syntax ($name for properties, #name for colors).
|
|
92
|
+
* Properties are only injected when the component using them is rendered.
|
|
93
|
+
*
|
|
94
|
+
* For color tokens (#name), `syntax: '<color>'` is auto-set and
|
|
95
|
+
* `initialValue` defaults to `'transparent'` if not specified.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* configure({
|
|
100
|
+
* properties: {
|
|
101
|
+
* '$rotation': { syntax: '<angle>', initialValue: '0deg' },
|
|
102
|
+
* '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
|
|
103
|
+
* '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
|
|
104
|
+
* },
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Now use in styles - properties are registered when component renders:
|
|
108
|
+
* const Spinner = tasty({
|
|
109
|
+
* styles: {
|
|
110
|
+
* transform: 'rotate($rotation)',
|
|
111
|
+
* transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
|
|
112
|
+
* },
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
properties?: Record<string, PropertyDefinition>;
|
|
117
|
+
/**
|
|
118
|
+
* Custom style handlers that transform style properties into CSS declarations.
|
|
119
|
+
* Handlers replace built-in handlers for the same style name.
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { styleHandlers } from '@tenphi/tasty';
|
|
123
|
+
*
|
|
124
|
+
* configure({
|
|
125
|
+
* handlers: {
|
|
126
|
+
* // Override fill with custom behavior
|
|
127
|
+
* fill: ({ fill }) => {
|
|
128
|
+
* if (fill?.startsWith('gradient:')) {
|
|
129
|
+
* return { background: fill.slice(9) };
|
|
130
|
+
* }
|
|
131
|
+
* return styleHandlers.fill({ fill });
|
|
132
|
+
* },
|
|
133
|
+
* // Add new custom style
|
|
134
|
+
* elevation: ({ elevation }) => {
|
|
135
|
+
* const level = parseInt(elevation) || 1;
|
|
136
|
+
* return {
|
|
137
|
+
* 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
|
|
138
|
+
* 'z-index': String(level * 100),
|
|
139
|
+
* };
|
|
140
|
+
* },
|
|
141
|
+
* },
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
handlers?: Record<string, StyleHandlerDefinition>;
|
|
146
|
+
/**
|
|
147
|
+
* Predefined tokens that are replaced during style parsing.
|
|
148
|
+
* Token values are processed through the parser (like component tokens).
|
|
149
|
+
* Use `$name` for custom properties and `#name` for color tokens.
|
|
150
|
+
*
|
|
151
|
+
* For color tokens (#name), boolean `true` is converted to `transparent`.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* configure({
|
|
156
|
+
* tokens: {
|
|
157
|
+
* $spacing: '2x',
|
|
158
|
+
* '$card-padding': '4x',
|
|
159
|
+
* '#accent': '#purple',
|
|
160
|
+
* '#surface': '#white',
|
|
161
|
+
* '#overlay': true, // → transparent
|
|
162
|
+
* },
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* // Now use in styles - tokens are replaced at parse time:
|
|
166
|
+
* const Card = tasty({
|
|
167
|
+
* styles: {
|
|
168
|
+
* padding: '$card-padding', // → calc(4 * var(--gap))
|
|
169
|
+
* fill: '#surface', // → var(--white-color)
|
|
170
|
+
* },
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
tokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
|
|
175
|
+
/**
|
|
176
|
+
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
177
|
+
* Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
|
|
178
|
+
* tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
|
|
179
|
+
*
|
|
180
|
+
* Components reference recipes via: `recipe: 'name1 name2'` in their styles.
|
|
181
|
+
* Use `|` to separate base recipes from post recipes: `recipe: 'base1 base2 | post1'`.
|
|
182
|
+
* Resolution order: `base_recipes → component styles → post_recipes`.
|
|
183
|
+
*
|
|
184
|
+
* Recipes cannot reference other recipes.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* configure({
|
|
189
|
+
* recipes: {
|
|
190
|
+
* card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
191
|
+
* elevated: { shadow: '2x 2x 4x #shadow' },
|
|
192
|
+
* },
|
|
193
|
+
* });
|
|
194
|
+
*
|
|
195
|
+
* // Usage in styles:
|
|
196
|
+
* const Card = tasty({
|
|
197
|
+
* styles: {
|
|
198
|
+
* recipe: 'card elevated',
|
|
199
|
+
* color: '#text', // Overrides recipe values
|
|
200
|
+
* },
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
recipes?: Record<string, RecipeStyles>;
|
|
205
|
+
}
|
|
206
|
+
declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
|
|
207
|
+
declare global {
|
|
208
|
+
interface Window {
|
|
209
|
+
[GLOBAL_INJECTOR_KEY]?: StyleInjector;
|
|
210
|
+
}
|
|
211
|
+
var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Detect if we're running in a test environment
|
|
215
|
+
*/
|
|
216
|
+
declare function isTestEnvironment(): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Check if styles have been generated (configuration is locked)
|
|
219
|
+
*/
|
|
220
|
+
declare function hasStylesGenerated(): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Check if any global keyframes are configured.
|
|
223
|
+
* Fast path: returns false if no keyframes were ever set.
|
|
224
|
+
*/
|
|
225
|
+
declare function hasGlobalKeyframes(): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Get global keyframes configuration.
|
|
228
|
+
* Returns null if no keyframes configured (fast path for zero-overhead).
|
|
229
|
+
*/
|
|
230
|
+
declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
|
|
231
|
+
/**
|
|
232
|
+
* Check if any global recipes are configured.
|
|
233
|
+
* Fast path: returns false if no recipes were ever set.
|
|
234
|
+
*/
|
|
235
|
+
declare function hasGlobalRecipes(): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Get global recipes configuration.
|
|
238
|
+
* Returns null if no recipes configured (fast path for zero-overhead).
|
|
239
|
+
*/
|
|
240
|
+
declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
|
|
241
|
+
/**
|
|
242
|
+
* Check if configuration is locked (styles have been generated)
|
|
243
|
+
*/
|
|
244
|
+
declare function isConfigLocked(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Configure the Tasty style system.
|
|
247
|
+
*
|
|
248
|
+
* Must be called BEFORE any styles are generated (before first render that uses tasty).
|
|
249
|
+
* After styles are generated, configuration is locked and calls to configure() will
|
|
250
|
+
* emit a warning and be ignored.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import { configure } from '@tenphi/tasty';
|
|
255
|
+
*
|
|
256
|
+
* // Configure before app renders
|
|
257
|
+
* configure({
|
|
258
|
+
* nonce: 'abc123',
|
|
259
|
+
* states: {
|
|
260
|
+
* '@mobile': '@media(w < 768px)',
|
|
261
|
+
* '@dark': '@root(theme=dark)',
|
|
262
|
+
* },
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
declare function configure(config?: Partial<TastyConfig>): void;
|
|
267
|
+
/**
|
|
268
|
+
* Get the current configuration.
|
|
269
|
+
* If not configured, returns default configuration.
|
|
270
|
+
*/
|
|
271
|
+
declare function getConfig(): TastyConfig;
|
|
272
|
+
/**
|
|
273
|
+
* Reset configuration (for testing only).
|
|
274
|
+
* Clears the global injector and allows reconfiguration.
|
|
275
|
+
*/
|
|
276
|
+
declare function resetConfig(): void;
|
|
277
|
+
//#endregion
|
|
278
|
+
export { TastyConfig, configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig };
|
|
279
|
+
//# sourceMappingURL=config.d.ts.map
|