weapp-tailwindcss 4.10.3 → 4.11.0-alpha.1

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 (64) hide show
  1. package/dist/{chunk-3XVUGMTY.mjs → chunk-2LH6PZH3.mjs} +8 -4
  2. package/dist/{chunk-3WUHHFLF.mjs → chunk-35EI5JMK.mjs} +4 -2
  3. package/dist/{chunk-RYC23C3K.js → chunk-4LPOQMFS.js} +203 -198
  4. package/dist/{chunk-5U24PLVV.js → chunk-ACTJYB33.js} +4 -2
  5. package/dist/chunk-CZLXTEHN.js +1936 -0
  6. package/dist/{chunk-TNYEOBAC.mjs → chunk-DOH7FULQ.mjs} +1 -1
  7. package/dist/{chunk-E7775SFS.mjs → chunk-FZNYV7VH.mjs} +914 -334
  8. package/dist/{chunk-6Z4GEN2Y.js → chunk-G3G437UE.js} +2 -2
  9. package/dist/{chunk-DEIJXHGJ.js → chunk-G5NLM3AL.js} +978 -398
  10. package/dist/{chunk-W2N6G2QQ.js → chunk-GWDHNCL2.js} +60 -46
  11. package/dist/{chunk-QOTLDKI4.mjs → chunk-IEZ5RBMG.mjs} +197 -192
  12. package/dist/{chunk-RM3SY4S4.mjs → chunk-JBM3HGHP.mjs} +52 -12
  13. package/dist/{chunk-WXT2GI5R.mjs → chunk-KKT2DKMW.mjs} +30 -16
  14. package/dist/chunk-LD7LZ4IK.mjs +1933 -0
  15. package/dist/{chunk-GCRL3ZYP.js → chunk-NOKJXG3W.js} +5 -5
  16. package/dist/{chunk-YUTKX7JZ.js → chunk-OV7FX6XR.js} +1 -1
  17. package/dist/{chunk-SR4GC2F4.js → chunk-OYSABARD.js} +8 -4
  18. package/dist/{chunk-LICQ6EGN.mjs → chunk-QYZCRG7F.mjs} +2 -2
  19. package/dist/{chunk-UYTCZXNE.mjs → chunk-R6KEYO3F.mjs} +6 -5
  20. package/dist/{chunk-WF636Q5E.js → chunk-SQG2MOFQ.js} +10 -9
  21. package/dist/{chunk-L7OBNTRI.js → chunk-W2EMGF7H.js} +57 -17
  22. package/dist/cli.js +45 -42
  23. package/dist/cli.mjs +9 -6
  24. package/dist/core.d.mts +4 -3
  25. package/dist/core.d.ts +4 -3
  26. package/dist/core.js +124 -30
  27. package/dist/core.mjs +119 -25
  28. package/dist/css-macro/postcss.js +6 -5
  29. package/dist/css-macro/postcss.mjs +4 -3
  30. package/dist/css-macro.js +5 -5
  31. package/dist/css-macro.mjs +2 -2
  32. package/dist/defaults.js +3 -3
  33. package/dist/defaults.mjs +2 -2
  34. package/dist/escape.js +2 -1
  35. package/dist/escape.mjs +2 -1
  36. package/dist/gulp.d.mts +1 -1
  37. package/dist/gulp.d.ts +1 -1
  38. package/dist/gulp.js +8 -7
  39. package/dist/gulp.mjs +8 -7
  40. package/dist/index.js +11 -11
  41. package/dist/index.mjs +9 -9
  42. package/dist/postcss-html-transform.js +1 -1
  43. package/dist/postcss-html-transform.mjs +1 -1
  44. package/dist/presets.js +5 -5
  45. package/dist/presets.mjs +2 -2
  46. package/dist/reset.js +1 -1
  47. package/dist/reset.mjs +1 -1
  48. package/dist/types.js +1 -1
  49. package/dist/types.mjs +1 -1
  50. package/dist/vite.d.mts +1 -1
  51. package/dist/vite.d.ts +1 -1
  52. package/dist/vite.js +9 -8
  53. package/dist/vite.mjs +8 -7
  54. package/dist/webpack.d.mts +1 -1
  55. package/dist/webpack.d.ts +1 -1
  56. package/dist/webpack.js +10 -9
  57. package/dist/webpack.mjs +8 -7
  58. package/dist/webpack4.d.mts +1 -1
  59. package/dist/webpack4.d.ts +1 -1
  60. package/dist/webpack4.js +64 -49
  61. package/dist/webpack4.mjs +33 -18
  62. package/package.json +7 -7
  63. package/dist/chunk-PALDKVKG.mjs +0 -1291
  64. package/dist/chunk-YJSFFRNZ.js +0 -1291
@@ -6,13 +6,16 @@ function createMediaQuery(value) {
6
6
  function createNegativeMediaQuery(value) {
7
7
  return `@media not screen and (${queryKey}:"${value}"){&}`;
8
8
  }
9
+ var UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
10
+ var WHITESPACE_RE = /\s+/g;
11
+ var LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
9
12
  function normalComment(text) {
10
13
  if (typeof text === "string") {
11
- const normalized = text.replaceAll(/(?<!\\)_/g, " ").replaceAll(/\s+/g, " ").trim();
14
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
12
15
  if (normalized.includes("\\")) {
13
16
  return normalized;
14
17
  }
15
- return normalized.replaceAll(/\s*(\|\||&&)\s*/g, " $1 ").replaceAll(/\s+/g, " ").trim();
18
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
16
19
  }
17
20
  return text;
18
21
  }
@@ -28,11 +31,12 @@ function ifndef(text) {
28
31
  end: `#endif`
29
32
  };
30
33
  }
34
+ var QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
31
35
  function matchCustomPropertyFromValue(str, cb) {
32
36
  let arr;
33
37
  let index = 0;
34
- const regex = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
35
- while ((arr = regex.exec(str)) !== null) {
38
+ QUERY_KEY_REGEX.lastIndex = 0;
39
+ while ((arr = QUERY_KEY_REGEX.exec(str)) !== null) {
36
40
  cb(arr, index);
37
41
  index++;
38
42
  }
@@ -7,10 +7,12 @@ import { isAllowedClassName, MappingChars2String } from "@weapp-core/escape";
7
7
  var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
8
8
  var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
9
9
  var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
10
+ var BACKSLASH_RE = /\\/g;
10
11
  function normalizePath(p) {
11
- return p.replace(/\\/g, "/");
12
+ return p.replace(BACKSLASH_RE, "/");
12
13
  }
13
14
  var MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
15
+ var KBONE_MAIN_CSS_RE = /^(?:common\/)?miniprogram-app/;
14
16
  var MAIN_CSS_CHUNK_MATCHERS = {
15
17
  "uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
16
18
  "uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
@@ -25,7 +27,7 @@ var MAIN_CSS_CHUNK_MATCHERS = {
25
27
  "remax": (file) => file.startsWith("app"),
26
28
  "rax": (file) => file.startsWith("bundle"),
27
29
  "native": (file) => file.startsWith("app"),
28
- "kbone": (file) => /^(?:common\/)?miniprogram-app/.test(file)
30
+ "kbone": (file) => KBONE_MAIN_CSS_RE.test(file)
29
31
  };
30
32
  var alwaysFalse = () => false;
31
33
  function createMainCssChunkMatcher() {
@@ -3,11 +3,95 @@
3
3
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
4
4
 
5
5
 
6
- var _chunkYUTKX7JZjs = require('./chunk-YUTKX7JZ.js');
6
+ var _chunkOV7FX6XRjs = require('./chunk-OV7FX6XR.js');
7
7
 
8
8
  // src/logger/index.ts
9
9
  var _logger = require('@weapp-tailwindcss/logger');
10
10
 
11
+ // src/context/workspace.ts
12
+ var _fs = require('fs');
13
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
14
+ var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
15
+ "node_modules",
16
+ ".git",
17
+ ".hg",
18
+ ".svn",
19
+ ".turbo",
20
+ ".output",
21
+ ".next",
22
+ "dist",
23
+ "build"
24
+ ]);
25
+ function findWorkspaceRoot(startDir) {
26
+ if (!startDir) {
27
+ return void 0;
28
+ }
29
+ let current = _path2.default.resolve(startDir);
30
+ while (true) {
31
+ const workspaceFile = _path2.default.join(current, "pnpm-workspace.yaml");
32
+ if (_fs.existsSync.call(void 0, workspaceFile)) {
33
+ return current;
34
+ }
35
+ const parent = _path2.default.dirname(current);
36
+ if (parent === current) {
37
+ return void 0;
38
+ }
39
+ current = parent;
40
+ }
41
+ }
42
+ function findNearestPackageRoot(startDir) {
43
+ if (!startDir) {
44
+ return void 0;
45
+ }
46
+ let current = _path2.default.resolve(startDir);
47
+ while (true) {
48
+ const pkgPath = _path2.default.join(current, "package.json");
49
+ if (_fs.existsSync.call(void 0, pkgPath)) {
50
+ return current;
51
+ }
52
+ const parent = _path2.default.dirname(current);
53
+ if (parent === current) {
54
+ return void 0;
55
+ }
56
+ current = parent;
57
+ }
58
+ }
59
+ function findWorkspacePackageDir(rootDir, packageName) {
60
+ const visited = /* @__PURE__ */ new Set();
61
+ const queue = [_path2.default.resolve(rootDir)];
62
+ while (queue.length > 0) {
63
+ const current = queue.shift();
64
+ const normalized = _path2.default.normalize(current);
65
+ if (visited.has(normalized)) {
66
+ continue;
67
+ }
68
+ visited.add(normalized);
69
+ try {
70
+ const pkgPath = _path2.default.join(normalized, "package.json");
71
+ if (_fs.existsSync.call(void 0, pkgPath)) {
72
+ const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf8"));
73
+ if (_optionalChain([pkg, 'optionalAccess', _ => _.name]) === packageName) {
74
+ return normalized;
75
+ }
76
+ }
77
+ } catch (e) {
78
+ }
79
+ let entries;
80
+ try {
81
+ entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
82
+ } catch (e2) {
83
+ continue;
84
+ }
85
+ for (const entry of entries) {
86
+ if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || _optionalChain([entry, 'access', _2 => _2.isSymbolicLink, 'optionalCall', _3 => _3()])) {
87
+ continue;
88
+ }
89
+ queue.push(_path2.default.join(normalized, entry.name));
90
+ }
91
+ }
92
+ return void 0;
93
+ }
94
+
11
95
  // src/tailwindcss/v4/config.ts
12
96
 
13
97
  var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
@@ -77,18 +161,18 @@ function hasConfiguredCssEntries(ctx) {
77
161
  if (normalizeCssEntriesConfig(ctx.cssEntries)) {
78
162
  return true;
79
163
  }
80
- if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _ => _.tailwindcss, 'optionalAccess', _2 => _2.v4, 'optionalAccess', _3 => _3.cssEntries]))) {
164
+ if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _4 => _4.tailwindcss, 'optionalAccess', _5 => _5.v4, 'optionalAccess', _6 => _6.cssEntries]))) {
81
165
  return true;
82
166
  }
83
167
  const patcherOptions = ctx.tailwindcssPatcherOptions;
84
168
  if (patcherOptions) {
85
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _4 => _4.tailwindcss, 'optionalAccess', _5 => _5.v4, 'optionalAccess', _6 => _6.cssEntries]))) {
169
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _7 => _7.tailwindcss, 'optionalAccess', _8 => _8.v4, 'optionalAccess', _9 => _9.cssEntries]))) {
86
170
  return true;
87
171
  }
88
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _7 => _7.tailwind, 'optionalAccess', _8 => _8.v4, 'optionalAccess', _9 => _9.cssEntries]))) {
172
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _10 => _10.tailwind, 'optionalAccess', _11 => _11.v4, 'optionalAccess', _12 => _12.cssEntries]))) {
89
173
  return true;
90
174
  }
91
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _10 => _10.patch, 'optionalAccess', _11 => _11.tailwindcss, 'optionalAccess', _12 => _12.v4, 'optionalAccess', _13 => _13.cssEntries]))) {
175
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _13 => _13.patch, 'optionalAccess', _14 => _14.tailwindcss, 'optionalAccess', _15 => _15.v4, 'optionalAccess', _16 => _16.cssEntries]))) {
92
176
  return true;
93
177
  }
94
178
  }
@@ -99,7 +183,7 @@ function warnMissingCssEntries(ctx, patcher) {
99
183
  if (hasWarnedMissingCssEntries) {
100
184
  return;
101
185
  }
102
- if (_optionalChain([patcher, 'optionalAccess', _14 => _14.majorVersion]) !== 4) {
186
+ if (_optionalChain([patcher, 'optionalAccess', _17 => _17.majorVersion]) !== 4) {
103
187
  return;
104
188
  }
105
189
  if (hasConfiguredCssEntries(ctx)) {
@@ -111,107 +195,132 @@ function warnMissingCssEntries(ctx, patcher) {
111
195
  );
112
196
  }
113
197
  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) {
198
+ const cssCalcOptions = _nullishCoalesce(cssCalc, () => ( _optionalChain([patcher, 'optionalAccess', _18 => _18.majorVersion]) === 4));
199
+ if (_optionalChain([patcher, 'optionalAccess', _19 => _19.majorVersion]) === 4 && cssCalcOptions) {
116
200
  return ensureDefaultsIncluded(cssCalcOptions);
117
201
  }
118
202
  return cssCalcOptions;
119
203
  }
120
204
 
121
- // src/tailwindcss/v4/patcher.ts
205
+ // src/tailwindcss/patcher-resolve.ts
122
206
 
207
+ var _module = require('module');
123
208
 
124
- // src/tailwindcss/patcher.ts
125
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
126
209
  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) {
210
+ var _url = require('url');
211
+ var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
212
+ var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
213
+ "stubs/config.full.js",
214
+ "defaultConfig.js"
215
+ ];
216
+ var TAILWIND_CONFIG_FILES = [
217
+ "tailwind.config.js",
218
+ "tailwind.config.cjs",
219
+ "tailwind.config.mjs",
220
+ "tailwind.config.ts",
221
+ "tailwind.config.cts",
222
+ "tailwind.config.mts"
223
+ ];
224
+ function isPathSpecifier(specifier) {
225
+ if (!specifier) {
226
+ return false;
227
+ }
228
+ if (specifier.startsWith("file://")) {
229
+ return true;
230
+ }
231
+ if (_path2.default.isAbsolute(specifier)) {
232
+ return true;
233
+ }
234
+ return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
235
+ }
236
+ function resolveModuleFromPaths(specifier, paths) {
237
+ if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
147
238
  return void 0;
148
239
  }
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;
240
+ try {
241
+ const req = _module.createRequire.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
242
+ return req.resolve(specifier, { paths });
243
+ } catch (e3) {
244
+ return void 0;
160
245
  }
161
246
  }
162
- function findNearestPackageRoot(startDir) {
163
- if (!startDir) {
247
+ function resolveTailwindConfigFallback(packageName, paths) {
248
+ if (!packageName) {
164
249
  return void 0;
165
250
  }
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;
251
+ for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
252
+ const candidate = `${packageName}/${suffix}`;
253
+ const resolved = resolveModuleFromPaths(candidate, paths);
254
+ if (resolved) {
255
+ return resolved;
175
256
  }
176
- current = parent;
177
257
  }
258
+ return void 0;
178
259
  }
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
- }
260
+ function appendNodeModules(paths, dir) {
261
+ if (!dir) {
262
+ return;
263
+ }
264
+ const nodeModulesDir = _path2.default.join(dir, "node_modules");
265
+ if (_fs.existsSync.call(void 0, nodeModulesDir)) {
266
+ paths.add(nodeModulesDir);
267
+ }
268
+ }
269
+ function findTailwindConfig(searchRoots) {
270
+ for (const root of searchRoots) {
271
+ for (const file of TAILWIND_CONFIG_FILES) {
272
+ const candidate = _path2.default.resolve(root, file);
273
+ if (_fs.existsSync.call(void 0, candidate)) {
274
+ return candidate;
196
275
  }
197
- } catch (e) {
198
276
  }
199
- let entries;
200
- try {
201
- entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
202
- } catch (e2) {
203
- continue;
277
+ }
278
+ return void 0;
279
+ }
280
+ function createDefaultResolvePaths(basedir) {
281
+ const paths = /* @__PURE__ */ new Set();
282
+ let fallbackCandidates = [];
283
+ if (basedir) {
284
+ const resolvedBase = _path2.default.resolve(basedir);
285
+ appendNodeModules(paths, resolvedBase);
286
+ fallbackCandidates.push(resolvedBase);
287
+ const packageRoot = findNearestPackageRoot(resolvedBase);
288
+ if (packageRoot) {
289
+ appendNodeModules(paths, packageRoot);
290
+ fallbackCandidates.push(packageRoot);
204
291
  }
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));
292
+ }
293
+ const cwd = _process2.default.cwd();
294
+ appendNodeModules(paths, cwd);
295
+ try {
296
+ const modulePath = _url.fileURLToPath.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
297
+ const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
298
+ paths.add(candidate);
299
+ } catch (e4) {
300
+ paths.add(_chunkOV7FX6XRjs.importMetaUrl);
301
+ }
302
+ if (paths.size === 0) {
303
+ fallbackCandidates = fallbackCandidates.filter(Boolean);
304
+ if (fallbackCandidates.length === 0) {
305
+ fallbackCandidates.push(cwd);
306
+ }
307
+ for (const candidate of fallbackCandidates) {
308
+ paths.add(candidate);
210
309
  }
211
310
  }
212
- return void 0;
311
+ return [...paths];
213
312
  }
214
313
 
314
+ // src/tailwindcss/v4/patcher.ts
315
+
316
+
317
+ // src/tailwindcss/patcher.ts
318
+
319
+
320
+
321
+ var _shared = require('@weapp-tailwindcss/shared');
322
+ var _tailwindcsspatch = require('tailwindcss-patch');
323
+
215
324
  // src/tailwindcss/patcher-options.ts
216
325
  function normalizeExtendLengthUnits(value) {
217
326
  if (value === false) {
@@ -363,115 +472,6 @@ function toModernTailwindcssPatchOptions(options) {
363
472
  return normalized;
364
473
  }
365
474
 
366
- // src/tailwindcss/patcher-resolve.ts
367
-
368
- var _module = require('module');
369
-
370
-
371
- var _url = require('url');
372
- var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
373
- var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
374
- "stubs/config.full.js",
375
- "defaultConfig.js"
376
- ];
377
- var TAILWIND_CONFIG_FILES = [
378
- "tailwind.config.js",
379
- "tailwind.config.cjs",
380
- "tailwind.config.mjs",
381
- "tailwind.config.ts",
382
- "tailwind.config.cts",
383
- "tailwind.config.mts"
384
- ];
385
- function isPathSpecifier(specifier) {
386
- if (!specifier) {
387
- return false;
388
- }
389
- if (specifier.startsWith("file://")) {
390
- return true;
391
- }
392
- if (_path2.default.isAbsolute(specifier)) {
393
- return true;
394
- }
395
- return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
396
- }
397
- function resolveModuleFromPaths(specifier, paths) {
398
- if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
399
- return void 0;
400
- }
401
- try {
402
- const req = _module.createRequire.call(void 0, _chunkYUTKX7JZjs.importMetaUrl);
403
- return req.resolve(specifier, { paths });
404
- } catch (e3) {
405
- return void 0;
406
- }
407
- }
408
- function resolveTailwindConfigFallback(packageName, paths) {
409
- if (!packageName) {
410
- return void 0;
411
- }
412
- for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
413
- const candidate = `${packageName}/${suffix}`;
414
- const resolved = resolveModuleFromPaths(candidate, paths);
415
- if (resolved) {
416
- return resolved;
417
- }
418
- }
419
- return void 0;
420
- }
421
- function appendNodeModules(paths, dir) {
422
- if (!dir) {
423
- return;
424
- }
425
- const nodeModulesDir = _path2.default.join(dir, "node_modules");
426
- if (_fs.existsSync.call(void 0, nodeModulesDir)) {
427
- paths.add(nodeModulesDir);
428
- }
429
- }
430
- function findTailwindConfig(searchRoots) {
431
- for (const root of searchRoots) {
432
- for (const file of TAILWIND_CONFIG_FILES) {
433
- const candidate = _path2.default.resolve(root, file);
434
- if (_fs.existsSync.call(void 0, candidate)) {
435
- return candidate;
436
- }
437
- }
438
- }
439
- return void 0;
440
- }
441
- function createDefaultResolvePaths(basedir) {
442
- const paths = /* @__PURE__ */ new Set();
443
- let fallbackCandidates = [];
444
- if (basedir) {
445
- const resolvedBase = _path2.default.resolve(basedir);
446
- appendNodeModules(paths, resolvedBase);
447
- fallbackCandidates.push(resolvedBase);
448
- const packageRoot = findNearestPackageRoot(resolvedBase);
449
- if (packageRoot) {
450
- appendNodeModules(paths, packageRoot);
451
- fallbackCandidates.push(packageRoot);
452
- }
453
- }
454
- const cwd = _process2.default.cwd();
455
- appendNodeModules(paths, cwd);
456
- try {
457
- const modulePath = _url.fileURLToPath.call(void 0, _chunkYUTKX7JZjs.importMetaUrl);
458
- const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
459
- paths.add(candidate);
460
- } catch (e4) {
461
- paths.add(_chunkYUTKX7JZjs.importMetaUrl);
462
- }
463
- if (paths.size === 0) {
464
- fallbackCandidates = fallbackCandidates.filter(Boolean);
465
- if (fallbackCandidates.length === 0) {
466
- fallbackCandidates.push(cwd);
467
- }
468
- for (const candidate of fallbackCandidates) {
469
- paths.add(candidate);
470
- }
471
- }
472
- return [...paths];
473
- }
474
-
475
475
  // src/tailwindcss/patcher.ts
476
476
  function createFallbackTailwindcssPatcher() {
477
477
  const packageInfo = {
@@ -510,6 +510,8 @@ function createFallbackTailwindcssPatcher() {
510
510
  };
511
511
  }
512
512
  var hasLoggedMissingTailwind = false;
513
+ var TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
514
+ var UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
513
515
  function createTailwindcssPatcher(options) {
514
516
  const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
515
517
  const cache = {
@@ -583,7 +585,7 @@ function createTailwindcssPatcher(options) {
583
585
  const sourcePaths = customPaths ? existingResolve.paths : resolvePaths;
584
586
  resolvedTailwindOptions.resolve = {
585
587
  ...existingResolve,
586
- paths: Array.from(new Set(sourcePaths))
588
+ paths: [...new Set(sourcePaths)]
587
589
  };
588
590
  _logger.logger.debug("Tailwind resolve config %O", {
589
591
  packageName: resolvedTailwindOptions.packageName,
@@ -631,14 +633,14 @@ function createTailwindcssPatcher(options) {
631
633
  return new (0, _tailwindcsspatch.TailwindcssPatcher)(resolvedOptions);
632
634
  } catch (error) {
633
635
  const searchPaths = _optionalChain([resolvedOptions, 'access', _41 => _41.tailwindcss, 'optionalAccess', _42 => _42.resolve, 'optionalAccess', _43 => _43.paths]);
634
- if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
636
+ if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
635
637
  if (!hasLoggedMissingTailwind) {
636
638
  _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");
637
639
  hasLoggedMissingTailwind = true;
638
640
  }
639
641
  return createFallbackTailwindcssPatcher();
640
642
  }
641
- if (error instanceof Error && /unable to locate tailwind css package/i.test(error.message)) {
643
+ if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) {
642
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);
643
645
  }
644
646
  throw error;
@@ -947,7 +949,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
947
949
  packageCandidates.add(
948
950
  _nullishCoalesce(_nullishCoalesce(mergedTailwindOptions.packageName, () => ( configuredPackageName)), () => ( "tailwindcss"))
949
951
  );
950
- const patchers = Array.from(packageCandidates).map((packageName) => {
952
+ const patchers = Array.from(packageCandidates, (packageName) => {
951
953
  const tailwindOptionsForPackage = {
952
954
  ...mergedTailwindOptions,
953
955
  packageName
@@ -1015,6 +1017,8 @@ function pickPackageEnvBasedir() {
1015
1017
  }
1016
1018
  return void 0;
1017
1019
  }
1020
+ var STACK_PAREN_RE = /\(([^)]+)\)/u;
1021
+ var STACK_AT_RE = /at\s+(\S.*)$/u;
1018
1022
  function detectCallerBasedir() {
1019
1023
  const stack = new Error("resolveTailwindcssBasedir stack probe").stack;
1020
1024
  if (!stack) {
@@ -1025,7 +1029,7 @@ function detectCallerBasedir() {
1025
1029
  }
1026
1030
  const lines = stack.split("\n");
1027
1031
  for (const line of lines) {
1028
- const match = _nullishCoalesce(line.match(/\(([^)]+)\)/u), () => ( line.match(/at\s+(\S.*)$/u)));
1032
+ const match = _nullishCoalesce(line.match(STACK_PAREN_RE), () => ( line.match(STACK_AT_RE)));
1029
1033
  const location = _optionalChain([match, 'optionalAccess', _75 => _75[1]]);
1030
1034
  if (!location) {
1031
1035
  continue;
@@ -1261,4 +1265,5 @@ function createTailwindcssPatcherFromContext(ctx) {
1261
1265
 
1262
1266
 
1263
1267
 
1264
- exports.findWorkspaceRoot = findWorkspaceRoot; exports.findNearestPackageRoot = findNearestPackageRoot; exports.warnMissingCssEntries = warnMissingCssEntries; exports.applyV4CssCalcDefaults = applyV4CssCalcDefaults; exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext; exports.logger = _logger.logger;
1268
+
1269
+ exports.findWorkspaceRoot = findWorkspaceRoot; exports.findNearestPackageRoot = findNearestPackageRoot; exports.warnMissingCssEntries = warnMissingCssEntries; exports.applyV4CssCalcDefaults = applyV4CssCalcDefaults; exports.findTailwindConfig = findTailwindConfig; exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext; exports.logger = _logger.logger;
@@ -7,10 +7,12 @@ var _escape = require('@weapp-core/escape');
7
7
  var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
8
8
  var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
9
9
  var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
10
+ var BACKSLASH_RE = /\\/g;
10
11
  function normalizePath(p) {
11
- return p.replace(/\\/g, "/");
12
+ return p.replace(BACKSLASH_RE, "/");
12
13
  }
13
14
  var MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
15
+ var KBONE_MAIN_CSS_RE = /^(?:common\/)?miniprogram-app/;
14
16
  var MAIN_CSS_CHUNK_MATCHERS = {
15
17
  "uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
16
18
  "uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
@@ -25,7 +27,7 @@ var MAIN_CSS_CHUNK_MATCHERS = {
25
27
  "remax": (file) => file.startsWith("app"),
26
28
  "rax": (file) => file.startsWith("bundle"),
27
29
  "native": (file) => file.startsWith("app"),
28
- "kbone": (file) => /^(?:common\/)?miniprogram-app/.test(file)
30
+ "kbone": (file) => KBONE_MAIN_CSS_RE.test(file)
29
31
  };
30
32
  var alwaysFalse = () => false;
31
33
  function createMainCssChunkMatcher() {