@miniben90/x-win 1.5.1 → 1.6.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.
package/README.md CHANGED
@@ -16,7 +16,7 @@ npm i @miniben90/x-win
16
16
  yarn add @miniben90/x-win
17
17
  ```
18
18
 
19
- ## How to use
19
+ ## How to use x-win
20
20
 
21
21
  ### Get information about the currently active window
22
22
 
@@ -56,6 +56,18 @@ console.log(currentWindow);
56
56
  }
57
57
  ```
58
58
 
59
+ You can also use asynchronous methods instead. To do so, you just have to use `activeWindowAsync`, for example:
60
+
61
+ ```typescript
62
+ import { activeWindowAsync, type WindowInfo } from '@miniben90/x-win';
63
+
64
+ activeWindow()
65
+ .then((currentWindow: WindowInfo) => {
66
+ console.log(currentWindow);
67
+ });
68
+
69
+ ```
70
+
59
71
  ### Get a list of open windows with information
60
72
 
61
73
  `exemple.ts`:
@@ -94,6 +106,18 @@ console.log(windows);
94
106
  }]
95
107
  ```
96
108
 
109
+ You can also use asynchronous methods instead. To do so, you just have to use `openWindowsAsync`, for example:
110
+
111
+ ```typescript
112
+ import { openWindowsAsync, type WindowInfo } from '@miniben90/x-win';
113
+
114
+ openWindowsAsync()
115
+ .then((windows: WindowInfo[]) => {
116
+ console.log(windows);
117
+ });
118
+
119
+ ```
120
+
97
121
  ### Subscribe to get the current active window
98
122
 
99
123
  Thread will be start to check every `100ms` for a new active window (checking window title, window id and process id).
package/index.d.ts CHANGED
@@ -40,7 +40,7 @@ export interface WindowInfo {
40
40
  url: string
41
41
  }
42
42
  /**
43
- * Retrieve information about currently active window.
43
+ * Retrieve information the about currently active window.
44
44
  * Returns an object of `WindowInfo`.
45
45
  *
46
46
  * # Example
@@ -55,7 +55,24 @@ export interface WindowInfo {
55
55
  */
56
56
  export function activeWindow(): WindowInfo
57
57
  /**
58
- * Retrieve information about currently open windows.
58
+ * Retrieve information about the currently active window as a promise.
59
+ * Returns an object of `WindowInfo`.
60
+ *
61
+ * # Example
62
+ * ```javascript
63
+ * activeWindow()
64
+ * .then(currentWindow => {
65
+ * console.log(currentWindow);
66
+ * });
67
+ * ```
68
+ *
69
+ * # Information about Electron
70
+ *
71
+ * It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
72
+ */
73
+ export function activeWindowAsync(): Promise<WindowInfo>
74
+ /**
75
+ * Retrieve information about the currently open windows.
59
76
  * Returns an array of `WindowInfo`, each containing details about a specific open window.
60
77
  *
61
78
  * # Example
@@ -71,6 +88,25 @@ export function activeWindow(): WindowInfo
71
88
  * It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
72
89
  */
73
90
  export function openWindows(): Array<WindowInfo>
91
+ /**
92
+ * Retrieve information about the currently open windows as a promise.
93
+ * Returns an array of `WindowInfo`, each containing details about a specific open window.
94
+ *
95
+ * # Example
96
+ * ```javascript
97
+ * openWindows()
98
+ * .then(windows => {
99
+ * for (let i = 0; i < windows.length; i++) {
100
+ * console.log(i, windows[i]);
101
+ * }
102
+ * });
103
+ * ```
104
+ *
105
+ * # Information about Electron
106
+ *
107
+ * It is recommended to use this function within a worker to mitigate potential recovery issues on MacOS.
108
+ */
109
+ export function openWindowsAsync(): Promise<Array<WindowInfo>>
74
110
  /**
75
111
  * Subscribe an observer thread to monitor changes in the active window.
76
112
  *
package/index.js CHANGED
@@ -281,10 +281,12 @@ if (!nativeBinding) {
281
281
  throw new Error(`Failed to load native binding`)
282
282
  }
283
283
 
284
- const { activeWindow, openWindows, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } = nativeBinding
284
+ const { activeWindow, activeWindowAsync, openWindows, openWindowsAsync, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } = nativeBinding
285
285
 
286
286
  module.exports.activeWindow = activeWindow
287
+ module.exports.activeWindowAsync = activeWindowAsync
287
288
  module.exports.openWindows = openWindows
289
+ module.exports.openWindowsAsync = openWindowsAsync
288
290
  module.exports.subscribeActiveWindow = subscribeActiveWindow
289
291
  module.exports.unsubscribeActiveWindow = unsubscribeActiveWindow
290
292
  module.exports.unsubscribeAllActiveWindow = unsubscribeAllActiveWindow
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.5.1",
4
+ "version": "1.6.0",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
@@ -61,12 +61,12 @@
61
61
  },
62
62
  "packageManager": "yarn@4.0.2",
63
63
  "optionalDependencies": {
64
- "@miniben90/x-win-win32-x64-msvc": "1.5.1",
65
- "@miniben90/x-win-darwin-x64": "1.5.1",
66
- "@miniben90/x-win-linux-x64-gnu": "1.5.1",
67
- "@miniben90/x-win-darwin-arm64": "1.5.1",
68
- "@miniben90/x-win-win32-arm64-msvc": "1.5.1",
69
- "@miniben90/x-win-win32-ia32-msvc": "1.5.1",
70
- "@miniben90/x-win-darwin-universal": "1.5.1"
64
+ "@miniben90/x-win-win32-x64-msvc": "1.6.0",
65
+ "@miniben90/x-win-darwin-x64": "1.6.0",
66
+ "@miniben90/x-win-linux-x64-gnu": "1.6.0",
67
+ "@miniben90/x-win-darwin-arm64": "1.6.0",
68
+ "@miniben90/x-win-win32-arm64-msvc": "1.6.0",
69
+ "@miniben90/x-win-win32-ia32-msvc": "1.6.0",
70
+ "@miniben90/x-win-darwin-universal": "1.6.0"
71
71
  }
72
72
  }