assistsx-js 0.0.2020 → 0.0.2022

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.
@@ -32,7 +32,7 @@ export interface AccessibilityEventFilterConfig {
32
32
  * 如果为空,则处理所有类型的事件
33
33
  * 如果指定类型,则只处理指定类型的事件
34
34
  */
35
- eventTypes?: Set<number> | null;
35
+ eventTypes?: number[] | null;
36
36
  /**
37
37
  * 是否启用事件去重
38
38
  * true: 启用去重,避免重复处理相同事件
@@ -64,7 +64,7 @@ export declare class AccessibilityEventFilter {
64
64
  /**
65
65
  * 事件类型过滤
66
66
  */
67
- readonly eventTypes: Set<number> | null;
67
+ readonly eventTypes?: number[] | null;
68
68
  /**
69
69
  * 是否启用事件去重
70
70
  */
@@ -4,13 +4,13 @@
4
4
  */
5
5
  export class AccessibilityEventFilter {
6
6
  constructor(config = {}) {
7
- var _a, _b, _c, _d, _e, _f;
7
+ var _a, _b, _c, _d, _e;
8
8
  this.packageName = (_a = config.packageName) !== null && _a !== void 0 ? _a : null;
9
9
  this.processInBackground = (_b = config.processInBackground) !== null && _b !== void 0 ? _b : true;
10
10
  this.fetchNodeInfo = (_c = config.fetchNodeInfo) !== null && _c !== void 0 ? _c : true;
11
11
  this.enableLogging = (_d = config.enableLogging) !== null && _d !== void 0 ? _d : false;
12
- this.eventTypes = (_e = config.eventTypes) !== null && _e !== void 0 ? _e : null;
13
- this.enableDeduplication = (_f = config.enableDeduplication) !== null && _f !== void 0 ? _f : false;
12
+ this.eventTypes = config.eventTypes;
13
+ this.enableDeduplication = (_e = config.enableDeduplication) !== null && _e !== void 0 ? _e : false;
14
14
  }
15
15
  /**
16
16
  * 检查是否应该处理指定包的事件
@@ -26,7 +26,9 @@ export class AccessibilityEventFilter {
26
26
  * @returns true表示应该处理,false表示应该过滤
27
27
  */
28
28
  shouldProcessEventType(eventType) {
29
- return this.eventTypes === null || this.eventTypes.has(eventType);
29
+ var _a, _b;
30
+ return (this.eventTypes === null ||
31
+ ((_b = (_a = this.eventTypes) === null || _a === void 0 ? void 0 : _a.includes(eventType)) !== null && _b !== void 0 ? _b : false));
30
32
  }
31
33
  /**
32
34
  * 创建默认的过滤配置
@@ -42,6 +42,25 @@ export interface WebFloatingWindowOptions {
42
42
  maxHeight?: number;
43
43
  initialCenter?: boolean;
44
44
  }
45
+ /**
46
+ * HTTP请求选项接口定义
47
+ */
48
+ export interface HttpRequestOptions {
49
+ url: string;
50
+ method?: "GET" | "POST";
51
+ headers?: Record<string, string>;
52
+ body?: string;
53
+ timeout?: number;
54
+ }
55
+ /**
56
+ * HTTP响应数据接口定义
57
+ */
58
+ export interface HttpResponse {
59
+ statusCode: number;
60
+ statusMessage: string;
61
+ body: string;
62
+ headers: Record<string, string>;
63
+ }
45
64
  export declare const callbacks: Map<string, (data: string) => void>;
46
65
  export declare const accessibilityEventListeners: AccessibilityEventListener[];
47
66
  export declare class AssistsX {
@@ -364,6 +383,7 @@ export declare class AssistsX {
364
383
  static getUniqueDeviceId(): any;
365
384
  static getAndroidID(): any;
366
385
  static getMacAddress(): Promise<any>;
386
+ static getDeviceInfo(): Promise<any>;
367
387
  static setAccessibilityEventFilters(value: AccessibilityEventFilter[]): Promise<any>;
368
388
  static addAccessibilityEventFilter(value: AccessibilityEventFilter): Promise<any>;
369
389
  /**
package/dist/AssistsX.js CHANGED
@@ -566,6 +566,10 @@ export class AssistsX {
566
566
  const response = await this.asyncCall(CallMethod.getMacAddress);
567
567
  return response.getDataOrDefault({});
568
568
  }
569
+ static async getDeviceInfo() {
570
+ const response = await this.asyncCall(CallMethod.getDeviceInfo);
571
+ return response.getDataOrDefault({});
572
+ }
569
573
  static async setAccessibilityEventFilters(value) {
570
574
  const response = this.call(CallMethod.setAccessibilityEventFilters, {
571
575
  args: { value },
@@ -311,6 +311,7 @@ export declare class AssistsXAsync {
311
311
  static getUniqueDeviceId(): Promise<any>;
312
312
  static getAndroidID(): Promise<any>;
313
313
  static getMacAddress(): Promise<any>;
314
+ static getDeviceInfo(): Promise<any>;
314
315
  /**
315
316
  * 获取屏幕尺寸
316
317
  * @returns 屏幕尺寸对象
@@ -7,7 +7,7 @@ import { CallMethod } from "./CallMethod";
7
7
  import { CallResponse } from "./CallResponse";
8
8
  import { Bounds } from "./Bounds";
9
9
  import { generateUUID } from "./Utils";
10
- import { callbacks } from "./AssistsX";
10
+ import { callbacks, } from "./AssistsX";
11
11
  export class AssistsXAsync {
12
12
  /**
13
13
  * 执行异步调用
@@ -515,6 +515,10 @@ export class AssistsXAsync {
515
515
  const response = await this.asyncCall(CallMethod.getMacAddress);
516
516
  return response.getDataOrDefault({});
517
517
  }
518
+ static async getDeviceInfo() {
519
+ const response = await this.asyncCall(CallMethod.getDeviceInfo);
520
+ return response.getDataOrDefault({});
521
+ }
518
522
  /**
519
523
  * 获取屏幕尺寸
520
524
  * @returns 屏幕尺寸对象
@@ -44,5 +44,7 @@ export declare const CallMethod: {
44
44
  readonly getUniqueDeviceId: "getUniqueDeviceId";
45
45
  readonly addAccessibilityEventFilter: "addAccessibilityEventFilter";
46
46
  readonly setAccessibilityEventFilters: "setAccessibilityEventFilters";
47
+ readonly httpRequest: "httpRequest";
48
+ readonly getDeviceInfo: "getDeviceInfo";
47
49
  };
48
50
  export type CallMethodType = (typeof CallMethod)[keyof typeof CallMethod];
@@ -45,4 +45,6 @@ export const CallMethod = {
45
45
  getUniqueDeviceId: "getUniqueDeviceId",
46
46
  addAccessibilityEventFilter: "addAccessibilityEventFilter",
47
47
  setAccessibilityEventFilters: "setAccessibilityEventFilters",
48
+ httpRequest: "httpRequest",
49
+ getDeviceInfo: "getDeviceInfo",
48
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistsx-js",
3
- "version": "0.0.2020",
3
+ "version": "0.0.2022",
4
4
  "description": "assistsx-js自动化开发SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -36,7 +36,7 @@ export interface AccessibilityEventFilterConfig {
36
36
  * 如果为空,则处理所有类型的事件
37
37
  * 如果指定类型,则只处理指定类型的事件
38
38
  */
39
- eventTypes?: Set<number> | null;
39
+ eventTypes?: number[] | null;
40
40
 
41
41
  /**
42
42
  * 是否启用事件去重
@@ -74,7 +74,7 @@ export class AccessibilityEventFilter {
74
74
  /**
75
75
  * 事件类型过滤
76
76
  */
77
- public readonly eventTypes: Set<number> | null;
77
+ public readonly eventTypes?: number[] | null;
78
78
 
79
79
  /**
80
80
  * 是否启用事件去重
@@ -86,7 +86,7 @@ export class AccessibilityEventFilter {
86
86
  this.processInBackground = config.processInBackground ?? true;
87
87
  this.fetchNodeInfo = config.fetchNodeInfo ?? true;
88
88
  this.enableLogging = config.enableLogging ?? false;
89
- this.eventTypes = config.eventTypes ?? null;
89
+ this.eventTypes = config.eventTypes;
90
90
  this.enableDeduplication = config.enableDeduplication ?? false;
91
91
  }
92
92
 
@@ -105,7 +105,10 @@ export class AccessibilityEventFilter {
105
105
  * @returns true表示应该处理,false表示应该过滤
106
106
  */
107
107
  public shouldProcessEventType(eventType: number): boolean {
108
- return this.eventTypes === null || this.eventTypes.has(eventType);
108
+ return (
109
+ this.eventTypes === null ||
110
+ (this.eventTypes?.includes(eventType) ?? false)
111
+ );
109
112
  }
110
113
 
111
114
  /**
package/src/AssistsX.ts CHANGED
@@ -49,6 +49,27 @@ export interface WebFloatingWindowOptions {
49
49
  initialCenter?: boolean;
50
50
  }
51
51
 
52
+ /**
53
+ * HTTP请求选项接口定义
54
+ */
55
+ export interface HttpRequestOptions {
56
+ url: string;
57
+ method?: "GET" | "POST";
58
+ headers?: Record<string, string>;
59
+ body?: string;
60
+ timeout?: number;
61
+ }
62
+
63
+ /**
64
+ * HTTP响应数据接口定义
65
+ */
66
+ export interface HttpResponse {
67
+ statusCode: number;
68
+ statusMessage: string;
69
+ body: string;
70
+ headers: Record<string, string>;
71
+ }
72
+
52
73
  // 回调函数存储对象
53
74
  export const callbacks: Map<string, (data: string) => void> = new Map();
54
75
 
@@ -799,6 +820,10 @@ export class AssistsX {
799
820
  const response = await this.asyncCall(CallMethod.getMacAddress);
800
821
  return response.getDataOrDefault({});
801
822
  }
823
+ public static async getDeviceInfo(): Promise<any> {
824
+ const response = await this.asyncCall(CallMethod.getDeviceInfo);
825
+ return response.getDataOrDefault({});
826
+ }
802
827
  public static async setAccessibilityEventFilters(
803
828
  value: AccessibilityEventFilter[]
804
829
  ): Promise<any> {
@@ -884,4 +909,24 @@ export class AssistsX {
884
909
  public static getAccessibilityEventListenerCount(): number {
885
910
  return accessibilityEventListeners.length;
886
911
  }
912
+
913
+ /**
914
+ * 发送HTTP请求
915
+ * @param options 请求选项
916
+ * @returns HTTP响应
917
+ */
918
+ // public static async httpRequest(
919
+ // options: HttpRequestOptions
920
+ // ): Promise<HttpResponse> {
921
+ // const { url, method = "GET", headers, body, timeout = 30 } = options;
922
+ // const response = await this.asyncCall(CallMethod.httpRequest, {
923
+ // args: { url, method, headers, body, timeout },
924
+ // });
925
+ // return response.getDataOrDefault({
926
+ // statusCode: -1,
927
+ // statusMessage: "",
928
+ // body: "",
929
+ // headers: {},
930
+ // });
931
+ // }
887
932
  }
@@ -7,7 +7,13 @@ import { CallMethod } from "./CallMethod";
7
7
  import { CallResponse } from "./CallResponse";
8
8
  import { Bounds } from "./Bounds";
9
9
  import { generateUUID } from "./Utils";
10
- import { AssistsX, callbacks, WebFloatingWindowOptions } from "./AssistsX";
10
+ import {
11
+ AssistsX,
12
+ callbacks,
13
+ WebFloatingWindowOptions,
14
+ HttpRequestOptions,
15
+ HttpResponse,
16
+ } from "./AssistsX";
11
17
 
12
18
  export class AssistsXAsync {
13
19
  /**
@@ -704,6 +710,10 @@ export class AssistsXAsync {
704
710
  const response = await this.asyncCall(CallMethod.getMacAddress);
705
711
  return response.getDataOrDefault({});
706
712
  }
713
+ public static async getDeviceInfo(): Promise<any> {
714
+ const response = await this.asyncCall(CallMethod.getDeviceInfo);
715
+ return response.getDataOrDefault({});
716
+ }
707
717
 
708
718
  /**
709
719
  * 获取屏幕尺寸
@@ -722,4 +732,24 @@ export class AssistsXAsync {
722
732
  const response = await this.asyncCall(CallMethod.getAppScreenSize);
723
733
  return response.getDataOrDefault("{}");
724
734
  }
735
+
736
+ /**
737
+ * 发送HTTP请求
738
+ * @param options 请求选项
739
+ * @returns HTTP响应
740
+ */
741
+ // public static async httpRequest(
742
+ // options: HttpRequestOptions
743
+ // ): Promise<HttpResponse> {
744
+ // const { url, method = "GET", headers, body, timeout = 30 } = options;
745
+ // const response = await this.asyncCall(CallMethod.httpRequest, {
746
+ // args: { url, method, headers, body, timeout },
747
+ // });
748
+ // return response.getDataOrDefault({
749
+ // statusCode: -1,
750
+ // statusMessage: "",
751
+ // body: "",
752
+ // headers: {},
753
+ // });
754
+ // }
725
755
  }
package/src/CallMethod.ts CHANGED
@@ -48,6 +48,9 @@ export const CallMethod = {
48
48
 
49
49
  addAccessibilityEventFilter: "addAccessibilityEventFilter",
50
50
  setAccessibilityEventFilters: "setAccessibilityEventFilters",
51
+
52
+ httpRequest: "httpRequest",
53
+ getDeviceInfo: "getDeviceInfo",
51
54
  } as const;
52
55
 
53
56
  // 导出类型定义