weapp-tailwindcss 4.7.8 → 4.7.10-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{chunk-OQ5PKCFN.mjs → chunk-2WJGB2LE.mjs} +1 -1
  2. package/dist/{chunk-ZSTADQDZ.js → chunk-6MBTOUPD.js} +10 -10
  3. package/dist/{chunk-6J63FRIY.js → chunk-AEIEPXO3.js} +214 -40
  4. package/dist/{chunk-DMJK47DW.mjs → chunk-BTPDRSHI.mjs} +1 -1
  5. package/dist/{chunk-LJ5AQYTF.js → chunk-GRO26PCL.js} +6 -6
  6. package/dist/{chunk-G7MXWOBI.mjs → chunk-J7OY4W53.mjs} +182 -8
  7. package/dist/{chunk-HPUZNQ4G.js → chunk-KMCQEHJM.js} +17 -14
  8. package/dist/{chunk-GCF5VD66.js → chunk-LRD5B5J7.js} +11 -11
  9. package/dist/{chunk-6NAX73ZA.mjs → chunk-QB67X26Y.mjs} +2 -2
  10. package/dist/{chunk-UCPNYFTI.js → chunk-XGRBCPBI.js} +1 -1
  11. package/dist/{chunk-6HQQYIBT.mjs → chunk-YEFXGOXH.mjs} +1 -1
  12. package/dist/{chunk-SHMBWMDV.mjs → chunk-YW5YW5D4.mjs} +13 -10
  13. package/dist/cli.js +12 -12
  14. package/dist/cli.mjs +3 -3
  15. package/dist/core.js +9 -9
  16. package/dist/core.mjs +3 -3
  17. package/dist/css-macro/postcss.js +1 -1
  18. package/dist/css-macro/postcss.mjs +1 -1
  19. package/dist/css-macro.js +1 -1
  20. package/dist/css-macro.mjs +1 -1
  21. package/dist/defaults.js +1 -1
  22. package/dist/defaults.mjs +1 -1
  23. package/dist/gulp.js +5 -5
  24. package/dist/gulp.mjs +4 -4
  25. package/dist/index.js +7 -7
  26. package/dist/index.mjs +6 -6
  27. package/dist/postcss-html-transform.js +1 -1
  28. package/dist/postcss-html-transform.mjs +1 -1
  29. package/dist/presets.js +3 -3
  30. package/dist/presets.mjs +2 -2
  31. package/dist/types.d.mts +25 -25
  32. package/dist/types.d.ts +25 -25
  33. package/dist/types.js +1 -1
  34. package/dist/types.mjs +1 -1
  35. package/dist/vite.js +5 -5
  36. package/dist/vite.mjs +4 -4
  37. package/dist/webpack.js +5 -5
  38. package/dist/webpack.mjs +4 -4
  39. package/dist/webpack4.js +12 -12
  40. package/dist/webpack4.mjs +3 -3
  41. package/package.json +4 -4
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createTailwindcssPatcherFromContext
3
- } from "./chunk-SHMBWMDV.mjs";
3
+ } from "./chunk-YW5YW5D4.mjs";
4
4
  import {
5
5
  getDefaultOptions
6
6
  } from "./chunk-PYXTMD6B.mjs";
@@ -288,7 +288,7 @@ var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
288
288
 
289
289
  // src/context/index.ts
290
290
  import { rm } from "fs/promises";
291
- import { logger as logger3, pc } from "@weapp-tailwindcss/logger";
291
+ import { logger as logger4, pc } from "@weapp-tailwindcss/logger";
292
292
 
293
293
  // src/cache/index.ts
294
294
  import { LRUCache } from "lru-cache";
@@ -393,6 +393,177 @@ function initializeCache(cacheConfig) {
393
393
  return cacheConfig;
394
394
  }
395
395
 
396
+ // src/context/compiler-context-cache.ts
397
+ import { Buffer } from "buffer";
398
+ import { logger as logger2 } from "@weapp-tailwindcss/logger";
399
+ var globalCacheHolder = globalThis;
400
+ var compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
401
+ function compareNormalizedValues(a, b) {
402
+ const aStr = JSON.stringify(a);
403
+ const bStr = JSON.stringify(b);
404
+ return aStr.localeCompare(bStr);
405
+ }
406
+ function withCircularGuard(value, stack, factory) {
407
+ if (stack.has(value)) {
408
+ throw new TypeError("Cannot serialize circular structure in compiler context options");
409
+ }
410
+ stack.add(value);
411
+ try {
412
+ return factory();
413
+ } finally {
414
+ stack.delete(value);
415
+ }
416
+ }
417
+ function encodeTaggedValue(type, value) {
418
+ const record = { __type: type };
419
+ if (value !== void 0) {
420
+ record.value = value;
421
+ }
422
+ return record;
423
+ }
424
+ function normalizeOptionsValue(rawValue, stack = /* @__PURE__ */ new WeakSet()) {
425
+ if (rawValue === null) {
426
+ return null;
427
+ }
428
+ if (rawValue === void 0) {
429
+ return encodeTaggedValue("Undefined");
430
+ }
431
+ const type = typeof rawValue;
432
+ if (type === "string") {
433
+ return rawValue;
434
+ }
435
+ if (type === "boolean") {
436
+ return rawValue;
437
+ }
438
+ if (type === "number") {
439
+ const numericValue = rawValue;
440
+ if (Number.isNaN(numericValue)) {
441
+ return encodeTaggedValue("Number", "NaN");
442
+ }
443
+ if (!Number.isFinite(numericValue)) {
444
+ return encodeTaggedValue("Number", numericValue > 0 ? "Infinity" : "-Infinity");
445
+ }
446
+ if (Object.is(numericValue, -0)) {
447
+ return encodeTaggedValue("Number", "-0");
448
+ }
449
+ return numericValue;
450
+ }
451
+ if (type === "bigint") {
452
+ return encodeTaggedValue("BigInt", rawValue.toString());
453
+ }
454
+ if (type === "symbol") {
455
+ const symbolValue = rawValue;
456
+ return encodeTaggedValue("Symbol", symbolValue.description ?? String(symbolValue));
457
+ }
458
+ if (type === "function") {
459
+ return encodeTaggedValue("Function", rawValue.toString());
460
+ }
461
+ if (Array.isArray(rawValue)) {
462
+ return withCircularGuard(rawValue, stack, () => rawValue.map((item) => normalizeOptionsValue(item, stack)));
463
+ }
464
+ if (rawValue instanceof Date) {
465
+ return encodeTaggedValue("Date", rawValue.toISOString());
466
+ }
467
+ if (rawValue instanceof RegExp) {
468
+ return {
469
+ __type: "RegExp",
470
+ source: rawValue.source,
471
+ flags: rawValue.flags
472
+ };
473
+ }
474
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(rawValue)) {
475
+ return encodeTaggedValue("Buffer", rawValue.toString("base64"));
476
+ }
477
+ if (ArrayBuffer.isView(rawValue)) {
478
+ const view = rawValue;
479
+ const buffer = Buffer.from(view.buffer, view.byteOffset, view.byteLength);
480
+ return encodeTaggedValue(view.constructor?.name ?? "ArrayBufferView", buffer.toString("base64"));
481
+ }
482
+ if (rawValue instanceof ArrayBuffer) {
483
+ return encodeTaggedValue("ArrayBuffer", Buffer.from(rawValue).toString("base64"));
484
+ }
485
+ if (rawValue instanceof Set) {
486
+ return withCircularGuard(rawValue, stack, () => {
487
+ const normalizedEntries = Array.from(rawValue, (element) => normalizeOptionsValue(element, stack));
488
+ normalizedEntries.sort(compareNormalizedValues);
489
+ return {
490
+ __type: "Set",
491
+ value: normalizedEntries
492
+ };
493
+ });
494
+ }
495
+ if (rawValue instanceof Map) {
496
+ return withCircularGuard(rawValue, stack, () => {
497
+ const normalizedEntries = Array.from(rawValue.entries()).map(([key, entryValue]) => ({
498
+ key: normalizeOptionsValue(key, stack),
499
+ value: normalizeOptionsValue(entryValue, stack)
500
+ }));
501
+ normalizedEntries.sort((a, b) => compareNormalizedValues(a.key, b.key));
502
+ return {
503
+ __type: "Map",
504
+ value: normalizedEntries.map((entry) => [entry.key, entry.value])
505
+ };
506
+ });
507
+ }
508
+ if (typeof URL !== "undefined" && rawValue instanceof URL) {
509
+ return encodeTaggedValue("URL", rawValue.toString());
510
+ }
511
+ if (rawValue instanceof Error) {
512
+ const errorValue = rawValue;
513
+ return {
514
+ __type: "Error",
515
+ name: errorValue.name,
516
+ message: errorValue.message,
517
+ stack: errorValue.stack ?? ""
518
+ };
519
+ }
520
+ if (rawValue instanceof Promise) {
521
+ return encodeTaggedValue("Promise");
522
+ }
523
+ if (rawValue instanceof WeakMap) {
524
+ return encodeTaggedValue("WeakMap");
525
+ }
526
+ if (rawValue instanceof WeakSet) {
527
+ return encodeTaggedValue("WeakSet");
528
+ }
529
+ if (rawValue && typeof rawValue === "object") {
530
+ return withCircularGuard(rawValue, stack, () => {
531
+ const result = {};
532
+ const entries = Object.entries(rawValue);
533
+ entries.sort(([a], [b]) => a.localeCompare(b));
534
+ for (const [key, entryValue] of entries) {
535
+ result[key] = normalizeOptionsValue(entryValue, stack);
536
+ }
537
+ return result;
538
+ });
539
+ }
540
+ return encodeTaggedValue(typeof rawValue, String(rawValue));
541
+ }
542
+ function createCompilerContextCacheKey(opts) {
543
+ try {
544
+ const normalized = normalizeOptionsValue(opts ?? {});
545
+ const serialized = JSON.stringify(normalized);
546
+ return md5(serialized);
547
+ } catch (error) {
548
+ logger2.debug("skip compiler context cache: %O", error);
549
+ return void 0;
550
+ }
551
+ }
552
+ function withCompilerContextCache(opts, factory) {
553
+ const cacheKey = createCompilerContextCacheKey(opts);
554
+ if (cacheKey) {
555
+ const cached = compilerContextCache.get(cacheKey);
556
+ if (cached) {
557
+ return cached;
558
+ }
559
+ }
560
+ const ctx = factory();
561
+ if (cacheKey) {
562
+ compilerContextCache.set(cacheKey, ctx);
563
+ }
564
+ return ctx;
565
+ }
566
+
396
567
  // src/context/custom-attributes.ts
397
568
  function toCustomAttributesEntities(customAttributes) {
398
569
  if (!customAttributes) {
@@ -2201,7 +2372,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2201
2372
  }
2202
2373
 
2203
2374
  // src/context/logger.ts
2204
- import { logger as logger2 } from "@weapp-tailwindcss/logger";
2375
+ import { logger as logger3 } from "@weapp-tailwindcss/logger";
2205
2376
  var loggerLevelMap = {
2206
2377
  error: 0,
2207
2378
  warn: 1,
@@ -2209,7 +2380,7 @@ var loggerLevelMap = {
2209
2380
  silent: -999
2210
2381
  };
2211
2382
  function applyLoggerLevel(logLevel) {
2212
- logger2.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
2383
+ logger3.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
2213
2384
  }
2214
2385
 
2215
2386
  // src/context/index.ts
@@ -2293,11 +2464,11 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2293
2464
  if (err?.code === "ENOENT") {
2294
2465
  continue;
2295
2466
  }
2296
- logger3.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
2467
+ logger4.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
2297
2468
  }
2298
2469
  }
2299
2470
  }
2300
- function getCompilerContext(opts) {
2471
+ function createInternalCompilerContext(opts) {
2301
2472
  const ctx = defuOverrideArray(
2302
2473
  opts,
2303
2474
  getDefaultOptions(),
@@ -2308,9 +2479,9 @@ function getCompilerContext(opts) {
2308
2479
  const twPatcher = createTailwindcssPatcherFromContext(ctx);
2309
2480
  logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
2310
2481
  if (twPatcher.packageInfo?.version) {
2311
- logger3.success(`\u5F53\u524D\u4F7F\u7528 ${pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${pc.underline(pc.bold(pc.green(twPatcher.packageInfo.version)))}`);
2482
+ logger4.success(`\u5F53\u524D\u4F7F\u7528 ${pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${pc.underline(pc.bold(pc.green(twPatcher.packageInfo.version)))}`);
2312
2483
  } else {
2313
- logger3.warn(`${pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
2484
+ logger4.warn(`${pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
2314
2485
  }
2315
2486
  warnIfCliPatchTargetMismatch(ctx.tailwindcssBasedir, twPatcher);
2316
2487
  let cssCalcOptions = ctx.cssCalc ?? twPatcher.majorVersion === 4;
@@ -2347,6 +2518,9 @@ function getCompilerContext(opts) {
2347
2518
  });
2348
2519
  return ctx;
2349
2520
  }
2521
+ function getCompilerContext(opts) {
2522
+ return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
2523
+ }
2350
2524
 
2351
2525
  export {
2352
2526
  createDebug,
@@ -3,7 +3,7 @@
3
3
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
4
4
 
5
5
 
6
- var _chunkUCPNYFTIjs = require('./chunk-UCPNYFTI.js');
6
+ var _chunkXGRBCPBIjs = require('./chunk-XGRBCPBI.js');
7
7
 
8
8
  // src/context/tailwindcss.ts
9
9
  var _module = require('module');
@@ -46,7 +46,7 @@ function resolveModuleFromPaths(specifier, paths) {
46
46
  return void 0;
47
47
  }
48
48
  try {
49
- const req = _module.createRequire.call(void 0, _chunkUCPNYFTIjs.importMetaUrl);
49
+ const req = _module.createRequire.call(void 0, _chunkXGRBCPBIjs.importMetaUrl);
50
50
  return req.resolve(specifier, { paths });
51
51
  } catch (e) {
52
52
  return void 0;
@@ -163,11 +163,11 @@ function createDefaultResolvePaths(basedir) {
163
163
  const cwd = _process2.default.cwd();
164
164
  appendNodeModules(paths, cwd);
165
165
  try {
166
- const modulePath = _url.fileURLToPath.call(void 0, _chunkUCPNYFTIjs.importMetaUrl);
166
+ const modulePath = _url.fileURLToPath.call(void 0, _chunkXGRBCPBIjs.importMetaUrl);
167
167
  const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
168
168
  paths.add(candidate);
169
169
  } catch (e2) {
170
- paths.add(_chunkUCPNYFTIjs.importMetaUrl);
170
+ paths.add(_chunkXGRBCPBIjs.importMetaUrl);
171
171
  }
172
172
  if (paths.size === 0) {
173
173
  fallbackCandidates = fallbackCandidates.filter(Boolean);
@@ -741,8 +741,7 @@ function createMultiTailwindcssPatcher(patchers) {
741
741
  }
742
742
  return multiPatcher;
743
743
  }
744
- function tryCreateMultiTailwindcssPatcher(cssEntries, options) {
745
- const groups = groupCssEntriesByBase(cssEntries);
744
+ function tryCreateMultiTailwindcssPatcher(groups, options) {
746
745
  if (groups.size <= 1) {
747
746
  return void 0;
748
747
  }
@@ -769,25 +768,29 @@ function createTailwindcssPatcherFromContext(ctx) {
769
768
  if (normalizedCssEntries) {
770
769
  ctx.cssEntries = normalizedCssEntries;
771
770
  }
772
- const multiPatcher = normalizedCssEntries ? tryCreateMultiTailwindcssPatcher(normalizedCssEntries, {
771
+ const patcherOptions = {
773
772
  tailwindcss,
774
773
  tailwindcssPatcherOptions,
775
774
  supportCustomLengthUnitsPatch,
776
775
  appType
777
- }) : void 0;
776
+ };
777
+ const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries) : void 0;
778
+ const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
778
779
  if (multiPatcher) {
779
780
  return multiPatcher;
780
781
  }
782
+ if (_optionalChain([groupedCssEntries, 'optionalAccess', _36 => _36.size]) === 1) {
783
+ const firstGroup = groupedCssEntries.entries().next().value;
784
+ if (firstGroup) {
785
+ const [baseDir, entries] = firstGroup;
786
+ return createPatcherForBase(baseDir, entries, patcherOptions);
787
+ }
788
+ }
781
789
  const effectiveCssEntries = _nullishCoalesce(normalizedCssEntries, () => ( rawCssEntries));
782
790
  return createPatcherForBase(
783
791
  resolvedTailwindcssBasedir,
784
792
  effectiveCssEntries,
785
- {
786
- tailwindcss,
787
- tailwindcssPatcherOptions,
788
- supportCustomLengthUnitsPatch,
789
- appType
790
- }
793
+ patcherOptions
791
794
  );
792
795
  }
793
796
 
@@ -17,7 +17,7 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
17
17
 
18
18
 
19
19
 
20
- var _chunk6J63FRIYjs = require('./chunk-6J63FRIY.js');
20
+ var _chunkAEIEPXO3js = require('./chunk-AEIEPXO3.js');
21
21
 
22
22
 
23
23
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
@@ -49,7 +49,7 @@ function updateStaticAttribute(ms, prop) {
49
49
  const start = prop.value.loc.start.offset + 1;
50
50
  const end = prop.value.loc.end.offset - 1;
51
51
  if (start < end) {
52
- ms.update(start, end, _chunk6J63FRIYjs.replaceWxml.call(void 0, prop.value.content));
52
+ ms.update(start, end, _chunkAEIEPXO3js.replaceWxml.call(void 0, prop.value.content));
53
53
  }
54
54
  }
55
55
  function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
@@ -61,7 +61,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
61
61
  if (start >= end) {
62
62
  return;
63
63
  }
64
- const generated = _chunk6J63FRIYjs.generateCode.call(void 0, prop.exp.content, {
64
+ const generated = _chunkAEIEPXO3js.generateCode.call(void 0, prop.exp.content, {
65
65
  jsHandler,
66
66
  runtimeSet,
67
67
  wrapExpression: true
@@ -90,7 +90,7 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
90
90
  return;
91
91
  }
92
92
  const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
93
- const matchCustomAttribute = _chunk6J63FRIYjs.createAttributeMatcher.call(void 0, customAttributesEntities);
93
+ const matchCustomAttribute = _chunkAEIEPXO3js.createAttributeMatcher.call(void 0, customAttributesEntities);
94
94
  const ms = new (0, _magicstring2.default)(code);
95
95
  const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
96
96
  if (errors.length === 0) {
@@ -213,7 +213,7 @@ async function formatPostcssSourceMap(rawMap, file) {
213
213
  }
214
214
 
215
215
  // src/bundlers/vite/index.ts
216
- var debug = _chunk6J63FRIYjs.createDebug.call(void 0, );
216
+ var debug = _chunkAEIEPXO3js.createDebug.call(void 0, );
217
217
  function readOutputEntry(entry) {
218
218
  if (entry.output.type === "chunk") {
219
219
  return entry.output.code;
@@ -280,7 +280,7 @@ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
280
280
  }
281
281
  }
282
282
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
283
- const opts = _chunk6J63FRIYjs.getCompilerContext.call(void 0, options);
283
+ const opts = _chunkAEIEPXO3js.getCompilerContext.call(void 0, options);
284
284
  const {
285
285
  disabled,
286
286
  customAttributes,
@@ -302,17 +302,17 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
302
302
  if (disabled) {
303
303
  return;
304
304
  }
305
- const customAttributesEntities = _chunk6J63FRIYjs.toCustomAttributesEntities.call(void 0, customAttributes);
305
+ const customAttributesEntities = _chunkAEIEPXO3js.toCustomAttributesEntities.call(void 0, customAttributes);
306
306
  const runtimeState = {
307
307
  twPatcher: initialTwPatcher,
308
- patchPromise: _chunk6J63FRIYjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
308
+ patchPromise: _chunkAEIEPXO3js.createTailwindPatchPromise.call(void 0, initialTwPatcher),
309
309
  refreshTailwindcssPatcher
310
310
  };
311
311
  let runtimeSet;
312
312
  let runtimeSetPromise;
313
313
  let resolvedConfig;
314
314
  async function refreshRuntimeState(force) {
315
- const refreshed = await _chunk6J63FRIYjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
315
+ const refreshed = await _chunkAEIEPXO3js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
316
316
  if (refreshed) {
317
317
  runtimeSet = void 0;
318
318
  runtimeSetPromise = void 0;
@@ -325,7 +325,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
325
325
  return runtimeSet;
326
326
  }
327
327
  if (force || !runtimeSetPromise) {
328
- const task2 = _chunk6J63FRIYjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
328
+ const task2 = _chunkAEIEPXO3js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
329
329
  force: force || !runtimeSet,
330
330
  skipRefresh: force
331
331
  });
@@ -344,7 +344,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
344
344
  onLoad();
345
345
  const plugins = [
346
346
  {
347
- name: `${_chunk6J63FRIYjs.vitePluginName}:post`,
347
+ name: `${_chunkAEIEPXO3js.vitePluginName}:post`,
348
348
  enforce: "post",
349
349
  configResolved(config) {
350
350
  resolvedConfig = config;
@@ -16,13 +16,13 @@ import {
16
16
  getCompilerContext,
17
17
  pluginName,
18
18
  refreshTailwindRuntimeState
19
- } from "./chunk-G7MXWOBI.mjs";
19
+ } from "./chunk-J7OY4W53.mjs";
20
20
  import {
21
21
  getGroupedEntries
22
22
  } from "./chunk-ZNKIYZRQ.mjs";
23
23
  import {
24
24
  __dirname
25
- } from "./chunk-DMJK47DW.mjs";
25
+ } from "./chunk-BTPDRSHI.mjs";
26
26
 
27
27
  // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
28
28
  import fs from "fs";
@@ -5,7 +5,7 @@
5
5
  throw Error('Dynamic require of "' + x + '" is not supported');
6
6
  });
7
7
 
8
- // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.53.1_@types+node@24.10.1__@swc+core@1.15.1_@swc+h_d92aa008e7d0cb6e2dab5bcd2ea8592f/node_modules/tsup/assets/cjs_shims.js
8
+ // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.53.1_@types+node@24.10.1__@swc+core@1.15.2_@swc+h_714fe42112a7ecb62f8dfb6a41f9e513/node_modules/tsup/assets/cjs_shims.js
9
9
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
10
10
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
11
11
 
@@ -17,7 +17,7 @@ import {
17
17
  replaceWxml,
18
18
  toCustomAttributesEntities,
19
19
  vitePluginName
20
- } from "./chunk-G7MXWOBI.mjs";
20
+ } from "./chunk-J7OY4W53.mjs";
21
21
  import {
22
22
  getGroupedEntries
23
23
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -738,8 +738,7 @@ function createMultiTailwindcssPatcher(patchers) {
738
738
  }
739
739
  return multiPatcher;
740
740
  }
741
- function tryCreateMultiTailwindcssPatcher(cssEntries, options) {
742
- const groups = groupCssEntriesByBase(cssEntries);
741
+ function tryCreateMultiTailwindcssPatcher(groups, options) {
743
742
  if (groups.size <= 1) {
744
743
  return void 0;
745
744
  }
@@ -766,25 +765,29 @@ function createTailwindcssPatcherFromContext(ctx) {
766
765
  if (normalizedCssEntries) {
767
766
  ctx.cssEntries = normalizedCssEntries;
768
767
  }
769
- const multiPatcher = normalizedCssEntries ? tryCreateMultiTailwindcssPatcher(normalizedCssEntries, {
768
+ const patcherOptions = {
770
769
  tailwindcss,
771
770
  tailwindcssPatcherOptions,
772
771
  supportCustomLengthUnitsPatch,
773
772
  appType
774
- }) : void 0;
773
+ };
774
+ const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries) : void 0;
775
+ const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
775
776
  if (multiPatcher) {
776
777
  return multiPatcher;
777
778
  }
779
+ if (groupedCssEntries?.size === 1) {
780
+ const firstGroup = groupedCssEntries.entries().next().value;
781
+ if (firstGroup) {
782
+ const [baseDir, entries] = firstGroup;
783
+ return createPatcherForBase(baseDir, entries, patcherOptions);
784
+ }
785
+ }
778
786
  const effectiveCssEntries = normalizedCssEntries ?? rawCssEntries;
779
787
  return createPatcherForBase(
780
788
  resolvedTailwindcssBasedir,
781
789
  effectiveCssEntries,
782
- {
783
- tailwindcss,
784
- tailwindcssPatcherOptions,
785
- supportCustomLengthUnitsPatch,
786
- appType
787
- }
790
+ patcherOptions
788
791
  );
789
792
  }
790
793
 
package/dist/cli.js CHANGED
@@ -7,8 +7,8 @@ var _chunkOXASK55Qjs = require('./chunk-OXASK55Q.js');
7
7
 
8
8
 
9
9
 
10
- var _chunk6J63FRIYjs = require('./chunk-6J63FRIY.js');
11
- require('./chunk-HPUZNQ4G.js');
10
+ var _chunkAEIEPXO3js = require('./chunk-AEIEPXO3.js');
11
+ require('./chunk-KMCQEHJM.js');
12
12
  require('./chunk-SMYOFNHJ.js');
13
13
 
14
14
 
@@ -16,7 +16,7 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
16
16
 
17
17
 
18
18
 
19
- var _chunkUCPNYFTIjs = require('./chunk-UCPNYFTI.js');
19
+ var _chunkXGRBCPBIjs = require('./chunk-XGRBCPBI.js');
20
20
 
21
21
  // src/cli.ts
22
22
  var _promises = require('fs/promises');
@@ -34,12 +34,12 @@ function getNodeRequire() {
34
34
  if (cachedRequire) {
35
35
  return cachedRequire;
36
36
  }
37
- if (typeof _chunkUCPNYFTIjs.__require === "function") {
38
- cachedRequire = _chunkUCPNYFTIjs.__require;
37
+ if (typeof _chunkXGRBCPBIjs.__require === "function") {
38
+ cachedRequire = _chunkXGRBCPBIjs.__require;
39
39
  return cachedRequire;
40
40
  }
41
41
  try {
42
- cachedRequire = _module.createRequire.call(void 0, _chunkUCPNYFTIjs.importMetaUrl);
42
+ cachedRequire = _module.createRequire.call(void 0, _chunkXGRBCPBIjs.importMetaUrl);
43
43
  } catch (e) {
44
44
  cachedRequire = void 0;
45
45
  }
@@ -124,7 +124,7 @@ function createCliContext(overrides, resolvedCwd) {
124
124
  current
125
125
  );
126
126
  }
127
- return _chunk6J63FRIYjs.getCompilerContext.call(void 0, userOptions);
127
+ return _chunkAEIEPXO3js.getCompilerContext.call(void 0, userOptions);
128
128
  }
129
129
  function formatOutputPath(target, baseDir) {
130
130
  const root = _nullishCoalesce(baseDir, () => ( _process2.default.cwd()));
@@ -289,9 +289,9 @@ function logTokenPreview(report, format, groupKey) {
289
289
 
290
290
  // src/cli.ts
291
291
  _process2.default.title = "node (weapp-tailwindcss)";
292
- if (_semver2.default.lt(_process2.default.versions.node, _chunk6J63FRIYjs.WEAPP_TW_REQUIRED_NODE_VERSION)) {
292
+ if (_semver2.default.lt(_process2.default.versions.node, _chunkAEIEPXO3js.WEAPP_TW_REQUIRED_NODE_VERSION)) {
293
293
  _chunkOXASK55Qjs.logger.warn(
294
- `You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunk6J63FRIYjs.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
294
+ `You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunkAEIEPXO3js.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
295
295
  );
296
296
  }
297
297
  var cli = _cac2.default.call(void 0, "weapp-tailwindcss");
@@ -301,13 +301,13 @@ cli.command("patch", "Apply Tailwind CSS runtime patches").alias("install").opti
301
301
  const ctx = createCliContext(void 0, resolvedCwd);
302
302
  const shouldClearCache = toBoolean(options.clearCache, false);
303
303
  if (shouldClearCache) {
304
- await _chunk6J63FRIYjs.clearTailwindcssPatcherCache.call(void 0, ctx.twPatcher, { removeDirectory: true });
304
+ await _chunkAEIEPXO3js.clearTailwindcssPatcherCache.call(void 0, ctx.twPatcher, { removeDirectory: true });
305
305
  }
306
- _chunk6J63FRIYjs.logTailwindcssTarget.call(void 0, "cli", ctx.twPatcher, ctx.tailwindcssBasedir);
306
+ _chunkAEIEPXO3js.logTailwindcssTarget.call(void 0, "cli", ctx.twPatcher, ctx.tailwindcssBasedir);
307
307
  await ctx.twPatcher.patch();
308
308
  const shouldRecordTarget = toBoolean(options.recordTarget, false);
309
309
  if (shouldRecordTarget) {
310
- const recordPath = await _chunk6J63FRIYjs.saveCliPatchTargetRecord.call(void 0, ctx.tailwindcssBasedir, ctx.twPatcher);
310
+ const recordPath = await _chunkAEIEPXO3js.saveCliPatchTargetRecord.call(void 0, ctx.tailwindcssBasedir, ctx.twPatcher);
311
311
  if (recordPath) {
312
312
  _chunkOXASK55Qjs.logger.info(`\u8BB0\u5F55 weapp-tw patch \u76EE\u6807 -> ${formatOutputPath(recordPath, resolvedCwd)}`);
313
313
  }
package/dist/cli.mjs CHANGED
@@ -7,15 +7,15 @@ import {
7
7
  getCompilerContext,
8
8
  logTailwindcssTarget,
9
9
  saveCliPatchTargetRecord
10
- } from "./chunk-G7MXWOBI.mjs";
11
- import "./chunk-SHMBWMDV.mjs";
10
+ } from "./chunk-J7OY4W53.mjs";
11
+ import "./chunk-YW5YW5D4.mjs";
12
12
  import "./chunk-PYXTMD6B.mjs";
13
13
  import {
14
14
  defuOverrideArray
15
15
  } from "./chunk-ZNKIYZRQ.mjs";
16
16
  import {
17
17
  __require
18
- } from "./chunk-DMJK47DW.mjs";
18
+ } from "./chunk-BTPDRSHI.mjs";
19
19
 
20
20
  // src/cli.ts
21
21
  import { writeFile } from "fs/promises";
package/dist/core.js CHANGED
@@ -3,25 +3,25 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk6J63FRIYjs = require('./chunk-6J63FRIY.js');
7
- require('./chunk-HPUZNQ4G.js');
6
+ var _chunkAEIEPXO3js = require('./chunk-AEIEPXO3.js');
7
+ require('./chunk-KMCQEHJM.js');
8
8
  require('./chunk-SMYOFNHJ.js');
9
9
  require('./chunk-UW3WHSZ5.js');
10
- require('./chunk-UCPNYFTI.js');
10
+ require('./chunk-XGRBCPBI.js');
11
11
 
12
12
  // src/core.ts
13
13
  var _shared = require('@weapp-tailwindcss/shared');
14
14
  function createContext(options = {}) {
15
- const opts = _chunk6J63FRIYjs.getCompilerContext.call(void 0, options);
15
+ const opts = _chunkAEIEPXO3js.getCompilerContext.call(void 0, options);
16
16
  const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
17
17
  let runtimeSet = /* @__PURE__ */ new Set();
18
18
  const runtimeState = {
19
19
  twPatcher: initialTwPatcher,
20
- patchPromise: _chunk6J63FRIYjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
20
+ patchPromise: _chunkAEIEPXO3js.createTailwindPatchPromise.call(void 0, initialTwPatcher),
21
21
  refreshTailwindcssPatcher
22
22
  };
23
23
  async function refreshRuntimeState(force) {
24
- await _chunk6J63FRIYjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
24
+ await _chunkAEIEPXO3js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
25
25
  }
26
26
  async function transformWxss(rawCss, options2) {
27
27
  await runtimeState.patchPromise;
@@ -30,7 +30,7 @@ function createContext(options = {}) {
30
30
  }));
31
31
  await refreshRuntimeState(true);
32
32
  await runtimeState.patchPromise;
33
- runtimeSet = await _chunk6J63FRIYjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
33
+ runtimeSet = await _chunkAEIEPXO3js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
34
34
  return result;
35
35
  }
36
36
  async function transformJs(rawJs, options2 = {}) {
@@ -40,7 +40,7 @@ function createContext(options = {}) {
40
40
  } else {
41
41
  await refreshRuntimeState(true);
42
42
  await runtimeState.patchPromise;
43
- runtimeSet = await _chunk6J63FRIYjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
43
+ runtimeSet = await _chunkAEIEPXO3js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
44
44
  }
45
45
  return await jsHandler(rawJs, runtimeSet, options2);
46
46
  }
@@ -49,7 +49,7 @@ function createContext(options = {}) {
49
49
  if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
50
50
  await refreshRuntimeState(true);
51
51
  await runtimeState.patchPromise;
52
- runtimeSet = await _chunk6J63FRIYjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
52
+ runtimeSet = await _chunkAEIEPXO3js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
53
53
  }
54
54
  return templateHandler(rawWxml, _shared.defuOverrideArray.call(void 0, options2, {
55
55
  runtimeSet
package/dist/core.mjs CHANGED
@@ -3,11 +3,11 @@ import {
3
3
  createTailwindPatchPromise,
4
4
  getCompilerContext,
5
5
  refreshTailwindRuntimeState
6
- } from "./chunk-G7MXWOBI.mjs";
7
- import "./chunk-SHMBWMDV.mjs";
6
+ } from "./chunk-J7OY4W53.mjs";
7
+ import "./chunk-YW5YW5D4.mjs";
8
8
  import "./chunk-PYXTMD6B.mjs";
9
9
  import "./chunk-ZNKIYZRQ.mjs";
10
- import "./chunk-DMJK47DW.mjs";
10
+ import "./chunk-BTPDRSHI.mjs";
11
11
 
12
12
  // src/core.ts
13
13
  import { defuOverrideArray } from "@weapp-tailwindcss/shared";