@weapp-tailwindcss/postcss 3.0.5 → 3.0.8

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.
Files changed (33) hide show
  1. package/dist/compat/mini-program-css/finalize-options.d.ts +4 -0
  2. package/dist/compat/mini-program-css/predicates.d.ts +1 -0
  3. package/dist/compat/mini-program-css/selectors.d.ts +3 -0
  4. package/dist/compat/tailwindcss-v4.d.ts +2 -0
  5. package/dist/css-macro/auto.d.ts +7 -0
  6. package/dist/css-macro/constants.d.ts +17 -0
  7. package/dist/css-macro/postcss.d.ts +6 -0
  8. package/dist/css-macro/postcss.js +7 -0
  9. package/dist/css-macro/postcss.mjs +2 -0
  10. package/dist/generator-plugin/config-directive.d.ts +1 -0
  11. package/dist/generator-plugin/context.d.ts +8 -0
  12. package/dist/generator-plugin/directives.d.ts +5 -0
  13. package/dist/generator-plugin/index.d.ts +4 -0
  14. package/dist/generator-plugin/package-version.d.ts +3 -0
  15. package/dist/generator-plugin/source-files.d.ts +7 -0
  16. package/dist/generator-plugin/tailwind-version.d.ts +3 -0
  17. package/dist/generator-plugin/types.d.ts +101 -0
  18. package/dist/html-transform.js +1 -1
  19. package/dist/html-transform.mjs +1 -1
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.js +2680 -704
  22. package/dist/index.mjs +2657 -708
  23. package/dist/options-resolver.d.ts +1 -0
  24. package/dist/postcss-BebUgs5n.mjs +158 -0
  25. package/dist/postcss-by-0mwIg.js +169 -0
  26. package/dist/postcss-config.d.ts +8 -0
  27. package/dist/postcss-runtime.d.ts +2 -0
  28. package/dist/source-scan/inline-source.d.ts +7 -0
  29. package/dist/source-scan.d.ts +31 -0
  30. package/dist/types.d.ts +113 -9
  31. package/dist/vite-css-rules.d.ts +17 -0
  32. package/package.json +17 -5
  33. package/dist/{html-transform-Dgak7hXa.js → html-transform-CMF3g0Cc.js} +1 -1
@@ -1,4 +1,5 @@
1
1
  import type { IStyleHandlerOptions } from './types';
2
+ export declare function normalizeCssOptions<T extends Partial<IStyleHandlerOptions>>(options: T, mirrorTopLevel?: boolean): T;
2
3
  export interface OptionsResolver {
3
4
  resolve: (overrides?: Partial<IStyleHandlerOptions>) => IStyleHandlerOptions;
4
5
  }
@@ -0,0 +1,158 @@
1
+ //#region src/css-macro/constants.ts
2
+ const queryKey = "weapp-tw-platform";
3
+ const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
4
+ const WHITESPACE_RE = /\s+/g;
5
+ const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
6
+ function normalComment(text) {
7
+ if (typeof text === "string") {
8
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
9
+ if (normalized.includes("\\")) return normalized;
10
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
11
+ }
12
+ return text;
13
+ }
14
+ function ifdef(text) {
15
+ return {
16
+ start: `#ifdef ${normalComment(text)}`,
17
+ end: `#endif`
18
+ };
19
+ }
20
+ function ifndef(text) {
21
+ return {
22
+ start: `#ifndef ${normalComment(text)}`,
23
+ end: `#endif`
24
+ };
25
+ }
26
+ const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
27
+ function matchCustomPropertyFromValue(str, cb) {
28
+ let index = 0;
29
+ QUERY_KEY_REGEX.lastIndex = 0;
30
+ let arr = QUERY_KEY_REGEX.exec(str);
31
+ while (arr !== null) {
32
+ cb(arr, index);
33
+ index++;
34
+ arr = QUERY_KEY_REGEX.exec(str);
35
+ }
36
+ }
37
+ function parseConditionalAtRuleParam(params) {
38
+ const value = params.trim();
39
+ const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
40
+ if (!quoted) return value;
41
+ return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
42
+ }
43
+ //#endregion
44
+ //#region src/css-macro/postcss.ts
45
+ const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
46
+ const CONDITIONAL_COMMENT_SPACING = " ";
47
+ const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
48
+ const creator = () => {
49
+ return {
50
+ postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
51
+ prepare() {
52
+ function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
53
+ const hasPreviousNode = Boolean(atRule.prev());
54
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
55
+ const startComment = helper.comment({
56
+ raws: {
57
+ left: CONDITIONAL_COMMENT_SPACING,
58
+ right: CONDITIONAL_COMMENT_SPACING
59
+ },
60
+ text: comment.start
61
+ });
62
+ const endComment = helper.comment({
63
+ raws: {
64
+ left: CONDITIONAL_COMMENT_SPACING,
65
+ right: CONDITIONAL_COMMENT_SPACING
66
+ },
67
+ text: comment.end
68
+ });
69
+ const nextNodes = [
70
+ startComment,
71
+ ...clonedNodes,
72
+ endComment
73
+ ];
74
+ atRule.replaceWith(nextNodes);
75
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
76
+ startComment.raws["after"] = "\n";
77
+ if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
78
+ endComment.raws.before = "\n";
79
+ endComment.raws["after"] = "\n";
80
+ const nextNode = endComment?.next();
81
+ if (nextNode) nextNode.raws.before = "\n";
82
+ }
83
+ function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
84
+ if (atRule.parent?.type !== "rule") return false;
85
+ const parentRule = atRule.parent;
86
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
87
+ const conditionalRule = parentRule.clone();
88
+ conditionalRule.removeAll();
89
+ conditionalRule.append(...clonedNodes);
90
+ const startComment = helper.comment({
91
+ raws: {
92
+ left: CONDITIONAL_COMMENT_SPACING,
93
+ right: CONDITIONAL_COMMENT_SPACING
94
+ },
95
+ text: comment.start
96
+ });
97
+ const endComment = helper.comment({
98
+ raws: {
99
+ left: CONDITIONAL_COMMENT_SPACING,
100
+ right: CONDITIONAL_COMMENT_SPACING
101
+ },
102
+ text: comment.end
103
+ });
104
+ const nextNodes = [
105
+ startComment,
106
+ conditionalRule,
107
+ endComment
108
+ ];
109
+ const hasPreviousNode = Boolean(parentRule.prev());
110
+ atRule.remove();
111
+ if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
112
+ else parentRule.after(nextNodes);
113
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
114
+ startComment.raws["after"] = "\n";
115
+ conditionalRule.raws.before = "\n";
116
+ endComment.raws.before = "\n";
117
+ endComment.raws["after"] = "\n";
118
+ const nextNode = endComment.next();
119
+ if (nextNode) nextNode.raws.before = "\n";
120
+ return true;
121
+ }
122
+ return {
123
+ AtRule(atRule, helper) {
124
+ if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
125
+ const text = parseConditionalAtRuleParam(atRule.params);
126
+ const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
127
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
128
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
129
+ return;
130
+ }
131
+ if (atRule.name === "media") {
132
+ const values = [];
133
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
134
+ const value = arr[1];
135
+ if (value) values.push(value);
136
+ });
137
+ if (values.length > 0) {
138
+ const isNegative = atRule.params.includes("not");
139
+ const text = values.join(" ");
140
+ const comment = isNegative ? ifndef(text) : ifdef(text);
141
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
142
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
143
+ }
144
+ }
145
+ },
146
+ CommentExit(comment) {
147
+ if (IFDEF_ENDIF_RE.test(comment.text)) {
148
+ comment.raws.left = CONDITIONAL_COMMENT_SPACING;
149
+ comment.raws.right = CONDITIONAL_COMMENT_SPACING;
150
+ }
151
+ }
152
+ };
153
+ }
154
+ };
155
+ };
156
+ creator.postcss = true;
157
+ //#endregion
158
+ export { creator as n, CSS_MACRO_POSTCSS_PLUGIN_NAME as t };
@@ -0,0 +1,169 @@
1
+ //#region src/css-macro/constants.ts
2
+ const queryKey = "weapp-tw-platform";
3
+ const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
4
+ const WHITESPACE_RE = /\s+/g;
5
+ const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
6
+ function normalComment(text) {
7
+ if (typeof text === "string") {
8
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
9
+ if (normalized.includes("\\")) return normalized;
10
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
11
+ }
12
+ return text;
13
+ }
14
+ function ifdef(text) {
15
+ return {
16
+ start: `#ifdef ${normalComment(text)}`,
17
+ end: `#endif`
18
+ };
19
+ }
20
+ function ifndef(text) {
21
+ return {
22
+ start: `#ifndef ${normalComment(text)}`,
23
+ end: `#endif`
24
+ };
25
+ }
26
+ const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
27
+ function matchCustomPropertyFromValue(str, cb) {
28
+ let index = 0;
29
+ QUERY_KEY_REGEX.lastIndex = 0;
30
+ let arr = QUERY_KEY_REGEX.exec(str);
31
+ while (arr !== null) {
32
+ cb(arr, index);
33
+ index++;
34
+ arr = QUERY_KEY_REGEX.exec(str);
35
+ }
36
+ }
37
+ function parseConditionalAtRuleParam(params) {
38
+ const value = params.trim();
39
+ const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
40
+ if (!quoted) return value;
41
+ return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
42
+ }
43
+ //#endregion
44
+ //#region src/css-macro/postcss.ts
45
+ const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
46
+ const CONDITIONAL_COMMENT_SPACING = " ";
47
+ const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
48
+ const creator = () => {
49
+ return {
50
+ postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
51
+ prepare() {
52
+ function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
53
+ const hasPreviousNode = Boolean(atRule.prev());
54
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
55
+ const startComment = helper.comment({
56
+ raws: {
57
+ left: CONDITIONAL_COMMENT_SPACING,
58
+ right: CONDITIONAL_COMMENT_SPACING
59
+ },
60
+ text: comment.start
61
+ });
62
+ const endComment = helper.comment({
63
+ raws: {
64
+ left: CONDITIONAL_COMMENT_SPACING,
65
+ right: CONDITIONAL_COMMENT_SPACING
66
+ },
67
+ text: comment.end
68
+ });
69
+ const nextNodes = [
70
+ startComment,
71
+ ...clonedNodes,
72
+ endComment
73
+ ];
74
+ atRule.replaceWith(nextNodes);
75
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
76
+ startComment.raws["after"] = "\n";
77
+ if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
78
+ endComment.raws.before = "\n";
79
+ endComment.raws["after"] = "\n";
80
+ const nextNode = endComment?.next();
81
+ if (nextNode) nextNode.raws.before = "\n";
82
+ }
83
+ function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
84
+ if (atRule.parent?.type !== "rule") return false;
85
+ const parentRule = atRule.parent;
86
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
87
+ const conditionalRule = parentRule.clone();
88
+ conditionalRule.removeAll();
89
+ conditionalRule.append(...clonedNodes);
90
+ const startComment = helper.comment({
91
+ raws: {
92
+ left: CONDITIONAL_COMMENT_SPACING,
93
+ right: CONDITIONAL_COMMENT_SPACING
94
+ },
95
+ text: comment.start
96
+ });
97
+ const endComment = helper.comment({
98
+ raws: {
99
+ left: CONDITIONAL_COMMENT_SPACING,
100
+ right: CONDITIONAL_COMMENT_SPACING
101
+ },
102
+ text: comment.end
103
+ });
104
+ const nextNodes = [
105
+ startComment,
106
+ conditionalRule,
107
+ endComment
108
+ ];
109
+ const hasPreviousNode = Boolean(parentRule.prev());
110
+ atRule.remove();
111
+ if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
112
+ else parentRule.after(nextNodes);
113
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
114
+ startComment.raws["after"] = "\n";
115
+ conditionalRule.raws.before = "\n";
116
+ endComment.raws.before = "\n";
117
+ endComment.raws["after"] = "\n";
118
+ const nextNode = endComment.next();
119
+ if (nextNode) nextNode.raws.before = "\n";
120
+ return true;
121
+ }
122
+ return {
123
+ AtRule(atRule, helper) {
124
+ if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
125
+ const text = parseConditionalAtRuleParam(atRule.params);
126
+ const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
127
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
128
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
129
+ return;
130
+ }
131
+ if (atRule.name === "media") {
132
+ const values = [];
133
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
134
+ const value = arr[1];
135
+ if (value) values.push(value);
136
+ });
137
+ if (values.length > 0) {
138
+ const isNegative = atRule.params.includes("not");
139
+ const text = values.join(" ");
140
+ const comment = isNegative ? ifndef(text) : ifdef(text);
141
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
142
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
143
+ }
144
+ }
145
+ },
146
+ CommentExit(comment) {
147
+ if (IFDEF_ENDIF_RE.test(comment.text)) {
148
+ comment.raws.left = CONDITIONAL_COMMENT_SPACING;
149
+ comment.raws.right = CONDITIONAL_COMMENT_SPACING;
150
+ }
151
+ }
152
+ };
153
+ }
154
+ };
155
+ };
156
+ creator.postcss = true;
157
+ //#endregion
158
+ Object.defineProperty(exports, "CSS_MACRO_POSTCSS_PLUGIN_NAME", {
159
+ enumerable: true,
160
+ get: function() {
161
+ return CSS_MACRO_POSTCSS_PLUGIN_NAME;
162
+ }
163
+ });
164
+ Object.defineProperty(exports, "creator", {
165
+ enumerable: true,
166
+ get: function() {
167
+ return creator;
168
+ }
169
+ });
@@ -0,0 +1,8 @@
1
+ import postcssrc from 'postcss-load-config';
2
+ export declare function getPostcssPluginName(plugin: unknown): string | undefined;
3
+ export declare function removeTailwindPostcssPlugins(plugins: unknown[]): number;
4
+ export declare function resolveFilteredPostcssConfig(root: string): Promise<{
5
+ options: import("postcss").ProcessOptions<import("postcss").Document | import("postcss").Root>;
6
+ plugins: postcssrc.ResultPlugin[];
7
+ removed: number;
8
+ } | undefined>;
@@ -0,0 +1,2 @@
1
+ export type { AcceptedPlugin, AtRule, Container, Declaration, Document, Helpers, Node, Plugin, PluginCreator, ProcessOptions, Processor, Result, Root, Rule, } from 'postcss';
2
+ export { default as postcss } from 'postcss';
@@ -0,0 +1,7 @@
1
+ import type { Root } from 'postcss';
2
+ export interface TailwindInlineSourceCandidates {
3
+ included: Set<string>;
4
+ excluded: Set<string>;
5
+ }
6
+ export declare function expandInlineSourceCandidatePattern(pattern: string): string[];
7
+ export declare function collectCssInlineSourceCandidates(root: Root): TailwindInlineSourceCandidates;
@@ -0,0 +1,31 @@
1
+ import type { Root } from 'postcss';
2
+ export interface TailwindSourceEntry {
3
+ base: string;
4
+ pattern: string;
5
+ negated: boolean;
6
+ }
7
+ export type { TailwindInlineSourceCandidates } from './source-scan/inline-source';
8
+ export { collectCssInlineSourceCandidates, expandInlineSourceCandidatePattern } from './source-scan/inline-source';
9
+ export declare const DEFAULT_SOURCE_SCAN_EXTENSIONS: string[];
10
+ export declare const FULL_SOURCE_SCAN_EXTENSIONS: string[];
11
+ export declare function createSourceScanPattern(extensions?: string[]): string;
12
+ export declare const FULL_SOURCE_SCAN_PATTERN: string;
13
+ export declare const FULL_SOURCE_SCAN_EXTENSION_RE: RegExp;
14
+ export declare function toPosixPath(value: string): string;
15
+ export declare function resolveSourceScanPath(value: string): string;
16
+ export declare function isFileExcludedByTailwindSourceEntries(file: string, entries: TailwindSourceEntry[] | undefined): boolean;
17
+ export declare function isFileMatchedByTailwindSourceEntries(file: string, entries: TailwindSourceEntry[] | undefined): boolean;
18
+ export declare function createTailwindSourceEntryMatcher(entries: TailwindSourceEntry[] | undefined): ((file: string) => boolean) | undefined;
19
+ export declare function parseConfigParam(params: string): string | undefined;
20
+ export declare function normalizeLegacyContentEntries(content: unknown, base: string, options?: {
21
+ relativeBase?: string | undefined;
22
+ }): TailwindSourceEntry[];
23
+ export declare function resolveTailwindSourceEntry(sourcePath: string, base: string, negated: boolean, defaultPattern?: string): Promise<TailwindSourceEntry>;
24
+ export declare function parseSourceFileParam(params: string): {
25
+ negated: boolean;
26
+ sourcePath: string;
27
+ } | undefined;
28
+ export declare function resolveCssSourceEntries(root: Root, base: string, defaultPattern?: string): Promise<TailwindSourceEntry[]>;
29
+ export declare function expandTailwindSourceEntries(entries: TailwindSourceEntry[], options?: {
30
+ ignore?: string[];
31
+ }): Promise<string[]>;
package/dist/types.d.ts CHANGED
@@ -53,43 +53,147 @@ export interface PlatformUnitConversionOptions {
53
53
  platforms: UnitConversionPlatformMap;
54
54
  }
55
55
  export type UnitConversionOptions = UnitConversionConfig | PlatformUnitConversionOptions | false;
56
+ export interface CssSelectorReplacement {
57
+ root?: string | string[] | false | undefined;
58
+ universal?: string | string[] | false | undefined;
59
+ }
60
+ export interface CssAtRules {
61
+ property?: boolean | undefined;
62
+ supports?: boolean | undefined;
63
+ media?: boolean | undefined;
64
+ }
65
+ export interface CssOptions {
66
+ cssPreflight?: CssPreflightOptions | undefined;
67
+ cssPreflightRange?: 'all' | undefined;
68
+ cssChildCombinatorReplaceValue?: string | string[] | undefined;
69
+ cssPresetEnv?: PresetEnvOptions | undefined;
70
+ autoprefixer?: WeappAutoprefixerOptions | undefined;
71
+ atRules?: CssAtRules | undefined;
72
+ injectAdditionalCssVarScope?: boolean | undefined;
73
+ cssSelectorReplacement?: CssSelectorReplacement | undefined;
74
+ rem2rpx?: boolean | Rem2rpxOptions | undefined;
75
+ px2rpx?: boolean | Px2rpxOptions | undefined;
76
+ unitsToPx?: boolean | UnitsToPxOptions | undefined;
77
+ unitConversion?: UnitConversionOptions | undefined;
78
+ platform?: string | undefined;
79
+ cssRemoveHoverPseudoClass?: boolean | undefined;
80
+ cssRemoveProperty?: boolean | undefined;
81
+ cssCalc?: boolean | CssCalcOptions | (string | RegExp)[] | undefined;
82
+ /**
83
+ * 是否显式追加 Tailwind CSS v4 渐变字面量组合兜底。
84
+ */
85
+ tailwindcssV4GradientFallback?: boolean | undefined;
86
+ }
56
87
  export type IStyleHandlerOptions = {
57
88
  ctx?: PostcssContext | undefined;
89
+ /**
90
+ * @deprecated 请使用 `cssOptions.platform`。
91
+ */
58
92
  platform?: string | undefined;
59
93
  postcssOptions?: LoadedPostcssOptions | undefined;
94
+ cssOptions?: CssOptions | undefined;
95
+ /**
96
+ * @deprecated 请使用 `cssOptions.cssRemoveProperty`。
97
+ */
60
98
  cssRemoveProperty?: boolean | undefined;
99
+ /**
100
+ * @deprecated 请使用 `cssOptions.cssRemoveHoverPseudoClass`。
101
+ */
61
102
  cssRemoveHoverPseudoClass?: boolean | undefined;
103
+ /**
104
+ * @deprecated 请使用 `cssOptions.tailwindcssV4GradientFallback`。
105
+ */
106
+ tailwindcssV4GradientFallback?: boolean | undefined;
107
+ /**
108
+ * @deprecated 请使用 `cssOptions.cssPresetEnv`。
109
+ */
62
110
  cssPresetEnv?: PresetEnvOptions | undefined;
111
+ /**
112
+ * @deprecated 请使用 `cssOptions.atRules`。
113
+ */
114
+ atRules?: CssAtRules | undefined;
115
+ /**
116
+ * @deprecated 请使用 `cssOptions.autoprefixer`。
117
+ */
63
118
  autoprefixer?: WeappAutoprefixerOptions | undefined;
119
+ /**
120
+ * @deprecated 请使用 `cssOptions.cssCalc`。
121
+ */
64
122
  cssCalc?: boolean | CssCalcOptions | (string | RegExp)[] | undefined;
65
- atRules?: {
66
- property?: boolean | undefined;
67
- supports?: boolean | undefined;
68
- media?: boolean | undefined;
69
- } | undefined;
70
123
  uniAppX?: boolean | undefined;
71
124
  uniAppXCssTarget?: UniAppXCssTarget | undefined;
72
125
  uniAppXUnsupported?: UniAppXUnsupportedMode | undefined;
73
126
  majorVersion?: number | undefined;
74
127
  } & RequiredStyleHandlerOptions;
75
128
  export interface UserDefinedPostcssOptions {
129
+ /**
130
+ * @deprecated 请使用 `cssOptions.cssPreflight`。
131
+ */
76
132
  cssPreflight?: CssPreflightOptions | undefined;
133
+ /**
134
+ * @deprecated 请使用 `cssOptions.cssPreflightRange`。
135
+ */
77
136
  cssPreflightRange?: 'all' | undefined;
137
+ /**
138
+ * @deprecated 请使用 `cssOptions.cssChildCombinatorReplaceValue`。
139
+ */
78
140
  cssChildCombinatorReplaceValue?: string | string[] | undefined;
141
+ /**
142
+ * @deprecated 请使用 `cssOptions.cssPresetEnv`。
143
+ */
79
144
  cssPresetEnv?: PresetEnvOptions | undefined;
145
+ /**
146
+ * @deprecated 请使用 `cssOptions.autoprefixer`。
147
+ */
80
148
  autoprefixer?: WeappAutoprefixerOptions | undefined;
149
+ /**
150
+ * @deprecated 请使用 `cssOptions.injectAdditionalCssVarScope`。
151
+ */
81
152
  injectAdditionalCssVarScope?: boolean | undefined;
82
- cssSelectorReplacement?: {
83
- root?: string | string[] | false | undefined;
84
- universal?: string | string[] | false | undefined;
85
- } | undefined;
153
+ /**
154
+ * @deprecated 请使用 `cssOptions.cssSelectorReplacement`。
155
+ */
156
+ cssSelectorReplacement?: CssSelectorReplacement | undefined;
157
+ /**
158
+ * @deprecated 请使用 `cssOptions.rem2rpx`。
159
+ */
86
160
  rem2rpx?: boolean | Rem2rpxOptions | undefined;
161
+ /**
162
+ * @deprecated 请使用 `cssOptions.px2rpx`。
163
+ */
87
164
  px2rpx?: boolean | Px2rpxOptions | undefined;
165
+ /**
166
+ * @deprecated 请使用 `cssOptions.unitsToPx`。
167
+ */
88
168
  unitsToPx?: boolean | UnitsToPxOptions | undefined;
169
+ /**
170
+ * @deprecated 请使用 `cssOptions.unitConversion`。
171
+ */
89
172
  unitConversion?: UnitConversionOptions | undefined;
90
173
  postcssOptions?: LoadedPostcssOptions | undefined;
174
+ /**
175
+ * @deprecated 请使用 `cssOptions.cssRemoveHoverPseudoClass`。
176
+ */
91
177
  cssRemoveHoverPseudoClass?: boolean | undefined;
178
+ /**
179
+ * @deprecated 请使用 `cssOptions.cssRemoveProperty`。
180
+ */
92
181
  cssRemoveProperty?: boolean | undefined;
182
+ /**
183
+ * CSS 生成与兼容后处理的微调配置。
184
+ *
185
+ * `cssPreflight`、`cssPreflightRange`、`cssChildCombinatorReplaceValue`、`cssPresetEnv`、`autoprefixer`、
186
+ * `atRules`、`injectAdditionalCssVarScope`、`cssSelectorReplacement`、`rem2rpx`、`px2rpx`、`unitsToPx`、
187
+ * `unitConversion`、`platform`、`cssRemoveHoverPseudoClass`、`cssRemoveProperty`、`cssCalc`
188
+ * 与 `tailwindcssV4GradientFallback` 都推荐放在这里。
189
+ */
190
+ cssOptions?: CssOptions | undefined;
191
+ /**
192
+ * 是否显式追加 Tailwind CSS v4 渐变字面量组合兜底。
193
+ *
194
+ * @deprecated 请使用 `cssOptions.tailwindcssV4GradientFallback`。
195
+ */
196
+ tailwindcssV4GradientFallback?: boolean | undefined;
93
197
  uniAppX?: boolean | undefined;
94
198
  uniAppXCssTarget?: UniAppXCssTarget | undefined;
95
199
  uniAppXUnsupported?: UniAppXUnsupportedMode | undefined;
@@ -0,0 +1,17 @@
1
+ export declare function mergeMiniProgramPreflightRuleDeclarations(baseCss: string, css: string): {
2
+ baseCss: string;
3
+ css: string;
4
+ changed: boolean;
5
+ };
6
+ export declare function mergeMiniProgramThemeScopeRuleDeclarations(baseCss: string, css: string): {
7
+ baseCss: string;
8
+ css: string;
9
+ changed: boolean;
10
+ };
11
+ export declare function mergeCoveredCssRuleDeclarations(baseCss: string, css: string): {
12
+ baseCss: string;
13
+ css: string;
14
+ changed: boolean;
15
+ };
16
+ export declare function filterExistingCssRules(baseCss: string, css: string): string;
17
+ export declare function containsCssAfterMinify(baseCss: string, css: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "3.0.5",
3
+ "version": "3.0.8",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -30,6 +30,11 @@
30
30
  "import": "./dist/html-transform.mjs",
31
31
  "require": "./dist/html-transform.js"
32
32
  },
33
+ "./css-macro/postcss": {
34
+ "types": "./dist/css-macro/postcss.d.ts",
35
+ "import": "./dist/css-macro/postcss.mjs",
36
+ "require": "./dist/css-macro/postcss.js"
37
+ },
33
38
  "./package.json": "./package.json"
34
39
  },
35
40
  "main": "./dist/index.js",
@@ -40,6 +45,9 @@
40
45
  "html-transform": [
41
46
  "./dist/html-transform.d.ts"
42
47
  ],
48
+ "css-macro/postcss": [
49
+ "./dist/css-macro/postcss.d.ts"
50
+ ],
43
51
  "types": [
44
52
  "./dist/types.d.ts"
45
53
  ],
@@ -59,24 +67,28 @@
59
67
  "@weapp-core/escape": "~8.0.0",
60
68
  "autoprefixer": "^10.5.0",
61
69
  "lru-cache": "11.5.1",
70
+ "micromatch": "^4.0.8",
62
71
  "postcss": "^8.5.15",
72
+ "postcss-load-config": "^6.0.1",
63
73
  "postcss-pxtrans": "^1.0.4",
64
74
  "postcss-rem-to-responsive-pixel": "^7.0.4",
65
75
  "postcss-rule-unit-converter": "^0.2.2",
66
- "postcss-selector-parser": "~7.1.2",
76
+ "postcss-selector-parser": "~7.1.4",
67
77
  "postcss-value-parser": "^4.2.0",
78
+ "tailwindcss-patch": "9.4.4",
68
79
  "@weapp-tailwindcss/postcss-calc": "^1.0.2",
69
- "@weapp-tailwindcss/shared": "2.0.0"
80
+ "@weapp-tailwindcss/shared": "2.0.0",
81
+ "tailwindcss-config": "2.0.0"
70
82
  },
71
83
  "devDependencies": {
72
- "@csstools/css-color-parser": "^4.1.1",
84
+ "@csstools/css-color-parser": "^4.1.7",
73
85
  "@csstools/css-parser-algorithms": "^4.0.0",
74
86
  "@csstools/css-tokenizer": "^4.0.0",
75
87
  "@csstools/postcss-is-pseudo-class": "^6.0.0",
76
88
  "fast-check": "^4.8.0",
77
89
  "postcss-calc": "link:packages/postcss-calc",
78
90
  "postcss-custom-properties": "^15.0.1",
79
- "postcss-preset-env": "^11.3.0"
91
+ "postcss-preset-env": "^11.3.1"
80
92
  },
81
93
  "scripts": {
82
94
  "dev": "tsdown --watch --sourcemap",
@@ -21,9 +21,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
- let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
25
24
  let node_process = require("node:process");
26
25
  node_process = __toESM(node_process);
26
+ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
27
27
  //#region src/html-transform.ts
28
28
  const htmlTags = [
29
29
  "html",