weapp-tailwindcss 2.4.1 → 2.4.3
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.
- package/README.md +8 -8
- package/dist/cli.js +4 -4
- package/dist/cli.mjs +4 -4
- package/dist/extractors/split.d.ts +1 -1
- package/dist/gulp.js +6 -7
- package/dist/gulp.mjs +6 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/mangle/index.d.ts +8 -0
- package/dist/{options-b3e419f1.js → options-2e71e6b3.js} +271 -66
- package/dist/{options-3578215d.mjs → options-a2ba3653.mjs} +258 -54
- package/dist/options.d.ts +1 -3
- package/dist/postcss/index.d.ts +1 -1
- package/dist/postcss/shared.d.ts +3 -1
- package/dist/{postcss-564aef44.mjs → postcss-15e2ef2d.mjs} +8 -4
- package/dist/{postcss-06f57f3f.js → postcss-b8952a11.js} +8 -4
- package/dist/postcss.js +2 -3
- package/dist/postcss.mjs +2 -3
- package/dist/replace.js +7 -11
- package/dist/replace.mjs +8 -12
- package/dist/shared-cdb5ee55.js +152 -0
- package/dist/shared-fc50603a.mjs +144 -0
- package/dist/types.d.ts +24 -4
- package/dist/utils.d.ts +1 -0
- package/dist/vite.js +8 -9
- package/dist/vite.mjs +7 -8
- package/dist/webpack.js +8 -9
- package/dist/webpack.mjs +7 -8
- package/dist/wxml/shared.d.ts +2 -2
- package/dist/wxml/utils.d.ts +4 -4
- package/package.json +29 -26
- package/dist/mangle/store.d.ts +0 -15
- package/dist/shared-497eda3c.mjs +0 -332
- package/dist/shared-823d1fc1.js +0 -353
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
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",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"sideEffects": false,
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/sonofmagic/weapp-tailwindcss
|
|
51
|
+
"url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"bin",
|
|
@@ -100,37 +100,38 @@
|
|
|
100
100
|
"@icebreakers/cli": "^0.1.1",
|
|
101
101
|
"@icebreakers/readme": "0.1.0",
|
|
102
102
|
"@rollup/plugin-alias": "^5.0.0",
|
|
103
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
103
|
+
"@rollup/plugin-commonjs": "^25.0.1",
|
|
104
104
|
"@rollup/plugin-json": "^6.0.0",
|
|
105
|
-
"@rollup/plugin-node-resolve": "^15.0
|
|
105
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
106
106
|
"@rollup/plugin-terser": "^0.4.3",
|
|
107
107
|
"@rollup/plugin-typescript": "^11.1.1",
|
|
108
108
|
"@tsconfig/recommended": "^1.0.2",
|
|
109
109
|
"@types/babel__generator": "^7.6.4",
|
|
110
110
|
"@types/babel__traverse": "^7.18.5",
|
|
111
111
|
"@types/fs-extra": "^11.0.1",
|
|
112
|
-
"@types/gulp": "^4.0.
|
|
112
|
+
"@types/gulp": "^4.0.11",
|
|
113
113
|
"@types/gulp-postcss": "^8.0.3",
|
|
114
|
-
"@types/jest": "^29.5.
|
|
115
|
-
"@types/lodash": "^4.14.
|
|
114
|
+
"@types/jest": "^29.5.2",
|
|
115
|
+
"@types/lodash": "^4.14.195",
|
|
116
116
|
"@types/micromatch": "^4.0.2",
|
|
117
|
-
"@types/node": "^20.2.
|
|
118
|
-
"@types/react": "^18.2.6",
|
|
117
|
+
"@types/node": "^20.2.6",
|
|
119
118
|
"@types/semver": "^7.5.0",
|
|
120
119
|
"@types/vinyl": "^2.0.7",
|
|
121
120
|
"@types/webpack": "^5.28.1",
|
|
122
121
|
"@types/webpack-sources": "^3.2.0",
|
|
123
|
-
"@vitest/coverage-
|
|
122
|
+
"@vitest/coverage-v8": "^0.32.0",
|
|
124
123
|
"autoprefixer": "^10.4.14",
|
|
125
124
|
"babel-loader": "^9.1.2",
|
|
126
|
-
"bumpp": "^9.1.
|
|
125
|
+
"bumpp": "^9.1.1",
|
|
127
126
|
"chalk": "4.1.2",
|
|
128
127
|
"cross-env": "^7.0.3",
|
|
129
|
-
"css-loader": "^6.
|
|
128
|
+
"css-loader": "^6.8.1",
|
|
130
129
|
"defu": "6.1.2",
|
|
131
130
|
"del": "^6.1.1",
|
|
132
|
-
"eslint": "8.
|
|
131
|
+
"eslint": "8.42.0",
|
|
133
132
|
"eslint-config-icebreaker": "^1.1.0",
|
|
133
|
+
"eslint-config-prettier": "^8.8.0",
|
|
134
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
134
135
|
"execa": "5",
|
|
135
136
|
"fast-glob": "^3.2.12",
|
|
136
137
|
"fs-extra": "^11.1.1",
|
|
@@ -139,15 +140,15 @@
|
|
|
139
140
|
"html-loader": "^4.2.0",
|
|
140
141
|
"jest": "^29.5.0",
|
|
141
142
|
"lodash": "^4.17.21",
|
|
142
|
-
"memfs": "^3.5.
|
|
143
|
+
"memfs": "^3.5.3",
|
|
143
144
|
"mini-css-extract-plugin": "^2.7.6",
|
|
144
145
|
"miniprogram-automator": "^0.12.0",
|
|
145
146
|
"pkg-types": "^1.0.3",
|
|
146
147
|
"postcss-load-config": "^4.0.1",
|
|
147
|
-
"postcss-loader": "^7.3.
|
|
148
|
+
"postcss-loader": "^7.3.3",
|
|
148
149
|
"postcss-rem-to-responsive-pixel": "^5.1.3",
|
|
149
150
|
"prettier": "^2.8.8",
|
|
150
|
-
"rollup": "^3.
|
|
151
|
+
"rollup": "^3.24.1",
|
|
151
152
|
"rollup-plugin-visualizer": "^5.9.0",
|
|
152
153
|
"simple-functional-loader": "^1.2.1",
|
|
153
154
|
"style-loader": "^3.3.3",
|
|
@@ -157,15 +158,15 @@
|
|
|
157
158
|
"ts-node": "^10.9.1",
|
|
158
159
|
"ts-patch": "^2.1.0",
|
|
159
160
|
"tsd": "^0.28.1",
|
|
160
|
-
"tslib": "^2.5.
|
|
161
|
+
"tslib": "^2.5.3",
|
|
161
162
|
"ttypescript": "^1.5.15",
|
|
162
163
|
"typescript": "^4.9.5",
|
|
163
164
|
"typescript-transform-paths": "^3.4.6",
|
|
164
165
|
"vinyl": "^3.0.0",
|
|
165
|
-
"vite": "^4.3.
|
|
166
|
-
"vitest": "^0.
|
|
166
|
+
"vite": "^4.3.9",
|
|
167
|
+
"vitest": "^0.32.0",
|
|
167
168
|
"weapp-tailwindcss-children": "^0.1.0",
|
|
168
|
-
"webpack": "^5.
|
|
169
|
+
"webpack": "^5.86.0"
|
|
169
170
|
},
|
|
170
171
|
"dependencies": {
|
|
171
172
|
"@babel/generator": "^7.21.4",
|
|
@@ -174,13 +175,13 @@
|
|
|
174
175
|
"@babel/types": "^7.21.4",
|
|
175
176
|
"@csstools/postcss-is-pseudo-class": "^3.2.1",
|
|
176
177
|
"micromatch": "^4.0.5",
|
|
177
|
-
"postcss": "8.4.
|
|
178
|
+
"postcss": "8.4.24",
|
|
178
179
|
"postcss-selector-parser": "^6.0.13",
|
|
179
180
|
"semver": "^7.5.1",
|
|
180
|
-
"tailwindcss-mangle-shared": "^1.2.
|
|
181
|
-
"tailwindcss-patch": "^1.2.
|
|
181
|
+
"tailwindcss-mangle-shared": "^1.2.4",
|
|
182
|
+
"tailwindcss-patch": "^1.2.4"
|
|
182
183
|
},
|
|
183
|
-
"packageManager": "pnpm@8.
|
|
184
|
+
"packageManager": "pnpm@8.6.1",
|
|
184
185
|
"scripts": {
|
|
185
186
|
"dev": "yarn clean && yarn dts && cross-env NODE_ENV=development rollup -c rollup.config.ts --configPlugin typescript -w",
|
|
186
187
|
"build": "yarn clean && cross-env NODE_ENV=production rollup -c rollup.config.ts --configPlugin typescript && yarn dts",
|
|
@@ -189,8 +190,11 @@
|
|
|
189
190
|
"dts": "tsc --emitDeclarationOnly -p tsconfig.dts.json",
|
|
190
191
|
"test": "jest && vitest run",
|
|
191
192
|
"jest-u": "jest -u",
|
|
192
|
-
"
|
|
193
|
+
"test:dev": "vitest",
|
|
193
194
|
"vitest:coverage": "vitest run --coverage",
|
|
195
|
+
"e2e": "vitest run -c ./vitest.e2e.config.ts",
|
|
196
|
+
"e2e:dev": "vitest -c ./vitest.e2e.config.ts",
|
|
197
|
+
"e2e:u": "vitest run -u -c ./vitest.e2e.config.ts",
|
|
194
198
|
"test:all": "cross-env JEST_INVALID_SKIP_CASES=1 jest",
|
|
195
199
|
"init:rename": "node scripts/init/rename.js",
|
|
196
200
|
"clean": "node scripts/clean.js",
|
|
@@ -199,7 +203,6 @@
|
|
|
199
203
|
"demo:dev": "node scripts/demo/dev.js",
|
|
200
204
|
"demo:build": "node scripts/demo/build.js",
|
|
201
205
|
"demo:build:local": "node scripts/demo/build.js --local",
|
|
202
|
-
"demo:e2e": "ts-node scripts/demo/e2e.js",
|
|
203
206
|
"demo:link": "node scripts/demo/link.js",
|
|
204
207
|
"demo:install": "node scripts/demo/install.js",
|
|
205
208
|
"demo:install:beta": "node scripts/demo/install.js --beta",
|
package/dist/mangle/store.d.ts
DELETED
|
@@ -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;
|
package/dist/shared-497eda3c.mjs
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { ClassGenerator, defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
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
|
-
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
131
|
-
function isValidSelector(selector = '') {
|
|
132
|
-
return validateFilterRE.test(selector);
|
|
133
|
-
}
|
|
134
|
-
const splitCode = (code) => {
|
|
135
|
-
return code.split(/\s+|"/).filter((element) => isValidSelector(element));
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
function isRegexp(value) {
|
|
139
|
-
return Object.prototype.toString.call(value) === '[object RegExp]';
|
|
140
|
-
}
|
|
141
|
-
function isMap(value) {
|
|
142
|
-
return Object.prototype.toString.call(value) === '[object Map]';
|
|
143
|
-
}
|
|
144
|
-
const noop = () => { };
|
|
145
|
-
function groupBy(arr, cb) {
|
|
146
|
-
if (!Array.isArray(arr)) {
|
|
147
|
-
throw new TypeError('expected an array for first argument');
|
|
148
|
-
}
|
|
149
|
-
if (typeof cb !== 'function') {
|
|
150
|
-
throw new TypeError('expected a function for second argument');
|
|
151
|
-
}
|
|
152
|
-
const result = {};
|
|
153
|
-
for (const item of arr) {
|
|
154
|
-
const bucketCategory = cb(item);
|
|
155
|
-
const bucket = result[bucketCategory];
|
|
156
|
-
if (Array.isArray(bucket)) {
|
|
157
|
-
result[bucketCategory].push(item);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
result[bucketCategory] = [item];
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
function getGroupedEntries(entries, options) {
|
|
166
|
-
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
167
|
-
const groupedEntries = groupBy(entries, ([file]) => {
|
|
168
|
-
if (cssMatcher(file)) {
|
|
169
|
-
return 'css';
|
|
170
|
-
}
|
|
171
|
-
else if (htmlMatcher(file)) {
|
|
172
|
-
return 'html';
|
|
173
|
-
}
|
|
174
|
-
else if (jsMatcher(file)) {
|
|
175
|
-
return 'js';
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
return 'other';
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
return groupedEntries;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function escapeStringRegexp(str) {
|
|
185
|
-
if (typeof str !== 'string') {
|
|
186
|
-
throw new TypeError('Expected a string');
|
|
187
|
-
}
|
|
188
|
-
return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
|
|
189
|
-
}
|
|
190
|
-
const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
|
|
191
|
-
const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
|
|
192
|
-
function handleRegexp(reg) {
|
|
193
|
-
return `(?:${reg.source})`;
|
|
194
|
-
}
|
|
195
|
-
function getSourceString(input) {
|
|
196
|
-
let result;
|
|
197
|
-
if (typeof input === 'string') {
|
|
198
|
-
result = input;
|
|
199
|
-
}
|
|
200
|
-
else if (isRegexp(input)) {
|
|
201
|
-
result = input.source;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
result = input.toString();
|
|
205
|
-
}
|
|
206
|
-
return result;
|
|
207
|
-
}
|
|
208
|
-
function makePattern(arr) {
|
|
209
|
-
let pattern = '';
|
|
210
|
-
if (Array.isArray(arr)) {
|
|
211
|
-
pattern = arr
|
|
212
|
-
.reduce((acc, cur) => {
|
|
213
|
-
if (typeof cur === 'string') {
|
|
214
|
-
acc.push(cur);
|
|
215
|
-
}
|
|
216
|
-
else if (isRegexp(cur)) {
|
|
217
|
-
acc.push(handleRegexp(cur));
|
|
218
|
-
}
|
|
219
|
-
return acc;
|
|
220
|
-
}, [])
|
|
221
|
-
.join('|');
|
|
222
|
-
}
|
|
223
|
-
else if (typeof arr === 'string') {
|
|
224
|
-
pattern = arr;
|
|
225
|
-
}
|
|
226
|
-
else if (isRegexp(arr)) {
|
|
227
|
-
pattern = handleRegexp(arr);
|
|
228
|
-
}
|
|
229
|
-
return pattern;
|
|
230
|
-
}
|
|
231
|
-
function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
|
|
232
|
-
const { exact = true } = options;
|
|
233
|
-
const prefix = exact ? '(?<=^|\\s)' : '';
|
|
234
|
-
const pattern = makePattern(attrs);
|
|
235
|
-
let tagPattern = getSourceString(tag);
|
|
236
|
-
if (tagPattern === '*') {
|
|
237
|
-
tagPattern = '[a-z][-a-z]*[a-z]*';
|
|
238
|
-
}
|
|
239
|
-
const source = `<(${tagPattern})\\s+[^>]*?(?:${prefix}(${pattern})="(?:[^"]*)")[^>]*?\\/?>`;
|
|
240
|
-
return new RegExp(source, 'g');
|
|
241
|
-
}
|
|
242
|
-
function createTemplateClassRegexp(attrs, options = {}) {
|
|
243
|
-
const { exact = true } = options;
|
|
244
|
-
const prefix = exact ? '(?<=^|\\s)' : '';
|
|
245
|
-
const pattern = makePattern(attrs);
|
|
246
|
-
const source = `(?:${prefix}${pattern})=(?:["']\\W+\\s*(?:\\w+)\\()?["']([^"]+)['"]`;
|
|
247
|
-
return new RegExp(source, 'gs');
|
|
248
|
-
}
|
|
249
|
-
function makeCustomAttributes(entries) {
|
|
250
|
-
if (Array.isArray(entries)) {
|
|
251
|
-
return entries.map(([k, v]) => {
|
|
252
|
-
return {
|
|
253
|
-
tagRegexp: createTempleteHandlerMatchRegexp(k, v),
|
|
254
|
-
attrRegexp: createTemplateClassRegexp(v),
|
|
255
|
-
tag: getSourceString(k),
|
|
256
|
-
attrs: v
|
|
257
|
-
};
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
const variableRegExp = /{{(.*?)}}/gs;
|
|
262
|
-
function variableMatch(original) {
|
|
263
|
-
return variableRegExp.exec(original);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function getSelf(x) {
|
|
267
|
-
return x;
|
|
268
|
-
}
|
|
269
|
-
const defaultScopedStore = {
|
|
270
|
-
rawOptions: false,
|
|
271
|
-
runtimeSet: new Set(),
|
|
272
|
-
classGenerator: new ClassGenerator(),
|
|
273
|
-
filter: defaultMangleClassFilter,
|
|
274
|
-
cssHandler: getSelf,
|
|
275
|
-
jsHandler: getSelf,
|
|
276
|
-
wxmlHandler: getSelf
|
|
277
|
-
};
|
|
278
|
-
const store = Object.assign({}, defaultScopedStore);
|
|
279
|
-
function useStore() {
|
|
280
|
-
return store;
|
|
281
|
-
}
|
|
282
|
-
function handleValue(rawSource) {
|
|
283
|
-
const arr = splitCode(rawSource);
|
|
284
|
-
for (const x of arr) {
|
|
285
|
-
if (store.runtimeSet.has(x)) {
|
|
286
|
-
rawSource = rawSource.replaceAll(new RegExp(escapeStringRegexp(x), 'g'), store.classGenerator.generateClassName(x).name);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return rawSource;
|
|
290
|
-
}
|
|
291
|
-
function initStore(options) {
|
|
292
|
-
var _a;
|
|
293
|
-
store.rawOptions = options;
|
|
294
|
-
if (options) {
|
|
295
|
-
if (options === true) {
|
|
296
|
-
options = {
|
|
297
|
-
classGenerator: {},
|
|
298
|
-
mangleClassFilter: defaultMangleClassFilter
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
store.classGenerator = new ClassGenerator(options.classGenerator);
|
|
302
|
-
store.filter = (_a = options.mangleClassFilter) !== null && _a !== void 0 ? _a : defaultMangleClassFilter;
|
|
303
|
-
store.jsHandler = (rawSource) => {
|
|
304
|
-
return handleValue(rawSource);
|
|
305
|
-
};
|
|
306
|
-
store.cssHandler = (rawSource) => {
|
|
307
|
-
return handleValue(rawSource);
|
|
308
|
-
};
|
|
309
|
-
store.wxmlHandler = (rawSource) => {
|
|
310
|
-
return handleValue(rawSource);
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function setRuntimeSet(runtimeSet) {
|
|
315
|
-
const newSet = new Set();
|
|
316
|
-
for (const c of runtimeSet) {
|
|
317
|
-
if (store.filter(c)) {
|
|
318
|
-
newSet.add(c);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
store.runtimeSet = newSet;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function internalCssSelectorReplacer(selectors, map = SimpleMappingChars2String) {
|
|
325
|
-
const { cssHandler } = useStore();
|
|
326
|
-
selectors = cssHandler(selectors);
|
|
327
|
-
return escape(selectors, {
|
|
328
|
-
map
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export { MappingChars2String as M, SimpleMappingChars2String as S, templateClassExactRegexp as a, variableRegExp as b, initStore as c, setRuntimeSet as d, escapeStringRegexp as e, internalCssSelectorReplacer as f, getGroupedEntries as g, escape as h, isMap as i, SYMBOL_TABLE as j, MappingChars2StringEntries as k, SimpleMappingChars2StringEntries as l, makeCustomAttributes as m, noop as n, splitCode as s, tagWithEitherClassAndHoverClassRegexp as t, useStore as u, variableMatch as v };
|