weapp-tailwindcss 2.4.0 → 2.4.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.
@@ -0,0 +1,148 @@
1
+ 'use strict';
2
+
3
+ const SYMBOL_TABLE = {
4
+ BACKQUOTE: '`',
5
+ TILDE: '~',
6
+ EXCLAM: '!',
7
+ AT: '@',
8
+ NUMBERSIGN: '#',
9
+ DOLLAR: '$',
10
+ PERCENT: '%',
11
+ CARET: '^',
12
+ AMPERSAND: '&',
13
+ ASTERISK: '*',
14
+ PARENLEFT: '(',
15
+ PARENRIGHT: ')',
16
+ MINUS: '-',
17
+ UNDERSCORE: '_',
18
+ EQUAL: '=',
19
+ PLUS: '+',
20
+ BRACKETLEFT: '[',
21
+ BRACELEFT: '{',
22
+ BRACKETRIGHT: ']',
23
+ BRACERIGHT: '}',
24
+ SEMICOLON: ';',
25
+ COLON: ':',
26
+ QUOTE: "'",
27
+ DOUBLEQUOTE: '"',
28
+ BACKSLASH: '\\',
29
+ BAR: '|',
30
+ COMMA: ',',
31
+ LESS: '<',
32
+ PERIOD: '.',
33
+ GREATER: '>',
34
+ SLASH: '/',
35
+ QUESTION: '?',
36
+ SPACE: ' ',
37
+ DOT: '.',
38
+ HASH: '#'
39
+ };
40
+ const MappingChars2String = {
41
+ '[': '_bl_',
42
+ ']': '_br_',
43
+ '(': '_pl_',
44
+ ')': '_qr_',
45
+ '#': '_h_',
46
+ '!': '_i_',
47
+ '/': '_s_',
48
+ '\\': '_bs_',
49
+ '.': '_d_',
50
+ ':': '_c_',
51
+ '%': '_p_',
52
+ ',': '_co_',
53
+ "'": '_q_',
54
+ '"': '_dq_',
55
+ '*': '_a_',
56
+ '&': '_am_',
57
+ '@': '_at_',
58
+ '{': '_bal_',
59
+ '}': '_bar_',
60
+ '+': '_plus_',
61
+ ';': '_se_',
62
+ '<': '_l_',
63
+ '~': '_t_',
64
+ '=': '_e_',
65
+ '>': '_g_',
66
+ '?': '_qu_',
67
+ '^': '_ca_',
68
+ '`': '_bq_',
69
+ '|': '_b_',
70
+ $: '_do_'
71
+ };
72
+ const MappingChars2StringEntries = Object.entries(MappingChars2String);
73
+ const SimpleMappingChars2String = {
74
+ '[': '_',
75
+ ']': '_',
76
+ '(': '_',
77
+ ')': '_',
78
+ '{': '_',
79
+ '}': '_',
80
+ '+': 'a',
81
+ ',': 'b',
82
+ ':': 'c',
83
+ '.': 'd',
84
+ '=': 'e',
85
+ ';': 'f',
86
+ '>': 'g',
87
+ '#': 'h',
88
+ '!': 'i',
89
+ '@': 'j',
90
+ '^': 'k',
91
+ '<': 'l',
92
+ '*': 'm',
93
+ '&': 'n',
94
+ '?': 'o',
95
+ '%': 'p',
96
+ "'": 'q',
97
+ $: 'r',
98
+ '/': 's',
99
+ '~': 't',
100
+ '|': 'u',
101
+ '`': 'v',
102
+ '\\': 'w',
103
+ '"': 'x'
104
+ };
105
+ const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
106
+
107
+ const MAX_ASCII_CHAR_CODE = 127;
108
+ function escape(selectors, options = {
109
+ map: SimpleMappingChars2String
110
+ }) {
111
+ const { map = SimpleMappingChars2String } = options;
112
+ const sb = [...selectors];
113
+ for (let i = 0; i < sb.length; i++) {
114
+ const char = sb[i];
115
+ const code = char.codePointAt(0);
116
+ if (code !== undefined && code > MAX_ASCII_CHAR_CODE) {
117
+ sb[i] = 'u' + Number(code).toString(16);
118
+ }
119
+ else {
120
+ const hit = map[char];
121
+ if (hit) {
122
+ sb[i] = hit;
123
+ }
124
+ }
125
+ }
126
+ const res = sb.join('');
127
+ return res;
128
+ }
129
+
130
+ function internalCssSelectorReplacer(selectors, options = {
131
+ escapeMap: SimpleMappingChars2String,
132
+ }) {
133
+ const { mangleContext, escapeMap } = options;
134
+ if (mangleContext) {
135
+ selectors = mangleContext.cssHandler(selectors);
136
+ }
137
+ return escape(selectors, {
138
+ map: escapeMap
139
+ });
140
+ }
141
+
142
+ exports.MappingChars2String = MappingChars2String;
143
+ exports.MappingChars2StringEntries = MappingChars2StringEntries;
144
+ exports.SYMBOL_TABLE = SYMBOL_TABLE;
145
+ exports.SimpleMappingChars2String = SimpleMappingChars2String;
146
+ exports.SimpleMappingChars2StringEntries = SimpleMappingChars2StringEntries;
147
+ exports.escape = escape;
148
+ exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
@@ -0,0 +1,140 @@
1
+ const SYMBOL_TABLE = {
2
+ BACKQUOTE: '`',
3
+ TILDE: '~',
4
+ EXCLAM: '!',
5
+ AT: '@',
6
+ NUMBERSIGN: '#',
7
+ DOLLAR: '$',
8
+ PERCENT: '%',
9
+ CARET: '^',
10
+ AMPERSAND: '&',
11
+ ASTERISK: '*',
12
+ PARENLEFT: '(',
13
+ PARENRIGHT: ')',
14
+ MINUS: '-',
15
+ UNDERSCORE: '_',
16
+ EQUAL: '=',
17
+ PLUS: '+',
18
+ BRACKETLEFT: '[',
19
+ BRACELEFT: '{',
20
+ BRACKETRIGHT: ']',
21
+ BRACERIGHT: '}',
22
+ SEMICOLON: ';',
23
+ COLON: ':',
24
+ QUOTE: "'",
25
+ DOUBLEQUOTE: '"',
26
+ BACKSLASH: '\\',
27
+ BAR: '|',
28
+ COMMA: ',',
29
+ LESS: '<',
30
+ PERIOD: '.',
31
+ GREATER: '>',
32
+ SLASH: '/',
33
+ QUESTION: '?',
34
+ SPACE: ' ',
35
+ DOT: '.',
36
+ HASH: '#'
37
+ };
38
+ const MappingChars2String = {
39
+ '[': '_bl_',
40
+ ']': '_br_',
41
+ '(': '_pl_',
42
+ ')': '_qr_',
43
+ '#': '_h_',
44
+ '!': '_i_',
45
+ '/': '_s_',
46
+ '\\': '_bs_',
47
+ '.': '_d_',
48
+ ':': '_c_',
49
+ '%': '_p_',
50
+ ',': '_co_',
51
+ "'": '_q_',
52
+ '"': '_dq_',
53
+ '*': '_a_',
54
+ '&': '_am_',
55
+ '@': '_at_',
56
+ '{': '_bal_',
57
+ '}': '_bar_',
58
+ '+': '_plus_',
59
+ ';': '_se_',
60
+ '<': '_l_',
61
+ '~': '_t_',
62
+ '=': '_e_',
63
+ '>': '_g_',
64
+ '?': '_qu_',
65
+ '^': '_ca_',
66
+ '`': '_bq_',
67
+ '|': '_b_',
68
+ $: '_do_'
69
+ };
70
+ const MappingChars2StringEntries = Object.entries(MappingChars2String);
71
+ const SimpleMappingChars2String = {
72
+ '[': '_',
73
+ ']': '_',
74
+ '(': '_',
75
+ ')': '_',
76
+ '{': '_',
77
+ '}': '_',
78
+ '+': 'a',
79
+ ',': 'b',
80
+ ':': 'c',
81
+ '.': 'd',
82
+ '=': 'e',
83
+ ';': 'f',
84
+ '>': 'g',
85
+ '#': 'h',
86
+ '!': 'i',
87
+ '@': 'j',
88
+ '^': 'k',
89
+ '<': 'l',
90
+ '*': 'm',
91
+ '&': 'n',
92
+ '?': 'o',
93
+ '%': 'p',
94
+ "'": 'q',
95
+ $: 'r',
96
+ '/': 's',
97
+ '~': 't',
98
+ '|': 'u',
99
+ '`': 'v',
100
+ '\\': 'w',
101
+ '"': 'x'
102
+ };
103
+ const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
104
+
105
+ const MAX_ASCII_CHAR_CODE = 127;
106
+ function escape(selectors, options = {
107
+ map: SimpleMappingChars2String
108
+ }) {
109
+ const { map = SimpleMappingChars2String } = options;
110
+ const sb = [...selectors];
111
+ for (let i = 0; i < sb.length; i++) {
112
+ const char = sb[i];
113
+ const code = char.codePointAt(0);
114
+ if (code !== undefined && code > MAX_ASCII_CHAR_CODE) {
115
+ sb[i] = 'u' + Number(code).toString(16);
116
+ }
117
+ else {
118
+ const hit = map[char];
119
+ if (hit) {
120
+ sb[i] = hit;
121
+ }
122
+ }
123
+ }
124
+ const res = sb.join('');
125
+ return res;
126
+ }
127
+
128
+ function internalCssSelectorReplacer(selectors, options = {
129
+ escapeMap: SimpleMappingChars2String,
130
+ }) {
131
+ const { mangleContext, escapeMap } = options;
132
+ if (mangleContext) {
133
+ selectors = mangleContext.cssHandler(selectors);
134
+ }
135
+ return escape(selectors, {
136
+ map: escapeMap
137
+ });
138
+ }
139
+
140
+ export { MappingChars2String as M, SimpleMappingChars2String as S, SYMBOL_TABLE as a, MappingChars2StringEntries as b, SimpleMappingChars2StringEntries as c, escape as e, internalCssSelectorReplacer as i };
package/dist/types.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import type { Rule } from 'postcss';
2
- import type { IClassGeneratorOptions } from 'tailwindcss-mangle-shared';
2
+ import type { IClassGeneratorOptions, ClassGenerator } from 'tailwindcss-mangle-shared';
3
3
  import type { GeneratorResult } from '@babel/generator';
4
4
  import type { InjectPreflight } from './postcss/preflight';
5
5
  export type ItemOrItemArray<T> = T | T[];
6
- export type { TraverseOptions } from '@babel/traverse';
7
- export type { Node } from '@babel/types';
8
6
  export type AppType = 'uni-app' | 'uni-app-vite' | 'taro' | 'remax' | 'rax' | 'native' | 'kbone' | 'mpx';
9
7
  export interface IPropValue {
10
8
  prop: string;
@@ -14,7 +12,7 @@ export type CssPresetProps = string;
14
12
  export type CssPreflightOptions = {
15
13
  [key: CssPresetProps]: string | number | boolean;
16
14
  } | false;
17
- type RequiredStyleHandlerOptions = {
15
+ export type RequiredStyleHandlerOptions = {
18
16
  isMainChunk: boolean;
19
17
  cssInjectPreflight?: InjectPreflight;
20
18
  cssPreflightRange?: 'view' | 'all';
@@ -22,8 +20,13 @@ type RequiredStyleHandlerOptions = {
22
20
  escapeMap?: Record<string, string>;
23
21
  };
24
22
  export type CustomRuleCallback = (node: Rule, options: Readonly<RequiredStyleHandlerOptions>) => void;
23
+ export interface InternalCssSelectorReplacerOptions {
24
+ mangleContext?: IMangleScopeContext;
25
+ escapeMap?: Record<string, string>;
26
+ }
25
27
  export type IStyleHandlerOptions = {
26
28
  customRuleCallback?: CustomRuleCallback;
29
+ mangleContext?: IMangleScopeContext;
27
30
  } & RequiredStyleHandlerOptions;
28
31
  export type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>> | Map<string | RegExp, ItemOrItemArray<string | RegExp>>;
29
32
  export type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
@@ -31,6 +34,8 @@ export type IJsHandlerOptions = {
31
34
  escapeMap?: Record<string, string>;
32
35
  classNameSet: Set<string>;
33
36
  minifiedJs?: boolean;
37
+ arbitraryValues?: IArbitraryValues;
38
+ mangleContext?: IMangleScopeContext;
34
39
  };
35
40
  export interface RawSource {
36
41
  start: number;
@@ -58,6 +63,9 @@ export interface IMangleOptions {
58
63
  classGenerator?: IClassGeneratorOptions;
59
64
  mangleClassFilter?: (className: string) => boolean;
60
65
  }
66
+ export interface IArbitraryValues {
67
+ allowDoubleQuotes?: boolean;
68
+ }
61
69
  export interface UserDefinedOptions {
62
70
  htmlMatcher?: ((name: string) => boolean) | string | string[];
63
71
  cssMatcher?: ((name: string) => boolean) | string | string[];
@@ -78,6 +86,16 @@ export interface UserDefinedOptions {
78
86
  appType?: AppType;
79
87
  minifiedJs?: boolean;
80
88
  mangle?: boolean | IMangleOptions;
89
+ arbitraryValues?: IArbitraryValues;
90
+ }
91
+ export interface IMangleScopeContext {
92
+ rawOptions: UserDefinedOptions['mangle'];
93
+ runtimeSet: Set<string>;
94
+ classGenerator: ClassGenerator;
95
+ filter: (className: string) => boolean;
96
+ cssHandler: (rawSource: string) => string;
97
+ jsHandler: (rawSource: string) => string;
98
+ wxmlHandler: (rawSource: string) => string;
81
99
  }
82
100
  export interface ICommonReplaceOptions {
83
101
  keepEOL?: boolean;
@@ -92,6 +110,7 @@ export type ICustomRegexp = {
92
110
  export interface ITempleteHandlerOptions extends ICommonReplaceOptions {
93
111
  customAttributesEntities?: ICustomAttributesEntities;
94
112
  escapeMap?: Record<string, string>;
113
+ mangleContext?: IMangleScopeContext;
95
114
  }
96
115
  export type GlobOrFunctionMatchers = 'htmlMatcher' | 'cssMatcher' | 'jsMatcher' | 'mainCssChunkMatcher';
97
116
  export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobOrFunctionMatchers | 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary'> & {
@@ -104,6 +123,7 @@ export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobO
104
123
  escapeMap: Record<string, string>;
105
124
  patch: () => void;
106
125
  customReplaceDictionary: Record<string, string>;
126
+ setMangleRuntimeSet: (runtimeSet: Set<string>) => void;
107
127
  }>;
108
128
  export type InternalPostcssOptions = Pick<UserDefinedOptions, 'cssMatcher' | 'mainCssChunkMatcher' | 'cssPreflight' | 'replaceUniversalSelectorWith' | 'cssPreflightRange' | 'customRuleCallback' | 'disabled'>;
109
129
  export interface IBaseWebpackPlugin {
package/dist/utils.d.ts CHANGED
@@ -3,5 +3,6 @@ export declare function isRegexp(value: unknown): boolean;
3
3
  export declare function isMap(value: unknown): boolean;
4
4
  export declare function regExpTest(arr: (string | RegExp)[] | undefined, str: string): boolean;
5
5
  export declare const noop: () => void;
6
+ export declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
6
7
  export declare function getGroupedEntries<T>(entries: [string, T][], options: InternalUserDefinedOptions): Record<"css" | "html" | "js" | "other", [string, T][]>;
7
8
  export { default as defu } from 'defu';
package/dist/vite.js CHANGED
@@ -2,35 +2,34 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-450d76c2.js');
6
- var postcss = require('./postcss-0c103b15.js');
7
- var shared = require('./shared-9744fdd1.js');
5
+ var options = require('./options-3a20e9d4.js');
6
+ var postcss = require('./postcss-e0e5739b.js');
8
7
  require('micromatch');
9
8
  require('@babel/types');
10
9
  require('@babel/generator');
11
10
  require('@babel/parser');
12
11
  require('@babel/traverse');
13
12
  require('./replace.js');
14
- require('tailwindcss-mangle-shared');
13
+ require('./shared-28d43730.js');
15
14
  require('postcss');
16
15
  require('@csstools/postcss-is-pseudo-class');
17
16
  require('node:path');
18
17
  require('node:fs');
19
18
  require('semver');
20
19
  require('tailwindcss-patch');
20
+ require('tailwindcss-mangle-shared');
21
21
  require('postcss-selector-parser');
22
22
 
23
23
  function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
24
24
  if (options$1.customReplaceDictionary === undefined) {
25
25
  options$1.customReplaceDictionary = 'simple';
26
26
  }
27
- const opts = options.getOptions(options$1, ['patch', 'style', 'templete', 'js']);
28
- const { disabled, onEnd, onLoad, onStart, onUpdate, templeteHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, mangle } = opts;
27
+ const opts = options.getOptions(options$1);
28
+ const { disabled, onEnd, onLoad, onStart, onUpdate, templeteHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet } = opts;
29
29
  if (disabled) {
30
30
  return;
31
31
  }
32
32
  patch === null || patch === void 0 ? void 0 : patch();
33
- shared.initStore(mangle);
34
33
  const twPatcher = options.createTailwindcssPatcher();
35
34
  onLoad();
36
35
  return {
@@ -41,9 +40,9 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
41
40
  },
42
41
  generateBundle(opt, bundle, isWrite) {
43
42
  const entries = Object.entries(bundle);
44
- const groupedEntries = shared.getGroupedEntries(entries, opts);
43
+ const groupedEntries = options.getGroupedEntries(entries, opts);
45
44
  const set = twPatcher.getClassSet();
46
- shared.setRuntimeSet(set);
45
+ setMangleRuntimeSet(set);
47
46
  if (Array.isArray(groupedEntries.html)) {
48
47
  for (let i = 0; i < groupedEntries.html.length; i++) {
49
48
  const [file, originalSource] = groupedEntries.html[i];
package/dist/vite.mjs CHANGED
@@ -1,32 +1,31 @@
1
- import { g as getOptions, a as createTailwindcssPatcher } from './options-5c083791.mjs';
2
- import { v as vitePluginName } from './postcss-e3fcf6f1.mjs';
3
- import { c as initStore, g as getGroupedEntries, d as setRuntimeSet } from './shared-89ea7f77.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-2a6f14b8.mjs';
2
+ import { v as vitePluginName } from './postcss-b4e0e1ac.mjs';
4
3
  import 'micromatch';
5
4
  import '@babel/types';
6
5
  import '@babel/generator';
7
6
  import '@babel/parser';
8
7
  import '@babel/traverse';
9
8
  import './replace.mjs';
10
- import 'tailwindcss-mangle-shared';
9
+ import './shared-31001503.mjs';
11
10
  import 'postcss';
12
11
  import '@csstools/postcss-is-pseudo-class';
13
12
  import 'node:path';
14
13
  import 'node:fs';
15
14
  import 'semver';
16
15
  import 'tailwindcss-patch';
16
+ import 'tailwindcss-mangle-shared';
17
17
  import 'postcss-selector-parser';
18
18
 
19
19
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
20
20
  if (options.customReplaceDictionary === undefined) {
21
21
  options.customReplaceDictionary = 'simple';
22
22
  }
23
- const opts = getOptions(options, ['patch', 'style', 'templete', 'js']);
24
- const { disabled, onEnd, onLoad, onStart, onUpdate, templeteHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, mangle } = opts;
23
+ const opts = getOptions(options);
24
+ const { disabled, onEnd, onLoad, onStart, onUpdate, templeteHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet } = opts;
25
25
  if (disabled) {
26
26
  return;
27
27
  }
28
28
  patch === null || patch === void 0 ? void 0 : patch();
29
- initStore(mangle);
30
29
  const twPatcher = createTailwindcssPatcher();
31
30
  onLoad();
32
31
  return {
@@ -39,7 +38,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
39
38
  const entries = Object.entries(bundle);
40
39
  const groupedEntries = getGroupedEntries(entries, opts);
41
40
  const set = twPatcher.getClassSet();
42
- setRuntimeSet(set);
41
+ setMangleRuntimeSet(set);
43
42
  if (Array.isArray(groupedEntries.html)) {
44
43
  for (let i = 0; i < groupedEntries.html.length; i++) {
45
44
  const [file, originalSource] = groupedEntries.html[i];
package/dist/webpack.js CHANGED
@@ -2,39 +2,38 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-450d76c2.js');
6
- var postcss = require('./postcss-0c103b15.js');
7
- var shared = require('./shared-9744fdd1.js');
5
+ var options = require('./options-3a20e9d4.js');
6
+ var postcss = require('./postcss-e0e5739b.js');
8
7
  require('micromatch');
9
8
  require('@babel/types');
10
9
  require('@babel/generator');
11
10
  require('@babel/parser');
12
11
  require('@babel/traverse');
13
12
  require('./replace.js');
13
+ require('./shared-28d43730.js');
14
14
  require('postcss');
15
15
  require('@csstools/postcss-is-pseudo-class');
16
16
  require('node:path');
17
17
  require('node:fs');
18
18
  require('semver');
19
19
  require('tailwindcss-patch');
20
- require('postcss-selector-parser');
21
20
  require('tailwindcss-mangle-shared');
21
+ require('postcss-selector-parser');
22
22
 
23
23
  class UnifiedWebpackPluginV5 {
24
24
  constructor(options$1 = {}) {
25
25
  if (options$1.customReplaceDictionary === undefined) {
26
26
  options$1.customReplaceDictionary = 'simple';
27
27
  }
28
- this.options = options.getOptions(options$1, ['style', 'patch', 'templete', 'js']);
28
+ this.options = options.getOptions(options$1);
29
29
  this.appType = this.options.appType;
30
30
  }
31
31
  apply(compiler) {
32
- const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templeteHandler, jsHandler, mangle } = this.options;
32
+ const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templeteHandler, jsHandler, setMangleRuntimeSet } = this.options;
33
33
  if (disabled) {
34
34
  return;
35
35
  }
36
36
  patch === null || patch === void 0 ? void 0 : patch();
37
- shared.initStore(mangle);
38
37
  const Compilation = compiler.webpack.Compilation;
39
38
  const { ConcatSource } = compiler.webpack.sources;
40
39
  const twPatcher = options.createTailwindcssPatcher();
@@ -56,9 +55,9 @@ class UnifiedWebpackPluginV5 {
56
55
  }, (assets) => {
57
56
  onStart();
58
57
  const entries = Object.entries(assets);
59
- const groupedEntries = shared.getGroupedEntries(entries, this.options);
58
+ const groupedEntries = options.getGroupedEntries(entries, this.options);
60
59
  const set = getClassSet();
61
- shared.setRuntimeSet(set);
60
+ setMangleRuntimeSet(set);
62
61
  if (Array.isArray(groupedEntries.html)) {
63
62
  for (let i = 0; i < groupedEntries.html.length; i++) {
64
63
  const [file, originalSource] = groupedEntries.html[i];
package/dist/webpack.mjs CHANGED
@@ -1,36 +1,35 @@
1
- import { g as getOptions, a as createTailwindcssPatcher } from './options-5c083791.mjs';
2
- import { a as pluginName, N as NS } from './postcss-e3fcf6f1.mjs';
3
- import { c as initStore, g as getGroupedEntries, d as setRuntimeSet } from './shared-89ea7f77.mjs';
1
+ import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-2a6f14b8.mjs';
2
+ import { a as pluginName, N as NS } from './postcss-b4e0e1ac.mjs';
4
3
  import 'micromatch';
5
4
  import '@babel/types';
6
5
  import '@babel/generator';
7
6
  import '@babel/parser';
8
7
  import '@babel/traverse';
9
8
  import './replace.mjs';
9
+ import './shared-31001503.mjs';
10
10
  import 'postcss';
11
11
  import '@csstools/postcss-is-pseudo-class';
12
12
  import 'node:path';
13
13
  import 'node:fs';
14
14
  import 'semver';
15
15
  import 'tailwindcss-patch';
16
- import 'postcss-selector-parser';
17
16
  import 'tailwindcss-mangle-shared';
17
+ import 'postcss-selector-parser';
18
18
 
19
19
  class UnifiedWebpackPluginV5 {
20
20
  constructor(options = {}) {
21
21
  if (options.customReplaceDictionary === undefined) {
22
22
  options.customReplaceDictionary = 'simple';
23
23
  }
24
- this.options = getOptions(options, ['style', 'patch', 'templete', 'js']);
24
+ this.options = getOptions(options);
25
25
  this.appType = this.options.appType;
26
26
  }
27
27
  apply(compiler) {
28
- const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templeteHandler, jsHandler, mangle } = this.options;
28
+ const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templeteHandler, jsHandler, setMangleRuntimeSet } = this.options;
29
29
  if (disabled) {
30
30
  return;
31
31
  }
32
32
  patch === null || patch === void 0 ? void 0 : patch();
33
- initStore(mangle);
34
33
  const Compilation = compiler.webpack.Compilation;
35
34
  const { ConcatSource } = compiler.webpack.sources;
36
35
  const twPatcher = createTailwindcssPatcher();
@@ -54,7 +53,7 @@ class UnifiedWebpackPluginV5 {
54
53
  const entries = Object.entries(assets);
55
54
  const groupedEntries = getGroupedEntries(entries, this.options);
56
55
  const set = getClassSet();
57
- setRuntimeSet(set);
56
+ setMangleRuntimeSet(set);
58
57
  if (Array.isArray(groupedEntries.html)) {
59
58
  for (let i = 0; i < groupedEntries.html.length; i++) {
60
59
  const [file, originalSource] = groupedEntries.html[i];
@@ -1,2 +1,2 @@
1
- import { ICommonReplaceOptions } from "../types";
2
- export declare function replaceWxml(original: string, options?: ICommonReplaceOptions | boolean): string;
1
+ import { ITempleteHandlerOptions } from "../types";
2
+ export declare function replaceWxml(original: string, options?: ITempleteHandlerOptions): string;
@@ -1,7 +1,7 @@
1
- import type { RawSource, ICommonReplaceOptions, ITempleteHandlerOptions } from "../types";
2
- export declare function generateCode(match: string, options?: ICommonReplaceOptions): string;
1
+ import type { RawSource, ITempleteHandlerOptions } from "../types";
2
+ export declare function generateCode(match: string, options?: ITempleteHandlerOptions): string;
3
3
  export declare function extractSource(original: string): RawSource[];
4
- export declare function templeteReplacer(original: string, options?: ICommonReplaceOptions): string;
5
- export declare function templeteHandler(rawSource: string, options?: ICommonReplaceOptions): string;
4
+ export declare function templeteReplacer(original: string, options?: ITempleteHandlerOptions): string;
5
+ export declare function templeteHandler(rawSource: string, options?: ITempleteHandlerOptions): string;
6
6
  export declare function customTempleteHandler(rawSource: string, options?: ITempleteHandlerOptions): string;
7
7
  export declare function createTempleteHandler(options?: ITempleteHandlerOptions): (rawSource: string, opt?: ITempleteHandlerOptions) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "把tailwindcss jit引擎,带给小程序开发者们\nbring tailwindcss jit engine to our miniprogram developers!",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -191,6 +191,9 @@
191
191
  "jest-u": "jest -u",
192
192
  "vitest:test": "vitest",
193
193
  "vitest:coverage": "vitest run --coverage",
194
+ "e2e": "vitest run -c ./vitest.e2e.config.ts",
195
+ "e2e:dev": "vitest -c ./vitest.e2e.config.ts",
196
+ "e2e:u": "vitest run -u -c ./vitest.e2e.config.ts",
194
197
  "test:all": "cross-env JEST_INVALID_SKIP_CASES=1 jest",
195
198
  "init:rename": "node scripts/init/rename.js",
196
199
  "clean": "node scripts/clean.js",
@@ -199,7 +202,6 @@
199
202
  "demo:dev": "node scripts/demo/dev.js",
200
203
  "demo:build": "node scripts/demo/build.js",
201
204
  "demo:build:local": "node scripts/demo/build.js --local",
202
- "demo:e2e": "ts-node scripts/demo/e2e.js",
203
205
  "demo:link": "node scripts/demo/link.js",
204
206
  "demo:install": "node scripts/demo/install.js",
205
207
  "demo:install:beta": "node scripts/demo/install.js --beta",
@@ -1,15 +0,0 @@
1
- import { ClassGenerator } from 'tailwindcss-mangle-shared';
2
- import { UserDefinedOptions } from "../types";
3
- export interface IMangleScopeStore {
4
- rawOptions: UserDefinedOptions['mangle'];
5
- runtimeSet: Set<string>;
6
- classGenerator: ClassGenerator;
7
- filter: (className: string) => boolean;
8
- cssHandler: (rawSource: string) => string;
9
- jsHandler: (rawSource: string) => string;
10
- wxmlHandler: (rawSource: string) => string;
11
- }
12
- export declare function useStore(): IMangleScopeStore;
13
- export declare function resetStore(): IMangleScopeStore;
14
- export declare function initStore(options: UserDefinedOptions['mangle']): void;
15
- export declare function setRuntimeSet(runtimeSet: Set<string>): void;