/** * dock-manager-model - the pure state behind . It wraps the base * `dock-model` tree (the docked/tiled area) with the three "pro" docking * surfaces a real IDE has: * * floating panes popped out into movable/resizable windows (a single tabs * leaf each - a floating panel). * autoHide leaves collapsed to an edge strip; a fly-out reveals them and * "pin" re-docks them. * main the tiled dock area itself (a `DockNode` tree, or null when * everything has been floated / hidden). * * As with the base model, every operation is a pure transform returning a NEW * state, so a whole workspace - tiled + floating + hidden - serializes to JSON * and restores exactly. The Svelte view owns the DOM, gestures and z-order * painting; all the surgery lives here and is unit-tested without a browser. */ import { type DockNode, type DockTabs, type DockPane, type DockZone, type IdGen } from './dock-model'; export type DockSide = Exclude; /** A floating window: one tabs leaf shown in a movable/resizable frame. */ export type FloatWindow = { id: string; leaf: DockTabs; x: number; y: number; width: number; height: number; /** Stacking order; higher is on top. */ z: number; /** Collapsed to just its title bar. */ minimized?: boolean; /** Expanded to fill the manager (its x/y/w/h are kept for restore). */ maximized?: boolean; }; /** A leaf collapsed to an edge; a fly-out reveals it, "pin" re-docks it. */ export type AutoHideEntry = { id: string; side: DockSide; leaf: DockTabs; /** Fly-out panel size in px along the reveal axis. */ size: number; }; export type DockManagerState = { main: DockNode | null; floating: FloatWindow[]; autoHide: AutoHideEntry[]; /** A tiled leaf shown maximized (filling the docked area), or null. */ maximizedLeaf?: string | null; }; /** Where a pane currently lives. */ export type PaneLocation = { kind: 'main'; } | { kind: 'floating'; windowId: string; } | { kind: 'autoHide'; entryId: string; }; export declare function locatePane(state: DockManagerState, paneId: string): PaneLocation | null; /** Which surface holds a tabs leaf: 'main', a window id, or null. */ export declare function surfaceOfTabs(state: DockManagerState, tabsId: string): 'main' | string | null; /** Reorder a tab within its leaf, wherever that leaf lives (main or a float). */ export declare function reorderTab(state: DockManagerState, tabsId: string, from: number, to: number): DockManagerState; /** Resize a group's children (splitter drag). Groups only exist in `main` * (floating windows are single leaves), so this targets the main tree. */ export declare function resizeGroup(state: DockManagerState, groupId: string, sizes: number[]): DockManagerState; /** Set the active tab of a leaf in main or a floating window. */ export declare function setManagerActive(state: DockManagerState, tabsId: string, active: number): DockManagerState; /** * Dock a pane onto a target leaf (`center` = new tab, edge = split). Works * across surfaces: a floating pane can dock into main, a main pane into a float * (centre only), etc. Edge zones only apply when the target is in `main`. */ export declare function dockPaneOnto(state: DockManagerState, paneId: string, targetTabsId: string, zone: DockZone, genId: IdGen): DockManagerState; /** Insert a NEW pane into the main area - the first leaf (as a tab), or as the * whole main when empty. Used to pop a window/pop-out back into the layout. */ export declare function addPaneToMain(state: DockManagerState, p: DockPane, genId: IdGen): DockManagerState; /** Dock a pane into an empty main area (main becomes a single leaf holding it). */ export declare function dockPaneToEmptyMain(state: DockManagerState, paneId: string, genId: IdGen): DockManagerState; /** Pop a pane out into a new floating window at the given rect. */ export declare function floatPane(state: DockManagerState, paneId: string, rect: { x: number; y: number; width: number; height: number; }, genId: IdGen): DockManagerState; /** Dock an entire floating window's panes back into a main leaf. */ export declare function dockWindowOnto(state: DockManagerState, windowId: string, targetTabsId: string, zone: DockZone, genId: IdGen): DockManagerState; /** Move a floating window (top-left). */ export declare function moveWindow(state: DockManagerState, windowId: string, x: number, y: number): DockManagerState; /** Resize a floating window. */ export declare function resizeWindow(state: DockManagerState, windowId: string, width: number, height: number): DockManagerState; /** Raise a floating window to the top of the stack. */ export declare function bringToFront(state: DockManagerState, windowId: string): DockManagerState; /** Collapse a floating window to just its title bar (or restore it). */ export declare function setWindowMinimized(state: DockManagerState, windowId: string, minimized: boolean): DockManagerState; /** Toggle a floating window between filling the manager and its own rect. */ export declare function toggleWindowMaximized(state: DockManagerState, windowId: string): DockManagerState; /** Close a floating window and all its panes. */ export declare function closeWindow(state: DockManagerState, windowId: string): DockManagerState; /** Find a tabs leaf anywhere (main or a floating window) by id. */ export declare function findLeafById(state: DockManagerState, tabsId: string): DockTabs | null; /** Toggle a tiled leaf maximized (filling the docked area). Clears if it is gone. */ export declare function toggleMaximizeLeaf(state: DockManagerState, tabsId: string): DockManagerState; /** Send a floating window's panel to an edge as an auto-hidden entry. */ export declare function autoHideWindow(state: DockManagerState, windowId: string, side: DockSide, genId: IdGen, size?: number): DockManagerState; /** Collapse a MAIN leaf to an edge strip (auto-hide) on the given side. */ export declare function autoHideLeaf(state: DockManagerState, tabsId: string, side: DockSide, size?: number): DockManagerState; /** Auto-hide a single pane to an edge (drag a tab to the manager border). The * pane leaves its leaf and becomes its own collapsed entry on that side. */ export declare function autoHidePaneToSide(state: DockManagerState, paneId: string, side: DockSide, genId: IdGen, size?: number): DockManagerState; /** * Pin an auto-hidden entry back into the main dock area on its edge. `fraction` * is the share of the axis the re-docked panel should take (default 0.25). */ export declare function pinAutoHidden(state: DockManagerState, entryId: string, genId: IdGen, fraction?: number): DockManagerState; /** Resize an auto-hide fly-out. */ export declare function setAutoHideSize(state: DockManagerState, entryId: string, size: number): DockManagerState; /** Close a pane wherever it lives. */ export declare function closePane(state: DockManagerState, paneId: string): DockManagerState; /** Every pane id across all surfaces. */ export declare function allManagerPaneIds(state: DockManagerState): string[]; /** Every id used anywhere in the workspace: node ids (groups + tabs leaves), * pane ids, floating-window ids and auto-hide entry ids. Used to keep a freshly * generated id unique even against a workspace restored from storage - the * manager's id counter is module-scoped and resets on reload, so without this * the same `dm-N` can be minted twice and collide (a keyed `{#each}` then throws * `each_key_duplicate`). */ export declare function allManagerIds(state: DockManagerState): string[]; /** Reassign any duplicate group / tabs NODE id (and floating-window / auto-hide * entry id) so no keyed sibling list sees a collision. Pane ids are left alone - * they key the `pane` snippet to its content, so a rename would blank a panel; * a restored workspace's repeats are always on the generated node ids anyway. * Idempotent: a clean workspace is returned value-equal. */ export declare function dedupeManagerNodeIds(state: DockManagerState): DockManagerState;