@miniben90/x-win 1.3.1 → 1.5.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 +39 -1
  2. package/index.d.ts +3 -0
  3. package/index.js +33 -1
  4. package/package.json +11 -11
package/README.md CHANGED
@@ -94,14 +94,47 @@ console.log(windows);
94
94
  }]
95
95
  ```
96
96
 
97
+ ### Subscribe to get the current active window
98
+
99
+ Thread will be start to check every `100ms` for a new active window (checking window title, window id and process id).
100
+
101
+ * `subscribeActiveWindow`: Create a subscription with a callback function
102
+ * `unsubscribeActiveWindow`: Remove a specific subscription
103
+ * `unsubscribeAllActiveWindow`: Remove all threads
104
+
105
+
106
+ ```typescript
107
+ import { subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
108
+
109
+ const a = subscribeActiveWindow(activeWindow => {
110
+ console.log('test a', activeWindow);
111
+ });
112
+
113
+ const b = subscribeActiveWindow(activeWindow => {
114
+ console.log('test b', activeWindow);
115
+ });
116
+
117
+
118
+ const c = subscribeActiveWindow(activeWindow => {
119
+ console.log('test c', activeWindow);
120
+ });
121
+
122
+ setTimeout(() => unsubscribeActiveWindow(c), 5000);
123
+
124
+ setTimeout(() => unsubscribeAllActiveWindow(), 10000);
125
+ ```
126
+
97
127
  # Linux
98
128
 
99
- > Dependencies are required to be installed for development purposes.
129
+ Dependencies are required to be installed for development purposes.
100
130
 
101
131
  ```sh
102
132
  sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxcb-shm0-dev
103
133
  ```
104
134
 
135
+ > ⚠️**Warning**
136
+ > Recovery url is not available on linux
137
+
105
138
  # Darwin
106
139
 
107
140
  ## Screen recording permission introduced in macOS 10.15 Catalina
@@ -164,6 +197,11 @@ It will use AppleScript to get informations for chromium browsers and safari
164
197
  | opera software - OperaGX | ✅ |
165
198
  | Vivaldi | |
166
199
 
200
+ ## Electron
201
+
202
+ * To prevent potential crashes and issues, it's recommended to execute recovery operations within a worker thread ([https://nodejs.org/api/worker_threads.html](https://nodejs.org/api/worker_threads.html))
203
+ * For macOS, you can utilize functions to check and request screen permissions ([https://www.electronjs.org/fr/docs/latest/api/system-preferences](https://www.electronjs.org/fr/docs/latest/api/system-preferences))
204
+
167
205
  <hr class="padding-top: 30px;padding-bottom:30px">
168
206
 
169
207
  # Project References
package/index.d.ts CHANGED
@@ -41,3 +41,6 @@ export interface WindowInfo {
41
41
  }
42
42
  export function activeWindow(): WindowInfo
43
43
  export function openWindows(): Array<WindowInfo>
44
+ export function subscribeActiveWindow(callback: (info: WindowInfo) => void): number
45
+ export function unsubscribeActiveWindow(threadId: number): void
46
+ export function unsubscribeAllActiveWindow(): void
package/index.js CHANGED
@@ -237,6 +237,35 @@ switch (platform) {
237
237
  loadError = e
238
238
  }
239
239
  break
240
+ case 'riscv64':
241
+ if (isMusl()) {
242
+ localFileExisted = existsSync(
243
+ join(__dirname, 'x-win.linux-riscv64-musl.node')
244
+ )
245
+ try {
246
+ if (localFileExisted) {
247
+ nativeBinding = require('./x-win.linux-riscv64-musl.node')
248
+ } else {
249
+ nativeBinding = require('@miniben90/x-win-linux-riscv64-musl')
250
+ }
251
+ } catch (e) {
252
+ loadError = e
253
+ }
254
+ } else {
255
+ localFileExisted = existsSync(
256
+ join(__dirname, 'x-win.linux-riscv64-gnu.node')
257
+ )
258
+ try {
259
+ if (localFileExisted) {
260
+ nativeBinding = require('./x-win.linux-riscv64-gnu.node')
261
+ } else {
262
+ nativeBinding = require('@miniben90/x-win-linux-riscv64-gnu')
263
+ }
264
+ } catch (e) {
265
+ loadError = e
266
+ }
267
+ }
268
+ break
240
269
  default:
241
270
  throw new Error(`Unsupported architecture on Linux: ${arch}`)
242
271
  }
@@ -252,7 +281,10 @@ if (!nativeBinding) {
252
281
  throw new Error(`Failed to load native binding`)
253
282
  }
254
283
 
255
- const { activeWindow, openWindows } = nativeBinding
284
+ const { activeWindow, openWindows, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } = nativeBinding
256
285
 
257
286
  module.exports.activeWindow = activeWindow
258
287
  module.exports.openWindows = openWindows
288
+ module.exports.subscribeActiveWindow = subscribeActiveWindow
289
+ module.exports.unsubscribeActiveWindow = unsubscribeActiveWindow
290
+ 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.3.1",
4
+ "version": "1.5.0",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
@@ -41,8 +41,8 @@
41
41
  "open"
42
42
  ],
43
43
  "devDependencies": {
44
- "@napi-rs/cli": "^2.16.3",
45
- "ava": "^5.3.1"
44
+ "@napi-rs/cli": "^2.17.0",
45
+ "ava": "^6.0.1"
46
46
  },
47
47
  "ava": {
48
48
  "timeout": "3m"
@@ -59,14 +59,14 @@
59
59
  "universal": "napi universal",
60
60
  "version": "napi version"
61
61
  },
62
- "packageManager": "yarn@3.6.3",
62
+ "packageManager": "yarn@4.0.2",
63
63
  "optionalDependencies": {
64
- "@miniben90/x-win-win32-x64-msvc": "1.3.1",
65
- "@miniben90/x-win-darwin-x64": "1.3.1",
66
- "@miniben90/x-win-linux-x64-gnu": "1.3.1",
67
- "@miniben90/x-win-darwin-arm64": "1.3.1",
68
- "@miniben90/x-win-win32-arm64-msvc": "1.3.1",
69
- "@miniben90/x-win-win32-ia32-msvc": "1.3.1",
70
- "@miniben90/x-win-darwin-universal": "1.3.1"
64
+ "@miniben90/x-win-win32-x64-msvc": "1.5.0",
65
+ "@miniben90/x-win-darwin-x64": "1.5.0",
66
+ "@miniben90/x-win-linux-x64-gnu": "1.5.0",
67
+ "@miniben90/x-win-darwin-arm64": "1.5.0",
68
+ "@miniben90/x-win-win32-arm64-msvc": "1.5.0",
69
+ "@miniben90/x-win-win32-ia32-msvc": "1.5.0",
70
+ "@miniben90/x-win-darwin-universal": "1.5.0"
71
71
  }
72
72
  }