@miniben90/x-win 1.7.1 → 1.8.0-beta
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 +16 -10
- package/index.d.ts +158 -2
- package/index.js +19 -1
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|

|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
This project uses Rust and napi-rs to make it easy to obtain the active window or an array of open windows. It works on Microsoft Windows (10, 11), [Linux (with X server)](#linux), and [macOS 10.6+](#darwin).
|
|
9
|
+
This project uses Rust and napi-rs to make it easy to obtain the active window or an array of open windows. It works on Microsoft Windows (10, 11), [Linux (with X server)](#linux), [Linux (with Gnome =< 45)](#GNOME), and [macOS 10.6+](#darwin).
|
|
10
10
|
|
|
11
11
|
## How to install
|
|
12
12
|
|
|
@@ -128,7 +128,6 @@ Thread will be start to check every `100ms` for a new active window (checking wi
|
|
|
128
128
|
* `unsubscribeActiveWindow`: Remove a specific subscription
|
|
129
129
|
* `unsubscribeAllActiveWindow`: Remove all threads
|
|
130
130
|
|
|
131
|
-
|
|
132
131
|
```typescript
|
|
133
132
|
import { subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
|
|
134
133
|
|
|
@@ -140,7 +139,6 @@ const b = subscribeActiveWindow(activeWindow => {
|
|
|
140
139
|
console.log('test b', activeWindow);
|
|
141
140
|
});
|
|
142
141
|
|
|
143
|
-
|
|
144
142
|
const c = subscribeActiveWindow(activeWindow => {
|
|
145
143
|
console.log('test c', activeWindow);
|
|
146
144
|
});
|
|
@@ -150,28 +148,36 @@ setTimeout(() => unsubscribeActiveWindow(c), 5000);
|
|
|
150
148
|
setTimeout(() => unsubscribeAllActiveWindow(), 10000);
|
|
151
149
|
```
|
|
152
150
|
|
|
153
|
-
|
|
151
|
+
## Linux
|
|
154
152
|
|
|
155
153
|
Dependencies are required to be installed for development purposes.
|
|
156
154
|
|
|
157
155
|
```sh
|
|
158
|
-
sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxcb-shm0-dev
|
|
156
|
+
sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxcb-shm0-dev pkg-config build-essential
|
|
159
157
|
```
|
|
160
158
|
|
|
161
159
|
> ⚠️**Warning**
|
|
162
160
|
> Recovery url is not available on linux
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
### GNOME (Wayland)
|
|
163
|
+
|
|
164
|
+
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).
|
|
165
|
+
|
|
166
|
+
The extension can be installed using the `installExtension` function, which will deposit it in `~/.local/share/gnome-shell/extensions/x-win@miniben90.org`.
|
|
167
|
+
|
|
168
|
+
After executing this function, it's vital to **restart the user session** to load the new extension and then proceed to enable it using `enableExtension` to be able to use x-win.
|
|
169
|
+
|
|
170
|
+
### Darwin (version 10.6+)
|
|
165
171
|
|
|
166
172
|
## Screen recording permission introduced in macOS 10.15 Catalina
|
|
167
173
|
|
|
168
174
|
> macOS requires you to grant access for screen recording. If your project does not have it, the title will be an empty value.
|
|
169
175
|
|
|
170
|
-
|
|
176
|
+
## URLs (Only available for Darwin and Windows Systems)
|
|
171
177
|
|
|
172
178
|
It is possible to get URL of browsers window for macOS and Windows.
|
|
173
179
|
|
|
174
|
-
|
|
180
|
+
### Windows
|
|
175
181
|
|
|
176
182
|
| Browser name | Tested |
|
|
177
183
|
|---|---|
|
|
@@ -192,7 +198,7 @@ It is possible to get URL of browsers window for macOS and Windows.
|
|
|
192
198
|
| beaker | |
|
|
193
199
|
| beaker browser | |
|
|
194
200
|
|
|
195
|
-
|
|
201
|
+
### macOS
|
|
196
202
|
|
|
197
203
|
It will use AppleScript to get informations for chromium browsers and safari
|
|
198
204
|
|
|
@@ -230,7 +236,7 @@ It will use AppleScript to get informations for chromium browsers and safari
|
|
|
230
236
|
|
|
231
237
|
<hr class="padding-top: 30px;padding-bottom:30px">
|
|
232
238
|
|
|
233
|
-
|
|
239
|
+
## Project References
|
|
234
240
|
|
|
235
241
|
**Project Inspirations:**
|
|
236
242
|
|
package/index.d.ts
CHANGED
|
@@ -44,7 +44,21 @@ export interface WindowInfo {
|
|
|
44
44
|
* Returns an object of `WindowInfo`.
|
|
45
45
|
*
|
|
46
46
|
* # Example
|
|
47
|
+
*
|
|
48
|
+
* ## Javascript example
|
|
49
|
+
*
|
|
47
50
|
* ```javascript
|
|
51
|
+
* const { activeWindow } = require('@miniben90/x-win');
|
|
52
|
+
*
|
|
53
|
+
* const currentWindow = activeWindow();
|
|
54
|
+
* console.log(currentWindow);
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ## Typescript example
|
|
58
|
+
*
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { activeWindow } from '@miniben90/x-win';
|
|
61
|
+
*
|
|
48
62
|
* const currentWindow = activeWindow();
|
|
49
63
|
* console.log(currentWindow);
|
|
50
64
|
* ```
|
|
@@ -59,8 +73,22 @@ export function activeWindow(): WindowInfo
|
|
|
59
73
|
* Returns an object of `WindowInfo`.
|
|
60
74
|
*
|
|
61
75
|
* # Example
|
|
76
|
+
*
|
|
77
|
+
* ## Javascript example
|
|
78
|
+
*
|
|
62
79
|
* ```javascript
|
|
63
|
-
*
|
|
80
|
+
* activeWindowAsync()
|
|
81
|
+
* .then(currentWindow => {
|
|
82
|
+
* console.log(currentWindow);
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* ## Typescript example
|
|
87
|
+
*
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import { activeWindowAsync } from '@miniben90/x-win';
|
|
90
|
+
*
|
|
91
|
+
* activeWindowAsync()
|
|
64
92
|
* .then(currentWindow => {
|
|
65
93
|
* console.log(currentWindow);
|
|
66
94
|
* });
|
|
@@ -76,7 +104,23 @@ export function activeWindowAsync(): Promise<WindowInfo>
|
|
|
76
104
|
* Returns an array of `WindowInfo`, each containing details about a specific open window.
|
|
77
105
|
*
|
|
78
106
|
* # Example
|
|
107
|
+
*
|
|
108
|
+
* ## Javascript example
|
|
109
|
+
*
|
|
79
110
|
* ```javascript
|
|
111
|
+
* const { openWindows } = require('@miniben90/x-win');
|
|
112
|
+
*
|
|
113
|
+
* const windows = openWindows();
|
|
114
|
+
* for (let i = 0; i < windows.length; i++) {
|
|
115
|
+
* console.log(i, windows[i]);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* ## Typescript Example
|
|
120
|
+
*
|
|
121
|
+
* ```typescript
|
|
122
|
+
* import { openWindows } from '@miniben90/x-win';
|
|
123
|
+
*
|
|
80
124
|
* const windows = openWindows();
|
|
81
125
|
* for (let i = 0; i < windows.length; i++) {
|
|
82
126
|
* console.log(i, windows[i]);
|
|
@@ -93,8 +137,26 @@ export function openWindows(): Array<WindowInfo>
|
|
|
93
137
|
* Returns an array of `WindowInfo`, each containing details about a specific open window.
|
|
94
138
|
*
|
|
95
139
|
* # Example
|
|
140
|
+
*
|
|
141
|
+
* ## Javascript example
|
|
142
|
+
*
|
|
96
143
|
* ```javascript
|
|
97
|
-
*
|
|
144
|
+
* const { openWindowsAsync } = resuire('@miniben90/x-win');
|
|
145
|
+
*
|
|
146
|
+
* openWindowsAsync()
|
|
147
|
+
* .then(windows => {
|
|
148
|
+
* for (let i = 0; i < windows.length; i++) {
|
|
149
|
+
* console.log(i, windows[i]);
|
|
150
|
+
* }
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* ## Typescript example
|
|
155
|
+
*
|
|
156
|
+
* ```typescript
|
|
157
|
+
* import { openWindowsAsync } from '@miniben90/x-win';
|
|
158
|
+
*
|
|
159
|
+
* openWindowsAsync()
|
|
98
160
|
* .then(windows => {
|
|
99
161
|
* for (let i = 0; i < windows.length; i++) {
|
|
100
162
|
* console.log(i, windows[i]);
|
|
@@ -111,7 +173,30 @@ export function openWindowsAsync(): Promise<Array<WindowInfo>>
|
|
|
111
173
|
* Subscribe an observer thread to monitor changes in the active window.
|
|
112
174
|
*
|
|
113
175
|
* # Example
|
|
176
|
+
*
|
|
177
|
+
* ## Javascript example
|
|
178
|
+
*
|
|
114
179
|
* ```javascript
|
|
180
|
+
* const { subscribeActiveWindow, unsubscribeAllActiveWindow } = require('@miniben90/x-win');
|
|
181
|
+
*
|
|
182
|
+
* const a = subscribeActiveWindow((info) => {
|
|
183
|
+
* t.log(a, info);
|
|
184
|
+
* });
|
|
185
|
+
* const b = subscribeActiveWindow((info) => {
|
|
186
|
+
* t.log(b, info);
|
|
187
|
+
* });
|
|
188
|
+
* const c = subscribeActiveWindow((info) => {
|
|
189
|
+
* t.log(c, info);
|
|
190
|
+
* });
|
|
191
|
+
*
|
|
192
|
+
* unsubscribeAllActiveWindow();
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* ## Typescript example
|
|
196
|
+
*
|
|
197
|
+
* ```typescript
|
|
198
|
+
* import { subscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
|
|
199
|
+
*
|
|
115
200
|
* const a = subscribeActiveWindow((info) => {
|
|
116
201
|
* t.log(a, info);
|
|
117
202
|
* });
|
|
@@ -124,13 +209,39 @@ export function openWindowsAsync(): Promise<Array<WindowInfo>>
|
|
|
124
209
|
*
|
|
125
210
|
* unsubscribeAllActiveWindow();
|
|
126
211
|
* ```
|
|
212
|
+
*
|
|
127
213
|
*/
|
|
128
214
|
export function subscribeActiveWindow(callback: (info: WindowInfo) => void): number
|
|
129
215
|
/**
|
|
130
216
|
* Terminate and unsubscribe a specific observer using their ID.
|
|
131
217
|
*
|
|
132
218
|
* # Example
|
|
219
|
+
*
|
|
220
|
+
* ## Javascript example
|
|
221
|
+
*
|
|
133
222
|
* ```javascript
|
|
223
|
+
* const { subscribeActiveWindow, unsubscribeActiveWindow } = require('@miniben90/x-win');
|
|
224
|
+
*
|
|
225
|
+
* const a = subscribeActiveWindow((info) => {
|
|
226
|
+
* t.log(a, info);
|
|
227
|
+
* });
|
|
228
|
+
* const b = subscribeActiveWindow((info) => {
|
|
229
|
+
* t.log(b, info);
|
|
230
|
+
* });
|
|
231
|
+
* const c = subscribeActiveWindow((info) => {
|
|
232
|
+
* t.log(c, info);
|
|
233
|
+
* });
|
|
234
|
+
*
|
|
235
|
+
* unsubscribeActiveWindow(a);
|
|
236
|
+
* unsubscribeActiveWindow(b);
|
|
237
|
+
* unsubscribeActiveWindow(c);
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* ## Typescript example
|
|
241
|
+
*
|
|
242
|
+
* ```typescript
|
|
243
|
+
* import { subscribeActiveWindow, unsubscribeActiveWindow } from '@miniben90/x-win';
|
|
244
|
+
*
|
|
134
245
|
* const a = subscribeActiveWindow((info) => {
|
|
135
246
|
* t.log(a, info);
|
|
136
247
|
* });
|
|
@@ -151,7 +262,30 @@ export function unsubscribeActiveWindow(threadId: number): void
|
|
|
151
262
|
* Terminate and unsubscribe all observer threads monitoring changes in the active window.
|
|
152
263
|
*
|
|
153
264
|
* # Example
|
|
265
|
+
*
|
|
266
|
+
* ## Javascript example
|
|
267
|
+
*
|
|
154
268
|
* ```javascript
|
|
269
|
+
* const { subscribeActiveWindow, unsubscribeAllActiveWindow } = require('@miniben90/x-win');
|
|
270
|
+
*
|
|
271
|
+
* const a = subscribeActiveWindow((info) => {
|
|
272
|
+
* t.log(a, info);
|
|
273
|
+
* });
|
|
274
|
+
* const b = subscribeActiveWindow((info) => {
|
|
275
|
+
* t.log(b, info);
|
|
276
|
+
* });
|
|
277
|
+
* const c = subscribeActiveWindow((info) => {
|
|
278
|
+
* t.log(c, info);
|
|
279
|
+
* });
|
|
280
|
+
*
|
|
281
|
+
* unsubscribeAllActiveWindow();
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* ## Typescript example
|
|
285
|
+
*
|
|
286
|
+
* ```typescript
|
|
287
|
+
* import { subscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
|
|
288
|
+
*
|
|
155
289
|
* const a = subscribeActiveWindow((info) => {
|
|
156
290
|
* t.log(a, info);
|
|
157
291
|
* });
|
|
@@ -166,3 +300,25 @@ export function unsubscribeActiveWindow(threadId: number): void
|
|
|
166
300
|
* ```
|
|
167
301
|
*/
|
|
168
302
|
export function unsubscribeAllActiveWindow(): void
|
|
303
|
+
/**
|
|
304
|
+
* Install Gnome extensions required for Linux using Gnome > 41.
|
|
305
|
+
* This function will write extension files needed to correctly detect working windows with Wayland desktop environment.
|
|
306
|
+
* Restart session will be require to install the gnome extension.
|
|
307
|
+
*/
|
|
308
|
+
export function installExtension(): boolean
|
|
309
|
+
/**
|
|
310
|
+
* Install Gnome extensions required for Linux using Gnome > 41.
|
|
311
|
+
* This function will write extension files needed to correctly detect working windows with Wayland desktop environment.
|
|
312
|
+
* Restart session will be require to remove the gnome extension.
|
|
313
|
+
*/
|
|
314
|
+
export function uninstallExtension(): boolean
|
|
315
|
+
/**
|
|
316
|
+
* Enable Gnome extensions required for Linux using Gnome > 41.
|
|
317
|
+
* This function will enable extension needed to correctly detect working windows with Wayland desktop environment.
|
|
318
|
+
*/
|
|
319
|
+
export function enableExtension(): boolean
|
|
320
|
+
/**
|
|
321
|
+
* Disable Gnome extensions required for Linux using Gnome > 41.
|
|
322
|
+
* This function will disable extension needed to correctly detect working windows with Wayland desktop environment.
|
|
323
|
+
*/
|
|
324
|
+
export function disableExtension(): boolean
|
package/index.js
CHANGED
|
@@ -266,6 +266,20 @@ switch (platform) {
|
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
break
|
|
269
|
+
case 's390x':
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'x-win.linux-s390x-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./x-win.linux-s390x-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@miniben90/x-win-linux-s390x-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
break
|
|
269
283
|
default:
|
|
270
284
|
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
271
285
|
}
|
|
@@ -281,7 +295,7 @@ if (!nativeBinding) {
|
|
|
281
295
|
throw new Error(`Failed to load native binding`)
|
|
282
296
|
}
|
|
283
297
|
|
|
284
|
-
const { activeWindow, activeWindowAsync, openWindows, openWindowsAsync, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } = nativeBinding
|
|
298
|
+
const { activeWindow, activeWindowAsync, openWindows, openWindowsAsync, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow, installExtension, uninstallExtension, enableExtension, disableExtension } = nativeBinding
|
|
285
299
|
|
|
286
300
|
module.exports.activeWindow = activeWindow
|
|
287
301
|
module.exports.activeWindowAsync = activeWindowAsync
|
|
@@ -290,3 +304,7 @@ module.exports.openWindowsAsync = openWindowsAsync
|
|
|
290
304
|
module.exports.subscribeActiveWindow = subscribeActiveWindow
|
|
291
305
|
module.exports.unsubscribeActiveWindow = unsubscribeActiveWindow
|
|
292
306
|
module.exports.unsubscribeAllActiveWindow = unsubscribeAllActiveWindow
|
|
307
|
+
module.exports.installExtension = installExtension
|
|
308
|
+
module.exports.uninstallExtension = uninstallExtension
|
|
309
|
+
module.exports.enableExtension = enableExtension
|
|
310
|
+
module.exports.disableExtension = disableExtension
|
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.8.0-beta",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -41,11 +41,12 @@
|
|
|
41
41
|
"open"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@napi-rs/cli": "^2.
|
|
45
|
-
"ava": "^6.
|
|
44
|
+
"@napi-rs/cli": "^2.18.0",
|
|
45
|
+
"ava": "^6.1.1"
|
|
46
46
|
},
|
|
47
47
|
"ava": {
|
|
48
|
-
"timeout": "3m"
|
|
48
|
+
"timeout": "3m",
|
|
49
|
+
"failFast": true
|
|
49
50
|
},
|
|
50
51
|
"engines": {
|
|
51
52
|
"node": ">= 14"
|
|
@@ -61,12 +62,12 @@
|
|
|
61
62
|
},
|
|
62
63
|
"packageManager": "yarn@4.0.2",
|
|
63
64
|
"optionalDependencies": {
|
|
64
|
-
"@miniben90/x-win-win32-x64-msvc": "1.
|
|
65
|
-
"@miniben90/x-win-darwin-x64": "1.
|
|
66
|
-
"@miniben90/x-win-linux-x64-gnu": "1.
|
|
67
|
-
"@miniben90/x-win-darwin-arm64": "1.
|
|
68
|
-
"@miniben90/x-win-win32-arm64-msvc": "1.
|
|
69
|
-
"@miniben90/x-win-win32-ia32-msvc": "1.
|
|
70
|
-
"@miniben90/x-win-darwin-universal": "1.
|
|
65
|
+
"@miniben90/x-win-win32-x64-msvc": "1.8.0-beta",
|
|
66
|
+
"@miniben90/x-win-darwin-x64": "1.8.0-beta",
|
|
67
|
+
"@miniben90/x-win-linux-x64-gnu": "1.8.0-beta",
|
|
68
|
+
"@miniben90/x-win-darwin-arm64": "1.8.0-beta",
|
|
69
|
+
"@miniben90/x-win-win32-arm64-msvc": "1.8.0-beta",
|
|
70
|
+
"@miniben90/x-win-win32-ia32-msvc": "1.8.0-beta",
|
|
71
|
+
"@miniben90/x-win-darwin-universal": "1.8.0-beta"
|
|
71
72
|
}
|
|
72
73
|
}
|