@miniben90/x-win 1.9.2 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -2
- package/README.md +30 -5
- package/index.d.ts +43 -26
- package/index.js +2 -1
- package/package.json +20 -13
package/LICENSE
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2023 BENKHADRA Hocine
|
|
4
|
-
|
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
7
5
|
in the Software without restriction, including without limitation the rights
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @miniben90/x-win
|
|
2
|
-
|
|
3
|
-
[](https://github.com/miniben-90/x-win/actions/workflows/ci-rs.yml)
|
|
3
|
+
[](https://github.com/miniben-90/x-win/actions/workflows/ci-napi.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@miniben90/x-win)
|
|
5
5
|

|
|
6
6
|

|
|
@@ -150,6 +150,31 @@ setTimeout(() => unsubscribeActiveWindow(c), 5000);
|
|
|
150
150
|
setTimeout(() => unsubscribeAllActiveWindow(), 10000);
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
### Get icon from `WindoInfo`
|
|
154
|
+
|
|
155
|
+
It is possible to get an icon from the `WindowInfo` class object using `getIcon` or `getIconAsync`, which will return an `IconInfo` struct.
|
|
156
|
+
The icon will be stored in `IconInfo.data` in base64 PNG format.
|
|
157
|
+
|
|
158
|
+
Example:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { activeWindow, type WindowInfo, type IconInfo } from '@miniben90/x-win';
|
|
162
|
+
|
|
163
|
+
const window: WindowInfo = activeWindow();
|
|
164
|
+
const iconInfo: IconInfo = window.getIcon();
|
|
165
|
+
console.log(console);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Response:
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
{
|
|
172
|
+
height: 32,
|
|
173
|
+
width: 32,
|
|
174
|
+
data: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAD/0lEQVR4Ae3gAZAkSZIkSRKLqpm7R0REZmZmVlVVVVV3d3d3d/fMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMdHd3d3dXV1VVVVVmZkZGRIS7m5kKz0xmV3d1d3dPz8zMzMxMovjvhfjvhfjvhfjvhXimW7+LvwJemhfNLvA6D34f/pp/H8Qz3fpdmH+dXeB1Hvw+/DX/dohneuq3Yf4Vth/0+px59JtC2+NfrTvz17rpw14GQDzT474W8yLoNq9l56aX55pHvQas7+DfJBboEV8mAPFMfupnmBdV2wOP/HvoUd8oAPFMfsIHm/9CevQ3C0A8kx//gea/kB7zrQIQz+THv7/5L6THfLsAxDP5ce9r/gvpsd8pAPFMftx7m/9Ceux3C0A8k//hPc1zsXkW869gkHgWieehF/teAYhn8t+/u3km29iQNjakDeZfRQJJSCCJEEjifnrx7xeAeCb//bsaINO0NK2ZcUpaMy2NDca8KISQoBRRQtQa1CJKiJBAoBf/QQGIZ/LfvbNtyEyGyQxj8nOrD+Kn73gU/x5vfdMTeYvZN9P3ha6KEkISeokfFoB4Jv/dO9pppjTrITlaTrz/rV/L+aPGv8epjcK3P+Qj2ZhXZl1QiggJveSPCkA8k//27W2bqZnlunFwNPEOT/xa/iP8xKM/io1FYd4XahUhoZf8cQGIZ/LfvK1tMzWzXDcOjibe4Ulfz3+En3jUR7AxL8xnhVpFSOilflIA4pn8N29t20zNLFeNg6OJd3jyN/If4Sce9WFszAvzWaEWESH0Uj8tAPFM/uu3tG2mZparxsGy8Q5P/kae2/c96IMoISJEiMvSkGkyzbs/41t4bj/xyA9lY16Yzwq1ipDQS/+sAMQz+a/ezDZMzSzXjYOjxts/8et5bj/2yA9jPiv0XVALl00NhjFZD8nbP/HreW4/+ZgPZ2NWmM+CWoMQ6GV+QQDimfyXb2AnTM0s142Do8bbPeEbeG4/8ZgPY2NWmM+CWgXANJn1kCzXyds87ut5bj/12A9nYx7M+6DWIAR6uV8TgHgm/+mr2IapJct1cnCUvM3jv53n9tOPfX825sG8D7oqAMbJrMfkaJW81T98O8/tZx77/mwsgnkf1CIihF7xjwQgnsl/9BJ/5eSlpzSrdXKwTN7qcd/Lc/u5F3tPFvNg3otaBMDUzHowy7V587//Hp7bz734e7IxC2a9qEWE9Nd61b97GQDxQrz8F/6BeS5//qmvJl6Il//CPzDP5c8/9dXE84f474X474X474X478U/AiZPaTD3cWUhAAAAAElFTkSuQmCC"
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
153
178
|
## Linux
|
|
154
179
|
|
|
155
180
|
Dependencies are required to be installed for development purposes.
|
|
@@ -158,11 +183,11 @@ Dependencies are required to be installed for development purposes.
|
|
|
158
183
|
sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxcb-shm0-dev pkg-config build-essential
|
|
159
184
|
```
|
|
160
185
|
|
|
161
|
-
> ⚠️**Warning
|
|
162
|
-
> libc.so.6 is needed
|
|
186
|
+
> ⚠️**Warning**<br />
|
|
187
|
+
> libc.so.6 is needed<br />
|
|
188
|
+
> ⚠️**Warning**<br />
|
|
163
189
|
> Recovery url is not available on linux
|
|
164
190
|
|
|
165
|
-
|
|
166
191
|
### GNOME (Wayland)
|
|
167
192
|
|
|
168
193
|
In order to recover data, you'll need to install and activate an extension designed for systems running GNOME version 41 or newer (as evaluation is disabled from this version onward).
|
package/index.d.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Struct to store
|
|
7
|
+
* Struct to store process information of the window
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
10
|
-
|
|
9
|
+
export interface IconInfo {
|
|
10
|
+
data: string
|
|
11
|
+
height: number
|
|
12
|
+
width: number
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Struct to store process information of the window
|
|
@@ -18,6 +20,12 @@ export interface ProcessInfo {
|
|
|
18
20
|
name: string
|
|
19
21
|
execName: string
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Struct to store usage data of the window
|
|
25
|
+
*/
|
|
26
|
+
export interface UsageInfo {
|
|
27
|
+
memory: number
|
|
28
|
+
}
|
|
21
29
|
/**
|
|
22
30
|
* Struct to store position and size of the window
|
|
23
31
|
*/
|
|
@@ -28,18 +36,6 @@ export interface WindowPosition {
|
|
|
28
36
|
height: number
|
|
29
37
|
isFullScreen: boolean
|
|
30
38
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Struct to store all informations of the window
|
|
33
|
-
*/
|
|
34
|
-
export interface WindowInfo {
|
|
35
|
-
id: number
|
|
36
|
-
os: string
|
|
37
|
-
title: string
|
|
38
|
-
position: WindowPosition
|
|
39
|
-
info: ProcessInfo
|
|
40
|
-
usage: UsageInfo
|
|
41
|
-
url: string
|
|
42
|
-
}
|
|
43
39
|
/**
|
|
44
40
|
* Retrieve information the about currently active window.
|
|
45
41
|
* Returns an object of `WindowInfo`.
|
|
@@ -68,7 +64,7 @@ export interface WindowInfo {
|
|
|
68
64
|
*
|
|
69
65
|
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
|
|
70
66
|
*/
|
|
71
|
-
export function activeWindow(): WindowInfo
|
|
67
|
+
export declare function activeWindow(): WindowInfo
|
|
72
68
|
/**
|
|
73
69
|
* Retrieve information about the currently active window as a promise.
|
|
74
70
|
* Returns an object of `WindowInfo`.
|
|
@@ -99,7 +95,7 @@ export function activeWindow(): WindowInfo
|
|
|
99
95
|
*
|
|
100
96
|
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
|
|
101
97
|
*/
|
|
102
|
-
export function activeWindowAsync(): Promise<WindowInfo>
|
|
98
|
+
export declare function activeWindowAsync(): Promise<WindowInfo>
|
|
103
99
|
/**
|
|
104
100
|
* Retrieve information about the currently open windows.
|
|
105
101
|
* Returns an array of `WindowInfo`, each containing details about a specific open window.
|
|
@@ -132,7 +128,7 @@ export function activeWindowAsync(): Promise<WindowInfo>
|
|
|
132
128
|
*
|
|
133
129
|
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
|
|
134
130
|
*/
|
|
135
|
-
export function openWindows(): Array<WindowInfo>
|
|
131
|
+
export declare function openWindows(): Array<WindowInfo>
|
|
136
132
|
/**
|
|
137
133
|
* Retrieve information about the currently open windows as a promise.
|
|
138
134
|
* Returns an array of `WindowInfo`, each containing details about a specific open window.
|
|
@@ -169,7 +165,7 @@ export function openWindows(): Array<WindowInfo>
|
|
|
169
165
|
*
|
|
170
166
|
* It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
|
|
171
167
|
*/
|
|
172
|
-
export function openWindowsAsync(): Promise<Array<WindowInfo>>
|
|
168
|
+
export declare function openWindowsAsync(): Promise<Array<WindowInfo>>
|
|
173
169
|
/**
|
|
174
170
|
* Subscribe an observer thread to monitor changes in the active window.
|
|
175
171
|
*
|
|
@@ -212,7 +208,7 @@ export function openWindowsAsync(): Promise<Array<WindowInfo>>
|
|
|
212
208
|
* ```
|
|
213
209
|
*
|
|
214
210
|
*/
|
|
215
|
-
export function subscribeActiveWindow(callback: (info: WindowInfo) => void): number
|
|
211
|
+
export declare function subscribeActiveWindow(callback: (info: WindowInfo) => void): number
|
|
216
212
|
/**
|
|
217
213
|
* Terminate and unsubscribe a specific observer using their ID.
|
|
218
214
|
*
|
|
@@ -258,7 +254,7 @@ export function subscribeActiveWindow(callback: (info: WindowInfo) => void): num
|
|
|
258
254
|
* unsubscribeActiveWindow(c);
|
|
259
255
|
* ```
|
|
260
256
|
*/
|
|
261
|
-
export function unsubscribeActiveWindow(threadId: number): void
|
|
257
|
+
export declare function unsubscribeActiveWindow(threadId: number): void
|
|
262
258
|
/**
|
|
263
259
|
* Terminate and unsubscribe all observer threads monitoring changes in the active window.
|
|
264
260
|
*
|
|
@@ -300,26 +296,47 @@ export function unsubscribeActiveWindow(threadId: number): void
|
|
|
300
296
|
* unsubscribeAllActiveWindow();
|
|
301
297
|
* ```
|
|
302
298
|
*/
|
|
303
|
-
export function unsubscribeAllActiveWindow(): void
|
|
299
|
+
export declare function unsubscribeAllActiveWindow(): void
|
|
304
300
|
/**
|
|
305
301
|
* Install Gnome extensions required for Linux using Gnome > 41.
|
|
306
302
|
* This function will write extension files needed to correctly detect working windows with Wayland desktop environment.
|
|
307
303
|
* Restart session will be require to install the gnome extension.
|
|
308
304
|
*/
|
|
309
|
-
export function installExtension(): boolean
|
|
305
|
+
export declare function installExtension(): boolean
|
|
310
306
|
/**
|
|
311
307
|
* Install Gnome extensions required for Linux using Gnome > 41.
|
|
312
308
|
* This function will write extension files needed to correctly detect working windows with Wayland desktop environment.
|
|
313
309
|
* Restart session will be require to remove the gnome extension.
|
|
314
310
|
*/
|
|
315
|
-
export function uninstallExtension(): boolean
|
|
311
|
+
export declare function uninstallExtension(): boolean
|
|
316
312
|
/**
|
|
317
313
|
* Enable Gnome extensions required for Linux using Gnome > 41.
|
|
318
314
|
* This function will enable extension needed to correctly detect working windows with Wayland desktop environment.
|
|
319
315
|
*/
|
|
320
|
-
export function enableExtension(): boolean
|
|
316
|
+
export declare function enableExtension(): boolean
|
|
321
317
|
/**
|
|
322
318
|
* Disable Gnome extensions required for Linux using Gnome > 41.
|
|
323
319
|
* This function will disable extension needed to correctly detect working windows with Wayland desktop environment.
|
|
324
320
|
*/
|
|
325
|
-
export function disableExtension(): boolean
|
|
321
|
+
export declare function disableExtension(): boolean
|
|
322
|
+
/**
|
|
323
|
+
* Struct to store all informations of the window
|
|
324
|
+
*/
|
|
325
|
+
export class WindowInfo {
|
|
326
|
+
id: number
|
|
327
|
+
os: string
|
|
328
|
+
title: string
|
|
329
|
+
position: WindowPosition
|
|
330
|
+
info: ProcessInfo
|
|
331
|
+
usage: UsageInfo
|
|
332
|
+
url: string
|
|
333
|
+
constructor(id: number, os: string, title: string, position: WindowPosition, info: ProcessInfo, usage: UsageInfo, url: string)
|
|
334
|
+
/**
|
|
335
|
+
* Funciton who help to recover icon of application and will return `IconInfo`.
|
|
336
|
+
*/
|
|
337
|
+
getIcon(): IconInfo
|
|
338
|
+
/**
|
|
339
|
+
* Promise funciton who help to recover icon of application and will return `IconInfo`.
|
|
340
|
+
*/
|
|
341
|
+
getIconAsync(): Promise<IconInfo>
|
|
342
|
+
}
|
package/index.js
CHANGED
|
@@ -310,8 +310,9 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { activeWindow, activeWindowAsync, openWindows, openWindowsAsync, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow, installExtension, uninstallExtension, enableExtension, disableExtension } = nativeBinding
|
|
313
|
+
const { WindowInfo, activeWindow, activeWindowAsync, openWindows, openWindowsAsync, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow, installExtension, uninstallExtension, enableExtension, disableExtension } = nativeBinding
|
|
314
314
|
|
|
315
|
+
module.exports.WindowInfo = WindowInfo
|
|
315
316
|
module.exports.activeWindow = activeWindow
|
|
316
317
|
module.exports.activeWindowAsync = activeWindowAsync
|
|
317
318
|
module.exports.openWindows = openWindows
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miniben90/x-win",
|
|
3
3
|
"description": "This package allows you to retrieve precise information about active and open windows on Windows, MacOS, and Linux. You can obtain the position, size, title, and other memory of windows.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.1",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"aarch64-apple-darwin",
|
|
18
18
|
"aarch64-pc-windows-msvc",
|
|
19
19
|
"i686-pc-windows-msvc",
|
|
20
|
-
"universal-apple-darwin"
|
|
20
|
+
"universal-apple-darwin",
|
|
21
|
+
"x86_64-unknown-linux-musl"
|
|
21
22
|
]
|
|
22
23
|
}
|
|
23
24
|
},
|
|
@@ -41,12 +42,16 @@
|
|
|
41
42
|
"open"
|
|
42
43
|
],
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@napi-rs/cli": "^2.18.
|
|
45
|
-
"ava": "^6.1.3"
|
|
45
|
+
"@napi-rs/cli": "^2.18.4",
|
|
46
|
+
"ava": "^6.1.3",
|
|
47
|
+
"husky": "^9.1.4"
|
|
46
48
|
},
|
|
47
49
|
"ava": {
|
|
48
50
|
"timeout": "3m",
|
|
49
|
-
"failFast": true
|
|
51
|
+
"failFast": true,
|
|
52
|
+
"files": [
|
|
53
|
+
"__test__/**/*.mjs"
|
|
54
|
+
]
|
|
50
55
|
},
|
|
51
56
|
"engines": {
|
|
52
57
|
"node": ">= 14"
|
|
@@ -58,16 +63,18 @@
|
|
|
58
63
|
"prepublishOnly": "napi prepublish -t npm",
|
|
59
64
|
"test": "ava",
|
|
60
65
|
"universal": "napi universal",
|
|
61
|
-
"version": "napi version"
|
|
66
|
+
"version": "napi version",
|
|
67
|
+
"prepare": "husky"
|
|
62
68
|
},
|
|
63
69
|
"packageManager": "yarn@4.1.1",
|
|
64
70
|
"optionalDependencies": {
|
|
65
|
-
"@miniben90/x-win-win32-x64-msvc": "1.
|
|
66
|
-
"@miniben90/x-win-darwin-x64": "1.
|
|
67
|
-
"@miniben90/x-win-linux-x64-gnu": "1.
|
|
68
|
-
"@miniben90/x-win-darwin-arm64": "1.
|
|
69
|
-
"@miniben90/x-win-win32-arm64-msvc": "1.
|
|
70
|
-
"@miniben90/x-win-win32-ia32-msvc": "1.
|
|
71
|
-
"@miniben90/x-win-darwin-universal": "1.
|
|
71
|
+
"@miniben90/x-win-win32-x64-msvc": "1.10.1",
|
|
72
|
+
"@miniben90/x-win-darwin-x64": "1.10.1",
|
|
73
|
+
"@miniben90/x-win-linux-x64-gnu": "1.10.1",
|
|
74
|
+
"@miniben90/x-win-darwin-arm64": "1.10.1",
|
|
75
|
+
"@miniben90/x-win-win32-arm64-msvc": "1.10.1",
|
|
76
|
+
"@miniben90/x-win-win32-ia32-msvc": "1.10.1",
|
|
77
|
+
"@miniben90/x-win-darwin-universal": "1.10.1",
|
|
78
|
+
"@miniben90/x-win-linux-x64-musl": "1.10.1"
|
|
72
79
|
}
|
|
73
80
|
}
|