weapp-tailwindcss 4.11.2 → 4.12.0-next.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 (67) hide show
  1. package/README.md +38 -0
  2. package/dist/{chunk-WJIRXC26.js → chunk-5ONE75V7.js} +117 -119
  3. package/dist/{chunk-OMARW5NC.mjs → chunk-AYJ4HLWZ.mjs} +4 -2
  4. package/dist/{chunk-VGPAKLMZ.mjs → chunk-F5XJWJYO.mjs} +12 -7
  5. package/dist/{chunk-SUKOZ6OG.js → chunk-FMK6SFQQ.js} +10 -6
  6. package/dist/{chunk-TT5WHNGS.js → chunk-GC7WXUOW.js} +136 -77
  7. package/dist/{chunk-W3DXDWYC.mjs → chunk-GD4SQMVF.mjs} +49 -51
  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-3QHYEMEW.js → chunk-LVSUBDJC.js} +45 -40
  11. package/dist/{chunk-QK6VNNNL.js → chunk-NIS74SI6.js} +8 -6
  12. package/dist/{chunk-CRDOWYG4.js → chunk-ONLKZIRQ.js} +1 -1
  13. package/dist/{chunk-AB2RGZQO.mjs → chunk-QNRJCEZN.mjs} +131 -72
  14. package/dist/{chunk-ZZ36BKM5.mjs → chunk-UUJWDME4.mjs} +6 -2
  15. package/dist/{chunk-AV3XB6EQ.js → chunk-WSS26HZS.js} +5 -5
  16. package/dist/{chunk-JIERVBTX.mjs → chunk-ZR3KN3FG.mjs} +1 -1
  17. package/dist/cli.js +8 -1
  18. package/dist/cli.mjs +8 -1
  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";
@@ -362,14 +363,14 @@ function initializeCache(cacheConfig) {
362
363
  }
363
364
 
364
365
  // src/tailwindcss/runtime-logs.ts
365
- import process from "process";
366
+ import process2 from "process";
366
367
  import { logger as logger2, pc } from "@weapp-tailwindcss/logger";
367
368
  var runtimeLogDedupeHolder = globalThis;
368
369
  var runtimeLogDedupe = runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
369
370
  function createRuntimeLogKey(category, baseDir, rootPath, version) {
370
371
  return JSON.stringify([
371
372
  category,
372
- baseDir ?? process.cwd(),
373
+ baseDir ?? process2.cwd(),
373
374
  rootPath ?? "",
374
375
  version ?? ""
375
376
  ]);
@@ -404,7 +405,7 @@ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
404
405
  }
405
406
 
406
407
  // src/tailwindcss/targets.ts
407
- import process4 from "process";
408
+ import process5 from "process";
408
409
  import { logger as logger4 } from "@weapp-tailwindcss/logger";
409
410
 
410
411
  // src/tailwindcss/targets/paths.ts
@@ -459,13 +460,13 @@ function getRecordFileCandidates(baseDir) {
459
460
  import { existsSync as existsSync2, readFileSync } from "fs";
460
461
  import { mkdir, writeFile } from "fs/promises";
461
462
  import path2 from "path";
462
- import process2 from "process";
463
+ import process3 from "process";
463
464
  import { logger as logger3 } from "@weapp-tailwindcss/logger";
464
465
 
465
466
  // package.json
466
467
  var package_default = {
467
468
  name: "weapp-tailwindcss",
468
- version: "4.11.2",
469
+ version: "4.12.0-next.0",
469
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!",
470
471
  author: "ice breaker <1324318532@qq.com>",
471
472
  license: "MIT",
@@ -667,6 +668,7 @@ var package_default = {
667
668
  "@weapp-core/regex": "~1.0.1",
668
669
  "@weapp-tailwindcss/logger": "workspace:*",
669
670
  "@weapp-tailwindcss/postcss": "workspace:*",
671
+ "@weapp-tailwindcss/reset": "workspace:*",
670
672
  "@weapp-tailwindcss/shared": "workspace:*",
671
673
  cac: "6.7.14",
672
674
  "comment-json": "^4.6.2",
@@ -681,6 +683,9 @@ var package_default = {
681
683
  "tailwindcss-patch": "catalog:tailwindcssPatch",
682
684
  "webpack-sources": "3.3.4",
683
685
  yaml: "^2.8.3"
686
+ },
687
+ devDependencies: {
688
+ "fast-check": "^4.7.0"
684
689
  }
685
690
  };
686
691
 
@@ -703,7 +708,7 @@ function warnInvalidPatchTargetRecord(baseDir, recordPath, reason) {
703
708
  }
704
709
  loggedInvalidPatchRecords.add(normalizedPath);
705
710
  const fileDisplay = formatRelativeToBase(normalizedPath, baseDir);
706
- const baseDisplay = formatRelativeToBase(path2.normalize(baseDir), process2.cwd());
711
+ const baseDisplay = formatRelativeToBase(path2.normalize(baseDir), process3.cwd());
707
712
  const reasonMessage = reason ? `\uFF1A${reason}` : "";
708
713
  logger3.warn(
709
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`
@@ -762,7 +767,7 @@ async function saveCliPatchTargetRecord(baseDir, patcher, options) {
762
767
  `, "utf8");
763
768
  return recordPath;
764
769
  } catch (error) {
765
- const baseDisplay = formatRelativeToBase(normalizedBase, process2.cwd());
770
+ const baseDisplay = formatRelativeToBase(normalizedBase, process3.cwd());
766
771
  logger3.warn(
767
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',
768
773
  baseDisplay,
@@ -775,10 +780,10 @@ async function saveCliPatchTargetRecord(baseDir, patcher, options) {
775
780
 
776
781
  // src/tailwindcss/targets/recorder.ts
777
782
  import path3 from "path";
778
- import process3 from "process";
783
+ import process4 from "process";
779
784
  function findPatchTargetRecord(baseDir) {
780
785
  const visited = /* @__PURE__ */ new Set();
781
- const fallback = baseDir ?? process3.cwd();
786
+ const fallback = baseDir ?? process4.cwd();
782
787
  let current = path3.resolve(fallback);
783
788
  while (!visited.has(current)) {
784
789
  const record = readPatchTargetRecord(current);
@@ -861,7 +866,7 @@ function logTailwindcssTarget(kind, patcher, baseDir) {
861
866
  logger4.warn(
862
867
  "%s \u672A\u627E\u5230 Tailwind CSS \u4F9D\u8D56\uFF0C\u8BF7\u68C0\u67E5\u5728 %s \u662F\u5426\u5DF2\u5B89\u88C5 tailwindcss",
863
868
  label,
864
- baseDir ?? process4.cwd()
869
+ baseDir ?? process5.cwd()
865
870
  );
866
871
  return;
867
872
  }
@@ -877,7 +882,7 @@ function logTailwindcssTarget(kind, patcher, baseDir) {
877
882
  // src/context/compiler-context-cache.ts
878
883
  import { Buffer } from "buffer";
879
884
  import path4 from "path";
880
- import process5 from "process";
885
+ import process6 from "process";
881
886
  import { logger as logger5 } from "@weapp-tailwindcss/logger";
882
887
  var PAREN_CONTENT_RE = /\(([^)]+)\)/u;
883
888
  var AT_LOCATION_RE = /at\s+(\S.*)$/u;
@@ -911,7 +916,7 @@ function shouldProbeCallerLocation(opts) {
911
916
  if (hasExplicitOptionBasedir(opts)) {
912
917
  return false;
913
918
  }
914
- return !(process5.env.WEAPP_TAILWINDCSS_BASEDIR || process5.env.WEAPP_TAILWINDCSS_BASE_DIR || process5.env.TAILWINDCSS_BASEDIR || process5.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);
915
920
  }
916
921
  function detectCallerLocation() {
917
922
  const stack = new Error("compiler-context-cache stack probe").stack;
@@ -944,20 +949,20 @@ function getRuntimeCacheScope(opts) {
944
949
  }
945
950
  const runtimeScope = {
946
951
  caller: void 0,
947
- cwd: process5.cwd(),
948
- init_cwd: process5.env.INIT_CWD,
949
- npm_config_local_prefix: process5.env.npm_config_local_prefix,
950
- npm_package_json: process5.env.npm_package_json,
951
- pnpm_package_name: process5.env.PNPM_PACKAGE_NAME,
952
- pwd: process5.env.PWD,
953
- tailwindcss_base_dir: process5.env.TAILWINDCSS_BASE_DIR,
954
- tailwindcss_basedir: process5.env.TAILWINDCSS_BASEDIR,
955
- uni_app_input_dir: process5.env.UNI_APP_INPUT_DIR,
956
- uni_cli_root: process5.env.UNI_CLI_ROOT,
957
- uni_input_dir: process5.env.UNI_INPUT_DIR,
958
- uni_input_root: process5.env.UNI_INPUT_ROOT,
959
- weapp_tailwindcss_base_dir: process5.env.WEAPP_TAILWINDCSS_BASE_DIR,
960
- weapp_tailwindcss_basedir: process5.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
961
966
  };
962
967
  if (shouldProbeCallerLocation(opts)) {
963
968
  runtimeScope.caller = detectCallerLocation();
@@ -1164,6 +1169,9 @@ function toCustomAttributesEntities(customAttributes) {
1164
1169
  // src/context/handlers.ts
1165
1170
  import { createStyleHandler } from "@weapp-tailwindcss/postcss";
1166
1171
 
1172
+ // src/js/index.ts
1173
+ import { LRUCache as LRUCache3 } from "lru-cache";
1174
+
1167
1175
  // src/babel/index.ts
1168
1176
  import _babelTraverse from "@babel/traverse";
1169
1177
  import { parse, parseExpression } from "@babel/parser";
@@ -2981,6 +2989,49 @@ function jsHandler(rawSource, options) {
2981
2989
  }
2982
2990
 
2983
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
+ }
2984
3035
  function hasDefinedOverrides(options) {
2985
3036
  if (!options) {
2986
3037
  return false;
@@ -2992,17 +3043,6 @@ function hasDefinedOverrides(options) {
2992
3043
  }
2993
3044
  return false;
2994
3045
  }
2995
- var CACHEABLE_SOURCE_MAX_LENGTH = 512;
2996
- var RESULT_CACHE_LIMIT = 256;
2997
- function shouldCacheJsResult(rawSource, options) {
2998
- if (rawSource.length === 0 || rawSource.length > CACHEABLE_SOURCE_MAX_LENGTH) {
2999
- return false;
3000
- }
3001
- if (options.moduleGraph || options.filename) {
3002
- return false;
3003
- }
3004
- return true;
3005
- }
3006
3046
  function createJsHandler(options) {
3007
3047
  const defaults = {
3008
3048
  escapeMap: options.escapeMap,
@@ -3021,11 +3061,10 @@ function createJsHandler(options) {
3021
3061
  uniAppX: options.uniAppX,
3022
3062
  moduleSpecifierReplacements: options.moduleSpecifierReplacements
3023
3063
  };
3024
- const resolvedOptionsByClassNameSet = /* @__PURE__ */ new WeakMap();
3064
+ const defaultOptionsCache = /* @__PURE__ */ new WeakMap();
3025
3065
  let resolvedOptionsWithoutClassNameSet;
3026
- const resolvedOverrideOptions = /* @__PURE__ */ new WeakMap();
3027
- const resolvedOverrideOptionsByClassNameSet = /* @__PURE__ */ new WeakMap();
3028
- const resultCache = /* @__PURE__ */ new WeakMap();
3066
+ const overrideOptionsCache = /* @__PURE__ */ new WeakMap();
3067
+ const resultCache = new LRUCache3({ max: RESULT_CACHE_MAX });
3029
3068
  function resolveDefaultOptions(classNameSet) {
3030
3069
  if (!classNameSet) {
3031
3070
  if (!resolvedOptionsWithoutClassNameSet) {
@@ -3036,7 +3075,7 @@ function createJsHandler(options) {
3036
3075
  }
3037
3076
  return resolvedOptionsWithoutClassNameSet;
3038
3077
  }
3039
- const cached = resolvedOptionsByClassNameSet.get(classNameSet);
3078
+ const cached = defaultOptionsCache.get(classNameSet);
3040
3079
  if (cached) {
3041
3080
  return cached;
3042
3081
  }
@@ -3044,42 +3083,36 @@ function createJsHandler(options) {
3044
3083
  ...defaults,
3045
3084
  classNameSet
3046
3085
  };
3047
- resolvedOptionsByClassNameSet.set(classNameSet, created);
3086
+ defaultOptionsCache.set(classNameSet, created);
3048
3087
  return created;
3049
3088
  }
3050
3089
  function getCachedJsResult(rawSource, resolvedOptions) {
3051
- if (!shouldCacheJsResult(rawSource, resolvedOptions)) {
3090
+ if (rawSource.length === 0) {
3052
3091
  return void 0;
3053
3092
  }
3054
- const cache = resultCache.get(resolvedOptions);
3055
- return cache?.get(rawSource);
3093
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${md5(rawSource)}`;
3094
+ return resultCache.get(key);
3056
3095
  }
3057
3096
  function setCachedJsResult(rawSource, resolvedOptions, result) {
3058
- if (!shouldCacheJsResult(rawSource, resolvedOptions) || result.error || result.linked) {
3097
+ if (rawSource.length === 0 || result.error || result.linked) {
3059
3098
  return result;
3060
3099
  }
3061
- let cache = resultCache.get(resolvedOptions);
3062
- if (!cache) {
3063
- cache = /* @__PURE__ */ new Map();
3064
- resultCache.set(resolvedOptions, cache);
3065
- }
3066
- cache.set(rawSource, result);
3067
- if (cache.size > RESULT_CACHE_LIMIT) {
3068
- const firstKey = cache.keys().next().value;
3069
- if (typeof firstKey === "string") {
3070
- cache.delete(firstKey);
3071
- }
3072
- }
3100
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${md5(rawSource)}`;
3101
+ resultCache.set(key, result);
3073
3102
  return result;
3074
3103
  }
3075
3104
  function resolveOptions(classNameSet, overrideOptions) {
3076
3105
  if (!hasDefinedOverrides(overrideOptions)) {
3077
3106
  return resolveDefaultOptions(classNameSet);
3078
3107
  }
3108
+ let entry = overrideOptionsCache.get(overrideOptions);
3109
+ if (!entry) {
3110
+ entry = { bySet: /* @__PURE__ */ new WeakMap() };
3111
+ overrideOptionsCache.set(overrideOptions, entry);
3112
+ }
3079
3113
  if (!classNameSet) {
3080
- const cached2 = resolvedOverrideOptions.get(overrideOptions);
3081
- if (cached2) {
3082
- return cached2;
3114
+ if (entry.noSet) {
3115
+ return entry.noSet;
3083
3116
  }
3084
3117
  const created2 = defuOverrideArray(
3085
3118
  {
@@ -3088,15 +3121,10 @@ function createJsHandler(options) {
3088
3121
  },
3089
3122
  defaults
3090
3123
  );
3091
- resolvedOverrideOptions.set(overrideOptions, created2);
3124
+ entry.noSet = created2;
3092
3125
  return created2;
3093
3126
  }
3094
- let cache = resolvedOverrideOptionsByClassNameSet.get(overrideOptions);
3095
- if (!cache) {
3096
- cache = /* @__PURE__ */ new WeakMap();
3097
- resolvedOverrideOptionsByClassNameSet.set(overrideOptions, cache);
3098
- }
3099
- const cached = cache.get(classNameSet);
3127
+ const cached = entry.bySet.get(classNameSet);
3100
3128
  if (cached) {
3101
3129
  return cached;
3102
3130
  }
@@ -3107,7 +3135,7 @@ function createJsHandler(options) {
3107
3135
  },
3108
3136
  defaults
3109
3137
  );
3110
- cache.set(classNameSet, created);
3138
+ entry.bySet.set(classNameSet, created);
3111
3139
  return created;
3112
3140
  }
3113
3141
  function handler(rawSource, classNameSet, options2) {
@@ -3637,6 +3665,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3637
3665
  cssRemoveProperty,
3638
3666
  cssRemoveHoverPseudoClass,
3639
3667
  cssPresetEnv,
3668
+ autoprefixer,
3640
3669
  uniAppX,
3641
3670
  px2rpx,
3642
3671
  unitsToPx,
@@ -3652,6 +3681,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3652
3681
  replaceRuntimePackages
3653
3682
  } = ctx;
3654
3683
  const uniAppXEnabled = isUniAppXEnabled(uniAppX);
3684
+ const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
3655
3685
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
3656
3686
  const styleHandler = createStyleHandler({
3657
3687
  cssPreflight,
@@ -3665,10 +3695,13 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
3665
3695
  cssRemoveProperty,
3666
3696
  cssRemoveHoverPseudoClass,
3667
3697
  cssPresetEnv,
3698
+ autoprefixer,
3668
3699
  uniAppX: uniAppXEnabled,
3700
+ uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
3669
3701
  cssCalc: cssCalcOptions,
3670
3702
  px2rpx,
3671
- unitsToPx
3703
+ unitsToPx,
3704
+ majorVersion: tailwindcssMajorVersion
3672
3705
  });
3673
3706
  const jsHandler2 = createJsHandler({
3674
3707
  escapeMap,
@@ -3808,6 +3841,31 @@ function getCompilerContext(opts) {
3808
3841
  return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
3809
3842
  }
3810
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
+
3811
3869
  // src/tailwindcss/recorder.ts
3812
3870
  function setupPatchRecorder(patcher, baseDir, options) {
3813
3871
  const recorder = createPatchTargetRecorder(baseDir, patcher, options);
@@ -3843,5 +3901,6 @@ export {
3843
3901
  createAttributeMatcher,
3844
3902
  generateCode,
3845
3903
  getCompilerContext,
3904
+ shouldSkipJsTransform,
3846
3905
  setupPatchRecorder
3847
3906
  };
@@ -6,8 +6,9 @@ import {
6
6
  ensureRuntimeClassSet,
7
7
  getCompilerContext,
8
8
  refreshTailwindRuntimeState,
9
- setupPatchRecorder
10
- } from "./chunk-AB2RGZQO.mjs";
9
+ setupPatchRecorder,
10
+ shouldSkipJsTransform
11
+ } from "./chunk-QNRJCEZN.mjs";
11
12
 
12
13
  // src/bundlers/gulp/index.ts
13
14
  import { Buffer } from "buffer";
@@ -225,6 +226,9 @@ function createPlugins(options = {}) {
225
226
  async transform() {
226
227
  await runtimeState.patchPromise;
227
228
  const currentSource = file.contents?.toString() ?? rawSource;
229
+ if (shouldSkipJsTransform(currentSource, handlerOptions)) {
230
+ return { result: currentSource };
231
+ }
228
232
  const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
229
233
  debug("js handle: %s", file.path);
230
234
  return {
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk7LKMJZD2js = require('./chunk-7LKMJZD2.js');
3
+ var _chunkGMKSBLNYjs = require('./chunk-GMKSBLNY.js');
4
4
 
5
5
 
6
- var _chunkTT5WHNGSjs = require('./chunk-TT5WHNGS.js');
6
+ var _chunkGC7WXUOWjs = require('./chunk-GC7WXUOW.js');
7
7
 
8
8
  // src/shared/mpx.ts
9
9
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
@@ -145,7 +145,7 @@ function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
145
145
  if (!CSS_EXT_RE2.test(normalizedIssuer)) {
146
146
  return;
147
147
  }
148
- const resolved = _chunk7LKMJZD2js.resolveTailwindcssImport.call(void 0, request, pkgDir, { appType });
148
+ const resolved = _chunkGMKSBLNYjs.resolveTailwindcssImport.call(void 0, request, pkgDir, { appType });
149
149
  if (!resolved) {
150
150
  return;
151
151
  }
@@ -155,8 +155,8 @@ function applyTailwindcssCssImportRewrite(compiler, options) {
155
155
  if (!options.enabled) {
156
156
  return;
157
157
  }
158
- compiler.hooks.normalModuleFactory.tap(_chunkTT5WHNGSjs.pluginName, (factory) => {
159
- factory.hooks.beforeResolve.tap(_chunkTT5WHNGSjs.pluginName, (data) => {
158
+ compiler.hooks.normalModuleFactory.tap(_chunkGC7WXUOWjs.pluginName, (factory) => {
159
+ factory.hooks.beforeResolve.tap(_chunkGC7WXUOWjs.pluginName, (data) => {
160
160
  rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
161
161
  });
162
162
  });
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-F2CKKG6Q.mjs";
4
4
  import {
5
5
  pluginName
6
- } from "./chunk-AB2RGZQO.mjs";
6
+ } from "./chunk-QNRJCEZN.mjs";
7
7
 
8
8
  // src/shared/mpx.ts
9
9
  import path2 from "path";
package/dist/cli.js CHANGED
@@ -208,7 +208,7 @@ var import_logger2 = require("@weapp-tailwindcss/logger");
208
208
  // package.json
209
209
  var package_default = {
210
210
  name: "weapp-tailwindcss",
211
- version: "4.11.2",
211
+ version: "4.12.0-next.0",
212
212
  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!",
213
213
  author: "ice breaker <1324318532@qq.com>",
214
214
  license: "MIT",
@@ -410,6 +410,7 @@ var package_default = {
410
410
  "@weapp-core/regex": "~1.0.1",
411
411
  "@weapp-tailwindcss/logger": "workspace:*",
412
412
  "@weapp-tailwindcss/postcss": "workspace:*",
413
+ "@weapp-tailwindcss/reset": "workspace:*",
413
414
  "@weapp-tailwindcss/shared": "workspace:*",
414
415
  cac: "6.7.14",
415
416
  "comment-json": "^4.6.2",
@@ -424,6 +425,9 @@ var package_default = {
424
425
  "tailwindcss-patch": "catalog:tailwindcssPatch",
425
426
  "webpack-sources": "3.3.4",
426
427
  yaml: "^2.8.3"
428
+ },
429
+ devDependencies: {
430
+ "fast-check": "^4.7.0"
427
431
  }
428
432
  };
429
433
 
@@ -645,6 +649,9 @@ var compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__
645
649
  // src/context/handlers.ts
646
650
  var import_postcss = require("@weapp-tailwindcss/postcss");
647
651
 
652
+ // src/js/index.ts
653
+ var import_lru_cache3 = require("lru-cache");
654
+
648
655
  // src/babel/index.ts
649
656
  var import_traverse = __toESM(require("@babel/traverse"));
650
657
  var import_parser = require("@babel/parser");
package/dist/cli.mjs CHANGED
@@ -184,7 +184,7 @@ import { logger as logger2 } from "@weapp-tailwindcss/logger";
184
184
  // package.json
185
185
  var package_default = {
186
186
  name: "weapp-tailwindcss",
187
- version: "4.11.2",
187
+ version: "4.12.0-next.0",
188
188
  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!",
189
189
  author: "ice breaker <1324318532@qq.com>",
190
190
  license: "MIT",
@@ -386,6 +386,7 @@ var package_default = {
386
386
  "@weapp-core/regex": "~1.0.1",
387
387
  "@weapp-tailwindcss/logger": "workspace:*",
388
388
  "@weapp-tailwindcss/postcss": "workspace:*",
389
+ "@weapp-tailwindcss/reset": "workspace:*",
389
390
  "@weapp-tailwindcss/shared": "workspace:*",
390
391
  cac: "6.7.14",
391
392
  "comment-json": "^4.6.2",
@@ -400,6 +401,9 @@ var package_default = {
400
401
  "tailwindcss-patch": "catalog:tailwindcssPatch",
401
402
  "webpack-sources": "3.3.4",
402
403
  yaml: "^2.8.3"
404
+ },
405
+ devDependencies: {
406
+ "fast-check": "^4.7.0"
403
407
  }
404
408
  };
405
409
 
@@ -621,6 +625,9 @@ var compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__
621
625
  // src/context/handlers.ts
622
626
  import { createStyleHandler } from "@weapp-tailwindcss/postcss";
623
627
 
628
+ // src/js/index.ts
629
+ import { LRUCache as LRUCache3 } from "lru-cache";
630
+
624
631
  // src/babel/index.ts
625
632
  import _babelTraverse from "@babel/traverse";
626
633
  import { parse, parseExpression } from "@babel/parser";
package/dist/core.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ITemplateHandlerOptions, CreateJsHandlerOptions, JsHandlerResult } from './types.mjs';
2
2
  import * as postcss from 'postcss';
3
- import { e as UserDefinedOptions } from './index-CoXntW_P.mjs';
3
+ import { e as UserDefinedOptions } from './index-BXrmQelt.mjs';
4
4
  import { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
5
5
  import '@babel/parser';
6
6
  import 'magic-string';
package/dist/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ITemplateHandlerOptions, CreateJsHandlerOptions, JsHandlerResult } from './types.js';
2
2
  import * as postcss from 'postcss';
3
- import { e as UserDefinedOptions } from './index-CoXntW_P.js';
3
+ import { e as UserDefinedOptions } from './index-BXrmQelt.js';
4
4
  import { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
5
5
  import '@babel/parser';
6
6
  import 'magic-string';
package/dist/core.js CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkTT5WHNGSjs = require('./chunk-TT5WHNGS.js');
6
- require('./chunk-QK6VNNNL.js');
5
+
6
+ var _chunkGC7WXUOWjs = require('./chunk-GC7WXUOW.js');
7
+ require('./chunk-NIS74SI6.js');
7
8
  require('./chunk-A5PB4KZT.js');
8
9
  require('./chunk-DYLQ6UOI.js');
9
- require('./chunk-CRDOWYG4.js');
10
+ require('./chunk-ONLKZIRQ.js');
10
11
 
11
12
  // src/core.ts
12
13
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
@@ -24,9 +25,9 @@ function resolveTransformWxssOptions(options) {
24
25
  return _shared.defuOverrideArray.call(void 0, options, DEFAULT_MAIN_CHUNK_STYLE_OPTIONS);
25
26
  }
26
27
  function createContext(options = {}) {
27
- const opts = _chunkTT5WHNGSjs.getCompilerContext.call(void 0, options);
28
+ const opts = _chunkGC7WXUOWjs.getCompilerContext.call(void 0, options);
28
29
  const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
29
- const patchRecorderState = _chunkTT5WHNGSjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
30
+ const patchRecorderState = _chunkGC7WXUOWjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
30
31
  source: "runtime",
31
32
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
32
33
  });
@@ -143,7 +144,7 @@ function createContext(options = {}) {
143
144
  async function transformWxss(rawCss, options2) {
144
145
  await runtimeState.patchPromise;
145
146
  const result = await styleHandler(rawCss, resolveTransformWxssOptions(options2));
146
- runtimeSet = await _chunkTT5WHNGSjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
147
+ runtimeSet = await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
147
148
  forceRefresh: true,
148
149
  forceCollect: true
149
150
  });
@@ -154,16 +155,20 @@ function createContext(options = {}) {
154
155
  if (_optionalChain([options2, 'optionalAccess', _ => _.runtimeSet])) {
155
156
  runtimeSet = options2.runtimeSet;
156
157
  } else if (runtimeSet.size === 0) {
157
- runtimeSet = await _chunkTT5WHNGSjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
158
+ runtimeSet = await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
158
159
  forceCollect: true
159
160
  });
160
161
  }
161
- return await jsHandler(rawJs, runtimeSet, resolveTransformJsOptions(options2));
162
+ const resolvedOptions = resolveTransformJsOptions(options2);
163
+ if (_chunkGC7WXUOWjs.shouldSkipJsTransform.call(void 0, rawJs, resolvedOptions)) {
164
+ return { code: rawJs };
165
+ }
166
+ return await jsHandler(rawJs, runtimeSet, resolvedOptions);
162
167
  }
163
168
  async function transformWxml(rawWxml, options2) {
164
169
  await runtimeState.patchPromise;
165
170
  if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
166
- runtimeSet = await _chunkTT5WHNGSjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
171
+ runtimeSet = await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
167
172
  forceCollect: true
168
173
  });
169
174
  }
package/dist/core.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  ensureRuntimeClassSet,
3
3
  getCompilerContext,
4
- setupPatchRecorder
5
- } from "./chunk-AB2RGZQO.mjs";
6
- import "./chunk-OMARW5NC.mjs";
4
+ setupPatchRecorder,
5
+ shouldSkipJsTransform
6
+ } from "./chunk-QNRJCEZN.mjs";
7
+ import "./chunk-AYJ4HLWZ.mjs";
7
8
  import "./chunk-XAKAD2CR.mjs";
8
9
  import "./chunk-OOHJLO5M.mjs";
9
- import "./chunk-EFBQ4SQR.mjs";
10
+ import "./chunk-HL3US2OT.mjs";
10
11
 
11
12
  // src/core.ts
12
13
  import process from "process";
@@ -158,7 +159,11 @@ function createContext(options = {}) {
158
159
  forceCollect: true
159
160
  });
160
161
  }
161
- return await jsHandler(rawJs, runtimeSet, resolveTransformJsOptions(options2));
162
+ const resolvedOptions = resolveTransformJsOptions(options2);
163
+ if (shouldSkipJsTransform(rawJs, resolvedOptions)) {
164
+ return { code: rawJs };
165
+ }
166
+ return await jsHandler(rawJs, runtimeSet, resolvedOptions);
162
167
  }
163
168
  async function transformWxml(rawWxml, options2) {
164
169
  await runtimeState.patchPromise;
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  var _chunkOYSABARDjs = require('../chunk-OYSABARD.js');
6
- require('../chunk-CRDOWYG4.js');
6
+ require('../chunk-ONLKZIRQ.js');
7
7
 
8
8
  // src/css-macro/postcss.ts
9
9
  var IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;