electron-sys 0.4.0

Raw bindings to the Electron API for projects using wasm-bindgen.
Documentation
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
use crate::{
    class::{BrowserView, Menu, NativeImage, TouchBar, WebContents},
    interface::{
        AppDetailsOptions,
        BrowserWindowOptions,
        IgnoreMouseEventsOptions,
        LoadFileOptions,
        LoadUrlOptions,
        ProgressBarOptions,
        Rectangle,
        Size,
        VisibleOnAllWorkspacesOptions,
    },
};
use js_sys::{Function, JsString, Map};
use node_sys::{events::EventEmitter, Buffer};
use wasm_bindgen::prelude::*;

#[wasm_bindgen(module = "electron")]
extern {
    #[wasm_bindgen(extends = EventEmitter)]
    #[derive(Clone, Debug)]
    /// Docs: http://electronjs.org/docs/api/browser-window
    pub type BrowserWindow;

    //****************//
    // Static Methods //
    //****************//

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "addDevToolsExtension")]
    pub fn add_dev_tools_extension(path: &str);

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "addExtension")]
    pub fn add_extension(path: &str);

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "fromBrowserView")]
    pub fn from_browser_view(browser_view: &BrowserView) -> Option<BrowserWindow>;

    // FIXME: should return Option<BrowserWindow>?
    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "from_id")]
    pub fn from_id(id: u32) -> BrowserWindow;

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "from_web_contents")]
    pub fn from_web_contents(web_contents: &WebContents) -> Option<BrowserWindow>;

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "getAllWindows")]
    pub fn get_all_windows() -> Box<[JsValue]>;

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "getDevToolsExtension")]
    pub fn get_dev_tools_extension() -> Map;

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "getFocusedWindow")]
    pub fn get_focused_window() -> Option<BrowserWindow>;

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "removeDevToolsExtension")]
    pub fn remove_dev_tools_extension(name: &str);

    #[wasm_bindgen(static_method_of = BrowserWindow, js_name = "removeExtension")]
    pub fn remove_extension(name: &str);

    //******************//
    // Instance Methods //
    //******************//

    #[wasm_bindgen(constructor)]
    pub fn new(options: Option<BrowserWindowOptions>) -> BrowserWindow;

    #[wasm_bindgen(method, js_name = "addBrowserView")]
    pub fn add_browser_view(this: &BrowserWindow, browser_view: &BrowserView);

    #[wasm_bindgen(method, js_name = "addTabbedWindow")]
    pub fn add_tabbed_window(this: &BrowserWindow, browser_view: &BrowserWindow);

    #[wasm_bindgen(method)]
    pub fn blur(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "blurWebView")]
    pub fn blur_web_view(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "capturePage")]
    pub fn capture_page(this: &BrowserWindow, rectangle: Option<Rectangle>);

    #[wasm_bindgen(method)]
    pub fn center(this: &BrowserWindow);

    #[wasm_bindgen(method)]
    pub fn close(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "closeFilePreview")]
    pub fn close_file_preview(this: &BrowserWindow);

    #[wasm_bindgen(method)]
    pub fn destroy(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "flashFrame")]
    pub fn flash_frame(this: &BrowserWindow);

    #[wasm_bindgen(method)]
    pub fn focus(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "focusOnWebView")]
    pub fn focus_on_web_view(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "getBounds")]
    pub fn get_bounds(this: &BrowserWindow) -> Rectangle;

    #[wasm_bindgen(method, js_name = "getBrowserView")]
    pub fn get_browser_view(this: &BrowserWindow) -> Option<BrowserView>;

    #[wasm_bindgen(method, js_name = "getBrowserViews")]
    pub fn get_browser_views(this: &BrowserWindow) -> Box<[JsValue]>;

    #[wasm_bindgen(method, js_name = "getChildWindows")]
    pub fn get_child_windows(this: &BrowserWindow) -> Box<[JsValue]>;

    #[wasm_bindgen(method, js_name = "getContentBounds")]
    pub fn get_content_bounds(this: &BrowserWindow) -> Rectangle;

    #[wasm_bindgen(method, js_name = "getContentSize")]
    pub fn get_content_size(this: &BrowserWindow) -> Box<[u32]>;

    #[wasm_bindgen(method, js_name = "getMaximumSize")]
    pub fn get_maximum_size(this: &BrowserWindow) -> Box<[u32]>;

    #[wasm_bindgen(method, js_name = "getMediaSourceId")]
    pub fn get_media_source_id(this: &BrowserWindow) -> JsString;

    #[wasm_bindgen(method, js_name = "getMinimumSize")]
    pub fn get_minimum_size(this: &BrowserWindow) -> Box<[JsValue]>;

    #[wasm_bindgen(method, js_name = "getNativeWindowHandle")]
    pub fn get_native_window_handle(this: &BrowserWindow) -> Buffer;

    #[wasm_bindgen(method, js_name = "getNormalBounds")]
    pub fn get_normal_bounds(this: &BrowserWindow) -> Rectangle;

    #[wasm_bindgen(method, js_name = "getOpacity")]
    pub fn get_opacity(this: &BrowserWindow) -> f32;

    #[wasm_bindgen(method, js_name = "getParentWindow")]
    pub fn get_parent_window(this: &BrowserWindow) -> BrowserWindow;

    #[wasm_bindgen(method, js_name = "getPosition")]
    pub fn get_position(this: &BrowserWindow) -> Box<[JsValue]>;

    #[wasm_bindgen(method, js_name = "getRepresentedFilename")]
    pub fn get_represented_filename(this: &BrowserWindow) -> Box<[JsValue]>;

    #[wasm_bindgen(method, js_name = "getSize")]
    pub fn get_size(this: &BrowserWindow) -> Box<[JsValue]>;

    #[wasm_bindgen(method, js_name = "getTitle")]
    pub fn get_title(this: &BrowserWindow) -> JsString;

    #[wasm_bindgen(method, js_name = "hasShadow")]
    pub fn has_shadow(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method)]
    pub fn hide(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "hookWindowMessage")]
    pub fn hook_window_message(this: &BrowserWindow, message: u32, callback: &Function);

    #[wasm_bindgen(method, js_name = "isAlwaysOnTop")]
    pub fn is_always_on_top(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isDestroyed")]
    pub fn is_destroyed(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isDocumentEdited")]
    pub fn is_document_edited(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isEnabled")]
    pub fn is_enabled(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isFocued")]
    pub fn is_focused(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isFullScreenable")]
    pub fn is_full_screenable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isKiosk")]
    pub fn is_kiosk(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isMaximized")]
    pub fn is_maximized(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isMenuBarVisible")]
    pub fn is_menu_bar_visible(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isMinimized")]
    pub fn is_minimized(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isModal")]
    pub fn is_modal(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isNormal")]
    pub fn is_normal(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isSimpleFullScreen")]
    pub fn is_simple_full_screen(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isVisible")]
    pub fn is_visible(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isVisibleOnAllWorkspaces")]
    pub fn is_visible_on_all_workspaces(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, js_name = "isWindowMessageHooked")]
    pub fn is_window_message_hooked(this: &BrowserWindow, message: u32) -> bool;

    #[wasm_bindgen(method, js_name = "loadFile")]
    pub fn load_file(this: &BrowserWindow, path: &str, options: Option<LoadFileOptions>);

    #[wasm_bindgen(method, js_name = "loadURL")]
    pub fn load_url(this: &BrowserWindow, url: &str, options: Option<LoadUrlOptions>);

    #[wasm_bindgen(method)]
    pub fn maximize(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "mergeAllWindows")]
    pub fn merge_all_windows(this: &BrowserWindow);

    #[wasm_bindgen(method)]
    pub fn minimize(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "moveAbove")]
    pub fn move_above(this: &BrowserWindow, media_source_id: &str);

    #[wasm_bindgen(method, js_name = "moveTabToNewWindow")]
    pub fn move_tab_to_new_window(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "moveTop")]
    pub fn move_top(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "previewFile")]
    pub fn preview_file(this: &BrowserWindow, path: &str, display_name: Option<&str>);

    #[wasm_bindgen(method)]
    pub fn reload(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "removeBrowserView")]
    pub fn remove_browser_view(this: &BrowserWindow, browser_view: &BrowserView);

    #[wasm_bindgen(method, js_name = "removeMenu")]
    pub fn remove_menu(this: &BrowserWindow);

    #[wasm_bindgen(method)]
    pub fn restore(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "selectNextTab")]
    pub fn select_next_tab(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "selectPreviousTab")]
    pub fn select_previous_tab(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "setAlwaysOnTop")]
    pub fn set_always_on_top(this: &BrowserWindow, flag: bool, level: Option<&str>, relative_level: Option<i32>);

    #[wasm_bindgen(method, js_name = "setAppDetails")]
    pub fn set_app_details(this: &BrowserWindow, options: AppDetailsOptions);

    #[wasm_bindgen(method, js_name = "setAspectRatio")]
    pub fn set_aspect_ratio(this: &BrowserWindow, aspect_ratio: f32, extra_size: Option<Size>);

    #[wasm_bindgen(method, js_name = "setAutoHideCursor")]
    pub fn set_auto_hide_cursor(this: &BrowserWindow, auto_hide: bool);

    #[wasm_bindgen(method, js_name = "setBackgroundColor")]
    pub fn set_background_color(this: &BrowserWindow, background_color: &str);

    #[wasm_bindgen(method, js_name = "setBounds")]
    pub fn set_bounds(this: &BrowserWindow, bounds: Rectangle, animate: Option<bool>);

    #[wasm_bindgen(method, js_name = "setBrowserView")]
    pub fn set_browser_view(this: &BrowserWindow, browser_view: &BrowserView);

    #[wasm_bindgen(method, js_name = "setContentBounds")]
    pub fn set_content_bounds(this: &BrowserWindow, bounds: Rectangle, animate: Option<bool>);

    #[wasm_bindgen(method, js_name = "setContentProtection")]
    pub fn set_content_protection(this: &BrowserWindow, enable: bool);

    #[wasm_bindgen(method, js_name = "setContentSize")]
    pub fn set_content_size(this: &BrowserWindow, width: u32, height: u32, animate: Option<bool>);

    #[wasm_bindgen(method, js_name = "setDocumentEdited")]
    pub fn set_document_edited(this: &BrowserWindow, edited: bool);

    #[wasm_bindgen(method, js_name = "setEnabled")]
    pub fn set_enabled(this: &BrowserWindow, edited: bool);

    #[wasm_bindgen(method, js_name = "setFocusable")]
    pub fn set_focusable(this: &BrowserWindow, focusable: bool);

    #[wasm_bindgen(method, js_name = "setFullScreen")]
    pub fn set_full_screen(this: &BrowserWindow, flag: bool);

    #[wasm_bindgen(method, js_name = "setHasShadow")]
    pub fn set_has_shadow(this: &BrowserWindow, has_shadow: bool);

    #[wasm_bindgen(method, js_name = "setIcon")]
    pub fn set_icon(this: &BrowserWindow, icon: &NativeImage);

    #[wasm_bindgen(method, js_name = "setIgnoreMouseEvents")]
    pub fn set_ignore_mouse_events(this: &BrowserWindow, ignore: bool, options: Option<IgnoreMouseEventsOptions>);

    #[wasm_bindgen(method, js_name = "setKiosk")]
    pub fn set_kiosk(this: &BrowserWindow, flag: bool);

    #[wasm_bindgen(method, js_name = "setMaximizable")]
    pub fn set_maximumizable(this: &BrowserWindow, maximizable: bool);

    #[wasm_bindgen(method, js_name = "setMaximumSize")]
    pub fn set_maximum_size(this: &BrowserWindow, width: u32, height: u32);

    #[wasm_bindgen(method, js_name = "setMenu")]
    pub fn set_menu(this: &BrowserWindow, menu: Option<Menu>);

    #[wasm_bindgen(method, js_name = "setMenuBarVisibility")]
    pub fn set_menu_bar_visibility(this: &BrowserWindow, visible: bool);

    #[wasm_bindgen(method, js_name = "setMinimumSize")]
    pub fn set_minimum_size(this: &BrowserWindow, width: u32, height: u32);

    #[wasm_bindgen(method, js_name = "setOpacity")]
    pub fn set_opacity(this: &BrowserWindow, opacity: f32);

    #[wasm_bindgen(method, js_name = "setOverlayIcon")]
    pub fn set_overlay_icon(this: &BrowserWindow, overlay: Option<&NativeImage>, description: &str);

    #[wasm_bindgen(method, js_name = "setParentWindow")]
    pub fn set_parent_window(this: &BrowserWindow, parent: Option<&BrowserWindow>);

    #[wasm_bindgen(method, js_name = "setPosition")]
    pub fn set_position(this: &BrowserWindow, x: u32, y: u32, animate: Option<bool>);

    #[wasm_bindgen(method, js_name = "setProgressBar")]
    pub fn set_progress_bar(this: &BrowserWindow, progress: u32, options: Option<ProgressBarOptions>);

    #[wasm_bindgen(method, js_name = "setRepresentedFilename")]
    pub fn set_represented_filename(this: &BrowserWindow, filename: &str);

    #[wasm_bindgen(method, js_name = "setShape")]
    pub fn set_shape(this: &BrowserWindow, rectangles: Box<[JsValue]>);

    #[wasm_bindgen(method, js_name = "setSheetOffset")]
    pub fn set_sheet_offset(this: &BrowserWindow, y: i32, x: Option<i32>);

    #[wasm_bindgen(method, js_name = "setSimpleFullScreen")]
    pub fn set_simple_full_screen(this: &BrowserWindow, flag: bool);

    #[wasm_bindgen(method, js_name = "setSize")]
    pub fn set_size(this: &BrowserWindow, width: u32, height: u32, animate: Option<bool>);

    #[wasm_bindgen(method, js_name = "setSkipTaskbar")]
    pub fn set_skip_taskbar(this: &BrowserWindow, skip: bool);

    #[wasm_bindgen(method, js_name = "setThumbarButtons")]
    pub fn set_thumbar_buttons(this: &BrowserWindow, buttons: Box<[JsValue]>) -> bool;

    #[wasm_bindgen(method, js_name = "setThumbnailClip")]
    pub fn set_thumbnail_clip(this: &BrowserWindow, region: Rectangle);

    #[wasm_bindgen(method, js_name = "setThumbnailToolTip")]
    pub fn set_thumbnail_tool_tip(this: &BrowserWindow, tool_tip: &str);

    #[wasm_bindgen(method, js_name = "setTitle")]
    pub fn set_title(this: &BrowserWindow, title: &str);

    #[wasm_bindgen(method, js_name = "setTouchBar")]
    pub fn set_touch_bar(this: &BrowserWindow, touch_bar: Option<&TouchBar>);

    #[wasm_bindgen(method, js_name = "setVibrancy")]
    pub fn set_vibrancy(this: &BrowserWindow, kind: Option<&str>);

    #[wasm_bindgen(method, js_name = "setVisibleOnAllWorkspaces")]
    pub fn set_visible_on_all_workspaces(
        this: &BrowserWindow,
        visible: bool,
        options: Option<VisibleOnAllWorkspacesOptions>,
    );

    #[wasm_bindgen(method, js_name = "setWindowButtonVisibility")]
    pub fn set_window_button_visibility(this: &BrowserWindow, visible: bool);

    #[wasm_bindgen(method)]
    pub fn show(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "showAppDetails")]
    pub fn show_app_details(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "showAspectRatio")]
    pub fn show_aspect_ratio(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "showDefinitionForSelection")]
    pub fn show_definition_for_selection(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "showInactive")]
    pub fn show_inactive(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "toggleTabBar")]
    pub fn toggle_tab_bar(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "unhookAllWindowMessages")]
    pub fn unhook_all_window_messages(this: &BrowserWindow);

    #[wasm_bindgen(method, js_name = "unhookWindowMessage")]
    pub fn unhook_window_messages(this: &BrowserWindow, message: u32);

    //*********************//
    // Instance Properties //
    //*********************//

    #[wasm_bindgen(method, getter, js_name = "accessibleTitle")]
    pub fn accessible_title(this: &BrowserWindow) -> JsString;

    #[wasm_bindgen(method, setter, js_name = "accessibleTitle")]
    pub fn set_accessible_title(this: &BrowserWindow, value: JsString);

    #[wasm_bindgen(method, getter, js_name = "autoHideMenuBar")]
    pub fn auto_hide_menu_bar(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter, js_name = "autoHideMenuBar")]
    pub fn set_auto_hide_menu_bar(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter)]
    pub fn closable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter, js_name = "closable")]
    pub fn set_closable(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter, js_name = "excludedFromShownWindowsMenu")]
    pub fn excluded_from_shown_windows_menu(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter, js_name = "excludedFromShownWindowsMenu")]
    pub fn set_excluded_from_shown_windows_menu(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter, js_name = "fullScreenable")]
    pub fn full_screenable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter, js_name = "fullScreenable")]
    pub fn set_full_screenable(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter)] // readonly
    pub fn id(this: &BrowserWindow) -> u32;

    #[wasm_bindgen(method, getter)]
    pub fn maximizable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter)]
    pub fn set_maximizable(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter)]
    pub fn minimizable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter)]
    pub fn set_minimizable(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter)]
    pub fn movable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter)]
    pub fn set_movable(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter)]
    pub fn resizable(this: &BrowserWindow) -> bool;

    #[wasm_bindgen(method, setter)]
    pub fn set_resizable(this: &BrowserWindow, value: bool);

    #[wasm_bindgen(method, getter, js_name = "webContents")] // readonly
    pub fn web_contents(this: &BrowserWindow) -> WebContents;
}