removed unused processesseessess
This commit is contained in:
parent
348f355eb2
commit
4fdc567e08
158 changed files with 1317 additions and 3351 deletions
|
|
@ -30,7 +30,7 @@
|
|||
function capture(worldRef = global.world, label = "action") {
|
||||
const world = ensure(worldRef);
|
||||
if (!world || world._historyRestoring) return false;
|
||||
const snap = global.TarinaiSnapshot?.createSnapshot?.(world);
|
||||
const snap = global.TarinaiSnapshot.createSnapshot(world);
|
||||
if (!snap) return false;
|
||||
const key = snapshotKey(snap);
|
||||
if (key && key === world._lastUndoSnapshotKey) return false;
|
||||
|
|
@ -42,11 +42,11 @@
|
|||
}
|
||||
|
||||
function restore(worldRef, entry) {
|
||||
if (!worldRef || !entry?.snapshot || !global.TarinaiRestoreCoordinator?.restoreSnapshot) return false;
|
||||
if (!worldRef || !entry?.snapshot) return false;
|
||||
worldRef._historyRestoring = true;
|
||||
try {
|
||||
global.TarinaiRestoreCoordinator.restoreSnapshot(cloneSnapshot(entry.snapshot), worldRef, { syncUi: true });
|
||||
worldRef._lastUndoSnapshotKey = snapshotKey(global.TarinaiSnapshot?.createSnapshot?.(worldRef));
|
||||
worldRef._lastUndoSnapshotKey = snapshotKey(global.TarinaiSnapshot.createSnapshot(worldRef));
|
||||
return true;
|
||||
} finally {
|
||||
worldRef._historyRestoring = false;
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
function undo(worldRef = global.world) {
|
||||
const world = ensure(worldRef);
|
||||
if (!world || !world._undoStack.length) return { ok: false, reason: "empty" };
|
||||
const current = global.TarinaiSnapshot?.createSnapshot?.(world);
|
||||
const current = global.TarinaiSnapshot.createSnapshot(world);
|
||||
const prev = world._undoStack.pop();
|
||||
if (current) world._redoStack.push({ snapshot: cloneSnapshot(current), key: snapshotKey(current), label: "redo", time: world.time || 0 });
|
||||
if (world._redoStack.length > MAX_HISTORY) world._redoStack.splice(0, world._redoStack.length - MAX_HISTORY);
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
function redo(worldRef = global.world) {
|
||||
const world = ensure(worldRef);
|
||||
if (!world || !world._redoStack.length) return { ok: false, reason: "empty" };
|
||||
const current = global.TarinaiSnapshot?.createSnapshot?.(world);
|
||||
const current = global.TarinaiSnapshot.createSnapshot(world);
|
||||
const next = world._redoStack.pop();
|
||||
if (current) world._undoStack.push({ snapshot: cloneSnapshot(current), key: snapshotKey(current), label: "undo", time: world.time || 0 });
|
||||
if (world._undoStack.length > MAX_HISTORY) world._undoStack.splice(0, world._undoStack.length - MAX_HISTORY);
|
||||
|
|
@ -75,17 +75,6 @@
|
|||
return { ok, label: next.label || "" };
|
||||
}
|
||||
|
||||
function clear(worldRef = global.world) {
|
||||
const world = ensure(worldRef);
|
||||
if (!world) return false;
|
||||
world._undoStack.length = 0;
|
||||
world._redoStack.length = 0;
|
||||
world._lastUndoSnapshotKey = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
function canUndo(worldRef = global.world) { return !!worldRef?._undoStack?.length; }
|
||||
function canRedo(worldRef = global.world) { return !!worldRef?._redoStack?.length; }
|
||||
|
||||
global.TarinaiHistory = Object.freeze({ capture, undo, redo, clear, canUndo, canRedo });
|
||||
global.TarinaiHistory = Object.freeze({ capture, undo, redo });
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue