@kbach/react-native 1.0.0-beta.9 → 1.0.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 +495 -0
- package/LICENSE +21 -0
- package/README.md +198 -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-7CNURQSH.mjs +112 -0
- package/dist/{chunk-YOC3SHF5.mjs → chunk-HYQFT32E.mjs} +2 -2
- package/dist/chunk-MUPEQJRT.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 +1300 -610
- 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 +1532 -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 +1522 -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,641 @@ 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
|
+
|
|
696
1145
|
// src/jsEngine/shared.ts
|
|
697
1146
|
function decl(property, value) {
|
|
698
1147
|
return { property, value };
|
|
@@ -700,6 +1149,7 @@ function decl(property, value) {
|
|
|
700
1149
|
function spacingPx(theme, value) {
|
|
701
1150
|
const fromTable = theme.spacing[value];
|
|
702
1151
|
if (fromTable !== void 0) return fromTable;
|
|
1152
|
+
if (value === "px") return 1;
|
|
703
1153
|
const n = Number(value);
|
|
704
1154
|
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
705
1155
|
}
|
|
@@ -715,7 +1165,10 @@ function resolveLength(theme, parsed) {
|
|
|
715
1165
|
}
|
|
716
1166
|
function resolveNegatableLength(theme, parsed) {
|
|
717
1167
|
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
718
|
-
if (parsed.isArbitrary)
|
|
1168
|
+
if (parsed.isArbitrary) {
|
|
1169
|
+
const value2 = parsed.value;
|
|
1170
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
1171
|
+
}
|
|
719
1172
|
const value = parsed.value;
|
|
720
1173
|
if (value === null) return null;
|
|
721
1174
|
const px = spacingPx(theme, value);
|
|
@@ -723,11 +1176,71 @@ function resolveNegatableLength(theme, parsed) {
|
|
|
723
1176
|
if (px === 0) return "0px";
|
|
724
1177
|
return `-${px}px`;
|
|
725
1178
|
}
|
|
1179
|
+
function fractionPercent(value) {
|
|
1180
|
+
const slashIdx = value.indexOf("/");
|
|
1181
|
+
if (slashIdx === -1) return null;
|
|
1182
|
+
const numStr = value.slice(0, slashIdx);
|
|
1183
|
+
const denStr = value.slice(slashIdx + 1);
|
|
1184
|
+
const num = Number(numStr);
|
|
1185
|
+
const den = Number(denStr);
|
|
1186
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
1187
|
+
if (den === 0) return null;
|
|
1188
|
+
const pct = num / den * 100;
|
|
1189
|
+
const formatted = pct.toFixed(6);
|
|
1190
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
1191
|
+
return `${trimmed}%`;
|
|
1192
|
+
}
|
|
1193
|
+
function resolveNegatableSize(theme, parsed) {
|
|
1194
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1195
|
+
if (parsed.negative && parsed.value === "full") return "-100%";
|
|
1196
|
+
const pct = fractionPercent(parsed.value);
|
|
1197
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
1198
|
+
}
|
|
1199
|
+
return resolveNegatableLength(theme, parsed);
|
|
1200
|
+
}
|
|
1201
|
+
function negate(value) {
|
|
1202
|
+
const numeric = (v) => /^[\d.]/.test(v);
|
|
1203
|
+
if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
|
|
1204
|
+
return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
|
|
1205
|
+
}
|
|
1206
|
+
function resolvePercent(parsed) {
|
|
1207
|
+
if (parsed.negative) return null;
|
|
1208
|
+
const value = parsed.value;
|
|
1209
|
+
if (value === null) return null;
|
|
1210
|
+
if (parsed.isArbitrary) return value;
|
|
1211
|
+
const pct = Number(value);
|
|
1212
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
1213
|
+
return String(pct / 100);
|
|
1214
|
+
}
|
|
726
1215
|
|
|
727
1216
|
// src/jsEngine/resolvers/layout.ts
|
|
728
1217
|
function negateRaw(value, negative) {
|
|
729
1218
|
return negative ? `-${value}` : value;
|
|
730
1219
|
}
|
|
1220
|
+
var WHOLE = /^\d+$/;
|
|
1221
|
+
var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
1222
|
+
function overflowAxisValue(property, value) {
|
|
1223
|
+
switch (value) {
|
|
1224
|
+
case "auto":
|
|
1225
|
+
case "hidden":
|
|
1226
|
+
case "clip":
|
|
1227
|
+
case "visible":
|
|
1228
|
+
case "scroll":
|
|
1229
|
+
return [decl(property, value)];
|
|
1230
|
+
default:
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
function overscrollValue(property, value) {
|
|
1235
|
+
switch (value) {
|
|
1236
|
+
case "auto":
|
|
1237
|
+
case "contain":
|
|
1238
|
+
case "none":
|
|
1239
|
+
return [decl(property, value)];
|
|
1240
|
+
default:
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
731
1244
|
function resolve(parsed, theme) {
|
|
732
1245
|
switch (parsed.utility) {
|
|
733
1246
|
case "flex":
|
|
@@ -774,6 +1287,12 @@ function resolve(parsed, theme) {
|
|
|
774
1287
|
return [decl("justify-content", "space-around")];
|
|
775
1288
|
case "justify-evenly":
|
|
776
1289
|
return [decl("justify-content", "space-evenly")];
|
|
1290
|
+
case "justify-normal":
|
|
1291
|
+
return [decl("justify-content", "normal")];
|
|
1292
|
+
case "justify-stretch":
|
|
1293
|
+
return [decl("justify-content", "stretch")];
|
|
1294
|
+
case "content-normal":
|
|
1295
|
+
return [decl("align-content", "normal")];
|
|
777
1296
|
case "content-start":
|
|
778
1297
|
return [decl("align-content", "flex-start")];
|
|
779
1298
|
case "content-end":
|
|
@@ -808,6 +1327,18 @@ function resolve(parsed, theme) {
|
|
|
808
1327
|
return [decl("overflow", "scroll")];
|
|
809
1328
|
case "overflow-visible":
|
|
810
1329
|
return [decl("overflow", "visible")];
|
|
1330
|
+
case "overflow-clip":
|
|
1331
|
+
return [decl("overflow", "clip")];
|
|
1332
|
+
case "overflow-x":
|
|
1333
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
1334
|
+
case "overflow-y":
|
|
1335
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
1336
|
+
case "overscroll":
|
|
1337
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
1338
|
+
case "overscroll-x":
|
|
1339
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
1340
|
+
case "overscroll-y":
|
|
1341
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
811
1342
|
case "static":
|
|
812
1343
|
return [decl("position", "static")];
|
|
813
1344
|
case "relative":
|
|
@@ -818,40 +1349,91 @@ function resolve(parsed, theme) {
|
|
|
818
1349
|
return [decl("position", "fixed")];
|
|
819
1350
|
case "sticky":
|
|
820
1351
|
return [decl("position", "sticky")];
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
1352
|
+
// Only real values, mirroring layout.rs: a whole number, z-auto, the
|
|
1353
|
+
// order-first/-last/-none keywords, or an arbitrary [...]. Anything
|
|
1354
|
+
// else used to pass straight through (z-banana -> z-index: banana).
|
|
1355
|
+
case "z": {
|
|
1356
|
+
const v = parsed.value;
|
|
1357
|
+
if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
|
|
1358
|
+
return [decl("z-index", negateRaw(v, parsed.negative))];
|
|
1359
|
+
}
|
|
1360
|
+
case "order": {
|
|
1361
|
+
const v = parsed.value;
|
|
1362
|
+
if (v === null) return null;
|
|
1363
|
+
if (v === "first") return [decl("order", "-9999")];
|
|
1364
|
+
if (v === "last") return [decl("order", "9999")];
|
|
1365
|
+
if (v === "none") return [decl("order", "0")];
|
|
1366
|
+
if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
|
|
1367
|
+
return [decl("order", negateRaw(v, parsed.negative))];
|
|
1368
|
+
}
|
|
825
1369
|
case "grow":
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1370
|
+
case "shrink": {
|
|
1371
|
+
const v = parsed.value ?? "1";
|
|
1372
|
+
if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
|
|
1373
|
+
return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
|
|
1374
|
+
}
|
|
829
1375
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
830
|
-
// convention ("-top-4")
|
|
1376
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
1377
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
831
1378
|
case "top": {
|
|
832
|
-
const v =
|
|
1379
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
833
1380
|
return v === null ? null : [decl("top", v)];
|
|
834
1381
|
}
|
|
835
1382
|
case "right": {
|
|
836
|
-
const v =
|
|
1383
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
837
1384
|
return v === null ? null : [decl("right", v)];
|
|
838
1385
|
}
|
|
839
1386
|
case "bottom": {
|
|
840
|
-
const v =
|
|
1387
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
841
1388
|
return v === null ? null : [decl("bottom", v)];
|
|
842
1389
|
}
|
|
843
1390
|
case "left": {
|
|
844
|
-
const v =
|
|
1391
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
845
1392
|
return v === null ? null : [decl("left", v)];
|
|
846
1393
|
}
|
|
847
1394
|
case "inset": {
|
|
848
|
-
const v =
|
|
1395
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
849
1396
|
return v === null ? null : [decl("inset", v)];
|
|
850
1397
|
}
|
|
851
|
-
case "
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1398
|
+
case "inset-x": {
|
|
1399
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1400
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
1401
|
+
}
|
|
1402
|
+
case "inset-y": {
|
|
1403
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1404
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
1405
|
+
}
|
|
1406
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
1407
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
1408
|
+
case "start": {
|
|
1409
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1410
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
1411
|
+
}
|
|
1412
|
+
case "end": {
|
|
1413
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1414
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
1415
|
+
}
|
|
1416
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
1417
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
1418
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
1419
|
+
// "aspect" arm.
|
|
1420
|
+
case "aspect": {
|
|
1421
|
+
const value = parsed.value;
|
|
1422
|
+
if (value === null) return null;
|
|
1423
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
1424
|
+
switch (value) {
|
|
1425
|
+
case "square":
|
|
1426
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
1427
|
+
case "video":
|
|
1428
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
1429
|
+
case "auto":
|
|
1430
|
+
return [decl("aspect-ratio", "auto")];
|
|
1431
|
+
default: {
|
|
1432
|
+
const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
|
|
1433
|
+
return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
855
1437
|
default:
|
|
856
1438
|
return null;
|
|
857
1439
|
}
|
|
@@ -893,7 +1475,7 @@ function resolveFlex(parsed, web) {
|
|
|
893
1475
|
case "shrink-0":
|
|
894
1476
|
return [decl("flex-shrink", "0")];
|
|
895
1477
|
default:
|
|
896
|
-
return null;
|
|
1478
|
+
return /^\d+$/.test(value) ? [decl("flex", value)] : null;
|
|
897
1479
|
}
|
|
898
1480
|
}
|
|
899
1481
|
|
|
@@ -928,20 +1510,6 @@ function namedSize(key) {
|
|
|
928
1510
|
return null;
|
|
929
1511
|
}
|
|
930
1512
|
}
|
|
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
1513
|
function cssSizeKeyword(key) {
|
|
946
1514
|
switch (key) {
|
|
947
1515
|
case "min":
|
|
@@ -1075,19 +1643,16 @@ function resolve2(parsed, theme) {
|
|
|
1075
1643
|
}
|
|
1076
1644
|
}
|
|
1077
1645
|
|
|
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
1646
|
// src/jsEngine/resolvers/border.ts
|
|
1085
1647
|
function radiusSize(key) {
|
|
1086
1648
|
switch (key) {
|
|
1087
1649
|
case "none":
|
|
1088
1650
|
return "0px";
|
|
1089
|
-
|
|
1651
|
+
// Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
|
|
1652
|
+
case "xs":
|
|
1090
1653
|
return "0.125rem";
|
|
1654
|
+
case "sm":
|
|
1655
|
+
return "0.25rem";
|
|
1091
1656
|
case "md":
|
|
1092
1657
|
return "0.375rem";
|
|
1093
1658
|
case "lg":
|
|
@@ -1098,12 +1663,19 @@ function radiusSize(key) {
|
|
|
1098
1663
|
return "1rem";
|
|
1099
1664
|
case "3xl":
|
|
1100
1665
|
return "1.5rem";
|
|
1666
|
+
case "4xl":
|
|
1667
|
+
return "2rem";
|
|
1101
1668
|
case "full":
|
|
1102
1669
|
return "9999px";
|
|
1103
1670
|
default:
|
|
1104
1671
|
return null;
|
|
1105
1672
|
}
|
|
1106
1673
|
}
|
|
1674
|
+
function borderWidthPx(parsed) {
|
|
1675
|
+
if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
|
|
1676
|
+
const n = Number(parsed.value);
|
|
1677
|
+
return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
|
|
1678
|
+
}
|
|
1107
1679
|
function borderSideProperty(side) {
|
|
1108
1680
|
switch (side) {
|
|
1109
1681
|
case "t":
|
|
@@ -1126,49 +1698,68 @@ function borderValue(theme, parsed) {
|
|
|
1126
1698
|
if (side !== null) {
|
|
1127
1699
|
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1128
1700
|
}
|
|
1701
|
+
const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
|
|
1702
|
+
if (pair !== null) {
|
|
1703
|
+
return [
|
|
1704
|
+
decl(`${pair[0]}-width`, "1px"),
|
|
1705
|
+
decl(`${pair[1]}-width`, "1px"),
|
|
1706
|
+
decl(`${pair[0]}-style`, "solid"),
|
|
1707
|
+
decl(`${pair[1]}-style`, "solid")
|
|
1708
|
+
];
|
|
1709
|
+
}
|
|
1129
1710
|
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1130
1711
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1131
1712
|
}
|
|
1132
1713
|
if (parsed.isArbitrary) {
|
|
1133
|
-
return [decl("border-width", value)];
|
|
1714
|
+
if (isLength(parsed, value)) return [decl("border-width", value)];
|
|
1715
|
+
const color2 = colorValue(theme, parsed);
|
|
1716
|
+
return color2 === null ? null : [decl("border-color", color2)];
|
|
1134
1717
|
}
|
|
1135
1718
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1136
|
-
const v =
|
|
1719
|
+
const v = borderWidthPx(parsed);
|
|
1137
1720
|
return v === null ? null : [decl("border-width", v)];
|
|
1138
1721
|
}
|
|
1139
1722
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1140
1723
|
return [decl("border-style", value)];
|
|
1141
1724
|
}
|
|
1142
|
-
const
|
|
1143
|
-
return
|
|
1725
|
+
const color = colorValue(theme, parsed);
|
|
1726
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1144
1727
|
}
|
|
1145
1728
|
function borderSideValue(theme, parsed, sideProperty) {
|
|
1146
1729
|
const value = parsed.value;
|
|
1147
1730
|
if (value === null) return null;
|
|
1148
|
-
if (parsed.isArbitrary)
|
|
1731
|
+
if (parsed.isArbitrary) {
|
|
1732
|
+
if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
|
|
1733
|
+
const color2 = colorValue(theme, parsed);
|
|
1734
|
+
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
1735
|
+
}
|
|
1149
1736
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1150
|
-
const v =
|
|
1737
|
+
const v = borderWidthPx(parsed);
|
|
1151
1738
|
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1152
1739
|
}
|
|
1153
1740
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1154
1741
|
return [decl(`${sideProperty}-style`, value)];
|
|
1155
1742
|
}
|
|
1156
|
-
const
|
|
1157
|
-
return
|
|
1743
|
+
const color = colorValue(theme, parsed);
|
|
1744
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1158
1745
|
}
|
|
1159
1746
|
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1160
1747
|
const value = parsed.value;
|
|
1161
1748
|
if (value === null) return null;
|
|
1162
|
-
if (parsed.isArbitrary)
|
|
1749
|
+
if (parsed.isArbitrary) {
|
|
1750
|
+
if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1751
|
+
const color2 = colorValue(theme, parsed);
|
|
1752
|
+
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1753
|
+
}
|
|
1163
1754
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1164
|
-
const v =
|
|
1755
|
+
const v = borderWidthPx(parsed);
|
|
1165
1756
|
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1166
1757
|
}
|
|
1167
1758
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1168
1759
|
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1169
1760
|
}
|
|
1170
|
-
const
|
|
1171
|
-
return
|
|
1761
|
+
const color = colorValue(theme, parsed);
|
|
1762
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1172
1763
|
}
|
|
1173
1764
|
function radiusProperties(side) {
|
|
1174
1765
|
switch (side) {
|
|
@@ -1208,79 +1799,28 @@ function resolveRadiusSide(theme, parsed, side) {
|
|
|
1208
1799
|
}
|
|
1209
1800
|
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1210
1801
|
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
|
-
}
|
|
1802
|
+
return /^\d+$/.test(key) ? `${Number(key)}px` : null;
|
|
1225
1803
|
}
|
|
1226
1804
|
function outlineValue(theme, parsed) {
|
|
1227
1805
|
const value = parsed.value;
|
|
1228
1806
|
if (value === null) return null;
|
|
1229
|
-
if (parsed.isArbitrary)
|
|
1807
|
+
if (parsed.isArbitrary) {
|
|
1808
|
+
if (isLength(parsed, value)) return [decl("outline-width", value)];
|
|
1809
|
+
const color2 = colorValue(theme, parsed);
|
|
1810
|
+
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1811
|
+
}
|
|
1230
1812
|
const w = outlineWidthValue(value);
|
|
1231
1813
|
if (w !== null) return [decl("outline-width", w)];
|
|
1232
1814
|
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1815
|
+
const color = colorValue(theme, parsed);
|
|
1816
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1235
1817
|
}
|
|
1236
1818
|
function outlineOffsetValue(parsed) {
|
|
1237
1819
|
const value = parsed.value;
|
|
1238
1820
|
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)];
|
|
1821
|
+
const v = parsed.isArbitrary ? value : outlineWidthValue(value);
|
|
1822
|
+
if (v === null) return null;
|
|
1823
|
+
return [decl("outline-offset", parsed.negative ? negate(v) : v)];
|
|
1284
1824
|
}
|
|
1285
1825
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1286
1826
|
function resolve3(parsed, theme) {
|
|
@@ -1310,14 +1850,19 @@ function resolve3(parsed, theme) {
|
|
|
1310
1850
|
const v = resolveLength(theme, parsed);
|
|
1311
1851
|
return v === null ? null : [decl("border-radius", v)];
|
|
1312
1852
|
}
|
|
1853
|
+
// Rings are web-only (a var()-composed CSS box-shadow React Native can't
|
|
1854
|
+
// parse) — same as resolvers/mod.rs's native dispatcher.
|
|
1313
1855
|
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
1856
|
case "ring-offset":
|
|
1317
|
-
return
|
|
1857
|
+
return null;
|
|
1858
|
+
// Outlines: the same final native style the Rust engine produces once
|
|
1859
|
+
// its var()-based web declarations are filtered out (resolve_style.rs):
|
|
1860
|
+
// bare `outline` is a 1px width, `outline-none` is outline-style: none,
|
|
1861
|
+
// `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
|
|
1318
1862
|
case "outline":
|
|
1319
|
-
if (parsed.value === null) return [decl("outline-
|
|
1320
|
-
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1863
|
+
if (parsed.value === null) return [decl("outline-width", "1px")];
|
|
1864
|
+
if (parsed.value === "none") return [decl("outline-style", "none")];
|
|
1865
|
+
if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
|
|
1321
1866
|
return outlineValue(theme, parsed);
|
|
1322
1867
|
case "outline-offset":
|
|
1323
1868
|
return outlineOffsetValue(parsed);
|
|
@@ -1348,32 +1893,75 @@ function textSize(key) {
|
|
|
1348
1893
|
return "1.875rem";
|
|
1349
1894
|
case "4xl":
|
|
1350
1895
|
return "2.25rem";
|
|
1896
|
+
case "5xl":
|
|
1897
|
+
return "3rem";
|
|
1898
|
+
case "6xl":
|
|
1899
|
+
return "3.75rem";
|
|
1900
|
+
case "7xl":
|
|
1901
|
+
return "4.5rem";
|
|
1902
|
+
case "8xl":
|
|
1903
|
+
return "6rem";
|
|
1904
|
+
case "9xl":
|
|
1905
|
+
return "8rem";
|
|
1351
1906
|
default:
|
|
1352
1907
|
return null;
|
|
1353
1908
|
}
|
|
1354
1909
|
}
|
|
1355
1910
|
function lineHeightSize(key) {
|
|
1911
|
+
if (key === "px") return "1px";
|
|
1912
|
+
if (key.trim() === "") return null;
|
|
1913
|
+
const n = Number(key);
|
|
1914
|
+
return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
|
|
1915
|
+
}
|
|
1916
|
+
function leadingNamed(key) {
|
|
1356
1917
|
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";
|
|
1918
|
+
case "none":
|
|
1919
|
+
return 1;
|
|
1920
|
+
case "tight":
|
|
1921
|
+
return 1.25;
|
|
1922
|
+
case "snug":
|
|
1923
|
+
return 1.375;
|
|
1924
|
+
case "normal":
|
|
1925
|
+
return 1.5;
|
|
1926
|
+
case "relaxed":
|
|
1927
|
+
return 1.625;
|
|
1928
|
+
case "loose":
|
|
1929
|
+
return 2;
|
|
1373
1930
|
default:
|
|
1374
1931
|
return null;
|
|
1375
1932
|
}
|
|
1376
1933
|
}
|
|
1934
|
+
function splitSizeLeading(value) {
|
|
1935
|
+
const i = value.indexOf("/");
|
|
1936
|
+
if (i === -1) return null;
|
|
1937
|
+
const size = textSize(value.slice(0, i));
|
|
1938
|
+
const leading = value.slice(i + 1);
|
|
1939
|
+
return size === null || leading === "" ? null : [size, leading];
|
|
1940
|
+
}
|
|
1941
|
+
function sizeLeadingNative(size, leading) {
|
|
1942
|
+
const rem = (n) => {
|
|
1943
|
+
const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
|
|
1944
|
+
if (unit === null) return null;
|
|
1945
|
+
const number = size.slice(0, -unit.length);
|
|
1946
|
+
const s = Number(number);
|
|
1947
|
+
return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
|
|
1948
|
+
};
|
|
1949
|
+
const arbitrary = arbitraryModifier(leading);
|
|
1950
|
+
if (arbitrary !== null) {
|
|
1951
|
+
if (arbitrary.startsWith("var(")) return null;
|
|
1952
|
+
const n = Number(arbitrary);
|
|
1953
|
+
return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
|
|
1954
|
+
}
|
|
1955
|
+
const scale = lineHeightSize(leading);
|
|
1956
|
+
if (scale !== null) return scale;
|
|
1957
|
+
const m = leadingNamed(leading);
|
|
1958
|
+
return m === null ? null : rem(m);
|
|
1959
|
+
}
|
|
1960
|
+
function arbitraryFontIsWeight(parsed, value) {
|
|
1961
|
+
const hint = parsed.typeHint ?? null;
|
|
1962
|
+
if (hint !== null) return hint === "number" || hint === "integer";
|
|
1963
|
+
return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
|
|
1964
|
+
}
|
|
1377
1965
|
function textAlign(key) {
|
|
1378
1966
|
switch (key) {
|
|
1379
1967
|
case "left":
|
|
@@ -1384,6 +1972,12 @@ function textAlign(key) {
|
|
|
1384
1972
|
return "right";
|
|
1385
1973
|
case "justify":
|
|
1386
1974
|
return "justify";
|
|
1975
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1976
|
+
// as layout.rs's start/end inset properties.
|
|
1977
|
+
case "start":
|
|
1978
|
+
return "start";
|
|
1979
|
+
case "end":
|
|
1980
|
+
return "end";
|
|
1387
1981
|
default:
|
|
1388
1982
|
return null;
|
|
1389
1983
|
}
|
|
@@ -1392,6 +1986,10 @@ function fontWeight(key) {
|
|
|
1392
1986
|
switch (key) {
|
|
1393
1987
|
case "thin":
|
|
1394
1988
|
return "100";
|
|
1989
|
+
case "extralight":
|
|
1990
|
+
return "200";
|
|
1991
|
+
case "light":
|
|
1992
|
+
return "300";
|
|
1395
1993
|
case "normal":
|
|
1396
1994
|
return "400";
|
|
1397
1995
|
case "medium":
|
|
@@ -1402,6 +2000,22 @@ function fontWeight(key) {
|
|
|
1402
2000
|
return "700";
|
|
1403
2001
|
case "extrabold":
|
|
1404
2002
|
return "800";
|
|
2003
|
+
case "black":
|
|
2004
|
+
return "900";
|
|
2005
|
+
default:
|
|
2006
|
+
return null;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function fontFamilyValue(theme, key) {
|
|
2010
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
2011
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
2012
|
+
switch (key) {
|
|
2013
|
+
case "sans":
|
|
2014
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
2015
|
+
case "serif":
|
|
2016
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
2017
|
+
case "mono":
|
|
2018
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1405
2019
|
default:
|
|
1406
2020
|
return null;
|
|
1407
2021
|
}
|
|
@@ -1410,8 +2024,14 @@ function fontWeight(key) {
|
|
|
1410
2024
|
// src/jsEngine/resolvers/effects.ts
|
|
1411
2025
|
function nativeShadowValue(key) {
|
|
1412
2026
|
switch (key) {
|
|
1413
|
-
|
|
2027
|
+
// Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
|
|
2028
|
+
// v3's `sm` is `xs`.
|
|
2029
|
+
case "2xs":
|
|
2030
|
+
return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
|
|
2031
|
+
case "xs":
|
|
1414
2032
|
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
2033
|
+
case "sm":
|
|
2034
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1415
2035
|
case "DEFAULT":
|
|
1416
2036
|
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1417
2037
|
case "md":
|
|
@@ -1443,13 +2063,115 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1443
2063
|
];
|
|
1444
2064
|
}
|
|
1445
2065
|
|
|
2066
|
+
// src/jsEngine/resolvers/transform.ts
|
|
2067
|
+
function scaleFactor(parsed) {
|
|
2068
|
+
if (parsed.value === null || parsed.value.trim() === "") return null;
|
|
2069
|
+
const n = Number(parsed.value);
|
|
2070
|
+
if (!Number.isFinite(n)) return null;
|
|
2071
|
+
const factor = parsed.isArbitrary ? n : n / 100;
|
|
2072
|
+
return parsed.negative ? -factor : factor;
|
|
2073
|
+
}
|
|
2074
|
+
function angle(parsed) {
|
|
2075
|
+
if (parsed.value === null) return null;
|
|
2076
|
+
if (parsed.isArbitrary) {
|
|
2077
|
+
if (!parsed.negative) return parsed.value;
|
|
2078
|
+
if (parsed.value.startsWith("-")) return parsed.value.slice(1);
|
|
2079
|
+
if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
|
|
2080
|
+
return `calc(${parsed.value} * -1)`;
|
|
2081
|
+
}
|
|
2082
|
+
const n = Number(parsed.value);
|
|
2083
|
+
if (!Number.isFinite(n)) return null;
|
|
2084
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
2085
|
+
}
|
|
2086
|
+
function resolveNative(parsed, theme) {
|
|
2087
|
+
switch (parsed.utility) {
|
|
2088
|
+
case "transform-none":
|
|
2089
|
+
return [decl("transform-op-none", "1")];
|
|
2090
|
+
// Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
|
|
2091
|
+
case "translate": {
|
|
2092
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
|
|
2093
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2094
|
+
return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
|
|
2095
|
+
}
|
|
2096
|
+
case "skew": {
|
|
2097
|
+
const deg = angle(parsed);
|
|
2098
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
|
|
2099
|
+
}
|
|
2100
|
+
case "backface-visible":
|
|
2101
|
+
return [decl("backface-visibility", "visible")];
|
|
2102
|
+
case "backface-hidden":
|
|
2103
|
+
return [decl("backface-visibility", "hidden")];
|
|
2104
|
+
case "translate-x": {
|
|
2105
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2106
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
2107
|
+
}
|
|
2108
|
+
case "translate-y": {
|
|
2109
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2110
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
2111
|
+
}
|
|
2112
|
+
case "scale": {
|
|
2113
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
|
|
2114
|
+
const n = scaleFactor(parsed);
|
|
2115
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
2116
|
+
}
|
|
2117
|
+
case "scale-x": {
|
|
2118
|
+
const n = scaleFactor(parsed);
|
|
2119
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
2120
|
+
}
|
|
2121
|
+
case "scale-y": {
|
|
2122
|
+
const n = scaleFactor(parsed);
|
|
2123
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
2124
|
+
}
|
|
2125
|
+
case "rotate": {
|
|
2126
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
|
|
2127
|
+
const deg = angle(parsed);
|
|
2128
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
2129
|
+
}
|
|
2130
|
+
case "rotate-x": {
|
|
2131
|
+
const deg = angle(parsed);
|
|
2132
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
2133
|
+
}
|
|
2134
|
+
case "rotate-y": {
|
|
2135
|
+
const deg = angle(parsed);
|
|
2136
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
2137
|
+
}
|
|
2138
|
+
case "rotate-z": {
|
|
2139
|
+
const deg = angle(parsed);
|
|
2140
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
2141
|
+
}
|
|
2142
|
+
case "skew-x": {
|
|
2143
|
+
const deg = angle(parsed);
|
|
2144
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
2145
|
+
}
|
|
2146
|
+
case "skew-y": {
|
|
2147
|
+
const deg = angle(parsed);
|
|
2148
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
2149
|
+
}
|
|
2150
|
+
default:
|
|
2151
|
+
return null;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
|
|
1446
2155
|
// src/jsEngine/resolveUtilityNative.ts
|
|
1447
|
-
function
|
|
2156
|
+
function firstFontName(stack) {
|
|
2157
|
+
const first = stack.split(",")[0] ?? stack;
|
|
2158
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
2159
|
+
}
|
|
2160
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1448
2161
|
switch (parsed.utility) {
|
|
1449
2162
|
case "font": {
|
|
1450
2163
|
if (parsed.value === null) return null;
|
|
2164
|
+
if (parsed.isArbitrary) {
|
|
2165
|
+
if (arbitraryFontIsWeight(parsed, parsed.value)) {
|
|
2166
|
+
const n = Number(parsed.value);
|
|
2167
|
+
return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
|
|
2168
|
+
}
|
|
2169
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
2170
|
+
}
|
|
1451
2171
|
const w = fontWeight(parsed.value);
|
|
1452
|
-
|
|
2172
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
2173
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
2174
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1453
2175
|
}
|
|
1454
2176
|
case "uppercase":
|
|
1455
2177
|
return [decl("text-transform", "uppercase")];
|
|
@@ -1485,16 +2207,27 @@ function resolveLeadingTrackingNative(parsed) {
|
|
|
1485
2207
|
return null;
|
|
1486
2208
|
}
|
|
1487
2209
|
function nativeHexColor(parsed, theme) {
|
|
1488
|
-
|
|
1489
|
-
if (value === null) return null;
|
|
1490
|
-
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
2210
|
+
return colorValue(theme, parsed);
|
|
1491
2211
|
}
|
|
1492
2212
|
function resolveTextNative(parsed, theme) {
|
|
1493
2213
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1494
2214
|
const size = textSize(parsed.value);
|
|
1495
2215
|
if (size !== null) return [decl("font-size", size)];
|
|
2216
|
+
const sized = splitSizeLeading(parsed.value);
|
|
2217
|
+
if (sized !== null) {
|
|
2218
|
+
const lh = sizeLeadingNative(sized[0], sized[1]);
|
|
2219
|
+
return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
|
|
2220
|
+
}
|
|
1496
2221
|
const align = textAlign(parsed.value);
|
|
1497
2222
|
if (align !== null) return [decl("text-align", align)];
|
|
2223
|
+
} else if (parsed.isArbitrary && parsed.value !== null) {
|
|
2224
|
+
const leading = parsed.modifier ?? null;
|
|
2225
|
+
if (isLength(parsed, parsed.value)) {
|
|
2226
|
+
if (leading === null) return [decl("font-size", parsed.value)];
|
|
2227
|
+
const lh = sizeLeadingNative(parsed.value, leading);
|
|
2228
|
+
return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
|
|
2229
|
+
}
|
|
2230
|
+
if (leading !== null) return null;
|
|
1498
2231
|
}
|
|
1499
2232
|
const hex = nativeHexColor(parsed, theme);
|
|
1500
2233
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1511,13 +2244,20 @@ function resolveColorNative(parsed, theme) {
|
|
|
1511
2244
|
return null;
|
|
1512
2245
|
}
|
|
1513
2246
|
}
|
|
2247
|
+
function resolveOpacityNative(parsed) {
|
|
2248
|
+
if (parsed.utility !== "opacity") return null;
|
|
2249
|
+
const v = resolvePercent(parsed);
|
|
2250
|
+
return v === null ? null : [decl("opacity", v)];
|
|
2251
|
+
}
|
|
1514
2252
|
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);
|
|
2253
|
+
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
2254
|
}
|
|
1517
2255
|
|
|
1518
2256
|
// src/jsEngine/resolveStyle.ts
|
|
1519
2257
|
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
2258
|
+
var STATE_HOLD_MARKER2 = "_kbon";
|
|
1520
2259
|
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
2260
|
+
if (modifier === STATE_HOLD_MARKER2) return true;
|
|
1521
2261
|
if (modifier === "dark") return colorScheme === "dark";
|
|
1522
2262
|
if (modifier === "active") return pressed;
|
|
1523
2263
|
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
@@ -1525,6 +2265,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1525
2265
|
if (minWidth === void 0) return null;
|
|
1526
2266
|
return width >= minWidth;
|
|
1527
2267
|
}
|
|
2268
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
2269
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
2270
|
+
return px === null ? null : width >= px;
|
|
2271
|
+
}
|
|
2272
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
2273
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
2274
|
+
return px === null ? null : width < px;
|
|
2275
|
+
}
|
|
2276
|
+
const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
|
|
2277
|
+
const custom = screen(modifier);
|
|
2278
|
+
if (typeof custom === "number") return width >= custom;
|
|
2279
|
+
if (modifier.startsWith("max-")) {
|
|
2280
|
+
const max = screen(modifier.slice(4));
|
|
2281
|
+
if (typeof max === "number") return width < max;
|
|
2282
|
+
}
|
|
2283
|
+
if (modifier.startsWith("min-")) {
|
|
2284
|
+
const min = screen(modifier.slice(4));
|
|
2285
|
+
if (typeof min === "number") return width >= min;
|
|
2286
|
+
}
|
|
2287
|
+
if (modifier.startsWith("not-")) {
|
|
2288
|
+
const rest = modifier.slice(4);
|
|
2289
|
+
if (rest === "dark") return colorScheme !== "dark";
|
|
2290
|
+
const isBreakpoint = (name) => typeof screen(name) === "number";
|
|
2291
|
+
if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
|
|
2292
|
+
const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
|
|
2293
|
+
return holds === null ? null : !holds;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
1528
2296
|
return null;
|
|
1529
2297
|
}
|
|
1530
2298
|
function kebabToCamel(s) {
|
|
@@ -1569,6 +2337,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1569
2337
|
"shadow-opacity",
|
|
1570
2338
|
"shadow-radius",
|
|
1571
2339
|
"elevation",
|
|
2340
|
+
"opacity",
|
|
1572
2341
|
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1573
2342
|
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1574
2343
|
// style system wants plain numbers for these exactly like the generic
|
|
@@ -1582,29 +2351,104 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1582
2351
|
"border-bottom-right-radius",
|
|
1583
2352
|
"border-bottom-left-radius",
|
|
1584
2353
|
"outline-width",
|
|
1585
|
-
"outline-offset"
|
|
2354
|
+
"outline-offset",
|
|
2355
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
2356
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
2357
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
2358
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
2359
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
2360
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
2361
|
+
// get collected into the final array.
|
|
2362
|
+
"transform-op-translate-x",
|
|
2363
|
+
"transform-op-translate-y",
|
|
2364
|
+
"transform-op-scale-x",
|
|
2365
|
+
"transform-op-scale-y"
|
|
1586
2366
|
]);
|
|
2367
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
2368
|
+
["transform-op-translate-x", "translateX"],
|
|
2369
|
+
["transform-op-translate-y", "translateY"],
|
|
2370
|
+
["transform-op-rotate", "rotate"],
|
|
2371
|
+
["transform-op-rotate-x", "rotateX"],
|
|
2372
|
+
["transform-op-rotate-y", "rotateY"],
|
|
2373
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
2374
|
+
["transform-op-skew-x", "skewX"],
|
|
2375
|
+
["transform-op-skew-y", "skewY"],
|
|
2376
|
+
["transform-op-scale-x", "scaleX"],
|
|
2377
|
+
["transform-op-scale-y", "scaleY"]
|
|
2378
|
+
]);
|
|
2379
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
2380
|
+
function isPlainPercentage(value) {
|
|
2381
|
+
if (!value.endsWith("%")) return false;
|
|
2382
|
+
let digits = value.slice(0, -1);
|
|
2383
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
2384
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
2385
|
+
}
|
|
2386
|
+
function sanitizeForWarning(value) {
|
|
2387
|
+
const MAX_CHARS = 60;
|
|
2388
|
+
const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
|
|
2389
|
+
if (escaped.length <= MAX_CHARS) return escaped;
|
|
2390
|
+
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
2391
|
+
}
|
|
1587
2392
|
function rnStyleValue(property, value) {
|
|
1588
|
-
if (
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
2393
|
+
if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
|
|
2394
|
+
const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
|
|
2395
|
+
const space = inner.lastIndexOf(" ");
|
|
2396
|
+
if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
|
|
2397
|
+
}
|
|
2398
|
+
if (property === "aspect-ratio") {
|
|
2399
|
+
if (value.trim() === "auto") return { value: null, warning: null };
|
|
2400
|
+
const parts = value.split("/").map((s) => s.trim());
|
|
2401
|
+
let n = null;
|
|
2402
|
+
if (parts.length === 1) {
|
|
2403
|
+
const a = Number(parts[0]);
|
|
2404
|
+
n = Number.isFinite(a) ? a : null;
|
|
2405
|
+
} else if (parts.length === 2) {
|
|
2406
|
+
const a = Number(parts[0]);
|
|
2407
|
+
const b = Number(parts[1]);
|
|
2408
|
+
n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
|
|
1599
2409
|
}
|
|
1600
|
-
|
|
2410
|
+
return { value: n, warning: null };
|
|
2411
|
+
}
|
|
2412
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
2413
|
+
return { value, warning: null };
|
|
2414
|
+
}
|
|
2415
|
+
if (value === "auto") {
|
|
2416
|
+
return { value: "auto", warning: null };
|
|
1601
2417
|
}
|
|
1602
|
-
|
|
2418
|
+
let px = null;
|
|
2419
|
+
if (value.endsWith("px")) {
|
|
2420
|
+
const n = Number(value.slice(0, -2));
|
|
2421
|
+
px = Number.isFinite(n) ? n : null;
|
|
2422
|
+
} else if (value.endsWith("rem")) {
|
|
2423
|
+
const n = Number(value.slice(0, -3));
|
|
2424
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
2425
|
+
} else {
|
|
2426
|
+
const n = Number(value);
|
|
2427
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
2428
|
+
}
|
|
2429
|
+
if (px !== null) return { value: px, warning: null };
|
|
2430
|
+
if (isPlainPercentage(value)) {
|
|
2431
|
+
return { value, warning: null };
|
|
2432
|
+
}
|
|
2433
|
+
const reduced = reduceConstantMath(value);
|
|
2434
|
+
if (reduced !== null) {
|
|
2435
|
+
return { value: reduced, warning: null };
|
|
2436
|
+
}
|
|
2437
|
+
const sanitizedValue = sanitizeForWarning(value);
|
|
2438
|
+
const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
2439
|
+
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).
|
|
2440
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
2441
|
+
return { value: null, warning };
|
|
1603
2442
|
}
|
|
1604
|
-
function
|
|
2443
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1605
2444
|
const style = {};
|
|
2445
|
+
const warnings = [];
|
|
1606
2446
|
let shadowOffset = null;
|
|
1607
|
-
|
|
2447
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
2448
|
+
const keySpecificity = /* @__PURE__ */ new Map();
|
|
2449
|
+
const transformSpecificity = /* @__PURE__ */ new Map();
|
|
2450
|
+
for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
|
|
2451
|
+
const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
|
|
1608
2452
|
const parsed = parseClass(token);
|
|
1609
2453
|
const allModifiersHold = parsed.modifiers.every(
|
|
1610
2454
|
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
@@ -1612,36 +2456,121 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1612
2456
|
if (!allModifiersHold) continue;
|
|
1613
2457
|
const decls = resolveUtilityNative(parsed, theme);
|
|
1614
2458
|
if (decls === null) continue;
|
|
2459
|
+
const spec = parsed.modifiers.length;
|
|
1615
2460
|
for (const d of decls) {
|
|
1616
2461
|
if (d.property.startsWith("__")) {
|
|
1617
2462
|
continue;
|
|
1618
2463
|
}
|
|
2464
|
+
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
|
|
2465
|
+
continue;
|
|
2466
|
+
}
|
|
1619
2467
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
2468
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1620
2469
|
const n = Number(d.value);
|
|
1621
2470
|
if (!Number.isFinite(n)) continue;
|
|
1622
2471
|
if (shadowOffset === null) shadowOffset = {};
|
|
1623
2472
|
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
2473
|
+
keySpecificity.set("shadowOffset", spec);
|
|
2474
|
+
continue;
|
|
2475
|
+
}
|
|
2476
|
+
if (d.property === "transform-op-none") {
|
|
2477
|
+
transformOps.clear();
|
|
2478
|
+
transformSpecificity.clear();
|
|
2479
|
+
continue;
|
|
2480
|
+
}
|
|
2481
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
2482
|
+
if (opKey !== void 0) {
|
|
2483
|
+
if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
|
|
2484
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
2485
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
2486
|
+
if (value2 !== null) {
|
|
2487
|
+
transformOps.set(opKey, value2);
|
|
2488
|
+
transformSpecificity.set(opKey, spec);
|
|
2489
|
+
}
|
|
1624
2490
|
continue;
|
|
1625
2491
|
}
|
|
1626
|
-
|
|
2492
|
+
const key = kebabToCamel(d.property);
|
|
2493
|
+
if (spec < (keySpecificity.get(key) ?? 0)) continue;
|
|
2494
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
2495
|
+
if (warning !== null) warnings.push(warning);
|
|
2496
|
+
if (value !== null) {
|
|
2497
|
+
style[key] = value;
|
|
2498
|
+
keySpecificity.set(key, spec);
|
|
2499
|
+
}
|
|
1627
2500
|
}
|
|
1628
2501
|
}
|
|
1629
2502
|
if (shadowOffset !== null) {
|
|
1630
2503
|
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1631
2504
|
}
|
|
1632
|
-
|
|
2505
|
+
if (transformOps.size > 0) {
|
|
2506
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
2507
|
+
[key]: transformOps.get(key)
|
|
2508
|
+
}));
|
|
2509
|
+
}
|
|
2510
|
+
return { style, warnings };
|
|
1633
2511
|
}
|
|
1634
2512
|
|
|
1635
2513
|
// src/nativeBridge.ts
|
|
2514
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
2515
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
2516
|
+
var cachedForThemeJson = null;
|
|
1636
2517
|
function resolveStyle(classString, pressed = false) {
|
|
1637
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1638
|
-
const width =
|
|
1639
|
-
const
|
|
2518
|
+
const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
|
|
2519
|
+
const width = import_react_native2.Dimensions.get("window").width;
|
|
2520
|
+
const themeJson = (0, import_theme2.getThemeJson)();
|
|
2521
|
+
if (themeJson !== cachedForThemeJson) {
|
|
2522
|
+
resolveStyleCache.clear();
|
|
2523
|
+
cachedForThemeJson = themeJson;
|
|
2524
|
+
}
|
|
2525
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
2526
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
2527
|
+
if (cached !== void 0) return { ...cached };
|
|
2528
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
2529
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
2530
|
+
resolveStyleCache.set(cacheKey, style);
|
|
2531
|
+
return { ...style };
|
|
2532
|
+
}
|
|
2533
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
2534
|
+
const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
|
|
1640
2535
|
if (!KbachModule) {
|
|
1641
|
-
|
|
2536
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
|
|
2537
|
+
warnIfDev(classString, warnings2);
|
|
2538
|
+
return style2;
|
|
2539
|
+
}
|
|
2540
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
2541
|
+
const style = JSON.parse(json);
|
|
2542
|
+
const warnings = style.__kbachWarnings;
|
|
2543
|
+
if (warnings !== void 0) {
|
|
2544
|
+
delete style.__kbachWarnings;
|
|
2545
|
+
warnIfDev(classString, warnings);
|
|
2546
|
+
}
|
|
2547
|
+
return style;
|
|
2548
|
+
}
|
|
2549
|
+
var WARNED_MESSAGES_MAX = 500;
|
|
2550
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
2551
|
+
var QUOTED_TOKEN_RE = /"([^"]*)"/;
|
|
2552
|
+
function highlightToken(classString, warning) {
|
|
2553
|
+
const match = QUOTED_TOKEN_RE.exec(warning);
|
|
2554
|
+
if (match === null) return classString;
|
|
2555
|
+
const quoted = match[1].replace(/\s+/g, "");
|
|
2556
|
+
if (quoted === "") return classString;
|
|
2557
|
+
const parts = classString.split(/(\s+)/);
|
|
2558
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
2559
|
+
if (idx === -1) return classString;
|
|
2560
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
2561
|
+
return parts.join("");
|
|
2562
|
+
}
|
|
2563
|
+
function warnIfDev(classString, warnings) {
|
|
2564
|
+
if (warnings.length === 0) return;
|
|
2565
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
2566
|
+
for (const warning of warnings) {
|
|
2567
|
+
const message = `${warning}
|
|
2568
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
2569
|
+
if (warnedMessages.has(message)) continue;
|
|
2570
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
2571
|
+
warnedMessages.add(message);
|
|
2572
|
+
console.warn(message);
|
|
1642
2573
|
}
|
|
1643
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1644
|
-
return JSON.parse(json);
|
|
1645
2574
|
}
|
|
1646
2575
|
|
|
1647
2576
|
// src/jsx-runtime.tsx
|