weapp-tailwindcss 5.0.8 → 5.0.10
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/auto-CTp6wE5a.js +33 -0
- package/dist/auto-Cl8_hsG6.mjs +22 -0
- package/dist/{bundle-state-cHwTyrOS.js → bundle-state-BwtEqxvU.js} +3 -3
- package/dist/{bundle-state-5FtFktJr.mjs → bundle-state-CXzPknlT.mjs} +2 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +0 -2
- package/dist/cli.js +1 -159
- package/dist/cli.mjs +1 -159
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -7
- package/dist/css-macro/postcss.d.ts +1 -6
- package/dist/css-macro/postcss.js +15 -3
- package/dist/css-macro/postcss.mjs +2 -2
- package/dist/css-macro.js +19 -5
- package/dist/css-macro.mjs +16 -2
- package/dist/{generator-C--TrAod.js → generator-ChgOWNOj.js} +1 -1
- package/dist/{generator-DnwUQOXB.mjs → generator-h2XRiJ9-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B22YSGU_.mjs → gulp-Be88jhoY.mjs} +5 -5
- package/dist/{gulp-5Tan5bHG.js → gulp-CHtZF-oT.js} +6 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-CscCNKb9.js → hmr-timing-BkivBZvN.js} +41 -43
- package/dist/{hmr-timing-DK-mine6.mjs → hmr-timing-Ct5w4hdM.mjs} +6 -7
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/postcss.d.ts +2 -13
- package/dist/postcss.js +14 -3
- package/dist/postcss.mjs +10 -1
- package/dist/{precheck-CcxTR7E_.mjs → precheck-BpHxsWRd.mjs} +4 -4
- package/dist/{precheck-B8y6tDvG.js → precheck-CY9oaH49.js} +5 -5
- package/dist/presets.js +4 -4
- package/dist/presets.mjs +3 -3
- package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -1
- package/dist/{tailwindcss-0DaftXcU.mjs → tailwindcss-Bfy2egdX.mjs} +2 -2
- package/dist/{tailwindcss-DbZ4o4m_.js → tailwindcss-DbbAKAZP.js} +3 -3
- package/dist/{transform-DiW_u3eD.js → transform-Cd634UZV.js} +1 -1
- package/dist/{transform-DRyWUN5X.mjs → transform-r5evL6Hn.mjs} +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/{v3-engine-ArQVHEau.mjs → v3-engine-CFkP6dWF.mjs} +4 -5
- package/dist/{v3-engine-DdlvXpID.js → v3-engine-D0yA9ZkF.js} +35 -73
- package/dist/{vite-_iUhzc4t.mjs → vite-BM_iIFmS.mjs} +10 -411
- package/dist/{vite-C_IUnDBy.js → vite-Bh-BNp5g.js} +27 -431
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/watch-dependencies-bpG6kmAf.js +80 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +60 -393
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-KLoTb5Dr.js → webpack-CJAOcYEO.js} +8 -8
- package/dist/{webpack-CqnI4Ymw.mjs → webpack-DPdrcC2X.mjs} +7 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -4
- package/dist/auto-Cvy0zWpS.js +0 -238
- package/dist/auto-DEHRmEAx.mjs +0 -200
- package/dist/bundlers/vite/postcss-config.d.ts +0 -6
- package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +0 -17
- package/dist/postcss/config-directive.d.ts +0 -1
- package/dist/postcss/context.d.ts +0 -9
- package/dist/postcss/source-files.d.ts +0 -8
- package/dist/postcss/tailwind-version.d.ts +0 -3
- package/dist/postcss-C7BMYpEF.mjs +0 -169
- package/dist/postcss-CiYLsqZn.js +0 -192
- package/dist/postcss-CjWuDZwL.mjs +0 -275
- package/dist/postcss-R5pDVHUy.js +0 -284
- package/dist/watch-dependencies-zwx4EhBn.js +0 -5535
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_watch_dependencies = require("./watch-dependencies-
|
|
1
|
+
const require_watch_dependencies = require("./watch-dependencies-bpG6kmAf.js");
|
|
2
2
|
let node_buffer = require("node:buffer");
|
|
3
3
|
let node_process = require("node:process");
|
|
4
4
|
node_process = require_watch_dependencies.__toESM(node_process);
|
|
@@ -18,7 +18,7 @@ function shouldCleanRuntimeCss(css) {
|
|
|
18
18
|
return css.includes("@layer") || css.includes("@theme");
|
|
19
19
|
}
|
|
20
20
|
function cleanRuntimeCss(css) {
|
|
21
|
-
const root =
|
|
21
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
22
22
|
(0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
|
|
23
23
|
removeUnsupportedThemeKeyframes(root);
|
|
24
24
|
return root.toString();
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-D0yA9ZkF.js");
|
|
3
|
+
const require_generator = require("./generator-ChgOWNOj.js");
|
|
4
|
+
const require_precheck = require("./precheck-CY9oaH49.js");
|
|
5
5
|
const require_utils = require("./utils-Dolmt8EO.js");
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
8
|
-
const require_bundle_state = require("./bundle-state-
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-DbbAKAZP.js");
|
|
7
|
+
const require_hmr_timing = require("./hmr-timing-BkivBZvN.js");
|
|
8
|
+
const require_bundle_state = require("./bundle-state-BwtEqxvU.js");
|
|
9
9
|
let node_module = require("node:module");
|
|
10
10
|
node_module = require_chunk.__toESM(node_module);
|
|
11
|
-
let node_process = require("node:process");
|
|
12
|
-
node_process = require_chunk.__toESM(node_process);
|
|
13
11
|
let node_fs = require("node:fs");
|
|
14
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
15
13
|
let node_path = require("node:path");
|
|
16
14
|
node_path = require_chunk.__toESM(node_path);
|
|
15
|
+
let node_process = require("node:process");
|
|
16
|
+
node_process = require_chunk.__toESM(node_process);
|
|
17
17
|
let micromatch = require("micromatch");
|
|
18
18
|
micromatch = require_chunk.__toESM(micromatch);
|
|
19
19
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { M as removeTailwindSourceDirectives, l as getRuntimeClassSetSignature,
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-
|
|
3
|
-
import { b as refreshTailwindRuntimeState, d as _defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-
|
|
1
|
+
import { M as removeTailwindSourceDirectives, l as getRuntimeClassSetSignature, m as resolveViteSourceScanEntries, rt as createDebug, st as resolveTailwindcssOptions } from "./v3-engine-CFkP6dWF.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-h2XRiJ9-.mjs";
|
|
3
|
+
import { b as refreshTailwindRuntimeState, d as _defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-BpHxsWRd.mjs";
|
|
4
4
|
import { r as getGroupedEntries } from "./utils-DsaS975I.mjs";
|
|
5
|
-
import { c as hasConfiguredTailwindV4CssRoots, l as upsertTailwindV4CssSource } from "./tailwindcss-
|
|
6
|
-
import { _ as isCssSourceTraceEnabled, a as createTailwindV3DefaultExtractor, d as isPureLocalCssImportWrapper, f as finalizeMiniProgramCss, g as createCssTokenSourceMap, h as createCssSourceTraceCacheSignature, m as annotateCssSourceTrace, n as emitHmrTiming, o as createBundleRuntimeClassSetManager, p as pruneMiniProgramGeneratedCss, r as createSourceCandidateCollector, s as generateCssByGenerator, v as processCachedTask } from "./hmr-timing-
|
|
7
|
-
import { C as toAbsoluteOutputPath, S as resolveOutputSpecifier, b as stripRequestQuery, d as stripBundlerGeneratedCssMarkers, f as resolvePackageDir, l as hasBundlerGeneratedCssMarker, n as createBundleBuildState, p as resolvePluginDisabledState, r as updateBundleBuildState, s as pushConcurrentTaskFactories, t as buildBundleSnapshot, y as isSourceStyleRequest } from "./bundle-state-
|
|
5
|
+
import { c as hasConfiguredTailwindV4CssRoots, l as upsertTailwindV4CssSource } from "./tailwindcss-Bfy2egdX.mjs";
|
|
6
|
+
import { _ as isCssSourceTraceEnabled, a as createTailwindV3DefaultExtractor, d as isPureLocalCssImportWrapper, f as finalizeMiniProgramCss, g as createCssTokenSourceMap, h as createCssSourceTraceCacheSignature, m as annotateCssSourceTrace, n as emitHmrTiming, o as createBundleRuntimeClassSetManager, p as pruneMiniProgramGeneratedCss, r as createSourceCandidateCollector, s as generateCssByGenerator, v as processCachedTask } from "./hmr-timing-Ct5w4hdM.mjs";
|
|
7
|
+
import { C as toAbsoluteOutputPath, S as resolveOutputSpecifier, b as stripRequestQuery, d as stripBundlerGeneratedCssMarkers, f as resolvePackageDir, l as hasBundlerGeneratedCssMarker, n as createBundleBuildState, p as resolvePluginDisabledState, r as updateBundleBuildState, s as pushConcurrentTaskFactories, t as buildBundleSnapshot, y as isSourceStyleRequest } from "./bundle-state-CXzPknlT.mjs";
|
|
8
8
|
import Module, { createRequire } from "node:module";
|
|
9
|
-
import process from "node:process";
|
|
10
9
|
import fs from "node:fs";
|
|
11
10
|
import path from "node:path";
|
|
11
|
+
import process from "node:process";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import micromatch from "micromatch";
|
|
14
14
|
//#region src/shared/tailwindcss-css-redirect.ts
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_webpack = require("./webpack-
|
|
2
|
+
const require_webpack = require("./webpack-CJAOcYEO.js");
|
|
3
3
|
exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_webpack.WeappTailwindcss;
|
|
5
5
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-DPdrcC2X.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.10",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -181,13 +181,11 @@
|
|
|
181
181
|
"lru-cache": "11.5.1",
|
|
182
182
|
"magic-string": "0.30.21",
|
|
183
183
|
"micromatch": "^4.0.8",
|
|
184
|
-
"postcss-load-config": "^6.0.1",
|
|
185
|
-
"postcss-selector-parser": "^7.1.2",
|
|
186
184
|
"semver": "~7.8.4",
|
|
187
185
|
"tailwindcss-patch": "9.4.3",
|
|
188
186
|
"yaml": "^2.9.0",
|
|
187
|
+
"@weapp-tailwindcss/postcss": "3.0.7",
|
|
189
188
|
"@weapp-tailwindcss/logger": "2.0.0",
|
|
190
|
-
"@weapp-tailwindcss/postcss": "3.0.5",
|
|
191
189
|
"@weapp-tailwindcss/reset": "0.1.1",
|
|
192
190
|
"@weapp-tailwindcss/shared": "2.0.0",
|
|
193
191
|
"tailwindcss-config": "2.0.0"
|
package/dist/auto-Cvy0zWpS.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_postcss = require("./postcss-CiYLsqZn.js");
|
|
3
|
-
let postcss = require("postcss");
|
|
4
|
-
postcss = require_chunk.__toESM(postcss);
|
|
5
|
-
let node_process = require("node:process");
|
|
6
|
-
node_process = require_chunk.__toESM(node_process);
|
|
7
|
-
//#region src/css-macro/auto.ts
|
|
8
|
-
const CSS_MACRO_PLUGIN_MARKER = "__weappTailwindcssCssMacro";
|
|
9
|
-
const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
|
|
10
|
-
const PLATFORM_ENV_KEYS = [
|
|
11
|
-
"WEAPP_TW_TARGET",
|
|
12
|
-
"WEAPP_TAILWINDCSS_TARGET",
|
|
13
|
-
"UNI_PLATFORM",
|
|
14
|
-
"UNI_UTS_PLATFORM",
|
|
15
|
-
"TARO_ENV",
|
|
16
|
-
"MPX_CLI_MODE",
|
|
17
|
-
"MPX_CURRENT_TARGET_MODE"
|
|
18
|
-
];
|
|
19
|
-
const CONDITIONAL_END_RE = /^\s*#endif\s*$/;
|
|
20
|
-
function readEnvValue(key) {
|
|
21
|
-
return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
|
|
22
|
-
}
|
|
23
|
-
function normalizePlatformToken(value) {
|
|
24
|
-
return value?.trim().replaceAll("_", "-").toUpperCase() || void 0;
|
|
25
|
-
}
|
|
26
|
-
function resolveCssMacroPlatform(options) {
|
|
27
|
-
const explicit = normalizePlatformToken(options?.platform);
|
|
28
|
-
if (explicit) return explicit;
|
|
29
|
-
for (const key of PLATFORM_ENV_KEYS) {
|
|
30
|
-
const value = normalizePlatformToken(readEnvValue(key));
|
|
31
|
-
if (value) return value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function createPlatformTokenSet(platform) {
|
|
35
|
-
const normalized = normalizePlatformToken(platform);
|
|
36
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
37
|
-
if (!normalized) return tokens;
|
|
38
|
-
tokens.add(normalized);
|
|
39
|
-
if (normalized.startsWith("MP-")) tokens.add("MP");
|
|
40
|
-
if (normalized === "WEAPP" || normalized === "WEIXIN" || normalized === "WX") {
|
|
41
|
-
tokens.add("MP");
|
|
42
|
-
tokens.add("MP-WEIXIN");
|
|
43
|
-
}
|
|
44
|
-
if (normalized === "MP-WEIXIN") {
|
|
45
|
-
tokens.add("WEAPP");
|
|
46
|
-
tokens.add("WEIXIN");
|
|
47
|
-
tokens.add("WX");
|
|
48
|
-
}
|
|
49
|
-
if (normalized === "H5") tokens.add("WEB");
|
|
50
|
-
if (normalized === "WEB") tokens.add("H5");
|
|
51
|
-
if (normalized === "APP") tokens.add("APP-PLUS");
|
|
52
|
-
if (normalized.startsWith("APP-")) tokens.add("APP");
|
|
53
|
-
if (normalized.startsWith("QUICKAPP-WEBVIEW")) tokens.add("QUICKAPP-WEBVIEW");
|
|
54
|
-
return tokens;
|
|
55
|
-
}
|
|
56
|
-
function combineAnd(values) {
|
|
57
|
-
if (values.includes(false)) return false;
|
|
58
|
-
return values.every((value) => value === true) ? true : void 0;
|
|
59
|
-
}
|
|
60
|
-
function combineOr(values) {
|
|
61
|
-
if (values.includes(true)) return true;
|
|
62
|
-
return values.every((value) => value === false) ? false : void 0;
|
|
63
|
-
}
|
|
64
|
-
function evaluatePlatformExpression(expression, platformTokens) {
|
|
65
|
-
return combineOr(expression.split(/\s*\|\|\s*/).map((orPart) => {
|
|
66
|
-
return combineAnd(orPart.split(/\s*&&\s*/).map((part) => {
|
|
67
|
-
const token = normalizePlatformToken(part);
|
|
68
|
-
if (!token || /[<>=!()]/.test(token)) return;
|
|
69
|
-
return platformTokens.has(token);
|
|
70
|
-
}));
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
function negateConditionalValue(value) {
|
|
74
|
-
return value === void 0 ? void 0 : !value;
|
|
75
|
-
}
|
|
76
|
-
function getActiveConditionalValue(stack) {
|
|
77
|
-
if (stack.includes(false)) return false;
|
|
78
|
-
return stack.includes(void 0) ? void 0 : true;
|
|
79
|
-
}
|
|
80
|
-
function parseConditionalStart(text) {
|
|
81
|
-
const normalized = text.trim();
|
|
82
|
-
if (!normalized.startsWith("#")) return;
|
|
83
|
-
const body = normalized.slice(1).trimStart();
|
|
84
|
-
for (const directive of ["ifndef", "ifdef"]) {
|
|
85
|
-
if (!body.startsWith(directive)) continue;
|
|
86
|
-
const expression = body.slice(directive.length).trim();
|
|
87
|
-
if (expression.length === 0) return;
|
|
88
|
-
return {
|
|
89
|
-
directive,
|
|
90
|
-
expression
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function compileCssMacroConditionalComments(css, options) {
|
|
95
|
-
const platformTokens = createPlatformTokenSet(resolveCssMacroPlatform(options));
|
|
96
|
-
if (platformTokens.size === 0 || !css.includes("#if")) return css;
|
|
97
|
-
try {
|
|
98
|
-
const root = postcss.default.parse(css);
|
|
99
|
-
const transformContainer = (container) => {
|
|
100
|
-
const stack = [];
|
|
101
|
-
for (const node of [...container.nodes ?? []]) {
|
|
102
|
-
if (node.type === "comment") {
|
|
103
|
-
const start = parseConditionalStart(node.text);
|
|
104
|
-
if (start) {
|
|
105
|
-
const value = start.directive === "ifndef" ? negateConditionalValue(evaluatePlatformExpression(start.expression, platformTokens)) : evaluatePlatformExpression(start.expression, platformTokens);
|
|
106
|
-
const parentActive = getActiveConditionalValue(stack);
|
|
107
|
-
stack.push(value);
|
|
108
|
-
if (parentActive !== void 0 && value !== void 0) node.remove();
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (CONDITIONAL_END_RE.test(node.text)) {
|
|
112
|
-
const value = stack.pop();
|
|
113
|
-
if (getActiveConditionalValue(stack) !== void 0 && value !== void 0) node.remove();
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (getActiveConditionalValue(stack) === false) {
|
|
118
|
-
node.remove();
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if ("nodes" in node && node.nodes) transformContainer(node);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
transformContainer(root);
|
|
125
|
-
return root.toString();
|
|
126
|
-
} catch {
|
|
127
|
-
return css;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function markCssMacroPlugin(value) {
|
|
131
|
-
Object.defineProperty(value, CSS_MACRO_PLUGIN_MARKER, {
|
|
132
|
-
configurable: false,
|
|
133
|
-
enumerable: false,
|
|
134
|
-
value: true
|
|
135
|
-
});
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
function isCssMacroTailwindPlugin(value) {
|
|
139
|
-
return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
|
|
140
|
-
}
|
|
141
|
-
function hasCssMacroTailwindPlugin(plugins) {
|
|
142
|
-
if (!plugins) return false;
|
|
143
|
-
if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
|
|
144
|
-
if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
function parseCssPluginRequest(params) {
|
|
148
|
-
const value = params.trim();
|
|
149
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
150
|
-
if (quoted) return quoted[2];
|
|
151
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
152
|
-
return url?.[2] ?? url?.[3];
|
|
153
|
-
}
|
|
154
|
-
function isCssMacroPluginRequest(request) {
|
|
155
|
-
return request === "weapp-tailwindcss/css-macro";
|
|
156
|
-
}
|
|
157
|
-
function hasCssMacroTailwindV4Directive(css) {
|
|
158
|
-
if (!css?.includes("css-macro")) return false;
|
|
159
|
-
try {
|
|
160
|
-
let found = false;
|
|
161
|
-
postcss.default.parse(css).walkAtRules("plugin", (rule) => {
|
|
162
|
-
if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
|
|
163
|
-
});
|
|
164
|
-
return found;
|
|
165
|
-
} catch {
|
|
166
|
-
return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function isCssMacroPostcssPlugin(plugin) {
|
|
170
|
-
if (plugin === require_postcss.creator) return true;
|
|
171
|
-
return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
|
|
172
|
-
}
|
|
173
|
-
function withCssMacroPostcssPlugins(plugins) {
|
|
174
|
-
const macroPlugin = require_postcss.creator();
|
|
175
|
-
if (!plugins) return [macroPlugin];
|
|
176
|
-
if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
|
|
177
|
-
if (typeof plugins === "object") {
|
|
178
|
-
const values = Object.values(plugins).filter(Boolean);
|
|
179
|
-
if (values.some(isCssMacroPostcssPlugin)) return values;
|
|
180
|
-
return [...values, macroPlugin];
|
|
181
|
-
}
|
|
182
|
-
return [macroPlugin];
|
|
183
|
-
}
|
|
184
|
-
function withCssMacroStyleOptions(options) {
|
|
185
|
-
const postcssOptions = options?.postcssOptions;
|
|
186
|
-
return {
|
|
187
|
-
...options,
|
|
188
|
-
[CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
|
|
189
|
-
postcssOptions: {
|
|
190
|
-
...postcssOptions,
|
|
191
|
-
plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function hasCssMacroStyleOptions(options) {
|
|
196
|
-
return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
|
|
197
|
-
}
|
|
198
|
-
async function transformCssMacroCss(css, options) {
|
|
199
|
-
const result = (await (0, postcss.default)([require_postcss.creator()]).process(css, { from: void 0 })).css;
|
|
200
|
-
return compileCssMacroConditionalComments(result, options);
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
|
-
Object.defineProperty(exports, "hasCssMacroStyleOptions", {
|
|
204
|
-
enumerable: true,
|
|
205
|
-
get: function() {
|
|
206
|
-
return hasCssMacroStyleOptions;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
Object.defineProperty(exports, "hasCssMacroTailwindPlugin", {
|
|
210
|
-
enumerable: true,
|
|
211
|
-
get: function() {
|
|
212
|
-
return hasCssMacroTailwindPlugin;
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
Object.defineProperty(exports, "hasCssMacroTailwindV4Directive", {
|
|
216
|
-
enumerable: true,
|
|
217
|
-
get: function() {
|
|
218
|
-
return hasCssMacroTailwindV4Directive;
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
Object.defineProperty(exports, "markCssMacroPlugin", {
|
|
222
|
-
enumerable: true,
|
|
223
|
-
get: function() {
|
|
224
|
-
return markCssMacroPlugin;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
Object.defineProperty(exports, "transformCssMacroCss", {
|
|
228
|
-
enumerable: true,
|
|
229
|
-
get: function() {
|
|
230
|
-
return transformCssMacroCss;
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
Object.defineProperty(exports, "withCssMacroStyleOptions", {
|
|
234
|
-
enumerable: true,
|
|
235
|
-
get: function() {
|
|
236
|
-
return withCssMacroStyleOptions;
|
|
237
|
-
}
|
|
238
|
-
});
|
package/dist/auto-DEHRmEAx.mjs
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { n as creator } from "./postcss-C7BMYpEF.mjs";
|
|
2
|
-
import postcss from "postcss";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
//#region src/css-macro/auto.ts
|
|
5
|
-
const CSS_MACRO_PLUGIN_MARKER = "__weappTailwindcssCssMacro";
|
|
6
|
-
const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
|
|
7
|
-
const PLATFORM_ENV_KEYS = [
|
|
8
|
-
"WEAPP_TW_TARGET",
|
|
9
|
-
"WEAPP_TAILWINDCSS_TARGET",
|
|
10
|
-
"UNI_PLATFORM",
|
|
11
|
-
"UNI_UTS_PLATFORM",
|
|
12
|
-
"TARO_ENV",
|
|
13
|
-
"MPX_CLI_MODE",
|
|
14
|
-
"MPX_CURRENT_TARGET_MODE"
|
|
15
|
-
];
|
|
16
|
-
const CONDITIONAL_END_RE = /^\s*#endif\s*$/;
|
|
17
|
-
function readEnvValue(key) {
|
|
18
|
-
return typeof process === "undefined" ? void 0 : process.env[key];
|
|
19
|
-
}
|
|
20
|
-
function normalizePlatformToken(value) {
|
|
21
|
-
return value?.trim().replaceAll("_", "-").toUpperCase() || void 0;
|
|
22
|
-
}
|
|
23
|
-
function resolveCssMacroPlatform(options) {
|
|
24
|
-
const explicit = normalizePlatformToken(options?.platform);
|
|
25
|
-
if (explicit) return explicit;
|
|
26
|
-
for (const key of PLATFORM_ENV_KEYS) {
|
|
27
|
-
const value = normalizePlatformToken(readEnvValue(key));
|
|
28
|
-
if (value) return value;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function createPlatformTokenSet(platform) {
|
|
32
|
-
const normalized = normalizePlatformToken(platform);
|
|
33
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
34
|
-
if (!normalized) return tokens;
|
|
35
|
-
tokens.add(normalized);
|
|
36
|
-
if (normalized.startsWith("MP-")) tokens.add("MP");
|
|
37
|
-
if (normalized === "WEAPP" || normalized === "WEIXIN" || normalized === "WX") {
|
|
38
|
-
tokens.add("MP");
|
|
39
|
-
tokens.add("MP-WEIXIN");
|
|
40
|
-
}
|
|
41
|
-
if (normalized === "MP-WEIXIN") {
|
|
42
|
-
tokens.add("WEAPP");
|
|
43
|
-
tokens.add("WEIXIN");
|
|
44
|
-
tokens.add("WX");
|
|
45
|
-
}
|
|
46
|
-
if (normalized === "H5") tokens.add("WEB");
|
|
47
|
-
if (normalized === "WEB") tokens.add("H5");
|
|
48
|
-
if (normalized === "APP") tokens.add("APP-PLUS");
|
|
49
|
-
if (normalized.startsWith("APP-")) tokens.add("APP");
|
|
50
|
-
if (normalized.startsWith("QUICKAPP-WEBVIEW")) tokens.add("QUICKAPP-WEBVIEW");
|
|
51
|
-
return tokens;
|
|
52
|
-
}
|
|
53
|
-
function combineAnd(values) {
|
|
54
|
-
if (values.includes(false)) return false;
|
|
55
|
-
return values.every((value) => value === true) ? true : void 0;
|
|
56
|
-
}
|
|
57
|
-
function combineOr(values) {
|
|
58
|
-
if (values.includes(true)) return true;
|
|
59
|
-
return values.every((value) => value === false) ? false : void 0;
|
|
60
|
-
}
|
|
61
|
-
function evaluatePlatformExpression(expression, platformTokens) {
|
|
62
|
-
return combineOr(expression.split(/\s*\|\|\s*/).map((orPart) => {
|
|
63
|
-
return combineAnd(orPart.split(/\s*&&\s*/).map((part) => {
|
|
64
|
-
const token = normalizePlatformToken(part);
|
|
65
|
-
if (!token || /[<>=!()]/.test(token)) return;
|
|
66
|
-
return platformTokens.has(token);
|
|
67
|
-
}));
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
function negateConditionalValue(value) {
|
|
71
|
-
return value === void 0 ? void 0 : !value;
|
|
72
|
-
}
|
|
73
|
-
function getActiveConditionalValue(stack) {
|
|
74
|
-
if (stack.includes(false)) return false;
|
|
75
|
-
return stack.includes(void 0) ? void 0 : true;
|
|
76
|
-
}
|
|
77
|
-
function parseConditionalStart(text) {
|
|
78
|
-
const normalized = text.trim();
|
|
79
|
-
if (!normalized.startsWith("#")) return;
|
|
80
|
-
const body = normalized.slice(1).trimStart();
|
|
81
|
-
for (const directive of ["ifndef", "ifdef"]) {
|
|
82
|
-
if (!body.startsWith(directive)) continue;
|
|
83
|
-
const expression = body.slice(directive.length).trim();
|
|
84
|
-
if (expression.length === 0) return;
|
|
85
|
-
return {
|
|
86
|
-
directive,
|
|
87
|
-
expression
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function compileCssMacroConditionalComments(css, options) {
|
|
92
|
-
const platformTokens = createPlatformTokenSet(resolveCssMacroPlatform(options));
|
|
93
|
-
if (platformTokens.size === 0 || !css.includes("#if")) return css;
|
|
94
|
-
try {
|
|
95
|
-
const root = postcss.parse(css);
|
|
96
|
-
const transformContainer = (container) => {
|
|
97
|
-
const stack = [];
|
|
98
|
-
for (const node of [...container.nodes ?? []]) {
|
|
99
|
-
if (node.type === "comment") {
|
|
100
|
-
const start = parseConditionalStart(node.text);
|
|
101
|
-
if (start) {
|
|
102
|
-
const value = start.directive === "ifndef" ? negateConditionalValue(evaluatePlatformExpression(start.expression, platformTokens)) : evaluatePlatformExpression(start.expression, platformTokens);
|
|
103
|
-
const parentActive = getActiveConditionalValue(stack);
|
|
104
|
-
stack.push(value);
|
|
105
|
-
if (parentActive !== void 0 && value !== void 0) node.remove();
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (CONDITIONAL_END_RE.test(node.text)) {
|
|
109
|
-
const value = stack.pop();
|
|
110
|
-
if (getActiveConditionalValue(stack) !== void 0 && value !== void 0) node.remove();
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (getActiveConditionalValue(stack) === false) {
|
|
115
|
-
node.remove();
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if ("nodes" in node && node.nodes) transformContainer(node);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
transformContainer(root);
|
|
122
|
-
return root.toString();
|
|
123
|
-
} catch {
|
|
124
|
-
return css;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function markCssMacroPlugin(value) {
|
|
128
|
-
Object.defineProperty(value, CSS_MACRO_PLUGIN_MARKER, {
|
|
129
|
-
configurable: false,
|
|
130
|
-
enumerable: false,
|
|
131
|
-
value: true
|
|
132
|
-
});
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
function isCssMacroTailwindPlugin(value) {
|
|
136
|
-
return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
|
|
137
|
-
}
|
|
138
|
-
function hasCssMacroTailwindPlugin(plugins) {
|
|
139
|
-
if (!plugins) return false;
|
|
140
|
-
if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
|
|
141
|
-
if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
function parseCssPluginRequest(params) {
|
|
145
|
-
const value = params.trim();
|
|
146
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
147
|
-
if (quoted) return quoted[2];
|
|
148
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
149
|
-
return url?.[2] ?? url?.[3];
|
|
150
|
-
}
|
|
151
|
-
function isCssMacroPluginRequest(request) {
|
|
152
|
-
return request === "weapp-tailwindcss/css-macro";
|
|
153
|
-
}
|
|
154
|
-
function hasCssMacroTailwindV4Directive(css) {
|
|
155
|
-
if (!css?.includes("css-macro")) return false;
|
|
156
|
-
try {
|
|
157
|
-
let found = false;
|
|
158
|
-
postcss.parse(css).walkAtRules("plugin", (rule) => {
|
|
159
|
-
if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
|
|
160
|
-
});
|
|
161
|
-
return found;
|
|
162
|
-
} catch {
|
|
163
|
-
return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function isCssMacroPostcssPlugin(plugin) {
|
|
167
|
-
if (plugin === creator) return true;
|
|
168
|
-
return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
|
|
169
|
-
}
|
|
170
|
-
function withCssMacroPostcssPlugins(plugins) {
|
|
171
|
-
const macroPlugin = creator();
|
|
172
|
-
if (!plugins) return [macroPlugin];
|
|
173
|
-
if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
|
|
174
|
-
if (typeof plugins === "object") {
|
|
175
|
-
const values = Object.values(plugins).filter(Boolean);
|
|
176
|
-
if (values.some(isCssMacroPostcssPlugin)) return values;
|
|
177
|
-
return [...values, macroPlugin];
|
|
178
|
-
}
|
|
179
|
-
return [macroPlugin];
|
|
180
|
-
}
|
|
181
|
-
function withCssMacroStyleOptions(options) {
|
|
182
|
-
const postcssOptions = options?.postcssOptions;
|
|
183
|
-
return {
|
|
184
|
-
...options,
|
|
185
|
-
[CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
|
|
186
|
-
postcssOptions: {
|
|
187
|
-
...postcssOptions,
|
|
188
|
-
plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function hasCssMacroStyleOptions(options) {
|
|
193
|
-
return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
|
|
194
|
-
}
|
|
195
|
-
async function transformCssMacroCss(css, options) {
|
|
196
|
-
const result = (await postcss([creator()]).process(css, { from: void 0 })).css;
|
|
197
|
-
return compileCssMacroConditionalComments(result, options);
|
|
198
|
-
}
|
|
199
|
-
//#endregion
|
|
200
|
-
export { transformCssMacroCss as a, markCssMacroPlugin as i, hasCssMacroTailwindPlugin as n, withCssMacroStyleOptions as o, hasCssMacroTailwindV4Directive as r, hasCssMacroStyleOptions as t };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import postcssrc from 'postcss-load-config';
|
|
2
|
-
export declare function resolveFilteredPostcssConfig(root: string): Promise<{
|
|
3
|
-
options: import("postcss").ProcessOptions<import("postcss").Document | import("postcss").Root>;
|
|
4
|
-
plugins: postcssrc.ResultPlugin[];
|
|
5
|
-
removed: number;
|
|
6
|
-
} | undefined>;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function prependConfigDirective(css: string, config: string | undefined): string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Result, Root } from 'postcss';
|
|
2
|
-
import type { WeappTailwindcssGenerateResult } from '../generator';
|
|
3
|
-
import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
|
|
4
|
-
export declare function resolveInputFile(result: Result): string | undefined;
|
|
5
|
-
export declare function resolvePostcssBase(result: Result, options: WeappTailwindcssPostcssPluginOptions): string;
|
|
6
|
-
export declare function resolvePostcssProjectRoot(result: Result, options: WeappTailwindcssPostcssPluginOptions): string;
|
|
7
|
-
export declare function replaceRootCss(root: Root, css: string, result: Result): void;
|
|
8
|
-
export declare function addDependencyMessages(result: Result, generated: WeappTailwindcssGenerateResult): void;
|
|
9
|
-
export declare function addSourceDependencyMessages(result: Result, files: string[]): void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Result, Root } from 'postcss';
|
|
2
|
-
import type { TailwindV4CandidateSource } from '../generator';
|
|
3
|
-
import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
|
|
4
|
-
export declare function collectAutoTailwindCandidates(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): Promise<Set<string>>;
|
|
5
|
-
export declare function collectPostcssLocalSources(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): Promise<{
|
|
6
|
-
files: string[];
|
|
7
|
-
sources: TailwindV4CandidateSource[];
|
|
8
|
-
}>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { Result, Root } from 'postcss';
|
|
2
|
-
import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
|
|
3
|
-
export declare function resolvePostcssTailwindVersion(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): import("../tailwindcss/version").SupportedTailwindcssMajorVersion;
|