chaincss 2.1.29 → 2.1.31
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 +397 -65
- package/dist/browser.js +3398 -0
- package/dist/cli/index.js +312 -375
- package/dist/compiler/btt.d.ts +11 -72
- package/dist/compiler/component-generator.d.ts +10 -0
- package/dist/compiler/index.js +198 -331
- package/dist/compiler/recipe.d.ts +35 -0
- package/dist/compiler/scanner.d.ts +5 -0
- package/dist/compiler/timeline.d.ts +29 -0
- package/dist/index.js +253 -397
- package/dist/plugins/vite.js +110 -186
- package/index.html +41 -0
- package/package.json +8 -7
- package/src/browser.ts +9 -0
- package/src/compiler/btt.ts +126 -901
- package/src/compiler/component-generator.ts +87 -0
- package/src/compiler/recipe.ts +145 -0
- package/src/compiler/scanner.ts +46 -0
- package/src/compiler/timeline.ts +128 -0
package/dist/browser.js
ADDED
|
@@ -0,0 +1,3398 @@
|
|
|
1
|
+
// src/compiler/shorthands.ts
|
|
2
|
+
var shorthandMap = {
|
|
3
|
+
"m": "margin",
|
|
4
|
+
"mt": "marginTop",
|
|
5
|
+
"mr": "marginRight",
|
|
6
|
+
"mb": "marginBottom",
|
|
7
|
+
"ml": "marginLeft",
|
|
8
|
+
"p": "padding",
|
|
9
|
+
"pt": "paddingTop",
|
|
10
|
+
"pr": "paddingRight",
|
|
11
|
+
"pb": "paddingBottom",
|
|
12
|
+
"pl": "paddingLeft",
|
|
13
|
+
"z": "zIndex",
|
|
14
|
+
"op": "opacity",
|
|
15
|
+
"ov": "overflow",
|
|
16
|
+
"ovx": "overflowX",
|
|
17
|
+
"ovy": "overflowY",
|
|
18
|
+
"objFit": "objectFit",
|
|
19
|
+
"objPos": "objectPosition",
|
|
20
|
+
"d": "display",
|
|
21
|
+
"pos": "position",
|
|
22
|
+
"w": "width",
|
|
23
|
+
"h": "height",
|
|
24
|
+
"minW": "minWidth",
|
|
25
|
+
"maxW": "maxWidth",
|
|
26
|
+
"minH": "minHeight",
|
|
27
|
+
"maxH": "maxHeight",
|
|
28
|
+
"bg": "backgroundColor",
|
|
29
|
+
"bgImg": "backgroundImage",
|
|
30
|
+
"bgPos": "backgroundPosition",
|
|
31
|
+
"bgSize": "backgroundSize",
|
|
32
|
+
"c": "color",
|
|
33
|
+
"flexDir": "flexDirection",
|
|
34
|
+
"flexWrap": "flexWrap",
|
|
35
|
+
"justify": "justifyContent",
|
|
36
|
+
"items": "alignItems",
|
|
37
|
+
"self": "alignSelf",
|
|
38
|
+
"content": "alignContent",
|
|
39
|
+
"gap": "gap",
|
|
40
|
+
"gapX": "columnGap",
|
|
41
|
+
"gapY": "rowGap",
|
|
42
|
+
"grow": "flexGrow",
|
|
43
|
+
"shrink": "flexShrink",
|
|
44
|
+
"basis": "flexBasis",
|
|
45
|
+
"order": "order",
|
|
46
|
+
"gridCols": "gridTemplateColumns",
|
|
47
|
+
"gridRows": "gridTemplateRows",
|
|
48
|
+
"gridRow": "gridRow",
|
|
49
|
+
"gridCol": "gridColumn",
|
|
50
|
+
"rounded": "borderRadius",
|
|
51
|
+
"br": "borderRadius",
|
|
52
|
+
"radius": "borderRadius",
|
|
53
|
+
"roundedTL": "borderTopLeftRadius",
|
|
54
|
+
"roundedTR": "borderTopRightRadius",
|
|
55
|
+
"roundedBR": "borderBottomRightRadius",
|
|
56
|
+
"roundedBL": "borderBottomLeftRadius",
|
|
57
|
+
"border": "border",
|
|
58
|
+
"borderW": "borderWidth",
|
|
59
|
+
"borderC": "borderColor",
|
|
60
|
+
"borderS": "borderStyle",
|
|
61
|
+
"borderT": "borderTop",
|
|
62
|
+
"borderR": "borderRight",
|
|
63
|
+
"borderB": "borderBottom",
|
|
64
|
+
"borderL": "borderLeft",
|
|
65
|
+
"fontF": "fontFamily",
|
|
66
|
+
"text": "color",
|
|
67
|
+
"align": "textAlign",
|
|
68
|
+
"fs": "fontSize",
|
|
69
|
+
"fw": "fontWeight",
|
|
70
|
+
"lh": "lineHeight",
|
|
71
|
+
"ls": "letterSpacing",
|
|
72
|
+
"shadow": "boxShadow",
|
|
73
|
+
"textShadow": "textShadow",
|
|
74
|
+
"transform": "transform",
|
|
75
|
+
"transformOrigin": "transformOrigin",
|
|
76
|
+
"transition": "transition",
|
|
77
|
+
"transitionAll": "transition",
|
|
78
|
+
"cursor": "cursor",
|
|
79
|
+
"pointer": "cursor",
|
|
80
|
+
"resize": "resize",
|
|
81
|
+
"filter": "filter",
|
|
82
|
+
"backdropFilter": "backdropFilter"
|
|
83
|
+
};
|
|
84
|
+
var macros = {
|
|
85
|
+
// --- Spacing & Sizing ---
|
|
86
|
+
mx: (v, c) => {
|
|
87
|
+
const value = typeof v === "number" ? `${v}px` : v;
|
|
88
|
+
c.marginLeft = value;
|
|
89
|
+
c.marginRight = value;
|
|
90
|
+
},
|
|
91
|
+
my: (v, c) => {
|
|
92
|
+
const value = typeof v === "number" ? `${v}px` : v;
|
|
93
|
+
c.marginTop = value;
|
|
94
|
+
c.marginBottom = value;
|
|
95
|
+
},
|
|
96
|
+
px: (v, c) => {
|
|
97
|
+
const value = typeof v === "number" ? `${v}px` : v;
|
|
98
|
+
c.paddingLeft = value;
|
|
99
|
+
c.paddingRight = value;
|
|
100
|
+
},
|
|
101
|
+
py: (v, c) => {
|
|
102
|
+
const value = typeof v === "number" ? `${v}px` : v;
|
|
103
|
+
c.paddingTop = value;
|
|
104
|
+
c.paddingBottom = value;
|
|
105
|
+
},
|
|
106
|
+
size: (v, c) => {
|
|
107
|
+
c.width = v;
|
|
108
|
+
c.height = v;
|
|
109
|
+
},
|
|
110
|
+
inset: (v, c) => {
|
|
111
|
+
if (typeof v === "object") {
|
|
112
|
+
if (v.top !== void 0) c.top = v.top;
|
|
113
|
+
if (v.right !== void 0) c.right = v.right;
|
|
114
|
+
if (v.bottom !== void 0) c.bottom = v.bottom;
|
|
115
|
+
if (v.left !== void 0) c.left = v.left;
|
|
116
|
+
} else {
|
|
117
|
+
c.top = v;
|
|
118
|
+
c.right = v;
|
|
119
|
+
c.bottom = v;
|
|
120
|
+
c.left = v;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
insetX: (v, c) => {
|
|
124
|
+
c.left = v;
|
|
125
|
+
c.right = v;
|
|
126
|
+
},
|
|
127
|
+
insetY: (v, c) => {
|
|
128
|
+
c.top = v;
|
|
129
|
+
c.bottom = v;
|
|
130
|
+
},
|
|
131
|
+
// --- Borders ---
|
|
132
|
+
borderX: (v, c) => {
|
|
133
|
+
c.borderLeft = v;
|
|
134
|
+
c.borderRight = v;
|
|
135
|
+
},
|
|
136
|
+
borderY: (v, c) => {
|
|
137
|
+
c.borderTop = v;
|
|
138
|
+
c.borderBottom = v;
|
|
139
|
+
},
|
|
140
|
+
// --- Layouts & Display ---
|
|
141
|
+
flex: (v, c) => {
|
|
142
|
+
c.display = "flex";
|
|
143
|
+
if (v && v !== true && typeof v === "string") c.flex = v;
|
|
144
|
+
},
|
|
145
|
+
inlineFlex: (v, c) => {
|
|
146
|
+
c.display = "inline-flex";
|
|
147
|
+
},
|
|
148
|
+
grid: (v, c) => {
|
|
149
|
+
c.display = "grid";
|
|
150
|
+
if (v && v !== true && typeof v === "string") c.grid = v;
|
|
151
|
+
},
|
|
152
|
+
inlineGrid: (v, c) => {
|
|
153
|
+
c.display = "inline-grid";
|
|
154
|
+
},
|
|
155
|
+
cols: (v, c) => {
|
|
156
|
+
c.gridTemplateColumns = typeof v === "number" ? `repeat(${v}, minmax(0, 1fr))` : v;
|
|
157
|
+
},
|
|
158
|
+
rows: (v, c) => {
|
|
159
|
+
c.gridTemplateRows = typeof v === "number" ? `repeat(${v}, minmax(0, 1fr))` : v;
|
|
160
|
+
},
|
|
161
|
+
center: (v, c) => {
|
|
162
|
+
c.display = v === "inline" ? "inline-flex" : "flex";
|
|
163
|
+
c.alignItems = "center";
|
|
164
|
+
c.justifyContent = "center";
|
|
165
|
+
},
|
|
166
|
+
flexCenter: (v, c) => {
|
|
167
|
+
c.display = "flex";
|
|
168
|
+
c.alignItems = "center";
|
|
169
|
+
c.justifyContent = "center";
|
|
170
|
+
if (v === "col" || v === "column") c.flexDirection = "column";
|
|
171
|
+
},
|
|
172
|
+
gridCenter: (v, c) => {
|
|
173
|
+
c.display = "grid";
|
|
174
|
+
c.placeItems = "center";
|
|
175
|
+
},
|
|
176
|
+
stack: (v, c) => {
|
|
177
|
+
c.display = "flex";
|
|
178
|
+
if (typeof v === "object") {
|
|
179
|
+
c.flexDirection = v.dir === "row" ? "row" : "column";
|
|
180
|
+
c.gap = v.spacing;
|
|
181
|
+
} else if (v === "row") {
|
|
182
|
+
c.flexDirection = "row";
|
|
183
|
+
c.gap = "1rem";
|
|
184
|
+
} else {
|
|
185
|
+
c.flexDirection = "column";
|
|
186
|
+
c.gap = typeof v === "number" ? `${v}px` : v || "1rem";
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
gridTable: (v, c) => {
|
|
190
|
+
const min = typeof v === "number" ? `${v}px` : v;
|
|
191
|
+
c.display = "grid";
|
|
192
|
+
c.gridTemplateColumns = `repeat(auto-fit, minmax(${min}, 1fr))`;
|
|
193
|
+
},
|
|
194
|
+
// --- Visibility & Behavior ---
|
|
195
|
+
hide: (v, c) => {
|
|
196
|
+
c.opacity = 0;
|
|
197
|
+
c.visibility = "hidden";
|
|
198
|
+
c.pointerEvents = "none";
|
|
199
|
+
},
|
|
200
|
+
show: (v, c) => {
|
|
201
|
+
c.opacity = 1;
|
|
202
|
+
c.visibility = "visible";
|
|
203
|
+
c.pointerEvents = "auto";
|
|
204
|
+
},
|
|
205
|
+
unselectable: (v, c) => {
|
|
206
|
+
c.userSelect = "none";
|
|
207
|
+
c.WebkitUserSelect = "none";
|
|
208
|
+
c.MozUserSelect = "none";
|
|
209
|
+
c.msUserSelect = "none";
|
|
210
|
+
c.cursor = "default";
|
|
211
|
+
},
|
|
212
|
+
scrollable: (v, c) => {
|
|
213
|
+
if (v === "x") {
|
|
214
|
+
c.overflowX = "auto";
|
|
215
|
+
c.overflowY = "hidden";
|
|
216
|
+
} else if (v === "y") {
|
|
217
|
+
c.overflowX = "hidden";
|
|
218
|
+
c.overflowY = "auto";
|
|
219
|
+
} else if (v === "both") {
|
|
220
|
+
c.overflow = "auto";
|
|
221
|
+
} else {
|
|
222
|
+
c.overflow = "auto";
|
|
223
|
+
}
|
|
224
|
+
c.WebkitOverflowScrolling = "touch";
|
|
225
|
+
},
|
|
226
|
+
// --- Positioning ---
|
|
227
|
+
absolute: (v, c) => handlePosition("absolute", v, c),
|
|
228
|
+
fixed: (v, c) => handlePosition("fixed", v, c),
|
|
229
|
+
sticky: (v, c) => handlePosition("sticky", v, c),
|
|
230
|
+
relative: (v, c) => handlePosition("relative", v, c),
|
|
231
|
+
// --- Shapes & Content ---
|
|
232
|
+
circle: (v, c) => {
|
|
233
|
+
c.width = v;
|
|
234
|
+
c.height = v;
|
|
235
|
+
c.borderRadius = "50%";
|
|
236
|
+
c.display = "flex";
|
|
237
|
+
c.alignItems = "center";
|
|
238
|
+
c.justifyContent = "center";
|
|
239
|
+
},
|
|
240
|
+
square: (v, c) => {
|
|
241
|
+
c.width = v;
|
|
242
|
+
c.height = v;
|
|
243
|
+
c.display = "flex";
|
|
244
|
+
c.alignItems = "center";
|
|
245
|
+
c.justifyContent = "center";
|
|
246
|
+
},
|
|
247
|
+
truncate: (v, c) => {
|
|
248
|
+
c.overflow = "hidden";
|
|
249
|
+
c.textOverflow = "ellipsis";
|
|
250
|
+
c.whiteSpace = "nowrap";
|
|
251
|
+
},
|
|
252
|
+
aspect: (v, c) => {
|
|
253
|
+
const map = {
|
|
254
|
+
square: "1 / 1",
|
|
255
|
+
video: "16 / 9",
|
|
256
|
+
golden: "1.618 / 1",
|
|
257
|
+
portrait: "3 / 4",
|
|
258
|
+
landscape: "4 / 3"
|
|
259
|
+
};
|
|
260
|
+
c.aspectRatio = map[v] || v;
|
|
261
|
+
},
|
|
262
|
+
// --- Aesthetic Effects ---
|
|
263
|
+
glass: (v, c) => {
|
|
264
|
+
const blur = typeof v === "number" ? `${v}px` : v || "10px";
|
|
265
|
+
c.backdropFilter = `blur(${blur})`;
|
|
266
|
+
c.WebkitBackdropFilter = `blur(${blur})`;
|
|
267
|
+
c.backgroundColor = "rgba(255, 255, 255, 0.1)";
|
|
268
|
+
c.border = "1px solid rgba(255, 255, 255, 0.2)";
|
|
269
|
+
},
|
|
270
|
+
glow: (v, c) => {
|
|
271
|
+
let color;
|
|
272
|
+
let size;
|
|
273
|
+
if (typeof v === "string") {
|
|
274
|
+
color = v;
|
|
275
|
+
size = 20;
|
|
276
|
+
} else {
|
|
277
|
+
color = v.color || "rgba(255,255,255,0.5)";
|
|
278
|
+
size = v.size || 20;
|
|
279
|
+
}
|
|
280
|
+
c.boxShadow = `0 0 ${size / 4}px ${color}, 0 0 ${size / 2}px ${color}, 0 0 ${size}px ${color}`;
|
|
281
|
+
},
|
|
282
|
+
textGradient: (v, c) => {
|
|
283
|
+
let colors;
|
|
284
|
+
let angle;
|
|
285
|
+
if (Array.isArray(v)) {
|
|
286
|
+
colors = v;
|
|
287
|
+
angle = 90;
|
|
288
|
+
} else {
|
|
289
|
+
colors = v.colors;
|
|
290
|
+
angle = v.angle || 90;
|
|
291
|
+
}
|
|
292
|
+
c.backgroundImage = `linear-gradient(${angle}deg, ${colors.join(", ")})`;
|
|
293
|
+
c.WebkitBackgroundClip = "text";
|
|
294
|
+
c.backgroundClip = "text";
|
|
295
|
+
c.WebkitTextFillColor = "transparent";
|
|
296
|
+
c.color = "transparent";
|
|
297
|
+
c.display = "inline-block";
|
|
298
|
+
},
|
|
299
|
+
meshGradient: (v, c) => {
|
|
300
|
+
const [c1, c2, c3, c4] = Array.isArray(v) ? v : [v[0], v[1], v[2], v[3]];
|
|
301
|
+
c.backgroundColor = c1;
|
|
302
|
+
c.backgroundImage = `radial-gradient(at 0% 0%, ${c2} 0px, transparent 50%), radial-gradient(at 100% 0%, ${c3} 0px, transparent 50%), radial-gradient(at 100% 100%, ${c4} 0px, transparent 50%)`;
|
|
303
|
+
},
|
|
304
|
+
noise: (v, c) => {
|
|
305
|
+
const op = typeof v === "number" ? v : 0.05;
|
|
306
|
+
c.backgroundImage = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='${op}'/%3E%3C/svg%3E")`;
|
|
307
|
+
},
|
|
308
|
+
// --- Logic & Responsive ---
|
|
309
|
+
skeleton: (v, c) => {
|
|
310
|
+
let active;
|
|
311
|
+
let baseColor;
|
|
312
|
+
let highlightColor;
|
|
313
|
+
if (typeof v === "boolean") {
|
|
314
|
+
active = v;
|
|
315
|
+
baseColor = "rgba(0,0,0,0.1)";
|
|
316
|
+
highlightColor = "rgba(0,0,0,0.05)";
|
|
317
|
+
} else {
|
|
318
|
+
active = v.active;
|
|
319
|
+
baseColor = v.color || "rgba(0,0,0,0.1)";
|
|
320
|
+
highlightColor = v.highlight || "rgba(0,0,0,0.05)";
|
|
321
|
+
}
|
|
322
|
+
if (!active) return;
|
|
323
|
+
c.backgroundColor = baseColor;
|
|
324
|
+
c.backgroundImage = `linear-gradient(90deg, ${baseColor} 25%, ${highlightColor} 50%, ${baseColor} 75%)`;
|
|
325
|
+
c.backgroundSize = "200% 100%";
|
|
326
|
+
c.animation = "skeleton-loading 1.5s infinite linear";
|
|
327
|
+
if (!c.atRules) c.atRules = [];
|
|
328
|
+
c.atRules.push({
|
|
329
|
+
type: "keyframes",
|
|
330
|
+
name: "skeleton-loading",
|
|
331
|
+
steps: {
|
|
332
|
+
"0%": { backgroundPosition: "200% 0" },
|
|
333
|
+
"100%": { backgroundPosition: "-200% 0" }
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
fluidText: (v, c) => {
|
|
338
|
+
const min = typeof v.min === "number" ? `${v.min}px` : v.min;
|
|
339
|
+
const max = typeof v.max === "number" ? `${v.max}px` : v.max;
|
|
340
|
+
c.fontSize = `clamp(${min}, ${v.vw || "4vw"}, ${max})`;
|
|
341
|
+
},
|
|
342
|
+
safeArea: (v, c) => {
|
|
343
|
+
const edges = Array.isArray(v) ? v : [v || "all"];
|
|
344
|
+
const map = {
|
|
345
|
+
top: "Top",
|
|
346
|
+
bottom: "Bottom",
|
|
347
|
+
left: "Left",
|
|
348
|
+
right: "Right"
|
|
349
|
+
};
|
|
350
|
+
edges.forEach((e) => {
|
|
351
|
+
if (e === "all") {
|
|
352
|
+
Object.keys(map).forEach((k) => {
|
|
353
|
+
c[`padding${map[k]}`] = `env(safe-area-inset-${k})`;
|
|
354
|
+
});
|
|
355
|
+
} else if (map[e]) {
|
|
356
|
+
c[`padding${map[e]}`] = `env(safe-area-inset-${e})`;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
},
|
|
360
|
+
// --- Nested Rules & Interactions ---
|
|
361
|
+
clickScale: (v, c) => {
|
|
362
|
+
const s = typeof v === "number" ? v : 0.95;
|
|
363
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
364
|
+
c.nestedRules.push({
|
|
365
|
+
selector: "&:active",
|
|
366
|
+
styles: {
|
|
367
|
+
transform: `scale(${s})`,
|
|
368
|
+
transition: "transform 0.1s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
onInteracting: (v, c, useTokens) => {
|
|
373
|
+
const res = getSubStyles(v, useTokens);
|
|
374
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
375
|
+
["&:hover", "&:focus-visible", "&:active"].forEach(
|
|
376
|
+
(s) => c.nestedRules.push({ selector: s, styles: res })
|
|
377
|
+
);
|
|
378
|
+
},
|
|
379
|
+
children: (v, c, useTokens) => {
|
|
380
|
+
const res = getSubStyles(v, useTokens);
|
|
381
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
382
|
+
c.nestedRules.push({ selector: "& > *", styles: res });
|
|
383
|
+
},
|
|
384
|
+
dark: (v, c, useTokens) => handleTheme(v, c, "dark", useTokens),
|
|
385
|
+
light: (v, c, useTokens) => handleTheme(v, c, "light", useTokens),
|
|
386
|
+
// --- Utility Macros ---
|
|
387
|
+
pill: (v, c) => {
|
|
388
|
+
c.borderRadius = "9999px";
|
|
389
|
+
c.padding = "8px 20px";
|
|
390
|
+
c.display = "inline-flex";
|
|
391
|
+
c.alignItems = "center";
|
|
392
|
+
c.whiteSpace = "nowrap";
|
|
393
|
+
},
|
|
394
|
+
containerMacro: (v, c) => {
|
|
395
|
+
c.width = "100%";
|
|
396
|
+
c.maxWidth = typeof v === "number" ? `${v}px` : v || "1200px";
|
|
397
|
+
macros.mx("auto", c, false);
|
|
398
|
+
macros.px("20px", c, false);
|
|
399
|
+
},
|
|
400
|
+
fullScreen: (v, c) => {
|
|
401
|
+
c.position = "fixed";
|
|
402
|
+
c.top = 0;
|
|
403
|
+
c.right = 0;
|
|
404
|
+
c.bottom = 0;
|
|
405
|
+
c.left = 0;
|
|
406
|
+
c.zIndex = typeof v === "number" ? v : 9999;
|
|
407
|
+
},
|
|
408
|
+
shimmer: (v, c) => {
|
|
409
|
+
c.backgroundImage = "linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent)";
|
|
410
|
+
c.backgroundSize = "200% 100%";
|
|
411
|
+
c.animation = "shimmer 2s infinite linear";
|
|
412
|
+
if (!c.atRules) c.atRules = [];
|
|
413
|
+
c.atRules.push({
|
|
414
|
+
type: "keyframes",
|
|
415
|
+
name: "shimmer",
|
|
416
|
+
steps: {
|
|
417
|
+
"0%": { backgroundPosition: "-200% 0" },
|
|
418
|
+
"100%": { backgroundPosition: "200% 0" }
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
},
|
|
422
|
+
bento: (v, c, useTokens) => {
|
|
423
|
+
c.display = "grid";
|
|
424
|
+
if (typeof v === "number") {
|
|
425
|
+
c.gridTemplateColumns = `repeat(${v}, minmax(0, 1fr))`;
|
|
426
|
+
c.gap = "16px";
|
|
427
|
+
} else if (typeof v === "object") {
|
|
428
|
+
c.gridTemplateColumns = `repeat(${v.cols || 4}, minmax(0, 1fr))`;
|
|
429
|
+
c.gap = typeof v.gap === "number" ? `${v.gap}px` : v.gap || "16px";
|
|
430
|
+
}
|
|
431
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
432
|
+
const childStyles = typeof v?.children === "function" ? getSubStyles(v.children, useTokens) : {
|
|
433
|
+
borderRadius: "12px",
|
|
434
|
+
padding: "20px",
|
|
435
|
+
backgroundColor: "rgba(255,255,255,0.05)"
|
|
436
|
+
};
|
|
437
|
+
c.nestedRules.push({
|
|
438
|
+
selector: "& > *",
|
|
439
|
+
styles: childStyles
|
|
440
|
+
});
|
|
441
|
+
},
|
|
442
|
+
pressable: (v, c, useTokens) => {
|
|
443
|
+
c.cursor = "pointer";
|
|
444
|
+
macros.unselectable(v, c, useTokens);
|
|
445
|
+
macros.clickScale(v, c, useTokens);
|
|
446
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
447
|
+
c.nestedRules.push({
|
|
448
|
+
selector: "&:hover",
|
|
449
|
+
styles: { opacity: 0.8 }
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
focusRing: (v, c, useTokens) => {
|
|
453
|
+
const ringColor = typeof v === "string" ? v : "#3b82f6";
|
|
454
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
455
|
+
c.nestedRules.push({
|
|
456
|
+
selector: "&:focus-visible",
|
|
457
|
+
styles: {
|
|
458
|
+
outline: `2px solid ${ringColor}`,
|
|
459
|
+
outlineOffset: "2px"
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
},
|
|
463
|
+
outlineDebug: (v, c) => {
|
|
464
|
+
c.border = "1px solid red";
|
|
465
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
466
|
+
c.nestedRules.push({
|
|
467
|
+
selector: "& > *",
|
|
468
|
+
styles: { outline: "1px solid rgba(0,255,0,0.5)" }
|
|
469
|
+
});
|
|
470
|
+
},
|
|
471
|
+
parallax: (v, c) => {
|
|
472
|
+
c.transformStyle = "preserve-3d";
|
|
473
|
+
c.perspective = "1px";
|
|
474
|
+
c.height = "100vh";
|
|
475
|
+
c.overflowX = "hidden";
|
|
476
|
+
c.overflowY = "auto";
|
|
477
|
+
if (!c.nestedRules) c.nestedRules = [];
|
|
478
|
+
const scale = typeof v === "number" ? v : 2;
|
|
479
|
+
c.nestedRules.push({
|
|
480
|
+
selector: "& > *",
|
|
481
|
+
styles: { transform: `translateZ(-1px) scale(${scale})` }
|
|
482
|
+
});
|
|
483
|
+
},
|
|
484
|
+
lineClamp: (v, c) => {
|
|
485
|
+
const lines = typeof v === "number" ? v : 3;
|
|
486
|
+
c.display = "-webkit-box";
|
|
487
|
+
c.WebkitLineClamp = lines;
|
|
488
|
+
c.WebkitBoxOrient = "vertical";
|
|
489
|
+
c.overflow = "hidden";
|
|
490
|
+
},
|
|
491
|
+
frostedNav: (v, c, useTokens) => {
|
|
492
|
+
macros.fixed({ top: 0, left: 0 }, c, useTokens);
|
|
493
|
+
c.width = "100%";
|
|
494
|
+
macros.glass(v || 15, c, useTokens);
|
|
495
|
+
macros.safeArea("top", c, useTokens);
|
|
496
|
+
c.zIndex = 1e3;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
function handlePosition(type, v, c) {
|
|
500
|
+
c.position = type;
|
|
501
|
+
if (v && typeof v === "object") {
|
|
502
|
+
if (v.top !== void 0) c.top = v.top;
|
|
503
|
+
if (v.right !== void 0) c.right = v.right;
|
|
504
|
+
if (v.bottom !== void 0) c.bottom = v.bottom;
|
|
505
|
+
if (v.left !== void 0) c.left = v.left;
|
|
506
|
+
} else if (v !== void 0 && typeof v !== "boolean") {
|
|
507
|
+
c.top = v;
|
|
508
|
+
c.right = v;
|
|
509
|
+
c.bottom = v;
|
|
510
|
+
c.left = v;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function getSubStyles(callback, useTokens) {
|
|
514
|
+
const sub = createChain(useTokens);
|
|
515
|
+
callback(sub);
|
|
516
|
+
const result = sub.$el();
|
|
517
|
+
const { selectors, atRules, nestedRules, ...pure } = result;
|
|
518
|
+
return pure;
|
|
519
|
+
}
|
|
520
|
+
function handleTheme(cb, c, mode, useTokens) {
|
|
521
|
+
if (!c.atRules) c.atRules = [];
|
|
522
|
+
c.atRules.push({
|
|
523
|
+
type: "media",
|
|
524
|
+
query: `(prefers-color-scheme: ${mode})`,
|
|
525
|
+
styles: getSubStyles(cb, useTokens)
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function handleShorthand(prop, value, catcher, useTokens = true) {
|
|
529
|
+
if (macros[prop]) {
|
|
530
|
+
macros[prop](value, catcher, useTokens);
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
if (["scale", "rotate", "skew"].includes(prop)) {
|
|
534
|
+
if (!catcher._transforms) catcher._transforms = {};
|
|
535
|
+
catcher._transforms[prop] = value;
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
if (prop === "x") {
|
|
539
|
+
if (!catcher._transforms) catcher._transforms = {};
|
|
540
|
+
catcher._transforms.translateX = value;
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
if (prop === "y") {
|
|
544
|
+
if (!catcher._transforms) catcher._transforms = {};
|
|
545
|
+
catcher._transforms.translateY = value;
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
function getAvailableShorthands() {
|
|
551
|
+
return [...Object.keys(shorthandMap), ...Object.keys(macros)];
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/compiler/suggestions.ts
|
|
555
|
+
var KNOWN_SHORTHANDS = [
|
|
556
|
+
// Spacing
|
|
557
|
+
"m",
|
|
558
|
+
"mt",
|
|
559
|
+
"mr",
|
|
560
|
+
"mb",
|
|
561
|
+
"ml",
|
|
562
|
+
"p",
|
|
563
|
+
"pt",
|
|
564
|
+
"pr",
|
|
565
|
+
"pb",
|
|
566
|
+
"pl",
|
|
567
|
+
"mx",
|
|
568
|
+
"my",
|
|
569
|
+
"px",
|
|
570
|
+
"py",
|
|
571
|
+
"inset",
|
|
572
|
+
"insetX",
|
|
573
|
+
"insetY",
|
|
574
|
+
// Sizing
|
|
575
|
+
"w",
|
|
576
|
+
"h",
|
|
577
|
+
"minW",
|
|
578
|
+
"maxW",
|
|
579
|
+
"minH",
|
|
580
|
+
"maxH",
|
|
581
|
+
"size",
|
|
582
|
+
"aspect",
|
|
583
|
+
// Display & Layout
|
|
584
|
+
"d",
|
|
585
|
+
"pos",
|
|
586
|
+
"flex",
|
|
587
|
+
"grid",
|
|
588
|
+
"inlineFlex",
|
|
589
|
+
"inlineGrid",
|
|
590
|
+
"flexDir",
|
|
591
|
+
"flexWrap",
|
|
592
|
+
"justify",
|
|
593
|
+
"items",
|
|
594
|
+
"align",
|
|
595
|
+
"content",
|
|
596
|
+
"self",
|
|
597
|
+
"center",
|
|
598
|
+
"flexCenter",
|
|
599
|
+
"gridCenter",
|
|
600
|
+
"stack",
|
|
601
|
+
"gridTable",
|
|
602
|
+
"cols",
|
|
603
|
+
"rows",
|
|
604
|
+
"gap",
|
|
605
|
+
"gapX",
|
|
606
|
+
"gapY",
|
|
607
|
+
"grow",
|
|
608
|
+
"shrink",
|
|
609
|
+
"basis",
|
|
610
|
+
"order",
|
|
611
|
+
// Colors & Backgrounds
|
|
612
|
+
"bg",
|
|
613
|
+
"c",
|
|
614
|
+
"text",
|
|
615
|
+
"op",
|
|
616
|
+
// Borders
|
|
617
|
+
"border",
|
|
618
|
+
"borderW",
|
|
619
|
+
"borderC",
|
|
620
|
+
"borderS",
|
|
621
|
+
"borderT",
|
|
622
|
+
"borderR",
|
|
623
|
+
"borderB",
|
|
624
|
+
"borderL",
|
|
625
|
+
"borderX",
|
|
626
|
+
"borderY",
|
|
627
|
+
"rounded",
|
|
628
|
+
"br",
|
|
629
|
+
"radius",
|
|
630
|
+
"roundedTL",
|
|
631
|
+
"roundedTR",
|
|
632
|
+
"roundedBR",
|
|
633
|
+
"roundedBL",
|
|
634
|
+
// Typography
|
|
635
|
+
"fontF",
|
|
636
|
+
"fs",
|
|
637
|
+
"fw",
|
|
638
|
+
"lh",
|
|
639
|
+
"ls",
|
|
640
|
+
"align",
|
|
641
|
+
// Effects
|
|
642
|
+
"shadow",
|
|
643
|
+
"truncate",
|
|
644
|
+
"hide",
|
|
645
|
+
"show",
|
|
646
|
+
"unselectable",
|
|
647
|
+
"scrollable",
|
|
648
|
+
"glass",
|
|
649
|
+
"glow",
|
|
650
|
+
"textGradient",
|
|
651
|
+
"meshGradient",
|
|
652
|
+
"noise",
|
|
653
|
+
// Positioning
|
|
654
|
+
"absolute",
|
|
655
|
+
"fixed",
|
|
656
|
+
"sticky",
|
|
657
|
+
"relative",
|
|
658
|
+
// Utilities
|
|
659
|
+
"pill",
|
|
660
|
+
"container",
|
|
661
|
+
"fullScreen",
|
|
662
|
+
"shimmer",
|
|
663
|
+
"bento",
|
|
664
|
+
"pressable",
|
|
665
|
+
"focusRing",
|
|
666
|
+
"outlineDebug",
|
|
667
|
+
"skeleton",
|
|
668
|
+
"safeArea",
|
|
669
|
+
"clickScale",
|
|
670
|
+
"onInteracting",
|
|
671
|
+
"children",
|
|
672
|
+
"dark",
|
|
673
|
+
"light",
|
|
674
|
+
"fluidText"
|
|
675
|
+
];
|
|
676
|
+
var COMMON_CSS_PROPERTIES = [
|
|
677
|
+
"display",
|
|
678
|
+
"position",
|
|
679
|
+
"margin",
|
|
680
|
+
"margin-top",
|
|
681
|
+
"margin-right",
|
|
682
|
+
"margin-bottom",
|
|
683
|
+
"margin-left",
|
|
684
|
+
"padding",
|
|
685
|
+
"padding-top",
|
|
686
|
+
"padding-right",
|
|
687
|
+
"padding-bottom",
|
|
688
|
+
"padding-left",
|
|
689
|
+
"color",
|
|
690
|
+
"background",
|
|
691
|
+
"background-color",
|
|
692
|
+
"background-image",
|
|
693
|
+
"background-size",
|
|
694
|
+
"background-position",
|
|
695
|
+
"border",
|
|
696
|
+
"border-width",
|
|
697
|
+
"border-style",
|
|
698
|
+
"border-color",
|
|
699
|
+
"border-radius",
|
|
700
|
+
"width",
|
|
701
|
+
"height",
|
|
702
|
+
"max-width",
|
|
703
|
+
"max-height",
|
|
704
|
+
"min-width",
|
|
705
|
+
"min-height",
|
|
706
|
+
"font-size",
|
|
707
|
+
"font-weight",
|
|
708
|
+
"font-family",
|
|
709
|
+
"line-height",
|
|
710
|
+
"letter-spacing",
|
|
711
|
+
"text-align",
|
|
712
|
+
"cursor",
|
|
713
|
+
"opacity",
|
|
714
|
+
"z-index",
|
|
715
|
+
"overflow",
|
|
716
|
+
"overflow-x",
|
|
717
|
+
"overflow-y",
|
|
718
|
+
"flex",
|
|
719
|
+
"flex-direction",
|
|
720
|
+
"flex-wrap",
|
|
721
|
+
"justify-content",
|
|
722
|
+
"align-items",
|
|
723
|
+
"align-self",
|
|
724
|
+
"gap",
|
|
725
|
+
"grid",
|
|
726
|
+
"grid-template-columns",
|
|
727
|
+
"grid-template-rows",
|
|
728
|
+
"grid-column",
|
|
729
|
+
"grid-row",
|
|
730
|
+
"transition",
|
|
731
|
+
"transform",
|
|
732
|
+
"animation",
|
|
733
|
+
"box-shadow",
|
|
734
|
+
"text-shadow",
|
|
735
|
+
"filter",
|
|
736
|
+
"backdrop-filter",
|
|
737
|
+
"clip-path",
|
|
738
|
+
"mask",
|
|
739
|
+
"pointer-events",
|
|
740
|
+
"user-select",
|
|
741
|
+
"resize",
|
|
742
|
+
"appearance"
|
|
743
|
+
];
|
|
744
|
+
var ANIMATION_PRESETS = [
|
|
745
|
+
"fadeIn",
|
|
746
|
+
"fadeOut",
|
|
747
|
+
"fadeInUp",
|
|
748
|
+
"fadeInDown",
|
|
749
|
+
"fadeInLeft",
|
|
750
|
+
"fadeInRight",
|
|
751
|
+
"fadeOutUp",
|
|
752
|
+
"fadeOutDown",
|
|
753
|
+
"slideInUp",
|
|
754
|
+
"slideInDown",
|
|
755
|
+
"slideInLeft",
|
|
756
|
+
"slideInRight",
|
|
757
|
+
"slideOutUp",
|
|
758
|
+
"slideOutDown",
|
|
759
|
+
"zoomIn",
|
|
760
|
+
"zoomOut",
|
|
761
|
+
"zoomInUp",
|
|
762
|
+
"zoomInDown",
|
|
763
|
+
"bounce",
|
|
764
|
+
"bounceIn",
|
|
765
|
+
"bounceOut",
|
|
766
|
+
"pulse",
|
|
767
|
+
"pulseGlow",
|
|
768
|
+
"shake",
|
|
769
|
+
"shakeX",
|
|
770
|
+
"shakeY",
|
|
771
|
+
"spin",
|
|
772
|
+
"spinReverse",
|
|
773
|
+
"wiggle",
|
|
774
|
+
"wobble",
|
|
775
|
+
"flip",
|
|
776
|
+
"flipX",
|
|
777
|
+
"blink",
|
|
778
|
+
"typing",
|
|
779
|
+
"cursor",
|
|
780
|
+
"shimmer",
|
|
781
|
+
"ripple",
|
|
782
|
+
"float",
|
|
783
|
+
"sink",
|
|
784
|
+
"swing",
|
|
785
|
+
"flash",
|
|
786
|
+
"textReveal",
|
|
787
|
+
"textGlitch"
|
|
788
|
+
];
|
|
789
|
+
var BREAKPOINTS = [
|
|
790
|
+
"sm",
|
|
791
|
+
"md",
|
|
792
|
+
"lg",
|
|
793
|
+
"xl",
|
|
794
|
+
"2xl",
|
|
795
|
+
"mobile",
|
|
796
|
+
"tablet",
|
|
797
|
+
"desktop",
|
|
798
|
+
"mobile-sm",
|
|
799
|
+
"mobile-md",
|
|
800
|
+
"tablet-sm",
|
|
801
|
+
"tablet-lg",
|
|
802
|
+
"desktop-sm",
|
|
803
|
+
"desktop-md",
|
|
804
|
+
"desktop-lg",
|
|
805
|
+
"portrait",
|
|
806
|
+
"landscape",
|
|
807
|
+
"dark",
|
|
808
|
+
"light",
|
|
809
|
+
"reducedMotion",
|
|
810
|
+
"highContrast",
|
|
811
|
+
"print",
|
|
812
|
+
"hover",
|
|
813
|
+
"no-hover",
|
|
814
|
+
"fine",
|
|
815
|
+
"coarse"
|
|
816
|
+
];
|
|
817
|
+
function levenshteinDistance(a, b) {
|
|
818
|
+
if (a.length === 0) return b.length;
|
|
819
|
+
if (b.length === 0) return a.length;
|
|
820
|
+
const matrix = [];
|
|
821
|
+
for (let i = 0; i <= b.length; i++) {
|
|
822
|
+
matrix[i] = [i];
|
|
823
|
+
}
|
|
824
|
+
for (let j = 0; j <= a.length; j++) {
|
|
825
|
+
matrix[0][j] = j;
|
|
826
|
+
}
|
|
827
|
+
for (let i = 1; i <= b.length; i++) {
|
|
828
|
+
for (let j = 1; j <= a.length; j++) {
|
|
829
|
+
const cost = a[j - 1] === b[i - 1] ? 0 : 1;
|
|
830
|
+
matrix[i][j] = Math.min(
|
|
831
|
+
matrix[i - 1][j] + 1,
|
|
832
|
+
// deletion
|
|
833
|
+
matrix[i][j - 1] + 1,
|
|
834
|
+
// insertion
|
|
835
|
+
matrix[i - 1][j - 1] + cost
|
|
836
|
+
// substitution
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return matrix[b.length][a.length];
|
|
841
|
+
}
|
|
842
|
+
function findBestMatches(query, candidates, maxResults = 3, maxDistance = 3) {
|
|
843
|
+
const matches = [];
|
|
844
|
+
for (const candidate of candidates) {
|
|
845
|
+
const distance = levenshteinDistance(query.toLowerCase(), candidate.toLowerCase());
|
|
846
|
+
if (distance <= maxDistance) {
|
|
847
|
+
matches.push({
|
|
848
|
+
name: candidate,
|
|
849
|
+
distance,
|
|
850
|
+
type: getTypeForCandidate(candidate)
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
matches.sort((a, b) => {
|
|
855
|
+
if (a.distance !== b.distance) return a.distance - b.distance;
|
|
856
|
+
return a.name.localeCompare(b.name);
|
|
857
|
+
});
|
|
858
|
+
return matches.slice(0, maxResults);
|
|
859
|
+
}
|
|
860
|
+
function getTypeForCandidate(candidate) {
|
|
861
|
+
if (KNOWN_SHORTHANDS.includes(candidate)) return "shorthand";
|
|
862
|
+
if (COMMON_CSS_PROPERTIES.includes(candidate)) return "css-property";
|
|
863
|
+
if (ANIMATION_PRESETS.includes(candidate)) return "animation";
|
|
864
|
+
if (BREAKPOINTS.includes(candidate)) return "breakpoint";
|
|
865
|
+
return "macro";
|
|
866
|
+
}
|
|
867
|
+
function getSuggestion(prop, validProperties = [], type = "all") {
|
|
868
|
+
let candidates = [];
|
|
869
|
+
if (type === "shorthand") {
|
|
870
|
+
candidates = KNOWN_SHORTHANDS;
|
|
871
|
+
} else if (type === "css-property") {
|
|
872
|
+
candidates = [...COMMON_CSS_PROPERTIES, ...validProperties];
|
|
873
|
+
} else {
|
|
874
|
+
candidates = [
|
|
875
|
+
...KNOWN_SHORTHANDS,
|
|
876
|
+
...COMMON_CSS_PROPERTIES,
|
|
877
|
+
...validProperties,
|
|
878
|
+
...ANIMATION_PRESETS,
|
|
879
|
+
...BREAKPOINTS
|
|
880
|
+
];
|
|
881
|
+
}
|
|
882
|
+
candidates = [...new Set(candidates)];
|
|
883
|
+
const matches = findBestMatches(prop, candidates, 1, 3);
|
|
884
|
+
if (matches.length > 0) {
|
|
885
|
+
return matches[0];
|
|
886
|
+
}
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// src/compiler/tokens.ts
|
|
891
|
+
var defaultTokens = {
|
|
892
|
+
colors: {
|
|
893
|
+
primary: "#667eea",
|
|
894
|
+
secondary: "#764ba2",
|
|
895
|
+
success: "#48bb78",
|
|
896
|
+
danger: "#f56565",
|
|
897
|
+
warning: "#ed8936",
|
|
898
|
+
info: "#4299e1",
|
|
899
|
+
light: "#f7fafc",
|
|
900
|
+
dark: "#1a202c",
|
|
901
|
+
white: "#ffffff",
|
|
902
|
+
black: "#000000",
|
|
903
|
+
gray: {
|
|
904
|
+
50: "#f9fafb",
|
|
905
|
+
100: "#f7fafc",
|
|
906
|
+
200: "#edf2f7",
|
|
907
|
+
300: "#e2e8f0",
|
|
908
|
+
400: "#cbd5e0",
|
|
909
|
+
500: "#a0aec0",
|
|
910
|
+
600: "#718096",
|
|
911
|
+
700: "#4a5568",
|
|
912
|
+
800: "#2d3748",
|
|
913
|
+
900: "#1a202c"
|
|
914
|
+
},
|
|
915
|
+
blue: {
|
|
916
|
+
50: "#eff6ff",
|
|
917
|
+
100: "#dbeafe",
|
|
918
|
+
200: "#bfdbfe",
|
|
919
|
+
300: "#93c5fd",
|
|
920
|
+
400: "#60a5fa",
|
|
921
|
+
500: "#3b82f6",
|
|
922
|
+
600: "#2563eb",
|
|
923
|
+
700: "#1d4ed8",
|
|
924
|
+
800: "#1e40af",
|
|
925
|
+
900: "#1e3a8a"
|
|
926
|
+
},
|
|
927
|
+
green: {
|
|
928
|
+
50: "#f0fdf4",
|
|
929
|
+
100: "#dcfce7",
|
|
930
|
+
200: "#bbf7d0",
|
|
931
|
+
300: "#86efac",
|
|
932
|
+
400: "#4ade80",
|
|
933
|
+
500: "#22c55e",
|
|
934
|
+
600: "#16a34a",
|
|
935
|
+
700: "#15803d",
|
|
936
|
+
800: "#166534",
|
|
937
|
+
900: "#14532d"
|
|
938
|
+
},
|
|
939
|
+
red: {
|
|
940
|
+
50: "#fef2f2",
|
|
941
|
+
100: "#fee2e2",
|
|
942
|
+
200: "#fecaca",
|
|
943
|
+
300: "#fca5a5",
|
|
944
|
+
400: "#f87171",
|
|
945
|
+
500: "#ef4444",
|
|
946
|
+
600: "#dc2626",
|
|
947
|
+
700: "#b91c1c",
|
|
948
|
+
800: "#991b1b",
|
|
949
|
+
900: "#7f1d1d"
|
|
950
|
+
},
|
|
951
|
+
yellow: {
|
|
952
|
+
50: "#fefce8",
|
|
953
|
+
100: "#fef9c3",
|
|
954
|
+
200: "#fef08a",
|
|
955
|
+
300: "#fde047",
|
|
956
|
+
400: "#facc15",
|
|
957
|
+
500: "#eab308",
|
|
958
|
+
600: "#ca8a04",
|
|
959
|
+
700: "#a16207",
|
|
960
|
+
800: "#854d0e",
|
|
961
|
+
900: "#713f12"
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
spacing: {
|
|
965
|
+
0: "0",
|
|
966
|
+
0.5: "0.125rem",
|
|
967
|
+
1: "0.25rem",
|
|
968
|
+
1.5: "0.375rem",
|
|
969
|
+
2: "0.5rem",
|
|
970
|
+
2.5: "0.625rem",
|
|
971
|
+
3: "0.75rem",
|
|
972
|
+
3.5: "0.875rem",
|
|
973
|
+
4: "1rem",
|
|
974
|
+
5: "1.25rem",
|
|
975
|
+
6: "1.5rem",
|
|
976
|
+
7: "1.75rem",
|
|
977
|
+
8: "2rem",
|
|
978
|
+
9: "2.25rem",
|
|
979
|
+
10: "2.5rem",
|
|
980
|
+
11: "2.75rem",
|
|
981
|
+
12: "3rem",
|
|
982
|
+
14: "3.5rem",
|
|
983
|
+
16: "4rem",
|
|
984
|
+
20: "5rem",
|
|
985
|
+
24: "6rem",
|
|
986
|
+
28: "7rem",
|
|
987
|
+
32: "8rem",
|
|
988
|
+
36: "9rem",
|
|
989
|
+
40: "10rem",
|
|
990
|
+
44: "11rem",
|
|
991
|
+
48: "12rem",
|
|
992
|
+
52: "13rem",
|
|
993
|
+
56: "14rem",
|
|
994
|
+
60: "15rem",
|
|
995
|
+
64: "16rem",
|
|
996
|
+
72: "18rem",
|
|
997
|
+
80: "20rem",
|
|
998
|
+
96: "24rem",
|
|
999
|
+
xs: "0.5rem",
|
|
1000
|
+
sm: "1rem",
|
|
1001
|
+
md: "1.5rem",
|
|
1002
|
+
lg: "2rem",
|
|
1003
|
+
xl: "3rem",
|
|
1004
|
+
"2xl": "4rem",
|
|
1005
|
+
"3xl": "6rem",
|
|
1006
|
+
"4xl": "8rem",
|
|
1007
|
+
"5xl": "10rem"
|
|
1008
|
+
},
|
|
1009
|
+
typography: {
|
|
1010
|
+
fontFamily: {
|
|
1011
|
+
sans: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
1012
|
+
serif: 'Georgia, Cambria, "Times New Roman", Times, serif',
|
|
1013
|
+
mono: 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
|
1014
|
+
system: "system-ui, -apple-system, sans-serif"
|
|
1015
|
+
},
|
|
1016
|
+
fontSize: {
|
|
1017
|
+
xs: "0.75rem",
|
|
1018
|
+
sm: "0.875rem",
|
|
1019
|
+
base: "1rem",
|
|
1020
|
+
lg: "1.125rem",
|
|
1021
|
+
xl: "1.25rem",
|
|
1022
|
+
"2xl": "1.5rem",
|
|
1023
|
+
"3xl": "1.875rem",
|
|
1024
|
+
"4xl": "2.25rem",
|
|
1025
|
+
"5xl": "3rem",
|
|
1026
|
+
"6xl": "3.75rem",
|
|
1027
|
+
"7xl": "4.5rem",
|
|
1028
|
+
"8xl": "6rem",
|
|
1029
|
+
"9xl": "8rem"
|
|
1030
|
+
},
|
|
1031
|
+
fontWeight: {
|
|
1032
|
+
hairline: "100",
|
|
1033
|
+
thin: "200",
|
|
1034
|
+
light: "300",
|
|
1035
|
+
normal: "400",
|
|
1036
|
+
medium: "500",
|
|
1037
|
+
semibold: "600",
|
|
1038
|
+
bold: "700",
|
|
1039
|
+
extrabold: "800",
|
|
1040
|
+
black: "900"
|
|
1041
|
+
},
|
|
1042
|
+
lineHeight: {
|
|
1043
|
+
none: "1",
|
|
1044
|
+
tight: "1.25",
|
|
1045
|
+
snug: "1.375",
|
|
1046
|
+
normal: "1.5",
|
|
1047
|
+
relaxed: "1.625",
|
|
1048
|
+
loose: "2",
|
|
1049
|
+
3: ".75rem",
|
|
1050
|
+
4: "1rem",
|
|
1051
|
+
5: "1.25rem",
|
|
1052
|
+
6: "1.5rem",
|
|
1053
|
+
7: "1.75rem",
|
|
1054
|
+
8: "2rem",
|
|
1055
|
+
9: "2.25rem",
|
|
1056
|
+
10: "2.5rem"
|
|
1057
|
+
},
|
|
1058
|
+
letterSpacing: {
|
|
1059
|
+
tighter: "-0.05em",
|
|
1060
|
+
tight: "-0.025em",
|
|
1061
|
+
normal: "0",
|
|
1062
|
+
wide: "0.025em",
|
|
1063
|
+
wider: "0.05em",
|
|
1064
|
+
widest: "0.1em"
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
breakpoints: {
|
|
1068
|
+
sm: "640px",
|
|
1069
|
+
md: "768px",
|
|
1070
|
+
lg: "1024px",
|
|
1071
|
+
xl: "1280px",
|
|
1072
|
+
"2xl": "1536px",
|
|
1073
|
+
"3xl": "1920px",
|
|
1074
|
+
mobile: "640px",
|
|
1075
|
+
tablet: "768px",
|
|
1076
|
+
desktop: "1024px",
|
|
1077
|
+
wide: "1280px"
|
|
1078
|
+
},
|
|
1079
|
+
zIndex: {
|
|
1080
|
+
0: "0",
|
|
1081
|
+
10: "10",
|
|
1082
|
+
20: "20",
|
|
1083
|
+
30: "30",
|
|
1084
|
+
40: "40",
|
|
1085
|
+
50: "50",
|
|
1086
|
+
auto: "auto",
|
|
1087
|
+
dropdown: "1000",
|
|
1088
|
+
sticky: "1020",
|
|
1089
|
+
fixed: "1030",
|
|
1090
|
+
modal: "1040",
|
|
1091
|
+
popover: "1050",
|
|
1092
|
+
tooltip: "1060",
|
|
1093
|
+
toast: "1070",
|
|
1094
|
+
overlay: "1080"
|
|
1095
|
+
},
|
|
1096
|
+
shadows: {
|
|
1097
|
+
xs: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
1098
|
+
sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
1099
|
+
base: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",
|
|
1100
|
+
md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
1101
|
+
lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
1102
|
+
xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
1103
|
+
"2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
1104
|
+
inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)",
|
|
1105
|
+
none: "none",
|
|
1106
|
+
"glow-sm": "0 0 10px rgba(102, 126, 234, 0.5)",
|
|
1107
|
+
"glow-md": "0 0 20px rgba(102, 126, 234, 0.5)",
|
|
1108
|
+
"glow-lg": "0 0 30px rgba(102, 126, 234, 0.5)"
|
|
1109
|
+
},
|
|
1110
|
+
borderRadius: {
|
|
1111
|
+
none: "0",
|
|
1112
|
+
sm: "0.125rem",
|
|
1113
|
+
base: "0.25rem",
|
|
1114
|
+
md: "0.375rem",
|
|
1115
|
+
lg: "0.5rem",
|
|
1116
|
+
xl: "0.75rem",
|
|
1117
|
+
"2xl": "1rem",
|
|
1118
|
+
"3xl": "1.5rem",
|
|
1119
|
+
"4xl": "2rem",
|
|
1120
|
+
full: "9999px"
|
|
1121
|
+
},
|
|
1122
|
+
// Additional animation presets
|
|
1123
|
+
animations: {
|
|
1124
|
+
fade: {
|
|
1125
|
+
"0%": { opacity: 0 },
|
|
1126
|
+
"100%": { opacity: 1 }
|
|
1127
|
+
},
|
|
1128
|
+
slideUp: {
|
|
1129
|
+
"0%": { transform: "translateY(20px)", opacity: 0 },
|
|
1130
|
+
"100%": { transform: "translateY(0)", opacity: 1 }
|
|
1131
|
+
},
|
|
1132
|
+
slideDown: {
|
|
1133
|
+
"0%": { transform: "translateY(-20px)", opacity: 0 },
|
|
1134
|
+
"100%": { transform: "translateY(0)", opacity: 1 }
|
|
1135
|
+
},
|
|
1136
|
+
slideLeft: {
|
|
1137
|
+
"0%": { transform: "translateX(20px)", opacity: 0 },
|
|
1138
|
+
"100%": { transform: "translateX(0)", opacity: 1 }
|
|
1139
|
+
},
|
|
1140
|
+
slideRight: {
|
|
1141
|
+
"0%": { transform: "translateX(-20px)", opacity: 0 },
|
|
1142
|
+
"100%": { transform: "translateX(0)", opacity: 1 }
|
|
1143
|
+
},
|
|
1144
|
+
scale: {
|
|
1145
|
+
"0%": { transform: "scale(0.95)", opacity: 0 },
|
|
1146
|
+
"100%": { transform: "scale(1)", opacity: 1 }
|
|
1147
|
+
},
|
|
1148
|
+
bounce: {
|
|
1149
|
+
"0%, 100%": { transform: "translateY(0)" },
|
|
1150
|
+
"50%": { transform: "translateY(-25%)" }
|
|
1151
|
+
},
|
|
1152
|
+
pulse: {
|
|
1153
|
+
"0%, 100%": { opacity: 1 },
|
|
1154
|
+
"50%": { opacity: 0.5 }
|
|
1155
|
+
},
|
|
1156
|
+
spin: {
|
|
1157
|
+
"0%": { transform: "rotate(0deg)" },
|
|
1158
|
+
"100%": { transform: "rotate(360deg)" }
|
|
1159
|
+
},
|
|
1160
|
+
shimmer: {
|
|
1161
|
+
"0%": { backgroundPosition: "-200% 0" },
|
|
1162
|
+
"100%": { backgroundPosition: "200% 0" }
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
var DesignTokens = class _DesignTokens {
|
|
1167
|
+
customTokens;
|
|
1168
|
+
customFlattened;
|
|
1169
|
+
defaultFlattened;
|
|
1170
|
+
tokenCache = /* @__PURE__ */ new Map();
|
|
1171
|
+
constructor(customTokens = {}) {
|
|
1172
|
+
this.customTokens = this.deepClone(customTokens);
|
|
1173
|
+
this.customFlattened = this.flattenTokens(this.customTokens);
|
|
1174
|
+
this.defaultFlattened = this.flattenTokens(defaultTokens);
|
|
1175
|
+
Object.freeze(this.customTokens);
|
|
1176
|
+
Object.freeze(this.customFlattened);
|
|
1177
|
+
Object.freeze(this.defaultFlattened);
|
|
1178
|
+
}
|
|
1179
|
+
// Deep clone objects
|
|
1180
|
+
deepClone(obj) {
|
|
1181
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
1182
|
+
if (Array.isArray(obj)) return obj.map((item) => this.deepClone(item));
|
|
1183
|
+
const cloned = {};
|
|
1184
|
+
for (const key in obj) {
|
|
1185
|
+
if (obj.hasOwnProperty(key)) {
|
|
1186
|
+
cloned[key] = this.deepClone(obj[key]);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return cloned;
|
|
1190
|
+
}
|
|
1191
|
+
// Deep freeze to prevent accidental modifications
|
|
1192
|
+
deepFreeze(obj) {
|
|
1193
|
+
Object.keys(obj).forEach((key) => {
|
|
1194
|
+
const value = obj[key];
|
|
1195
|
+
if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
|
|
1196
|
+
this.deepFreeze(value);
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
return Object.freeze(obj);
|
|
1200
|
+
}
|
|
1201
|
+
// Flatten nested tokens for easy access
|
|
1202
|
+
flattenTokens(obj, prefix = "") {
|
|
1203
|
+
const result = {};
|
|
1204
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1205
|
+
const prefixed = prefix ? `${prefix}.${key}` : key;
|
|
1206
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1207
|
+
Object.assign(result, this.flattenTokens(value, prefixed));
|
|
1208
|
+
} else {
|
|
1209
|
+
result[prefixed] = String(value);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
return result;
|
|
1213
|
+
}
|
|
1214
|
+
// Get token value by path (e.g., 'colors.primary')
|
|
1215
|
+
// Checks custom tokens first, then falls back to default tokens
|
|
1216
|
+
get(path, defaultValue = "") {
|
|
1217
|
+
if (this.tokenCache.has(path)) {
|
|
1218
|
+
return this.tokenCache.get(path);
|
|
1219
|
+
}
|
|
1220
|
+
let value;
|
|
1221
|
+
if (path in this.customFlattened) {
|
|
1222
|
+
value = this.customFlattened[path];
|
|
1223
|
+
}
|
|
1224
|
+
if (value === void 0 && path in this.defaultFlattened) {
|
|
1225
|
+
value = this.defaultFlattened[path];
|
|
1226
|
+
}
|
|
1227
|
+
if (value && value.startsWith("$")) {
|
|
1228
|
+
const refPath = value.substring(1);
|
|
1229
|
+
value = this.get(refPath, defaultValue);
|
|
1230
|
+
}
|
|
1231
|
+
const result = value !== void 0 ? value : defaultValue;
|
|
1232
|
+
this.tokenCache.set(path, result);
|
|
1233
|
+
return result;
|
|
1234
|
+
}
|
|
1235
|
+
// Get token with type safety
|
|
1236
|
+
getColor(path, defaultValue = "#000000") {
|
|
1237
|
+
return this.get(`colors.${path}`, defaultValue);
|
|
1238
|
+
}
|
|
1239
|
+
getSpacing(path, defaultValue = "0") {
|
|
1240
|
+
return this.get(`spacing.${path}`, defaultValue);
|
|
1241
|
+
}
|
|
1242
|
+
getFontSize(path, defaultValue = "1rem") {
|
|
1243
|
+
return this.get(`typography.fontSize.${path}`, defaultValue);
|
|
1244
|
+
}
|
|
1245
|
+
getFontWeight(path, defaultValue = "400") {
|
|
1246
|
+
return this.get(`typography.fontWeight.${path}`, defaultValue);
|
|
1247
|
+
}
|
|
1248
|
+
getLineHeight(path, defaultValue = "1.5") {
|
|
1249
|
+
return this.get(`typography.lineHeight.${path}`, defaultValue);
|
|
1250
|
+
}
|
|
1251
|
+
getBreakpoint(path, defaultValue = "768px") {
|
|
1252
|
+
return this.get(`breakpoints.${path}`, defaultValue);
|
|
1253
|
+
}
|
|
1254
|
+
getZIndex(path, defaultValue = "0") {
|
|
1255
|
+
return this.get(`zIndex.${path}`, defaultValue);
|
|
1256
|
+
}
|
|
1257
|
+
getShadow(path, defaultValue = "none") {
|
|
1258
|
+
return this.get(`shadows.${path}`, defaultValue);
|
|
1259
|
+
}
|
|
1260
|
+
getBorderRadius(path, defaultValue = "0") {
|
|
1261
|
+
return this.get(`borderRadius.${path}`, defaultValue);
|
|
1262
|
+
}
|
|
1263
|
+
// Get all custom tokens (as flattened object)
|
|
1264
|
+
getCustomTokens() {
|
|
1265
|
+
return { ...this.customFlattened };
|
|
1266
|
+
}
|
|
1267
|
+
// Get all default tokens (as flattened object)
|
|
1268
|
+
getDefaultTokens() {
|
|
1269
|
+
return { ...this.defaultFlattened };
|
|
1270
|
+
}
|
|
1271
|
+
// Check if a token exists (in either custom or default)
|
|
1272
|
+
has(path) {
|
|
1273
|
+
return path in this.customFlattened || path in this.defaultFlattened;
|
|
1274
|
+
}
|
|
1275
|
+
// Generate CSS variables from tokens (combines both custom and default)
|
|
1276
|
+
toCSSVariables(prefix = "chain") {
|
|
1277
|
+
let css = ":root {\n";
|
|
1278
|
+
const allTokens = { ...this.defaultFlattened, ...this.customFlattened };
|
|
1279
|
+
for (const [key, value] of Object.entries(allTokens)) {
|
|
1280
|
+
const varName = `--${prefix}-${key.replace(/\./g, "-")}`;
|
|
1281
|
+
css += ` ${varName}: ${value};
|
|
1282
|
+
`;
|
|
1283
|
+
}
|
|
1284
|
+
css += "}\n";
|
|
1285
|
+
return css;
|
|
1286
|
+
}
|
|
1287
|
+
// Generate media queries from breakpoints
|
|
1288
|
+
toMediaQueries() {
|
|
1289
|
+
const queries = {};
|
|
1290
|
+
for (const [name, value] of Object.entries(this.customFlattened)) {
|
|
1291
|
+
if (name.startsWith("breakpoints.")) {
|
|
1292
|
+
const breakpointName = name.replace("breakpoints.", "");
|
|
1293
|
+
queries[breakpointName] = value;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return queries;
|
|
1297
|
+
}
|
|
1298
|
+
// Create a theme variant (overrides on top of defaults + custom)
|
|
1299
|
+
createTheme(name, overrides) {
|
|
1300
|
+
const newCustomTokens = this.deepClone(this.customTokens);
|
|
1301
|
+
for (const [path, value] of Object.entries(overrides)) {
|
|
1302
|
+
const parts = path.split(".");
|
|
1303
|
+
let current = newCustomTokens;
|
|
1304
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1305
|
+
if (!current[parts[i]]) {
|
|
1306
|
+
current[parts[i]] = {};
|
|
1307
|
+
}
|
|
1308
|
+
current = current[parts[i]];
|
|
1309
|
+
}
|
|
1310
|
+
current[parts[parts.length - 1]] = value;
|
|
1311
|
+
}
|
|
1312
|
+
return new _DesignTokens(newCustomTokens);
|
|
1313
|
+
}
|
|
1314
|
+
// Merge with another token set
|
|
1315
|
+
merge(tokens2) {
|
|
1316
|
+
const merged = this.deepClone(this.customTokens);
|
|
1317
|
+
const deepMerge = (target, source) => {
|
|
1318
|
+
for (const key in source) {
|
|
1319
|
+
if (source.hasOwnProperty(key)) {
|
|
1320
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
1321
|
+
if (!target[key]) target[key] = {};
|
|
1322
|
+
deepMerge(target[key], source[key]);
|
|
1323
|
+
} else {
|
|
1324
|
+
target[key] = source[key];
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
deepMerge(merged, tokens2);
|
|
1330
|
+
return new _DesignTokens(merged);
|
|
1331
|
+
}
|
|
1332
|
+
// Clear cache
|
|
1333
|
+
clearCache() {
|
|
1334
|
+
this.tokenCache.clear();
|
|
1335
|
+
}
|
|
1336
|
+
// Get token path suggestions for autocomplete
|
|
1337
|
+
getSuggestions(partialPath) {
|
|
1338
|
+
const allTokens = { ...this.defaultFlattened, ...this.customFlattened };
|
|
1339
|
+
const suggestions = [];
|
|
1340
|
+
for (const key of Object.keys(allTokens)) {
|
|
1341
|
+
if (key.includes(partialPath)) {
|
|
1342
|
+
suggestions.push(key);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
return suggestions.sort();
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
var tokens = new DesignTokens(defaultTokens);
|
|
1349
|
+
|
|
1350
|
+
// src/compiler/token-resolver.ts
|
|
1351
|
+
var currentTokenContext = null;
|
|
1352
|
+
function resolveToken(value, useTokens = true, tokenContext) {
|
|
1353
|
+
if (!useTokens || typeof value !== "string") return value;
|
|
1354
|
+
const functionMatch = value.match(/^(?:token|\$token)\s*\(\s*['"]([^'"]+)['"]\s*\)$/);
|
|
1355
|
+
if (functionMatch) {
|
|
1356
|
+
const tokenPath = functionMatch[1];
|
|
1357
|
+
const resolved = resolveTokenPath(tokenPath, tokenContext);
|
|
1358
|
+
return resolved !== void 0 ? resolved : value;
|
|
1359
|
+
}
|
|
1360
|
+
if (value.includes("$")) {
|
|
1361
|
+
return value.replace(/\$([a-zA-Z0-9.-]+)/g, (match, path) => {
|
|
1362
|
+
const resolved = resolveTokenPath(path, tokenContext);
|
|
1363
|
+
if (resolved !== void 0 && resolved !== null) {
|
|
1364
|
+
return String(resolved);
|
|
1365
|
+
}
|
|
1366
|
+
if (true) {
|
|
1367
|
+
console.warn(`[ChainCSS] Token not found: ${path}`);
|
|
1368
|
+
}
|
|
1369
|
+
return match;
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
return value;
|
|
1373
|
+
}
|
|
1374
|
+
function resolveTokenPath(path, tokenContext) {
|
|
1375
|
+
let resolved = null;
|
|
1376
|
+
if (tokenContext && typeof tokenContext.get === "function") {
|
|
1377
|
+
resolved = tokenContext.get(path);
|
|
1378
|
+
}
|
|
1379
|
+
if ((resolved === void 0 || resolved === null) && currentTokenContext) {
|
|
1380
|
+
resolved = currentTokenContext.get(path);
|
|
1381
|
+
}
|
|
1382
|
+
if (resolved === void 0 || resolved === null) {
|
|
1383
|
+
if (tokens && typeof tokens.get === "function") {
|
|
1384
|
+
resolved = tokens.get(path);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
return resolved;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
// src/compiler/breakpoints.ts
|
|
1391
|
+
var DEFAULT_BREAKPOINTS = {
|
|
1392
|
+
// Mobile-first breakpoints
|
|
1393
|
+
sm: "(min-width: 640px)",
|
|
1394
|
+
md: "(min-width: 768px)",
|
|
1395
|
+
lg: "(min-width: 1024px)",
|
|
1396
|
+
xl: "(min-width: 1280px)",
|
|
1397
|
+
"2xl": "(min-width: 1536px)",
|
|
1398
|
+
// Desktop-first breakpoints (alternative naming)
|
|
1399
|
+
mobile: "(max-width: 767px)",
|
|
1400
|
+
tablet: "(min-width: 768px) and (max-width: 1023px)",
|
|
1401
|
+
desktop: "(min-width: 1024px)",
|
|
1402
|
+
// Specific device breakpoints
|
|
1403
|
+
"mobile-sm": "(max-width: 375px)",
|
|
1404
|
+
"mobile-md": "(min-width: 376px) and (max-width: 768px)",
|
|
1405
|
+
"tablet-sm": "(min-width: 769px) and (max-width: 834px)",
|
|
1406
|
+
"tablet-lg": "(min-width: 835px) and (max-width: 1024px)",
|
|
1407
|
+
"desktop-sm": "(min-width: 1025px) and (max-width: 1280px)",
|
|
1408
|
+
"desktop-md": "(min-width: 1281px) and (max-width: 1440px)",
|
|
1409
|
+
"desktop-lg": "(min-width: 1441px)",
|
|
1410
|
+
// Orientation breakpoints
|
|
1411
|
+
portrait: "(orientation: portrait)",
|
|
1412
|
+
landscape: "(orientation: landscape)",
|
|
1413
|
+
// Feature breakpoints
|
|
1414
|
+
dark: "(prefers-color-scheme: dark)",
|
|
1415
|
+
light: "(prefers-color-scheme: light)",
|
|
1416
|
+
reducedMotion: "(prefers-reduced-motion: reduce)",
|
|
1417
|
+
highContrast: "(prefers-contrast: high)",
|
|
1418
|
+
// Print
|
|
1419
|
+
print: "print",
|
|
1420
|
+
// Hover capabilities
|
|
1421
|
+
hover: "(hover: hover)",
|
|
1422
|
+
"no-hover": "(hover: none)",
|
|
1423
|
+
// Pointer capabilities
|
|
1424
|
+
fine: "(pointer: fine)",
|
|
1425
|
+
coarse: "(pointer: coarse)"
|
|
1426
|
+
};
|
|
1427
|
+
var currentBreakpoints = { ...DEFAULT_BREAKPOINTS };
|
|
1428
|
+
|
|
1429
|
+
// src/compiler/animations.ts
|
|
1430
|
+
var animationPresets = {
|
|
1431
|
+
// Fades
|
|
1432
|
+
fadeIn: {
|
|
1433
|
+
"0%": { opacity: 0 },
|
|
1434
|
+
"100%": { opacity: 1 }
|
|
1435
|
+
},
|
|
1436
|
+
fadeOut: {
|
|
1437
|
+
"0%": { opacity: 1 },
|
|
1438
|
+
"100%": { opacity: 0 }
|
|
1439
|
+
},
|
|
1440
|
+
fadeInUp: {
|
|
1441
|
+
"0%": { opacity: 0, transform: "translateY(20px)" },
|
|
1442
|
+
"100%": { opacity: 1, transform: "translateY(0)" }
|
|
1443
|
+
},
|
|
1444
|
+
fadeInDown: {
|
|
1445
|
+
"0%": { opacity: 0, transform: "translateY(-20px)" },
|
|
1446
|
+
"100%": { opacity: 1, transform: "translateY(0)" }
|
|
1447
|
+
},
|
|
1448
|
+
fadeInLeft: {
|
|
1449
|
+
"0%": { opacity: 0, transform: "translateX(-20px)" },
|
|
1450
|
+
"100%": { opacity: 1, transform: "translateX(0)" }
|
|
1451
|
+
},
|
|
1452
|
+
fadeInRight: {
|
|
1453
|
+
"0%": { opacity: 0, transform: "translateX(20px)" },
|
|
1454
|
+
"100%": { opacity: 1, transform: "translateX(0)" }
|
|
1455
|
+
},
|
|
1456
|
+
fadeOutUp: {
|
|
1457
|
+
"0%": { opacity: 1, transform: "translateY(0)" },
|
|
1458
|
+
"100%": { opacity: 0, transform: "translateY(-20px)" }
|
|
1459
|
+
},
|
|
1460
|
+
fadeOutDown: {
|
|
1461
|
+
"0%": { opacity: 1, transform: "translateY(0)" },
|
|
1462
|
+
"100%": { opacity: 0, transform: "translateY(20px)" }
|
|
1463
|
+
},
|
|
1464
|
+
// Slides
|
|
1465
|
+
slideInUp: {
|
|
1466
|
+
"0%": { transform: "translateY(100%)" },
|
|
1467
|
+
"100%": { transform: "translateY(0)" }
|
|
1468
|
+
},
|
|
1469
|
+
slideInDown: {
|
|
1470
|
+
"0%": { transform: "translateY(-100%)" },
|
|
1471
|
+
"100%": { transform: "translateY(0)" }
|
|
1472
|
+
},
|
|
1473
|
+
slideInLeft: {
|
|
1474
|
+
"0%": { transform: "translateX(-100%)" },
|
|
1475
|
+
"100%": { transform: "translateX(0)" }
|
|
1476
|
+
},
|
|
1477
|
+
slideInRight: {
|
|
1478
|
+
"0%": { transform: "translateX(100%)" },
|
|
1479
|
+
"100%": { transform: "translateX(0)" }
|
|
1480
|
+
},
|
|
1481
|
+
slideOutUp: {
|
|
1482
|
+
"0%": { transform: "translateY(0)" },
|
|
1483
|
+
"100%": { transform: "translateY(-100%)" }
|
|
1484
|
+
},
|
|
1485
|
+
slideOutDown: {
|
|
1486
|
+
"0%": { transform: "translateY(0)" },
|
|
1487
|
+
"100%": { transform: "translateY(100%)" }
|
|
1488
|
+
},
|
|
1489
|
+
// Zooms
|
|
1490
|
+
zoomIn: {
|
|
1491
|
+
"0%": { opacity: 0, transform: "scale(0.8)" },
|
|
1492
|
+
"100%": { opacity: 1, transform: "scale(1)" }
|
|
1493
|
+
},
|
|
1494
|
+
zoomOut: {
|
|
1495
|
+
"0%": { opacity: 1, transform: "scale(1)" },
|
|
1496
|
+
"100%": { opacity: 0, transform: "scale(0.8)" }
|
|
1497
|
+
},
|
|
1498
|
+
zoomInUp: {
|
|
1499
|
+
"0%": { opacity: 0, transform: "scale(0.8) translateY(20px)" },
|
|
1500
|
+
"100%": { opacity: 1, transform: "scale(1) translateY(0)" }
|
|
1501
|
+
},
|
|
1502
|
+
zoomInDown: {
|
|
1503
|
+
"0%": { opacity: 0, transform: "scale(0.8) translateY(-20px)" },
|
|
1504
|
+
"100%": { opacity: 1, transform: "scale(1) translateY(0)" }
|
|
1505
|
+
},
|
|
1506
|
+
// Bounces
|
|
1507
|
+
bounce: {
|
|
1508
|
+
"0%, 100%": { transform: "translateY(0)" },
|
|
1509
|
+
"50%": { transform: "translateY(-20px)" }
|
|
1510
|
+
},
|
|
1511
|
+
bounceIn: {
|
|
1512
|
+
"0%": { opacity: 0, transform: "scale(0.8)" },
|
|
1513
|
+
"50%": { transform: "scale(1.05)" },
|
|
1514
|
+
"100%": { opacity: 1, transform: "scale(1)" }
|
|
1515
|
+
},
|
|
1516
|
+
bounceOut: {
|
|
1517
|
+
"0%": { transform: "scale(1)" },
|
|
1518
|
+
"50%": { transform: "scale(0.95)" },
|
|
1519
|
+
"100%": { opacity: 0, transform: "scale(0.8)" }
|
|
1520
|
+
},
|
|
1521
|
+
// Pulses
|
|
1522
|
+
pulse: {
|
|
1523
|
+
"0%, 100%": { transform: "scale(1)" },
|
|
1524
|
+
"50%": { transform: "scale(1.05)" }
|
|
1525
|
+
},
|
|
1526
|
+
pulseGlow: {
|
|
1527
|
+
"0%, 100%": { opacity: 1, filter: "brightness(1)" },
|
|
1528
|
+
"50%": { opacity: 0.8, filter: "brightness(1.2)" }
|
|
1529
|
+
},
|
|
1530
|
+
// Shakes
|
|
1531
|
+
shake: {
|
|
1532
|
+
"0%, 100%": { transform: "translateX(0)" },
|
|
1533
|
+
"25%": { transform: "translateX(-5px)" },
|
|
1534
|
+
"75%": { transform: "translateX(5px)" }
|
|
1535
|
+
},
|
|
1536
|
+
shakeX: {
|
|
1537
|
+
"0%, 100%": { transform: "translateX(0)" },
|
|
1538
|
+
"25%, 75%": { transform: "translateX(-10px)" },
|
|
1539
|
+
"50%": { transform: "translateX(10px)" }
|
|
1540
|
+
},
|
|
1541
|
+
shakeY: {
|
|
1542
|
+
"0%, 100%": { transform: "translateY(0)" },
|
|
1543
|
+
"25%, 75%": { transform: "translateY(-10px)" },
|
|
1544
|
+
"50%": { transform: "translateY(10px)" }
|
|
1545
|
+
},
|
|
1546
|
+
// Rotations
|
|
1547
|
+
spin: {
|
|
1548
|
+
"0%": { transform: "rotate(0deg)" },
|
|
1549
|
+
"100%": { transform: "rotate(360deg)" }
|
|
1550
|
+
},
|
|
1551
|
+
spinReverse: {
|
|
1552
|
+
"0%": { transform: "rotate(0deg)" },
|
|
1553
|
+
"100%": { transform: "rotate(-360deg)" }
|
|
1554
|
+
},
|
|
1555
|
+
wiggle: {
|
|
1556
|
+
"0%, 100%": { transform: "rotate(-3deg)" },
|
|
1557
|
+
"50%": { transform: "rotate(3deg)" }
|
|
1558
|
+
},
|
|
1559
|
+
wobble: {
|
|
1560
|
+
"0%": { transform: "translateX(0%)" },
|
|
1561
|
+
"15%": { transform: "translateX(-25%) rotate(-5deg)" },
|
|
1562
|
+
"30%": { transform: "translateX(20%) rotate(3deg)" },
|
|
1563
|
+
"45%": { transform: "translateX(-15%) rotate(-3deg)" },
|
|
1564
|
+
"60%": { transform: "translateX(10%) rotate(2deg)" },
|
|
1565
|
+
"75%": { transform: "translateX(-5%) rotate(-1deg)" },
|
|
1566
|
+
"100%": { transform: "translateX(0%)" }
|
|
1567
|
+
},
|
|
1568
|
+
// Flips
|
|
1569
|
+
flip: {
|
|
1570
|
+
"0%": { transform: "perspective(400px) rotateY(0)" },
|
|
1571
|
+
"100%": { transform: "perspective(400px) rotateY(180deg)" }
|
|
1572
|
+
},
|
|
1573
|
+
flipX: {
|
|
1574
|
+
"0%": { transform: "perspective(400px) rotateX(0)" },
|
|
1575
|
+
"100%": { transform: "perspective(400px) rotateX(180deg)" }
|
|
1576
|
+
},
|
|
1577
|
+
// Special effects
|
|
1578
|
+
blink: {
|
|
1579
|
+
"0%, 100%": { opacity: 1 },
|
|
1580
|
+
"50%": { opacity: 0 }
|
|
1581
|
+
},
|
|
1582
|
+
typing: {
|
|
1583
|
+
"0%": { width: "0" },
|
|
1584
|
+
"100%": { width: "100%" }
|
|
1585
|
+
},
|
|
1586
|
+
cursor: {
|
|
1587
|
+
"0%, 100%": { borderColor: "transparent" },
|
|
1588
|
+
"50%": { borderColor: "currentColor" }
|
|
1589
|
+
},
|
|
1590
|
+
shimmer: {
|
|
1591
|
+
"0%": { backgroundPosition: "-200% 0" },
|
|
1592
|
+
"100%": { backgroundPosition: "200% 0" }
|
|
1593
|
+
},
|
|
1594
|
+
ripple: {
|
|
1595
|
+
"0%": { transform: "scale(0)", opacity: 0.5 },
|
|
1596
|
+
"100%": { transform: "scale(4)", opacity: 0 }
|
|
1597
|
+
},
|
|
1598
|
+
float: {
|
|
1599
|
+
"0%, 100%": { transform: "translateY(0)" },
|
|
1600
|
+
"50%": { transform: "translateY(-10px)" }
|
|
1601
|
+
},
|
|
1602
|
+
sink: {
|
|
1603
|
+
"0%, 100%": { transform: "translateY(0)" },
|
|
1604
|
+
"50%": { transform: "translateY(10px)" }
|
|
1605
|
+
},
|
|
1606
|
+
swing: {
|
|
1607
|
+
"0%, 100%": { transform: "rotate(0deg)" },
|
|
1608
|
+
"25%": { transform: "rotate(15deg)" },
|
|
1609
|
+
"75%": { transform: "rotate(-15deg)" }
|
|
1610
|
+
},
|
|
1611
|
+
flash: {
|
|
1612
|
+
"0%, 100%": { opacity: 1 },
|
|
1613
|
+
"25%, 75%": { opacity: 0.5 },
|
|
1614
|
+
"50%": { opacity: 0 }
|
|
1615
|
+
},
|
|
1616
|
+
// Text animations
|
|
1617
|
+
textReveal: {
|
|
1618
|
+
"0%": { clipPath: "inset(0 100% 0 0)" },
|
|
1619
|
+
"100%": { clipPath: "inset(0 0 0 0)" }
|
|
1620
|
+
},
|
|
1621
|
+
textGlitch: {
|
|
1622
|
+
"0%, 100%": { transform: "translate(0, 0)" },
|
|
1623
|
+
"20%": { transform: "translate(-2px, 1px)" },
|
|
1624
|
+
"40%": { transform: "translate(2px, -1px)" },
|
|
1625
|
+
"60%": { transform: "translate(-1px, 2px)" },
|
|
1626
|
+
"80%": { transform: "translate(1px, -2px)" }
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
var DEFAULT_ANIMATION_CONFIG = {
|
|
1630
|
+
name: "",
|
|
1631
|
+
// Add this missing property
|
|
1632
|
+
duration: "0.3s",
|
|
1633
|
+
delay: "0s",
|
|
1634
|
+
timing: "ease",
|
|
1635
|
+
iteration: 1,
|
|
1636
|
+
direction: "normal",
|
|
1637
|
+
fillMode: "both",
|
|
1638
|
+
playState: "running"
|
|
1639
|
+
};
|
|
1640
|
+
function createAnimation(animationName, config = {}) {
|
|
1641
|
+
const {
|
|
1642
|
+
duration = DEFAULT_ANIMATION_CONFIG.duration,
|
|
1643
|
+
delay = DEFAULT_ANIMATION_CONFIG.delay,
|
|
1644
|
+
timing = DEFAULT_ANIMATION_CONFIG.timing,
|
|
1645
|
+
iteration = DEFAULT_ANIMATION_CONFIG.iteration,
|
|
1646
|
+
direction = DEFAULT_ANIMATION_CONFIG.direction,
|
|
1647
|
+
fillMode = DEFAULT_ANIMATION_CONFIG.fillMode,
|
|
1648
|
+
playState = DEFAULT_ANIMATION_CONFIG.playState
|
|
1649
|
+
} = config;
|
|
1650
|
+
const animationValue = `${animationName} ${duration} ${timing} ${delay} ${iteration} ${direction} ${playState}`;
|
|
1651
|
+
return {
|
|
1652
|
+
animation: animationValue.trim(),
|
|
1653
|
+
animationFillMode: fillMode,
|
|
1654
|
+
animationName,
|
|
1655
|
+
animationDuration: duration,
|
|
1656
|
+
animationDelay: delay,
|
|
1657
|
+
animationTimingFunction: timing,
|
|
1658
|
+
animationIterationCount: iteration,
|
|
1659
|
+
animationDirection: direction,
|
|
1660
|
+
animationPlayState: playState
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
function getAnimationPreset(name) {
|
|
1664
|
+
return animationPresets[name];
|
|
1665
|
+
}
|
|
1666
|
+
function getAnimationPresetNames() {
|
|
1667
|
+
return Object.keys(animationPresets);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
// src/compiler/helpers.ts
|
|
1671
|
+
function normalizeValue(value) {
|
|
1672
|
+
if (value === null || value === void 0) return "0";
|
|
1673
|
+
if (typeof value === "number") return `${value}px`;
|
|
1674
|
+
return String(value);
|
|
1675
|
+
}
|
|
1676
|
+
function performCalculation(a, b, operation, options = {}) {
|
|
1677
|
+
const valA = normalizeValue(a);
|
|
1678
|
+
const valB = normalizeValue(b);
|
|
1679
|
+
let result;
|
|
1680
|
+
switch (operation) {
|
|
1681
|
+
case "add":
|
|
1682
|
+
result = `calc(${valA} + ${valB})`;
|
|
1683
|
+
break;
|
|
1684
|
+
case "subtract":
|
|
1685
|
+
result = `calc(${valA} - ${valB})`;
|
|
1686
|
+
break;
|
|
1687
|
+
case "multiply":
|
|
1688
|
+
result = `calc(${valA} * ${valB})`;
|
|
1689
|
+
break;
|
|
1690
|
+
case "divide":
|
|
1691
|
+
result = `calc(${valA} / ${valB})`;
|
|
1692
|
+
break;
|
|
1693
|
+
default:
|
|
1694
|
+
result = `calc(${valA} ${operation} ${valB})`;
|
|
1695
|
+
}
|
|
1696
|
+
if (options.simplify) {
|
|
1697
|
+
result = simplifyCalc(result);
|
|
1698
|
+
}
|
|
1699
|
+
return result;
|
|
1700
|
+
}
|
|
1701
|
+
function simplifyCalc(calcExpr) {
|
|
1702
|
+
if (calcExpr.startsWith("calc(") && calcExpr.endsWith(")")) {
|
|
1703
|
+
const inner = calcExpr.slice(5, -1);
|
|
1704
|
+
if (!inner.includes("+") && !inner.includes("-") && !inner.includes("*") && !inner.includes("/")) {
|
|
1705
|
+
return inner.trim();
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
return calcExpr;
|
|
1709
|
+
}
|
|
1710
|
+
function createCalc(expr, options = {}) {
|
|
1711
|
+
let result = `calc(${expr})`;
|
|
1712
|
+
if (options.simplify) {
|
|
1713
|
+
result = simplifyCalc(result);
|
|
1714
|
+
}
|
|
1715
|
+
return result;
|
|
1716
|
+
}
|
|
1717
|
+
var helpers = {
|
|
1718
|
+
// Basic calc
|
|
1719
|
+
calc: (expr, options) => createCalc(expr, options),
|
|
1720
|
+
// Arithmetic operations
|
|
1721
|
+
add: (a, b, options) => performCalculation(a, b, "add", options),
|
|
1722
|
+
subtract: (a, b, options) => performCalculation(a, b, "subtract", options),
|
|
1723
|
+
sub: (a, b, options) => performCalculation(a, b, "subtract", options),
|
|
1724
|
+
multiply: (a, b, options) => performCalculation(a, b, "multiply", options),
|
|
1725
|
+
mul: (a, b, options) => performCalculation(a, b, "multiply", options),
|
|
1726
|
+
divide: (a, b, options) => performCalculation(a, b, "divide", options),
|
|
1727
|
+
div: (a, b, options) => performCalculation(a, b, "divide", options),
|
|
1728
|
+
// Complex operations
|
|
1729
|
+
sum: (...values) => {
|
|
1730
|
+
const expr = values.map((v) => normalizeValue(v)).join(" + ");
|
|
1731
|
+
return createCalc(expr);
|
|
1732
|
+
},
|
|
1733
|
+
difference: (a, ...rest) => {
|
|
1734
|
+
const expr = [a, ...rest].map((v) => normalizeValue(v)).join(" - ");
|
|
1735
|
+
return createCalc(expr);
|
|
1736
|
+
},
|
|
1737
|
+
product: (...values) => {
|
|
1738
|
+
const expr = values.map((v) => normalizeValue(v)).join(" * ");
|
|
1739
|
+
return createCalc(expr);
|
|
1740
|
+
},
|
|
1741
|
+
quotient: (a, ...rest) => {
|
|
1742
|
+
const expr = [a, ...rest].map((v) => normalizeValue(v)).join(" / ");
|
|
1743
|
+
return createCalc(expr);
|
|
1744
|
+
},
|
|
1745
|
+
// Unit helpers with conversion
|
|
1746
|
+
mpx: (value) => {
|
|
1747
|
+
if (typeof value === "number") return `${value}px`;
|
|
1748
|
+
if (/^\d+(?:\.\d+)?(?:px|rem|em|%|vw|vh)$/.test(value)) return value;
|
|
1749
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}px`;
|
|
1750
|
+
return value;
|
|
1751
|
+
},
|
|
1752
|
+
rem: (value, base = 16) => {
|
|
1753
|
+
if (typeof value === "number") return `${value}rem`;
|
|
1754
|
+
if (/^\d+(?:\.\d+)?rem$/.test(value)) return value;
|
|
1755
|
+
if (/^\d+(?:\.\d+)?px$/.test(value)) {
|
|
1756
|
+
const px = parseFloat(value);
|
|
1757
|
+
return `${px / base}rem`;
|
|
1758
|
+
}
|
|
1759
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}rem`;
|
|
1760
|
+
return value;
|
|
1761
|
+
},
|
|
1762
|
+
em: (value, context = 16) => {
|
|
1763
|
+
if (typeof value === "number") return `${value}em`;
|
|
1764
|
+
if (/^\d+(?:\.\d+)?em$/.test(value)) return value;
|
|
1765
|
+
if (/^\d+(?:\.\d+)?px$/.test(value)) {
|
|
1766
|
+
const px = parseFloat(value);
|
|
1767
|
+
return `${px / context}em`;
|
|
1768
|
+
}
|
|
1769
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}em`;
|
|
1770
|
+
return value;
|
|
1771
|
+
},
|
|
1772
|
+
percent: (value) => {
|
|
1773
|
+
if (typeof value === "number") return `${value}%`;
|
|
1774
|
+
if (/^\d+(?:\.\d+)?%$/.test(value)) return value;
|
|
1775
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}%`;
|
|
1776
|
+
return value;
|
|
1777
|
+
},
|
|
1778
|
+
vw: (value) => {
|
|
1779
|
+
if (typeof value === "number") return `${value}vw`;
|
|
1780
|
+
if (/^\d+(?:\.\d+)?vw$/.test(value)) return value;
|
|
1781
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vw`;
|
|
1782
|
+
return value;
|
|
1783
|
+
},
|
|
1784
|
+
vh: (value) => {
|
|
1785
|
+
if (typeof value === "number") return `${value}vh`;
|
|
1786
|
+
if (/^\d+(?:\.\d+)?vh$/.test(value)) return value;
|
|
1787
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vh`;
|
|
1788
|
+
return value;
|
|
1789
|
+
},
|
|
1790
|
+
vmin: (value) => {
|
|
1791
|
+
if (typeof value === "number") return `${value}vmin`;
|
|
1792
|
+
if (/^\d+(?:\.\d+)?vmin$/.test(value)) return value;
|
|
1793
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vmin`;
|
|
1794
|
+
return value;
|
|
1795
|
+
},
|
|
1796
|
+
vmax: (value) => {
|
|
1797
|
+
if (typeof value === "number") return `${value}vmax`;
|
|
1798
|
+
if (/^\d+(?:\.\d+)?vmax$/.test(value)) return value;
|
|
1799
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vmax`;
|
|
1800
|
+
return value;
|
|
1801
|
+
},
|
|
1802
|
+
ch: (value) => {
|
|
1803
|
+
if (typeof value === "number") return `${value}ch`;
|
|
1804
|
+
if (/^\d+(?:\.\d+)?ch$/.test(value)) return value;
|
|
1805
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}ch`;
|
|
1806
|
+
return value;
|
|
1807
|
+
},
|
|
1808
|
+
ex: (value) => {
|
|
1809
|
+
if (typeof value === "number") return `${value}ex`;
|
|
1810
|
+
if (/^\d+(?:\.\d+)?ex$/.test(value)) return value;
|
|
1811
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}ex`;
|
|
1812
|
+
return value;
|
|
1813
|
+
},
|
|
1814
|
+
// Convert between units
|
|
1815
|
+
convert: (value, fromUnit, toUnit, context = 16) => {
|
|
1816
|
+
let numericValue;
|
|
1817
|
+
if (typeof value === "number") {
|
|
1818
|
+
numericValue = value;
|
|
1819
|
+
} else {
|
|
1820
|
+
numericValue = parseFloat(value);
|
|
1821
|
+
}
|
|
1822
|
+
let inPx;
|
|
1823
|
+
switch (fromUnit) {
|
|
1824
|
+
case "px":
|
|
1825
|
+
inPx = numericValue;
|
|
1826
|
+
break;
|
|
1827
|
+
case "rem":
|
|
1828
|
+
inPx = numericValue * context;
|
|
1829
|
+
break;
|
|
1830
|
+
case "em":
|
|
1831
|
+
inPx = numericValue * context;
|
|
1832
|
+
break;
|
|
1833
|
+
case "%":
|
|
1834
|
+
inPx = numericValue / 100 * context;
|
|
1835
|
+
break;
|
|
1836
|
+
case "vw":
|
|
1837
|
+
inPx = numericValue / 100 * 1920;
|
|
1838
|
+
break;
|
|
1839
|
+
case "vh":
|
|
1840
|
+
inPx = numericValue / 100 * 1080;
|
|
1841
|
+
break;
|
|
1842
|
+
default:
|
|
1843
|
+
inPx = numericValue;
|
|
1844
|
+
}
|
|
1845
|
+
let result;
|
|
1846
|
+
switch (toUnit) {
|
|
1847
|
+
case "px":
|
|
1848
|
+
result = inPx;
|
|
1849
|
+
break;
|
|
1850
|
+
case "rem":
|
|
1851
|
+
result = inPx / context;
|
|
1852
|
+
break;
|
|
1853
|
+
case "em":
|
|
1854
|
+
result = inPx / context;
|
|
1855
|
+
break;
|
|
1856
|
+
case "%":
|
|
1857
|
+
result = inPx / context * 100;
|
|
1858
|
+
break;
|
|
1859
|
+
case "vw":
|
|
1860
|
+
result = inPx / 1920 * 100;
|
|
1861
|
+
break;
|
|
1862
|
+
case "vh":
|
|
1863
|
+
result = inPx / 1080 * 100;
|
|
1864
|
+
break;
|
|
1865
|
+
default:
|
|
1866
|
+
result = inPx;
|
|
1867
|
+
}
|
|
1868
|
+
if (Math.abs(result - Math.round(result)) < 0.01) {
|
|
1869
|
+
return `${Math.round(result)}${toUnit}`;
|
|
1870
|
+
}
|
|
1871
|
+
return `${result.toFixed(2)}${toUnit}`;
|
|
1872
|
+
},
|
|
1873
|
+
// Min/Max/Clamp with better formatting
|
|
1874
|
+
min: (...values) => {
|
|
1875
|
+
const formatted = values.map((v) => normalizeValue(v)).join(", ");
|
|
1876
|
+
return `min(${formatted})`;
|
|
1877
|
+
},
|
|
1878
|
+
max: (...values) => {
|
|
1879
|
+
const formatted = values.map((v) => normalizeValue(v)).join(", ");
|
|
1880
|
+
return `max(${formatted})`;
|
|
1881
|
+
},
|
|
1882
|
+
clamp: (min, preferred, max, options) => {
|
|
1883
|
+
const minVal = normalizeValue(min);
|
|
1884
|
+
const prefVal = normalizeValue(preferred);
|
|
1885
|
+
const maxVal = normalizeValue(max);
|
|
1886
|
+
let result = `clamp(${minVal}, ${prefVal}, ${maxVal})`;
|
|
1887
|
+
if (options?.simplify) {
|
|
1888
|
+
result = simplifyCalc(result);
|
|
1889
|
+
}
|
|
1890
|
+
return result;
|
|
1891
|
+
},
|
|
1892
|
+
// Rounding helpers
|
|
1893
|
+
round: (value, precision = 2) => {
|
|
1894
|
+
const num = typeof value === "number" ? value : parseFloat(value);
|
|
1895
|
+
return num.toFixed(precision);
|
|
1896
|
+
},
|
|
1897
|
+
ceil: (value) => {
|
|
1898
|
+
const num = typeof value === "number" ? value : parseFloat(value);
|
|
1899
|
+
return Math.ceil(num).toString();
|
|
1900
|
+
},
|
|
1901
|
+
floor: (value) => {
|
|
1902
|
+
const num = typeof value === "number" ? value : parseFloat(value);
|
|
1903
|
+
return Math.floor(num).toString();
|
|
1904
|
+
},
|
|
1905
|
+
// Color helpers (returns CSS color values)
|
|
1906
|
+
rgba: (r, g, b, a = 1) => {
|
|
1907
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
1908
|
+
},
|
|
1909
|
+
hsla: (h, s, l, a = 1) => {
|
|
1910
|
+
return `hsla(${h}, ${s}%, ${l}%, ${a})`;
|
|
1911
|
+
},
|
|
1912
|
+
// String helpers
|
|
1913
|
+
url: (path) => {
|
|
1914
|
+
return `url(${path})`;
|
|
1915
|
+
},
|
|
1916
|
+
format: (strings, ...values) => {
|
|
1917
|
+
let result = "";
|
|
1918
|
+
for (let i = 0; i < strings.length; i++) {
|
|
1919
|
+
result += strings[i];
|
|
1920
|
+
if (i < values.length) {
|
|
1921
|
+
result += normalizeValue(values[i]);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
return result;
|
|
1925
|
+
},
|
|
1926
|
+
// Conditional helpers
|
|
1927
|
+
if: (condition, trueValue, falseValue) => {
|
|
1928
|
+
return condition ? trueValue : falseValue;
|
|
1929
|
+
},
|
|
1930
|
+
// String manipulation
|
|
1931
|
+
camelToKebab: (str) => {
|
|
1932
|
+
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1933
|
+
},
|
|
1934
|
+
kebabToCamel: (str) => {
|
|
1935
|
+
return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1936
|
+
},
|
|
1937
|
+
toPx: (value) => {
|
|
1938
|
+
if (typeof value === "number") return `${value}px`;
|
|
1939
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}px`;
|
|
1940
|
+
return value;
|
|
1941
|
+
},
|
|
1942
|
+
toRem: (value, base = 16) => {
|
|
1943
|
+
if (typeof value === "number") return `${value / base}rem`;
|
|
1944
|
+
if (/^\d+(?:\.\d+)?px$/.test(value)) {
|
|
1945
|
+
const px = parseFloat(value);
|
|
1946
|
+
return `${px / base}rem`;
|
|
1947
|
+
}
|
|
1948
|
+
if (/^\d+(?:\.\d+)?$/.test(value)) {
|
|
1949
|
+
const numValue = typeof value === "string" ? parseFloat(value) : value;
|
|
1950
|
+
return `${numValue / base}rem`;
|
|
1951
|
+
}
|
|
1952
|
+
return value;
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
1957
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
1958
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
1959
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
1960
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
1961
|
+
var styles = {
|
|
1962
|
+
modifier: {
|
|
1963
|
+
reset: [0, 0],
|
|
1964
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
1965
|
+
bold: [1, 22],
|
|
1966
|
+
dim: [2, 22],
|
|
1967
|
+
italic: [3, 23],
|
|
1968
|
+
underline: [4, 24],
|
|
1969
|
+
overline: [53, 55],
|
|
1970
|
+
inverse: [7, 27],
|
|
1971
|
+
hidden: [8, 28],
|
|
1972
|
+
strikethrough: [9, 29]
|
|
1973
|
+
},
|
|
1974
|
+
color: {
|
|
1975
|
+
black: [30, 39],
|
|
1976
|
+
red: [31, 39],
|
|
1977
|
+
green: [32, 39],
|
|
1978
|
+
yellow: [33, 39],
|
|
1979
|
+
blue: [34, 39],
|
|
1980
|
+
magenta: [35, 39],
|
|
1981
|
+
cyan: [36, 39],
|
|
1982
|
+
white: [37, 39],
|
|
1983
|
+
// Bright color
|
|
1984
|
+
blackBright: [90, 39],
|
|
1985
|
+
gray: [90, 39],
|
|
1986
|
+
// Alias of `blackBright`
|
|
1987
|
+
grey: [90, 39],
|
|
1988
|
+
// Alias of `blackBright`
|
|
1989
|
+
redBright: [91, 39],
|
|
1990
|
+
greenBright: [92, 39],
|
|
1991
|
+
yellowBright: [93, 39],
|
|
1992
|
+
blueBright: [94, 39],
|
|
1993
|
+
magentaBright: [95, 39],
|
|
1994
|
+
cyanBright: [96, 39],
|
|
1995
|
+
whiteBright: [97, 39]
|
|
1996
|
+
},
|
|
1997
|
+
bgColor: {
|
|
1998
|
+
bgBlack: [40, 49],
|
|
1999
|
+
bgRed: [41, 49],
|
|
2000
|
+
bgGreen: [42, 49],
|
|
2001
|
+
bgYellow: [43, 49],
|
|
2002
|
+
bgBlue: [44, 49],
|
|
2003
|
+
bgMagenta: [45, 49],
|
|
2004
|
+
bgCyan: [46, 49],
|
|
2005
|
+
bgWhite: [47, 49],
|
|
2006
|
+
// Bright color
|
|
2007
|
+
bgBlackBright: [100, 49],
|
|
2008
|
+
bgGray: [100, 49],
|
|
2009
|
+
// Alias of `bgBlackBright`
|
|
2010
|
+
bgGrey: [100, 49],
|
|
2011
|
+
// Alias of `bgBlackBright`
|
|
2012
|
+
bgRedBright: [101, 49],
|
|
2013
|
+
bgGreenBright: [102, 49],
|
|
2014
|
+
bgYellowBright: [103, 49],
|
|
2015
|
+
bgBlueBright: [104, 49],
|
|
2016
|
+
bgMagentaBright: [105, 49],
|
|
2017
|
+
bgCyanBright: [106, 49],
|
|
2018
|
+
bgWhiteBright: [107, 49]
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
2022
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
2023
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
2024
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
2025
|
+
function assembleStyles() {
|
|
2026
|
+
const codes = /* @__PURE__ */ new Map();
|
|
2027
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
2028
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
2029
|
+
styles[styleName] = {
|
|
2030
|
+
open: `\x1B[${style[0]}m`,
|
|
2031
|
+
close: `\x1B[${style[1]}m`
|
|
2032
|
+
};
|
|
2033
|
+
group[styleName] = styles[styleName];
|
|
2034
|
+
codes.set(style[0], style[1]);
|
|
2035
|
+
}
|
|
2036
|
+
Object.defineProperty(styles, groupName, {
|
|
2037
|
+
value: group,
|
|
2038
|
+
enumerable: false
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
Object.defineProperty(styles, "codes", {
|
|
2042
|
+
value: codes,
|
|
2043
|
+
enumerable: false
|
|
2044
|
+
});
|
|
2045
|
+
styles.color.close = "\x1B[39m";
|
|
2046
|
+
styles.bgColor.close = "\x1B[49m";
|
|
2047
|
+
styles.color.ansi = wrapAnsi16();
|
|
2048
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
2049
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
2050
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
2051
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
2052
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
2053
|
+
Object.defineProperties(styles, {
|
|
2054
|
+
rgbToAnsi256: {
|
|
2055
|
+
value(red, green, blue) {
|
|
2056
|
+
if (red === green && green === blue) {
|
|
2057
|
+
if (red < 8) {
|
|
2058
|
+
return 16;
|
|
2059
|
+
}
|
|
2060
|
+
if (red > 248) {
|
|
2061
|
+
return 231;
|
|
2062
|
+
}
|
|
2063
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
2064
|
+
}
|
|
2065
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
2066
|
+
},
|
|
2067
|
+
enumerable: false
|
|
2068
|
+
},
|
|
2069
|
+
hexToRgb: {
|
|
2070
|
+
value(hex) {
|
|
2071
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
2072
|
+
if (!matches) {
|
|
2073
|
+
return [0, 0, 0];
|
|
2074
|
+
}
|
|
2075
|
+
let [colorString] = matches;
|
|
2076
|
+
if (colorString.length === 3) {
|
|
2077
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
2078
|
+
}
|
|
2079
|
+
const integer = Number.parseInt(colorString, 16);
|
|
2080
|
+
return [
|
|
2081
|
+
/* eslint-disable no-bitwise */
|
|
2082
|
+
integer >> 16 & 255,
|
|
2083
|
+
integer >> 8 & 255,
|
|
2084
|
+
integer & 255
|
|
2085
|
+
/* eslint-enable no-bitwise */
|
|
2086
|
+
];
|
|
2087
|
+
},
|
|
2088
|
+
enumerable: false
|
|
2089
|
+
},
|
|
2090
|
+
hexToAnsi256: {
|
|
2091
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
2092
|
+
enumerable: false
|
|
2093
|
+
},
|
|
2094
|
+
ansi256ToAnsi: {
|
|
2095
|
+
value(code) {
|
|
2096
|
+
if (code < 8) {
|
|
2097
|
+
return 30 + code;
|
|
2098
|
+
}
|
|
2099
|
+
if (code < 16) {
|
|
2100
|
+
return 90 + (code - 8);
|
|
2101
|
+
}
|
|
2102
|
+
let red;
|
|
2103
|
+
let green;
|
|
2104
|
+
let blue;
|
|
2105
|
+
if (code >= 232) {
|
|
2106
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
2107
|
+
green = red;
|
|
2108
|
+
blue = red;
|
|
2109
|
+
} else {
|
|
2110
|
+
code -= 16;
|
|
2111
|
+
const remainder = code % 36;
|
|
2112
|
+
red = Math.floor(code / 36) / 5;
|
|
2113
|
+
green = Math.floor(remainder / 6) / 5;
|
|
2114
|
+
blue = remainder % 6 / 5;
|
|
2115
|
+
}
|
|
2116
|
+
const value = Math.max(red, green, blue) * 2;
|
|
2117
|
+
if (value === 0) {
|
|
2118
|
+
return 30;
|
|
2119
|
+
}
|
|
2120
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
2121
|
+
if (value === 2) {
|
|
2122
|
+
result += 60;
|
|
2123
|
+
}
|
|
2124
|
+
return result;
|
|
2125
|
+
},
|
|
2126
|
+
enumerable: false
|
|
2127
|
+
},
|
|
2128
|
+
rgbToAnsi: {
|
|
2129
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
2130
|
+
enumerable: false
|
|
2131
|
+
},
|
|
2132
|
+
hexToAnsi: {
|
|
2133
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
2134
|
+
enumerable: false
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
return styles;
|
|
2138
|
+
}
|
|
2139
|
+
var ansiStyles = assembleStyles();
|
|
2140
|
+
var ansi_styles_default = ansiStyles;
|
|
2141
|
+
|
|
2142
|
+
// node_modules/chalk/source/vendor/supports-color/browser.js
|
|
2143
|
+
var level = (() => {
|
|
2144
|
+
if (!("navigator" in globalThis)) {
|
|
2145
|
+
return 0;
|
|
2146
|
+
}
|
|
2147
|
+
if (globalThis.navigator.userAgentData) {
|
|
2148
|
+
const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium");
|
|
2149
|
+
if (brand && brand.version > 93) {
|
|
2150
|
+
return 3;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
|
|
2154
|
+
return 1;
|
|
2155
|
+
}
|
|
2156
|
+
return 0;
|
|
2157
|
+
})();
|
|
2158
|
+
var colorSupport = level !== 0 && {
|
|
2159
|
+
level,
|
|
2160
|
+
hasBasic: true,
|
|
2161
|
+
has256: level >= 2,
|
|
2162
|
+
has16m: level >= 3
|
|
2163
|
+
};
|
|
2164
|
+
var supportsColor = {
|
|
2165
|
+
stdout: colorSupport,
|
|
2166
|
+
stderr: colorSupport
|
|
2167
|
+
};
|
|
2168
|
+
var browser_default = supportsColor;
|
|
2169
|
+
|
|
2170
|
+
// node_modules/chalk/source/utilities.js
|
|
2171
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
2172
|
+
let index = string.indexOf(substring);
|
|
2173
|
+
if (index === -1) {
|
|
2174
|
+
return string;
|
|
2175
|
+
}
|
|
2176
|
+
const substringLength = substring.length;
|
|
2177
|
+
let endIndex = 0;
|
|
2178
|
+
let returnValue = "";
|
|
2179
|
+
do {
|
|
2180
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
2181
|
+
endIndex = index + substringLength;
|
|
2182
|
+
index = string.indexOf(substring, endIndex);
|
|
2183
|
+
} while (index !== -1);
|
|
2184
|
+
returnValue += string.slice(endIndex);
|
|
2185
|
+
return returnValue;
|
|
2186
|
+
}
|
|
2187
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
2188
|
+
let endIndex = 0;
|
|
2189
|
+
let returnValue = "";
|
|
2190
|
+
do {
|
|
2191
|
+
const gotCR = string[index - 1] === "\r";
|
|
2192
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
2193
|
+
endIndex = index + 1;
|
|
2194
|
+
index = string.indexOf("\n", endIndex);
|
|
2195
|
+
} while (index !== -1);
|
|
2196
|
+
returnValue += string.slice(endIndex);
|
|
2197
|
+
return returnValue;
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
// node_modules/chalk/source/index.js
|
|
2201
|
+
var { stdout: stdoutColor, stderr: stderrColor } = browser_default;
|
|
2202
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
2203
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
2204
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
2205
|
+
var levelMapping = [
|
|
2206
|
+
"ansi",
|
|
2207
|
+
"ansi",
|
|
2208
|
+
"ansi256",
|
|
2209
|
+
"ansi16m"
|
|
2210
|
+
];
|
|
2211
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
2212
|
+
var applyOptions = (object, options = {}) => {
|
|
2213
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
2214
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
2215
|
+
}
|
|
2216
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
2217
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
2218
|
+
};
|
|
2219
|
+
var chalkFactory = (options) => {
|
|
2220
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
2221
|
+
applyOptions(chalk2, options);
|
|
2222
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
2223
|
+
return chalk2;
|
|
2224
|
+
};
|
|
2225
|
+
function createChalk(options) {
|
|
2226
|
+
return chalkFactory(options);
|
|
2227
|
+
}
|
|
2228
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
2229
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
2230
|
+
styles2[styleName] = {
|
|
2231
|
+
get() {
|
|
2232
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
2233
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
2234
|
+
return builder;
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
styles2.visible = {
|
|
2239
|
+
get() {
|
|
2240
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
2241
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
2242
|
+
return builder;
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
var getModelAnsi = (model, level2, type, ...arguments_) => {
|
|
2246
|
+
if (model === "rgb") {
|
|
2247
|
+
if (level2 === "ansi16m") {
|
|
2248
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
2249
|
+
}
|
|
2250
|
+
if (level2 === "ansi256") {
|
|
2251
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
2252
|
+
}
|
|
2253
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
2254
|
+
}
|
|
2255
|
+
if (model === "hex") {
|
|
2256
|
+
return getModelAnsi("rgb", level2, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
2257
|
+
}
|
|
2258
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
2259
|
+
};
|
|
2260
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
2261
|
+
for (const model of usedModels) {
|
|
2262
|
+
styles2[model] = {
|
|
2263
|
+
get() {
|
|
2264
|
+
const { level: level2 } = this;
|
|
2265
|
+
return function(...arguments_) {
|
|
2266
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level2], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
2267
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
2272
|
+
styles2[bgModel] = {
|
|
2273
|
+
get() {
|
|
2274
|
+
const { level: level2 } = this;
|
|
2275
|
+
return function(...arguments_) {
|
|
2276
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level2], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
2277
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
var proto = Object.defineProperties(() => {
|
|
2283
|
+
}, {
|
|
2284
|
+
...styles2,
|
|
2285
|
+
level: {
|
|
2286
|
+
enumerable: true,
|
|
2287
|
+
get() {
|
|
2288
|
+
return this[GENERATOR].level;
|
|
2289
|
+
},
|
|
2290
|
+
set(level2) {
|
|
2291
|
+
this[GENERATOR].level = level2;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
});
|
|
2295
|
+
var createStyler = (open, close, parent) => {
|
|
2296
|
+
let openAll;
|
|
2297
|
+
let closeAll;
|
|
2298
|
+
if (parent === void 0) {
|
|
2299
|
+
openAll = open;
|
|
2300
|
+
closeAll = close;
|
|
2301
|
+
} else {
|
|
2302
|
+
openAll = parent.openAll + open;
|
|
2303
|
+
closeAll = close + parent.closeAll;
|
|
2304
|
+
}
|
|
2305
|
+
return {
|
|
2306
|
+
open,
|
|
2307
|
+
close,
|
|
2308
|
+
openAll,
|
|
2309
|
+
closeAll,
|
|
2310
|
+
parent
|
|
2311
|
+
};
|
|
2312
|
+
};
|
|
2313
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
2314
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
2315
|
+
Object.setPrototypeOf(builder, proto);
|
|
2316
|
+
builder[GENERATOR] = self;
|
|
2317
|
+
builder[STYLER] = _styler;
|
|
2318
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
2319
|
+
return builder;
|
|
2320
|
+
};
|
|
2321
|
+
var applyStyle = (self, string) => {
|
|
2322
|
+
if (self.level <= 0 || !string) {
|
|
2323
|
+
return self[IS_EMPTY] ? "" : string;
|
|
2324
|
+
}
|
|
2325
|
+
let styler = self[STYLER];
|
|
2326
|
+
if (styler === void 0) {
|
|
2327
|
+
return string;
|
|
2328
|
+
}
|
|
2329
|
+
const { openAll, closeAll } = styler;
|
|
2330
|
+
if (string.includes("\x1B")) {
|
|
2331
|
+
while (styler !== void 0) {
|
|
2332
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
2333
|
+
styler = styler.parent;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
const lfIndex = string.indexOf("\n");
|
|
2337
|
+
if (lfIndex !== -1) {
|
|
2338
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
2339
|
+
}
|
|
2340
|
+
return openAll + string + closeAll;
|
|
2341
|
+
};
|
|
2342
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
2343
|
+
var chalk = createChalk();
|
|
2344
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2345
|
+
var source_default = chalk;
|
|
2346
|
+
|
|
2347
|
+
// src/compiler/Chain.ts
|
|
2348
|
+
var currentTokenContext2 = null;
|
|
2349
|
+
function setTokenContext(context) {
|
|
2350
|
+
currentTokenContext2 = context;
|
|
2351
|
+
}
|
|
2352
|
+
function getTokenContext() {
|
|
2353
|
+
return currentTokenContext2;
|
|
2354
|
+
}
|
|
2355
|
+
var debugMode = false;
|
|
2356
|
+
function enableDebug(enable = true) {
|
|
2357
|
+
debugMode = enable;
|
|
2358
|
+
if (enable) {
|
|
2359
|
+
console.log("\u{1F50D} ChainCSS Debug Mode Enabled");
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
var PUBLIC_METHODS = /* @__PURE__ */ new Set([
|
|
2363
|
+
// Finalizers
|
|
2364
|
+
"$el",
|
|
2365
|
+
"end",
|
|
2366
|
+
// State & Nesting
|
|
2367
|
+
"hover",
|
|
2368
|
+
"use",
|
|
2369
|
+
"when",
|
|
2370
|
+
"nest",
|
|
2371
|
+
// Component
|
|
2372
|
+
"component",
|
|
2373
|
+
"componentName",
|
|
2374
|
+
"props",
|
|
2375
|
+
// Responsive & AT-Rules
|
|
2376
|
+
"responsive",
|
|
2377
|
+
"media",
|
|
2378
|
+
"supports",
|
|
2379
|
+
"containerQuery",
|
|
2380
|
+
"layer",
|
|
2381
|
+
"keyframes",
|
|
2382
|
+
"fontFace",
|
|
2383
|
+
// Animations
|
|
2384
|
+
"animation",
|
|
2385
|
+
"animate",
|
|
2386
|
+
"duration",
|
|
2387
|
+
"delay",
|
|
2388
|
+
"timing",
|
|
2389
|
+
"iteration",
|
|
2390
|
+
"infinite",
|
|
2391
|
+
// Math Helpers
|
|
2392
|
+
"calc",
|
|
2393
|
+
"add",
|
|
2394
|
+
"subtract",
|
|
2395
|
+
"sub",
|
|
2396
|
+
"multiply",
|
|
2397
|
+
"mul",
|
|
2398
|
+
"divide",
|
|
2399
|
+
"div",
|
|
2400
|
+
"mpx",
|
|
2401
|
+
"rem",
|
|
2402
|
+
"em",
|
|
2403
|
+
"percent",
|
|
2404
|
+
"vw",
|
|
2405
|
+
"vh",
|
|
2406
|
+
"min",
|
|
2407
|
+
"max",
|
|
2408
|
+
"clamp",
|
|
2409
|
+
// Meta
|
|
2410
|
+
"debug",
|
|
2411
|
+
"explain"
|
|
2412
|
+
]);
|
|
2413
|
+
var ChainClass = class {
|
|
2414
|
+
catcher = {};
|
|
2415
|
+
useTokens;
|
|
2416
|
+
hoverCatcher = null;
|
|
2417
|
+
valueCache = /* @__PURE__ */ new Map();
|
|
2418
|
+
MAX_CACHE_SIZE = 200;
|
|
2419
|
+
__proxy = null;
|
|
2420
|
+
constructor(useTokens = true) {
|
|
2421
|
+
this.useTokens = useTokens;
|
|
2422
|
+
}
|
|
2423
|
+
// ==========================================================================
|
|
2424
|
+
// Core Methods
|
|
2425
|
+
// ==========================================================================
|
|
2426
|
+
resolveValue(value) {
|
|
2427
|
+
const cacheKey = typeof value === "function" ? `fn_${value.toString().slice(0, 100)}` : JSON.stringify(value);
|
|
2428
|
+
if (this.valueCache.has(cacheKey)) {
|
|
2429
|
+
return this.valueCache.get(cacheKey);
|
|
2430
|
+
}
|
|
2431
|
+
let resolved = value;
|
|
2432
|
+
if (typeof value === "function") {
|
|
2433
|
+
resolved = value(helpers);
|
|
2434
|
+
}
|
|
2435
|
+
if (this.useTokens && typeof resolved === "string" && resolved.includes("$")) {
|
|
2436
|
+
const tokenResolved = resolveToken(resolved, this.useTokens, currentTokenContext2);
|
|
2437
|
+
resolved = tokenResolved !== void 0 && tokenResolved !== null ? tokenResolved : resolved;
|
|
2438
|
+
}
|
|
2439
|
+
if (this.valueCache.size >= this.MAX_CACHE_SIZE) {
|
|
2440
|
+
const firstKey = this.valueCache.keys().next().value;
|
|
2441
|
+
if (firstKey) this.valueCache.delete(firstKey);
|
|
2442
|
+
}
|
|
2443
|
+
this.valueCache.set(cacheKey, resolved);
|
|
2444
|
+
return resolved;
|
|
2445
|
+
}
|
|
2446
|
+
setTransform(type, value) {
|
|
2447
|
+
if (!this.catcher._transforms) this.catcher._transforms = {};
|
|
2448
|
+
this.catcher._transforms[type] = this.resolveValue(value);
|
|
2449
|
+
return this.__proxy || this;
|
|
2450
|
+
}
|
|
2451
|
+
setProperty(prop, value) {
|
|
2452
|
+
if (handleShorthand(prop, value, this.catcher, this.useTokens)) {
|
|
2453
|
+
return this.__proxy || this;
|
|
2454
|
+
}
|
|
2455
|
+
const mappedProp = shorthandMap[prop] || prop;
|
|
2456
|
+
let resolvedValue = this.resolveValue(value);
|
|
2457
|
+
if (debugMode) {
|
|
2458
|
+
const displayProp = prop === mappedProp ? prop : `${prop} (${mappedProp})`;
|
|
2459
|
+
console.log(
|
|
2460
|
+
source_default.blue(`[ChainCSS Debug]`),
|
|
2461
|
+
source_default.gray(displayProp),
|
|
2462
|
+
"->",
|
|
2463
|
+
source_default.green(resolvedValue)
|
|
2464
|
+
);
|
|
2465
|
+
}
|
|
2466
|
+
const unitlessProperties = /* @__PURE__ */ new Set([
|
|
2467
|
+
"zIndex",
|
|
2468
|
+
"opacity",
|
|
2469
|
+
"flex",
|
|
2470
|
+
"order",
|
|
2471
|
+
"flexGrow",
|
|
2472
|
+
"flexShrink",
|
|
2473
|
+
"flexBasis",
|
|
2474
|
+
"fontWeight",
|
|
2475
|
+
"lineHeight",
|
|
2476
|
+
"scale",
|
|
2477
|
+
"zoom",
|
|
2478
|
+
"animationIterationCount",
|
|
2479
|
+
"columnCount",
|
|
2480
|
+
"orphans",
|
|
2481
|
+
"widows",
|
|
2482
|
+
"tabSize"
|
|
2483
|
+
]);
|
|
2484
|
+
if (typeof resolvedValue === "number" && !unitlessProperties.has(prop) && !unitlessProperties.has(mappedProp)) {
|
|
2485
|
+
resolvedValue = `${resolvedValue}px`;
|
|
2486
|
+
}
|
|
2487
|
+
if (this.hoverCatcher !== null) {
|
|
2488
|
+
this.hoverCatcher[mappedProp] = resolvedValue;
|
|
2489
|
+
} else {
|
|
2490
|
+
this.catcher[mappedProp] = resolvedValue;
|
|
2491
|
+
}
|
|
2492
|
+
return this.__proxy || this;
|
|
2493
|
+
}
|
|
2494
|
+
// ==========================================================================
|
|
2495
|
+
// Proxy handler - routes all property access
|
|
2496
|
+
// ==========================================================================
|
|
2497
|
+
get(prop) {
|
|
2498
|
+
if (typeof prop === "symbol") return void 0;
|
|
2499
|
+
if (prop === "mx") return (value) => this.macroHandler("mx", value);
|
|
2500
|
+
if (prop === "my") return (value) => this.macroHandler("my", value);
|
|
2501
|
+
if (prop === "px") return (value) => this.macroHandler("px", value);
|
|
2502
|
+
if (prop === "py") return (value) => this.macroHandler("py", value);
|
|
2503
|
+
if (prop === "size") return (value) => this.macroHandler("size", value);
|
|
2504
|
+
if (prop === "inset") return (value) => this.macroHandler("inset", value);
|
|
2505
|
+
if (prop === "insetX") return (value) => this.macroHandler("insetX", value);
|
|
2506
|
+
if (prop === "insetY") return (value) => this.macroHandler("insetY", value);
|
|
2507
|
+
if (prop === "borderX") return (value) => this.macroHandler("borderX", value);
|
|
2508
|
+
if (prop === "borderY") return (value) => this.macroHandler("borderY", value);
|
|
2509
|
+
if (prop === "flex") return (value) => this.macroHandler("flex", value);
|
|
2510
|
+
if (prop === "inlineFlex") return (value) => this.macroHandler("inlineFlex", value);
|
|
2511
|
+
if (prop === "grid") return (value) => this.macroHandler("grid", value);
|
|
2512
|
+
if (prop === "inlineGrid") return (value) => this.macroHandler("inlineGrid", value);
|
|
2513
|
+
if (prop === "cols") return (value) => this.macroHandler("cols", value);
|
|
2514
|
+
if (prop === "rows") return (value) => this.macroHandler("rows", value);
|
|
2515
|
+
if (prop === "center") return (type) => this.macroHandler("center", type);
|
|
2516
|
+
if (prop === "flexCenter") return (dir) => this.macroHandler("flexCenter", dir);
|
|
2517
|
+
if (prop === "gridCenter") return () => this.macroHandler("gridCenter");
|
|
2518
|
+
if (prop === "stack") return (config) => this.macroHandler("stack", config);
|
|
2519
|
+
if (prop === "gridTable") return (minWidth) => this.macroHandler("gridTable", minWidth);
|
|
2520
|
+
if (prop === "aspect") return (ratio) => this.macroHandler("aspect", ratio);
|
|
2521
|
+
if (prop === "hide") return () => this.macroHandler("hide");
|
|
2522
|
+
if (prop === "show") return () => this.macroHandler("show");
|
|
2523
|
+
if (prop === "unselectable") return () => this.macroHandler("unselectable");
|
|
2524
|
+
if (prop === "scrollable") return (axis) => this.macroHandler("scrollable", axis);
|
|
2525
|
+
if (prop === "safeArea") return (edge) => this.macroHandler("safeArea", edge);
|
|
2526
|
+
if (prop === "absolute") return (coords) => this.macroHandler("absolute", coords);
|
|
2527
|
+
if (prop === "fixed") return (coords) => this.macroHandler("fixed", coords);
|
|
2528
|
+
if (prop === "sticky") return (coords) => this.macroHandler("sticky", coords);
|
|
2529
|
+
if (prop === "relative") return (coords) => this.macroHandler("relative", coords);
|
|
2530
|
+
if (prop === "circle") return (size) => this.macroHandler("circle", size);
|
|
2531
|
+
if (prop === "square") return (size) => this.macroHandler("square", size);
|
|
2532
|
+
if (prop === "truncate") return () => this.macroHandler("truncate");
|
|
2533
|
+
if (prop === "fluidText") return (config) => this.macroHandler("fluidText", config);
|
|
2534
|
+
if (prop === "glass") return (blur) => this.macroHandler("glass", blur);
|
|
2535
|
+
if (prop === "glow") return (config) => this.macroHandler("glow", config);
|
|
2536
|
+
if (prop === "textGradient") return (colors) => this.macroHandler("textGradient", colors);
|
|
2537
|
+
if (prop === "meshGradient") return (colors) => this.macroHandler("meshGradient", colors);
|
|
2538
|
+
if (prop === "noise") return (opacity) => this.macroHandler("noise", opacity);
|
|
2539
|
+
if (prop === "skeleton") return (active) => this.macroHandler("skeleton", active);
|
|
2540
|
+
if (prop === "clickScale") return (amount) => this.macroHandler("clickScale", amount);
|
|
2541
|
+
if (prop === "onInteracting") return (callback) => this.macroHandler("onInteracting", callback);
|
|
2542
|
+
if (prop === "children") return (callback) => this.macroHandler("children", callback);
|
|
2543
|
+
if (prop === "dark") return (callback) => this.macroHandler("dark", callback);
|
|
2544
|
+
if (prop === "light") return (callback) => this.macroHandler("light", callback);
|
|
2545
|
+
if (prop === "pill") return () => this.macroHandler("pill");
|
|
2546
|
+
if (prop === "containerMacro") return (maxWidth) => this.macroHandler("containerMacro", maxWidth);
|
|
2547
|
+
if (prop === "fullScreen") return (zIndex) => this.macroHandler("fullScreen", zIndex);
|
|
2548
|
+
if (prop === "shimmer") return () => this.macroHandler("shimmer");
|
|
2549
|
+
if (prop === "bento") return (cols) => this.macroHandler("bento", cols);
|
|
2550
|
+
if (prop === "pressable") return () => this.macroHandler("pressable");
|
|
2551
|
+
if (prop === "focusRing") return (color) => this.macroHandler("focusRing", color);
|
|
2552
|
+
if (prop === "outlineDebug") return () => this.macroHandler("outlineDebug");
|
|
2553
|
+
if (prop === "parallax") return (scale) => this.macroHandler("parallax", scale);
|
|
2554
|
+
if (prop === "lineClamp") return (lines) => this.macroHandler("lineClamp", lines);
|
|
2555
|
+
if (prop === "frostedNav") return (blur) => this.macroHandler("frostedNav", blur);
|
|
2556
|
+
if (prop === "gap") return (value) => this.setProperty("gap", value);
|
|
2557
|
+
if (prop === "gapX") return (value) => this.setProperty("columnGap", value);
|
|
2558
|
+
if (prop === "gapY") return (value) => this.setProperty("rowGap", value);
|
|
2559
|
+
if (prop === "hover") return this.createHover.bind(this);
|
|
2560
|
+
if (prop === "end") return this.endHover.bind(this);
|
|
2561
|
+
if (prop === "use") return this.useMixin.bind(this);
|
|
2562
|
+
if (prop === "when") return this.whenCondition.bind(this);
|
|
2563
|
+
if (prop === "nest") return this.nestSelector.bind(this);
|
|
2564
|
+
if (prop === "component") return this.setComponent.bind(this);
|
|
2565
|
+
if (prop === "componentName") return this.setComponentName.bind(this);
|
|
2566
|
+
if (prop === "props") return this.setProps.bind(this);
|
|
2567
|
+
if (prop === "debug") return this.enableDebugMode.bind(this);
|
|
2568
|
+
if (prop === "explain") return this.explainShorthand.bind(this);
|
|
2569
|
+
if (prop === "$el") return this.finalize.bind(this);
|
|
2570
|
+
if (prop === "scale") return (value) => this.setTransform("scale", value);
|
|
2571
|
+
if (prop === "rotate") return (value) => this.setTransform("rotate", value);
|
|
2572
|
+
if (prop === "x") return (value) => this.setTransform("translateX", value);
|
|
2573
|
+
if (prop === "y") return (value) => this.setTransform("translateY", value);
|
|
2574
|
+
if (prop === "skew") return (value) => this.setTransform("skew", value);
|
|
2575
|
+
if (animationPresets[prop]) {
|
|
2576
|
+
return (config) => this.applyAnimation(prop, config);
|
|
2577
|
+
}
|
|
2578
|
+
if (prop === "animate") return this.createAnimation.bind(this);
|
|
2579
|
+
if (prop === "duration") return (v) => this.setProperty("animationDuration", v);
|
|
2580
|
+
if (prop === "delay") return (v) => this.setProperty("animationDelay", v);
|
|
2581
|
+
if (prop === "timing") return (v) => this.setProperty("animationTimingFunction", v);
|
|
2582
|
+
if (prop === "iteration") return (v) => this.setProperty("animationIterationCount", v);
|
|
2583
|
+
if (prop === "infinite") return () => this.setProperty("animationIterationCount", "infinite");
|
|
2584
|
+
if (prop === "calc") return helpers.calc;
|
|
2585
|
+
if (prop === "add") return helpers.add;
|
|
2586
|
+
if (prop === "subtract" || prop === "sub") return helpers.subtract;
|
|
2587
|
+
if (prop === "multiply" || prop === "mul") return helpers.multiply;
|
|
2588
|
+
if (prop === "divide" || prop === "div") return helpers.divide;
|
|
2589
|
+
if (prop === "mpx") return (v) => helpers.mpx(v);
|
|
2590
|
+
if (prop === "rem") return (v) => helpers.rem(v);
|
|
2591
|
+
if (prop === "em") return helpers.em;
|
|
2592
|
+
if (prop === "percent") return helpers.percent;
|
|
2593
|
+
if (prop === "vw") return helpers.vw;
|
|
2594
|
+
if (prop === "vh") return helpers.vh;
|
|
2595
|
+
if (prop === "min") return helpers.min;
|
|
2596
|
+
if (prop === "max") return helpers.max;
|
|
2597
|
+
if (prop === "clamp") return helpers.clamp;
|
|
2598
|
+
if (currentBreakpoints && currentBreakpoints[prop]) {
|
|
2599
|
+
return (callback) => this.applyResponsive(prop, callback);
|
|
2600
|
+
}
|
|
2601
|
+
if (prop === "media") return this.applyMedia.bind(this);
|
|
2602
|
+
if (prop === "keyframes") return this.defineKeyframes.bind(this);
|
|
2603
|
+
if (prop === "fontFace") return this.defineFontFace.bind(this);
|
|
2604
|
+
if (prop === "supports") return this.applySupports.bind(this);
|
|
2605
|
+
if (prop === "containerQuery") return this.applyContainerQuery.bind(this);
|
|
2606
|
+
if (prop === "layer") return this.applyLayer.bind(this);
|
|
2607
|
+
return (value) => this.setProperty(prop, value);
|
|
2608
|
+
}
|
|
2609
|
+
// ==========================================================================
|
|
2610
|
+
// Finalize
|
|
2611
|
+
// ==========================================================================
|
|
2612
|
+
finalize(...selectors) {
|
|
2613
|
+
const styles3 = structuredClone(this.catcher);
|
|
2614
|
+
delete styles3._componentName;
|
|
2615
|
+
delete styles3._generateComponent;
|
|
2616
|
+
delete styles3._framework;
|
|
2617
|
+
delete styles3._propsDefinition;
|
|
2618
|
+
if (this.catcher._transforms) {
|
|
2619
|
+
const t = this.catcher._transforms;
|
|
2620
|
+
const transformString = Object.entries(t).map(([k, v]) => {
|
|
2621
|
+
const needsUnit = k.includes("translate") || k === "x" || k === "y";
|
|
2622
|
+
const unit = needsUnit && typeof v === "number" ? "px" : "";
|
|
2623
|
+
return `${k}(${v}${unit})`;
|
|
2624
|
+
}).join(" ");
|
|
2625
|
+
styles3.transform = transformString;
|
|
2626
|
+
delete styles3._transforms;
|
|
2627
|
+
}
|
|
2628
|
+
if (this.catcher.nestedRules) {
|
|
2629
|
+
styles3.nestedRules = structuredClone(this.catcher.nestedRules);
|
|
2630
|
+
}
|
|
2631
|
+
for (const key of Object.keys(styles3)) {
|
|
2632
|
+
if (key.startsWith("&:")) {
|
|
2633
|
+
const pseudoSelector = key.substring(1);
|
|
2634
|
+
styles3[pseudoSelector] = styles3[key];
|
|
2635
|
+
delete styles3[key];
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
this.clear();
|
|
2639
|
+
if (selectors.length === 0) return styles3;
|
|
2640
|
+
if (debugMode) {
|
|
2641
|
+
console.log("[ChainCSS Debug] Raw selectors:", selectors);
|
|
2642
|
+
}
|
|
2643
|
+
const cleanSelectors = selectors.map((selector) => {
|
|
2644
|
+
let clean = selector;
|
|
2645
|
+
if (clean.startsWith(".chain-")) {
|
|
2646
|
+
clean = clean.replace(/^\./, "").replace(/^chain-/, "");
|
|
2647
|
+
} else if (clean.startsWith("chain-")) {
|
|
2648
|
+
clean = clean.substring(6);
|
|
2649
|
+
}
|
|
2650
|
+
if (debugMode) {
|
|
2651
|
+
console.log(`[ChainCSS Debug] Cleaned: "${selector}" -> "${clean}"`);
|
|
2652
|
+
}
|
|
2653
|
+
return clean;
|
|
2654
|
+
});
|
|
2655
|
+
if (debugMode) {
|
|
2656
|
+
console.log("[ChainCSS Debug] Final selectors:", cleanSelectors);
|
|
2657
|
+
}
|
|
2658
|
+
return {
|
|
2659
|
+
selectors: cleanSelectors,
|
|
2660
|
+
...styles3
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
// ==========================================================================
|
|
2664
|
+
// Public Method Implementations (renamed to avoid collisions)
|
|
2665
|
+
// ==========================================================================
|
|
2666
|
+
macroHandler(macroName, value) {
|
|
2667
|
+
const macroFn = macros[macroName];
|
|
2668
|
+
if (macroFn) {
|
|
2669
|
+
macroFn(value, this.catcher, this.useTokens);
|
|
2670
|
+
} else {
|
|
2671
|
+
this.setProperty(macroName, value);
|
|
2672
|
+
}
|
|
2673
|
+
return this.__proxy || this;
|
|
2674
|
+
}
|
|
2675
|
+
createHover() {
|
|
2676
|
+
if (debugMode) {
|
|
2677
|
+
console.log(` \u{1F5B1}\uFE0F Hover styles added`);
|
|
2678
|
+
}
|
|
2679
|
+
this.hoverCatcher = {};
|
|
2680
|
+
return this.__proxy || this;
|
|
2681
|
+
}
|
|
2682
|
+
endHover() {
|
|
2683
|
+
if (this.hoverCatcher !== null) {
|
|
2684
|
+
this.catcher.hover = { ...this.hoverCatcher };
|
|
2685
|
+
this.hoverCatcher = null;
|
|
2686
|
+
}
|
|
2687
|
+
return this.__proxy || this;
|
|
2688
|
+
}
|
|
2689
|
+
useMixin(mixin) {
|
|
2690
|
+
const { selectors, atRules, ...styles3 } = mixin;
|
|
2691
|
+
Object.assign(this.catcher, styles3);
|
|
2692
|
+
if (atRules) {
|
|
2693
|
+
this.catcher.atRules = [...this.catcher.atRules || [], ...atRules];
|
|
2694
|
+
}
|
|
2695
|
+
return this.__proxy || this;
|
|
2696
|
+
}
|
|
2697
|
+
whenCondition(condition, callback) {
|
|
2698
|
+
if (condition) {
|
|
2699
|
+
callback(this.__proxy || this);
|
|
2700
|
+
}
|
|
2701
|
+
return this.__proxy || this;
|
|
2702
|
+
}
|
|
2703
|
+
nestSelector(selector, callback) {
|
|
2704
|
+
const subChain = createChain(this.useTokens);
|
|
2705
|
+
callback(subChain);
|
|
2706
|
+
const result = subChain.$el();
|
|
2707
|
+
if (!this.catcher.nestedRules) this.catcher.nestedRules = [];
|
|
2708
|
+
this.catcher.nestedRules.push({
|
|
2709
|
+
selector,
|
|
2710
|
+
styles: result
|
|
2711
|
+
});
|
|
2712
|
+
return this.__proxy || this;
|
|
2713
|
+
}
|
|
2714
|
+
setComponentName(name) {
|
|
2715
|
+
this.catcher._componentName = name;
|
|
2716
|
+
return this.__proxy || this;
|
|
2717
|
+
}
|
|
2718
|
+
setComponent(framework = "auto") {
|
|
2719
|
+
this.catcher._generateComponent = true;
|
|
2720
|
+
this.catcher._framework = framework;
|
|
2721
|
+
return this.__proxy || this;
|
|
2722
|
+
}
|
|
2723
|
+
setProps(propsDefinition) {
|
|
2724
|
+
if (propsDefinition) {
|
|
2725
|
+
this.catcher._propsDefinition = propsDefinition;
|
|
2726
|
+
}
|
|
2727
|
+
return this.__proxy || this;
|
|
2728
|
+
}
|
|
2729
|
+
enableDebugMode() {
|
|
2730
|
+
debugMode = true;
|
|
2731
|
+
return this.__proxy || this;
|
|
2732
|
+
}
|
|
2733
|
+
explainShorthand(shorthand) {
|
|
2734
|
+
const mapped = shorthandMap[shorthand];
|
|
2735
|
+
if (mapped) {
|
|
2736
|
+
console.log(`
|
|
2737
|
+
\u{1F4D6} ChainCSS Explanation:`);
|
|
2738
|
+
console.log(` .${shorthand}() \u2192 ${mapped}`);
|
|
2739
|
+
console.log(` Example: .${shorthand}('value') sets CSS property '${mapped}'
|
|
2740
|
+
`);
|
|
2741
|
+
} else {
|
|
2742
|
+
const suggestion = getSuggestion(shorthand);
|
|
2743
|
+
if (suggestion && typeof suggestion === "string") {
|
|
2744
|
+
console.log(`
|
|
2745
|
+
\u26A0\uFE0F ChainCSS: '${shorthand}' is not a recognized shorthand.`);
|
|
2746
|
+
console.log(` Did you mean .${suggestion}()?
|
|
2747
|
+
`);
|
|
2748
|
+
} else {
|
|
2749
|
+
console.log(`
|
|
2750
|
+
\u26A0\uFE0F ChainCSS: '${shorthand}' is not a recognized shorthand or CSS property.
|
|
2751
|
+
`);
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
return this.__proxy || this;
|
|
2755
|
+
}
|
|
2756
|
+
// ==========================================================================
|
|
2757
|
+
// Animation Methods
|
|
2758
|
+
// ==========================================================================
|
|
2759
|
+
applyAnimation(name, config) {
|
|
2760
|
+
if (!name) {
|
|
2761
|
+
console.warn("\u26A0\uFE0F ChainCSS: animation() requires a name parameter");
|
|
2762
|
+
return this.__proxy || this;
|
|
2763
|
+
}
|
|
2764
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2765
|
+
const preset = animationPresets[name];
|
|
2766
|
+
if (!preset && !this.catcher.atRules.some((rule) => rule.type === "keyframes" && rule.name === name)) {
|
|
2767
|
+
console.warn(`\u26A0\uFE0F ChainCSS: Unknown animation preset '${name}'. Available: ${Object.keys(animationPresets).join(", ")}`);
|
|
2768
|
+
return this.__proxy || this;
|
|
2769
|
+
}
|
|
2770
|
+
const hasKeyframes = this.catcher.atRules.some(
|
|
2771
|
+
(rule) => rule.type === "keyframes" && rule.name === name
|
|
2772
|
+
);
|
|
2773
|
+
if (!hasKeyframes && preset) {
|
|
2774
|
+
this.catcher.atRules.push({
|
|
2775
|
+
type: "keyframes",
|
|
2776
|
+
name,
|
|
2777
|
+
steps: preset
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
const animationStyles = createAnimation(name, config);
|
|
2781
|
+
Object.assign(this.catcher, animationStyles);
|
|
2782
|
+
return this.__proxy || this;
|
|
2783
|
+
}
|
|
2784
|
+
createAnimation(name, keyframes, config) {
|
|
2785
|
+
if (!name || !keyframes) {
|
|
2786
|
+
console.warn("\u26A0\uFE0F ChainCSS: animate() requires name and keyframes parameters");
|
|
2787
|
+
return this.__proxy || this;
|
|
2788
|
+
}
|
|
2789
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2790
|
+
this.catcher.atRules.push({
|
|
2791
|
+
type: "keyframes",
|
|
2792
|
+
name,
|
|
2793
|
+
steps: keyframes
|
|
2794
|
+
});
|
|
2795
|
+
const animationStyles = createAnimation(name, config);
|
|
2796
|
+
Object.assign(this.catcher, animationStyles);
|
|
2797
|
+
return this.__proxy || this;
|
|
2798
|
+
}
|
|
2799
|
+
// ==========================================================================
|
|
2800
|
+
// Responsive & AT-Rules
|
|
2801
|
+
// ==========================================================================
|
|
2802
|
+
applyResponsive(breakpoint, callback) {
|
|
2803
|
+
const subChain = createChain(this.useTokens);
|
|
2804
|
+
callback(subChain);
|
|
2805
|
+
const result = subChain.$el();
|
|
2806
|
+
const { selectors, ...pureStyles } = result || {};
|
|
2807
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2808
|
+
this.catcher.atRules.push({
|
|
2809
|
+
type: "media",
|
|
2810
|
+
query: currentBreakpoints[breakpoint],
|
|
2811
|
+
styles: pureStyles
|
|
2812
|
+
});
|
|
2813
|
+
return this.__proxy || this;
|
|
2814
|
+
}
|
|
2815
|
+
applyMedia(query, callback) {
|
|
2816
|
+
const subChain = createChain(this.useTokens);
|
|
2817
|
+
callback(subChain);
|
|
2818
|
+
const result = subChain.$el();
|
|
2819
|
+
const { selectors, ...pureStyles } = result || {};
|
|
2820
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2821
|
+
this.catcher.atRules.push({
|
|
2822
|
+
type: "media",
|
|
2823
|
+
query,
|
|
2824
|
+
styles: pureStyles
|
|
2825
|
+
});
|
|
2826
|
+
return this.__proxy || this;
|
|
2827
|
+
}
|
|
2828
|
+
defineKeyframes(name, steps) {
|
|
2829
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2830
|
+
this.catcher.atRules.push({
|
|
2831
|
+
type: "keyframes",
|
|
2832
|
+
name,
|
|
2833
|
+
steps
|
|
2834
|
+
});
|
|
2835
|
+
return this.__proxy || this;
|
|
2836
|
+
}
|
|
2837
|
+
defineFontFace(properties) {
|
|
2838
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2839
|
+
this.catcher.atRules.push({
|
|
2840
|
+
type: "font-face",
|
|
2841
|
+
properties
|
|
2842
|
+
});
|
|
2843
|
+
return this.__proxy || this;
|
|
2844
|
+
}
|
|
2845
|
+
applySupports(condition, callback) {
|
|
2846
|
+
const subChain = createChain(this.useTokens);
|
|
2847
|
+
callback(subChain);
|
|
2848
|
+
const result = subChain.$el();
|
|
2849
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2850
|
+
this.catcher.atRules.push({
|
|
2851
|
+
type: "supports",
|
|
2852
|
+
condition,
|
|
2853
|
+
styles: result
|
|
2854
|
+
});
|
|
2855
|
+
return this.__proxy || this;
|
|
2856
|
+
}
|
|
2857
|
+
applyContainerQuery(condition, callback) {
|
|
2858
|
+
const subChain = createChain(this.useTokens);
|
|
2859
|
+
callback(subChain);
|
|
2860
|
+
const result = subChain.$el();
|
|
2861
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2862
|
+
this.catcher.atRules.push({
|
|
2863
|
+
type: "container",
|
|
2864
|
+
condition,
|
|
2865
|
+
styles: result
|
|
2866
|
+
});
|
|
2867
|
+
return this.__proxy || this;
|
|
2868
|
+
}
|
|
2869
|
+
applyLayer(name, callback) {
|
|
2870
|
+
const subChain = createChain(this.useTokens);
|
|
2871
|
+
callback(subChain);
|
|
2872
|
+
const result = subChain.$el();
|
|
2873
|
+
if (!this.catcher.atRules) this.catcher.atRules = [];
|
|
2874
|
+
this.catcher.atRules.push({
|
|
2875
|
+
type: "layer",
|
|
2876
|
+
name,
|
|
2877
|
+
styles: result
|
|
2878
|
+
});
|
|
2879
|
+
return this.__proxy || this;
|
|
2880
|
+
}
|
|
2881
|
+
// ==========================================================================
|
|
2882
|
+
// Cleanup
|
|
2883
|
+
// ==========================================================================
|
|
2884
|
+
clear() {
|
|
2885
|
+
this.catcher = {};
|
|
2886
|
+
this.hoverCatcher = null;
|
|
2887
|
+
this.valueCache.clear();
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
function createChain(useTokens = true) {
|
|
2891
|
+
const chained = new ChainClass(useTokens);
|
|
2892
|
+
const proxy = new Proxy(chained, {
|
|
2893
|
+
get(target, prop) {
|
|
2894
|
+
if (typeof prop === "symbol") return void 0;
|
|
2895
|
+
if (PUBLIC_METHODS.has(prop) && prop in target) {
|
|
2896
|
+
const val = target[prop];
|
|
2897
|
+
return typeof val === "function" ? val.bind(target) : val;
|
|
2898
|
+
}
|
|
2899
|
+
return target.get(prop);
|
|
2900
|
+
}
|
|
2901
|
+
});
|
|
2902
|
+
chained.__proxy = proxy;
|
|
2903
|
+
return proxy;
|
|
2904
|
+
}
|
|
2905
|
+
var chain = (useTokens = true) => createChain(useTokens);
|
|
2906
|
+
|
|
2907
|
+
// src/runtime/Chain.ts
|
|
2908
|
+
var debugMode2 = false;
|
|
2909
|
+
var runtimeMacros = { ...macros };
|
|
2910
|
+
var globalManifest = {};
|
|
2911
|
+
var setManifest = (manifest) => {
|
|
2912
|
+
if (manifest.atomicMap) {
|
|
2913
|
+
globalManifest = manifest.atomicMap;
|
|
2914
|
+
} else if (manifest.atomicClasses) {
|
|
2915
|
+
globalManifest = manifest.atomicClasses;
|
|
2916
|
+
} else {
|
|
2917
|
+
globalManifest = manifest || {};
|
|
2918
|
+
}
|
|
2919
|
+
if (debugMode2) {
|
|
2920
|
+
console.log("[ChainCSS] Manifest loaded with", Object.keys(globalManifest).length, "entries");
|
|
2921
|
+
}
|
|
2922
|
+
};
|
|
2923
|
+
var globalTokens = {};
|
|
2924
|
+
var setTokens = (tokens2) => {
|
|
2925
|
+
globalTokens = tokens2;
|
|
2926
|
+
if (debugMode2) {
|
|
2927
|
+
console.log("[ChainCSS] Tokens updated:", Object.keys(globalTokens));
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
var RuntimeChain = class _RuntimeChain {
|
|
2931
|
+
constructor(useTokens = false) {
|
|
2932
|
+
this.useTokens = useTokens;
|
|
2933
|
+
const PUBLIC_METHODS2 = /* @__PURE__ */ new Set([
|
|
2934
|
+
"use",
|
|
2935
|
+
"hover",
|
|
2936
|
+
"$el",
|
|
2937
|
+
"$name",
|
|
2938
|
+
"end",
|
|
2939
|
+
"getCatcher"
|
|
2940
|
+
]);
|
|
2941
|
+
this.proxy = new Proxy(this, {
|
|
2942
|
+
/**
|
|
2943
|
+
* 1. TRAPS FOR EXTERNAL TOOLS (React, DevTools, JSON.stringify)
|
|
2944
|
+
* This prevents the "cyclic object value" error.
|
|
2945
|
+
*/
|
|
2946
|
+
get: (target, prop) => {
|
|
2947
|
+
if (prop === "toJSON") return () => target.catcher;
|
|
2948
|
+
if (prop === "constructor") return _RuntimeChain;
|
|
2949
|
+
if (prop === Symbol.toStringTag) return "RuntimeChain";
|
|
2950
|
+
if (prop === "_isChain") return true;
|
|
2951
|
+
if (typeof prop !== "string") return target[prop];
|
|
2952
|
+
if (prop in target && PUBLIC_METHODS2.has(prop)) {
|
|
2953
|
+
const val = target[prop];
|
|
2954
|
+
return typeof val === "function" ? val.bind(target) : val;
|
|
2955
|
+
}
|
|
2956
|
+
if (prop in target && typeof target[prop] === "function") {
|
|
2957
|
+
if (debugMode2) {
|
|
2958
|
+
console.warn(`[ChainCSS] '${prop}' is an internal method, not part of the public API`);
|
|
2959
|
+
}
|
|
2960
|
+
return void 0;
|
|
2961
|
+
}
|
|
2962
|
+
const realProp = shorthandMap[prop] || prop;
|
|
2963
|
+
if (runtimeMacros[prop]) {
|
|
2964
|
+
return (val) => {
|
|
2965
|
+
runtimeMacros[prop](val, target.catcher, target.useTokens);
|
|
2966
|
+
return target.proxy;
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
return (val) => {
|
|
2970
|
+
let finalVal = val;
|
|
2971
|
+
let valueWithUnit = val;
|
|
2972
|
+
const unitless = ["opacity", "zIndex", "flex", "fontWeight", "flexGrow", "flexShrink", "flexBasis", "order", "lineHeight", "animationIterationCount", "orphans", "widows", "columnCount"];
|
|
2973
|
+
if (typeof finalVal === "number" && !unitless.includes(realProp)) {
|
|
2974
|
+
valueWithUnit = `${val}px`;
|
|
2975
|
+
finalVal = valueWithUnit;
|
|
2976
|
+
}
|
|
2977
|
+
const lookupKey = `${realProp}:${valueWithUnit}`;
|
|
2978
|
+
const staticClass = globalManifest[lookupKey];
|
|
2979
|
+
if (staticClass) {
|
|
2980
|
+
if (!target.catcher._classes.includes(staticClass)) {
|
|
2981
|
+
target.catcher._classes.push(staticClass);
|
|
2982
|
+
if (debugMode2) {
|
|
2983
|
+
console.log(`[ChainCSS] Using atomic class: ${staticClass} for ${lookupKey}`);
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
} else {
|
|
2987
|
+
if (debugMode2) {
|
|
2988
|
+
console.log(`[ChainCSS] No atomic class for ${lookupKey}, will inject at runtime`);
|
|
2989
|
+
}
|
|
2990
|
+
target.catcher[realProp] = finalVal;
|
|
2991
|
+
}
|
|
2992
|
+
return target.proxy;
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
useTokens;
|
|
2998
|
+
// catcher now tracks both raw styles and pre-baked class names
|
|
2999
|
+
catcher = { _classes: [] };
|
|
3000
|
+
componentName = "";
|
|
3001
|
+
proxy;
|
|
3002
|
+
use(plugin) {
|
|
3003
|
+
const { selectors, atRules, ...styles3 } = plugin;
|
|
3004
|
+
Object.entries(styles3).forEach(([key, val]) => {
|
|
3005
|
+
const realProp = shorthandMap[key] || key;
|
|
3006
|
+
this.catcher[realProp] = val;
|
|
3007
|
+
});
|
|
3008
|
+
return this.proxy;
|
|
3009
|
+
}
|
|
3010
|
+
hover() {
|
|
3011
|
+
const hoverCatcher = { _classes: [] };
|
|
3012
|
+
const hoverHandler = {
|
|
3013
|
+
get: (_, prop) => {
|
|
3014
|
+
if (prop === "end") {
|
|
3015
|
+
return () => {
|
|
3016
|
+
this.catcher.hover = { ...this.catcher.hover, ...hoverCatcher };
|
|
3017
|
+
return this.proxy;
|
|
3018
|
+
};
|
|
3019
|
+
}
|
|
3020
|
+
const realProp = shorthandMap[prop] || prop;
|
|
3021
|
+
return (val) => {
|
|
3022
|
+
const lookupKey = `hover:${realProp}:${val}`;
|
|
3023
|
+
const staticClass = globalManifest[lookupKey];
|
|
3024
|
+
if (staticClass) {
|
|
3025
|
+
if (!hoverCatcher._classes.includes(staticClass)) {
|
|
3026
|
+
hoverCatcher._classes.push(staticClass);
|
|
3027
|
+
}
|
|
3028
|
+
} else if (runtimeMacros[prop]) {
|
|
3029
|
+
runtimeMacros[prop](val, hoverCatcher, this.useTokens);
|
|
3030
|
+
} else {
|
|
3031
|
+
hoverCatcher[realProp] = val;
|
|
3032
|
+
}
|
|
3033
|
+
return hoverProxy;
|
|
3034
|
+
};
|
|
3035
|
+
}
|
|
3036
|
+
};
|
|
3037
|
+
const hoverProxy = new Proxy({}, hoverHandler);
|
|
3038
|
+
return hoverProxy;
|
|
3039
|
+
}
|
|
3040
|
+
/**
|
|
3041
|
+
* Set the component name for class generation
|
|
3042
|
+
*/
|
|
3043
|
+
$name(name) {
|
|
3044
|
+
this.componentName = name;
|
|
3045
|
+
return this;
|
|
3046
|
+
}
|
|
3047
|
+
/**
|
|
3048
|
+
* Finalizes the chain. Returns the style object and resets the catcher.
|
|
3049
|
+
*/
|
|
3050
|
+
$el(name) {
|
|
3051
|
+
const result = structuredClone(this.catcher);
|
|
3052
|
+
result._name = name || this.componentName || "element";
|
|
3053
|
+
delete result._componentName;
|
|
3054
|
+
delete result._generateComponent;
|
|
3055
|
+
delete result._framework;
|
|
3056
|
+
delete result._propsDefinition;
|
|
3057
|
+
this.catcher = { _classes: [] };
|
|
3058
|
+
this.componentName = "";
|
|
3059
|
+
return result;
|
|
3060
|
+
}
|
|
3061
|
+
end(name) {
|
|
3062
|
+
return this.$el(name);
|
|
3063
|
+
}
|
|
3064
|
+
/**
|
|
3065
|
+
* Get the current catcher (for debugging)
|
|
3066
|
+
*/
|
|
3067
|
+
getCatcher() {
|
|
3068
|
+
return { ...this.catcher };
|
|
3069
|
+
}
|
|
3070
|
+
};
|
|
3071
|
+
var $ = () => new RuntimeChain(false).proxy;
|
|
3072
|
+
var $t = () => new RuntimeChain(true).proxy;
|
|
3073
|
+
var chain2 = (useTokens = false) => new RuntimeChain(useTokens).proxy;
|
|
3074
|
+
|
|
3075
|
+
// src/core/auto-detector.ts
|
|
3076
|
+
var AutoDetector = class _AutoDetector {
|
|
3077
|
+
static instance;
|
|
3078
|
+
dynamicPatterns = [
|
|
3079
|
+
/\$\{.*\}/,
|
|
3080
|
+
// Template literals: ${variable}
|
|
3081
|
+
/props\.[a-zA-Z]+/,
|
|
3082
|
+
// Props access: props.color
|
|
3083
|
+
/theme\.[a-zA-Z]+/,
|
|
3084
|
+
// Theme access: theme.primary
|
|
3085
|
+
/state\.[a-zA-Z]+/,
|
|
3086
|
+
// State access: state.isActive
|
|
3087
|
+
/this\.[a-zA-Z]+/,
|
|
3088
|
+
// This binding
|
|
3089
|
+
/useContext\(/,
|
|
3090
|
+
// React hook
|
|
3091
|
+
/useSelector\(/,
|
|
3092
|
+
// Redux selector
|
|
3093
|
+
/getState\(/
|
|
3094
|
+
// Store getter
|
|
3095
|
+
];
|
|
3096
|
+
staticPatterns = [
|
|
3097
|
+
/^#[0-9a-f]{3,6}$/i,
|
|
3098
|
+
// Hex colors
|
|
3099
|
+
/^[a-z]+$/,
|
|
3100
|
+
// Simple words (red, blue, flex)
|
|
3101
|
+
/^\d+(?:\.\d+)?(?:px|rem|em|%)?$/
|
|
3102
|
+
// Numbers with optional units
|
|
3103
|
+
];
|
|
3104
|
+
debug = false;
|
|
3105
|
+
static getInstance() {
|
|
3106
|
+
if (!_AutoDetector.instance) {
|
|
3107
|
+
_AutoDetector.instance = new _AutoDetector();
|
|
3108
|
+
}
|
|
3109
|
+
return _AutoDetector.instance;
|
|
3110
|
+
}
|
|
3111
|
+
enableDebug(enabled) {
|
|
3112
|
+
this.debug = enabled;
|
|
3113
|
+
}
|
|
3114
|
+
detectValueType(value, prop) {
|
|
3115
|
+
if (typeof value === "function") {
|
|
3116
|
+
if (this.debug) console.log(`[AutoDetector] Function detected for ${prop} -> runtime-only`);
|
|
3117
|
+
return "runtime-only";
|
|
3118
|
+
}
|
|
3119
|
+
if (value === void 0 || value === null) {
|
|
3120
|
+
return "static";
|
|
3121
|
+
}
|
|
3122
|
+
if (typeof value === "object" && value !== null) {
|
|
3123
|
+
if (this.debug) console.log(`[AutoDetector] Object detected for ${prop} -> dynamic`);
|
|
3124
|
+
return "dynamic";
|
|
3125
|
+
}
|
|
3126
|
+
if (typeof value === "string") {
|
|
3127
|
+
for (const pattern of this.staticPatterns) {
|
|
3128
|
+
if (pattern.test(value)) {
|
|
3129
|
+
if (this.debug) console.log(`[AutoDetector] Static pattern matched for ${prop}: ${value}`);
|
|
3130
|
+
return "static";
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
for (const pattern of this.dynamicPatterns) {
|
|
3134
|
+
if (pattern.test(value)) {
|
|
3135
|
+
if (this.debug) console.log(`[AutoDetector] Dynamic pattern matched for ${prop}: ${value}`);
|
|
3136
|
+
return "dynamic";
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
3141
|
+
return "static";
|
|
3142
|
+
}
|
|
3143
|
+
return "static";
|
|
3144
|
+
}
|
|
3145
|
+
analyzeChain(calls) {
|
|
3146
|
+
const staticParts = [];
|
|
3147
|
+
const dynamicParts = [];
|
|
3148
|
+
const runtimeOnlyParts = [];
|
|
3149
|
+
for (const call of calls) {
|
|
3150
|
+
const type = this.detectValueType(call.value, call.prop);
|
|
3151
|
+
const part = {
|
|
3152
|
+
type,
|
|
3153
|
+
prop: call.prop,
|
|
3154
|
+
value: call.value,
|
|
3155
|
+
originalValue: call.value,
|
|
3156
|
+
index: call.index
|
|
3157
|
+
};
|
|
3158
|
+
switch (type) {
|
|
3159
|
+
case "static":
|
|
3160
|
+
staticParts.push(part);
|
|
3161
|
+
break;
|
|
3162
|
+
case "dynamic":
|
|
3163
|
+
dynamicParts.push(part);
|
|
3164
|
+
break;
|
|
3165
|
+
case "runtime-only":
|
|
3166
|
+
runtimeOnlyParts.push(part);
|
|
3167
|
+
break;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
const isHybrid = staticParts.length > 0 && (dynamicParts.length > 0 || runtimeOnlyParts.length > 0);
|
|
3171
|
+
let mode = "build";
|
|
3172
|
+
if (isHybrid) {
|
|
3173
|
+
mode = "hybrid";
|
|
3174
|
+
} else if (dynamicParts.length > 0 || runtimeOnlyParts.length > 0) {
|
|
3175
|
+
mode = "runtime";
|
|
3176
|
+
} else {
|
|
3177
|
+
mode = "build";
|
|
3178
|
+
}
|
|
3179
|
+
if (this.debug) {
|
|
3180
|
+
console.log("[AutoDetector] Analysis:", {
|
|
3181
|
+
static: staticParts.length,
|
|
3182
|
+
dynamic: dynamicParts.length,
|
|
3183
|
+
runtimeOnly: runtimeOnlyParts.length,
|
|
3184
|
+
mode,
|
|
3185
|
+
isHybrid
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
return {
|
|
3189
|
+
staticParts,
|
|
3190
|
+
dynamicParts,
|
|
3191
|
+
runtimeOnlyParts,
|
|
3192
|
+
isHybrid,
|
|
3193
|
+
mode
|
|
3194
|
+
};
|
|
3195
|
+
}
|
|
3196
|
+
addDynamicPattern(pattern) {
|
|
3197
|
+
this.dynamicPatterns.push(pattern);
|
|
3198
|
+
if (this.debug) console.log(`[AutoDetector] Added dynamic pattern: ${pattern}`);
|
|
3199
|
+
}
|
|
3200
|
+
addStaticPattern(pattern) {
|
|
3201
|
+
this.staticPatterns.push(pattern);
|
|
3202
|
+
if (this.debug) console.log(`[AutoDetector] Added static pattern: ${pattern}`);
|
|
3203
|
+
}
|
|
3204
|
+
reset() {
|
|
3205
|
+
this.dynamicPatterns = [
|
|
3206
|
+
/\$\{.*\}/,
|
|
3207
|
+
/props\.[a-zA-Z]+/,
|
|
3208
|
+
/theme\.[a-zA-Z]+/,
|
|
3209
|
+
/state\.[a-zA-Z]+/,
|
|
3210
|
+
/this\.[a-zA-Z]+/,
|
|
3211
|
+
/useContext\(/,
|
|
3212
|
+
/useSelector\(/,
|
|
3213
|
+
/getState\(/
|
|
3214
|
+
];
|
|
3215
|
+
this.staticPatterns = [
|
|
3216
|
+
/^#[0-9a-f]{3,6}$/i,
|
|
3217
|
+
/^[a-z]+$/,
|
|
3218
|
+
/^\d+(?:\.\d+)?(?:px|rem|em|%)?$/
|
|
3219
|
+
];
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
var autoDetector = AutoDetector.getInstance();
|
|
3223
|
+
|
|
3224
|
+
// src/core/smart-chain.ts
|
|
3225
|
+
var SmartChainProxy = class {
|
|
3226
|
+
calls = [];
|
|
3227
|
+
callIndex = 0;
|
|
3228
|
+
useTokens;
|
|
3229
|
+
MAX_CALLS = 500;
|
|
3230
|
+
// Safety cap
|
|
3231
|
+
constructor(useTokens = true) {
|
|
3232
|
+
this.useTokens = useTokens;
|
|
3233
|
+
}
|
|
3234
|
+
recordCall(prop, ...args) {
|
|
3235
|
+
if (this.calls.length >= this.MAX_CALLS) {
|
|
3236
|
+
console.warn("\u26A0\uFE0F ChainCSS: Smart chain call limit reached. Consider using build chain for static styles.");
|
|
3237
|
+
return this;
|
|
3238
|
+
}
|
|
3239
|
+
this.calls.push({
|
|
3240
|
+
prop,
|
|
3241
|
+
value: args[0],
|
|
3242
|
+
args,
|
|
3243
|
+
index: this.callIndex++
|
|
3244
|
+
});
|
|
3245
|
+
return this;
|
|
3246
|
+
}
|
|
3247
|
+
processHybrid(analysis, selectors) {
|
|
3248
|
+
const buildInstance = chain(this.useTokens);
|
|
3249
|
+
const runtimeInstance = new RuntimeChain(this.useTokens).proxy;
|
|
3250
|
+
for (const part of analysis.staticParts) {
|
|
3251
|
+
const call = this.calls[part.index];
|
|
3252
|
+
if (call && buildInstance[call.prop]) {
|
|
3253
|
+
buildInstance[call.prop](...call.args);
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
const allDynamic = [...analysis.dynamicParts, ...analysis.runtimeOnlyParts];
|
|
3257
|
+
for (const part of allDynamic) {
|
|
3258
|
+
const call = this.calls[part.index];
|
|
3259
|
+
if (call && runtimeInstance[call.prop]) {
|
|
3260
|
+
runtimeInstance[call.prop](...call.args);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
const buildResult = buildInstance.$el(...selectors);
|
|
3264
|
+
const runtimeResult = runtimeInstance.$el(...selectors);
|
|
3265
|
+
return {
|
|
3266
|
+
...typeof buildResult === "object" ? buildResult : {},
|
|
3267
|
+
...typeof runtimeResult === "object" ? runtimeResult : {},
|
|
3268
|
+
__buildClasses: buildResult,
|
|
3269
|
+
__runtimeClasses: runtimeResult,
|
|
3270
|
+
__isHybrid: true
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
processPureBuild(selectors) {
|
|
3274
|
+
const buildInstance = chain(this.useTokens);
|
|
3275
|
+
for (const call of this.calls) {
|
|
3276
|
+
if (buildInstance[call.prop]) {
|
|
3277
|
+
buildInstance[call.prop](...call.args);
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
return buildInstance.$el(...selectors);
|
|
3281
|
+
}
|
|
3282
|
+
processPureRuntime(selectors) {
|
|
3283
|
+
const runtimeInstance = new RuntimeChain(this.useTokens).proxy;
|
|
3284
|
+
for (const call of this.calls) {
|
|
3285
|
+
if (runtimeInstance[call.prop]) {
|
|
3286
|
+
runtimeInstance[call.prop](...call.args);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
return runtimeInstance.$el(...selectors);
|
|
3290
|
+
}
|
|
3291
|
+
$el(...selectors) {
|
|
3292
|
+
if (this.calls.length === 0) {
|
|
3293
|
+
return {};
|
|
3294
|
+
}
|
|
3295
|
+
const callsWithIndex = this.calls.map((call, idx) => ({
|
|
3296
|
+
prop: call.prop,
|
|
3297
|
+
value: call.value,
|
|
3298
|
+
index: idx
|
|
3299
|
+
}));
|
|
3300
|
+
const analysis = autoDetector.analyzeChain(callsWithIndex);
|
|
3301
|
+
if (this.calls[0]?.prop === "__isSmartChain") {
|
|
3302
|
+
return this.processPureRuntime(selectors);
|
|
3303
|
+
}
|
|
3304
|
+
let result;
|
|
3305
|
+
switch (analysis.mode) {
|
|
3306
|
+
case "hybrid":
|
|
3307
|
+
result = this.processHybrid(analysis, selectors);
|
|
3308
|
+
break;
|
|
3309
|
+
case "runtime":
|
|
3310
|
+
result = this.processPureRuntime(selectors);
|
|
3311
|
+
break;
|
|
3312
|
+
case "build":
|
|
3313
|
+
default:
|
|
3314
|
+
result = this.processPureBuild(selectors);
|
|
3315
|
+
break;
|
|
3316
|
+
}
|
|
3317
|
+
this.calls = [];
|
|
3318
|
+
this.callIndex = 0;
|
|
3319
|
+
return result;
|
|
3320
|
+
}
|
|
3321
|
+
getProxy() {
|
|
3322
|
+
const proxy = new Proxy(this, {
|
|
3323
|
+
get(target, prop) {
|
|
3324
|
+
if (prop === "__isSmartChain") return true;
|
|
3325
|
+
if (prop === "$el") return target.$el.bind(target);
|
|
3326
|
+
if (prop === "then") return void 0;
|
|
3327
|
+
return (...args) => {
|
|
3328
|
+
target.recordCall(prop, ...args);
|
|
3329
|
+
return proxy;
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
});
|
|
3333
|
+
return proxy;
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
function smartChain(useTokens = true) {
|
|
3337
|
+
const proxy = new SmartChainProxy(useTokens);
|
|
3338
|
+
return proxy.getProxy();
|
|
3339
|
+
}
|
|
3340
|
+
var buildChain = (useTokens) => chain(useTokens);
|
|
3341
|
+
var runtimeChain = (useTokens) => new RuntimeChain(useTokens || true).proxy;
|
|
3342
|
+
|
|
3343
|
+
// src/runtime/index.ts
|
|
3344
|
+
function injectChainStyles(styles3) {
|
|
3345
|
+
let css = "";
|
|
3346
|
+
for (const [key, obj] of Object.entries(styles3)) {
|
|
3347
|
+
if (!obj || !obj.selectors) continue;
|
|
3348
|
+
const sel = "." + obj.selectors[0];
|
|
3349
|
+
css += sel + "{";
|
|
3350
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
3351
|
+
if (["selectors", "hover", "atRules", "nestedRules", "_name", "_classes"].includes(k)) continue;
|
|
3352
|
+
css += k.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + v + ";";
|
|
3353
|
+
}
|
|
3354
|
+
css += "}";
|
|
3355
|
+
if (obj.hover) {
|
|
3356
|
+
css += sel + ":hover{";
|
|
3357
|
+
for (const [k, v] of Object.entries(obj.hover)) css += k.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + v + ";";
|
|
3358
|
+
css += "}";
|
|
3359
|
+
}
|
|
3360
|
+
if (obj.nestedRules) {
|
|
3361
|
+
for (const rule of obj.nestedRules) {
|
|
3362
|
+
css += rule.selector.replace("&", sel) + "{";
|
|
3363
|
+
for (const [k, v] of Object.entries(rule.styles || {})) css += k.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + v + ";";
|
|
3364
|
+
css += "}";
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
const el = document.createElement("style");
|
|
3369
|
+
el.setAttribute("data-chaincss", "runtime");
|
|
3370
|
+
el.textContent = css;
|
|
3371
|
+
document.head.appendChild(el);
|
|
3372
|
+
console.log("\u26D3\uFE0F ChainCSS \u2014 " + Object.keys(styles3).length + " styles injected | CSS: " + css.length + " bytes | smartChain auto-detect active");
|
|
3373
|
+
return el;
|
|
3374
|
+
}
|
|
3375
|
+
export {
|
|
3376
|
+
$,
|
|
3377
|
+
$t,
|
|
3378
|
+
animationPresets,
|
|
3379
|
+
buildChain,
|
|
3380
|
+
chain,
|
|
3381
|
+
createAnimation,
|
|
3382
|
+
createChain,
|
|
3383
|
+
enableDebug,
|
|
3384
|
+
getAnimationPreset,
|
|
3385
|
+
getAnimationPresetNames,
|
|
3386
|
+
getAvailableShorthands,
|
|
3387
|
+
getTokenContext,
|
|
3388
|
+
helpers,
|
|
3389
|
+
injectChainStyles,
|
|
3390
|
+
macros,
|
|
3391
|
+
chain2 as runtimeChain,
|
|
3392
|
+
setManifest,
|
|
3393
|
+
setTokenContext,
|
|
3394
|
+
setTokens,
|
|
3395
|
+
shorthandMap,
|
|
3396
|
+
smartChain,
|
|
3397
|
+
runtimeChain as smartRuntimeChain
|
|
3398
|
+
};
|