@singcl/ad-execute-manager 1.2.0 → 1.3.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/dist/ad/InterstitialAdFather.d.ts +131 -0
- package/dist/ad/InterstitialAdNovel.d.ts +441 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,131 @@
|
|
|
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;
|
|
5
|
+
export type IRewardedVideoAd = {
|
|
6
|
+
/**
|
|
7
|
+
* 显示激励视频广告
|
|
8
|
+
*/
|
|
9
|
+
show: () => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @typedef IRewardedVideoAd
|
|
13
|
+
* @property {() => Promise.<void>} show 显示激励视频广告
|
|
14
|
+
*/
|
|
15
|
+
declare class InterstitialAdFather {
|
|
16
|
+
/** @type {IRewordAdConfig | null} */
|
|
17
|
+
static args: IRewordAdConfig | null;
|
|
18
|
+
/**
|
|
19
|
+
* @param {IRewordAdConfig} args
|
|
20
|
+
*/
|
|
21
|
+
static buildArgs(args: IRewordAdConfig): void;
|
|
22
|
+
/**
|
|
23
|
+
* 使用管理器执行广告
|
|
24
|
+
* @param {Object} adInstance 广告实例
|
|
25
|
+
* @param {Object} ctx 上下文对象,用于传递数据和状态
|
|
26
|
+
* @param {Object} ctx.options 广告执行选项
|
|
27
|
+
* @param {Object} ctx.options.log 是否打印日志
|
|
28
|
+
* @param {Object} ctx.collection 回调集合
|
|
29
|
+
* @returns {Promise} 广告执行结果的Promise
|
|
30
|
+
*/
|
|
31
|
+
static executeWithManager(adInstance: any, ctx: {
|
|
32
|
+
options: {
|
|
33
|
+
log: any;
|
|
34
|
+
};
|
|
35
|
+
collection: any;
|
|
36
|
+
}): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* @param {IConstructArgs} args
|
|
39
|
+
*/
|
|
40
|
+
constructor(args: IConstructArgs);
|
|
41
|
+
_initSign: string;
|
|
42
|
+
_preserveOnEnd: boolean;
|
|
43
|
+
_interstitialAd: any;
|
|
44
|
+
_ttErrorMsgs: string[];
|
|
45
|
+
_ttErrorCodes: number[];
|
|
46
|
+
_adConfig: {};
|
|
47
|
+
/**
|
|
48
|
+
* 初始化
|
|
49
|
+
* 子类可以选择覆盖此方法,或使用默认实现
|
|
50
|
+
* @param {IRewordAdConfig} params
|
|
51
|
+
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
52
|
+
* @returns {this} 当前实例
|
|
53
|
+
*/
|
|
54
|
+
initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
|
|
55
|
+
initialized(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 执行广告展示
|
|
58
|
+
* @abstract
|
|
59
|
+
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
60
|
+
* @param {IRewordAdConfig} [ctx.options] 广告执行选项
|
|
61
|
+
* @param {CallbackCollection} [ctx.collection] 回调集合
|
|
62
|
+
* @param {Function} next 执行下一个任务的回调函数,在洋葱模型中手动调用以继续执行流程
|
|
63
|
+
* @returns {Promise<unknown>} 广告执行结果的Promise
|
|
64
|
+
* @throws {Error} 子类必须实现此方法
|
|
65
|
+
*/
|
|
66
|
+
ad(ctx?: {
|
|
67
|
+
options?: IRewordAdConfig;
|
|
68
|
+
collection?: CallbackCollection;
|
|
69
|
+
}, next?: Function): Promise<unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* 确保广告按顺序执行
|
|
72
|
+
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
73
|
+
* @param {IRewordAdConfig} [ctx.options] 广告执行选项
|
|
74
|
+
* @param {CallbackCollection} [ctx.collection] 回调集合
|
|
75
|
+
* @returns {Promise.<unknown>} 广告执行结果的Promise
|
|
76
|
+
*/
|
|
77
|
+
addExecuteManager(ctx?: {
|
|
78
|
+
options?: IRewordAdConfig;
|
|
79
|
+
collection?: CallbackCollection;
|
|
80
|
+
}): Promise<unknown>;
|
|
81
|
+
destroy(): void;
|
|
82
|
+
/**
|
|
83
|
+
* 清理广告实例
|
|
84
|
+
* @abstract 清理广告实例,子类必须实现此方法
|
|
85
|
+
*/
|
|
86
|
+
clear(): void;
|
|
87
|
+
/**
|
|
88
|
+
* 任务执行完成后始终执行的一个方法
|
|
89
|
+
* @abstract 任务执行完成后始终执行的一个方法,子类需要用到时实现此方法
|
|
90
|
+
* @param {object} [_args] 执行结果信息
|
|
91
|
+
*/
|
|
92
|
+
record(_args?: object): this;
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @param {({isEnded: boolean, count: number}) => void} callback
|
|
96
|
+
*/
|
|
97
|
+
onClose(callback: ({ isEnded: boolean, count: number }: any) => void): void;
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @param {({isEnded: boolean, count: number}) => void} callback
|
|
101
|
+
*/
|
|
102
|
+
offClose(callback: ({ isEnded: boolean, count: number }: any) => void): void;
|
|
103
|
+
/**
|
|
104
|
+
* show
|
|
105
|
+
* @returns { Promise.<void>}
|
|
106
|
+
* @params {{errMsg: string; errCode: number}} err
|
|
107
|
+
*/
|
|
108
|
+
show(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* show
|
|
111
|
+
* @returns { Promise.<void>}
|
|
112
|
+
*/
|
|
113
|
+
load(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param {({errMsg: string; errCode: number}) => void} callback
|
|
117
|
+
*/
|
|
118
|
+
onError(callback: any): void;
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @param {({errMsg: string; errCode: number}) => void} callback
|
|
122
|
+
*/
|
|
123
|
+
offError(callback: any): void;
|
|
124
|
+
onLoad(callback: any): void;
|
|
125
|
+
offLoad(callback: any): void;
|
|
126
|
+
/**
|
|
127
|
+
* 站位方法,没有任何左右
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
placeholder(): any;
|
|
131
|
+
}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
export default InterstitialAdNovel;
|
|
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
|
+
* 是否保留tt激励视频广告实例
|
|
57
|
+
*/
|
|
58
|
+
preserveOnEnd?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 是否需要在超时情况下结束广告
|
|
61
|
+
*/
|
|
62
|
+
needEndOnTimeout?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 激励视频参数 (可选)
|
|
65
|
+
*/
|
|
66
|
+
adConfig?: IRewordAdConfig | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 回调集合
|
|
69
|
+
*/
|
|
70
|
+
collection?: IConnection | undefined;
|
|
71
|
+
};
|
|
72
|
+
export type ICloseArgs = {
|
|
73
|
+
/**
|
|
74
|
+
* 是否看完
|
|
75
|
+
*/
|
|
76
|
+
isEnded: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 完整观看次数
|
|
79
|
+
*/
|
|
80
|
+
count: number;
|
|
81
|
+
};
|
|
82
|
+
export type IEndArgs = {
|
|
83
|
+
/**
|
|
84
|
+
* 是否解锁全部
|
|
85
|
+
*/
|
|
86
|
+
can_unlock_all?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* 是否解锁小说
|
|
89
|
+
*/
|
|
90
|
+
can_unlock_novel?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* 剩余次数
|
|
93
|
+
*/
|
|
94
|
+
remain?: number;
|
|
95
|
+
/**
|
|
96
|
+
* 结束类型
|
|
97
|
+
*/
|
|
98
|
+
end_type?: "halfway" | "finished";
|
|
99
|
+
};
|
|
100
|
+
export type IRewardedVideoAd = {
|
|
101
|
+
/**
|
|
102
|
+
* 显示激励视频广告
|
|
103
|
+
*/
|
|
104
|
+
show: () => Promise<void>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* @typedef {import('../typings/ad.js').IRewordAdConfig} IRewordAdConfig
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* @typedef ICallbackArgs
|
|
111
|
+
* @property {number} scene 广告执行场景
|
|
112
|
+
* @property {boolean} isEnded 是否看完
|
|
113
|
+
* @property {number} count 完整观看次数
|
|
114
|
+
* @property {() => void} [end] 执行下一个任务的回调函数,手动调用以继续执行流程[end]
|
|
115
|
+
* @property {(args: {ignoreRemain: boolean, scene: number}) => void} [circle] 执行下一个任务的回调函数, 手动调用以继续执行流程[circle]
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* @typedef IConnection
|
|
120
|
+
* @property {(args: ICallbackArgs) => void} [onHalfway] 广告中途退出回调
|
|
121
|
+
* @property {(args: ICallbackArgs) => void} [onShow] 广告展示回调
|
|
122
|
+
* @property {(args: ICallbackArgs) => void} [onFinish] 广告执行成功回调
|
|
123
|
+
* @property {(args: ICallbackArgs) => void} [onAlways] 广告执行成功回调
|
|
124
|
+
* @property {(e:unknown) => void} [onError] 广告执行失败回调
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* @typedef IConstructArgs
|
|
128
|
+
* @property {string} [sign] 初始化标识
|
|
129
|
+
* @property {boolean} [preserveOnEnd] 是否保留tt激励视频广告实例
|
|
130
|
+
* @property {boolean} [needEndOnTimeout] 是否需要在超时情况下结束广告
|
|
131
|
+
* @property {IRewordAdConfig=} [adConfig] 激励视频参数 (可选)
|
|
132
|
+
* @property {IConnection=} [collection] 回调集合
|
|
133
|
+
*/
|
|
134
|
+
/**
|
|
135
|
+
* @typedef ICloseArgs
|
|
136
|
+
* @property {boolean} isEnded 是否看完
|
|
137
|
+
* @property {number} count 完整观看次数
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* @typedef IEndArgs
|
|
141
|
+
* @property {boolean} [can_unlock_all] 是否解锁全部
|
|
142
|
+
* @property {boolean} [can_unlock_novel] 是否解锁小说
|
|
143
|
+
* @property {number} [remain] 剩余次数
|
|
144
|
+
* @property {'halfway' | 'finished'} [end_type] 结束类型
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
/**
|
|
148
|
+
* @typedef IRewardedVideoAd
|
|
149
|
+
* @property {() => Promise.<void>} show 显示激励视频广告
|
|
150
|
+
*/
|
|
151
|
+
declare class InterstitialAdNovel extends InterstitialAdFather {
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param {IConstructArgs} args
|
|
155
|
+
* @returns {InterstitialAdNovel}
|
|
156
|
+
*/
|
|
157
|
+
static build(args: IConstructArgs): InterstitialAdNovel;
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* @returns {InterstitialAdNovel}
|
|
161
|
+
*/
|
|
162
|
+
static getInstance(): InterstitialAdNovel;
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param {IConstructArgs} args
|
|
166
|
+
* @returns {InterstitialAdNovel}
|
|
167
|
+
*/
|
|
168
|
+
static "new"(args: IConstructArgs): InterstitialAdNovel;
|
|
169
|
+
/**
|
|
170
|
+
* @param {IConstructArgs} args
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
constructor(args: IConstructArgs);
|
|
174
|
+
_onHalfway: any;
|
|
175
|
+
_onShow: any;
|
|
176
|
+
_onFinish: any;
|
|
177
|
+
_onAlways: any;
|
|
178
|
+
_onError: any;
|
|
179
|
+
_alwaysCallback: any;
|
|
180
|
+
_halfwayCallback: any;
|
|
181
|
+
_finishedCallback: any;
|
|
182
|
+
_resolve: any;
|
|
183
|
+
_next: any;
|
|
184
|
+
/** @type {number} 广告执行场景 */
|
|
185
|
+
_scene: number;
|
|
186
|
+
_adTimeout: any;
|
|
187
|
+
_adTimeoutTime: number;
|
|
188
|
+
_adBeforeShowTimer: any;
|
|
189
|
+
_adBeforeShowTime: number;
|
|
190
|
+
_adSpeedCloseTimer: any;
|
|
191
|
+
_adSpeedCloseTime: number;
|
|
192
|
+
_needEndOnTimeout: boolean;
|
|
193
|
+
/** @deprecated TODO 移除 */
|
|
194
|
+
_needSpeedEndOnTimeout: boolean;
|
|
195
|
+
bindAdCloseLister: any;
|
|
196
|
+
bindAdErrorLister: any;
|
|
197
|
+
bindAdLoadLister: any;
|
|
198
|
+
bindApiAdErrorLister: any;
|
|
199
|
+
_bindShiftCloseLister: any;
|
|
200
|
+
_bindShiftErrorLister: any;
|
|
201
|
+
/**
|
|
202
|
+
* 初始化
|
|
203
|
+
* 子类可以选择覆盖此方法,或使用默认实现
|
|
204
|
+
* @param {IRewordAdConfig} args
|
|
205
|
+
* @param {(v: IRewardedVideoAd) => void} [callback] 初始化成功回调
|
|
206
|
+
* @returns {this} 当前实例
|
|
207
|
+
*/
|
|
208
|
+
initialize(args: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
|
|
209
|
+
_initAdLister(): void;
|
|
210
|
+
/**
|
|
211
|
+
* @param {object} args
|
|
212
|
+
* @param {number} [args.retry] 重试次数
|
|
213
|
+
*/
|
|
214
|
+
_initNovelConfig(args: {
|
|
215
|
+
retry?: number;
|
|
216
|
+
}): void;
|
|
217
|
+
novelConfig: RewardAdNovelConfig;
|
|
218
|
+
_onInnerExecuteBefore(): any;
|
|
219
|
+
_onInnerAdShowSuccess(): any;
|
|
220
|
+
/**
|
|
221
|
+
* 广告展示超时设置
|
|
222
|
+
* @param {object} args
|
|
223
|
+
* @param {string} args.scene 广告执行场景 必填
|
|
224
|
+
* @param {Function} args.end 结束当前广告任务的回调函数 必填
|
|
225
|
+
*/
|
|
226
|
+
_setAdTimeout(args: {
|
|
227
|
+
scene: string;
|
|
228
|
+
end: Function;
|
|
229
|
+
}): void;
|
|
230
|
+
/**
|
|
231
|
+
* 广告展示前定时器
|
|
232
|
+
* @param {object} args
|
|
233
|
+
* @param {string} args.scene 广告执行场景 必填
|
|
234
|
+
* @param {Function} args.prelude 广告展示前回调函数 可选
|
|
235
|
+
*/
|
|
236
|
+
_adPreludeInterval(args: {
|
|
237
|
+
scene: string;
|
|
238
|
+
prelude: Function;
|
|
239
|
+
}): void;
|
|
240
|
+
_clearAdTimeout(): void;
|
|
241
|
+
/**
|
|
242
|
+
* 广告展示成功分析
|
|
243
|
+
* 子类需要埋点可以选择覆盖此方法
|
|
244
|
+
* @param {object} _args
|
|
245
|
+
* @param {string} _args.scene 广告执行场景 必填
|
|
246
|
+
* @param {string} [_args.msg] 广告执行成功原因
|
|
247
|
+
* @param {result} _args.result 广告执行成功结果
|
|
248
|
+
* @returns
|
|
249
|
+
*/
|
|
250
|
+
_adShowSuccessAnalytics(_args: {
|
|
251
|
+
scene: string;
|
|
252
|
+
msg?: string;
|
|
253
|
+
result: result;
|
|
254
|
+
}): any;
|
|
255
|
+
/**
|
|
256
|
+
* 广告展示失败分析
|
|
257
|
+
* 子类需要埋点可以选择覆盖此方法
|
|
258
|
+
* @param {object} _args
|
|
259
|
+
* @param {string} _args.scene 广告执行场景 必填
|
|
260
|
+
* @param {string} _args.msg 广告执行失败原因 必填
|
|
261
|
+
* @param {result} _args.result 广告执行失败结果
|
|
262
|
+
* @returns
|
|
263
|
+
*/
|
|
264
|
+
_adShowFailureAnalytics(_args: {
|
|
265
|
+
scene: string;
|
|
266
|
+
msg: string;
|
|
267
|
+
result: result;
|
|
268
|
+
}): any;
|
|
269
|
+
/**
|
|
270
|
+
* 广告加载成功分析
|
|
271
|
+
* 子类需要埋点可以选择覆盖此方法
|
|
272
|
+
* @param {object} _args
|
|
273
|
+
* @param {string} _args.scene 广告执行场景 必填
|
|
274
|
+
* @param {string} [_args.msg] 广告执行成功原因
|
|
275
|
+
* @param {result} _args.result 广告执行成功结果
|
|
276
|
+
* @returns
|
|
277
|
+
*/
|
|
278
|
+
_adLoadSuccessAnalytics(_args: {
|
|
279
|
+
scene: string;
|
|
280
|
+
msg?: string;
|
|
281
|
+
result: result;
|
|
282
|
+
}): any;
|
|
283
|
+
/**
|
|
284
|
+
* 广告加载失败分析
|
|
285
|
+
* 子类需要埋点可以选择覆盖此方法
|
|
286
|
+
* @param {object} _args
|
|
287
|
+
* @param {string} _args.scene 广告执行场景 必填
|
|
288
|
+
* @param {string} _args.msg 广告执行失败原因 必填
|
|
289
|
+
* @param {result} _args.result 广告执行失败结果
|
|
290
|
+
* @returns
|
|
291
|
+
*/
|
|
292
|
+
_adLoadFailureAnalytics(_args: {
|
|
293
|
+
scene: string;
|
|
294
|
+
msg: string;
|
|
295
|
+
result: result;
|
|
296
|
+
}): any;
|
|
297
|
+
/**
|
|
298
|
+
* 广告关闭成功分析
|
|
299
|
+
* 子类需要埋点可以选择覆盖此方法
|
|
300
|
+
* @param {object} _args
|
|
301
|
+
* @param {string} _args.scene 广告执行场景 必填
|
|
302
|
+
* @param {number} _args.ad_is_completed 广告是否完成 必填
|
|
303
|
+
* @param {number} _args.ad_count 广告执行次数 必填
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
_adCloseSuccessAnalytics(_args: {
|
|
307
|
+
scene: string;
|
|
308
|
+
ad_is_completed: number;
|
|
309
|
+
ad_count: number;
|
|
310
|
+
}): any;
|
|
311
|
+
get rewardAd(): any;
|
|
312
|
+
/**
|
|
313
|
+
* 确保广告按顺序执行
|
|
314
|
+
* @override
|
|
315
|
+
* @param {Object} [ctx] 上下文对象,用于传递数据和状态
|
|
316
|
+
* @param {IRewordAdConfig} [ctx.options] 广告执行选项
|
|
317
|
+
* @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
318
|
+
* @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
|
|
319
|
+
*/
|
|
320
|
+
override addExecuteManager(ctx?: {
|
|
321
|
+
options?: IRewordAdConfig;
|
|
322
|
+
collection?: import("../typings/ad.js").CallbackCollection;
|
|
323
|
+
}): Promise<(IEndArgs & ICloseArgs) | undefined>;
|
|
324
|
+
/**
|
|
325
|
+
* @override
|
|
326
|
+
* @param {object} [ctx] 广告执行上下文
|
|
327
|
+
* @param {import('../typings/ad.js').IRewordAdConfig} [ctx.options] 广告执行选项
|
|
328
|
+
* @param {import('../typings/ad.js').CallbackCollection} [ctx.collection] 回调集合
|
|
329
|
+
* @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
|
|
330
|
+
* @returns {Promise.<IEndArgs & ICloseArgs | Undefined>}
|
|
331
|
+
*/
|
|
332
|
+
override ad(ctx?: {
|
|
333
|
+
options?: import("../typings/ad.js").IRewordAdConfig;
|
|
334
|
+
collection?: import("../typings/ad.js").CallbackCollection;
|
|
335
|
+
}, next?: Function): Promise<(IEndArgs & ICloseArgs) | undefined>;
|
|
336
|
+
/**
|
|
337
|
+
* @param {object} [ctx] 广告执行上下文
|
|
338
|
+
* @param {object} [ctx.options] 广告执行选项
|
|
339
|
+
* @param {number} [ctx.options.scene] 广告执行场景
|
|
340
|
+
* @param {object} ctx.collection 回调集合
|
|
341
|
+
* @param {(v?: unknown) => void} ctx.collection.resolve 广告执行成功的回调函数
|
|
342
|
+
* @param {(v?: unknown) => void} [ctx.collection.reject] 广告执行失败的回调函数
|
|
343
|
+
* @param {(v?: unknown) => void} [ctx.collection.before] 广告执行前的回调函数
|
|
344
|
+
* @param {(v?: unknown) => void} [ctx.collection.success] 广告执行成功的回调函数
|
|
345
|
+
* @param {(v?: unknown) => void} [ctx.collection.prelude] 拉起广告前计时的回调函数
|
|
346
|
+
* @param {Function} next 执行下一个任务的回调函数,手动调用以继续执行流程
|
|
347
|
+
*/
|
|
348
|
+
_adInner(ctx?: {
|
|
349
|
+
options?: {
|
|
350
|
+
scene?: number;
|
|
351
|
+
};
|
|
352
|
+
collection: {
|
|
353
|
+
resolve: (v?: unknown) => void;
|
|
354
|
+
reject?: (v?: unknown) => void;
|
|
355
|
+
before?: (v?: unknown) => void;
|
|
356
|
+
success?: (v?: unknown) => void;
|
|
357
|
+
prelude?: (v?: unknown) => void;
|
|
358
|
+
};
|
|
359
|
+
}, next?: Function): void;
|
|
360
|
+
_before: (v?: unknown) => void;
|
|
361
|
+
_success: (v?: unknown) => void;
|
|
362
|
+
/**
|
|
363
|
+
* 广告加载
|
|
364
|
+
* @returns
|
|
365
|
+
*/
|
|
366
|
+
adLoad(): Promise<void>;
|
|
367
|
+
/**
|
|
368
|
+
* 广告展示
|
|
369
|
+
* @returns
|
|
370
|
+
*/
|
|
371
|
+
adShow(): Promise<void>;
|
|
372
|
+
_outerCloseCallback(args: any): void;
|
|
373
|
+
_outerHalfwayCallback(args: any): void;
|
|
374
|
+
_outerFinishedCallback(args: any): void;
|
|
375
|
+
/**
|
|
376
|
+
* 关闭激励视频
|
|
377
|
+
* 子类重写该方法时,必须调用this._clearAdTimeout();清除超时定时器
|
|
378
|
+
* @param {ICloseArgs} args
|
|
379
|
+
*/
|
|
380
|
+
adCloseLister(args: ICloseArgs): void;
|
|
381
|
+
adErrorLister(e: any): void;
|
|
382
|
+
apiAdErrorLister(e: any): void;
|
|
383
|
+
/**
|
|
384
|
+
* 激励视频广告组件**成功**拉取广告素材时会触发
|
|
385
|
+
* 创建激励时候后会自动拉取广告素材,如果广告拉取成功,也会触发此事件,不管是否调用show方法
|
|
386
|
+
* @param {unknown} e
|
|
387
|
+
*/
|
|
388
|
+
adLoadLister(e: unknown): void;
|
|
389
|
+
adDestroy(): void;
|
|
390
|
+
_shiftCloseLister(args: any): void;
|
|
391
|
+
_shiftErrorLister(args: any): void;
|
|
392
|
+
/**
|
|
393
|
+
* 手动出栈
|
|
394
|
+
*/
|
|
395
|
+
shift(): void;
|
|
396
|
+
}
|
|
397
|
+
import InterstitialAdFather from './InterstitialAdFather.js';
|
|
398
|
+
declare class RewardAdNovelConfig {
|
|
399
|
+
/**
|
|
400
|
+
*
|
|
401
|
+
* @param {object} args
|
|
402
|
+
* @param {string} args.sign 初始化标识
|
|
403
|
+
* @param {number} [args.retry] 重试次数
|
|
404
|
+
* @returns {RewardAdNovelConfig}
|
|
405
|
+
*/
|
|
406
|
+
static "new"(args: {
|
|
407
|
+
sign: string;
|
|
408
|
+
retry?: number;
|
|
409
|
+
}): RewardAdNovelConfig;
|
|
410
|
+
/**
|
|
411
|
+
*
|
|
412
|
+
* @param {object} [args]
|
|
413
|
+
* @param {number} [args.retry]
|
|
414
|
+
*/
|
|
415
|
+
constructor(args?: {
|
|
416
|
+
retry?: number;
|
|
417
|
+
});
|
|
418
|
+
frequency: {
|
|
419
|
+
total: number;
|
|
420
|
+
current: number;
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
*
|
|
424
|
+
* @param {object} [args]
|
|
425
|
+
* @param {number} [args.retry]
|
|
426
|
+
*/
|
|
427
|
+
_init(args?: {
|
|
428
|
+
retry?: number;
|
|
429
|
+
}): void;
|
|
430
|
+
/**
|
|
431
|
+
*
|
|
432
|
+
* @param {object} [args]
|
|
433
|
+
* @param {number} [args.retry]
|
|
434
|
+
*/
|
|
435
|
+
_adTimes(args?: {
|
|
436
|
+
retry?: number;
|
|
437
|
+
}): void;
|
|
438
|
+
reset(): void;
|
|
439
|
+
updateRetry(): void;
|
|
440
|
+
remain(): number;
|
|
441
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{default:()=>src,Storage:()=>ad_Storage,RewardAdGlobalRecorder:()=>ad_RewardAdGlobalRecorder,CountRecorder:()=>CountRecorder,RewardAdNovel:()=>ad_RewardAdNovel,RewardAdFather:()=>ad_RewardAdFather,Logger:()=>Logger,ExbAnalyticsJS:()=>ad_ExbAnalyticsJS,AdExecuteManager:()=>ad_AdExecuteManager,RewardAdSceneTriggerManager:()=>ad_RewardAdSceneTriggerManager,SerializableError:()=>SerializableError});const compose=e=>e.map(e=>(t,r)=>async s=>await e(Object.assign({},t,s),r)).reduce((e,t)=>(r,s)=>e(r,t(r,s))),ad_compose=compose;class Logger{constructor(e={}){const{prefix:t="Logger",level:r="info",enabled:s=!0}=e;this.prefix=t,this.enabled=s,this.levels={error:0,warn:1,info:2,debug:3},this.currentLevel=this.levels[r]||this.levels.info}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}setLevel(e){Object.prototype.hasOwnProperty.call(this.levels,e)&&(this.currentLevel=this.levels[e])}formatMessage(e,t){let r=new Date,s=`${r.getFullYear()}/${r.getMonth()+1}/${r.getDate()} ${r.getHours()}:${r.getMinutes()}:${r.getSeconds()}`;return`[${s}] [${e.toUpperCase()}] [${this.prefix}] ${t}`}_log(e,t,...r){if(!this.enabled)return;let s=this.levels[e];if(void 0!==s&&this.currentLevel>=s){let s=this.formatMessage(e,t);switch(e){case"error":console.error(s,...r);break;case"warn":console.warn(s,...r);break;case"info":console.info(s,...r);break;case"debug":console.debug(s,...r);break;default:console.log(s,...r)}}}error(e,...t){this._log("error",e,...t)}warn(e,...t){this._log("warn",e,...t)}info(e,...t){this._log("info",e,...t)}debug(e,...t){this._log("debug",e,...t)}log(e,t,...r){this._log(e,t,...r)}}class AdExecuteManager{static _instance=null;_taskStack=[];_currentBatchTasks=[];_isRunning=!1;_currentTask=null;constructor(e){if(this.logger=new Logger({prefix:"AdExecuteManager",enabled:!!e?.log}),AdExecuteManager._instance)return AdExecuteManager._instance;AdExecuteManager._instance=this}static getInstance(e){return AdExecuteManager._instance||(AdExecuteManager._instance=new AdExecuteManager(e)),AdExecuteManager._instance}addTask(e,t){return e&&"function"==typeof e.ad?new Promise((r,s)=>{let i={adInstance:e,options:t.options??{},callbackCollection:t.collection??{},resolve:r,reject:s,id:`ad_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,_isResolved:!1,_isRejected:!1};this._taskStack.push(i),this._isRunning||this._compose()}):(this.logger.error("无效的广告实例 请正确实现.ad方法"),Promise.reject(Error("无效的广告实例")))}_compose(){if(0===this._taskStack.length){this._isRunning=!1,this._currentTask=null;return}this._isRunning=!0;let e=[...this._taskStack];this._taskStack=[],this._currentBatchTasks=e;let t=e.map(e=>async(t,r)=>{let{adInstance:s,options:i,callbackCollection:n,resolve:a,id:o}=e;if(e._isResolved||e._isRejected)return void await r(t);this._currentTask=e;try{let l=async e=>{await r(Object.assign({},t,e))},d=await s.initialize(i).ad({options:i,collection:n},l),c=Object.assign({id:o},d);this.logger.info(`任务执行成功,成功信息:${JSON.stringify(c)}`),e._isResolved=!0,a(c),s?.record(c)}catch(n){let i=Object.assign({id:o,apiError:n});this.logger.error(`任务执行失败, 继续下一个任务,错误信息:${JSON.stringify(i)}`),e._isRejected=!0;try{s?.clear()}catch(e){this.logger.error("clear error: ",JSON.stringify(Object.assign({id:o,apiError:e})))}a(i),s?.record(i),await r(t)}}),r={roundTasks:t.length};compose(t)(r,async e=>{this.logger.info("本轮活动队列已经清空",e),this._taskStack.length>0?Promise.resolve().then(()=>{this._compose()}):(this._isRunning=!1,this._currentTask=null,this._currentBatchTasks=[])})()}clearTasks(){if(this._currentTask){if(this._currentTask._isResolved||this._currentTask._isRejected){this._currentTask=null;return}try{this._currentTask.callbackCollection&&this._currentTask.callbackCollection.onCancel&&this._currentTask.callbackCollection.onCancel(),this._currentTask._isResolved=!0,this._currentTask.resolve()}catch(e){this.logger.error("clear current task error: ",e)}this._currentTask=null}this._currentBatchTasks.length>0&&(this._currentBatchTasks.forEach(e=>{if(e!==this._currentTask&&!e._isResolved&&!e._isRejected)try{e.callbackCollection&&e.callbackCollection.onCancel&&e.callbackCollection.onCancel(),e._isResolved=!0,e.resolve()}catch(e){this.logger.error("clear current batch task error: ",e)}}),this._currentBatchTasks=[]),this._taskStack.forEach(e=>{if(!e._isResolved&&!e._isRejected&&(e._isResolved=!0,e.resolve(),e.callbackCollection&&e.callbackCollection.onCancel))try{e.callbackCollection.onCancel()}catch(e){this.logger.error("clear task error: ",e)}}),this._taskStack=[],this._isRunning=!1}getTaskCount(){return this._taskStack.filter(e=>!e._isResolved&&!e._isRejected).length+this._currentBatchTasks.filter(e=>e!==this._currentTask&&!e._isResolved&&!e._isRejected).length+(!this._currentTask||this._currentTask._isResolved||this._currentTask._isRejected?0:1)}isRunning(){return this._isRunning}getCurrentTaskId(){return this._currentTask?.id||null}}const ad_AdExecuteManager=AdExecuteManager;class SerializableError extends Error{constructor(e){super(e),this.name=this.constructor.name,this.stack=Error(e).stack,Object.defineProperty(this,"message",{enumerable:!0}),Object.defineProperty(this,"name",{enumerable:!0}),Object.defineProperty(this,"stack",{enumerable:!0})}toJSON(){return{name:this.name,message:this.message,stack:this.stack}}}class RewardAdFather{static args=null;_initSign="";_preserveOnEnd=!1;_rewardAd=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];constructor(e){this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._preserveOnEnd=e?.preserveOnEnd??!1}initialize(e,t){if(this._rewardAd)return console.warn("RewardAdFather: rewardAd has been initialized"),t?.(this._rewardAd),this;let r=Object.assign({},RewardAdFather.args,this._adConfig,e);if(!r.adUnitId)throw console.error("[RewardAdFather] reward args adUnitId is required",r),new SerializableError("[RewardAdFather] reward args adUnitId is required");return this._rewardAd=tt.createRewardedVideoAd(r),t?.(this._rewardAd),this}initialized(){return!!this._rewardAd}async ad(e,t=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let t=Object.assign({},this._adConfig,e?.options??{});return RewardAdFather.executeWithManager(this,Object.assign({},e,{options:t}))}destroy(){this._rewardAd&&!this._preserveOnEnd&&(this._rewardAd.destroy(),this._rewardAd=null)}clear(){throw Error("子类必须实现clear方法")}record(e){return this}onClose(e){this._rewardAd&&this._rewardAd.onClose(e)}offClose(e){this._rewardAd&&this._rewardAd.offClose(e)}show(){return this._rewardAd?this._rewardAd.show():Promise.reject({errMsg:"rewardAd is null"})}load(){if(this._rewardAd)return this._rewardAd.load()}onError(e){this._rewardAd&&this._rewardAd.onError(e)}offError(e){this._rewardAd&&this._rewardAd.offError(e)}onLoad(e){this._rewardAd&&this._rewardAd.onLoad(e)}offLoad(e){this._rewardAd&&this._rewardAd.offLoad(e)}placeholder(){return null}static buildArgs(e){e?.adUnitId||console.error("[RewardAdFather] RewardParams.adUnitId is required"),RewardAdFather.args=e}static async executeWithManager(e,t){return e&&e instanceof RewardAdFather?ad_AdExecuteManager.getInstance({log:t?.options?.log??!0}).addTask(e,t):(console.error("RewardAdFather: executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}const ad_RewardAdFather=RewardAdFather;class Storage{constructor(e={}){this.config={prefix:"storage_",expire:null,...e},this.logger=new Logger({prefix:"Storage"})}getTodayEndTimestamp(){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999).getTime()}_setItem(e,t,r){let s=void 0!==r?r:this.config.expire;"today"===s&&(s=this.getTodayEndTimestamp()-Date.now());let i={value:t,expire:s,timestamp:Date.now()};try{tt.setStorageSync(e,JSON.stringify(i))}catch(e){console.error("Storage setItem error:",e)}}_getItem(e){try{let t=tt.getStorageSync(e);if(!t)return null;let r=JSON.parse(t);if(r.expire&&Date.now()-r.timestamp>r.expire)return this.removeItem(e),null;return r.value}catch(e){return console.error("Storage getItem error:",e),null}}setItem(e,t,r){let s=this.config.prefix+e;return this._setItem(s,t,r)}getItem(e){let t=this.config.prefix+e;return this._getItem(t)}getUserItem(e){let t=this.config.userId??"null";if("null"===t)return this.logger.error("userId is required"),null;let r=`${this.config.prefix}_${t}_${e}`;return this._getItem(r)}setUserItem(e,t,r){let s=this.config.userId??"null";if("null"===s)return void this.logger.error("userId is required");let i=`${this.config.prefix}_${s}_${e}`;return this._setItem(i,t,r)}removeItem(e){try{tt.removeStorageSync(e)}catch(e){console.error("Storage removeItem error:",e)}}clear(){try{tt.clearStorageSync()}catch(e){console.error("Storage clear error:",e)}}keys(){try{let e=[];return(tt.getStorageInfoSync().keys??[]).forEach(t=>{if(t.startsWith(this.config.prefix)){let r=JSON.parse(tt.getStorageSync(t));(!r.expire||Date.now()-r.timestamp<=r.expire)&&e.push(t.replace(this.config.prefix,""))}}),e}catch(e){return console.error("Storage keys error:",e),[]}}static new(e){return new Storage(e)}}const ad_Storage=Storage;class CountRecorder{_total=0;_local_sign="";_expire="today";constructor(e){if(this.storage=ad_Storage.new({userId:e.userId}),!e.local_sign)throw Error("local_sign is required");this._local_sign=e.local_sign,this._total=e.total??0,this._expire=e.expire??"today",this._init()}_init(){this._initLocalTimes()}_adTimes(){return this._total}_safeLocalValue(e){return"object"!=typeof e||null===e?{}:e}_initLocalTimes(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),r=this._safeLocalValue(t);r&&r?.total==e||this.storage.setUserItem(this._local_sign,{total:e,today:r?.today??0},this._expire)}updateToday(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),r=this._safeLocalValue(t),s=r?.today??0;this.storage.setUserItem(this._local_sign,{total:e,today:s+1},this._expire)}remain(){let e=this.storage.getUserItem(this._local_sign),t=this._safeLocalValue(e),r=t?.today??0;return Number(t?.total??0)-Number(r)}static new(e){return new CountRecorder(e)}}function matchErrorWithKeywords(e,t){return!!t&&e.some(e=>RegExp(e,"i").test(t))}function findAdTypeBySceneFlag(e,t,r="showTimes"){if(!Array.isArray(e))return console.error("第一个参数必须是数组"),null;let s=e.find(e=>e&&e.adSceneFlag===t);return s?s[r]:null}function getAdSceneTextObj(e){return Object.entries(e).reduce((e,[t,r])=>(e[r]=Number(t),e),{})}const DEFAULT_SCENT_TYPE_OBJ={9999:"inner_default_other"},DEFAULT_SCENT_TEXT_OBJ=getAdSceneTextObj(DEFAULT_SCENT_TYPE_OBJ);class RewardAdGlobalRecorder{static instance=null;_initSign="";_halfway=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}];_finished=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}];constructor(e){if(RewardAdGlobalRecorder.instance)return RewardAdGlobalRecorder.instance;this._initSign=e?.sign??"",this._halfway=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}],this._finished=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}],RewardAdGlobalRecorder.instance=this}initialize(e){}_halfwayUpdate(e){let t=this._halfway.find(t=>t.scene===e.scene);t?t.count+=1:this._halfway.push({scene:e.scene,count:1})}_halfwayGet(e){let t=e?.scenes??[];return(t.length>0?this._halfway.filter(e=>t.includes(e.scene)):this._halfway).reduce((e,t)=>e+t.count,0)}_halfwayReset(){this._halfway=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}]}_finishedUpdate(e){let t=this._finished.find(t=>t.scene===e.scene);t?t.count+=1:this._finished.push({scene:e.scene,count:1})}_finishedGet(e){let t=e?.scenes??[];return(t.length>0?this._finished.filter(e=>t.includes(e.scene)):this._finished).reduce((e,t)=>e+t.count,0)}_finishedReset(){this._finished=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}]}record(e){switch(e.type){case"halfway":this._halfwayUpdate(e);break;case"finished":this._finishedUpdate(e)}}rest(e){switch(e){case"halfway":this._halfwayReset();break;case"finished":this._finishedReset()}}get(e){switch(e.type){case"halfway":return this._halfwayGet(e);case"finished":return this._finishedGet(e);default:return null}}placeholder(){return null}static build(e){return RewardAdGlobalRecorder.instance||(RewardAdGlobalRecorder.instance=new RewardAdGlobalRecorder(e)),RewardAdGlobalRecorder.instance}static getInstance(){if(!RewardAdGlobalRecorder.instance)throw Error("RewardAdGlobalRecorder instance is not init");return RewardAdGlobalRecorder.instance}}const ad_RewardAdGlobalRecorder=RewardAdGlobalRecorder;class RewardAdSceneTriggerManager{static instance=null;_initSign="";_currScene=null;_sceneTypeObj={};constructor(e){if(RewardAdSceneTriggerManager.instance)return RewardAdSceneTriggerManager.instance;this._initSign=e?.sign??"",this._sceneTypeObj=e?.sceneTypeObj??{},RewardAdSceneTriggerManager.instance=this}initialize(e){}addScene(e){return console.log("----------------------AD触发场景:--------------------",e),this._currScene=e,this}addSceneType(e=1){return this.addScene(this._sceneTypeObj[e]),this}getCurrentScene(){return this._currScene}placeholder(){return null}static build(e){return RewardAdSceneTriggerManager.instance||(RewardAdSceneTriggerManager.instance=new RewardAdSceneTriggerManager(e)),RewardAdSceneTriggerManager.instance}static getInstance(){if(!RewardAdSceneTriggerManager.instance)throw Error("RewardAdSceneTriggerManager instance is not init");return RewardAdSceneTriggerManager.instance}}const ad_RewardAdSceneTriggerManager=RewardAdSceneTriggerManager;class ExbAnalyticsJS{static instance=null;_initSign="";_needReport=!1;constructor(e){if(ExbAnalyticsJS.instance)return ExbAnalyticsJS.instance;this._initSign=e?.sign??"",this._needReport=e?.needReport??!1,this._userConfig=e?.userConfig??null,ExbAnalyticsJS.instance=this}initialize(e){return this._needReport?e:void console.warn("ExbAnalyticsJS needReport is false, do not report")}track(e,t,r){if(!this._needReport)return;if(!e)throw Error("eventName is required");let s=Object.assign({},this._getCommonUserInfo(),t),i=r?.sign??"track";console.log(`-------------${i}-----------------------:`,e,s),tt.reportAnalytics(e,s)}_getCommonUserInfo(){let{user_id:e,user_type:t,user_group:r}=this._userConfig??{};return{user_id:e,user_type:t,user_group:r}}identify(e){if(!e)throw Error("userInfo is required");if(!e.user_id)throw Error("user_id is required");return this._userConfig={user_id:e.user_id,user_type:e.user_type??0,user_group:e.user_group??0},this}alias(){return null}pages(){return null}page(e,t){this.track(e,t,{sign:"page"})}cpage(e){return this.page("cpage",e)}placeholder(){return null}static build(e){return ExbAnalyticsJS.instance||(ExbAnalyticsJS.instance=new ExbAnalyticsJS(e)),ExbAnalyticsJS.instance}static getInstance(){if(!ExbAnalyticsJS.instance)throw Error("ExbAnalyticsJS instance is not init");return ExbAnalyticsJS.instance}static new(e){return new ExbAnalyticsJS(e)}}const ad_ExbAnalyticsJS=ExbAnalyticsJS;class RewardAdNovel extends ad_RewardAdFather{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=DEFAULT_SCENT_TEXT_OBJ.inner_default_other;_adTimeout=null;_adTimeoutTime=8e3;_adBeforeShowTimer=null;_adBeforeShowTime=300;_adSpeedCloseTimer=null;_adSpeedCloseTime=5e3;_needEndOnTimeout=!0;_needSpeedEndOnTimeout=!1;bindAdCloseLister=this.adCloseLister.bind(this);bindAdErrorLister=this.adErrorLister.bind(this);bindAdLoadLister=this.adLoadLister.bind(this);bindApiAdErrorLister=this.apiAdErrorLister.bind(this);_bindShiftCloseLister=this._shiftCloseLister.bind(this);_bindShiftErrorLister=this._shiftErrorLister.bind(this);constructor(e){super(e),this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._needEndOnTimeout=e?.needEndOnTimeout??!0,this._onHalfway=e?.collection?.onHalfway??null,this._onShow=e?.collection?.onShow??null,this._onFinish=e?.collection?.onFinish??null,this._onAlways=e?.collection?.onAlways??null,this._onError=e?.collection?.onError??null}initialize(e,t){return super.initialize(e,t),this._initAdLister(),this._initNovelConfig(e),this}_initAdLister(){this.onClose(this.bindAdCloseLister),this.onError(this.bindAdErrorLister),this.onLoad(this.bindAdLoadLister),tt.onError(this.bindApiAdErrorLister)}_initNovelConfig(e){this.novelConfig=RewardAdNovelConfig.new({retry:e?.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let t=()=>{tt.offAppShow(t),console.warn("[RewardAdNovel] ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",e?.scene);let r="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:e?.scene,msg:r,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),e?.end({resolvedValue:{apiError:{errMsg:r}},nextValue:null})};tt.onAppShow(t)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{console.warn("[RewardAdNovel] Ad show timeout, handling fallback ad case, scene:",e?.scene),this._adShowFailureAnalytics({scene:e?.scene,msg:"ad_show_timeout: normal",result:0}),e?.end({resolvedValue:{apiError:{errMsg:"ad_show_timeout: normal"}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearTimeout(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowSuccessAnalytics(e){return null}_adShowFailureAnalytics(e){return null}_adLoadSuccessAnalytics(e){return null}_adLoadFailureAnalytics(e){return null}_adCloseSuccessAnalytics(e){return null}get rewardAd(){return this._rewardAd}addExecuteManager(e){return super.addExecuteManager(e)}ad(e,t=null){return this._alwaysCallback=e?.collection?.always,this._halfwayCallback=e?.collection?.halfway,this._finishedCallback=e?.collection?.finished,this._onInnerExecuteBefore(),new Promise(r=>{this._adInner({options:{scene:e?.options?.scene},collection:{resolve:r,before:e.collection?.before,success:e.collection?.success,prelude:e.collection?.prelude}},t)})}_adInner(e,t=null){let r=e?.collection?.resolve,s=e?.options?.scene??this._scene??DEFAULT_SCENT_TEXT_OBJ.inner_default_other,i=e?.collection?.before,n=e?.collection?.success,a=e?.collection?.prelude,o=e=>{this._clearAdTimeout(),this.adDestroy(),r?.(Object.assign({scene:s},e?.resolvedValue)),t?.(Object.assign({scene:s},e?.nextValue))},l=()=>{this._scene=s,i?.({scene:s}),this._before=i,this._onShow?.({scene:s}),ad_RewardAdSceneTriggerManager.getInstance().addSceneType(s),this._resolve=r,this._next=t,this._setAdTimeout({scene:s,end:o}),this._adPreludeInterval({scene:s,prelude:a}),this.adShow().then(()=>{this._clearAdTimeout(),n?.({scene:s}),this._success=n,this._adShowSuccessAnalytics({scene:s,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:s,msg:e?.errMsg,result:0}),matchErrorWithKeywords(this._ttErrorMsgs,e?.errMsg)||this._ttErrorCodes.includes(e?.errorCode))?o({scene:s,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?o({scene:s,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:s,result:1}),l()}).catch(e=>{this._adLoadFailureAnalytics({scene:s,msg:e?.errMsg,result:0}),o({scene:s,resolvedValue:{apiError:e},nextValue:null})}))})};l()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){this._alwaysCallback?.(e)}_outerHalfwayCallback(e){this._halfwayCallback?.(e)}_outerFinishedCallback(e){this._finishedCallback?.(e)}adCloseLister(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let t={...e,scene:this._scene},r=t=>{this.adDestroy(),this._resolve?.(Object.assign({},e,{scene:this._scene},t)),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null};e?.isEnded?(this._outerFinishedCallback(t),this._onFinish?.(t)):(this._outerHalfwayCallback(t),this._onHalfway?.(t)),this._outerCloseCallback(t),this._onAlways?.(t),r({end_type:e.isEnded?"finished":"halfway"})}adErrorLister(e){this._clearAdTimeout(),console.error("[RewardAdNovel] adErrorLister",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){this._clearAdTimeout(),console.error("[API RewardAdNovel] apiAdErrorLister:",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:e?.errMsg}),console.info("[RewardAdNovel] adLoadLister:",JSON.stringify({scene:this._scene,info:e}))}adDestroy(){this.offClose(this.bindAdCloseLister),this.offError(this.bindAdErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy()}clear(){this._clearAdTimeout(),this.offClose(this.bindAdCloseLister),this.offClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){this._clearAdTimeout(),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offClose(this._bindShiftCloseLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){this._clearAdTimeout(),this.offClose(this._bindShiftCloseLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offError(this._bindShiftErrorLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}shift(){this.offClose(this.bindAdCloseLister),this.onClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.onError(this._bindShiftErrorLister)}static build(e){return RewardAdNovel.instance||(RewardAdNovel.instance=new RewardAdNovel(e)),RewardAdNovel.instance}static getInstance(){if(!RewardAdNovel.instance)throw Error("RewardAdNovel instance is not init");return RewardAdNovel.instance}static new(e){return new RewardAdNovel(e)}}class RewardAdNovelConfig{frequency={total:0,current:0};constructor(e){this._init(e)}_init(e){this._adTimes(e)}_adTimes(e){this.frequency.total=e?.retry??4}reset(){this.frequency.current=0}updateRetry(){this.frequency.current=this.frequency.current+1}remain(){return this.frequency.total-this.frequency.current}static new(e){return new RewardAdNovelConfig(e)}}const ad_RewardAdNovel=RewardAdNovel,src=ad_AdExecuteManager;for(var __rspack_i in exports.AdExecuteManager=__webpack_exports__.AdExecuteManager,exports.CountRecorder=__webpack_exports__.CountRecorder,exports.ExbAnalyticsJS=__webpack_exports__.ExbAnalyticsJS,exports.Logger=__webpack_exports__.Logger,exports.RewardAdFather=__webpack_exports__.RewardAdFather,exports.RewardAdGlobalRecorder=__webpack_exports__.RewardAdGlobalRecorder,exports.RewardAdNovel=__webpack_exports__.RewardAdNovel,exports.RewardAdSceneTriggerManager=__webpack_exports__.RewardAdSceneTriggerManager,exports.SerializableError=__webpack_exports__.SerializableError,exports.Storage=__webpack_exports__.Storage,exports.default=__webpack_exports__.default,__webpack_exports__)-1===["AdExecuteManager","CountRecorder","ExbAnalyticsJS","Logger","RewardAdFather","RewardAdGlobalRecorder","RewardAdNovel","RewardAdSceneTriggerManager","SerializableError","Storage","default"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{SerializableError:()=>SerializableError,default:()=>src,InterstitialAdNovel:()=>ad_InterstitialAdNovel,Storage:()=>ad_Storage,ExbAnalyticsJS:()=>ad_ExbAnalyticsJS,CountRecorder:()=>CountRecorder,RewardAdGlobalRecorder:()=>ad_RewardAdGlobalRecorder,RewardAdFather:()=>ad_RewardAdFather,InterstitialAdFather:()=>ad_InterstitialAdFather,Logger:()=>Logger,AdExecuteManager:()=>ad_AdExecuteManager,RewardAdNovel:()=>ad_RewardAdNovel,RewardAdSceneTriggerManager:()=>ad_RewardAdSceneTriggerManager});const compose=e=>e.map(e=>(t,r)=>async i=>await e(Object.assign({},t,i),r)).reduce((e,t)=>(r,i)=>e(r,t(r,i))),ad_compose=compose;class Logger{constructor(e={}){const{prefix:t="Logger",level:r="info",enabled:i=!0}=e;this.prefix=t,this.enabled=i,this.levels={error:0,warn:1,info:2,debug:3},this.currentLevel=this.levels[r]||this.levels.info}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}setLevel(e){Object.prototype.hasOwnProperty.call(this.levels,e)&&(this.currentLevel=this.levels[e])}formatMessage(e,t){let r=new Date,i=`${r.getFullYear()}/${r.getMonth()+1}/${r.getDate()} ${r.getHours()}:${r.getMinutes()}:${r.getSeconds()}`;return`[${i}] [${e.toUpperCase()}] [${this.prefix}] ${t}`}_log(e,t,...r){if(!this.enabled)return;let i=this.levels[e];if(void 0!==i&&this.currentLevel>=i){let i=this.formatMessage(e,t);switch(e){case"error":console.error(i,...r);break;case"warn":console.warn(i,...r);break;case"info":console.info(i,...r);break;case"debug":console.debug(i,...r);break;default:console.log(i,...r)}}}error(e,...t){this._log("error",e,...t)}warn(e,...t){this._log("warn",e,...t)}info(e,...t){this._log("info",e,...t)}debug(e,...t){this._log("debug",e,...t)}log(e,t,...r){this._log(e,t,...r)}}class AdExecuteManager{static _instance=null;_taskStack=[];_currentBatchTasks=[];_isRunning=!1;_currentTask=null;constructor(e){if(this.logger=new Logger({prefix:"AdExecuteManager",enabled:!!e?.log}),AdExecuteManager._instance)return AdExecuteManager._instance;AdExecuteManager._instance=this}static getInstance(e){return AdExecuteManager._instance||(AdExecuteManager._instance=new AdExecuteManager(e)),AdExecuteManager._instance}addTask(e,t){return e&&"function"==typeof e.ad?new Promise((r,i)=>{let s={adInstance:e,options:t.options??{},callbackCollection:t.collection??{},resolve:r,reject:i,id:`ad_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,_isResolved:!1,_isRejected:!1};this._taskStack.push(s),this._isRunning||this._compose()}):(this.logger.error("无效的广告实例 请正确实现.ad方法"),Promise.reject(Error("无效的广告实例")))}_compose(){if(0===this._taskStack.length){this._isRunning=!1,this._currentTask=null;return}this._isRunning=!0;let e=[...this._taskStack];this._taskStack=[],this._currentBatchTasks=e;let t=e.map(e=>async(t,r)=>{let{adInstance:i,options:s,callbackCollection:n,resolve:a,id:l}=e;if(e._isResolved||e._isRejected)return void await r(t);this._currentTask=e;try{let o=async e=>{await r(Object.assign({},t,e))},d=await i.initialize(s).ad({options:s,collection:n},o),h=Object.assign({id:l},d);this.logger.info(`任务执行成功,成功信息:${JSON.stringify(h)}`),e._isResolved=!0,a(h),i?.record(h)}catch(n){let s=Object.assign({id:l,apiError:n});this.logger.error(`任务执行失败, 继续下一个任务,错误信息:${JSON.stringify(s)}`),e._isRejected=!0;try{i?.clear()}catch(e){this.logger.error("clear error: ",JSON.stringify(Object.assign({id:l,apiError:e})))}a(s),i?.record(s),await r(t)}}),r={roundTasks:t.length};compose(t)(r,async e=>{this.logger.info("本轮活动队列已经清空",e),this._taskStack.length>0?Promise.resolve().then(()=>{this._compose()}):(this._isRunning=!1,this._currentTask=null,this._currentBatchTasks=[])})()}clearTasks(){if(this._currentTask){if(this._currentTask._isResolved||this._currentTask._isRejected){this._currentTask=null;return}try{this._currentTask.callbackCollection&&this._currentTask.callbackCollection.onCancel&&this._currentTask.callbackCollection.onCancel(),this._currentTask._isResolved=!0,this._currentTask.resolve()}catch(e){this.logger.error("clear current task error: ",e)}this._currentTask=null}this._currentBatchTasks.length>0&&(this._currentBatchTasks.forEach(e=>{if(e!==this._currentTask&&!e._isResolved&&!e._isRejected)try{e.callbackCollection&&e.callbackCollection.onCancel&&e.callbackCollection.onCancel(),e._isResolved=!0,e.resolve()}catch(e){this.logger.error("clear current batch task error: ",e)}}),this._currentBatchTasks=[]),this._taskStack.forEach(e=>{if(!e._isResolved&&!e._isRejected&&(e._isResolved=!0,e.resolve(),e.callbackCollection&&e.callbackCollection.onCancel))try{e.callbackCollection.onCancel()}catch(e){this.logger.error("clear task error: ",e)}}),this._taskStack=[],this._isRunning=!1}getTaskCount(){return this._taskStack.filter(e=>!e._isResolved&&!e._isRejected).length+this._currentBatchTasks.filter(e=>e!==this._currentTask&&!e._isResolved&&!e._isRejected).length+(!this._currentTask||this._currentTask._isResolved||this._currentTask._isRejected?0:1)}isRunning(){return this._isRunning}getCurrentTaskId(){return this._currentTask?.id||null}}const ad_AdExecuteManager=AdExecuteManager;class SerializableError extends Error{constructor(e){super(e),this.name=this.constructor.name,this.stack=Error(e).stack,Object.defineProperty(this,"message",{enumerable:!0}),Object.defineProperty(this,"name",{enumerable:!0}),Object.defineProperty(this,"stack",{enumerable:!0})}toJSON(){return{name:this.name,message:this.message,stack:this.stack}}}class RewardAdFather{static args=null;_initSign="";_preserveOnEnd=!1;_rewardAd=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];constructor(e){this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._preserveOnEnd=e?.preserveOnEnd??!1}initialize(e,t){if(this._rewardAd)return console.warn("RewardAdFather: rewardAd has been initialized"),t?.(this._rewardAd),this;let r=Object.assign({},RewardAdFather.args,this._adConfig,e);if(!r.adUnitId)throw console.error("[RewardAdFather] reward args adUnitId is required",r),new SerializableError("[RewardAdFather] reward args adUnitId is required");return this._rewardAd=tt.createRewardedVideoAd(r),t?.(this._rewardAd),this}initialized(){return!!this._rewardAd}async ad(e,t=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let t=Object.assign({},this._adConfig,e?.options??{});return RewardAdFather.executeWithManager(this,Object.assign({},e,{options:t}))}destroy(){this._rewardAd&&!this._preserveOnEnd&&(this._rewardAd.destroy(),this._rewardAd=null)}clear(){throw Error("子类必须实现clear方法")}record(e){return this}onClose(e){this._rewardAd&&this._rewardAd.onClose(e)}offClose(e){this._rewardAd&&this._rewardAd.offClose(e)}show(){return this._rewardAd?this._rewardAd.show():Promise.reject({errMsg:"rewardAd is null"})}load(){if(this._rewardAd)return this._rewardAd.load()}onError(e){this._rewardAd&&this._rewardAd.onError(e)}offError(e){this._rewardAd&&this._rewardAd.offError(e)}onLoad(e){this._rewardAd&&this._rewardAd.onLoad(e)}offLoad(e){this._rewardAd&&this._rewardAd.offLoad(e)}placeholder(){return null}static buildArgs(e){e?.adUnitId||console.error("[RewardAdFather] RewardParams.adUnitId is required"),RewardAdFather.args=e}static async executeWithManager(e,t){return e&&e instanceof RewardAdFather?ad_AdExecuteManager.getInstance({log:t?.options?.log??!0}).addTask(e,t):(console.error("RewardAdFather: executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}const ad_RewardAdFather=RewardAdFather;class Storage{constructor(e={}){this.config={prefix:"storage_",expire:null,...e},this.logger=new Logger({prefix:"Storage"})}getTodayEndTimestamp(){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999).getTime()}_setItem(e,t,r){let i=void 0!==r?r:this.config.expire;"today"===i&&(i=this.getTodayEndTimestamp()-Date.now());let s={value:t,expire:i,timestamp:Date.now()};try{tt.setStorageSync(e,JSON.stringify(s))}catch(e){console.error("Storage setItem error:",e)}}_getItem(e){try{let t=tt.getStorageSync(e);if(!t)return null;let r=JSON.parse(t);if(r.expire&&Date.now()-r.timestamp>r.expire)return this.removeItem(e),null;return r.value}catch(e){return console.error("Storage getItem error:",e),null}}setItem(e,t,r){let i=this.config.prefix+e;return this._setItem(i,t,r)}getItem(e){let t=this.config.prefix+e;return this._getItem(t)}getUserItem(e){let t=this.config.userId??"null";if("null"===t)return this.logger.error("userId is required"),null;let r=`${this.config.prefix}_${t}_${e}`;return this._getItem(r)}setUserItem(e,t,r){let i=this.config.userId??"null";if("null"===i)return void this.logger.error("userId is required");let s=`${this.config.prefix}_${i}_${e}`;return this._setItem(s,t,r)}removeItem(e){try{tt.removeStorageSync(e)}catch(e){console.error("Storage removeItem error:",e)}}clear(){try{tt.clearStorageSync()}catch(e){console.error("Storage clear error:",e)}}keys(){try{let e=[];return(tt.getStorageInfoSync().keys??[]).forEach(t=>{if(t.startsWith(this.config.prefix)){let r=JSON.parse(tt.getStorageSync(t));(!r.expire||Date.now()-r.timestamp<=r.expire)&&e.push(t.replace(this.config.prefix,""))}}),e}catch(e){return console.error("Storage keys error:",e),[]}}static new(e){return new Storage(e)}}const ad_Storage=Storage;class CountRecorder{_total=0;_local_sign="";_expire="today";constructor(e){if(this.storage=ad_Storage.new({userId:e.userId}),!e.local_sign)throw Error("local_sign is required");this._local_sign=e.local_sign,this._total=e.total??0,this._expire=e.expire??"today",this._init()}_init(){this._initLocalTimes()}_adTimes(){return this._total}_safeLocalValue(e){return"object"!=typeof e||null===e?{}:e}_initLocalTimes(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),r=this._safeLocalValue(t);r&&r?.total==e||this.storage.setUserItem(this._local_sign,{total:e,today:r?.today??0},this._expire)}updateToday(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),r=this._safeLocalValue(t),i=r?.today??0;this.storage.setUserItem(this._local_sign,{total:e,today:i+1},this._expire)}remain(){let e=this.storage.getUserItem(this._local_sign),t=this._safeLocalValue(e),r=t?.today??0;return Number(t?.total??0)-Number(r)}static new(e){return new CountRecorder(e)}}function matchErrorWithKeywords(e,t){return!!t&&e.some(e=>RegExp(e,"i").test(t))}function findAdTypeBySceneFlag(e,t,r="showTimes"){if(!Array.isArray(e))return console.error("第一个参数必须是数组"),null;let i=e.find(e=>e&&e.adSceneFlag===t);return i?i[r]:null}function getAdSceneTextObj(e){return Object.entries(e).reduce((e,[t,r])=>(e[r]=Number(t),e),{})}const DEFAULT_SCENT_TYPE_OBJ={9999:"inner_default_other"},DEFAULT_SCENT_TEXT_OBJ=getAdSceneTextObj(DEFAULT_SCENT_TYPE_OBJ);class RewardAdGlobalRecorder{static instance=null;_initSign="";_halfway=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}];_finished=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}];constructor(e){if(RewardAdGlobalRecorder.instance)return RewardAdGlobalRecorder.instance;this._initSign=e?.sign??"",this._halfway=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}],this._finished=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}],RewardAdGlobalRecorder.instance=this}initialize(e){}_halfwayUpdate(e){let t=this._halfway.find(t=>t.scene===e.scene);t?t.count+=1:this._halfway.push({scene:e.scene,count:1})}_halfwayGet(e){let t=e?.scenes??[];return(t.length>0?this._halfway.filter(e=>t.includes(e.scene)):this._halfway).reduce((e,t)=>e+t.count,0)}_halfwayReset(){this._halfway=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}]}_finishedUpdate(e){let t=this._finished.find(t=>t.scene===e.scene);t?t.count+=1:this._finished.push({scene:e.scene,count:1})}_finishedGet(e){let t=e?.scenes??[];return(t.length>0?this._finished.filter(e=>t.includes(e.scene)):this._finished).reduce((e,t)=>e+t.count,0)}_finishedReset(){this._finished=[{scene:DEFAULT_SCENT_TEXT_OBJ.inner_default_other,count:0}]}record(e){switch(e.type){case"halfway":this._halfwayUpdate(e);break;case"finished":this._finishedUpdate(e)}}rest(e){switch(e){case"halfway":this._halfwayReset();break;case"finished":this._finishedReset()}}get(e){switch(e.type){case"halfway":return this._halfwayGet(e);case"finished":return this._finishedGet(e);default:return null}}placeholder(){return null}static build(e){return RewardAdGlobalRecorder.instance||(RewardAdGlobalRecorder.instance=new RewardAdGlobalRecorder(e)),RewardAdGlobalRecorder.instance}static getInstance(){if(!RewardAdGlobalRecorder.instance)throw Error("RewardAdGlobalRecorder instance is not init");return RewardAdGlobalRecorder.instance}}const ad_RewardAdGlobalRecorder=RewardAdGlobalRecorder;class RewardAdSceneTriggerManager{static instance=null;_initSign="";_currScene=null;_sceneTypeObj={};constructor(e){if(RewardAdSceneTriggerManager.instance)return RewardAdSceneTriggerManager.instance;this._initSign=e?.sign??"",this._sceneTypeObj=e?.sceneTypeObj??{},RewardAdSceneTriggerManager.instance=this}initialize(e){}addScene(e){return console.log("----------------------AD触发场景:--------------------",e),this._currScene=e,this}addSceneType(e=1){return this.addScene(this._sceneTypeObj[e]),this}getCurrentScene(){return this._currScene}placeholder(){return null}static build(e){return RewardAdSceneTriggerManager.instance||(RewardAdSceneTriggerManager.instance=new RewardAdSceneTriggerManager(e)),RewardAdSceneTriggerManager.instance}static getInstance(){if(!RewardAdSceneTriggerManager.instance)throw Error("RewardAdSceneTriggerManager instance is not init");return RewardAdSceneTriggerManager.instance}}const ad_RewardAdSceneTriggerManager=RewardAdSceneTriggerManager;class ExbAnalyticsJS{static instance=null;_initSign="";_needReport=!1;constructor(e){if(ExbAnalyticsJS.instance)return ExbAnalyticsJS.instance;this._initSign=e?.sign??"",this._needReport=e?.needReport??!1,this._userConfig=e?.userConfig??null,ExbAnalyticsJS.instance=this}initialize(e){return this._needReport?e:void console.warn("ExbAnalyticsJS needReport is false, do not report")}track(e,t,r){if(!this._needReport)return;if(!e)throw Error("eventName is required");let i=Object.assign({},this._getCommonUserInfo(),t),s=r?.sign??"track";console.log(`-------------${s}-----------------------:`,e,i),tt.reportAnalytics(e,i)}_getCommonUserInfo(){let{user_id:e,user_type:t,user_group:r}=this._userConfig??{};return{user_id:e,user_type:t,user_group:r}}identify(e){if(!e)throw Error("userInfo is required");if(!e.user_id)throw Error("user_id is required");return this._userConfig={user_id:e.user_id,user_type:e.user_type??0,user_group:e.user_group??0},this}alias(){return null}pages(){return null}page(e,t){this.track(e,t,{sign:"page"})}cpage(e){return this.page("cpage",e)}placeholder(){return null}static build(e){return ExbAnalyticsJS.instance||(ExbAnalyticsJS.instance=new ExbAnalyticsJS(e)),ExbAnalyticsJS.instance}static getInstance(){if(!ExbAnalyticsJS.instance)throw Error("ExbAnalyticsJS instance is not init");return ExbAnalyticsJS.instance}static new(e){return new ExbAnalyticsJS(e)}}const ad_ExbAnalyticsJS=ExbAnalyticsJS;class RewardAdNovel extends ad_RewardAdFather{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=DEFAULT_SCENT_TEXT_OBJ.inner_default_other;_adTimeout=null;_adTimeoutTime=8e3;_adBeforeShowTimer=null;_adBeforeShowTime=300;_adSpeedCloseTimer=null;_adSpeedCloseTime=5e3;_needEndOnTimeout=!0;_needSpeedEndOnTimeout=!1;bindAdCloseLister=this.adCloseLister.bind(this);bindAdErrorLister=this.adErrorLister.bind(this);bindAdLoadLister=this.adLoadLister.bind(this);bindApiAdErrorLister=this.apiAdErrorLister.bind(this);_bindShiftCloseLister=this._shiftCloseLister.bind(this);_bindShiftErrorLister=this._shiftErrorLister.bind(this);constructor(e){super(e),this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._needEndOnTimeout=e?.needEndOnTimeout??!0,this._onHalfway=e?.collection?.onHalfway??null,this._onShow=e?.collection?.onShow??null,this._onFinish=e?.collection?.onFinish??null,this._onAlways=e?.collection?.onAlways??null,this._onError=e?.collection?.onError??null}initialize(e,t){return super.initialize(e,t),this._initAdLister(),this._initNovelConfig(e),this}_initAdLister(){this.onClose(this.bindAdCloseLister),this.onError(this.bindAdErrorLister),this.onLoad(this.bindAdLoadLister),tt.onError(this.bindApiAdErrorLister)}_initNovelConfig(e){this.novelConfig=RewardAdNovelConfig.new({retry:e?.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let t=()=>{tt.offAppShow(t),console.warn("[RewardAdNovel] ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",e?.scene);let r="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:e?.scene,msg:r,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),e?.end({resolvedValue:{apiError:{errMsg:r}},nextValue:null})};tt.onAppShow(t)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{console.warn("[RewardAdNovel] Ad show timeout, handling fallback ad case, scene:",e?.scene),this._adShowFailureAnalytics({scene:e?.scene,msg:"ad_show_timeout: normal",result:0}),e?.end({resolvedValue:{apiError:{errMsg:"ad_show_timeout: normal"}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearTimeout(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowSuccessAnalytics(e){return null}_adShowFailureAnalytics(e){return null}_adLoadSuccessAnalytics(e){return null}_adLoadFailureAnalytics(e){return null}_adCloseSuccessAnalytics(e){return null}get rewardAd(){return this._rewardAd}addExecuteManager(e){return super.addExecuteManager(e)}ad(e,t=null){return this._alwaysCallback=e?.collection?.always,this._halfwayCallback=e?.collection?.halfway,this._finishedCallback=e?.collection?.finished,this._onInnerExecuteBefore(),new Promise(r=>{this._adInner({options:{scene:e?.options?.scene},collection:{resolve:r,before:e.collection?.before,success:e.collection?.success,prelude:e.collection?.prelude}},t)})}_adInner(e,t=null){let r=e?.collection?.resolve,i=e?.options?.scene??this._scene??DEFAULT_SCENT_TEXT_OBJ.inner_default_other,s=e?.collection?.before,n=e?.collection?.success,a=e?.collection?.prelude,l=e=>{this._clearAdTimeout(),this.adDestroy(),r?.(Object.assign({scene:i},e?.resolvedValue)),t?.(Object.assign({scene:i},e?.nextValue))},o=()=>{this._scene=i,s?.({scene:i}),this._before=s,this._onShow?.({scene:i}),ad_RewardAdSceneTriggerManager.getInstance().addSceneType(i),this._resolve=r,this._next=t,this._setAdTimeout({scene:i,end:l}),this._adPreludeInterval({scene:i,prelude:a}),this.adShow().then(()=>{this._clearAdTimeout(),n?.({scene:i}),this._success=n,this._adShowSuccessAnalytics({scene:i,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:i,msg:e?.errMsg,result:0}),matchErrorWithKeywords(this._ttErrorMsgs,e?.errMsg)||this._ttErrorCodes.includes(e?.errorCode))?l({scene:i,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?l({scene:i,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:i,result:1}),o()}).catch(e=>{this._adLoadFailureAnalytics({scene:i,msg:e?.errMsg,result:0}),l({scene:i,resolvedValue:{apiError:e},nextValue:null})}))})};o()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){this._alwaysCallback?.(e)}_outerHalfwayCallback(e){this._halfwayCallback?.(e)}_outerFinishedCallback(e){this._finishedCallback?.(e)}adCloseLister(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let t={...e,scene:this._scene},r=t=>{this.adDestroy(),this._resolve?.(Object.assign({},e,{scene:this._scene},t)),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null};e?.isEnded?(this._outerFinishedCallback(t),this._onFinish?.(t)):(this._outerHalfwayCallback(t),this._onHalfway?.(t)),this._outerCloseCallback(t),this._onAlways?.(t),r({end_type:e.isEnded?"finished":"halfway"})}adErrorLister(e){this._clearAdTimeout(),console.error("[RewardAdNovel] adErrorLister",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){this._clearAdTimeout(),console.error("[API RewardAdNovel] apiAdErrorLister:",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:e?.errMsg}),console.info("[RewardAdNovel] adLoadLister:",JSON.stringify({scene:this._scene,info:e}))}adDestroy(){this.offClose(this.bindAdCloseLister),this.offError(this.bindAdErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy()}clear(){this._clearAdTimeout(),this.offClose(this.bindAdCloseLister),this.offClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){this._clearAdTimeout(),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offClose(this._bindShiftCloseLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){this._clearAdTimeout(),this.offClose(this._bindShiftCloseLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offError(this._bindShiftErrorLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}shift(){this.offClose(this.bindAdCloseLister),this.onClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.onError(this._bindShiftErrorLister)}static build(e){return RewardAdNovel.instance||(RewardAdNovel.instance=new RewardAdNovel(e)),RewardAdNovel.instance}static getInstance(){if(!RewardAdNovel.instance)throw Error("RewardAdNovel instance is not init");return RewardAdNovel.instance}static new(e){return new RewardAdNovel(e)}}class RewardAdNovelConfig{frequency={total:0,current:0};constructor(e){this._init(e)}_init(e){this._adTimes(e)}_adTimes(e){this.frequency.total=e?.retry??4}reset(){this.frequency.current=0}updateRetry(){this.frequency.current=this.frequency.current+1}remain(){return this.frequency.total-this.frequency.current}static new(e){return new RewardAdNovelConfig(e)}}const ad_RewardAdNovel=RewardAdNovel;class InterstitialAdFather{static args=null;_initSign="";_preserveOnEnd=!1;_interstitialAd=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];constructor(e){this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._preserveOnEnd=e?.preserveOnEnd??!1}initialize(e,t){if(this._interstitialAd)return console.warn("InterstitialAdFather: interstitialAd has been initialized"),t?.(this._interstitialAd),this;let r=Object.assign({},InterstitialAdFather.args,this._adConfig,e);if(!r.adUnitId)throw console.error("[InterstitialAdFather] interstitialAd args adUnitId is required",r),new SerializableError("[InterstitialAdFather] interstitialAd args adUnitId is required");return this._interstitialAd=tt.createInterstitialAd(r),t?.(this._interstitialAd),this}initialized(){return!!this._interstitialAd}async ad(e,t=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let t=Object.assign({},this._adConfig,e?.options??{});return InterstitialAdFather.executeWithManager(this,Object.assign({},e,{options:t}))}destroy(){this._interstitialAd&&!this._preserveOnEnd&&(this._interstitialAd.destroy(),this._interstitialAd=null)}clear(){throw Error("子类必须实现clear方法")}record(e){return this}onClose(e){this._interstitialAd&&this._interstitialAd.onClose(e)}offClose(e){this._interstitialAd&&this._interstitialAd.offClose(e)}show(){return this._interstitialAd?this._interstitialAd.show():Promise.reject({errMsg:"interstitialAd is null"})}load(){if(this._interstitialAd)return this._interstitialAd.load()}onError(e){this._interstitialAd&&this._interstitialAd.onError(e)}offError(e){this._interstitialAd&&this._interstitialAd.offError(e)}onLoad(e){this._interstitialAd&&this._interstitialAd.onLoad(e)}offLoad(e){this._interstitialAd&&this._interstitialAd.offLoad(e)}placeholder(){return null}static buildArgs(e){e?.adUnitId||console.error("[InterstitialAdFather] interstitialAdParams.adUnitId is required"),InterstitialAdFather.args=e}static async executeWithManager(e,t){return e&&e instanceof InterstitialAdFather?ad_AdExecuteManager.getInstance({log:t?.options?.log??!0}).addTask(e,t):(console.error("InterstitialAdFather: executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}const ad_InterstitialAdFather=InterstitialAdFather;class InterstitialAdNovel extends ad_InterstitialAdFather{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=DEFAULT_SCENT_TEXT_OBJ.inner_default_other;_adTimeout=null;_adTimeoutTime=8e3;_adBeforeShowTimer=null;_adBeforeShowTime=300;_adSpeedCloseTimer=null;_adSpeedCloseTime=5e3;_needEndOnTimeout=!0;_needSpeedEndOnTimeout=!1;bindAdCloseLister=this.adCloseLister.bind(this);bindAdErrorLister=this.adErrorLister.bind(this);bindAdLoadLister=this.adLoadLister.bind(this);bindApiAdErrorLister=this.apiAdErrorLister.bind(this);_bindShiftCloseLister=this._shiftCloseLister.bind(this);_bindShiftErrorLister=this._shiftErrorLister.bind(this);constructor(e){super(e),this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._needEndOnTimeout=e?.needEndOnTimeout??!0,this._onHalfway=e?.collection?.onHalfway??null,this._onShow=e?.collection?.onShow??null,this._onFinish=e?.collection?.onFinish??null,this._onAlways=e?.collection?.onAlways??null,this._onError=e?.collection?.onError??null}initialize(e,t){return super.initialize(e,t),this._initAdLister(),this._initNovelConfig(e),this}_initAdLister(){this.onClose(this.bindAdCloseLister),this.onError(this.bindAdErrorLister),this.onLoad(this.bindAdLoadLister),tt.onError(this.bindApiAdErrorLister)}_initNovelConfig(e){this.novelConfig=InterstitialAdNovel_RewardAdNovelConfig.new({retry:e?.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let t=()=>{tt.offAppShow(t),console.warn("[InterstitialAdNovel] ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",e?.scene);let r="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:e?.scene,msg:r,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),e?.end({resolvedValue:{apiError:{errMsg:r}},nextValue:null})};tt.onAppShow(t)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{console.warn("[InterstitialAdNovel] Ad show timeout, handling fallback ad case, scene:",e?.scene),this._adShowFailureAnalytics({scene:e?.scene,msg:"ad_show_timeout: normal",result:0}),e?.end({resolvedValue:{apiError:{errMsg:"ad_show_timeout: normal"}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearTimeout(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowSuccessAnalytics(e){return null}_adShowFailureAnalytics(e){return null}_adLoadSuccessAnalytics(e){return null}_adLoadFailureAnalytics(e){return null}_adCloseSuccessAnalytics(e){return null}get rewardAd(){return this._rewardAd}addExecuteManager(e){return super.addExecuteManager(e)}ad(e,t=null){return this._alwaysCallback=e?.collection?.always,this._halfwayCallback=e?.collection?.halfway,this._finishedCallback=e?.collection?.finished,this._onInnerExecuteBefore(),new Promise(r=>{this._adInner({options:{scene:e?.options?.scene},collection:{resolve:r,before:e.collection?.before,success:e.collection?.success,prelude:e.collection?.prelude}},t)})}_adInner(e,t=null){let r=e?.collection?.resolve,i=e?.options?.scene??this._scene??DEFAULT_SCENT_TEXT_OBJ.inner_default_other,s=e?.collection?.before,n=e?.collection?.success,a=e?.collection?.prelude,l=e=>{this._clearAdTimeout(),this.adDestroy(),r?.(Object.assign({scene:i},e?.resolvedValue)),t?.(Object.assign({scene:i},e?.nextValue))},o=()=>{this._scene=i,s?.({scene:i}),this._before=s,this._onShow?.({scene:i}),this._resolve=r,this._next=t,this._setAdTimeout({scene:i,end:l}),this._adPreludeInterval({scene:i,prelude:a}),this.adShow().then(()=>{this._clearAdTimeout(),n?.({scene:i}),this._success=n,this._adShowSuccessAnalytics({scene:i,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:i,msg:e?.errMsg,result:0}),matchErrorWithKeywords(this._ttErrorMsgs,e?.errMsg)||this._ttErrorCodes.includes(e?.errorCode))?l({scene:i,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?l({scene:i,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:i,result:1}),o()}).catch(e=>{this._adLoadFailureAnalytics({scene:i,msg:e?.errMsg,result:0}),l({scene:i,resolvedValue:{apiError:e},nextValue:null})}))})};o()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){this._alwaysCallback?.(e)}_outerHalfwayCallback(e){this._halfwayCallback?.(e)}_outerFinishedCallback(e){this._finishedCallback?.(e)}adCloseLister(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let t={...e,scene:this._scene},r=t=>{this.adDestroy(),this._resolve?.(Object.assign({},e,{scene:this._scene},t)),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null};e?.isEnded?(this._outerFinishedCallback(t),this._onFinish?.(t)):(this._outerHalfwayCallback(t),this._onHalfway?.(t)),this._outerCloseCallback(t),this._onAlways?.(t),r({end_type:e.isEnded?"finished":"halfway"})}adErrorLister(e){this._clearAdTimeout(),console.error("[InterstitialAdNovel] adErrorLister",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){this._clearAdTimeout(),console.error("[API InterstitialAdNovel] apiAdErrorLister:",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:e?.errMsg}),console.info("[InterstitialAdNovel] adLoadLister:",JSON.stringify({scene:this._scene,info:e}))}adDestroy(){this.offClose(this.bindAdCloseLister),this.offError(this.bindAdErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy()}clear(){this._clearAdTimeout(),this.offClose(this.bindAdCloseLister),this.offClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){this._clearAdTimeout(),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offClose(this._bindShiftCloseLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){this._clearAdTimeout(),this.offClose(this._bindShiftCloseLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offError(this._bindShiftErrorLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}shift(){this.offClose(this.bindAdCloseLister),this.onClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.onError(this._bindShiftErrorLister)}static build(e){return InterstitialAdNovel.instance||(InterstitialAdNovel.instance=new InterstitialAdNovel(e)),InterstitialAdNovel.instance}static getInstance(){if(!InterstitialAdNovel.instance)throw Error("InterstitialAdNovel instance is not init");return InterstitialAdNovel.instance}static new(e){return new InterstitialAdNovel(e)}}class InterstitialAdNovel_RewardAdNovelConfig{frequency={total:0,current:0};constructor(e){this._init(e)}_init(e){this._adTimes(e)}_adTimes(e){this.frequency.total=e?.retry??4}reset(){this.frequency.current=0}updateRetry(){this.frequency.current=this.frequency.current+1}remain(){return this.frequency.total-this.frequency.current}static new(e){return new InterstitialAdNovel_RewardAdNovelConfig(e)}}const ad_InterstitialAdNovel=InterstitialAdNovel,src=ad_AdExecuteManager;for(var __rspack_i in exports.AdExecuteManager=__webpack_exports__.AdExecuteManager,exports.CountRecorder=__webpack_exports__.CountRecorder,exports.ExbAnalyticsJS=__webpack_exports__.ExbAnalyticsJS,exports.InterstitialAdFather=__webpack_exports__.InterstitialAdFather,exports.InterstitialAdNovel=__webpack_exports__.InterstitialAdNovel,exports.Logger=__webpack_exports__.Logger,exports.RewardAdFather=__webpack_exports__.RewardAdFather,exports.RewardAdGlobalRecorder=__webpack_exports__.RewardAdGlobalRecorder,exports.RewardAdNovel=__webpack_exports__.RewardAdNovel,exports.RewardAdSceneTriggerManager=__webpack_exports__.RewardAdSceneTriggerManager,exports.SerializableError=__webpack_exports__.SerializableError,exports.Storage=__webpack_exports__.Storage,exports.default=__webpack_exports__.default,__webpack_exports__)-1===["AdExecuteManager","CountRecorder","ExbAnalyticsJS","InterstitialAdFather","InterstitialAdNovel","Logger","RewardAdFather","RewardAdGlobalRecorder","RewardAdNovel","RewardAdSceneTriggerManager","SerializableError","Storage","default"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,6 @@ import RewardAdGlobalRecorder from './ad/RewardAdGlobalRecorder';
|
|
|
9
9
|
import RewardAdSceneTriggerManager from './ad/RewardAdSceneTriggerManager';
|
|
10
10
|
import ExbAnalyticsJS from './ad/ExbAnalyticsJS';
|
|
11
11
|
import RewardAdNovel from './ad/RewardAdNovel';
|
|
12
|
-
|
|
12
|
+
import InterstitialAdFather from './ad/InterstitialAdFather';
|
|
13
|
+
import InterstitialAdNovel from './ad/InterstitialAdNovel';
|
|
14
|
+
export { AdExecuteManager, RewardAdFather, SerializableError, Logger, Storage, CountRecorder, RewardAdGlobalRecorder, RewardAdSceneTriggerManager, ExbAnalyticsJS, RewardAdNovel, InterstitialAdFather, InterstitialAdNovel };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class e{constructor(e={}){let{prefix:t="Logger",level:s="info",enabled:r=!0}=e;this.prefix=t,this.enabled=r,this.levels={error:0,warn:1,info:2,debug:3},this.currentLevel=this.levels[s]||this.levels.info}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}setLevel(e){Object.prototype.hasOwnProperty.call(this.levels,e)&&(this.currentLevel=this.levels[e])}formatMessage(e,t){let s=new Date,r=`${s.getFullYear()}/${s.getMonth()+1}/${s.getDate()} ${s.getHours()}:${s.getMinutes()}:${s.getSeconds()}`;return`[${r}] [${e.toUpperCase()}] [${this.prefix}] ${t}`}_log(e,t,...s){if(!this.enabled)return;let r=this.levels[e];if(void 0!==r&&this.currentLevel>=r){let r=this.formatMessage(e,t);switch(e){case"error":console.error(r,...s);break;case"warn":console.warn(r,...s);break;case"info":console.info(r,...s);break;case"debug":console.debug(r,...s);break;default:console.log(r,...s)}}}error(e,...t){this._log("error",e,...t)}warn(e,...t){this._log("warn",e,...t)}info(e,...t){this._log("info",e,...t)}debug(e,...t){this._log("debug",e,...t)}log(e,t,...s){this._log(e,t,...s)}}class t{static _instance=null;_taskStack=[];_currentBatchTasks=[];_isRunning=!1;_currentTask=null;constructor(s){if(this.logger=new e({prefix:"AdExecuteManager",enabled:!!s?.log}),t._instance)return t._instance;t._instance=this}static getInstance(e){return t._instance||(t._instance=new t(e)),t._instance}addTask(e,t){return e&&"function"==typeof e.ad?new Promise((s,r)=>{let i={adInstance:e,options:t.options??{},callbackCollection:t.collection??{},resolve:s,reject:r,id:`ad_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,_isResolved:!1,_isRejected:!1};this._taskStack.push(i),this._isRunning||this._compose()}):(this.logger.error("无效的广告实例 请正确实现.ad方法"),Promise.reject(Error("无效的广告实例")))}_compose(){if(0===this._taskStack.length){this._isRunning=!1,this._currentTask=null;return}this._isRunning=!0;let e=[...this._taskStack];this._taskStack=[],this._currentBatchTasks=e;let t=e.map(e=>async(t,s)=>{let{adInstance:r,options:i,callbackCollection:n,resolve:a,id:l}=e;if(e._isResolved||e._isRejected)return void await s(t);this._currentTask=e;try{let o=async e=>{await s(Object.assign({},t,e))},h=await r.initialize(i).ad({options:i,collection:n},o),c=Object.assign({id:l},h);this.logger.info(`任务执行成功,成功信息:${JSON.stringify(c)}`),e._isResolved=!0,a(c),r?.record(c)}catch(n){let i=Object.assign({id:l,apiError:n});this.logger.error(`任务执行失败, 继续下一个任务,错误信息:${JSON.stringify(i)}`),e._isRejected=!0;try{r?.clear()}catch(e){this.logger.error("clear error: ",JSON.stringify(Object.assign({id:l,apiError:e})))}a(i),r?.record(i),await s(t)}}),s={roundTasks:t.length};t.map(e=>(t,s)=>async r=>await e(Object.assign({},t,r),s)).reduce((e,t)=>(s,r)=>e(s,t(s,r)))(s,async e=>{this.logger.info("本轮活动队列已经清空",e),this._taskStack.length>0?Promise.resolve().then(()=>{this._compose()}):(this._isRunning=!1,this._currentTask=null,this._currentBatchTasks=[])})()}clearTasks(){if(this._currentTask){if(this._currentTask._isResolved||this._currentTask._isRejected){this._currentTask=null;return}try{this._currentTask.callbackCollection&&this._currentTask.callbackCollection.onCancel&&this._currentTask.callbackCollection.onCancel(),this._currentTask._isResolved=!0,this._currentTask.resolve()}catch(e){this.logger.error("clear current task error: ",e)}this._currentTask=null}this._currentBatchTasks.length>0&&(this._currentBatchTasks.forEach(e=>{if(e!==this._currentTask&&!e._isResolved&&!e._isRejected)try{e.callbackCollection&&e.callbackCollection.onCancel&&e.callbackCollection.onCancel(),e._isResolved=!0,e.resolve()}catch(e){this.logger.error("clear current batch task error: ",e)}}),this._currentBatchTasks=[]),this._taskStack.forEach(e=>{if(!e._isResolved&&!e._isRejected&&(e._isResolved=!0,e.resolve(),e.callbackCollection&&e.callbackCollection.onCancel))try{e.callbackCollection.onCancel()}catch(e){this.logger.error("clear task error: ",e)}}),this._taskStack=[],this._isRunning=!1}getTaskCount(){return this._taskStack.filter(e=>!e._isResolved&&!e._isRejected).length+this._currentBatchTasks.filter(e=>e!==this._currentTask&&!e._isResolved&&!e._isRejected).length+(!this._currentTask||this._currentTask._isResolved||this._currentTask._isRejected?0:1)}isRunning(){return this._isRunning}getCurrentTaskId(){return this._currentTask?.id||null}}let s=t;class r extends Error{constructor(e){super(e),this.name=this.constructor.name,this.stack=Error(e).stack,Object.defineProperty(this,"message",{enumerable:!0}),Object.defineProperty(this,"name",{enumerable:!0}),Object.defineProperty(this,"stack",{enumerable:!0})}toJSON(){return{name:this.name,message:this.message,stack:this.stack}}}class i{static args=null;_initSign="";_preserveOnEnd=!1;_rewardAd=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];constructor(e){this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._preserveOnEnd=e?.preserveOnEnd??!1}initialize(e,t){if(this._rewardAd)return console.warn("RewardAdFather: rewardAd has been initialized"),t?.(this._rewardAd),this;let s=Object.assign({},i.args,this._adConfig,e);if(!s.adUnitId)throw console.error("[RewardAdFather] reward args adUnitId is required",s),new r("[RewardAdFather] reward args adUnitId is required");return this._rewardAd=tt.createRewardedVideoAd(s),t?.(this._rewardAd),this}initialized(){return!!this._rewardAd}async ad(e,t=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let t=Object.assign({},this._adConfig,e?.options??{});return i.executeWithManager(this,Object.assign({},e,{options:t}))}destroy(){this._rewardAd&&!this._preserveOnEnd&&(this._rewardAd.destroy(),this._rewardAd=null)}clear(){throw Error("子类必须实现clear方法")}record(e){return this}onClose(e){this._rewardAd&&this._rewardAd.onClose(e)}offClose(e){this._rewardAd&&this._rewardAd.offClose(e)}show(){return this._rewardAd?this._rewardAd.show():Promise.reject({errMsg:"rewardAd is null"})}load(){if(this._rewardAd)return this._rewardAd.load()}onError(e){this._rewardAd&&this._rewardAd.onError(e)}offError(e){this._rewardAd&&this._rewardAd.offError(e)}onLoad(e){this._rewardAd&&this._rewardAd.onLoad(e)}offLoad(e){this._rewardAd&&this._rewardAd.offLoad(e)}placeholder(){return null}static buildArgs(e){e?.adUnitId||console.error("[RewardAdFather] RewardParams.adUnitId is required"),i.args=e}static async executeWithManager(e,t){return e&&e instanceof i?s.getInstance({log:t?.options?.log??!0}).addTask(e,t):(console.error("RewardAdFather: executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}let n=i;class a{constructor(t={}){this.config={prefix:"storage_",expire:null,...t},this.logger=new e({prefix:"Storage"})}getTodayEndTimestamp(){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999).getTime()}_setItem(e,t,s){let r=void 0!==s?s:this.config.expire;"today"===r&&(r=this.getTodayEndTimestamp()-Date.now());let i={value:t,expire:r,timestamp:Date.now()};try{tt.setStorageSync(e,JSON.stringify(i))}catch(e){console.error("Storage setItem error:",e)}}_getItem(e){try{let t=tt.getStorageSync(e);if(!t)return null;let s=JSON.parse(t);if(s.expire&&Date.now()-s.timestamp>s.expire)return this.removeItem(e),null;return s.value}catch(e){return console.error("Storage getItem error:",e),null}}setItem(e,t,s){let r=this.config.prefix+e;return this._setItem(r,t,s)}getItem(e){let t=this.config.prefix+e;return this._getItem(t)}getUserItem(e){let t=this.config.userId??"null";if("null"===t)return this.logger.error("userId is required"),null;let s=`${this.config.prefix}_${t}_${e}`;return this._getItem(s)}setUserItem(e,t,s){let r=this.config.userId??"null";if("null"===r)return void this.logger.error("userId is required");let i=`${this.config.prefix}_${r}_${e}`;return this._setItem(i,t,s)}removeItem(e){try{tt.removeStorageSync(e)}catch(e){console.error("Storage removeItem error:",e)}}clear(){try{tt.clearStorageSync()}catch(e){console.error("Storage clear error:",e)}}keys(){try{let e=[];return(tt.getStorageInfoSync().keys??[]).forEach(t=>{if(t.startsWith(this.config.prefix)){let s=JSON.parse(tt.getStorageSync(t));(!s.expire||Date.now()-s.timestamp<=s.expire)&&e.push(t.replace(this.config.prefix,""))}}),e}catch(e){return console.error("Storage keys error:",e),[]}}static new(e){return new a(e)}}let l=a;class o{_total=0;_local_sign="";_expire="today";constructor(e){if(this.storage=l.new({userId:e.userId}),!e.local_sign)throw Error("local_sign is required");this._local_sign=e.local_sign,this._total=e.total??0,this._expire=e.expire??"today",this._init()}_init(){this._initLocalTimes()}_adTimes(){return this._total}_safeLocalValue(e){return"object"!=typeof e||null===e?{}:e}_initLocalTimes(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),s=this._safeLocalValue(t);s&&s?.total==e||this.storage.setUserItem(this._local_sign,{total:e,today:s?.today??0},this._expire)}updateToday(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),s=this._safeLocalValue(t),r=s?.today??0;this.storage.setUserItem(this._local_sign,{total:e,today:r+1},this._expire)}remain(){let e=this.storage.getUserItem(this._local_sign),t=this._safeLocalValue(e),s=t?.today??0;return Number(t?.total??0)-Number(s)}static new(e){return new o(e)}}let h=Object.entries({9999:"inner_default_other"}).reduce((e,[t,s])=>(e[s]=Number(t),e),{});class c{static instance=null;_initSign="";_halfway=[{scene:h.inner_default_other,count:0}];_finished=[{scene:h.inner_default_other,count:0}];constructor(e){if(c.instance)return c.instance;this._initSign=e?.sign??"",this._halfway=[{scene:h.inner_default_other,count:0}],this._finished=[{scene:h.inner_default_other,count:0}],c.instance=this}initialize(e){}_halfwayUpdate(e){let t=this._halfway.find(t=>t.scene===e.scene);t?t.count+=1:this._halfway.push({scene:e.scene,count:1})}_halfwayGet(e){let t=e?.scenes??[];return(t.length>0?this._halfway.filter(e=>t.includes(e.scene)):this._halfway).reduce((e,t)=>e+t.count,0)}_halfwayReset(){this._halfway=[{scene:h.inner_default_other,count:0}]}_finishedUpdate(e){let t=this._finished.find(t=>t.scene===e.scene);t?t.count+=1:this._finished.push({scene:e.scene,count:1})}_finishedGet(e){let t=e?.scenes??[];return(t.length>0?this._finished.filter(e=>t.includes(e.scene)):this._finished).reduce((e,t)=>e+t.count,0)}_finishedReset(){this._finished=[{scene:h.inner_default_other,count:0}]}record(e){switch(e.type){case"halfway":this._halfwayUpdate(e);break;case"finished":this._finishedUpdate(e)}}rest(e){switch(e){case"halfway":this._halfwayReset();break;case"finished":this._finishedReset()}}get(e){switch(e.type){case"halfway":return this._halfwayGet(e);case"finished":return this._finishedGet(e);default:return null}}placeholder(){return null}static build(e){return c.instance||(c.instance=new c(e)),c.instance}static getInstance(){if(!c.instance)throw Error("RewardAdGlobalRecorder instance is not init");return c.instance}}let d=c;class u{static instance=null;_initSign="";_currScene=null;_sceneTypeObj={};constructor(e){if(u.instance)return u.instance;this._initSign=e?.sign??"",this._sceneTypeObj=e?.sceneTypeObj??{},u.instance=this}initialize(e){}addScene(e){return console.log("----------------------AD触发场景:--------------------",e),this._currScene=e,this}addSceneType(e=1){return this.addScene(this._sceneTypeObj[e]),this}getCurrentScene(){return this._currScene}placeholder(){return null}static build(e){return u.instance||(u.instance=new u(e)),u.instance}static getInstance(){if(!u.instance)throw Error("RewardAdSceneTriggerManager instance is not init");return u.instance}}let _=u;class f{static instance=null;_initSign="";_needReport=!1;constructor(e){if(f.instance)return f.instance;this._initSign=e?.sign??"",this._needReport=e?.needReport??!1,this._userConfig=e?.userConfig??null,f.instance=this}initialize(e){return this._needReport?e:void console.warn("ExbAnalyticsJS needReport is false, do not report")}track(e,t,s){if(!this._needReport)return;if(!e)throw Error("eventName is required");let r=Object.assign({},this._getCommonUserInfo(),t),i=s?.sign??"track";console.log(`-------------${i}-----------------------:`,e,r),tt.reportAnalytics(e,r)}_getCommonUserInfo(){let{user_id:e,user_type:t,user_group:s}=this._userConfig??{};return{user_id:e,user_type:t,user_group:s}}identify(e){if(!e)throw Error("userInfo is required");if(!e.user_id)throw Error("user_id is required");return this._userConfig={user_id:e.user_id,user_type:e.user_type??0,user_group:e.user_group??0},this}alias(){return null}pages(){return null}page(e,t){this.track(e,t,{sign:"page"})}cpage(e){return this.page("cpage",e)}placeholder(){return null}static build(e){return f.instance||(f.instance=new f(e)),f.instance}static getInstance(){if(!f.instance)throw Error("ExbAnalyticsJS instance is not init");return f.instance}static new(e){return new f(e)}}let g=f;class w extends n{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=h.inner_default_other;_adTimeout=null;_adTimeoutTime=8e3;_adBeforeShowTimer=null;_adBeforeShowTime=300;_adSpeedCloseTimer=null;_adSpeedCloseTime=5e3;_needEndOnTimeout=!0;_needSpeedEndOnTimeout=!1;bindAdCloseLister=this.adCloseLister.bind(this);bindAdErrorLister=this.adErrorLister.bind(this);bindAdLoadLister=this.adLoadLister.bind(this);bindApiAdErrorLister=this.apiAdErrorLister.bind(this);_bindShiftCloseLister=this._shiftCloseLister.bind(this);_bindShiftErrorLister=this._shiftErrorLister.bind(this);constructor(e){super(e),this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._needEndOnTimeout=e?.needEndOnTimeout??!0,this._onHalfway=e?.collection?.onHalfway??null,this._onShow=e?.collection?.onShow??null,this._onFinish=e?.collection?.onFinish??null,this._onAlways=e?.collection?.onAlways??null,this._onError=e?.collection?.onError??null}initialize(e,t){return super.initialize(e,t),this._initAdLister(),this._initNovelConfig(e),this}_initAdLister(){this.onClose(this.bindAdCloseLister),this.onError(this.bindAdErrorLister),this.onLoad(this.bindAdLoadLister),tt.onError(this.bindApiAdErrorLister)}_initNovelConfig(e){this.novelConfig=y.new({retry:e?.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let t=()=>{tt.offAppShow(t),console.warn("[RewardAdNovel] ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",e?.scene);let s="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:e?.scene,msg:s,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),e?.end({resolvedValue:{apiError:{errMsg:s}},nextValue:null})};tt.onAppShow(t)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{console.warn("[RewardAdNovel] Ad show timeout, handling fallback ad case, scene:",e?.scene),this._adShowFailureAnalytics({scene:e?.scene,msg:"ad_show_timeout: normal",result:0}),e?.end({resolvedValue:{apiError:{errMsg:"ad_show_timeout: normal"}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearTimeout(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowSuccessAnalytics(e){return null}_adShowFailureAnalytics(e){return null}_adLoadSuccessAnalytics(e){return null}_adLoadFailureAnalytics(e){return null}_adCloseSuccessAnalytics(e){return null}get rewardAd(){return this._rewardAd}addExecuteManager(e){return super.addExecuteManager(e)}ad(e,t=null){return this._alwaysCallback=e?.collection?.always,this._halfwayCallback=e?.collection?.halfway,this._finishedCallback=e?.collection?.finished,this._onInnerExecuteBefore(),new Promise(s=>{this._adInner({options:{scene:e?.options?.scene},collection:{resolve:s,before:e.collection?.before,success:e.collection?.success,prelude:e.collection?.prelude}},t)})}_adInner(e,t=null){let s=e?.collection?.resolve,r=e?.options?.scene??this._scene??h.inner_default_other,i=e?.collection?.before,n=e?.collection?.success,a=e?.collection?.prelude,l=e=>{this._clearAdTimeout(),this.adDestroy(),s?.(Object.assign({scene:r},e?.resolvedValue)),t?.(Object.assign({scene:r},e?.nextValue))},o=()=>{this._scene=r,i?.({scene:r}),this._before=i,this._onShow?.({scene:r}),_.getInstance().addSceneType(r),this._resolve=s,this._next=t,this._setAdTimeout({scene:r,end:l}),this._adPreludeInterval({scene:r,prelude:a}),this.adShow().then(()=>{this._clearAdTimeout(),n?.({scene:r}),this._success=n,this._adShowSuccessAnalytics({scene:r,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{var t,s;(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:r,msg:e?.errMsg,result:0}),t=this._ttErrorMsgs,(s=e?.errMsg)&&t.some(e=>RegExp(e,"i").test(s))||this._ttErrorCodes.includes(e?.errorCode))?l({scene:r,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?l({scene:r,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:r,result:1}),o()}).catch(e=>{this._adLoadFailureAnalytics({scene:r,msg:e?.errMsg,result:0}),l({scene:r,resolvedValue:{apiError:e},nextValue:null})}))})};o()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){this._alwaysCallback?.(e)}_outerHalfwayCallback(e){this._halfwayCallback?.(e)}_outerFinishedCallback(e){this._finishedCallback?.(e)}adCloseLister(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let t={...e,scene:this._scene},s=t=>{this.adDestroy(),this._resolve?.(Object.assign({},e,{scene:this._scene},t)),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null};e?.isEnded?(this._outerFinishedCallback(t),this._onFinish?.(t)):(this._outerHalfwayCallback(t),this._onHalfway?.(t)),this._outerCloseCallback(t),this._onAlways?.(t),s({end_type:e.isEnded?"finished":"halfway"})}adErrorLister(e){this._clearAdTimeout(),console.error("[RewardAdNovel] adErrorLister",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){this._clearAdTimeout(),console.error("[API RewardAdNovel] apiAdErrorLister:",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:e?.errMsg}),console.info("[RewardAdNovel] adLoadLister:",JSON.stringify({scene:this._scene,info:e}))}adDestroy(){this.offClose(this.bindAdCloseLister),this.offError(this.bindAdErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy()}clear(){this._clearAdTimeout(),this.offClose(this.bindAdCloseLister),this.offClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){this._clearAdTimeout(),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offClose(this._bindShiftCloseLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){this._clearAdTimeout(),this.offClose(this._bindShiftCloseLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offError(this._bindShiftErrorLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}shift(){this.offClose(this.bindAdCloseLister),this.onClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.onError(this._bindShiftErrorLister)}static build(e){return w.instance||(w.instance=new w(e)),w.instance}static getInstance(){if(!w.instance)throw Error("RewardAdNovel instance is not init");return w.instance}static new(e){return new w(e)}}class y{frequency={total:0,current:0};constructor(e){this._init(e)}_init(e){this._adTimes(e)}_adTimes(e){this.frequency.total=e?.retry??4}reset(){this.frequency.current=0}updateRetry(){this.frequency.current=this.frequency.current+1}remain(){return this.frequency.total-this.frequency.current}static new(e){return new y(e)}}let p=w,b=s;export{s as AdExecuteManager,o as CountRecorder,g as ExbAnalyticsJS,e as Logger,n as RewardAdFather,d as RewardAdGlobalRecorder,p as RewardAdNovel,_ as RewardAdSceneTriggerManager,r as SerializableError,l as Storage,b as default};
|
|
1
|
+
class e{constructor(e={}){let{prefix:t="Logger",level:i="info",enabled:s=!0}=e;this.prefix=t,this.enabled=s,this.levels={error:0,warn:1,info:2,debug:3},this.currentLevel=this.levels[i]||this.levels.info}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}setLevel(e){Object.prototype.hasOwnProperty.call(this.levels,e)&&(this.currentLevel=this.levels[e])}formatMessage(e,t){let i=new Date,s=`${i.getFullYear()}/${i.getMonth()+1}/${i.getDate()} ${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}`;return`[${s}] [${e.toUpperCase()}] [${this.prefix}] ${t}`}_log(e,t,...i){if(!this.enabled)return;let s=this.levels[e];if(void 0!==s&&this.currentLevel>=s){let s=this.formatMessage(e,t);switch(e){case"error":console.error(s,...i);break;case"warn":console.warn(s,...i);break;case"info":console.info(s,...i);break;case"debug":console.debug(s,...i);break;default:console.log(s,...i)}}}error(e,...t){this._log("error",e,...t)}warn(e,...t){this._log("warn",e,...t)}info(e,...t){this._log("info",e,...t)}debug(e,...t){this._log("debug",e,...t)}log(e,t,...i){this._log(e,t,...i)}}class t{static _instance=null;_taskStack=[];_currentBatchTasks=[];_isRunning=!1;_currentTask=null;constructor(i){if(this.logger=new e({prefix:"AdExecuteManager",enabled:!!i?.log}),t._instance)return t._instance;t._instance=this}static getInstance(e){return t._instance||(t._instance=new t(e)),t._instance}addTask(e,t){return e&&"function"==typeof e.ad?new Promise((i,s)=>{let r={adInstance:e,options:t.options??{},callbackCollection:t.collection??{},resolve:i,reject:s,id:`ad_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,_isResolved:!1,_isRejected:!1};this._taskStack.push(r),this._isRunning||this._compose()}):(this.logger.error("无效的广告实例 请正确实现.ad方法"),Promise.reject(Error("无效的广告实例")))}_compose(){if(0===this._taskStack.length){this._isRunning=!1,this._currentTask=null;return}this._isRunning=!0;let e=[...this._taskStack];this._taskStack=[],this._currentBatchTasks=e;let t=e.map(e=>async(t,i)=>{let{adInstance:s,options:r,callbackCollection:n,resolve:l,id:a}=e;if(e._isResolved||e._isRejected)return void await i(t);this._currentTask=e;try{let o=async e=>{await i(Object.assign({},t,e))},h=await s.initialize(r).ad({options:r,collection:n},o),d=Object.assign({id:a},h);this.logger.info(`任务执行成功,成功信息:${JSON.stringify(d)}`),e._isResolved=!0,l(d),s?.record(d)}catch(n){let r=Object.assign({id:a,apiError:n});this.logger.error(`任务执行失败, 继续下一个任务,错误信息:${JSON.stringify(r)}`),e._isRejected=!0;try{s?.clear()}catch(e){this.logger.error("clear error: ",JSON.stringify(Object.assign({id:a,apiError:e})))}l(r),s?.record(r),await i(t)}}),i={roundTasks:t.length};t.map(e=>(t,i)=>async s=>await e(Object.assign({},t,s),i)).reduce((e,t)=>(i,s)=>e(i,t(i,s)))(i,async e=>{this.logger.info("本轮活动队列已经清空",e),this._taskStack.length>0?Promise.resolve().then(()=>{this._compose()}):(this._isRunning=!1,this._currentTask=null,this._currentBatchTasks=[])})()}clearTasks(){if(this._currentTask){if(this._currentTask._isResolved||this._currentTask._isRejected){this._currentTask=null;return}try{this._currentTask.callbackCollection&&this._currentTask.callbackCollection.onCancel&&this._currentTask.callbackCollection.onCancel(),this._currentTask._isResolved=!0,this._currentTask.resolve()}catch(e){this.logger.error("clear current task error: ",e)}this._currentTask=null}this._currentBatchTasks.length>0&&(this._currentBatchTasks.forEach(e=>{if(e!==this._currentTask&&!e._isResolved&&!e._isRejected)try{e.callbackCollection&&e.callbackCollection.onCancel&&e.callbackCollection.onCancel(),e._isResolved=!0,e.resolve()}catch(e){this.logger.error("clear current batch task error: ",e)}}),this._currentBatchTasks=[]),this._taskStack.forEach(e=>{if(!e._isResolved&&!e._isRejected&&(e._isResolved=!0,e.resolve(),e.callbackCollection&&e.callbackCollection.onCancel))try{e.callbackCollection.onCancel()}catch(e){this.logger.error("clear task error: ",e)}}),this._taskStack=[],this._isRunning=!1}getTaskCount(){return this._taskStack.filter(e=>!e._isResolved&&!e._isRejected).length+this._currentBatchTasks.filter(e=>e!==this._currentTask&&!e._isResolved&&!e._isRejected).length+(!this._currentTask||this._currentTask._isResolved||this._currentTask._isRejected?0:1)}isRunning(){return this._isRunning}getCurrentTaskId(){return this._currentTask?.id||null}}let i=t;class s extends Error{constructor(e){super(e),this.name=this.constructor.name,this.stack=Error(e).stack,Object.defineProperty(this,"message",{enumerable:!0}),Object.defineProperty(this,"name",{enumerable:!0}),Object.defineProperty(this,"stack",{enumerable:!0})}toJSON(){return{name:this.name,message:this.message,stack:this.stack}}}class r{static args=null;_initSign="";_preserveOnEnd=!1;_rewardAd=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];constructor(e){this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._preserveOnEnd=e?.preserveOnEnd??!1}initialize(e,t){if(this._rewardAd)return console.warn("RewardAdFather: rewardAd has been initialized"),t?.(this._rewardAd),this;let i=Object.assign({},r.args,this._adConfig,e);if(!i.adUnitId)throw console.error("[RewardAdFather] reward args adUnitId is required",i),new s("[RewardAdFather] reward args adUnitId is required");return this._rewardAd=tt.createRewardedVideoAd(i),t?.(this._rewardAd),this}initialized(){return!!this._rewardAd}async ad(e,t=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let t=Object.assign({},this._adConfig,e?.options??{});return r.executeWithManager(this,Object.assign({},e,{options:t}))}destroy(){this._rewardAd&&!this._preserveOnEnd&&(this._rewardAd.destroy(),this._rewardAd=null)}clear(){throw Error("子类必须实现clear方法")}record(e){return this}onClose(e){this._rewardAd&&this._rewardAd.onClose(e)}offClose(e){this._rewardAd&&this._rewardAd.offClose(e)}show(){return this._rewardAd?this._rewardAd.show():Promise.reject({errMsg:"rewardAd is null"})}load(){if(this._rewardAd)return this._rewardAd.load()}onError(e){this._rewardAd&&this._rewardAd.onError(e)}offError(e){this._rewardAd&&this._rewardAd.offError(e)}onLoad(e){this._rewardAd&&this._rewardAd.onLoad(e)}offLoad(e){this._rewardAd&&this._rewardAd.offLoad(e)}placeholder(){return null}static buildArgs(e){e?.adUnitId||console.error("[RewardAdFather] RewardParams.adUnitId is required"),r.args=e}static async executeWithManager(e,t){return e&&e instanceof r?i.getInstance({log:t?.options?.log??!0}).addTask(e,t):(console.error("RewardAdFather: executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}let n=r;class l{constructor(t={}){this.config={prefix:"storage_",expire:null,...t},this.logger=new e({prefix:"Storage"})}getTodayEndTimestamp(){let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999).getTime()}_setItem(e,t,i){let s=void 0!==i?i:this.config.expire;"today"===s&&(s=this.getTodayEndTimestamp()-Date.now());let r={value:t,expire:s,timestamp:Date.now()};try{tt.setStorageSync(e,JSON.stringify(r))}catch(e){console.error("Storage setItem error:",e)}}_getItem(e){try{let t=tt.getStorageSync(e);if(!t)return null;let i=JSON.parse(t);if(i.expire&&Date.now()-i.timestamp>i.expire)return this.removeItem(e),null;return i.value}catch(e){return console.error("Storage getItem error:",e),null}}setItem(e,t,i){let s=this.config.prefix+e;return this._setItem(s,t,i)}getItem(e){let t=this.config.prefix+e;return this._getItem(t)}getUserItem(e){let t=this.config.userId??"null";if("null"===t)return this.logger.error("userId is required"),null;let i=`${this.config.prefix}_${t}_${e}`;return this._getItem(i)}setUserItem(e,t,i){let s=this.config.userId??"null";if("null"===s)return void this.logger.error("userId is required");let r=`${this.config.prefix}_${s}_${e}`;return this._setItem(r,t,i)}removeItem(e){try{tt.removeStorageSync(e)}catch(e){console.error("Storage removeItem error:",e)}}clear(){try{tt.clearStorageSync()}catch(e){console.error("Storage clear error:",e)}}keys(){try{let e=[];return(tt.getStorageInfoSync().keys??[]).forEach(t=>{if(t.startsWith(this.config.prefix)){let i=JSON.parse(tt.getStorageSync(t));(!i.expire||Date.now()-i.timestamp<=i.expire)&&e.push(t.replace(this.config.prefix,""))}}),e}catch(e){return console.error("Storage keys error:",e),[]}}static new(e){return new l(e)}}let a=l;class o{_total=0;_local_sign="";_expire="today";constructor(e){if(this.storage=a.new({userId:e.userId}),!e.local_sign)throw Error("local_sign is required");this._local_sign=e.local_sign,this._total=e.total??0,this._expire=e.expire??"today",this._init()}_init(){this._initLocalTimes()}_adTimes(){return this._total}_safeLocalValue(e){return"object"!=typeof e||null===e?{}:e}_initLocalTimes(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),i=this._safeLocalValue(t);i&&i?.total==e||this.storage.setUserItem(this._local_sign,{total:e,today:i?.today??0},this._expire)}updateToday(){let e=this._adTimes(),t=this.storage.getUserItem(this._local_sign),i=this._safeLocalValue(t),s=i?.today??0;this.storage.setUserItem(this._local_sign,{total:e,today:s+1},this._expire)}remain(){let e=this.storage.getUserItem(this._local_sign),t=this._safeLocalValue(e),i=t?.today??0;return Number(t?.total??0)-Number(i)}static new(e){return new o(e)}}function h(e,t){return!!t&&e.some(e=>RegExp(e,"i").test(t))}let d=Object.entries({9999:"inner_default_other"}).reduce((e,[t,i])=>(e[i]=Number(t),e),{});class c{static instance=null;_initSign="";_halfway=[{scene:d.inner_default_other,count:0}];_finished=[{scene:d.inner_default_other,count:0}];constructor(e){if(c.instance)return c.instance;this._initSign=e?.sign??"",this._halfway=[{scene:d.inner_default_other,count:0}],this._finished=[{scene:d.inner_default_other,count:0}],c.instance=this}initialize(e){}_halfwayUpdate(e){let t=this._halfway.find(t=>t.scene===e.scene);t?t.count+=1:this._halfway.push({scene:e.scene,count:1})}_halfwayGet(e){let t=e?.scenes??[];return(t.length>0?this._halfway.filter(e=>t.includes(e.scene)):this._halfway).reduce((e,t)=>e+t.count,0)}_halfwayReset(){this._halfway=[{scene:d.inner_default_other,count:0}]}_finishedUpdate(e){let t=this._finished.find(t=>t.scene===e.scene);t?t.count+=1:this._finished.push({scene:e.scene,count:1})}_finishedGet(e){let t=e?.scenes??[];return(t.length>0?this._finished.filter(e=>t.includes(e.scene)):this._finished).reduce((e,t)=>e+t.count,0)}_finishedReset(){this._finished=[{scene:d.inner_default_other,count:0}]}record(e){switch(e.type){case"halfway":this._halfwayUpdate(e);break;case"finished":this._finishedUpdate(e)}}rest(e){switch(e){case"halfway":this._halfwayReset();break;case"finished":this._finishedReset()}}get(e){switch(e.type){case"halfway":return this._halfwayGet(e);case"finished":return this._finishedGet(e);default:return null}}placeholder(){return null}static build(e){return c.instance||(c.instance=new c(e)),c.instance}static getInstance(){if(!c.instance)throw Error("RewardAdGlobalRecorder instance is not init");return c.instance}}let u=c;class _{static instance=null;_initSign="";_currScene=null;_sceneTypeObj={};constructor(e){if(_.instance)return _.instance;this._initSign=e?.sign??"",this._sceneTypeObj=e?.sceneTypeObj??{},_.instance=this}initialize(e){}addScene(e){return console.log("----------------------AD触发场景:--------------------",e),this._currScene=e,this}addSceneType(e=1){return this.addScene(this._sceneTypeObj[e]),this}getCurrentScene(){return this._currScene}placeholder(){return null}static build(e){return _.instance||(_.instance=new _(e)),_.instance}static getInstance(){if(!_.instance)throw Error("RewardAdSceneTriggerManager instance is not init");return _.instance}}let f=_;class g{static instance=null;_initSign="";_needReport=!1;constructor(e){if(g.instance)return g.instance;this._initSign=e?.sign??"",this._needReport=e?.needReport??!1,this._userConfig=e?.userConfig??null,g.instance=this}initialize(e){return this._needReport?e:void console.warn("ExbAnalyticsJS needReport is false, do not report")}track(e,t,i){if(!this._needReport)return;if(!e)throw Error("eventName is required");let s=Object.assign({},this._getCommonUserInfo(),t),r=i?.sign??"track";console.log(`-------------${r}-----------------------:`,e,s),tt.reportAnalytics(e,s)}_getCommonUserInfo(){let{user_id:e,user_type:t,user_group:i}=this._userConfig??{};return{user_id:e,user_type:t,user_group:i}}identify(e){if(!e)throw Error("userInfo is required");if(!e.user_id)throw Error("user_id is required");return this._userConfig={user_id:e.user_id,user_type:e.user_type??0,user_group:e.user_group??0},this}alias(){return null}pages(){return null}page(e,t){this.track(e,t,{sign:"page"})}cpage(e){return this.page("cpage",e)}placeholder(){return null}static build(e){return g.instance||(g.instance=new g(e)),g.instance}static getInstance(){if(!g.instance)throw Error("ExbAnalyticsJS instance is not init");return g.instance}static new(e){return new g(e)}}let w=g;class A extends n{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=d.inner_default_other;_adTimeout=null;_adTimeoutTime=8e3;_adBeforeShowTimer=null;_adBeforeShowTime=300;_adSpeedCloseTimer=null;_adSpeedCloseTime=5e3;_needEndOnTimeout=!0;_needSpeedEndOnTimeout=!1;bindAdCloseLister=this.adCloseLister.bind(this);bindAdErrorLister=this.adErrorLister.bind(this);bindAdLoadLister=this.adLoadLister.bind(this);bindApiAdErrorLister=this.apiAdErrorLister.bind(this);_bindShiftCloseLister=this._shiftCloseLister.bind(this);_bindShiftErrorLister=this._shiftErrorLister.bind(this);constructor(e){super(e),this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._needEndOnTimeout=e?.needEndOnTimeout??!0,this._onHalfway=e?.collection?.onHalfway??null,this._onShow=e?.collection?.onShow??null,this._onFinish=e?.collection?.onFinish??null,this._onAlways=e?.collection?.onAlways??null,this._onError=e?.collection?.onError??null}initialize(e,t){return super.initialize(e,t),this._initAdLister(),this._initNovelConfig(e),this}_initAdLister(){this.onClose(this.bindAdCloseLister),this.onError(this.bindAdErrorLister),this.onLoad(this.bindAdLoadLister),tt.onError(this.bindApiAdErrorLister)}_initNovelConfig(e){this.novelConfig=b.new({retry:e?.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let t=()=>{tt.offAppShow(t),console.warn("[RewardAdNovel] ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",e?.scene);let i="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:e?.scene,msg:i,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),e?.end({resolvedValue:{apiError:{errMsg:i}},nextValue:null})};tt.onAppShow(t)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{console.warn("[RewardAdNovel] Ad show timeout, handling fallback ad case, scene:",e?.scene),this._adShowFailureAnalytics({scene:e?.scene,msg:"ad_show_timeout: normal",result:0}),e?.end({resolvedValue:{apiError:{errMsg:"ad_show_timeout: normal"}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearTimeout(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowSuccessAnalytics(e){return null}_adShowFailureAnalytics(e){return null}_adLoadSuccessAnalytics(e){return null}_adLoadFailureAnalytics(e){return null}_adCloseSuccessAnalytics(e){return null}get rewardAd(){return this._rewardAd}addExecuteManager(e){return super.addExecuteManager(e)}ad(e,t=null){return this._alwaysCallback=e?.collection?.always,this._halfwayCallback=e?.collection?.halfway,this._finishedCallback=e?.collection?.finished,this._onInnerExecuteBefore(),new Promise(i=>{this._adInner({options:{scene:e?.options?.scene},collection:{resolve:i,before:e.collection?.before,success:e.collection?.success,prelude:e.collection?.prelude}},t)})}_adInner(e,t=null){let i=e?.collection?.resolve,s=e?.options?.scene??this._scene??d.inner_default_other,r=e?.collection?.before,n=e?.collection?.success,l=e?.collection?.prelude,a=e=>{this._clearAdTimeout(),this.adDestroy(),i?.(Object.assign({scene:s},e?.resolvedValue)),t?.(Object.assign({scene:s},e?.nextValue))},o=()=>{this._scene=s,r?.({scene:s}),this._before=r,this._onShow?.({scene:s}),f.getInstance().addSceneType(s),this._resolve=i,this._next=t,this._setAdTimeout({scene:s,end:a}),this._adPreludeInterval({scene:s,prelude:l}),this.adShow().then(()=>{this._clearAdTimeout(),n?.({scene:s}),this._success=n,this._adShowSuccessAnalytics({scene:s,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:s,msg:e?.errMsg,result:0}),h(this._ttErrorMsgs,e?.errMsg)||this._ttErrorCodes.includes(e?.errorCode))?a({scene:s,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?a({scene:s,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:s,result:1}),o()}).catch(e=>{this._adLoadFailureAnalytics({scene:s,msg:e?.errMsg,result:0}),a({scene:s,resolvedValue:{apiError:e},nextValue:null})}))})};o()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){this._alwaysCallback?.(e)}_outerHalfwayCallback(e){this._halfwayCallback?.(e)}_outerFinishedCallback(e){this._finishedCallback?.(e)}adCloseLister(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let t={...e,scene:this._scene},i=t=>{this.adDestroy(),this._resolve?.(Object.assign({},e,{scene:this._scene},t)),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null};e?.isEnded?(this._outerFinishedCallback(t),this._onFinish?.(t)):(this._outerHalfwayCallback(t),this._onHalfway?.(t)),this._outerCloseCallback(t),this._onAlways?.(t),i({end_type:e.isEnded?"finished":"halfway"})}adErrorLister(e){this._clearAdTimeout(),console.error("[RewardAdNovel] adErrorLister",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){this._clearAdTimeout(),console.error("[API RewardAdNovel] apiAdErrorLister:",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:e?.errMsg}),console.info("[RewardAdNovel] adLoadLister:",JSON.stringify({scene:this._scene,info:e}))}adDestroy(){this.offClose(this.bindAdCloseLister),this.offError(this.bindAdErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy()}clear(){this._clearAdTimeout(),this.offClose(this.bindAdCloseLister),this.offClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){this._clearAdTimeout(),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offClose(this._bindShiftCloseLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){this._clearAdTimeout(),this.offClose(this._bindShiftCloseLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offError(this._bindShiftErrorLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}shift(){this.offClose(this.bindAdCloseLister),this.onClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.onError(this._bindShiftErrorLister)}static build(e){return A.instance||(A.instance=new A(e)),A.instance}static getInstance(){if(!A.instance)throw Error("RewardAdNovel instance is not init");return A.instance}static new(e){return new A(e)}}class b{frequency={total:0,current:0};constructor(e){this._init(e)}_init(e){this._adTimes(e)}_adTimes(e){this.frequency.total=e?.retry??4}reset(){this.frequency.current=0}updateRetry(){this.frequency.current=this.frequency.current+1}remain(){return this.frequency.total-this.frequency.current}static new(e){return new b(e)}}let y=A;class m{static args=null;_initSign="";_preserveOnEnd=!1;_interstitialAd=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];constructor(e){this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._preserveOnEnd=e?.preserveOnEnd??!1}initialize(e,t){if(this._interstitialAd)return console.warn("InterstitialAdFather: interstitialAd has been initialized"),t?.(this._interstitialAd),this;let i=Object.assign({},m.args,this._adConfig,e);if(!i.adUnitId)throw console.error("[InterstitialAdFather] interstitialAd args adUnitId is required",i),new s("[InterstitialAdFather] interstitialAd args adUnitId is required");return this._interstitialAd=tt.createInterstitialAd(i),t?.(this._interstitialAd),this}initialized(){return!!this._interstitialAd}async ad(e,t=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let t=Object.assign({},this._adConfig,e?.options??{});return m.executeWithManager(this,Object.assign({},e,{options:t}))}destroy(){this._interstitialAd&&!this._preserveOnEnd&&(this._interstitialAd.destroy(),this._interstitialAd=null)}clear(){throw Error("子类必须实现clear方法")}record(e){return this}onClose(e){this._interstitialAd&&this._interstitialAd.onClose(e)}offClose(e){this._interstitialAd&&this._interstitialAd.offClose(e)}show(){return this._interstitialAd?this._interstitialAd.show():Promise.reject({errMsg:"interstitialAd is null"})}load(){if(this._interstitialAd)return this._interstitialAd.load()}onError(e){this._interstitialAd&&this._interstitialAd.onError(e)}offError(e){this._interstitialAd&&this._interstitialAd.offError(e)}onLoad(e){this._interstitialAd&&this._interstitialAd.onLoad(e)}offLoad(e){this._interstitialAd&&this._interstitialAd.offLoad(e)}placeholder(){return null}static buildArgs(e){e?.adUnitId||console.error("[InterstitialAdFather] interstitialAdParams.adUnitId is required"),m.args=e}static async executeWithManager(e,t){return e&&e instanceof m?i.getInstance({log:t?.options?.log??!0}).addTask(e,t):(console.error("InterstitialAdFather: executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}let p=m;class S extends p{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=d.inner_default_other;_adTimeout=null;_adTimeoutTime=8e3;_adBeforeShowTimer=null;_adBeforeShowTime=300;_adSpeedCloseTimer=null;_adSpeedCloseTime=5e3;_needEndOnTimeout=!0;_needSpeedEndOnTimeout=!1;bindAdCloseLister=this.adCloseLister.bind(this);bindAdErrorLister=this.adErrorLister.bind(this);bindAdLoadLister=this.adLoadLister.bind(this);bindApiAdErrorLister=this.apiAdErrorLister.bind(this);_bindShiftCloseLister=this._shiftCloseLister.bind(this);_bindShiftErrorLister=this._shiftErrorLister.bind(this);constructor(e){super(e),this._initSign=e?.sign??"",this._adConfig=e?.adConfig??{},this._needEndOnTimeout=e?.needEndOnTimeout??!0,this._onHalfway=e?.collection?.onHalfway??null,this._onShow=e?.collection?.onShow??null,this._onFinish=e?.collection?.onFinish??null,this._onAlways=e?.collection?.onAlways??null,this._onError=e?.collection?.onError??null}initialize(e,t){return super.initialize(e,t),this._initAdLister(),this._initNovelConfig(e),this}_initAdLister(){this.onClose(this.bindAdCloseLister),this.onError(this.bindAdErrorLister),this.onLoad(this.bindAdLoadLister),tt.onError(this.bindApiAdErrorLister)}_initNovelConfig(e){this.novelConfig=E.new({retry:e?.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let t=()=>{tt.offAppShow(t),console.warn("[InterstitialAdNovel] ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",e?.scene);let i="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:e?.scene,msg:i,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),e?.end({resolvedValue:{apiError:{errMsg:i}},nextValue:null})};tt.onAppShow(t)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{console.warn("[InterstitialAdNovel] Ad show timeout, handling fallback ad case, scene:",e?.scene),this._adShowFailureAnalytics({scene:e?.scene,msg:"ad_show_timeout: normal",result:0}),e?.end({resolvedValue:{apiError:{errMsg:"ad_show_timeout: normal"}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{e.prelude?.({scene:e?.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearTimeout(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowSuccessAnalytics(e){return null}_adShowFailureAnalytics(e){return null}_adLoadSuccessAnalytics(e){return null}_adLoadFailureAnalytics(e){return null}_adCloseSuccessAnalytics(e){return null}get rewardAd(){return this._rewardAd}addExecuteManager(e){return super.addExecuteManager(e)}ad(e,t=null){return this._alwaysCallback=e?.collection?.always,this._halfwayCallback=e?.collection?.halfway,this._finishedCallback=e?.collection?.finished,this._onInnerExecuteBefore(),new Promise(i=>{this._adInner({options:{scene:e?.options?.scene},collection:{resolve:i,before:e.collection?.before,success:e.collection?.success,prelude:e.collection?.prelude}},t)})}_adInner(e,t=null){let i=e?.collection?.resolve,s=e?.options?.scene??this._scene??d.inner_default_other,r=e?.collection?.before,n=e?.collection?.success,l=e?.collection?.prelude,a=e=>{this._clearAdTimeout(),this.adDestroy(),i?.(Object.assign({scene:s},e?.resolvedValue)),t?.(Object.assign({scene:s},e?.nextValue))},o=()=>{this._scene=s,r?.({scene:s}),this._before=r,this._onShow?.({scene:s}),this._resolve=i,this._next=t,this._setAdTimeout({scene:s,end:a}),this._adPreludeInterval({scene:s,prelude:l}),this.adShow().then(()=>{this._clearAdTimeout(),n?.({scene:s}),this._success=n,this._adShowSuccessAnalytics({scene:s,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:s,msg:e?.errMsg,result:0}),h(this._ttErrorMsgs,e?.errMsg)||this._ttErrorCodes.includes(e?.errorCode))?a({scene:s,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?a({scene:s,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:s,result:1}),o()}).catch(e=>{this._adLoadFailureAnalytics({scene:s,msg:e?.errMsg,result:0}),a({scene:s,resolvedValue:{apiError:e},nextValue:null})}))})};o()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){this._alwaysCallback?.(e)}_outerHalfwayCallback(e){this._halfwayCallback?.(e)}_outerFinishedCallback(e){this._finishedCallback?.(e)}adCloseLister(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let t={...e,scene:this._scene},i=t=>{this.adDestroy(),this._resolve?.(Object.assign({},e,{scene:this._scene},t)),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null};e?.isEnded?(this._outerFinishedCallback(t),this._onFinish?.(t)):(this._outerHalfwayCallback(t),this._onHalfway?.(t)),this._outerCloseCallback(t),this._onAlways?.(t),i({end_type:e.isEnded?"finished":"halfway"})}adErrorLister(e){this._clearAdTimeout(),console.error("[InterstitialAdNovel] adErrorLister",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){this._clearAdTimeout(),console.error("[API InterstitialAdNovel] apiAdErrorLister:",JSON.stringify(e)),this.adDestroy(),this._onError?.(e),this._resolve?.({apiError:e}),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:e?.errMsg}),console.info("[InterstitialAdNovel] adLoadLister:",JSON.stringify({scene:this._scene,info:e}))}adDestroy(){this.offClose(this.bindAdCloseLister),this.offError(this.bindAdErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy()}clear(){this._clearAdTimeout(),this.offClose(this.bindAdCloseLister),this.offClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){this._clearAdTimeout(),this.offError(this._bindShiftErrorLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offClose(this._bindShiftCloseLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){this._clearAdTimeout(),this.offClose(this._bindShiftCloseLister),this.offLoad(this.bindAdLoadLister),tt.offError(this.bindApiAdErrorLister),this._onHalfway=null,this._onFinish=null,this._onAlways=null,this._onShow=null,this._onError=null,this._alwaysCallback=null,this._halfwayCallback=null,this._finishedCallback=null,this.offError(this._bindShiftErrorLister),this.destroy(),this._resolve?.(Object.assign({},e,{scene:this._scene})),this._resolve=null,this._next?.(),this._next=null,this._success=null,this._before=null}shift(){this.offClose(this.bindAdCloseLister),this.onClose(this._bindShiftCloseLister),this.offError(this.bindAdErrorLister),this.onError(this._bindShiftErrorLister)}static build(e){return S.instance||(S.instance=new S(e)),S.instance}static getInstance(){if(!S.instance)throw Error("InterstitialAdNovel instance is not init");return S.instance}static new(e){return new S(e)}}class E{frequency={total:0,current:0};constructor(e){this._init(e)}_init(e){this._adTimes(e)}_adTimes(e){this.frequency.total=e?.retry??4}reset(){this.frequency.current=0}updateRetry(){this.frequency.current=this.frequency.current+1}remain(){return this.frequency.total-this.frequency.current}static new(e){return new E(e)}}let C=S,T=i;export{i as AdExecuteManager,o as CountRecorder,w as ExbAnalyticsJS,p as InterstitialAdFather,C as InterstitialAdNovel,e as Logger,n as RewardAdFather,u as RewardAdGlobalRecorder,y as RewardAdNovel,f as RewardAdSceneTriggerManager,s as SerializableError,a as Storage,T as default};
|