@tenphi/tasty 0.0.0-snapshot.64dc4f4 → 0.0.0-snapshot.6da0da7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -5
- package/dist/chunks/cacheKey.js +16 -8
- package/dist/chunks/cacheKey.js.map +1 -1
- package/dist/chunks/renderChunk.js +31 -32
- package/dist/chunks/renderChunk.js.map +1 -1
- package/dist/config.d.ts +33 -10
- package/dist/config.js +57 -13
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +5 -6
- package/dist/core/index.js +3 -3
- package/dist/hooks/useStyles.js +4 -3
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +3 -3
- package/dist/injector/injector.js +1 -7
- package/dist/injector/injector.js.map +1 -1
- package/dist/parser/classify.js.map +1 -1
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +24 -14
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +328 -79
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.d.ts +1 -1
- package/dist/pipeline/parseStateKey.js +2 -6
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/plugins/types.d.ts +9 -2
- package/dist/properties/property-type-resolver.js +4 -0
- package/dist/properties/property-type-resolver.js.map +1 -1
- package/dist/ssr/collector.js +11 -1
- package/dist/ssr/collector.js.map +1 -1
- package/dist/states/index.js +10 -257
- package/dist/states/index.js.map +1 -1
- package/dist/styles/types.d.ts +14 -1
- package/dist/tasty.js +23 -10
- package/dist/tasty.js.map +1 -1
- package/dist/utils/cache-wrapper.js +4 -8
- package/dist/utils/cache-wrapper.js.map +1 -1
- package/dist/utils/has-keys.js +13 -0
- package/dist/utils/has-keys.js.map +1 -0
- package/dist/utils/mod-attrs.js +1 -1
- package/dist/utils/styles.d.ts +1 -64
- package/dist/utils/styles.js +7 -319
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.d.ts +24 -13
- package/dist/utils/typography.js +6 -16
- package/dist/utils/typography.js.map +1 -1
- package/dist/zero/babel.d.ts +32 -4
- package/dist/zero/babel.js +34 -7
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/next.d.ts +16 -1
- package/dist/zero/next.js +66 -12
- package/dist/zero/next.js.map +1 -1
- package/docs/adoption.md +286 -0
- package/docs/comparison.md +413 -0
- package/docs/configuration.md +41 -10
- package/docs/debug.md +1 -1
- package/docs/design-system.md +401 -0
- package/docs/{usage.md → dsl.md} +254 -409
- package/docs/getting-started.md +201 -0
- package/docs/injector.md +2 -2
- package/docs/methodology.md +501 -0
- package/docs/runtime.md +291 -0
- package/docs/ssr.md +11 -1
- package/docs/styles.md +2 -2
- package/docs/tasty-static.md +64 -20
- package/package.json +8 -5
- package/dist/tokens/typography.d.ts +0 -19
- package/dist/tokens/typography.js +0 -237
- package/dist/tokens/typography.js.map +0 -1
package/README.md
CHANGED
|
@@ -192,6 +192,15 @@ Traditional CSS has two structural problems.
|
|
|
192
192
|
|
|
193
193
|
First, the **cascade** resolves conflicts by specificity and source order: when multiple selectors match, the one with the highest specificity wins, or — if specificity is equal — the last one in source order wins. That makes styles inherently fragile. Reordering imports, adding a media query, or composing components from different libraries can silently break styling.
|
|
194
194
|
|
|
195
|
+
A small example makes this tangible. Two rules for a button's background:
|
|
196
|
+
|
|
197
|
+
```css
|
|
198
|
+
.btn:hover { background: dodgerblue; }
|
|
199
|
+
.btn[disabled] { background: gray; }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Both selectors have specificity `(0, 1, 1)`. When the button is hovered **and** disabled, both match — and the last rule in source order wins. Swap the two lines and a hovered disabled button silently turns blue instead of gray. This class of bug is invisible in code review because the logic is correct; only the ordering is wrong.
|
|
203
|
+
|
|
195
204
|
Second, **authoring selectors that capture real-world state logic is fundamentally hard.** A single state like "dark mode" may depend on a root attribute, an OS preference, or both — each branch needing its own selector, proper negation of competing branches, and correct `@media` nesting. The example below shows the CSS you'd write by hand for just *one* property with *one* state. Scale that across dozens of properties, then add breakpoints and container queries, and the selector logic quickly becomes unmanageable.
|
|
196
205
|
|
|
197
206
|
Tasty solves both problems at once: **every state mapping compiles into mutually exclusive selectors.**
|
|
@@ -211,7 +220,33 @@ const Text = tasty({
|
|
|
211
220
|
});
|
|
212
221
|
```
|
|
213
222
|
|
|
214
|
-
If `@dark` expands to `@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))`,
|
|
223
|
+
If `@dark` expands to `@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))`, try writing the CSS by hand. A first attempt might look like this:
|
|
224
|
+
|
|
225
|
+
```css
|
|
226
|
+
/* First attempt — the @media branch is too broad */
|
|
227
|
+
.t0 { color: var(--text-color); }
|
|
228
|
+
:root[data-schema="dark"] .t0 { color: var(--text-on-dark-color); }
|
|
229
|
+
@media (prefers-color-scheme: dark) {
|
|
230
|
+
.t0 { color: var(--text-on-dark-color); }
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The `@media` branch fires even when `data-schema="light"` is explicitly set. Fix that:
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
/* Second attempt — @media is scoped, but the default is still too broad */
|
|
238
|
+
.t0 { color: var(--text-color); }
|
|
239
|
+
:root[data-schema="dark"] .t0 { color: var(--text-on-dark-color); }
|
|
240
|
+
@media (prefers-color-scheme: dark) {
|
|
241
|
+
:root:not([data-schema]) .t0 { color: var(--text-on-dark-color); }
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Better — but the bare `.t0` default still matches unconditionally. It matches in dark mode, it matches when `data-schema="dark"` is set, and it can beat the attribute selector by source order if another rule re-declares it later. There is no selector that says "apply this default only when none of the dark branches win."
|
|
246
|
+
|
|
247
|
+
This is just *one* property with *one* state, and getting it right already takes multiple iterations. The correct selectors require negating every other branch — which is exactly what Tasty generates automatically:
|
|
248
|
+
|
|
249
|
+
Tasty generates the correct version automatically:
|
|
215
250
|
|
|
216
251
|
```css
|
|
217
252
|
/* Branch 1: Explicit dark schema */
|
|
@@ -243,6 +278,8 @@ Every rule is guarded by the negation of higher-priority rules. No two rules can
|
|
|
243
278
|
|
|
244
279
|
By absorbing selector complexity, Tasty makes advanced CSS patterns practical again — nested container queries, multi-condition `@supports` gates, and combined root-state/media branches. You stay in pure CSS instead of relying on JavaScript workarounds, so the browser can optimize layout, painting, and transitions natively. Tasty doesn't limit CSS; it unlocks its full potential by removing the complexity that held teams back.
|
|
245
280
|
|
|
281
|
+
[Try it in the Tasty Playground →](https://cube-ui-kit.vercel.app/?path=/story/getting-started-tasty-playground--playground)
|
|
282
|
+
|
|
246
283
|
## Capabilities
|
|
247
284
|
|
|
248
285
|
### Design Tokens and Custom Units
|
|
@@ -408,8 +445,8 @@ import { useStyles, useGlobalStyles, useRawCSS } from '@tenphi/tasty';
|
|
|
408
445
|
|
|
409
446
|
function App() {
|
|
410
447
|
const { className } = useStyles({ padding: '2x', fill: '#surface' });
|
|
411
|
-
useGlobalStyles('
|
|
412
|
-
useRawCSS('
|
|
448
|
+
useGlobalStyles('body', { margin: '0' });
|
|
449
|
+
useRawCSS('@font-face { font-family: "Custom"; src: url(...); }');
|
|
413
450
|
|
|
414
451
|
return <main className={className}>...</main>;
|
|
415
452
|
}
|
|
@@ -573,20 +610,57 @@ Syntax highlighting for Tasty styles in TypeScript, TSX, JavaScript, and JSX. Hi
|
|
|
573
610
|
<img src="assets/tasty-vscode-highlight.png" width="512" alt="Tasty VS Code syntax highlighting example">
|
|
574
611
|
</p>
|
|
575
612
|
|
|
576
|
-
|
|
613
|
+
## Built with Tasty
|
|
614
|
+
|
|
615
|
+
### [tasty.style](https://tasty.style) ([source](https://github.com/tenphi/tasty.style))
|
|
616
|
+
|
|
617
|
+
The official Tasty documentation and landing page — itself built entirely with Tasty. A showcase for zero-runtime styling via `tastyStatic`, SSR with Next.js, and OKHSL color theming with Glaze.
|
|
618
|
+
|
|
619
|
+
### [Cube Cloud](https://cube.dev/)
|
|
620
|
+
|
|
621
|
+
Enterprise universal semantic layer platform by Cube Dev, Inc. Cube Cloud unifies data modeling, caching, access control, and APIs (REST, GraphQL, SQL, AI) for analytics at scale. Tasty has powered its frontend for over 5 years in production.
|
|
622
|
+
|
|
623
|
+
### [Cube Cloud for Excel and Google Sheets](https://cube.dev/)
|
|
624
|
+
|
|
625
|
+
A single spreadsheet add-in deployed to both [Microsoft Excel](https://marketplace.microsoft.com/en-us/product/office/WA200008486) and [Google Sheets](https://workspace.google.com/u/0/marketplace/app/cube_cloud_for_sheets/641460343379). Connects spreadsheets to any cloud data platform (BigQuery, Databricks, Snowflake, Redshift, and more) via Cube Cloud's universal semantic layer.
|
|
626
|
+
|
|
627
|
+
### [Cube UI Kit](https://github.com/cube-js/cube-ui-kit) ([storybook](https://cube-ui-kit.vercel.app/))
|
|
577
628
|
|
|
578
629
|
Open-source React UI kit built on Tasty + React Aria. 100+ production components proving Tasty works at design-system scale. A reference implementation and a ready-to-use component library.
|
|
579
630
|
|
|
580
631
|
## Documentation
|
|
581
632
|
|
|
582
|
-
|
|
633
|
+
### Start here
|
|
634
|
+
|
|
635
|
+
- **[Getting Started](docs/getting-started.md)** — Installation, first component, configuration, ESLint plugin setup, editor tooling, and rendering mode decision tree
|
|
636
|
+
- **[Methodology](docs/methodology.md)** — The recommended patterns for structuring Tasty components: root + sub-elements, styleProps, tokens, styles vs style, wrapping and extension
|
|
637
|
+
|
|
638
|
+
### Guides
|
|
639
|
+
|
|
640
|
+
- **[Building a Design System](docs/design-system.md)** — Practical guide to building a DS layer: token vocabulary, state aliases, recipes, primitives, compound components, override contracts
|
|
641
|
+
- **[Adoption Guide](docs/adoption.md)** — Where Tasty sits in the stack, who should adopt it, what you define yourself, and how to introduce it incrementally into an existing design system
|
|
642
|
+
|
|
643
|
+
### Reference
|
|
644
|
+
|
|
645
|
+
- **[Style DSL](docs/dsl.md)** — The Tasty style language: state maps, tokens, units, color syntax, extending semantics, recipes, keyframes, and @property
|
|
646
|
+
- **[Runtime API](docs/runtime.md)** — React-specific API: `tasty()` factory, component props, variants, sub-elements, and hooks
|
|
583
647
|
- **[Configuration](docs/configuration.md)** — Global configuration: tokens, recipes, custom units, style handlers, and TypeScript extensions
|
|
584
648
|
- **[Style Properties](docs/styles.md)** — Complete reference for all enhanced style properties: syntax, values, modifiers, and recommendations
|
|
649
|
+
|
|
650
|
+
### Rendering modes
|
|
651
|
+
|
|
585
652
|
- **[Zero Runtime (tastyStatic)](docs/tasty-static.md)** — Build-time static styling: Babel plugin setup, Next.js integration, and static style patterns
|
|
586
653
|
- **[Server-Side Rendering](docs/ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks: streaming support, cache hydration, and troubleshooting
|
|
654
|
+
|
|
655
|
+
### Internals
|
|
656
|
+
|
|
587
657
|
- **[Style Injector](docs/injector.md)** — Internal CSS injection engine: `inject()`, `injectGlobal()`, `injectRawCSS()`, `keyframes()`, deduplication, reference counting, cleanup, SSR support, and Shadow DOM
|
|
588
658
|
- **[Debug Utilities](docs/debug.md)** — Runtime CSS inspection via `tastyDebug`: CSS extraction, element inspection, cache metrics, chunk breakdown, and performance monitoring
|
|
589
659
|
|
|
660
|
+
### Context
|
|
661
|
+
|
|
662
|
+
- **[Comparison](docs/comparison.md)** — How Tasty compares to Tailwind, Panda CSS, vanilla-extract, StyleX, Stitches, and Emotion: positioning, trade-offs, and when each tool fits best
|
|
663
|
+
|
|
590
664
|
## License
|
|
591
665
|
|
|
592
666
|
[MIT](LICENSE)
|
package/dist/chunks/cacheKey.js
CHANGED
|
@@ -11,20 +11,29 @@ import { extractLocalPredefinedStates, extractPredefinedStateRefs } from "../sta
|
|
|
11
11
|
* - Global predefined states don't affect cache keys (constant across app)
|
|
12
12
|
* - Local predefined states only affect cache keys if referenced in the chunk
|
|
13
13
|
*/
|
|
14
|
+
const _stableStringifyCache = /* @__PURE__ */ new WeakMap();
|
|
14
15
|
/**
|
|
15
16
|
* Recursively serialize a value with sorted keys for stable output.
|
|
16
17
|
* This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.
|
|
18
|
+
* Uses a WeakMap cache for object values to avoid re-serializing the same references.
|
|
17
19
|
*/
|
|
18
20
|
function stableStringify(value) {
|
|
19
21
|
if (value === null) return "null";
|
|
20
22
|
if (value === void 0) return "undefined";
|
|
21
23
|
if (typeof value !== "object") return JSON.stringify(value);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const cached = _stableStringifyCache.get(value);
|
|
25
|
+
if (cached !== void 0) return cached;
|
|
26
|
+
let result;
|
|
27
|
+
if (Array.isArray(value)) result = "[" + value.map(stableStringify).join(",") + "]";
|
|
28
|
+
else {
|
|
29
|
+
const obj = value;
|
|
30
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
31
|
+
const parts = [];
|
|
32
|
+
for (const key of sortedKeys) if (obj[key] !== void 0) parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);
|
|
33
|
+
result = "{" + parts.join(",") + "}";
|
|
34
|
+
}
|
|
35
|
+
_stableStringifyCache.set(value, result);
|
|
36
|
+
return result;
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Generate a cache key for a specific chunk.
|
|
@@ -42,9 +51,8 @@ function stableStringify(value) {
|
|
|
42
51
|
*/
|
|
43
52
|
function generateChunkCacheKey(styles, chunkName, styleKeys) {
|
|
44
53
|
const parts = [chunkName];
|
|
45
|
-
const sortedKeys = styleKeys.slice().sort();
|
|
46
54
|
let chunkStylesStr = "";
|
|
47
|
-
for (const key of
|
|
55
|
+
for (const key of styleKeys) {
|
|
48
56
|
const value = styles[key];
|
|
49
57
|
if (value !== void 0) {
|
|
50
58
|
const serialized = stableStringify(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheKey.js","names":[],"sources":["../../src/chunks/cacheKey.ts"],"sourcesContent":["/**\n * Chunk-specific cache key generation.\n *\n * Generates cache keys that only include styles relevant to a specific chunk,\n * enabling more granular caching and reuse.\n *\n * Enhanced to support predefined states:\n * - Global predefined states don't affect cache keys (constant across app)\n * - Local predefined states only affect cache keys if referenced in the chunk\n */\n\nimport {\n extractLocalPredefinedStates,\n extractPredefinedStateRefs,\n} from '../states';\nimport type { Styles } from '../styles/types';\n\n/**\n * Recursively serialize a value with sorted keys for stable output.\n * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n if (Array.isArray(value)) {\n
|
|
1
|
+
{"version":3,"file":"cacheKey.js","names":[],"sources":["../../src/chunks/cacheKey.ts"],"sourcesContent":["/**\n * Chunk-specific cache key generation.\n *\n * Generates cache keys that only include styles relevant to a specific chunk,\n * enabling more granular caching and reuse.\n *\n * Enhanced to support predefined states:\n * - Global predefined states don't affect cache keys (constant across app)\n * - Local predefined states only affect cache keys if referenced in the chunk\n */\n\nimport {\n extractLocalPredefinedStates,\n extractPredefinedStateRefs,\n} from '../states';\nimport type { Styles } from '../styles/types';\n\nconst _stableStringifyCache = new WeakMap<object, string>();\n\n/**\n * Recursively serialize a value with sorted keys for stable output.\n * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.\n * Uses a WeakMap cache for object values to avoid re-serializing the same references.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n\n const cached = _stableStringifyCache.get(value as object);\n if (cached !== undefined) return cached;\n\n let result: string;\n if (Array.isArray(value)) {\n result = '[' + value.map(stableStringify).join(',') + ']';\n } else {\n const obj = value as Record<string, unknown>;\n const sortedKeys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of sortedKeys) {\n if (obj[key] !== undefined) {\n parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);\n }\n }\n result = '{' + parts.join(',') + '}';\n }\n\n _stableStringifyCache.set(value as object, result);\n return result;\n}\n\n/**\n * Generate a cache key for a specific chunk.\n *\n * Only includes the styles that belong to this chunk, allowing\n * chunks to be cached independently.\n *\n * Also includes relevant local predefined states that are referenced\n * by this chunk's styles.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns A stable cache key string\n */\nexport function generateChunkCacheKey(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): string {\n // Start with chunk name for namespace separation\n const parts: string[] = [chunkName];\n\n // styleKeys are already sorted by categorizeStyleKeys\n let chunkStylesStr = '';\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n // Use stable stringify for consistent serialization regardless of key order\n const serialized = stableStringify(value);\n parts.push(`${key}:${serialized}`);\n chunkStylesStr += serialized;\n }\n }\n\n // Extract local predefined states from the full styles object\n const localStates = extractLocalPredefinedStates(styles);\n\n // Only include local predefined states that are actually referenced in this chunk\n if (Object.keys(localStates).length > 0) {\n const referencedStates = extractPredefinedStateRefs(chunkStylesStr);\n const relevantLocalStates: string[] = [];\n\n for (const stateName of referencedStates) {\n if (localStates[stateName]) {\n relevantLocalStates.push(`${stateName}=${localStates[stateName]}`);\n }\n }\n\n // Add relevant local states to the cache key (sorted for stability)\n if (relevantLocalStates.length > 0) {\n relevantLocalStates.sort();\n parts.unshift(`[states:${relevantLocalStates.join('|')}]`);\n }\n }\n\n // Use null character as separator (safe, not in JSON output)\n return parts.join('\\0');\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,wCAAwB,IAAI,SAAyB;;;;;;AAO3D,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,UAAU,KACZ,QAAO;AAET,KAAI,UAAU,OACZ,QAAO;AAET,KAAI,OAAO,UAAU,SACnB,QAAO,KAAK,UAAU,MAAM;CAG9B,MAAM,SAAS,sBAAsB,IAAI,MAAgB;AACzD,KAAI,WAAW,OAAW,QAAO;CAEjC,IAAI;AACJ,KAAI,MAAM,QAAQ,MAAM,CACtB,UAAS,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,IAAI,GAAG;MACjD;EACL,MAAM,MAAM;EACZ,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,MAAM;EAC1C,MAAM,QAAkB,EAAE;AAC1B,OAAK,MAAM,OAAO,WAChB,KAAI,IAAI,SAAS,OACf,OAAM,KAAK,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,gBAAgB,IAAI,KAAK,GAAG;AAGrE,WAAS,MAAM,MAAM,KAAK,IAAI,GAAG;;AAGnC,uBAAsB,IAAI,OAAiB,OAAO;AAClD,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,sBACd,QACA,WACA,WACQ;CAER,MAAM,QAAkB,CAAC,UAAU;CAGnC,IAAI,iBAAiB;AAErB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,QAAW;GAEvB,MAAM,aAAa,gBAAgB,MAAM;AACzC,SAAM,KAAK,GAAG,IAAI,GAAG,aAAa;AAClC,qBAAkB;;;CAKtB,MAAM,cAAc,6BAA6B,OAAO;AAGxD,KAAI,OAAO,KAAK,YAAY,CAAC,SAAS,GAAG;EACvC,MAAM,mBAAmB,2BAA2B,eAAe;EACnE,MAAM,sBAAgC,EAAE;AAExC,OAAK,MAAM,aAAa,iBACtB,KAAI,YAAY,WACd,qBAAoB,KAAK,GAAG,UAAU,GAAG,YAAY,aAAa;AAKtE,MAAI,oBAAoB,SAAS,GAAG;AAClC,uBAAoB,MAAM;AAC1B,SAAM,QAAQ,WAAW,oBAAoB,KAAK,IAAI,CAAC,GAAG;;;AAK9D,QAAO,MAAM,KAAK,KAAK"}
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
import { extractLocalPredefinedStates } from "../states/index.js";
|
|
2
|
-
import { renderStyles } from "../pipeline/index.js";
|
|
2
|
+
import { hasPipelineCacheEntry, renderStyles } from "../pipeline/index.js";
|
|
3
3
|
import { CHUNK_NAMES } from "./definitions.js";
|
|
4
4
|
|
|
5
5
|
//#region src/chunks/renderChunk.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
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
|
|
7
|
+
* Build a filtered styles object for a regular chunk.
|
|
21
8
|
*/
|
|
22
|
-
function
|
|
23
|
-
if (styleKeys.length === 0) return {
|
|
24
|
-
rules: [],
|
|
25
|
-
className: ""
|
|
26
|
-
};
|
|
27
|
-
if (chunkName === CHUNK_NAMES.SUBCOMPONENTS) return renderSubcomponentsChunk(styles, styleKeys);
|
|
9
|
+
function buildFilteredStyles(styles, styleKeys) {
|
|
28
10
|
const localPredefinedStates = extractLocalPredefinedStates(styles);
|
|
29
11
|
const filteredStyles = {};
|
|
30
12
|
for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
|
|
@@ -32,19 +14,12 @@ function renderStylesForChunk(styles, chunkName, styleKeys) {
|
|
|
32
14
|
const value = styles[key];
|
|
33
15
|
if (value !== void 0) filteredStyles[key] = value;
|
|
34
16
|
}
|
|
35
|
-
return
|
|
17
|
+
return filteredStyles;
|
|
36
18
|
}
|
|
37
19
|
/**
|
|
38
|
-
*
|
|
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
|
|
20
|
+
* Build a filtered styles object for the subcomponents chunk.
|
|
46
21
|
*/
|
|
47
|
-
function
|
|
22
|
+
function buildSubcomponentFilteredStyles(styles, selectorKeys) {
|
|
48
23
|
const localPredefinedStates = extractLocalPredefinedStates(styles);
|
|
49
24
|
const filteredStyles = {};
|
|
50
25
|
for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
|
|
@@ -53,7 +28,31 @@ function renderSubcomponentsChunk(styles, selectorKeys) {
|
|
|
53
28
|
if (value !== void 0) filteredStyles[key] = value;
|
|
54
29
|
}
|
|
55
30
|
if (styles.$ !== void 0) filteredStyles.$ = styles.$;
|
|
56
|
-
return
|
|
31
|
+
return filteredStyles;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Render styles for a specific chunk.
|
|
35
|
+
*
|
|
36
|
+
* On pipeline cache hit, avoids building the filtered styles object entirely.
|
|
37
|
+
* Only constructs it on cache miss when the pipeline actually needs the styles.
|
|
38
|
+
*
|
|
39
|
+
* IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')
|
|
40
|
+
* are always included in the filtered styles, regardless of which chunk is
|
|
41
|
+
* being rendered. This ensures that state references like '@mobile' in any
|
|
42
|
+
* chunk can be properly resolved by the pipeline.
|
|
43
|
+
*
|
|
44
|
+
* @param styles - The full styles object
|
|
45
|
+
* @param chunkName - Name of the chunk being rendered
|
|
46
|
+
* @param styleKeys - Keys of styles belonging to this chunk
|
|
47
|
+
* @returns RenderResult with rules for this chunk
|
|
48
|
+
*/
|
|
49
|
+
function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
|
|
50
|
+
if (styleKeys.length === 0) return {
|
|
51
|
+
rules: [],
|
|
52
|
+
className: ""
|
|
53
|
+
};
|
|
54
|
+
if (pipelineCacheKey && hasPipelineCacheEntry(pipelineCacheKey)) return renderStyles(void 0, void 0, void 0, pipelineCacheKey);
|
|
55
|
+
return renderStyles(chunkName === CHUNK_NAMES.SUBCOMPONENTS ? buildSubcomponentFilteredStyles(styles, styleKeys) : buildFilteredStyles(styles, styleKeys), void 0, void 0, pipelineCacheKey);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderChunk.js","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 *
|
|
1
|
+
{"version":3,"file":"renderChunk.js","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 { hasPipelineCacheEntry, renderStyles } from '../pipeline';\nimport { extractLocalPredefinedStates } from '../states';\nimport type { Styles } from '../styles/types';\n\nimport { CHUNK_NAMES } from './definitions';\n\n/**\n * Build a filtered styles object for a regular chunk.\n */\nfunction buildFilteredStyles(styles: Styles, styleKeys: string[]): Styles {\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n const filteredStyles: Styles = {};\n\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n return filteredStyles;\n}\n\n/**\n * Build a filtered styles object for the subcomponents chunk.\n */\nfunction buildSubcomponentFilteredStyles(\n styles: Styles,\n selectorKeys: string[],\n): Styles {\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n const filteredStyles: Styles = {};\n\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n for (const key of selectorKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n if (styles.$ !== undefined) {\n filteredStyles.$ = styles.$;\n }\n\n return filteredStyles;\n}\n\n/**\n * Render styles for a specific chunk.\n *\n * On pipeline cache hit, avoids building the filtered styles object entirely.\n * Only constructs it on cache miss when the pipeline actually needs the styles.\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 pipelineCacheKey?: string,\n): RenderResult {\n if (styleKeys.length === 0) {\n return { rules: [], className: '' };\n }\n\n // Fast path: skip building filteredStyles when pipeline has a cached result\n if (pipelineCacheKey && hasPipelineCacheEntry(pipelineCacheKey)) {\n return renderStyles(undefined, undefined, undefined, pipelineCacheKey);\n }\n\n // Cache miss: build filtered styles and run pipeline\n const filteredStyles =\n chunkName === CHUNK_NAMES.SUBCOMPONENTS\n ? buildSubcomponentFilteredStyles(styles, styleKeys)\n : buildFilteredStyles(styles, styleKeys);\n\n return renderStyles(filteredStyles, undefined, undefined, pipelineCacheKey);\n}\n"],"mappings":";;;;;;;;AAiBA,SAAS,oBAAoB,QAAgB,WAA6B;CACxE,MAAM,wBAAwB,6BAA6B,OAAO;CAClE,MAAM,iBAAyB,EAAE;AAEjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAGxB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAI1B,QAAO;;;;;AAMT,SAAS,gCACP,QACA,cACQ;CACR,MAAM,wBAAwB,6BAA6B,OAAO;CAClE,MAAM,iBAAyB,EAAE;AAEjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAGxB,MAAK,MAAM,OAAO,cAAc;EAC9B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAI1B,KAAI,OAAO,MAAM,OACf,gBAAe,IAAI,OAAO;AAG5B,QAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,qBACd,QACA,WACA,WACA,kBACc;AACd,KAAI,UAAU,WAAW,EACvB,QAAO;EAAE,OAAO,EAAE;EAAE,WAAW;EAAI;AAIrC,KAAI,oBAAoB,sBAAsB,iBAAiB,CAC7D,QAAO,aAAa,QAAW,QAAW,QAAW,iBAAiB;AASxE,QAAO,aAJL,cAAc,YAAY,gBACtB,gCAAgC,QAAQ,UAAU,GAClD,oBAAoB,QAAQ,UAAU,EAER,QAAW,QAAW,iBAAiB"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KeyframesSteps, PropertyDefinition } from "./injector/types.js";
|
|
2
2
|
import { StyleDetails, UnitHandler } from "./parser/types.js";
|
|
3
3
|
import { StyleHandlerDefinition } from "./utils/styles.js";
|
|
4
|
-
import { RecipeStyles } from "./styles/types.js";
|
|
4
|
+
import { ConfigTokens, RecipeStyles } from "./styles/types.js";
|
|
5
5
|
import { StyleInjector } from "./injector/injector.js";
|
|
6
6
|
import { TastyPlugin } from "./plugins/types.js";
|
|
7
7
|
|
|
@@ -152,20 +152,43 @@ interface TastyConfig {
|
|
|
152
152
|
*/
|
|
153
153
|
handlers?: Record<string, StyleHandlerDefinition>;
|
|
154
154
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
155
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
156
|
+
* Values are parsed through the Tasty DSL. Supports state maps
|
|
157
|
+
* for responsive/theme-aware tokens.
|
|
158
|
+
*
|
|
159
|
+
* - `$name` keys become `--name` CSS custom properties
|
|
160
|
+
* - `#name` keys become `--name-color` and `--name-color-rgb` properties
|
|
161
|
+
*
|
|
162
|
+
* Tokens are injected once when the first style is rendered.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* configure({
|
|
167
|
+
* tokens: {
|
|
168
|
+
* '$gap': '4px',
|
|
169
|
+
* '#primary': {
|
|
170
|
+
* '': '#purple',
|
|
171
|
+
* '@dark': '#light-purple',
|
|
172
|
+
* },
|
|
173
|
+
* },
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
tokens?: ConfigTokens;
|
|
178
|
+
/**
|
|
179
|
+
* Predefined tokens that are replaced during style parsing (parse-time substitution).
|
|
157
180
|
* Use `$name` for custom properties and `#name` for color tokens.
|
|
181
|
+
* Values are substituted inline before CSS generation, unlike `tokens` which
|
|
182
|
+
* inject CSS custom properties on `:root`.
|
|
158
183
|
*
|
|
159
184
|
* For color tokens (#name), boolean `true` is converted to `transparent`.
|
|
160
185
|
*
|
|
161
186
|
* @example
|
|
162
187
|
* ```ts
|
|
163
188
|
* configure({
|
|
164
|
-
*
|
|
189
|
+
* replaceTokens: {
|
|
165
190
|
* $spacing: '2x',
|
|
166
|
-
* '$card-padding': '4x',
|
|
167
191
|
* '#accent': '#purple',
|
|
168
|
-
* '#surface': '#white',
|
|
169
192
|
* '#overlay': true, // → transparent
|
|
170
193
|
* },
|
|
171
194
|
* });
|
|
@@ -173,13 +196,13 @@ interface TastyConfig {
|
|
|
173
196
|
* // Now use in styles - tokens are replaced at parse time:
|
|
174
197
|
* const Card = tasty({
|
|
175
198
|
* styles: {
|
|
176
|
-
* padding: '$
|
|
177
|
-
* fill: '#
|
|
199
|
+
* padding: '$spacing', // → calc(2 * var(--gap))
|
|
200
|
+
* fill: '#accent', // → var(--purple-color)
|
|
178
201
|
* },
|
|
179
202
|
* });
|
|
180
203
|
* ```
|
|
181
204
|
*/
|
|
182
|
-
|
|
205
|
+
replaceTokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
|
|
183
206
|
/**
|
|
184
207
|
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
185
208
|
* Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
|
|
@@ -229,7 +252,7 @@ declare function isTestEnvironment(): boolean;
|
|
|
229
252
|
declare function hasStylesGenerated(): boolean;
|
|
230
253
|
/**
|
|
231
254
|
* Check if any global keyframes are configured.
|
|
232
|
-
*
|
|
255
|
+
* Uses a pre-computed flag to avoid Object.keys() allocation on every call.
|
|
233
256
|
*/
|
|
234
257
|
declare function hasGlobalKeyframes(): boolean;
|
|
235
258
|
/**
|
package/dist/config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isDevEnv } from "./utils/is-dev-env.js";
|
|
2
|
-
import { setGlobalPredefinedStates } from "./states/index.js";
|
|
3
2
|
import { CUSTOM_UNITS, getGlobalFuncs, getGlobalParser, normalizeColorTokenValue, resetGlobalPredefinedTokens, setGlobalPredefinedTokens } from "./utils/styles.js";
|
|
4
3
|
import { normalizeHandlerDefinition, registerHandler, resetHandlers } from "./styles/predefined.js";
|
|
5
4
|
import { StyleInjector } from "./injector/injector.js";
|
|
6
|
-
import {
|
|
5
|
+
import { setGlobalPredefinedStates } from "./states/index.js";
|
|
6
|
+
import { clearPipelineCache, isSelector, renderStyles } from "./pipeline/index.js";
|
|
7
7
|
|
|
8
8
|
//#region src/config.ts
|
|
9
9
|
/**
|
|
@@ -34,6 +34,7 @@ let currentConfig = null;
|
|
|
34
34
|
let globalKeyframes = null;
|
|
35
35
|
let globalProperties = null;
|
|
36
36
|
let globalRecipes = null;
|
|
37
|
+
let globalConfigTokens = null;
|
|
37
38
|
/**
|
|
38
39
|
* Internal properties required by tasty core features.
|
|
39
40
|
* These are always injected when styles are first generated.
|
|
@@ -157,6 +158,10 @@ function markStylesGenerated() {
|
|
|
157
158
|
}]);
|
|
158
159
|
}
|
|
159
160
|
if (globalProperties && Object.keys(globalProperties).length > 0) for (const [token, definition] of Object.entries(globalProperties)) injector.property(token, definition);
|
|
161
|
+
if (globalConfigTokens && Object.keys(globalConfigTokens).length > 0) {
|
|
162
|
+
const tokenRules = renderStyles(globalConfigTokens, ":root");
|
|
163
|
+
if (tokenRules.length > 0) injector.injectGlobal(tokenRules);
|
|
164
|
+
}
|
|
160
165
|
}
|
|
161
166
|
/**
|
|
162
167
|
* Check if styles have been generated (configuration is locked)
|
|
@@ -164,12 +169,13 @@ function markStylesGenerated() {
|
|
|
164
169
|
function hasStylesGenerated() {
|
|
165
170
|
return stylesGenerated;
|
|
166
171
|
}
|
|
172
|
+
let _hasGlobalKeyframes = false;
|
|
167
173
|
/**
|
|
168
174
|
* Check if any global keyframes are configured.
|
|
169
|
-
*
|
|
175
|
+
* Uses a pre-computed flag to avoid Object.keys() allocation on every call.
|
|
170
176
|
*/
|
|
171
177
|
function hasGlobalKeyframes() {
|
|
172
|
-
return
|
|
178
|
+
return _hasGlobalKeyframes;
|
|
173
179
|
}
|
|
174
180
|
/**
|
|
175
181
|
* Get global keyframes configuration.
|
|
@@ -188,6 +194,7 @@ function setGlobalKeyframes(keyframes) {
|
|
|
188
194
|
return;
|
|
189
195
|
}
|
|
190
196
|
globalKeyframes = keyframes;
|
|
197
|
+
_hasGlobalKeyframes = Object.keys(keyframes).length > 0;
|
|
191
198
|
}
|
|
192
199
|
/**
|
|
193
200
|
* Check if any global properties are configured.
|
|
@@ -247,6 +254,27 @@ function setGlobalRecipes(recipes) {
|
|
|
247
254
|
globalRecipes = recipes;
|
|
248
255
|
}
|
|
249
256
|
/**
|
|
257
|
+
* Get global token styles for :root injection.
|
|
258
|
+
* Returns null if no tokens configured.
|
|
259
|
+
*/
|
|
260
|
+
function getGlobalConfigTokens() {
|
|
261
|
+
return globalConfigTokens;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Set global token styles (called from configure).
|
|
265
|
+
* Internal use only.
|
|
266
|
+
*/
|
|
267
|
+
function setGlobalConfigTokens(styles) {
|
|
268
|
+
if (stylesGenerated) {
|
|
269
|
+
warnOnce("tokens-after-styles", "[Tasty] Cannot update tokens after styles have been generated.\nThe new tokens will be ignored.");
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
globalConfigTokens = globalConfigTokens ? {
|
|
273
|
+
...globalConfigTokens,
|
|
274
|
+
...styles
|
|
275
|
+
} : styles;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
250
278
|
* Check if configuration is locked (styles have been generated)
|
|
251
279
|
*/
|
|
252
280
|
function isConfigLocked() {
|
|
@@ -282,7 +310,8 @@ function configure(config = {}) {
|
|
|
282
310
|
let mergedUnits = {};
|
|
283
311
|
let mergedFuncs = {};
|
|
284
312
|
let mergedHandlers = {};
|
|
285
|
-
let
|
|
313
|
+
let mergedReplaceTokens = {};
|
|
314
|
+
let mergedConfigTokens = {};
|
|
286
315
|
let mergedRecipes = {};
|
|
287
316
|
if (config.plugins) for (const plugin of config.plugins) {
|
|
288
317
|
if (plugin.states) mergedStates = {
|
|
@@ -301,8 +330,12 @@ function configure(config = {}) {
|
|
|
301
330
|
...mergedHandlers,
|
|
302
331
|
...plugin.handlers
|
|
303
332
|
};
|
|
304
|
-
if (plugin.
|
|
305
|
-
...
|
|
333
|
+
if (plugin.replaceTokens) mergedReplaceTokens = {
|
|
334
|
+
...mergedReplaceTokens,
|
|
335
|
+
...plugin.replaceTokens
|
|
336
|
+
};
|
|
337
|
+
if (plugin.tokens) mergedConfigTokens = {
|
|
338
|
+
...mergedConfigTokens,
|
|
306
339
|
...plugin.tokens
|
|
307
340
|
};
|
|
308
341
|
if (plugin.recipes) mergedRecipes = {
|
|
@@ -326,14 +359,22 @@ function configure(config = {}) {
|
|
|
326
359
|
...mergedHandlers,
|
|
327
360
|
...config.handlers
|
|
328
361
|
};
|
|
329
|
-
if (config.
|
|
330
|
-
...
|
|
362
|
+
if (config.replaceTokens) mergedReplaceTokens = {
|
|
363
|
+
...mergedReplaceTokens,
|
|
364
|
+
...config.replaceTokens
|
|
365
|
+
};
|
|
366
|
+
if (config.tokens) mergedConfigTokens = {
|
|
367
|
+
...mergedConfigTokens,
|
|
331
368
|
...config.tokens
|
|
332
369
|
};
|
|
333
370
|
if (config.recipes) mergedRecipes = {
|
|
334
371
|
...mergedRecipes,
|
|
335
372
|
...config.recipes
|
|
336
373
|
};
|
|
374
|
+
if (devMode) {
|
|
375
|
+
const tokenKeys = new Set(Object.keys(mergedConfigTokens));
|
|
376
|
+
for (const key of Object.keys(mergedReplaceTokens)) if (tokenKeys.has(key)) warnOnce(`token-conflict-${key}`, `[Tasty] Token "${key}" is defined in both \`tokens\` and \`replaceTokens\`. \`replaceTokens\` performs parse-time substitution, so the \`tokens\` CSS custom property will be injected but never used by Tasty styles. Remove it from one of the two.`);
|
|
377
|
+
}
|
|
337
378
|
if (Object.keys(mergedStates).length > 0) setGlobalPredefinedStates(mergedStates);
|
|
338
379
|
const parser = getGlobalParser();
|
|
339
380
|
if (config.parserCacheSize !== void 0) parser.updateOptions({ cacheSize: config.parserCacheSize });
|
|
@@ -356,9 +397,9 @@ function configure(config = {}) {
|
|
|
356
397
|
if (config.keyframes) setGlobalKeyframes(config.keyframes);
|
|
357
398
|
if (config.properties) setGlobalProperties(config.properties);
|
|
358
399
|
if (Object.keys(mergedHandlers).length > 0) for (const [name, definition] of Object.entries(mergedHandlers)) registerHandler(normalizeHandlerDefinition(name, definition));
|
|
359
|
-
if (Object.keys(
|
|
400
|
+
if (Object.keys(mergedReplaceTokens).length > 0) {
|
|
360
401
|
const processedTokens = {};
|
|
361
|
-
for (const [key, value] of Object.entries(
|
|
402
|
+
for (const [key, value] of Object.entries(mergedReplaceTokens)) if (key.startsWith("#")) {
|
|
362
403
|
const normalized = normalizeColorTokenValue(value);
|
|
363
404
|
if (normalized === null) continue;
|
|
364
405
|
processedTokens[key] = String(normalized);
|
|
@@ -366,8 +407,9 @@ function configure(config = {}) {
|
|
|
366
407
|
else processedTokens[key] = String(value);
|
|
367
408
|
setGlobalPredefinedTokens(processedTokens);
|
|
368
409
|
}
|
|
410
|
+
if (Object.keys(mergedConfigTokens).length > 0) setGlobalConfigTokens(mergedConfigTokens);
|
|
369
411
|
if (Object.keys(mergedRecipes).length > 0) setGlobalRecipes(mergedRecipes);
|
|
370
|
-
const { states: _states, parserCacheSize: _parserCacheSize, units: _units, funcs: _funcs, plugins: _plugins, keyframes: _keyframes, properties: _properties, handlers: _handlers, tokens: _tokens, recipes: _recipes, ...injectorConfig } = config;
|
|
412
|
+
const { states: _states, parserCacheSize: _parserCacheSize, units: _units, funcs: _funcs, plugins: _plugins, keyframes: _keyframes, properties: _properties, handlers: _handlers, tokens: _tokens, replaceTokens: _replaceTokens, recipes: _recipes, ...injectorConfig } = config;
|
|
371
413
|
const fullConfig = {
|
|
372
414
|
...createDefaultConfig(),
|
|
373
415
|
...currentConfig,
|
|
@@ -402,8 +444,10 @@ function resetConfig() {
|
|
|
402
444
|
stylesGenerated = false;
|
|
403
445
|
currentConfig = null;
|
|
404
446
|
globalKeyframes = null;
|
|
447
|
+
_hasGlobalKeyframes = false;
|
|
405
448
|
globalProperties = null;
|
|
406
449
|
globalRecipes = null;
|
|
450
|
+
globalConfigTokens = null;
|
|
407
451
|
resetGlobalPredefinedTokens();
|
|
408
452
|
resetHandlers();
|
|
409
453
|
clearPipelineCache();
|
|
@@ -413,5 +457,5 @@ function resetConfig() {
|
|
|
413
457
|
}
|
|
414
458
|
|
|
415
459
|
//#endregion
|
|
416
|
-
export { INTERNAL_PROPERTIES, INTERNAL_TOKENS, configure, getConfig, getGlobalInjector, getGlobalKeyframes, getGlobalProperties, getGlobalRecipes, hasGlobalKeyframes, hasGlobalProperties, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, markStylesGenerated, resetConfig };
|
|
460
|
+
export { INTERNAL_PROPERTIES, INTERNAL_TOKENS, configure, getConfig, getGlobalConfigTokens, getGlobalInjector, getGlobalKeyframes, getGlobalProperties, getGlobalRecipes, hasGlobalKeyframes, hasGlobalProperties, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, markStylesGenerated, resetConfig };
|
|
417
461
|
//# sourceMappingURL=config.js.map
|