This repository has been archived by the owner on Oct 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathelectron.d.ts
7781 lines (7407 loc) Β· 306 KB
/
electron.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
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Electron 1.6.12
// Project: http://electron.atom.io/
// Definitions by: The Electron Team <https://github.com/electron/electron>
// Definitions: https://github.com/electron/electron-typescript-definitions
/// <reference types="node" />
type GlobalEvent = Event;
declare namespace Electron {
class EventEmitter {
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
prependListener(event: string, listener: Function): this;
prependOnceListener(event: string, listener: Function): this;
eventNames(): string[];
}
class Accelerator extends String {
}
interface Event extends GlobalEvent {
preventDefault: () => void;
sender: WebContents;
returnValue: any;
ctrlkey?: boolean;
metaKey?: boolean;
shiftKey?: boolean;
}
interface CommonInterface {
clipboard: Electron.Clipboard;
crashReporter: Electron.CrashReporter;
nativeImage: typeof Electron.NativeImage;
screen: Electron.Screen;
shell: Electron.Shell;
}
interface MainInterface extends CommonInterface {
app: Electron.App;
autoUpdater: Electron.AutoUpdater;
BrowserView: typeof Electron.BrowserView;
BrowserWindow: typeof Electron.BrowserWindow;
ClientRequest: typeof Electron.ClientRequest;
contentTracing: Electron.ContentTracing;
Cookies: typeof Electron.Cookies;
Debugger: typeof Electron.Debugger;
dialog: Electron.Dialog;
DownloadItem: typeof Electron.DownloadItem;
globalShortcut: Electron.GlobalShortcut;
IncomingMessage: typeof Electron.IncomingMessage;
ipcMain: Electron.IpcMain;
Menu: typeof Electron.Menu;
MenuItem: typeof Electron.MenuItem;
net: Electron.Net;
powerMonitor: Electron.PowerMonitor;
powerSaveBlocker: Electron.PowerSaveBlocker;
protocol: Electron.Protocol;
session: typeof Electron.Session;
systemPreferences: Electron.SystemPreferences;
TouchBar: typeof Electron.TouchBar;
Tray: typeof Electron.Tray;
webContents: typeof Electron.WebContents;
WebRequest: typeof Electron.WebRequest;
}
interface RendererInterface extends CommonInterface {
BrowserWindowProxy: typeof Electron.BrowserWindowProxy;
desktopCapturer: Electron.DesktopCapturer;
ipcRenderer: Electron.IpcRenderer;
remote: Electron.Remote;
webFrame: Electron.WebFrame;
webviewTag: Electron.WebviewTag;
}
interface AllElectron {
app: Electron.App;
autoUpdater: Electron.AutoUpdater;
BrowserView: typeof Electron.BrowserView;
BrowserWindow: typeof Electron.BrowserWindow;
BrowserWindowProxy: typeof Electron.BrowserWindowProxy;
ClientRequest: typeof Electron.ClientRequest;
clipboard: Electron.Clipboard;
contentTracing: Electron.ContentTracing;
Cookies: typeof Electron.Cookies;
crashReporter: Electron.CrashReporter;
Debugger: typeof Electron.Debugger;
desktopCapturer: Electron.DesktopCapturer;
dialog: Electron.Dialog;
DownloadItem: typeof Electron.DownloadItem;
globalShortcut: Electron.GlobalShortcut;
IncomingMessage: typeof Electron.IncomingMessage;
ipcMain: Electron.IpcMain;
ipcRenderer: Electron.IpcRenderer;
Menu: typeof Electron.Menu;
MenuItem: typeof Electron.MenuItem;
nativeImage: typeof Electron.NativeImage;
net: Electron.Net;
powerMonitor: Electron.PowerMonitor;
powerSaveBlocker: Electron.PowerSaveBlocker;
protocol: Electron.Protocol;
remote: Electron.Remote;
screen: Electron.Screen;
session: typeof Electron.Session;
shell: Electron.Shell;
systemPreferences: Electron.SystemPreferences;
TouchBar: typeof Electron.TouchBar;
Tray: typeof Electron.Tray;
webContents: typeof Electron.WebContents;
webFrame: Electron.WebFrame;
WebRequest: typeof Electron.WebRequest;
webviewTag: Electron.WebviewTag;
}
interface App extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/app
/**
* Emitted when Chrome's accessibility support changes. This event fires when
* assistive technologies, such as screen readers, are enabled or disabled. See
* https://www.chromium.org/developers/design-documents/accessibility for more
* details.
*/
on(event: 'accessibility-support-changed', listener: (event: Event,
/**
* `true` when Chrome's accessibility support is enabled, `false` otherwise.
*/
accessibilitySupportEnabled: boolean) => void): this;
once(event: 'accessibility-support-changed', listener: (event: Event,
/**
* `true` when Chrome's accessibility support is enabled, `false` otherwise.
*/
accessibilitySupportEnabled: boolean) => void): this;
addListener(event: 'accessibility-support-changed', listener: (event: Event,
/**
* `true` when Chrome's accessibility support is enabled, `false` otherwise.
*/
accessibilitySupportEnabled: boolean) => void): this;
removeListener(event: 'accessibility-support-changed', listener: (event: Event,
/**
* `true` when Chrome's accessibility support is enabled, `false` otherwise.
*/
accessibilitySupportEnabled: boolean) => void): this;
/**
* Emitted when the application is activated. Various actions can trigger this
* event, such as launching the application for the first time, attempting to
* re-launch the application when it's already running, or clicking on the
* application's dock or taskbar icon.
*/
on(event: 'activate', listener: (event: Event,
hasVisibleWindows: boolean) => void): this;
once(event: 'activate', listener: (event: Event,
hasVisibleWindows: boolean) => void): this;
addListener(event: 'activate', listener: (event: Event,
hasVisibleWindows: boolean) => void): this;
removeListener(event: 'activate', listener: (event: Event,
hasVisibleWindows: boolean) => void): this;
/**
* Emitted before the application starts closing its windows. Calling
* event.preventDefault() will prevent the default behaviour, which is terminating
* the application. Note: If application quit was initiated by
* autoUpdater.quitAndInstall() then before-quit is emitted after emitting close
* event on all windows and closing them.
*/
on(event: 'before-quit', listener: (event: Event) => void): this;
once(event: 'before-quit', listener: (event: Event) => void): this;
addListener(event: 'before-quit', listener: (event: Event) => void): this;
removeListener(event: 'before-quit', listener: (event: Event) => void): this;
/**
* Emitted when a browserWindow gets blurred.
*/
on(event: 'browser-window-blur', listener: (event: Event,
window: BrowserWindow) => void): this;
once(event: 'browser-window-blur', listener: (event: Event,
window: BrowserWindow) => void): this;
addListener(event: 'browser-window-blur', listener: (event: Event,
window: BrowserWindow) => void): this;
removeListener(event: 'browser-window-blur', listener: (event: Event,
window: BrowserWindow) => void): this;
/**
* Emitted when a new browserWindow is created.
*/
on(event: 'browser-window-created', listener: (event: Event,
window: BrowserWindow) => void): this;
once(event: 'browser-window-created', listener: (event: Event,
window: BrowserWindow) => void): this;
addListener(event: 'browser-window-created', listener: (event: Event,
window: BrowserWindow) => void): this;
removeListener(event: 'browser-window-created', listener: (event: Event,
window: BrowserWindow) => void): this;
/**
* Emitted when a browserWindow gets focused.
*/
on(event: 'browser-window-focus', listener: (event: Event,
window: BrowserWindow) => void): this;
once(event: 'browser-window-focus', listener: (event: Event,
window: BrowserWindow) => void): this;
addListener(event: 'browser-window-focus', listener: (event: Event,
window: BrowserWindow) => void): this;
removeListener(event: 'browser-window-focus', listener: (event: Event,
window: BrowserWindow) => void): this;
/**
* Emitted when failed to verify the certificate for url, to trust the certificate
* you should prevent the default behavior with event.preventDefault() and call
* callback(true).
*/
on(event: 'certificate-error', listener: (event: Event,
webContents: WebContents,
url: string,
/**
* The error code
*/
error: string,
certificate: Certificate,
callback: (isTrusted: boolean) => void) => void): this;
once(event: 'certificate-error', listener: (event: Event,
webContents: WebContents,
url: string,
/**
* The error code
*/
error: string,
certificate: Certificate,
callback: (isTrusted: boolean) => void) => void): this;
addListener(event: 'certificate-error', listener: (event: Event,
webContents: WebContents,
url: string,
/**
* The error code
*/
error: string,
certificate: Certificate,
callback: (isTrusted: boolean) => void) => void): this;
removeListener(event: 'certificate-error', listener: (event: Event,
webContents: WebContents,
url: string,
/**
* The error code
*/
error: string,
certificate: Certificate,
callback: (isTrusted: boolean) => void) => void): this;
/**
* Emitted during Handoff when an activity from a different device wants to be
* resumed. You should call event.preventDefault() if you want to handle this
* event. A user activity can be continued only in an app that has the same
* developer Team ID as the activity's source app and that supports the activity's
* type. Supported activity types are specified in the app's Info.plist under the
* NSUserActivityTypes key.
*/
on(event: 'continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity on another device.
*/
userInfo: any) => void): this;
once(event: 'continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity on another device.
*/
userInfo: any) => void): this;
addListener(event: 'continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity on another device.
*/
userInfo: any) => void): this;
removeListener(event: 'continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity on another device.
*/
userInfo: any) => void): this;
/**
* Emitted when the gpu process crashes or is killed.
*/
on(event: 'gpu-process-crashed', listener: (event: Event,
killed: boolean) => void): this;
once(event: 'gpu-process-crashed', listener: (event: Event,
killed: boolean) => void): this;
addListener(event: 'gpu-process-crashed', listener: (event: Event,
killed: boolean) => void): this;
removeListener(event: 'gpu-process-crashed', listener: (event: Event,
killed: boolean) => void): this;
/**
* Emitted when webContents wants to do basic auth. The default behavior is to
* cancel all authentications, to override this you should prevent the default
* behavior with event.preventDefault() and call callback(username, password) with
* the credentials.
*/
on(event: 'login', listener: (event: Event,
webContents: WebContents,
request: Request,
authInfo: AuthInfo,
callback: (username: string, password: string) => void) => void): this;
once(event: 'login', listener: (event: Event,
webContents: WebContents,
request: Request,
authInfo: AuthInfo,
callback: (username: string, password: string) => void) => void): this;
addListener(event: 'login', listener: (event: Event,
webContents: WebContents,
request: Request,
authInfo: AuthInfo,
callback: (username: string, password: string) => void) => void): this;
removeListener(event: 'login', listener: (event: Event,
webContents: WebContents,
request: Request,
authInfo: AuthInfo,
callback: (username: string, password: string) => void) => void): this;
/**
* Emitted when the user wants to open a file with the application. The open-file
* event is usually emitted when the application is already open and the OS wants
* to reuse the application to open the file. open-file is also emitted when a file
* is dropped onto the dock and the application is not yet running. Make sure to
* listen for the open-file event very early in your application startup to handle
* this case (even before the ready event is emitted). You should call
* event.preventDefault() if you want to handle this event. On Windows, you have to
* parse process.argv (in the main process) to get the filepath.
*/
on(event: 'open-file', listener: (event: Event,
path: string) => void): this;
once(event: 'open-file', listener: (event: Event,
path: string) => void): this;
addListener(event: 'open-file', listener: (event: Event,
path: string) => void): this;
removeListener(event: 'open-file', listener: (event: Event,
path: string) => void): this;
/**
* Emitted when the user wants to open a URL with the application. Your
* application's Info.plist file must define the url scheme within the
* CFBundleURLTypes key, and set NSPrincipalClass to AtomApplication. You should
* call event.preventDefault() if you want to handle this event.
*/
on(event: 'open-url', listener: (event: Event,
url: string) => void): this;
once(event: 'open-url', listener: (event: Event,
url: string) => void): this;
addListener(event: 'open-url', listener: (event: Event,
url: string) => void): this;
removeListener(event: 'open-url', listener: (event: Event,
url: string) => void): this;
/**
* Emitted when the application is quitting.
*/
on(event: 'quit', listener: (event: Event,
exitCode: number) => void): this;
once(event: 'quit', listener: (event: Event,
exitCode: number) => void): this;
addListener(event: 'quit', listener: (event: Event,
exitCode: number) => void): this;
removeListener(event: 'quit', listener: (event: Event,
exitCode: number) => void): this;
/**
* Emitted when Electron has finished initializing. On macOS, launchInfo holds the
* userInfo of the NSUserNotification that was used to open the application, if it
* was launched from Notification Center. You can call app.isReady() to check if
* this event has already fired.
*/
on(event: 'ready', listener: (launchInfo: any) => void): this;
once(event: 'ready', listener: (launchInfo: any) => void): this;
addListener(event: 'ready', listener: (launchInfo: any) => void): this;
removeListener(event: 'ready', listener: (launchInfo: any) => void): this;
/**
* Emitted when a client certificate is requested. The url corresponds to the
* navigation entry requesting the client certificate and callback can be called
* with an entry filtered from the list. Using event.preventDefault() prevents the
* application from using the first certificate from the store.
*/
on(event: 'select-client-certificate', listener: (event: Event,
webContents: WebContents,
url: string,
certificateList: Certificate[],
callback: (certificate?: Certificate) => void) => void): this;
once(event: 'select-client-certificate', listener: (event: Event,
webContents: WebContents,
url: string,
certificateList: Certificate[],
callback: (certificate?: Certificate) => void) => void): this;
addListener(event: 'select-client-certificate', listener: (event: Event,
webContents: WebContents,
url: string,
certificateList: Certificate[],
callback: (certificate?: Certificate) => void) => void): this;
removeListener(event: 'select-client-certificate', listener: (event: Event,
webContents: WebContents,
url: string,
certificateList: Certificate[],
callback: (certificate?: Certificate) => void) => void): this;
/**
* Emitted when a new webContents is created.
*/
on(event: 'web-contents-created', listener: (event: Event,
webContents: WebContents) => void): this;
once(event: 'web-contents-created', listener: (event: Event,
webContents: WebContents) => void): this;
addListener(event: 'web-contents-created', listener: (event: Event,
webContents: WebContents) => void): this;
removeListener(event: 'web-contents-created', listener: (event: Event,
webContents: WebContents) => void): this;
/**
* Emitted when the application has finished basic startup. On Windows and Linux,
* the will-finish-launching event is the same as the ready event; on macOS, this
* event represents the applicationWillFinishLaunching notification of
* NSApplication. You would usually set up listeners for the open-file and open-url
* events here, and start the crash reporter and auto updater. In most cases, you
* should just do everything in the ready event handler.
*/
on(event: 'will-finish-launching', listener: Function): this;
once(event: 'will-finish-launching', listener: Function): this;
addListener(event: 'will-finish-launching', listener: Function): this;
removeListener(event: 'will-finish-launching', listener: Function): this;
/**
* Emitted when all windows have been closed and the application will quit. Calling
* event.preventDefault() will prevent the default behaviour, which is terminating
* the application. See the description of the window-all-closed event for the
* differences between the will-quit and window-all-closed events.
*/
on(event: 'will-quit', listener: (event: Event) => void): this;
once(event: 'will-quit', listener: (event: Event) => void): this;
addListener(event: 'will-quit', listener: (event: Event) => void): this;
removeListener(event: 'will-quit', listener: (event: Event) => void): this;
/**
* Emitted when all windows have been closed. If you do not subscribe to this event
* and all windows are closed, the default behavior is to quit the app; however, if
* you subscribe, you control whether the app quits or not. If the user pressed Cmd
* + Q, or the developer called app.quit(), Electron will first try to close all
* the windows and then emit the will-quit event, and in this case the
* window-all-closed event would not be emitted.
*/
on(event: 'window-all-closed', listener: Function): this;
once(event: 'window-all-closed', listener: Function): this;
addListener(event: 'window-all-closed', listener: Function): this;
removeListener(event: 'window-all-closed', listener: Function): this;
/**
* Adds path to the recent documents list. This list is managed by the OS. On
* Windows you can visit the list from the task bar, and on macOS you can visit it
* from dock menu.
*/
addRecentDocument(path: string): void;
/**
* Clears the recent documents list.
*/
clearRecentDocuments(): void;
/**
* Disables hardware acceleration for current app. This method can only be called
* before app is ready.
*/
disableHardwareAcceleration(): void;
/**
* Exits immediately with exitCode. exitCode defaults to 0. All windows will be
* closed immediately without asking user and the before-quit and will-quit events
* will not be emitted.
*/
exit(exitCode?: number): void;
/**
* On Linux, focuses on the first visible window. On macOS, makes the application
* the active app. On Windows, focuses on the application's first window.
*/
focus(): void;
/**
* Returns ProcessMemoryInfo[]: Array of ProcessMemoryInfo objects that correspond
* to memory usage statistics of all the processes associated with the app.
*/
getAppMemoryInfo(): void;
getAppPath(): string;
getBadgeCount(): number;
getCurrentActivityType(): string;
/**
* Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
* and macOS, icons depend on the application associated with file mime type.
*/
getFileIcon(path: string, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void;
/**
* Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
* and macOS, icons depend on the application associated with file mime type.
*/
getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void;
getJumpListSettings(): JumpListSettings;
/**
* Note: When distributing your packaged app, you have to also ship the locales
* folder. Note: On Windows you have to call it after the ready events gets
* emitted.
*/
getLocale(): string;
/**
* If you provided path and args options to app.setLoginItemSettings then you need
* to pass the same arguments here for openAtLogin to be set correctly. Note: This
* API has no effect on MAS builds.
*/
getLoginItemSettings(options?: LoginItemSettingsOptions): LoginItemSettings;
/**
* Usually the name field of package.json is a short lowercased name, according to
* the npm modules spec. You should usually also specify a productName field, which
* is your application's full capitalized name, and which will be preferred over
* name by Electron.
*/
getName(): string;
/**
* You can request the following paths by the name:
*/
getPath(name: string): string;
getVersion(): string;
/**
* Hides all application windows without minimizing them.
*/
hide(): void;
/**
* Imports the certificate in pkcs12 format into the platform certificate store.
* callback is called with the result of import operation, a value of 0 indicates
* success while any other value indicates failure according to chromium
* net_error_list.
*/
importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void;
isAccessibilitySupportEnabled(): boolean;
/**
* This method checks if the current executable is the default handler for a
* protocol (aka URI scheme). If so, it will return true. Otherwise, it will return
* false. Note: On macOS, you can use this method to check if the app has been
* registered as the default protocol handler for a protocol. You can also verify
* this by checking ~/Library/Preferences/com.apple.LaunchServices.plist on the
* macOS machine. Please refer to Apple's documentation for details. The API uses
* the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
*/
isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
isReady(): boolean;
isUnityRunning(): boolean;
/**
* This method makes your application a Single Instance Application - instead of
* allowing multiple instances of your app to run, this will ensure that only a
* single instance of your app is running, and other instances signal this instance
* and exit. callback will be called with callback(argv, workingDirectory) when a
* second instance has been executed. argv is an Array of the second instance's
* command line arguments, and workingDirectory is its current working directory.
* Usually applications respond to this by making their primary window focused and
* non-minimized. The callback is guaranteed to be executed after the ready event
* of app gets emitted. This method returns false if your process is the primary
* instance of the application and your app should continue loading. And returns
* true if your process has sent its parameters to another instance, and you should
* immediately quit. On macOS the system enforces single instance automatically
* when users try to open a second instance of your app in Finder, and the
* open-file and open-url events will be emitted for that. However when users start
* your app in command line the system's single instance mechanism will be bypassed
* and you have to use this method to ensure single instance. An example of
* activating the window of primary instance when a second instance starts:
*/
makeSingleInstance(callback: (argv: string[], workingDirectory: string) => void): boolean;
/**
* Try to close all windows. The before-quit event will be emitted first. If all
* windows are successfully closed, the will-quit event will be emitted and by
* default the application will terminate. This method guarantees that all
* beforeunload and unload event handlers are correctly executed. It is possible
* that a window cancels the quitting by returning false in the beforeunload event
* handler.
*/
quit(): void;
/**
* Relaunches the app when current instance exits. By default the new instance will
* use the same working directory and command line arguments with current instance.
* When args is specified, the args will be passed as command line arguments
* instead. When execPath is specified, the execPath will be executed for relaunch
* instead of current app. Note that this method does not quit the app when
* executed, you have to call app.quit or app.exit after calling app.relaunch to
* make the app restart. When app.relaunch is called for multiple times, multiple
* instances will be started after current instance exited. An example of
* restarting current instance immediately and adding a new command line argument
* to the new instance:
*/
relaunch(options?: RelaunchOptions): void;
/**
* Releases all locks that were created by makeSingleInstance. This will allow
* multiple instances of the application to once again run side by side.
*/
releaseSingleInstance(): void;
/**
* This method checks if the current executable as the default handler for a
* protocol (aka URI scheme). If so, it will remove the app as the default handler.
*/
removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
/**
* Set the about panel options. This will override the values defined in the app's
* .plist file. See the Apple docs for more details.
*/
setAboutPanelOptions(options: AboutPanelOptionsOptions): void;
/**
* Changes the Application User Model ID to id.
*/
setAppUserModelId(id: string): void;
/**
* This method sets the current executable as the default handler for a protocol
* (aka URI scheme). It allows you to integrate your app deeper into the operating
* system. Once registered, all links with your-protocol:// will be opened with the
* current executable. The whole link, including protocol, will be passed to your
* application as a parameter. On Windows you can provide optional parameters path,
* the path to your executable, and args, an array of arguments to be passed to
* your executable when it launches. Note: On macOS, you can only register
* protocols that have been added to your app's info.plist, which can not be
* modified at runtime. You can however change the file with a simple text editor
* or script during build time. Please refer to Apple's documentation for details.
* The API uses the Windows Registry and LSSetDefaultHandlerForURLScheme
* internally.
*/
setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
/**
* Sets the counter badge for current app. Setting the count to 0 will hide the
* badge. On macOS it shows on the dock icon. On Linux it only works for Unity
* launcher, Note: Unity launcher requires the existence of a .desktop file to
* work, for more information please read Desktop Environment Integration.
*/
setBadgeCount(count: number): boolean;
/**
* Sets or removes a custom Jump List for the application, and returns one of the
* following strings: If categories is null the previously set custom Jump List (if
* any) will be replaced by the standard Jump List for the app (managed by
* Windows). Note: If a JumpListCategory object has neither the type nor the name
* property set then its type is assumed to be tasks. If the name property is set
* but the type property is omitted then the type is assumed to be custom. Note:
* Users can remove items from custom categories, and Windows will not allow a
* removed item to be added back into a custom category until after the next
* successful call to app.setJumpList(categories). Any attempt to re-add a removed
* item to a custom category earlier than that will result in the entire custom
* category being omitted from the Jump List. The list of removed items can be
* obtained using app.getJumpListSettings(). Here's a very simple example of
* creating a custom Jump List:
*/
setJumpList(categories: JumpListCategory[]): void;
/**
* Set the app's login item settings. To work with Electron's autoUpdater on
* Windows, which uses Squirrel, you'll want to set the launch path to Update.exe,
* and pass arguments that specify your application name. For example: Note: This
* API has no effect on MAS builds.
*/
setLoginItemSettings(settings: Settings, path?: string, args?: string[]): void;
/**
* Overrides the current application's name.
*/
setName(name: string): void;
/**
* Overrides the path to a special directory or file associated with name. If the
* path specifies a directory that does not exist, the directory will be created by
* this method. On failure an Error is thrown. You can only override paths of a
* name defined in app.getPath. By default, web pages' cookies and caches will be
* stored under the userData directory. If you want to change this location, you
* have to override the userData path before the ready event of the app module is
* emitted.
*/
setPath(name: string, path: string): void;
/**
* Creates an NSUserActivity and sets it as the current activity. The activity is
* eligible for Handoff to another device afterward.
*/
setUserActivity(type: string, userInfo: any, webpageURL?: string): void;
/**
* Adds tasks to the Tasks category of the JumpList on Windows. tasks is an array
* of Task objects. Note: If you'd like to customize the Jump List even more use
* app.setJumpList(categories) instead.
*/
setUserTasks(tasks: Task[]): boolean;
/**
* Shows application windows after they were hidden. Does not automatically focus
* them.
*/
show(): void;
commandLine: CommandLine;
dock: Dock;
}
interface AutoUpdater extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/auto-updater
/**
* Emitted when checking if an update has started.
*/
on(event: 'checking-for-update', listener: Function): this;
once(event: 'checking-for-update', listener: Function): this;
addListener(event: 'checking-for-update', listener: Function): this;
removeListener(event: 'checking-for-update', listener: Function): this;
/**
* Emitted when there is an error while updating.
*/
on(event: 'error', listener: (error: Error) => void): this;
once(event: 'error', listener: (error: Error) => void): this;
addListener(event: 'error', listener: (error: Error) => void): this;
removeListener(event: 'error', listener: (error: Error) => void): this;
/**
* Emitted when there is an available update. The update is downloaded
* automatically.
*/
on(event: 'update-available', listener: Function): this;
once(event: 'update-available', listener: Function): this;
addListener(event: 'update-available', listener: Function): this;
removeListener(event: 'update-available', listener: Function): this;
/**
* Emitted when an update has been downloaded. On Windows only releaseName is
* available.
*/
on(event: 'update-downloaded', listener: (event: Event,
releaseNotes: string,
releaseName: string,
releaseDate: Date,
updateURL: string) => void): this;
once(event: 'update-downloaded', listener: (event: Event,
releaseNotes: string,
releaseName: string,
releaseDate: Date,
updateURL: string) => void): this;
addListener(event: 'update-downloaded', listener: (event: Event,
releaseNotes: string,
releaseName: string,
releaseDate: Date,
updateURL: string) => void): this;
removeListener(event: 'update-downloaded', listener: (event: Event,
releaseNotes: string,
releaseName: string,
releaseDate: Date,
updateURL: string) => void): this;
/**
* Emitted when there is no available update.
*/
on(event: 'update-not-available', listener: Function): this;
once(event: 'update-not-available', listener: Function): this;
addListener(event: 'update-not-available', listener: Function): this;
removeListener(event: 'update-not-available', listener: Function): this;
/**
* Asks the server whether there is an update. You must call setFeedURL before
* using this API.
*/
checkForUpdates(): void;
getFeedURL(): string;
/**
* Restarts the app and installs the update after it has been downloaded. It should
* only be called after update-downloaded has been emitted. Note:
* autoUpdater.quitAndInstall() will close all application windows first and only
* emit before-quit event on app after that. This is different from the normal quit
* event sequence.
*/
quitAndInstall(): void;
/**
* Sets the url and initialize the auto updater.
*/
setFeedURL(url: string, requestHeaders?: any): void;
}
interface BluetoothDevice {
// Docs: http://electron.atom.io/docs/api/structures/bluetooth-device
deviceId: string;
deviceName: string;
}
class BrowserView extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/browser-view
constructor(options?: BrowserViewConstructorOptions);
setAutoResize(options: AutoResizeOptions): void;
setBackgroundColor(color: string): void;
/**
* Resizes and moves the view to the supplied bounds relative to the window.
*/
setBounds(bounds: Rectangle): void;
id: number;
webContents: WebContents;
}
class BrowserWindow extends EventEmitter {
// Docs: http://electron.atom.io/docs/api/browser-window
/**
* Emitted when an App Command is invoked. These are typically related to keyboard
* media keys or browser commands, as well as the "Back" button built into some
* mice on Windows. Commands are lowercased, underscores are replaced with hyphens,
* and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is
* emitted as browser-backward.
*/
on(event: 'app-command', listener: (event: Event,
command: string) => void): this;
once(event: 'app-command', listener: (event: Event,
command: string) => void): this;
addListener(event: 'app-command', listener: (event: Event,
command: string) => void): this;
removeListener(event: 'app-command', listener: (event: Event,
command: string) => void): this;
/**
* Emitted when the window loses focus.
*/
on(event: 'blur', listener: Function): this;
once(event: 'blur', listener: Function): this;
addListener(event: 'blur', listener: Function): this;
removeListener(event: 'blur', listener: Function): this;
/**
* Emitted when the window is going to be closed. It's emitted before the
* beforeunload and unload event of the DOM. Calling event.preventDefault() will
* cancel the close. Usually you would want to use the beforeunload handler to
* decide whether the window should be closed, which will also be called when the
* window is reloaded. In Electron, returning any value other than undefined would
* cancel the close. For example:
*/
on(event: 'close', listener: (event: Event) => void): this;
once(event: 'close', listener: (event: Event) => void): this;
addListener(event: 'close', listener: (event: Event) => void): this;
removeListener(event: 'close', listener: (event: Event) => void): this;
/**
* Emitted when the window is closed. After you have received this event you should
* remove the reference to the window and avoid using it any more.
*/
on(event: 'closed', listener: Function): this;
once(event: 'closed', listener: Function): this;
addListener(event: 'closed', listener: Function): this;
removeListener(event: 'closed', listener: Function): this;
/**
* Emitted when the window enters a full-screen state.
*/
on(event: 'enter-full-screen', listener: Function): this;
once(event: 'enter-full-screen', listener: Function): this;
addListener(event: 'enter-full-screen', listener: Function): this;
removeListener(event: 'enter-full-screen', listener: Function): this;
/**
* Emitted when the window enters a full-screen state triggered by HTML API.
*/
on(event: 'enter-html-full-screen', listener: Function): this;
once(event: 'enter-html-full-screen', listener: Function): this;
addListener(event: 'enter-html-full-screen', listener: Function): this;
removeListener(event: 'enter-html-full-screen', listener: Function): this;
/**
* Emitted when the window gains focus.
*/
on(event: 'focus', listener: Function): this;
once(event: 'focus', listener: Function): this;
addListener(event: 'focus', listener: Function): this;
removeListener(event: 'focus', listener: Function): this;
/**
* Emitted when the window is hidden.
*/
on(event: 'hide', listener: Function): this;
once(event: 'hide', listener: Function): this;
addListener(event: 'hide', listener: Function): this;
removeListener(event: 'hide', listener: Function): this;
/**
* Emitted when the window leaves a full-screen state.
*/
on(event: 'leave-full-screen', listener: Function): this;
once(event: 'leave-full-screen', listener: Function): this;
addListener(event: 'leave-full-screen', listener: Function): this;
removeListener(event: 'leave-full-screen', listener: Function): this;
/**
* Emitted when the window leaves a full-screen state triggered by HTML API.
*/
on(event: 'leave-html-full-screen', listener: Function): this;
once(event: 'leave-html-full-screen', listener: Function): this;
addListener(event: 'leave-html-full-screen', listener: Function): this;
removeListener(event: 'leave-html-full-screen', listener: Function): this;
/**
* Emitted when window is maximized.
*/
on(event: 'maximize', listener: Function): this;
once(event: 'maximize', listener: Function): this;
addListener(event: 'maximize', listener: Function): this;
removeListener(event: 'maximize', listener: Function): this;
/**
* Emitted when the window is minimized.
*/
on(event: 'minimize', listener: Function): this;
once(event: 'minimize', listener: Function): this;
addListener(event: 'minimize', listener: Function): this;
removeListener(event: 'minimize', listener: Function): this;
/**
* Emitted when the window is being moved to a new position. Note: On macOS this
* event is just an alias of moved.
*/
on(event: 'move', listener: Function): this;
once(event: 'move', listener: Function): this;
addListener(event: 'move', listener: Function): this;
removeListener(event: 'move', listener: Function): this;
/**
* Emitted once when the window is moved to a new position.
*/
on(event: 'moved', listener: Function): this;
once(event: 'moved', listener: Function): this;
addListener(event: 'moved', listener: Function): this;
removeListener(event: 'moved', listener: Function): this;
/**
* Emitted when the document changed its title, calling event.preventDefault() will
* prevent the native window's title from changing.
*/
on(event: 'page-title-updated', listener: (event: Event,
title: string) => void): this;
once(event: 'page-title-updated', listener: (event: Event,
title: string) => void): this;
addListener(event: 'page-title-updated', listener: (event: Event,
title: string) => void): this;
removeListener(event: 'page-title-updated', listener: (event: Event,
title: string) => void): this;
/**
* Emitted when the web page has been rendered (while not being shown) and window
* can be displayed without a visual flash.
*/
on(event: 'ready-to-show', listener: Function): this;
once(event: 'ready-to-show', listener: Function): this;
addListener(event: 'ready-to-show', listener: Function): this;
removeListener(event: 'ready-to-show', listener: Function): this;
/**
* Emitted when the window is being resized.
*/
on(event: 'resize', listener: Function): this;
once(event: 'resize', listener: Function): this;
addListener(event: 'resize', listener: Function): this;
removeListener(event: 'resize', listener: Function): this;
/**
* Emitted when the unresponsive web page becomes responsive again.
*/
on(event: 'responsive', listener: Function): this;
once(event: 'responsive', listener: Function): this;
addListener(event: 'responsive', listener: Function): this;
removeListener(event: 'responsive', listener: Function): this;
/**
* Emitted when the window is restored from a minimized state.
*/
on(event: 'restore', listener: Function): this;
once(event: 'restore', listener: Function): this;
addListener(event: 'restore', listener: Function): this;
removeListener(event: 'restore', listener: Function): this;
/**
* Emitted when scroll wheel event phase has begun.
*/
on(event: 'scroll-touch-begin', listener: Function): this;
once(event: 'scroll-touch-begin', listener: Function): this;
addListener(event: 'scroll-touch-begin', listener: Function): this;
removeListener(event: 'scroll-touch-begin', listener: Function): this;
/**
* Emitted when scroll wheel event phase filed upon reaching the edge of element.
*/
on(event: 'scroll-touch-edge', listener: Function): this;
once(event: 'scroll-touch-edge', listener: Function): this;
addListener(event: 'scroll-touch-edge', listener: Function): this;
removeListener(event: 'scroll-touch-edge', listener: Function): this;
/**
* Emitted when scroll wheel event phase has ended.
*/
on(event: 'scroll-touch-end', listener: Function): this;
once(event: 'scroll-touch-end', listener: Function): this;
addListener(event: 'scroll-touch-end', listener: Function): this;
removeListener(event: 'scroll-touch-end', listener: Function): this;
/**
* Emitted when window session is going to end due to force shutdown or machine
* restart or session log off.
*/
on(event: 'session-end', listener: Function): this;
once(event: 'session-end', listener: Function): this;
addListener(event: 'session-end', listener: Function): this;
removeListener(event: 'session-end', listener: Function): this;
/**
* Emitted when the window opens a sheet.
*/
on(event: 'sheet-begin', listener: Function): this;
once(event: 'sheet-begin', listener: Function): this;
addListener(event: 'sheet-begin', listener: Function): this;
removeListener(event: 'sheet-begin', listener: Function): this;
/**
* Emitted when the window has closed a sheet.
*/
on(event: 'sheet-end', listener: Function): this;
once(event: 'sheet-end', listener: Function): this;
addListener(event: 'sheet-end', listener: Function): this;
removeListener(event: 'sheet-end', listener: Function): this;
/**
* Emitted when the window is shown.
*/
on(event: 'show', listener: Function): this;
once(event: 'show', listener: Function): this;
addListener(event: 'show', listener: Function): this;
removeListener(event: 'show', listener: Function): this;
/**
* Emitted on 3-finger swipe. Possible directions are up, right, down, left.