@midscene/computer 1.12.8-beta-20260916030003.0 → 1.12.8
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/dist/es/cli.mjs +25 -60
- package/dist/es/index.mjs +25 -60
- package/dist/lib/cli.js +25 -60
- package/dist/lib/index.js +25 -60
- package/dist/types/index.d.ts +0 -2
- package/package.json +3 -3
package/dist/es/cli.mjs
CHANGED
|
@@ -386,14 +386,6 @@ function resolveShiftedKey(character, keyboardLayout) {
|
|
|
386
386
|
if (/^[A-Z]$/.test(character)) return character.toLowerCase();
|
|
387
387
|
return 'en-US' === keyboardLayout ? US_SHIFTED_CHARACTER_KEYS.get(character) : void 0;
|
|
388
388
|
}
|
|
389
|
-
function clampPointerPointToSize(point, size) {
|
|
390
|
-
const maximumX = Math.max(0, Math.floor(size.width) - 1);
|
|
391
|
-
const maximumY = Math.max(0, Math.floor(size.height) - 1);
|
|
392
|
-
return {
|
|
393
|
-
x: Math.max(0, Math.min(point.x, maximumX)),
|
|
394
|
-
y: Math.max(0, Math.min(point.y, maximumY))
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
389
|
const POWERSHELL_TIMEOUT_MS = 15000;
|
|
398
390
|
const POWERSHELL_MAX_BUFFER = 67108864;
|
|
399
391
|
const WINDOWS_PHYSICAL_PIXEL_POWERSHELL_PREAMBLE = `
|
|
@@ -1128,20 +1120,6 @@ class ComputerDevice {
|
|
|
1128
1120
|
moveDisplayPointer(point, context, smooth) {
|
|
1129
1121
|
return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
|
|
1130
1122
|
}
|
|
1131
|
-
async performPointerDrag(from, to, duration) {
|
|
1132
|
-
const screenSize = await this.size();
|
|
1133
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
1134
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
1135
|
-
await this.moveDisplayPointer(boundedFrom, 'Mouse did not reach the drag start target');
|
|
1136
|
-
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1137
|
-
await this.inputDriver.delay(100);
|
|
1138
|
-
await this.moveDisplayPointer(boundedTo, 'Mouse did not reach the drag end target', {
|
|
1139
|
-
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1140
|
-
smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
|
|
1141
|
-
});
|
|
1142
|
-
await this.inputDriver.delay(100);
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
1123
|
async focusKeyboardTarget(element, delayMs) {
|
|
1146
1124
|
const [x, y] = element.center;
|
|
1147
1125
|
if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
|
|
@@ -1234,7 +1212,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1234
1212
|
}
|
|
1235
1213
|
async healthCheck(displays) {
|
|
1236
1214
|
console.log('[HealthCheck] Starting health check...');
|
|
1237
|
-
console.log("[HealthCheck] @midscene/computer v1.12.8
|
|
1215
|
+
console.log("[HealthCheck] @midscene/computer v1.12.8");
|
|
1238
1216
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1239
1217
|
const screenshotTimeout = 15000;
|
|
1240
1218
|
let timeoutId;
|
|
@@ -1582,9 +1560,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1582
1560
|
}
|
|
1583
1561
|
actionSpace() {
|
|
1584
1562
|
const defaultActions = [
|
|
1585
|
-
...defineActionsFromInputPrimitives(this.inputPrimitives
|
|
1586
|
-
size: ()=>this.size()
|
|
1587
|
-
})
|
|
1563
|
+
...defineActionsFromInputPrimitives(this.inputPrimitives)
|
|
1588
1564
|
];
|
|
1589
1565
|
const platformActions = Object.values(createPlatformActions());
|
|
1590
1566
|
const customActions = this.options?.customActions || [];
|
|
@@ -1715,11 +1691,15 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1715
1691
|
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1716
1692
|
},
|
|
1717
1693
|
dragAndDrop: async (from, to)=>{
|
|
1718
|
-
await this.
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1694
|
+
await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
|
|
1695
|
+
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1696
|
+
await this.inputDriver.delay(100);
|
|
1697
|
+
await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
|
|
1698
|
+
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1699
|
+
smoothDelay: SMOOTH_MOVE_DELAY_DRAG
|
|
1700
|
+
});
|
|
1701
|
+
await this.inputDriver.delay(100);
|
|
1702
|
+
});
|
|
1723
1703
|
}
|
|
1724
1704
|
},
|
|
1725
1705
|
keyboard: {
|
|
@@ -2220,9 +2200,7 @@ class RDPDevice {
|
|
|
2220
2200
|
}
|
|
2221
2201
|
actionSpace() {
|
|
2222
2202
|
const defaultActions = [
|
|
2223
|
-
...defineActionsFromInputPrimitives(this.inputPrimitives,
|
|
2224
|
-
size: ()=>this.size()
|
|
2225
|
-
}),
|
|
2203
|
+
...defineActionsFromInputPrimitives(this.inputPrimitives),
|
|
2226
2204
|
defineAction({
|
|
2227
2205
|
name: 'ListDisplays',
|
|
2228
2206
|
description: 'List all available displays/monitors',
|
|
@@ -2306,26 +2284,6 @@ class RDPDevice {
|
|
|
2306
2284
|
}
|
|
2307
2285
|
if (options?.settleDelayMs) await sleep(options.settleDelayMs);
|
|
2308
2286
|
}
|
|
2309
|
-
async performPointerDrag(from, to, duration) {
|
|
2310
|
-
const screenSize = await this.size();
|
|
2311
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
2312
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
2313
|
-
await this.movePointer(Math.round(boundedFrom.x), Math.round(boundedFrom.y), {
|
|
2314
|
-
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2315
|
-
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2316
|
-
});
|
|
2317
|
-
await this.backend.mouseButton('left', 'down');
|
|
2318
|
-
try {
|
|
2319
|
-
await sleep(DRAG_HOLD_DURATION);
|
|
2320
|
-
await this.movePointer(Math.round(boundedTo.x), Math.round(boundedTo.y), {
|
|
2321
|
-
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2322
|
-
stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
|
|
2323
|
-
});
|
|
2324
|
-
await sleep(DRAG_HOLD_DURATION);
|
|
2325
|
-
} finally{
|
|
2326
|
-
await this.backend.mouseButton('left', 'up');
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
2287
|
async performWheel(direction, amount, x, y) {
|
|
2330
2288
|
let remaining = Math.abs(amount);
|
|
2331
2289
|
if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
|
|
@@ -2379,11 +2337,18 @@ class RDPDevice {
|
|
|
2379
2337
|
});
|
|
2380
2338
|
},
|
|
2381
2339
|
dragAndDrop: async (from, to)=>{
|
|
2382
|
-
await this.
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2340
|
+
await this.movePointer(Math.round(from.x), Math.round(from.y), {
|
|
2341
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2342
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2343
|
+
});
|
|
2344
|
+
await this.backend.mouseButton('left', 'down');
|
|
2345
|
+
await sleep(DRAG_HOLD_DURATION);
|
|
2346
|
+
await this.movePointer(Math.round(to.x), Math.round(to.y), {
|
|
2347
|
+
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2348
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
|
|
2349
|
+
});
|
|
2350
|
+
await sleep(DRAG_HOLD_DURATION);
|
|
2351
|
+
await this.backend.mouseButton('left', 'up');
|
|
2387
2352
|
}
|
|
2388
2353
|
},
|
|
2389
2354
|
keyboard: {
|
|
@@ -2723,7 +2688,7 @@ const tools = new ComputerMidsceneTools({
|
|
|
2723
2688
|
});
|
|
2724
2689
|
runToolsCLI(tools, 'midscene-computer', {
|
|
2725
2690
|
stripPrefix: 'computer_',
|
|
2726
|
-
version: "1.12.8
|
|
2691
|
+
version: "1.12.8",
|
|
2727
2692
|
extraCommands: createReportCliCommands()
|
|
2728
2693
|
}).catch((e)=>{
|
|
2729
2694
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -386,14 +386,6 @@ function resolveShiftedKey(character, keyboardLayout) {
|
|
|
386
386
|
if (/^[A-Z]$/.test(character)) return character.toLowerCase();
|
|
387
387
|
return 'en-US' === keyboardLayout ? US_SHIFTED_CHARACTER_KEYS.get(character) : void 0;
|
|
388
388
|
}
|
|
389
|
-
function clampPointerPointToSize(point, size) {
|
|
390
|
-
const maximumX = Math.max(0, Math.floor(size.width) - 1);
|
|
391
|
-
const maximumY = Math.max(0, Math.floor(size.height) - 1);
|
|
392
|
-
return {
|
|
393
|
-
x: Math.max(0, Math.min(point.x, maximumX)),
|
|
394
|
-
y: Math.max(0, Math.min(point.y, maximumY))
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
389
|
const POWERSHELL_TIMEOUT_MS = 15000;
|
|
398
390
|
const POWERSHELL_MAX_BUFFER = 67108864;
|
|
399
391
|
const WINDOWS_PHYSICAL_PIXEL_POWERSHELL_PREAMBLE = `
|
|
@@ -1128,20 +1120,6 @@ class ComputerDevice {
|
|
|
1128
1120
|
moveDisplayPointer(point, context, smooth) {
|
|
1129
1121
|
return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
|
|
1130
1122
|
}
|
|
1131
|
-
async performPointerDrag(from, to, duration) {
|
|
1132
|
-
const screenSize = await this.size();
|
|
1133
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
1134
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
1135
|
-
await this.moveDisplayPointer(boundedFrom, 'Mouse did not reach the drag start target');
|
|
1136
|
-
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1137
|
-
await this.inputDriver.delay(100);
|
|
1138
|
-
await this.moveDisplayPointer(boundedTo, 'Mouse did not reach the drag end target', {
|
|
1139
|
-
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1140
|
-
smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
|
|
1141
|
-
});
|
|
1142
|
-
await this.inputDriver.delay(100);
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
1123
|
async focusKeyboardTarget(element, delayMs) {
|
|
1146
1124
|
const [x, y] = element.center;
|
|
1147
1125
|
if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
|
|
@@ -1234,7 +1212,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1234
1212
|
}
|
|
1235
1213
|
async healthCheck(displays) {
|
|
1236
1214
|
console.log('[HealthCheck] Starting health check...');
|
|
1237
|
-
console.log("[HealthCheck] @midscene/computer v1.12.8
|
|
1215
|
+
console.log("[HealthCheck] @midscene/computer v1.12.8");
|
|
1238
1216
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1239
1217
|
const screenshotTimeout = 15000;
|
|
1240
1218
|
let timeoutId;
|
|
@@ -1582,9 +1560,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1582
1560
|
}
|
|
1583
1561
|
actionSpace() {
|
|
1584
1562
|
const defaultActions = [
|
|
1585
|
-
...defineActionsFromInputPrimitives(this.inputPrimitives
|
|
1586
|
-
size: ()=>this.size()
|
|
1587
|
-
})
|
|
1563
|
+
...defineActionsFromInputPrimitives(this.inputPrimitives)
|
|
1588
1564
|
];
|
|
1589
1565
|
const platformActions = Object.values(createPlatformActions());
|
|
1590
1566
|
const customActions = this.options?.customActions || [];
|
|
@@ -1715,11 +1691,15 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1715
1691
|
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1716
1692
|
},
|
|
1717
1693
|
dragAndDrop: async (from, to)=>{
|
|
1718
|
-
await this.
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1694
|
+
await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
|
|
1695
|
+
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1696
|
+
await this.inputDriver.delay(100);
|
|
1697
|
+
await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
|
|
1698
|
+
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1699
|
+
smoothDelay: SMOOTH_MOVE_DELAY_DRAG
|
|
1700
|
+
});
|
|
1701
|
+
await this.inputDriver.delay(100);
|
|
1702
|
+
});
|
|
1723
1703
|
}
|
|
1724
1704
|
},
|
|
1725
1705
|
keyboard: {
|
|
@@ -2263,9 +2243,7 @@ class RDPDevice {
|
|
|
2263
2243
|
}
|
|
2264
2244
|
actionSpace() {
|
|
2265
2245
|
const defaultActions = [
|
|
2266
|
-
...defineActionsFromInputPrimitives(this.inputPrimitives,
|
|
2267
|
-
size: ()=>this.size()
|
|
2268
|
-
}),
|
|
2246
|
+
...defineActionsFromInputPrimitives(this.inputPrimitives),
|
|
2269
2247
|
defineAction({
|
|
2270
2248
|
name: 'ListDisplays',
|
|
2271
2249
|
description: 'List all available displays/monitors',
|
|
@@ -2349,26 +2327,6 @@ class RDPDevice {
|
|
|
2349
2327
|
}
|
|
2350
2328
|
if (options?.settleDelayMs) await sleep(options.settleDelayMs);
|
|
2351
2329
|
}
|
|
2352
|
-
async performPointerDrag(from, to, duration) {
|
|
2353
|
-
const screenSize = await this.size();
|
|
2354
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
2355
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
2356
|
-
await this.movePointer(Math.round(boundedFrom.x), Math.round(boundedFrom.y), {
|
|
2357
|
-
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2358
|
-
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2359
|
-
});
|
|
2360
|
-
await this.backend.mouseButton('left', 'down');
|
|
2361
|
-
try {
|
|
2362
|
-
await sleep(DRAG_HOLD_DURATION);
|
|
2363
|
-
await this.movePointer(Math.round(boundedTo.x), Math.round(boundedTo.y), {
|
|
2364
|
-
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2365
|
-
stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
|
|
2366
|
-
});
|
|
2367
|
-
await sleep(DRAG_HOLD_DURATION);
|
|
2368
|
-
} finally{
|
|
2369
|
-
await this.backend.mouseButton('left', 'up');
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
2330
|
async performWheel(direction, amount, x, y) {
|
|
2373
2331
|
let remaining = Math.abs(amount);
|
|
2374
2332
|
if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
|
|
@@ -2422,11 +2380,18 @@ class RDPDevice {
|
|
|
2422
2380
|
});
|
|
2423
2381
|
},
|
|
2424
2382
|
dragAndDrop: async (from, to)=>{
|
|
2425
|
-
await this.
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2383
|
+
await this.movePointer(Math.round(from.x), Math.round(from.y), {
|
|
2384
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2385
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2386
|
+
});
|
|
2387
|
+
await this.backend.mouseButton('left', 'down');
|
|
2388
|
+
await sleep(DRAG_HOLD_DURATION);
|
|
2389
|
+
await this.movePointer(Math.round(to.x), Math.round(to.y), {
|
|
2390
|
+
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2391
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
|
|
2392
|
+
});
|
|
2393
|
+
await sleep(DRAG_HOLD_DURATION);
|
|
2394
|
+
await this.backend.mouseButton('left', 'up');
|
|
2430
2395
|
}
|
|
2431
2396
|
},
|
|
2432
2397
|
keyboard: {
|
|
@@ -2762,7 +2727,7 @@ class ComputerMidsceneTools extends BaseMidsceneTools {
|
|
|
2762
2727
|
}
|
|
2763
2728
|
}
|
|
2764
2729
|
function version() {
|
|
2765
|
-
const currentVersion = "1.12.8
|
|
2730
|
+
const currentVersion = "1.12.8";
|
|
2766
2731
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
2767
2732
|
return currentVersion;
|
|
2768
2733
|
}
|
package/dist/lib/cli.js
CHANGED
|
@@ -411,14 +411,6 @@ function resolveShiftedKey(character, keyboardLayout) {
|
|
|
411
411
|
if (/^[A-Z]$/.test(character)) return character.toLowerCase();
|
|
412
412
|
return 'en-US' === keyboardLayout ? US_SHIFTED_CHARACTER_KEYS.get(character) : void 0;
|
|
413
413
|
}
|
|
414
|
-
function clampPointerPointToSize(point, size) {
|
|
415
|
-
const maximumX = Math.max(0, Math.floor(size.width) - 1);
|
|
416
|
-
const maximumY = Math.max(0, Math.floor(size.height) - 1);
|
|
417
|
-
return {
|
|
418
|
-
x: Math.max(0, Math.min(point.x, maximumX)),
|
|
419
|
-
y: Math.max(0, Math.min(point.y, maximumY))
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
414
|
const POWERSHELL_TIMEOUT_MS = 15000;
|
|
423
415
|
const POWERSHELL_MAX_BUFFER = 67108864;
|
|
424
416
|
const WINDOWS_PHYSICAL_PIXEL_POWERSHELL_PREAMBLE = `
|
|
@@ -1154,20 +1146,6 @@ class ComputerDevice {
|
|
|
1154
1146
|
moveDisplayPointer(point, context, smooth) {
|
|
1155
1147
|
return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
|
|
1156
1148
|
}
|
|
1157
|
-
async performPointerDrag(from, to, duration) {
|
|
1158
|
-
const screenSize = await this.size();
|
|
1159
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
1160
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
1161
|
-
await this.moveDisplayPointer(boundedFrom, 'Mouse did not reach the drag start target');
|
|
1162
|
-
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1163
|
-
await this.inputDriver.delay(100);
|
|
1164
|
-
await this.moveDisplayPointer(boundedTo, 'Mouse did not reach the drag end target', {
|
|
1165
|
-
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1166
|
-
smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
|
|
1167
|
-
});
|
|
1168
|
-
await this.inputDriver.delay(100);
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
1149
|
async focusKeyboardTarget(element, delayMs) {
|
|
1172
1150
|
const [x, y] = element.center;
|
|
1173
1151
|
if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
|
|
@@ -1260,7 +1238,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1260
1238
|
}
|
|
1261
1239
|
async healthCheck(displays) {
|
|
1262
1240
|
console.log('[HealthCheck] Starting health check...');
|
|
1263
|
-
console.log("[HealthCheck] @midscene/computer v1.12.8
|
|
1241
|
+
console.log("[HealthCheck] @midscene/computer v1.12.8");
|
|
1264
1242
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1265
1243
|
const screenshotTimeout = 15000;
|
|
1266
1244
|
let timeoutId;
|
|
@@ -1608,9 +1586,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1608
1586
|
}
|
|
1609
1587
|
actionSpace() {
|
|
1610
1588
|
const defaultActions = [
|
|
1611
|
-
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives
|
|
1612
|
-
size: ()=>this.size()
|
|
1613
|
-
})
|
|
1589
|
+
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives)
|
|
1614
1590
|
];
|
|
1615
1591
|
const platformActions = Object.values(createPlatformActions());
|
|
1616
1592
|
const customActions = this.options?.customActions || [];
|
|
@@ -1741,11 +1717,15 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1741
1717
|
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1742
1718
|
},
|
|
1743
1719
|
dragAndDrop: async (from, to)=>{
|
|
1744
|
-
await this.
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1720
|
+
await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
|
|
1721
|
+
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1722
|
+
await this.inputDriver.delay(100);
|
|
1723
|
+
await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
|
|
1724
|
+
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1725
|
+
smoothDelay: SMOOTH_MOVE_DELAY_DRAG
|
|
1726
|
+
});
|
|
1727
|
+
await this.inputDriver.delay(100);
|
|
1728
|
+
});
|
|
1749
1729
|
}
|
|
1750
1730
|
},
|
|
1751
1731
|
keyboard: {
|
|
@@ -2247,9 +2227,7 @@ class RDPDevice {
|
|
|
2247
2227
|
}
|
|
2248
2228
|
actionSpace() {
|
|
2249
2229
|
const defaultActions = [
|
|
2250
|
-
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives,
|
|
2251
|
-
size: ()=>this.size()
|
|
2252
|
-
}),
|
|
2230
|
+
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives),
|
|
2253
2231
|
(0, device_namespaceObject.defineAction)({
|
|
2254
2232
|
name: 'ListDisplays',
|
|
2255
2233
|
description: 'List all available displays/monitors',
|
|
@@ -2333,26 +2311,6 @@ class RDPDevice {
|
|
|
2333
2311
|
}
|
|
2334
2312
|
if (options?.settleDelayMs) await (0, utils_namespaceObject.sleep)(options.settleDelayMs);
|
|
2335
2313
|
}
|
|
2336
|
-
async performPointerDrag(from, to, duration) {
|
|
2337
|
-
const screenSize = await this.size();
|
|
2338
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
2339
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
2340
|
-
await this.movePointer(Math.round(boundedFrom.x), Math.round(boundedFrom.y), {
|
|
2341
|
-
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2342
|
-
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2343
|
-
});
|
|
2344
|
-
await this.backend.mouseButton('left', 'down');
|
|
2345
|
-
try {
|
|
2346
|
-
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2347
|
-
await this.movePointer(Math.round(boundedTo.x), Math.round(boundedTo.y), {
|
|
2348
|
-
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2349
|
-
stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
|
|
2350
|
-
});
|
|
2351
|
-
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2352
|
-
} finally{
|
|
2353
|
-
await this.backend.mouseButton('left', 'up');
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
2314
|
async performWheel(direction, amount, x, y) {
|
|
2357
2315
|
let remaining = Math.abs(amount);
|
|
2358
2316
|
if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
|
|
@@ -2406,11 +2364,18 @@ class RDPDevice {
|
|
|
2406
2364
|
});
|
|
2407
2365
|
},
|
|
2408
2366
|
dragAndDrop: async (from, to)=>{
|
|
2409
|
-
await this.
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2367
|
+
await this.movePointer(Math.round(from.x), Math.round(from.y), {
|
|
2368
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2369
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2370
|
+
});
|
|
2371
|
+
await this.backend.mouseButton('left', 'down');
|
|
2372
|
+
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2373
|
+
await this.movePointer(Math.round(to.x), Math.round(to.y), {
|
|
2374
|
+
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2375
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
|
|
2376
|
+
});
|
|
2377
|
+
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2378
|
+
await this.backend.mouseButton('left', 'up');
|
|
2414
2379
|
}
|
|
2415
2380
|
},
|
|
2416
2381
|
keyboard: {
|
|
@@ -2750,7 +2715,7 @@ const tools = new ComputerMidsceneTools({
|
|
|
2750
2715
|
});
|
|
2751
2716
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
|
|
2752
2717
|
stripPrefix: 'computer_',
|
|
2753
|
-
version: "1.12.8
|
|
2718
|
+
version: "1.12.8",
|
|
2754
2719
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
2755
2720
|
}).catch((e)=>{
|
|
2756
2721
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -437,14 +437,6 @@ function resolveShiftedKey(character, keyboardLayout) {
|
|
|
437
437
|
if (/^[A-Z]$/.test(character)) return character.toLowerCase();
|
|
438
438
|
return 'en-US' === keyboardLayout ? US_SHIFTED_CHARACTER_KEYS.get(character) : void 0;
|
|
439
439
|
}
|
|
440
|
-
function clampPointerPointToSize(point, size) {
|
|
441
|
-
const maximumX = Math.max(0, Math.floor(size.width) - 1);
|
|
442
|
-
const maximumY = Math.max(0, Math.floor(size.height) - 1);
|
|
443
|
-
return {
|
|
444
|
-
x: Math.max(0, Math.min(point.x, maximumX)),
|
|
445
|
-
y: Math.max(0, Math.min(point.y, maximumY))
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
440
|
const POWERSHELL_TIMEOUT_MS = 15000;
|
|
449
441
|
const POWERSHELL_MAX_BUFFER = 67108864;
|
|
450
442
|
const WINDOWS_PHYSICAL_PIXEL_POWERSHELL_PREAMBLE = `
|
|
@@ -1180,20 +1172,6 @@ class ComputerDevice {
|
|
|
1180
1172
|
moveDisplayPointer(point, context, smooth) {
|
|
1181
1173
|
return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
|
|
1182
1174
|
}
|
|
1183
|
-
async performPointerDrag(from, to, duration) {
|
|
1184
|
-
const screenSize = await this.size();
|
|
1185
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
1186
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
1187
|
-
await this.moveDisplayPointer(boundedFrom, 'Mouse did not reach the drag start target');
|
|
1188
|
-
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1189
|
-
await this.inputDriver.delay(100);
|
|
1190
|
-
await this.moveDisplayPointer(boundedTo, 'Mouse did not reach the drag end target', {
|
|
1191
|
-
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1192
|
-
smoothDelay: void 0 === duration ? SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / SMOOTH_MOVE_STEPS_DRAG))
|
|
1193
|
-
});
|
|
1194
|
-
await this.inputDriver.delay(100);
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
1175
|
async focusKeyboardTarget(element, delayMs) {
|
|
1198
1176
|
const [x, y] = element.center;
|
|
1199
1177
|
if ('darwin' === process.platform) await this.inputPrimitives.pointer.tap({
|
|
@@ -1286,7 +1264,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1286
1264
|
}
|
|
1287
1265
|
async healthCheck(displays) {
|
|
1288
1266
|
console.log('[HealthCheck] Starting health check...');
|
|
1289
|
-
console.log("[HealthCheck] @midscene/computer v1.12.8
|
|
1267
|
+
console.log("[HealthCheck] @midscene/computer v1.12.8");
|
|
1290
1268
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1291
1269
|
const screenshotTimeout = 15000;
|
|
1292
1270
|
let timeoutId;
|
|
@@ -1634,9 +1612,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1634
1612
|
}
|
|
1635
1613
|
actionSpace() {
|
|
1636
1614
|
const defaultActions = [
|
|
1637
|
-
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives
|
|
1638
|
-
size: ()=>this.size()
|
|
1639
|
-
})
|
|
1615
|
+
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives)
|
|
1640
1616
|
];
|
|
1641
1617
|
const platformActions = Object.values(createPlatformActions());
|
|
1642
1618
|
const customActions = this.options?.customActions || [];
|
|
@@ -1767,11 +1743,15 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1767
1743
|
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1768
1744
|
},
|
|
1769
1745
|
dragAndDrop: async (from, to)=>{
|
|
1770
|
-
await this.
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1746
|
+
await this.moveDisplayPointer(from, 'Mouse did not reach the drag start target');
|
|
1747
|
+
await this.inputDriver.withMouseButton('left', async ()=>{
|
|
1748
|
+
await this.inputDriver.delay(100);
|
|
1749
|
+
await this.moveDisplayPointer(to, 'Mouse did not reach the drag end target', {
|
|
1750
|
+
smoothSteps: SMOOTH_MOVE_STEPS_DRAG,
|
|
1751
|
+
smoothDelay: SMOOTH_MOVE_DELAY_DRAG
|
|
1752
|
+
});
|
|
1753
|
+
await this.inputDriver.delay(100);
|
|
1754
|
+
});
|
|
1775
1755
|
}
|
|
1776
1756
|
},
|
|
1777
1757
|
keyboard: {
|
|
@@ -2317,9 +2297,7 @@ class RDPDevice {
|
|
|
2317
2297
|
}
|
|
2318
2298
|
actionSpace() {
|
|
2319
2299
|
const defaultActions = [
|
|
2320
|
-
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives,
|
|
2321
|
-
size: ()=>this.size()
|
|
2322
|
-
}),
|
|
2300
|
+
...(0, device_namespaceObject.defineActionsFromInputPrimitives)(this.inputPrimitives),
|
|
2323
2301
|
(0, device_namespaceObject.defineAction)({
|
|
2324
2302
|
name: 'ListDisplays',
|
|
2325
2303
|
description: 'List all available displays/monitors',
|
|
@@ -2403,26 +2381,6 @@ class RDPDevice {
|
|
|
2403
2381
|
}
|
|
2404
2382
|
if (options?.settleDelayMs) await (0, utils_namespaceObject.sleep)(options.settleDelayMs);
|
|
2405
2383
|
}
|
|
2406
|
-
async performPointerDrag(from, to, duration) {
|
|
2407
|
-
const screenSize = await this.size();
|
|
2408
|
-
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
2409
|
-
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
2410
|
-
await this.movePointer(Math.round(boundedFrom.x), Math.round(boundedFrom.y), {
|
|
2411
|
-
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2412
|
-
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2413
|
-
});
|
|
2414
|
-
await this.backend.mouseButton('left', 'down');
|
|
2415
|
-
try {
|
|
2416
|
-
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2417
|
-
await this.movePointer(Math.round(boundedTo.x), Math.round(boundedTo.y), {
|
|
2418
|
-
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2419
|
-
stepDelayMs: void 0 === duration ? device_SMOOTH_MOVE_DELAY_DRAG : Math.max(0, Math.round(duration / device_SMOOTH_MOVE_STEPS_DRAG))
|
|
2420
|
-
});
|
|
2421
|
-
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2422
|
-
} finally{
|
|
2423
|
-
await this.backend.mouseButton('left', 'up');
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
2384
|
async performWheel(direction, amount, x, y) {
|
|
2427
2385
|
let remaining = Math.abs(amount);
|
|
2428
2386
|
if (0 === remaining) remaining = DEFAULT_SCROLL_STEP_AMOUNT;
|
|
@@ -2476,11 +2434,18 @@ class RDPDevice {
|
|
|
2476
2434
|
});
|
|
2477
2435
|
},
|
|
2478
2436
|
dragAndDrop: async (from, to)=>{
|
|
2479
|
-
await this.
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2437
|
+
await this.movePointer(Math.round(from.x), Math.round(from.y), {
|
|
2438
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2439
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2440
|
+
});
|
|
2441
|
+
await this.backend.mouseButton('left', 'down');
|
|
2442
|
+
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2443
|
+
await this.movePointer(Math.round(to.x), Math.round(to.y), {
|
|
2444
|
+
steps: device_SMOOTH_MOVE_STEPS_DRAG,
|
|
2445
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_DRAG
|
|
2446
|
+
});
|
|
2447
|
+
await (0, utils_namespaceObject.sleep)(DRAG_HOLD_DURATION);
|
|
2448
|
+
await this.backend.mouseButton('left', 'up');
|
|
2484
2449
|
}
|
|
2485
2450
|
},
|
|
2486
2451
|
keyboard: {
|
|
@@ -2820,7 +2785,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2820
2785
|
}
|
|
2821
2786
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
2822
2787
|
function version() {
|
|
2823
|
-
const currentVersion = "1.12.8
|
|
2788
|
+
const currentVersion = "1.12.8";
|
|
2824
2789
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
2825
2790
|
return currentVersion;
|
|
2826
2791
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -89,7 +89,6 @@ export declare class ComputerDevice implements AbstractInterface {
|
|
|
89
89
|
constructor(options?: ComputerDeviceOpt);
|
|
90
90
|
private moveGlobalPointer;
|
|
91
91
|
private moveDisplayPointer;
|
|
92
|
-
private performPointerDrag;
|
|
93
92
|
private focusKeyboardTarget;
|
|
94
93
|
describe(): string;
|
|
95
94
|
/**
|
|
@@ -389,7 +388,6 @@ export declare class RDPDevice implements AbstractInterface {
|
|
|
389
388
|
private edgeScrollDirection;
|
|
390
389
|
private defaultScrollDistance;
|
|
391
390
|
private movePointer;
|
|
392
|
-
private performPointerDrag;
|
|
393
391
|
private performWheel;
|
|
394
392
|
}
|
|
395
393
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer",
|
|
3
|
-
"version": "1.12.8
|
|
3
|
+
"version": "1.12.8",
|
|
4
4
|
"description": "Midscene.js Computer Desktop Automation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@computer-use/libnut": "^4.2.0",
|
|
34
34
|
"clipboardy": "^4.0.0",
|
|
35
35
|
"screenshot-desktop": "^1.15.3",
|
|
36
|
-
"@midscene/
|
|
37
|
-
"@midscene/
|
|
36
|
+
"@midscene/core": "1.12.8",
|
|
37
|
+
"@midscene/shared": "1.12.8"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
40
|
"node-mac-permissions": "2.5.0"
|