weapp-tailwindcss 4.9.2-alpha.2 → 4.9.3
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/dist/{chunk-W4XFWZB5.js → chunk-3UOPODB3.js} +44 -44
- package/dist/{chunk-JOLM54PI.mjs → chunk-4HESZS5A.mjs} +2 -2
- package/dist/{chunk-5O6237HX.js → chunk-4RUFPPI6.js} +400 -377
- package/dist/{chunk-ZE7JKKFT.mjs → chunk-7D27E7TU.mjs} +438 -415
- package/dist/{chunk-KA2JONAP.js → chunk-A2BRI46M.js} +5 -5
- package/dist/{chunk-3SKEY32E.mjs → chunk-F2CKKG6Q.mjs} +67 -67
- package/dist/{chunk-YBTRKOE2.js → chunk-I3IRT5VH.js} +7 -7
- package/dist/chunk-IMOEZLDR.js +441 -0
- package/dist/{chunk-OU2OBBPZ.mjs → chunk-IW3B6ZJD.mjs} +646 -565
- package/dist/{chunk-NGRAUBWU.js → chunk-KXZ4MP4L.js} +277 -236
- package/dist/chunk-PU5CC4ZI.mjs +444 -0
- package/dist/{chunk-FFGR5V3H.mjs → chunk-SPH6SCTM.mjs} +1 -1
- package/dist/{chunk-J7KULRTR.js → chunk-VOD2WUH6.js} +635 -554
- package/dist/{chunk-2WPTDMN3.js → chunk-VPHA77FH.js} +61 -61
- package/dist/{chunk-QA5NZSGN.mjs → chunk-WH65CIYG.mjs} +41 -41
- package/dist/{chunk-UAEME5HT.js → chunk-Y6F6NBA7.js} +1 -1
- package/dist/{chunk-6HBFEXOW.mjs → chunk-Z2D5NSG5.mjs} +265 -224
- package/dist/{chunk-XWGIWOHV.mjs → chunk-ZL22KEHH.mjs} +2 -2
- package/dist/cli.js +182 -136
- package/dist/cli.mjs +194 -148
- package/dist/core.js +10 -10
- package/dist/core.mjs +4 -4
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +6 -6
- package/dist/gulp.mjs +5 -5
- package/dist/index.js +10 -10
- package/dist/index.mjs +9 -9
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.d.mts +2 -1
- package/dist/reset.d.ts +2 -1
- package/dist/reset.js +25 -21
- package/dist/reset.mjs +25 -21
- package/dist/types.d.mts +503 -474
- package/dist/types.d.ts +503 -474
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -7
- package/dist/vite.mjs +6 -6
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -4
- package/dist/webpack.js +8 -8
- package/dist/webpack.mjs +7 -7
- package/dist/webpack4.js +351 -307
- package/dist/webpack4.mjs +341 -297
- package/package.json +11 -11
- package/dist/chunk-CF7VDUIE.mjs +0 -397
- package/dist/chunk-OGG7WXHZ.js +0 -394
|
@@ -5,90 +5,6 @@ import {
|
|
|
5
5
|
// src/logger/index.ts
|
|
6
6
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
7
7
|
|
|
8
|
-
// src/context/workspace.ts
|
|
9
|
-
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
10
|
-
import path from "path";
|
|
11
|
-
var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
|
|
12
|
-
"node_modules",
|
|
13
|
-
".git",
|
|
14
|
-
".hg",
|
|
15
|
-
".svn",
|
|
16
|
-
".turbo",
|
|
17
|
-
".output",
|
|
18
|
-
".next",
|
|
19
|
-
"dist",
|
|
20
|
-
"build"
|
|
21
|
-
]);
|
|
22
|
-
function findWorkspaceRoot(startDir) {
|
|
23
|
-
if (!startDir) {
|
|
24
|
-
return void 0;
|
|
25
|
-
}
|
|
26
|
-
let current = path.resolve(startDir);
|
|
27
|
-
while (true) {
|
|
28
|
-
const workspaceFile = path.join(current, "pnpm-workspace.yaml");
|
|
29
|
-
if (existsSync(workspaceFile)) {
|
|
30
|
-
return current;
|
|
31
|
-
}
|
|
32
|
-
const parent = path.dirname(current);
|
|
33
|
-
if (parent === current) {
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
current = parent;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function findNearestPackageRoot(startDir) {
|
|
40
|
-
if (!startDir) {
|
|
41
|
-
return void 0;
|
|
42
|
-
}
|
|
43
|
-
let current = path.resolve(startDir);
|
|
44
|
-
while (true) {
|
|
45
|
-
const pkgPath = path.join(current, "package.json");
|
|
46
|
-
if (existsSync(pkgPath)) {
|
|
47
|
-
return current;
|
|
48
|
-
}
|
|
49
|
-
const parent = path.dirname(current);
|
|
50
|
-
if (parent === current) {
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
current = parent;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function findWorkspacePackageDir(rootDir, packageName) {
|
|
57
|
-
const visited = /* @__PURE__ */ new Set();
|
|
58
|
-
const queue = [path.resolve(rootDir)];
|
|
59
|
-
while (queue.length > 0) {
|
|
60
|
-
const current = queue.shift();
|
|
61
|
-
const normalized = path.normalize(current);
|
|
62
|
-
if (visited.has(normalized)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
visited.add(normalized);
|
|
66
|
-
try {
|
|
67
|
-
const pkgPath = path.join(normalized, "package.json");
|
|
68
|
-
if (existsSync(pkgPath)) {
|
|
69
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
70
|
-
if (pkg?.name === packageName) {
|
|
71
|
-
return normalized;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
}
|
|
76
|
-
let entries;
|
|
77
|
-
try {
|
|
78
|
-
entries = readdirSync(normalized, { withFileTypes: true });
|
|
79
|
-
} catch {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
for (const entry of entries) {
|
|
83
|
-
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
queue.push(path.join(normalized, entry.name));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
8
|
// src/tailwindcss/v4/config.ts
|
|
93
9
|
import { logger as logger2 } from "@weapp-tailwindcss/logger";
|
|
94
10
|
var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
@@ -197,23 +113,191 @@ function applyV4CssCalcDefaults(cssCalc, patcher) {
|
|
|
197
113
|
}
|
|
198
114
|
|
|
199
115
|
// src/tailwindcss/v4/patcher.ts
|
|
200
|
-
import path3 from "path";
|
|
201
116
|
import { logger as logger4 } from "@weapp-tailwindcss/logger";
|
|
202
117
|
|
|
203
118
|
// src/tailwindcss/patcher.ts
|
|
119
|
+
import path3 from "path";
|
|
120
|
+
import process2 from "process";
|
|
121
|
+
import { logger as logger3 } from "@weapp-tailwindcss/logger";
|
|
122
|
+
import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
123
|
+
import { TailwindcssPatcher } from "tailwindcss-patch";
|
|
124
|
+
|
|
125
|
+
// src/context/workspace.ts
|
|
126
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
127
|
+
import path from "path";
|
|
128
|
+
var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
|
|
129
|
+
"node_modules",
|
|
130
|
+
".git",
|
|
131
|
+
".hg",
|
|
132
|
+
".svn",
|
|
133
|
+
".turbo",
|
|
134
|
+
".output",
|
|
135
|
+
".next",
|
|
136
|
+
"dist",
|
|
137
|
+
"build"
|
|
138
|
+
]);
|
|
139
|
+
function findWorkspaceRoot(startDir) {
|
|
140
|
+
if (!startDir) {
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
let current = path.resolve(startDir);
|
|
144
|
+
while (true) {
|
|
145
|
+
const workspaceFile = path.join(current, "pnpm-workspace.yaml");
|
|
146
|
+
if (existsSync(workspaceFile)) {
|
|
147
|
+
return current;
|
|
148
|
+
}
|
|
149
|
+
const parent = path.dirname(current);
|
|
150
|
+
if (parent === current) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
current = parent;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function findNearestPackageRoot(startDir) {
|
|
157
|
+
if (!startDir) {
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
160
|
+
let current = path.resolve(startDir);
|
|
161
|
+
while (true) {
|
|
162
|
+
const pkgPath = path.join(current, "package.json");
|
|
163
|
+
if (existsSync(pkgPath)) {
|
|
164
|
+
return current;
|
|
165
|
+
}
|
|
166
|
+
const parent = path.dirname(current);
|
|
167
|
+
if (parent === current) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
current = parent;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function findWorkspacePackageDir(rootDir, packageName) {
|
|
174
|
+
const visited = /* @__PURE__ */ new Set();
|
|
175
|
+
const queue = [path.resolve(rootDir)];
|
|
176
|
+
while (queue.length > 0) {
|
|
177
|
+
const current = queue.shift();
|
|
178
|
+
const normalized = path.normalize(current);
|
|
179
|
+
if (visited.has(normalized)) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
visited.add(normalized);
|
|
183
|
+
try {
|
|
184
|
+
const pkgPath = path.join(normalized, "package.json");
|
|
185
|
+
if (existsSync(pkgPath)) {
|
|
186
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
187
|
+
if (pkg?.name === packageName) {
|
|
188
|
+
return normalized;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
let entries;
|
|
194
|
+
try {
|
|
195
|
+
entries = readdirSync(normalized, { withFileTypes: true });
|
|
196
|
+
} catch {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
for (const entry of entries) {
|
|
200
|
+
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
queue.push(path.join(normalized, entry.name));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return void 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/tailwindcss/patcher-options.ts
|
|
210
|
+
function normalizeExtendLengthUnits(value) {
|
|
211
|
+
if (value === false) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
if (value === true) {
|
|
215
|
+
return { enabled: true };
|
|
216
|
+
}
|
|
217
|
+
if (value && typeof value === "object") {
|
|
218
|
+
return {
|
|
219
|
+
enabled: true,
|
|
220
|
+
...value
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return void 0;
|
|
224
|
+
}
|
|
225
|
+
function normalizeTailwindcssPatcherOptions(options) {
|
|
226
|
+
if (!options) {
|
|
227
|
+
return void 0;
|
|
228
|
+
}
|
|
229
|
+
if ("patch" in options) {
|
|
230
|
+
const { cache, patch } = options;
|
|
231
|
+
const normalized = {};
|
|
232
|
+
if (cache !== void 0) {
|
|
233
|
+
normalized.cache = cache;
|
|
234
|
+
}
|
|
235
|
+
if (patch?.overwrite !== void 0) {
|
|
236
|
+
normalized.overwrite = patch.overwrite;
|
|
237
|
+
}
|
|
238
|
+
if (patch?.filter) {
|
|
239
|
+
normalized.filter = patch.filter;
|
|
240
|
+
}
|
|
241
|
+
const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
|
|
242
|
+
const exposeContext = patch?.applyPatches?.exportContext;
|
|
243
|
+
if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
|
|
244
|
+
normalized.features = {
|
|
245
|
+
exposeContext,
|
|
246
|
+
extendLengthUnits
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const cwd = patch?.cwd ?? patch?.basedir;
|
|
250
|
+
if (cwd) {
|
|
251
|
+
normalized.cwd = cwd;
|
|
252
|
+
}
|
|
253
|
+
const tailwindOptions = patch?.tailwindcss ? { ...patch.tailwindcss } : void 0;
|
|
254
|
+
const legacyResolve = patch?.resolve;
|
|
255
|
+
let nextTailwindOptions = tailwindOptions;
|
|
256
|
+
if (nextTailwindOptions?.version === 2 && !nextTailwindOptions.packageName) {
|
|
257
|
+
nextTailwindOptions = {
|
|
258
|
+
...nextTailwindOptions,
|
|
259
|
+
packageName: "@tailwindcss/postcss7-compat",
|
|
260
|
+
postcssPlugin: nextTailwindOptions.postcssPlugin
|
|
261
|
+
};
|
|
262
|
+
if (!nextTailwindOptions.postcssPlugin) {
|
|
263
|
+
nextTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (nextTailwindOptions || legacyResolve) {
|
|
267
|
+
const resolveOptions = nextTailwindOptions?.resolve;
|
|
268
|
+
const mergedResolve = legacyResolve || resolveOptions ? {
|
|
269
|
+
...resolveOptions ?? {},
|
|
270
|
+
...legacyResolve ?? {}
|
|
271
|
+
} : void 0;
|
|
272
|
+
normalized.tailwind = {
|
|
273
|
+
...nextTailwindOptions ?? {},
|
|
274
|
+
...mergedResolve ? { resolve: mergedResolve } : {}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return normalized;
|
|
278
|
+
}
|
|
279
|
+
return options;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/tailwindcss/patcher-resolve.ts
|
|
204
283
|
import { existsSync as existsSync2 } from "fs";
|
|
205
284
|
import { createRequire } from "module";
|
|
206
285
|
import path2 from "path";
|
|
207
286
|
import process from "process";
|
|
208
287
|
import { fileURLToPath } from "url";
|
|
209
|
-
import { logger as logger3 } from "@weapp-tailwindcss/logger";
|
|
210
|
-
import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
211
|
-
import { TailwindcssPatcher } from "tailwindcss-patch";
|
|
212
288
|
var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
|
|
213
289
|
var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
|
|
214
290
|
"stubs/config.full.js",
|
|
215
291
|
"defaultConfig.js"
|
|
216
292
|
];
|
|
293
|
+
var TAILWIND_CONFIG_FILES = [
|
|
294
|
+
"tailwind.config.js",
|
|
295
|
+
"tailwind.config.cjs",
|
|
296
|
+
"tailwind.config.mjs",
|
|
297
|
+
"tailwind.config.ts",
|
|
298
|
+
"tailwind.config.cts",
|
|
299
|
+
"tailwind.config.mts"
|
|
300
|
+
];
|
|
217
301
|
function isPathSpecifier(specifier) {
|
|
218
302
|
if (!specifier) {
|
|
219
303
|
return false;
|
|
@@ -250,43 +334,6 @@ function resolveTailwindConfigFallback(packageName, paths) {
|
|
|
250
334
|
}
|
|
251
335
|
return void 0;
|
|
252
336
|
}
|
|
253
|
-
function createFallbackTailwindcssPatcher() {
|
|
254
|
-
const packageInfo = {
|
|
255
|
-
name: "tailwindcss",
|
|
256
|
-
version: void 0,
|
|
257
|
-
rootPath: "",
|
|
258
|
-
packageJsonPath: "",
|
|
259
|
-
packageJson: {}
|
|
260
|
-
};
|
|
261
|
-
return {
|
|
262
|
-
packageInfo,
|
|
263
|
-
async patch() {
|
|
264
|
-
return {
|
|
265
|
-
exposeContext: void 0,
|
|
266
|
-
extendLengthUnits: void 0
|
|
267
|
-
};
|
|
268
|
-
},
|
|
269
|
-
async getClassSet() {
|
|
270
|
-
return /* @__PURE__ */ new Set();
|
|
271
|
-
},
|
|
272
|
-
async extract(_options) {
|
|
273
|
-
const classSet = /* @__PURE__ */ new Set();
|
|
274
|
-
return {
|
|
275
|
-
classList: [],
|
|
276
|
-
classSet
|
|
277
|
-
};
|
|
278
|
-
},
|
|
279
|
-
async collectContentTokens() {
|
|
280
|
-
return {
|
|
281
|
-
entries: [],
|
|
282
|
-
filesScanned: 0,
|
|
283
|
-
sources: [],
|
|
284
|
-
skippedFiles: []
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
var hasLoggedMissingTailwind = false;
|
|
290
337
|
function appendNodeModules(paths, dir) {
|
|
291
338
|
if (!dir) {
|
|
292
339
|
return;
|
|
@@ -296,14 +343,6 @@ function appendNodeModules(paths, dir) {
|
|
|
296
343
|
paths.add(nodeModulesDir);
|
|
297
344
|
}
|
|
298
345
|
}
|
|
299
|
-
var TAILWIND_CONFIG_FILES = [
|
|
300
|
-
"tailwind.config.js",
|
|
301
|
-
"tailwind.config.cjs",
|
|
302
|
-
"tailwind.config.mjs",
|
|
303
|
-
"tailwind.config.ts",
|
|
304
|
-
"tailwind.config.cts",
|
|
305
|
-
"tailwind.config.mts"
|
|
306
|
-
];
|
|
307
346
|
function findTailwindConfig(searchRoots) {
|
|
308
347
|
for (const root of searchRoots) {
|
|
309
348
|
for (const file of TAILWIND_CONFIG_FILES) {
|
|
@@ -348,99 +387,67 @@ function createDefaultResolvePaths(basedir) {
|
|
|
348
387
|
}
|
|
349
388
|
return [...paths];
|
|
350
389
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (!options) {
|
|
368
|
-
return void 0;
|
|
369
|
-
}
|
|
370
|
-
if ("patch" in options) {
|
|
371
|
-
const { cache, patch } = options;
|
|
372
|
-
const normalized = {};
|
|
373
|
-
if (cache !== void 0) {
|
|
374
|
-
normalized.cache = cache;
|
|
375
|
-
}
|
|
376
|
-
if (patch?.overwrite !== void 0) {
|
|
377
|
-
normalized.overwrite = patch.overwrite;
|
|
378
|
-
}
|
|
379
|
-
if (patch?.filter) {
|
|
380
|
-
normalized.filter = patch.filter;
|
|
381
|
-
}
|
|
382
|
-
const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
|
|
383
|
-
const exposeContext = patch?.applyPatches?.exportContext;
|
|
384
|
-
if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
|
|
385
|
-
normalized.features = {
|
|
386
|
-
exposeContext,
|
|
387
|
-
extendLengthUnits
|
|
390
|
+
|
|
391
|
+
// src/tailwindcss/patcher.ts
|
|
392
|
+
function createFallbackTailwindcssPatcher() {
|
|
393
|
+
const packageInfo = {
|
|
394
|
+
name: "tailwindcss",
|
|
395
|
+
version: void 0,
|
|
396
|
+
rootPath: "",
|
|
397
|
+
packageJsonPath: "",
|
|
398
|
+
packageJson: {}
|
|
399
|
+
};
|
|
400
|
+
return {
|
|
401
|
+
packageInfo,
|
|
402
|
+
async patch() {
|
|
403
|
+
return {
|
|
404
|
+
exposeContext: void 0,
|
|
405
|
+
extendLengthUnits: void 0
|
|
388
406
|
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
nextTailwindOptions = {
|
|
399
|
-
...nextTailwindOptions,
|
|
400
|
-
packageName: "@tailwindcss/postcss7-compat",
|
|
401
|
-
postcssPlugin: nextTailwindOptions.postcssPlugin
|
|
407
|
+
},
|
|
408
|
+
async getClassSet() {
|
|
409
|
+
return /* @__PURE__ */ new Set();
|
|
410
|
+
},
|
|
411
|
+
async extract(_options) {
|
|
412
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
413
|
+
return {
|
|
414
|
+
classList: [],
|
|
415
|
+
classSet
|
|
402
416
|
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
...resolveOptions ?? {},
|
|
411
|
-
...legacyResolve ?? {}
|
|
412
|
-
} : void 0;
|
|
413
|
-
normalized.tailwind = {
|
|
414
|
-
...nextTailwindOptions ?? {},
|
|
415
|
-
...mergedResolve ? { resolve: mergedResolve } : {}
|
|
417
|
+
},
|
|
418
|
+
async collectContentTokens() {
|
|
419
|
+
return {
|
|
420
|
+
entries: [],
|
|
421
|
+
filesScanned: 0,
|
|
422
|
+
sources: [],
|
|
423
|
+
skippedFiles: []
|
|
416
424
|
};
|
|
417
425
|
}
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
return options;
|
|
426
|
+
};
|
|
421
427
|
}
|
|
428
|
+
var hasLoggedMissingTailwind = false;
|
|
422
429
|
function createTailwindcssPatcher(options) {
|
|
423
430
|
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
424
431
|
const cache = {
|
|
425
432
|
driver: "memory"
|
|
426
433
|
};
|
|
427
|
-
const normalizedBasedir = basedir ?
|
|
428
|
-
const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ??
|
|
434
|
+
const normalizedBasedir = basedir ? path3.resolve(basedir) : void 0;
|
|
435
|
+
const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? process2.cwd();
|
|
429
436
|
if (cacheDir) {
|
|
430
|
-
if (
|
|
437
|
+
if (path3.isAbsolute(cacheDir)) {
|
|
431
438
|
cache.dir = cacheDir;
|
|
432
439
|
} else if (normalizedBasedir) {
|
|
433
|
-
cache.dir =
|
|
440
|
+
cache.dir = path3.resolve(normalizedBasedir, cacheDir);
|
|
434
441
|
} else {
|
|
435
|
-
cache.dir =
|
|
442
|
+
cache.dir = path3.resolve(process2.cwd(), cacheDir);
|
|
436
443
|
}
|
|
437
444
|
} else {
|
|
438
|
-
cache.dir =
|
|
445
|
+
cache.dir = path3.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
|
|
439
446
|
}
|
|
440
447
|
if (normalizedBasedir) {
|
|
441
448
|
cache.cwd = normalizedBasedir;
|
|
442
449
|
}
|
|
443
|
-
const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ??
|
|
450
|
+
const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? process2.cwd());
|
|
444
451
|
const normalizedUserOptions = normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
|
|
445
452
|
const extendLengthUnits = normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
|
|
446
453
|
const baseTailwindOptions = defuOverrideArray2(
|
|
@@ -512,7 +519,7 @@ function createTailwindcssPatcher(options) {
|
|
|
512
519
|
searchRoots.add(resolvedOptions.tailwind.cwd);
|
|
513
520
|
}
|
|
514
521
|
for (const resolvePath of resolvedOptions.tailwind.resolve?.paths ?? []) {
|
|
515
|
-
const parentDir =
|
|
522
|
+
const parentDir = path3.dirname(resolvePath);
|
|
516
523
|
searchRoots.add(parentDir);
|
|
517
524
|
}
|
|
518
525
|
const configPath = findTailwindConfig(searchRoots);
|
|
@@ -529,35 +536,182 @@ function createTailwindcssPatcher(options) {
|
|
|
529
536
|
}
|
|
530
537
|
}
|
|
531
538
|
}
|
|
532
|
-
if (!resolvedOptions.tailwind.cwd && configPath) {
|
|
533
|
-
resolvedOptions.tailwind.cwd =
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
try {
|
|
537
|
-
return new TailwindcssPatcher(resolvedOptions);
|
|
538
|
-
} catch (error) {
|
|
539
|
-
const searchPaths = resolvedOptions.tailwind?.resolve?.paths;
|
|
540
|
-
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
541
|
-
if (!hasLoggedMissingTailwind) {
|
|
542
|
-
logger3.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
|
|
543
|
-
hasLoggedMissingTailwind = true;
|
|
539
|
+
if (!resolvedOptions.tailwind.cwd && configPath) {
|
|
540
|
+
resolvedOptions.tailwind.cwd = path3.dirname(configPath);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
try {
|
|
544
|
+
return new TailwindcssPatcher(resolvedOptions);
|
|
545
|
+
} catch (error) {
|
|
546
|
+
const searchPaths = resolvedOptions.tailwind?.resolve?.paths;
|
|
547
|
+
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
548
|
+
if (!hasLoggedMissingTailwind) {
|
|
549
|
+
logger3.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
|
|
550
|
+
hasLoggedMissingTailwind = true;
|
|
551
|
+
}
|
|
552
|
+
return createFallbackTailwindcssPatcher();
|
|
553
|
+
}
|
|
554
|
+
if (error instanceof Error && /unable to locate tailwind css package/i.test(error.message)) {
|
|
555
|
+
logger3.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwind?.packageName, searchPaths);
|
|
556
|
+
}
|
|
557
|
+
throw error;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/tailwindcss/v4/multi-patcher.ts
|
|
562
|
+
function createMultiTailwindcssPatcher(patchers) {
|
|
563
|
+
if (patchers.length <= 1) {
|
|
564
|
+
return patchers[0];
|
|
565
|
+
}
|
|
566
|
+
const [first] = patchers;
|
|
567
|
+
const multiPatcher = {
|
|
568
|
+
...first,
|
|
569
|
+
packageInfo: first?.packageInfo,
|
|
570
|
+
majorVersion: first?.majorVersion,
|
|
571
|
+
options: first?.options,
|
|
572
|
+
async patch() {
|
|
573
|
+
let exposeContext;
|
|
574
|
+
let extendLengthUnits;
|
|
575
|
+
for (const patcher of patchers) {
|
|
576
|
+
const result = await patcher.patch();
|
|
577
|
+
if (result?.exposeContext && exposeContext == null) {
|
|
578
|
+
exposeContext = result.exposeContext;
|
|
579
|
+
}
|
|
580
|
+
if (result?.extendLengthUnits && extendLengthUnits == null) {
|
|
581
|
+
extendLengthUnits = result.extendLengthUnits;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return {
|
|
585
|
+
exposeContext,
|
|
586
|
+
extendLengthUnits
|
|
587
|
+
};
|
|
588
|
+
},
|
|
589
|
+
async getClassSet() {
|
|
590
|
+
const aggregated = /* @__PURE__ */ new Set();
|
|
591
|
+
for (const patcher of patchers) {
|
|
592
|
+
const current = await patcher.getClassSet();
|
|
593
|
+
for (const className of current) {
|
|
594
|
+
aggregated.add(className);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return aggregated;
|
|
598
|
+
},
|
|
599
|
+
async extract(options) {
|
|
600
|
+
const aggregatedSet = /* @__PURE__ */ new Set();
|
|
601
|
+
const aggregatedList = [];
|
|
602
|
+
let filename;
|
|
603
|
+
for (const patcher of patchers) {
|
|
604
|
+
const result = await patcher.extract(options);
|
|
605
|
+
if (!result) {
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
if (filename === void 0 && result.filename) {
|
|
609
|
+
filename = result.filename;
|
|
610
|
+
}
|
|
611
|
+
if (result.classList) {
|
|
612
|
+
for (const className of result.classList) {
|
|
613
|
+
if (!aggregatedSet.has(className)) {
|
|
614
|
+
aggregatedList.push(className);
|
|
615
|
+
}
|
|
616
|
+
aggregatedSet.add(className);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (result.classSet) {
|
|
620
|
+
for (const className of result.classSet) {
|
|
621
|
+
aggregatedSet.add(className);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return {
|
|
626
|
+
classList: aggregatedList,
|
|
627
|
+
classSet: aggregatedSet,
|
|
628
|
+
filename
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) {
|
|
633
|
+
multiPatcher.getClassSetSync = () => {
|
|
634
|
+
const aggregated = /* @__PURE__ */ new Set();
|
|
635
|
+
for (const patcher of patchers) {
|
|
636
|
+
const current = patcher.getClassSetSync?.();
|
|
637
|
+
if (!current) {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
for (const className of current) {
|
|
641
|
+
aggregated.add(className);
|
|
642
|
+
}
|
|
544
643
|
}
|
|
545
|
-
return
|
|
546
|
-
}
|
|
547
|
-
if (error instanceof Error && /unable to locate tailwind css package/i.test(error.message)) {
|
|
548
|
-
logger3.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwind?.packageName, searchPaths);
|
|
549
|
-
}
|
|
550
|
-
throw error;
|
|
644
|
+
return aggregated;
|
|
645
|
+
};
|
|
551
646
|
}
|
|
647
|
+
return multiPatcher;
|
|
552
648
|
}
|
|
553
649
|
|
|
554
|
-
// src/tailwindcss/v4/patcher.ts
|
|
650
|
+
// src/tailwindcss/v4/patcher-options.ts
|
|
555
651
|
function isLegacyTailwindcssPatcherOptions(options) {
|
|
556
652
|
return typeof options === "object" && options !== null && "patch" in options;
|
|
557
653
|
}
|
|
558
654
|
function isModernTailwindcssPatchOptions(options) {
|
|
559
655
|
return typeof options === "object" && options !== null && !("patch" in options);
|
|
560
656
|
}
|
|
657
|
+
function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries) {
|
|
658
|
+
const hasCssEntries = cssEntries.length > 0;
|
|
659
|
+
if (!options) {
|
|
660
|
+
return options;
|
|
661
|
+
}
|
|
662
|
+
if (isLegacyTailwindcssPatcherOptions(options)) {
|
|
663
|
+
const patchOptions = options.patch;
|
|
664
|
+
if (!patchOptions) {
|
|
665
|
+
return options;
|
|
666
|
+
}
|
|
667
|
+
const nextPatch = {
|
|
668
|
+
...patchOptions,
|
|
669
|
+
basedir: baseDir,
|
|
670
|
+
cwd: patchOptions.cwd ?? baseDir
|
|
671
|
+
};
|
|
672
|
+
if (patchOptions.tailwindcss) {
|
|
673
|
+
const nextV4 = {
|
|
674
|
+
...patchOptions.tailwindcss.v4 ?? {}
|
|
675
|
+
};
|
|
676
|
+
if (hasCssEntries) {
|
|
677
|
+
nextV4.cssEntries = cssEntries;
|
|
678
|
+
} else {
|
|
679
|
+
nextV4.cssEntries = nextV4.cssEntries ?? cssEntries;
|
|
680
|
+
if (nextV4.base === void 0) {
|
|
681
|
+
nextV4.base = baseDir;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
nextPatch.tailwindcss = {
|
|
685
|
+
...patchOptions.tailwindcss,
|
|
686
|
+
v4: nextV4
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
return {
|
|
690
|
+
...options,
|
|
691
|
+
patch: nextPatch
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
if (!isModernTailwindcssPatchOptions(options)) {
|
|
695
|
+
return options;
|
|
696
|
+
}
|
|
697
|
+
if (!options.tailwind) {
|
|
698
|
+
return options;
|
|
699
|
+
}
|
|
700
|
+
return {
|
|
701
|
+
...options,
|
|
702
|
+
tailwind: {
|
|
703
|
+
...options.tailwind,
|
|
704
|
+
v4: {
|
|
705
|
+
...options.tailwind.v4 ?? {},
|
|
706
|
+
...hasCssEntries ? {} : { base: options.tailwind.v4?.base ?? baseDir },
|
|
707
|
+
cssEntries: hasCssEntries ? cssEntries : options.tailwind.v4?.cssEntries ?? cssEntries
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// src/tailwindcss/v4/css-entries.ts
|
|
714
|
+
import path4 from "path";
|
|
561
715
|
function guessBasedirFromEntries(entries) {
|
|
562
716
|
if (!entries) {
|
|
563
717
|
return void 0;
|
|
@@ -567,10 +721,10 @@ function guessBasedirFromEntries(entries) {
|
|
|
567
721
|
continue;
|
|
568
722
|
}
|
|
569
723
|
const trimmed = entry.trim();
|
|
570
|
-
if (!trimmed || !
|
|
724
|
+
if (!trimmed || !path4.isAbsolute(trimmed)) {
|
|
571
725
|
continue;
|
|
572
726
|
}
|
|
573
|
-
const entryDir =
|
|
727
|
+
const entryDir = path4.dirname(trimmed);
|
|
574
728
|
const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
|
|
575
729
|
if (resolved) {
|
|
576
730
|
return resolved;
|
|
@@ -591,7 +745,7 @@ function normalizeCssEntries(entries, anchor) {
|
|
|
591
745
|
if (trimmed.length === 0) {
|
|
592
746
|
continue;
|
|
593
747
|
}
|
|
594
|
-
const resolved =
|
|
748
|
+
const resolved = path4.isAbsolute(trimmed) ? path4.normalize(trimmed) : path4.normalize(path4.resolve(anchor, trimmed));
|
|
595
749
|
normalized.add(resolved);
|
|
596
750
|
}
|
|
597
751
|
return normalized.size > 0 ? [...normalized] : void 0;
|
|
@@ -600,11 +754,11 @@ function isSubPath(parent, child) {
|
|
|
600
754
|
if (!parent || !child) {
|
|
601
755
|
return false;
|
|
602
756
|
}
|
|
603
|
-
const relative =
|
|
604
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
757
|
+
const relative = path4.relative(parent, child);
|
|
758
|
+
return relative === "" || !relative.startsWith("..") && !path4.isAbsolute(relative);
|
|
605
759
|
}
|
|
606
760
|
function resolveCssEntryBase(entryDir, options) {
|
|
607
|
-
const normalizedDir =
|
|
761
|
+
const normalizedDir = path4.normalize(entryDir);
|
|
608
762
|
const { preferredBaseDir, workspaceRoot } = options;
|
|
609
763
|
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) {
|
|
610
764
|
return preferredBaseDir;
|
|
@@ -614,18 +768,18 @@ function resolveCssEntryBase(entryDir, options) {
|
|
|
614
768
|
}
|
|
615
769
|
const packageRoot = findNearestPackageRoot(normalizedDir);
|
|
616
770
|
if (packageRoot) {
|
|
617
|
-
return
|
|
771
|
+
return path4.normalize(packageRoot);
|
|
618
772
|
}
|
|
619
773
|
return normalizedDir;
|
|
620
774
|
}
|
|
621
775
|
function groupCssEntriesByBase(entries, options = {}) {
|
|
622
776
|
const normalizedOptions = {
|
|
623
|
-
preferredBaseDir: options.preferredBaseDir ?
|
|
624
|
-
workspaceRoot: options.workspaceRoot ?
|
|
777
|
+
preferredBaseDir: options.preferredBaseDir ? path4.normalize(options.preferredBaseDir) : void 0,
|
|
778
|
+
workspaceRoot: options.workspaceRoot ? path4.normalize(options.workspaceRoot) : void 0
|
|
625
779
|
};
|
|
626
780
|
const groups = /* @__PURE__ */ new Map();
|
|
627
781
|
for (const entry of entries) {
|
|
628
|
-
const entryDir =
|
|
782
|
+
const entryDir = path4.dirname(entry);
|
|
629
783
|
const baseDir = resolveCssEntryBase(entryDir, normalizedOptions);
|
|
630
784
|
const bucket = groups.get(baseDir);
|
|
631
785
|
if (bucket) {
|
|
@@ -636,61 +790,8 @@ function groupCssEntriesByBase(entries, options = {}) {
|
|
|
636
790
|
}
|
|
637
791
|
return groups;
|
|
638
792
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
if (!options) {
|
|
642
|
-
return options;
|
|
643
|
-
}
|
|
644
|
-
if (isLegacyTailwindcssPatcherOptions(options)) {
|
|
645
|
-
const patchOptions = options.patch;
|
|
646
|
-
if (!patchOptions) {
|
|
647
|
-
return options;
|
|
648
|
-
}
|
|
649
|
-
const nextPatch = {
|
|
650
|
-
...patchOptions,
|
|
651
|
-
basedir: baseDir,
|
|
652
|
-
cwd: patchOptions.cwd ?? baseDir
|
|
653
|
-
};
|
|
654
|
-
if (patchOptions.tailwindcss) {
|
|
655
|
-
const nextV4 = {
|
|
656
|
-
...patchOptions.tailwindcss.v4 ?? {}
|
|
657
|
-
};
|
|
658
|
-
if (hasCssEntries) {
|
|
659
|
-
nextV4.cssEntries = cssEntries;
|
|
660
|
-
} else {
|
|
661
|
-
nextV4.cssEntries = nextV4.cssEntries ?? cssEntries;
|
|
662
|
-
if (nextV4.base === void 0) {
|
|
663
|
-
nextV4.base = baseDir;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
nextPatch.tailwindcss = {
|
|
667
|
-
...patchOptions.tailwindcss,
|
|
668
|
-
v4: nextV4
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
return {
|
|
672
|
-
...options,
|
|
673
|
-
patch: nextPatch
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
if (!isModernTailwindcssPatchOptions(options)) {
|
|
677
|
-
return options;
|
|
678
|
-
}
|
|
679
|
-
if (!options.tailwind) {
|
|
680
|
-
return options;
|
|
681
|
-
}
|
|
682
|
-
return {
|
|
683
|
-
...options,
|
|
684
|
-
tailwind: {
|
|
685
|
-
...options.tailwind,
|
|
686
|
-
v4: {
|
|
687
|
-
...options.tailwind.v4 ?? {},
|
|
688
|
-
...hasCssEntries ? {} : { base: options.tailwind.v4?.base ?? baseDir },
|
|
689
|
-
cssEntries: hasCssEntries ? cssEntries : options.tailwind.v4?.cssEntries ?? cssEntries
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
}
|
|
793
|
+
|
|
794
|
+
// src/tailwindcss/v4/patcher.ts
|
|
694
795
|
function createPatcherForBase(baseDir, cssEntries, options) {
|
|
695
796
|
const {
|
|
696
797
|
tailwindcss,
|
|
@@ -771,93 +872,6 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
771
872
|
});
|
|
772
873
|
return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
|
|
773
874
|
}
|
|
774
|
-
function createMultiTailwindcssPatcher(patchers) {
|
|
775
|
-
if (patchers.length <= 1) {
|
|
776
|
-
return patchers[0];
|
|
777
|
-
}
|
|
778
|
-
const [first] = patchers;
|
|
779
|
-
const multiPatcher = {
|
|
780
|
-
...first,
|
|
781
|
-
packageInfo: first?.packageInfo,
|
|
782
|
-
majorVersion: first?.majorVersion,
|
|
783
|
-
options: first?.options,
|
|
784
|
-
async patch() {
|
|
785
|
-
let exposeContext;
|
|
786
|
-
let extendLengthUnits;
|
|
787
|
-
for (const patcher of patchers) {
|
|
788
|
-
const result = await patcher.patch();
|
|
789
|
-
if (result?.exposeContext && exposeContext == null) {
|
|
790
|
-
exposeContext = result.exposeContext;
|
|
791
|
-
}
|
|
792
|
-
if (result?.extendLengthUnits && extendLengthUnits == null) {
|
|
793
|
-
extendLengthUnits = result.extendLengthUnits;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
return {
|
|
797
|
-
exposeContext,
|
|
798
|
-
extendLengthUnits
|
|
799
|
-
};
|
|
800
|
-
},
|
|
801
|
-
async getClassSet() {
|
|
802
|
-
const aggregated = /* @__PURE__ */ new Set();
|
|
803
|
-
for (const patcher of patchers) {
|
|
804
|
-
const current = await patcher.getClassSet();
|
|
805
|
-
for (const className of current) {
|
|
806
|
-
aggregated.add(className);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
return aggregated;
|
|
810
|
-
},
|
|
811
|
-
async extract(options) {
|
|
812
|
-
const aggregatedSet = /* @__PURE__ */ new Set();
|
|
813
|
-
const aggregatedList = [];
|
|
814
|
-
let filename;
|
|
815
|
-
for (const patcher of patchers) {
|
|
816
|
-
const result = await patcher.extract(options);
|
|
817
|
-
if (!result) {
|
|
818
|
-
continue;
|
|
819
|
-
}
|
|
820
|
-
if (filename === void 0 && result.filename) {
|
|
821
|
-
filename = result.filename;
|
|
822
|
-
}
|
|
823
|
-
if (result.classList) {
|
|
824
|
-
for (const className of result.classList) {
|
|
825
|
-
if (!aggregatedSet.has(className)) {
|
|
826
|
-
aggregatedList.push(className);
|
|
827
|
-
}
|
|
828
|
-
aggregatedSet.add(className);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
if (result.classSet) {
|
|
832
|
-
for (const className of result.classSet) {
|
|
833
|
-
aggregatedSet.add(className);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
return {
|
|
838
|
-
classList: aggregatedList,
|
|
839
|
-
classSet: aggregatedSet,
|
|
840
|
-
filename
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) {
|
|
845
|
-
multiPatcher.getClassSetSync = () => {
|
|
846
|
-
const aggregated = /* @__PURE__ */ new Set();
|
|
847
|
-
for (const patcher of patchers) {
|
|
848
|
-
const current = patcher.getClassSetSync?.();
|
|
849
|
-
if (!current) {
|
|
850
|
-
continue;
|
|
851
|
-
}
|
|
852
|
-
for (const className of current) {
|
|
853
|
-
aggregated.add(className);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
return aggregated;
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
return multiPatcher;
|
|
860
|
-
}
|
|
861
875
|
function tryCreateMultiTailwindcssPatcher(groups, options) {
|
|
862
876
|
if (groups.size <= 1) {
|
|
863
877
|
return void 0;
|
|
@@ -870,11 +884,10 @@ function tryCreateMultiTailwindcssPatcher(groups, options) {
|
|
|
870
884
|
return createMultiTailwindcssPatcher(patchers);
|
|
871
885
|
}
|
|
872
886
|
|
|
873
|
-
// src/context/tailwindcss.ts
|
|
874
|
-
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
887
|
+
// src/context/tailwindcss/basedir.ts
|
|
875
888
|
import { createRequire as createRequire2 } from "module";
|
|
876
|
-
import
|
|
877
|
-
import
|
|
889
|
+
import path5 from "path";
|
|
890
|
+
import process3 from "process";
|
|
878
891
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
879
892
|
import { logger as logger5 } from "@weapp-tailwindcss/logger";
|
|
880
893
|
var ENV_BASEDIR_KEYS = [
|
|
@@ -892,23 +905,23 @@ var ENV_BASEDIR_KEYS = [
|
|
|
892
905
|
var GENERIC_ENV_BASEDIR_KEYS = /* @__PURE__ */ new Set(["INIT_CWD", "PWD"]);
|
|
893
906
|
function pickEnvBasedir() {
|
|
894
907
|
for (const key of ENV_BASEDIR_KEYS) {
|
|
895
|
-
const value =
|
|
896
|
-
if (value &&
|
|
908
|
+
const value = process3.env[key];
|
|
909
|
+
if (value && path5.isAbsolute(value)) {
|
|
897
910
|
return { key, value };
|
|
898
911
|
}
|
|
899
912
|
}
|
|
900
913
|
return void 0;
|
|
901
914
|
}
|
|
902
915
|
function pickPackageEnvBasedir() {
|
|
903
|
-
const packageJsonPath =
|
|
916
|
+
const packageJsonPath = process3.env.npm_package_json;
|
|
904
917
|
if (packageJsonPath) {
|
|
905
|
-
const packageDir =
|
|
906
|
-
if (packageDir &&
|
|
918
|
+
const packageDir = path5.dirname(packageJsonPath);
|
|
919
|
+
if (packageDir && path5.isAbsolute(packageDir)) {
|
|
907
920
|
return packageDir;
|
|
908
921
|
}
|
|
909
922
|
}
|
|
910
|
-
const localPrefix =
|
|
911
|
-
if (localPrefix &&
|
|
923
|
+
const localPrefix = process3.env.npm_config_local_prefix;
|
|
924
|
+
if (localPrefix && path5.isAbsolute(localPrefix)) {
|
|
912
925
|
return localPrefix;
|
|
913
926
|
}
|
|
914
927
|
return void 0;
|
|
@@ -918,7 +931,7 @@ function detectCallerBasedir() {
|
|
|
918
931
|
if (!stack) {
|
|
919
932
|
return void 0;
|
|
920
933
|
}
|
|
921
|
-
if (
|
|
934
|
+
if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
922
935
|
logger5.debug("caller stack: %s", stack);
|
|
923
936
|
}
|
|
924
937
|
const lines = stack.split("\n");
|
|
@@ -937,15 +950,15 @@ function detectCallerBasedir() {
|
|
|
937
950
|
}
|
|
938
951
|
}
|
|
939
952
|
const [candidate] = filePath.split(":");
|
|
940
|
-
const resolvedPath =
|
|
941
|
-
if (!
|
|
953
|
+
const resolvedPath = path5.isAbsolute(filePath) ? filePath : candidate;
|
|
954
|
+
if (!path5.isAbsolute(resolvedPath)) {
|
|
942
955
|
continue;
|
|
943
956
|
}
|
|
944
957
|
if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) {
|
|
945
958
|
continue;
|
|
946
959
|
}
|
|
947
960
|
try {
|
|
948
|
-
return
|
|
961
|
+
return path5.dirname(resolvedPath);
|
|
949
962
|
} catch {
|
|
950
963
|
continue;
|
|
951
964
|
}
|
|
@@ -960,10 +973,10 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
960
973
|
const packageEnvBasedir = pickPackageEnvBasedir();
|
|
961
974
|
const shouldDetectCaller = !envBasedir || envBasedirIsGeneric;
|
|
962
975
|
const callerBasedir = shouldDetectCaller ? detectCallerBasedir() : void 0;
|
|
963
|
-
const cwd =
|
|
976
|
+
const cwd = process3.cwd();
|
|
964
977
|
const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
|
|
965
|
-
const resolveRelative = (value) =>
|
|
966
|
-
if (
|
|
978
|
+
const resolveRelative = (value) => path5.isAbsolute(value) ? path5.normalize(value) : path5.normalize(path5.resolve(anchor, value));
|
|
979
|
+
if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
967
980
|
logger5.debug("resolveTailwindcssBasedir anchor %O", {
|
|
968
981
|
basedir,
|
|
969
982
|
envBasedir,
|
|
@@ -972,7 +985,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
972
985
|
packageEnvBasedir,
|
|
973
986
|
fallback,
|
|
974
987
|
callerBasedir,
|
|
975
|
-
npm_package_json:
|
|
988
|
+
npm_package_json: process3.env.npm_package_json,
|
|
976
989
|
cwd,
|
|
977
990
|
anchor
|
|
978
991
|
});
|
|
@@ -981,32 +994,32 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
981
994
|
return resolveRelative(basedir);
|
|
982
995
|
}
|
|
983
996
|
if (envBasedir && !envBasedirIsGeneric) {
|
|
984
|
-
return
|
|
997
|
+
return path5.normalize(envBasedir);
|
|
985
998
|
}
|
|
986
999
|
if (fallback && fallback.trim().length > 0) {
|
|
987
1000
|
return resolveRelative(fallback);
|
|
988
1001
|
}
|
|
989
1002
|
if (packageEnvBasedir) {
|
|
990
|
-
return
|
|
1003
|
+
return path5.normalize(packageEnvBasedir);
|
|
991
1004
|
}
|
|
992
1005
|
if (callerBasedir) {
|
|
993
|
-
const normalizedCaller =
|
|
994
|
-
const librarySegment = `${
|
|
1006
|
+
const normalizedCaller = path5.normalize(callerBasedir);
|
|
1007
|
+
const librarySegment = `${path5.sep}weapp-tailwindcss${path5.sep}`;
|
|
995
1008
|
if (!normalizedCaller.includes(librarySegment)) {
|
|
996
1009
|
return normalizedCaller;
|
|
997
1010
|
}
|
|
998
1011
|
}
|
|
999
|
-
const packageName =
|
|
1012
|
+
const packageName = process3.env.PNPM_PACKAGE_NAME;
|
|
1000
1013
|
if (packageName) {
|
|
1001
1014
|
try {
|
|
1002
|
-
const anchorRequire = createRequire2(
|
|
1015
|
+
const anchorRequire = createRequire2(path5.join(anchor, "__resolve_tailwindcss_basedir__.cjs"));
|
|
1003
1016
|
const packageJsonPath = anchorRequire.resolve(`${packageName}/package.json`);
|
|
1004
|
-
if (
|
|
1017
|
+
if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
1005
1018
|
logger5.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
|
|
1006
1019
|
}
|
|
1007
|
-
return
|
|
1020
|
+
return path5.normalize(path5.dirname(packageJsonPath));
|
|
1008
1021
|
} catch {
|
|
1009
|
-
if (
|
|
1022
|
+
if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
1010
1023
|
logger5.debug("failed to resolve package json for %s", packageName);
|
|
1011
1024
|
}
|
|
1012
1025
|
const workspaceRoot = findWorkspaceRoot(anchor);
|
|
@@ -1019,16 +1032,24 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
1019
1032
|
}
|
|
1020
1033
|
}
|
|
1021
1034
|
if (envBasedir) {
|
|
1022
|
-
return
|
|
1035
|
+
return path5.normalize(envBasedir);
|
|
1023
1036
|
}
|
|
1024
|
-
return
|
|
1037
|
+
return path5.normalize(cwd);
|
|
1025
1038
|
}
|
|
1039
|
+
|
|
1040
|
+
// src/context/tailwindcss.ts
|
|
1041
|
+
import { logger as logger6 } from "@weapp-tailwindcss/logger";
|
|
1042
|
+
|
|
1043
|
+
// src/context/tailwindcss/rax.ts
|
|
1044
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
1045
|
+
import path6 from "path";
|
|
1046
|
+
import process4 from "process";
|
|
1026
1047
|
function isRaxWorkspace(appType, baseDir) {
|
|
1027
1048
|
if (appType === "rax") {
|
|
1028
1049
|
return true;
|
|
1029
1050
|
}
|
|
1030
1051
|
try {
|
|
1031
|
-
const pkgPath =
|
|
1052
|
+
const pkgPath = path6.join(baseDir, "package.json");
|
|
1032
1053
|
if (!existsSync3(pkgPath)) {
|
|
1033
1054
|
return false;
|
|
1034
1055
|
}
|
|
@@ -1056,20 +1077,20 @@ function collectRaxStyleEntries(baseDir) {
|
|
|
1056
1077
|
];
|
|
1057
1078
|
const discovered = [];
|
|
1058
1079
|
for (const relative of STYLE_CANDIDATES) {
|
|
1059
|
-
const candidate =
|
|
1080
|
+
const candidate = path6.resolve(baseDir, relative);
|
|
1060
1081
|
if (existsSync3(candidate)) {
|
|
1061
|
-
discovered.push(
|
|
1082
|
+
discovered.push(path6.normalize(candidate));
|
|
1062
1083
|
}
|
|
1063
1084
|
}
|
|
1064
1085
|
return discovered;
|
|
1065
1086
|
}
|
|
1066
1087
|
function detectImplicitCssEntries(appType, baseDir) {
|
|
1067
1088
|
const baseCandidates = /* @__PURE__ */ new Set();
|
|
1068
|
-
baseCandidates.add(
|
|
1069
|
-
const envCandidates = [
|
|
1089
|
+
baseCandidates.add(path6.normalize(baseDir));
|
|
1090
|
+
const envCandidates = [process4.cwd(), process4.env.INIT_CWD, process4.env.PWD];
|
|
1070
1091
|
for (const candidate of envCandidates) {
|
|
1071
1092
|
if (candidate) {
|
|
1072
|
-
baseCandidates.add(
|
|
1093
|
+
baseCandidates.add(path6.normalize(candidate));
|
|
1073
1094
|
}
|
|
1074
1095
|
}
|
|
1075
1096
|
for (const candidateBase of baseCandidates) {
|
|
@@ -1083,6 +1104,8 @@ function detectImplicitCssEntries(appType, baseDir) {
|
|
|
1083
1104
|
}
|
|
1084
1105
|
return void 0;
|
|
1085
1106
|
}
|
|
1107
|
+
|
|
1108
|
+
// src/context/tailwindcss.ts
|
|
1086
1109
|
function createTailwindcssPatcherFromContext(ctx) {
|
|
1087
1110
|
const {
|
|
1088
1111
|
tailwindcssBasedir,
|
|
@@ -1095,7 +1118,7 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
1095
1118
|
const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
|
|
1096
1119
|
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
|
|
1097
1120
|
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
1098
|
-
|
|
1121
|
+
logger6.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
|
|
1099
1122
|
let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
|
|
1100
1123
|
if (!normalizedCssEntries) {
|
|
1101
1124
|
normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
|