@weapp-vite/ast 7.5.0 → 7.7.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.
Files changed (36) hide show
  1. package/dist/babel.d.mts +1 -2
  2. package/dist/babel.mjs +1 -2
  3. package/dist/babelCore.d.mts +0 -2
  4. package/dist/babelCore.mjs +1 -2
  5. package/dist/babelLoader.d.mts +2 -0
  6. package/dist/babelLoader.mjs +32 -0
  7. package/dist/babelNodes.d.mts +1 -3
  8. package/dist/babelNodes.mjs +1 -2
  9. package/dist/{engine-CBE2OpFp.mjs → engine-DNS4Kzzw.mjs} +3 -6
  10. package/dist/engine.d.mts +2 -4
  11. package/dist/engine.mjs +1 -1
  12. package/dist/index.d.mts +70 -13
  13. package/dist/index.mjs +70 -29
  14. package/dist/native-D8RHiEuF.mjs +358 -0
  15. package/dist/{onPageScroll-n3Vptu1_.d.mts → onPageScroll-9kwtAWzG.d.mts} +1 -11
  16. package/dist/{onPageScroll-tuvgNooK.mjs → onPageScroll-CN_ocv9l.mjs} +6 -10
  17. package/dist/operations/componentProps.d.mts +2 -4
  18. package/dist/operations/componentProps.mjs +2 -3
  19. package/dist/operations/featureFlags.d.mts +2 -4
  20. package/dist/operations/featureFlags.mjs +3 -4
  21. package/dist/operations/jsxAutoComponents.d.mts +2 -12
  22. package/dist/operations/jsxAutoComponents.mjs +4 -8
  23. package/dist/operations/onPageScroll.d.mts +1 -1
  24. package/dist/operations/onPageScroll.mjs +1 -1
  25. package/dist/operations/platformApi.d.mts +2 -4
  26. package/dist/operations/platformApi.mjs +3 -4
  27. package/dist/operations/require.d.mts +2 -4
  28. package/dist/operations/require.mjs +3 -4
  29. package/dist/operations/scriptSetupImports.d.mts +2 -4
  30. package/dist/operations/scriptSetupImports.mjs +2 -3
  31. package/dist/operations/setDataPick.d.mts +2 -4
  32. package/dist/operations/setDataPick.mjs +2 -3
  33. package/dist/{types-4qG2Ubmk.d.mts → types-urOiI-JL.d.mts} +0 -2
  34. package/dist/types.d.mts +1 -1
  35. package/package.json +18 -8
  36. package/dist/native-C-xcrMBn.mjs +0 -54
@@ -1,6 +1,5 @@
1
- import { n as AstParserLike, t as AstEngineName } from "../types-4qG2Ubmk.mjs";
1
+ import { n as AstParserLike, t as AstEngineName } from "../types-urOiI-JL.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
- //#region src/operations/require.d.ts
4
3
  export interface RequireToken {
5
4
  start: number;
6
5
  end: number;
@@ -49,5 +48,4 @@ export declare function hasStaticRequireCall(ast: Program): boolean;
49
48
  export declare function mayContainStaticRequireLiteral(code: string, options?: {
50
49
  engine?: AstEngineName;
51
50
  parserLike?: AstParserLike;
52
- }): boolean;
53
- //#endregion
51
+ }): boolean;
@@ -1,7 +1,7 @@
1
- import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
2
- import { i as shouldUseNativeAst, r as loadNativeAstBindingSync, t as analyzeScriptWithNative } from "../native-C-xcrMBn.mjs";
1
+ import { t as parseJsLikeWithEngine } from "../engine-DNS4Kzzw.mjs";
2
+ import { a as loadNativeAstBindingSync, o as shouldUseNativeAst, r as analyzeScriptWithNative } from "../native-D8RHiEuF.mjs";
3
3
  import { walk } from "oxc-walker";
4
- //#region src/operations/require.ts
4
+ // src/operations/require.ts
5
5
  function mayContainRequireCallByText(code) {
6
6
  return code.includes("require(") || code.includes("require (") || code.includes("require`");
7
7
  }
@@ -128,5 +128,4 @@ function mayContainStaticRequireLiteral(code, options) {
128
128
  return true;
129
129
  }
130
130
  }
131
- //#endregion
132
131
  export { collectRequireTokens, getDynamicImportLiteralToken, getRequireAsyncLiteralToken, getRequireCallbackLiteralToken, getStaticRequireLiteralValue, hasStaticRequireCall, isStaticRequireCall, mayContainRequireCallByText, mayContainStaticRequireLiteral };
@@ -1,5 +1,4 @@
1
- import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
2
- //#region src/operations/scriptSetupImports.d.ts
1
+ import { t as AstEngineName } from "../types-urOiI-JL.mjs";
3
2
  export interface ScriptSetupImport {
4
3
  localName: string;
5
4
  importSource: string;
@@ -16,5 +15,4 @@ export declare function collectScriptSetupImportsWithBabel(scriptSetup: string,
16
15
  */
17
16
  export declare function collectScriptSetupImportsFromCode(scriptSetup: string, templateComponentNames: Set<string>, options?: {
18
17
  astEngine?: AstEngineName;
19
- }): ScriptSetupImport[];
20
- //#endregion
18
+ }): ScriptSetupImport[];
@@ -1,6 +1,6 @@
1
1
  import { BABEL_TS_MODULE_PARSER_OPTIONS, parse } from "../babel.mjs";
2
- import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
3
- //#region src/operations/scriptSetupImports.ts
2
+ import { t as parseJsLikeWithEngine } from "../engine-DNS4Kzzw.mjs";
3
+ // src/operations/scriptSetupImports.ts
4
4
  function mayContainRelevantScriptSetupImports(scriptSetup, templateComponentNames) {
5
5
  if (templateComponentNames.size === 0) return false;
6
6
  if (!scriptSetup.includes("import")) return false;
@@ -67,5 +67,4 @@ function collectScriptSetupImportsFromCode(scriptSetup, templateComponentNames,
67
67
  return [];
68
68
  }
69
69
  }
70
- //#endregion
71
70
  export { collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, createScriptSetupImport, getScriptSetupImportedName, mayContainRelevantScriptSetupImports };
@@ -1,5 +1,4 @@
1
- import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
2
- //#region src/operations/setDataPick.d.ts
1
+ import { t as AstEngineName } from "../types-urOiI-JL.mjs";
3
2
  export declare function collectLoopScopeAliases(template: string): Set<string>;
4
3
  export declare function extractTemplateExpressions(template: string): string[];
5
4
  export declare function collectIdentifiersFromExpression(expression: string): Set<string>;
@@ -15,5 +14,4 @@ export declare function collectSetDataPickKeysWithOxc(template: string): string[
15
14
  */
16
15
  export declare function collectSetDataPickKeysFromTemplateCode(template: string, options?: {
17
16
  astEngine?: AstEngineName;
18
- }): string[];
19
- //#endregion
17
+ }): string[];
@@ -1,7 +1,7 @@
1
1
  import { BABEL_TS_MODULE_PARSER_OPTIONS, parse, traverse } from "../babel.mjs";
2
- import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
2
+ import { t as parseJsLikeWithEngine } from "../engine-DNS4Kzzw.mjs";
3
3
  import { getMiniProgramDirectivePrefix, getSupportedMiniProgramPlatforms } from "@weapp-core/shared";
4
- //#region src/operations/setDataPick.ts
4
+ // src/operations/setDataPick.ts
5
5
  const TEMPLATE_MUSTACHE_RE = /\{\{([\s\S]*?)\}\}/g;
6
6
  const FOR_DIRECTIVE_PREFIX_PATTERN = Array.from(/* @__PURE__ */ new Set(["s", ...getSupportedMiniProgramPlatforms().map((platform) => getMiniProgramDirectivePrefix(platform))])).sort((left, right) => right.length - left.length).map((prefix) => prefix.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&")).join("|");
7
7
  const FOR_DIRECTIVE_SEPARATOR_PATTERN = "[:-]";
@@ -285,5 +285,4 @@ function collectSetDataPickKeysFromTemplateCode(template, options) {
285
285
  return [];
286
286
  }
287
287
  }
288
- //#endregion
289
288
  export { collectIdentifiersFromExpression, collectIdentifiersFromExpressionWithOxc, collectLoopScopeAliases, collectPatternBindingNames, collectSetDataPickKeysFromTemplateCode, collectSetDataPickKeysWithBabel, collectSetDataPickKeysWithOxc, extractTemplateExpressions, hasBindingInScopes };
@@ -1,4 +1,3 @@
1
- //#region src/types.d.ts
2
1
  /**
3
2
  * AST 引擎名称。
4
3
  */
@@ -20,5 +19,4 @@ interface WeappAstConfig {
20
19
  interface AstParserLike {
21
20
  parse?: (input: string, options?: unknown) => unknown;
22
21
  }
23
- //#endregion
24
22
  export { AstParserLike as n, WeappAstConfig as r, AstEngineName as t };
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as AstParserLike, r as WeappAstConfig, t as AstEngineName } from "./types-4qG2Ubmk.mjs";
1
+ import { n as AstParserLike, r as WeappAstConfig, t as AstEngineName } from "./types-urOiI-JL.mjs";
2
2
  export { AstEngineName, AstParserLike, WeappAstConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-vite/ast",
3
3
  "type": "module",
4
- "version": "7.5.0",
4
+ "version": "7.7.0",
5
5
  "description": "weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -41,6 +41,10 @@
41
41
  "types": "./dist/babelCore.d.mts",
42
42
  "import": "./dist/babelCore.mjs"
43
43
  },
44
+ "./babelLoader": {
45
+ "types": "./dist/babelLoader.d.mts",
46
+ "import": "./dist/babelLoader.mjs"
47
+ },
44
48
  "./babelTraverse": {
45
49
  "types": "./dist/babelTraverse.d.mts",
46
50
  "import": "./dist/babelTraverse.mjs"
@@ -103,19 +107,25 @@
103
107
  "dist"
104
108
  ],
105
109
  "engines": {
106
- "node": "^22.18.0 || ^24.11.0 || >=26.0.0"
110
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
107
111
  },
108
112
  "dependencies": {
109
- "@babel/core": "^8.0.7",
113
+ "@babel/core": "^8.0.9",
110
114
  "@babel/generator": "^8.0.6",
111
- "@babel/parser": "^8.0.7",
115
+ "@babel/parser": "^8.0.8",
112
116
  "@babel/traverse": "^8.0.7",
113
- "@babel/types": "^8.0.6",
114
- "@oxc-project/types": "^0.153.0",
115
- "@weapp-core/shared": "3.2.8",
116
- "oxc-parser": "^0.153.0",
117
+ "@babel/types": "^8.0.8",
118
+ "@oxc-project/types": "^0.155.0",
119
+ "@weapp-core/shared": "3.4.0",
120
+ "oxc-parser": "^0.155.0",
117
121
  "oxc-walker": "^1.1.1"
118
122
  },
123
+ "tsd": {
124
+ "compilerOptions": {
125
+ "module": "NodeNext",
126
+ "moduleResolution": "NodeNext"
127
+ }
128
+ },
119
129
  "publishConfig": {
120
130
  "access": "public",
121
131
  "registry": "https://registry.npmjs.org"
@@ -1,54 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import process from "node:process";
3
- //#region src/native.ts
4
- const require = createRequire(import.meta.url);
5
- let binding;
6
- let lastScriptAnalysis;
7
- function resolveNativeAstModulePath() {
8
- return process.env.WEAPP_VITE_NATIVE_AST_PATH?.trim() || void 0;
9
- }
10
- function shouldUseNativeAst() {
11
- return process.env.WEAPP_VITE_NATIVE === "1" && Boolean(resolveNativeAstModulePath());
12
- }
13
- function loadNativeAstBindingSync() {
14
- if (!shouldUseNativeAst()) return;
15
- if (binding !== void 0) return binding || void 0;
16
- try {
17
- binding = require(resolveNativeAstModulePath());
18
- } catch {
19
- binding = false;
20
- }
21
- return binding || void 0;
22
- }
23
- function analyzeScriptWithNative(code, options) {
24
- const analyzeNative = loadNativeAstBindingSync()?.analyzeScriptNative;
25
- if (!analyzeNative) return;
26
- const hookToFeatureJson = options?.hookToFeature ? JSON.stringify(options.hookToFeature) : void 0;
27
- const key = [
28
- code,
29
- options?.filename ?? "",
30
- options?.moduleId ?? "",
31
- hookToFeatureJson ?? ""
32
- ].join("\0");
33
- if (lastScriptAnalysis?.key === key) return lastScriptAnalysis.result;
34
- const result = analyzeNative(code, options?.moduleId, hookToFeatureJson, options?.filename ?? "inline.ts");
35
- lastScriptAnalysis = {
36
- key,
37
- result
38
- };
39
- return result;
40
- }
41
- function analyzeScriptsWithNative(inputs) {
42
- const analyzeNative = loadNativeAstBindingSync()?.analyzeScriptsNative;
43
- if (!analyzeNative) return;
44
- return analyzeNative(inputs.map((input) => {
45
- return {
46
- code: input.code,
47
- filename: input.filename ?? "inline.ts",
48
- hookToFeatureJson: input.hookToFeature ? JSON.stringify(input.hookToFeature) : void 0,
49
- moduleId: input.moduleId
50
- };
51
- }));
52
- }
53
- //#endregion
54
- export { shouldUseNativeAst as i, analyzeScriptsWithNative as n, loadNativeAstBindingSync as r, analyzeScriptWithNative as t };