weapp-tailwindcss 2.4.1 → 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.
@@ -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 };
@@ -1,353 +0,0 @@
1
- 'use strict';
2
-
3
- var tailwindcssMangleShared = require('tailwindcss-mangle-shared');
4
-
5
- const SYMBOL_TABLE = {
6
- BACKQUOTE: '`',
7
- TILDE: '~',
8
- EXCLAM: '!',
9
- AT: '@',
10
- NUMBERSIGN: '#',
11
- DOLLAR: '$',
12
- PERCENT: '%',
13
- CARET: '^',
14
- AMPERSAND: '&',
15
- ASTERISK: '*',
16
- PARENLEFT: '(',
17
- PARENRIGHT: ')',
18
- MINUS: '-',
19
- UNDERSCORE: '_',
20
- EQUAL: '=',
21
- PLUS: '+',
22
- BRACKETLEFT: '[',
23
- BRACELEFT: '{',
24
- BRACKETRIGHT: ']',
25
- BRACERIGHT: '}',
26
- SEMICOLON: ';',
27
- COLON: ':',
28
- QUOTE: "'",
29
- DOUBLEQUOTE: '"',
30
- BACKSLASH: '\\',
31
- BAR: '|',
32
- COMMA: ',',
33
- LESS: '<',
34
- PERIOD: '.',
35
- GREATER: '>',
36
- SLASH: '/',
37
- QUESTION: '?',
38
- SPACE: ' ',
39
- DOT: '.',
40
- HASH: '#'
41
- };
42
- const MappingChars2String = {
43
- '[': '_bl_',
44
- ']': '_br_',
45
- '(': '_pl_',
46
- ')': '_qr_',
47
- '#': '_h_',
48
- '!': '_i_',
49
- '/': '_s_',
50
- '\\': '_bs_',
51
- '.': '_d_',
52
- ':': '_c_',
53
- '%': '_p_',
54
- ',': '_co_',
55
- "'": '_q_',
56
- '"': '_dq_',
57
- '*': '_a_',
58
- '&': '_am_',
59
- '@': '_at_',
60
- '{': '_bal_',
61
- '}': '_bar_',
62
- '+': '_plus_',
63
- ';': '_se_',
64
- '<': '_l_',
65
- '~': '_t_',
66
- '=': '_e_',
67
- '>': '_g_',
68
- '?': '_qu_',
69
- '^': '_ca_',
70
- '`': '_bq_',
71
- '|': '_b_',
72
- $: '_do_'
73
- };
74
- const MappingChars2StringEntries = Object.entries(MappingChars2String);
75
- const SimpleMappingChars2String = {
76
- '[': '_',
77
- ']': '_',
78
- '(': '_',
79
- ')': '_',
80
- '{': '_',
81
- '}': '_',
82
- '+': 'a',
83
- ',': 'b',
84
- ':': 'c',
85
- '.': 'd',
86
- '=': 'e',
87
- ';': 'f',
88
- '>': 'g',
89
- '#': 'h',
90
- '!': 'i',
91
- '@': 'j',
92
- '^': 'k',
93
- '<': 'l',
94
- '*': 'm',
95
- '&': 'n',
96
- '?': 'o',
97
- '%': 'p',
98
- "'": 'q',
99
- $: 'r',
100
- '/': 's',
101
- '~': 't',
102
- '|': 'u',
103
- '`': 'v',
104
- '\\': 'w',
105
- '"': 'x'
106
- };
107
- const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
108
-
109
- const MAX_ASCII_CHAR_CODE = 127;
110
- function escape(selectors, options = {
111
- map: SimpleMappingChars2String
112
- }) {
113
- const { map = SimpleMappingChars2String } = options;
114
- const sb = [...selectors];
115
- for (let i = 0; i < sb.length; i++) {
116
- const char = sb[i];
117
- const code = char.codePointAt(0);
118
- if (code !== undefined && code > MAX_ASCII_CHAR_CODE) {
119
- sb[i] = 'u' + Number(code).toString(16);
120
- }
121
- else {
122
- const hit = map[char];
123
- if (hit) {
124
- sb[i] = hit;
125
- }
126
- }
127
- }
128
- const res = sb.join('');
129
- return res;
130
- }
131
-
132
- const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
133
- function isValidSelector(selector = '') {
134
- return validateFilterRE.test(selector);
135
- }
136
- const splitCode = (code) => {
137
- return code.split(/\s+|"/).filter((element) => isValidSelector(element));
138
- };
139
-
140
- function isRegexp(value) {
141
- return Object.prototype.toString.call(value) === '[object RegExp]';
142
- }
143
- function isMap(value) {
144
- return Object.prototype.toString.call(value) === '[object Map]';
145
- }
146
- const noop = () => { };
147
- function groupBy(arr, cb) {
148
- if (!Array.isArray(arr)) {
149
- throw new TypeError('expected an array for first argument');
150
- }
151
- if (typeof cb !== 'function') {
152
- throw new TypeError('expected a function for second argument');
153
- }
154
- const result = {};
155
- for (const item of arr) {
156
- const bucketCategory = cb(item);
157
- const bucket = result[bucketCategory];
158
- if (Array.isArray(bucket)) {
159
- result[bucketCategory].push(item);
160
- }
161
- else {
162
- result[bucketCategory] = [item];
163
- }
164
- }
165
- return result;
166
- }
167
- function getGroupedEntries(entries, options) {
168
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
169
- const groupedEntries = groupBy(entries, ([file]) => {
170
- if (cssMatcher(file)) {
171
- return 'css';
172
- }
173
- else if (htmlMatcher(file)) {
174
- return 'html';
175
- }
176
- else if (jsMatcher(file)) {
177
- return 'js';
178
- }
179
- else {
180
- return 'other';
181
- }
182
- });
183
- return groupedEntries;
184
- }
185
-
186
- function escapeStringRegexp(str) {
187
- if (typeof str !== 'string') {
188
- throw new TypeError('Expected a string');
189
- }
190
- return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
191
- }
192
- const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
193
- const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
194
- function handleRegexp(reg) {
195
- return `(?:${reg.source})`;
196
- }
197
- function getSourceString(input) {
198
- let result;
199
- if (typeof input === 'string') {
200
- result = input;
201
- }
202
- else if (isRegexp(input)) {
203
- result = input.source;
204
- }
205
- else {
206
- result = input.toString();
207
- }
208
- return result;
209
- }
210
- function makePattern(arr) {
211
- let pattern = '';
212
- if (Array.isArray(arr)) {
213
- pattern = arr
214
- .reduce((acc, cur) => {
215
- if (typeof cur === 'string') {
216
- acc.push(cur);
217
- }
218
- else if (isRegexp(cur)) {
219
- acc.push(handleRegexp(cur));
220
- }
221
- return acc;
222
- }, [])
223
- .join('|');
224
- }
225
- else if (typeof arr === 'string') {
226
- pattern = arr;
227
- }
228
- else if (isRegexp(arr)) {
229
- pattern = handleRegexp(arr);
230
- }
231
- return pattern;
232
- }
233
- function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
234
- const { exact = true } = options;
235
- const prefix = exact ? '(?<=^|\\s)' : '';
236
- const pattern = makePattern(attrs);
237
- let tagPattern = getSourceString(tag);
238
- if (tagPattern === '*') {
239
- tagPattern = '[a-z][-a-z]*[a-z]*';
240
- }
241
- const source = `<(${tagPattern})\\s+[^>]*?(?:${prefix}(${pattern})="(?:[^"]*)")[^>]*?\\/?>`;
242
- return new RegExp(source, 'g');
243
- }
244
- function createTemplateClassRegexp(attrs, options = {}) {
245
- const { exact = true } = options;
246
- const prefix = exact ? '(?<=^|\\s)' : '';
247
- const pattern = makePattern(attrs);
248
- const source = `(?:${prefix}${pattern})=(?:["']\\W+\\s*(?:\\w+)\\()?["']([^"]+)['"]`;
249
- return new RegExp(source, 'gs');
250
- }
251
- function makeCustomAttributes(entries) {
252
- if (Array.isArray(entries)) {
253
- return entries.map(([k, v]) => {
254
- return {
255
- tagRegexp: createTempleteHandlerMatchRegexp(k, v),
256
- attrRegexp: createTemplateClassRegexp(v),
257
- tag: getSourceString(k),
258
- attrs: v
259
- };
260
- });
261
- }
262
- }
263
- const variableRegExp = /{{(.*?)}}/gs;
264
- function variableMatch(original) {
265
- return variableRegExp.exec(original);
266
- }
267
-
268
- function getSelf(x) {
269
- return x;
270
- }
271
- const defaultScopedStore = {
272
- rawOptions: false,
273
- runtimeSet: new Set(),
274
- classGenerator: new tailwindcssMangleShared.ClassGenerator(),
275
- filter: tailwindcssMangleShared.defaultMangleClassFilter,
276
- cssHandler: getSelf,
277
- jsHandler: getSelf,
278
- wxmlHandler: getSelf
279
- };
280
- const store = Object.assign({}, defaultScopedStore);
281
- function useStore() {
282
- return store;
283
- }
284
- function handleValue(rawSource) {
285
- const arr = splitCode(rawSource);
286
- for (const x of arr) {
287
- if (store.runtimeSet.has(x)) {
288
- rawSource = rawSource.replaceAll(new RegExp(escapeStringRegexp(x), 'g'), store.classGenerator.generateClassName(x).name);
289
- }
290
- }
291
- return rawSource;
292
- }
293
- function initStore(options) {
294
- var _a;
295
- store.rawOptions = options;
296
- if (options) {
297
- if (options === true) {
298
- options = {
299
- classGenerator: {},
300
- mangleClassFilter: tailwindcssMangleShared.defaultMangleClassFilter
301
- };
302
- }
303
- store.classGenerator = new tailwindcssMangleShared.ClassGenerator(options.classGenerator);
304
- store.filter = (_a = options.mangleClassFilter) !== null && _a !== void 0 ? _a : tailwindcssMangleShared.defaultMangleClassFilter;
305
- store.jsHandler = (rawSource) => {
306
- return handleValue(rawSource);
307
- };
308
- store.cssHandler = (rawSource) => {
309
- return handleValue(rawSource);
310
- };
311
- store.wxmlHandler = (rawSource) => {
312
- return handleValue(rawSource);
313
- };
314
- }
315
- }
316
- function setRuntimeSet(runtimeSet) {
317
- const newSet = new Set();
318
- for (const c of runtimeSet) {
319
- if (store.filter(c)) {
320
- newSet.add(c);
321
- }
322
- }
323
- store.runtimeSet = newSet;
324
- }
325
-
326
- function internalCssSelectorReplacer(selectors, map = SimpleMappingChars2String) {
327
- const { cssHandler } = useStore();
328
- selectors = cssHandler(selectors);
329
- return escape(selectors, {
330
- map
331
- });
332
- }
333
-
334
- exports.MappingChars2String = MappingChars2String;
335
- exports.MappingChars2StringEntries = MappingChars2StringEntries;
336
- exports.SYMBOL_TABLE = SYMBOL_TABLE;
337
- exports.SimpleMappingChars2String = SimpleMappingChars2String;
338
- exports.SimpleMappingChars2StringEntries = SimpleMappingChars2StringEntries;
339
- exports.escape = escape;
340
- exports.escapeStringRegexp = escapeStringRegexp;
341
- exports.getGroupedEntries = getGroupedEntries;
342
- exports.initStore = initStore;
343
- exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
344
- exports.isMap = isMap;
345
- exports.makeCustomAttributes = makeCustomAttributes;
346
- exports.noop = noop;
347
- exports.setRuntimeSet = setRuntimeSet;
348
- exports.splitCode = splitCode;
349
- exports.tagWithEitherClassAndHoverClassRegexp = tagWithEitherClassAndHoverClassRegexp;
350
- exports.templateClassExactRegexp = templateClassExactRegexp;
351
- exports.useStore = useStore;
352
- exports.variableMatch = variableMatch;
353
- exports.variableRegExp = variableRegExp;