restty 0.1.5 → 0.1.6
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/README.md +92 -19
- package/dist/app/index.d.ts +6 -1
- package/dist/app/pane-app-manager.d.ts +43 -0
- package/dist/app/panes.d.ts +75 -0
- package/dist/app/restty.d.ts +57 -0
- package/dist/app/session.d.ts +3 -0
- package/dist/app/types.d.ts +33 -15
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1332 -230
- package/dist/pty/pty.d.ts +2 -1
- package/dist/pty/types.d.ts +14 -0
- package/dist/renderer/types.d.ts +11 -1
- package/dist/renderer/webgpu.d.ts +5 -2
- package/package.json +20 -2
package/README.md
CHANGED
|
@@ -21,31 +21,28 @@ npm i restty
|
|
|
21
21
|
|
|
22
22
|
## Minimal setup
|
|
23
23
|
|
|
24
|
-
`restty`
|
|
24
|
+
`restty` auto-creates panes, canvas, and hidden IME inputs for you.
|
|
25
25
|
|
|
26
26
|
```html
|
|
27
|
-
<
|
|
28
|
-
<textarea id="ime" style="position:absolute;left:-9999px;top:-9999px"></textarea>
|
|
27
|
+
<div id="termRoot"></div>
|
|
29
28
|
```
|
|
30
29
|
|
|
31
30
|
```ts
|
|
32
|
-
import {
|
|
31
|
+
import { Restty } from "restty";
|
|
33
32
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
imeInput: document.getElementById("ime") as HTMLTextAreaElement,
|
|
37
|
-
renderer: "auto", // "auto" | "webgpu" | "webgl2"
|
|
33
|
+
const restty = new Restty({
|
|
34
|
+
root: document.getElementById("termRoot") as HTMLElement,
|
|
38
35
|
});
|
|
39
|
-
|
|
40
|
-
await app.init();
|
|
41
36
|
```
|
|
42
37
|
|
|
38
|
+
By default, `restty` loads fonts from CDN URLs. You can override them at init via typed `fontSources`.
|
|
39
|
+
|
|
43
40
|
## Common examples
|
|
44
41
|
|
|
45
42
|
### Connect to a PTY websocket
|
|
46
43
|
|
|
47
44
|
```ts
|
|
48
|
-
|
|
45
|
+
restty.connectPty("ws://localhost:8787/pty");
|
|
49
46
|
```
|
|
50
47
|
|
|
51
48
|
### Apply a built-in theme
|
|
@@ -54,7 +51,7 @@ app.connectPty("ws://localhost:8787/pty");
|
|
|
54
51
|
import { getBuiltinTheme } from "restty";
|
|
55
52
|
|
|
56
53
|
const theme = getBuiltinTheme("Aizen Dark");
|
|
57
|
-
if (theme)
|
|
54
|
+
if (theme) restty.applyTheme(theme);
|
|
58
55
|
```
|
|
59
56
|
|
|
60
57
|
### Parse and apply a custom Ghostty theme
|
|
@@ -67,22 +64,91 @@ foreground = #c0caf5
|
|
|
67
64
|
background = #1a1b26
|
|
68
65
|
cursor-color = #c0caf5
|
|
69
66
|
`;
|
|
70
|
-
|
|
67
|
+
restty.applyTheme(parseGhosttyTheme(themeText), "inline");
|
|
71
68
|
```
|
|
72
69
|
|
|
73
70
|
### Send input manually
|
|
74
71
|
|
|
75
72
|
```ts
|
|
76
|
-
|
|
73
|
+
restty.sendInput("ls -la\n");
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Provide custom fonts on init
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const restty = new Restty({
|
|
80
|
+
root: document.getElementById("termRoot") as HTMLElement,
|
|
81
|
+
fontSources: [
|
|
82
|
+
{
|
|
83
|
+
type: "url",
|
|
84
|
+
url: "https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono@v2.304/fonts/ttf/JetBrainsMono-Regular.ttf",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "local",
|
|
88
|
+
matchers: ["jetbrains mono nerd font", "fira code nerd font"],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Switch fonts at runtime (all panes)
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
await restty.setFontSources([
|
|
98
|
+
{ type: "local", matchers: ["sf mono"], required: true },
|
|
99
|
+
{
|
|
100
|
+
type: "url",
|
|
101
|
+
url: "https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@v3.4.0/patched-fonts/NerdFontsSymbolsOnly/SymbolsNerdFontMono-Regular.ttf",
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
77
104
|
```
|
|
78
105
|
|
|
79
|
-
##
|
|
106
|
+
## Multi-pane + Context Menu Defaults
|
|
107
|
+
|
|
108
|
+
`restty` ships a pane manager and a default terminal context menu so you can add split panes quickly.
|
|
109
|
+
It auto-creates pane DOM, canvas, and hidden IME inputs for you.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import {
|
|
113
|
+
Restty,
|
|
114
|
+
getBuiltinTheme,
|
|
115
|
+
} from "restty";
|
|
116
|
+
|
|
117
|
+
const root = document.getElementById("paneRoot") as HTMLElement;
|
|
118
|
+
|
|
119
|
+
const restty = new Restty({
|
|
120
|
+
root,
|
|
121
|
+
appOptions: {
|
|
122
|
+
renderer: "auto",
|
|
123
|
+
fontSize: 18,
|
|
124
|
+
callbacks: {
|
|
125
|
+
onLog: (line) => console.log(line),
|
|
126
|
+
},
|
|
127
|
+
elements: {},
|
|
128
|
+
},
|
|
129
|
+
defaultContextMenu: {
|
|
130
|
+
getPtyUrl: () => "ws://localhost:8787/pty",
|
|
131
|
+
},
|
|
132
|
+
shortcuts: true,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const first = restty.getActivePane();
|
|
136
|
+
const theme = getBuiltinTheme("Aizen Dark");
|
|
137
|
+
if (theme && first) first.app.applyTheme(theme);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Default split shortcuts are enabled:
|
|
141
|
+
- `Cmd/Ctrl + D` split right
|
|
142
|
+
- `Cmd/Ctrl + Shift + D` split down
|
|
143
|
+
|
|
144
|
+
## Restty API
|
|
80
145
|
|
|
81
146
|
Main methods:
|
|
82
|
-
- `
|
|
147
|
+
- `new Restty({ root, ...options })`
|
|
83
148
|
- `destroy()`
|
|
84
|
-
- `
|
|
85
|
-
- `
|
|
149
|
+
- `getPanes()` / `getActivePane()` / `getFocusedPane()`
|
|
150
|
+
- `splitActivePane("vertical" | "horizontal")` / `splitPane(id, direction)` / `closePane(id)`
|
|
151
|
+
- `connectPty(url)` / `disconnectPty()` / `isPtyConnected()`
|
|
86
152
|
- `setRenderer("auto" | "webgpu" | "webgl2")`
|
|
87
153
|
- `setFontSize(number)`
|
|
88
154
|
- `applyTheme(theme)` / `resetTheme()`
|
|
@@ -91,7 +157,7 @@ Main methods:
|
|
|
91
157
|
- `copySelectionToClipboard()` / `pasteFromClipboard()`
|
|
92
158
|
- `updateSize(force?)`
|
|
93
159
|
|
|
94
|
-
Low-level ABI access is
|
|
160
|
+
Low-level ABI access is available via `loadResttyWasm()` when you need direct render-state integration.
|
|
95
161
|
|
|
96
162
|
## Local development
|
|
97
163
|
|
|
@@ -108,6 +174,11 @@ bun run playground
|
|
|
108
174
|
|
|
109
175
|
Open `http://localhost:5173`.
|
|
110
176
|
|
|
177
|
+
Static deploy (Cloudflare Pages):
|
|
178
|
+
- Build: `bun run build:assets`
|
|
179
|
+
- Output directory: `playground/public`
|
|
180
|
+
- Keep `_headers` in that folder for COOP/COEP (required by WebContainer mode).
|
|
181
|
+
|
|
111
182
|
## Commands (repo)
|
|
112
183
|
|
|
113
184
|
```bash
|
|
@@ -119,6 +190,8 @@ bun run format:check # formatting check (src only)
|
|
|
119
190
|
bun run build:assets # playground bundles
|
|
120
191
|
bun run pty # local PTY server
|
|
121
192
|
bun run playground # playground dev server
|
|
193
|
+
./test.sh # static terminal capability sweep
|
|
194
|
+
./demo.sh # animated terminal demo (good for WebContainer demos)
|
|
122
195
|
```
|
|
123
196
|
|
|
124
197
|
## Acknowledgements
|
package/dist/app/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ResttyApp, ResttyAppOptions } from "./types";
|
|
2
|
-
export
|
|
2
|
+
export { createResttyAppSession, getDefaultResttyAppSession } from "./session";
|
|
3
|
+
export { createResttyPaneManager, createDefaultResttyPaneContextMenuItems, getResttyShortcutModifierLabel, } from "./panes";
|
|
4
|
+
export { Restty } from "./restty";
|
|
5
|
+
export type { ResttyAppElements, ResttyAppCallbacks, FontSource, ResttyFontSource, ResttyUrlFontSource, ResttyBufferFontSource, ResttyLocalFontSource, ResttyWasmLogListener, ResttyAppSession, ResttyAppOptions, ResttyApp, } from "./types";
|
|
6
|
+
export type { ResttyPaneSplitDirection, ResttyPaneContextMenuItem, ResttyPaneDefinition, ResttyPaneShortcutsOptions, ResttyPaneContextMenuOptions, CreateResttyPaneManagerOptions, ResttyPaneManager, ResttyPaneWithApp, CreateDefaultResttyPaneContextMenuItemsOptions, } from "./panes";
|
|
7
|
+
export type { ResttyOptions } from "./restty";
|
|
3
8
|
export declare function createResttyApp(options: ResttyAppOptions): ResttyApp;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ResttyPaneContextMenuOptions, type ResttyPaneManager, type ResttyPaneShortcutsOptions, type ResttyPaneWithApp } from "./panes";
|
|
2
|
+
import type { ResttyAppOptions, ResttyAppSession } from "./types";
|
|
3
|
+
export type ResttyManagedAppPane = ResttyPaneWithApp & {
|
|
4
|
+
canvas: HTMLCanvasElement;
|
|
5
|
+
imeInput: HTMLTextAreaElement;
|
|
6
|
+
termDebugEl: HTMLPreElement;
|
|
7
|
+
};
|
|
8
|
+
export type ResttyPaneDomDefaults = {
|
|
9
|
+
paneClassName?: string;
|
|
10
|
+
canvasClassName?: string;
|
|
11
|
+
imeInputClassName?: string;
|
|
12
|
+
termDebugClassName?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ResttyPaneAppOptionsInput = Omit<ResttyAppOptions, "canvas" | "imeInput" | "session">;
|
|
15
|
+
export type ResttyDefaultPaneContextMenuOptions = {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
canOpen?: (event: MouseEvent, pane: ResttyManagedAppPane) => boolean;
|
|
18
|
+
modKeyLabel?: string;
|
|
19
|
+
getPtyUrl?: () => string | null | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type CreateResttyAppPaneManagerOptions = {
|
|
22
|
+
root: HTMLElement;
|
|
23
|
+
session?: ResttyAppSession;
|
|
24
|
+
appOptions?: ResttyPaneAppOptionsInput | ((context: {
|
|
25
|
+
id: number;
|
|
26
|
+
sourcePane: ResttyManagedAppPane | null;
|
|
27
|
+
canvas: HTMLCanvasElement;
|
|
28
|
+
imeInput: HTMLTextAreaElement;
|
|
29
|
+
termDebugEl: HTMLPreElement;
|
|
30
|
+
}) => ResttyPaneAppOptionsInput);
|
|
31
|
+
paneDom?: ResttyPaneDomDefaults;
|
|
32
|
+
autoInit?: boolean;
|
|
33
|
+
minPaneSize?: number;
|
|
34
|
+
shortcuts?: boolean | ResttyPaneShortcutsOptions;
|
|
35
|
+
contextMenu?: ResttyPaneContextMenuOptions<ResttyManagedAppPane> | null;
|
|
36
|
+
defaultContextMenu?: boolean | ResttyDefaultPaneContextMenuOptions;
|
|
37
|
+
onPaneCreated?: (pane: ResttyManagedAppPane) => void;
|
|
38
|
+
onPaneClosed?: (pane: ResttyManagedAppPane) => void;
|
|
39
|
+
onPaneSplit?: (sourcePane: ResttyManagedAppPane, createdPane: ResttyManagedAppPane, direction: "vertical" | "horizontal") => void;
|
|
40
|
+
onActivePaneChange?: (pane: ResttyManagedAppPane | null) => void;
|
|
41
|
+
onLayoutChanged?: () => void;
|
|
42
|
+
};
|
|
43
|
+
export declare function createResttyAppPaneManager(options: CreateResttyAppPaneManagerOptions): ResttyPaneManager<ResttyManagedAppPane>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ResttyApp } from "./types";
|
|
2
|
+
export type ResttyPaneSplitDirection = "vertical" | "horizontal";
|
|
3
|
+
export type ResttyPaneContextMenuItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
shortcut?: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
action: () => void | Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
export type ResttyPaneDefinition = {
|
|
11
|
+
id: number;
|
|
12
|
+
container: HTMLDivElement;
|
|
13
|
+
focusTarget?: HTMLElement | null;
|
|
14
|
+
};
|
|
15
|
+
export type ResttyPaneShortcutsOptions = {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
canHandleEvent?: (event: KeyboardEvent) => boolean;
|
|
18
|
+
isAllowedInputTarget?: (target: HTMLElement) => boolean;
|
|
19
|
+
};
|
|
20
|
+
export type ResttyPaneContextMenuOptions<TPane extends ResttyPaneDefinition> = {
|
|
21
|
+
canOpen?: (event: MouseEvent, pane: TPane) => boolean;
|
|
22
|
+
getItems: (pane: TPane, manager: ResttyPaneManager<TPane>) => Array<ResttyPaneContextMenuItem | "separator">;
|
|
23
|
+
};
|
|
24
|
+
export type CreateResttyPaneManagerOptions<TPane extends ResttyPaneDefinition> = {
|
|
25
|
+
root: HTMLElement;
|
|
26
|
+
createPane: (context: {
|
|
27
|
+
id: number;
|
|
28
|
+
sourcePane: TPane | null;
|
|
29
|
+
manager: ResttyPaneManager<TPane>;
|
|
30
|
+
}) => TPane;
|
|
31
|
+
destroyPane?: (pane: TPane) => void;
|
|
32
|
+
onPaneCreated?: (pane: TPane) => void;
|
|
33
|
+
onPaneClosed?: (pane: TPane) => void;
|
|
34
|
+
onPaneSplit?: (sourcePane: TPane, createdPane: TPane, direction: ResttyPaneSplitDirection) => void;
|
|
35
|
+
onActivePaneChange?: (pane: TPane | null) => void;
|
|
36
|
+
onLayoutChanged?: () => void;
|
|
37
|
+
minPaneSize?: number;
|
|
38
|
+
contextMenu?: ResttyPaneContextMenuOptions<TPane> | null;
|
|
39
|
+
shortcuts?: boolean | ResttyPaneShortcutsOptions;
|
|
40
|
+
};
|
|
41
|
+
export type ResttyPaneManager<TPane extends ResttyPaneDefinition> = {
|
|
42
|
+
getPanes: () => TPane[];
|
|
43
|
+
getPaneById: (id: number) => TPane | null;
|
|
44
|
+
getActivePane: () => TPane | null;
|
|
45
|
+
getFocusedPane: () => TPane | null;
|
|
46
|
+
createInitialPane: (options?: {
|
|
47
|
+
focus?: boolean;
|
|
48
|
+
}) => TPane;
|
|
49
|
+
setActivePane: (id: number, options?: {
|
|
50
|
+
focus?: boolean;
|
|
51
|
+
}) => void;
|
|
52
|
+
markPaneFocused: (id: number, options?: {
|
|
53
|
+
focus?: boolean;
|
|
54
|
+
}) => void;
|
|
55
|
+
splitPane: (id: number, direction: ResttyPaneSplitDirection) => TPane | null;
|
|
56
|
+
splitActivePane: (direction: ResttyPaneSplitDirection) => TPane | null;
|
|
57
|
+
closePane: (id: number) => boolean;
|
|
58
|
+
requestLayoutSync: () => void;
|
|
59
|
+
hideContextMenu: () => void;
|
|
60
|
+
destroy: () => void;
|
|
61
|
+
};
|
|
62
|
+
export type ResttyPaneWithApp = ResttyPaneDefinition & {
|
|
63
|
+
app: ResttyApp;
|
|
64
|
+
paused?: boolean;
|
|
65
|
+
setPaused?: (value: boolean) => void;
|
|
66
|
+
};
|
|
67
|
+
export type CreateDefaultResttyPaneContextMenuItemsOptions<TPane extends ResttyPaneWithApp> = {
|
|
68
|
+
pane: TPane;
|
|
69
|
+
manager: Pick<ResttyPaneManager<TPane>, "splitPane" | "closePane" | "getPanes">;
|
|
70
|
+
modKeyLabel?: string;
|
|
71
|
+
getPtyUrl?: () => string | null | undefined;
|
|
72
|
+
};
|
|
73
|
+
export declare function getResttyShortcutModifierLabel(): "Cmd" | "Ctrl";
|
|
74
|
+
export declare function createDefaultResttyPaneContextMenuItems<TPane extends ResttyPaneWithApp>(options: CreateDefaultResttyPaneContextMenuItemsOptions<TPane>): Array<ResttyPaneContextMenuItem | "separator">;
|
|
75
|
+
export declare function createResttyPaneManager<TPane extends ResttyPaneDefinition>(options: CreateResttyPaneManagerOptions<TPane>): ResttyPaneManager<TPane>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { GhosttyTheme } from "../theme";
|
|
2
|
+
import type { InputHandler } from "../input";
|
|
3
|
+
import { type CreateResttyAppPaneManagerOptions, type ResttyPaneAppOptionsInput, type ResttyManagedAppPane } from "./pane-app-manager";
|
|
4
|
+
import type { ResttyPaneManager, ResttyPaneSplitDirection } from "./panes";
|
|
5
|
+
import type { ResttyFontSource } from "./types";
|
|
6
|
+
export type ResttyOptions = Omit<CreateResttyAppPaneManagerOptions, "appOptions"> & {
|
|
7
|
+
appOptions?: CreateResttyAppPaneManagerOptions["appOptions"];
|
|
8
|
+
fontSources?: ResttyPaneAppOptionsInput["fontSources"];
|
|
9
|
+
createInitialPane?: boolean | {
|
|
10
|
+
focus?: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare class Restty {
|
|
14
|
+
readonly paneManager: ResttyPaneManager<ResttyManagedAppPane>;
|
|
15
|
+
private fontSources;
|
|
16
|
+
constructor(options: ResttyOptions);
|
|
17
|
+
getPanes(): ResttyManagedAppPane[];
|
|
18
|
+
getPaneById(id: number): ResttyManagedAppPane | null;
|
|
19
|
+
getActivePane(): ResttyManagedAppPane | null;
|
|
20
|
+
getFocusedPane(): ResttyManagedAppPane | null;
|
|
21
|
+
createInitialPane(options?: {
|
|
22
|
+
focus?: boolean;
|
|
23
|
+
}): ResttyManagedAppPane;
|
|
24
|
+
splitActivePane(direction: ResttyPaneSplitDirection): ResttyManagedAppPane | null;
|
|
25
|
+
splitPane(id: number, direction: ResttyPaneSplitDirection): ResttyManagedAppPane | null;
|
|
26
|
+
closePane(id: number): boolean;
|
|
27
|
+
setActivePane(id: number, options?: {
|
|
28
|
+
focus?: boolean;
|
|
29
|
+
}): void;
|
|
30
|
+
markPaneFocused(id: number, options?: {
|
|
31
|
+
focus?: boolean;
|
|
32
|
+
}): void;
|
|
33
|
+
requestLayoutSync(): void;
|
|
34
|
+
hideContextMenu(): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
connectPty(url?: string): void;
|
|
37
|
+
disconnectPty(): void;
|
|
38
|
+
isPtyConnected(): boolean;
|
|
39
|
+
setRenderer(value: "auto" | "webgpu" | "webgl2"): void;
|
|
40
|
+
setPaused(value: boolean): void;
|
|
41
|
+
togglePause(): void;
|
|
42
|
+
setFontSize(value: number): void;
|
|
43
|
+
setFontSources(sources: ResttyFontSource[]): Promise<void>;
|
|
44
|
+
applyTheme(theme: GhosttyTheme, sourceLabel?: string): void;
|
|
45
|
+
resetTheme(): void;
|
|
46
|
+
sendInput(text: string, source?: string): void;
|
|
47
|
+
sendKeyInput(text: string, source?: string): void;
|
|
48
|
+
clearScreen(): void;
|
|
49
|
+
setMouseMode(value: string): void;
|
|
50
|
+
getMouseStatus(): ReturnType<InputHandler["getMouseStatus"]>;
|
|
51
|
+
copySelectionToClipboard(): Promise<boolean>;
|
|
52
|
+
pasteFromClipboard(): Promise<boolean>;
|
|
53
|
+
dumpAtlasForCodepoint(cp: number): void;
|
|
54
|
+
updateSize(force?: boolean): void;
|
|
55
|
+
getBackend(): string;
|
|
56
|
+
private requireActivePane;
|
|
57
|
+
}
|
package/dist/app/types.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { InputHandler } from "../input";
|
|
2
|
+
import type { PtyTransport } from "../pty";
|
|
3
|
+
import type { WebGPUCoreState } from "../renderer";
|
|
2
4
|
import type { GhosttyTheme } from "../theme";
|
|
5
|
+
import type { ResttyWasm } from "../wasm";
|
|
6
|
+
export type ResttyWasmLogListener = (message: string) => void;
|
|
7
|
+
export type ResttyAppSession = {
|
|
8
|
+
getWasm: () => Promise<ResttyWasm>;
|
|
9
|
+
getWebGPUCore: (canvas: HTMLCanvasElement) => Promise<WebGPUCoreState | null>;
|
|
10
|
+
addWasmLogListener?: (listener: ResttyWasmLogListener) => void;
|
|
11
|
+
removeWasmLogListener?: (listener: ResttyWasmLogListener) => void;
|
|
12
|
+
};
|
|
3
13
|
export type ResttyAppElements = {
|
|
4
14
|
backendEl?: HTMLElement | null;
|
|
5
15
|
fpsEl?: HTMLElement | null;
|
|
@@ -33,29 +43,35 @@ export type ResttyAppCallbacks = {
|
|
|
33
43
|
onPtyStatus?: (status: string) => void;
|
|
34
44
|
onMouseStatus?: (status: string) => void;
|
|
35
45
|
};
|
|
36
|
-
export type
|
|
37
|
-
|
|
38
|
-
url
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
export type ResttyFontBufferData = ArrayBuffer | ArrayBufferView;
|
|
47
|
+
export type ResttyUrlFontSource = {
|
|
48
|
+
type: "url";
|
|
49
|
+
url: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
};
|
|
52
|
+
export type ResttyBufferFontSource = {
|
|
53
|
+
type: "buffer";
|
|
54
|
+
data: ResttyFontBufferData;
|
|
55
|
+
label?: string;
|
|
56
|
+
};
|
|
57
|
+
export type ResttyLocalFontSource = {
|
|
58
|
+
type: "local";
|
|
59
|
+
matchers: string[];
|
|
60
|
+
label?: string;
|
|
61
|
+
required?: boolean;
|
|
41
62
|
};
|
|
63
|
+
export type ResttyFontSource = ResttyUrlFontSource | ResttyBufferFontSource | ResttyLocalFontSource;
|
|
64
|
+
export type FontSource = ResttyFontSource;
|
|
42
65
|
export type ResttyAppOptions = {
|
|
43
66
|
canvas: HTMLCanvasElement;
|
|
67
|
+
session?: ResttyAppSession;
|
|
44
68
|
imeInput?: HTMLTextAreaElement | null;
|
|
45
69
|
elements?: ResttyAppElements;
|
|
46
70
|
callbacks?: ResttyAppCallbacks;
|
|
47
71
|
renderer?: "auto" | "webgpu" | "webgl2";
|
|
48
72
|
fontSize?: number;
|
|
49
|
-
assetBaseUrl?: string;
|
|
50
73
|
alphaBlending?: "native" | "linear" | "linear-corrected";
|
|
51
|
-
fontSources?:
|
|
52
|
-
primary?: {
|
|
53
|
-
url?: string;
|
|
54
|
-
buffer?: ArrayBuffer;
|
|
55
|
-
matchers?: string[];
|
|
56
|
-
};
|
|
57
|
-
fallbacks?: FontSource[];
|
|
58
|
-
};
|
|
74
|
+
fontSources?: ResttyFontSource[];
|
|
59
75
|
maxSymbolAtlasScale?: number;
|
|
60
76
|
fontScaleOverrides?: {
|
|
61
77
|
match: RegExp;
|
|
@@ -66,6 +82,7 @@ export type ResttyAppOptions = {
|
|
|
66
82
|
attachWindowEvents?: boolean;
|
|
67
83
|
attachCanvasEvents?: boolean;
|
|
68
84
|
debugExpose?: boolean;
|
|
85
|
+
ptyTransport?: PtyTransport;
|
|
69
86
|
};
|
|
70
87
|
export type ResttyApp = {
|
|
71
88
|
init: () => Promise<void>;
|
|
@@ -74,12 +91,13 @@ export type ResttyApp = {
|
|
|
74
91
|
setPaused: (value: boolean) => void;
|
|
75
92
|
togglePause: () => void;
|
|
76
93
|
setFontSize: (value: number) => void;
|
|
94
|
+
setFontSources: (sources: ResttyFontSource[]) => Promise<void>;
|
|
77
95
|
applyTheme: (theme: GhosttyTheme, sourceLabel?: string) => void;
|
|
78
96
|
resetTheme: () => void;
|
|
79
97
|
sendInput: (text: string, source?: string) => void;
|
|
80
98
|
sendKeyInput: (text: string, source?: string) => void;
|
|
81
99
|
clearScreen: () => void;
|
|
82
|
-
connectPty: (url
|
|
100
|
+
connectPty: (url?: string) => void;
|
|
83
101
|
disconnectPty: () => void;
|
|
84
102
|
isPtyConnected: () => boolean;
|
|
85
103
|
setMouseMode: (value: string) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
export { type Color, type RectData, type GlyphBox, type NerdMetrics, type WebGPUState, type WebGLState, type WebGLAtlasState, type AtlasState, type RendererState, type RendererConfig, type ResizeState, type ScrollbarState, BOX_STYLE_NONE, BOX_STYLE_LIGHT, BOX_STYLE_HEAVY, BOX_STYLE_DOUBLE, BOX_LINE_MAP, RECT_SHADER, GLYPH_SHADER, isPrivateUse, isSpaceCp, isBoxDrawing, isBlockElement, isLegacyComputing, isPowerline, isBraille, isGraphicsElement, isSymbolCp, applyAlpha, pushRect, pushRectSnapped, pushRectBox, drawBlockElement, drawBoxDrawing, drawBraille, drawPowerline, constrainGlyphBox, initWebGPU, initWebGL, ensureInstanceBuffer, ensureGLInstanceBuffer, configureContext, createResizeState, createScrollbarState, } from "./renderer";
|
|
1
|
+
export { type Color, type RectData, type GlyphBox, type NerdMetrics, type WebGPUCoreState, type WebGPUState, type WebGLState, type WebGLAtlasState, type AtlasState, type RendererState, type RendererConfig, type ResizeState, type ScrollbarState, BOX_STYLE_NONE, BOX_STYLE_LIGHT, BOX_STYLE_HEAVY, BOX_STYLE_DOUBLE, BOX_LINE_MAP, RECT_SHADER, GLYPH_SHADER, isPrivateUse, isSpaceCp, isBoxDrawing, isBlockElement, isLegacyComputing, isPowerline, isBraille, isGraphicsElement, isSymbolCp, applyAlpha, pushRect, pushRectSnapped, pushRectBox, drawBlockElement, drawBoxDrawing, drawBraille, drawPowerline, constrainGlyphBox, initWebGPUCore, initWebGPU, initWebGL, ensureInstanceBuffer, ensureGLInstanceBuffer, configureContext, createResizeState, createScrollbarState, } from "./renderer";
|
|
2
2
|
export { type GridState, type CellMetrics, type GridConfig, type FontMetricsProvider, type ShapeResult, fontHeightUnits, computeCellMetrics, createGridState, updateGridState, clamp, } from "./grid";
|
|
3
3
|
export { type FontEntry, type FontManagerState, type ShapedCluster, type ShapedGlyph, type FallbackFontSource, type FontScaleOverride, type NerdConstraint, type NerdConstraintRange, isSymbolFont, isNerdSymbolFont, fontMaxCellSpan, fontScaleOverride, fontRasterScale, createFontEntry, resetFontEntry, createFontManagerState, fontHasGlyph, fontAdvanceUnits, glyphWidthUnits, pickFontIndexForText, tryFetchFontBuffer, tryLocalFontBuffer, loadPrimaryFontBuffer, loadFallbackFontBuffers, isNerdSymbolCodepoint, NERD_SYMBOL_RANGES, getNerdConstraint, NERD_CONSTRAINTS, } from "./fonts";
|
|
4
4
|
export { type SelectionState, type SelectionRange, type CellTextGetter, createSelectionState, clearSelection, startSelection, updateSelection, endSelection, selectionForRow, getSelectionText, normalizeSelectionCell, positionToCell, copyToClipboard, pasteFromClipboard, } from "./selection";
|
|
5
5
|
export type { CellPosition } from "./selection";
|
|
6
6
|
export { type ImeState, createImeState, setPreedit, clearPreedit, startComposition, updateComposition, endComposition, syncImeSelection, updateImePosition, PREEDIT_BG, PREEDIT_ACTIVE_BG, PREEDIT_FG, PREEDIT_UL, PREEDIT_CARET, } from "./ime";
|
|
7
7
|
export type { CursorPosition } from "./ime";
|
|
8
|
-
export { type PtyMessage, type PtyStatusMessage, type PtyErrorMessage, type PtyExitMessage, type PtyServerMessage, type PtyConnectionState, type PtyCallbacks, createPtyConnection, connectPty, disconnectPty, sendPtyInput, sendPtyResize, isPtyConnected, } from "./pty";
|
|
8
|
+
export { type PtyMessage, type PtyStatusMessage, type PtyErrorMessage, type PtyExitMessage, type PtyServerMessage, type PtyConnectionState, type PtyCallbacks, type PtyConnectOptions, type PtyTransport, createPtyConnection, connectPty, disconnectPty, sendPtyInput, sendPtyResize, isPtyConnected, createWebSocketPtyTransport, } from "./pty";
|
|
9
9
|
export { createInputHandler } from "./input";
|
|
10
10
|
export type { InputHandler, InputHandlerConfig, InputHandlerOptions, MouseMode, MouseStatus, } from "./input";
|
|
11
11
|
export { loadResttyWasm, ResttyWasm } from "./wasm";
|
|
12
12
|
export type { WasmAbi, WasmAbiKind, CursorInfo, RenderState, ResttyWasmExports, ResttyWasmOptions, } from "./wasm";
|
|
13
13
|
export { parseGhosttyTheme, parseGhosttyColor, colorToFloats, colorToRgbU32, listBuiltinThemeNames, isBuiltinThemeName, getBuiltinThemeSource, getBuiltinTheme, } from "./theme";
|
|
14
14
|
export type { GhosttyTheme, ThemeColor, ResttyBuiltinThemeName } from "./theme";
|
|
15
|
-
export {
|
|
16
|
-
export type {
|
|
15
|
+
export { Restty } from "./app/restty";
|
|
16
|
+
export type { ResttyOptions } from "./app/restty";
|
|
17
|
+
export type { ResttyManagedAppPane, ResttyPaneDomDefaults, ResttyPaneAppOptionsInput, } from "./app/pane-app-manager";
|
|
18
|
+
export type { ResttyFontSource, ResttyUrlFontSource, ResttyBufferFontSource, ResttyLocalFontSource, } from "./app/types";
|