@ad-execute-manager/ad 2.0.0-alpha.4 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 singcl
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 singcl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,149 +1,380 @@
1
- # @singcl/ad
2
-
3
- Ad-related classes including InterstitialAdFather, InterstitialAdNovel, RewardAdFather, and RewardAdNovel for ad management.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @singcl/ad
9
- ```
10
-
11
- ## Features
12
-
13
- - **InterstitialAdFather**: Base class for interstitial ads
14
- - **InterstitialAdNovel**: Novel-specific interstitial ad implementation
15
- - **RewardAdFather**: Base class for reward ads
16
- - **RewardAdNovel**: Novel-specific reward ad implementation
17
-
18
- ## Usage
19
-
20
- ### InterstitialAdNovel
21
-
22
- ```javascript
23
- import { InterstitialAdNovel } from '@singcl/ad';
24
-
25
- const interstitialAd = InterstitialAdNovel.new({
26
- sign: 'novel_interstitial',
27
- preserveOnEnd: false,
28
- needEndOnTimeout: true,
29
- collection: {
30
- onHalfway: (args) => {
31
- console.log('Ad halfway:', args);
32
- },
33
- onShow: (args) => {
34
- console.log('Ad shown:', args);
35
- },
36
- onFinish: (args) => {
37
- console.log('Ad finished:', args);
38
- },
39
- onAlways: (args) => {
40
- console.log('Ad always:', args);
41
- },
42
- onError: (error) => {
43
- console.error('Ad error:', error);
44
- }
45
- }
46
- });
47
-
48
- // Initialize ad
49
- interstitialAd.initialize({
50
- adUnitId: 'your-ad-unit-id',
51
- retry: 3
52
- });
53
-
54
- // Show ad
55
- const result = await interstitialAd.addExecuteManager({
56
- options: {
57
- scene: 1
58
- }
59
- });
60
-
61
- console.log('Ad result:', result);
62
- ```
63
-
64
- ### RewardAdNovel
65
-
66
- ```javascript
67
- import { RewardAdNovel } from '@singcl/ad';
68
-
69
- const rewardAd = RewardAdNovel.new({
70
- sign: 'novel_reward',
71
- preserveOnEnd: false,
72
- needEndOnTimeout: true,
73
- collection: {
74
- onHalfway: (args) => {
75
- console.log('Ad halfway:', args);
76
- },
77
- onShow: (args) => {
78
- console.log('Ad shown:', args);
79
- },
80
- onFinish: (args) => {
81
- console.log('Ad finished:', args);
82
- },
83
- onAlways: (args) => {
84
- console.log('Ad always:', args);
85
- },
86
- onError: (error) => {
87
- console.error('Ad error:', error);
88
- }
89
- }
90
- });
91
-
92
- // Initialize ad
93
- rewardAd.initialize({
94
- adUnitId: 'your-ad-unit-id',
95
- retry: 3
96
- });
97
-
98
- // Show ad
99
- const result = await rewardAd.addExecuteManager({
100
- options: {
101
- scene: 2,
102
- timeout: 10000
103
- }
104
- });
105
-
106
- console.log('Ad result:', result);
107
- ```
108
-
109
- ## API
110
-
111
- ### InterstitialAdFather
112
-
113
- Base class for interstitial ads with common functionality.
114
-
115
- ### InterstitialAdNovel
116
-
117
- ```typescript
118
- class InterstitialAdNovel extends InterstitialAdFather {
119
- static build(args: IConstructArgs): InterstitialAdNovel;
120
- static getInstance(): InterstitialAdNovel;
121
- static new(args: IConstructArgs): InterstitialAdNovel;
122
- initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
123
- addExecuteManager(ctx: any): Promise<any>;
124
- clear(): void;
125
- shift(): void;
126
- }
127
- ```
128
-
129
- ### RewardAdFather
130
-
131
- Base class for reward ads with common functionality.
132
-
133
- ### RewardAdNovel
134
-
135
- ```typescript
136
- class RewardAdNovel extends RewardAdFather {
137
- static build(args: IConstructArgs): RewardAdNovel;
138
- static getInstance(): RewardAdNovel;
139
- static new(args: IConstructArgs): RewardAdNovel;
140
- initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
141
- addExecuteManager(ctx: any): Promise<any>;
142
- clear(): void;
143
- shift(): void;
144
- }
145
- ```
146
-
147
- ## License
148
-
149
- MIT
1
+ # @ad-execute-manager/ad
2
+
3
+ Ad-related classes including InterstitialAdFather, InterstitialAdNovel, RewardAdFather, and RewardAdNovel for ad management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ad-execute-manager/ad
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **InterstitialAdFather**: Base class for interstitial ads with common functionality
14
+ - **InterstitialAdNovel**: Novel-specific interstitial ad implementation with enhanced features
15
+ - **RewardAdFather**: Base class for reward ads with common functionality
16
+ - **RewardAdNovel**: Novel-specific reward ad implementation with enhanced features
17
+
18
+ ## Usage
19
+
20
+ ### InterstitialAdNovel
21
+
22
+ ```javascript
23
+ import { InterstitialAdNovel } from '@ad-execute-manager/ad';
24
+
25
+ const interstitialAd = InterstitialAdNovel.new({
26
+ sign: 'novel_interstitial',
27
+ preserveOnEnd: false,
28
+ needEndOnTimeout: true,
29
+ collection: {
30
+ onHalfway: (args) => {
31
+ console.log('Ad halfway:', args);
32
+ },
33
+ onShow: (args) => {
34
+ console.log('Ad shown:', args);
35
+ },
36
+ onFinish: (args) => {
37
+ console.log('Ad finished:', args);
38
+ },
39
+ onAlways: (args) => {
40
+ console.log('Ad always:', args);
41
+ },
42
+ onError: (error) => {
43
+ console.error('Ad error:', error);
44
+ }
45
+ }
46
+ });
47
+
48
+ // Initialize ad
49
+ interstitialAd.initialize({
50
+ adUnitId: 'your-ad-unit-id',
51
+ retry: 3
52
+ });
53
+
54
+ // Show ad
55
+ const result = await interstitialAd.addExecuteManager({
56
+ options: {
57
+ scene: 1
58
+ }
59
+ });
60
+
61
+ console.log('Ad result:', result);
62
+ ```
63
+
64
+ ### RewardAdNovel
65
+
66
+ ```javascript
67
+ import { RewardAdNovel } from '@ad-execute-manager/ad';
68
+
69
+ const rewardAd = RewardAdNovel.new({
70
+ sign: 'novel_reward',
71
+ preserveOnEnd: false,
72
+ needEndOnTimeout: true,
73
+ collection: {
74
+ onHalfway: (args) => {
75
+ console.log('Ad halfway:', args);
76
+ },
77
+ onShow: (args) => {
78
+ console.log('Ad shown:', args);
79
+ },
80
+ onFinish: (args) => {
81
+ console.log('Ad finished:', args);
82
+ },
83
+ onAlways: (args) => {
84
+ console.log('Ad always:', args);
85
+ },
86
+ onError: (error) => {
87
+ console.error('Ad error:', error);
88
+ }
89
+ }
90
+ });
91
+
92
+ // Initialize ad
93
+ rewardAd.initialize({
94
+ adUnitId: 'your-ad-unit-id',
95
+ retry: 3
96
+ });
97
+
98
+ // Show ad
99
+ const result = await rewardAd.addExecuteManager({
100
+ options: {
101
+ scene: 2,
102
+ timeout: 10000
103
+ }
104
+ });
105
+
106
+ console.log('Ad result:', result);
107
+ ```
108
+
109
+ ## API
110
+
111
+ ### InterstitialAdFather
112
+
113
+ Base class for interstitial ads with common functionality.
114
+
115
+ ### InterstitialAdNovel
116
+
117
+ ```typescript
118
+ class InterstitialAdNovel extends InterstitialAdFather {
119
+ /**
120
+ * Builds and returns an instance of InterstitialAdNovel
121
+ * @param args Construction arguments
122
+ * @returns Instance of InterstitialAdNovel
123
+ */
124
+ static build(args: IConstructArgs): InterstitialAdNovel;
125
+
126
+ /**
127
+ * Gets the singleton instance of InterstitialAdNovel
128
+ * @returns Singleton instance of InterstitialAdNovel
129
+ */
130
+ static getInstance(): InterstitialAdNovel;
131
+
132
+ /**
133
+ * Creates a new instance of InterstitialAdNovel
134
+ * @param args Construction arguments
135
+ * @returns New instance of InterstitialAdNovel
136
+ */
137
+ static new(args: IConstructArgs): InterstitialAdNovel;
138
+
139
+ /**
140
+ * Initializes the ad with configuration
141
+ * @param params Ad configuration parameters
142
+ * @param callback Optional callback function
143
+ * @returns Current instance for method chaining
144
+ */
145
+ initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
146
+
147
+ /**
148
+ * Adds execute manager and runs the ad
149
+ * @param ctx Context object with options
150
+ * @returns Promise with ad execution result
151
+ */
152
+ addExecuteManager(ctx: any): Promise<any>;
153
+
154
+ /**
155
+ * Clears the ad instance
156
+ */
157
+ clear(): void;
158
+
159
+ /**
160
+ * Shifts the ad instance
161
+ */
162
+ shift(): void;
163
+ }
164
+ ```
165
+
166
+ ### RewardAdFather
167
+
168
+ Base class for reward ads with common functionality.
169
+
170
+ ### RewardAdNovel
171
+
172
+ ```typescript
173
+ class RewardAdNovel extends RewardAdFather {
174
+ /**
175
+ * Builds and returns an instance of RewardAdNovel
176
+ * @param args Construction arguments
177
+ * @returns Instance of RewardAdNovel
178
+ */
179
+ static build(args: IConstructArgs): RewardAdNovel;
180
+
181
+ /**
182
+ * Gets the singleton instance of RewardAdNovel
183
+ * @returns Singleton instance of RewardAdNovel
184
+ */
185
+ static getInstance(): RewardAdNovel;
186
+
187
+ /**
188
+ * Creates a new instance of RewardAdNovel
189
+ * @param args Construction arguments
190
+ * @returns New instance of RewardAdNovel
191
+ */
192
+ static new(args: IConstructArgs): RewardAdNovel;
193
+
194
+ /**
195
+ * Initializes the ad with configuration
196
+ * @param params Ad configuration parameters
197
+ * @param callback Optional callback function
198
+ * @returns Current instance for method chaining
199
+ */
200
+ initialize(params: IRewordAdConfig, callback?: (v: IRewardedVideoAd) => void): this;
201
+
202
+ /**
203
+ * Adds execute manager and runs the ad
204
+ * @param ctx Context object with options
205
+ * @returns Promise with ad execution result
206
+ */
207
+ addExecuteManager(ctx: any): Promise<any>;
208
+
209
+ /**
210
+ * Clears the ad instance
211
+ */
212
+ clear(): void;
213
+
214
+ /**
215
+ * Shifts the ad instance
216
+ */
217
+ shift(): void;
218
+ }
219
+ ```
220
+
221
+ ## Configuration
222
+
223
+ ### Construction Arguments
224
+
225
+ When creating an ad instance, you can pass the following configuration options:
226
+
227
+ - **sign**: Unique identifier for the ad instance
228
+ - **preserveOnEnd**: Whether to preserve the instance after ad ends
229
+ - **needEndOnTimeout**: Whether to end the ad on timeout
230
+ - **collection**: Event collection object with callback functions
231
+ - **onHalfway**: Called when ad reaches halfway point
232
+ - **onShow**: Called when ad is shown
233
+ - **onFinish**: Called when ad finishes
234
+ - **onAlways**: Called always after ad operation
235
+ - **onError**: Called when ad encounters error
236
+
237
+ ### Initialize Parameters
238
+
239
+ When initializing an ad, you can pass the following parameters:
240
+
241
+ - **adUnitId**: Unique identifier for the ad unit
242
+ - **retry**: Number of retry attempts on ad error
243
+
244
+ ## Examples
245
+
246
+ ### Example 1: Basic Interstitial Ad Usage
247
+
248
+ ```javascript
249
+ import { InterstitialAdNovel } from '@ad-execute-manager/ad';
250
+
251
+ // Create ad instance
252
+ const interstitialAd = InterstitialAdNovel.new({
253
+ sign: 'chapter_end_interstitial',
254
+ preserveOnEnd: false,
255
+ needEndOnTimeout: true,
256
+ collection: {
257
+ onFinish: () => {
258
+ console.log('Interstitial ad finished, proceeding to next chapter');
259
+ // Proceed to next chapter logic here
260
+ },
261
+ onError: (error) => {
262
+ console.error('Interstitial ad error:', error);
263
+ // Handle error gracefully, maybe skip ad
264
+ }
265
+ }
266
+ });
267
+
268
+ // Initialize and show ad
269
+ interstitialAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 2 });
270
+
271
+ // Show ad at chapter end
272
+ async function showAdAtChapterEnd() {
273
+ try {
274
+ const result = await interstitialAd.addExecuteManager({ options: { scene: 1 } });
275
+ console.log('Ad result:', result);
276
+ } catch (error) {
277
+ console.error('Ad execution error:', error);
278
+ }
279
+ }
280
+
281
+ // Usage
282
+ // showAdAtChapterEnd();
283
+ ```
284
+
285
+ ### Example 2: Reward Ad for Premium Content
286
+
287
+ ```javascript
288
+ import { RewardAdNovel } from '@ad-execute-manager/ad';
289
+
290
+ // Create reward ad instance
291
+ const rewardAd = RewardAdNovel.new({
292
+ sign: 'premium_content_reward',
293
+ preserveOnEnd: true,
294
+ needEndOnTimeout: true,
295
+ collection: {
296
+ onFinish: (args) => {
297
+ console.log('Reward ad finished, unlocking premium content');
298
+ // Unlock premium content logic here
299
+ unlockPremiumContent();
300
+ },
301
+ onError: (error) => {
302
+ console.error('Reward ad error:', error);
303
+ // Show error message to user
304
+ showErrorMessage('Failed to load ad. Please try again later.');
305
+ }
306
+ }
307
+ });
308
+
309
+ // Initialize ad
310
+ rewardAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 3 });
311
+
312
+ // Function to unlock premium content
313
+ function unlockPremiumContent() {
314
+ // Logic to unlock premium content
315
+ console.log('Premium content unlocked!');
316
+ }
317
+
318
+ // Function to show error message
319
+ function showErrorMessage(message) {
320
+ // Logic to show error message
321
+ console.log('Error:', message);
322
+ }
323
+
324
+ // Show reward ad to unlock premium content
325
+ async function showRewardAdForPremium() {
326
+ try {
327
+ const result = await rewardAd.addExecuteManager({
328
+ options: {
329
+ scene: 2,
330
+ timeout: 15000
331
+ }
332
+ });
333
+ console.log('Reward ad result:', result);
334
+ } catch (error) {
335
+ console.error('Reward ad execution error:', error);
336
+ }
337
+ }
338
+
339
+ // Usage
340
+ // showRewardAdForPremium();
341
+ ```
342
+
343
+ ### Example 3: Ad Instance Management
344
+
345
+ ```javascript
346
+ import { InterstitialAdNovel, RewardAdNovel } from '@ad-execute-manager/ad';
347
+
348
+ // Create ad instances
349
+ const interstitialAd = InterstitialAdNovel.new({ sign: 'interstitial' });
350
+ const rewardAd = RewardAdNovel.new({ sign: 'reward' });
351
+
352
+ // Initialize ads
353
+ interstitialAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 2 });
354
+ rewardAd.initialize({ adUnitId: 'ca-app-pub-xxx/xxx', retry: 3 });
355
+
356
+ // Function to show appropriate ad based on user action
357
+ async function showAdBasedOnAction(action) {
358
+ try {
359
+ switch (action) {
360
+ case 'chapter_end':
361
+ return await interstitialAd.addExecuteManager({ options: { scene: 1 } });
362
+ case 'unlock_premium':
363
+ return await rewardAd.addExecuteManager({ options: { scene: 2 } });
364
+ default:
365
+ throw new Error('Invalid ad action');
366
+ }
367
+ } catch (error) {
368
+ console.error('Ad error:', error);
369
+ return { success: false, error: error.message };
370
+ }
371
+ }
372
+
373
+ // Usage examples
374
+ // showAdBasedOnAction('chapter_end');
375
+ // showAdBasedOnAction('unlock_premium');
376
+ ```
377
+
378
+ ## License
379
+
380
+ MIT
package/dist/index.cjs CHANGED
@@ -1,2 +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,i)=>{for(var t in i)__webpack_require__.o(i,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},__webpack_require__.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),__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__,{RewardAdNovel:()=>src_RewardAdNovel,RewardAdFather:()=>src_RewardAdFather,InterstitialAdFather:()=>src_InterstitialAdFather,InterstitialAdNovel:()=>src_InterstitialAdNovel});const core_namespaceObject=require("@ad-execute-manager/core"),helper_namespaceObject=require("@ad-execute-manager/helper");class InterstitialAdFather{static args=null;_logger=null;_initSign="";_preserveOnEnd=!1;_interstitialAd=null;__ad__=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is required","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302,140502];constructor(e){this._logger=new helper_namespaceObject.Logger({prefix:"InterstitialAdFather",enabled:!!((null==e?void 0:e.log)??!0)}),this._initSign=(null==e?void 0:e.sign)??"",this._adConfig=(null==e?void 0:e.adConfig)??{},this._preserveOnEnd=(null==e?void 0:e.preserveOnEnd)??!1}initialize(e,i){if(this._interstitialAd)return this._logger.warn("interstitialAd has been initialized"),null==i||i(this._interstitialAd),this;let t=Object.assign({},InterstitialAdFather.args,this._adConfig,e);if(!t.adUnitId)throw this._logger.error("interstitialAd args The adUnitId is required",t),new helper_namespaceObject.SerializableError("[InterstitialAdFather] interstitialAd args The adUnitId is required",{errMsg:"The adUnitId is required",errorCode:100003});let r=tt.createInterstitialAd(t);return this._interstitialAd=r,this.__ad__=r,null==i||i(this._interstitialAd),this}initialized(){return!!this._interstitialAd}async ad(e,i=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let i=Object.assign({},this._adConfig,(null==e?void 0:e.options)??{});return InterstitialAdFather.executeWithManager(this,Object.assign({},e,{options:i}))}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:"[InterstitialAdFather] can not show,interstitialAd is null",errorCode:120001})}load(){return this._interstitialAd?this._interstitialAd.load():Promise.reject({errMsg:"[InterstitialAdFather] can not load,interstitialAd is null",errorCode:120002})}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){(null==e?void 0:e.adUnitId)||new helper_namespaceObject.Logger({prefix:"InterstitialAdFather",enable:!0}).error("interstitialAdParams.adUnitId is required"),InterstitialAdFather.args=e}static async executeWithManager(e,i){return e&&e instanceof InterstitialAdFather?core_namespaceObject.AdExecuteManager.getInstance().addTask(e,i):(new helper_namespaceObject.Logger({prefix:"InterstitialAdFather",enable:!0}).error("executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}const src_InterstitialAdFather=InterstitialAdFather;class RewardAdFather{static args=null;_logger=null;_adTimeoutTime=8e3;_initSign="";_preserveOnEnd=!1;_rewardAd=null;__ad__=null;_ttErrorMsgs=["The adUnitId is closed","The adUnitId is prohibit","The adUnitId is invalid","The adUnitId is required","The adUnitId is empty","feature is not supported in app"];_ttErrorCodes=[139902,123302];__bindAdErrorForeverHandler=this.__adErrorForeverHandler.bind(this);constructor(e){this._logger=new helper_namespaceObject.Logger({prefix:"RewardAdFather",enabled:!!((null==e?void 0:e.log)??!0)}),this._initSign=(null==e?void 0:e.sign)??"",this._adConfig=(null==e?void 0:e.adConfig)??{},this._preserveOnEnd=(null==e?void 0:e.preserveOnEnd)??!1}initialize(e,i){if(this._rewardAd)return this._logger.warn("rewardAd has been initialized"),null==i||i(this._rewardAd),this;let t=Object.assign({},RewardAdFather.args,this._adConfig,e);if(!t.adUnitId)throw this._logger.error("reward args The adUnitId is required",t),new helper_namespaceObject.SerializableError("[RewardAdFather] reward args The adUnitId is required",{errMsg:"The adUnitId is required",errorCode:100002});let r=tt.createRewardedVideoAd(t);return this._logger.info("bindAdErrorForeverHandler at initialized:",null==e?void 0:e.foreverErrorBind),(null==e?void 0:e.foreverErrorBind)&&(null==r||r.offError(this.__bindAdErrorForeverHandler),null==r||r.onError(this.__bindAdErrorForeverHandler)),this._rewardAd=r,this.__ad__=r,null==i||i(this._rewardAd),this}initialized(){return!!this._rewardAd}__adErrorForeverHandler(e){this.adErrorForeverHandler(e)}adErrorForeverHandler(e){return null}async ad(e,i=null){throw Error("子类必须实现ad方法")}async addExecuteManager(e){let i=Object.assign({},this._adConfig,(null==e?void 0:e.options)??{});return RewardAdFather.executeWithManager(this,Object.assign({},e,{options:i}))}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:"[RewardAdFather] can not show,rewardAd is null",errorCode:110001})}load(){return this._rewardAd?this._rewardAd.load():Promise.reject({errMsg:"[RewardAdFather] can not load,rewardAd is null",errorCode:110002})}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){(null==e?void 0:e.adUnitId)||new helper_namespaceObject.Logger({prefix:"RewardAdFather",enable:!0}).error("RewardParams.adUnitId is required"),RewardAdFather.args=e}static async executeWithManager(e,i){return e&&e instanceof RewardAdFather?core_namespaceObject.AdExecuteManager.getInstance().addTask(e,i):(new helper_namespaceObject.Logger({prefix:"RewardAdFather",enable:!0}).error("executeWithManager - 无效的广告实例"),Promise.reject(Error("无效的广告实例")))}}const src_RewardAdFather=RewardAdFather;function matchErrorWithKeywords(e,i){return!!i&&e.some(e=>RegExp(e,"i").test(i))}function getAdSceneTextObj(e){return Object.entries(e).reduce((e,[i,t])=>(e[t]=Number(i),e),{})}const DEFAULT_SCENT_TYPE_OBJ={9999:"inner_default_other"},DEFAULT_SCENT_TEXT_OBJ=getAdSceneTextObj(DEFAULT_SCENT_TYPE_OBJ),AD_TYPE_ENUM={AD_TYPE_REWARD:1,AD_TYPE_INTERSTITIAL:2},AD_TYPE_ENUM_REVERSE=Object.entries(AD_TYPE_ENUM).reduce((e,[i,t])=>(e[t]=i,e),{});class RewardAdNovel extends src_RewardAdFather{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_logger=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=DEFAULT_SCENT_TEXT_OBJ.inner_default_other;_adTypeR=AD_TYPE_ENUM.AD_TYPE_REWARD;_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){var i,t,r,l,s;super(e),this._logger=new helper_namespaceObject.Logger({prefix:"RewardAdNovel",enabled:!!((null==e?void 0:e.log)??!0)}),this._initSign=(null==e?void 0:e.sign)??"",this._adConfig=(null==e?void 0:e.adConfig)??{},this._needEndOnTimeout=(null==e?void 0:e.needEndOnTimeout)??!0,this._onHalfway=(null==e||null==(i=e.collection)?void 0:i.onHalfway)??null,this._onShow=(null==e||null==(t=e.collection)?void 0:t.onShow)??null,this._onFinish=(null==e||null==(r=e.collection)?void 0:r.onFinish)??null,this._onAlways=(null==e||null==(l=e.collection)?void 0:l.onAlways)??null,this._onError=(null==e||null==(s=e.collection)?void 0:s.onError)??null}initialize(e,i){return super.initialize(e,i),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:null==e?void 0:e.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(e){return null}_setAdTimeout(e){if(this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let i=()=>{tt.offAppShow(i),this._logger.warn("ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",null==e?void 0:e.scene);let t="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:null==e?void 0:e.scene,msg:t,errorCode:1e5,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),null==e||e.end({resolvedValue:{apiError:{errMsg:t,errorCode:1e5}},nextValue:null})};tt.onAppShow(i)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout){let i=(null==e?void 0:e.timeout)??this._adTimeoutTime;this._adTimeout=setTimeout(()=>{this._logger.warn("Ad show timeout, handling fallback ad case,",`scene: ${null==e?void 0:e.scene},timeout: ${i}`),this._adShowFailureAnalytics({scene:null==e?void 0:e.scene,msg:"ad_show_timeout: normal",errorCode:1e5,result:0}),this._adTimeoutBeforeEnd({scene:null==e?void 0:e.scene,timeout:i}),null==e||e.end({resolvedValue:{apiError:{errMsg:`ad_show_timeout: normal, reward ad, timeout: ${i}`,errorCode:1e5,timeout:i}},nextValue:null})},i)}}_adTimeoutBeforeEnd(e){return e}_adPreludeInterval(e){var i;null==(i=e.prelude)||i.call(e,{scene:null==e?void 0:e.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{var i;null==(i=e.prelude)||i.call(e,{scene:null==e?void 0:e.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()})},this._adBeforeShowTime)}_clearAdTimeout(){this._adTimeout&&(clearTimeout(this._adTimeout),this._adTimeout=null),this._adBeforeShowTimer&&(clearInterval(this._adBeforeShowTimer),this._adBeforeShowTimer=null),this._adSpeedCloseTimer&&(clearTimeout(this._adSpeedCloseTimer),this._adSpeedCloseTimer=null)}_adShowBeforeAnalytics(e){return 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,i=null){var t,r,l;return this._alwaysCallback=null==e||null==(t=e.collection)?void 0:t.always,this._halfwayCallback=null==e||null==(r=e.collection)?void 0:r.halfway,this._finishedCallback=null==e||null==(l=e.collection)?void 0:l.finished,this._recovered=null==e?void 0:e.recovered,this._onInnerExecuteBefore(),new Promise(t=>{var r,l,s,n,o;this._adInner({options:{scene:null==e||null==(r=e.options)?void 0:r.scene,timeout:null==e||null==(l=e.options)?void 0:l.timeout},collection:{resolve:t,before:null==(s=e.collection)?void 0:s.before,success:null==(n=e.collection)?void 0:n.success,prelude:null==(o=e.collection)?void 0:o.prelude},recovered:e.recovered},i)})}_adInner(e,i=null){var t,r,l,s,n;let o=null==e||null==(t=e.collection)?void 0:t.resolve,a=(null==e||null==(r=e.options)?void 0:r.scene)??this._scene??DEFAULT_SCENT_TEXT_OBJ.inner_default_other,d=null==e||null==(l=e.collection)?void 0:l.before,h=null==e||null==(s=e.collection)?void 0:s.success,u=null==e||null==(n=e.collection)?void 0:n.prelude,_=(null==e?void 0:e.recovered)??this._recovered,c=e=>{this._clearAdTimeout(),this.adDestroy(),null==o||o(Object.assign({scene:a,adTypeR:this._adTypeR},null==e?void 0:e.resolvedValue)),null==i||i(Object.assign({scene:a},null==e?void 0:e.nextValue))},f=()=>{var t,r;this._scene=a,null==d||d({scene:a}),this._before=d,null==(t=this._onShow)||t.call(this,{scene:a}),this._adShowBeforeAnalytics({scene:a}),this._resolve=o,this._next=i,this._setAdTimeout({scene:a,end:c,timeout:null==e||null==(r=e.options)?void 0:r.timeout}),this._adPreludeInterval({scene:a,prelude:u}),this.adShow().then(()=>{this._clearAdTimeout(),null==h||h({scene:a}),this._success=h,this._adShowSuccessAnalytics({scene:a,result:1,recovered:_}),this._onInnerAdShowSuccess({scene:a,result:1,recovered:_})}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:a,msg:null==e?void 0:e.errMsg,errorCode:null==e?void 0:e.errorCode,result:0}),matchErrorWithKeywords(this._ttErrorMsgs,null==e?void 0:e.errMsg)||this._ttErrorCodes.includes(null==e?void 0:e.errorCode))?c({scene:a,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?c({scene:a,resolvedValue:{apiError:{errMsg:`[RewardAdNovel]: no remain, remain: ${this.novelConfig.remain()}, retry: ${this.novelConfig.frequency.total},
2
- tt: {errMsg: ${null==e?void 0:e.errMsg}, errorCode: ${null==e?void 0:e.errorCode}}`,errorCode:1e5}},nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:a,result:1,frequency:this.novelConfig.frequency}),f()}).catch(e=>{this._adLoadFailureAnalytics({scene:a,msg:null==e?void 0:e.errMsg,result:0}),c({scene:a,resolvedValue:{apiError:e},nextValue:null})}))})};f()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){var i;null==(i=this._alwaysCallback)||i.call(this,e)}_outerHalfwayCallback(e){var i;null==(i=this._halfwayCallback)||i.call(this,e)}_outerFinishedCallback(e){var i;null==(i=this._finishedCallback)||i.call(this,e)}__adCloseLister__(e){this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:+!!e.isEnded,ad_count:e.count});let i=Object.assign({},e,{scene:this._scene,adTypeR:this._adTypeR,end_type:e.isEnded?"finished":"halfway"}),t=e=>{var t,r;this.adDestroy(),null==(t=this._resolve)||t.call(this,Object.assign({},i,e)),this._resolve=null,null==(r=this._next)||r.call(this),this._next=null,this._success=null,this._before=null},r=e=>{var t,r,l;let s=Object.assign({},i,e);(null==s?void 0:s.isEnded)?(this._outerFinishedCallback(s),null==(r=this._onFinish)||r.call(this,s)):(this._outerHalfwayCallback(s),null==(l=this._onHalfway)||l.call(this,s)),this._outerCloseCallback(s),null==(t=this._onAlways)||t.call(this,s)};this.adCloseLister(i,{conn:r,end:t})}adCloseLister(e,i){var t,r;null==i||null==(t=i.conn)||t.call(i,e),null==i||null==(r=i.end)||r.call(i,e)}__adErrorLister__(e){var i,t,r;this._clearAdTimeout(),this._logger.error("adErrorLister",JSON.stringify(e)),this._adShowFailureAnalytics({scene:this._scene,msg:null==e?void 0:e.errMsg,errorCode:null==e?void 0:e.errorCode,result:0}),this.adErrorLister(e),this.adDestroy(),null==(i=this._onError)||i.call(this,e),null==(t=this._resolve)||t.call(this,{apiError:e,scene:this._scene,adTypeR:this._adTypeR}),this._resolve=null,null==(r=this._next)||r.call(this),this._next=null,this._success=null,this._before=null}adErrorLister(e){return e}__apiAdErrorLister__(e){var i,t,r;this._clearAdTimeout(),this._logger.error("API apiAdErrorLister:",JSON.stringify(e)),this._adShowFailureAnalytics({scene:this._scene,msg:null==e?void 0:e.errMsg,errorCode:null==e?void 0:e.errorCode,result:0}),this.apiAdErrorLister(e),this.adDestroy(),null==(i=this._onError)||i.call(this,e),null==(t=this._resolve)||t.call(this,{apiError:e,scene:this._scene,adTypeR:this._adTypeR}),this._resolve=null,null==(r=this._next)||r.call(this),this._next=null,this._success=null,this._before=null}apiAdErrorLister(e){return e}__adLoadLister__(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:null==e?void 0:e.errMsg}),this._logger.info("adLoadLister:",JSON.stringify({scene:this._scene,info:e})),this.adLoadLister(e)}adLoadLister(e){return 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._recovered=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._recovered=null,this.destroy(),this._resolve=null,this._next=null,this._success=null,this._before=null}_shiftCloseLister(e){var i,t;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._recovered=null,this.offClose(this._bindShiftCloseLister),this.destroy(),null==(i=this._resolve)||i.call(this,Object.assign({},e,{scene:this._scene,adTypeR:this._adTypeR})),this._resolve=null,null==(t=this._next)||t.call(this),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){var i,t;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._recovered=null,this.offError(this._bindShiftErrorLister),this.destroy(),null==(i=this._resolve)||i.call(this,Object.assign({},e,{scene:this._scene,adTypeR:this._adTypeR})),this._resolve=null,null==(t=this._next)||t.call(this),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=(null==e?void 0: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 src_RewardAdNovel=RewardAdNovel;class InterstitialAdNovel extends src_InterstitialAdFather{_onHalfway=null;_onShow=null;_onFinish=null;_onAlways=null;_onError=null;_logger=null;_initSign="";_alwaysCallback=null;_halfwayCallback=null;_finishedCallback=null;_resolve=null;_next=null;_scene=DEFAULT_SCENT_TEXT_OBJ.inner_default_other;_adTypeR=AD_TYPE_ENUM.AD_TYPE_INTERSTITIAL;_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){var i,t,r,l,s;super(e),this._logger=new helper_namespaceObject.Logger({prefix:"InterstitialAdNovel",enabled:!!((null==e?void 0:e.log)??!0)}),this._initSign=(null==e?void 0:e.sign)??"",this._adConfig=(null==e?void 0:e.adConfig)??{},this._needEndOnTimeout=(null==e?void 0:e.needEndOnTimeout)??!0,this._onHalfway=(null==e||null==(i=e.collection)?void 0:i.onHalfway)??null,this._onShow=(null==e||null==(t=e.collection)?void 0:t.onShow)??null,this._onFinish=(null==e||null==(r=e.collection)?void 0:r.onFinish)??null,this._onAlways=(null==e||null==(l=e.collection)?void 0:l.onAlways)??null,this._onError=(null==e||null==(s=e.collection)?void 0:s.onError)??null}initialize(e,i){return super.initialize(e,i),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:null==e?void 0:e.retry})}_onInnerExecuteBefore(){return null}_onInnerAdShowSuccess(){return null}_setAdTimeout(e){this._needSpeedEndOnTimeout&&(this._adSpeedCloseTimer=setTimeout(()=>{if("ios"==tt.getSystemInfoSync().platform){let i=()=>{tt.offAppShow(i),this._logger.warn("ad_show_timeout: ios platform close ad onAppShow, handling fallback ad case, scene:",null==e?void 0:e.scene);let t="ad_show_timeout: ios platform close ad onAppShow";this._adShowFailureAnalytics({scene:null==e?void 0:e.scene,msg:t,errorCode:100001,result:0}),this._adTimeout&&clearTimeout(this._adTimeout),null==e||e.end({resolvedValue:{apiError:{errMsg:t,errorCode:100001}},nextValue:null})};tt.onAppShow(i)}clearTimeout(this._adSpeedCloseTimer)},this._adSpeedCloseTime)),this._needEndOnTimeout&&(this._adTimeout=setTimeout(()=>{this._logger.warn("Ad show timeout, handling fallback ad case, scene:",null==e?void 0:e.scene),this._adShowFailureAnalytics({scene:null==e?void 0:e.scene,msg:`ad_show_timeout: normal, interstitial ad, timeout: ${this._adTimeoutTime}`,errorCode:100001,result:0}),null==e||e.end({resolvedValue:{apiError:{errMsg:`ad_show_timeout: normal, interstitial ad, timeout: ${this._adTimeoutTime}`,errorCode:100001}},nextValue:null})},this._adTimeoutTime))}_adPreludeInterval(e){var i;null==(i=e.prelude)||i.call(e,{scene:null==e?void 0:e.scene,frequency:this._adBeforeShowTime,time:new Date().getTime()}),this._adBeforeShowTimer=setInterval(()=>{var i;null==(i=e.prelude)||i.call(e,{scene:null==e?void 0: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)}_adShowBeforeAnalytics(e){return 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,i=null){var t,r,l;return this._alwaysCallback=null==e||null==(t=e.collection)?void 0:t.always,this._halfwayCallback=null==e||null==(r=e.collection)?void 0:r.halfway,this._finishedCallback=null==e||null==(l=e.collection)?void 0:l.finished,this._onInnerExecuteBefore(),new Promise(t=>{var r,l,s,n;this._adInner({options:{scene:null==e||null==(r=e.options)?void 0:r.scene},collection:{resolve:t,before:null==(l=e.collection)?void 0:l.before,success:null==(s=e.collection)?void 0:s.success,prelude:null==(n=e.collection)?void 0:n.prelude}},i)})}_adInner(e,i=null){var t,r,l,s,n;let o=null==e||null==(t=e.collection)?void 0:t.resolve,a=(null==e||null==(r=e.options)?void 0:r.scene)??this._scene??DEFAULT_SCENT_TEXT_OBJ.inner_default_other,d=null==e||null==(l=e.collection)?void 0:l.before,h=null==e||null==(s=e.collection)?void 0:s.success,u=null==e||null==(n=e.collection)?void 0:n.prelude,_=e=>{this._clearAdTimeout(),this.adDestroy(),null==o||o(Object.assign({scene:a,adTypeR:this._adTypeR},null==e?void 0:e.resolvedValue)),null==i||i(Object.assign({scene:a},null==e?void 0:e.nextValue))},c=()=>{var e;this._scene=a,null==d||d({scene:a}),this._before=d,null==(e=this._onShow)||e.call(this,{scene:a}),this._adShowBeforeAnalytics({scene:a}),this._resolve=o,this._next=i,this._setAdTimeout({scene:a,end:_}),this._adPreludeInterval({scene:a,prelude:u}),this.adShow().then(()=>{this._clearAdTimeout(),null==h||h({scene:a}),this._success=h,this._adShowSuccessAnalytics({scene:a,result:1}),this._onInnerAdShowSuccess()}).catch(e=>{(this._clearAdTimeout(),this._adShowFailureAnalytics({scene:a,msg:null==e?void 0:e.errMsg,errorCode:null==e?void 0:e.errorCode,result:0}),matchErrorWithKeywords(this._ttErrorMsgs,null==e?void 0:e.errMsg)||this._ttErrorCodes.includes(null==e?void 0:e.errorCode))?_({scene:a,resolvedValue:{apiError:e},nextValue:null}):0>=this.novelConfig.remain()?_({scene:a,resolvedValue:null,nextValue:null}):(this.novelConfig.updateRetry(),this.adLoad().then(()=>{this._adLoadSuccessAnalytics({scene:a,result:1}),c()}).catch(e=>{this._adLoadFailureAnalytics({scene:a,msg:null==e?void 0:e.errMsg,result:0}),_({scene:a,resolvedValue:{apiError:e},nextValue:null})}))})};c()}adLoad(){return this.load()}adShow(){return this.show()}_outerCloseCallback(e){var i;null==(i=this._alwaysCallback)||i.call(this,e)}_outerHalfwayCallback(e){var i;null==(i=this._halfwayCallback)||i.call(this,e)}_outerFinishedCallback(e){var i;null==(i=this._finishedCallback)||i.call(this,e)}adCloseLister(){var e,i,t;this._clearAdTimeout(),this._adCloseSuccessAnalytics({scene:this._scene,ad_is_completed:1});let r={scene:this._scene},l=e=>{var i,t;this.adDestroy(),null==(i=this._resolve)||i.call(this,Object.assign({},{scene:this._scene,adTypeR:this._adTypeR},e)),this._resolve=null,null==(t=this._next)||t.call(this),this._next=null,this._success=null,this._before=null};this._outerFinishedCallback(r),null==(e=this._onFinish)||e.call(this,r),this._outerHalfwayCallback(r),null==(i=this._onHalfway)||i.call(this,r),this._outerCloseCallback(r),null==(t=this._onAlways)||t.call(this,r),l({end_type:"finished"})}adErrorLister(e){var i,t,r;this._clearAdTimeout(),this._logger.error("adErrorLister",JSON.stringify(e)),this._adShowFailureAnalytics({scene:this._scene,msg:null==e?void 0:e.errMsg,errorCode:null==e?void 0:e.errorCode,result:0}),null==(i=this._onError)||i.call(this,e),0>=this.novelConfig.remain()&&(this.adDestroy(),null==(t=this._resolve)||t.call(this,{apiError:e,scene:this._scene,adTypeR:this._adTypeR}),this._resolve=null,null==(r=this._next)||r.call(this),this._next=null,this._success=null,this._before=null)}apiAdErrorLister(e){var i,t,r;this._clearAdTimeout(),this._logger.error("API apiAdErrorLister:",JSON.stringify(e)),this._adShowFailureAnalytics({scene:this._scene,msg:null==e?void 0:e.errMsg,errorCode:null==e?void 0:e.errorCode,result:0}),this.adDestroy(),null==(i=this._onError)||i.call(this,e),null==(t=this._resolve)||t.call(this,{apiError:e,scene:this._scene,adTypeR:this._adTypeR}),this._resolve=null,null==(r=this._next)||r.call(this),this._next=null,this._success=null,this._before=null}adLoadLister(e){this._adLoadSuccessAnalytics({scene:this._scene,result:1,msg:null==e?void 0:e.errMsg}),this._logger.info("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){var i,t;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(),null==(i=this._resolve)||i.call(this,Object.assign({},e,{scene:this._scene,adTypeR:this._adTypeR})),this._resolve=null,null==(t=this._next)||t.call(this),this._next=null,this._success=null,this._before=null}_shiftErrorLister(e){var i,t;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(),null==(i=this._resolve)||i.call(this,Object.assign({},e,{scene:this._scene,adTypeR:this._adTypeR})),this._resolve=null,null==(t=this._next)||t.call(this),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=(null==e?void 0: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 src_InterstitialAdNovel=InterstitialAdNovel;for(var __rspack_i in exports.InterstitialAdFather=__webpack_exports__.InterstitialAdFather,exports.InterstitialAdNovel=__webpack_exports__.InterstitialAdNovel,exports.RewardAdFather=__webpack_exports__.RewardAdFather,exports.RewardAdNovel=__webpack_exports__.RewardAdNovel,__webpack_exports__)-1===["InterstitialAdFather","InterstitialAdNovel","RewardAdFather","RewardAdNovel"].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,r)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:r[_]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__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__,{RewardAdNovel:()=>ad_reward_namespaceObject.RewardAdNovel,RewardAdFather:()=>ad_reward_namespaceObject.RewardAdFather,InterstitialAdFather:()=>ad_interstitial_namespaceObject.InterstitialAdFather,InterstitialAdNovel:()=>ad_interstitial_namespaceObject.InterstitialAdNovel,AdExecuteManager:()=>core_namespaceObject.AdExecuteManager});const core_namespaceObject=require("@ad-execute-manager/core"),ad_interstitial_namespaceObject=require("@ad-execute-manager/ad-interstitial"),ad_reward_namespaceObject=require("@ad-execute-manager/ad-reward");for(var __rspack_i in exports.AdExecuteManager=__webpack_exports__.AdExecuteManager,exports.InterstitialAdFather=__webpack_exports__.InterstitialAdFather,exports.InterstitialAdNovel=__webpack_exports__.InterstitialAdNovel,exports.RewardAdFather=__webpack_exports__.RewardAdFather,exports.RewardAdNovel=__webpack_exports__.RewardAdNovel,__webpack_exports__)-1===["AdExecuteManager","InterstitialAdFather","InterstitialAdNovel","RewardAdFather","RewardAdNovel"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { default as InterstitialAdFather } from "./InterstitialAdFather";
2
- export { default as RewardAdFather } from "./RewardAdFather";
3
- export { default as RewardAdNovel } from "./RewardAdNovel";
4
- export { default as InterstitialAdNovel } from "./InterstitialAdNovel";
1
+ export { AdExecuteManager } from "@ad-execute-manager/core";
2
+ export { InterstitialAdFather, InterstitialAdNovel } from "@ad-execute-manager/ad-interstitial";
3
+ export { RewardAdFather, RewardAdNovel } from "@ad-execute-manager/ad-reward";