@ekhein/lamda-node-sdk 2.1.3 → 2.1.4

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,4 +1,4 @@
1
- import { DeepPartial, SelectorWaitRequest } from "../rpc/uiautomator";
1
+ import { Selector } from "../rpc/uiautomator";
2
2
  export declare class TimeoutException extends Error {
3
- constructor(args: DeepPartial<SelectorWaitRequest>);
3
+ constructor(selector: Selector, timeout: number);
4
4
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimeoutException = void 0;
4
4
  const util_1 = require("util");
5
5
  class TimeoutException extends Error {
6
- constructor(args) {
7
- super((0, util_1.format)("%s %sms selector [%s]", TimeoutException.name, args.timeout, args.selector));
6
+ constructor(selector, timeout) {
7
+ super((0, util_1.format)("%s %sms selector [%s]", TimeoutException.name, timeout, selector));
8
8
  }
9
9
  }
10
10
  exports.TimeoutException = TimeoutException;
package/dist/main.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Corner, Selector } from './rpc/uiautomator';
1
2
  import { UtilClient, UiAutomatorClient, ApplicationClient, DebugClient, FileClient, LockClient, ProxyClient, SelinuxPolicyClient, ShellClient, StatusClient, StorageClient, WifiClient, SettingsClient } from './rpc/services';
2
3
  export declare class Device {
3
4
  readonly Util: UtilClient;
@@ -16,10 +17,10 @@ export declare class Device {
16
17
  private channel;
17
18
  private client;
18
19
  constructor(host?: string, prot?: number);
19
- click(...args: Parameters<typeof this.UiAutomator["selectorClick"]>): Promise<import("./rpc/types").Boolean>;
20
- waitFor(...args: Parameters<typeof this.UiAutomator["selectorWaitForExists"]>): Promise<void>;
20
+ click(selector: Partial<Selector>, corner?: Corner): Promise<import("./rpc/types").Boolean>;
21
+ clickEx(keys: string, keyboard: Record<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", Partial<Selector>>): Promise<void>;
22
+ waitFor(selector: Selector, timeout?: number): Promise<true>;
21
23
  sleep(min?: number, max?: number): Promise<unknown>;
22
- passwd(pwd: string, keyboard: Record<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", Parameters<typeof this.UiAutomator["selectorClick"]>[0]>): Promise<void>;
23
24
  activity(data: string): Promise<import("./rpc/types").Boolean>;
24
25
  kill(name: string): Promise<import("./rpc/types").Boolean>;
25
26
  open(name: string): Promise<import("./rpc/types").Boolean>;
package/dist/main.js CHANGED
@@ -47,36 +47,35 @@ class Device {
47
47
  })
48
48
  });
49
49
  }
50
- async click(...args) {
50
+ async click(selector, corner) {
51
51
  return this.UiAutomator
52
- .selectorClick(...args);
52
+ .selectorClick({ selector, corner });
53
53
  }
54
- async waitFor(...args) {
55
- args[0] = Object.assign({ timeout: 30e3 }, args[0]);
54
+ async clickEx(keys, keyboard) {
55
+ for (let i = 0; i < keys.length; i++) {
56
+ await this.sleep(100, 200);
57
+ await this.click(keyboard[keys[i]]);
58
+ }
59
+ }
60
+ async waitFor(selector, timeout = 15e3) {
56
61
  return this.UiAutomator
57
- .selectorWaitForExists(...args)
62
+ .selectorWaitForExists({ selector, timeout })
58
63
  .then(async (exists) => {
59
- if (!exists.value) {
60
- throw new timeout_exception_1.TimeoutException(args[0]);
61
- }
64
+ if (exists.value === false)
65
+ throw new timeout_exception_1.TimeoutException(selector, timeout);
66
+ return exists.value;
62
67
  });
63
68
  }
64
69
  async sleep(min = 500, max = min) {
65
70
  const ms = Math.random() * (max - min) + min;
66
71
  return new Promise(resolve => setTimeout(resolve, ms));
67
72
  }
68
- async passwd(pwd, keyboard) {
69
- for (let i = 0; i < pwd.length; i++) {
70
- await this.sleep(100, 200);
71
- await this.click(keyboard[pwd[i]]);
72
- }
73
- }
74
73
  async activity(data) {
75
74
  return this.Application
76
75
  .startActivity({
77
76
  data,
78
77
  action: android_intent_1.ACTION_VIEW,
79
- flags: (activity_flag_1.FLAG_ACTIVITY_NEW_TASK | activity_flag_1.FLAG_ACTIVITY_CLEAR_TOP | activity_flag_1.FLAG_ACTIVITY_CLEAR_TASK)
78
+ flags: activity_flag_1.FLAG_ACTIVITY_NEW_TASK | activity_flag_1.FLAG_ACTIVITY_CLEAR_TOP | activity_flag_1.FLAG_ACTIVITY_CLEAR_TASK
80
79
  });
81
80
  }
82
81
  async kill(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekhein/lamda-node-sdk",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "author": "ekhein",
5
5
  "license": "MIT",
6
6
  "main": "./dist/main.js",