@ad-execute-manager/ad 2.0.0-alpha.1 → 2.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 singcl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,380 @@
1
+ # @ad-execute-manager/ad
2
+
3
+ Ad-related classes including InterstitialAdFather, InterstitialAdNovel, RewardAdFather, and RewardAdNovel for ad management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ad-execute-manager/ad
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **InterstitialAdFather**: Base class for interstitial ads with common functionality
14
+ - **InterstitialAdNovel**: Novel-specific interstitial ad implementation with enhanced features
15
+ - **RewardAdFather**: Base class for reward ads with common functionality
16
+ - **RewardAdNovel**: Novel-specific reward ad implementation with enhanced features
17
+
18
+ ## Usage
19
+
20
+ ### InterstitialAdNovel
21
+
22
+ ```javascript
23
+ import { InterstitialAdNovel } from '@ad-execute-manager/ad';
24
+
25
+ const interstitialAd = InterstitialAdNovel.new({
26
+ sign: 'novel_interstitial',
27
+ preserveOnEnd: false,
28
+ needEndOnTimeout: true,
29
+ collection: {
30
+ onHalfway: (args) => {
31
+ console.log('Ad halfway:', args);
32
+ },
33
+ onShow: (args) => {
34
+ console.log('Ad shown:', args);
35
+ },
36
+ onFinish: (args) => {
37
+ console.log('Ad finished:', args);
38
+ },
39
+ onAlways: (args) => {
40
+ console.log('Ad always:', args);
41
+ },
42
+ onError: (error) => {
43
+ console.error('Ad error:', error);
44
+ }
45
+ }
46
+ });
47
+
48
+ // Initialize ad
49
+ interstitialAd.initialize({
50
+ adUnitId: 'your-ad-unit-id',
51
+ retry: 3
52
+ });
53
+
54
+ // Show ad
55
+ const result = await interstitialAd.addExecuteManager({
56
+ options: {
57
+ scene: 1
58
+ }
59
+ });
60
+
61
+ console.log('Ad result:', result);
62
+ ```
63
+
64
+ ### RewardAdNovel
65
+
66
+ ```javascript
67
+ import { RewardAdNovel } from '@ad-execute-manager/ad';
68
+
69
+ const rewardAd = RewardAdNovel.new({
70
+ sign: 'novel_reward',
71
+ preserveOnEnd: false,
72
+ needEndOnTimeout: true,
73
+ collection: {
74
+ onHalfway: (args) => {
75
+ console.log('Ad halfway:', args);
76
+ },
77
+ onShow: (args) => {
78
+ console.log('Ad shown:', args);
79
+ },
80
+ onFinish: (args) => {
81
+ console.log('Ad finished:', args);
82
+ },
83
+ onAlways: (args) => {
84
+ console.log('Ad always:', args);
85
+ },
86
+ onError: (error) => {
87
+ console.error('Ad error:', error);
88
+ }
89
+ }
90
+ });
91
+
92
+ // Initialize ad
93
+ rewardAd.initialize({
94
+ adUnitId: 'your-ad-unit-id',
95
+ retry: 3
96
+ });
97
+
98
+ // Show ad
99
+ const result = await rewardAd.addExecuteManager({
100
+ options: {
101
+ scene: 2,
102
+ timeout: 10000
103
+ }
104
+ });
105
+
106
+ console.log('Ad result:', result);
107
+ ```
108
+
109
+ ## API
110
+
111
+ ### InterstitialAdFather
112
+
113
+ Base class for interstitial ads with common functionality.
114
+
115
+ ### InterstitialAdNovel
116
+
117
+ ```typescript
118
+ class InterstitialAdNovel extends InterstitialAdFather {
119
+ /**
120
+ * Builds and returns an instance of InterstitialAdNovel
121
+ * @param args Construction arguments
122
+ * @returns Instance of InterstitialAdNovel
123
+ */
124
+ static build(args: IConstructArgs): InterstitialAdNovel;
125
+
126
+ /**
127
+ * Gets the singleton instance of InterstitialAdNovel
128
+ * @returns Singleton instance of InterstitialAdNovel
129
+ */
130
+ static getInstance(): InterstitialAdNovel;
131
+
132
+ /**
133
+ * Creates a new instance of InterstitialAdNovel
134
+ * @param args Construction arguments
135
+ * @returns New instance of InterstitialAdNovel
136
+ */
137
+ static new(args: IConstructArgs): InterstitialAdNovel;
138
+
139
+ /**
140
+ * Initializes the ad with configuration
141
+ * @param params Ad configuration parameters
142
+ * @param callback Optional callback function
143
+ * @returns Current instance for method chaining
144
+ */
145
+ initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
146
+
147
+ /**
148
+ * Adds execute manager and runs the ad
149
+ * @param ctx Context object with options
150
+ * @returns Promise with ad execution result
151
+ */
152
+ addExecuteManager(ctx: any): Promise<any>;
153
+
154
+ /**
155
+ * Clears the ad instance
156
+ */
157
+ clear(): void;
158
+
159
+ /**
160
+ * Shifts the ad instance
161
+ */
162
+ shift(): void;
163
+ }
164
+ ```
165
+
166
+ ### RewardAdFather
167
+
168
+ Base class for reward ads with common functionality.
169
+
170
+ ### RewardAdNovel
171
+
172
+ ```typescript
173
+ class RewardAdNovel extends RewardAdFather {
174
+ /**
175
+ * Builds and returns an instance of RewardAdNovel
176
+ * @param args Construction arguments
177
+ * @returns Instance of RewardAdNovel
178
+ */
179
+ static build(args: IConstructArgs): RewardAdNovel;
180
+
181
+ /**
182
+ * Gets the singleton instance of RewardAdNovel
183
+ * @returns Singleton instance of RewardAdNovel
184
+ */
185
+ static getInstance(): RewardAdNovel;
186
+
187
+ /**
188
+ * Creates a new instance of RewardAdNovel
189
+ * @param args Construction arguments
190
+ * @returns New instance of RewardAdNovel
191
+ */
192
+ static new(args: IConstructArgs): RewardAdNovel;
193
+
194
+ /**
195
+ * Initializes the ad with configuration
196
+ * @param params Ad configuration parameters
197
+ * @param callback Optional callback function
198
+ * @returns Current instance for method chaining
199
+ */
200
+ initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
201
+
202
+ /**
203
+ * Adds execute manager and runs the ad
204
+ * @param ctx Context object with options
205
+ * @returns Promise with ad execution result
206
+ */
207
+ addExecuteManager(ctx: any): Promise<any>;
208
+
209
+ /**
210
+ * Clears the ad instance
211
+ */
212
+ clear(): void;
213
+
214
+ /**
215
+ * Shifts the ad instance
216
+ */
217
+ shift(): void;
218
+ }
219
+ ```
220
+
221
+ ## Configuration
222
+
223
+ ### Construction Arguments
224
+
225
+ When creating an ad instance, you can pass the following configuration options:
226
+
227
+ - **sign**: Unique identifier for the ad instance
228
+ - **preserveOnEnd**: Whether to preserve the instance after ad ends
229
+ - **needEndOnTimeout**: Whether to end the ad on timeout
230
+ - **collection**: Event collection object with callback functions
231
+ - **onHalfway**: Called when ad reaches halfway point
232
+ - **onShow**: Called when ad is shown
233
+ - **onFinish**: Called when ad finishes
234
+ - **onAlways**: Called always after ad operation
235
+ - **onError**: Called when ad encounters error
236
+
237
+ ### Initialize Parameters
238
+
239
+ When initializing an ad, you can pass the following parameters:
240
+
241
+ - **adUnitId**: Unique identifier for the ad unit
242
+ - **retry**: Number of retry attempts on ad error
243
+
244
+ ## Examples
245
+
246
+ ### Example 1: Basic Interstitial Ad Usage
247
+
248
+ ```javascript
249
+ import { InterstitialAdNovel } from '@ad-execute-manager/ad';
250
+
251
+ // Create ad instance
252
+ const interstitialAd = InterstitialAdNovel.new({
253
+ sign: 'chapter_end_interstitial',
254
+ preserveOnEnd: false,
255
+ needEndOnTimeout: true,
256
+ collection: {
257
+ onFinish: () => {
258
+ console.log('Interstitial ad finished, proceeding to next chapter');
259
+ // Proceed to next chapter logic here
260
+ },
261
+ onError: (error) => {
262
+ console.error('Interstitial ad error:', error);
263
+ // Handle error gracefully, maybe skip ad
264
+ }
265
+ }
266
+ });
267
+
268
+ // Initialize and show ad
269
+ interstitialAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 2 });
270
+
271
+ // Show ad at chapter end
272
+ async function showAdAtChapterEnd() {
273
+ try {
274
+ const result = await interstitialAd.addExecuteManager({ options: { scene: 1 } });
275
+ console.log('Ad result:', result);
276
+ } catch (error) {
277
+ console.error('Ad execution error:', error);
278
+ }
279
+ }
280
+
281
+ // Usage
282
+ // showAdAtChapterEnd();
283
+ ```
284
+
285
+ ### Example 2: Reward Ad for Premium Content
286
+
287
+ ```javascript
288
+ import { RewardAdNovel } from '@ad-execute-manager/ad';
289
+
290
+ // Create reward ad instance
291
+ const rewardAd = RewardAdNovel.new({
292
+ sign: 'premium_content_reward',
293
+ preserveOnEnd: true,
294
+ needEndOnTimeout: true,
295
+ collection: {
296
+ onFinish: (args) => {
297
+ console.log('Reward ad finished, unlocking premium content');
298
+ // Unlock premium content logic here
299
+ unlockPremiumContent();
300
+ },
301
+ onError: (error) => {
302
+ console.error('Reward ad error:', error);
303
+ // Show error message to user
304
+ showErrorMessage('Failed to load ad. Please try again later.');
305
+ }
306
+ }
307
+ });
308
+
309
+ // Initialize ad
310
+ rewardAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 3 });
311
+
312
+ // Function to unlock premium content
313
+ function unlockPremiumContent() {
314
+ // Logic to unlock premium content
315
+ console.log('Premium content unlocked!');
316
+ }
317
+
318
+ // Function to show error message
319
+ function showErrorMessage(message) {
320
+ // Logic to show error message
321
+ console.log('Error:', message);
322
+ }
323
+
324
+ // Show reward ad to unlock premium content
325
+ async function showRewardAdForPremium() {
326
+ try {
327
+ const result = await rewardAd.addExecuteManager({
328
+ options: {
329
+ scene: 2,
330
+ timeout: 15000
331
+ }
332
+ });
333
+ console.log('Reward ad result:', result);
334
+ } catch (error) {
335
+ console.error('Reward ad execution error:', error);
336
+ }
337
+ }
338
+
339
+ // Usage
340
+ // showRewardAdForPremium();
341
+ ```
342
+
343
+ ### Example 3: Ad Instance Management
344
+
345
+ ```javascript
346
+ import { InterstitialAdNovel, RewardAdNovel } from '@ad-execute-manager/ad';
347
+
348
+ // Create ad instances
349
+ const interstitialAd = InterstitialAdNovel.new({ sign: 'interstitial' });
350
+ const rewardAd = RewardAdNovel.new({ sign: 'reward' });
351
+
352
+ // Initialize ads
353
+ interstitialAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 2 });
354
+ rewardAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 3 });
355
+
356
+ // Function to show appropriate ad based on user action
357
+ async function showAdBasedOnAction(action) {
358
+ try {
359
+ switch (action) {
360
+ case 'chapter_end':
361
+ return await interstitialAd.addExecuteManager({ options: { scene: 1 } });
362
+ case 'unlock_premium':
363
+ return await rewardAd.addExecuteManager({ options: { scene: 2 } });
364
+ default:
365
+ throw new Error('Invalid ad action');
366
+ }
367
+ } catch (error) {
368
+ console.error('Ad error:', error);
369
+ return { success: false, error: error.message };
370
+ }
371
+ }
372
+
373
+ // Usage examples
374
+ // showAdBasedOnAction('chapter_end');
375
+ // showAdBasedOnAction('unlock_premium');
376
+ ```
377
+
378
+ ## License
379
+
380
+ MIT
@@ -1,7 +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
+ /**
6
+ * 激励视频实例
7
+ */
8
+ export type InterstitialAd = import("./typings/create-interstitial-ad.js").InterstitialAd;
5
9
  export type IRewardedVideoAd = {
6
10
  /**
7
11
  * 显示激励视频广告
@@ -24,23 +28,32 @@ declare class InterstitialAdFather {
24
28
  * @param {Object} adInstance 广告实例
25
29
  * @param {Object} ctx 上下文对象,用于传递数据和状态
26
30
  * @param {Object} ctx.options 广告执行选项
27
- * @param {Object} ctx.options.log 是否打印日志
28
31
  * @param {Object} ctx.collection 回调集合
29
32
  * @returns {Promise} 广告执行结果的Promise
30
33
  */
31
34
  static executeWithManager(adInstance: any, ctx: {
32
- options: {
33
- log: any;
34
- };
35
+ options: any;
35
36
  collection: any;
36
37
  }): Promise<any>;
37
38
  /**
38
39
  * @param {IConstructArgs} args
39
40
  */
40
41
  constructor(args: IConstructArgs);
42
+ /** @private */
43
+ /** @type {Logger} */
44
+ _logger: Logger;
41
45
  _initSign: string;
42
46
  _preserveOnEnd: boolean;
43
- _interstitialAd: any;
47
+ /**
48
+ * 激励视频实例
49
+ * @type {InterstitialAd | null}
50
+ */
51
+ _interstitialAd: InterstitialAd | null;
52
+ /**
53
+ * 激励视频实例
54
+ * @type {InterstitialAd | null}
55
+ */
56
+ __ad__: InterstitialAd | null;
44
57
  _ttErrorMsgs: string[];
45
58
  _ttErrorCodes: number[];
46
59
  _adConfig: {};
@@ -88,8 +101,26 @@ declare class InterstitialAdFather {
88
101
  * 任务执行完成后始终执行的一个方法
89
102
  * @abstract 任务执行完成后始终执行的一个方法,子类需要用到时实现此方法
90
103
  * @param {object} [_args] 执行结果信息
91
- */
92
- record(_args?: object): this;
104
+ * @param {number} [_args.scene] 场景信息
105
+ * @param {string} _args.id 任务id
106
+ * @param {object} [_args.apiError] 广告api错误信息
107
+ * @param {number} [_args.adTypeR] 广告类型 1 激励视频 2插屏广告
108
+ * @param {object} _args.recovered 后台恢复重试
109
+ * @param {boolean} [_args.recovered.retry] 后台恢复预估是否重试
110
+ * @param {number} [_args.recovered.count] 后台恢复预估重试次数
111
+ * @param {string} [_args.recovered.message] 后台恢复预估重试原因
112
+ */
113
+ record(_args?: {
114
+ scene?: number;
115
+ id: string;
116
+ apiError?: object;
117
+ adTypeR?: number;
118
+ recovered: {
119
+ retry?: boolean;
120
+ count?: number;
121
+ message?: string;
122
+ };
123
+ }): this;
93
124
  /**
94
125
  *
95
126
  * @param {({isEnded: boolean, count: number}) => void} callback
@@ -129,3 +160,4 @@ declare class InterstitialAdFather {
129
160
  */
130
161
  placeholder(): any;
131
162
  }
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,30 @@ 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
+ * ATTENTION: 应用一旦进入后台,90%概率.show() 方法的.then() 回调将不会被执行, .catch() 回调也不会被执行。
343
+ * 此时将进入超时处理逻辑
342
344
  * @override
343
345
  * @param {object} [ctx] 广告执行上下文
344
- * @param {import('../typings/ad.js').IRewordAdConfig} [ctx.options] 广告执行选项
345
- * @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] 回调集合
346
348
  * @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
347
349
  * @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
348
350
  */
349
351
  override ad(ctx?: {
350
- options?: import("../typings/ad.js").IRewordAdConfig;
351
- collection?: import("../typings/ad.js").CallbackCollection;
352
+ options?: import("./typings/ad.js").IRewordAdConfig;
353
+ collection?: import("./typings/ad.js").CallbackCollection;
352
354
  }, next?: Function): Promise<(IEndArgs & ICloseArgs) | undefined>;
353
355
  /**
356
+ * ATTENTION: 应用一旦进入后台,90%概率.show() 方法的.then() 回调将不会被执行, .catch() 回调也不会被执行。
357
+ * 此时将进入超时处理逻辑
354
358
  * @param {object} [ctx] 广告执行上下文
355
359
  * @param {object} [ctx.options] 广告执行选项
356
360
  * @param {number} [ctx.options.scene] 广告执行场景
@@ -1,7 +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 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 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;
5
7
  export type IRewardedVideoAd = {
6
8
  /**
7
9
  * 显示激励视频广告
@@ -24,25 +26,36 @@ declare class RewardAdFather {
24
26
  * @param {Object} adInstance 广告实例
25
27
  * @param {Object} ctx 上下文对象,用于传递数据和状态
26
28
  * @param {Object} ctx.options 广告执行选项
27
- * @param {Object} ctx.options.log 是否打印日志
28
29
  * @param {Object} ctx.collection 回调集合
29
30
  * @returns {Promise} 广告执行结果的Promise
30
31
  */
31
32
  static executeWithManager(adInstance: any, ctx: {
32
- options: {
33
- log: any;
34
- };
33
+ options: any;
35
34
  collection: any;
36
35
  }): Promise<any>;
37
36
  /**
38
37
  * @param {IConstructArgs} args
39
38
  */
40
39
  constructor(args: IConstructArgs);
40
+ /** @private */
41
+ /** @type {Logger} */
42
+ _logger: Logger;
43
+ _adTimeoutTime: number;
41
44
  _initSign: string;
42
45
  _preserveOnEnd: boolean;
43
- _rewardAd: any;
46
+ /**
47
+ * 激励视频实例
48
+ * @type {RewardedVideoAd | null}
49
+ */
50
+ _rewardAd: RewardedVideoAd | null;
51
+ /**
52
+ * 激励视频实例
53
+ * @type {RewardedVideoAd | null}
54
+ */
55
+ __ad__: RewardedVideoAd | null;
44
56
  _ttErrorMsgs: string[];
45
57
  _ttErrorCodes: number[];
58
+ __bindAdErrorForeverHandler: any;
46
59
  _adConfig: {};
47
60
  /**
48
61
  * 初始化
@@ -53,12 +66,29 @@ declare class RewardAdFather {
53
66
  */
54
67
  initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
55
68
  initialized(): boolean;
69
+ /**
70
+ * 激励视频展示失败时始终执行的一个方法
71
+ * @private
72
+ * @param {{errMsg: string; errCode: number}} e 错误信息
73
+ */
74
+ private __adErrorForeverHandler;
75
+ /**
76
+ * 激励视频展示失败时始终执行的一个方法
77
+ * @abstract 激励视频展示失败时始终执行的一个方法,子类需要用到时实现此方法
78
+ * @param {{errMsg: string; errCode: number}} _e 错误信息
79
+ * @returns
80
+ */
81
+ adErrorForeverHandler(_e: {
82
+ errMsg: string;
83
+ errCode: number;
84
+ }): any;
56
85
  /**
57
86
  * 执行广告展示
58
87
  * @abstract
59
88
  * @param {Object} [ctx] 上下文对象,用于传递数据和状态
60
89
  * @param {IRewordAdConfig} [ctx.options] 广告执行选项
61
90
  * @param {CallbackCollection} [ctx.collection] 回调集合
91
+ * @param {RecoveredInfo} [ctx.recovered] 恢复重试信息
62
92
  * @param {Function} next 执行下一个任务的回调函数,在洋葱模型中手动调用以继续执行流程
63
93
  * @returns {Promise<unknown>} 广告执行结果的Promise
64
94
  * @throws {Error} 子类必须实现此方法
@@ -66,6 +96,7 @@ declare class RewardAdFather {
66
96
  ad(ctx?: {
67
97
  options?: IRewordAdConfig;
68
98
  collection?: CallbackCollection;
99
+ recovered?: RecoveredInfo;
69
100
  }, next?: Function): Promise<unknown>;
70
101
  /**
71
102
  * 确保广告按顺序执行
@@ -88,8 +119,26 @@ declare class RewardAdFather {
88
119
  * 任务执行完成后始终执行的一个方法
89
120
  * @abstract 任务执行完成后始终执行的一个方法,子类需要用到时实现此方法
90
121
  * @param {object} [_args] 执行结果信息
91
- */
92
- record(_args?: object): this;
122
+ * @param {number} [_args.scene] 场景信息
123
+ * @param {string} _args.id 任务id
124
+ * @param {object} [_args.apiError] 广告api错误信息
125
+ * @param {number} [_args.adTypeR] 广告类型 1 激励视频 2插屏广告
126
+ * @param {object} _args.recovered 后台恢复重试
127
+ * @param {boolean} [_args.recovered.retry] 后台恢复预估是否重试
128
+ * @param {number} [_args.recovered.count] 后台恢复预估重试次数
129
+ * @param {string} [_args.recovered.message] 后台恢复预估重试原因
130
+ */
131
+ record(_args?: {
132
+ scene?: number;
133
+ id: string;
134
+ apiError?: object;
135
+ adTypeR?: number;
136
+ recovered: {
137
+ retry?: boolean;
138
+ count?: number;
139
+ message?: string;
140
+ };
141
+ }): this;
93
142
  /**
94
143
  *
95
144
  * @param {({isEnded: boolean, count: number}) => void} callback
@@ -129,3 +178,4 @@ declare class RewardAdFather {
129
178
  */
130
179
  placeholder(): any;
131
180
  }
181
+ import { Logger } from '@ad-execute-manager/helper';