freat: renaming

This commit is contained in:
2026-03-15 14:11:11 +01:00
parent 2326bbe035
commit 04c039bdde
18 changed files with 455 additions and 462 deletions

View File

@@ -0,0 +1,37 @@
/**
* Per-recollection graph persistence (localStorage).
* Saves and loads StoredGraphState (version + nodes + edges). Used by useCanvasGraph and export.
*/
import type { StoredGraphState } from '@/lib/graph/state'
export type { StoredGraphState }
export const RECOLLECTION_FILE_EXT = '.zui.json'
export const RECOLLECTION_VERSION = 1
const GRAPH_KEY_PREFIX = 'zui_graph_'
export function getGraphStorageKey(recollectionId: string): string {
return `${GRAPH_KEY_PREFIX}${recollectionId}`
}
export function loadGraphFromStorage(recollectionId: string): StoredGraphState | null {
try {
const raw = localStorage.getItem(getGraphStorageKey(recollectionId))
if (!raw) return null
const data = JSON.parse(raw) as unknown
if (!data || typeof data !== 'object' || !Array.isArray((data as StoredGraphState).nodes) || !Array.isArray((data as StoredGraphState).edges))
return null
return data as StoredGraphState
} catch {
return null
}
}
export function saveGraphToStorage(recollectionId: string, state: StoredGraphState): void {
localStorage.setItem(getGraphStorageKey(recollectionId), JSON.stringify(state))
}
export function removeGraphFromStorage(recollectionId: string): void {
localStorage.removeItem(getGraphStorageKey(recollectionId))
}