@chiyou/minigame-framework 1.0.0

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