weapp-tailwindcss 2.4.3 → 2.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.
- package/dist/cli.js +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/constants.d.ts +1 -1
- package/dist/gulp.js +10 -8
- package/dist/gulp.mjs +10 -8
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/dist/{options-a2ba3653.mjs → options-1e3a224a.mjs} +51 -37
- package/dist/{options-2e71e6b3.js → options-ad127e0c.js} +51 -37
- package/dist/postcss/plugin.d.ts +1 -1
- package/dist/postcss/shared.d.ts +1 -1
- package/dist/{postcss-15e2ef2d.mjs → postcss-9a63df9d.mjs} +11 -4
- package/dist/{postcss-b8952a11.js → postcss-fbdc673b.js} +10 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/reg.d.ts +1 -1
- package/dist/replace.js +1 -1
- package/dist/replace.mjs +2 -2
- package/dist/{shared-fc50603a.mjs → shared-7c88fb94.mjs} +19 -2
- package/dist/{shared-cdb5ee55.js → shared-ae7dd073.js} +19 -2
- package/dist/types.d.ts +8 -3
- package/dist/vite.js +9 -7
- package/dist/vite.mjs +9 -7
- package/dist/weapp-tw-runtime-loader.js +16 -0
- package/dist/weapp-tw-runtime-loader.mjs +10 -0
- package/dist/webpack/BaseUnifiedPlugin/v5.d.ts +0 -1
- package/dist/webpack/loaders/weapp-tw-runtime-loader.d.ts +5 -0
- package/dist/webpack.js +37 -20
- package/dist/webpack.mjs +32 -20
- package/dist/wxml/index.d.ts +1 -1
- package/dist/wxml/utils.d.ts +2 -2
- package/package.json +22 -17
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var options = require('./options-
|
|
3
|
+
var options = require('./options-ad127e0c.js');
|
|
4
4
|
require('micromatch');
|
|
5
5
|
require('@babel/types');
|
|
6
6
|
require('@babel/generator');
|
|
7
7
|
require('@babel/parser');
|
|
8
8
|
require('@babel/traverse');
|
|
9
9
|
require('./replace.js');
|
|
10
|
-
require('./shared-
|
|
10
|
+
require('./shared-ae7dd073.js');
|
|
11
11
|
require('postcss');
|
|
12
|
-
require('./postcss-
|
|
12
|
+
require('./postcss-fbdc673b.js');
|
|
13
13
|
require('postcss-selector-parser');
|
|
14
14
|
require('@csstools/postcss-is-pseudo-class');
|
|
15
15
|
require('node:path');
|
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { g as getOptions, c as createPatch } from './options-
|
|
1
|
+
import { g as getOptions, c as createPatch } from './options-1e3a224a.mjs';
|
|
2
2
|
import 'micromatch';
|
|
3
3
|
import '@babel/types';
|
|
4
4
|
import '@babel/generator';
|
|
5
5
|
import '@babel/parser';
|
|
6
6
|
import '@babel/traverse';
|
|
7
7
|
import './replace.mjs';
|
|
8
|
-
import './shared-
|
|
8
|
+
import './shared-7c88fb94.mjs';
|
|
9
9
|
import 'postcss';
|
|
10
|
-
import './postcss-
|
|
10
|
+
import './postcss-9a63df9d.mjs';
|
|
11
11
|
import 'postcss-selector-parser';
|
|
12
12
|
import '@csstools/postcss-is-pseudo-class';
|
|
13
13
|
import 'node:path';
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const runtimeAopLoader = "weapp-tw-runtime-aop-loader";
|
|
2
2
|
export declare const postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
3
3
|
export declare const ManglePluginHooks = "ManglePluginHooks";
|
|
4
4
|
export declare const WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks = "WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks";
|
package/dist/gulp.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var stream = require('node:stream');
|
|
6
|
-
var options = require('./options-
|
|
6
|
+
var options = require('./options-ad127e0c.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('@babel/types');
|
|
9
9
|
require('@babel/generator');
|
|
10
10
|
require('@babel/parser');
|
|
11
11
|
require('@babel/traverse');
|
|
12
12
|
require('./replace.js');
|
|
13
|
-
require('./shared-
|
|
13
|
+
require('./shared-ae7dd073.js');
|
|
14
14
|
require('postcss');
|
|
15
|
-
require('./postcss-
|
|
15
|
+
require('./postcss-fbdc673b.js');
|
|
16
16
|
require('postcss-selector-parser');
|
|
17
17
|
require('@csstools/postcss-is-pseudo-class');
|
|
18
18
|
require('node:path');
|
|
@@ -32,14 +32,14 @@ function createPlugins(options$1 = {}) {
|
|
|
32
32
|
}
|
|
33
33
|
const opts = options.getOptions(options$1);
|
|
34
34
|
const { templeteHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
35
|
-
let
|
|
35
|
+
let runtimeSet = new Set();
|
|
36
36
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
37
37
|
const twPatcher = options.createTailwindcssPatcher();
|
|
38
38
|
function transformWxss() {
|
|
39
39
|
const transformStream = new Transform({ objectMode: true });
|
|
40
40
|
transformStream._transform = function (file, encoding, callback) {
|
|
41
|
-
|
|
42
|
-
setMangleRuntimeSet(
|
|
41
|
+
runtimeSet = twPatcher.getClassSet();
|
|
42
|
+
setMangleRuntimeSet(runtimeSet);
|
|
43
43
|
const error = null;
|
|
44
44
|
if (file.contents) {
|
|
45
45
|
const code = styleHandler(file.contents.toString(), {
|
|
@@ -56,7 +56,7 @@ function createPlugins(options$1 = {}) {
|
|
|
56
56
|
transformStream._transform = function (file, encoding, callback) {
|
|
57
57
|
const error = null;
|
|
58
58
|
if (file.contents) {
|
|
59
|
-
const { code } = jsHandler(file.contents.toString(),
|
|
59
|
+
const { code } = jsHandler(file.contents.toString(), runtimeSet);
|
|
60
60
|
file.contents = Buffer.from(code);
|
|
61
61
|
}
|
|
62
62
|
callback(error, file);
|
|
@@ -68,7 +68,9 @@ function createPlugins(options$1 = {}) {
|
|
|
68
68
|
transformStream._transform = function (file, encoding, callback) {
|
|
69
69
|
const error = null;
|
|
70
70
|
if (file.contents) {
|
|
71
|
-
const code = templeteHandler(file.contents.toString()
|
|
71
|
+
const code = templeteHandler(file.contents.toString(), {
|
|
72
|
+
runtimeSet
|
|
73
|
+
});
|
|
72
74
|
file.contents = Buffer.from(code);
|
|
73
75
|
}
|
|
74
76
|
callback(error, file);
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import stream from 'node:stream';
|
|
2
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
2
|
+
import { g as getOptions, a as createTailwindcssPatcher } from './options-1e3a224a.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import '@babel/types';
|
|
5
5
|
import '@babel/generator';
|
|
6
6
|
import '@babel/parser';
|
|
7
7
|
import '@babel/traverse';
|
|
8
8
|
import './replace.mjs';
|
|
9
|
-
import './shared-
|
|
9
|
+
import './shared-7c88fb94.mjs';
|
|
10
10
|
import 'postcss';
|
|
11
|
-
import './postcss-
|
|
11
|
+
import './postcss-9a63df9d.mjs';
|
|
12
12
|
import 'postcss-selector-parser';
|
|
13
13
|
import '@csstools/postcss-is-pseudo-class';
|
|
14
14
|
import 'node:path';
|
|
@@ -24,14 +24,14 @@ function createPlugins(options = {}) {
|
|
|
24
24
|
}
|
|
25
25
|
const opts = getOptions(options);
|
|
26
26
|
const { templeteHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
27
|
-
let
|
|
27
|
+
let runtimeSet = new Set();
|
|
28
28
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
29
29
|
const twPatcher = createTailwindcssPatcher();
|
|
30
30
|
function transformWxss() {
|
|
31
31
|
const transformStream = new Transform({ objectMode: true });
|
|
32
32
|
transformStream._transform = function (file, encoding, callback) {
|
|
33
|
-
|
|
34
|
-
setMangleRuntimeSet(
|
|
33
|
+
runtimeSet = twPatcher.getClassSet();
|
|
34
|
+
setMangleRuntimeSet(runtimeSet);
|
|
35
35
|
const error = null;
|
|
36
36
|
if (file.contents) {
|
|
37
37
|
const code = styleHandler(file.contents.toString(), {
|
|
@@ -48,7 +48,7 @@ function createPlugins(options = {}) {
|
|
|
48
48
|
transformStream._transform = function (file, encoding, callback) {
|
|
49
49
|
const error = null;
|
|
50
50
|
if (file.contents) {
|
|
51
|
-
const { code } = jsHandler(file.contents.toString(),
|
|
51
|
+
const { code } = jsHandler(file.contents.toString(), runtimeSet);
|
|
52
52
|
file.contents = Buffer.from(code);
|
|
53
53
|
}
|
|
54
54
|
callback(error, file);
|
|
@@ -60,7 +60,9 @@ function createPlugins(options = {}) {
|
|
|
60
60
|
transformStream._transform = function (file, encoding, callback) {
|
|
61
61
|
const error = null;
|
|
62
62
|
if (file.contents) {
|
|
63
|
-
const code = templeteHandler(file.contents.toString()
|
|
63
|
+
const code = templeteHandler(file.contents.toString(), {
|
|
64
|
+
runtimeSet
|
|
65
|
+
});
|
|
64
66
|
file.contents = Buffer.from(code);
|
|
65
67
|
}
|
|
66
68
|
callback(error, file);
|
package/dist/index.js
CHANGED
|
@@ -5,20 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var webpack = require('./webpack.js');
|
|
6
6
|
var vite = require('./vite.js');
|
|
7
7
|
var gulp = require('./gulp.js');
|
|
8
|
-
require('
|
|
8
|
+
require('node:path');
|
|
9
|
+
require('node:fs');
|
|
10
|
+
require('./options-ad127e0c.js');
|
|
9
11
|
require('micromatch');
|
|
10
12
|
require('@babel/types');
|
|
11
13
|
require('@babel/generator');
|
|
12
14
|
require('@babel/parser');
|
|
13
15
|
require('@babel/traverse');
|
|
14
16
|
require('./replace.js');
|
|
15
|
-
require('./shared-
|
|
17
|
+
require('./shared-ae7dd073.js');
|
|
16
18
|
require('postcss');
|
|
17
|
-
require('./postcss-
|
|
19
|
+
require('./postcss-fbdc673b.js');
|
|
18
20
|
require('postcss-selector-parser');
|
|
19
21
|
require('@csstools/postcss-is-pseudo-class');
|
|
20
|
-
require('node:path');
|
|
21
|
-
require('node:fs');
|
|
22
22
|
require('semver');
|
|
23
23
|
require('tailwindcss-patch');
|
|
24
24
|
require('tailwindcss-mangle-shared');
|
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export { UnifiedWebpackPluginV5 } from './webpack.mjs';
|
|
2
2
|
export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
|
-
import '
|
|
4
|
+
import 'node:path';
|
|
5
|
+
import 'node:fs';
|
|
6
|
+
import './options-1e3a224a.mjs';
|
|
5
7
|
import 'micromatch';
|
|
6
8
|
import '@babel/types';
|
|
7
9
|
import '@babel/generator';
|
|
8
10
|
import '@babel/parser';
|
|
9
11
|
import '@babel/traverse';
|
|
10
12
|
import './replace.mjs';
|
|
11
|
-
import './shared-
|
|
13
|
+
import './shared-7c88fb94.mjs';
|
|
12
14
|
import 'postcss';
|
|
13
|
-
import './postcss-
|
|
15
|
+
import './postcss-9a63df9d.mjs';
|
|
14
16
|
import 'postcss-selector-parser';
|
|
15
17
|
import '@csstools/postcss-is-pseudo-class';
|
|
16
|
-
import 'node:path';
|
|
17
|
-
import 'node:fs';
|
|
18
18
|
import 'semver';
|
|
19
19
|
import 'tailwindcss-patch';
|
|
20
20
|
import 'tailwindcss-mangle-shared';
|
|
@@ -4,9 +4,9 @@ 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 { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-
|
|
7
|
+
import { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-7c88fb94.mjs';
|
|
8
8
|
import postcss from 'postcss';
|
|
9
|
-
import { p as postcssWeappTailwindcss } from './postcss-
|
|
9
|
+
import { p as postcssWeappTailwindcss } from './postcss-9a63df9d.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';
|
|
@@ -84,7 +84,7 @@ function groupBy(arr, cb) {
|
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
86
|
function getGroupedEntries(entries, options) {
|
|
87
|
-
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
87
|
+
const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
|
|
88
88
|
const groupedEntries = groupBy(entries, ([file]) => {
|
|
89
89
|
if (cssMatcher(file)) {
|
|
90
90
|
return 'css';
|
|
@@ -92,7 +92,7 @@ function getGroupedEntries(entries, options) {
|
|
|
92
92
|
else if (htmlMatcher(file)) {
|
|
93
93
|
return 'html';
|
|
94
94
|
}
|
|
95
|
-
else if (jsMatcher(file)) {
|
|
95
|
+
else if (jsMatcher(file) || wxsMatcher(file)) {
|
|
96
96
|
return 'js';
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
@@ -180,9 +180,7 @@ function makeCustomAttributes(entries) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
const variableRegExp = /{{(.*?)}}/gs;
|
|
183
|
-
|
|
184
|
-
return variableRegExp.exec(original);
|
|
185
|
-
}
|
|
183
|
+
const wxsTagRegexp = /<wxs\s*(?:[a-z][a-z-]*[a-z]*(?:\s*=\s*".*?")?)*\s*>(.*?)<\/wxs>/gs;
|
|
186
184
|
|
|
187
185
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
188
186
|
function isValidSelector(selector = '') {
|
|
@@ -310,6 +308,9 @@ const defaultOptions = {
|
|
|
310
308
|
}
|
|
311
309
|
}
|
|
312
310
|
},
|
|
311
|
+
wxsMatcher: (file) => {
|
|
312
|
+
return false;
|
|
313
|
+
},
|
|
313
314
|
cssPreflight: {
|
|
314
315
|
'box-sizing': 'border-box',
|
|
315
316
|
'border-width': '0',
|
|
@@ -339,7 +340,9 @@ const defaultOptions = {
|
|
|
339
340
|
appType: undefined,
|
|
340
341
|
arbitraryValues: {
|
|
341
342
|
allowDoubleQuotes: false
|
|
342
|
-
}
|
|
343
|
+
},
|
|
344
|
+
cssChildCombinatorReplaceValue: 'view + view',
|
|
345
|
+
inlineWxs: false
|
|
343
346
|
};
|
|
344
347
|
|
|
345
348
|
function generateCode(match, options = {}) {
|
|
@@ -367,23 +370,24 @@ function generateCode(match, options = {}) {
|
|
|
367
370
|
});
|
|
368
371
|
return code;
|
|
369
372
|
}
|
|
370
|
-
function
|
|
371
|
-
let match =
|
|
373
|
+
function extract(original, reg) {
|
|
374
|
+
let match = reg.exec(original);
|
|
372
375
|
const sources = [];
|
|
373
376
|
while (match !== null) {
|
|
374
377
|
const start = match.index;
|
|
375
|
-
const end =
|
|
378
|
+
const end = reg.lastIndex;
|
|
376
379
|
sources.push({
|
|
377
380
|
start,
|
|
378
381
|
end,
|
|
379
|
-
raw: match[1]
|
|
380
|
-
prevConcatenated: !/\s/.test(original[start - 1]),
|
|
381
|
-
nextConcatenated: !/\s/.test(original[end])
|
|
382
|
+
raw: match[1]
|
|
382
383
|
});
|
|
383
|
-
match =
|
|
384
|
+
match = reg.exec(original);
|
|
384
385
|
}
|
|
385
386
|
return sources;
|
|
386
387
|
}
|
|
388
|
+
function extractSource(original) {
|
|
389
|
+
return extract(original, variableRegExp);
|
|
390
|
+
}
|
|
387
391
|
function templeteReplacer(original, options = {}) {
|
|
388
392
|
const sources = extractSource(original);
|
|
389
393
|
if (sources.length > 0) {
|
|
@@ -434,24 +438,27 @@ function templeteHandler(rawSource, options = {}) {
|
|
|
434
438
|
});
|
|
435
439
|
});
|
|
436
440
|
}
|
|
437
|
-
function customTempleteHandler(rawSource, options
|
|
441
|
+
function customTempleteHandler(rawSource, options) {
|
|
442
|
+
const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
|
|
438
443
|
let source = templeteHandler(rawSource, options);
|
|
439
|
-
const regexps = makeCustomAttributes(
|
|
440
|
-
if (regexps) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return
|
|
445
|
-
return m1.replace(className, templeteReplacer(className, options));
|
|
446
|
-
});
|
|
444
|
+
const regexps = makeCustomAttributes(customAttributesEntities);
|
|
445
|
+
if (regexps && Array.isArray(regexps)) {
|
|
446
|
+
for (const regexp of regexps) {
|
|
447
|
+
source = source.replace(regexp.tagRegexp, (m0) => {
|
|
448
|
+
return m0.replace(regexp.attrRegexp, (m1, className) => {
|
|
449
|
+
return m1.replace(className, templeteReplacer(className, options));
|
|
447
450
|
});
|
|
448
|
-
}
|
|
451
|
+
});
|
|
449
452
|
}
|
|
450
|
-
return source;
|
|
451
453
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
+
if (inlineWxs) {
|
|
455
|
+
const wxsTags = extract(source, wxsTagRegexp);
|
|
456
|
+
for (const x of wxsTags) {
|
|
457
|
+
const code = jsHandler(x.raw, runtimeSet).code;
|
|
458
|
+
source = source.replaceAll(x.raw, code);
|
|
459
|
+
}
|
|
454
460
|
}
|
|
461
|
+
return source;
|
|
455
462
|
}
|
|
456
463
|
function createTempleteHandler(options = {}) {
|
|
457
464
|
return (rawSource, opt = {}) => {
|
|
@@ -690,11 +697,12 @@ function getOptions(options = {}) {
|
|
|
690
697
|
normalizeMatcher(options, 'cssMatcher');
|
|
691
698
|
normalizeMatcher(options, 'htmlMatcher');
|
|
692
699
|
normalizeMatcher(options, 'jsMatcher');
|
|
700
|
+
normalizeMatcher(options, 'wxsMatcher');
|
|
693
701
|
normalizeMatcher(options, 'mainCssChunkMatcher');
|
|
694
702
|
const result = defu(options, defaultOptions, {
|
|
695
703
|
minifiedJs: isProd()
|
|
696
704
|
});
|
|
697
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues } = result;
|
|
705
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs } = result;
|
|
698
706
|
result.escapeMap = customReplaceDictionary;
|
|
699
707
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
700
708
|
const customAttributesEntities = isMap(options.customAttributes)
|
|
@@ -703,25 +711,31 @@ function getOptions(options = {}) {
|
|
|
703
711
|
const { escapeMap, minifiedJs } = result;
|
|
704
712
|
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
705
713
|
initMangle(options.mangle);
|
|
706
|
-
|
|
707
|
-
customAttributesEntities,
|
|
708
|
-
escapeMap,
|
|
709
|
-
mangleContext
|
|
710
|
-
});
|
|
711
|
-
result.styleHandler = createStyleHandler({
|
|
714
|
+
const styleHandler = createStyleHandler({
|
|
712
715
|
cssInjectPreflight,
|
|
713
716
|
customRuleCallback,
|
|
714
717
|
cssPreflightRange,
|
|
715
718
|
replaceUniversalSelectorWith,
|
|
716
719
|
escapeMap,
|
|
717
|
-
mangleContext
|
|
720
|
+
mangleContext,
|
|
721
|
+
cssChildCombinatorReplaceValue
|
|
718
722
|
});
|
|
719
|
-
result.
|
|
723
|
+
result.styleHandler = styleHandler;
|
|
724
|
+
const jsHandler = createjsHandler({
|
|
720
725
|
minifiedJs,
|
|
721
726
|
escapeMap,
|
|
722
727
|
mangleContext,
|
|
723
728
|
arbitraryValues
|
|
724
729
|
});
|
|
730
|
+
result.jsHandler = jsHandler;
|
|
731
|
+
const templeteHandler = createTempleteHandler({
|
|
732
|
+
customAttributesEntities,
|
|
733
|
+
escapeMap,
|
|
734
|
+
mangleContext,
|
|
735
|
+
inlineWxs,
|
|
736
|
+
jsHandler
|
|
737
|
+
});
|
|
738
|
+
result.templeteHandler = templeteHandler;
|
|
725
739
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
726
740
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
727
741
|
return result;
|
|
@@ -6,9 +6,9 @@ var generate = require('@babel/generator');
|
|
|
6
6
|
var parser = require('@babel/parser');
|
|
7
7
|
var traverse = require('@babel/traverse');
|
|
8
8
|
var replace = require('./replace.js');
|
|
9
|
-
var shared = require('./shared-
|
|
9
|
+
var shared = require('./shared-ae7dd073.js');
|
|
10
10
|
var postcss = require('postcss');
|
|
11
|
-
var postcss$1 = require('./postcss-
|
|
11
|
+
var postcss$1 = require('./postcss-fbdc673b.js');
|
|
12
12
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
13
13
|
var path = require('node:path');
|
|
14
14
|
var fs = require('node:fs');
|
|
@@ -114,7 +114,7 @@ function groupBy(arr, cb) {
|
|
|
114
114
|
return result;
|
|
115
115
|
}
|
|
116
116
|
function getGroupedEntries(entries, options) {
|
|
117
|
-
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
117
|
+
const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
|
|
118
118
|
const groupedEntries = groupBy(entries, ([file]) => {
|
|
119
119
|
if (cssMatcher(file)) {
|
|
120
120
|
return 'css';
|
|
@@ -122,7 +122,7 @@ function getGroupedEntries(entries, options) {
|
|
|
122
122
|
else if (htmlMatcher(file)) {
|
|
123
123
|
return 'html';
|
|
124
124
|
}
|
|
125
|
-
else if (jsMatcher(file)) {
|
|
125
|
+
else if (jsMatcher(file) || wxsMatcher(file)) {
|
|
126
126
|
return 'js';
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
@@ -210,9 +210,7 @@ function makeCustomAttributes(entries) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
const variableRegExp = /{{(.*?)}}/gs;
|
|
213
|
-
|
|
214
|
-
return variableRegExp.exec(original);
|
|
215
|
-
}
|
|
213
|
+
const wxsTagRegexp = /<wxs\s*(?:[a-z][a-z-]*[a-z]*(?:\s*=\s*".*?")?)*\s*>(.*?)<\/wxs>/gs;
|
|
216
214
|
|
|
217
215
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
218
216
|
function isValidSelector(selector = '') {
|
|
@@ -340,6 +338,9 @@ const defaultOptions = {
|
|
|
340
338
|
}
|
|
341
339
|
}
|
|
342
340
|
},
|
|
341
|
+
wxsMatcher: (file) => {
|
|
342
|
+
return false;
|
|
343
|
+
},
|
|
343
344
|
cssPreflight: {
|
|
344
345
|
'box-sizing': 'border-box',
|
|
345
346
|
'border-width': '0',
|
|
@@ -369,7 +370,9 @@ const defaultOptions = {
|
|
|
369
370
|
appType: undefined,
|
|
370
371
|
arbitraryValues: {
|
|
371
372
|
allowDoubleQuotes: false
|
|
372
|
-
}
|
|
373
|
+
},
|
|
374
|
+
cssChildCombinatorReplaceValue: 'view + view',
|
|
375
|
+
inlineWxs: false
|
|
373
376
|
};
|
|
374
377
|
|
|
375
378
|
function generateCode(match, options = {}) {
|
|
@@ -397,23 +400,24 @@ function generateCode(match, options = {}) {
|
|
|
397
400
|
});
|
|
398
401
|
return code;
|
|
399
402
|
}
|
|
400
|
-
function
|
|
401
|
-
let match =
|
|
403
|
+
function extract(original, reg) {
|
|
404
|
+
let match = reg.exec(original);
|
|
402
405
|
const sources = [];
|
|
403
406
|
while (match !== null) {
|
|
404
407
|
const start = match.index;
|
|
405
|
-
const end =
|
|
408
|
+
const end = reg.lastIndex;
|
|
406
409
|
sources.push({
|
|
407
410
|
start,
|
|
408
411
|
end,
|
|
409
|
-
raw: match[1]
|
|
410
|
-
prevConcatenated: !/\s/.test(original[start - 1]),
|
|
411
|
-
nextConcatenated: !/\s/.test(original[end])
|
|
412
|
+
raw: match[1]
|
|
412
413
|
});
|
|
413
|
-
match =
|
|
414
|
+
match = reg.exec(original);
|
|
414
415
|
}
|
|
415
416
|
return sources;
|
|
416
417
|
}
|
|
418
|
+
function extractSource(original) {
|
|
419
|
+
return extract(original, variableRegExp);
|
|
420
|
+
}
|
|
417
421
|
function templeteReplacer(original, options = {}) {
|
|
418
422
|
const sources = extractSource(original);
|
|
419
423
|
if (sources.length > 0) {
|
|
@@ -464,24 +468,27 @@ function templeteHandler(rawSource, options = {}) {
|
|
|
464
468
|
});
|
|
465
469
|
});
|
|
466
470
|
}
|
|
467
|
-
function customTempleteHandler(rawSource, options
|
|
471
|
+
function customTempleteHandler(rawSource, options) {
|
|
472
|
+
const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
|
|
468
473
|
let source = templeteHandler(rawSource, options);
|
|
469
|
-
const regexps = makeCustomAttributes(
|
|
470
|
-
if (regexps) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
return
|
|
475
|
-
return m1.replace(className, templeteReplacer(className, options));
|
|
476
|
-
});
|
|
474
|
+
const regexps = makeCustomAttributes(customAttributesEntities);
|
|
475
|
+
if (regexps && Array.isArray(regexps)) {
|
|
476
|
+
for (const regexp of regexps) {
|
|
477
|
+
source = source.replace(regexp.tagRegexp, (m0) => {
|
|
478
|
+
return m0.replace(regexp.attrRegexp, (m1, className) => {
|
|
479
|
+
return m1.replace(className, templeteReplacer(className, options));
|
|
477
480
|
});
|
|
478
|
-
}
|
|
481
|
+
});
|
|
479
482
|
}
|
|
480
|
-
return source;
|
|
481
483
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
+
if (inlineWxs) {
|
|
485
|
+
const wxsTags = extract(source, wxsTagRegexp);
|
|
486
|
+
for (const x of wxsTags) {
|
|
487
|
+
const code = jsHandler(x.raw, runtimeSet).code;
|
|
488
|
+
source = source.replaceAll(x.raw, code);
|
|
489
|
+
}
|
|
484
490
|
}
|
|
491
|
+
return source;
|
|
485
492
|
}
|
|
486
493
|
function createTempleteHandler(options = {}) {
|
|
487
494
|
return (rawSource, opt = {}) => {
|
|
@@ -720,11 +727,12 @@ function getOptions(options = {}) {
|
|
|
720
727
|
normalizeMatcher(options, 'cssMatcher');
|
|
721
728
|
normalizeMatcher(options, 'htmlMatcher');
|
|
722
729
|
normalizeMatcher(options, 'jsMatcher');
|
|
730
|
+
normalizeMatcher(options, 'wxsMatcher');
|
|
723
731
|
normalizeMatcher(options, 'mainCssChunkMatcher');
|
|
724
732
|
const result = defu(options, defaultOptions, {
|
|
725
733
|
minifiedJs: isProd()
|
|
726
734
|
});
|
|
727
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues } = result;
|
|
735
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs } = result;
|
|
728
736
|
result.escapeMap = customReplaceDictionary;
|
|
729
737
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
730
738
|
const customAttributesEntities = isMap(options.customAttributes)
|
|
@@ -733,25 +741,31 @@ function getOptions(options = {}) {
|
|
|
733
741
|
const { escapeMap, minifiedJs } = result;
|
|
734
742
|
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
735
743
|
initMangle(options.mangle);
|
|
736
|
-
|
|
737
|
-
customAttributesEntities,
|
|
738
|
-
escapeMap,
|
|
739
|
-
mangleContext
|
|
740
|
-
});
|
|
741
|
-
result.styleHandler = createStyleHandler({
|
|
744
|
+
const styleHandler = createStyleHandler({
|
|
742
745
|
cssInjectPreflight,
|
|
743
746
|
customRuleCallback,
|
|
744
747
|
cssPreflightRange,
|
|
745
748
|
replaceUniversalSelectorWith,
|
|
746
749
|
escapeMap,
|
|
747
|
-
mangleContext
|
|
750
|
+
mangleContext,
|
|
751
|
+
cssChildCombinatorReplaceValue
|
|
748
752
|
});
|
|
749
|
-
result.
|
|
753
|
+
result.styleHandler = styleHandler;
|
|
754
|
+
const jsHandler = createjsHandler({
|
|
750
755
|
minifiedJs,
|
|
751
756
|
escapeMap,
|
|
752
757
|
mangleContext,
|
|
753
758
|
arbitraryValues
|
|
754
759
|
});
|
|
760
|
+
result.jsHandler = jsHandler;
|
|
761
|
+
const templeteHandler = createTempleteHandler({
|
|
762
|
+
customAttributesEntities,
|
|
763
|
+
escapeMap,
|
|
764
|
+
mangleContext,
|
|
765
|
+
inlineWxs,
|
|
766
|
+
jsHandler
|
|
767
|
+
});
|
|
768
|
+
result.templeteHandler = templeteHandler;
|
|
755
769
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
756
770
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
757
771
|
return result;
|
package/dist/postcss/plugin.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { PluginCreator } from 'postcss';
|
|
|
2
2
|
import type { IStyleHandlerOptions } from "../types";
|
|
3
3
|
export type PostcssWeappTailwindcssRenamePlugin = PluginCreator<IStyleHandlerOptions>;
|
|
4
4
|
declare const postcssWeappTailwindcss: PostcssWeappTailwindcssRenamePlugin;
|
|
5
|
-
export { postcssWeappTailwindcss
|
|
5
|
+
export { postcssWeappTailwindcss };
|
|
6
6
|
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
package/dist/postcss/shared.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { InternalCssSelectorReplacerOptions } from "../types";
|
|
2
2
|
export declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
|
|
3
|
-
export declare
|
|
3
|
+
export declare const cssUnescape: (str: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import selectorParser from 'postcss-selector-parser';
|
|
2
|
-
import { i as internalCssSelectorReplacer } from './shared-
|
|
2
|
+
import { i as internalCssSelectorReplacer } from './shared-7c88fb94.mjs';
|
|
3
3
|
import { Rule, Declaration } from 'postcss';
|
|
4
4
|
import '@csstools/postcss-is-pseudo-class';
|
|
5
5
|
|
|
@@ -57,7 +57,15 @@ function testIfVariablesScope(node, count = 1) {
|
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
59
|
function commonChunkPreflight(node, options) {
|
|
60
|
-
|
|
60
|
+
let childCombinatorReplaceValue = 'view + view';
|
|
61
|
+
if (Array.isArray(options.cssChildCombinatorReplaceValue)) {
|
|
62
|
+
const part = options.cssChildCombinatorReplaceValue.join(',');
|
|
63
|
+
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
64
|
+
}
|
|
65
|
+
else if (typeof options.cssChildCombinatorReplaceValue === 'string') {
|
|
66
|
+
childCombinatorReplaceValue = options.cssChildCombinatorReplaceValue;
|
|
67
|
+
}
|
|
68
|
+
node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
61
69
|
if (testIfVariablesScope(node)) {
|
|
62
70
|
const selectorParts = node.selector.split(',');
|
|
63
71
|
if (!selectorParts.includes('view')) {
|
|
@@ -82,7 +90,6 @@ function commonChunkPreflight(node, options) {
|
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
|
|
85
|
-
const NS = 'jsx-rename-loader';
|
|
86
93
|
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
87
94
|
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
88
95
|
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
@@ -105,4 +112,4 @@ const postcssWeappTailwindcss = (options = {
|
|
|
105
112
|
};
|
|
106
113
|
postcssWeappTailwindcss.postcss = true;
|
|
107
114
|
|
|
108
|
-
export {
|
|
115
|
+
export { pluginName as a, postcssWeappTailwindcss as p, vitePluginName as v };
|