@gongxh/bit-core 0.0.3 → 0.0.6
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/LICENSE +21 -0
- package/README.md +175 -56
- package/dist/bit-core.cjs +2215 -223
- package/dist/bit-core.d.ts +579 -20
- package/dist/bit-core.min.cjs +1 -1
- package/dist/bit-core.min.mjs +1 -1
- package/dist/bit-core.mjs +2203 -225
- package/package.json +33 -51
package/dist/bit-core.d.ts
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
import { Component } from 'cc';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* 启用或禁用调试模式。
|
|
5
|
+
* @param enable - 如果为 true,则启用调试模式;如果为 false,则禁用调试模式。不设置默认不开启
|
|
6
|
+
*/
|
|
7
|
+
declare function enableDebugMode(enable: boolean): void;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @Author: Gongxh
|
|
11
|
+
* @Date: 2024-12-07
|
|
12
|
+
* @Description: 适配用的类
|
|
13
|
+
*/
|
|
14
|
+
declare abstract class Adapter {
|
|
15
|
+
/** 适配器实例 */
|
|
16
|
+
static instance: Adapter;
|
|
17
|
+
/**
|
|
18
|
+
* 添加屏幕尺寸发生变化的监听
|
|
19
|
+
* @param listener 监听器
|
|
20
|
+
*/
|
|
21
|
+
addResizeListener(listener: (...args: any) => void): void;
|
|
22
|
+
/**
|
|
23
|
+
* 移除屏幕尺寸发生变化的监听
|
|
24
|
+
* @param listener 监听器
|
|
25
|
+
*/
|
|
26
|
+
removeResizeListener(listener: (...args: any) => void): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @Author: Gongxh
|
|
31
|
+
* @Date: 2024-12-07
|
|
32
|
+
* @Description:cocos游戏入口 定义了游戏启动时的基本配置和初始化流程。
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
declare abstract class CocosEntry extends Component {
|
|
36
|
+
fps: number;
|
|
37
|
+
enableDebug: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 虚函数,子类需要实现
|
|
40
|
+
* kunpo库初始化完成后调用
|
|
41
|
+
*/
|
|
42
|
+
abstract onInit(): void;
|
|
43
|
+
/**
|
|
44
|
+
* 时间相关
|
|
45
|
+
*/
|
|
46
|
+
private initTime;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @Author: Gongxh
|
|
51
|
+
* @Date: 2024-12-07
|
|
52
|
+
* @Description: cocos UI模块
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
declare abstract class Module extends Component {
|
|
56
|
+
/**
|
|
57
|
+
* 模块名称
|
|
58
|
+
* @type {string}
|
|
59
|
+
*/
|
|
60
|
+
readonly moduleName: string;
|
|
61
|
+
/**
|
|
62
|
+
* 虚函数,子类需要实现
|
|
63
|
+
* 模块初始化完成后调用的函数
|
|
64
|
+
* @abstract
|
|
65
|
+
*/
|
|
66
|
+
protected abstract onInit(): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
3
69
|
/**
|
|
4
70
|
* @Author: Gongxh
|
|
5
71
|
* @Date: 2024-12-07
|
|
@@ -111,10 +177,28 @@ declare class Screen {
|
|
|
111
177
|
}
|
|
112
178
|
|
|
113
179
|
/**
|
|
114
|
-
*
|
|
115
|
-
* @
|
|
180
|
+
* @Author: Gongxh
|
|
181
|
+
* @Date: 2025-03-04
|
|
182
|
+
* @Description: 二进制工具类 - 使用 JavaScript 标准库实现
|
|
116
183
|
*/
|
|
117
|
-
declare
|
|
184
|
+
declare class Binary {
|
|
185
|
+
/**
|
|
186
|
+
* 将对象转换为二进制数据
|
|
187
|
+
*/
|
|
188
|
+
static toBinary(obj: any): Uint8Array;
|
|
189
|
+
/**
|
|
190
|
+
* 将二进制数据转换JSON数据
|
|
191
|
+
* @param binary 二进制数据
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
static toJson(binary: any): any;
|
|
195
|
+
/**
|
|
196
|
+
* 检查数据是否为二进制格式
|
|
197
|
+
* @param data 要检查的数据
|
|
198
|
+
* @returns 是否为二进制格式
|
|
199
|
+
*/
|
|
200
|
+
static isBinaryFormat(data: Uint8Array): boolean;
|
|
201
|
+
}
|
|
118
202
|
|
|
119
203
|
/**
|
|
120
204
|
* @Author: Gongxh
|
|
@@ -143,40 +227,515 @@ declare function warn(...args: any[]): void;
|
|
|
143
227
|
*/
|
|
144
228
|
declare function error(...args: any[]): void;
|
|
145
229
|
|
|
230
|
+
/**
|
|
231
|
+
* 对字符串执行md5处理
|
|
232
|
+
*
|
|
233
|
+
* @export
|
|
234
|
+
* @param {string} message 要处理的字符串
|
|
235
|
+
* @returns {string} md5
|
|
236
|
+
*/
|
|
237
|
+
declare function md5(message: string): string;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @Author: Gongxh
|
|
241
|
+
* @Date: 2025-03-06
|
|
242
|
+
* @Description: 时间工具
|
|
243
|
+
*/
|
|
244
|
+
declare class Time {
|
|
245
|
+
/** 获取游戏系统启动时间戳 */
|
|
246
|
+
static get osBootTime(): number;
|
|
247
|
+
/** 获取主动设置的网络时间 单位ms */
|
|
248
|
+
static get netTime(): number;
|
|
249
|
+
/** 获取本地时间与网路时间的偏移量 单位ms */
|
|
250
|
+
static get netTimeDiff(): number;
|
|
251
|
+
/** 获取系统运行时间 */
|
|
252
|
+
static get runTime(): number;
|
|
253
|
+
/**
|
|
254
|
+
* 设置网络时间, 单位ms
|
|
255
|
+
* @param netTime 网络时间
|
|
256
|
+
*/
|
|
257
|
+
static setNetTime(netTime: number): void;
|
|
258
|
+
/**
|
|
259
|
+
* 获取当前时间 单位ms
|
|
260
|
+
*/
|
|
261
|
+
static now(): number;
|
|
262
|
+
/**
|
|
263
|
+
* 将毫秒转换为秒
|
|
264
|
+
* @param ms 毫秒
|
|
265
|
+
*/
|
|
266
|
+
static msTos(ms: number): number;
|
|
267
|
+
/**
|
|
268
|
+
* 将秒转换为毫秒
|
|
269
|
+
*/
|
|
270
|
+
static sToMs(s: number): number;
|
|
271
|
+
/**
|
|
272
|
+
* 获取年份
|
|
273
|
+
* @param timestamp 时间戳 (ms)
|
|
274
|
+
* @returns 年份
|
|
275
|
+
*/
|
|
276
|
+
static getYear(timestamp?: number): number;
|
|
277
|
+
/**
|
|
278
|
+
* 获取月份
|
|
279
|
+
* @param timestamp 时间戳 (ms)
|
|
280
|
+
* @returns 月份
|
|
281
|
+
*/
|
|
282
|
+
static getMonth(timestamp?: number): number;
|
|
283
|
+
/**
|
|
284
|
+
* 获取日期
|
|
285
|
+
* @param timestamp 时间戳 (ms)
|
|
286
|
+
* @returns 日期
|
|
287
|
+
*/
|
|
288
|
+
static getDay(timestamp?: number): number;
|
|
289
|
+
/**
|
|
290
|
+
* 获取小时
|
|
291
|
+
* @param timestamp 时间戳 (ms)
|
|
292
|
+
* @returns 小时
|
|
293
|
+
*/
|
|
294
|
+
static getHour(timestamp?: number): number;
|
|
295
|
+
/**
|
|
296
|
+
* 获取分钟
|
|
297
|
+
* @param timestamp 时间戳 (ms)
|
|
298
|
+
* @returns 分钟
|
|
299
|
+
*/
|
|
300
|
+
static getMinute(timestamp?: number): number;
|
|
301
|
+
/**
|
|
302
|
+
* 获取秒
|
|
303
|
+
* @param timestamp 时间戳 (ms)
|
|
304
|
+
* @returns 秒
|
|
305
|
+
*/
|
|
306
|
+
static getSecond(timestamp?: number): number;
|
|
307
|
+
/**
|
|
308
|
+
* 获取当天开始时间
|
|
309
|
+
* @param timestamp 时间戳 (ms)
|
|
310
|
+
* @returns 时间戳 (ms)
|
|
311
|
+
*/
|
|
312
|
+
static getDayStartTime(timestamp?: number): number;
|
|
313
|
+
/**
|
|
314
|
+
* 获取当天的结束时间
|
|
315
|
+
* @param timestamp 时间戳 (ms)
|
|
316
|
+
* @returns 时间戳 (ms)
|
|
317
|
+
*/
|
|
318
|
+
static getDayEndTime(timestamp?: number): number;
|
|
319
|
+
/**
|
|
320
|
+
* 获取传入时间是周几
|
|
321
|
+
* @param {number} [time] (ms)
|
|
322
|
+
* @returns {number}
|
|
323
|
+
*/
|
|
324
|
+
static getWeekDay(time?: number): number;
|
|
325
|
+
/**
|
|
326
|
+
* 获取当前周的开始时间
|
|
327
|
+
* @param timestamp 时间戳 (ms)
|
|
328
|
+
* @returns 时间戳 (ms)
|
|
329
|
+
*/
|
|
330
|
+
static getWeekStartTime(timestamp?: number): number;
|
|
331
|
+
static getWeekEndTime(timestamp?: number): number;
|
|
332
|
+
/**
|
|
333
|
+
* 获取当前月开始时间
|
|
334
|
+
* @param timestamp 时间戳 (ms)
|
|
335
|
+
* @returns 时间戳 (ms)
|
|
336
|
+
*/
|
|
337
|
+
static getMonthStartTime(timestamp?: number): number;
|
|
338
|
+
/**
|
|
339
|
+
* 获取当前月结束时间
|
|
340
|
+
* @param timestamp 时间戳 (ms)
|
|
341
|
+
* @returns 时间戳 (ms)
|
|
342
|
+
*/
|
|
343
|
+
static getMonthEndTime(timestamp?: number): number;
|
|
344
|
+
/**
|
|
345
|
+
* 获取当前年份开始时间
|
|
346
|
+
* @param timestamp 时间戳 (ms)
|
|
347
|
+
* @returns 时间戳 (ms)
|
|
348
|
+
*/
|
|
349
|
+
static getYearStartTime(timestamp?: number): number;
|
|
350
|
+
/**
|
|
351
|
+
* 获取当前年份结束时间
|
|
352
|
+
* @param timestamp 时间戳 (ms)
|
|
353
|
+
* @returns 时间戳 (ms)
|
|
354
|
+
*/
|
|
355
|
+
static getYearEndTime(timestamp?: number): number;
|
|
356
|
+
/**
|
|
357
|
+
* 获取当前月的天数
|
|
358
|
+
* @param timestamp 时间戳 (ms)
|
|
359
|
+
* @returns 天数
|
|
360
|
+
*/
|
|
361
|
+
static getMonthDays(timestamp?: number): number;
|
|
362
|
+
/**
|
|
363
|
+
* 是否是同一天
|
|
364
|
+
* @param timestamp1 时间戳1 (ms)
|
|
365
|
+
* @param now 时间戳2 (ms) 如果不传,则和当前时间比较
|
|
366
|
+
* @returns 是否是同一天
|
|
367
|
+
*/
|
|
368
|
+
static isSameDay(timestamp1: number, now?: number): boolean;
|
|
369
|
+
/**
|
|
370
|
+
* 是否是同一周
|
|
371
|
+
* @param timestamp1 时间戳1 (ms)
|
|
372
|
+
* @param now 时间戳2 (ms) 如果不传,则和当前时间比较
|
|
373
|
+
* @returns 是否是同一周
|
|
374
|
+
*/
|
|
375
|
+
static isSameWeek(timestamp1: number, now?: number): boolean;
|
|
376
|
+
/**
|
|
377
|
+
* 是否是同一月
|
|
378
|
+
* @param timestamp1 时间戳1 (ms)
|
|
379
|
+
* @param now 时间戳2 (ms) 如果不传,则和当前时间比较
|
|
380
|
+
* @returns 是否是同一月
|
|
381
|
+
*/
|
|
382
|
+
static isSameMonth(timestamp1: number, now?: number): boolean;
|
|
383
|
+
/**
|
|
384
|
+
* 是否是同一年
|
|
385
|
+
* @param timestamp1 时间戳1 (ms)
|
|
386
|
+
* @param now 时间戳2 (ms) 如果不传,则和当前时间比较
|
|
387
|
+
* @returns 是否是同一年
|
|
388
|
+
*/
|
|
389
|
+
static isSameYear(timestamp1: number, now?: number): boolean;
|
|
390
|
+
/**
|
|
391
|
+
* 通用时间格式化方法
|
|
392
|
+
* @param timestamp 时间戳 (ms)
|
|
393
|
+
* @param pattern 格式化模板
|
|
394
|
+
*
|
|
395
|
+
* 支持的占位符(大写补零,小写不补零):
|
|
396
|
+
* - YYYY: 四位年份 (2025) | YY: 两位年份 (25)
|
|
397
|
+
* - MM: 两位月份 (01-12) | M: 月份 (1-12)
|
|
398
|
+
* - DD: 两位日期 (01-31) | D: 日期 (1-31)
|
|
399
|
+
* - hh: 两位小时 (00-23) | h: 小时 (0-23)
|
|
400
|
+
* - mm: 两位分钟 (00-59) | m: 分钟 (0-59)
|
|
401
|
+
* - ss: 两位秒 (00-59) | s: 秒 (0-59)
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* Time.format(timestamp, 'YYYY-MM-DD hh:mm:ss') // "2025-01-05 14:30:45"
|
|
405
|
+
* Time.format(timestamp, 'YYYY年MM月DD日 hh:mm') // "2025年01月05日 14:30"
|
|
406
|
+
* Time.format(timestamp, 'M月D日 h时m分') // "1月5日 14时30分"
|
|
407
|
+
*/
|
|
408
|
+
static format(timestamp: number, pattern: string): string;
|
|
409
|
+
/**
|
|
410
|
+
* 格式化时间 格式: xxxx-xx-xx hh:mm:ss
|
|
411
|
+
* @param timestamp 时间戳 (ms)
|
|
412
|
+
*/
|
|
413
|
+
static formatTime(timestamp: number): string;
|
|
414
|
+
/**
|
|
415
|
+
* 格式化时间 格式: xxxx年xx月xx日 hh:mm:ss
|
|
416
|
+
* @param timestamp 时间戳 (ms)
|
|
417
|
+
*/
|
|
418
|
+
static formatTimeChinese(timestamp: number): string;
|
|
419
|
+
/**
|
|
420
|
+
* 通用时长格式化方法
|
|
421
|
+
* @param seconds 时长(秒)
|
|
422
|
+
* @param pattern 格式化模板
|
|
423
|
+
* @param options 格式化选项
|
|
424
|
+
*
|
|
425
|
+
* 支持的占位符(大写补零,小写不补零):
|
|
426
|
+
* - DD/D: 天数
|
|
427
|
+
* - HH/H: 总小时数(可超过24)
|
|
428
|
+
* - hh/h: 小时数(0-23范围)
|
|
429
|
+
* - MM/M: 总分钟数(可超过60)
|
|
430
|
+
* - mm/m: 分钟数(0-59范围)
|
|
431
|
+
* - ss/s: 秒数(0-59范围)
|
|
432
|
+
*
|
|
433
|
+
* options.autoHide: 自动隐藏为0的高位单位(默认false)
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* Time.formatDuration(3661, 'HH:mm:ss') // "01:01:01"
|
|
437
|
+
* Time.formatDuration(3661, 'MM:ss') // "61:01"
|
|
438
|
+
* Time.formatDuration(3661, 'H小时m分s秒') // "1小时1分1秒"
|
|
439
|
+
* Time.formatDuration(90061, 'DD天hh:mm:ss') // "1天01:01:01"
|
|
440
|
+
* Time.formatDuration(125, 'HH:mm:ss', { autoHide: true }) // "02:05"
|
|
441
|
+
* Time.formatDuration(3661, 'DD天HH时mm分ss秒', { autoHide: true }) // "1时1分1秒"
|
|
442
|
+
*/
|
|
443
|
+
static formatDuration(seconds: number, pattern: string, options?: {
|
|
444
|
+
autoHide?: boolean;
|
|
445
|
+
}): string;
|
|
446
|
+
/**
|
|
447
|
+
* 智能格式化时长 - 自动隐藏为0的高位单位
|
|
448
|
+
* @param time 时间 (s)
|
|
449
|
+
* @param pattern 格式化模板,默认 'D天h小时m分s秒'
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* Time.formatSmart(86461) // "1天1小时1分1秒"
|
|
453
|
+
* Time.formatSmart(3661) // "1小时1分1秒"
|
|
454
|
+
* Time.formatSmart(61) // "1分1秒"
|
|
455
|
+
* Time.formatSmart(1) // "1秒"
|
|
456
|
+
*/
|
|
457
|
+
static formatSmart(time: number, pattern?: string): string;
|
|
458
|
+
/**
|
|
459
|
+
* 智能格式化时长(简化版) - 只显示最大的两个单位,较小单位向上取整
|
|
460
|
+
* @param time 时间 (s)
|
|
461
|
+
* @param pattern 格式化模板,默认 'D天h小时|h小时m分|m分s秒',用 | 分隔不同级别
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* Time.formatSmartSimple(90061) // "1天2小时" (1.04小时向上取整为2)
|
|
465
|
+
* Time.formatSmartSimple(3661) // "1小时2分" (1.02分钟向上取整为2)
|
|
466
|
+
* Time.formatSmartSimple(61) // "1分2秒" (1.02秒向上取整为2)
|
|
467
|
+
* Time.formatSmartSimple(1) // "1秒"
|
|
468
|
+
* Time.formatSmartSimple(90061, 'D天h时|h时m分|m分s秒') // "1天2时"
|
|
469
|
+
*/
|
|
470
|
+
static formatSmartSimple(time: number, pattern?: string): string;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @Author: Gongxh
|
|
475
|
+
* @Date: 2025-04-11
|
|
476
|
+
* @Description:
|
|
477
|
+
*/
|
|
478
|
+
declare class Utils {
|
|
479
|
+
/**
|
|
480
|
+
* 版本号比较
|
|
481
|
+
* @param version1 本地版本号
|
|
482
|
+
* @param version2 远程版本号
|
|
483
|
+
* 如果返回值大于0,则version1大于version2
|
|
484
|
+
* 如果返回值等于0,则version1等于version2
|
|
485
|
+
* 如果返回值小于0,则version1小于version2
|
|
486
|
+
*/
|
|
487
|
+
static compareVersion(version1: string, version2: string): number;
|
|
488
|
+
/**
|
|
489
|
+
* 判断传入的字符串是否是json格式的字符串
|
|
490
|
+
*/
|
|
491
|
+
static isJsonString(str: string): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* 获取url参数
|
|
494
|
+
* @param url
|
|
495
|
+
*/
|
|
496
|
+
static getUrlParam(url: string): {
|
|
497
|
+
url: string;
|
|
498
|
+
params: {
|
|
499
|
+
[key: string]: string;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* 给url添加参数
|
|
504
|
+
* @param url
|
|
505
|
+
* @returns 新的url
|
|
506
|
+
*/
|
|
507
|
+
static addUrlParam(url: string, key: string, value: string): string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @Author: Gongxh
|
|
512
|
+
* @Date: 2025-04-18
|
|
513
|
+
* @Description: 通用的 Promise 结果
|
|
514
|
+
*/
|
|
515
|
+
interface IPromiseResult {
|
|
516
|
+
/** 0:成功 其他:失败 */
|
|
517
|
+
code: number;
|
|
518
|
+
/** 失败信息 */
|
|
519
|
+
message: string;
|
|
520
|
+
}
|
|
521
|
+
interface ICheckUpdatePromiseResult extends IPromiseResult {
|
|
522
|
+
/** 需要更新的资源大小 (KB) */
|
|
523
|
+
size?: number;
|
|
524
|
+
}
|
|
525
|
+
|
|
146
526
|
/**
|
|
147
527
|
* @Author: Gongxh
|
|
148
528
|
* @Date: 2024-12-07
|
|
149
|
-
* @Description:
|
|
529
|
+
* @Description:
|
|
150
530
|
*/
|
|
531
|
+
declare class GlobalTimer {
|
|
532
|
+
/**
|
|
533
|
+
* 启动一个定时器,执行指定的回调函数。
|
|
534
|
+
* @param callback - 要定时执行的回调函数。
|
|
535
|
+
* @param interval - 定时器的时间间隔(秒)。
|
|
536
|
+
* @param loop - [loop=0] 重复次数:0:回调一次,1~n:回调n次,-1:无限重复
|
|
537
|
+
* @returns 返回定时器的ID。
|
|
538
|
+
*/
|
|
539
|
+
static startTimer(callback: () => void, interval: number, loop?: number): number;
|
|
540
|
+
/**
|
|
541
|
+
* 停止指定ID的计时器。
|
|
542
|
+
* @param timerId - 要停止的计时器的唯一标识符。
|
|
543
|
+
*/
|
|
544
|
+
static stopTimer(timerId: number): void;
|
|
545
|
+
/**
|
|
546
|
+
* 暂停指定ID的计时器。
|
|
547
|
+
* @param timerId - 要暂停的计时器的唯一标识符。
|
|
548
|
+
*/
|
|
549
|
+
static pauseTimer(timerId: number): void;
|
|
550
|
+
/**
|
|
551
|
+
* 恢复指定ID的计时器。
|
|
552
|
+
* @param timerId - 要恢复的计时器的唯一标识符。
|
|
553
|
+
*/
|
|
554
|
+
static resumeTimer(timerId: number): void;
|
|
555
|
+
/**
|
|
556
|
+
* 清除所有定时器。
|
|
557
|
+
*/
|
|
558
|
+
static clearAllTimer(): void;
|
|
559
|
+
}
|
|
151
560
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
561
|
+
/**
|
|
562
|
+
* @Author: Gongxh
|
|
563
|
+
* @Date: 2025-02-14
|
|
564
|
+
* @Description: 内部使用的全局定时器
|
|
565
|
+
*/
|
|
566
|
+
declare class InnerTimer {
|
|
567
|
+
private static _timer;
|
|
155
568
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
569
|
+
* 初始化全局定时器,设置定时器间隔为16毫秒。
|
|
570
|
+
* 此方法用于启动一个定时器实例,以便在整个应用程序中跟踪时间相关的操作。
|
|
158
571
|
*/
|
|
159
|
-
|
|
572
|
+
static initTimer(): void;
|
|
573
|
+
/**
|
|
574
|
+
* 启动一个定时器,执行指定的回调函数。
|
|
575
|
+
* @param callback - 要定时执行的回调函数。
|
|
576
|
+
* @param interval - 定时器的时间间隔(秒)。
|
|
577
|
+
* @param loop - [loop=0] 重复次数:0:回调一次,1~n:回调n次,-1:无限重复
|
|
578
|
+
* @returns 返回定时器的ID。
|
|
579
|
+
*/
|
|
580
|
+
static startTimer(callback: () => void, interval: number, loop?: number): number;
|
|
581
|
+
/**
|
|
582
|
+
* 停止指定ID的计时器。
|
|
583
|
+
* @param timerId - 要停止的计时器的唯一标识符。
|
|
584
|
+
*/
|
|
585
|
+
static stopTimer(timerId: number): void;
|
|
586
|
+
static update(dt: number): void;
|
|
160
587
|
}
|
|
161
588
|
|
|
162
589
|
/**
|
|
163
590
|
* @Author: Gongxh
|
|
164
591
|
* @Date: 2024-12-07
|
|
165
|
-
* @Description:
|
|
592
|
+
* @Description: 二叉堆(默认最小堆) 支持最大堆和最小堆
|
|
166
593
|
*/
|
|
594
|
+
declare abstract class HeapNode {
|
|
595
|
+
index: number;
|
|
596
|
+
abstract lessThan(other: HeapNode): boolean;
|
|
597
|
+
}
|
|
598
|
+
declare class BinaryHeap<T extends HeapNode> {
|
|
599
|
+
constructor(capacity: number);
|
|
600
|
+
/**
|
|
601
|
+
* 清空
|
|
602
|
+
*/
|
|
603
|
+
clear(): void;
|
|
604
|
+
/**
|
|
605
|
+
* 获取节点
|
|
606
|
+
* @param index 节点索引
|
|
607
|
+
*/
|
|
608
|
+
get(index: number): T;
|
|
609
|
+
/**
|
|
610
|
+
* 获取顶部节点
|
|
611
|
+
*/
|
|
612
|
+
top(): T;
|
|
613
|
+
/**
|
|
614
|
+
* 是否包含节点
|
|
615
|
+
* @param node 节点
|
|
616
|
+
*/
|
|
617
|
+
contains(node: T): boolean;
|
|
618
|
+
/**
|
|
619
|
+
* Push节点
|
|
620
|
+
* @param node 节点
|
|
621
|
+
*/
|
|
622
|
+
push(node: T): void;
|
|
623
|
+
/**
|
|
624
|
+
* Pop节点
|
|
625
|
+
* @returns
|
|
626
|
+
*/
|
|
627
|
+
pop(): T;
|
|
628
|
+
/**
|
|
629
|
+
* 移除节点
|
|
630
|
+
* @param node 要移除的节点
|
|
631
|
+
*/
|
|
632
|
+
remove(node: T): void;
|
|
633
|
+
/**
|
|
634
|
+
* 更新节点
|
|
635
|
+
* @param node 要更新的节点
|
|
636
|
+
*/
|
|
637
|
+
update(node: T): boolean;
|
|
638
|
+
get count(): number;
|
|
639
|
+
get empty(): boolean;
|
|
640
|
+
}
|
|
167
641
|
|
|
168
|
-
|
|
642
|
+
/** 单链表结结构节点 */
|
|
643
|
+
declare class LinkedNode<T> {
|
|
644
|
+
element: T;
|
|
645
|
+
next: LinkedNode<T>;
|
|
646
|
+
constructor(element: T);
|
|
647
|
+
}
|
|
648
|
+
/** 双向链表结结构节点 */
|
|
649
|
+
declare class DoublyNode<T> extends LinkedNode<T> {
|
|
650
|
+
prev: DoublyNode<T>;
|
|
651
|
+
next: DoublyNode<T>;
|
|
652
|
+
constructor(element: T);
|
|
653
|
+
}
|
|
654
|
+
/** 单向链表 */
|
|
655
|
+
declare class LinkedList<T> {
|
|
169
656
|
/**
|
|
170
|
-
*
|
|
171
|
-
* @
|
|
657
|
+
* create
|
|
658
|
+
* @param equalsFn 比较是否相等(支持自定义)
|
|
172
659
|
*/
|
|
173
|
-
|
|
660
|
+
constructor(equalsFn?: (a: T, b: T) => boolean);
|
|
661
|
+
/** 向链表尾部添加元素 */
|
|
662
|
+
push(element: T): void;
|
|
174
663
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* @
|
|
664
|
+
* 在链表的指定位置插入一个元素。
|
|
665
|
+
* @param element 要插入的元素。
|
|
666
|
+
* @param index 插入位置的索引,从0开始计数。
|
|
667
|
+
* @returns 如果插入成功返回true,否则返回false。
|
|
178
668
|
*/
|
|
179
|
-
|
|
669
|
+
insert(element: T, index: number): boolean;
|
|
670
|
+
/**
|
|
671
|
+
* 获取链表中指定位置的元素,如果不存在返回 underfined
|
|
672
|
+
* @param index
|
|
673
|
+
*/
|
|
674
|
+
getElementAt(index: number): LinkedNode<T>;
|
|
675
|
+
/**
|
|
676
|
+
* 从链表中移除一个元素
|
|
677
|
+
* @param element
|
|
678
|
+
*/
|
|
679
|
+
remove(element: T): T;
|
|
680
|
+
/**
|
|
681
|
+
* 从链表的特定位置移除一个元素
|
|
682
|
+
* @param index
|
|
683
|
+
*/
|
|
684
|
+
removeAt(index: number): T;
|
|
685
|
+
/**
|
|
686
|
+
* 返回元素在链表中的索引,如果没有则返回-1
|
|
687
|
+
* @param element
|
|
688
|
+
*/
|
|
689
|
+
indexOf(element: T): number;
|
|
690
|
+
clear(): void;
|
|
691
|
+
getHead(): LinkedNode<T>;
|
|
692
|
+
isEmpty(): boolean;
|
|
693
|
+
size(): number;
|
|
694
|
+
toString(): string;
|
|
695
|
+
}
|
|
696
|
+
/** 双向链表 */
|
|
697
|
+
declare class DoublyLinkedList<T> extends LinkedList<T> {
|
|
698
|
+
/**
|
|
699
|
+
* create
|
|
700
|
+
* @param equalsFn 比较是否相等(支持自定义)
|
|
701
|
+
*/
|
|
702
|
+
constructor(equalsFn?: (a: T, b: T) => boolean);
|
|
703
|
+
/**
|
|
704
|
+
* 向链表尾部添加元素
|
|
705
|
+
* @param element
|
|
706
|
+
*/
|
|
707
|
+
push(element: T): void;
|
|
708
|
+
/**
|
|
709
|
+
* 向链表指定位置添加元素
|
|
710
|
+
* @param element
|
|
711
|
+
* @param index
|
|
712
|
+
*/
|
|
713
|
+
insert(element: T, index: number): boolean;
|
|
714
|
+
/**
|
|
715
|
+
* 从链表的特定位置移除一个元素
|
|
716
|
+
* @param index
|
|
717
|
+
*/
|
|
718
|
+
removeAt(index: number): T;
|
|
719
|
+
/**
|
|
720
|
+
* 获取链表中指定位置的元素,如果不存在返回 null
|
|
721
|
+
* @param index
|
|
722
|
+
*/
|
|
723
|
+
getElementAt(index: number): DoublyNode<T>;
|
|
724
|
+
getHead(): DoublyNode<T>;
|
|
725
|
+
getTail(): DoublyNode<T>;
|
|
726
|
+
clear(): void;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare class Stack<T> {
|
|
730
|
+
constructor(equalsFn?: (a: T, b: T) => boolean);
|
|
731
|
+
push(element: T): void;
|
|
732
|
+
pop(): T;
|
|
733
|
+
peek(): T;
|
|
734
|
+
size(): number;
|
|
735
|
+
isEmpty(): boolean;
|
|
736
|
+
clear(): void;
|
|
737
|
+
toString(): string;
|
|
180
738
|
}
|
|
181
739
|
|
|
182
|
-
export { CocosEntry, Module, Platform, PlatformType, Screen, debug, enableDebugMode, error, info, log, warn };
|
|
740
|
+
export { Adapter, Binary, BinaryHeap, CocosEntry, DoublyLinkedList, DoublyNode, GlobalTimer, HeapNode, InnerTimer, LinkedList, LinkedNode, Module, Platform, PlatformType, Screen, Stack, Time, Utils, debug, enableDebugMode, error, info, log, md5, warn };
|
|
741
|
+
export type { ICheckUpdatePromiseResult, IPromiseResult };
|