@tenphi/tasty 0.0.0-snapshot.d656d18 → 0.0.0-snapshot.d720187
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{babel-_RVkw0iE.d.ts → babel-D6lOuSwk.d.ts} +2 -2
- package/dist/chunks/{collector-DBGcmUEq.js → collector-BVzrXWil.js} +4 -3
- package/dist/chunks/{collector-DBGcmUEq.js.map → collector-BVzrXWil.js.map} +1 -1
- package/dist/chunks/config-engine-7nX85gCT.js +403 -0
- package/dist/chunks/config-engine-7nX85gCT.js.map +1 -0
- package/dist/chunks/css-definitions-CfXdhJ-p.js +1194 -0
- package/dist/chunks/css-definitions-CfXdhJ-p.js.map +1 -0
- package/dist/chunks/{debug-BUwqo6vC.js → debug-DpMV1J0r.js} +4 -3
- package/dist/chunks/{debug-BUwqo6vC.js.map → debug-DpMV1J0r.js.map} +1 -1
- package/dist/chunks/hydration-CLdVKcH2.js +59 -0
- package/dist/chunks/hydration-CLdVKcH2.js.map +1 -0
- package/dist/chunks/{react-runtime-B3CmvDEQ.js → react-runtime-C5_xOQFf.js} +4 -3
- package/dist/chunks/{react-runtime-B3CmvDEQ.js.map → react-runtime-C5_xOQFf.js.map} +1 -1
- package/dist/chunks/{runtime-engine-Y00VWjrS.js → runtime-engine-BfqCASPn.js} +17 -1601
- package/dist/chunks/runtime-engine-BfqCASPn.js.map +1 -0
- package/dist/chunks/{style-engine-CqSmIlud.js → style-engine-CBuOt1e4.js} +192 -174
- package/dist/chunks/style-engine-CBuOt1e4.js.map +1 -0
- package/dist/chunks/{css-writer-PFzrSPeu.js → zero-engine-CJR3ZKcW.js} +3 -3
- package/dist/chunks/zero-engine-CJR3ZKcW.js.map +1 -0
- package/dist/{config-BI0y21JV.d.ts → config-BWYrv_Aa.d.ts} +4 -4
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +6 -4
- package/dist/{index-CrT0bsiI.d.ts → index-C5tyPTer.d.ts} +3 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -4
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +2 -2
- package/dist/ssr/index.d.ts +5 -5
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +2 -2
- package/dist/ssr/next.js +4 -4
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +63 -23
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/package.json +9 -3
- package/dist/chunks/css-writer-PFzrSPeu.js.map +0 -1
- package/dist/chunks/hydrate-6YoHZP6A.js +0 -37
- package/dist/chunks/hydrate-6YoHZP6A.js.map +0 -1
- package/dist/chunks/runtime-engine-Y00VWjrS.js.map +0 -1
- package/dist/chunks/style-engine-CqSmIlud.js.map +0 -1
|
@@ -2,11 +2,13 @@ import { E as makeEmptyDetails, M as normalizeDslName, N as toSnakeCase, P as CS
|
|
|
2
2
|
import { a as warnOnceDev, i as warn, n as isSelector, o as isDevEnv } from "./shared-utils-OIg0N_dp.js";
|
|
3
3
|
//#region src/config-state.ts
|
|
4
4
|
/**
|
|
5
|
-
* Minimal configuration
|
|
6
|
-
* configuration module. Keeping it independent
|
|
7
|
-
* from importing the full injector
|
|
5
|
+
* Minimal configuration state shared by the style engine, zero-runtime
|
|
6
|
+
* extractor, and runtime configuration module. Keeping it independent
|
|
7
|
+
* prevents pure rendering code from importing the full injector graph.
|
|
8
8
|
*/
|
|
9
9
|
let stylesGenerated = false;
|
|
10
|
+
let globalPolyfills = null;
|
|
11
|
+
const GTKEY_POLYFILLS = "__tasty_cfg_polyfills__";
|
|
10
12
|
function hasStylesGenerated() {
|
|
11
13
|
return stylesGenerated;
|
|
12
14
|
}
|
|
@@ -19,6 +21,188 @@ function markStylesGeneratedState() {
|
|
|
19
21
|
function resetStylesGeneratedState() {
|
|
20
22
|
stylesGenerated = false;
|
|
21
23
|
}
|
|
24
|
+
/** Whether the CSS `@function` inline-expansion polyfill is enabled. */
|
|
25
|
+
function isFunctionsPolyfillEnabled() {
|
|
26
|
+
const shared = globalThis[GTKEY_POLYFILLS];
|
|
27
|
+
return (globalPolyfills ?? shared)?.functions === true;
|
|
28
|
+
}
|
|
29
|
+
function setGlobalPolyfillsState(polyfills) {
|
|
30
|
+
globalPolyfills = {
|
|
31
|
+
...globalPolyfills ?? {},
|
|
32
|
+
...polyfills
|
|
33
|
+
};
|
|
34
|
+
globalThis[GTKEY_POLYFILLS] = globalPolyfills;
|
|
35
|
+
}
|
|
36
|
+
function resetGlobalPolyfillsState() {
|
|
37
|
+
globalPolyfills = null;
|
|
38
|
+
delete globalThis[GTKEY_POLYFILLS];
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/states/index.ts
|
|
42
|
+
/**
|
|
43
|
+
* Advanced State Mapping - Predefined States Management
|
|
44
|
+
*
|
|
45
|
+
* This module handles global and local predefined states for the Tasty styling system.
|
|
46
|
+
* See ADVANCED_STATE_MAPPING.md for full specification.
|
|
47
|
+
*/
|
|
48
|
+
const BUILTIN_STATES = new Set([
|
|
49
|
+
"@starting",
|
|
50
|
+
"@keyframes",
|
|
51
|
+
"@property",
|
|
52
|
+
"@font-face",
|
|
53
|
+
"@counter-style",
|
|
54
|
+
"@function",
|
|
55
|
+
"@supports",
|
|
56
|
+
"@inherit"
|
|
57
|
+
]);
|
|
58
|
+
let globalPredefinedStates = {};
|
|
59
|
+
const emittedWarnings = /* @__PURE__ */ new Set();
|
|
60
|
+
const devMode$1 = isDevEnv();
|
|
61
|
+
/**
|
|
62
|
+
* Emit a warning only once
|
|
63
|
+
*/
|
|
64
|
+
function warnOnce(key, message) {
|
|
65
|
+
if (devMode$1 && !emittedWarnings.has(key)) {
|
|
66
|
+
emittedWarnings.add(key);
|
|
67
|
+
console.warn(message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Configure global predefined states
|
|
72
|
+
*/
|
|
73
|
+
function setGlobalPredefinedStates(states) {
|
|
74
|
+
if (hasStylesGenerated()) {
|
|
75
|
+
const newStateNames = Object.keys(states).join(", ");
|
|
76
|
+
warnOnce(`dynamic-states:${newStateNames}`, `[Tasty] Cannot update predefined states after styles have been generated.\nThe new definition(s) for ${newStateNames} will be ignored.`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
for (const [name, value] of Object.entries(states)) {
|
|
80
|
+
if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(name)) {
|
|
81
|
+
warnOnce(`invalid-state-name:${name}`, `[Tasty] Invalid predefined state name '${name}'. Must start with '@' followed by a letter.`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (BUILTIN_STATES.has(name)) {
|
|
85
|
+
warnOnce(`reserved-state:${name}`, `[Tasty] Cannot define predefined state '${name}'. This name is reserved for built-in functionality.`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (name === "@media" || name === "@root" || name === "@parent" || name === "@own" || name.startsWith("@(")) {
|
|
89
|
+
warnOnce(`reserved-prefix:${name}`, `[Tasty] Cannot define predefined state '${name}'. This prefix is reserved for built-in functionality.`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const crossRefs = extractPredefinedStateRefs(value);
|
|
93
|
+
if (crossRefs.length > 0) {
|
|
94
|
+
warnOnce(`cross-ref:${name}`, `[Tasty] Predefined state '${name}' references another predefined state '${crossRefs[0]}'.\nPredefined states cannot reference each other. Use the full definition instead.`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (globalPredefinedStates[name] && globalPredefinedStates[name] !== value) warnOnce(`duplicate-state:${name}`, `[Tasty] Duplicate predefined state '${name}' in configure(). The last definition will be used.`);
|
|
98
|
+
globalPredefinedStates[name] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get global predefined states
|
|
103
|
+
*/
|
|
104
|
+
function getGlobalPredefinedStates() {
|
|
105
|
+
return globalPredefinedStates;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Regex to match predefined state references in a string
|
|
109
|
+
* Matches @name that is NOT followed by ( or : and is a complete word
|
|
110
|
+
* Uses word boundary and negative lookahead
|
|
111
|
+
*/
|
|
112
|
+
const PREDEFINED_STATE_PATTERN = /@([A-Za-z][A-Za-z0-9-]*)(?![A-Za-z0-9-:(])/g;
|
|
113
|
+
/**
|
|
114
|
+
* Extract predefined state references from a string
|
|
115
|
+
*/
|
|
116
|
+
function extractPredefinedStateRefs(value) {
|
|
117
|
+
const matches = value.matchAll(PREDEFINED_STATE_PATTERN);
|
|
118
|
+
const refs = [];
|
|
119
|
+
for (const match of matches) {
|
|
120
|
+
const stateName = "@" + match[1];
|
|
121
|
+
if (!BUILTIN_STATES.has(stateName) && !refs.includes(stateName)) refs.push(stateName);
|
|
122
|
+
}
|
|
123
|
+
return refs;
|
|
124
|
+
}
|
|
125
|
+
const _localStatesCache = /* @__PURE__ */ new WeakMap();
|
|
126
|
+
/**
|
|
127
|
+
* Extract local predefined states from a styles object
|
|
128
|
+
* Local predefined states are top-level keys starting with @ that have string values
|
|
129
|
+
* and are valid predefined state names (not built-in like @media, @root, etc.)
|
|
130
|
+
*
|
|
131
|
+
* Results are cached by object identity via WeakMap since the same styles object
|
|
132
|
+
* is passed to this function multiple times per pipeline run (once per chunk
|
|
133
|
+
* in renderStylesForChunk and generateChunkCacheKey).
|
|
134
|
+
*/
|
|
135
|
+
function extractLocalPredefinedStates(styles) {
|
|
136
|
+
if (!styles || typeof styles !== "object") return {};
|
|
137
|
+
const cached = _localStatesCache.get(styles);
|
|
138
|
+
if (cached !== void 0) return cached;
|
|
139
|
+
const localStates = {};
|
|
140
|
+
for (const [key, value] of Object.entries(styles)) if (key.startsWith("@") && typeof value === "string") {
|
|
141
|
+
if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(key)) continue;
|
|
142
|
+
if (BUILTIN_STATES.has(key)) continue;
|
|
143
|
+
if (key === "@media" || key === "@root" || key === "@parent" || key === "@own" || key.startsWith("@(")) continue;
|
|
144
|
+
const crossRefs = extractPredefinedStateRefs(value);
|
|
145
|
+
if (crossRefs.length > 0) {
|
|
146
|
+
warnOnce(`local-cross-ref:${key}`, `[Tasty] Predefined state '${key}' references another predefined state '${crossRefs[0]}'.\nPredefined states cannot reference each other. Use the full definition instead.`);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
localStates[key] = value;
|
|
150
|
+
}
|
|
151
|
+
_localStatesCache.set(styles, localStates);
|
|
152
|
+
return localStates;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create a state parser context from styles
|
|
156
|
+
*/
|
|
157
|
+
function createStateParserContext(styles, isSubElement) {
|
|
158
|
+
return {
|
|
159
|
+
localPredefinedStates: styles ? extractLocalPredefinedStates(styles) : {},
|
|
160
|
+
globalPredefinedStates: getGlobalPredefinedStates(),
|
|
161
|
+
isSubElement
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolve a predefined state reference to its value
|
|
166
|
+
* Returns the resolved value or null if not found
|
|
167
|
+
*/
|
|
168
|
+
function resolvePredefinedState(stateKey, ctx) {
|
|
169
|
+
if (ctx.localPredefinedStates[stateKey]) return ctx.localPredefinedStates[stateKey];
|
|
170
|
+
if (ctx.globalPredefinedStates[stateKey]) return ctx.globalPredefinedStates[stateKey];
|
|
171
|
+
warnOnce(`undefined-state:${stateKey}`, `[Tasty] Undefined predefined state '${stateKey}'.\nDefine it in configure({ states: { '${stateKey}': '...' } }) or in the component's styles.`);
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Expand dimension shorthands in a condition string
|
|
176
|
+
* w -> width, h -> height, is -> inline-size, bs -> block-size
|
|
177
|
+
*/
|
|
178
|
+
function expandDimensionShorthands(condition) {
|
|
179
|
+
let result = condition;
|
|
180
|
+
result = result.replace(/\bw\b/g, "width");
|
|
181
|
+
result = result.replace(/\bh\b/g, "height");
|
|
182
|
+
result = result.replace(/\bis\b/g, "inline-size");
|
|
183
|
+
result = result.replace(/\bbs\b/g, "block-size");
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Convert tasty units in a string (e.g., 40x -> calc(var(--gap) * 40))
|
|
188
|
+
*/
|
|
189
|
+
function expandTastyUnits(value) {
|
|
190
|
+
return value.replace(/(\d+(?:\.\d+)?)\s*x\b/g, (_, num) => {
|
|
191
|
+
return `calc(var(--gap) * ${num})`;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Find the index of the first comma at parentheses depth 0.
|
|
196
|
+
* Returns -1 if no top-level comma is found.
|
|
197
|
+
* This prevents splitting on commas inside function calls like scroll-state(a, b).
|
|
198
|
+
*/
|
|
199
|
+
function findTopLevelComma(s) {
|
|
200
|
+
let depth = 0;
|
|
201
|
+
for (let i = 0; i < s.length; i++) if (s[i] === "(") depth++;
|
|
202
|
+
else if (s[i] === ")") depth--;
|
|
203
|
+
else if (s[i] === "," && depth === 0) return i;
|
|
204
|
+
return -1;
|
|
205
|
+
}
|
|
22
206
|
//#endregion
|
|
23
207
|
//#region src/styles/logical-list.ts
|
|
24
208
|
/** Data-only logical style families shared by handlers, public lists, and chunks. */
|
|
@@ -1912,7 +2096,7 @@ widthStyle.__lookupStyles = [
|
|
|
1912
2096
|
];
|
|
1913
2097
|
//#endregion
|
|
1914
2098
|
//#region src/styles/predefined.ts
|
|
1915
|
-
const devMode
|
|
2099
|
+
const devMode = isDevEnv();
|
|
1916
2100
|
/**
|
|
1917
2101
|
* Dev-mode check evaluated per call rather than at module load.
|
|
1918
2102
|
*
|
|
@@ -2056,7 +2240,7 @@ function normalizeHandlerDefinition(keyName, definition) {
|
|
|
2056
2240
|
* Validate a handler definition in development mode.
|
|
2057
2241
|
*/
|
|
2058
2242
|
function validateHandler(name, handler, lookupStyles) {
|
|
2059
|
-
if (!devMode
|
|
2243
|
+
if (!devMode) return;
|
|
2060
2244
|
if (typeof handler !== "function") console.warn(`[Tasty] Handler "${name}" is not a function. Handlers must be functions that return CSSMap, CSSMap[], or null.`);
|
|
2061
2245
|
if (!lookupStyles || !Array.isArray(lookupStyles) || lookupStyles.length === 0) console.warn(`[Tasty] Handler "${name}" has invalid lookupStyles. Expected non-empty array of style names.`);
|
|
2062
2246
|
}
|
|
@@ -2133,7 +2317,7 @@ function warnAboutOrphanedStyles(lookupStyles, handlersToRemove, options) {
|
|
|
2133
2317
|
function registerHandler(handler, options) {
|
|
2134
2318
|
const lookupStyles = handler.__lookupStyles;
|
|
2135
2319
|
if (!lookupStyles || lookupStyles.length === 0) {
|
|
2136
|
-
if (devMode
|
|
2320
|
+
if (devMode) console.warn("[Tasty] Cannot register handler without __lookupStyles property.");
|
|
2137
2321
|
return;
|
|
2138
2322
|
}
|
|
2139
2323
|
alignHandlerChunks(lookupStyles, options);
|
|
@@ -2260,172 +2444,6 @@ function defineHandler(deps, handler) {
|
|
|
2260
2444
|
//#region src/styles/index.ts
|
|
2261
2445
|
const { STYLE_HANDLER_MAP } = predefine();
|
|
2262
2446
|
//#endregion
|
|
2263
|
-
//#region src/states/index.ts
|
|
2264
|
-
/**
|
|
2265
|
-
* Advanced State Mapping - Predefined States Management
|
|
2266
|
-
*
|
|
2267
|
-
* This module handles global and local predefined states for the Tasty styling system.
|
|
2268
|
-
* See ADVANCED_STATE_MAPPING.md for full specification.
|
|
2269
|
-
*/
|
|
2270
|
-
const BUILTIN_STATES = new Set([
|
|
2271
|
-
"@starting",
|
|
2272
|
-
"@keyframes",
|
|
2273
|
-
"@property",
|
|
2274
|
-
"@font-face",
|
|
2275
|
-
"@counter-style",
|
|
2276
|
-
"@function",
|
|
2277
|
-
"@supports",
|
|
2278
|
-
"@inherit"
|
|
2279
|
-
]);
|
|
2280
|
-
let globalPredefinedStates = {};
|
|
2281
|
-
const emittedWarnings = /* @__PURE__ */ new Set();
|
|
2282
|
-
const devMode = isDevEnv();
|
|
2283
|
-
/**
|
|
2284
|
-
* Emit a warning only once
|
|
2285
|
-
*/
|
|
2286
|
-
function warnOnce(key, message) {
|
|
2287
|
-
if (devMode && !emittedWarnings.has(key)) {
|
|
2288
|
-
emittedWarnings.add(key);
|
|
2289
|
-
console.warn(message);
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
/**
|
|
2293
|
-
* Configure global predefined states
|
|
2294
|
-
*/
|
|
2295
|
-
function setGlobalPredefinedStates(states) {
|
|
2296
|
-
if (hasStylesGenerated()) {
|
|
2297
|
-
const newStateNames = Object.keys(states).join(", ");
|
|
2298
|
-
warnOnce(`dynamic-states:${newStateNames}`, `[Tasty] Cannot update predefined states after styles have been generated.\nThe new definition(s) for ${newStateNames} will be ignored.`);
|
|
2299
|
-
return;
|
|
2300
|
-
}
|
|
2301
|
-
for (const [name, value] of Object.entries(states)) {
|
|
2302
|
-
if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(name)) {
|
|
2303
|
-
warnOnce(`invalid-state-name:${name}`, `[Tasty] Invalid predefined state name '${name}'. Must start with '@' followed by a letter.`);
|
|
2304
|
-
continue;
|
|
2305
|
-
}
|
|
2306
|
-
if (BUILTIN_STATES.has(name)) {
|
|
2307
|
-
warnOnce(`reserved-state:${name}`, `[Tasty] Cannot define predefined state '${name}'. This name is reserved for built-in functionality.`);
|
|
2308
|
-
continue;
|
|
2309
|
-
}
|
|
2310
|
-
if (name === "@media" || name === "@root" || name === "@parent" || name === "@own" || name.startsWith("@(")) {
|
|
2311
|
-
warnOnce(`reserved-prefix:${name}`, `[Tasty] Cannot define predefined state '${name}'. This prefix is reserved for built-in functionality.`);
|
|
2312
|
-
continue;
|
|
2313
|
-
}
|
|
2314
|
-
const crossRefs = extractPredefinedStateRefs(value);
|
|
2315
|
-
if (crossRefs.length > 0) {
|
|
2316
|
-
warnOnce(`cross-ref:${name}`, `[Tasty] Predefined state '${name}' references another predefined state '${crossRefs[0]}'.\nPredefined states cannot reference each other. Use the full definition instead.`);
|
|
2317
|
-
continue;
|
|
2318
|
-
}
|
|
2319
|
-
if (globalPredefinedStates[name] && globalPredefinedStates[name] !== value) warnOnce(`duplicate-state:${name}`, `[Tasty] Duplicate predefined state '${name}' in configure(). The last definition will be used.`);
|
|
2320
|
-
globalPredefinedStates[name] = value;
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
/**
|
|
2324
|
-
* Get global predefined states
|
|
2325
|
-
*/
|
|
2326
|
-
function getGlobalPredefinedStates() {
|
|
2327
|
-
return globalPredefinedStates;
|
|
2328
|
-
}
|
|
2329
|
-
/**
|
|
2330
|
-
* Regex to match predefined state references in a string
|
|
2331
|
-
* Matches @name that is NOT followed by ( or : and is a complete word
|
|
2332
|
-
* Uses word boundary and negative lookahead
|
|
2333
|
-
*/
|
|
2334
|
-
const PREDEFINED_STATE_PATTERN = /@([A-Za-z][A-Za-z0-9-]*)(?![A-Za-z0-9-:(])/g;
|
|
2335
|
-
/**
|
|
2336
|
-
* Extract predefined state references from a string
|
|
2337
|
-
*/
|
|
2338
|
-
function extractPredefinedStateRefs(value) {
|
|
2339
|
-
const matches = value.matchAll(PREDEFINED_STATE_PATTERN);
|
|
2340
|
-
const refs = [];
|
|
2341
|
-
for (const match of matches) {
|
|
2342
|
-
const stateName = "@" + match[1];
|
|
2343
|
-
if (!BUILTIN_STATES.has(stateName) && !refs.includes(stateName)) refs.push(stateName);
|
|
2344
|
-
}
|
|
2345
|
-
return refs;
|
|
2346
|
-
}
|
|
2347
|
-
const _localStatesCache = /* @__PURE__ */ new WeakMap();
|
|
2348
|
-
/**
|
|
2349
|
-
* Extract local predefined states from a styles object
|
|
2350
|
-
* Local predefined states are top-level keys starting with @ that have string values
|
|
2351
|
-
* and are valid predefined state names (not built-in like @media, @root, etc.)
|
|
2352
|
-
*
|
|
2353
|
-
* Results are cached by object identity via WeakMap since the same styles object
|
|
2354
|
-
* is passed to this function multiple times per pipeline run (once per chunk
|
|
2355
|
-
* in renderStylesForChunk and generateChunkCacheKey).
|
|
2356
|
-
*/
|
|
2357
|
-
function extractLocalPredefinedStates(styles) {
|
|
2358
|
-
if (!styles || typeof styles !== "object") return {};
|
|
2359
|
-
const cached = _localStatesCache.get(styles);
|
|
2360
|
-
if (cached !== void 0) return cached;
|
|
2361
|
-
const localStates = {};
|
|
2362
|
-
for (const [key, value] of Object.entries(styles)) if (key.startsWith("@") && typeof value === "string") {
|
|
2363
|
-
if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(key)) continue;
|
|
2364
|
-
if (BUILTIN_STATES.has(key)) continue;
|
|
2365
|
-
if (key === "@media" || key === "@root" || key === "@parent" || key === "@own" || key.startsWith("@(")) continue;
|
|
2366
|
-
const crossRefs = extractPredefinedStateRefs(value);
|
|
2367
|
-
if (crossRefs.length > 0) {
|
|
2368
|
-
warnOnce(`local-cross-ref:${key}`, `[Tasty] Predefined state '${key}' references another predefined state '${crossRefs[0]}'.\nPredefined states cannot reference each other. Use the full definition instead.`);
|
|
2369
|
-
continue;
|
|
2370
|
-
}
|
|
2371
|
-
localStates[key] = value;
|
|
2372
|
-
}
|
|
2373
|
-
_localStatesCache.set(styles, localStates);
|
|
2374
|
-
return localStates;
|
|
2375
|
-
}
|
|
2376
|
-
/**
|
|
2377
|
-
* Create a state parser context from styles
|
|
2378
|
-
*/
|
|
2379
|
-
function createStateParserContext(styles, isSubElement) {
|
|
2380
|
-
return {
|
|
2381
|
-
localPredefinedStates: styles ? extractLocalPredefinedStates(styles) : {},
|
|
2382
|
-
globalPredefinedStates: getGlobalPredefinedStates(),
|
|
2383
|
-
isSubElement
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
|
-
/**
|
|
2387
|
-
* Resolve a predefined state reference to its value
|
|
2388
|
-
* Returns the resolved value or null if not found
|
|
2389
|
-
*/
|
|
2390
|
-
function resolvePredefinedState(stateKey, ctx) {
|
|
2391
|
-
if (ctx.localPredefinedStates[stateKey]) return ctx.localPredefinedStates[stateKey];
|
|
2392
|
-
if (ctx.globalPredefinedStates[stateKey]) return ctx.globalPredefinedStates[stateKey];
|
|
2393
|
-
warnOnce(`undefined-state:${stateKey}`, `[Tasty] Undefined predefined state '${stateKey}'.\nDefine it in configure({ states: { '${stateKey}': '...' } }) or in the component's styles.`);
|
|
2394
|
-
return null;
|
|
2395
|
-
}
|
|
2396
|
-
/**
|
|
2397
|
-
* Expand dimension shorthands in a condition string
|
|
2398
|
-
* w -> width, h -> height, is -> inline-size, bs -> block-size
|
|
2399
|
-
*/
|
|
2400
|
-
function expandDimensionShorthands(condition) {
|
|
2401
|
-
let result = condition;
|
|
2402
|
-
result = result.replace(/\bw\b/g, "width");
|
|
2403
|
-
result = result.replace(/\bh\b/g, "height");
|
|
2404
|
-
result = result.replace(/\bis\b/g, "inline-size");
|
|
2405
|
-
result = result.replace(/\bbs\b/g, "block-size");
|
|
2406
|
-
return result;
|
|
2407
|
-
}
|
|
2408
|
-
/**
|
|
2409
|
-
* Convert tasty units in a string (e.g., 40x -> calc(var(--gap) * 40))
|
|
2410
|
-
*/
|
|
2411
|
-
function expandTastyUnits(value) {
|
|
2412
|
-
return value.replace(/(\d+(?:\.\d+)?)\s*x\b/g, (_, num) => {
|
|
2413
|
-
return `calc(var(--gap) * ${num})`;
|
|
2414
|
-
});
|
|
2415
|
-
}
|
|
2416
|
-
/**
|
|
2417
|
-
* Find the index of the first comma at parentheses depth 0.
|
|
2418
|
-
* Returns -1 if no top-level comma is found.
|
|
2419
|
-
* This prevents splitting on commas inside function calls like scroll-state(a, b).
|
|
2420
|
-
*/
|
|
2421
|
-
function findTopLevelComma(s) {
|
|
2422
|
-
let depth = 0;
|
|
2423
|
-
for (let i = 0; i < s.length; i++) if (s[i] === "(") depth++;
|
|
2424
|
-
else if (s[i] === ")") depth--;
|
|
2425
|
-
else if (s[i] === "," && depth === 0) return i;
|
|
2426
|
-
return -1;
|
|
2427
|
-
}
|
|
2428
|
-
//#endregion
|
|
2429
2447
|
//#region src/pipeline/conditions.ts
|
|
2430
2448
|
/**
|
|
2431
2449
|
* Create a TRUE condition (matches everything)
|
|
@@ -7191,6 +7209,6 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
|
|
|
7191
7209
|
return renderStyles(chunkName === CHUNK_NAMES.SUBCOMPONENTS ? buildSubcomponentFilteredStyles(styles, styleKeys) : buildFilteredStyles(styles, styleKeys), void 0, void 0, pipelineCacheKey);
|
|
7192
7210
|
}
|
|
7193
7211
|
//#endregion
|
|
7194
|
-
export {
|
|
7212
|
+
export { APPEARANCE_CHUNK_STYLES as A, getGlobalPredefinedStates as B, STYLE_HANDLER_MAP as C, resetHandlers as D, registerHandler as E, LAYOUT_CHUNK_STYLES as F, resetGlobalPolyfillsState as G, hasStylesGenerated as H, POSITION_CHUNK_STYLES as I, resetStylesGeneratedState as K, STYLE_TO_CHUNK as L, DIMENSION_CHUNK_STYLES as M, DISPLAY_CHUNK_STYLES as N, styleHandlers as O, FONT_CHUNK_STYLES as P, resetStyleChunks as R, camelToKebab as S, normalizeHandlerDefinition as T, isFunctionsPolyfillEnabled as U, setGlobalPredefinedStates as V, markStylesGeneratedState as W, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, CHUNK_NAMES as j, createStyle as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, setGlobalPolyfillsState as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, defineHandler as w, parseStateKey as x, clearPipelineCache as y, createStateParserContext as z };
|
|
7195
7213
|
|
|
7196
|
-
//# sourceMappingURL=style-engine-
|
|
7214
|
+
//# sourceMappingURL=style-engine-CBuOt1e4.js.map
|