@jolibox/implement 1.1.4-beta.12 → 1.1.4-beta.14
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/.rush/temp/package-deps_build.json +12 -11
- package/dist/{h5 → common}/ads/ads-action-detection.d.ts +3 -1
- package/dist/{h5 → common}/ads/anti-cheating.d.ts +2 -2
- package/dist/common/ads/channel-policy.d.ts +4 -0
- package/dist/{h5 → common}/ads/index.d.ts +11 -3
- package/dist/common/context/index.d.ts +1 -0
- package/dist/common/report/task-track/index.d.ts +3 -0
- package/dist/h5/api/ads.d.ts +1 -0
- package/dist/h5/api/index.d.ts +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +3 -3
- package/dist/index.native.js +3 -3
- package/implement.build.log +2 -2
- package/package.json +3 -3
- package/src/{h5 → common}/ads/ads-action-detection.ts +4 -4
- package/src/{h5 → common}/ads/anti-cheating.ts +2 -4
- package/src/common/ads/channel-policy.ts +7 -0
- package/src/{h5 → common}/ads/index.ts +31 -45
- package/src/common/context/index.ts +10 -6
- package/src/common/report/task-track/index.ts +57 -8
- package/src/h5/api/ads.ts +24 -0
- package/src/h5/api/index.ts +1 -0
- package/src/h5/report/index.ts +1 -0
- package/src/index.ts +0 -1
- package/src/native/api/ads.ts +28 -8
- package/dist/common/report/errors/error-types.d.ts +0 -122
- package/src/common/report/errors/error-types.ts +0 -206
|
@@ -30,7 +30,7 @@ export abstract class TaskTracker {
|
|
|
30
30
|
|
|
31
31
|
abstract reporter(point: TaskPoint): void;
|
|
32
32
|
abstract tracker(point: TrackEvent, info: Record<string, unknown> | null): void;
|
|
33
|
-
constructor(eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
|
|
33
|
+
constructor(readonly eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
|
|
34
34
|
this.interval = interval ?? 5 * 1000;
|
|
35
35
|
|
|
36
36
|
eventEmitter.on('visible', (visible) => {
|
|
@@ -63,14 +63,16 @@ export abstract class TaskTracker {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
private createRAFTimer(callback: (duration: number) => void) {
|
|
66
|
-
let lastTime =
|
|
66
|
+
let lastTime = Date.now();
|
|
67
67
|
let rafId: number;
|
|
68
|
+
let intervalId: number;
|
|
68
69
|
let isRunning = false;
|
|
69
70
|
let totalTime = 0;
|
|
70
71
|
|
|
71
|
-
const tick = (
|
|
72
|
+
const tick = () => {
|
|
72
73
|
if (!isRunning) return;
|
|
73
74
|
|
|
75
|
+
const currentTime = Date.now();
|
|
74
76
|
const deltaTime = currentTime - lastTime;
|
|
75
77
|
if (deltaTime >= this.interval) {
|
|
76
78
|
if (this.visible) {
|
|
@@ -83,19 +85,66 @@ export abstract class TaskTracker {
|
|
|
83
85
|
rafId = requestAnimationFrame(tick);
|
|
84
86
|
};
|
|
85
87
|
|
|
88
|
+
const startInterval = () => {
|
|
89
|
+
stopRAF();
|
|
90
|
+
lastTime = Date.now();
|
|
91
|
+
intervalId = window.setInterval(() => {
|
|
92
|
+
if (!isRunning) return;
|
|
93
|
+
const currentTime = Date.now();
|
|
94
|
+
const deltaTime = currentTime - lastTime;
|
|
95
|
+
if (deltaTime >= this.interval) {
|
|
96
|
+
lastTime = currentTime;
|
|
97
|
+
}
|
|
98
|
+
}, this.interval) as unknown as number;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const startRAF = () => {
|
|
102
|
+
stopInterval();
|
|
103
|
+
lastTime = Date.now();
|
|
104
|
+
rafId = requestAnimationFrame(tick);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const stopRAF = () => {
|
|
108
|
+
if (rafId) {
|
|
109
|
+
cancelAnimationFrame(rafId);
|
|
110
|
+
rafId = 0;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const stopInterval = () => {
|
|
115
|
+
if (intervalId) {
|
|
116
|
+
clearInterval(intervalId);
|
|
117
|
+
intervalId = 0;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
this.eventEmitter.on('visible', (visible) => {
|
|
122
|
+
if (!isRunning) return;
|
|
123
|
+
|
|
124
|
+
console.log('visible', visible);
|
|
125
|
+
if (visible) {
|
|
126
|
+
startRAF();
|
|
127
|
+
} else {
|
|
128
|
+
startInterval();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const originVisible = this.visible;
|
|
86
133
|
return {
|
|
87
134
|
start() {
|
|
88
135
|
if (!isRunning) {
|
|
89
136
|
isRunning = true;
|
|
90
|
-
|
|
91
|
-
|
|
137
|
+
if (originVisible) {
|
|
138
|
+
startRAF();
|
|
139
|
+
} else {
|
|
140
|
+
startInterval();
|
|
141
|
+
}
|
|
92
142
|
}
|
|
93
143
|
},
|
|
94
144
|
stop() {
|
|
95
145
|
isRunning = false;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
146
|
+
stopRAF();
|
|
147
|
+
stopInterval();
|
|
99
148
|
}
|
|
100
149
|
};
|
|
101
150
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JoliboxAdsImpl } from '@/common/ads';
|
|
2
|
+
import { track } from '../report';
|
|
3
|
+
import { tracker as h5Tracker } from '../report/event-tracker';
|
|
4
|
+
import { createCommands } from '@jolibox/common';
|
|
5
|
+
import JoliboxHttpClient from '../http';
|
|
6
|
+
|
|
7
|
+
const commands = createCommands();
|
|
8
|
+
const ads = new JoliboxAdsImpl(track, new JoliboxHttpClient(), () => h5Tracker.networkIsOk);
|
|
9
|
+
|
|
10
|
+
commands.registerCommand('AdsSDK.init', (config) => {
|
|
11
|
+
ads.init(config);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
commands.registerCommand('AdsSDK.adConfig', (params) => {
|
|
15
|
+
ads.adConfig(params);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
commands.registerCommand('AdsSDK.adBreak', (params) => {
|
|
19
|
+
ads.adBreak(params);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
commands.registerCommand('AdsSDK.adUnit', (params) => {
|
|
23
|
+
ads.adUnit(params);
|
|
24
|
+
});
|
package/src/h5/api/index.ts
CHANGED
package/src/h5/report/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/native/api/ads.ts
CHANGED
|
@@ -3,27 +3,47 @@ import { createSyncAPI, registerCanIUse } from './base';
|
|
|
3
3
|
|
|
4
4
|
const commands = createCommands();
|
|
5
5
|
|
|
6
|
+
import { IAdsInitParams, JoliboxAdsImpl, IAdConfigParams, IAdBreakParams, IAdUnitParams } from '@/common/ads';
|
|
7
|
+
import { track } from '../report';
|
|
8
|
+
|
|
9
|
+
import { innerFetch as fetch } from '../network';
|
|
10
|
+
|
|
11
|
+
// TODO: 从network中获取isOK
|
|
12
|
+
const ads = new JoliboxAdsImpl(
|
|
13
|
+
track,
|
|
14
|
+
{
|
|
15
|
+
get: <T>(url: string, options?: any) =>
|
|
16
|
+
fetch<T>(url, {
|
|
17
|
+
method: 'GET',
|
|
18
|
+
responseType: 'json',
|
|
19
|
+
appendHostCookie: true,
|
|
20
|
+
...options
|
|
21
|
+
}).then((res) => res.response.data as T)
|
|
22
|
+
},
|
|
23
|
+
() => true
|
|
24
|
+
);
|
|
25
|
+
|
|
6
26
|
const adInit = createSyncAPI('adInit', {
|
|
7
|
-
implement: (config) => {
|
|
8
|
-
|
|
27
|
+
implement: (config?: IAdsInitParams) => {
|
|
28
|
+
ads.init(config);
|
|
9
29
|
}
|
|
10
30
|
});
|
|
11
31
|
|
|
12
32
|
const adConfig = createSyncAPI('adConfig', {
|
|
13
|
-
implement: (params) => {
|
|
14
|
-
|
|
33
|
+
implement: (params: IAdConfigParams) => {
|
|
34
|
+
ads.adConfig(params);
|
|
15
35
|
}
|
|
16
36
|
});
|
|
17
37
|
|
|
18
38
|
const adBreak = createSyncAPI('adBreak', {
|
|
19
|
-
implement: (params) => {
|
|
20
|
-
|
|
39
|
+
implement: (params: IAdBreakParams) => {
|
|
40
|
+
ads.adBreak(params);
|
|
21
41
|
}
|
|
22
42
|
});
|
|
23
43
|
|
|
24
44
|
const adUnit = createSyncAPI('adUnit', {
|
|
25
|
-
implement: (params) => {
|
|
26
|
-
|
|
45
|
+
implement: (params: IAdUnitParams) => {
|
|
46
|
+
ads.adUnit(params);
|
|
27
47
|
}
|
|
28
48
|
});
|
|
29
49
|
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
type InternalLifeCycleErrorName = 'INTERNAL_GAME_LAUNCH_ERROR';
|
|
2
|
-
type InternalAPIErrorName = 'INTERNAL_API_ERROR';
|
|
3
|
-
type InternalMetricErrorName = 'INTERNAL_METRIC_REPORT_ERROR';
|
|
4
|
-
type InternalReporterErrorName = 'INTERNAL_REPORTER_ERROR';
|
|
5
|
-
type InternalUtilErrorName = 'INTERNAL_BUFFER_ERROR' | 'INTERNAL_SCHEMA_PARSE_ERROR';
|
|
6
|
-
type InternalInjectErrorName = 'INTERNAL_CONTEXT_ERROR' | 'INTERNAL_JSCORE_ERROR';
|
|
7
|
-
type InternalBridgeErrorName = 'INTERNAL_INVOKE_NATIVE_ERROR' | 'INTERNAL_APPLY_NATIVE_ERROR' | 'INTERNAL_INVOKE_METHOD_ERROR';
|
|
8
|
-
type UserErrorName = 'USER_VALIDATE_ERROR' | 'USER_GLOBAL_ERROR' | 'USER_FETCH_ERROR' | 'API_ERROR' | 'USER_CUSTOM_ERROR';
|
|
9
|
-
export type ErrorName = InternalLifeCycleErrorName | InternalInjectErrorName | InternalAPIErrorName | InternalBridgeErrorName | InternalUtilErrorName | InternalReporterErrorName | UserErrorName | InternalMetricErrorName;
|
|
10
|
-
export type ErrorKind = 'INTERNAL_ERROR' | 'USER_ERROR' | 'API_ERROR';
|
|
11
|
-
export type ErrorEnv = 'native' | 'h5';
|
|
12
|
-
export type LoadScriptError = BaseError & {
|
|
13
|
-
code?: number;
|
|
14
|
-
};
|
|
15
|
-
export declare enum LoadScriptCode {
|
|
16
|
-
DEVELOPER_FILE_NOT_FOUND = 0,
|
|
17
|
-
INTERNAL_IOS_CAN_NOT_FOUND_PKG = 1,
|
|
18
|
-
USER_IOS_LOAD_TIMEOUT = 2,
|
|
19
|
-
INTERNAL_IOS_PKG_LOAD_ERROR = 3,
|
|
20
|
-
INTERNAL_IOS_PKG_PARSE_FAIL = 4,
|
|
21
|
-
USER_IOS_GET_EMPTY_DATA = 5,
|
|
22
|
-
USER_ANDROID_GET_PKG_FAIL = 6,
|
|
23
|
-
DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE = 7
|
|
24
|
-
}
|
|
25
|
-
export declare abstract class BaseError extends Error {
|
|
26
|
-
abstract kind: ErrorKind;
|
|
27
|
-
abstract name: ErrorName;
|
|
28
|
-
priority: 'P0' | 'P1';
|
|
29
|
-
env?: ErrorEnv;
|
|
30
|
-
raw?: Error;
|
|
31
|
-
component?: string;
|
|
32
|
-
constructor(error: string | Error);
|
|
33
|
-
}
|
|
34
|
-
export declare abstract class InternalError extends BaseError {
|
|
35
|
-
readonly kind = "INTERNAL_ERROR";
|
|
36
|
-
}
|
|
37
|
-
export declare abstract class UserError extends BaseError {
|
|
38
|
-
readonly kind = "USER_ERROR";
|
|
39
|
-
}
|
|
40
|
-
export declare class UserValidateError extends UserError {
|
|
41
|
-
readonly name = "USER_VALIDATE_ERROR";
|
|
42
|
-
}
|
|
43
|
-
export declare class UserGlobalError extends UserError {
|
|
44
|
-
readonly name = "USER_GLOBAL_ERROR";
|
|
45
|
-
readonly priority = "P0";
|
|
46
|
-
}
|
|
47
|
-
export declare class UserCustomError extends UserError {
|
|
48
|
-
readonly message: string;
|
|
49
|
-
readonly errNo?: number | undefined;
|
|
50
|
-
readonly name = "USER_CUSTOM_ERROR";
|
|
51
|
-
errMsg: string;
|
|
52
|
-
extra?: {
|
|
53
|
-
[key: string]: unknown;
|
|
54
|
-
};
|
|
55
|
-
constructor(message: string, errNo?: number | undefined, extra?: {
|
|
56
|
-
[key: string]: unknown;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
export declare class UserFetchError extends UserError {
|
|
60
|
-
readonly message: string;
|
|
61
|
-
readonly errNo?: number | undefined;
|
|
62
|
-
readonly name = "USER_FETCH_ERROR";
|
|
63
|
-
errMsg: string;
|
|
64
|
-
extra?: {
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
};
|
|
67
|
-
constructor(message: string, errNo?: number | undefined, extra?: {
|
|
68
|
-
[key: string]: unknown;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
export declare class InternalSchemaParseError extends InternalError {
|
|
72
|
-
readonly name = "INTERNAL_SCHEMA_PARSE_ERROR";
|
|
73
|
-
readonly priority = "P0";
|
|
74
|
-
}
|
|
75
|
-
export declare class InternalInvokeNativeError extends InternalError {
|
|
76
|
-
readonly name = "INTERNAL_INVOKE_NATIVE_ERROR";
|
|
77
|
-
}
|
|
78
|
-
export declare class InternalApplyNativeError extends InternalError {
|
|
79
|
-
readonly errNo?: number | undefined;
|
|
80
|
-
readonly name = "INTERNAL_APPLY_NATIVE_ERROR";
|
|
81
|
-
errorType?: string;
|
|
82
|
-
errorCode?: number;
|
|
83
|
-
constructor(message: string, errNo?: number | undefined, errorType?: string, errorCode?: number);
|
|
84
|
-
}
|
|
85
|
-
export declare class InternalInvokeMethodError extends InternalError {
|
|
86
|
-
readonly name = "INTERNAL_INVOKE_METHOD_ERROR";
|
|
87
|
-
}
|
|
88
|
-
export declare class InternalJSCoreNotFoundError extends InternalError {
|
|
89
|
-
readonly name = "INTERNAL_JSCORE_ERROR";
|
|
90
|
-
}
|
|
91
|
-
export declare class InternalBufferError extends InternalError {
|
|
92
|
-
readonly name = "INTERNAL_BUFFER_ERROR";
|
|
93
|
-
}
|
|
94
|
-
export declare class InternalContextError extends InternalError {
|
|
95
|
-
readonly message: string;
|
|
96
|
-
readonly name = "INTERNAL_CONTEXT_ERROR";
|
|
97
|
-
readonly property: string;
|
|
98
|
-
constructor(message: string, property: string);
|
|
99
|
-
}
|
|
100
|
-
export declare class APIError extends BaseError {
|
|
101
|
-
readonly message: string;
|
|
102
|
-
readonly code: number;
|
|
103
|
-
readonly kind = "API_ERROR";
|
|
104
|
-
readonly name = "API_ERROR";
|
|
105
|
-
extra?: Record<string, unknown>;
|
|
106
|
-
errorType?: string;
|
|
107
|
-
constructor(message: string, code: number, errorType?: string, stack?: string, priority?: 'P0' | 'P1');
|
|
108
|
-
toJSON(): {
|
|
109
|
-
message: string;
|
|
110
|
-
stack: string | undefined;
|
|
111
|
-
name: string;
|
|
112
|
-
code: number;
|
|
113
|
-
errorType: string | undefined;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
export declare class InternalMetricReportError extends InternalError {
|
|
117
|
-
readonly name = "INTERNAL_METRIC_REPORT_ERROR";
|
|
118
|
-
}
|
|
119
|
-
export declare class InternalReporterError extends InternalError {
|
|
120
|
-
readonly name = "INTERNAL_REPORTER_ERROR";
|
|
121
|
-
}
|
|
122
|
-
export {};
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
type InternalLifeCycleErrorName = 'INTERNAL_GAME_LAUNCH_ERROR';
|
|
2
|
-
|
|
3
|
-
// API
|
|
4
|
-
type InternalAPIErrorName = 'INTERNAL_API_ERROR';
|
|
5
|
-
|
|
6
|
-
// 前端埋点
|
|
7
|
-
type InternalMetricErrorName = 'INTERNAL_METRIC_REPORT_ERROR';
|
|
8
|
-
|
|
9
|
-
// reporter
|
|
10
|
-
type InternalReporterErrorName = 'INTERNAL_REPORTER_ERROR';
|
|
11
|
-
|
|
12
|
-
// 内部错误
|
|
13
|
-
type InternalUtilErrorName = 'INTERNAL_BUFFER_ERROR' | 'INTERNAL_SCHEMA_PARSE_ERROR';
|
|
14
|
-
|
|
15
|
-
// Native Inject Error
|
|
16
|
-
type InternalInjectErrorName = 'INTERNAL_CONTEXT_ERROR' | 'INTERNAL_JSCORE_ERROR';
|
|
17
|
-
|
|
18
|
-
type InternalBridgeErrorName =
|
|
19
|
-
| 'INTERNAL_INVOKE_NATIVE_ERROR'
|
|
20
|
-
| 'INTERNAL_APPLY_NATIVE_ERROR'
|
|
21
|
-
| 'INTERNAL_INVOKE_METHOD_ERROR';
|
|
22
|
-
|
|
23
|
-
// User
|
|
24
|
-
type UserErrorName =
|
|
25
|
-
| 'USER_VALIDATE_ERROR'
|
|
26
|
-
| 'USER_GLOBAL_ERROR'
|
|
27
|
-
| 'USER_FETCH_ERROR'
|
|
28
|
-
| 'API_ERROR'
|
|
29
|
-
| 'USER_CUSTOM_ERROR';
|
|
30
|
-
|
|
31
|
-
export type ErrorName =
|
|
32
|
-
| InternalLifeCycleErrorName
|
|
33
|
-
| InternalInjectErrorName
|
|
34
|
-
| InternalAPIErrorName
|
|
35
|
-
| InternalBridgeErrorName
|
|
36
|
-
| InternalUtilErrorName
|
|
37
|
-
| InternalReporterErrorName
|
|
38
|
-
| UserErrorName
|
|
39
|
-
| InternalMetricErrorName;
|
|
40
|
-
|
|
41
|
-
export type ErrorKind = 'INTERNAL_ERROR' | 'USER_ERROR' | 'API_ERROR';
|
|
42
|
-
export type ErrorEnv = 'native' | 'h5';
|
|
43
|
-
export type LoadScriptError = BaseError & { code?: number };
|
|
44
|
-
export enum LoadScriptCode {
|
|
45
|
-
DEVELOPER_FILE_NOT_FOUND = 0,
|
|
46
|
-
INTERNAL_IOS_CAN_NOT_FOUND_PKG = 1,
|
|
47
|
-
USER_IOS_LOAD_TIMEOUT = 2,
|
|
48
|
-
INTERNAL_IOS_PKG_LOAD_ERROR = 3,
|
|
49
|
-
INTERNAL_IOS_PKG_PARSE_FAIL = 4,
|
|
50
|
-
USER_IOS_GET_EMPTY_DATA = 5,
|
|
51
|
-
USER_ANDROID_GET_PKG_FAIL = 6,
|
|
52
|
-
DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE = 7
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export abstract class BaseError extends Error {
|
|
56
|
-
abstract kind: ErrorKind;
|
|
57
|
-
abstract name: ErrorName;
|
|
58
|
-
priority: 'P0' | 'P1';
|
|
59
|
-
env?: ErrorEnv;
|
|
60
|
-
raw?: Error;
|
|
61
|
-
component?: string;
|
|
62
|
-
constructor(error: string | Error) {
|
|
63
|
-
if (typeof error === 'string') {
|
|
64
|
-
super(error);
|
|
65
|
-
this.priority = 'P1';
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
super(error.message);
|
|
69
|
-
this.priority = 'P1';
|
|
70
|
-
this.stack = error.stack;
|
|
71
|
-
this.raw = error;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export abstract class InternalError extends BaseError {
|
|
76
|
-
readonly kind = 'INTERNAL_ERROR';
|
|
77
|
-
}
|
|
78
|
-
export abstract class UserError extends BaseError {
|
|
79
|
-
readonly kind = 'USER_ERROR';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export class UserValidateError extends UserError {
|
|
83
|
-
readonly name = 'USER_VALIDATE_ERROR';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export class UserGlobalError extends UserError {
|
|
87
|
-
readonly name = 'USER_GLOBAL_ERROR';
|
|
88
|
-
readonly priority = 'P0';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export class UserCustomError extends UserError {
|
|
92
|
-
readonly name = 'USER_CUSTOM_ERROR';
|
|
93
|
-
errMsg: string;
|
|
94
|
-
extra?: { [key: string]: unknown };
|
|
95
|
-
|
|
96
|
-
constructor(readonly message: string, readonly errNo?: number, extra?: { [key: string]: unknown }) {
|
|
97
|
-
super(message);
|
|
98
|
-
this.errMsg = message;
|
|
99
|
-
|
|
100
|
-
if (extra) {
|
|
101
|
-
this.extra = Object.assign({}, this.extra, extra);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export class UserFetchError extends UserError {
|
|
107
|
-
readonly name = 'USER_FETCH_ERROR';
|
|
108
|
-
errMsg: string;
|
|
109
|
-
extra?: { [key: string]: unknown };
|
|
110
|
-
|
|
111
|
-
constructor(readonly message: string, readonly errNo?: number, extra?: { [key: string]: unknown }) {
|
|
112
|
-
super(message);
|
|
113
|
-
this.errMsg = message;
|
|
114
|
-
|
|
115
|
-
if (extra) {
|
|
116
|
-
this.extra = Object.assign({}, this.extra, extra);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export class InternalSchemaParseError extends InternalError {
|
|
122
|
-
readonly name = 'INTERNAL_SCHEMA_PARSE_ERROR';
|
|
123
|
-
readonly priority = 'P0';
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export class InternalInvokeNativeError extends InternalError {
|
|
127
|
-
readonly name = 'INTERNAL_INVOKE_NATIVE_ERROR';
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export class InternalApplyNativeError extends InternalError {
|
|
131
|
-
readonly name = 'INTERNAL_APPLY_NATIVE_ERROR';
|
|
132
|
-
errorType?: string;
|
|
133
|
-
errorCode?: number;
|
|
134
|
-
constructor(message: string, readonly errNo?: number, errorType?: string, errorCode?: number) {
|
|
135
|
-
super(message);
|
|
136
|
-
this.errorType = errorType;
|
|
137
|
-
this.errorCode = errorCode;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export class InternalInvokeMethodError extends InternalError {
|
|
142
|
-
readonly name = 'INTERNAL_INVOKE_METHOD_ERROR';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export class InternalJSCoreNotFoundError extends InternalError {
|
|
146
|
-
readonly name = 'INTERNAL_JSCORE_ERROR';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export class InternalBufferError extends InternalError {
|
|
150
|
-
readonly name = 'INTERNAL_BUFFER_ERROR';
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export class InternalContextError extends InternalError {
|
|
154
|
-
readonly name = 'INTERNAL_CONTEXT_ERROR';
|
|
155
|
-
readonly property: string;
|
|
156
|
-
constructor(readonly message: string, property: string) {
|
|
157
|
-
super(message);
|
|
158
|
-
this.property = property;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export class APIError extends BaseError {
|
|
163
|
-
readonly kind = 'API_ERROR';
|
|
164
|
-
readonly name = 'API_ERROR';
|
|
165
|
-
extra?: Record<string, unknown>;
|
|
166
|
-
errorType?: string;
|
|
167
|
-
|
|
168
|
-
constructor(
|
|
169
|
-
readonly message: string,
|
|
170
|
-
readonly code: number,
|
|
171
|
-
errorType?: string,
|
|
172
|
-
stack?: string,
|
|
173
|
-
priority?: 'P0' | 'P1'
|
|
174
|
-
) {
|
|
175
|
-
super(message);
|
|
176
|
-
|
|
177
|
-
if (errorType) {
|
|
178
|
-
this.errorType = errorType;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (stack !== undefined) {
|
|
182
|
-
this.stack = stack;
|
|
183
|
-
}
|
|
184
|
-
if (priority) {
|
|
185
|
-
this.priority = priority;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
toJSON() {
|
|
190
|
-
return {
|
|
191
|
-
message: this.message,
|
|
192
|
-
stack: this.stack,
|
|
193
|
-
name: this.name,
|
|
194
|
-
code: this.code,
|
|
195
|
-
errorType: this.errorType
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export class InternalMetricReportError extends InternalError {
|
|
201
|
-
readonly name = 'INTERNAL_METRIC_REPORT_ERROR';
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export class InternalReporterError extends InternalError {
|
|
205
|
-
readonly name = 'INTERNAL_REPORTER_ERROR';
|
|
206
|
-
}
|