@kbach/react-native 1.0.0-beta.9 → 1.1.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +504 -0
- package/LICENSE +21 -0
- package/README.md +206 -70
- package/THIRD_PARTY_NOTICES.md +41 -0
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/{chunk-YOC3SHF5.mjs → chunk-6F44N62F.mjs} +2 -2
- package/dist/chunk-FSO4WVCH.mjs +112 -0
- package/dist/chunk-R7E5D3D6.mjs +623 -0
- package/dist/darkModeStore.d.ts +73 -0
- package/dist/darkModeStore.js +118 -0
- package/dist/dynamicTokens.d.ts +53 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +90 -70
- package/dist/index.js +1369 -611
- package/dist/index.web.d.ts +91 -1
- package/dist/index.web.js +204 -441
- package/dist/index.web.mjs +294 -12
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.js +1600 -603
- package/dist/jsx-dev-runtime.web.d.ts +2 -2
- package/dist/jsx-dev-runtime.web.js +20 -355
- package/dist/jsx-dev-runtime.web.mjs +18 -6
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +1590 -593
- package/dist/jsx-runtime.web.d.ts +3 -3
- package/dist/jsx-runtime.web.js +17 -355
- package/dist/jsx-runtime.web.mjs +2 -3
- package/dist/semanticElements-Bk3TB-vt.d.ts +334 -0
- package/dist/theme.d.ts +79 -0
- package/dist/{chunk-HK6PDJJK.mjs → theme.js} +99 -11
- package/llms.txt +38 -0
- package/package.json +15 -13
- package/src/babel-plugin.js +95 -25
- package/dist/chunk-DLIXI5OW.mjs +0 -53
- package/dist/chunk-DOWW44F7.mjs +0 -14
- package/dist/chunk-H5Z24XX5.mjs +0 -192
- package/dist/chunk-SY5OAY2C.mjs +0 -1211
- package/dist/chunk-X4UQCEOE.mjs +0 -186
- package/dist/chunk-Z664AKW7.mjs +0 -54
- package/dist/index.d.mts +0 -83
- package/dist/index.mjs +0 -38
- package/dist/index.web.d.mts +0 -15
- package/dist/jsx-dev-runtime.d.mts +0 -10
- package/dist/jsx-dev-runtime.mjs +0 -18
- package/dist/jsx-dev-runtime.web.d.mts +0 -10
- package/dist/jsx-runtime.d.mts +0 -7
- package/dist/jsx-runtime.mjs +0 -15
- package/dist/jsx-runtime.web.d.mts +0 -7
- package/dist/useColors-CeP5_HvM.d.mts +0 -230
- package/dist/useColors-CeP5_HvM.d.ts +0 -230
package/dist/jsx-runtime.js
CHANGED
|
@@ -30,422 +30,8 @@ module.exports = __toCommonJS(jsx_runtime_exports);
|
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
31
|
var import_react = require("react");
|
|
32
32
|
var import_react_native = require("react-native");
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
|
|
37
|
-
const resolved = resolveStyle2(classStrRaw, pressed);
|
|
38
|
-
if (userStyle === void 0) {
|
|
39
|
-
return resolved;
|
|
40
|
-
}
|
|
41
|
-
if (typeof userStyle === "function") {
|
|
42
|
-
return [resolved, userStyle({ pressed })];
|
|
43
|
-
}
|
|
44
|
-
return [resolved, userStyle];
|
|
45
|
-
}
|
|
46
|
-
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
47
|
-
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
48
|
-
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
49
|
-
}
|
|
50
|
-
const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
|
|
51
|
-
if (typeof classStrRaw !== "string") {
|
|
52
|
-
return makeElement(isStaticChildren, type, rawProps, key);
|
|
53
|
-
}
|
|
54
|
-
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
|
|
55
|
-
return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
|
|
56
|
-
}
|
|
57
|
-
function createJsxFunctions(resolveStyle2) {
|
|
58
|
-
function jsx2(type, props, key) {
|
|
59
|
-
return processElement(resolveStyle2, type, props, key, false);
|
|
60
|
-
}
|
|
61
|
-
function jsxs2(type, props, key) {
|
|
62
|
-
return processElement(resolveStyle2, type, props, key, true);
|
|
63
|
-
}
|
|
64
|
-
return { jsx: jsx2, jsxs: jsxs2 };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/nativeBridge.ts
|
|
68
|
-
var import_react_native3 = require("react-native");
|
|
69
|
-
|
|
70
|
-
// src/generatedPalette.ts
|
|
71
|
-
var PALETTE = {
|
|
72
|
-
"amber-1": "#fffbeb",
|
|
73
|
-
"amber-10": "#78350f",
|
|
74
|
-
"amber-11": "#451a03",
|
|
75
|
-
"amber-12": "#291002",
|
|
76
|
-
"amber-2": "#fef3c7",
|
|
77
|
-
"amber-3": "#fde68a",
|
|
78
|
-
"amber-4": "#fcd34d",
|
|
79
|
-
"amber-5": "#fbbf24",
|
|
80
|
-
"amber-6": "#f59e0b",
|
|
81
|
-
"amber-7": "#d97706",
|
|
82
|
-
"amber-8": "#b45309",
|
|
83
|
-
"amber-9": "#92400e",
|
|
84
|
-
"black": "#000000",
|
|
85
|
-
"blue-1": "#eff6ff",
|
|
86
|
-
"blue-10": "#1e3a8a",
|
|
87
|
-
"blue-11": "#172554",
|
|
88
|
-
"blue-12": "#0d1633",
|
|
89
|
-
"blue-2": "#dbeafe",
|
|
90
|
-
"blue-3": "#bfdbfe",
|
|
91
|
-
"blue-4": "#93c5fd",
|
|
92
|
-
"blue-5": "#60a5fa",
|
|
93
|
-
"blue-6": "#3b82f6",
|
|
94
|
-
"blue-7": "#2563eb",
|
|
95
|
-
"blue-8": "#1d4ed8",
|
|
96
|
-
"blue-9": "#1e40af",
|
|
97
|
-
"bronze": "#cd7f32",
|
|
98
|
-
"coal": "#1c1c1c",
|
|
99
|
-
"copper": "#b87333",
|
|
100
|
-
"current": "currentColor",
|
|
101
|
-
"cyan-1": "#ecfeff",
|
|
102
|
-
"cyan-10": "#164e63",
|
|
103
|
-
"cyan-11": "#083344",
|
|
104
|
-
"cyan-12": "#041e28",
|
|
105
|
-
"cyan-2": "#cffafe",
|
|
106
|
-
"cyan-3": "#a5f3fc",
|
|
107
|
-
"cyan-4": "#67e8f9",
|
|
108
|
-
"cyan-5": "#22d3ee",
|
|
109
|
-
"cyan-6": "#06b6d4",
|
|
110
|
-
"cyan-7": "#0891b2",
|
|
111
|
-
"cyan-8": "#0e7490",
|
|
112
|
-
"cyan-9": "#155e75",
|
|
113
|
-
"emerald-1": "#ecfdf5",
|
|
114
|
-
"emerald-10": "#064e3b",
|
|
115
|
-
"emerald-11": "#022c22",
|
|
116
|
-
"emerald-12": "#011a14",
|
|
117
|
-
"emerald-2": "#d1fae5",
|
|
118
|
-
"emerald-3": "#a7f3d0",
|
|
119
|
-
"emerald-4": "#6ee7b7",
|
|
120
|
-
"emerald-5": "#34d399",
|
|
121
|
-
"emerald-6": "#10b981",
|
|
122
|
-
"emerald-7": "#059669",
|
|
123
|
-
"emerald-8": "#047857",
|
|
124
|
-
"emerald-9": "#065f46",
|
|
125
|
-
"fuchsia-1": "#fdf4ff",
|
|
126
|
-
"fuchsia-10": "#701a75",
|
|
127
|
-
"fuchsia-11": "#4a044e",
|
|
128
|
-
"fuchsia-12": "#2d022f",
|
|
129
|
-
"fuchsia-2": "#fae8ff",
|
|
130
|
-
"fuchsia-3": "#f5d0fe",
|
|
131
|
-
"fuchsia-4": "#f0abfc",
|
|
132
|
-
"fuchsia-5": "#e879f9",
|
|
133
|
-
"fuchsia-6": "#d946ef",
|
|
134
|
-
"fuchsia-7": "#c026d3",
|
|
135
|
-
"fuchsia-8": "#a21caf",
|
|
136
|
-
"fuchsia-9": "#86198f",
|
|
137
|
-
"gold": "#d4af37",
|
|
138
|
-
"gray-1": "#f9fafb",
|
|
139
|
-
"gray-10": "#111827",
|
|
140
|
-
"gray-11": "#030712",
|
|
141
|
-
"gray-12": "#020409",
|
|
142
|
-
"gray-2": "#f3f4f6",
|
|
143
|
-
"gray-3": "#e5e7eb",
|
|
144
|
-
"gray-4": "#d1d5db",
|
|
145
|
-
"gray-5": "#9ca3af",
|
|
146
|
-
"gray-6": "#6b7280",
|
|
147
|
-
"gray-7": "#4b5563",
|
|
148
|
-
"gray-8": "#374151",
|
|
149
|
-
"gray-9": "#1f2937",
|
|
150
|
-
"green-1": "#f0fdf4",
|
|
151
|
-
"green-10": "#14532d",
|
|
152
|
-
"green-11": "#052e16",
|
|
153
|
-
"green-12": "#031b0d",
|
|
154
|
-
"green-2": "#dcfce7",
|
|
155
|
-
"green-3": "#bbf7d0",
|
|
156
|
-
"green-4": "#86efac",
|
|
157
|
-
"green-5": "#4ade80",
|
|
158
|
-
"green-6": "#22c55e",
|
|
159
|
-
"green-7": "#16a34a",
|
|
160
|
-
"green-8": "#15803d",
|
|
161
|
-
"green-9": "#166534",
|
|
162
|
-
"indigo-1": "#eef2ff",
|
|
163
|
-
"indigo-10": "#312e81",
|
|
164
|
-
"indigo-11": "#1e1b4b",
|
|
165
|
-
"indigo-12": "#12102d",
|
|
166
|
-
"indigo-2": "#e0e7ff",
|
|
167
|
-
"indigo-3": "#c7d2fe",
|
|
168
|
-
"indigo-4": "#a5b4fc",
|
|
169
|
-
"indigo-5": "#818cf8",
|
|
170
|
-
"indigo-6": "#6366f1",
|
|
171
|
-
"indigo-7": "#4f46e5",
|
|
172
|
-
"indigo-8": "#4338ca",
|
|
173
|
-
"indigo-9": "#3730a3",
|
|
174
|
-
"lime-1": "#f7fee7",
|
|
175
|
-
"lime-10": "#365314",
|
|
176
|
-
"lime-11": "#1a2e05",
|
|
177
|
-
"lime-12": "#0f1b03",
|
|
178
|
-
"lime-2": "#ecfccb",
|
|
179
|
-
"lime-3": "#d9f99d",
|
|
180
|
-
"lime-4": "#bef264",
|
|
181
|
-
"lime-5": "#a3e635",
|
|
182
|
-
"lime-6": "#84cc16",
|
|
183
|
-
"lime-7": "#65a30d",
|
|
184
|
-
"lime-8": "#4d7c0f",
|
|
185
|
-
"lime-9": "#3f6212",
|
|
186
|
-
"neutral-1": "#fafafa",
|
|
187
|
-
"neutral-10": "#171717",
|
|
188
|
-
"neutral-11": "#0a0a0a",
|
|
189
|
-
"neutral-12": "#050505",
|
|
190
|
-
"neutral-2": "#f5f5f5",
|
|
191
|
-
"neutral-3": "#e5e5e5",
|
|
192
|
-
"neutral-4": "#d4d4d4",
|
|
193
|
-
"neutral-5": "#a3a3a3",
|
|
194
|
-
"neutral-6": "#737373",
|
|
195
|
-
"neutral-7": "#525252",
|
|
196
|
-
"neutral-8": "#404040",
|
|
197
|
-
"neutral-9": "#262626",
|
|
198
|
-
"orange-1": "#fff7ed",
|
|
199
|
-
"orange-10": "#7c2d12",
|
|
200
|
-
"orange-11": "#431407",
|
|
201
|
-
"orange-12": "#270c04",
|
|
202
|
-
"orange-2": "#ffedd5",
|
|
203
|
-
"orange-3": "#fed7aa",
|
|
204
|
-
"orange-4": "#fdba74",
|
|
205
|
-
"orange-5": "#fb923c",
|
|
206
|
-
"orange-6": "#f97316",
|
|
207
|
-
"orange-7": "#ea580c",
|
|
208
|
-
"orange-8": "#c2410c",
|
|
209
|
-
"orange-9": "#9a3412",
|
|
210
|
-
"pink-1": "#fdf2f8",
|
|
211
|
-
"pink-10": "#831843",
|
|
212
|
-
"pink-11": "#500724",
|
|
213
|
-
"pink-12": "#300415",
|
|
214
|
-
"pink-2": "#fce7f3",
|
|
215
|
-
"pink-3": "#fbcfe8",
|
|
216
|
-
"pink-4": "#f9a8d4",
|
|
217
|
-
"pink-5": "#f472b6",
|
|
218
|
-
"pink-6": "#ec4899",
|
|
219
|
-
"pink-7": "#db2777",
|
|
220
|
-
"pink-8": "#be185d",
|
|
221
|
-
"pink-9": "#9d174d",
|
|
222
|
-
"purple-1": "#faf5ff",
|
|
223
|
-
"purple-10": "#581c87",
|
|
224
|
-
"purple-11": "#3b0764",
|
|
225
|
-
"purple-12": "#23043c",
|
|
226
|
-
"purple-2": "#f3e8ff",
|
|
227
|
-
"purple-3": "#e9d5ff",
|
|
228
|
-
"purple-4": "#d8b4fe",
|
|
229
|
-
"purple-5": "#c084fc",
|
|
230
|
-
"purple-6": "#a855f7",
|
|
231
|
-
"purple-7": "#9333ea",
|
|
232
|
-
"purple-8": "#7e22ce",
|
|
233
|
-
"purple-9": "#6b21a8",
|
|
234
|
-
"red-1": "#fef2f2",
|
|
235
|
-
"red-10": "#7f1d1d",
|
|
236
|
-
"red-11": "#450a0a",
|
|
237
|
-
"red-12": "#280606",
|
|
238
|
-
"red-2": "#fee2e2",
|
|
239
|
-
"red-3": "#fecaca",
|
|
240
|
-
"red-4": "#fca5a5",
|
|
241
|
-
"red-5": "#f87171",
|
|
242
|
-
"red-6": "#ef4444",
|
|
243
|
-
"red-7": "#dc2626",
|
|
244
|
-
"red-8": "#b91c1c",
|
|
245
|
-
"red-9": "#991b1b",
|
|
246
|
-
"rose-1": "#fff1f2",
|
|
247
|
-
"rose-10": "#881337",
|
|
248
|
-
"rose-11": "#4c0519",
|
|
249
|
-
"rose-12": "#2d030e",
|
|
250
|
-
"rose-2": "#ffe4e6",
|
|
251
|
-
"rose-3": "#fecdd3",
|
|
252
|
-
"rose-4": "#fda4af",
|
|
253
|
-
"rose-5": "#fb7185",
|
|
254
|
-
"rose-6": "#f43f5e",
|
|
255
|
-
"rose-7": "#e11d48",
|
|
256
|
-
"rose-8": "#be123c",
|
|
257
|
-
"rose-9": "#9f1239",
|
|
258
|
-
"silver": "#c0c0c0",
|
|
259
|
-
"sky-1": "#f0f9ff",
|
|
260
|
-
"sky-10": "#0c4a6e",
|
|
261
|
-
"sky-11": "#082f49",
|
|
262
|
-
"sky-12": "#041b2b",
|
|
263
|
-
"sky-2": "#e0f2fe",
|
|
264
|
-
"sky-3": "#bae6fd",
|
|
265
|
-
"sky-4": "#7dd3fc",
|
|
266
|
-
"sky-5": "#38bdf8",
|
|
267
|
-
"sky-6": "#0ea5e9",
|
|
268
|
-
"sky-7": "#0284c7",
|
|
269
|
-
"sky-8": "#0369a1",
|
|
270
|
-
"sky-9": "#075985",
|
|
271
|
-
"slate-1": "#f8fafc",
|
|
272
|
-
"slate-10": "#0f172a",
|
|
273
|
-
"slate-11": "#020617",
|
|
274
|
-
"slate-12": "#01020a",
|
|
275
|
-
"slate-2": "#f1f5f9",
|
|
276
|
-
"slate-3": "#e2e8f0",
|
|
277
|
-
"slate-4": "#cbd5e1",
|
|
278
|
-
"slate-5": "#94a3b8",
|
|
279
|
-
"slate-6": "#64748b",
|
|
280
|
-
"slate-7": "#475569",
|
|
281
|
-
"slate-8": "#334155",
|
|
282
|
-
"slate-9": "#1e293b",
|
|
283
|
-
"stone-1": "#fafaf9",
|
|
284
|
-
"stone-10": "#1c1917",
|
|
285
|
-
"stone-11": "#0c0a09",
|
|
286
|
-
"stone-12": "#070605",
|
|
287
|
-
"stone-2": "#f5f5f4",
|
|
288
|
-
"stone-3": "#e7e5e4",
|
|
289
|
-
"stone-4": "#d6d3d1",
|
|
290
|
-
"stone-5": "#a8a29e",
|
|
291
|
-
"stone-6": "#78716c",
|
|
292
|
-
"stone-7": "#57534e",
|
|
293
|
-
"stone-8": "#44403c",
|
|
294
|
-
"stone-9": "#292524",
|
|
295
|
-
"teal-1": "#f0fdfa",
|
|
296
|
-
"teal-10": "#134e4a",
|
|
297
|
-
"teal-11": "#042f2e",
|
|
298
|
-
"teal-12": "#021c1b",
|
|
299
|
-
"teal-2": "#ccfbf1",
|
|
300
|
-
"teal-3": "#99f6e4",
|
|
301
|
-
"teal-4": "#5eead4",
|
|
302
|
-
"teal-5": "#2dd4bf",
|
|
303
|
-
"teal-6": "#14b8a6",
|
|
304
|
-
"teal-7": "#0d9488",
|
|
305
|
-
"teal-8": "#0f766e",
|
|
306
|
-
"teal-9": "#115e59",
|
|
307
|
-
"transparent": "transparent",
|
|
308
|
-
"violet-1": "#f5f3ff",
|
|
309
|
-
"violet-10": "#4c1d95",
|
|
310
|
-
"violet-11": "#2e1065",
|
|
311
|
-
"violet-12": "#1c0a3d",
|
|
312
|
-
"violet-2": "#ede9fe",
|
|
313
|
-
"violet-3": "#ddd6fe",
|
|
314
|
-
"violet-4": "#c4b5fd",
|
|
315
|
-
"violet-5": "#a78bfa",
|
|
316
|
-
"violet-6": "#8b5cf6",
|
|
317
|
-
"violet-7": "#7c3aed",
|
|
318
|
-
"violet-8": "#6d28d9",
|
|
319
|
-
"violet-9": "#5b21b6",
|
|
320
|
-
"white": "#ffffff",
|
|
321
|
-
"yellow-1": "#fefce8",
|
|
322
|
-
"yellow-10": "#713f12",
|
|
323
|
-
"yellow-11": "#422006",
|
|
324
|
-
"yellow-12": "#271304",
|
|
325
|
-
"yellow-2": "#fef9c3",
|
|
326
|
-
"yellow-3": "#fef08a",
|
|
327
|
-
"yellow-4": "#fde047",
|
|
328
|
-
"yellow-5": "#facc15",
|
|
329
|
-
"yellow-6": "#eab308",
|
|
330
|
-
"yellow-7": "#ca8a04",
|
|
331
|
-
"yellow-8": "#a16207",
|
|
332
|
-
"yellow-9": "#854d0e",
|
|
333
|
-
"zinc-1": "#fafafa",
|
|
334
|
-
"zinc-10": "#18181b",
|
|
335
|
-
"zinc-11": "#09090b",
|
|
336
|
-
"zinc-12": "#050506",
|
|
337
|
-
"zinc-2": "#f4f4f5",
|
|
338
|
-
"zinc-3": "#e4e4e7",
|
|
339
|
-
"zinc-4": "#d4d4d8",
|
|
340
|
-
"zinc-5": "#a1a1aa",
|
|
341
|
-
"zinc-6": "#71717a",
|
|
342
|
-
"zinc-7": "#52525b",
|
|
343
|
-
"zinc-8": "#3f3f46",
|
|
344
|
-
"zinc-9": "#27272a"
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
// src/theme.ts
|
|
348
|
-
var defaultTheme = {
|
|
349
|
-
colors: PALETTE,
|
|
350
|
-
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
351
|
-
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
352
|
-
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Only the
|
|
353
|
-
// "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
|
|
354
|
-
// native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
|
|
355
|
-
// live `n * 4px` formula for any bare numeric step not listed here
|
|
356
|
-
// (`p-0.25`, `w-13`, ...), so this table names the common values and
|
|
357
|
-
// gives a theme override something to target, not the full resolvable
|
|
358
|
-
// set. Mirrors @kbach/react's theme.ts exactly.
|
|
359
|
-
spacing: {
|
|
360
|
-
"0": 0,
|
|
361
|
-
"px": 1,
|
|
362
|
-
"0.5": 2,
|
|
363
|
-
"1": 4,
|
|
364
|
-
"1.5": 6,
|
|
365
|
-
"2": 8,
|
|
366
|
-
"2.5": 10,
|
|
367
|
-
"3": 12,
|
|
368
|
-
"3.5": 14,
|
|
369
|
-
"4": 16,
|
|
370
|
-
"5": 20,
|
|
371
|
-
"6": 24,
|
|
372
|
-
"7": 28,
|
|
373
|
-
"8": 32,
|
|
374
|
-
"9": 36,
|
|
375
|
-
"10": 40,
|
|
376
|
-
"11": 44,
|
|
377
|
-
"12": 48,
|
|
378
|
-
"14": 56,
|
|
379
|
-
"16": 64,
|
|
380
|
-
"20": 80,
|
|
381
|
-
"24": 96,
|
|
382
|
-
"28": 112,
|
|
383
|
-
"32": 128,
|
|
384
|
-
"36": 144,
|
|
385
|
-
"40": 160,
|
|
386
|
-
"44": 176,
|
|
387
|
-
"48": 192,
|
|
388
|
-
"52": 208,
|
|
389
|
-
"56": 224,
|
|
390
|
-
"60": 240,
|
|
391
|
-
"64": 256,
|
|
392
|
-
"72": 288,
|
|
393
|
-
"80": 320,
|
|
394
|
-
"96": 384
|
|
395
|
-
},
|
|
396
|
-
screens: {
|
|
397
|
-
sm: 640,
|
|
398
|
-
md: 768,
|
|
399
|
-
lg: 1024,
|
|
400
|
-
xl: 1280,
|
|
401
|
-
"2xl": 1536
|
|
402
|
-
},
|
|
403
|
-
// Byte-for-byte the same three stacks
|
|
404
|
-
// packages/core-engine/src/resolvers/typography.rs's `font_family_value`
|
|
405
|
-
// falls back to. On native these three still effectively no-op (see
|
|
406
|
-
// `first_font_name`'s own doc comment for why a generic CSS keyword
|
|
407
|
-
// isn't a real loadable font) — only a caller-configured custom name
|
|
408
|
-
// changes native rendering; Expo Web uses the full stack as-is.
|
|
409
|
-
fontFamily: {
|
|
410
|
-
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
411
|
-
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
412
|
-
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
413
|
-
},
|
|
414
|
-
darkMode: "attribute",
|
|
415
|
-
// Empty by default, matching real Tailwind's own defaults.
|
|
416
|
-
container: {}
|
|
417
|
-
};
|
|
418
|
-
var activeTheme = defaultTheme;
|
|
419
|
-
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
420
|
-
function getTheme() {
|
|
421
|
-
return activeTheme;
|
|
422
|
-
}
|
|
423
|
-
function getThemeJson() {
|
|
424
|
-
return activeThemeJson;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/darkModeStore.ts
|
|
428
|
-
var import_react_native2 = require("react-native");
|
|
429
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
430
|
-
function systemPrefersDark() {
|
|
431
|
-
return import_react_native2.Appearance.getColorScheme() === "dark";
|
|
432
|
-
}
|
|
433
|
-
function resolveIsDark(m) {
|
|
434
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
435
|
-
}
|
|
436
|
-
var mode = "system";
|
|
437
|
-
var isDark = resolveIsDark(mode);
|
|
438
|
-
var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
|
|
439
|
-
if (mode !== "system") return;
|
|
440
|
-
isDark = colorScheme === "dark";
|
|
441
|
-
notify();
|
|
442
|
-
});
|
|
443
|
-
function notify() {
|
|
444
|
-
for (const listener of listeners) listener();
|
|
445
|
-
}
|
|
446
|
-
function getGlobalDarkMode() {
|
|
447
|
-
return isDark;
|
|
448
|
-
}
|
|
33
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
34
|
+
var import_theme = require("./theme");
|
|
449
35
|
|
|
450
36
|
// src/jsEngine/parser.ts
|
|
451
37
|
var VALUE_PREFIXES = [
|
|
@@ -533,12 +119,23 @@ var VALUE_PREFIXES = [
|
|
|
533
119
|
"leading-",
|
|
534
120
|
"tracking-",
|
|
535
121
|
"font-",
|
|
122
|
+
"align-",
|
|
536
123
|
"z-",
|
|
124
|
+
"inset-x-",
|
|
125
|
+
"inset-y-",
|
|
537
126
|
"inset-",
|
|
538
127
|
"top-",
|
|
539
128
|
"right-",
|
|
540
129
|
"bottom-",
|
|
541
130
|
"left-",
|
|
131
|
+
"start-",
|
|
132
|
+
"end-",
|
|
133
|
+
"overflow-x-",
|
|
134
|
+
"overflow-y-",
|
|
135
|
+
"overscroll-x-",
|
|
136
|
+
"overscroll-y-",
|
|
137
|
+
"overscroll-",
|
|
138
|
+
"aspect-",
|
|
542
139
|
"divide-color-",
|
|
543
140
|
"space-x-",
|
|
544
141
|
"space-y-",
|
|
@@ -566,12 +163,23 @@ var VALUE_PREFIXES = [
|
|
|
566
163
|
"justify-self-",
|
|
567
164
|
"scale-x-",
|
|
568
165
|
"scale-y-",
|
|
166
|
+
"scale-z-",
|
|
569
167
|
"scale-",
|
|
168
|
+
"rotate-x-",
|
|
169
|
+
"rotate-y-",
|
|
170
|
+
"rotate-z-",
|
|
570
171
|
"rotate-",
|
|
172
|
+
// Bare 'translate-'/'skew-' (both axes) after their per-axis forms, same
|
|
173
|
+
// longer-before-shorter rule as resolvers/parser.rs.
|
|
571
174
|
"translate-x-",
|
|
572
175
|
"translate-y-",
|
|
176
|
+
"translate-z-",
|
|
177
|
+
"translate-",
|
|
573
178
|
"skew-x-",
|
|
574
179
|
"skew-y-",
|
|
180
|
+
"skew-",
|
|
181
|
+
"perspective-origin-",
|
|
182
|
+
"perspective-",
|
|
575
183
|
"origin-",
|
|
576
184
|
"blur-",
|
|
577
185
|
"brightness-",
|
|
@@ -604,14 +212,200 @@ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
|
604
212
|
function isSafeArbitraryValue(value) {
|
|
605
213
|
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
606
214
|
}
|
|
215
|
+
function normalizeMathWhitespace(raw) {
|
|
216
|
+
if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
|
|
217
|
+
return raw;
|
|
218
|
+
}
|
|
219
|
+
const chars = Array.from(raw);
|
|
220
|
+
let out = "";
|
|
221
|
+
let i = 0;
|
|
222
|
+
let prevEndsValue = false;
|
|
223
|
+
while (i < chars.length) {
|
|
224
|
+
const c = chars[i];
|
|
225
|
+
if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
|
|
226
|
+
const start = i;
|
|
227
|
+
let depth = 0;
|
|
228
|
+
while (i < chars.length) {
|
|
229
|
+
if (chars[i] === "(") depth++;
|
|
230
|
+
else if (chars[i] === ")") {
|
|
231
|
+
depth--;
|
|
232
|
+
if (depth === 0) {
|
|
233
|
+
i++;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
i++;
|
|
238
|
+
}
|
|
239
|
+
out += chars.slice(start, i).join("");
|
|
240
|
+
prevEndsValue = true;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (c === "+" || c === "-") {
|
|
244
|
+
if (prevEndsValue) {
|
|
245
|
+
out += ` ${c} `;
|
|
246
|
+
i++;
|
|
247
|
+
while (i < chars.length && /\s/.test(chars[i])) i++;
|
|
248
|
+
prevEndsValue = false;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
out += c;
|
|
252
|
+
prevEndsValue = false;
|
|
253
|
+
} else if (c === "(" || c === ",") {
|
|
254
|
+
out += c;
|
|
255
|
+
if (c === ",") out += " ";
|
|
256
|
+
prevEndsValue = false;
|
|
257
|
+
} else if (c === ")") {
|
|
258
|
+
out += c;
|
|
259
|
+
prevEndsValue = true;
|
|
260
|
+
} else if (/\s/.test(c)) {
|
|
261
|
+
} else if (c === "*" || c === "/") {
|
|
262
|
+
out += c;
|
|
263
|
+
prevEndsValue = false;
|
|
264
|
+
} else {
|
|
265
|
+
out += c;
|
|
266
|
+
prevEndsValue = true;
|
|
267
|
+
}
|
|
268
|
+
i++;
|
|
269
|
+
}
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
var TYPE_HINTS = /* @__PURE__ */ new Set([
|
|
273
|
+
"color",
|
|
274
|
+
"length",
|
|
275
|
+
"size",
|
|
276
|
+
"line-width",
|
|
277
|
+
"percentage",
|
|
278
|
+
"number",
|
|
279
|
+
"integer",
|
|
280
|
+
"image",
|
|
281
|
+
"url",
|
|
282
|
+
"position",
|
|
283
|
+
"bg-size",
|
|
284
|
+
"family-name",
|
|
285
|
+
"generic-name",
|
|
286
|
+
"absolute-size",
|
|
287
|
+
"relative-size",
|
|
288
|
+
"angle",
|
|
289
|
+
"shadow",
|
|
290
|
+
"any"
|
|
291
|
+
]);
|
|
292
|
+
function arbitraryModifier(modifier) {
|
|
293
|
+
const bracketed = parenVarShorthand(modifier) ?? modifier;
|
|
294
|
+
if (!(bracketed.length > 2 && bracketed.startsWith("[") && bracketed.endsWith("]"))) return null;
|
|
295
|
+
const raw = bracketed.slice(1, -1);
|
|
296
|
+
if (!isSafeArbitraryValue(raw)) return null;
|
|
297
|
+
return normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
298
|
+
}
|
|
299
|
+
function splitTypeHint(raw) {
|
|
300
|
+
const i = raw.indexOf(":");
|
|
301
|
+
if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
|
|
302
|
+
return [null, raw];
|
|
303
|
+
}
|
|
304
|
+
function parenVarShorthand(value) {
|
|
305
|
+
const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
|
|
306
|
+
if (!m) return null;
|
|
307
|
+
const [, hint, name, tail = ""] = m;
|
|
308
|
+
if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
|
|
309
|
+
return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
|
|
310
|
+
}
|
|
311
|
+
function splitBracketModifier(value) {
|
|
312
|
+
if (!value.startsWith("[")) return [value, null];
|
|
313
|
+
let depth = 0;
|
|
314
|
+
for (let i = 0; i < value.length; i++) {
|
|
315
|
+
const ch = value[i];
|
|
316
|
+
if (ch === "[") depth += 1;
|
|
317
|
+
else if (ch === "]") {
|
|
318
|
+
depth -= 1;
|
|
319
|
+
if (depth === 0) {
|
|
320
|
+
const after = value.slice(i + 1);
|
|
321
|
+
return after.startsWith("/") && after.length > 1 ? [value.slice(0, i + 1), after.slice(1)] : [value, null];
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return [value, null];
|
|
326
|
+
}
|
|
327
|
+
function trimNumber(n) {
|
|
328
|
+
return `${Math.round(n * 1e6) / 1e6}`;
|
|
329
|
+
}
|
|
330
|
+
function parseAlpha(modifier) {
|
|
331
|
+
const raw = arbitraryModifier(modifier);
|
|
332
|
+
if (raw !== null) {
|
|
333
|
+
if (raw.endsWith("%")) {
|
|
334
|
+
const n3 = strictNumber(raw.slice(0, -1));
|
|
335
|
+
return n3 !== null && n3 >= 0 && n3 <= 100 ? { fraction: n3 / 100 } : null;
|
|
336
|
+
}
|
|
337
|
+
const n2 = strictNumber(raw);
|
|
338
|
+
if (n2 !== null) return n2 >= 0 && n2 <= 1 ? { fraction: n2 } : null;
|
|
339
|
+
return raw.startsWith("var(") || raw.startsWith("calc(") ? { raw } : null;
|
|
340
|
+
}
|
|
341
|
+
if (!/^(?:\d+\.?\d*|\.\d+)$/.test(modifier)) return null;
|
|
342
|
+
const n = Number(modifier);
|
|
343
|
+
return n <= 100 ? { fraction: n / 100 } : null;
|
|
344
|
+
}
|
|
345
|
+
function strictNumber(text) {
|
|
346
|
+
return /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text) ? Number(text) : null;
|
|
347
|
+
}
|
|
348
|
+
function expandThemeFunctions(raw) {
|
|
349
|
+
if (!raw.includes("--spacing(") && !raw.includes("--alpha(")) return raw;
|
|
350
|
+
let out = "";
|
|
351
|
+
let rest = raw;
|
|
352
|
+
for (; ; ) {
|
|
353
|
+
const found = ["--spacing(", "--alpha("].map((name) => ({ name, at: rest.indexOf(name) })).filter((f) => f.at !== -1).sort((a, b) => a.at - b.at)[0];
|
|
354
|
+
if (found === void 0) break;
|
|
355
|
+
const argsFrom = found.at + found.name.length;
|
|
356
|
+
let depth = 1;
|
|
357
|
+
let close = -1;
|
|
358
|
+
for (let i = argsFrom; i < rest.length; i++) {
|
|
359
|
+
if (rest[i] === "(") depth += 1;
|
|
360
|
+
else if (rest[i] === ")") {
|
|
361
|
+
depth -= 1;
|
|
362
|
+
if (depth === 0) {
|
|
363
|
+
close = i;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (close === -1) break;
|
|
369
|
+
const arg = expandThemeFunctions(rest.slice(argsFrom, close).trim());
|
|
370
|
+
out += rest.slice(0, found.at);
|
|
371
|
+
if (found.name === "--spacing(") {
|
|
372
|
+
const n = strictNumber(arg);
|
|
373
|
+
out += n !== null ? `${trimNumber(n * 4)}px` : `calc(4px * ${arg})`;
|
|
374
|
+
} else {
|
|
375
|
+
const slash = arg.lastIndexOf("/");
|
|
376
|
+
if (slash === -1) {
|
|
377
|
+
out += arg;
|
|
378
|
+
} else {
|
|
379
|
+
const alpha = arg.slice(slash + 1).trim();
|
|
380
|
+
const n = strictNumber(alpha);
|
|
381
|
+
out += `color-mix(in srgb, ${arg.slice(0, slash).trim()} ${n !== null ? `${trimNumber(n * 100)}%` : alpha}, transparent)`;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
rest = rest.slice(close + 1);
|
|
385
|
+
}
|
|
386
|
+
return out + rest;
|
|
387
|
+
}
|
|
388
|
+
var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
|
|
389
|
+
function looksLikeColor(value) {
|
|
390
|
+
return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
|
|
391
|
+
}
|
|
392
|
+
function colorWithOpacity(color, alpha) {
|
|
393
|
+
const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
|
|
394
|
+
if (m && "fraction" in alpha) {
|
|
395
|
+
const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
|
|
396
|
+
const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
397
|
+
return `rgba(${r},${g},${b},${trimNumber(alpha.fraction)})`;
|
|
398
|
+
}
|
|
399
|
+
return `color-mix(in srgb, ${color} ${"fraction" in alpha ? `${trimNumber(alpha.fraction * 100)}%` : alpha.raw}, transparent)`;
|
|
400
|
+
}
|
|
607
401
|
function splitRespectingBrackets(token) {
|
|
608
402
|
const parts = [];
|
|
609
403
|
let depth = 0;
|
|
610
404
|
let start = 0;
|
|
611
405
|
for (let i = 0; i < token.length; i++) {
|
|
612
406
|
const ch = token[i];
|
|
613
|
-
if (ch === "[") depth += 1;
|
|
614
|
-
else if (ch === "]") depth -= 1;
|
|
407
|
+
if (ch === "[" || ch === "(") depth += 1;
|
|
408
|
+
else if (ch === "]" || ch === ")") depth -= 1;
|
|
615
409
|
else if (ch === ":" && depth <= 0) {
|
|
616
410
|
parts.push(token.slice(start, i));
|
|
617
411
|
start = i + 1;
|
|
@@ -624,9 +418,11 @@ function parseClass(token) {
|
|
|
624
418
|
const parts = splitRespectingBrackets(token);
|
|
625
419
|
let base = parts.pop() ?? token;
|
|
626
420
|
const modifiers = parts;
|
|
627
|
-
const important = base.startsWith("!");
|
|
628
|
-
if (
|
|
421
|
+
const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
|
|
422
|
+
if (base.startsWith("!")) {
|
|
629
423
|
base = base.slice(1);
|
|
424
|
+
} else if (important) {
|
|
425
|
+
base = base.slice(0, -1);
|
|
630
426
|
}
|
|
631
427
|
const negative = base.startsWith("-");
|
|
632
428
|
if (negative) {
|
|
@@ -639,7 +435,7 @@ function parseClass(token) {
|
|
|
639
435
|
const property = raw.slice(0, colonIdx);
|
|
640
436
|
const rawValue = raw.slice(colonIdx + 1);
|
|
641
437
|
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
642
|
-
const value = rawValue.replace(/_/g, " ");
|
|
438
|
+
const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
|
|
643
439
|
return {
|
|
644
440
|
modifiers,
|
|
645
441
|
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
@@ -654,28 +450,46 @@ function parseClass(token) {
|
|
|
654
450
|
}
|
|
655
451
|
for (const prefix of VALUE_PREFIXES) {
|
|
656
452
|
if (!base.startsWith(prefix)) continue;
|
|
657
|
-
const
|
|
658
|
-
if (
|
|
453
|
+
const written = base.slice(prefix.length);
|
|
454
|
+
if (written === "") continue;
|
|
455
|
+
const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
|
|
659
456
|
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
660
457
|
const raw = value.slice(1, -1);
|
|
661
458
|
if (!isSafeArbitraryValue(raw)) {
|
|
662
459
|
continue;
|
|
663
460
|
}
|
|
664
|
-
const spaced = raw.replace(/_/g, " ");
|
|
461
|
+
const spaced = normalizeMathWhitespace(expandThemeFunctions(raw.replace(/_/g, " ")));
|
|
462
|
+
let [typeHint, hinted] = splitTypeHint(spaced);
|
|
463
|
+
let modifier = null;
|
|
464
|
+
if (tail !== null) {
|
|
465
|
+
const isColor = typeHint === "color" || typeHint === null && looksLikeColor(hinted);
|
|
466
|
+
const alpha = isColor ? parseAlpha(tail) : null;
|
|
467
|
+
if (alpha !== null) {
|
|
468
|
+
hinted = colorWithOpacity(hinted, alpha);
|
|
469
|
+
typeHint = "color";
|
|
470
|
+
} else if (prefix === "text-") {
|
|
471
|
+
modifier = tail;
|
|
472
|
+
} else {
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
665
476
|
return {
|
|
666
477
|
modifiers,
|
|
667
478
|
utility: prefix.slice(0, -1),
|
|
668
|
-
value:
|
|
479
|
+
value: hinted,
|
|
480
|
+
typeHint,
|
|
669
481
|
isArbitrary: true,
|
|
670
482
|
important,
|
|
671
483
|
negative,
|
|
672
|
-
original: token
|
|
484
|
+
original: token,
|
|
485
|
+
modifier
|
|
673
486
|
};
|
|
674
487
|
}
|
|
675
488
|
return {
|
|
676
489
|
modifiers,
|
|
677
490
|
utility: prefix.slice(0, -1),
|
|
678
|
-
value
|
|
491
|
+
// a named value keeps its own /opacity (`bg-blue-6/50`)
|
|
492
|
+
value: tail === null ? value : `${value}/${tail}`,
|
|
679
493
|
isArbitrary: false,
|
|
680
494
|
important,
|
|
681
495
|
negative,
|
|
@@ -693,6 +507,708 @@ function parseClass(token) {
|
|
|
693
507
|
};
|
|
694
508
|
}
|
|
695
509
|
|
|
510
|
+
// src/jsEngine/resolvers/color.ts
|
|
511
|
+
function lookupHex(theme, key) {
|
|
512
|
+
const entry = theme.colors[key];
|
|
513
|
+
return typeof entry === "string" ? entry : null;
|
|
514
|
+
}
|
|
515
|
+
var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
|
|
516
|
+
function findModeAwareColor(base, theme) {
|
|
517
|
+
const important = base.startsWith("!") ? "!" : "";
|
|
518
|
+
const rest = important ? base.slice(1) : base;
|
|
519
|
+
for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
|
|
520
|
+
if (!rest.startsWith(prefix)) continue;
|
|
521
|
+
const [name, opacity] = splitOpacity(rest.slice(prefix.length));
|
|
522
|
+
const entry = theme.colors[name];
|
|
523
|
+
if (typeof entry === "object" && entry !== null) {
|
|
524
|
+
return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
function applyOpacityToHex(hex, opacity) {
|
|
530
|
+
if (opacity === null) return hex;
|
|
531
|
+
if (hexToRgb(hex) === null) return hex;
|
|
532
|
+
return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
|
|
533
|
+
}
|
|
534
|
+
function substituteModeAwareColorToken(token, theme, colorScheme) {
|
|
535
|
+
const segments = token.split(":");
|
|
536
|
+
const base = segments.pop() ?? token;
|
|
537
|
+
const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
|
|
538
|
+
const found = findModeAwareColor(base, theme);
|
|
539
|
+
if (found === null) return token;
|
|
540
|
+
const hex = colorScheme === "dark" ? found.dark : found.light;
|
|
541
|
+
return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
|
|
542
|
+
}
|
|
543
|
+
function classStringUsesModeAwareColor(classString, theme) {
|
|
544
|
+
return classString.split(/\s+/).some((rawToken) => {
|
|
545
|
+
if (!rawToken) return false;
|
|
546
|
+
const segments = rawToken.split(":");
|
|
547
|
+
const base = segments.pop() ?? rawToken;
|
|
548
|
+
return findModeAwareColor(base, theme) !== null;
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function hexToRgb(hex) {
|
|
552
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
553
|
+
if (!m) return null;
|
|
554
|
+
let h = m[1];
|
|
555
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
556
|
+
const n = parseInt(h, 16);
|
|
557
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
558
|
+
}
|
|
559
|
+
function splitOpacity(value) {
|
|
560
|
+
const slash = value.indexOf("/");
|
|
561
|
+
if (slash === -1) return [value, null];
|
|
562
|
+
const alpha = parseAlpha(value.slice(slash + 1));
|
|
563
|
+
return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
|
|
564
|
+
}
|
|
565
|
+
function colorValue(theme, parsed) {
|
|
566
|
+
const value = parsed.value;
|
|
567
|
+
if (value === null) return null;
|
|
568
|
+
if (parsed.isArbitrary) return value;
|
|
569
|
+
const [name, opacity] = splitOpacity(value);
|
|
570
|
+
const hex = lookupHex(theme, name);
|
|
571
|
+
if (hex === null) return null;
|
|
572
|
+
return opacity === null ? hex : colorWithOpacity(hex, opacity);
|
|
573
|
+
}
|
|
574
|
+
var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
|
|
575
|
+
function looksLikeLength(value) {
|
|
576
|
+
const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
|
|
577
|
+
const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
|
|
578
|
+
if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
|
|
579
|
+
if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
|
|
580
|
+
return MATH_LENGTH_UNIT.test(value);
|
|
581
|
+
}
|
|
582
|
+
var MATH_LENGTH_UNIT = /\d(?:px|rem|em|%|vh|vw|vmin|vmax|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cqw|cqh|cqi|cqb)(?![A-Za-z])/;
|
|
583
|
+
function isLength(parsed, value) {
|
|
584
|
+
switch (parsed.typeHint ?? null) {
|
|
585
|
+
case null:
|
|
586
|
+
return looksLikeLength(value);
|
|
587
|
+
case "length":
|
|
588
|
+
case "size":
|
|
589
|
+
case "line-width":
|
|
590
|
+
case "percentage":
|
|
591
|
+
case "number":
|
|
592
|
+
case "integer":
|
|
593
|
+
case "absolute-size":
|
|
594
|
+
case "relative-size":
|
|
595
|
+
return true;
|
|
596
|
+
default:
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// src/jsxRuntimeCore.ts
|
|
602
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
603
|
+
|
|
604
|
+
// src/jsEngine/calc.ts
|
|
605
|
+
function reduceConstantMath(raw) {
|
|
606
|
+
const trimmed = raw.trim();
|
|
607
|
+
const calc = stripCall(trimmed, "calc");
|
|
608
|
+
if (calc !== null) {
|
|
609
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
610
|
+
}
|
|
611
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
612
|
+
if (clamp !== null) {
|
|
613
|
+
const args = splitTopLevelCommas(clamp);
|
|
614
|
+
if (args.length !== 3) return null;
|
|
615
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
616
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
617
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
618
|
+
}
|
|
619
|
+
const min = stripCall(trimmed, "min");
|
|
620
|
+
if (min !== null) {
|
|
621
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
622
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
623
|
+
}
|
|
624
|
+
const max = stripCall(trimmed, "max");
|
|
625
|
+
if (max !== null) {
|
|
626
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
627
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
628
|
+
}
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
function stripCall(raw, name) {
|
|
632
|
+
if (!raw.startsWith(name)) return null;
|
|
633
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
634
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
635
|
+
return afterName.slice(1, -1);
|
|
636
|
+
}
|
|
637
|
+
function splitTopLevelCommas(s) {
|
|
638
|
+
const parts = [];
|
|
639
|
+
let depth = 0;
|
|
640
|
+
let start = 0;
|
|
641
|
+
for (let i = 0; i < s.length; i++) {
|
|
642
|
+
const ch = s[i];
|
|
643
|
+
if (ch === "(") depth++;
|
|
644
|
+
else if (ch === ")") depth--;
|
|
645
|
+
else if (ch === "," && depth === 0) {
|
|
646
|
+
parts.push(s.slice(start, i).trim());
|
|
647
|
+
start = i + 1;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
parts.push(s.slice(start).trim());
|
|
651
|
+
return parts;
|
|
652
|
+
}
|
|
653
|
+
var Evaluator = class {
|
|
654
|
+
constructor(s) {
|
|
655
|
+
this.pos = 0;
|
|
656
|
+
this.s = s;
|
|
657
|
+
}
|
|
658
|
+
parseExprToEnd() {
|
|
659
|
+
const value = this.expr();
|
|
660
|
+
if (value === null) return null;
|
|
661
|
+
this.skipWs();
|
|
662
|
+
return this.pos === this.s.length ? value : null;
|
|
663
|
+
}
|
|
664
|
+
skipWs() {
|
|
665
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
666
|
+
}
|
|
667
|
+
peek() {
|
|
668
|
+
this.skipWs();
|
|
669
|
+
return this.s[this.pos];
|
|
670
|
+
}
|
|
671
|
+
expr() {
|
|
672
|
+
let value = this.term();
|
|
673
|
+
if (value === null) return null;
|
|
674
|
+
for (; ; ) {
|
|
675
|
+
const ch = this.peek();
|
|
676
|
+
if (ch === "+") {
|
|
677
|
+
this.pos++;
|
|
678
|
+
const rhs = this.term();
|
|
679
|
+
if (rhs === null) return null;
|
|
680
|
+
value += rhs;
|
|
681
|
+
} else if (ch === "-") {
|
|
682
|
+
this.pos++;
|
|
683
|
+
const rhs = this.term();
|
|
684
|
+
if (rhs === null) return null;
|
|
685
|
+
value -= rhs;
|
|
686
|
+
} else {
|
|
687
|
+
return value;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
term() {
|
|
692
|
+
let value = this.factor();
|
|
693
|
+
if (value === null) return null;
|
|
694
|
+
for (; ; ) {
|
|
695
|
+
const ch = this.peek();
|
|
696
|
+
if (ch === "*") {
|
|
697
|
+
this.pos++;
|
|
698
|
+
const rhs = this.factor();
|
|
699
|
+
if (rhs === null) return null;
|
|
700
|
+
value *= rhs;
|
|
701
|
+
} else if (ch === "/") {
|
|
702
|
+
this.pos++;
|
|
703
|
+
const divisor = this.factor();
|
|
704
|
+
if (divisor === null || divisor === 0) return null;
|
|
705
|
+
value /= divisor;
|
|
706
|
+
} else {
|
|
707
|
+
return value;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
factor() {
|
|
712
|
+
const ch = this.peek();
|
|
713
|
+
if (ch === void 0) return null;
|
|
714
|
+
if (ch === "(") {
|
|
715
|
+
this.pos++;
|
|
716
|
+
const value = this.expr();
|
|
717
|
+
if (value === null || this.peek() !== ")") return null;
|
|
718
|
+
this.pos++;
|
|
719
|
+
return value;
|
|
720
|
+
}
|
|
721
|
+
if (ch === "-") {
|
|
722
|
+
this.pos++;
|
|
723
|
+
const value = this.factor();
|
|
724
|
+
return value === null ? null : -value;
|
|
725
|
+
}
|
|
726
|
+
return this.numberWithUnit();
|
|
727
|
+
}
|
|
728
|
+
numberWithUnit() {
|
|
729
|
+
this.skipWs();
|
|
730
|
+
const start = this.pos;
|
|
731
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
732
|
+
if (this.pos === start) return null;
|
|
733
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
734
|
+
if (!Number.isFinite(n)) return null;
|
|
735
|
+
const unitStart = this.pos;
|
|
736
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
737
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
738
|
+
switch (unit) {
|
|
739
|
+
case "":
|
|
740
|
+
return n;
|
|
741
|
+
case "px":
|
|
742
|
+
return n;
|
|
743
|
+
case "rem":
|
|
744
|
+
return n * 16;
|
|
745
|
+
default:
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
// src/layoutCalc.ts
|
|
752
|
+
var NEG = (v) => ({ percent: -v.percent, px: -v.px });
|
|
753
|
+
var ADD = (a, b) => ({ percent: a.percent + b.percent, px: a.px + b.px });
|
|
754
|
+
var SUB = (a, b) => ({ percent: a.percent - b.percent, px: a.px - b.px });
|
|
755
|
+
function MUL(a, b) {
|
|
756
|
+
if (a.percent === 0) return { percent: b.percent * a.px, px: b.px * a.px };
|
|
757
|
+
if (b.percent === 0) return { percent: a.percent * b.px, px: a.px * b.px };
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
function DIV(a, b) {
|
|
761
|
+
if (b.percent !== 0 || b.px === 0) return null;
|
|
762
|
+
return { percent: a.percent / b.px, px: a.px / b.px };
|
|
763
|
+
}
|
|
764
|
+
var PercentAwareEvaluator = class {
|
|
765
|
+
constructor(s) {
|
|
766
|
+
this.pos = 0;
|
|
767
|
+
this.s = s;
|
|
768
|
+
}
|
|
769
|
+
parseExprToEnd() {
|
|
770
|
+
const value = this.expr();
|
|
771
|
+
if (value === null) return null;
|
|
772
|
+
this.skipWs();
|
|
773
|
+
return this.pos === this.s.length ? value : null;
|
|
774
|
+
}
|
|
775
|
+
skipWs() {
|
|
776
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
777
|
+
}
|
|
778
|
+
peek() {
|
|
779
|
+
this.skipWs();
|
|
780
|
+
return this.s[this.pos];
|
|
781
|
+
}
|
|
782
|
+
expr() {
|
|
783
|
+
let value = this.term();
|
|
784
|
+
if (value === null) return null;
|
|
785
|
+
for (; ; ) {
|
|
786
|
+
const ch = this.peek();
|
|
787
|
+
if (ch === "+") {
|
|
788
|
+
this.pos++;
|
|
789
|
+
const rhs = this.term();
|
|
790
|
+
if (rhs === null) return null;
|
|
791
|
+
value = ADD(value, rhs);
|
|
792
|
+
} else if (ch === "-") {
|
|
793
|
+
this.pos++;
|
|
794
|
+
const rhs = this.term();
|
|
795
|
+
if (rhs === null) return null;
|
|
796
|
+
value = SUB(value, rhs);
|
|
797
|
+
} else {
|
|
798
|
+
return value;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
term() {
|
|
803
|
+
let value = this.factor();
|
|
804
|
+
if (value === null) return null;
|
|
805
|
+
for (; ; ) {
|
|
806
|
+
const ch = this.peek();
|
|
807
|
+
if (ch === "*") {
|
|
808
|
+
this.pos++;
|
|
809
|
+
const rhs = this.factor();
|
|
810
|
+
if (rhs === null) return null;
|
|
811
|
+
const result = MUL(value, rhs);
|
|
812
|
+
if (result === null) return null;
|
|
813
|
+
value = result;
|
|
814
|
+
} else if (ch === "/") {
|
|
815
|
+
this.pos++;
|
|
816
|
+
const rhs = this.factor();
|
|
817
|
+
if (rhs === null) return null;
|
|
818
|
+
const result = DIV(value, rhs);
|
|
819
|
+
if (result === null) return null;
|
|
820
|
+
value = result;
|
|
821
|
+
} else {
|
|
822
|
+
return value;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
factor() {
|
|
827
|
+
const ch = this.peek();
|
|
828
|
+
if (ch === void 0) return null;
|
|
829
|
+
if (ch === "(") {
|
|
830
|
+
this.pos++;
|
|
831
|
+
const value = this.expr();
|
|
832
|
+
if (value === null || this.peek() !== ")") return null;
|
|
833
|
+
this.pos++;
|
|
834
|
+
return value;
|
|
835
|
+
}
|
|
836
|
+
if (ch === "-") {
|
|
837
|
+
this.pos++;
|
|
838
|
+
const value = this.factor();
|
|
839
|
+
return value === null ? null : NEG(value);
|
|
840
|
+
}
|
|
841
|
+
return this.numberWithUnit();
|
|
842
|
+
}
|
|
843
|
+
numberWithUnit() {
|
|
844
|
+
this.skipWs();
|
|
845
|
+
const start = this.pos;
|
|
846
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
847
|
+
if (this.pos === start) return null;
|
|
848
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
849
|
+
if (!Number.isFinite(n)) return null;
|
|
850
|
+
if (this.s[this.pos] === "%") {
|
|
851
|
+
this.pos++;
|
|
852
|
+
return { percent: n, px: 0 };
|
|
853
|
+
}
|
|
854
|
+
const unitStart = this.pos;
|
|
855
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
856
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
857
|
+
switch (unit) {
|
|
858
|
+
case "":
|
|
859
|
+
return { percent: 0, px: n };
|
|
860
|
+
case "px":
|
|
861
|
+
return { percent: 0, px: n };
|
|
862
|
+
case "rem":
|
|
863
|
+
return { percent: 0, px: n * 16 };
|
|
864
|
+
default:
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
var PERCENT_TOKEN_OUTER_RE = /^(w|h)-\[(.+)\]$/;
|
|
870
|
+
function parsePercentRelativeCalc(token) {
|
|
871
|
+
const m = PERCENT_TOKEN_OUTER_RE.exec(token);
|
|
872
|
+
if (!m) return null;
|
|
873
|
+
const property = m[1] === "w" ? "width" : "height";
|
|
874
|
+
const inner = stripCall(m[2].replace(/_/g, " ").trim(), "calc");
|
|
875
|
+
if (inner === null) return null;
|
|
876
|
+
const result = new PercentAwareEvaluator(inner).parseExprToEnd();
|
|
877
|
+
if (result === null || result.percent === 0) return null;
|
|
878
|
+
return { property, percentCoefficient: result.percent, constantPx: result.px };
|
|
879
|
+
}
|
|
880
|
+
function resolvePercentRelativeCalc(basisPx, calc) {
|
|
881
|
+
return basisPx * calc.percentCoefficient / 100 + calc.constantPx;
|
|
882
|
+
}
|
|
883
|
+
function parsePercentRelativeMinMaxClamp(token) {
|
|
884
|
+
const m = PERCENT_TOKEN_OUTER_RE.exec(token);
|
|
885
|
+
if (!m) return null;
|
|
886
|
+
const property = m[1] === "w" ? "width" : "height";
|
|
887
|
+
const spaced = m[2].replace(/_/g, " ");
|
|
888
|
+
let kind;
|
|
889
|
+
let inner;
|
|
890
|
+
if ((inner = stripCall(spaced, "min")) !== null) kind = "min";
|
|
891
|
+
else if ((inner = stripCall(spaced, "max")) !== null) kind = "max";
|
|
892
|
+
else if ((inner = stripCall(spaced, "clamp")) !== null) kind = "clamp";
|
|
893
|
+
else return null;
|
|
894
|
+
const args = splitTopLevelCommas(inner);
|
|
895
|
+
if (kind === "clamp" && args.length !== 3) return null;
|
|
896
|
+
if (kind !== "clamp" && args.length < 1) return null;
|
|
897
|
+
const operands = args.map((arg) => new PercentAwareEvaluator(arg.trim()).parseExprToEnd());
|
|
898
|
+
if (operands.some((o) => o === null)) return null;
|
|
899
|
+
const resolved = operands;
|
|
900
|
+
if (!resolved.some((o) => o.percent !== 0)) return null;
|
|
901
|
+
return {
|
|
902
|
+
property,
|
|
903
|
+
resolve(basisPx) {
|
|
904
|
+
const values = resolved.map((o) => basisPx * o.percent / 100 + o.px);
|
|
905
|
+
if (kind === "min") return Math.min(...values);
|
|
906
|
+
if (kind === "max") return Math.max(...values);
|
|
907
|
+
const [min, preferred, max] = values;
|
|
908
|
+
return Math.max(min, Math.min(preferred, max));
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function parsePercentRelativeExpr(token) {
|
|
913
|
+
const calc = parsePercentRelativeCalc(token);
|
|
914
|
+
if (calc) return { property: calc.property, resolve: (basisPx) => resolvePercentRelativeCalc(basisPx, calc) };
|
|
915
|
+
return parsePercentRelativeMinMaxClamp(token);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// src/jsxRuntimeCore.ts
|
|
919
|
+
var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
|
|
920
|
+
function substituteDynamicTokens(classStrRaw) {
|
|
921
|
+
if (!classStrRaw.includes("var(--")) return classStrRaw;
|
|
922
|
+
return classStrRaw.replace(DYNAMIC_TOKEN_MATCH_RE, (whole, name) => {
|
|
923
|
+
const value = (0, import_dynamicTokens.getDynamicToken)(name);
|
|
924
|
+
return value ?? whole;
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
var PERCENT_RELATIVE_CALC_HINT_RE = /[wh]-\[(calc|min|max|clamp)\(.*%.*\)\]/;
|
|
928
|
+
function extractPercentRelativeCalcs(classStrRaw) {
|
|
929
|
+
const found = [];
|
|
930
|
+
for (const token of classStrRaw.split(/\s+/)) {
|
|
931
|
+
const parsed = parsePercentRelativeExpr(token);
|
|
932
|
+
if (parsed) found.push(parsed);
|
|
933
|
+
}
|
|
934
|
+
return found;
|
|
935
|
+
}
|
|
936
|
+
function stripPercentRelativeCalcTokens(classStrRaw) {
|
|
937
|
+
return classStrRaw.split(/\s+/).filter((token) => token && parsePercentRelativeExpr(token) === null).join(" ");
|
|
938
|
+
}
|
|
939
|
+
var STATE_MODIFIER_NAMES = /* @__PURE__ */ new Set(["hover", "focus", "disabled"]);
|
|
940
|
+
var STATIC_ARIA_SHORTCUT_NAMES = /* @__PURE__ */ new Set([
|
|
941
|
+
"aria-checked",
|
|
942
|
+
"aria-disabled",
|
|
943
|
+
"aria-expanded",
|
|
944
|
+
"aria-hidden",
|
|
945
|
+
"aria-pressed",
|
|
946
|
+
"aria-readonly",
|
|
947
|
+
"aria-required",
|
|
948
|
+
"aria-selected",
|
|
949
|
+
"aria-busy"
|
|
950
|
+
]);
|
|
951
|
+
var STATE_MODIFIER_HINT_RE = /(^|\s|:)(hover|focus|disabled|aria-checked|aria-disabled|aria-expanded|aria-hidden|aria-pressed|aria-readonly|aria-required|aria-selected|aria-busy):|data-\[|aria-\[/;
|
|
952
|
+
function bracketContent(name, prefix) {
|
|
953
|
+
if (!name.startsWith(prefix)) return null;
|
|
954
|
+
const rest = name.slice(prefix.length);
|
|
955
|
+
if (!rest.startsWith("[") || !rest.endsWith("]")) return null;
|
|
956
|
+
return rest.slice(1, -1);
|
|
957
|
+
}
|
|
958
|
+
function evalAttrCondition(hostRest, attrPrefix, inner) {
|
|
959
|
+
const eqIdx = inner.indexOf("=");
|
|
960
|
+
if (eqIdx === -1) return Boolean(hostRest[`${attrPrefix}${inner}`]);
|
|
961
|
+
const key = inner.slice(0, eqIdx);
|
|
962
|
+
const value = inner.slice(eqIdx + 1);
|
|
963
|
+
return String(hostRest[`${attrPrefix}${key}`]) === value;
|
|
964
|
+
}
|
|
965
|
+
function isAriaTruthy(value) {
|
|
966
|
+
return value === true || value === "true";
|
|
967
|
+
}
|
|
968
|
+
function propBasedModifierState(name, states, hostRest) {
|
|
969
|
+
if (STATE_MODIFIER_NAMES.has(name)) return states[name];
|
|
970
|
+
if (STATIC_ARIA_SHORTCUT_NAMES.has(name)) return isAriaTruthy(hostRest[name]);
|
|
971
|
+
const dataInner = bracketContent(name, "data-");
|
|
972
|
+
if (dataInner !== null) return evalAttrCondition(hostRest, "data-", dataInner);
|
|
973
|
+
const ariaInner = bracketContent(name, "aria-");
|
|
974
|
+
if (ariaInner !== null) return evalAttrCondition(hostRest, "aria-", ariaInner);
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
var STATE_HOLD_MARKER = "_kbon";
|
|
978
|
+
function markSatisfiedStateModifiers(parts, namesToReplace) {
|
|
979
|
+
const utility = parts[parts.length - 1] ?? "";
|
|
980
|
+
const modifiers = parts.slice(0, -1).map((m) => namesToReplace.has(m) ? STATE_HOLD_MARKER : m);
|
|
981
|
+
return [...modifiers, utility].join(":");
|
|
982
|
+
}
|
|
983
|
+
function substituteStateModifiers(classStrRaw, states, hostRest) {
|
|
984
|
+
if (!STATE_MODIFIER_HINT_RE.test(classStrRaw)) return classStrRaw;
|
|
985
|
+
const kept = [];
|
|
986
|
+
for (const token of classStrRaw.split(/\s+/)) {
|
|
987
|
+
if (!token) continue;
|
|
988
|
+
const parts = splitRespectingBrackets(token);
|
|
989
|
+
const modifiers = parts.slice(0, -1);
|
|
990
|
+
const resolved = modifiers.map((m) => [m, propBasedModifierState(m, states, hostRest)]);
|
|
991
|
+
const required = resolved.filter(([, v]) => v !== null);
|
|
992
|
+
if (required.length === 0) {
|
|
993
|
+
kept.push(token);
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
if (required.every(([, v]) => v === true)) {
|
|
997
|
+
const requiredNames = new Set(required.map(([m]) => m));
|
|
998
|
+
kept.push(markSatisfiedStateModifiers(parts, requiredNames));
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return kept.join(" ");
|
|
1002
|
+
}
|
|
1003
|
+
function makeElement(isStaticChildren, type, props, key) {
|
|
1004
|
+
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
1005
|
+
}
|
|
1006
|
+
function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed, hostRest, layoutOverrides, states = { hover: false, focus: false, disabled: false }) {
|
|
1007
|
+
const stateResolved = substituteStateModifiers(classStrRaw, states, hostRest);
|
|
1008
|
+
const cleaned = stripPercentRelativeCalcTokens(substituteDynamicTokens(stateResolved));
|
|
1009
|
+
const resolved = resolveStyle2(cleaned, pressed);
|
|
1010
|
+
if (layoutOverrides) {
|
|
1011
|
+
Object.assign(resolved, layoutOverrides);
|
|
1012
|
+
}
|
|
1013
|
+
if (userStyle === void 0) {
|
|
1014
|
+
return resolved;
|
|
1015
|
+
}
|
|
1016
|
+
if (typeof userStyle === "function") {
|
|
1017
|
+
return [resolved, userStyle({ pressed })];
|
|
1018
|
+
}
|
|
1019
|
+
return [resolved, userStyle];
|
|
1020
|
+
}
|
|
1021
|
+
var DARK_MODIFIER_RE = /(^|\s|:)dark:/;
|
|
1022
|
+
var BREAKPOINT_MODIFIER_RE = /(^|\s|:)(sm|md|lg|xl|2xl):|(^|\s|:)(min|max)-\[[^\]]*\]:/;
|
|
1023
|
+
var HOVER_MODIFIER_RE = /(^|\s|:)hover:/;
|
|
1024
|
+
var FOCUS_MODIFIER_RE = /(^|\s|:)focus:/;
|
|
1025
|
+
function usesModeAwareColor(classStrRaw) {
|
|
1026
|
+
return classStringUsesModeAwareColor(classStrRaw, (0, import_theme.getTheme)());
|
|
1027
|
+
}
|
|
1028
|
+
function ReactiveElement({
|
|
1029
|
+
hostType,
|
|
1030
|
+
hostRest,
|
|
1031
|
+
classStrRaw,
|
|
1032
|
+
userStyle,
|
|
1033
|
+
resolveStyle: resolveStyle2,
|
|
1034
|
+
elementKey,
|
|
1035
|
+
isStaticChildren
|
|
1036
|
+
}) {
|
|
1037
|
+
(0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
|
|
1038
|
+
(0, import_react.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, import_dynamicTokens.getDynamicTokensVersion);
|
|
1039
|
+
const windowSize = (0, import_react_native.useWindowDimensions)();
|
|
1040
|
+
const [measuredBasis, setMeasuredBasis] = (0, import_react.useState)(null);
|
|
1041
|
+
const lastWindowSizeRef = (0, import_react.useRef)(windowSize);
|
|
1042
|
+
if (lastWindowSizeRef.current.width !== windowSize.width || lastWindowSizeRef.current.height !== windowSize.height) {
|
|
1043
|
+
lastWindowSizeRef.current = windowSize;
|
|
1044
|
+
if (measuredBasis !== null) {
|
|
1045
|
+
setMeasuredBasis(null);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
const measure = (0, import_react.useCallback)((e) => {
|
|
1049
|
+
const { width: w, height: h } = e.nativeEvent.layout;
|
|
1050
|
+
setMeasuredBasis((prev) => prev === null ? { width: w, height: h } : prev);
|
|
1051
|
+
}, []);
|
|
1052
|
+
const [isHovered, setIsHovered] = (0, import_react.useState)(false);
|
|
1053
|
+
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
1054
|
+
const percentCalcs = extractPercentRelativeCalcs(classStrRaw);
|
|
1055
|
+
let layoutOverrides;
|
|
1056
|
+
let hostRestWithLayout = hostRest;
|
|
1057
|
+
if (percentCalcs.length > 0) {
|
|
1058
|
+
layoutOverrides = {};
|
|
1059
|
+
for (const calc of percentCalcs) {
|
|
1060
|
+
const basis = measuredBasis?.[calc.property];
|
|
1061
|
+
layoutOverrides[calc.property] = basis === void 0 ? "100%" : calc.resolve(basis);
|
|
1062
|
+
}
|
|
1063
|
+
const userOnLayout = hostRest.onLayout;
|
|
1064
|
+
hostRestWithLayout = {
|
|
1065
|
+
...hostRest,
|
|
1066
|
+
onLayout: userOnLayout ? (e) => {
|
|
1067
|
+
measure(e);
|
|
1068
|
+
userOnLayout(e);
|
|
1069
|
+
} : measure
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
if (HOVER_MODIFIER_RE.test(classStrRaw)) {
|
|
1073
|
+
const userOnHoverIn = hostRestWithLayout.onHoverIn;
|
|
1074
|
+
const userOnHoverOut = hostRestWithLayout.onHoverOut;
|
|
1075
|
+
hostRestWithLayout = {
|
|
1076
|
+
...hostRestWithLayout,
|
|
1077
|
+
onHoverIn: (e) => {
|
|
1078
|
+
setIsHovered(true);
|
|
1079
|
+
userOnHoverIn?.(e);
|
|
1080
|
+
},
|
|
1081
|
+
onHoverOut: (e) => {
|
|
1082
|
+
setIsHovered(false);
|
|
1083
|
+
userOnHoverOut?.(e);
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
if (FOCUS_MODIFIER_RE.test(classStrRaw)) {
|
|
1088
|
+
const userOnFocus = hostRestWithLayout.onFocus;
|
|
1089
|
+
const userOnBlur = hostRestWithLayout.onBlur;
|
|
1090
|
+
hostRestWithLayout = {
|
|
1091
|
+
...hostRestWithLayout,
|
|
1092
|
+
onFocus: (e) => {
|
|
1093
|
+
setIsFocused(true);
|
|
1094
|
+
userOnFocus?.(e);
|
|
1095
|
+
},
|
|
1096
|
+
onBlur: (e) => {
|
|
1097
|
+
setIsFocused(false);
|
|
1098
|
+
userOnBlur?.(e);
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
const states = { hover: isHovered, focus: isFocused, disabled: hostRest.disabled === true };
|
|
1103
|
+
const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, hostRest, layoutOverrides, states) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, hostRest, layoutOverrides, states);
|
|
1104
|
+
return makeElement(
|
|
1105
|
+
isStaticChildren,
|
|
1106
|
+
hostType,
|
|
1107
|
+
{ ...hostRestWithLayout, className: classStrRaw, style: finalStyle },
|
|
1108
|
+
elementKey
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
1112
|
+
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
1113
|
+
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
1114
|
+
}
|
|
1115
|
+
const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
|
|
1116
|
+
if (typeof classStrRaw !== "string") {
|
|
1117
|
+
return makeElement(isStaticChildren, type, rawProps, key);
|
|
1118
|
+
}
|
|
1119
|
+
if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || HOVER_MODIFIER_RE.test(classStrRaw) || FOCUS_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw) || usesModeAwareColor(classStrRaw)) {
|
|
1120
|
+
return (0, import_jsx_runtime.jsx)(
|
|
1121
|
+
ReactiveElement,
|
|
1122
|
+
{ hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
|
|
1123
|
+
key
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
const staticStates = { hover: false, focus: false, disabled: rest.disabled === true };
|
|
1127
|
+
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, rest, void 0, staticStates) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, rest, void 0, staticStates);
|
|
1128
|
+
return makeElement(isStaticChildren, type, { ...rest, className: classStrRaw, style: finalStyle }, key);
|
|
1129
|
+
}
|
|
1130
|
+
function createJsxFunctions(resolveStyle2) {
|
|
1131
|
+
function jsx2(type, props, key) {
|
|
1132
|
+
return processElement(resolveStyle2, type, props, key, false);
|
|
1133
|
+
}
|
|
1134
|
+
function jsxs2(type, props, key) {
|
|
1135
|
+
return processElement(resolveStyle2, type, props, key, true);
|
|
1136
|
+
}
|
|
1137
|
+
return { jsx: jsx2, jsxs: jsxs2 };
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// src/nativeBridge.ts
|
|
1141
|
+
var import_react_native2 = require("react-native");
|
|
1142
|
+
var import_theme2 = require("./theme");
|
|
1143
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1144
|
+
|
|
1145
|
+
// src/jsEngine/groups.ts
|
|
1146
|
+
function expandVariantGroups(input) {
|
|
1147
|
+
if (!input.includes(":(")) return input;
|
|
1148
|
+
const out = [];
|
|
1149
|
+
for (const token of splitTopLevel(input)) expandToken(token, "", false, out);
|
|
1150
|
+
return out.join(" ");
|
|
1151
|
+
}
|
|
1152
|
+
function splitTopLevel(s) {
|
|
1153
|
+
const parts = [];
|
|
1154
|
+
let depth = 0;
|
|
1155
|
+
let start = -1;
|
|
1156
|
+
for (let i = 0; i < s.length; i++) {
|
|
1157
|
+
const ch = s[i];
|
|
1158
|
+
if (ch === "(" || ch === "[") depth++;
|
|
1159
|
+
else if (ch === ")" || ch === "]") depth--;
|
|
1160
|
+
const space = /\s/.test(ch);
|
|
1161
|
+
if (space && depth <= 0) {
|
|
1162
|
+
if (start >= 0) {
|
|
1163
|
+
parts.push(s.slice(start, i));
|
|
1164
|
+
start = -1;
|
|
1165
|
+
}
|
|
1166
|
+
depth = Math.max(depth, 0);
|
|
1167
|
+
} else if (start < 0 && !space) {
|
|
1168
|
+
start = i;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
if (start >= 0) parts.push(s.slice(start));
|
|
1172
|
+
return parts;
|
|
1173
|
+
}
|
|
1174
|
+
function groupOpen(token) {
|
|
1175
|
+
let brackets = 0;
|
|
1176
|
+
for (let i = 0; i < token.length; i++) {
|
|
1177
|
+
const ch = token[i];
|
|
1178
|
+
if (ch === "[") brackets++;
|
|
1179
|
+
else if (ch === "]") brackets--;
|
|
1180
|
+
else if (ch === "(" && brackets === 0 && i > 1 && token[i - 1] === ":") return i;
|
|
1181
|
+
}
|
|
1182
|
+
return -1;
|
|
1183
|
+
}
|
|
1184
|
+
function groupClose(token, open) {
|
|
1185
|
+
let depth = 0;
|
|
1186
|
+
for (let i = open; i < token.length; i++) {
|
|
1187
|
+
const ch = token[i];
|
|
1188
|
+
if (ch === "(" || ch === "[") depth++;
|
|
1189
|
+
else if (ch === ")" || ch === "]") {
|
|
1190
|
+
depth--;
|
|
1191
|
+
if (depth === 0) return ch === ")" ? i : -1;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
return -1;
|
|
1195
|
+
}
|
|
1196
|
+
function pushClass(prefix, cls, important, out) {
|
|
1197
|
+
if (!cls) return;
|
|
1198
|
+
const bare = cls.split(":").pop() ?? cls;
|
|
1199
|
+
out.push(prefix + cls + (important && !cls.endsWith("!") && !bare.startsWith("!") ? "!" : ""));
|
|
1200
|
+
}
|
|
1201
|
+
function expandToken(token, prefix, important, out) {
|
|
1202
|
+
const open = groupOpen(token);
|
|
1203
|
+
if (open < 0) return pushClass(prefix, token, important, out);
|
|
1204
|
+
const close = groupClose(token, open);
|
|
1205
|
+
if (close < 0) return pushClass(prefix, token, important, out);
|
|
1206
|
+
const rest = token.slice(close + 1);
|
|
1207
|
+
if (rest !== "" && rest !== "!") return pushClass(prefix, token, important, out);
|
|
1208
|
+
const innerPrefix = prefix + token.slice(0, open);
|
|
1209
|
+
for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
696
1212
|
// src/jsEngine/shared.ts
|
|
697
1213
|
function decl(property, value) {
|
|
698
1214
|
return { property, value };
|
|
@@ -700,6 +1216,7 @@ function decl(property, value) {
|
|
|
700
1216
|
function spacingPx(theme, value) {
|
|
701
1217
|
const fromTable = theme.spacing[value];
|
|
702
1218
|
if (fromTable !== void 0) return fromTable;
|
|
1219
|
+
if (value === "px") return 1;
|
|
703
1220
|
const n = Number(value);
|
|
704
1221
|
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
705
1222
|
}
|
|
@@ -715,7 +1232,10 @@ function resolveLength(theme, parsed) {
|
|
|
715
1232
|
}
|
|
716
1233
|
function resolveNegatableLength(theme, parsed) {
|
|
717
1234
|
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
718
|
-
if (parsed.isArbitrary)
|
|
1235
|
+
if (parsed.isArbitrary) {
|
|
1236
|
+
const value2 = parsed.value;
|
|
1237
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
1238
|
+
}
|
|
719
1239
|
const value = parsed.value;
|
|
720
1240
|
if (value === null) return null;
|
|
721
1241
|
const px = spacingPx(theme, value);
|
|
@@ -723,11 +1243,71 @@ function resolveNegatableLength(theme, parsed) {
|
|
|
723
1243
|
if (px === 0) return "0px";
|
|
724
1244
|
return `-${px}px`;
|
|
725
1245
|
}
|
|
1246
|
+
function fractionPercent(value) {
|
|
1247
|
+
const slashIdx = value.indexOf("/");
|
|
1248
|
+
if (slashIdx === -1) return null;
|
|
1249
|
+
const numStr = value.slice(0, slashIdx);
|
|
1250
|
+
const denStr = value.slice(slashIdx + 1);
|
|
1251
|
+
const num = Number(numStr);
|
|
1252
|
+
const den = Number(denStr);
|
|
1253
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
1254
|
+
if (den === 0) return null;
|
|
1255
|
+
const pct = num / den * 100;
|
|
1256
|
+
const formatted = pct.toFixed(6);
|
|
1257
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
1258
|
+
return `${trimmed}%`;
|
|
1259
|
+
}
|
|
1260
|
+
function resolveNegatableSize(theme, parsed) {
|
|
1261
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1262
|
+
if (parsed.negative && parsed.value === "full") return "-100%";
|
|
1263
|
+
const pct = fractionPercent(parsed.value);
|
|
1264
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
1265
|
+
}
|
|
1266
|
+
return resolveNegatableLength(theme, parsed);
|
|
1267
|
+
}
|
|
1268
|
+
function negate(value) {
|
|
1269
|
+
const numeric = (v) => /^[\d.]/.test(v);
|
|
1270
|
+
if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
|
|
1271
|
+
return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
|
|
1272
|
+
}
|
|
1273
|
+
function resolvePercent(parsed) {
|
|
1274
|
+
if (parsed.negative) return null;
|
|
1275
|
+
const value = parsed.value;
|
|
1276
|
+
if (value === null) return null;
|
|
1277
|
+
if (parsed.isArbitrary) return value;
|
|
1278
|
+
const pct = Number(value);
|
|
1279
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
1280
|
+
return String(pct / 100);
|
|
1281
|
+
}
|
|
726
1282
|
|
|
727
1283
|
// src/jsEngine/resolvers/layout.ts
|
|
728
1284
|
function negateRaw(value, negative) {
|
|
729
1285
|
return negative ? `-${value}` : value;
|
|
730
1286
|
}
|
|
1287
|
+
var WHOLE = /^\d+$/;
|
|
1288
|
+
var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
1289
|
+
function overflowAxisValue(property, value) {
|
|
1290
|
+
switch (value) {
|
|
1291
|
+
case "auto":
|
|
1292
|
+
case "hidden":
|
|
1293
|
+
case "clip":
|
|
1294
|
+
case "visible":
|
|
1295
|
+
case "scroll":
|
|
1296
|
+
return [decl(property, value)];
|
|
1297
|
+
default:
|
|
1298
|
+
return null;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function overscrollValue(property, value) {
|
|
1302
|
+
switch (value) {
|
|
1303
|
+
case "auto":
|
|
1304
|
+
case "contain":
|
|
1305
|
+
case "none":
|
|
1306
|
+
return [decl(property, value)];
|
|
1307
|
+
default:
|
|
1308
|
+
return null;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
731
1311
|
function resolve(parsed, theme) {
|
|
732
1312
|
switch (parsed.utility) {
|
|
733
1313
|
case "flex":
|
|
@@ -774,6 +1354,12 @@ function resolve(parsed, theme) {
|
|
|
774
1354
|
return [decl("justify-content", "space-around")];
|
|
775
1355
|
case "justify-evenly":
|
|
776
1356
|
return [decl("justify-content", "space-evenly")];
|
|
1357
|
+
case "justify-normal":
|
|
1358
|
+
return [decl("justify-content", "normal")];
|
|
1359
|
+
case "justify-stretch":
|
|
1360
|
+
return [decl("justify-content", "stretch")];
|
|
1361
|
+
case "content-normal":
|
|
1362
|
+
return [decl("align-content", "normal")];
|
|
777
1363
|
case "content-start":
|
|
778
1364
|
return [decl("align-content", "flex-start")];
|
|
779
1365
|
case "content-end":
|
|
@@ -808,6 +1394,18 @@ function resolve(parsed, theme) {
|
|
|
808
1394
|
return [decl("overflow", "scroll")];
|
|
809
1395
|
case "overflow-visible":
|
|
810
1396
|
return [decl("overflow", "visible")];
|
|
1397
|
+
case "overflow-clip":
|
|
1398
|
+
return [decl("overflow", "clip")];
|
|
1399
|
+
case "overflow-x":
|
|
1400
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
1401
|
+
case "overflow-y":
|
|
1402
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
1403
|
+
case "overscroll":
|
|
1404
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
1405
|
+
case "overscroll-x":
|
|
1406
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
1407
|
+
case "overscroll-y":
|
|
1408
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
811
1409
|
case "static":
|
|
812
1410
|
return [decl("position", "static")];
|
|
813
1411
|
case "relative":
|
|
@@ -818,40 +1416,91 @@ function resolve(parsed, theme) {
|
|
|
818
1416
|
return [decl("position", "fixed")];
|
|
819
1417
|
case "sticky":
|
|
820
1418
|
return [decl("position", "sticky")];
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
1419
|
+
// Only real values, mirroring layout.rs: a whole number, z-auto, the
|
|
1420
|
+
// order-first/-last/-none keywords, or an arbitrary [...]. Anything
|
|
1421
|
+
// else used to pass straight through (z-banana -> z-index: banana).
|
|
1422
|
+
case "z": {
|
|
1423
|
+
const v = parsed.value;
|
|
1424
|
+
if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
|
|
1425
|
+
return [decl("z-index", negateRaw(v, parsed.negative))];
|
|
1426
|
+
}
|
|
1427
|
+
case "order": {
|
|
1428
|
+
const v = parsed.value;
|
|
1429
|
+
if (v === null) return null;
|
|
1430
|
+
if (v === "first") return [decl("order", "-9999")];
|
|
1431
|
+
if (v === "last") return [decl("order", "9999")];
|
|
1432
|
+
if (v === "none") return [decl("order", "0")];
|
|
1433
|
+
if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
|
|
1434
|
+
return [decl("order", negateRaw(v, parsed.negative))];
|
|
1435
|
+
}
|
|
825
1436
|
case "grow":
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1437
|
+
case "shrink": {
|
|
1438
|
+
const v = parsed.value ?? "1";
|
|
1439
|
+
if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
|
|
1440
|
+
return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
|
|
1441
|
+
}
|
|
829
1442
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
830
|
-
// convention ("-top-4")
|
|
1443
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
1444
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
831
1445
|
case "top": {
|
|
832
|
-
const v =
|
|
1446
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
833
1447
|
return v === null ? null : [decl("top", v)];
|
|
834
1448
|
}
|
|
835
1449
|
case "right": {
|
|
836
|
-
const v =
|
|
1450
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
837
1451
|
return v === null ? null : [decl("right", v)];
|
|
838
1452
|
}
|
|
839
1453
|
case "bottom": {
|
|
840
|
-
const v =
|
|
1454
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
841
1455
|
return v === null ? null : [decl("bottom", v)];
|
|
842
1456
|
}
|
|
843
1457
|
case "left": {
|
|
844
|
-
const v =
|
|
1458
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
845
1459
|
return v === null ? null : [decl("left", v)];
|
|
846
1460
|
}
|
|
847
1461
|
case "inset": {
|
|
848
|
-
const v =
|
|
1462
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
849
1463
|
return v === null ? null : [decl("inset", v)];
|
|
850
1464
|
}
|
|
851
|
-
case "
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1465
|
+
case "inset-x": {
|
|
1466
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1467
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
1468
|
+
}
|
|
1469
|
+
case "inset-y": {
|
|
1470
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1471
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
1472
|
+
}
|
|
1473
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
1474
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
1475
|
+
case "start": {
|
|
1476
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1477
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
1478
|
+
}
|
|
1479
|
+
case "end": {
|
|
1480
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1481
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
1482
|
+
}
|
|
1483
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
1484
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
1485
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
1486
|
+
// "aspect" arm.
|
|
1487
|
+
case "aspect": {
|
|
1488
|
+
const value = parsed.value;
|
|
1489
|
+
if (value === null) return null;
|
|
1490
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
1491
|
+
switch (value) {
|
|
1492
|
+
case "square":
|
|
1493
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
1494
|
+
case "video":
|
|
1495
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
1496
|
+
case "auto":
|
|
1497
|
+
return [decl("aspect-ratio", "auto")];
|
|
1498
|
+
default: {
|
|
1499
|
+
const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
|
|
1500
|
+
return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
855
1504
|
default:
|
|
856
1505
|
return null;
|
|
857
1506
|
}
|
|
@@ -893,7 +1542,7 @@ function resolveFlex(parsed, web) {
|
|
|
893
1542
|
case "shrink-0":
|
|
894
1543
|
return [decl("flex-shrink", "0")];
|
|
895
1544
|
default:
|
|
896
|
-
return null;
|
|
1545
|
+
return /^\d+$/.test(value) ? [decl("flex", value)] : null;
|
|
897
1546
|
}
|
|
898
1547
|
}
|
|
899
1548
|
|
|
@@ -928,20 +1577,6 @@ function namedSize(key) {
|
|
|
928
1577
|
return null;
|
|
929
1578
|
}
|
|
930
1579
|
}
|
|
931
|
-
function fractionPercent(value) {
|
|
932
|
-
const slashIdx = value.indexOf("/");
|
|
933
|
-
if (slashIdx === -1) return null;
|
|
934
|
-
const numStr = value.slice(0, slashIdx);
|
|
935
|
-
const denStr = value.slice(slashIdx + 1);
|
|
936
|
-
const num = Number(numStr);
|
|
937
|
-
const den = Number(denStr);
|
|
938
|
-
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
939
|
-
if (den === 0) return null;
|
|
940
|
-
const pct = num / den * 100;
|
|
941
|
-
const formatted = pct.toFixed(6);
|
|
942
|
-
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
943
|
-
return `${trimmed}%`;
|
|
944
|
-
}
|
|
945
1580
|
function cssSizeKeyword(key) {
|
|
946
1581
|
switch (key) {
|
|
947
1582
|
case "min":
|
|
@@ -1075,19 +1710,16 @@ function resolve2(parsed, theme) {
|
|
|
1075
1710
|
}
|
|
1076
1711
|
}
|
|
1077
1712
|
|
|
1078
|
-
// src/jsEngine/resolvers/color.ts
|
|
1079
|
-
function lookupHex(theme, key) {
|
|
1080
|
-
const entry = theme.colors[key];
|
|
1081
|
-
return typeof entry === "string" ? entry : null;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
1713
|
// src/jsEngine/resolvers/border.ts
|
|
1085
1714
|
function radiusSize(key) {
|
|
1086
1715
|
switch (key) {
|
|
1087
1716
|
case "none":
|
|
1088
1717
|
return "0px";
|
|
1089
|
-
|
|
1718
|
+
// Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
|
|
1719
|
+
case "xs":
|
|
1090
1720
|
return "0.125rem";
|
|
1721
|
+
case "sm":
|
|
1722
|
+
return "0.25rem";
|
|
1091
1723
|
case "md":
|
|
1092
1724
|
return "0.375rem";
|
|
1093
1725
|
case "lg":
|
|
@@ -1098,12 +1730,19 @@ function radiusSize(key) {
|
|
|
1098
1730
|
return "1rem";
|
|
1099
1731
|
case "3xl":
|
|
1100
1732
|
return "1.5rem";
|
|
1733
|
+
case "4xl":
|
|
1734
|
+
return "2rem";
|
|
1101
1735
|
case "full":
|
|
1102
1736
|
return "9999px";
|
|
1103
1737
|
default:
|
|
1104
1738
|
return null;
|
|
1105
1739
|
}
|
|
1106
1740
|
}
|
|
1741
|
+
function borderWidthPx(parsed) {
|
|
1742
|
+
if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
|
|
1743
|
+
const n = Number(parsed.value);
|
|
1744
|
+
return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
|
|
1745
|
+
}
|
|
1107
1746
|
function borderSideProperty(side) {
|
|
1108
1747
|
switch (side) {
|
|
1109
1748
|
case "t":
|
|
@@ -1126,49 +1765,68 @@ function borderValue(theme, parsed) {
|
|
|
1126
1765
|
if (side !== null) {
|
|
1127
1766
|
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1128
1767
|
}
|
|
1768
|
+
const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
|
|
1769
|
+
if (pair !== null) {
|
|
1770
|
+
return [
|
|
1771
|
+
decl(`${pair[0]}-width`, "1px"),
|
|
1772
|
+
decl(`${pair[1]}-width`, "1px"),
|
|
1773
|
+
decl(`${pair[0]}-style`, "solid"),
|
|
1774
|
+
decl(`${pair[1]}-style`, "solid")
|
|
1775
|
+
];
|
|
1776
|
+
}
|
|
1129
1777
|
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1130
1778
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1131
1779
|
}
|
|
1132
1780
|
if (parsed.isArbitrary) {
|
|
1133
|
-
return [decl("border-width", value)];
|
|
1781
|
+
if (isLength(parsed, value)) return [decl("border-width", value)];
|
|
1782
|
+
const color2 = colorValue(theme, parsed);
|
|
1783
|
+
return color2 === null ? null : [decl("border-color", color2)];
|
|
1134
1784
|
}
|
|
1135
1785
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1136
|
-
const v =
|
|
1786
|
+
const v = borderWidthPx(parsed);
|
|
1137
1787
|
return v === null ? null : [decl("border-width", v)];
|
|
1138
1788
|
}
|
|
1139
1789
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1140
1790
|
return [decl("border-style", value)];
|
|
1141
1791
|
}
|
|
1142
|
-
const
|
|
1143
|
-
return
|
|
1792
|
+
const color = colorValue(theme, parsed);
|
|
1793
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1144
1794
|
}
|
|
1145
1795
|
function borderSideValue(theme, parsed, sideProperty) {
|
|
1146
1796
|
const value = parsed.value;
|
|
1147
1797
|
if (value === null) return null;
|
|
1148
|
-
if (parsed.isArbitrary)
|
|
1798
|
+
if (parsed.isArbitrary) {
|
|
1799
|
+
if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
|
|
1800
|
+
const color2 = colorValue(theme, parsed);
|
|
1801
|
+
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
1802
|
+
}
|
|
1149
1803
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1150
|
-
const v =
|
|
1804
|
+
const v = borderWidthPx(parsed);
|
|
1151
1805
|
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1152
1806
|
}
|
|
1153
1807
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1154
1808
|
return [decl(`${sideProperty}-style`, value)];
|
|
1155
1809
|
}
|
|
1156
|
-
const
|
|
1157
|
-
return
|
|
1810
|
+
const color = colorValue(theme, parsed);
|
|
1811
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1158
1812
|
}
|
|
1159
1813
|
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1160
1814
|
const value = parsed.value;
|
|
1161
1815
|
if (value === null) return null;
|
|
1162
|
-
if (parsed.isArbitrary)
|
|
1816
|
+
if (parsed.isArbitrary) {
|
|
1817
|
+
if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1818
|
+
const color2 = colorValue(theme, parsed);
|
|
1819
|
+
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1820
|
+
}
|
|
1163
1821
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1164
|
-
const v =
|
|
1822
|
+
const v = borderWidthPx(parsed);
|
|
1165
1823
|
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1166
1824
|
}
|
|
1167
1825
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1168
1826
|
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1169
1827
|
}
|
|
1170
|
-
const
|
|
1171
|
-
return
|
|
1828
|
+
const color = colorValue(theme, parsed);
|
|
1829
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1172
1830
|
}
|
|
1173
1831
|
function radiusProperties(side) {
|
|
1174
1832
|
switch (side) {
|
|
@@ -1208,79 +1866,28 @@ function resolveRadiusSide(theme, parsed, side) {
|
|
|
1208
1866
|
}
|
|
1209
1867
|
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1210
1868
|
function outlineWidthValue(key) {
|
|
1211
|
-
|
|
1212
|
-
case "0":
|
|
1213
|
-
return "0px";
|
|
1214
|
-
case "1":
|
|
1215
|
-
return "1px";
|
|
1216
|
-
case "2":
|
|
1217
|
-
return "2px";
|
|
1218
|
-
case "4":
|
|
1219
|
-
return "4px";
|
|
1220
|
-
case "8":
|
|
1221
|
-
return "8px";
|
|
1222
|
-
default:
|
|
1223
|
-
return null;
|
|
1224
|
-
}
|
|
1869
|
+
return /^\d+$/.test(key) ? `${Number(key)}px` : null;
|
|
1225
1870
|
}
|
|
1226
1871
|
function outlineValue(theme, parsed) {
|
|
1227
1872
|
const value = parsed.value;
|
|
1228
1873
|
if (value === null) return null;
|
|
1229
|
-
if (parsed.isArbitrary)
|
|
1874
|
+
if (parsed.isArbitrary) {
|
|
1875
|
+
if (isLength(parsed, value)) return [decl("outline-width", value)];
|
|
1876
|
+
const color2 = colorValue(theme, parsed);
|
|
1877
|
+
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1878
|
+
}
|
|
1230
1879
|
const w = outlineWidthValue(value);
|
|
1231
1880
|
if (w !== null) return [decl("outline-width", w)];
|
|
1232
1881
|
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1882
|
+
const color = colorValue(theme, parsed);
|
|
1883
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1235
1884
|
}
|
|
1236
1885
|
function outlineOffsetValue(parsed) {
|
|
1237
1886
|
const value = parsed.value;
|
|
1238
1887
|
if (value === null) return null;
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
return
|
|
1242
|
-
}
|
|
1243
|
-
var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
|
|
1244
|
-
function ringWidth(key) {
|
|
1245
|
-
switch (key) {
|
|
1246
|
-
case "0":
|
|
1247
|
-
return "0px";
|
|
1248
|
-
case "1":
|
|
1249
|
-
return "1px";
|
|
1250
|
-
case "2":
|
|
1251
|
-
return "2px";
|
|
1252
|
-
case "4":
|
|
1253
|
-
return "4px";
|
|
1254
|
-
case "8":
|
|
1255
|
-
return "8px";
|
|
1256
|
-
default:
|
|
1257
|
-
return null;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
function ringValue(theme, parsed) {
|
|
1261
|
-
const value = parsed.value;
|
|
1262
|
-
if (value === null) return null;
|
|
1263
|
-
if (value === "inset") {
|
|
1264
|
-
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1265
|
-
}
|
|
1266
|
-
if (!parsed.isArbitrary) {
|
|
1267
|
-
const w = ringWidth(value);
|
|
1268
|
-
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1269
|
-
}
|
|
1270
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1271
|
-
if (color === null) return null;
|
|
1272
|
-
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1273
|
-
}
|
|
1274
|
-
function ringOffsetValue(theme, parsed) {
|
|
1275
|
-
const value = parsed.value;
|
|
1276
|
-
if (value === null) return null;
|
|
1277
|
-
if (!parsed.isArbitrary) {
|
|
1278
|
-
const w = ringWidth(value);
|
|
1279
|
-
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1280
|
-
}
|
|
1281
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1282
|
-
if (color === null) return null;
|
|
1283
|
-
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1888
|
+
const v = parsed.isArbitrary ? value : outlineWidthValue(value);
|
|
1889
|
+
if (v === null) return null;
|
|
1890
|
+
return [decl("outline-offset", parsed.negative ? negate(v) : v)];
|
|
1284
1891
|
}
|
|
1285
1892
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1286
1893
|
function resolve3(parsed, theme) {
|
|
@@ -1310,14 +1917,19 @@ function resolve3(parsed, theme) {
|
|
|
1310
1917
|
const v = resolveLength(theme, parsed);
|
|
1311
1918
|
return v === null ? null : [decl("border-radius", v)];
|
|
1312
1919
|
}
|
|
1920
|
+
// Rings are web-only (a var()-composed CSS box-shadow React Native can't
|
|
1921
|
+
// parse) — same as resolvers/mod.rs's native dispatcher.
|
|
1313
1922
|
case "ring":
|
|
1314
|
-
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1315
|
-
return ringValue(theme, parsed);
|
|
1316
1923
|
case "ring-offset":
|
|
1317
|
-
return
|
|
1924
|
+
return null;
|
|
1925
|
+
// Outlines: the same final native style the Rust engine produces once
|
|
1926
|
+
// its var()-based web declarations are filtered out (resolve_style.rs):
|
|
1927
|
+
// bare `outline` is a 1px width, `outline-none` is outline-style: none,
|
|
1928
|
+
// `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
|
|
1318
1929
|
case "outline":
|
|
1319
|
-
if (parsed.value === null) return [decl("outline-
|
|
1320
|
-
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1930
|
+
if (parsed.value === null) return [decl("outline-width", "1px")];
|
|
1931
|
+
if (parsed.value === "none") return [decl("outline-style", "none")];
|
|
1932
|
+
if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
|
|
1321
1933
|
return outlineValue(theme, parsed);
|
|
1322
1934
|
case "outline-offset":
|
|
1323
1935
|
return outlineOffsetValue(parsed);
|
|
@@ -1348,32 +1960,75 @@ function textSize(key) {
|
|
|
1348
1960
|
return "1.875rem";
|
|
1349
1961
|
case "4xl":
|
|
1350
1962
|
return "2.25rem";
|
|
1963
|
+
case "5xl":
|
|
1964
|
+
return "3rem";
|
|
1965
|
+
case "6xl":
|
|
1966
|
+
return "3.75rem";
|
|
1967
|
+
case "7xl":
|
|
1968
|
+
return "4.5rem";
|
|
1969
|
+
case "8xl":
|
|
1970
|
+
return "6rem";
|
|
1971
|
+
case "9xl":
|
|
1972
|
+
return "8rem";
|
|
1351
1973
|
default:
|
|
1352
1974
|
return null;
|
|
1353
1975
|
}
|
|
1354
1976
|
}
|
|
1355
1977
|
function lineHeightSize(key) {
|
|
1978
|
+
if (key === "px") return "1px";
|
|
1979
|
+
if (key.trim() === "") return null;
|
|
1980
|
+
const n = Number(key);
|
|
1981
|
+
return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
|
|
1982
|
+
}
|
|
1983
|
+
function leadingNamed(key) {
|
|
1356
1984
|
switch (key) {
|
|
1357
|
-
case "
|
|
1358
|
-
return
|
|
1359
|
-
case "
|
|
1360
|
-
return
|
|
1361
|
-
case "
|
|
1362
|
-
return
|
|
1363
|
-
case "
|
|
1364
|
-
return
|
|
1365
|
-
case "
|
|
1366
|
-
return
|
|
1367
|
-
case "
|
|
1368
|
-
return
|
|
1369
|
-
case "9":
|
|
1370
|
-
return "2.25rem";
|
|
1371
|
-
case "10":
|
|
1372
|
-
return "2.5rem";
|
|
1985
|
+
case "none":
|
|
1986
|
+
return 1;
|
|
1987
|
+
case "tight":
|
|
1988
|
+
return 1.25;
|
|
1989
|
+
case "snug":
|
|
1990
|
+
return 1.375;
|
|
1991
|
+
case "normal":
|
|
1992
|
+
return 1.5;
|
|
1993
|
+
case "relaxed":
|
|
1994
|
+
return 1.625;
|
|
1995
|
+
case "loose":
|
|
1996
|
+
return 2;
|
|
1373
1997
|
default:
|
|
1374
1998
|
return null;
|
|
1375
1999
|
}
|
|
1376
2000
|
}
|
|
2001
|
+
function splitSizeLeading(value) {
|
|
2002
|
+
const i = value.indexOf("/");
|
|
2003
|
+
if (i === -1) return null;
|
|
2004
|
+
const size = textSize(value.slice(0, i));
|
|
2005
|
+
const leading = value.slice(i + 1);
|
|
2006
|
+
return size === null || leading === "" ? null : [size, leading];
|
|
2007
|
+
}
|
|
2008
|
+
function sizeLeadingNative(size, leading) {
|
|
2009
|
+
const rem = (n) => {
|
|
2010
|
+
const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
|
|
2011
|
+
if (unit === null) return null;
|
|
2012
|
+
const number = size.slice(0, -unit.length);
|
|
2013
|
+
const s = Number(number);
|
|
2014
|
+
return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
|
|
2015
|
+
};
|
|
2016
|
+
const arbitrary = arbitraryModifier(leading);
|
|
2017
|
+
if (arbitrary !== null) {
|
|
2018
|
+
if (arbitrary.startsWith("var(")) return null;
|
|
2019
|
+
const n = Number(arbitrary);
|
|
2020
|
+
return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
|
|
2021
|
+
}
|
|
2022
|
+
const scale = lineHeightSize(leading);
|
|
2023
|
+
if (scale !== null) return scale;
|
|
2024
|
+
const m = leadingNamed(leading);
|
|
2025
|
+
return m === null ? null : rem(m);
|
|
2026
|
+
}
|
|
2027
|
+
function arbitraryFontIsWeight(parsed, value) {
|
|
2028
|
+
const hint = parsed.typeHint ?? null;
|
|
2029
|
+
if (hint !== null) return hint === "number" || hint === "integer";
|
|
2030
|
+
return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
|
|
2031
|
+
}
|
|
1377
2032
|
function textAlign(key) {
|
|
1378
2033
|
switch (key) {
|
|
1379
2034
|
case "left":
|
|
@@ -1384,6 +2039,12 @@ function textAlign(key) {
|
|
|
1384
2039
|
return "right";
|
|
1385
2040
|
case "justify":
|
|
1386
2041
|
return "justify";
|
|
2042
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
2043
|
+
// as layout.rs's start/end inset properties.
|
|
2044
|
+
case "start":
|
|
2045
|
+
return "start";
|
|
2046
|
+
case "end":
|
|
2047
|
+
return "end";
|
|
1387
2048
|
default:
|
|
1388
2049
|
return null;
|
|
1389
2050
|
}
|
|
@@ -1392,6 +2053,10 @@ function fontWeight(key) {
|
|
|
1392
2053
|
switch (key) {
|
|
1393
2054
|
case "thin":
|
|
1394
2055
|
return "100";
|
|
2056
|
+
case "extralight":
|
|
2057
|
+
return "200";
|
|
2058
|
+
case "light":
|
|
2059
|
+
return "300";
|
|
1395
2060
|
case "normal":
|
|
1396
2061
|
return "400";
|
|
1397
2062
|
case "medium":
|
|
@@ -1402,6 +2067,22 @@ function fontWeight(key) {
|
|
|
1402
2067
|
return "700";
|
|
1403
2068
|
case "extrabold":
|
|
1404
2069
|
return "800";
|
|
2070
|
+
case "black":
|
|
2071
|
+
return "900";
|
|
2072
|
+
default:
|
|
2073
|
+
return null;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
function fontFamilyValue(theme, key) {
|
|
2077
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
2078
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
2079
|
+
switch (key) {
|
|
2080
|
+
case "sans":
|
|
2081
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
2082
|
+
case "serif":
|
|
2083
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
2084
|
+
case "mono":
|
|
2085
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1405
2086
|
default:
|
|
1406
2087
|
return null;
|
|
1407
2088
|
}
|
|
@@ -1410,8 +2091,14 @@ function fontWeight(key) {
|
|
|
1410
2091
|
// src/jsEngine/resolvers/effects.ts
|
|
1411
2092
|
function nativeShadowValue(key) {
|
|
1412
2093
|
switch (key) {
|
|
1413
|
-
|
|
2094
|
+
// Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
|
|
2095
|
+
// v3's `sm` is `xs`.
|
|
2096
|
+
case "2xs":
|
|
2097
|
+
return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
|
|
2098
|
+
case "xs":
|
|
1414
2099
|
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
2100
|
+
case "sm":
|
|
2101
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1415
2102
|
case "DEFAULT":
|
|
1416
2103
|
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1417
2104
|
case "md":
|
|
@@ -1443,13 +2130,115 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1443
2130
|
];
|
|
1444
2131
|
}
|
|
1445
2132
|
|
|
2133
|
+
// src/jsEngine/resolvers/transform.ts
|
|
2134
|
+
function scaleFactor(parsed) {
|
|
2135
|
+
if (parsed.value === null || parsed.value.trim() === "") return null;
|
|
2136
|
+
const n = Number(parsed.value);
|
|
2137
|
+
if (!Number.isFinite(n)) return null;
|
|
2138
|
+
const factor = parsed.isArbitrary ? n : n / 100;
|
|
2139
|
+
return parsed.negative ? -factor : factor;
|
|
2140
|
+
}
|
|
2141
|
+
function angle(parsed) {
|
|
2142
|
+
if (parsed.value === null) return null;
|
|
2143
|
+
if (parsed.isArbitrary) {
|
|
2144
|
+
if (!parsed.negative) return parsed.value;
|
|
2145
|
+
if (parsed.value.startsWith("-")) return parsed.value.slice(1);
|
|
2146
|
+
if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
|
|
2147
|
+
return `calc(${parsed.value} * -1)`;
|
|
2148
|
+
}
|
|
2149
|
+
const n = Number(parsed.value);
|
|
2150
|
+
if (!Number.isFinite(n)) return null;
|
|
2151
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
2152
|
+
}
|
|
2153
|
+
function resolveNative(parsed, theme) {
|
|
2154
|
+
switch (parsed.utility) {
|
|
2155
|
+
case "transform-none":
|
|
2156
|
+
return [decl("transform-op-none", "1")];
|
|
2157
|
+
// Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
|
|
2158
|
+
case "translate": {
|
|
2159
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
|
|
2160
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2161
|
+
return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
|
|
2162
|
+
}
|
|
2163
|
+
case "skew": {
|
|
2164
|
+
const deg = angle(parsed);
|
|
2165
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
|
|
2166
|
+
}
|
|
2167
|
+
case "backface-visible":
|
|
2168
|
+
return [decl("backface-visibility", "visible")];
|
|
2169
|
+
case "backface-hidden":
|
|
2170
|
+
return [decl("backface-visibility", "hidden")];
|
|
2171
|
+
case "translate-x": {
|
|
2172
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2173
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
2174
|
+
}
|
|
2175
|
+
case "translate-y": {
|
|
2176
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2177
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
2178
|
+
}
|
|
2179
|
+
case "scale": {
|
|
2180
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
|
|
2181
|
+
const n = scaleFactor(parsed);
|
|
2182
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
2183
|
+
}
|
|
2184
|
+
case "scale-x": {
|
|
2185
|
+
const n = scaleFactor(parsed);
|
|
2186
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
2187
|
+
}
|
|
2188
|
+
case "scale-y": {
|
|
2189
|
+
const n = scaleFactor(parsed);
|
|
2190
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
2191
|
+
}
|
|
2192
|
+
case "rotate": {
|
|
2193
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
|
|
2194
|
+
const deg = angle(parsed);
|
|
2195
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
2196
|
+
}
|
|
2197
|
+
case "rotate-x": {
|
|
2198
|
+
const deg = angle(parsed);
|
|
2199
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
2200
|
+
}
|
|
2201
|
+
case "rotate-y": {
|
|
2202
|
+
const deg = angle(parsed);
|
|
2203
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
2204
|
+
}
|
|
2205
|
+
case "rotate-z": {
|
|
2206
|
+
const deg = angle(parsed);
|
|
2207
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
2208
|
+
}
|
|
2209
|
+
case "skew-x": {
|
|
2210
|
+
const deg = angle(parsed);
|
|
2211
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
2212
|
+
}
|
|
2213
|
+
case "skew-y": {
|
|
2214
|
+
const deg = angle(parsed);
|
|
2215
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
2216
|
+
}
|
|
2217
|
+
default:
|
|
2218
|
+
return null;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
|
|
1446
2222
|
// src/jsEngine/resolveUtilityNative.ts
|
|
1447
|
-
function
|
|
2223
|
+
function firstFontName(stack) {
|
|
2224
|
+
const first = stack.split(",")[0] ?? stack;
|
|
2225
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
2226
|
+
}
|
|
2227
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1448
2228
|
switch (parsed.utility) {
|
|
1449
2229
|
case "font": {
|
|
1450
2230
|
if (parsed.value === null) return null;
|
|
2231
|
+
if (parsed.isArbitrary) {
|
|
2232
|
+
if (arbitraryFontIsWeight(parsed, parsed.value)) {
|
|
2233
|
+
const n = Number(parsed.value);
|
|
2234
|
+
return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
|
|
2235
|
+
}
|
|
2236
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
2237
|
+
}
|
|
1451
2238
|
const w = fontWeight(parsed.value);
|
|
1452
|
-
|
|
2239
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
2240
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
2241
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1453
2242
|
}
|
|
1454
2243
|
case "uppercase":
|
|
1455
2244
|
return [decl("text-transform", "uppercase")];
|
|
@@ -1485,16 +2274,27 @@ function resolveLeadingTrackingNative(parsed) {
|
|
|
1485
2274
|
return null;
|
|
1486
2275
|
}
|
|
1487
2276
|
function nativeHexColor(parsed, theme) {
|
|
1488
|
-
|
|
1489
|
-
if (value === null) return null;
|
|
1490
|
-
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
2277
|
+
return colorValue(theme, parsed);
|
|
1491
2278
|
}
|
|
1492
2279
|
function resolveTextNative(parsed, theme) {
|
|
1493
2280
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1494
2281
|
const size = textSize(parsed.value);
|
|
1495
2282
|
if (size !== null) return [decl("font-size", size)];
|
|
2283
|
+
const sized = splitSizeLeading(parsed.value);
|
|
2284
|
+
if (sized !== null) {
|
|
2285
|
+
const lh = sizeLeadingNative(sized[0], sized[1]);
|
|
2286
|
+
return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
|
|
2287
|
+
}
|
|
1496
2288
|
const align = textAlign(parsed.value);
|
|
1497
2289
|
if (align !== null) return [decl("text-align", align)];
|
|
2290
|
+
} else if (parsed.isArbitrary && parsed.value !== null) {
|
|
2291
|
+
const leading = parsed.modifier ?? null;
|
|
2292
|
+
if (isLength(parsed, parsed.value)) {
|
|
2293
|
+
if (leading === null) return [decl("font-size", parsed.value)];
|
|
2294
|
+
const lh = sizeLeadingNative(parsed.value, leading);
|
|
2295
|
+
return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
|
|
2296
|
+
}
|
|
2297
|
+
if (leading !== null) return null;
|
|
1498
2298
|
}
|
|
1499
2299
|
const hex = nativeHexColor(parsed, theme);
|
|
1500
2300
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1511,13 +2311,20 @@ function resolveColorNative(parsed, theme) {
|
|
|
1511
2311
|
return null;
|
|
1512
2312
|
}
|
|
1513
2313
|
}
|
|
2314
|
+
function resolveOpacityNative(parsed) {
|
|
2315
|
+
if (parsed.utility !== "opacity") return null;
|
|
2316
|
+
const v = resolvePercent(parsed);
|
|
2317
|
+
return v === null ? null : [decl("opacity", v)];
|
|
2318
|
+
}
|
|
1514
2319
|
function resolveUtilityNative(parsed, theme) {
|
|
1515
|
-
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
2320
|
+
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed, theme) ?? resolveOpacityNative(parsed) ?? nativeShadowDeclarations(parsed) ?? resolveNative(parsed, theme);
|
|
1516
2321
|
}
|
|
1517
2322
|
|
|
1518
2323
|
// src/jsEngine/resolveStyle.ts
|
|
1519
2324
|
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
2325
|
+
var STATE_HOLD_MARKER2 = "_kbon";
|
|
1520
2326
|
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
2327
|
+
if (modifier === STATE_HOLD_MARKER2) return true;
|
|
1521
2328
|
if (modifier === "dark") return colorScheme === "dark";
|
|
1522
2329
|
if (modifier === "active") return pressed;
|
|
1523
2330
|
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
@@ -1525,6 +2332,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1525
2332
|
if (minWidth === void 0) return null;
|
|
1526
2333
|
return width >= minWidth;
|
|
1527
2334
|
}
|
|
2335
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
2336
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
2337
|
+
return px === null ? null : width >= px;
|
|
2338
|
+
}
|
|
2339
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
2340
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
2341
|
+
return px === null ? null : width < px;
|
|
2342
|
+
}
|
|
2343
|
+
const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
|
|
2344
|
+
const custom = screen(modifier);
|
|
2345
|
+
if (typeof custom === "number") return width >= custom;
|
|
2346
|
+
if (modifier.startsWith("max-")) {
|
|
2347
|
+
const max = screen(modifier.slice(4));
|
|
2348
|
+
if (typeof max === "number") return width < max;
|
|
2349
|
+
}
|
|
2350
|
+
if (modifier.startsWith("min-")) {
|
|
2351
|
+
const min = screen(modifier.slice(4));
|
|
2352
|
+
if (typeof min === "number") return width >= min;
|
|
2353
|
+
}
|
|
2354
|
+
if (modifier.startsWith("not-")) {
|
|
2355
|
+
const rest = modifier.slice(4);
|
|
2356
|
+
if (rest === "dark") return colorScheme !== "dark";
|
|
2357
|
+
const isBreakpoint = (name) => typeof screen(name) === "number";
|
|
2358
|
+
if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
|
|
2359
|
+
const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
|
|
2360
|
+
return holds === null ? null : !holds;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
1528
2363
|
return null;
|
|
1529
2364
|
}
|
|
1530
2365
|
function kebabToCamel(s) {
|
|
@@ -1569,6 +2404,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1569
2404
|
"shadow-opacity",
|
|
1570
2405
|
"shadow-radius",
|
|
1571
2406
|
"elevation",
|
|
2407
|
+
"opacity",
|
|
1572
2408
|
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1573
2409
|
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1574
2410
|
// style system wants plain numbers for these exactly like the generic
|
|
@@ -1582,29 +2418,105 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1582
2418
|
"border-bottom-right-radius",
|
|
1583
2419
|
"border-bottom-left-radius",
|
|
1584
2420
|
"outline-width",
|
|
1585
|
-
"outline-offset"
|
|
2421
|
+
"outline-offset",
|
|
2422
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
2423
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
2424
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
2425
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
2426
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
2427
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
2428
|
+
// get collected into the final array.
|
|
2429
|
+
"transform-op-translate-x",
|
|
2430
|
+
"transform-op-translate-y",
|
|
2431
|
+
"transform-op-scale-x",
|
|
2432
|
+
"transform-op-scale-y"
|
|
1586
2433
|
]);
|
|
2434
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
2435
|
+
["transform-op-translate-x", "translateX"],
|
|
2436
|
+
["transform-op-translate-y", "translateY"],
|
|
2437
|
+
["transform-op-rotate", "rotate"],
|
|
2438
|
+
["transform-op-rotate-x", "rotateX"],
|
|
2439
|
+
["transform-op-rotate-y", "rotateY"],
|
|
2440
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
2441
|
+
["transform-op-skew-x", "skewX"],
|
|
2442
|
+
["transform-op-skew-y", "skewY"],
|
|
2443
|
+
["transform-op-scale-x", "scaleX"],
|
|
2444
|
+
["transform-op-scale-y", "scaleY"]
|
|
2445
|
+
]);
|
|
2446
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
2447
|
+
function isPlainPercentage(value) {
|
|
2448
|
+
if (!value.endsWith("%")) return false;
|
|
2449
|
+
let digits = value.slice(0, -1);
|
|
2450
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
2451
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
2452
|
+
}
|
|
2453
|
+
function sanitizeForWarning(value) {
|
|
2454
|
+
const MAX_CHARS = 60;
|
|
2455
|
+
const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
|
|
2456
|
+
if (escaped.length <= MAX_CHARS) return escaped;
|
|
2457
|
+
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
2458
|
+
}
|
|
1587
2459
|
function rnStyleValue(property, value) {
|
|
1588
|
-
if (
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
2460
|
+
if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
|
|
2461
|
+
const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
|
|
2462
|
+
const space = inner.lastIndexOf(" ");
|
|
2463
|
+
if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
|
|
2464
|
+
}
|
|
2465
|
+
if (property === "aspect-ratio") {
|
|
2466
|
+
if (value.trim() === "auto") return { value: null, warning: null };
|
|
2467
|
+
const parts = value.split("/").map((s) => s.trim());
|
|
2468
|
+
let n = null;
|
|
2469
|
+
if (parts.length === 1) {
|
|
2470
|
+
const a = Number(parts[0]);
|
|
2471
|
+
n = Number.isFinite(a) ? a : null;
|
|
2472
|
+
} else if (parts.length === 2) {
|
|
2473
|
+
const a = Number(parts[0]);
|
|
2474
|
+
const b = Number(parts[1]);
|
|
2475
|
+
n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
|
|
1599
2476
|
}
|
|
1600
|
-
|
|
2477
|
+
return { value: n, warning: null };
|
|
1601
2478
|
}
|
|
1602
|
-
|
|
2479
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
2480
|
+
return { value, warning: null };
|
|
2481
|
+
}
|
|
2482
|
+
if (value === "auto") {
|
|
2483
|
+
return { value: "auto", warning: null };
|
|
2484
|
+
}
|
|
2485
|
+
let px = null;
|
|
2486
|
+
if (value.endsWith("px")) {
|
|
2487
|
+
const n = Number(value.slice(0, -2));
|
|
2488
|
+
px = Number.isFinite(n) ? n : null;
|
|
2489
|
+
} else if (value.endsWith("rem")) {
|
|
2490
|
+
const n = Number(value.slice(0, -3));
|
|
2491
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
2492
|
+
} else {
|
|
2493
|
+
const n = Number(value);
|
|
2494
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
2495
|
+
}
|
|
2496
|
+
if (px !== null) return { value: px, warning: null };
|
|
2497
|
+
if (isPlainPercentage(value)) {
|
|
2498
|
+
return { value, warning: null };
|
|
2499
|
+
}
|
|
2500
|
+
const reduced = reduceConstantMath(value);
|
|
2501
|
+
if (reduced !== null) {
|
|
2502
|
+
return { value: reduced, warning: null };
|
|
2503
|
+
}
|
|
2504
|
+
const sanitizedValue = sanitizeForWarning(value);
|
|
2505
|
+
const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
2506
|
+
calc()/min()/max()/clamp() only resolve on native when every operand is a constant px/rem length (no %, vw, vh, var(), or other viewport/CSS-variable units \u2014 those need real layout/DOM, which doesn't exist on native at paint time).
|
|
2507
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
2508
|
+
return { value: null, warning };
|
|
1603
2509
|
}
|
|
1604
|
-
function
|
|
2510
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
2511
|
+
classString = expandVariantGroups(classString);
|
|
1605
2512
|
const style = {};
|
|
2513
|
+
const warnings = [];
|
|
1606
2514
|
let shadowOffset = null;
|
|
1607
|
-
|
|
2515
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
2516
|
+
const keySpecificity = /* @__PURE__ */ new Map();
|
|
2517
|
+
const transformSpecificity = /* @__PURE__ */ new Map();
|
|
2518
|
+
for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
|
|
2519
|
+
const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
|
|
1608
2520
|
const parsed = parseClass(token);
|
|
1609
2521
|
const allModifiersHold = parsed.modifiers.every(
|
|
1610
2522
|
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
@@ -1612,36 +2524,121 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1612
2524
|
if (!allModifiersHold) continue;
|
|
1613
2525
|
const decls = resolveUtilityNative(parsed, theme);
|
|
1614
2526
|
if (decls === null) continue;
|
|
2527
|
+
const spec = parsed.modifiers.length;
|
|
1615
2528
|
for (const d of decls) {
|
|
1616
2529
|
if (d.property.startsWith("__")) {
|
|
1617
2530
|
continue;
|
|
1618
2531
|
}
|
|
2532
|
+
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
|
|
2533
|
+
continue;
|
|
2534
|
+
}
|
|
1619
2535
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
2536
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1620
2537
|
const n = Number(d.value);
|
|
1621
2538
|
if (!Number.isFinite(n)) continue;
|
|
1622
2539
|
if (shadowOffset === null) shadowOffset = {};
|
|
1623
2540
|
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
2541
|
+
keySpecificity.set("shadowOffset", spec);
|
|
1624
2542
|
continue;
|
|
1625
2543
|
}
|
|
1626
|
-
|
|
2544
|
+
if (d.property === "transform-op-none") {
|
|
2545
|
+
transformOps.clear();
|
|
2546
|
+
transformSpecificity.clear();
|
|
2547
|
+
continue;
|
|
2548
|
+
}
|
|
2549
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
2550
|
+
if (opKey !== void 0) {
|
|
2551
|
+
if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
|
|
2552
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
2553
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
2554
|
+
if (value2 !== null) {
|
|
2555
|
+
transformOps.set(opKey, value2);
|
|
2556
|
+
transformSpecificity.set(opKey, spec);
|
|
2557
|
+
}
|
|
2558
|
+
continue;
|
|
2559
|
+
}
|
|
2560
|
+
const key = kebabToCamel(d.property);
|
|
2561
|
+
if (spec < (keySpecificity.get(key) ?? 0)) continue;
|
|
2562
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
2563
|
+
if (warning !== null) warnings.push(warning);
|
|
2564
|
+
if (value !== null) {
|
|
2565
|
+
style[key] = value;
|
|
2566
|
+
keySpecificity.set(key, spec);
|
|
2567
|
+
}
|
|
1627
2568
|
}
|
|
1628
2569
|
}
|
|
1629
2570
|
if (shadowOffset !== null) {
|
|
1630
2571
|
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1631
2572
|
}
|
|
1632
|
-
|
|
2573
|
+
if (transformOps.size > 0) {
|
|
2574
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
2575
|
+
[key]: transformOps.get(key)
|
|
2576
|
+
}));
|
|
2577
|
+
}
|
|
2578
|
+
return { style, warnings };
|
|
1633
2579
|
}
|
|
1634
2580
|
|
|
1635
2581
|
// src/nativeBridge.ts
|
|
2582
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
2583
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
2584
|
+
var cachedForThemeJson = null;
|
|
1636
2585
|
function resolveStyle(classString, pressed = false) {
|
|
1637
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1638
|
-
const width =
|
|
1639
|
-
const
|
|
2586
|
+
const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
|
|
2587
|
+
const width = import_react_native2.Dimensions.get("window").width;
|
|
2588
|
+
const themeJson = (0, import_theme2.getThemeJson)();
|
|
2589
|
+
if (themeJson !== cachedForThemeJson) {
|
|
2590
|
+
resolveStyleCache.clear();
|
|
2591
|
+
cachedForThemeJson = themeJson;
|
|
2592
|
+
}
|
|
2593
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
2594
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
2595
|
+
if (cached !== void 0) return { ...cached };
|
|
2596
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
2597
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
2598
|
+
resolveStyleCache.set(cacheKey, style);
|
|
2599
|
+
return { ...style };
|
|
2600
|
+
}
|
|
2601
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
2602
|
+
const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
|
|
1640
2603
|
if (!KbachModule) {
|
|
1641
|
-
|
|
2604
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
|
|
2605
|
+
warnIfDev(classString, warnings2);
|
|
2606
|
+
return style2;
|
|
2607
|
+
}
|
|
2608
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
2609
|
+
const style = JSON.parse(json);
|
|
2610
|
+
const warnings = style.__kbachWarnings;
|
|
2611
|
+
if (warnings !== void 0) {
|
|
2612
|
+
delete style.__kbachWarnings;
|
|
2613
|
+
warnIfDev(classString, warnings);
|
|
2614
|
+
}
|
|
2615
|
+
return style;
|
|
2616
|
+
}
|
|
2617
|
+
var WARNED_MESSAGES_MAX = 500;
|
|
2618
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
2619
|
+
var QUOTED_TOKEN_RE = /"([^"]*)"/;
|
|
2620
|
+
function highlightToken(classString, warning) {
|
|
2621
|
+
const match = QUOTED_TOKEN_RE.exec(warning);
|
|
2622
|
+
if (match === null) return classString;
|
|
2623
|
+
const quoted = match[1].replace(/\s+/g, "");
|
|
2624
|
+
if (quoted === "") return classString;
|
|
2625
|
+
const parts = classString.split(/(\s+)/);
|
|
2626
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
2627
|
+
if (idx === -1) return classString;
|
|
2628
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
2629
|
+
return parts.join("");
|
|
2630
|
+
}
|
|
2631
|
+
function warnIfDev(classString, warnings) {
|
|
2632
|
+
if (warnings.length === 0) return;
|
|
2633
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
2634
|
+
for (const warning of warnings) {
|
|
2635
|
+
const message = `${warning}
|
|
2636
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
2637
|
+
if (warnedMessages.has(message)) continue;
|
|
2638
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
2639
|
+
warnedMessages.add(message);
|
|
2640
|
+
console.warn(message);
|
|
1642
2641
|
}
|
|
1643
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1644
|
-
return JSON.parse(json);
|
|
1645
2642
|
}
|
|
1646
2643
|
|
|
1647
2644
|
// src/jsx-runtime.tsx
|