forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github-electron-main.d.ts
270 lines (248 loc) · 8.93 KB
/
github-electron-main.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
// Type definitions for the Electron 0.25.2 main process
// Project: http://electron.atom.io/
// Definitions by: jedmao <https://github.com/jedmao/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="./github-electron.d.ts" />
declare module GitHubElectron {
interface ContentTracing {
/**
* Get a set of category groups. The category groups can change as new code paths are reached.
* @param callback Called once all child processes have acked to the getCategories request.
*/
getCategories(callback: (categoryGroups: any[]) => void): void;
/**
* Start recording on all processes. Recording begins immediately locally, and asynchronously
* on child processes as soon as they receive the EnableRecording request.
* @param categoryFilter A filter to control what category groups should be traced.
* A filter can have an optional "-" prefix to exclude category groups that contain
* a matching category. Having both included and excluded category patterns in the
* same list would not be supported.
* @param options controls what kind of tracing is enabled, it could be a OR-ed
* combination of tracing.DEFAULT_OPTIONS, tracing.ENABLE_SYSTRACE, tracing.ENABLE_SAMPLING
* and tracing.RECORD_CONTINUOUSLY.
* @param callback Called once all child processes have acked to the startRecording request.
*/
startRecording(categoryFilter: string, options: number, callback: Function): void;
/**
* Stop recording on all processes. Child processes typically are caching trace data and
* only rarely flush and send trace data back to the main process. That is because it may
* be an expensive operation to send the trace data over IPC, and we would like to avoid
* much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all
* child processes to flush any pending trace data.
* @param resultFilePath Trace data will be written into this file if it is not empty,
* or into a temporary file.
* @param callback Called once all child processes have acked to the stopRecording request.
*/
stopRecording(resultFilePath: string, callback:
/**
* @param filePath A file that contains the traced data.
*/
(filePath: string) => void
): void;
/**
* Start monitoring on all processes. Monitoring begins immediately locally, and asynchronously
* on child processes as soon as they receive the startMonitoring request.
* @param callback Called once all child processes have acked to the startMonitoring request.
*/
startMonitoring(categoryFilter: string, options: number, callback: Function): void;
/**
* Stop monitoring on all processes.
* @param callback Called once all child processes have acked to the stopMonitoring request.
*/
stopMonitoring(callback: Function): void;
/**
* Get the current monitoring traced data. Child processes typically are caching trace data
* and only rarely flush and send trace data back to the main process. That is because it may
* be an expensive operation to send the trace data over IPC, and we would like to avoid much
* runtime overhead of tracing. So, to end tracing, we must asynchronously ask all child
* processes to flush any pending trace data.
* @param callback Called once all child processes have acked to the captureMonitoringSnapshot request.
*/
captureMonitoringSnapshot(resultFilePath: string, callback:
/**
* @param filePath A file that contains the traced data
* @returns {}
*/
(filePath: string) => void
): void;
/**
* Get the maximum across processes of trace buffer percent full state.
* @param callback Called when the TraceBufferUsage value is determined.
*/
getTraceBufferUsage(callback: Function): void;
/**
* @param callback Called every time the given event occurs on any process.
*/
setWatchEvent(categoryName: string, eventName: string, callback: Function): void;
/**
* Cancel the watch event. If tracing is enabled, this may race with the watch event callback.
*/
cancelWatchEvent(): void;
DEFAULT_OPTIONS: number;
ENABLE_SYSTRACE: number;
ENABLE_SAMPLING: number;
RECORD_CONTINUOUSLY: number;
}
interface Dialog {
/**
* @param callback If supplied, the API call will be asynchronous.
* @returns On success, returns an array of file paths chosen by the user,
* otherwise returns undefined.
*/
showOpenDialog: typeof GitHubElectron.Dialog.showOpenDialog;
/**
* @param callback If supplied, the API call will be asynchronous.
* @returns On success, returns the path of file chosen by the user, otherwise
* returns undefined.
*/
showSaveDialog: typeof GitHubElectron.Dialog.showSaveDialog;
/**
* Shows a message box. It will block until the message box is closed. It returns .
* @param callback If supplied, the API call will be asynchronous.
* @returns The index of the clicked button.
*/
showMessageBox: typeof GitHubElectron.Dialog.showMessageBox;
/**
* Runs a modal dialog that shows an error message. This API can be called safely
* before the ready event of app module emits, it is usually used to report errors
* in early stage of startup.
*/
showErrorBox(title: string, content: string): void;
}
interface GlobalShortcut {
/**
* Registers a global shortcut of accelerator.
* @param accelerator Represents a keyboard shortcut. It can contain modifiers
* and key codes, combined by the "+" character.
* @param callback Called when the registered shortcut is pressed by the user.
* @returns {}
*/
register(accelerator: string, callback: Function): void;
/**
* @param accelerator Represents a keyboard shortcut. It can contain modifiers
* and key codes, combined by the "+" character.
* @returns Whether the accelerator is registered.
*/
isRegistered(accelerator: string): boolean;
/**
* Unregisters the global shortcut of keycode.
* @param accelerator Represents a keyboard shortcut. It can contain modifiers
* and key codes, combined by the "+" character.
*/
unregister(accelerator: string): void;
/**
* Unregisters all the global shortcuts.
*/
unregisterAll(): void;
}
class RequestFileJob {
/**
* Create a request job which would query a file of path and set corresponding mime types.
*/
constructor(path: string);
}
class RequestStringJob {
/**
* Create a request job which sends a string as response.
*/
constructor(options?: {
/**
* Default is "text/plain".
*/
mimeType?: string;
/**
* Default is "UTF-8".
*/
charset?: string;
data?: string;
});
}
class RequestBufferJob {
/**
* Create a request job which accepts a buffer and sends a string as response.
*/
constructor(options?: {
/**
* Default is "application/octet-stream".
*/
mimeType?: string;
/**
* Default is "UTF-8".
*/
encoding?: string;
data?: Buffer;
});
}
interface Protocol {
registerProtocol(scheme: string, handler: (request: any) => void): void;
unregisterProtocol(scheme: string): void;
isHandledProtocol(scheme: string): boolean;
interceptProtocol(scheme: string, handler: (request: any) => void): void;
uninterceptProtocol(scheme: string): void;
RequestFileJob: typeof RequestFileJob;
RequestStringJob: typeof RequestStringJob;
RequestBufferJob: typeof RequestBufferJob;
}
}
declare module 'app' {
var _app: GitHubElectron.App;
export = _app;
}
declare module 'auto-updater' {
var _autoUpdater: GitHubElectron.AutoUpdater;
export = _autoUpdater;
}
declare module 'browser-window' {
var BrowserWindow: typeof GitHubElectron.BrowserWindow;
export = BrowserWindow;
}
declare module 'content-tracing' {
var contentTracing: GitHubElectron.ContentTracing
export = contentTracing;
}
declare module 'dialog' {
var dialog: GitHubElectron.Dialog
export = dialog;
}
declare module 'global-shortcut' {
var globalShortcut: GitHubElectron.GlobalShortcut;
export = globalShortcut;
}
declare module 'ipc' {
var ipc: NodeJS.EventEmitter;
export = ipc;
}
declare module 'menu' {
var Menu: typeof GitHubElectron.Menu;
export = Menu;
}
declare module 'menu-item' {
var MenuItem: typeof GitHubElectron.MenuItem;
export = MenuItem;
}
declare module 'power-monitor' {
var powerMonitor: NodeJS.EventEmitter;
export = powerMonitor;
}
declare module 'protocol' {
var protocol: GitHubElectron.Protocol;
export = protocol;
}
declare module 'tray' {
var Tray: typeof GitHubElectron.Tray;
export = Tray;
}
interface NodeRequireFunction {
(id: 'app'): GitHubElectron.App
(id: 'auto-updater'): GitHubElectron.AutoUpdater
(id: 'browser-window'): typeof GitHubElectron.BrowserWindow
(id: 'content-tracing'): GitHubElectron.ContentTracing
(id: 'dialog'): GitHubElectron.Dialog
(id: 'global-shortcut'): GitHubElectron.GlobalShortcut
(id: 'ipc'): NodeJS.EventEmitter
(id: 'menu'): typeof GitHubElectron.Menu
(id: 'menu-item'): typeof GitHubElectron.MenuItem
(id: 'power-monitor'): NodeJS.EventEmitter
(id: 'protocol'): GitHubElectron.Protocol
(id: 'tray'): typeof GitHubElectron.Tray
}