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
|
@@ -4,14 +4,15 @@ import generate from '@babel/generator';
|
|
|
4
4
|
import { parse, parseExpression } from '@babel/parser';
|
|
5
5
|
import traverse from '@babel/traverse';
|
|
6
6
|
import { replaceJs as replaceWxml } from './replace.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-fc50603a.mjs';
|
|
8
8
|
import postcss from 'postcss';
|
|
9
|
-
import { p as postcssWeappTailwindcss } from './postcss-
|
|
9
|
+
import { p as postcssWeappTailwindcss } from './postcss-15e2ef2d.mjs';
|
|
10
10
|
import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import fs from 'node:fs';
|
|
13
13
|
import { gte } from 'semver';
|
|
14
14
|
import { monkeyPatchForExposingContext, requireResolve, TailwindcssPatcher } from 'tailwindcss-patch';
|
|
15
|
+
import { ClassGenerator, defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
15
16
|
|
|
16
17
|
function isObject(value) {
|
|
17
18
|
return value !== null && typeof value === "object";
|
|
@@ -55,12 +56,152 @@ function createDefu(merger) {
|
|
|
55
56
|
}
|
|
56
57
|
const defu = createDefu();
|
|
57
58
|
|
|
59
|
+
function isRegexp(value) {
|
|
60
|
+
return Object.prototype.toString.call(value) === '[object RegExp]';
|
|
61
|
+
}
|
|
62
|
+
function isMap(value) {
|
|
63
|
+
return Object.prototype.toString.call(value) === '[object Map]';
|
|
64
|
+
}
|
|
65
|
+
const noop = () => { };
|
|
66
|
+
function groupBy(arr, cb) {
|
|
67
|
+
if (!Array.isArray(arr)) {
|
|
68
|
+
throw new TypeError('expected an array for first argument');
|
|
69
|
+
}
|
|
70
|
+
if (typeof cb !== 'function') {
|
|
71
|
+
throw new TypeError('expected a function for second argument');
|
|
72
|
+
}
|
|
73
|
+
const result = {};
|
|
74
|
+
for (const item of arr) {
|
|
75
|
+
const bucketCategory = cb(item);
|
|
76
|
+
const bucket = result[bucketCategory];
|
|
77
|
+
if (Array.isArray(bucket)) {
|
|
78
|
+
result[bucketCategory].push(item);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
result[bucketCategory] = [item];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
function getGroupedEntries(entries, options) {
|
|
87
|
+
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
88
|
+
const groupedEntries = groupBy(entries, ([file]) => {
|
|
89
|
+
if (cssMatcher(file)) {
|
|
90
|
+
return 'css';
|
|
91
|
+
}
|
|
92
|
+
else if (htmlMatcher(file)) {
|
|
93
|
+
return 'html';
|
|
94
|
+
}
|
|
95
|
+
else if (jsMatcher(file)) {
|
|
96
|
+
return 'js';
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return 'other';
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return groupedEntries;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function escapeStringRegexp(str) {
|
|
106
|
+
if (typeof str !== 'string') {
|
|
107
|
+
throw new TypeError('Expected a string');
|
|
108
|
+
}
|
|
109
|
+
return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
|
|
110
|
+
}
|
|
111
|
+
const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
|
|
112
|
+
const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
|
|
113
|
+
function handleRegexp(reg) {
|
|
114
|
+
return `(?:${reg.source})`;
|
|
115
|
+
}
|
|
116
|
+
function getSourceString(input) {
|
|
117
|
+
let result;
|
|
118
|
+
if (typeof input === 'string') {
|
|
119
|
+
result = input;
|
|
120
|
+
}
|
|
121
|
+
else if (isRegexp(input)) {
|
|
122
|
+
result = input.source;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
result = input.toString();
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
function makePattern(arr) {
|
|
130
|
+
let pattern = '';
|
|
131
|
+
if (Array.isArray(arr)) {
|
|
132
|
+
pattern = arr
|
|
133
|
+
.reduce((acc, cur) => {
|
|
134
|
+
if (typeof cur === 'string') {
|
|
135
|
+
acc.push(cur);
|
|
136
|
+
}
|
|
137
|
+
else if (isRegexp(cur)) {
|
|
138
|
+
acc.push(handleRegexp(cur));
|
|
139
|
+
}
|
|
140
|
+
return acc;
|
|
141
|
+
}, [])
|
|
142
|
+
.join('|');
|
|
143
|
+
}
|
|
144
|
+
else if (typeof arr === 'string') {
|
|
145
|
+
pattern = arr;
|
|
146
|
+
}
|
|
147
|
+
else if (isRegexp(arr)) {
|
|
148
|
+
pattern = handleRegexp(arr);
|
|
149
|
+
}
|
|
150
|
+
return pattern;
|
|
151
|
+
}
|
|
152
|
+
function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
|
|
153
|
+
const { exact = true } = options;
|
|
154
|
+
const prefix = exact ? '(?<=^|\\s)' : '';
|
|
155
|
+
const pattern = makePattern(attrs);
|
|
156
|
+
let tagPattern = getSourceString(tag);
|
|
157
|
+
if (tagPattern === '*') {
|
|
158
|
+
tagPattern = '[a-z][-a-z]*[a-z]*';
|
|
159
|
+
}
|
|
160
|
+
const source = `<(${tagPattern})\\s+[^>]*?(?:${prefix}(${pattern})="(?:[^"]*)")[^>]*?\\/?>`;
|
|
161
|
+
return new RegExp(source, 'g');
|
|
162
|
+
}
|
|
163
|
+
function createTemplateClassRegexp(attrs, options = {}) {
|
|
164
|
+
const { exact = true } = options;
|
|
165
|
+
const prefix = exact ? '(?<=^|\\s)' : '';
|
|
166
|
+
const pattern = makePattern(attrs);
|
|
167
|
+
const source = `(?:${prefix}${pattern})=(?:["']\\W+\\s*(?:\\w+)\\()?["']([^"]+)['"]`;
|
|
168
|
+
return new RegExp(source, 'gs');
|
|
169
|
+
}
|
|
170
|
+
function makeCustomAttributes(entries) {
|
|
171
|
+
if (Array.isArray(entries)) {
|
|
172
|
+
return entries.map(([k, v]) => {
|
|
173
|
+
return {
|
|
174
|
+
tagRegexp: createTempleteHandlerMatchRegexp(k, v),
|
|
175
|
+
attrRegexp: createTemplateClassRegexp(v),
|
|
176
|
+
tag: getSourceString(k),
|
|
177
|
+
attrs: v
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const variableRegExp = /{{(.*?)}}/gs;
|
|
183
|
+
function variableMatch(original) {
|
|
184
|
+
return variableRegExp.exec(original);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
188
|
+
function isValidSelector(selector = '') {
|
|
189
|
+
return validateFilterRE.test(selector);
|
|
190
|
+
}
|
|
191
|
+
const splitCode = (code, allowDoubleQuotes = false) => {
|
|
192
|
+
const splitter = allowDoubleQuotes ? /\s+/ : /\s+|"/;
|
|
193
|
+
return code.split(splitter).filter((element) => isValidSelector(element));
|
|
194
|
+
};
|
|
195
|
+
|
|
58
196
|
const isProd = () => process.env.NODE_ENV === 'production';
|
|
59
197
|
|
|
60
198
|
function handleValue(str, node, options) {
|
|
199
|
+
var _a;
|
|
61
200
|
const set = options.classNameSet;
|
|
62
201
|
const escapeMap = options.escapeMap;
|
|
63
|
-
const
|
|
202
|
+
const allowDoubleQuotes = (_a = options.arbitraryValues) === null || _a === void 0 ? void 0 : _a.allowDoubleQuotes;
|
|
203
|
+
const ctx = options.mangleContext;
|
|
204
|
+
const arr = splitCode(str, allowDoubleQuotes);
|
|
64
205
|
let rawStr = str;
|
|
65
206
|
for (const v of arr) {
|
|
66
207
|
if (set.has(v)) {
|
|
@@ -69,8 +210,9 @@ function handleValue(str, node, options) {
|
|
|
69
210
|
ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('weapp-tw') && x.value.includes('ignore')) > -1;
|
|
70
211
|
}
|
|
71
212
|
if (!ignoreFlag) {
|
|
72
|
-
|
|
73
|
-
|
|
213
|
+
if (ctx) {
|
|
214
|
+
rawStr = ctx.jsHandler(rawStr);
|
|
215
|
+
}
|
|
74
216
|
rawStr = rawStr.replaceAll(new RegExp(escapeStringRegexp(v), 'g'), replaceWxml(v, {
|
|
75
217
|
escapeMap
|
|
76
218
|
}));
|
|
@@ -116,11 +258,14 @@ function jsHandler(rawSource, options) {
|
|
|
116
258
|
});
|
|
117
259
|
}
|
|
118
260
|
function createjsHandler(options) {
|
|
261
|
+
const { mangleContext, arbitraryValues, minifiedJs, escapeMap } = options;
|
|
119
262
|
return (rawSource, set) => {
|
|
120
263
|
return jsHandler(rawSource, {
|
|
121
264
|
classNameSet: set,
|
|
122
|
-
minifiedJs
|
|
123
|
-
escapeMap
|
|
265
|
+
minifiedJs,
|
|
266
|
+
escapeMap,
|
|
267
|
+
arbitraryValues,
|
|
268
|
+
mangleContext
|
|
124
269
|
});
|
|
125
270
|
};
|
|
126
271
|
}
|
|
@@ -191,7 +336,10 @@ const defaultOptions = {
|
|
|
191
336
|
overwrite: true
|
|
192
337
|
}
|
|
193
338
|
},
|
|
194
|
-
appType: undefined
|
|
339
|
+
appType: undefined,
|
|
340
|
+
arbitraryValues: {
|
|
341
|
+
allowDoubleQuotes: false
|
|
342
|
+
}
|
|
195
343
|
};
|
|
196
344
|
|
|
197
345
|
function generateCode(match, options = {}) {
|
|
@@ -246,7 +394,8 @@ function templeteReplacer(original, options = {}) {
|
|
|
246
394
|
const before = original.slice(p, m.start);
|
|
247
395
|
resultArray.push(replaceWxml(before, {
|
|
248
396
|
keepEOL: true,
|
|
249
|
-
escapeMap: options.escapeMap
|
|
397
|
+
escapeMap: options.escapeMap,
|
|
398
|
+
mangleContext: options.mangleContext
|
|
250
399
|
}));
|
|
251
400
|
p = m.start;
|
|
252
401
|
if (m.raw.trim().length > 0) {
|
|
@@ -263,19 +412,18 @@ function templeteReplacer(original, options = {}) {
|
|
|
263
412
|
const after = original.slice(m.end);
|
|
264
413
|
resultArray.push(replaceWxml(after, {
|
|
265
414
|
keepEOL: true,
|
|
266
|
-
escapeMap: options.escapeMap
|
|
415
|
+
escapeMap: options.escapeMap,
|
|
416
|
+
mangleContext: options.mangleContext
|
|
267
417
|
}));
|
|
268
418
|
}
|
|
269
419
|
}
|
|
270
|
-
return resultArray
|
|
271
|
-
.filter(Boolean)
|
|
272
|
-
.join('')
|
|
273
|
-
.trim();
|
|
420
|
+
return resultArray.filter(Boolean).join('').trim();
|
|
274
421
|
}
|
|
275
422
|
else {
|
|
276
423
|
return replaceWxml(original, {
|
|
277
424
|
keepEOL: false,
|
|
278
|
-
escapeMap: options.escapeMap
|
|
425
|
+
escapeMap: options.escapeMap,
|
|
426
|
+
mangleContext: options.mangleContext
|
|
279
427
|
});
|
|
280
428
|
}
|
|
281
429
|
}
|
|
@@ -453,6 +601,72 @@ function createTailwindcssPatcher() {
|
|
|
453
601
|
});
|
|
454
602
|
}
|
|
455
603
|
|
|
604
|
+
function getSelf(x) {
|
|
605
|
+
return x;
|
|
606
|
+
}
|
|
607
|
+
const defaultMangleContext = {
|
|
608
|
+
rawOptions: false,
|
|
609
|
+
runtimeSet: new Set(),
|
|
610
|
+
classGenerator: new ClassGenerator(),
|
|
611
|
+
filter: defaultMangleClassFilter,
|
|
612
|
+
cssHandler: getSelf,
|
|
613
|
+
jsHandler: getSelf,
|
|
614
|
+
wxmlHandler: getSelf
|
|
615
|
+
};
|
|
616
|
+
function useMangleStore() {
|
|
617
|
+
const ctx = Object.assign({}, defaultMangleContext);
|
|
618
|
+
function resetMangle() {
|
|
619
|
+
return Object.assign(ctx, defaultMangleContext);
|
|
620
|
+
}
|
|
621
|
+
function handleValue(rawSource) {
|
|
622
|
+
const arr = splitCode(rawSource);
|
|
623
|
+
for (const x of arr) {
|
|
624
|
+
if (ctx.runtimeSet.has(x)) {
|
|
625
|
+
rawSource = rawSource.replaceAll(new RegExp(escapeStringRegexp(x), 'g'), ctx.classGenerator.generateClassName(x).name);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return rawSource;
|
|
629
|
+
}
|
|
630
|
+
function initMangle(options) {
|
|
631
|
+
var _a;
|
|
632
|
+
ctx.rawOptions = options;
|
|
633
|
+
if (options) {
|
|
634
|
+
if (options === true) {
|
|
635
|
+
options = {
|
|
636
|
+
classGenerator: {},
|
|
637
|
+
mangleClassFilter: defaultMangleClassFilter
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
ctx.classGenerator = new ClassGenerator(options.classGenerator);
|
|
641
|
+
ctx.filter = (_a = options.mangleClassFilter) !== null && _a !== void 0 ? _a : defaultMangleClassFilter;
|
|
642
|
+
ctx.jsHandler = (rawSource) => {
|
|
643
|
+
return handleValue(rawSource);
|
|
644
|
+
};
|
|
645
|
+
ctx.cssHandler = (rawSource) => {
|
|
646
|
+
return handleValue(rawSource);
|
|
647
|
+
};
|
|
648
|
+
ctx.wxmlHandler = (rawSource) => {
|
|
649
|
+
return handleValue(rawSource);
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function setMangleRuntimeSet(runtimeSet) {
|
|
654
|
+
const newSet = new Set();
|
|
655
|
+
for (const c of runtimeSet) {
|
|
656
|
+
if (ctx.filter(c)) {
|
|
657
|
+
newSet.add(c);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
ctx.runtimeSet = newSet;
|
|
661
|
+
}
|
|
662
|
+
return {
|
|
663
|
+
mangleContext: ctx,
|
|
664
|
+
resetMangle,
|
|
665
|
+
initMangle,
|
|
666
|
+
setMangleRuntimeSet
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
456
670
|
function createGlobMatcher(pattern) {
|
|
457
671
|
return function (file) {
|
|
458
672
|
return isMatch(file, pattern);
|
|
@@ -463,18 +677,7 @@ function normalizeMatcher(options, key) {
|
|
|
463
677
|
options[key] = createGlobMatcher(options[key]);
|
|
464
678
|
}
|
|
465
679
|
}
|
|
466
|
-
function getOptions(options = {}
|
|
467
|
-
const registerModules = modules.reduce((acc, cur) => {
|
|
468
|
-
if (acc[cur] !== undefined) {
|
|
469
|
-
acc[cur] = true;
|
|
470
|
-
}
|
|
471
|
-
return acc;
|
|
472
|
-
}, {
|
|
473
|
-
templete: false,
|
|
474
|
-
style: false,
|
|
475
|
-
patch: false,
|
|
476
|
-
js: false
|
|
477
|
-
});
|
|
680
|
+
function getOptions(options = {}) {
|
|
478
681
|
if (options.supportCustomLengthUnitsPatch === true) {
|
|
479
682
|
options.supportCustomLengthUnitsPatch = undefined;
|
|
480
683
|
}
|
|
@@ -491,36 +694,37 @@ function getOptions(options = {}, modules = ['style', 'templete', 'patch', 'js']
|
|
|
491
694
|
const result = defu(options, defaultOptions, {
|
|
492
695
|
minifiedJs: isProd()
|
|
493
696
|
});
|
|
494
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch } = result;
|
|
697
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues } = result;
|
|
495
698
|
result.escapeMap = customReplaceDictionary;
|
|
496
699
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
497
|
-
const customAttributesEntities = isMap(options.customAttributes)
|
|
700
|
+
const customAttributesEntities = isMap(options.customAttributes)
|
|
701
|
+
? [...options.customAttributes.entries()]
|
|
702
|
+
: Object.entries(customAttributes);
|
|
498
703
|
const { escapeMap, minifiedJs } = result;
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
704
|
+
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
705
|
+
initMangle(options.mangle);
|
|
706
|
+
result.templeteHandler = createTempleteHandler({
|
|
707
|
+
customAttributesEntities,
|
|
708
|
+
escapeMap,
|
|
709
|
+
mangleContext
|
|
710
|
+
});
|
|
711
|
+
result.styleHandler = createStyleHandler({
|
|
712
|
+
cssInjectPreflight,
|
|
713
|
+
customRuleCallback,
|
|
714
|
+
cssPreflightRange,
|
|
715
|
+
replaceUniversalSelectorWith,
|
|
716
|
+
escapeMap,
|
|
717
|
+
mangleContext
|
|
718
|
+
});
|
|
719
|
+
result.jsHandler = createjsHandler({
|
|
720
|
+
minifiedJs,
|
|
721
|
+
escapeMap,
|
|
722
|
+
mangleContext,
|
|
723
|
+
arbitraryValues
|
|
724
|
+
});
|
|
725
|
+
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
726
|
+
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
523
727
|
return result;
|
|
524
728
|
}
|
|
525
729
|
|
|
526
|
-
export { createTailwindcssPatcher as a, createPatch as c, getOptions as g };
|
|
730
|
+
export { createTailwindcssPatcher as a, getGroupedEntries as b, createPatch as c, getOptions as g };
|
package/dist/options.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { InternalUserDefinedOptions, UserDefinedOptions } from './types';
|
|
2
|
-
|
|
3
|
-
export declare function getOptions(options?: UserDefinedOptions, modules?: IModules): InternalUserDefinedOptions;
|
|
4
|
-
export {};
|
|
2
|
+
export declare function getOptions(options?: UserDefinedOptions): InternalUserDefinedOptions;
|
package/dist/postcss/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IStyleHandlerOptions } from "../types";
|
|
2
2
|
export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): string;
|
|
3
|
-
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt
|
|
3
|
+
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => string;
|
package/dist/postcss/shared.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { InternalCssSelectorReplacerOptions } from "../types";
|
|
2
|
+
export declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
|
|
3
|
+
export declare function cssUnescape(value: string): string;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import selectorParser from 'postcss-selector-parser';
|
|
2
|
-
import {
|
|
2
|
+
import { i as internalCssSelectorReplacer } from './shared-fc50603a.mjs';
|
|
3
3
|
import { Rule, Declaration } from 'postcss';
|
|
4
4
|
import '@csstools/postcss-is-pseudo-class';
|
|
5
5
|
|
|
6
6
|
const createTransform = (rule, options) => {
|
|
7
|
-
const
|
|
7
|
+
const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
|
|
8
|
+
const replaceFlag = replaceUniversalSelectorWith !== false;
|
|
8
9
|
const transform = (selectors) => {
|
|
9
10
|
selectors.walk((selector) => {
|
|
10
11
|
if (selector.type === 'universal' && replaceFlag) {
|
|
11
|
-
selector.value =
|
|
12
|
+
selector.value = replaceUniversalSelectorWith;
|
|
12
13
|
}
|
|
13
14
|
if (selector.type === 'selector') {
|
|
14
15
|
const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
|
|
15
16
|
node && selector.remove();
|
|
16
17
|
}
|
|
17
18
|
if (selector.type === 'class') {
|
|
18
|
-
selector.value = internalCssSelectorReplacer(selector.value,
|
|
19
|
+
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
20
|
+
escapeMap,
|
|
21
|
+
mangleContext
|
|
22
|
+
});
|
|
19
23
|
}
|
|
20
24
|
});
|
|
21
25
|
if (selectors.length === 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var selectorParser = require('postcss-selector-parser');
|
|
4
|
-
var shared = require('./shared-
|
|
4
|
+
var shared = require('./shared-cdb5ee55.js');
|
|
5
5
|
var postcss = require('postcss');
|
|
6
6
|
require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
|
|
@@ -10,18 +10,22 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var selectorParser__default = /*#__PURE__*/_interopDefaultCompat(selectorParser);
|
|
11
11
|
|
|
12
12
|
const createTransform = (rule, options) => {
|
|
13
|
-
const
|
|
13
|
+
const { replaceUniversalSelectorWith, escapeMap, mangleContext } = options;
|
|
14
|
+
const replaceFlag = replaceUniversalSelectorWith !== false;
|
|
14
15
|
const transform = (selectors) => {
|
|
15
16
|
selectors.walk((selector) => {
|
|
16
17
|
if (selector.type === 'universal' && replaceFlag) {
|
|
17
|
-
selector.value =
|
|
18
|
+
selector.value = replaceUniversalSelectorWith;
|
|
18
19
|
}
|
|
19
20
|
if (selector.type === 'selector') {
|
|
20
21
|
const node = selector.nodes.find((x) => x.type === 'pseudo' && x.value === ':hover');
|
|
21
22
|
node && selector.remove();
|
|
22
23
|
}
|
|
23
24
|
if (selector.type === 'class') {
|
|
24
|
-
selector.value = shared.internalCssSelectorReplacer(selector.value,
|
|
25
|
+
selector.value = shared.internalCssSelectorReplacer(selector.value, {
|
|
26
|
+
escapeMap,
|
|
27
|
+
mangleContext
|
|
28
|
+
});
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
if (selectors.length === 0) {
|
package/dist/postcss.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var postcss = require('./postcss-
|
|
5
|
+
var postcss = require('./postcss-b8952a11.js');
|
|
6
6
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
require('postcss-selector-parser');
|
|
8
|
-
require('./shared-
|
|
9
|
-
require('tailwindcss-mangle-shared');
|
|
8
|
+
require('./shared-cdb5ee55.js');
|
|
10
9
|
require('postcss');
|
|
11
10
|
|
|
12
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
package/dist/postcss.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { p as postcssWeappTailwindcss } from './postcss-
|
|
1
|
+
export { p as postcssWeappTailwindcss } from './postcss-15e2ef2d.mjs';
|
|
2
2
|
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
|
3
3
|
import 'postcss-selector-parser';
|
|
4
|
-
import './shared-
|
|
5
|
-
import 'tailwindcss-mangle-shared';
|
|
4
|
+
import './shared-fc50603a.mjs';
|
|
6
5
|
import 'postcss';
|
package/dist/replace.js
CHANGED
|
@@ -2,27 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var shared = require('./shared-
|
|
6
|
-
require('tailwindcss-mangle-shared');
|
|
5
|
+
var shared = require('./shared-cdb5ee55.js');
|
|
7
6
|
|
|
8
7
|
function replaceWxml(original, options = {
|
|
9
8
|
keepEOL: false,
|
|
10
9
|
escapeMap: shared.SimpleMappingChars2String
|
|
11
10
|
}) {
|
|
12
|
-
|
|
13
|
-
options = {
|
|
14
|
-
keepEOL: options
|
|
15
|
-
};
|
|
16
|
-
}
|
|
11
|
+
const { keepEOL, escapeMap, mangleContext } = options;
|
|
17
12
|
let res = original;
|
|
18
|
-
if (!
|
|
13
|
+
if (!keepEOL) {
|
|
19
14
|
res = res
|
|
20
15
|
.replaceAll(/[\n\r]+/g, '');
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
if (mangleContext) {
|
|
18
|
+
res = mangleContext.wxmlHandler(res);
|
|
19
|
+
}
|
|
24
20
|
res = shared.escape(res, {
|
|
25
|
-
map:
|
|
21
|
+
map: escapeMap
|
|
26
22
|
});
|
|
27
23
|
return res;
|
|
28
24
|
}
|
package/dist/replace.mjs
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { M as MappingChars2String,
|
|
3
|
-
import 'tailwindcss-mangle-shared';
|
|
1
|
+
import { e as escape, S as SimpleMappingChars2String } from './shared-fc50603a.mjs';
|
|
2
|
+
export { M as MappingChars2String, b as MappingChars2StringEntries, a as SYMBOL_TABLE, c as SimpleMappingChars2StringEntries, i as replaceCss } from './shared-fc50603a.mjs';
|
|
4
3
|
|
|
5
4
|
function replaceWxml(original, options = {
|
|
6
5
|
keepEOL: false,
|
|
7
6
|
escapeMap: SimpleMappingChars2String
|
|
8
7
|
}) {
|
|
9
|
-
|
|
10
|
-
options = {
|
|
11
|
-
keepEOL: options
|
|
12
|
-
};
|
|
13
|
-
}
|
|
8
|
+
const { keepEOL, escapeMap, mangleContext } = options;
|
|
14
9
|
let res = original;
|
|
15
|
-
if (!
|
|
10
|
+
if (!keepEOL) {
|
|
16
11
|
res = res
|
|
17
12
|
.replaceAll(/[\n\r]+/g, '');
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (mangleContext) {
|
|
15
|
+
res = mangleContext.wxmlHandler(res);
|
|
16
|
+
}
|
|
21
17
|
res = escape(res, {
|
|
22
|
-
map:
|
|
18
|
+
map: escapeMap
|
|
23
19
|
});
|
|
24
20
|
return res;
|
|
25
21
|
}
|