drgame-cc 1.0.62 → 1.0.63

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 (43) hide show
  1. package/drres/focus/focus_1/gesture.atlas +34 -34
  2. package/drres/focus/focus_2/gesture.atlas +41 -41
  3. package/drres/focus/focus_3/gesture.atlas +34 -34
  4. package/drres/focus/focus_4/gesture.atlas +20 -20
  5. package/drres/prefab/HelperWin.prefab +508 -508
  6. package/drscript/PlatformAdapter.ts +2 -2
  7. package/drscript/ad-sdk/README.md +78 -12
  8. package/drscript/ad-sdk/ad-sdk.ts +416 -0
  9. package/drscript/ad-sdk/{adapters/xiaomi-adapter.js.meta → ad-sdk.ts.meta} +2 -2
  10. package/drscript/ad-sdk/event-emitter.ts +66 -0
  11. package/drscript/ad-sdk/event-emitter.ts.meta +10 -0
  12. package/drscript/ad-sdk/leaderboard/leaderboard.ts +219 -0
  13. package/drscript/ad-sdk/leaderboard/leaderboard.ts.meta +10 -0
  14. package/drscript/ad-sdk/package.json +18 -17
  15. package/drscript/ad-sdk/reporters/reporter.ts +515 -0
  16. package/drscript/ad-sdk/reporters/reporter.ts.meta +10 -0
  17. package/drscript/ad-sdk/reporters/superset-lewo.ts +464 -0
  18. package/drscript/ad-sdk/reporters/superset-lewo.ts.meta +10 -0
  19. package/drscript/ad-sdk/types/enums.ts +103 -0
  20. package/drscript/ad-sdk/types/enums.ts.meta +10 -0
  21. package/drscript/ad-sdk/types/{index.d.ts → index.ts} +1 -1
  22. package/drscript/ad-sdk/types/index.ts.meta +10 -0
  23. package/drscript/ad-sdk/types/{interfaces.d.ts → interfaces.ts} +61 -10
  24. package/drscript/ad-sdk/types/interfaces.ts.meta +10 -0
  25. package/drscript/ad-sdk/user-gamedata/user-gamedata.ts +219 -0
  26. package/drscript/ad-sdk/user-gamedata/user-gamedata.ts.meta +10 -0
  27. package/drscript/ad-sdk/user-gamedata.meta +13 -0
  28. package/package.json +1 -1
  29. package/drscript/ad-sdk/ad-sdk.d.ts +0 -59
  30. package/drscript/ad-sdk/ad-sdk.js +0 -338
  31. package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts +0 -29
  32. package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts.meta +0 -6
  33. package/drscript/ad-sdk/adapters/xiaomi-adapter.js +0 -452
  34. package/drscript/ad-sdk/event-emitter.d.ts +0 -12
  35. package/drscript/ad-sdk/event-emitter.js +0 -65
  36. package/drscript/ad-sdk/leaderboard/leaderboard.d.ts +0 -23
  37. package/drscript/ad-sdk/leaderboard/leaderboard.js +0 -193
  38. package/drscript/ad-sdk/reporters/reporter.d.ts +0 -85
  39. package/drscript/ad-sdk/reporters/reporter.js +0 -500
  40. package/drscript/ad-sdk/reporters/superset-lewo.js +0 -574
  41. package/drscript/ad-sdk/types/enums.d.ts +0 -66
  42. package/drscript/ad-sdk/types/enums.js +0 -113
  43. package/drscript/ad-sdk/types/index.js +0 -15
@@ -1,500 +0,0 @@
1
- /**
2
- * 数据上报模块 - 统一封装层
3
- *
4
- * 内部使用 supersetLewo 上报脚本,对外提供简洁的调用接口:
5
- * Reporter.init(config) — 初始化
6
- * Reporter.report(data, immediate) — 单次上报(默认加入队列批量发送)
7
- * Reporter.reportBatch(list) — 批量上报
8
- * Reporter.flushQueue() — 立即刷新队列
9
- * Reporter.reportAppStart() — 启动事件
10
- * Reporter.reportSwitchBackground() — 切后台事件
11
- * Reporter.reportSwitchBack() — 切回事件
12
- * Reporter.reportAppExit() — 退出事件(自动计算游戏时长)
13
- * Reporter.updateUserInfo(info) — 登录后更新用户信息
14
- */
15
-
16
- var supersetLewo = require('./superset-lewo');
17
-
18
- // ────────────────────────────────────────
19
- // 上报动作类型
20
- // ────────────────────────────────────────
21
-
22
- var ActionType = {
23
- /** 曝光 */
24
- Exposure: '曝光',
25
- /** 点击 */
26
- Click: '点击',
27
- /** 开始播放 */
28
- StartPlay: '开始播放',
29
- /** 结束播放(需上报时长 action_value) */
30
- EndPlay: '结束播放',
31
- /** 分享 */
32
- Share: '分享',
33
- /** 订购(需上报成功订购金额) */
34
- Order: '订购',
35
- /** 启动 */
36
- Start: '启动',
37
- /** 退出 */
38
- Exit: '退出',
39
- /** 切后台 */
40
- SwitchBackground: '切后台',
41
- /** 切回 */
42
- SwitchBack: '切回',
43
- };
44
-
45
- // ────────────────────────────────────────
46
- // 内部队列管理(无需修改 supersetLewo)
47
- // ────────────────────────────────────────
48
-
49
- /** 配置接口地址 */
50
- var CONFIG_URL = 'https://sup.daoran.tv/bi-api/api/config/get';
51
-
52
- /** 事件队列 */
53
- var _eventQueue = [];
54
- /** 定时器句柄 */
55
- var _batchTimer = null;
56
- /** 每批最大条数 */
57
- var _perNum = 10;
58
- /** 发送间隔(秒) */
59
- var _spaceSec = 30;
60
- /** 队列模式是否已启用 */
61
- var _queueEnabled = false;
62
-
63
- /** 会话启动时间戳(毫秒),用于计算游戏时长 */
64
- var _sessionStartTime = 0;
65
-
66
- /** 额外用户信息(登录后填充,合并到上报 user 对象) */
67
- var _extraUserInfo = {};
68
-
69
- /**
70
- * 修补 supersetLewo.getUserInfo,使登录后的额外字段能合并到 user 对象
71
- * 避免修改 superset-lewo.js 源文件
72
- */
73
- (function _patchGetUserInfo() {
74
- var originalGetUserInfo = supersetLewo.getUserInfo;
75
- supersetLewo.getUserInfo = function () {
76
- var info = originalGetUserInfo();
77
- // 合并额外字段(如 user_id、user_type 等)
78
- for (var key in _extraUserInfo) {
79
- if (_extraUserInfo.hasOwnProperty(key)) {
80
- info[key] = _extraUserInfo[key];
81
- }
82
- }
83
- return info;
84
- };
85
- })();
86
-
87
- /**
88
- * 刷新队列 —— 将队列中所有事件打包发送
89
- */
90
- function _flushQueue() {
91
- if (_eventQueue.length === 0) return;
92
- var batch = _eventQueue.splice(0, _perNum);
93
- supersetLewo.batchReporting(batch);
94
- }
95
-
96
- /**
97
- * 添加单条事件到队列
98
- */
99
- function _addToQueue(eventItem) {
100
- _eventQueue.push(eventItem);
101
- if (_eventQueue.length >= _perNum) {
102
- _flushQueue();
103
- }
104
- }
105
-
106
- /**
107
- * 批量添加事件到队列
108
- */
109
- function _addBatchToQueue(eventList) {
110
- if (!Array.isArray(eventList) || eventList.length === 0) return;
111
- for (var i = 0; i < eventList.length; i++) {
112
- _eventQueue.push(eventList[i]);
113
- }
114
- if (_eventQueue.length >= _perNum) {
115
- _flushQueue();
116
- }
117
- }
118
-
119
- /**
120
- * 启用队列定时刷新
121
- */
122
- function _startQueueTimer() {
123
- if (_queueEnabled) return;
124
- _queueEnabled = true;
125
- _batchTimer = setInterval(_flushQueue, _spaceSec * 1000);
126
- }
127
-
128
- /**
129
- * 停止队列定时刷新
130
- */
131
- function _stopQueueTimer() {
132
- _queueEnabled = false;
133
- if (_batchTimer) {
134
- clearInterval(_batchTimer);
135
- _batchTimer = null;
136
- }
137
- }
138
-
139
- // ────────────────────────────────────────
140
- // Reporter 实现
141
- // ────────────────────────────────────────
142
-
143
- var Reporter = {
144
- /** 是否已初始化 */
145
- _initialized: false,
146
-
147
- /** 公共字段缓存(初始化时设置,每次上报自动合并) */
148
- _commonInfo: {},
149
-
150
- /**
151
- * 从后端获取批量上报配置
152
- * @param {Function} [callback] - 回调函数,接收 { perNum, spaceSec }
153
- */
154
- fetchReportConfig: function (callback) {
155
- var self = this;
156
- supersetLewo.ajax({
157
- url: CONFIG_URL,
158
- type: 'get',
159
- dataType: 'json',
160
- data: {},
161
- success: function (xhr, rsp) {
162
- if (rsp && rsp.code === 200 && rsp.data) {
163
- var cfg = rsp.data;
164
- _perNum = cfg.perNum || 10;
165
- _spaceSec = cfg.spaceSec || 30;
166
- if (typeof callback === 'function') {
167
- callback({ perNum: _perNum, spaceSec: _spaceSec });
168
- }
169
- } else {
170
- if (typeof callback === 'function') {
171
- callback({ perNum: 10, spaceSec: 30 });
172
- }
173
- }
174
- },
175
- error: function (xhr, rsp) {
176
- console.warn('[Reporter] fetchReportConfig failed, use defaults');
177
- if (typeof callback === 'function') {
178
- callback({ perNum: 10, spaceSec: 30 });
179
- }
180
- }
181
- });
182
- },
183
-
184
- /**
185
- * 初始化上报模块
186
- * @param {import('../types/interfaces').IReporterConfig} config
187
- */
188
- init: function (config) {
189
- config = config || {};
190
-
191
- // 设置上报地址(未传则使用 supersetLewo 默认值)
192
- if (config.report_url) {
193
- supersetLewo.config.reportUrl = config.report_url;
194
- }
195
-
196
- // 设置请求头
197
- if (config.headers && config.headers.length > 0) {
198
- supersetLewo.config.defaultHeaders = config.headers;
199
- }
200
-
201
- // 设置默认行为类型
202
- if (config.default_action_type) {
203
- supersetLewo.config.defaultActionType = config.default_action_type;
204
- }
205
-
206
- // 缓存公共字段
207
- this._commonInfo = {
208
- app_item: config.app_item || '',
209
- content_type: config.content_type || '游戏',
210
- content_id: config.content_id || '',
211
- content_title: config.content_title || '',
212
- };
213
-
214
- // 自动填充 device_id
215
- if (!this._commonInfo.device_id) {
216
- this._commonInfo.device_id = supersetLewo.createDeviceId();
217
- }
218
-
219
- supersetLewo.initUserInfo({
220
- os_type: config.os_type || "", // 操作系统类型 android/ios
221
- os_version: config.os_version || "", // 操作系统版本号
222
- app_version: config.app_version || "1.0.0", // APP版本号
223
- app_item: config.app_item || "", // 渠道编码(项目编码)
224
- app_name: config.app_name || config.content_title || "", // APP名称
225
- app_project: config.app_project || config.content_id || "", // 产品编码
226
- province: config.province || "", // 省份编码
227
- city: config.city || "", // 城市编码
228
- uid: config.uid || "", // 注册登录用户全局UID;游客/未登录填空字符串
229
- user_id: config.user_id || "", // 会员ID(memberId),无则填空字符串,不用uid填充
230
- device_id: this._commonInfo.device_id, // 设备唯一ID
231
- device_brand: config.device_brand || "", // 设备品牌,小写
232
- device_model: config.device_model || "", // 设备型号
233
- network_type: config.network_type || "", // 网络类型:wifi/cellular
234
- carrier: config.carrier || "", // 运营商
235
- promotion_flag: config.promotion_flag || "0", // 推广标识(ubp接口获取,1推广/0自然)
236
- user_type: config.user_type || "0" // 用户身份类型(0游客/1注册用户/2付费用户)
237
- });
238
-
239
- this._initialized = true;
240
-
241
- // 记录启动时间
242
- _sessionStartTime = Date.now();
243
-
244
- // 异步拉取批量配置,拉取成功后启动队列
245
- var self = this;
246
- this.fetchReportConfig(function (batchCfg) {
247
- _startQueueTimer();
248
- console.log('[Reporter] Batch config:', batchCfg, '- Queue mode enabled');
249
- });
250
-
251
- console.log('[Reporter] Initialized, reportUrl:', supersetLewo.config.reportUrl);
252
- },
253
-
254
- /**
255
- * 单次上报
256
- * @param {import('../types/interfaces').IReportItem} data - 上报数据
257
- * @param {boolean} [immediate=false] - 是否立即发送(不经过队列)
258
- */
259
- report: function (data, immediate) {
260
- if (!this._initialized) {
261
- console.warn('[Reporter] Not initialized. Call Reporter.init() first.');
262
- return;
263
- }
264
-
265
- // 合并公共字段 + 传入数据
266
- var merged = {};
267
- var key;
268
- for (key in this._commonInfo) {
269
- if (this._commonInfo.hasOwnProperty(key)) {
270
- merged[key] = this._commonInfo[key];
271
- }
272
- }
273
- for (key in data) {
274
- if (data.hasOwnProperty(key)) {
275
- merged[key] = data[key];
276
- }
277
- }
278
-
279
- // 自动填充 device_id
280
- if (!merged.device_id) {
281
- merged.device_id = supersetLewo.createDeviceId();
282
- }
283
-
284
- if (immediate) {
285
- // 立即发送(生命周期事件等需要及时上报的场景)
286
- supersetLewo.superBatchReport(merged);
287
- } else {
288
- // 加入队列,凑批次后批量发送
289
- _addToQueue(merged);
290
- }
291
- },
292
-
293
- /**
294
- * 批量上报
295
- * @param {Array<import('../types/interfaces').IReportItem>} dataList - 上报数据列表
296
- * @param {import('../types/interfaces').IReportItem} [commonInfo] - 可选公共字段
297
- * @param {boolean} [immediate=false] - 是否立即发送(不经过队列)
298
- */
299
- reportBatch: function (dataList, commonInfo, immediate) {
300
- if (!this._initialized) {
301
- console.warn('[Reporter] Not initialized. Call Reporter.init() first.');
302
- return;
303
- }
304
-
305
- var mergedCommon = {};
306
- var key;
307
-
308
- // 合并初始化时的公共字段
309
- for (key in this._commonInfo) {
310
- if (this._commonInfo.hasOwnProperty(key)) {
311
- mergedCommon[key] = this._commonInfo[key];
312
- }
313
- }
314
-
315
- // 合并传入的公共字段(优先级更高)
316
- if (commonInfo) {
317
- for (key in commonInfo) {
318
- if (commonInfo.hasOwnProperty(key)) {
319
- mergedCommon[key] = commonInfo[key];
320
- }
321
- }
322
- }
323
-
324
- // 自动填充 device_id
325
- if (!mergedCommon.device_id) {
326
- mergedCommon.device_id = supersetLewo.createDeviceId();
327
- }
328
-
329
- // 合并公共字段到各事件中
330
- var items = [];
331
- for (var i = 0; i < dataList.length; i++) {
332
- var item = {};
333
- for (key in mergedCommon) {
334
- if (mergedCommon.hasOwnProperty(key)) {
335
- item[key] = mergedCommon[key];
336
- }
337
- }
338
- for (key in dataList[i]) {
339
- if (dataList[i].hasOwnProperty(key)) {
340
- item[key] = dataList[i][key];
341
- }
342
- }
343
- items.push(item);
344
- }
345
-
346
- if (immediate) {
347
- // 立即发送
348
- supersetLewo.batchReporting(items);
349
- } else {
350
- // 加入队列
351
- _addBatchToQueue(items);
352
- }
353
- },
354
-
355
- /**
356
- * 立即刷新队列,将队列中所有事件立即发送
357
- */
358
- flushQueue: function () {
359
- _flushQueue();
360
- },
361
-
362
- /**
363
- * 上报「启动」事件 - APP启动成功后调用,记录启动时间
364
- */
365
- reportAppStart: function () {
366
- _sessionStartTime = Date.now();
367
- this.report({
368
- element_position: "AppLaunch",
369
- position_name: "应用启动",
370
- element_type: "page",
371
- element_name: "app_start",
372
- action_type: ActionType.Start,
373
- action_value: ""
374
- }, true);
375
- },
376
-
377
- /**
378
- * 上报「切后台」事件 - APP切到后台时调用
379
- * 计算当前时间与启动时间差,action_value传时间差(秒)
380
- */
381
- reportSwitchBackground: function () {
382
- var duration = Math.floor((Date.now() - _sessionStartTime) / 1000);
383
- this.report({
384
- element_position: "AppBackground",
385
- position_name: "应用切后台",
386
- element_type: "page",
387
- element_name: "app_switch_background",
388
- action_type: ActionType.SwitchBackground,
389
- action_value: String(duration)
390
- }, true);
391
- },
392
-
393
- /**
394
- * 上报「切回」事件 - APP从后台切回时调用,上报后更新启动时间
395
- */
396
- reportSwitchBack: function () {
397
- this.report({
398
- element_position: "AppForeground",
399
- position_name: "应用切前台",
400
- element_type: "page",
401
- element_name: "app_switch_back",
402
- action_type: ActionType.SwitchBack,
403
- action_value: ""
404
- }, true);
405
- // 更新启动时间
406
- _sessionStartTime = Date.now();
407
- },
408
-
409
- /**
410
- * 上报「退出」事件 - APP退出前调用
411
- * 计算当前时间与启动时间差,action_value传时间差(秒),给后台上传游戏时长
412
- */
413
- reportAppExit: function () {
414
- // 先刷新队列中剩余事件
415
- _flushQueue();
416
-
417
- var duration = Math.floor((Date.now() - _sessionStartTime) / 1000);
418
- this.report({
419
- element_position: "AppExit",
420
- position_name: "应用退出",
421
- element_type: "page",
422
- element_name: "app_exit",
423
- action_type: ActionType.Exit,
424
- action_value: String(duration)
425
- }, true);
426
- // 重置启动时间
427
- _sessionStartTime = 0;
428
- },
429
-
430
- /**
431
- * 更新用户信息(登录后调用,传入memberId等)
432
- * @param {Object} userInfo - 用户信息,如 { user_id: 'nC650471', user_type: '1' }
433
- */
434
- updateUserInfo: function (userInfo) {
435
- if (!userInfo) return;
436
- // 更新公共字段(合并到 data 事件中)
437
- this.setCommonInfo(userInfo);
438
- // 更新额外用户信息(合并到上报的 user 对象中)
439
- for (var key in userInfo) {
440
- if (userInfo.hasOwnProperty(key)) {
441
- _extraUserInfo[key] = userInfo[key];
442
- }
443
- }
444
- console.log('[Reporter] updateUserInfo:', userInfo);
445
- },
446
-
447
- /**
448
- * 获取或创建设备唯一ID
449
- * @returns {string}
450
- */
451
- createDeviceId: function () {
452
- return supersetLewo.createDeviceId();
453
- },
454
-
455
- /**
456
- * 重置设备ID(清除缓存、localStorage、cookie)
457
- */
458
- resetDeviceId: function () {
459
- supersetLewo.resetDeviceId();
460
- if (this._commonInfo) {
461
- this._commonInfo.device_id = supersetLewo.createDeviceId();
462
- }
463
- },
464
-
465
- /**
466
- * 更新公共字段(如用户登录后更新 user_id)
467
- * @param {Object} info - 要更新的字段(下划线格式)
468
- */
469
- setCommonInfo: function (info) {
470
- for (var key in info) {
471
- if (info.hasOwnProperty(key)) {
472
- this._commonInfo[key] = info[key];
473
- }
474
- }
475
- },
476
-
477
- /**
478
- * 获取当前公共字段
479
- * @returns {Object}
480
- */
481
- getCommonInfo: function () {
482
- var copy = {};
483
- for (var key in this._commonInfo) {
484
- if (this._commonInfo.hasOwnProperty(key)) {
485
- copy[key] = this._commonInfo[key];
486
- }
487
- }
488
- return copy;
489
- },
490
-
491
- /** 获取底层 supersetLewo 实例(高级用法) */
492
- get instance() {
493
- return supersetLewo;
494
- },
495
- };
496
-
497
- module.exports = {
498
- Reporter: Reporter,
499
- ActionType: ActionType,
500
- };