gpui-bridge 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +56 -2
- package/dist/app.d.ts +329 -0
- package/dist/app.js +587 -0
- package/dist/host-process.d.ts +18 -0
- package/dist/host-process.js +56 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +58 -0
- package/dist/protocol.d.ts +982 -0
- package/dist/protocol.js +3 -0
- package/dist/tree.d.ts +19 -0
- package/dist/tree.js +70 -0
- package/dist/txiki.d.ts +10 -0
- package/dist/txiki.js +90 -0
- package/package.json +44 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 gpui-bridge contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gpui-bridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native desktop UIs with [GPUI](https://www.gpui.rs/) (the UI framework of the Zed editor) and
|
|
4
|
+
[gpui-kit](https://gpui-kit.com/), driven from JavaScript or
|
|
5
|
+
TypeScript. This package is the Node.js client; a Rust host owns the window, the event loop and
|
|
6
|
+
the component tree, and they talk over stdin/stdout with JSON Lines.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { createApp } from "gpui-bridge";
|
|
10
|
+
|
|
11
|
+
const app = await createApp();
|
|
12
|
+
let count = 0;
|
|
13
|
+
const label = app.text({ content: "0", class: "text-xl font-bold" });
|
|
14
|
+
const add = app.button({ label: "Add", variant: "primary" }).on("click", () => {
|
|
15
|
+
label.set({ content: String(++count) });
|
|
16
|
+
app.commit();
|
|
17
|
+
});
|
|
18
|
+
app.window({ title: "Counter", width: 320, height: 200, root: app.div({ class: "flex flex-col items-center gap-4 p-6 size-full" }).append(label, add) });
|
|
19
|
+
app.commit();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install gpui-bridge
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The package pulls in an optimized `gpui-bridge-host` binary for the machine installing it: the
|
|
29
|
+
npm package `@indios/gpui-bridge-<platform>-<arch>` (`@indios/gpui-bridge-win32-x64`, `@indios/gpui-bridge-linux-x64`,
|
|
30
|
+
`@indios/gpui-bridge-darwin-arm64`) is an optional dependency, so only the host this machine can run is
|
|
31
|
+
downloaded. No Rust toolchain is needed at runtime — except on a platform without a package
|
|
32
|
+
yet: set `GPUI_BRIDGE_HOST` to a host built from the repository. Node.js 22.6+ (or
|
|
33
|
+
[txiki.js](https://github.com/saghul/txiki.js) through `gpui-bridge/dist/txiki.js`).
|
|
34
|
+
|
|
35
|
+
Styles are Tailwind-like class strings that use the theme's colors, so light and dark mode and
|
|
36
|
+
custom themes come for free. Props, events and every node type are typed.
|
|
37
|
+
|
|
38
|
+
## Host lookup
|
|
39
|
+
|
|
40
|
+
1. `createApp({ hostPath })`
|
|
41
|
+
2. `$GPUI_BRIDGE_HOST`
|
|
42
|
+
3. `@indios/gpui-bridge-<platform>-<arch>/bin/gpui-bridge-host[.exe]`, the platform package installed
|
|
43
|
+
with this one (`defaultHostPath()` reports the path that wins)
|
|
44
|
+
4. A Cargo build in `target/debug` or `target/release`, searched upwards (a checkout)
|
|
45
|
+
|
|
46
|
+
The platform package's `bin/host.json` records the host version, protocol version and target it
|
|
47
|
+
was built for; include it in a bug report.
|
|
48
|
+
|
|
49
|
+
## Links
|
|
50
|
+
|
|
51
|
+
- [Protocol specification](https://github.com/InDIOS/gpui-bridge/blob/main/docs/PROTOCOL.md),
|
|
52
|
+
for writing a client in another language.
|
|
53
|
+
- [React renderer](https://www.npmjs.com/package/gpui-bridge-react) on top of this client.
|
|
54
|
+
- Examples and the rest of the repository:
|
|
55
|
+
[InDIOS/gpui-bridge](https://github.com/InDIOS/gpui-bridge).
|
|
56
|
+
|
|
57
|
+
Protocol version 1. MIT licensed.
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { type ClientMessage, type ErrorCode, type HostMessage, type MenuItem, type NodeEvents, type NodeId, type NodeProps, type NodeType, type ThemeSet, type WindowEventName, type WindowId, type WindowTheme } from "./protocol.js";
|
|
2
|
+
import { Tree } from "./tree.js";
|
|
3
|
+
export interface HostExit {
|
|
4
|
+
code: number | null;
|
|
5
|
+
signal: string | null;
|
|
6
|
+
/** Last lines the host wrote to stderr, for crash reports. */
|
|
7
|
+
stderrTail: string[];
|
|
8
|
+
/** Set when the process could not be started at all (e.g. binary not found). */
|
|
9
|
+
spawnError?: Error;
|
|
10
|
+
}
|
|
11
|
+
/** A running host process, as seen by the client core. */
|
|
12
|
+
export interface HostTransport {
|
|
13
|
+
send(message: ClientMessage): void;
|
|
14
|
+
/** Closes stdin; the host exits on EOF. */
|
|
15
|
+
close(): void;
|
|
16
|
+
kill(): void;
|
|
17
|
+
}
|
|
18
|
+
/** What a transport reports back while the host runs. */
|
|
19
|
+
export interface HostEvents {
|
|
20
|
+
onMessage(message: HostMessage): void;
|
|
21
|
+
/** stdout carried something that is not a protocol message. */
|
|
22
|
+
onCorruptLine(line: string): void;
|
|
23
|
+
onExit(exit: HostExit): void;
|
|
24
|
+
}
|
|
25
|
+
export interface WindowOptions {
|
|
26
|
+
title?: string;
|
|
27
|
+
width?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
/** Initial position. Only read when the window opens. */
|
|
30
|
+
x?: number;
|
|
31
|
+
y?: number;
|
|
32
|
+
/** Minimum size the user can resize to. Only read when the window opens. */
|
|
33
|
+
minWidth?: number;
|
|
34
|
+
minHeight?: number;
|
|
35
|
+
root?: UINode<NodeType>;
|
|
36
|
+
theme?: WindowTheme;
|
|
37
|
+
themeSet?: ThemeSet;
|
|
38
|
+
/** No system title bar (draw your own with `windowControl` divs). Only read when the window opens. */
|
|
39
|
+
frameless?: boolean;
|
|
40
|
+
/** Minimizes (`true`) or restores (`false`) on the next commit. An action, not a remembered state. */
|
|
41
|
+
minimized?: boolean;
|
|
42
|
+
/** Window events to receive; `AppWindow.on` sets this for you. Replaces the previous list. */
|
|
43
|
+
events?: WindowEventName[];
|
|
44
|
+
}
|
|
45
|
+
/** A window event (PROTOCOL.md section 3); only the ones the window subscribed to arrive. */
|
|
46
|
+
export interface WindowEventPayload {
|
|
47
|
+
id: WindowId;
|
|
48
|
+
event: WindowEventName;
|
|
49
|
+
/** `move` and `resize`: the window's bounds. */
|
|
50
|
+
x?: number;
|
|
51
|
+
y?: number;
|
|
52
|
+
width?: number;
|
|
53
|
+
height?: number;
|
|
54
|
+
/** `visibility`: whether the window is being presented. */
|
|
55
|
+
visible?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** A toast (PROTOCOL.md section 14). */
|
|
58
|
+
export interface NotifyOptions {
|
|
59
|
+
message: string;
|
|
60
|
+
title?: string;
|
|
61
|
+
type?: "info" | "success" | "warning" | "error";
|
|
62
|
+
/** Default window 1. */
|
|
63
|
+
window?: WindowId;
|
|
64
|
+
/** Lets a click be reported (`notification` event); a new toast with the same id replaces it. */
|
|
65
|
+
id?: string;
|
|
66
|
+
/** Default true. */
|
|
67
|
+
autohide?: boolean;
|
|
68
|
+
/** Also post it to the Windows notification center. */
|
|
69
|
+
system?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** `openDialog` options (PROTOCOL.md section 13). Default: one file. */
|
|
72
|
+
export interface OpenDialogOptions {
|
|
73
|
+
files?: boolean;
|
|
74
|
+
directories?: boolean;
|
|
75
|
+
multiple?: boolean;
|
|
76
|
+
/** The confirm button's text. */
|
|
77
|
+
prompt?: string;
|
|
78
|
+
}
|
|
79
|
+
/** `saveDialog` options. */
|
|
80
|
+
export interface SaveDialogOptions {
|
|
81
|
+
/** Where the dialog starts; default the host's working directory. */
|
|
82
|
+
directory?: string;
|
|
83
|
+
/** Suggested file name. */
|
|
84
|
+
name?: string;
|
|
85
|
+
}
|
|
86
|
+
/** The system tray icon (PROTOCOL.md section 11). Each call updates only the fields it passes. */
|
|
87
|
+
export interface TrayOptions {
|
|
88
|
+
/** An image file (PNG, ICO…), drawn at the tray's size. */
|
|
89
|
+
icon?: string;
|
|
90
|
+
tooltip?: string;
|
|
91
|
+
/** Opens on right-click; a native menu, so item icons are not drawn. */
|
|
92
|
+
menu?: MenuItem[];
|
|
93
|
+
}
|
|
94
|
+
/** An `error` message from the host: the operation was rejected, the host keeps running. */
|
|
95
|
+
export interface HostError {
|
|
96
|
+
code: ErrorCode;
|
|
97
|
+
message: string;
|
|
98
|
+
op?: string;
|
|
99
|
+
}
|
|
100
|
+
interface AppEvents {
|
|
101
|
+
error: HostError;
|
|
102
|
+
/** The user closed a window. */
|
|
103
|
+
windowClosed: {
|
|
104
|
+
id: WindowId;
|
|
105
|
+
};
|
|
106
|
+
/** A window event the client subscribed to (`window.events`, or `AppWindow.on` for that window). */
|
|
107
|
+
windowEvent: WindowEventPayload;
|
|
108
|
+
/** The user clicked a toast that has an `id`. */
|
|
109
|
+
notification: {
|
|
110
|
+
id: string;
|
|
111
|
+
window: WindowId;
|
|
112
|
+
};
|
|
113
|
+
/** A key registered with `shortcuts()` was pressed in window `window`. */
|
|
114
|
+
shortcut: {
|
|
115
|
+
keys: string;
|
|
116
|
+
window: WindowId;
|
|
117
|
+
};
|
|
118
|
+
/** The user clicked the tray icon (`click`) or chose an item of its menu (`menu`, with the item id). */
|
|
119
|
+
tray: {
|
|
120
|
+
event: "click";
|
|
121
|
+
} | {
|
|
122
|
+
event: "menu";
|
|
123
|
+
item: string;
|
|
124
|
+
};
|
|
125
|
+
exit: HostExit;
|
|
126
|
+
}
|
|
127
|
+
/** `setProps` input: `null` removes a prop. */
|
|
128
|
+
export type PropsUpdate<T extends NodeType> = {
|
|
129
|
+
[K in keyof NodeProps[T]]?: NodeProps[T][K] | null;
|
|
130
|
+
};
|
|
131
|
+
export declare class HostExitedError extends Error {
|
|
132
|
+
readonly exit: HostExit;
|
|
133
|
+
constructor(message: string, exit: HostExit);
|
|
134
|
+
}
|
|
135
|
+
export declare class UINode<T extends NodeType> {
|
|
136
|
+
private readonly app;
|
|
137
|
+
readonly id: NodeId;
|
|
138
|
+
readonly type: T;
|
|
139
|
+
/** @internal */
|
|
140
|
+
constructor(app: App, id: NodeId, type: T);
|
|
141
|
+
append(...children: UINode<NodeType>[]): this;
|
|
142
|
+
insertBefore(child: UINode<NodeType>, before: UINode<NodeType>): this;
|
|
143
|
+
/** Merges props; `null` removes one. */
|
|
144
|
+
set(props: PropsUpdate<T>): this;
|
|
145
|
+
/** Subscribes to an event; the host only emits subscribed events. */
|
|
146
|
+
on<E extends keyof NodeEvents[T] & string>(event: E, handler: (payload: NodeEvents[T][E]) => void): this;
|
|
147
|
+
off<E extends keyof NodeEvents[T] & string>(event: E): this;
|
|
148
|
+
/** Gives the node the keyboard focus on the next commit (an Input, a Textarea or a div with `keyDown`). */
|
|
149
|
+
focus(): this;
|
|
150
|
+
/** Removes the node and all its descendants. */
|
|
151
|
+
remove(): void;
|
|
152
|
+
}
|
|
153
|
+
/** A window other than the main one (`App.createWindow`). */
|
|
154
|
+
export declare class AppWindow {
|
|
155
|
+
private readonly app;
|
|
156
|
+
readonly id: WindowId;
|
|
157
|
+
private readonly closedListeners;
|
|
158
|
+
private readonly eventListeners;
|
|
159
|
+
/** The subscription list last sent, to avoid one message per listener. */
|
|
160
|
+
private eventNames;
|
|
161
|
+
/** @internal */
|
|
162
|
+
constructor(app: App, id: WindowId);
|
|
163
|
+
/** Updates the window; like `App.window`, it opens on the first commit that sets `root`. */
|
|
164
|
+
set(options: WindowOptions): this;
|
|
165
|
+
/** Closes the window on the next commit. No `closed` event follows: that is only for the user closing it. */
|
|
166
|
+
close(): void;
|
|
167
|
+
/** The user closed the window, or a window event (which the window subscribes to on commit). */
|
|
168
|
+
on(event: "closed", listener: () => void): this;
|
|
169
|
+
on(event: WindowEventName, listener: (payload: WindowEventPayload) => void): this;
|
|
170
|
+
off(event: "closed", listener: () => void): this;
|
|
171
|
+
off(event: WindowEventName, listener: (payload: WindowEventPayload) => void): this;
|
|
172
|
+
/** @internal */
|
|
173
|
+
handleClosed(): void;
|
|
174
|
+
/** @internal */
|
|
175
|
+
handleWindowEvent(payload: WindowEventPayload): void;
|
|
176
|
+
/** Sends the subscription list only when the set of subscribed events changes. */
|
|
177
|
+
private syncEvents;
|
|
178
|
+
}
|
|
179
|
+
export declare class App {
|
|
180
|
+
private readonly host;
|
|
181
|
+
private readonly hostPath;
|
|
182
|
+
/** @internal Protocol operations queued until `commit`. */
|
|
183
|
+
readonly wire: Tree;
|
|
184
|
+
private readonly listeners;
|
|
185
|
+
private exitInfo?;
|
|
186
|
+
private closing;
|
|
187
|
+
private nextWindowId;
|
|
188
|
+
private readonly windows;
|
|
189
|
+
/** Windows given a root and not closed: the host exits when the user closes the last one. */
|
|
190
|
+
private readonly openWindows;
|
|
191
|
+
private nextRequest;
|
|
192
|
+
/** System actions waiting for their `result`. */
|
|
193
|
+
private readonly requests;
|
|
194
|
+
/** A tray keeps the host running after the last window closes. */
|
|
195
|
+
private hasTray;
|
|
196
|
+
private readonly exitWaiters;
|
|
197
|
+
/** @internal */
|
|
198
|
+
constructor(host: HostTransport, hostPath: string);
|
|
199
|
+
div(props?: NodeProps["div"]): UINode<"div">;
|
|
200
|
+
text(props?: NodeProps["text"]): UINode<"text">;
|
|
201
|
+
button(props?: NodeProps["Button"]): UINode<"Button">;
|
|
202
|
+
input(props?: NodeProps["Input"]): UINode<"Input">;
|
|
203
|
+
checkbox(props?: NodeProps["Checkbox"]): UINode<"Checkbox">;
|
|
204
|
+
icon(props?: NodeProps["Icon"]): UINode<"Icon">;
|
|
205
|
+
image(props?: NodeProps["Image"]): UINode<"Image">;
|
|
206
|
+
switch(props?: NodeProps["Switch"]): UINode<"Switch">;
|
|
207
|
+
radioGroup(props?: NodeProps["RadioGroup"]): UINode<"RadioGroup">;
|
|
208
|
+
select(props?: NodeProps["Select"]): UINode<"Select">;
|
|
209
|
+
slider(props?: NodeProps["Slider"]): UINode<"Slider">;
|
|
210
|
+
textarea(props?: NodeProps["Textarea"]): UINode<"Textarea">;
|
|
211
|
+
/** A modal dialog shown while `open`; append its body as children. */
|
|
212
|
+
dialog(props?: NodeProps["Dialog"]): UINode<"Dialog">;
|
|
213
|
+
/** A list that builds only the rows in view; append one child per row (PROTOCOL.md section 15). */
|
|
214
|
+
virtualList(props?: NodeProps["VirtualList"]): UINode<"VirtualList">;
|
|
215
|
+
/** A data table with text cells; it virtualizes its rows. */
|
|
216
|
+
table(props?: NodeProps["Table"]): UINode<"Table">;
|
|
217
|
+
/** A tab bar; show the chosen tab's content yourself. */
|
|
218
|
+
tabs(props?: NodeProps["Tabs"]): UINode<"Tabs">;
|
|
219
|
+
/** One tab of a `Tabs`; append the nodes of its chip (an `Icon`, a `text`, a `Tag`…; a last `Button` is drawn after them). */
|
|
220
|
+
tab(props?: NodeProps["Tab"]): UINode<"Tab">;
|
|
221
|
+
/** A menu bar: one button per menu (PROTOCOL.md section 10). */
|
|
222
|
+
menuBar(props?: NodeProps["MenuBar"]): UINode<"MenuBar">;
|
|
223
|
+
/** An inline message; `close` when it is `closable` (PROTOCOL.md section 17). */
|
|
224
|
+
alert(props?: NodeProps["Alert"]): UINode<"Alert">;
|
|
225
|
+
/** A count, a dot or an icon over its children. */
|
|
226
|
+
badge(props?: NodeProps["Badge"]): UINode<"Badge">;
|
|
227
|
+
tag(props?: NodeProps["Tag"]): UINode<"Tag">;
|
|
228
|
+
/** A key or shortcut, such as `ctrl-s`. */
|
|
229
|
+
kbd(props?: NodeProps["Kbd"]): UINode<"Kbd">;
|
|
230
|
+
/** A progress bar: `value` from 0 to 100. */
|
|
231
|
+
progress(props?: NodeProps["Progress"]): UINode<"Progress">;
|
|
232
|
+
/** A spinner; give it a size with `class` (`size-4`). */
|
|
233
|
+
spinner(props?: NodeProps["Spinner"]): UINode<"Spinner">;
|
|
234
|
+
/** A loading placeholder. */
|
|
235
|
+
skeleton(props?: NodeProps["Skeleton"]): UINode<"Skeleton">;
|
|
236
|
+
/** Stars: `change` with the chosen count. */
|
|
237
|
+
rating(props?: NodeProps["Rating"]): UINode<"Rating">;
|
|
238
|
+
/** Page navigation: `change` with the chosen page (1-based). */
|
|
239
|
+
pagination(props?: NodeProps["Pagination"]): UINode<"Pagination">;
|
|
240
|
+
/** Content shown while `open`; toggle it with anything that takes a click. */
|
|
241
|
+
collapsible(props?: NodeProps["Collapsible"]): UINode<"Collapsible">;
|
|
242
|
+
/** Sections as `items`; `change` with the id of the one toggled. */
|
|
243
|
+
accordion(props?: NodeProps["Accordion"]): UINode<"Accordion">;
|
|
244
|
+
/** A user picture, or their initial. */
|
|
245
|
+
avatar(props?: NodeProps["Avatar"]): UINode<"Avatar">;
|
|
246
|
+
/** A step indicator: `change` with the chosen step's `value`. */
|
|
247
|
+
stepper(props?: NodeProps["Stepper"]): UINode<"Stepper">;
|
|
248
|
+
/** A text field with increment and decrement buttons. */
|
|
249
|
+
numberInput(props?: NodeProps["NumberInput"]): UINode<"NumberInput">;
|
|
250
|
+
/** A one-time code, one cell per digit. */
|
|
251
|
+
otpInput(props?: NodeProps["OtpInput"]): UINode<"OtpInput">;
|
|
252
|
+
/** A form; append `Field`s to it. */
|
|
253
|
+
form(props?: NodeProps["Form"]): UINode<"Form">;
|
|
254
|
+
/** A label, an optional description and its children as the control. */
|
|
255
|
+
field(props?: NodeProps["Field"]): UINode<"Field">;
|
|
256
|
+
/** A titled box; append its content. */
|
|
257
|
+
groupBox(props?: NodeProps["GroupBox"]): UINode<"GroupBox">;
|
|
258
|
+
/** Key-value rows. */
|
|
259
|
+
descriptionList(props?: NodeProps["DescriptionList"]): UINode<"DescriptionList">;
|
|
260
|
+
/** A status bar with text on the left and on the right. */
|
|
261
|
+
statusBar(props?: NodeProps["StatusBar"]): UINode<"StatusBar">;
|
|
262
|
+
/** A toolbar; append its content. */
|
|
263
|
+
toolbar(props?: NodeProps["Toolbar"]): UINode<"Toolbar">;
|
|
264
|
+
/** Panels the user can resize; append one child per panel. */
|
|
265
|
+
resizable(props?: NodeProps["Resizable"]): UINode<"Resizable">;
|
|
266
|
+
/** A month view: `change` with the chosen day (`YYYY-MM-DD`). */
|
|
267
|
+
calendar(props?: NodeProps["Calendar"]): UINode<"Calendar">;
|
|
268
|
+
/** Items in props; `change` with the chosen item's id, `expand`/`collapse` with a folder's id. */
|
|
269
|
+
tree(props?: NodeProps["Tree"]): UINode<"Tree">;
|
|
270
|
+
/** A parsed patch; `change` with the selected lines. */
|
|
271
|
+
diff(props?: NodeProps["Diff"]): UINode<"Diff">;
|
|
272
|
+
/** Slides as children; `change` with the selected index. */
|
|
273
|
+
carousel(props?: NodeProps["Carousel"]): UINode<"Carousel">;
|
|
274
|
+
/** Sections of entries in props; `change` with the clicked entry's id. */
|
|
275
|
+
sidebar(props?: NodeProps["Sidebar"]): UINode<"Sidebar">;
|
|
276
|
+
/** A line, bar or pie chart of the points in `data`. */
|
|
277
|
+
chart(props?: NodeProps["Chart"]): UINode<"Chart">;
|
|
278
|
+
/** A node of any type; the specific methods below only add typing. */
|
|
279
|
+
create<T extends NodeType>(type: T, props?: NodeProps[T]): UINode<T>;
|
|
280
|
+
/** Creates or updates the main window (window 1). It opens on the first commit that sets `root`. */
|
|
281
|
+
window(options: WindowOptions): this;
|
|
282
|
+
/** Another window, with its own root; it opens on the first commit that sets `root`. */
|
|
283
|
+
createWindow(options?: WindowOptions): AppWindow;
|
|
284
|
+
/** @internal */
|
|
285
|
+
queueWindow(id: WindowId | undefined, options: WindowOptions): void;
|
|
286
|
+
/** @internal */
|
|
287
|
+
queueCloseWindow(id: WindowId): void;
|
|
288
|
+
/** Native "open" dialog; resolves with the chosen paths, or `null` if cancelled. */
|
|
289
|
+
openDialog(options?: OpenDialogOptions): Promise<string[] | null>;
|
|
290
|
+
/** Native "save" dialog; resolves with the chosen path, or `null` if cancelled. */
|
|
291
|
+
saveDialog(options?: SaveDialogOptions): Promise<string | null>;
|
|
292
|
+
/** The clipboard's text, or `null` if it holds none. */
|
|
293
|
+
readClipboard(): Promise<string | null>;
|
|
294
|
+
/** Shows a toast now (not on commit). */
|
|
295
|
+
notify(options: NotifyOptions): void;
|
|
296
|
+
writeClipboard(text: string): void;
|
|
297
|
+
/** Opens a URL with the system's handler (the browser for http). */
|
|
298
|
+
openUrl(url: string): void;
|
|
299
|
+
/** Opens a file or folder with its default app. */
|
|
300
|
+
openPath(path: string): void;
|
|
301
|
+
/** Actions run when the host gets them, not on commit. */
|
|
302
|
+
private action;
|
|
303
|
+
private request;
|
|
304
|
+
/** App-wide keyboard shortcuts (`ctrl-s`, `f5`…), applied on the next commit; replaces the list. */
|
|
305
|
+
shortcuts(keys: string[]): this;
|
|
306
|
+
/** Shows or updates the system tray icon on the next commit. */
|
|
307
|
+
tray(options: TrayOptions): this;
|
|
308
|
+
/** Removes the tray icon on the next commit; with no window open, the host then exits. */
|
|
309
|
+
removeTray(): this;
|
|
310
|
+
/** Sends every pending operation; the host renders once per commit. */
|
|
311
|
+
commit(): void;
|
|
312
|
+
on<K extends keyof AppEvents>(event: K, listener: (payload: AppEvents[K]) => void): this;
|
|
313
|
+
off<K extends keyof AppEvents>(event: K, listener: (payload: AppEvents[K]) => void): this;
|
|
314
|
+
/** Closes the connection; resolves when the host has exited. */
|
|
315
|
+
close(): Promise<HostExit>;
|
|
316
|
+
/** Resolves when the host process has exited, for any reason. */
|
|
317
|
+
exited(): Promise<HostExit>;
|
|
318
|
+
/** @internal */
|
|
319
|
+
handleMessage(message: HostMessage): void;
|
|
320
|
+
/** @internal */
|
|
321
|
+
handleExit(exit: HostExit): void;
|
|
322
|
+
private emit;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Starts the host through `start` and completes the handshake. Rejects with a
|
|
326
|
+
* clear message if the host cannot start.
|
|
327
|
+
*/
|
|
328
|
+
export declare function connect(hostPath: string, start: (events: HostEvents) => HostTransport): Promise<App>;
|
|
329
|
+
export {};
|