weapp-tailwindcss 3.0.10 → 3.1.0
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/cache/index.d.ts +2 -1
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +13 -11
- package/dist/core.mjs +13 -11
- package/dist/css-macro/postcss.js +3 -3
- package/dist/css-macro/postcss.mjs +3 -3
- package/dist/gulp.js +5 -3
- package/dist/gulp.mjs +5 -3
- package/dist/{index-DfbtBzIV.mjs → index-BatBMY3C.mjs} +10 -10
- package/dist/index-C9cFs8_u.js +136 -0
- package/dist/{index-CKzzVDhq.js → index-CarwQa1I.js} +6 -2
- package/dist/{index-CLxBL7MC.mjs → index-CsZGfl55.mjs} +3 -2
- package/dist/index-DEWZ8_xX.mjs +130 -0
- package/dist/{index-C7QwtXvo.mjs → index-DKNUquoz.mjs} +6 -2
- package/dist/{index-CKXO21Qe.js → index-DyK5Vd4R.js} +3 -2
- package/dist/{index-BBGsdK79.js → index-jf-1m663.js} +10 -10
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -6
- package/dist/js/handlers.d.ts +9 -2
- package/dist/js/index.d.ts +2 -1
- package/dist/{options-Ce8c4jgF.js → options-AIjWBFPo.js} +154 -60
- package/dist/{options-D74YiXdv.mjs → options-D6Mza941.mjs} +154 -60
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/types.d.ts +7 -3
- package/dist/{v5-B5nztYEa.js → v5-BV64BMJS.js} +10 -10
- package/dist/{v5-KEbKT7UN.mjs → v5-CH-EIloz.mjs} +10 -10
- package/dist/vite.js +4 -4
- package/dist/vite.mjs +4 -4
- package/dist/webpack.js +4 -4
- package/dist/webpack.mjs +4 -4
- package/dist/webpack4.js +10 -10
- package/dist/webpack4.mjs +10 -10
- package/dist/wxml/utils.d.ts +2 -2
- package/package.json +41 -36
- package/dist/index-DMO3Y3vp.mjs +0 -64
- package/dist/index-DXyNWU95.js +0 -70
package/dist/cache/index.d.ts
CHANGED
|
@@ -26,5 +26,6 @@ export interface ICreateCacheReturnType {
|
|
|
26
26
|
source: CacheValue;
|
|
27
27
|
}>) => void | Promise<void>;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
export type ICreateCacheOptions = boolean;
|
|
30
|
+
declare function createCache(options?: ICreateCacheOptions): ICreateCacheReturnType;
|
|
30
31
|
export { createCache };
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var semver = require('semver');
|
|
4
|
-
var options = require('./options-
|
|
5
|
-
var index = require('./index-
|
|
4
|
+
var options = require('./options-AIjWBFPo.js');
|
|
5
|
+
var index = require('./index-CarwQa1I.js');
|
|
6
6
|
require('magic-string');
|
|
7
7
|
require('./replace.js');
|
|
8
8
|
require('@weapp-core/escape');
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
-
import { g as getOptions, a as createPatch } from './options-
|
|
3
|
-
import { W as WEAPP_TW_REQUIRED_NODE_VERSION } from './index-
|
|
2
|
+
import { g as getOptions, a as createPatch } from './options-D6Mza941.mjs';
|
|
3
|
+
import { W as WEAPP_TW_REQUIRED_NODE_VERSION } from './index-DKNUquoz.mjs';
|
|
4
4
|
import 'magic-string';
|
|
5
5
|
import './replace.mjs';
|
|
6
6
|
import '@weapp-core/escape';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UserDefinedOptions } from "./types";
|
|
2
2
|
export declare function createContext(options?: UserDefinedOptions): {
|
|
3
3
|
transformWxss: (rawCss: string) => Promise<string>;
|
|
4
|
-
transformWxml: (rawWxml: string) => string
|
|
4
|
+
transformWxml: (rawWxml: string) => Promise<string>;
|
|
5
5
|
transformJs: (rawJs: string, options?: {
|
|
6
6
|
runtimeSet?: Set<string> | undefined;
|
|
7
|
-
}) => string
|
|
7
|
+
}) => Promise<string>;
|
|
8
8
|
};
|
package/dist/core.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var options = require('./options-
|
|
5
|
+
var options = require('./options-AIjWBFPo.js');
|
|
6
6
|
require('magic-string');
|
|
7
7
|
require('./replace.js');
|
|
8
8
|
require('@weapp-core/escape');
|
|
@@ -17,7 +17,7 @@ require('./defu-Cdz2PomB.js');
|
|
|
17
17
|
require('@babel/types');
|
|
18
18
|
require('htmlparser2');
|
|
19
19
|
require('postcss');
|
|
20
|
-
require('./index-
|
|
20
|
+
require('./index-CarwQa1I.js');
|
|
21
21
|
require('@csstools/postcss-is-pseudo-class');
|
|
22
22
|
require('postcss-rem-to-responsive-pixel');
|
|
23
23
|
require('postcss-selector-parser');
|
|
@@ -43,15 +43,17 @@ function createContext(options$1 = {}) {
|
|
|
43
43
|
return code;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
function transformJs(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
function transformJs(rawJs_1) {
|
|
47
|
+
return options.__awaiter(this, arguments, void 0, function* (rawJs, options = {}) {
|
|
48
|
+
runtimeSet =
|
|
49
|
+
options && options.runtimeSet
|
|
50
|
+
? options.runtimeSet
|
|
51
|
+
: twPatcher.getClassSet({
|
|
52
|
+
basedir: tailwindcssBasedir
|
|
53
|
+
});
|
|
54
|
+
const { code } = yield jsHandler(rawJs, runtimeSet);
|
|
55
|
+
return code;
|
|
56
|
+
});
|
|
55
57
|
}
|
|
56
58
|
function transformWxml(rawWxml) {
|
|
57
59
|
const code = templateHandler(rawWxml, {
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D6Mza941.mjs';
|
|
2
2
|
import 'magic-string';
|
|
3
3
|
import './replace.mjs';
|
|
4
4
|
import '@weapp-core/escape';
|
|
@@ -13,7 +13,7 @@ import './defu-n46TJT6t.mjs';
|
|
|
13
13
|
import '@babel/types';
|
|
14
14
|
import 'htmlparser2';
|
|
15
15
|
import 'postcss';
|
|
16
|
-
import './index-
|
|
16
|
+
import './index-DKNUquoz.mjs';
|
|
17
17
|
import '@csstools/postcss-is-pseudo-class';
|
|
18
18
|
import 'postcss-rem-to-responsive-pixel';
|
|
19
19
|
import 'postcss-selector-parser';
|
|
@@ -39,15 +39,17 @@ function createContext(options = {}) {
|
|
|
39
39
|
return code;
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function transformJs(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
function transformJs(rawJs_1) {
|
|
43
|
+
return __awaiter(this, arguments, void 0, function* (rawJs, options = {}) {
|
|
44
|
+
runtimeSet =
|
|
45
|
+
options && options.runtimeSet
|
|
46
|
+
? options.runtimeSet
|
|
47
|
+
: twPatcher.getClassSet({
|
|
48
|
+
basedir: tailwindcssBasedir
|
|
49
|
+
});
|
|
50
|
+
const { code } = yield jsHandler(rawJs, runtimeSet);
|
|
51
|
+
return code;
|
|
52
|
+
});
|
|
51
53
|
}
|
|
52
54
|
function transformWxml(rawWxml) {
|
|
53
55
|
const code = templateHandler(rawWxml, {
|
|
@@ -8,6 +8,7 @@ const creator = () => {
|
|
|
8
8
|
prepare() {
|
|
9
9
|
return {
|
|
10
10
|
AtRule(atRule, helper) {
|
|
11
|
+
var _a;
|
|
11
12
|
if (atRule.name === 'media') {
|
|
12
13
|
const values = [];
|
|
13
14
|
constants.matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
@@ -17,14 +18,14 @@ const creator = () => {
|
|
|
17
18
|
const isNegative = atRule.params.includes('not');
|
|
18
19
|
const text = values.join(' ');
|
|
19
20
|
const comment = isNegative ? constants.ifndef(text) : constants.ifdef(text);
|
|
20
|
-
atRule.
|
|
21
|
+
atRule.replaceWith([
|
|
21
22
|
helper.comment({
|
|
22
23
|
raws: {
|
|
23
24
|
before: '\n'
|
|
24
25
|
},
|
|
25
26
|
text: comment.start
|
|
26
27
|
}),
|
|
27
|
-
...atRule.nodes,
|
|
28
|
+
...((_a = atRule.nodes) !== null && _a !== void 0 ? _a : []),
|
|
28
29
|
helper.comment({
|
|
29
30
|
raws: {
|
|
30
31
|
before: '\n'
|
|
@@ -32,7 +33,6 @@ const creator = () => {
|
|
|
32
33
|
text: comment.end
|
|
33
34
|
})
|
|
34
35
|
]);
|
|
35
|
-
atRule.remove();
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
},
|
|
@@ -6,6 +6,7 @@ const creator = () => {
|
|
|
6
6
|
prepare() {
|
|
7
7
|
return {
|
|
8
8
|
AtRule(atRule, helper) {
|
|
9
|
+
var _a;
|
|
9
10
|
if (atRule.name === 'media') {
|
|
10
11
|
const values = [];
|
|
11
12
|
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
@@ -15,14 +16,14 @@ const creator = () => {
|
|
|
15
16
|
const isNegative = atRule.params.includes('not');
|
|
16
17
|
const text = values.join(' ');
|
|
17
18
|
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
18
|
-
atRule.
|
|
19
|
+
atRule.replaceWith([
|
|
19
20
|
helper.comment({
|
|
20
21
|
raws: {
|
|
21
22
|
before: '\n'
|
|
22
23
|
},
|
|
23
24
|
text: comment.start
|
|
24
25
|
}),
|
|
25
|
-
...atRule.nodes,
|
|
26
|
+
...((_a = atRule.nodes) !== null && _a !== void 0 ? _a : []),
|
|
26
27
|
helper.comment({
|
|
27
28
|
raws: {
|
|
28
29
|
before: '\n'
|
|
@@ -30,7 +31,6 @@ const creator = () => {
|
|
|
30
31
|
text: comment.end
|
|
31
32
|
})
|
|
32
33
|
]);
|
|
33
|
-
atRule.remove();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
},
|
package/dist/gulp.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
6
|
-
require('./options-
|
|
5
|
+
var index = require('./index-C9cFs8_u.js');
|
|
6
|
+
require('./options-AIjWBFPo.js');
|
|
7
7
|
require('magic-string');
|
|
8
8
|
require('./replace.js');
|
|
9
9
|
require('@weapp-core/escape');
|
|
@@ -18,7 +18,7 @@ require('./defu-Cdz2PomB.js');
|
|
|
18
18
|
require('@babel/types');
|
|
19
19
|
require('htmlparser2');
|
|
20
20
|
require('postcss');
|
|
21
|
-
require('./index-
|
|
21
|
+
require('./index-CarwQa1I.js');
|
|
22
22
|
require('@csstools/postcss-is-pseudo-class');
|
|
23
23
|
require('postcss-rem-to-responsive-pixel');
|
|
24
24
|
require('postcss-selector-parser');
|
|
@@ -30,6 +30,8 @@ require('@tailwindcss-mangle/shared');
|
|
|
30
30
|
require('lru-cache');
|
|
31
31
|
require('md5');
|
|
32
32
|
require('node:stream');
|
|
33
|
+
require('./index-DyK5Vd4R.js');
|
|
34
|
+
require('debug');
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { c as createPlugins } from './index-
|
|
2
|
-
import './options-
|
|
1
|
+
export { c as createPlugins } from './index-DEWZ8_xX.mjs';
|
|
2
|
+
import './options-D6Mza941.mjs';
|
|
3
3
|
import 'magic-string';
|
|
4
4
|
import './replace.mjs';
|
|
5
5
|
import '@weapp-core/escape';
|
|
@@ -14,7 +14,7 @@ import './defu-n46TJT6t.mjs';
|
|
|
14
14
|
import '@babel/types';
|
|
15
15
|
import 'htmlparser2';
|
|
16
16
|
import 'postcss';
|
|
17
|
-
import './index-
|
|
17
|
+
import './index-DKNUquoz.mjs';
|
|
18
18
|
import '@csstools/postcss-is-pseudo-class';
|
|
19
19
|
import 'postcss-rem-to-responsive-pixel';
|
|
20
20
|
import 'postcss-selector-parser';
|
|
@@ -26,3 +26,5 @@ import '@tailwindcss-mangle/shared';
|
|
|
26
26
|
import 'lru-cache';
|
|
27
27
|
import 'md5';
|
|
28
28
|
import 'node:stream';
|
|
29
|
+
import './index-CsZGfl55.mjs';
|
|
30
|
+
import 'debug';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-
|
|
2
|
-
import { v as vitePluginName } from './index-
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D6Mza941.mjs';
|
|
2
|
+
import { v as vitePluginName } from './index-DKNUquoz.mjs';
|
|
3
3
|
import { g as getGroupedEntries } from './defaults-CBb6_9nJ.mjs';
|
|
4
|
-
import { c as createDebug } from './index-
|
|
4
|
+
import { c as createDebug } from './index-CsZGfl55.mjs';
|
|
5
5
|
|
|
6
|
-
const debug = createDebug(
|
|
6
|
+
const debug = createDebug();
|
|
7
7
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
8
8
|
if (options.customReplaceDictionary === undefined) {
|
|
9
9
|
options.customReplaceDictionary = 'simple';
|
|
@@ -46,8 +46,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
46
46
|
else {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
-
}, () => {
|
|
50
|
-
originalSource.source = templateHandler(oldVal, {
|
|
49
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
originalSource.source = yield templateHandler(oldVal, {
|
|
51
51
|
runtimeSet
|
|
52
52
|
});
|
|
53
53
|
onUpdate(file, oldVal, originalSource.source);
|
|
@@ -57,7 +57,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
57
57
|
key: file,
|
|
58
58
|
source: originalSource.source
|
|
59
59
|
};
|
|
60
|
-
});
|
|
60
|
+
}));
|
|
61
61
|
}
|
|
62
62
|
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
63
63
|
}
|
|
@@ -77,10 +77,10 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
77
77
|
else {
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
|
-
}, () => {
|
|
80
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
81
81
|
const mapFilename = file + '.map';
|
|
82
82
|
const hasMap = Boolean(bundle[mapFilename]);
|
|
83
|
-
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
83
|
+
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
84
84
|
generateMap: hasMap
|
|
85
85
|
});
|
|
86
86
|
originalSource.code = code;
|
|
@@ -94,7 +94,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
94
94
|
key: file,
|
|
95
95
|
source: code
|
|
96
96
|
};
|
|
97
|
-
});
|
|
97
|
+
}));
|
|
98
98
|
}
|
|
99
99
|
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
100
100
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var options = require('./options-AIjWBFPo.js');
|
|
4
|
+
var stream = require('node:stream');
|
|
5
|
+
var index = require('./index-DyK5Vd4R.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var stream__default = /*#__PURE__*/_interopDefaultCompat(stream);
|
|
10
|
+
|
|
11
|
+
const debug = index.createDebug();
|
|
12
|
+
const Transform = stream__default["default"].Transform;
|
|
13
|
+
function createPlugins(options$1 = {}) {
|
|
14
|
+
const opts = options.getOptions(options$1);
|
|
15
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir, cache } = opts;
|
|
16
|
+
let runtimeSet = new Set();
|
|
17
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
18
|
+
const twPatcher = options.createTailwindcssPatcher();
|
|
19
|
+
function transformWxss() {
|
|
20
|
+
return new Transform({
|
|
21
|
+
objectMode: true,
|
|
22
|
+
transform: function (file, encoding, callback) {
|
|
23
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
runtimeSet = twPatcher.getClassSet({
|
|
25
|
+
basedir: tailwindcssBasedir
|
|
26
|
+
});
|
|
27
|
+
setMangleRuntimeSet(runtimeSet);
|
|
28
|
+
const error = null;
|
|
29
|
+
if (file.contents) {
|
|
30
|
+
const rawSource = file.contents.toString();
|
|
31
|
+
const hash = cache.computeHash(rawSource);
|
|
32
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
33
|
+
yield cache.process(file.path, () => {
|
|
34
|
+
const source = cache.get(file.path);
|
|
35
|
+
if (source) {
|
|
36
|
+
file.contents = Buffer.from(source);
|
|
37
|
+
debug('css cache hit: %s', file.path);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const code = yield styleHandler(rawSource, {
|
|
44
|
+
isMainChunk: true
|
|
45
|
+
});
|
|
46
|
+
file.contents = Buffer.from(code);
|
|
47
|
+
debug('css handle: %s', file.path);
|
|
48
|
+
return {
|
|
49
|
+
key: file.path,
|
|
50
|
+
source: code
|
|
51
|
+
};
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
callback(error, file);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function transformJs() {
|
|
60
|
+
return new Transform({
|
|
61
|
+
objectMode: true,
|
|
62
|
+
transform: function (file, encoding, callback) {
|
|
63
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const error = null;
|
|
65
|
+
if (file.contents) {
|
|
66
|
+
const rawSource = file.contents.toString();
|
|
67
|
+
const hash = cache.computeHash(rawSource);
|
|
68
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
69
|
+
yield cache.process(file.path, () => {
|
|
70
|
+
const source = cache.get(file.path);
|
|
71
|
+
if (source) {
|
|
72
|
+
file.contents = Buffer.from(source);
|
|
73
|
+
debug('js cache hit: %s', file.path);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const { code } = yield jsHandler(rawSource, runtimeSet);
|
|
80
|
+
file.contents = Buffer.from(code);
|
|
81
|
+
debug('js handle: %s', file.path);
|
|
82
|
+
return {
|
|
83
|
+
key: file.path,
|
|
84
|
+
source: code
|
|
85
|
+
};
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
callback(error, file);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function transformWxml() {
|
|
94
|
+
return new Transform({
|
|
95
|
+
objectMode: true,
|
|
96
|
+
transform: function (file, encoding, callback) {
|
|
97
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const error = null;
|
|
99
|
+
if (file.contents) {
|
|
100
|
+
const rawSource = file.contents.toString();
|
|
101
|
+
const hash = cache.computeHash(rawSource);
|
|
102
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
103
|
+
yield cache.process(file.path, () => {
|
|
104
|
+
const source = cache.get(file.path);
|
|
105
|
+
if (source) {
|
|
106
|
+
file.contents = Buffer.from(source);
|
|
107
|
+
debug('html cache hit: %s', file.path);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const code = yield templateHandler(rawSource, {
|
|
114
|
+
runtimeSet
|
|
115
|
+
});
|
|
116
|
+
file.contents = Buffer.from(code);
|
|
117
|
+
debug('html handle: %s', file.path);
|
|
118
|
+
return {
|
|
119
|
+
key: file.path,
|
|
120
|
+
source: code
|
|
121
|
+
};
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
callback(error, file);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
transformWxss,
|
|
131
|
+
transformWxml,
|
|
132
|
+
transformJs
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports.createPlugins = createPlugins;
|
|
@@ -396,8 +396,12 @@ const postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
396
396
|
},
|
|
397
397
|
AtRule(atRule) {
|
|
398
398
|
if (isAtMediaHover(atRule)) {
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
if (atRule.nodes) {
|
|
400
|
+
atRule.replaceWith(atRule.nodes);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
atRule.remove();
|
|
404
|
+
}
|
|
401
405
|
}
|
|
402
406
|
}
|
|
403
407
|
};
|
|
@@ -2,9 +2,10 @@ import _createDebug from 'debug';
|
|
|
2
2
|
|
|
3
3
|
const _debug = _createDebug('weapp-tw');
|
|
4
4
|
function createDebug(prefix) {
|
|
5
|
-
|
|
5
|
+
function debug(formatter, ...args) {
|
|
6
6
|
return _debug((prefix !== null && prefix !== void 0 ? prefix : '') + formatter, ...args);
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
return debug;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export { createDebug as c };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-D6Mza941.mjs';
|
|
2
|
+
import stream from 'node:stream';
|
|
3
|
+
import { c as createDebug } from './index-CsZGfl55.mjs';
|
|
4
|
+
|
|
5
|
+
const debug = createDebug();
|
|
6
|
+
const Transform = stream.Transform;
|
|
7
|
+
function createPlugins(options = {}) {
|
|
8
|
+
const opts = getOptions(options);
|
|
9
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir, cache } = opts;
|
|
10
|
+
let runtimeSet = new Set();
|
|
11
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
12
|
+
const twPatcher = createTailwindcssPatcher();
|
|
13
|
+
function transformWxss() {
|
|
14
|
+
return new Transform({
|
|
15
|
+
objectMode: true,
|
|
16
|
+
transform: function (file, encoding, callback) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
runtimeSet = twPatcher.getClassSet({
|
|
19
|
+
basedir: tailwindcssBasedir
|
|
20
|
+
});
|
|
21
|
+
setMangleRuntimeSet(runtimeSet);
|
|
22
|
+
const error = null;
|
|
23
|
+
if (file.contents) {
|
|
24
|
+
const rawSource = file.contents.toString();
|
|
25
|
+
const hash = cache.computeHash(rawSource);
|
|
26
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
27
|
+
yield cache.process(file.path, () => {
|
|
28
|
+
const source = cache.get(file.path);
|
|
29
|
+
if (source) {
|
|
30
|
+
file.contents = Buffer.from(source);
|
|
31
|
+
debug('css cache hit: %s', file.path);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const code = yield styleHandler(rawSource, {
|
|
38
|
+
isMainChunk: true
|
|
39
|
+
});
|
|
40
|
+
file.contents = Buffer.from(code);
|
|
41
|
+
debug('css handle: %s', file.path);
|
|
42
|
+
return {
|
|
43
|
+
key: file.path,
|
|
44
|
+
source: code
|
|
45
|
+
};
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
callback(error, file);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function transformJs() {
|
|
54
|
+
return new Transform({
|
|
55
|
+
objectMode: true,
|
|
56
|
+
transform: function (file, encoding, callback) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const error = null;
|
|
59
|
+
if (file.contents) {
|
|
60
|
+
const rawSource = file.contents.toString();
|
|
61
|
+
const hash = cache.computeHash(rawSource);
|
|
62
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
63
|
+
yield cache.process(file.path, () => {
|
|
64
|
+
const source = cache.get(file.path);
|
|
65
|
+
if (source) {
|
|
66
|
+
file.contents = Buffer.from(source);
|
|
67
|
+
debug('js cache hit: %s', file.path);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const { code } = yield jsHandler(rawSource, runtimeSet);
|
|
74
|
+
file.contents = Buffer.from(code);
|
|
75
|
+
debug('js handle: %s', file.path);
|
|
76
|
+
return {
|
|
77
|
+
key: file.path,
|
|
78
|
+
source: code
|
|
79
|
+
};
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
callback(error, file);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function transformWxml() {
|
|
88
|
+
return new Transform({
|
|
89
|
+
objectMode: true,
|
|
90
|
+
transform: function (file, encoding, callback) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const error = null;
|
|
93
|
+
if (file.contents) {
|
|
94
|
+
const rawSource = file.contents.toString();
|
|
95
|
+
const hash = cache.computeHash(rawSource);
|
|
96
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
97
|
+
yield cache.process(file.path, () => {
|
|
98
|
+
const source = cache.get(file.path);
|
|
99
|
+
if (source) {
|
|
100
|
+
file.contents = Buffer.from(source);
|
|
101
|
+
debug('html cache hit: %s', file.path);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const code = yield templateHandler(rawSource, {
|
|
108
|
+
runtimeSet
|
|
109
|
+
});
|
|
110
|
+
file.contents = Buffer.from(code);
|
|
111
|
+
debug('html handle: %s', file.path);
|
|
112
|
+
return {
|
|
113
|
+
key: file.path,
|
|
114
|
+
source: code
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
callback(error, file);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
transformWxss,
|
|
125
|
+
transformWxml,
|
|
126
|
+
transformJs
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { createPlugins as c };
|
|
@@ -388,8 +388,12 @@ const postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
388
388
|
},
|
|
389
389
|
AtRule(atRule) {
|
|
390
390
|
if (isAtMediaHover(atRule)) {
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
if (atRule.nodes) {
|
|
392
|
+
atRule.replaceWith(atRule.nodes);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
atRule.remove();
|
|
396
|
+
}
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
399
|
};
|
|
@@ -8,9 +8,10 @@ var _createDebug__default = /*#__PURE__*/_interopDefaultCompat(_createDebug);
|
|
|
8
8
|
|
|
9
9
|
const _debug = _createDebug__default["default"]('weapp-tw');
|
|
10
10
|
function createDebug(prefix) {
|
|
11
|
-
|
|
11
|
+
function debug(formatter, ...args) {
|
|
12
12
|
return _debug((prefix !== null && prefix !== void 0 ? prefix : '') + formatter, ...args);
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
|
+
return debug;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
exports.createDebug = createDebug;
|