weapp-tailwindcss 4.7.0 → 4.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{chunk-Q5TPAJI4.js → chunk-2SI3KT2H.js} +7 -6
  2. package/dist/{chunk-IY2OKZE6.mjs → chunk-3ARXMTWC.mjs} +21 -8
  3. package/dist/{chunk-D7SF52F6.mjs → chunk-5BW6X6AJ.mjs} +42 -36
  4. package/dist/chunk-667CYXAH.mjs +133 -0
  5. package/dist/chunk-BUMQQPAO.js +133 -0
  6. package/dist/{chunk-W3JU6K3T.js → chunk-FPDJ3BCM.js} +260 -108
  7. package/dist/{chunk-BAXZHBSU.js → chunk-GNWJEIZZ.js} +92 -77
  8. package/dist/{chunk-7TKAJ3P6.mjs → chunk-JYCQWWYU.mjs} +257 -105
  9. package/dist/{chunk-NRG7N2Q7.mjs → chunk-KZJLIZIK.mjs} +0 -1
  10. package/dist/{chunk-34T2BFTJ.mjs → chunk-KZUIVLPP.mjs} +42 -1
  11. package/dist/{chunk-C3CG4UUY.js → chunk-OPTIAB5G.js} +21 -8
  12. package/dist/{chunk-BTOCLUJ4.mjs → chunk-Q6PLZCM6.mjs} +6 -5
  13. package/dist/{chunk-CCMDCC3N.js → chunk-QZRXYCOQ.js} +49 -43
  14. package/dist/{chunk-WVKK6TBL.js → chunk-W7BVY5S5.js} +42 -1
  15. package/dist/{chunk-LZ6L3UQO.js → chunk-WXBFAARR.js} +0 -1
  16. package/dist/{chunk-KSXOBEXQ.mjs → chunk-Z2H7M33Z.mjs} +83 -68
  17. package/dist/cli.js +6 -6
  18. package/dist/cli.mjs +3 -3
  19. package/dist/core.js +10 -9
  20. package/dist/core.mjs +10 -9
  21. package/dist/defaults.js +2 -2
  22. package/dist/defaults.mjs +1 -1
  23. package/dist/gulp.js +6 -6
  24. package/dist/gulp.mjs +5 -5
  25. package/dist/index.js +9 -9
  26. package/dist/index.mjs +8 -8
  27. package/dist/presets.js +2 -2
  28. package/dist/presets.mjs +1 -1
  29. package/dist/types.d.mts +2 -21
  30. package/dist/types.d.ts +2 -21
  31. package/dist/vite.js +7 -7
  32. package/dist/vite.mjs +6 -6
  33. package/dist/webpack.js +7 -7
  34. package/dist/webpack.mjs +6 -6
  35. package/dist/webpack4.js +51 -45
  36. package/dist/webpack4.mjs +44 -38
  37. package/package.json +4 -4
  38. package/dist/chunk-FB5P4TRH.js +0 -70
  39. package/dist/chunk-YPBRGP6K.mjs +0 -70
@@ -3,10 +3,10 @@
3
3
  var _chunkDWAEHRHNjs = require('./chunk-DWAEHRHN.js');
4
4
 
5
5
 
6
- var _chunkC3CG4UUYjs = require('./chunk-C3CG4UUY.js');
6
+ var _chunkOPTIAB5Gjs = require('./chunk-OPTIAB5G.js');
7
7
 
8
8
 
9
- var _chunkLZ6L3UQOjs = require('./chunk-LZ6L3UQO.js');
9
+ var _chunkWXBFAARRjs = require('./chunk-WXBFAARR.js');
10
10
 
11
11
 
12
12
 
@@ -142,7 +142,6 @@ function toCustomAttributesEntities(customAttributes) {
142
142
  var _postcss = require('@weapp-tailwindcss/postcss');
143
143
 
144
144
  // src/js/babel.ts
145
- var _escape = require('@ast-core/escape');
146
145
 
147
146
  var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
148
147
 
@@ -209,6 +208,84 @@ function createNameMatcher(list, { exact = false } = {}) {
209
208
  };
210
209
  }
211
210
 
211
+ // src/js/evalTransforms.ts
212
+ var _escape = require('@ast-core/escape');
213
+ function isEvalPath(path) {
214
+ if (path.isCallExpression()) {
215
+ const calleePath = path.get("callee");
216
+ return calleePath.isIdentifier({ name: "eval" });
217
+ }
218
+ return false;
219
+ }
220
+ function createEvalReplacementToken(path, updated) {
221
+ const node = path.node;
222
+ let offset = 0;
223
+ let original;
224
+ if (path.isStringLiteral()) {
225
+ offset = 1;
226
+ original = path.node.value;
227
+ } else if (path.isTemplateElement()) {
228
+ original = path.node.value.raw;
229
+ } else {
230
+ original = "";
231
+ }
232
+ if (typeof node.start !== "number" || typeof node.end !== "number") {
233
+ return void 0;
234
+ }
235
+ const start = node.start + offset;
236
+ const end = node.end - offset;
237
+ if (start >= end) {
238
+ return void 0;
239
+ }
240
+ if (original === updated) {
241
+ return void 0;
242
+ }
243
+ const value = path.isStringLiteral() ? _escape.jsStringEscape.call(void 0, updated) : updated;
244
+ return {
245
+ start,
246
+ end,
247
+ value,
248
+ path
249
+ };
250
+ }
251
+ function handleEvalStringLiteral(path, options, updater, handler) {
252
+ const { code } = handler(path.node.value, {
253
+ ...options,
254
+ needEscaped: false,
255
+ generateMap: false
256
+ });
257
+ if (!code) {
258
+ return;
259
+ }
260
+ const token = createEvalReplacementToken(path, code);
261
+ if (token) {
262
+ updater.addToken(token);
263
+ }
264
+ }
265
+ function handleEvalTemplateElement(path, options, updater, handler) {
266
+ const { code } = handler(path.node.value.raw, {
267
+ ...options,
268
+ generateMap: false
269
+ });
270
+ if (!code) {
271
+ return;
272
+ }
273
+ const token = createEvalReplacementToken(path, code);
274
+ if (token) {
275
+ updater.addToken(token);
276
+ }
277
+ }
278
+ function walkEvalExpression(path, options, updater, handler) {
279
+ path.traverse({
280
+ StringLiteral(innerPath) {
281
+ handleEvalStringLiteral(innerPath, options, updater, handler);
282
+ },
283
+ TemplateElement(innerPath) {
284
+ handleEvalTemplateElement(innerPath, options, updater, handler);
285
+ }
286
+ });
287
+ }
288
+
212
289
  // src/js/handlers.ts
213
290
 
214
291
 
@@ -842,71 +919,7 @@ var NodePathWalker = class {
842
919
  }
843
920
  };
844
921
 
845
- // src/js/babel.ts
846
- var parseCache = new (0, _lrucache.LRUCache)(
847
- {
848
- max: 512
849
- }
850
- );
851
- function genCacheKey(source, options) {
852
- return source + JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val);
853
- }
854
- function babelParse(code, { cache, ...options } = {}) {
855
- const cacheKey = genCacheKey(code, options);
856
- let result;
857
- if (cache) {
858
- result = parseCache.get(cacheKey);
859
- }
860
- if (!result) {
861
- result = _parser.parse.call(void 0, code, options);
862
- if (cache) {
863
- parseCache.set(cacheKey, result);
864
- }
865
- }
866
- return result;
867
- }
868
- function isEvalPath(p) {
869
- if (p.isCallExpression()) {
870
- const calleePath = p.get("callee");
871
- return calleePath.isIdentifier(
872
- {
873
- name: "eval"
874
- }
875
- );
876
- }
877
- return false;
878
- }
879
- function createEvalReplacementToken(path, updated) {
880
- const node = path.node;
881
- let offset = 0;
882
- let original;
883
- if (path.isStringLiteral()) {
884
- offset = 1;
885
- original = path.node.value;
886
- } else if (path.isTemplateElement()) {
887
- original = path.node.value.raw;
888
- } else {
889
- original = "";
890
- }
891
- if (typeof node.start !== "number" || typeof node.end !== "number") {
892
- return void 0;
893
- }
894
- const start = node.start + offset;
895
- const end = node.end - offset;
896
- if (start >= end) {
897
- return void 0;
898
- }
899
- if (original === updated) {
900
- return void 0;
901
- }
902
- const value = path.isStringLiteral() ? _escape.jsStringEscape.call(void 0, updated) : updated;
903
- return {
904
- start,
905
- end,
906
- value,
907
- path
908
- };
909
- }
922
+ // src/js/sourceAnalysis.ts
910
923
  function createModuleSpecifierReplacementToken(path, replacement) {
911
924
  const node = path.node;
912
925
  if (node.value === replacement) {
@@ -964,42 +977,179 @@ function collectModuleSpecifierReplacementTokens(analysis, replacements) {
964
977
  }
965
978
  return tokens;
966
979
  }
967
- function handleEvalStringLiteral(path, options, updater, handler) {
968
- const { code } = handler(path.node.value, {
969
- ...options,
970
- needEscaped: false,
971
- generateMap: false
972
- });
973
- if (!code) {
974
- return;
975
- }
976
- const token = createEvalReplacementToken(path, code);
977
- if (token) {
978
- updater.addToken(token);
979
- }
980
+
981
+ // src/js/taggedTemplateIgnore.ts
982
+ function createTaggedTemplateIgnore({ matcher, names }) {
983
+ const bindingIgnoreCache = /* @__PURE__ */ new Map();
984
+ const taggedTemplateIgnoreCache = /* @__PURE__ */ new WeakMap();
985
+ const canonicalIgnoreNames = new Set(
986
+ (_nullishCoalesce(names, () => ( []))).filter((item) => typeof item === "string")
987
+ );
988
+ const propertyMatches = (propertyPath) => {
989
+ if (!propertyPath) {
990
+ return false;
991
+ }
992
+ if (propertyPath.isIdentifier()) {
993
+ const { name } = propertyPath.node;
994
+ return canonicalIgnoreNames.has(name) || matcher(name);
995
+ }
996
+ if (propertyPath.isStringLiteral()) {
997
+ const { value } = propertyPath.node;
998
+ return canonicalIgnoreNames.has(value) || matcher(value);
999
+ }
1000
+ return false;
1001
+ };
1002
+ const resolvesMemberExpressionToIgnore = (path, seen) => {
1003
+ const propertyPath = path.get("property");
1004
+ if (propertyMatches(propertyPath)) {
1005
+ return true;
1006
+ }
1007
+ const objectPath = path.get("object");
1008
+ if (objectPath.isIdentifier()) {
1009
+ const binding = objectPath.scope.getBinding(objectPath.node.name);
1010
+ if (binding) {
1011
+ return resolvesToWeappTwIgnore(binding, seen);
1012
+ }
1013
+ }
1014
+ return false;
1015
+ };
1016
+ const resolvesToWeappTwIgnore = (binding, seen) => {
1017
+ const cached = bindingIgnoreCache.get(binding);
1018
+ if (cached !== void 0) {
1019
+ return cached;
1020
+ }
1021
+ if (seen.has(binding)) {
1022
+ return false;
1023
+ }
1024
+ seen.add(binding);
1025
+ let result = false;
1026
+ const bindingPath = binding.path;
1027
+ if (bindingPath.isImportSpecifier()) {
1028
+ const imported = bindingPath.node.imported;
1029
+ if (imported.type === "Identifier" && (canonicalIgnoreNames.has(imported.name) || matcher(imported.name))) {
1030
+ result = true;
1031
+ } else if (imported.type === "StringLiteral" && (canonicalIgnoreNames.has(imported.value) || matcher(imported.value))) {
1032
+ result = true;
1033
+ }
1034
+ } else if (bindingPath.isVariableDeclarator()) {
1035
+ const init = bindingPath.get("init");
1036
+ if (init && init.node) {
1037
+ if (init.isIdentifier()) {
1038
+ const target = binding.scope.getBinding(init.node.name);
1039
+ if (target) {
1040
+ result = resolvesToWeappTwIgnore(target, seen);
1041
+ }
1042
+ } else if (init.isMemberExpression()) {
1043
+ result = resolvesMemberExpressionToIgnore(init, seen);
1044
+ }
1045
+ }
1046
+ }
1047
+ bindingIgnoreCache.set(binding, result);
1048
+ seen.delete(binding);
1049
+ return result;
1050
+ };
1051
+ const getEffectiveTagPath = (tagPath) => {
1052
+ let current = tagPath;
1053
+ while (true) {
1054
+ if (_optionalChain([current, 'access', _18 => _18.isParenthesizedExpression, 'optionalCall', _19 => _19()]) || current.node.type === "ParenthesizedExpression") {
1055
+ current = current.get("expression");
1056
+ continue;
1057
+ }
1058
+ if (current.isTSAsExpression() || current.isTSTypeAssertion()) {
1059
+ current = current.get("expression");
1060
+ continue;
1061
+ }
1062
+ if (current.isTSNonNullExpression()) {
1063
+ current = current.get("expression");
1064
+ continue;
1065
+ }
1066
+ if (_optionalChain([current, 'access', _20 => _20.isTypeCastExpression, 'optionalCall', _21 => _21()])) {
1067
+ current = current.get("expression");
1068
+ continue;
1069
+ }
1070
+ if (current.isSequenceExpression()) {
1071
+ const expressions = current.get("expressions");
1072
+ const last = expressions[expressions.length - 1];
1073
+ if (last) {
1074
+ current = last;
1075
+ continue;
1076
+ }
1077
+ }
1078
+ if (_optionalChain([current, 'access', _22 => _22.isCallExpression, 'optionalCall', _23 => _23()]) || current.node.type === "CallExpression") {
1079
+ const callee = current.get("callee");
1080
+ current = callee;
1081
+ continue;
1082
+ }
1083
+ break;
1084
+ }
1085
+ return current;
1086
+ };
1087
+ const evaluateTagPath = (tagPath) => {
1088
+ if (_optionalChain([tagPath, 'access', _24 => _24.isCallExpression, 'optionalCall', _25 => _25()]) || tagPath.node.type === "CallExpression") {
1089
+ const calleePath = tagPath.get("callee");
1090
+ return evaluateTagPath(calleePath);
1091
+ }
1092
+ if (tagPath.isIdentifier()) {
1093
+ if (matcher(tagPath.node.name)) {
1094
+ return true;
1095
+ }
1096
+ const binding = tagPath.scope.getBinding(tagPath.node.name);
1097
+ if (binding) {
1098
+ return resolvesToWeappTwIgnore(binding, /* @__PURE__ */ new Set());
1099
+ }
1100
+ return false;
1101
+ }
1102
+ if (tagPath.isMemberExpression()) {
1103
+ return resolvesMemberExpressionToIgnore(tagPath, /* @__PURE__ */ new Set());
1104
+ }
1105
+ return false;
1106
+ };
1107
+ const computeIgnore = (tagPath) => {
1108
+ const cached = taggedTemplateIgnoreCache.get(tagPath.node);
1109
+ if (cached !== void 0) {
1110
+ return cached;
1111
+ }
1112
+ const effectiveTagPath = getEffectiveTagPath(tagPath);
1113
+ const effectiveCached = taggedTemplateIgnoreCache.get(effectiveTagPath.node);
1114
+ if (effectiveCached !== void 0) {
1115
+ taggedTemplateIgnoreCache.set(tagPath.node, effectiveCached);
1116
+ return effectiveCached;
1117
+ }
1118
+ const result = evaluateTagPath(effectiveTagPath);
1119
+ taggedTemplateIgnoreCache.set(effectiveTagPath.node, result);
1120
+ taggedTemplateIgnoreCache.set(tagPath.node, result);
1121
+ return result;
1122
+ };
1123
+ return {
1124
+ shouldIgnore(tagPath) {
1125
+ return computeIgnore(tagPath);
1126
+ },
1127
+ getEffectiveTagPath
1128
+ };
980
1129
  }
981
- function handleEvalTemplateElement(path, options, updater, handler) {
982
- const { code } = handler(path.node.value.raw, {
983
- ...options,
984
- generateMap: false
985
- });
986
- if (!code) {
987
- return;
988
- }
989
- const token = createEvalReplacementToken(path, code);
990
- if (token) {
991
- updater.addToken(token);
1130
+
1131
+ // src/js/babel.ts
1132
+ var parseCache = new (0, _lrucache.LRUCache)(
1133
+ {
1134
+ max: 512
992
1135
  }
1136
+ );
1137
+ function genCacheKey(source, options) {
1138
+ return source + JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val);
993
1139
  }
994
- function walkEvalExpression(path, options, updater, handler) {
995
- path.traverse({
996
- StringLiteral(innerPath) {
997
- handleEvalStringLiteral(innerPath, options, updater, handler);
998
- },
999
- TemplateElement(innerPath) {
1000
- handleEvalTemplateElement(innerPath, options, updater, handler);
1140
+ function babelParse(code, { cache, ...options } = {}) {
1141
+ const cacheKey = genCacheKey(code, options);
1142
+ let result;
1143
+ if (cache) {
1144
+ result = parseCache.get(cacheKey);
1145
+ }
1146
+ if (!result) {
1147
+ result = _parser.parse.call(void 0, code, options);
1148
+ if (cache) {
1149
+ parseCache.set(cacheKey, result);
1001
1150
  }
1002
- });
1151
+ }
1152
+ return result;
1003
1153
  }
1004
1154
  function analyzeSource(ast, options, handler) {
1005
1155
  const jsTokenUpdater = new JsTokenUpdater();
@@ -1015,6 +1165,10 @@ function analyzeSource(ast, options, handler) {
1015
1165
  }
1016
1166
  );
1017
1167
  const isIgnoredTaggedTemplate = createNameMatcher(options.ignoreTaggedTemplateExpressionIdentifiers, { exact: true });
1168
+ const taggedTemplateIgnore = createTaggedTemplateIgnore({
1169
+ matcher: isIgnoredTaggedTemplate,
1170
+ names: options.ignoreTaggedTemplateExpressionIdentifiers
1171
+ });
1018
1172
  const targetPaths = [];
1019
1173
  const importDeclarations = /* @__PURE__ */ new Set();
1020
1174
  const exportDeclarations = /* @__PURE__ */ new Set();
@@ -1039,7 +1193,7 @@ function analyzeSource(ast, options, handler) {
1039
1193
  }
1040
1194
  if (ppp.isTaggedTemplateExpression()) {
1041
1195
  const tagPath = ppp.get("tag");
1042
- if (tagPath.isIdentifier() && isIgnoredTaggedTemplate(tagPath.node.name)) {
1196
+ if (taggedTemplateIgnore.shouldIgnore(tagPath)) {
1043
1197
  return;
1044
1198
  }
1045
1199
  }
@@ -1058,7 +1212,7 @@ function analyzeSource(ast, options, handler) {
1058
1212
  const args = p.get("arguments");
1059
1213
  if (Array.isArray(args) && args.length > 0) {
1060
1214
  const first = args[0];
1061
- if (_optionalChain([first, 'optionalAccess', _18 => _18.isStringLiteral, 'call', _19 => _19()])) {
1215
+ if (_optionalChain([first, 'optionalAccess', _26 => _26.isStringLiteral, 'call', _27 => _27()])) {
1062
1216
  requireCallPaths.push(first);
1063
1217
  }
1064
1218
  }
@@ -1368,7 +1522,7 @@ function generateCode(match, options = {}) {
1368
1522
  if (t.isMemberExpression(path.parent)) {
1369
1523
  return;
1370
1524
  }
1371
- if (t.isBinaryExpression(path.parent) && (t.isConditionalExpression(_optionalChain([path, 'access', _20 => _20.parentPath, 'optionalAccess', _21 => _21.parent])) || t.isLogicalExpression(_optionalChain([path, 'access', _22 => _22.parentPath, 'optionalAccess', _23 => _23.parent])))) {
1525
+ if (t.isBinaryExpression(path.parent) && (t.isConditionalExpression(_optionalChain([path, 'access', _28 => _28.parentPath, 'optionalAccess', _29 => _29.parent])) || t.isLogicalExpression(_optionalChain([path, 'access', _30 => _30.parentPath, 'optionalAccess', _31 => _31.parent])))) {
1372
1526
  return;
1373
1527
  }
1374
1528
  jsTokenUpdater.addToken(
@@ -1618,7 +1772,6 @@ function resolveRuntimePackageReplacements(option) {
1618
1772
  function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions) {
1619
1773
  const {
1620
1774
  cssPreflight,
1621
- customRuleCallback,
1622
1775
  cssPreflightRange,
1623
1776
  escapeMap,
1624
1777
  cssChildCombinatorReplaceValue,
@@ -1643,7 +1796,6 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
1643
1796
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
1644
1797
  const styleHandler = _postcss.createStyleHandler.call(void 0, {
1645
1798
  cssPreflight,
1646
- customRuleCallback,
1647
1799
  cssPreflightRange,
1648
1800
  escapeMap,
1649
1801
  cssChildCombinatorReplaceValue,
@@ -1748,13 +1900,13 @@ function ensureDefaultsIncluded(value) {
1748
1900
  function getCompilerContext(opts) {
1749
1901
  const ctx = _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
1750
1902
  opts,
1751
- _chunkLZ6L3UQOjs.getDefaultOptions.call(void 0, ),
1903
+ _chunkWXBFAARRjs.getDefaultOptions.call(void 0, ),
1752
1904
  {}
1753
1905
  );
1754
1906
  ctx.escapeMap = ctx.customReplaceDictionary;
1755
1907
  applyLoggerLevel(ctx.logLevel);
1756
- const twPatcher = _chunkC3CG4UUYjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
1757
- if (_optionalChain([twPatcher, 'access', _24 => _24.packageInfo, 'optionalAccess', _25 => _25.version])) {
1908
+ const twPatcher = _chunkOPTIAB5Gjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
1909
+ if (_optionalChain([twPatcher, 'access', _32 => _32.packageInfo, 'optionalAccess', _33 => _33.version])) {
1758
1910
  _logger.logger.success(`\u5F53\u524D\u4F7F\u7528 ${_logger.pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${_logger.pc.underline(_logger.pc.bold(_logger.pc.green(twPatcher.packageInfo.version)))}`);
1759
1911
  } else {
1760
1912
  _logger.logger.warn(`${_logger.pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);