weapp-tailwindcss 2.9.1 → 2.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/dist/cache/index.d.ts +5 -2
- package/dist/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/gulp.js +15 -11
- package/dist/gulp.mjs +15 -11
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{options-b96f6338.js → options-09ebba08.js} +56 -17
- package/dist/{options-f70d1c6f.mjs → options-63407615.mjs} +56 -18
- package/dist/postcss/index.d.ts +2 -2
- package/dist/types.d.ts +3 -1
- package/dist/vite.js +110 -106
- package/dist/vite.mjs +110 -106
- package/dist/webpack.js +15 -13
- package/dist/webpack.mjs +15 -13
- package/package.json +32 -28
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
> `小程序` + `tailwindcss` 全方面解决方案
|
|
25
25
|
> 想试试在小程序里使用 `CSS-in-JS` 思想? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
|
|
26
26
|
|
|
27
|
-
\[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档](./v1.md)\]
|
|
27
|
+
\[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
|
|
28
28
|
|
|
29
29
|
- [Tips](#tips)
|
|
30
30
|
- [特性](#特性)
|
|
@@ -43,13 +43,15 @@
|
|
|
43
43
|
- [使用`hbuilderx` 进行构建和开发](#使用hbuilderx-进行构建和开发)
|
|
44
44
|
- [使用`tarojs`进行构建 `vscode`开发](#使用tarojs进行构建-vscode开发)
|
|
45
45
|
- [原生小程序开发模板](#原生小程序开发模板)
|
|
46
|
-
- [tailwindcss plugin](#tailwindcss-plugin)
|
|
47
|
-
- [
|
|
46
|
+
- [tailwindcss plugin / util](#tailwindcss-plugin--util)
|
|
47
|
+
- [weapp-pandacss](#weapp-pandacss)
|
|
48
48
|
- [Bugs \& Issues](#bugs--issues)
|
|
49
49
|
|
|
50
50
|
## Tips
|
|
51
51
|
|
|
52
|
-
自从 `2.3.3` 版本开始,我发布了一个额外的包叫 `weapp-tailwindcss`,它和 `weapp-tailwindcss-webpack-plugin` 代码版本完全一致,且保持发布版本的同步。以后可以都去安装 `weapp-tailwindcss` 这个包(当然现在 `webpack-plugin` 这个包也不会废弃,也会时刻保持版本的同步)。为什么要这么做的原因,主要是因为 `weapp-tailwindcss-webpack-plugin`
|
|
52
|
+
自从 `2.3.3` 版本开始,我发布了一个额外的包叫 `weapp-tailwindcss`,它和 `weapp-tailwindcss-webpack-plugin` 代码版本完全一致,且保持发布版本的同步。以后可以都去安装 `weapp-tailwindcss` 这个包(当然现在 `webpack-plugin` 这个包也不会废弃,也会时刻保持版本的同步)。为什么要这么做的原因,主要是因为 `weapp-tailwindcss-webpack-plugin` 这个名字,已经不适合描述现在这种,多插件并存的状态了,为了以后的发展就改了个名字。
|
|
53
|
+
|
|
54
|
+
前沿阅读: [What’s Tailwind Oxide Engine? The Next Evolution of Tailwind CSS](https://medium.com/@bomber.marek/whats-tailwind-oxide-engine-the-next-evolution-of-tailwind-css-32e7ef8e19a1),未来 `tailwindcss` 会切换到这个引擎来大幅加快构建和运行速度,当然等它发布正式版本的时候,我也会尽可能第一时间去进行兼容新的引擎。
|
|
53
55
|
|
|
54
56
|
## 特性
|
|
55
57
|
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
|
|
64
66
|
### 插件介绍
|
|
65
67
|
|
|
66
|
-
从 `weapp-tailwindcss/webpack` 导出的`UnifiedWebpackPluginV5` 是一个核心插件,所有使用 `
|
|
68
|
+
从 `weapp-tailwindcss/webpack` 导出的`UnifiedWebpackPluginV5` 是一个核心插件,所有使用 `webpack5` 进行打包的框架都可以使用它。
|
|
67
69
|
|
|
68
70
|
从 `weapp-tailwindcss/vite` 导出的`UnifiedViteWeappTailwindcssPlugin` 为 `vite` 专用插件,配置项和使用方式和 `webpack` 插件是一致的。
|
|
69
71
|
|
|
@@ -121,13 +123,15 @@
|
|
|
121
123
|
|
|
122
124
|
[weapp-native-mina-tailwindcss-template(webpack打包)](https://github.com/sonofmagic/weapp-native-mina-tailwindcss-template)
|
|
123
125
|
|
|
124
|
-
### tailwindcss plugin
|
|
126
|
+
### tailwindcss plugin / util
|
|
127
|
+
|
|
128
|
+
- [css-to-tailwindcss-plugin](./packages/css-to-tailwindcss-plugin/) transform your `css/scss` to `tailwindcss plugin`
|
|
125
129
|
|
|
126
|
-
[weapp-tailwindcss-children](https://github.com/sonofmagic/weapp-tailwindcss-children)
|
|
130
|
+
- [weapp-tailwindcss-children](https://github.com/sonofmagic/weapp-tailwindcss-children)
|
|
127
131
|
|
|
128
|
-
###
|
|
132
|
+
### weapp-pandacss
|
|
129
133
|
|
|
130
|
-
[
|
|
134
|
+
[weapp-pandacss](https://github.com/sonofmagic/weapp-pandacss) `CSS-in-JS` 编译时框架的小程序适配器
|
|
131
135
|
|
|
132
136
|
## Bugs & Issues
|
|
133
137
|
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -18,10 +18,13 @@ export interface ICreateCacheReturnType {
|
|
|
18
18
|
set: <V extends CacheValue = sources.Source>(key: string, value: V) => this['instance'];
|
|
19
19
|
has: (key: string) => boolean;
|
|
20
20
|
calcHashValueChanged: (key: HashMapKey, hash: string) => this;
|
|
21
|
-
process: (key: string, callback: () => void | false
|
|
21
|
+
process: (key: string, callback: () => void | false | Promise<void | false>, fallback: () => void | {
|
|
22
22
|
key: string;
|
|
23
23
|
source: CacheValue;
|
|
24
|
-
}
|
|
24
|
+
} | Promise<void | {
|
|
25
|
+
key: string;
|
|
26
|
+
source: CacheValue;
|
|
27
|
+
}>) => void | Promise<void>;
|
|
25
28
|
}
|
|
26
29
|
declare function createCache(): ICreateCacheReturnType;
|
|
27
30
|
export { createCache };
|
package/dist/cli.js
CHANGED
package/dist/cli.mjs
CHANGED
package/dist/gulp.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var options = require('./options-09ebba08.js');
|
|
5
6
|
var stream = require('node:stream');
|
|
6
|
-
var options = require('./options-b96f6338.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('magic-string');
|
|
9
9
|
require('./replace.js');
|
|
@@ -39,23 +39,27 @@ function createPlugins(options$1 = {}) {
|
|
|
39
39
|
options$1.customReplaceDictionary = 'simple';
|
|
40
40
|
}
|
|
41
41
|
const opts = options.getOptions(options$1);
|
|
42
|
-
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
42
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
|
|
43
43
|
let runtimeSet = new Set();
|
|
44
44
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
45
45
|
const twPatcher = options.createTailwindcssPatcher();
|
|
46
46
|
function transformWxss() {
|
|
47
47
|
const transformStream = new Transform({ objectMode: true });
|
|
48
48
|
transformStream._transform = function (file, encoding, callback) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (file.contents) {
|
|
53
|
-
const code = styleHandler(file.contents.toString(), {
|
|
54
|
-
isMainChunk: true
|
|
49
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
runtimeSet = twPatcher.getClassSet({
|
|
51
|
+
basedir: tailwindcssBasedir
|
|
55
52
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
setMangleRuntimeSet(runtimeSet);
|
|
54
|
+
const error = null;
|
|
55
|
+
if (file.contents) {
|
|
56
|
+
const code = yield styleHandler(file.contents.toString(), {
|
|
57
|
+
isMainChunk: true
|
|
58
|
+
});
|
|
59
|
+
file.contents = Buffer.from(code);
|
|
60
|
+
}
|
|
61
|
+
callback(error, file);
|
|
62
|
+
});
|
|
59
63
|
};
|
|
60
64
|
return transformStream;
|
|
61
65
|
}
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-63407615.mjs';
|
|
1
2
|
import stream from 'node:stream';
|
|
2
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-f70d1c6f.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import 'magic-string';
|
|
5
5
|
import './replace.mjs';
|
|
@@ -31,23 +31,27 @@ function createPlugins(options = {}) {
|
|
|
31
31
|
options.customReplaceDictionary = 'simple';
|
|
32
32
|
}
|
|
33
33
|
const opts = getOptions(options);
|
|
34
|
-
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
34
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
|
|
35
35
|
let runtimeSet = new Set();
|
|
36
36
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
37
37
|
const twPatcher = createTailwindcssPatcher();
|
|
38
38
|
function transformWxss() {
|
|
39
39
|
const transformStream = new Transform({ objectMode: true });
|
|
40
40
|
transformStream._transform = function (file, encoding, callback) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (file.contents) {
|
|
45
|
-
const code = styleHandler(file.contents.toString(), {
|
|
46
|
-
isMainChunk: true
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
runtimeSet = twPatcher.getClassSet({
|
|
43
|
+
basedir: tailwindcssBasedir
|
|
47
44
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
setMangleRuntimeSet(runtimeSet);
|
|
46
|
+
const error = null;
|
|
47
|
+
if (file.contents) {
|
|
48
|
+
const code = yield styleHandler(file.contents.toString(), {
|
|
49
|
+
isMainChunk: true
|
|
50
|
+
});
|
|
51
|
+
file.contents = Buffer.from(code);
|
|
52
|
+
}
|
|
53
|
+
callback(error, file);
|
|
54
|
+
});
|
|
51
55
|
};
|
|
52
56
|
return transformStream;
|
|
53
57
|
}
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,7 @@ 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('
|
|
9
|
-
require('node:fs');
|
|
10
|
-
require('./options-b96f6338.js');
|
|
8
|
+
require('./options-09ebba08.js');
|
|
11
9
|
require('micromatch');
|
|
12
10
|
require('magic-string');
|
|
13
11
|
require('./replace.js');
|
|
@@ -25,6 +23,8 @@ require('postcss');
|
|
|
25
23
|
require('./postcss-8d7f67b4.js');
|
|
26
24
|
require('postcss-selector-parser');
|
|
27
25
|
require('@csstools/postcss-is-pseudo-class');
|
|
26
|
+
require('node:path');
|
|
27
|
+
require('node:fs');
|
|
28
28
|
require('semver');
|
|
29
29
|
require('tailwindcss-patch');
|
|
30
30
|
require('@tailwindcss-mangle/shared');
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export { UnifiedWebpackPluginV5 } from './webpack.mjs';
|
|
2
2
|
export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
|
-
import '
|
|
5
|
-
import 'node:fs';
|
|
6
|
-
import './options-f70d1c6f.mjs';
|
|
4
|
+
import './options-63407615.mjs';
|
|
7
5
|
import 'micromatch';
|
|
8
6
|
import 'magic-string';
|
|
9
7
|
import './replace.mjs';
|
|
@@ -21,6 +19,8 @@ import 'postcss';
|
|
|
21
19
|
import './postcss-55ed4d42.mjs';
|
|
22
20
|
import 'postcss-selector-parser';
|
|
23
21
|
import '@csstools/postcss-is-pseudo-class';
|
|
22
|
+
import 'node:path';
|
|
23
|
+
import 'node:fs';
|
|
24
24
|
import 'semver';
|
|
25
25
|
import 'tailwindcss-patch';
|
|
26
26
|
import '@tailwindcss-mangle/shared';
|
|
@@ -53,6 +53,38 @@ var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
|
53
53
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
54
54
|
var md5__default = /*#__PURE__*/_interopDefaultCompat(md5);
|
|
55
55
|
|
|
56
|
+
/******************************************************************************
|
|
57
|
+
Copyright (c) Microsoft Corporation.
|
|
58
|
+
|
|
59
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
60
|
+
purpose with or without fee is hereby granted.
|
|
61
|
+
|
|
62
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
63
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
64
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
65
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
66
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
67
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
68
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
69
|
+
***************************************************************************** */
|
|
70
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
74
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
75
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
76
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
77
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
78
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
79
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
84
|
+
var e = new Error(message);
|
|
85
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
86
|
+
};
|
|
87
|
+
|
|
56
88
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
57
89
|
function isValidSelector(selector = '') {
|
|
58
90
|
return validateFilterRE.test(selector);
|
|
@@ -326,6 +358,10 @@ function createJsHandler(options) {
|
|
|
326
358
|
};
|
|
327
359
|
}
|
|
328
360
|
|
|
361
|
+
function getQuotes(quote) {
|
|
362
|
+
const quotes = quote === "'" ? 'double' : 'single';
|
|
363
|
+
return quotes;
|
|
364
|
+
}
|
|
329
365
|
function generateCode(match, options = {}) {
|
|
330
366
|
const ast = parser.parseExpression(match);
|
|
331
367
|
traverse__default["default"](ast, {
|
|
@@ -345,7 +381,7 @@ function generateCode(match, options = {}) {
|
|
|
345
381
|
compact: true,
|
|
346
382
|
minified: true,
|
|
347
383
|
jsescOption: {
|
|
348
|
-
quotes:
|
|
384
|
+
quotes: getQuotes(options.quote),
|
|
349
385
|
minimal: true
|
|
350
386
|
}
|
|
351
387
|
});
|
|
@@ -443,12 +479,8 @@ function customTemplateHandler(rawSource, options) {
|
|
|
443
479
|
},
|
|
444
480
|
onattribute(name, value, quote) {
|
|
445
481
|
if (value) {
|
|
446
|
-
if (quote === "'") {
|
|
447
|
-
s.update(parser.startIndex + name.length + 1, parser.startIndex + name.length + 2, '"');
|
|
448
|
-
s.update(parser.startIndex + name.length + value.length + 2, parser.startIndex + name.length + value.length + 3, '"');
|
|
449
|
-
}
|
|
450
482
|
function update() {
|
|
451
|
-
s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, options));
|
|
483
|
+
s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, Object.assign(Object.assign({}, options), { quote })));
|
|
452
484
|
}
|
|
453
485
|
if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class' || name === 'virtualhostclass')) {
|
|
454
486
|
update();
|
|
@@ -491,7 +523,11 @@ function createTemplateHandler(options = {}) {
|
|
|
491
523
|
}
|
|
492
524
|
|
|
493
525
|
function styleHandler(rawSource, options) {
|
|
494
|
-
return
|
|
526
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
527
|
+
return (yield postcss__default["default"]([postcssIsPseudoClass__default["default"](), postcss$1.postcssWeappTailwindcss(options)])
|
|
528
|
+
.process(rawSource)
|
|
529
|
+
.async()).css;
|
|
530
|
+
});
|
|
495
531
|
}
|
|
496
532
|
function createStyleHandler(options) {
|
|
497
533
|
return (rawSource, opt) => {
|
|
@@ -748,17 +784,19 @@ function createCache() {
|
|
|
748
784
|
return instance.has(key);
|
|
749
785
|
},
|
|
750
786
|
process(key, callback, fallback) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
787
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
788
|
+
const hit = this.getHashValue(key);
|
|
789
|
+
if (hit && !hit.changed) {
|
|
790
|
+
const returnFlag = yield callback();
|
|
791
|
+
if (returnFlag !== false) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
756
794
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
795
|
+
const res = yield fallback();
|
|
796
|
+
if (res) {
|
|
797
|
+
this.set(res.key, res.source);
|
|
798
|
+
}
|
|
799
|
+
});
|
|
762
800
|
}
|
|
763
801
|
};
|
|
764
802
|
}
|
|
@@ -837,6 +875,7 @@ function getOptions(options = {}) {
|
|
|
837
875
|
return result;
|
|
838
876
|
}
|
|
839
877
|
|
|
878
|
+
exports.__awaiter = __awaiter;
|
|
840
879
|
exports.createPatch = createPatch;
|
|
841
880
|
exports.createTailwindcssPatcher = createTailwindcssPatcher;
|
|
842
881
|
exports.getOptions = getOptions;
|
|
@@ -21,6 +21,38 @@ import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/sh
|
|
|
21
21
|
import { LRUCache } from 'lru-cache';
|
|
22
22
|
import md5 from 'md5';
|
|
23
23
|
|
|
24
|
+
/******************************************************************************
|
|
25
|
+
Copyright (c) Microsoft Corporation.
|
|
26
|
+
|
|
27
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
28
|
+
purpose with or without fee is hereby granted.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
31
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
32
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
33
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
34
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
35
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
36
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
37
|
+
***************************************************************************** */
|
|
38
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
42
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
47
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
52
|
+
var e = new Error(message);
|
|
53
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
54
|
+
};
|
|
55
|
+
|
|
24
56
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
25
57
|
function isValidSelector(selector = '') {
|
|
26
58
|
return validateFilterRE.test(selector);
|
|
@@ -294,6 +326,10 @@ function createJsHandler(options) {
|
|
|
294
326
|
};
|
|
295
327
|
}
|
|
296
328
|
|
|
329
|
+
function getQuotes(quote) {
|
|
330
|
+
const quotes = quote === "'" ? 'double' : 'single';
|
|
331
|
+
return quotes;
|
|
332
|
+
}
|
|
297
333
|
function generateCode(match, options = {}) {
|
|
298
334
|
const ast = parseExpression(match);
|
|
299
335
|
traverse(ast, {
|
|
@@ -313,7 +349,7 @@ function generateCode(match, options = {}) {
|
|
|
313
349
|
compact: true,
|
|
314
350
|
minified: true,
|
|
315
351
|
jsescOption: {
|
|
316
|
-
quotes:
|
|
352
|
+
quotes: getQuotes(options.quote),
|
|
317
353
|
minimal: true
|
|
318
354
|
}
|
|
319
355
|
});
|
|
@@ -411,12 +447,8 @@ function customTemplateHandler(rawSource, options) {
|
|
|
411
447
|
},
|
|
412
448
|
onattribute(name, value, quote) {
|
|
413
449
|
if (value) {
|
|
414
|
-
if (quote === "'") {
|
|
415
|
-
s.update(parser.startIndex + name.length + 1, parser.startIndex + name.length + 2, '"');
|
|
416
|
-
s.update(parser.startIndex + name.length + value.length + 2, parser.startIndex + name.length + value.length + 3, '"');
|
|
417
|
-
}
|
|
418
450
|
function update() {
|
|
419
|
-
s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, options));
|
|
451
|
+
s.update(parser.startIndex + name.length + 2, parser.endIndex, templateReplacer(value, Object.assign(Object.assign({}, options), { quote })));
|
|
420
452
|
}
|
|
421
453
|
if (!disabledDefaultTemplateHandler && (name === 'class' || name === 'hover-class' || name === 'virtualhostclass')) {
|
|
422
454
|
update();
|
|
@@ -459,7 +491,11 @@ function createTemplateHandler(options = {}) {
|
|
|
459
491
|
}
|
|
460
492
|
|
|
461
493
|
function styleHandler(rawSource, options) {
|
|
462
|
-
return
|
|
494
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
495
|
+
return (yield postcss([postcssIsPseudoClass(), postcssWeappTailwindcss(options)])
|
|
496
|
+
.process(rawSource)
|
|
497
|
+
.async()).css;
|
|
498
|
+
});
|
|
463
499
|
}
|
|
464
500
|
function createStyleHandler(options) {
|
|
465
501
|
return (rawSource, opt) => {
|
|
@@ -716,17 +752,19 @@ function createCache() {
|
|
|
716
752
|
return instance.has(key);
|
|
717
753
|
},
|
|
718
754
|
process(key, callback, fallback) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
755
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
756
|
+
const hit = this.getHashValue(key);
|
|
757
|
+
if (hit && !hit.changed) {
|
|
758
|
+
const returnFlag = yield callback();
|
|
759
|
+
if (returnFlag !== false) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
724
762
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
763
|
+
const res = yield fallback();
|
|
764
|
+
if (res) {
|
|
765
|
+
this.set(res.key, res.source);
|
|
766
|
+
}
|
|
767
|
+
});
|
|
730
768
|
}
|
|
731
769
|
};
|
|
732
770
|
}
|
|
@@ -805,4 +843,4 @@ function getOptions(options = {}) {
|
|
|
805
843
|
return result;
|
|
806
844
|
}
|
|
807
845
|
|
|
808
|
-
export { createTailwindcssPatcher as a, createPatch as c, getOptions as g };
|
|
846
|
+
export { __awaiter as _, createTailwindcssPatcher as a, createPatch as c, getOptions as g };
|
package/dist/postcss/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IStyleHandlerOptions } from "../types";
|
|
2
|
-
export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): string
|
|
3
|
-
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => string
|
|
2
|
+
export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): Promise<string>;
|
|
3
|
+
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<string>;
|
package/dist/types.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ export interface UserDefinedOptions {
|
|
|
106
106
|
root?: string | false;
|
|
107
107
|
universal?: string | false;
|
|
108
108
|
};
|
|
109
|
+
tailwindcssBasedir?: string;
|
|
109
110
|
}
|
|
110
111
|
export type JsHandler = (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
|
|
111
112
|
export interface IMangleScopeContext {
|
|
@@ -129,6 +130,7 @@ export interface ITemplateHandlerOptions extends ICommonReplaceOptions {
|
|
|
129
130
|
jsHandler?: JsHandler;
|
|
130
131
|
runtimeSet?: Set<string>;
|
|
131
132
|
disabledDefaultTemplateHandler?: boolean;
|
|
133
|
+
quote?: string | null;
|
|
132
134
|
}
|
|
133
135
|
export type GlobOrFunctionMatchers = 'htmlMatcher' | 'cssMatcher' | 'jsMatcher' | 'mainCssChunkMatcher' | 'wxsMatcher';
|
|
134
136
|
export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobOrFunctionMatchers | 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary'> & {
|
|
@@ -136,7 +138,7 @@ export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobO
|
|
|
136
138
|
} & {
|
|
137
139
|
supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | false;
|
|
138
140
|
templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => string;
|
|
139
|
-
styleHandler: (rawSource: string, options: IStyleHandlerOptions) => string
|
|
141
|
+
styleHandler: (rawSource: string, options: IStyleHandlerOptions) => Promise<string>;
|
|
140
142
|
jsHandler: JsHandler;
|
|
141
143
|
escapeMap: Record<string, string>;
|
|
142
144
|
patch: () => void;
|