weapp-tailwindcss 4.0.2 → 4.0.3-alpha.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 (56) hide show
  1. package/dist/chunk-2XGDXMFW.mjs +144 -0
  2. package/dist/{chunk-75EWCRQW.mjs → chunk-3AUX4FGE.mjs} +1 -1
  3. package/dist/{chunk-FHP2IWTD.mjs → chunk-5VREU6OZ.mjs} +189 -199
  4. package/dist/{chunk-YUXG2EJF.js → chunk-7FQEXXKJ.js} +6 -6
  5. package/dist/{chunk-RHTRRSP3.mjs → chunk-AFETST4F.mjs} +1 -1
  6. package/dist/{chunk-3HOCRXDT.mjs → chunk-E6GMQWXH.mjs} +22 -22
  7. package/dist/chunk-GXHC2INT.mjs +167 -0
  8. package/dist/chunk-IH4SPSSD.js +7 -0
  9. package/dist/chunk-INPHAJ2H.js +144 -0
  10. package/dist/{chunk-XKF5XSEO.js → chunk-KEPAORFQ.js} +28 -31
  11. package/dist/{chunk-HBQASQKY.js → chunk-LSSLYD6B.js} +2 -2
  12. package/dist/{chunk-NSZPW6UU.js → chunk-MCXEMTT6.js} +201 -208
  13. package/dist/{chunk-6Z776ZWK.js → chunk-NS3NEDWD.js} +1 -1
  14. package/dist/{chunk-AB467PG7.mjs → chunk-RGXLY3HG.mjs} +1 -1
  15. package/dist/chunk-UZEAMGMU.js +167 -0
  16. package/dist/chunk-X5LVW3JI.mjs +10 -0
  17. package/dist/cli.js +10 -10
  18. package/dist/cli.mjs +6 -6
  19. package/dist/core.js +9 -13
  20. package/dist/core.mjs +8 -12
  21. package/dist/css-macro/postcss.js +6 -7
  22. package/dist/css-macro/postcss.mjs +3 -4
  23. package/dist/css-macro.js +8 -8
  24. package/dist/css-macro.mjs +3 -3
  25. package/dist/defaults.js +4 -4
  26. package/dist/defaults.mjs +3 -3
  27. package/dist/escape.js +3 -3
  28. package/dist/escape.mjs +2 -2
  29. package/dist/gulp.js +8 -8
  30. package/dist/gulp.mjs +7 -7
  31. package/dist/index.js +12 -12
  32. package/dist/index.mjs +11 -11
  33. package/dist/types.js +2 -1
  34. package/dist/types.mjs +2 -1
  35. package/dist/vite.js +9 -9
  36. package/dist/vite.mjs +8 -8
  37. package/dist/weapp-tw-runtime-loader.js +28 -5
  38. package/dist/webpack.js +9 -9
  39. package/dist/webpack.mjs +8 -8
  40. package/dist/webpack4.js +30 -32
  41. package/dist/webpack4.mjs +24 -24
  42. package/package.json +4 -4
  43. package/dist/chunk-6FNC3XMI.js +0 -45
  44. package/dist/chunk-AXBFBHS2.mjs +0 -45
  45. package/dist/chunk-D6FTUNLD.mjs +0 -172
  46. package/dist/chunk-G63AWKPG.js +0 -172
  47. package/dist/chunk-MGGYACFY.js +0 -152
  48. package/dist/chunk-TFTD2FWQ.mjs +0 -152
  49. /package/dist/{chunk-N62XM3T3.js → chunk-EHEK77RO.js} +0 -0
  50. /package/dist/{chunk-MUJ65IQ3.mjs → chunk-L4LCKH3T.mjs} +0 -0
  51. /package/dist/{chunk-HL6Y5PYZ.mjs → chunk-L7PW3J3N.mjs} +0 -0
  52. /package/dist/{chunk-FXPGR372.js → chunk-O2IOQ3BD.js} +0 -0
  53. /package/dist/{chunk-WGQLZ5K4.js → chunk-PLMJW644.js} +0 -0
  54. /package/dist/{chunk-PCBSAFQF.mjs → chunk-Q67IXIAH.mjs} +0 -0
  55. /package/dist/{chunk-35CYTBPM.js → chunk-SUFSR3LY.js} +0 -0
  56. /package/dist/{chunk-LOLJLZCX.mjs → chunk-YAN7TO2B.mjs} +0 -0
@@ -1,18 +1,16 @@
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 }; }
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 _chunkWGQLZ5K4js = require('./chunk-WGQLZ5K4.js');
3
+ var _chunkPLMJW644js = require('./chunk-PLMJW644.js');
4
4
 
5
5
 
6
- var _chunkYUXG2EJFjs = require('./chunk-YUXG2EJF.js');
6
+ var _chunk7FQEXXKJjs = require('./chunk-7FQEXXKJ.js');
7
7
 
8
8
 
9
9
 
10
- var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
10
+ var _chunkSUFSR3LYjs = require('./chunk-SUFSR3LY.js');
11
11
 
12
12
 
13
-
14
-
15
- var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
13
+ var _chunkIH4SPSSDjs = require('./chunk-IH4SPSSD.js');
16
14
 
17
15
  // src/logger/index.ts
18
16
  var _logger = require('@weapp-tailwindcss/logger');
@@ -71,27 +69,25 @@ function createCache(options) {
71
69
  has(key) {
72
70
  return instance.has(key);
73
71
  },
74
- process(key, callback, fallback) {
75
- return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
76
- if (disabled) {
77
- const res = yield fallback();
78
- if (res) {
79
- this.set(res.key, res.source);
80
- }
81
- } else {
82
- const hit = this.getHashValue(key);
83
- if (hit && !hit.changed) {
84
- const returnFlag = yield callback();
85
- if (returnFlag !== false) {
86
- return;
87
- }
88
- }
89
- const res = yield fallback();
90
- if (res) {
91
- this.set(res.key, res.source);
72
+ async process(key, callback, fallback) {
73
+ if (disabled) {
74
+ const res = await fallback();
75
+ if (res) {
76
+ this.set(res.key, res.source);
77
+ }
78
+ } else {
79
+ const hit = this.getHashValue(key);
80
+ if (hit && !hit.changed) {
81
+ const returnFlag = await callback();
82
+ if (returnFlag !== false) {
83
+ return;
92
84
  }
93
85
  }
94
- });
86
+ const res = await fallback();
87
+ if (res) {
88
+ this.set(res.key, res.source);
89
+ }
90
+ }
95
91
  }
96
92
  };
97
93
  }
@@ -131,7 +127,7 @@ function replaceHandleValue(str, node, options, ms, offset = 0) {
131
127
  alwaysEscape,
132
128
  unescapeUnicode
133
129
  } = options;
134
- const allowDoubleQuotes = arbitraryValues == null ? void 0 : arbitraryValues.allowDoubleQuotes;
130
+ const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _ => _.allowDoubleQuotes]);
135
131
  let rawStr = str;
136
132
  let needUpdate = false;
137
133
  if (unescapeUnicode && rawStr.includes("\\u")) {
@@ -139,7 +135,7 @@ function replaceHandleValue(str, node, options, ms, offset = 0) {
139
135
  }
140
136
  const arr = _extractors.splitCode.call(void 0, rawStr, allowDoubleQuotes);
141
137
  for (const v of arr) {
142
- if (alwaysEscape || classNameSet && classNameSet.has(v) && !(jsPreserveClass == null ? void 0 : jsPreserveClass(v))) {
138
+ if (alwaysEscape || classNameSet && classNameSet.has(v) && !_optionalChain([jsPreserveClass, 'optionalCall', _2 => _2(v)])) {
143
139
  let ignoreFlag = false;
144
140
  if (Array.isArray(node.leadingComments)) {
145
141
  ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes("weapp-tw") && x.value.includes("ignore")) > -1;
@@ -150,7 +146,7 @@ function replaceHandleValue(str, node, options, ms, offset = 0) {
150
146
  }
151
147
  rawStr = rawStr.replace(
152
148
  new RegExp(_regex.escapeStringRegexp.call(void 0, v)),
153
- _chunkWGQLZ5K4js.replaceWxml.call(void 0, v, {
149
+ _chunkPLMJW644js.replaceWxml.call(void 0, v, {
154
150
  escapeMap
155
151
  })
156
152
  );
@@ -170,16 +166,14 @@ function replaceHandleValue(str, node, options, ms, offset = 0) {
170
166
  }
171
167
 
172
168
  // src/js/ast-grep.ts
173
- function getAstGrep() {
174
- return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
175
- try {
176
- const mod = yield Promise.resolve().then(() => _interopRequireWildcard(require("@ast-grep/napi")));
177
- return mod;
178
- } catch (error) {
179
- _logger.logger.warn("\u8BF7\u5148\u5B89\u88C5 `@ast-grep/napi` , \u5B89\u88C5\u5B8C\u6210\u540E\u518D\u5C1D\u8BD5\u8FD0\u884C\uFF01");
180
- throw error;
181
- }
182
- });
169
+ async function getAstGrep() {
170
+ try {
171
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("@ast-grep/napi")));
172
+ return mod;
173
+ } catch (error) {
174
+ _logger.logger.warn("\u8BF7\u5148\u5B89\u88C5 `@ast-grep/napi` , \u5B89\u88C5\u5B8C\u6210\u540E\u518D\u5C1D\u8BD5\u8FD0\u884C\uFF01");
175
+ throw error;
176
+ }
183
177
  }
184
178
  function isRangeWithinArray(ranges, targetRange) {
185
179
  const { start: targetStart, end: targetEnd } = targetRange;
@@ -187,89 +181,85 @@ function isRangeWithinArray(ranges, targetRange) {
187
181
  return start.index <= targetStart.index && end.index >= targetEnd.index;
188
182
  });
189
183
  }
190
- function astGrepUpdateString(ast, options, ms) {
191
- return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
192
- var _a;
193
- const { Lang, kind } = yield getAstGrep();
194
- const callExpressionNodes = ast.findAll(kind(Lang.JavaScript, "call_expression"));
195
- let chooseNodeRanges = [];
196
- if (Array.isArray(options.ignoreCallExpressionIdentifiers) && options.ignoreCallExpressionIdentifiers.length) {
197
- chooseNodeRanges = callExpressionNodes.filter((x) => {
198
- var _a2;
199
- const id = x.child(0);
200
- return (id == null ? void 0 : id.kindToRefine) === "identifier" && ((_a2 = options.ignoreCallExpressionIdentifiers) == null ? void 0 : _a2.includes(id.text()));
201
- }).map((x) => x == null ? void 0 : x.range());
184
+ async function astGrepUpdateString(ast, options, ms) {
185
+ const { Lang, kind } = await getAstGrep();
186
+ const callExpressionNodes = ast.findAll(kind(Lang.JavaScript, "call_expression"));
187
+ let chooseNodeRanges = [];
188
+ if (Array.isArray(options.ignoreCallExpressionIdentifiers) && options.ignoreCallExpressionIdentifiers.length) {
189
+ chooseNodeRanges = callExpressionNodes.filter((x) => {
190
+ const id = x.child(0);
191
+ return _optionalChain([id, 'optionalAccess', _3 => _3.kindToRefine]) === "identifier" && _optionalChain([options, 'access', _4 => _4.ignoreCallExpressionIdentifiers, 'optionalAccess', _5 => _5.includes, 'call', _6 => _6(id.text())]);
192
+ }).map((x) => _optionalChain([x, 'optionalAccess', _7 => _7.range, 'call', _8 => _8()]));
193
+ }
194
+ const nodes = ast.findAll(kind(Lang.JavaScript, "string"));
195
+ for (const node of nodes) {
196
+ const range = node.range();
197
+ if (isRangeWithinArray(chooseNodeRanges, range)) {
198
+ continue;
199
+ }
200
+ const text = node.text();
201
+ replaceHandleValue(
202
+ text.slice(1, -1),
203
+ {
204
+ end: range.end.index - 1,
205
+ start: range.start.index + 1
206
+ },
207
+ {
208
+ ...options,
209
+ unescapeUnicode: true
210
+ },
211
+ ms,
212
+ 0
213
+ );
214
+ }
215
+ const templateNodes = ast.findAll(kind(Lang.JavaScript, "template_string"));
216
+ for (const node of templateNodes) {
217
+ const p = node.parent();
218
+ if (p && p.kind() === "call_expression") {
219
+ const c = p.child(0);
220
+ if (c && c.kind() === "identifier" && _optionalChain([options, 'access', _9 => _9.ignoreTaggedTemplateExpressionIdentifiers, 'optionalAccess', _10 => _10.includes, 'call', _11 => _11(c.text())])) {
221
+ continue;
222
+ }
202
223
  }
203
- const nodes = ast.findAll(kind(Lang.JavaScript, "string"));
204
- for (const node of nodes) {
205
- const range = node.range();
224
+ const fragments = node.findAll(kind(Lang.JavaScript, "string_fragment"));
225
+ for (const fragment of fragments) {
226
+ const range = fragment.range();
206
227
  if (isRangeWithinArray(chooseNodeRanges, range)) {
207
228
  continue;
208
229
  }
209
- const text = node.text();
230
+ const text = fragment.text();
210
231
  replaceHandleValue(
211
- text.slice(1, -1),
232
+ text,
212
233
  {
213
- end: range.end.index - 1,
214
- start: range.start.index + 1
234
+ end: range.end.index,
235
+ start: range.start.index
215
236
  },
216
- _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
237
+ {
238
+ ...options,
217
239
  unescapeUnicode: true
218
- }),
240
+ },
219
241
  ms,
220
242
  0
221
243
  );
222
244
  }
223
- const templateNodes = ast.findAll(kind(Lang.JavaScript, "template_string"));
224
- for (const node of templateNodes) {
225
- const p = node.parent();
226
- if (p && p.kind() === "call_expression") {
227
- const c = p.child(0);
228
- if (c && c.kind() === "identifier" && ((_a = options.ignoreTaggedTemplateExpressionIdentifiers) == null ? void 0 : _a.includes(c.text()))) {
229
- continue;
230
- }
231
- }
232
- const fragments = node.findAll(kind(Lang.JavaScript, "string_fragment"));
233
- for (const fragment of fragments) {
234
- const range = fragment.range();
235
- if (isRangeWithinArray(chooseNodeRanges, range)) {
236
- continue;
237
- }
238
- const text = fragment.text();
239
- replaceHandleValue(
240
- text,
241
- {
242
- end: range.end.index,
243
- start: range.start.index
244
- },
245
- _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
246
- unescapeUnicode: true
247
- }),
248
- ms,
249
- 0
250
- );
251
- }
252
- }
253
- });
245
+ }
254
246
  }
255
- function jsHandlerAsync(rawSource, options) {
256
- return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
257
- const ms = new (0, _magicstring2.default)(rawSource);
258
- const { parseAsync, Lang } = yield getAstGrep();
259
- let ast;
260
- try {
261
- const root = yield parseAsync(Lang.JavaScript, rawSource);
262
- ast = root.root();
263
- } catch (e) {
264
- return {
265
- code: rawSource
266
- };
267
- }
268
- yield astGrepUpdateString(ast, options, ms);
247
+ async function jsHandlerAsync(rawSource, options) {
248
+ const ms = new (0, _magicstring2.default)(rawSource);
249
+ const { parseAsync, Lang } = await getAstGrep();
250
+ let ast;
251
+ try {
252
+ const root = await parseAsync(Lang.JavaScript, rawSource);
253
+ ast = root.root();
254
+ } catch (e2) {
269
255
  return {
270
- code: ms.toString()
256
+ code: rawSource
271
257
  };
272
- });
258
+ }
259
+ await astGrepUpdateString(ast, options, ms);
260
+ return {
261
+ code: ms.toString()
262
+ };
273
263
  }
274
264
 
275
265
  // src/js/babel.ts
@@ -308,7 +298,6 @@ function jsHandler(rawSource, options) {
308
298
  const traverseOptions = {
309
299
  StringLiteral: {
310
300
  enter(p) {
311
- var _a;
312
301
  if (ignoreFlag) {
313
302
  return;
314
303
  }
@@ -319,9 +308,10 @@ function jsHandler(rawSource, options) {
319
308
  replaceHandleValue(
320
309
  n.value,
321
310
  n,
322
- _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
323
- needEscaped: (_a = options.needEscaped) != null ? _a : true
324
- }),
311
+ {
312
+ ...options,
313
+ needEscaped: _nullishCoalesce(options.needEscaped, () => ( true))
314
+ },
325
315
  ms,
326
316
  1
327
317
  );
@@ -329,12 +319,11 @@ function jsHandler(rawSource, options) {
329
319
  },
330
320
  TemplateElement: {
331
321
  enter(p) {
332
- var _a;
333
322
  if (ignoreFlag) {
334
323
  return;
335
324
  }
336
325
  if (p.parentPath.isTemplateLiteral()) {
337
- if (p.parentPath.parentPath.isTaggedTemplateExpression() && p.parentPath.parentPath.get("tag").isIdentifier() && ((_a = options.ignoreTaggedTemplateExpressionIdentifiers) == null ? void 0 : _a.includes(p.parentPath.parentPath.get("tag").node.name)) || isEvalPath(p.parentPath.parentPath)) {
326
+ if (p.parentPath.parentPath.isTaggedTemplateExpression() && p.parentPath.parentPath.get("tag").isIdentifier() && _optionalChain([options, 'access', _12 => _12.ignoreTaggedTemplateExpressionIdentifiers, 'optionalAccess', _13 => _13.includes, 'call', _14 => _14(p.parentPath.parentPath.get("tag").node.name)]) || isEvalPath(p.parentPath.parentPath)) {
338
327
  return;
339
328
  }
340
329
  }
@@ -342,9 +331,10 @@ function jsHandler(rawSource, options) {
342
331
  replaceHandleValue(
343
332
  n.value.raw,
344
333
  n,
345
- _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
334
+ {
335
+ ...options,
346
336
  needEscaped: false
347
- }),
337
+ },
348
338
  ms,
349
339
  0
350
340
  );
@@ -352,15 +342,15 @@ function jsHandler(rawSource, options) {
352
342
  },
353
343
  CallExpression: {
354
344
  enter(p) {
355
- var _a;
356
345
  if (isEvalPath(p)) {
357
346
  p.traverse({
358
347
  StringLiteral: {
359
348
  enter(s) {
360
- const res = jsHandler(s.node.value, _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
349
+ const res = jsHandler(s.node.value, {
350
+ ...options,
361
351
  needEscaped: false,
362
352
  generateMap: false
363
- }));
353
+ });
364
354
  if (res.code) {
365
355
  const node = s.node;
366
356
  if (typeof node.start === "number" && typeof node.end === "number") {
@@ -376,9 +366,10 @@ function jsHandler(rawSource, options) {
376
366
  },
377
367
  TemplateElement: {
378
368
  enter(s) {
379
- const res = jsHandler(s.node.value.raw, _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
369
+ const res = jsHandler(s.node.value.raw, {
370
+ ...options,
380
371
  generateMap: false
381
- }));
372
+ });
382
373
  if (res.code) {
383
374
  const node = s.node;
384
375
  if (typeof node.start === "number" && typeof node.end === "number") {
@@ -393,7 +384,7 @@ function jsHandler(rawSource, options) {
393
384
  }
394
385
  }
395
386
  });
396
- } else if (p.get("callee").isIdentifier() && ((_a = options.ignoreCallExpressionIdentifiers) == null ? void 0 : _a.includes(p.get("callee").node.name))) {
387
+ } else if (p.get("callee").isIdentifier() && _optionalChain([options, 'access', _15 => _15.ignoreCallExpressionIdentifiers, 'optionalAccess', _16 => _16.includes, 'call', _17 => _17(p.get("callee").node.name)])) {
397
388
  ignoreFlag = true;
398
389
  ignoreFlagMap.set(p, true);
399
390
  }
@@ -430,7 +421,7 @@ function createJsHandler(options) {
430
421
  ignoreTaggedTemplateExpressionIdentifiers
431
422
  } = options;
432
423
  function handler(rawSource, classNameSet, options2) {
433
- const opts = _chunk35CYTBPMjs.defuOverrideArray.call(void 0, options2, {
424
+ const opts = _chunkSUFSR3LYjs.defuOverrideArray.call(void 0, options2, {
434
425
  classNameSet,
435
426
  escapeMap,
436
427
  arbitraryValues,
@@ -448,7 +439,7 @@ function createJsHandler(options) {
448
439
  return jsHandler(rawSource, opts);
449
440
  }
450
441
  function sync(rawSource, classNameSet, options2) {
451
- const opts = _chunk35CYTBPMjs.defuOverrideArray.call(void 0, options2, {
442
+ const opts = _chunkSUFSR3LYjs.defuOverrideArray.call(void 0, options2, {
452
443
  classNameSet,
453
444
  escapeMap,
454
445
  arbitraryValues,
@@ -472,7 +463,7 @@ var _localpkg = require('local-pkg');
472
463
  // src/tailwindcss/patcher.ts
473
464
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
474
465
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
475
- var _escape3 = require('@weapp-core/escape');
466
+ var _shared = require('@weapp-tailwindcss/shared');
476
467
  var _tailwindcsspatch = require('tailwindcss-patch');
477
468
  function createTailwindcssPatcher(options) {
478
469
  const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, resolve } = options || {};
@@ -495,10 +486,14 @@ function createTailwindcssPatcher(options) {
495
486
  extendLengthUnits: supportCustomLengthUnitsPatch
496
487
  },
497
488
  tailwindcss,
498
- resolve,
499
- filter: (x) => {
500
- return !_escape3.isAllowedClassName.call(void 0, x);
501
- }
489
+ resolve: _shared.defuOverrideArray.call(void 0, resolve, {
490
+ paths: [
491
+ _chunkIH4SPSSDjs.importMetaUrl
492
+ ]
493
+ })
494
+ // filter: (x) => {
495
+ // return !isAllowedClassName(x)
496
+ // },
502
497
  // for example
503
498
  // resolve: {
504
499
  // paths: [
@@ -632,7 +627,7 @@ var Tokenizer = class {
632
627
  function generateCode(match, options = {}) {
633
628
  try {
634
629
  const { jsHandler: jsHandler2, runtimeSet } = options;
635
- if ((jsHandler2 == null ? void 0 : jsHandler2.sync) && runtimeSet) {
630
+ if (_optionalChain([jsHandler2, 'optionalAccess', _18 => _18.sync]) && runtimeSet) {
636
631
  const { code } = jsHandler2.sync(match, runtimeSet);
637
632
  return code;
638
633
  } else {
@@ -640,11 +635,10 @@ function generateCode(match, options = {}) {
640
635
  const ast = _parser.parseExpression.call(void 0, match);
641
636
  traverse(ast, {
642
637
  StringLiteral(path2) {
643
- var _a, _b;
644
638
  if (t.isMemberExpression(path2.parent)) {
645
639
  return;
646
640
  }
647
- if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression((_a = path2.parentPath) == null ? void 0 : _a.parent) || t.isLogicalExpression((_b = path2.parentPath) == null ? void 0 : _b.parent))) {
641
+ if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression(_optionalChain([path2, 'access', _19 => _19.parentPath, 'optionalAccess', _20 => _20.parent])) || t.isLogicalExpression(_optionalChain([path2, 'access', _21 => _21.parentPath, 'optionalAccess', _22 => _22.parent])))) {
648
642
  return;
649
643
  }
650
644
  const n = path2.node;
@@ -666,7 +660,7 @@ function generateCode(match, options = {}) {
666
660
  });
667
661
  return ms.toString();
668
662
  }
669
- } catch (e) {
663
+ } catch (e3) {
670
664
  return match;
671
665
  }
672
666
  }
@@ -676,7 +670,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
676
670
  if (token.expressions.length > 0) {
677
671
  for (const exp of token.expressions) {
678
672
  if (exp.start > token.start && p < exp.start) {
679
- ms.update(p, exp.start, _chunkWGQLZ5K4js.replaceWxml.call(void 0, ms.slice(p, exp.start), {
673
+ ms.update(p, exp.start, _chunkPLMJW644js.replaceWxml.call(void 0, ms.slice(p, exp.start), {
680
674
  keepEOL: true,
681
675
  escapeMap: options.escapeMap,
682
676
  mangleContext: options.mangleContext,
@@ -690,7 +684,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
690
684
  p = exp.end;
691
685
  }
692
686
  if (token.end > p) {
693
- ms.update(p, token.end, _chunkWGQLZ5K4js.replaceWxml.call(void 0, ms.slice(p, token.end), {
687
+ ms.update(p, token.end, _chunkPLMJW644js.replaceWxml.call(void 0, ms.slice(p, token.end), {
694
688
  keepEOL: false,
695
689
  escapeMap: options.escapeMap,
696
690
  mangleContext: options.mangleContext,
@@ -698,7 +692,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
698
692
  }));
699
693
  }
700
694
  } else {
701
- ms.update(token.start, token.end, _chunkWGQLZ5K4js.replaceWxml.call(void 0, token.value, {
695
+ ms.update(token.start, token.end, _chunkPLMJW644js.replaceWxml.call(void 0, token.value, {
702
696
  keepEOL: false,
703
697
  escapeMap: options.escapeMap,
704
698
  mangleContext: options.mangleContext,
@@ -733,86 +727,85 @@ function isPropsMatch(props, attr) {
733
727
  return regTest(props, attr);
734
728
  }
735
729
  }
736
- function customTemplateHandler(rawSource, options) {
737
- return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
738
- const {
739
- customAttributesEntities = [],
740
- disabledDefaultTemplateHandler,
741
- inlineWxs,
742
- runtimeSet,
743
- jsHandler: jsHandler2
744
- } = options != null ? options : {};
745
- const s = new (0, _magicstring2.default)(rawSource);
746
- let tag = "";
747
- const wxsArray = [];
748
- const parser = new (0, _htmlparser2.Parser)(
749
- {
750
- onopentagname(name) {
751
- tag = name;
752
- },
753
- onattribute(name, value, quote) {
754
- if (value) {
755
- let update2 = function() {
756
- s.update(
757
- parser.startIndex + name.length + 2,
758
- // !important
759
- // htmlparser2 9.0.0: parser.endIndex
760
- // htmlparser2 9.1.0: parser.endIndex - 1
761
- // https://github.com/sonofmagic/weapp-tailwindcss/issues/269
762
- parser.endIndex - 1,
763
- templateReplacer(value, _chunk6FNC3XMIjs.__spreadProps.call(void 0, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {}, options), {
764
- quote
765
- }))
766
- );
767
- };
768
- var update = update2;
769
- if (!disabledDefaultTemplateHandler && ["class", "hover-class", "virtualhostclass"].includes(name.toLocaleLowerCase())) {
770
- update2();
771
- }
772
- for (const [t2, props] of customAttributesEntities) {
773
- if (t2 === "*") {
774
- if (isPropsMatch(props, name)) {
775
- update2();
776
- }
777
- } else if (typeof t2 === "string") {
778
- if (t2 === tag && isPropsMatch(props, name)) {
779
- update2();
780
- }
781
- } else if (regTest(t2, tag) && isPropsMatch(props, name)) {
730
+ async function customTemplateHandler(rawSource, options) {
731
+ const {
732
+ customAttributesEntities = [],
733
+ disabledDefaultTemplateHandler,
734
+ inlineWxs,
735
+ runtimeSet,
736
+ jsHandler: jsHandler2
737
+ } = _nullishCoalesce(options, () => ( {}));
738
+ const s = new (0, _magicstring2.default)(rawSource);
739
+ let tag = "";
740
+ const wxsArray = [];
741
+ const parser = new (0, _htmlparser2.Parser)(
742
+ {
743
+ onopentagname(name) {
744
+ tag = name;
745
+ },
746
+ onattribute(name, value, quote) {
747
+ if (value) {
748
+ let update2 = function() {
749
+ s.update(
750
+ parser.startIndex + name.length + 2,
751
+ // !important
752
+ // htmlparser2 9.0.0: parser.endIndex
753
+ // htmlparser2 9.1.0: parser.endIndex - 1
754
+ // https://github.com/sonofmagic/weapp-tailwindcss/issues/269
755
+ parser.endIndex - 1,
756
+ templateReplacer(value, {
757
+ ...options,
758
+ quote
759
+ })
760
+ );
761
+ };
762
+ var update = update2;
763
+ if (!disabledDefaultTemplateHandler && ["class", "hover-class", "virtualhostclass"].includes(name.toLocaleLowerCase())) {
764
+ update2();
765
+ }
766
+ for (const [t2, props] of customAttributesEntities) {
767
+ if (t2 === "*") {
768
+ if (isPropsMatch(props, name)) {
782
769
  update2();
783
770
  }
771
+ } else if (typeof t2 === "string") {
772
+ if (t2 === tag && isPropsMatch(props, name)) {
773
+ update2();
774
+ }
775
+ } else if (regTest(t2, tag) && isPropsMatch(props, name)) {
776
+ update2();
784
777
  }
785
778
  }
786
- },
787
- ontext(data) {
788
- if (inlineWxs && tag === "wxs") {
789
- wxsArray.push({
790
- data,
791
- endIndex: parser.endIndex + 1,
792
- startIndex: parser.startIndex
793
- });
794
- }
795
- },
796
- onclosetag() {
797
- tag = "";
798
779
  }
799
780
  },
800
- {
801
- xmlMode: true
781
+ ontext(data) {
782
+ if (inlineWxs && tag === "wxs") {
783
+ wxsArray.push({
784
+ data,
785
+ endIndex: parser.endIndex + 1,
786
+ startIndex: parser.startIndex
787
+ });
788
+ }
789
+ },
790
+ onclosetag() {
791
+ tag = "";
802
792
  }
803
- );
804
- parser.write(s.original);
805
- parser.end();
806
- for (const { data, endIndex, startIndex } of wxsArray) {
807
- const { code } = yield jsHandler2(data, runtimeSet);
808
- s.update(startIndex, endIndex, code);
793
+ },
794
+ {
795
+ xmlMode: true
809
796
  }
810
- return s.toString();
811
- });
797
+ );
798
+ parser.write(s.original);
799
+ parser.end();
800
+ for (const { data, endIndex, startIndex } of wxsArray) {
801
+ const { code } = await jsHandler2(data, runtimeSet);
802
+ s.update(startIndex, endIndex, code);
803
+ }
804
+ return s.toString();
812
805
  }
813
806
  function createTemplateHandler(options = {}) {
814
807
  return (rawSource, opt = {}) => {
815
- return customTemplateHandler(rawSource, _chunk35CYTBPMjs.defuOverrideArray.call(void 0, opt, options));
808
+ return customTemplateHandler(rawSource, _chunkSUFSR3LYjs.defuOverrideArray.call(void 0, opt, options));
816
809
  };
817
810
  }
818
811
 
@@ -820,9 +813,9 @@ function createTemplateHandler(options = {}) {
820
813
  var _mangle = require('@weapp-tailwindcss/mangle');
821
814
  var _postcss = require('@weapp-tailwindcss/postcss');
822
815
  function getCompilerContext(opts) {
823
- const ctx = _chunk35CYTBPMjs.defuOverrideArray.call(void 0,
816
+ const ctx = _chunkSUFSR3LYjs.defuOverrideArray.call(void 0,
824
817
  opts,
825
- _chunkYUXG2EJFjs.getDefaultOptions.call(void 0, ),
818
+ _chunk7FQEXXKJjs.getDefaultOptions.call(void 0, ),
826
819
  {}
827
820
  );
828
821
  ctx.escapeMap = ctx.customReplaceDictionary;
@@ -855,7 +848,7 @@ function getCompilerContext(opts) {
855
848
  tailwindcss,
856
849
  resolve
857
850
  } = ctx;
858
- const customAttributesEntities = _chunk35CYTBPMjs.isMap.call(void 0, customAttributes) ? [...customAttributes.entries()] : Object.entries(customAttributes);
851
+ const customAttributesEntities = _chunkSUFSR3LYjs.isMap.call(void 0, customAttributes) ? [...customAttributes.entries()] : Object.entries(customAttributes);
859
852
  const { initMangle, mangleContext, setMangleRuntimeSet } = _mangle.useMangleStore.call(void 0, );
860
853
  initMangle(mangle);
861
854
  const styleHandler = _postcss.createStyleHandler.call(void 0, {
@@ -898,7 +891,7 @@ function getCompilerContext(opts) {
898
891
  {
899
892
  basedir: tailwindcssBasedir,
900
893
  cacheDir: appType === "mpx" ? "node_modules/tailwindcss-patch/.cache" : void 0,
901
- supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch != null ? supportCustomLengthUnitsPatch : true,
894
+ supportCustomLengthUnitsPatch: _nullishCoalesce(supportCustomLengthUnitsPatch, () => ( true)),
902
895
  tailwindcss,
903
896
  resolve
904
897
  }
@@ -8,7 +8,7 @@ function createNegativeMediaQuery(value) {
8
8
  }
9
9
  function normalComment(text) {
10
10
  if (typeof text === "string") {
11
- return text.replaceAll(new RegExp("(?<!\\\\)_", "g"), " ");
11
+ return text.replaceAll(/(?<!\\)_/g, " ");
12
12
  }
13
13
  return text;
14
14
  }
@@ -8,7 +8,7 @@ function createNegativeMediaQuery(value) {
8
8
  }
9
9
  function normalComment(text) {
10
10
  if (typeof text === "string") {
11
- return text.replaceAll(new RegExp("(?<!\\\\)_", "g"), " ");
11
+ return text.replaceAll(/(?<!\\)_/g, " ");
12
12
  }
13
13
  return text;
14
14
  }