@ives_xxz/framework 1.0.7 → 1.0.9

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/FW.d.ts CHANGED
@@ -748,12 +748,17 @@ declare namespace FW {
748
748
  * @param assetProperty
749
749
  */
750
750
  hasAsset(assetProperty: AssetProperty): boolean;
751
+ /**
752
+ * 初始化远程包配置
753
+ * @param config
754
+ */
755
+ initializeRemoteBundleConfig(config: RemoteBundleConfig): void;
751
756
  };
752
757
 
753
758
  type RemoteBundleConfig = {
754
759
  bundleName: string;
755
760
  url: string;
756
- hash: string;
761
+ version: string;
757
762
  };
758
763
 
759
764
  type BundleManager = {
@@ -38,10 +38,9 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
38
38
  const remote = this.remoteBundleConfigMap.get(bundleName);
39
39
  const url = remote ? remote.url : '';
40
40
  const path = `${url}${bundleName}`;
41
-
42
41
  cc.assetManager.loadBundle(
43
42
  path,
44
- { version: this.remoteBundleConfigMap.get(bundleName) || '' },
43
+ { version: this.remoteBundleConfigMap.get(bundleName)?.version || '' },
45
44
  (err: Error, bundle: cc.AssetManager.Bundle) => {
46
45
  if (err || !bundle) {
47
46
  FWLog.error(`"加载bundle失败:"${bundleName}!`);
@@ -1,6 +1,8 @@
1
1
  import FWLog from '../log/FWLog';
2
2
  import { FWManager } from './FWManager';
3
3
 
4
+ const TEMOTE_ASSET = 'remote-asset';
5
+
4
6
  export default class FWHotUpdateManager extends FWManager implements FW.HotUpdateManager {
5
7
  private listener: FW.HotUpdateListener;
6
8
  private assetMgr: any;
@@ -11,6 +13,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
11
13
 
12
14
  setListener(listener: FW.HotUpdateListener): void {
13
15
  this.listener = listener;
16
+ FWLog.debug('热更新监听设置');
14
17
  }
15
18
 
16
19
  public update(localManifest: cc.Asset) {
@@ -18,7 +21,9 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
18
21
  FWLog.error('没有找到本地Manifest文件!');
19
22
  return;
20
23
  }
24
+ FWLog.debug('开始热更新流程');
21
25
  this.localManifest = localManifest;
26
+ this.storePath = `${jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/'}${TEMOTE_ASSET}`;
22
27
  this.assetMgr = new jsb.AssetsManager('', this.storePath, this.versionCompareHandle);
23
28
  this.assetMgr.setVerifyCallback(function (path: string, asset: any) {
24
29
  const compressed = asset.compressed;
@@ -35,6 +40,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
35
40
  }
36
41
 
37
42
  private versionCompareHandle(currentVersion: string, newVersion: string): number {
43
+ FWLog.debug('版本比较', currentVersion, newVersion);
38
44
  this.listener.versionCompareHandle(currentVersion, newVersion);
39
45
  var vA = currentVersion.split('.');
40
46
  var vB = newVersion.split('.');
@@ -63,12 +69,16 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
63
69
  }
64
70
 
65
71
  private checkHotUpdate() {
72
+ FWLog.debug('checkHotUpdate1', this.isUpdate);
66
73
  if (this.isUpdate) {
67
74
  return;
68
75
  }
76
+ FWLog.debug('checkHotUpdate2', this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED);
69
77
  if (this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED) {
70
78
  this.assetMgr.loadLocalManifest(this.localManifest.nativeUrl);
71
79
  }
80
+ FWLog.debug('checkHotUpdate3', this.assetMgr.getLocalManifest());
81
+ FWLog.debug('checkHotUpdate4', this.assetMgr.getLocalManifest().isLoaded());
72
82
  if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
73
83
  return;
74
84
  }
@@ -208,6 +218,6 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
208
218
  return `${size.toFixed(size < 10 ? 2 : 1)} ${units[unitIndex]}`;
209
219
  }
210
220
 
211
- public initialize(): void {}
212
- public onDestroy(): void {}
221
+ public initialize(): void { }
222
+ public onDestroy(): void { }
213
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -8,4 +8,4 @@
8
8
  ],
9
9
  "author": "ives",
10
10
  "license": "ISC"
11
- }
11
+ }
@@ -60,6 +60,7 @@ export default class FWSocket implements FW.Socket {
60
60
  this.messageEvents = cc.js.createMap();
61
61
  this.protocolContainer = new Map<Symbol, string>();
62
62
  this.protocolRegistry = new Map<string, Set<Symbol>>();
63
+ this.reconnectTimes = 0;
63
64
  }
64
65
 
65
66
  createSocket(
@@ -80,7 +81,7 @@ export default class FWSocket implements FW.Socket {
80
81
  this.isReconnect = true;
81
82
  this.sendHeartTimestamp = 0;
82
83
  this.receiveTimeStamp = new Date().getTime();
83
-
84
+ FWLog.debug('创建socket -> ', address);
84
85
  this.socket = new WebSocket(address);
85
86
  this.socket.onopen = this.onSocketOpen.bind(this);
86
87
  this.socket.onclose = this.onSocketClose.bind(this);
@@ -248,6 +249,7 @@ export default class FWSocket implements FW.Socket {
248
249
 
249
250
  /** socket关闭 */
250
251
  private onSocketClose() {
252
+ FWLog.debug('on close!');
251
253
  this.handle?.onClose?.();
252
254
  FW.Entry.timeMgr.scheduleOnce(
253
255
  () => {