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