weapp-tailwindcss 4.9.9-beta.0 → 4.10.0-beta.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 (47) hide show
  1. package/dist/{chunk-FT3YGOHE.mjs → chunk-2KAM7AAG.mjs} +35 -7
  2. package/dist/{chunk-PO3CCFU7.js → chunk-3RGU475C.js} +4 -4
  3. package/dist/{chunk-YPIQUBC4.mjs → chunk-7ATL22KK.mjs} +44 -17
  4. package/dist/{chunk-NBS6RMNM.mjs → chunk-AGF55OIE.mjs} +1 -1
  5. package/dist/{chunk-YYE3U4L3.mjs → chunk-D3I6GQUV.mjs} +134 -20
  6. package/dist/{chunk-HAM3JEU2.js → chunk-DBAAU4LK.js} +1 -1
  7. package/dist/{chunk-U4T2HGRZ.js → chunk-F7FBGRWS.js} +16 -13
  8. package/dist/{chunk-YVYWSXU7.mjs → chunk-FIJF6OL7.mjs} +13 -10
  9. package/dist/{chunk-A2ST4H4Y.js → chunk-FLJBD5TW.js} +5 -5
  10. package/dist/{chunk-CAFL5XBF.js → chunk-GFJYJ6WV.js} +65 -38
  11. package/dist/{chunk-47TVJCQM.mjs → chunk-HT76VHOV.mjs} +1 -1
  12. package/dist/{chunk-DOX3RXJ2.js → chunk-IIDSY4XZ.js} +2 -2
  13. package/dist/{chunk-IY5ZVBL2.mjs → chunk-Q7TIBSU2.mjs} +37 -1
  14. package/dist/{chunk-42HSNAKM.js → chunk-QOWSZHYT.js} +42 -6
  15. package/dist/{chunk-YY55J7K3.js → chunk-UCDOKKRH.js} +141 -27
  16. package/dist/{chunk-HQ2G6NBK.js → chunk-YS2V3XY2.js} +57 -29
  17. package/dist/cli.js +39 -39
  18. package/dist/cli.mjs +2 -2
  19. package/dist/core.js +29 -22
  20. package/dist/core.mjs +28 -21
  21. package/dist/css-macro/postcss.js +1 -1
  22. package/dist/css-macro/postcss.mjs +1 -1
  23. package/dist/css-macro.js +1 -1
  24. package/dist/css-macro.mjs +1 -1
  25. package/dist/defaults.js +1 -1
  26. package/dist/defaults.mjs +1 -1
  27. package/dist/gulp.js +6 -6
  28. package/dist/gulp.mjs +4 -4
  29. package/dist/index.js +10 -10
  30. package/dist/index.mjs +7 -7
  31. package/dist/postcss-html-transform.js +1 -1
  32. package/dist/postcss-html-transform.mjs +1 -1
  33. package/dist/presets.js +5 -5
  34. package/dist/presets.mjs +1 -1
  35. package/dist/reset.js +1 -1
  36. package/dist/reset.mjs +1 -1
  37. package/dist/types.d.mts +5 -0
  38. package/dist/types.d.ts +5 -0
  39. package/dist/types.js +1 -1
  40. package/dist/types.mjs +1 -1
  41. package/dist/vite.js +7 -7
  42. package/dist/vite.mjs +4 -4
  43. package/dist/webpack.js +8 -8
  44. package/dist/webpack.mjs +5 -5
  45. package/dist/webpack4.js +63 -41
  46. package/dist/webpack4.mjs +40 -18
  47. package/package.json +7 -6
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkPO3CCFU7js = require('./chunk-PO3CCFU7.js');
6
+ var _chunk3RGU475Cjs = require('./chunk-3RGU475C.js');
7
7
 
8
8
 
9
9
  var _chunkLBZCKOMTjs = require('./chunk-LBZCKOMT.js');
@@ -79,6 +79,15 @@ function createTailwindPatchPromise(twPatcher, onPatched) {
79
79
  }
80
80
  });
81
81
  }
82
+ var runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
83
+ function getRuntimeClassSetStateEntry(state) {
84
+ let entry = runtimeClassSetStateCache.get(state);
85
+ if (!entry) {
86
+ entry = {};
87
+ runtimeClassSetStateCache.set(state, entry);
88
+ }
89
+ return entry;
90
+ }
82
91
  async function refreshTailwindRuntimeState(state, forceOrOptions) {
83
92
  const normalizedOptions = typeof forceOrOptions === "boolean" ? { force: forceOrOptions } : forceOrOptions;
84
93
  const force = normalizedOptions.force;
@@ -100,6 +109,62 @@ async function refreshTailwindRuntimeState(state, forceOrOptions) {
100
109
  }
101
110
  return refreshed;
102
111
  }
112
+ async function ensureRuntimeClassSet(state, options = {}) {
113
+ const forceRefresh = options.forceRefresh === true;
114
+ const forceCollect = options.forceCollect === true;
115
+ const clearCache = options.clearCache === true;
116
+ const allowEmpty = options.allowEmpty === true;
117
+ if (forceRefresh) {
118
+ await refreshTailwindRuntimeState(state, {
119
+ force: true,
120
+ clearCache
121
+ });
122
+ }
123
+ await state.patchPromise;
124
+ const entry = getRuntimeClassSetStateEntry(state);
125
+ const signature = getRuntimeClassSetSignature(state.twPatcher);
126
+ const signatureChanged = entry.signature !== signature;
127
+ const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
128
+ if (!shouldForceCollect) {
129
+ if (entry.value && (allowEmpty || entry.value.size > 0)) {
130
+ return entry.value;
131
+ }
132
+ if (entry.promise) {
133
+ return entry.promise;
134
+ }
135
+ }
136
+ const task = (async () => {
137
+ const collected = await collectRuntimeClassSet(state.twPatcher, {
138
+ force: shouldForceCollect,
139
+ skipRefresh: true,
140
+ clearCache
141
+ });
142
+ if (allowEmpty || collected.size > 0) {
143
+ return collected;
144
+ }
145
+ await refreshTailwindRuntimeState(state, {
146
+ force: true,
147
+ clearCache: true
148
+ });
149
+ await state.patchPromise;
150
+ return collectRuntimeClassSet(state.twPatcher, {
151
+ force: true,
152
+ skipRefresh: true,
153
+ clearCache: true
154
+ });
155
+ })();
156
+ entry.promise = task;
157
+ try {
158
+ const runtimeSet = await task;
159
+ entry.value = runtimeSet;
160
+ entry.signature = getRuntimeClassSetSignature(state.twPatcher);
161
+ return runtimeSet;
162
+ } finally {
163
+ if (entry.promise === task) {
164
+ entry.promise = void 0;
165
+ }
166
+ }
167
+ }
103
168
  function shouldPreferSync(majorVersion) {
104
169
  if (majorVersion == null) {
105
170
  return true;
@@ -201,7 +266,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
201
266
  // package.json
202
267
  var package_default = {
203
268
  name: "weapp-tailwindcss",
204
- version: "4.9.9-beta.0",
269
+ version: "4.10.0-beta.2",
205
270
  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!",
206
271
  author: "ice breaker <1324318532@qq.com>",
207
272
  license: "MIT",
@@ -384,7 +449,8 @@ var package_default = {
384
449
  lint: "eslint .",
385
450
  "lint:fix": "eslint ./src --fix",
386
451
  postinstall: "node bin/weapp-tailwindcss.js patch",
387
- "bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts"
452
+ "bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts",
453
+ "test:watch-hmr": "tsx scripts/watch-hmr-regression.ts"
388
454
  },
389
455
  publishConfig: {
390
456
  access: "public",
@@ -411,7 +477,7 @@ var package_default = {
411
477
  "local-pkg": "^1.1.2",
412
478
  "lru-cache": "10.4.3",
413
479
  "magic-string": "0.30.21",
414
- semver: "~7.7.3",
480
+ semver: "~7.7.4",
415
481
  "tailwindcss-patch": "catalog:tailwindcssPatch",
416
482
  "webpack-sources": "3.3.3",
417
483
  yaml: "^2.8.2"
@@ -561,7 +627,7 @@ function formatRelativeToBase(targetPath, baseDir) {
561
627
  }
562
628
  function resolveRecordLocation(baseDir) {
563
629
  const normalizedBase = _path2.default.normalize(baseDir);
564
- const packageRoot = _nullishCoalesce(_chunkPO3CCFU7js.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
630
+ const packageRoot = _nullishCoalesce(_chunk3RGU475Cjs.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
565
631
  const packageJsonPath = _path2.default.join(packageRoot, "package.json");
566
632
  const hasPackageJson = _fs.existsSync.call(void 0, packageJsonPath);
567
633
  const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
@@ -1057,6 +1123,67 @@ var _escape = require('@ast-core/escape');
1057
1123
 
1058
1124
  var _extractors = require('@weapp-tailwindcss/shared/extractors');
1059
1125
 
1126
+ // src/shared/classname-transform.ts
1127
+ var arbitraryClassTokenRE = /\[[^\]\r\n]+\]/;
1128
+ var utilityLikeClassRE = /^-?[@\w][\w:/.[\]()%#!,-]*$/;
1129
+ var escapableTokenRE = /[.[\]/:]/;
1130
+ function isArbitraryValueClassName(candidate) {
1131
+ if (!arbitraryClassTokenRE.test(candidate)) {
1132
+ return false;
1133
+ }
1134
+ return candidate.startsWith("[") || candidate.includes("-[") || candidate.includes(":[");
1135
+ }
1136
+ function shouldFallbackEscapeClassName(candidate) {
1137
+ if (!candidate) {
1138
+ return false;
1139
+ }
1140
+ if (candidate.startsWith("@")) {
1141
+ return false;
1142
+ }
1143
+ if (candidate.includes("://")) {
1144
+ return false;
1145
+ }
1146
+ if (candidate.includes("/")) {
1147
+ return false;
1148
+ }
1149
+ if (!utilityLikeClassRE.test(candidate)) {
1150
+ return false;
1151
+ }
1152
+ if (isArbitraryValueClassName(candidate)) {
1153
+ return true;
1154
+ }
1155
+ if (!escapableTokenRE.test(candidate)) {
1156
+ return false;
1157
+ }
1158
+ if (!candidate.includes(".")) {
1159
+ return false;
1160
+ }
1161
+ return candidate.includes("-") || candidate.includes(":");
1162
+ }
1163
+ function shouldTransformClassNameCandidate(candidate, {
1164
+ alwaysEscape,
1165
+ classNameSet,
1166
+ staleClassNameFallback,
1167
+ jsPreserveClass
1168
+ }) {
1169
+ if (alwaysEscape) {
1170
+ return true;
1171
+ }
1172
+ if (_optionalChain([jsPreserveClass, 'optionalCall', _32 => _32(candidate)])) {
1173
+ return false;
1174
+ }
1175
+ if (!classNameSet || classNameSet.size === 0) {
1176
+ return false;
1177
+ }
1178
+ if (classNameSet.has(candidate)) {
1179
+ return true;
1180
+ }
1181
+ if (!staleClassNameFallback) {
1182
+ return false;
1183
+ }
1184
+ return shouldFallbackEscapeClassName(candidate);
1185
+ }
1186
+
1060
1187
  // src/utils/decode.ts
1061
1188
  var unicodeEscapeRE = /\\u([\dA-Fa-f]{4})/g;
1062
1189
  var unicodeEscapeTestRE = /\\u[\dA-Fa-f]{4}/;
@@ -1134,22 +1261,6 @@ function getReplacement(candidate, escapeMap) {
1134
1261
  function hasIgnoreComment(node) {
1135
1262
  return Array.isArray(node.leadingComments) && node.leadingComments.some((comment) => comment.value.includes("weapp-tw") && comment.value.includes("ignore"));
1136
1263
  }
1137
- function shouldTransformClassName(candidate, {
1138
- alwaysEscape,
1139
- classNameSet,
1140
- jsPreserveClass
1141
- }) {
1142
- if (alwaysEscape) {
1143
- return true;
1144
- }
1145
- if (!classNameSet) {
1146
- return false;
1147
- }
1148
- if (!classNameSet.has(candidate)) {
1149
- return false;
1150
- }
1151
- return !_optionalChain([jsPreserveClass, 'optionalCall', _32 => _32(candidate)]);
1152
- }
1153
1264
  function extractLiteralValue(path4, { unescapeUnicode, arbitraryValues }) {
1154
1265
  const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _33 => _33.allowDoubleQuotes]);
1155
1266
  let offset = 0;
@@ -1193,7 +1304,7 @@ function replaceHandleValue(path4, options) {
1193
1304
  let transformed = literal;
1194
1305
  let mutated = false;
1195
1306
  for (const candidate of candidates) {
1196
- if (!shouldTransformClassName(candidate, options)) {
1307
+ if (!shouldTransformClassNameCandidate(candidate, options)) {
1197
1308
  continue;
1198
1309
  }
1199
1310
  if (!transformed.includes(candidate)) {
@@ -2259,6 +2370,7 @@ function createJsHandler(options) {
2259
2370
  const {
2260
2371
  arbitraryValues,
2261
2372
  escapeMap,
2373
+ staleClassNameFallback,
2262
2374
  jsPreserveClass,
2263
2375
  generateMap,
2264
2376
  needEscaped,
@@ -2280,6 +2392,7 @@ function createJsHandler(options) {
2280
2392
  {
2281
2393
  classNameSet,
2282
2394
  escapeMap,
2395
+ staleClassNameFallback,
2283
2396
  arbitraryValues,
2284
2397
  jsPreserveClass,
2285
2398
  generateMap,
@@ -2867,15 +2980,15 @@ function createInternalCompilerContext(opts) {
2867
2980
  );
2868
2981
  ctx.escapeMap = ctx.customReplaceDictionary;
2869
2982
  applyLoggerLevel(ctx.logLevel);
2870
- const twPatcher = _chunkPO3CCFU7js.createTailwindcssPatcherFromContext.call(void 0, ctx);
2983
+ const twPatcher = _chunk3RGU475Cjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
2871
2984
  logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
2872
2985
  if (_optionalChain([twPatcher, 'access', _97 => _97.packageInfo, 'optionalAccess', _98 => _98.version])) {
2873
2986
  _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)))}`);
2874
2987
  } else {
2875
2988
  _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`);
2876
2989
  }
2877
- _chunkPO3CCFU7js.warnMissingCssEntries.call(void 0, ctx, twPatcher);
2878
- const cssCalcOptions = _chunkPO3CCFU7js.applyV4CssCalcDefaults.call(void 0, ctx.cssCalc, twPatcher);
2990
+ _chunk3RGU475Cjs.warnMissingCssEntries.call(void 0, ctx, twPatcher);
2991
+ const cssCalcOptions = _chunk3RGU475Cjs.applyV4CssCalcDefaults.call(void 0, ctx.cssCalc, twPatcher);
2879
2992
  ctx.cssCalc = cssCalcOptions;
2880
2993
  const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
2881
2994
  const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
@@ -2894,7 +3007,7 @@ function createInternalCompilerContext(opts) {
2894
3007
  await clearTailwindcssPatcherCache(previousPatcher);
2895
3008
  }
2896
3009
  invalidateRuntimeClassSet(previousPatcher);
2897
- const nextPatcher = _chunkPO3CCFU7js.createTailwindcssPatcherFromContext.call(void 0, ctx);
3010
+ const nextPatcher = _chunk3RGU475Cjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
2898
3011
  Object.assign(previousPatcher, nextPatcher);
2899
3012
  ctx.twPatcher = previousPatcher;
2900
3013
  return previousPatcher;
@@ -2927,4 +3040,5 @@ function getCompilerContext(opts) {
2927
3040
 
2928
3041
 
2929
3042
 
2930
- exports.createDebug = createDebug; exports.getRuntimeClassSetSignature = getRuntimeClassSetSignature; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION; exports.createPatchTargetRecorder = createPatchTargetRecorder; exports.logTailwindcssTarget = logTailwindcssTarget; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.replaceWxml = replaceWxml; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.clearTailwindcssPatcherCache = clearTailwindcssPatcherCache; exports.getCompilerContext = getCompilerContext;
3043
+
3044
+ exports.createDebug = createDebug; exports.getRuntimeClassSetSignature = getRuntimeClassSetSignature; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.ensureRuntimeClassSet = ensureRuntimeClassSet; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION; exports.createPatchTargetRecorder = createPatchTargetRecorder; exports.logTailwindcssTarget = logTailwindcssTarget; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.replaceWxml = replaceWxml; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.clearTailwindcssPatcherCache = clearTailwindcssPatcherCache; exports.getCompilerContext = getCompilerContext;
@@ -6,13 +6,13 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkDOX3RXJ2js = require('./chunk-DOX3RXJ2.js');
9
+ var _chunkIIDSY4XZjs = require('./chunk-IIDSY4XZ.js');
10
10
 
11
11
 
12
12
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
13
13
 
14
14
 
15
- var _chunkA2ST4H4Yjs = require('./chunk-A2ST4H4Y.js');
15
+ var _chunkFLJBD5TWjs = require('./chunk-FLJBD5TW.js');
16
16
 
17
17
 
18
18
 
@@ -24,7 +24,7 @@ var _chunkA2ST4H4Yjs = require('./chunk-A2ST4H4Y.js');
24
24
 
25
25
 
26
26
 
27
- var _chunkYY55J7K3js = require('./chunk-YY55J7K3.js');
27
+ var _chunkUCDOKKRHjs = require('./chunk-UCDOKKRH.js');
28
28
 
29
29
 
30
30
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
@@ -54,7 +54,7 @@ function updateStaticAttribute(ms, prop) {
54
54
  const start = prop.value.loc.start.offset + 1;
55
55
  const end = prop.value.loc.end.offset - 1;
56
56
  if (start < end) {
57
- ms.update(start, end, _chunkYY55J7K3js.replaceWxml.call(void 0, prop.value.content));
57
+ ms.update(start, end, _chunkUCDOKKRHjs.replaceWxml.call(void 0, prop.value.content));
58
58
  }
59
59
  }
60
60
  function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
@@ -66,7 +66,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
66
66
  if (start >= end) {
67
67
  return;
68
68
  }
69
- const generated = _chunkYY55J7K3js.generateCode.call(void 0, prop.exp.content, {
69
+ const generated = _chunkUCDOKKRHjs.generateCode.call(void 0, prop.exp.content, {
70
70
  jsHandler,
71
71
  runtimeSet,
72
72
  wrapExpression: true
@@ -95,7 +95,7 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
95
95
  return;
96
96
  }
97
97
  const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
98
- const matchCustomAttribute = _chunkYY55J7K3js.createAttributeMatcher.call(void 0, customAttributesEntities);
98
+ const matchCustomAttribute = _chunkUCDOKKRHjs.createAttributeMatcher.call(void 0, customAttributesEntities);
99
99
  const ms = new (0, _magicstring2.default)(code);
100
100
  const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
101
101
  if (errors.length === 0) {
@@ -360,7 +360,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
360
360
  runtimeSet,
361
361
  applyLinkedResults: applyLinkedResults2
362
362
  } = options;
363
- const absoluteFile = _chunkDOX3RXJ2js.toAbsoluteOutputPath.call(void 0, file, outDir);
363
+ const absoluteFile = _chunkIIDSY4XZjs.toAbsoluteOutputPath.call(void 0, file, outDir);
364
364
  const rawSource = originalSource.source.toString();
365
365
  const rawHashSource = options.hashSalt ? `${rawSource}
366
366
  /*${options.hashSalt}*/` : rawSource;
@@ -432,7 +432,7 @@ function isJavaScriptEntry(entry) {
432
432
  function createBundleModuleGraphOptions(outputDir, entries) {
433
433
  return {
434
434
  resolve(specifier, importer) {
435
- return _chunkDOX3RXJ2js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => entries.has(candidate));
435
+ return _chunkIIDSY4XZjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => entries.has(candidate));
436
436
  },
437
437
  load(id) {
438
438
  const entry = entries.get(id);
@@ -527,7 +527,7 @@ function readEntrySource(output) {
527
527
  return output.source.toString();
528
528
  }
529
529
  function toJsAbsoluteFilename(file, outDir) {
530
- return _chunkDOX3RXJ2js.toAbsoluteOutputPath.call(void 0, file, outDir);
530
+ return _chunkIIDSY4XZjs.toAbsoluteOutputPath.call(void 0, file, outDir);
531
531
  }
532
532
  function computeDirtyEntries(entries, opts, state) {
533
533
  const nextSourceHashByFile = /* @__PURE__ */ new Map();
@@ -620,6 +620,30 @@ function formatCacheHitRate(metric) {
620
620
  }
621
621
  return `${(metric.cacheHits / metric.total * 100).toFixed(2)}%`;
622
622
  }
623
+ function formatMs(value) {
624
+ return value.toFixed(2);
625
+ }
626
+ function summarizeStringDiff(previous, next) {
627
+ if (previous === next) {
628
+ return "same";
629
+ }
630
+ const previousLength = previous.length;
631
+ const nextLength = next.length;
632
+ const minLength = Math.min(previousLength, nextLength);
633
+ let prefixLength = 0;
634
+ while (prefixLength < minLength && previous.charCodeAt(prefixLength) === next.charCodeAt(prefixLength)) {
635
+ prefixLength += 1;
636
+ }
637
+ let previousSuffixCursor = previousLength - 1;
638
+ let nextSuffixCursor = nextLength - 1;
639
+ while (previousSuffixCursor >= prefixLength && nextSuffixCursor >= prefixLength && previous.charCodeAt(previousSuffixCursor) === next.charCodeAt(nextSuffixCursor)) {
640
+ previousSuffixCursor -= 1;
641
+ nextSuffixCursor -= 1;
642
+ }
643
+ const previousChangedLength = previousSuffixCursor >= prefixLength ? previousSuffixCursor - prefixLength + 1 : 0;
644
+ const nextChangedLength = nextSuffixCursor >= prefixLength ? nextSuffixCursor - prefixLength + 1 : 0;
645
+ return `changed@${prefixLength} old=${previousChangedLength} new=${nextChangedLength} len=${previousLength}->${nextLength}`;
646
+ }
623
647
  function createLinkedImpactSignature(entry, linkedImpactsByEntry, sourceHashByFile) {
624
648
  const changedLinkedFiles = linkedImpactsByEntry.get(entry);
625
649
  if (!changedLinkedFiles || changedLinkedFiles.size === 0) {
@@ -676,6 +700,7 @@ function createGenerateBundleHook(context) {
676
700
  const forceRuntimeRefresh = _process2.default.env.WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH === "1";
677
701
  const disableDirtyOptimization = _process2.default.env.WEAPP_TW_VITE_DISABLE_DIRTY === "1";
678
702
  const disableJsPrecheck = _process2.default.env.WEAPP_TW_VITE_DISABLE_JS_PRECHECK === "1";
703
+ const debugCssDiff = _process2.default.env.WEAPP_TW_VITE_DEBUG_CSS_DIFF === "1";
679
704
  const entries = Object.entries(bundle);
680
705
  const dirtyEntries = computeDirtyEntries(entries, opts, state);
681
706
  const processSets = buildProcessSets(entries, opts, dirtyEntries.changedByType, state.previousLinkedByEntry, disableDirtyOptimization);
@@ -696,7 +721,7 @@ function createGenerateBundleHook(context) {
696
721
  const runtime = await ensureRuntimeClassSet(forceRuntimeRefresh);
697
722
  metrics.runtimeSet = measureElapsed(runtimeStart);
698
723
  debug2("get runtimeSet, class count: %d", runtime.size);
699
- const runtimeSignature = _nullishCoalesce(_chunkYY55J7K3js.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher), () => ( "runtime:missing"));
724
+ const runtimeSignature = _nullishCoalesce(_chunkUCDOKKRHjs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher), () => ( "runtime:missing"));
700
725
  const handleLinkedUpdate = (fileName, previous, next) => {
701
726
  onUpdate(fileName, previous, next);
702
727
  debug2("js linked handle: %s", fileName);
@@ -795,6 +820,9 @@ function createGenerateBundleHook(context) {
795
820
  },
796
821
  majorVersion: runtimeState.twPatcher.majorVersion
797
822
  });
823
+ if (debugCssDiff) {
824
+ debug2("css diff %s: %s", file, summarizeStringDiff(rawSource, css));
825
+ }
798
826
  metrics.css.elapsed += measureElapsed(start);
799
827
  metrics.css.transformed++;
800
828
  onUpdate(file, rawSource, css);
@@ -931,7 +959,7 @@ function createGenerateBundleHook(context) {
931
959
  });
932
960
  }
933
961
  }
934
- _chunkDOX3RXJ2js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
962
+ _chunkIIDSY4XZjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
935
963
  await Promise.all(tasks);
936
964
  for (const apply of pendingLinkedUpdates) {
937
965
  apply();
@@ -955,24 +983,24 @@ function createGenerateBundleHook(context) {
955
983
  }
956
984
  state.previousLinkedByEntry = nextLinkedByEntry;
957
985
  debug2(
958
- "metrics iteration=%d runtime=%.2fms html(total=%d transform=%d hit=%d rate=%s elapsed=%.2fms) js(total=%d transform=%d hit=%d rate=%s elapsed=%.2fms) css(total=%d transform=%d hit=%d rate=%s elapsed=%.2fms)",
986
+ "metrics iteration=%d runtime=%sms html(total=%d transform=%d hit=%d rate=%s elapsed=%sms) js(total=%d transform=%d hit=%d rate=%s elapsed=%sms) css(total=%d transform=%d hit=%d rate=%s elapsed=%sms)",
959
987
  state.iteration,
960
- metrics.runtimeSet,
988
+ formatMs(metrics.runtimeSet),
961
989
  metrics.html.total,
962
990
  metrics.html.transformed,
963
991
  metrics.html.cacheHits,
964
992
  formatCacheHitRate(metrics.html),
965
- metrics.html.elapsed,
993
+ formatMs(metrics.html.elapsed),
966
994
  metrics.js.total,
967
995
  metrics.js.transformed,
968
996
  metrics.js.cacheHits,
969
997
  formatCacheHitRate(metrics.js),
970
- metrics.js.elapsed,
998
+ formatMs(metrics.js.elapsed),
971
999
  metrics.css.total,
972
1000
  metrics.css.transformed,
973
1001
  metrics.css.cacheHits,
974
1002
  formatCacheHitRate(metrics.css),
975
- metrics.css.elapsed
1003
+ formatMs(metrics.css.elapsed)
976
1004
  );
977
1005
  onEnd();
978
1006
  debug2("end");
@@ -1000,12 +1028,12 @@ function createRewriteCssImportsPlugins(options) {
1000
1028
  const { appType, weappTailwindcssDirPosix: weappTailwindcssDirPosix2 } = options;
1001
1029
  return [
1002
1030
  {
1003
- name: `${_chunkYY55J7K3js.vitePluginName}:rewrite-css-imports`,
1031
+ name: `${_chunkUCDOKKRHjs.vitePluginName}:rewrite-css-imports`,
1004
1032
  enforce: "pre",
1005
1033
  resolveId: {
1006
1034
  order: "pre",
1007
1035
  handler(id, importer) {
1008
- const replacement = _chunkDOX3RXJ2js.resolveTailwindcssImport.call(void 0, id, weappTailwindcssDirPosix2, {
1036
+ const replacement = _chunkIIDSY4XZjs.resolveTailwindcssImport.call(void 0, id, weappTailwindcssDirPosix2, {
1009
1037
  join: joinPosixPath,
1010
1038
  appType
1011
1039
  });
@@ -1024,7 +1052,7 @@ function createRewriteCssImportsPlugins(options) {
1024
1052
  if (!isCSSRequest(id)) {
1025
1053
  return null;
1026
1054
  }
1027
- const rewritten = _chunkDOX3RXJ2js.rewriteTailwindcssImportsInCode.call(void 0, code, weappTailwindcssDirPosix2, {
1055
+ const rewritten = _chunkIIDSY4XZjs.rewriteTailwindcssImportsInCode.call(void 0, code, weappTailwindcssDirPosix2, {
1028
1056
  join: joinPosixPath,
1029
1057
  appType
1030
1058
  });
@@ -1042,12 +1070,12 @@ function createRewriteCssImportsPlugins(options) {
1042
1070
  }
1043
1071
 
1044
1072
  // src/bundlers/vite/index.ts
1045
- var debug = _chunkYY55J7K3js.createDebug.call(void 0, );
1046
- var weappTailwindcssPackageDir = _chunkDOX3RXJ2js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
1073
+ var debug = _chunkUCDOKKRHjs.createDebug.call(void 0, );
1074
+ var weappTailwindcssPackageDir = _chunkIIDSY4XZjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
1047
1075
  var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
1048
1076
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1049
1077
  const rewriteCssImportsSpecified = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
1050
- const opts = _chunkYY55J7K3js.getCompilerContext.call(void 0, options);
1078
+ const opts = _chunkUCDOKKRHjs.getCompilerContext.call(void 0, options);
1051
1079
  const {
1052
1080
  disabled,
1053
1081
  customAttributes,
@@ -1061,7 +1089,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1061
1089
  uniAppX,
1062
1090
  disabledDefaultTemplateHandler
1063
1091
  } = opts;
1064
- const disabledOptions = _chunkDOX3RXJ2js.resolveDisabledOptions.call(void 0, disabled);
1092
+ const disabledOptions = _chunkIIDSY4XZjs.resolveDisabledOptions.call(void 0, disabled);
1065
1093
  const tailwindcssMajorVersion = _nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0));
1066
1094
  const shouldRewriteCssImports = opts.rewriteCssImports !== false && !disabledOptions.rewriteCssImports && (rewriteCssImportsSpecified || tailwindcssMajorVersion >= 4);
1067
1095
  const rewritePlugins = createRewriteCssImportsPlugins({
@@ -1072,8 +1100,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1072
1100
  if (disabledOptions.plugin) {
1073
1101
  return rewritePlugins.length ? rewritePlugins : void 0;
1074
1102
  }
1075
- const customAttributesEntities = _chunkYY55J7K3js.toCustomAttributesEntities.call(void 0, customAttributes);
1076
- const patchRecorderState = _chunkA2ST4H4Yjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
1103
+ const customAttributesEntities = _chunkUCDOKKRHjs.toCustomAttributesEntities.call(void 0, customAttributes);
1104
+ const patchRecorderState = _chunkFLJBD5TWjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
1077
1105
  source: "runtime",
1078
1106
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
1079
1107
  });
@@ -1090,7 +1118,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1090
1118
  let runtimeRefreshOptionsKey;
1091
1119
  function resolveRuntimeRefreshOptions() {
1092
1120
  const configPath = _optionalChain([runtimeState, 'access', _29 => _29.twPatcher, 'access', _30 => _30.options, 'optionalAccess', _31 => _31.tailwind, 'optionalAccess', _32 => _32.config]);
1093
- const signature = _chunkYY55J7K3js.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
1121
+ const signature = _chunkUCDOKKRHjs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
1094
1122
  const optionsKey = JSON.stringify({
1095
1123
  appType,
1096
1124
  uniAppX: Boolean(uniAppX),
@@ -1111,7 +1139,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1111
1139
  async function refreshRuntimeState(force) {
1112
1140
  const invalidation = resolveRuntimeRefreshOptions();
1113
1141
  const shouldRefresh = force || invalidation.changed;
1114
- const refreshed = await _chunkYY55J7K3js.refreshTailwindRuntimeState.call(void 0, runtimeState, {
1142
+ const refreshed = await _chunkUCDOKKRHjs.refreshTailwindRuntimeState.call(void 0, runtimeState, {
1115
1143
  force: shouldRefresh,
1116
1144
  clearCache: force || invalidation.changed
1117
1145
  });
@@ -1132,7 +1160,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1132
1160
  }
1133
1161
  if (forceRuntimeRefresh || !runtimeSetPromise) {
1134
1162
  const invalidation = resolveRuntimeRefreshOptions();
1135
- const task2 = _chunkYY55J7K3js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
1163
+ const task2 = _chunkUCDOKKRHjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
1136
1164
  force: forceRuntimeRefresh || invalidation.changed,
1137
1165
  skipRefresh: forceRuntimeRefresh,
1138
1166
  clearCache: forceRuntimeRefresh || invalidation.changed
@@ -1168,7 +1196,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1168
1196
  const plugins = [
1169
1197
  ...rewritePlugins,
1170
1198
  {
1171
- name: `${_chunkYY55J7K3js.vitePluginName}:post`,
1199
+ name: `${_chunkUCDOKKRHjs.vitePluginName}:post`,
1172
1200
  enforce: "post",
1173
1201
  configResolved(config) {
1174
1202
  resolvedConfig = config;