restty 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/atlas-builder.d.ts +38 -0
- package/dist/app/font-sources.d.ts +2 -0
- package/dist/app/index.js +234 -90
- package/dist/app/pane-app-manager.d.ts +43 -0
- package/dist/app/panes-context-menu.d.ts +10 -0
- package/dist/app/panes-styles.d.ts +5 -0
- package/dist/app/panes-types.d.ts +89 -0
- package/dist/app/panes.d.ts +10 -0
- package/dist/app/restty.d.ts +20 -0
- package/dist/app/session.d.ts +6 -0
- package/dist/app/types.d.ts +123 -0
- package/dist/fonts/index.js +2 -1
- package/dist/fonts/manager.d.ts +25 -0
- package/dist/fonts/nerd-constraints.d.ts +4 -0
- package/dist/fonts/nerd-ranges.d.ts +2 -0
- package/dist/fonts/types.d.ts +51 -0
- package/dist/grid/grid.d.ts +22 -0
- package/dist/grid/types.d.ts +32 -0
- package/dist/ime/ime.d.ts +13 -0
- package/dist/ime/types.d.ts +8 -0
- package/dist/index.js +234 -90
- package/dist/input/ansi.d.ts +3 -0
- package/dist/input/index.js +5 -1
- package/dist/input/mouse.d.ts +10 -0
- package/dist/input/output.d.ts +11 -0
- package/dist/input/types.d.ts +7 -0
- package/dist/internal.js +234 -90
- package/dist/pty/kitty-media.d.ts +3 -0
- package/dist/pty/pty.d.ts +11 -0
- package/dist/pty/types.d.ts +49 -0
- package/dist/renderer/box-drawing-map.d.ts +4 -0
- package/dist/renderer/index.js +145 -42
- package/dist/renderer/shaders.d.ts +7 -0
- package/dist/renderer/shapes.d.ts +43 -0
- package/dist/renderer/types.d.ts +43 -0
- package/dist/renderer/webgpu.d.ts +11 -0
- package/dist/selection/selection.d.ts +24 -0
- package/dist/selection/types.d.ts +13 -0
- package/dist/theme/catalog.d.ts +5 -0
- package/dist/theme/ghostty.d.ts +18 -0
- package/dist/wasm/embedded.d.ts +1 -0
- package/dist/wasm/runtime.d.ts +29 -0
- package/package.json +1 -1
|
@@ -1,28 +1,55 @@
|
|
|
1
1
|
import { type ResttyPaneStyleOptions, type ResttyPaneStylesOptions, type ResttyPaneContextMenuOptions, type ResttyPaneManager, type ResttyPaneShortcutsOptions, type ResttyPaneWithApp } from "./panes";
|
|
2
2
|
import type { ResttyAppOptions, ResttyAppSession } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* A pane created by the app pane manager, extending the base pane
|
|
5
|
+
* with DOM elements needed by the terminal app.
|
|
6
|
+
*/
|
|
3
7
|
export type ResttyManagedAppPane = ResttyPaneWithApp & {
|
|
8
|
+
/** The canvas element used for terminal rendering. */
|
|
4
9
|
canvas: HTMLCanvasElement;
|
|
10
|
+
/** Hidden textarea for IME composition input. */
|
|
5
11
|
imeInput: HTMLTextAreaElement;
|
|
12
|
+
/** Pre element for terminal debug / accessibility output. */
|
|
6
13
|
termDebugEl: HTMLPreElement;
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Default CSS class names for pane DOM elements.
|
|
17
|
+
*/
|
|
8
18
|
export type ResttyPaneDomDefaults = {
|
|
9
19
|
paneClassName?: string;
|
|
10
20
|
canvasClassName?: string;
|
|
11
21
|
imeInputClassName?: string;
|
|
12
22
|
termDebugClassName?: string;
|
|
13
23
|
};
|
|
24
|
+
/** Style options for managed panes (alias for ResttyPaneStyleOptions). */
|
|
14
25
|
export type ResttyManagedPaneStyleOptions = ResttyPaneStyleOptions;
|
|
26
|
+
/** Style configuration including enabled flag (alias for ResttyPaneStylesOptions). */
|
|
15
27
|
export type ResttyManagedPaneStylesOptions = ResttyPaneStylesOptions;
|
|
28
|
+
/** App options minus the DOM/session fields that the pane manager provides. */
|
|
16
29
|
export type ResttyPaneAppOptionsInput = Omit<ResttyAppOptions, "canvas" | "imeInput" | "session">;
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for the built-in default context menu.
|
|
32
|
+
*/
|
|
17
33
|
export type ResttyDefaultPaneContextMenuOptions = {
|
|
34
|
+
/** Whether the default context menu is enabled (default true). */
|
|
18
35
|
enabled?: boolean;
|
|
36
|
+
/** Guard predicate; return false to suppress the menu for a given event. */
|
|
19
37
|
canOpen?: (event: MouseEvent, pane: ResttyManagedAppPane) => boolean;
|
|
38
|
+
/** Override the modifier key label shown in shortcut hints. */
|
|
20
39
|
modKeyLabel?: string;
|
|
40
|
+
/** Provide the PTY WebSocket URL for the connect/disconnect menu item. */
|
|
21
41
|
getPtyUrl?: () => string | null | undefined;
|
|
22
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Options for creating an app-level pane manager that wires up DOM
|
|
45
|
+
* elements, the terminal app, and the shared session automatically.
|
|
46
|
+
*/
|
|
23
47
|
export type CreateResttyAppPaneManagerOptions = {
|
|
48
|
+
/** Root element that will contain all pane DOM trees. */
|
|
24
49
|
root: HTMLElement;
|
|
50
|
+
/** Shared session for WASM/WebGPU resources (defaults to the global session). */
|
|
25
51
|
session?: ResttyAppSession;
|
|
52
|
+
/** Per-pane app options, static object or factory receiving pane context. */
|
|
26
53
|
appOptions?: ResttyPaneAppOptionsInput | ((context: {
|
|
27
54
|
id: number;
|
|
28
55
|
sourcePane: ResttyManagedAppPane | null;
|
|
@@ -30,17 +57,33 @@ export type CreateResttyAppPaneManagerOptions = {
|
|
|
30
57
|
imeInput: HTMLTextAreaElement;
|
|
31
58
|
termDebugEl: HTMLPreElement;
|
|
32
59
|
}) => ResttyPaneAppOptionsInput);
|
|
60
|
+
/** Override default CSS class names for pane DOM elements. */
|
|
33
61
|
paneDom?: ResttyPaneDomDefaults;
|
|
62
|
+
/** Automatically call app.init() after pane creation (default true). */
|
|
34
63
|
autoInit?: boolean;
|
|
64
|
+
/** Minimum pane size in pixels during split-resize (default 96). */
|
|
35
65
|
minPaneSize?: number;
|
|
66
|
+
/** Enable or configure built-in pane CSS styles. */
|
|
36
67
|
paneStyles?: boolean | ResttyManagedPaneStylesOptions;
|
|
68
|
+
/** Enable or configure keyboard shortcuts for splitting. */
|
|
37
69
|
shortcuts?: boolean | ResttyPaneShortcutsOptions;
|
|
70
|
+
/** Custom context menu implementation (overrides defaultContextMenu). */
|
|
38
71
|
contextMenu?: ResttyPaneContextMenuOptions<ResttyManagedAppPane> | null;
|
|
72
|
+
/** Enable or configure the built-in default context menu. */
|
|
39
73
|
defaultContextMenu?: boolean | ResttyDefaultPaneContextMenuOptions;
|
|
74
|
+
/** Called after a new pane is created. */
|
|
40
75
|
onPaneCreated?: (pane: ResttyManagedAppPane) => void;
|
|
76
|
+
/** Called after a pane is closed. */
|
|
41
77
|
onPaneClosed?: (pane: ResttyManagedAppPane) => void;
|
|
78
|
+
/** Called after a pane is split. */
|
|
42
79
|
onPaneSplit?: (sourcePane: ResttyManagedAppPane, createdPane: ResttyManagedAppPane, direction: "vertical" | "horizontal") => void;
|
|
80
|
+
/** Called when the active pane changes (or becomes null). */
|
|
43
81
|
onActivePaneChange?: (pane: ResttyManagedAppPane | null) => void;
|
|
82
|
+
/** Called when the layout changes (splits, closes, resizes). */
|
|
44
83
|
onLayoutChanged?: () => void;
|
|
45
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Create an app-aware pane manager that automatically constructs
|
|
87
|
+
* canvas, IME input, and terminal app instances for each pane.
|
|
88
|
+
*/
|
|
46
89
|
export declare function createResttyAppPaneManager(options: CreateResttyAppPaneManagerOptions): ResttyPaneManager<ResttyManagedAppPane>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ResttyPaneContextMenuOptions, ResttyPaneDefinition, ResttyPaneManager } from "./panes-types";
|
|
2
|
+
/**
|
|
3
|
+
* Context menu controller for pane right-click interactions.
|
|
4
|
+
* - element: the menu DOM node
|
|
5
|
+
* - isOpen: returns true if menu is currently visible
|
|
6
|
+
* - containsTarget: checks if an event target is inside the menu
|
|
7
|
+
* - show: displays the menu at client coordinates for a given pane
|
|
8
|
+
* - hide: hides the menu
|
|
9
|
+
* - destroy: removes the menu from the DOM
|
|
10
|
+
*/
|
|
2
11
|
export type PaneContextMenuController<TPane extends ResttyPaneDefinition> = {
|
|
3
12
|
element: HTMLDivElement;
|
|
4
13
|
isOpen: () => boolean;
|
|
@@ -7,6 +16,7 @@ export type PaneContextMenuController<TPane extends ResttyPaneDefinition> = {
|
|
|
7
16
|
hide: () => void;
|
|
8
17
|
destroy: () => void;
|
|
9
18
|
};
|
|
19
|
+
/** Creates a context menu controller that renders menu items, handles positioning within viewport bounds, and manages click-to-hide behavior. */
|
|
10
20
|
export declare function createPaneContextMenuController<TPane extends ResttyPaneDefinition>(options: {
|
|
11
21
|
contextMenu: ResttyPaneContextMenuOptions<TPane>;
|
|
12
22
|
doc: Document;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ResttyPaneStyleOptions } from "./panes-types";
|
|
2
|
+
/** Default style options for pane layout and appearance. */
|
|
2
3
|
export declare const DEFAULT_RESTTY_PANE_STYLE_OPTIONS: Required<ResttyPaneStyleOptions>;
|
|
4
|
+
/** Validates and normalizes pane style options, clamping numeric values to safe ranges and applying defaults. */
|
|
3
5
|
export declare function normalizePaneStyleOptions(options: ResttyPaneStyleOptions): Required<ResttyPaneStyleOptions>;
|
|
6
|
+
/** Injects the pane stylesheet into the document if not already present. */
|
|
4
7
|
export declare function ensureResttyPaneStylesDocument(doc: Document): void;
|
|
8
|
+
/** Applies pane style options to a root element via CSS custom properties. */
|
|
5
9
|
export declare function applyPaneStyleOptionsToRoot(root: HTMLElement, options: Readonly<Required<ResttyPaneStyleOptions>>): void;
|
|
10
|
+
/** Removes pane style class and custom properties from a root element. */
|
|
6
11
|
export declare function clearPaneStyleOptionsFromRoot(root: HTMLElement): void;
|
|
@@ -1,86 +1,175 @@
|
|
|
1
1
|
import type { ResttyApp } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Direction for splitting a pane.
|
|
4
|
+
* - vertical: split left/right
|
|
5
|
+
* - horizontal: split top/bottom
|
|
6
|
+
*/
|
|
2
7
|
export type ResttyPaneSplitDirection = "vertical" | "horizontal";
|
|
8
|
+
/**
|
|
9
|
+
* A single item in a pane context menu.
|
|
10
|
+
*/
|
|
3
11
|
export type ResttyPaneContextMenuItem = {
|
|
12
|
+
/** Display text for the menu item. */
|
|
4
13
|
label: string;
|
|
14
|
+
/** Keyboard shortcut hint shown alongside the label. */
|
|
5
15
|
shortcut?: string;
|
|
16
|
+
/** Whether the item is interactive (default true). */
|
|
6
17
|
enabled?: boolean;
|
|
18
|
+
/** Render the item with destructive/warning styling. */
|
|
7
19
|
danger?: boolean;
|
|
20
|
+
/** Callback invoked when the item is selected. */
|
|
8
21
|
action: () => void | Promise<void>;
|
|
9
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Minimum definition of a pane managed by the pane manager.
|
|
25
|
+
*/
|
|
10
26
|
export type ResttyPaneDefinition = {
|
|
27
|
+
/** Unique numeric identifier for this pane. */
|
|
11
28
|
id: number;
|
|
29
|
+
/** DOM container element that holds the pane content. */
|
|
12
30
|
container: HTMLDivElement;
|
|
31
|
+
/** Element to receive focus when the pane is activated. */
|
|
13
32
|
focusTarget?: HTMLElement | null;
|
|
14
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for pane keyboard shortcuts.
|
|
36
|
+
*/
|
|
15
37
|
export type ResttyPaneShortcutsOptions = {
|
|
38
|
+
/** Enable or disable shortcut handling (default true). */
|
|
16
39
|
enabled?: boolean;
|
|
40
|
+
/** Guard that determines whether a keyboard event should be handled. */
|
|
17
41
|
canHandleEvent?: (event: KeyboardEvent) => boolean;
|
|
42
|
+
/** Guard that determines whether the event target is an allowed input element. */
|
|
18
43
|
isAllowedInputTarget?: (target: HTMLElement) => boolean;
|
|
19
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for the pane right-click context menu.
|
|
47
|
+
*/
|
|
20
48
|
export type ResttyPaneContextMenuOptions<TPane extends ResttyPaneDefinition> = {
|
|
49
|
+
/** Guard that determines whether the context menu may open for a given event and pane. */
|
|
21
50
|
canOpen?: (event: MouseEvent, pane: TPane) => boolean;
|
|
51
|
+
/** Build the list of menu items and separators for a pane. */
|
|
22
52
|
getItems: (pane: TPane, manager: ResttyPaneManager<TPane>) => Array<ResttyPaneContextMenuItem | "separator">;
|
|
23
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Visual styling options for pane layout and dividers.
|
|
56
|
+
*/
|
|
24
57
|
export type ResttyPaneStyleOptions = {
|
|
58
|
+
/** CSS background color for the split container. */
|
|
25
59
|
splitBackground?: string;
|
|
60
|
+
/** CSS background color for individual panes. */
|
|
26
61
|
paneBackground?: string;
|
|
62
|
+
/** Opacity applied to inactive panes (0-1). */
|
|
27
63
|
inactivePaneOpacity?: number;
|
|
64
|
+
/** Opacity applied to the active pane (0-1). */
|
|
28
65
|
activePaneOpacity?: number;
|
|
66
|
+
/** Duration in ms for opacity transitions between active/inactive states. */
|
|
29
67
|
opacityTransitionMs?: number;
|
|
68
|
+
/** Divider/gutter thickness in CSS pixels. */
|
|
30
69
|
dividerThicknessPx?: number;
|
|
31
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Pane style options with an enable/disable toggle.
|
|
73
|
+
*/
|
|
32
74
|
export type ResttyPaneStylesOptions = ResttyPaneStyleOptions & {
|
|
75
|
+
/** Enable or disable automatic pane styling (default true). */
|
|
33
76
|
enabled?: boolean;
|
|
34
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Options for creating a pane manager instance.
|
|
80
|
+
*/
|
|
35
81
|
export type CreateResttyPaneManagerOptions<TPane extends ResttyPaneDefinition> = {
|
|
82
|
+
/** Root DOM element that contains all pane containers. */
|
|
36
83
|
root: HTMLElement;
|
|
84
|
+
/** Factory function called to create a new pane. */
|
|
37
85
|
createPane: (context: {
|
|
38
86
|
id: number;
|
|
39
87
|
sourcePane: TPane | null;
|
|
40
88
|
manager: ResttyPaneManager<TPane>;
|
|
41
89
|
}) => TPane;
|
|
90
|
+
/** Cleanup function called when a pane is removed. */
|
|
42
91
|
destroyPane?: (pane: TPane) => void;
|
|
92
|
+
/** Called after a new pane has been created and inserted into the layout. */
|
|
43
93
|
onPaneCreated?: (pane: TPane) => void;
|
|
94
|
+
/** Called after a pane has been closed and removed from the layout. */
|
|
44
95
|
onPaneClosed?: (pane: TPane) => void;
|
|
96
|
+
/** Called after a pane has been split into two. */
|
|
45
97
|
onPaneSplit?: (sourcePane: TPane, createdPane: TPane, direction: ResttyPaneSplitDirection) => void;
|
|
98
|
+
/** Called when the active pane changes (null when all panes are closed). */
|
|
46
99
|
onActivePaneChange?: (pane: TPane | null) => void;
|
|
100
|
+
/** Called after any layout change (split, close, resize). */
|
|
47
101
|
onLayoutChanged?: () => void;
|
|
102
|
+
/** Minimum pane size in CSS pixels before further splits are rejected. */
|
|
48
103
|
minPaneSize?: number;
|
|
104
|
+
/** Context menu configuration, or null to disable. */
|
|
49
105
|
contextMenu?: ResttyPaneContextMenuOptions<TPane> | null;
|
|
106
|
+
/** Keyboard shortcut configuration, or a boolean to enable/disable with defaults. */
|
|
50
107
|
shortcuts?: boolean | ResttyPaneShortcutsOptions;
|
|
108
|
+
/** Pane styling configuration, or a boolean to enable/disable with defaults. */
|
|
51
109
|
styles?: boolean | ResttyPaneStylesOptions;
|
|
52
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Public API for managing a split-pane layout.
|
|
113
|
+
*/
|
|
53
114
|
export type ResttyPaneManager<TPane extends ResttyPaneDefinition> = {
|
|
115
|
+
/** Return all currently open panes. */
|
|
54
116
|
getPanes: () => TPane[];
|
|
117
|
+
/** Look up a pane by its numeric ID, or null if not found. */
|
|
55
118
|
getPaneById: (id: number) => TPane | null;
|
|
119
|
+
/** Return the currently active pane, or null if none. */
|
|
56
120
|
getActivePane: () => TPane | null;
|
|
121
|
+
/** Return the pane that currently has DOM focus, or null if none. */
|
|
57
122
|
getFocusedPane: () => TPane | null;
|
|
123
|
+
/** Create the first pane in an empty layout. */
|
|
58
124
|
createInitialPane: (options?: {
|
|
59
125
|
focus?: boolean;
|
|
60
126
|
}) => TPane;
|
|
127
|
+
/** Set a pane as active by ID, optionally moving DOM focus to it. */
|
|
61
128
|
setActivePane: (id: number, options?: {
|
|
62
129
|
focus?: boolean;
|
|
63
130
|
}) => void;
|
|
131
|
+
/** Mark a pane as focused by ID without necessarily changing the active pane. */
|
|
64
132
|
markPaneFocused: (id: number, options?: {
|
|
65
133
|
focus?: boolean;
|
|
66
134
|
}) => void;
|
|
135
|
+
/** Split an existing pane by ID in the given direction, returning the new pane or null on failure. */
|
|
67
136
|
splitPane: (id: number, direction: ResttyPaneSplitDirection) => TPane | null;
|
|
137
|
+
/** Split the currently active pane, returning the new pane or null on failure. */
|
|
68
138
|
splitActivePane: (direction: ResttyPaneSplitDirection) => TPane | null;
|
|
139
|
+
/** Close a pane by ID, returning true if it was found and removed. */
|
|
69
140
|
closePane: (id: number) => boolean;
|
|
141
|
+
/** Return the current resolved style options. */
|
|
70
142
|
getStyleOptions: () => Readonly<Required<ResttyPaneStyleOptions>>;
|
|
143
|
+
/** Update style options and reapply them to the layout. */
|
|
71
144
|
setStyleOptions: (options: ResttyPaneStyleOptions) => void;
|
|
145
|
+
/** Schedule an asynchronous layout recalculation. */
|
|
72
146
|
requestLayoutSync: () => void;
|
|
147
|
+
/** Dismiss any open context menu. */
|
|
73
148
|
hideContextMenu: () => void;
|
|
149
|
+
/** Tear down all panes, event listeners, and DOM structures. */
|
|
74
150
|
destroy: () => void;
|
|
75
151
|
};
|
|
152
|
+
/**
|
|
153
|
+
* Pane definition extended with a ResttyApp instance and pause control.
|
|
154
|
+
*/
|
|
76
155
|
export type ResttyPaneWithApp = ResttyPaneDefinition & {
|
|
156
|
+
/** The terminal app running inside this pane. */
|
|
77
157
|
app: ResttyApp;
|
|
158
|
+
/** Whether the pane's renderer is currently paused. */
|
|
78
159
|
paused?: boolean;
|
|
160
|
+
/** Pause or resume this pane's renderer. */
|
|
79
161
|
setPaused?: (value: boolean) => void;
|
|
80
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* Options for building the default set of context menu items for a pane with an app.
|
|
165
|
+
*/
|
|
81
166
|
export type CreateDefaultResttyPaneContextMenuItemsOptions<TPane extends ResttyPaneWithApp> = {
|
|
167
|
+
/** The pane the context menu was opened on. */
|
|
82
168
|
pane: TPane;
|
|
169
|
+
/** Subset of the pane manager API needed for split/close actions. */
|
|
83
170
|
manager: Pick<ResttyPaneManager<TPane>, "splitPane" | "closePane" | "getPanes">;
|
|
171
|
+
/** Platform modifier key label (e.g. "Cmd" or "Ctrl") shown in shortcut hints. */
|
|
84
172
|
modKeyLabel?: string;
|
|
173
|
+
/** Provider for the current PTY URL, used for reconnect/copy-URL items. */
|
|
85
174
|
getPtyUrl?: () => string | null | undefined;
|
|
86
175
|
};
|
package/dist/app/panes.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { CreateDefaultResttyPaneContextMenuItemsOptions, CreateResttyPaneManagerOptions, ResttyPaneContextMenuItem, ResttyPaneDefinition, ResttyPaneManager, ResttyPaneWithApp } from "./panes-types";
|
|
2
2
|
export type { CreateDefaultResttyPaneContextMenuItemsOptions, CreateResttyPaneManagerOptions, ResttyPaneContextMenuItem, ResttyPaneContextMenuOptions, ResttyPaneDefinition, ResttyPaneManager, ResttyPaneShortcutsOptions, ResttyPaneSplitDirection, ResttyPaneStyleOptions, ResttyPaneStylesOptions, ResttyPaneWithApp, } from "./panes-types";
|
|
3
|
+
/** Return the platform-appropriate shortcut modifier label ("Cmd" on macOS, "Ctrl" elsewhere). */
|
|
3
4
|
export declare function getResttyShortcutModifierLabel(): "Cmd" | "Ctrl";
|
|
5
|
+
/**
|
|
6
|
+
* Build the standard right-click context menu items for a pane
|
|
7
|
+
* (copy, paste, split, close, clear, PTY toggle, pause toggle).
|
|
8
|
+
*/
|
|
4
9
|
export declare function createDefaultResttyPaneContextMenuItems<TPane extends ResttyPaneWithApp>(options: CreateDefaultResttyPaneContextMenuItemsOptions<TPane>): Array<ResttyPaneContextMenuItem | "separator">;
|
|
10
|
+
/**
|
|
11
|
+
* Create a pane manager that owns a split-pane layout inside a root
|
|
12
|
+
* element. Handles pane creation, splitting, resizing, focus
|
|
13
|
+
* tracking, keyboard shortcuts, and context menus.
|
|
14
|
+
*/
|
|
5
15
|
export declare function createResttyPaneManager<TPane extends ResttyPaneDefinition>(options: CreateResttyPaneManagerOptions<TPane>): ResttyPaneManager<TPane>;
|
package/dist/app/restty.d.ts
CHANGED
|
@@ -3,13 +3,22 @@ import type { GhosttyTheme } from "../theme";
|
|
|
3
3
|
import { type CreateResttyAppPaneManagerOptions, type ResttyManagedAppPane, type ResttyManagedPaneStyleOptions, type ResttyPaneAppOptionsInput } from "./pane-app-manager";
|
|
4
4
|
import type { ResttyPaneManager, ResttyPaneSplitDirection } from "./panes";
|
|
5
5
|
import type { ResttyFontSource } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Top-level configuration for creating a Restty instance.
|
|
8
|
+
*/
|
|
6
9
|
export type ResttyOptions = Omit<CreateResttyAppPaneManagerOptions, "appOptions"> & {
|
|
10
|
+
/** Per-pane app options, static or factory. */
|
|
7
11
|
appOptions?: CreateResttyAppPaneManagerOptions["appOptions"];
|
|
12
|
+
/** Font sources applied to every pane. */
|
|
8
13
|
fontSources?: ResttyPaneAppOptionsInput["fontSources"];
|
|
14
|
+
/** Whether to create the first pane automatically (default true). */
|
|
9
15
|
createInitialPane?: boolean | {
|
|
10
16
|
focus?: boolean;
|
|
11
17
|
};
|
|
12
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Public API surface exposed by each pane handle.
|
|
21
|
+
*/
|
|
13
22
|
export type ResttyPaneApi = {
|
|
14
23
|
id: number;
|
|
15
24
|
setRenderer: (value: "auto" | "webgpu" | "webgl2") => void;
|
|
@@ -33,6 +42,11 @@ export type ResttyPaneApi = {
|
|
|
33
42
|
getBackend: () => string;
|
|
34
43
|
getRawPane: () => ResttyManagedAppPane;
|
|
35
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Thin wrapper around a managed pane that delegates calls to the
|
|
47
|
+
* underlying app. Resolves the pane lazily so it stays valid across
|
|
48
|
+
* layout changes.
|
|
49
|
+
*/
|
|
36
50
|
export declare class ResttyPaneHandle implements ResttyPaneApi {
|
|
37
51
|
private readonly resolvePane;
|
|
38
52
|
constructor(resolvePane: () => ResttyManagedAppPane);
|
|
@@ -58,6 +72,11 @@ export declare class ResttyPaneHandle implements ResttyPaneApi {
|
|
|
58
72
|
getBackend(): string;
|
|
59
73
|
getRawPane(): ResttyManagedAppPane;
|
|
60
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Main entry point for the restty terminal widget. Manages a set of
|
|
77
|
+
* split panes, each running its own terminal app, and exposes
|
|
78
|
+
* convenience methods that operate on the active pane.
|
|
79
|
+
*/
|
|
61
80
|
export declare class Restty {
|
|
62
81
|
readonly paneManager: ResttyPaneManager<ResttyManagedAppPane>;
|
|
63
82
|
private fontSources;
|
|
@@ -112,4 +131,5 @@ export declare class Restty {
|
|
|
112
131
|
private requirePaneById;
|
|
113
132
|
private requireActivePaneHandle;
|
|
114
133
|
}
|
|
134
|
+
/** Create a new Restty instance with the given options. */
|
|
115
135
|
export declare function createRestty(options: ResttyOptions): Restty;
|
package/dist/app/session.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { ResttyAppSession } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new app session that lazily loads the WASM module and
|
|
4
|
+
* initializes the WebGPU core on first use. Multiple panes can
|
|
5
|
+
* share a single session to avoid duplicate resource loading.
|
|
6
|
+
*/
|
|
2
7
|
export declare function createResttyAppSession(): ResttyAppSession;
|
|
8
|
+
/** Return the global default session, creating it on first call. */
|
|
3
9
|
export declare function getDefaultResttyAppSession(): ResttyAppSession;
|
package/dist/app/types.d.ts
CHANGED
|
@@ -3,86 +3,182 @@ import type { PtyTransport } from "../pty";
|
|
|
3
3
|
import type { WebGPUCoreState } from "../renderer";
|
|
4
4
|
import type { GhosttyTheme } from "../theme";
|
|
5
5
|
import type { ResttyWasm } from "../wasm";
|
|
6
|
+
/** Callback for WASM log messages. */
|
|
6
7
|
export type ResttyWasmLogListener = (message: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Session provider that supplies shared WASM and WebGPU resources.
|
|
10
|
+
*/
|
|
7
11
|
export type ResttyAppSession = {
|
|
12
|
+
/** Lazily initialize and return the WASM module. */
|
|
8
13
|
getWasm: () => Promise<ResttyWasm>;
|
|
14
|
+
/** Lazily initialize and return the WebGPU renderer core for a canvas. */
|
|
9
15
|
getWebGPUCore: (canvas: HTMLCanvasElement) => Promise<WebGPUCoreState | null>;
|
|
16
|
+
/** Subscribe to WASM log output. */
|
|
10
17
|
addWasmLogListener?: (listener: ResttyWasmLogListener) => void;
|
|
18
|
+
/** Unsubscribe from WASM log output. */
|
|
11
19
|
removeWasmLogListener?: (listener: ResttyWasmLogListener) => void;
|
|
12
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Optional DOM elements for debug/status displays.
|
|
23
|
+
*/
|
|
13
24
|
export type ResttyAppElements = {
|
|
25
|
+
/** Renderer backend name display. */
|
|
14
26
|
backendEl?: HTMLElement | null;
|
|
27
|
+
/** Frames-per-second counter display. */
|
|
15
28
|
fpsEl?: HTMLElement | null;
|
|
29
|
+
/** Device pixel ratio display. */
|
|
16
30
|
dprEl?: HTMLElement | null;
|
|
31
|
+
/** Canvas pixel size display. */
|
|
17
32
|
sizeEl?: HTMLElement | null;
|
|
33
|
+
/** Grid column/row count display. */
|
|
18
34
|
gridEl?: HTMLElement | null;
|
|
35
|
+
/** Cell pixel dimensions display. */
|
|
19
36
|
cellEl?: HTMLElement | null;
|
|
37
|
+
/** Terminal size (cols x rows) display. */
|
|
20
38
|
termSizeEl?: HTMLElement | null;
|
|
39
|
+
/** Cursor position display. */
|
|
21
40
|
cursorPosEl?: HTMLElement | null;
|
|
41
|
+
/** Input sequence debug display. */
|
|
22
42
|
inputDebugEl?: HTMLElement | null;
|
|
43
|
+
/** General debug text display. */
|
|
23
44
|
dbgEl?: HTMLElement | null;
|
|
45
|
+
/** PTY connection status display. */
|
|
24
46
|
ptyStatusEl?: HTMLElement | null;
|
|
47
|
+
/** Mouse mode/status display. */
|
|
25
48
|
mouseStatusEl?: HTMLElement | null;
|
|
49
|
+
/** Terminal internal debug display. */
|
|
26
50
|
termDebugEl?: HTMLElement | null;
|
|
51
|
+
/** Scrollable log output display. */
|
|
27
52
|
logEl?: HTMLElement | null;
|
|
53
|
+
/** Glyph atlas info display. */
|
|
28
54
|
atlasInfoEl?: HTMLElement | null;
|
|
55
|
+
/** Canvas element for atlas visualization. */
|
|
29
56
|
atlasCanvas?: HTMLCanvasElement | null;
|
|
30
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Callbacks fired by the app when internal state changes.
|
|
60
|
+
*/
|
|
31
61
|
export type ResttyAppCallbacks = {
|
|
62
|
+
/** A log line was emitted. */
|
|
32
63
|
onLog?: (line: string) => void;
|
|
64
|
+
/** Renderer backend was determined. */
|
|
33
65
|
onBackend?: (backend: string) => void;
|
|
66
|
+
/** Frame rate updated. */
|
|
34
67
|
onFps?: (fps: number) => void;
|
|
68
|
+
/** Device pixel ratio changed. */
|
|
35
69
|
onDpr?: (dpr: number) => void;
|
|
70
|
+
/** Canvas pixel dimensions changed. */
|
|
36
71
|
onCanvasSize?: (width: number, height: number) => void;
|
|
72
|
+
/** Grid size (cols x rows) changed. */
|
|
37
73
|
onGridSize?: (cols: number, rows: number) => void;
|
|
74
|
+
/** Cell pixel dimensions changed. */
|
|
38
75
|
onCellSize?: (cellW: number, cellH: number) => void;
|
|
76
|
+
/** Terminal size (cols x rows) changed. */
|
|
39
77
|
onTermSize?: (cols: number, rows: number) => void;
|
|
78
|
+
/** Cursor position changed. */
|
|
40
79
|
onCursor?: (col: number, row: number) => void;
|
|
80
|
+
/** General debug text updated. */
|
|
41
81
|
onDebug?: (text: string) => void;
|
|
82
|
+
/** Input sequence debug text updated. */
|
|
42
83
|
onInputDebug?: (text: string) => void;
|
|
84
|
+
/** PTY connection status changed. */
|
|
43
85
|
onPtyStatus?: (status: string) => void;
|
|
86
|
+
/** Mouse mode/status changed. */
|
|
44
87
|
onMouseStatus?: (status: string) => void;
|
|
45
88
|
};
|
|
89
|
+
/** Raw font data as an ArrayBuffer or typed-array view. */
|
|
46
90
|
export type ResttyFontBufferData = ArrayBuffer | ArrayBufferView;
|
|
91
|
+
/** Font source loaded from a URL. */
|
|
47
92
|
export type ResttyUrlFontSource = {
|
|
48
93
|
type: "url";
|
|
94
|
+
/** URL to fetch the font file from. */
|
|
49
95
|
url: string;
|
|
96
|
+
/** Human-readable label for debug/log output. */
|
|
50
97
|
label?: string;
|
|
51
98
|
};
|
|
99
|
+
/** Font source loaded from an in-memory buffer. */
|
|
52
100
|
export type ResttyBufferFontSource = {
|
|
53
101
|
type: "buffer";
|
|
102
|
+
/** Raw font file bytes. */
|
|
54
103
|
data: ResttyFontBufferData;
|
|
104
|
+
/** Human-readable label for debug/log output. */
|
|
55
105
|
label?: string;
|
|
56
106
|
};
|
|
107
|
+
/** Font source resolved from locally installed fonts via the Local Font Access API. */
|
|
57
108
|
export type ResttyLocalFontSource = {
|
|
58
109
|
type: "local";
|
|
110
|
+
/** Font family name patterns to match against installed fonts. */
|
|
59
111
|
matchers: string[];
|
|
112
|
+
/** Human-readable label for debug/log output. */
|
|
60
113
|
label?: string;
|
|
114
|
+
/** If true, font loading fails when no local match is found. */
|
|
61
115
|
required?: boolean;
|
|
62
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* A font source specification.
|
|
119
|
+
* - url: fetched from a URL
|
|
120
|
+
* - buffer: provided as in-memory bytes
|
|
121
|
+
* - local: resolved from locally installed fonts
|
|
122
|
+
*/
|
|
63
123
|
export type ResttyFontSource = ResttyUrlFontSource | ResttyBufferFontSource | ResttyLocalFontSource;
|
|
124
|
+
/** Alias for ResttyFontSource. */
|
|
64
125
|
export type FontSource = ResttyFontSource;
|
|
126
|
+
/**
|
|
127
|
+
* Built-in font preset.
|
|
128
|
+
* - default-cdn: load the default font from CDN
|
|
129
|
+
* - none: do not load any preset fonts
|
|
130
|
+
*/
|
|
65
131
|
export type ResttyFontPreset = "default-cdn" | "none";
|
|
132
|
+
/**
|
|
133
|
+
* Touch-based text selection behavior.
|
|
134
|
+
* - drag: immediate drag-selection on touch
|
|
135
|
+
* - long-press: selection starts after a long-press timeout
|
|
136
|
+
* - off: disable touch selection entirely
|
|
137
|
+
*/
|
|
66
138
|
export type ResttyTouchSelectionMode = "drag" | "long-press" | "off";
|
|
139
|
+
/**
|
|
140
|
+
* Options for creating a ResttyApp instance.
|
|
141
|
+
*/
|
|
67
142
|
export type ResttyAppOptions = {
|
|
143
|
+
/** Target canvas element for terminal rendering. */
|
|
68
144
|
canvas: HTMLCanvasElement;
|
|
145
|
+
/** Shared session for WASM/WebGPU resource reuse across panes. */
|
|
69
146
|
session?: ResttyAppSession;
|
|
147
|
+
/** Hidden textarea for IME composition input. */
|
|
70
148
|
imeInput?: HTMLTextAreaElement | null;
|
|
149
|
+
/** Optional DOM elements for debug/status displays. */
|
|
71
150
|
elements?: ResttyAppElements;
|
|
151
|
+
/** Callbacks for state-change notifications. */
|
|
72
152
|
callbacks?: ResttyAppCallbacks;
|
|
153
|
+
/** Renderer backend preference (default "auto"). */
|
|
73
154
|
renderer?: "auto" | "webgpu" | "webgl2";
|
|
155
|
+
/** Font size in CSS pixels. */
|
|
74
156
|
fontSize?: number;
|
|
157
|
+
/**
|
|
158
|
+
* Alpha blending strategy.
|
|
159
|
+
* - native: GPU-native premultiplied alpha
|
|
160
|
+
* - linear: linear-space blending
|
|
161
|
+
* - linear-corrected: linear-space with gamma correction
|
|
162
|
+
*/
|
|
75
163
|
alphaBlending?: "native" | "linear" | "linear-corrected";
|
|
164
|
+
/** Built-in font preset to load. */
|
|
76
165
|
fontPreset?: ResttyFontPreset;
|
|
166
|
+
/** Custom font sources to load. */
|
|
77
167
|
fontSources?: ResttyFontSource[];
|
|
168
|
+
/** Maximum scale factor for the symbol atlas texture. */
|
|
78
169
|
maxSymbolAtlasScale?: number;
|
|
170
|
+
/** Per-glyph scale overrides matched by regex. */
|
|
79
171
|
fontScaleOverrides?: {
|
|
80
172
|
match: RegExp;
|
|
81
173
|
scale: number;
|
|
82
174
|
}[];
|
|
175
|
+
/** Scale factor applied to Nerd Font icons. */
|
|
83
176
|
nerdIconScale?: number;
|
|
177
|
+
/** Automatically resize the terminal on container/window changes (default true). */
|
|
84
178
|
autoResize?: boolean;
|
|
179
|
+
/** Attach resize/focus listeners to the window object. */
|
|
85
180
|
attachWindowEvents?: boolean;
|
|
181
|
+
/** Attach pointer/keyboard listeners to the canvas. */
|
|
86
182
|
attachCanvasEvents?: boolean;
|
|
87
183
|
/**
|
|
88
184
|
* Touch selection behavior on pointerType=touch:
|
|
@@ -101,30 +197,57 @@ export type ResttyAppOptions = {
|
|
|
101
197
|
* canceled and touch pan-scroll takes priority.
|
|
102
198
|
*/
|
|
103
199
|
touchSelectionMoveThresholdPx?: number;
|
|
200
|
+
/** Expose internal state on the window object for debugging. */
|
|
104
201
|
debugExpose?: boolean;
|
|
202
|
+
/** PTY transport layer for terminal I/O. */
|
|
105
203
|
ptyTransport?: PtyTransport;
|
|
106
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Public API for a terminal app instance.
|
|
207
|
+
*/
|
|
107
208
|
export type ResttyApp = {
|
|
209
|
+
/** Initialize the renderer, fonts, and terminal state. */
|
|
108
210
|
init: () => Promise<void>;
|
|
211
|
+
/** Tear down all resources and event listeners. */
|
|
109
212
|
destroy: () => void;
|
|
213
|
+
/** Switch the renderer backend at runtime. */
|
|
110
214
|
setRenderer: (value: "auto" | "webgpu" | "webgl2") => void;
|
|
215
|
+
/** Pause or resume rendering. */
|
|
111
216
|
setPaused: (value: boolean) => void;
|
|
217
|
+
/** Toggle the rendering pause state. */
|
|
112
218
|
togglePause: () => void;
|
|
219
|
+
/** Update the terminal font size in CSS pixels. */
|
|
113
220
|
setFontSize: (value: number) => void;
|
|
221
|
+
/** Replace the active font sources and reload fonts. */
|
|
114
222
|
setFontSources: (sources: ResttyFontSource[]) => Promise<void>;
|
|
223
|
+
/** Apply a Ghostty color theme. */
|
|
115
224
|
applyTheme: (theme: GhosttyTheme, sourceLabel?: string) => void;
|
|
225
|
+
/** Reset colors to the default theme. */
|
|
116
226
|
resetTheme: () => void;
|
|
227
|
+
/** Write raw text to the terminal PTY. */
|
|
117
228
|
sendInput: (text: string, source?: string) => void;
|
|
229
|
+
/** Encode and send a key sequence to the terminal PTY. */
|
|
118
230
|
sendKeyInput: (text: string, source?: string) => void;
|
|
231
|
+
/** Clear the visible screen and scrollback. */
|
|
119
232
|
clearScreen: () => void;
|
|
233
|
+
/** Open a PTY connection, optionally to a specific URL. */
|
|
120
234
|
connectPty: (url?: string) => void;
|
|
235
|
+
/** Close the active PTY connection. */
|
|
121
236
|
disconnectPty: () => void;
|
|
237
|
+
/** Check whether the PTY transport is currently connected. */
|
|
122
238
|
isPtyConnected: () => boolean;
|
|
239
|
+
/** Override the mouse reporting mode. */
|
|
123
240
|
setMouseMode: (value: MouseMode) => void;
|
|
241
|
+
/** Return current mouse reporting status. */
|
|
124
242
|
getMouseStatus: () => ReturnType<InputHandler["getMouseStatus"]>;
|
|
243
|
+
/** Copy the current text selection to the clipboard. */
|
|
125
244
|
copySelectionToClipboard: () => Promise<boolean>;
|
|
245
|
+
/** Paste clipboard contents into the terminal. */
|
|
126
246
|
pasteFromClipboard: () => Promise<boolean>;
|
|
247
|
+
/** Dump the glyph atlas entry for a given Unicode codepoint. */
|
|
127
248
|
dumpAtlasForCodepoint: (cp: number) => void;
|
|
249
|
+
/** Recalculate terminal dimensions from the canvas size. */
|
|
128
250
|
updateSize: (force?: boolean) => void;
|
|
251
|
+
/** Return the name of the active renderer backend. */
|
|
129
252
|
getBackend: () => string;
|
|
130
253
|
};
|
package/dist/fonts/index.js
CHANGED
|
@@ -240,8 +240,9 @@ function isSymbolCp(cp) {
|
|
|
240
240
|
const isBlockElement = cp >= 9600 && cp <= 9631;
|
|
241
241
|
const isLegacyComputing = cp >= 129792 && cp <= 130047 || cp >= 117760 && cp <= 118463;
|
|
242
242
|
const isPowerline = cp >= 57520 && cp <= 57559;
|
|
243
|
+
const isTransportControl = cp >= 9193 && cp <= 9210;
|
|
243
244
|
const isGraphicsElement = isBoxDrawing || isBlockElement || isLegacyComputing || isPowerline;
|
|
244
|
-
return isPrivateUse || isGraphicsElement;
|
|
245
|
+
return isPrivateUse || isGraphicsElement || isTransportControl;
|
|
245
246
|
}
|
|
246
247
|
function pickFontIndexForText(state, text, expectedSpan, shapeClusterWithFont) {
|
|
247
248
|
if (!state.fonts.length)
|