@weapp-tailwindcss/postcss 2.2.0 → 2.2.1-next.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/README.md +4 -5
- package/dist/autoprefixer.d.ts +7 -0
- package/dist/compat/color-mix.d.ts +5 -0
- package/dist/compat/tailwindcss-rpx.d.ts +4 -0
- package/dist/compat/tailwindcss-v4.d.ts +12 -0
- package/dist/compat/uni-app-x-uvue.d.ts +3 -0
- package/dist/compat/uni-app-x.d.ts +9 -0
- package/dist/constants.d.ts +1 -0
- package/dist/content-probe.d.ts +38 -0
- package/dist/cssVarsV3.d.ts +5 -0
- package/dist/cssVarsV4.d.ts +5 -0
- package/dist/defaults.d.ts +2 -0
- package/dist/fingerprint.d.ts +6 -0
- package/dist/handler.d.ts +2 -0
- package/dist/html-transform-DuSRw6IH.js +225 -0
- package/dist/html-transform.d.ts +3 -7
- package/dist/html-transform.js +2 -8
- package/dist/html-transform.mjs +190 -5
- package/dist/index.d.ts +8 -18
- package/dist/index.js +2296 -2727
- package/dist/index.mjs +2274 -2721
- package/dist/mp.d.ts +26 -0
- package/dist/options-resolver.d.ts +5 -0
- package/dist/pipeline.d.ts +44 -0
- package/dist/plugins/colorFunctionalFallback.d.ts +5 -0
- package/dist/plugins/ctx.d.ts +6 -0
- package/dist/plugins/getCalcDuplicateCleaner.d.ts +3 -0
- package/dist/plugins/getCalcPlugin.d.ts +3 -0
- package/dist/plugins/getCustomPropertyCleaner.d.ts +3 -0
- package/dist/plugins/getPxTransformPlugin.d.ts +3 -0
- package/dist/plugins/getRemTransformPlugin.d.ts +3 -0
- package/dist/plugins/getUnitsToPxPlugin.d.ts +3 -0
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins/post/decl-dedupe.d.ts +3 -0
- package/dist/plugins/post/specificity-cleaner.d.ts +5 -0
- package/dist/plugins/post.d.ts +6 -0
- package/dist/plugins/pre.d.ts +5 -0
- package/dist/preflight.d.ts +3 -0
- package/dist/preset-env-options.d.ts +14 -0
- package/dist/processor-cache.d.ts +18 -0
- package/dist/selectorParser/before-after.d.ts +2 -0
- package/dist/selectorParser/fallback.d.ts +9 -0
- package/dist/selectorParser/rule-transformer.d.ts +4 -0
- package/dist/selectorParser/spacing.d.ts +6 -0
- package/dist/selectorParser/utils.d.ts +11 -0
- package/dist/selectorParser.d.ts +4 -0
- package/dist/shared.d.ts +3 -0
- package/dist/types.d.ts +86 -8
- package/dist/types.js +0 -1
- package/dist/types.mjs +1 -1
- package/dist/utils/css-vars.d.ts +9 -0
- package/dist/utils/decl-order.d.ts +5 -0
- package/dist/utils/selector-guard.d.ts +8 -0
- package/dist/utils/tw-vars.d.ts +5 -0
- package/package.json +5 -4
- package/dist/chunk-2DNJBRQ3.mjs +0 -64
- package/dist/chunk-2Y3ULRB3.js +0 -64
- package/dist/chunk-GGNOJ77I.js +0 -1
- package/dist/chunk-WAXGOBY2.mjs +0 -0
- package/dist/html-transform.d.mts +0 -13
- package/dist/index.d.mts +0 -18
- package/dist/types-DiOShlJF.d.mts +0 -172
- package/dist/types-DiOShlJF.d.ts +0 -172
- package/dist/types.d.mts +0 -8
package/README.md
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|

|
|
17
17
|

|
|
18
|
-

|
|
19
18
|

|
|
20
19
|
[](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
|
|
21
20
|
[](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
|
|
@@ -55,12 +54,12 @@
|
|
|
55
54
|
|
|
56
55
|
## 版本对应
|
|
57
56
|
|
|
58
|
-
目前,`weapp-tailwindcss` 的 `
|
|
57
|
+
目前,`weapp-tailwindcss` 的 `5.x` 版本
|
|
59
58
|
|
|
60
|
-
- 支持最新版本的 `tailwindcss v4` 和 `v3
|
|
61
|
-
- 支持 `webpack5
|
|
59
|
+
- 支持最新版本的 `tailwindcss v4` 和 `v3`。
|
|
60
|
+
- 支持 `webpack5`、`vite`、`rspack`、`rollup`、`rolldown` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
|
|
62
61
|
|
|
63
|
-
>
|
|
62
|
+
> `weapp-tailwindcss@5` 面向 Tailwind CSS v3/v4 和现代构建链路,不再内置 Webpack4、PostCSS7、Tailwind CSS v2 兼容入口。`weapp-tailwindcss@5` 需要 `nodejs` 版本 `^20.19.0 || >=22.12.0`,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
|
|
64
63
|
|
|
65
64
|
## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
|
|
66
65
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type autoprefixer from 'autoprefixer';
|
|
2
|
+
import type { AcceptedPlugin } from 'postcss';
|
|
3
|
+
export type AutoprefixerOptions = autoprefixer.Options;
|
|
4
|
+
export type WeappAutoprefixerOptions = boolean | AutoprefixerOptions;
|
|
5
|
+
export declare const WEAPP_AUTOPREFIXER_BROWSERS: string[];
|
|
6
|
+
export declare function isAutoprefixerPlugin(plugin: AcceptedPlugin): boolean;
|
|
7
|
+
export declare function resolveAutoprefixerPlugin(option: WeappAutoprefixerOptions | undefined): AcceptedPlugin | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AtRule, Declaration, Rule } from 'postcss';
|
|
2
|
+
export declare function isTailwindcssV4(options?: {
|
|
3
|
+
majorVersion?: number;
|
|
4
|
+
}): boolean;
|
|
5
|
+
export declare function testIfRootHostForV4(node: Rule): boolean;
|
|
6
|
+
export declare const cssVarsV4Nodes: Declaration[];
|
|
7
|
+
export declare function isTailwindcssV4ModernCheck(atRule: AtRule): boolean;
|
|
8
|
+
export declare function isTailwindcssV4LinearGradientSupports(atRule: AtRule): boolean;
|
|
9
|
+
export declare function isTailwindcssV4DisplayP3Supports(atRule: AtRule): boolean;
|
|
10
|
+
export declare function isTailwindcssV4DisplayP3Media(atRule: AtRule): boolean;
|
|
11
|
+
export declare function isTailwindcssV4DisplayP3Declaration(decl: Declaration): boolean;
|
|
12
|
+
export declare function normalizeTailwindcssV4Declaration(decl: Declaration): boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Result as PostcssResult } from 'postcss';
|
|
2
|
+
import type { IStyleHandlerOptions } from '../types';
|
|
3
|
+
export declare function applyUniAppXUvueCompatibility(result: PostcssResult, options?: Pick<IStyleHandlerOptions, 'uniAppX' | 'uniAppXCssTarget' | 'uniAppXUnsupported'>): PostcssResult<import("postcss").Document | import("postcss").Root>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result as PostcssResult, Rule } from 'postcss';
|
|
2
|
+
import type { Node, Pseudo } from 'postcss-selector-parser';
|
|
3
|
+
import type { IStyleHandlerOptions } from '../types';
|
|
4
|
+
import postcss from 'postcss';
|
|
5
|
+
export declare function isUniAppXEnabled(options?: Pick<IStyleHandlerOptions, 'uniAppX'>): boolean;
|
|
6
|
+
export declare function applyUniAppXBaseCompatibility(result: PostcssResult, options?: Pick<IStyleHandlerOptions, 'uniAppX'>): PostcssResult<postcss.Document | postcss.Root>;
|
|
7
|
+
export declare function stripUnsupportedPseudoForUniAppX(node: Pseudo, enabled: boolean): void;
|
|
8
|
+
export declare function stripUnsupportedNodeForUniAppX(node: Node, options: Pick<IStyleHandlerOptions, 'uniAppX'>): boolean;
|
|
9
|
+
export declare function shouldRemoveEmptyRuleForUniAppX(rule: Rule, options: Pick<IStyleHandlerOptions, 'uniAppX'>): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS 内容特征探测模块
|
|
3
|
+
*
|
|
4
|
+
* 通过正则和字符串匹配快速判断 CSS 是否包含特定特征,
|
|
5
|
+
* 用于在构建流水线前决定哪些插件可以跳过。
|
|
6
|
+
* 仅使用字符串方法和正则表达式,不引入 AST 解析开销。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* CSS 内容特征信号,表示哪些特征存在于当前 CSS 中
|
|
10
|
+
*/
|
|
11
|
+
export interface FeatureSignal {
|
|
12
|
+
/** CSS 中是否包含现代颜色函数语法(如 rgb(r g b / a) 空格分隔写法) */
|
|
13
|
+
hasModernColorFunction: boolean;
|
|
14
|
+
/** CSS 中是否包含需要 postcss-preset-env 处理的特征 */
|
|
15
|
+
hasPresetEnvFeatures: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 所有标志均为 true 的默认信号(回退值)
|
|
19
|
+
*/
|
|
20
|
+
export declare const FULL_SIGNAL: FeatureSignal;
|
|
21
|
+
/**
|
|
22
|
+
* 所有标志均为 false 的空信号
|
|
23
|
+
*/
|
|
24
|
+
export declare const EMPTY_SIGNAL: FeatureSignal;
|
|
25
|
+
/**
|
|
26
|
+
* 探测 CSS 内容特征,返回 FeatureSignal
|
|
27
|
+
*
|
|
28
|
+
* @param css - 待探测的 CSS 字符串
|
|
29
|
+
* @returns 特征信号对象
|
|
30
|
+
*/
|
|
31
|
+
export declare function probeFeatures(css: string): FeatureSignal;
|
|
32
|
+
/**
|
|
33
|
+
* 将 FeatureSignal 序列化为缓存键片段
|
|
34
|
+
*
|
|
35
|
+
* @param signal - 特征信号对象
|
|
36
|
+
* @returns 缓存键字符串
|
|
37
|
+
*/
|
|
38
|
+
export declare function signalToCacheKey(signal: FeatureSignal): string;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
24
|
+
let node_process = require("node:process");
|
|
25
|
+
node_process = __toESM(node_process);
|
|
26
|
+
//#region src/html-transform.ts
|
|
27
|
+
const htmlTags = [
|
|
28
|
+
"html",
|
|
29
|
+
"body",
|
|
30
|
+
"a",
|
|
31
|
+
"audio",
|
|
32
|
+
"button",
|
|
33
|
+
"canvas",
|
|
34
|
+
"form",
|
|
35
|
+
"iframe",
|
|
36
|
+
"img",
|
|
37
|
+
"input",
|
|
38
|
+
"label",
|
|
39
|
+
"progress",
|
|
40
|
+
"select",
|
|
41
|
+
"slot",
|
|
42
|
+
"textarea",
|
|
43
|
+
"video",
|
|
44
|
+
"abbr",
|
|
45
|
+
"area",
|
|
46
|
+
"b",
|
|
47
|
+
"bdi",
|
|
48
|
+
"big",
|
|
49
|
+
"br",
|
|
50
|
+
"cite",
|
|
51
|
+
"code",
|
|
52
|
+
"data",
|
|
53
|
+
"datalist",
|
|
54
|
+
"del",
|
|
55
|
+
"dfn",
|
|
56
|
+
"em",
|
|
57
|
+
"i",
|
|
58
|
+
"ins",
|
|
59
|
+
"kbd",
|
|
60
|
+
"map",
|
|
61
|
+
"mark",
|
|
62
|
+
"meter",
|
|
63
|
+
"output",
|
|
64
|
+
"picture",
|
|
65
|
+
"q",
|
|
66
|
+
"s",
|
|
67
|
+
"samp",
|
|
68
|
+
"small",
|
|
69
|
+
"span",
|
|
70
|
+
"strong",
|
|
71
|
+
"sub",
|
|
72
|
+
"sup",
|
|
73
|
+
"td",
|
|
74
|
+
"template",
|
|
75
|
+
"th",
|
|
76
|
+
"time",
|
|
77
|
+
"tt",
|
|
78
|
+
"u",
|
|
79
|
+
"var",
|
|
80
|
+
"wbr",
|
|
81
|
+
"address",
|
|
82
|
+
"article",
|
|
83
|
+
"aside",
|
|
84
|
+
"blockquote",
|
|
85
|
+
"caption",
|
|
86
|
+
"dd",
|
|
87
|
+
"details",
|
|
88
|
+
"dialog",
|
|
89
|
+
"div",
|
|
90
|
+
"dl",
|
|
91
|
+
"dt",
|
|
92
|
+
"fieldset",
|
|
93
|
+
"figcaption",
|
|
94
|
+
"figure",
|
|
95
|
+
"footer",
|
|
96
|
+
"h1",
|
|
97
|
+
"h2",
|
|
98
|
+
"h3",
|
|
99
|
+
"h4",
|
|
100
|
+
"h5",
|
|
101
|
+
"h6",
|
|
102
|
+
"header",
|
|
103
|
+
"hgroup",
|
|
104
|
+
"hr",
|
|
105
|
+
"legend",
|
|
106
|
+
"li",
|
|
107
|
+
"main",
|
|
108
|
+
"nav",
|
|
109
|
+
"ol",
|
|
110
|
+
"p",
|
|
111
|
+
"pre",
|
|
112
|
+
"section",
|
|
113
|
+
"summary",
|
|
114
|
+
"table",
|
|
115
|
+
"tbody",
|
|
116
|
+
"tfoot",
|
|
117
|
+
"thead",
|
|
118
|
+
"tr",
|
|
119
|
+
"ul",
|
|
120
|
+
"svg"
|
|
121
|
+
];
|
|
122
|
+
const miniAppTags = [
|
|
123
|
+
"cover-image",
|
|
124
|
+
"cover-view",
|
|
125
|
+
"match-media",
|
|
126
|
+
"movable-area",
|
|
127
|
+
"movable-view",
|
|
128
|
+
"page-container",
|
|
129
|
+
"scroll-view",
|
|
130
|
+
"share-element",
|
|
131
|
+
"swiper",
|
|
132
|
+
"swiper-item",
|
|
133
|
+
"view",
|
|
134
|
+
"icon",
|
|
135
|
+
"progress",
|
|
136
|
+
"rich-text",
|
|
137
|
+
"text",
|
|
138
|
+
"button",
|
|
139
|
+
"checkbox",
|
|
140
|
+
"checkbox-group",
|
|
141
|
+
"editor",
|
|
142
|
+
"form",
|
|
143
|
+
"input",
|
|
144
|
+
"keyboard-accessory",
|
|
145
|
+
"label",
|
|
146
|
+
"picker",
|
|
147
|
+
"picker-view",
|
|
148
|
+
"picker-view-column",
|
|
149
|
+
"radio",
|
|
150
|
+
"radio-group",
|
|
151
|
+
"slider",
|
|
152
|
+
"switch",
|
|
153
|
+
"textarea",
|
|
154
|
+
"functional-page-navigator",
|
|
155
|
+
"navigator",
|
|
156
|
+
"audio",
|
|
157
|
+
"camera",
|
|
158
|
+
"image",
|
|
159
|
+
"live-player",
|
|
160
|
+
"live-pusher",
|
|
161
|
+
"video",
|
|
162
|
+
"voip-room",
|
|
163
|
+
"map",
|
|
164
|
+
"canvas",
|
|
165
|
+
"web-view",
|
|
166
|
+
"ad",
|
|
167
|
+
"ad-custom",
|
|
168
|
+
"official-account",
|
|
169
|
+
"open-data",
|
|
170
|
+
"navigation-bar",
|
|
171
|
+
"page-meta"
|
|
172
|
+
];
|
|
173
|
+
const tags2Rgx = (tags = []) => new RegExp(`(^| |\\+|,|~|>|\\n)(${tags.join("|")})\\b(?=$| |\\.|\\+|,|~|:|\\[)`, "g");
|
|
174
|
+
const UNIVERSAL_SELECTOR_RE = /(?:^| )\*(?![=/*])/;
|
|
175
|
+
const postcssHtmlTransform = (opts = {}) => {
|
|
176
|
+
const options = (0, _weapp_tailwindcss_shared.defu)(opts, { platform: node_process.default.env.TARO_ENV });
|
|
177
|
+
let selectorFilter;
|
|
178
|
+
let walkRules;
|
|
179
|
+
switch (options.platform) {
|
|
180
|
+
case "h5":
|
|
181
|
+
selectorFilter = tags2Rgx(miniAppTags);
|
|
182
|
+
walkRules = (rule) => {
|
|
183
|
+
rule.selector = rule.selector.replace(selectorFilter, "$1taro-$2-core");
|
|
184
|
+
};
|
|
185
|
+
break;
|
|
186
|
+
case "rn": break;
|
|
187
|
+
case "quickapp": break;
|
|
188
|
+
default: {
|
|
189
|
+
const selector = tags2Rgx(htmlTags);
|
|
190
|
+
walkRules = (rule) => {
|
|
191
|
+
if (options.removeUniversal && UNIVERSAL_SELECTOR_RE.test(rule.selector)) {
|
|
192
|
+
rule.remove();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
rule.selector = rule.selector.replace(selector, "$1.h5-$2");
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
postcssPlugin: "postcss-html-transform",
|
|
201
|
+
Rule(rule) {
|
|
202
|
+
if (typeof walkRules === "function") if (selectorFilter && selectorFilter.test(rule.selector)) walkRules(rule);
|
|
203
|
+
else walkRules(rule);
|
|
204
|
+
},
|
|
205
|
+
Declaration(decl) {
|
|
206
|
+
if (options?.removeCursorStyle) {
|
|
207
|
+
if (decl.prop === "cursor") decl.remove();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
postcssHtmlTransform.postcss = true;
|
|
213
|
+
//#endregion
|
|
214
|
+
Object.defineProperty(exports, "__toESM", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: function() {
|
|
217
|
+
return __toESM;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, "postcssHtmlTransform", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function() {
|
|
223
|
+
return postcssHtmlTransform;
|
|
224
|
+
}
|
|
225
|
+
});
|
package/dist/html-transform.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PluginCreator } from 'postcss';
|
|
2
|
-
|
|
3
|
-
interface IOptions {
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
export interface IOptions {
|
|
4
3
|
/** 当前编译平台 */
|
|
5
4
|
platform?: string;
|
|
6
5
|
/** 设置是否去除 cursor 相关样式 (h5默认值:true) */
|
|
@@ -9,7 +8,4 @@ interface IOptions {
|
|
|
9
8
|
removeUniversal?: boolean;
|
|
10
9
|
}
|
|
11
10
|
declare const postcssHtmlTransform: PluginCreator<IOptions>;
|
|
12
|
-
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
export = postcssHtmlTransform;
|
|
15
|
-
export type { IOptions };
|
|
11
|
+
export default postcssHtmlTransform;
|
package/dist/html-transform.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _chunk2Y3ULRB3js = require('./chunk-2Y3ULRB3.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.default = _chunk2Y3ULRB3js.html_transform_default;
|
|
7
|
-
|
|
8
|
-
module.exports = exports.default;
|
|
1
|
+
const require_html_transform = require("./html-transform-DuSRw6IH.js");
|
|
2
|
+
module.exports = require_html_transform.postcssHtmlTransform;
|
package/dist/html-transform.mjs
CHANGED
|
@@ -1,6 +1,191 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { defu } from "@weapp-tailwindcss/shared";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
//#region src/html-transform.ts
|
|
4
|
+
const htmlTags = [
|
|
5
|
+
"html",
|
|
6
|
+
"body",
|
|
7
|
+
"a",
|
|
8
|
+
"audio",
|
|
9
|
+
"button",
|
|
10
|
+
"canvas",
|
|
11
|
+
"form",
|
|
12
|
+
"iframe",
|
|
13
|
+
"img",
|
|
14
|
+
"input",
|
|
15
|
+
"label",
|
|
16
|
+
"progress",
|
|
17
|
+
"select",
|
|
18
|
+
"slot",
|
|
19
|
+
"textarea",
|
|
20
|
+
"video",
|
|
21
|
+
"abbr",
|
|
22
|
+
"area",
|
|
23
|
+
"b",
|
|
24
|
+
"bdi",
|
|
25
|
+
"big",
|
|
26
|
+
"br",
|
|
27
|
+
"cite",
|
|
28
|
+
"code",
|
|
29
|
+
"data",
|
|
30
|
+
"datalist",
|
|
31
|
+
"del",
|
|
32
|
+
"dfn",
|
|
33
|
+
"em",
|
|
34
|
+
"i",
|
|
35
|
+
"ins",
|
|
36
|
+
"kbd",
|
|
37
|
+
"map",
|
|
38
|
+
"mark",
|
|
39
|
+
"meter",
|
|
40
|
+
"output",
|
|
41
|
+
"picture",
|
|
42
|
+
"q",
|
|
43
|
+
"s",
|
|
44
|
+
"samp",
|
|
45
|
+
"small",
|
|
46
|
+
"span",
|
|
47
|
+
"strong",
|
|
48
|
+
"sub",
|
|
49
|
+
"sup",
|
|
50
|
+
"td",
|
|
51
|
+
"template",
|
|
52
|
+
"th",
|
|
53
|
+
"time",
|
|
54
|
+
"tt",
|
|
55
|
+
"u",
|
|
56
|
+
"var",
|
|
57
|
+
"wbr",
|
|
58
|
+
"address",
|
|
59
|
+
"article",
|
|
60
|
+
"aside",
|
|
61
|
+
"blockquote",
|
|
62
|
+
"caption",
|
|
63
|
+
"dd",
|
|
64
|
+
"details",
|
|
65
|
+
"dialog",
|
|
66
|
+
"div",
|
|
67
|
+
"dl",
|
|
68
|
+
"dt",
|
|
69
|
+
"fieldset",
|
|
70
|
+
"figcaption",
|
|
71
|
+
"figure",
|
|
72
|
+
"footer",
|
|
73
|
+
"h1",
|
|
74
|
+
"h2",
|
|
75
|
+
"h3",
|
|
76
|
+
"h4",
|
|
77
|
+
"h5",
|
|
78
|
+
"h6",
|
|
79
|
+
"header",
|
|
80
|
+
"hgroup",
|
|
81
|
+
"hr",
|
|
82
|
+
"legend",
|
|
83
|
+
"li",
|
|
84
|
+
"main",
|
|
85
|
+
"nav",
|
|
86
|
+
"ol",
|
|
87
|
+
"p",
|
|
88
|
+
"pre",
|
|
89
|
+
"section",
|
|
90
|
+
"summary",
|
|
91
|
+
"table",
|
|
92
|
+
"tbody",
|
|
93
|
+
"tfoot",
|
|
94
|
+
"thead",
|
|
95
|
+
"tr",
|
|
96
|
+
"ul",
|
|
97
|
+
"svg"
|
|
98
|
+
];
|
|
99
|
+
const miniAppTags = [
|
|
100
|
+
"cover-image",
|
|
101
|
+
"cover-view",
|
|
102
|
+
"match-media",
|
|
103
|
+
"movable-area",
|
|
104
|
+
"movable-view",
|
|
105
|
+
"page-container",
|
|
106
|
+
"scroll-view",
|
|
107
|
+
"share-element",
|
|
108
|
+
"swiper",
|
|
109
|
+
"swiper-item",
|
|
110
|
+
"view",
|
|
111
|
+
"icon",
|
|
112
|
+
"progress",
|
|
113
|
+
"rich-text",
|
|
114
|
+
"text",
|
|
115
|
+
"button",
|
|
116
|
+
"checkbox",
|
|
117
|
+
"checkbox-group",
|
|
118
|
+
"editor",
|
|
119
|
+
"form",
|
|
120
|
+
"input",
|
|
121
|
+
"keyboard-accessory",
|
|
122
|
+
"label",
|
|
123
|
+
"picker",
|
|
124
|
+
"picker-view",
|
|
125
|
+
"picker-view-column",
|
|
126
|
+
"radio",
|
|
127
|
+
"radio-group",
|
|
128
|
+
"slider",
|
|
129
|
+
"switch",
|
|
130
|
+
"textarea",
|
|
131
|
+
"functional-page-navigator",
|
|
132
|
+
"navigator",
|
|
133
|
+
"audio",
|
|
134
|
+
"camera",
|
|
135
|
+
"image",
|
|
136
|
+
"live-player",
|
|
137
|
+
"live-pusher",
|
|
138
|
+
"video",
|
|
139
|
+
"voip-room",
|
|
140
|
+
"map",
|
|
141
|
+
"canvas",
|
|
142
|
+
"web-view",
|
|
143
|
+
"ad",
|
|
144
|
+
"ad-custom",
|
|
145
|
+
"official-account",
|
|
146
|
+
"open-data",
|
|
147
|
+
"navigation-bar",
|
|
148
|
+
"page-meta"
|
|
149
|
+
];
|
|
150
|
+
const tags2Rgx = (tags = []) => new RegExp(`(^| |\\+|,|~|>|\\n)(${tags.join("|")})\\b(?=$| |\\.|\\+|,|~|:|\\[)`, "g");
|
|
151
|
+
const UNIVERSAL_SELECTOR_RE = /(?:^| )\*(?![=/*])/;
|
|
152
|
+
const postcssHtmlTransform = (opts = {}) => {
|
|
153
|
+
const options = defu(opts, { platform: process.env.TARO_ENV });
|
|
154
|
+
let selectorFilter;
|
|
155
|
+
let walkRules;
|
|
156
|
+
switch (options.platform) {
|
|
157
|
+
case "h5":
|
|
158
|
+
selectorFilter = tags2Rgx(miniAppTags);
|
|
159
|
+
walkRules = (rule) => {
|
|
160
|
+
rule.selector = rule.selector.replace(selectorFilter, "$1taro-$2-core");
|
|
161
|
+
};
|
|
162
|
+
break;
|
|
163
|
+
case "rn": break;
|
|
164
|
+
case "quickapp": break;
|
|
165
|
+
default: {
|
|
166
|
+
const selector = tags2Rgx(htmlTags);
|
|
167
|
+
walkRules = (rule) => {
|
|
168
|
+
if (options.removeUniversal && UNIVERSAL_SELECTOR_RE.test(rule.selector)) {
|
|
169
|
+
rule.remove();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
rule.selector = rule.selector.replace(selector, "$1.h5-$2");
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
postcssPlugin: "postcss-html-transform",
|
|
178
|
+
Rule(rule) {
|
|
179
|
+
if (typeof walkRules === "function") if (selectorFilter && selectorFilter.test(rule.selector)) walkRules(rule);
|
|
180
|
+
else walkRules(rule);
|
|
181
|
+
},
|
|
182
|
+
Declaration(decl) {
|
|
183
|
+
if (options?.removeCursorStyle) {
|
|
184
|
+
if (decl.prop === "cursor") decl.remove();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
6
188
|
};
|
|
189
|
+
postcssHtmlTransform.postcss = true;
|
|
190
|
+
//#endregion
|
|
191
|
+
export { postcssHtmlTransform as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import 'postcss-rule-unit-converter';
|
|
10
|
-
import 'autoprefixer';
|
|
11
|
-
|
|
12
|
-
declare function createStyleHandler(options?: Partial<IStyleHandlerOptions>): StyleHandler;
|
|
13
|
-
|
|
14
|
-
declare function createFallbackPlaceholderReplacer(): (code: string) => string;
|
|
15
|
-
|
|
16
|
-
declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
|
|
17
|
-
|
|
18
|
-
export { IStyleHandlerOptions, InternalCssSelectorReplacerOptions, StyleHandler, createFallbackPlaceholderReplacer, createStyleHandler, internalCssSelectorReplacer };
|
|
1
|
+
export { type DynamicColorMixAlphaProtection, protectDynamicColorMixAlpha } from './compat/color-mix';
|
|
2
|
+
export * from './handler';
|
|
3
|
+
export { default as postcssHtmlTransform, type IOptions as PostcssHtmlTransformOptions } from './html-transform';
|
|
4
|
+
export { createStylePipeline, type PipelineNodeContext, type PipelineNodeCursor, type PipelineStage, type ResolvedPipelineNode, type StyleProcessingPipeline, } from './pipeline';
|
|
5
|
+
export { createFallbackPlaceholderReplacer } from './plugins/post/specificity-cleaner';
|
|
6
|
+
export { createInjectPreflight } from './preflight';
|
|
7
|
+
export { internalCssSelectorReplacer } from './shared';
|
|
8
|
+
export * from './types';
|