feat(rerun): retain live playback and recover isolated viewer resources
This commit is contained in:
@@ -32,6 +32,26 @@ const additions = {
|
||||
},
|
||||
};
|
||||
|
||||
// Preserve the exact previous patch as an audited upgrade path.
|
||||
for (const [name, addition] of Object.entries(additions)) {
|
||||
addition.previousCode = addition.code;
|
||||
if (name === "index.d.ts") {
|
||||
addition.code += " set_height_slice(lower: number | null, upper: number | null): boolean;\n get_height_bounds(): {min: number; max: number} | null;\n";
|
||||
} else {
|
||||
const typed = name === "index.ts";
|
||||
addition.code += ` set_height_slice(lower${typed ? ": number | null" : ""}, upper${typed ? ": number | null" : ""})${typed ? ": boolean" : ""} {
|
||||
if (!this.#handle) throw new Error("Rerun viewer is stopped");
|
||||
const off = lower === null && upper === null;
|
||||
return this.#handle.nodedc_height_slice(off ? undefined : (lower ?? -3e38), off ? undefined : (upper ?? 3e38));
|
||||
}
|
||||
get_height_bounds()${typed ? ": {min: number; max: number} | null" : ""} {
|
||||
if (!this.#handle) throw new Error("Rerun viewer is stopped");
|
||||
return JSON.parse(this.#handle.nodedc_height_bounds() ?? "null");
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the complete set before changing any installed file. A package
|
||||
// upgrade, corrupt artifact or independently modified wrapper fails closed.
|
||||
const writes = [];
|
||||
@@ -39,9 +59,9 @@ for (const [name, identity] of Object.entries(manifest.files)) {
|
||||
const current = readFileSync(resolve(packageRoot, name));
|
||||
let output;
|
||||
if (additions[name]) {
|
||||
const { marker, code } = additions[name];
|
||||
const { marker, code, previousCode } = additions[name];
|
||||
const source = current.toString("utf8");
|
||||
const original = source.includes(code) ? source.replace(code, "") : source;
|
||||
const original = source.includes(code) ? source.replace(code, "") : source.replace(previousCode, "");
|
||||
if (sha(original) !== identity.upstreamSha256 || original.split(marker).length !== 2) {
|
||||
throw new Error(`Unexpected upstream wrapper: ${name}`);
|
||||
}
|
||||
@@ -49,7 +69,7 @@ for (const [name, identity] of Object.entries(manifest.files)) {
|
||||
} else {
|
||||
output = readFileSync(resolve(vendorRoot, identity.artifact));
|
||||
if (sha(output) !== identity.sha256) throw new Error(`Corrupt navigation artifact: ${name}`);
|
||||
if (![identity.upstreamSha256, identity.sha256].includes(sha(current))) {
|
||||
if (![identity.upstreamSha256, identity.previousArtifactSha256, identity.sha256].includes(sha(current))) {
|
||||
throw new Error(`Unexpected installed runtime: ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user