@singcl/ad-execute-manager 2.0.11 → 2.0.13

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.
@@ -27,12 +27,12 @@ declare class InterstitialAdFather {
27
27
  * 使用管理器执行广告
28
28
  * @param {Object} adInstance 广告实例
29
29
  * @param {Object} ctx 上下文对象,用于传递数据和状态
30
- * @param {Object} ctx.options 广告执行选项
31
- * @param {Object} ctx.collection 回调集合
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: any;
35
- collection: any;
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 {IRewordAdConfig} params
64
+ * @param {import('./typings/ad.js').IAdOptions} params
65
65
  * @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
66
66
  * @returns {this} 当前实例
67
67
  */
68
- initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
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 {IRewordAdConfig} [ctx.options] 广告执行选项
87
+ * @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
88
88
  * @param {CallbackCollection} [ctx.collection] 回调集合
89
89
  */
90
90
  addExecuteManager(ctx?: {
91
- options?: IRewordAdConfig;
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 {IRewordAdConfig} args
179
+ * @param {import('./typings/ad.js').IAdOptions} args
180
180
  * @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
181
181
  * @returns {this} 当前实例
182
182
  */
183
- initialize(args: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
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').IRewordAdConfig} [ctx.options] 广告执行选项
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").IRewordAdConfig;
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
- * 场景值 - 自用参数,非tt API要求的参数
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
- retry: number;
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
- remain?: number;
66
+ end_type?: "finished" | "halfway";
69
67
  };
70
68
  export type CallbackCollection = {
71
69
  /**
72
70
  * 每次外部回调
73
71
  */
74
- always?: (ctx?: IExeCallbackArgs) => void;
72
+ always?: (ctx?: IExeCallbackArgs & {
73
+ [key: string]: unknown;
74
+ }) => void;
75
75
  /**
76
76
  * 完整看完广告外部回调 不管一个还是几个
77
77
  */
78
- finished?: (ctx?: IExeCallbackArgs) => void;
78
+ finished?: (ctx?: IExeCallbackArgs & {
79
+ [key: string]: unknown;
80
+ }) => void;
79
81
  /**
80
82
  * 半途退出广告外部回调
81
83
  */
82
- halfway?: (ctx?: IExeCallbackArgs) => void;
84
+ halfway?: (ctx?: IExeCallbackArgs & {
85
+ [key: string]: unknown;
86
+ }) => void;
83
87
  /**
84
88
  * 取消广告外部回调
85
89
  */
86
- cancel?: (ctx?: IExeCallbackArgs) => void;
90
+ cancel?: () => void;
87
91
  /**
88
92
  * 展示广告外部回调
89
93
  */
90
- before?: (ctx?: IExeCallbackArgs) => void;
94
+ before?: (ctx?: {
95
+ scene: number;
96
+ }) => void;
91
97
  /**
92
98
  * 展示广告成功外部回调
93
99
  */
94
- success?: (ctx?: IExeCallbackArgs) => void;
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
- prelude?: (ctx?: unknown) => void;
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 ICallbackArgs = {
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
- remain?: number;
145
+ errMsg?: string;
131
146
  /**
132
- * 执行下一个任务的回调函数,手动调用以继续执行流程[end]
147
+ * 错误码
133
148
  */
134
- end?: () => void;
149
+ errorCode?: number;
135
150
  /**
136
- * 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
151
+ * 错误信息
137
152
  */
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) => void;
160
+ onHalfway?: (args: ICallbackArgs & {
161
+ [key: string]: unknown;
162
+ }) => void;
148
163
  /**
149
164
  * 广告展示回调
150
165
  */
151
- onShow?: (args: ICallbackArgs) => void;
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
- onFinish?: (args: ICallbackArgs) => void;
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
  */
@@ -4,6 +4,8 @@ export type CallbackCollection = import("./typings/ad.js").CallbackCollection;
4
4
  export type RecoveredInfo = import("./typings/ad.js").RecoveredInfo;
5
5
  export type IConstructArgs = import("./typings/ad.js").IConstructArgs;
6
6
  export type RewardedVideoAd = import("./typings/create-rewarded-video-ad.js").RewardedVideoAd;
7
+ export type ITaskResult = import("./typings/ad.js").ITaskResult;
8
+ export type ITaskResultGeneric<T extends unknown> = ITaskResult & T;
7
9
  export type IRewardedVideoAd = {
8
10
  /**
9
11
  * 显示激励视频广告
@@ -22,18 +24,18 @@ declare class RewardAdFather {
22
24
  */
23
25
  static buildArgs(args: IRewordAdConfig): void;
24
26
  /**
27
+ * @template {object} T
25
28
  * 使用管理器执行广告
26
29
  * @param {Object} adInstance 广告实例
27
30
  * @param {Object} ctx 上下文对象,用于传递数据和状态
28
- * @param {Object} ctx.options 广告执行选项
29
- * @param {Object} ctx.collection 回调集合
31
+ * @param {import('./typings/ad.js').IAdOptions} ctx.options 广告执行选项
32
+ * @param {CallbackCollection} ctx.collection 回调集合
33
+ * @returns {Promise<ITaskResultGeneric<T> | undefined>} 广告执行结果的Promise
30
34
  */
31
- static executeWithManager(adInstance: any, ctx: {
32
- options: any;
33
- collection: any;
34
- }): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
35
- [key: string]: any;
36
- }>;
35
+ static executeWithManager<T extends unknown>(adInstance: any, ctx: {
36
+ options: import("./typings/ad.js").IAdOptions;
37
+ collection: CallbackCollection;
38
+ }): Promise<ITaskResultGeneric<T> | undefined>;
37
39
  /**
38
40
  * @param {IConstructArgs} args
39
41
  */
@@ -61,11 +63,11 @@ declare class RewardAdFather {
61
63
  /**
62
64
  * 初始化
63
65
  * 子类可以选择覆盖此方法,或使用默认实现
64
- * @param {IRewordAdConfig} params
66
+ * @param {import('./typings/ad.js').IAdOptions} params
65
67
  * @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
66
68
  * @returns {this} 当前实例
67
69
  */
68
- initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
70
+ initialize(params: import("./typings/ad.js").IAdOptions, callback?: (v: IRewardedVideoAd) => void): this;
69
71
  initialized(): boolean;
70
72
  /**
71
73
  * 激励视频展示失败时始终执行的一个方法
@@ -87,7 +89,7 @@ declare class RewardAdFather {
87
89
  * 执行广告展示
88
90
  * @abstract
89
91
  * @param {Object} [ctx] 上下文对象,用于传递数据和状态
90
- * @param {IRewordAdConfig} [ctx.options] 广告执行选项
92
+ * @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
91
93
  * @param {CallbackCollection} [ctx.collection] 回调集合
92
94
  * @param {RecoveredInfo} [ctx.recovered] 恢复重试信息
93
95
  * @param {Function} next 执行下一个任务的回调函数,在洋葱模型中手动调用以继续执行流程
@@ -95,22 +97,22 @@ declare class RewardAdFather {
95
97
  * @throws {Error} 子类必须实现此方法
96
98
  */
97
99
  ad(ctx?: {
98
- options?: IRewordAdConfig;
100
+ options?: import("./typings/ad.js").IAdOptions;
99
101
  collection?: CallbackCollection;
100
102
  recovered?: RecoveredInfo;
101
103
  }, next?: Function): Promise<unknown>;
102
104
  /**
105
+ * @template {object} T
103
106
  * 确保广告按顺序执行
104
107
  * @param {Object} [ctx] 上下文对象,用于传递数据和状态
105
- * @param {IRewordAdConfig} [ctx.options] 广告执行选项
108
+ * @param {import('./typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
106
109
  * @param {CallbackCollection} [ctx.collection] 回调集合
110
+ * @returns {Promise<ITaskResultGeneric<T> | undefined>} 广告执行结果的Promise
107
111
  */
108
- addExecuteManager(ctx?: {
109
- options?: IRewordAdConfig;
112
+ addExecuteManager<T extends unknown>(ctx?: {
113
+ options?: import("./typings/ad.js").IAdOptions;
110
114
  collection?: CallbackCollection;
111
- }): Promise<import("@ad-execute-manager/core/dist/AdExecuteManager.js").ITaskResult & {
112
- [key: string]: any;
113
- }>;
115
+ }): Promise<ITaskResultGeneric<T> | undefined>;
114
116
  destroy(): void;
115
117
  /**
116
118
  * 清理广告实例
@@ -1,78 +1,6 @@
1
1
  export default RewardAdNovel;
2
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
- * 是否开启日志
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 ICallbackArgs
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 {IRewordAdConfig} args
84
+ * @param {import('./typings/ad.js').IAdOptions} args
184
85
  * @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
185
86
  * @returns {this} 当前实例
186
87
  */
187
- initialize(args: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
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').IRewordAdConfig} [ctx.options] 广告执行选项
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").IRewordAdConfig;
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
- * 场景值 - 自用参数,非tt API要求的参数
28
+ * 是否需要在超时情况下结束广告 - 自用参数,非tt API要求的参数
27
29
  */
28
- scene?: number | undefined;
29
- /**
30
- * 广告超时时间 单位ms - 自用参数,非tt API要求的参数
31
- */
32
- timeout?: number | undefined;
33
- /**
34
- * 重试次数 - 自用参数 ,非tt API要求的参数
35
- */
36
- retry: number;
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
- remain?: number;
66
+ end_type?: "finished" | "halfway";
69
67
  };
70
68
  export type CallbackCollection = {
71
69
  /**
72
- * 完成广告外部回调 不管看不看完
70
+ * 每次外部回调
73
71
  */
74
- always?: (ctx?: IExeCallbackArgs) => void;
72
+ always?: (ctx?: IExeCallbackArgs & {
73
+ [key: string]: unknown;
74
+ }) => void;
75
75
  /**
76
76
  * 完整看完广告外部回调 不管一个还是几个
77
77
  */
78
- finished?: (ctx?: IExeCallbackArgs) => void;
78
+ finished?: (ctx?: IExeCallbackArgs & {
79
+ [key: string]: unknown;
80
+ }) => void;
79
81
  /**
80
82
  * 半途退出广告外部回调
81
83
  */
82
- halfway?: (ctx?: IExeCallbackArgs) => void;
84
+ halfway?: (ctx?: IExeCallbackArgs & {
85
+ [key: string]: unknown;
86
+ }) => void;
83
87
  /**
84
88
  * 取消广告外部回调
85
89
  */
86
- cancel?: (ctx?: IExeCallbackArgs) => void;
90
+ cancel?: () => void;
87
91
  /**
88
92
  * 展示广告外部回调
89
93
  */
90
- before?: (ctx?: IExeCallbackArgs) => void;
94
+ before?: (ctx?: {
95
+ scene: number;
96
+ }) => void;
91
97
  /**
92
98
  * 展示广告成功外部回调
93
99
  */
94
- success?: (ctx?: IExeCallbackArgs) => void;
100
+ success?: (ctx?: {
101
+ scene: number;
102
+ }) => void;
95
103
  /**
96
- * 计时回调
104
+ * 计时回调 scene: 广告场景 frequency: 广告展示前间隔时间 time: 广告展示时前间戳
97
105
  */
98
- prelude?: (ctx?: unknown) => void;
106
+ prelude?: (ctx?: {
107
+ scene: number;
108
+ frequency: number;
109
+ time: number;
110
+ }) => void;
99
111
  };
112
+ export type IAdOptionsOther = {
113
+ /**
114
+ * 场景值 - 自用参数,非tt API要求的参数
115
+ */
116
+ scene?: number | undefined;
117
+ /**
118
+ * 广告超时时间 单位ms - 自用参数,非tt API要求的参数
119
+ */
120
+ timeout?: number | undefined;
121
+ /**
122
+ * 重试次数 - 自用参数 ,非tt API要求的参数
123
+ */
124
+ retry: number;
125
+ };
126
+ export type IAdOptions = IRewordAdConfig & IRewordAdOther & IAdOptionsOther;
100
127
  export type RecoveredInfo = {
101
128
  /**
102
129
  * 恢复重试次数
@@ -111,48 +138,80 @@ export type RecoveredInfo = {
111
138
  */
112
139
  message: string;
113
140
  };
114
- export type ICallbackArgs = {
141
+ export type IApiError = {
115
142
  /**
116
- * 广告执行场景
143
+ * 错误信息
117
144
  */
118
- scene: number;
145
+ errMsg?: string;
119
146
  /**
120
- * 是否看完
147
+ * 错误码
121
148
  */
122
- isEnded: boolean;
149
+ errorCode?: number;
123
150
  /**
124
- * 完整观看次数
151
+ * 错误信息
125
152
  */
126
- count: number;
153
+ message?: string;
154
+ };
155
+ export type ITaskResult = {
127
156
  /**
128
- * 剩余观看次数
157
+ * 广告任务的唯一标识符
129
158
  */
130
- remain?: number;
159
+ id: string;
131
160
  /**
132
- * 执行下一个任务的回调函数,手动调用以继续执行流程[end]
161
+ * 广告错误信息
133
162
  */
134
- end?: () => void;
163
+ apiError?: IApiError;
135
164
  /**
136
- * 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
165
+ * 广告任务后台恢复前台时预估重试次数的原因
137
166
  */
138
- circle?: (args: {
139
- ignoreRemain: boolean;
140
- scene: number;
141
- }) => void;
167
+ recovered?: RecoveredInfo;
168
+ /**
169
+ * 广告场景
170
+ */
171
+ scene?: string;
172
+ /**
173
+ * 广告类型 1:激励视频 2:插屏
174
+ */
175
+ adTypeR?: 1 | 2;
176
+ /**
177
+ * 广告结束类型
178
+ */
179
+ end_type?: "finished" | "halfway";
180
+ /**
181
+ * 是否看完广告
182
+ */
183
+ isEnded?: boolean;
184
+ /**
185
+ * 完整观看广告次数
186
+ */
187
+ count?: number;
142
188
  };
189
+ export type ICallbackArgs = IExeCallbackArgs;
143
190
  export type IConnection = {
144
191
  /**
145
192
  * 广告中途退出回调
146
193
  */
147
- onHalfway?: (args: ICallbackArgs) => void;
194
+ onHalfway?: (args: ICallbackArgs & {
195
+ [key: string]: unknown;
196
+ }) => void;
148
197
  /**
149
198
  * 广告展示回调
150
199
  */
151
- onShow?: (args: ICallbackArgs) => void;
200
+ onShow?: (args: {
201
+ scene: number;
202
+ }) => void;
203
+ /**
204
+ * 广告执行成功回调
205
+ */
206
+ onFinish?: (args: ICallbackArgs & {
207
+ [key: string]: unknown;
208
+ }) => void;
152
209
  /**
153
210
  * 广告执行成功回调
154
211
  */
155
- onFinish?: (args: ICallbackArgs) => void;
212
+ onAlways?: (args: ICallbackArgs & {
213
+ [key: string]: unknown;
214
+ }) => void;
156
215
  /**
157
216
  * 广告执行失败回调
158
217
  */
@@ -162,19 +221,19 @@ export type IConstructArgs = {
162
221
  /**
163
222
  * 初始化标识
164
223
  */
165
- sign: string;
224
+ sign?: string;
166
225
  /**
167
- * 是否开启日志
226
+ * 是否保留tt激励视频广告实例
168
227
  */
169
- log?: boolean | undefined;
228
+ preserveOnEnd?: boolean;
170
229
  /**
171
- * 重试次数
230
+ * 是否需要在超时情况下结束广告
172
231
  */
173
- retry: number;
232
+ needEndOnTimeout?: boolean;
174
233
  /**
175
- * 是否保留tt激励视频广告实例
234
+ * 是否需要在错误情况下查询剩余次数
176
235
  */
177
- preserveOnEnd: boolean;
236
+ lookUpRemainOnError?: boolean;
178
237
  /**
179
238
  * 激励视频参数 (可选)
180
239
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singcl/ad-execute-manager",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
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
5
  "type": "module",
6
6
  "exports": {
@@ -21,7 +21,7 @@
21
21
  "url": "https://github.com/singcl"
22
22
  },
23
23
  "license": "MIT",
24
- "homepage": "https://npmjs.com/package/@singcl/ad-execute-manager",
24
+ "homepage": "https://npmx.dev/package/@singcl/ad-execute-manager",
25
25
  "repository": {
26
26
  "type": "git",
27
27
  "url": "git+https://github.com/singcl/ad-execute-manager.git"
@@ -30,7 +30,13 @@
30
30
  "url": "https://github.com/singcl/ad-execute-manager/issues"
31
31
  },
32
32
  "engines": {
33
- "node": ">=14.0.0"
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"
34
40
  },
35
41
  "keywords": [
36
42
  "ad",
@@ -78,10 +84,10 @@
78
84
  "typescript": "^5.9.3"
79
85
  },
80
86
  "dependencies": {
81
- "@ad-execute-manager/core": "^2.0.5",
87
+ "@ad-execute-manager/core": "^2.0.6",
82
88
  "@ad-execute-manager/logger": "^2.0.5",
83
- "@ad-execute-manager/ad-reward": "^2.0.5",
84
- "@ad-execute-manager/ad-interstitial": "^2.0.5",
89
+ "@ad-execute-manager/ad-reward": "^2.0.6",
90
+ "@ad-execute-manager/ad-interstitial": "^2.0.6",
85
91
  "@ad-execute-manager/count-recorder": "^2.0.5",
86
92
  "@ad-execute-manager/serializable-error": "^2.0.5",
87
93
  "@ad-execute-manager/storage": "^2.0.5",