weapp-tailwindcss 4.11.1 → 4.12.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 (67) hide show
  1. package/README.md +38 -0
  2. package/dist/{chunk-VOCOKTZW.js → chunk-4LBAL3RE.js} +117 -119
  3. package/dist/{chunk-ZUV5AZRB.mjs → chunk-5CF3HTTN.mjs} +1 -1
  4. package/dist/{chunk-OMARW5NC.mjs → chunk-AYJ4HLWZ.mjs} +4 -2
  5. package/dist/{chunk-SV55AOBL.mjs → chunk-C2E5ZLNI.mjs} +12 -7
  6. package/dist/{chunk-6YV5WADN.js → chunk-CAZQZPMY.js} +45 -40
  7. package/dist/{chunk-Q2HTQFI4.js → chunk-CTGWJGKJ.js} +5 -5
  8. package/dist/{chunk-7LKMJZD2.js → chunk-GMKSBLNY.js} +2 -2
  9. package/dist/{chunk-EFBQ4SQR.mjs → chunk-HL3US2OT.mjs} +1 -1
  10. package/dist/{chunk-Y6JUVWRU.js → chunk-IUYO6NQO.js} +10 -6
  11. package/dist/{chunk-WSMWD4MC.mjs → chunk-JRLWGMVZ.mjs} +6 -2
  12. package/dist/{chunk-QK6VNNNL.js → chunk-NIS74SI6.js} +8 -6
  13. package/dist/{chunk-CRDOWYG4.js → chunk-ONLKZIRQ.js} +1 -1
  14. package/dist/{chunk-SSASUP5F.js → chunk-RQWWSU4U.js} +187 -82
  15. package/dist/{chunk-KX2JVTVM.mjs → chunk-V34LWQTS.mjs} +49 -51
  16. package/dist/{chunk-4O2J5ZM6.mjs → chunk-ZABCOAAS.mjs} +195 -90
  17. package/dist/cli.js +121 -81
  18. package/dist/cli.mjs +121 -81
  19. package/dist/core.d.mts +1 -1
  20. package/dist/core.d.ts +1 -1
  21. package/dist/core.js +14 -9
  22. package/dist/core.mjs +10 -5
  23. package/dist/css-macro/postcss.js +1 -1
  24. package/dist/css-macro/postcss.mjs +1 -1
  25. package/dist/css-macro.js +1 -1
  26. package/dist/css-macro.mjs +1 -1
  27. package/dist/defaults.d.mts +1 -1
  28. package/dist/defaults.d.ts +1 -1
  29. package/dist/defaults.js +1 -1
  30. package/dist/defaults.mjs +1 -1
  31. package/dist/gulp.d.mts +1 -1
  32. package/dist/gulp.d.ts +1 -1
  33. package/dist/gulp.js +5 -5
  34. package/dist/gulp.mjs +4 -4
  35. package/dist/{index-CoXntW_P.d.mts → index-BXrmQelt.d.mts} +29 -1
  36. package/dist/{index-CoXntW_P.d.ts → index-BXrmQelt.d.ts} +29 -1
  37. package/dist/index.d.mts +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +9 -9
  40. package/dist/index.mjs +7 -7
  41. package/dist/postcss-html-transform.js +1 -1
  42. package/dist/postcss-html-transform.mjs +1 -1
  43. package/dist/presets.d.mts +8 -1
  44. package/dist/presets.d.ts +8 -1
  45. package/dist/presets.js +7 -6
  46. package/dist/presets.mjs +3 -2
  47. package/dist/reset.d.mts +1 -31
  48. package/dist/reset.d.ts +3 -32
  49. package/dist/reset.js +3 -160
  50. package/dist/reset.mjs +3 -160
  51. package/dist/types.d.mts +2 -2
  52. package/dist/types.d.ts +2 -2
  53. package/dist/types.js +1 -1
  54. package/dist/types.mjs +1 -1
  55. package/dist/vite.d.mts +1 -1
  56. package/dist/vite.d.ts +1 -1
  57. package/dist/vite.js +6 -6
  58. package/dist/vite.mjs +4 -4
  59. package/dist/webpack.d.mts +1 -1
  60. package/dist/webpack.d.ts +1 -1
  61. package/dist/webpack.js +7 -7
  62. package/dist/webpack.mjs +5 -5
  63. package/dist/webpack4.d.mts +1 -1
  64. package/dist/webpack4.d.ts +1 -1
  65. package/dist/webpack4.js +41 -36
  66. package/dist/webpack4.mjs +12 -7
  67. package/package.json +8 -4
@@ -7,8 +7,9 @@ import {
7
7
  invalidateRuntimeClassSet,
8
8
  isUniAppXEnabled,
9
9
  logger,
10
+ resolveUniAppXOptions,
10
11
  warnMissingCssEntries
11
- } from "./chunk-OMARW5NC.mjs";
12
+ } from "./chunk-AYJ4HLWZ.mjs";
12
13
  import {
13
14
  getDefaultOptions
14
15
  } from "./chunk-XAKAD2CR.mjs";
@@ -256,7 +257,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
256
257
 
257
258
  // src/context/index.ts
258
259
  import { rm } from "fs/promises";
259
- import { logger as logger6, pc } from "@weapp-tailwindcss/logger";
260
+ import { logger as logger7 } from "@weapp-tailwindcss/logger";
260
261
 
261
262
  // src/cache/index.ts
262
263
  import { LRUCache } from "lru-cache";
@@ -361,9 +362,51 @@ function initializeCache(cacheConfig) {
361
362
  return cacheConfig;
362
363
  }
363
364
 
365
+ // src/tailwindcss/runtime-logs.ts
366
+ import process2 from "process";
367
+ import { logger as logger2, pc } from "@weapp-tailwindcss/logger";
368
+ var runtimeLogDedupeHolder = globalThis;
369
+ var runtimeLogDedupe = runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
370
+ function createRuntimeLogKey(category, baseDir, rootPath, version) {
371
+ return JSON.stringify([
372
+ category,
373
+ baseDir ?? process2.cwd(),
374
+ rootPath ?? "",
375
+ version ?? ""
376
+ ]);
377
+ }
378
+ function markRuntimeLog(category, baseDir, rootPath, version) {
379
+ const key = createRuntimeLogKey(category, baseDir, rootPath, version);
380
+ if (runtimeLogDedupe.has(key)) {
381
+ return false;
382
+ }
383
+ runtimeLogDedupe.add(key);
384
+ return true;
385
+ }
386
+ function logRuntimeTailwindcssTarget(baseDir, rootPath, version) {
387
+ if (!markRuntimeLog("target", baseDir, rootPath, version)) {
388
+ return;
389
+ }
390
+ const versionText = version ? ` (v${version})` : "";
391
+ logger2.info("%s \u4F7F\u7528 Tailwind CSS%s", "Weapp-tailwindcss", versionText);
392
+ }
393
+ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
394
+ if (version) {
395
+ if (!markRuntimeLog("version", baseDir, rootPath, version)) {
396
+ return;
397
+ }
398
+ logger2.success(`\u5F53\u524D\u4F7F\u7528 ${pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${pc.underline(pc.bold(pc.green(version)))}`);
399
+ return;
400
+ }
401
+ if (!markRuntimeLog("missing", baseDir, rootPath, version)) {
402
+ return;
403
+ }
404
+ logger2.warn(`${pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
405
+ }
406
+
364
407
  // src/tailwindcss/targets.ts
365
- import process3 from "process";
366
- import { logger as logger3 } from "@weapp-tailwindcss/logger";
408
+ import process5 from "process";
409
+ import { logger as logger4 } from "@weapp-tailwindcss/logger";
367
410
 
368
411
  // src/tailwindcss/targets/paths.ts
369
412
  import { existsSync } from "fs";
@@ -417,13 +460,13 @@ function getRecordFileCandidates(baseDir) {
417
460
  import { existsSync as existsSync2, readFileSync } from "fs";
418
461
  import { mkdir, writeFile } from "fs/promises";
419
462
  import path2 from "path";
420
- import process from "process";
421
- import { logger as logger2 } from "@weapp-tailwindcss/logger";
463
+ import process3 from "process";
464
+ import { logger as logger3 } from "@weapp-tailwindcss/logger";
422
465
 
423
466
  // package.json
424
467
  var package_default = {
425
468
  name: "weapp-tailwindcss",
426
- version: "4.11.1",
469
+ version: "4.12.0-alpha.1",
427
470
  description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
428
471
  author: "ice breaker <1324318532@qq.com>",
429
472
  license: "MIT",
@@ -625,6 +668,7 @@ var package_default = {
625
668
  "@weapp-core/regex": "~1.0.1",
626
669
  "@weapp-tailwindcss/logger": "workspace:*",
627
670
  "@weapp-tailwindcss/postcss": "workspace:*",
671
+ "@weapp-tailwindcss/reset": "workspace:*",
628
672
  "@weapp-tailwindcss/shared": "workspace:*",
629
673
  cac: "6.7.14",
630
674
  "comment-json": "^4.6.2",
@@ -639,6 +683,9 @@ var package_default = {
639
683
  "tailwindcss-patch": "catalog:tailwindcssPatch",
640
684
  "webpack-sources": "3.3.4",
641
685
  yaml: "^2.8.3"
686
+ },
687
+ devDependencies: {
688
+ "fast-check": "^4.7.0"
642
689
  }
643
690
  };
644
691
 
@@ -661,9 +708,9 @@ function warnInvalidPatchTargetRecord(baseDir, recordPath, reason) {
661
708
  }
662
709
  loggedInvalidPatchRecords.add(normalizedPath);
663
710
  const fileDisplay = formatRelativeToBase(normalizedPath, baseDir);
664
- const baseDisplay = formatRelativeToBase(path2.normalize(baseDir), process.cwd());
711
+ const baseDisplay = formatRelativeToBase(path2.normalize(baseDir), process3.cwd());
665
712
  const reasonMessage = reason ? `\uFF1A${reason}` : "";
666
- logger2.warn(
713
+ logger3.warn(
667
714
  `\u68C0\u6D4B\u5230\u635F\u574F\u7684 Tailwind CSS \u76EE\u6807\u8BB0\u5F55 ${fileDisplay}${reasonMessage}\u3002\u8BF7\u5728 ${baseDisplay} \u91CD\u65B0\u6267\u884C "weapp-tw patch --record-target" \u6216\u5220\u9664\u8BE5\u6587\u4EF6\u540E\u518D\u8FD0\u884C\u3002`
668
715
  );
669
716
  }
@@ -720,23 +767,23 @@ async function saveCliPatchTargetRecord(baseDir, patcher, options) {
720
767
  `, "utf8");
721
768
  return recordPath;
722
769
  } catch (error) {
723
- const baseDisplay = formatRelativeToBase(normalizedBase, process.cwd());
724
- logger2.warn(
770
+ const baseDisplay = formatRelativeToBase(normalizedBase, process3.cwd());
771
+ logger3.warn(
725
772
  '\u81EA\u52A8\u66F4\u65B0 Tailwind CSS \u8865\u4E01\u8BB0\u5F55\u5931\u8D25\uFF0C\u8BF7\u5728 %s \u8FD0\u884C "weapp-tw patch --cwd %s"\u3002',
726
773
  baseDisplay,
727
774
  normalizedBase
728
775
  );
729
- logger2.debug("failed to persist patch target record %s: %O", recordPath, error);
776
+ logger3.debug("failed to persist patch target record %s: %O", recordPath, error);
730
777
  return void 0;
731
778
  }
732
779
  }
733
780
 
734
781
  // src/tailwindcss/targets/recorder.ts
735
782
  import path3 from "path";
736
- import process2 from "process";
783
+ import process4 from "process";
737
784
  function findPatchTargetRecord(baseDir) {
738
785
  const visited = /* @__PURE__ */ new Set();
739
- const fallback = baseDir ?? process2.cwd();
786
+ const fallback = baseDir ?? process4.cwd();
740
787
  let current = path3.resolve(fallback);
741
788
  while (!visited.has(current)) {
742
789
  const record = readPatchTargetRecord(current);
@@ -814,25 +861,29 @@ function createPatchTargetRecorder(baseDir, patcher, options) {
814
861
  // src/tailwindcss/targets.ts
815
862
  function logTailwindcssTarget(kind, patcher, baseDir) {
816
863
  const packageInfo = patcher?.packageInfo;
817
- const label = kind === "cli" ? "weapp-tw patch" : "tailwindcss-patcher";
864
+ const label = kind === "cli" ? "weapp-tw patch" : "Weapp-tailwindcss";
818
865
  if (!packageInfo?.rootPath) {
819
- logger3.warn(
866
+ logger4.warn(
820
867
  "%s \u672A\u627E\u5230 Tailwind CSS \u4F9D\u8D56\uFF0C\u8BF7\u68C0\u67E5\u5728 %s \u662F\u5426\u5DF2\u5B89\u88C5 tailwindcss",
821
868
  label,
822
- baseDir ?? process3.cwd()
869
+ baseDir ?? process5.cwd()
823
870
  );
824
871
  return;
825
872
  }
826
873
  const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
827
874
  const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
828
- logger3.info("%s \u7ED1\u5B9A Tailwind CSS -> %s%s", label, displayPath, version);
875
+ if (kind === "runtime") {
876
+ logRuntimeTailwindcssTarget(baseDir, packageInfo.rootPath, packageInfo.version);
877
+ return;
878
+ }
879
+ logger4.info("%s \u7ED1\u5B9A Tailwind CSS -> %s%s", label, displayPath, version);
829
880
  }
830
881
 
831
882
  // src/context/compiler-context-cache.ts
832
883
  import { Buffer } from "buffer";
833
884
  import path4 from "path";
834
- import process4 from "process";
835
- import { logger as logger4 } from "@weapp-tailwindcss/logger";
885
+ import process6 from "process";
886
+ import { logger as logger5 } from "@weapp-tailwindcss/logger";
836
887
  var PAREN_CONTENT_RE = /\(([^)]+)\)/u;
837
888
  var AT_LOCATION_RE = /at\s+(\S.*)$/u;
838
889
  var TRAILING_LINE_COL_RE = /:\d+(?::\d+)?$/u;
@@ -865,7 +916,7 @@ function shouldProbeCallerLocation(opts) {
865
916
  if (hasExplicitOptionBasedir(opts)) {
866
917
  return false;
867
918
  }
868
- return !(process4.env.WEAPP_TAILWINDCSS_BASEDIR || process4.env.WEAPP_TAILWINDCSS_BASE_DIR || process4.env.TAILWINDCSS_BASEDIR || process4.env.TAILWINDCSS_BASE_DIR);
919
+ return !(process6.env.WEAPP_TAILWINDCSS_BASEDIR || process6.env.WEAPP_TAILWINDCSS_BASE_DIR || process6.env.TAILWINDCSS_BASEDIR || process6.env.TAILWINDCSS_BASE_DIR);
869
920
  }
870
921
  function detectCallerLocation() {
871
922
  const stack = new Error("compiler-context-cache stack probe").stack;
@@ -898,20 +949,20 @@ function getRuntimeCacheScope(opts) {
898
949
  }
899
950
  const runtimeScope = {
900
951
  caller: void 0,
901
- cwd: process4.cwd(),
902
- init_cwd: process4.env.INIT_CWD,
903
- npm_config_local_prefix: process4.env.npm_config_local_prefix,
904
- npm_package_json: process4.env.npm_package_json,
905
- pnpm_package_name: process4.env.PNPM_PACKAGE_NAME,
906
- pwd: process4.env.PWD,
907
- tailwindcss_base_dir: process4.env.TAILWINDCSS_BASE_DIR,
908
- tailwindcss_basedir: process4.env.TAILWINDCSS_BASEDIR,
909
- uni_app_input_dir: process4.env.UNI_APP_INPUT_DIR,
910
- uni_cli_root: process4.env.UNI_CLI_ROOT,
911
- uni_input_dir: process4.env.UNI_INPUT_DIR,
912
- uni_input_root: process4.env.UNI_INPUT_ROOT,
913
- weapp_tailwindcss_base_dir: process4.env.WEAPP_TAILWINDCSS_BASE_DIR,
914
- weapp_tailwindcss_basedir: process4.env.WEAPP_TAILWINDCSS_BASEDIR
952
+ cwd: process6.cwd(),
953
+ init_cwd: process6.env.INIT_CWD,
954
+ npm_config_local_prefix: process6.env.npm_config_local_prefix,
955
+ npm_package_json: process6.env.npm_package_json,
956
+ pnpm_package_name: process6.env.PNPM_PACKAGE_NAME,
957
+ pwd: process6.env.PWD,
958
+ tailwindcss_base_dir: process6.env.TAILWINDCSS_BASE_DIR,
959
+ tailwindcss_basedir: process6.env.TAILWINDCSS_BASEDIR,
960
+ uni_app_input_dir: process6.env.UNI_APP_INPUT_DIR,
961
+ uni_cli_root: process6.env.UNI_CLI_ROOT,
962
+ uni_input_dir: process6.env.UNI_INPUT_DIR,
963
+ uni_input_root: process6.env.UNI_INPUT_ROOT,
964
+ weapp_tailwindcss_base_dir: process6.env.WEAPP_TAILWINDCSS_BASE_DIR,
965
+ weapp_tailwindcss_basedir: process6.env.WEAPP_TAILWINDCSS_BASEDIR
915
966
  };
916
967
  if (shouldProbeCallerLocation(opts)) {
917
968
  runtimeScope.caller = detectCallerLocation();
@@ -1083,7 +1134,7 @@ function createCompilerContextCacheKey(opts) {
1083
1134
  keyStore.set(runtimeCacheScopeKey, cacheKey);
1084
1135
  return cacheKey;
1085
1136
  } catch (error) {
1086
- logger4.debug("skip compiler context cache: %O", error);
1137
+ logger5.debug("skip compiler context cache: %O", error);
1087
1138
  return void 0;
1088
1139
  }
1089
1140
  }
@@ -1118,6 +1169,9 @@ function toCustomAttributesEntities(customAttributes) {
1118
1169
  // src/context/handlers.ts
1119
1170
  import { createStyleHandler } from "@weapp-tailwindcss/postcss";
1120
1171
 
1172
+ // src/js/index.ts
1173
+ import { LRUCache as LRUCache3 } from "lru-cache";
1174
+
1121
1175
  // src/babel/index.ts
1122
1176
  import _babelTraverse from "@babel/traverse";
1123
1177
  import { parse, parseExpression } from "@babel/parser";
@@ -2935,6 +2989,49 @@ function jsHandler(rawSource, options) {
2935
2989
  }
2936
2990
 
2937
2991
  // src/js/index.ts
2992
+ var RESULT_CACHE_MAX = 512;
2993
+ var classNameSetIds = /* @__PURE__ */ new WeakMap();
2994
+ var nextClassNameSetId = 0;
2995
+ function getClassNameSetId(set) {
2996
+ if (!set) {
2997
+ return "none";
2998
+ }
2999
+ const existing = classNameSetIds.get(set);
3000
+ if (existing !== void 0) {
3001
+ return String(existing);
3002
+ }
3003
+ const id = nextClassNameSetId++;
3004
+ classNameSetIds.set(set, id);
3005
+ return String(id);
3006
+ }
3007
+ var fingerprintCache = /* @__PURE__ */ new WeakMap();
3008
+ function getOptionsFingerprint(options) {
3009
+ const cached = fingerprintCache.get(options);
3010
+ if (cached) {
3011
+ return cached;
3012
+ }
3013
+ const parts = [
3014
+ getClassNameSetId(options.classNameSet),
3015
+ JSON.stringify(options.escapeMap ?? null),
3016
+ options.needEscaped ? "1" : "0",
3017
+ options.alwaysEscape ? "1" : "0",
3018
+ options.unescapeUnicode ? "1" : "0",
3019
+ options.generateMap ? "1" : "0",
3020
+ options.uniAppX ? "1" : "0",
3021
+ options.wrapExpression ? "1" : "0",
3022
+ String(options.tailwindcssMajorVersion ?? ""),
3023
+ String(options.staleClassNameFallback ?? ""),
3024
+ String(options.jsArbitraryValueFallback ?? ""),
3025
+ JSON.stringify(options.arbitraryValues ?? null),
3026
+ JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
3027
+ JSON.stringify(options.ignoreTaggedTemplateExpressionIdentifiers?.map((v) => v instanceof RegExp ? v.source : v) ?? null),
3028
+ JSON.stringify(options.moduleSpecifierReplacements ?? null),
3029
+ JSON.stringify(options.babelParserOptions ?? null)
3030
+ ];
3031
+ const fingerprint = parts.join("|");
3032
+ fingerprintCache.set(options, fingerprint);
3033
+ return fingerprint;
3034
+ }
2938
3035
  function hasDefinedOverrides(options) {
2939
3036
  if (!options) {
2940
3037
  return false;
@@ -2946,17 +3043,6 @@ function hasDefinedOverrides(options) {
2946
3043
  }
2947
3044
  return false;
2948
3045
  }
2949
- var CACHEABLE_SOURCE_MAX_LENGTH = 512;
2950
- var RESULT_CACHE_LIMIT = 256;
2951
- function shouldCacheJsResult(rawSource, options) {
2952
- if (rawSource.length === 0 || rawSource.length > CACHEABLE_SOURCE_MAX_LENGTH) {
2953
- return false;
2954
- }
2955
- if (options.moduleGraph || options.filename) {
2956
- return false;
2957
- }
2958
- return true;
2959
- }
2960
3046
  function createJsHandler(options) {
2961
3047
  const defaults = {
2962
3048
  escapeMap: options.escapeMap,
@@ -2975,11 +3061,10 @@ function createJsHandler(options) {
2975
3061
  uniAppX: options.uniAppX,
2976
3062
  moduleSpecifierReplacements: options.moduleSpecifierReplacements
2977
3063
  };
2978
- const resolvedOptionsByClassNameSet = /* @__PURE__ */ new WeakMap();
3064
+ const defaultOptionsCache = /* @__PURE__ */ new WeakMap();
2979
3065
  let resolvedOptionsWithoutClassNameSet;
2980
- const resolvedOverrideOptions = /* @__PURE__ */ new WeakMap();
2981
- const resolvedOverrideOptionsByClassNameSet = /* @__PURE__ */ new WeakMap();
2982
- const resultCache = /* @__PURE__ */ new WeakMap();
3066
+ const overrideOptionsCache = /* @__PURE__ */ new WeakMap();
3067
+ const resultCache = new LRUCache3({ max: RESULT_CACHE_MAX });
2983
3068
  function resolveDefaultOptions(classNameSet) {
2984
3069
  if (!classNameSet) {
2985
3070
  if (!resolvedOptionsWithoutClassNameSet) {
@@ -2990,7 +3075,7 @@ function createJsHandler(options) {
2990
3075
  }
2991
3076
  return resolvedOptionsWithoutClassNameSet;
2992
3077
  }
2993
- const cached = resolvedOptionsByClassNameSet.get(classNameSet);
3078
+ const cached = defaultOptionsCache.get(classNameSet);
2994
3079
  if (cached) {
2995
3080
  return cached;
2996
3081
  }
@@ -2998,42 +3083,36 @@ function createJsHandler(options) {
2998
3083
  ...defaults,
2999
3084
  classNameSet
3000
3085
  };
3001
- resolvedOptionsByClassNameSet.set(classNameSet, created);
3086
+ defaultOptionsCache.set(classNameSet, created);
3002
3087
  return created;
3003
3088
  }
3004
3089
  function getCachedJsResult(rawSource, resolvedOptions) {
3005
- if (!shouldCacheJsResult(rawSource, resolvedOptions)) {
3090
+ if (rawSource.length === 0) {
3006
3091
  return void 0;
3007
3092
  }
3008
- const cache = resultCache.get(resolvedOptions);
3009
- return cache?.get(rawSource);
3093
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${md5(rawSource)}`;
3094
+ return resultCache.get(key);
3010
3095
  }
3011
3096
  function setCachedJsResult(rawSource, resolvedOptions, result) {
3012
- if (!shouldCacheJsResult(rawSource, resolvedOptions) || result.error || result.linked) {
3097
+ if (rawSource.length === 0 || result.error || result.linked) {
3013
3098
  return result;
3014
3099
  }
3015
- let cache = resultCache.get(resolvedOptions);
3016
- if (!cache) {
3017
- cache = /* @__PURE__ */ new Map();
3018
- resultCache.set(resolvedOptions, cache);
3019
- }
3020
- cache.set(rawSource, result);
3021
- if (cache.size > RESULT_CACHE_LIMIT) {
3022
- const firstKey = cache.keys().next().value;
3023
- if (typeof firstKey === "string") {
3024
- cache.delete(firstKey);
3025
- }
3026
- }
3100
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${md5(rawSource)}`;
3101
+ resultCache.set(key, result);
3027
3102
  return result;
3028
3103
  }
3029
3104
  function resolveOptions(classNameSet, overrideOptions) {
3030
3105
  if (!hasDefinedOverrides(overrideOptions)) {
3031
3106
  return resolveDefaultOptions(classNameSet);
3032
3107
  }
3108
+ let entry = overrideOptionsCache.get(overrideOptions);
3109
+ if (!entry) {
3110
+ entry = { bySet: /* @__PURE__ */ new WeakMap() };
3111
+ overrideOptionsCache.set(overrideOptions, entry);
3112
+ }
3033
3113
  if (!classNameSet) {
3034
- const cached2 = resolvedOverrideOptions.get(overrideOptions);
3035
- if (cached2) {
3036
- return cached2;
3114
+ if (entry.noSet) {
3115
+ return entry.noSet;
3037
3116
  }
3038
3117
  const created2 = defuOverrideArray(
3039
3118
  {
@@ -3042,15 +3121,10 @@ function createJsHandler(options) {
3042
3121
  },
3043
3122
  defaults
3044
3123
  );
3045
- resolvedOverrideOptions.set(overrideOptions, created2);
3124
+ entry.noSet = created2;
3046
3125
  return created2;
3047
3126
  }
3048
- let cache = resolvedOverrideOptionsByClassNameSet.get(overrideOptions);
3049
- if (!cache) {
3050
- cache = /* @__PURE__ */ new WeakMap();
3051
- resolvedOverrideOptionsByClassNameSet.set(overrideOptions, cache);
3052
- }
3053
- const cached = cache.get(classNameSet);
3127
+ const cached = entry.bySet.get(classNameSet);
3054
3128
  if (cached) {
3055
3129
  return cached;
3056
3130
  }
@@ -3061,7 +3135,7 @@ function createJsHandler(options) {
3061
3135
  },
3062
3136
  defaults
3063
3137
  );
3064
- cache.set(classNameSet, created);
3138
+ entry.bySet.set(classNameSet, created);
3065
3139
  return created;
3066
3140
  }
3067
3141
  function handler(rawSource, classNameSet, options2) {
@@ -3591,6 +3665,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3591
3665
  cssRemoveProperty,
3592
3666
  cssRemoveHoverPseudoClass,
3593
3667
  cssPresetEnv,
3668
+ autoprefixer,
3594
3669
  uniAppX,
3595
3670
  px2rpx,
3596
3671
  unitsToPx,
@@ -3606,6 +3681,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3606
3681
  replaceRuntimePackages
3607
3682
  } = ctx;
3608
3683
  const uniAppXEnabled = isUniAppXEnabled(uniAppX);
3684
+ const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
3609
3685
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
3610
3686
  const styleHandler = createStyleHandler({
3611
3687
  cssPreflight,
@@ -3619,10 +3695,13 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3619
3695
  cssRemoveProperty,
3620
3696
  cssRemoveHoverPseudoClass,
3621
3697
  cssPresetEnv,
3698
+ autoprefixer,
3622
3699
  uniAppX: uniAppXEnabled,
3700
+ uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
3623
3701
  cssCalc: cssCalcOptions,
3624
3702
  px2rpx,
3625
- unitsToPx
3703
+ unitsToPx,
3704
+ majorVersion: tailwindcssMajorVersion
3626
3705
  });
3627
3706
  const jsHandler2 = createJsHandler({
3628
3707
  escapeMap,
@@ -3653,7 +3732,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3653
3732
  }
3654
3733
 
3655
3734
  // src/context/logger.ts
3656
- import { logger as logger5 } from "@weapp-tailwindcss/logger";
3735
+ import { logger as logger6 } from "@weapp-tailwindcss/logger";
3657
3736
  var loggerLevelMap = {
3658
3737
  error: 0,
3659
3738
  warn: 1,
@@ -3661,7 +3740,7 @@ var loggerLevelMap = {
3661
3740
  silent: -999
3662
3741
  };
3663
3742
  function applyLoggerLevel(logLevel) {
3664
- logger5.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
3743
+ logger6.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
3665
3744
  }
3666
3745
 
3667
3746
  // src/context/index.ts
@@ -3677,7 +3756,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
3677
3756
  try {
3678
3757
  await patcher.clearCache({ scope: "all" });
3679
3758
  } catch (error) {
3680
- logger6.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
3759
+ logger7.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
3681
3760
  }
3682
3761
  }
3683
3762
  if (!options?.removeDirectory) {
@@ -3706,7 +3785,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
3706
3785
  if (err?.code === "ENOENT") {
3707
3786
  continue;
3708
3787
  }
3709
- logger6.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
3788
+ logger7.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
3710
3789
  }
3711
3790
  }
3712
3791
  }
@@ -3720,11 +3799,11 @@ function createInternalCompilerContext(opts) {
3720
3799
  applyLoggerLevel(ctx.logLevel);
3721
3800
  const twPatcher = createTailwindcssPatcherFromContext(ctx);
3722
3801
  logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
3723
- if (twPatcher.packageInfo?.version) {
3724
- logger6.success(`\u5F53\u524D\u4F7F\u7528 ${pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${pc.underline(pc.bold(pc.green(twPatcher.packageInfo.version)))}`);
3725
- } else {
3726
- logger6.warn(`${pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
3727
- }
3802
+ logRuntimeTailwindcssVersion(
3803
+ ctx.tailwindcssBasedir,
3804
+ twPatcher.packageInfo?.rootPath,
3805
+ twPatcher.packageInfo?.version
3806
+ );
3728
3807
  warnMissingCssEntries(ctx, twPatcher);
3729
3808
  const cssCalcOptions = applyV4CssCalcDefaults(ctx.cssCalc, twPatcher);
3730
3809
  ctx.cssCalc = cssCalcOptions;
@@ -3762,6 +3841,31 @@ function getCompilerContext(opts) {
3762
3841
  return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
3763
3842
  }
3764
3843
 
3844
+ // src/js/precheck.ts
3845
+ var FAST_JS_TRANSFORM_HINT_RE = /className\b|class\s*=|classList\.|\b(?:twMerge|clsx|classnames|cn|cva)\b|\[["'`]class["'`]\]|text-\[|bg-\[|\b(?:[whpm]|px|py|mx|my|rounded|flex|grid|gap)-/;
3846
+ var DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
3847
+ function shouldSkipJsTransform(rawSource, options) {
3848
+ if (process.env.WEAPP_TW_DISABLE_JS_PRECHECK === "1") {
3849
+ return false;
3850
+ }
3851
+ if (!rawSource) {
3852
+ return true;
3853
+ }
3854
+ if (options?.alwaysEscape) {
3855
+ return false;
3856
+ }
3857
+ if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) {
3858
+ return false;
3859
+ }
3860
+ if (options?.wrapExpression) {
3861
+ return false;
3862
+ }
3863
+ if (DEPENDENCY_HINT_RE.test(rawSource)) {
3864
+ return false;
3865
+ }
3866
+ return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
3867
+ }
3868
+
3765
3869
  // src/tailwindcss/recorder.ts
3766
3870
  function setupPatchRecorder(patcher, baseDir, options) {
3767
3871
  const recorder = createPatchTargetRecorder(baseDir, patcher, options);
@@ -3797,5 +3901,6 @@ export {
3797
3901
  createAttributeMatcher,
3798
3902
  generateCode,
3799
3903
  getCompilerContext,
3904
+ shouldSkipJsTransform,
3800
3905
  setupPatchRecorder
3801
3906
  };