refactor(domain): consolidate property-key extraction behind semanticStaticPropertyKey (#823)

Inline the private memberKey/propertyKey wrappers in semantic
MemberMutations/Projection/Values to direct canonical calls.
Migrate the electron Browser/Values member keys off legacy
propertyName (provably identical: explicit computed guard retained).
Delegate bundle calleeName/endpointArgument/stringArgument to the
static helpers, adding loadURL endpoint parity with static analysis.

Bundle regressions pin nested-dynamic-receiver and loadURL parity.
Remaining computed-identifier forks in electron Native/Ipc tracked
in #822.
This commit is contained in:
morluto
2026-10-07 11:13:59 +08:00
committed by GitHub
parent 75f50d86f6
commit 764ff05231
8 changed files with 54 additions and 84 deletions
+1 -44
View File
@@ -3,27 +3,7 @@ import * as t from "@babel/types";
import { sanitizeBrowserUrl } from "./browserObservation.js";
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
/** Name of a call/new callee from its AST node. */
export const calleeName = (callee: t.Node): string => {
if (t.isIdentifier(callee)) return callee.name;
if (t.isImport(callee)) return "import";
if (t.isMemberExpression(callee) || t.isOptionalMemberExpression(callee)) {
const object = t.isExpression(callee.object)
? calleeName(callee.object)
: "";
const property = semanticStaticPropertyName(
callee.property,
callee.computed,
);
if (property === "") return "";
return object === "" ? property : `${object}.${property}`;
}
return "";
};
export const stringArgument = (
value: t.Node | null | undefined,
): string | undefined => (t.isStringLiteral(value) ? value.value : undefined);
/** Pick the endpoint argument for common network-call patterns. */
export const objectValue = (
object: t.ObjectExpression,
@@ -83,26 +63,3 @@ export const locationFields = (node: t.Node) => ({
line: node.loc?.start.line ?? null,
column: node.loc?.start.column ?? null,
});
/** Pick the endpoint argument for common network-call patterns. */
export const endpointArgument = (
name: string,
args: readonly (
| t.Expression
| t.SpreadElement
| t.JSXNamespacedName
| t.ArgumentPlaceholder
)[],
): string | undefined => {
if (name === "fetch" || name.endsWith(".fetch") || name === "WebSocket")
return stringArgument(args[0]);
if (name.endsWith(".open") && stringArgument(args[1]) !== undefined)
return stringArgument(args[1]);
if (
["get", "post", "put", "patch", "delete", "request"].some(
(method) => name === method || name.endsWith(`.${method}`),
)
)
return stringArgument(args[0]);
return undefined;
};