tarinai/js/restore_coordinator.js

29 lines
1.1 KiB
JavaScript

"use strict";
(function (global) {
const Snapshot = global.TarinaiSnapshot;
if (!Snapshot) throw new Error("TarinaiSnapshot is not available for restore_coordinator.js");
function renderWorldAfterRestore(worldRef = global.world) {
if (!worldRef) return;
if (typeof renderLog === "function") renderLog(worldRef.logs || []);
if (typeof resetArchiveRenderState === "function") resetArchiveRenderState();
if (typeof renderArchive === "function") renderArchive();
if (typeof renderSelected === "function") renderSelected();
if (typeof renderStats === "function") renderStats();
if (typeof render === "function") render();
if (typeof syncTopButtons === "function") syncTopButtons();
}
function syncRestoreDependents(worldRef = global.world) {
renderWorldAfterRestore(worldRef);
}
function restoreSnapshot(snapshot, worldRef = global.world, options = {}) {
const result = Snapshot.restoreSnapshot(snapshot, worldRef);
if (options.syncUi !== false) syncRestoreDependents(worldRef);
return result;
}
global.TarinaiRestoreCoordinator = { restoreSnapshot };
})(typeof window !== "undefined" ? window : globalThis);