refactor(browser): return complete observation evidence
This commit is contained in:
@@ -6,7 +6,6 @@ import type {
|
||||
ElectronPageInspection,
|
||||
InspectElectronPageInput,
|
||||
} from "../domain/electronObservation.js";
|
||||
import { MAX_ELECTRON_SCRIPT_SOURCE_BYTES } from "../domain/electronObservation.js";
|
||||
import { createWebTextArtifact } from "../domain/webContentArtifact.js";
|
||||
import type { CdpConnection } from "./CdpConnection.js";
|
||||
import { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
|
||||
@@ -91,8 +90,6 @@ const captureScriptSource = async (
|
||||
reason: "source capture was not approved",
|
||||
},
|
||||
};
|
||||
if (script.length > MAX_ELECTRON_SCRIPT_SOURCE_BYTES)
|
||||
return sourceLimitResult(input.completeness);
|
||||
const result = requiredRecord(
|
||||
await input.connection.send(
|
||||
"Debugger.getScriptSource",
|
||||
@@ -102,9 +99,6 @@ const captureScriptSource = async (
|
||||
),
|
||||
);
|
||||
const text = stringValue(result.scriptSource) ?? "";
|
||||
const bytes = Buffer.byteLength(text);
|
||||
if (bytes > MAX_ELECTRON_SCRIPT_SOURCE_BYTES)
|
||||
return sourceLimitResult(input.completeness);
|
||||
return {
|
||||
source: {
|
||||
included: true,
|
||||
@@ -113,15 +107,6 @@ const captureScriptSource = async (
|
||||
};
|
||||
};
|
||||
|
||||
const sourceLimitResult = (
|
||||
completeness: CdpCaptureCompleteness,
|
||||
): { readonly source: ElectronScriptSource } => {
|
||||
completeness.truncate("script_sources");
|
||||
return {
|
||||
source: { included: false, reason: "script source byte limit reached" },
|
||||
};
|
||||
};
|
||||
|
||||
const digest = (value: unknown): string => {
|
||||
const encoded = canonicalize(value);
|
||||
if (encoded === undefined) throw new TypeError("Expected canonical JSON");
|
||||
|
||||
Reference in New Issue
Block a user