weapp-tailwindcss 2.6.1 → 2.6.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/dist/cli.js +6 -5
- package/dist/cli.mjs +6 -5
- package/dist/{defaults-0d9846f4.js → defaults-28cfeec8.js} +5 -8
- package/dist/{defaults-c7f00aae.mjs → defaults-702719e1.mjs} +5 -7
- package/dist/defaults.js +2 -2
- package/dist/defaults.mjs +2 -2
- package/dist/escape.d.ts +1 -3
- package/dist/gulp.js +8 -7
- package/dist/gulp.mjs +8 -7
- package/dist/index.js +6 -5
- package/dist/index.mjs +6 -5
- package/dist/{options-6a265426.js → options-43afee21.js} +89 -162
- package/dist/{options-800ea85a.mjs → options-d8cb9e14.mjs} +66 -139
- package/dist/postcss/shared.d.ts +0 -1
- package/dist/{postcss-cf8b998a.js → postcss-4e99a8e8.js} +35 -35
- package/dist/{postcss-53e2ad95.mjs → postcss-a551ddc0.mjs} +35 -35
- package/dist/postcss.js +3 -3
- package/dist/postcss.mjs +3 -3
- package/dist/reg.d.ts +1 -26
- package/dist/replace.d.ts +1 -1
- package/dist/replace.js +24 -9
- package/dist/replace.mjs +4 -5
- package/dist/shared-df9de23f.js +17 -0
- package/dist/shared-fd149084.mjs +15 -0
- package/dist/types.d.ts +4 -8
- package/dist/vite.js +8 -7
- package/dist/vite.mjs +8 -7
- package/dist/webpack.js +8 -7
- package/dist/webpack.mjs +8 -7
- package/dist/wxml/index.d.ts +1 -1
- package/dist/wxml/shared.d.ts +2 -2
- package/dist/wxml/utils.d.ts +6 -6
- package/package.json +20 -18
- package/dist/dic-05980807.js +0 -111
- package/dist/dic-3790a3a4.mjs +0 -105
- package/dist/dic.d.ts +0 -44
- package/dist/shared-4eed0e5c.js +0 -62
- package/dist/shared-686bfc32.mjs +0 -59
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var options = require('./options-
|
|
3
|
+
var options = require('./options-43afee21.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('
|
|
11
|
-
require('./shared-
|
|
12
|
-
require('
|
|
10
|
+
require('@weapp-core/escape');
|
|
11
|
+
require('./shared-df9de23f.js');
|
|
12
|
+
require('@weapp-core/regex');
|
|
13
|
+
require('./defaults-28cfeec8.js');
|
|
13
14
|
require('postcss');
|
|
14
|
-
require('./postcss-
|
|
15
|
+
require('./postcss-4e99a8e8.js');
|
|
15
16
|
require('postcss-selector-parser');
|
|
16
17
|
require('@csstools/postcss-is-pseudo-class');
|
|
17
18
|
require('node:path');
|
package/dist/cli.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { g as getOptions, c as createPatch } from './options-
|
|
1
|
+
import { g as getOptions, c as createPatch } from './options-d8cb9e14.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 '
|
|
9
|
-
import './shared-
|
|
10
|
-
import '
|
|
8
|
+
import '@weapp-core/escape';
|
|
9
|
+
import './shared-fd149084.mjs';
|
|
10
|
+
import '@weapp-core/regex';
|
|
11
|
+
import './defaults-702719e1.mjs';
|
|
11
12
|
import 'postcss';
|
|
12
|
-
import './postcss-
|
|
13
|
+
import './postcss-a551ddc0.mjs';
|
|
13
14
|
import 'postcss-selector-parser';
|
|
14
15
|
import '@csstools/postcss-is-pseudo-class';
|
|
15
16
|
import 'node:path';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var escape = require('@weapp-core/escape');
|
|
4
4
|
|
|
5
|
-
function isRegexp(value) {
|
|
6
|
-
return Object.prototype.toString.call(value) === '[object RegExp]';
|
|
7
|
-
}
|
|
8
5
|
function isMap(value) {
|
|
9
6
|
return Object.prototype.toString.call(value) === '[object Map]';
|
|
10
7
|
}
|
|
@@ -88,7 +85,7 @@ const defaultOptions = {
|
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
},
|
|
91
|
-
wxsMatcher: (
|
|
88
|
+
wxsMatcher: () => {
|
|
92
89
|
return false;
|
|
93
90
|
},
|
|
94
91
|
cssPreflight: {
|
|
@@ -106,7 +103,7 @@ const defaultOptions = {
|
|
|
106
103
|
onEnd: noop,
|
|
107
104
|
onUpdate: noop,
|
|
108
105
|
customAttributes: {},
|
|
109
|
-
customReplaceDictionary:
|
|
106
|
+
customReplaceDictionary: escape.SimpleMappingChars2String,
|
|
110
107
|
supportCustomLengthUnitsPatch: {
|
|
111
108
|
units: ['rpx'],
|
|
112
109
|
dangerousOptions: {
|
|
@@ -129,11 +126,11 @@ const defaultOptions = {
|
|
|
129
126
|
return true;
|
|
130
127
|
}
|
|
131
128
|
return false;
|
|
132
|
-
}
|
|
129
|
+
},
|
|
130
|
+
disabledDefaultTemplateHandler: false
|
|
133
131
|
};
|
|
134
132
|
|
|
135
133
|
exports.defaultOptions = defaultOptions;
|
|
136
134
|
exports.getGroupedEntries = getGroupedEntries;
|
|
137
135
|
exports.isMap = isMap;
|
|
138
|
-
exports.isRegexp = isRegexp;
|
|
139
136
|
exports.noop = noop;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SimpleMappingChars2String } from '@weapp-core/escape';
|
|
2
2
|
|
|
3
|
-
function isRegexp(value) {
|
|
4
|
-
return Object.prototype.toString.call(value) === '[object RegExp]';
|
|
5
|
-
}
|
|
6
3
|
function isMap(value) {
|
|
7
4
|
return Object.prototype.toString.call(value) === '[object Map]';
|
|
8
5
|
}
|
|
@@ -86,7 +83,7 @@ const defaultOptions = {
|
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
},
|
|
89
|
-
wxsMatcher: (
|
|
86
|
+
wxsMatcher: () => {
|
|
90
87
|
return false;
|
|
91
88
|
},
|
|
92
89
|
cssPreflight: {
|
|
@@ -127,7 +124,8 @@ const defaultOptions = {
|
|
|
127
124
|
return true;
|
|
128
125
|
}
|
|
129
126
|
return false;
|
|
130
|
-
}
|
|
127
|
+
},
|
|
128
|
+
disabledDefaultTemplateHandler: false
|
|
131
129
|
};
|
|
132
130
|
|
|
133
|
-
export {
|
|
131
|
+
export { defaultOptions as d, getGroupedEntries as g, isMap as i, noop as n };
|
package/dist/defaults.js
CHANGED
package/dist/defaults.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { d as defaultOptions } from './defaults-
|
|
2
|
-
import '
|
|
1
|
+
export { d as defaultOptions } from './defaults-702719e1.mjs';
|
|
2
|
+
import '@weapp-core/escape';
|
package/dist/escape.d.ts
CHANGED
package/dist/gulp.js
CHANGED
|
@@ -3,18 +3,19 @@
|
|
|
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-43afee21.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('
|
|
14
|
-
require('./shared-
|
|
15
|
-
require('
|
|
13
|
+
require('@weapp-core/escape');
|
|
14
|
+
require('./shared-df9de23f.js');
|
|
15
|
+
require('@weapp-core/regex');
|
|
16
|
+
require('./defaults-28cfeec8.js');
|
|
16
17
|
require('postcss');
|
|
17
|
-
require('./postcss-
|
|
18
|
+
require('./postcss-4e99a8e8.js');
|
|
18
19
|
require('postcss-selector-parser');
|
|
19
20
|
require('@csstools/postcss-is-pseudo-class');
|
|
20
21
|
require('node:path');
|
|
@@ -33,7 +34,7 @@ function createPlugins(options$1 = {}) {
|
|
|
33
34
|
options$1.customReplaceDictionary = 'simple';
|
|
34
35
|
}
|
|
35
36
|
const opts = options.getOptions(options$1);
|
|
36
|
-
const {
|
|
37
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
37
38
|
let runtimeSet = new Set();
|
|
38
39
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
39
40
|
const twPatcher = options.createTailwindcssPatcher();
|
|
@@ -70,7 +71,7 @@ function createPlugins(options$1 = {}) {
|
|
|
70
71
|
transformStream._transform = function (file, encoding, callback) {
|
|
71
72
|
const error = null;
|
|
72
73
|
if (file.contents) {
|
|
73
|
-
const code =
|
|
74
|
+
const code = templateHandler(file.contents.toString(), {
|
|
74
75
|
runtimeSet
|
|
75
76
|
});
|
|
76
77
|
file.contents = Buffer.from(code);
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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-d8cb9e14.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 '
|
|
10
|
-
import './shared-
|
|
11
|
-
import '
|
|
9
|
+
import '@weapp-core/escape';
|
|
10
|
+
import './shared-fd149084.mjs';
|
|
11
|
+
import '@weapp-core/regex';
|
|
12
|
+
import './defaults-702719e1.mjs';
|
|
12
13
|
import 'postcss';
|
|
13
|
-
import './postcss-
|
|
14
|
+
import './postcss-a551ddc0.mjs';
|
|
14
15
|
import 'postcss-selector-parser';
|
|
15
16
|
import '@csstools/postcss-is-pseudo-class';
|
|
16
17
|
import 'node:path';
|
|
@@ -25,7 +26,7 @@ function createPlugins(options = {}) {
|
|
|
25
26
|
options.customReplaceDictionary = 'simple';
|
|
26
27
|
}
|
|
27
28
|
const opts = getOptions(options);
|
|
28
|
-
const {
|
|
29
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
29
30
|
let runtimeSet = new Set();
|
|
30
31
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
31
32
|
const twPatcher = createTailwindcssPatcher();
|
|
@@ -62,7 +63,7 @@ function createPlugins(options = {}) {
|
|
|
62
63
|
transformStream._transform = function (file, encoding, callback) {
|
|
63
64
|
const error = null;
|
|
64
65
|
if (file.contents) {
|
|
65
|
-
const code =
|
|
66
|
+
const code = templateHandler(file.contents.toString(), {
|
|
66
67
|
runtimeSet
|
|
67
68
|
});
|
|
68
69
|
file.contents = Buffer.from(code);
|
package/dist/index.js
CHANGED
|
@@ -7,18 +7,19 @@ var vite = require('./vite.js');
|
|
|
7
7
|
var gulp = require('./gulp.js');
|
|
8
8
|
require('node:path');
|
|
9
9
|
require('node:fs');
|
|
10
|
-
require('./options-
|
|
10
|
+
require('./options-43afee21.js');
|
|
11
11
|
require('micromatch');
|
|
12
12
|
require('@babel/types');
|
|
13
13
|
require('@babel/generator');
|
|
14
14
|
require('@babel/parser');
|
|
15
15
|
require('@babel/traverse');
|
|
16
16
|
require('./replace.js');
|
|
17
|
-
require('
|
|
18
|
-
require('./shared-
|
|
19
|
-
require('
|
|
17
|
+
require('@weapp-core/escape');
|
|
18
|
+
require('./shared-df9de23f.js');
|
|
19
|
+
require('@weapp-core/regex');
|
|
20
|
+
require('./defaults-28cfeec8.js');
|
|
20
21
|
require('postcss');
|
|
21
|
-
require('./postcss-
|
|
22
|
+
require('./postcss-4e99a8e8.js');
|
|
22
23
|
require('postcss-selector-parser');
|
|
23
24
|
require('@csstools/postcss-is-pseudo-class');
|
|
24
25
|
require('semver');
|
package/dist/index.mjs
CHANGED
|
@@ -3,18 +3,19 @@ export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
4
|
import 'node:path';
|
|
5
5
|
import 'node:fs';
|
|
6
|
-
import './options-
|
|
6
|
+
import './options-d8cb9e14.mjs';
|
|
7
7
|
import 'micromatch';
|
|
8
8
|
import '@babel/types';
|
|
9
9
|
import '@babel/generator';
|
|
10
10
|
import '@babel/parser';
|
|
11
11
|
import '@babel/traverse';
|
|
12
12
|
import './replace.mjs';
|
|
13
|
-
import '
|
|
14
|
-
import './shared-
|
|
15
|
-
import '
|
|
13
|
+
import '@weapp-core/escape';
|
|
14
|
+
import './shared-fd149084.mjs';
|
|
15
|
+
import '@weapp-core/regex';
|
|
16
|
+
import './defaults-702719e1.mjs';
|
|
16
17
|
import 'postcss';
|
|
17
|
-
import './postcss-
|
|
18
|
+
import './postcss-a551ddc0.mjs';
|
|
18
19
|
import 'postcss-selector-parser';
|
|
19
20
|
import '@csstools/postcss-is-pseudo-class';
|
|
20
21
|
import 'semver';
|
|
@@ -6,11 +6,12 @@ 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
|
|
9
|
+
var regex = require('@weapp-core/regex');
|
|
10
|
+
var defaults = require('./defaults-28cfeec8.js');
|
|
10
11
|
var postcss = require('postcss');
|
|
11
|
-
var postcss$1 = require('./postcss-
|
|
12
|
+
var postcss$1 = require('./postcss-4e99a8e8.js');
|
|
12
13
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
13
|
-
var
|
|
14
|
+
var escape = require('@weapp-core/escape');
|
|
14
15
|
var path = require('node:path');
|
|
15
16
|
var fs = require('node:fs');
|
|
16
17
|
var semver = require('semver');
|
|
@@ -20,21 +21,21 @@ var tailwindcssMangleShared = require('tailwindcss-mangle-shared');
|
|
|
20
21
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
22
|
|
|
22
23
|
function _interopNamespaceCompat(e) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
25
|
+
var n = Object.create(null);
|
|
26
|
+
if (e) {
|
|
27
|
+
Object.keys(e).forEach(function (k) {
|
|
28
|
+
if (k !== 'default') {
|
|
29
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return e[k]; }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
n["default"] = e;
|
|
37
|
-
return Object.freeze(n);
|
|
36
|
+
}
|
|
37
|
+
n["default"] = e;
|
|
38
|
+
return Object.freeze(n);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
var t__namespace = /*#__PURE__*/_interopNamespaceCompat(t);
|
|
@@ -45,128 +46,6 @@ var postcssIsPseudoClass__default = /*#__PURE__*/_interopDefaultCompat(postcssIs
|
|
|
45
46
|
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
46
47
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
47
48
|
|
|
48
|
-
function isObject(value) {
|
|
49
|
-
return value !== null && typeof value === "object";
|
|
50
|
-
}
|
|
51
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
52
|
-
if (!isObject(defaults)) {
|
|
53
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
54
|
-
}
|
|
55
|
-
const object = Object.assign({}, defaults);
|
|
56
|
-
for (const key in baseObject) {
|
|
57
|
-
if (key === "__proto__" || key === "constructor") {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const value = baseObject[key];
|
|
61
|
-
if (value === null || value === void 0) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
68
|
-
object[key] = [...value, ...object[key]];
|
|
69
|
-
} else if (isObject(value) && isObject(object[key])) {
|
|
70
|
-
object[key] = _defu(
|
|
71
|
-
value,
|
|
72
|
-
object[key],
|
|
73
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
74
|
-
merger
|
|
75
|
-
);
|
|
76
|
-
} else {
|
|
77
|
-
object[key] = value;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return object;
|
|
81
|
-
}
|
|
82
|
-
function createDefu(merger) {
|
|
83
|
-
return (...arguments_) => (
|
|
84
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
85
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
const defu = createDefu();
|
|
89
|
-
|
|
90
|
-
function escapeStringRegexp(str) {
|
|
91
|
-
if (typeof str !== 'string') {
|
|
92
|
-
throw new TypeError('Expected a string');
|
|
93
|
-
}
|
|
94
|
-
return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d');
|
|
95
|
-
}
|
|
96
|
-
const templateClassExactRegexp = /(?<=^|\s)(?:hover-)?class=(?:["']\W+\s*\w+\()?["']([^"]+)["']/gs;
|
|
97
|
-
const tagWithEitherClassAndHoverClassRegexp = /<[a-z][a-z-]*[a-z]*\s+[^>]*?(?:hover-)?clas{2}="[^"]*"[^>]*?\/?>/g;
|
|
98
|
-
function handleRegexp(reg) {
|
|
99
|
-
return `(?:${reg.source})`;
|
|
100
|
-
}
|
|
101
|
-
function getSourceString(input) {
|
|
102
|
-
let result;
|
|
103
|
-
if (typeof input === 'string') {
|
|
104
|
-
result = input;
|
|
105
|
-
}
|
|
106
|
-
else if (defaults.isRegexp(input)) {
|
|
107
|
-
result = input.source;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
result = input.toString();
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
function makePattern(arr) {
|
|
115
|
-
let pattern = '';
|
|
116
|
-
if (Array.isArray(arr)) {
|
|
117
|
-
pattern = arr
|
|
118
|
-
.reduce((acc, cur) => {
|
|
119
|
-
if (typeof cur === 'string') {
|
|
120
|
-
acc.push(cur);
|
|
121
|
-
}
|
|
122
|
-
else if (defaults.isRegexp(cur)) {
|
|
123
|
-
acc.push(handleRegexp(cur));
|
|
124
|
-
}
|
|
125
|
-
return acc;
|
|
126
|
-
}, [])
|
|
127
|
-
.join('|');
|
|
128
|
-
}
|
|
129
|
-
else if (typeof arr === 'string') {
|
|
130
|
-
pattern = arr;
|
|
131
|
-
}
|
|
132
|
-
else if (defaults.isRegexp(arr)) {
|
|
133
|
-
pattern = handleRegexp(arr);
|
|
134
|
-
}
|
|
135
|
-
return pattern;
|
|
136
|
-
}
|
|
137
|
-
function createTempleteHandlerMatchRegexp(tag, attrs, options = {}) {
|
|
138
|
-
const { exact = true } = options;
|
|
139
|
-
const prefix = exact ? '(?<=^|\\s)' : '';
|
|
140
|
-
const pattern = makePattern(attrs);
|
|
141
|
-
let tagPattern = getSourceString(tag);
|
|
142
|
-
if (tagPattern === '*') {
|
|
143
|
-
tagPattern = '[a-z][-a-z]*[a-z]*';
|
|
144
|
-
}
|
|
145
|
-
const source = `<(${tagPattern})\\s+[^>]*?(?:${prefix}(${pattern})="(?:[^"]*)")[^>]*?\\/?>`;
|
|
146
|
-
return new RegExp(source, 'g');
|
|
147
|
-
}
|
|
148
|
-
function createTemplateClassRegexp(attrs, options = {}) {
|
|
149
|
-
const { exact = true } = options;
|
|
150
|
-
const prefix = exact ? '(?<=^|\\s)' : '';
|
|
151
|
-
const pattern = makePattern(attrs);
|
|
152
|
-
const source = `(?:${prefix}${pattern})=(?:["']\\W+\\s*(?:\\w+)\\()?["']([^"]+)['"]`;
|
|
153
|
-
return new RegExp(source, 'gs');
|
|
154
|
-
}
|
|
155
|
-
function makeCustomAttributes(entries) {
|
|
156
|
-
if (Array.isArray(entries)) {
|
|
157
|
-
return entries.map(([k, v]) => {
|
|
158
|
-
return {
|
|
159
|
-
tagRegexp: createTempleteHandlerMatchRegexp(k, v),
|
|
160
|
-
attrRegexp: createTemplateClassRegexp(v),
|
|
161
|
-
tag: getSourceString(k),
|
|
162
|
-
attrs: v
|
|
163
|
-
};
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const variableRegExp = /{{(.*?)}}/gs;
|
|
168
|
-
const wxsTagRegexp = /<wxs\s*(?:[a-z][a-z-]*[a-z]*(?:\s*=\s*".*?")?)*\s*>(.*?)<\/wxs>/gs;
|
|
169
|
-
|
|
170
49
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
171
50
|
function isValidSelector(selector = '') {
|
|
172
51
|
return validateFilterRE.test(selector);
|
|
@@ -197,7 +76,7 @@ function handleValue(str, node, options) {
|
|
|
197
76
|
if (ctx) {
|
|
198
77
|
rawStr = ctx.jsHandler(rawStr);
|
|
199
78
|
}
|
|
200
|
-
rawStr = rawStr.replaceAll(new RegExp(escapeStringRegexp(v), 'g'), replace.replaceJs(v, {
|
|
79
|
+
rawStr = rawStr.replaceAll(new RegExp(regex.escapeStringRegexp(v), 'g'), replace.replaceJs(v, {
|
|
201
80
|
escapeMap
|
|
202
81
|
}));
|
|
203
82
|
}
|
|
@@ -255,6 +134,48 @@ function createjsHandler(options) {
|
|
|
255
134
|
};
|
|
256
135
|
}
|
|
257
136
|
|
|
137
|
+
function isObject(value) {
|
|
138
|
+
return value !== null && typeof value === "object";
|
|
139
|
+
}
|
|
140
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
141
|
+
if (!isObject(defaults)) {
|
|
142
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
143
|
+
}
|
|
144
|
+
const object = Object.assign({}, defaults);
|
|
145
|
+
for (const key in baseObject) {
|
|
146
|
+
if (key === "__proto__" || key === "constructor") {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const value = baseObject[key];
|
|
150
|
+
if (value === null || value === void 0) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
157
|
+
object[key] = [...value, ...object[key]];
|
|
158
|
+
} else if (isObject(value) && isObject(object[key])) {
|
|
159
|
+
object[key] = _defu(
|
|
160
|
+
value,
|
|
161
|
+
object[key],
|
|
162
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
163
|
+
merger
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
object[key] = value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return object;
|
|
170
|
+
}
|
|
171
|
+
function createDefu(merger) {
|
|
172
|
+
return (...arguments_) => (
|
|
173
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
174
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
const defu = createDefu();
|
|
178
|
+
|
|
258
179
|
function generateCode(match, options = {}) {
|
|
259
180
|
const ast = parser.parseExpression(match);
|
|
260
181
|
traverse__default["default"](ast, {
|
|
@@ -296,9 +217,9 @@ function extract(original, reg) {
|
|
|
296
217
|
return sources;
|
|
297
218
|
}
|
|
298
219
|
function extractSource(original) {
|
|
299
|
-
return extract(original, variableRegExp);
|
|
220
|
+
return extract(original, regex.variableRegExp);
|
|
300
221
|
}
|
|
301
|
-
function
|
|
222
|
+
function templateReplacer(original, options = {}) {
|
|
302
223
|
const sources = extractSource(original);
|
|
303
224
|
if (sources.length > 0) {
|
|
304
225
|
const resultArray = [];
|
|
@@ -341,28 +262,31 @@ function templeteReplacer(original, options = {}) {
|
|
|
341
262
|
});
|
|
342
263
|
}
|
|
343
264
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
346
|
-
return
|
|
347
|
-
|
|
265
|
+
function templateHandler(rawSource, options = {}) {
|
|
266
|
+
if (options.disabledDefaultTemplateHandler) {
|
|
267
|
+
return rawSource;
|
|
268
|
+
}
|
|
269
|
+
return rawSource.replace(regex.tagWithEitherClassAndHoverClassRegexp, (m0) => {
|
|
270
|
+
return m0.replace(regex.templateClassExactRegexp, (m1, className) => {
|
|
271
|
+
return m1.replace(className, templateReplacer(className, options));
|
|
348
272
|
});
|
|
349
273
|
});
|
|
350
274
|
}
|
|
351
|
-
function
|
|
275
|
+
function customTemplateHandler(rawSource, options) {
|
|
352
276
|
const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
|
|
353
|
-
let source =
|
|
354
|
-
const regexps = makeCustomAttributes(customAttributesEntities);
|
|
277
|
+
let source = templateHandler(rawSource, options);
|
|
278
|
+
const regexps = regex.makeCustomAttributes(customAttributesEntities);
|
|
355
279
|
if (regexps && Array.isArray(regexps)) {
|
|
356
280
|
for (const regexp of regexps) {
|
|
357
281
|
source = source.replace(regexp.tagRegexp, (m0) => {
|
|
358
282
|
return m0.replace(regexp.attrRegexp, (m1, className) => {
|
|
359
|
-
return m1.replace(className,
|
|
283
|
+
return m1.replace(className, templateReplacer(className, options));
|
|
360
284
|
});
|
|
361
285
|
});
|
|
362
286
|
}
|
|
363
287
|
}
|
|
364
288
|
if (inlineWxs) {
|
|
365
|
-
const wxsTags = extract(source, wxsTagRegexp);
|
|
289
|
+
const wxsTags = extract(source, regex.wxsTagRegexp);
|
|
366
290
|
for (const x of wxsTags) {
|
|
367
291
|
const code = jsHandler(x.raw, runtimeSet).code;
|
|
368
292
|
source = source.replaceAll(x.raw, code);
|
|
@@ -370,9 +294,9 @@ function customTempleteHandler(rawSource, options) {
|
|
|
370
294
|
}
|
|
371
295
|
return source;
|
|
372
296
|
}
|
|
373
|
-
function
|
|
297
|
+
function createTemplateHandler(options = {}) {
|
|
374
298
|
return (rawSource, opt = {}) => {
|
|
375
|
-
return
|
|
299
|
+
return customTemplateHandler(rawSource, defu(opt, options));
|
|
376
300
|
};
|
|
377
301
|
}
|
|
378
302
|
|
|
@@ -502,11 +426,13 @@ function internalPatch(pkgJsonPath, options, overwrite = true) {
|
|
|
502
426
|
if (pkgJsonPath) {
|
|
503
427
|
const pkgJson = require(pkgJsonPath);
|
|
504
428
|
const dangerousOptions = options.dangerousOptions;
|
|
505
|
-
|
|
429
|
+
const version = pkgJson.version;
|
|
430
|
+
if (semver.gte(version, dangerousOptions.gteVersion)) {
|
|
506
431
|
const rootDir = path__default["default"].dirname(pkgJsonPath);
|
|
507
432
|
const dataTypes = monkeyPatchForSupportingCustomUnit(rootDir, options);
|
|
508
433
|
const result = tailwindcssPatch.monkeyPatchForExposingContext(rootDir, {
|
|
509
|
-
overwrite
|
|
434
|
+
overwrite,
|
|
435
|
+
version
|
|
510
436
|
});
|
|
511
437
|
return Object.assign(Object.assign({}, result), { dataTypes });
|
|
512
438
|
}
|
|
@@ -539,7 +465,7 @@ function useMangleStore() {
|
|
|
539
465
|
const arr = splitCode(rawSource);
|
|
540
466
|
for (const x of arr) {
|
|
541
467
|
if (ctx.runtimeSet.has(x)) {
|
|
542
|
-
rawSource = rawSource.replaceAll(new RegExp(escapeStringRegexp(x), 'g'), ctx.classGenerator.generateClassName(x).name);
|
|
468
|
+
rawSource = rawSource.replaceAll(new RegExp(regex.escapeStringRegexp(x), 'g'), ctx.classGenerator.generateClassName(x).name);
|
|
543
469
|
}
|
|
544
470
|
}
|
|
545
471
|
return rawSource;
|
|
@@ -599,10 +525,10 @@ function getOptions(options = {}) {
|
|
|
599
525
|
options.supportCustomLengthUnitsPatch = undefined;
|
|
600
526
|
}
|
|
601
527
|
if (options.customReplaceDictionary === 'simple') {
|
|
602
|
-
options.customReplaceDictionary =
|
|
528
|
+
options.customReplaceDictionary = escape.SimpleMappingChars2String;
|
|
603
529
|
}
|
|
604
530
|
else if (options.customReplaceDictionary === 'complex') {
|
|
605
|
-
options.customReplaceDictionary =
|
|
531
|
+
options.customReplaceDictionary = escape.MappingChars2String;
|
|
606
532
|
}
|
|
607
533
|
normalizeMatcher(options, 'cssMatcher');
|
|
608
534
|
normalizeMatcher(options, 'htmlMatcher');
|
|
@@ -612,7 +538,7 @@ function getOptions(options = {}) {
|
|
|
612
538
|
const result = defu(options, defaults.defaultOptions, {
|
|
613
539
|
minifiedJs: isProd()
|
|
614
540
|
});
|
|
615
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass } = result;
|
|
541
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs, injectAdditionalCssVarScope, jsPreserveClass, disabledDefaultTemplateHandler } = result;
|
|
616
542
|
result.escapeMap = customReplaceDictionary;
|
|
617
543
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
618
544
|
const customAttributesEntities = defaults.isMap(options.customAttributes)
|
|
@@ -640,14 +566,15 @@ function getOptions(options = {}) {
|
|
|
640
566
|
jsPreserveClass
|
|
641
567
|
});
|
|
642
568
|
result.jsHandler = jsHandler;
|
|
643
|
-
const
|
|
569
|
+
const templateHandler = createTemplateHandler({
|
|
644
570
|
customAttributesEntities,
|
|
645
571
|
escapeMap,
|
|
646
572
|
mangleContext,
|
|
647
573
|
inlineWxs,
|
|
648
|
-
jsHandler
|
|
574
|
+
jsHandler,
|
|
575
|
+
disabledDefaultTemplateHandler
|
|
649
576
|
});
|
|
650
|
-
result.
|
|
577
|
+
result.templateHandler = templateHandler;
|
|
651
578
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
652
579
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
653
580
|
return result;
|