@miniben90/x-win 1.9.2 → 1.10.0

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.
Files changed (4) hide show
  1. package/README.md +27 -0
  2. package/index.d.ts +37 -20
  3. package/index.js +2 -1
  4. package/package.json +12 -9
package/README.md CHANGED
@@ -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.
@@ -160,6 +185,8 @@ sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0
160
185
 
161
186
  > ⚠️**Warning**
162
187
  > libc.so.6 is needed
188
+
189
+ > ⚠️**Warning**
163
190
  > Recovery url is not available on linux
164
191
 
165
192
 
package/index.d.ts CHANGED
@@ -29,16 +29,12 @@ export interface WindowPosition {
29
29
  isFullScreen: boolean
30
30
  }
31
31
  /**
32
- * Struct to store all informations of the window
32
+ * Struct to store process information of the window
33
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
34
+ export interface IconInfo {
35
+ data: string
36
+ height: number
37
+ width: number
42
38
  }
43
39
  /**
44
40
  * Retrieve information the about currently active window.
@@ -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.9.2",
4
+ "version": "1.10.0",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
@@ -46,7 +46,10 @@
46
46
  },
47
47
  "ava": {
48
48
  "timeout": "3m",
49
- "failFast": true
49
+ "failFast": true,
50
+ "files": [
51
+ "__test__/**/*.mjs"
52
+ ]
50
53
  },
51
54
  "engines": {
52
55
  "node": ">= 14"
@@ -62,12 +65,12 @@
62
65
  },
63
66
  "packageManager": "yarn@4.1.1",
64
67
  "optionalDependencies": {
65
- "@miniben90/x-win-win32-x64-msvc": "1.9.2",
66
- "@miniben90/x-win-darwin-x64": "1.9.2",
67
- "@miniben90/x-win-linux-x64-gnu": "1.9.2",
68
- "@miniben90/x-win-darwin-arm64": "1.9.2",
69
- "@miniben90/x-win-win32-arm64-msvc": "1.9.2",
70
- "@miniben90/x-win-win32-ia32-msvc": "1.9.2",
71
- "@miniben90/x-win-darwin-universal": "1.9.2"
68
+ "@miniben90/x-win-win32-x64-msvc": "1.10.0",
69
+ "@miniben90/x-win-darwin-x64": "1.10.0",
70
+ "@miniben90/x-win-linux-x64-gnu": "1.10.0",
71
+ "@miniben90/x-win-darwin-arm64": "1.10.0",
72
+ "@miniben90/x-win-win32-arm64-msvc": "1.10.0",
73
+ "@miniben90/x-win-win32-ia32-msvc": "1.10.0",
74
+ "@miniben90/x-win-darwin-universal": "1.10.0"
72
75
  }
73
76
  }