@tenphi/tasty 0.0.0-snapshot.27699f6 → 0.0.0-snapshot.27b6708
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 +171 -107
- package/dist/{async-storage-B7_o6FKt.js → async-storage-DKK-wTD4.js} +1 -1
- package/dist/{async-storage-B7_o6FKt.js.map → async-storage-DKK-wTD4.js.map} +1 -1
- package/dist/babel-BUQGeOXA.d.ts +83 -0
- package/dist/{collector-QwpPODsy.js → collector-DTahQUiV.js} +97 -23
- package/dist/collector-DTahQUiV.js.map +1 -0
- package/dist/{collector-LuU1vZ68.d.ts → collector-DUaHCcTS.d.ts} +54 -7
- package/dist/{config-rrijM-U2.js → config-B5kHzuNz.js} +5144 -3012
- package/dist/config-B5kHzuNz.js.map +1 -0
- package/dist/{config-vuCRkBWX.d.ts → config-YsxGv4tq.d.ts} +412 -33
- package/dist/{context-CkSg-kDT.js → context-CA8YKeMn.js} +1 -1
- package/dist/{context-CkSg-kDT.js.map → context-CA8YKeMn.js.map} +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-BvTG0J_M.js → core-Dr4u1NVD.js} +162 -188
- package/dist/core-Dr4u1NVD.js.map +1 -0
- package/dist/{css-writer-C7HJGEmN.js → css-writer-B-J87ncv.js} +78 -17
- package/dist/css-writer-B-J87ncv.js.map +1 -0
- package/dist/{format-global-rules-Dbc_1tc3.js → format-global-rules-DklyaXv-.js} +1 -1
- package/dist/{format-global-rules-Dbc_1tc3.js.map → format-global-rules-DklyaXv-.js.map} +1 -1
- package/dist/{format-rules-BvokPr1L.js → format-rules-DKOA-6qu.js} +4 -17
- package/dist/format-rules-DKOA-6qu.js.map +1 -0
- package/dist/{hydrate-Dsv7Pwon.js → hydrate-OeMX99We.js} +3 -11
- package/dist/{hydrate-Dsv7Pwon.js.map → hydrate-OeMX99We.js.map} +1 -1
- package/dist/{index-dUtwpOux.d.ts → index-Cd45t5NM.d.ts} +319 -64
- package/dist/{index-ZRxZWzlj.d.ts → index-PqN-DIpn.d.ts} +498 -189
- package/dist/index.d.ts +5 -5
- package/dist/index.js +253 -63
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-DDqRjwa9.js → keyframes-CV8azJf3.js} +97 -191
- package/dist/keyframes-CV8azJf3.js.map +1 -0
- package/dist/{merge-styles-CtDJMhpJ.d.ts → merge-styles-CU7JbEwg.d.ts} +2 -2
- package/dist/{merge-styles-B8jV6zu3.js → merge-styles-oklji0KB.js} +2 -2
- package/dist/{merge-styles-B8jV6zu3.js.map → merge-styles-oklji0KB.js.map} +1 -1
- package/dist/{resolve-recipes-BnTZz2I_.js → resolve-recipes-DTG81rzl.js} +3 -3
- package/dist/{resolve-recipes-BnTZz2I_.js.map → resolve-recipes-DTG81rzl.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-static.d.ts +16 -0
- package/dist/ssr/astro-middleware-static.js +18 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +8 -6
- package/dist/ssr/astro-middleware.js +10 -10
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +2 -17
- package/dist/ssr/astro.js +29 -21
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -9
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -3
- package/dist/ssr/next.js +6 -7
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +4 -4
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.js.map +1 -1
- package/dist/zero/babel.d.ts +2 -81
- package/dist/zero/babel.js +39 -27
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +16 -2
- package/dist/zero/index.js +2 -2
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +1 -1
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +12 -6
- package/docs/adoption.md +53 -28
- package/docs/ai-agents.md +224 -0
- package/docs/comparison.md +59 -30
- package/docs/configuration.md +498 -69
- package/docs/debug.md +7 -7
- package/docs/design-system.md +43 -24
- package/docs/dsl.md +510 -178
- package/docs/getting-started.md +55 -34
- package/docs/injector.md +58 -5
- package/docs/methodology.md +68 -36
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +93 -25
- package/docs/plugins.md +349 -0
- package/docs/react-api.md +162 -38
- package/docs/ssr.md +45 -35
- package/docs/styles.md +65 -16
- package/docs/tasty-static.md +25 -8
- package/package.json +43 -21
- package/tasty.config.ts +6 -0
- package/dist/collector-QwpPODsy.js.map +0 -1
- package/dist/config-rrijM-U2.js.map +0 -1
- package/dist/core-BvTG0J_M.js.map +0 -1
- package/dist/css-writer-C7HJGEmN.js.map +0 -1
- package/dist/format-rules-BvokPr1L.js.map +0 -1
- package/dist/keyframes-DDqRjwa9.js.map +0 -1
|
@@ -1,104 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as mergeKeyframes, c as generateChunkCacheKey,
|
|
3
|
-
import { n as formatPropertyCSS, r as getRegisteredSSRCollector, t as formatRules } from "./format-rules-
|
|
4
|
-
import { t as resolveRecipes } from "./resolve-recipes-
|
|
1
|
+
import { Bt as getGlobalParseFunctions, G as StyleInjector, Gt as parseStyle, It as registerLocalFunctionPolyfills, J as hasLocalCounterStyle, K as extractLocalCounterStyle, Mt as formatFunctionRule, Nt as hasLocalFunctions, Pt as parseFunctionName, Q as hasLocalFontFace, Qt as isDevEnv, Ut as normalizeColorTokenValue, Vt as getGlobalParser, X as fontFaceContentHash, Y as extractLocalFontFace, Z as formatFontFaceRule, _ as isFunctionsPolyfillEnabled, _t as hashString, bt as hasLocalProperties, c as getGlobalInjector, en as Lru, et as STYLE_HANDLER_MAP, f as getNamePrefix, ft as makeClassName, ht as tastyClassRegex, it as PropertyTypeResolver, jt as extractLocalFunctions, l as getGlobalKeyframes, n as getConfig, p as hasGlobalKeyframes, q as formatCounterStyleRule, rt as createStyle, sn as normalizeDslName, tn as overrideColorAlpha, v as isTestEnvironment, vt as extractLocalProperties, wt as CHUNK_NAMES, xt as parsePropertyToken, y as markStylesGenerated, z as camelToKebab } from "./config-B5kHzuNz.js";
|
|
2
|
+
import { a as mergeKeyframes, c as generateChunkCacheKey, i as hasLocalKeyframes, l as categorizeStyleKeys, n as extractLocalKeyframes, o as replaceAnimationNames, r as filterUsedKeyframes, s as renderStylesForChunk, t as extractAnimationNamesFromStyles } from "./keyframes-CV8azJf3.js";
|
|
3
|
+
import { n as formatPropertyCSS, r as getRegisteredSSRCollector, t as formatRules } from "./format-rules-DKOA-6qu.js";
|
|
4
|
+
import { t as resolveRecipes } from "./resolve-recipes-DTG81rzl.js";
|
|
5
5
|
import { cache } from "react";
|
|
6
|
-
//#region src/
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"paddingBlock",
|
|
34
|
-
"overflow",
|
|
35
|
-
"scrollbar",
|
|
36
|
-
"textAlign"
|
|
37
|
-
];
|
|
38
|
-
const BLOCK_OUTER_STYLES = [
|
|
39
|
-
"border",
|
|
40
|
-
"radius",
|
|
41
|
-
"shadow",
|
|
42
|
-
"outline"
|
|
43
|
-
];
|
|
44
|
-
const BLOCK_STYLES = [...BLOCK_INNER_STYLES, ...BLOCK_OUTER_STYLES];
|
|
45
|
-
const COLOR_STYLES = [
|
|
46
|
-
"color",
|
|
47
|
-
"fill",
|
|
48
|
-
"fade",
|
|
49
|
-
"image"
|
|
50
|
-
];
|
|
51
|
-
const TEXT_STYLES = [
|
|
52
|
-
"textTransform",
|
|
53
|
-
"fontWeight",
|
|
54
|
-
"fontStyle"
|
|
55
|
-
];
|
|
56
|
-
const DIMENSION_STYLES = [
|
|
57
|
-
"width",
|
|
58
|
-
"height",
|
|
59
|
-
"flexBasis",
|
|
60
|
-
"flexGrow",
|
|
61
|
-
"flexShrink",
|
|
62
|
-
"flex"
|
|
63
|
-
];
|
|
64
|
-
const FLOW_STYLES = [
|
|
65
|
-
"flow",
|
|
66
|
-
"place",
|
|
67
|
-
"placeItems",
|
|
68
|
-
"placeContent",
|
|
69
|
-
"alignItems",
|
|
70
|
-
"alignContent",
|
|
71
|
-
"justifyItems",
|
|
72
|
-
"justifyContent",
|
|
73
|
-
"align",
|
|
74
|
-
"justify",
|
|
75
|
-
"gap",
|
|
76
|
-
"columnGap",
|
|
77
|
-
"rowGap",
|
|
78
|
-
"gridColumns",
|
|
79
|
-
"gridRows",
|
|
80
|
-
"gridTemplate",
|
|
81
|
-
"gridAreas"
|
|
82
|
-
];
|
|
83
|
-
const CONTAINER_STYLES = [
|
|
84
|
-
...BASE_STYLES,
|
|
85
|
-
...COLOR_STYLES,
|
|
86
|
-
...DIMENSION_STYLES,
|
|
87
|
-
...POSITION_STYLES,
|
|
88
|
-
...BLOCK_STYLES,
|
|
89
|
-
...FLOW_STYLES
|
|
90
|
-
];
|
|
91
|
-
const OUTER_STYLES = [
|
|
92
|
-
...POSITION_STYLES,
|
|
93
|
-
...DIMENSION_STYLES,
|
|
94
|
-
...BLOCK_OUTER_STYLES
|
|
95
|
-
];
|
|
96
|
-
const INNER_STYLES = [
|
|
97
|
-
...BASE_STYLES,
|
|
98
|
-
...COLOR_STYLES,
|
|
99
|
-
...BLOCK_INNER_STYLES,
|
|
100
|
-
...FLOW_STYLES
|
|
101
|
-
];
|
|
6
|
+
//#region src/utils/function-color.ts
|
|
7
|
+
const RE_FUNC_NAME = /^([a-z][a-z0-9-]*)\s*\(/i;
|
|
8
|
+
const RE_COLOR_OUT = /^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\(|^#|^var\(--/i;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve a `name(...)` value produced by a registered custom parse function
|
|
11
|
+
* into its concrete color output.
|
|
12
|
+
*
|
|
13
|
+
* A color function is just a `functions` entry whose output is an already
|
|
14
|
+
* supported color (`rgb`, `hsl`, `#…`, `oklch`, …). This helper delegates the
|
|
15
|
+
* value to the global parser (which already runs the registered parse function)
|
|
16
|
+
* and returns the result only when it looks like a color. Returns `null` when
|
|
17
|
+
* `str` is not a registered custom function or its output is not a color.
|
|
18
|
+
*
|
|
19
|
+
* This is the generic replacement for the previously hardcoded okhsl/okhst
|
|
20
|
+
* conversion branches scattered across `strToRgb`, `resolveToRgbaValues`, and
|
|
21
|
+
* the `#token.alpha` injection path.
|
|
22
|
+
*/
|
|
23
|
+
function resolveFunctionColor(str) {
|
|
24
|
+
const m = RE_FUNC_NAME.exec(str);
|
|
25
|
+
if (!m) return null;
|
|
26
|
+
const name = m[1].toLowerCase();
|
|
27
|
+
getGlobalParser();
|
|
28
|
+
if (!(name in getGlobalParseFunctions())) return null;
|
|
29
|
+
const out = getGlobalParser().process(str).output;
|
|
30
|
+
if (!out || !RE_COLOR_OUT.test(out)) return null;
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
102
33
|
//#endregion
|
|
103
34
|
//#region src/injector/chunk-sheet-registry.ts
|
|
104
35
|
/**
|
|
@@ -265,33 +196,53 @@ function fontFace(family, descriptors, options) {
|
|
|
265
196
|
/**
|
|
266
197
|
* Inject a CSS @counter-style rule.
|
|
267
198
|
*
|
|
268
|
-
* Permanent and global — no dispose or ref-counting.
|
|
269
|
-
*
|
|
199
|
+
* Permanent and global — no dispose or ref-counting. Deduplicates by name and
|
|
200
|
+
* overrides an existing rule by default. Pass `weak: true` for global
|
|
201
|
+
* `configure()` definitions, which never clobber an existing rule.
|
|
270
202
|
*/
|
|
271
203
|
function counterStyle(name, descriptors, options) {
|
|
272
204
|
return getGlobalInjector().counterStyle(name, descriptors, options);
|
|
273
205
|
}
|
|
274
206
|
/**
|
|
207
|
+
* Inject a CSS @function rule (custom function).
|
|
208
|
+
*
|
|
209
|
+
* Permanent and global — no dispose or ref-counting. Deduplicates by function
|
|
210
|
+
* name and overrides an existing rule by default. Pass `weak: true` for global
|
|
211
|
+
* `configure()` definitions, which never clobber an existing rule.
|
|
212
|
+
*
|
|
213
|
+
* @param name - The function name (`$$name`, `$name`, or `--name`)
|
|
214
|
+
* @param definition - Function definition (args, returns, result, local vars)
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* func('$$negative', { args: ['$value'], result: '(-1 * $value)' });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
function func(name, definition, options) {
|
|
222
|
+
return getGlobalInjector().func(name, definition, options);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
275
225
|
* Get CSS text from all sheets (for SSR)
|
|
276
226
|
*/
|
|
277
|
-
function
|
|
278
|
-
return getGlobalInjector().
|
|
227
|
+
function getCSSText(options) {
|
|
228
|
+
return getGlobalInjector().getCSSText(options);
|
|
279
229
|
}
|
|
280
230
|
/**
|
|
281
231
|
* Collect only CSS used by a rendered subtree (like jest-styled-components).
|
|
282
232
|
* Pass the container returned by render(...).
|
|
283
233
|
*/
|
|
284
|
-
function
|
|
234
|
+
function getCSSTextForNode(node, options) {
|
|
235
|
+
const classRegex = tastyClassRegex(getNamePrefix());
|
|
285
236
|
const classSet = /* @__PURE__ */ new Set();
|
|
286
237
|
const readClasses = (el) => {
|
|
287
238
|
const cls = el.getAttribute("class");
|
|
288
239
|
if (!cls) return;
|
|
289
|
-
for (const token of cls.split(/\s+/)) if (
|
|
240
|
+
for (const token of cls.split(/\s+/)) if (classRegex.test(token)) classSet.add(token);
|
|
290
241
|
};
|
|
291
242
|
if (node.getAttribute) readClasses(node);
|
|
292
243
|
const elements = node.querySelectorAll ? node.querySelectorAll("[class]") : [];
|
|
293
244
|
if (elements) elements.forEach(readClasses);
|
|
294
|
-
return getGlobalInjector().
|
|
245
|
+
return getGlobalInjector().getCSSTextForClasses(classSet, options);
|
|
295
246
|
}
|
|
296
247
|
/**
|
|
297
248
|
* Force cleanup of unused rules
|
|
@@ -319,12 +270,6 @@ function gc(options) {
|
|
|
319
270
|
return getGlobalInjector().gc(options);
|
|
320
271
|
}
|
|
321
272
|
/**
|
|
322
|
-
* Check if we're currently running in a test environment
|
|
323
|
-
*/
|
|
324
|
-
function getIsTestEnvironment() {
|
|
325
|
-
return isTestEnvironment();
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
273
|
* Get the global injector instance for debugging
|
|
329
274
|
*/
|
|
330
275
|
const injector = { get instance() {
|
|
@@ -367,6 +312,7 @@ const getRSCCache = cache(() => ({
|
|
|
367
312
|
emittedKeys: /* @__PURE__ */ new Set(),
|
|
368
313
|
internalsEmitted: false,
|
|
369
314
|
pendingCSS: [],
|
|
315
|
+
keyToIndex: /* @__PURE__ */ new Map(),
|
|
370
316
|
generatedNames: /* @__PURE__ */ new Map()
|
|
371
317
|
}));
|
|
372
318
|
function rscAllocateClassName(rscCache, cacheKey) {
|
|
@@ -375,7 +321,7 @@ function rscAllocateClassName(rscCache, cacheKey) {
|
|
|
375
321
|
className: existing,
|
|
376
322
|
isNew: false
|
|
377
323
|
};
|
|
378
|
-
const className =
|
|
324
|
+
const className = makeClassName(getNamePrefix(), hashString(cacheKey));
|
|
379
325
|
rscCache.cacheKeyToClassName.set(cacheKey, className);
|
|
380
326
|
return {
|
|
381
327
|
className,
|
|
@@ -390,15 +336,28 @@ function flushPendingCSS(rscCache) {
|
|
|
390
336
|
if (rscCache.pendingCSS.length === 0) return "";
|
|
391
337
|
const css = rscCache.pendingCSS.join("\n");
|
|
392
338
|
rscCache.pendingCSS.length = 0;
|
|
339
|
+
rscCache.keyToIndex.clear();
|
|
393
340
|
return css;
|
|
394
341
|
}
|
|
395
342
|
/**
|
|
396
343
|
* Push CSS into the RSC pending buffer with dedup via emittedKeys.
|
|
397
344
|
* Returns true if the CSS was added, false if it was already emitted.
|
|
345
|
+
*
|
|
346
|
+
* Pass `replace` for slot-keyed entries (an explicit `id`), where the last write
|
|
347
|
+
* must win to match the client's update-tracking behavior. If the slot has
|
|
348
|
+
* already been flushed into a `<style>` tag the new CSS is appended instead,
|
|
349
|
+
* which still wins by cascade order.
|
|
398
350
|
*/
|
|
399
|
-
function pushRSCCSS(rscCache, key, css) {
|
|
400
|
-
if (
|
|
351
|
+
function pushRSCCSS(rscCache, key, css, replace) {
|
|
352
|
+
if (replace) {
|
|
353
|
+
const pendingIndex = rscCache.keyToIndex.get(key);
|
|
354
|
+
if (pendingIndex !== void 0) {
|
|
355
|
+
rscCache.pendingCSS[pendingIndex] = css;
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
} else if (rscCache.emittedKeys.has(key)) return false;
|
|
401
359
|
rscCache.emittedKeys.add(key);
|
|
360
|
+
rscCache.keyToIndex.set(key, rscCache.pendingCSS.length);
|
|
402
361
|
rscCache.pendingCSS.push(css);
|
|
403
362
|
return true;
|
|
404
363
|
}
|
|
@@ -428,7 +387,7 @@ function getStyleTarget() {
|
|
|
428
387
|
function scanAndEmitAutoProperties(rules, styles, emit) {
|
|
429
388
|
const registered = /* @__PURE__ */ new Set();
|
|
430
389
|
if (styles) {
|
|
431
|
-
const localProps = styles["@
|
|
390
|
+
const localProps = styles["@property"];
|
|
432
391
|
if (localProps && typeof localProps === "object") for (const token of Object.keys(localProps)) {
|
|
433
392
|
const parsed = parsePropertyToken(token);
|
|
434
393
|
if (parsed.isValid) registered.add(parsed.cssName);
|
|
@@ -454,7 +413,7 @@ function scanAndEmitAutoProperties(rules, styles, emit) {
|
|
|
454
413
|
*
|
|
455
414
|
* @param rules - Rendered style rules containing CSS declarations
|
|
456
415
|
* @param collector - SSR collector to emit @property CSS into
|
|
457
|
-
* @param styles - Original styles object (used to skip explicit @
|
|
416
|
+
* @param styles - Original styles object (used to skip explicit @property)
|
|
458
417
|
*/
|
|
459
418
|
function collectAutoInferredProperties(rules, collector, styles) {
|
|
460
419
|
scanAndEmitAutoProperties(rules, styles, (name, css) => {
|
|
@@ -625,13 +584,23 @@ function collectAncillaryRSC(rscCache, styles) {
|
|
|
625
584
|
}
|
|
626
585
|
}
|
|
627
586
|
}
|
|
587
|
+
if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
|
|
588
|
+
const localFunctions = extractLocalFunctions(styles);
|
|
589
|
+
if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) {
|
|
590
|
+
const key = `__func:${parseFunctionName(name)}`;
|
|
591
|
+
if (!rscCache.emittedKeys.has(key)) {
|
|
592
|
+
rscCache.emittedKeys.add(key);
|
|
593
|
+
parts.push(formatFunctionRule(name, definition));
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
628
597
|
return parts.join("\n");
|
|
629
598
|
}
|
|
630
599
|
/**
|
|
631
600
|
* Process all chunks in RSC mode: render CSS to strings, allocate classNames,
|
|
632
601
|
* and return combined { className, css }.
|
|
633
602
|
*/
|
|
634
|
-
function computeStylesRSC(styles, chunkMap) {
|
|
603
|
+
function computeStylesRSC(styles, chunkMap, stableStyles) {
|
|
635
604
|
const rscCache = getRSCCache();
|
|
636
605
|
const cssParts = [];
|
|
637
606
|
const classNames = [];
|
|
@@ -641,7 +610,7 @@ function computeStylesRSC(styles, chunkMap) {
|
|
|
641
610
|
if (internalsCSS) cssParts.push(internalsCSS);
|
|
642
611
|
for (const [chunkName, chunkStyleKeys] of chunkMap) {
|
|
643
612
|
if (chunkStyleKeys.length === 0) continue;
|
|
644
|
-
const { className, isNew } = rscAllocateClassName(rscCache, generateChunkCacheKey(styles, chunkName, chunkStyleKeys));
|
|
613
|
+
const { className, isNew } = rscAllocateClassName(rscCache, generateChunkCacheKey(styles, chunkName, chunkStyleKeys, stableStyles));
|
|
645
614
|
classNames.push(className);
|
|
646
615
|
if (isNew) {
|
|
647
616
|
const renderResult = renderStylesForChunk(styles, chunkName, chunkStyleKeys);
|
|
@@ -675,9 +644,9 @@ function getUsedKeyframes(styles) {
|
|
|
675
644
|
/**
|
|
676
645
|
* Process a chunk on the SSR path: allocate via collector, render, collect CSS.
|
|
677
646
|
*/
|
|
678
|
-
function processChunkSSR(collector, styles, chunkName, styleKeys) {
|
|
647
|
+
function processChunkSSR(collector, styles, chunkName, styleKeys, stableStyles) {
|
|
679
648
|
if (styleKeys.length === 0) return null;
|
|
680
|
-
const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
|
|
649
|
+
const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys, stableStyles);
|
|
681
650
|
const { className, isNewAllocation } = collector.allocateClassName(cacheKey);
|
|
682
651
|
if (isNewAllocation) {
|
|
683
652
|
const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);
|
|
@@ -705,9 +674,9 @@ function processChunkSSR(collector, styles, chunkName, styleKeys) {
|
|
|
705
674
|
* Process a chunk on the client: render, allocate className, and inject
|
|
706
675
|
* CSS synchronously. The injector's cache makes this idempotent.
|
|
707
676
|
*/
|
|
708
|
-
function processChunkSync(styles, chunkName, styleKeys, root) {
|
|
677
|
+
function processChunkSync(styles, chunkName, styleKeys, stableStyles, root) {
|
|
709
678
|
if (styleKeys.length === 0) return null;
|
|
710
|
-
const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
|
|
679
|
+
const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys, stableStyles);
|
|
711
680
|
const renderResult = renderStylesForChunk(styles, chunkName, styleKeys, cacheKey);
|
|
712
681
|
if (renderResult.rules.length === 0) return null;
|
|
713
682
|
const { className } = inject(renderResult.rules, {
|
|
@@ -774,6 +743,10 @@ function injectAncillarySync(styles, root) {
|
|
|
774
743
|
const localCounterStyle = extractLocalCounterStyle(styles);
|
|
775
744
|
if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) counterStyle(name, descriptors, { root });
|
|
776
745
|
}
|
|
746
|
+
if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
|
|
747
|
+
const localFunctions = extractLocalFunctions(styles);
|
|
748
|
+
if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) func(name, definition, { root });
|
|
749
|
+
}
|
|
777
750
|
}
|
|
778
751
|
/**
|
|
779
752
|
* Collect all ancillary rules into the SSR collector.
|
|
@@ -809,6 +782,13 @@ function collectAncillarySSR(collector, styles, chunks) {
|
|
|
809
782
|
collector.collectCounterStyle(name, css);
|
|
810
783
|
}
|
|
811
784
|
}
|
|
785
|
+
if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
|
|
786
|
+
const localFunctions = extractLocalFunctions(styles);
|
|
787
|
+
if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) {
|
|
788
|
+
const css = formatFunctionRule(name, definition);
|
|
789
|
+
collector.collectFunction(parseFunctionName(name), css);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
812
792
|
if (getConfig().autoPropertyTypes !== false) {
|
|
813
793
|
const allRules = chunks.flatMap((c) => c.renderResult.rules);
|
|
814
794
|
if (allRules.length > 0) collectAutoInferredProperties(allRules, collector, styles);
|
|
@@ -832,24 +812,26 @@ function collectAncillarySSR(collector, styles, chunks) {
|
|
|
832
812
|
function computeStyles(styles, options) {
|
|
833
813
|
if (!styles || !hasKeys(styles)) return EMPTY_RESULT;
|
|
834
814
|
const resolved = resolveRecipes(styles);
|
|
815
|
+
const stableStyles = options?.stableStyles === true && resolved === styles;
|
|
816
|
+
if (isFunctionsPolyfillEnabled() && hasLocalFunctions(resolved)) registerLocalFunctionPolyfills(resolved);
|
|
835
817
|
const chunkMap = categorizeStyleKeys(resolved);
|
|
836
818
|
const collector = options?.ssrCollector !== void 0 ? options.ssrCollector : getRegisteredSSRCollector();
|
|
837
819
|
const chunks = [];
|
|
838
820
|
if (collector) {
|
|
839
821
|
collector.collectInternals();
|
|
840
822
|
for (const [chunkName, chunkStyleKeys] of chunkMap) {
|
|
841
|
-
const chunk = processChunkSSR(collector, resolved, chunkName, chunkStyleKeys);
|
|
823
|
+
const chunk = processChunkSSR(collector, resolved, chunkName, chunkStyleKeys, stableStyles);
|
|
842
824
|
if (chunk) chunks.push(chunk);
|
|
843
825
|
}
|
|
844
826
|
collectAncillarySSR(collector, resolved, chunks);
|
|
845
|
-
} else if (typeof document === "undefined") return computeStylesRSC(resolved, chunkMap);
|
|
827
|
+
} else if (typeof document === "undefined") return computeStylesRSC(resolved, chunkMap, stableStyles);
|
|
846
828
|
else {
|
|
847
829
|
const root = options?.root;
|
|
848
830
|
injectAncillarySync(resolved, root);
|
|
849
831
|
const usedKf = getUsedKeyframes(resolved);
|
|
850
832
|
const nameMap = usedKf ? injectKeyframesSync(usedKf, root) : null;
|
|
851
833
|
for (const [chunkName, chunkStyleKeys] of chunkMap) {
|
|
852
|
-
const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys, root);
|
|
834
|
+
const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys, stableStyles, root);
|
|
853
835
|
if (chunk) chunks.push(chunk);
|
|
854
836
|
}
|
|
855
837
|
if (nameMap) injectChunkRulesSync(chunks, nameMap, root);
|
|
@@ -904,7 +886,7 @@ function filterBaseProps(props, opts = {}) {
|
|
|
904
886
|
//#endregion
|
|
905
887
|
//#region src/utils/colors.ts
|
|
906
888
|
function color(name, opacity = 1) {
|
|
907
|
-
if (opacity !== 1) return
|
|
889
|
+
if (opacity !== 1) return overrideColorAlpha(`var(--${name}-color)`, String(opacity));
|
|
908
890
|
return `var(--${name}-color)`;
|
|
909
891
|
}
|
|
910
892
|
//#endregion
|
|
@@ -934,7 +916,7 @@ function modAttrs(map) {
|
|
|
934
916
|
if (value === true) attrs[attrName] = "";
|
|
935
917
|
else if (typeof value === "string") attrs[attrName] = value;
|
|
936
918
|
else if (typeof value === "number") attrs[attrName] = String(value);
|
|
937
|
-
else console.warn(`Tasty
|
|
919
|
+
else console.warn(`[Tasty] Invalid mod value for "${key}". Expected boolean, string, or number, got ${typeof value}`);
|
|
938
920
|
return attrs;
|
|
939
921
|
}, {}) : null;
|
|
940
922
|
}
|
|
@@ -1061,28 +1043,13 @@ const dotize = {
|
|
|
1061
1043
|
//#endregion
|
|
1062
1044
|
//#region src/utils/process-tokens.ts
|
|
1063
1045
|
/**
|
|
1064
|
-
* Extract color components in the configured color space.
|
|
1065
|
-
* Returns a CSS variable reference for token colors, or decomposed
|
|
1066
|
-
* components as a space-separated string.
|
|
1067
|
-
*/
|
|
1068
|
-
function extractColorSpaceValue(colorValue, parsedOutput) {
|
|
1069
|
-
const suffix = getColorSpaceSuffix();
|
|
1070
|
-
const varMatch = parsedOutput.match(/var\(--([a-z0-9-]+)-color\)/);
|
|
1071
|
-
if (varMatch) return `var(--${varMatch[1]}-color-${suffix})`;
|
|
1072
|
-
const components = getColorSpaceComponents(colorValue);
|
|
1073
|
-
if (components !== colorValue) return components;
|
|
1074
|
-
const componentsFromParsed = getColorSpaceComponents(parsedOutput);
|
|
1075
|
-
if (componentsFromParsed !== parsedOutput) return componentsFromParsed;
|
|
1076
|
-
return parsedOutput;
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
1046
|
* Check if a value is a valid token value (string, number, or boolean - not object).
|
|
1080
1047
|
* Returns false for `false` values (they mean "skip this token").
|
|
1081
1048
|
*/
|
|
1082
1049
|
function isValidTokenValue(value) {
|
|
1083
1050
|
if (value === void 0 || value === null || value === false) return false;
|
|
1084
1051
|
if (typeof value === "object") {
|
|
1085
|
-
console.warn("Tasty
|
|
1052
|
+
console.warn("[Tasty] Object values are not allowed in tokens prop. Tokens do not support state-based styling. Use a primitive value instead.");
|
|
1086
1053
|
return false;
|
|
1087
1054
|
}
|
|
1088
1055
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
@@ -1099,9 +1066,24 @@ function processTokenValue(value) {
|
|
|
1099
1066
|
return parseStyle(value).output;
|
|
1100
1067
|
}
|
|
1101
1068
|
/**
|
|
1069
|
+
* Resolve one `$name` / `#name` entry to the custom property it declares and
|
|
1070
|
+
* the value to declare, or `null` when the entry declares nothing.
|
|
1071
|
+
*
|
|
1072
|
+
* The two sigils differ only in the property name they build and in how `true`
|
|
1073
|
+
* is read: for a custom property it is the empty value, for a color it is
|
|
1074
|
+
* `transparent`.
|
|
1075
|
+
*/
|
|
1076
|
+
function resolveTokenEntry(key, value) {
|
|
1077
|
+
const name = `--${normalizeDslName(key.slice(1))}`;
|
|
1078
|
+
if (key[0] === "$") return [name, processTokenValue(value === true ? "" : value)];
|
|
1079
|
+
const colorValue = normalizeColorTokenValue(value);
|
|
1080
|
+
if (colorValue === null) return null;
|
|
1081
|
+
return [`${name}-color`, processTokenValue(colorValue)];
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1102
1084
|
* Process tokens object into inline style properties.
|
|
1103
|
-
* -
|
|
1104
|
-
* -
|
|
1085
|
+
* - `$name` -> `--name` with the parsed value
|
|
1086
|
+
* - `#name` -> `--name-color` with the parsed value
|
|
1105
1087
|
*
|
|
1106
1088
|
* @param tokens - The tokens object to process
|
|
1107
1089
|
* @returns CSSProperties object or undefined if no tokens to process
|
|
@@ -1114,24 +1096,11 @@ function processTokens(tokens) {
|
|
|
1114
1096
|
for (const key of keys) {
|
|
1115
1097
|
const value = tokens[key];
|
|
1116
1098
|
if (!isValidTokenValue(value)) continue;
|
|
1117
|
-
if (key
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
} else if (key.startsWith("#")) {
|
|
1123
|
-
const colorName = key.slice(1);
|
|
1124
|
-
const suffix = getColorSpaceSuffix();
|
|
1125
|
-
const effectiveValue = normalizeColorTokenValue(value);
|
|
1126
|
-
if (effectiveValue === null) continue;
|
|
1127
|
-
const originalValue = typeof effectiveValue === "number" ? String(effectiveValue) : effectiveValue;
|
|
1128
|
-
const lowerValue = originalValue.toLowerCase();
|
|
1129
|
-
const processedValue = processTokenValue(effectiveValue);
|
|
1130
|
-
if (!result) result = {};
|
|
1131
|
-
result[`--${colorName}-color`] = processedValue;
|
|
1132
|
-
if (/^#current(?:\.|$)/i.test(lowerValue)) continue;
|
|
1133
|
-
result[`--${colorName}-color-${suffix}`] = extractColorSpaceValue(originalValue, processedValue);
|
|
1134
|
-
}
|
|
1099
|
+
if (key[0] !== "$" && key[0] !== "#") continue;
|
|
1100
|
+
const entry = resolveTokenEntry(key, value);
|
|
1101
|
+
if (!entry) continue;
|
|
1102
|
+
if (!result) result = {};
|
|
1103
|
+
result[entry[0]] = entry[1];
|
|
1135
1104
|
}
|
|
1136
1105
|
return result;
|
|
1137
1106
|
}
|
|
@@ -1158,10 +1127,12 @@ function getUnusedClasses(root = document) {
|
|
|
1158
1127
|
}
|
|
1159
1128
|
function findDomTastyClasses(root = document) {
|
|
1160
1129
|
const classes = /* @__PURE__ */ new Set();
|
|
1161
|
-
|
|
1130
|
+
const elements = root.querySelectorAll?.("[class]") || [];
|
|
1131
|
+
const classRegex = tastyClassRegex(getNamePrefix());
|
|
1132
|
+
elements.forEach((el) => {
|
|
1162
1133
|
const attr = el.getAttribute("class");
|
|
1163
1134
|
if (attr) {
|
|
1164
|
-
for (const cls of attr.split(/\s+/)) if (
|
|
1135
|
+
for (const cls of attr.split(/\s+/)) if (classRegex.test(cls)) classes.add(cls);
|
|
1165
1136
|
}
|
|
1166
1137
|
});
|
|
1167
1138
|
return sortTastyClasses(classes);
|
|
@@ -1248,7 +1219,7 @@ function buildChunkBreakdown(root = document) {
|
|
|
1248
1219
|
ruleCount: 0
|
|
1249
1220
|
};
|
|
1250
1221
|
byChunk[chunk].classes.push(className);
|
|
1251
|
-
const css = injector.instance.
|
|
1222
|
+
const css = injector.instance.getCSSTextForClasses([className], { root });
|
|
1252
1223
|
byChunk[chunk].cssSize += css.length;
|
|
1253
1224
|
byChunk[chunk].ruleCount += countRules(css);
|
|
1254
1225
|
}
|
|
@@ -1361,38 +1332,39 @@ const tastyDebug = {
|
|
|
1361
1332
|
css(target, opts) {
|
|
1362
1333
|
const { root = document, prettify = true, raw = false, source = false } = opts || {};
|
|
1363
1334
|
let css = "";
|
|
1364
|
-
|
|
1335
|
+
const classRegex = tastyClassRegex(getNamePrefix());
|
|
1336
|
+
if (source && typeof target === "string" && classRegex.test(target)) {
|
|
1365
1337
|
const src = getSourceCssForClasses([target], root);
|
|
1366
1338
|
if (src) css = src;
|
|
1367
1339
|
else {
|
|
1368
|
-
if (!raw) console.warn("
|
|
1369
|
-
css = injector.instance.
|
|
1340
|
+
if (!raw) console.warn("[Tasty] source CSS not available (requires dev mode or TASTY_DEBUG=true). Falling back to live CSSOM.");
|
|
1341
|
+
css = injector.instance.getCSSTextForClasses([target], { root });
|
|
1370
1342
|
}
|
|
1371
1343
|
} else if (source && Array.isArray(target)) {
|
|
1372
1344
|
const src = getSourceCssForClasses(target, root);
|
|
1373
1345
|
if (src) css = src;
|
|
1374
1346
|
else {
|
|
1375
|
-
if (!raw) console.warn("
|
|
1376
|
-
css = injector.instance.
|
|
1347
|
+
if (!raw) console.warn("[Tasty] source CSS not available. Falling back to live CSSOM.");
|
|
1348
|
+
css = injector.instance.getCSSTextForClasses(target, { root });
|
|
1377
1349
|
}
|
|
1378
|
-
} else if (typeof target === "string") if (target === "all") css = injector.instance.
|
|
1350
|
+
} else if (typeof target === "string") if (target === "all") css = injector.instance.getCSSText({ root });
|
|
1379
1351
|
else if (target === "global") {
|
|
1380
1352
|
css = getGlobalTypeCSS("global", root).css;
|
|
1381
1353
|
return css;
|
|
1382
1354
|
} else if (target === "active") {
|
|
1383
1355
|
const active = findDomTastyClasses(root);
|
|
1384
|
-
css = injector.instance.
|
|
1356
|
+
css = injector.instance.getCSSTextForClasses(active, { root });
|
|
1385
1357
|
} else if (target === "unused") {
|
|
1386
1358
|
const unused = getUnusedClasses(root);
|
|
1387
|
-
css = injector.instance.
|
|
1359
|
+
css = injector.instance.getCSSTextForClasses(unused, { root });
|
|
1388
1360
|
} else if (target === "page") css = getPageCSS(root);
|
|
1389
|
-
else if (
|
|
1361
|
+
else if (classRegex.test(target)) css = injector.instance.getCSSTextForClasses([target], { root });
|
|
1390
1362
|
else {
|
|
1391
1363
|
const el = root.querySelector?.(target);
|
|
1392
|
-
if (el) css =
|
|
1364
|
+
if (el) css = getCSSTextForNode(el, { root });
|
|
1393
1365
|
}
|
|
1394
|
-
else if (Array.isArray(target)) css = injector.instance.
|
|
1395
|
-
else if (target instanceof Element) css =
|
|
1366
|
+
else if (Array.isArray(target)) css = injector.instance.getCSSTextForClasses(target, { root });
|
|
1367
|
+
else if (target instanceof Element) css = getCSSTextForNode(target, { root });
|
|
1396
1368
|
const result = prettify ? prettifyCSS(css) : css;
|
|
1397
1369
|
if (!raw) {
|
|
1398
1370
|
const label = Array.isArray(target) ? `[${target.join(", ")}]` : target;
|
|
@@ -1415,15 +1387,17 @@ const tastyDebug = {
|
|
|
1415
1387
|
size: 0,
|
|
1416
1388
|
rules: 0
|
|
1417
1389
|
};
|
|
1418
|
-
if (!raw) console.warn("
|
|
1390
|
+
if (!raw) console.warn("[Tasty] debug.inspect: element not found");
|
|
1419
1391
|
return empty;
|
|
1420
1392
|
}
|
|
1421
|
-
const
|
|
1393
|
+
const classList = element.getAttribute("class") || "";
|
|
1394
|
+
const classRegex = tastyClassRegex(getNamePrefix());
|
|
1395
|
+
const tastyClasses = classList.split(/\s+/).filter((cls) => classRegex.test(cls));
|
|
1422
1396
|
const chunks = tastyClasses.map((className) => ({
|
|
1423
1397
|
className,
|
|
1424
1398
|
chunkName: getChunkForClass(className, root)
|
|
1425
1399
|
}));
|
|
1426
|
-
const css =
|
|
1400
|
+
const css = getCSSTextForNode(element, { root });
|
|
1427
1401
|
const rules = countRules(css);
|
|
1428
1402
|
const result = {
|
|
1429
1403
|
element,
|
|
@@ -1450,9 +1424,9 @@ const tastyDebug = {
|
|
|
1450
1424
|
const activeClasses = findDomTastyClasses(root);
|
|
1451
1425
|
const unusedClasses = getUnusedClasses(root);
|
|
1452
1426
|
const totalStyledClasses = [...activeClasses, ...unusedClasses];
|
|
1453
|
-
const activeCSS = injector.instance.
|
|
1454
|
-
const unusedCSS = injector.instance.
|
|
1455
|
-
const allCSS = injector.instance.
|
|
1427
|
+
const activeCSS = injector.instance.getCSSTextForClasses(activeClasses, { root });
|
|
1428
|
+
const unusedCSS = injector.instance.getCSSTextForClasses(unusedClasses, { root });
|
|
1429
|
+
const allCSS = injector.instance.getCSSText({ root });
|
|
1456
1430
|
const activeRuleCount = countRules(activeCSS);
|
|
1457
1431
|
const unusedRuleCount = countRules(unusedCSS);
|
|
1458
1432
|
const globalData = getGlobalTypeCSS("global", root);
|
|
@@ -1587,6 +1561,6 @@ function getPageCSS(root = document) {
|
|
|
1587
1561
|
}
|
|
1588
1562
|
if (typeof window !== "undefined" && isDevEnv()) tastyDebug.install();
|
|
1589
1563
|
//#endregion
|
|
1590
|
-
export { property as A,
|
|
1564
|
+
export { property as A, getRawCSSText as C, injector as D, injectRawCSS as E, ChunkSheetRegistry as M, chunkSheetRegistry as N, isPropertyDefined as O, resolveFunctionColor as P, getCSSTextForNode as S, injectGlobal as T, destroy as _, color as a, gc as b, hasKeys as c, collectAutoInferredPropertiesRSC as d, getStyleTarget as f, createInjector as g, counterStyle as h, _modAttrs as i, touch as j, keyframes as k, formatKeyframesCSS as l, cleanup as m, processTokens as n, filterBaseProps as o, pushRSCCSS as p, dotize as r, computeStyles as s, tastyDebug as t, collectAutoInferredProperties as u, fontFace as v, inject as w, getCSSText as x, func as y };
|
|
1591
1565
|
|
|
1592
|
-
//# sourceMappingURL=core-
|
|
1566
|
+
//# sourceMappingURL=core-Dr4u1NVD.js.map
|