@chiyou/minigame-framework 1.0.1 → 1.0.3

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.
Files changed (114) hide show
  1. package/assets/Scripts/index.ts +2 -5
  2. package/package.json +5 -13
  3. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +0 -78
  4. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +0 -230
  5. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +0 -31
  6. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +0 -224
  7. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +0 -34
  8. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +0 -524
  9. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +0 -34
  10. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +0 -631
  11. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +0 -33
  12. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +0 -460
  13. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +0 -31
  14. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +0 -227
  15. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +0 -33
  16. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +0 -458
  17. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +0 -35
  18. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +0 -770
  19. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +0 -33
  20. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +0 -519
  21. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +0 -33
  22. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +0 -492
  23. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +0 -33
  24. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +0 -695
  25. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +0 -34
  26. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +0 -597
  27. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +0 -33
  28. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +0 -458
  29. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +0 -51
  30. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +0 -17
  31. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +0 -45
  32. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +0 -555
  33. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +0 -44
  34. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +0 -148
  35. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +0 -48
  36. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +0 -715
  37. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +0 -44
  38. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +0 -296
  39. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +0 -45
  40. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +0 -284
  41. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +0 -44
  42. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +0 -283
  43. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +0 -43
  44. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +0 -406
  45. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +0 -43
  46. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +0 -248
  47. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +0 -44
  48. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +0 -517
  49. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +0 -44
  50. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +0 -295
  51. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +0 -55
  52. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +0 -964
  53. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +0 -44
  54. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +0 -295
  55. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +0 -44
  56. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +0 -393
  57. package/dist/Framework/Definition/AdDefinition.d.ts +0 -130
  58. package/dist/Framework/Definition/AdDefinition.js +0 -208
  59. package/dist/Framework/Definition/FrameworkBase.d.ts +0 -13
  60. package/dist/Framework/Definition/FrameworkBase.js +0 -23
  61. package/dist/Framework/Definition/PrivacyDefinition.d.ts +0 -51
  62. package/dist/Framework/Definition/PrivacyDefinition.js +0 -70
  63. package/dist/Framework/Definition/SocialDefinition.d.ts +0 -16
  64. package/dist/Framework/Definition/SocialDefinition.js +0 -2
  65. package/dist/Framework/Definition/SystemDefinition.d.ts +0 -43
  66. package/dist/Framework/Definition/SystemDefinition.js +0 -28
  67. package/dist/Framework/Definition/UIDefinition.d.ts +0 -6
  68. package/dist/Framework/Definition/UIDefinition.js +0 -7
  69. package/dist/Framework/Definition/UserDefinition.d.ts +0 -14
  70. package/dist/Framework/Definition/UserDefinition.js +0 -10
  71. package/dist/Framework/Manager/AdMgr.d.ts +0 -57
  72. package/dist/Framework/Manager/AdMgr.js +0 -684
  73. package/dist/Framework/Manager/AudioMgr.d.ts +0 -28
  74. package/dist/Framework/Manager/AudioMgr.js +0 -265
  75. package/dist/Framework/Manager/BaseMgr.d.ts +0 -18
  76. package/dist/Framework/Manager/BaseMgr.js +0 -114
  77. package/dist/Framework/Manager/EventMgr.d.ts +0 -18
  78. package/dist/Framework/Manager/EventMgr.js +0 -90
  79. package/dist/Framework/Manager/ExcelMgr.d.ts +0 -24
  80. package/dist/Framework/Manager/ExcelMgr.js +0 -156
  81. package/dist/Framework/Manager/LifeCycleMgr.d.ts +0 -20
  82. package/dist/Framework/Manager/LifeCycleMgr.js +0 -110
  83. package/dist/Framework/Manager/NodePoolMgr.d.ts +0 -53
  84. package/dist/Framework/Manager/NodePoolMgr.js +0 -279
  85. package/dist/Framework/Manager/PrivacyMgr.d.ts +0 -15
  86. package/dist/Framework/Manager/PrivacyMgr.js +0 -176
  87. package/dist/Framework/Manager/ResMgr.d.ts +0 -49
  88. package/dist/Framework/Manager/ResMgr.js +0 -337
  89. package/dist/Framework/Manager/SocialMgr.d.ts +0 -23
  90. package/dist/Framework/Manager/SocialMgr.js +0 -220
  91. package/dist/Framework/Manager/SystemMgr.d.ts +0 -24
  92. package/dist/Framework/Manager/SystemMgr.js +0 -222
  93. package/dist/Framework/Manager/TimerMgr.d.ts +0 -11
  94. package/dist/Framework/Manager/TimerMgr.js +0 -63
  95. package/dist/Framework/Manager/UIMgr.d.ts +0 -33
  96. package/dist/Framework/Manager/UIMgr.js +0 -223
  97. package/dist/Framework/Manager/UserMgr.d.ts +0 -15
  98. package/dist/Framework/Manager/UserMgr.js +0 -148
  99. package/dist/Framework/Utils/BezierUtils.d.ts +0 -49
  100. package/dist/Framework/Utils/BezierUtils.js +0 -247
  101. package/dist/Framework/Utils/CSVUtils.d.ts +0 -35
  102. package/dist/Framework/Utils/CSVUtils.js +0 -341
  103. package/dist/Framework/Utils/LogUtils.d.ts +0 -7
  104. package/dist/Framework/Utils/LogUtils.js +0 -32
  105. package/dist/Framework/Utils/NumberUtils.d.ts +0 -16
  106. package/dist/Framework/Utils/NumberUtils.js +0 -44
  107. package/dist/Framework/Utils/TaskUtils.d.ts +0 -10
  108. package/dist/Framework/Utils/TaskUtils.js +0 -24
  109. package/dist/Framework/Utils/TimeUtils.d.ts +0 -19
  110. package/dist/Framework/Utils/TimeUtils.js +0 -33
  111. package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +0 -12
  112. package/dist/Framework/Utils/WXBizDataCryptUtils.js +0 -37
  113. package/dist/index.d.ts +0 -30
  114. package/dist/index.js +0 -35
@@ -1,524 +0,0 @@
1
- import { AbsAdAdapter, InterstitialAdStatus, RewardedVideoAdStatus } from './AbsAdAdapter';
2
- import { LogUtils } from '../../Utils/LogUtils';
3
- import { AdDefinition, InterstitialAd_Callback_Status, RewardedVideoAd_Callback_Status } from '../../Definition/AdDefinition';
4
- import { PlatformID } from '../../Definition/SystemDefinition';
5
- class TTBannerAd {
6
- constructor(adUnitId, ad, isFirstLoad) {
7
- this.unitId = adUnitId;
8
- this.ad = ad;
9
- this.errorListener = null;
10
- this.loadListener = null;
11
- this.resizeListener = null;
12
- this.isRecreating = false;
13
- this.isFirstLoad = isFirstLoad;
14
- }
15
- destroy() {
16
- if (this.ad !== null) {
17
- if (this.errorListener !== null) {
18
- this.ad.offError(this.errorListener);
19
- this.errorListener = null;
20
- }
21
- if (this.loadListener !== null) {
22
- this.ad.offLoad(this.loadListener);
23
- this.loadListener = null;
24
- }
25
- if (this.resizeListener !== null) {
26
- this.ad.offResize(this.resizeListener);
27
- this.resizeListener = null;
28
- }
29
- this.ad.destroy();
30
- this.ad = null;
31
- }
32
- this.isRecreating = false;
33
- }
34
- }
35
- class TTInterstitialAd {
36
- constructor(adUnitId, callback) {
37
- this.unitId = adUnitId;
38
- this.ad = null;
39
- this.status = InterstitialAdStatus.Status_Destroyed;
40
- this.callback = callback;
41
- this.errorListener = null;
42
- this.loadListener = null;
43
- this.closeListener = null;
44
- this.isShowImmediately = false;
45
- }
46
- destroy() {
47
- if (this.ad !== null) {
48
- if (this.errorListener !== null) {
49
- this.ad.offError(this.errorListener);
50
- this.errorListener = null;
51
- }
52
- if (this.loadListener !== null) {
53
- this.ad.offLoad(this.loadListener);
54
- this.loadListener = null;
55
- }
56
- if (this.closeListener !== null) {
57
- this.ad.offClose(this.closeListener);
58
- this.closeListener = null;
59
- }
60
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.destroy()");
61
- this.ad.destroy().then(() => {
62
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.destroy() success");
63
- this.ad = null;
64
- this.isShowImmediately = false;
65
- this.status = InterstitialAdStatus.Status_Destroyed;
66
- }).catch((err) => {
67
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.destroy() fail");
68
- if (err) {
69
- LogUtils.Instance.log("", err);
70
- }
71
- });
72
- }
73
- }
74
- }
75
- class TTRewardedVideoAd {
76
- constructor(adUnitId, callback) {
77
- this.unitId = adUnitId;
78
- this.ad = null;
79
- this.status = RewardedVideoAdStatus.Status_Destroyed;
80
- this.callback = callback;
81
- this.errorListener = null;
82
- this.loadListener = null;
83
- this.closeListener = null;
84
- this.isShowImmediately = false;
85
- }
86
- destroy() {
87
- if (this.ad !== null) {
88
- if (this.errorListener !== null) {
89
- this.ad.offError(this.errorListener);
90
- this.errorListener = null;
91
- }
92
- if (this.loadListener !== null) {
93
- this.ad.offLoad(this.loadListener);
94
- this.loadListener = null;
95
- }
96
- if (this.closeListener !== null) {
97
- this.ad.offClose(this.closeListener);
98
- this.closeListener = null;
99
- }
100
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.destroy()");
101
- this.ad.destroy().then(() => {
102
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.destroy() success");
103
- this.ad = null;
104
- this.isShowImmediately = false;
105
- this.status = RewardedVideoAdStatus.Status_Destroyed;
106
- }).catch((err) => {
107
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.destroy() fail");
108
- if (err) {
109
- LogUtils.Instance.log("", err);
110
- }
111
- });
112
- }
113
- }
114
- }
115
- export class AdAdapterDouYin extends AbsAdAdapter {
116
- constructor() {
117
- super(...arguments);
118
- this.ttInterstitialAd = null;
119
- this.ttRewardedVideoAd = null;
120
- this.ttBannerAds = [];
121
- }
122
- init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
123
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "init()");
124
- this.ttInterstitialAd = new TTInterstitialAd(interstitialAdUnitId, interstitialAdCallback);
125
- this.ttRewardedVideoAd = new TTRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
126
- this.ttBannerAds = [];
127
- }
128
- createBannerAd(adUnitId) {
129
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "createBannerAd()");
130
- let isFirstLoad = true;
131
- for (let i = 0; i < this.ttBannerAds.length; i++) {
132
- if (this.ttBannerAds[i].unitId === adUnitId) {
133
- isFirstLoad = this.ttBannerAds[i].isFirstLoad;
134
- break;
135
- }
136
- }
137
- this.destroyBannerAd(adUnitId);
138
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "createBannerAd() adUnitId=" + adUnitId);
139
- let bannerAdInfo = AdDefinition.AdInfoConfig.BannerAd_Info;
140
- if (bannerAdInfo === null || !bannerAdInfo.shouldShow) {
141
- return false;
142
- }
143
- let bannerAdPlatformInfo = AdDefinition.BannerAdStyleConfig.get(PlatformID.ID_MiniGame_DouYin);
144
- if (bannerAdPlatformInfo === null) {
145
- return false;
146
- }
147
- let bannerAdPosition = this.calcBannerAdPosition(bannerAdInfo, bannerAdPlatformInfo);
148
- let bannerAdParam = {
149
- adUnitId: adUnitId,
150
- style: {
151
- width: bannerAdPosition.realWidth,
152
- left: bannerAdPosition.left,
153
- top: bannerAdPosition.top,
154
- },
155
- };
156
- if (bannerAdPlatformInfo.canAutoRefresh) {
157
- bannerAdParam.adIntervals = bannerAdPlatformInfo.refreshInterval;
158
- }
159
- let bannerAd = window["tt"].createBannerAd(bannerAdParam);
160
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "tt.createBannerAd() " + (bannerAd !== null ? "success" : "fail"));
161
- LogUtils.Instance.log("", bannerAd);
162
- if (!bannerAd) {
163
- return false;
164
- }
165
- let ttBannerAd = new TTBannerAd(adUnitId, bannerAd, isFirstLoad);
166
- this.ttBannerAds.push(ttBannerAd);
167
- ttBannerAd.errorListener = (err) => {
168
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttBannerAd.ad.onError()");
169
- if (err) {
170
- LogUtils.Instance.log("", err);
171
- }
172
- if (!ttBannerAd.isRecreating) {
173
- ttBannerAd.isRecreating = true;
174
- this.scheduleOnce(() => {
175
- ttBannerAd.isRecreating = false;
176
- this.createBannerAd(adUnitId);
177
- }, 15);
178
- }
179
- };
180
- ttBannerAd.ad.onError(ttBannerAd.errorListener);
181
- ttBannerAd.loadListener = () => {
182
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttBannerAd.ad.onLoad()");
183
- };
184
- ttBannerAd.ad.onLoad(ttBannerAd.loadListener);
185
- ttBannerAd.resizeListener = (res) => {
186
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttBannerAd.ad.onResize()");
187
- if (res) {
188
- LogUtils.Instance.log("", res);
189
- }
190
- };
191
- ttBannerAd.ad.onResize(ttBannerAd.resizeListener);
192
- if (!bannerAdPlatformInfo.canAutoRefresh) {
193
- if (!ttBannerAd.isRecreating) {
194
- ttBannerAd.isRecreating = true;
195
- this.scheduleOnce(() => {
196
- ttBannerAd.isRecreating = false;
197
- this.createBannerAd(adUnitId);
198
- }, bannerAdPlatformInfo.refreshInterval);
199
- }
200
- }
201
- return true;
202
- }
203
- destroyBannerAd(adUnitId) {
204
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "destroyBannerAd(): adUnitId=" + adUnitId);
205
- let index = -1;
206
- for (let i = 0; i < this.ttBannerAds.length; i++) {
207
- if (this.ttBannerAds[i].unitId === adUnitId) {
208
- index = i;
209
- break;
210
- }
211
- }
212
- if (index >= 0) {
213
- this.ttBannerAds[index].destroy();
214
- this.ttBannerAds.splice(index, 1);
215
- }
216
- }
217
- showBannerAd(adUnitId) {
218
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "showBannerAd(): adUnitId=" + adUnitId);
219
- for (let i = 0; i < this.ttBannerAds.length; i++) {
220
- if (this.ttBannerAds[i].unitId === adUnitId) {
221
- this.ttBannerAds[i].ad.show();
222
- break;
223
- }
224
- }
225
- }
226
- hideBannerAd(adUnitId) {
227
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "hideBannerAd(): adUnitId=" + adUnitId);
228
- for (let i = 0; i < this.ttBannerAds.length; i++) {
229
- if (this.ttBannerAds[i].unitId === adUnitId) {
230
- this.ttBannerAds[i].ad.hide();
231
- break;
232
- }
233
- }
234
- }
235
- createInterstitialAd() {
236
- this.destroyInterstitialAd();
237
- let checkDestroyed = () => {
238
- if (this.ttInterstitialAd.status === InterstitialAdStatus.Status_Destroyed) {
239
- this.unschedule(checkDestroyed);
240
- this._createInterstitialAd();
241
- }
242
- };
243
- this.schedule(checkDestroyed, 1, 5);
244
- }
245
- _createInterstitialAd() {
246
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "createInterstitialAd() adUnitId=" + this.ttInterstitialAd.unitId);
247
- let interstitialAd = window["tt"].createInterstitialAd({
248
- adUnitId: this.ttInterstitialAd.unitId
249
- });
250
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "tt.createInterstitialAd() " + (interstitialAd !== null ? "success" : "fail"));
251
- LogUtils.Instance.log("", interstitialAd);
252
- if (!interstitialAd) {
253
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Error;
254
- this.ttInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
255
- return;
256
- }
257
- this.ttInterstitialAd.ad = interstitialAd;
258
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Init;
259
- this.ttInterstitialAd.errorListener = (err) => {
260
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.onError()");
261
- if (err) {
262
- LogUtils.Instance.log("", err);
263
- }
264
- if (this.ttInterstitialAd.status !== InterstitialAdStatus.Status_Watching) {
265
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Error;
266
- this.ttInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
267
- }
268
- };
269
- this.ttInterstitialAd.ad.onError(this.ttInterstitialAd.errorListener);
270
- this.ttInterstitialAd.loadListener = () => {
271
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.onLoad()");
272
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
273
- if (this.ttInterstitialAd.isShowImmediately) {
274
- this.ttInterstitialAd.isShowImmediately = false;
275
- this._showInterstitialAd();
276
- }
277
- };
278
- this.ttInterstitialAd.ad.onLoad(this.ttInterstitialAd.loadListener);
279
- this.ttInterstitialAd.closeListener = () => {
280
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.onClose()");
281
- this.ttInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Close);
282
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Watched;
283
- this.createInterstitialAd();
284
- };
285
- this.ttInterstitialAd.ad.onClose(this.ttInterstitialAd.closeListener);
286
- this.scheduleOnce(() => {
287
- if (this.ttInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
288
- this._loadInterstitialAd(false);
289
- }
290
- }, 2);
291
- }
292
- showInterstitialAd() {
293
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "showInterstitialAd()");
294
- if (this.ttInterstitialAd.ad === null) {
295
- return;
296
- }
297
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.status=" + InterstitialAdStatus[this.ttInterstitialAd.status]);
298
- switch (this.ttInterstitialAd.status) {
299
- case InterstitialAdStatus.Status_Destroyed:
300
- case InterstitialAdStatus.Status_Watching:
301
- case InterstitialAdStatus.Status_StartToWatch:
302
- break;
303
- case InterstitialAdStatus.Status_Loaded:
304
- this._showInterstitialAd();
305
- break;
306
- case InterstitialAdStatus.Status_Watched:
307
- this.createInterstitialAd();
308
- break;
309
- case InterstitialAdStatus.Status_Error:
310
- case InterstitialAdStatus.Status_Init:
311
- this._loadInterstitialAd(true);
312
- break;
313
- default:
314
- break;
315
- }
316
- }
317
- destroyInterstitialAd() {
318
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "destroyInterstitialAd()");
319
- this.ttInterstitialAd.destroy();
320
- }
321
- isIntersititialAdShowing() {
322
- if (this.ttInterstitialAd.ad === null) {
323
- return false;
324
- }
325
- if (this.ttInterstitialAd.status === InterstitialAdStatus.Status_Watching) {
326
- return true;
327
- }
328
- return false;
329
- }
330
- _loadInterstitialAd(isShowImmediately) {
331
- this.ttInterstitialAd.isShowImmediately = isShowImmediately;
332
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.load()");
333
- this.ttInterstitialAd.ad.load()
334
- .then(() => {
335
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.load() success");
336
- }).catch((err) => {
337
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.load() error");
338
- if (err) {
339
- LogUtils.Instance.log("", err);
340
- }
341
- });
342
- }
343
- _showInterstitialAd() {
344
- if (this.ttInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
345
- return;
346
- }
347
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_StartToWatch;
348
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.show()");
349
- this.ttInterstitialAd.ad.show()
350
- .then(() => {
351
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.show() success");
352
- if (this.ttInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
353
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Watching;
354
- this.ttInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Watching);
355
- }
356
- }).catch((err) => {
357
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttInterstitialAd.ad.show() error");
358
- if (err) {
359
- LogUtils.Instance.log("", err);
360
- }
361
- if (this.ttInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
362
- this.ttInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
363
- }
364
- });
365
- }
366
- createRewardedVideoAd() {
367
- this.destroyRewardedVideoAd();
368
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "createRewardedVideoAd() adUnitId=" + this.ttRewardedVideoAd.unitId);
369
- let rewardedVideoAd = window["tt"].createRewardedVideoAd({
370
- adUnitId: this.ttRewardedVideoAd.unitId
371
- });
372
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "tt.createRewardedVideoAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
373
- LogUtils.Instance.log("", rewardedVideoAd);
374
- if (!rewardedVideoAd) {
375
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
376
- this.ttRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
377
- return;
378
- }
379
- this.ttRewardedVideoAd.ad = rewardedVideoAd;
380
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
381
- this.ttRewardedVideoAd.errorListener = (err) => {
382
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.onError()");
383
- if (err) {
384
- LogUtils.Instance.log("", err);
385
- }
386
- if (this.ttRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
387
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
388
- this.ttRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
389
- }
390
- };
391
- this.ttRewardedVideoAd.ad.onError(this.ttRewardedVideoAd.errorListener);
392
- this.ttRewardedVideoAd.loadListener = () => {
393
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.onLoad()");
394
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
395
- if (this.ttRewardedVideoAd.isShowImmediately) {
396
- this.ttRewardedVideoAd.isShowImmediately = false;
397
- this._showRewardedVideoAd();
398
- }
399
- };
400
- this.ttRewardedVideoAd.ad.onLoad(this.ttRewardedVideoAd.loadListener);
401
- this.ttRewardedVideoAd.closeListener = (res) => {
402
- let isEnded = (res !== null) ? res.isEnded : false;
403
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.onClose()");
404
- LogUtils.Instance.log("", "isEnded=" + isEnded);
405
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
406
- if (isEnded) {
407
- this.ttRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
408
- }
409
- else {
410
- this.ttRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
411
- }
412
- this.scheduleOnce(() => {
413
- if (this.ttRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
414
- this._loadRewardedVideoAd(false);
415
- }
416
- }, 2);
417
- };
418
- this.ttRewardedVideoAd.ad.onClose(this.ttRewardedVideoAd.closeListener);
419
- this.scheduleOnce(() => {
420
- if (this.ttRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
421
- this._loadRewardedVideoAd(false);
422
- }
423
- }, 2);
424
- }
425
- showRewardedVideoAd() {
426
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "showRewardedVideoAd()");
427
- if (this.ttRewardedVideoAd.ad === null) {
428
- return;
429
- }
430
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.status=" + RewardedVideoAdStatus[this.ttRewardedVideoAd.status]);
431
- switch (this.ttRewardedVideoAd.status) {
432
- case RewardedVideoAdStatus.Status_Destroyed:
433
- case RewardedVideoAdStatus.Status_Watching:
434
- case RewardedVideoAdStatus.Status_StartToWatch:
435
- break;
436
- case RewardedVideoAdStatus.Status_Loaded:
437
- this._showRewardedVideoAd();
438
- break;
439
- case RewardedVideoAdStatus.Status_Error:
440
- case RewardedVideoAdStatus.Status_Init:
441
- case RewardedVideoAdStatus.Status_Watched:
442
- this._loadRewardedVideoAd(true);
443
- break;
444
- default:
445
- break;
446
- }
447
- }
448
- destroyRewardedVideoAd() {
449
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "destroyRewardedVideoAd()");
450
- this.ttRewardedVideoAd.destroy();
451
- }
452
- isRewardedVideoAdLoaded() {
453
- if (this.ttRewardedVideoAd.ad === null) {
454
- return false;
455
- }
456
- if (this.ttRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
457
- return true;
458
- }
459
- return false;
460
- }
461
- isRewardedVideoAdShowing() {
462
- if (this.ttRewardedVideoAd.ad === null) {
463
- return false;
464
- }
465
- if (this.ttRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
466
- return true;
467
- }
468
- return false;
469
- }
470
- _loadRewardedVideoAd(isShowImmediately) {
471
- this.ttRewardedVideoAd.isShowImmediately = isShowImmediately;
472
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.load()");
473
- this.ttRewardedVideoAd.ad.load()
474
- .then(() => {
475
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.load() success");
476
- }).catch((err) => {
477
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.load() error");
478
- if (err) {
479
- LogUtils.Instance.log("", err);
480
- }
481
- });
482
- }
483
- _showRewardedVideoAd() {
484
- if (this.ttRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
485
- return;
486
- }
487
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_StartToWatch;
488
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.show()");
489
- this.ttRewardedVideoAd.ad.show()
490
- .then(() => {
491
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.show() success");
492
- if (this.ttRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
493
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
494
- this.ttRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
495
- }
496
- }).catch((err) => {
497
- LogUtils.Instance.log(AdAdapterDouYin.TAG, "ttRewardedVideoAd.ad.show() error");
498
- if (err) {
499
- LogUtils.Instance.log("", err);
500
- }
501
- if (this.ttRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
502
- this.ttRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
503
- }
504
- });
505
- }
506
- createCustomAd(adUnitId) {
507
- return false;
508
- }
509
- destroyCustomAd(adUnitId) {
510
- }
511
- showCustomAd(adUnitId) {
512
- }
513
- hideCustomAd(adUnitId) {
514
- }
515
- createPortalAd(adUnitId) {
516
- }
517
- destroyPortalAd(adUnitId) {
518
- }
519
- showPortalAd(adUnitId) {
520
- }
521
- hidePortalAd(adUnitId) {
522
- }
523
- }
524
- AdAdapterDouYin.TAG = "AdAdapterDouYin";
@@ -1,34 +0,0 @@
1
- import { AbsAdAdapter } from "./AbsAdAdapter";
2
- export declare class AdAdapterHonor extends AbsAdAdapter {
3
- static TAG: string;
4
- private honorInterstitialAd;
5
- private honorRewardedVideoAd;
6
- private honorBannerAds;
7
- private honorPortalAds;
8
- init(interstitialAdUnitId: string, interstitialAdCallback: Function, rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void;
9
- createBannerAd(adUnitId: string): boolean;
10
- destroyBannerAd(adUnitId: string): void;
11
- showBannerAd(adUnitId: string): void;
12
- hideBannerAd(adUnitId: string): void;
13
- createInterstitialAd(): void;
14
- showInterstitialAd(): void;
15
- destroyInterstitialAd(): void;
16
- isIntersititialAdShowing(): boolean;
17
- protected _loadInterstitialAd(isShowImmediately: boolean): void;
18
- protected _showInterstitialAd(): void;
19
- createRewardedVideoAd(): void;
20
- showRewardedVideoAd(): void;
21
- destroyRewardedVideoAd(): void;
22
- isRewardedVideoAdLoaded(): boolean;
23
- isRewardedVideoAdShowing(): boolean;
24
- protected _loadRewardedVideoAd(isShowImmediately: boolean): void;
25
- protected _showRewardedVideoAd(): void;
26
- createCustomAd(adUnitId: string): boolean;
27
- destroyCustomAd(adUnitId: string): void;
28
- showCustomAd(adUnitId: string): void;
29
- hideCustomAd(adUnitId: string): void;
30
- createPortalAd(adUnitId: string): void;
31
- destroyPortalAd(adUnitId: string): void;
32
- showPortalAd(adUnitId: string): void;
33
- hidePortalAd(adUnitId: string): void;
34
- }