@weapp-vite/ast 6.15.6 → 6.15.7

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,10 +1,13 @@
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 { getMiniProgramDirectivePrefix, getSupportedMiniProgramPlatforms } from "@weapp-core/shared";
3
4
  //#region src/operations/setDataPick.ts
4
5
  const TEMPLATE_MUSTACHE_RE = /\{\{([\s\S]*?)\}\}/g;
5
- const WX_FOR_TAG_RE = /<[^>]*\bwx:for\s*=\s*(?:"[^"]*"|'[^']*')[^>]*>/g;
6
- const WX_FOR_ITEM_RE = /\bwx:for-item\s*=\s*(?:"([^"]+)"|'([^']+)')/;
7
- const WX_FOR_INDEX_RE = /\bwx:for-index\s*=\s*(?:"([^"]+)"|'([^']+)')/;
6
+ const FOR_DIRECTIVE_PREFIX_PATTERN = Array.from(new Set(["s", ...getSupportedMiniProgramPlatforms().map((platform) => getMiniProgramDirectivePrefix(platform))])).sort((left, right) => right.length - left.length).map((prefix) => prefix.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&")).join("|");
7
+ const FOR_DIRECTIVE_SEPARATOR_PATTERN = "[:-]";
8
+ const FOR_TAG_RE = new RegExp(`<[^>]*\\b(?:${FOR_DIRECTIVE_PREFIX_PATTERN})${FOR_DIRECTIVE_SEPARATOR_PATTERN}for\\s*=\\s*(?:\"[^\"]*\"|'[^']*')[^>]*>`, "g");
9
+ const FOR_ITEM_RE = new RegExp(`\\b(?:${FOR_DIRECTIVE_PREFIX_PATTERN})${FOR_DIRECTIVE_SEPARATOR_PATTERN}for-item\\s*=\\s*(?:\"([^\"]+)\"|'([^']+)')`);
10
+ const FOR_INDEX_RE = new RegExp(`\\b(?:${FOR_DIRECTIVE_PREFIX_PATTERN})${FOR_DIRECTIVE_SEPARATOR_PATTERN}for-index\\s*=\\s*(?:\"([^\"]+)\"|'([^']+)')`);
8
11
  const JS_GLOBAL_IDENTIFIERS = new Set([
9
12
  "undefined",
10
13
  "NaN",
@@ -34,14 +37,14 @@ const JS_GLOBAL_IDENTIFIERS = new Set([
34
37
  ]);
35
38
  function collectLoopScopeAliases(template) {
36
39
  const aliases = /* @__PURE__ */ new Set();
37
- const tagMatches = template.match(WX_FOR_TAG_RE) ?? [];
40
+ const tagMatches = template.match(FOR_TAG_RE) ?? [];
38
41
  for (const tag of tagMatches) {
39
- const itemMatch = tag.match(WX_FOR_ITEM_RE);
42
+ const itemMatch = tag.match(FOR_ITEM_RE);
40
43
  if (itemMatch) {
41
44
  const itemAlias = (itemMatch[1] ?? itemMatch[2] ?? "").trim();
42
45
  if (itemAlias) aliases.add(itemAlias);
43
46
  } else aliases.add("item");
44
- const indexMatch = tag.match(WX_FOR_INDEX_RE);
47
+ const indexMatch = tag.match(FOR_INDEX_RE);
45
48
  if (indexMatch) {
46
49
  const indexAlias = (indexMatch[1] ?? indexMatch[2] ?? "").trim();
47
50
  if (indexAlias) aliases.add(indexAlias);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-vite/ast",
3
3
  "type": "module",
4
- "version": "6.15.6",
4
+ "version": "6.15.7",
5
5
  "description": "weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -106,9 +106,10 @@
106
106
  "@babel/parser": "^7.29.2",
107
107
  "@babel/traverse": "^7.29.0",
108
108
  "@babel/types": "^7.29.0",
109
- "@oxc-project/types": "^0.125.0",
110
- "oxc-parser": "^0.125.0",
111
- "oxc-walker": "^0.7.0"
109
+ "@oxc-project/types": "^0.126.0",
110
+ "oxc-parser": "^0.126.0",
111
+ "oxc-walker": "^0.7.0",
112
+ "@weapp-core/shared": "3.0.4"
112
113
  },
113
114
  "publishConfig": {
114
115
  "access": "public",