This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
electron.d.ts
9649 lines (9233 loc) · 394 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 4.0.0-beta.10
// Project: http://electronjs.org/
// 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;
altKey?: boolean;
}
interface CommonInterface {
clipboard: Clipboard;
crashReporter: CrashReporter;
nativeImage: typeof NativeImage;
screen: Screen;
shell: Shell;
}
interface MainInterface extends CommonInterface {
app: App;
autoUpdater: AutoUpdater;
BrowserView: typeof BrowserView;
BrowserWindow: typeof BrowserWindow;
ClientRequest: typeof ClientRequest;
contentTracing: ContentTracing;
Cookies: typeof Cookies;
Debugger: typeof Debugger;
dialog: Dialog;
DownloadItem: typeof DownloadItem;
globalShortcut: GlobalShortcut;
inAppPurchase: InAppPurchase;
IncomingMessage: typeof IncomingMessage;
ipcMain: IpcMain;
Menu: typeof Menu;
MenuItem: typeof MenuItem;
net: Net;
netLog: NetLog;
Notification: typeof Notification;
powerMonitor: PowerMonitor;
powerSaveBlocker: PowerSaveBlocker;
protocol: Protocol;
session: typeof Session;
systemPreferences: SystemPreferences;
TouchBar: typeof TouchBar;
Tray: typeof Tray;
webContents: typeof WebContents;
WebRequest: typeof WebRequest;
}
interface RendererInterface extends CommonInterface {
BrowserWindowProxy: typeof BrowserWindowProxy;
desktopCapturer: DesktopCapturer;
ipcRenderer: IpcRenderer;
remote: Remote;
webFrame: WebFrame;
webviewTag: WebviewTag;
}
interface AllElectron extends MainInterface, RendererInterface {}
const app: App;
const autoUpdater: AutoUpdater;
const clipboard: Clipboard;
const contentTracing: ContentTracing;
const crashReporter: CrashReporter;
const desktopCapturer: DesktopCapturer;
const dialog: Dialog;
const globalShortcut: GlobalShortcut;
const inAppPurchase: InAppPurchase;
const ipcMain: IpcMain;
const ipcRenderer: IpcRenderer;
type nativeImage = NativeImage;
const nativeImage: typeof NativeImage;
const net: Net;
const netLog: NetLog;
const powerMonitor: PowerMonitor;
const powerSaveBlocker: PowerSaveBlocker;
const protocol: Protocol;
const remote: Remote;
const screen: Screen;
type session = Session;
const session: typeof Session;
const shell: Shell;
const systemPreferences: SystemPreferences;
type webContents = WebContents;
const webContents: typeof WebContents;
const webFrame: WebFrame;
const webviewTag: WebviewTag;
interface App extends EventEmitter {
// Docs: http://electronjs.org/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 during Handoff after an activity from this device was successfully
* resumed on another one.
*/
on(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
once(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
addListener(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
removeListener(event: 'activity-was-continued', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => 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. Note: On Windows, this event will not be
* emitted if the app is closed due to a shutdown/restart of the system or a user
* logout.
*/
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 during Handoff when an activity from a different device fails to be
* resumed.
*/
on(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
once(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
addListener(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => void): this;
removeListener(event: 'continue-activity-error', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* A string with the error's localized description.
*/
error: string) => 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 clicks the native macOS new tab button. The new tab button
* is only visible if the current BrowserWindow has a tabbingIdentifier
*/
on(event: 'new-window-for-tab', listener: (event: Event) => void): this;
once(event: 'new-window-for-tab', listener: (event: Event) => void): this;
addListener(event: 'new-window-for-tab', listener: (event: Event) => void): this;
removeListener(event: 'new-window-for-tab', listener: (event: Event) => 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. Note: On Windows, this event will not
* be emitted if the app is closed due to a shutdown/restart of the system or a
* user logout.
*/
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 remote.getGlobal() is called in the renderer process of
* webContents. Calling event.preventDefault() will prevent the global from being
* returned. Custom value can be returned by setting event.returnValue.
*/
on(event: 'remote-get-global', listener: (event: Event,
webContents: WebContents,
globalName: string) => void): this;
once(event: 'remote-get-global', listener: (event: Event,
webContents: WebContents,
globalName: string) => void): this;
addListener(event: 'remote-get-global', listener: (event: Event,
webContents: WebContents,
globalName: string) => void): this;
removeListener(event: 'remote-get-global', listener: (event: Event,
webContents: WebContents,
globalName: string) => void): this;
/**
* Emitted when remote.require() is called in the renderer process of webContents.
* Calling event.preventDefault() will prevent the module from being returned.
* Custom value can be returned by setting event.returnValue.
*/
on(event: 'remote-require', listener: (event: Event,
webContents: WebContents,
moduleName: string) => void): this;
once(event: 'remote-require', listener: (event: Event,
webContents: WebContents,
moduleName: string) => void): this;
addListener(event: 'remote-require', listener: (event: Event,
webContents: WebContents,
moduleName: string) => void): this;
removeListener(event: 'remote-require', listener: (event: Event,
webContents: WebContents,
moduleName: string) => void): this;
/**
* This event will be emitted inside the primary instance of your application 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. This event is guaranteed to be emitted after the ready event of
* app gets emitted.
*/
on(event: 'second-instance', listener: (event: Event,
/**
* An array of the second instance's command line arguments
*/
argv: string[],
/**
* The second instance's working directory
*/
workingDirectory: string) => void): this;
once(event: 'second-instance', listener: (event: Event,
/**
* An array of the second instance's command line arguments
*/
argv: string[],
/**
* The second instance's working directory
*/
workingDirectory: string) => void): this;
addListener(event: 'second-instance', listener: (event: Event,
/**
* An array of the second instance's command line arguments
*/
argv: string[],
/**
* The second instance's working directory
*/
workingDirectory: string) => void): this;
removeListener(event: 'second-instance', listener: (event: Event,
/**
* An array of the second instance's command line arguments
*/
argv: string[],
/**
* The second instance's working directory
*/
workingDirectory: string) => 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 Electron has created a new session.
*/
on(event: 'session-created', listener: (session: Session) => void): this;
once(event: 'session-created', listener: (session: Session) => void): this;
addListener(event: 'session-created', listener: (session: Session) => void): this;
removeListener(event: 'session-created', listener: (session: Session) => void): this;
/**
* Emitted when Handoff is about to be resumed on another device. If you need to
* update the state to be transferred, you should call event.preventDefault()
* immediately, construct a new userInfo dictionary and call
* app.updateCurrentActiviy() in a timely manner. Otherwise the operation will fail
* and continue-activity-error will be called.
*/
on(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
once(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
addListener(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => void): this;
removeListener(event: 'update-activity-state', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string,
/**
* Contains app-specific state stored by the activity.
*/
userInfo: any) => 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 during Handoff before an activity from a different device wants to be
* resumed. You should call event.preventDefault() if you want to handle this
* event.
*/
on(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
once(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
addListener(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => void): this;
removeListener(event: 'will-continue-activity', listener: (event: Event,
/**
* A string identifying the activity. Maps to .
*/
type: string) => 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 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. Note: On
* Windows, this event will not be emitted if the app is closed due to a
* shutdown/restart of the system or a user logout.
*/
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;
/**
* By default, Chromium disables 3D APIs (e.g. WebGL) until restart on a per domain
* basis if the GPU processes crashes too frequently. This function disables that
* behaviour. This method can only be called before app is ready.
*/
disableDomainBlockingFor3DAPIs(): void;
/**
* Disables hardware acceleration for current app. This method can only be called
* before app is ready.
*/
disableHardwareAcceleration(): void;
/**
* Enables mixed sandbox mode on the app. This method can only be called before app
* is ready.
*/
enableMixedSandbox(): void;
/**
* Enables full sandbox mode on the app. This method can only be called before app
* is ready.
*/
enableSandbox(): 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;
getAppMetrics(): ProcessMetric[];
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, 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, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void;
getGPUFeatureStatus(): GPUFeatureStatus;
/**
* For infoType equal to complete: Promise is fulfilled with Object containing all
* the GPU Information as in chromium's GPUInfo object. This includes the version
* and driver information that's shown on chrome://gpu page. For infoType equal to
* basic: Promise is fulfilled with Object containing fewer attributes than when
* requested with complete. Here's an example of basic response: Using basic should
* be preferred if only basic information like vendorId or driverId is needed.
*/
getGPUInfo(infoType: string): Promise<any>;
getJumpListSettings(): JumpListSettings;
/**
* To set the locale, you'll want to use a command line switch at app startup,
* which may be found here. 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.
*/
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;
/**
* This method returns whether or not this instance of your app is currently
* holding the single instance lock. You can request the lock with
* app.requestSingleInstanceLock() and release with app.releaseSingleInstanceLock()
*/
hasSingleInstanceLock(): boolean;
/**
* 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;
/**
* Invalidates the current Handoff user activity.
*/
invalidateCurrentActivity(type: string): 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;
isInApplicationsFolder(): boolean;
isReady(): boolean;
isUnityRunning(): boolean;
/**
* No confirmation dialog will be presented by default, if you wish to allow the
* user to confirm the operation you may do so using the dialog API. NOTE: This
* method throws errors if anything other than the user causes the move to fail.
* For instance if the user cancels the authorization dialog this method returns
* false. If we fail to perform the copy then this method will throw an error. The
* message in the error should be informative and tell you exactly what went wrong
*/
moveToApplicationsFolder(): 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 requestSingleInstanceLock. This will
* allow multiple instances of the application to once again run side by side.
*/
releaseSingleInstanceLock(): 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;
/**
* 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. The return value of this method indicates whether or not this instance
* of your application successfully obtained the lock. If it failed to obtain the
* lock you can assume that another instance of your application is already running
* with the lock and exit immediately. I.e. This method returns true if your
* process is the primary instance of your application and your app should continue
* loading. It returns false if your process should immediately quit as it has
* sent its parameters to another instance that has already acquired the lock. 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:
*/
requestSingleInstanceLock(): 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;
/**
* Manually enables Chrome's accessibility support, allowing to expose
* accessibility switch to users in application settings.
* https://www.chromium.org/developers/design-documents/accessibility for more
* details. Disabled by default. Note: Rendering accessibility tree can
* significantly affect the performance of your app. It should not be enabled by
* default.
*/
setAccessibilitySupportEnabled(enabled: boolean): 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:
*/
setLoginItemSettings(settings: Settings): 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;
/**
* Show the about panel with the values defined in the app's .plist file or with
* the options set via app.setAboutPanelOptions(options).
*/
showAboutPanel(): void;
/**
* Start accessing a security scoped resource. With this method Electron
* applications that are packaged for the Mac App Store may reach outside their
* sandbox to access files chosen by the user. See Apple's documentation for a
* description of how this system works.
*/
startAccessingSecurityScopedResource(bookmarkData: string): Function;
/**
* Updates the current activity if its type matches type, merging the entries from
* userInfo into its current userInfo dictionary.
*/
updateCurrentActivity(type: string, userInfo: any): void;
whenReady(): Promise<void>;
commandLine: CommandLine;
dock: Dock;
/**
* A Boolean property that returns true if the app is packaged, false otherwise.