rust-rpa 0.2.6-beta.1 → 0.2.6-beta.2
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 +2 -2
- package/index.d.ts +11 -33
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -205,7 +205,7 @@ main();
|
|
|
205
205
|
- `setBounds(bounds)` - 设置窗口边界
|
|
206
206
|
- `toJSON()` - 转为 JSON 对象
|
|
207
207
|
- `captureImage(options?)` - 截图
|
|
208
|
-
- `watchChanges(options?, callback)` - 监听窗口内容变化;返回 `WindowWatcher`(`stop()` / `isRunning()
|
|
208
|
+
- `watchChanges(options?, callback)` - 监听窗口内容变化;返回 `WindowWatcher`(`stop()` / `isRunning()`),回调无参数;`stableFrames` 选项可过滤光标闪烁等瞬态变化
|
|
209
209
|
- `recognizeText(options?)` - OCR 识别文字
|
|
210
210
|
- `findText(text, options?)` - 查找文字
|
|
211
211
|
- `findIcon(template, options?)` - 查找图标
|
|
@@ -636,7 +636,7 @@ if (targetWindow) {
|
|
|
636
636
|
|
|
637
637
|
#### 新功能
|
|
638
638
|
|
|
639
|
-
- **Window.watchChanges(窗口内容变化监听)**: 后台线程降采样对比相邻帧,超过阈值才截取完整窗口图并回调;支持 `threshold`、`from`(`window`/`screen`)、`region`、`captureSize
|
|
639
|
+
- **Window.watchChanges(窗口内容变化监听)**: 后台线程降采样对比相邻帧,超过阈值才截取完整窗口图并回调;支持 `threshold`、`from`(`window`/`screen`)、`region`、`captureSize`;返回 `WindowWatcher` 可 `stop()`。
|
|
640
640
|
|
|
641
641
|
### 0.2.3
|
|
642
642
|
|
package/index.d.ts
CHANGED
|
@@ -271,8 +271,6 @@ export interface WindowWatchOptionsJs {
|
|
|
271
271
|
region?: CaptureRegion | null
|
|
272
272
|
/** 检测到变化后传递给回调的截图目标尺寸 */
|
|
273
273
|
captureSize?: CaptureSizeJs | null
|
|
274
|
-
/** 是否在回调中传递截图图像,默认 true */
|
|
275
|
-
sendImage?: boolean
|
|
276
274
|
/**
|
|
277
275
|
* 变化确认帧数,默认 0
|
|
278
276
|
*
|
|
@@ -288,7 +286,7 @@ export interface WindowWatchOptionsJs {
|
|
|
288
286
|
stableFrames?: number
|
|
289
287
|
}
|
|
290
288
|
/** 窗口内容变化监听的回调函数签名 */
|
|
291
|
-
export type WindowChangeCallback = (
|
|
289
|
+
export type WindowChangeCallback = () => void
|
|
292
290
|
/** 窗口变化监听器句柄,用于停止监听 */
|
|
293
291
|
export interface WindowWatcher {
|
|
294
292
|
/** 停止监听,释放底层资源 */
|
|
@@ -1308,65 +1306,45 @@ export declare class Window {
|
|
|
1308
1306
|
*/
|
|
1309
1307
|
clickIcon(template: ImageData, options?: WindowWaitOptions | null): Promise<ClickResult>
|
|
1310
1308
|
/**
|
|
1311
|
-
*
|
|
1309
|
+
* 监听窗口内容变化,当检测到变化时触发回调函数
|
|
1312
1310
|
*
|
|
1313
|
-
*
|
|
1311
|
+
* 底层使用降采样差异检测,仅在窗口内容发生变化时才触发回调,
|
|
1314
1312
|
* 资源开销远低于定时轮询截图。
|
|
1315
1313
|
*
|
|
1316
1314
|
* @param options 监听选项(可选)
|
|
1317
|
-
* @param callback
|
|
1315
|
+
* @param callback 变化时的回调函数(无参数)
|
|
1318
1316
|
* @returns WindowWatcher 句柄,调用 stop() 可停止监听
|
|
1319
1317
|
*
|
|
1320
1318
|
* @example
|
|
1321
1319
|
* ```javascript
|
|
1322
|
-
* // 场景 1
|
|
1320
|
+
* // 场景 1:监听窗口变化
|
|
1323
1321
|
* const watcher = targetWindow.watchChanges(
|
|
1324
1322
|
* { threshold: 0.02, from: 'window' },
|
|
1325
|
-
* (
|
|
1326
|
-
* console.log(`窗口变化,新截图: ${image.width}x${image.height}`);
|
|
1327
|
-
* sendToExternalService(image);
|
|
1328
|
-
* }
|
|
1329
|
-
* );
|
|
1330
|
-
* ```
|
|
1331
|
-
*
|
|
1332
|
-
* @example
|
|
1333
|
-
* ```javascript
|
|
1334
|
-
* // 场景 2:只需要知道窗口有变化,不需要截图(更低开销)
|
|
1335
|
-
* const watcher = targetWindow.watchChanges(
|
|
1336
|
-
* { sendImage: false },
|
|
1337
|
-
* (image) => {
|
|
1323
|
+
* () => {
|
|
1338
1324
|
* console.log('窗口内容发生了变化');
|
|
1339
|
-
* onWindowChanged();
|
|
1340
1325
|
* }
|
|
1341
1326
|
* );
|
|
1342
1327
|
* ```
|
|
1343
1328
|
*
|
|
1344
1329
|
* @example
|
|
1345
1330
|
* ```javascript
|
|
1346
|
-
* // 场景
|
|
1331
|
+
* // 场景 2:仅监听窗口的特定区域
|
|
1347
1332
|
* const watcher = targetWindow.watchChanges(
|
|
1348
1333
|
* {
|
|
1349
1334
|
* region: { x: 100, y: 200, width: 400, height: 300 },
|
|
1350
|
-
* captureSize: { width: 800, height: 600 },
|
|
1351
|
-
* sendImage: true
|
|
1352
1335
|
* },
|
|
1353
|
-
* (
|
|
1354
|
-
*
|
|
1336
|
+
* () => {
|
|
1337
|
+
* console.log('指定区域内容发生了变化');
|
|
1355
1338
|
* }
|
|
1356
1339
|
* );
|
|
1357
|
-
*
|
|
1358
|
-
* // 停止监听
|
|
1359
|
-
* setTimeout(() => {
|
|
1360
|
-
* watcher.stop();
|
|
1361
|
-
* }, 60000);
|
|
1362
1340
|
* ```
|
|
1363
1341
|
*
|
|
1364
1342
|
* @example
|
|
1365
1343
|
* ```javascript
|
|
1366
|
-
* // 场景
|
|
1344
|
+
* // 场景 3:忽略光标闪烁,仅检测真实内容变化
|
|
1367
1345
|
* const watcher = targetWindow.watchChanges(
|
|
1368
1346
|
* { threshold: 0.02, stableFrames: 2 },
|
|
1369
|
-
* (
|
|
1347
|
+
* () => {
|
|
1370
1348
|
* console.log('窗口内容发生持久变化');
|
|
1371
1349
|
* }
|
|
1372
1350
|
* );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-rpa",
|
|
3
|
-
"version": "0.2.6-beta.
|
|
3
|
+
"version": "0.2.6-beta.2",
|
|
4
4
|
"description": "Rust-based RPA automation library for Node.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"commander": "^14.0.3"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@alibot/rust-rpa-win32-x64-msvc": "0.2.6-beta.
|
|
71
|
-
"@alibot/rust-rpa-win32-ia32-msvc": "0.2.6-beta.
|
|
72
|
-
"@alibot/rust-rpa-darwin-x64": "0.2.6-beta.
|
|
73
|
-
"@alibot/rust-rpa-darwin-arm64": "0.2.6-beta.
|
|
70
|
+
"@alibot/rust-rpa-win32-x64-msvc": "0.2.6-beta.2",
|
|
71
|
+
"@alibot/rust-rpa-win32-ia32-msvc": "0.2.6-beta.2",
|
|
72
|
+
"@alibot/rust-rpa-darwin-x64": "0.2.6-beta.2",
|
|
73
|
+
"@alibot/rust-rpa-darwin-arm64": "0.2.6-beta.2"
|
|
74
74
|
}
|
|
75
75
|
}
|