weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.31
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 +6 -7
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/auto-TH1jG2UW.js +115 -0
- package/dist/auto-XyKTOP7B.mjs +78 -0
- package/dist/bundle-state-Bi-cQua6.mjs +413 -0
- package/dist/bundle-state-Ct_8GcSR.js +529 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +21 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
- package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +16 -22
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/index.d.ts +5 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
- package/dist/bundlers/vite/source-candidates.d.ts +19 -1
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +758 -604
- package/dist/cli.mjs +766 -612
- package/dist/constants.d.ts +1 -2
- package/dist/context/runtime-package-replacements.d.ts +2 -0
- package/dist/context/style-options.d.ts +3 -0
- package/dist/core.js +12 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/auto.d.ts +10 -0
- package/dist/css-macro/constants.d.ts +5 -2
- package/dist/css-macro/postcss.d.ts +1 -0
- package/dist/css-macro/postcss.js +7 -46
- package/dist/css-macro/postcss.mjs +2 -46
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +16 -7
- package/dist/css-macro.mjs +15 -6
- package/dist/defaults-8xrgzxFY.mjs +151 -0
- package/dist/defaults-zKUH2mDe.js +193 -0
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +6 -131
- package/dist/defaults.mjs +2 -129
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +9 -8
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-CrU-Ghc1.js +90 -0
- package/dist/generator-Qw-tZ0Z2.mjs +65 -0
- package/dist/generator.js +12 -12
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +187 -48
- package/dist/gulp.mjs +180 -41
- package/dist/incremental-runtime-class-set-Boqi1QlB.mjs +2224 -0
- package/dist/incremental-runtime-class-set-FAOHZmzh.js +2293 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +19 -7
- package/dist/index.mjs +6 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/logger-BNzxZbZj.mjs +2 -0
- package/dist/logger-TlKT3xmR.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-C6zOQqlL.mjs +228 -0
- package/dist/postcss-C7BMYpEF.mjs +169 -0
- package/dist/postcss-CiYLsqZn.js +192 -0
- package/dist/postcss-DAWf9D3C.js +237 -0
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/precheck-D7K12zeX.mjs +4716 -0
- package/dist/precheck-D7gJSmJz.js +4842 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/uni-app-x.d.ts +1 -0
- package/dist/presets.js +29 -13
- package/dist/presets.mjs +25 -11
- package/dist/reset.d.ts +1 -0
- package/dist/reset.js +1 -1
- package/dist/runtime-registry-DpcR3IHI.js +5496 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-CX2ozpKM.mjs +322 -0
- package/dist/source-candidates-DNM8iwXW.js +335 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-B-e2RiXr.js +642 -0
- package/dist/tailwindcss-C7dJHZ0G.mjs +591 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +52 -49
- package/dist/types/shared.d.ts +6 -0
- package/dist/types/user-defined-options/general.d.ts +25 -24
- package/dist/types/user-defined-options/important.d.ts +33 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/unocss/index.d.ts +2 -0
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/options.d.ts +2 -0
- package/dist/utils/regex.d.ts +1 -0
- package/dist/{utils-DmC9_In3.js → utils-D7Ygohep.js} +2 -2
- package/dist/{utils-7DUGTFED.mjs → utils-DsaS975I.mjs} +1 -1
- package/dist/v3-engine-CHItlVq5.js +3616 -0
- package/dist/v3-engine-DcvCCHfs.mjs +3321 -0
- package/dist/vite-BgTPSkQS.js +24446 -0
- package/dist/vite-fFRpSvyz.mjs +24432 -0
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +5227 -18
- package/dist/weapp-tw-runtime-classset-loader.js +32 -9
- package/dist/webpack-BXSWVdXh.js +851 -0
- package/dist/webpack-Dx2AZpGU.mjs +841 -0
- package/dist/webpack.d.ts +1 -3
- package/dist/webpack.js +3 -4
- package/dist/webpack.mjs +2 -2
- package/package.json +38 -48
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/constants-B-_T5UnW.mjs +0 -44
- package/dist/constants-p1dyh1x1.js +0 -73
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
- package/dist/generator-css-Bwy_Uz89.mjs +0 -1097
- package/dist/generator-css-CRLrHW4F.js +0 -1124
- package/dist/generator-mmhXzZnv.js +0 -1276
- package/dist/js/syntax.d.ts +0 -10
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
- package/dist/loader-anchors-1MumTAtA.mjs +0 -205
- package/dist/loader-anchors-TrFvT6g1.js +0 -273
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/recorder-GdTJ3QqX.js +0 -2878
- package/dist/recorder-XdFvVASS.mjs +0 -2763
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/vite-BDywuCjn.mjs +0 -2186
- package/dist/vite-DgRh_GXn.js +0 -2199
- package/dist/webpack-CAJR4hhP.js +0 -456
- package/dist/webpack-CiHqVZTg.mjs +0 -441
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
package/dist/cli.js
CHANGED
|
@@ -36,267 +36,653 @@ require("@weapp-tailwindcss/shared");
|
|
|
36
36
|
let debug = require("debug");
|
|
37
37
|
debug = __toESM(debug);
|
|
38
38
|
let node_fs = require("node:fs");
|
|
39
|
+
node_fs = __toESM(node_fs);
|
|
40
|
+
require("postcss");
|
|
41
|
+
require("micromatch");
|
|
42
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
39
43
|
let node_module = require("node:module");
|
|
40
|
-
require("
|
|
44
|
+
require("fast-glob");
|
|
45
|
+
require("tailwindcss-config");
|
|
41
46
|
let _babel_traverse = require("@babel/traverse");
|
|
42
47
|
_babel_traverse = __toESM(_babel_traverse);
|
|
43
48
|
let _babel_parser = require("@babel/parser");
|
|
44
|
-
let _weapp_core_regex = require("@weapp-core/regex");
|
|
45
49
|
let magic_string = require("magic-string");
|
|
46
50
|
magic_string = __toESM(magic_string);
|
|
47
51
|
let _ast_core_escape = require("@ast-core/escape");
|
|
48
52
|
let _weapp_tailwindcss_shared_extractors = require("@weapp-tailwindcss/shared/extractors");
|
|
49
53
|
require("@babel/types");
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let yaml = require("yaml");
|
|
54
|
+
//#region src/js/babel/cache-options.ts
|
|
55
|
+
const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
|
|
56
|
+
const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
|
|
57
|
+
//#endregion
|
|
55
58
|
//#region src/debug/index.ts
|
|
56
59
|
const _debug = (0, debug.default)("weapp-tw");
|
|
57
60
|
function createDebug(prefix) {
|
|
58
|
-
const debug$
|
|
61
|
+
const debug$4 = ((formatter, ...args) => {
|
|
59
62
|
return _debug((prefix ?? "") + formatter, ...args);
|
|
60
63
|
});
|
|
61
|
-
Object.defineProperty(debug$
|
|
64
|
+
Object.defineProperty(debug$4, "enabled", {
|
|
62
65
|
enumerable: false,
|
|
63
66
|
configurable: false,
|
|
64
67
|
get() {
|
|
65
68
|
return _debug.enabled;
|
|
66
69
|
}
|
|
67
70
|
});
|
|
68
|
-
return debug$
|
|
71
|
+
return debug$4;
|
|
69
72
|
}
|
|
70
|
-
createDebug("[tailwindcss:runtime] ");
|
|
71
73
|
//#endregion
|
|
72
|
-
//#region src/
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
//#region src/css-macro/constants.ts
|
|
75
|
+
const queryKey = "weapp-tw-platform";
|
|
76
|
+
const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
|
|
77
|
+
const WHITESPACE_RE = /\s+/g;
|
|
78
|
+
const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
|
|
79
|
+
function normalComment(text) {
|
|
80
|
+
if (typeof text === "string") {
|
|
81
|
+
const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
82
|
+
if (normalized.includes("\\")) return normalized;
|
|
83
|
+
return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
84
|
+
}
|
|
85
|
+
return text;
|
|
86
|
+
}
|
|
87
|
+
function ifdef(text) {
|
|
88
|
+
return {
|
|
89
|
+
start: `#ifdef ${normalComment(text)}`,
|
|
90
|
+
end: `#endif`
|
|
91
|
+
};
|
|
88
92
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
function ifndef(text) {
|
|
94
|
+
return {
|
|
95
|
+
start: `#ifndef ${normalComment(text)}`,
|
|
96
|
+
end: `#endif`
|
|
97
|
+
};
|
|
93
98
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
while (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
current = parent;
|
|
99
|
+
const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
100
|
+
function matchCustomPropertyFromValue(str, cb) {
|
|
101
|
+
let index = 0;
|
|
102
|
+
QUERY_KEY_REGEX.lastIndex = 0;
|
|
103
|
+
let arr = QUERY_KEY_REGEX.exec(str);
|
|
104
|
+
while (arr !== null) {
|
|
105
|
+
cb(arr, index);
|
|
106
|
+
index++;
|
|
107
|
+
arr = QUERY_KEY_REGEX.exec(str);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const parent = node_path.default.dirname(current);
|
|
112
|
-
if (parent === current) return;
|
|
113
|
-
current = parent;
|
|
114
|
-
}
|
|
110
|
+
function parseConditionalAtRuleParam(params) {
|
|
111
|
+
const value = params.trim();
|
|
112
|
+
const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
|
|
113
|
+
if (!quoted) return value;
|
|
114
|
+
return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
|
-
//#region src/
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
return node_path.default.normalize(value).replace(/\\/g, "/");
|
|
123
|
-
}
|
|
124
|
-
function formatRelativeToBase(targetPath, baseDir) {
|
|
125
|
-
if (!baseDir) return toDisplayPath(targetPath);
|
|
126
|
-
const relative = node_path.default.relative(baseDir, targetPath);
|
|
127
|
-
if (!relative || relative === ".") return ".";
|
|
128
|
-
if (relative.startsWith("..")) return toDisplayPath(targetPath);
|
|
129
|
-
return toDisplayPath(node_path.default.join(".", relative));
|
|
130
|
-
}
|
|
131
|
-
function resolveRecordLocation(baseDir) {
|
|
132
|
-
const normalizedBase = node_path.default.normalize(baseDir);
|
|
133
|
-
const packageRoot = findNearestPackageRoot(normalizedBase) ?? normalizedBase;
|
|
134
|
-
const packageJsonPath = node_path.default.join(packageRoot, "package.json");
|
|
135
|
-
const hasPackageJson = (0, node_fs.existsSync)(packageJsonPath);
|
|
136
|
-
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
137
|
-
const recordKey = (0, _weapp_tailwindcss_shared_node.md5)(node_path.default.normalize(recordKeySource));
|
|
138
|
-
const recordDir = node_path.default.join(packageRoot, "node_modules", ".cache", "weapp-tailwindcss", recordKey);
|
|
117
|
+
//#region src/css-macro/postcss.ts
|
|
118
|
+
const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
119
|
+
const CONDITIONAL_COMMENT_SPACING = " ";
|
|
120
|
+
const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
|
|
121
|
+
const creator = () => {
|
|
139
122
|
return {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
123
|
+
postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
|
|
124
|
+
prepare() {
|
|
125
|
+
function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
|
|
126
|
+
const hasPreviousNode = Boolean(atRule.prev());
|
|
127
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
128
|
+
const startComment = helper.comment({
|
|
129
|
+
raws: {
|
|
130
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
131
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
132
|
+
},
|
|
133
|
+
text: comment.start
|
|
134
|
+
});
|
|
135
|
+
const endComment = helper.comment({
|
|
136
|
+
raws: {
|
|
137
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
138
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
139
|
+
},
|
|
140
|
+
text: comment.end
|
|
141
|
+
});
|
|
142
|
+
const nextNodes = [
|
|
143
|
+
startComment,
|
|
144
|
+
...clonedNodes,
|
|
145
|
+
endComment
|
|
146
|
+
];
|
|
147
|
+
atRule.replaceWith(nextNodes);
|
|
148
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
149
|
+
startComment.raws["after"] = "\n";
|
|
150
|
+
if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
|
|
151
|
+
endComment.raws.before = "\n";
|
|
152
|
+
endComment.raws["after"] = "\n";
|
|
153
|
+
const nextNode = endComment?.next();
|
|
154
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
155
|
+
}
|
|
156
|
+
function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
|
|
157
|
+
if (atRule.parent?.type !== "rule") return false;
|
|
158
|
+
const parentRule = atRule.parent;
|
|
159
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
160
|
+
const conditionalRule = parentRule.clone();
|
|
161
|
+
conditionalRule.removeAll();
|
|
162
|
+
conditionalRule.append(...clonedNodes);
|
|
163
|
+
const startComment = helper.comment({
|
|
164
|
+
raws: {
|
|
165
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
166
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
167
|
+
},
|
|
168
|
+
text: comment.start
|
|
169
|
+
});
|
|
170
|
+
const endComment = helper.comment({
|
|
171
|
+
raws: {
|
|
172
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
173
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
174
|
+
},
|
|
175
|
+
text: comment.end
|
|
176
|
+
});
|
|
177
|
+
const nextNodes = [
|
|
178
|
+
startComment,
|
|
179
|
+
conditionalRule,
|
|
180
|
+
endComment
|
|
181
|
+
];
|
|
182
|
+
const hasPreviousNode = Boolean(parentRule.prev());
|
|
183
|
+
atRule.remove();
|
|
184
|
+
if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
|
|
185
|
+
else parentRule.after(nextNodes);
|
|
186
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
187
|
+
startComment.raws["after"] = "\n";
|
|
188
|
+
conditionalRule.raws.before = "\n";
|
|
189
|
+
endComment.raws.before = "\n";
|
|
190
|
+
endComment.raws["after"] = "\n";
|
|
191
|
+
const nextNode = endComment.next();
|
|
192
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
193
|
+
return true;
|
|
187
194
|
}
|
|
188
195
|
return {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
196
|
+
AtRule(atRule, helper) {
|
|
197
|
+
if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
|
|
198
|
+
const text = parseConditionalAtRuleParam(atRule.params);
|
|
199
|
+
const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
|
|
200
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
201
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (atRule.name === "media") {
|
|
205
|
+
const values = [];
|
|
206
|
+
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
207
|
+
const value = arr[1];
|
|
208
|
+
if (value) values.push(value);
|
|
209
|
+
});
|
|
210
|
+
if (values.length > 0) {
|
|
211
|
+
const isNegative = atRule.params.includes("not");
|
|
212
|
+
const text = values.join(" ");
|
|
213
|
+
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
214
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
215
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
CommentExit(comment) {
|
|
220
|
+
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
221
|
+
comment.raws.left = CONDITIONAL_COMMENT_SPACING;
|
|
222
|
+
comment.raws.right = CONDITIONAL_COMMENT_SPACING;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
192
225
|
};
|
|
193
|
-
} catch (error) {
|
|
194
|
-
warnInvalidPatchTargetRecord(normalizedBase, recordPath, error instanceof Error ? error.message : String(error));
|
|
195
|
-
continue;
|
|
196
226
|
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
async function saveCliPatchTargetRecord(baseDir, patcher, options) {
|
|
200
|
-
if (!baseDir || !patcher?.packageInfo?.rootPath) return;
|
|
201
|
-
const normalizedBase = node_path.default.normalize(baseDir);
|
|
202
|
-
const location = resolveRecordLocation(normalizedBase);
|
|
203
|
-
const recordPath = options?.recordPath ? node_path.default.normalize(options.recordPath) : location.recordPath;
|
|
204
|
-
const record = {
|
|
205
|
-
tailwindPackagePath: node_path.default.normalize(patcher.packageInfo.rootPath),
|
|
206
|
-
packageVersion: patcher.packageInfo.version,
|
|
207
|
-
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
208
|
-
source: options?.source ?? "cli",
|
|
209
|
-
tailwindcssBasedir: normalizedBase,
|
|
210
|
-
cwd: options?.cwd ? node_path.default.normalize(options.cwd) : normalizedBase,
|
|
211
|
-
patchVersion: WEAPP_TW_VERSION,
|
|
212
|
-
packageJsonPath: options?.packageJsonPath ?? location.packageJsonPath,
|
|
213
|
-
recordKey: options?.recordKey ?? location.recordKey
|
|
214
227
|
};
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
await (0, node_fs_promises.writeFile)(recordPath, `${JSON.stringify(record, null, 2)}\n`, "utf8");
|
|
218
|
-
return recordPath;
|
|
219
|
-
} catch (error) {
|
|
220
|
-
const baseDisplay = formatRelativeToBase(normalizedBase, node_process.default.cwd());
|
|
221
|
-
_weapp_tailwindcss_logger.logger.warn("自动更新 Tailwind CSS 补丁记录失败,请在 %s 运行 \"weapp-tw patch --cwd %s\"。", baseDisplay, normalizedBase);
|
|
222
|
-
_weapp_tailwindcss_logger.logger.debug("failed to persist patch target record %s: %O", recordPath, error);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
228
|
+
};
|
|
229
|
+
creator.postcss = true;
|
|
226
230
|
//#endregion
|
|
227
|
-
//#region src/tailwindcss/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
231
|
+
//#region src/tailwindcss/source-scan.ts
|
|
232
|
+
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
233
|
+
"html",
|
|
234
|
+
"wxml",
|
|
235
|
+
"axml",
|
|
236
|
+
"jxml",
|
|
237
|
+
"ksml",
|
|
238
|
+
"ttml",
|
|
239
|
+
"qml",
|
|
240
|
+
"tyml",
|
|
241
|
+
"xhsml",
|
|
242
|
+
"swan",
|
|
243
|
+
"vue",
|
|
244
|
+
"mpx",
|
|
245
|
+
"js",
|
|
246
|
+
"jsx",
|
|
247
|
+
"ts",
|
|
248
|
+
"tsx"
|
|
249
|
+
];
|
|
250
|
+
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
251
|
+
"js",
|
|
252
|
+
"jsx",
|
|
253
|
+
"mjs",
|
|
254
|
+
"cjs",
|
|
255
|
+
"ts",
|
|
256
|
+
"tsx",
|
|
257
|
+
"mts",
|
|
258
|
+
"cts",
|
|
259
|
+
"vue",
|
|
260
|
+
"uvue",
|
|
261
|
+
"nvue",
|
|
262
|
+
"svelte",
|
|
263
|
+
"mpx",
|
|
264
|
+
"html",
|
|
265
|
+
"wxml",
|
|
266
|
+
"axml",
|
|
267
|
+
"jxml",
|
|
268
|
+
"ksml",
|
|
269
|
+
"ttml",
|
|
270
|
+
"qml",
|
|
271
|
+
"tyml",
|
|
272
|
+
"xhsml",
|
|
273
|
+
"swan",
|
|
274
|
+
"css",
|
|
275
|
+
"wxss",
|
|
276
|
+
"acss",
|
|
277
|
+
"jxss",
|
|
278
|
+
"ttss",
|
|
279
|
+
"qss",
|
|
280
|
+
"tyss",
|
|
281
|
+
"scss",
|
|
282
|
+
"sass",
|
|
283
|
+
"less",
|
|
284
|
+
"styl",
|
|
285
|
+
"stylus"
|
|
286
|
+
];
|
|
287
|
+
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
288
|
+
return `**/*.{${extensions.join(",")}}`;
|
|
282
289
|
}
|
|
290
|
+
createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
291
|
+
new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
283
292
|
//#endregion
|
|
284
|
-
//#region src/
|
|
285
|
-
function
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
293
|
+
//#region src/utils/object.ts
|
|
294
|
+
function definedEntries(value) {
|
|
295
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
296
|
+
}
|
|
297
|
+
function omitUndefined(value) {
|
|
298
|
+
return Object.fromEntries(definedEntries(value));
|
|
299
|
+
}
|
|
300
|
+
(0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
301
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
302
|
+
cssRemoveHoverPseudoClass: true,
|
|
303
|
+
isMainChunk: true,
|
|
304
|
+
majorVersion: 4
|
|
305
|
+
});
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
308
|
+
const TAILWIND_V3_COLOR_STEPS = [
|
|
309
|
+
"50",
|
|
310
|
+
"100",
|
|
311
|
+
"200",
|
|
312
|
+
"300",
|
|
313
|
+
"400",
|
|
314
|
+
"500",
|
|
315
|
+
"600",
|
|
316
|
+
"700",
|
|
317
|
+
"800",
|
|
318
|
+
"900",
|
|
319
|
+
"950"
|
|
320
|
+
];
|
|
321
|
+
const TAILWIND_V3_COLOR_PALETTE = {
|
|
322
|
+
slate: [
|
|
323
|
+
"#f8fafc",
|
|
324
|
+
"#f1f5f9",
|
|
325
|
+
"#e2e8f0",
|
|
326
|
+
"#cbd5e1",
|
|
327
|
+
"#94a3b8",
|
|
328
|
+
"#64748b",
|
|
329
|
+
"#475569",
|
|
330
|
+
"#334155",
|
|
331
|
+
"#1e293b",
|
|
332
|
+
"#0f172a",
|
|
333
|
+
"#020617"
|
|
334
|
+
],
|
|
335
|
+
gray: [
|
|
336
|
+
"#f9fafb",
|
|
337
|
+
"#f3f4f6",
|
|
338
|
+
"#e5e7eb",
|
|
339
|
+
"#d1d5db",
|
|
340
|
+
"#9ca3af",
|
|
341
|
+
"#6b7280",
|
|
342
|
+
"#4b5563",
|
|
343
|
+
"#374151",
|
|
344
|
+
"#1f2937",
|
|
345
|
+
"#111827",
|
|
346
|
+
"#030712"
|
|
347
|
+
],
|
|
348
|
+
zinc: [
|
|
349
|
+
"#fafafa",
|
|
350
|
+
"#f4f4f5",
|
|
351
|
+
"#e4e4e7",
|
|
352
|
+
"#d4d4d8",
|
|
353
|
+
"#a1a1aa",
|
|
354
|
+
"#71717a",
|
|
355
|
+
"#52525b",
|
|
356
|
+
"#3f3f46",
|
|
357
|
+
"#27272a",
|
|
358
|
+
"#18181b",
|
|
359
|
+
"#09090b"
|
|
360
|
+
],
|
|
361
|
+
neutral: [
|
|
362
|
+
"#fafafa",
|
|
363
|
+
"#f5f5f5",
|
|
364
|
+
"#e5e5e5",
|
|
365
|
+
"#d4d4d4",
|
|
366
|
+
"#a3a3a3",
|
|
367
|
+
"#737373",
|
|
368
|
+
"#525252",
|
|
369
|
+
"#404040",
|
|
370
|
+
"#262626",
|
|
371
|
+
"#171717",
|
|
372
|
+
"#0a0a0a"
|
|
373
|
+
],
|
|
374
|
+
stone: [
|
|
375
|
+
"#fafaf9",
|
|
376
|
+
"#f5f5f4",
|
|
377
|
+
"#e7e5e4",
|
|
378
|
+
"#d6d3d1",
|
|
379
|
+
"#a8a29e",
|
|
380
|
+
"#78716c",
|
|
381
|
+
"#57534e",
|
|
382
|
+
"#44403c",
|
|
383
|
+
"#292524",
|
|
384
|
+
"#1c1917",
|
|
385
|
+
"#0c0a09"
|
|
386
|
+
],
|
|
387
|
+
red: [
|
|
388
|
+
"#fef2f2",
|
|
389
|
+
"#fee2e2",
|
|
390
|
+
"#fecaca",
|
|
391
|
+
"#fca5a5",
|
|
392
|
+
"#f87171",
|
|
393
|
+
"#ef4444",
|
|
394
|
+
"#dc2626",
|
|
395
|
+
"#b91c1c",
|
|
396
|
+
"#991b1b",
|
|
397
|
+
"#7f1d1d",
|
|
398
|
+
"#450a0a"
|
|
399
|
+
],
|
|
400
|
+
orange: [
|
|
401
|
+
"#fff7ed",
|
|
402
|
+
"#ffedd5",
|
|
403
|
+
"#fed7aa",
|
|
404
|
+
"#fdba74",
|
|
405
|
+
"#fb923c",
|
|
406
|
+
"#f97316",
|
|
407
|
+
"#ea580c",
|
|
408
|
+
"#c2410c",
|
|
409
|
+
"#9a3412",
|
|
410
|
+
"#7c2d12",
|
|
411
|
+
"#431407"
|
|
412
|
+
],
|
|
413
|
+
amber: [
|
|
414
|
+
"#fffbeb",
|
|
415
|
+
"#fef3c7",
|
|
416
|
+
"#fde68a",
|
|
417
|
+
"#fcd34d",
|
|
418
|
+
"#fbbf24",
|
|
419
|
+
"#f59e0b",
|
|
420
|
+
"#d97706",
|
|
421
|
+
"#b45309",
|
|
422
|
+
"#92400e",
|
|
423
|
+
"#78350f",
|
|
424
|
+
"#451a03"
|
|
425
|
+
],
|
|
426
|
+
yellow: [
|
|
427
|
+
"#fefce8",
|
|
428
|
+
"#fef9c3",
|
|
429
|
+
"#fef08a",
|
|
430
|
+
"#fde047",
|
|
431
|
+
"#facc15",
|
|
432
|
+
"#eab308",
|
|
433
|
+
"#ca8a04",
|
|
434
|
+
"#a16207",
|
|
435
|
+
"#854d0e",
|
|
436
|
+
"#713f12",
|
|
437
|
+
"#422006"
|
|
438
|
+
],
|
|
439
|
+
lime: [
|
|
440
|
+
"#f7fee7",
|
|
441
|
+
"#ecfccb",
|
|
442
|
+
"#d9f99d",
|
|
443
|
+
"#bef264",
|
|
444
|
+
"#a3e635",
|
|
445
|
+
"#84cc16",
|
|
446
|
+
"#65a30d",
|
|
447
|
+
"#4d7c0f",
|
|
448
|
+
"#3f6212",
|
|
449
|
+
"#365314",
|
|
450
|
+
"#1a2e05"
|
|
451
|
+
],
|
|
452
|
+
green: [
|
|
453
|
+
"#f0fdf4",
|
|
454
|
+
"#dcfce7",
|
|
455
|
+
"#bbf7d0",
|
|
456
|
+
"#86efac",
|
|
457
|
+
"#4ade80",
|
|
458
|
+
"#22c55e",
|
|
459
|
+
"#16a34a",
|
|
460
|
+
"#15803d",
|
|
461
|
+
"#166534",
|
|
462
|
+
"#14532d",
|
|
463
|
+
"#052e16"
|
|
464
|
+
],
|
|
465
|
+
emerald: [
|
|
466
|
+
"#ecfdf5",
|
|
467
|
+
"#d1fae5",
|
|
468
|
+
"#a7f3d0",
|
|
469
|
+
"#6ee7b7",
|
|
470
|
+
"#34d399",
|
|
471
|
+
"#10b981",
|
|
472
|
+
"#059669",
|
|
473
|
+
"#047857",
|
|
474
|
+
"#065f46",
|
|
475
|
+
"#064e3b",
|
|
476
|
+
"#022c22"
|
|
477
|
+
],
|
|
478
|
+
teal: [
|
|
479
|
+
"#f0fdfa",
|
|
480
|
+
"#ccfbf1",
|
|
481
|
+
"#99f6e4",
|
|
482
|
+
"#5eead4",
|
|
483
|
+
"#2dd4bf",
|
|
484
|
+
"#14b8a6",
|
|
485
|
+
"#0d9488",
|
|
486
|
+
"#0f766e",
|
|
487
|
+
"#115e59",
|
|
488
|
+
"#134e4a",
|
|
489
|
+
"#042f2e"
|
|
490
|
+
],
|
|
491
|
+
cyan: [
|
|
492
|
+
"#ecfeff",
|
|
493
|
+
"#cffafe",
|
|
494
|
+
"#a5f3fc",
|
|
495
|
+
"#67e8f9",
|
|
496
|
+
"#22d3ee",
|
|
497
|
+
"#06b6d4",
|
|
498
|
+
"#0891b2",
|
|
499
|
+
"#0e7490",
|
|
500
|
+
"#155e75",
|
|
501
|
+
"#164e63",
|
|
502
|
+
"#083344"
|
|
503
|
+
],
|
|
504
|
+
sky: [
|
|
505
|
+
"#f0f9ff",
|
|
506
|
+
"#e0f2fe",
|
|
507
|
+
"#bae6fd",
|
|
508
|
+
"#7dd3fc",
|
|
509
|
+
"#38bdf8",
|
|
510
|
+
"#0ea5e9",
|
|
511
|
+
"#0284c7",
|
|
512
|
+
"#0369a1",
|
|
513
|
+
"#075985",
|
|
514
|
+
"#0c4a6e",
|
|
515
|
+
"#082f49"
|
|
516
|
+
],
|
|
517
|
+
blue: [
|
|
518
|
+
"#eff6ff",
|
|
519
|
+
"#dbeafe",
|
|
520
|
+
"#bfdbfe",
|
|
521
|
+
"#93c5fd",
|
|
522
|
+
"#60a5fa",
|
|
523
|
+
"#3b82f6",
|
|
524
|
+
"#2563eb",
|
|
525
|
+
"#1d4ed8",
|
|
526
|
+
"#1e40af",
|
|
527
|
+
"#1e3a8a",
|
|
528
|
+
"#172554"
|
|
529
|
+
],
|
|
530
|
+
indigo: [
|
|
531
|
+
"#eef2ff",
|
|
532
|
+
"#e0e7ff",
|
|
533
|
+
"#c7d2fe",
|
|
534
|
+
"#a5b4fc",
|
|
535
|
+
"#818cf8",
|
|
536
|
+
"#6366f1",
|
|
537
|
+
"#4f46e5",
|
|
538
|
+
"#4338ca",
|
|
539
|
+
"#3730a3",
|
|
540
|
+
"#312e81",
|
|
541
|
+
"#1e1b4b"
|
|
542
|
+
],
|
|
543
|
+
violet: [
|
|
544
|
+
"#f5f3ff",
|
|
545
|
+
"#ede9fe",
|
|
546
|
+
"#ddd6fe",
|
|
547
|
+
"#c4b5fd",
|
|
548
|
+
"#a78bfa",
|
|
549
|
+
"#8b5cf6",
|
|
550
|
+
"#7c3aed",
|
|
551
|
+
"#6d28d9",
|
|
552
|
+
"#5b21b6",
|
|
553
|
+
"#4c1d95",
|
|
554
|
+
"#2e1065"
|
|
555
|
+
],
|
|
556
|
+
purple: [
|
|
557
|
+
"#faf5ff",
|
|
558
|
+
"#f3e8ff",
|
|
559
|
+
"#e9d5ff",
|
|
560
|
+
"#d8b4fe",
|
|
561
|
+
"#c084fc",
|
|
562
|
+
"#a855f7",
|
|
563
|
+
"#9333ea",
|
|
564
|
+
"#7e22ce",
|
|
565
|
+
"#6b21a8",
|
|
566
|
+
"#581c87",
|
|
567
|
+
"#3b0764"
|
|
568
|
+
],
|
|
569
|
+
fuchsia: [
|
|
570
|
+
"#fdf4ff",
|
|
571
|
+
"#fae8ff",
|
|
572
|
+
"#f5d0fe",
|
|
573
|
+
"#f0abfc",
|
|
574
|
+
"#e879f9",
|
|
575
|
+
"#d946ef",
|
|
576
|
+
"#c026d3",
|
|
577
|
+
"#a21caf",
|
|
578
|
+
"#86198f",
|
|
579
|
+
"#701a75",
|
|
580
|
+
"#4a044e"
|
|
581
|
+
],
|
|
582
|
+
pink: [
|
|
583
|
+
"#fdf2f8",
|
|
584
|
+
"#fce7f3",
|
|
585
|
+
"#fbcfe8",
|
|
586
|
+
"#f9a8d4",
|
|
587
|
+
"#f472b6",
|
|
588
|
+
"#ec4899",
|
|
589
|
+
"#db2777",
|
|
590
|
+
"#be185d",
|
|
591
|
+
"#9d174d",
|
|
592
|
+
"#831843",
|
|
593
|
+
"#500724"
|
|
594
|
+
],
|
|
595
|
+
rose: [
|
|
596
|
+
"#fff1f2",
|
|
597
|
+
"#ffe4e6",
|
|
598
|
+
"#fecdd3",
|
|
599
|
+
"#fda4af",
|
|
600
|
+
"#fb7185",
|
|
601
|
+
"#f43f5e",
|
|
602
|
+
"#e11d48",
|
|
603
|
+
"#be123c",
|
|
604
|
+
"#9f1239",
|
|
605
|
+
"#881337",
|
|
606
|
+
"#4c0519"
|
|
607
|
+
]
|
|
608
|
+
};
|
|
609
|
+
function createTailwindV3DefaultColorThemeCss() {
|
|
610
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
611
|
+
for (const [color, values] of Object.entries(TAILWIND_V3_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V3_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V3_COLOR_STEPS[index]}: ${values[index]};`);
|
|
612
|
+
return [
|
|
613
|
+
"@theme {",
|
|
614
|
+
...declarations,
|
|
615
|
+
"}"
|
|
616
|
+
].join("\n");
|
|
617
|
+
}
|
|
618
|
+
[
|
|
619
|
+
"@theme {",
|
|
620
|
+
" --default-ring-width: 3px;",
|
|
621
|
+
" --default-ring-color: var(--color-blue-500, #3b82f6);",
|
|
622
|
+
" --default-outline-width: 3px;",
|
|
623
|
+
"",
|
|
624
|
+
" --shadow-xs: 0 1px rgb(0 0 0 / 0.05);",
|
|
625
|
+
" --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);",
|
|
626
|
+
" --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);",
|
|
627
|
+
" --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);",
|
|
628
|
+
" --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);",
|
|
629
|
+
" --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);",
|
|
630
|
+
"",
|
|
631
|
+
" --blur-xs: 4px;",
|
|
632
|
+
" --blur-sm: 4px;",
|
|
633
|
+
" --blur: 8px;",
|
|
634
|
+
" --backdrop-blur-xs: 4px;",
|
|
635
|
+
" --backdrop-blur-sm: 4px;",
|
|
636
|
+
" --backdrop-blur: 8px;",
|
|
637
|
+
"",
|
|
638
|
+
" --radius-xs: 0.125rem;",
|
|
639
|
+
" --radius-sm: 0.125rem;",
|
|
640
|
+
" --radius: 0.25rem;",
|
|
641
|
+
"}",
|
|
642
|
+
createTailwindV3DefaultColorThemeCss()
|
|
643
|
+
].join("\n");
|
|
644
|
+
[
|
|
645
|
+
"*,",
|
|
646
|
+
"::after,",
|
|
647
|
+
"::before,",
|
|
648
|
+
"::backdrop,",
|
|
649
|
+
"::file-selector-button {",
|
|
650
|
+
" border-color: var(--color-gray-200, currentcolor);",
|
|
651
|
+
"}",
|
|
652
|
+
"",
|
|
653
|
+
"input::placeholder,",
|
|
654
|
+
"textarea::placeholder {",
|
|
655
|
+
" opacity: 1;",
|
|
656
|
+
" color: var(--color-gray-400, currentcolor);",
|
|
657
|
+
"}",
|
|
658
|
+
"",
|
|
659
|
+
"button:not(:disabled),",
|
|
660
|
+
"[role=\"button\"]:not(:disabled) {",
|
|
661
|
+
" cursor: pointer;",
|
|
662
|
+
"}",
|
|
663
|
+
"",
|
|
664
|
+
"dialog {",
|
|
665
|
+
" margin: auto;",
|
|
666
|
+
"}"
|
|
667
|
+
].join("\n");
|
|
668
|
+
(0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
669
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
670
|
+
cssRemoveHoverPseudoClass: true,
|
|
671
|
+
isMainChunk: true,
|
|
672
|
+
majorVersion: 3
|
|
673
|
+
});
|
|
674
|
+
[
|
|
675
|
+
"@tailwind base;",
|
|
676
|
+
"@tailwind components;",
|
|
677
|
+
"@tailwind utilities;"
|
|
678
|
+
].join("\n");
|
|
679
|
+
createDebug("[tailwindcss:runtime-patch] ");
|
|
680
|
+
(0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
681
|
+
createDebug("[tailwindcss:runtime] ");
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/tailwindcss/runtime-logs.ts
|
|
684
|
+
const runtimeLogDedupeHolder = globalThis;
|
|
685
|
+
runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
|
|
300
686
|
//#endregion
|
|
301
687
|
//#region src/context/compiler-context-cache.ts
|
|
302
688
|
const globalCacheHolder = globalThis;
|
|
@@ -308,6 +694,12 @@ function _interopDefaultCompat(e) {
|
|
|
308
694
|
}
|
|
309
695
|
const traverse = _interopDefaultCompat(_babel_traverse.default);
|
|
310
696
|
//#endregion
|
|
697
|
+
//#region src/utils/regex.ts
|
|
698
|
+
function escapeStringRegexp(str) {
|
|
699
|
+
if (typeof str !== "string") throw new TypeError("Expected a string");
|
|
700
|
+
return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
|
|
701
|
+
}
|
|
702
|
+
//#endregion
|
|
311
703
|
//#region src/utils/nameMatcher.ts
|
|
312
704
|
const NEVER_MATCH_NAME$1 = () => false;
|
|
313
705
|
const GLOBAL_FLAG_REGEXP = /g/g;
|
|
@@ -315,10 +707,11 @@ function buildFuzzyMatcher(fuzzyStrings) {
|
|
|
315
707
|
if (fuzzyStrings.length === 0) return;
|
|
316
708
|
if (fuzzyStrings.length === 1) {
|
|
317
709
|
const [needle] = fuzzyStrings;
|
|
710
|
+
if (needle === void 0) return;
|
|
318
711
|
return (value) => value.includes(needle);
|
|
319
712
|
}
|
|
320
713
|
const unique = [...new Set(fuzzyStrings)];
|
|
321
|
-
const pattern = new RegExp(unique.map(
|
|
714
|
+
const pattern = new RegExp(unique.map(escapeStringRegexp).join("|"));
|
|
322
715
|
return (value) => pattern.test(value);
|
|
323
716
|
}
|
|
324
717
|
function normaliseRegex(regex) {
|
|
@@ -338,11 +731,13 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
338
731
|
const exactStringCount = exactStrings?.size ?? 0;
|
|
339
732
|
if (exactStringCount === 1 && regexList.length === 0) {
|
|
340
733
|
const [needle] = exactStrings;
|
|
734
|
+
if (needle === void 0) return NEVER_MATCH_NAME$1;
|
|
341
735
|
return (value) => value === needle;
|
|
342
736
|
}
|
|
343
737
|
if (regexList.length === 0) return (value) => exactStrings.has(value);
|
|
344
738
|
if (exactStringCount === 0 && regexList.length === 1) {
|
|
345
739
|
const [regex] = regexList;
|
|
740
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
346
741
|
return (value) => regex.test(value);
|
|
347
742
|
}
|
|
348
743
|
return (value) => {
|
|
@@ -355,6 +750,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
355
750
|
if (fuzzyMatcher && !hasRegex) return fuzzyMatcher;
|
|
356
751
|
if (!fuzzyMatcher && regexList.length === 1) {
|
|
357
752
|
const [regex] = regexList;
|
|
753
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
358
754
|
return (value) => regex.test(value);
|
|
359
755
|
}
|
|
360
756
|
return (value) => {
|
|
@@ -365,20 +761,40 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
365
761
|
}
|
|
366
762
|
//#endregion
|
|
367
763
|
//#region src/js/babel/parse.ts
|
|
368
|
-
const parseCache = new lru_cache.LRUCache({ max:
|
|
764
|
+
const parseCache = new lru_cache.LRUCache({ max: HARD_PARSE_CACHE_MAX_ENTRIES });
|
|
369
765
|
function genCacheKey(source, options) {
|
|
370
|
-
if (typeof options === "string") return source
|
|
371
|
-
return source
|
|
766
|
+
if (typeof options === "string") return `${(0, _weapp_tailwindcss_shared_node.md5)(source)}:${options}`;
|
|
767
|
+
return `${(0, _weapp_tailwindcss_shared_node.md5)(source)}:${JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val)}`;
|
|
768
|
+
}
|
|
769
|
+
function normalizeCacheMaxEntries(value) {
|
|
770
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 128;
|
|
771
|
+
return Math.min(Math.max(Math.floor(value), 0), HARD_PARSE_CACHE_MAX_ENTRIES);
|
|
772
|
+
}
|
|
773
|
+
function normalizeCacheMaxSourceLength(value) {
|
|
774
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH;
|
|
775
|
+
return Math.max(Math.floor(value), 0);
|
|
776
|
+
}
|
|
777
|
+
function trimParseCache(maxEntries) {
|
|
778
|
+
while (parseCache.size > maxEntries) parseCache.pop();
|
|
372
779
|
}
|
|
373
780
|
function babelParse(code, opts = {}) {
|
|
374
|
-
const { cache, cacheKey, ...rest } = opts;
|
|
375
|
-
const
|
|
781
|
+
const { cache, cacheKey, cacheMaxEntries, cacheMaxSourceLength, ...rest } = opts;
|
|
782
|
+
const maxEntries = normalizeCacheMaxEntries(cacheMaxEntries);
|
|
783
|
+
const maxSourceLength = normalizeCacheMaxSourceLength(cacheMaxSourceLength);
|
|
784
|
+
const shouldCache = cache === true && maxEntries > 0 && code.length <= maxSourceLength;
|
|
785
|
+
const cacheKeyString = shouldCache ? genCacheKey(code, cacheKey ?? rest) : void 0;
|
|
376
786
|
let result;
|
|
377
|
-
if (
|
|
787
|
+
if (shouldCache) {
|
|
788
|
+
trimParseCache(maxEntries);
|
|
789
|
+
result = parseCache.get(cacheKeyString);
|
|
790
|
+
}
|
|
378
791
|
if (!result) {
|
|
379
|
-
const { cache: _cache, cacheKey: _cacheKey, ...parseOptions } = opts;
|
|
792
|
+
const { cache: _cache, cacheKey: _cacheKey, cacheMaxEntries: _cacheMaxEntries, cacheMaxSourceLength: _cacheMaxSourceLength, ...parseOptions } = opts;
|
|
380
793
|
result = (0, _babel_parser.parse)(code, parseOptions);
|
|
381
|
-
if (
|
|
794
|
+
if (shouldCache) {
|
|
795
|
+
parseCache.set(cacheKeyString, result);
|
|
796
|
+
trimParseCache(maxEntries);
|
|
797
|
+
}
|
|
382
798
|
}
|
|
383
799
|
return result;
|
|
384
800
|
}
|
|
@@ -392,10 +808,10 @@ function replaceWxml(original, options = {
|
|
|
392
808
|
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
393
809
|
let res = original;
|
|
394
810
|
if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
|
|
395
|
-
res = (0, _weapp_core_escape.escape)(res, {
|
|
811
|
+
res = (0, _weapp_core_escape.escape)(res, omitUndefined({
|
|
396
812
|
map: escapeMap,
|
|
397
813
|
ignoreHead
|
|
398
|
-
});
|
|
814
|
+
}));
|
|
399
815
|
return res;
|
|
400
816
|
}
|
|
401
817
|
//#endregion
|
|
@@ -933,6 +1349,44 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
933
1349
|
}
|
|
934
1350
|
}
|
|
935
1351
|
//#endregion
|
|
1352
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
1353
|
+
function _typeof(o) {
|
|
1354
|
+
"@babel/helpers - typeof";
|
|
1355
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
1356
|
+
return typeof o;
|
|
1357
|
+
} : function(o) {
|
|
1358
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1359
|
+
}, _typeof(o);
|
|
1360
|
+
}
|
|
1361
|
+
//#endregion
|
|
1362
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
1363
|
+
function toPrimitive(t, r) {
|
|
1364
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
1365
|
+
var e = t[Symbol.toPrimitive];
|
|
1366
|
+
if (void 0 !== e) {
|
|
1367
|
+
var i = e.call(t, r || "default");
|
|
1368
|
+
if ("object" != _typeof(i)) return i;
|
|
1369
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1370
|
+
}
|
|
1371
|
+
return ("string" === r ? String : Number)(t);
|
|
1372
|
+
}
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
1375
|
+
function toPropertyKey(t) {
|
|
1376
|
+
var i = toPrimitive(t, "string");
|
|
1377
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
1378
|
+
}
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
1381
|
+
function _defineProperty(e, r, t) {
|
|
1382
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1383
|
+
value: t,
|
|
1384
|
+
enumerable: !0,
|
|
1385
|
+
configurable: !0,
|
|
1386
|
+
writable: !0
|
|
1387
|
+
}) : e[r] = t, e;
|
|
1388
|
+
}
|
|
1389
|
+
//#endregion
|
|
936
1390
|
//#region src/js/JsTokenUpdater.ts
|
|
937
1391
|
/**
|
|
938
1392
|
* Lightweight helper that batches updates to {@link MagicString}.
|
|
@@ -941,6 +1395,7 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
941
1395
|
*/
|
|
942
1396
|
var JsTokenUpdater = class {
|
|
943
1397
|
constructor({ value } = {}) {
|
|
1398
|
+
_defineProperty(this, "tokens", void 0);
|
|
944
1399
|
this.tokens = value ? [...value] : [];
|
|
945
1400
|
}
|
|
946
1401
|
addToken(token) {
|
|
@@ -974,7 +1429,7 @@ var JsTokenUpdater = class {
|
|
|
974
1429
|
var IgnoredExportsTracker = class {
|
|
975
1430
|
constructor(options) {
|
|
976
1431
|
this.options = options;
|
|
977
|
-
this
|
|
1432
|
+
_defineProperty(this, "ignoredExportNames", /* @__PURE__ */ new Map());
|
|
978
1433
|
}
|
|
979
1434
|
addIgnoredExport(filename, exportName) {
|
|
980
1435
|
if (!exportName) return;
|
|
@@ -1093,8 +1548,16 @@ var IgnoredExportsTracker = class {
|
|
|
1093
1548
|
//#region src/js/ModuleGraph.ts
|
|
1094
1549
|
var JsModuleGraph = class {
|
|
1095
1550
|
constructor(entry, graphOptions) {
|
|
1096
|
-
this
|
|
1097
|
-
this
|
|
1551
|
+
_defineProperty(this, "modules", /* @__PURE__ */ new Map());
|
|
1552
|
+
_defineProperty(this, "queue", []);
|
|
1553
|
+
_defineProperty(this, "resolve", void 0);
|
|
1554
|
+
_defineProperty(this, "load", void 0);
|
|
1555
|
+
_defineProperty(this, "filter", void 0);
|
|
1556
|
+
_defineProperty(this, "maxDepth", void 0);
|
|
1557
|
+
_defineProperty(this, "baseOptions", void 0);
|
|
1558
|
+
_defineProperty(this, "parserOptions", void 0);
|
|
1559
|
+
_defineProperty(this, "rootFilename", void 0);
|
|
1560
|
+
_defineProperty(this, "ignoredExports", void 0);
|
|
1098
1561
|
this.resolve = graphOptions.resolve;
|
|
1099
1562
|
this.load = graphOptions.load;
|
|
1100
1563
|
this.filter = graphOptions.filter;
|
|
@@ -1266,6 +1729,12 @@ const NEVER_MATCH_NAME = () => false;
|
|
|
1266
1729
|
*/
|
|
1267
1730
|
var NodePathWalker = class {
|
|
1268
1731
|
constructor({ ignoreCallExpressionIdentifiers, callback } = {}) {
|
|
1732
|
+
_defineProperty(this, "ignoreCallExpressionIdentifiers", void 0);
|
|
1733
|
+
_defineProperty(this, "callback", void 0);
|
|
1734
|
+
_defineProperty(this, "isIgnoredCallIdentifier", void 0);
|
|
1735
|
+
_defineProperty(this, "hasIgnoredCallIdentifiers", void 0);
|
|
1736
|
+
_defineProperty(this, "importsStore", void 0);
|
|
1737
|
+
_defineProperty(this, "visitedStore", void 0);
|
|
1269
1738
|
this.hasIgnoredCallIdentifiers = Boolean(ignoreCallExpressionIdentifiers && ignoreCallExpressionIdentifiers.length > 0);
|
|
1270
1739
|
this.ignoreCallExpressionIdentifiers = ignoreCallExpressionIdentifiers ?? EMPTY_IGNORE_CALL_EXPRESSION_IDENTIFIERS;
|
|
1271
1740
|
this.callback = callback ?? NOOP_STRING_PATH_CALLBACK;
|
|
@@ -1528,7 +1997,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1528
1997
|
const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
|
|
1529
1998
|
const ignoredPaths = needScope ? /* @__PURE__ */ new WeakSet() : EMPTY_IGNORED_PATHS;
|
|
1530
1999
|
const walker = needScope ? new NodePathWalker({
|
|
1531
|
-
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
2000
|
+
...options.ignoreCallExpressionIdentifiers === void 0 ? {} : { ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers },
|
|
1532
2001
|
callback(path) {
|
|
1533
2002
|
ignoredPaths.add(path);
|
|
1534
2003
|
}
|
|
@@ -1538,7 +2007,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1538
2007
|
function getTaggedTemplateIgnore() {
|
|
1539
2008
|
if (!taggedTemplateIgnore) taggedTemplateIgnore = createTaggedTemplateIgnore({
|
|
1540
2009
|
matcher: getIgnoredTaggedTemplateMatcher(options),
|
|
1541
|
-
names: options.ignoreTaggedTemplateExpressionIdentifiers
|
|
2010
|
+
...options.ignoreTaggedTemplateExpressionIdentifiers === void 0 ? {} : { names: options.ignoreTaggedTemplateExpressionIdentifiers }
|
|
1542
2011
|
});
|
|
1543
2012
|
return taggedTemplateIgnore;
|
|
1544
2013
|
}
|
|
@@ -1627,9 +2096,8 @@ function jsHandler(rawSource, options) {
|
|
|
1627
2096
|
if (shouldWrapExpression) {
|
|
1628
2097
|
const start = 0;
|
|
1629
2098
|
const end = source.length;
|
|
1630
|
-
const prefixLength = 2;
|
|
1631
2099
|
const suffixLength = 2;
|
|
1632
|
-
ms.remove(start,
|
|
2100
|
+
ms.remove(start, 2);
|
|
1633
2101
|
ms.remove(end - suffixLength, end);
|
|
1634
2102
|
}
|
|
1635
2103
|
const result = { code: ms.toString() };
|
|
@@ -1673,6 +2141,13 @@ function isWhitespace(char) {
|
|
|
1673
2141
|
//#region src/wxml/Tokenizer.ts
|
|
1674
2142
|
var Tokenizer = class {
|
|
1675
2143
|
constructor() {
|
|
2144
|
+
_defineProperty(this, "state", void 0);
|
|
2145
|
+
_defineProperty(this, "buffer", void 0);
|
|
2146
|
+
_defineProperty(this, "tokens", void 0);
|
|
2147
|
+
_defineProperty(this, "bufferStartIndex", void 0);
|
|
2148
|
+
_defineProperty(this, "expressionStartIndex", void 0);
|
|
2149
|
+
_defineProperty(this, "expressionBuffer", void 0);
|
|
2150
|
+
_defineProperty(this, "expressions", void 0);
|
|
1676
2151
|
this.reset();
|
|
1677
2152
|
}
|
|
1678
2153
|
processChar(char, index) {
|
|
@@ -1763,6 +2238,7 @@ var Tokenizer = class {
|
|
|
1763
2238
|
this.reset();
|
|
1764
2239
|
for (let i = 0; i < input.length; i++) {
|
|
1765
2240
|
const char = input[i];
|
|
2241
|
+
if (char === void 0) continue;
|
|
1766
2242
|
this.processChar(char, i);
|
|
1767
2243
|
}
|
|
1768
2244
|
if (this.buffer.length > 0) this.tokens.push({
|
|
@@ -1787,35 +2263,8 @@ var Tokenizer = class {
|
|
|
1787
2263
|
};
|
|
1788
2264
|
new Tokenizer();
|
|
1789
2265
|
//#endregion
|
|
1790
|
-
//#region src/
|
|
1791
|
-
|
|
1792
|
-
if (!patcher) return;
|
|
1793
|
-
const cacheOptions = patcher.options?.cache;
|
|
1794
|
-
if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) return;
|
|
1795
|
-
if (typeof patcher.clearCache === "function") try {
|
|
1796
|
-
await patcher.clearCache({ scope: "all" });
|
|
1797
|
-
} catch (error) {
|
|
1798
|
-
_weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
|
|
1799
|
-
}
|
|
1800
|
-
if (!options?.removeDirectory) return;
|
|
1801
|
-
const cachePaths = /* @__PURE__ */ new Map();
|
|
1802
|
-
const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
|
|
1803
|
-
if (normalizedCacheOptions?.path) cachePaths.set(normalizedCacheOptions.path, false);
|
|
1804
|
-
const privateCachePath = patcher?.cacheStore?.options?.path;
|
|
1805
|
-
if (privateCachePath) cachePaths.set(privateCachePath, false);
|
|
1806
|
-
if (options?.removeDirectory && normalizedCacheOptions?.dir) cachePaths.set(normalizedCacheOptions.dir, true);
|
|
1807
|
-
if (!cachePaths.size) return;
|
|
1808
|
-
for (const [cachePath, recursive] of cachePaths.entries()) try {
|
|
1809
|
-
await (0, node_fs_promises.rm)(cachePath, {
|
|
1810
|
-
force: true,
|
|
1811
|
-
recursive
|
|
1812
|
-
});
|
|
1813
|
-
} catch (error) {
|
|
1814
|
-
const err = error;
|
|
1815
|
-
if (err?.code === "ENOENT") continue;
|
|
1816
|
-
_weapp_tailwindcss_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
2266
|
+
//#region src/constants.ts
|
|
2267
|
+
const WEAPP_TW_REQUIRED_NODE_VERSION_RANGE = "^20.19.0 || >=22.12.0";
|
|
1819
2268
|
//#endregion
|
|
1820
2269
|
//#region src/cli/context.ts
|
|
1821
2270
|
function formatOutputPath(target, baseDir) {
|
|
@@ -1860,7 +2309,7 @@ const FRAMEWORK_DEPS = [
|
|
|
1860
2309
|
];
|
|
1861
2310
|
//#endregion
|
|
1862
2311
|
//#region src/cli/doctor.ts
|
|
1863
|
-
function tryReadJson
|
|
2312
|
+
function tryReadJson(file) {
|
|
1864
2313
|
try {
|
|
1865
2314
|
return JSON.parse((0, node_fs.readFileSync)(file, "utf8"));
|
|
1866
2315
|
} catch {
|
|
@@ -1871,11 +2320,11 @@ function findFirstExisting(cwd, files) {
|
|
|
1871
2320
|
return files.find((file) => (0, node_fs.existsSync)(node_path.default.join(cwd, file)));
|
|
1872
2321
|
}
|
|
1873
2322
|
function readProjectPackageJson(cwd) {
|
|
1874
|
-
return tryReadJson
|
|
2323
|
+
return tryReadJson(node_path.default.join(cwd, "package.json"));
|
|
1875
2324
|
}
|
|
1876
2325
|
function readDependencyVersion(cwd, packageName) {
|
|
1877
2326
|
try {
|
|
1878
|
-
return tryReadJson
|
|
2327
|
+
return tryReadJson((0, node_module.createRequire)(node_path.default.join(cwd, "package.json")).resolve(`${packageName}/package.json`))?.version;
|
|
1879
2328
|
} catch {
|
|
1880
2329
|
return;
|
|
1881
2330
|
}
|
|
@@ -2118,43 +2567,6 @@ function resolveCliCwd(value) {
|
|
|
2118
2567
|
return node_path.default.isAbsolute(raw) ? node_path.default.normalize(raw) : node_path.default.resolve(node_process.default.cwd(), raw);
|
|
2119
2568
|
}
|
|
2120
2569
|
//#endregion
|
|
2121
|
-
//#region src/tailwindcss/index.ts
|
|
2122
|
-
function getTailwindcssPackageInfo(options) {
|
|
2123
|
-
return (0, local_pkg.getPackageInfoSync)("tailwindcss", options);
|
|
2124
|
-
}
|
|
2125
|
-
//#endregion
|
|
2126
|
-
//#region src/cli/helpers/patch-cwd.ts
|
|
2127
|
-
/**
|
|
2128
|
-
* Resolve default working directory for `weapp-tw patch`.
|
|
2129
|
-
* Prefer explicit env overrides to avoid cross-package INIT_CWD pollution.
|
|
2130
|
-
*/
|
|
2131
|
-
function normalizeCandidatePath(baseDir, candidate) {
|
|
2132
|
-
if (!candidate) return;
|
|
2133
|
-
return node_path.default.isAbsolute(candidate) ? node_path.default.normalize(candidate) : node_path.default.resolve(baseDir, candidate);
|
|
2134
|
-
}
|
|
2135
|
-
function detectTailwindWorkspace(paths) {
|
|
2136
|
-
for (const candidate of paths) try {
|
|
2137
|
-
if (getTailwindcssPackageInfo({ paths: [candidate] })?.rootPath) return candidate;
|
|
2138
|
-
} catch {}
|
|
2139
|
-
}
|
|
2140
|
-
function resolvePatchDefaultCwd(currentCwd = node_process.default.cwd()) {
|
|
2141
|
-
const baseDir = node_path.default.normalize(currentCwd);
|
|
2142
|
-
const explicitCwd = normalizeCandidatePath(baseDir, node_process.default.env.WEAPP_TW_PATCH_CWD);
|
|
2143
|
-
if (explicitCwd) return explicitCwd;
|
|
2144
|
-
const workspaceRoot = findWorkspaceRoot(baseDir);
|
|
2145
|
-
const initCwd = normalizeCandidatePath(baseDir, node_process.default.env.INIT_CWD);
|
|
2146
|
-
const localPrefix = normalizeCandidatePath(baseDir, node_process.default.env.npm_config_local_prefix);
|
|
2147
|
-
const candidates = [
|
|
2148
|
-
baseDir,
|
|
2149
|
-
workspaceRoot,
|
|
2150
|
-
initCwd,
|
|
2151
|
-
localPrefix
|
|
2152
|
-
].filter(Boolean);
|
|
2153
|
-
const detected = detectTailwindWorkspace([...new Set(candidates)]);
|
|
2154
|
-
if (detected) return detected;
|
|
2155
|
-
return initCwd ?? localPrefix ?? workspaceRoot ?? baseDir;
|
|
2156
|
-
}
|
|
2157
|
-
//#endregion
|
|
2158
2570
|
//#region src/cli/helpers.ts
|
|
2159
2571
|
async function ensureDir(dir) {
|
|
2160
2572
|
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
@@ -2162,7 +2574,7 @@ async function ensureDir(dir) {
|
|
|
2162
2574
|
function handleCliError$1(error) {
|
|
2163
2575
|
if (error instanceof Error) {
|
|
2164
2576
|
_weapp_tailwindcss_logger.logger.error(error.message);
|
|
2165
|
-
if (error.stack && node_process.default.env
|
|
2577
|
+
if (error.stack && node_process.default.env["WEAPP_TW_DEBUG"] === "1") _weapp_tailwindcss_logger.logger.error(error.stack);
|
|
2166
2578
|
} else _weapp_tailwindcss_logger.logger.error(String(error));
|
|
2167
2579
|
}
|
|
2168
2580
|
function commandAction(handler) {
|
|
@@ -2176,216 +2588,15 @@ function commandAction(handler) {
|
|
|
2176
2588
|
};
|
|
2177
2589
|
}
|
|
2178
2590
|
//#endregion
|
|
2179
|
-
//#region src/cli/mount-options/patch-status.ts
|
|
2180
|
-
function formatStatusFilesHint(files) {
|
|
2181
|
-
if (!files?.length) return "";
|
|
2182
|
-
return ` (${files.join(", ")})`;
|
|
2183
|
-
}
|
|
2184
|
-
function logPatchStatusReport(report) {
|
|
2185
|
-
const applied = report.entries.filter((entry) => entry.status === "applied");
|
|
2186
|
-
const pending = report.entries.filter((entry) => entry.status === "not-applied");
|
|
2187
|
-
const skipped = report.entries.filter((entry) => entry.status === "skipped" || entry.status === "unsupported");
|
|
2188
|
-
const packageLabel = `${report.package.name ?? "tailwindcss"}@${report.package.version ?? "unknown"}`;
|
|
2189
|
-
_weapp_tailwindcss_logger.logger.info(`Patch status for ${packageLabel} (v${report.majorVersion})`);
|
|
2190
|
-
if (applied.length) {
|
|
2191
|
-
_weapp_tailwindcss_logger.logger.success("Applied:");
|
|
2192
|
-
applied.forEach((entry) => {
|
|
2193
|
-
_weapp_tailwindcss_logger.logger.success(` - ${entry.name}${formatStatusFilesHint(entry.files)}`);
|
|
2194
|
-
});
|
|
2195
|
-
}
|
|
2196
|
-
if (pending.length) {
|
|
2197
|
-
_weapp_tailwindcss_logger.logger.warn("Needs attention:");
|
|
2198
|
-
pending.forEach((entry) => {
|
|
2199
|
-
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
2200
|
-
_weapp_tailwindcss_logger.logger.warn(` - ${entry.name}${formatStatusFilesHint(entry.files)}${details}`);
|
|
2201
|
-
});
|
|
2202
|
-
} else _weapp_tailwindcss_logger.logger.success("All applicable patches are applied.");
|
|
2203
|
-
if (skipped.length) {
|
|
2204
|
-
_weapp_tailwindcss_logger.logger.info("Skipped:");
|
|
2205
|
-
skipped.forEach((entry) => {
|
|
2206
|
-
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
2207
|
-
_weapp_tailwindcss_logger.logger.info(` - ${entry.name}${details}`);
|
|
2208
|
-
});
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
//#endregion
|
|
2212
|
-
//#region src/cli/patch-options.ts
|
|
2213
|
-
const DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = {
|
|
2214
|
-
enabled: true,
|
|
2215
|
-
units: ["rpx"],
|
|
2216
|
-
overwrite: true
|
|
2217
|
-
};
|
|
2218
|
-
function withDefaultExtendLengthUnits(options) {
|
|
2219
|
-
const normalized = options ?? {};
|
|
2220
|
-
if (normalized.apply?.extendLengthUnits == null) return {
|
|
2221
|
-
...normalized,
|
|
2222
|
-
apply: {
|
|
2223
|
-
...normalized.apply ?? {},
|
|
2224
|
-
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
2225
|
-
}
|
|
2226
|
-
};
|
|
2227
|
-
return normalized;
|
|
2228
|
-
}
|
|
2229
|
-
function buildExtendLengthUnitsOverride(options) {
|
|
2230
|
-
if (options?.apply?.extendLengthUnits == null) return { apply: {
|
|
2231
|
-
...options?.apply ?? {},
|
|
2232
|
-
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
2233
|
-
} };
|
|
2234
|
-
}
|
|
2235
|
-
//#endregion
|
|
2236
|
-
//#region src/cli/workspace/workspace-io.ts
|
|
2237
|
-
function tryReadJson(file) {
|
|
2238
|
-
try {
|
|
2239
|
-
const content = (0, node_fs.readFileSync)(file, "utf8");
|
|
2240
|
-
return JSON.parse(content);
|
|
2241
|
-
} catch {
|
|
2242
|
-
return;
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
//#endregion
|
|
2246
|
-
//#region src/cli/workspace/workspace-globs.ts
|
|
2247
|
-
function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
|
|
2248
|
-
const pkg = tryReadJson(node_path.default.join(workspaceRoot, "package.json"));
|
|
2249
|
-
if (!pkg?.workspaces) return [];
|
|
2250
|
-
if (Array.isArray(pkg.workspaces)) return pkg.workspaces.filter(Boolean);
|
|
2251
|
-
if (Array.isArray(pkg.workspaces.packages)) return pkg.workspaces.packages.filter(Boolean);
|
|
2252
|
-
return [];
|
|
2253
|
-
}
|
|
2254
|
-
function parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot) {
|
|
2255
|
-
const workspaceFile = node_path.default.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
2256
|
-
if (!(0, node_fs.existsSync)(workspaceFile)) return [];
|
|
2257
|
-
try {
|
|
2258
|
-
const parsed = (0, yaml.parse)((0, node_fs.readFileSync)(workspaceFile, "utf8"));
|
|
2259
|
-
return Array.isArray(parsed?.packages) ? parsed.packages.filter(Boolean) : [];
|
|
2260
|
-
} catch {
|
|
2261
|
-
return [];
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
//#endregion
|
|
2265
|
-
//#region src/cli/workspace/workspace-lock.ts
|
|
2266
|
-
function parseImportersFromLock(workspaceRoot) {
|
|
2267
|
-
const lockPath = node_path.default.join(workspaceRoot, "pnpm-lock.yaml");
|
|
2268
|
-
if (!(0, node_fs.existsSync)(lockPath)) return [];
|
|
2269
|
-
try {
|
|
2270
|
-
const importers = (0, yaml.parse)((0, node_fs.readFileSync)(lockPath, "utf8"))?.importers;
|
|
2271
|
-
if (!importers) return [];
|
|
2272
|
-
return Object.keys(importers).map((key) => {
|
|
2273
|
-
if (!key || key === ".") return workspaceRoot;
|
|
2274
|
-
return node_path.default.join(workspaceRoot, key);
|
|
2275
|
-
});
|
|
2276
|
-
} catch {
|
|
2277
|
-
return [];
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
//#endregion
|
|
2281
|
-
//#region src/cli/workspace/package-dirs.ts
|
|
2282
|
-
const BACKSLASH_RE$1 = /\\/g;
|
|
2283
|
-
const TRAILING_SLASH_RE = /\/+$/;
|
|
2284
|
-
async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
2285
|
-
const dirs = /* @__PURE__ */ new Set();
|
|
2286
|
-
for (const importerDir of parseImportersFromLock(workspaceRoot)) dirs.add(node_path.default.normalize(importerDir));
|
|
2287
|
-
if (!dirs.size) {
|
|
2288
|
-
let globs = parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot);
|
|
2289
|
-
if (!globs.length) globs = parseWorkspaceGlobsFromPackageJson(workspaceRoot);
|
|
2290
|
-
if (globs.length > 0) {
|
|
2291
|
-
const packageJsonFiles = await (0, fast_glob.default)(globs.map((pattern) => {
|
|
2292
|
-
const normalized = pattern.replace(BACKSLASH_RE$1, "/").replace(TRAILING_SLASH_RE, "");
|
|
2293
|
-
return normalized.endsWith("package.json") ? normalized : `${normalized}/package.json`;
|
|
2294
|
-
}), {
|
|
2295
|
-
cwd: workspaceRoot,
|
|
2296
|
-
absolute: true,
|
|
2297
|
-
onlyFiles: true,
|
|
2298
|
-
unique: true,
|
|
2299
|
-
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
2300
|
-
});
|
|
2301
|
-
for (const file of packageJsonFiles) dirs.add(node_path.default.normalize(node_path.default.dirname(file)));
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
if ((0, node_fs.existsSync)(node_path.default.join(workspaceRoot, "package.json"))) dirs.add(node_path.default.normalize(workspaceRoot));
|
|
2305
|
-
return [...dirs];
|
|
2306
|
-
}
|
|
2307
|
-
//#endregion
|
|
2308
|
-
//#region src/cli/workspace/patch-utils.ts
|
|
2309
|
-
function formatDisplayName(workspaceRoot, dir, name) {
|
|
2310
|
-
const relative = node_path.default.relative(workspaceRoot, dir) || ".";
|
|
2311
|
-
return name ? `${name} (${relative})` : relative;
|
|
2312
|
-
}
|
|
2313
|
-
function summarizeWorkspaceResults(results) {
|
|
2314
|
-
const patched = results.filter((result) => result.status === "patched").length;
|
|
2315
|
-
const skipped = results.filter((result) => result.status === "skipped").length;
|
|
2316
|
-
const failed = results.filter((result) => result.status === "failed").length;
|
|
2317
|
-
_weapp_tailwindcss_logger.logger.info("[workspace] 汇总:已补丁 %d,跳过 %d,失败 %d", patched, skipped, failed);
|
|
2318
|
-
}
|
|
2319
|
-
//#endregion
|
|
2320
|
-
//#region src/cli/workspace/patch-package.ts
|
|
2321
|
-
function createWorkspacePatcher(cwd) {
|
|
2322
|
-
return new tailwindcss_patch.TailwindcssPatcher((0, tailwindcss_patch.normalizeOptions)(withDefaultExtendLengthUnits({ projectRoot: cwd })));
|
|
2323
|
-
}
|
|
2324
|
-
async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
|
|
2325
|
-
const displayName = formatDisplayName(workspaceRoot, dir, pkgName);
|
|
2326
|
-
if (!getTailwindcssPackageInfo({ paths: [dir] })?.rootPath) {
|
|
2327
|
-
_weapp_tailwindcss_logger.logger.info("[workspace] 跳过 %s(tailwindcss 未安装)。", displayName);
|
|
2328
|
-
return {
|
|
2329
|
-
dir,
|
|
2330
|
-
name: pkgName,
|
|
2331
|
-
status: "skipped",
|
|
2332
|
-
message: "tailwindcss 未安装,已跳过。"
|
|
2333
|
-
};
|
|
2334
|
-
}
|
|
2335
|
-
try {
|
|
2336
|
-
const patcher = createWorkspacePatcher(dir);
|
|
2337
|
-
if (options.clearCache) await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
2338
|
-
const recorder = createPatchTargetRecorder(dir, patcher, {
|
|
2339
|
-
source: "cli",
|
|
2340
|
-
cwd: dir,
|
|
2341
|
-
recordTarget: options.recordTarget !== false,
|
|
2342
|
-
alwaysRecord: true
|
|
2343
|
-
});
|
|
2344
|
-
if (recorder?.message) _weapp_tailwindcss_logger.logger.info("[workspace] %s %s", displayName, recorder.message);
|
|
2345
|
-
logTailwindcssTarget("cli", patcher, dir);
|
|
2346
|
-
await patcher.patch();
|
|
2347
|
-
if (recorder?.onPatched) await recorder.onPatched();
|
|
2348
|
-
_weapp_tailwindcss_logger.logger.success("[workspace] 已补丁 %s", displayName);
|
|
2349
|
-
return {
|
|
2350
|
-
dir,
|
|
2351
|
-
name: pkgName,
|
|
2352
|
-
status: "patched",
|
|
2353
|
-
message: "已完成 patch。"
|
|
2354
|
-
};
|
|
2355
|
-
} catch (error) {
|
|
2356
|
-
const message = `${error instanceof Error ? error.message : String(error)},${`请在 ${dir} 运行 "weapp-tw patch --cwd ${dir}".`}`;
|
|
2357
|
-
_weapp_tailwindcss_logger.logger.error("[workspace] 补丁失败 %s:%s", displayName, message);
|
|
2358
|
-
return {
|
|
2359
|
-
dir,
|
|
2360
|
-
name: pkgName,
|
|
2361
|
-
status: "failed",
|
|
2362
|
-
message
|
|
2363
|
-
};
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
//#endregion
|
|
2367
|
-
//#region src/cli/workspace.ts
|
|
2368
|
-
async function patchWorkspace(options) {
|
|
2369
|
-
const cwd = options.cwd ?? node_process.default.cwd();
|
|
2370
|
-
const workspaceRoot = findWorkspaceRoot(cwd) ?? cwd;
|
|
2371
|
-
const packageDirs = await resolveWorkspacePackageDirs(workspaceRoot);
|
|
2372
|
-
if (packageDirs.length === 0) {
|
|
2373
|
-
_weapp_tailwindcss_logger.logger.warn("未在 %s 检测到 workspace 包,已跳过批量 patch。", workspaceRoot);
|
|
2374
|
-
return;
|
|
2375
|
-
}
|
|
2376
|
-
const results = [];
|
|
2377
|
-
for (const dir of packageDirs) {
|
|
2378
|
-
const pkgJson = tryReadJson(node_path.default.join(dir, "package.json"));
|
|
2379
|
-
results.push(await patchWorkspacePackage(workspaceRoot, dir, pkgJson?.name, options));
|
|
2380
|
-
}
|
|
2381
|
-
summarizeWorkspaceResults(results);
|
|
2382
|
-
}
|
|
2383
|
-
//#endregion
|
|
2384
2591
|
//#region src/cli/mount-options.ts
|
|
2592
|
+
const PATCH_COMMAND_OBSOLETE_NOTICE = "提示:weapp-tailwindcss@5 已由构建运行时接管 Tailwind CSS 处理,weapp-tw patch 已无需执行;请移除 package.json 中的 postinstall 钩子。";
|
|
2593
|
+
function logPatchCommandObsoleteNotice() {
|
|
2594
|
+
_weapp_tailwindcss_logger.logger.warn(PATCH_COMMAND_OBSOLETE_NOTICE);
|
|
2595
|
+
}
|
|
2385
2596
|
function handleCliError(error) {
|
|
2386
2597
|
if (error instanceof Error) {
|
|
2387
2598
|
_weapp_tailwindcss_logger.logger.error(error.message);
|
|
2388
|
-
if (error.stack && node_process.default.env
|
|
2599
|
+
if (error.stack && node_process.default.env["WEAPP_TW_DEBUG"] === "1") _weapp_tailwindcss_logger.logger.error(error.stack);
|
|
2389
2600
|
} else _weapp_tailwindcss_logger.logger.error(String(error));
|
|
2390
2601
|
}
|
|
2391
2602
|
function withCommandErrorHandling(handler) {
|
|
@@ -2399,92 +2610,18 @@ function withCommandErrorHandling(handler) {
|
|
|
2399
2610
|
}
|
|
2400
2611
|
});
|
|
2401
2612
|
}
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2613
|
+
const forwardedCommands = [
|
|
2614
|
+
"extract",
|
|
2615
|
+
"tokens",
|
|
2616
|
+
"init",
|
|
2617
|
+
"migrate",
|
|
2618
|
+
"restore",
|
|
2619
|
+
"validate"
|
|
2620
|
+
];
|
|
2621
|
+
const commandHandlers = Object.fromEntries(forwardedCommands.map((command) => [command, withCommandErrorHandling(async (_ctx, next) => next())]));
|
|
2407
2622
|
const mountOptions = {
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
name: "patch",
|
|
2411
|
-
aliases: ["install"],
|
|
2412
|
-
appendDefaultOptions: false,
|
|
2413
|
-
optionDefs: [
|
|
2414
|
-
{
|
|
2415
|
-
flags: "--cwd <dir>",
|
|
2416
|
-
description: "Working directory",
|
|
2417
|
-
config: { default: resolvePatchDefaultCwd() }
|
|
2418
|
-
},
|
|
2419
|
-
{
|
|
2420
|
-
flags: "--record-target",
|
|
2421
|
-
description: "Write tailwindcss target metadata (node_modules/.cache/weapp-tailwindcss/tailwindcss-target.json). Pass \"--record-target false\" to skip.",
|
|
2422
|
-
config: { default: true }
|
|
2423
|
-
},
|
|
2424
|
-
{
|
|
2425
|
-
flags: "--clear-cache",
|
|
2426
|
-
description: "Clear tailwindcss-patch cache before patch (opt-in)"
|
|
2427
|
-
},
|
|
2428
|
-
{
|
|
2429
|
-
flags: "--workspace",
|
|
2430
|
-
description: "Scan pnpm workspace packages and patch each Tailwind CSS dependency"
|
|
2431
|
-
}
|
|
2432
|
-
]
|
|
2433
|
-
},
|
|
2434
|
-
status: {
|
|
2435
|
-
appendDefaultOptions: false,
|
|
2436
|
-
optionDefs: [{
|
|
2437
|
-
flags: "--cwd <dir>",
|
|
2438
|
-
description: "Working directory",
|
|
2439
|
-
config: { default: resolvePatchDefaultCwd() }
|
|
2440
|
-
}, {
|
|
2441
|
-
flags: "--json",
|
|
2442
|
-
description: "Print a JSON report of patch status"
|
|
2443
|
-
}]
|
|
2444
|
-
}
|
|
2445
|
-
},
|
|
2446
|
-
commandHandlers: {
|
|
2447
|
-
install: withCommandErrorHandling(async (ctx) => {
|
|
2448
|
-
const shouldClearCache = toBoolean(ctx.args.clearCache, false);
|
|
2449
|
-
const shouldRecordTarget = toBoolean(ctx.args.recordTarget, true);
|
|
2450
|
-
if (toBoolean(ctx.args.workspace, false)) {
|
|
2451
|
-
await patchWorkspace({
|
|
2452
|
-
cwd: ctx.cwd,
|
|
2453
|
-
clearCache: shouldClearCache,
|
|
2454
|
-
recordTarget: shouldRecordTarget
|
|
2455
|
-
});
|
|
2456
|
-
return;
|
|
2457
|
-
}
|
|
2458
|
-
const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
|
|
2459
|
-
if (shouldClearCache) await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
2460
|
-
const recorder = createPatchTargetRecorder(ctx.cwd, patcher, {
|
|
2461
|
-
source: "cli",
|
|
2462
|
-
cwd: ctx.cwd,
|
|
2463
|
-
recordTarget: shouldRecordTarget,
|
|
2464
|
-
alwaysRecord: true
|
|
2465
|
-
});
|
|
2466
|
-
if (recorder?.message) _weapp_tailwindcss_logger.logger.info(recorder.message);
|
|
2467
|
-
logTailwindcssTarget("cli", patcher, ctx.cwd);
|
|
2468
|
-
await patcher.patch();
|
|
2469
|
-
if (recorder?.onPatched) {
|
|
2470
|
-
const recordPath = await recorder.onPatched();
|
|
2471
|
-
if (recordPath) _weapp_tailwindcss_logger.logger.info(`记录 weapp-tw patch 目标 -> ${formatOutputPath(recordPath, ctx.cwd)}`);
|
|
2472
|
-
}
|
|
2473
|
-
_weapp_tailwindcss_logger.logger.success("Tailwind CSS 运行时补丁已完成。");
|
|
2474
|
-
}),
|
|
2475
|
-
extract: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
2476
|
-
tokens: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
2477
|
-
init: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
2478
|
-
status: withCommandErrorHandling(async (ctx) => {
|
|
2479
|
-
const report = await (await createPatcherWithDefaultExtendLengthUnits(ctx)).getPatchStatus();
|
|
2480
|
-
if (ctx.args.json) {
|
|
2481
|
-
_weapp_tailwindcss_logger.logger.log(JSON.stringify(report, null, 2));
|
|
2482
|
-
return report;
|
|
2483
|
-
}
|
|
2484
|
-
logPatchStatusReport(report);
|
|
2485
|
-
return report;
|
|
2486
|
-
})
|
|
2487
|
-
}
|
|
2623
|
+
commands: [...forwardedCommands],
|
|
2624
|
+
commandHandlers
|
|
2488
2625
|
};
|
|
2489
2626
|
//#endregion
|
|
2490
2627
|
//#region src/cli/vscode-entry.ts
|
|
@@ -2592,6 +2729,23 @@ const cli = (0, tailwindcss_patch.createTailwindcssPatchCli)({
|
|
|
2592
2729
|
name: "weapp-tailwindcss",
|
|
2593
2730
|
mountOptions
|
|
2594
2731
|
});
|
|
2732
|
+
cli.command("patch", "Deprecated no-op: v5 runtime handles Tailwind CSS automatically").alias("install").option("--cwd <dir>", "Ignored working directory").option("--clear-cache", "Ignored compatibility option").option("--record-target [enabled]", "Ignored compatibility option").option("--workspace", "Ignored compatibility option").action(commandAction(async (_options) => {
|
|
2733
|
+
logPatchCommandObsoleteNotice();
|
|
2734
|
+
_weapp_tailwindcss_logger.logger.success("已跳过:当前版本不需要手动执行 Tailwind CSS patch。");
|
|
2735
|
+
}));
|
|
2736
|
+
cli.command("status", "Deprecated no-op: patch status is no longer required").option("--cwd <dir>", "Ignored working directory").option("--json", "Print a JSON no-op report").action(commandAction(async (options) => {
|
|
2737
|
+
const payload = {
|
|
2738
|
+
required: false,
|
|
2739
|
+
status: "unnecessary",
|
|
2740
|
+
message: PATCH_COMMAND_OBSOLETE_NOTICE
|
|
2741
|
+
};
|
|
2742
|
+
if (toBoolean(options.json, false)) {
|
|
2743
|
+
_weapp_tailwindcss_logger.logger.log(JSON.stringify(payload, null, 2));
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
logPatchCommandObsoleteNotice();
|
|
2747
|
+
_weapp_tailwindcss_logger.logger.success("无需检查 Tailwind CSS patch 状态。");
|
|
2748
|
+
}));
|
|
2595
2749
|
cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliSense").option("--cwd <dir>", "Working directory").option("--css <file>", "Path to the CSS file that imports weapp-tailwindcss (required)").option("--output <file>", `Helper output path. Defaults to ${DEFAULT_VSCODE_ENTRY_OUTPUT}`).option("--source <pattern>", "Additional @source glob (can be repeated)").option("--force", "Overwrite the helper file when it already exists").action(commandAction(async (options) => {
|
|
2596
2750
|
const resolvedCwd = resolveCliCwd(options.cwd);
|
|
2597
2751
|
const baseDir = resolvedCwd ?? node_process.default.cwd();
|
|
@@ -2613,6 +2767,6 @@ cli.command("doctor", "Check project setup for weapp-tailwindcss").option("--cwd
|
|
|
2613
2767
|
if (hasDoctorFailure(report, toBoolean(options.strict, false))) node_process.default.exitCode = 1;
|
|
2614
2768
|
}));
|
|
2615
2769
|
cli.help();
|
|
2616
|
-
cli.version(node_process.default.env
|
|
2770
|
+
cli.version(node_process.default.env["npm_package_version"] ?? "0.0.0");
|
|
2617
2771
|
cli.parse();
|
|
2618
2772
|
//#endregion
|