weapp-tailwindcss 4.5.2 → 4.6.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 (73) hide show
  1. package/dist/{chunk-FOUWGCIJ.js → chunk-7CGHD2TI.js} +17 -15
  2. package/dist/{chunk-L4AXTSIM.mjs → chunk-7PGHZOTU.mjs} +10 -30
  3. package/dist/chunk-AXLRUW5H.js +776 -0
  4. package/dist/{chunk-PLMJW644.js → chunk-DWAEHRHN.js} +1 -4
  5. package/dist/{chunk-NHB7NFQC.js → chunk-E5PXIHDN.js} +1 -1
  6. package/dist/chunk-FB5P4TRH.js +70 -0
  7. package/dist/{chunk-ZUH5ZA7D.js → chunk-FVA7Y2YU.js} +21 -19
  8. package/dist/{chunk-FOSGDQZ7.js → chunk-I7FYDXN6.js} +3 -5
  9. package/dist/chunk-IY2OKZE6.mjs +773 -0
  10. package/dist/{chunk-CKTI35D3.mjs → chunk-JG5LBGLH.mjs} +27 -7
  11. package/dist/{chunk-FWIGQ4RY.mjs → chunk-KHILYAA4.mjs} +1 -1
  12. package/dist/chunk-LTJQUORK.js +32 -0
  13. package/dist/{chunk-TGTFIOJU.js → chunk-M6DWZX4H.js} +31 -11
  14. package/dist/{chunk-GGIH6WLF.mjs → chunk-MXVUK23K.mjs} +14 -12
  15. package/dist/{chunk-A3TJT6B6.js → chunk-OVDIACVK.js} +19 -39
  16. package/dist/{chunk-H4JTYYOI.mjs → chunk-RRHPTTCP.mjs} +0 -11
  17. package/dist/{chunk-WFZ73Q6S.mjs → chunk-TTDQ4TK2.mjs} +14 -12
  18. package/dist/{chunk-Q67IXIAH.mjs → chunk-VSRDBMDB.mjs} +1 -4
  19. package/dist/{chunk-IHKVNALD.mjs → chunk-YLNOOPZL.mjs} +3 -5
  20. package/dist/chunk-YPBRGP6K.mjs +70 -0
  21. package/dist/cli.js +11 -8
  22. package/dist/cli.mjs +11 -8
  23. package/dist/core.d.mts +0 -1
  24. package/dist/core.d.ts +0 -1
  25. package/dist/core.js +23 -12
  26. package/dist/core.mjs +21 -10
  27. package/dist/css-macro/postcss.js +1 -1
  28. package/dist/css-macro/postcss.mjs +1 -1
  29. package/dist/css-macro.js +1 -1
  30. package/dist/css-macro.mjs +1 -1
  31. package/dist/defaults.d.mts +0 -1
  32. package/dist/defaults.d.ts +0 -1
  33. package/dist/defaults.js +3 -3
  34. package/dist/defaults.mjs +2 -2
  35. package/dist/escape.d.mts +0 -1
  36. package/dist/escape.d.ts +0 -1
  37. package/dist/escape.js +3 -3
  38. package/dist/escape.mjs +2 -2
  39. package/dist/gulp.d.mts +0 -1
  40. package/dist/gulp.d.ts +0 -1
  41. package/dist/gulp.js +9 -8
  42. package/dist/gulp.mjs +8 -7
  43. package/dist/index.d.mts +1 -2
  44. package/dist/index.d.ts +1 -2
  45. package/dist/index.js +11 -10
  46. package/dist/index.mjs +10 -9
  47. package/dist/postcss-html-transform.js +1 -1
  48. package/dist/postcss-html-transform.mjs +1 -1
  49. package/dist/presets.d.mts +0 -1
  50. package/dist/presets.d.ts +0 -1
  51. package/dist/presets.js +17 -23
  52. package/dist/presets.mjs +16 -22
  53. package/dist/types.d.mts +10 -30
  54. package/dist/types.d.ts +10 -30
  55. package/dist/types.js +1 -1
  56. package/dist/types.mjs +1 -1
  57. package/dist/vite.d.mts +0 -1
  58. package/dist/vite.d.ts +0 -1
  59. package/dist/vite.js +9 -8
  60. package/dist/vite.mjs +8 -7
  61. package/dist/weapp-tw-runtime-loader.js +4 -1
  62. package/dist/webpack.d.mts +0 -1
  63. package/dist/webpack.d.ts +0 -1
  64. package/dist/webpack.js +9 -8
  65. package/dist/webpack.mjs +8 -7
  66. package/dist/webpack4.d.mts +0 -1
  67. package/dist/webpack4.d.ts +0 -1
  68. package/dist/webpack4.js +21 -19
  69. package/dist/webpack4.mjs +17 -15
  70. package/package.json +8 -9
  71. package/dist/chunk-2NRTWL47.js +0 -43
  72. package/dist/chunk-KBR4YB6N.js +0 -178
  73. package/dist/chunk-S2WEN6NJ.mjs +0 -175
@@ -1,10 +1,13 @@
1
1
  import {
2
- createDebug,
3
2
  processCachedTask
4
- } from "./chunk-H4JTYYOI.mjs";
3
+ } from "./chunk-RRHPTTCP.mjs";
4
+ import {
5
+ collectRuntimeClassSet,
6
+ createDebug
7
+ } from "./chunk-YPBRGP6K.mjs";
5
8
  import {
6
9
  getCompilerContext
7
- } from "./chunk-L4AXTSIM.mjs";
10
+ } from "./chunk-7PGHZOTU.mjs";
8
11
 
9
12
  // src/bundlers/gulp/index.ts
10
13
  import { Buffer } from "buffer";
@@ -16,10 +19,20 @@ var debug = createDebug();
16
19
  var Transform = stream.Transform;
17
20
  function createPlugins(options = {}) {
18
21
  const opts = getCompilerContext(options);
19
- const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
22
+ const { templateHandler, styleHandler, jsHandler, cache, twPatcher } = opts;
20
23
  let runtimeSet = /* @__PURE__ */ new Set();
21
- twPatcher.patch();
24
+ const patchPromise = Promise.resolve(twPatcher.patch());
22
25
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
26
+ let runtimeSetInitialized = false;
27
+ async function refreshRuntimeSet(force = false) {
28
+ await patchPromise;
29
+ if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
30
+ return runtimeSet;
31
+ }
32
+ runtimeSet = await collectRuntimeClassSet(twPatcher);
33
+ runtimeSetInitialized = true;
34
+ return runtimeSet;
35
+ }
23
36
  function resolveWithExtensions(base) {
24
37
  for (const ext of MODULE_EXTENSIONS) {
25
38
  const candidate = `${base}${ext}`;
@@ -94,8 +107,8 @@ function createPlugins(options = {}) {
94
107
  if (!file.contents) {
95
108
  return;
96
109
  }
97
- runtimeSet = await twPatcher.getClassSet();
98
- setMangleRuntimeSet(runtimeSet);
110
+ await refreshRuntimeSet(true);
111
+ await patchPromise;
99
112
  const rawSource = file.contents.toString();
100
113
  await processCachedTask({
101
114
  cache,
@@ -108,6 +121,7 @@ function createPlugins(options = {}) {
108
121
  debug("css cache hit: %s", file.path);
109
122
  },
110
123
  async transform() {
124
+ await patchPromise;
111
125
  const { css } = await styleHandler(rawSource, {
112
126
  isMainChunk: true,
113
127
  majorVersion: twPatcher.majorVersion,
@@ -124,6 +138,8 @@ function createPlugins(options = {}) {
124
138
  if (!file.contents) {
125
139
  return;
126
140
  }
141
+ await refreshRuntimeSet(runtimeSet.size === 0);
142
+ await patchPromise;
127
143
  const filename = path.resolve(file.path);
128
144
  const moduleGraph = options2.moduleGraph ?? createModuleGraphOptionsFor();
129
145
  const handlerOptions = {
@@ -147,6 +163,7 @@ function createPlugins(options = {}) {
147
163
  debug("js cache hit: %s", file.path);
148
164
  },
149
165
  async transform() {
166
+ await patchPromise;
150
167
  const currentSource = file.contents?.toString() ?? rawSource;
151
168
  const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
152
169
  debug("js handle: %s", file.path);
@@ -160,6 +177,8 @@ function createPlugins(options = {}) {
160
177
  if (!file.contents) {
161
178
  return;
162
179
  }
180
+ await refreshRuntimeSet(runtimeSet.size === 0);
181
+ await patchPromise;
163
182
  const rawSource = file.contents.toString();
164
183
  await processCachedTask({
165
184
  cache,
@@ -172,6 +191,7 @@ function createPlugins(options = {}) {
172
191
  debug("html cache hit: %s", file.path);
173
192
  },
174
193
  async transform() {
194
+ await patchPromise;
175
195
  const code = await templateHandler(rawSource, {
176
196
  runtimeSet,
177
197
  ...options2
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.8.1__@swc+core@1.13.5_jiti@2._cec5ee635e8b2932d274eae561437dbd/node_modules/tsup/assets/esm_shims.js
1
+ // ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.9.1__@swc+core@1.13.5_@swc+he_98381cc53e0855b33bb51e41d0f2099f/node_modules/tsup/assets/esm_shims.js
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }// src/bundlers/shared/cache.ts
2
+ async function processCachedTask({
3
+ cache,
4
+ cacheKey,
5
+ hashKey = cacheKey,
6
+ rawSource,
7
+ readCache,
8
+ applyResult,
9
+ transform,
10
+ onCacheHit
11
+ }) {
12
+ let cacheHit = false;
13
+ const result = await cache.process({
14
+ key: cacheKey,
15
+ hashKey,
16
+ rawSource,
17
+ resolveCache: readCache,
18
+ async onCacheHit(value) {
19
+ cacheHit = true;
20
+ await applyResult(value);
21
+ _optionalChain([onCacheHit, 'optionalCall', _ => _()]);
22
+ },
23
+ transform
24
+ });
25
+ if (!cacheHit) {
26
+ await applyResult(result);
27
+ }
28
+ }
29
+
30
+
31
+
32
+ exports.processCachedTask = processCachedTask;
@@ -1,10 +1,13 @@
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 _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
3
4
 
4
- var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
5
5
 
6
6
 
7
- var _chunkA3TJT6B6js = require('./chunk-A3TJT6B6.js');
7
+ var _chunkFB5P4TRHjs = require('./chunk-FB5P4TRH.js');
8
+
9
+
10
+ var _chunkOVDIACVKjs = require('./chunk-OVDIACVK.js');
8
11
 
9
12
  // src/bundlers/gulp/index.ts
10
13
  var _buffer = require('buffer');
@@ -12,14 +15,24 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
12
15
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
13
16
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
14
17
  var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
15
- var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
18
+ var debug = _chunkFB5P4TRHjs.createDebug.call(void 0, );
16
19
  var Transform = _stream2.default.Transform;
17
20
  function createPlugins(options = {}) {
18
- const opts = _chunkA3TJT6B6js.getCompilerContext.call(void 0, options);
19
- const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
21
+ const opts = _chunkOVDIACVKjs.getCompilerContext.call(void 0, options);
22
+ const { templateHandler, styleHandler, jsHandler, cache, twPatcher } = opts;
20
23
  let runtimeSet = /* @__PURE__ */ new Set();
21
- twPatcher.patch();
24
+ const patchPromise = Promise.resolve(twPatcher.patch());
22
25
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
26
+ let runtimeSetInitialized = false;
27
+ async function refreshRuntimeSet(force = false) {
28
+ await patchPromise;
29
+ if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
30
+ return runtimeSet;
31
+ }
32
+ runtimeSet = await _chunkFB5P4TRHjs.collectRuntimeClassSet.call(void 0, twPatcher);
33
+ runtimeSetInitialized = true;
34
+ return runtimeSet;
35
+ }
23
36
  function resolveWithExtensions(base) {
24
37
  for (const ext of MODULE_EXTENSIONS) {
25
38
  const candidate = `${base}${ext}`;
@@ -94,10 +107,10 @@ function createPlugins(options = {}) {
94
107
  if (!file.contents) {
95
108
  return;
96
109
  }
97
- runtimeSet = await twPatcher.getClassSet();
98
- setMangleRuntimeSet(runtimeSet);
110
+ await refreshRuntimeSet(true);
111
+ await patchPromise;
99
112
  const rawSource = file.contents.toString();
100
- await _chunk2NRTWL47js.processCachedTask.call(void 0, {
113
+ await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
101
114
  cache,
102
115
  cacheKey: file.path,
103
116
  rawSource,
@@ -108,6 +121,7 @@ function createPlugins(options = {}) {
108
121
  debug("css cache hit: %s", file.path);
109
122
  },
110
123
  async transform() {
124
+ await patchPromise;
111
125
  const { css } = await styleHandler(rawSource, {
112
126
  isMainChunk: true,
113
127
  majorVersion: twPatcher.majorVersion,
@@ -124,6 +138,8 @@ function createPlugins(options = {}) {
124
138
  if (!file.contents) {
125
139
  return;
126
140
  }
141
+ await refreshRuntimeSet(runtimeSet.size === 0);
142
+ await patchPromise;
127
143
  const filename = _path2.default.resolve(file.path);
128
144
  const moduleGraph = _nullishCoalesce(options2.moduleGraph, () => ( createModuleGraphOptionsFor()));
129
145
  const handlerOptions = {
@@ -136,7 +152,7 @@ function createPlugins(options = {}) {
136
152
  }
137
153
  };
138
154
  const rawSource = file.contents.toString();
139
- await _chunk2NRTWL47js.processCachedTask.call(void 0, {
155
+ await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
140
156
  cache,
141
157
  cacheKey: file.path,
142
158
  rawSource,
@@ -147,6 +163,7 @@ function createPlugins(options = {}) {
147
163
  debug("js cache hit: %s", file.path);
148
164
  },
149
165
  async transform() {
166
+ await patchPromise;
150
167
  const currentSource = _nullishCoalesce(_optionalChain([file, 'access', _2 => _2.contents, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]), () => ( rawSource));
151
168
  const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
152
169
  debug("js handle: %s", file.path);
@@ -160,8 +177,10 @@ function createPlugins(options = {}) {
160
177
  if (!file.contents) {
161
178
  return;
162
179
  }
180
+ await refreshRuntimeSet(runtimeSet.size === 0);
181
+ await patchPromise;
163
182
  const rawSource = file.contents.toString();
164
- await _chunk2NRTWL47js.processCachedTask.call(void 0, {
183
+ await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
165
184
  cache,
166
185
  cacheKey: file.path,
167
186
  rawSource,
@@ -172,6 +191,7 @@ function createPlugins(options = {}) {
172
191
  debug("html cache hit: %s", file.path);
173
192
  },
174
193
  async transform() {
194
+ await patchPromise;
175
195
  const code = await templateHandler(rawSource, {
176
196
  runtimeSet,
177
197
  ...options2
@@ -6,21 +6,24 @@ import {
6
6
  toAbsoluteOutputPath
7
7
  } from "./chunk-34T2BFTJ.mjs";
8
8
  import {
9
- createDebug,
10
9
  processCachedTask
11
- } from "./chunk-H4JTYYOI.mjs";
10
+ } from "./chunk-RRHPTTCP.mjs";
11
+ import {
12
+ collectRuntimeClassSet,
13
+ createDebug
14
+ } from "./chunk-YPBRGP6K.mjs";
12
15
  import {
13
16
  pluginName
14
17
  } from "./chunk-CMUA5KCO.mjs";
15
18
  import {
16
19
  getCompilerContext
17
- } from "./chunk-L4AXTSIM.mjs";
20
+ } from "./chunk-7PGHZOTU.mjs";
18
21
  import {
19
22
  getGroupedEntries
20
23
  } from "./chunk-ZNKIYZRQ.mjs";
21
24
  import {
22
25
  __dirname
23
- } from "./chunk-FWIGQ4RY.mjs";
26
+ } from "./chunk-KHILYAA4.mjs";
24
27
 
25
28
  // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
26
29
  import fs from "fs";
@@ -43,7 +46,6 @@ var UnifiedWebpackPluginV5 = class {
43
46
  styleHandler,
44
47
  templateHandler,
45
48
  jsHandler,
46
- setMangleRuntimeSet,
47
49
  runtimeLoaderPath,
48
50
  cache,
49
51
  twPatcher
@@ -51,13 +53,12 @@ var UnifiedWebpackPluginV5 = class {
51
53
  if (disabled) {
52
54
  return;
53
55
  }
54
- twPatcher.patch();
56
+ const patchPromise = Promise.resolve(twPatcher.patch());
55
57
  const { Compilation, sources, NormalModule } = compiler.webpack;
56
58
  const { ConcatSource } = sources;
57
- function getClassSetInLoader() {
58
- if (twPatcher.majorVersion !== 4) {
59
- return twPatcher.getClassSetV3();
60
- }
59
+ async function getClassSetInLoader() {
60
+ await patchPromise;
61
+ await collectRuntimeClassSet(twPatcher);
61
62
  }
62
63
  onLoad();
63
64
  const loader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
@@ -87,6 +88,7 @@ var UnifiedWebpackPluginV5 = class {
87
88
  async (assets) => {
88
89
  onStart();
89
90
  debug("start");
91
+ await patchPromise;
90
92
  for (const chunk of compilation.chunks) {
91
93
  if (chunk.id && chunk.hash) {
92
94
  cache.calcHashValueChanged(chunk.id, chunk.hash);
@@ -147,8 +149,7 @@ var UnifiedWebpackPluginV5 = class {
147
149
  }
148
150
  };
149
151
  const groupedEntries = getGroupedEntries(entries, this.options);
150
- const runtimeSet = await twPatcher.getClassSet();
151
- setMangleRuntimeSet(runtimeSet);
152
+ const runtimeSet = await collectRuntimeClassSet(twPatcher);
152
153
  debug("get runtimeSet, class count: %d", runtimeSet.size);
153
154
  const tasks = [];
154
155
  if (Array.isArray(groupedEntries.html)) {
@@ -241,6 +242,7 @@ var UnifiedWebpackPluginV5 = class {
241
242
  debug("css cache hit: %s", file);
242
243
  },
243
244
  transform: async () => {
245
+ await patchPromise;
244
246
  const { css } = await styleHandler(rawSource, {
245
247
  isMainChunk: mainCssChunkMatcher(file, this.appType),
246
248
  postcssOptions: {
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkPLMJW644js = require('./chunk-PLMJW644.js');
3
+ var _chunkDWAEHRHNjs = require('./chunk-DWAEHRHN.js');
4
4
 
5
5
 
6
- var _chunkKBR4YB6Njs = require('./chunk-KBR4YB6N.js');
6
+ var _chunkAXLRUW5Hjs = require('./chunk-AXLRUW5H.js');
7
7
 
8
8
 
9
- var _chunkFOSGDQZ7js = require('./chunk-FOSGDQZ7.js');
9
+ var _chunkI7FYDXN6js = require('./chunk-I7FYDXN6.js');
10
10
 
11
11
 
12
12
 
@@ -14,7 +14,6 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
14
14
 
15
15
  // src/context/index.ts
16
16
  var _logger = require('@weapp-tailwindcss/logger');
17
- var _mangle = require('@weapp-tailwindcss/mangle');
18
17
 
19
18
  // src/cache/index.ts
20
19
  var _lrucache = require('lru-cache');
@@ -244,7 +243,7 @@ function getReplacement(candidate, escapeMap) {
244
243
  if (!escapeMap) {
245
244
  let cached2 = defaultReplacementCache.get(candidate);
246
245
  if (cached2 === void 0) {
247
- cached2 = _chunkPLMJW644js.replaceWxml.call(void 0, candidate, { escapeMap });
246
+ cached2 = _chunkDWAEHRHNjs.replaceWxml.call(void 0, candidate, { escapeMap });
248
247
  defaultReplacementCache.set(candidate, cached2);
249
248
  }
250
249
  return cached2;
@@ -256,7 +255,7 @@ function getReplacement(candidate, escapeMap) {
256
255
  }
257
256
  let cached = store.get(candidate);
258
257
  if (cached === void 0) {
259
- cached = _chunkPLMJW644js.replaceWxml.call(void 0, candidate, { escapeMap });
258
+ cached = _chunkDWAEHRHNjs.replaceWxml.call(void 0, candidate, { escapeMap });
260
259
  store.set(candidate, cached);
261
260
  }
262
261
  return cached;
@@ -306,7 +305,6 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
306
305
  function replaceHandleValue(path, options) {
307
306
  const {
308
307
  escapeMap,
309
- mangleContext,
310
308
  needEscaped = false
311
309
  } = options;
312
310
  const { classNameSet, alwaysEscape } = options;
@@ -323,19 +321,10 @@ function replaceHandleValue(path, options) {
323
321
  }
324
322
  let transformed = literal;
325
323
  let mutated = false;
326
- let normalised = false;
327
324
  for (const candidate of candidates) {
328
325
  if (!shouldTransformClassName(candidate, options)) {
329
326
  continue;
330
327
  }
331
- if (mangleContext && !normalised) {
332
- const mangled = mangleContext.jsHandler(transformed);
333
- if (mangled !== transformed) {
334
- transformed = mangled;
335
- mutated = true;
336
- }
337
- normalised = true;
338
- }
339
328
  if (!transformed.includes(candidate)) {
340
329
  continue;
341
330
  }
@@ -1081,11 +1070,13 @@ function jsHandler(rawSource, options) {
1081
1070
  // src/js/index.ts
1082
1071
  function createJsHandler(options) {
1083
1072
  const {
1084
- mangleContext,
1085
1073
  arbitraryValues,
1086
1074
  escapeMap,
1087
1075
  jsPreserveClass,
1088
1076
  generateMap,
1077
+ needEscaped,
1078
+ alwaysEscape,
1079
+ unescapeUnicode,
1089
1080
  babelParserOptions,
1090
1081
  ignoreCallExpressionIdentifiers,
1091
1082
  ignoreTaggedTemplateExpressionIdentifiers,
@@ -1102,9 +1093,11 @@ function createJsHandler(options) {
1102
1093
  classNameSet,
1103
1094
  escapeMap,
1104
1095
  arbitraryValues,
1105
- mangleContext,
1106
1096
  jsPreserveClass,
1107
1097
  generateMap,
1098
+ needEscaped,
1099
+ alwaysEscape,
1100
+ unescapeUnicode,
1108
1101
  babelParserOptions,
1109
1102
  ignoreCallExpressionIdentifiers,
1110
1103
  ignoreTaggedTemplateExpressionIdentifiers,
@@ -1295,7 +1288,6 @@ function generateCode(match, options = {}) {
1295
1288
  replaceHandleValue(
1296
1289
  path,
1297
1290
  {
1298
- mangleContext: options.mangleContext,
1299
1291
  escapeMap: options.escapeMap,
1300
1292
  classNameSet: options.runtimeSet,
1301
1293
  needEscaped: true,
@@ -1319,10 +1311,9 @@ function handleEachClassFragment(ms, tokens, options = {}) {
1319
1311
  if (token.start > previousEnd) {
1320
1312
  const gap = ms.slice(previousEnd, token.start);
1321
1313
  if (isAllWhitespace(gap)) {
1322
- ms.update(previousEnd, token.start, _chunkPLMJW644js.replaceWxml.call(void 0, gap, {
1314
+ ms.update(previousEnd, token.start, _chunkDWAEHRHNjs.replaceWxml.call(void 0, gap, {
1323
1315
  keepEOL: false,
1324
1316
  escapeMap: options.escapeMap,
1325
- mangleContext: options.mangleContext,
1326
1317
  ignoreHead: true
1327
1318
  }));
1328
1319
  }
@@ -1331,10 +1322,9 @@ function handleEachClassFragment(ms, tokens, options = {}) {
1331
1322
  if (token.expressions.length > 0) {
1332
1323
  for (const exp of token.expressions) {
1333
1324
  if (exp.start > token.start && p < exp.start) {
1334
- ms.update(p, exp.start, _chunkPLMJW644js.replaceWxml.call(void 0, ms.slice(p, exp.start), {
1325
+ ms.update(p, exp.start, _chunkDWAEHRHNjs.replaceWxml.call(void 0, ms.slice(p, exp.start), {
1335
1326
  keepEOL: true,
1336
1327
  escapeMap: options.escapeMap,
1337
- mangleContext: options.mangleContext,
1338
1328
  // 首的str才会被转译
1339
1329
  // example: 2xl:xx 2x{{y}}
1340
1330
  ignoreHead: p > 0
@@ -1345,18 +1335,16 @@ function handleEachClassFragment(ms, tokens, options = {}) {
1345
1335
  p = exp.end;
1346
1336
  }
1347
1337
  if (token.end > p) {
1348
- ms.update(p, token.end, _chunkPLMJW644js.replaceWxml.call(void 0, ms.slice(p, token.end), {
1338
+ ms.update(p, token.end, _chunkDWAEHRHNjs.replaceWxml.call(void 0, ms.slice(p, token.end), {
1349
1339
  keepEOL: false,
1350
1340
  escapeMap: options.escapeMap,
1351
- mangleContext: options.mangleContext,
1352
1341
  ignoreHead: true
1353
1342
  }));
1354
1343
  }
1355
1344
  } else {
1356
- ms.update(token.start, token.end, _chunkPLMJW644js.replaceWxml.call(void 0, token.value, {
1345
+ ms.update(token.start, token.end, _chunkDWAEHRHNjs.replaceWxml.call(void 0, token.value, {
1357
1346
  keepEOL: false,
1358
1347
  escapeMap: options.escapeMap,
1359
- mangleContext: options.mangleContext,
1360
1348
  ignoreHead: false
1361
1349
  }));
1362
1350
  }
@@ -1367,10 +1355,9 @@ function handleEachClassFragment(ms, tokens, options = {}) {
1367
1355
  if (lastToken.end < ms.original.length) {
1368
1356
  const gap = ms.slice(lastToken.end, ms.original.length);
1369
1357
  if (isAllWhitespace(gap)) {
1370
- ms.update(lastToken.end, ms.original.length, _chunkPLMJW644js.replaceWxml.call(void 0, gap, {
1358
+ ms.update(lastToken.end, ms.original.length, _chunkDWAEHRHNjs.replaceWxml.call(void 0, gap, {
1371
1359
  keepEOL: false,
1372
1360
  escapeMap: options.escapeMap,
1373
- mangleContext: options.mangleContext,
1374
1361
  ignoreHead: true
1375
1362
  }));
1376
1363
  }
@@ -1527,7 +1514,7 @@ function createTemplateHandler(options = {}) {
1527
1514
  }
1528
1515
 
1529
1516
  // src/context/handlers.ts
1530
- function createHandlersFromContext(ctx, mangleContext, customAttributesEntities, cssCalcOptions) {
1517
+ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions) {
1531
1518
  const {
1532
1519
  cssPreflight,
1533
1520
  customRuleCallback,
@@ -1556,7 +1543,6 @@ function createHandlersFromContext(ctx, mangleContext, customAttributesEntities,
1556
1543
  customRuleCallback,
1557
1544
  cssPreflightRange,
1558
1545
  escapeMap,
1559
- mangleContext,
1560
1546
  cssChildCombinatorReplaceValue,
1561
1547
  injectAdditionalCssVarScope,
1562
1548
  cssSelectorReplacement,
@@ -1571,7 +1557,6 @@ function createHandlersFromContext(ctx, mangleContext, customAttributesEntities,
1571
1557
  });
1572
1558
  const jsHandler2 = createJsHandler({
1573
1559
  escapeMap,
1574
- mangleContext,
1575
1560
  arbitraryValues,
1576
1561
  jsPreserveClass,
1577
1562
  generateMap: true,
@@ -1583,7 +1568,6 @@ function createHandlersFromContext(ctx, mangleContext, customAttributesEntities,
1583
1568
  const templateHandler = createTemplateHandler({
1584
1569
  customAttributesEntities,
1585
1570
  escapeMap,
1586
- mangleContext,
1587
1571
  inlineWxs,
1588
1572
  jsHandler: jsHandler2,
1589
1573
  disabledDefaultTemplateHandler
@@ -1646,12 +1630,12 @@ function ensureSpacingIncluded(value) {
1646
1630
  function getCompilerContext(opts) {
1647
1631
  const ctx = _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
1648
1632
  opts,
1649
- _chunkFOSGDQZ7js.getDefaultOptions.call(void 0, ),
1633
+ _chunkI7FYDXN6js.getDefaultOptions.call(void 0, ),
1650
1634
  {}
1651
1635
  );
1652
1636
  ctx.escapeMap = ctx.customReplaceDictionary;
1653
1637
  applyLoggerLevel(ctx.logLevel);
1654
- const twPatcher = _chunkKBR4YB6Njs.createTailwindcssPatcherFromContext.call(void 0, ctx);
1638
+ const twPatcher = _chunkAXLRUW5Hjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
1655
1639
  if (_optionalChain([twPatcher, 'access', _22 => _22.packageInfo, 'optionalAccess', _23 => _23.version])) {
1656
1640
  _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)))}`);
1657
1641
  } else {
@@ -1663,18 +1647,14 @@ function getCompilerContext(opts) {
1663
1647
  }
1664
1648
  ctx.cssCalc = cssCalcOptions;
1665
1649
  const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
1666
- const { initMangle, mangleContext, setMangleRuntimeSet } = _mangle.useMangleStore.call(void 0, );
1667
- initMangle(ctx.mangle);
1668
1650
  const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
1669
1651
  ctx,
1670
- mangleContext,
1671
1652
  customAttributesEntities,
1672
1653
  cssCalcOptions
1673
1654
  );
1674
1655
  ctx.styleHandler = styleHandler;
1675
1656
  ctx.jsHandler = jsHandler2;
1676
1657
  ctx.templateHandler = templateHandler;
1677
- ctx.setMangleRuntimeSet = setMangleRuntimeSet;
1678
1658
  ctx.cache = initializeCache(ctx.cache);
1679
1659
  ctx.twPatcher = twPatcher;
1680
1660
  return ctx;
@@ -1,13 +1,3 @@
1
- // src/debug/index.ts
2
- import _createDebug from "debug";
3
- var _debug = _createDebug("weapp-tw");
4
- function createDebug(prefix) {
5
- function debug(formatter, ...args) {
6
- return _debug((prefix ?? "") + formatter, ...args);
7
- }
8
- return debug;
9
- }
10
-
11
1
  // src/bundlers/shared/cache.ts
12
2
  async function processCachedTask({
13
3
  cache,
@@ -38,6 +28,5 @@ async function processCachedTask({
38
28
  }
39
29
 
40
30
  export {
41
- createDebug,
42
31
  processCachedTask
43
32
  };
@@ -3,19 +3,22 @@ import {
3
3
  toAbsoluteOutputPath
4
4
  } from "./chunk-34T2BFTJ.mjs";
5
5
  import {
6
- createDebug,
7
6
  processCachedTask
8
- } from "./chunk-H4JTYYOI.mjs";
7
+ } from "./chunk-RRHPTTCP.mjs";
8
+ import {
9
+ collectRuntimeClassSet,
10
+ createDebug
11
+ } from "./chunk-YPBRGP6K.mjs";
9
12
  import {
10
13
  vitePluginName
11
14
  } from "./chunk-CMUA5KCO.mjs";
12
15
  import {
13
16
  generateCode,
14
17
  getCompilerContext
15
- } from "./chunk-L4AXTSIM.mjs";
18
+ } from "./chunk-7PGHZOTU.mjs";
16
19
  import {
17
20
  replaceWxml
18
- } from "./chunk-Q67IXIAH.mjs";
21
+ } from "./chunk-VSRDBMDB.mjs";
19
22
  import {
20
23
  getGroupedEntries
21
24
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -248,7 +251,6 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
248
251
  jsHandler,
249
252
  mainCssChunkMatcher,
250
253
  appType,
251
- setMangleRuntimeSet,
252
254
  cache,
253
255
  twPatcher,
254
256
  uniAppX
@@ -256,7 +258,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
256
258
  if (disabled) {
257
259
  return;
258
260
  }
259
- twPatcher.patch();
261
+ const patchPromise = Promise.resolve(twPatcher.patch());
260
262
  let runtimeSet;
261
263
  let resolvedConfig;
262
264
  onLoad();
@@ -278,6 +280,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
278
280
  }
279
281
  },
280
282
  async generateBundle(_opt, bundle) {
283
+ await patchPromise;
281
284
  debug("start");
282
285
  onStart();
283
286
  const entries = Object.entries(bundle);
@@ -293,8 +296,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
293
296
  }
294
297
  const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
295
298
  const groupedEntries = getGroupedEntries(entries, opts);
296
- runtimeSet = await twPatcher.getClassSet();
297
- setMangleRuntimeSet(runtimeSet);
299
+ runtimeSet = await collectRuntimeClassSet(twPatcher);
298
300
  debug("get runtimeSet, class count: %d", runtimeSet.size);
299
301
  const handleLinkedUpdate = (fileName, previous, next) => {
300
302
  onUpdate(fileName, previous, next);
@@ -421,6 +423,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
421
423
  debug("css cache hit: %s", file);
422
424
  },
423
425
  async transform() {
426
+ await patchPromise;
424
427
  const { css } = await styleHandler(rawSource, {
425
428
  isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType),
426
429
  postcssOptions: {
@@ -454,6 +457,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
454
457
  name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
455
458
  enforce,
456
459
  async transform(code, id) {
460
+ await patchPromise;
457
461
  const { query } = parseVueRequest(id);
458
462
  if (isCSSRequest(id) || query.vue && query.type === "style") {
459
463
  const postcssResult = await styleHandler(code, {
@@ -493,10 +497,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
493
497
  name: "weapp-tailwindcss:uni-app-x:nvue",
494
498
  enforce: "pre",
495
499
  async buildStart() {
496
- const res = await twPatcher.extract({ write: false });
497
- if (res) {
498
- runtimeSet = res.classSet;
499
- }
500
+ await patchPromise;
501
+ runtimeSet = await collectRuntimeClassSet(twPatcher);
500
502
  },
501
503
  transform(code, id) {
502
504
  return transformUVue(code, id, jsHandler, runtimeSet);
@@ -4,14 +4,11 @@ function replaceWxml(original, options = {
4
4
  keepEOL: false,
5
5
  escapeMap: MappingChars2String
6
6
  }) {
7
- const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
7
+ const { keepEOL, escapeMap, ignoreHead } = options;
8
8
  let res = original;
9
9
  if (!keepEOL) {
10
10
  res = res.replaceAll(/[\n\r]+/g, "");
11
11
  }
12
- if (mangleContext) {
13
- res = mangleContext.wxmlHandler(res);
14
- }
15
12
  res = escape(res, {
16
13
  map: escapeMap,
17
14
  ignoreHead