weapp-tailwindcss 3.4.0-alpha.0 → 3.4.0-alpha.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 (124) hide show
  1. package/dist/babel/index.d.ts +16 -0
  2. package/dist/bundlers/gulp/index.d.ts +8 -0
  3. package/dist/bundlers/vite/index.d.ts +3 -0
  4. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +8 -0
  5. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +8 -0
  6. package/dist/bundlers/webpack/index.d.ts +1 -0
  7. package/dist/{weapp-tw-runtime-loader.d.ts → bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts} +2 -4
  8. package/dist/cache/index.d.ts +32 -0
  9. package/dist/cli.d.ts +1 -2
  10. package/dist/cli.js +51 -1760
  11. package/dist/cli.mjs +45 -34
  12. package/dist/constants-CFM1J-h1.js +42 -0
  13. package/dist/constants-Dy2Dd3Fz.mjs +36 -0
  14. package/dist/constants.d.ts +7 -0
  15. package/dist/core.d.ts +2 -16
  16. package/dist/core.js +60 -1775
  17. package/dist/core.mjs +60 -46
  18. package/dist/css-macro/constants.d.ts +14 -0
  19. package/dist/css-macro/index.d.ts +4 -7
  20. package/dist/css-macro/index.js +30 -140
  21. package/dist/css-macro/index.mjs +28 -35
  22. package/dist/css-macro/postcss.d.ts +3 -5
  23. package/dist/css-macro/postcss.js +46 -99
  24. package/dist/css-macro/postcss.mjs +45 -54
  25. package/dist/debug/index.d.ts +2 -0
  26. package/dist/defaults-DW-EahCC.js +145 -0
  27. package/dist/defaults-w3rlKQwe.mjs +139 -0
  28. package/dist/defaults.d.ts +2 -16
  29. package/dist/defaults.js +7 -208
  30. package/dist/defaults.mjs +4 -9
  31. package/dist/defu-Cdz2PomB.js +60 -0
  32. package/dist/defu-n46TJT6t.mjs +57 -0
  33. package/dist/env.d.ts +2 -0
  34. package/dist/escape.d.ts +4 -0
  35. package/dist/extractors/split.d.ts +3 -0
  36. package/dist/gulp.d.ts +1 -26
  37. package/dist/gulp.js +38 -1898
  38. package/dist/gulp.mjs +30 -15
  39. package/dist/index-B2TNoaOv.mjs +134 -0
  40. package/dist/index-B5NiRecR.js +130 -0
  41. package/dist/index-BEIjgKpF.mjs +11 -0
  42. package/dist/index-BPzIdybK.mjs +513 -0
  43. package/dist/index-DeW_zXzo.mjs +124 -0
  44. package/dist/index-DmzxhHCX.js +136 -0
  45. package/dist/index-DwZHOkK3.js +526 -0
  46. package/dist/index-HC-Qkn0i.js +17 -0
  47. package/dist/index.d.ts +4 -17
  48. package/dist/index.js +43 -2291
  49. package/dist/index.mjs +33 -23
  50. package/dist/js/handlers.d.ts +13 -0
  51. package/dist/js/index.d.ts +7 -0
  52. package/dist/mangle/index.d.ts +8 -0
  53. package/dist/options-7EjuAISl.mjs +869 -0
  54. package/dist/options-C-rvBixk.js +901 -0
  55. package/dist/options.d.ts +2 -0
  56. package/dist/postcss/cssVars.d.ts +5 -0
  57. package/dist/postcss/index.d.ts +3 -0
  58. package/dist/postcss/mp.d.ts +8 -0
  59. package/dist/postcss/plugins/ctx.d.ts +6 -0
  60. package/dist/postcss/plugins/index.d.ts +7 -0
  61. package/dist/postcss/plugins/post.d.ts +5 -0
  62. package/dist/postcss/plugins/pre.d.ts +5 -0
  63. package/dist/postcss/preflight.d.ts +3 -0
  64. package/dist/postcss/selectorParser.d.ts +6 -0
  65. package/dist/postcss/shared.d.ts +3 -0
  66. package/dist/postcss/symbols.d.ts +1 -0
  67. package/dist/postcss.d.ts +1 -23
  68. package/dist/postcss.js +22 -598
  69. package/dist/postcss.mjs +8 -17
  70. package/dist/reg.d.ts +1 -0
  71. package/dist/replace.d.ts +3 -19
  72. package/dist/replace.js +42 -93
  73. package/dist/replace.mjs +26 -30
  74. package/dist/shared-DbJl6i6a.mjs +25 -0
  75. package/dist/shared-hzYeE1wX.js +28 -0
  76. package/dist/tailwindcss/patcher.d.ts +3 -0
  77. package/dist/types.d.ts +165 -0
  78. package/dist/utils.d.ts +18 -0
  79. package/dist/v5-BD9-sqra.mjs +174 -0
  80. package/dist/v5-Ch6783yy.js +181 -0
  81. package/dist/vite.d.ts +1 -22
  82. package/dist/vite.js +36 -1947
  83. package/dist/vite.mjs +28 -15
  84. package/dist/weapp-tw-runtime-loader.js +14 -41
  85. package/dist/weapp-tw-runtime-loader.mjs +8 -12
  86. package/dist/webpack.d.ts +1 -26
  87. package/dist/webpack.js +37 -1994
  88. package/dist/webpack.mjs +29 -15
  89. package/dist/webpack4.d.ts +1 -27
  90. package/dist/webpack4.js +190 -1979
  91. package/dist/webpack4.mjs +188 -211
  92. package/dist/wxml/Tokenizer.d.ts +31 -0
  93. package/dist/wxml/index.d.ts +2 -0
  94. package/dist/wxml/shared.d.ts +2 -0
  95. package/dist/wxml/utils.d.ts +13 -0
  96. package/package.json +3 -3
  97. package/dist/chunk-257YPDSI.mjs +0 -173
  98. package/dist/chunk-75EWCRQW.mjs +0 -13
  99. package/dist/chunk-AB467PG7.mjs +0 -43
  100. package/dist/chunk-E7XGHGC7.mjs +0 -62
  101. package/dist/chunk-GUE4UCRJ.mjs +0 -126
  102. package/dist/chunk-IOYI6MSW.mjs +0 -533
  103. package/dist/chunk-LDWI65M5.mjs +0 -152
  104. package/dist/chunk-NVFWRLOI.mjs +0 -27
  105. package/dist/chunk-ORMKM6ZA.mjs +0 -30
  106. package/dist/chunk-PC4B5JJB.mjs +0 -953
  107. package/dist/chunk-SRLZU2YE.mjs +0 -95
  108. package/dist/chunk-VECXHWWG.mjs +0 -31
  109. package/dist/chunk-VN37QGSM.mjs +0 -216
  110. package/dist/cli.d.mts +0 -2
  111. package/dist/core.d.mts +0 -22
  112. package/dist/css-macro/index.d.mts +0 -18
  113. package/dist/css-macro/postcss.d.mts +0 -7
  114. package/dist/defaults.d.mts +0 -16
  115. package/dist/gulp.d.mts +0 -26
  116. package/dist/index.d.mts +0 -17
  117. package/dist/postcss.d.mts +0 -23
  118. package/dist/replace.d.mts +0 -19
  119. package/dist/types-DSNuiOhH.d.mts +0 -519
  120. package/dist/types-DSNuiOhH.d.ts +0 -519
  121. package/dist/vite.d.mts +0 -22
  122. package/dist/weapp-tw-runtime-loader.d.mts +0 -7
  123. package/dist/webpack.d.mts +0 -26
  124. package/dist/webpack4.d.mts +0 -27
package/dist/webpack.js CHANGED
@@ -1,1994 +1,37 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __export = (target, all) => {
26
- for (var name in all)
27
- __defProp(target, name, { get: all[name], enumerable: true });
28
- };
29
- var __copyProps = (to, from, except, desc) => {
30
- if (from && typeof from === "object" || typeof from === "function") {
31
- for (let key of __getOwnPropNames(from))
32
- if (!__hasOwnProp.call(to, key) && key !== except)
33
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
- }
35
- return to;
36
- };
37
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
38
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
39
- // If the importer is in node compatibility mode or this is not an ESM
40
- // file that has been converted to a CommonJS file using a Babel-
41
- // compatible transform (i.e. "__esModule" has not been set), then set
42
- // "default" to the CommonJS "module.exports" for node compatibility.
43
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
44
- mod
45
- ));
46
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
- var __async = (__this, __arguments, generator) => {
48
- return new Promise((resolve, reject) => {
49
- var fulfilled = (value) => {
50
- try {
51
- step(generator.next(value));
52
- } catch (e) {
53
- reject(e);
54
- }
55
- };
56
- var rejected = (value) => {
57
- try {
58
- step(generator.throw(value));
59
- } catch (e) {
60
- reject(e);
61
- }
62
- };
63
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
64
- step((generator = generator.apply(__this, __arguments)).next());
65
- });
66
- };
67
-
68
- // src/webpack.ts
69
- var webpack_exports = {};
70
- __export(webpack_exports, {
71
- UnifiedWebpackPluginV5: () => UnifiedWebpackPluginV5
72
- });
73
- module.exports = __toCommonJS(webpack_exports);
74
-
75
- // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
76
- var import_node_path2 = __toESM(require("path"));
77
- var import_node_fs = __toESM(require("fs"));
78
-
79
- // src/js/index.ts
80
- var import_magic_string = __toESM(require("magic-string"));
81
-
82
- // src/escape.ts
83
- var escape_exports = {};
84
- __export(escape_exports, {
85
- decodeUnicode: () => decodeUnicode,
86
- decodeUnicode2: () => decodeUnicode2,
87
- jsStringEscape: () => import_escape.jsStringEscape
88
- });
89
- __reExport(escape_exports, require("@weapp-core/escape"));
90
- var import_escape = require("@ast-core/escape");
91
- function decodeUnicode(s) {
92
- return unescape(s.replaceAll(/\\(u[\dA-Fa-f]{4})/g, "%$1"));
93
- }
94
- function decodeUnicode2(input) {
95
- try {
96
- return JSON.parse(`"${input}"`);
97
- } catch (_error) {
98
- return input;
99
- }
100
- }
101
-
102
- // src/wxml/shared.ts
103
- function replaceWxml(original, options = {
104
- keepEOL: false,
105
- escapeMap: escape_exports.SimpleMappingChars2String
106
- }) {
107
- const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
108
- let res = original;
109
- if (!keepEOL) {
110
- res = res.replaceAll(/[\n\r]+/g, "");
111
- }
112
- if (mangleContext) {
113
- res = mangleContext.wxmlHandler(res);
114
- }
115
- res = (0, escape_exports.escape)(res, {
116
- map: escapeMap,
117
- ignoreHead
118
- });
119
- return res;
120
- }
121
-
122
- // src/reg.ts
123
- var reg_exports = {};
124
- __reExport(reg_exports, require("@weapp-core/regex"));
125
-
126
- // src/extractors/split.ts
127
- var validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
128
- function isValidSelector(selector = "") {
129
- return validateFilterRE.test(selector);
130
- }
131
- function splitCode(code, allowDoubleQuotes = false) {
132
- const splitter = allowDoubleQuotes ? /\s+/ : /\s+|"/;
133
- return code.split(splitter).filter((element) => isValidSelector(element));
134
- }
135
-
136
- // src/js/handlers.ts
137
- function replaceHandleValue(str, node, options, ms, offset = 0) {
138
- const {
139
- classNameSet: set,
140
- escapeMap,
141
- mangleContext: ctx,
142
- needEscaped = false,
143
- jsPreserveClass,
144
- arbitraryValues,
145
- always,
146
- unescapeUnicode
147
- } = options;
148
- const allowDoubleQuotes = arbitraryValues == null ? void 0 : arbitraryValues.allowDoubleQuotes;
149
- let rawStr = str;
150
- let needUpdate = false;
151
- if (unescapeUnicode && rawStr.includes("\\u")) {
152
- rawStr = decodeUnicode2(rawStr);
153
- }
154
- const arr = splitCode(rawStr, allowDoubleQuotes);
155
- for (const v of arr) {
156
- if (always || set && set.has(v) && !(jsPreserveClass == null ? void 0 : jsPreserveClass(v))) {
157
- let ignoreFlag = false;
158
- if (Array.isArray(node.leadingComments)) {
159
- ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes("weapp-tw") && x.value.includes("ignore")) > -1;
160
- }
161
- if (!ignoreFlag) {
162
- if (ctx) {
163
- rawStr = ctx.jsHandler(rawStr);
164
- }
165
- rawStr = rawStr.replace(
166
- new RegExp((0, reg_exports.escapeStringRegexp)(v)),
167
- replaceWxml(v, {
168
- escapeMap
169
- })
170
- );
171
- needUpdate = true;
172
- }
173
- }
174
- }
175
- if (needUpdate && typeof node.start === "number" && typeof node.end === "number") {
176
- const start = node.start + offset;
177
- const end = node.end - offset;
178
- if (start < end && str !== rawStr) {
179
- const content = needEscaped ? (0, import_escape.jsStringEscape)(rawStr) : rawStr;
180
- ms.update(start, end, content);
181
- }
182
- }
183
- return rawStr;
184
- }
185
-
186
- // src/babel/index.ts
187
- var import_generator = __toESM(require("@babel/generator"));
188
- var import_traverse = __toESM(require("@babel/traverse"));
189
- var import_parser = require("@babel/parser");
190
- function _interopDefaultCompat(e) {
191
- return e && typeof e === "object" && "default" in e ? e.default : e;
192
- }
193
- var generate = _interopDefaultCompat(import_generator.default);
194
- var traverse = _interopDefaultCompat(import_traverse.default);
195
-
196
- // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
197
- function isPlainObject(value) {
198
- if (value === null || typeof value !== "object") {
199
- return false;
200
- }
201
- const prototype = Object.getPrototypeOf(value);
202
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
203
- return false;
204
- }
205
- if (Symbol.iterator in value) {
206
- return false;
207
- }
208
- if (Symbol.toStringTag in value) {
209
- return Object.prototype.toString.call(value) === "[object Module]";
210
- }
211
- return true;
212
- }
213
- function _defu(baseObject, defaults, namespace = ".", merger) {
214
- if (!isPlainObject(defaults)) {
215
- return _defu(baseObject, {}, namespace, merger);
216
- }
217
- const object = Object.assign({}, defaults);
218
- for (const key in baseObject) {
219
- if (key === "__proto__" || key === "constructor") {
220
- continue;
221
- }
222
- const value = baseObject[key];
223
- if (value === null || value === void 0) {
224
- continue;
225
- }
226
- if (merger && merger(object, key, value, namespace)) {
227
- continue;
228
- }
229
- if (Array.isArray(value) && Array.isArray(object[key])) {
230
- object[key] = [...value, ...object[key]];
231
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
232
- object[key] = _defu(
233
- value,
234
- object[key],
235
- (namespace ? `${namespace}.` : "") + key.toString(),
236
- merger
237
- );
238
- } else {
239
- object[key] = value;
240
- }
241
- }
242
- return object;
243
- }
244
- function createDefu(merger) {
245
- return (...arguments_) => (
246
- // eslint-disable-next-line unicorn/no-array-reduce
247
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
248
- );
249
- }
250
- var defu = createDefu();
251
- var defuFn = createDefu((object, key, currentValue) => {
252
- if (object[key] !== void 0 && typeof currentValue === "function") {
253
- object[key] = currentValue(object[key]);
254
- return true;
255
- }
256
- });
257
- var defuArrayFn = createDefu((object, key, currentValue) => {
258
- if (Array.isArray(object[key]) && typeof currentValue === "function") {
259
- object[key] = currentValue(object[key]);
260
- return true;
261
- }
262
- });
263
-
264
- // src/utils.ts
265
- function isMap(value) {
266
- return Object.prototype.toString.call(value) === "[object Map]";
267
- }
268
- function noop() {
269
- }
270
- function groupBy(arr, cb) {
271
- if (!Array.isArray(arr)) {
272
- throw new TypeError("expected an array for first argument");
273
- }
274
- if (typeof cb !== "function") {
275
- throw new TypeError("expected a function for second argument");
276
- }
277
- const result = {};
278
- for (const item of arr) {
279
- const bucketCategory = cb(item);
280
- const bucket = result[bucketCategory];
281
- if (Array.isArray(bucket)) {
282
- result[bucketCategory].push(item);
283
- } else {
284
- result[bucketCategory] = [item];
285
- }
286
- }
287
- return result;
288
- }
289
- function getGroupedEntries(entries, options) {
290
- const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
291
- const groupedEntries = groupBy(entries, ([file]) => {
292
- if (cssMatcher(file)) {
293
- return "css";
294
- } else if (htmlMatcher(file)) {
295
- return "html";
296
- } else if (jsMatcher(file) || wxsMatcher(file)) {
297
- return "js";
298
- } else {
299
- return "other";
300
- }
301
- });
302
- return groupedEntries;
303
- }
304
- function removeExt(file) {
305
- return file.replace(/\.[^./]+$/, "");
306
- }
307
- var defuOverrideArray = createDefu((obj, key, value) => {
308
- if (Array.isArray(obj[key]) && Array.isArray(value)) {
309
- obj[key] = value;
310
- return true;
311
- }
312
- });
313
-
314
- // src/js/index.ts
315
- function isEvalPath(p) {
316
- if (p.isCallExpression()) {
317
- const calleePath = p.get("callee");
318
- return calleePath.isIdentifier() && calleePath.node.name === "eval";
319
- }
320
- return false;
321
- }
322
- function getAstGrep() {
323
- return __async(this, null, function* () {
324
- try {
325
- const { js } = yield import("@ast-grep/napi");
326
- return js;
327
- } catch (error) {
328
- console.warn("\u8BF7\u5148\u5B89\u88C5 `@ast-grep/napi` , \u5B89\u88C5\u5B8C\u6210\u540E\u518D\u5C1D\u8BD5\u8FD0\u884C\uFF01");
329
- throw error;
330
- }
331
- });
332
- }
333
- function astGrepUpdateString(ast, options, ms) {
334
- return __async(this, null, function* () {
335
- const js = yield getAstGrep();
336
- const nodes = ast.findAll(js.kind("string"));
337
- for (const node of nodes) {
338
- const range = node.range();
339
- const text = node.text();
340
- replaceHandleValue(
341
- text.slice(1, -1),
342
- {
343
- end: range.end.index - 1,
344
- start: range.start.index + 1
345
- },
346
- __spreadProps(__spreadValues({}, options), {
347
- unescapeUnicode: true
348
- }),
349
- ms,
350
- 0
351
- );
352
- }
353
- const templateNodes = ast.findAll(js.kind("template_string"));
354
- for (const node of templateNodes) {
355
- const fragments = node.findAll(js.kind("string_fragment"));
356
- for (const fragment of fragments) {
357
- const range = fragment.range();
358
- const text = fragment.text();
359
- replaceHandleValue(
360
- text,
361
- {
362
- end: range.end.index,
363
- start: range.start.index
364
- },
365
- __spreadProps(__spreadValues({}, options), {
366
- unescapeUnicode: true
367
- }),
368
- ms,
369
- 0
370
- );
371
- }
372
- }
373
- });
374
- }
375
- function jsHandler(rawSource, options) {
376
- const ms = new import_magic_string.default(rawSource);
377
- let ast;
378
- try {
379
- ast = (0, import_parser.parse)(rawSource, options.babelParserOptions);
380
- } catch (error) {
381
- return {
382
- code: rawSource,
383
- error
384
- };
385
- }
386
- const traverseOptions = {
387
- StringLiteral: {
388
- enter(p) {
389
- var _a;
390
- if (isEvalPath(p.parentPath)) {
391
- return;
392
- }
393
- const n = p.node;
394
- replaceHandleValue(
395
- n.value,
396
- n,
397
- __spreadProps(__spreadValues({}, options), {
398
- needEscaped: (_a = options.needEscaped) != null ? _a : true
399
- }),
400
- ms,
401
- 1
402
- );
403
- }
404
- // exit(p) {}
405
- },
406
- TemplateElement: {
407
- enter(p) {
408
- if (p.parentPath.isTemplateLiteral() && isEvalPath(p.parentPath.parentPath)) {
409
- return;
410
- }
411
- const n = p.node;
412
- replaceHandleValue(
413
- n.value.raw,
414
- n,
415
- __spreadProps(__spreadValues({}, options), {
416
- needEscaped: false
417
- }),
418
- ms,
419
- 0
420
- );
421
- }
422
- },
423
- CallExpression: {
424
- enter(p) {
425
- if (isEvalPath(p)) {
426
- p.traverse({
427
- StringLiteral: {
428
- enter(s) {
429
- const res = jsHandler(s.node.value, __spreadProps(__spreadValues({}, options), {
430
- needEscaped: false,
431
- generateMap: false
432
- }));
433
- if (res.code) {
434
- const node = s.node;
435
- if (typeof node.start === "number" && typeof node.end === "number") {
436
- const start = node.start + 1;
437
- const end = node.end - 1;
438
- if (start < end && s.node.value !== res.code) {
439
- ms.update(start, end, (0, import_escape.jsStringEscape)(res.code));
440
- node.value = res.code;
441
- }
442
- }
443
- }
444
- }
445
- },
446
- TemplateElement: {
447
- enter(s) {
448
- const res = jsHandler(s.node.value.raw, __spreadProps(__spreadValues({}, options), {
449
- generateMap: false
450
- }));
451
- if (res.code) {
452
- const node = s.node;
453
- if (typeof node.start === "number" && typeof node.end === "number") {
454
- const start = node.start;
455
- const end = node.end;
456
- if (start < end && s.node.value.raw !== res.code) {
457
- ms.update(start, end, res.code);
458
- s.node.value.raw = res.code;
459
- }
460
- }
461
- }
462
- }
463
- }
464
- });
465
- }
466
- }
467
- }
468
- };
469
- traverse(ast, traverseOptions);
470
- return {
471
- code: ms.toString()
472
- };
473
- }
474
- function jsHandlerAsync(rawSource, options) {
475
- return __async(this, null, function* () {
476
- const ms = new import_magic_string.default(rawSource);
477
- const js = yield getAstGrep();
478
- let ast;
479
- try {
480
- const root = yield js.parseAsync(rawSource);
481
- ast = root.root();
482
- } catch (e) {
483
- return {
484
- code: rawSource
485
- };
486
- }
487
- yield astGrepUpdateString(ast, options, ms);
488
- return {
489
- code: ms.toString()
490
- };
491
- });
492
- }
493
- function createJsHandler(options) {
494
- const { mangleContext, arbitraryValues, escapeMap, jsPreserveClass, generateMap, jsAstTool, babelParserOptions } = options;
495
- function _jsHandler(rawSource, set, options2) {
496
- const opts = defuOverrideArray(options2, {
497
- classNameSet: set,
498
- escapeMap,
499
- arbitraryValues,
500
- mangleContext,
501
- jsPreserveClass,
502
- generateMap,
503
- jsAstTool,
504
- babelParserOptions
505
- });
506
- if (opts.jsAstTool === "ast-grep") {
507
- return jsHandlerAsync(rawSource, opts);
508
- }
509
- return jsHandler(rawSource, opts);
510
- }
511
- function sync(rawSource, set, options2) {
512
- const opts = defuOverrideArray(options2, {
513
- classNameSet: set,
514
- escapeMap,
515
- arbitraryValues,
516
- mangleContext,
517
- jsPreserveClass,
518
- generateMap,
519
- jsAstTool,
520
- babelParserOptions
521
- });
522
- return jsHandler(rawSource, opts);
523
- }
524
- _jsHandler.sync = sync;
525
- return _jsHandler;
526
- }
527
-
528
- // src/defaults.ts
529
- var defaultOptions = {
530
- cssMatcher: (file) => /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/.test(file),
531
- htmlMatcher: (file) => /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty)ml|swan)$/.test(file),
532
- jsMatcher: (file) => {
533
- if (file.includes("node_modules")) {
534
- return false;
535
- }
536
- return /.+\.[cm]?js?$/.test(file);
537
- },
538
- mainCssChunkMatcher: (file, appType) => {
539
- switch (appType) {
540
- case "uni-app": {
541
- return /^common\/main/.test(file);
542
- }
543
- case "uni-app-vite": {
544
- return file.startsWith("app") || /^common\/main/.test(file);
545
- }
546
- case "mpx": {
547
- return file.startsWith("app");
548
- }
549
- case "taro": {
550
- return file.startsWith("app");
551
- }
552
- case "remax": {
553
- return file.startsWith("app");
554
- }
555
- case "rax": {
556
- return file.startsWith("bundle");
557
- }
558
- case "native": {
559
- return file.startsWith("app");
560
- }
561
- case "kbone": {
562
- return /^(?:common\/)?miniprogram-app/.test(file);
563
- }
564
- default: {
565
- return true;
566
- }
567
- }
568
- },
569
- wxsMatcher: () => {
570
- return false;
571
- },
572
- // https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
573
- cssPreflight: {
574
- "box-sizing": "border-box",
575
- "border-width": "0",
576
- "border-style": "solid",
577
- "border-color": "currentColor"
578
- },
579
- disabled: false,
580
- customRuleCallback: noop,
581
- onLoad: noop,
582
- onStart: noop,
583
- onEnd: noop,
584
- onUpdate: noop,
585
- customAttributes: {},
586
- customReplaceDictionary: escape_exports.SimpleMappingChars2String,
587
- appType: void 0,
588
- arbitraryValues: {
589
- allowDoubleQuotes: false
590
- },
591
- cssChildCombinatorReplaceValue: ["view"],
592
- inlineWxs: false,
593
- injectAdditionalCssVarScope: false,
594
- jsPreserveClass: (keyword) => {
595
- if (keyword === "*") {
596
- return true;
597
- }
598
- return false;
599
- },
600
- disabledDefaultTemplateHandler: false,
601
- cssSelectorReplacement: {
602
- root: "page",
603
- universal: ["view", "text"]
604
- },
605
- babelParserOptions: {
606
- sourceType: "unambiguous"
607
- },
608
- postcssOptions: {},
609
- cssRemoveHoverPseudoClass: true
610
- // jsAstTool: 'ast-grep'
611
- };
612
-
613
- // src/wxml/utils.ts
614
- var t = __toESM(require("@babel/types"));
615
- var import_htmlparser2 = require("htmlparser2");
616
- var import_magic_string2 = __toESM(require("magic-string"));
617
-
618
- // src/wxml/Tokenizer.ts
619
- var Tokenizer = class {
620
- constructor() {
621
- this.reset();
622
- }
623
- processChar(char, index) {
624
- switch (this.state) {
625
- case 0 /* START */:
626
- if (char === " ") {
627
- } else if (char === "{") {
628
- this.state = 2 /* OPEN_BRACE */;
629
- this.bufferStartIndex = index;
630
- this.buffer += char;
631
- this.expressionBuffer = char;
632
- this.expressionStartIndex = index;
633
- } else {
634
- this.state = 1 /* TEXT */;
635
- this.bufferStartIndex = index;
636
- this.buffer += char;
637
- }
638
- break;
639
- case 1 /* TEXT */:
640
- if (char === " ") {
641
- this.tokens.push({ start: this.bufferStartIndex, end: index, value: this.buffer, expressions: this.expressions });
642
- this.buffer = "";
643
- this.expressions = [];
644
- this.state = 0 /* START */;
645
- } else if (char === "{") {
646
- this.buffer += char;
647
- this.expressionBuffer = char;
648
- this.expressionStartIndex = index;
649
- this.state = 2 /* OPEN_BRACE */;
650
- } else {
651
- this.buffer += char;
652
- }
653
- break;
654
- case 2 /* OPEN_BRACE */:
655
- if (char === "}") {
656
- this.buffer += char;
657
- this.expressionBuffer += char;
658
- this.state = 3 /* POTENTIAL_CLOSE */;
659
- } else {
660
- this.buffer += char;
661
- this.expressionBuffer += char;
662
- }
663
- break;
664
- case 3 /* POTENTIAL_CLOSE */:
665
- if (char === "}") {
666
- this.buffer += char;
667
- this.expressionBuffer += char;
668
- this.expressions.push({
669
- start: this.expressionStartIndex,
670
- end: index + 1,
671
- value: this.expressionBuffer
672
- });
673
- this.expressionBuffer = "";
674
- this.state = 4 /* BRACES_COMPLETE */;
675
- } else {
676
- this.buffer += char;
677
- this.expressionBuffer += char;
678
- this.state = 2 /* OPEN_BRACE */;
679
- }
680
- break;
681
- case 4 /* BRACES_COMPLETE */:
682
- if (char === " ") {
683
- this.tokens.push({
684
- start: this.bufferStartIndex,
685
- end: index,
686
- value: this.buffer,
687
- expressions: this.expressions
688
- });
689
- this.buffer = "";
690
- this.expressions = [];
691
- this.state = 0 /* START */;
692
- } else if (char === "{") {
693
- this.expressionStartIndex = index;
694
- this.expressionBuffer = char;
695
- this.buffer += char;
696
- this.state = 2 /* OPEN_BRACE */;
697
- } else {
698
- this.buffer += char;
699
- this.state = 1 /* TEXT */;
700
- }
701
- break;
702
- default:
703
- throw new Error("Unexpected state");
704
- }
705
- }
706
- run(input) {
707
- for (let i = 0; i < input.length; i++) {
708
- const char = input[i];
709
- this.processChar(char, i);
710
- }
711
- if (this.buffer.length > 0) {
712
- this.tokens.push({
713
- start: this.bufferStartIndex,
714
- end: input.length,
715
- value: this.buffer,
716
- expressions: this.expressions
717
- });
718
- }
719
- return this.tokens;
720
- }
721
- reset() {
722
- this.state = 0 /* START */;
723
- this.buffer = "";
724
- this.tokens = [];
725
- this.bufferStartIndex = 0;
726
- this.expressionBuffer = "";
727
- this.expressionStartIndex = 0;
728
- this.expressions = [];
729
- }
730
- };
731
-
732
- // src/wxml/utils.ts
733
- function generateCode(match, options = {}) {
734
- try {
735
- const { jsHandler: jsHandler2, runtimeSet } = options;
736
- if (jsHandler2 && jsHandler2.sync && runtimeSet) {
737
- const { code } = jsHandler2.sync(match, runtimeSet);
738
- return code;
739
- } else {
740
- const ms = new import_magic_string2.default(match);
741
- const ast = (0, import_parser.parseExpression)(match);
742
- traverse(ast, {
743
- StringLiteral(path3) {
744
- var _a, _b;
745
- if (t.isMemberExpression(path3.parent)) {
746
- return;
747
- }
748
- if (t.isBinaryExpression(path3.parent) && (t.isConditionalExpression((_a = path3.parentPath) == null ? void 0 : _a.parent) || t.isLogicalExpression((_b = path3.parentPath) == null ? void 0 : _b.parent))) {
749
- return;
750
- }
751
- const n = path3.node;
752
- replaceHandleValue(
753
- n.value,
754
- n,
755
- {
756
- mangleContext: options.mangleContext,
757
- escapeMap: options.escapeMap,
758
- classNameSet: options.runtimeSet,
759
- needEscaped: true,
760
- always: true
761
- },
762
- ms,
763
- 1
764
- );
765
- },
766
- noScope: true
767
- });
768
- return ms.toString();
769
- }
770
- } catch (e) {
771
- return match;
772
- }
773
- }
774
- function extract(original, reg) {
775
- let match = reg.exec(original);
776
- const sources = [];
777
- while (match !== null) {
778
- const start = match.index;
779
- const end = reg.lastIndex;
780
- sources.push({
781
- start,
782
- end,
783
- raw: match[1]
784
- });
785
- match = reg.exec(original);
786
- }
787
- return sources;
788
- }
789
- function extractSource(original) {
790
- return extract(original, reg_exports.variableRegExp);
791
- }
792
- function handleEachClassFragment(original, options = {}) {
793
- const sources = extractSource(original);
794
- if (sources.length > 0) {
795
- const resultArray = [];
796
- let p = 0;
797
- for (let i = 0; i < sources.length; i++) {
798
- const m = sources[i];
799
- const before = original.slice(p, m.start);
800
- resultArray.push(
801
- replaceWxml(before, {
802
- keepEOL: true,
803
- escapeMap: options.escapeMap,
804
- mangleContext: options.mangleContext,
805
- // 首的str才会被转译
806
- // example: 2xl:xx 2x{{y}}
807
- ignoreHead: p > 0
808
- })
809
- );
810
- p = m.start;
811
- if (m.raw.trim().length > 0) {
812
- const code = generateCode(m.raw, options);
813
- const source = `{{${code}}}`;
814
- m.source = source;
815
- } else {
816
- m.source = "";
817
- }
818
- resultArray.push(m.source);
819
- p = m.end;
820
- if (i === sources.length - 1) {
821
- const after = original.slice(m.end);
822
- resultArray.push(
823
- replaceWxml(after, {
824
- keepEOL: true,
825
- escapeMap: options.escapeMap,
826
- mangleContext: options.mangleContext,
827
- ignoreHead: true
828
- })
829
- );
830
- }
831
- }
832
- return resultArray.filter(Boolean).join("").trim();
833
- } else {
834
- return replaceWxml(original, {
835
- keepEOL: false,
836
- escapeMap: options.escapeMap,
837
- mangleContext: options.mangleContext,
838
- ignoreHead: false
839
- });
840
- }
841
- }
842
- function templateReplacer(original, options = {}) {
843
- const ms = new import_magic_string2.default(original);
844
- const tokenizer = new Tokenizer();
845
- const tokens = tokenizer.run(ms.original);
846
- for (const token of tokens) {
847
- const target = handleEachClassFragment(token.value, options);
848
- ms.update(token.start, token.end, target);
849
- }
850
- return ms.toString();
851
- }
852
- function regTest(reg, str) {
853
- reg.lastIndex = 0;
854
- return reg.test(str);
855
- }
856
- function isPropsMatch(props, attr) {
857
- if (Array.isArray(props)) {
858
- for (const prop of props) {
859
- const res = typeof prop === "string" ? prop.toLowerCase() === attr.toLowerCase() : regTest(prop, attr);
860
- if (res) {
861
- return res;
862
- }
863
- }
864
- return false;
865
- } else if (typeof props === "string") {
866
- return props === attr;
867
- } else {
868
- return regTest(props, attr);
869
- }
870
- }
871
- function customTemplateHandler(rawSource, options) {
872
- return __async(this, null, function* () {
873
- const {
874
- customAttributesEntities = [],
875
- disabledDefaultTemplateHandler,
876
- inlineWxs,
877
- runtimeSet,
878
- jsHandler: jsHandler2
879
- } = options != null ? options : {};
880
- const s = new import_magic_string2.default(rawSource);
881
- let tag = "";
882
- const wxsArray = [];
883
- const parser = new import_htmlparser2.Parser(
884
- {
885
- onopentagname(name) {
886
- tag = name;
887
- },
888
- onattribute(name, value, quote) {
889
- if (value) {
890
- let update2 = function() {
891
- s.update(
892
- parser.startIndex + name.length + 2,
893
- // !important
894
- // htmlparser2 9.0.0: parser.endIndex
895
- // htmlparser2 9.1.0: parser.endIndex - 1
896
- // https://github.com/sonofmagic/weapp-tailwindcss/issues/269
897
- parser.endIndex - 1,
898
- templateReplacer(value, __spreadProps(__spreadValues({}, options), {
899
- quote
900
- }))
901
- );
902
- };
903
- var update = update2;
904
- if (!disabledDefaultTemplateHandler && (name === "class" || name === "hover-class" || name === "virtualHostClass" || name === "virtualhostclass")) {
905
- update2();
906
- }
907
- for (const [t2, props] of customAttributesEntities) {
908
- if (t2 === "*") {
909
- if (isPropsMatch(props, name)) {
910
- update2();
911
- }
912
- } else if (typeof t2 === "string") {
913
- if (t2 === tag && isPropsMatch(props, name)) {
914
- update2();
915
- }
916
- } else if (regTest(t2, tag) && isPropsMatch(props, name)) {
917
- update2();
918
- }
919
- }
920
- }
921
- },
922
- ontext(data) {
923
- if (inlineWxs && tag === "wxs") {
924
- wxsArray.push({
925
- data,
926
- endIndex: parser.endIndex + 1,
927
- startIndex: parser.startIndex
928
- });
929
- }
930
- },
931
- onclosetag() {
932
- tag = "";
933
- }
934
- },
935
- {
936
- xmlMode: true
937
- }
938
- );
939
- parser.write(s.original);
940
- parser.end();
941
- for (const { data, endIndex, startIndex } of wxsArray) {
942
- const { code } = yield jsHandler2(data, runtimeSet);
943
- s.update(startIndex, endIndex, code);
944
- }
945
- return s.toString();
946
- });
947
- }
948
- function createTemplateHandler(options = {}) {
949
- return (rawSource, opt = {}) => {
950
- return customTemplateHandler(rawSource, defuOverrideArray(opt, options));
951
- };
952
- }
953
-
954
- // src/postcss/index.ts
955
- var import_postcss2 = __toESM(require("postcss"));
956
-
957
- // src/postcss/plugins/index.ts
958
- var import_postcss_is_pseudo_class = __toESM(require("@csstools/postcss-is-pseudo-class"));
959
- var import_postcss_rem_to_responsive_pixel = __toESM(require("postcss-rem-to-responsive-pixel"));
960
-
961
- // src/postcss/selectorParser.ts
962
- var import_postcss_selector_parser = __toESM(require("postcss-selector-parser"));
963
-
964
- // src/postcss/shared.ts
965
- function internalCssSelectorReplacer(selectors, options = {
966
- escapeMap: escape_exports.SimpleMappingChars2String
967
- }) {
968
- const { mangleContext, escapeMap } = options;
969
- if (mangleContext) {
970
- selectors = mangleContext.cssHandler(selectors);
971
- }
972
- return (0, escape_exports.escape)(selectors, {
973
- map: escapeMap
974
- });
975
- }
976
- function composeIsPseudo(strs) {
977
- if (typeof strs === "string") {
978
- return strs;
979
- }
980
- if (strs.length > 1) {
981
- return `:is(${strs.join(",")})`;
982
- }
983
- return strs.join("");
984
- }
985
-
986
- // src/postcss/selectorParser.ts
987
- function createRuleTransform(rule, options) {
988
- const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
989
- const transform = (selectors) => {
990
- selectors.walk((selector) => {
991
- if (selector.type === "universal" && cssSelectorReplacement && cssSelectorReplacement.universal) {
992
- selector.value = composeIsPseudo(cssSelectorReplacement.universal);
993
- }
994
- if (cssRemoveHoverPseudoClass && selector.type === "selector") {
995
- const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
996
- node && selector.remove();
997
- }
998
- if (selector.type === "pseudo" && selector.value === ":root" && cssSelectorReplacement && cssSelectorReplacement.root) {
999
- selector.value = composeIsPseudo(cssSelectorReplacement.root);
1000
- }
1001
- if (selector.type === "class") {
1002
- selector.value = internalCssSelectorReplacer(selector.value, {
1003
- escapeMap,
1004
- mangleContext
1005
- });
1006
- }
1007
- });
1008
- if (selectors.length === 0) {
1009
- rule.remove();
1010
- }
1011
- };
1012
- return transform;
1013
- }
1014
- function getRuleTransformer(rule, options) {
1015
- return (0, import_postcss_selector_parser.default)(createRuleTransform(rule, options));
1016
- }
1017
- function ruleTransformSync(rule, options) {
1018
- const transformer = getRuleTransformer(rule, options);
1019
- return transformer.transformSync(rule, {
1020
- lossless: false,
1021
- updateSelector: true
1022
- });
1023
- }
1024
- function isOnlyBeforeAndAfterPseudoElement(node) {
1025
- let b = false;
1026
- let a = false;
1027
- (0, import_postcss_selector_parser.default)((selectors) => {
1028
- selectors.walkPseudos((s) => {
1029
- var _a;
1030
- if (((_a = s.parent) == null ? void 0 : _a.length) === 1) {
1031
- if (/^:?:before$/.test(s.value)) {
1032
- b = true;
1033
- }
1034
- if (/^:?:after$/.test(s.value)) {
1035
- a = true;
1036
- }
1037
- }
1038
- });
1039
- }).astSync(node);
1040
- return b && a;
1041
- }
1042
- var fallbackRemove = (0, import_postcss_selector_parser.default)((selectors) => {
1043
- selectors.walk((selector) => {
1044
- var _a, _b;
1045
- if (selector.type === "universal") {
1046
- (_a = selector.parent) == null ? void 0 : _a.remove();
1047
- }
1048
- if (selector.type === "pseudo" && selector.value === ":is") {
1049
- (_b = selector.parent) == null ? void 0 : _b.remove();
1050
- }
1051
- });
1052
- });
1053
-
1054
- // src/postcss/mp.ts
1055
- var import_postcss = require("postcss");
1056
-
1057
- // src/postcss/cssVars.ts
1058
- var cssVars_default = [
1059
- {
1060
- prop: "--tw-border-spacing-x",
1061
- value: "0"
1062
- },
1063
- {
1064
- prop: "--tw-border-spacing-y",
1065
- value: "0"
1066
- },
1067
- {
1068
- prop: "--tw-translate-x",
1069
- value: "0"
1070
- },
1071
- {
1072
- prop: "--tw-translate-y",
1073
- value: "0"
1074
- },
1075
- {
1076
- prop: "--tw-rotate",
1077
- value: "0"
1078
- },
1079
- {
1080
- prop: "--tw-skew-x",
1081
- value: "0"
1082
- },
1083
- {
1084
- prop: "--tw-skew-y",
1085
- value: "0"
1086
- },
1087
- {
1088
- prop: "--tw-scale-x",
1089
- value: "1"
1090
- },
1091
- {
1092
- prop: "--tw-scale-y",
1093
- value: "1"
1094
- },
1095
- {
1096
- prop: "--tw-pan-x",
1097
- value: " "
1098
- },
1099
- {
1100
- prop: "--tw-pan-y",
1101
- value: " "
1102
- },
1103
- {
1104
- prop: "--tw-pinch-zoom",
1105
- value: " "
1106
- },
1107
- {
1108
- prop: "--tw-scroll-snap-strictness",
1109
- value: "proximity"
1110
- },
1111
- {
1112
- prop: "--tw-gradient-from-position",
1113
- value: " "
1114
- },
1115
- {
1116
- prop: "--tw-gradient-via-position",
1117
- value: " "
1118
- },
1119
- {
1120
- prop: "--tw-gradient-to-position",
1121
- value: " "
1122
- },
1123
- {
1124
- prop: "--tw-ordinal",
1125
- value: " "
1126
- },
1127
- {
1128
- prop: "--tw-slashed-zero",
1129
- value: " "
1130
- },
1131
- {
1132
- prop: "--tw-numeric-figure",
1133
- value: " "
1134
- },
1135
- {
1136
- prop: "--tw-numeric-spacing",
1137
- value: " "
1138
- },
1139
- {
1140
- prop: "--tw-numeric-fraction",
1141
- value: " "
1142
- },
1143
- {
1144
- prop: "--tw-ring-inset",
1145
- value: " "
1146
- },
1147
- {
1148
- prop: "--tw-ring-offset-width",
1149
- value: "0px"
1150
- },
1151
- {
1152
- prop: "--tw-ring-offset-color",
1153
- value: "#fff"
1154
- },
1155
- {
1156
- prop: "--tw-ring-color",
1157
- value: "rgb(59 130 246 / 0.5)"
1158
- },
1159
- {
1160
- prop: "--tw-ring-offset-shadow",
1161
- value: "0 0 #0000"
1162
- },
1163
- {
1164
- prop: "--tw-ring-shadow",
1165
- value: "0 0 #0000"
1166
- },
1167
- {
1168
- prop: "--tw-shadow",
1169
- value: "0 0 #0000"
1170
- },
1171
- {
1172
- prop: "--tw-shadow-colored",
1173
- value: "0 0 #0000"
1174
- },
1175
- {
1176
- prop: "--tw-blur",
1177
- value: " "
1178
- },
1179
- {
1180
- prop: "--tw-brightness",
1181
- value: " "
1182
- },
1183
- {
1184
- prop: "--tw-contrast",
1185
- value: " "
1186
- },
1187
- {
1188
- prop: "--tw-grayscale",
1189
- value: " "
1190
- },
1191
- {
1192
- prop: "--tw-hue-rotate",
1193
- value: " "
1194
- },
1195
- {
1196
- prop: "--tw-invert",
1197
- value: " "
1198
- },
1199
- {
1200
- prop: "--tw-saturate",
1201
- value: " "
1202
- },
1203
- {
1204
- prop: "--tw-sepia",
1205
- value: " "
1206
- },
1207
- {
1208
- prop: "--tw-drop-shadow",
1209
- value: " "
1210
- },
1211
- {
1212
- prop: "--tw-backdrop-blur",
1213
- value: " "
1214
- },
1215
- {
1216
- prop: "--tw-backdrop-brightness",
1217
- value: " "
1218
- },
1219
- {
1220
- prop: "--tw-backdrop-contrast",
1221
- value: " "
1222
- },
1223
- {
1224
- prop: "--tw-backdrop-grayscale",
1225
- value: " "
1226
- },
1227
- {
1228
- prop: "--tw-backdrop-hue-rotate",
1229
- value: " "
1230
- },
1231
- {
1232
- prop: "--tw-backdrop-invert",
1233
- value: " "
1234
- },
1235
- {
1236
- prop: "--tw-backdrop-opacity",
1237
- value: " "
1238
- },
1239
- {
1240
- prop: "--tw-backdrop-saturate",
1241
- value: " "
1242
- },
1243
- {
1244
- prop: "--tw-backdrop-sepia",
1245
- value: " "
1246
- },
1247
- {
1248
- prop: "--tw-contain-size",
1249
- value: " "
1250
- },
1251
- {
1252
- prop: "--tw-contain-layout",
1253
- value: " "
1254
- },
1255
- {
1256
- prop: "--tw-contain-paint",
1257
- value: " "
1258
- },
1259
- {
1260
- prop: "--tw-contain-style",
1261
- value: " "
1262
- }
1263
- ];
1264
-
1265
- // src/postcss/mp.ts
1266
- var initialNodes = cssVars_default.map((x) => {
1267
- return new import_postcss.Declaration({
1268
- prop: x.prop,
1269
- value: x.value
1270
- });
1271
- });
1272
- var PATTERNS = [
1273
- /:not\(template\)\s*[~+]\s*:not\(template\)/.source,
1274
- /:not\(\[hidden\]\)\s*[~+]\s*:not\(\[hidden\]\)/.source
1275
- ].join("|");
1276
- var BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, "g");
1277
- function testIfVariablesScope(node, count = 2) {
1278
- if (isOnlyBeforeAndAfterPseudoElement(node)) {
1279
- const nodes = node.nodes;
1280
- let c = 0;
1281
- for (const tryTestDecl of nodes) {
1282
- if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
1283
- c++;
1284
- }
1285
- if (c >= count) {
1286
- return true;
1287
- }
1288
- }
1289
- return false;
1290
- }
1291
- return false;
1292
- }
1293
- function testIfTwBackdrop(node, count = 2) {
1294
- if (node.type === "rule" && node.selector === "::backdrop") {
1295
- const nodes = node.nodes;
1296
- let c = 0;
1297
- for (const tryTestDecl of nodes) {
1298
- if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
1299
- c++;
1300
- }
1301
- if (c >= count) {
1302
- return true;
1303
- }
1304
- }
1305
- return false;
1306
- }
1307
- return false;
1308
- }
1309
- function makePseudoVarRule() {
1310
- const pseudoVarRule = new import_postcss.Rule({
1311
- // selectors: ['::before', '::after'],
1312
- selector: "::before,::after"
1313
- });
1314
- pseudoVarRule.append(
1315
- new import_postcss.Declaration({
1316
- prop: "--tw-content",
1317
- value: '""'
1318
- })
1319
- );
1320
- return pseudoVarRule;
1321
- }
1322
- function remakeCssVarSelector(selectors, options) {
1323
- const { cssPreflightRange, cssSelectorReplacement } = options;
1324
- if (cssPreflightRange === "all" && !selectors.includes(":not(not)")) {
1325
- selectors.push(":not(not)");
1326
- }
1327
- if (cssSelectorReplacement) {
1328
- if (Array.isArray(cssSelectorReplacement.universal)) {
1329
- if (!cssSelectorReplacement.universal.every((x) => {
1330
- return selectors.includes(x);
1331
- }) && !selectors.includes("*")) {
1332
- selectors.unshift("*");
1333
- }
1334
- } else if (typeof cssSelectorReplacement.universal === "string" && !selectors.includes(cssSelectorReplacement.universal) && !selectors.includes("*")) {
1335
- selectors.unshift("*");
1336
- }
1337
- }
1338
- return selectors;
1339
- }
1340
- function remakeCombinatorSelector(selector, cssChildCombinatorReplaceValue) {
1341
- let childCombinatorReplaceValue = "view + view";
1342
- if (Array.isArray(cssChildCombinatorReplaceValue) && cssChildCombinatorReplaceValue.length > 0) {
1343
- const x = composeIsPseudo(cssChildCombinatorReplaceValue);
1344
- childCombinatorReplaceValue = `${x} + ${x}`;
1345
- } else if (typeof cssChildCombinatorReplaceValue === "string") {
1346
- childCombinatorReplaceValue = cssChildCombinatorReplaceValue;
1347
- }
1348
- return selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
1349
- }
1350
- function commonChunkPreflight(node, options) {
1351
- const { ctx, cssChildCombinatorReplaceValue, cssInjectPreflight, injectAdditionalCssVarScope } = options;
1352
- node.selector = remakeCombinatorSelector(node.selector, cssChildCombinatorReplaceValue);
1353
- if (testIfVariablesScope(node)) {
1354
- ctx == null ? void 0 : ctx.markVariablesScope(node);
1355
- node.selectors = remakeCssVarSelector(node.selectors, options);
1356
- node.before(makePseudoVarRule());
1357
- if (typeof cssInjectPreflight === "function") {
1358
- node.append(...cssInjectPreflight());
1359
- }
1360
- }
1361
- if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
1362
- const syntheticRule = new import_postcss.Rule({
1363
- selectors: ["*", "::after", "::before"],
1364
- nodes: initialNodes
1365
- });
1366
- syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
1367
- node.before(syntheticRule);
1368
- node.before(makePseudoVarRule());
1369
- if (typeof cssInjectPreflight === "function") {
1370
- syntheticRule.append(...cssInjectPreflight());
1371
- }
1372
- }
1373
- }
1374
-
1375
- // src/constants.ts
1376
- var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
1377
- var pluginName = "weapp-tailwindcss-webpack-plugin";
1378
-
1379
- // src/postcss/plugins/pre.ts
1380
- function isAtMediaHover(atRule) {
1381
- return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || atRule.name === "media" && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params);
1382
- }
1383
- var postcssWeappTailwindcssPrePlugin = (options = {
1384
- isMainChunk: true
1385
- }) => {
1386
- const { isMainChunk } = options;
1387
- const p = {
1388
- postcssPlugin,
1389
- Rule(rule) {
1390
- ruleTransformSync(rule, options);
1391
- },
1392
- AtRule(atRule) {
1393
- if (isAtMediaHover(atRule)) {
1394
- if (atRule.nodes) {
1395
- atRule.replaceWith(atRule.nodes);
1396
- } else {
1397
- atRule.remove();
1398
- }
1399
- }
1400
- }
1401
- };
1402
- if (isMainChunk) {
1403
- p.Once = (root) => {
1404
- root.walkRules((rule) => {
1405
- commonChunkPreflight(rule, options);
1406
- });
1407
- };
1408
- }
1409
- return p;
1410
- };
1411
- postcssWeappTailwindcssPrePlugin.postcss = true;
1412
-
1413
- // src/postcss/plugins/post.ts
1414
- var postcssWeappTailwindcssPostPlugin = (options = {
1415
- isMainChunk: true
1416
- }) => {
1417
- const { customRuleCallback, isMainChunk, ctx } = options;
1418
- const p = {
1419
- postcssPlugin
1420
- };
1421
- if (isMainChunk) {
1422
- p.OnceExit = (root) => {
1423
- root.walkRules((rule) => {
1424
- if (ctx) {
1425
- if (ctx.isVariablesScope(rule)) {
1426
- fallbackRemove.transformSync(rule, {
1427
- updateSelector: true,
1428
- lossless: false
1429
- });
1430
- }
1431
- } else if (testIfVariablesScope(rule)) {
1432
- fallbackRemove.transformSync(rule, {
1433
- updateSelector: true,
1434
- lossless: false
1435
- });
1436
- }
1437
- });
1438
- };
1439
- }
1440
- if (typeof customRuleCallback === "function") {
1441
- p.Rule = (rule) => {
1442
- customRuleCallback(rule, options);
1443
- };
1444
- }
1445
- return p;
1446
- };
1447
- postcssWeappTailwindcssPostPlugin.postcss = true;
1448
-
1449
- // src/postcss/symbols.ts
1450
- var VariablesScopeSymbol = Symbol("VariablesScope");
1451
-
1452
- // src/postcss/plugins/ctx.ts
1453
- function createContext() {
1454
- const variablesScopeWeakMap = /* @__PURE__ */ new WeakMap();
1455
- function isVariablesScope(rule) {
1456
- return variablesScopeWeakMap.get(rule) === VariablesScopeSymbol;
1457
- }
1458
- function markVariablesScope(rule) {
1459
- variablesScopeWeakMap.set(rule, VariablesScopeSymbol);
1460
- }
1461
- return {
1462
- variablesScopeWeakMap,
1463
- isVariablesScope,
1464
- markVariablesScope
1465
- };
1466
- }
1467
-
1468
- // src/postcss/plugins/index.ts
1469
- var import_postcss_is_pseudo_class2 = __toESM(require("@csstools/postcss-is-pseudo-class"));
1470
- var import_postcss_rem_to_responsive_pixel2 = __toESM(require("postcss-rem-to-responsive-pixel"));
1471
- function getPlugins(options) {
1472
- var _a, _b;
1473
- const ctx = createContext();
1474
- options.ctx = ctx;
1475
- const plugins = [
1476
- ...(_b = (_a = options.postcssOptions) == null ? void 0 : _a.plugins) != null ? _b : [],
1477
- postcssWeappTailwindcssPrePlugin(options),
1478
- (0, import_postcss_is_pseudo_class.default)({
1479
- specificityMatchingName: "weapp-tw-ig"
1480
- })
1481
- ];
1482
- if (options.rem2rpx) {
1483
- plugins.push(
1484
- (0, import_postcss_rem_to_responsive_pixel.default)(
1485
- typeof options.rem2rpx === "object" ? options.rem2rpx : {
1486
- rootValue: 32,
1487
- propList: ["*"],
1488
- transformUnit: "rpx"
1489
- }
1490
- )
1491
- );
1492
- }
1493
- plugins.push(postcssWeappTailwindcssPostPlugin(options));
1494
- return plugins;
1495
- }
1496
-
1497
- // src/postcss/index.ts
1498
- function styleHandler(rawSource, options) {
1499
- return __async(this, null, function* () {
1500
- var _a, _b;
1501
- return (yield (0, import_postcss2.default)(getPlugins(options)).process(
1502
- rawSource,
1503
- (_b = (_a = options.postcssOptions) == null ? void 0 : _a.options) != null ? _b : {
1504
- from: void 0
1505
- }
1506
- ).async()).css;
1507
- });
1508
- }
1509
- function createStyleHandler(options) {
1510
- return (rawSource, opt) => {
1511
- return styleHandler(
1512
- rawSource,
1513
- defuOverrideArray(opt, options)
1514
- );
1515
- };
1516
- }
1517
-
1518
- // src/postcss/preflight.ts
1519
- function createInjectPreflight(options) {
1520
- const result = [];
1521
- if (options && typeof options === "object") {
1522
- const entries = Object.entries(options);
1523
- for (const [prop, value] of entries) {
1524
- if (value !== false) {
1525
- result.push({
1526
- prop,
1527
- value: value.toString()
1528
- });
1529
- }
1530
- }
1531
- }
1532
- return () => {
1533
- return result;
1534
- };
1535
- }
1536
-
1537
- // src/tailwindcss/patcher.ts
1538
- var import_node_path = __toESM(require("path"));
1539
- var import_node_process = __toESM(require("process"));
1540
- var import_tailwindcss_patch = require("tailwindcss-patch");
1541
- function createTailwindcssPatcher(basedir, cacheDir, supportCustomLengthUnitsPatch) {
1542
- const cache = {};
1543
- if (cacheDir) {
1544
- if (import_node_path.default.isAbsolute(cacheDir)) {
1545
- cache.dir = cacheDir;
1546
- } else if (basedir) {
1547
- cache.dir = import_node_path.default.resolve(basedir, cacheDir);
1548
- } else {
1549
- cache.dir = import_node_path.default.resolve(import_node_process.default.cwd(), cacheDir);
1550
- }
1551
- }
1552
- return new import_tailwindcss_patch.TailwindcssPatcher({
1553
- cache,
1554
- patch: {
1555
- basedir,
1556
- applyPatches: {
1557
- exportContext: true,
1558
- extendLengthUnits: supportCustomLengthUnitsPatch
1559
- }
1560
- }
1561
- });
1562
- }
1563
-
1564
- // src/mangle/index.ts
1565
- var import_shared5 = require("@tailwindcss-mangle/shared");
1566
- function getSelf(x) {
1567
- return x;
1568
- }
1569
- var defaultMangleContext = {
1570
- rawOptions: false,
1571
- runtimeSet: /* @__PURE__ */ new Set(),
1572
- classGenerator: new import_shared5.ClassGenerator(),
1573
- filter: import_shared5.defaultMangleClassFilter,
1574
- cssHandler: getSelf,
1575
- jsHandler: getSelf,
1576
- wxmlHandler: getSelf
1577
- };
1578
- function useMangleStore() {
1579
- const ctx = Object.assign({}, defaultMangleContext);
1580
- function resetMangle() {
1581
- return Object.assign(ctx, defaultMangleContext);
1582
- }
1583
- function handleValue(rawSource) {
1584
- const arr = splitCode(rawSource);
1585
- for (const x of arr) {
1586
- if (ctx.runtimeSet.has(x)) {
1587
- rawSource = rawSource.replace(new RegExp((0, reg_exports.escapeStringRegexp)(x)), ctx.classGenerator.generateClassName(x).name);
1588
- }
1589
- }
1590
- return rawSource;
1591
- }
1592
- function initMangle(options) {
1593
- var _a;
1594
- ctx.rawOptions = options;
1595
- if (options) {
1596
- if (options === true) {
1597
- options = {
1598
- classGenerator: {},
1599
- mangleClassFilter: import_shared5.defaultMangleClassFilter
1600
- };
1601
- }
1602
- ctx.classGenerator = new import_shared5.ClassGenerator(options.classGenerator);
1603
- ctx.filter = (_a = options.mangleClassFilter) != null ? _a : import_shared5.defaultMangleClassFilter;
1604
- ctx.jsHandler = (rawSource) => {
1605
- return handleValue(rawSource);
1606
- };
1607
- ctx.cssHandler = (rawSource) => {
1608
- return handleValue(rawSource);
1609
- };
1610
- ctx.wxmlHandler = (rawSource) => {
1611
- return handleValue(rawSource);
1612
- };
1613
- }
1614
- }
1615
- function setMangleRuntimeSet(runtimeSet) {
1616
- const newSet = /* @__PURE__ */ new Set();
1617
- for (const c of runtimeSet) {
1618
- if (ctx.filter(c)) {
1619
- newSet.add(c);
1620
- }
1621
- }
1622
- ctx.runtimeSet = newSet;
1623
- }
1624
- return {
1625
- mangleContext: ctx,
1626
- resetMangle,
1627
- initMangle,
1628
- setMangleRuntimeSet
1629
- };
1630
- }
1631
-
1632
- // src/cache/index.ts
1633
- var import_lru_cache = require("lru-cache");
1634
- var import_md5 = __toESM(require("md5"));
1635
- function createCache(options) {
1636
- const disabled = options === false;
1637
- const hashMap = /* @__PURE__ */ new Map();
1638
- const instance = new import_lru_cache.LRUCache({
1639
- // 可能会添加和删除一些页面和组件, 先设定 1024 吧
1640
- max: 1024,
1641
- ttl: 0,
1642
- ttlAutopurge: false
1643
- });
1644
- return {
1645
- hashMap,
1646
- instance,
1647
- hasHashKey(key) {
1648
- return hashMap.has(key);
1649
- },
1650
- getHashValue(key) {
1651
- return hashMap.get(key);
1652
- },
1653
- setHashValue(key, value) {
1654
- return hashMap.set(key, value);
1655
- },
1656
- get(key) {
1657
- return instance.get(key);
1658
- },
1659
- set(key, value) {
1660
- return instance.set(key, value);
1661
- },
1662
- computeHash(message) {
1663
- return (0, import_md5.default)(message);
1664
- },
1665
- calcHashValueChanged(key, hash) {
1666
- const hit = this.getHashValue(key);
1667
- if (hit) {
1668
- this.setHashValue(key, {
1669
- // new file should be changed
1670
- changed: hash !== hit.hash,
1671
- // new hash
1672
- hash
1673
- });
1674
- } else {
1675
- this.setHashValue(key, {
1676
- // new file should be changed
1677
- changed: true,
1678
- hash
1679
- });
1680
- }
1681
- return this;
1682
- },
1683
- has(key) {
1684
- return instance.has(key);
1685
- },
1686
- process(key, callback, fallback) {
1687
- return __async(this, null, function* () {
1688
- if (disabled) {
1689
- const res = yield fallback();
1690
- if (res) {
1691
- this.set(res.key, res.source);
1692
- }
1693
- } else {
1694
- const hit = this.getHashValue(key);
1695
- if (hit && !hit.changed) {
1696
- const returnFlag = yield callback();
1697
- if (returnFlag !== false) {
1698
- return;
1699
- }
1700
- }
1701
- const res = yield fallback();
1702
- if (res) {
1703
- this.set(res.key, res.source);
1704
- }
1705
- }
1706
- });
1707
- }
1708
- };
1709
- }
1710
-
1711
- // src/options.ts
1712
- function getOptions(opts) {
1713
- const result = defuOverrideArray(
1714
- opts,
1715
- defaultOptions,
1716
- {}
1717
- );
1718
- result.escapeMap = result.customReplaceDictionary;
1719
- const {
1720
- cssPreflight,
1721
- customRuleCallback,
1722
- cssPreflightRange,
1723
- customAttributes,
1724
- supportCustomLengthUnitsPatch,
1725
- arbitraryValues,
1726
- cssChildCombinatorReplaceValue,
1727
- inlineWxs,
1728
- injectAdditionalCssVarScope,
1729
- jsPreserveClass,
1730
- disabledDefaultTemplateHandler,
1731
- cssSelectorReplacement,
1732
- rem2rpx,
1733
- cache,
1734
- jsAstTool,
1735
- babelParserOptions,
1736
- postcssOptions,
1737
- cssRemoveHoverPseudoClass,
1738
- escapeMap,
1739
- mangle,
1740
- tailwindcssBasedir,
1741
- appType
1742
- } = result;
1743
- const cssInjectPreflight = createInjectPreflight(cssPreflight);
1744
- const customAttributesEntities = isMap(customAttributes) ? [...customAttributes.entries()] : Object.entries(customAttributes);
1745
- const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
1746
- initMangle(mangle);
1747
- const styleHandler2 = createStyleHandler({
1748
- cssInjectPreflight,
1749
- customRuleCallback,
1750
- cssPreflightRange,
1751
- escapeMap,
1752
- mangleContext,
1753
- cssChildCombinatorReplaceValue,
1754
- injectAdditionalCssVarScope,
1755
- cssSelectorReplacement,
1756
- rem2rpx,
1757
- postcssOptions,
1758
- cssRemoveHoverPseudoClass
1759
- });
1760
- const jsHandler2 = createJsHandler({
1761
- escapeMap,
1762
- mangleContext,
1763
- arbitraryValues,
1764
- jsPreserveClass,
1765
- generateMap: true,
1766
- jsAstTool,
1767
- babelParserOptions
1768
- });
1769
- const templateHandler = createTemplateHandler({
1770
- customAttributesEntities,
1771
- escapeMap,
1772
- mangleContext,
1773
- inlineWxs,
1774
- jsHandler: jsHandler2,
1775
- disabledDefaultTemplateHandler
1776
- });
1777
- result.styleHandler = styleHandler2;
1778
- result.jsHandler = jsHandler2;
1779
- result.templateHandler = templateHandler;
1780
- const twPatcher = createTailwindcssPatcher(tailwindcssBasedir, appType === "mpx" ? "node_modules/tailwindcss-patch/.cache" : void 0, supportCustomLengthUnitsPatch);
1781
- result.patch = twPatcher.patch;
1782
- result.setMangleRuntimeSet = setMangleRuntimeSet;
1783
- result.cache = cache === void 0 || typeof cache === "boolean" ? createCache(cache) : cache;
1784
- result.twPatcher = twPatcher;
1785
- return result;
1786
- }
1787
-
1788
- // src/debug/index.ts
1789
- var import_debug = __toESM(require("debug"));
1790
- var _debug = (0, import_debug.default)("weapp-tw");
1791
- function createDebug(prefix) {
1792
- function debug2(formatter, ...args) {
1793
- return _debug((prefix != null ? prefix : "") + formatter, ...args);
1794
- }
1795
- return debug2;
1796
- }
1797
-
1798
- // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
1799
- var debug = createDebug();
1800
- var UnifiedWebpackPluginV5 = class {
1801
- constructor(options = {}) {
1802
- this.options = getOptions(options);
1803
- this.appType = this.options.appType;
1804
- }
1805
- apply(compiler) {
1806
- const {
1807
- mainCssChunkMatcher,
1808
- disabled,
1809
- onLoad,
1810
- onUpdate,
1811
- onEnd,
1812
- onStart,
1813
- styleHandler: styleHandler2,
1814
- patch,
1815
- templateHandler,
1816
- jsHandler: jsHandler2,
1817
- setMangleRuntimeSet,
1818
- runtimeLoaderPath,
1819
- cache,
1820
- twPatcher
1821
- } = this.options;
1822
- if (disabled) {
1823
- return;
1824
- }
1825
- patch == null ? void 0 : patch();
1826
- const { Compilation, sources, NormalModule } = compiler.webpack;
1827
- const { ConcatSource, RawSource } = sources;
1828
- function getClassSet() {
1829
- return twPatcher.getClassSet();
1830
- }
1831
- onLoad();
1832
- const loader = runtimeLoaderPath != null ? runtimeLoaderPath : import_node_path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js");
1833
- const isExisted = import_node_fs.default.existsSync(loader);
1834
- const WeappTwRuntimeAopLoader = {
1835
- loader,
1836
- options: {
1837
- getClassSet
1838
- },
1839
- ident: null,
1840
- type: null
1841
- };
1842
- compiler.hooks.compilation.tap(pluginName, (compilation) => {
1843
- NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module2) => {
1844
- if (isExisted) {
1845
- const idx = module2.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
1846
- if (idx > -1) {
1847
- module2.loaders.unshift(WeappTwRuntimeAopLoader);
1848
- }
1849
- }
1850
- });
1851
- compilation.hooks.processAssets.tapPromise(
1852
- {
1853
- name: pluginName,
1854
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
1855
- },
1856
- (assets) => __async(this, null, function* () {
1857
- onStart();
1858
- debug("start");
1859
- for (const chunk of compilation.chunks) {
1860
- if (chunk.id && chunk.hash) {
1861
- cache.calcHashValueChanged(chunk.id, chunk.hash);
1862
- }
1863
- }
1864
- const entries = Object.entries(assets);
1865
- const groupedEntries = getGroupedEntries(entries, this.options);
1866
- const runtimeSet = getClassSet();
1867
- setMangleRuntimeSet(runtimeSet);
1868
- debug("get runtimeSet, class count: %d", runtimeSet.size);
1869
- if (Array.isArray(groupedEntries.html)) {
1870
- let noCachedCount = 0;
1871
- for (let i = 0; i < groupedEntries.html.length; i++) {
1872
- const [file, originalSource] = groupedEntries.html[i];
1873
- const rawSource = originalSource.source().toString();
1874
- const hash = cache.computeHash(rawSource);
1875
- const cacheKey = file;
1876
- cache.calcHashValueChanged(cacheKey, hash);
1877
- yield cache.process(
1878
- cacheKey,
1879
- () => {
1880
- const source = cache.get(cacheKey);
1881
- if (source) {
1882
- compilation.updateAsset(file, source);
1883
- debug("html cache hit: %s", file);
1884
- } else {
1885
- return false;
1886
- }
1887
- },
1888
- () => __async(this, null, function* () {
1889
- const wxml = yield templateHandler(rawSource, {
1890
- runtimeSet
1891
- });
1892
- const source = new ConcatSource(wxml);
1893
- compilation.updateAsset(file, source);
1894
- onUpdate(file, rawSource, wxml);
1895
- debug("html handle: %s", file);
1896
- noCachedCount++;
1897
- return {
1898
- key: cacheKey,
1899
- source
1900
- };
1901
- })
1902
- );
1903
- }
1904
- debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
1905
- }
1906
- if (Array.isArray(groupedEntries.js)) {
1907
- let noCachedCount = 0;
1908
- for (let i = 0; i < groupedEntries.js.length; i++) {
1909
- const [file, originalSource] = groupedEntries.js[i];
1910
- const cacheKey = removeExt(file);
1911
- yield cache.process(
1912
- cacheKey,
1913
- () => {
1914
- const source = cache.get(cacheKey);
1915
- if (source) {
1916
- compilation.updateAsset(file, source);
1917
- debug("js cache hit: %s", file);
1918
- } else {
1919
- return false;
1920
- }
1921
- },
1922
- () => __async(this, null, function* () {
1923
- const rawSource = originalSource.source().toString();
1924
- const mapFilename = `${file}.map`;
1925
- const hasMap = Boolean(assets[mapFilename]);
1926
- const { code, map } = yield jsHandler2(rawSource, runtimeSet, {
1927
- generateMap: hasMap
1928
- });
1929
- const source = new ConcatSource(code);
1930
- compilation.updateAsset(file, source);
1931
- onUpdate(file, rawSource, code);
1932
- debug("js handle: %s", file);
1933
- noCachedCount++;
1934
- if (hasMap && map) {
1935
- const source2 = new RawSource(map.toString());
1936
- compilation.updateAsset(mapFilename, source2);
1937
- }
1938
- return {
1939
- key: cacheKey,
1940
- source
1941
- };
1942
- })
1943
- );
1944
- }
1945
- debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
1946
- }
1947
- if (Array.isArray(groupedEntries.css)) {
1948
- let noCachedCount = 0;
1949
- for (let i = 0; i < groupedEntries.css.length; i++) {
1950
- const [file, originalSource] = groupedEntries.css[i];
1951
- const rawSource = originalSource.source().toString();
1952
- const hash = cache.computeHash(rawSource);
1953
- const cacheKey = file;
1954
- cache.calcHashValueChanged(cacheKey, hash);
1955
- yield cache.process(
1956
- cacheKey,
1957
- () => {
1958
- const source = cache.get(cacheKey);
1959
- if (source) {
1960
- compilation.updateAsset(file, source);
1961
- debug("css cache hit: %s", file);
1962
- } else {
1963
- return false;
1964
- }
1965
- },
1966
- () => __async(this, null, function* () {
1967
- const css = yield styleHandler2(rawSource, {
1968
- isMainChunk: mainCssChunkMatcher(file, this.appType)
1969
- });
1970
- const source = new ConcatSource(css);
1971
- compilation.updateAsset(file, source);
1972
- onUpdate(file, rawSource, css);
1973
- debug("css handle: %s", file);
1974
- noCachedCount++;
1975
- return {
1976
- key: cacheKey,
1977
- source
1978
- };
1979
- })
1980
- );
1981
- }
1982
- debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
1983
- }
1984
- debug("end");
1985
- onEnd();
1986
- })
1987
- );
1988
- });
1989
- }
1990
- };
1991
- // Annotate the CommonJS export names for ESM import in node:
1992
- 0 && (module.exports = {
1993
- UnifiedWebpackPluginV5
1994
- });
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var v5 = require('./v5-Ch6783yy.js');
6
+ require('./options-C-rvBixk.js');
7
+ require('magic-string');
8
+ require('./replace.js');
9
+ require('@weapp-core/escape');
10
+ require('@ast-core/escape');
11
+ require('./shared-hzYeE1wX.js');
12
+ require('@weapp-core/regex');
13
+ require('@babel/generator');
14
+ require('@babel/traverse');
15
+ require('@babel/parser');
16
+ require('./defaults-DW-EahCC.js');
17
+ require('./defu-Cdz2PomB.js');
18
+ require('@babel/types');
19
+ require('htmlparser2');
20
+ require('postcss');
21
+ require('./index-DwZHOkK3.js');
22
+ require('@csstools/postcss-is-pseudo-class');
23
+ require('postcss-rem-to-responsive-pixel');
24
+ require('postcss-selector-parser');
25
+ require('node:path');
26
+ require('node:process');
27
+ require('tailwindcss-patch');
28
+ require('@tailwindcss-mangle/shared');
29
+ require('lru-cache');
30
+ require('md5');
31
+ require('node:fs');
32
+ require('./index-HC-Qkn0i.js');
33
+ require('debug');
34
+
35
+
36
+
37
+ exports.UnifiedWebpackPluginV5 = v5.UnifiedWebpackPluginV5;