@ives_xxz/framework 1.6.5 → 2.0.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/Framework.ts +9 -13
- package/FrameworkAutoInitialize.ts +58 -0
- package/{CC.d.ts.meta → FrameworkAutoInitialize.ts.meta} +1 -1
- package/FrameworkBase.ts +24 -23
- package/animation/FWSkeleton.ts +5 -6
- package/component/FWVirtualViewComponent.ts +42 -45
- package/config/FWAssetConfig.ts +2 -2
- package/controller/FWLayerController.ts +3 -7
- package/data/FWData.ts +2 -3
- package/define/FWEventDefine.ts +24 -21
- package/define/FWSystemDefine.ts +127 -132
- package/define/FWSystemDefine.ts.meta +1 -1
- package/entry/FWEntry.ts +2 -3
- package/expand/FWDecorator.ts +56 -114
- package/expand/FWRollingViewNesting.ts +3 -5
- package/item/FWVirtualListItem.ts +1 -1
- package/language/FWLanguage.ts +15 -19
- package/layer/FWLayer.ts +1 -1
- package/log/FWLog.ts +30 -35
- package/logic/FWLogic.ts +2 -4
- package/machine/FWStateMachine.ts +1 -2
- package/manager/FWAnimationManager.ts +6 -8
- package/manager/FWAssetManager.ts +22 -23
- package/manager/FWAudioManager.ts +30 -52
- package/manager/FWBundleManager.ts +2 -4
- package/manager/FWComponentManager.ts +0 -1
- package/manager/FWEngineManager.ts +10 -14
- package/manager/FWEventManager.ts +4 -7
- package/manager/FWHotUpdateManager.ts +32 -33
- package/manager/FWLanguageManager.ts +1 -2
- package/manager/FWLayerManager.ts +88 -138
- package/manager/FWManager.ts +1 -3
- package/manager/FWObjectManager.ts +7 -9
- package/manager/FWPerformanceManager.ts +2 -3
- package/manager/FWPromiseManager.ts +29 -28
- package/manager/FWResManager.ts +1 -3
- package/manager/FWSocketManager.ts +2 -5
- package/manager/FWStateManager.ts +2 -4
- package/manager/FWTimeManager.ts +14 -15
- package/manager/FWUiManager.ts +3 -4
- package/package.json +1 -1
- package/{register → registry}/FWRegistry.ts +8 -8
- package/service/http/FWHttp.ts +5 -7
- package/service/socket/FWSocket.ts +28 -43
- package/service/socket/FWSocketHandle.ts +3 -6
- package/service/socket/FWSocketSender.ts +5 -9
- package/types/Creator.d.ts.meta +6 -0
- package/{FW.d.ts → types/FW.d.ts} +407 -153
- package/types/Global.d.ts +21 -0
- package/{render/FWAssembler.ts.meta → types/Global.d.ts.meta} +1 -1
- package/types.meta +13 -0
- package/utils/FWObjectPool.ts +5 -7
- package/utils/FWTask.ts +18 -22
- package/render/FWAssembler.ts +0 -11
- /package/{register → registry}/FWRegistry.ts.meta +0 -0
- /package/{register.meta → registry.meta} +0 -0
- /package/{CC.d.ts → types/Creator.d.ts} +0 -0
- /package/{FW.d.ts.meta → types/FW.d.ts.meta} +0 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { FWManager } from
|
|
2
|
-
import FWLog from "../log/FWLog";
|
|
3
|
-
import { FWSystemDefine } from "../define/FWSystemDefine";
|
|
1
|
+
import { FWManager } from './FWManager';
|
|
4
2
|
|
|
5
3
|
class FWAudioData {
|
|
6
4
|
clip: cc.AudioClip;
|
|
@@ -11,17 +9,10 @@ class FWAudioData {
|
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
class FWAudioPoolItem {
|
|
14
|
-
constructor(
|
|
15
|
-
public audioId: number,
|
|
16
|
-
public startTime: number,
|
|
17
|
-
public tag?: string
|
|
18
|
-
) {}
|
|
12
|
+
constructor(public audioId: number, public startTime: number, public tag?: string) {}
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
export default class FWAudioManager
|
|
22
|
-
extends FWManager
|
|
23
|
-
implements FW.AudioManager
|
|
24
|
-
{
|
|
15
|
+
export default class FWAudioManager extends FWManager implements FW.AudioManager {
|
|
25
16
|
musicVolume: number = 1;
|
|
26
17
|
effectsVolume: number = 1;
|
|
27
18
|
soundVolume: number = 1;
|
|
@@ -38,21 +29,13 @@ export default class FWAudioManager
|
|
|
38
29
|
* 播放背景音乐
|
|
39
30
|
*/
|
|
40
31
|
async playMusic(path: string, volume?: number, loop?: boolean): Promise<void>;
|
|
41
|
-
async playMusic(
|
|
42
|
-
|
|
43
|
-
volume?: number,
|
|
44
|
-
loop?: boolean
|
|
45
|
-
): Promise<void>;
|
|
46
|
-
async playMusic(
|
|
47
|
-
assetProperty: FW.AssetProperty,
|
|
48
|
-
volume?: number,
|
|
49
|
-
loop?: boolean
|
|
50
|
-
): Promise<void>;
|
|
32
|
+
async playMusic(music: cc.AudioClip, volume?: number, loop?: boolean): Promise<void>;
|
|
33
|
+
async playMusic(assetProperty: FW.AssetProperty, volume?: number, loop?: boolean): Promise<void>;
|
|
51
34
|
async playMusic(): Promise<void> {
|
|
52
35
|
try {
|
|
53
36
|
const audioData = await this.processAudioArguments(
|
|
54
37
|
arguments,
|
|
55
|
-
|
|
38
|
+
FW.SystemDefine.FWAudioType.MUSIC,
|
|
56
39
|
);
|
|
57
40
|
if (!audioData.clip) return;
|
|
58
41
|
|
|
@@ -63,9 +46,9 @@ export default class FWAudioManager
|
|
|
63
46
|
const id = cc.audioEngine.playMusic(audioData.clip, loop);
|
|
64
47
|
cc.audioEngine.setVolume(id, volume);
|
|
65
48
|
|
|
66
|
-
|
|
49
|
+
FW.Log.debug(`播放背景音乐: ${this.getAudioName(audioData.clip)}`);
|
|
67
50
|
} catch (e) {
|
|
68
|
-
|
|
51
|
+
FW.Log.error('播放音乐失败:', e);
|
|
69
52
|
}
|
|
70
53
|
}
|
|
71
54
|
|
|
@@ -95,40 +78,39 @@ export default class FWAudioManager
|
|
|
95
78
|
cb?: (id: number) => void,
|
|
96
79
|
volume?: number,
|
|
97
80
|
loop?: boolean,
|
|
98
|
-
tag?: string
|
|
81
|
+
tag?: string,
|
|
99
82
|
): Promise<number>;
|
|
100
83
|
async play(
|
|
101
84
|
audio: cc.AudioClip,
|
|
102
85
|
cb?: (id: number) => void,
|
|
103
86
|
volume?: number,
|
|
104
87
|
loop?: boolean,
|
|
105
|
-
tag?: string
|
|
88
|
+
tag?: string,
|
|
106
89
|
): Promise<number>;
|
|
107
90
|
async play(
|
|
108
91
|
assetProperty: FW.AssetProperty,
|
|
109
92
|
cb?: (id: number) => void,
|
|
110
93
|
volume?: number,
|
|
111
94
|
loop?: boolean,
|
|
112
|
-
tag?: string
|
|
95
|
+
tag?: string,
|
|
113
96
|
): Promise<number>;
|
|
114
97
|
async play(): Promise<number> {
|
|
115
98
|
try {
|
|
116
99
|
if (this.audioPool.size >= this.maxConcurrentAudio) {
|
|
117
100
|
this.clearFinishedAudio();
|
|
118
101
|
if (this.audioPool.size >= this.maxConcurrentAudio) {
|
|
119
|
-
|
|
102
|
+
FW.Log.warn('音频池已满,无法播放新音频');
|
|
120
103
|
return -1;
|
|
121
104
|
}
|
|
122
105
|
}
|
|
123
106
|
|
|
124
107
|
const audioData = await this.processAudioArguments(
|
|
125
108
|
arguments,
|
|
126
|
-
|
|
109
|
+
FW.SystemDefine.FWAudioType.SOUND,
|
|
127
110
|
);
|
|
128
111
|
if (!audioData.clip) return -1;
|
|
129
112
|
|
|
130
|
-
const volume =
|
|
131
|
-
(audioData.volume ?? this.soundVolume) * this.effectsVolume;
|
|
113
|
+
const volume = (audioData.volume ?? this.soundVolume) * this.effectsVolume;
|
|
132
114
|
const loop = audioData.loop ?? false;
|
|
133
115
|
const tag = audioData.tag;
|
|
134
116
|
|
|
@@ -143,7 +125,7 @@ export default class FWAudioManager
|
|
|
143
125
|
|
|
144
126
|
return id;
|
|
145
127
|
} catch (e) {
|
|
146
|
-
|
|
128
|
+
FW.Log.error('播放音效失败:', e);
|
|
147
129
|
return -1;
|
|
148
130
|
}
|
|
149
131
|
}
|
|
@@ -155,30 +137,30 @@ export default class FWAudioManager
|
|
|
155
137
|
if (this.audioPool.has(id)) {
|
|
156
138
|
cc.audioEngine.stop(id);
|
|
157
139
|
this.audioPool.delete(id);
|
|
158
|
-
|
|
140
|
+
FW.Log.debug(`停止音效: ID ${id}`);
|
|
159
141
|
}
|
|
160
142
|
}
|
|
161
143
|
|
|
162
144
|
pauseAll(): void {
|
|
163
145
|
cc.audioEngine.pauseAll();
|
|
164
|
-
|
|
146
|
+
FW.Log.debug('暂停所有音效');
|
|
165
147
|
}
|
|
166
148
|
|
|
167
149
|
resumeAll(): void {
|
|
168
150
|
cc.audioEngine.resumeAll();
|
|
169
|
-
|
|
151
|
+
FW.Log.debug('恢复所有音效');
|
|
170
152
|
}
|
|
171
153
|
|
|
172
154
|
stopAll(): void {
|
|
173
155
|
cc.audioEngine.stopAll();
|
|
174
156
|
this.audioPool.clear();
|
|
175
|
-
|
|
157
|
+
FW.Log.debug('停止所有音效');
|
|
176
158
|
}
|
|
177
159
|
|
|
178
160
|
/** 设置播放音效是否静音 */
|
|
179
161
|
setSoundMute(mute: boolean): void {
|
|
180
162
|
this.soundVolume = mute ? 0 : 1;
|
|
181
|
-
|
|
163
|
+
FW.Log.debug(`音效${mute ? '静音' : '取消静音'}`);
|
|
182
164
|
}
|
|
183
165
|
|
|
184
166
|
/**
|
|
@@ -188,7 +170,7 @@ export default class FWAudioManager
|
|
|
188
170
|
try {
|
|
189
171
|
let clip: cc.AudioClip;
|
|
190
172
|
|
|
191
|
-
if (typeof assetProperty ===
|
|
173
|
+
if (typeof assetProperty === 'string') {
|
|
192
174
|
clip = await FW.Entry.resMgr.loadAsset<cc.AudioClip>({
|
|
193
175
|
path: assetProperty,
|
|
194
176
|
bundle: FW.Entry.bundleName,
|
|
@@ -249,7 +231,7 @@ export default class FWAudioManager
|
|
|
249
231
|
*/
|
|
250
232
|
private async processAudioArguments(
|
|
251
233
|
args: IArguments,
|
|
252
|
-
type:
|
|
234
|
+
type: FW.SystemDefine.FWAudioType,
|
|
253
235
|
): Promise<FWAudioData> {
|
|
254
236
|
const audioData = new FWAudioData();
|
|
255
237
|
const argsArray = Array.from(args);
|
|
@@ -261,7 +243,7 @@ export default class FWAudioManager
|
|
|
261
243
|
audioData.clip = await this.loadAudioClip(assetProperty);
|
|
262
244
|
}
|
|
263
245
|
|
|
264
|
-
if (type ===
|
|
246
|
+
if (type === FW.SystemDefine.FWAudioType.MUSIC) {
|
|
265
247
|
audioData.volume = argsArray[1];
|
|
266
248
|
audioData.loop = argsArray[2];
|
|
267
249
|
} else {
|
|
@@ -278,7 +260,7 @@ export default class FWAudioManager
|
|
|
278
260
|
* 标准化资源属性
|
|
279
261
|
*/
|
|
280
262
|
private normalizeAssetProperty(input: any): FW.AssetProperty {
|
|
281
|
-
if (typeof input ===
|
|
263
|
+
if (typeof input === 'string') {
|
|
282
264
|
return {
|
|
283
265
|
path: input,
|
|
284
266
|
bundle: FW.Entry.bundleName,
|
|
@@ -290,9 +272,7 @@ export default class FWAudioManager
|
|
|
290
272
|
/**
|
|
291
273
|
* 加载音频片段
|
|
292
274
|
*/
|
|
293
|
-
private async loadAudioClip(
|
|
294
|
-
assetProperty: FW.AssetProperty
|
|
295
|
-
): Promise<cc.AudioClip> {
|
|
275
|
+
private async loadAudioClip(assetProperty: FW.AssetProperty): Promise<cc.AudioClip> {
|
|
296
276
|
try {
|
|
297
277
|
return await FW.Entry.resMgr.loadAsset<cc.AudioClip>(assetProperty);
|
|
298
278
|
} catch (e) {
|
|
@@ -304,19 +284,17 @@ export default class FWAudioManager
|
|
|
304
284
|
* 生成缓存键
|
|
305
285
|
*/
|
|
306
286
|
private getCacheKey(assetProperty: FW.AssetProperty): string {
|
|
307
|
-
if (typeof assetProperty ===
|
|
287
|
+
if (typeof assetProperty === 'string') {
|
|
308
288
|
return `${FW.Entry.bundleName}_${assetProperty}`;
|
|
309
289
|
}
|
|
310
|
-
return `${assetProperty.bundle || FW.Entry.bundleName}_${
|
|
311
|
-
assetProperty.path
|
|
312
|
-
}`;
|
|
290
|
+
return `${assetProperty.bundle || FW.Entry.bundleName}_${assetProperty.path}`;
|
|
313
291
|
}
|
|
314
292
|
|
|
315
293
|
/**
|
|
316
294
|
* 获取音频名称
|
|
317
295
|
*/
|
|
318
296
|
private getAudioName(clip: cc.AudioClip): string {
|
|
319
|
-
return clip.name ||
|
|
297
|
+
return clip.name || '未知音频';
|
|
320
298
|
}
|
|
321
299
|
|
|
322
300
|
/**
|
|
@@ -330,7 +308,7 @@ export default class FWAudioManager
|
|
|
330
308
|
if (!cc.audioEngine.getState(id)) {
|
|
331
309
|
this.audioPool.delete(id);
|
|
332
310
|
} else if (currentTime - item.startTime > maxAge) {
|
|
333
|
-
|
|
311
|
+
FW.Log.warn(`强制停止超时音频: ID ${id}`);
|
|
334
312
|
this.stop(id);
|
|
335
313
|
}
|
|
336
314
|
});
|
|
@@ -344,7 +322,7 @@ export default class FWAudioManager
|
|
|
344
322
|
this.clearFinishedAudio,
|
|
345
323
|
this.cleanupInterval,
|
|
346
324
|
cc.macro.REPEAT_FOREVER,
|
|
347
|
-
this
|
|
325
|
+
this,
|
|
348
326
|
);
|
|
349
327
|
}
|
|
350
328
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { FWManager } from './FWManager';
|
|
2
|
-
import FWLog from '../log/FWLog';
|
|
3
2
|
import { FWSystemConfig } from '../config/FWSystemConfig';
|
|
4
|
-
import { FWLodash } from '../utils/FWLodash';
|
|
5
3
|
|
|
6
4
|
export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
7
5
|
bundleMap: Map<string, cc.AssetManager.Bundle>;
|
|
@@ -44,7 +42,7 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
44
42
|
},
|
|
45
43
|
async (err: Error, bundle: cc.AssetManager.Bundle) => {
|
|
46
44
|
if (err || !bundle) {
|
|
47
|
-
|
|
45
|
+
FW.Log.error(`"加载bundle失败:"${bundleName}!`);
|
|
48
46
|
reject(err);
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -67,7 +65,7 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
67
65
|
*/
|
|
68
66
|
get(bundleName: string): cc.AssetManager.Bundle {
|
|
69
67
|
if (!this.has(bundleName)) {
|
|
70
|
-
|
|
68
|
+
FW.Log.error('获取bundle失败,请先加载!');
|
|
71
69
|
return undefined;
|
|
72
70
|
}
|
|
73
71
|
return this.bundleMap.get(bundleName);
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { FWEventDefine } from '../define/FWEventDefine';
|
|
2
|
-
import { FWSystemDefine } from '../define/FWSystemDefine';
|
|
3
|
-
import Framework from '../Framework';
|
|
4
|
-
import FWLog from '../log/FWLog';
|
|
5
1
|
import { FWManager } from './FWManager';
|
|
6
2
|
|
|
7
3
|
export default class FWEngineManager extends FWManager implements FW.EngineManager {
|
|
@@ -17,29 +13,29 @@ export default class FWEngineManager extends FWManager implements FW.EngineManag
|
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
restart() {
|
|
20
|
-
FW.Entry.evtMgr.dispatch(
|
|
16
|
+
FW.Entry.evtMgr.dispatch(FW.EventDefine.SystemEvent.SYSTEM_RESTART);
|
|
21
17
|
FW.Entry.initialize();
|
|
22
|
-
Framework.restart();
|
|
18
|
+
FW.Framework.restart();
|
|
23
19
|
cc.game.restart();
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
getMemory() {
|
|
27
23
|
if (!this.debug) return;
|
|
28
24
|
if (window.performance && window.performance['memory']) {
|
|
29
|
-
|
|
25
|
+
FW.Log.debug(
|
|
30
26
|
'浏览器允许的最大内存:',
|
|
31
27
|
this.formatBytes(window.performance['memory'].jsHeapSizeLimit),
|
|
32
28
|
);
|
|
33
|
-
|
|
29
|
+
FW.Log.debug(
|
|
34
30
|
'浏览器已分配内存:',
|
|
35
31
|
this.formatBytes(window.performance['memory'].totalJSHeapSize),
|
|
36
32
|
);
|
|
37
|
-
|
|
33
|
+
FW.Log.debug(
|
|
38
34
|
'浏览器已使用内存:',
|
|
39
35
|
this.formatBytes(window.performance['memory'].usedJSHeapSize),
|
|
40
36
|
);
|
|
41
37
|
} else {
|
|
42
|
-
|
|
38
|
+
FW.Log.debug('当前浏览器不支持 performance.memory');
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
/**
|
|
@@ -51,14 +47,14 @@ export default class FWEngineManager extends FWManager implements FW.EngineManag
|
|
|
51
47
|
}
|
|
52
48
|
/** 应用切换到前台 */
|
|
53
49
|
private onAppShow() {
|
|
54
|
-
|
|
55
|
-
FW.Entry.evtMgr?.dispatch(
|
|
50
|
+
FW.Log.debug('game on show!');
|
|
51
|
+
FW.Entry.evtMgr?.dispatch(FW.EventDefine.CCEvent.ON_SHOW);
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
/** 应用切换到后台 */
|
|
59
55
|
private onAppHide() {
|
|
60
|
-
|
|
61
|
-
FW.Entry.evtMgr?.dispatch(
|
|
56
|
+
FW.Log.debug('game on hide!');
|
|
57
|
+
FW.Entry.evtMgr?.dispatch(FW.EventDefine.CCEvent.ON_HIDE);
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
private formatBytes(bytes: number) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { FWSystemDefine } from '../define/FWSystemDefine';
|
|
2
|
-
import FWLog from '../log/FWLog';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* 观察者
|
|
6
3
|
*/
|
|
@@ -166,13 +163,13 @@ export default class FWEventManager implements FW.EventManager {
|
|
|
166
163
|
) => void,
|
|
167
164
|
target: FW.TargetType,
|
|
168
165
|
options?: {
|
|
169
|
-
priority?:
|
|
166
|
+
priority?: number;
|
|
170
167
|
intercept?: boolean;
|
|
171
168
|
once?: boolean;
|
|
172
169
|
},
|
|
173
170
|
) {
|
|
174
171
|
const observers = this.listeners[eventName];
|
|
175
|
-
const define =
|
|
172
|
+
const define = FW.SystemDefine.FWPriorityOrder;
|
|
176
173
|
const priority = options?.priority === undefined ? define.NORMAL : options.priority;
|
|
177
174
|
const intercept = options?.intercept === undefined ? false : options.intercept;
|
|
178
175
|
const once = options?.once === undefined ? false : options.once;
|
|
@@ -218,13 +215,13 @@ export default class FWEventManager implements FW.EventManager {
|
|
|
218
215
|
) => void,
|
|
219
216
|
target: FW.TargetType,
|
|
220
217
|
options?: {
|
|
221
|
-
priority?:
|
|
218
|
+
priority?: number;
|
|
222
219
|
intercept?: boolean;
|
|
223
220
|
},
|
|
224
221
|
) {
|
|
225
222
|
this.register(eventName, cb, target, {
|
|
226
223
|
...options,
|
|
227
|
-
once: true,
|
|
224
|
+
once: true,
|
|
228
225
|
});
|
|
229
226
|
}
|
|
230
227
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import FWLog from '../log/FWLog';
|
|
2
1
|
import { FWManager } from './FWManager';
|
|
3
2
|
|
|
4
3
|
const TEMOTE_ASSET = 'remote-asset';
|
|
@@ -15,16 +14,16 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
15
14
|
|
|
16
15
|
setListener(listener: FW.HotUpdateListener): FW.HotUpdateManager {
|
|
17
16
|
this.listener = listener;
|
|
18
|
-
|
|
17
|
+
FW.Log.debug('热更新监听设置');
|
|
19
18
|
return this;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
public update(localManifest: cc.Asset) {
|
|
23
22
|
if (!localManifest) {
|
|
24
|
-
|
|
23
|
+
FW.Log.error('没有找到本地Manifest文件!');
|
|
25
24
|
return;
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
FW.Log.debug('开始热更新流程');
|
|
28
27
|
this.localManifest = localManifest;
|
|
29
28
|
this.storePath = `${jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/'}${TEMOTE_ASSET}`;
|
|
30
29
|
this.assetMgr = new jsb.AssetsManager('', this.storePath, this.versionCompareHandle.bind(this));
|
|
@@ -43,7 +42,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
private versionCompareHandle(currentVersion: string, newVersion: string): number {
|
|
46
|
-
|
|
45
|
+
FW.Log.debug('版本比较', currentVersion, newVersion);
|
|
47
46
|
this.currentVersion = currentVersion;
|
|
48
47
|
this.newVersion = newVersion;
|
|
49
48
|
this.listener.versionCompareHandle(this.currentVersion, this.newVersion);
|
|
@@ -74,7 +73,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
private checkHotUpdate() {
|
|
77
|
-
|
|
76
|
+
FW.Log.debug('checkHotUpdate1', this.isUpdate);
|
|
78
77
|
if (this.isUpdate) {
|
|
79
78
|
return;
|
|
80
79
|
}
|
|
@@ -82,17 +81,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
82
81
|
this.assetMgr.loadLocalManifest(this.localManifest.nativeUrl);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
FW.Log.debug('checkHotUpdate3', this.assetMgr.getLocalManifest());
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
FW.Log.debug('checkHotUpdate4', this.assetMgr.getLocalManifest().isLoaded());
|
|
88
87
|
|
|
89
88
|
if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
|
|
90
|
-
|
|
89
|
+
FW.Log.debug('本地manifest未加载,尝试重新加载');
|
|
91
90
|
this.reloadLocalManifest();
|
|
92
91
|
|
|
93
92
|
// 如果仍然无法加载,则返回
|
|
94
93
|
if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
|
|
95
|
-
|
|
94
|
+
FW.Log.error('无法加载本地manifest文件');
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
98
97
|
}
|
|
@@ -109,37 +108,37 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
109
108
|
this.assetMgr.loadLocalManifest(updatedManifestPath);
|
|
110
109
|
|
|
111
110
|
if (this.assetMgr.getLocalManifest() && this.assetMgr.getLocalManifest().isLoaded()) {
|
|
112
|
-
|
|
111
|
+
FW.Log.debug('本地manifest重新加载成功');
|
|
113
112
|
this.localManifest = this.assetMgr.getLocalManifest();
|
|
114
113
|
} else {
|
|
115
|
-
|
|
114
|
+
FW.Log.error('本地manifest重新加载失败');
|
|
116
115
|
}
|
|
117
116
|
} else {
|
|
118
|
-
|
|
117
|
+
FW.Log.error('更新后的manifest文件不存在:', updatedManifestPath);
|
|
119
118
|
}
|
|
120
119
|
} catch (error) {
|
|
121
|
-
|
|
120
|
+
FW.Log.error('重新加载本地manifest时出错:', error);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
private checkEventHandle(event: any) {
|
|
126
125
|
const code = event.getEventCode();
|
|
127
|
-
|
|
126
|
+
FW.Log.debug('checkEvent getEventCode -> ', code);
|
|
128
127
|
switch (code) {
|
|
129
128
|
case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
|
|
130
|
-
|
|
129
|
+
FW.Log.debug('checkEvent getEventCode -> ', 'ERROR_NO_LOCAL_MANIFEST');
|
|
131
130
|
break;
|
|
132
131
|
case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
|
|
133
|
-
|
|
132
|
+
FW.Log.debug('checkEvent getEventCode -> ', 'ERROR_DOWNLOAD_MANIFEST');
|
|
134
133
|
break;
|
|
135
134
|
case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST:
|
|
136
|
-
|
|
135
|
+
FW.Log.debug('checkEvent getEventCode -> ', 'ERROR_PARSE_MANIFEST');
|
|
137
136
|
break;
|
|
138
137
|
case jsb.EventAssetsManager.ALREADY_UP_TO_DATE:
|
|
139
|
-
|
|
138
|
+
FW.Log.debug('checkEvent getEventCode -> ', 'ALREADY_UP_TO_DATE');
|
|
140
139
|
break;
|
|
141
140
|
case jsb.EventAssetsManager.NEW_VERSION_FOUND:
|
|
142
|
-
|
|
141
|
+
FW.Log.debug('checkEvent getEventCode -> ', 'NEW_VERSION_FOUND');
|
|
143
142
|
break;
|
|
144
143
|
default:
|
|
145
144
|
return;
|
|
@@ -148,7 +147,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
148
147
|
this.listener.checkHotUpdateHandle?.(code);
|
|
149
148
|
this.assetMgr.setEventCallback(null!);
|
|
150
149
|
this.isUpdate = false;
|
|
151
|
-
|
|
150
|
+
FW.Log.debug(
|
|
152
151
|
'isFind New Version -> ',
|
|
153
152
|
event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND,
|
|
154
153
|
);
|
|
@@ -158,10 +157,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
private hotUpdate() {
|
|
161
|
-
|
|
160
|
+
FW.Log.debug('start hotUpdate ->', this.assetMgr, this.isUpdate);
|
|
162
161
|
if (this.assetMgr && !this.isUpdate) {
|
|
163
162
|
this.assetMgr.setEventCallback(this.updateEventHandle.bind(this));
|
|
164
|
-
|
|
163
|
+
FW.Log.debug(
|
|
165
164
|
'assetMgr state ->',
|
|
166
165
|
this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED,
|
|
167
166
|
);
|
|
@@ -185,7 +184,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
185
184
|
let convertTotalBytes: string = '';
|
|
186
185
|
const code = event.getEventCode();
|
|
187
186
|
const msg = event.getMessage();
|
|
188
|
-
|
|
187
|
+
FW.Log.debug('updateEvent getEventCode -> ', code);
|
|
189
188
|
let str = '';
|
|
190
189
|
switch (code) {
|
|
191
190
|
case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
|
|
@@ -194,7 +193,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
194
193
|
break;
|
|
195
194
|
case jsb.EventAssetsManager.UPDATE_PROGRESSION:
|
|
196
195
|
str = 'UPDATE_PROGRESSION';
|
|
197
|
-
|
|
196
|
+
FW.Log.debug('updateEvent percent -> ', event.getPercent());
|
|
198
197
|
if (event.getPercent() > 0) {
|
|
199
198
|
downloadedFiles = event.getDownloadedFiles();
|
|
200
199
|
totalFiles = event.getTotalFiles();
|
|
@@ -203,7 +202,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
203
202
|
convertDownloadedBytes = this.convertBytes(downloadedBytes);
|
|
204
203
|
convertTotalBytes = this.convertBytes(totalBytes);
|
|
205
204
|
percent = event.getPercent();
|
|
206
|
-
|
|
205
|
+
FW.Log.debug(
|
|
207
206
|
'正在更新中 -> ',
|
|
208
207
|
'下载文件数量:',
|
|
209
208
|
downloadedFiles,
|
|
@@ -236,7 +235,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
236
235
|
convertDownloadedBytes = this.convertBytes(downloadedBytes);
|
|
237
236
|
convertTotalBytes = this.convertBytes(totalBytes);
|
|
238
237
|
percent = event.getPercent();
|
|
239
|
-
|
|
238
|
+
FW.Log.debug(
|
|
240
239
|
'正在更新完成 -> ',
|
|
241
240
|
'下载文件数量:',
|
|
242
241
|
downloadedFiles,
|
|
@@ -266,8 +265,8 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
266
265
|
break;
|
|
267
266
|
}
|
|
268
267
|
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
FW.Log.debug('热更新中->', str);
|
|
269
|
+
FW.Log.debug('热更新msg ->', msg);
|
|
271
270
|
this.listener.hotUpdatingHandle?.(code, {
|
|
272
271
|
percent: percent,
|
|
273
272
|
downloadedFiles: downloadedFiles,
|
|
@@ -278,15 +277,15 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
278
277
|
convertTotalBytes: convertTotalBytes,
|
|
279
278
|
});
|
|
280
279
|
if (failed) {
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
FW.Log.debug('热更新中结果 failed -> ', failed);
|
|
281
|
+
FW.Log.debug('下载失败');
|
|
283
282
|
this.assetMgr.setEventCallback(null!);
|
|
284
283
|
this.isUpdate = false;
|
|
285
284
|
this.retry();
|
|
286
285
|
}
|
|
287
286
|
if (needRestart) {
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
FW.Log.debug('热更新中结果 needRestart -> ', needRestart);
|
|
288
|
+
FW.Log.debug('下载完成');
|
|
290
289
|
const searchPaths = jsb.fileUtils.getSearchPaths();
|
|
291
290
|
const newPaths = this.assetMgr.getLocalManifest().getSearchPaths();
|
|
292
291
|
Array.prototype.unshift.apply(searchPaths, newPaths);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FWEventDefine } from '../define/FWEventDefine';
|
|
2
1
|
import { FWManager } from './FWManager';
|
|
3
2
|
|
|
4
3
|
export default class FWLanguageManager extends FWManager implements FW.LanguageManager {
|
|
@@ -91,7 +90,7 @@ export default class FWLanguageManager extends FWManager implements FW.LanguageM
|
|
|
91
90
|
async initializeLanguage(language: string) {
|
|
92
91
|
if (this.language == language) return;
|
|
93
92
|
this.language = language;
|
|
94
|
-
FW.Entry.evtMgr.dispatch(
|
|
93
|
+
FW.Entry.evtMgr.dispatch(FW.EventDefine.LanguageEvent.LANGUAGE_CHANGE);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
getLanguageIndex() {
|