import type { BSPNode, BSPSplit, BSPLeaf } from "./dsl"; export interface BSPLayout { name: string; dsl: string; root: BSPNode; weight: number; } export interface BSPPane { id: string; leaf: BSPLeaf; } export interface BSPAssignments { assignments: Record; } export declare const PRESETS: BSPLayout[]; /** Create a BSP assignment value representing a compositor surface. * Format: "surface::" */ export declare function surfaceAssignment(connectionId: string, surfaceId: number): string; /** Check whether a BSP assignment value represents a surface. */ export declare function isSurfaceAssignment(value: string | null): boolean; /** Extract the numeric surface ID from a surface assignment string, or null. */ export declare function parseSurfaceAssignment(value: string | null): { connectionId: string; surfaceId: number; } | null; /** BSP assignment for an editor tile: "editor::". */ export declare function editorAssignment(connectionId: string, path: string): string; /** BSP assignment for a rendered preview of a file: * "preview::". Same shape as an editor tile — it is * the same file, shown rendered instead of as source, and the view * switcher flips between them. */ export declare function previewAssignment(connectionId: string, path: string): string; /** BSP assignment for a git diff tile: "diff::" for the * unstaged (INDEX×WORKTREE) diff, or ":staged:" for the staged * (HEAD×INDEX) diff. `path` is absolute (starts with "/"), so the "staged:" * marker is unambiguous. */ /** Which endpoints a diff tile compares. * - "unstaged": INDEX×WORKTREE (tracked, unstaged edits) * - "staged": HEAD×INDEX (git diff --cached) * - "untracked": INDEX×WORKTREE + untracked walk (a new file, shown added) * - "worktree": HEAD×WORKTREE (all changes since HEAD, staged + unstaged) */ export type DiffSide = "unstaged" | "staged" | "untracked" | "worktree"; export declare function diffAssignment(connectionId: string, path: string, side?: DiffSide): string; /** Decode a diff tile's arg into { side, staged, path }. `staged` is kept as a * convenience alias for `side === "staged"`. */ export declare function parseDiffArg(arg: string): { side: DiffSide; staged: boolean; path: string; }; /** BSP assignment for a server's own panels — what its session supervisor * runs, who is connected, its units, its extensions: "manage::". * * The trailing colon is not decoration: `parseTileAssignment` splits on the * first ":" after the prefix, and a manage tile has nothing to say after its * connection. Keeping the shape means every kind-agnostic path (the hash * writer, the tab registry, drop handling) treats it like any other tile. * * There is one per connection by construction, so opening Manage twice lands * on the same tile rather than accumulating panels that each hold a live * client watch. */ export declare function manageAssignment(connectionId: string): string; /** BSP assignment for a commit tile: "commit:::". * `oid` is hex (no ":"), so the first ":" of the arg splits oid from repo. */ export declare function commitAssignment(connectionId: string, oid: string, repoPath: string): string; /** True when the assignment is an editor/diff/commit/manage tile (not a * session). */ export declare function isTileAssignment(value: string | null): boolean; /** True when the assignment names pane content rather than a terminal session * — a surface, an IDE tile, or a web pane. Anything that answers true here * must be kept out of session assignment and focus bookkeeping. */ export declare function isContentAssignment(value: string | null): boolean; export interface TileAssignment { kind: "editor" | "diff" | "commit" | "preview" | "manage"; connectionId: string; /** Verbatim argument (a path, ":" for commit, empty for * manage — the connection is the whole address). */ arg: string; } /** Parse an editor/diff/commit tile assignment, or null. */ export declare function parseTileAssignment(value: string | null): TileAssignment | null; /** BSP assignment for a web pane: "web::". */ export declare function webAssignment(connectionId: string, url: string): string; /** Check whether a BSP assignment value represents a web pane. */ export declare function isWebAssignment(value: string | null): boolean; /** Parse a web pane assignment into its connection and URL, or null. */ export declare function parseWebAssignment(value: string | null): { connectionId: string; url: string; } | null; export declare function enumeratePanes(node: BSPNode, path?: readonly number[]): BSPPane[]; export declare function assignSessionsToPanes(panes: readonly BSPPane[], orderedSessionIds: readonly string[]): BSPAssignments; export declare function buildCandidateOrder({ liveSessionIds, focusedSessionId, currentAssignedInPaneOrder, lruSessionIds, }: { liveSessionIds: readonly string[]; focusedSessionId: string | null; currentAssignedInPaneOrder?: readonly string[]; lruSessionIds?: readonly string[]; }): string[]; /** * The assignments after a dropped `value` lands in `targetPaneId`, or `null` * when nothing changes. * * A drop that names the pane the drag left (`fromPaneId` — a pane's ✕ * doubling as its drag handle) is a *move*, not another open: the source * pane takes what the target held, so the content lands in exactly one pane, * and dropping on an empty pane is a plain move. Gated on the source still * holding the dragged value — a layout change mid-drag must not evict * whatever else got there since. * * Surface assignments are unique views, so recover their source from the * current assignments if a browser omits the secondary source-pane drag MIME * (or if that pane id went stale). Generic tile drops deliberately remain * copies/opens when they have no valid source marker. */ export declare function assignmentsAfterDrop(prev: Readonly>, value: string, targetPaneId: string, fromPaneId: string | undefined, validPaneIds: readonly string[]): Record | null; export declare function reconcileAssignments({ panes, previous, liveSessionIds, knownSessionIds, liveSurfaceKeys, readyConnectionIds, sessionReplacements, sessionConnectionIds, }: { panes: readonly BSPPane[]; previous: BSPAssignments; liveSessionIds: readonly string[]; knownSessionIds: readonly string[]; /** When provided, surface assignments for destroyed surfaces are cleared. * Each key is "connectionId:surfaceId". */ liveSurfaceKeys?: readonly string[]; /** Connections that are both present AND ready. Surface assignments * whose connection is absent OR not yet ready (reconnecting) are * preserved — the surface may reappear once the connection finishes * its handshake or is re-added. */ readyConnectionIds?: ReadonlySet; /** Maps old (closed) session IDs to replacement live session IDs. * Used to re-map pane assignments after a reconnect where PTYs get * new session IDs but represent the same underlying terminal. */ sessionReplacements?: ReadonlyMap; /** Maps session IDs to their owning connection ID. Used together with * `readyConnectionIds` to preserve terminal assignments whose * connection is absent or still reconnecting — mirroring the surface * assignment protection so terminals survive reconnect cycles too. */ sessionConnectionIds?: ReadonlyMap; }): BSPAssignments; export declare function adjustWeights(split: BSPSplit, indexA: number, indexB: number, fraction: number): BSPSplit; export declare function layoutFromDSL(dsl: string): BSPLayout; //# sourceMappingURL=layout.d.ts.map