@midscene/android 0.30.3-beta-20251011125638.0 → 0.30.3-beta-20251015092615.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
@@ -3,7 +3,7 @@ import node_fs from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import node_path from "node:path";
5
5
  import { getMidsceneLocationSchema, z } from "@midscene/core";
6
- import { defineAction, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionScroll, defineActionTap } from "@midscene/core/device";
6
+ import { defineAction, defineActionClearInput, defineActionDoubleClick, defineActionDragAndDrop, defineActionKeyboardPress, defineActionScroll, defineActionTap } from "@midscene/core/device";
7
7
  import { getTmpFile, sleep } from "@midscene/core/utils";
8
8
  import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, globalConfigManager, overrideAIConfig } from "@midscene/shared/env";
9
9
  import { createImgBase64ByFormat, isValidPNGImageBuffer } from "@midscene/shared/img";
@@ -45,17 +45,23 @@ class AndroidDevice {
45
45
  description: 'Input text into the input field',
46
46
  interfaceAlias: 'aiInput',
47
47
  paramSchema: z.object({
48
- value: z.string().describe('The final that should be filled in the input box. No matter what modifications are required, just provide the final value to replace the existing input value. Giving a blank string means clear the input field.'),
48
+ value: z.string().describe('The text to input. Provide the final content for replace/append modes, or an empty string when using clear mode to remove existing text.'),
49
49
  autoDismissKeyboard: z.boolean().optional().describe('If true, the keyboard will be dismissed after the input is completed. Do not set it unless the user asks you to do so.'),
50
+ mode: z["enum"]([
51
+ 'replace',
52
+ 'clear',
53
+ 'append'
54
+ ]).default('replace').optional().describe('Input mode: "replace" (default) - clear the field and input the value; "append" - append the value to existing content; "clear" - clear the field without inputting new text.'),
50
55
  locate: getMidsceneLocationSchema().describe('The input field to be filled').optional()
51
56
  }),
52
57
  call: async (param)=>{
53
58
  var _this_options;
54
59
  const element = param.locate;
55
60
  if (element) {
56
- await this.clearInput(element);
57
- if (!param || !param.value) return;
61
+ if ('append' !== param.mode) await this.clearInput(element);
58
62
  }
63
+ if ('clear' === param.mode) return;
64
+ if (!param || !param.value) return;
59
65
  const autoDismissKeyboard = param.autoDismissKeyboard ?? (null == (_this_options = this.options) ? void 0 : _this_options.autoDismissKeyboard);
60
66
  await this.keyboardType(param.value, {
61
67
  autoDismissKeyboard
@@ -161,6 +167,11 @@ class AndroidDevice {
161
167
  else if ('up' === param.direction) await this.pullUp(startPoint, param.distance, param.duration);
162
168
  else throw new Error(`Unknown pull direction: ${param.direction}`);
163
169
  }
170
+ }),
171
+ defineActionClearInput(async (param)=>{
172
+ const element = param.locate;
173
+ node_assert(element, 'Element not found, cannot clear input');
174
+ await this.clearInput(element);
164
175
  })
165
176
  ];
166
177
  const customActions = this.customActions || [];
package/dist/lib/index.js CHANGED
@@ -91,17 +91,23 @@ class AndroidDevice {
91
91
  description: 'Input text into the input field',
92
92
  interfaceAlias: 'aiInput',
93
93
  paramSchema: core_namespaceObject.z.object({
94
- value: core_namespaceObject.z.string().describe('The final that should be filled in the input box. No matter what modifications are required, just provide the final value to replace the existing input value. Giving a blank string means clear the input field.'),
94
+ value: core_namespaceObject.z.string().describe('The text to input. Provide the final content for replace/append modes, or an empty string when using clear mode to remove existing text.'),
95
95
  autoDismissKeyboard: core_namespaceObject.z.boolean().optional().describe('If true, the keyboard will be dismissed after the input is completed. Do not set it unless the user asks you to do so.'),
96
+ mode: core_namespaceObject.z["enum"]([
97
+ 'replace',
98
+ 'clear',
99
+ 'append'
100
+ ]).default('replace').optional().describe('Input mode: "replace" (default) - clear the field and input the value; "append" - append the value to existing content; "clear" - clear the field without inputting new text.'),
96
101
  locate: (0, core_namespaceObject.getMidsceneLocationSchema)().describe('The input field to be filled').optional()
97
102
  }),
98
103
  call: async (param)=>{
99
104
  var _this_options;
100
105
  const element = param.locate;
101
106
  if (element) {
102
- await this.clearInput(element);
103
- if (!param || !param.value) return;
107
+ if ('append' !== param.mode) await this.clearInput(element);
104
108
  }
109
+ if ('clear' === param.mode) return;
110
+ if (!param || !param.value) return;
105
111
  const autoDismissKeyboard = param.autoDismissKeyboard ?? (null == (_this_options = this.options) ? void 0 : _this_options.autoDismissKeyboard);
106
112
  await this.keyboardType(param.value, {
107
113
  autoDismissKeyboard
@@ -207,6 +213,11 @@ class AndroidDevice {
207
213
  else if ('up' === param.direction) await this.pullUp(startPoint, param.distance, param.duration);
208
214
  else throw new Error(`Unknown pull direction: ${param.direction}`);
209
215
  }
216
+ }),
217
+ (0, device_namespaceObject.defineActionClearInput)(async (param)=>{
218
+ const element = param.locate;
219
+ external_node_assert_default()(element, 'Element not found, cannot clear input');
220
+ await this.clearInput(element);
210
221
  })
211
222
  ];
212
223
  const customActions = this.customActions || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "0.30.3-beta-20251011125638.0",
3
+ "version": "0.30.3-beta-20251015092615.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/shared": "0.30.3-beta-20251011125638.0",
31
- "@midscene/core": "0.30.3-beta-20251011125638.0"
30
+ "@midscene/core": "0.30.3-beta-20251015092615.0",
31
+ "@midscene/shared": "0.30.3-beta-20251015092615.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@rslib/core": "^0.11.2",
@@ -37,7 +37,7 @@
37
37
  "typescript": "^5.8.3",
38
38
  "tsx": "^4.19.2",
39
39
  "vitest": "3.0.5",
40
- "@midscene/playground": "0.30.3-beta-20251011125638.0"
40
+ "@midscene/playground": "0.30.3-beta-20251015092615.0"
41
41
  },
42
42
  "license": "MIT",
43
43
  "scripts": {