@singcl/ad-execute-manager 1.12.5 → 1.12.6

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,14 +27,15 @@ 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 回调集合
32
- * @returns {Promise} 广告执行结果的Promise
30
+ * @param {IRewordAdConfig} [ctx.options] 广告执行选项
31
+ * @param {CallbackCollection} [ctx.collection] 回调集合
33
32
  */
34
33
  static executeWithManager(adInstance: any, ctx: {
35
- options: any;
36
- collection: any;
37
- }): Promise<any>;
34
+ options?: IRewordAdConfig;
35
+ collection?: CallbackCollection;
36
+ }): Promise<import("../core/AdExecuteManager").ITaskResult & {
37
+ [key: string]: any;
38
+ }>;
38
39
  /**
39
40
  * @param {IConstructArgs} args
40
41
  */
@@ -89,7 +90,9 @@ declare class InterstitialAdFather {
89
90
  addExecuteManager(ctx?: {
90
91
  options?: IRewordAdConfig;
91
92
  collection?: CallbackCollection;
92
- }): Promise<any>;
93
+ }): Promise<import("../core/AdExecuteManager").ITaskResult & {
94
+ [key: string]: any;
95
+ }>;
93
96
  destroy(): void;
94
97
  /**
95
98
  * 清理广告实例
@@ -25,14 +25,15 @@ declare class RewardAdFather {
25
25
  * 使用管理器执行广告
26
26
  * @param {Object} adInstance 广告实例
27
27
  * @param {Object} ctx 上下文对象,用于传递数据和状态
28
- * @param {Object} ctx.options 广告执行选项
29
- * @param {Object} ctx.collection 回调集合
30
- * @returns {Promise} 广告执行结果的Promise
28
+ * @param {IRewordAdConfig} [ctx.options] 广告执行选项
29
+ * @param {CallbackCollection} [ctx.collection] 回调集合
31
30
  */
32
31
  static executeWithManager(adInstance: any, ctx: {
33
- options: any;
34
- collection: any;
35
- }): Promise<any>;
32
+ options?: IRewordAdConfig;
33
+ collection?: CallbackCollection;
34
+ }): Promise<import("../core/AdExecuteManager").ITaskResult & {
35
+ [key: string]: any;
36
+ }>;
36
37
  /**
37
38
  * @param {IConstructArgs} args
38
39
  */
@@ -107,7 +108,9 @@ declare class RewardAdFather {
107
108
  addExecuteManager(ctx?: {
108
109
  options?: IRewordAdConfig;
109
110
  collection?: CallbackCollection;
110
- }): Promise<any>;
111
+ }): Promise<import("../core/AdExecuteManager").ITaskResult & {
112
+ [key: string]: any;
113
+ }>;
111
114
  destroy(): void;
112
115
  /**
113
116
  * 清理广告实例
@@ -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;
@@ -342,17 +242,30 @@ declare class RewardAdNovel extends RewardAdFather {
342
242
  ad_count: number;
343
243
  }): any;
344
244
  get rewardAd(): import("../typings/create-rewarded-video-ad.js").RewardedVideoAd;
245
+ /**
246
+ * 确保广告按顺序执行
247
+ * @override
248
+ * @param {Object} [ctx] 上下文对象,用于传递数据和状态
249
+ * @param {import('../typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
250
+ * @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
251
+ */
252
+ override addExecuteManager(ctx?: {
253
+ options?: import("../typings/ad.js").IAdOptions;
254
+ collection?: import("../typings/ad.js").CallbackCollection;
255
+ }): Promise<import("../core/AdExecuteManager.js").ITaskResult & {
256
+ [key: string]: any;
257
+ }>;
345
258
  /**
346
259
  * @override
347
260
  * @param {object} [ctx] 广告执行上下文
348
- * @param {import('../typings/ad.js').IRewordAdConfig} [ctx.options] 广告执行选项
261
+ * @param {import('../typings/ad.js').IAdOptions} [ctx.options] 广告执行选项
349
262
  * @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
350
263
  * @param {import('../typings/ad.js').RecoveredInfo} [ctx.recovered] 恢复重试信息
351
264
  * @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
352
265
  * @returns {Promise.<object | Undefined>}
353
266
  */
354
267
  override ad(ctx?: {
355
- options?: import("../typings/ad.js").IRewordAdConfig;
268
+ options?: import("../typings/ad.js").IAdOptions;
356
269
  collection?: import("../typings/ad.js").CallbackCollection;
357
270
  recovered?: import("../typings/ad.js").RecoveredInfo;
358
271
  }, 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要求的参数
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
+ * 广告场景
67
57
  */
68
- remain?: number;
58
+ scene?: string;
59
+ /**
60
+ * 广告类型 1:激励视频 2:插屏
61
+ */
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) => 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
  * 恢复重试次数
@@ -125,48 +152,32 @@ export type IApiError = {
125
152
  */
126
153
  message?: string;
127
154
  };
128
- export type ICallbackArgs = {
129
- /**
130
- * 广告执行场景
131
- */
132
- scene: number;
133
- /**
134
- * 是否看完
135
- */
136
- isEnded: boolean;
137
- /**
138
- * 完整观看次数
139
- */
140
- count: number;
141
- /**
142
- * 剩余观看次数
143
- */
144
- remain?: number;
155
+ export type ICallbackArgs = IExeCallbackArgs;
156
+ export type IConnection = {
145
157
  /**
146
- * 执行下一个任务的回调函数,手动调用以继续执行流程[end]
158
+ * 广告中途退出回调
147
159
  */
148
- end?: () => void;
160
+ onHalfway?: (args: ICallbackArgs & {
161
+ [key: string]: unknown;
162
+ }) => void;
149
163
  /**
150
- * 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
164
+ * 广告展示回调
151
165
  */
152
- circle?: (args: {
153
- ignoreRemain: boolean;
166
+ onShow?: (args: {
154
167
  scene: number;
155
168
  }) => void;
156
- };
157
- export type IConnection = {
158
169
  /**
159
- * 广告中途退出回调
160
- */
161
- onHalfway?: (args: ICallbackArgs) => void;
162
- /**
163
- * 广告展示回调
170
+ * 广告执行成功回调
164
171
  */
165
- onShow?: (args: ICallbackArgs) => void;
172
+ onFinish?: (args: ICallbackArgs & {
173
+ [key: string]: unknown;
174
+ }) => void;
166
175
  /**
167
176
  * 广告执行成功回调
168
177
  */
169
- onFinish?: (args: ICallbackArgs) => void;
178
+ onAlways?: (args: ICallbackArgs & {
179
+ [key: string]: unknown;
180
+ }) => void;
170
181
  /**
171
182
  * 广告执行失败回调
172
183
  */
@@ -177,14 +188,6 @@ export type IConstructArgs = {
177
188
  * 初始化标识
178
189
  */
179
190
  sign: string;
180
- /**
181
- * 是否开启日志
182
- */
183
- log?: boolean | undefined;
184
- /**
185
- * 重试次数
186
- */
187
- retry: number;
188
191
  /**
189
192
  * 是否保留tt激励视频广告实例
190
193
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singcl/ad-execute-manager",
3
- "version": "1.12.5",
3
+ "version": "1.12.6",
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": {