@bitovi/vybit 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/overlay/dist/overlay.js +805 -670
- package/package.json +1 -1
- package/panel/dist/assets/{DesignMode-BAyjCFC8.js → DesignMode-nOHHHxgv.js} +2 -2
- package/panel/dist/assets/index-BYIDlGa3.js +53 -0
- package/panel/dist/assets/index-BqcsQk03.css +1 -0
- package/panel/dist/index.html +4 -4
- package/server/tailwind-v3.ts +476 -146
- package/server/tailwind-v4.ts +228 -115
- package/shared/types.ts +29 -1
- package/panel/dist/assets/index-DVWn5Mcj.js +0 -49
- package/panel/dist/assets/index-_AiRfYt4.css +0 -1
package/server/tailwind-v3.ts
CHANGED
|
@@ -1,158 +1,488 @@
|
|
|
1
1
|
// Tailwind v3 adapter — uses resolveConfig + PostCSS from the target project's tailwindcss v3.
|
|
2
2
|
|
|
3
3
|
import { existsSync, readFileSync } from "fs";
|
|
4
|
-
import { resolve } from "path";
|
|
5
4
|
import { createRequire } from "module";
|
|
6
|
-
import
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
import { pathToFileURL } from "url";
|
|
7
|
+
import type {
|
|
8
|
+
TailwindAdapter,
|
|
9
|
+
TailwindThemeSubset,
|
|
10
|
+
} from "./tailwind-adapter.js";
|
|
7
11
|
|
|
8
12
|
let cached: TailwindThemeSubset | null = null;
|
|
9
13
|
|
|
10
14
|
const defaultTheme: TailwindThemeSubset = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
15
|
+
spacing: {
|
|
16
|
+
"0": "0px",
|
|
17
|
+
px: "1px",
|
|
18
|
+
"0.5": "0.125rem",
|
|
19
|
+
"1": "0.25rem",
|
|
20
|
+
"1.5": "0.375rem",
|
|
21
|
+
"2": "0.5rem",
|
|
22
|
+
"2.5": "0.625rem",
|
|
23
|
+
"3": "0.75rem",
|
|
24
|
+
"3.5": "0.875rem",
|
|
25
|
+
"4": "1rem",
|
|
26
|
+
"5": "1.25rem",
|
|
27
|
+
"6": "1.5rem",
|
|
28
|
+
"7": "1.75rem",
|
|
29
|
+
"8": "2rem",
|
|
30
|
+
"9": "2.25rem",
|
|
31
|
+
"10": "2.5rem",
|
|
32
|
+
"11": "2.75rem",
|
|
33
|
+
"12": "3rem",
|
|
34
|
+
"14": "3.5rem",
|
|
35
|
+
"16": "4rem",
|
|
36
|
+
"20": "5rem",
|
|
37
|
+
"24": "6rem",
|
|
38
|
+
"28": "7rem",
|
|
39
|
+
"32": "8rem",
|
|
40
|
+
"36": "9rem",
|
|
41
|
+
"40": "10rem",
|
|
42
|
+
"44": "11rem",
|
|
43
|
+
"48": "12rem",
|
|
44
|
+
"52": "13rem",
|
|
45
|
+
"56": "14rem",
|
|
46
|
+
"60": "15rem",
|
|
47
|
+
"64": "16rem",
|
|
48
|
+
"72": "18rem",
|
|
49
|
+
"80": "20rem",
|
|
50
|
+
"96": "24rem",
|
|
51
|
+
},
|
|
52
|
+
colors: {
|
|
53
|
+
inherit: "inherit",
|
|
54
|
+
current: "currentColor",
|
|
55
|
+
transparent: "transparent",
|
|
56
|
+
black: "#000",
|
|
57
|
+
white: "#fff",
|
|
58
|
+
slate: {
|
|
59
|
+
"50": "#f8fafc",
|
|
60
|
+
"100": "#f1f5f9",
|
|
61
|
+
"200": "#e2e8f0",
|
|
62
|
+
"300": "#cbd5e1",
|
|
63
|
+
"400": "#94a3b8",
|
|
64
|
+
"500": "#64748b",
|
|
65
|
+
"600": "#475569",
|
|
66
|
+
"700": "#334155",
|
|
67
|
+
"800": "#1e293b",
|
|
68
|
+
"900": "#0f172a",
|
|
69
|
+
"950": "#020617",
|
|
70
|
+
},
|
|
71
|
+
gray: {
|
|
72
|
+
"50": "#f9fafb",
|
|
73
|
+
"100": "#f3f4f6",
|
|
74
|
+
"200": "#e5e7eb",
|
|
75
|
+
"300": "#d1d5db",
|
|
76
|
+
"400": "#9ca3af",
|
|
77
|
+
"500": "#6b7280",
|
|
78
|
+
"600": "#4b5563",
|
|
79
|
+
"700": "#374151",
|
|
80
|
+
"800": "#1f2937",
|
|
81
|
+
"900": "#111827",
|
|
82
|
+
"950": "#030712",
|
|
83
|
+
},
|
|
84
|
+
zinc: {
|
|
85
|
+
"50": "#fafafa",
|
|
86
|
+
"100": "#f4f4f5",
|
|
87
|
+
"200": "#e4e4e7",
|
|
88
|
+
"300": "#d4d4d8",
|
|
89
|
+
"400": "#a1a1aa",
|
|
90
|
+
"500": "#71717a",
|
|
91
|
+
"600": "#52525b",
|
|
92
|
+
"700": "#3f3f46",
|
|
93
|
+
"800": "#27272a",
|
|
94
|
+
"900": "#18181b",
|
|
95
|
+
"950": "#09090b",
|
|
96
|
+
},
|
|
97
|
+
neutral: {
|
|
98
|
+
"50": "#fafafa",
|
|
99
|
+
"100": "#f5f5f5",
|
|
100
|
+
"200": "#e5e5e5",
|
|
101
|
+
"300": "#d4d4d4",
|
|
102
|
+
"400": "#a3a3a3",
|
|
103
|
+
"500": "#737373",
|
|
104
|
+
"600": "#525252",
|
|
105
|
+
"700": "#404040",
|
|
106
|
+
"800": "#262626",
|
|
107
|
+
"900": "#171717",
|
|
108
|
+
"950": "#0a0a0a",
|
|
109
|
+
},
|
|
110
|
+
stone: {
|
|
111
|
+
"50": "#fafaf9",
|
|
112
|
+
"100": "#f5f5f4",
|
|
113
|
+
"200": "#e7e5e4",
|
|
114
|
+
"300": "#d6d3d1",
|
|
115
|
+
"400": "#a8a29e",
|
|
116
|
+
"500": "#78716c",
|
|
117
|
+
"600": "#57534e",
|
|
118
|
+
"700": "#44403c",
|
|
119
|
+
"800": "#292524",
|
|
120
|
+
"900": "#1c1917",
|
|
121
|
+
"950": "#0c0a09",
|
|
122
|
+
},
|
|
123
|
+
red: {
|
|
124
|
+
"50": "#fef2f2",
|
|
125
|
+
"100": "#fee2e2",
|
|
126
|
+
"200": "#fecaca",
|
|
127
|
+
"300": "#fca5a5",
|
|
128
|
+
"400": "#f87171",
|
|
129
|
+
"500": "#ef4444",
|
|
130
|
+
"600": "#dc2626",
|
|
131
|
+
"700": "#b91c1c",
|
|
132
|
+
"800": "#991b1b",
|
|
133
|
+
"900": "#7f1d1d",
|
|
134
|
+
"950": "#450a0a",
|
|
135
|
+
},
|
|
136
|
+
orange: {
|
|
137
|
+
"50": "#fff7ed",
|
|
138
|
+
"100": "#ffedd5",
|
|
139
|
+
"200": "#fed7aa",
|
|
140
|
+
"300": "#fdba74",
|
|
141
|
+
"400": "#fb923c",
|
|
142
|
+
"500": "#f97316",
|
|
143
|
+
"600": "#ea580c",
|
|
144
|
+
"700": "#c2410c",
|
|
145
|
+
"800": "#9a3412",
|
|
146
|
+
"900": "#7c2d12",
|
|
147
|
+
"950": "#431407",
|
|
148
|
+
},
|
|
149
|
+
amber: {
|
|
150
|
+
"50": "#fffbeb",
|
|
151
|
+
"100": "#fef3c7",
|
|
152
|
+
"200": "#fde68a",
|
|
153
|
+
"300": "#fcd34d",
|
|
154
|
+
"400": "#fbbf24",
|
|
155
|
+
"500": "#f59e0b",
|
|
156
|
+
"600": "#d97706",
|
|
157
|
+
"700": "#b45309",
|
|
158
|
+
"800": "#92400e",
|
|
159
|
+
"900": "#78350f",
|
|
160
|
+
"950": "#451a03",
|
|
161
|
+
},
|
|
162
|
+
yellow: {
|
|
163
|
+
"50": "#fefce8",
|
|
164
|
+
"100": "#fef9c3",
|
|
165
|
+
"200": "#fef08a",
|
|
166
|
+
"300": "#fde047",
|
|
167
|
+
"400": "#facc15",
|
|
168
|
+
"500": "#eab308",
|
|
169
|
+
"600": "#ca8a04",
|
|
170
|
+
"700": "#a16207",
|
|
171
|
+
"800": "#854d0e",
|
|
172
|
+
"900": "#713f12",
|
|
173
|
+
"950": "#422006",
|
|
174
|
+
},
|
|
175
|
+
lime: {
|
|
176
|
+
"50": "#f7fee7",
|
|
177
|
+
"100": "#ecfccb",
|
|
178
|
+
"200": "#d9f99d",
|
|
179
|
+
"300": "#bef264",
|
|
180
|
+
"400": "#a3e635",
|
|
181
|
+
"500": "#84cc16",
|
|
182
|
+
"600": "#65a30d",
|
|
183
|
+
"700": "#4d7c0f",
|
|
184
|
+
"800": "#3f6212",
|
|
185
|
+
"900": "#365314",
|
|
186
|
+
"950": "#1a2e05",
|
|
187
|
+
},
|
|
188
|
+
green: {
|
|
189
|
+
"50": "#f0fdf4",
|
|
190
|
+
"100": "#dcfce7",
|
|
191
|
+
"200": "#bbf7d0",
|
|
192
|
+
"300": "#86efac",
|
|
193
|
+
"400": "#4ade80",
|
|
194
|
+
"500": "#22c55e",
|
|
195
|
+
"600": "#16a34a",
|
|
196
|
+
"700": "#15803d",
|
|
197
|
+
"800": "#166534",
|
|
198
|
+
"900": "#14532d",
|
|
199
|
+
"950": "#052e16",
|
|
200
|
+
},
|
|
201
|
+
emerald: {
|
|
202
|
+
"50": "#ecfdf5",
|
|
203
|
+
"100": "#d1fae5",
|
|
204
|
+
"200": "#a7f3d0",
|
|
205
|
+
"300": "#6ee7b7",
|
|
206
|
+
"400": "#34d399",
|
|
207
|
+
"500": "#10b981",
|
|
208
|
+
"600": "#059669",
|
|
209
|
+
"700": "#047857",
|
|
210
|
+
"800": "#065f46",
|
|
211
|
+
"900": "#064e3b",
|
|
212
|
+
"950": "#022c22",
|
|
213
|
+
},
|
|
214
|
+
teal: {
|
|
215
|
+
"50": "#f0fdfa",
|
|
216
|
+
"100": "#ccfbf1",
|
|
217
|
+
"200": "#99f6e4",
|
|
218
|
+
"300": "#5eead4",
|
|
219
|
+
"400": "#2dd4bf",
|
|
220
|
+
"500": "#14b8a6",
|
|
221
|
+
"600": "#0d9488",
|
|
222
|
+
"700": "#0f766e",
|
|
223
|
+
"800": "#115e59",
|
|
224
|
+
"900": "#134e4a",
|
|
225
|
+
"950": "#042f2e",
|
|
226
|
+
},
|
|
227
|
+
cyan: {
|
|
228
|
+
"50": "#ecfeff",
|
|
229
|
+
"100": "#cffafe",
|
|
230
|
+
"200": "#a5f3fc",
|
|
231
|
+
"300": "#67e8f9",
|
|
232
|
+
"400": "#22d3ee",
|
|
233
|
+
"500": "#06b6d4",
|
|
234
|
+
"600": "#0891b2",
|
|
235
|
+
"700": "#0e7490",
|
|
236
|
+
"800": "#155e75",
|
|
237
|
+
"900": "#164e63",
|
|
238
|
+
"950": "#083344",
|
|
239
|
+
},
|
|
240
|
+
sky: {
|
|
241
|
+
"50": "#f0f9ff",
|
|
242
|
+
"100": "#e0f2fe",
|
|
243
|
+
"200": "#bae6fd",
|
|
244
|
+
"300": "#7dd3fc",
|
|
245
|
+
"400": "#38bdf8",
|
|
246
|
+
"500": "#0ea5e9",
|
|
247
|
+
"600": "#0284c7",
|
|
248
|
+
"700": "#0369a1",
|
|
249
|
+
"800": "#075985",
|
|
250
|
+
"900": "#0c4a6e",
|
|
251
|
+
"950": "#082f49",
|
|
252
|
+
},
|
|
253
|
+
blue: {
|
|
254
|
+
"50": "#eff6ff",
|
|
255
|
+
"100": "#dbeafe",
|
|
256
|
+
"200": "#bfdbfe",
|
|
257
|
+
"300": "#93c5fd",
|
|
258
|
+
"400": "#60a5fa",
|
|
259
|
+
"500": "#3b82f6",
|
|
260
|
+
"600": "#2563eb",
|
|
261
|
+
"700": "#1d4ed8",
|
|
262
|
+
"800": "#1e40af",
|
|
263
|
+
"900": "#1e3a8a",
|
|
264
|
+
"950": "#172554",
|
|
265
|
+
},
|
|
266
|
+
indigo: {
|
|
267
|
+
"50": "#eef2ff",
|
|
268
|
+
"100": "#e0e7ff",
|
|
269
|
+
"200": "#c7d2fe",
|
|
270
|
+
"300": "#a5b4fc",
|
|
271
|
+
"400": "#818cf8",
|
|
272
|
+
"500": "#6366f1",
|
|
273
|
+
"600": "#4f46e5",
|
|
274
|
+
"700": "#4338ca",
|
|
275
|
+
"800": "#3730a3",
|
|
276
|
+
"900": "#312e81",
|
|
277
|
+
"950": "#1e1b4b",
|
|
278
|
+
},
|
|
279
|
+
violet: {
|
|
280
|
+
"50": "#f5f3ff",
|
|
281
|
+
"100": "#ede9fe",
|
|
282
|
+
"200": "#ddd6fe",
|
|
283
|
+
"300": "#c4b5fd",
|
|
284
|
+
"400": "#a78bfa",
|
|
285
|
+
"500": "#8b5cf6",
|
|
286
|
+
"600": "#7c3aed",
|
|
287
|
+
"700": "#6d28d9",
|
|
288
|
+
"800": "#5b21b6",
|
|
289
|
+
"900": "#4c1d95",
|
|
290
|
+
"950": "#2e1065",
|
|
291
|
+
},
|
|
292
|
+
purple: {
|
|
293
|
+
"50": "#faf5ff",
|
|
294
|
+
"100": "#f3e8ff",
|
|
295
|
+
"200": "#e9d5ff",
|
|
296
|
+
"300": "#d8b4fe",
|
|
297
|
+
"400": "#c084fc",
|
|
298
|
+
"500": "#a855f7",
|
|
299
|
+
"600": "#9333ea",
|
|
300
|
+
"700": "#7e22ce",
|
|
301
|
+
"800": "#6b21a8",
|
|
302
|
+
"900": "#581c87",
|
|
303
|
+
"950": "#3b0764",
|
|
304
|
+
},
|
|
305
|
+
fuchsia: {
|
|
306
|
+
"50": "#fdf4ff",
|
|
307
|
+
"100": "#fae8ff",
|
|
308
|
+
"200": "#f5d0fe",
|
|
309
|
+
"300": "#f0abfc",
|
|
310
|
+
"400": "#e879f9",
|
|
311
|
+
"500": "#d946ef",
|
|
312
|
+
"600": "#c026d3",
|
|
313
|
+
"700": "#a21caf",
|
|
314
|
+
"800": "#86198f",
|
|
315
|
+
"900": "#701a75",
|
|
316
|
+
"950": "#4a044e",
|
|
317
|
+
},
|
|
318
|
+
pink: {
|
|
319
|
+
"50": "#fdf2f8",
|
|
320
|
+
"100": "#fce7f3",
|
|
321
|
+
"200": "#fbcfe8",
|
|
322
|
+
"300": "#f9a8d4",
|
|
323
|
+
"400": "#f472b6",
|
|
324
|
+
"500": "#ec4899",
|
|
325
|
+
"600": "#db2777",
|
|
326
|
+
"700": "#be185d",
|
|
327
|
+
"800": "#9d174d",
|
|
328
|
+
"900": "#831843",
|
|
329
|
+
"950": "#500724",
|
|
330
|
+
},
|
|
331
|
+
rose: {
|
|
332
|
+
"50": "#fff1f2",
|
|
333
|
+
"100": "#ffe4e6",
|
|
334
|
+
"200": "#fecdd3",
|
|
335
|
+
"300": "#fda4af",
|
|
336
|
+
"400": "#fb7185",
|
|
337
|
+
"500": "#f43f5e",
|
|
338
|
+
"600": "#e11d48",
|
|
339
|
+
"700": "#be123c",
|
|
340
|
+
"800": "#9f1239",
|
|
341
|
+
"900": "#881337",
|
|
342
|
+
"950": "#4c0519",
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
fontSize: {
|
|
346
|
+
xs: ["0.75rem", { lineHeight: "1rem" }],
|
|
347
|
+
sm: ["0.875rem", { lineHeight: "1.25rem" }],
|
|
348
|
+
base: ["1rem", { lineHeight: "1.5rem" }],
|
|
349
|
+
lg: ["1.125rem", { lineHeight: "1.75rem" }],
|
|
350
|
+
xl: ["1.25rem", { lineHeight: "1.75rem" }],
|
|
351
|
+
"2xl": ["1.5rem", { lineHeight: "2rem" }],
|
|
352
|
+
"3xl": ["1.875rem", { lineHeight: "2.25rem" }],
|
|
353
|
+
"4xl": ["2.25rem", { lineHeight: "2.5rem" }],
|
|
354
|
+
"5xl": ["3rem", { lineHeight: "1" }],
|
|
355
|
+
"6xl": ["3.75rem", { lineHeight: "1" }],
|
|
356
|
+
"7xl": ["4.5rem", { lineHeight: "1" }],
|
|
357
|
+
"8xl": ["6rem", { lineHeight: "1" }],
|
|
358
|
+
"9xl": ["8rem", { lineHeight: "1" }],
|
|
359
|
+
},
|
|
360
|
+
fontWeight: {
|
|
361
|
+
thin: "100",
|
|
362
|
+
extralight: "200",
|
|
363
|
+
light: "300",
|
|
364
|
+
normal: "400",
|
|
365
|
+
medium: "500",
|
|
366
|
+
semibold: "600",
|
|
367
|
+
bold: "700",
|
|
368
|
+
extrabold: "800",
|
|
369
|
+
black: "900",
|
|
370
|
+
},
|
|
371
|
+
borderRadius: {
|
|
372
|
+
none: "0px",
|
|
373
|
+
sm: "0.125rem",
|
|
374
|
+
DEFAULT: "0.25rem",
|
|
375
|
+
md: "0.375rem",
|
|
376
|
+
lg: "0.5rem",
|
|
377
|
+
xl: "0.75rem",
|
|
378
|
+
"2xl": "1rem",
|
|
379
|
+
"3xl": "1.5rem",
|
|
380
|
+
full: "9999px",
|
|
381
|
+
},
|
|
71
382
|
};
|
|
72
383
|
|
|
73
384
|
export class TailwindV3Adapter implements TailwindAdapter {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
385
|
+
readonly version = 3 as const;
|
|
386
|
+
|
|
387
|
+
async resolveTailwindConfig(): Promise<TailwindThemeSubset> {
|
|
388
|
+
if (cached) return cached;
|
|
389
|
+
|
|
390
|
+
const cwd = process.cwd();
|
|
391
|
+
const jsPath = resolve(cwd, "tailwind.config.js");
|
|
392
|
+
const tsPath = resolve(cwd, "tailwind.config.ts");
|
|
393
|
+
const cjsPath = resolve(cwd, "tailwind.config.cjs");
|
|
394
|
+
const configPath = existsSync(jsPath)
|
|
395
|
+
? jsPath
|
|
396
|
+
: existsSync(tsPath)
|
|
397
|
+
? tsPath
|
|
398
|
+
: existsSync(cjsPath)
|
|
399
|
+
? cjsPath
|
|
400
|
+
: null;
|
|
401
|
+
|
|
402
|
+
if (configPath) {
|
|
403
|
+
try {
|
|
404
|
+
const req = createRequire(resolve(cwd, "package.json"));
|
|
405
|
+
const resolveConfig = (
|
|
406
|
+
await import(
|
|
407
|
+
pathToFileURL(req.resolve("tailwindcss/resolveConfig")).href
|
|
408
|
+
)
|
|
409
|
+
).default;
|
|
410
|
+
const userConfig = (await import(pathToFileURL(configPath).href))
|
|
411
|
+
.default;
|
|
412
|
+
const full = resolveConfig(userConfig);
|
|
413
|
+
const theme = full.theme ?? {};
|
|
414
|
+
|
|
415
|
+
cached = {
|
|
416
|
+
spacing:
|
|
417
|
+
(theme.spacing as Record<string, string>) ?? defaultTheme.spacing,
|
|
418
|
+
colors:
|
|
419
|
+
(theme.colors as Record<string, unknown>) ?? defaultTheme.colors,
|
|
420
|
+
fontSize:
|
|
421
|
+
(theme.fontSize as Record<string, unknown>) ??
|
|
422
|
+
defaultTheme.fontSize,
|
|
423
|
+
fontWeight:
|
|
424
|
+
(theme.fontWeight as Record<string, unknown>) ??
|
|
425
|
+
defaultTheme.fontWeight,
|
|
426
|
+
borderRadius:
|
|
427
|
+
(theme.borderRadius as Record<string, string>) ??
|
|
428
|
+
defaultTheme.borderRadius,
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
console.error(`[tailwind] v3 resolved config from ${configPath}`);
|
|
432
|
+
return cached;
|
|
433
|
+
} catch (err) {
|
|
434
|
+
console.error(
|
|
435
|
+
"[tailwind] v3 failed to resolve config, using defaults:",
|
|
436
|
+
err,
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
console.error("[tailwind] v3 no tailwind.config found — using defaults.");
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
cached = defaultTheme;
|
|
444
|
+
return cached;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async generateCssForClasses(classes: string[]): Promise<string> {
|
|
448
|
+
const cwd = process.cwd();
|
|
449
|
+
const req = createRequire(resolve(cwd, "package.json"));
|
|
450
|
+
|
|
451
|
+
const jsPath = resolve(cwd, "tailwind.config.js");
|
|
452
|
+
const tsPath = resolve(cwd, "tailwind.config.ts");
|
|
453
|
+
const cjsPath = resolve(cwd, "tailwind.config.cjs");
|
|
454
|
+
const configPath = existsSync(jsPath)
|
|
455
|
+
? jsPath
|
|
456
|
+
: existsSync(tsPath)
|
|
457
|
+
? tsPath
|
|
458
|
+
: existsSync(cjsPath)
|
|
459
|
+
? cjsPath
|
|
460
|
+
: null;
|
|
461
|
+
|
|
462
|
+
let userConfig: object = {};
|
|
463
|
+
if (configPath) {
|
|
464
|
+
try {
|
|
465
|
+
userConfig = (await import(pathToFileURL(configPath).href)).default;
|
|
466
|
+
} catch {
|
|
467
|
+
// fall through to empty config
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Load postcss and tailwindcss as a PostCSS plugin from the target project
|
|
472
|
+
const postcss = (await import(pathToFileURL(req.resolve("postcss")).href))
|
|
473
|
+
.default;
|
|
474
|
+
const tailwindPlugin = (
|
|
475
|
+
await import(pathToFileURL(req.resolve("tailwindcss")).href)
|
|
476
|
+
).default;
|
|
477
|
+
|
|
478
|
+
const result = await postcss([
|
|
479
|
+
tailwindPlugin({
|
|
480
|
+
...userConfig,
|
|
481
|
+
content: [], // skip file scanning
|
|
482
|
+
safelist: classes, // generate only the requested classes
|
|
483
|
+
}),
|
|
484
|
+
]).process("@tailwind utilities;", { from: undefined });
|
|
485
|
+
|
|
486
|
+
return result.css;
|
|
487
|
+
}
|
|
158
488
|
}
|