@midscene/android 0.17.6-beta-20250605050844.0 → 0.18.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.
@@ -1,10 +1,15 @@
1
1
  import { PageType, Size, Point } from '@midscene/core';
2
2
  import { ElementInfo } from '@midscene/shared/extractor';
3
- import { AndroidDevicePage } from '@midscene/web';
3
+ import { AndroidDevicePage, AndroidDeviceInputOpt } from '@midscene/web';
4
4
  import { ADB, Device } from 'appium-adb';
5
5
  import { PageAgent, PageAgentOpt } from '@midscene/web/agent';
6
6
  export { overrideAIConfig } from '@midscene/shared/env';
7
7
 
8
+ type AndroidDeviceOpt = {
9
+ androidAdbPath?: string;
10
+ remoteAdbHost?: string;
11
+ remoteAdbPort?: number;
12
+ } & AndroidDeviceInputOpt;
8
13
  declare class AndroidDevice implements AndroidDevicePage {
9
14
  private deviceId;
10
15
  private screenSize;
@@ -14,16 +19,8 @@ declare class AndroidDevice implements AndroidDevicePage {
14
19
  private connectingAdb;
15
20
  pageType: PageType;
16
21
  uri: string | undefined;
17
- options?: {
18
- androidAdbPath?: string;
19
- remoteAdbHost?: string;
20
- remoteAdbPort?: number;
21
- };
22
- constructor(deviceId: string, options?: {
23
- androidAdbPath?: string;
24
- remoteAdbHost?: string;
25
- remoteAdbPort?: number;
26
- });
22
+ options?: AndroidDeviceOpt;
23
+ constructor(deviceId: string, options?: AndroidDeviceOpt);
27
24
  connect(): Promise<ADB>;
28
25
  getAdb(): Promise<ADB>;
29
26
  private createAdbProxy;
@@ -49,7 +46,7 @@ declare class AndroidDevice implements AndroidDevicePage {
49
46
  }) => Promise<void>;
50
47
  };
51
48
  get keyboard(): {
52
- type: (text: string) => Promise<void>;
49
+ type: (text: string, options?: AndroidDeviceInputOpt) => Promise<void>;
53
50
  press: (action: {
54
51
  key: string;
55
52
  command?: string;
@@ -85,11 +82,12 @@ declare class AndroidDevice implements AndroidDevicePage {
85
82
  getElementInfoByXpath(xpath: string): Promise<ElementInfo>;
86
83
  }
87
84
 
85
+ type AndroidAgentOpt = PageAgentOpt;
88
86
  declare class AndroidAgent extends PageAgent<AndroidDevice> {
89
- constructor(page: AndroidDevice, opts?: PageAgentOpt);
87
+ constructor(page: AndroidDevice, opts?: AndroidAgentOpt);
90
88
  launch(uri: string): Promise<void>;
91
89
  }
92
- declare function agentFromAdbDevice(deviceId?: string, opts?: PageAgentOpt): Promise<AndroidAgent>;
90
+ declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
93
91
 
94
92
  declare function getConnectedDevices(): Promise<Device[]>;
95
93
 
package/dist/es/index.js CHANGED
@@ -271,7 +271,7 @@ ${Object.keys(size).filter((key) => size[key]).map(
271
271
  }
272
272
  get keyboard() {
273
273
  return {
274
- type: (text) => this.keyboardType(text),
274
+ type: (text, options) => this.keyboardType(text, options),
275
275
  press: (action) => this.keyboardPressAction(action)
276
276
  };
277
277
  }
@@ -410,18 +410,20 @@ ${Object.keys(size).filter((key) => size[key]).map(
410
410
  this.yadbPushed = true;
411
411
  }
412
412
  }
413
- async keyboardType(text) {
413
+ async keyboardType(text, options) {
414
414
  if (!text)
415
415
  return;
416
416
  const adb = await this.getAdb();
417
417
  const isChinese = /[\p{Script=Han}\p{sc=Hani}]/u.test(text);
418
+ const isAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
418
419
  if (!isChinese) {
419
420
  await adb.inputText(text);
421
+ } else {
422
+ await this.execYadb(text);
423
+ }
424
+ if (isAutoDismissKeyboard === true) {
420
425
  await adb.hideKeyboard();
421
- return;
422
426
  }
423
- await this.execYadb(text);
424
- await adb.hideKeyboard();
425
427
  }
426
428
  async keyboardPress(key) {
427
429
  const keyCodeMap = {
@@ -575,7 +577,12 @@ async function agentFromAdbDevice(deviceId, opts) {
575
577
  deviceId
576
578
  );
577
579
  }
578
- const page = new AndroidDevice(deviceId);
580
+ const page = new AndroidDevice(deviceId, {
581
+ autoDismissKeyboard: opts?.autoDismissKeyboard,
582
+ androidAdbPath: opts?.androidAdbPath,
583
+ remoteAdbHost: opts?.remoteAdbHost,
584
+ remoteAdbPort: opts?.remoteAdbPort
585
+ });
579
586
  await page.connect();
580
587
  return new AndroidAgent(page, opts);
581
588
  }
@@ -1,10 +1,15 @@
1
1
  import { PageType, Size, Point } from '@midscene/core';
2
2
  import { ElementInfo } from '@midscene/shared/extractor';
3
- import { AndroidDevicePage } from '@midscene/web';
3
+ import { AndroidDevicePage, AndroidDeviceInputOpt } from '@midscene/web';
4
4
  import { ADB, Device } from 'appium-adb';
5
5
  import { PageAgent, PageAgentOpt } from '@midscene/web/agent';
6
6
  export { overrideAIConfig } from '@midscene/shared/env';
7
7
 
8
+ type AndroidDeviceOpt = {
9
+ androidAdbPath?: string;
10
+ remoteAdbHost?: string;
11
+ remoteAdbPort?: number;
12
+ } & AndroidDeviceInputOpt;
8
13
  declare class AndroidDevice implements AndroidDevicePage {
9
14
  private deviceId;
10
15
  private screenSize;
@@ -14,16 +19,8 @@ declare class AndroidDevice implements AndroidDevicePage {
14
19
  private connectingAdb;
15
20
  pageType: PageType;
16
21
  uri: string | undefined;
17
- options?: {
18
- androidAdbPath?: string;
19
- remoteAdbHost?: string;
20
- remoteAdbPort?: number;
21
- };
22
- constructor(deviceId: string, options?: {
23
- androidAdbPath?: string;
24
- remoteAdbHost?: string;
25
- remoteAdbPort?: number;
26
- });
22
+ options?: AndroidDeviceOpt;
23
+ constructor(deviceId: string, options?: AndroidDeviceOpt);
27
24
  connect(): Promise<ADB>;
28
25
  getAdb(): Promise<ADB>;
29
26
  private createAdbProxy;
@@ -49,7 +46,7 @@ declare class AndroidDevice implements AndroidDevicePage {
49
46
  }) => Promise<void>;
50
47
  };
51
48
  get keyboard(): {
52
- type: (text: string) => Promise<void>;
49
+ type: (text: string, options?: AndroidDeviceInputOpt) => Promise<void>;
53
50
  press: (action: {
54
51
  key: string;
55
52
  command?: string;
@@ -85,11 +82,12 @@ declare class AndroidDevice implements AndroidDevicePage {
85
82
  getElementInfoByXpath(xpath: string): Promise<ElementInfo>;
86
83
  }
87
84
 
85
+ type AndroidAgentOpt = PageAgentOpt;
88
86
  declare class AndroidAgent extends PageAgent<AndroidDevice> {
89
- constructor(page: AndroidDevice, opts?: PageAgentOpt);
87
+ constructor(page: AndroidDevice, opts?: AndroidAgentOpt);
90
88
  launch(uri: string): Promise<void>;
91
89
  }
92
- declare function agentFromAdbDevice(deviceId?: string, opts?: PageAgentOpt): Promise<AndroidAgent>;
90
+ declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
93
91
 
94
92
  declare function getConnectedDevices(): Promise<Device[]>;
95
93
 
package/dist/lib/index.js CHANGED
@@ -307,7 +307,7 @@ ${Object.keys(size).filter((key) => size[key]).map(
307
307
  }
308
308
  get keyboard() {
309
309
  return {
310
- type: (text) => this.keyboardType(text),
310
+ type: (text, options) => this.keyboardType(text, options),
311
311
  press: (action) => this.keyboardPressAction(action)
312
312
  };
313
313
  }
@@ -446,18 +446,20 @@ ${Object.keys(size).filter((key) => size[key]).map(
446
446
  this.yadbPushed = true;
447
447
  }
448
448
  }
449
- async keyboardType(text) {
449
+ async keyboardType(text, options) {
450
450
  if (!text)
451
451
  return;
452
452
  const adb = await this.getAdb();
453
453
  const isChinese = /[\p{Script=Han}\p{sc=Hani}]/u.test(text);
454
+ const isAutoDismissKeyboard = options?.autoDismissKeyboard ?? this.options?.autoDismissKeyboard ?? true;
454
455
  if (!isChinese) {
455
456
  await adb.inputText(text);
457
+ } else {
458
+ await this.execYadb(text);
459
+ }
460
+ if (isAutoDismissKeyboard === true) {
456
461
  await adb.hideKeyboard();
457
- return;
458
462
  }
459
- await this.execYadb(text);
460
- await adb.hideKeyboard();
461
463
  }
462
464
  async keyboardPress(key) {
463
465
  const keyCodeMap = {
@@ -611,7 +613,12 @@ async function agentFromAdbDevice(deviceId, opts) {
611
613
  deviceId
612
614
  );
613
615
  }
614
- const page = new AndroidDevice(deviceId);
616
+ const page = new AndroidDevice(deviceId, {
617
+ autoDismissKeyboard: opts?.autoDismissKeyboard,
618
+ androidAdbPath: opts?.androidAdbPath,
619
+ remoteAdbHost: opts?.remoteAdbHost,
620
+ remoteAdbPort: opts?.remoteAdbPort
621
+ });
615
622
  await page.connect();
616
623
  return new AndroidAgent(page, opts);
617
624
  }
@@ -1,10 +1,15 @@
1
1
  import { PageType, Size, Point } from '@midscene/core';
2
2
  import { ElementInfo } from '@midscene/shared/extractor';
3
- import { AndroidDevicePage } from '@midscene/web';
3
+ import { AndroidDevicePage, AndroidDeviceInputOpt } from '@midscene/web';
4
4
  import { ADB, Device } from 'appium-adb';
5
5
  import { PageAgent, PageAgentOpt } from '@midscene/web/agent';
6
6
  export { overrideAIConfig } from '@midscene/shared/env';
7
7
 
8
+ type AndroidDeviceOpt = {
9
+ androidAdbPath?: string;
10
+ remoteAdbHost?: string;
11
+ remoteAdbPort?: number;
12
+ } & AndroidDeviceInputOpt;
8
13
  declare class AndroidDevice implements AndroidDevicePage {
9
14
  private deviceId;
10
15
  private screenSize;
@@ -14,16 +19,8 @@ declare class AndroidDevice implements AndroidDevicePage {
14
19
  private connectingAdb;
15
20
  pageType: PageType;
16
21
  uri: string | undefined;
17
- options?: {
18
- androidAdbPath?: string;
19
- remoteAdbHost?: string;
20
- remoteAdbPort?: number;
21
- };
22
- constructor(deviceId: string, options?: {
23
- androidAdbPath?: string;
24
- remoteAdbHost?: string;
25
- remoteAdbPort?: number;
26
- });
22
+ options?: AndroidDeviceOpt;
23
+ constructor(deviceId: string, options?: AndroidDeviceOpt);
27
24
  connect(): Promise<ADB>;
28
25
  getAdb(): Promise<ADB>;
29
26
  private createAdbProxy;
@@ -49,7 +46,7 @@ declare class AndroidDevice implements AndroidDevicePage {
49
46
  }) => Promise<void>;
50
47
  };
51
48
  get keyboard(): {
52
- type: (text: string) => Promise<void>;
49
+ type: (text: string, options?: AndroidDeviceInputOpt) => Promise<void>;
53
50
  press: (action: {
54
51
  key: string;
55
52
  command?: string;
@@ -85,11 +82,12 @@ declare class AndroidDevice implements AndroidDevicePage {
85
82
  getElementInfoByXpath(xpath: string): Promise<ElementInfo>;
86
83
  }
87
84
 
85
+ type AndroidAgentOpt = PageAgentOpt;
88
86
  declare class AndroidAgent extends PageAgent<AndroidDevice> {
89
- constructor(page: AndroidDevice, opts?: PageAgentOpt);
87
+ constructor(page: AndroidDevice, opts?: AndroidAgentOpt);
90
88
  launch(uri: string): Promise<void>;
91
89
  }
92
- declare function agentFromAdbDevice(deviceId?: string, opts?: PageAgentOpt): Promise<AndroidAgent>;
90
+ declare function agentFromAdbDevice(deviceId?: string, opts?: AndroidAgentOpt & AndroidDeviceOpt): Promise<AndroidAgent>;
93
91
 
94
92
  declare function getConnectedDevices(): Promise<Device[]>;
95
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "0.17.6-beta-20250605050844.0",
3
+ "version": "0.18.0",
4
4
  "description": "Android automation library for Midscene",
5
5
  "keywords": [
6
6
  "Android UI automation",
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "appium-adb": "12.12.1",
27
- "@midscene/shared": "0.17.6-beta-20250605050844.0",
28
- "@midscene/web": "0.17.6-beta-20250605050844.0",
29
- "@midscene/core": "0.17.6-beta-20250605050844.0"
27
+ "@midscene/core": "0.18.0",
28
+ "@midscene/shared": "0.18.0",
29
+ "@midscene/web": "0.18.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@modern-js/module-tools": "2.60.6",