-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
305 lines (303 loc) · 9.82 KB
/
index.d.ts
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
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export const enum FullscreenType {
/** Exclusive fullscreen. */
Exclusive = 0,
/** Borderless fullscreen. */
Borderless = 1
}
export interface Dimensions {
/** The width of the size. */
width: number
/** The height of the size. */
height: number
}
export interface Position {
/** The x position. */
x: number
/** The y position. */
y: number
}
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
}
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 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
}
export interface JsProgressBar {
/** The progress state. */
state?: ProgressBarState
/** The progress value. */
progress?: number
}
export interface BrowserWindowOptions {
/** 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 theme of the window. */
export const enum Theme {
/** The light theme. */
Light = 0,
/** The dark theme. */
Dark = 1,
/** The system theme. */
System = 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
}
/** TODO */
export const enum WebviewApplicationEvent {
/** Window close event. */
WindowCloseRequested = 0
}
export interface HeaderData {
/** The key of the header. */
key: string
/** The value of the header. */
value?: string
}
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
}
/** Returns the version of the webview. */
export declare function getWebviewVersion(): string
/** Represents the control flow of the application. */
export const enum ControlFlow {
/** The application will continue running. */
Poll = 0,
/** The application will wait until the specified time. */
WaitUntil = 1,
/** The application will exit. */
Exit = 2,
/** The application will exit with the given exit code. */
ExitWithCode = 3
}
/** Represents the options for creating an application. */
export interface ApplicationOptions {
/** The control flow of the application. Default is `Poll`. */
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
}
/** Represents an event for the application. */
export interface ApplicationEvent {
/** The event type. */
event: WebviewApplicationEvent
}
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 theme. */
get theme(): JsTheme
/** Sets the window theme. */
setTheme(theme: JsTheme): 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
}
export type JsWebview = Webview
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(scaleFacotr: 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
}
/** 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
/** 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
/** Runs the application. This method will block the current thread. */
run(): void
}