weapp-tailwindcss 3.2.1 → 3.3.0

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 (58) hide show
  1. package/dist/bundlers/vite/index.d.ts +1 -1
  2. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +1 -1
  3. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  4. package/dist/cli.js +12 -11
  5. package/dist/cli.mjs +6 -6
  6. package/dist/{constants-D-YMDg7M.js → constants-CFM1J-h1.js} +3 -3
  7. package/dist/{constants-CcqTvLgQ.mjs → constants-Dy2Dd3Fz.mjs} +3 -3
  8. package/dist/core.d.ts +1 -1
  9. package/dist/core.js +12 -13
  10. package/dist/core.mjs +12 -13
  11. package/dist/css-macro/index.js +2 -2
  12. package/dist/css-macro/index.mjs +2 -2
  13. package/dist/css-macro/postcss.js +8 -8
  14. package/dist/css-macro/postcss.mjs +8 -8
  15. package/dist/{defaults-DOGbAFEj.mjs → defaults-BDivGN-J.mjs} +10 -10
  16. package/dist/{defaults-CGBcgdIr.js → defaults-z7wUEh47.js} +10 -10
  17. package/dist/defaults.js +1 -1
  18. package/dist/defaults.mjs +1 -1
  19. package/dist/extractors/split.d.ts +1 -1
  20. package/dist/gulp.js +7 -5
  21. package/dist/gulp.mjs +7 -5
  22. package/dist/{index-UGtfFwsf.mjs → index-BMv1aBKz.mjs} +13 -16
  23. package/dist/{index-DC60ES8u.mjs → index-BPzIdybK.mjs} +91 -91
  24. package/dist/{index-EnQF5WiI.mjs → index-Bm-88xa7.mjs} +14 -16
  25. package/dist/{index-iiM-deHl.js → index-CeRMFNvT.js} +13 -16
  26. package/dist/{index-6BUjj8Rl.js → index-DwZHOkK3.js} +91 -91
  27. package/dist/{index-BpY7tq3j.js → index-oneQz6yy.js} +20 -22
  28. package/dist/index.js +9 -7
  29. package/dist/index.mjs +9 -7
  30. package/dist/js/handlers.d.ts +1 -1
  31. package/dist/mangle/index.d.ts +1 -1
  32. package/dist/{options-BjZGMFOk.js → options-DCor-e5I.js} +80 -74
  33. package/dist/{options-D1IYbX_E.mjs → options-SmfRHxH0.mjs} +82 -75
  34. package/dist/postcss/plugins/index.d.ts +2 -2
  35. package/dist/postcss/preflight.d.ts +1 -1
  36. package/dist/postcss/selectorParser.d.ts +1 -1
  37. package/dist/postcss/shared.d.ts +1 -1
  38. package/dist/postcss.js +2 -2
  39. package/dist/postcss.mjs +2 -2
  40. package/dist/replace.d.ts +1 -1
  41. package/dist/replace.js +3 -3
  42. package/dist/replace.mjs +3 -3
  43. package/dist/{shared-BX0VV-pr.mjs → shared-DbJl6i6a.mjs} +2 -2
  44. package/dist/{shared-BDew1Ric.js → shared-hzYeE1wX.js} +2 -2
  45. package/dist/tailwindcss/patcher.d.ts +4 -3
  46. package/dist/types.d.ts +7 -5
  47. package/dist/utils.d.ts +1 -1
  48. package/dist/{v5-C6FTqEeL.mjs → v5-CQUeTJ2W.mjs} +16 -19
  49. package/dist/{v5-DA4DSMKO.js → v5-ea_QoULz.js} +16 -19
  50. package/dist/vite.js +6 -5
  51. package/dist/vite.mjs +6 -5
  52. package/dist/webpack.js +6 -5
  53. package/dist/webpack.mjs +6 -5
  54. package/dist/webpack4.js +17 -19
  55. package/dist/webpack4.mjs +17 -19
  56. package/dist/wxml/shared.d.ts +1 -1
  57. package/dist/wxml/utils.d.ts +2 -2
  58. package/package.json +80 -78
@@ -6,15 +6,16 @@ import { jsStringEscape } from '@ast-core/escape';
6
6
  import _babelGenerate from '@babel/generator';
7
7
  import _babelTraverse from '@babel/traverse';
8
8
  import { parse, parseExpression } from '@babel/parser';
9
- import { d as defuOverrideArray, n as noop, a as defaultOptions, i as isMap } from './defaults-DOGbAFEj.mjs';
9
+ import { d as defuOverrideArray, n as noop, a as defaultOptions, i as isMap } from './defaults-BDivGN-J.mjs';
10
10
  import * as t from '@babel/types';
11
11
  import { Parser } from 'htmlparser2';
12
12
  import postcss from 'postcss';
13
- import { g as getPlugins } from './index-DC60ES8u.mjs';
13
+ import { g as getPlugins } from './index-BPzIdybK.mjs';
14
14
  import path from 'node:path';
15
15
  import fs from 'node:fs';
16
+ import 'node:process';
16
17
  import { gte } from 'semver';
17
- import { monkeyPatchForExposingContext, requireResolve, TailwindcssPatcher } from 'tailwindcss-patch';
18
+ import { TailwindcssPatcher, requireResolve } from 'tailwindcss-patch';
18
19
  import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
19
20
  import { LRUCache } from 'lru-cache';
20
21
  import md5 from 'md5';
@@ -55,16 +56,16 @@ const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
55
56
  function isValidSelector(selector = '') {
56
57
  return validateFilterRE.test(selector);
57
58
  }
58
- const splitCode = (code, allowDoubleQuotes = false) => {
59
+ function splitCode(code, allowDoubleQuotes = false) {
59
60
  const splitter = allowDoubleQuotes ? /\s+/ : /\s+|"/;
60
- return code.split(splitter).filter((element) => isValidSelector(element));
61
- };
61
+ return code.split(splitter).filter(element => isValidSelector(element));
62
+ }
62
63
 
63
64
  function decodeUnicode(s) {
64
65
  return unescape(s.replaceAll(/\\(u[\dA-Fa-f]{4})/gm, '%$1'));
65
66
  }
66
67
  function replaceHandleValue(str, node, options, ms, offset = 0) {
67
- const { classNameSet: set, escapeMap, mangleContext: ctx, needEscaped = false, jsPreserveClass, arbitraryValues, always, unescapeUnicode } = options;
68
+ const { classNameSet: set, escapeMap, mangleContext: ctx, needEscaped = false, jsPreserveClass, arbitraryValues, always, unescapeUnicode, } = options;
68
69
  const allowDoubleQuotes = arbitraryValues === null || arbitraryValues === void 0 ? void 0 : arbitraryValues.allowDoubleQuotes;
69
70
  const arr = splitCode(str, allowDoubleQuotes);
70
71
  let rawStr = str;
@@ -80,15 +81,15 @@ function replaceHandleValue(str, node, options, ms, offset = 0) {
80
81
  if (always || (set && set.has(v) && !(jsPreserveClass === null || jsPreserveClass === void 0 ? void 0 : jsPreserveClass(v)))) {
81
82
  let ignoreFlag = false;
82
83
  if (Array.isArray(node.leadingComments)) {
83
- ignoreFlag =
84
- node.leadingComments.findIndex((x) => x.value.includes('weapp-tw') && x.value.includes('ignore')) > -1;
84
+ ignoreFlag
85
+ = node.leadingComments.findIndex(x => x.value.includes('weapp-tw') && x.value.includes('ignore')) > -1;
85
86
  }
86
87
  if (!ignoreFlag) {
87
88
  if (ctx) {
88
89
  rawStr = ctx.jsHandler(rawStr);
89
90
  }
90
91
  rawStr = rawStr.replace(new RegExp(escapeStringRegexp(v)), replaceWxml(v, {
91
- escapeMap
92
+ escapeMap,
92
93
  }));
93
94
  }
94
95
  }
@@ -138,7 +139,7 @@ function astGrepUpdateString(ast, options, ms) {
138
139
  const text = node.text();
139
140
  replaceHandleValue(text.slice(1, -1), {
140
141
  end: range.end.index - 1,
141
- start: range.start.index + 1
142
+ start: range.start.index + 1,
142
143
  }, Object.assign(Object.assign({}, options), { unescapeUnicode: true }), ms, 0);
143
144
  }
144
145
  const templateNodes = ast.findAll(js.kind('template_string'));
@@ -149,7 +150,7 @@ function astGrepUpdateString(ast, options, ms) {
149
150
  const text = fragment.text();
150
151
  replaceHandleValue(text, {
151
152
  end: range.end.index,
152
- start: range.start.index
153
+ start: range.start.index,
153
154
  }, Object.assign(Object.assign({}, options), { unescapeUnicode: true }), ms, 0);
154
155
  }
155
156
  }
@@ -164,7 +165,7 @@ function jsHandler(rawSource, options) {
164
165
  catch (error) {
165
166
  return {
166
167
  code: rawSource,
167
- error: error
168
+ error: error,
168
169
  };
169
170
  }
170
171
  const traverseOptions = {
@@ -176,7 +177,7 @@ function jsHandler(rawSource, options) {
176
177
  }
177
178
  const n = p.node;
178
179
  replaceHandleValue(n.value, n, Object.assign(Object.assign({}, options), { needEscaped: (_a = options.needEscaped) !== null && _a !== void 0 ? _a : true }), ms, 1);
179
- }
180
+ },
180
181
  },
181
182
  TemplateElement: {
182
183
  enter(p) {
@@ -185,7 +186,7 @@ function jsHandler(rawSource, options) {
185
186
  }
186
187
  const n = p.node;
187
188
  replaceHandleValue(n.value.raw, n, Object.assign(Object.assign({}, options), { needEscaped: false }), ms, 0);
188
- }
189
+ },
189
190
  },
190
191
  CallExpression: {
191
192
  enter(p) {
@@ -205,7 +206,7 @@ function jsHandler(rawSource, options) {
205
206
  }
206
207
  }
207
208
  }
208
- }
209
+ },
209
210
  },
210
211
  TemplateElement: {
211
212
  enter(s) {
@@ -221,16 +222,16 @@ function jsHandler(rawSource, options) {
221
222
  }
222
223
  }
223
224
  }
224
- }
225
- }
225
+ },
226
+ },
226
227
  });
227
228
  }
228
- }
229
- }
229
+ },
230
+ },
230
231
  };
231
232
  traverse(ast, traverseOptions);
232
233
  return {
233
- code: ms.toString()
234
+ code: ms.toString(),
234
235
  };
235
236
  }
236
237
  function jsHandlerAsync(rawSource, options) {
@@ -244,12 +245,12 @@ function jsHandlerAsync(rawSource, options) {
244
245
  }
245
246
  catch (_a) {
246
247
  return {
247
- code: rawSource
248
+ code: rawSource,
248
249
  };
249
250
  }
250
251
  yield astGrepUpdateString(ast, options, ms);
251
252
  return {
252
- code: ms.toString()
253
+ code: ms.toString(),
253
254
  };
254
255
  });
255
256
  }
@@ -264,7 +265,7 @@ function createJsHandler(options) {
264
265
  jsPreserveClass,
265
266
  generateMap,
266
267
  jsAstTool,
267
- babelParserOptions
268
+ babelParserOptions,
268
269
  });
269
270
  if (opts.jsAstTool === 'ast-grep') {
270
271
  return jsHandlerAsync(rawSource, opts);
@@ -292,10 +293,10 @@ function generateCode(match, options = {}) {
292
293
  escapeMap: options.escapeMap,
293
294
  classNameSet: options.runtimeSet,
294
295
  needEscaped: true,
295
- always: true
296
+ always: true,
296
297
  }, ms, 1);
297
298
  },
298
- noScope: true
299
+ noScope: true,
299
300
  });
300
301
  return ms.toString();
301
302
  }
@@ -312,7 +313,7 @@ function extract(original, reg) {
312
313
  sources.push({
313
314
  start,
314
315
  end,
315
- raw: match[1]
316
+ raw: match[1],
316
317
  });
317
318
  match = reg.exec(original);
318
319
  }
@@ -332,7 +333,7 @@ function templateReplacer(original, options = {}) {
332
333
  resultArray.push(replaceWxml(before, {
333
334
  keepEOL: true,
334
335
  escapeMap: options.escapeMap,
335
- mangleContext: options.mangleContext
336
+ mangleContext: options.mangleContext,
336
337
  }));
337
338
  p = m.start;
338
339
  if (m.raw.trim().length > 0) {
@@ -350,7 +351,7 @@ function templateReplacer(original, options = {}) {
350
351
  resultArray.push(replaceWxml(after, {
351
352
  keepEOL: true,
352
353
  escapeMap: options.escapeMap,
353
- mangleContext: options.mangleContext
354
+ mangleContext: options.mangleContext,
354
355
  }));
355
356
  }
356
357
  }
@@ -360,7 +361,7 @@ function templateReplacer(original, options = {}) {
360
361
  return replaceWxml(original, {
361
362
  keepEOL: false,
362
363
  escapeMap: options.escapeMap,
363
- mangleContext: options.mangleContext
364
+ mangleContext: options.mangleContext,
364
365
  });
365
366
  }
366
367
  }
@@ -387,7 +388,7 @@ function isPropsMatch(props, attr) {
387
388
  }
388
389
  function customTemplateHandler(rawSource, options) {
389
390
  return __awaiter(this, void 0, void 0, function* () {
390
- const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options !== null && options !== void 0 ? options : {};
391
+ const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler, } = options !== null && options !== void 0 ? options : {};
391
392
  const s = new MagicString(rawSource);
392
393
  let tag = '';
393
394
  const wxsArray = [];
@@ -400,8 +401,8 @@ function customTemplateHandler(rawSource, options) {
400
401
  function update() {
401
402
  s.update(parser.startIndex + name.length + 2, parser.endIndex - 1, templateReplacer(value, Object.assign(Object.assign({}, options), { quote })));
402
403
  }
403
- if (!disabledDefaultTemplateHandler &&
404
- (name === 'class' || name === 'hover-class' || name === 'virtualHostClass' || name === 'virtualhostclass')) {
404
+ if (!disabledDefaultTemplateHandler
405
+ && (name === 'class' || name === 'hover-class' || name === 'virtualHostClass' || name === 'virtualhostclass')) {
405
406
  update();
406
407
  }
407
408
  for (const [t, props] of customAttributesEntities) {
@@ -426,15 +427,15 @@ function customTemplateHandler(rawSource, options) {
426
427
  wxsArray.push({
427
428
  data,
428
429
  endIndex: parser.endIndex + 1,
429
- startIndex: parser.startIndex
430
+ startIndex: parser.startIndex,
430
431
  });
431
432
  }
432
433
  },
433
434
  onclosetag() {
434
435
  tag = '';
435
- }
436
+ },
436
437
  }, {
437
- xmlMode: true
438
+ xmlMode: true,
438
439
  });
439
440
  parser.write(s.original);
440
441
  parser.end();
@@ -456,7 +457,7 @@ function styleHandler(rawSource, options) {
456
457
  var _a, _b;
457
458
  return (yield postcss(getPlugins(options))
458
459
  .process(rawSource, (_b = (_a = options.postcssOptions) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : {
459
- from: undefined
460
+ from: undefined,
460
461
  })
461
462
  .async()).css;
462
463
  });
@@ -467,7 +468,7 @@ function createStyleHandler(options) {
467
468
  };
468
469
  }
469
470
 
470
- const createInjectPreflight = (options) => {
471
+ function createInjectPreflight(options) {
471
472
  const result = [];
472
473
  if (options && typeof options === 'object') {
473
474
  const entries = Object.entries(options);
@@ -475,7 +476,7 @@ const createInjectPreflight = (options) => {
475
476
  if (value !== false) {
476
477
  result.push({
477
478
  prop,
478
- value: value.toString()
479
+ value: value.toString(),
479
480
  });
480
481
  }
481
482
  }
@@ -483,7 +484,7 @@ const createInjectPreflight = (options) => {
483
484
  return () => {
484
485
  return result;
485
486
  };
486
- };
487
+ }
487
488
 
488
489
  function findAstNode(content, options) {
489
490
  const DOPTS = options.dangerousOptions;
@@ -492,11 +493,11 @@ function findAstNode(content, options) {
492
493
  let changed = false;
493
494
  traverse(ast, {
494
495
  Identifier(path) {
495
- if (path.node.name === DOPTS.variableName &&
496
- t.isVariableDeclarator(path.parent) &&
497
- t.isArrayExpression(path.parent.init)) {
496
+ if (path.node.name === DOPTS.variableName
497
+ && t.isVariableDeclarator(path.parent)
498
+ && t.isArrayExpression(path.parent.init)) {
498
499
  arrayRef = path.parent.init;
499
- const set = new Set(path.parent.init.elements.map((x) => x.value));
500
+ const set = new Set(path.parent.init.elements.map(x => x.value));
500
501
  for (let i = 0; i < options.units.length; i++) {
501
502
  const unit = options.units[i];
502
503
  if (!set.has(unit)) {
@@ -504,24 +505,24 @@ function findAstNode(content, options) {
504
505
  if (t.isStringLiteral(x)) {
505
506
  return {
506
507
  type: x === null || x === void 0 ? void 0 : x.type,
507
- value: x === null || x === void 0 ? void 0 : x.value
508
+ value: x === null || x === void 0 ? void 0 : x.value,
508
509
  };
509
510
  }
510
511
  return x;
511
512
  });
512
513
  path.parent.init.elements.push({
513
514
  type: 'StringLiteral',
514
- value: unit
515
+ value: unit,
515
516
  });
516
517
  changed = true;
517
518
  }
518
519
  }
519
520
  }
520
- }
521
+ },
521
522
  });
522
523
  return {
523
524
  arrayRef,
524
- changed
525
+ changed,
525
526
  };
526
527
  }
527
528
 
@@ -530,7 +531,7 @@ function getInstalledPkgJsonPath(options) {
530
531
  try {
531
532
  const tmpJsonPath = requireResolve(`${dangerousOptions.packageName}/package.json`, {
532
533
  paths: options.paths,
533
- basedir: options.basedir
534
+ basedir: options.basedir,
534
535
  });
535
536
  return tmpJsonPath;
536
537
  }
@@ -549,7 +550,7 @@ function createPatch(options) {
549
550
  return internalPatch(getInstalledPkgJsonPath(options), options);
550
551
  }
551
552
  catch (error) {
552
- console.warn(`patch tailwindcss failed:` + error.message);
553
+ console.warn(`patch tailwindcss failed: ${error.message}`);
553
554
  }
554
555
  };
555
556
  }
@@ -559,14 +560,14 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
559
560
  const DOPTS = dangerousOptions;
560
561
  const dataTypesFilePath = path.resolve(rootDir, DOPTS.lengthUnitsFilePath);
561
562
  const dataTypesFileContent = fs.readFileSync(dataTypesFilePath, {
562
- encoding: 'utf8'
563
+ encoding: 'utf8',
563
564
  });
564
565
  const { arrayRef, changed } = findAstNode(dataTypesFileContent, options);
565
566
  if (arrayRef && changed) {
566
567
  const { code } = generate(arrayRef, {
567
568
  jsescOption: {
568
- quotes: 'single'
569
- }
569
+ quotes: 'single',
570
+ },
570
571
  });
571
572
  if (arrayRef.start && arrayRef.end) {
572
573
  const prev = dataTypesFileContent.slice(0, arrayRef.start);
@@ -574,7 +575,7 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
574
575
  const newCode = prev + code + next;
575
576
  if (DOPTS.overwrite) {
576
577
  fs.writeFileSync((_a = DOPTS.destPath) !== null && _a !== void 0 ? _a : dataTypesFilePath, newCode, {
577
- encoding: 'utf8'
578
+ encoding: 'utf8',
578
579
  });
579
580
  console.log('patch tailwindcss for custom length unit successfully!');
580
581
  }
@@ -582,7 +583,7 @@ function monkeyPatchForSupportingCustomUnit(rootDir, options) {
582
583
  return code;
583
584
  }
584
585
  }
585
- function internalPatch(pkgJsonPath, options, overwrite = true) {
586
+ function internalPatch(pkgJsonPath, options) {
586
587
  if (pkgJsonPath) {
587
588
  const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
588
589
  const dangerousOptions = options.dangerousOptions;
@@ -590,17 +591,18 @@ function internalPatch(pkgJsonPath, options, overwrite = true) {
590
591
  if (gte(version, dangerousOptions.gteVersion)) {
591
592
  const rootDir = path.dirname(pkgJsonPath);
592
593
  const dataTypes = monkeyPatchForSupportingCustomUnit(rootDir, options);
593
- const result = monkeyPatchForExposingContext(rootDir, {
594
- overwrite,
595
- version
596
- });
597
- return Object.assign(Object.assign({}, result), { dataTypes });
594
+ return {
595
+ dataTypes,
596
+ };
598
597
  }
599
598
  }
600
599
  }
601
- function createTailwindcssPatcher() {
600
+ function createTailwindcssPatcher(basedir) {
602
601
  return new TailwindcssPatcher({
603
- cache: true
602
+ cache: true,
603
+ patch: {
604
+ basedir,
605
+ },
604
606
  });
605
607
  }
606
608
 
@@ -614,7 +616,7 @@ const defaultMangleContext = {
614
616
  filter: defaultMangleClassFilter,
615
617
  cssHandler: getSelf,
616
618
  jsHandler: getSelf,
617
- wxmlHandler: getSelf
619
+ wxmlHandler: getSelf,
618
620
  };
619
621
  function useMangleStore() {
620
622
  const ctx = Object.assign({}, defaultMangleContext);
@@ -637,7 +639,7 @@ function useMangleStore() {
637
639
  if (options === true) {
638
640
  options = {
639
641
  classGenerator: {},
640
- mangleClassFilter: defaultMangleClassFilter
642
+ mangleClassFilter: defaultMangleClassFilter,
641
643
  };
642
644
  }
643
645
  ctx.classGenerator = new ClassGenerator(options.classGenerator);
@@ -666,7 +668,7 @@ function useMangleStore() {
666
668
  mangleContext: ctx,
667
669
  resetMangle,
668
670
  initMangle,
669
- setMangleRuntimeSet
671
+ setMangleRuntimeSet,
670
672
  };
671
673
  }
672
674
 
@@ -676,7 +678,7 @@ function createCache(options) {
676
678
  const instance = new LRUCache({
677
679
  max: 1024,
678
680
  ttl: 0,
679
- ttlAutopurge: false
681
+ ttlAutopurge: false,
680
682
  });
681
683
  return {
682
684
  hashMap,
@@ -704,13 +706,13 @@ function createCache(options) {
704
706
  if (hit) {
705
707
  this.setHashValue(key, {
706
708
  changed: hash !== hit.hash,
707
- hash
709
+ hash,
708
710
  });
709
711
  }
710
712
  else {
711
713
  this.setHashValue(key, {
712
714
  changed: true,
713
- hash
715
+ hash,
714
716
  });
715
717
  }
716
718
  return this;
@@ -740,14 +742,14 @@ function createCache(options) {
740
742
  }
741
743
  }
742
744
  });
743
- }
745
+ },
744
746
  };
745
747
  }
746
748
 
747
749
  function getOptions(opts) {
748
750
  const result = defuOverrideArray(opts, defaultOptions, {});
749
751
  result.escapeMap = result.customReplaceDictionary;
750
- const { cssPreflight, customRuleCallback, cssPreflightRange, customAttributes, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, cssSelectorReplacement, rem2rpx, cache, jsAstTool, babelParserOptions, postcssOptions, cssRemoveHoverPseudoClass, escapeMap, mangle } = result;
752
+ const { cssPreflight, customRuleCallback, cssPreflightRange, customAttributes, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler, cssSelectorReplacement, rem2rpx, cache, jsAstTool, babelParserOptions, postcssOptions, cssRemoveHoverPseudoClass, escapeMap, mangle, tailwindcssBasedir, } = result;
751
753
  const cssInjectPreflight = createInjectPreflight(cssPreflight);
752
754
  const customAttributesEntities = isMap(customAttributes)
753
755
  ? [...customAttributes.entries()]
@@ -765,7 +767,7 @@ function getOptions(opts) {
765
767
  cssSelectorReplacement,
766
768
  rem2rpx,
767
769
  postcssOptions,
768
- cssRemoveHoverPseudoClass
770
+ cssRemoveHoverPseudoClass,
769
771
  });
770
772
  const jsHandler = createJsHandler({
771
773
  escapeMap,
@@ -774,7 +776,7 @@ function getOptions(opts) {
774
776
  jsPreserveClass,
775
777
  generateMap: true,
776
778
  jsAstTool,
777
- babelParserOptions
779
+ babelParserOptions,
778
780
  });
779
781
  const templateHandler = createTemplateHandler({
780
782
  customAttributesEntities,
@@ -782,15 +784,20 @@ function getOptions(opts) {
782
784
  mangleContext,
783
785
  inlineWxs,
784
786
  jsHandler,
785
- disabledDefaultTemplateHandler
787
+ disabledDefaultTemplateHandler,
786
788
  });
787
789
  result.styleHandler = styleHandler;
788
790
  result.jsHandler = jsHandler;
789
791
  result.templateHandler = templateHandler;
790
- result.patch = createPatch(supportCustomLengthUnitsPatch);
792
+ const twPatcher = createTailwindcssPatcher(tailwindcssBasedir);
793
+ result.patch = () => {
794
+ createPatch(supportCustomLengthUnitsPatch)();
795
+ twPatcher.patch();
796
+ };
791
797
  result.setMangleRuntimeSet = setMangleRuntimeSet;
792
798
  result.cache = cache === undefined || typeof cache === 'boolean' ? createCache(cache) : cache;
799
+ result.twPatcher = twPatcher;
793
800
  return result;
794
801
  }
795
802
 
796
- export { __awaiter as _, createPatch as a, createTailwindcssPatcher as c, getOptions as g };
803
+ export { __awaiter as _, createTailwindcssPatcher as c, getOptions as g };
@@ -1,5 +1,5 @@
1
- import { AcceptedPlugin } from 'postcss';
2
- import { IStyleHandlerOptions } from "../../types";
1
+ import type { AcceptedPlugin } from 'postcss';
2
+ import type { IStyleHandlerOptions } from "../../types";
3
3
  export declare function getPlugins(options: IStyleHandlerOptions): AcceptedPlugin[];
4
4
  export { postcssWeappTailwindcssPostPlugin } from './post';
5
5
  export { postcssWeappTailwindcssPrePlugin } from './pre';
@@ -1,3 +1,3 @@
1
1
  import type { CssPreflightOptions, IPropValue } from "../types";
2
2
  export type InjectPreflight = () => IPropValue[];
3
- export declare const createInjectPreflight: (options?: CssPreflightOptions) => InjectPreflight;
3
+ export declare function createInjectPreflight(options?: CssPreflightOptions): InjectPreflight;
@@ -1,6 +1,6 @@
1
1
  import selectorParser from 'postcss-selector-parser';
2
2
  import type { Rule } from 'postcss';
3
3
  import type { IStyleHandlerOptions } from "../types";
4
- export declare const ruleTransformSync: (rule: Rule, options: IStyleHandlerOptions) => void;
4
+ export declare function ruleTransformSync(rule: Rule, options: IStyleHandlerOptions): void;
5
5
  export declare function isOnlyBeforeAndAfterPseudoElement(node: Rule): boolean;
6
6
  export declare const fallbackRemove: selectorParser.Processor<void, selectorParser.Selectors>;
@@ -1,3 +1,3 @@
1
- import { InternalCssSelectorReplacerOptions } from "../types";
1
+ import type { InternalCssSelectorReplacerOptions } from "../types";
2
2
  export declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
3
3
  export declare function composeIsPseudo(strs: string | string[]): string;
package/dist/postcss.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-6BUjj8Rl.js');
5
+ var index = require('./index-DwZHOkK3.js');
6
6
  var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
7
7
  var postcssRem2rpx = require('postcss-rem-to-responsive-pixel');
8
8
  require('postcss-selector-parser');
9
- require('./shared-BDew1Ric.js');
9
+ require('./shared-hzYeE1wX.js');
10
10
  require('@weapp-core/escape');
11
11
  require('@ast-core/escape');
12
12
  require('postcss');
package/dist/postcss.mjs CHANGED
@@ -1,8 +1,8 @@
1
- export { g as getPlugins, p as postcssWeappTailwindcssPostPlugin, a as postcssWeappTailwindcssPrePlugin } from './index-DC60ES8u.mjs';
1
+ export { g as getPlugins, p as postcssWeappTailwindcssPostPlugin, a as postcssWeappTailwindcssPrePlugin } from './index-BPzIdybK.mjs';
2
2
  export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
3
3
  export { default as postcssRem2rpx } from 'postcss-rem-to-responsive-pixel';
4
4
  import 'postcss-selector-parser';
5
- import './shared-BX0VV-pr.mjs';
5
+ import './shared-DbJl6i6a.mjs';
6
6
  import '@weapp-core/escape';
7
7
  import '@ast-core/escape';
8
8
  import 'postcss';
package/dist/replace.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { MappingChars2String, MappingChars2StringEntries, MappingStringDictionary, SYMBOL_TABLE, SYMBOL_TABLE_TYPE, SYMBOL_TABLE_TYPE_VALUES, SimpleMappingChars2String, SimpleMappingChars2StringEntries } from './escape';
1
+ export { MappingChars2String, MappingChars2StringEntries, MappingStringDictionary, SYMBOL_TABLE, SYMBOL_TABLE_TYPE, SYMBOL_TABLE_TYPE_VALUES, SimpleMappingChars2String, SimpleMappingChars2StringEntries, } from './escape';
2
2
  export { replaceWxml as replaceJs } from './wxml/shared';
3
3
  export { internalCssSelectorReplacer as replaceCss } from './postcss/shared';
package/dist/replace.js CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var escape = require('@weapp-core/escape');
6
6
  require('@ast-core/escape');
7
- var shared = require('./shared-BDew1Ric.js');
7
+ var shared = require('./shared-hzYeE1wX.js');
8
8
 
9
9
  function replaceWxml(original, options = {
10
10
  keepEOL: false,
11
- escapeMap: escape.SimpleMappingChars2String
11
+ escapeMap: escape.SimpleMappingChars2String,
12
12
  }) {
13
13
  const { keepEOL, escapeMap, mangleContext } = options;
14
14
  let res = original;
@@ -20,7 +20,7 @@ function replaceWxml(original, options = {
20
20
  res = mangleContext.wxmlHandler(res);
21
21
  }
22
22
  res = escape.escape(res, {
23
- map: escapeMap
23
+ map: escapeMap,
24
24
  });
25
25
  return res;
26
26
  }
package/dist/replace.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
2
2
  export { MappingChars2String, MappingChars2StringEntries, SYMBOL_TABLE, SimpleMappingChars2String, SimpleMappingChars2StringEntries } from '@weapp-core/escape';
3
3
  import '@ast-core/escape';
4
- export { i as replaceCss } from './shared-BX0VV-pr.mjs';
4
+ export { i as replaceCss } from './shared-DbJl6i6a.mjs';
5
5
 
6
6
  function replaceWxml(original, options = {
7
7
  keepEOL: false,
8
- escapeMap: SimpleMappingChars2String
8
+ escapeMap: SimpleMappingChars2String,
9
9
  }) {
10
10
  const { keepEOL, escapeMap, mangleContext } = options;
11
11
  let res = original;
@@ -17,7 +17,7 @@ function replaceWxml(original, options = {
17
17
  res = mangleContext.wxmlHandler(res);
18
18
  }
19
19
  res = escape(res, {
20
- map: escapeMap
20
+ map: escapeMap,
21
21
  });
22
22
  return res;
23
23
  }
@@ -2,14 +2,14 @@ import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
2
2
  import '@ast-core/escape';
3
3
 
4
4
  function internalCssSelectorReplacer(selectors, options = {
5
- escapeMap: SimpleMappingChars2String
5
+ escapeMap: SimpleMappingChars2String,
6
6
  }) {
7
7
  const { mangleContext, escapeMap } = options;
8
8
  if (mangleContext) {
9
9
  selectors = mangleContext.cssHandler(selectors);
10
10
  }
11
11
  return escape(selectors, {
12
- map: escapeMap
12
+ map: escapeMap,
13
13
  });
14
14
  }
15
15
  function composeIsPseudo(strs) {
@@ -4,14 +4,14 @@ var escape = require('@weapp-core/escape');
4
4
  require('@ast-core/escape');
5
5
 
6
6
  function internalCssSelectorReplacer(selectors, options = {
7
- escapeMap: escape.SimpleMappingChars2String
7
+ escapeMap: escape.SimpleMappingChars2String,
8
8
  }) {
9
9
  const { mangleContext, escapeMap } = options;
10
10
  if (mangleContext) {
11
11
  selectors = mangleContext.cssHandler(selectors);
12
12
  }
13
13
  return escape.escape(selectors, {
14
- map: escapeMap
14
+ map: escapeMap,
15
15
  });
16
16
  }
17
17
  function composeIsPseudo(strs) {
@@ -1,8 +1,9 @@
1
1
  import { TailwindcssPatcher } from 'tailwindcss-patch';
2
2
  import type { ILengthUnitsPatchOptions, InternalPatchResult } from "../types";
3
+ import { noop } from "../utils";
3
4
  export declare function getInstalledPkgJsonPath(options: ILengthUnitsPatchOptions): string | undefined;
4
- export declare function createPatch(options: false | ILengthUnitsPatchOptions): () => void;
5
+ export declare function createPatch(options: false | ILengthUnitsPatchOptions): typeof noop;
5
6
  export declare function monkeyPatchForSupportingCustomUnit(rootDir: string, options: ILengthUnitsPatchOptions): string | undefined;
6
- export declare function internalPatch(pkgJsonPath: string | undefined, options: ILengthUnitsPatchOptions, overwrite?: boolean): InternalPatchResult | undefined;
7
+ export declare function internalPatch(pkgJsonPath: string | undefined, options: ILengthUnitsPatchOptions): InternalPatchResult | undefined;
7
8
  export declare function mkCacheDirectory(cwd?: string): string;
8
- export declare function createTailwindcssPatcher(): TailwindcssPatcher;
9
+ export declare function createTailwindcssPatcher(basedir?: string): TailwindcssPatcher;