Skip to content
API reference

window-manager

Import
import * as api from "@fungi.computer/nacre/window-manager";
Kind Export Description
type alias WindowLaunch Minimum identity required to own a window across mount generations.
type alias WindowStatus Current presentation state of a managed window.
type alias WindowHost Mount operations supplied by the embedding host; selection and authority stay with it.
type alias WindowEvents What a mounted App tells its window while it lives.
type alias WindowProjection Immutable snapshot of one window and its mount generation.
type alias WindowsProjection Current ordered collection of managed window snapshots.
type alias WindowMount Create a host-owned mount in a container, observing cancellation and navigation.
type alias WindowManager Own window lifetimes, visibility and serialized host mutations.
type alias WindowManagerOptions Host adapters used to create, attach and validate window mounts.
function hasVisibleWindows() Whether any projected App window is still visible in the workspace.
function createWindowManager() Owns App-window generations while leaving selection and App authority to the caller. A stale mount is always disposed when it eventually resolves.

WindowLaunchtype alias

Section titled “WindowLaunch”
Signature
type WindowLaunch = Readonly<{
windowId: string;
}>;

Minimum identity required to own a window across mount generations.


WindowStatustype alias

Section titled “WindowStatus”
Signature
type WindowStatus = "loading" | "ready" | "minimized" | "error";

Current presentation state of a managed window.


WindowHosttype alias

Section titled “WindowHost”
Signature
type WindowHost<Launch> = Readonly<{
setVisibility: (visibility) => void | Promise<void>;
reconfigure: (launch, signal?) => void | Promise<void>;
requestClose?: () => boolean | Promise<boolean>;
requestBack?: () => boolean | Promise<boolean>;
activateNavigation?: (activation) => boolean | Promise<boolean>;
activateStatus?: (action) => boolean | Promise<boolean>;
dispose: () => void | Promise<void>;
}>;

Mount operations supplied by the embedding host; selection and authority stay with it.

Type Parameter
Launch extends WindowLaunch

WindowEventstype alias

Section titled “WindowEvents”
Signature
type WindowEvents = Readonly<{
onComputerChoice: () => Promise<void>;
onNavigationState: (state) => void;
onStatusItems: (items) => void;
}>;

What a mounted App tells its window while it lives.


WindowProjectiontype alias

Section titled “WindowProjection”
Signature
type WindowProjection<Launch, Container> = Readonly<{
windowId: string;
launch: Launch;
container: Container;
status: WindowStatus;
generation: number;
error?: unknown;
cleanupError?: unknown;
navigation: AppNavigationState | null;
statusItems: readonly AppStatusItem[];
}>;

Immutable snapshot of one window and its mount generation.

Type Parameter
Launch extends WindowLaunch
Container

WindowsProjectiontype alias

Section titled “WindowsProjection”
Signature
type WindowsProjection<Launch, Container> = Readonly<{
windows: readonly WindowProjection<Launch, Container>[];
}>;

Current ordered collection of managed window snapshots.

Type Parameter
Launch extends WindowLaunch
Container

WindowMounttype alias

Section titled “WindowMount”
Signature
type WindowMount<Launch, Container> = (
container,
launch,
signal,
events,
) => WindowHost<Launch> | Promise<WindowHost<Launch>>;

Create a host-owned mount in a container, observing cancellation and navigation.

Type Parameter
Launch extends WindowLaunch
Container
Parameter Type
container Container
launch Launch
signal AbortSignal
events WindowEvents

| WindowHost<Launch> | Promise<WindowHost<Launch>>


WindowManagertype alias

Section titled “WindowManager”
Signature
type WindowManager<Launch, Container> = Readonly<{
open: (launch) => Promise<void>;
attach: (windowId) => void;
minimize: (windowId) => Promise<void>;
restore: (windowId) => Promise<void>;
hideAll: () => Promise<void>;
restoreHidden: () => Promise<void>;
close: (windowId) => Promise<void>;
reconfigure: (windowId, launch) => Promise<void>;
update: (windowId, derive) => Promise<void>;
replace: (windowId, launch) => Promise<void>;
back: (windowId) => Promise<boolean>;
activateNavigation: (windowId, activation) => Promise<boolean>;
activateStatus: (windowId, action) => Promise<boolean>;
registerComputerChoice: (windowId, handler) => () => void;
dispose: () => Promise<void>;
read: () => WindowsProjection<Launch, Container>;
subscribe: (listener) => () => void;
}>;

Own window lifetimes, visibility and serialized host mutations.

Type Parameter
Launch extends WindowLaunch
Container

WindowManagerOptionstype alias

Section titled “WindowManagerOptions”
Signature
type WindowManagerOptions<Launch, Container> = Readonly<{
mount: WindowMount<Launch, Container>;
createContainer: (launch) => Container;
waitForAttachment?: boolean;
onFailure?: (failure) => void;
isAttached?: (container) => boolean;
validateReconfiguration?: (current, next) => void;
isChromeOnlyChange?: (current, next) => boolean;
}>;

Host adapters used to create, attach and validate window mounts.

Type Parameter
Launch extends WindowLaunch
Container

hasVisibleWindows()function

Section titled “hasVisibleWindows()”
Signature
function hasVisibleWindows<Launch, Container>(projection): boolean;

Whether any projected App window is still visible in the workspace.

Type Parameter
Launch extends Readonly<{ windowId: string; }>
Container
Parameter Type
projection WindowsProjection<Launch, Container>

boolean


createWindowManager()function

Section titled “createWindowManager()”
Signature
function createWindowManager<Launch, Container>(
options,
): WindowManager<Launch, Container>;

Owns App-window generations while leaving selection and App authority to the caller. A stale mount is always disposed when it eventually resolves.

Type Parameter
Launch extends Readonly<{ windowId: string; }>
Container
Parameter Type
options WindowManagerOptions<Launch, Container>

WindowManager<Launch, Container>