@weapp-vite/ast 6.16.46 → 6.17.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.mjs +1 -9
- package/dist/babelCore.d.mts +35 -2
- package/dist/babelCore.mjs +6 -2
- package/dist/babelNodes.d.mts +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{onPageScroll-RxvH7Pi_.mjs → onPageScroll-BDuUZSSJ.mjs} +28 -37
- package/dist/{onPageScroll-C1BbvMzn.d.mts → onPageScroll-DpsTdS_S.d.mts} +1 -1
- package/dist/operations/componentProps.mjs +7 -2
- package/dist/operations/featureFlags.mjs +2 -1
- package/dist/operations/onPageScroll.d.mts +1 -1
- package/dist/operations/onPageScroll.mjs +1 -1
- package/package.json +8 -8
package/dist/babel.mjs
CHANGED
|
@@ -3,9 +3,6 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
const BABEL_TS_MODULE_PLUGINS = [
|
|
4
4
|
"typescript",
|
|
5
5
|
"decorators-legacy",
|
|
6
|
-
"classProperties",
|
|
7
|
-
"classPrivateProperties",
|
|
8
|
-
"classPrivateMethods",
|
|
9
6
|
"jsx"
|
|
10
7
|
];
|
|
11
8
|
const BABEL_TS_MODULE_PARSER_OPTIONS = {
|
|
@@ -52,12 +49,7 @@ function getVisitorKeys() {
|
|
|
52
49
|
function parseJsLike(source) {
|
|
53
50
|
return parse(source, {
|
|
54
51
|
sourceType: "module",
|
|
55
|
-
plugins: [
|
|
56
|
-
...BABEL_TS_MODULE_PLUGINS,
|
|
57
|
-
"dynamicImport",
|
|
58
|
-
"optionalChaining",
|
|
59
|
-
"nullishCoalescingOperator"
|
|
60
|
-
]
|
|
52
|
+
plugins: [...BABEL_TS_MODULE_PLUGINS]
|
|
61
53
|
});
|
|
62
54
|
}
|
|
63
55
|
//#endregion
|
package/dist/babelCore.d.mts
CHANGED
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as BabelCore from "@babel/core";
|
|
2
|
+
import { InputOptions as TransformOptions, NodePath } from "@babel/core";
|
|
3
|
+
|
|
4
|
+
//#region src/babelCore.d.ts
|
|
5
|
+
declare const babelCore: typeof BabelCore;
|
|
6
|
+
declare const parse: {
|
|
7
|
+
(code: string, callback: {
|
|
8
|
+
(err: Error, ast: null): void;
|
|
9
|
+
(err: null, ast: import("@babel/parser").ParseResult | null): void;
|
|
10
|
+
}): void;
|
|
11
|
+
(code: string, opts: BabelCore.InputOptions | undefined | null, callback: {
|
|
12
|
+
(err: Error, ast: null): void;
|
|
13
|
+
(err: null, ast: import("@babel/parser").ParseResult | null): void;
|
|
14
|
+
}): void;
|
|
15
|
+
}, parseAsync: typeof BabelCore.parseAsync, parseSync: typeof BabelCore.parseSync, transform: {
|
|
16
|
+
(code: string, callback: {
|
|
17
|
+
(err: Error, file: null): void;
|
|
18
|
+
(err: null, file: BabelCore.FileResult | null): void;
|
|
19
|
+
}): void;
|
|
20
|
+
(code: string, opts: BabelCore.InputOptions | undefined | null, callback: {
|
|
21
|
+
(err: Error, file: null): void;
|
|
22
|
+
(err: null, file: BabelCore.FileResult | null): void;
|
|
23
|
+
}): void;
|
|
24
|
+
}, transformAsync: typeof BabelCore.transformAsync, transformFile: typeof BabelCore.transformFile, transformFileAsync: typeof BabelCore.transformFileAsync, transformFileSync: typeof BabelCore.transformFileSync, transformFromAst: {
|
|
25
|
+
(ast: BabelCore.types.File | BabelCore.types.Program, code: string, callback: {
|
|
26
|
+
(err: Error, file: null): void;
|
|
27
|
+
(err: null, file: BabelCore.FileResult | null): void;
|
|
28
|
+
}): void;
|
|
29
|
+
(ast: BabelCore.types.File | BabelCore.types.Program, code: string, opts: BabelCore.InputOptions | undefined | null, callback: {
|
|
30
|
+
(err: Error, file: null): void;
|
|
31
|
+
(err: null, file: BabelCore.FileResult | null): void;
|
|
32
|
+
}): void;
|
|
33
|
+
}, transformFromAstAsync: typeof BabelCore.transformFromAstAsync, transformFromAstSync: typeof BabelCore.transformFromAstSync, transformSync: typeof BabelCore.transformSync, types: typeof BabelCore.types, version: string;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type NodePath, type TransformOptions, babelCore as default, parse, parseAsync, parseSync, transform, transformAsync, transformFile, transformFileAsync, transformFileSync, transformFromAst, transformFromAstAsync, transformFromAstSync, transformSync, types, version };
|
package/dist/babelCore.mjs
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region src/babelCore.ts
|
|
3
|
+
const babelCore = createRequire(import.meta.url)("@babel/core");
|
|
4
|
+
const { parse, parseAsync, parseSync, transform, transformAsync, transformFile, transformFileAsync, transformFileSync, transformFromAst, transformFromAstAsync, transformFromAstSync, transformSync, types, version } = babelCore;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { babelCore as default, parse, parseAsync, parseSync, transform, transformAsync, transformFile, transformFileAsync, transformFileSync, transformFromAst, transformFromAstAsync, transformFromAstSync, transformSync, types, version };
|
package/dist/babelNodes.d.mts
CHANGED
|
@@ -4,8 +4,8 @@ import { Expression, ObjectExpression, ObjectMethod, ObjectProperty, PrivateName
|
|
|
4
4
|
//#region src/babelNodes.d.ts
|
|
5
5
|
declare function unwrapTypeScriptExpression(exp: Expression): Expression;
|
|
6
6
|
declare function toStaticObjectKey(key: Expression | PrivateName | t.Identifier): string | null;
|
|
7
|
-
declare function getObjectPropertyByKey(node: ObjectExpression, key: string): ObjectMethod |
|
|
8
|
-
declare function getRenderPropertyFromComponentOptions(componentExpr: Expression): ObjectMethod |
|
|
7
|
+
declare function getObjectPropertyByKey(node: ObjectExpression, key: string): ObjectMethod | t.ObjectPropertyNonComputed | null;
|
|
8
|
+
declare function getRenderPropertyFromComponentOptions(componentExpr: Expression): ObjectMethod | t.ObjectPropertyNonComputed | null;
|
|
9
9
|
declare function resolveRenderableExpression(node: ObjectMethod | ObjectProperty): Expression | null;
|
|
10
10
|
declare function resolveRenderExpressionFromComponentOptions(componentExpr: Expression): Expression | null;
|
|
11
11
|
//#endregion
|
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, 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 collectOnPageScrollWarningsWithBabel, a as getLocationFromOffset, c as getOxcCallExpressionCalleeName, d as isOnPageScrollCallee, f as isOxcFunctionLike, g as collectPageScrollInspectionWithOxc, h as collectOnPageScrollWarningsWithOxc, i as getCallExpressionCalleeName, l as getOxcMemberExpressionPropertyName, m as isStaticPropertyName, n as createLineStartOffsets, o as getMemberExpressionPropertyName, p as isOxcOnPageScrollCallee, r as createWarningPrefix, s as getOnPageScrollCallbackArgument, t as collectOnPageScrollPerformanceWarnings, u as getOxcStaticPropertyName, v as collectPageScrollInspection } from "./onPageScroll-
|
|
8
|
+
import { _ as collectOnPageScrollWarningsWithBabel, a as getLocationFromOffset, c as getOxcCallExpressionCalleeName, d as isOnPageScrollCallee, f as isOxcFunctionLike, g as collectPageScrollInspectionWithOxc, h as collectOnPageScrollWarningsWithOxc, i as getCallExpressionCalleeName, l as getOxcMemberExpressionPropertyName, m as isStaticPropertyName, n as createLineStartOffsets, o as getMemberExpressionPropertyName, p as isOxcOnPageScrollCallee, r as createWarningPrefix, s as getOnPageScrollCallbackArgument, t as collectOnPageScrollPerformanceWarnings, u as getOxcStaticPropertyName, v as collectPageScrollInspection } from "./onPageScroll-DpsTdS_S.mjs";
|
|
9
9
|
import { hasPlatformApiMemberExpression, isPlatformApiIdentifier, isPlatformApiMemberExpression, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, platformApiIdentifierList, platformApiIdentifiers } from "./operations/platformApi.mjs";
|
|
10
10
|
import { RequireToken, collectRequireTokens, getRequireAsyncLiteralToken, getStaticRequireLiteralValue, hasStaticRequireCall, isStaticRequireCall, mayContainRequireCallByText, mayContainStaticRequireLiteral } from "./operations/require.mjs";
|
|
11
11
|
import { ScriptSetupImport, collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, createScriptSetupImport, getScriptSetupImportedName, mayContainRelevantScriptSetupImports } from "./operations/scriptSetupImports.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { n as oxcAstEngine, r as babelAstEngine, t as parseJsLikeWithEngine } fr
|
|
|
4
4
|
import { collectComponentPropsFromCode, collectComponentPropsWithBabel, collectComponentPropsWithOxc, extractComponentProperties, extractPropertiesObject, getStaticPropertyName, mapConstructorName, mayContainComponentPropsShape, mergeComponentPropTypes, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveTypeFromNode } from "./operations/componentProps.mjs";
|
|
5
5
|
import { collectFeatureFlagsFromCode, collectFeatureFlagsWithBabel, collectFeatureFlagsWithOxc, consumeNamedFeatureFlag, consumeNamespaceFeatureFlag, mayContainFeatureFlagHints, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal } from "./operations/featureFlags.mjs";
|
|
6
6
|
import { collectJsxAutoComponentsFromCode, collectJsxAutoComponentsWithBabel, collectJsxAutoComponentsWithOxc, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, collectJsxTemplateTagsFromOxc, createJsxImportedComponent, defaultIsDefineComponentSource, defaultResolveBabelComponentExpression, defaultResolveBabelRenderExpression, getJsxImportLocalName, getJsxImportedName, getJsxOxcStaticPropertyName, isJsxDefineComponentImportSpecifier, mayContainJsxAutoComponentEntry, resolveOxcComponentExpression, resolveOxcRenderExpression, unwrapOxcExpression } from "./operations/jsxAutoComponents.mjs";
|
|
7
|
-
import { _ as isOxcOnPageScrollCallee, a as collectPageScrollInspection, c as getCallExpressionCalleeName, d as getOnPageScrollCallbackArgument, f as getOxcCallExpressionCalleeName, g as isOxcFunctionLike, h as isOnPageScrollCallee, i as collectOnPageScrollWarningsWithBabel, l as getLocationFromOffset, m as getOxcStaticPropertyName, n as collectOnPageScrollWarningsWithOxc, o as createLineStartOffsets, p as getOxcMemberExpressionPropertyName, r as collectPageScrollInspectionWithOxc, s as createWarningPrefix, t as collectOnPageScrollPerformanceWarnings, u as getMemberExpressionPropertyName, v as isStaticPropertyName } from "./onPageScroll-
|
|
7
|
+
import { _ as isOxcOnPageScrollCallee, a as collectPageScrollInspection, c as getCallExpressionCalleeName, d as getOnPageScrollCallbackArgument, f as getOxcCallExpressionCalleeName, g as isOxcFunctionLike, h as isOnPageScrollCallee, i as collectOnPageScrollWarningsWithBabel, l as getLocationFromOffset, m as getOxcStaticPropertyName, n as collectOnPageScrollWarningsWithOxc, o as createLineStartOffsets, p as getOxcMemberExpressionPropertyName, r as collectPageScrollInspectionWithOxc, s as createWarningPrefix, t as collectOnPageScrollPerformanceWarnings, u as getMemberExpressionPropertyName, v as isStaticPropertyName } from "./onPageScroll-BDuUZSSJ.mjs";
|
|
8
8
|
import { hasPlatformApiMemberExpression, isPlatformApiIdentifier, isPlatformApiMemberExpression, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, platformApiIdentifierList, platformApiIdentifiers } from "./operations/platformApi.mjs";
|
|
9
9
|
import { collectRequireTokens, getRequireAsyncLiteralToken, getStaticRequireLiteralValue, hasStaticRequireCall, isStaticRequireCall, mayContainRequireCallByText, mayContainStaticRequireLiteral } from "./operations/require.mjs";
|
|
10
10
|
import { collectScriptSetupImportsFromCode, collectScriptSetupImportsWithBabel, collectScriptSetupImportsWithOxc, createScriptSetupImport, getScriptSetupImportedName, mayContainRelevantScriptSetupImports } from "./operations/scriptSetupImports.mjs";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseJsLike, traverse } from "./babel.mjs";
|
|
2
2
|
import { t as parseJsLikeWithEngine } from "./engine-CBE2OpFp.mjs";
|
|
3
|
+
import { walk } from "oxc-walker";
|
|
3
4
|
//#region src/operations/onPageScroll/shared.ts
|
|
4
5
|
function isStaticPropertyName(key) {
|
|
5
6
|
if (key.type === "Identifier") return key.name;
|
|
@@ -169,6 +170,9 @@ function collectOnPageScrollWarningsWithBabel(code, filename) {
|
|
|
169
170
|
}
|
|
170
171
|
//#endregion
|
|
171
172
|
//#region src/operations/onPageScroll/oxc.ts
|
|
173
|
+
function isOxcNestedFunctionBoundary(node) {
|
|
174
|
+
return isOxcFunctionLike(node) || node?.type === "FunctionDeclaration";
|
|
175
|
+
}
|
|
172
176
|
function collectPageScrollInspectionWithOxc(node) {
|
|
173
177
|
const inspection = {
|
|
174
178
|
empty: node.body?.type === "BlockStatement" && node.body.body.length === 0,
|
|
@@ -176,27 +180,20 @@ function collectPageScrollInspectionWithOxc(node) {
|
|
|
176
180
|
syncApis: /* @__PURE__ */ new Set()
|
|
177
181
|
};
|
|
178
182
|
const root = node.body?.type === "BlockStatement" ? node.body : node.body;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (current
|
|
183
|
-
|
|
184
|
-
if (current.callee?.type === "MemberExpression" && current.callee.object?.type === "Identifier" && current.callee.object.name === "wx") {
|
|
185
|
-
const propertyName = getOxcMemberExpressionPropertyName(current.callee);
|
|
186
|
-
if (propertyName && propertyName.endsWith("Sync")) inspection.syncApis.add(`wx.${propertyName}`);
|
|
187
|
-
}
|
|
188
|
-
} else if (current.type === "ChainExpression") {
|
|
189
|
-
visit(current.expression, allowNestedFunctions);
|
|
183
|
+
if (!root) return inspection;
|
|
184
|
+
walk(root, { enter(node) {
|
|
185
|
+
const current = node;
|
|
186
|
+
if (current !== root && isOxcNestedFunctionBoundary(current)) {
|
|
187
|
+
this.skip();
|
|
190
188
|
return;
|
|
191
189
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
if (current.type !== "CallExpression") return;
|
|
191
|
+
if (getOxcCallExpressionCalleeName(current.callee) === "setData") inspection.hasSetDataCall = true;
|
|
192
|
+
if (current.callee?.type === "MemberExpression" && current.callee.object?.type === "Identifier" && current.callee.object.name === "wx") {
|
|
193
|
+
const propertyName = getOxcMemberExpressionPropertyName(current.callee);
|
|
194
|
+
if (propertyName && propertyName.endsWith("Sync")) inspection.syncApis.add(`wx.${propertyName}`);
|
|
197
195
|
}
|
|
198
|
-
}
|
|
199
|
-
if (root) visit(root, true);
|
|
196
|
+
} });
|
|
200
197
|
return inspection;
|
|
201
198
|
}
|
|
202
199
|
function collectOnPageScrollWarningsWithOxc(code, filename) {
|
|
@@ -227,26 +224,20 @@ function collectOnPageScrollWarningsWithOxc(code, filename) {
|
|
|
227
224
|
if (inspection.hasSetDataCall) addWarning(`${prefix} 检测到 ${sourceLabel} 内调用 setData,建议改用节流、IntersectionObserver 或合并更新。`);
|
|
228
225
|
for (const syncApi of inspection.syncApis) addWarning(`${prefix} 检测到 ${sourceLabel} 内调用同步 API(${syncApi}),可能阻塞渲染线程。`);
|
|
229
226
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
const startOffset =
|
|
234
|
-
reportInspection(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
for (const value of Object.values(node)) {
|
|
243
|
-
if (!value) continue;
|
|
244
|
-
if (Array.isArray(value)) {
|
|
245
|
-
for (const child of value) if (child && typeof child === "object" && typeof child.type === "string") visit(child);
|
|
246
|
-
} else if (typeof value === "object" && typeof value.type === "string") visit(value);
|
|
227
|
+
walk(ast, { enter(node) {
|
|
228
|
+
const current = node;
|
|
229
|
+
if (current.type === "Property" && !current.computed && getOxcStaticPropertyName(current.key) === "onPageScroll" && isOxcFunctionLike(current.value)) {
|
|
230
|
+
const startOffset = current.method ? current.key?.end : current.value.start;
|
|
231
|
+
reportInspection(current.value, "onPageScroll", startOffset);
|
|
232
|
+
this.skip();
|
|
233
|
+
} else if (current.type === "CallExpression" && isOxcOnPageScrollCallee(current.callee, onPageScrollHookNames, namespaceImports)) {
|
|
234
|
+
const arg0 = current.arguments?.[0];
|
|
235
|
+
if (arg0 && arg0.type !== "SpreadElement" && isOxcFunctionLike(arg0)) {
|
|
236
|
+
reportInspection(arg0, "onPageScroll(...)");
|
|
237
|
+
this.skip();
|
|
238
|
+
}
|
|
247
239
|
}
|
|
248
|
-
}
|
|
249
|
-
visit(ast);
|
|
240
|
+
} });
|
|
250
241
|
return warnings;
|
|
251
242
|
}
|
|
252
243
|
//#endregion
|
|
@@ -27,7 +27,7 @@ declare function isOnPageScrollCallee(callee: t.Expression | t.V8IntrinsicIdenti
|
|
|
27
27
|
declare function getCallExpressionCalleeName(callee: t.Expression | t.V8IntrinsicIdentifier): string | undefined;
|
|
28
28
|
declare function getOnPageScrollCallbackArgument(node: {
|
|
29
29
|
arguments?: Array<t.Expression | t.SpreadElement | t.ArgumentPlaceholder | null>;
|
|
30
|
-
}): t.
|
|
30
|
+
}): t.ArrowFunctionExpression | t.FunctionExpression | undefined;
|
|
31
31
|
declare function createWarningPrefix(filename: string, line?: number, column?: number): string;
|
|
32
32
|
declare function getOxcStaticPropertyName(node: any): string | undefined;
|
|
33
33
|
declare function getOxcMemberExpressionPropertyName(node: any): string | undefined;
|
|
@@ -3,8 +3,9 @@ import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
|
|
|
3
3
|
import { walk } from "oxc-walker";
|
|
4
4
|
//#region src/operations/componentProps.ts
|
|
5
5
|
const COMPONENT_PROPS_TEXT_HINTS = ["properties", "props"];
|
|
6
|
+
const COMPONENT_OPTIONS_CALL_HINT_RE = /\b[a-z_$][\w$]*(?:\s*<[^(){};]+>)?\s*(?:\?\.\s*)?\(/i;
|
|
6
7
|
function mayContainComponentPropsShape(code) {
|
|
7
|
-
return COMPONENT_PROPS_TEXT_HINTS.some((hint) => code.includes(hint));
|
|
8
|
+
return COMPONENT_PROPS_TEXT_HINTS.some((hint) => code.includes(hint)) && COMPONENT_OPTIONS_CALL_HINT_RE.test(code);
|
|
8
9
|
}
|
|
9
10
|
const CONSTRUCTOR_TYPE_MAP = {
|
|
10
11
|
String: "string",
|
|
@@ -150,7 +151,10 @@ function collectComponentPropsWithOxc(code) {
|
|
|
150
151
|
const bindings = /* @__PURE__ */ new Map();
|
|
151
152
|
let resolved = false;
|
|
152
153
|
walk(ast, { enter(node) {
|
|
153
|
-
if (resolved)
|
|
154
|
+
if (resolved) {
|
|
155
|
+
this.skip();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
154
158
|
if (node.type === "VariableDeclarator" && node.id?.type === "Identifier") {
|
|
155
159
|
const optionsObject = resolveOptionsObjectExpression(node.init, bindings);
|
|
156
160
|
if (optionsObject) bindings.set(node.id.name, optionsObject);
|
|
@@ -162,6 +166,7 @@ function collectComponentPropsWithOxc(code) {
|
|
|
162
166
|
if (!optionsObject) return;
|
|
163
167
|
resolved = true;
|
|
164
168
|
for (const [key, value] of extractComponentProperties(optionsObject)) props.set(key, value);
|
|
169
|
+
this.skip();
|
|
165
170
|
} });
|
|
166
171
|
return props;
|
|
167
172
|
}
|
|
@@ -3,9 +3,10 @@ import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
|
|
|
3
3
|
import * as t from "@babel/types";
|
|
4
4
|
import { walk } from "oxc-walker";
|
|
5
5
|
//#region src/operations/featureFlags.ts
|
|
6
|
+
const CALL_EXPRESSION_TEXT_RE = /\b[a-z_$][\w$]*(?:\s*<[^(){};]+>)?\s*(?:\?\.\s*)?\(/i;
|
|
6
7
|
function mayContainFeatureFlagHints(code, moduleId, hookToFeature) {
|
|
7
8
|
if (!code.includes(moduleId)) return false;
|
|
8
|
-
return Object.keys(hookToFeature).some((hookName) => code.includes(hookName));
|
|
9
|
+
return CALL_EXPRESSION_TEXT_RE.test(code) && Object.keys(hookToFeature).some((hookName) => code.includes(hookName));
|
|
9
10
|
}
|
|
10
11
|
function consumeNamedFeatureFlag(enabled, namedHookLocals, name) {
|
|
11
12
|
const matched = namedHookLocals.get(name);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as collectOnPageScrollWarningsWithBabel, a as getLocationFromOffset, c as getOxcCallExpressionCalleeName, d as isOnPageScrollCallee, f as isOxcFunctionLike, g as collectPageScrollInspectionWithOxc, h as collectOnPageScrollWarningsWithOxc, i as getCallExpressionCalleeName, l as getOxcMemberExpressionPropertyName, m as isStaticPropertyName, n as createLineStartOffsets, o as getMemberExpressionPropertyName, p as isOxcOnPageScrollCallee, r as createWarningPrefix, s as getOnPageScrollCallbackArgument, t as collectOnPageScrollPerformanceWarnings, u as getOxcStaticPropertyName, v as collectPageScrollInspection } from "../onPageScroll-
|
|
1
|
+
import { _ as collectOnPageScrollWarningsWithBabel, a as getLocationFromOffset, c as getOxcCallExpressionCalleeName, d as isOnPageScrollCallee, f as isOxcFunctionLike, g as collectPageScrollInspectionWithOxc, h as collectOnPageScrollWarningsWithOxc, i as getCallExpressionCalleeName, l as getOxcMemberExpressionPropertyName, m as isStaticPropertyName, n as createLineStartOffsets, o as getMemberExpressionPropertyName, p as isOxcOnPageScrollCallee, r as createWarningPrefix, s as getOnPageScrollCallbackArgument, t as collectOnPageScrollPerformanceWarnings, u as getOxcStaticPropertyName, v as collectPageScrollInspection } from "../onPageScroll-DpsTdS_S.mjs";
|
|
2
2
|
export { collectOnPageScrollPerformanceWarnings, collectOnPageScrollWarningsWithBabel, collectOnPageScrollWarningsWithOxc, collectPageScrollInspection, collectPageScrollInspectionWithOxc, createLineStartOffsets, createWarningPrefix, getCallExpressionCalleeName, getLocationFromOffset, getMemberExpressionPropertyName, getOnPageScrollCallbackArgument, getOxcCallExpressionCalleeName, getOxcMemberExpressionPropertyName, getOxcStaticPropertyName, isOnPageScrollCallee, isOxcFunctionLike, isOxcOnPageScrollCallee, isStaticPropertyName };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as isOxcOnPageScrollCallee, a as collectPageScrollInspection, c as getCallExpressionCalleeName, d as getOnPageScrollCallbackArgument, f as getOxcCallExpressionCalleeName, g as isOxcFunctionLike, h as isOnPageScrollCallee, i as collectOnPageScrollWarningsWithBabel, l as getLocationFromOffset, m as getOxcStaticPropertyName, n as collectOnPageScrollWarningsWithOxc, o as createLineStartOffsets, p as getOxcMemberExpressionPropertyName, r as collectPageScrollInspectionWithOxc, s as createWarningPrefix, t as collectOnPageScrollPerformanceWarnings, u as getMemberExpressionPropertyName, v as isStaticPropertyName } from "../onPageScroll-
|
|
1
|
+
import { _ as isOxcOnPageScrollCallee, a as collectPageScrollInspection, c as getCallExpressionCalleeName, d as getOnPageScrollCallbackArgument, f as getOxcCallExpressionCalleeName, g as isOxcFunctionLike, h as isOnPageScrollCallee, i as collectOnPageScrollWarningsWithBabel, l as getLocationFromOffset, m as getOxcStaticPropertyName, n as collectOnPageScrollWarningsWithOxc, o as createLineStartOffsets, p as getOxcMemberExpressionPropertyName, r as collectPageScrollInspectionWithOxc, s as createWarningPrefix, t as collectOnPageScrollPerformanceWarnings, u as getMemberExpressionPropertyName, v as isStaticPropertyName } from "../onPageScroll-BDuUZSSJ.mjs";
|
|
2
2
|
export { collectOnPageScrollPerformanceWarnings, collectOnPageScrollWarningsWithBabel, 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.17.0",
|
|
5
5
|
"description": "weapp-vite 共享 AST 分析工具包,统一 Babel/Oxc 解析与常用分析操作",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -101,13 +101,13 @@
|
|
|
101
101
|
"node": ">=20"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@babel/core": "^
|
|
105
|
-
"@babel/generator": "^
|
|
106
|
-
"@babel/parser": "^
|
|
107
|
-
"@babel/traverse": "^
|
|
108
|
-
"@babel/types": "^
|
|
109
|
-
"@oxc-project/types": "^0.
|
|
110
|
-
"oxc-parser": "^0.
|
|
104
|
+
"@babel/core": "^8.0.1",
|
|
105
|
+
"@babel/generator": "^8.0.0",
|
|
106
|
+
"@babel/parser": "^8.0.0",
|
|
107
|
+
"@babel/traverse": "^8.0.0",
|
|
108
|
+
"@babel/types": "^8.0.0",
|
|
109
|
+
"@oxc-project/types": "^0.136.0",
|
|
110
|
+
"oxc-parser": "^0.136.0",
|
|
111
111
|
"oxc-walker": "^1.0.0",
|
|
112
112
|
"@weapp-core/shared": "3.0.4"
|
|
113
113
|
},
|