@kbach/react-native 1.0.0-beta.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +495 -0
- package/LICENSE +21 -0
- package/README.md +198 -70
- package/THIRD_PARTY_NOTICES.md +41 -0
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-7CNURQSH.mjs +112 -0
- package/dist/{chunk-YOC3SHF5.mjs → chunk-HYQFT32E.mjs} +2 -2
- package/dist/chunk-MUPEQJRT.mjs +623 -0
- package/dist/darkModeStore.d.ts +73 -0
- package/dist/darkModeStore.js +118 -0
- package/dist/dynamicTokens.d.ts +53 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +90 -70
- package/dist/index.js +1300 -610
- package/dist/index.web.d.ts +91 -1
- package/dist/index.web.js +204 -441
- package/dist/index.web.mjs +294 -12
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.js +1532 -603
- package/dist/jsx-dev-runtime.web.d.ts +2 -2
- package/dist/jsx-dev-runtime.web.js +20 -355
- package/dist/jsx-dev-runtime.web.mjs +18 -6
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +1522 -593
- package/dist/jsx-runtime.web.d.ts +3 -3
- package/dist/jsx-runtime.web.js +17 -355
- package/dist/jsx-runtime.web.mjs +2 -3
- package/dist/semanticElements-Bk3TB-vt.d.ts +334 -0
- package/dist/theme.d.ts +79 -0
- package/dist/{chunk-HK6PDJJK.mjs → theme.js} +99 -11
- package/llms.txt +38 -0
- package/package.json +15 -13
- package/src/babel-plugin.js +95 -25
- package/dist/chunk-DLIXI5OW.mjs +0 -53
- package/dist/chunk-DOWW44F7.mjs +0 -14
- package/dist/chunk-H5Z24XX5.mjs +0 -192
- package/dist/chunk-SY5OAY2C.mjs +0 -1211
- package/dist/chunk-X4UQCEOE.mjs +0 -186
- package/dist/chunk-Z664AKW7.mjs +0 -54
- package/dist/index.d.mts +0 -83
- package/dist/index.mjs +0 -38
- package/dist/index.web.d.mts +0 -15
- package/dist/jsx-dev-runtime.d.mts +0 -10
- package/dist/jsx-dev-runtime.mjs +0 -18
- package/dist/jsx-dev-runtime.web.d.mts +0 -10
- package/dist/jsx-runtime.d.mts +0 -7
- package/dist/jsx-runtime.mjs +0 -15
- package/dist/jsx-runtime.web.d.mts +0 -7
- package/dist/useColors-CeP5_HvM.d.mts +0 -230
- package/dist/useColors-CeP5_HvM.d.ts +0 -230
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -29,432 +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). Only the
|
|
362
|
-
// "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
|
|
363
|
-
// native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
|
|
364
|
-
// live `n * 4px` formula for any bare numeric step not listed here
|
|
365
|
-
// (`p-0.25`, `w-13`, ...), so this table names the common values and
|
|
366
|
-
// gives a theme override something to target, not the full resolvable
|
|
367
|
-
// set. Mirrors @kbach/react's theme.ts exactly.
|
|
368
|
-
spacing: {
|
|
369
|
-
"0": 0,
|
|
370
|
-
"px": 1,
|
|
371
|
-
"0.5": 2,
|
|
372
|
-
"1": 4,
|
|
373
|
-
"1.5": 6,
|
|
374
|
-
"2": 8,
|
|
375
|
-
"2.5": 10,
|
|
376
|
-
"3": 12,
|
|
377
|
-
"3.5": 14,
|
|
378
|
-
"4": 16,
|
|
379
|
-
"5": 20,
|
|
380
|
-
"6": 24,
|
|
381
|
-
"7": 28,
|
|
382
|
-
"8": 32,
|
|
383
|
-
"9": 36,
|
|
384
|
-
"10": 40,
|
|
385
|
-
"11": 44,
|
|
386
|
-
"12": 48,
|
|
387
|
-
"14": 56,
|
|
388
|
-
"16": 64,
|
|
389
|
-
"20": 80,
|
|
390
|
-
"24": 96,
|
|
391
|
-
"28": 112,
|
|
392
|
-
"32": 128,
|
|
393
|
-
"36": 144,
|
|
394
|
-
"40": 160,
|
|
395
|
-
"44": 176,
|
|
396
|
-
"48": 192,
|
|
397
|
-
"52": 208,
|
|
398
|
-
"56": 224,
|
|
399
|
-
"60": 240,
|
|
400
|
-
"64": 256,
|
|
401
|
-
"72": 288,
|
|
402
|
-
"80": 320,
|
|
403
|
-
"96": 384
|
|
404
|
-
},
|
|
405
|
-
screens: {
|
|
406
|
-
sm: 640,
|
|
407
|
-
md: 768,
|
|
408
|
-
lg: 1024,
|
|
409
|
-
xl: 1280,
|
|
410
|
-
"2xl": 1536
|
|
411
|
-
},
|
|
412
|
-
// Byte-for-byte the same three stacks
|
|
413
|
-
// packages/core-engine/src/resolvers/typography.rs's `font_family_value`
|
|
414
|
-
// falls back to. On native these three still effectively no-op (see
|
|
415
|
-
// `first_font_name`'s own doc comment for why a generic CSS keyword
|
|
416
|
-
// isn't a real loadable font) — only a caller-configured custom name
|
|
417
|
-
// changes native rendering; Expo Web uses the full stack as-is.
|
|
418
|
-
fontFamily: {
|
|
419
|
-
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
420
|
-
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
421
|
-
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
422
|
-
},
|
|
423
|
-
darkMode: "attribute",
|
|
424
|
-
// Empty by default, matching real Tailwind's own defaults.
|
|
425
|
-
container: {}
|
|
426
|
-
};
|
|
427
|
-
var activeTheme = defaultTheme;
|
|
428
|
-
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
429
|
-
function getTheme() {
|
|
430
|
-
return activeTheme;
|
|
431
|
-
}
|
|
432
|
-
function getThemeJson() {
|
|
433
|
-
return activeThemeJson;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// src/darkModeStore.ts
|
|
437
|
-
var import_react_native2 = require("react-native");
|
|
438
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
439
|
-
function systemPrefersDark() {
|
|
440
|
-
return import_react_native2.Appearance.getColorScheme() === "dark";
|
|
441
|
-
}
|
|
442
|
-
function resolveIsDark(m) {
|
|
443
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
444
|
-
}
|
|
445
|
-
var mode = "system";
|
|
446
|
-
var isDark = resolveIsDark(mode);
|
|
447
|
-
var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
|
|
448
|
-
if (mode !== "system") return;
|
|
449
|
-
isDark = colorScheme === "dark";
|
|
450
|
-
notify();
|
|
451
|
-
});
|
|
452
|
-
function notify() {
|
|
453
|
-
for (const listener of listeners) listener();
|
|
454
|
-
}
|
|
455
|
-
function getGlobalDarkMode() {
|
|
456
|
-
return isDark;
|
|
457
|
-
}
|
|
32
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
33
|
+
var import_theme = require("./theme");
|
|
458
34
|
|
|
459
35
|
// src/jsEngine/parser.ts
|
|
460
36
|
var VALUE_PREFIXES = [
|
|
@@ -542,12 +118,23 @@ var VALUE_PREFIXES = [
|
|
|
542
118
|
"leading-",
|
|
543
119
|
"tracking-",
|
|
544
120
|
"font-",
|
|
121
|
+
"align-",
|
|
545
122
|
"z-",
|
|
123
|
+
"inset-x-",
|
|
124
|
+
"inset-y-",
|
|
546
125
|
"inset-",
|
|
547
126
|
"top-",
|
|
548
127
|
"right-",
|
|
549
128
|
"bottom-",
|
|
550
129
|
"left-",
|
|
130
|
+
"start-",
|
|
131
|
+
"end-",
|
|
132
|
+
"overflow-x-",
|
|
133
|
+
"overflow-y-",
|
|
134
|
+
"overscroll-x-",
|
|
135
|
+
"overscroll-y-",
|
|
136
|
+
"overscroll-",
|
|
137
|
+
"aspect-",
|
|
551
138
|
"divide-color-",
|
|
552
139
|
"space-x-",
|
|
553
140
|
"space-y-",
|
|
@@ -575,12 +162,23 @@ var VALUE_PREFIXES = [
|
|
|
575
162
|
"justify-self-",
|
|
576
163
|
"scale-x-",
|
|
577
164
|
"scale-y-",
|
|
165
|
+
"scale-z-",
|
|
578
166
|
"scale-",
|
|
167
|
+
"rotate-x-",
|
|
168
|
+
"rotate-y-",
|
|
169
|
+
"rotate-z-",
|
|
579
170
|
"rotate-",
|
|
171
|
+
// Bare 'translate-'/'skew-' (both axes) after their per-axis forms, same
|
|
172
|
+
// longer-before-shorter rule as resolvers/parser.rs.
|
|
580
173
|
"translate-x-",
|
|
581
174
|
"translate-y-",
|
|
175
|
+
"translate-z-",
|
|
176
|
+
"translate-",
|
|
582
177
|
"skew-x-",
|
|
583
178
|
"skew-y-",
|
|
179
|
+
"skew-",
|
|
180
|
+
"perspective-origin-",
|
|
181
|
+
"perspective-",
|
|
584
182
|
"origin-",
|
|
585
183
|
"blur-",
|
|
586
184
|
"brightness-",
|
|
@@ -613,14 +211,200 @@ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
|
613
211
|
function isSafeArbitraryValue(value) {
|
|
614
212
|
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
615
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
|
+
}
|
|
616
400
|
function splitRespectingBrackets(token) {
|
|
617
401
|
const parts = [];
|
|
618
402
|
let depth = 0;
|
|
619
403
|
let start = 0;
|
|
620
404
|
for (let i = 0; i < token.length; i++) {
|
|
621
405
|
const ch = token[i];
|
|
622
|
-
if (ch === "[") depth += 1;
|
|
623
|
-
else if (ch === "]") depth -= 1;
|
|
406
|
+
if (ch === "[" || ch === "(") depth += 1;
|
|
407
|
+
else if (ch === "]" || ch === ")") depth -= 1;
|
|
624
408
|
else if (ch === ":" && depth <= 0) {
|
|
625
409
|
parts.push(token.slice(start, i));
|
|
626
410
|
start = i + 1;
|
|
@@ -633,9 +417,11 @@ function parseClass(token) {
|
|
|
633
417
|
const parts = splitRespectingBrackets(token);
|
|
634
418
|
let base = parts.pop() ?? token;
|
|
635
419
|
const modifiers = parts;
|
|
636
|
-
const important = base.startsWith("!");
|
|
637
|
-
if (
|
|
420
|
+
const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
|
|
421
|
+
if (base.startsWith("!")) {
|
|
638
422
|
base = base.slice(1);
|
|
423
|
+
} else if (important) {
|
|
424
|
+
base = base.slice(0, -1);
|
|
639
425
|
}
|
|
640
426
|
const negative = base.startsWith("-");
|
|
641
427
|
if (negative) {
|
|
@@ -648,7 +434,7 @@ function parseClass(token) {
|
|
|
648
434
|
const property = raw.slice(0, colonIdx);
|
|
649
435
|
const rawValue = raw.slice(colonIdx + 1);
|
|
650
436
|
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
651
|
-
const value = rawValue.replace(/_/g, " ");
|
|
437
|
+
const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
|
|
652
438
|
return {
|
|
653
439
|
modifiers,
|
|
654
440
|
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
@@ -663,28 +449,46 @@ function parseClass(token) {
|
|
|
663
449
|
}
|
|
664
450
|
for (const prefix of VALUE_PREFIXES) {
|
|
665
451
|
if (!base.startsWith(prefix)) continue;
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
452
|
+
const written = base.slice(prefix.length);
|
|
453
|
+
if (written === "") continue;
|
|
454
|
+
const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
|
|
668
455
|
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
669
456
|
const raw = value.slice(1, -1);
|
|
670
457
|
if (!isSafeArbitraryValue(raw)) {
|
|
671
458
|
continue;
|
|
672
459
|
}
|
|
673
|
-
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
|
+
}
|
|
674
475
|
return {
|
|
675
476
|
modifiers,
|
|
676
477
|
utility: prefix.slice(0, -1),
|
|
677
|
-
value:
|
|
478
|
+
value: hinted,
|
|
479
|
+
typeHint,
|
|
678
480
|
isArbitrary: true,
|
|
679
481
|
important,
|
|
680
482
|
negative,
|
|
681
|
-
original: token
|
|
483
|
+
original: token,
|
|
484
|
+
modifier
|
|
682
485
|
};
|
|
683
486
|
}
|
|
684
487
|
return {
|
|
685
488
|
modifiers,
|
|
686
489
|
utility: prefix.slice(0, -1),
|
|
687
|
-
value
|
|
490
|
+
// a named value keeps its own /opacity (`bg-blue-6/50`)
|
|
491
|
+
value: tail === null ? value : `${value}/${tail}`,
|
|
688
492
|
isArbitrary: false,
|
|
689
493
|
important,
|
|
690
494
|
negative,
|
|
@@ -702,6 +506,651 @@ function parseClass(token) {
|
|
|
702
506
|
};
|
|
703
507
|
}
|
|
704
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
|
+
|
|
705
1154
|
// src/jsEngine/shared.ts
|
|
706
1155
|
function decl(property, value) {
|
|
707
1156
|
return { property, value };
|
|
@@ -709,6 +1158,7 @@ function decl(property, value) {
|
|
|
709
1158
|
function spacingPx(theme, value) {
|
|
710
1159
|
const fromTable = theme.spacing[value];
|
|
711
1160
|
if (fromTable !== void 0) return fromTable;
|
|
1161
|
+
if (value === "px") return 1;
|
|
712
1162
|
const n = Number(value);
|
|
713
1163
|
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
714
1164
|
}
|
|
@@ -724,7 +1174,10 @@ function resolveLength(theme, parsed) {
|
|
|
724
1174
|
}
|
|
725
1175
|
function resolveNegatableLength(theme, parsed) {
|
|
726
1176
|
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
727
|
-
if (parsed.isArbitrary)
|
|
1177
|
+
if (parsed.isArbitrary) {
|
|
1178
|
+
const value2 = parsed.value;
|
|
1179
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
1180
|
+
}
|
|
728
1181
|
const value = parsed.value;
|
|
729
1182
|
if (value === null) return null;
|
|
730
1183
|
const px = spacingPx(theme, value);
|
|
@@ -732,11 +1185,71 @@ function resolveNegatableLength(theme, parsed) {
|
|
|
732
1185
|
if (px === 0) return "0px";
|
|
733
1186
|
return `-${px}px`;
|
|
734
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
|
+
}
|
|
735
1224
|
|
|
736
1225
|
// src/jsEngine/resolvers/layout.ts
|
|
737
1226
|
function negateRaw(value, negative) {
|
|
738
1227
|
return negative ? `-${value}` : value;
|
|
739
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
|
+
}
|
|
740
1253
|
function resolve(parsed, theme) {
|
|
741
1254
|
switch (parsed.utility) {
|
|
742
1255
|
case "flex":
|
|
@@ -783,6 +1296,12 @@ function resolve(parsed, theme) {
|
|
|
783
1296
|
return [decl("justify-content", "space-around")];
|
|
784
1297
|
case "justify-evenly":
|
|
785
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")];
|
|
786
1305
|
case "content-start":
|
|
787
1306
|
return [decl("align-content", "flex-start")];
|
|
788
1307
|
case "content-end":
|
|
@@ -817,6 +1336,18 @@ function resolve(parsed, theme) {
|
|
|
817
1336
|
return [decl("overflow", "scroll")];
|
|
818
1337
|
case "overflow-visible":
|
|
819
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);
|
|
820
1351
|
case "static":
|
|
821
1352
|
return [decl("position", "static")];
|
|
822
1353
|
case "relative":
|
|
@@ -827,40 +1358,91 @@ function resolve(parsed, theme) {
|
|
|
827
1358
|
return [decl("position", "fixed")];
|
|
828
1359
|
case "sticky":
|
|
829
1360
|
return [decl("position", "sticky")];
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
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
|
+
}
|
|
834
1378
|
case "grow":
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
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
|
+
}
|
|
838
1384
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
839
|
-
// 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.
|
|
840
1387
|
case "top": {
|
|
841
|
-
const v =
|
|
1388
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
842
1389
|
return v === null ? null : [decl("top", v)];
|
|
843
1390
|
}
|
|
844
1391
|
case "right": {
|
|
845
|
-
const v =
|
|
1392
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
846
1393
|
return v === null ? null : [decl("right", v)];
|
|
847
1394
|
}
|
|
848
1395
|
case "bottom": {
|
|
849
|
-
const v =
|
|
1396
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
850
1397
|
return v === null ? null : [decl("bottom", v)];
|
|
851
1398
|
}
|
|
852
1399
|
case "left": {
|
|
853
|
-
const v =
|
|
1400
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
854
1401
|
return v === null ? null : [decl("left", v)];
|
|
855
1402
|
}
|
|
856
1403
|
case "inset": {
|
|
857
|
-
const v =
|
|
1404
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
858
1405
|
return v === null ? null : [decl("inset", v)];
|
|
859
1406
|
}
|
|
860
|
-
case "
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
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
|
+
}
|
|
864
1446
|
default:
|
|
865
1447
|
return null;
|
|
866
1448
|
}
|
|
@@ -902,7 +1484,7 @@ function resolveFlex(parsed, web) {
|
|
|
902
1484
|
case "shrink-0":
|
|
903
1485
|
return [decl("flex-shrink", "0")];
|
|
904
1486
|
default:
|
|
905
|
-
return null;
|
|
1487
|
+
return /^\d+$/.test(value) ? [decl("flex", value)] : null;
|
|
906
1488
|
}
|
|
907
1489
|
}
|
|
908
1490
|
|
|
@@ -937,20 +1519,6 @@ function namedSize(key) {
|
|
|
937
1519
|
return null;
|
|
938
1520
|
}
|
|
939
1521
|
}
|
|
940
|
-
function fractionPercent(value) {
|
|
941
|
-
const slashIdx = value.indexOf("/");
|
|
942
|
-
if (slashIdx === -1) return null;
|
|
943
|
-
const numStr = value.slice(0, slashIdx);
|
|
944
|
-
const denStr = value.slice(slashIdx + 1);
|
|
945
|
-
const num = Number(numStr);
|
|
946
|
-
const den = Number(denStr);
|
|
947
|
-
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
948
|
-
if (den === 0) return null;
|
|
949
|
-
const pct = num / den * 100;
|
|
950
|
-
const formatted = pct.toFixed(6);
|
|
951
|
-
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
952
|
-
return `${trimmed}%`;
|
|
953
|
-
}
|
|
954
1522
|
function cssSizeKeyword(key) {
|
|
955
1523
|
switch (key) {
|
|
956
1524
|
case "min":
|
|
@@ -1084,19 +1652,16 @@ function resolve2(parsed, theme) {
|
|
|
1084
1652
|
}
|
|
1085
1653
|
}
|
|
1086
1654
|
|
|
1087
|
-
// src/jsEngine/resolvers/color.ts
|
|
1088
|
-
function lookupHex(theme, key) {
|
|
1089
|
-
const entry = theme.colors[key];
|
|
1090
|
-
return typeof entry === "string" ? entry : null;
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
1655
|
// src/jsEngine/resolvers/border.ts
|
|
1094
1656
|
function radiusSize(key) {
|
|
1095
1657
|
switch (key) {
|
|
1096
1658
|
case "none":
|
|
1097
1659
|
return "0px";
|
|
1098
|
-
|
|
1660
|
+
// Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
|
|
1661
|
+
case "xs":
|
|
1099
1662
|
return "0.125rem";
|
|
1663
|
+
case "sm":
|
|
1664
|
+
return "0.25rem";
|
|
1100
1665
|
case "md":
|
|
1101
1666
|
return "0.375rem";
|
|
1102
1667
|
case "lg":
|
|
@@ -1107,12 +1672,19 @@ function radiusSize(key) {
|
|
|
1107
1672
|
return "1rem";
|
|
1108
1673
|
case "3xl":
|
|
1109
1674
|
return "1.5rem";
|
|
1675
|
+
case "4xl":
|
|
1676
|
+
return "2rem";
|
|
1110
1677
|
case "full":
|
|
1111
1678
|
return "9999px";
|
|
1112
1679
|
default:
|
|
1113
1680
|
return null;
|
|
1114
1681
|
}
|
|
1115
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
|
+
}
|
|
1116
1688
|
function borderSideProperty(side) {
|
|
1117
1689
|
switch (side) {
|
|
1118
1690
|
case "t":
|
|
@@ -1135,49 +1707,68 @@ function borderValue(theme, parsed) {
|
|
|
1135
1707
|
if (side !== null) {
|
|
1136
1708
|
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1137
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
|
+
}
|
|
1138
1719
|
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1139
1720
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1140
1721
|
}
|
|
1141
1722
|
if (parsed.isArbitrary) {
|
|
1142
|
-
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)];
|
|
1143
1726
|
}
|
|
1144
1727
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1145
|
-
const v =
|
|
1728
|
+
const v = borderWidthPx(parsed);
|
|
1146
1729
|
return v === null ? null : [decl("border-width", v)];
|
|
1147
1730
|
}
|
|
1148
1731
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1149
1732
|
return [decl("border-style", value)];
|
|
1150
1733
|
}
|
|
1151
|
-
const
|
|
1152
|
-
return
|
|
1734
|
+
const color = colorValue(theme, parsed);
|
|
1735
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1153
1736
|
}
|
|
1154
1737
|
function borderSideValue(theme, parsed, sideProperty) {
|
|
1155
1738
|
const value = parsed.value;
|
|
1156
1739
|
if (value === null) return null;
|
|
1157
|
-
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
|
+
}
|
|
1158
1745
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1159
|
-
const v =
|
|
1746
|
+
const v = borderWidthPx(parsed);
|
|
1160
1747
|
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1161
1748
|
}
|
|
1162
1749
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1163
1750
|
return [decl(`${sideProperty}-style`, value)];
|
|
1164
1751
|
}
|
|
1165
|
-
const
|
|
1166
|
-
return
|
|
1752
|
+
const color = colorValue(theme, parsed);
|
|
1753
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1167
1754
|
}
|
|
1168
1755
|
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1169
1756
|
const value = parsed.value;
|
|
1170
1757
|
if (value === null) return null;
|
|
1171
|
-
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
|
+
}
|
|
1172
1763
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1173
|
-
const v =
|
|
1764
|
+
const v = borderWidthPx(parsed);
|
|
1174
1765
|
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1175
1766
|
}
|
|
1176
1767
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1177
1768
|
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1178
1769
|
}
|
|
1179
|
-
const
|
|
1180
|
-
return
|
|
1770
|
+
const color = colorValue(theme, parsed);
|
|
1771
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1181
1772
|
}
|
|
1182
1773
|
function radiusProperties(side) {
|
|
1183
1774
|
switch (side) {
|
|
@@ -1217,79 +1808,28 @@ function resolveRadiusSide(theme, parsed, side) {
|
|
|
1217
1808
|
}
|
|
1218
1809
|
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1219
1810
|
function outlineWidthValue(key) {
|
|
1220
|
-
|
|
1221
|
-
case "0":
|
|
1222
|
-
return "0px";
|
|
1223
|
-
case "1":
|
|
1224
|
-
return "1px";
|
|
1225
|
-
case "2":
|
|
1226
|
-
return "2px";
|
|
1227
|
-
case "4":
|
|
1228
|
-
return "4px";
|
|
1229
|
-
case "8":
|
|
1230
|
-
return "8px";
|
|
1231
|
-
default:
|
|
1232
|
-
return null;
|
|
1233
|
-
}
|
|
1811
|
+
return /^\d+$/.test(key) ? `${Number(key)}px` : null;
|
|
1234
1812
|
}
|
|
1235
1813
|
function outlineValue(theme, parsed) {
|
|
1236
1814
|
const value = parsed.value;
|
|
1237
1815
|
if (value === null) return null;
|
|
1238
|
-
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
|
+
}
|
|
1239
1821
|
const w = outlineWidthValue(value);
|
|
1240
1822
|
if (w !== null) return [decl("outline-width", w)];
|
|
1241
1823
|
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1242
|
-
const
|
|
1243
|
-
return
|
|
1824
|
+
const color = colorValue(theme, parsed);
|
|
1825
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1244
1826
|
}
|
|
1245
1827
|
function outlineOffsetValue(parsed) {
|
|
1246
1828
|
const value = parsed.value;
|
|
1247
1829
|
if (value === null) return null;
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
return
|
|
1251
|
-
}
|
|
1252
|
-
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))";
|
|
1253
|
-
function ringWidth(key) {
|
|
1254
|
-
switch (key) {
|
|
1255
|
-
case "0":
|
|
1256
|
-
return "0px";
|
|
1257
|
-
case "1":
|
|
1258
|
-
return "1px";
|
|
1259
|
-
case "2":
|
|
1260
|
-
return "2px";
|
|
1261
|
-
case "4":
|
|
1262
|
-
return "4px";
|
|
1263
|
-
case "8":
|
|
1264
|
-
return "8px";
|
|
1265
|
-
default:
|
|
1266
|
-
return null;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
function ringValue(theme, parsed) {
|
|
1270
|
-
const value = parsed.value;
|
|
1271
|
-
if (value === null) return null;
|
|
1272
|
-
if (value === "inset") {
|
|
1273
|
-
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1274
|
-
}
|
|
1275
|
-
if (!parsed.isArbitrary) {
|
|
1276
|
-
const w = ringWidth(value);
|
|
1277
|
-
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1278
|
-
}
|
|
1279
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1280
|
-
if (color === null) return null;
|
|
1281
|
-
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1282
|
-
}
|
|
1283
|
-
function ringOffsetValue(theme, parsed) {
|
|
1284
|
-
const value = parsed.value;
|
|
1285
|
-
if (value === null) return null;
|
|
1286
|
-
if (!parsed.isArbitrary) {
|
|
1287
|
-
const w = ringWidth(value);
|
|
1288
|
-
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1289
|
-
}
|
|
1290
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1291
|
-
if (color === null) return null;
|
|
1292
|
-
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)];
|
|
1293
1833
|
}
|
|
1294
1834
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1295
1835
|
function resolve3(parsed, theme) {
|
|
@@ -1319,14 +1859,19 @@ function resolve3(parsed, theme) {
|
|
|
1319
1859
|
const v = resolveLength(theme, parsed);
|
|
1320
1860
|
return v === null ? null : [decl("border-radius", v)];
|
|
1321
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.
|
|
1322
1864
|
case "ring":
|
|
1323
|
-
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1324
|
-
return ringValue(theme, parsed);
|
|
1325
1865
|
case "ring-offset":
|
|
1326
|
-
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).
|
|
1327
1871
|
case "outline":
|
|
1328
|
-
if (parsed.value === null) return [decl("outline-
|
|
1329
|
-
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")];
|
|
1330
1875
|
return outlineValue(theme, parsed);
|
|
1331
1876
|
case "outline-offset":
|
|
1332
1877
|
return outlineOffsetValue(parsed);
|
|
@@ -1357,32 +1902,75 @@ function textSize(key) {
|
|
|
1357
1902
|
return "1.875rem";
|
|
1358
1903
|
case "4xl":
|
|
1359
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";
|
|
1360
1915
|
default:
|
|
1361
1916
|
return null;
|
|
1362
1917
|
}
|
|
1363
1918
|
}
|
|
1364
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) {
|
|
1365
1926
|
switch (key) {
|
|
1366
|
-
case "
|
|
1367
|
-
return
|
|
1368
|
-
case "
|
|
1369
|
-
return
|
|
1370
|
-
case "
|
|
1371
|
-
return
|
|
1372
|
-
case "
|
|
1373
|
-
return
|
|
1374
|
-
case "
|
|
1375
|
-
return
|
|
1376
|
-
case "
|
|
1377
|
-
return
|
|
1378
|
-
case "9":
|
|
1379
|
-
return "2.25rem";
|
|
1380
|
-
case "10":
|
|
1381
|
-
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;
|
|
1382
1939
|
default:
|
|
1383
1940
|
return null;
|
|
1384
1941
|
}
|
|
1385
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
|
+
}
|
|
1386
1974
|
function textAlign(key) {
|
|
1387
1975
|
switch (key) {
|
|
1388
1976
|
case "left":
|
|
@@ -1393,6 +1981,12 @@ function textAlign(key) {
|
|
|
1393
1981
|
return "right";
|
|
1394
1982
|
case "justify":
|
|
1395
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";
|
|
1396
1990
|
default:
|
|
1397
1991
|
return null;
|
|
1398
1992
|
}
|
|
@@ -1401,6 +1995,10 @@ function fontWeight(key) {
|
|
|
1401
1995
|
switch (key) {
|
|
1402
1996
|
case "thin":
|
|
1403
1997
|
return "100";
|
|
1998
|
+
case "extralight":
|
|
1999
|
+
return "200";
|
|
2000
|
+
case "light":
|
|
2001
|
+
return "300";
|
|
1404
2002
|
case "normal":
|
|
1405
2003
|
return "400";
|
|
1406
2004
|
case "medium":
|
|
@@ -1411,6 +2009,22 @@ function fontWeight(key) {
|
|
|
1411
2009
|
return "700";
|
|
1412
2010
|
case "extrabold":
|
|
1413
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';
|
|
1414
2028
|
default:
|
|
1415
2029
|
return null;
|
|
1416
2030
|
}
|
|
@@ -1419,8 +2033,14 @@ function fontWeight(key) {
|
|
|
1419
2033
|
// src/jsEngine/resolvers/effects.ts
|
|
1420
2034
|
function nativeShadowValue(key) {
|
|
1421
2035
|
switch (key) {
|
|
1422
|
-
|
|
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":
|
|
1423
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 };
|
|
1424
2044
|
case "DEFAULT":
|
|
1425
2045
|
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1426
2046
|
case "md":
|
|
@@ -1452,13 +2072,115 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1452
2072
|
];
|
|
1453
2073
|
}
|
|
1454
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
|
+
|
|
1455
2164
|
// src/jsEngine/resolveUtilityNative.ts
|
|
1456
|
-
function
|
|
2165
|
+
function firstFontName(stack) {
|
|
2166
|
+
const first = stack.split(",")[0] ?? stack;
|
|
2167
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
2168
|
+
}
|
|
2169
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1457
2170
|
switch (parsed.utility) {
|
|
1458
2171
|
case "font": {
|
|
1459
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
|
+
}
|
|
1460
2180
|
const w = fontWeight(parsed.value);
|
|
1461
|
-
|
|
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))];
|
|
1462
2184
|
}
|
|
1463
2185
|
case "uppercase":
|
|
1464
2186
|
return [decl("text-transform", "uppercase")];
|
|
@@ -1494,16 +2216,27 @@ function resolveLeadingTrackingNative(parsed) {
|
|
|
1494
2216
|
return null;
|
|
1495
2217
|
}
|
|
1496
2218
|
function nativeHexColor(parsed, theme) {
|
|
1497
|
-
|
|
1498
|
-
if (value === null) return null;
|
|
1499
|
-
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
2219
|
+
return colorValue(theme, parsed);
|
|
1500
2220
|
}
|
|
1501
2221
|
function resolveTextNative(parsed, theme) {
|
|
1502
2222
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1503
2223
|
const size = textSize(parsed.value);
|
|
1504
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
|
+
}
|
|
1505
2230
|
const align = textAlign(parsed.value);
|
|
1506
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;
|
|
1507
2240
|
}
|
|
1508
2241
|
const hex = nativeHexColor(parsed, theme);
|
|
1509
2242
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1520,13 +2253,20 @@ function resolveColorNative(parsed, theme) {
|
|
|
1520
2253
|
return null;
|
|
1521
2254
|
}
|
|
1522
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
|
+
}
|
|
1523
2261
|
function resolveUtilityNative(parsed, theme) {
|
|
1524
|
-
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);
|
|
1525
2263
|
}
|
|
1526
2264
|
|
|
1527
2265
|
// src/jsEngine/resolveStyle.ts
|
|
1528
2266
|
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
2267
|
+
var STATE_HOLD_MARKER2 = "_kbon";
|
|
1529
2268
|
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
2269
|
+
if (modifier === STATE_HOLD_MARKER2) return true;
|
|
1530
2270
|
if (modifier === "dark") return colorScheme === "dark";
|
|
1531
2271
|
if (modifier === "active") return pressed;
|
|
1532
2272
|
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
@@ -1534,6 +2274,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1534
2274
|
if (minWidth === void 0) return null;
|
|
1535
2275
|
return width >= minWidth;
|
|
1536
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
|
+
}
|
|
1537
2305
|
return null;
|
|
1538
2306
|
}
|
|
1539
2307
|
function kebabToCamel(s) {
|
|
@@ -1578,6 +2346,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1578
2346
|
"shadow-opacity",
|
|
1579
2347
|
"shadow-radius",
|
|
1580
2348
|
"elevation",
|
|
2349
|
+
"opacity",
|
|
1581
2350
|
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1582
2351
|
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1583
2352
|
// style system wants plain numbers for these exactly like the generic
|
|
@@ -1591,29 +2360,104 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1591
2360
|
"border-bottom-right-radius",
|
|
1592
2361
|
"border-bottom-left-radius",
|
|
1593
2362
|
"outline-width",
|
|
1594
|
-
"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"
|
|
1595
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"]
|
|
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
|
+
}
|
|
1596
2401
|
function rnStyleValue(property, value) {
|
|
1597
|
-
if (
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
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;
|
|
1608
2418
|
}
|
|
1609
|
-
|
|
2419
|
+
return { value: n, warning: null };
|
|
1610
2420
|
}
|
|
1611
|
-
|
|
2421
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
2422
|
+
return { value, warning: null };
|
|
2423
|
+
}
|
|
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 };
|
|
1612
2451
|
}
|
|
1613
|
-
function
|
|
2452
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1614
2453
|
const style = {};
|
|
2454
|
+
const warnings = [];
|
|
1615
2455
|
let shadowOffset = null;
|
|
1616
|
-
|
|
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);
|
|
1617
2461
|
const parsed = parseClass(token);
|
|
1618
2462
|
const allModifiersHold = parsed.modifiers.every(
|
|
1619
2463
|
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
@@ -1621,36 +2465,121 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1621
2465
|
if (!allModifiersHold) continue;
|
|
1622
2466
|
const decls = resolveUtilityNative(parsed, theme);
|
|
1623
2467
|
if (decls === null) continue;
|
|
2468
|
+
const spec = parsed.modifiers.length;
|
|
1624
2469
|
for (const d of decls) {
|
|
1625
2470
|
if (d.property.startsWith("__")) {
|
|
1626
2471
|
continue;
|
|
1627
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
|
+
}
|
|
1628
2476
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
2477
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1629
2478
|
const n = Number(d.value);
|
|
1630
2479
|
if (!Number.isFinite(n)) continue;
|
|
1631
2480
|
if (shadowOffset === null) shadowOffset = {};
|
|
1632
2481
|
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
2482
|
+
keySpecificity.set("shadowOffset", spec);
|
|
1633
2483
|
continue;
|
|
1634
2484
|
}
|
|
1635
|
-
|
|
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
|
+
}
|
|
1636
2509
|
}
|
|
1637
2510
|
}
|
|
1638
2511
|
if (shadowOffset !== null) {
|
|
1639
2512
|
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1640
2513
|
}
|
|
1641
|
-
|
|
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 };
|
|
1642
2520
|
}
|
|
1643
2521
|
|
|
1644
2522
|
// src/nativeBridge.ts
|
|
2523
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
2524
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
2525
|
+
var cachedForThemeJson = null;
|
|
1645
2526
|
function resolveStyle(classString, pressed = false) {
|
|
1646
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1647
|
-
const width =
|
|
1648
|
-
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");
|
|
1649
2544
|
if (!KbachModule) {
|
|
1650
|
-
|
|
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);
|
|
1651
2582
|
}
|
|
1652
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1653
|
-
return JSON.parse(json);
|
|
1654
2583
|
}
|
|
1655
2584
|
|
|
1656
2585
|
// src/jsx-runtime.tsx
|