@ives_xxz/framework 1.1.8 → 1.1.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 +2 -2
- package/manager/FWHotUpdateManager.ts +35 -11
- package/package.json +1 -1
package/FW.d.ts
CHANGED
|
@@ -843,7 +843,7 @@ declare namespace FW {
|
|
|
843
843
|
};
|
|
844
844
|
|
|
845
845
|
type HotUpdateManager = {
|
|
846
|
-
setListener(listener: HotUpdateListener):
|
|
846
|
+
setListener(listener: HotUpdateListener): HotUpdateManager;
|
|
847
847
|
update(localManifest: cc.Asset): void;
|
|
848
848
|
};
|
|
849
849
|
|
|
@@ -1470,7 +1470,7 @@ declare namespace FW {
|
|
|
1470
1470
|
/**
|
|
1471
1471
|
* 状态构造类
|
|
1472
1472
|
*/
|
|
1473
|
-
stateConstructor: { new(): T };
|
|
1473
|
+
stateConstructor: { new (): T };
|
|
1474
1474
|
};
|
|
1475
1475
|
|
|
1476
1476
|
type AudioManager = {
|
|
@@ -11,11 +11,12 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
11
11
|
private localManifest: cc.Asset;
|
|
12
12
|
private isRetry: boolean;
|
|
13
13
|
private currentVersion: string;
|
|
14
|
-
private newVersion: string
|
|
14
|
+
private newVersion: string;
|
|
15
15
|
|
|
16
|
-
setListener(listener: FW.HotUpdateListener):
|
|
16
|
+
setListener(listener: FW.HotUpdateListener): FW.HotUpdateManager {
|
|
17
17
|
this.listener = listener;
|
|
18
18
|
FWLog.debug('热更新监听设置');
|
|
19
|
+
return this;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
public update(localManifest: cc.Asset) {
|
|
@@ -96,7 +97,6 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
|
|
100
100
|
this.assetMgr.setEventCallback(this.checkEventHandle.bind(this));
|
|
101
101
|
this.assetMgr.checkUpdate();
|
|
102
102
|
this.isUpdate = true;
|
|
@@ -148,7 +148,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
148
148
|
this.listener.checkHotUpdateHandle?.(code);
|
|
149
149
|
this.assetMgr.setEventCallback(null!);
|
|
150
150
|
this.isUpdate = false;
|
|
151
|
-
FWLog.debug(
|
|
151
|
+
FWLog.debug(
|
|
152
|
+
'isFind New Version -> ',
|
|
153
|
+
event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND,
|
|
154
|
+
);
|
|
152
155
|
if (event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND) {
|
|
153
156
|
this.hotUpdate();
|
|
154
157
|
}
|
|
@@ -158,7 +161,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
158
161
|
FWLog.debug('start hotUpdate ->', this.assetMgr, this.isUpdate);
|
|
159
162
|
if (this.assetMgr && !this.isUpdate) {
|
|
160
163
|
this.assetMgr.setEventCallback(this.updateEventHandle.bind(this));
|
|
161
|
-
FWLog.debug(
|
|
164
|
+
FWLog.debug(
|
|
165
|
+
'assetMgr state ->',
|
|
166
|
+
this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED,
|
|
167
|
+
);
|
|
162
168
|
if (this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED) {
|
|
163
169
|
this.assetMgr.loadLocalManifest(this.localManifest.nativeUrl);
|
|
164
170
|
}
|
|
@@ -197,7 +203,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
197
203
|
convertDownloadedBytes = this.convertBytes(downloadedBytes);
|
|
198
204
|
convertTotalBytes = this.convertBytes(totalBytes);
|
|
199
205
|
percent = event.getPercent();
|
|
200
|
-
FWLog.debug(
|
|
206
|
+
FWLog.debug(
|
|
207
|
+
'正在更新中 -> ',
|
|
208
|
+
'下载文件数量:',
|
|
209
|
+
downloadedFiles,
|
|
210
|
+
',下载文件总数量:',
|
|
211
|
+
totalFiles,
|
|
212
|
+
',已下载大小:',
|
|
213
|
+
convertDownloadedBytes,
|
|
214
|
+
',下载总大小:',
|
|
215
|
+
convertTotalBytes,
|
|
216
|
+
);
|
|
201
217
|
}
|
|
202
218
|
break;
|
|
203
219
|
case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
|
|
@@ -220,7 +236,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
220
236
|
convertDownloadedBytes = this.convertBytes(downloadedBytes);
|
|
221
237
|
convertTotalBytes = this.convertBytes(totalBytes);
|
|
222
238
|
percent = event.getPercent();
|
|
223
|
-
FWLog.debug(
|
|
239
|
+
FWLog.debug(
|
|
240
|
+
'正在更新完成 -> ',
|
|
241
|
+
'下载文件数量:',
|
|
242
|
+
downloadedFiles,
|
|
243
|
+
',下载文件总数量:',
|
|
244
|
+
totalFiles,
|
|
245
|
+
',已下载大小:',
|
|
246
|
+
convertDownloadedBytes,
|
|
247
|
+
',下载总大小:',
|
|
248
|
+
convertTotalBytes,
|
|
249
|
+
);
|
|
224
250
|
}
|
|
225
251
|
str = 'UPDATE_FINISHED';
|
|
226
252
|
needRestart = true;
|
|
@@ -268,12 +294,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
268
294
|
this.isRetry = false;
|
|
269
295
|
this.isUpdate = false;
|
|
270
296
|
|
|
271
|
-
|
|
272
297
|
this.reloadLocalManifest();
|
|
273
298
|
|
|
274
299
|
this.assetMgr.setEventCallback(null!);
|
|
275
300
|
this.listener.completedHandle?.(this.newVersion);
|
|
276
|
-
|
|
277
301
|
}
|
|
278
302
|
}
|
|
279
303
|
|
|
@@ -288,6 +312,6 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
288
312
|
return `${size.toFixed(size < 10 ? 2 : 1)} ${units[unitIndex]}`;
|
|
289
313
|
}
|
|
290
314
|
|
|
291
|
-
public initialize(): void {
|
|
292
|
-
public onDestroy(): void {
|
|
315
|
+
public initialize(): void {}
|
|
316
|
+
public onDestroy(): void {}
|
|
293
317
|
}
|