@kbach/react-native 1.0.0-beta.5 → 1.0.0-beta.51
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 +361 -0
- package/README.md +150 -137
- 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-CD5WFFIQ.mjs +40 -0
- package/dist/chunk-IJAXJVB4.mjs +566 -0
- package/dist/chunk-KHQ2BWYH.mjs +112 -0
- package/dist/clsx-BLLSnqAa.d.ts +277 -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 +92 -151
- package/dist/index.js +2119 -393
- package/dist/index.web.d.ts +101 -4
- package/dist/index.web.js +438 -401
- package/dist/index.web.mjs +268 -14
- package/dist/jsx-dev-runtime.js +2238 -332
- package/dist/jsx-dev-runtime.web.js +207 -361
- package/dist/jsx-dev-runtime.web.mjs +19 -7
- package/dist/jsx-runtime.js +2238 -332
- package/dist/jsx-runtime.web.js +191 -353
- package/dist/jsx-runtime.web.mjs +3 -6
- package/dist/theme.d.ts +79 -0
- package/dist/{chunk-AEVOM2NB.mjs → theme.js} +89 -62
- package/package.json +44 -14
- package/src/babel-plugin.js +144 -2
- package/dist/chunk-4KCCEMEN.mjs +0 -66
- package/dist/chunk-DLIXI5OW.mjs +0 -53
- package/dist/chunk-FG5E4NLJ.mjs +0 -18
- package/dist/chunk-KSDFO34H.mjs +0 -32
- package/dist/chunk-OJQAJLYT.mjs +0 -14
- package/dist/chunk-ZUE6SCTE.mjs +0 -14
- package/dist/index.d.mts +0 -161
- package/dist/index.mjs +0 -32
- package/dist/index.web.d.mts +0 -7
- package/dist/jsx-dev-runtime.d.mts +0 -10
- package/dist/jsx-dev-runtime.mjs +0 -17
- package/dist/jsx-dev-runtime.web.d.mts +0 -10
- package/dist/jsx-runtime.d.mts +0 -7
- package/dist/jsx-runtime.mjs +0 -14
- package/dist/jsx-runtime.web.d.mts +0 -7
package/dist/index.js
CHANGED
|
@@ -21,456 +21,2182 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
ThemeProvider: () => ThemeProvider,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
applyKbachConfig: () => applyKbachConfig,
|
|
25
|
+
clsx: () => clsx,
|
|
26
|
+
defaultTheme: () => import_theme4.defaultTheme,
|
|
27
|
+
deleteDynamicToken: () => import_dynamicTokens2.deleteDynamicToken,
|
|
28
|
+
getDynamicToken: () => import_dynamicTokens2.getDynamicToken,
|
|
29
|
+
getGlobalDarkMode: () => import_darkModeStore5.getGlobalDarkMode,
|
|
30
|
+
getGlobalThemeMode: () => import_darkModeStore5.getGlobalThemeMode,
|
|
31
|
+
getTheme: () => import_theme4.getTheme,
|
|
32
|
+
resolveKbachConfig: () => resolveKbachConfig,
|
|
28
33
|
resolveStyle: () => resolveStyle,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
setDynamicToken: () => import_dynamicTokens2.setDynamicToken,
|
|
35
|
+
setGlobalThemeMode: () => import_darkModeStore5.setGlobalThemeMode,
|
|
36
|
+
setTheme: () => import_theme4.setTheme,
|
|
37
|
+
subscribeDynamicTokens: () => import_dynamicTokens2.subscribeDynamicTokens,
|
|
38
|
+
subscribeGlobalDarkMode: () => import_darkModeStore5.subscribeGlobalDarkMode,
|
|
39
|
+
toggleGlobalDarkMode: () => import_darkModeStore5.toggleGlobalDarkMode,
|
|
40
|
+
useColors: () => useColors,
|
|
41
|
+
useDynamicToken: () => useDynamicToken,
|
|
34
42
|
useTheme: () => useTheme
|
|
35
43
|
});
|
|
36
44
|
module.exports = __toCommonJS(src_exports);
|
|
45
|
+
var import_theme4 = require("./theme");
|
|
37
46
|
|
|
38
|
-
// src/
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"amber-11": "#451a03",
|
|
43
|
-
"amber-12": "#291002",
|
|
44
|
-
"amber-2": "#fef3c7",
|
|
45
|
-
"amber-3": "#fde68a",
|
|
46
|
-
"amber-4": "#fcd34d",
|
|
47
|
-
"amber-5": "#fbbf24",
|
|
48
|
-
"amber-6": "#f59e0b",
|
|
49
|
-
"amber-7": "#d97706",
|
|
50
|
-
"amber-8": "#b45309",
|
|
51
|
-
"amber-9": "#92400e",
|
|
52
|
-
"black": "#000000",
|
|
53
|
-
"blue-1": "#eff6ff",
|
|
54
|
-
"blue-10": "#1e3a8a",
|
|
55
|
-
"blue-11": "#172554",
|
|
56
|
-
"blue-12": "#0d1633",
|
|
57
|
-
"blue-2": "#dbeafe",
|
|
58
|
-
"blue-3": "#bfdbfe",
|
|
59
|
-
"blue-4": "#93c5fd",
|
|
60
|
-
"blue-5": "#60a5fa",
|
|
61
|
-
"blue-6": "#3b82f6",
|
|
62
|
-
"blue-7": "#2563eb",
|
|
63
|
-
"blue-8": "#1d4ed8",
|
|
64
|
-
"blue-9": "#1e40af",
|
|
65
|
-
"bronze": "#cd7f32",
|
|
66
|
-
"coal": "#1c1c1c",
|
|
67
|
-
"copper": "#b87333",
|
|
68
|
-
"current": "currentColor",
|
|
69
|
-
"cyan-1": "#ecfeff",
|
|
70
|
-
"cyan-10": "#164e63",
|
|
71
|
-
"cyan-11": "#083344",
|
|
72
|
-
"cyan-12": "#041e28",
|
|
73
|
-
"cyan-2": "#cffafe",
|
|
74
|
-
"cyan-3": "#a5f3fc",
|
|
75
|
-
"cyan-4": "#67e8f9",
|
|
76
|
-
"cyan-5": "#22d3ee",
|
|
77
|
-
"cyan-6": "#06b6d4",
|
|
78
|
-
"cyan-7": "#0891b2",
|
|
79
|
-
"cyan-8": "#0e7490",
|
|
80
|
-
"cyan-9": "#155e75",
|
|
81
|
-
"emerald-1": "#ecfdf5",
|
|
82
|
-
"emerald-10": "#064e3b",
|
|
83
|
-
"emerald-11": "#022c22",
|
|
84
|
-
"emerald-12": "#011a14",
|
|
85
|
-
"emerald-2": "#d1fae5",
|
|
86
|
-
"emerald-3": "#a7f3d0",
|
|
87
|
-
"emerald-4": "#6ee7b7",
|
|
88
|
-
"emerald-5": "#34d399",
|
|
89
|
-
"emerald-6": "#10b981",
|
|
90
|
-
"emerald-7": "#059669",
|
|
91
|
-
"emerald-8": "#047857",
|
|
92
|
-
"emerald-9": "#065f46",
|
|
93
|
-
"fuchsia-1": "#fdf4ff",
|
|
94
|
-
"fuchsia-10": "#701a75",
|
|
95
|
-
"fuchsia-11": "#4a044e",
|
|
96
|
-
"fuchsia-12": "#2d022f",
|
|
97
|
-
"fuchsia-2": "#fae8ff",
|
|
98
|
-
"fuchsia-3": "#f5d0fe",
|
|
99
|
-
"fuchsia-4": "#f0abfc",
|
|
100
|
-
"fuchsia-5": "#e879f9",
|
|
101
|
-
"fuchsia-6": "#d946ef",
|
|
102
|
-
"fuchsia-7": "#c026d3",
|
|
103
|
-
"fuchsia-8": "#a21caf",
|
|
104
|
-
"fuchsia-9": "#86198f",
|
|
105
|
-
"gold": "#d4af37",
|
|
106
|
-
"gray-1": "#f9fafb",
|
|
107
|
-
"gray-10": "#111827",
|
|
108
|
-
"gray-11": "#030712",
|
|
109
|
-
"gray-12": "#020409",
|
|
110
|
-
"gray-2": "#f3f4f6",
|
|
111
|
-
"gray-3": "#e5e7eb",
|
|
112
|
-
"gray-4": "#d1d5db",
|
|
113
|
-
"gray-5": "#9ca3af",
|
|
114
|
-
"gray-6": "#6b7280",
|
|
115
|
-
"gray-7": "#4b5563",
|
|
116
|
-
"gray-8": "#374151",
|
|
117
|
-
"gray-9": "#1f2937",
|
|
118
|
-
"green-1": "#f0fdf4",
|
|
119
|
-
"green-10": "#14532d",
|
|
120
|
-
"green-11": "#052e16",
|
|
121
|
-
"green-12": "#031b0d",
|
|
122
|
-
"green-2": "#dcfce7",
|
|
123
|
-
"green-3": "#bbf7d0",
|
|
124
|
-
"green-4": "#86efac",
|
|
125
|
-
"green-5": "#4ade80",
|
|
126
|
-
"green-6": "#22c55e",
|
|
127
|
-
"green-7": "#16a34a",
|
|
128
|
-
"green-8": "#15803d",
|
|
129
|
-
"green-9": "#166534",
|
|
130
|
-
"indigo-1": "#eef2ff",
|
|
131
|
-
"indigo-10": "#312e81",
|
|
132
|
-
"indigo-11": "#1e1b4b",
|
|
133
|
-
"indigo-12": "#12102d",
|
|
134
|
-
"indigo-2": "#e0e7ff",
|
|
135
|
-
"indigo-3": "#c7d2fe",
|
|
136
|
-
"indigo-4": "#a5b4fc",
|
|
137
|
-
"indigo-5": "#818cf8",
|
|
138
|
-
"indigo-6": "#6366f1",
|
|
139
|
-
"indigo-7": "#4f46e5",
|
|
140
|
-
"indigo-8": "#4338ca",
|
|
141
|
-
"indigo-9": "#3730a3",
|
|
142
|
-
"lime-1": "#f7fee7",
|
|
143
|
-
"lime-10": "#365314",
|
|
144
|
-
"lime-11": "#1a2e05",
|
|
145
|
-
"lime-12": "#0f1b03",
|
|
146
|
-
"lime-2": "#ecfccb",
|
|
147
|
-
"lime-3": "#d9f99d",
|
|
148
|
-
"lime-4": "#bef264",
|
|
149
|
-
"lime-5": "#a3e635",
|
|
150
|
-
"lime-6": "#84cc16",
|
|
151
|
-
"lime-7": "#65a30d",
|
|
152
|
-
"lime-8": "#4d7c0f",
|
|
153
|
-
"lime-9": "#3f6212",
|
|
154
|
-
"neutral-1": "#fafafa",
|
|
155
|
-
"neutral-10": "#171717",
|
|
156
|
-
"neutral-11": "#0a0a0a",
|
|
157
|
-
"neutral-12": "#050505",
|
|
158
|
-
"neutral-2": "#f5f5f5",
|
|
159
|
-
"neutral-3": "#e5e5e5",
|
|
160
|
-
"neutral-4": "#d4d4d4",
|
|
161
|
-
"neutral-5": "#a3a3a3",
|
|
162
|
-
"neutral-6": "#737373",
|
|
163
|
-
"neutral-7": "#525252",
|
|
164
|
-
"neutral-8": "#404040",
|
|
165
|
-
"neutral-9": "#262626",
|
|
166
|
-
"orange-1": "#fff7ed",
|
|
167
|
-
"orange-10": "#7c2d12",
|
|
168
|
-
"orange-11": "#431407",
|
|
169
|
-
"orange-12": "#270c04",
|
|
170
|
-
"orange-2": "#ffedd5",
|
|
171
|
-
"orange-3": "#fed7aa",
|
|
172
|
-
"orange-4": "#fdba74",
|
|
173
|
-
"orange-5": "#fb923c",
|
|
174
|
-
"orange-6": "#f97316",
|
|
175
|
-
"orange-7": "#ea580c",
|
|
176
|
-
"orange-8": "#c2410c",
|
|
177
|
-
"orange-9": "#9a3412",
|
|
178
|
-
"pink-1": "#fdf2f8",
|
|
179
|
-
"pink-10": "#831843",
|
|
180
|
-
"pink-11": "#500724",
|
|
181
|
-
"pink-12": "#300415",
|
|
182
|
-
"pink-2": "#fce7f3",
|
|
183
|
-
"pink-3": "#fbcfe8",
|
|
184
|
-
"pink-4": "#f9a8d4",
|
|
185
|
-
"pink-5": "#f472b6",
|
|
186
|
-
"pink-6": "#ec4899",
|
|
187
|
-
"pink-7": "#db2777",
|
|
188
|
-
"pink-8": "#be185d",
|
|
189
|
-
"pink-9": "#9d174d",
|
|
190
|
-
"purple-1": "#faf5ff",
|
|
191
|
-
"purple-10": "#581c87",
|
|
192
|
-
"purple-11": "#3b0764",
|
|
193
|
-
"purple-12": "#23043c",
|
|
194
|
-
"purple-2": "#f3e8ff",
|
|
195
|
-
"purple-3": "#e9d5ff",
|
|
196
|
-
"purple-4": "#d8b4fe",
|
|
197
|
-
"purple-5": "#c084fc",
|
|
198
|
-
"purple-6": "#a855f7",
|
|
199
|
-
"purple-7": "#9333ea",
|
|
200
|
-
"purple-8": "#7e22ce",
|
|
201
|
-
"purple-9": "#6b21a8",
|
|
202
|
-
"red-1": "#fef2f2",
|
|
203
|
-
"red-10": "#7f1d1d",
|
|
204
|
-
"red-11": "#450a0a",
|
|
205
|
-
"red-12": "#280606",
|
|
206
|
-
"red-2": "#fee2e2",
|
|
207
|
-
"red-3": "#fecaca",
|
|
208
|
-
"red-4": "#fca5a5",
|
|
209
|
-
"red-5": "#f87171",
|
|
210
|
-
"red-6": "#ef4444",
|
|
211
|
-
"red-7": "#dc2626",
|
|
212
|
-
"red-8": "#b91c1c",
|
|
213
|
-
"red-9": "#991b1b",
|
|
214
|
-
"rose-1": "#fff1f2",
|
|
215
|
-
"rose-10": "#881337",
|
|
216
|
-
"rose-11": "#4c0519",
|
|
217
|
-
"rose-12": "#2d030e",
|
|
218
|
-
"rose-2": "#ffe4e6",
|
|
219
|
-
"rose-3": "#fecdd3",
|
|
220
|
-
"rose-4": "#fda4af",
|
|
221
|
-
"rose-5": "#fb7185",
|
|
222
|
-
"rose-6": "#f43f5e",
|
|
223
|
-
"rose-7": "#e11d48",
|
|
224
|
-
"rose-8": "#be123c",
|
|
225
|
-
"rose-9": "#9f1239",
|
|
226
|
-
"silver": "#c0c0c0",
|
|
227
|
-
"sky-1": "#f0f9ff",
|
|
228
|
-
"sky-10": "#0c4a6e",
|
|
229
|
-
"sky-11": "#082f49",
|
|
230
|
-
"sky-12": "#041b2b",
|
|
231
|
-
"sky-2": "#e0f2fe",
|
|
232
|
-
"sky-3": "#bae6fd",
|
|
233
|
-
"sky-4": "#7dd3fc",
|
|
234
|
-
"sky-5": "#38bdf8",
|
|
235
|
-
"sky-6": "#0ea5e9",
|
|
236
|
-
"sky-7": "#0284c7",
|
|
237
|
-
"sky-8": "#0369a1",
|
|
238
|
-
"sky-9": "#075985",
|
|
239
|
-
"slate-1": "#f8fafc",
|
|
240
|
-
"slate-10": "#0f172a",
|
|
241
|
-
"slate-11": "#020617",
|
|
242
|
-
"slate-12": "#01020a",
|
|
243
|
-
"slate-2": "#f1f5f9",
|
|
244
|
-
"slate-3": "#e2e8f0",
|
|
245
|
-
"slate-4": "#cbd5e1",
|
|
246
|
-
"slate-5": "#94a3b8",
|
|
247
|
-
"slate-6": "#64748b",
|
|
248
|
-
"slate-7": "#475569",
|
|
249
|
-
"slate-8": "#334155",
|
|
250
|
-
"slate-9": "#1e293b",
|
|
251
|
-
"stone-1": "#fafaf9",
|
|
252
|
-
"stone-10": "#1c1917",
|
|
253
|
-
"stone-11": "#0c0a09",
|
|
254
|
-
"stone-12": "#070605",
|
|
255
|
-
"stone-2": "#f5f5f4",
|
|
256
|
-
"stone-3": "#e7e5e4",
|
|
257
|
-
"stone-4": "#d6d3d1",
|
|
258
|
-
"stone-5": "#a8a29e",
|
|
259
|
-
"stone-6": "#78716c",
|
|
260
|
-
"stone-7": "#57534e",
|
|
261
|
-
"stone-8": "#44403c",
|
|
262
|
-
"stone-9": "#292524",
|
|
263
|
-
"teal-1": "#f0fdfa",
|
|
264
|
-
"teal-10": "#134e4a",
|
|
265
|
-
"teal-11": "#042f2e",
|
|
266
|
-
"teal-12": "#021c1b",
|
|
267
|
-
"teal-2": "#ccfbf1",
|
|
268
|
-
"teal-3": "#99f6e4",
|
|
269
|
-
"teal-4": "#5eead4",
|
|
270
|
-
"teal-5": "#2dd4bf",
|
|
271
|
-
"teal-6": "#14b8a6",
|
|
272
|
-
"teal-7": "#0d9488",
|
|
273
|
-
"teal-8": "#0f766e",
|
|
274
|
-
"teal-9": "#115e59",
|
|
275
|
-
"transparent": "transparent",
|
|
276
|
-
"violet-1": "#f5f3ff",
|
|
277
|
-
"violet-10": "#4c1d95",
|
|
278
|
-
"violet-11": "#2e1065",
|
|
279
|
-
"violet-12": "#1c0a3d",
|
|
280
|
-
"violet-2": "#ede9fe",
|
|
281
|
-
"violet-3": "#ddd6fe",
|
|
282
|
-
"violet-4": "#c4b5fd",
|
|
283
|
-
"violet-5": "#a78bfa",
|
|
284
|
-
"violet-6": "#8b5cf6",
|
|
285
|
-
"violet-7": "#7c3aed",
|
|
286
|
-
"violet-8": "#6d28d9",
|
|
287
|
-
"violet-9": "#5b21b6",
|
|
288
|
-
"white": "#ffffff",
|
|
289
|
-
"yellow-1": "#fefce8",
|
|
290
|
-
"yellow-10": "#713f12",
|
|
291
|
-
"yellow-11": "#422006",
|
|
292
|
-
"yellow-12": "#271304",
|
|
293
|
-
"yellow-2": "#fef9c3",
|
|
294
|
-
"yellow-3": "#fef08a",
|
|
295
|
-
"yellow-4": "#fde047",
|
|
296
|
-
"yellow-5": "#facc15",
|
|
297
|
-
"yellow-6": "#eab308",
|
|
298
|
-
"yellow-7": "#ca8a04",
|
|
299
|
-
"yellow-8": "#a16207",
|
|
300
|
-
"yellow-9": "#854d0e",
|
|
301
|
-
"zinc-1": "#fafafa",
|
|
302
|
-
"zinc-10": "#18181b",
|
|
303
|
-
"zinc-11": "#09090b",
|
|
304
|
-
"zinc-12": "#050506",
|
|
305
|
-
"zinc-2": "#f4f4f5",
|
|
306
|
-
"zinc-3": "#e4e4e7",
|
|
307
|
-
"zinc-4": "#d4d4d8",
|
|
308
|
-
"zinc-5": "#a1a1aa",
|
|
309
|
-
"zinc-6": "#71717a",
|
|
310
|
-
"zinc-7": "#52525b",
|
|
311
|
-
"zinc-8": "#3f3f46",
|
|
312
|
-
"zinc-9": "#27272a"
|
|
313
|
-
};
|
|
47
|
+
// src/nativeBridge.ts
|
|
48
|
+
var import_react_native = require("react-native");
|
|
49
|
+
var import_theme = require("./theme");
|
|
50
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
314
51
|
|
|
315
|
-
// src/
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
52
|
+
// src/jsEngine/parser.ts
|
|
53
|
+
var VALUE_PREFIXES = [
|
|
54
|
+
"bg-opacity-",
|
|
55
|
+
"text-opacity-",
|
|
56
|
+
"bg-blend-",
|
|
57
|
+
"text-shadow-",
|
|
58
|
+
"bg-",
|
|
59
|
+
"text-",
|
|
60
|
+
"border-x-",
|
|
61
|
+
"border-y-",
|
|
62
|
+
"border-t-",
|
|
63
|
+
"border-r-",
|
|
64
|
+
"border-b-",
|
|
65
|
+
"border-l-",
|
|
66
|
+
"border-",
|
|
67
|
+
"caret-",
|
|
68
|
+
"accent-",
|
|
69
|
+
"fill-",
|
|
70
|
+
"stroke-width-",
|
|
71
|
+
"stroke-",
|
|
72
|
+
"resize-",
|
|
73
|
+
"touch-",
|
|
74
|
+
"will-change-",
|
|
75
|
+
"scroll-mx-",
|
|
76
|
+
"scroll-my-",
|
|
77
|
+
"scroll-mt-",
|
|
78
|
+
"scroll-mr-",
|
|
79
|
+
"scroll-mb-",
|
|
80
|
+
"scroll-ml-",
|
|
81
|
+
"scroll-m-",
|
|
82
|
+
"scroll-px-",
|
|
83
|
+
"scroll-py-",
|
|
84
|
+
"scroll-pt-",
|
|
85
|
+
"scroll-pr-",
|
|
86
|
+
"scroll-pb-",
|
|
87
|
+
"scroll-pl-",
|
|
88
|
+
"scroll-p-",
|
|
89
|
+
"px-",
|
|
90
|
+
"py-",
|
|
91
|
+
"pt-",
|
|
92
|
+
"pr-",
|
|
93
|
+
"pb-",
|
|
94
|
+
"pl-",
|
|
95
|
+
"p-",
|
|
96
|
+
"mx-",
|
|
97
|
+
"my-",
|
|
98
|
+
"mt-",
|
|
99
|
+
"mr-",
|
|
100
|
+
"mb-",
|
|
101
|
+
"ml-",
|
|
102
|
+
"m-",
|
|
103
|
+
"gap-x-",
|
|
104
|
+
"gap-y-",
|
|
105
|
+
"gap-",
|
|
106
|
+
"min-w-",
|
|
107
|
+
"max-w-",
|
|
108
|
+
"w-",
|
|
109
|
+
"min-h-",
|
|
110
|
+
"max-h-",
|
|
111
|
+
"h-",
|
|
112
|
+
"size-",
|
|
113
|
+
"basis-",
|
|
114
|
+
"rounded-tl-",
|
|
115
|
+
"rounded-tr-",
|
|
116
|
+
"rounded-br-",
|
|
117
|
+
"rounded-bl-",
|
|
118
|
+
"rounded-t-",
|
|
119
|
+
"rounded-r-",
|
|
120
|
+
"rounded-b-",
|
|
121
|
+
"rounded-l-",
|
|
122
|
+
"rounded-",
|
|
123
|
+
"ring-offset-",
|
|
124
|
+
"ring-",
|
|
125
|
+
"outline-offset-",
|
|
126
|
+
"outline-",
|
|
127
|
+
"shadow-",
|
|
128
|
+
"opacity-",
|
|
129
|
+
"duration-",
|
|
130
|
+
"delay-",
|
|
131
|
+
"ease-",
|
|
132
|
+
"cursor-",
|
|
133
|
+
"mix-blend-",
|
|
134
|
+
"animate-",
|
|
135
|
+
"leading-",
|
|
136
|
+
"tracking-",
|
|
137
|
+
"font-",
|
|
138
|
+
"z-",
|
|
139
|
+
"inset-x-",
|
|
140
|
+
"inset-y-",
|
|
141
|
+
"inset-",
|
|
142
|
+
"top-",
|
|
143
|
+
"right-",
|
|
144
|
+
"bottom-",
|
|
145
|
+
"left-",
|
|
146
|
+
"start-",
|
|
147
|
+
"end-",
|
|
148
|
+
"overflow-x-",
|
|
149
|
+
"overflow-y-",
|
|
150
|
+
"overscroll-x-",
|
|
151
|
+
"overscroll-y-",
|
|
152
|
+
"overscroll-",
|
|
153
|
+
"aspect-",
|
|
154
|
+
"divide-color-",
|
|
155
|
+
"space-x-",
|
|
156
|
+
"space-y-",
|
|
157
|
+
"flex-",
|
|
158
|
+
"grow-",
|
|
159
|
+
"shrink-",
|
|
160
|
+
"order-",
|
|
161
|
+
"grid-cols-",
|
|
162
|
+
"grid-rows-",
|
|
163
|
+
"grid-flow-",
|
|
164
|
+
"auto-cols-",
|
|
165
|
+
"auto-rows-",
|
|
166
|
+
"col-span-",
|
|
167
|
+
"col-start-",
|
|
168
|
+
"col-end-",
|
|
169
|
+
"col-",
|
|
170
|
+
"row-span-",
|
|
171
|
+
"row-start-",
|
|
172
|
+
"row-end-",
|
|
173
|
+
"row-",
|
|
174
|
+
"place-items-",
|
|
175
|
+
"place-content-",
|
|
176
|
+
"place-self-",
|
|
177
|
+
"justify-items-",
|
|
178
|
+
"justify-self-",
|
|
179
|
+
"scale-x-",
|
|
180
|
+
"scale-y-",
|
|
181
|
+
"scale-z-",
|
|
182
|
+
"scale-",
|
|
183
|
+
"rotate-x-",
|
|
184
|
+
"rotate-y-",
|
|
185
|
+
"rotate-z-",
|
|
186
|
+
"rotate-",
|
|
187
|
+
"translate-x-",
|
|
188
|
+
"translate-y-",
|
|
189
|
+
"translate-z-",
|
|
190
|
+
"skew-x-",
|
|
191
|
+
"skew-y-",
|
|
192
|
+
"perspective-origin-",
|
|
193
|
+
"perspective-",
|
|
194
|
+
"origin-",
|
|
195
|
+
"blur-",
|
|
196
|
+
"brightness-",
|
|
197
|
+
"contrast-",
|
|
198
|
+
"grayscale-",
|
|
199
|
+
"hue-rotate-",
|
|
200
|
+
"invert-",
|
|
201
|
+
"saturate-",
|
|
202
|
+
"sepia-",
|
|
203
|
+
"drop-shadow-",
|
|
204
|
+
"filter-",
|
|
205
|
+
"backdrop-blur-",
|
|
206
|
+
"backdrop-brightness-",
|
|
207
|
+
"backdrop-contrast-",
|
|
208
|
+
"backdrop-grayscale-",
|
|
209
|
+
"backdrop-hue-rotate-",
|
|
210
|
+
"backdrop-invert-",
|
|
211
|
+
"backdrop-opacity-",
|
|
212
|
+
"backdrop-saturate-",
|
|
213
|
+
"backdrop-sepia-",
|
|
214
|
+
"backdrop-filter-",
|
|
215
|
+
"decoration-",
|
|
216
|
+
"underline-offset-",
|
|
217
|
+
"indent-",
|
|
218
|
+
"from-",
|
|
219
|
+
"via-",
|
|
220
|
+
"to-"
|
|
221
|
+
];
|
|
222
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
223
|
+
function isSafeArbitraryValue(value) {
|
|
224
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
225
|
+
}
|
|
226
|
+
function normalizeMathWhitespace(raw) {
|
|
227
|
+
if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
|
|
228
|
+
return raw;
|
|
229
|
+
}
|
|
230
|
+
const chars = Array.from(raw);
|
|
231
|
+
let out = "";
|
|
232
|
+
let i = 0;
|
|
233
|
+
let prevEndsValue = false;
|
|
234
|
+
while (i < chars.length) {
|
|
235
|
+
const c = chars[i];
|
|
236
|
+
if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
|
|
237
|
+
const start = i;
|
|
238
|
+
let depth = 0;
|
|
239
|
+
while (i < chars.length) {
|
|
240
|
+
if (chars[i] === "(") depth++;
|
|
241
|
+
else if (chars[i] === ")") {
|
|
242
|
+
depth--;
|
|
243
|
+
if (depth === 0) {
|
|
244
|
+
i++;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
i++;
|
|
249
|
+
}
|
|
250
|
+
out += chars.slice(start, i).join("");
|
|
251
|
+
prevEndsValue = true;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (c === "+" || c === "-") {
|
|
255
|
+
if (prevEndsValue) {
|
|
256
|
+
out += ` ${c} `;
|
|
257
|
+
i++;
|
|
258
|
+
while (i < chars.length && /\s/.test(chars[i])) i++;
|
|
259
|
+
prevEndsValue = false;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
out += c;
|
|
263
|
+
prevEndsValue = false;
|
|
264
|
+
} else if (c === "(" || c === ",") {
|
|
265
|
+
out += c;
|
|
266
|
+
if (c === ",") out += " ";
|
|
267
|
+
prevEndsValue = false;
|
|
268
|
+
} else if (c === ")") {
|
|
269
|
+
out += c;
|
|
270
|
+
prevEndsValue = true;
|
|
271
|
+
} else if (/\s/.test(c)) {
|
|
272
|
+
} else if (c === "*" || c === "/") {
|
|
273
|
+
out += c;
|
|
274
|
+
prevEndsValue = false;
|
|
275
|
+
} else {
|
|
276
|
+
out += c;
|
|
277
|
+
prevEndsValue = true;
|
|
278
|
+
}
|
|
279
|
+
i++;
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
343
282
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
283
|
+
function splitRespectingBrackets(token) {
|
|
284
|
+
const parts = [];
|
|
285
|
+
let depth = 0;
|
|
286
|
+
let start = 0;
|
|
287
|
+
for (let i = 0; i < token.length; i++) {
|
|
288
|
+
const ch = token[i];
|
|
289
|
+
if (ch === "[") depth += 1;
|
|
290
|
+
else if (ch === "]") depth -= 1;
|
|
291
|
+
else if (ch === ":" && depth <= 0) {
|
|
292
|
+
parts.push(token.slice(start, i));
|
|
293
|
+
start = i + 1;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
parts.push(token.slice(start));
|
|
297
|
+
return parts;
|
|
346
298
|
}
|
|
347
|
-
function
|
|
348
|
-
|
|
299
|
+
function parseClass(token) {
|
|
300
|
+
const parts = splitRespectingBrackets(token);
|
|
301
|
+
let base = parts.pop() ?? token;
|
|
302
|
+
const modifiers = parts;
|
|
303
|
+
const important = base.startsWith("!");
|
|
304
|
+
if (important) {
|
|
305
|
+
base = base.slice(1);
|
|
306
|
+
}
|
|
307
|
+
const negative = base.startsWith("-");
|
|
308
|
+
if (negative) {
|
|
309
|
+
base = base.slice(1);
|
|
310
|
+
}
|
|
311
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
312
|
+
const raw = base.slice(1, -1);
|
|
313
|
+
const colonIdx = raw.indexOf(":");
|
|
314
|
+
if (colonIdx !== -1) {
|
|
315
|
+
const property = raw.slice(0, colonIdx);
|
|
316
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
317
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
318
|
+
const value = normalizeMathWhitespace(rawValue.replace(/_/g, " "));
|
|
319
|
+
return {
|
|
320
|
+
modifiers,
|
|
321
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
322
|
+
value: `${property}:${value}`,
|
|
323
|
+
isArbitrary: true,
|
|
324
|
+
important,
|
|
325
|
+
negative,
|
|
326
|
+
original: token
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
332
|
+
if (!base.startsWith(prefix)) continue;
|
|
333
|
+
const value = base.slice(prefix.length);
|
|
334
|
+
if (value === "") continue;
|
|
335
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
336
|
+
const raw = value.slice(1, -1);
|
|
337
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const spaced = normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
341
|
+
return {
|
|
342
|
+
modifiers,
|
|
343
|
+
utility: prefix.slice(0, -1),
|
|
344
|
+
value: spaced,
|
|
345
|
+
isArbitrary: true,
|
|
346
|
+
important,
|
|
347
|
+
negative,
|
|
348
|
+
original: token
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
modifiers,
|
|
353
|
+
utility: prefix.slice(0, -1),
|
|
354
|
+
value,
|
|
355
|
+
isArbitrary: false,
|
|
356
|
+
important,
|
|
357
|
+
negative,
|
|
358
|
+
original: token
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
modifiers,
|
|
363
|
+
utility: base,
|
|
364
|
+
value: null,
|
|
365
|
+
isArbitrary: false,
|
|
366
|
+
important,
|
|
367
|
+
negative,
|
|
368
|
+
original: token
|
|
369
|
+
};
|
|
349
370
|
}
|
|
350
371
|
|
|
351
|
-
// src/
|
|
352
|
-
|
|
372
|
+
// src/jsEngine/shared.ts
|
|
373
|
+
function decl(property, value) {
|
|
374
|
+
return { property, value };
|
|
375
|
+
}
|
|
376
|
+
function spacingPx(theme, value) {
|
|
377
|
+
const fromTable = theme.spacing[value];
|
|
378
|
+
if (fromTable !== void 0) return fromTable;
|
|
379
|
+
const n = Number(value);
|
|
380
|
+
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
381
|
+
}
|
|
382
|
+
function resolveLength(theme, parsed) {
|
|
383
|
+
if (parsed.negative) return null;
|
|
384
|
+
const value = parsed.value;
|
|
385
|
+
if (value === null) return null;
|
|
386
|
+
if (parsed.isArbitrary) return value;
|
|
387
|
+
if (value === "full") return "100%";
|
|
388
|
+
if (value === "auto") return "auto";
|
|
389
|
+
const px = spacingPx(theme, value);
|
|
390
|
+
return px === void 0 ? null : `${px}px`;
|
|
391
|
+
}
|
|
392
|
+
function resolveNegatableLength(theme, parsed) {
|
|
393
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
394
|
+
if (parsed.isArbitrary) {
|
|
395
|
+
const value2 = parsed.value;
|
|
396
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
397
|
+
}
|
|
398
|
+
const value = parsed.value;
|
|
399
|
+
if (value === null) return null;
|
|
400
|
+
const px = spacingPx(theme, value);
|
|
401
|
+
if (px === void 0) return null;
|
|
402
|
+
if (px === 0) return "0px";
|
|
403
|
+
return `-${px}px`;
|
|
404
|
+
}
|
|
405
|
+
function fractionPercent(value) {
|
|
406
|
+
const slashIdx = value.indexOf("/");
|
|
407
|
+
if (slashIdx === -1) return null;
|
|
408
|
+
const numStr = value.slice(0, slashIdx);
|
|
409
|
+
const denStr = value.slice(slashIdx + 1);
|
|
410
|
+
const num = Number(numStr);
|
|
411
|
+
const den = Number(denStr);
|
|
412
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
413
|
+
if (den === 0) return null;
|
|
414
|
+
const pct = num / den * 100;
|
|
415
|
+
const formatted = pct.toFixed(6);
|
|
416
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
417
|
+
return `${trimmed}%`;
|
|
418
|
+
}
|
|
419
|
+
function resolveNegatableSize(theme, parsed) {
|
|
420
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
421
|
+
const pct = fractionPercent(parsed.value);
|
|
422
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
423
|
+
}
|
|
424
|
+
return resolveNegatableLength(theme, parsed);
|
|
425
|
+
}
|
|
426
|
+
function resolvePercent(parsed) {
|
|
427
|
+
if (parsed.negative) return null;
|
|
428
|
+
const value = parsed.value;
|
|
429
|
+
if (value === null) return null;
|
|
430
|
+
if (parsed.isArbitrary) return value;
|
|
431
|
+
const pct = Number(value);
|
|
432
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
433
|
+
return String(pct / 100);
|
|
434
|
+
}
|
|
353
435
|
|
|
354
|
-
// src/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
function systemPrefersDark() {
|
|
358
|
-
return import_react_native.Appearance.getColorScheme() === "dark";
|
|
359
|
-
}
|
|
360
|
-
function resolveIsDark(m) {
|
|
361
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
362
|
-
}
|
|
363
|
-
var mode = "system";
|
|
364
|
-
var isDark = resolveIsDark(mode);
|
|
365
|
-
var hasExplicitChoice = false;
|
|
366
|
-
var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
|
|
367
|
-
if (mode !== "system") return;
|
|
368
|
-
isDark = colorScheme === "dark";
|
|
369
|
-
notify();
|
|
370
|
-
});
|
|
371
|
-
function notify() {
|
|
372
|
-
for (const listener of listeners) listener();
|
|
436
|
+
// src/jsEngine/resolvers/layout.ts
|
|
437
|
+
function negateRaw(value, negative) {
|
|
438
|
+
return negative ? `-${value}` : value;
|
|
373
439
|
}
|
|
374
|
-
function
|
|
375
|
-
|
|
440
|
+
function overflowAxisValue(property, value) {
|
|
441
|
+
switch (value) {
|
|
442
|
+
case "auto":
|
|
443
|
+
case "hidden":
|
|
444
|
+
case "clip":
|
|
445
|
+
case "visible":
|
|
446
|
+
case "scroll":
|
|
447
|
+
return [decl(property, value)];
|
|
448
|
+
default:
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
376
451
|
}
|
|
377
|
-
function
|
|
378
|
-
|
|
452
|
+
function overscrollValue(property, value) {
|
|
453
|
+
switch (value) {
|
|
454
|
+
case "auto":
|
|
455
|
+
case "contain":
|
|
456
|
+
case "none":
|
|
457
|
+
return [decl(property, value)];
|
|
458
|
+
default:
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
379
461
|
}
|
|
380
|
-
function
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
462
|
+
function resolve(parsed, theme) {
|
|
463
|
+
switch (parsed.utility) {
|
|
464
|
+
case "flex":
|
|
465
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
466
|
+
case "grid":
|
|
467
|
+
return [decl("display", "grid")];
|
|
468
|
+
case "block":
|
|
469
|
+
return [decl("display", "block")];
|
|
470
|
+
case "inline-block":
|
|
471
|
+
return [decl("display", "inline-block")];
|
|
472
|
+
case "inline":
|
|
473
|
+
return [decl("display", "inline")];
|
|
474
|
+
case "inline-flex":
|
|
475
|
+
return [decl("display", "inline-flex")];
|
|
476
|
+
case "inline-grid":
|
|
477
|
+
return [decl("display", "inline-grid")];
|
|
478
|
+
case "contents":
|
|
479
|
+
return [decl("display", "contents")];
|
|
480
|
+
case "flow-root":
|
|
481
|
+
return [decl("display", "flow-root")];
|
|
482
|
+
case "hidden":
|
|
483
|
+
return [decl("display", "none")];
|
|
484
|
+
case "@container":
|
|
485
|
+
return [decl("container-type", "inline-size")];
|
|
486
|
+
case "items-center":
|
|
487
|
+
return [decl("align-items", "center")];
|
|
488
|
+
case "items-start":
|
|
489
|
+
return [decl("align-items", "flex-start")];
|
|
490
|
+
case "items-end":
|
|
491
|
+
return [decl("align-items", "flex-end")];
|
|
492
|
+
case "items-baseline":
|
|
493
|
+
return [decl("align-items", "baseline")];
|
|
494
|
+
case "items-stretch":
|
|
495
|
+
return [decl("align-items", "stretch")];
|
|
496
|
+
case "justify-center":
|
|
497
|
+
return [decl("justify-content", "center")];
|
|
498
|
+
case "justify-start":
|
|
499
|
+
return [decl("justify-content", "flex-start")];
|
|
500
|
+
case "justify-end":
|
|
501
|
+
return [decl("justify-content", "flex-end")];
|
|
502
|
+
case "justify-between":
|
|
503
|
+
return [decl("justify-content", "space-between")];
|
|
504
|
+
case "justify-around":
|
|
505
|
+
return [decl("justify-content", "space-around")];
|
|
506
|
+
case "justify-evenly":
|
|
507
|
+
return [decl("justify-content", "space-evenly")];
|
|
508
|
+
case "justify-normal":
|
|
509
|
+
return [decl("justify-content", "normal")];
|
|
510
|
+
case "justify-stretch":
|
|
511
|
+
return [decl("justify-content", "stretch")];
|
|
512
|
+
case "content-normal":
|
|
513
|
+
return [decl("align-content", "normal")];
|
|
514
|
+
case "content-start":
|
|
515
|
+
return [decl("align-content", "flex-start")];
|
|
516
|
+
case "content-end":
|
|
517
|
+
return [decl("align-content", "flex-end")];
|
|
518
|
+
case "content-center":
|
|
519
|
+
return [decl("align-content", "center")];
|
|
520
|
+
case "content-between":
|
|
521
|
+
return [decl("align-content", "space-between")];
|
|
522
|
+
case "content-around":
|
|
523
|
+
return [decl("align-content", "space-around")];
|
|
524
|
+
case "content-evenly":
|
|
525
|
+
return [decl("align-content", "space-evenly")];
|
|
526
|
+
case "content-stretch":
|
|
527
|
+
return [decl("align-content", "stretch")];
|
|
528
|
+
case "self-auto":
|
|
529
|
+
return [decl("align-self", "auto")];
|
|
530
|
+
case "self-center":
|
|
531
|
+
return [decl("align-self", "center")];
|
|
532
|
+
case "self-start":
|
|
533
|
+
return [decl("align-self", "flex-start")];
|
|
534
|
+
case "self-end":
|
|
535
|
+
return [decl("align-self", "flex-end")];
|
|
536
|
+
case "self-stretch":
|
|
537
|
+
return [decl("align-self", "stretch")];
|
|
538
|
+
case "self-baseline":
|
|
539
|
+
return [decl("align-self", "baseline")];
|
|
540
|
+
case "overflow-hidden":
|
|
541
|
+
return [decl("overflow", "hidden")];
|
|
542
|
+
case "overflow-auto":
|
|
543
|
+
return [decl("overflow", "auto")];
|
|
544
|
+
case "overflow-scroll":
|
|
545
|
+
return [decl("overflow", "scroll")];
|
|
546
|
+
case "overflow-visible":
|
|
547
|
+
return [decl("overflow", "visible")];
|
|
548
|
+
case "overflow-clip":
|
|
549
|
+
return [decl("overflow", "clip")];
|
|
550
|
+
case "overflow-x":
|
|
551
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
552
|
+
case "overflow-y":
|
|
553
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
554
|
+
case "overscroll":
|
|
555
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
556
|
+
case "overscroll-x":
|
|
557
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
558
|
+
case "overscroll-y":
|
|
559
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
560
|
+
case "static":
|
|
561
|
+
return [decl("position", "static")];
|
|
562
|
+
case "relative":
|
|
563
|
+
return [decl("position", "relative")];
|
|
564
|
+
case "absolute":
|
|
565
|
+
return [decl("position", "absolute")];
|
|
566
|
+
case "fixed":
|
|
567
|
+
return [decl("position", "fixed")];
|
|
568
|
+
case "sticky":
|
|
569
|
+
return [decl("position", "sticky")];
|
|
570
|
+
case "z":
|
|
571
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
572
|
+
case "order":
|
|
573
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
574
|
+
case "grow":
|
|
575
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
576
|
+
case "shrink":
|
|
577
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
578
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
579
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
580
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
581
|
+
case "top": {
|
|
582
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
583
|
+
return v === null ? null : [decl("top", v)];
|
|
584
|
+
}
|
|
585
|
+
case "right": {
|
|
586
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
587
|
+
return v === null ? null : [decl("right", v)];
|
|
588
|
+
}
|
|
589
|
+
case "bottom": {
|
|
590
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
591
|
+
return v === null ? null : [decl("bottom", v)];
|
|
592
|
+
}
|
|
593
|
+
case "left": {
|
|
594
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
595
|
+
return v === null ? null : [decl("left", v)];
|
|
596
|
+
}
|
|
597
|
+
case "inset": {
|
|
598
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
599
|
+
return v === null ? null : [decl("inset", v)];
|
|
600
|
+
}
|
|
601
|
+
case "inset-x": {
|
|
602
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
603
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
604
|
+
}
|
|
605
|
+
case "inset-y": {
|
|
606
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
607
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
608
|
+
}
|
|
609
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
610
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
611
|
+
case "start": {
|
|
612
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
613
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
614
|
+
}
|
|
615
|
+
case "end": {
|
|
616
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
617
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
618
|
+
}
|
|
619
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
620
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
621
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
622
|
+
// "aspect" arm.
|
|
623
|
+
case "aspect": {
|
|
624
|
+
const value = parsed.value;
|
|
625
|
+
if (value === null) return null;
|
|
626
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
627
|
+
switch (value) {
|
|
628
|
+
case "square":
|
|
629
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
630
|
+
case "video":
|
|
631
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
632
|
+
case "auto":
|
|
633
|
+
return [decl("aspect-ratio", "auto")];
|
|
634
|
+
default:
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
default:
|
|
639
|
+
return null;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function resolveFlex(parsed, web) {
|
|
643
|
+
if (parsed.utility !== "flex") return null;
|
|
644
|
+
const value = parsed.value;
|
|
645
|
+
if (value === null) return null;
|
|
646
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
647
|
+
switch (value) {
|
|
648
|
+
case "row":
|
|
649
|
+
return [decl("flex-direction", "row")];
|
|
650
|
+
case "col":
|
|
651
|
+
return [decl("flex-direction", "column")];
|
|
652
|
+
case "row-reverse":
|
|
653
|
+
return [decl("flex-direction", "row-reverse")];
|
|
654
|
+
case "col-reverse":
|
|
655
|
+
return [decl("flex-direction", "column-reverse")];
|
|
656
|
+
case "wrap":
|
|
657
|
+
return [decl("flex-wrap", "wrap")];
|
|
658
|
+
case "wrap-reverse":
|
|
659
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
660
|
+
case "nowrap":
|
|
661
|
+
return [decl("flex-wrap", "nowrap")];
|
|
662
|
+
case "1":
|
|
663
|
+
return [decl("flex", "1")];
|
|
664
|
+
case "auto":
|
|
665
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
666
|
+
case "initial":
|
|
667
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
668
|
+
case "none":
|
|
669
|
+
return [decl("flex", web ? "none" : "0")];
|
|
670
|
+
case "grow":
|
|
671
|
+
return [decl("flex-grow", "1")];
|
|
672
|
+
case "grow-0":
|
|
673
|
+
return [decl("flex-grow", "0")];
|
|
674
|
+
case "shrink":
|
|
675
|
+
return [decl("flex-shrink", "1")];
|
|
676
|
+
case "shrink-0":
|
|
677
|
+
return [decl("flex-shrink", "0")];
|
|
678
|
+
default:
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
385
681
|
}
|
|
386
|
-
|
|
387
|
-
|
|
682
|
+
|
|
683
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
684
|
+
function namedSize(key) {
|
|
685
|
+
switch (key) {
|
|
686
|
+
case "sm":
|
|
687
|
+
return "24rem";
|
|
688
|
+
case "md":
|
|
689
|
+
return "28rem";
|
|
690
|
+
case "lg":
|
|
691
|
+
return "32rem";
|
|
692
|
+
case "xl":
|
|
693
|
+
return "36rem";
|
|
694
|
+
case "2xl":
|
|
695
|
+
return "42rem";
|
|
696
|
+
case "3xl":
|
|
697
|
+
return "48rem";
|
|
698
|
+
case "4xl":
|
|
699
|
+
return "56rem";
|
|
700
|
+
case "5xl":
|
|
701
|
+
return "64rem";
|
|
702
|
+
case "6xl":
|
|
703
|
+
return "72rem";
|
|
704
|
+
case "7xl":
|
|
705
|
+
return "80rem";
|
|
706
|
+
case "8xl":
|
|
707
|
+
return "88rem";
|
|
708
|
+
case "9xl":
|
|
709
|
+
return "96rem";
|
|
710
|
+
default:
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
388
713
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
391
|
-
|
|
714
|
+
function cssSizeKeyword(key) {
|
|
715
|
+
switch (key) {
|
|
716
|
+
case "min":
|
|
717
|
+
return "min-content";
|
|
718
|
+
case "max":
|
|
719
|
+
return "max-content";
|
|
720
|
+
case "fit":
|
|
721
|
+
return "fit-content";
|
|
722
|
+
default:
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
392
725
|
}
|
|
393
|
-
function
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
726
|
+
function resolveSize(theme, parsed) {
|
|
727
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
728
|
+
const named = namedSize(parsed.value);
|
|
729
|
+
if (named !== null) return named;
|
|
730
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
731
|
+
if (kw !== null) return kw;
|
|
732
|
+
const fraction = fractionPercent(parsed.value);
|
|
733
|
+
if (fraction !== null) return fraction;
|
|
734
|
+
}
|
|
735
|
+
return resolveLength(theme, parsed);
|
|
736
|
+
}
|
|
737
|
+
function resolve2(parsed, theme) {
|
|
738
|
+
const length = () => resolveLength(theme, parsed);
|
|
739
|
+
const size = () => resolveSize(theme, parsed);
|
|
740
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
741
|
+
switch (parsed.utility) {
|
|
742
|
+
case "p": {
|
|
743
|
+
const v = length();
|
|
744
|
+
return v === null ? null : [decl("padding", v)];
|
|
745
|
+
}
|
|
746
|
+
case "px": {
|
|
747
|
+
const v = length();
|
|
748
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
749
|
+
}
|
|
750
|
+
case "py": {
|
|
751
|
+
const v = length();
|
|
752
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
753
|
+
}
|
|
754
|
+
case "pt": {
|
|
755
|
+
const v = length();
|
|
756
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
757
|
+
}
|
|
758
|
+
case "pr": {
|
|
759
|
+
const v = length();
|
|
760
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
761
|
+
}
|
|
762
|
+
case "pb": {
|
|
763
|
+
const v = length();
|
|
764
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
765
|
+
}
|
|
766
|
+
case "pl": {
|
|
767
|
+
const v = length();
|
|
768
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
769
|
+
}
|
|
770
|
+
case "m": {
|
|
771
|
+
const v = negatableLength();
|
|
772
|
+
return v === null ? null : [decl("margin", v)];
|
|
773
|
+
}
|
|
774
|
+
case "mx": {
|
|
775
|
+
const v = negatableLength();
|
|
776
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
777
|
+
}
|
|
778
|
+
case "my": {
|
|
779
|
+
const v = negatableLength();
|
|
780
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
781
|
+
}
|
|
782
|
+
case "mt": {
|
|
783
|
+
const v = negatableLength();
|
|
784
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
785
|
+
}
|
|
786
|
+
case "mr": {
|
|
787
|
+
const v = negatableLength();
|
|
788
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
789
|
+
}
|
|
790
|
+
case "mb": {
|
|
791
|
+
const v = negatableLength();
|
|
792
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
793
|
+
}
|
|
794
|
+
case "ml": {
|
|
795
|
+
const v = negatableLength();
|
|
796
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
797
|
+
}
|
|
798
|
+
case "gap": {
|
|
799
|
+
const v = length();
|
|
800
|
+
return v === null ? null : [decl("gap", v)];
|
|
801
|
+
}
|
|
802
|
+
case "gap-x": {
|
|
803
|
+
const v = length();
|
|
804
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
805
|
+
}
|
|
806
|
+
case "gap-y": {
|
|
807
|
+
const v = length();
|
|
808
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
809
|
+
}
|
|
810
|
+
case "w": {
|
|
811
|
+
const v = size();
|
|
812
|
+
return v === null ? null : [decl("width", v)];
|
|
813
|
+
}
|
|
814
|
+
case "h": {
|
|
815
|
+
const v = size();
|
|
816
|
+
return v === null ? null : [decl("height", v)];
|
|
817
|
+
}
|
|
818
|
+
case "min-w": {
|
|
819
|
+
const v = size();
|
|
820
|
+
return v === null ? null : [decl("min-width", v)];
|
|
821
|
+
}
|
|
822
|
+
case "max-w": {
|
|
823
|
+
const v = size();
|
|
824
|
+
return v === null ? null : [decl("max-width", v)];
|
|
825
|
+
}
|
|
826
|
+
case "min-h": {
|
|
827
|
+
const v = size();
|
|
828
|
+
return v === null ? null : [decl("min-height", v)];
|
|
829
|
+
}
|
|
830
|
+
case "max-h": {
|
|
831
|
+
const v = size();
|
|
832
|
+
return v === null ? null : [decl("max-height", v)];
|
|
833
|
+
}
|
|
834
|
+
case "size": {
|
|
835
|
+
const v = size();
|
|
836
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
837
|
+
}
|
|
838
|
+
case "basis": {
|
|
839
|
+
const v = size();
|
|
840
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
841
|
+
}
|
|
842
|
+
default:
|
|
843
|
+
return null;
|
|
844
|
+
}
|
|
398
845
|
}
|
|
399
846
|
|
|
400
|
-
// src/
|
|
401
|
-
function
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
847
|
+
// src/jsEngine/resolvers/color.ts
|
|
848
|
+
function lookupHex(theme, key) {
|
|
849
|
+
const entry = theme.colors[key];
|
|
850
|
+
return typeof entry === "string" ? entry : null;
|
|
851
|
+
}
|
|
852
|
+
var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
|
|
853
|
+
function findModeAwareColor(base, theme) {
|
|
854
|
+
const important = base.startsWith("!") ? "!" : "";
|
|
855
|
+
const rest = important ? base.slice(1) : base;
|
|
856
|
+
for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
|
|
857
|
+
if (!rest.startsWith(prefix)) continue;
|
|
858
|
+
const [name, opacity] = splitOpacity(rest.slice(prefix.length));
|
|
859
|
+
const entry = theme.colors[name];
|
|
860
|
+
if (typeof entry === "object" && entry !== null) {
|
|
861
|
+
return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
function applyOpacityToHex(hex, opacity) {
|
|
867
|
+
if (opacity === null) return hex;
|
|
868
|
+
const rgb = hexToRgb(hex);
|
|
869
|
+
if (rgb === null) return hex;
|
|
870
|
+
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
871
|
+
}
|
|
872
|
+
function substituteModeAwareColorToken(token, theme, colorScheme) {
|
|
873
|
+
const segments = token.split(":");
|
|
874
|
+
const base = segments.pop() ?? token;
|
|
875
|
+
const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
|
|
876
|
+
const found = findModeAwareColor(base, theme);
|
|
877
|
+
if (found === null) return token;
|
|
878
|
+
const hex = colorScheme === "dark" ? found.dark : found.light;
|
|
879
|
+
return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
|
|
880
|
+
}
|
|
881
|
+
function hexToRgb(hex) {
|
|
882
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
883
|
+
if (!m) return null;
|
|
884
|
+
let h = m[1];
|
|
885
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
886
|
+
const n = parseInt(h, 16);
|
|
887
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
888
|
+
}
|
|
889
|
+
function splitOpacity(value) {
|
|
890
|
+
const slash = value.lastIndexOf("/");
|
|
891
|
+
if (slash === -1) return [value, null];
|
|
892
|
+
const opacityText = value.slice(slash + 1);
|
|
893
|
+
const n = Number(opacityText);
|
|
894
|
+
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
895
|
+
return [value.slice(0, slash), n];
|
|
896
|
+
}
|
|
897
|
+
return [value, null];
|
|
898
|
+
}
|
|
899
|
+
function colorValue(theme, parsed) {
|
|
900
|
+
const value = parsed.value;
|
|
901
|
+
if (value === null) return null;
|
|
902
|
+
if (parsed.isArbitrary) return value;
|
|
903
|
+
const [name, opacity] = splitOpacity(value);
|
|
904
|
+
const hex = lookupHex(theme, name);
|
|
905
|
+
if (hex === null) return null;
|
|
906
|
+
if (opacity === null) return hex;
|
|
907
|
+
const rgb = hexToRgb(hex);
|
|
908
|
+
if (rgb === null) return hex;
|
|
909
|
+
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
910
|
+
}
|
|
911
|
+
var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
|
|
912
|
+
function looksLikeLength(value) {
|
|
913
|
+
const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
|
|
914
|
+
const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
|
|
915
|
+
return withoutUnit !== "" && Number.isFinite(Number(withoutUnit));
|
|
407
916
|
}
|
|
408
917
|
|
|
409
|
-
// src/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
918
|
+
// src/jsEngine/resolvers/border.ts
|
|
919
|
+
function radiusSize(key) {
|
|
920
|
+
switch (key) {
|
|
921
|
+
case "none":
|
|
922
|
+
return "0px";
|
|
923
|
+
case "sm":
|
|
924
|
+
return "0.125rem";
|
|
925
|
+
case "md":
|
|
926
|
+
return "0.375rem";
|
|
927
|
+
case "lg":
|
|
928
|
+
return "0.5rem";
|
|
929
|
+
case "xl":
|
|
930
|
+
return "0.75rem";
|
|
931
|
+
case "2xl":
|
|
932
|
+
return "1rem";
|
|
933
|
+
case "3xl":
|
|
934
|
+
return "1.5rem";
|
|
935
|
+
case "full":
|
|
936
|
+
return "9999px";
|
|
937
|
+
default:
|
|
938
|
+
return null;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
function borderSideProperty(side) {
|
|
942
|
+
switch (side) {
|
|
943
|
+
case "t":
|
|
944
|
+
return "border-top";
|
|
945
|
+
case "r":
|
|
946
|
+
return "border-right";
|
|
947
|
+
case "b":
|
|
948
|
+
return "border-bottom";
|
|
949
|
+
case "l":
|
|
950
|
+
return "border-left";
|
|
951
|
+
default:
|
|
952
|
+
return null;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
function borderValue(theme, parsed) {
|
|
956
|
+
const value = parsed.value;
|
|
957
|
+
if (value === null) return null;
|
|
958
|
+
if (!parsed.isArbitrary) {
|
|
959
|
+
const side = borderSideProperty(value);
|
|
960
|
+
if (side !== null) {
|
|
961
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
962
|
+
}
|
|
963
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
964
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
965
|
+
}
|
|
966
|
+
if (parsed.isArbitrary) {
|
|
967
|
+
if (looksLikeLength(value)) return [decl("border-width", value)];
|
|
968
|
+
const color2 = colorValue(theme, parsed);
|
|
969
|
+
return color2 === null ? null : [decl("border-color", color2)];
|
|
970
|
+
}
|
|
971
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
972
|
+
const v = resolveLength(theme, parsed);
|
|
973
|
+
return v === null ? null : [decl("border-width", v)];
|
|
974
|
+
}
|
|
975
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
976
|
+
return [decl("border-style", value)];
|
|
977
|
+
}
|
|
978
|
+
const color = colorValue(theme, parsed);
|
|
979
|
+
return color === null ? null : [decl("border-color", color)];
|
|
980
|
+
}
|
|
981
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
982
|
+
const value = parsed.value;
|
|
983
|
+
if (value === null) return null;
|
|
984
|
+
if (parsed.isArbitrary) {
|
|
985
|
+
if (looksLikeLength(value)) return [decl(`${sideProperty}-width`, value)];
|
|
986
|
+
const color2 = colorValue(theme, parsed);
|
|
987
|
+
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
988
|
+
}
|
|
989
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
990
|
+
const v = resolveLength(theme, parsed);
|
|
991
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
992
|
+
}
|
|
993
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
994
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
995
|
+
}
|
|
996
|
+
const color = colorValue(theme, parsed);
|
|
997
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
998
|
+
}
|
|
999
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1000
|
+
const value = parsed.value;
|
|
1001
|
+
if (value === null) return null;
|
|
1002
|
+
if (parsed.isArbitrary) {
|
|
1003
|
+
if (looksLikeLength(value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1004
|
+
const color2 = colorValue(theme, parsed);
|
|
1005
|
+
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1006
|
+
}
|
|
1007
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1008
|
+
const v = resolveLength(theme, parsed);
|
|
1009
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1010
|
+
}
|
|
1011
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1012
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1013
|
+
}
|
|
1014
|
+
const color = colorValue(theme, parsed);
|
|
1015
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1016
|
+
}
|
|
1017
|
+
function radiusProperties(side) {
|
|
1018
|
+
switch (side) {
|
|
1019
|
+
case "t":
|
|
1020
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
1021
|
+
case "r":
|
|
1022
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
1023
|
+
case "b":
|
|
1024
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
1025
|
+
case "l":
|
|
1026
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
1027
|
+
case "tl":
|
|
1028
|
+
return ["border-top-left-radius"];
|
|
1029
|
+
case "tr":
|
|
1030
|
+
return ["border-top-right-radius"];
|
|
1031
|
+
case "br":
|
|
1032
|
+
return ["border-bottom-right-radius"];
|
|
1033
|
+
case "bl":
|
|
1034
|
+
return ["border-bottom-left-radius"];
|
|
1035
|
+
default:
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function resolveRadiusValue(theme, parsed) {
|
|
1040
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1041
|
+
const size = radiusSize(parsed.value);
|
|
1042
|
+
if (size !== null) return size;
|
|
1043
|
+
}
|
|
1044
|
+
return resolveLength(theme, parsed);
|
|
1045
|
+
}
|
|
1046
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
1047
|
+
const properties = radiusProperties(side);
|
|
1048
|
+
if (properties === null) return null;
|
|
1049
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
1050
|
+
if (value === null) return null;
|
|
1051
|
+
return properties.map((p) => decl(p, value));
|
|
1052
|
+
}
|
|
1053
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1054
|
+
function outlineWidthValue(key) {
|
|
1055
|
+
switch (key) {
|
|
1056
|
+
case "0":
|
|
1057
|
+
return "0px";
|
|
1058
|
+
case "1":
|
|
1059
|
+
return "1px";
|
|
1060
|
+
case "2":
|
|
1061
|
+
return "2px";
|
|
1062
|
+
case "4":
|
|
1063
|
+
return "4px";
|
|
1064
|
+
case "8":
|
|
1065
|
+
return "8px";
|
|
1066
|
+
default:
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function outlineValue(theme, parsed) {
|
|
1071
|
+
const value = parsed.value;
|
|
1072
|
+
if (value === null) return null;
|
|
1073
|
+
if (parsed.isArbitrary) {
|
|
1074
|
+
if (looksLikeLength(value)) return [decl("outline-width", value)];
|
|
1075
|
+
const color2 = colorValue(theme, parsed);
|
|
1076
|
+
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1077
|
+
}
|
|
1078
|
+
const w = outlineWidthValue(value);
|
|
1079
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
1080
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1081
|
+
const color = colorValue(theme, parsed);
|
|
1082
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1083
|
+
}
|
|
1084
|
+
function outlineOffsetValue(parsed) {
|
|
1085
|
+
const value = parsed.value;
|
|
1086
|
+
if (value === null) return null;
|
|
1087
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
1088
|
+
const w = outlineWidthValue(value);
|
|
1089
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
1090
|
+
}
|
|
1091
|
+
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))";
|
|
1092
|
+
function ringWidth(key) {
|
|
1093
|
+
switch (key) {
|
|
1094
|
+
case "0":
|
|
1095
|
+
return "0px";
|
|
1096
|
+
case "1":
|
|
1097
|
+
return "1px";
|
|
1098
|
+
case "2":
|
|
1099
|
+
return "2px";
|
|
1100
|
+
case "4":
|
|
1101
|
+
return "4px";
|
|
1102
|
+
case "8":
|
|
1103
|
+
return "8px";
|
|
1104
|
+
default:
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
function ringValue(theme, parsed) {
|
|
1109
|
+
const value = parsed.value;
|
|
1110
|
+
if (value === null) return null;
|
|
1111
|
+
if (value === "inset") {
|
|
1112
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1113
|
+
}
|
|
1114
|
+
if (!parsed.isArbitrary) {
|
|
1115
|
+
const w = ringWidth(value);
|
|
1116
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1117
|
+
}
|
|
1118
|
+
const color = colorValue(theme, parsed);
|
|
1119
|
+
if (color === null) return null;
|
|
1120
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1121
|
+
}
|
|
1122
|
+
function ringOffsetValue(theme, parsed) {
|
|
1123
|
+
const value = parsed.value;
|
|
1124
|
+
if (value === null) return null;
|
|
1125
|
+
if (!parsed.isArbitrary) {
|
|
1126
|
+
const w = ringWidth(value);
|
|
1127
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1128
|
+
}
|
|
1129
|
+
const color = colorValue(theme, parsed);
|
|
1130
|
+
if (color === null) return null;
|
|
1131
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1132
|
+
}
|
|
1133
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1134
|
+
function resolve3(parsed, theme) {
|
|
1135
|
+
switch (parsed.utility) {
|
|
1136
|
+
case "border":
|
|
1137
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1138
|
+
return borderValue(theme, parsed);
|
|
1139
|
+
case "border-t":
|
|
1140
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1141
|
+
case "border-r":
|
|
1142
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1143
|
+
case "border-b":
|
|
1144
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1145
|
+
case "border-l":
|
|
1146
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1147
|
+
case "border-x":
|
|
1148
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1149
|
+
case "border-y":
|
|
1150
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1151
|
+
case "rounded": {
|
|
1152
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1153
|
+
const value = parsed.value;
|
|
1154
|
+
if (!parsed.isArbitrary) {
|
|
1155
|
+
const size = radiusSize(value);
|
|
1156
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1157
|
+
}
|
|
1158
|
+
const v = resolveLength(theme, parsed);
|
|
1159
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1160
|
+
}
|
|
1161
|
+
case "ring":
|
|
1162
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1163
|
+
return ringValue(theme, parsed);
|
|
1164
|
+
case "ring-offset":
|
|
1165
|
+
return ringOffsetValue(theme, parsed);
|
|
1166
|
+
case "outline":
|
|
1167
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1168
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1169
|
+
return outlineValue(theme, parsed);
|
|
1170
|
+
case "outline-offset":
|
|
1171
|
+
return outlineOffsetValue(parsed);
|
|
1172
|
+
default:
|
|
1173
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1174
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1175
|
+
}
|
|
1176
|
+
return null;
|
|
1177
|
+
}
|
|
413
1178
|
}
|
|
414
1179
|
|
|
415
|
-
// src/
|
|
416
|
-
|
|
1180
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1181
|
+
function textSize(key) {
|
|
1182
|
+
switch (key) {
|
|
1183
|
+
case "xs":
|
|
1184
|
+
return "0.75rem";
|
|
1185
|
+
case "sm":
|
|
1186
|
+
return "0.875rem";
|
|
1187
|
+
case "base":
|
|
1188
|
+
return "1rem";
|
|
1189
|
+
case "lg":
|
|
1190
|
+
return "1.125rem";
|
|
1191
|
+
case "xl":
|
|
1192
|
+
return "1.25rem";
|
|
1193
|
+
case "2xl":
|
|
1194
|
+
return "1.5rem";
|
|
1195
|
+
case "3xl":
|
|
1196
|
+
return "1.875rem";
|
|
1197
|
+
case "4xl":
|
|
1198
|
+
return "2.25rem";
|
|
1199
|
+
case "5xl":
|
|
1200
|
+
return "3rem";
|
|
1201
|
+
case "6xl":
|
|
1202
|
+
return "3.75rem";
|
|
1203
|
+
case "7xl":
|
|
1204
|
+
return "4.5rem";
|
|
1205
|
+
case "8xl":
|
|
1206
|
+
return "6rem";
|
|
1207
|
+
case "9xl":
|
|
1208
|
+
return "8rem";
|
|
1209
|
+
default:
|
|
1210
|
+
return null;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
function lineHeightSize(key) {
|
|
1214
|
+
switch (key) {
|
|
1215
|
+
case "3":
|
|
1216
|
+
return "0.75rem";
|
|
1217
|
+
case "4":
|
|
1218
|
+
return "1rem";
|
|
1219
|
+
case "5":
|
|
1220
|
+
return "1.25rem";
|
|
1221
|
+
case "6":
|
|
1222
|
+
return "1.5rem";
|
|
1223
|
+
case "7":
|
|
1224
|
+
return "1.75rem";
|
|
1225
|
+
case "8":
|
|
1226
|
+
return "2rem";
|
|
1227
|
+
case "9":
|
|
1228
|
+
return "2.25rem";
|
|
1229
|
+
case "10":
|
|
1230
|
+
return "2.5rem";
|
|
1231
|
+
default:
|
|
1232
|
+
return null;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
function textAlign(key) {
|
|
1236
|
+
switch (key) {
|
|
1237
|
+
case "left":
|
|
1238
|
+
return "left";
|
|
1239
|
+
case "center":
|
|
1240
|
+
return "center";
|
|
1241
|
+
case "right":
|
|
1242
|
+
return "right";
|
|
1243
|
+
case "justify":
|
|
1244
|
+
return "justify";
|
|
1245
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1246
|
+
// as layout.rs's start/end inset properties.
|
|
1247
|
+
case "start":
|
|
1248
|
+
return "start";
|
|
1249
|
+
case "end":
|
|
1250
|
+
return "end";
|
|
1251
|
+
default:
|
|
1252
|
+
return null;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
function fontWeight(key) {
|
|
1256
|
+
switch (key) {
|
|
1257
|
+
case "thin":
|
|
1258
|
+
return "100";
|
|
1259
|
+
case "extralight":
|
|
1260
|
+
return "200";
|
|
1261
|
+
case "light":
|
|
1262
|
+
return "300";
|
|
1263
|
+
case "normal":
|
|
1264
|
+
return "400";
|
|
1265
|
+
case "medium":
|
|
1266
|
+
return "500";
|
|
1267
|
+
case "semibold":
|
|
1268
|
+
return "600";
|
|
1269
|
+
case "bold":
|
|
1270
|
+
return "700";
|
|
1271
|
+
case "extrabold":
|
|
1272
|
+
return "800";
|
|
1273
|
+
case "black":
|
|
1274
|
+
return "900";
|
|
1275
|
+
default:
|
|
1276
|
+
return null;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
function fontFamilyValue(theme, key) {
|
|
1280
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
1281
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
1282
|
+
switch (key) {
|
|
1283
|
+
case "sans":
|
|
1284
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
1285
|
+
case "serif":
|
|
1286
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
1287
|
+
case "mono":
|
|
1288
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1289
|
+
default:
|
|
1290
|
+
return null;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
417
1293
|
|
|
418
|
-
// src/
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
1294
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1295
|
+
function nativeShadowValue(key) {
|
|
1296
|
+
switch (key) {
|
|
1297
|
+
case "sm":
|
|
1298
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1299
|
+
case "DEFAULT":
|
|
1300
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1301
|
+
case "md":
|
|
1302
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1303
|
+
case "lg":
|
|
1304
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1305
|
+
case "xl":
|
|
1306
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1307
|
+
case "2xl":
|
|
1308
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1309
|
+
case "none":
|
|
1310
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1311
|
+
default:
|
|
1312
|
+
return null;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
function nativeShadowDeclarations(parsed) {
|
|
1316
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1317
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1318
|
+
const s = nativeShadowValue(key);
|
|
1319
|
+
if (s === null) return null;
|
|
1320
|
+
return [
|
|
1321
|
+
decl("shadow-color", "#000000"),
|
|
1322
|
+
decl("shadow-offset-x", "0"),
|
|
1323
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1324
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1325
|
+
decl("shadow-radius", String(s.radius)),
|
|
1326
|
+
decl("elevation", String(s.elevation))
|
|
1327
|
+
];
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
// src/jsEngine/resolvers/transform.ts
|
|
1331
|
+
function scaleFactor(parsed) {
|
|
1332
|
+
if (parsed.value === null) return null;
|
|
1333
|
+
const n = Number(parsed.value);
|
|
1334
|
+
if (!Number.isFinite(n)) return null;
|
|
1335
|
+
return parsed.isArbitrary ? n : n / 100;
|
|
1336
|
+
}
|
|
1337
|
+
function angle(parsed) {
|
|
1338
|
+
if (parsed.value === null) return null;
|
|
1339
|
+
if (parsed.isArbitrary) return parsed.value;
|
|
1340
|
+
const n = Number(parsed.value);
|
|
1341
|
+
if (!Number.isFinite(n)) return null;
|
|
1342
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
1343
|
+
}
|
|
1344
|
+
function resolveNative(parsed, theme) {
|
|
1345
|
+
switch (parsed.utility) {
|
|
1346
|
+
case "transform-none":
|
|
1347
|
+
return [decl("transform-op-none", "1")];
|
|
1348
|
+
case "backface-visible":
|
|
1349
|
+
return [decl("backface-visibility", "visible")];
|
|
1350
|
+
case "backface-hidden":
|
|
1351
|
+
return [decl("backface-visibility", "hidden")];
|
|
1352
|
+
case "translate-x": {
|
|
1353
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1354
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
1355
|
+
}
|
|
1356
|
+
case "translate-y": {
|
|
1357
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1358
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
1359
|
+
}
|
|
1360
|
+
case "scale": {
|
|
1361
|
+
const n = scaleFactor(parsed);
|
|
1362
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
1363
|
+
}
|
|
1364
|
+
case "scale-x": {
|
|
1365
|
+
const n = scaleFactor(parsed);
|
|
1366
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
1367
|
+
}
|
|
1368
|
+
case "scale-y": {
|
|
1369
|
+
const n = scaleFactor(parsed);
|
|
1370
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
1371
|
+
}
|
|
1372
|
+
case "rotate": {
|
|
1373
|
+
const deg = angle(parsed);
|
|
1374
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
1375
|
+
}
|
|
1376
|
+
case "rotate-x": {
|
|
1377
|
+
const deg = angle(parsed);
|
|
1378
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
1379
|
+
}
|
|
1380
|
+
case "rotate-y": {
|
|
1381
|
+
const deg = angle(parsed);
|
|
1382
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
1383
|
+
}
|
|
1384
|
+
case "rotate-z": {
|
|
1385
|
+
const deg = angle(parsed);
|
|
1386
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
1387
|
+
}
|
|
1388
|
+
case "skew-x": {
|
|
1389
|
+
const deg = angle(parsed);
|
|
1390
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
1391
|
+
}
|
|
1392
|
+
case "skew-y": {
|
|
1393
|
+
const deg = angle(parsed);
|
|
1394
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
1395
|
+
}
|
|
1396
|
+
default:
|
|
1397
|
+
return null;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1402
|
+
function firstFontName(stack) {
|
|
1403
|
+
const first = stack.split(",")[0] ?? stack;
|
|
1404
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
1405
|
+
}
|
|
1406
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1407
|
+
switch (parsed.utility) {
|
|
1408
|
+
case "font": {
|
|
1409
|
+
if (parsed.value === null) return null;
|
|
1410
|
+
if (parsed.isArbitrary) {
|
|
1411
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
1412
|
+
}
|
|
1413
|
+
const w = fontWeight(parsed.value);
|
|
1414
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
1415
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
1416
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1417
|
+
}
|
|
1418
|
+
case "uppercase":
|
|
1419
|
+
return [decl("text-transform", "uppercase")];
|
|
1420
|
+
case "lowercase":
|
|
1421
|
+
return [decl("text-transform", "lowercase")];
|
|
1422
|
+
case "capitalize":
|
|
1423
|
+
return [decl("text-transform", "capitalize")];
|
|
1424
|
+
case "underline":
|
|
1425
|
+
return [decl("text-decoration-line", "underline")];
|
|
1426
|
+
case "line-through":
|
|
1427
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1428
|
+
case "no-underline":
|
|
1429
|
+
return [decl("text-decoration-line", "none")];
|
|
1430
|
+
case "italic":
|
|
1431
|
+
return [decl("font-style", "italic")];
|
|
1432
|
+
case "not-italic":
|
|
1433
|
+
return [decl("font-style", "normal")];
|
|
1434
|
+
default:
|
|
1435
|
+
return null;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1439
|
+
const value = parsed.value;
|
|
1440
|
+
if (value === null) return null;
|
|
1441
|
+
if (parsed.utility === "leading") {
|
|
1442
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1443
|
+
const v = lineHeightSize(value);
|
|
1444
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1445
|
+
}
|
|
1446
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1447
|
+
return [decl("letter-spacing", value)];
|
|
1448
|
+
}
|
|
1449
|
+
return null;
|
|
1450
|
+
}
|
|
1451
|
+
function nativeHexColor(parsed, theme) {
|
|
1452
|
+
return colorValue(theme, parsed);
|
|
1453
|
+
}
|
|
1454
|
+
function resolveTextNative(parsed, theme) {
|
|
1455
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1456
|
+
const size = textSize(parsed.value);
|
|
1457
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1458
|
+
const align = textAlign(parsed.value);
|
|
1459
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1460
|
+
}
|
|
1461
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1462
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1463
|
+
}
|
|
1464
|
+
function resolveColorNative(parsed, theme) {
|
|
1465
|
+
switch (parsed.utility) {
|
|
1466
|
+
case "bg": {
|
|
1467
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1468
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1469
|
+
}
|
|
1470
|
+
case "text":
|
|
1471
|
+
return resolveTextNative(parsed, theme);
|
|
1472
|
+
default:
|
|
1473
|
+
return null;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
function resolveOpacityNative(parsed) {
|
|
1477
|
+
if (parsed.utility !== "opacity") return null;
|
|
1478
|
+
const v = resolvePercent(parsed);
|
|
1479
|
+
return v === null ? null : [decl("opacity", v)];
|
|
1480
|
+
}
|
|
1481
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1482
|
+
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);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
// src/jsEngine/calc.ts
|
|
1486
|
+
function reduceConstantMath(raw) {
|
|
1487
|
+
const trimmed = raw.trim();
|
|
1488
|
+
const calc = stripCall(trimmed, "calc");
|
|
1489
|
+
if (calc !== null) {
|
|
1490
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
1491
|
+
}
|
|
1492
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
1493
|
+
if (clamp !== null) {
|
|
1494
|
+
const args = splitTopLevelCommas(clamp);
|
|
1495
|
+
if (args.length !== 3) return null;
|
|
1496
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
1497
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
1498
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
1499
|
+
}
|
|
1500
|
+
const min = stripCall(trimmed, "min");
|
|
1501
|
+
if (min !== null) {
|
|
1502
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1503
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
1504
|
+
}
|
|
1505
|
+
const max = stripCall(trimmed, "max");
|
|
1506
|
+
if (max !== null) {
|
|
1507
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1508
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
1509
|
+
}
|
|
1510
|
+
return null;
|
|
1511
|
+
}
|
|
1512
|
+
function stripCall(raw, name) {
|
|
1513
|
+
if (!raw.startsWith(name)) return null;
|
|
1514
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
1515
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
1516
|
+
return afterName.slice(1, -1);
|
|
1517
|
+
}
|
|
1518
|
+
function splitTopLevelCommas(s) {
|
|
1519
|
+
const parts = [];
|
|
1520
|
+
let depth = 0;
|
|
1521
|
+
let start = 0;
|
|
1522
|
+
for (let i = 0; i < s.length; i++) {
|
|
1523
|
+
const ch = s[i];
|
|
1524
|
+
if (ch === "(") depth++;
|
|
1525
|
+
else if (ch === ")") depth--;
|
|
1526
|
+
else if (ch === "," && depth === 0) {
|
|
1527
|
+
parts.push(s.slice(start, i).trim());
|
|
1528
|
+
start = i + 1;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
parts.push(s.slice(start).trim());
|
|
1532
|
+
return parts;
|
|
1533
|
+
}
|
|
1534
|
+
var Evaluator = class {
|
|
1535
|
+
constructor(s) {
|
|
1536
|
+
this.pos = 0;
|
|
1537
|
+
this.s = s;
|
|
1538
|
+
}
|
|
1539
|
+
parseExprToEnd() {
|
|
1540
|
+
const value = this.expr();
|
|
1541
|
+
if (value === null) return null;
|
|
1542
|
+
this.skipWs();
|
|
1543
|
+
return this.pos === this.s.length ? value : null;
|
|
1544
|
+
}
|
|
1545
|
+
skipWs() {
|
|
1546
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
1547
|
+
}
|
|
1548
|
+
peek() {
|
|
1549
|
+
this.skipWs();
|
|
1550
|
+
return this.s[this.pos];
|
|
1551
|
+
}
|
|
1552
|
+
expr() {
|
|
1553
|
+
let value = this.term();
|
|
1554
|
+
if (value === null) return null;
|
|
1555
|
+
for (; ; ) {
|
|
1556
|
+
const ch = this.peek();
|
|
1557
|
+
if (ch === "+") {
|
|
1558
|
+
this.pos++;
|
|
1559
|
+
const rhs = this.term();
|
|
1560
|
+
if (rhs === null) return null;
|
|
1561
|
+
value += rhs;
|
|
1562
|
+
} else if (ch === "-") {
|
|
1563
|
+
this.pos++;
|
|
1564
|
+
const rhs = this.term();
|
|
1565
|
+
if (rhs === null) return null;
|
|
1566
|
+
value -= rhs;
|
|
1567
|
+
} else {
|
|
1568
|
+
return value;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
term() {
|
|
1573
|
+
let value = this.factor();
|
|
1574
|
+
if (value === null) return null;
|
|
1575
|
+
for (; ; ) {
|
|
1576
|
+
const ch = this.peek();
|
|
1577
|
+
if (ch === "*") {
|
|
1578
|
+
this.pos++;
|
|
1579
|
+
const rhs = this.factor();
|
|
1580
|
+
if (rhs === null) return null;
|
|
1581
|
+
value *= rhs;
|
|
1582
|
+
} else if (ch === "/") {
|
|
1583
|
+
this.pos++;
|
|
1584
|
+
const divisor = this.factor();
|
|
1585
|
+
if (divisor === null || divisor === 0) return null;
|
|
1586
|
+
value /= divisor;
|
|
1587
|
+
} else {
|
|
1588
|
+
return value;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
factor() {
|
|
1593
|
+
const ch = this.peek();
|
|
1594
|
+
if (ch === void 0) return null;
|
|
1595
|
+
if (ch === "(") {
|
|
1596
|
+
this.pos++;
|
|
1597
|
+
const value = this.expr();
|
|
1598
|
+
if (value === null || this.peek() !== ")") return null;
|
|
1599
|
+
this.pos++;
|
|
1600
|
+
return value;
|
|
1601
|
+
}
|
|
1602
|
+
if (ch === "-") {
|
|
1603
|
+
this.pos++;
|
|
1604
|
+
const value = this.factor();
|
|
1605
|
+
return value === null ? null : -value;
|
|
1606
|
+
}
|
|
1607
|
+
return this.numberWithUnit();
|
|
1608
|
+
}
|
|
1609
|
+
numberWithUnit() {
|
|
1610
|
+
this.skipWs();
|
|
1611
|
+
const start = this.pos;
|
|
1612
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
1613
|
+
if (this.pos === start) return null;
|
|
1614
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
1615
|
+
if (!Number.isFinite(n)) return null;
|
|
1616
|
+
const unitStart = this.pos;
|
|
1617
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
1618
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
1619
|
+
switch (unit) {
|
|
1620
|
+
case "":
|
|
1621
|
+
return n;
|
|
1622
|
+
case "px":
|
|
1623
|
+
return n;
|
|
1624
|
+
case "rem":
|
|
1625
|
+
return n * 16;
|
|
1626
|
+
default:
|
|
1627
|
+
return null;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
// src/jsEngine/resolveStyle.ts
|
|
1633
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1634
|
+
var STATE_HOLD_MARKER = "_kbon";
|
|
1635
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1636
|
+
if (modifier === STATE_HOLD_MARKER) return true;
|
|
1637
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1638
|
+
if (modifier === "active") return pressed;
|
|
1639
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1640
|
+
const minWidth = theme.screens[modifier];
|
|
1641
|
+
if (minWidth === void 0) return null;
|
|
1642
|
+
return width >= minWidth;
|
|
1643
|
+
}
|
|
1644
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
1645
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1646
|
+
return px === null ? null : width >= px;
|
|
1647
|
+
}
|
|
1648
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
1649
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1650
|
+
return px === null ? null : width <= px;
|
|
1651
|
+
}
|
|
1652
|
+
return null;
|
|
1653
|
+
}
|
|
1654
|
+
function kebabToCamel(s) {
|
|
1655
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1656
|
+
}
|
|
1657
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1658
|
+
"padding",
|
|
1659
|
+
"padding-top",
|
|
1660
|
+
"padding-right",
|
|
1661
|
+
"padding-bottom",
|
|
1662
|
+
"padding-left",
|
|
1663
|
+
"margin",
|
|
1664
|
+
"margin-top",
|
|
1665
|
+
"margin-right",
|
|
1666
|
+
"margin-bottom",
|
|
1667
|
+
"margin-left",
|
|
1668
|
+
"gap",
|
|
1669
|
+
"column-gap",
|
|
1670
|
+
"row-gap",
|
|
1671
|
+
"width",
|
|
1672
|
+
"height",
|
|
1673
|
+
"min-width",
|
|
1674
|
+
"max-width",
|
|
1675
|
+
"min-height",
|
|
1676
|
+
"max-height",
|
|
1677
|
+
"top",
|
|
1678
|
+
"right",
|
|
1679
|
+
"bottom",
|
|
1680
|
+
"left",
|
|
1681
|
+
"inset",
|
|
1682
|
+
"border-radius",
|
|
1683
|
+
"border-width",
|
|
1684
|
+
"font-size",
|
|
1685
|
+
"z-index",
|
|
1686
|
+
"line-height",
|
|
1687
|
+
"letter-spacing",
|
|
1688
|
+
"flex",
|
|
1689
|
+
"flex-grow",
|
|
1690
|
+
"flex-shrink",
|
|
1691
|
+
"order",
|
|
1692
|
+
"flex-basis",
|
|
1693
|
+
"shadow-opacity",
|
|
1694
|
+
"shadow-radius",
|
|
1695
|
+
"elevation",
|
|
1696
|
+
"opacity",
|
|
1697
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1698
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1699
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1700
|
+
// "border-width"/"border-radius" forms above.
|
|
1701
|
+
"border-top-width",
|
|
1702
|
+
"border-right-width",
|
|
1703
|
+
"border-bottom-width",
|
|
1704
|
+
"border-left-width",
|
|
1705
|
+
"border-top-left-radius",
|
|
1706
|
+
"border-top-right-radius",
|
|
1707
|
+
"border-bottom-right-radius",
|
|
1708
|
+
"border-bottom-left-radius",
|
|
1709
|
+
"outline-width",
|
|
1710
|
+
"outline-offset",
|
|
1711
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
1712
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
1713
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
1714
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
1715
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
1716
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
1717
|
+
// get collected into the final array.
|
|
1718
|
+
"transform-op-translate-x",
|
|
1719
|
+
"transform-op-translate-y",
|
|
1720
|
+
"transform-op-scale-x",
|
|
1721
|
+
"transform-op-scale-y"
|
|
1722
|
+
]);
|
|
1723
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
1724
|
+
["transform-op-translate-x", "translateX"],
|
|
1725
|
+
["transform-op-translate-y", "translateY"],
|
|
1726
|
+
["transform-op-rotate", "rotate"],
|
|
1727
|
+
["transform-op-rotate-x", "rotateX"],
|
|
1728
|
+
["transform-op-rotate-y", "rotateY"],
|
|
1729
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
1730
|
+
["transform-op-skew-x", "skewX"],
|
|
1731
|
+
["transform-op-skew-y", "skewY"],
|
|
1732
|
+
["transform-op-scale-x", "scaleX"],
|
|
1733
|
+
["transform-op-scale-y", "scaleY"]
|
|
1734
|
+
]);
|
|
1735
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
1736
|
+
function isPlainPercentage(value) {
|
|
1737
|
+
if (!value.endsWith("%")) return false;
|
|
1738
|
+
let digits = value.slice(0, -1);
|
|
1739
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
1740
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
1741
|
+
}
|
|
1742
|
+
function sanitizeForWarning(value) {
|
|
1743
|
+
const MAX_CHARS = 60;
|
|
1744
|
+
const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
|
|
1745
|
+
if (escaped.length <= MAX_CHARS) return escaped;
|
|
1746
|
+
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
1747
|
+
}
|
|
1748
|
+
function rnStyleValue(property, value) {
|
|
1749
|
+
if (property === "aspect-ratio") {
|
|
1750
|
+
if (value.trim() === "auto") return { value: null, warning: null };
|
|
1751
|
+
const parts = value.split("/").map((s) => s.trim());
|
|
1752
|
+
let n = null;
|
|
1753
|
+
if (parts.length === 1) {
|
|
1754
|
+
const a = Number(parts[0]);
|
|
1755
|
+
n = Number.isFinite(a) ? a : null;
|
|
1756
|
+
} else if (parts.length === 2) {
|
|
1757
|
+
const a = Number(parts[0]);
|
|
1758
|
+
const b = Number(parts[1]);
|
|
1759
|
+
n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
|
|
1760
|
+
}
|
|
1761
|
+
return { value: n, warning: null };
|
|
1762
|
+
}
|
|
1763
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1764
|
+
return { value, warning: null };
|
|
1765
|
+
}
|
|
1766
|
+
if (value === "auto") {
|
|
1767
|
+
return { value: "auto", warning: null };
|
|
1768
|
+
}
|
|
1769
|
+
let px = null;
|
|
1770
|
+
if (value.endsWith("px")) {
|
|
1771
|
+
const n = Number(value.slice(0, -2));
|
|
1772
|
+
px = Number.isFinite(n) ? n : null;
|
|
1773
|
+
} else if (value.endsWith("rem")) {
|
|
1774
|
+
const n = Number(value.slice(0, -3));
|
|
1775
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1776
|
+
} else {
|
|
1777
|
+
const n = Number(value);
|
|
1778
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1779
|
+
}
|
|
1780
|
+
if (px !== null) return { value: px, warning: null };
|
|
1781
|
+
if (isPlainPercentage(value)) {
|
|
1782
|
+
return { value, warning: null };
|
|
1783
|
+
}
|
|
1784
|
+
const reduced = reduceConstantMath(value);
|
|
1785
|
+
if (reduced !== null) {
|
|
1786
|
+
return { value: reduced, warning: null };
|
|
1787
|
+
}
|
|
1788
|
+
const sanitizedValue = sanitizeForWarning(value);
|
|
1789
|
+
const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
1790
|
+
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).
|
|
1791
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
1792
|
+
return { value: null, warning };
|
|
1793
|
+
}
|
|
1794
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1795
|
+
const style = {};
|
|
1796
|
+
const warnings = [];
|
|
1797
|
+
let shadowOffset = null;
|
|
1798
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
1799
|
+
const keySpecificity = /* @__PURE__ */ new Map();
|
|
1800
|
+
const transformSpecificity = /* @__PURE__ */ new Map();
|
|
1801
|
+
for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
|
|
1802
|
+
const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
|
|
1803
|
+
const parsed = parseClass(token);
|
|
1804
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1805
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
426
1806
|
);
|
|
1807
|
+
if (!allModifiersHold) continue;
|
|
1808
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1809
|
+
if (decls === null) continue;
|
|
1810
|
+
const spec = parsed.modifiers.length;
|
|
1811
|
+
for (const d of decls) {
|
|
1812
|
+
if (d.property.startsWith("__")) {
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1816
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1817
|
+
const n = Number(d.value);
|
|
1818
|
+
if (!Number.isFinite(n)) continue;
|
|
1819
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1820
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1821
|
+
keySpecificity.set("shadowOffset", spec);
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
if (d.property === "transform-op-none") {
|
|
1825
|
+
transformOps.clear();
|
|
1826
|
+
transformSpecificity.clear();
|
|
1827
|
+
continue;
|
|
1828
|
+
}
|
|
1829
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
1830
|
+
if (opKey !== void 0) {
|
|
1831
|
+
if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
|
|
1832
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
1833
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
1834
|
+
if (value2 !== null) {
|
|
1835
|
+
transformOps.set(opKey, value2);
|
|
1836
|
+
transformSpecificity.set(opKey, spec);
|
|
1837
|
+
}
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
const key = kebabToCamel(d.property);
|
|
1841
|
+
if (spec < (keySpecificity.get(key) ?? 0)) continue;
|
|
1842
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
1843
|
+
if (warning !== null) warnings.push(warning);
|
|
1844
|
+
if (value !== null) {
|
|
1845
|
+
style[key] = value;
|
|
1846
|
+
keySpecificity.set(key, spec);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
if (shadowOffset !== null) {
|
|
1851
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1852
|
+
}
|
|
1853
|
+
if (transformOps.size > 0) {
|
|
1854
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
1855
|
+
[key]: transformOps.get(key)
|
|
1856
|
+
}));
|
|
1857
|
+
}
|
|
1858
|
+
return { style, warnings };
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
// src/nativeBridge.ts
|
|
1862
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
1863
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
1864
|
+
var cachedForThemeJson = null;
|
|
1865
|
+
function resolveStyle(classString, pressed = false) {
|
|
1866
|
+
const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
|
|
1867
|
+
const width = import_react_native.Dimensions.get("window").width;
|
|
1868
|
+
const themeJson = (0, import_theme.getThemeJson)();
|
|
1869
|
+
if (themeJson !== cachedForThemeJson) {
|
|
1870
|
+
resolveStyleCache.clear();
|
|
1871
|
+
cachedForThemeJson = themeJson;
|
|
1872
|
+
}
|
|
1873
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
1874
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
1875
|
+
if (cached !== void 0) return { ...cached };
|
|
1876
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
1877
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
1878
|
+
resolveStyleCache.set(cacheKey, style);
|
|
1879
|
+
return { ...style };
|
|
1880
|
+
}
|
|
1881
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
1882
|
+
const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
|
|
1883
|
+
if (!KbachModule) {
|
|
1884
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
|
|
1885
|
+
warnIfDev(classString, warnings2);
|
|
1886
|
+
return style2;
|
|
1887
|
+
}
|
|
1888
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
1889
|
+
const style = JSON.parse(json);
|
|
1890
|
+
const warnings = style.__kbachWarnings;
|
|
1891
|
+
if (warnings !== void 0) {
|
|
1892
|
+
delete style.__kbachWarnings;
|
|
1893
|
+
warnIfDev(classString, warnings);
|
|
427
1894
|
}
|
|
428
|
-
return
|
|
1895
|
+
return style;
|
|
1896
|
+
}
|
|
1897
|
+
var WARNED_MESSAGES_MAX = 500;
|
|
1898
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
1899
|
+
var QUOTED_TOKEN_RE = /"([^"]*)"/;
|
|
1900
|
+
function highlightToken(classString, warning) {
|
|
1901
|
+
const match = QUOTED_TOKEN_RE.exec(warning);
|
|
1902
|
+
if (match === null) return classString;
|
|
1903
|
+
const quoted = match[1].replace(/\s+/g, "");
|
|
1904
|
+
if (quoted === "") return classString;
|
|
1905
|
+
const parts = classString.split(/(\s+)/);
|
|
1906
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
1907
|
+
if (idx === -1) return classString;
|
|
1908
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
1909
|
+
return parts.join("");
|
|
1910
|
+
}
|
|
1911
|
+
function warnIfDev(classString, warnings) {
|
|
1912
|
+
if (warnings.length === 0) return;
|
|
1913
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
1914
|
+
for (const warning of warnings) {
|
|
1915
|
+
const message = `${warning}
|
|
1916
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
1917
|
+
if (warnedMessages.has(message)) continue;
|
|
1918
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
1919
|
+
warnedMessages.add(message);
|
|
1920
|
+
console.warn(message);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
// src/config.ts
|
|
1925
|
+
var import_theme2 = require("./theme");
|
|
1926
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1927
|
+
function parseHexRgb(hex) {
|
|
1928
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1929
|
+
if (!m) return null;
|
|
1930
|
+
let h = m[1];
|
|
1931
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1932
|
+
const n = parseInt(h, 16);
|
|
1933
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1934
|
+
}
|
|
1935
|
+
function applyOpacityToHex2(hex, opacityText) {
|
|
1936
|
+
const rgb = parseHexRgb(hex);
|
|
1937
|
+
if (!rgb) return hex;
|
|
1938
|
+
const a = Number(opacityText) / 100;
|
|
1939
|
+
const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
|
|
1940
|
+
return `rgba(${rgb.join(",")},${clamped})`;
|
|
1941
|
+
}
|
|
1942
|
+
function resolveColorEntry(value, lookup) {
|
|
1943
|
+
const slash = value.indexOf("/");
|
|
1944
|
+
const name = slash === -1 ? value : value.slice(0, slash);
|
|
1945
|
+
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
1946
|
+
const base = lookup(name);
|
|
1947
|
+
if (base === void 0) return value;
|
|
1948
|
+
return opacity === void 0 ? base : applyOpacityToHex2(base, opacity);
|
|
1949
|
+
}
|
|
1950
|
+
function resolveColors(extend, existing) {
|
|
1951
|
+
const { dark: darkExtend, ...lightExtend } = extend;
|
|
1952
|
+
const resolvedLight = {};
|
|
1953
|
+
const lookupLight = (name) => {
|
|
1954
|
+
const found = resolvedLight[name] ?? existing[name];
|
|
1955
|
+
return typeof found === "string" ? found : void 0;
|
|
1956
|
+
};
|
|
1957
|
+
for (const [name, value] of Object.entries(lightExtend)) {
|
|
1958
|
+
if (typeof value !== "string") continue;
|
|
1959
|
+
resolvedLight[name] = resolveColorEntry(value, lookupLight);
|
|
1960
|
+
}
|
|
1961
|
+
const result = { ...resolvedLight };
|
|
1962
|
+
if (darkExtend) {
|
|
1963
|
+
const resolvedDark = {};
|
|
1964
|
+
const lookupDark = (name) => {
|
|
1965
|
+
const found = resolvedDark[name] ?? existing[name];
|
|
1966
|
+
return typeof found === "string" ? found : void 0;
|
|
1967
|
+
};
|
|
1968
|
+
for (const [name, value] of Object.entries(darkExtend)) {
|
|
1969
|
+
resolvedDark[name] = resolveColorEntry(value, lookupDark);
|
|
1970
|
+
}
|
|
1971
|
+
for (const [name, darkValue] of Object.entries(resolvedDark)) {
|
|
1972
|
+
const lightValue = resolvedLight[name];
|
|
1973
|
+
if (lightValue === void 0) continue;
|
|
1974
|
+
result[name] = { light: lightValue, dark: darkValue };
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
return result;
|
|
1978
|
+
}
|
|
1979
|
+
function resolveKbachConfig(config) {
|
|
1980
|
+
let theme = { ...import_theme2.defaultTheme, ...config.theme };
|
|
1981
|
+
if (config.extend?.colors) {
|
|
1982
|
+
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
1983
|
+
}
|
|
1984
|
+
if (config.extend?.spacing) {
|
|
1985
|
+
theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
|
|
1986
|
+
}
|
|
1987
|
+
if (config.extend?.screens) {
|
|
1988
|
+
theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
|
|
1989
|
+
}
|
|
1990
|
+
if (config.extend?.fontFamily) {
|
|
1991
|
+
theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
|
|
1992
|
+
}
|
|
1993
|
+
if (config.extend?.container) {
|
|
1994
|
+
theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
|
|
1995
|
+
}
|
|
1996
|
+
if (config.darkMode) {
|
|
1997
|
+
theme = { ...theme, darkMode: config.darkMode };
|
|
1998
|
+
}
|
|
1999
|
+
return theme;
|
|
2000
|
+
}
|
|
2001
|
+
function applyKbachConfig(config) {
|
|
2002
|
+
const theme = resolveKbachConfig(config);
|
|
2003
|
+
(0, import_theme2.setTheme)(theme);
|
|
2004
|
+
(0, import_darkModeStore2.resyncDomWithActiveTheme)();
|
|
2005
|
+
return theme;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
// src/useTheme.ts
|
|
2009
|
+
var import_react = require("react");
|
|
2010
|
+
var import_darkModeStore3 = require("./darkModeStore");
|
|
2011
|
+
function useTheme() {
|
|
2012
|
+
const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalDarkMode);
|
|
2013
|
+
const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalThemeMode);
|
|
2014
|
+
return (0, import_react.useMemo)(
|
|
2015
|
+
() => ({ mode, isDark, setMode: import_darkModeStore3.setGlobalThemeMode, toggle: import_darkModeStore3.toggleGlobalDarkMode }),
|
|
2016
|
+
[mode, isDark]
|
|
2017
|
+
);
|
|
429
2018
|
}
|
|
430
2019
|
|
|
431
2020
|
// src/ThemeProvider.tsx
|
|
2021
|
+
var import_react2 = require("react");
|
|
2022
|
+
var import_darkModeStore4 = require("./darkModeStore");
|
|
432
2023
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2024
|
+
var PERSIST_STORAGE_KEY = "kbach-theme";
|
|
2025
|
+
function isThemeMode(value) {
|
|
2026
|
+
return value === "light" || value === "dark" || value === "system";
|
|
2027
|
+
}
|
|
433
2028
|
var mountedProviderCount = 0;
|
|
434
2029
|
var warnedMultipleProviders = false;
|
|
435
|
-
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
436
|
-
(0,
|
|
2030
|
+
function ThemeProvider({ children, defaultMode = "system", persist = false }) {
|
|
2031
|
+
(0, import_react2.useEffect)(() => {
|
|
437
2032
|
mountedProviderCount++;
|
|
438
2033
|
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
439
2034
|
warnedMultipleProviders = true;
|
|
440
2035
|
console.warn(
|
|
441
|
-
"[
|
|
2036
|
+
"[Kbach] Multiple <ThemeProvider> instances are mounted at once.\nDark mode is one global store \u2014 useTheme() reads it everywhere, not scoped per provider \u2014 so their defaultMode/persist seeds will fight over the same state.\nMount exactly one <ThemeProvider>, as high in the tree as convenient."
|
|
442
2037
|
);
|
|
443
2038
|
}
|
|
444
2039
|
return () => {
|
|
445
2040
|
mountedProviderCount--;
|
|
446
2041
|
};
|
|
447
2042
|
}, []);
|
|
448
|
-
const seeded = (0,
|
|
449
|
-
(0,
|
|
2043
|
+
const seeded = (0, import_react2.useRef)(false);
|
|
2044
|
+
(0, import_react2.useEffect)(() => {
|
|
450
2045
|
if (seeded.current) return;
|
|
451
2046
|
seeded.current = true;
|
|
452
|
-
|
|
2047
|
+
if (!persist) {
|
|
2048
|
+
(0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
let cancelled = false;
|
|
2052
|
+
persist.getItem(PERSIST_STORAGE_KEY).then((stored) => {
|
|
2053
|
+
if (cancelled) return;
|
|
2054
|
+
if (isThemeMode(stored)) (0, import_darkModeStore4.seedDefaultMode)(stored);
|
|
2055
|
+
else (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2056
|
+
}).catch(() => {
|
|
2057
|
+
if (!cancelled) (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2058
|
+
});
|
|
2059
|
+
return () => {
|
|
2060
|
+
cancelled = true;
|
|
2061
|
+
};
|
|
453
2062
|
}, []);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
2063
|
+
(0, import_react2.useEffect)(() => {
|
|
2064
|
+
if (!persist) return;
|
|
2065
|
+
return (0, import_darkModeStore4.subscribeGlobalDarkMode)(() => {
|
|
2066
|
+
persist.setItem(PERSIST_STORAGE_KEY, (0, import_darkModeStore4.getGlobalThemeMode)()).catch(() => {
|
|
2067
|
+
});
|
|
2068
|
+
});
|
|
2069
|
+
}, [persist]);
|
|
2070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
// src/index.ts
|
|
2074
|
+
var import_darkModeStore5 = require("./darkModeStore");
|
|
2075
|
+
|
|
2076
|
+
// src/useColors.ts
|
|
2077
|
+
var import_react3 = require("react");
|
|
2078
|
+
var import_theme3 = require("./theme");
|
|
2079
|
+
function parseHexRgb2(hex) {
|
|
2080
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
2081
|
+
if (!m) return null;
|
|
2082
|
+
let h = m[1];
|
|
2083
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
2084
|
+
const n = parseInt(h, 16);
|
|
2085
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
2086
|
+
}
|
|
2087
|
+
function applyOpacity(color, opacity) {
|
|
2088
|
+
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
2089
|
+
if (color.startsWith("#")) {
|
|
2090
|
+
const rgb = parseHexRgb2(color);
|
|
2091
|
+
return rgb ? `rgba(${rgb.join(",")},${a})` : color;
|
|
2092
|
+
}
|
|
2093
|
+
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
2094
|
+
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
2095
|
+
return color;
|
|
2096
|
+
}
|
|
2097
|
+
function resolveEntry(entry, isDark) {
|
|
2098
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
2099
|
+
}
|
|
2100
|
+
function makeColorsProxy(theme, isDark) {
|
|
2101
|
+
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
2102
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2103
|
+
function resolveNamed(key) {
|
|
2104
|
+
let name = key;
|
|
2105
|
+
let opacity;
|
|
2106
|
+
if (key.includes("/")) {
|
|
2107
|
+
const slash = key.indexOf("/");
|
|
2108
|
+
name = key.slice(0, slash);
|
|
2109
|
+
opacity = Number(key.slice(slash + 1));
|
|
2110
|
+
}
|
|
2111
|
+
const entry = theme.colors[name];
|
|
2112
|
+
if (entry === void 0) return void 0;
|
|
2113
|
+
const value = resolveEntry(entry, isDark);
|
|
2114
|
+
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
2115
|
+
}
|
|
2116
|
+
function makeFamilyProxy(family) {
|
|
2117
|
+
return new Proxy({}, {
|
|
2118
|
+
get(_, prop) {
|
|
2119
|
+
const key = String(prop);
|
|
2120
|
+
if (key === "then") return void 0;
|
|
2121
|
+
return resolveNamed(`${family}-${key}`);
|
|
2122
|
+
}
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
const get = (name) => resolveNamed(name) ?? name;
|
|
2126
|
+
return new Proxy({ alpha, get }, {
|
|
2127
|
+
get(_, prop) {
|
|
2128
|
+
const key = String(prop);
|
|
2129
|
+
if (key === "then") return void 0;
|
|
2130
|
+
if (key === "alpha") return alpha;
|
|
2131
|
+
if (key === "get") return get;
|
|
2132
|
+
const direct = resolveNamed(key);
|
|
2133
|
+
if (direct !== void 0) return direct;
|
|
2134
|
+
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
2135
|
+
return cache.get(key);
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
function useColors() {
|
|
2140
|
+
const { isDark } = useTheme();
|
|
2141
|
+
const theme = (0, import_theme3.getTheme)();
|
|
2142
|
+
return (0, import_react3.useMemo)(() => makeColorsProxy(theme, isDark), [theme, isDark]);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
// src/index.ts
|
|
2146
|
+
var import_dynamicTokens2 = require("./dynamicTokens");
|
|
2147
|
+
|
|
2148
|
+
// src/useDynamicToken.ts
|
|
2149
|
+
var import_react4 = require("react");
|
|
2150
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
2151
|
+
function useDynamicToken(name) {
|
|
2152
|
+
return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
// src/clsx.ts
|
|
2156
|
+
function clsx(...inputs) {
|
|
2157
|
+
let out = "";
|
|
2158
|
+
for (const input of inputs) {
|
|
2159
|
+
const piece = resolveClassValue(input);
|
|
2160
|
+
if (piece) out = out ? `${out} ${piece}` : piece;
|
|
2161
|
+
}
|
|
2162
|
+
return out;
|
|
2163
|
+
}
|
|
2164
|
+
function resolveClassValue(value) {
|
|
2165
|
+
if (!value) return "";
|
|
2166
|
+
const type = typeof value;
|
|
2167
|
+
if (type === "string" || type === "number" || type === "bigint") return String(value);
|
|
2168
|
+
if (Array.isArray(value)) return clsx(...value);
|
|
2169
|
+
if (type === "object") {
|
|
2170
|
+
let out = "";
|
|
2171
|
+
for (const key in value) {
|
|
2172
|
+
if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
|
|
2173
|
+
out = out ? `${out} ${key}` : key;
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
return out;
|
|
2177
|
+
}
|
|
2178
|
+
return "";
|
|
461
2179
|
}
|
|
462
2180
|
// Annotate the CommonJS export names for ESM import in node:
|
|
463
2181
|
0 && (module.exports = {
|
|
464
2182
|
ThemeProvider,
|
|
2183
|
+
applyKbachConfig,
|
|
2184
|
+
clsx,
|
|
465
2185
|
defaultTheme,
|
|
2186
|
+
deleteDynamicToken,
|
|
2187
|
+
getDynamicToken,
|
|
466
2188
|
getGlobalDarkMode,
|
|
467
2189
|
getGlobalThemeMode,
|
|
468
2190
|
getTheme,
|
|
2191
|
+
resolveKbachConfig,
|
|
469
2192
|
resolveStyle,
|
|
2193
|
+
setDynamicToken,
|
|
470
2194
|
setGlobalThemeMode,
|
|
471
2195
|
setTheme,
|
|
2196
|
+
subscribeDynamicTokens,
|
|
472
2197
|
subscribeGlobalDarkMode,
|
|
473
2198
|
toggleGlobalDarkMode,
|
|
474
|
-
|
|
2199
|
+
useColors,
|
|
2200
|
+
useDynamicToken,
|
|
475
2201
|
useTheme
|
|
476
2202
|
});
|