@weapp-vite/ast 6.16.6 → 6.16.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BABEL_TS_MODULE_PARSER_OPTIONS, parse, traverse } from "../babel.mjs";
|
|
2
2
|
import { t as parseJsLikeWithEngine } from "../engine-DHqNPCDA.mjs";
|
|
3
|
+
import { WEVU_GENERIC_SLOT_SCOPE_ATTR, WEVU_NATIVE_SLOT_SCOPE_DATA_KEY, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
|
|
3
4
|
import { getMiniProgramDirectivePrefix, getSupportedMiniProgramPlatforms } from "@weapp-core/shared";
|
|
4
5
|
//#region src/operations/setDataPick.ts
|
|
5
6
|
const TEMPLATE_MUSTACHE_RE = /\{\{([\s\S]*?)\}\}/g;
|
|
@@ -8,6 +9,7 @@ const FOR_DIRECTIVE_SEPARATOR_PATTERN = "[:-]";
|
|
|
8
9
|
const FOR_TAG_RE = new RegExp(`<[^>]*\\b(?:${FOR_DIRECTIVE_PREFIX_PATTERN})${FOR_DIRECTIVE_SEPARATOR_PATTERN}for\\s*=\\s*(?:\"[^\"]*\"|'[^']*')[^>]*>`, "g");
|
|
9
10
|
const FOR_ITEM_RE = new RegExp(`\\b(?:${FOR_DIRECTIVE_PREFIX_PATTERN})${FOR_DIRECTIVE_SEPARATOR_PATTERN}for-item\\s*=\\s*(?:\"([^\"]+)\"|'([^']+)')`);
|
|
10
11
|
const FOR_INDEX_RE = new RegExp(`\\b(?:${FOR_DIRECTIVE_PREFIX_PATTERN})${FOR_DIRECTIVE_SEPARATOR_PATTERN}for-index\\s*=\\s*(?:\"([^\"]+)\"|'([^']+)')`);
|
|
12
|
+
const WEVU_SLOT_SCOPE_ATTR_RE = new RegExp(`\\b(?:${WEVU_SLOT_SCOPE_KEY}|${WEVU_GENERIC_SLOT_SCOPE_ATTR})\\s*=`);
|
|
11
13
|
const JS_GLOBAL_IDENTIFIERS = new Set([
|
|
12
14
|
"undefined",
|
|
13
15
|
"NaN",
|
|
@@ -282,7 +284,12 @@ function collectSetDataPickKeysFromTemplateCode(template, options) {
|
|
|
282
284
|
if (!template.includes("{{")) return [];
|
|
283
285
|
const engine = options?.astEngine ?? "babel";
|
|
284
286
|
try {
|
|
285
|
-
|
|
287
|
+
const keys = engine === "oxc" ? collectSetDataPickKeysWithOxc(template) : collectSetDataPickKeysWithBabel(template);
|
|
288
|
+
if (WEVU_SLOT_SCOPE_ATTR_RE.test(template) && !keys.includes(WEVU_NATIVE_SLOT_SCOPE_DATA_KEY)) {
|
|
289
|
+
keys.push(WEVU_NATIVE_SLOT_SCOPE_DATA_KEY);
|
|
290
|
+
keys.sort((a, b) => a.localeCompare(b));
|
|
291
|
+
}
|
|
292
|
+
return keys;
|
|
286
293
|
} catch {
|
|
287
294
|
return [];
|
|
288
295
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/ast",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.8",
|
|
5
5
|
"description": "weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@babel/types": "^7.29.0",
|
|
109
109
|
"@oxc-project/types": "^0.129.0",
|
|
110
110
|
"oxc-parser": "^0.129.0",
|
|
111
|
-
"oxc-walker": "^0.
|
|
111
|
+
"oxc-walker": "^1.0.0",
|
|
112
112
|
"@weapp-core/shared": "3.0.4"
|
|
113
113
|
},
|
|
114
114
|
"publishConfig": {
|