@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,12 +1,9 @@
1
1
  /**
2
- * MiniGameFramework - 基于 Cocos Creator 3.x 的小游戏开发框架
2
+ * MiniGameFramework - 入口文件
3
3
  *
4
- * @module MiniGameFramework
4
+ * 导出所有框架模块,保持与原有 import 路径兼容
5
5
  */
6
6
 
7
- // Framework 入口文件
8
- // 用于导出所有框架模块
9
-
10
7
  // Manager 模块
11
8
  export { ResMgr } from './Framework/Manager/ResMgr';
12
9
  export { UIMgr, UICtrl } from './Framework/Manager/UIMgr';
package/package.json CHANGED
@@ -1,19 +1,14 @@
1
1
  {
2
2
  "name": "@chiyou/minigame-framework",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "基于 Cocos Creator 3.x 的小游戏开发框架,支持多平台发布",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "assets/Scripts/index.js",
6
+ "types": "assets/Scripts/index.d.ts",
7
7
  "exports": {
8
- ".": "./dist/index.js",
9
- "./Adapter/*": "./dist/Adapter/*.js",
10
- "./Manager/*": "./dist/Manager/*.js",
11
- "./Utils/*": "./dist/Utils/*.js",
12
- "./Definition/*": "./dist/Definition/*.js"
8
+ ".": "./assets/Scripts/index.js"
13
9
  },
14
10
  "files": [
15
- "assets",
16
- "dist"
11
+ "assets"
17
12
  ],
18
13
  "scripts": {
19
14
  "build": "tsc || true",
@@ -28,9 +23,6 @@
28
23
  ],
29
24
  "author": "chiyou",
30
25
  "license": "MIT",
31
- "peerDependencies": {
32
- "cc": ">=3.8.0"
33
- },
34
26
  "devDependencies": {
35
27
  "typescript": "^5.0.0"
36
28
  },
@@ -1,78 +0,0 @@
1
- import { Component } from "cc";
2
- import { BannerAd_Info, BannerAd_PlatformInfo, CustomAd_Info, CustomAd_PlatformInfo, PortalAd_PlatformInfo } from "../../Definition/AdDefinition";
3
- import { ScreenInfo } from "../../Definition/SystemDefinition";
4
- import { AdMgr } from "../../Manager/AdMgr";
5
- import { AbsPlatformAdapter } from "../PlatformAdapter/AbsPlatformAdapter";
6
- export declare enum InterstitialAdStatus {
7
- Status_Error = -1,
8
- Status_Init = 0,
9
- Status_Loaded = 1,
10
- Status_StartToWatch = 2,
11
- Status_Watching = 3,
12
- Status_Watched = 4,
13
- Status_Destroyed = 5
14
- }
15
- export declare enum RewardedVideoAdStatus {
16
- Status_Error = -1,
17
- Status_Init = 0,
18
- Status_Loaded = 1,
19
- Status_StartToWatch = 2,
20
- Status_Watching = 3,
21
- Status_Watched = 4,
22
- Status_Destroyed = 5
23
- }
24
- export type BannerAdPosition = {
25
- realWidth: number;
26
- realHeight: number;
27
- left: number;
28
- top: number;
29
- };
30
- export type CustomAdPosition = {
31
- realWidth: number;
32
- realHeight: number;
33
- left: number;
34
- top: number;
35
- };
36
- export type PortalAdPosition = {
37
- realWidth: number;
38
- realHeight: number;
39
- left: number;
40
- top: number;
41
- };
42
- export declare abstract class AbsAdAdapter extends Component {
43
- protected static TAG: string;
44
- protected screenInfo: ScreenInfo;
45
- protected adMgr: AdMgr;
46
- protected platformAdapter: AbsPlatformAdapter;
47
- protected onLoad(): void;
48
- onInit(screenInfo: ScreenInfo, adMgr: AdMgr, interstitialAdUnitId: string, interstitialAdCallback: Function, rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void;
49
- abstract init(interstitialAdUnitId: string, interstitialAdCallback: Function, rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void;
50
- abstract createBannerAd(adUnitId: string): boolean;
51
- abstract destroyBannerAd(adUnitId: string): void;
52
- abstract showBannerAd(adUnitId: string): void;
53
- abstract hideBannerAd(adUnitId: string): void;
54
- abstract createInterstitialAd(): void;
55
- abstract showInterstitialAd(): void;
56
- abstract destroyInterstitialAd(): void;
57
- abstract isIntersititialAdShowing(): boolean;
58
- protected abstract _loadInterstitialAd(isShowImmediately: boolean): void;
59
- protected abstract _showInterstitialAd(): void;
60
- abstract createRewardedVideoAd(): void;
61
- abstract showRewardedVideoAd(): void;
62
- abstract destroyRewardedVideoAd(): void;
63
- abstract isRewardedVideoAdLoaded(): boolean;
64
- abstract isRewardedVideoAdShowing(): boolean;
65
- protected abstract _loadRewardedVideoAd(isShowImmediately: boolean): void;
66
- protected abstract _showRewardedVideoAd(): void;
67
- abstract createCustomAd(adUnitId: string): boolean;
68
- abstract destroyCustomAd(adUnitId: string): void;
69
- abstract showCustomAd(adUnitId: string): void;
70
- abstract hideCustomAd(adUnitId: string): void;
71
- abstract createPortalAd(adUnitId: string): void;
72
- abstract destroyPortalAd(adUnitId: string): void;
73
- abstract showPortalAd(adUnitId: string): void;
74
- abstract hidePortalAd(adUnitId: string): void;
75
- calcBannerAdPosition(bannerAdInfo: BannerAd_Info, bannerAdPlatformInfo: BannerAd_PlatformInfo): BannerAdPosition;
76
- calcCustomAdPosition(customAdInfo: CustomAd_Info, customAdPlatformInfo: CustomAd_PlatformInfo): CustomAdPosition;
77
- calcPortalAdPosition(portalAdPlatformInfo: PortalAd_PlatformInfo): PortalAdPosition;
78
- }
@@ -1,230 +0,0 @@
1
- import { Component } from "cc";
2
- import { BannerAd_XPosition, BannerAd_YPosition, CustomAd_XPosition, CustomAd_YPosition } from "../../Definition/AdDefinition";
3
- import { BaseMgr } from "../../Manager/BaseMgr";
4
- export var InterstitialAdStatus;
5
- (function (InterstitialAdStatus) {
6
- InterstitialAdStatus[InterstitialAdStatus["Status_Error"] = -1] = "Status_Error";
7
- InterstitialAdStatus[InterstitialAdStatus["Status_Init"] = 0] = "Status_Init";
8
- InterstitialAdStatus[InterstitialAdStatus["Status_Loaded"] = 1] = "Status_Loaded";
9
- InterstitialAdStatus[InterstitialAdStatus["Status_StartToWatch"] = 2] = "Status_StartToWatch";
10
- InterstitialAdStatus[InterstitialAdStatus["Status_Watching"] = 3] = "Status_Watching";
11
- InterstitialAdStatus[InterstitialAdStatus["Status_Watched"] = 4] = "Status_Watched";
12
- InterstitialAdStatus[InterstitialAdStatus["Status_Destroyed"] = 5] = "Status_Destroyed";
13
- })(InterstitialAdStatus || (InterstitialAdStatus = {}));
14
- export var RewardedVideoAdStatus;
15
- (function (RewardedVideoAdStatus) {
16
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_Error"] = -1] = "Status_Error";
17
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_Init"] = 0] = "Status_Init";
18
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_Loaded"] = 1] = "Status_Loaded";
19
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_StartToWatch"] = 2] = "Status_StartToWatch";
20
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_Watching"] = 3] = "Status_Watching";
21
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_Watched"] = 4] = "Status_Watched";
22
- RewardedVideoAdStatus[RewardedVideoAdStatus["Status_Destroyed"] = 5] = "Status_Destroyed";
23
- })(RewardedVideoAdStatus || (RewardedVideoAdStatus = {}));
24
- export class AbsAdAdapter extends Component {
25
- constructor() {
26
- super(...arguments);
27
- this.screenInfo = null;
28
- this.adMgr = null;
29
- this.platformAdapter = null;
30
- }
31
- onLoad() {
32
- }
33
- onInit(screenInfo, adMgr, interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
34
- this.screenInfo = screenInfo;
35
- this.adMgr = adMgr;
36
- this.platformAdapter = BaseMgr.Instance.getPlatformAdapter();
37
- this.init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback);
38
- }
39
- calcBannerAdPosition(bannerAdInfo, bannerAdPlatformInfo) {
40
- let xPosition = bannerAdInfo.xPosition;
41
- let yPosition = bannerAdInfo.yPosition;
42
- let xMargin = bannerAdPlatformInfo.xMargin;
43
- let yMargin = bannerAdPlatformInfo.yMargin;
44
- let width = bannerAdPlatformInfo.width;
45
- let height = bannerAdPlatformInfo.height;
46
- let adScaleRatio = bannerAdPlatformInfo.scaleRatio;
47
- let left = 0;
48
- let top = 0;
49
- let realWidth = 0;
50
- let realHeight = 0;
51
- if (adScaleRatio === 0) {
52
- realWidth = width;
53
- if (this.screenInfo !== null) {
54
- realWidth = this.screenInfo.windowWidth - xMargin * 2;
55
- }
56
- realHeight = height * realWidth / width;
57
- left = xMargin;
58
- switch (yPosition) {
59
- case BannerAd_YPosition.Top:
60
- top = yMargin;
61
- break;
62
- case BannerAd_YPosition.Center:
63
- top = yMargin;
64
- if (this.screenInfo !== null) {
65
- top = this.screenInfo.windowHeight / 2 - realHeight / 2;
66
- }
67
- break;
68
- case BannerAd_YPosition.Bottom:
69
- top = yMargin;
70
- if (this.screenInfo !== null) {
71
- top = this.screenInfo.windowHeight - realHeight - yMargin;
72
- }
73
- break;
74
- }
75
- }
76
- else {
77
- realWidth = width * adScaleRatio;
78
- realHeight = height * adScaleRatio;
79
- switch (yPosition) {
80
- case BannerAd_YPosition.Top:
81
- top = yMargin;
82
- break;
83
- case BannerAd_YPosition.Center:
84
- top = yMargin;
85
- if (this.screenInfo !== null) {
86
- top = this.screenInfo.windowHeight / 2 - realHeight / 2;
87
- }
88
- break;
89
- case BannerAd_YPosition.Bottom:
90
- top = yMargin;
91
- if (this.screenInfo !== null) {
92
- top = this.screenInfo.windowHeight - realHeight - yMargin;
93
- }
94
- break;
95
- }
96
- switch (xPosition) {
97
- case BannerAd_XPosition.Left:
98
- left = xMargin;
99
- break;
100
- case BannerAd_XPosition.Center:
101
- left = xMargin;
102
- if (this.screenInfo !== null) {
103
- left = this.screenInfo.windowWidth / 2 - realWidth / 2;
104
- }
105
- break;
106
- case BannerAd_XPosition.Right:
107
- left = xMargin;
108
- if (this.screenInfo !== null) {
109
- left = this.screenInfo.windowWidth - realWidth - xMargin;
110
- }
111
- break;
112
- }
113
- }
114
- let posInfo = {
115
- realWidth: realWidth,
116
- realHeight: realHeight,
117
- left: left,
118
- top: top,
119
- };
120
- return posInfo;
121
- }
122
- calcCustomAdPosition(customAdInfo, customAdPlatformInfo) {
123
- let xPosition = customAdInfo.xPostion;
124
- let yPosition = customAdInfo.yPostion;
125
- let xMargin = customAdPlatformInfo.xMargin;
126
- let yMargin = customAdPlatformInfo.yMargin;
127
- let width = customAdPlatformInfo.width;
128
- let height = customAdPlatformInfo.height;
129
- let adScaleRatio = customAdPlatformInfo.scaleRatio;
130
- let top = 0;
131
- let left = 0;
132
- let realWidth = 0;
133
- let realHeight = 0;
134
- if (adScaleRatio === 0) {
135
- realWidth = width;
136
- if (this.screenInfo !== null) {
137
- realWidth = this.screenInfo.windowWidth - xMargin * 2;
138
- }
139
- realHeight = height * realWidth / width;
140
- left = xMargin;
141
- switch (yPosition) {
142
- case CustomAd_YPosition.Top:
143
- top = yMargin;
144
- break;
145
- case CustomAd_YPosition.Center:
146
- top = yMargin;
147
- if (this.screenInfo !== null) {
148
- top = this.screenInfo.windowHeight / 2 - realHeight / 2;
149
- }
150
- break;
151
- case CustomAd_YPosition.Bottom:
152
- top = yMargin;
153
- if (this.screenInfo !== null) {
154
- top = this.screenInfo.windowHeight - realHeight - yMargin;
155
- }
156
- break;
157
- }
158
- }
159
- else {
160
- realWidth = width * adScaleRatio;
161
- realHeight = height * adScaleRatio;
162
- switch (yPosition) {
163
- case CustomAd_YPosition.Top:
164
- top = yMargin;
165
- break;
166
- case CustomAd_YPosition.Center:
167
- top = 0;
168
- if (this.screenInfo !== null) {
169
- top = this.screenInfo.windowHeight / 2 - realHeight / 2;
170
- }
171
- break;
172
- case CustomAd_YPosition.Bottom:
173
- top = 0;
174
- if (this.screenInfo !== null) {
175
- top = this.screenInfo.windowHeight - realHeight - yMargin;
176
- }
177
- break;
178
- }
179
- switch (xPosition) {
180
- case CustomAd_XPosition.Left:
181
- left = xMargin;
182
- break;
183
- case CustomAd_XPosition.Center:
184
- left = 0;
185
- if (this.screenInfo !== null) {
186
- left = this.screenInfo.windowWidth / 2 - realWidth / 2;
187
- }
188
- break;
189
- case CustomAd_XPosition.Right:
190
- left = 0;
191
- if (this.screenInfo !== null) {
192
- left = this.screenInfo.windowWidth - realWidth - xMargin;
193
- }
194
- break;
195
- }
196
- }
197
- let posInfo = {
198
- realWidth: realWidth,
199
- realHeight: realHeight,
200
- left: left,
201
- top: top,
202
- };
203
- return posInfo;
204
- }
205
- calcPortalAdPosition(portalAdPlatformInfo) {
206
- let width = portalAdPlatformInfo.width;
207
- let height = portalAdPlatformInfo.height;
208
- let adScaleRatio = portalAdPlatformInfo.scaleRatio;
209
- let top = 0;
210
- let left = 0;
211
- let realWidth = 0;
212
- let realHeight = 0;
213
- realWidth = width * adScaleRatio;
214
- realHeight = height * adScaleRatio;
215
- top = 0;
216
- left = 0;
217
- if (this.screenInfo !== null) {
218
- left = this.screenInfo.windowWidth / 2 - realWidth / 2;
219
- top = this.screenInfo.windowHeight / 2 - realHeight / 2;
220
- }
221
- let posInfo = {
222
- realWidth: realWidth,
223
- realHeight: realHeight,
224
- left: left,
225
- top: top,
226
- };
227
- return posInfo;
228
- }
229
- }
230
- AbsAdAdapter.TAG = "AbsAdAdapter";
@@ -1,31 +0,0 @@
1
- import { AbsAdAdapter } from "./AbsAdAdapter";
2
- export declare class AdAdapterBilibili extends AbsAdAdapter {
3
- static TAG: string;
4
- private blRewardedVideoAd;
5
- init(interstitialAdUnitId: string, interstitialAdCallback: Function, rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void;
6
- createBannerAd(adUnitId: string): boolean;
7
- destroyBannerAd(adUnitId: string): void;
8
- showBannerAd(adUnitId: string): void;
9
- hideBannerAd(adUnitId: string): void;
10
- createInterstitialAd(): void;
11
- showInterstitialAd(): void;
12
- destroyInterstitialAd(): void;
13
- isIntersititialAdShowing(): boolean;
14
- protected _loadInterstitialAd(isShowImmediately: boolean): void;
15
- protected _showInterstitialAd(): void;
16
- createRewardedVideoAd(): void;
17
- showRewardedVideoAd(): void;
18
- destroyRewardedVideoAd(): void;
19
- isRewardedVideoAdLoaded(): boolean;
20
- isRewardedVideoAdShowing(): boolean;
21
- protected _loadRewardedVideoAd(isShowImmediately: boolean): void;
22
- protected _showRewardedVideoAd(): void;
23
- createCustomAd(adUnitId: string): boolean;
24
- destroyCustomAd(adUnitId: string): void;
25
- showCustomAd(adUnitId: string): void;
26
- hideCustomAd(adUnitId: string): void;
27
- createPortalAd(adUnitId: string): void;
28
- destroyPortalAd(adUnitId: string): void;
29
- showPortalAd(adUnitId: string): void;
30
- hidePortalAd(adUnitId: string): void;
31
- }
@@ -1,224 +0,0 @@
1
- import { RewardedVideoAd_Callback_Status } from "../../Definition/AdDefinition";
2
- import { LogUtils } from "../../Utils/LogUtils";
3
- import { AbsAdAdapter, RewardedVideoAdStatus } from "./AbsAdAdapter";
4
- class BLRewardedVideoAd {
5
- constructor(adUnitId, callback) {
6
- this.unitId = adUnitId;
7
- this.ad = null;
8
- this.status = RewardedVideoAdStatus.Status_Destroyed;
9
- this.callback = callback;
10
- this.errorListener = null;
11
- this.loadListener = null;
12
- this.closeListener = null;
13
- this.isShowImmediately = false;
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.closeListener !== null) {
26
- this.ad.offClose(this.closeListener);
27
- this.closeListener = null;
28
- }
29
- this.ad.destroy();
30
- this.ad = null;
31
- }
32
- this.isShowImmediately = false;
33
- this.status = RewardedVideoAdStatus.Status_Destroyed;
34
- }
35
- }
36
- export class AdAdapterBilibili extends AbsAdAdapter {
37
- constructor() {
38
- super(...arguments);
39
- this.blRewardedVideoAd = null;
40
- }
41
- init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
42
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "init()");
43
- this.blRewardedVideoAd = new BLRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
44
- }
45
- createBannerAd(adUnitId) {
46
- return false;
47
- }
48
- destroyBannerAd(adUnitId) {
49
- }
50
- showBannerAd(adUnitId) {
51
- }
52
- hideBannerAd(adUnitId) {
53
- }
54
- createInterstitialAd() {
55
- }
56
- showInterstitialAd() {
57
- }
58
- destroyInterstitialAd() {
59
- }
60
- isIntersititialAdShowing() {
61
- return false;
62
- }
63
- _loadInterstitialAd(isShowImmediately) {
64
- }
65
- _showInterstitialAd() {
66
- }
67
- createRewardedVideoAd() {
68
- this.destroyRewardedVideoAd();
69
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "createRewardedVideoAd() adUnitId=" + this.blRewardedVideoAd.unitId);
70
- let rewardedVideoAd = window["bl"].createRewardedVideoAd({
71
- adUnitId: this.blRewardedVideoAd.unitId
72
- });
73
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "bl.createRewardedVideoAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
74
- LogUtils.Instance.log("", rewardedVideoAd);
75
- if (!rewardedVideoAd) {
76
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
77
- this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
78
- return;
79
- }
80
- this.blRewardedVideoAd.ad = rewardedVideoAd;
81
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
82
- this.blRewardedVideoAd.errorListener = (err) => {
83
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.onError()");
84
- if (err) {
85
- LogUtils.Instance.log("", err);
86
- }
87
- if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
88
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
89
- this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
90
- }
91
- };
92
- this.blRewardedVideoAd.ad.onError(this.blRewardedVideoAd.errorListener);
93
- this.blRewardedVideoAd.loadListener = () => {
94
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.onLoad()");
95
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
96
- if (this.blRewardedVideoAd.isShowImmediately) {
97
- this.blRewardedVideoAd.isShowImmediately = false;
98
- this._showRewardedVideoAd();
99
- }
100
- };
101
- this.blRewardedVideoAd.ad.onLoad(this.blRewardedVideoAd.loadListener);
102
- this.blRewardedVideoAd.closeListener = (res) => {
103
- let isEnded = (res !== null) ? res.isEnded : false;
104
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.onClose()");
105
- LogUtils.Instance.log("", "isEnded=" + isEnded);
106
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
107
- if (isEnded) {
108
- this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
109
- }
110
- else {
111
- this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
112
- }
113
- this.scheduleOnce(() => {
114
- if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
115
- this._loadRewardedVideoAd(false);
116
- }
117
- }, 2);
118
- };
119
- this.blRewardedVideoAd.ad.onClose(this.blRewardedVideoAd.closeListener);
120
- this.scheduleOnce(() => {
121
- if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
122
- this._loadRewardedVideoAd(false);
123
- }
124
- }, 2);
125
- }
126
- showRewardedVideoAd() {
127
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "showRewardedVideoAd()");
128
- if (this.blRewardedVideoAd.ad === null) {
129
- return;
130
- }
131
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.status=" + RewardedVideoAdStatus[this.blRewardedVideoAd.status]);
132
- switch (this.blRewardedVideoAd.status) {
133
- case RewardedVideoAdStatus.Status_Destroyed:
134
- case RewardedVideoAdStatus.Status_Watching:
135
- case RewardedVideoAdStatus.Status_StartToWatch:
136
- break;
137
- case RewardedVideoAdStatus.Status_Loaded:
138
- this._showRewardedVideoAd();
139
- break;
140
- case RewardedVideoAdStatus.Status_Watched:
141
- case RewardedVideoAdStatus.Status_Error:
142
- case RewardedVideoAdStatus.Status_Init:
143
- this._loadRewardedVideoAd(true);
144
- break;
145
- default:
146
- break;
147
- }
148
- }
149
- destroyRewardedVideoAd() {
150
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "destroyRewardedVideoAd()");
151
- this.blRewardedVideoAd.destroy();
152
- }
153
- isRewardedVideoAdLoaded() {
154
- if (this.blRewardedVideoAd.ad === null) {
155
- return false;
156
- }
157
- if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
158
- return true;
159
- }
160
- return false;
161
- }
162
- isRewardedVideoAdShowing() {
163
- if (this.blRewardedVideoAd.ad === null) {
164
- return false;
165
- }
166
- if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
167
- return true;
168
- }
169
- return false;
170
- }
171
- _loadRewardedVideoAd(isShowImmediately) {
172
- this.blRewardedVideoAd.isShowImmediately = isShowImmediately;
173
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.load()");
174
- this.blRewardedVideoAd.ad.load().then(() => {
175
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.load() success");
176
- }).catch((err) => {
177
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.load() error");
178
- if (err) {
179
- LogUtils.Instance.log("", err);
180
- }
181
- });
182
- }
183
- _showRewardedVideoAd() {
184
- if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
185
- return;
186
- }
187
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_StartToWatch;
188
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.show()");
189
- this.blRewardedVideoAd.ad.show()
190
- .then(() => {
191
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.show() success");
192
- if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
193
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
194
- this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
195
- }
196
- }).catch((err) => {
197
- LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.show() error");
198
- if (err) {
199
- LogUtils.Instance.log("", err);
200
- }
201
- if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
202
- this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
203
- }
204
- });
205
- }
206
- createCustomAd(adUnitId) {
207
- return false;
208
- }
209
- destroyCustomAd(adUnitId) {
210
- }
211
- showCustomAd(adUnitId) {
212
- }
213
- hideCustomAd(adUnitId) {
214
- }
215
- createPortalAd(adUnitId) {
216
- }
217
- destroyPortalAd(adUnitId) {
218
- }
219
- showPortalAd(adUnitId) {
220
- }
221
- hidePortalAd(adUnitId) {
222
- }
223
- }
224
- AdAdapterBilibili.TAG = "AdAdapterBilibili";
@@ -1,34 +0,0 @@
1
- import { AbsAdAdapter } from './AbsAdAdapter';
2
- export declare class AdAdapterDouYin extends AbsAdAdapter {
3
- static TAG: string;
4
- private ttInterstitialAd;
5
- private ttRewardedVideoAd;
6
- private ttBannerAds;
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
- private _createInterstitialAd;
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
- }