@singcl/ad-execute-manager 2.0.11 → 2.0.12
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/ad-interstitial/src/InterstitialAdFather.d.ts +8 -8
- package/dist/ad-interstitial/src/InterstitialAdNovel.d.ts +17 -4
- package/dist/ad-interstitial/src/typings/ad.d.ts +74 -57
- package/dist/ad-reward/src/RewardAdFather.d.ts +10 -10
- package/dist/ad-reward/src/RewardAdNovel.d.ts +8 -106
- package/dist/ad-reward/src/typings/ad.d.ts +82 -57
- package/package.json +97 -91
|
@@ -27,12 +27,12 @@ declare class InterstitialAdFather {
|
|
|
27
27
|
* 使用管理器执行广告
|
|
28
28
|
* @param {Object} adInstance 广告实例
|
|
29
29
|
* @param {Object} ctx 上下文对象,用于传递数据和状态
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
30
|
+
* @param {import('./typings/ad.js').IAdOptions} ctx.options 广告执行选项
|
|
31
|
+
* @param {CallbackCollection} ctx.collection 回调集合
|
|
32
32
|
*/
|
|
33
33
|
static executeWithManager(adInstance: any, ctx: {
|
|
34
|
-
options:
|
|
35
|
-
collection:
|
|
34
|
+
options: import("./typings/ad.js").IAdOptions;
|
|
35
|
+
collection: CallbackCollection;
|
|
36
36
|
}): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
|
|
37
37
|
[key: string]: any;
|
|
38
38
|
}>;
|
|
@@ -61,11 +61,11 @@ declare class InterstitialAdFather {
|
|
|
61
61
|
/**
|
|
62
62
|
* 初始化
|
|
63
63
|
* 子类可以选择覆盖此方法,或使用默认实现
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {import('./typings/ad.js').IAdOptions} params
|
|
65
65
|
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
66
66
|
* @returns {this} 当前实例
|
|
67
67
|
*/
|
|
68
|
-
initialize(params:
|
|
68
|
+
initialize(params: import("./typings/ad.js").IAdOptions, callback?: (v: IRewardedVideoAd) => void): this;
|
|
69
69
|
initialized(): boolean;
|
|
70
70
|
/**
|
|
71
71
|
* 执行广告展示
|
|
@@ -84,11 +84,11 @@ declare class InterstitialAdFather {
|
|
|
84
84
|
/**
|
|
85
85
|
* 确保广告按顺序执行
|
|
86
86
|
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
87
|
-
* @param {
|
|
87
|
+
* @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
|
|
88
88
|
* @param {CallbackCollection} [ctx.collection] 回调集合
|
|
89
89
|
*/
|
|
90
90
|
addExecuteManager(ctx?: {
|
|
91
|
-
options?:
|
|
91
|
+
options?: import("./typings/ad.js").IAdOptions;
|
|
92
92
|
collection?: CallbackCollection;
|
|
93
93
|
}): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
|
|
94
94
|
[key: string]: any;
|
|
@@ -176,11 +176,11 @@ declare class InterstitialAdNovel extends InterstitialAdFather {
|
|
|
176
176
|
/**
|
|
177
177
|
* 初始化
|
|
178
178
|
* 子类可以选择覆盖此方法,或使用默认实现
|
|
179
|
-
* @param {
|
|
179
|
+
* @param {import('./typings/ad.js').IAdOptions} args
|
|
180
180
|
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
181
181
|
* @returns {this} 当前实例
|
|
182
182
|
*/
|
|
183
|
-
initialize(args:
|
|
183
|
+
initialize(args: import("./typings/ad.js").IAdOptions, callback?: (v: IRewardedVideoAd) => void): this;
|
|
184
184
|
_initAdLister(): void;
|
|
185
185
|
/**
|
|
186
186
|
* @param {object} args
|
|
@@ -300,18 +300,31 @@ declare class InterstitialAdNovel extends InterstitialAdFather {
|
|
|
300
300
|
ad_is_completed: number;
|
|
301
301
|
}): any;
|
|
302
302
|
get rewardAd(): any;
|
|
303
|
+
/**
|
|
304
|
+
* 确保广告按顺序执行
|
|
305
|
+
* @override
|
|
306
|
+
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
307
|
+
* @param {import('. /typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
|
|
308
|
+
* @param {import('./typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
309
|
+
*/
|
|
310
|
+
override addExecuteManager(ctx?: {
|
|
311
|
+
options?: any;
|
|
312
|
+
collection?: import("./typings/ad.js").CallbackCollection;
|
|
313
|
+
}): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
|
|
314
|
+
[key: string]: any;
|
|
315
|
+
}>;
|
|
303
316
|
/**
|
|
304
317
|
* ATTENTION: 应用一旦进入后台,90%概率.show() 方法的.then() 回调将不会被执行, .catch() 回调也不会被执行。
|
|
305
318
|
* 此时将进入超时处理逻辑
|
|
306
319
|
* @override
|
|
307
320
|
* @param {object} [ctx] 广告执行上下文
|
|
308
|
-
* @param {import('./typings/ad.js').
|
|
321
|
+
* @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
|
|
309
322
|
* @param {import('./typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
310
323
|
* @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
|
|
311
324
|
* @returns {Promise.<object | Undefined>}
|
|
312
325
|
*/
|
|
313
326
|
override ad(ctx?: {
|
|
314
|
-
options?: import("./typings/ad.js").
|
|
327
|
+
options?: import("./typings/ad.js").IAdOptions;
|
|
315
328
|
collection?: import("./typings/ad.js").CallbackCollection;
|
|
316
329
|
}, next?: Function): Promise<object | undefined>;
|
|
317
330
|
/**
|
|
@@ -22,18 +22,12 @@ export type IRewordAdConfig = {
|
|
|
22
22
|
* 额外观看广告的次数,合法的数据范围为 1~4,multiton 为 true 时必填
|
|
23
23
|
*/
|
|
24
24
|
multitonRewardTimes?: number | undefined;
|
|
25
|
+
};
|
|
26
|
+
export type IRewordAdOther = {
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
scene?: number | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* 广告超时时间 单位ms - 自用参数,非tt API要求的参数
|
|
31
|
-
*/
|
|
32
|
-
timeout?: number | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* 重试次数 - 自用参数 ,非tt API要求的参数
|
|
28
|
+
* 是否需要在超时情况下结束广告 - 自用参数,非tt API要求的参数
|
|
35
29
|
*/
|
|
36
|
-
|
|
30
|
+
needEndOnTimeout?: boolean | undefined;
|
|
37
31
|
/**
|
|
38
32
|
* 是否绑定永远的错误事件 - 自用参数,非tt API要求的参数
|
|
39
33
|
*/
|
|
@@ -50,10 +44,6 @@ export type InterstitialAdConfig = {
|
|
|
50
44
|
scene?: number | undefined;
|
|
51
45
|
};
|
|
52
46
|
export type IExeCallbackArgs = {
|
|
53
|
-
/**
|
|
54
|
-
* 广告执行场景
|
|
55
|
-
*/
|
|
56
|
-
scene: number;
|
|
57
47
|
/**
|
|
58
48
|
* 是否看完
|
|
59
49
|
*/
|
|
@@ -63,40 +53,77 @@ export type IExeCallbackArgs = {
|
|
|
63
53
|
*/
|
|
64
54
|
count: number;
|
|
65
55
|
/**
|
|
66
|
-
*
|
|
56
|
+
* 广告场景
|
|
57
|
+
*/
|
|
58
|
+
scene?: string;
|
|
59
|
+
/**
|
|
60
|
+
* 广告类型 1:激励视频 2:插屏
|
|
61
|
+
*/
|
|
62
|
+
adTypeR?: 1 | 2;
|
|
63
|
+
/**
|
|
64
|
+
* 广告结束类型
|
|
67
65
|
*/
|
|
68
|
-
|
|
66
|
+
end_type?: "finished" | "halfway";
|
|
69
67
|
};
|
|
70
68
|
export type CallbackCollection = {
|
|
71
69
|
/**
|
|
72
70
|
* 每次外部回调
|
|
73
71
|
*/
|
|
74
|
-
always?: (ctx?: IExeCallbackArgs
|
|
72
|
+
always?: (ctx?: IExeCallbackArgs & {
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}) => void;
|
|
75
75
|
/**
|
|
76
76
|
* 完整看完广告外部回调 不管一个还是几个
|
|
77
77
|
*/
|
|
78
|
-
finished?: (ctx?: IExeCallbackArgs
|
|
78
|
+
finished?: (ctx?: IExeCallbackArgs & {
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}) => void;
|
|
79
81
|
/**
|
|
80
82
|
* 半途退出广告外部回调
|
|
81
83
|
*/
|
|
82
|
-
halfway?: (ctx?: IExeCallbackArgs
|
|
84
|
+
halfway?: (ctx?: IExeCallbackArgs & {
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}) => void;
|
|
83
87
|
/**
|
|
84
88
|
* 取消广告外部回调
|
|
85
89
|
*/
|
|
86
|
-
cancel?: (
|
|
90
|
+
cancel?: () => void;
|
|
87
91
|
/**
|
|
88
92
|
* 展示广告外部回调
|
|
89
93
|
*/
|
|
90
|
-
before?: (ctx?:
|
|
94
|
+
before?: (ctx?: {
|
|
95
|
+
scene: number;
|
|
96
|
+
}) => void;
|
|
91
97
|
/**
|
|
92
98
|
* 展示广告成功外部回调
|
|
93
99
|
*/
|
|
94
|
-
success?: (ctx?:
|
|
100
|
+
success?: (ctx?: {
|
|
101
|
+
scene: number;
|
|
102
|
+
}) => void;
|
|
103
|
+
/**
|
|
104
|
+
* 计时回调 scene: 广告场景 frequency: 广告展示前间隔时间 time: 广告展示时前间戳
|
|
105
|
+
*/
|
|
106
|
+
prelude?: (ctx?: {
|
|
107
|
+
scene: number;
|
|
108
|
+
frequency: number;
|
|
109
|
+
time: number;
|
|
110
|
+
}) => void;
|
|
111
|
+
};
|
|
112
|
+
export type IAdOptionsOther = {
|
|
113
|
+
/**
|
|
114
|
+
* 场景值 - 自用参数,非tt API要求的参数
|
|
115
|
+
*/
|
|
116
|
+
scene?: number | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* 广告超时时间 单位ms - 自用参数,非tt API要求的参数
|
|
119
|
+
*/
|
|
120
|
+
timeout?: number | undefined;
|
|
95
121
|
/**
|
|
96
|
-
*
|
|
122
|
+
* 重试次数 - 自用参数 ,非tt API要求的参数
|
|
97
123
|
*/
|
|
98
|
-
|
|
124
|
+
retry: number;
|
|
99
125
|
};
|
|
126
|
+
export type IAdOptions = IRewordAdConfig & IRewordAdOther & IAdOptionsOther;
|
|
100
127
|
export type RecoveredInfo = {
|
|
101
128
|
/**
|
|
102
129
|
* 恢复重试次数
|
|
@@ -111,48 +138,46 @@ export type RecoveredInfo = {
|
|
|
111
138
|
*/
|
|
112
139
|
message: string;
|
|
113
140
|
};
|
|
114
|
-
export type
|
|
115
|
-
/**
|
|
116
|
-
* 广告执行场景
|
|
117
|
-
*/
|
|
118
|
-
scene: number;
|
|
119
|
-
/**
|
|
120
|
-
* 是否看完
|
|
121
|
-
*/
|
|
122
|
-
isEnded: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* 完整观看次数
|
|
125
|
-
*/
|
|
126
|
-
count: number;
|
|
141
|
+
export type IApiError = {
|
|
127
142
|
/**
|
|
128
|
-
*
|
|
143
|
+
* 错误信息
|
|
129
144
|
*/
|
|
130
|
-
|
|
145
|
+
errMsg?: string;
|
|
131
146
|
/**
|
|
132
|
-
*
|
|
147
|
+
* 错误码
|
|
133
148
|
*/
|
|
134
|
-
|
|
149
|
+
errorCode?: number;
|
|
135
150
|
/**
|
|
136
|
-
*
|
|
151
|
+
* 错误信息
|
|
137
152
|
*/
|
|
138
|
-
|
|
139
|
-
ignoreRemain: boolean;
|
|
140
|
-
scene: number;
|
|
141
|
-
}) => void;
|
|
153
|
+
message?: string;
|
|
142
154
|
};
|
|
155
|
+
export type ICallbackArgs = IExeCallbackArgs;
|
|
143
156
|
export type IConnection = {
|
|
144
157
|
/**
|
|
145
158
|
* 广告中途退出回调
|
|
146
159
|
*/
|
|
147
|
-
onHalfway?: (args: ICallbackArgs
|
|
160
|
+
onHalfway?: (args: ICallbackArgs & {
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
}) => void;
|
|
148
163
|
/**
|
|
149
164
|
* 广告展示回调
|
|
150
165
|
*/
|
|
151
|
-
onShow?: (args:
|
|
166
|
+
onShow?: (args: {
|
|
167
|
+
scene: number;
|
|
168
|
+
}) => void;
|
|
169
|
+
/**
|
|
170
|
+
* 广告执行成功回调
|
|
171
|
+
*/
|
|
172
|
+
onFinish?: (args: ICallbackArgs & {
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
}) => void;
|
|
152
175
|
/**
|
|
153
176
|
* 广告执行成功回调
|
|
154
177
|
*/
|
|
155
|
-
|
|
178
|
+
onAlways?: (args: ICallbackArgs & {
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}) => void;
|
|
156
181
|
/**
|
|
157
182
|
* 广告执行失败回调
|
|
158
183
|
*/
|
|
@@ -163,14 +188,6 @@ export type IConstructArgs = {
|
|
|
163
188
|
* 初始化标识
|
|
164
189
|
*/
|
|
165
190
|
sign: string;
|
|
166
|
-
/**
|
|
167
|
-
* 是否开启日志
|
|
168
|
-
*/
|
|
169
|
-
log?: boolean | undefined;
|
|
170
|
-
/**
|
|
171
|
-
* 重试次数
|
|
172
|
-
*/
|
|
173
|
-
retry: number;
|
|
174
191
|
/**
|
|
175
192
|
* 是否保留tt激励视频广告实例
|
|
176
193
|
*/
|
|
@@ -25,12 +25,12 @@ declare class RewardAdFather {
|
|
|
25
25
|
* 使用管理器执行广告
|
|
26
26
|
* @param {Object} adInstance 广告实例
|
|
27
27
|
* @param {Object} ctx 上下文对象,用于传递数据和状态
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
28
|
+
* @param {import('./typings/ad.js').IAdOptions} ctx.options 广告执行选项
|
|
29
|
+
* @param {CallbackCollection} ctx.collection 回调集合
|
|
30
30
|
*/
|
|
31
31
|
static executeWithManager(adInstance: any, ctx: {
|
|
32
|
-
options:
|
|
33
|
-
collection:
|
|
32
|
+
options: import("./typings/ad.js").IAdOptions;
|
|
33
|
+
collection: CallbackCollection;
|
|
34
34
|
}): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
|
|
35
35
|
[key: string]: any;
|
|
36
36
|
}>;
|
|
@@ -61,11 +61,11 @@ declare class RewardAdFather {
|
|
|
61
61
|
/**
|
|
62
62
|
* 初始化
|
|
63
63
|
* 子类可以选择覆盖此方法,或使用默认实现
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {import('./typings/ad.js').IAdOptions} params
|
|
65
65
|
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
66
66
|
* @returns {this} 当前实例
|
|
67
67
|
*/
|
|
68
|
-
initialize(params:
|
|
68
|
+
initialize(params: import("./typings/ad.js").IAdOptions, callback?: (v: IRewardedVideoAd) => void): this;
|
|
69
69
|
initialized(): boolean;
|
|
70
70
|
/**
|
|
71
71
|
* 激励视频展示失败时始终执行的一个方法
|
|
@@ -87,7 +87,7 @@ declare class RewardAdFather {
|
|
|
87
87
|
* 执行广告展示
|
|
88
88
|
* @abstract
|
|
89
89
|
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
90
|
-
* @param {
|
|
90
|
+
* @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
|
|
91
91
|
* @param {CallbackCollection} [ctx.collection] 回调集合
|
|
92
92
|
* @param {RecoveredInfo} [ctx.recovered] 恢复重试信息
|
|
93
93
|
* @param {Function} next 执行下一个任务的回调函数,在洋葱模型中手动调用以继续执行流程
|
|
@@ -95,18 +95,18 @@ declare class RewardAdFather {
|
|
|
95
95
|
* @throws {Error} 子类必须实现此方法
|
|
96
96
|
*/
|
|
97
97
|
ad(ctx?: {
|
|
98
|
-
options?:
|
|
98
|
+
options?: import("./typings/ad.js").IAdOptions;
|
|
99
99
|
collection?: CallbackCollection;
|
|
100
100
|
recovered?: RecoveredInfo;
|
|
101
101
|
}, next?: Function): Promise<unknown>;
|
|
102
102
|
/**
|
|
103
103
|
* 确保广告按顺序执行
|
|
104
104
|
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
105
|
-
* @param {
|
|
105
|
+
* @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
|
|
106
106
|
* @param {CallbackCollection} [ctx.collection] 回调集合
|
|
107
107
|
*/
|
|
108
108
|
addExecuteManager(ctx?: {
|
|
109
|
-
options?:
|
|
109
|
+
options?: import("./typings/ad.js").IAdOptions;
|
|
110
110
|
collection?: CallbackCollection;
|
|
111
111
|
}): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
|
|
112
112
|
[key: string]: any;
|
|
@@ -1,78 +1,6 @@
|
|
|
1
1
|
export default RewardAdNovel;
|
|
2
2
|
export type IRewordAdConfig = import("./typings/ad.js").IRewordAdConfig;
|
|
3
|
-
export type
|
|
4
|
-
/**
|
|
5
|
-
* 广告执行场景
|
|
6
|
-
*/
|
|
7
|
-
scene: number;
|
|
8
|
-
/**
|
|
9
|
-
* 是否看完
|
|
10
|
-
*/
|
|
11
|
-
isEnded: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* 完整观看次数
|
|
14
|
-
*/
|
|
15
|
-
count: number;
|
|
16
|
-
/**
|
|
17
|
-
* 执行下一个任务的回调函数,手动调用以继续执行流程[end]
|
|
18
|
-
*/
|
|
19
|
-
end?: () => void;
|
|
20
|
-
/**
|
|
21
|
-
* 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
|
|
22
|
-
*/
|
|
23
|
-
circle?: (args: {
|
|
24
|
-
ignoreRemain: boolean;
|
|
25
|
-
scene: number;
|
|
26
|
-
}) => void;
|
|
27
|
-
};
|
|
28
|
-
export type IConnection = {
|
|
29
|
-
/**
|
|
30
|
-
* 广告中途退出回调
|
|
31
|
-
*/
|
|
32
|
-
onHalfway?: (args: ICallbackArgs) => void;
|
|
33
|
-
/**
|
|
34
|
-
* 广告展示回调
|
|
35
|
-
*/
|
|
36
|
-
onShow?: (args: ICallbackArgs) => void;
|
|
37
|
-
/**
|
|
38
|
-
* 广告执行成功回调
|
|
39
|
-
*/
|
|
40
|
-
onFinish?: (args: ICallbackArgs) => void;
|
|
41
|
-
/**
|
|
42
|
-
* 广告执行成功回调
|
|
43
|
-
*/
|
|
44
|
-
onAlways?: (args: ICallbackArgs) => void;
|
|
45
|
-
/**
|
|
46
|
-
* 广告执行失败回调
|
|
47
|
-
*/
|
|
48
|
-
onError?: (e: unknown) => void;
|
|
49
|
-
};
|
|
50
|
-
export type IConstructArgs = {
|
|
51
|
-
/**
|
|
52
|
-
* 初始化标识
|
|
53
|
-
*/
|
|
54
|
-
sign?: string;
|
|
55
|
-
/**
|
|
56
|
-
* 是否开启日志
|
|
57
|
-
*/
|
|
58
|
-
log?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* 是否保留tt激励视频广告实例
|
|
61
|
-
*/
|
|
62
|
-
preserveOnEnd?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* 是否需要在超时情况下结束广告
|
|
65
|
-
*/
|
|
66
|
-
needEndOnTimeout?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* 激励视频参数 (可选)
|
|
69
|
-
*/
|
|
70
|
-
adConfig?: IRewordAdConfig | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* 回调集合
|
|
73
|
-
*/
|
|
74
|
-
collection?: IConnection | undefined;
|
|
75
|
-
};
|
|
3
|
+
export type IConstructArgs = import("./typings/ad.js").IConstructArgs;
|
|
76
4
|
export type ICloseArgs = {
|
|
77
5
|
/**
|
|
78
6
|
* 是否看完
|
|
@@ -93,30 +21,7 @@ export type IRewardedVideoAd = {
|
|
|
93
21
|
* @typedef {import('./typings/ad.js').IRewordAdConfig} IRewordAdConfig
|
|
94
22
|
*/
|
|
95
23
|
/**
|
|
96
|
-
* @typedef
|
|
97
|
-
* @property {number} scene 广告执行场景
|
|
98
|
-
* @property {boolean} isEnded 是否看完
|
|
99
|
-
* @property {number} count 完整观看次数
|
|
100
|
-
* @property {() => void} [end] 执行下一个任务的回调函数,手动调用以继续执行流程[end]
|
|
101
|
-
* @property {(args: {ignoreRemain: boolean, scene: number}) => void} [circle] 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
|
|
102
|
-
*
|
|
103
|
-
*/
|
|
104
|
-
/**
|
|
105
|
-
* @typedef IConnection
|
|
106
|
-
* @property {(args: ICallbackArgs) => void} [onHalfway] 广告中途退出回调
|
|
107
|
-
* @property {(args: ICallbackArgs) => void} [onShow] 广告展示回调
|
|
108
|
-
* @property {(args: ICallbackArgs) => void} [onFinish] 广告执行成功回调
|
|
109
|
-
* @property {(args: ICallbackArgs) => void} [onAlways] 广告执行成功回调
|
|
110
|
-
* @property {(e:unknown) => void} [onError] 广告执行失败回调
|
|
111
|
-
*/
|
|
112
|
-
/**
|
|
113
|
-
* @typedef IConstructArgs
|
|
114
|
-
* @property {string} [sign] 初始化标识
|
|
115
|
-
* @property {boolean} [log] 是否开启日志
|
|
116
|
-
* @property {boolean} [preserveOnEnd] 是否保留tt激励视频广告实例
|
|
117
|
-
* @property {boolean} [needEndOnTimeout] 是否需要在超时情况下结束广告
|
|
118
|
-
* @property {IRewordAdConfig=} [adConfig] 激励视频参数 (可选)
|
|
119
|
-
* @property {IConnection=} [collection] 回调集合
|
|
24
|
+
* @typedef {import('./typings/ad.js').IConstructArgs} IConstructArgs
|
|
120
25
|
*/
|
|
121
26
|
/**
|
|
122
27
|
* @typedef ICloseArgs
|
|
@@ -145,11 +50,6 @@ declare class RewardAdNovel extends RewardAdFather {
|
|
|
145
50
|
* @returns {RewardAdNovel}
|
|
146
51
|
*/
|
|
147
52
|
static "new"(args: IConstructArgs): RewardAdNovel;
|
|
148
|
-
/**
|
|
149
|
-
* @param {IConstructArgs} args
|
|
150
|
-
*
|
|
151
|
-
*/
|
|
152
|
-
constructor(args: IConstructArgs);
|
|
153
53
|
_onHalfway: any;
|
|
154
54
|
_onShow: any;
|
|
155
55
|
_onFinish: any;
|
|
@@ -169,6 +69,7 @@ declare class RewardAdNovel extends RewardAdFather {
|
|
|
169
69
|
_adSpeedCloseTimer: any;
|
|
170
70
|
_adSpeedCloseTime: number;
|
|
171
71
|
_needEndOnTimeout: boolean;
|
|
72
|
+
_lookUpRemainOnError: boolean;
|
|
172
73
|
/** @deprecated TODO 移除 */
|
|
173
74
|
_needSpeedEndOnTimeout: boolean;
|
|
174
75
|
bindAdCloseLister: any;
|
|
@@ -180,11 +81,11 @@ declare class RewardAdNovel extends RewardAdFather {
|
|
|
180
81
|
/**
|
|
181
82
|
* 初始化
|
|
182
83
|
* 子类可以选择覆盖此方法,或使用默认实现
|
|
183
|
-
* @param {
|
|
84
|
+
* @param {import('./typings/ad.js').IAdOptions} args
|
|
184
85
|
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
185
86
|
* @returns {this} 当前实例
|
|
186
87
|
*/
|
|
187
|
-
initialize(args:
|
|
88
|
+
initialize(args: import("./typings/ad.js").IAdOptions, callback?: (v: IRewardedVideoAd) => void): this;
|
|
188
89
|
_initAdLister(): void;
|
|
189
90
|
/**
|
|
190
91
|
* @param {object} args
|
|
@@ -275,6 +176,7 @@ declare class RewardAdNovel extends RewardAdFather {
|
|
|
275
176
|
/**
|
|
276
177
|
* 广告展示失败分析
|
|
277
178
|
* 子类需要埋点可以选择覆盖此方法
|
|
179
|
+
* ATTENTION:该方法可能会调用两次,一次是show().catch(),一次是onError(),所以需要做好去重处理
|
|
278
180
|
* @protected
|
|
279
181
|
* @param {object} _args
|
|
280
182
|
* @param {string} _args.scene 广告执行场景 必填
|
|
@@ -345,14 +247,14 @@ declare class RewardAdNovel extends RewardAdFather {
|
|
|
345
247
|
/**
|
|
346
248
|
* @override
|
|
347
249
|
* @param {object} [ctx] 广告执行上下文
|
|
348
|
-
* @param {import('./typings/ad.js').
|
|
250
|
+
* @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
|
|
349
251
|
* @param {import('./typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
350
252
|
* @param {import('./typings/ad.js').RecoveredInfo} [ctx.recovered] 恢复重试信息
|
|
351
253
|
* @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
|
|
352
254
|
* @returns {Promise.<object | Undefined>}
|
|
353
255
|
*/
|
|
354
256
|
override ad(ctx?: {
|
|
355
|
-
options?: import("./typings/ad.js").
|
|
257
|
+
options?: import("./typings/ad.js").IAdOptions;
|
|
356
258
|
collection?: import("./typings/ad.js").CallbackCollection;
|
|
357
259
|
recovered?: import("./typings/ad.js").RecoveredInfo;
|
|
358
260
|
}, next?: Function): Promise<object | undefined>;
|
|
@@ -22,18 +22,12 @@ export type IRewordAdConfig = {
|
|
|
22
22
|
* 额外观看广告的次数,合法的数据范围为 1~4,multiton 为 true 时必填
|
|
23
23
|
*/
|
|
24
24
|
multitonRewardTimes?: number | undefined;
|
|
25
|
+
};
|
|
26
|
+
export type IRewordAdOther = {
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
scene?: number | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* 广告超时时间 单位ms - 自用参数,非tt API要求的参数
|
|
31
|
-
*/
|
|
32
|
-
timeout?: number | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* 重试次数 - 自用参数 ,非tt API要求的参数
|
|
28
|
+
* 是否需要在超时情况下结束广告 - 自用参数,非tt API要求的参数
|
|
35
29
|
*/
|
|
36
|
-
|
|
30
|
+
needEndOnTimeout?: boolean | undefined;
|
|
37
31
|
/**
|
|
38
32
|
* 是否绑定永远的错误事件 - 自用参数,非tt API要求的参数
|
|
39
33
|
*/
|
|
@@ -50,10 +44,6 @@ export type InterstitialAdConfig = {
|
|
|
50
44
|
scene?: number | undefined;
|
|
51
45
|
};
|
|
52
46
|
export type IExeCallbackArgs = {
|
|
53
|
-
/**
|
|
54
|
-
* 广告执行场景
|
|
55
|
-
*/
|
|
56
|
-
scene: number;
|
|
57
47
|
/**
|
|
58
48
|
* 是否看完
|
|
59
49
|
*/
|
|
@@ -63,40 +53,77 @@ export type IExeCallbackArgs = {
|
|
|
63
53
|
*/
|
|
64
54
|
count: number;
|
|
65
55
|
/**
|
|
66
|
-
*
|
|
56
|
+
* 广告场景
|
|
57
|
+
*/
|
|
58
|
+
scene?: string;
|
|
59
|
+
/**
|
|
60
|
+
* 广告类型 1:激励视频 2:插屏
|
|
67
61
|
*/
|
|
68
|
-
|
|
62
|
+
adTypeR?: 1 | 2;
|
|
63
|
+
/**
|
|
64
|
+
* 广告结束类型
|
|
65
|
+
*/
|
|
66
|
+
end_type?: "finished" | "halfway";
|
|
69
67
|
};
|
|
70
68
|
export type CallbackCollection = {
|
|
71
69
|
/**
|
|
72
|
-
*
|
|
70
|
+
* 每次外部回调
|
|
73
71
|
*/
|
|
74
|
-
always?: (ctx?: IExeCallbackArgs
|
|
72
|
+
always?: (ctx?: IExeCallbackArgs & {
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}) => void;
|
|
75
75
|
/**
|
|
76
76
|
* 完整看完广告外部回调 不管一个还是几个
|
|
77
77
|
*/
|
|
78
|
-
finished?: (ctx?: IExeCallbackArgs
|
|
78
|
+
finished?: (ctx?: IExeCallbackArgs & {
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}) => void;
|
|
79
81
|
/**
|
|
80
82
|
* 半途退出广告外部回调
|
|
81
83
|
*/
|
|
82
|
-
halfway?: (ctx?: IExeCallbackArgs
|
|
84
|
+
halfway?: (ctx?: IExeCallbackArgs & {
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}) => void;
|
|
83
87
|
/**
|
|
84
88
|
* 取消广告外部回调
|
|
85
89
|
*/
|
|
86
|
-
cancel?: (
|
|
90
|
+
cancel?: () => void;
|
|
87
91
|
/**
|
|
88
92
|
* 展示广告外部回调
|
|
89
93
|
*/
|
|
90
|
-
before?: (ctx?:
|
|
94
|
+
before?: (ctx?: {
|
|
95
|
+
scene: number;
|
|
96
|
+
}) => void;
|
|
91
97
|
/**
|
|
92
98
|
* 展示广告成功外部回调
|
|
93
99
|
*/
|
|
94
|
-
success?: (ctx?:
|
|
100
|
+
success?: (ctx?: {
|
|
101
|
+
scene: number;
|
|
102
|
+
}) => void;
|
|
103
|
+
/**
|
|
104
|
+
* 计时回调 scene: 广告场景 frequency: 广告展示前间隔时间 time: 广告展示时前间戳
|
|
105
|
+
*/
|
|
106
|
+
prelude?: (ctx?: {
|
|
107
|
+
scene: number;
|
|
108
|
+
frequency: number;
|
|
109
|
+
time: number;
|
|
110
|
+
}) => void;
|
|
111
|
+
};
|
|
112
|
+
export type IAdOptionsOther = {
|
|
113
|
+
/**
|
|
114
|
+
* 场景值 - 自用参数,非tt API要求的参数
|
|
115
|
+
*/
|
|
116
|
+
scene?: number | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* 广告超时时间 单位ms - 自用参数,非tt API要求的参数
|
|
119
|
+
*/
|
|
120
|
+
timeout?: number | undefined;
|
|
95
121
|
/**
|
|
96
|
-
*
|
|
122
|
+
* 重试次数 - 自用参数 ,非tt API要求的参数
|
|
97
123
|
*/
|
|
98
|
-
|
|
124
|
+
retry: number;
|
|
99
125
|
};
|
|
126
|
+
export type IAdOptions = IRewordAdConfig & IRewordAdOther & IAdOptionsOther;
|
|
100
127
|
export type RecoveredInfo = {
|
|
101
128
|
/**
|
|
102
129
|
* 恢复重试次数
|
|
@@ -111,48 +138,46 @@ export type RecoveredInfo = {
|
|
|
111
138
|
*/
|
|
112
139
|
message: string;
|
|
113
140
|
};
|
|
114
|
-
export type
|
|
141
|
+
export type IApiError = {
|
|
115
142
|
/**
|
|
116
|
-
*
|
|
143
|
+
* 错误信息
|
|
117
144
|
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 是否看完
|
|
121
|
-
*/
|
|
122
|
-
isEnded: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* 完整观看次数
|
|
125
|
-
*/
|
|
126
|
-
count: number;
|
|
145
|
+
errMsg?: string;
|
|
127
146
|
/**
|
|
128
|
-
*
|
|
147
|
+
* 错误码
|
|
129
148
|
*/
|
|
130
|
-
|
|
149
|
+
errorCode?: number;
|
|
131
150
|
/**
|
|
132
|
-
*
|
|
151
|
+
* 错误信息
|
|
133
152
|
*/
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
|
|
137
|
-
*/
|
|
138
|
-
circle?: (args: {
|
|
139
|
-
ignoreRemain: boolean;
|
|
140
|
-
scene: number;
|
|
141
|
-
}) => void;
|
|
153
|
+
message?: string;
|
|
142
154
|
};
|
|
155
|
+
export type ICallbackArgs = IExeCallbackArgs;
|
|
143
156
|
export type IConnection = {
|
|
144
157
|
/**
|
|
145
158
|
* 广告中途退出回调
|
|
146
159
|
*/
|
|
147
|
-
onHalfway?: (args: ICallbackArgs
|
|
160
|
+
onHalfway?: (args: ICallbackArgs & {
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
}) => void;
|
|
148
163
|
/**
|
|
149
164
|
* 广告展示回调
|
|
150
165
|
*/
|
|
151
|
-
onShow?: (args:
|
|
166
|
+
onShow?: (args: {
|
|
167
|
+
scene: number;
|
|
168
|
+
}) => void;
|
|
152
169
|
/**
|
|
153
170
|
* 广告执行成功回调
|
|
154
171
|
*/
|
|
155
|
-
onFinish?: (args: ICallbackArgs
|
|
172
|
+
onFinish?: (args: ICallbackArgs & {
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
}) => void;
|
|
175
|
+
/**
|
|
176
|
+
* 广告执行成功回调
|
|
177
|
+
*/
|
|
178
|
+
onAlways?: (args: ICallbackArgs & {
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}) => void;
|
|
156
181
|
/**
|
|
157
182
|
* 广告执行失败回调
|
|
158
183
|
*/
|
|
@@ -162,19 +187,19 @@ export type IConstructArgs = {
|
|
|
162
187
|
/**
|
|
163
188
|
* 初始化标识
|
|
164
189
|
*/
|
|
165
|
-
sign
|
|
190
|
+
sign?: string;
|
|
166
191
|
/**
|
|
167
|
-
*
|
|
192
|
+
* 是否保留tt激励视频广告实例
|
|
168
193
|
*/
|
|
169
|
-
|
|
194
|
+
preserveOnEnd?: boolean;
|
|
170
195
|
/**
|
|
171
|
-
*
|
|
196
|
+
* 是否需要在超时情况下结束广告
|
|
172
197
|
*/
|
|
173
|
-
|
|
198
|
+
needEndOnTimeout?: boolean;
|
|
174
199
|
/**
|
|
175
|
-
*
|
|
200
|
+
* 是否需要在错误情况下查询剩余次数
|
|
176
201
|
*/
|
|
177
|
-
|
|
202
|
+
lookUpRemainOnError?: boolean;
|
|
178
203
|
/**
|
|
179
204
|
* 激励视频参数 (可选)
|
|
180
205
|
*/
|
package/package.json
CHANGED
|
@@ -1,91 +1,97 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@singcl/ad-execute-manager",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "A powerful and flexible ad execution management library for handling reward-based ads, interstitial ads, and other advertising formats in JavaScript applications.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"import": "./dist/index.js",
|
|
9
|
-
"require": "./dist/index.cjs",
|
|
10
|
-
"types": "./dist/index.d.ts"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"main": "./dist/index.cjs",
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"author": {
|
|
19
|
-
"name": "singcl",
|
|
20
|
-
"email": "iambabyer@gmail.com",
|
|
21
|
-
"url": "https://github.com/singcl"
|
|
22
|
-
},
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"homepage": "https://
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/singcl/ad-execute-manager.git"
|
|
28
|
-
},
|
|
29
|
-
"bugs": {
|
|
30
|
-
"url": "https://github.com/singcl/ad-execute-manager/issues"
|
|
31
|
-
},
|
|
32
|
-
"engines": {
|
|
33
|
-
"node": ">=
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"packages:
|
|
59
|
-
"packages:
|
|
60
|
-
"packages:
|
|
61
|
-
"packages:
|
|
62
|
-
"packages:
|
|
63
|
-
"packages:
|
|
64
|
-
"packages:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"@
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"@ad-execute-manager/
|
|
88
|
-
"@ad-execute-manager/
|
|
89
|
-
"@ad-execute-manager/
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@singcl/ad-execute-manager",
|
|
3
|
+
"version": "2.0.12",
|
|
4
|
+
"description": "A powerful and flexible ad execution management library for handling reward-based ads, interstitial ads, and other advertising formats in JavaScript applications.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"require": "./dist/index.cjs",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "singcl",
|
|
20
|
+
"email": "iambabyer@gmail.com",
|
|
21
|
+
"url": "https://github.com/singcl"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"homepage": "https://npmx.dev/package/@singcl/ad-execute-manager",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/singcl/ad-execute-manager.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/singcl/ad-execute-manager/issues"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=8.0.0",
|
|
34
|
+
"npm": ">=6.0.0",
|
|
35
|
+
"yarn": ">=1.0.0",
|
|
36
|
+
"pnpm": ">=8.0.0"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"ad",
|
|
43
|
+
"advertisement",
|
|
44
|
+
"reward-ad",
|
|
45
|
+
"interstitial-ad",
|
|
46
|
+
"ad-manager",
|
|
47
|
+
"ad-execution",
|
|
48
|
+
"javascript",
|
|
49
|
+
"nodejs"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "rslib build && tsc",
|
|
53
|
+
"dev": "rslib build --watch",
|
|
54
|
+
"format": "prettier --write .",
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"test": "rstest",
|
|
57
|
+
"prepublishOnly": "npm i && npm run build",
|
|
58
|
+
"packages:install": "node build-packages.js install",
|
|
59
|
+
"packages:build": "node build-packages.js build",
|
|
60
|
+
"packages:publish": "node build-packages.js publish",
|
|
61
|
+
"packages:publish:patch": "node build-packages.js publish patch",
|
|
62
|
+
"packages:publish:minor": "node build-packages.js publish minor",
|
|
63
|
+
"packages:publish:major": "node build-packages.js publish major",
|
|
64
|
+
"packages:lint": "node build-packages.js lint",
|
|
65
|
+
"packages:format": "node build-packages.js format",
|
|
66
|
+
"packages:clean": "node build-packages.js clean",
|
|
67
|
+
"packages:all": "node build-packages.js all",
|
|
68
|
+
"packages:all:patch": "node build-packages.js all patch",
|
|
69
|
+
"packages:all:minor": "node build-packages.js all minor",
|
|
70
|
+
"packages:all:major": "node build-packages.js all major"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@babel/eslint-parser": "^7.28.5",
|
|
74
|
+
"@babel/preset-env": "^7.28.5",
|
|
75
|
+
"@douyin-microapp/typings": "^1.3.1",
|
|
76
|
+
"@eslint/js": "^9.39.1",
|
|
77
|
+
"@rslib/core": "^0.18.5",
|
|
78
|
+
"@rstest/core": "^0.7.2",
|
|
79
|
+
"@singcl/ad-execute-manager": "^1.11.12",
|
|
80
|
+
"eslint": "^9.39.2",
|
|
81
|
+
"eslint-plugin-import": "^2.32.0",
|
|
82
|
+
"globals": "^16.5.0",
|
|
83
|
+
"prettier": "^3.7.3",
|
|
84
|
+
"typescript": "^5.9.3"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@ad-execute-manager/core": "^2.0.5",
|
|
88
|
+
"@ad-execute-manager/logger": "^2.0.5",
|
|
89
|
+
"@ad-execute-manager/ad-reward": "^2.0.5",
|
|
90
|
+
"@ad-execute-manager/ad-interstitial": "^2.0.5",
|
|
91
|
+
"@ad-execute-manager/count-recorder": "^2.0.5",
|
|
92
|
+
"@ad-execute-manager/serializable-error": "^2.0.5",
|
|
93
|
+
"@ad-execute-manager/storage": "^2.0.5",
|
|
94
|
+
"@ad-execute-manager/event": "^2.0.5",
|
|
95
|
+
"@ad-execute-manager/analytics": "^2.0.5"
|
|
96
|
+
}
|
|
97
|
+
}
|