refactor(domain): extract source-map envelope walk and disambiguate stringValue (#828)

Move the indexed sections walk shared by the browser fetcher and
the artifact reader into domain/sourceMapEnvelope with the
fetchers stricter offset validation as an option; both validators
keep their leaf strictness. Rename the browser CDP stringValue to
cdpStringValue across its 18 files, fold the fingerprint duplicate
into the static helper, and rename the version-keys shadow to
nonEmptyString.
This commit is contained in:
morluto
2026-10-07 11:23:37 +08:00
committed by GitHub
parent 6dd719eaf6
commit 64ebdf4501
24 changed files with 300 additions and 200 deletions
+9 -9
View File
@@ -5,7 +5,7 @@ import {
isHttpUrl,
recordValue,
recordsValue,
stringValue,
cdpStringValue,
} from "./CdpCaptureValues.js";
import type { CaptureContext } from "./CdpPageCapture.js";
import { optionalCdpCommand } from "./CdpOptionalCommand.js";
@@ -32,19 +32,19 @@ export const captureWorkers = async (
const items: WebPageInspection["workers"] = [];
if (result === undefined) completeness.unavailable("workers");
for (const target of recordsValue(recordValue(result)?.targetInfos)) {
const type = stringValue(target.type) ?? "";
const type = cdpStringValue(target.type) ?? "";
const url = allowedSanitizedUrl(target.url, allowedOrigins);
const relatedToPage =
stringValue(target.openerId) === context.target.id ||
(stringValue(target.parentFrameId) !== undefined &&
frameIds.has(stringValue(target.parentFrameId) ?? ""));
cdpStringValue(target.openerId) === context.target.id ||
(cdpStringValue(target.parentFrameId) !== undefined &&
frameIds.has(cdpStringValue(target.parentFrameId) ?? ""));
if (!type.includes("worker")) continue;
if (!relatedToPage) {
completeness.exclude("workers", "out_of_target_scope");
continue;
}
if (url === undefined) {
const rawUrl = stringValue(target.url);
const rawUrl = cdpStringValue(target.url);
completeness.exclude(
"workers",
rawUrl === undefined || rawUrl === ""
@@ -56,13 +56,13 @@ export const captureWorkers = async (
continue;
}
items.push({
target_id: stringValue(target.targetId) ?? "",
target_id: cdpStringValue(target.targetId) ?? "",
type,
url: url.url,
origin: url.origin,
attached: target.attached === true,
opener_target_id: stringValue(target.openerId) ?? null,
parent_frame_id: stringValue(target.parentFrameId) ?? null,
opener_target_id: cdpStringValue(target.openerId) ?? null,
parent_frame_id: cdpStringValue(target.parentFrameId) ?? null,
});
}
return items;