@ives_xxz/framework 2.1.33 → 2.1.35

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.
@@ -44,10 +44,10 @@ export class FWLayerType {
44
44
  }
45
45
 
46
46
  export class FWTaskStatus {
47
- IDLE = "IDLE";
48
- RUNNING = "RUNNING";
49
- PAUSED = "PAUSED";
50
- COMPLETED = "COMPLETED";
47
+ IDLE = 'IDLE';
48
+ RUNNING = 'RUNNING';
49
+ PAUSED = 'PAUSED';
50
+ COMPLETED = 'COMPLETED';
51
51
  }
52
52
 
53
53
  export class FWPriorityOrder {
@@ -91,17 +91,17 @@ export class FWLogType {
91
91
  * HTTP请求类型
92
92
  */
93
93
  export class FWHttpRequestType {
94
- GET = "GET";
95
- POST = "POST";
94
+ GET = 'GET';
95
+ POST = 'POST';
96
96
  }
97
97
 
98
98
  /**
99
99
  * 动画机类型
100
100
  */
101
101
  export class FWAnimationMachineType {
102
- TWEEN = "TWEEN";
103
- SKELETON = "SKELETON";
104
- ANIMATION = "ANIMATION";
102
+ TWEEN = 'TWEEN';
103
+ SKELETON = 'SKELETON';
104
+ ANIMATION = 'ANIMATION';
105
105
  }
106
106
 
107
107
  export class FWVirtualScrollViewDirection {
@@ -127,23 +127,25 @@ export class FWScrollViewSelectedType {
127
127
  }
128
128
 
129
129
  export class FWLanguageAssetType {
130
- LABEL = "label";
131
- SPRITE = "sprite";
132
- SKELETON = "skeleton";
130
+ LABEL = 'label';
131
+ SPRITE = 'sprite';
132
+ SKELETON = 'skeleton';
133
133
  }
134
134
 
135
135
  export class FWPromiseStatus {
136
- PENDING = "pending";
137
- FULFILLED = "fulfilled";
138
- REJECTED = "rejected";
139
- CANCELLED = "cancelled";
136
+ PENDING = 'pending';
137
+ FULFILLED = 'fulfilled';
138
+ REJECTED = 'rejected';
139
+ CANCELLED = 'cancelled';
140
140
  }
141
141
 
142
142
  export class FWLayerState {
143
- CLOSED = "closed";
144
- OPENING = "opening";
145
- OPENED = "opened";
146
- CLOSING = "closing";
143
+ LOADING = 'loading';
144
+ LOADED = 'loaded';
145
+ OPENING = 'opening';
146
+ OPENED = 'opened';
147
+ CLOSED = 'closed';
148
+ CLOSING = 'closing';
147
149
  }
148
150
 
149
151
  export class FWAudioType {
@@ -13,24 +13,33 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
13
13
  private stateManager: FWLayerStateManager;
14
14
  private queueManager: FWLayerQueueManager;
15
15
  private openManager: FWLayerOpenManager;
16
+ private debug: boolean;
16
17
 
17
18
  public initialize(): void {
19
+ this.debug = false;
18
20
  this.resourceManager = new FWLayerResourceManager();
19
21
  this.dataManager = new FWLayerDataManager();
20
22
  this.createManager = new FWLayerCreateManager();
21
23
  this.stackManager = new FWLayerStackManager();
22
- this.stateManager = new FWLayerStateManager();
23
24
  this.queueManager = new FWLayerQueueManager();
24
-
25
+ this.stateManager = new FWLayerStateManager();
25
26
  this.openManager = new FWLayerOpenManager(
26
27
  this.dataManager,
27
28
  this.resourceManager,
28
29
  this.createManager,
29
30
  this.stackManager,
30
31
  this.queueManager,
32
+ this.stateManager,
31
33
  );
32
34
  }
33
35
 
36
+ openDebug() {
37
+ this.debug = true;
38
+ }
39
+
40
+ isDebug() {
41
+ return this.debug;
42
+ }
34
43
  /**
35
44
  * 异步打开Layer
36
45
  */
@@ -38,6 +47,9 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
38
47
  async openAsync<Ctr extends FW.LayerController = FW.LayerController>(
39
48
  data: FW.LayerOpenArgs,
40
49
  ): Promise<Ctr> {
50
+ if (this.debug) {
51
+ FW.Log.error(`异步打开Layer ->`, cc.js.getClassName(data.type));
52
+ }
41
53
  return this.openManager.openLayerAsync(data) as Promise<Ctr>;
42
54
  }
43
55
 
@@ -47,6 +59,9 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
47
59
  openSync<Ctr extends FW.LayerController = FW.LayerController>(
48
60
  data: FW.LayerOpenArgs,
49
61
  ): Ctr {
62
+ if (this.debug) {
63
+ FW.Log.error(`同步打开Layer ->`, cc.js.getClassName(data.type));
64
+ }
50
65
  return this.openManager.openLayerSync(data) as Ctr;
51
66
  }
52
67
 
@@ -172,14 +187,26 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
172
187
  let layerData = ctr.layerData;
173
188
 
174
189
  if (cc.isValid(ctr.layer?.node)) {
190
+ this.stateManager.setState(
191
+ ctr.layerData.controllerConstructor,
192
+ FW.SystemDefine.FWLayerState.CLOSING,
193
+ );
194
+
175
195
  await ctr.onClose?.();
196
+
197
+ this.stateManager.setState(
198
+ ctr.layerData.controllerConstructor,
199
+ FW.SystemDefine.FWLayerState.CLOSED,
200
+ );
201
+
176
202
  ctr.destroy?.();
203
+
177
204
  if (ctr.autoRelease) {
178
205
  FW.Entry.resMgr.releaseAsset(ctr.layerData.layerAssetProperty);
179
206
  }
180
207
  this.dataManager.notifyExternalRefUpdates(ctr.layerData);
181
208
  }
182
-
209
+ this.stateManager.removeState(layerData?.controllerConstructor);
183
210
  this.dataManager.removeFromMap(layerData?.controllerConstructor);
184
211
  this.dataManager.removeFromRegistry(ctr.layerData?.controllerConstructor);
185
212
 
@@ -464,6 +491,7 @@ class FWLayerOpenManager {
464
491
  private createManager: FWLayerCreateManager,
465
492
  private stackManager: FWLayerStackManager,
466
493
  private queueManager: FWLayerQueueManager,
494
+ private stateManager: FWLayerStateManager,
467
495
  ) {}
468
496
 
469
497
  /**
@@ -561,12 +589,29 @@ class FWLayerOpenManager {
561
589
  Ctr extends FW.LayerController = FW.LayerController,
562
590
  >(layerData: FWLayerData, data: FW.LayerOpenArgs): Promise<Ctr> {
563
591
  try {
592
+ this.stateManager.setState(
593
+ layerData.controllerConstructor,
594
+ FW.SystemDefine.FWLayerState.LOADING,
595
+ );
564
596
  const res = await this.resourceManager.loadLayerAsync(layerData);
597
+
598
+ this.stateManager.setState(
599
+ layerData.controllerConstructor,
600
+ FW.SystemDefine.FWLayerState.OPENING,
601
+ );
565
602
  const ctr = this.createLayer(layerData, res, data) as Ctr;
603
+
566
604
  this.dataManager.removeFromRegistry(layerData.controllerConstructor);
605
+
606
+ this.stateManager.setState(
607
+ layerData.controllerConstructor,
608
+ FW.SystemDefine.FWLayerState.OPENED,
609
+ );
610
+
567
611
  return ctr;
568
612
  } catch (e) {
569
613
  FW.Log.error(`asyncGenerationLayer failed:`, e);
614
+ this.stateManager.removeState(layerData.controllerConstructor);
570
615
  this.dataManager.clearFailedLayer(layerData);
571
616
  throw e;
572
617
  }
@@ -579,12 +624,22 @@ class FWLayerOpenManager {
579
624
  Ctr extends FW.LayerController = FW.LayerController,
580
625
  >(layerData: FWLayerData, data: FW.LayerOpenArgs): Ctr {
581
626
  try {
627
+ this.stateManager.setState(
628
+ layerData.controllerConstructor,
629
+ FW.SystemDefine.FWLayerState.OPENING,
630
+ );
582
631
  const res = this.resourceManager.loadLayerSync(layerData);
583
632
  const ctr = this.createLayer(layerData, res, data) as Ctr;
584
- this.dataManager.removeFromRegistry(layerData.controllerConstructor);
633
+
634
+ this.stateManager.setState(
635
+ layerData.controllerConstructor,
636
+ FW.SystemDefine.FWLayerState.OPENED,
637
+ );
638
+
585
639
  return ctr;
586
640
  } catch (e) {
587
641
  FW.Log.error(`syncGenerationLayer failed:`, e);
642
+ this.dataManager.removeFromRegistry(layerData.controllerConstructor);
588
643
  this.dataManager.clearFailedLayer(layerData);
589
644
  return undefined;
590
645
  }
@@ -698,11 +753,14 @@ class FWLayerStateManager {
698
753
  new () => FW.LayerController,
699
754
  FW.SystemDefine.FWLayerState
700
755
  >();
701
-
756
+ constructor() {}
702
757
  setState(
703
758
  ctrType: new () => FW.LayerController,
704
759
  state: FW.SystemDefine.FWLayerState,
705
760
  ): void {
761
+ if (FW.Entry.layerMgr.isDebug()) {
762
+ FW.Log.debug(`${cc.js.getClassName(ctrType)}->更新状态${state}`);
763
+ }
706
764
  this.layerStates.set(ctrType, state);
707
765
  }
708
766
 
@@ -725,6 +783,9 @@ class FWLayerStateManager {
725
783
  }
726
784
 
727
785
  removeState(ctrType: new () => FW.LayerController): void {
786
+ if (FW.Entry.layerMgr.isDebug()) {
787
+ FW.Log.debug(`${cc.js.getClassName(ctrType)}->移除状态`);
788
+ }
728
789
  this.layerStates.delete(ctrType);
729
790
  }
730
791
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "2.1.33",
3
+ "version": "2.1.35",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -1,4 +1,4 @@
1
- import { FWSystemConfig } from "../../config/FWSystemConfig";
1
+ import { FWSystemConfig } from '../../config/FWSystemConfig';
2
2
 
3
3
  /**
4
4
  * TODO 犹豫socket没有改版暂时已老的cmd字符串映射方式做,后期优化
@@ -106,14 +106,10 @@ export default class FWSocket extends FW.Service implements FW.Socket {
106
106
  this.heartInternal = config?.heartInternal || defaultConfig.heartInternal;
107
107
  this.heartTimeout = config?.heartTimeout || defaultConfig.heartTimeout;
108
108
  this.heartWeakTime = config?.heartWeakTime || defaultConfig.heartWeakTime;
109
- this.maxReconnectTimes =
110
- config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
111
- this.reconnectInternal =
112
- config?.reconnectInternal || defaultConfig.reconnectInternal;
113
- this.protocolSymbol =
114
- config?.protocolSymbol || defaultConfig.protocolSymbol;
115
- this.protocolPollingTime =
116
- config?.protocolPollingTime || defaultConfig.protocolPollingTime;
109
+ this.maxReconnectTimes = config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
110
+ this.reconnectInternal = config?.reconnectInternal || defaultConfig.reconnectInternal;
111
+ this.protocolSymbol = config?.protocolSymbol || defaultConfig.protocolSymbol;
112
+ this.protocolPollingTime = config?.protocolPollingTime || defaultConfig.protocolPollingTime;
117
113
 
118
114
  this.promiseProxy = {
119
115
  promise: undefined,
@@ -127,7 +123,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
127
123
 
128
124
  return this.promiseProxy;
129
125
  } catch (e) {
130
- FW.Log.error("创建socket失败:", e);
126
+ FW.Log.error('创建socket失败:', e);
131
127
  }
132
128
  }
133
129
  /**
@@ -205,22 +201,16 @@ export default class FWSocket extends FW.Service implements FW.Socket {
205
201
  this.socket?.close();
206
202
  this.socket = null;
207
203
 
208
- this.createSocket(
209
- this.address,
210
- this.tag,
211
- this.socketSender,
212
- this.socketHandle,
213
- {
214
- heartInternal: this.heartInternal,
215
- heartTimeout: this.heartTimeout,
216
- heartWeakTime: this.heartWeakTime,
217
- maxReconnectTimes: this.maxReconnectTimes,
218
- reconnectInternal: this.reconnectInternal,
219
- protocolSymbol: this.protocolSymbol,
220
- protocolPollingTime: this.protocolPollingTime,
221
- certificate: this.certificate,
222
- },
223
- );
204
+ this.createSocket(this.address, this.tag, this.socketSender, this.socketHandle, {
205
+ heartInternal: this.heartInternal,
206
+ heartTimeout: this.heartTimeout,
207
+ heartWeakTime: this.heartWeakTime,
208
+ maxReconnectTimes: this.maxReconnectTimes,
209
+ reconnectInternal: this.reconnectInternal,
210
+ protocolSymbol: this.protocolSymbol,
211
+ protocolPollingTime: this.protocolPollingTime,
212
+ certificate: this.certificate,
213
+ });
224
214
  }
225
215
 
226
216
  async send(msg: string) {
@@ -230,8 +220,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
230
220
  const protocolKey = this.socketSender.getProtocolKey?.(msg);
231
221
  if (protocolKey) {
232
222
  const symbol = Symbol(protocolKey);
233
- const registry =
234
- this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
223
+ const registry = this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
235
224
  const protocolPolling: FW.ProtocolPolling = {
236
225
  msg: msg,
237
226
  schedule: FW.Entry.timeMgr.schedule(
@@ -252,7 +241,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
252
241
 
253
242
  /** 连接打开 */
254
243
  private onSocketOpen() {
255
- FW.Log.debug("on open!");
244
+ FW.Log.debug('on open!');
256
245
  FW.Entry.timeMgr.unSchedule(this);
257
246
  this.reconnectTimes = 0;
258
247
  this.sendHeartTimestamp = 0;
@@ -296,15 +285,12 @@ export default class FWSocket extends FW.Service implements FW.Socket {
296
285
 
297
286
  /** socket关闭 */
298
287
  private onSocketClose() {
299
- FW.Log.debug("on close!");
288
+ FW.Log.debug('on close!');
300
289
  this.socketHandle?.onClose?.();
301
290
  FW.Entry.timeMgr.scheduleOnce(
302
291
  () => {
303
- if (
304
- this.getReadyState() == WebSocket.CLOSING ||
305
- this.getReadyState() == WebSocket.CLOSED
306
- ) {
307
- FW.Log.debug("on close!");
292
+ if (this.getReadyState() == WebSocket.CLOSING || this.getReadyState() == WebSocket.CLOSED) {
293
+ FW.Log.debug('on close!');
308
294
  this.reconnect();
309
295
  }
310
296
  },
package/types/FW.d.ts CHANGED
@@ -899,6 +899,10 @@ declare namespace FW {
899
899
 
900
900
  /** 清理方法 */
901
901
  clear(): void;
902
+ /** 开启调试 */
903
+ openDebug():void;
904
+ /** 是否开启调试 */
905
+ isDebug():boolean;
902
906
 
903
907
  /**
904
908
  * 异步打开layer
@@ -2644,6 +2648,8 @@ declare namespace FW {
2644
2648
  * 层状态
2645
2649
  */
2646
2650
  export class FWLayerState {
2651
+ static LOADING = 'loading';
2652
+ static LOADED = 'loaded';
2647
2653
  static CLOSED = 'closed';
2648
2654
  static OPENING = 'opening';
2649
2655
  static OPENED = 'opened';