weapp-tailwindcss 4.11.0-alpha.0 → 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-FV4ZRTAK.js → chunk-2W24MRCQ.js} +10 -12
  3. package/dist/chunk-4AFQP74Z.js +24 -0
  4. package/dist/{chunk-7XQXBJL6.js → chunk-4TTPYMVM.js} +12 -8
  5. package/dist/{chunk-RXNSOSCT.js → chunk-5KSBT6GU.js} +448 -270
  6. package/dist/{chunk-QX2A7SBB.mjs → chunk-66E76FQE.mjs} +666 -102
  7. package/dist/{chunk-WGFNCK5B.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-XGUD52TA.mjs → chunk-EW2K6CO5.mjs} +413 -235
  13. package/dist/{chunk-FMWKBZWX.mjs → chunk-HADJCWHU.mjs} +291 -265
  14. package/dist/{chunk-FKUPQQYX.js → chunk-K7CZXT46.js} +692 -125
  15. package/dist/{chunk-ACTJYB33.js → chunk-LL3QUKJI.js} +3 -1
  16. package/dist/{chunk-I4EOMKX2.js → chunk-LYGLQCWI.js} +356 -330
  17. package/dist/{chunk-LTJQUORK.js → chunk-OF6MFURR.js} +2 -0
  18. package/dist/{chunk-W3JO6LBC.mjs → chunk-RED7Y22U.mjs} +91 -10
  19. package/dist/{chunk-CLNUBO3Q.mjs → chunk-SJ3SG6DU.mjs} +5 -1
  20. package/dist/{chunk-OIDFSOER.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 +9 -9
  72. package/dist/chunk-EOK3NZVC.mjs +0 -29
  73. package/dist/chunk-PXZUQ7RR.js +0 -29
@@ -3,216 +3,15 @@
3
3
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
4
4
 
5
5
 
6
- var _chunkOV7FX6XRjs = require('./chunk-OV7FX6XR.js');
6
+ var _chunkCRDOWYG4js = require('./chunk-CRDOWYG4.js');
7
7
 
8
- // src/logger/index.ts
9
- var _logger = require('@weapp-tailwindcss/logger');
10
-
11
- // src/tailwindcss/v4/config.ts
12
-
13
- var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
14
- function includesToken(list, token) {
15
- return list.some((candidate) => {
16
- if (typeof token === "string") {
17
- if (typeof candidate === "string") {
18
- return candidate === token;
19
- }
20
- candidate.lastIndex = 0;
21
- return candidate.test(token);
22
- }
23
- if (typeof candidate === "string") {
24
- token.lastIndex = 0;
25
- return token.test(candidate);
26
- }
27
- return candidate.source === token.source && candidate.flags === token.flags;
28
- });
29
- }
30
- function ensureDefaultsIncluded(value) {
31
- if (value === true) {
32
- return {
33
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
34
- };
35
- }
36
- if (Array.isArray(value)) {
37
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
38
- return value;
39
- }
40
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
41
- return missing.length > 0 ? [...value, ...missing] : value;
42
- }
43
- if (value && typeof value === "object") {
44
- const include = value.includeCustomProperties;
45
- if (!Array.isArray(include)) {
46
- return {
47
- ...value,
48
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
49
- };
50
- }
51
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
52
- return value;
53
- }
54
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
55
- return missing.length > 0 ? {
56
- ...value,
57
- includeCustomProperties: [...include, ...missing]
58
- } : value;
59
- }
60
- return value;
61
- }
62
- function normalizeCssEntriesConfig(entries) {
63
- if (!entries) {
64
- return void 0;
65
- }
66
- if (typeof entries === "string") {
67
- const trimmed = entries.trim();
68
- return trimmed ? [trimmed] : void 0;
69
- }
70
- if (!Array.isArray(entries)) {
71
- return void 0;
72
- }
73
- const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
74
- return normalized.length > 0 ? normalized : void 0;
75
- }
76
- function hasConfiguredCssEntries(ctx) {
77
- if (normalizeCssEntriesConfig(ctx.cssEntries)) {
78
- return true;
79
- }
80
- if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _ => _.tailwindcss, 'optionalAccess', _2 => _2.v4, 'optionalAccess', _3 => _3.cssEntries]))) {
81
- return true;
82
- }
83
- const patcherOptions = ctx.tailwindcssPatcherOptions;
84
- if (patcherOptions) {
85
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _4 => _4.tailwindcss, 'optionalAccess', _5 => _5.v4, 'optionalAccess', _6 => _6.cssEntries]))) {
86
- return true;
87
- }
88
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _7 => _7.tailwind, 'optionalAccess', _8 => _8.v4, 'optionalAccess', _9 => _9.cssEntries]))) {
89
- return true;
90
- }
91
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _10 => _10.patch, 'optionalAccess', _11 => _11.tailwindcss, 'optionalAccess', _12 => _12.v4, 'optionalAccess', _13 => _13.cssEntries]))) {
92
- return true;
93
- }
94
- }
95
- return false;
96
- }
97
- var hasWarnedMissingCssEntries = false;
98
- function warnMissingCssEntries(ctx, patcher) {
99
- if (hasWarnedMissingCssEntries) {
100
- return;
101
- }
102
- if (_optionalChain([patcher, 'optionalAccess', _14 => _14.majorVersion]) !== 4) {
103
- return;
104
- }
105
- if (hasConfiguredCssEntries(ctx)) {
106
- return;
107
- }
108
- hasWarnedMissingCssEntries = true;
109
- _logger.logger.warn(
110
- '[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'
111
- );
112
- }
113
- function applyV4CssCalcDefaults(cssCalc, patcher) {
114
- const cssCalcOptions = _nullishCoalesce(cssCalc, () => ( _optionalChain([patcher, 'optionalAccess', _15 => _15.majorVersion]) === 4));
115
- if (_optionalChain([patcher, 'optionalAccess', _16 => _16.majorVersion]) === 4 && cssCalcOptions) {
116
- return ensureDefaultsIncluded(cssCalcOptions);
117
- }
118
- return cssCalcOptions;
119
- }
120
-
121
- // src/tailwindcss/v4/patcher.ts
122
-
123
-
124
- // src/tailwindcss/patcher.ts
125
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
126
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
127
-
128
- var _shared = require('@weapp-tailwindcss/shared');
129
- var _tailwindcsspatch = require('tailwindcss-patch');
130
-
131
- // src/context/workspace.ts
132
- var _fs = require('fs');
133
-
134
- var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
135
- "node_modules",
136
- ".git",
137
- ".hg",
138
- ".svn",
139
- ".turbo",
140
- ".output",
141
- ".next",
142
- "dist",
143
- "build"
144
- ]);
145
- function findWorkspaceRoot(startDir) {
146
- if (!startDir) {
147
- return void 0;
148
- }
149
- let current = _path2.default.resolve(startDir);
150
- while (true) {
151
- const workspaceFile = _path2.default.join(current, "pnpm-workspace.yaml");
152
- if (_fs.existsSync.call(void 0, workspaceFile)) {
153
- return current;
154
- }
155
- const parent = _path2.default.dirname(current);
156
- if (parent === current) {
157
- return void 0;
158
- }
159
- current = parent;
160
- }
161
- }
162
- function findNearestPackageRoot(startDir) {
163
- if (!startDir) {
8
+ // src/tailwindcss/patcher-options.ts
9
+ function resolveTailwindcssOptions(options) {
10
+ if (!options) {
164
11
  return void 0;
165
12
  }
166
- let current = _path2.default.resolve(startDir);
167
- while (true) {
168
- const pkgPath = _path2.default.join(current, "package.json");
169
- if (_fs.existsSync.call(void 0, pkgPath)) {
170
- return current;
171
- }
172
- const parent = _path2.default.dirname(current);
173
- if (parent === current) {
174
- return void 0;
175
- }
176
- current = parent;
177
- }
178
- }
179
- function findWorkspacePackageDir(rootDir, packageName) {
180
- const visited = /* @__PURE__ */ new Set();
181
- const queue = [_path2.default.resolve(rootDir)];
182
- while (queue.length > 0) {
183
- const current = queue.shift();
184
- const normalized = _path2.default.normalize(current);
185
- if (visited.has(normalized)) {
186
- continue;
187
- }
188
- visited.add(normalized);
189
- try {
190
- const pkgPath = _path2.default.join(normalized, "package.json");
191
- if (_fs.existsSync.call(void 0, pkgPath)) {
192
- const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf8"));
193
- if (_optionalChain([pkg, 'optionalAccess', _17 => _17.name]) === packageName) {
194
- return normalized;
195
- }
196
- }
197
- } catch (e) {
198
- }
199
- let entries;
200
- try {
201
- entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
202
- } catch (e2) {
203
- continue;
204
- }
205
- for (const entry of entries) {
206
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || _optionalChain([entry, 'access', _18 => _18.isSymbolicLink, 'optionalCall', _19 => _19()])) {
207
- continue;
208
- }
209
- queue.push(_path2.default.join(normalized, entry.name));
210
- }
211
- }
212
- return void 0;
13
+ return _nullishCoalesce(options.tailwindcss, () => ( options.tailwind));
213
14
  }
214
-
215
- // src/tailwindcss/patcher-options.ts
216
15
  function normalizeExtendLengthUnits(value) {
217
16
  if (value === false) {
218
17
  return false;
@@ -240,26 +39,26 @@ function normalizeTailwindcssPatcherOptions(options) {
240
39
  }
241
40
  const apply = {};
242
41
  const extract = {};
243
- if (_optionalChain([patch, 'optionalAccess', _20 => _20.overwrite]) !== void 0) {
42
+ if (_optionalChain([patch, 'optionalAccess', _ => _.overwrite]) !== void 0) {
244
43
  apply.overwrite = patch.overwrite;
245
44
  }
246
- if (_optionalChain([patch, 'optionalAccess', _21 => _21.filter])) {
45
+ if (_optionalChain([patch, 'optionalAccess', _2 => _2.filter])) {
247
46
  normalized.filter = patch.filter;
248
47
  }
249
- const extendLengthUnits = normalizeExtendLengthUnits(_optionalChain([patch, 'optionalAccess', _22 => _22.applyPatches, 'optionalAccess', _23 => _23.extendLengthUnits]));
250
- const exposeContext = _optionalChain([patch, 'optionalAccess', _24 => _24.applyPatches, 'optionalAccess', _25 => _25.exportContext]);
48
+ const extendLengthUnits = normalizeExtendLengthUnits(_optionalChain([patch, 'optionalAccess', _3 => _3.applyPatches, 'optionalAccess', _4 => _4.extendLengthUnits]));
49
+ const exposeContext = _optionalChain([patch, 'optionalAccess', _5 => _5.applyPatches, 'optionalAccess', _6 => _6.exportContext]);
251
50
  if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
252
51
  apply.exposeContext = exposeContext;
253
52
  apply.extendLengthUnits = extendLengthUnits;
254
53
  }
255
- const cwd = _nullishCoalesce(_optionalChain([patch, 'optionalAccess', _26 => _26.cwd]), () => ( _optionalChain([patch, 'optionalAccess', _27 => _27.basedir])));
54
+ const cwd = _nullishCoalesce(_optionalChain([patch, 'optionalAccess', _7 => _7.cwd]), () => ( _optionalChain([patch, 'optionalAccess', _8 => _8.basedir])));
256
55
  if (cwd) {
257
56
  normalized.projectRoot = cwd;
258
57
  }
259
- const tailwindOptions = _optionalChain([patch, 'optionalAccess', _28 => _28.tailwindcss]) ? { ...patch.tailwindcss } : void 0;
260
- const legacyResolve = _optionalChain([patch, 'optionalAccess', _29 => _29.resolve]);
58
+ const tailwindOptions = _optionalChain([patch, 'optionalAccess', _9 => _9.tailwindcss]) ? { ...patch.tailwindcss } : void 0;
59
+ const legacyResolve = _optionalChain([patch, 'optionalAccess', _10 => _10.resolve]);
261
60
  let nextTailwindOptions = tailwindOptions;
262
- if (_optionalChain([nextTailwindOptions, 'optionalAccess', _30 => _30.version]) === 2 && !nextTailwindOptions.packageName) {
61
+ if (_optionalChain([nextTailwindOptions, 'optionalAccess', _11 => _11.version]) === 2 && !nextTailwindOptions.packageName) {
263
62
  nextTailwindOptions = {
264
63
  ...nextTailwindOptions,
265
64
  packageName: "@tailwindcss/postcss7-compat",
@@ -270,7 +69,7 @@ function normalizeTailwindcssPatcherOptions(options) {
270
69
  }
271
70
  }
272
71
  if (nextTailwindOptions || legacyResolve) {
273
- const resolveOptions = _optionalChain([nextTailwindOptions, 'optionalAccess', _31 => _31.resolve]);
72
+ const resolveOptions = _optionalChain([nextTailwindOptions, 'optionalAccess', _12 => _12.resolve]);
274
73
  const mergedResolve = legacyResolve || resolveOptions ? {
275
74
  ..._nullishCoalesce(resolveOptions, () => ( {})),
276
75
  ..._nullishCoalesce(legacyResolve, () => ( {}))
@@ -280,7 +79,7 @@ function normalizeTailwindcssPatcherOptions(options) {
280
79
  ...mergedResolve ? { resolve: mergedResolve } : {}
281
80
  };
282
81
  }
283
- if (_optionalChain([patch, 'optionalAccess', _32 => _32.output])) {
82
+ if (_optionalChain([patch, 'optionalAccess', _13 => _13.output])) {
284
83
  if (patch.output.filename !== void 0) {
285
84
  extract.file = patch.output.filename;
286
85
  }
@@ -316,7 +115,7 @@ function toModernTailwindcssPatchOptions(options) {
316
115
  if (projectRoot) {
317
116
  normalized.projectRoot = projectRoot;
318
117
  }
319
- const tailwindcss = _nullishCoalesce(options.tailwindcss, () => ( options.tailwind));
118
+ const tailwindcss = resolveTailwindcssOptions(options);
320
119
  if (tailwindcss) {
321
120
  normalized.tailwindcss = {
322
121
  ...tailwindcss
@@ -328,10 +127,10 @@ function toModernTailwindcssPatchOptions(options) {
328
127
  if (apply.overwrite === void 0 && options.overwrite !== void 0) {
329
128
  apply.overwrite = options.overwrite;
330
129
  }
331
- if (apply.exposeContext === void 0 && _optionalChain([options, 'access', _33 => _33.features, 'optionalAccess', _34 => _34.exposeContext]) !== void 0) {
130
+ if (apply.exposeContext === void 0 && _optionalChain([options, 'access', _14 => _14.features, 'optionalAccess', _15 => _15.exposeContext]) !== void 0) {
332
131
  apply.exposeContext = options.features.exposeContext;
333
132
  }
334
- if (apply.extendLengthUnits === void 0 && _optionalChain([options, 'access', _35 => _35.features, 'optionalAccess', _36 => _36.extendLengthUnits]) !== void 0) {
133
+ if (apply.extendLengthUnits === void 0 && _optionalChain([options, 'access', _16 => _16.features, 'optionalAccess', _17 => _17.extendLengthUnits]) !== void 0) {
335
134
  apply.extendLengthUnits = options.features.extendLengthUnits;
336
135
  }
337
136
  if (Object.keys(apply).length > 0) {
@@ -363,11 +162,345 @@ function toModernTailwindcssPatchOptions(options) {
363
162
  return normalized;
364
163
  }
365
164
 
165
+ // src/tailwindcss/runtime/cache.ts
166
+ var _fs = require('fs');
167
+ var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
168
+ var runtimeFileSignatureCache = /* @__PURE__ */ new Map();
169
+ var runtimeFileSignatureCacheClearTimer;
170
+ var runtimeSignaturePatchersSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
171
+ function getCacheEntry(twPatcher) {
172
+ let entry = runtimeClassSetCache.get(twPatcher);
173
+ if (!entry) {
174
+ entry = {};
175
+ runtimeClassSetCache.set(twPatcher, entry);
176
+ }
177
+ return entry;
178
+ }
179
+ function scheduleRuntimeConfigSignatureCacheClear() {
180
+ if (runtimeFileSignatureCacheClearTimer) {
181
+ return;
182
+ }
183
+ runtimeFileSignatureCacheClearTimer = setTimeout(() => {
184
+ runtimeFileSignatureCache.clear();
185
+ runtimeFileSignatureCacheClearTimer = void 0;
186
+ }, 0);
187
+ _optionalChain([runtimeFileSignatureCacheClearTimer, 'access', _18 => _18.unref, 'optionalCall', _19 => _19()]);
188
+ }
189
+ function getFileSignature(filePath) {
190
+ const cached = runtimeFileSignatureCache.get(filePath);
191
+ if (cached !== void 0) {
192
+ return cached;
193
+ }
194
+ let signature;
195
+ try {
196
+ const stats = _fs.statSync.call(void 0, filePath);
197
+ signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
198
+ } catch (e) {
199
+ signature = `${filePath}:missing`;
200
+ }
201
+ runtimeFileSignatureCache.set(filePath, signature);
202
+ scheduleRuntimeConfigSignatureCacheClear();
203
+ return signature;
204
+ }
205
+ function getTailwindTrackedFiles(twPatcher) {
206
+ const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
207
+ const tracked = /* @__PURE__ */ new Set();
208
+ const configPath = _optionalChain([tailwindOptions, 'optionalAccess', _20 => _20.config]);
209
+ if (typeof configPath === "string" && configPath.length > 0) {
210
+ tracked.add(configPath);
211
+ }
212
+ for (const entry of _nullishCoalesce(_optionalChain([tailwindOptions, 'optionalAccess', _21 => _21.v4, 'optionalAccess', _22 => _22.cssEntries]), () => ( []))) {
213
+ if (typeof entry === "string" && entry.length > 0) {
214
+ tracked.add(entry);
215
+ }
216
+ }
217
+ return tracked;
218
+ }
219
+ function normalizeSignatureValue(value) {
220
+ if (value == null) {
221
+ return "null";
222
+ }
223
+ if (typeof value === "string") {
224
+ return value;
225
+ }
226
+ if (typeof value === "number" || typeof value === "boolean") {
227
+ return String(value);
228
+ }
229
+ if (Array.isArray(value)) {
230
+ return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
231
+ }
232
+ if (typeof value === "object") {
233
+ const entries = Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b));
234
+ return `{${entries.map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
235
+ }
236
+ return String(value);
237
+ }
238
+ function getTailwindOptionsSignature(twPatcher) {
239
+ const options = twPatcher.options;
240
+ const tailwindOptions = resolveTailwindcssOptions(options);
241
+ return normalizeSignatureValue({
242
+ projectRoot: _optionalChain([options, 'optionalAccess', _23 => _23.projectRoot]),
243
+ packageName: _optionalChain([tailwindOptions, 'optionalAccess', _24 => _24.packageName]),
244
+ versionHint: _optionalChain([tailwindOptions, 'optionalAccess', _25 => _25.versionHint]),
245
+ cwd: _optionalChain([tailwindOptions, 'optionalAccess', _26 => _26.cwd]),
246
+ config: _optionalChain([tailwindOptions, 'optionalAccess', _27 => _27.config]),
247
+ v2: _optionalChain([tailwindOptions, 'optionalAccess', _28 => _28.v2]),
248
+ v3: _optionalChain([tailwindOptions, 'optionalAccess', _29 => _29.v3]),
249
+ v4: {
250
+ base: _optionalChain([tailwindOptions, 'optionalAccess', _30 => _30.v4, 'optionalAccess', _31 => _31.base]),
251
+ configuredBase: _optionalChain([tailwindOptions, 'optionalAccess', _32 => _32.v4, 'optionalAccess', _33 => _33.configuredBase]),
252
+ css: _optionalChain([tailwindOptions, 'optionalAccess', _34 => _34.v4, 'optionalAccess', _35 => _35.css]),
253
+ cssEntries: _optionalChain([tailwindOptions, 'optionalAccess', _36 => _36.v4, 'optionalAccess', _37 => _37.cssEntries]),
254
+ hasUserDefinedSources: _optionalChain([tailwindOptions, 'optionalAccess', _38 => _38.v4, 'optionalAccess', _39 => _39.hasUserDefinedSources]),
255
+ sources: _optionalChain([tailwindOptions, 'optionalAccess', _40 => _40.v4, 'optionalAccess', _41 => _41.sources])
256
+ }
257
+ });
258
+ }
259
+ function getPatchTargetSignature(twPatcher) {
260
+ const packageInfo = twPatcher.packageInfo;
261
+ return [
262
+ _nullishCoalesce(_optionalChain([packageInfo, 'optionalAccess', _42 => _42.name]), () => ( "missing")),
263
+ _nullishCoalesce(_optionalChain([packageInfo, 'optionalAccess', _43 => _43.rootPath]), () => ( "missing")),
264
+ _nullishCoalesce(_optionalChain([packageInfo, 'optionalAccess', _44 => _44.version]), () => ( "unknown")),
265
+ _nullishCoalesce(twPatcher.majorVersion, () => ( "unknown")),
266
+ getTailwindOptionsSignature(twPatcher)
267
+ ].join(":");
268
+ }
269
+ function getNestedPatchers(twPatcher) {
270
+ const nested = twPatcher[runtimeSignaturePatchersSymbol];
271
+ return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
272
+ }
273
+ function getOwnRuntimeClassSetSignature(twPatcher) {
274
+ const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
275
+ const configSignature = trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing";
276
+ const patchTargetSignature = getPatchTargetSignature(twPatcher);
277
+ return `${configSignature}|patch:${patchTargetSignature}`;
278
+ }
279
+ function invalidateRuntimeClassSet(twPatcher) {
280
+ if (!twPatcher) {
281
+ return;
282
+ }
283
+ const nestedPatchers = getNestedPatchers(twPatcher);
284
+ if (nestedPatchers) {
285
+ for (const patcher of nestedPatchers) {
286
+ invalidateRuntimeClassSet(patcher);
287
+ }
288
+ }
289
+ for (const trackedFile of getTailwindTrackedFiles(twPatcher)) {
290
+ runtimeFileSignatureCache.delete(trackedFile);
291
+ }
292
+ runtimeClassSetCache.delete(twPatcher);
293
+ }
294
+ function getRuntimeClassSetCacheEntry(twPatcher) {
295
+ return getCacheEntry(twPatcher);
296
+ }
297
+ function getRuntimeClassSetSignature(twPatcher) {
298
+ const nestedPatchers = getNestedPatchers(twPatcher);
299
+ if (nestedPatchers) {
300
+ return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
301
+ }
302
+ return getOwnRuntimeClassSetSignature(twPatcher);
303
+ }
304
+
305
+ // src/context/workspace.ts
306
+
307
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
308
+ var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
309
+ "node_modules",
310
+ ".git",
311
+ ".hg",
312
+ ".svn",
313
+ ".turbo",
314
+ ".output",
315
+ ".next",
316
+ "dist",
317
+ "build"
318
+ ]);
319
+ function findWorkspaceRoot(startDir) {
320
+ if (!startDir) {
321
+ return void 0;
322
+ }
323
+ let current = _path2.default.resolve(startDir);
324
+ while (true) {
325
+ const workspaceFile = _path2.default.join(current, "pnpm-workspace.yaml");
326
+ if (_fs.existsSync.call(void 0, workspaceFile)) {
327
+ return current;
328
+ }
329
+ const parent = _path2.default.dirname(current);
330
+ if (parent === current) {
331
+ return void 0;
332
+ }
333
+ current = parent;
334
+ }
335
+ }
336
+ function findNearestPackageRoot(startDir) {
337
+ if (!startDir) {
338
+ return void 0;
339
+ }
340
+ let current = _path2.default.resolve(startDir);
341
+ while (true) {
342
+ const pkgPath = _path2.default.join(current, "package.json");
343
+ if (_fs.existsSync.call(void 0, pkgPath)) {
344
+ return current;
345
+ }
346
+ const parent = _path2.default.dirname(current);
347
+ if (parent === current) {
348
+ return void 0;
349
+ }
350
+ current = parent;
351
+ }
352
+ }
353
+ function findWorkspacePackageDir(rootDir, packageName) {
354
+ const visited = /* @__PURE__ */ new Set();
355
+ const queue = [_path2.default.resolve(rootDir)];
356
+ while (queue.length > 0) {
357
+ const current = queue.shift();
358
+ const normalized = _path2.default.normalize(current);
359
+ if (visited.has(normalized)) {
360
+ continue;
361
+ }
362
+ visited.add(normalized);
363
+ try {
364
+ const pkgPath = _path2.default.join(normalized, "package.json");
365
+ if (_fs.existsSync.call(void 0, pkgPath)) {
366
+ const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf8"));
367
+ if (_optionalChain([pkg, 'optionalAccess', _45 => _45.name]) === packageName) {
368
+ return normalized;
369
+ }
370
+ }
371
+ } catch (e2) {
372
+ }
373
+ let entries;
374
+ try {
375
+ entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
376
+ } catch (e3) {
377
+ continue;
378
+ }
379
+ for (const entry of entries) {
380
+ if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || _optionalChain([entry, 'access', _46 => _46.isSymbolicLink, 'optionalCall', _47 => _47()])) {
381
+ continue;
382
+ }
383
+ queue.push(_path2.default.join(normalized, entry.name));
384
+ }
385
+ }
386
+ return void 0;
387
+ }
388
+
389
+ // src/tailwindcss/v4/config.ts
390
+ var _logger = require('@weapp-tailwindcss/logger');
391
+ var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
392
+ function includesToken(list, token) {
393
+ return list.some((candidate) => {
394
+ if (typeof token === "string") {
395
+ if (typeof candidate === "string") {
396
+ return candidate === token;
397
+ }
398
+ candidate.lastIndex = 0;
399
+ return candidate.test(token);
400
+ }
401
+ if (typeof candidate === "string") {
402
+ token.lastIndex = 0;
403
+ return token.test(candidate);
404
+ }
405
+ return candidate.source === token.source && candidate.flags === token.flags;
406
+ });
407
+ }
408
+ function ensureDefaultsIncluded(value) {
409
+ if (value === true) {
410
+ return {
411
+ includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
412
+ };
413
+ }
414
+ if (Array.isArray(value)) {
415
+ if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
416
+ return value;
417
+ }
418
+ const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
419
+ return missing.length > 0 ? [...value, ...missing] : value;
420
+ }
421
+ if (value && typeof value === "object") {
422
+ const include = value.includeCustomProperties;
423
+ if (!Array.isArray(include)) {
424
+ return {
425
+ ...value,
426
+ includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
427
+ };
428
+ }
429
+ if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
430
+ return value;
431
+ }
432
+ const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
433
+ return missing.length > 0 ? {
434
+ ...value,
435
+ includeCustomProperties: [...include, ...missing]
436
+ } : value;
437
+ }
438
+ return value;
439
+ }
440
+ function normalizeCssEntriesConfig(entries) {
441
+ if (!entries) {
442
+ return void 0;
443
+ }
444
+ if (typeof entries === "string") {
445
+ const trimmed = entries.trim();
446
+ return trimmed ? [trimmed] : void 0;
447
+ }
448
+ if (!Array.isArray(entries)) {
449
+ return void 0;
450
+ }
451
+ const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
452
+ return normalized.length > 0 ? normalized : void 0;
453
+ }
454
+ function hasConfiguredCssEntries(ctx) {
455
+ if (normalizeCssEntriesConfig(ctx.cssEntries)) {
456
+ return true;
457
+ }
458
+ if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _48 => _48.tailwindcss, 'optionalAccess', _49 => _49.v4, 'optionalAccess', _50 => _50.cssEntries]))) {
459
+ return true;
460
+ }
461
+ const patcherOptions = ctx.tailwindcssPatcherOptions;
462
+ if (patcherOptions) {
463
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _51 => _51.tailwindcss, 'optionalAccess', _52 => _52.v4, 'optionalAccess', _53 => _53.cssEntries]))) {
464
+ return true;
465
+ }
466
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _54 => _54.tailwind, 'optionalAccess', _55 => _55.v4, 'optionalAccess', _56 => _56.cssEntries]))) {
467
+ return true;
468
+ }
469
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _57 => _57.patch, 'optionalAccess', _58 => _58.tailwindcss, 'optionalAccess', _59 => _59.v4, 'optionalAccess', _60 => _60.cssEntries]))) {
470
+ return true;
471
+ }
472
+ }
473
+ return false;
474
+ }
475
+ var hasWarnedMissingCssEntries = false;
476
+ function warnMissingCssEntries(ctx, patcher) {
477
+ if (hasWarnedMissingCssEntries) {
478
+ return;
479
+ }
480
+ if (_optionalChain([patcher, 'optionalAccess', _61 => _61.majorVersion]) !== 4) {
481
+ return;
482
+ }
483
+ if (hasConfiguredCssEntries(ctx)) {
484
+ return;
485
+ }
486
+ hasWarnedMissingCssEntries = true;
487
+ _logger.logger.warn(
488
+ '[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'
489
+ );
490
+ }
491
+ function applyV4CssCalcDefaults(cssCalc, patcher) {
492
+ const cssCalcOptions = _nullishCoalesce(cssCalc, () => ( _optionalChain([patcher, 'optionalAccess', _62 => _62.majorVersion]) === 4));
493
+ if (_optionalChain([patcher, 'optionalAccess', _63 => _63.majorVersion]) === 4 && cssCalcOptions) {
494
+ return ensureDefaultsIncluded(cssCalcOptions);
495
+ }
496
+ return cssCalcOptions;
497
+ }
498
+
366
499
  // src/tailwindcss/patcher-resolve.ts
367
500
 
368
501
  var _module = require('module');
369
502
 
370
-
503
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
371
504
  var _url = require('url');
372
505
  var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
373
506
  var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
@@ -399,9 +532,9 @@ function resolveModuleFromPaths(specifier, paths) {
399
532
  return void 0;
400
533
  }
401
534
  try {
402
- const req = _module.createRequire.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
535
+ const req = _module.createRequire.call(void 0, _chunkCRDOWYG4js.importMetaUrl);
403
536
  return req.resolve(specifier, { paths });
404
- } catch (e3) {
537
+ } catch (e4) {
405
538
  return void 0;
406
539
  }
407
540
  }
@@ -454,11 +587,11 @@ function createDefaultResolvePaths(basedir) {
454
587
  const cwd = _process2.default.cwd();
455
588
  appendNodeModules(paths, cwd);
456
589
  try {
457
- const modulePath = _url.fileURLToPath.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
590
+ const modulePath = _url.fileURLToPath.call(void 0, _chunkCRDOWYG4js.importMetaUrl);
458
591
  const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
459
592
  paths.add(candidate);
460
- } catch (e4) {
461
- paths.add(_chunkOV7FX6XRjs.importMetaUrl);
593
+ } catch (e5) {
594
+ paths.add(_chunkCRDOWYG4js.importMetaUrl);
462
595
  }
463
596
  if (paths.size === 0) {
464
597
  fallbackCandidates = fallbackCandidates.filter(Boolean);
@@ -472,7 +605,15 @@ function createDefaultResolvePaths(basedir) {
472
605
  return [...paths];
473
606
  }
474
607
 
608
+ // src/tailwindcss/v4/patcher.ts
609
+
610
+
475
611
  // src/tailwindcss/patcher.ts
612
+
613
+
614
+
615
+ var _shared = require('@weapp-tailwindcss/shared');
616
+ var _tailwindcsspatch = require('tailwindcss-patch');
476
617
  function createFallbackTailwindcssPatcher() {
477
618
  const packageInfo = {
478
619
  name: "tailwindcss",
@@ -512,6 +653,9 @@ function createFallbackTailwindcssPatcher() {
512
653
  var hasLoggedMissingTailwind = false;
513
654
  var TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
514
655
  var UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
656
+ function isTailwindcssV4PackageName(packageName) {
657
+ return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
658
+ }
515
659
  function createTailwindcssPatcher(options) {
516
660
  const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
517
661
  const cache = {
@@ -556,7 +700,7 @@ function createTailwindcssPatcher(options) {
556
700
  baseTailwindOptions.packageName = "tailwindcss";
557
701
  }
558
702
  if (!baseTailwindOptions.postcssPlugin) {
559
- baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 ? "@tailwindcss/postcss" : "tailwindcss";
703
+ baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
560
704
  }
561
705
  if (typeof baseTailwindOptions.postcssPlugin === "string") {
562
706
  const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
@@ -596,7 +740,7 @@ function createTailwindcssPatcher(options) {
596
740
  if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
597
741
  const resolvedPlugin = resolveModuleFromPaths(
598
742
  resolvedTailwindOptions.postcssPlugin,
599
- _nullishCoalesce(_optionalChain([resolvedTailwindOptions, 'access', _37 => _37.resolve, 'optionalAccess', _38 => _38.paths]), () => ( resolvePaths))
743
+ _nullishCoalesce(_optionalChain([resolvedTailwindOptions, 'access', _64 => _64.resolve, 'optionalAccess', _65 => _65.paths]), () => ( resolvePaths))
600
744
  );
601
745
  if (resolvedPlugin) {
602
746
  resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
@@ -606,7 +750,7 @@ function createTailwindcssPatcher(options) {
606
750
  if (resolvedTailwindOptions.cwd) {
607
751
  searchRoots.add(resolvedTailwindOptions.cwd);
608
752
  }
609
- for (const resolvePath of _nullishCoalesce(_optionalChain([resolvedTailwindOptions, 'access', _39 => _39.resolve, 'optionalAccess', _40 => _40.paths]), () => ( []))) {
753
+ for (const resolvePath of _nullishCoalesce(_optionalChain([resolvedTailwindOptions, 'access', _66 => _66.resolve, 'optionalAccess', _67 => _67.paths]), () => ( []))) {
610
754
  const parentDir = _path2.default.dirname(resolvePath);
611
755
  searchRoots.add(parentDir);
612
756
  }
@@ -632,7 +776,7 @@ function createTailwindcssPatcher(options) {
632
776
  try {
633
777
  return new (0, _tailwindcsspatch.TailwindcssPatcher)(resolvedOptions);
634
778
  } catch (error) {
635
- const searchPaths = _optionalChain([resolvedOptions, 'access', _41 => _41.tailwindcss, 'optionalAccess', _42 => _42.resolve, 'optionalAccess', _43 => _43.paths]);
779
+ const searchPaths = _optionalChain([resolvedOptions, 'access', _68 => _68.tailwindcss, 'optionalAccess', _69 => _69.resolve, 'optionalAccess', _70 => _70.paths]);
636
780
  if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
637
781
  if (!hasLoggedMissingTailwind) {
638
782
  _logger.logger.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");
@@ -641,7 +785,7 @@ function createTailwindcssPatcher(options) {
641
785
  return createFallbackTailwindcssPatcher();
642
786
  }
643
787
  if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) {
644
- _logger.logger.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', _optionalChain([resolvedOptions, 'access', _44 => _44.tailwindcss, 'optionalAccess', _45 => _45.packageName]), searchPaths);
788
+ _logger.logger.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', _optionalChain([resolvedOptions, 'access', _71 => _71.tailwindcss, 'optionalAccess', _72 => _72.packageName]), searchPaths);
645
789
  }
646
790
  throw error;
647
791
  }
@@ -655,18 +799,18 @@ function createMultiTailwindcssPatcher(patchers) {
655
799
  const [first] = patchers;
656
800
  const multiPatcher = {
657
801
  ...first,
658
- packageInfo: _optionalChain([first, 'optionalAccess', _46 => _46.packageInfo]),
659
- majorVersion: _optionalChain([first, 'optionalAccess', _47 => _47.majorVersion]),
660
- options: _optionalChain([first, 'optionalAccess', _48 => _48.options]),
802
+ packageInfo: _optionalChain([first, 'optionalAccess', _73 => _73.packageInfo]),
803
+ majorVersion: _optionalChain([first, 'optionalAccess', _74 => _74.majorVersion]),
804
+ options: _optionalChain([first, 'optionalAccess', _75 => _75.options]),
661
805
  async patch() {
662
806
  let exposeContext;
663
807
  let extendLengthUnits;
664
808
  for (const patcher of patchers) {
665
809
  const result = await patcher.patch();
666
- if (_optionalChain([result, 'optionalAccess', _49 => _49.exposeContext]) && exposeContext == null) {
810
+ if (_optionalChain([result, 'optionalAccess', _76 => _76.exposeContext]) && exposeContext == null) {
667
811
  exposeContext = result.exposeContext;
668
812
  }
669
- if (_optionalChain([result, 'optionalAccess', _50 => _50.extendLengthUnits]) && extendLengthUnits == null) {
813
+ if (_optionalChain([result, 'optionalAccess', _77 => _77.extendLengthUnits]) && extendLengthUnits == null) {
670
814
  extendLengthUnits = result.extendLengthUnits;
671
815
  }
672
816
  }
@@ -722,7 +866,7 @@ function createMultiTailwindcssPatcher(patchers) {
722
866
  multiPatcher.getClassSetSync = () => {
723
867
  const aggregated = /* @__PURE__ */ new Set();
724
868
  for (const patcher of patchers) {
725
- const current = _optionalChain([patcher, 'access', _51 => _51.getClassSetSync, 'optionalCall', _52 => _52()]);
869
+ const current = _optionalChain([patcher, 'access', _78 => _78.getClassSetSync, 'optionalCall', _79 => _79()]);
726
870
  if (!current) {
727
871
  continue;
728
872
  }
@@ -733,6 +877,10 @@ function createMultiTailwindcssPatcher(patchers) {
733
877
  return aggregated;
734
878
  };
735
879
  }
880
+ Object.defineProperty(multiPatcher, runtimeSignaturePatchersSymbol, {
881
+ value: [...patchers],
882
+ configurable: true
883
+ });
736
884
  return multiPatcher;
737
885
  }
738
886
 
@@ -794,8 +942,8 @@ function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries)
794
942
  ...modernTailwind,
795
943
  v4: {
796
944
  ..._nullishCoalesce(modernTailwind.v4, () => ( {})),
797
- ...hasCssEntries ? {} : { base: _nullishCoalesce(_optionalChain([modernTailwind, 'access', _53 => _53.v4, 'optionalAccess', _54 => _54.base]), () => ( baseDir)) },
798
- cssEntries: hasCssEntries ? cssEntries : _nullishCoalesce(_optionalChain([modernTailwind, 'access', _55 => _55.v4, 'optionalAccess', _56 => _56.cssEntries]), () => ( cssEntries))
945
+ ...hasCssEntries ? {} : { base: _nullishCoalesce(_optionalChain([modernTailwind, 'access', _80 => _80.v4, 'optionalAccess', _81 => _81.base]), () => ( baseDir)) },
946
+ cssEntries: hasCssEntries ? cssEntries : _nullishCoalesce(_optionalChain([modernTailwind, 'access', _82 => _82.v4, 'optionalAccess', _83 => _83.cssEntries]), () => ( cssEntries))
799
947
  }
800
948
  }
801
949
  };
@@ -883,13 +1031,26 @@ function groupCssEntriesByBase(entries, options = {}) {
883
1031
  }
884
1032
 
885
1033
  // src/tailwindcss/v4/patcher.ts
1034
+ var CONFIGURED_TAILWIND_VERSION_RE = /Configured tailwindcss\.version=\d+/u;
1035
+ var RESOLVED_TAILWIND_VERSION_RE = /resolved package ".+" is version /u;
1036
+ function isTailwindcss4Package(packageName) {
1037
+ return Boolean(
1038
+ packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4"))
1039
+ );
1040
+ }
1041
+ function hasOwnV4Signal(value) {
1042
+ return typeof value === "object" && value !== null && "v4" in value;
1043
+ }
1044
+ function isTailwindVersionMismatchError(error) {
1045
+ return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
1046
+ }
886
1047
  function createPatcherForBase(baseDir, cssEntries, options) {
887
1048
  const {
888
1049
  tailwindcss,
889
1050
  tailwindcssPatcherOptions,
890
1051
  supportCustomLengthUnitsPatch
891
1052
  } = options;
892
- const hasCssEntries = Boolean(_optionalChain([cssEntries, 'optionalAccess', _57 => _57.length]));
1053
+ const hasCssEntries = Boolean(_optionalChain([cssEntries, 'optionalAccess', _84 => _84.length]));
893
1054
  const defaultTailwindcssConfig = {
894
1055
  cwd: baseDir,
895
1056
  v2: {
@@ -903,9 +1064,6 @@ function createPatcherForBase(baseDir, cssEntries, options) {
903
1064
  cssEntries
904
1065
  }
905
1066
  };
906
- if (hasCssEntries && (tailwindcss == null || tailwindcss.version == null)) {
907
- defaultTailwindcssConfig.version = 4;
908
- }
909
1067
  const mergedTailwindOptions = _chunkDYLQ6UOIjs.defuOverrideArray.call(void 0,
910
1068
  _nullishCoalesce(tailwindcss, () => ( {})),
911
1069
  defaultTailwindcssConfig
@@ -920,7 +1078,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
920
1078
  mergedTailwindOptions.v4.base = baseDir;
921
1079
  }
922
1080
  if (hasCssEntries) {
923
- if (_optionalChain([cssEntries, 'optionalAccess', _58 => _58.length])) {
1081
+ if (_optionalChain([cssEntries, 'optionalAccess', _85 => _85.length])) {
924
1082
  mergedTailwindOptions.v4.cssEntries = cssEntries;
925
1083
  } else if (!mergedTailwindOptions.v4.cssEntries) {
926
1084
  mergedTailwindOptions.v4.cssEntries = [];
@@ -934,12 +1092,10 @@ function createPatcherForBase(baseDir, cssEntries, options) {
934
1092
  baseDir,
935
1093
  _nullishCoalesce(cssEntries, () => ( []))
936
1094
  );
937
- const configuredPackageName = _optionalChain([tailwindcss, 'optionalAccess', _59 => _59.packageName]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _60 => _60.tailwindcss, 'optionalAccess', _61 => _61.packageName]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _62 => _62.tailwind, 'optionalAccess', _63 => _63.packageName]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _64 => _64.patch, 'optionalAccess', _65 => _65.tailwindcss, 'optionalAccess', _66 => _66.packageName]);
938
- const configuredVersion = _optionalChain([tailwindcss, 'optionalAccess', _67 => _67.version]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _68 => _68.tailwindcss, 'optionalAccess', _69 => _69.version]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _70 => _70.tailwind, 'optionalAccess', _71 => _71.version]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _72 => _72.patch, 'optionalAccess', _73 => _73.tailwindcss, 'optionalAccess', _74 => _74.version]) || mergedTailwindOptions.version;
939
- const isTailwindcss4Package = (packageName) => Boolean(
940
- packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4"))
941
- );
942
- const isV4 = configuredVersion === 4 || mergedTailwindOptions.version === 4 || isTailwindcss4Package(_nullishCoalesce(configuredPackageName, () => ( mergedTailwindOptions.packageName)));
1095
+ const configuredPackageName = _optionalChain([tailwindcss, 'optionalAccess', _86 => _86.packageName]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _87 => _87.tailwindcss, 'optionalAccess', _88 => _88.packageName]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _89 => _89.tailwind, 'optionalAccess', _90 => _90.packageName]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _91 => _91.patch, 'optionalAccess', _92 => _92.tailwindcss, 'optionalAccess', _93 => _93.packageName]);
1096
+ const configuredVersion = _optionalChain([tailwindcss, 'optionalAccess', _94 => _94.version]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _95 => _95.tailwindcss, 'optionalAccess', _96 => _96.version]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _97 => _97.tailwind, 'optionalAccess', _98 => _98.version]) || _optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _99 => _99.patch, 'optionalAccess', _100 => _100.tailwindcss, 'optionalAccess', _101 => _101.version]) || mergedTailwindOptions.version;
1097
+ const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(_optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _102 => _102.tailwindcss])) || hasOwnV4Signal(_optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _103 => _103.tailwind])) || hasOwnV4Signal(_optionalChain([tailwindcssPatcherOptions, 'optionalAccess', _104 => _104.patch, 'optionalAccess', _105 => _105.tailwindcss]));
1098
+ const isV4 = configuredVersion === 4 || mergedTailwindOptions.version === 4 || isTailwindcss4Package(_nullishCoalesce(configuredPackageName, () => ( mergedTailwindOptions.packageName))) || hasExplicitV4Signals;
943
1099
  const tailwindPackageConfigured = Boolean(configuredPackageName);
944
1100
  const shouldPatchV4PostcssPackage = isV4 && !tailwindPackageConfigured;
945
1101
  const packageCandidates = /* @__PURE__ */ new Set();
@@ -949,18 +1105,33 @@ function createPatcherForBase(baseDir, cssEntries, options) {
949
1105
  packageCandidates.add(
950
1106
  _nullishCoalesce(_nullishCoalesce(mergedTailwindOptions.packageName, () => ( configuredPackageName)), () => ( "tailwindcss"))
951
1107
  );
952
- const patchers = Array.from(packageCandidates, (packageName) => {
1108
+ const patchers = [];
1109
+ const packageCandidateList = [...packageCandidates];
1110
+ let firstVersionMismatchError;
1111
+ for (const packageName of packageCandidateList) {
953
1112
  const tailwindOptionsForPackage = {
954
1113
  ...mergedTailwindOptions,
955
1114
  packageName
956
1115
  };
957
- return createTailwindcssPatcher({
958
- basedir: baseDir,
959
- supportCustomLengthUnitsPatch: _nullishCoalesce(supportCustomLengthUnitsPatch, () => ( true)),
960
- tailwindcss: tailwindOptionsForPackage,
961
- tailwindcssPatcherOptions: patchedOptions
962
- });
963
- });
1116
+ try {
1117
+ patchers.push(createTailwindcssPatcher({
1118
+ basedir: baseDir,
1119
+ supportCustomLengthUnitsPatch: _nullishCoalesce(supportCustomLengthUnitsPatch, () => ( true)),
1120
+ tailwindcss: tailwindOptionsForPackage,
1121
+ tailwindcssPatcherOptions: patchedOptions
1122
+ }));
1123
+ } catch (error) {
1124
+ if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
1125
+ _nullishCoalesce(firstVersionMismatchError, () => ( (firstVersionMismatchError = error)));
1126
+ _logger.logger.warn('skip incompatible Tailwind package candidate "%s" for v4 patcher: %s', packageName, error.message);
1127
+ continue;
1128
+ }
1129
+ throw error;
1130
+ }
1131
+ }
1132
+ if (patchers.length === 0 && firstVersionMismatchError) {
1133
+ throw firstVersionMismatchError;
1134
+ }
964
1135
  return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
965
1136
  }
966
1137
  function tryCreateMultiTailwindcssPatcher(groups, options) {
@@ -1030,7 +1201,7 @@ function detectCallerBasedir() {
1030
1201
  const lines = stack.split("\n");
1031
1202
  for (const line of lines) {
1032
1203
  const match = _nullishCoalesce(line.match(STACK_PAREN_RE), () => ( line.match(STACK_AT_RE)));
1033
- const location = _optionalChain([match, 'optionalAccess', _75 => _75[1]]);
1204
+ const location = _optionalChain([match, 'optionalAccess', _106 => _106[1]]);
1034
1205
  if (!location) {
1035
1206
  continue;
1036
1207
  }
@@ -1038,7 +1209,7 @@ function detectCallerBasedir() {
1038
1209
  if (filePath.startsWith("file://")) {
1039
1210
  try {
1040
1211
  filePath = _url.fileURLToPath.call(void 0, filePath);
1041
- } catch (e5) {
1212
+ } catch (e6) {
1042
1213
  continue;
1043
1214
  }
1044
1215
  }
@@ -1052,7 +1223,7 @@ function detectCallerBasedir() {
1052
1223
  }
1053
1224
  try {
1054
1225
  return _path2.default.dirname(resolvedPath);
1055
- } catch (e6) {
1226
+ } catch (e7) {
1056
1227
  continue;
1057
1228
  }
1058
1229
  }
@@ -1060,8 +1231,8 @@ function detectCallerBasedir() {
1060
1231
  }
1061
1232
  function resolveTailwindcssBasedir(basedir, fallback) {
1062
1233
  const envBasedirResult = pickEnvBasedir();
1063
- const envBasedir = _optionalChain([envBasedirResult, 'optionalAccess', _76 => _76.value]);
1064
- const envBasedirKey = _optionalChain([envBasedirResult, 'optionalAccess', _77 => _77.key]);
1234
+ const envBasedir = _optionalChain([envBasedirResult, 'optionalAccess', _107 => _107.value]);
1235
+ const envBasedirKey = _optionalChain([envBasedirResult, 'optionalAccess', _108 => _108.key]);
1065
1236
  const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
1066
1237
  const packageEnvBasedir = pickPackageEnvBasedir();
1067
1238
  const shouldDetectCaller = !envBasedir || envBasedirIsGeneric;
@@ -1111,7 +1282,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
1111
1282
  _logger.logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
1112
1283
  }
1113
1284
  return _path2.default.normalize(_path2.default.dirname(packageJsonPath));
1114
- } catch (e7) {
1285
+ } catch (e8) {
1115
1286
  if (_process2.default.env.WEAPP_TW_DEBUG_STACK === "1") {
1116
1287
  _logger.logger.debug("failed to resolve package json for %s", packageName);
1117
1288
  }
@@ -1154,7 +1325,7 @@ function isRaxWorkspace(appType, baseDir) {
1154
1325
  if (deps["rax-app"] || deps.rax) {
1155
1326
  return true;
1156
1327
  }
1157
- } catch (e8) {
1328
+ } catch (e9) {
1158
1329
  return false;
1159
1330
  }
1160
1331
  return false;
@@ -1219,12 +1390,12 @@ function createTailwindcssPatcherFromContext(ctx) {
1219
1390
  if (normalizedCssEntries) {
1220
1391
  ctx.cssEntries = normalizedCssEntries;
1221
1392
  }
1222
- const shouldAttachBase = Boolean(ctx.tailwindcssBasedir && _optionalChain([normalizedCssEntries, 'optionalAccess', _78 => _78.length]));
1223
- const tailwindcssWithBase = shouldAttachBase && _optionalChain([tailwindcss, 'optionalAccess', _79 => _79.v4]) !== null ? {
1393
+ const shouldAttachBase = Boolean(ctx.tailwindcssBasedir && _optionalChain([normalizedCssEntries, 'optionalAccess', _109 => _109.length]));
1394
+ const tailwindcssWithBase = shouldAttachBase && _optionalChain([tailwindcss, 'optionalAccess', _110 => _110.v4]) !== null ? {
1224
1395
  ..._nullishCoalesce(tailwindcss, () => ( {})),
1225
1396
  v4: {
1226
- ..._nullishCoalesce(_optionalChain([tailwindcss, 'optionalAccess', _80 => _80.v4]), () => ( {})),
1227
- base: _nullishCoalesce(_optionalChain([tailwindcss, 'optionalAccess', _81 => _81.v4, 'optionalAccess', _82 => _82.base]), () => ( resolvedTailwindcssBasedir))
1397
+ ..._nullishCoalesce(_optionalChain([tailwindcss, 'optionalAccess', _111 => _111.v4]), () => ( {})),
1398
+ base: _nullishCoalesce(_optionalChain([tailwindcss, 'optionalAccess', _112 => _112.v4, 'optionalAccess', _113 => _113.base]), () => ( resolvedTailwindcssBasedir))
1228
1399
  }
1229
1400
  } : tailwindcss;
1230
1401
  const patcherOptions = {
@@ -1242,7 +1413,7 @@ function createTailwindcssPatcherFromContext(ctx) {
1242
1413
  if (multiPatcher) {
1243
1414
  return multiPatcher;
1244
1415
  }
1245
- if (_optionalChain([groupedCssEntries, 'optionalAccess', _83 => _83.size]) === 1) {
1416
+ if (_optionalChain([groupedCssEntries, 'optionalAccess', _114 => _114.size]) === 1) {
1246
1417
  const firstGroup = groupedCssEntries.entries().next().value;
1247
1418
  if (firstGroup) {
1248
1419
  const [baseDir, entries] = firstGroup;
@@ -1257,6 +1428,13 @@ function createTailwindcssPatcherFromContext(ctx) {
1257
1428
  );
1258
1429
  }
1259
1430
 
1431
+ // src/logger/index.ts
1432
+
1433
+
1434
+
1435
+
1436
+
1437
+
1260
1438
 
1261
1439
 
1262
1440
 
@@ -1265,4 +1443,4 @@ function createTailwindcssPatcherFromContext(ctx) {
1265
1443
 
1266
1444
 
1267
1445
 
1268
- exports.findWorkspaceRoot = findWorkspaceRoot; exports.findNearestPackageRoot = findNearestPackageRoot; exports.warnMissingCssEntries = warnMissingCssEntries; exports.applyV4CssCalcDefaults = applyV4CssCalcDefaults; exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext; exports.logger = _logger.logger;
1446
+ exports.resolveTailwindcssOptions = resolveTailwindcssOptions; exports.invalidateRuntimeClassSet = invalidateRuntimeClassSet; exports.getRuntimeClassSetCacheEntry = getRuntimeClassSetCacheEntry; exports.getRuntimeClassSetSignature = getRuntimeClassSetSignature; exports.findNearestPackageRoot = findNearestPackageRoot; exports.warnMissingCssEntries = warnMissingCssEntries; exports.applyV4CssCalcDefaults = applyV4CssCalcDefaults; exports.findTailwindConfig = findTailwindConfig; exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext; exports.logger = _logger.logger;