@singcl/ad-execute-manager 2.0.0 → 2.0.2

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.
Files changed (43) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +558 -631
  3. package/dist/ad/{InterstitialAdFather.d.ts → src/InterstitialAdFather.d.ts} +5 -5
  4. package/dist/ad/{InterstitialAdNovel.d.ts → src/InterstitialAdNovel.d.ts} +8 -8
  5. package/dist/ad/{RewardAdFather.d.ts → src/RewardAdFather.d.ts} +6 -6
  6. package/dist/ad/{RewardAdNovel.d.ts → src/RewardAdNovel.d.ts} +65 -36
  7. package/dist/ad/src/index.d.ts +5 -0
  8. package/dist/{typings → ad/src/typings}/ad.d.ts +0 -4
  9. package/dist/analytics/{AdAnalyticsJS.d.ts → src/AdAnalyticsJS.d.ts} +1 -1
  10. package/dist/analytics/src/index.d.ts +1 -0
  11. package/dist/core/{AdExecuteManager.d.ts → src/AdExecuteManager.d.ts} +27 -10
  12. package/dist/core/src/index.d.ts +1 -0
  13. package/dist/core/src/typings/ad.d.ts +208 -0
  14. package/dist/core/typings/ad.d.ts +208 -0
  15. package/dist/helper/{PubSub.d.ts → src/PubSub.d.ts} +1 -1
  16. package/dist/helper/src/index.d.ts +6 -0
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.d.ts +13 -13
  19. package/dist/index.js +2 -2
  20. package/dist/{other → tools/src}/RewardAdGlobalRecorder.d.ts +2 -2
  21. package/dist/{other → tools/src}/RewardAdSceneTriggerManager.d.ts +11 -11
  22. package/dist/tools/src/const.d.ts +3 -0
  23. package/dist/tools/src/index.d.ts +3 -0
  24. package/dist/tools/src/typings/ad.d.ts +208 -0
  25. package/dist/tools/src/typings/common.d.ts +14 -0
  26. package/dist/tools/src/typings/create-interstitial-ad.d.ts +42 -0
  27. package/dist/tools/src/typings/create-rewarded-video-ad.d.ts +42 -0
  28. package/dist/tools/src/typings/tracker.d.ts +1 -0
  29. package/package.json +6 -2
  30. /package/dist/{const → ad/src/const}/const.d.ts +0 -0
  31. /package/dist/{typings → ad/src/typings}/common.d.ts +0 -0
  32. /package/dist/{typings → ad/src/typings}/create-interstitial-ad.d.ts +0 -0
  33. /package/dist/{typings → ad/src/typings}/create-rewarded-video-ad.d.ts +0 -0
  34. /package/dist/{typings → ad/src/typings}/tracker.d.ts +0 -0
  35. /package/dist/{utils → ad/src/utils}/functional.d.ts +0 -0
  36. /package/dist/core/{_util.d.ts → src/_util.d.ts} +0 -0
  37. /package/dist/core/{compose.d.ts → src/compose.d.ts} +0 -0
  38. /package/dist/helper/{CountRecorder.d.ts → src/CountRecorder.d.ts} +0 -0
  39. /package/dist/helper/{EventEmitter.d.ts → src/EventEmitter.d.ts} +0 -0
  40. /package/dist/helper/{Logger.d.ts → src/Logger.d.ts} +0 -0
  41. /package/dist/helper/{SerializableError.d.ts → src/SerializableError.d.ts} +0 -0
  42. /package/dist/helper/{Storage.d.ts → src/Storage.d.ts} +0 -0
  43. /package/dist/{other → tools/src}/LovelUnlockManager.d.ts +0 -0
@@ -1,11 +1,11 @@
1
1
  export default InterstitialAdFather;
2
- export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
3
- export type CallbackCollection = import("../typings/ad.js").CallbackCollection;
4
- export type IConstructArgs = import("../typings/ad.js").IConstructArgs;
2
+ export type IRewordAdConfig = import("./typings/ad.js").IRewordAdConfig;
3
+ export type CallbackCollection = import("./typings/ad.js").CallbackCollection;
4
+ export type IConstructArgs = import("./typings/ad.js").IConstructArgs;
5
5
  /**
6
6
  * 激励视频实例
7
7
  */
8
- export type InterstitialAd = import("../typings/create-interstitial-ad.js").InterstitialAd;
8
+ export type InterstitialAd = import("./typings/create-interstitial-ad.js").InterstitialAd;
9
9
  export type IRewardedVideoAd = {
10
10
  /**
11
11
  * 显示激励视频广告
@@ -160,4 +160,4 @@ declare class InterstitialAdFather {
160
160
  */
161
161
  placeholder(): any;
162
162
  }
163
- import { Logger } from '../helper/Logger';
163
+ import { Logger } from '@ad-execute-manager/helper';
@@ -1,5 +1,5 @@
1
1
  export default InterstitialAdNovel;
2
- export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
2
+ export type IRewordAdConfig = import("./typings/ad.js").IRewordAdConfig;
3
3
  export type ICallbackArgs = {
4
4
  /**
5
5
  * 广告执行场景
@@ -104,7 +104,7 @@ export type IRewardedVideoAd = {
104
104
  show: () => Promise<void>;
105
105
  };
106
106
  /**
107
- * @typedef {import('../typings/ad.js').IRewordAdConfig} IRewordAdConfig
107
+ * @typedef {import('./typings/ad.js').IRewordAdConfig} IRewordAdConfig
108
108
  */
109
109
  /**
110
110
  * @typedef ICallbackArgs
@@ -331,26 +331,26 @@ declare class InterstitialAdNovel extends InterstitialAdFather {
331
331
  * @override
332
332
  * @param {Object} [ctx] 上下文对象,用于传递数据和状态
333
333
  * @param {IRewordAdConfig} [ctx.options] 广告执行选项
334
- * @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
334
+ * @param {import('./typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
335
335
  * @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
336
336
  */
337
337
  override addExecuteManager(ctx?: {
338
338
  options?: IRewordAdConfig;
339
- collection?: import("../typings/ad.js").CallbackCollection;
339
+ collection?: import("./typings/ad.js").CallbackCollection;
340
340
  }): Promise<(IEndArgs & ICloseArgs) | undefined>;
341
341
  /**
342
342
  * ATTENTION: 应用一旦进入后台,90%概率.show() 方法的.then() 回调将不会被执行, .catch() 回调也不会被执行。
343
343
  * 此时将进入超时处理逻辑
344
344
  * @override
345
345
  * @param {object} [ctx] 广告执行上下文
346
- * @param {import('../typings/ad.js').IRewordAdConfig} [ctx.options] 广告执行选项
347
- * @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
346
+ * @param {import('./typings/ad.js').IRewordAdConfig} [ctx.options] 广告执行选项
347
+ * @param {import('./typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
348
348
  * @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
349
349
  * @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
350
350
  */
351
351
  override ad(ctx?: {
352
- options?: import("../typings/ad.js").IRewordAdConfig;
353
- collection?: import("../typings/ad.js").CallbackCollection;
352
+ options?: import("./typings/ad.js").IRewordAdConfig;
353
+ collection?: import("./typings/ad.js").CallbackCollection;
354
354
  }, next?: Function): Promise<(IEndArgs & ICloseArgs) | undefined>;
355
355
  /**
356
356
  * ATTENTION: 应用一旦进入后台,90%概率.show() 方法的.then() 回调将不会被执行, .catch() 回调也不会被执行。
@@ -1,9 +1,9 @@
1
1
  export default RewardAdFather;
2
- export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
3
- export type CallbackCollection = import("../typings/ad.js").CallbackCollection;
4
- export type RecoveredInfo = import("../typings/ad.js").RecoveredInfo;
5
- export type IConstructArgs = import("../typings/ad.js").IConstructArgs;
6
- export type RewardedVideoAd = import("../typings/create-rewarded-video-ad.js").RewardedVideoAd;
2
+ export type IRewordAdConfig = import("./typings/ad.js").IRewordAdConfig;
3
+ export type CallbackCollection = import("./typings/ad.js").CallbackCollection;
4
+ export type RecoveredInfo = import("./typings/ad.js").RecoveredInfo;
5
+ export type IConstructArgs = import("./typings/ad.js").IConstructArgs;
6
+ export type RewardedVideoAd = import("./typings/create-rewarded-video-ad.js").RewardedVideoAd;
7
7
  export type IRewardedVideoAd = {
8
8
  /**
9
9
  * 显示激励视频广告
@@ -178,4 +178,4 @@ declare class RewardAdFather {
178
178
  */
179
179
  placeholder(): any;
180
180
  }
181
- import { Logger } from '../helper/Logger';
181
+ import { Logger } from '@ad-execute-manager/helper';
@@ -1,5 +1,5 @@
1
1
  export default RewardAdNovel;
2
- export type IRewordAdConfig = import("../typings/ad.js").IRewordAdConfig;
2
+ export type IRewordAdConfig = any;
3
3
  export type ICallbackArgs = {
4
4
  /**
5
5
  * 广告执行场景
@@ -64,10 +64,6 @@ export type IConstructArgs = {
64
64
  * 是否需要在超时情况下结束广告
65
65
  */
66
66
  needEndOnTimeout?: boolean;
67
- /**
68
- * 关闭广告时候是否需要主动结束任务
69
- */
70
- proactive?: boolean;
71
67
  /**
72
68
  * 激励视频参数 (可选)
73
69
  */
@@ -137,7 +133,6 @@ export type IRewardedVideoAd = {
137
133
  * @property {boolean} [log] 是否开启日志
138
134
  * @property {boolean} [preserveOnEnd] 是否保留tt激励视频广告实例
139
135
  * @property {boolean} [needEndOnTimeout] 是否需要在超时情况下结束广告
140
- * @property {boolean} [proactive] 关闭广告时候是否需要主动结束任务
141
136
  * @property {IRewordAdConfig=} [adConfig] 激励视频参数 (可选)
142
137
  * @property {IConnection=} [collection] 回调集合
143
138
  */
@@ -202,16 +197,13 @@ declare class RewardAdNovel extends RewardAdFather {
202
197
  _needEndOnTimeout: boolean;
203
198
  /** @deprecated TODO 移除 */
204
199
  _needSpeedEndOnTimeout: boolean;
205
- /**
206
- * @description 关闭广告时候是否需要主动结束任务
207
- */
208
- _proactive: boolean;
209
200
  bindAdCloseLister: any;
210
201
  bindAdErrorLister: any;
211
202
  bindAdLoadLister: any;
212
203
  bindApiAdErrorLister: any;
213
204
  _bindShiftCloseLister: any;
214
205
  _bindShiftErrorLister: any;
206
+ _adConfig: any;
215
207
  /**
216
208
  * 初始化
217
209
  * 子类可以选择覆盖此方法,或使用默认实现
@@ -240,7 +232,7 @@ declare class RewardAdNovel extends RewardAdFather {
240
232
  _onInnerAdShowSuccess(_args: {
241
233
  scene: string;
242
234
  result?: number;
243
- recovered?: import("../typings/ad.js").RecoveredInfo;
235
+ recovered?: any;
244
236
  }): any;
245
237
  /**
246
238
  * 广告展示超时设置
@@ -305,7 +297,7 @@ declare class RewardAdNovel extends RewardAdFather {
305
297
  scene: string;
306
298
  msg?: string;
307
299
  result: 0 | 1;
308
- recovered?: import("../typings/ad.js").RecoveredInfo;
300
+ recovered?: any;
309
301
  }): any;
310
302
  /**
311
303
  * 广告展示失败分析
@@ -376,7 +368,7 @@ declare class RewardAdNovel extends RewardAdFather {
376
368
  ad_is_completed: number;
377
369
  ad_count: number;
378
370
  }): any;
379
- get rewardAd(): import("../typings/create-rewarded-video-ad.js").RewardedVideoAd;
371
+ get rewardAd(): import("./typings/create-rewarded-video-ad.js").RewardedVideoAd;
380
372
  /**
381
373
  * 确保广告按顺序执行
382
374
  * @override
@@ -387,7 +379,7 @@ declare class RewardAdNovel extends RewardAdFather {
387
379
  */
388
380
  override addExecuteManager(ctx?: {
389
381
  options?: IRewordAdConfig;
390
- collection?: import("../typings/ad.js").CallbackCollection;
382
+ collection?: any;
391
383
  }): Promise<(IEndArgs & ICloseArgs) | undefined>;
392
384
  /**
393
385
  * @override
@@ -399,11 +391,11 @@ declare class RewardAdNovel extends RewardAdFather {
399
391
  * @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
400
392
  */
401
393
  override ad(ctx?: {
402
- options?: import("../typings/ad.js").IRewordAdConfig;
403
- collection?: import("../typings/ad.js").CallbackCollection;
404
- recovered?: import("../typings/ad.js").RecoveredInfo;
394
+ options?: any;
395
+ collection?: any;
396
+ recovered?: any;
405
397
  }, next?: Function): Promise<(IEndArgs & ICloseArgs) | undefined>;
406
- _recovered: import("../typings/ad.js").RecoveredInfo;
398
+ _recovered: any;
407
399
  /**
408
400
  * @param {object} [ctx] 广告执行上下文
409
401
  * @param {object} [ctx.options] 广告执行选项
@@ -424,7 +416,7 @@ declare class RewardAdNovel extends RewardAdFather {
424
416
  timeout?: number;
425
417
  };
426
418
  collection: object;
427
- recovered?: import("../typings/ad.js").RecoveredInfo;
419
+ recovered?: any;
428
420
  }, next?: Function): void;
429
421
  _before: any;
430
422
  _success: any;
@@ -442,33 +434,70 @@ declare class RewardAdNovel extends RewardAdFather {
442
434
  _outerHalfwayCallback(args: any): void;
443
435
  _outerFinishedCallback(args: any): void;
444
436
  /**
445
- * 关闭激励视频
437
+ * 内部关闭激励视频
438
+ * @private
446
439
  * @param {ICloseArgs} args
447
440
  */
448
- __adCloseLister__(args: ICloseArgs): void;
441
+ private __adCloseLister__;
449
442
  /**
450
- * 关闭激励视频结束任务
451
- * 子类可以重写该方法,如果子类不提供该方法,则使用默认实现
452
- * 如果子类需要主动结束任务,则需要设置proactive为true,同时主动调用end方法
443
+ * 关闭激励视频
444
+ * 子类可重写该方法
445
+ * @protected
453
446
  * @param {object} args
454
- * @param {(ctx: object) => void} args.end 结束任务 如果proactive为true,则需要主动调用end方法,否则不需要调用
455
- * @param {(ctx: object) => void} args.conn 调用传入的回调函数 如果proactive为true,则需要主动调用conn方法,否则不需要调用
447
+ * @param {boolean} args.isEnded 广告是否完成
448
+ * @param {number} args.count 广告执行次数
449
+ * @param {string} args.scene 广告执行场景
450
+ * @param {number} args.adTypeR 广告类型
451
+ * @param {string} args.end_type 广告关闭类型
452
+ * @param {object} [connection] 广告关闭回调集合
453
+ * @param {(ctx: object) => void} [connection.conn] 调用外部传入的回调
454
+ * @param {(ctx: object) => void} [connection.end] 结束任务的回调
455
+ *
456
456
  */
457
- adCloseLister(args: {
458
- end: (ctx: object) => void;
459
- conn: (ctx: object) => void;
460
- }): {
461
- end: (ctx: object) => void;
462
- conn: (ctx: object) => void;
463
- };
464
- adErrorLister(e: any): void;
465
- apiAdErrorLister(e: any): void;
457
+ protected adCloseLister(args: {
458
+ isEnded: boolean;
459
+ count: number;
460
+ scene: string;
461
+ adTypeR: number;
462
+ end_type: string;
463
+ }, connection?: {
464
+ conn?: (ctx: object) => void;
465
+ end?: (ctx: object) => void;
466
+ }): void;
467
+ /**
468
+ * 激励视频广告组件**失败**时会触发
469
+ * @private
470
+ */
471
+ private __adErrorLister__;
466
472
  /**
473
+ * 激励视频广告组件**失败**时会触发
474
+ * @protected
475
+ */
476
+ protected adErrorLister(e: any): any;
477
+ /**
478
+ * 激励视频广告组件api**失败**时会触发
479
+ * @private
480
+ */
481
+ private __apiAdErrorLister__;
482
+ /**
483
+ * 激励视频广告组件api**失败**时会触发
484
+ * @protected
485
+ */
486
+ protected apiAdErrorLister(e: any): any;
487
+ /**
488
+ * @private
489
+ * 激励视频广告组件**成功**拉取广告素材时会触发
490
+ * 创建激励时候后会自动拉取广告素材,如果广告拉取成功,也会触发此事件,不管是否调用show方法
491
+ * @param {unknown} e
492
+ */
493
+ private __adLoadLister__;
494
+ /**
495
+ * @protected
467
496
  * 激励视频广告组件**成功**拉取广告素材时会触发
468
497
  * 创建激励时候后会自动拉取广告素材,如果广告拉取成功,也会触发此事件,不管是否调用show方法
469
498
  * @param {unknown} e
470
499
  */
471
- adLoadLister(e: unknown): void;
500
+ protected adLoadLister(e: unknown): unknown;
472
501
  adDestroy(): void;
473
502
  _shiftCloseLister(args: any): void;
474
503
  _shiftErrorLister(args: any): void;
@@ -0,0 +1,5 @@
1
+ export { AdExecuteManager } from "@ad-execute-manager/core";
2
+ export { default as InterstitialAdFather } from "./InterstitialAdFather";
3
+ export { default as RewardAdFather } from "./RewardAdFather";
4
+ export { default as RewardAdNovel } from "./RewardAdNovel";
5
+ export { default as InterstitialAdNovel } from "./InterstitialAdNovel";
@@ -38,10 +38,6 @@ export type IRewordAdConfig = {
38
38
  * 是否绑定永远的错误事件 - 自用参数,非tt API要求的参数
39
39
  */
40
40
  foreverErrorBind?: boolean | undefined;
41
- /**
42
- * 关闭广告时候是否需要主动结束任务 - 自用参数,非tt API要求的参数
43
- */
44
- proactive?: boolean | undefined;
45
41
  };
46
42
  export type InterstitialAdConfig = {
47
43
  /**
@@ -138,4 +138,4 @@ declare class AdAnalyticsJS {
138
138
  */
139
139
  placeholder(): any;
140
140
  }
141
- import { Logger } from '../helper/Logger';
141
+ import { Logger } from '@ad-execute-manager/helper';
@@ -0,0 +1 @@
1
+ export { default as AdAnalyticsJS } from "./AdAnalyticsJS.js";
@@ -1,17 +1,34 @@
1
1
  export default AdExecuteManager;
2
+ export type IAdInstance = {
3
+ /**
4
+ * 超时时间
5
+ */
6
+ _adTimeoutTime: number;
7
+ /**
8
+ * 初始化广告
9
+ */
10
+ initialize: (ctx: unknown) => IAdInstance;
11
+ /**
12
+ * 显示广告
13
+ */
14
+ ad: (options: unknown, ctx: unknown, recovered: unknown) => Promise<unknown>;
15
+ clear: () => void;
16
+ };
17
+ export type IRewordAdConfig = import("./typings/ad.js").IRewordAdConfig;
18
+ export type CallbackCollection = import("./typings/ad.js").CallbackCollection;
2
19
  export type AdTask = {
3
20
  /**
4
21
  * RewardAdFather的子类实例
5
22
  */
6
- adInstance: import("../ad/RewardAdFather.js").default;
23
+ adInstance: IAdInstance;
7
24
  /**
8
25
  * 广告执行选项
9
26
  */
10
- options: import("../typings/ad.js").IRewordAdConfig;
27
+ options: IRewordAdConfig;
11
28
  /**
12
29
  * 回调集合
13
30
  */
14
- callbackCollection: import("../typings/ad.js").CallbackCollection;
31
+ callbackCollection: CallbackCollection;
15
32
  /**
16
33
  * 广告执行成功的回调函数
17
34
  */
@@ -191,15 +208,15 @@ declare class AdExecuteManager {
191
208
  isVisibilityListenerEnabled(): boolean;
192
209
  /**
193
210
  * 添加广告任务
194
- * @param {import('../ad/RewardAdFather.js').default} adInstance RewardAdFather的子类实例
211
+ * @param {IAdInstance} adInstance RewardAdFather的子类实例
195
212
  * @param {Object} ctx 广告执行上下文
196
- * @param {import('../typings/ad.js').IRewordAdConfig} ctx.options 广告执行选项
197
- * @param {import('../typings/ad.js').CallbackCollection} ctx.collection 回调集合
213
+ * @param {IRewordAdConfig} ctx.options 广告执行选项
214
+ * @param {CallbackCollection} ctx.collection 回调集合
198
215
  * @returns {Promise} 广告执行结果的Promise
199
216
  */
200
- addTask(adInstance: import("../ad/RewardAdFather.js").default, ctx: {
201
- options: import("../typings/ad.js").IRewordAdConfig;
202
- collection: import("../typings/ad.js").CallbackCollection;
217
+ addTask(adInstance: IAdInstance, ctx: {
218
+ options: IRewordAdConfig;
219
+ collection: CallbackCollection;
203
220
  }): Promise<any>;
204
221
  /**
205
222
  * 组合所有任务
@@ -232,4 +249,4 @@ declare class AdExecuteManager {
232
249
  */
233
250
  whenAllTasksComplete(): Promise<void>;
234
251
  }
235
- import { Logger } from '../helper/Logger';
252
+ import { Logger } from '@ad-execute-manager/helper';
@@ -0,0 +1 @@
1
+ export { default as AdExecuteManager } from "./AdExecuteManager.js";
@@ -0,0 +1,208 @@
1
+ export type IRewordAdConfig = {
2
+ /**
3
+ * 激励视频广告id - 必填
4
+ */
5
+ adUnitId: string;
6
+ /**
7
+ * 是否开启进度提醒。开启时广告文案为「再看 n 个xxx」,关闭时为「再看 1 个xxx」。其中 n 表示用户当前还需额外观看广告的次数
8
+ */
9
+ progressTip?: boolean | undefined;
10
+ /**
11
+ * - 再得广告的奖励文案,用户每看完一个广告都会展示,multiton 为 true 时必填。
12
+ * - 文案完整内容为「再看 1 个xxx」,其中 xxx 是 multitonRewardMsg 配置的文案内容,最大长度为 7,
13
+ * - 文案内容根据 multitonRewardMsg 的配置按顺序展示。若 multitonRewardMsg 长度小于 multitonRewardTimes ,
14
+ * - 则后续的激励再得广告文案取 multitonRewardMsg 数组最后一个。
15
+ */
16
+ multitonRewardMsg?: Array<string> | undefined;
17
+ /**
18
+ * 是否开启激励再得广告
19
+ */
20
+ multiton?: boolean | undefined;
21
+ /**
22
+ * 额外观看广告的次数,合法的数据范围为 1~4,multiton 为 true 时必填
23
+ */
24
+ multitonRewardTimes?: number | undefined;
25
+ /**
26
+ * 场景值 - 自用参数,非tt API要求的参数
27
+ */
28
+ scene?: number | undefined;
29
+ /**
30
+ * 广告超时时间 单位ms - 自用参数,非tt API要求的参数
31
+ */
32
+ timeout?: number | undefined;
33
+ /**
34
+ * 重试次数 - 自用参数 ,非tt API要求的参数
35
+ */
36
+ retry: number;
37
+ /**
38
+ * 是否绑定永远的错误事件 - 自用参数,非tt API要求的参数
39
+ */
40
+ foreverErrorBind?: boolean | undefined;
41
+ };
42
+ export type InterstitialAdConfig = {
43
+ /**
44
+ * 单个广告单元的 id。可从「开放平台控制台-进入对应小程序-运营-商业化变现-广告管理」中获取 - 必填
45
+ */
46
+ adUnitId: string;
47
+ /**
48
+ * 场景值 - 自用参数
49
+ */
50
+ scene?: number | undefined;
51
+ };
52
+ export type IExeCallbackArgs = {
53
+ /**
54
+ * 广告执行场景
55
+ */
56
+ scene: number;
57
+ /**
58
+ * 是否看完
59
+ */
60
+ isEnded: boolean;
61
+ /**
62
+ * 完整观看次数
63
+ */
64
+ count: number;
65
+ /**
66
+ * 剩余观看次数
67
+ */
68
+ remain?: number;
69
+ };
70
+ export type CallbackCollection = {
71
+ /**
72
+ * 每次外部回调
73
+ */
74
+ always?: (ctx?: IExeCallbackArgs) => void;
75
+ /**
76
+ * 完整看完广告外部回调 不管一个还是几个
77
+ */
78
+ finished?: (ctx?: IExeCallbackArgs) => void;
79
+ /**
80
+ * 半途退出广告外部回调
81
+ */
82
+ halfway?: (ctx?: IExeCallbackArgs) => void;
83
+ /**
84
+ * 完成广告外部回调 不管看不看完
85
+ */
86
+ complete?: (ctx?: IExeCallbackArgs) => void;
87
+ /**
88
+ * 取消广告外部回调
89
+ */
90
+ onCancel?: (ctx?: IExeCallbackArgs) => void;
91
+ /**
92
+ * 展示广告外部回调
93
+ */
94
+ before?: (ctx?: IExeCallbackArgs) => void;
95
+ /**
96
+ * 展示广告成功外部回调
97
+ */
98
+ success?: (ctx?: IExeCallbackArgs) => void;
99
+ /**
100
+ * 计时回调
101
+ */
102
+ prelude?: (ctx?: unknown) => void;
103
+ };
104
+ export type RecoveredInfo = {
105
+ /**
106
+ * 恢复重试次数
107
+ */
108
+ count: number;
109
+ /**
110
+ * 是否恢复重试
111
+ */
112
+ retry: boolean;
113
+ /**
114
+ * 恢复重试原因
115
+ */
116
+ message: string;
117
+ };
118
+ export type ICallbackArgs = {
119
+ /**
120
+ * 广告执行场景
121
+ */
122
+ scene: number;
123
+ /**
124
+ * 是否看完
125
+ */
126
+ isEnded: boolean;
127
+ /**
128
+ * 完整观看次数
129
+ */
130
+ count: number;
131
+ /**
132
+ * 剩余观看次数
133
+ */
134
+ remain?: number;
135
+ /**
136
+ * 执行下一个任务的回调函数,手动调用以继续执行流程[end]
137
+ */
138
+ end?: () => void;
139
+ /**
140
+ * 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
141
+ */
142
+ circle?: (args: {
143
+ ignoreRemain: boolean;
144
+ scene: number;
145
+ }) => void;
146
+ };
147
+ export type IConnection = {
148
+ /**
149
+ * 广告中途退出回调
150
+ */
151
+ onHalfway?: (args: ICallbackArgs) => void;
152
+ /**
153
+ * 广告展示回调
154
+ */
155
+ onShow?: (args: ICallbackArgs) => void;
156
+ /**
157
+ * 广告执行成功回调
158
+ */
159
+ onFinish?: (args: ICallbackArgs) => void;
160
+ /**
161
+ * 广告执行失败回调
162
+ */
163
+ onError?: (e: unknown) => void;
164
+ };
165
+ export type IConstructArgs = {
166
+ /**
167
+ * 初始化标识
168
+ */
169
+ sign: string;
170
+ /**
171
+ * 是否开启日志
172
+ */
173
+ log?: boolean | undefined;
174
+ /**
175
+ * 重试次数
176
+ */
177
+ retry: number;
178
+ /**
179
+ * 是否保留tt激励视频广告实例
180
+ */
181
+ preserveOnEnd: boolean;
182
+ /**
183
+ * 激励视频参数 (可选)
184
+ */
185
+ adConfig?: IRewordAdConfig | undefined;
186
+ /**
187
+ * 回调集合
188
+ */
189
+ collection?: IConnection | undefined;
190
+ };
191
+ /**
192
+ * 广告场景类型映射对象
193
+ */
194
+ export type SceneTypeMap = {
195
+ readonly [x: number]: string;
196
+ };
197
+ /**
198
+ * 广告场景类型文本映射对象(反向映射)
199
+ */
200
+ export type SceneTextMap = { readonly [K in SceneTypeMap[keyof SceneTypeMap]]: { [P in keyof SceneTypeMap]: SceneTypeMap[P] extends K ? P : never; }[keyof SceneTypeMap]; };
201
+ /**
202
+ * 场景值枚举 可持续添加
203
+ */
204
+ export type RewardAdTriggerScene = keyof SceneTextMap;
205
+ /**
206
+ * 场景值枚举 可持续添加
207
+ */
208
+ export type RewardAdTriggerSceneType = keyof SceneTypeMap;