weapp-tailwindcss 3.8.0-alpha.1 → 4.0.0-alpha.10
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/{chunk-QEEWOML6.mjs → chunk-CRIVJETU.mjs} +13 -14
- package/dist/{chunk-NLFQ7XRK.mjs → chunk-F23L6ZME.mjs} +5 -5
- package/dist/chunk-FXPGR372.js +1 -0
- package/dist/{chunk-YSEHQ3FF.js → chunk-GHLS2DGY.js} +12 -13
- package/dist/{chunk-IETFIAKJ.js → chunk-GX4O2YZI.js} +4 -4
- package/dist/chunk-HL6Y5PYZ.mjs +10 -0
- package/dist/{chunk-2STNBSVB.js → chunk-KVKGWZDD.js} +14 -15
- package/dist/chunk-LOLJLZCX.mjs +0 -0
- package/dist/chunk-N62XM3T3.js +10 -0
- package/dist/{chunk-U7O2XXYR.mjs → chunk-PCBSAFQF.mjs} +2 -2
- package/dist/{chunk-MWTUP5KG.mjs → chunk-PCLP6Y32.mjs} +46 -154
- package/dist/chunk-RHTRRSP3.mjs +118 -0
- package/dist/{chunk-LWRZXI5T.js → chunk-UDT6MZJ7.js} +53 -161
- package/dist/{chunk-RFNUATFD.js → chunk-WGQLZ5K4.js} +1 -1
- package/dist/{chunk-EODGLB63.mjs → chunk-XW3PPBN2.mjs} +13 -14
- package/dist/chunk-YUXG2EJF.js +118 -0
- package/dist/cli.js +10 -11
- package/dist/cli.mjs +9 -10
- package/dist/core.d.mts +3 -5
- package/dist/core.d.ts +3 -5
- package/dist/core.js +11 -12
- package/dist/core.mjs +12 -13
- package/dist/defaults.d.mts +3 -5
- package/dist/defaults.d.ts +3 -5
- package/dist/defaults.js +2 -2
- package/dist/defaults.mjs +1 -1
- package/dist/escape.d.mts +6 -7
- package/dist/escape.d.ts +6 -7
- package/dist/escape.js +2 -2
- package/dist/escape.mjs +1 -1
- package/dist/gulp.d.mts +3 -5
- package/dist/gulp.d.ts +3 -5
- package/dist/gulp.js +5 -7
- package/dist/gulp.mjs +4 -6
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +10 -10
- package/dist/index.mjs +8 -8
- package/dist/{index-g4epDIUu.d.mts → types.d.mts} +153 -211
- package/dist/{index-g4epDIUu.d.ts → types.d.ts} +153 -211
- package/dist/types.js +1 -0
- package/dist/types.mjs +1 -0
- package/dist/vite.d.mts +3 -5
- package/dist/vite.d.ts +3 -5
- package/dist/vite.js +6 -7
- package/dist/vite.mjs +5 -6
- package/dist/weapp-tw-runtime-loader.js +8 -3
- package/dist/webpack.d.mts +3 -5
- package/dist/webpack.d.ts +3 -5
- package/dist/webpack.js +6 -7
- package/dist/webpack.mjs +5 -6
- package/dist/webpack4.d.mts +3 -5
- package/dist/webpack4.d.ts +3 -5
- package/dist/webpack4.js +16 -18
- package/dist/webpack4.mjs +15 -17
- package/package.json +17 -31
- package/dist/chunk-FG63RW47.mjs +0 -7106
- package/dist/chunk-KE7J6XFD.mjs +0 -537
- package/dist/chunk-LQN2VTMU.js +0 -537
- package/dist/chunk-VKSQ6BRD.mjs +0 -27
- package/dist/chunk-XSZXPWWL.js +0 -27
- package/dist/chunk-YYT4NLHK.js +0 -7109
- package/dist/postcss.d.mts +0 -28
- package/dist/postcss.d.ts +0 -28
- package/dist/postcss.js +0 -16
- package/dist/postcss.mjs +0 -16
- package/dist/replace.d.mts +0 -22
- package/dist/replace.d.ts +0 -22
- package/dist/replace.js +0 -33
- package/dist/replace.mjs +0 -33
- package/dist/shared-5ArEo9kL.d.mts +0 -5
- package/dist/shared-DI2Qz1ou.d.ts +0 -5
- package/dist/weapp-tw-runtime-loader.d.mts +0 -7
- package/dist/weapp-tw-runtime-loader.d.ts +0 -7
- package/dist/weapp-tw-runtime-loader.mjs +0 -14
|
@@ -2,15 +2,15 @@ import {
|
|
|
2
2
|
createDebug
|
|
3
3
|
} from "./chunk-75EWCRQW.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
pluginName
|
|
6
|
+
} from "./chunk-HL6Y5PYZ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
getCompilerContext
|
|
9
|
+
} from "./chunk-PCLP6Y32.mjs";
|
|
7
10
|
import {
|
|
8
11
|
getGroupedEntries,
|
|
9
12
|
removeExt
|
|
10
13
|
} from "./chunk-MUJ65IQ3.mjs";
|
|
11
|
-
import {
|
|
12
|
-
pluginName
|
|
13
|
-
} from "./chunk-KE7J6XFD.mjs";
|
|
14
14
|
import {
|
|
15
15
|
__async
|
|
16
16
|
} from "./chunk-AXBFBHS2.mjs";
|
|
@@ -21,7 +21,7 @@ import path from "node:path";
|
|
|
21
21
|
var debug = createDebug();
|
|
22
22
|
var UnifiedWebpackPluginV5 = class {
|
|
23
23
|
constructor(options = {}) {
|
|
24
|
-
this.options =
|
|
24
|
+
this.options = getCompilerContext(options);
|
|
25
25
|
this.appType = this.options.appType;
|
|
26
26
|
}
|
|
27
27
|
apply(compiler) {
|
|
@@ -33,7 +33,6 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
33
33
|
onEnd,
|
|
34
34
|
onStart,
|
|
35
35
|
styleHandler,
|
|
36
|
-
patch,
|
|
37
36
|
templateHandler,
|
|
38
37
|
jsHandler,
|
|
39
38
|
setMangleRuntimeSet,
|
|
@@ -44,7 +43,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
44
43
|
if (disabled) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
|
-
patch
|
|
46
|
+
twPatcher.patch();
|
|
48
47
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
49
48
|
const { ConcatSource, RawSource } = sources;
|
|
50
49
|
function getClassSet() {
|
|
@@ -90,8 +89,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
90
89
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
91
90
|
if (Array.isArray(groupedEntries.html)) {
|
|
92
91
|
let noCachedCount = 0;
|
|
93
|
-
for (
|
|
94
|
-
const [file, originalSource] =
|
|
92
|
+
for (const element of groupedEntries.html) {
|
|
93
|
+
const [file, originalSource] = element;
|
|
95
94
|
const rawSource = originalSource.source().toString();
|
|
96
95
|
const hash = cache.computeHash(rawSource);
|
|
97
96
|
const cacheKey = file;
|
|
@@ -127,8 +126,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
127
126
|
}
|
|
128
127
|
if (Array.isArray(groupedEntries.js)) {
|
|
129
128
|
let noCachedCount = 0;
|
|
130
|
-
for (
|
|
131
|
-
const [file, originalSource] =
|
|
129
|
+
for (const element of groupedEntries.js) {
|
|
130
|
+
const [file, originalSource] = element;
|
|
132
131
|
const cacheKey = removeExt(file);
|
|
133
132
|
yield cache.process(
|
|
134
133
|
cacheKey,
|
|
@@ -168,8 +167,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
168
167
|
}
|
|
169
168
|
if (Array.isArray(groupedEntries.css)) {
|
|
170
169
|
let noCachedCount = 0;
|
|
171
|
-
for (
|
|
172
|
-
const [file, originalSource] =
|
|
170
|
+
for (const element of groupedEntries.css) {
|
|
171
|
+
const [file, originalSource] = element;
|
|
173
172
|
const rawSource = originalSource.source().toString();
|
|
174
173
|
const hash = cache.computeHash(rawSource);
|
|
175
174
|
const cacheKey = file;
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
createDebug
|
|
3
3
|
} from "./chunk-75EWCRQW.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
getCompilerContext
|
|
6
|
+
} from "./chunk-PCLP6Y32.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__async,
|
|
9
9
|
__spreadValues
|
|
@@ -15,10 +15,10 @@ import stream from "node:stream";
|
|
|
15
15
|
var debug = createDebug();
|
|
16
16
|
var Transform = stream.Transform;
|
|
17
17
|
function createPlugins(options = {}) {
|
|
18
|
-
const opts =
|
|
19
|
-
const { templateHandler, styleHandler,
|
|
18
|
+
const opts = getCompilerContext(options);
|
|
19
|
+
const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
20
20
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
21
|
-
patch
|
|
21
|
+
twPatcher.patch();
|
|
22
22
|
function transformWxss(options2 = {}) {
|
|
23
23
|
return new Transform({
|
|
24
24
|
objectMode: true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkN62XM3T3js = require('./chunk-N62XM3T3.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkUDT6MZJ7js = require('./chunk-UDT6MZJ7.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
|
|
@@ -17,7 +17,7 @@ var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
|
|
|
17
17
|
// src/bundlers/vite/index.ts
|
|
18
18
|
var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
|
|
19
19
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
20
|
-
const opts =
|
|
20
|
+
const opts = _chunkUDT6MZJ7js.getCompilerContext.call(void 0, options);
|
|
21
21
|
const {
|
|
22
22
|
disabled,
|
|
23
23
|
onEnd,
|
|
@@ -26,7 +26,6 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
26
26
|
onUpdate,
|
|
27
27
|
templateHandler,
|
|
28
28
|
styleHandler,
|
|
29
|
-
patch,
|
|
30
29
|
jsHandler,
|
|
31
30
|
mainCssChunkMatcher,
|
|
32
31
|
appType,
|
|
@@ -37,10 +36,10 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
37
36
|
if (disabled) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
patch
|
|
39
|
+
twPatcher.patch();
|
|
41
40
|
onLoad();
|
|
42
41
|
return {
|
|
43
|
-
name:
|
|
42
|
+
name: _chunkN62XM3T3js.vitePluginName,
|
|
44
43
|
enforce: "post",
|
|
45
44
|
generateBundle(_opt, bundle) {
|
|
46
45
|
return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
@@ -53,8 +52,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
53
52
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
54
53
|
if (Array.isArray(groupedEntries.html)) {
|
|
55
54
|
let noCachedCount = 0;
|
|
56
|
-
for (
|
|
57
|
-
const [file, originalSource] =
|
|
55
|
+
for (const element of groupedEntries.html) {
|
|
56
|
+
const [file, originalSource] = element;
|
|
58
57
|
const oldVal = originalSource.source.toString();
|
|
59
58
|
const hash = cache.computeHash(oldVal);
|
|
60
59
|
cache.calcHashValueChanged(file, hash);
|
|
@@ -87,8 +86,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
87
86
|
}
|
|
88
87
|
if (Array.isArray(groupedEntries.js)) {
|
|
89
88
|
let noCachedCount = 0;
|
|
90
|
-
for (
|
|
91
|
-
const [file, originalSource] =
|
|
89
|
+
for (const element of groupedEntries.js) {
|
|
90
|
+
const [file, originalSource] = element;
|
|
92
91
|
const rawSource = originalSource.code;
|
|
93
92
|
const hash = cache.computeHash(rawSource);
|
|
94
93
|
cache.calcHashValueChanged(file, hash);
|
|
@@ -128,8 +127,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
128
127
|
}
|
|
129
128
|
if (Array.isArray(groupedEntries.css)) {
|
|
130
129
|
let noCachedCount = 0;
|
|
131
|
-
for (
|
|
132
|
-
const [file, originalSource] =
|
|
130
|
+
for (const element of groupedEntries.css) {
|
|
131
|
+
const [file, originalSource] = element;
|
|
133
132
|
const rawSource = originalSource.source.toString();
|
|
134
133
|
const hash = cache.computeHash(rawSource);
|
|
135
134
|
cache.calcHashValueChanged(file, hash);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkUDT6MZJ7js = require('./chunk-UDT6MZJ7.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -15,10 +15,10 @@ var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
|
|
|
15
15
|
var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
|
|
16
16
|
var Transform = _stream2.default.Transform;
|
|
17
17
|
function createPlugins(options = {}) {
|
|
18
|
-
const opts =
|
|
19
|
-
const { templateHandler, styleHandler,
|
|
18
|
+
const opts = _chunkUDT6MZJ7js.getCompilerContext.call(void 0, options);
|
|
19
|
+
const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
20
20
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
21
|
-
patch
|
|
21
|
+
twPatcher.patch();
|
|
22
22
|
function transformWxss(options2 = {}) {
|
|
23
23
|
return new Transform({
|
|
24
24
|
objectMode: true,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
3
|
+
var vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
|
|
4
|
+
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
pluginName,
|
|
8
|
+
vitePluginName,
|
|
9
|
+
WEAPP_TW_REQUIRED_NODE_VERSION
|
|
10
|
+
};
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkN62XM3T3js = require('./chunk-N62XM3T3.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
var _chunkUDT6MZJ7js = require('./chunk-UDT6MZJ7.js');
|
|
9
10
|
|
|
10
|
-
var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
|
|
@@ -21,7 +21,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
21
21
|
var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
|
|
22
22
|
var UnifiedWebpackPluginV5 = class {
|
|
23
23
|
constructor(options = {}) {
|
|
24
|
-
this.options =
|
|
24
|
+
this.options = _chunkUDT6MZJ7js.getCompilerContext.call(void 0, options);
|
|
25
25
|
this.appType = this.options.appType;
|
|
26
26
|
}
|
|
27
27
|
apply(compiler) {
|
|
@@ -33,7 +33,6 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
33
33
|
onEnd,
|
|
34
34
|
onStart,
|
|
35
35
|
styleHandler,
|
|
36
|
-
patch,
|
|
37
36
|
templateHandler,
|
|
38
37
|
jsHandler,
|
|
39
38
|
setMangleRuntimeSet,
|
|
@@ -44,7 +43,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
44
43
|
if (disabled) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
|
-
patch
|
|
46
|
+
twPatcher.patch();
|
|
48
47
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
49
48
|
const { ConcatSource, RawSource } = sources;
|
|
50
49
|
function getClassSet() {
|
|
@@ -61,8 +60,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
61
60
|
ident: null,
|
|
62
61
|
type: null
|
|
63
62
|
};
|
|
64
|
-
compiler.hooks.compilation.tap(
|
|
65
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
63
|
+
compiler.hooks.compilation.tap(_chunkN62XM3T3js.pluginName, (compilation) => {
|
|
64
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunkN62XM3T3js.pluginName, (_loaderContext, module) => {
|
|
66
65
|
if (isExisted) {
|
|
67
66
|
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
68
67
|
if (idx > -1) {
|
|
@@ -72,7 +71,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
72
71
|
});
|
|
73
72
|
compilation.hooks.processAssets.tapPromise(
|
|
74
73
|
{
|
|
75
|
-
name:
|
|
74
|
+
name: _chunkN62XM3T3js.pluginName,
|
|
76
75
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
77
76
|
},
|
|
78
77
|
(assets) => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
@@ -90,8 +89,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
90
89
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
91
90
|
if (Array.isArray(groupedEntries.html)) {
|
|
92
91
|
let noCachedCount = 0;
|
|
93
|
-
for (
|
|
94
|
-
const [file, originalSource] =
|
|
92
|
+
for (const element of groupedEntries.html) {
|
|
93
|
+
const [file, originalSource] = element;
|
|
95
94
|
const rawSource = originalSource.source().toString();
|
|
96
95
|
const hash = cache.computeHash(rawSource);
|
|
97
96
|
const cacheKey = file;
|
|
@@ -127,8 +126,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
127
126
|
}
|
|
128
127
|
if (Array.isArray(groupedEntries.js)) {
|
|
129
128
|
let noCachedCount = 0;
|
|
130
|
-
for (
|
|
131
|
-
const [file, originalSource] =
|
|
129
|
+
for (const element of groupedEntries.js) {
|
|
130
|
+
const [file, originalSource] = element;
|
|
132
131
|
const cacheKey = _chunk35CYTBPMjs.removeExt.call(void 0, file);
|
|
133
132
|
yield cache.process(
|
|
134
133
|
cacheKey,
|
|
@@ -168,8 +167,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
168
167
|
}
|
|
169
168
|
if (Array.isArray(groupedEntries.css)) {
|
|
170
169
|
let noCachedCount = 0;
|
|
171
|
-
for (
|
|
172
|
-
const [file, originalSource] =
|
|
170
|
+
for (const element of groupedEntries.css) {
|
|
171
|
+
const [file, originalSource] = element;
|
|
173
172
|
const rawSource = originalSource.source().toString();
|
|
174
173
|
const hash = cache.computeHash(rawSource);
|
|
175
174
|
const cacheKey = file;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/constants.ts
|
|
2
|
+
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
3
|
+
var vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
|
|
4
|
+
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/wxml/shared.ts
|
|
2
|
-
import { escape,
|
|
2
|
+
import { escape, MappingChars2String } from "@weapp-core/escape";
|
|
3
3
|
function replaceWxml(original, options = {
|
|
4
4
|
keepEOL: false,
|
|
5
|
-
escapeMap:
|
|
5
|
+
escapeMap: MappingChars2String
|
|
6
6
|
}) {
|
|
7
7
|
const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
|
|
8
8
|
let res = original;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceWxml
|
|
3
|
+
} from "./chunk-PCBSAFQF.mjs";
|
|
1
4
|
import {
|
|
2
5
|
getDefaultOptions
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RHTRRSP3.mjs";
|
|
4
7
|
import {
|
|
5
8
|
defuOverrideArray,
|
|
6
9
|
isMap
|
|
7
10
|
} from "./chunk-MUJ65IQ3.mjs";
|
|
8
|
-
import {
|
|
9
|
-
getPlugins
|
|
10
|
-
} from "./chunk-KE7J6XFD.mjs";
|
|
11
|
-
import {
|
|
12
|
-
replaceWxml
|
|
13
|
-
} from "./chunk-U7O2XXYR.mjs";
|
|
14
11
|
import {
|
|
15
12
|
__async,
|
|
16
13
|
__spreadProps,
|
|
@@ -98,6 +95,12 @@ function createCache(options) {
|
|
|
98
95
|
}
|
|
99
96
|
};
|
|
100
97
|
}
|
|
98
|
+
function initializeCache(cacheConfig) {
|
|
99
|
+
if (typeof cacheConfig === "boolean" || cacheConfig === void 0) {
|
|
100
|
+
return createCache(cacheConfig);
|
|
101
|
+
}
|
|
102
|
+
return cacheConfig;
|
|
103
|
+
}
|
|
101
104
|
|
|
102
105
|
// src/js/ast-grep.ts
|
|
103
106
|
import MagicString from "magic-string";
|
|
@@ -105,16 +108,7 @@ import MagicString from "magic-string";
|
|
|
105
108
|
// src/js/handlers.ts
|
|
106
109
|
import { jsStringEscape } from "@ast-core/escape";
|
|
107
110
|
import { escapeStringRegexp } from "@weapp-core/regex";
|
|
108
|
-
|
|
109
|
-
// src/extractors/split.ts
|
|
110
|
-
var validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
|
|
111
|
-
function isValidSelector(selector = "") {
|
|
112
|
-
return validateFilterRE.test(selector);
|
|
113
|
-
}
|
|
114
|
-
function splitCode(code, allowDoubleQuotes = false) {
|
|
115
|
-
const splitter = allowDoubleQuotes ? /\s+/ : /\s+|"/;
|
|
116
|
-
return code.split(splitter).filter((element) => isValidSelector(element));
|
|
117
|
-
}
|
|
111
|
+
import { splitCode } from "@weapp-tailwindcss/shared/extractors";
|
|
118
112
|
|
|
119
113
|
// src/utils/decode.ts
|
|
120
114
|
function decodeUnicode2(input) {
|
|
@@ -128,13 +122,13 @@ function decodeUnicode2(input) {
|
|
|
128
122
|
// src/js/handlers.ts
|
|
129
123
|
function replaceHandleValue(str, node, options, ms, offset = 0) {
|
|
130
124
|
const {
|
|
131
|
-
classNameSet
|
|
125
|
+
classNameSet,
|
|
132
126
|
escapeMap,
|
|
133
127
|
mangleContext: ctx,
|
|
134
128
|
needEscaped = false,
|
|
135
129
|
jsPreserveClass,
|
|
136
130
|
arbitraryValues,
|
|
137
|
-
|
|
131
|
+
alwaysEscape,
|
|
138
132
|
unescapeUnicode
|
|
139
133
|
} = options;
|
|
140
134
|
const allowDoubleQuotes = arbitraryValues == null ? void 0 : arbitraryValues.allowDoubleQuotes;
|
|
@@ -145,7 +139,7 @@ function replaceHandleValue(str, node, options, ms, offset = 0) {
|
|
|
145
139
|
}
|
|
146
140
|
const arr = splitCode(rawStr, allowDoubleQuotes);
|
|
147
141
|
for (const v of arr) {
|
|
148
|
-
if (
|
|
142
|
+
if (alwaysEscape || classNameSet && classNameSet.has(v) && !(jsPreserveClass == null ? void 0 : jsPreserveClass(v))) {
|
|
149
143
|
let ignoreFlag = false;
|
|
150
144
|
if (Array.isArray(node.leadingComments)) {
|
|
151
145
|
ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes("weapp-tw") && x.value.includes("ignore")) > -1;
|
|
@@ -283,13 +277,11 @@ import { jsStringEscape as jsStringEscape2 } from "@ast-core/escape";
|
|
|
283
277
|
import MagicString2 from "magic-string";
|
|
284
278
|
|
|
285
279
|
// src/babel/index.ts
|
|
286
|
-
import _babelGenerate from "@babel/generator";
|
|
287
280
|
import _babelTraverse from "@babel/traverse";
|
|
288
281
|
import { parse, parseExpression } from "@babel/parser";
|
|
289
282
|
function _interopDefaultCompat(e) {
|
|
290
283
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
291
284
|
}
|
|
292
|
-
var generate = _interopDefaultCompat(_babelGenerate);
|
|
293
285
|
var traverse = _interopDefaultCompat(_babelTraverse);
|
|
294
286
|
|
|
295
287
|
// src/js/babel.ts
|
|
@@ -437,9 +429,9 @@ function createJsHandler(options) {
|
|
|
437
429
|
ignoreCallExpressionIdentifiers,
|
|
438
430
|
ignoreTaggedTemplateExpressionIdentifiers
|
|
439
431
|
} = options;
|
|
440
|
-
function
|
|
432
|
+
function handler(rawSource, classNameSet, options2) {
|
|
441
433
|
const opts = defuOverrideArray(options2, {
|
|
442
|
-
classNameSet
|
|
434
|
+
classNameSet,
|
|
443
435
|
escapeMap,
|
|
444
436
|
arbitraryValues,
|
|
445
437
|
mangleContext,
|
|
@@ -455,9 +447,9 @@ function createJsHandler(options) {
|
|
|
455
447
|
}
|
|
456
448
|
return jsHandler(rawSource, opts);
|
|
457
449
|
}
|
|
458
|
-
function sync(rawSource,
|
|
450
|
+
function sync(rawSource, classNameSet, options2) {
|
|
459
451
|
const opts = defuOverrideArray(options2, {
|
|
460
|
-
classNameSet
|
|
452
|
+
classNameSet,
|
|
461
453
|
escapeMap,
|
|
462
454
|
arbitraryValues,
|
|
463
455
|
mangleContext,
|
|
@@ -470,117 +462,12 @@ function createJsHandler(options) {
|
|
|
470
462
|
});
|
|
471
463
|
return jsHandler(rawSource, opts);
|
|
472
464
|
}
|
|
473
|
-
|
|
474
|
-
return
|
|
465
|
+
handler.sync = sync;
|
|
466
|
+
return handler;
|
|
475
467
|
}
|
|
476
468
|
|
|
477
|
-
// src/
|
|
478
|
-
import {
|
|
479
|
-
import { escapeStringRegexp as escapeStringRegexp2 } from "@weapp-core/regex";
|
|
480
|
-
function getSelf(x) {
|
|
481
|
-
return x;
|
|
482
|
-
}
|
|
483
|
-
var defaultMangleContext = {
|
|
484
|
-
rawOptions: false,
|
|
485
|
-
runtimeSet: /* @__PURE__ */ new Set(),
|
|
486
|
-
classGenerator: new ClassGenerator(),
|
|
487
|
-
filter: defaultMangleClassFilter,
|
|
488
|
-
cssHandler: getSelf,
|
|
489
|
-
jsHandler: getSelf,
|
|
490
|
-
wxmlHandler: getSelf
|
|
491
|
-
};
|
|
492
|
-
function useMangleStore() {
|
|
493
|
-
const ctx = Object.assign({}, defaultMangleContext);
|
|
494
|
-
function resetMangle() {
|
|
495
|
-
return Object.assign(ctx, defaultMangleContext);
|
|
496
|
-
}
|
|
497
|
-
function handleValue(rawSource) {
|
|
498
|
-
const arr = splitCode(rawSource);
|
|
499
|
-
for (const x of arr) {
|
|
500
|
-
if (ctx.runtimeSet.has(x)) {
|
|
501
|
-
rawSource = rawSource.replace(new RegExp(escapeStringRegexp2(x)), ctx.classGenerator.generateClassName(x).name);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
return rawSource;
|
|
505
|
-
}
|
|
506
|
-
function initMangle(options) {
|
|
507
|
-
var _a;
|
|
508
|
-
ctx.rawOptions = options;
|
|
509
|
-
if (options) {
|
|
510
|
-
if (options === true) {
|
|
511
|
-
options = {
|
|
512
|
-
classGenerator: {},
|
|
513
|
-
mangleClassFilter: defaultMangleClassFilter
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
ctx.classGenerator = new ClassGenerator(options.classGenerator);
|
|
517
|
-
ctx.filter = (_a = options.mangleClassFilter) != null ? _a : defaultMangleClassFilter;
|
|
518
|
-
ctx.jsHandler = (rawSource) => {
|
|
519
|
-
return handleValue(rawSource);
|
|
520
|
-
};
|
|
521
|
-
ctx.cssHandler = (rawSource) => {
|
|
522
|
-
return handleValue(rawSource);
|
|
523
|
-
};
|
|
524
|
-
ctx.wxmlHandler = (rawSource) => {
|
|
525
|
-
return handleValue(rawSource);
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
function setMangleRuntimeSet(runtimeSet) {
|
|
530
|
-
const newSet = /* @__PURE__ */ new Set();
|
|
531
|
-
for (const c of runtimeSet) {
|
|
532
|
-
if (ctx.filter(c)) {
|
|
533
|
-
newSet.add(c);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
ctx.runtimeSet = newSet;
|
|
537
|
-
}
|
|
538
|
-
return {
|
|
539
|
-
mangleContext: ctx,
|
|
540
|
-
resetMangle,
|
|
541
|
-
initMangle,
|
|
542
|
-
setMangleRuntimeSet
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// src/postcss/index.ts
|
|
547
|
-
import postcss from "postcss";
|
|
548
|
-
function styleHandler(rawSource, options) {
|
|
549
|
-
var _a, _b;
|
|
550
|
-
return postcss(getPlugins(options)).process(
|
|
551
|
-
rawSource,
|
|
552
|
-
(_b = (_a = options.postcssOptions) == null ? void 0 : _a.options) != null ? _b : {
|
|
553
|
-
from: void 0
|
|
554
|
-
}
|
|
555
|
-
).async();
|
|
556
|
-
}
|
|
557
|
-
function createStyleHandler(options) {
|
|
558
|
-
return (rawSource, opt) => {
|
|
559
|
-
return styleHandler(
|
|
560
|
-
rawSource,
|
|
561
|
-
defuOverrideArray(opt, options)
|
|
562
|
-
);
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// src/postcss/preflight.ts
|
|
567
|
-
function createInjectPreflight(options) {
|
|
568
|
-
const result = [];
|
|
569
|
-
if (options && typeof options === "object") {
|
|
570
|
-
const entries = Object.entries(options);
|
|
571
|
-
for (const [prop, value] of entries) {
|
|
572
|
-
if (value !== false) {
|
|
573
|
-
result.push({
|
|
574
|
-
prop,
|
|
575
|
-
value: value.toString()
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
return () => {
|
|
581
|
-
return result;
|
|
582
|
-
};
|
|
583
|
-
}
|
|
469
|
+
// src/tailwindcss/index.ts
|
|
470
|
+
import { getPackageInfoSync } from "local-pkg";
|
|
584
471
|
|
|
585
472
|
// src/tailwindcss/patcher.ts
|
|
586
473
|
import path from "node:path";
|
|
@@ -732,7 +619,7 @@ var Tokenizer = class {
|
|
|
732
619
|
function generateCode(match, options = {}) {
|
|
733
620
|
try {
|
|
734
621
|
const { jsHandler: jsHandler2, runtimeSet } = options;
|
|
735
|
-
if (jsHandler2
|
|
622
|
+
if ((jsHandler2 == null ? void 0 : jsHandler2.sync) && runtimeSet) {
|
|
736
623
|
const { code } = jsHandler2.sync(match, runtimeSet);
|
|
737
624
|
return code;
|
|
738
625
|
} else {
|
|
@@ -756,7 +643,7 @@ function generateCode(match, options = {}) {
|
|
|
756
643
|
escapeMap: options.escapeMap,
|
|
757
644
|
classNameSet: options.runtimeSet,
|
|
758
645
|
needEscaped: true,
|
|
759
|
-
|
|
646
|
+
alwaysEscape: true
|
|
760
647
|
},
|
|
761
648
|
ms,
|
|
762
649
|
1
|
|
@@ -866,7 +753,7 @@ function customTemplateHandler(rawSource, options) {
|
|
|
866
753
|
);
|
|
867
754
|
};
|
|
868
755
|
var update = update2;
|
|
869
|
-
if (!disabledDefaultTemplateHandler &&
|
|
756
|
+
if (!disabledDefaultTemplateHandler && ["class", "hover-class", "virtualhostclass"].includes(name.toLocaleLowerCase())) {
|
|
870
757
|
update2();
|
|
871
758
|
}
|
|
872
759
|
for (const [t2, props] of customAttributesEntities) {
|
|
@@ -916,14 +803,16 @@ function createTemplateHandler(options = {}) {
|
|
|
916
803
|
};
|
|
917
804
|
}
|
|
918
805
|
|
|
919
|
-
// src/
|
|
920
|
-
|
|
921
|
-
|
|
806
|
+
// src/context/index.ts
|
|
807
|
+
import { useMangleStore } from "@weapp-tailwindcss/mangle";
|
|
808
|
+
import { createInjectPreflight, createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
809
|
+
function getCompilerContext(opts) {
|
|
810
|
+
const ctx = defuOverrideArray(
|
|
922
811
|
opts,
|
|
923
812
|
getDefaultOptions(),
|
|
924
813
|
{}
|
|
925
814
|
);
|
|
926
|
-
|
|
815
|
+
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
927
816
|
const {
|
|
928
817
|
cssPreflight,
|
|
929
818
|
customRuleCallback,
|
|
@@ -949,12 +838,12 @@ function getOptions(opts) {
|
|
|
949
838
|
appType,
|
|
950
839
|
ignoreCallExpressionIdentifiers,
|
|
951
840
|
ignoreTaggedTemplateExpressionIdentifiers
|
|
952
|
-
} =
|
|
841
|
+
} = ctx;
|
|
953
842
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
954
843
|
const customAttributesEntities = isMap(customAttributes) ? [...customAttributes.entries()] : Object.entries(customAttributes);
|
|
955
844
|
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
956
845
|
initMangle(mangle);
|
|
957
|
-
const
|
|
846
|
+
const styleHandler = createStyleHandler({
|
|
958
847
|
cssInjectPreflight,
|
|
959
848
|
customRuleCallback,
|
|
960
849
|
cssPreflightRange,
|
|
@@ -986,18 +875,21 @@ function getOptions(opts) {
|
|
|
986
875
|
jsHandler: jsHandler2,
|
|
987
876
|
disabledDefaultTemplateHandler
|
|
988
877
|
});
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
const twPatcher = createTailwindcssPatcher(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
878
|
+
ctx.styleHandler = styleHandler;
|
|
879
|
+
ctx.jsHandler = jsHandler2;
|
|
880
|
+
ctx.templateHandler = templateHandler;
|
|
881
|
+
const twPatcher = createTailwindcssPatcher(
|
|
882
|
+
tailwindcssBasedir,
|
|
883
|
+
appType === "mpx" ? "node_modules/tailwindcss-patch/.cache" : void 0,
|
|
884
|
+
supportCustomLengthUnitsPatch != null ? supportCustomLengthUnitsPatch : true
|
|
885
|
+
);
|
|
886
|
+
ctx.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
887
|
+
ctx.cache = initializeCache(cache);
|
|
888
|
+
ctx.twPatcher = twPatcher;
|
|
889
|
+
return ctx;
|
|
998
890
|
}
|
|
999
891
|
|
|
1000
892
|
export {
|
|
1001
893
|
logger,
|
|
1002
|
-
|
|
894
|
+
getCompilerContext
|
|
1003
895
|
};
|