fix(evidence): preserve literal keys and response body ownership

Retain exact empty and computed literal keys in JavaScript observations. Bind CDP response bodies to request occurrences, account for late responses, and validate the target after final progress callbacks.
This commit is contained in:
morluto
2026-10-12 16:17:29 +08:00
parent 79156e5bed
commit d1dcebce2c
10 changed files with 576 additions and 211 deletions
@@ -13,6 +13,7 @@ import type {
} from "./javascriptStaticAnalysisTypes.js";
import {
readExactJavaScriptLiteral,
semanticStaticPropertyKey,
semanticStaticPropertyName,
unwrapJavaScriptExpression,
} from "./javascriptAstValues.js";
@@ -131,15 +132,15 @@ export const moduleFactory = (
/** Derive a literal or explicitly computed module key. */
export const modulePropertyName = (
property: t.ObjectMethod | t.ObjectProperty | t.SpreadElement,
): string =>
t.isObjectMethod(property) || t.isObjectProperty(property)
? property.computed &&
!t.isStringLiteral(property.key) &&
!t.isNumericLiteral(property.key)
? `[computed@${String(property.start ?? -1)}]`
: semanticStaticPropertyName(property.key, property.computed) ||
`[unknown@${String(property.start ?? -1)}]`
): string => {
if (!t.isObjectMethod(property) && !t.isObjectProperty(property))
return `[unknown@${String(property.start ?? -1)}]`;
const key = semanticStaticPropertyKey(property.key, property.computed);
if (key !== null) return key;
return property.computed
? `[computed@${String(property.start ?? -1)}]`
: `[unknown@${String(property.start ?? -1)}]`;
};
/** Read the factory-local bundler require parameter when declared. */
export const factoryRequireName = (