@weapp-tailwindcss/postcss 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compat/web-css.d.ts +7 -0
- package/dist/generator-plugin/types.d.ts +3 -1
- package/dist/html-transform.js +193 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2205 -896
- package/dist/index.mjs +2158 -852
- package/dist/rolldown-runtime-emK7D4bc.js +35 -0
- package/dist/types.d.ts +14 -0
- package/package.json +3 -3
- package/dist/html-transform-CMF3g0Cc.js +0 -232
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WebCssCompatFeatures, WebCssCompatUserOptions } from '../types';
|
|
2
|
+
export interface NormalizedWebCssCompatOptions {
|
|
3
|
+
preset: 'off' | 'legacy-web';
|
|
4
|
+
features: Required<WebCssCompatFeatures>;
|
|
5
|
+
}
|
|
6
|
+
export declare function normalizeWebCssCompatOptions(options: WebCssCompatUserOptions | undefined): NormalizedWebCssCompatOptions;
|
|
7
|
+
export declare function transformWebCssCompat(css: string, options: WebCssCompatUserOptions | undefined): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IStyleHandlerOptions } from '../types';
|
|
1
|
+
import type { IStyleHandlerOptions, WebCssCompatUserOptions } from '../types';
|
|
2
2
|
export type WeappTailwindcssPostcssTarget = 'weapp' | 'web' | 'tailwind';
|
|
3
3
|
export interface TailwindCandidateSource {
|
|
4
4
|
content: string;
|
|
@@ -32,6 +32,7 @@ export interface WeappTailwindcssPostcssGeneratorUserOptions {
|
|
|
32
32
|
target?: WeappTailwindcssPostcssTarget | undefined;
|
|
33
33
|
config?: string | undefined;
|
|
34
34
|
styleOptions?: Partial<IStyleHandlerOptions> | undefined;
|
|
35
|
+
webCompat?: WebCssCompatUserOptions | undefined;
|
|
35
36
|
importFallback?: boolean | undefined;
|
|
36
37
|
bareArbitraryValues?: unknown;
|
|
37
38
|
}
|
|
@@ -39,6 +40,7 @@ export interface NormalizedWeappTailwindcssPostcssGeneratorOptions {
|
|
|
39
40
|
target: WeappTailwindcssPostcssTarget;
|
|
40
41
|
config?: string | undefined;
|
|
41
42
|
styleOptions?: Partial<IStyleHandlerOptions> | undefined;
|
|
43
|
+
webCompat: WebCssCompatUserOptions | undefined;
|
|
42
44
|
importFallback: boolean;
|
|
43
45
|
bareArbitraryValues?: unknown;
|
|
44
46
|
}
|
package/dist/html-transform.js
CHANGED
|
@@ -1,2 +1,193 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
|
+
let node_process = require("node:process");
|
|
3
|
+
node_process = require_rolldown_runtime.__toESM(node_process);
|
|
4
|
+
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
5
|
+
//#region src/html-transform.ts
|
|
6
|
+
const htmlTags = [
|
|
7
|
+
"html",
|
|
8
|
+
"body",
|
|
9
|
+
"a",
|
|
10
|
+
"audio",
|
|
11
|
+
"button",
|
|
12
|
+
"canvas",
|
|
13
|
+
"form",
|
|
14
|
+
"iframe",
|
|
15
|
+
"img",
|
|
16
|
+
"input",
|
|
17
|
+
"label",
|
|
18
|
+
"progress",
|
|
19
|
+
"select",
|
|
20
|
+
"slot",
|
|
21
|
+
"textarea",
|
|
22
|
+
"video",
|
|
23
|
+
"abbr",
|
|
24
|
+
"area",
|
|
25
|
+
"b",
|
|
26
|
+
"bdi",
|
|
27
|
+
"big",
|
|
28
|
+
"br",
|
|
29
|
+
"cite",
|
|
30
|
+
"code",
|
|
31
|
+
"data",
|
|
32
|
+
"datalist",
|
|
33
|
+
"del",
|
|
34
|
+
"dfn",
|
|
35
|
+
"em",
|
|
36
|
+
"i",
|
|
37
|
+
"ins",
|
|
38
|
+
"kbd",
|
|
39
|
+
"map",
|
|
40
|
+
"mark",
|
|
41
|
+
"meter",
|
|
42
|
+
"output",
|
|
43
|
+
"picture",
|
|
44
|
+
"q",
|
|
45
|
+
"s",
|
|
46
|
+
"samp",
|
|
47
|
+
"small",
|
|
48
|
+
"span",
|
|
49
|
+
"strong",
|
|
50
|
+
"sub",
|
|
51
|
+
"sup",
|
|
52
|
+
"td",
|
|
53
|
+
"template",
|
|
54
|
+
"th",
|
|
55
|
+
"time",
|
|
56
|
+
"tt",
|
|
57
|
+
"u",
|
|
58
|
+
"var",
|
|
59
|
+
"wbr",
|
|
60
|
+
"address",
|
|
61
|
+
"article",
|
|
62
|
+
"aside",
|
|
63
|
+
"blockquote",
|
|
64
|
+
"caption",
|
|
65
|
+
"dd",
|
|
66
|
+
"details",
|
|
67
|
+
"dialog",
|
|
68
|
+
"div",
|
|
69
|
+
"dl",
|
|
70
|
+
"dt",
|
|
71
|
+
"fieldset",
|
|
72
|
+
"figcaption",
|
|
73
|
+
"figure",
|
|
74
|
+
"footer",
|
|
75
|
+
"h1",
|
|
76
|
+
"h2",
|
|
77
|
+
"h3",
|
|
78
|
+
"h4",
|
|
79
|
+
"h5",
|
|
80
|
+
"h6",
|
|
81
|
+
"header",
|
|
82
|
+
"hgroup",
|
|
83
|
+
"hr",
|
|
84
|
+
"legend",
|
|
85
|
+
"li",
|
|
86
|
+
"main",
|
|
87
|
+
"nav",
|
|
88
|
+
"ol",
|
|
89
|
+
"p",
|
|
90
|
+
"pre",
|
|
91
|
+
"section",
|
|
92
|
+
"summary",
|
|
93
|
+
"table",
|
|
94
|
+
"tbody",
|
|
95
|
+
"tfoot",
|
|
96
|
+
"thead",
|
|
97
|
+
"tr",
|
|
98
|
+
"ul",
|
|
99
|
+
"svg"
|
|
100
|
+
];
|
|
101
|
+
const miniAppTags = [
|
|
102
|
+
"cover-image",
|
|
103
|
+
"cover-view",
|
|
104
|
+
"match-media",
|
|
105
|
+
"movable-area",
|
|
106
|
+
"movable-view",
|
|
107
|
+
"page-container",
|
|
108
|
+
"scroll-view",
|
|
109
|
+
"share-element",
|
|
110
|
+
"swiper",
|
|
111
|
+
"swiper-item",
|
|
112
|
+
"view",
|
|
113
|
+
"icon",
|
|
114
|
+
"progress",
|
|
115
|
+
"rich-text",
|
|
116
|
+
"text",
|
|
117
|
+
"button",
|
|
118
|
+
"checkbox",
|
|
119
|
+
"checkbox-group",
|
|
120
|
+
"editor",
|
|
121
|
+
"form",
|
|
122
|
+
"input",
|
|
123
|
+
"keyboard-accessory",
|
|
124
|
+
"label",
|
|
125
|
+
"picker",
|
|
126
|
+
"picker-view",
|
|
127
|
+
"picker-view-column",
|
|
128
|
+
"radio",
|
|
129
|
+
"radio-group",
|
|
130
|
+
"slider",
|
|
131
|
+
"switch",
|
|
132
|
+
"textarea",
|
|
133
|
+
"functional-page-navigator",
|
|
134
|
+
"navigator",
|
|
135
|
+
"audio",
|
|
136
|
+
"camera",
|
|
137
|
+
"image",
|
|
138
|
+
"live-player",
|
|
139
|
+
"live-pusher",
|
|
140
|
+
"video",
|
|
141
|
+
"voip-room",
|
|
142
|
+
"map",
|
|
143
|
+
"canvas",
|
|
144
|
+
"web-view",
|
|
145
|
+
"ad",
|
|
146
|
+
"ad-custom",
|
|
147
|
+
"official-account",
|
|
148
|
+
"open-data",
|
|
149
|
+
"navigation-bar",
|
|
150
|
+
"page-meta"
|
|
151
|
+
];
|
|
152
|
+
const tags2Rgx = (tags = []) => new RegExp(`(^| |\\+|,|~|>|\\n)(${tags.join("|")})\\b(?=$| |\\.|\\+|,|~|:|\\[)`, "g");
|
|
153
|
+
const UNIVERSAL_SELECTOR_RE = /(?:^| )\*(?![=/*])/;
|
|
154
|
+
const postcssHtmlTransform = (opts = {}) => {
|
|
155
|
+
const options = (0, _weapp_tailwindcss_shared.defu)(opts, { platform: node_process.default.env.TARO_ENV });
|
|
156
|
+
let selectorFilter;
|
|
157
|
+
let walkRules;
|
|
158
|
+
switch (options.platform) {
|
|
159
|
+
case "h5":
|
|
160
|
+
selectorFilter = tags2Rgx(miniAppTags);
|
|
161
|
+
walkRules = (rule) => {
|
|
162
|
+
rule.selector = rule.selector.replace(selectorFilter, "$1taro-$2-core");
|
|
163
|
+
};
|
|
164
|
+
break;
|
|
165
|
+
case "rn": break;
|
|
166
|
+
case "quickapp": break;
|
|
167
|
+
default: {
|
|
168
|
+
const selector = tags2Rgx(htmlTags);
|
|
169
|
+
walkRules = (rule) => {
|
|
170
|
+
if (options.removeUniversal && UNIVERSAL_SELECTOR_RE.test(rule.selector)) {
|
|
171
|
+
rule.remove();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
rule.selector = rule.selector.replace(selector, "$1.h5-$2");
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
postcssPlugin: "postcss-html-transform",
|
|
180
|
+
Rule(rule) {
|
|
181
|
+
if (typeof walkRules === "function") if (selectorFilter && selectorFilter.test(rule.selector)) walkRules(rule);
|
|
182
|
+
else walkRules(rule);
|
|
183
|
+
},
|
|
184
|
+
Declaration(decl) {
|
|
185
|
+
if (options?.removeCursorStyle) {
|
|
186
|
+
if (decl.prop === "cursor") decl.remove();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
postcssHtmlTransform.postcss = true;
|
|
192
|
+
//#endregion
|
|
193
|
+
module.exports = postcssHtmlTransform;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { type DynamicColorMixAlphaProtection, type DynamicColorMixAlphaProtectio
|
|
|
2
2
|
export { finalizeMiniProgramCss, hasMiniProgramCssSpecificityPlaceholders, hoistTailwindPreflightBase, pruneMiniProgramGeneratedCss, removeUnsupportedAtSupports, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules, stripMiniProgramCssSpecificityPlaceholders, } from './compat/mini-program-css';
|
|
3
3
|
export { normalizeMiniProgramPrefixedDeclaration, removeUnsupportedMiniProgramPrefixedAtRule, } from './compat/mini-program-prefixes';
|
|
4
4
|
export { convertTailwindcssRpxDeclarationsToRem, convertTailwindcssRpxDeclarationToRem, convertTailwindcssRpxValueToRem, normalizeTailwindcssRpxDeclaration, normalizeTailwindcssRpxDeclarations, normalizeTailwindcssWebRpxDeclarations, type TailwindcssRpxToRemOptions, } from './compat/tailwindcss-rpx';
|
|
5
|
+
export { type NormalizedWebCssCompatOptions, normalizeWebCssCompatOptions, transformWebCssCompat, } from './compat/web-css';
|
|
5
6
|
export { compileCssMacroConditionalComments, CSS_MACRO_STYLE_OPTIONS_MARKER, hasCssMacroStyleOptions, hasCssMacroTailwindV4Directive, transformCssMacroCss, withCssMacroStyleOptions, } from './css-macro/auto';
|
|
6
7
|
export { CSS_MACRO_POSTCSS_PLUGIN_NAME, default as cssMacroPostcssPlugin } from './css-macro/postcss';
|
|
7
8
|
export { createWeappTailwindcssPostcssPlugin } from './generator-plugin';
|