@weapp-vite/ast 7.0.3 → 7.1.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/dist/babel.d.mts +8 -9
- package/dist/babelCore.d.mts +2 -2
- package/dist/babelNodes.d.mts +7 -8
- package/dist/engine.d.mts +2 -3
- package/dist/index.d.mts +8 -8
- package/dist/operations/componentProps.d.mts +14 -15
- package/dist/operations/featureFlags.d.mts +12 -13
- package/dist/operations/jsxAutoComponents.d.mts +23 -24
- package/dist/operations/platformApi.d.mts +8 -9
- package/dist/operations/require.d.mts +13 -14
- package/dist/operations/scriptSetupImports.d.mts +8 -9
- package/dist/operations/setDataPick.d.mts +10 -11
- package/package.json +3 -3
package/dist/babel.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { ParserOptions, ParserPlugin } from "@babel/parser";
|
|
3
3
|
//#region src/babel.d.ts
|
|
4
|
-
declare const BABEL_TS_MODULE_PLUGINS: ParserPlugin[];
|
|
5
|
-
declare const BABEL_TS_MODULE_PARSER_OPTIONS: ParserOptions;
|
|
4
|
+
export declare const BABEL_TS_MODULE_PLUGINS: ParserPlugin[];
|
|
5
|
+
export declare const BABEL_TS_MODULE_PARSER_OPTIONS: ParserOptions;
|
|
6
6
|
type BabelTraverse = typeof import('@babel/traverse').default;
|
|
7
7
|
type BabelGenerate = typeof import('@babel/generator').default;
|
|
8
8
|
type BabelParse = typeof import('@babel/parser').parse;
|
|
@@ -11,10 +11,9 @@ type BabelGeneratorInputCode = Parameters<BabelGenerate>[2];
|
|
|
11
11
|
type BabelGeneratorResult = ReturnType<BabelGenerate>;
|
|
12
12
|
type TraverseFn = (...args: Parameters<BabelTraverse>) => ReturnType<BabelTraverse>;
|
|
13
13
|
type GenerateFn = (ast: t.Node, opts?: BabelGeneratorOptions, code?: BabelGeneratorInputCode) => BabelGeneratorResult;
|
|
14
|
-
declare const traverse: TraverseFn;
|
|
15
|
-
declare const generate: GenerateFn;
|
|
16
|
-
declare const parse: BabelParse;
|
|
17
|
-
declare function getVisitorKeys(): typeof import('@babel/types').VISITOR_KEYS;
|
|
18
|
-
declare function parseJsLike(source: string): t.File;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { BABEL_TS_MODULE_PARSER_OPTIONS, BABEL_TS_MODULE_PLUGINS, generate, getVisitorKeys, parse, parseJsLike, traverse };
|
|
14
|
+
export declare const traverse: TraverseFn;
|
|
15
|
+
export declare const generate: GenerateFn;
|
|
16
|
+
export declare const parse: BabelParse;
|
|
17
|
+
export declare function getVisitorKeys(): typeof import('@babel/types').VISITOR_KEYS;
|
|
18
|
+
export declare function parseJsLike(source: string): t.File;
|
|
19
|
+
//#endregion
|
package/dist/babelCore.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as BabelCore from "@babel/core";
|
|
|
2
2
|
import { InputOptions as TransformOptions, NodePath } from "@babel/core";
|
|
3
3
|
//#region src/babelCore.d.ts
|
|
4
4
|
declare const babelCore: typeof BabelCore;
|
|
5
|
-
declare const parse: {
|
|
5
|
+
export declare const parse: {
|
|
6
6
|
(code: string, callback: {
|
|
7
7
|
(err: Error, ast: null): void;
|
|
8
8
|
(err: null, ast: import("@babel/parser").ParseResult | null): void;
|
|
@@ -31,4 +31,4 @@ declare const parse: {
|
|
|
31
31
|
}): void;
|
|
32
32
|
}, transformFromAstAsync: typeof BabelCore.transformFromAstAsync, transformFromAstSync: typeof BabelCore.transformFromAstSync, transformSync: typeof BabelCore.transformSync, types: typeof BabelCore.types, version: string;
|
|
33
33
|
//#endregion
|
|
34
|
-
export { type NodePath, type TransformOptions, babelCore as default
|
|
34
|
+
export { type NodePath, type TransformOptions, babelCore as default };
|
package/dist/babelNodes.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { Expression, ObjectExpression, ObjectMethod, ObjectProperty, PrivateName } from "@babel/types";
|
|
3
3
|
//#region src/babelNodes.d.ts
|
|
4
|
-
declare function unwrapTypeScriptExpression(exp: Expression): Expression;
|
|
5
|
-
declare function toStaticObjectKey(key: Expression | PrivateName | t.Identifier): string | null;
|
|
6
|
-
declare function getObjectPropertyByKey(node: ObjectExpression, key: string): ObjectMethod | t.ObjectPropertyNonComputed | null;
|
|
7
|
-
declare function getRenderPropertyFromComponentOptions(componentExpr: Expression): ObjectMethod | t.ObjectPropertyNonComputed | null;
|
|
8
|
-
declare function resolveRenderableExpression(node: ObjectMethod | ObjectProperty): Expression | null;
|
|
9
|
-
declare function resolveRenderExpressionFromComponentOptions(componentExpr: Expression): Expression | null;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { getObjectPropertyByKey, getRenderPropertyFromComponentOptions, resolveRenderExpressionFromComponentOptions, resolveRenderableExpression, toStaticObjectKey, unwrapTypeScriptExpression };
|
|
4
|
+
export declare function unwrapTypeScriptExpression(exp: Expression): Expression;
|
|
5
|
+
export declare function toStaticObjectKey(key: Expression | PrivateName | t.Identifier): string | null;
|
|
6
|
+
export declare function getObjectPropertyByKey(node: ObjectExpression, key: string): ObjectMethod | t.ObjectPropertyNonComputed | null;
|
|
7
|
+
export declare function getRenderPropertyFromComponentOptions(componentExpr: Expression): ObjectMethod | t.ObjectPropertyNonComputed | null;
|
|
8
|
+
export declare function resolveRenderableExpression(node: ObjectMethod | ObjectProperty): Expression | null;
|
|
9
|
+
export declare function resolveRenderExpressionFromComponentOptions(componentExpr: Expression): Expression | null;
|
|
10
|
+
//#endregion
|
package/dist/engine.d.mts
CHANGED
|
@@ -3,10 +3,9 @@ import { n as AstParserLike, t as AstEngineName } from "./types-4qG2Ubmk.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* 统一解析 JS-like 源码,供 analysis 型 operation 复用。
|
|
5
5
|
*/
|
|
6
|
-
declare function parseJsLikeWithEngine(code: string, options?: {
|
|
6
|
+
export declare function parseJsLikeWithEngine(code: string, options?: {
|
|
7
7
|
engine?: AstEngineName;
|
|
8
8
|
filename?: string;
|
|
9
9
|
parserLike?: AstParserLike;
|
|
10
10
|
}): unknown;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { parseJsLikeWithEngine };
|
|
11
|
+
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ import { collectIdentifiersFromExpression, collectIdentifiersFromExpressionWithO
|
|
|
14
14
|
/**
|
|
15
15
|
* Babel AST 引擎。
|
|
16
16
|
*/
|
|
17
|
-
declare const babelAstEngine: {
|
|
17
|
+
export declare const babelAstEngine: {
|
|
18
18
|
name: "babel";
|
|
19
19
|
parseJsLike(code: string): import("@babel/types").File;
|
|
20
20
|
};
|
|
@@ -23,7 +23,7 @@ declare const babelAstEngine: {
|
|
|
23
23
|
/**
|
|
24
24
|
* Oxc AST 引擎。
|
|
25
25
|
*/
|
|
26
|
-
declare const oxcAstEngine: {
|
|
26
|
+
export declare const oxcAstEngine: {
|
|
27
27
|
name: "oxc";
|
|
28
28
|
parseJsLike(code: string, filename?: string): import("oxc-parser").Program;
|
|
29
29
|
};
|
|
@@ -47,24 +47,24 @@ interface ScriptAnalysisBatchInput<TFeature extends string = string> {
|
|
|
47
47
|
/**
|
|
48
48
|
* 对同一份脚本做批量 AST 预分析,避免多个轻量检查重复 parse 或跨 native 边界。
|
|
49
49
|
*/
|
|
50
|
-
declare function analyzeScript<TFeature extends string = string>(code: string, options?: ScriptAnalysisOptions<TFeature>): ScriptAnalysisResult<TFeature>;
|
|
50
|
+
export declare function analyzeScript<TFeature extends string = string>(code: string, options?: ScriptAnalysisOptions<TFeature>): ScriptAnalysisResult<TFeature>;
|
|
51
51
|
/**
|
|
52
52
|
* 对多份脚本做批量 native 预分析,减少 JS 与 Rust 的往返次数。
|
|
53
53
|
*/
|
|
54
|
-
declare function analyzeScripts<TFeature extends string = string>(inputs: ScriptAnalysisBatchInput<TFeature>[], options?: ScriptAnalysisOptions<TFeature>): Array<ScriptAnalysisResult<TFeature>>;
|
|
54
|
+
export declare function analyzeScripts<TFeature extends string = string>(inputs: ScriptAnalysisBatchInput<TFeature>[], options?: ScriptAnalysisOptions<TFeature>): Array<ScriptAnalysisResult<TFeature>>;
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/operations/scriptLiterals.d.ts
|
|
57
57
|
/**
|
|
58
58
|
* 收集脚本中的字符串字面量源码片段,供上层语义按需筛选。
|
|
59
59
|
*/
|
|
60
|
-
declare function collectScriptStringLiterals(code: string): string[];
|
|
60
|
+
export declare function collectScriptStringLiterals(code: string): string[];
|
|
61
61
|
/**
|
|
62
62
|
* 收集调用表达式中的字符串字面量源码片段。
|
|
63
63
|
*/
|
|
64
|
-
declare function collectScriptCallStringLiterals(code: string): string[];
|
|
64
|
+
export declare function collectScriptCallStringLiterals(code: string): string[];
|
|
65
65
|
/**
|
|
66
66
|
* 快速判断脚本是否包含调用或模块语法,避免上层无条件扩大候选集。
|
|
67
67
|
*/
|
|
68
|
-
declare function mayContainScriptCallOrModuleSyntax(code: string): boolean;
|
|
68
|
+
export declare function mayContainScriptCallOrModuleSyntax(code: string): boolean;
|
|
69
69
|
//#endregion
|
|
70
|
-
export { type AstEngineName, type AstParserLike, BABEL_TS_MODULE_PARSER_OPTIONS, BABEL_TS_MODULE_PLUGINS, type ComponentPropMap, type DynamicImportToken, type FeatureFlagOptions, type JsxAutoComponentAnalysisOptions, type JsxAutoComponentContext, type JsxBabelModuleAnalysisOptions, type JsxImportedComponent, type RequireCallbackToken, type RequireToken, type ScriptAnalysisBatchInput, type ScriptAnalysisOptions, type ScriptAnalysisResult, type ScriptSetupImport, type WeappAstConfig,
|
|
70
|
+
export { type AstEngineName, type AstParserLike, BABEL_TS_MODULE_PARSER_OPTIONS, BABEL_TS_MODULE_PLUGINS, type ComponentPropMap, type DynamicImportToken, type FeatureFlagOptions, type JsxAutoComponentAnalysisOptions, type JsxAutoComponentContext, type JsxBabelModuleAnalysisOptions, type JsxImportedComponent, type RequireCallbackToken, type RequireToken, type ScriptAnalysisBatchInput, type ScriptAnalysisOptions, type ScriptAnalysisResult, type ScriptSetupImport, type WeappAstConfig, collectComponentPropsFromCode, collectComponentPropsWithBabel, collectComponentPropsWithOxc, collectFeatureFlagsFromCode, collectFeatureFlagsWithBabel, collectFeatureFlagsWithNative, collectFeatureFlagsWithNativeBatch, collectFeatureFlagsWithOxc, collectIdentifiersFromExpression, collectIdentifiersFromExpressionWithOxc, collectJsxAutoComponentsFromCode, collectJsxAutoComponentsWithBabel, collectJsxAutoComponentsWithOxc, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, collectJsxTemplateTagsFromOxc, collectLoopScopeAliases, collectOnPageScrollPerformanceWarnings, collectOnPageScrollWarningsWithBabel, collectOnPageScrollWarningsWithNative, collectOnPageScrollWarningsWithOxc, collectPageScrollInspection, collectPageScrollInspectionWithOxc, collectPatternBindingNames, collectRequireTokens, collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, collectSetDataPickKeysFromTemplateCode, collectSetDataPickKeysWithBabel, collectSetDataPickKeysWithOxc, consumeNamedFeatureFlag, consumeNamespaceFeatureFlag, createJsxImportedComponent, createLineStartOffsets, createScriptSetupImport, createWarningPrefix, defaultIsDefineComponentSource, defaultResolveBabelComponentExpression, defaultResolveBabelRenderExpression, extractComponentProperties, extractPropertiesObject, extractTemplateExpressions, generate, getCallExpressionCalleeName, getDynamicImportLiteralToken, getJsxImportLocalName, getJsxImportedName, getJsxOxcStaticPropertyName, getLocationFromOffset, getMemberExpressionPropertyName, getObjectPropertyByKey, getOnPageScrollCallbackArgument, getOxcCallExpressionCalleeName, getOxcMemberExpressionPropertyName, getOxcStaticPropertyName, getRenderPropertyFromComponentOptions, getRequireAsyncLiteralToken, getRequireCallbackLiteralToken, getScriptSetupImportedName, getStaticPropertyName, getStaticRequireLiteralValue, getVisitorKeys, hasBindingInScopes, hasPlatformApiMemberExpression, hasStaticRequireCall, isJsxDefineComponentImportSpecifier, isOnPageScrollCallee, isOxcFunctionLike, isOxcOnPageScrollCallee, isPlatformApiIdentifier, isPlatformApiMemberExpression, isStaticPropertyName, isStaticRequireCall, mapConstructorName, mayContainComponentPropsShape, mayContainFeatureFlagHints, mayContainJsxAutoComponentEntry, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, mayContainRelevantScriptSetupImports, mayContainRequireCallByText, mayContainStaticRequireLiteral, mergeComponentPropTypes, parse, parseJsLike, parseJsLikeWithEngine, platformApiIdentifierList, platformApiIdentifiers, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveOxcComponentExpression, resolveOxcRenderExpression, resolveRenderExpressionFromComponentOptions, resolveRenderableExpression, resolveTypeFromNode, toStaticObjectKey, traverse, unwrapOxcExpression, unwrapTypeScriptExpression };
|
|
@@ -2,23 +2,22 @@ import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
|
2
2
|
import * as t from "@babel/types";
|
|
3
3
|
import { NodePath } from "@babel/traverse";
|
|
4
4
|
//#region src/operations/componentProps.d.ts
|
|
5
|
-
type ComponentPropMap = Map<string, string>;
|
|
6
|
-
declare function mayContainComponentPropsShape(code: string): boolean;
|
|
7
|
-
declare function mapConstructorName(name: string): string;
|
|
8
|
-
declare function resolveTypeFromNode(node: any): string;
|
|
9
|
-
declare function getStaticPropertyName(node: any): any;
|
|
10
|
-
declare function mergeComponentPropTypes(primaryType: string | undefined, optionalTypes: Array<string | undefined>): string;
|
|
11
|
-
declare function extractPropertiesObject(node: any): ComponentPropMap | undefined;
|
|
12
|
-
declare function resolveOptionsObjectExpression(node: any, bindings: Map<string, any>): any;
|
|
13
|
-
declare function resolveOptionsObjectExpressionWithBabel(path: NodePath<t.CallExpression>, node: t.Node | null | undefined): t.ObjectExpression | undefined;
|
|
14
|
-
declare function extractComponentProperties(optionsNode: any): ComponentPropMap;
|
|
15
|
-
declare function collectComponentPropsWithBabel(code: string): ComponentPropMap;
|
|
16
|
-
declare function collectComponentPropsWithOxc(code: string): ComponentPropMap;
|
|
5
|
+
export type ComponentPropMap = Map<string, string>;
|
|
6
|
+
export declare function mayContainComponentPropsShape(code: string): boolean;
|
|
7
|
+
export declare function mapConstructorName(name: string): string;
|
|
8
|
+
export declare function resolveTypeFromNode(node: any): string;
|
|
9
|
+
export declare function getStaticPropertyName(node: any): any;
|
|
10
|
+
export declare function mergeComponentPropTypes(primaryType: string | undefined, optionalTypes: Array<string | undefined>): string;
|
|
11
|
+
export declare function extractPropertiesObject(node: any): ComponentPropMap | undefined;
|
|
12
|
+
export declare function resolveOptionsObjectExpression(node: any, bindings: Map<string, any>): any;
|
|
13
|
+
export declare function resolveOptionsObjectExpressionWithBabel(path: NodePath<t.CallExpression>, node: t.Node | null | undefined): t.ObjectExpression | undefined;
|
|
14
|
+
export declare function extractComponentProperties(optionsNode: any): ComponentPropMap;
|
|
15
|
+
export declare function collectComponentPropsWithBabel(code: string): ComponentPropMap;
|
|
16
|
+
export declare function collectComponentPropsWithOxc(code: string): ComponentPropMap;
|
|
17
17
|
/**
|
|
18
18
|
* 从源码中提取组件属性类型映射。
|
|
19
19
|
*/
|
|
20
|
-
declare function collectComponentPropsFromCode(code: string, options?: {
|
|
20
|
+
export declare function collectComponentPropsFromCode(code: string, options?: {
|
|
21
21
|
astEngine?: AstEngineName;
|
|
22
22
|
}): ComponentPropMap;
|
|
23
|
-
//#endregion
|
|
24
|
-
export { ComponentPropMap, collectComponentPropsFromCode, collectComponentPropsWithBabel, collectComponentPropsWithOxc, extractComponentProperties, extractPropertiesObject, getStaticPropertyName, mapConstructorName, mayContainComponentPropsShape, mergeComponentPropTypes, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveTypeFromNode };
|
|
23
|
+
//#endregion
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
2
2
|
//#region src/operations/featureFlags.d.ts
|
|
3
|
-
interface FeatureFlagOptions<TFeature extends string> {
|
|
3
|
+
export interface FeatureFlagOptions<TFeature extends string> {
|
|
4
4
|
astEngine?: AstEngineName;
|
|
5
5
|
moduleId: string;
|
|
6
6
|
hookToFeature: Record<string, TFeature>;
|
|
7
7
|
}
|
|
8
|
-
declare function mayContainFeatureFlagHints<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): boolean;
|
|
9
|
-
declare function consumeNamedFeatureFlag<TFeature extends string>(enabled: Set<TFeature>, namedHookLocals: Map<string, TFeature>, name: string): void;
|
|
10
|
-
declare function consumeNamespaceFeatureFlag<TFeature extends string>(enabled: Set<TFeature>, namespaceLocals: Set<string>, hookToFeature: Record<string, TFeature>, namespace: string, hookName: string): void;
|
|
11
|
-
declare function registerNamedFeatureFlagLocal<TFeature extends string>(namedHookLocals: Map<string, TFeature>, hookToFeature: Record<string, TFeature>, importedName: string, localName: string): void;
|
|
12
|
-
declare function registerNamespaceFeatureFlagLocal(namespaceLocals: Set<string>, localName: string | undefined): void;
|
|
13
|
-
declare function collectFeatureFlagsWithBabel<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature>;
|
|
14
|
-
declare function collectFeatureFlagsWithOxc<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature>;
|
|
15
|
-
declare function collectFeatureFlagsWithNative<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature> | undefined;
|
|
16
|
-
declare function collectFeatureFlagsWithNativeBatch<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature> | undefined;
|
|
8
|
+
export declare function mayContainFeatureFlagHints<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): boolean;
|
|
9
|
+
export declare function consumeNamedFeatureFlag<TFeature extends string>(enabled: Set<TFeature>, namedHookLocals: Map<string, TFeature>, name: string): void;
|
|
10
|
+
export declare function consumeNamespaceFeatureFlag<TFeature extends string>(enabled: Set<TFeature>, namespaceLocals: Set<string>, hookToFeature: Record<string, TFeature>, namespace: string, hookName: string): void;
|
|
11
|
+
export declare function registerNamedFeatureFlagLocal<TFeature extends string>(namedHookLocals: Map<string, TFeature>, hookToFeature: Record<string, TFeature>, importedName: string, localName: string): void;
|
|
12
|
+
export declare function registerNamespaceFeatureFlagLocal(namespaceLocals: Set<string>, localName: string | undefined): void;
|
|
13
|
+
export declare function collectFeatureFlagsWithBabel<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature>;
|
|
14
|
+
export declare function collectFeatureFlagsWithOxc<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature>;
|
|
15
|
+
export declare function collectFeatureFlagsWithNative<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature> | undefined;
|
|
16
|
+
export declare function collectFeatureFlagsWithNativeBatch<TFeature extends string>(code: string, moduleId: string, hookToFeature: Record<string, TFeature>): Set<TFeature> | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* 根据模块 ID 与 hook 映射表,从源码中收集启用的特性标识。
|
|
19
19
|
*/
|
|
20
|
-
declare function collectFeatureFlagsFromCode<TFeature extends string>(code: string, options: FeatureFlagOptions<TFeature>): Set<TFeature>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { FeatureFlagOptions, collectFeatureFlagsFromCode, collectFeatureFlagsWithBabel, collectFeatureFlagsWithNative, collectFeatureFlagsWithNativeBatch, collectFeatureFlagsWithOxc, consumeNamedFeatureFlag, consumeNamespaceFeatureFlag, mayContainFeatureFlagHints, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal };
|
|
20
|
+
export declare function collectFeatureFlagsFromCode<TFeature extends string>(code: string, options: FeatureFlagOptions<TFeature>): Set<TFeature>;
|
|
21
|
+
//#endregion
|
|
@@ -2,58 +2,57 @@ import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
|
2
2
|
import * as t from "@babel/types";
|
|
3
3
|
import { Expression, ObjectExpression } from "@babel/types";
|
|
4
4
|
//#region src/operations/jsxAutoComponents/types.d.ts
|
|
5
|
-
interface JsxImportedComponent {
|
|
5
|
+
export interface JsxImportedComponent {
|
|
6
6
|
localName: string;
|
|
7
7
|
importSource: string;
|
|
8
8
|
importedName?: string;
|
|
9
9
|
kind: 'default' | 'named';
|
|
10
10
|
}
|
|
11
|
-
interface JsxAutoComponentContext {
|
|
11
|
+
export interface JsxAutoComponentContext {
|
|
12
12
|
templateTags: Set<string>;
|
|
13
13
|
importedComponents: JsxImportedComponent[];
|
|
14
14
|
}
|
|
15
|
-
interface JsxAutoComponentAnalysisOptions {
|
|
15
|
+
export interface JsxAutoComponentAnalysisOptions {
|
|
16
16
|
astEngine?: AstEngineName;
|
|
17
17
|
isCollectableTag: (tag: string) => boolean;
|
|
18
18
|
isDefineComponentSource?: (source: string) => boolean;
|
|
19
19
|
resolveBabelComponentExpression?: (declaration: t.Declaration | t.Expression | null, defineComponentDecls: Map<string, ObjectExpression>, defineComponentAliases: Set<string>) => Expression | null;
|
|
20
20
|
resolveBabelRenderExpression?: (componentExpr: Expression) => Expression | null;
|
|
21
21
|
}
|
|
22
|
-
interface JsxBabelModuleAnalysisOptions {
|
|
22
|
+
export interface JsxBabelModuleAnalysisOptions {
|
|
23
23
|
isDefineComponentSource?: (source: string) => boolean;
|
|
24
24
|
resolveBabelComponentExpression?: (declaration: t.Declaration | t.Expression | null, defineComponentDecls: Map<string, ObjectExpression>, defineComponentAliases: Set<string>) => Expression | null;
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/operations/jsxAutoComponents/babel.d.ts
|
|
28
|
-
declare function defaultResolveBabelComponentExpression(declaration: t.Declaration | t.Expression | null, defineComponentDecls: Map<string, ObjectExpression>, defineComponentAliases: Set<string>): Expression | null;
|
|
29
|
-
declare function defaultResolveBabelRenderExpression(componentExpr: Expression): Expression | null;
|
|
30
|
-
declare function collectJsxImportedComponentsAndDefaultExportFromBabelAst(ast: t.File, options?: JsxBabelModuleAnalysisOptions): {
|
|
28
|
+
export declare function defaultResolveBabelComponentExpression(declaration: t.Declaration | t.Expression | null, defineComponentDecls: Map<string, ObjectExpression>, defineComponentAliases: Set<string>): Expression | null;
|
|
29
|
+
export declare function defaultResolveBabelRenderExpression(componentExpr: Expression): Expression | null;
|
|
30
|
+
export declare function collectJsxImportedComponentsAndDefaultExportFromBabelAst(ast: t.File, options?: JsxBabelModuleAnalysisOptions): {
|
|
31
31
|
importedComponents: JsxImportedComponent[];
|
|
32
32
|
exportDefaultExpression: null;
|
|
33
33
|
};
|
|
34
|
-
declare function collectJsxTemplateTagsFromBabelExpression(renderExpression: Expression, isCollectableTag: (tag: string) => boolean): Set<string>;
|
|
35
|
-
declare function collectJsxAutoComponentsWithBabel(source: string, options: Required<JsxAutoComponentAnalysisOptions>): JsxAutoComponentContext;
|
|
34
|
+
export declare function collectJsxTemplateTagsFromBabelExpression(renderExpression: Expression, isCollectableTag: (tag: string) => boolean): Set<string>;
|
|
35
|
+
export declare function collectJsxAutoComponentsWithBabel(source: string, options: Required<JsxAutoComponentAnalysisOptions>): JsxAutoComponentContext;
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/operations/jsxAutoComponents/oxc.d.ts
|
|
38
|
-
declare function unwrapOxcExpression(node: any): any;
|
|
39
|
-
declare function getJsxOxcStaticPropertyName(node: any): any;
|
|
40
|
-
declare function resolveOxcComponentExpression(declaration: any, defineComponentDecls: Map<string, any>, defineComponentAliases: Set<string>): any;
|
|
41
|
-
declare function resolveOxcRenderExpression(componentExpr: any): any;
|
|
42
|
-
declare function collectJsxTemplateTagsFromOxc(renderExpression: any, isCollectableTag: (tag: string) => boolean): Set<string>;
|
|
43
|
-
declare function collectJsxAutoComponentsWithOxc(source: string, options: Required<Pick<JsxAutoComponentAnalysisOptions, 'isCollectableTag' | 'isDefineComponentSource'>>): JsxAutoComponentContext;
|
|
38
|
+
export declare function unwrapOxcExpression(node: any): any;
|
|
39
|
+
export declare function getJsxOxcStaticPropertyName(node: any): any;
|
|
40
|
+
export declare function resolveOxcComponentExpression(declaration: any, defineComponentDecls: Map<string, any>, defineComponentAliases: Set<string>): any;
|
|
41
|
+
export declare function resolveOxcRenderExpression(componentExpr: any): any;
|
|
42
|
+
export declare function collectJsxTemplateTagsFromOxc(renderExpression: any, isCollectableTag: (tag: string) => boolean): Set<string>;
|
|
43
|
+
export declare function collectJsxAutoComponentsWithOxc(source: string, options: Required<Pick<JsxAutoComponentAnalysisOptions, 'isCollectableTag' | 'isDefineComponentSource'>>): JsxAutoComponentContext;
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/operations/jsxAutoComponents/shared.d.ts
|
|
46
|
-
declare function mayContainJsxAutoComponentEntry(source: string): boolean;
|
|
47
|
-
declare function defaultIsDefineComponentSource(source: string): source is "vue";
|
|
48
|
-
declare function getJsxImportedName(imported: any): any;
|
|
49
|
-
declare function createJsxImportedComponent(localName: string, importSource: string, kind: JsxImportedComponent['kind'], imported?: any): JsxImportedComponent;
|
|
50
|
-
declare function getJsxImportLocalName(specifier: any): any;
|
|
51
|
-
declare function isJsxDefineComponentImportSpecifier(specifier: any): boolean;
|
|
46
|
+
export declare function mayContainJsxAutoComponentEntry(source: string): boolean;
|
|
47
|
+
export declare function defaultIsDefineComponentSource(source: string): source is "vue";
|
|
48
|
+
export declare function getJsxImportedName(imported: any): any;
|
|
49
|
+
export declare function createJsxImportedComponent(localName: string, importSource: string, kind: JsxImportedComponent['kind'], imported?: any): JsxImportedComponent;
|
|
50
|
+
export declare function getJsxImportLocalName(specifier: any): any;
|
|
51
|
+
export declare function isJsxDefineComponentImportSpecifier(specifier: any): boolean;
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/operations/jsxAutoComponents/index.d.ts
|
|
54
54
|
/**
|
|
55
55
|
* 从 JSX 源码中收集自动 usingComponents 所需的导入组件与模板标签。
|
|
56
56
|
*/
|
|
57
|
-
declare function collectJsxAutoComponentsFromCode(source: string, options: JsxAutoComponentAnalysisOptions): JsxAutoComponentContext;
|
|
58
|
-
//#endregion
|
|
59
|
-
export { JsxAutoComponentAnalysisOptions, JsxAutoComponentContext, JsxBabelModuleAnalysisOptions, JsxImportedComponent, collectJsxAutoComponentsFromCode, collectJsxAutoComponentsWithBabel, collectJsxAutoComponentsWithOxc, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, collectJsxTemplateTagsFromOxc, createJsxImportedComponent, defaultIsDefineComponentSource, defaultResolveBabelComponentExpression, defaultResolveBabelRenderExpression, getJsxImportLocalName, getJsxImportedName, getJsxOxcStaticPropertyName, isJsxDefineComponentImportSpecifier, mayContainJsxAutoComponentEntry, resolveOxcComponentExpression, resolveOxcRenderExpression, unwrapOxcExpression };
|
|
57
|
+
export declare function collectJsxAutoComponentsFromCode(source: string, options: JsxAutoComponentAnalysisOptions): JsxAutoComponentContext;
|
|
58
|
+
//#endregion
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { n as AstParserLike, t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
2
2
|
import { Program } from "@oxc-project/types";
|
|
3
3
|
//#region src/operations/platformApi.d.ts
|
|
4
|
-
declare const platformApiIdentifierList: readonly ["wx", "my", "tt", "swan", "jd", "xhs"];
|
|
5
|
-
declare const platformApiIdentifiers: Set<"wx" | "my" | "tt" | "swan" | "jd" | "xhs">;
|
|
6
|
-
declare function isPlatformApiIdentifier(name: string): boolean;
|
|
7
|
-
declare function mayContainPlatformApiIdentifierByText(code: string): boolean;
|
|
8
|
-
declare function isPlatformApiMemberExpression(node: any): boolean;
|
|
9
|
-
declare function hasPlatformApiMemberExpression(ast: Program): boolean;
|
|
4
|
+
export declare const platformApiIdentifierList: readonly ["wx", "my", "tt", "swan", "jd", "xhs"];
|
|
5
|
+
export declare const platformApiIdentifiers: Set<"wx" | "my" | "tt" | "swan" | "jd" | "xhs">;
|
|
6
|
+
export declare function isPlatformApiIdentifier(name: string): boolean;
|
|
7
|
+
export declare function mayContainPlatformApiIdentifierByText(code: string): boolean;
|
|
8
|
+
export declare function isPlatformApiMemberExpression(node: any): boolean;
|
|
9
|
+
export declare function hasPlatformApiMemberExpression(ast: Program): boolean;
|
|
10
10
|
/**
|
|
11
11
|
* 使用统一 AST 入口做平台 API 访问预判。
|
|
12
12
|
*/
|
|
13
|
-
declare function mayContainPlatformApiAccess(code: string, options?: {
|
|
13
|
+
export declare function mayContainPlatformApiAccess(code: string, options?: {
|
|
14
14
|
engine?: AstEngineName;
|
|
15
15
|
parserLike?: AstParserLike;
|
|
16
16
|
}): boolean;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { hasPlatformApiMemberExpression, isPlatformApiIdentifier, isPlatformApiMemberExpression, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, platformApiIdentifierList, platformApiIdentifiers };
|
|
17
|
+
//#endregion
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { n as AstParserLike, t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
2
2
|
import { Program } from "@oxc-project/types";
|
|
3
3
|
//#region src/operations/require.d.ts
|
|
4
|
-
interface RequireToken {
|
|
4
|
+
export interface RequireToken {
|
|
5
5
|
start: number;
|
|
6
6
|
end: number;
|
|
7
7
|
value: string;
|
|
8
8
|
async?: boolean;
|
|
9
9
|
}
|
|
10
|
-
interface DynamicImportToken {
|
|
10
|
+
export interface DynamicImportToken {
|
|
11
11
|
callEnd: number;
|
|
12
12
|
callStart: number;
|
|
13
13
|
end: number;
|
|
14
14
|
start: number;
|
|
15
15
|
value: string;
|
|
16
16
|
}
|
|
17
|
-
interface RequireCallbackToken extends RequireToken {
|
|
17
|
+
export interface RequireCallbackToken extends RequireToken {
|
|
18
18
|
callEnd: number;
|
|
19
19
|
callStart: number;
|
|
20
20
|
errorCallbackEnd?: number;
|
|
@@ -22,33 +22,32 @@ interface RequireCallbackToken extends RequireToken {
|
|
|
22
22
|
successCallbackEnd: number;
|
|
23
23
|
successCallbackStart: number;
|
|
24
24
|
}
|
|
25
|
-
declare function mayContainRequireCallByText(code: string): boolean;
|
|
26
|
-
declare function getStaticRequireLiteralValue(node: any): any;
|
|
25
|
+
export declare function mayContainRequireCallByText(code: string): boolean;
|
|
26
|
+
export declare function getStaticRequireLiteralValue(node: any): any;
|
|
27
27
|
/**
|
|
28
28
|
* 收集 `require.async()` 依赖字面量。
|
|
29
29
|
*/
|
|
30
|
-
declare function getRequireAsyncLiteralToken(node: any): RequireToken | null;
|
|
30
|
+
export declare function getRequireAsyncLiteralToken(node: any): RequireToken | null;
|
|
31
31
|
/**
|
|
32
32
|
* 收集 `require(path, callback)` 依赖字面量。
|
|
33
33
|
*/
|
|
34
|
-
declare function getRequireCallbackLiteralToken(node: any): RequireCallbackToken | null;
|
|
34
|
+
export declare function getRequireCallbackLiteralToken(node: any): RequireCallbackToken | null;
|
|
35
35
|
/**
|
|
36
36
|
* 收集静态 `import()` 依赖字面量。
|
|
37
37
|
*/
|
|
38
|
-
declare function getDynamicImportLiteralToken(node: any): DynamicImportToken | null;
|
|
39
|
-
declare function collectRequireTokens(ast: unknown): {
|
|
38
|
+
export declare function getDynamicImportLiteralToken(node: any): DynamicImportToken | null;
|
|
39
|
+
export declare function collectRequireTokens(ast: unknown): {
|
|
40
40
|
dynamicImportTokens: DynamicImportToken[];
|
|
41
41
|
requireCallbackTokens: RequireCallbackToken[];
|
|
42
42
|
requireTokens: RequireToken[];
|
|
43
43
|
};
|
|
44
|
-
declare function isStaticRequireCall(node: any): boolean;
|
|
45
|
-
declare function hasStaticRequireCall(ast: Program): boolean;
|
|
44
|
+
export declare function isStaticRequireCall(node: any): boolean;
|
|
45
|
+
export declare function hasStaticRequireCall(ast: Program): boolean;
|
|
46
46
|
/**
|
|
47
47
|
* 使用统一 AST 入口预判是否存在可静态分析的 `require("...")` / ``require(`...`)``。
|
|
48
48
|
*/
|
|
49
|
-
declare function mayContainStaticRequireLiteral(code: string, options?: {
|
|
49
|
+
export declare function mayContainStaticRequireLiteral(code: string, options?: {
|
|
50
50
|
engine?: AstEngineName;
|
|
51
51
|
parserLike?: AstParserLike;
|
|
52
52
|
}): boolean;
|
|
53
|
-
//#endregion
|
|
54
|
-
export { DynamicImportToken, RequireCallbackToken, RequireToken, collectRequireTokens, getDynamicImportLiteralToken, getRequireAsyncLiteralToken, getRequireCallbackLiteralToken, getStaticRequireLiteralValue, hasStaticRequireCall, isStaticRequireCall, mayContainRequireCallByText, mayContainStaticRequireLiteral };
|
|
53
|
+
//#endregion
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
2
2
|
//#region src/operations/scriptSetupImports.d.ts
|
|
3
|
-
interface ScriptSetupImport {
|
|
3
|
+
export interface ScriptSetupImport {
|
|
4
4
|
localName: string;
|
|
5
5
|
importSource: string;
|
|
6
6
|
importedName?: string;
|
|
7
7
|
kind: 'default' | 'named';
|
|
8
8
|
}
|
|
9
|
-
declare function mayContainRelevantScriptSetupImports(scriptSetup: string, templateComponentNames: Set<string>): boolean;
|
|
10
|
-
declare function getScriptSetupImportedName(imported: any): any;
|
|
11
|
-
declare function createScriptSetupImport(localName: string, importSource: string, kind: ScriptSetupImport['kind'], imported?: any): ScriptSetupImport;
|
|
12
|
-
declare function collectScriptSetupImportsWithOxc(scriptSetup: string, templateComponentNames: Set<string>): ScriptSetupImport[];
|
|
13
|
-
declare function collectScriptSetupImportsWithBabel(scriptSetup: string, templateComponentNames: Set<string>): ScriptSetupImport[];
|
|
9
|
+
export declare function mayContainRelevantScriptSetupImports(scriptSetup: string, templateComponentNames: Set<string>): boolean;
|
|
10
|
+
export declare function getScriptSetupImportedName(imported: any): any;
|
|
11
|
+
export declare function createScriptSetupImport(localName: string, importSource: string, kind: ScriptSetupImport['kind'], imported?: any): ScriptSetupImport;
|
|
12
|
+
export declare function collectScriptSetupImportsWithOxc(scriptSetup: string, templateComponentNames: Set<string>): ScriptSetupImport[];
|
|
13
|
+
export declare function collectScriptSetupImportsWithBabel(scriptSetup: string, templateComponentNames: Set<string>): ScriptSetupImport[];
|
|
14
14
|
/**
|
|
15
15
|
* 收集 `<script setup>` 中会参与自动 usingComponents 的导入声明。
|
|
16
16
|
*/
|
|
17
|
-
declare function collectScriptSetupImportsFromCode(scriptSetup: string, templateComponentNames: Set<string>, options?: {
|
|
17
|
+
export declare function collectScriptSetupImportsFromCode(scriptSetup: string, templateComponentNames: Set<string>, options?: {
|
|
18
18
|
astEngine?: AstEngineName;
|
|
19
19
|
}): ScriptSetupImport[];
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ScriptSetupImport, collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, createScriptSetupImport, getScriptSetupImportedName, mayContainRelevantScriptSetupImports };
|
|
20
|
+
//#endregion
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
|
|
2
2
|
//#region src/operations/setDataPick.d.ts
|
|
3
|
-
declare function collectLoopScopeAliases(template: string): Set<string>;
|
|
4
|
-
declare function extractTemplateExpressions(template: string): string[];
|
|
5
|
-
declare function collectIdentifiersFromExpression(expression: string): Set<string>;
|
|
6
|
-
declare function collectPatternBindingNames(node: any, bindings: Set<string>): void;
|
|
7
|
-
declare function hasBindingInScopes(scopes: Set<string>[], name: string): boolean;
|
|
8
|
-
declare function collectIdentifiersFromExpressionWithOxc(expression: string): Set<string>;
|
|
9
|
-
declare function collectSetDataPickKeysWithBabel(template: string): string[];
|
|
10
|
-
declare function collectSetDataPickKeysWithOxc(template: string): string[];
|
|
3
|
+
export declare function collectLoopScopeAliases(template: string): Set<string>;
|
|
4
|
+
export declare function extractTemplateExpressions(template: string): string[];
|
|
5
|
+
export declare function collectIdentifiersFromExpression(expression: string): Set<string>;
|
|
6
|
+
export declare function collectPatternBindingNames(node: any, bindings: Set<string>): void;
|
|
7
|
+
export declare function hasBindingInScopes(scopes: Set<string>[], name: string): boolean;
|
|
8
|
+
export declare function collectIdentifiersFromExpressionWithOxc(expression: string): Set<string>;
|
|
9
|
+
export declare function collectSetDataPickKeysWithBabel(template: string): string[];
|
|
10
|
+
export declare function collectSetDataPickKeysWithOxc(template: string): string[];
|
|
11
11
|
/**
|
|
12
12
|
* 从编译后的 WXML 模板提取渲染相关的顶层 key。
|
|
13
13
|
*
|
|
14
14
|
* 根据 AST 引擎从编译后的 WXML 模板提取渲染相关的顶层 key。
|
|
15
15
|
*/
|
|
16
|
-
declare function collectSetDataPickKeysFromTemplateCode(template: string, options?: {
|
|
16
|
+
export declare function collectSetDataPickKeysFromTemplateCode(template: string, options?: {
|
|
17
17
|
astEngine?: AstEngineName;
|
|
18
18
|
}): string[];
|
|
19
|
-
//#endregion
|
|
20
|
-
export { collectIdentifiersFromExpression, collectIdentifiersFromExpressionWithOxc, collectLoopScopeAliases, collectPatternBindingNames, collectSetDataPickKeysFromTemplateCode, collectSetDataPickKeysWithBabel, collectSetDataPickKeysWithOxc, extractTemplateExpressions, hasBindingInScopes };
|
|
19
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/ast",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0
|
|
4
|
+
"version": "7.1.0",
|
|
5
5
|
"description": "weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -106,9 +106,9 @@
|
|
|
106
106
|
"@babel/parser": "^8.0.4",
|
|
107
107
|
"@babel/traverse": "^8.0.4",
|
|
108
108
|
"@babel/types": "^8.0.4",
|
|
109
|
-
"@oxc-project/types": "^0.
|
|
109
|
+
"@oxc-project/types": "^0.149.0",
|
|
110
110
|
"@weapp-core/shared": "3.2.1",
|
|
111
|
-
"oxc-parser": "^0.
|
|
111
|
+
"oxc-parser": "^0.149.0",
|
|
112
112
|
"oxc-walker": "^1.1.1"
|
|
113
113
|
},
|
|
114
114
|
"publishConfig": {
|