assistsx-js 0.0.2020 → 0.0.2021
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?:
|
|
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
|
|
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
|
|
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 =
|
|
13
|
-
this.enableDeduplication = (
|
|
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
|
-
|
|
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
|
* 创建默认的过滤配置
|
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@ export interface AccessibilityEventFilterConfig {
|
|
|
36
36
|
* 如果为空,则处理所有类型的事件
|
|
37
37
|
* 如果指定类型,则只处理指定类型的事件
|
|
38
38
|
*/
|
|
39
|
-
eventTypes?:
|
|
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
|
|
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
|
|
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
|
|
108
|
+
return (
|
|
109
|
+
this.eventTypes === null ||
|
|
110
|
+
(this.eventTypes?.includes(eventType) ?? false)
|
|
111
|
+
);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
/**
|