-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathjs-bindings.d.ts
More file actions
454 lines (422 loc) · 12.6 KB
/
Copy pathjs-bindings.d.ts
File metadata and controls
454 lines (422 loc) · 12.6 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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class Application {
constructor(options?: ApplicationOptions | undefined | null)
onEvent(handler?: ((arg: ApplicationEvent) => void) | undefined | null): void
bind(handler?: ((arg: ApplicationEvent) => void) | undefined | null): void
exit(): void
createBrowserWindow(options?: BrowserWindowOptions | undefined | null): BrowserWindow
createChildBrowserWindow(options?: BrowserWindowOptions | undefined | null): BrowserWindow
setMenu(menuOptions?: MenuOptions | undefined | null): void
/**
* Pump the winit event loop once without blocking. Returns `true` while
* the app is alive, `false` when it should stop. Drive this from a JS
* `setInterval` via the `run()` wrapper in `index.js`.
*/
pumpEvents(): boolean
/** Run the application event loop. */
run(options?: ApplicationRunOptions | undefined | null): void
}
export declare class BrowserWindow {
/**
* Low-level protocol registration used by the JS `registerProtocol` wrapper.
* `handler` is called with a single JSON string argument:
* `{ id, url, method, headers, body }` where `body` is a number[] or null.
* Call `_completeProtocol(id, response)` when the response is ready.
*/
_registerProtocol(name: string, handler: (arg: string) => void): void
/**
* Complete a pending async protocol request previously started by the
* `_registerProtocol` handler. `id` matches the value in the JSON payload.
*/
_completeProtocol(id: number, response: CustomProtocolResponse): void
createWebview(options?: WebviewOptions | undefined | null): JsWebview
get isChild(): boolean
isFocused(): boolean
isVisible(): boolean
isDecorated(): boolean
isClosable(): boolean
isMaximizable(): boolean
isMinimizable(): boolean
isMaximized(): boolean
isMinimized(): boolean
isResizable(): boolean
setTitle(title: string): void
get title(): string
setClosable(closable: boolean): void
setMaximizable(maximizable: boolean): void
setMinimizable(minimizable: boolean): void
setResizable(resizable: boolean): void
/** Sets the window inner size (width and height). */
setMinSize(width: number, height: number, logical?: boolean | undefined | null): void
/** Gets the window inner size. */
getInnerSize(logical?: boolean | undefined | null): Dimensions
/** Sets the max window inner size (width and height). */
setMaxSize(width: number, height: number, logical?: boolean | undefined | null): void
/** Gets the window outer size. */
getOuterSize(logical?: boolean | undefined | null): Dimensions
/** Opens a file select dialog */
openFileDialog(options?: FileDialogOptions | undefined | null): Array<string>
id(): number
hasMenu(): boolean
get theme(): Theme
setTheme(theme: Theme): void
/**
* Set the window icon.
* - Passing raw RGBA bytes requires `width` and `height` (or just `width` to assume square).
* - Passing an encoded image buffer (PNG, ICO, JPEG, etc.) will auto-detect dimensions.
*/
setWindowIcon(icon: Uint8Array | Array<number>, width?: number | undefined | null, height?: number | undefined | null): void
removeWindowIcon(): void
setVisible(visible: boolean): void
/** No-op: winit does not expose a progress bar API. */
setProgressBar(state: JsProgressBar): void
setMaximized(value: boolean): void
setMinimized(value: boolean): void
focus(): void
getAvailableMonitors(): Array<Monitor>
getCurrentMonitor(): Monitor | null
getPrimaryMonitor(): Monitor | null
/** Not available in winit; always returns `None`. */
getMonitorFromPoint(x: number, y: number): Monitor | null
setContentProtection(enabled: boolean): void
setAlwaysOnTop(enabled: boolean): void
setAlwaysOnBottom(enabled: boolean): void
setDecorations(enabled: boolean): void
get fullscreen(): FullscreenType | null
setFullscreen(fullscreenType?: FullscreenType | undefined | null): void
close(): void
hide(): void
show(): void
/**
* Move the window so its outer top-left corner is at (`x`, `y`) in
* physical pixels.
*/
setPosition(x: number, y: number, logical?: boolean | undefined | null): void
/** Gets the window position. */
getPosition(logical?: boolean | undefined | null): Position
/**
* Center the window on its current monitor. Does nothing if the current
* monitor cannot be determined.
*/
center(): void
/** Device-pixel ratio for the monitor the window is currently on. */
scaleFactor(): number
setCursor(cursor: CursorType): void
setCursorVisible(visible: boolean): void
/**
* Move the OS cursor to (`x`, `y`) in logical pixels relative to the
* window's inner top-left corner.
*/
setCursorPosition(x: number, y: number): void
/**
* When `true` the window ignores mouse input (click-through). Supported on
* Windows and macOS; a no-op on other platforms.
*/
setIgnoreCursorEvents(ignore: boolean): void
/**
* Hide/show the window in the system taskbar. Supported on Windows only;
* a no-op on other platforms.
*/
setSkipTaskbar(skip: boolean): void
requestRedraw(): void
}
export declare class Webview {
constructor()
onIpcMessage(handler?: ((arg: IpcMessage) => void) | undefined | null): void
/**
* Low-level method used by the JS `expose()` wrapper.
*
* Injects a page script that creates `window[name]` as an object with:
* - static values from `statics_json` (a JSON object string)
* - async function stubs for each name in `func_names`
*
* When the page calls one of the stubs the call is routed back here via
* the internal IPC channel and dispatched to `handler`. `handler` is
* responsible for calling `evaluateScript` to send the response.
*/
_exposeInternal(name: string, staticsJson: string, funcNames: Array<string>, handler: (arg: ExposeCallData) => void): void
print(): void
zoom(scaleFactor: number): void
setWebviewVisibility(visible: boolean): void
isDevtoolsOpen(): boolean
openDevtools(): void
closeDevtools(): void
loadUrl(url: string): void
loadHtml(html: string): void
evaluateScript(js: string): void
evaluateScriptWithCallback(js: string, callback: ((err: Error | null, arg: string) => any)): void
reload(): void
/** Get the URL the webview is currently showing. */
url(): string | null
/** Load `url` with additional HTTP request headers. */
loadUrlWithHeaders(url: string, headers: Array<HeaderData>): void
/**
* Return all cookies currently stored for `url`, or every cookie if `url`
* is `null` / `undefined`.
*/
getCookies(url?: string | undefined | null): Array<WebviewCookie>
/** Store a cookie in the webview's session. */
setCookie(cookie: WebviewCookie): void
/**
* Delete a cookie by name. `domain` and `path` narrow the match;
* omit them to delete across all domains/paths.
*/
deleteCookie(name: string, domain?: string | undefined | null, path?: string | undefined | null): void
/** Erase all cookies, cache, local storage, and IndexedDB data. */
clearAllBrowsingData(): void
/**
* Set the background colour shown before (or behind) page content.
* Values are 0-255.
*/
setBackgroundColor(r: number, g: number, b: number, a: number): void
/**
* Return the webview's current bounds relative to the window, in logical
* pixels.
*/
getBounds(): WebviewBounds | null
/** Reposition and resize the webview within its window. */
setBounds(bounds: WebviewBounds): void
/** Give keyboard focus to the webview content area. */
focus(): void
/** Return focus to the parent/host window. */
focusParent(): void
}
export type JsWebview = Webview
export interface ApplicationEvent {
event: WebviewApplicationEvent
customMenuEvent?: CustomMenuEvent
}
export interface ApplicationOptions {
controlFlow?: ControlFlow
waitTime?: number
exitCode?: number
}
export interface ApplicationRunOptions {
/** The interval in milliseconds to pump events. Defaults to 16 (60 FPS). */
interval?: number
/** Whether to keep the event loop alive. Defaults to true. */
ref?: boolean
}
export interface BrowserWindowOptions {
menu?: MenuOptions
showMenu?: boolean
resizable?: boolean
title?: string
logical?: boolean
width?: number
height?: number
x?: number
y?: number
contentProtection?: boolean
alwaysOnTop?: boolean
alwaysOnBottom?: boolean
visible?: boolean
decorations?: boolean
visibleOnAllWorkspaces?: boolean
maximized?: boolean
maximizable?: boolean
minimizable?: boolean
focused?: boolean
transparent?: boolean
fullscreen?: FullscreenType
}
/** Kept for backward compat; no longer used internally. */
export declare enum ControlFlow {
Poll = 0,
Wait = 1,
WaitUntil = 2,
Exit = 3,
ExitWithCode = 4
}
/** Cursor shape passed to [`BrowserWindow::set_cursor`]. */
export declare enum CursorType {
Default = 0,
Crosshair = 1,
Hand = 2,
Arrow = 3,
Move = 4,
Text = 5,
Wait = 6,
Help = 7,
Progress = 8,
NotAllowed = 9,
ContextMenu = 10,
Cell = 11,
VerticalText = 12,
Alias = 13,
Copy = 14,
NoDrop = 15,
Grab = 16,
Grabbing = 17,
ZoomIn = 18,
ZoomOut = 19,
ResizeEast = 20,
ResizeNorth = 21,
ResizeNorthEast = 22,
ResizeNorthWest = 23,
ResizeSouth = 24,
ResizeSouthEast = 25,
ResizeSouthWest = 26,
ResizeWest = 27,
ResizeEastWest = 28,
ResizeNorthSouth = 29,
ResizeNorthEastSouthWest = 30,
ResizeNorthWestSouthEast = 31,
ResizeColumn = 32,
ResizeRow = 33,
AllScroll = 34
}
export interface CustomMenuEvent {
id: string
windowId: number
}
/** Incoming request delivered to a custom-protocol handler. */
export interface CustomProtocolRequest {
url: string
method: string
headers: Array<HeaderData>
body?: Buffer
}
/** Response returned by a custom-protocol handler. */
export interface CustomProtocolResponse {
/** HTTP status code. Defaults to 200. */
statusCode?: number
/** Extra response headers (e.g. `[{ key: "Cache-Control", value: "no-store" }]`). */
headers?: Array<HeaderData>
/** Response body bytes. */
body: Buffer
/** MIME type (e.g. `"text/html"`, `"application/javascript"`). */
mimeType?: string
}
export interface Dimensions {
width: number
height: number
}
/** Data sent to the expose handler when the page calls a proxied function. */
export interface ExposeCallData {
ns: string
method: string
id: number
argsJson: string
}
export interface FileDialogOptions {
multiple?: boolean
title?: string
defaultPath?: string
filters?: Array<FileFilter>
}
export interface FileFilter {
name: string
extensions: Array<string>
}
export declare enum FullscreenType {
Exclusive = 0,
Borderless = 1
}
export declare function getWebviewVersion(): string
export interface HeaderData {
key: string
value?: string
}
export interface IpcMessage {
body: Buffer
method: string
headers: Array<HeaderData>
uri: string
}
export interface JsProgressBar {
state?: ProgressBarState
progress?: number
}
export interface MenuItemOptions {
id?: string
label?: string
enabled?: boolean
accelerator?: string
submenu?: MenuOptions
role?: string
}
export interface MenuOptions {
items: Array<MenuItemOptions>
}
export interface Monitor {
name?: string
scaleFactor: number
size: Dimensions
position: Position
videoModes: Array<VideoMode>
}
export interface Position {
x: number
y: number
}
export declare enum ProgressBarState {
None = 0,
Normal = 1,
Indeterminate = 2,
Paused = 3,
Error = 4
}
export declare enum Theme {
Light = 0,
Dark = 1,
System = 2
}
export interface VideoMode {
size: Dimensions
bitDepth: number
refreshRate: number
}
export declare enum WebviewApplicationEvent {
WindowCloseRequested = 0,
ApplicationCloseRequested = 1,
CustomMenuClick = 2
}
export interface WebviewBounds {
x: number
y: number
width: number
height: number
}
export interface WebviewCookie {
name: string
value: string
domain?: string
path?: string
httpOnly?: boolean
secure?: boolean
/** `"strict"`, `"lax"`, or `"none"`. */
sameSite?: string
}
export interface WebviewOptions {
url?: string
html?: string
width?: number
height?: number
x?: number
y?: number
enableDevtools?: boolean
incognito?: boolean
userAgent?: string
child?: boolean
preload?: string
transparent?: boolean
theme?: Theme
hotkeysZoom?: boolean
clipboard?: boolean
autoplay?: boolean
backForwardNavigationGestures?: boolean
/**
* Custom name for the IPC global injected by wry (default: `"ipc"`).
* The page will access it as `window.<ipcName>.postMessage(...)`.
* wry always injects `window.ipc`; this option creates an alias via an
* initialization script. The original `window.ipc` remains available.
*/
ipcName?: string
}
export declare enum WindowCommand {
Close = 0,
Show = 1,
Hide = 2
}