weapp-tailwindcss 3.5.0 → 3.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +16 -11
  2. package/bin/weapp-tailwindcss.js +3 -2
  3. package/dist/cache/index.d.ts +1 -1
  4. package/dist/cli.js +16 -16
  5. package/dist/cli.mjs +16 -16
  6. package/dist/core.js +12 -12
  7. package/dist/core.mjs +12 -12
  8. package/dist/css-macro/index.js +1 -1
  9. package/dist/css-macro/index.mjs +1 -1
  10. package/dist/defaults.js +2 -2
  11. package/dist/defaults.mjs +2 -2
  12. package/dist/escape.d.ts +1 -1
  13. package/dist/gulp.js +14 -14
  14. package/dist/gulp.mjs +14 -14
  15. package/dist/{index-CCbEWRGc.js → index-B2LUAr--.js} +126 -126
  16. package/dist/{index-rwuSO4cM.mjs → index-CMRC3rPR.mjs} +2 -2
  17. package/dist/{index-Ddev8wez.js → index-D_Im3H17.js} +3 -3
  18. package/dist/{index-ClzClhjc.mjs → index-DnKMgPUl.mjs} +3 -3
  19. package/dist/{index-B8Pxc74h.js → index-DzdjmBcg.js} +2 -2
  20. package/dist/{index-szMvMylQ.mjs → index-zFq7tKDr.mjs} +126 -126
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +20 -20
  23. package/dist/index.mjs +18 -18
  24. package/dist/{options-BT2K7ro6.mjs → options-B9PPOdJv.mjs} +140 -171
  25. package/dist/{options-BjD225Hm.js → options-DgkOONy_.js} +142 -173
  26. package/dist/postcss.js +4 -4
  27. package/dist/postcss.mjs +4 -4
  28. package/dist/replace.d.ts +2 -2
  29. package/dist/replace.js +2 -2
  30. package/dist/replace.mjs +2 -2
  31. package/dist/tailwindcss/patcher.d.ts +1 -1
  32. package/dist/types.d.ts +6 -6
  33. package/dist/{v5-_VYyLdJC.js → v5-CqteGjOW.js} +5 -5
  34. package/dist/{v5-vdra_05U.mjs → v5-c6m3PupX.mjs} +4 -4
  35. package/dist/vite.js +13 -13
  36. package/dist/vite.mjs +13 -13
  37. package/dist/webpack.js +13 -13
  38. package/dist/webpack.mjs +13 -13
  39. package/dist/webpack4.js +13 -13
  40. package/dist/webpack4.mjs +12 -12
  41. package/dist/wxml/index.d.ts +1 -1
  42. package/dist/wxml/utils.d.ts +2 -5
  43. package/package.json +13 -12
  44. package/dist/{defaults-DW-EahCC.js → defaults-Bo5n6a1r.js} +2 -2
  45. package/dist/{defaults-w3rlKQwe.mjs → defaults-CWrYZAlE.mjs} +2 -2
  46. package/dist/{shared-DbJl6i6a.mjs → shared-COWjpokr.mjs} +1 -1
  47. package/dist/{shared-hzYeE1wX.js → shared-r_GpWheO.js} +1 -1
package/dist/index.js CHANGED
@@ -2,42 +2,42 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var v5 = require('./v5-_VYyLdJC.js');
6
- var index = require('./index-Ddev8wez.js');
7
- var index$1 = require('./index-B8Pxc74h.js');
8
- require('./options-BjD225Hm.js');
5
+ var index = require('./index-DzdjmBcg.js');
6
+ var index$1 = require('./index-D_Im3H17.js');
7
+ var v5 = require('./v5-CqteGjOW.js');
8
+ require('./options-DgkOONy_.js');
9
+ require('lru-cache');
10
+ require('md5');
11
+ require('./defaults-Bo5n6a1r.js');
12
+ require('@ast-core/escape');
13
+ require('@weapp-core/escape');
14
+ require('./defu-Cdz2PomB.js');
9
15
  require('magic-string');
10
16
  require('@babel/generator');
11
17
  require('@babel/traverse');
12
18
  require('@babel/parser');
13
- require('@weapp-core/escape');
14
- require('@ast-core/escape');
15
- require('./defaults-DW-EahCC.js');
16
- require('./defu-Cdz2PomB.js');
17
- require('./replace.js');
18
- require('./shared-hzYeE1wX.js');
19
19
  require('@weapp-core/regex');
20
+ require('./replace.js');
21
+ require('./shared-r_GpWheO.js');
20
22
  require('@tailwindcss-mangle/shared');
21
- require('lru-cache');
22
- require('md5');
23
23
  require('postcss');
24
- require('./index-CCbEWRGc.js');
24
+ require('./index-B2LUAr--.js');
25
25
  require('@csstools/postcss-is-pseudo-class');
26
26
  require('postcss-rem-to-responsive-pixel');
27
27
  require('postcss-selector-parser');
28
- require('@babel/types');
29
- require('htmlparser2');
30
28
  require('node:path');
31
29
  require('node:process');
32
30
  require('tailwindcss-patch');
33
- require('node:fs');
31
+ require('@babel/types');
32
+ require('htmlparser2');
33
+ require('node:buffer');
34
+ require('node:stream');
34
35
  require('./index-HC-Qkn0i.js');
35
36
  require('debug');
36
- require('node:stream');
37
- require('node:buffer');
37
+ require('node:fs');
38
38
 
39
39
 
40
40
 
41
+ exports.createPlugins = index.createPlugins;
42
+ exports.UnifiedViteWeappTailwindcssPlugin = index$1.UnifiedViteWeappTailwindcssPlugin;
41
43
  exports.UnifiedWebpackPluginV5 = v5.UnifiedWebpackPluginV5;
42
- exports.UnifiedViteWeappTailwindcssPlugin = index.UnifiedViteWeappTailwindcssPlugin;
43
- exports.createPlugins = index$1.createPlugins;
package/dist/index.mjs CHANGED
@@ -1,33 +1,33 @@
1
- export { U as UnifiedWebpackPluginV5 } from './v5-vdra_05U.mjs';
2
- export { U as UnifiedViteWeappTailwindcssPlugin } from './index-ClzClhjc.mjs';
3
- export { c as createPlugins } from './index-rwuSO4cM.mjs';
4
- import './options-BT2K7ro6.mjs';
1
+ export { c as createPlugins } from './index-CMRC3rPR.mjs';
2
+ export { U as UnifiedViteWeappTailwindcssPlugin } from './index-DnKMgPUl.mjs';
3
+ export { U as UnifiedWebpackPluginV5 } from './v5-c6m3PupX.mjs';
4
+ import './options-B9PPOdJv.mjs';
5
+ import 'lru-cache';
6
+ import 'md5';
7
+ import './defaults-CWrYZAlE.mjs';
8
+ import '@ast-core/escape';
9
+ import '@weapp-core/escape';
10
+ import './defu-n46TJT6t.mjs';
5
11
  import 'magic-string';
6
12
  import '@babel/generator';
7
13
  import '@babel/traverse';
8
14
  import '@babel/parser';
9
- import '@weapp-core/escape';
10
- import '@ast-core/escape';
11
- import './defaults-w3rlKQwe.mjs';
12
- import './defu-n46TJT6t.mjs';
13
- import './replace.mjs';
14
- import './shared-DbJl6i6a.mjs';
15
15
  import '@weapp-core/regex';
16
+ import './replace.mjs';
17
+ import './shared-COWjpokr.mjs';
16
18
  import '@tailwindcss-mangle/shared';
17
- import 'lru-cache';
18
- import 'md5';
19
19
  import 'postcss';
20
- import './index-szMvMylQ.mjs';
20
+ import './index-zFq7tKDr.mjs';
21
21
  import '@csstools/postcss-is-pseudo-class';
22
22
  import 'postcss-rem-to-responsive-pixel';
23
23
  import 'postcss-selector-parser';
24
- import '@babel/types';
25
- import 'htmlparser2';
26
24
  import 'node:path';
27
25
  import 'node:process';
28
26
  import 'tailwindcss-patch';
29
- import 'node:fs';
27
+ import '@babel/types';
28
+ import 'htmlparser2';
29
+ import 'node:buffer';
30
+ import 'node:stream';
30
31
  import './index-BEIjgKpF.mjs';
31
32
  import 'debug';
32
- import 'node:stream';
33
- import 'node:buffer';
33
+ import 'node:fs';
@@ -1,22 +1,22 @@
1
+ import { LRUCache } from 'lru-cache';
2
+ import md5 from 'md5';
3
+ import { d as defuOverrideArray, a as defaultOptions, i as isMap } from './defaults-CWrYZAlE.mjs';
1
4
  import MagicString from 'magic-string';
2
5
  import _babelGenerate from '@babel/generator';
3
6
  import _babelTraverse from '@babel/traverse';
4
7
  import { parse, parseExpression } from '@babel/parser';
5
- import '@weapp-core/escape';
6
8
  import { jsStringEscape } from '@ast-core/escape';
7
- import { d as defuOverrideArray, a as defaultOptions, i as isMap } from './defaults-w3rlKQwe.mjs';
9
+ import '@weapp-core/escape';
10
+ import { escapeStringRegexp } from '@weapp-core/regex';
8
11
  import { replaceJs as replaceWxml } from './replace.mjs';
9
- import { escapeStringRegexp, variableRegExp } from '@weapp-core/regex';
10
12
  import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
11
- import { LRUCache } from 'lru-cache';
12
- import md5 from 'md5';
13
13
  import postcss from 'postcss';
14
- import { g as getPlugins } from './index-szMvMylQ.mjs';
15
- import * as t from '@babel/types';
16
- import { Parser } from 'htmlparser2';
14
+ import { g as getPlugins } from './index-zFq7tKDr.mjs';
17
15
  import path from 'node:path';
18
16
  import process from 'node:process';
19
17
  import { TailwindcssPatcher } from 'tailwindcss-patch';
18
+ import * as t from '@babel/types';
19
+ import { Parser } from 'htmlparser2';
20
20
 
21
21
  /******************************************************************************
22
22
  Copyright (c) Microsoft Corporation.
@@ -32,7 +32,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
32
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33
33
  PERFORMANCE OF THIS SOFTWARE.
34
34
  ***************************************************************************** */
35
- /* global Reflect, Promise, SuppressedError, Symbol */
35
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
36
36
 
37
37
 
38
38
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -50,11 +50,79 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
50
50
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
51
  };
52
52
 
53
- function _interopDefaultCompat(e) {
54
- return e && typeof e === 'object' && 'default' in e ? e.default : e;
53
+ function createCache(options) {
54
+ const disabled = options === false;
55
+ const hashMap = new Map();
56
+ const instance = new LRUCache({
57
+ max: 1024,
58
+ ttl: 0,
59
+ ttlAutopurge: false,
60
+ });
61
+ return {
62
+ hashMap,
63
+ instance,
64
+ hasHashKey(key) {
65
+ return hashMap.has(key);
66
+ },
67
+ getHashValue(key) {
68
+ return hashMap.get(key);
69
+ },
70
+ setHashValue(key, value) {
71
+ return hashMap.set(key, value);
72
+ },
73
+ get(key) {
74
+ return instance.get(key);
75
+ },
76
+ set(key, value) {
77
+ return instance.set(key, value);
78
+ },
79
+ computeHash(message) {
80
+ return md5(message);
81
+ },
82
+ calcHashValueChanged(key, hash) {
83
+ const hit = this.getHashValue(key);
84
+ if (hit) {
85
+ this.setHashValue(key, {
86
+ changed: hash !== hit.hash,
87
+ hash,
88
+ });
89
+ }
90
+ else {
91
+ this.setHashValue(key, {
92
+ changed: true,
93
+ hash,
94
+ });
95
+ }
96
+ return this;
97
+ },
98
+ has(key) {
99
+ return instance.has(key);
100
+ },
101
+ process(key, callback, fallback) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ if (disabled) {
104
+ const res = yield fallback();
105
+ if (res) {
106
+ this.set(res.key, res.source);
107
+ }
108
+ }
109
+ else {
110
+ const hit = this.getHashValue(key);
111
+ if (hit && !hit.changed) {
112
+ const returnFlag = yield callback();
113
+ if (returnFlag !== false) {
114
+ return;
115
+ }
116
+ }
117
+ const res = yield fallback();
118
+ if (res) {
119
+ this.set(res.key, res.source);
120
+ }
121
+ }
122
+ });
123
+ },
124
+ };
55
125
  }
56
- _interopDefaultCompat(_babelGenerate);
57
- const traverse = _interopDefaultCompat(_babelTraverse);
58
126
 
59
127
  function decodeUnicode2(input) {
60
128
  try {
@@ -65,6 +133,12 @@ function decodeUnicode2(input) {
65
133
  }
66
134
  }
67
135
 
136
+ function _interopDefaultCompat(e) {
137
+ return e && typeof e === 'object' && 'default' in e ? e.default : e;
138
+ }
139
+ _interopDefaultCompat(_babelGenerate);
140
+ const traverse = _interopDefaultCompat(_babelTraverse);
141
+
68
142
  const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
69
143
  function isValidSelector(selector = '') {
70
144
  return validateFilterRE.test(selector);
@@ -359,80 +433,6 @@ function useMangleStore() {
359
433
  };
360
434
  }
361
435
 
362
- function createCache(options) {
363
- const disabled = options === false;
364
- const hashMap = new Map();
365
- const instance = new LRUCache({
366
- max: 1024,
367
- ttl: 0,
368
- ttlAutopurge: false,
369
- });
370
- return {
371
- hashMap,
372
- instance,
373
- hasHashKey(key) {
374
- return hashMap.has(key);
375
- },
376
- getHashValue(key) {
377
- return hashMap.get(key);
378
- },
379
- setHashValue(key, value) {
380
- return hashMap.set(key, value);
381
- },
382
- get(key) {
383
- return instance.get(key);
384
- },
385
- set(key, value) {
386
- return instance.set(key, value);
387
- },
388
- computeHash(message) {
389
- return md5(message);
390
- },
391
- calcHashValueChanged(key, hash) {
392
- const hit = this.getHashValue(key);
393
- if (hit) {
394
- this.setHashValue(key, {
395
- changed: hash !== hit.hash,
396
- hash,
397
- });
398
- }
399
- else {
400
- this.setHashValue(key, {
401
- changed: true,
402
- hash,
403
- });
404
- }
405
- return this;
406
- },
407
- has(key) {
408
- return instance.has(key);
409
- },
410
- process(key, callback, fallback) {
411
- return __awaiter(this, void 0, void 0, function* () {
412
- if (disabled) {
413
- const res = yield fallback();
414
- if (res) {
415
- this.set(res.key, res.source);
416
- }
417
- }
418
- else {
419
- const hit = this.getHashValue(key);
420
- if (hit && !hit.changed) {
421
- const returnFlag = yield callback();
422
- if (returnFlag !== false) {
423
- return;
424
- }
425
- }
426
- const res = yield fallback();
427
- if (res) {
428
- this.set(res.key, res.source);
429
- }
430
- }
431
- });
432
- },
433
- };
434
- }
435
-
436
436
  function styleHandler(rawSource, options) {
437
437
  var _a, _b;
438
438
  return postcss(getPlugins(options))
@@ -465,6 +465,31 @@ function createInjectPreflight(options) {
465
465
  };
466
466
  }
467
467
 
468
+ function createTailwindcssPatcher(basedir, cacheDir, supportCustomLengthUnitsPatch) {
469
+ const cache = {};
470
+ if (cacheDir) {
471
+ if (path.isAbsolute(cacheDir)) {
472
+ cache.dir = cacheDir;
473
+ }
474
+ else if (basedir) {
475
+ cache.dir = path.resolve(basedir, cacheDir);
476
+ }
477
+ else {
478
+ cache.dir = path.resolve(process.cwd(), cacheDir);
479
+ }
480
+ }
481
+ return new TailwindcssPatcher({
482
+ cache,
483
+ patch: {
484
+ basedir,
485
+ applyPatches: {
486
+ exportContext: true,
487
+ extendLengthUnits: supportCustomLengthUnitsPatch,
488
+ },
489
+ },
490
+ });
491
+ }
492
+
468
493
  var State;
469
494
  (function (State) {
470
495
  State[State["START"] = 0] = "START";
@@ -630,78 +655,47 @@ function generateCode(match, options = {}) {
630
655
  return match;
631
656
  }
632
657
  }
633
- function extract(original, reg) {
634
- let match = reg.exec(original);
635
- const sources = [];
636
- while (match !== null) {
637
- const start = match.index;
638
- const end = reg.lastIndex;
639
- sources.push({
640
- start,
641
- end,
642
- raw: match[1],
643
- });
644
- match = reg.exec(original);
645
- }
646
- return sources;
647
- }
648
- function extractSource(original) {
649
- return extract(original, variableRegExp);
650
- }
651
- function handleEachClassFragment(original, options = {}) {
652
- const sources = extractSource(original);
653
- if (sources.length > 0) {
654
- const resultArray = [];
655
- let p = 0;
656
- for (let i = 0; i < sources.length; i++) {
657
- const m = sources[i];
658
- const before = original.slice(p, m.start);
659
- resultArray.push(replaceWxml(before, {
660
- keepEOL: true,
661
- escapeMap: options.escapeMap,
662
- mangleContext: options.mangleContext,
663
- ignoreHead: p > 0,
664
- }));
665
- p = m.start;
666
- if (m.raw.trim().length > 0) {
667
- const code = generateCode(m.raw, options);
668
- const source = `{{${code}}}`;
669
- m.source = source;
670
- }
671
- else {
672
- m.source = '';
658
+ function handleEachClassFragment(ms, tokens, options = {}) {
659
+ for (const token of tokens) {
660
+ let p = token.start;
661
+ if (token.expressions.length > 0) {
662
+ for (const exp of token.expressions) {
663
+ if (exp.start > token.start && p < exp.start) {
664
+ ms.update(p, exp.start, replaceWxml(ms.slice(p, exp.start), {
665
+ keepEOL: true,
666
+ escapeMap: options.escapeMap,
667
+ mangleContext: options.mangleContext,
668
+ ignoreHead: p > 0,
669
+ }));
670
+ }
671
+ const code = `{{${generateCode(exp.value.slice(2, -2), options)}}}`;
672
+ ms.update(exp.start, exp.end, code);
673
+ p = exp.end;
673
674
  }
674
- resultArray.push(m.source);
675
- p = m.end;
676
- if (i === sources.length - 1) {
677
- const after = original.slice(m.end);
678
- resultArray.push(replaceWxml(after, {
679
- keepEOL: true,
675
+ if (token.end > p) {
676
+ ms.update(p, token.end, replaceWxml(ms.slice(p, token.end), {
677
+ keepEOL: false,
680
678
  escapeMap: options.escapeMap,
681
679
  mangleContext: options.mangleContext,
682
680
  ignoreHead: true,
683
681
  }));
684
682
  }
685
683
  }
686
- return resultArray.filter(Boolean).join('').trim();
687
- }
688
- else {
689
- return replaceWxml(original, {
690
- keepEOL: false,
691
- escapeMap: options.escapeMap,
692
- mangleContext: options.mangleContext,
693
- ignoreHead: false,
694
- });
684
+ else {
685
+ ms.update(token.start, token.end, replaceWxml(token.value, {
686
+ keepEOL: false,
687
+ escapeMap: options.escapeMap,
688
+ mangleContext: options.mangleContext,
689
+ ignoreHead: false,
690
+ }));
691
+ }
695
692
  }
696
693
  }
697
694
  function templateReplacer(original, options = {}) {
698
695
  const ms = new MagicString(original);
699
696
  const tokenizer = new Tokenizer();
700
697
  const tokens = tokenizer.run(ms.original);
701
- for (const token of tokens) {
702
- const target = handleEachClassFragment(token.value, options);
703
- ms.update(token.start, token.end, target);
704
- }
698
+ handleEachClassFragment(ms, tokens, options);
705
699
  return ms.toString();
706
700
  }
707
701
  function regTest(reg, str) {
@@ -791,31 +785,6 @@ function createTemplateHandler(options = {}) {
791
785
  };
792
786
  }
793
787
 
794
- function createTailwindcssPatcher(basedir, cacheDir, supportCustomLengthUnitsPatch) {
795
- const cache = {};
796
- if (cacheDir) {
797
- if (path.isAbsolute(cacheDir)) {
798
- cache.dir = cacheDir;
799
- }
800
- else if (basedir) {
801
- cache.dir = path.resolve(basedir, cacheDir);
802
- }
803
- else {
804
- cache.dir = path.resolve(process.cwd(), cacheDir);
805
- }
806
- }
807
- return new TailwindcssPatcher({
808
- cache,
809
- patch: {
810
- basedir,
811
- applyPatches: {
812
- exportContext: true,
813
- extendLengthUnits: supportCustomLengthUnitsPatch,
814
- },
815
- },
816
- });
817
- }
818
-
819
788
  function getOptions(opts) {
820
789
  const result = defuOverrideArray(opts, defaultOptions, {});
821
790
  result.escapeMap = result.customReplaceDictionary;