@midscene/android 0.28.8 → 0.28.9-beta-20250916162508.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/dist/es/index.mjs +10 -4
- package/dist/lib/index.js +9 -3
- package/dist/types/index.d.ts +2 -0
- package/package.json +3 -3
package/dist/es/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import node_assert from "node:assert";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
2
|
import node_fs from "node:fs";
|
|
4
3
|
import { createRequire } from "node:module";
|
|
5
4
|
import node_path from "node:path";
|
|
@@ -9,7 +8,7 @@ import { getTmpFile, sleep } from "@midscene/core/utils";
|
|
|
9
8
|
import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, globalConfigManager, overrideAIConfig } from "@midscene/shared/env";
|
|
10
9
|
import { createImgBase64ByFormat, isValidPNGImageBuffer, resizeAndConvertImgBuffer } from "@midscene/shared/img";
|
|
11
10
|
import { getDebug } from "@midscene/shared/logger";
|
|
12
|
-
import { repeat } from "@midscene/shared/utils";
|
|
11
|
+
import { repeat, uuid } from "@midscene/shared/utils";
|
|
13
12
|
import { ADB } from "appium-adb";
|
|
14
13
|
import { Agent } from "@midscene/core/agent";
|
|
15
14
|
function _define_property(obj, key, value) {
|
|
@@ -28,7 +27,7 @@ const defaultNormalScrollDuration = 1000;
|
|
|
28
27
|
const debugDevice = getDebug('android:device');
|
|
29
28
|
class AndroidDevice {
|
|
30
29
|
actionSpace() {
|
|
31
|
-
|
|
30
|
+
const defaultActions = [
|
|
32
31
|
defineActionTap(async (param)=>{
|
|
33
32
|
const element = param.locate;
|
|
34
33
|
node_assert(element, 'Element not found, cannot tap');
|
|
@@ -162,6 +161,11 @@ class AndroidDevice {
|
|
|
162
161
|
}
|
|
163
162
|
})
|
|
164
163
|
];
|
|
164
|
+
const customActions = this.customActions || [];
|
|
165
|
+
return [
|
|
166
|
+
...defaultActions,
|
|
167
|
+
...customActions
|
|
168
|
+
];
|
|
165
169
|
}
|
|
166
170
|
describe() {
|
|
167
171
|
return this.description || `DeviceId: ${this.deviceId}`;
|
|
@@ -469,7 +473,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
469
473
|
const { width, height } = await this.size();
|
|
470
474
|
const adb = await this.getAdb();
|
|
471
475
|
let screenshotBuffer;
|
|
472
|
-
const androidScreenshotPath = `/data/local/tmp/midscene_screenshot_${
|
|
476
|
+
const androidScreenshotPath = `/data/local/tmp/midscene_screenshot_${uuid()}.png`;
|
|
473
477
|
const useShellScreencap = 'number' == typeof (null == (_this_options = this.options) ? void 0 : _this_options.displayId);
|
|
474
478
|
try {
|
|
475
479
|
if (useShellScreencap) {
|
|
@@ -914,12 +918,14 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
914
918
|
_define_property(this, "connectingAdb", null);
|
|
915
919
|
_define_property(this, "destroyed", false);
|
|
916
920
|
_define_property(this, "description", void 0);
|
|
921
|
+
_define_property(this, "customActions", void 0);
|
|
917
922
|
_define_property(this, "interfaceType", 'android');
|
|
918
923
|
_define_property(this, "uri", void 0);
|
|
919
924
|
_define_property(this, "options", void 0);
|
|
920
925
|
node_assert(deviceId, 'deviceId is required for AndroidDevice');
|
|
921
926
|
this.deviceId = deviceId;
|
|
922
927
|
this.options = options;
|
|
928
|
+
this.customActions = null == options ? void 0 : options.customActions;
|
|
923
929
|
}
|
|
924
930
|
}
|
|
925
931
|
const debugUtils = getDebug('android:utils');
|
package/dist/lib/index.js
CHANGED
|
@@ -44,7 +44,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
44
44
|
});
|
|
45
45
|
const external_node_assert_namespaceObject = require("node:assert");
|
|
46
46
|
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
47
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
48
47
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
49
48
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
50
49
|
const external_node_module_namespaceObject = require("node:module");
|
|
@@ -74,7 +73,7 @@ const defaultNormalScrollDuration = 1000;
|
|
|
74
73
|
const debugDevice = (0, logger_namespaceObject.getDebug)('android:device');
|
|
75
74
|
class AndroidDevice {
|
|
76
75
|
actionSpace() {
|
|
77
|
-
|
|
76
|
+
const defaultActions = [
|
|
78
77
|
(0, device_namespaceObject.defineActionTap)(async (param)=>{
|
|
79
78
|
const element = param.locate;
|
|
80
79
|
external_node_assert_default()(element, 'Element not found, cannot tap');
|
|
@@ -208,6 +207,11 @@ class AndroidDevice {
|
|
|
208
207
|
}
|
|
209
208
|
})
|
|
210
209
|
];
|
|
210
|
+
const customActions = this.customActions || [];
|
|
211
|
+
return [
|
|
212
|
+
...defaultActions,
|
|
213
|
+
...customActions
|
|
214
|
+
];
|
|
211
215
|
}
|
|
212
216
|
describe() {
|
|
213
217
|
return this.description || `DeviceId: ${this.deviceId}`;
|
|
@@ -515,7 +519,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
515
519
|
const { width, height } = await this.size();
|
|
516
520
|
const adb = await this.getAdb();
|
|
517
521
|
let screenshotBuffer;
|
|
518
|
-
const androidScreenshotPath = `/data/local/tmp/midscene_screenshot_${(0,
|
|
522
|
+
const androidScreenshotPath = `/data/local/tmp/midscene_screenshot_${(0, shared_utils_namespaceObject.uuid)()}.png`;
|
|
519
523
|
const useShellScreencap = 'number' == typeof (null == (_this_options = this.options) ? void 0 : _this_options.displayId);
|
|
520
524
|
try {
|
|
521
525
|
if (useShellScreencap) {
|
|
@@ -960,12 +964,14 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
960
964
|
_define_property(this, "connectingAdb", null);
|
|
961
965
|
_define_property(this, "destroyed", false);
|
|
962
966
|
_define_property(this, "description", void 0);
|
|
967
|
+
_define_property(this, "customActions", void 0);
|
|
963
968
|
_define_property(this, "interfaceType", 'android');
|
|
964
969
|
_define_property(this, "uri", void 0);
|
|
965
970
|
_define_property(this, "options", void 0);
|
|
966
971
|
external_node_assert_default()(deviceId, 'deviceId is required for AndroidDevice');
|
|
967
972
|
this.deviceId = deviceId;
|
|
968
973
|
this.options = options;
|
|
974
|
+
this.customActions = null == options ? void 0 : options.customActions;
|
|
969
975
|
}
|
|
970
976
|
}
|
|
971
977
|
const agent_namespaceObject = require("@midscene/core/agent");
|
package/dist/types/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare class AndroidDevice implements AbstractInterface {
|
|
|
26
26
|
private connectingAdb;
|
|
27
27
|
private destroyed;
|
|
28
28
|
private description;
|
|
29
|
+
private customActions?;
|
|
29
30
|
interfaceType: InterfaceType;
|
|
30
31
|
uri: string | undefined;
|
|
31
32
|
options?: AndroidDeviceOpt;
|
|
@@ -124,6 +125,7 @@ declare type AndroidDeviceOpt = {
|
|
|
124
125
|
displayId?: number;
|
|
125
126
|
usePhysicalDisplayIdForScreenshot?: boolean;
|
|
126
127
|
usePhysicalDisplayIdForDisplayLookup?: boolean;
|
|
128
|
+
customActions?: DeviceAction<any>[];
|
|
127
129
|
} & AndroidDeviceInputOpt;
|
|
128
130
|
|
|
129
131
|
export declare function getConnectedDevices(): Promise<Device[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.9-beta-20250916162508.0",
|
|
4
4
|
"description": "Android automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Android UI automation",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"appium-adb": "12.12.1",
|
|
30
|
-
"@midscene/
|
|
31
|
-
"@midscene/
|
|
30
|
+
"@midscene/core": "0.28.9-beta-20250916162508.0",
|
|
31
|
+
"@midscene/shared": "0.28.9-beta-20250916162508.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@microsoft/api-extractor": "^7.52.10",
|