@weapp-vite/ast 6.24.0 → 6.25.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/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { parseJsLikeWithEngine } from "./engine.mjs";
|
|
|
5
5
|
import { ComponentPropMap, collectComponentPropsFromCode, collectComponentPropsWithBabel, collectComponentPropsWithOxc, extractComponentProperties, extractPropertiesObject, getStaticPropertyName, mapConstructorName, mayContainComponentPropsShape, mergeComponentPropTypes, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveTypeFromNode } from "./operations/componentProps.mjs";
|
|
6
6
|
import { FeatureFlagOptions, collectFeatureFlagsFromCode, collectFeatureFlagsWithBabel, collectFeatureFlagsWithNative, collectFeatureFlagsWithNativeBatch, collectFeatureFlagsWithOxc, consumeNamedFeatureFlag, consumeNamespaceFeatureFlag, mayContainFeatureFlagHints, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal } from "./operations/featureFlags.mjs";
|
|
7
7
|
import { JsxAutoComponentAnalysisOptions, JsxAutoComponentContext, JsxBabelModuleAnalysisOptions, JsxImportedComponent, collectJsxAutoComponentsFromCode, collectJsxAutoComponentsWithBabel, collectJsxAutoComponentsWithOxc, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, collectJsxTemplateTagsFromOxc, createJsxImportedComponent, defaultIsDefineComponentSource, defaultResolveBabelComponentExpression, defaultResolveBabelRenderExpression, getJsxImportLocalName, getJsxImportedName, getJsxOxcStaticPropertyName, isJsxDefineComponentImportSpecifier, mayContainJsxAutoComponentEntry, resolveOxcComponentExpression, resolveOxcRenderExpression, unwrapOxcExpression } from "./operations/jsxAutoComponents.mjs";
|
|
8
|
-
import { _ as collectPageScrollInspectionWithOxc, a as getCallExpressionCalleeName, c as getOnPageScrollCallbackArgument, d as getOxcStaticPropertyName, f as isOnPageScrollCallee, g as collectOnPageScrollWarningsWithOxc, h as isStaticPropertyName, i as createWarningPrefix, l as getOxcCallExpressionCalleeName, m as isOxcOnPageScrollCallee, n as collectOnPageScrollWarningsWithNative, o as getLocationFromOffset, p as isOxcFunctionLike, r as createLineStartOffsets, s as getMemberExpressionPropertyName, t as collectOnPageScrollPerformanceWarnings, u as getOxcMemberExpressionPropertyName, v as collectOnPageScrollWarningsWithBabel, y as collectPageScrollInspection } from "./onPageScroll-
|
|
8
|
+
import { _ as collectPageScrollInspectionWithOxc, a as getCallExpressionCalleeName, c as getOnPageScrollCallbackArgument, d as getOxcStaticPropertyName, f as isOnPageScrollCallee, g as collectOnPageScrollWarningsWithOxc, h as isStaticPropertyName, i as createWarningPrefix, l as getOxcCallExpressionCalleeName, m as isOxcOnPageScrollCallee, n as collectOnPageScrollWarningsWithNative, o as getLocationFromOffset, p as isOxcFunctionLike, r as createLineStartOffsets, s as getMemberExpressionPropertyName, t as collectOnPageScrollPerformanceWarnings, u as getOxcMemberExpressionPropertyName, v as collectOnPageScrollWarningsWithBabel, y as collectPageScrollInspection } from "./onPageScroll-n3Vptu1_.mjs";
|
|
9
9
|
import { hasPlatformApiMemberExpression, isPlatformApiIdentifier, isPlatformApiMemberExpression, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, platformApiIdentifierList, platformApiIdentifiers } from "./operations/platformApi.mjs";
|
|
10
10
|
import { DynamicImportToken, RequireCallbackToken, RequireToken, collectRequireTokens, getDynamicImportLiteralToken, getRequireAsyncLiteralToken, getRequireCallbackLiteralToken, getStaticRequireLiteralValue, hasStaticRequireCall, isStaticRequireCall, mayContainRequireCallByText, mayContainStaticRequireLiteral } from "./operations/require.mjs";
|
|
11
11
|
import { ScriptSetupImport, collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, createScriptSetupImport, getScriptSetupImportedName, mayContainRelevantScriptSetupImports } from "./operations/scriptSetupImports.mjs";
|
|
@@ -53,4 +53,18 @@ declare function analyzeScript<TFeature extends string = string>(code: string, o
|
|
|
53
53
|
*/
|
|
54
54
|
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
|
+
/**
|
|
58
|
+
* 收集脚本中的字符串字面量源码片段,供上层语义按需筛选。
|
|
59
|
+
*/
|
|
60
|
+
declare function collectScriptStringLiterals(code: string): string[];
|
|
61
|
+
/**
|
|
62
|
+
* 收集调用表达式中的字符串字面量源码片段。
|
|
63
|
+
*/
|
|
64
|
+
declare function collectScriptCallStringLiterals(code: string): string[];
|
|
65
|
+
/**
|
|
66
|
+
* 快速判断脚本是否包含调用或模块语法,避免上层无条件扩大候选集。
|
|
67
|
+
*/
|
|
68
|
+
declare function mayContainScriptCallOrModuleSyntax(code: string): boolean;
|
|
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, analyzeScript, analyzeScripts, babelAstEngine, 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, collectScriptCallStringLiterals, collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, collectScriptStringLiterals, 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, mayContainScriptCallOrModuleSyntax, mayContainStaticRequireLiteral, mergeComponentPropTypes, oxcAstEngine, parse, parseJsLike, parseJsLikeWithEngine, platformApiIdentifierList, platformApiIdentifiers, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveOxcComponentExpression, resolveOxcRenderExpression, resolveRenderExpressionFromComponentOptions, resolveRenderableExpression, resolveTypeFromNode, toStaticObjectKey, traverse, unwrapOxcExpression, unwrapTypeScriptExpression };
|
package/dist/index.mjs
CHANGED
|
@@ -65,4 +65,31 @@ function analyzeScripts(inputs, options) {
|
|
|
65
65
|
}));
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
-
|
|
68
|
+
//#region src/operations/scriptLiterals.ts
|
|
69
|
+
const JS_STRING_LITERALS_RE = /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g;
|
|
70
|
+
const SCRIPT_CALL_EXPRESSION_RE = /\b[$a-z_][\w$]*\s*\((?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[^()"'`])*\)/gi;
|
|
71
|
+
const SCRIPT_CALL_OR_MODULE_RE = /\b(?:import|export)\b|\b[$a-z_][\w$]*\s*\(/i;
|
|
72
|
+
/**
|
|
73
|
+
* 收集脚本中的字符串字面量源码片段,供上层语义按需筛选。
|
|
74
|
+
*/
|
|
75
|
+
function collectScriptStringLiterals(code) {
|
|
76
|
+
const candidates = [];
|
|
77
|
+
for (const match of code.matchAll(JS_STRING_LITERALS_RE)) candidates.push(match[0]);
|
|
78
|
+
return candidates;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 收集调用表达式中的字符串字面量源码片段。
|
|
82
|
+
*/
|
|
83
|
+
function collectScriptCallStringLiterals(code) {
|
|
84
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
85
|
+
for (const callMatch of code.matchAll(SCRIPT_CALL_EXPRESSION_RE)) for (const literalMatch of callMatch[0].matchAll(JS_STRING_LITERALS_RE)) candidates.add(literalMatch[0]);
|
|
86
|
+
return Array.from(candidates).sort();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 快速判断脚本是否包含调用或模块语法,避免上层无条件扩大候选集。
|
|
90
|
+
*/
|
|
91
|
+
function mayContainScriptCallOrModuleSyntax(code) {
|
|
92
|
+
return SCRIPT_CALL_OR_MODULE_RE.test(code);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { BABEL_TS_MODULE_PARSER_OPTIONS, BABEL_TS_MODULE_PLUGINS, analyzeScript, analyzeScripts, babelAstEngine, 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, collectScriptCallStringLiterals, collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, collectScriptStringLiterals, 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, mayContainScriptCallOrModuleSyntax, mayContainStaticRequireLiteral, mergeComponentPropTypes, oxcAstEngine, parse, parseJsLike, parseJsLikeWithEngine, platformApiIdentifierList, platformApiIdentifiers, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveOxcComponentExpression, resolveOxcRenderExpression, resolveRenderExpressionFromComponentOptions, resolveRenderableExpression, resolveTypeFromNode, toStaticObjectKey, traverse, unwrapOxcExpression, unwrapTypeScriptExpression };
|
|
@@ -26,7 +26,7 @@ declare function isOnPageScrollCallee(callee: t.Expression | t.V8IntrinsicIdenti
|
|
|
26
26
|
declare function getCallExpressionCalleeName(callee: t.Expression | t.V8IntrinsicIdentifier): string | undefined;
|
|
27
27
|
declare function getOnPageScrollCallbackArgument(node: {
|
|
28
28
|
arguments?: Array<t.Expression | t.SpreadElement | t.ArgumentPlaceholder | null>;
|
|
29
|
-
}): t.
|
|
29
|
+
}): t.FunctionExpression | t.ArrowFunctionExpression | undefined;
|
|
30
30
|
declare function createWarningPrefix(filename: string, line?: number, column?: number): string;
|
|
31
31
|
declare function getOxcStaticPropertyName(node: any): string | undefined;
|
|
32
32
|
declare function getOxcMemberExpressionPropertyName(node: any): string | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as collectPageScrollInspectionWithOxc, a as getCallExpressionCalleeName, c as getOnPageScrollCallbackArgument, d as getOxcStaticPropertyName, f as isOnPageScrollCallee, g as collectOnPageScrollWarningsWithOxc, h as isStaticPropertyName, i as createWarningPrefix, l as getOxcCallExpressionCalleeName, m as isOxcOnPageScrollCallee, n as collectOnPageScrollWarningsWithNative, o as getLocationFromOffset, p as isOxcFunctionLike, r as createLineStartOffsets, s as getMemberExpressionPropertyName, t as collectOnPageScrollPerformanceWarnings, u as getOxcMemberExpressionPropertyName, v as collectOnPageScrollWarningsWithBabel, y as collectPageScrollInspection } from "../onPageScroll-
|
|
1
|
+
import { _ as collectPageScrollInspectionWithOxc, a as getCallExpressionCalleeName, c as getOnPageScrollCallbackArgument, d as getOxcStaticPropertyName, f as isOnPageScrollCallee, g as collectOnPageScrollWarningsWithOxc, h as isStaticPropertyName, i as createWarningPrefix, l as getOxcCallExpressionCalleeName, m as isOxcOnPageScrollCallee, n as collectOnPageScrollWarningsWithNative, o as getLocationFromOffset, p as isOxcFunctionLike, r as createLineStartOffsets, s as getMemberExpressionPropertyName, t as collectOnPageScrollPerformanceWarnings, u as getOxcMemberExpressionPropertyName, v as collectOnPageScrollWarningsWithBabel, y as collectPageScrollInspection } from "../onPageScroll-n3Vptu1_.mjs";
|
|
2
2
|
export { collectOnPageScrollPerformanceWarnings, collectOnPageScrollWarningsWithBabel, collectOnPageScrollWarningsWithNative, collectOnPageScrollWarningsWithOxc, collectPageScrollInspection, collectPageScrollInspectionWithOxc, createLineStartOffsets, createWarningPrefix, getCallExpressionCalleeName, getLocationFromOffset, getMemberExpressionPropertyName, getOnPageScrollCallbackArgument, getOxcCallExpressionCalleeName, getOxcMemberExpressionPropertyName, getOxcStaticPropertyName, isOnPageScrollCallee, isOxcFunctionLike, isOxcOnPageScrollCallee, isStaticPropertyName };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/ast",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.25.0",
|
|
5
5
|
"description": "weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -121,6 +121,7 @@
|
|
|
121
121
|
"check:release": "pnpm build && pnpm typecheck && pnpm test && npm pack --dry-run . --cache ../../.cache/npm",
|
|
122
122
|
"test": "vitest run --config ./vitest.config.ts",
|
|
123
123
|
"test:dev": "vitest --config ./vitest.config.ts",
|
|
124
|
+
"test:types": "pnpm build && tsd",
|
|
124
125
|
"typecheck": "tsc --noEmit -p ./tsconfig.json",
|
|
125
126
|
"release": "pnpm publish",
|
|
126
127
|
"lint": "eslint .",
|