@ives_xxz/framework 2.0.16 → 2.1.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.
package/types/FW.d.ts CHANGED
@@ -1,13 +1,26 @@
1
1
  export as namespace FW;
2
2
 
3
3
  declare namespace FW {
4
+ /**
5
+ * 可构造类型 - 表示可以用 new 关键字实例化的类
6
+ * @template TInstance - 实例类型
7
+ * @template TArgs - 构造函数参数类型数组
8
+ */
4
9
  type Newable<TInstance = unknown, TArgs extends unknown[] = any[]> = new (
5
10
  ...args: TArgs
6
11
  ) => TInstance;
12
+
13
+ /**
14
+ * 抽象类型 - 表示具有原型的对象类型
15
+ * @template T - 原型类型
16
+ */
7
17
  type Abstract<T> = {
8
18
  prototype: T;
9
19
  };
10
-
20
+ /**
21
+ * 服务标识符数据类型 - 用于标识服务的多种可能类型
22
+ * @template TInstance - 实例类型
23
+ */
11
24
  type ServiceIdentifierData<TInstance = unknown> = string | symbol | Newable<TInstance> | Function;
12
25
 
13
26
  type CommonNewable<TInstance = unknown, TArgs extends unknown[] = any[]> = Newable<
@@ -18,43 +31,122 @@ declare namespace FW {
18
31
 
19
32
  type ServiceIdentifier<T = unknown> = CommonServiceIdentifier<T>;
20
33
  /**
21
- * 入口对象
34
+ * 框架入口对象 - 提供访问各种管理器和服务的统一入口
22
35
  */
23
36
  type Entry = {
37
+ /** 时间管理器 */
24
38
  timeMgr: TimeManager;
39
+ /** 层级管理器 */
25
40
  layerMgr: LayerManager;
41
+ /** 资源管理器 */
26
42
  resMgr: ResManager;
43
+ /** 动画管理器 */
27
44
  animationMgr: AnimationManager;
45
+ /** 状态管理器 */
28
46
  stateMgr: StateManager;
47
+ /** 音频管理器 */
29
48
  audioMgr: AudioManager;
49
+ /** Socket管理器 */
30
50
  socketMgr: SocketManager;
51
+ /** 对象管理器 */
31
52
  objectMgr: ObjectManager;
53
+ /** UI管理器 */
32
54
  uiMgr: UiManager;
55
+ /** 组件管理器 */
33
56
  componentMgr: ComponentManager;
57
+ /** 语言管理器 */
34
58
  languageMgr: LanguageManager;
59
+ /** 事件管理器 */
35
60
  evtMgr: EventManager;
61
+ /** 引擎管理器 */
36
62
  engineMgr: EngineManager;
63
+ /** 任务管理器 */
37
64
  taskMgr: TaskManager;
65
+ /** 热更新管理器 */
38
66
  hotUpdateMgr: HotUpdateManager;
67
+ /** Promise管理器 */
39
68
  promiseMgr: PromiseManager;
69
+ /** 性能管理器 */
40
70
  performanceMgr: PerformanceManager;
71
+ /** 场景组件 */
41
72
  scene: Scene;
73
+ /** 当前bundle名称 */
42
74
  bundleName: string;
75
+
76
+ /**
77
+ * 获取指定类型的服务组件
78
+ * @template T - 组件类型
79
+ * @param serviceIdentifier - 服务标识符
80
+ * @returns 对应类型的组件实例
81
+ */
43
82
  getComponent<T>(serviceIdentifier: FW.ServiceIdentifier<T>): T;
83
+
84
+ /**
85
+ * 获取指定类型的所有服务组件
86
+ * @template T - 组件类型
87
+ * @param serviceIdentifier - 服务标识符,可选
88
+ * @returns 对应类型的所有组件实例数组
89
+ */
44
90
  getComponents<T>(serviceIdentifier?: FW.ServiceIdentifier<T>): T[];
91
+
92
+ /**
93
+ * 启动场景
94
+ * @param bundleName - bundle名称
95
+ */
45
96
  launchScene(bundleName: string): void;
97
+
98
+ /**
99
+ * 注册框架组件
100
+ * @param data - 注册数据
101
+ */
46
102
  register(data: RegisterBundle): void;
103
+
104
+ /**
105
+ * 注销框架组件
106
+ * @param data - 注销数据
107
+ */
47
108
  unRegister(data: RegisterBundle): void;
109
+
110
+ /**
111
+ * 获取场景名称
112
+ * @param bundleName - bundle名称
113
+ * @returns 场景名称
114
+ */
48
115
  getSceneName(bundleName: string): string;
116
+
117
+ /**
118
+ * 获取依赖项
119
+ * @param bundleName - bundle名称
120
+ * @returns 依赖项数组
121
+ */
49
122
  getDepend(bundleName: string): string[];
123
+
124
+ /**
125
+ * 更新方法 - 每帧调用
126
+ * @param dt - 帧时间间隔
127
+ */
50
128
  update(dt: number): void;
129
+
130
+ /** 初始化方法 */
51
131
  initialize(): void;
132
+
133
+ /** 重启方法 */
52
134
  restart(): void;
53
135
  };
54
136
 
55
137
  type Manager = {};
56
138
 
139
+ /**
140
+ * Promise管理器 - 提供增强的Promise功能
141
+ */
57
142
  type PromiseManager = {
143
+ /**
144
+ * 执行Promise操作
145
+ * @template T - Promise解析值类型
146
+ * @param executor - Promise执行器函数
147
+ * @param options - 执行选项
148
+ * @returns Promise代理对象
149
+ */
58
150
  execute<T = any>(
59
151
  executor: (
60
152
  resolve: (value: T | PromiseLike<T>) => void,
@@ -64,29 +156,103 @@ declare namespace FW {
64
156
  ) => void = PromiseExcutor,
65
157
  options: PromiseExecuteOptions = {},
66
158
  ): PromiseProxy<T>;
159
+
160
+ /**
161
+ * 等待所有Promise完成
162
+ * @template T - Promise解析值类型
163
+ * @param promises - Promise代理数组
164
+ * @param options - 执行选项
165
+ * @returns 包含所有结果的Promise代理
166
+ */
67
167
  all<T = any>(
68
168
  promises: FW.PromiseProxy<T>[],
69
169
  options: FW.PromiseExecuteOptions = {},
70
170
  ): FW.PromiseProxy<FW.PromiseResult<T>>;
71
171
  };
72
172
 
173
+ /**
174
+ * 语言管理器 - 负责多语言支持和本地化
175
+ */
73
176
  type LanguageManager = {
177
+ /**
178
+ * 注册语言包枚举
179
+ * @param bundleName - bundle名称
180
+ * @param language - 语言枚举
181
+ * @param getter - 获取语言值的函数
182
+ */
74
183
  registerLanguagePackageEnum(
75
184
  bundleName: string,
76
185
  language: any,
77
186
  getter: (key: string, language?: string) => string,
78
187
  ): void;
188
+
189
+ /**
190
+ * 获取支持的语言列表
191
+ * @returns 支持的语言数组
192
+ */
79
193
  getSupportedLanguages(): string[];
194
+
195
+ /**
196
+ * 设置支持的语言列表
197
+ * @param languages - 语言数组
198
+ */
80
199
  setSupportedLanguages(languages: string[]): void;
200
+
201
+ /**
202
+ * 获取所有bundle名称
203
+ * @returns bundle名称数组
204
+ */
81
205
  getBundles(): string[];
206
+
207
+ /**
208
+ * 获取当前语言
209
+ * @returns 当前语言代码
210
+ */
82
211
  getLanguage(): string;
212
+
213
+ /**
214
+ * 获取当前语言索引
215
+ * @returns 语言索引
216
+ */
83
217
  getLanguageIndex(): number;
218
+
219
+ /**
220
+ * 获取语言包值
221
+ * @param bundleName - bundle名称
222
+ * @param key - 键值
223
+ * @param language - 语言代码(可选)
224
+ * @returns 语言包对应值
225
+ */
84
226
  getLanguagePackageValue(bundleName: string, key: string, language?: string): string;
227
+
228
+ /**
229
+ * 获取语言包枚举键列表
230
+ * @param bundleName - bundle名称
231
+ * @returns 键名数组
232
+ */
85
233
  getLanguagePackageEnumKeys(bundleName: string): string[];
234
+
235
+ /**
236
+ * 获取语言包枚举值列表
237
+ * @param bundleName - bundle名称
238
+ * @returns 值数组
239
+ */
86
240
  getLanguagePackageEnumValues(bundleName: string): string[];
241
+
242
+ /**
243
+ * 获取语言包枚举
244
+ * @template K - bundle名称类型
245
+ * @param bundleName - bundle名称
246
+ * @returns 语言包访问器
247
+ */
87
248
  getLanguagePackageEnum<K extends keyof ILanguageBundleAccessor>(
88
249
  bundleName: K,
89
250
  ): ILanguageBundleAccessor[K];
251
+
252
+ /**
253
+ * 初始化语言设置
254
+ * @param language - 语言代码
255
+ */
90
256
  initializeLanguage(language: string);
91
257
  };
92
258
 
@@ -155,7 +321,19 @@ declare namespace FW {
155
321
  onDestroy();
156
322
  };
157
323
 
324
+ /**
325
+ * Socket管理器 - 负责WebSocket连接的管理
326
+ */
158
327
  type SocketManager = {
328
+ /**
329
+ * 创建Socket连接
330
+ * @param tag - 标识符
331
+ * @param address - 地址
332
+ * @param sender - 发送器
333
+ * @param handle - 处理器
334
+ * @param config - 配置
335
+ * @returns Socket实例的Promise
336
+ */
159
337
  createSocket(
160
338
  tag: string,
161
339
  address: string,
@@ -163,23 +341,29 @@ declare namespace FW {
163
341
  handle: Handle,
164
342
  config: SocketConfig,
165
343
  ): Promise<Socket>;
344
+
166
345
  /**
167
- * 获取socket
168
- * @param type
169
- * @returns
346
+ * 获取Socket实例
347
+ * @param tag - 标识符(可选)
348
+ * @returns Socket实例
170
349
  */
171
350
  getSocket(tag?: string): Socket;
172
351
 
352
+ /**
353
+ * 获取所有Socket映射
354
+ * @returns Socket映射表
355
+ */
173
356
  getSocketMap(): Map<string, Socket>;
357
+
174
358
  /** 暂停消息处理 */
175
359
  pauseMessageHandle(): void;
176
360
 
177
361
  /** 恢复消息处理 */
178
362
  resumeMessageHandle(): void;
363
+
179
364
  /**
180
- * 关闭
181
- * @param fs
182
- * @returns
365
+ * 关闭Socket连接
366
+ * @param fs - Socket实例
183
367
  */
184
368
  closeSocket(fs: Socket): void;
185
369
  };
@@ -210,48 +394,67 @@ declare namespace FW {
210
394
  schedule: TimerSchedule;
211
395
  };
212
396
 
397
+ /**
398
+ * Socket连接对象
399
+ */
213
400
  type Socket = {
401
+ /** 销毁方法 */
214
402
  public onDestroy(): void;
403
+
215
404
  /**
216
- * 获取tag
217
- * */
405
+ * 获取标识符
406
+ * @returns 标识符字符串
407
+ */
218
408
  public getTag(): string;
409
+
219
410
  /**
220
411
  * 获取地址
221
- * @returns
412
+ * @returns 地址字符串
222
413
  */
223
414
  getAddress(): string;
224
415
 
225
416
  /**
226
- * 获取socket状态
227
- * @returns
417
+ * 获取Socket状态
418
+ * @returns 状态码
228
419
  */
229
420
  getReadyState(): number;
421
+
230
422
  /**
231
- * 重连
423
+ * 重新连接
424
+ * @param force - 是否强制重连
232
425
  */
233
426
  reconnect(force?: boolean): void;
234
- /**
235
- * 关闭连接
236
- */
427
+
428
+ /** 关闭连接 */
237
429
  close();
238
- /**
239
- * 清理
240
- */
430
+
431
+ /** 清理资源 */
241
432
  clear();
242
- /**
243
- * 暂停消息处理
244
- */
433
+
434
+ /** 暂停消息处理 */
245
435
  pauseMessageHandle();
246
- /**
247
- * 恢复消息处理
248
- */
436
+
437
+ /** 恢复消息处理 */
249
438
  resumeMessageHandle();
250
439
 
440
+ /**
441
+ * 发送消息
442
+ * @param msg - 消息内容
443
+ */
251
444
  send(msg);
252
445
 
446
+ /** 原生WebSocket对象 */
253
447
  socket: WebSocket;
254
448
 
449
+ /**
450
+ * 创建Socket连接
451
+ * @param address - 地址
452
+ * @param tag - 标识符
453
+ * @param sender - 发送器
454
+ * @param handle - 处理器
455
+ * @param config - 配置
456
+ * @returns SocketPromise代理对象
457
+ */
255
458
  createSocket(
256
459
  address: string,
257
460
  tag: string,
@@ -261,15 +464,26 @@ declare namespace FW {
261
464
  ): SocketPromiseProxy;
262
465
  };
263
466
 
467
+ /**
468
+ * Socket配置
469
+ */
264
470
  type SocketConfig = {
471
+ /** 心跳间隔 */
265
472
  heartInternal: number;
473
+ /** 心跳超时时间 */
266
474
  heartTimeout: number;
475
+ /** 心跳弱网时间 */
267
476
  heartWeakTime: number;
477
+ /** 最大重连次数 */
268
478
  maxReconnectTimes: number;
479
+ /** 重连间隔 */
269
480
  reconnectInternal: number;
481
+ /** 协议符号 */
270
482
  protocolSymbol: Symbol;
483
+ /** 协议轮询时间 */
271
484
  protocolPollingTime: number;
272
- certificate: cc.Asset;
485
+ /** 证书(可选) */
486
+ certificate?: cc.Asset;
273
487
  };
274
488
 
275
489
  /**
@@ -329,46 +543,43 @@ declare namespace FW {
329
543
  buttonDisable(target: TargetType);
330
544
  };
331
545
 
546
+ /**
547
+ * 时间管理器 - 负责游戏中的定时器和更新循环
548
+ */
332
549
  type TimeManager = {
550
+ /** 初始化方法 */
333
551
  initialize(): void;
552
+
553
+ /** 销毁方法 */
334
554
  onDestroy(): void;
335
555
 
336
- getTime(): string;
337
556
  /**
338
- * 一次性调度器
557
+ * 获取当前时间字符串
558
+ * @returns 时间字符串
339
559
  */
340
- scheduleOnce(cb?: () => void, tag?: string): FW.TimerSchedule;
560
+ getTime(): string;
561
+
341
562
  /**
342
- * 一次性调度器
563
+ * 一次性调度器(多种重载形式)
343
564
  */
565
+ scheduleOnce(cb?: () => void, tag?: string): FW.TimerSchedule;
344
566
  scheduleOnce(time?: number, tag?: string): FW.TimerSchedule;
345
- /**
346
- * 一次性调度器
347
- */
348
567
  scheduleOnce(cb?: () => void, target?: any): FW.TimerSchedule;
349
- /**
350
- * 一次性调度器
351
- */
352
568
  scheduleOnce(time?: number, target?: any): FW.TimerSchedule;
353
- /**
354
- * 一次性调度器
355
- */
356
569
  scheduleOnce(cb?: () => void, time?: number, tag?: string): FW.TimerSchedule;
357
- /**
358
- * 一次性调度器
359
- */
360
570
  scheduleOnce(time?: number, cb?: () => void, tag?: string): FW.TimerSchedule;
361
- /**
362
- * 一次性调度器
363
- */
364
571
  scheduleOnce(time?: number, cb?: () => void, target?: any): FW.TimerSchedule;
365
- /**
366
- * 一次性调度器
367
- */
368
572
  scheduleOnce(cb?: () => void, time?: number, target?: any): FW.TimerSchedule;
573
+
369
574
  /**
370
575
  * 自定义调度器
371
- * */
576
+ * @param cb - 回调函数
577
+ * @param time - 时间间隔
578
+ * @param repeat - 重复次数
579
+ * @param target - 目标对象
580
+ * @param tag - 标签
581
+ * @returns 时间调度器
582
+ */
372
583
  schedule(
373
584
  cb?: () => void,
374
585
  time?: number,
@@ -376,42 +587,85 @@ declare namespace FW {
376
587
  target?: TargetType,
377
588
  tag?: string,
378
589
  ): TimerSchedule;
379
- /** 暂停调度器 */
380
- pauseSchedule(tag: string): void;
381
- pauseSchedule(target: TargetType): void;
382
- pauseSchedule(id: number): void;
590
+
383
591
  /**
384
- * 取消调度器
385
- * */
386
- unSchedule(tag: string): void;
387
- unSchedule(target: TargetType): void;
388
- unSchedule(id: number): void;
592
+ * 暂停调度器
593
+ * @param tag
594
+ */
595
+ pauseSchedule(tag: string);
389
596
  /**
390
- * 恢复调度器
597
+ * 暂停调度器
598
+ * @param target
599
+ */
600
+ pauseSchedule(target: FW.TargetType);
601
+ /**
602
+ * 暂停调度器
603
+ * @param id
604
+ */
605
+ pauseSchedule(id: number);
606
+
607
+ /**
608
+ * 停止调度器
391
609
  * @param tag
392
610
  */
393
- resumeSchedule(tag: string): void;
394
- resumeSchedule(target: TargetType): void;
395
- resumeSchedule(id: number): void;
611
+ unSchedule(tag: string);
396
612
  /**
397
- * 每一帧更新
398
- * @param cb
613
+ * 停止调度器
614
+ * @param target: Comment | Object | cc.Node
615
+ */
616
+ unSchedule(target: FW.TargetType);
617
+ /**
618
+ * 停止调度器
619
+ * @param id: number
620
+ */
621
+ unSchedule(id: number);
622
+
623
+ /**
624
+ * 恢复调度器
399
625
  * @param tag
400
626
  */
627
+ resumeSchedule(tag: string);
628
+ /**
629
+ * 恢复调度器
630
+ * @param target
631
+ */
632
+ resumeSchedule(target: FW.TargetType);
633
+ /**
634
+ * 暂停调度器
635
+ * @param id
636
+ */
637
+ resumeSchedule(id: number);
638
+
639
+ /**
640
+ * 每帧更新回调注册
641
+ * @param cb - 更新回调函数
642
+ * @param tag - 标签(可选)
643
+ */
401
644
  update(cb: (dt: number) => void, tag?: string): void;
402
- update(cb: (dt: number) => void, target?: TargetType): void;
403
- update(cb: (dt: number) => void, tag?: string, target?: TargetType): void;
645
+
646
+ /**
647
+ * 更新处理方法
648
+ * @param dt - 帧时间间隔
649
+ */
404
650
  onUpdate(dt: number): void;
405
651
  };
406
652
 
653
+ /**
654
+ * 事件管理器 - 负责全局事件的注册、派发和管理
655
+ */
407
656
  type EventManager = {
657
+ /** 初始化方法 */
408
658
  initialize(): void;
659
+
660
+ /** 销毁方法 */
409
661
  onDestroy(): void;
662
+
410
663
  /**
411
- * 注册事件
412
- * @param eventName
413
- * @param cb
414
- * @param target
664
+ * 注册事件监听器
665
+ * @param eventName - 事件名称
666
+ * @param cb - 回调函数
667
+ * @param target - 目标对象
668
+ * @param options - 选项配置
415
669
  */
416
670
  register(
417
671
  eventName: string | number,
@@ -434,6 +688,13 @@ declare namespace FW {
434
688
  },
435
689
  );
436
690
 
691
+ /**
692
+ * 注册一次性事件监听器
693
+ * @param eventName - 事件名称
694
+ * @param cb - 回调函数
695
+ * @param target - 目标对象
696
+ * @param options - 选项配置
697
+ */
437
698
  registerOnce(
438
699
  eventName: string | number,
439
700
  cb: (
@@ -457,23 +718,24 @@ declare namespace FW {
457
718
 
458
719
  /**
459
720
  * 获取事件监听器数量
460
- * @param eventName 事件名
721
+ * @param eventName - 事件名
461
722
  * @returns 监听器数量
462
723
  */
463
724
  getListenerCount(eventName: string | number): number;
725
+
464
726
  /**
465
727
  * 派发事件
466
- * @param eventName
467
- * @param args1
468
- * @param args2
469
- * @param args3
470
- * @param args4
471
- * @param args5
472
- * @param args6
473
- * @param args7
474
- * @param args8
475
- * @param args9
476
- * @param args10
728
+ * @param eventName - 事件名称
729
+ * @param args1 - 参数1(可选)
730
+ * @param args2 - 参数2(可选)
731
+ * @param args3 - 参数3(可选)
732
+ * @param args4 - 参数4(可选)
733
+ * @param args5 - 参数5(可选)
734
+ * @param args6 - 参数6(可选)
735
+ * @param args7 - 参数7(可选)
736
+ * @param args8 - 参数8(可选)
737
+ * @param args9 - 参数9(可选)
738
+ * @param args10 - 参数10(可选)
477
739
  */
478
740
  dispatch(
479
741
  eventName: string | number,
@@ -488,43 +750,46 @@ declare namespace FW {
488
750
  args9?: FW.EventManagerArgs,
489
751
  args10?: FW.EventManagerArgs,
490
752
  ): void;
753
+
491
754
  /**
492
- * 注销事件
493
- * @param eventName
755
+ * 注销事件监听器
756
+ * @param eventName - 事件名称
757
+ * @param target - 目标对象
494
758
  */
495
759
  unRegister(eventName: string | number, target: TargetType): void;
496
760
 
497
761
  /**
498
- * 注销所有事件
499
- * @param eventName
762
+ * 注销所有指定事件的监听器
763
+ * @param eventName - 事件名称
500
764
  */
501
765
  eventOff(eventName: string | number): void;
502
766
 
503
767
  /**
504
- * 注销目标所有事件
505
- * @param target
768
+ * 注销目标对象上的所有事件监听器
769
+ * @param target - 目标对象
506
770
  */
507
771
  targetOff(target: TargetType): void;
508
772
 
509
773
  /**
510
- * 目标对象是否注册了指定事件
511
- * @param eventName
512
- * @param target
774
+ * 检查目标对象是否注册了指定事件
775
+ * @param eventName - 事件名称
776
+ * @param target - 目标对象
777
+ * @returns 是否已注册
513
778
  */
514
779
  has(eventName: string | number, target: Comment | Object): boolean;
515
780
 
516
781
  /**
517
- * 暂停目标身上注册事件
518
- * @param target
782
+ * 暂停目标对象上的所有事件监听
783
+ * @param target - 目标对象
519
784
  */
520
785
  targetPause(target: TargetType): void;
786
+
521
787
  /**
522
- * 恢复目标身上注册事件
523
- * @param target
788
+ * 恢复目标对象上的所有事件监听
789
+ * @param target - 目标对象
524
790
  */
525
791
  targetResume(target: TargetType);
526
792
  };
527
-
528
793
  /**
529
794
  * 事件管理参数
530
795
  */
@@ -620,16 +885,23 @@ declare namespace FW {
620
885
  };
621
886
 
622
887
  /**
623
- * 层级管理器
888
+ * 层级管理器 - 负责游戏界面层级的管理,包括打开、关闭、显示和隐藏等操作
624
889
  */
625
890
  type LayerManager = {
891
+ /** 初始化方法 */
626
892
  initialize(): void;
893
+
894
+ /** 销毁方法 */
627
895
  onDestroy(): void;
896
+
897
+ /** 清理方法 */
628
898
  clear(): void;
629
899
 
630
900
  /**
631
901
  * 异步打开layer
632
- * @param data
902
+ * @template Ctr - LayerController类型
903
+ * @param data - 层级打开参数
904
+ * @returns Promise返回打开的控制器实例
633
905
  */
634
906
  openAsync<Ctr extends FW.LayerController = FWLayerController>(
635
907
  data: LayerOpenArgs<Ctr>,
@@ -637,43 +909,60 @@ declare namespace FW {
637
909
 
638
910
  /**
639
911
  * 同步打开layer
640
- * @param data
912
+ * @template Ctr - LayerController类型
913
+ * @param data - 层级打开参数
914
+ * @returns 打开的控制器实例
641
915
  */
642
916
  openSync<Ctr extends FW.LayerController = FWLayerController>(data: LayerOpenArgs<Ctr>): Ctr;
917
+
643
918
  /**
644
919
  * 显示常驻layer
645
- * @param layer
920
+ * @template Ctr - LayerController类型
921
+ * @param ctr - 控制器实例
922
+ * @returns 控制器实例
646
923
  */
647
924
  displayLayer<Ctr extends FW.LayerController = FWLayerController>(ctr: Ctr): Ctr;
925
+
648
926
  /**
649
927
  * 隐藏常驻layer
650
- * @param layer
928
+ * @template Ctr - LayerController类型
929
+ * @param ctr - 控制器实例
930
+ * @returns 控制器实例
651
931
  */
652
932
  hideLayer<Ctr extends FW.LayerController = FWLayerController>(ctr: Ctr): Ctr;
933
+
653
934
  /**
654
935
  * 关闭layer
655
- * @param layer
936
+ * @template Ctr - LayerController类型
937
+ * @param ctr - 控制器实例
938
+ * @returns LayerController实例
656
939
  */
657
940
  close<Ctr extends FW.LayerController = FWLayerController>(ctr: Ctr): FWLayerController;
658
941
 
659
942
  /**
660
- * 从栈关闭
943
+ * 从栈关闭指定数量的layer
944
+ * @param count - 关闭层数量,默认为1
661
945
  */
662
946
  closeFromStack(count?: number): void;
947
+
663
948
  /**
664
- * 通过名字关闭
665
- * @param name
949
+ * 通过名字关闭layer
950
+ * @param name - layer名称或名称数组
666
951
  */
667
952
  closeFromLayerName(name: string | string[]);
953
+
668
954
  /**
669
- * 移除所有子Layer
670
- * @param layer
955
+ * 移除指定节点的所有子Layer
956
+ * @param node - 父节点
671
957
  */
672
958
  removeAllChildren(node: cc.Node);
673
959
 
960
+ /**
961
+ * 获取Layer映射表
962
+ * @returns Map<控制器构造函数, LayerData>
963
+ */
674
964
  getLayerMap(): Map<new () => LayerController, LayerData>;
675
965
  };
676
-
677
966
  /**
678
967
  * 资源数据
679
968
  */
@@ -722,48 +1011,68 @@ declare namespace FW {
722
1011
  assetProperty: AssetProperty;
723
1012
  };
724
1013
 
1014
+ /**
1015
+ * 资源管理器 - 负责游戏资源的加载、获取和释放等操作
1016
+ */
725
1017
  type ResManager = {
1018
+ /** 初始化方法 */
726
1019
  initialize(): void;
1020
+
1021
+ /** 销毁方法 */
727
1022
  onDestroy(): void;
728
1023
 
729
1024
  /**
730
- * 加载包
731
- * @param bundleName
1025
+ * 加载指定bundle
1026
+ * @param bundleName - bundle名称
1027
+ * @returns Promise返回加载的bundle对象
732
1028
  */
733
1029
  loadBundle(bundleName: string): Promise<cc.AssetManager.Bundle>;
1030
+
734
1031
  /**
735
- * 获取包
736
- * @param bundleName
1032
+ * 获取指定bundle
1033
+ * @param bundleName - bundle名称
1034
+ * @returns bundle对象
737
1035
  */
738
1036
  getBundle(bundleName: string): cc.AssetManager.Bundle;
1037
+
739
1038
  /**
740
- * 获取所有bundle
1039
+ * 获取所有bundle映射表
1040
+ * @returns Map<bundle名称, bundle对象>
741
1041
  */
742
1042
  getBundleMap(): Map<string, cc.AssetManager.Bundle>;
1043
+
743
1044
  /**
744
- * 释放包
745
- * @param bundleName
1045
+ * 释放指定bundle
1046
+ * @param bundleName - bundle名称
746
1047
  */
747
1048
  releaseBundle(bundleName: string): void;
1049
+
748
1050
  /**
749
- * 包是否存在
750
- * @param bundleName
1051
+ * 检查是否已加载指定bundle
1052
+ * @param bundleName - bundle名称
1053
+ * @returns 是否已加载
751
1054
  */
752
1055
  hasBundle(bundleName: string): boolean;
1056
+
753
1057
  /**
754
- * 预加载
755
- * @param assetProperty
1058
+ * 预加载资源
1059
+ * @param assetProperty - 资源属性或资源属性数组
756
1060
  */
757
1061
  preLoad(assetProperty: FW.AssetProperty | FW.AssetProperty[]);
1062
+
758
1063
  /**
759
1064
  * 加载远程资源
760
- * @param url
761
- * @param cb
1065
+ * @template T - 资源类型
1066
+ * @param url - 资源URL
1067
+ * @param cb - 回调函数
1068
+ * @returns Promise返回加载的资源
762
1069
  */
763
1070
  loadRemote<T extends cc.Asset = cc.Asset>(url: string, cb?: (asset: cc.Asset) => T): Promise<T>;
1071
+
764
1072
  /**
765
- * 从远程加载spine动画
766
- * @param data
1073
+ * 从远程加载spine动画数据
1074
+ * @param data - spine资源信息
1075
+ * @returns Promise返回spine骨骼数据
767
1076
  */
768
1077
  loadSpineDataFromRemote(data: {
769
1078
  img: string;
@@ -773,42 +1082,54 @@ declare namespace FW {
773
1082
  }): Promise<sp.SkeletonData>;
774
1083
 
775
1084
  /**
776
- * 加载资源返回数据
777
- * @param assetProperty
1085
+ * 加载资源并返回资源数据
1086
+ * @template T - 资源类型
1087
+ * @param assetProperty - 资源属性
1088
+ * @returns Promise返回资源数据
778
1089
  */
779
1090
  loadAssetData<T extends cc.Asset>(assetProperty: AssetProperty): Promise<AssetData>;
780
1091
 
781
1092
  /**
782
1093
  * 加载资源
783
- * @param assetProperty
1094
+ * @template T - 资源类型
1095
+ * @param assetProperty - 资源属性
1096
+ * @param cb - 回调函数
1097
+ * @returns Promise返回加载的资源
784
1098
  */
785
1099
  loadAsset<T extends cc.Asset>(assetProperty: AssetProperty, cb?: () => void): Promise<T>;
786
1100
 
787
1101
  /**
788
- * 获取资源
789
- * @param assetProperty
1102
+ * 获取资源数据
1103
+ * @template T - 资源类型
1104
+ * @param assetProperty - 资源属性
1105
+ * @returns 资源数据
790
1106
  */
791
1107
  getAssetData<T extends cc.Asset>(assetProperty: AssetProperty): AssetData;
792
1108
 
793
1109
  /**
794
1110
  * 获取资源
795
- * @param assetProperty
1111
+ * @template T - 资源类型
1112
+ * @param assetProperty - 资源属性
1113
+ * @returns 资源对象
796
1114
  */
797
1115
  getAsset<T extends cc.Asset = cc.Asset>(assetProperty: AssetProperty): T;
1116
+
798
1117
  /**
799
1118
  * 释放资源
800
- * @param assetProperty
1119
+ * @param assetProperty - 资源属性
801
1120
  */
802
1121
  releaseAsset(assetProperty: AssetProperty): void;
803
1122
 
804
1123
  /**
805
- * 资源是否存在
806
- * @param assetProperty
1124
+ * 检查资源是否存在
1125
+ * @param assetProperty - 资源属性
1126
+ * @returns 资源是否存在
807
1127
  */
808
1128
  hasAsset(assetProperty: AssetProperty): boolean;
1129
+
809
1130
  /**
810
- * 初始化远程包配置
811
- * @param config
1131
+ * 初始化远程bundle配置
1132
+ * @param config - 远程bundle配置
812
1133
  */
813
1134
  initializeRemoteBundleConfig(config: RemoteBundleConfig): void;
814
1135
  };
@@ -1075,71 +1396,83 @@ declare namespace FW {
1075
1396
  type TaskManager = {
1076
1397
  /**
1077
1398
  * 创建任务
1078
- * @param options
1079
- *
1080
- * frameBudget?: number; 每帧最大执行时间
1081
- * tasksFrameCount?: number; 每帧最多执行的任务个数
1399
+ * @param options - 任务选项
1400
+ * @returns Task对象
1082
1401
  */
1083
-
1084
1402
  createTask(options?: Partial<FW.TaskOptions>): FW.Task;
1403
+
1085
1404
  /**
1086
- * 获取任务
1087
- * @param taskId
1405
+ * 获取指定ID的任务
1406
+ * @param taskId - 任务ID
1407
+ * @returns Task对象或undefined
1088
1408
  */
1089
1409
  getTask(taskId: number): FW.Task | undefined;
1410
+
1090
1411
  /**
1091
- * 移除任务
1092
- * @param taskId
1412
+ * 停止指定ID的任务
1413
+ * @param taskId - 任务ID
1093
1414
  */
1094
1415
  stopTask(taskId: number): void;
1416
+
1095
1417
  /**
1096
1418
  * 获取所有任务
1419
+ * @returns Task数组
1097
1420
  */
1098
1421
  getAllTasks(): FW.Task[];
1099
1422
 
1423
+ /** 销毁方法 */
1100
1424
  onDestroy();
1101
1425
  };
1102
1426
 
1427
+ /**
1428
+ * 状态管理器 - 负责创建和管理系统状态机
1429
+ */
1103
1430
  type StateManager = {
1431
+ /** 初始化方法 */
1104
1432
  initialize(): void;
1433
+
1434
+ /** 销毁方法 */
1105
1435
  onDestroy(): void;
1436
+
1106
1437
  /**
1107
1438
  * 创建一个状态机
1108
- * @param stateMachineName
1439
+ * @param stateMachineName - 状态机名称(可选)
1440
+ * @returns StateMachine对象
1109
1441
  */
1110
1442
  createStateMachine(stateMachineName?: string): StateMachine;
1443
+
1111
1444
  /**
1112
1445
  * 移除一个状态机
1113
- * @param stateMachineName
1114
- * @returns
1446
+ * @param stateMachineName - 状态机名称(可选)
1115
1447
  */
1116
1448
  removeStateMachine(stateMachineName?: string);
1449
+
1117
1450
  /**
1118
1451
  * 暂停一个状态机
1119
- * @param stateMachineName
1120
- * @returns
1452
+ * @param stateMachineName - 状态机名称(可选)
1121
1453
  */
1122
1454
  pauseStateMachine(stateMachineName?: string);
1455
+
1123
1456
  /**
1124
1457
  * 恢复状态机
1125
- * @param stateMachineName
1126
- * @returns
1458
+ * @param stateMachineName - 状态机名称(可选)
1127
1459
  */
1128
1460
  resumeStateMachine(stateMachineName?: string);
1461
+
1129
1462
  /**
1130
1463
  * 注册状态进指定状态机
1131
- * @param stateMachineName
1132
- * @param state
1133
- * @returns
1464
+ * @param state - 状态机注册参数
1465
+ * @param stateMachineName - 状态机名称(可选)
1134
1466
  */
1135
1467
  register(
1136
1468
  state: FW.StateMachineRegisterArgs | FW.StateMachineRegisterArgs[],
1137
1469
  stateMachineName?: string,
1138
1470
  );
1471
+
1139
1472
  /**
1140
1473
  * 注销指定状态机的某个状态
1141
- * @param stateMachineName
1142
- * @param stateType
1474
+ * @param stateType - 状态类型
1475
+ * @param stateMachineName - 状态机名称(可选)
1143
1476
  */
1144
1477
  unRegister(stateType: number, stateMachineName?: string);
1145
1478
  };
@@ -1149,42 +1482,89 @@ declare namespace FW {
1149
1482
  error: boolean;
1150
1483
  };
1151
1484
 
1485
+ /**
1486
+ * 动画管理器 - 负责游戏中的动画创建和管理
1487
+ */
1152
1488
  type AnimationManager = {
1489
+ /** 初始化方法 */
1153
1490
  initialize(): void;
1491
+
1492
+ /** 销毁方法 */
1154
1493
  onDestroy(): void;
1155
1494
 
1156
1495
  /**
1157
1496
  * 创建一个tween动画
1158
- * @param args
1159
- * @returns
1497
+ * @param args - tween动画参数
1498
+ * @returns Tween动画对象
1160
1499
  */
1161
- createTween(args?: FW.TweenArgs): FW.Tween;
1500
+ createTween(args?: FW.TweenArgs): Tween;
1501
+
1162
1502
  /**
1163
1503
  * 创建一个skeleton动画
1164
- * @param skeleton
1165
- * @returns
1504
+ * @param skeleton - spine骨骼对象
1505
+ * @returns Skeleton动画对象
1166
1506
  */
1167
- createSkeleton(skeleton: sp.Skeleton): FW.Skeleton;
1507
+ createSkeleton(skeleton: sp.Skeleton): Skeleton;
1168
1508
 
1169
- /**
1170
- * 暂停所有动画
1171
- */
1509
+ /** 暂停所有动画 */
1172
1510
  pauseAll(): void;
1173
- /**
1174
- * 恢复所有动画
1175
- * */
1511
+
1512
+ /** 恢复所有动画 */
1176
1513
  resumeAll(): void;
1177
1514
  };
1178
1515
 
1516
+ /**
1517
+ * Tween动画对象 - 用于创建和控制缓动动画
1518
+ */
1179
1519
  type Tween = {
1520
+ /** 动画名称 */
1180
1521
  animationName: string;
1522
+
1523
+ /** Cocos Creator原生Tween对象 */
1181
1524
  animation: cc.Tween;
1525
+
1526
+ /** 初始化回调函数(可选) */
1182
1527
  onInit?(): void;
1528
+
1529
+ /**
1530
+ * 暂停动画
1531
+ * @returns 当前Tween对象,支持链式调用
1532
+ */
1183
1533
  pause(): FW.Tween;
1534
+
1535
+ /**
1536
+ * 恢复动画
1537
+ * @returns 当前Tween对象,支持链式调用
1538
+ */
1184
1539
  resume(): FW.Tween;
1540
+
1541
+ /**
1542
+ * 设置动画时间缩放比例
1543
+ * @param scale - 时间缩放比例,1为正常速度,大于1加快,小于1减慢
1544
+ * @returns 当前Tween对象,支持链式调用
1545
+ */
1185
1546
  timeScale(scale: number): FW.Tween;
1547
+
1548
+ /**
1549
+ * 开始播放动画
1550
+ * @returns 当前Tween对象,支持链式调用
1551
+ */
1186
1552
  start(): FW.Tween;
1553
+
1554
+ /**
1555
+ * 停止动画
1556
+ * @returns 当前Tween对象,支持链式调用
1557
+ */
1187
1558
  stop(): FW.Tween;
1559
+
1560
+ /**
1561
+ * 在指定时间内将属性变化到目标值
1562
+ * @template OPTS - 选项类型
1563
+ * @param duration - 持续时间(秒)
1564
+ * @param props - 目标属性值
1565
+ * @param opts - 动画选项(如缓动函数、进度回调等)
1566
+ * @returns 当前Tween对象,支持链式调用
1567
+ */
1188
1568
  to<
1189
1569
  OPTS extends Partial<{
1190
1570
  progress: Function;
@@ -1196,6 +1576,15 @@ declare namespace FW {
1196
1576
  props: ConstructorType<T>,
1197
1577
  opts?: OPTS,
1198
1578
  ): FW.Tween;
1579
+
1580
+ /**
1581
+ * 在指定时间内将属性按照增量变化
1582
+ * @template OPTS - 选项类型
1583
+ * @param duration - 持续时间(秒)
1584
+ * @param props - 属性增量值
1585
+ * @param opts - 动画选项(如缓动函数、进度回调等)
1586
+ * @returns 当前Tween对象,支持链式调用
1587
+ */
1199
1588
  by<
1200
1589
  OPTS extends Partial<{
1201
1590
  progress: Function;
@@ -1207,50 +1596,87 @@ declare namespace FW {
1207
1596
  props: ConstructorType<T>,
1208
1597
  opts?: OPTS,
1209
1598
  ): FW.Tween;
1599
+
1600
+ /**
1601
+ * 立即设置属性值
1602
+ * @param props - 要设置的属性值
1603
+ * @returns 当前Tween对象,支持链式调用
1604
+ */
1210
1605
  set(props: ConstructorType<T>): FW.Tween;
1211
1606
  };
1212
1607
 
1608
+ /**
1609
+ * Spine骨骼动画对象 - 用于控制Spine骨骼动画的播放和设置
1610
+ */
1213
1611
  type Skeleton = {
1612
+ /**
1613
+ * 播放动画
1614
+ * @param args - 骨骼动画参数
1615
+ * @returns Promise,在动画播放完成后resolve
1616
+ */
1214
1617
  play(args?: FW.SkeletonArgs): Promise<void>;
1618
+
1619
+ /**
1620
+ * 播放指定名称的动画
1621
+ * @param animationName - 动画名称
1622
+ * @param args - 骨骼动画参数
1623
+ * @returns Promise,在动画播放完成后resolve
1624
+ */
1215
1625
  play(animationName?: string, args?: FW.SkeletonArgs): Promise<void>;
1216
- /** 设置皮肤 */
1626
+
1627
+ /**
1628
+ * 设置皮肤
1629
+ * @param skinName - 皮肤名称
1630
+ */
1217
1631
  setSkin(skinName: string);
1218
- /** 更新数据 */
1632
+
1633
+ /**
1634
+ * 更新骨骼数据
1635
+ * @param data - 新的骨骼数据
1636
+ */
1219
1637
  updateSkeletonData(data: sp.SkeletonData);
1220
1638
 
1639
+ /**
1640
+ * 获取当前轨道条目
1641
+ * @returns 轨道条目对象
1642
+ */
1221
1643
  getTrackEntry();
1644
+
1222
1645
  /**
1223
- * 是否存在动画名
1224
- * @param animName
1225
- * @returns
1646
+ * 检查是否存在指定名称的动画
1647
+ * @param animName - 动画名称
1648
+ * @returns 是否存在该动画
1226
1649
  */
1227
1650
  hasAnimation(animName: string);
1651
+
1228
1652
  /**
1229
1653
  * 获取所有动画
1230
- * @returns
1654
+ * @returns 动画列表
1231
1655
  */
1232
1656
  getAnimations();
1233
1657
 
1234
1658
  /**
1235
- * 获取所有动画名字
1236
- * @returns
1659
+ * 获取所有动画名称
1660
+ * @returns 动画名称数组
1237
1661
  */
1238
1662
  getAnimationNames(): string[];
1239
1663
 
1240
- /** 速度缩放 */
1241
- timeScale(timeScale: number);
1242
1664
  /**
1243
- * 暂停
1665
+ * 设置时间缩放比例
1666
+ * @param timeScale - 时间缩放比例
1244
1667
  */
1668
+ timeScale(timeScale: number);
1669
+
1670
+ /** 暂停动画 */
1245
1671
  pause(): void;
1246
- /**
1247
- * 恢复
1248
- */
1672
+
1673
+ /** 恢复动画 */
1249
1674
  resume(): void;
1675
+
1250
1676
  /**
1251
- * 添加spine挂点
1252
- * @param boneName
1253
- * @param node
1677
+ * 添加骨骼挂点
1678
+ * @param boneName - 骨骼名称
1679
+ * @param node - 要挂载的节点
1254
1680
  */
1255
1681
  addBone(boneName: string, node: cc.Node);
1256
1682
  };
@@ -1384,29 +1810,40 @@ declare namespace FW {
1384
1810
  onUpdate(dt?: number): void;
1385
1811
  };
1386
1812
 
1813
+ /**
1814
+ * 状态机 - 管理不同状态之间的转换和执行
1815
+ */
1387
1816
  type StateMachine = {
1817
+ /** 当前状态 */
1388
1818
  state: number;
1389
1819
 
1390
- enter(stateType: number, ...args: any): void;
1391
- /**
1392
- * 暂停状态机
1393
- * */
1394
- pause();
1395
1820
  /**
1396
- * 恢复状态机
1821
+ * 进入指定状态
1822
+ * @param stateType - 状态类型
1823
+ * @param args - 传递给状态的参数
1397
1824
  */
1825
+ enter(stateType: number, ...args: any): void;
1826
+
1827
+ /** 暂停状态机 */
1828
+ pause();
1829
+
1830
+ /** 恢复状态机 */
1398
1831
  resume();
1832
+
1399
1833
  /**
1400
- * 注册
1401
- * @param type
1402
- * @param state
1834
+ * 注册状态
1835
+ * @template T - 状态基类类型
1836
+ * @param state - 状态机注册参数
1403
1837
  */
1404
1838
  register<T extends FWStateBase>(state: FW.StateMachineRegisterArgs<T>);
1839
+
1405
1840
  /**
1406
- * 注销
1407
- * @param type
1841
+ * 注销状态
1842
+ * @param stateType - 状态类型
1408
1843
  */
1409
1844
  unRegister(stateType: number);
1845
+
1846
+ /** 销毁方法 */
1410
1847
  onDestroy();
1411
1848
  };
1412
1849
 
@@ -1424,62 +1861,72 @@ declare namespace FW {
1424
1861
  stateConstructor: { new (): T };
1425
1862
  };
1426
1863
 
1864
+ /**
1865
+ * 音频管理器 - 负责游戏中背景音乐和音效的播放控制
1866
+ */
1427
1867
  type AudioManager = {
1428
1868
  /**
1429
1869
  * 播放背景音乐
1430
- * @param path
1431
- * @param volume
1432
- * @param loop
1870
+ * @param path - 音频资源路径
1871
+ * @param volume - 音量(0-1),默认为1
1872
+ * @param loop - 是否循环播放,默认为true
1433
1873
  */
1434
1874
  playMusic(path: string, volume?: number, loop?: boolean): void;
1875
+
1435
1876
  /**
1436
1877
  * 播放背景音乐
1437
- * @param music
1438
- * @param volume
1439
- * @param loop
1878
+ * @param music - 音频剪辑对象
1879
+ * @param volume - 音量(0-1),默认为1
1880
+ * @param loop - 是否循环播放,默认为true
1440
1881
  */
1441
1882
  playMusic(music: cc.AudioClip, volume?: number, loop?: boolean);
1883
+
1442
1884
  /**
1443
1885
  * 播放背景音乐
1444
- * @param assetProperty
1445
- * @param volume
1446
- * @param loop
1886
+ * @param assetProperty - 资源属性
1887
+ * @param volume - 音量(0-1),默认为1
1888
+ * @param loop - 是否循环播放,默认为true
1447
1889
  */
1448
1890
  playMusic(assetProperty: AssetProperty, volume?: number, loop?: boolean): void;
1449
- /**
1450
- * 停止背景音乐
1451
- */
1891
+
1892
+ /** 停止背景音乐 */
1452
1893
  stopMusic(): void;
1453
- /**
1454
- * 暂停背景音乐
1455
- */
1894
+
1895
+ /** 暂停背景音乐 */
1456
1896
  pauseMusic(): void;
1457
- /**
1458
- * 恢复背景音乐
1459
- */
1897
+
1898
+ /** 恢复背景音乐 */
1460
1899
  resumeMusic(): void;
1900
+
1461
1901
  /**
1462
- * 设置背景音效是否静音
1463
- * @param mute
1902
+ * 设置背景音乐是否静音
1903
+ * @param mute - 是否静音
1464
1904
  */
1465
1905
  setMusicMute(mute: boolean): void;
1906
+
1466
1907
  /**
1467
- * 停止
1468
- * @param id
1908
+ * 停止指定ID的音频
1909
+ * @param id - 音频ID
1469
1910
  */
1470
1911
  stop(id: number): void;
1912
+
1471
1913
  /**
1472
1914
  * 播放音效
1473
- * @param path
1474
- * @param volume
1475
- * @param loop
1915
+ * @param path - 音频资源路径
1916
+ * @param cb - 回调函数,参数为播放的音频ID
1917
+ * @param volume - 音量(0-1),默认为1
1918
+ * @param loop - 是否循环播放,默认为false
1919
+ * @returns Promise<number> 音频ID
1476
1920
  */
1477
1921
  play(path: string, cb?: (id: number) => void, volume?: number, loop?: boolean): Promise<number>;
1922
+
1478
1923
  /**
1479
1924
  * 播放音效
1480
- * @param audio
1481
- * @param volume
1482
- * @param loop
1925
+ * @param audio - 音频剪辑对象
1926
+ * @param cb - 回调函数,参数为播放的音频ID
1927
+ * @param volume - 音量(0-1),默认为1
1928
+ * @param loop - 是否循环播放,默认为false
1929
+ * @returns Promise<number> 音频ID
1483
1930
  */
1484
1931
  play(
1485
1932
  audio: cc.AudioClip,
@@ -1487,11 +1934,14 @@ declare namespace FW {
1487
1934
  volume?: number,
1488
1935
  loop?: boolean,
1489
1936
  ): Promise<number>;
1937
+
1490
1938
  /**
1491
1939
  * 播放音效
1492
- * @param assetProperty
1493
- * @param volume
1494
- * @param loop
1940
+ * @param assetProperty - 资源属性
1941
+ * @param cb - 回调函数,参数为播放的音频ID
1942
+ * @param volume - 音量(0-1),默认为1
1943
+ * @param loop - 是否循环播放,默认为false
1944
+ * @returns Promise<number> 音频ID
1495
1945
  */
1496
1946
  play(
1497
1947
  assetProperty: AssetProperty,
@@ -1499,21 +1949,19 @@ declare namespace FW {
1499
1949
  volume?: number,
1500
1950
  loop?: boolean,
1501
1951
  ): Promise<number>;
1502
- /**
1503
- * 暂停所有
1504
- */
1952
+
1953
+ /** 暂停所有音频 */
1505
1954
  pauseAll(): void;
1506
- /**
1507
- * 恢复所有
1508
- */
1955
+
1956
+ /** 恢复所有音频 */
1509
1957
  resumeAll(): void;
1510
- /**
1511
- * 停止所有
1512
- */
1958
+
1959
+ /** 停止所有音频 */
1513
1960
  stopAll(): void;
1961
+
1514
1962
  /**
1515
- * 设置播放音效是否静音
1516
- * @param mute
1963
+ * 设置音效是否静音
1964
+ * @param mute - 是否静音
1517
1965
  */
1518
1966
  setSoundMute(mute: boolean): void;
1519
1967
  };
@@ -1712,43 +2160,47 @@ declare namespace FW {
1712
2160
  };
1713
2161
 
1714
2162
  /**
1715
- * 任务
2163
+ * 任务对象 - 代表一个可控制的异步任务
1716
2164
  */
1717
2165
  type Task = {
1718
- /** id */
2166
+ /** 任务ID */
1719
2167
  readonly id: number;
2168
+
1720
2169
  /**
1721
2170
  * 获取当前任务状态
2171
+ * @returns 任务状态
1722
2172
  */
1723
2173
  getStatus(): FW.SystemDefine.FWTaskStatus;
2174
+
1724
2175
  /**
1725
- * 任务开始
1726
- * @param generator
2176
+ * 启动任务
2177
+ * @param generator - 任务生成器函数
2178
+ * @returns 当前Task对象,支持链式调用
1727
2179
  */
1728
2180
  start(generator: TaskFunction): Task;
2181
+
1729
2182
  /**
1730
2183
  * 添加任务
1731
- * @param generator
2184
+ * @param generator - 任务生成器函数
2185
+ * @returns 当前Task对象,支持链式调用
1732
2186
  */
1733
2187
  add(generator: TaskFunction): Task;
1734
- /**
1735
- * 任务暂停
1736
- */
2188
+
2189
+ /** 暂停任务 */
1737
2190
  pause(): void;
1738
- /**
1739
- * 任务恢复
1740
- */
2191
+
2192
+ /** 恢复任务 */
1741
2193
  resume(): void;
1742
- /**
1743
- * 重置
1744
- */
2194
+
2195
+ /** 重置任务 */
1745
2196
  reset(): void;
1746
- /**
1747
- * 停止任务
1748
- */
2197
+
2198
+ /** 停止任务 */
1749
2199
  stop(): void;
2200
+
1750
2201
  /**
1751
2202
  * 获取任务性能报告
2203
+ * @returns 任务性能报告
1752
2204
  */
1753
2205
  getPerformanceReport(): TaskPerformanceReport;
1754
2206
  };
@@ -1837,8 +2289,6 @@ declare namespace FW {
1837
2289
  retryCondition?: (error: any, retryCount: number) => boolean;
1838
2290
  };
1839
2291
 
1840
- type Promise = (resolve: (value: any) => void, reject: (reason?: any) => void) => void;
1841
-
1842
2292
  type PromiseAllResult<T = any> = {
1843
2293
  success: Array<{ id: number; value: T }>;
1844
2294
  failed: Array<{ id: number; reason: any }>;
@@ -1926,8 +2376,18 @@ declare namespace FW {
1926
2376
  createRegistry(bundleName: string): Registry;
1927
2377
  destroyRegistry(bundleName: string): void;
1928
2378
  register(data: RegisterFramework): void;
2379
+ /**
2380
+ * 注销组件
2381
+ * @param data
2382
+ */
1929
2383
  unRegister(data: RegisterFramework): void;
2384
+ /**
2385
+ * 重启框架
2386
+ */
1930
2387
  restart(): void;
2388
+ /**
2389
+ * 获取已注册的组件
2390
+ */
1931
2391
  getRegisteredComponents(): Map<string, RegisterFramework[]>;
1932
2392
  };
1933
2393
  declare let Framework: Framework;
@@ -1941,18 +2401,45 @@ declare namespace FW {
1941
2401
  public config?: FW.AssetConfig;
1942
2402
  public sender?: FW.Sender;
1943
2403
  public handle?: FW.Handle;
2404
+
2405
+ /**
2406
+ * 调用Promise函数 并捕获性能数据
2407
+ * @param operation
2408
+ * @param operationName
2409
+ */
1944
2410
  public invoke<T>(operation: Promise<T>, operationName: string = 'unknown'): Promise<T>;
2411
+ /**
2412
+ * 获取逻辑组件
2413
+ */
1945
2414
  public getLogic<T extends FW.Logic = FWLogic>();
2415
+ /**
2416
+ * 获取数据组件
2417
+ */
1946
2418
  public getData<T extends FW.Data = FWData>();
2419
+ /**
2420
+ * 获取发送组件
2421
+ */
1947
2422
  public getSender<T extends FW.Sender>();
2423
+ /**
2424
+ * 获取处理组件
2425
+ */
1948
2426
  public getHandle<T extends FW.Handle>();
2427
+ /**
2428
+ * 获取配置组件
2429
+ */
1949
2430
  public getConfig<T extends FW.AssetConfig>();
2431
+ /**
2432
+ * 初始化依赖
2433
+ */
1950
2434
  public initializeDependencies(): void;
1951
2435
  }
1952
2436
  }
1953
2437
 
1954
2438
  declare namespace FW {
1955
2439
  namespace SystemDefine {
2440
+ /**
2441
+ * 绑定标签
2442
+ */
1956
2443
  export class FWBindTag {
1957
2444
  static LOGIC = 0;
1958
2445
  static DATA = 1;
@@ -1962,6 +2449,9 @@ declare namespace FW {
1962
2449
  static SUB_LOGIC = 5;
1963
2450
  }
1964
2451
 
2452
+ /**
2453
+ * 对象类型
2454
+ */
1965
2455
  export class FWObjectType {
1966
2456
  static ACTIVE = 0;
1967
2457
  static OPACITY = 1;
@@ -1998,10 +2488,25 @@ declare namespace FW {
1998
2488
  static POPUP_DISPOSABLE = 3;
1999
2489
  }
2000
2490
 
2491
+ /**
2492
+ * 任务状态
2493
+ */
2001
2494
  export class FWTaskStatus {
2495
+ /**
2496
+ * 待处理
2497
+ */
2002
2498
  static IDLE = 'IDLE';
2499
+ /**
2500
+ * 运行中
2501
+ */
2003
2502
  static RUNNING = 'RUNNING';
2503
+ /**
2504
+ * 暂停中
2505
+ */
2004
2506
  static PAUSED = 'PAUSED';
2507
+ /**
2508
+ * 完成
2509
+ */
2005
2510
  static COMPLETED = 'COMPLETED';
2006
2511
  }
2007
2512
 
@@ -2059,29 +2564,44 @@ declare namespace FW {
2059
2564
  static ANIMATION = 'ANIMATION';
2060
2565
  }
2061
2566
 
2567
+ /**
2568
+ * 滚动视图模板类型
2569
+ */
2062
2570
  export class FWScrollViewTemplateType {
2063
2571
  static NODE = 0;
2064
2572
  static PREFAB = 1;
2065
2573
  }
2066
2574
 
2575
+ /**
2576
+ * 滚动视图滑动类型
2577
+ */
2067
2578
  export class FWScrollViewSlideType {
2068
2579
  static NORMAL = 0;
2069
2580
  static ADHERING = 1;
2070
2581
  static PAGE = 2;
2071
2582
  }
2072
2583
 
2584
+ /**
2585
+ * 滚动视图选中类型
2586
+ */
2073
2587
  export class FWScrollViewSelectedType {
2074
2588
  static NONE = 0;
2075
2589
  static SINGLE = 1;
2076
2590
  static MULTIPLE = 2;
2077
2591
  }
2078
2592
 
2593
+ /**
2594
+ * 语言资源类型
2595
+ */
2079
2596
  export class FWLanguageAssetType {
2080
2597
  static LABEL = 'label';
2081
2598
  static SPRITE = 'sprite';
2082
2599
  static SKELETON = 'skeleton';
2083
2600
  }
2084
2601
 
2602
+ /**
2603
+ * Promise状态
2604
+ */
2085
2605
  export class FWPromiseStatus {
2086
2606
  static PENDING = 'pending';
2087
2607
  static FULFILLED = 'fulfilled';
@@ -2089,6 +2609,9 @@ declare namespace FW {
2089
2609
  static CANCELLED = 'cancelled';
2090
2610
  }
2091
2611
 
2612
+ /**
2613
+ * 层状态
2614
+ */
2092
2615
  export class FWLayerState {
2093
2616
  static CLOSED = 'closed';
2094
2617
  static OPENING = 'opening';
@@ -2096,6 +2619,9 @@ declare namespace FW {
2096
2619
  static CLOSING = 'closing';
2097
2620
  }
2098
2621
 
2622
+ /**
2623
+ * 音频类型
2624
+ */
2099
2625
  export class FWAudioType {
2100
2626
  static MUSIC = 0;
2101
2627
  static SOUND = 1;
@@ -2130,11 +2656,20 @@ declare namespace FW {
2130
2656
  static ON_HIDE = 'ON_HIDE';
2131
2657
  }
2132
2658
  }
2659
+ /**
2660
+ * 系统定义
2661
+ */
2133
2662
  export const SystemDefine: SystemDefine;
2663
+ /**
2664
+ * 事件定义
2665
+ */
2134
2666
  export const EventDefine: EventDefine;
2135
2667
  }
2136
2668
 
2137
2669
  declare namespace FW {
2670
+ /**
2671
+ * layer基类
2672
+ */
2138
2673
  export class Layer extends cc.Component {
2139
2674
  node: cc.Node;
2140
2675
  ctr: LayerController;
@@ -2147,6 +2682,9 @@ declare namespace FW {
2147
2682
  public lateUpdate(dt: number): void;
2148
2683
  }
2149
2684
 
2685
+ /**
2686
+ * layer控制器基类
2687
+ */
2150
2688
  export class LayerController extends FrameworkBase {
2151
2689
  readonly entry: FW.Entry;
2152
2690
  logic?: Logic;
@@ -2203,9 +2741,16 @@ declare namespace FW {
2203
2741
  prototype: T;
2204
2742
  },
2205
2743
  ): T;
2744
+ /**
2745
+ * 注册事件
2746
+ * @param args
2747
+ */
2206
2748
  registerEvent(args: RegisterArgs): void;
2749
+ /** 注销事件 */
2207
2750
  unRegisterEvent(args: RegisterArgs);
2751
+ /** 注销所有事件 */
2208
2752
  unRegisterAll(): void;
2753
+ /** 注销指定对象所有事件 */
2209
2754
  unRegisterTarget(target: TargetType);
2210
2755
  /** 暂停事件 */
2211
2756
  pauseEvent();
@@ -2213,11 +2758,18 @@ declare namespace FW {
2213
2758
  resumeEvent();
2214
2759
  /** 关闭layer */
2215
2760
  close();
2761
+ /**
2762
+ * 添加外部引用
2763
+ * @param cb
2764
+ */
2216
2765
  addExternalReference?(cb?: (ctr: any) => void);
2217
2766
  }
2218
2767
  }
2219
2768
 
2220
2769
  declare namespace FW {
2770
+ /**
2771
+ * 注册类
2772
+ */
2221
2773
  export abstract class Registry {
2222
2774
  /**
2223
2775
  * bundle名字
@@ -2256,37 +2808,60 @@ declare namespace FW {
2256
2808
  */
2257
2809
  readonly handle?: Newable<SocketHandle>;
2258
2810
 
2811
+ /**
2812
+ * 注册
2813
+ */
2259
2814
  register(): void;
2815
+ /**
2816
+ * 卸载
2817
+ */
2260
2818
  unRegister(): void;
2261
-
2819
+ /**
2820
+ * 启用bundle
2821
+ */
2262
2822
  bundleEnabled(enable?: boolean);
2263
2823
  }
2264
2824
  }
2265
2825
 
2266
2826
  declare namespace FW {
2827
+ /**
2828
+ * 系统配置
2829
+ */
2267
2830
  export const SystemConfig;
2268
-
2831
+ /**
2832
+ * 场景
2833
+ */
2269
2834
  export class Scene extends cc.Component {
2270
2835
  onLoad(): void;
2271
2836
  update(dt: number);
2272
2837
  onDestroy(): void;
2273
2838
  }
2274
-
2839
+ /**
2840
+ * 逻辑
2841
+ */
2275
2842
  export class Logic extends FrameworkBase {
2276
2843
  public initialize?(): void;
2277
2844
  public onDestroy?(): void;
2278
2845
  }
2279
-
2846
+ /**
2847
+ * 数据
2848
+ */
2280
2849
  export class Data extends FrameworkBase {
2281
2850
  public initialize?(): void;
2282
2851
  public onDestroy?(): void;
2283
2852
  }
2284
2853
 
2854
+ /**
2855
+ * 资源配置
2856
+ */
2285
2857
  export abstract class AssetConfig {
2286
2858
  abstract preLoad: LoadConfig;
2287
2859
  abstract demandLoad: LoadConfig;
2288
2860
  }
2289
2861
 
2862
+ /**
2863
+ * socket发送者
2864
+ */
2290
2865
  export abstract class Sender extends FrameworkBase {
2291
2866
  initialize?();
2292
2867
  onDestroy?();
@@ -2296,54 +2871,83 @@ declare namespace FW {
2296
2871
  getProtocolKey?(msg: any): string;
2297
2872
  send(msg: any);
2298
2873
  }
2299
-
2874
+ /**
2875
+ * socket处理者
2876
+ */
2300
2877
  export abstract class Handle extends FrameworkBase {
2301
2878
  initialize?();
2302
2879
  onDestroy?();
2303
2880
  onWeakNetWork?(): void;
2304
- abstract onMessage(msg: any): void;
2305
2881
  onHeart?(msg: any): Promise<boolean>;
2306
2882
  onClose?(): void;
2307
2883
  onOpen?(): void;
2308
2884
  onError?(msg: any): void;
2309
2885
  onTimeout?(): void;
2886
+ abstract onMessage(msg: any): void;
2310
2887
  abstract getProtocolKey?(msg: any): string;
2311
2888
  abstract onBeforeReceivingMessage?(msg: any): Promise<FW.SocketMessage>;
2312
2889
  }
2313
2890
  }
2314
2891
 
2315
2892
  declare namespace FW {
2893
+ /**
2894
+ * 服务
2895
+ */
2316
2896
  export abstract class Service extends FrameworkBase {
2317
2897
  public abstract initialize(): void;
2318
2898
  public abstract onDestroy(): void;
2319
2899
  }
2320
- export class Http extends FWService {
2900
+ /**
2901
+ * http服务
2902
+ */
2903
+ export class Http extends Service {
2321
2904
  public initialize() {}
2322
2905
  public onDestroy(): void {}
2323
-
2906
+ /**
2907
+ * get请求
2908
+ * @param url
2909
+ * @param params
2910
+ * @param cb
2911
+ * @param tag
2912
+ */
2324
2913
  async getMessage(
2325
2914
  url: string,
2326
2915
  params?: string,
2327
2916
  cb?: (response: string) => void,
2328
2917
  tag?: string,
2329
2918
  ): Promise<string>;
2330
-
2919
+ /**
2920
+ * post请求
2921
+ * @param url
2922
+ * @param params
2923
+ * @param cb
2924
+ * @param tag
2925
+ */
2331
2926
  async postMessage(
2332
2927
  url: string,
2333
2928
  params?: string,
2334
2929
  cb?: (response: string) => void,
2335
2930
  tag?: string,
2336
2931
  ): Promise<string>;
2337
-
2932
+ /**
2933
+ * 请求错误
2934
+ * @param err
2935
+ */
2338
2936
  onError?(err: any);
2937
+ /**
2938
+ * 请求超时
2939
+ */
2339
2940
  onTimeout?();
2340
2941
  }
2341
2942
  }
2342
2943
 
2343
2944
  declare namespace FW {
2945
+ /**
2946
+ * 模拟socket
2947
+ */
2344
2948
  export class SocketMock {
2345
- static createMockData<T>(msgId: string, data: T);
2346
- public static start(mockResponses: {}): void;
2949
+ public static start(): void;
2347
2950
  public static stop(): void;
2951
+ public static updateMockResponses(mockResponses: {});
2348
2952
  }
2349
2953
  }