-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.d.ts
353 lines (351 loc) · 8.78 KB
/
index.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
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
/**
* Struct to store process information of the window
*/
export interface IconInfo {
data: string
height: number
width: number
}
/**
* Struct to store process information of the window
*/
export interface ProcessInfo {
processId: number
path: string
name: string
execName: string
}
/**
* Struct to store usage data of the window
*/
export interface UsageInfo {
memory: number
}
/**
* Struct to store position and size of the window
*/
export interface WindowPosition {
x: number
y: number
width: number
height: number
isFullScreen: boolean
}
/**
* Retrieve information the about currently active window.
* Returns an object of `WindowInfo`.
*
* # Example
*
* ## Javascript example
*
* ```javascript
* const { activeWindow } = require('@miniben90/x-win');
*
* const currentWindow = activeWindow();
* console.log(currentWindow);
* ```
*
* ## Typescript example
*
* ```typescript
* import { activeWindow } from '@miniben90/x-win';
*
* const currentWindow = activeWindow();
* console.log(currentWindow);
* ```
*
* # Information about Electron
*
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
*/
export declare function activeWindow(): WindowInfo
/**
* Retrieve information about the currently active window as a promise.
* Returns an object of `WindowInfo`.
*
* # Example
*
* ## Javascript example
*
* ```javascript
* activeWindowAsync()
* .then(currentWindow => {
* console.log(currentWindow);
* });
* ```
*
* ## Typescript example
*
* ```typescript
* import { activeWindowAsync } from '@miniben90/x-win';
*
* activeWindowAsync()
* .then(currentWindow => {
* console.log(currentWindow);
* });
* ```
*
* # Information about Electron
*
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
*/
export declare function activeWindowAsync(): Promise<WindowInfo>
/**
* Retrieve information about the currently open windows.
* Returns an array of `WindowInfo`, each containing details about a specific open window.
*
* # Example
*
* ## Javascript example
*
* ```javascript
* const { openWindows } = require('@miniben90/x-win');
*
* const windows = openWindows();
* for (let i = 0; i < windows.length; i++) {
* console.log(i, windows[i]);
* }
* ```
*
* ## Typescript Example
*
* ```typescript
* import { openWindows } from '@miniben90/x-win';
*
* const windows = openWindows();
* for (let i = 0; i < windows.length; i++) {
* console.log(i, windows[i]);
* }
* ```
*
* # Information about Electron
*
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
*/
export declare function openWindows(): Array<WindowInfo>
/**
* Retrieve information about the currently open windows as a promise.
* Returns an array of `WindowInfo`, each containing details about a specific open window.
*
* # Example
*
* ## Javascript example
*
* ```javascript
* const { openWindowsAsync } = resuire('@miniben90/x-win');
*
* openWindowsAsync()
* .then(windows => {
* for (let i = 0; i < windows.length; i++) {
* console.log(i, windows[i]);
* }
* });
* ```
*
* ## Typescript example
*
* ```typescript
* import { openWindowsAsync } from '@miniben90/x-win';
*
* openWindowsAsync()
* .then(windows => {
* for (let i = 0; i < windows.length; i++) {
* console.log(i, windows[i]);
* }
* });
* ```
*
* # Information about Electron
*
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
*/
export declare function openWindowsAsync(): Promise<Array<WindowInfo>>
/**
* Subscribe an observer thread to monitor changes in the active window.
* @param {function} callback - Callback function that returns the active window when it changes
* @param {number} [interval=100] - Interval between checks for changes in the active window (default: 100ms)
*
* # Example
*
* ## Javascript example
*
* ```javascript
* const { subscribeActiveWindow, unsubscribeAllActiveWindow } = require('@miniben90/x-win');
*
* const a = subscribeActiveWindow((info) => {
* t.log(a, info);
* });
* const b = subscribeActiveWindow((info) => {
* t.log(b, info);
* });
* const c = subscribeActiveWindow((info) => {
* t.log(c, info);
* });
* const d = subscribeActiveWindow((info) => {
* t.log(c, info);
* },500);// sleep interval: 500ms
*
* unsubscribeAllActiveWindow();
* ```
*
* ## Typescript example
*
* ```typescript
* import { subscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
*
* const a = subscribeActiveWindow((info) => {
* t.log(a, info);
* });
* const b = subscribeActiveWindow((info) => {
* t.log(b, info);
* });
* const c = subscribeActiveWindow((info) => {
* t.log(c, info);
* });
* const d = subscribeActiveWindow((info) => {
* t.log(c, info);
* },500);// sleep interval: 500ms
*
* unsubscribeAllActiveWindow();
* ```
*
*/
export declare function subscribeActiveWindow(callback: (info: WindowInfo) => void, interval?: number): number
/**
* Terminate and unsubscribe a specific observer using their ID.
*
* # Example
*
* ## Javascript example
*
* ```javascript
* const { subscribeActiveWindow, unsubscribeActiveWindow } = require('@miniben90/x-win');
*
* const a = subscribeActiveWindow((info) => {
* t.log(a, info);
* });
* const b = subscribeActiveWindow((info) => {
* t.log(b, info);
* });
* const c = subscribeActiveWindow((info) => {
* t.log(c, info);
* });
*
* unsubscribeActiveWindow(a);
* unsubscribeActiveWindow(b);
* unsubscribeActiveWindow(c);
* ```
*
* ## Typescript example
*
* ```typescript
* import { subscribeActiveWindow, unsubscribeActiveWindow } from '@miniben90/x-win';
*
* const a = subscribeActiveWindow((info) => {
* t.log(a, info);
* });
* const b = subscribeActiveWindow((info) => {
* t.log(b, info);
* });
* const c = subscribeActiveWindow((info) => {
* t.log(c, info);
* });
*
* unsubscribeActiveWindow(a);
* unsubscribeActiveWindow(b);
* unsubscribeActiveWindow(c);
* ```
*/
export declare function unsubscribeActiveWindow(threadId: number): void
/**
* Terminate and unsubscribe all observer threads monitoring changes in the active window.
*
* # Example
*
* ## Javascript example
*
* ```javascript
* const { subscribeActiveWindow, unsubscribeAllActiveWindow } = require('@miniben90/x-win');
*
* const a = subscribeActiveWindow((info) => {
* t.log(a, info);
* });
* const b = subscribeActiveWindow((info) => {
* t.log(b, info);
* });
* const c = subscribeActiveWindow((info) => {
* t.log(c, info);
* });
*
* unsubscribeAllActiveWindow();
* ```
*
* ## Typescript example
*
* ```typescript
* import { subscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
*
* const a = subscribeActiveWindow((info) => {
* t.log(a, info);
* });
* const b = subscribeActiveWindow((info) => {
* t.log(b, info);
* });
* const c = subscribeActiveWindow((info) => {
* t.log(c, info);
* });
*
* unsubscribeAllActiveWindow();
* ```
*/
export declare function unsubscribeAllActiveWindow(): void
/**
* Install "@mininben90/x-win" Gnome extension required for Linux using Gnome > 41.
* This function will write extension files needed to correctly detect working windows with Wayland desktop environment.
* **Restart session will be require to install the gnome extension.**
*/
export declare function installExtension(): boolean
/**
* Uninstall "@mininben90/x-win" Gnome extension.
* This function will disable and remove extension files.
* **Restart session will be require to remove the gnome extension.**
*/
export declare function uninstallExtension(): boolean
/**
* Enable Gnome extensions required for Linux using Gnome > 41.
* This function will enable extension needed to correctly detect working windows with Wayland desktop environment.
*/
export declare function enableExtension(): boolean
/**
* Disable Gnome extensions required for Linux using Gnome > 41.
* This function will disable extension needed to correctly detect working windows with Wayland desktop environment.
*/
export declare function disableExtension(): boolean
/**
* Struct to store all informations of the window
*/
export declare class WindowInfo {
id: number
os: string
title: string
position: WindowPosition
info: ProcessInfo
usage: UsageInfo
constructor(id: number, os: string, title: string, position: WindowPosition, info: ProcessInfo, usage: UsageInfo)
/**
* Funciton who help to recover icon of application and will return `IconInfo`.
*/
getIcon(): IconInfo
/**
* Promise funciton who help to recover icon of application and will return `IconInfo`.
*/
getIconAsync(): Promise<IconInfo>
/**
* Getter to recover browser url
*/
get url(): string
}