assistsx-js 0.0.2048 → 0.0.2050
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/AssistsX.d.ts +12 -0
- package/dist/AssistsX.js +22 -0
- package/dist/AssistsXAsync.d.ts +16 -0
- package/dist/AssistsXAsync.js +22 -0
- package/dist/CallMethod.d.ts +2 -0
- package/dist/CallMethod.js +2 -0
- package/dist/Step.d.ts +7 -1
- package/dist/Step.js +20 -7
- package/dist/StepError.d.ts +15 -7
- package/dist/StepError.js +13 -2
- package/package.json +1 -1
- package/src/AssistsX.ts +976 -954
- package/src/AssistsXAsync.ts +1044 -1012
- package/src/CallMethod.ts +62 -60
- package/src/Step.ts +20 -14
- package/src/StepError.ts +48 -36
package/dist/AssistsX.d.ts
CHANGED
|
@@ -420,6 +420,18 @@ export declare class AssistsX {
|
|
|
420
420
|
static getMacAddress(timeout?: number): Promise<any>;
|
|
421
421
|
static getDeviceInfo(timeout?: number): Promise<DeviceInfo>;
|
|
422
422
|
static getNetworkType(timeout?: number): Promise<any>;
|
|
423
|
+
/**
|
|
424
|
+
* 播放系统电话铃声
|
|
425
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
426
|
+
* @returns 播放结果消息
|
|
427
|
+
*/
|
|
428
|
+
static audioPlayRingtone(timeout?: number): Promise<string>;
|
|
429
|
+
/**
|
|
430
|
+
* 停止播放系统电话铃声
|
|
431
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
432
|
+
* @returns 停止结果消息
|
|
433
|
+
*/
|
|
434
|
+
static audioStopRingtone(timeout?: number): Promise<string>;
|
|
423
435
|
static setAccessibilityEventFilters(value: AccessibilityEventFilter[]): Promise<any>;
|
|
424
436
|
static addAccessibilityEventFilter(value: AccessibilityEventFilter): Promise<any>;
|
|
425
437
|
/**
|
package/dist/AssistsX.js
CHANGED
|
@@ -637,6 +637,28 @@ export class AssistsX {
|
|
|
637
637
|
});
|
|
638
638
|
return response.getDataOrDefault({});
|
|
639
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* 播放系统电话铃声
|
|
642
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
643
|
+
* @returns 播放结果消息
|
|
644
|
+
*/
|
|
645
|
+
static async audioPlayRingtone(timeout) {
|
|
646
|
+
const response = await this.asyncCall(CallMethod.audioPlayRingtone, {
|
|
647
|
+
timeout,
|
|
648
|
+
});
|
|
649
|
+
return response.getDataOrDefault("");
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* 停止播放系统电话铃声
|
|
653
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
654
|
+
* @returns 停止结果消息
|
|
655
|
+
*/
|
|
656
|
+
static async audioStopRingtone(timeout) {
|
|
657
|
+
const response = await this.asyncCall(CallMethod.audioStopRingtone, {
|
|
658
|
+
timeout,
|
|
659
|
+
});
|
|
660
|
+
return response.getDataOrDefault("");
|
|
661
|
+
}
|
|
640
662
|
static async setAccessibilityEventFilters(value) {
|
|
641
663
|
const response = this.call(CallMethod.setAccessibilityEventFilters, {
|
|
642
664
|
args: { value },
|
package/dist/AssistsXAsync.d.ts
CHANGED
|
@@ -442,6 +442,22 @@ export declare class AssistsXAsync {
|
|
|
442
442
|
static audioStop({ timeout, }: {
|
|
443
443
|
timeout?: number;
|
|
444
444
|
}): Promise<boolean | null | undefined>;
|
|
445
|
+
/**
|
|
446
|
+
* 播放系统电话铃声
|
|
447
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
448
|
+
* @returns 播放结果消息
|
|
449
|
+
*/
|
|
450
|
+
static audioPlayRingtone({ timeout, }: {
|
|
451
|
+
timeout?: number;
|
|
452
|
+
}): Promise<string>;
|
|
453
|
+
/**
|
|
454
|
+
* 停止播放系统电话铃声
|
|
455
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
456
|
+
* @returns 停止结果消息
|
|
457
|
+
*/
|
|
458
|
+
static audioStopRingtone({ timeout, }: {
|
|
459
|
+
timeout?: number;
|
|
460
|
+
}): Promise<string>;
|
|
445
461
|
/**
|
|
446
462
|
* 添加联系人
|
|
447
463
|
* @param name 联系人姓名(必填)
|
package/dist/AssistsXAsync.js
CHANGED
|
@@ -681,6 +681,28 @@ export class AssistsXAsync {
|
|
|
681
681
|
});
|
|
682
682
|
return response.getDataOrDefault(false);
|
|
683
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* 播放系统电话铃声
|
|
686
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
687
|
+
* @returns 播放结果消息
|
|
688
|
+
*/
|
|
689
|
+
static async audioPlayRingtone({ timeout = 30, }) {
|
|
690
|
+
const response = await this.asyncCall(CallMethod.audioPlayRingtone, {
|
|
691
|
+
timeout,
|
|
692
|
+
});
|
|
693
|
+
return response.getDataOrDefault("");
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* 停止播放系统电话铃声
|
|
697
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
698
|
+
* @returns 停止结果消息
|
|
699
|
+
*/
|
|
700
|
+
static async audioStopRingtone({ timeout = 30, }) {
|
|
701
|
+
const response = await this.asyncCall(CallMethod.audioStopRingtone, {
|
|
702
|
+
timeout,
|
|
703
|
+
});
|
|
704
|
+
return response.getDataOrDefault("");
|
|
705
|
+
}
|
|
684
706
|
/**
|
|
685
707
|
* 添加联系人
|
|
686
708
|
* @param name 联系人姓名(必填)
|
package/dist/CallMethod.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export declare const CallMethod: {
|
|
|
56
56
|
readonly download: "download";
|
|
57
57
|
readonly audioPlayFromFile: "audioPlayFromFile";
|
|
58
58
|
readonly audioStop: "audioStop";
|
|
59
|
+
readonly audioPlayRingtone: "audioPlayRingtone";
|
|
60
|
+
readonly audioStopRingtone: "audioStopRingtone";
|
|
59
61
|
readonly addContact: "addContact";
|
|
60
62
|
readonly getAllContacts: "getAllContacts";
|
|
61
63
|
};
|
package/dist/CallMethod.js
CHANGED
|
@@ -57,6 +57,8 @@ export const CallMethod = {
|
|
|
57
57
|
download: "download",
|
|
58
58
|
audioPlayFromFile: "audioPlayFromFile",
|
|
59
59
|
audioStop: "audioStop",
|
|
60
|
+
audioPlayRingtone: "audioPlayRingtone",
|
|
61
|
+
audioStopRingtone: "audioStopRingtone",
|
|
60
62
|
// 通讯录相关方法
|
|
61
63
|
addContact: "addContact",
|
|
62
64
|
getAllContacts: "getAllContacts",
|
package/dist/Step.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node } from "./Node";
|
|
2
|
+
import { StepError } from "./StepError";
|
|
2
3
|
import { StepAsync } from "./StepAsync";
|
|
3
4
|
export type StepResult = Step | undefined;
|
|
4
5
|
export type StepImpl = (step: Step) => Promise<StepResult>;
|
|
@@ -16,6 +17,10 @@ export declare class Step {
|
|
|
16
17
|
* 步骤拦截器列表
|
|
17
18
|
*/
|
|
18
19
|
private static _interceptors;
|
|
20
|
+
/**
|
|
21
|
+
* 步骤异常变量,默认为空
|
|
22
|
+
*/
|
|
23
|
+
static exception: StepError | undefined;
|
|
19
24
|
/**
|
|
20
25
|
* 运行步骤实现
|
|
21
26
|
* @param impl 步骤实现函数
|
|
@@ -46,8 +51,9 @@ export declare class Step {
|
|
|
46
51
|
static assignIdsToNodes(nodes: Node[], stepId: string | undefined): void;
|
|
47
52
|
/**
|
|
48
53
|
* 停止当前步骤执行
|
|
54
|
+
* @param exception 可选的异常对象,如果传入则使用该异常,否则使用默认的StepStopError
|
|
49
55
|
*/
|
|
50
|
-
static stop(): void;
|
|
56
|
+
static stop(exception?: StepError): void;
|
|
51
57
|
/**
|
|
52
58
|
* 添加步骤拦截器
|
|
53
59
|
* @param interceptor 拦截器函数
|
package/dist/Step.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { AssistsX } from "./AssistsX";
|
|
6
6
|
import { useStepStore } from "./StepStateStore";
|
|
7
7
|
import { generateUUID } from "./Utils";
|
|
8
|
-
import { StepError } from "./StepError";
|
|
8
|
+
import { StepError, StepStopError } from "./StepError";
|
|
9
9
|
import { StepAsync } from "./StepAsync";
|
|
10
10
|
export class Step {
|
|
11
11
|
/**
|
|
@@ -17,6 +17,7 @@ export class Step {
|
|
|
17
17
|
*/
|
|
18
18
|
static async run(impl, { stepId, tag, data, delayMs = Step.delayMsDefault, } = {}) {
|
|
19
19
|
var _a, _b, _c, _d, _e, _f;
|
|
20
|
+
this.exception = undefined;
|
|
20
21
|
const stepStore = useStepStore();
|
|
21
22
|
let implnName = impl.name;
|
|
22
23
|
let currentStep;
|
|
@@ -131,7 +132,7 @@ export class Step {
|
|
|
131
132
|
error: (_f = e === null || e === void 0 ? void 0 : e.message) !== null && _f !== void 0 ? _f : String(e),
|
|
132
133
|
});
|
|
133
134
|
stepStore.setError(errorMsg);
|
|
134
|
-
throw
|
|
135
|
+
throw e;
|
|
135
136
|
}
|
|
136
137
|
//步骤执行结束
|
|
137
138
|
stepStore.completeStep();
|
|
@@ -148,11 +149,12 @@ export class Step {
|
|
|
148
149
|
* @param stepId 要验证的步骤ID
|
|
149
150
|
*/
|
|
150
151
|
static assert(stepId) {
|
|
152
|
+
// 检查异常变量,如果不为空则直接抛出
|
|
153
|
+
if (Step.exception) {
|
|
154
|
+
throw Step.exception;
|
|
155
|
+
}
|
|
151
156
|
if (stepId && Step.stepId != stepId) {
|
|
152
|
-
|
|
153
|
-
throw new Error("主动中断步骤");
|
|
154
|
-
}
|
|
155
|
-
throw new Error("StepId mismatch");
|
|
157
|
+
throw new StepError("StepId mismatch", { stepId, currentStepId: Step.stepId });
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
/**
|
|
@@ -169,9 +171,16 @@ export class Step {
|
|
|
169
171
|
}
|
|
170
172
|
/**
|
|
171
173
|
* 停止当前步骤执行
|
|
174
|
+
* @param exception 可选的异常对象,如果传入则使用该异常,否则使用默认的StepStopError
|
|
172
175
|
*/
|
|
173
|
-
static stop() {
|
|
176
|
+
static stop(exception) {
|
|
174
177
|
this._stepId = "STEP_STOP";
|
|
178
|
+
if (exception) {
|
|
179
|
+
this.exception = exception;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.exception = new StepStopError("主动中断步骤", { stepId: this._stepId });
|
|
183
|
+
}
|
|
175
184
|
}
|
|
176
185
|
/**
|
|
177
186
|
* 添加步骤拦截器
|
|
@@ -622,3 +631,7 @@ Step._stepId = undefined;
|
|
|
622
631
|
* 步骤拦截器列表
|
|
623
632
|
*/
|
|
624
633
|
Step._interceptors = [];
|
|
634
|
+
/**
|
|
635
|
+
* 步骤异常变量,默认为空
|
|
636
|
+
*/
|
|
637
|
+
Step.exception = undefined;
|
package/dist/StepError.d.ts
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 步骤执行错误类
|
|
3
3
|
* 用于携带步骤执行过程中的错误信息和当前步骤对象
|
|
4
|
+
* 支持传入可选数据:message,data任何类型的数据
|
|
4
5
|
*/
|
|
5
6
|
export declare class StepError extends Error {
|
|
6
7
|
/**
|
|
7
8
|
* 步骤实现函数名
|
|
8
9
|
*/
|
|
9
|
-
readonly impl
|
|
10
|
+
readonly impl?: string;
|
|
10
11
|
/**
|
|
11
12
|
* 步骤标签
|
|
12
13
|
*/
|
|
13
|
-
readonly tag
|
|
14
|
+
readonly tag?: string | undefined;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* 步骤数据,可以是任何类型
|
|
16
17
|
*/
|
|
17
|
-
readonly data
|
|
18
|
+
readonly data?: any;
|
|
18
19
|
/**
|
|
19
20
|
* 原始错误
|
|
20
21
|
*/
|
|
21
|
-
readonly originalError
|
|
22
|
+
readonly originalError?: any;
|
|
22
23
|
/**
|
|
23
24
|
* 当前步骤对象
|
|
24
25
|
*/
|
|
25
|
-
readonly currentStep
|
|
26
|
-
constructor(message
|
|
26
|
+
readonly currentStep?: any;
|
|
27
|
+
constructor(message?: string, data?: any, impl?: string, tag?: string | undefined, originalError?: any, currentStep?: any | undefined);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 主动停止异常类
|
|
31
|
+
* 用于表示步骤被主动停止执行
|
|
32
|
+
*/
|
|
33
|
+
export declare class StepStopError extends StepError {
|
|
34
|
+
constructor(message?: string, data?: any);
|
|
27
35
|
}
|
package/dist/StepError.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 步骤执行错误类
|
|
3
3
|
* 用于携带步骤执行过程中的错误信息和当前步骤对象
|
|
4
|
+
* 支持传入可选数据:message,data任何类型的数据
|
|
4
5
|
*/
|
|
5
6
|
export class StepError extends Error {
|
|
6
|
-
constructor(message, impl, tag,
|
|
7
|
+
constructor(message, data, impl, tag, originalError, currentStep) {
|
|
7
8
|
super(message);
|
|
8
9
|
this.name = "StepError";
|
|
10
|
+
this.data = data;
|
|
9
11
|
this.impl = impl;
|
|
10
12
|
this.tag = tag;
|
|
11
|
-
this.data = data;
|
|
12
13
|
this.originalError = originalError;
|
|
13
14
|
this.currentStep = currentStep;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* 主动停止异常类
|
|
19
|
+
* 用于表示步骤被主动停止执行
|
|
20
|
+
*/
|
|
21
|
+
export class StepStopError extends StepError {
|
|
22
|
+
constructor(message, data) {
|
|
23
|
+
super(message || "主动中断步骤", data);
|
|
24
|
+
this.name = "StepStopError";
|
|
25
|
+
}
|
|
26
|
+
}
|