Skip to content
API reference

command-host

Import
import * as api from "@fungi.computer/nacre/command-host";
Kind Export Description
type alias AppCommandOptional An optional field a declaration may carry as explicitly undefined.
type alias AppCommandDeclaration The digest-covered command rows a mounted App’s Release declares, as the host receives them. Oyster compares and projects them; the Release declaration grammar stays with its owner, which hands rows of this shape.
type alias AppSurfaceCommandMount The command side of one mounted App’s host handlers.
type alias PaneCommands Commands owned by one pane, projected to globals plus its focus scope.
type alias PaneCommandMount Closing a pane withdraws all its leases, presenters and subscriptions.
type alias AppSurfaceCommandHost The shell-owned Whistle graph and its focused menu projection.
constant appDirectorySourceId Whistle source of Release-advertised rows for Apps not yet mounted.
function commandPaletteReservedChordForPlatform() Select the shell command-palette chord for a Mac or non-Mac keyboard.
function commandPaletteReservedChordForUserAgent() Select the shell command-palette chord from the embedding browser user agent.
function createAppSurfaceCommandHost() Own one shell’s Whistle runtime for mounted Apps and local panes. The embedding host supplies verified Release declarations and decides which App or pane has focus.

AppCommandOptionaltype alias

Section titled “AppCommandOptional”
Signature
type AppCommandOptional<T> = T | undefined;

An optional field a declaration may carry as explicitly undefined.

Type Parameter
T

AppCommandDeclarationtype alias

Section titled “AppCommandDeclaration”
Signature
type AppCommandDeclaration = Readonly<{
id: string;
title: string;
category: string;
description?: AppCommandOptional<string>;
projections?: AppCommandOptional<
Readonly<{
bindings?: AppCommandOptional<
Readonly<{
order?: AppCommandOptional<number>;
values: readonly string[];
}>
>;
agent?: AppCommandOptional<
Readonly<{
order?: AppCommandOptional<number>;
keybind?: AppCommandOptional<string>;
}>
>;
help?: AppCommandOptional<
Readonly<{
order?: AppCommandOptional<number>;
}>
>;
menu?: AppCommandOptional<
Readonly<{
order?: AppCommandOptional<number>;
}>
>;
palette?: AppCommandOptional<
Readonly<{
order?: AppCommandOptional<number>;
}>
>;
slash?: AppCommandOptional<
Readonly<{
order?: AppCommandOptional<number>;
aliases: readonly string[];
}>
>;
}>
>;
}>;

The digest-covered command rows a mounted App’s Release declares, as the host receives them. Oyster compares and projects them; the Release declaration grammar stays with its owner, which hands rows of this shape.


AppSurfaceCommandMounttype alias

Section titled “AppSurfaceCommandMount”
Signature
type AppSurfaceCommandMount = Readonly<{
agentCommands: Pick<WhistleRuntime, "snapshot" | "execute">;
handlers: Pick<AppHostHandlers, "registerCommands" | "invokeReservedChord">;
dispose: () => void;
}>;

The command side of one mounted App’s host handlers.


PaneCommandstype alias

Section titled “PaneCommands”
Signature
type PaneCommands = Readonly<{
commandId: (id) => string;
contribute: (commands) => WhistleContributionLease;
execute: WhistleRuntime["execute"];
snapshot: WhistleRuntime["snapshot"];
subscribe: WhistleRuntime["subscribe"];
present: WhistleRuntime["present"];
}>;

Commands owned by one pane, projected to globals plus its focus scope.


PaneCommandMounttype alias

Section titled “PaneCommandMount”
Signature
type PaneCommandMount = PaneCommands &
Readonly<{
dispose: () => void;
}>;

Closing a pane withdraws all its leases, presenters and subscriptions.


AppSurfaceCommandHosttype alias

Section titled “AppSurfaceCommandHost”
Signature
type AppSurfaceCommandHost = Readonly<{
mountPane: (paneId) => PaneCommandMount;
mount: (mountId, declarations) => AppSurfaceCommandMount;
focus: (mountId) => void;
registerShellCommands: (commands) => () => void;
registerDirectoryCommands: (commands, run) => () => void;
menu: () => readonly WhistleMenuProjection[];
active: () => WhistleSnapshot;
execute: (commandId, input) => Promise<WhistleExecutionOutcome>;
snapshot: () => WhistleSnapshot;
subscribe: (listener) => () => void;
dispose: () => void;
}>;

The shell-owned Whistle graph and its focused menu projection.

appDirectorySourceIdconstant

Section titled “appDirectorySourceId”
Signature
const appDirectorySourceId: "app-directory" = "app-directory";

Whistle source of Release-advertised rows for Apps not yet mounted.

commandPaletteReservedChordForPlatform()function

Section titled “commandPaletteReservedChordForPlatform()”
Signature
function commandPaletteReservedChordForPlatform(mac): AppHostReservedChord;

Select the shell command-palette chord for a Mac or non-Mac keyboard.

Parameter Type
mac boolean

AppHostReservedChord


commandPaletteReservedChordForUserAgent()function

Section titled “commandPaletteReservedChordForUserAgent()”
Signature
function commandPaletteReservedChordForUserAgent(
userAgent,
): AppHostReservedChord;

Select the shell command-palette chord from the embedding browser user agent.

Parameter Type
userAgent string

AppHostReservedChord


createAppSurfaceCommandHost()function

Section titled “createAppSurfaceCommandHost()”
Signature
function createAppSurfaceCommandHost(whistle?): AppSurfaceCommandHost;

Own one shell’s Whistle runtime for mounted Apps and local panes. The embedding host supplies verified Release declarations and decides which App or pane has focus.

Agar invokes registerCommands once for the aggregate command set of a mount. The adapter keeps that aggregate as one Whistle generation, so an Agar update replaces the generation atomically and disposal releases only that App. Command handlers remain the App’s callback; the shell only adds the Whistle identity and routes focused menu execution to it.

Parameter Type
whistle WhistleRuntime

AppSurfaceCommandHost