weapp-tailwindcss 5.0.0-next.8 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/auto-DEHRmEAx.mjs +200 -0
- package/dist/auto-dPpsm6FB.js +238 -0
- package/dist/bundle-state-CnaJxkFY.mjs +413 -0
- package/dist/bundle-state-DgGEhk_z.js +529 -0
- package/dist/bundlers/shared/cache.d.ts +9 -7
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -3
- 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/directives.d.ts +12 -3
- package/dist/bundlers/shared/generator-css/markers.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
- package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +6 -2
- 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 +6 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +13 -1
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +10 -2
- package/dist/bundlers/vite/index.d.ts +5 -2
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -5
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
- package/dist/bundlers/vite/source-candidates.d.ts +24 -2
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -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 -8
- 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 -11
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +684 -41
- package/dist/cli.mjs +682 -40
- package/dist/context/runtime-package-replacements.d.ts +2 -0
- package/dist/context/style-options.d.ts +3 -0
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/core.js +1 -2
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +11 -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.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.js +6 -150
- package/dist/defaults.mjs +1 -143
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/options.d.ts +11 -6
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator--0-ekuVO.js +92 -0
- package/dist/generator-B76ovqsv.mjs +67 -0
- package/dist/generator.js +12 -12
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +163 -40
- package/dist/gulp.mjs +155 -32
- package/dist/incremental-runtime-class-set-CN6K_97P.js +2366 -0
- package/dist/incremental-runtime-class-set-x10M9bn_.mjs +2291 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -5
- 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/precheck.d.ts +2 -2
- package/dist/js/replacement-cache.d.ts +5 -0
- package/dist/postcss-C7BMYpEF.mjs +169 -0
- package/dist/{postcss-w48mGIhe.mjs → postcss-CR9UCaIK.mjs} +54 -114
- package/dist/postcss-CiYLsqZn.js +192 -0
- package/dist/{postcss-QIXwT40c.js → postcss-hYimKoN_.js} +60 -121
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/precheck-BrNwLG2e.mjs +4716 -0
- package/dist/precheck-DPtJjZmV.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 +27 -13
- package/dist/presets.mjs +25 -13
- 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-DN1mihlU.mjs +322 -0
- package/dist/source-candidates-DSxme_O2.js +335 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -5
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime.d.ts +9 -9
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +19 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/patcher.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +18 -5
- package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-DWtPieNE.mjs} +72 -60
- package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-glCm_d3H.js} +81 -69
- package/dist/typedoc.export.d.ts +1 -1
- package/dist/types/index.d.ts +51 -41
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/typedoc-tailwindcss-patch.d.ts +67 -0
- package/dist/types/user-defined-options/general.d.ts +25 -22
- package/dist/types/user-defined-options/important.d.ts +32 -27
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/unocss/index.d.ts +2 -0
- 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-BiShvil9.js → utils-D7Ygohep.js} +2 -2
- package/dist/{utils-Btw1iOVV.mjs → utils-DsaS975I.mjs} +1 -1
- package/dist/v3-engine-D3BMLVAN.js +3712 -0
- package/dist/v3-engine-DCxNPBVs.mjs +3417 -0
- package/dist/vite-DOprpdH-.mjs +24493 -0
- package/dist/vite-Ec0uX6kF.js +24507 -0
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5444 -22
- package/dist/weapp-tw-runtime-classset-loader.js +32 -9
- package/dist/{webpack-CNV2dx3Q.js → webpack-Ccohlg3A.js} +341 -96
- package/dist/{webpack-CT6EEENx.mjs → webpack-DFlZcqAU.mjs} +323 -79
- package/dist/webpack.d.ts +1 -3
- package/dist/webpack.js +3 -4
- package/dist/webpack.mjs +2 -2
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -4
- package/package.json +22 -20
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -4
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
- package/dist/cache-BVAiJV3J.js +0 -502
- package/dist/cache-CHs4DXui.mjs +0 -434
- package/dist/constants-BoB_6lFw.js +0 -73
- package/dist/constants-E_loJC49.mjs +0 -44
- package/dist/generator-DKkhJbOg.js +0 -1531
- package/dist/generator-UBmfduYg.mjs +0 -1432
- package/dist/generator-css-BIapP56i.mjs +0 -1323
- package/dist/generator-css-Mksw8PgB.js +0 -1362
- 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/precheck-B32p-gLI.js +0 -2736
- package/dist/precheck-B4RH6ZNN.mjs +0 -2622
- package/dist/run-tasks-B50A3pxt.js +0 -128
- package/dist/run-tasks-DdNi-hkk.mjs +0 -91
- package/dist/runtime-patch-CwN5ya72.mjs +0 -71
- package/dist/runtime-patch-D6mBo_KB.js +0 -85
- package/dist/vite-BwgRVgxH.mjs +0 -2405
- package/dist/vite-DyZuiyap.js +0 -2418
- /package/dist/{logger-Bub1jggA.mjs → logger-BNzxZbZj.mjs} +0 -0
- /package/dist/{logger-BRy6XPQ2.js → logger-TlKT3xmR.js} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import semver from "semver";
|
|
4
|
-
import { createTailwindcssPatchCli } from "tailwindcss-patch";
|
|
4
|
+
import { createTailwindcssPatchCli, splitCandidateTokens } from "tailwindcss-patch";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
7
7
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
8
8
|
import { LRUCache } from "lru-cache";
|
|
9
|
-
import "@weapp-tailwindcss/shared/node";
|
|
9
|
+
import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
|
|
10
10
|
import { MappingChars2String, escape } from "@weapp-core/escape";
|
|
11
11
|
import "@weapp-tailwindcss/shared";
|
|
12
12
|
import _createDebug from "debug";
|
|
13
13
|
import { constants, existsSync, readFileSync } from "node:fs";
|
|
14
|
-
import "
|
|
14
|
+
import "postcss";
|
|
15
|
+
import "micromatch";
|
|
16
|
+
import { createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
17
|
+
import "fast-glob";
|
|
18
|
+
import "tailwindcss-config";
|
|
15
19
|
import _babelTraverse from "@babel/traverse";
|
|
16
20
|
import { parse } from "@babel/parser";
|
|
17
|
-
import { escapeStringRegexp } from "@weapp-core/regex";
|
|
18
21
|
import MagicString from "magic-string";
|
|
19
22
|
import { jsStringEscape } from "@ast-core/escape";
|
|
20
|
-
import { splitCode } from "@weapp-tailwindcss/shared/extractors";
|
|
21
23
|
import "@babel/types";
|
|
22
|
-
|
|
24
|
+
//#region src/js/babel/cache-options.ts
|
|
25
|
+
const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
|
|
26
|
+
const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
|
|
27
|
+
//#endregion
|
|
23
28
|
//#region src/debug/index.ts
|
|
24
29
|
const _debug = _createDebug("weapp-tw");
|
|
25
30
|
function createDebug(prefix) {
|
|
@@ -35,6 +40,612 @@ function createDebug(prefix) {
|
|
|
35
40
|
});
|
|
36
41
|
return debug;
|
|
37
42
|
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/css-macro/constants.ts
|
|
45
|
+
const queryKey = "weapp-tw-platform";
|
|
46
|
+
const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
|
|
47
|
+
const WHITESPACE_RE = /\s+/g;
|
|
48
|
+
const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
|
|
49
|
+
function normalComment(text) {
|
|
50
|
+
if (typeof text === "string") {
|
|
51
|
+
const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
52
|
+
if (normalized.includes("\\")) return normalized;
|
|
53
|
+
return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
54
|
+
}
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
function ifdef(text) {
|
|
58
|
+
return {
|
|
59
|
+
start: `#ifdef ${normalComment(text)}`,
|
|
60
|
+
end: `#endif`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function ifndef(text) {
|
|
64
|
+
return {
|
|
65
|
+
start: `#ifndef ${normalComment(text)}`,
|
|
66
|
+
end: `#endif`
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
70
|
+
function matchCustomPropertyFromValue(str, cb) {
|
|
71
|
+
let index = 0;
|
|
72
|
+
QUERY_KEY_REGEX.lastIndex = 0;
|
|
73
|
+
let arr = QUERY_KEY_REGEX.exec(str);
|
|
74
|
+
while (arr !== null) {
|
|
75
|
+
cb(arr, index);
|
|
76
|
+
index++;
|
|
77
|
+
arr = QUERY_KEY_REGEX.exec(str);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function parseConditionalAtRuleParam(params) {
|
|
81
|
+
const value = params.trim();
|
|
82
|
+
const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
|
|
83
|
+
if (!quoted) return value;
|
|
84
|
+
return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/css-macro/postcss.ts
|
|
88
|
+
const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
89
|
+
const CONDITIONAL_COMMENT_SPACING = " ";
|
|
90
|
+
const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
|
|
91
|
+
const creator = () => {
|
|
92
|
+
return {
|
|
93
|
+
postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
|
|
94
|
+
prepare() {
|
|
95
|
+
function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
|
|
96
|
+
const hasPreviousNode = Boolean(atRule.prev());
|
|
97
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
98
|
+
const startComment = helper.comment({
|
|
99
|
+
raws: {
|
|
100
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
101
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
102
|
+
},
|
|
103
|
+
text: comment.start
|
|
104
|
+
});
|
|
105
|
+
const endComment = helper.comment({
|
|
106
|
+
raws: {
|
|
107
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
108
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
109
|
+
},
|
|
110
|
+
text: comment.end
|
|
111
|
+
});
|
|
112
|
+
const nextNodes = [
|
|
113
|
+
startComment,
|
|
114
|
+
...clonedNodes,
|
|
115
|
+
endComment
|
|
116
|
+
];
|
|
117
|
+
atRule.replaceWith(nextNodes);
|
|
118
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
119
|
+
startComment.raws["after"] = "\n";
|
|
120
|
+
if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
|
|
121
|
+
endComment.raws.before = "\n";
|
|
122
|
+
endComment.raws["after"] = "\n";
|
|
123
|
+
const nextNode = endComment?.next();
|
|
124
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
125
|
+
}
|
|
126
|
+
function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
|
|
127
|
+
if (atRule.parent?.type !== "rule") return false;
|
|
128
|
+
const parentRule = atRule.parent;
|
|
129
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
130
|
+
const conditionalRule = parentRule.clone();
|
|
131
|
+
conditionalRule.removeAll();
|
|
132
|
+
conditionalRule.append(...clonedNodes);
|
|
133
|
+
const startComment = helper.comment({
|
|
134
|
+
raws: {
|
|
135
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
136
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
137
|
+
},
|
|
138
|
+
text: comment.start
|
|
139
|
+
});
|
|
140
|
+
const endComment = helper.comment({
|
|
141
|
+
raws: {
|
|
142
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
143
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
144
|
+
},
|
|
145
|
+
text: comment.end
|
|
146
|
+
});
|
|
147
|
+
const nextNodes = [
|
|
148
|
+
startComment,
|
|
149
|
+
conditionalRule,
|
|
150
|
+
endComment
|
|
151
|
+
];
|
|
152
|
+
const hasPreviousNode = Boolean(parentRule.prev());
|
|
153
|
+
atRule.remove();
|
|
154
|
+
if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
|
|
155
|
+
else parentRule.after(nextNodes);
|
|
156
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
157
|
+
startComment.raws["after"] = "\n";
|
|
158
|
+
conditionalRule.raws.before = "\n";
|
|
159
|
+
endComment.raws.before = "\n";
|
|
160
|
+
endComment.raws["after"] = "\n";
|
|
161
|
+
const nextNode = endComment.next();
|
|
162
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
AtRule(atRule, helper) {
|
|
167
|
+
if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
|
|
168
|
+
const text = parseConditionalAtRuleParam(atRule.params);
|
|
169
|
+
const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
|
|
170
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
171
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (atRule.name === "media") {
|
|
175
|
+
const values = [];
|
|
176
|
+
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
177
|
+
const value = arr[1];
|
|
178
|
+
if (value) values.push(value);
|
|
179
|
+
});
|
|
180
|
+
if (values.length > 0) {
|
|
181
|
+
const isNegative = atRule.params.includes("not");
|
|
182
|
+
const text = values.join(" ");
|
|
183
|
+
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
184
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
185
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
CommentExit(comment) {
|
|
190
|
+
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
191
|
+
comment.raws.left = CONDITIONAL_COMMENT_SPACING;
|
|
192
|
+
comment.raws.right = CONDITIONAL_COMMENT_SPACING;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
creator.postcss = true;
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/tailwindcss/source-scan.ts
|
|
202
|
+
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
203
|
+
"html",
|
|
204
|
+
"wxml",
|
|
205
|
+
"axml",
|
|
206
|
+
"jxml",
|
|
207
|
+
"ksml",
|
|
208
|
+
"ttml",
|
|
209
|
+
"qml",
|
|
210
|
+
"tyml",
|
|
211
|
+
"xhsml",
|
|
212
|
+
"swan",
|
|
213
|
+
"vue",
|
|
214
|
+
"mpx",
|
|
215
|
+
"js",
|
|
216
|
+
"jsx",
|
|
217
|
+
"ts",
|
|
218
|
+
"tsx"
|
|
219
|
+
];
|
|
220
|
+
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
221
|
+
"js",
|
|
222
|
+
"jsx",
|
|
223
|
+
"mjs",
|
|
224
|
+
"cjs",
|
|
225
|
+
"ts",
|
|
226
|
+
"tsx",
|
|
227
|
+
"mts",
|
|
228
|
+
"cts",
|
|
229
|
+
"vue",
|
|
230
|
+
"uvue",
|
|
231
|
+
"nvue",
|
|
232
|
+
"svelte",
|
|
233
|
+
"mpx",
|
|
234
|
+
"html",
|
|
235
|
+
"wxml",
|
|
236
|
+
"axml",
|
|
237
|
+
"jxml",
|
|
238
|
+
"ksml",
|
|
239
|
+
"ttml",
|
|
240
|
+
"qml",
|
|
241
|
+
"tyml",
|
|
242
|
+
"xhsml",
|
|
243
|
+
"swan",
|
|
244
|
+
"css",
|
|
245
|
+
"wxss",
|
|
246
|
+
"acss",
|
|
247
|
+
"jxss",
|
|
248
|
+
"ttss",
|
|
249
|
+
"qss",
|
|
250
|
+
"tyss",
|
|
251
|
+
"scss",
|
|
252
|
+
"sass",
|
|
253
|
+
"less",
|
|
254
|
+
"styl",
|
|
255
|
+
"stylus"
|
|
256
|
+
];
|
|
257
|
+
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
258
|
+
return `**/*.{${extensions.join(",")}}`;
|
|
259
|
+
}
|
|
260
|
+
createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
261
|
+
new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/utils/object.ts
|
|
264
|
+
function definedEntries(value) {
|
|
265
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
266
|
+
}
|
|
267
|
+
function omitUndefined(value) {
|
|
268
|
+
return Object.fromEntries(definedEntries(value));
|
|
269
|
+
}
|
|
270
|
+
createStyleHandler({
|
|
271
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
272
|
+
cssRemoveHoverPseudoClass: true,
|
|
273
|
+
isMainChunk: true,
|
|
274
|
+
majorVersion: 4
|
|
275
|
+
});
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
278
|
+
const TAILWIND_V3_COLOR_STEPS = [
|
|
279
|
+
"50",
|
|
280
|
+
"100",
|
|
281
|
+
"200",
|
|
282
|
+
"300",
|
|
283
|
+
"400",
|
|
284
|
+
"500",
|
|
285
|
+
"600",
|
|
286
|
+
"700",
|
|
287
|
+
"800",
|
|
288
|
+
"900",
|
|
289
|
+
"950"
|
|
290
|
+
];
|
|
291
|
+
const TAILWIND_V3_COLOR_PALETTE = {
|
|
292
|
+
slate: [
|
|
293
|
+
"#f8fafc",
|
|
294
|
+
"#f1f5f9",
|
|
295
|
+
"#e2e8f0",
|
|
296
|
+
"#cbd5e1",
|
|
297
|
+
"#94a3b8",
|
|
298
|
+
"#64748b",
|
|
299
|
+
"#475569",
|
|
300
|
+
"#334155",
|
|
301
|
+
"#1e293b",
|
|
302
|
+
"#0f172a",
|
|
303
|
+
"#020617"
|
|
304
|
+
],
|
|
305
|
+
gray: [
|
|
306
|
+
"#f9fafb",
|
|
307
|
+
"#f3f4f6",
|
|
308
|
+
"#e5e7eb",
|
|
309
|
+
"#d1d5db",
|
|
310
|
+
"#9ca3af",
|
|
311
|
+
"#6b7280",
|
|
312
|
+
"#4b5563",
|
|
313
|
+
"#374151",
|
|
314
|
+
"#1f2937",
|
|
315
|
+
"#111827",
|
|
316
|
+
"#030712"
|
|
317
|
+
],
|
|
318
|
+
zinc: [
|
|
319
|
+
"#fafafa",
|
|
320
|
+
"#f4f4f5",
|
|
321
|
+
"#e4e4e7",
|
|
322
|
+
"#d4d4d8",
|
|
323
|
+
"#a1a1aa",
|
|
324
|
+
"#71717a",
|
|
325
|
+
"#52525b",
|
|
326
|
+
"#3f3f46",
|
|
327
|
+
"#27272a",
|
|
328
|
+
"#18181b",
|
|
329
|
+
"#09090b"
|
|
330
|
+
],
|
|
331
|
+
neutral: [
|
|
332
|
+
"#fafafa",
|
|
333
|
+
"#f5f5f5",
|
|
334
|
+
"#e5e5e5",
|
|
335
|
+
"#d4d4d4",
|
|
336
|
+
"#a3a3a3",
|
|
337
|
+
"#737373",
|
|
338
|
+
"#525252",
|
|
339
|
+
"#404040",
|
|
340
|
+
"#262626",
|
|
341
|
+
"#171717",
|
|
342
|
+
"#0a0a0a"
|
|
343
|
+
],
|
|
344
|
+
stone: [
|
|
345
|
+
"#fafaf9",
|
|
346
|
+
"#f5f5f4",
|
|
347
|
+
"#e7e5e4",
|
|
348
|
+
"#d6d3d1",
|
|
349
|
+
"#a8a29e",
|
|
350
|
+
"#78716c",
|
|
351
|
+
"#57534e",
|
|
352
|
+
"#44403c",
|
|
353
|
+
"#292524",
|
|
354
|
+
"#1c1917",
|
|
355
|
+
"#0c0a09"
|
|
356
|
+
],
|
|
357
|
+
red: [
|
|
358
|
+
"#fef2f2",
|
|
359
|
+
"#fee2e2",
|
|
360
|
+
"#fecaca",
|
|
361
|
+
"#fca5a5",
|
|
362
|
+
"#f87171",
|
|
363
|
+
"#ef4444",
|
|
364
|
+
"#dc2626",
|
|
365
|
+
"#b91c1c",
|
|
366
|
+
"#991b1b",
|
|
367
|
+
"#7f1d1d",
|
|
368
|
+
"#450a0a"
|
|
369
|
+
],
|
|
370
|
+
orange: [
|
|
371
|
+
"#fff7ed",
|
|
372
|
+
"#ffedd5",
|
|
373
|
+
"#fed7aa",
|
|
374
|
+
"#fdba74",
|
|
375
|
+
"#fb923c",
|
|
376
|
+
"#f97316",
|
|
377
|
+
"#ea580c",
|
|
378
|
+
"#c2410c",
|
|
379
|
+
"#9a3412",
|
|
380
|
+
"#7c2d12",
|
|
381
|
+
"#431407"
|
|
382
|
+
],
|
|
383
|
+
amber: [
|
|
384
|
+
"#fffbeb",
|
|
385
|
+
"#fef3c7",
|
|
386
|
+
"#fde68a",
|
|
387
|
+
"#fcd34d",
|
|
388
|
+
"#fbbf24",
|
|
389
|
+
"#f59e0b",
|
|
390
|
+
"#d97706",
|
|
391
|
+
"#b45309",
|
|
392
|
+
"#92400e",
|
|
393
|
+
"#78350f",
|
|
394
|
+
"#451a03"
|
|
395
|
+
],
|
|
396
|
+
yellow: [
|
|
397
|
+
"#fefce8",
|
|
398
|
+
"#fef9c3",
|
|
399
|
+
"#fef08a",
|
|
400
|
+
"#fde047",
|
|
401
|
+
"#facc15",
|
|
402
|
+
"#eab308",
|
|
403
|
+
"#ca8a04",
|
|
404
|
+
"#a16207",
|
|
405
|
+
"#854d0e",
|
|
406
|
+
"#713f12",
|
|
407
|
+
"#422006"
|
|
408
|
+
],
|
|
409
|
+
lime: [
|
|
410
|
+
"#f7fee7",
|
|
411
|
+
"#ecfccb",
|
|
412
|
+
"#d9f99d",
|
|
413
|
+
"#bef264",
|
|
414
|
+
"#a3e635",
|
|
415
|
+
"#84cc16",
|
|
416
|
+
"#65a30d",
|
|
417
|
+
"#4d7c0f",
|
|
418
|
+
"#3f6212",
|
|
419
|
+
"#365314",
|
|
420
|
+
"#1a2e05"
|
|
421
|
+
],
|
|
422
|
+
green: [
|
|
423
|
+
"#f0fdf4",
|
|
424
|
+
"#dcfce7",
|
|
425
|
+
"#bbf7d0",
|
|
426
|
+
"#86efac",
|
|
427
|
+
"#4ade80",
|
|
428
|
+
"#22c55e",
|
|
429
|
+
"#16a34a",
|
|
430
|
+
"#15803d",
|
|
431
|
+
"#166534",
|
|
432
|
+
"#14532d",
|
|
433
|
+
"#052e16"
|
|
434
|
+
],
|
|
435
|
+
emerald: [
|
|
436
|
+
"#ecfdf5",
|
|
437
|
+
"#d1fae5",
|
|
438
|
+
"#a7f3d0",
|
|
439
|
+
"#6ee7b7",
|
|
440
|
+
"#34d399",
|
|
441
|
+
"#10b981",
|
|
442
|
+
"#059669",
|
|
443
|
+
"#047857",
|
|
444
|
+
"#065f46",
|
|
445
|
+
"#064e3b",
|
|
446
|
+
"#022c22"
|
|
447
|
+
],
|
|
448
|
+
teal: [
|
|
449
|
+
"#f0fdfa",
|
|
450
|
+
"#ccfbf1",
|
|
451
|
+
"#99f6e4",
|
|
452
|
+
"#5eead4",
|
|
453
|
+
"#2dd4bf",
|
|
454
|
+
"#14b8a6",
|
|
455
|
+
"#0d9488",
|
|
456
|
+
"#0f766e",
|
|
457
|
+
"#115e59",
|
|
458
|
+
"#134e4a",
|
|
459
|
+
"#042f2e"
|
|
460
|
+
],
|
|
461
|
+
cyan: [
|
|
462
|
+
"#ecfeff",
|
|
463
|
+
"#cffafe",
|
|
464
|
+
"#a5f3fc",
|
|
465
|
+
"#67e8f9",
|
|
466
|
+
"#22d3ee",
|
|
467
|
+
"#06b6d4",
|
|
468
|
+
"#0891b2",
|
|
469
|
+
"#0e7490",
|
|
470
|
+
"#155e75",
|
|
471
|
+
"#164e63",
|
|
472
|
+
"#083344"
|
|
473
|
+
],
|
|
474
|
+
sky: [
|
|
475
|
+
"#f0f9ff",
|
|
476
|
+
"#e0f2fe",
|
|
477
|
+
"#bae6fd",
|
|
478
|
+
"#7dd3fc",
|
|
479
|
+
"#38bdf8",
|
|
480
|
+
"#0ea5e9",
|
|
481
|
+
"#0284c7",
|
|
482
|
+
"#0369a1",
|
|
483
|
+
"#075985",
|
|
484
|
+
"#0c4a6e",
|
|
485
|
+
"#082f49"
|
|
486
|
+
],
|
|
487
|
+
blue: [
|
|
488
|
+
"#eff6ff",
|
|
489
|
+
"#dbeafe",
|
|
490
|
+
"#bfdbfe",
|
|
491
|
+
"#93c5fd",
|
|
492
|
+
"#60a5fa",
|
|
493
|
+
"#3b82f6",
|
|
494
|
+
"#2563eb",
|
|
495
|
+
"#1d4ed8",
|
|
496
|
+
"#1e40af",
|
|
497
|
+
"#1e3a8a",
|
|
498
|
+
"#172554"
|
|
499
|
+
],
|
|
500
|
+
indigo: [
|
|
501
|
+
"#eef2ff",
|
|
502
|
+
"#e0e7ff",
|
|
503
|
+
"#c7d2fe",
|
|
504
|
+
"#a5b4fc",
|
|
505
|
+
"#818cf8",
|
|
506
|
+
"#6366f1",
|
|
507
|
+
"#4f46e5",
|
|
508
|
+
"#4338ca",
|
|
509
|
+
"#3730a3",
|
|
510
|
+
"#312e81",
|
|
511
|
+
"#1e1b4b"
|
|
512
|
+
],
|
|
513
|
+
violet: [
|
|
514
|
+
"#f5f3ff",
|
|
515
|
+
"#ede9fe",
|
|
516
|
+
"#ddd6fe",
|
|
517
|
+
"#c4b5fd",
|
|
518
|
+
"#a78bfa",
|
|
519
|
+
"#8b5cf6",
|
|
520
|
+
"#7c3aed",
|
|
521
|
+
"#6d28d9",
|
|
522
|
+
"#5b21b6",
|
|
523
|
+
"#4c1d95",
|
|
524
|
+
"#2e1065"
|
|
525
|
+
],
|
|
526
|
+
purple: [
|
|
527
|
+
"#faf5ff",
|
|
528
|
+
"#f3e8ff",
|
|
529
|
+
"#e9d5ff",
|
|
530
|
+
"#d8b4fe",
|
|
531
|
+
"#c084fc",
|
|
532
|
+
"#a855f7",
|
|
533
|
+
"#9333ea",
|
|
534
|
+
"#7e22ce",
|
|
535
|
+
"#6b21a8",
|
|
536
|
+
"#581c87",
|
|
537
|
+
"#3b0764"
|
|
538
|
+
],
|
|
539
|
+
fuchsia: [
|
|
540
|
+
"#fdf4ff",
|
|
541
|
+
"#fae8ff",
|
|
542
|
+
"#f5d0fe",
|
|
543
|
+
"#f0abfc",
|
|
544
|
+
"#e879f9",
|
|
545
|
+
"#d946ef",
|
|
546
|
+
"#c026d3",
|
|
547
|
+
"#a21caf",
|
|
548
|
+
"#86198f",
|
|
549
|
+
"#701a75",
|
|
550
|
+
"#4a044e"
|
|
551
|
+
],
|
|
552
|
+
pink: [
|
|
553
|
+
"#fdf2f8",
|
|
554
|
+
"#fce7f3",
|
|
555
|
+
"#fbcfe8",
|
|
556
|
+
"#f9a8d4",
|
|
557
|
+
"#f472b6",
|
|
558
|
+
"#ec4899",
|
|
559
|
+
"#db2777",
|
|
560
|
+
"#be185d",
|
|
561
|
+
"#9d174d",
|
|
562
|
+
"#831843",
|
|
563
|
+
"#500724"
|
|
564
|
+
],
|
|
565
|
+
rose: [
|
|
566
|
+
"#fff1f2",
|
|
567
|
+
"#ffe4e6",
|
|
568
|
+
"#fecdd3",
|
|
569
|
+
"#fda4af",
|
|
570
|
+
"#fb7185",
|
|
571
|
+
"#f43f5e",
|
|
572
|
+
"#e11d48",
|
|
573
|
+
"#be123c",
|
|
574
|
+
"#9f1239",
|
|
575
|
+
"#881337",
|
|
576
|
+
"#4c0519"
|
|
577
|
+
]
|
|
578
|
+
};
|
|
579
|
+
function createTailwindV3DefaultColorThemeCss() {
|
|
580
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
581
|
+
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]};`);
|
|
582
|
+
return [
|
|
583
|
+
"@theme {",
|
|
584
|
+
...declarations,
|
|
585
|
+
"}"
|
|
586
|
+
].join("\n");
|
|
587
|
+
}
|
|
588
|
+
[
|
|
589
|
+
"@theme {",
|
|
590
|
+
" --default-ring-width: 3px;",
|
|
591
|
+
" --default-ring-color: var(--color-blue-500, #3b82f6);",
|
|
592
|
+
" --default-outline-width: 3px;",
|
|
593
|
+
"",
|
|
594
|
+
" --shadow-xs: 0 1px rgb(0 0 0 / 0.05);",
|
|
595
|
+
" --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);",
|
|
596
|
+
" --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);",
|
|
597
|
+
" --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);",
|
|
598
|
+
" --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);",
|
|
599
|
+
" --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);",
|
|
600
|
+
"",
|
|
601
|
+
" --blur-xs: 4px;",
|
|
602
|
+
" --blur-sm: 4px;",
|
|
603
|
+
" --blur: 8px;",
|
|
604
|
+
" --backdrop-blur-xs: 4px;",
|
|
605
|
+
" --backdrop-blur-sm: 4px;",
|
|
606
|
+
" --backdrop-blur: 8px;",
|
|
607
|
+
"",
|
|
608
|
+
" --radius-xs: 0.125rem;",
|
|
609
|
+
" --radius-sm: 0.125rem;",
|
|
610
|
+
" --radius: 0.25rem;",
|
|
611
|
+
"}",
|
|
612
|
+
createTailwindV3DefaultColorThemeCss()
|
|
613
|
+
].join("\n");
|
|
614
|
+
[
|
|
615
|
+
"*,",
|
|
616
|
+
"::after,",
|
|
617
|
+
"::before,",
|
|
618
|
+
"::backdrop,",
|
|
619
|
+
"::file-selector-button {",
|
|
620
|
+
" border-color: var(--color-gray-200, currentcolor);",
|
|
621
|
+
"}",
|
|
622
|
+
"",
|
|
623
|
+
"input::placeholder,",
|
|
624
|
+
"textarea::placeholder {",
|
|
625
|
+
" opacity: 1;",
|
|
626
|
+
" color: var(--color-gray-400, currentcolor);",
|
|
627
|
+
"}",
|
|
628
|
+
"",
|
|
629
|
+
"button:not(:disabled),",
|
|
630
|
+
"[role=\"button\"]:not(:disabled) {",
|
|
631
|
+
" cursor: pointer;",
|
|
632
|
+
"}",
|
|
633
|
+
"",
|
|
634
|
+
"dialog {",
|
|
635
|
+
" margin: auto;",
|
|
636
|
+
"}"
|
|
637
|
+
].join("\n");
|
|
638
|
+
createStyleHandler({
|
|
639
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
640
|
+
cssRemoveHoverPseudoClass: true,
|
|
641
|
+
isMainChunk: true,
|
|
642
|
+
majorVersion: 3
|
|
643
|
+
});
|
|
644
|
+
[
|
|
645
|
+
"@tailwind base;",
|
|
646
|
+
"@tailwind components;",
|
|
647
|
+
"@tailwind utilities;"
|
|
648
|
+
].join("\n");
|
|
38
649
|
createDebug("[tailwindcss:runtime-patch] ");
|
|
39
650
|
createRequire(import.meta.url);
|
|
40
651
|
createDebug("[tailwindcss:runtime] ");
|
|
@@ -47,15 +658,18 @@ runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolde
|
|
|
47
658
|
const globalCacheHolder = globalThis;
|
|
48
659
|
globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
|
|
49
660
|
//#endregion
|
|
50
|
-
//#region src/constants.ts
|
|
51
|
-
const WEAPP_TW_REQUIRED_NODE_VERSION_RANGE = "^20.19.0 || >=22.12.0";
|
|
52
|
-
//#endregion
|
|
53
661
|
//#region src/babel/index.ts
|
|
54
662
|
function _interopDefaultCompat(e) {
|
|
55
663
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
56
664
|
}
|
|
57
665
|
const traverse = _interopDefaultCompat(_babelTraverse);
|
|
58
666
|
//#endregion
|
|
667
|
+
//#region src/utils/regex.ts
|
|
668
|
+
function escapeStringRegexp(str) {
|
|
669
|
+
if (typeof str !== "string") throw new TypeError("Expected a string");
|
|
670
|
+
return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
|
|
671
|
+
}
|
|
672
|
+
//#endregion
|
|
59
673
|
//#region src/utils/nameMatcher.ts
|
|
60
674
|
const NEVER_MATCH_NAME$1 = () => false;
|
|
61
675
|
const GLOBAL_FLAG_REGEXP = /g/g;
|
|
@@ -63,6 +677,7 @@ function buildFuzzyMatcher(fuzzyStrings) {
|
|
|
63
677
|
if (fuzzyStrings.length === 0) return;
|
|
64
678
|
if (fuzzyStrings.length === 1) {
|
|
65
679
|
const [needle] = fuzzyStrings;
|
|
680
|
+
if (needle === void 0) return;
|
|
66
681
|
return (value) => value.includes(needle);
|
|
67
682
|
}
|
|
68
683
|
const unique = [...new Set(fuzzyStrings)];
|
|
@@ -86,11 +701,13 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
86
701
|
const exactStringCount = exactStrings?.size ?? 0;
|
|
87
702
|
if (exactStringCount === 1 && regexList.length === 0) {
|
|
88
703
|
const [needle] = exactStrings;
|
|
704
|
+
if (needle === void 0) return NEVER_MATCH_NAME$1;
|
|
89
705
|
return (value) => value === needle;
|
|
90
706
|
}
|
|
91
707
|
if (regexList.length === 0) return (value) => exactStrings.has(value);
|
|
92
708
|
if (exactStringCount === 0 && regexList.length === 1) {
|
|
93
709
|
const [regex] = regexList;
|
|
710
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
94
711
|
return (value) => regex.test(value);
|
|
95
712
|
}
|
|
96
713
|
return (value) => {
|
|
@@ -103,6 +720,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
103
720
|
if (fuzzyMatcher && !hasRegex) return fuzzyMatcher;
|
|
104
721
|
if (!fuzzyMatcher && regexList.length === 1) {
|
|
105
722
|
const [regex] = regexList;
|
|
723
|
+
if (!regex) return NEVER_MATCH_NAME$1;
|
|
106
724
|
return (value) => regex.test(value);
|
|
107
725
|
}
|
|
108
726
|
return (value) => {
|
|
@@ -113,20 +731,40 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
113
731
|
}
|
|
114
732
|
//#endregion
|
|
115
733
|
//#region src/js/babel/parse.ts
|
|
116
|
-
const parseCache = new LRUCache({ max:
|
|
734
|
+
const parseCache = new LRUCache({ max: HARD_PARSE_CACHE_MAX_ENTRIES });
|
|
117
735
|
function genCacheKey(source, options) {
|
|
118
|
-
if (typeof options === "string") return source
|
|
119
|
-
return source
|
|
736
|
+
if (typeof options === "string") return `${md5Hash(source)}:${options}`;
|
|
737
|
+
return `${md5Hash(source)}:${JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val)}`;
|
|
738
|
+
}
|
|
739
|
+
function normalizeCacheMaxEntries(value) {
|
|
740
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 128;
|
|
741
|
+
return Math.min(Math.max(Math.floor(value), 0), HARD_PARSE_CACHE_MAX_ENTRIES);
|
|
742
|
+
}
|
|
743
|
+
function normalizeCacheMaxSourceLength(value) {
|
|
744
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH;
|
|
745
|
+
return Math.max(Math.floor(value), 0);
|
|
746
|
+
}
|
|
747
|
+
function trimParseCache(maxEntries) {
|
|
748
|
+
while (parseCache.size > maxEntries) parseCache.pop();
|
|
120
749
|
}
|
|
121
750
|
function babelParse(code, opts = {}) {
|
|
122
|
-
const { cache, cacheKey, ...rest } = opts;
|
|
123
|
-
const
|
|
751
|
+
const { cache, cacheKey, cacheMaxEntries, cacheMaxSourceLength, ...rest } = opts;
|
|
752
|
+
const maxEntries = normalizeCacheMaxEntries(cacheMaxEntries);
|
|
753
|
+
const maxSourceLength = normalizeCacheMaxSourceLength(cacheMaxSourceLength);
|
|
754
|
+
const shouldCache = cache === true && maxEntries > 0 && code.length <= maxSourceLength;
|
|
755
|
+
const cacheKeyString = shouldCache ? genCacheKey(code, cacheKey ?? rest) : void 0;
|
|
124
756
|
let result;
|
|
125
|
-
if (
|
|
757
|
+
if (shouldCache) {
|
|
758
|
+
trimParseCache(maxEntries);
|
|
759
|
+
result = parseCache.get(cacheKeyString);
|
|
760
|
+
}
|
|
126
761
|
if (!result) {
|
|
127
|
-
const { cache: _cache, cacheKey: _cacheKey, ...parseOptions } = opts;
|
|
762
|
+
const { cache: _cache, cacheKey: _cacheKey, cacheMaxEntries: _cacheMaxEntries, cacheMaxSourceLength: _cacheMaxSourceLength, ...parseOptions } = opts;
|
|
128
763
|
result = parse(code, parseOptions);
|
|
129
|
-
if (
|
|
764
|
+
if (shouldCache) {
|
|
765
|
+
parseCache.set(cacheKeyString, result);
|
|
766
|
+
trimParseCache(maxEntries);
|
|
767
|
+
}
|
|
130
768
|
}
|
|
131
769
|
return result;
|
|
132
770
|
}
|
|
@@ -140,10 +778,10 @@ function replaceWxml(original, options = {
|
|
|
140
778
|
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
141
779
|
let res = original;
|
|
142
780
|
if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
|
|
143
|
-
res = escape(res, {
|
|
781
|
+
res = escape(res, omitUndefined({
|
|
144
782
|
map: escapeMap,
|
|
145
783
|
ignoreHead
|
|
146
|
-
});
|
|
784
|
+
}));
|
|
147
785
|
return res;
|
|
148
786
|
}
|
|
149
787
|
//#endregion
|
|
@@ -339,12 +977,9 @@ function isClassContextLiteralPath(path) {
|
|
|
339
977
|
return false;
|
|
340
978
|
}
|
|
341
979
|
//#endregion
|
|
342
|
-
//#region src/js/
|
|
343
|
-
const debug = createDebug("[js:handlers] ");
|
|
980
|
+
//#region src/js/replacement-cache.ts
|
|
344
981
|
const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
|
|
345
982
|
const defaultReplacementCache = /* @__PURE__ */ new Map();
|
|
346
|
-
const WEAPP_TW_IGNORE_MARKER = "weapp-tw";
|
|
347
|
-
const IGNORE_MARKER = "ignore";
|
|
348
983
|
function getReplacementCacheStore(escapeMap) {
|
|
349
984
|
if (!escapeMap) return defaultReplacementCache;
|
|
350
985
|
let store = replacementCacheByEscapeMap.get(escapeMap);
|
|
@@ -362,6 +997,11 @@ function getReplacement(candidate, escapeMap, store = getReplacementCacheStore(e
|
|
|
362
997
|
}
|
|
363
998
|
return cached;
|
|
364
999
|
}
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/js/handlers.ts
|
|
1002
|
+
const debug = createDebug("[js:handlers] ");
|
|
1003
|
+
const WEAPP_TW_IGNORE_MARKER = "weapp-tw";
|
|
1004
|
+
const IGNORE_MARKER = "ignore";
|
|
365
1005
|
function hasIgnoreComment(node) {
|
|
366
1006
|
const { leadingComments } = node;
|
|
367
1007
|
if (!Array.isArray(leadingComments) || leadingComments.length === 0) return false;
|
|
@@ -371,8 +1011,7 @@ function hasIgnoreComment(node) {
|
|
|
371
1011
|
}
|
|
372
1012
|
return false;
|
|
373
1013
|
}
|
|
374
|
-
function extractLiteralValue(path, { unescapeUnicode
|
|
375
|
-
const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
|
|
1014
|
+
function extractLiteralValue(path, { unescapeUnicode }) {
|
|
376
1015
|
const { node } = path;
|
|
377
1016
|
let offset = 0;
|
|
378
1017
|
let original;
|
|
@@ -384,7 +1023,6 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
384
1023
|
let literal = original;
|
|
385
1024
|
if (unescapeUnicode && original.includes("\\u")) literal = decodeUnicode2(original);
|
|
386
1025
|
return {
|
|
387
|
-
allowDoubleQuotes,
|
|
388
1026
|
literal,
|
|
389
1027
|
offset,
|
|
390
1028
|
original
|
|
@@ -438,8 +1076,8 @@ function replaceHandleValue(path, options) {
|
|
|
438
1076
|
const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
|
|
439
1077
|
if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
|
|
440
1078
|
if (hasIgnoreComment(path.node)) return;
|
|
441
|
-
const { literal, original,
|
|
442
|
-
const candidates =
|
|
1079
|
+
const { literal, original, offset } = extractLiteralValue(path, options);
|
|
1080
|
+
const candidates = splitCandidateTokens(literal);
|
|
443
1081
|
if (candidates.length === 0) return;
|
|
444
1082
|
const debugEnabled = debug.enabled;
|
|
445
1083
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
|
@@ -681,7 +1319,7 @@ function walkEvalExpression(path, options, updater, handler) {
|
|
|
681
1319
|
}
|
|
682
1320
|
}
|
|
683
1321
|
//#endregion
|
|
684
|
-
//#region \0@oxc-project+runtime@0.
|
|
1322
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
685
1323
|
function _typeof(o) {
|
|
686
1324
|
"@babel/helpers - typeof";
|
|
687
1325
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -691,7 +1329,7 @@ function _typeof(o) {
|
|
|
691
1329
|
}, _typeof(o);
|
|
692
1330
|
}
|
|
693
1331
|
//#endregion
|
|
694
|
-
//#region \0@oxc-project+runtime@0.
|
|
1332
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
695
1333
|
function toPrimitive(t, r) {
|
|
696
1334
|
if ("object" != _typeof(t) || !t) return t;
|
|
697
1335
|
var e = t[Symbol.toPrimitive];
|
|
@@ -703,13 +1341,13 @@ function toPrimitive(t, r) {
|
|
|
703
1341
|
return ("string" === r ? String : Number)(t);
|
|
704
1342
|
}
|
|
705
1343
|
//#endregion
|
|
706
|
-
//#region \0@oxc-project+runtime@0.
|
|
1344
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
707
1345
|
function toPropertyKey(t) {
|
|
708
1346
|
var i = toPrimitive(t, "string");
|
|
709
1347
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
710
1348
|
}
|
|
711
1349
|
//#endregion
|
|
712
|
-
//#region \0@oxc-project+runtime@0.
|
|
1350
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
713
1351
|
function _defineProperty(e, r, t) {
|
|
714
1352
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
715
1353
|
value: t,
|
|
@@ -1329,7 +1967,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1329
1967
|
const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
|
|
1330
1968
|
const ignoredPaths = needScope ? /* @__PURE__ */ new WeakSet() : EMPTY_IGNORED_PATHS;
|
|
1331
1969
|
const walker = needScope ? new NodePathWalker({
|
|
1332
|
-
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
1970
|
+
...options.ignoreCallExpressionIdentifiers === void 0 ? {} : { ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers },
|
|
1333
1971
|
callback(path) {
|
|
1334
1972
|
ignoredPaths.add(path);
|
|
1335
1973
|
}
|
|
@@ -1339,7 +1977,7 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
1339
1977
|
function getTaggedTemplateIgnore() {
|
|
1340
1978
|
if (!taggedTemplateIgnore) taggedTemplateIgnore = createTaggedTemplateIgnore({
|
|
1341
1979
|
matcher: getIgnoredTaggedTemplateMatcher(options),
|
|
1342
|
-
names: options.ignoreTaggedTemplateExpressionIdentifiers
|
|
1980
|
+
...options.ignoreTaggedTemplateExpressionIdentifiers === void 0 ? {} : { names: options.ignoreTaggedTemplateExpressionIdentifiers }
|
|
1343
1981
|
});
|
|
1344
1982
|
return taggedTemplateIgnore;
|
|
1345
1983
|
}
|
|
@@ -1428,9 +2066,8 @@ function jsHandler(rawSource, options) {
|
|
|
1428
2066
|
if (shouldWrapExpression) {
|
|
1429
2067
|
const start = 0;
|
|
1430
2068
|
const end = source.length;
|
|
1431
|
-
const prefixLength = 2;
|
|
1432
2069
|
const suffixLength = 2;
|
|
1433
|
-
ms.remove(start,
|
|
2070
|
+
ms.remove(start, 2);
|
|
1434
2071
|
ms.remove(end - suffixLength, end);
|
|
1435
2072
|
}
|
|
1436
2073
|
const result = { code: ms.toString() };
|
|
@@ -1571,6 +2208,7 @@ var Tokenizer = class {
|
|
|
1571
2208
|
this.reset();
|
|
1572
2209
|
for (let i = 0; i < input.length; i++) {
|
|
1573
2210
|
const char = input[i];
|
|
2211
|
+
if (char === void 0) continue;
|
|
1574
2212
|
this.processChar(char, i);
|
|
1575
2213
|
}
|
|
1576
2214
|
if (this.buffer.length > 0) this.tokens.push({
|
|
@@ -1595,6 +2233,9 @@ var Tokenizer = class {
|
|
|
1595
2233
|
};
|
|
1596
2234
|
new Tokenizer();
|
|
1597
2235
|
//#endregion
|
|
2236
|
+
//#region src/constants.ts
|
|
2237
|
+
const WEAPP_TW_REQUIRED_NODE_VERSION_RANGE = "^20.19.0 || >=22.12.0";
|
|
2238
|
+
//#endregion
|
|
1598
2239
|
//#region src/cli/context.ts
|
|
1599
2240
|
function formatOutputPath(target, baseDir) {
|
|
1600
2241
|
const root = baseDir ?? process.cwd();
|
|
@@ -1903,7 +2544,7 @@ async function ensureDir(dir) {
|
|
|
1903
2544
|
function handleCliError$1(error) {
|
|
1904
2545
|
if (error instanceof Error) {
|
|
1905
2546
|
logger.error(error.message);
|
|
1906
|
-
if (error.stack && process.env
|
|
2547
|
+
if (error.stack && process.env["WEAPP_TW_DEBUG"] === "1") logger.error(error.stack);
|
|
1907
2548
|
} else logger.error(String(error));
|
|
1908
2549
|
}
|
|
1909
2550
|
function commandAction(handler) {
|
|
@@ -1925,7 +2566,7 @@ function logPatchCommandObsoleteNotice() {
|
|
|
1925
2566
|
function handleCliError(error) {
|
|
1926
2567
|
if (error instanceof Error) {
|
|
1927
2568
|
logger.error(error.message);
|
|
1928
|
-
if (error.stack && process.env
|
|
2569
|
+
if (error.stack && process.env["WEAPP_TW_DEBUG"] === "1") logger.error(error.stack);
|
|
1929
2570
|
} else logger.error(String(error));
|
|
1930
2571
|
}
|
|
1931
2572
|
function withCommandErrorHandling(handler) {
|
|
@@ -1947,9 +2588,10 @@ const forwardedCommands = [
|
|
|
1947
2588
|
"restore",
|
|
1948
2589
|
"validate"
|
|
1949
2590
|
];
|
|
2591
|
+
const commandHandlers = Object.fromEntries(forwardedCommands.map((command) => [command, withCommandErrorHandling(async (_ctx, next) => next())]));
|
|
1950
2592
|
const mountOptions = {
|
|
1951
2593
|
commands: [...forwardedCommands],
|
|
1952
|
-
commandHandlers
|
|
2594
|
+
commandHandlers
|
|
1953
2595
|
};
|
|
1954
2596
|
//#endregion
|
|
1955
2597
|
//#region src/cli/vscode-entry.ts
|
|
@@ -2095,7 +2737,7 @@ cli.command("doctor", "Check project setup for weapp-tailwindcss").option("--cwd
|
|
|
2095
2737
|
if (hasDoctorFailure(report, toBoolean(options.strict, false))) process.exitCode = 1;
|
|
2096
2738
|
}));
|
|
2097
2739
|
cli.help();
|
|
2098
|
-
cli.version(process.env
|
|
2740
|
+
cli.version(process.env["npm_package_version"] ?? "0.0.0");
|
|
2099
2741
|
cli.parse();
|
|
2100
2742
|
//#endregion
|
|
2101
2743
|
export {};
|