Skip to content
API reference

headless

Import
import * as api from "@fungi.computer/maosaico/headless";
Kind Export Description
type alias Gesture The pointer-owned frame or divider operation currently in progress.
type alias State Pane geometry, ordering and the active gesture held by the layout store.
type alias MaosaicoState Live layout projection and commands; each state instance owns its store.
type alias Divider Clamped divider geometry for a main-pane layout.
type alias Arrangement Pane frames, overflow tabs and optional main-pane divider.
function createMaosaicoState() Create an independent layout store with no registered panes.
function arrangeTiles() Named layouts share minima and MRU tabs; the caller renders the groups.
Signature
type Gesture =
| {
kind: "frame";
id: string;
pointerId: number;
start: Frame;
snap?: {
side: SnapSide;
frame: Frame;
} | null;
}
| {
kind: "divider";
pointerId: number;
start: number | undefined;
};

The pointer-owned frame or divider operation currently in progress.

Signature
{
kind: "frame";
id: string;
pointerId: number;
start: Frame;
snap?: | {
side: SnapSide;
frame: Frame;
}
| null;
}
Name Type Description
kind "frame" Identifies a frame gesture.
id string Registered pane being moved or resized.
pointerId number Pointer that owns the gesture.
start Frame Frame restored when the gesture is cancelled.
snap? | { side: SnapSide; frame: Frame; } | null Candidate snap applied only when the gesture completes.

Signature
{
kind: "divider";
pointerId: number;
start: number | undefined;
}
Name Type Description
kind "divider" Identifies a divider gesture.
pointerId number Pointer that owns the divider.
start number | undefined Main-size preference restored on cancellation.

Signature
type State = object;

Pane geometry, ordering and the active gesture held by the layout store.

Signature
frames: Map<string, Frame>;

Registered floating frames, keyed by pane identity.

Signature
order: string[];

Focus order, with the most recently focused pane last.

Signature
tiles: string[];

Stable tiling order of participating panes.

Signature
minima: Map<string, Minima>;

Host-supplied minimum dimensions per pane.

Signature
participating: Set<string>;

Panes currently included in layout.

Signature
mainSize: number | undefined;

Preferred main-pane extent, or undefined for the default half.

Signature
zoomed: string | null;

Pane expanded to the container, or null.

Signature
gesture: Gesture | null;

Current pointer operation, or null.

Signature
restore: Map<string, Frame>;

Floating frames retained for restoration after snapping.


MaosaicoStatetype alias

Section titled “MaosaicoState”
Signature
type MaosaicoState = Readonly<State> & object;

Live layout projection and commands; each state instance owns its store.

Name Type Description
version number Revision incremented by store updates.
subscribe() (listener) => () => void Observe store changes; returns an unsubscribe function.
register() (id, frame, minima) => void Register or replace a pane’s frame and minima, including it in layout.
setParticipation() (id, participating) => void Include or exclude a registered pane without discarding its frame.
setMinima() (id, minima) => void Update minimum dimensions for an existing pane.
unregister() (id) => void Remove a pane, its ordering, restoration frame and active gesture.
begin() (id, pointerId) => void Capture a participating pane’s starting frame for a pointer gesture.
move() (id, pointerId, frame, bounds, minima, snapSide?) => void Update the owning pointer’s clamped frame and optional snap preview.
end() (id, pointerId) => void Finish the owning pointer’s gesture, applying its snap if present.
cancel() (id, pointerId) => void Restore the owning pointer’s starting frame and clear its gesture.
snap() (id, side, bounds, minima) => void Snap a participating pane and retain its previous frame.
restoreFrame() (id, bounds, minima) => void Restore a retained floating frame, clamped to current bounds and minima.
focus() (id) => void Move a registered pane to the top of focus order.
swap() (first, second) => void Exchange two participating panes’ positions in tiling order.
zoom() (id) => void Expand a participating pane, or clear expansion with null.
resizeMain() (size) => void Clear the preference with undefined to restore the default half.
beginDivider() (pointerId) => boolean Start a divider gesture only when no other gesture is active.
finishDivider() (pointerId, cancel) => void Finish the owning divider gesture, restoring its preference on cancel.
destroy() () => void Clear the current gesture and retained restoration frames.

Signature
type Divider = object;

Clamped divider geometry for a main-pane layout.

Signature
axis: "x" | "y";

Coordinate axis along which the divider moves.

Signature
position: number;

Current main-pane extent.

Signature
min: number;

Smallest extent permitted by pane minima.

Signature
max: number;

Largest extent permitted by pane minima and available bounds.


Arrangementtype alias

Section titled “Arrangement”
Signature
type Arrangement = object;

Pane frames, overflow tabs and optional main-pane divider.

Signature
frames: Map<string, Frame>;

Visible pane geometry, keyed by identity.

Signature
tabGroups: string[][];

Panes sharing an overflow slot; the host renders their tabs.

Signature
divider: Divider | null;

Main-pane divider, absent for equal layouts or insufficient space.

createMaosaicoState()function

Section titled “createMaosaicoState()”
Signature
function createMaosaicoState(): MaosaicoState;

Create an independent layout store with no registered panes.

MaosaicoState


arrangeTiles()function

Section titled “arrangeTiles()”
Signature
function arrangeTiles(order, minima, recent, bounds, options): Arrangement;

Named layouts share minima and MRU tabs; the caller renders the groups.

Parameter Type
order readonly string[]
minima ReadonlyMap<string, Size>
recent readonly string[]
bounds Size
options TilingOptions

Arrangement

Re-exports SnapSide


Re-exports Frame


Re-exports Bounds


Re-exports Minima


Re-exports TilingLayout


Re-exports TilingOptions