-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.d.ts
More file actions
390 lines (366 loc) · 12 KB
/
index.d.ts
File metadata and controls
390 lines (366 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/* auto-generated by NAPI-RS */
/* eslint-disable */
/** Represents an application. */
export declare class Application {
/** Creates a new application. */
constructor(options?: ApplicationOptions | undefined | null)
/** Sets the event handler callback. */
onEvent(handler?: ((arg: ApplicationEvent) => void) | undefined | null): void
/** Alias for on_event() - binds an event handler callback. */
bind(handler?: ((arg: ApplicationEvent) => void) | undefined | null): void
/** Exits the application gracefully. This will trigger the close event and clean up resources. */
exit(): void
/** Creates a new browser window. */
createBrowserWindow(options?: BrowserWindowOptions | undefined | null): BrowserWindow
/** Creates a new browser window as a child window. */
createChildBrowserWindow(options?: BrowserWindowOptions | undefined | null): BrowserWindow
/** Sets the global menu for the application (cross-platform) */
setMenu(menuOptions?: MenuOptions | undefined | null): void
/** Runs the application. This method will block the current thread. */
run(): void
}
export declare class BrowserWindow {
/** Creates a webview on this window. */
createWebview(options?: WebviewOptions | undefined | null): JsWebview
/** Whether or not the window is a child window. */
get isChild(): boolean
/** Whether the window is focused. */
isFocused(): boolean
/** Whether the window is visible. */
isVisible(): boolean
/** Whether the window is decorated. */
isDecorated(): boolean
/** Whether the window is closable. */
isClosable(): boolean
/** Whether the window is maximizable. */
isMaximizable(): boolean
/** Whether the window is minimizable. */
isMinimizable(): boolean
/** Whether the window is maximized. */
isMaximized(): boolean
/** Whether the window is minimized. */
isMinimized(): boolean
/** Whether the window is resizable. */
isResizable(): boolean
/** Sets the window title. */
setTitle(title: string): void
/** Sets the window title. */
get title(): string
/** Sets closable. */
setClosable(closable: boolean): void
/** Sets maximizable. */
setMaximizable(maximizable: boolean): void
/** Sets minimizable. */
setMinimizable(minimizable: boolean): void
/** Sets resizable. */
setResizable(resizable: boolean): void
/** Gets the window ID. */
id(): number
/** Gets whether the window has a menu. */
hasMenu(): boolean
/** Gets the window theme. */
get theme(): Theme
/** Sets the window theme. */
setTheme(theme: Theme): void
/** Sets the window icon. */
setWindowIcon(icon: Array<number> | string, width: number, height: number): void
/** Removes the window icon. */
removeWindowIcon(): void
/**
* Modifies the window's visibility.
* If `false`, this will hide all the window. If `true`, this will show the window.
*/
setVisible(visible: boolean): void
/** Modifies the window's progress bar. */
setProgressBar(state: JsProgressBar): void
/** Maximizes the window. */
setMaximized(value: boolean): void
/** Minimizes the window. */
setMinimized(value: boolean): void
/** Bring the window to front and focus. */
focus(): void
/** Get available monitors. */
getAvailableMonitors(): Array<Monitor>
/** Get the current monitor. */
getCurrentMonitor(): Monitor | null
/** Get the primary monitor. */
getPrimaryMonitor(): Monitor | null
/** Get the monitor from the given point. */
getMonitorFromPoint(x: number, y: number): Monitor | null
/** Prevents the window contents from being captured by other apps. */
setContentProtection(enabled: boolean): void
/** Sets the window always on top. */
setAlwaysOnTop(enabled: boolean): void
/** Sets always on bottom. */
setAlwaysOnBottom(enabled: boolean): void
/** Turn window decorations on or off. */
setDecorations(enabled: boolean): void
/** Gets the window's current fullscreen state. */
get fullscreen(): FullscreenType | null
/** Sets the window to fullscreen or back. */
setFullscreen(fullscreenType?: FullscreenType | undefined | null): void
/**
* Closes the window by hiding it. Note: This hides the window rather than closing it completely,
* as tao requires the event loop to handle window closing. Use this when you want to
* close a specific window (like a login window) and potentially reopen it later.
*/
close(): void
/** Hides the window without destroying it. */
hide(): void
/** Shows the window if it was hidden. */
show(): void
}
export declare class Webview {
constructor()
/** Sets the IPC handler callback. */
onIpcMessage(handler?: ((arg: IpcMessage) => void) | undefined | null): void
/** Launch a print modal for this window's contents. */
print(): void
/** Set webview zoom level. */
zoom(scaleFactor: number): void
/** Hides or shows the webview. */
setWebviewVisibility(visible: boolean): void
/** Whether the devtools is opened. */
isDevtoolsOpen(): boolean
/** Opens the devtools. */
openDevtools(): void
/** Closes the devtools. */
closeDevtools(): void
/** Loads the given URL. */
loadUrl(url: string): void
/** Loads the given HTML content. */
loadHtml(html: string): void
/** Evaluates the given JavaScript code. */
evaluateScript(js: string): void
evaluateScriptWithCallback(js: string, callback: ((err: Error | null, arg: string) => any)): void
/** Reloads the webview. */
reload(): void
}
export type JsWebview = Webview
/** Represents an event for the application. */
export interface ApplicationEvent {
/** The event type. */
event: WebviewApplicationEvent
/** Custom menu event data */
customMenuEvent?: CustomMenuEvent
}
/** Represents the options for creating an application. */
export interface ApplicationOptions {
/** The control flow of the application. Default is `Wait` (recommended for low CPU usage). */
controlFlow?: ControlFlow
/** The waiting time in ms for the application (only applicable if control flow is set to `WaitUntil`). */
waitTime?: number
/** The exit code of the application. Only applicable if control flow is set to `ExitWithCode`. */
exitCode?: number
}
export interface BrowserWindowOptions {
/** The window menu */
menu?: MenuOptions
/** Whether to show the menu bar */
showMenu?: boolean
/** Whether the window is resizable. Default is `true`. */
resizable?: boolean
/** The window title. */
title?: string
/** The width of the window. */
width?: number
/** The height of the window. */
height?: number
/** The x position of the window. */
x?: number
/** The y position of the window. */
y?: number
/** Whether or not the window should be created with content protection mode. */
contentProtection?: boolean
/** Whether or not the window is always on top. */
alwaysOnTop?: boolean
/** Whether or not the window is always on bottom. */
alwaysOnBottom?: boolean
/** Whether or not the window is visible. */
visible?: boolean
/** Whether or not the window decorations are enabled. */
decorations?: boolean
/** Whether or not the window is visible on all workspaces */
visibleOnAllWorkspaces?: boolean
/** Whether or not the window is maximized. */
maximized?: boolean
/** Whether or not the window is maximizable */
maximizable?: boolean
/** Whether or not the window is minimizable */
minimizable?: boolean
/** Whether or not the window is focused */
focused?: boolean
/** Whether or not the window is transparent */
transparent?: boolean
/** The fullscreen state of the window. */
fullscreen?: FullscreenType
}
/** Represents the control flow of the application. */
export declare const enum ControlFlow {
/** The application will continuously poll for events (high CPU usage). */
Poll = 0,
/** The application will wait for events (recommended, low CPU usage). */
Wait = 1,
/** The application will wait until the specified time. */
WaitUntil = 2,
/** The application will exit. */
Exit = 3,
/** The application will exit with the given exit code. */
ExitWithCode = 4
}
export interface CustomMenuEvent {
/** The menu item identifier */
id: string
/** The window identifier */
windowId: number
}
export interface Dimensions {
/** The width of the size. */
width: number
/** The height of the size. */
height: number
}
export declare const enum FullscreenType {
/** Exclusive fullscreen. */
Exclusive = 0,
/** Borderless fullscreen. */
Borderless = 1
}
/** Returns the version of the webview. */
export declare function getWebviewVersion(): string
export interface HeaderData {
/** The key of the header. */
key: string
/** The value of the header. */
value?: string
}
/** Initialize menu system from worker thread (cross-platform) */
export declare function initMenuSystem(): void
export interface IpcMessage {
/** The body of the message. */
body: Buffer
/** The HTTP method of the message. */
method: string
/** The http headers of the message. */
headers: Array<HeaderData>
/** The URI of the message. */
uri: string
}
export interface JsProgressBar {
/** The progress state. */
state?: ProgressBarState
/** The progress value. */
progress?: number
}
/** Represents menu item options from JavaScript */
export interface MenuItemOptions {
id?: string
label?: string
enabled?: boolean
accelerator?: string
submenu?: MenuOptions
role?: string
}
/** Represents menu options from JavaScript */
export interface MenuOptions {
items: Array<MenuItemOptions>
}
export interface Monitor {
/** The name of the monitor. */
name?: string
/** The scale factor of the monitor. */
scaleFactor: number
/** The size of the monitor. */
size: Dimensions
/** The position of the monitor. */
position: Position
/** The video modes of the monitor. */
videoModes: Array<VideoMode>
}
export interface Position {
/** The x position. */
x: number
/** The y position. */
y: number
}
export declare const enum ProgressBarState {
None = 0,
Normal = 1,
/** Treated as normal in linux and macos */
Indeterminate = 2,
/** Treated as normal in linux */
Paused = 3,
/** Treated as normal in linux */
Error = 4
}
/** Represents the theme of the window. */
export declare const enum Theme {
/** The light theme. */
Light = 0,
/** The dark theme. */
Dark = 1,
/** The system theme. */
System = 2
}
export interface VideoMode {
/** The size of the video mode. */
size: Dimensions
/** The bit depth of the video mode. */
bitDepth: number
/** The refresh rate of the video mode. */
refreshRate: number
}
/** Represents application events */
export declare const enum WebviewApplicationEvent {
/** Window close event. */
WindowCloseRequested = 0,
/** Application close event. */
ApplicationCloseRequested = 1,
/** Custom menu click event. */
CustomMenuClick = 2
}
export interface WebviewOptions {
/** The URL to load. */
url?: string
/** The HTML content to load. */
html?: string
/** The width of the window. */
width?: number
/** The height of the window. */
height?: number
/** The x position of the window. */
x?: number
/** The y position of the window. */
y?: number
/** Whether to enable devtools. Default is `true`. */
enableDevtools?: boolean
/** Whether the window is incognito. Default is `false`. */
incognito?: boolean
/** The default user agent. */
userAgent?: string
/** Whether the webview should be built as a child. */
child?: boolean
/** The preload script to inject. */
preload?: string
/** Whether the window is transparent. Default is `false`. */
transparent?: boolean
/** The default theme. */
theme?: Theme
/** Whether the window is zoomable via hotkeys or gestures. */
hotkeysZoom?: boolean
/** Whether the clipboard access is enabled. */
clipboard?: boolean
/** Whether the autoplay policy is enabled. */
autoplay?: boolean
/** Indicates whether horizontal swipe gestures trigger backward and forward page navigation. */
backForwardNavigationGestures?: boolean
}
/** Window commands that can be sent from JavaScript */
export declare const enum WindowCommand {
/** Close the window */
Close = 0,
/** Show the window */
Show = 1,
/** Hide the window */
Hide = 2
}