@midscene/android 1.0.1-beta-20251103074550.0 → 1.0.1-beta-20251104101357.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 CHANGED
@@ -105,30 +105,6 @@ class AndroidDevice {
105
105
  defineActionKeyboardPress(async (param)=>{
106
106
  await this.keyboardPress(param.keyName);
107
107
  }),
108
- defineAction({
109
- name: 'AndroidBackButton',
110
- description: 'Trigger the system "back" operation on Android devices',
111
- paramSchema: z.object({}),
112
- call: async ()=>{
113
- await this.back();
114
- }
115
- }),
116
- defineAction({
117
- name: 'AndroidHomeButton',
118
- description: 'Trigger the system "home" operation on Android devices',
119
- paramSchema: z.object({}),
120
- call: async ()=>{
121
- await this.home();
122
- }
123
- }),
124
- defineAction({
125
- name: 'AndroidRecentAppsButton',
126
- description: 'Trigger the system "recent apps" operation on Android devices',
127
- paramSchema: z.object({}),
128
- call: async ()=>{
129
- await this.recentApps();
130
- }
131
- }),
132
108
  defineAction({
133
109
  name: 'AndroidLongPress',
134
110
  description: 'Trigger a long press on the screen at specified coordinates on Android devices',
@@ -968,6 +944,30 @@ const createPlatformActions = (device)=>({
968
944
  call: async (param)=>{
969
945
  await device.launch(param);
970
946
  }
947
+ }),
948
+ AndroidBackButton: defineAction({
949
+ name: 'AndroidBackButton',
950
+ description: 'Trigger the system "back" operation on Android devices',
951
+ paramSchema: z["void"]().describe('No parameters required'),
952
+ call: async ()=>{
953
+ await device.back();
954
+ }
955
+ }),
956
+ AndroidHomeButton: defineAction({
957
+ name: 'AndroidHomeButton',
958
+ description: 'Trigger the system "home" operation on Android devices',
959
+ paramSchema: z["void"]().describe('No parameters required'),
960
+ call: async ()=>{
961
+ await device.home();
962
+ }
963
+ }),
964
+ AndroidRecentAppsButton: defineAction({
965
+ name: 'AndroidRecentAppsButton',
966
+ description: 'Trigger the system "recent apps" operation on Android devices',
967
+ paramSchema: z["void"]().describe('No parameters required'),
968
+ call: async ()=>{
969
+ await device.recentApps();
970
+ }
971
971
  })
972
972
  });
973
973
  const debugUtils = getDebug('android:utils');
@@ -998,10 +998,17 @@ function agent_define_property(obj, key, value) {
998
998
  }
999
999
  const debugAgent = getDebug('android:agent');
1000
1000
  class AndroidAgent extends Agent {
1001
+ createActionWrapper(name) {
1002
+ const action = this.wrapActionInActionSpace(name);
1003
+ return (...args)=>action(args[0]);
1004
+ }
1001
1005
  constructor(device, opts){
1002
- super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0);
1003
- this.launch = this.wrapActionInActionSpace('Launch');
1004
- this.runAdbShell = this.wrapActionInActionSpace('RunAdbShell');
1006
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
1007
+ this.launch = this.createActionWrapper('Launch');
1008
+ this.runAdbShell = this.createActionWrapper('RunAdbShell');
1009
+ this.back = this.createActionWrapper('AndroidBackButton');
1010
+ this.home = this.createActionWrapper('AndroidHomeButton');
1011
+ this.recentApps = this.createActionWrapper('AndroidRecentAppsButton');
1005
1012
  }
1006
1013
  }
1007
1014
  async function agentFromAdbDevice(deviceId, opts) {
package/dist/lib/index.js CHANGED
@@ -151,30 +151,6 @@ class AndroidDevice {
151
151
  (0, device_namespaceObject.defineActionKeyboardPress)(async (param)=>{
152
152
  await this.keyboardPress(param.keyName);
153
153
  }),
154
- (0, device_namespaceObject.defineAction)({
155
- name: 'AndroidBackButton',
156
- description: 'Trigger the system "back" operation on Android devices',
157
- paramSchema: core_namespaceObject.z.object({}),
158
- call: async ()=>{
159
- await this.back();
160
- }
161
- }),
162
- (0, device_namespaceObject.defineAction)({
163
- name: 'AndroidHomeButton',
164
- description: 'Trigger the system "home" operation on Android devices',
165
- paramSchema: core_namespaceObject.z.object({}),
166
- call: async ()=>{
167
- await this.home();
168
- }
169
- }),
170
- (0, device_namespaceObject.defineAction)({
171
- name: 'AndroidRecentAppsButton',
172
- description: 'Trigger the system "recent apps" operation on Android devices',
173
- paramSchema: core_namespaceObject.z.object({}),
174
- call: async ()=>{
175
- await this.recentApps();
176
- }
177
- }),
178
154
  (0, device_namespaceObject.defineAction)({
179
155
  name: 'AndroidLongPress',
180
156
  description: 'Trigger a long press on the screen at specified coordinates on Android devices',
@@ -1014,6 +990,30 @@ const createPlatformActions = (device)=>({
1014
990
  call: async (param)=>{
1015
991
  await device.launch(param);
1016
992
  }
993
+ }),
994
+ AndroidBackButton: (0, device_namespaceObject.defineAction)({
995
+ name: 'AndroidBackButton',
996
+ description: 'Trigger the system "back" operation on Android devices',
997
+ paramSchema: core_namespaceObject.z["void"]().describe('No parameters required'),
998
+ call: async ()=>{
999
+ await device.back();
1000
+ }
1001
+ }),
1002
+ AndroidHomeButton: (0, device_namespaceObject.defineAction)({
1003
+ name: 'AndroidHomeButton',
1004
+ description: 'Trigger the system "home" operation on Android devices',
1005
+ paramSchema: core_namespaceObject.z["void"]().describe('No parameters required'),
1006
+ call: async ()=>{
1007
+ await device.home();
1008
+ }
1009
+ }),
1010
+ AndroidRecentAppsButton: (0, device_namespaceObject.defineAction)({
1011
+ name: 'AndroidRecentAppsButton',
1012
+ description: 'Trigger the system "recent apps" operation on Android devices',
1013
+ paramSchema: core_namespaceObject.z["void"]().describe('No parameters required'),
1014
+ call: async ()=>{
1015
+ await device.recentApps();
1016
+ }
1017
1017
  })
1018
1018
  });
1019
1019
  const agent_namespaceObject = require("@midscene/core/agent");
@@ -1045,10 +1045,17 @@ function agent_define_property(obj, key, value) {
1045
1045
  }
1046
1046
  const debugAgent = (0, logger_namespaceObject.getDebug)('android:agent');
1047
1047
  class AndroidAgent extends agent_namespaceObject.Agent {
1048
+ createActionWrapper(name) {
1049
+ const action = this.wrapActionInActionSpace(name);
1050
+ return (...args)=>action(args[0]);
1051
+ }
1048
1052
  constructor(device, opts){
1049
- super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0);
1050
- this.launch = this.wrapActionInActionSpace('Launch');
1051
- this.runAdbShell = this.wrapActionInActionSpace('RunAdbShell');
1053
+ super(device, opts), agent_define_property(this, "launch", void 0), agent_define_property(this, "runAdbShell", void 0), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
1054
+ this.launch = this.createActionWrapper('Launch');
1055
+ this.runAdbShell = this.createActionWrapper('RunAdbShell');
1056
+ this.back = this.createActionWrapper('AndroidBackButton');
1057
+ this.home = this.createActionWrapper('AndroidHomeButton');
1058
+ this.recentApps = this.createActionWrapper('AndroidRecentAppsButton');
1052
1059
  }
1053
1060
  }
1054
1061
  async function agentFromAdbDevice(deviceId, opts) {
@@ -15,6 +15,8 @@ import { Point } from '@midscene/core';
15
15
  import { Size } from '@midscene/core';
16
16
  import { z } from '@midscene/core';
17
17
 
18
+ declare type ActionArgs<T extends DeviceAction> = [ActionParam<T>] extends [undefined] ? [] : [ActionParam<T>];
19
+
18
20
  export declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
19
21
 
20
22
  export declare class AndroidAgent extends Agent<AndroidDevice> {
@@ -26,7 +28,20 @@ export declare class AndroidAgent extends Agent<AndroidDevice> {
26
28
  * Execute ADB shell command on Android device
27
29
  */
28
30
  runAdbShell: WrappedAction<DeviceActionRunAdbShell>;
31
+ /**
32
+ * Trigger the system back operation on Android devices
33
+ */
34
+ back: WrappedAction<DeviceActionAndroidBackButton>;
35
+ /**
36
+ * Trigger the system home operation on Android devices
37
+ */
38
+ home: WrappedAction<DeviceActionAndroidHomeButton>;
39
+ /**
40
+ * Trigger the system recent apps operation on Android devices
41
+ */
42
+ recentApps: WrappedAction<DeviceActionAndroidRecentAppsButton>;
29
43
  constructor(device: AndroidDevice, opts?: AndroidAgentOpt);
44
+ private createActionWrapper;
30
45
  }
31
46
 
32
47
  declare type AndroidAgentOpt = AgentOpt;
@@ -126,6 +141,12 @@ export declare class AndroidDevice implements AbstractInterface {
126
141
  hideKeyboard(options?: AndroidDeviceInputOpt, timeoutMs?: number): Promise<boolean>;
127
142
  }
128
143
 
144
+ declare type DeviceActionAndroidBackButton = DeviceAction<void, void>;
145
+
146
+ declare type DeviceActionAndroidHomeButton = DeviceAction<void, void>;
147
+
148
+ declare type DeviceActionAndroidRecentAppsButton = DeviceAction<void, void>;
149
+
129
150
  declare type DeviceActionLaunch = DeviceAction<LaunchParam, void>;
130
151
 
131
152
  declare type DeviceActionRunAdbShell = DeviceAction<RunAdbShellParam, string>;
@@ -149,6 +170,6 @@ declare const runAdbShellParamSchema: z.ZodString;
149
170
  /**
150
171
  * Helper type to convert DeviceAction to wrapped method signature
151
172
  */
152
- declare type WrappedAction<T extends DeviceAction> = (param: ActionParam<T>) => Promise<ActionReturn<T>>;
173
+ declare type WrappedAction<T extends DeviceAction> = (...args: ActionArgs<T>) => Promise<ActionReturn<T>>;
153
174
 
154
175
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "1.0.1-beta-20251103074550.0",
3
+ "version": "1.0.1-beta-20251104101357.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/core": "1.0.1-beta-20251103074550.0",
31
- "@midscene/shared": "1.0.1-beta-20251103074550.0"
30
+ "@midscene/shared": "1.0.1-beta-20251104101357.0",
31
+ "@midscene/core": "1.0.1-beta-20251104101357.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@rslib/core": "^0.11.2",
@@ -38,7 +38,7 @@
38
38
  "tsx": "^4.19.2",
39
39
  "vitest": "3.0.5",
40
40
  "zod": "3.24.3",
41
- "@midscene/playground": "1.0.1-beta-20251103074550.0"
41
+ "@midscene/playground": "1.0.1-beta-20251104101357.0"
42
42
  },
43
43
  "license": "MIT",
44
44
  "scripts": {