drgame-cc 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -351
- package/build-templates/web-mobile/splash_en - /345/211/257/346/234/254.png +0 -0
- package/{tvui → drres}/config/default.json +30 -11
- package/drscript/BtnExtra.ts +17 -0
- package/drscript/Define.ts +22 -0
- package/drscript/ExitWin.ts +39 -0
- package/drscript/Info.ts +75 -0
- package/drscript/Loader.ts +89 -0
- package/drscript/PlatformAdapter.ts +165 -0
- package/drscript/README - /345/211/257/346/234/254.md" +814 -0
- package/drscript/README.md +814 -0
- package/drscript/ad/AdManager.ts +174 -0
- package/drscript/ad/AdManager.ts.meta +10 -0
- package/drscript/ad/AdSlot.ts +44 -0
- package/drscript/ad/AdSlot.ts.meta +10 -0
- package/drscript/ad/AggregateAdProvider.ts +148 -0
- package/drscript/ad/AggregateAdProvider.ts.meta +10 -0
- package/drscript/ad/IAdProvider.ts +39 -0
- package/drscript/ad/IAdProvider.ts.meta +10 -0
- package/drscript/ad/MockAdProvider.ts +36 -0
- package/drscript/ad/MockAdProvider.ts.meta +10 -0
- package/drscript/ad/SelfAdProvider.ts +41 -0
- package/drscript/ad/SelfAdProvider.ts.meta +10 -0
- package/drscript/ad-sdk/README.md +344 -0
- package/drscript/ad-sdk/README.md.meta +6 -0
- package/drscript/ad-sdk/ad-sdk.d.ts +59 -0
- package/drscript/ad-sdk/ad-sdk.d.ts.meta +6 -0
- package/drscript/ad-sdk/ad-sdk.js +322 -0
- package/drscript/ad-sdk/ad-sdk.js.meta +10 -0
- package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts +29 -0
- package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts.meta +6 -0
- package/drscript/ad-sdk/adapters/xiaomi-adapter.js +449 -0
- package/drscript/ad-sdk/adapters/xiaomi-adapter.js.meta +10 -0
- package/drscript/ad-sdk/adapters.meta +13 -0
- package/drscript/ad-sdk/event-emitter.d.ts +12 -0
- package/drscript/ad-sdk/event-emitter.d.ts.meta +6 -0
- package/drscript/ad-sdk/event-emitter.js +65 -0
- package/drscript/ad-sdk/event-emitter.js.meta +10 -0
- package/drscript/ad-sdk/leaderboard/leaderboard.d.ts +23 -0
- package/drscript/ad-sdk/leaderboard/leaderboard.d.ts.meta +6 -0
- package/drscript/ad-sdk/leaderboard/leaderboard.js +193 -0
- package/drscript/ad-sdk/leaderboard/leaderboard.js.meta +10 -0
- package/drscript/ad-sdk/leaderboard.meta +13 -0
- package/drscript/ad-sdk/package.json +46 -0
- package/drscript/ad-sdk/package.json.meta +6 -0
- package/drscript/ad-sdk/reporters/reporter.d.ts +40 -0
- package/drscript/ad-sdk/reporters/reporter.d.ts.meta +6 -0
- package/drscript/ad-sdk/reporters/reporter.js +198 -0
- package/drscript/ad-sdk/reporters/reporter.js.meta +10 -0
- package/drscript/ad-sdk/reporters/superset-lewo.js +413 -0
- package/drscript/ad-sdk/reporters/superset-lewo.js.meta +10 -0
- package/drscript/ad-sdk/reporters.meta +13 -0
- package/drscript/ad-sdk/types/enums.d.ts +64 -0
- package/drscript/ad-sdk/types/enums.d.ts.meta +6 -0
- package/drscript/ad-sdk/types/enums.js +111 -0
- package/drscript/ad-sdk/types/enums.js.meta +10 -0
- package/drscript/ad-sdk/types/index.d.ts +6 -0
- package/drscript/ad-sdk/types/index.d.ts.meta +6 -0
- package/drscript/ad-sdk/types/index.js +15 -0
- package/drscript/ad-sdk/types/index.js.meta +10 -0
- package/drscript/ad-sdk/types/interfaces.d.ts +333 -0
- package/drscript/ad-sdk/types/interfaces.d.ts.meta +6 -0
- package/drscript/ad-sdk/types.meta +13 -0
- package/drscript/config/TvUiConfig.ts +155 -0
- package/drscript/config/TvUiConfig.ts.meta +10 -0
- package/drscript/config/TvUiConfigManager.ts +133 -0
- package/drscript/config/TvUiConfigManager.ts.meta +10 -0
- package/drscript/core/BackManager.ts +40 -0
- package/drscript/core/BackManager.ts.meta +10 -0
- package/drscript/core/NativeBridge.ts +137 -0
- package/drscript/core/NativeBridge.ts.meta +10 -0
- package/drscript/core/TvUi.ts +69 -0
- package/drscript/core/TvUi.ts.meta +10 -0
- package/drscript/core/TvUiRoot.ts +137 -0
- package/drscript/core/TvUiRoot.ts.meta +10 -0
- package/drscript/focus/FocusItem.ts +57 -0
- package/drscript/focus/FocusItem.ts.meta +10 -0
- package/drscript/focus/FocusManager.ts +538 -0
- package/drscript/focus/FocusManager.ts.meta +10 -0
- package/drscript/focus/FocusScope.ts +10 -0
- package/drscript/focus/FocusScope.ts.meta +10 -0
- package/drscript/focus/FocusVisualLayer.ts +238 -0
- package/drscript/focus/FocusVisualLayer.ts.meta +10 -0
- package/drscript/icon/IconConfig.ts +7 -0
- package/drscript/icon/IconConfig.ts.meta +10 -0
- package/drscript/icon/IconManager.ts +97 -0
- package/drscript/icon/IconManager.ts.meta +10 -0
- package/drscript/input/KeyCodeAdapter.ts +23 -0
- package/drscript/input/KeyCodeAdapter.ts.meta +10 -0
- package/drscript/input/RemoteInputManager.ts +105 -0
- package/drscript/input/RemoteInputManager.ts.meta +10 -0
- package/drscript/toast/ToastComponent.ts +35 -0
- package/drscript/toast/ToastComponent.ts.meta +10 -0
- package/drscript/toast/ToastManager.ts +66 -0
- package/drscript/toast/ToastManager.ts.meta +10 -0
- package/drscript/toast/TvExitConfirmDialog.ts +334 -0
- package/drscript/toast/TvExitConfirmDialog.ts.meta +10 -0
- package/drscript/toast/UIFunctions.ts +150 -0
- package/drscript/toast/UIFunctions.ts.meta +10 -0
- package/package.json +3 -2
- package/scripts/postinstall.js +99 -67
- package/bin/drgame.d.ts +0 -632
- package/bin/drgame.js +0 -3010
- /package/{tvui → drres}/config/default.json.meta +0 -0
- /package/{tvui → drres}/config.meta +0 -0
- /package/{tvui → drres}/icons/pointer-blue-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-blue-60.png.meta +0 -0
- /package/{tvui → drres}/icons/pointer-pink-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-pink-60.png.meta +0 -0
- /package/{tvui → drres}/icons/pointer-yellow-60.png +0 -0
- /package/{tvui → drres}/icons/pointer-yellow-60.png.meta +0 -0
- /package/{tvui → drres}/icons.meta +0 -0
- /package/{tvui → drres}/prefab/ExitWin.prefab +0 -0
- /package/{tvui → drres}/prefab/ExitWin.prefab.meta +0 -0
- /package/{tvui → drres}/prefab/Toast.prefab +0 -0
- /package/{tvui → drres}/prefab/Toast.prefab.meta +0 -0
- /package/{tvui → drres}/prefab.meta +0 -0
- /package/{tvui → drres}/tv_exit/Toast.png +0 -0
- /package/{tvui → drres}/tv_exit/Toast.png.meta +0 -0
- /package/{tvui → drres}/tv_exit/close.png +0 -0
- /package/{tvui → drres}/tv_exit/close.png.meta +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/346/231/256/351/200/232.png" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/346/231/256/351/200/232.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/351/200/211/344/270/255.png" +0 -0
- /package/{tvui → drres}/tv_exit//345/217/226/346/266/210/346/214/211/351/222/256_/351/200/211/344/270/255.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//346/241/206.png" +0 -0
- /package/{tvui → drres}/tv_exit//346/241/206.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/346/231/256/351/200/232.png" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/346/231/256/351/200/232.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/351/200/211/344/270/255.png" +0 -0
- /package/{tvui → drres}/tv_exit//347/241/256/350/256/244/346/214/211/351/222/256_/351/200/211/344/270/255.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit//351/200/200/345/207/272/346/270/270/346/210/217.png" +0 -0
- /package/{tvui → drres}/tv_exit//351/200/200/345/207/272/346/270/270/346/210/217.png.meta" +0 -0
- /package/{tvui → drres}/tv_exit.meta +0 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聚合广告 SDK - 主入口
|
|
3
|
+
*
|
|
4
|
+
* 使用方式:
|
|
5
|
+
* const { AdSdk, AdPlatform, AdEvent } = require('./ad-sdk');
|
|
6
|
+
* await AdSdk.init({ platform: AdPlatform.Xiaomi });
|
|
7
|
+
* const result = await AdSdk.requestAd({ cpId: 'cp_001', rewardType: 'extra_life', triggerScene: 'game_over' });
|
|
8
|
+
*
|
|
9
|
+
* TS 项目中:
|
|
10
|
+
* import { AdSdk, AdPlatform } from './ad-sdk';
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { AdPlatform, AdEvent, AdErrorCode } = require('./types/enums');
|
|
14
|
+
const { XiaomiAdapter } = require('./adapters/xiaomi-adapter');
|
|
15
|
+
const { EventEmitter } = require('./event-emitter');
|
|
16
|
+
const { Reporter, ActionType } = require('./reporters/reporter');
|
|
17
|
+
const { Leaderboard } = require('./leaderboard/leaderboard');
|
|
18
|
+
const KEY_EVENT_NAME = '__key_event__';
|
|
19
|
+
|
|
20
|
+
// ────────────────────────────────────────
|
|
21
|
+
// 适配器注册表
|
|
22
|
+
// ────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
const BUILTIN_ADAPTERS = {};
|
|
25
|
+
BUILTIN_ADAPTERS[AdPlatform.Xiaomi] = XiaomiAdapter;
|
|
26
|
+
// 后续扩展:
|
|
27
|
+
// BUILTIN_ADAPTERS[AdPlatform.Huawei] = HuaweiAdapter;
|
|
28
|
+
// BUILTIN_ADAPTERS[AdPlatform.Tencent] = TencentAdapter;
|
|
29
|
+
|
|
30
|
+
// ────────────────────────────────────────
|
|
31
|
+
// SDK 实现
|
|
32
|
+
// ────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
class AdSdkImpl {
|
|
35
|
+
constructor() {
|
|
36
|
+
this._initialized = false;
|
|
37
|
+
this._currentPlatform = AdPlatform.Xiaomi;
|
|
38
|
+
this._adapters = new Map();
|
|
39
|
+
this._emitter = new EventEmitter();
|
|
40
|
+
this._globalEventHandler = null;
|
|
41
|
+
this._keyHandlers = [];
|
|
42
|
+
this._adapterKeyHandler = null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get currentPlatform() {
|
|
46
|
+
return this._currentPlatform;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 初始化 SDK
|
|
51
|
+
* @param {import('./types/interfaces').IAdSdkConfig} config
|
|
52
|
+
*/
|
|
53
|
+
async init(config) {
|
|
54
|
+
if (this._initialized) {
|
|
55
|
+
console.warn('[AdSdk] Already initialized. Call destroy() first if you need to re-init.');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this._currentPlatform = config.platform;
|
|
60
|
+
this._globalEventHandler = config.onEvent || null;
|
|
61
|
+
|
|
62
|
+
// 注册自定义适配器
|
|
63
|
+
if (config.customAdapters) {
|
|
64
|
+
for (const adapter of config.customAdapters) {
|
|
65
|
+
this._adapters.set(adapter.platform, adapter);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 注册内置适配器(不覆盖自定义的)
|
|
70
|
+
if (!this._adapters.has(config.platform)) {
|
|
71
|
+
const AdapterClass = BUILTIN_ADAPTERS[config.platform];
|
|
72
|
+
if (!AdapterClass) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
'[AdSdk] No adapter found for platform "' + config.platform + '". ' +
|
|
75
|
+
'Available: ' + Object.keys(BUILTIN_ADAPTERS).join(', ') + '. ' +
|
|
76
|
+
'You can also provide a custom adapter via config.customAdapters.'
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
const instance = new AdapterClass();
|
|
80
|
+
this._adapters.set(config.platform, instance);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 初始化当前平台的适配器
|
|
84
|
+
const adapter = this._adapters.get(config.platform);
|
|
85
|
+
const adapterConfig = (config.adapters && config.adapters[config.platform]) || {};
|
|
86
|
+
await adapter.init(adapterConfig);
|
|
87
|
+
|
|
88
|
+
// 桥接适配器事件到全局
|
|
89
|
+
const self = this;
|
|
90
|
+
const events = Object.values(AdEvent);
|
|
91
|
+
for (let i = 0; i < events.length; i++) {
|
|
92
|
+
const evt = events[i];
|
|
93
|
+
adapter.on(evt, function (data) {
|
|
94
|
+
self._emitter.emit(evt, data);
|
|
95
|
+
if (self._globalEventHandler) {
|
|
96
|
+
self._globalEventHandler(evt, data);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 桥接适配器的按键事件
|
|
102
|
+
if (adapter.onKeyEvent) {
|
|
103
|
+
self._adapterKeyHandler = function (keyEvent) {
|
|
104
|
+
for (var j = 0; j < self._keyHandlers.length; j++) {
|
|
105
|
+
try {
|
|
106
|
+
self._keyHandlers[j](keyEvent);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
console.error('[AdSdk] Key event handler error:', e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
adapter.onKeyEvent(self._adapterKeyHandler);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this._initialized = true;
|
|
116
|
+
console.log('[AdSdk] Initialized with platform: ' + config.platform);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 获取设备信息
|
|
121
|
+
* @returns {Promise<import('./types/interfaces').IDeviceInfo>}
|
|
122
|
+
*/
|
|
123
|
+
async getDeviceInfo() {
|
|
124
|
+
this._ensureInit();
|
|
125
|
+
const adapter = this._getAdapter();
|
|
126
|
+
if (adapter.getDeviceInfo) {
|
|
127
|
+
return adapter.getDeviceInfo();
|
|
128
|
+
}
|
|
129
|
+
throw new Error('[AdSdk] getDeviceInfo is not supported by the current adapter.');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 获取玩家账户信息
|
|
134
|
+
* @returns {Promise<import('./types/interfaces').IAccountInfo>}
|
|
135
|
+
*/
|
|
136
|
+
async getAccount() {
|
|
137
|
+
this._ensureInit();
|
|
138
|
+
const adapter = this._getAdapter();
|
|
139
|
+
if (adapter.getAccount) {
|
|
140
|
+
return adapter.getAccount();
|
|
141
|
+
}
|
|
142
|
+
throw new Error('[AdSdk] getAccount is not supported by the current adapter.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 请求播放广告
|
|
147
|
+
* @param {import('./types/interfaces').IAdRequest} request
|
|
148
|
+
* @returns {Promise<import('./types/interfaces').IAdRewardResult>}
|
|
149
|
+
*/
|
|
150
|
+
async requestAd(request) {
|
|
151
|
+
this._ensureInit();
|
|
152
|
+
return this._getAdapter().requestAd(request);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 通知游戏加载完成
|
|
157
|
+
* @param {string} version
|
|
158
|
+
*/
|
|
159
|
+
onGameReady(version) {
|
|
160
|
+
this._ensureInit();
|
|
161
|
+
const adapter = this._getAdapter();
|
|
162
|
+
if (adapter.onGameReady) {
|
|
163
|
+
adapter.onGameReady(version);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** 通知游戏暂停 */
|
|
168
|
+
onGamePause() {
|
|
169
|
+
this._ensureInit();
|
|
170
|
+
const adapter = this._getAdapter();
|
|
171
|
+
if (adapter.onGamePause) {
|
|
172
|
+
adapter.onGamePause();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** 通知游戏恢复 */
|
|
177
|
+
onGameResume() {
|
|
178
|
+
this._ensureInit();
|
|
179
|
+
const adapter = this._getAdapter();
|
|
180
|
+
if (adapter.onGameResume) {
|
|
181
|
+
adapter.onGameResume();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 退出游戏
|
|
187
|
+
* @returns {Promise<void>}
|
|
188
|
+
*/
|
|
189
|
+
async exitGame() {
|
|
190
|
+
this._ensureInit();
|
|
191
|
+
const adapter = this._getAdapter();
|
|
192
|
+
if (adapter.exitGame) {
|
|
193
|
+
return adapter.exitGame();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 监听广告事件
|
|
199
|
+
* @param {string} event
|
|
200
|
+
* @param {Function} handler
|
|
201
|
+
*/
|
|
202
|
+
on(event, handler) {
|
|
203
|
+
this._emitter.on(event, handler);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 取消监听
|
|
208
|
+
* @param {string} event
|
|
209
|
+
* @param {Function} [handler]
|
|
210
|
+
*/
|
|
211
|
+
off(event, handler) {
|
|
212
|
+
this._emitter.off(event, handler);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 监听遥控器按键事件
|
|
217
|
+
* @param {Function} handler - 回调函数,接收 { key, action } 对象
|
|
218
|
+
*/
|
|
219
|
+
onKeyEvent(handler) {
|
|
220
|
+
if (typeof handler === 'function' && this._keyHandlers.indexOf(handler) === -1) {
|
|
221
|
+
this._keyHandlers.push(handler);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 取消监听遥控器按键事件
|
|
227
|
+
* @param {Function} [handler] - 不传则清除所有
|
|
228
|
+
*/
|
|
229
|
+
offKeyEvent(handler) {
|
|
230
|
+
if (!handler) {
|
|
231
|
+
this._keyHandlers = [];
|
|
232
|
+
} else {
|
|
233
|
+
var idx = this._keyHandlers.indexOf(handler);
|
|
234
|
+
if (idx !== -1) {
|
|
235
|
+
this._keyHandlers.splice(idx, 1);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 切换广告平台
|
|
242
|
+
* @param {string} platform
|
|
243
|
+
*/
|
|
244
|
+
switchPlatform(platform) {
|
|
245
|
+
if (platform === this._currentPlatform) return;
|
|
246
|
+
|
|
247
|
+
const adapter = this._adapters.get(platform);
|
|
248
|
+
if (!adapter) {
|
|
249
|
+
throw new Error('[AdSdk] Platform "' + platform + '" not registered. Init with it first.');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
this._currentPlatform = platform;
|
|
253
|
+
console.log('[AdSdk] Switched to platform: ' + platform);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** 销毁 SDK */
|
|
257
|
+
destroy() {
|
|
258
|
+
// 清理适配器的按键桥接
|
|
259
|
+
const adapter = this._getAdapter();
|
|
260
|
+
if (adapter && adapter.offKeyEvent && this._adapterKeyHandler) {
|
|
261
|
+
adapter.offKeyEvent(this._adapterKeyHandler);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
for (const adapter of this._adapters.values()) {
|
|
265
|
+
adapter.destroy();
|
|
266
|
+
}
|
|
267
|
+
this._adapters.clear();
|
|
268
|
+
this._emitter.removeAllListeners();
|
|
269
|
+
this._globalEventHandler = null;
|
|
270
|
+
this._keyHandlers = [];
|
|
271
|
+
this._adapterKeyHandler = null;
|
|
272
|
+
this._initialized = false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ────────────────────────────────────────
|
|
276
|
+
// 内部
|
|
277
|
+
// ────────────────────────────────────────
|
|
278
|
+
|
|
279
|
+
_ensureInit() {
|
|
280
|
+
if (!this._initialized) {
|
|
281
|
+
throw new Error('[AdSdk] SDK not initialized. Call AdSdk.init() first.');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
_getAdapter() {
|
|
286
|
+
return this._adapters.get(this._currentPlatform);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ────────────────────────────────────────
|
|
291
|
+
// 导出单例
|
|
292
|
+
// ────────────────────────────────────────
|
|
293
|
+
|
|
294
|
+
const AdSdk = new AdSdkImpl();
|
|
295
|
+
|
|
296
|
+
// 命名导出
|
|
297
|
+
const { AdType, DevicePlatform, KeyCode, KeyAction } = require('./types/enums');
|
|
298
|
+
|
|
299
|
+
module.exports = {
|
|
300
|
+
// 单例
|
|
301
|
+
AdSdk,
|
|
302
|
+
|
|
303
|
+
// 枚举
|
|
304
|
+
AdPlatform,
|
|
305
|
+
AdType,
|
|
306
|
+
AdEvent,
|
|
307
|
+
AdErrorCode,
|
|
308
|
+
DevicePlatform,
|
|
309
|
+
KeyCode,
|
|
310
|
+
KeyAction,
|
|
311
|
+
|
|
312
|
+
// 数据上报
|
|
313
|
+
Reporter,
|
|
314
|
+
ActionType,
|
|
315
|
+
|
|
316
|
+
// 排行榜
|
|
317
|
+
Leaderboard,
|
|
318
|
+
|
|
319
|
+
// 类
|
|
320
|
+
XiaomiAdapter,
|
|
321
|
+
EventEmitter,
|
|
322
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聚合广告 SDK - 小米电视适配器类型声明
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdPlatform, AdEvent } from '../types/enums';
|
|
6
|
+
import {
|
|
7
|
+
IAdAdapter,
|
|
8
|
+
IAdapterConfig,
|
|
9
|
+
IAdRequest,
|
|
10
|
+
IAdRewardResult,
|
|
11
|
+
IDeviceInfo,
|
|
12
|
+
IAccountInfo,
|
|
13
|
+
IEventHandler,
|
|
14
|
+
} from '../types/interfaces';
|
|
15
|
+
|
|
16
|
+
export declare class XiaomiAdapter implements IAdAdapter {
|
|
17
|
+
readonly platform: AdPlatform;
|
|
18
|
+
init(config: IAdapterConfig): Promise<void>;
|
|
19
|
+
requestAd(request: IAdRequest): Promise<IAdRewardResult>;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
on(event: AdEvent, handler: IEventHandler): void;
|
|
22
|
+
off(event: AdEvent, handler?: IEventHandler): void;
|
|
23
|
+
getDeviceInfo(): Promise<IDeviceInfo>;
|
|
24
|
+
getAccount(): Promise<IAccountInfo>;
|
|
25
|
+
onGameReady(version: string): void;
|
|
26
|
+
onGamePause(): void;
|
|
27
|
+
onGameResume(): void;
|
|
28
|
+
exitGame(): Promise<void>;
|
|
29
|
+
}
|