@singcl/ad-execute-manager 2.1.2 → 2.3.0

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.
@@ -115,9 +115,11 @@ declare class RewardAdFather {
115
115
  }): Promise<ITaskResultGeneric<T> | undefined>;
116
116
  /**
117
117
  * 销毁广告实例
118
+ * 只要调用销毁,无论销毁成功或者失败,销毁时会自动移除广告对象上监听的所有 loaded,error,close 事件。
118
119
  * @param {boolean} preserved 是否保留广告实例
120
+ * @returns { Promise.<void>}
119
121
  */
120
- destroy(preserved?: boolean): void;
122
+ destroy(preserved?: boolean): Promise<void>;
121
123
  /**
122
124
  * 清理广告实例
123
125
  * @abstract 清理广告实例,子类必须实现此方法
@@ -85,8 +85,18 @@ declare class RewardAdNovel extends RewardAdFather {
85
85
  _finishedCallback: any;
86
86
  _resolve: any;
87
87
  _next: any;
88
+ /** @type {{options: import('./typings/ad.js').IAdOptions, collection: import('./typings/ad.js').CallbackCollection, recovered: import('./typings/ad.js').RecoveredInfo}} */
89
+ _adExecuteArgs: {
90
+ options: import("./typings/ad.js").IAdOptions;
91
+ collection: import("./typings/ad.js").CallbackCollection;
92
+ recovered: import("./typings/ad.js").RecoveredInfo;
93
+ };
94
+ /** @type {Function} */
95
+ _adNext: Function;
88
96
  /** @type {number} 广告执行场景 */
89
97
  _scene: number;
98
+ /** @type {string} 当前广告执行的唯一ID */
99
+ _eId: string;
90
100
  _adTypeR: 1;
91
101
  _adTimeout: any;
92
102
  _adBeforeShowTimer: any;
@@ -146,20 +156,55 @@ declare class RewardAdNovel extends RewardAdFather {
146
156
  retry?: number;
147
157
  }): void;
148
158
  novelConfig: RewardAdNovelConfig;
149
- _onInnerExecuteBefore(): any;
159
+ _onInnerExecuteBefore(_args: any): any;
160
+ _onAdExecuteBefore(_args: any): any;
150
161
  /**
151
162
  * @param {object} _args
152
163
  * @param {string} _args.scene 广告执行场景 必填
164
+ * @param {string} _args.eId 广告执行唯一ID 必填
153
165
  * @param {number} [_args.result] 广告执行成功结果 必填
154
166
  * @param {import('./typings/ad.js').RecoveredInfo} [_args.recovered] 恢复重试信息
155
167
  * @returns
156
168
  */
157
169
  _onInnerAdShowSuccess(_args: {
158
170
  scene: string;
171
+ eId: string;
159
172
  result?: number;
160
173
  recovered?: import("./typings/ad.js").RecoveredInfo;
161
174
  }): any;
162
175
  /**
176
+ * 子类可以选择覆盖此方法,或使用默认实现
177
+ * 视频展示中时 android会销毁成功,iOS会销毁失败
178
+ * @param {object} _args
179
+ * @param {string} _args.scene 广告执行场景 必填
180
+ * @param {string} _args.eId 广告执行唯一ID 必填
181
+ * @param {string} [_args.errMsg] 广告销毁失败原因
182
+ * @param {number} [_args.errorCode] 广告销毁失败错误码
183
+ * @returns
184
+ */
185
+ _onInnerAdDestroySuccess(_args: {
186
+ scene: string;
187
+ eId: string;
188
+ errMsg?: string;
189
+ errorCode?: number;
190
+ }): any;
191
+ /**
192
+ * 子类可以选择覆盖此方法,或使用默认实现
193
+ * @param {object} _args
194
+ * @param {string} _args.scene 广告执行场景 必填
195
+ * @param {string} _args.eId 广告执行唯一ID 必填
196
+ * @param {string} [_args.errMsg] 广告销毁失败原因
197
+ * @param {number} [_args.errorCode] 广告销毁失败错误码
198
+ * @returns
199
+ */
200
+ _onInnerAdDestroyFailed(_args: {
201
+ scene: string;
202
+ eId: string;
203
+ errMsg?: string;
204
+ errorCode?: number;
205
+ }): any;
206
+ /**
207
+ * @private
163
208
  * 广告展示超时设置
164
209
  * @param {object} args
165
210
  * @param {string} args.scene 广告执行场景 必填
@@ -167,11 +212,19 @@ declare class RewardAdNovel extends RewardAdFather {
167
212
  * @param {Function} args.end 结束当前广告任务的回调函数 必填
168
213
  * @param {boolean} [args.preserved] 是否在超时情况下保留广告实例 - 自用参数,非tt API要求的参数
169
214
  */
170
- _setAdTimeout(args: {
215
+ private _setAdTimeout;
216
+ /**
217
+ * @protected
218
+ * 广告展示超时设置
219
+ * @param {object} _args
220
+ * @param {string} _args.scene 广告执行场景 必填
221
+ * @param {number} [_args.timeout] 广告超时时间 单位ms
222
+ * @param {Function} _args.end 结束当前广告任务的回调函数 必填
223
+ */
224
+ protected customExecuteAfterTimeout(_args: {
171
225
  scene: string;
172
226
  timeout?: number;
173
227
  end: Function;
174
- preserved?: boolean;
175
228
  }): void;
176
229
  /**
177
230
  * 子类可以选择覆盖此方法
@@ -204,10 +257,12 @@ declare class RewardAdNovel extends RewardAdFather {
204
257
  * @protected
205
258
  * @param {object} _args
206
259
  * @param {string} _args.scene 广告执行场景 必填
260
+ * @param {string} _args.eId 广告执行唯一ID 必填
207
261
  * @returns
208
262
  */
209
263
  protected _adShowBeforeAnalytics(_args: {
210
264
  scene: string;
265
+ eId: string;
211
266
  }): any;
212
267
  /**
213
268
  * 广告展示成功分析
@@ -215,6 +270,7 @@ declare class RewardAdNovel extends RewardAdFather {
215
270
  * @protected
216
271
  * @param {object} _args
217
272
  * @param {string} _args.scene 广告执行场景 必填
273
+ * @param {string} _args.eId 广告执行唯一ID 必填
218
274
  * @param {string} [_args.msg] 广告执行成功原因
219
275
  * @param {0|1} _args.result 广告执行成功结果 必填
220
276
  * @param {import('./typings/ad.js').RecoveredInfo} [_args.recovered] 恢复重试信息
@@ -222,6 +278,7 @@ declare class RewardAdNovel extends RewardAdFather {
222
278
  */
223
279
  protected _adShowSuccessAnalytics(_args: {
224
280
  scene: string;
281
+ eId: string;
225
282
  msg?: string;
226
283
  result: 0 | 1;
227
284
  recovered?: import("./typings/ad.js").RecoveredInfo;
@@ -233,6 +290,7 @@ declare class RewardAdNovel extends RewardAdFather {
233
290
  * @protected
234
291
  * @param {object} _args
235
292
  * @param {string} _args.scene 广告执行场景 必填
293
+ * @param {string} _args.eId 广告执行唯一ID 必填
236
294
  * @param {string} _args.msg 广告执行失败原因 必填
237
295
  * @param {number} _args.errorCode 广告执行失败错误码 必填
238
296
  * @param {0|1} _args.result 广告执行失败结果
@@ -240,6 +298,7 @@ declare class RewardAdNovel extends RewardAdFather {
240
298
  */
241
299
  protected _adShowFailureAnalytics(_args: {
242
300
  scene: string;
301
+ eId: string;
243
302
  msg: string;
244
303
  errorCode: number;
245
304
  result: 0 | 1;
@@ -314,29 +373,46 @@ declare class RewardAdNovel extends RewardAdFather {
314
373
  _recovered: import("./typings/ad.js").RecoveredInfo;
315
374
  _preservedOnTimeout: boolean;
316
375
  /**
376
+ * ATTENTION: 广告循环执行内部函数,如果需要循环执行,请使用adCircleInner()函数, 不要直接调用此函数
377
+ * @private
317
378
  * @param {object} [ctx] 广告执行上下文
318
379
  * @param {object} [ctx.options] 广告执行选项
319
380
  * @param {number} [ctx.options.scene] 广告执行场景 必填
320
381
  * @param {number} [ctx.options.timeout] 广告超时时间 单位ms
321
382
  * @param {object} ctx.collection 回调集合
322
- * @param {import('./typings/ad.js').RecoveredInfo} [ctx.recovered] 恢复重试信息
323
383
  * @param {(v?: unknown) => void} ctx.collection.resolve 广告执行成功的回调函数
324
- * @param {(v?: unknown) => void} [ctx.collection.reject] 广告执行失败的回调函数
325
384
  * @param {(v?: unknown) => void} [ctx.collection.before] 广告执行前的回调函数
326
385
  * @param {(v?: unknown) => void} [ctx.collection.success] 广告执行成功的回调函数
327
386
  * @param {(v?: unknown) => void} [ctx.collection.prelude] 拉起广告前计时的回调函数
387
+ * @param {import('./typings/ad.js').RecoveredInfo} [ctx.recovered] 恢复重试信息
328
388
  * @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
329
389
  */
330
- _adInner(ctx?: {
390
+ private _adInner;
391
+ _before: (v?: unknown) => void;
392
+ _success: (v?: unknown) => void;
393
+ /**
394
+ * 广告循环执行
395
+ * @public
396
+ * @param {object} [ctx] 广告执行上下文
397
+ * @param {object} [ctx.options] 广告执行选项
398
+ * @param {number} [ctx.options.scene] 广告执行场景 必填
399
+ * @param {number} [ctx.options.timeout] 广告超时时间 单位ms
400
+ * @param {object} ctx.collection 回调集合
401
+ * @param {(v?: unknown) => void} [ctx.collection.before] 广告执行前的回调函数
402
+ * @param {(v?: unknown) => void} [ctx.collection.success] 广告执行成功的回调函数
403
+ * @param {(v?: unknown) => void} [ctx.collection.prelude] 拉起广告前计时的回调函数
404
+ */
405
+ public adCircleInner(ctx?: {
331
406
  options?: {
332
407
  scene?: number;
333
408
  timeout?: number;
334
409
  };
335
- collection: object;
336
- recovered?: import("./typings/ad.js").RecoveredInfo;
337
- }, next?: Function): void;
338
- _before: any;
339
- _success: any;
410
+ collection: {
411
+ before?: (v?: unknown) => void;
412
+ success?: (v?: unknown) => void;
413
+ prelude?: (v?: unknown) => void;
414
+ };
415
+ }): void;
340
416
  /**
341
417
  * 广告加载
342
418
  * @returns
@@ -348,7 +424,7 @@ declare class RewardAdNovel extends RewardAdFather {
348
424
  */
349
425
  adShow(): Promise<void>;
350
426
  /**
351
- * @deprecated - 2.x版本自v2.1.1开始已废弃,使用onExeAlways代替
427
+ * @deprecated - 1.x版本自v2.1.1已废弃,使用onExeAlways代替
352
428
  * - 关闭广告时候调用的回调,不管是否看完视频都会调用
353
429
  * - 调用adExecuteManager时collection.always回调
354
430
  * @param {Array.<unknown>} args
@@ -361,7 +437,7 @@ declare class RewardAdNovel extends RewardAdFather {
361
437
  */
362
438
  onExeAlways(...args: Array<unknown>): any;
363
439
  /**
364
- * @deprecated 2.x版本自v2.1.1开始已废弃,使用onExeHalfway代替
440
+ * @deprecated 1.x版本自v2.1.1已废弃,使用onExeHalfway代替
365
441
  * - 广告未看完时候调用的回调
366
442
  * - 调用adExecuteManager时collection.halfway回调
367
443
  * @param {Array.<unknown>} args
@@ -374,7 +450,7 @@ declare class RewardAdNovel extends RewardAdFather {
374
450
  */
375
451
  onExeHalfway(...args: Array<unknown>): any;
376
452
  /**
377
- * @deprecated 2.x版本自v2.1.1开始已废弃,使用onExeFinished代替
453
+ * @deprecated 1.x版本自v2.1.1已废弃,使用onExeFinished代替
378
454
  * - 广告看完时候调用的回调
379
455
  * - 调用adExecuteManager时collection.finished回调
380
456
  * @param {Array.<unknown>} args
@@ -494,6 +570,15 @@ declare class RewardAdNovel extends RewardAdFather {
494
570
  * @param {unknown} e
495
571
  */
496
572
  protected adLoadLister(e: unknown): unknown;
573
+ /**
574
+ * 销毁广告实例
575
+ * @protected
576
+ * @param {object} [args]
577
+ * @param {boolean} [args.preserved] 是否保留广告实例
578
+ */
579
+ protected __novelDestroy__(args?: {
580
+ preserved?: boolean;
581
+ }): void;
497
582
  /**
498
583
  * 销毁广告实例
499
584
  * @protected
@@ -14,7 +14,7 @@ export type RewardedVideoAd = {
14
14
  /**
15
15
  * 销毁广告实例
16
16
  */
17
- destroy: () => void;
17
+ destroy: () => Promise<any>;
18
18
  /**
19
19
  * 绑定广告 load 事件的监听器
20
20
  */
@@ -89,9 +89,10 @@ declare class AdAnalyticsJS {
89
89
  /**
90
90
  * 获取公共用户信息
91
91
  * @public
92
- * @returns {ICommonInfo}
92
+ * @param {string|number} [v] - key
93
+ * @returns {unknown}
93
94
  */
94
- public getCommonInfo(): ICommonInfo;
95
+ public getCommonInfo(v?: string | number): unknown;
95
96
  /**
96
97
  * 获取埋点公共用户信息
97
98
  * @protected
@@ -33,6 +33,19 @@ export class CountRecorder {
33
33
  _initLocalTimes(): void;
34
34
  updateToday(): void;
35
35
  remain(): number;
36
+ /**
37
+ * 保存指定次数
38
+ * @param {number} count 次数
39
+ */
40
+ save(count: number): void;
41
+ /**
42
+ * 清除当前类的本地存储
43
+ */
44
+ clear(): void;
45
+ /**
46
+ * 重置当前类的本地存储
47
+ */
48
+ reset(): void;
36
49
  }
37
50
  export type IConstructorArgs = {
38
51
  /**
@@ -106,6 +106,11 @@ declare class Storage {
106
106
  * @param {number|'today'} expire 过期时间(毫秒)或'today'表示当天有效,可选
107
107
  */
108
108
  setUserItem(key: string, value: any, expire: number | "today"): void;
109
+ /**
110
+ * 删除用户维度的存储项
111
+ * @param {string} key 存储键
112
+ */
113
+ removeUserItem(key: string): void;
109
114
  /**
110
115
  * 删除存储项
111
116
  * @param {string} key 存储键
package/package.json CHANGED
@@ -1,97 +1,97 @@
1
- {
2
- "name": "@singcl/ad-execute-manager",
3
- "version": "2.1.2",
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
- "type": "module",
6
- "exports": {
7
- ".": {
8
- "import": "./dist/index.js",
9
- "require": "./dist/index.cjs",
10
- "types": "./dist/index.d.ts"
11
- }
12
- },
13
- "main": "./dist/index.cjs",
14
- "types": "./dist/index.d.ts",
15
- "files": [
16
- "dist"
17
- ],
18
- "author": {
19
- "name": "singcl",
20
- "email": "iambabyer@gmail.com",
21
- "url": "https://github.com/singcl"
22
- },
23
- "license": "MIT",
24
- "homepage": "https://npmx.dev/package/@singcl/ad-execute-manager",
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/singcl/ad-execute-manager.git"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/singcl/ad-execute-manager/issues"
31
- },
32
- "engines": {
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"
40
- },
41
- "keywords": [
42
- "ad",
43
- "advertisement",
44
- "reward-ad",
45
- "interstitial-ad",
46
- "ad-manager",
47
- "ad-execution",
48
- "javascript",
49
- "nodejs"
50
- ],
51
- "scripts": {
52
- "build": "rslib build && tsc",
53
- "dev": "rslib build --watch",
54
- "format": "prettier --write .",
55
- "lint": "eslint .",
56
- "test": "rstest",
57
- "prepublishOnly": "npm i && npm run build",
58
- "packages:install": "node build-packages.js install",
59
- "packages:build": "node build-packages.js build",
60
- "packages:publish": "node build-packages.js publish",
61
- "packages:publish:patch": "node build-packages.js publish patch",
62
- "packages:publish:minor": "node build-packages.js publish minor",
63
- "packages:publish:major": "node build-packages.js publish major",
64
- "packages:lint": "node build-packages.js lint",
65
- "packages:format": "node build-packages.js format",
66
- "packages:clean": "node build-packages.js clean",
67
- "packages:all": "node build-packages.js all",
68
- "packages:all:patch": "node build-packages.js all patch",
69
- "packages:all:minor": "node build-packages.js all minor",
70
- "packages:all:major": "node build-packages.js all major"
71
- },
72
- "devDependencies": {
73
- "@babel/eslint-parser": "^7.28.5",
74
- "@babel/preset-env": "^7.28.5",
75
- "@douyin-microapp/typings": "^1.3.1",
76
- "@eslint/js": "^9.39.1",
77
- "@rslib/core": "^0.18.5",
78
- "@rstest/core": "^0.7.2",
79
- "@singcl/ad-execute-manager": "^1.11.12",
80
- "eslint": "^9.39.2",
81
- "eslint-plugin-import": "^2.32.0",
82
- "globals": "^16.5.0",
83
- "prettier": "^3.7.3",
84
- "typescript": "^5.9.3"
85
- },
86
- "dependencies": {
87
- "@ad-execute-manager/core": "^2.0.6",
88
- "@ad-execute-manager/logger": "^2.0.5",
89
- "@ad-execute-manager/ad-reward": "^2.1.1",
90
- "@ad-execute-manager/ad-interstitial": "^2.0.6",
91
- "@ad-execute-manager/count-recorder": "^2.0.5",
92
- "@ad-execute-manager/serializable-error": "^2.0.5",
93
- "@ad-execute-manager/storage": "^2.0.5",
94
- "@ad-execute-manager/event": "^2.0.5",
95
- "@ad-execute-manager/analytics": "^2.0.5"
96
- }
97
- }
1
+ {
2
+ "name": "@singcl/ad-execute-manager",
3
+ "version": "2.3.0",
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
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "author": {
19
+ "name": "singcl",
20
+ "email": "iambabyer@gmail.com",
21
+ "url": "https://github.com/singcl"
22
+ },
23
+ "license": "MIT",
24
+ "homepage": "https://npmx.dev/package/@singcl/ad-execute-manager",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/singcl/ad-execute-manager.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/singcl/ad-execute-manager/issues"
31
+ },
32
+ "engines": {
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"
40
+ },
41
+ "keywords": [
42
+ "ad",
43
+ "advertisement",
44
+ "reward-ad",
45
+ "interstitial-ad",
46
+ "ad-manager",
47
+ "ad-execution",
48
+ "javascript",
49
+ "nodejs"
50
+ ],
51
+ "scripts": {
52
+ "build": "rslib build && tsc",
53
+ "dev": "rslib build --watch",
54
+ "format": "prettier --write .",
55
+ "lint": "eslint .",
56
+ "test": "rstest",
57
+ "prepublishOnly": "npm i && npm run build",
58
+ "packages:install": "node build-packages.js install",
59
+ "packages:build": "node build-packages.js build",
60
+ "packages:publish": "node build-packages.js publish",
61
+ "packages:publish:patch": "node build-packages.js publish patch",
62
+ "packages:publish:minor": "node build-packages.js publish minor",
63
+ "packages:publish:major": "node build-packages.js publish major",
64
+ "packages:lint": "node build-packages.js lint",
65
+ "packages:format": "node build-packages.js format",
66
+ "packages:clean": "node build-packages.js clean",
67
+ "packages:all": "node build-packages.js all",
68
+ "packages:all:patch": "node build-packages.js all patch",
69
+ "packages:all:minor": "node build-packages.js all minor",
70
+ "packages:all:major": "node build-packages.js all major"
71
+ },
72
+ "devDependencies": {
73
+ "@babel/eslint-parser": "^7.28.5",
74
+ "@babel/preset-env": "^7.28.5",
75
+ "@douyin-microapp/typings": "^1.3.1",
76
+ "@eslint/js": "^9.39.1",
77
+ "@rslib/core": "^0.18.5",
78
+ "@rstest/core": "^0.7.2",
79
+ "@singcl/ad-execute-manager": "^1.11.12",
80
+ "eslint": "^9.39.2",
81
+ "eslint-plugin-import": "^2.32.0",
82
+ "globals": "^16.5.0",
83
+ "prettier": "^3.7.3",
84
+ "typescript": "^5.9.3"
85
+ },
86
+ "dependencies": {
87
+ "@ad-execute-manager/core": "^2.0.6",
88
+ "@ad-execute-manager/logger": "^2.0.5",
89
+ "@ad-execute-manager/ad-reward": "^2.3.0",
90
+ "@ad-execute-manager/ad-interstitial": "^2.0.6",
91
+ "@ad-execute-manager/count-recorder": "^2.1.0",
92
+ "@ad-execute-manager/serializable-error": "^2.0.5",
93
+ "@ad-execute-manager/storage": "^2.1.0",
94
+ "@ad-execute-manager/event": "^2.0.5",
95
+ "@ad-execute-manager/analytics": "^2.0.6"
96
+ }
97
+ }