/** * The per-scope history model (API §8.2) — a framework-free entries+cursor stack * with a version counter for `useSyncExternalStore`, its serialized entry shape * (`SerializedLocation`/`NavSnapshot` + equality/clone), and the seed precedence. * Source of truth for back/forward; the adapter is a projection sink around it. */ import type { NodePath } from '@astrale-os/sdk/graph/path'; import type { Key } from '@astrale-os/sdk/schema'; /** The serializable projection persisted in history / URLs / snapshots. */ export interface SerializedLocation { readonly node: NodePath; readonly view?: Key.View; readonly params?: Readonly>; } /** A versioned history snapshot — round-trips through `NavScope.restore`. */ export interface NavSnapshot { readonly v: 1; readonly entries: readonly SerializedLocation[]; readonly cursor: number; } /** Structural equality of two serialized locations (node + view + params). */ export declare function sameLocation(a: SerializedLocation, b: SerializedLocation): boolean; /** A deep-enough clone for a serialized entry (params copied). */ export declare function cloneLocation(loc: SerializedLocation): SerializedLocation; export declare class NavHistory { private entries; private cursor; private version; private readonly listeners; constructor(entries: SerializedLocation[], cursor: number); subscribe(listener: () => void): () => void; getVersion(): number; get current(): SerializedLocation | null; get canBack(): boolean; get canForward(): boolean; snapshot(): NavSnapshot; /** Push (or replace the current entry with) a location. No-op on same location. */ push(loc: SerializedLocation, replace: boolean): boolean; back(): boolean; forward(): boolean; /** * Reconcile an externally-observed location (browser back/forward, URL edit): * step the cursor when it matches an adjacent entry, else push it fresh. */ syncExternal(loc: SerializedLocation): boolean; /** Replace the whole stack (restore revalidation prune). */ reset(entries: readonly SerializedLocation[], cursor: number): void; private emit; } /** * Seed the initial entries+cursor from the three sources, in precedence order: * a `restore` snapshot (revalidated later against the memory), then the * adapter's current read, then `initial`; empty (idle) when none yields one. * A live adapter read that disagrees with a restored cursor is appended as the * current entry (a deep link overrides the saved position but keeps its back * history). */ export declare function seedEntries(fromAdapter: SerializedLocation | null, restore: { readonly entries: readonly SerializedLocation[]; readonly cursor: number; } | undefined, initialSerialized: SerializedLocation | null): { entries: SerializedLocation[]; cursor: number; }; //# sourceMappingURL=history.d.ts.map