weapp-tailwindcss 4.11.0-alpha.1 → 4.11.0-alpha.2

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.
Files changed (73) hide show
  1. package/dist/{chunk-35EI5JMK.mjs → chunk-23K4XDKF.mjs} +3 -1
  2. package/dist/{chunk-W2EMGF7H.js → chunk-2W24MRCQ.js} +10 -12
  3. package/dist/chunk-4AFQP74Z.js +24 -0
  4. package/dist/{chunk-SQG2MOFQ.js → chunk-4TTPYMVM.js} +12 -8
  5. package/dist/{chunk-4LPOQMFS.js → chunk-5KSBT6GU.js} +396 -219
  6. package/dist/{chunk-LD7LZ4IK.mjs → chunk-66E76FQE.mjs} +91 -50
  7. package/dist/{chunk-GWDHNCL2.js → chunk-6O7HJU2F.js} +123 -42
  8. package/dist/{chunk-RRHPTTCP.mjs → chunk-76S2EME4.mjs} +2 -0
  9. package/dist/{chunk-G3G437UE.js → chunk-7LKMJZD2.js} +2 -2
  10. package/dist/{chunk-OV7FX6XR.js → chunk-CRDOWYG4.js} +1 -1
  11. package/dist/{chunk-DOH7FULQ.mjs → chunk-EFBQ4SQR.mjs} +1 -1
  12. package/dist/{chunk-IEZ5RBMG.mjs → chunk-EW2K6CO5.mjs} +365 -188
  13. package/dist/{chunk-FZNYV7VH.mjs → chunk-HADJCWHU.mjs} +212 -258
  14. package/dist/{chunk-CZLXTEHN.js → chunk-K7CZXT46.js} +132 -91
  15. package/dist/{chunk-ACTJYB33.js → chunk-LL3QUKJI.js} +3 -1
  16. package/dist/{chunk-G5NLM3AL.js → chunk-LYGLQCWI.js} +278 -324
  17. package/dist/{chunk-LTJQUORK.js → chunk-OF6MFURR.js} +2 -0
  18. package/dist/{chunk-KKT2DKMW.mjs → chunk-RED7Y22U.mjs} +91 -10
  19. package/dist/{chunk-R6KEYO3F.mjs → chunk-SJ3SG6DU.mjs} +5 -1
  20. package/dist/{chunk-JBM3HGHP.mjs → chunk-UCUAXK7F.mjs} +4 -6
  21. package/dist/cli.js +1006 -147
  22. package/dist/cli.mjs +942 -107
  23. package/dist/core.d.mts +2 -2
  24. package/dist/core.d.ts +2 -2
  25. package/dist/core.js +9 -11
  26. package/dist/core.mjs +6 -8
  27. package/dist/css-macro/postcss.js +1 -1
  28. package/dist/css-macro/postcss.mjs +1 -1
  29. package/dist/css-macro.js +3 -3
  30. package/dist/css-macro.mjs +4 -4
  31. package/dist/defaults.d.mts +2 -2
  32. package/dist/defaults.d.ts +2 -2
  33. package/dist/defaults.js +3 -3
  34. package/dist/defaults.mjs +2 -2
  35. package/dist/gulp.d.mts +2 -2
  36. package/dist/gulp.d.ts +2 -2
  37. package/dist/gulp.js +7 -8
  38. package/dist/gulp.mjs +6 -7
  39. package/dist/{index-t_VBjwYm.d.ts → index-BMwzhITq.d.mts} +6 -6
  40. package/dist/{index-t_VBjwYm.d.mts → index-BMwzhITq.d.ts} +6 -6
  41. package/dist/index.d.mts +2 -2
  42. package/dist/index.d.ts +2 -2
  43. package/dist/index.js +11 -12
  44. package/dist/index.mjs +9 -10
  45. package/dist/postcss-html-transform.js +1 -1
  46. package/dist/postcss-html-transform.mjs +1 -1
  47. package/dist/presets.d.mts +2 -2
  48. package/dist/presets.d.ts +2 -2
  49. package/dist/presets.js +5 -5
  50. package/dist/presets.mjs +2 -2
  51. package/dist/reset.js +1 -1
  52. package/dist/reset.mjs +1 -1
  53. package/dist/types.d.mts +4 -4
  54. package/dist/types.d.ts +4 -4
  55. package/dist/types.js +1 -1
  56. package/dist/types.mjs +1 -1
  57. package/dist/vite.d.mts +2 -2
  58. package/dist/vite.d.ts +2 -2
  59. package/dist/vite.js +8 -9
  60. package/dist/vite.mjs +6 -7
  61. package/dist/weapp-tw-css-import-rewrite-loader.js +3 -1
  62. package/dist/weapp-tw-runtime-classset-loader.js +29 -2
  63. package/dist/webpack.d.mts +2 -2
  64. package/dist/webpack.d.ts +2 -2
  65. package/dist/webpack.js +9 -10
  66. package/dist/webpack.mjs +7 -8
  67. package/dist/webpack4.d.mts +2 -2
  68. package/dist/webpack4.d.ts +2 -2
  69. package/dist/webpack4.js +41 -41
  70. package/dist/webpack4.mjs +12 -12
  71. package/package.json +8 -8
  72. package/dist/chunk-NOKJXG3W.js +0 -29
  73. package/dist/chunk-QYZCRG7F.mjs +0 -29
@@ -2,8 +2,302 @@ import {
2
2
  defuOverrideArray
3
3
  } from "./chunk-OOHJLO5M.mjs";
4
4
 
5
- // src/logger/index.ts
6
- import { logger } from "@weapp-tailwindcss/logger";
5
+ // src/tailwindcss/patcher-options.ts
6
+ function resolveTailwindcssOptions(options) {
7
+ if (!options) {
8
+ return void 0;
9
+ }
10
+ return options.tailwindcss ?? options.tailwind;
11
+ }
12
+ function normalizeExtendLengthUnits(value) {
13
+ if (value === false) {
14
+ return false;
15
+ }
16
+ if (value === true) {
17
+ return { enabled: true };
18
+ }
19
+ if (value && typeof value === "object") {
20
+ return {
21
+ enabled: true,
22
+ ...value
23
+ };
24
+ }
25
+ return void 0;
26
+ }
27
+ function normalizeTailwindcssPatcherOptions(options) {
28
+ if (!options) {
29
+ return void 0;
30
+ }
31
+ if ("patch" in options) {
32
+ const { cache, patch } = options;
33
+ const normalized = {};
34
+ if (cache !== void 0) {
35
+ normalized.cache = cache;
36
+ }
37
+ const apply = {};
38
+ const extract = {};
39
+ if (patch?.overwrite !== void 0) {
40
+ apply.overwrite = patch.overwrite;
41
+ }
42
+ if (patch?.filter) {
43
+ normalized.filter = patch.filter;
44
+ }
45
+ const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
46
+ const exposeContext = patch?.applyPatches?.exportContext;
47
+ if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
48
+ apply.exposeContext = exposeContext;
49
+ apply.extendLengthUnits = extendLengthUnits;
50
+ }
51
+ const cwd = patch?.cwd ?? patch?.basedir;
52
+ if (cwd) {
53
+ normalized.projectRoot = cwd;
54
+ }
55
+ const tailwindOptions = patch?.tailwindcss ? { ...patch.tailwindcss } : void 0;
56
+ const legacyResolve = patch?.resolve;
57
+ let nextTailwindOptions = tailwindOptions;
58
+ if (nextTailwindOptions?.version === 2 && !nextTailwindOptions.packageName) {
59
+ nextTailwindOptions = {
60
+ ...nextTailwindOptions,
61
+ packageName: "@tailwindcss/postcss7-compat",
62
+ postcssPlugin: nextTailwindOptions.postcssPlugin
63
+ };
64
+ if (!nextTailwindOptions.postcssPlugin) {
65
+ nextTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
66
+ }
67
+ }
68
+ if (nextTailwindOptions || legacyResolve) {
69
+ const resolveOptions = nextTailwindOptions?.resolve;
70
+ const mergedResolve = legacyResolve || resolveOptions ? {
71
+ ...resolveOptions ?? {},
72
+ ...legacyResolve ?? {}
73
+ } : void 0;
74
+ normalized.tailwindcss = {
75
+ ...nextTailwindOptions ?? {},
76
+ ...mergedResolve ? { resolve: mergedResolve } : {}
77
+ };
78
+ }
79
+ if (patch?.output) {
80
+ if (patch.output.filename !== void 0) {
81
+ extract.file = patch.output.filename;
82
+ }
83
+ if (patch.output.loose !== void 0) {
84
+ extract.pretty = patch.output.loose ? 2 : false;
85
+ }
86
+ if (patch.output.removeUniversalSelector !== void 0) {
87
+ extract.removeUniversalSelector = patch.output.removeUniversalSelector;
88
+ }
89
+ }
90
+ if (Object.keys(apply).length > 0) {
91
+ normalized.apply = apply;
92
+ }
93
+ if (Object.keys(extract).length > 0) {
94
+ normalized.extract = extract;
95
+ }
96
+ return toModernTailwindcssPatchOptions(normalized);
97
+ }
98
+ return toModernTailwindcssPatchOptions(options);
99
+ }
100
+ function toModernTailwindcssPatchOptions(options) {
101
+ if (!options) {
102
+ return void 0;
103
+ }
104
+ const normalized = {};
105
+ if (options.cache !== void 0) {
106
+ normalized.cache = options.cache;
107
+ }
108
+ if (options.filter) {
109
+ normalized.filter = options.filter;
110
+ }
111
+ const projectRoot = options.projectRoot ?? options.cwd;
112
+ if (projectRoot) {
113
+ normalized.projectRoot = projectRoot;
114
+ }
115
+ const tailwindcss = resolveTailwindcssOptions(options);
116
+ if (tailwindcss) {
117
+ normalized.tailwindcss = {
118
+ ...tailwindcss
119
+ };
120
+ }
121
+ const apply = {
122
+ ...options.apply ?? {}
123
+ };
124
+ if (apply.overwrite === void 0 && options.overwrite !== void 0) {
125
+ apply.overwrite = options.overwrite;
126
+ }
127
+ if (apply.exposeContext === void 0 && options.features?.exposeContext !== void 0) {
128
+ apply.exposeContext = options.features.exposeContext;
129
+ }
130
+ if (apply.extendLengthUnits === void 0 && options.features?.extendLengthUnits !== void 0) {
131
+ apply.extendLengthUnits = options.features.extendLengthUnits;
132
+ }
133
+ if (Object.keys(apply).length > 0) {
134
+ normalized.apply = apply;
135
+ }
136
+ const extract = {
137
+ ...options.extract ?? {}
138
+ };
139
+ if (options.output) {
140
+ if (extract.write === void 0 && options.output.enabled !== void 0) {
141
+ extract.write = options.output.enabled;
142
+ }
143
+ if (extract.file === void 0 && options.output.file !== void 0) {
144
+ extract.file = options.output.file;
145
+ }
146
+ if (extract.format === void 0 && options.output.format !== void 0) {
147
+ extract.format = options.output.format;
148
+ }
149
+ if (extract.pretty === void 0 && options.output.pretty !== void 0) {
150
+ extract.pretty = options.output.pretty;
151
+ }
152
+ if (extract.removeUniversalSelector === void 0 && options.output.removeUniversalSelector !== void 0) {
153
+ extract.removeUniversalSelector = options.output.removeUniversalSelector;
154
+ }
155
+ }
156
+ if (Object.keys(extract).length > 0) {
157
+ normalized.extract = extract;
158
+ }
159
+ return normalized;
160
+ }
161
+
162
+ // src/tailwindcss/runtime/cache.ts
163
+ import { statSync } from "fs";
164
+ var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
165
+ var runtimeFileSignatureCache = /* @__PURE__ */ new Map();
166
+ var runtimeFileSignatureCacheClearTimer;
167
+ var runtimeSignaturePatchersSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
168
+ function getCacheEntry(twPatcher) {
169
+ let entry = runtimeClassSetCache.get(twPatcher);
170
+ if (!entry) {
171
+ entry = {};
172
+ runtimeClassSetCache.set(twPatcher, entry);
173
+ }
174
+ return entry;
175
+ }
176
+ function scheduleRuntimeConfigSignatureCacheClear() {
177
+ if (runtimeFileSignatureCacheClearTimer) {
178
+ return;
179
+ }
180
+ runtimeFileSignatureCacheClearTimer = setTimeout(() => {
181
+ runtimeFileSignatureCache.clear();
182
+ runtimeFileSignatureCacheClearTimer = void 0;
183
+ }, 0);
184
+ runtimeFileSignatureCacheClearTimer.unref?.();
185
+ }
186
+ function getFileSignature(filePath) {
187
+ const cached = runtimeFileSignatureCache.get(filePath);
188
+ if (cached !== void 0) {
189
+ return cached;
190
+ }
191
+ let signature;
192
+ try {
193
+ const stats = statSync(filePath);
194
+ signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
195
+ } catch {
196
+ signature = `${filePath}:missing`;
197
+ }
198
+ runtimeFileSignatureCache.set(filePath, signature);
199
+ scheduleRuntimeConfigSignatureCacheClear();
200
+ return signature;
201
+ }
202
+ function getTailwindTrackedFiles(twPatcher) {
203
+ const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
204
+ const tracked = /* @__PURE__ */ new Set();
205
+ const configPath = tailwindOptions?.config;
206
+ if (typeof configPath === "string" && configPath.length > 0) {
207
+ tracked.add(configPath);
208
+ }
209
+ for (const entry of tailwindOptions?.v4?.cssEntries ?? []) {
210
+ if (typeof entry === "string" && entry.length > 0) {
211
+ tracked.add(entry);
212
+ }
213
+ }
214
+ return tracked;
215
+ }
216
+ function normalizeSignatureValue(value) {
217
+ if (value == null) {
218
+ return "null";
219
+ }
220
+ if (typeof value === "string") {
221
+ return value;
222
+ }
223
+ if (typeof value === "number" || typeof value === "boolean") {
224
+ return String(value);
225
+ }
226
+ if (Array.isArray(value)) {
227
+ return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
228
+ }
229
+ if (typeof value === "object") {
230
+ const entries = Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b));
231
+ return `{${entries.map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
232
+ }
233
+ return String(value);
234
+ }
235
+ function getTailwindOptionsSignature(twPatcher) {
236
+ const options = twPatcher.options;
237
+ const tailwindOptions = resolveTailwindcssOptions(options);
238
+ return normalizeSignatureValue({
239
+ projectRoot: options?.projectRoot,
240
+ packageName: tailwindOptions?.packageName,
241
+ versionHint: tailwindOptions?.versionHint,
242
+ cwd: tailwindOptions?.cwd,
243
+ config: tailwindOptions?.config,
244
+ v2: tailwindOptions?.v2,
245
+ v3: tailwindOptions?.v3,
246
+ v4: {
247
+ base: tailwindOptions?.v4?.base,
248
+ configuredBase: tailwindOptions?.v4?.configuredBase,
249
+ css: tailwindOptions?.v4?.css,
250
+ cssEntries: tailwindOptions?.v4?.cssEntries,
251
+ hasUserDefinedSources: tailwindOptions?.v4?.hasUserDefinedSources,
252
+ sources: tailwindOptions?.v4?.sources
253
+ }
254
+ });
255
+ }
256
+ function getPatchTargetSignature(twPatcher) {
257
+ const packageInfo = twPatcher.packageInfo;
258
+ return [
259
+ packageInfo?.name ?? "missing",
260
+ packageInfo?.rootPath ?? "missing",
261
+ packageInfo?.version ?? "unknown",
262
+ twPatcher.majorVersion ?? "unknown",
263
+ getTailwindOptionsSignature(twPatcher)
264
+ ].join(":");
265
+ }
266
+ function getNestedPatchers(twPatcher) {
267
+ const nested = twPatcher[runtimeSignaturePatchersSymbol];
268
+ return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
269
+ }
270
+ function getOwnRuntimeClassSetSignature(twPatcher) {
271
+ const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
272
+ const configSignature = trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing";
273
+ const patchTargetSignature = getPatchTargetSignature(twPatcher);
274
+ return `${configSignature}|patch:${patchTargetSignature}`;
275
+ }
276
+ function invalidateRuntimeClassSet(twPatcher) {
277
+ if (!twPatcher) {
278
+ return;
279
+ }
280
+ const nestedPatchers = getNestedPatchers(twPatcher);
281
+ if (nestedPatchers) {
282
+ for (const patcher of nestedPatchers) {
283
+ invalidateRuntimeClassSet(patcher);
284
+ }
285
+ }
286
+ for (const trackedFile of getTailwindTrackedFiles(twPatcher)) {
287
+ runtimeFileSignatureCache.delete(trackedFile);
288
+ }
289
+ runtimeClassSetCache.delete(twPatcher);
290
+ }
291
+ function getRuntimeClassSetCacheEntry(twPatcher) {
292
+ return getCacheEntry(twPatcher);
293
+ }
294
+ function getRuntimeClassSetSignature(twPatcher) {
295
+ const nestedPatchers = getNestedPatchers(twPatcher);
296
+ if (nestedPatchers) {
297
+ return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
298
+ }
299
+ return getOwnRuntimeClassSetSignature(twPatcher);
300
+ }
7
301
 
8
302
  // src/context/workspace.ts
9
303
  import { existsSync, readdirSync, readFileSync } from "fs";
@@ -90,7 +384,7 @@ function findWorkspacePackageDir(rootDir, packageName) {
90
384
  }
91
385
 
92
386
  // src/tailwindcss/v4/config.ts
93
- import { logger as logger2 } from "@weapp-tailwindcss/logger";
387
+ import { logger } from "@weapp-tailwindcss/logger";
94
388
  var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
95
389
  function includesToken(list, token) {
96
390
  return list.some((candidate) => {
@@ -187,7 +481,7 @@ function warnMissingCssEntries(ctx, patcher) {
187
481
  return;
188
482
  }
189
483
  hasWarnedMissingCssEntries = true;
190
- logger2.warn(
484
+ logger.warn(
191
485
  '[tailwindcss@4] \u672A\u68C0\u6D4B\u5230 cssEntries \u914D\u7F6E\u3002\u8BF7\u4F20\u5165\u5305\u542B tailwindcss \u5F15\u7528\u7684 CSS \u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 cssEntries: ["/absolute/path/to/src/app.css"]\uFF0C\u5426\u5219 tailwindcss \u751F\u6210\u7684\u7C7B\u540D\u4E0D\u4F1A\u53C2\u4E0E\u8F6C\u8BD1\u3002'
192
486
  );
193
487
  }
@@ -309,167 +603,14 @@ function createDefaultResolvePaths(basedir) {
309
603
  }
310
604
 
311
605
  // src/tailwindcss/v4/patcher.ts
312
- import { logger as logger4 } from "@weapp-tailwindcss/logger";
606
+ import { logger as logger3 } from "@weapp-tailwindcss/logger";
313
607
 
314
608
  // src/tailwindcss/patcher.ts
315
609
  import path3 from "path";
316
610
  import process2 from "process";
317
- import { logger as logger3 } from "@weapp-tailwindcss/logger";
611
+ import { logger as logger2 } from "@weapp-tailwindcss/logger";
318
612
  import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
319
613
  import { TailwindcssPatcher } from "tailwindcss-patch";
320
-
321
- // src/tailwindcss/patcher-options.ts
322
- function normalizeExtendLengthUnits(value) {
323
- if (value === false) {
324
- return false;
325
- }
326
- if (value === true) {
327
- return { enabled: true };
328
- }
329
- if (value && typeof value === "object") {
330
- return {
331
- enabled: true,
332
- ...value
333
- };
334
- }
335
- return void 0;
336
- }
337
- function normalizeTailwindcssPatcherOptions(options) {
338
- if (!options) {
339
- return void 0;
340
- }
341
- if ("patch" in options) {
342
- const { cache, patch } = options;
343
- const normalized = {};
344
- if (cache !== void 0) {
345
- normalized.cache = cache;
346
- }
347
- const apply = {};
348
- const extract = {};
349
- if (patch?.overwrite !== void 0) {
350
- apply.overwrite = patch.overwrite;
351
- }
352
- if (patch?.filter) {
353
- normalized.filter = patch.filter;
354
- }
355
- const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
356
- const exposeContext = patch?.applyPatches?.exportContext;
357
- if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
358
- apply.exposeContext = exposeContext;
359
- apply.extendLengthUnits = extendLengthUnits;
360
- }
361
- const cwd = patch?.cwd ?? patch?.basedir;
362
- if (cwd) {
363
- normalized.projectRoot = cwd;
364
- }
365
- const tailwindOptions = patch?.tailwindcss ? { ...patch.tailwindcss } : void 0;
366
- const legacyResolve = patch?.resolve;
367
- let nextTailwindOptions = tailwindOptions;
368
- if (nextTailwindOptions?.version === 2 && !nextTailwindOptions.packageName) {
369
- nextTailwindOptions = {
370
- ...nextTailwindOptions,
371
- packageName: "@tailwindcss/postcss7-compat",
372
- postcssPlugin: nextTailwindOptions.postcssPlugin
373
- };
374
- if (!nextTailwindOptions.postcssPlugin) {
375
- nextTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
376
- }
377
- }
378
- if (nextTailwindOptions || legacyResolve) {
379
- const resolveOptions = nextTailwindOptions?.resolve;
380
- const mergedResolve = legacyResolve || resolveOptions ? {
381
- ...resolveOptions ?? {},
382
- ...legacyResolve ?? {}
383
- } : void 0;
384
- normalized.tailwindcss = {
385
- ...nextTailwindOptions ?? {},
386
- ...mergedResolve ? { resolve: mergedResolve } : {}
387
- };
388
- }
389
- if (patch?.output) {
390
- if (patch.output.filename !== void 0) {
391
- extract.file = patch.output.filename;
392
- }
393
- if (patch.output.loose !== void 0) {
394
- extract.pretty = patch.output.loose ? 2 : false;
395
- }
396
- if (patch.output.removeUniversalSelector !== void 0) {
397
- extract.removeUniversalSelector = patch.output.removeUniversalSelector;
398
- }
399
- }
400
- if (Object.keys(apply).length > 0) {
401
- normalized.apply = apply;
402
- }
403
- if (Object.keys(extract).length > 0) {
404
- normalized.extract = extract;
405
- }
406
- return toModernTailwindcssPatchOptions(normalized);
407
- }
408
- return toModernTailwindcssPatchOptions(options);
409
- }
410
- function toModernTailwindcssPatchOptions(options) {
411
- if (!options) {
412
- return void 0;
413
- }
414
- const normalized = {};
415
- if (options.cache !== void 0) {
416
- normalized.cache = options.cache;
417
- }
418
- if (options.filter) {
419
- normalized.filter = options.filter;
420
- }
421
- const projectRoot = options.projectRoot ?? options.cwd;
422
- if (projectRoot) {
423
- normalized.projectRoot = projectRoot;
424
- }
425
- const tailwindcss = options.tailwindcss ?? options.tailwind;
426
- if (tailwindcss) {
427
- normalized.tailwindcss = {
428
- ...tailwindcss
429
- };
430
- }
431
- const apply = {
432
- ...options.apply ?? {}
433
- };
434
- if (apply.overwrite === void 0 && options.overwrite !== void 0) {
435
- apply.overwrite = options.overwrite;
436
- }
437
- if (apply.exposeContext === void 0 && options.features?.exposeContext !== void 0) {
438
- apply.exposeContext = options.features.exposeContext;
439
- }
440
- if (apply.extendLengthUnits === void 0 && options.features?.extendLengthUnits !== void 0) {
441
- apply.extendLengthUnits = options.features.extendLengthUnits;
442
- }
443
- if (Object.keys(apply).length > 0) {
444
- normalized.apply = apply;
445
- }
446
- const extract = {
447
- ...options.extract ?? {}
448
- };
449
- if (options.output) {
450
- if (extract.write === void 0 && options.output.enabled !== void 0) {
451
- extract.write = options.output.enabled;
452
- }
453
- if (extract.file === void 0 && options.output.file !== void 0) {
454
- extract.file = options.output.file;
455
- }
456
- if (extract.format === void 0 && options.output.format !== void 0) {
457
- extract.format = options.output.format;
458
- }
459
- if (extract.pretty === void 0 && options.output.pretty !== void 0) {
460
- extract.pretty = options.output.pretty;
461
- }
462
- if (extract.removeUniversalSelector === void 0 && options.output.removeUniversalSelector !== void 0) {
463
- extract.removeUniversalSelector = options.output.removeUniversalSelector;
464
- }
465
- }
466
- if (Object.keys(extract).length > 0) {
467
- normalized.extract = extract;
468
- }
469
- return normalized;
470
- }
471
-
472
- // src/tailwindcss/patcher.ts
473
614
  function createFallbackTailwindcssPatcher() {
474
615
  const packageInfo = {
475
616
  name: "tailwindcss",
@@ -509,6 +650,9 @@ function createFallbackTailwindcssPatcher() {
509
650
  var hasLoggedMissingTailwind = false;
510
651
  var TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
511
652
  var UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
653
+ function isTailwindcssV4PackageName(packageName) {
654
+ return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
655
+ }
512
656
  function createTailwindcssPatcher(options) {
513
657
  const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
514
658
  const cache = {
@@ -553,7 +697,7 @@ function createTailwindcssPatcher(options) {
553
697
  baseTailwindOptions.packageName = "tailwindcss";
554
698
  }
555
699
  if (!baseTailwindOptions.postcssPlugin) {
556
- baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 ? "@tailwindcss/postcss" : "tailwindcss";
700
+ baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
557
701
  }
558
702
  if (typeof baseTailwindOptions.postcssPlugin === "string") {
559
703
  const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
@@ -584,7 +728,7 @@ function createTailwindcssPatcher(options) {
584
728
  ...existingResolve,
585
729
  paths: [...new Set(sourcePaths)]
586
730
  };
587
- logger3.debug("Tailwind resolve config %O", {
731
+ logger2.debug("Tailwind resolve config %O", {
588
732
  packageName: resolvedTailwindOptions.packageName,
589
733
  version: resolvedTailwindOptions.version,
590
734
  resolve: resolvedTailwindOptions.resolve,
@@ -632,13 +776,13 @@ function createTailwindcssPatcher(options) {
632
776
  const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
633
777
  if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
634
778
  if (!hasLoggedMissingTailwind) {
635
- 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");
779
+ logger2.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");
636
780
  hasLoggedMissingTailwind = true;
637
781
  }
638
782
  return createFallbackTailwindcssPatcher();
639
783
  }
640
784
  if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) {
641
- logger3.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwindcss?.packageName, searchPaths);
785
+ logger2.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwindcss?.packageName, searchPaths);
642
786
  }
643
787
  throw error;
644
788
  }
@@ -730,6 +874,10 @@ function createMultiTailwindcssPatcher(patchers) {
730
874
  return aggregated;
731
875
  };
732
876
  }
877
+ Object.defineProperty(multiPatcher, runtimeSignaturePatchersSymbol, {
878
+ value: [...patchers],
879
+ configurable: true
880
+ });
733
881
  return multiPatcher;
734
882
  }
735
883
 
@@ -880,6 +1028,19 @@ function groupCssEntriesByBase(entries, options = {}) {
880
1028
  }
881
1029
 
882
1030
  // src/tailwindcss/v4/patcher.ts
1031
+ var CONFIGURED_TAILWIND_VERSION_RE = /Configured tailwindcss\.version=\d+/u;
1032
+ var RESOLVED_TAILWIND_VERSION_RE = /resolved package ".+" is version /u;
1033
+ function isTailwindcss4Package(packageName) {
1034
+ return Boolean(
1035
+ packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4"))
1036
+ );
1037
+ }
1038
+ function hasOwnV4Signal(value) {
1039
+ return typeof value === "object" && value !== null && "v4" in value;
1040
+ }
1041
+ function isTailwindVersionMismatchError(error) {
1042
+ return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
1043
+ }
883
1044
  function createPatcherForBase(baseDir, cssEntries, options) {
884
1045
  const {
885
1046
  tailwindcss,
@@ -900,9 +1061,6 @@ function createPatcherForBase(baseDir, cssEntries, options) {
900
1061
  cssEntries
901
1062
  }
902
1063
  };
903
- if (hasCssEntries && (tailwindcss == null || tailwindcss.version == null)) {
904
- defaultTailwindcssConfig.version = 4;
905
- }
906
1064
  const mergedTailwindOptions = defuOverrideArray(
907
1065
  tailwindcss ?? {},
908
1066
  defaultTailwindcssConfig
@@ -933,10 +1091,8 @@ function createPatcherForBase(baseDir, cssEntries, options) {
933
1091
  );
934
1092
  const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwind?.packageName || tailwindcssPatcherOptions?.patch?.tailwindcss?.packageName;
935
1093
  const configuredVersion = tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || tailwindcssPatcherOptions?.tailwind?.version || tailwindcssPatcherOptions?.patch?.tailwindcss?.version || mergedTailwindOptions.version;
936
- const isTailwindcss4Package = (packageName) => Boolean(
937
- packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4"))
938
- );
939
- const isV4 = configuredVersion === 4 || mergedTailwindOptions.version === 4 || isTailwindcss4Package(configuredPackageName ?? mergedTailwindOptions.packageName);
1094
+ const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwind) || hasOwnV4Signal(tailwindcssPatcherOptions?.patch?.tailwindcss);
1095
+ const isV4 = configuredVersion === 4 || mergedTailwindOptions.version === 4 || isTailwindcss4Package(configuredPackageName ?? mergedTailwindOptions.packageName) || hasExplicitV4Signals;
940
1096
  const tailwindPackageConfigured = Boolean(configuredPackageName);
941
1097
  const shouldPatchV4PostcssPackage = isV4 && !tailwindPackageConfigured;
942
1098
  const packageCandidates = /* @__PURE__ */ new Set();
@@ -946,25 +1102,40 @@ function createPatcherForBase(baseDir, cssEntries, options) {
946
1102
  packageCandidates.add(
947
1103
  mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss"
948
1104
  );
949
- const patchers = Array.from(packageCandidates, (packageName) => {
1105
+ const patchers = [];
1106
+ const packageCandidateList = [...packageCandidates];
1107
+ let firstVersionMismatchError;
1108
+ for (const packageName of packageCandidateList) {
950
1109
  const tailwindOptionsForPackage = {
951
1110
  ...mergedTailwindOptions,
952
1111
  packageName
953
1112
  };
954
- return createTailwindcssPatcher({
955
- basedir: baseDir,
956
- supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
957
- tailwindcss: tailwindOptionsForPackage,
958
- tailwindcssPatcherOptions: patchedOptions
959
- });
960
- });
1113
+ try {
1114
+ patchers.push(createTailwindcssPatcher({
1115
+ basedir: baseDir,
1116
+ supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
1117
+ tailwindcss: tailwindOptionsForPackage,
1118
+ tailwindcssPatcherOptions: patchedOptions
1119
+ }));
1120
+ } catch (error) {
1121
+ if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
1122
+ firstVersionMismatchError ?? (firstVersionMismatchError = error);
1123
+ logger3.warn('skip incompatible Tailwind package candidate "%s" for v4 patcher: %s', packageName, error.message);
1124
+ continue;
1125
+ }
1126
+ throw error;
1127
+ }
1128
+ }
1129
+ if (patchers.length === 0 && firstVersionMismatchError) {
1130
+ throw firstVersionMismatchError;
1131
+ }
961
1132
  return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
962
1133
  }
963
1134
  function tryCreateMultiTailwindcssPatcher(groups, options) {
964
1135
  if (groups.size <= 1) {
965
1136
  return void 0;
966
1137
  }
967
- logger4.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
1138
+ logger3.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
968
1139
  const patchers = [];
969
1140
  for (const [baseDir, entries] of groups) {
970
1141
  patchers.push(createPatcherForBase(baseDir, entries, options));
@@ -977,7 +1148,7 @@ import { createRequire as createRequire2 } from "module";
977
1148
  import path5 from "path";
978
1149
  import process3 from "process";
979
1150
  import { fileURLToPath as fileURLToPath2 } from "url";
980
- import { logger as logger5 } from "@weapp-tailwindcss/logger";
1151
+ import { logger as logger4 } from "@weapp-tailwindcss/logger";
981
1152
  var ENV_BASEDIR_KEYS = [
982
1153
  "WEAPP_TAILWINDCSS_BASEDIR",
983
1154
  "WEAPP_TAILWINDCSS_BASE_DIR",
@@ -1022,7 +1193,7 @@ function detectCallerBasedir() {
1022
1193
  return void 0;
1023
1194
  }
1024
1195
  if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1025
- logger5.debug("caller stack: %s", stack);
1196
+ logger4.debug("caller stack: %s", stack);
1026
1197
  }
1027
1198
  const lines = stack.split("\n");
1028
1199
  for (const line of lines) {
@@ -1067,7 +1238,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
1067
1238
  const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
1068
1239
  const resolveRelative = (value) => path5.isAbsolute(value) ? path5.normalize(value) : path5.normalize(path5.resolve(anchor, value));
1069
1240
  if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1070
- logger5.debug("resolveTailwindcssBasedir anchor %O", {
1241
+ logger4.debug("resolveTailwindcssBasedir anchor %O", {
1071
1242
  basedir,
1072
1243
  envBasedir,
1073
1244
  envBasedirKey,
@@ -1105,12 +1276,12 @@ function resolveTailwindcssBasedir(basedir, fallback) {
1105
1276
  const anchorRequire = createRequire2(path5.join(anchor, "__resolve_tailwindcss_basedir__.cjs"));
1106
1277
  const packageJsonPath = anchorRequire.resolve(`${packageName}/package.json`);
1107
1278
  if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1108
- logger5.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
1279
+ logger4.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
1109
1280
  }
1110
1281
  return path5.normalize(path5.dirname(packageJsonPath));
1111
1282
  } catch {
1112
1283
  if (process3.env.WEAPP_TW_DEBUG_STACK === "1") {
1113
- logger5.debug("failed to resolve package json for %s", packageName);
1284
+ logger4.debug("failed to resolve package json for %s", packageName);
1114
1285
  }
1115
1286
  const workspaceRoot = findWorkspaceRoot(anchor);
1116
1287
  if (workspaceRoot) {
@@ -1128,7 +1299,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
1128
1299
  }
1129
1300
 
1130
1301
  // src/context/tailwindcss.ts
1131
- import { logger as logger6 } from "@weapp-tailwindcss/logger";
1302
+ import { logger as logger5 } from "@weapp-tailwindcss/logger";
1132
1303
 
1133
1304
  // src/context/tailwindcss/rax.ts
1134
1305
  import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
@@ -1208,7 +1379,7 @@ function createTailwindcssPatcherFromContext(ctx) {
1208
1379
  const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
1209
1380
  const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
1210
1381
  ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
1211
- logger6.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
1382
+ logger5.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
1212
1383
  let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
1213
1384
  if (!normalizedCssEntries) {
1214
1385
  normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
@@ -1254,13 +1425,19 @@ function createTailwindcssPatcherFromContext(ctx) {
1254
1425
  );
1255
1426
  }
1256
1427
 
1428
+ // src/logger/index.ts
1429
+ import { logger as logger6 } from "@weapp-tailwindcss/logger";
1430
+
1257
1431
  export {
1258
- findWorkspaceRoot,
1432
+ resolveTailwindcssOptions,
1433
+ invalidateRuntimeClassSet,
1434
+ getRuntimeClassSetCacheEntry,
1435
+ getRuntimeClassSetSignature,
1259
1436
  findNearestPackageRoot,
1260
1437
  warnMissingCssEntries,
1261
1438
  applyV4CssCalcDefaults,
1262
1439
  findTailwindConfig,
1263
1440
  resolveTailwindcssBasedir,
1264
1441
  createTailwindcssPatcherFromContext,
1265
- logger
1442
+ logger6 as logger
1266
1443
  };