@singcl/ad-execute-manager 1.0.13 → 1.0.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/dist/ad/RewardAdNovel.d.ts +370 -0
- package/package.json +1 -1
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
export default RewardAdNovel;
|
|
2
|
+
export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
|
|
3
|
+
export type ICallbackArgs = {
|
|
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
|
+
* 是否保留tt激励视频广告实例
|
|
57
|
+
*/
|
|
58
|
+
preserveOnEnd?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 是否需要在超时情况下结束广告
|
|
61
|
+
*/
|
|
62
|
+
needEndOnTimeout?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 激励视频参数 (可选)
|
|
65
|
+
*/
|
|
66
|
+
adConfig?: IRewordAdConfig | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 回调集合
|
|
69
|
+
*/
|
|
70
|
+
collection?: IConnection | undefined;
|
|
71
|
+
};
|
|
72
|
+
export type ICloseArgs = {
|
|
73
|
+
/**
|
|
74
|
+
* 是否看完
|
|
75
|
+
*/
|
|
76
|
+
isEnded: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 完整观看次数
|
|
79
|
+
*/
|
|
80
|
+
count: number;
|
|
81
|
+
};
|
|
82
|
+
export type IEndArgs = {
|
|
83
|
+
/**
|
|
84
|
+
* 是否解锁全部
|
|
85
|
+
*/
|
|
86
|
+
can_unlock_all?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* 是否解锁小说
|
|
89
|
+
*/
|
|
90
|
+
can_unlock_novel?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* 剩余次数
|
|
93
|
+
*/
|
|
94
|
+
remain?: number;
|
|
95
|
+
/**
|
|
96
|
+
* 结束类型
|
|
97
|
+
*/
|
|
98
|
+
end_type?: "halfway" | "finished";
|
|
99
|
+
};
|
|
100
|
+
export type IRewardedVideoAd = {
|
|
101
|
+
/**
|
|
102
|
+
* 显示激励视频广告
|
|
103
|
+
*/
|
|
104
|
+
show: () => Promise<void>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* @typedef {import('../typings/ad.js').IRewordAdConfig} IRewordAdConfig
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* @typedef ICallbackArgs
|
|
111
|
+
* @property {number} scene 广告执行场景
|
|
112
|
+
* @property {boolean} isEnded 是否看完
|
|
113
|
+
* @property {number} count 完整观看次数
|
|
114
|
+
* @property {() => void} [end] 执行下一个任务的回调函数,手动调用以继续执行流程[end]
|
|
115
|
+
* @property {(args: {ignoreRemain: boolean, scene: number}) => void} [circle] 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* @typedef IConnection
|
|
120
|
+
* @property {(args: ICallbackArgs) => void} [onHalfway] 广告中途退出回调
|
|
121
|
+
* @property {(args: ICallbackArgs) => void} [onShow] 广告展示回调
|
|
122
|
+
* @property {(args: ICallbackArgs) => void} [onFinish] 广告执行成功回调
|
|
123
|
+
* @property {(args: ICallbackArgs) => void} [onAlways] 广告执行成功回调
|
|
124
|
+
* @property {(e:unknown) => void} [onError] 广告执行失败回调
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* @typedef IConstructArgs
|
|
128
|
+
* @property {string} [sign] 初始化标识
|
|
129
|
+
* @property {boolean} [preserveOnEnd] 是否保留tt激励视频广告实例
|
|
130
|
+
* @property {boolean} [needEndOnTimeout] 是否需要在超时情况下结束广告
|
|
131
|
+
* @property {IRewordAdConfig=} [adConfig] 激励视频参数 (可选)
|
|
132
|
+
* @property {IConnection=} [collection] 回调集合
|
|
133
|
+
*/
|
|
134
|
+
/**
|
|
135
|
+
* @typedef ICloseArgs
|
|
136
|
+
* @property {boolean} isEnded 是否看完
|
|
137
|
+
* @property {number} count 完整观看次数
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* @typedef IEndArgs
|
|
141
|
+
* @property {boolean} [can_unlock_all] 是否解锁全部
|
|
142
|
+
* @property {boolean} [can_unlock_novel] 是否解锁小说
|
|
143
|
+
* @property {number} [remain] 剩余次数
|
|
144
|
+
* @property {'halfway' | 'finished'} [end_type] 结束类型
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
/**
|
|
148
|
+
* @typedef IRewardedVideoAd
|
|
149
|
+
* @property {() => Promise.<void>} show 显示激励视频广告
|
|
150
|
+
*/
|
|
151
|
+
declare class RewardAdNovel extends RewardAdFather {
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param {IConstructArgs} args
|
|
155
|
+
* @returns {RewardAdNovel}
|
|
156
|
+
*/
|
|
157
|
+
static build(args: IConstructArgs): RewardAdNovel;
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* @returns {RewardAdNovel}
|
|
161
|
+
*/
|
|
162
|
+
static getInstance(): RewardAdNovel;
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param {IConstructArgs} args
|
|
166
|
+
* @returns {RewardAdNovel}
|
|
167
|
+
*/
|
|
168
|
+
static "new"(args: IConstructArgs): RewardAdNovel;
|
|
169
|
+
/**
|
|
170
|
+
* @param {IConstructArgs} args
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
constructor(args: IConstructArgs);
|
|
174
|
+
_onHalfway: any;
|
|
175
|
+
_onShow: any;
|
|
176
|
+
_onFinish: any;
|
|
177
|
+
_onAlways: any;
|
|
178
|
+
_onError: any;
|
|
179
|
+
_alwaysCallback: any;
|
|
180
|
+
_halfwayCallback: any;
|
|
181
|
+
_finishedCallback: any;
|
|
182
|
+
_resolve: any;
|
|
183
|
+
_next: any;
|
|
184
|
+
/** @type {number} 广告执行场景 */
|
|
185
|
+
_scene: number;
|
|
186
|
+
_adTimeout: any;
|
|
187
|
+
_adTimeoutTime: number;
|
|
188
|
+
_adBeforeShowTimer: any;
|
|
189
|
+
_adBeforeShowTime: number;
|
|
190
|
+
_adSpeedCloseTimer: any;
|
|
191
|
+
_adSpeedCloseTime: number;
|
|
192
|
+
_needEndOnTimeout: boolean;
|
|
193
|
+
/** @deprecated TODO 移除 */
|
|
194
|
+
_needSpeedEndOnTimeout: boolean;
|
|
195
|
+
bindAdCloseLister: any;
|
|
196
|
+
bindAdErrorLister: any;
|
|
197
|
+
bindAdLoadLister: any;
|
|
198
|
+
bindApiAdErrorLister: any;
|
|
199
|
+
_bindShiftCloseLister: any;
|
|
200
|
+
_bindShiftErrorLister: any;
|
|
201
|
+
/**
|
|
202
|
+
* 初始化
|
|
203
|
+
* 子类可以选择覆盖此方法,或使用默认实现
|
|
204
|
+
* @param {IRewordAdConfig} args
|
|
205
|
+
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
206
|
+
* @returns {this} 当前实例
|
|
207
|
+
*/
|
|
208
|
+
initialize(args: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
|
|
209
|
+
_initAdLister(): void;
|
|
210
|
+
/**
|
|
211
|
+
* @param {object} args
|
|
212
|
+
* @param {number} [args.retry] 重试次数
|
|
213
|
+
*/
|
|
214
|
+
_initNovelConfig(args: {
|
|
215
|
+
retry?: number;
|
|
216
|
+
}): void;
|
|
217
|
+
novelConfig: RewardAdNovelConfig;
|
|
218
|
+
_onInnerExecuteBefore(): any;
|
|
219
|
+
_onInnerAdShowSuccess(): any;
|
|
220
|
+
/**
|
|
221
|
+
* 广告展示超时设置
|
|
222
|
+
* @param {object} args
|
|
223
|
+
* @param {string} args.scene 广告执行场景 必填
|
|
224
|
+
* @param {Function} args.end 结束当前广告任务的回调函数 必填
|
|
225
|
+
*/
|
|
226
|
+
_setAdTimeout(args: {
|
|
227
|
+
scene: string;
|
|
228
|
+
end: Function;
|
|
229
|
+
}): void;
|
|
230
|
+
/**
|
|
231
|
+
* 广告展示前定时器
|
|
232
|
+
* @param {object} args
|
|
233
|
+
* @param {string} args.scene 广告执行场景 必填
|
|
234
|
+
* @param {Function} args.prelude 广告展示前回调函数 可选
|
|
235
|
+
*/
|
|
236
|
+
_adPreludeInterval(args: {
|
|
237
|
+
scene: string;
|
|
238
|
+
prelude: Function;
|
|
239
|
+
}): void;
|
|
240
|
+
_clearAdTimeout(): void;
|
|
241
|
+
get rewardAd(): any;
|
|
242
|
+
/**
|
|
243
|
+
* 确保广告按顺序执行
|
|
244
|
+
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
245
|
+
* @param {IRewordAdConfig} [ctx.options] 广告执行选项
|
|
246
|
+
* @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
247
|
+
*
|
|
248
|
+
* @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
|
|
249
|
+
*/
|
|
250
|
+
addExecuteManager(ctx?: {
|
|
251
|
+
options?: IRewordAdConfig;
|
|
252
|
+
collection?: import("../typings/ad.js").CallbackCollection;
|
|
253
|
+
}): Promise<(IEndArgs & ICloseArgs) | undefined>;
|
|
254
|
+
/**
|
|
255
|
+
* @param {object} [ctx] 广告执行上下文
|
|
256
|
+
* @param {import('../typings/ad.js').IRewordAdConfig} [ctx.options] 广告执行选项
|
|
257
|
+
* @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
258
|
+
* @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
|
|
259
|
+
*
|
|
260
|
+
* @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
|
|
261
|
+
*/
|
|
262
|
+
ad(ctx?: {
|
|
263
|
+
options?: import("../typings/ad.js").IRewordAdConfig;
|
|
264
|
+
collection?: import("../typings/ad.js").CallbackCollection;
|
|
265
|
+
}, next?: Function): Promise<(IEndArgs & ICloseArgs) | undefined>;
|
|
266
|
+
/**
|
|
267
|
+
* @param {object} [ctx] 广告执行上下文
|
|
268
|
+
* @param {object} [ctx.options] 广告执行选项
|
|
269
|
+
* @param {number} [ctx.options.scene] 广告执行场景
|
|
270
|
+
* @param {object} ctx.collection 回调集合
|
|
271
|
+
* @param {(v?: unknown) => void} ctx.collection.resolve 广告执行成功的回调函数
|
|
272
|
+
* @param {(v?: unknown) => void} [ctx.collection.reject] 广告执行失败的回调函数
|
|
273
|
+
* @param {(v?: unknown) => void} [ctx.collection.before] 广告执行前的回调函数
|
|
274
|
+
* @param {(v?: unknown) => void} [ctx.collection.success] 广告执行成功的回调函数
|
|
275
|
+
* @param {(v?: unknown) => void} [ctx.collection.prelude] 拉起广告前计时的回调函数
|
|
276
|
+
* @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
|
|
277
|
+
*/
|
|
278
|
+
_adInner(ctx?: {
|
|
279
|
+
options?: {
|
|
280
|
+
scene?: number;
|
|
281
|
+
};
|
|
282
|
+
collection: {
|
|
283
|
+
resolve: (v?: unknown) => void;
|
|
284
|
+
reject?: (v?: unknown) => void;
|
|
285
|
+
before?: (v?: unknown) => void;
|
|
286
|
+
success?: (v?: unknown) => void;
|
|
287
|
+
prelude?: (v?: unknown) => void;
|
|
288
|
+
};
|
|
289
|
+
}, next?: Function): void;
|
|
290
|
+
_before: (v?: unknown) => void;
|
|
291
|
+
_success: (v?: unknown) => void;
|
|
292
|
+
/**
|
|
293
|
+
* 广告加载
|
|
294
|
+
* @returns
|
|
295
|
+
*/
|
|
296
|
+
adLoad(): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* 广告展示
|
|
299
|
+
* @returns
|
|
300
|
+
*/
|
|
301
|
+
adShow(): Promise<void>;
|
|
302
|
+
_outerCloseCallback(args: any): void;
|
|
303
|
+
_outerHalfwayCallback(args: any): void;
|
|
304
|
+
_outerFinishedCallback(args: any): void;
|
|
305
|
+
/**
|
|
306
|
+
* 关闭激励视频
|
|
307
|
+
* @param {ICloseArgs} args
|
|
308
|
+
*/
|
|
309
|
+
adCloseLister(args: ICloseArgs): void;
|
|
310
|
+
adErrorLister(e: any): void;
|
|
311
|
+
apiAdErrorLister(e: any): void;
|
|
312
|
+
/**
|
|
313
|
+
* 激励视频广告组件**成功**拉取广告素材时会触发
|
|
314
|
+
* 创建激励时候后会自动拉取广告素材,如果广告拉取成功,也会触发此事件,不管是否调用show方法
|
|
315
|
+
* @param {unknown} e
|
|
316
|
+
*/
|
|
317
|
+
adLoadLister(e: unknown): void;
|
|
318
|
+
adDestroy(): void;
|
|
319
|
+
_shiftCloseLister(args: any): void;
|
|
320
|
+
_shiftErrorLister(args: any): void;
|
|
321
|
+
/**
|
|
322
|
+
* 手动出栈
|
|
323
|
+
*/
|
|
324
|
+
shift(): void;
|
|
325
|
+
}
|
|
326
|
+
import RewardAdFather from './RewardAdFather.js';
|
|
327
|
+
declare class RewardAdNovelConfig {
|
|
328
|
+
/**
|
|
329
|
+
*
|
|
330
|
+
* @param {object} args
|
|
331
|
+
* @param {string} args.sign 初始化标识
|
|
332
|
+
* @param {number} [args.retry] 重试次数
|
|
333
|
+
* @returns {RewardAdNovelConfig}
|
|
334
|
+
*/
|
|
335
|
+
static "new"(args: {
|
|
336
|
+
sign: string;
|
|
337
|
+
retry?: number;
|
|
338
|
+
}): RewardAdNovelConfig;
|
|
339
|
+
/**
|
|
340
|
+
*
|
|
341
|
+
* @param {object} [args]
|
|
342
|
+
* @param {number} [args.retry]
|
|
343
|
+
*/
|
|
344
|
+
constructor(args?: {
|
|
345
|
+
retry?: number;
|
|
346
|
+
});
|
|
347
|
+
frequency: {
|
|
348
|
+
total: number;
|
|
349
|
+
current: number;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
*
|
|
353
|
+
* @param {object} [args]
|
|
354
|
+
* @param {number} [args.retry]
|
|
355
|
+
*/
|
|
356
|
+
_init(args?: {
|
|
357
|
+
retry?: number;
|
|
358
|
+
}): void;
|
|
359
|
+
/**
|
|
360
|
+
*
|
|
361
|
+
* @param {object} [args]
|
|
362
|
+
* @param {number} [args.retry]
|
|
363
|
+
*/
|
|
364
|
+
_adTimes(args?: {
|
|
365
|
+
retry?: number;
|
|
366
|
+
}): void;
|
|
367
|
+
reset(): void;
|
|
368
|
+
updateRetry(): void;
|
|
369
|
+
remain(): number;
|
|
370
|
+
}
|