@ives_xxz/framework 2.1.0 → 2.1.1
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/controller/FWLayerController.ts +1 -2
- package/entry/FWEntry.ts +25 -28
- package/manager/FWEngineManager.ts +25 -19
- package/package.json +1 -1
- package/scene/FWScene.ts +0 -4
- package/types/FW.d.ts +7 -7
|
@@ -35,9 +35,8 @@ export abstract class FWLayerController extends FW.FrameworkBase implements FW.L
|
|
|
35
35
|
async destroy() {
|
|
36
36
|
FW.Entry.timeMgr?.unSchedule(this);
|
|
37
37
|
FW.Entry.evtMgr?.targetOff(this);
|
|
38
|
-
cc.Tween.stopAllByTarget(this.layer?.node);
|
|
39
|
-
this.layer?.node?.stopAllActions();
|
|
40
38
|
this.layer?.unscheduleAllCallbacks();
|
|
39
|
+
this.layer?.node?.stopAllActions();
|
|
41
40
|
this.layer?.node?.destroy();
|
|
42
41
|
}
|
|
43
42
|
|
package/entry/FWEntry.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import FWUiManager from
|
|
2
|
-
import FWAnimationManager from
|
|
3
|
-
import FWAudioManager from
|
|
4
|
-
import FWComponentManager from
|
|
5
|
-
import FWEventManager from
|
|
6
|
-
import FWLanguageManager from
|
|
7
|
-
import { FWLayerManager } from
|
|
8
|
-
import FWObjectManager from
|
|
9
|
-
import { FWResManager } from
|
|
10
|
-
import FWSocketManager from
|
|
11
|
-
import { FWStateManager } from
|
|
12
|
-
import { FWTimeManager } from
|
|
13
|
-
import { FWSocketAutoProcessPause } from
|
|
14
|
-
import FWTaskManager from
|
|
15
|
-
import FWEngineManager from
|
|
16
|
-
import FWHotUpdateManager from
|
|
17
|
-
import FWPromiseManager from
|
|
18
|
-
import { FWPerformanceManager } from
|
|
1
|
+
import FWUiManager from '../manager/FWUiManager';
|
|
2
|
+
import FWAnimationManager from '../manager/FWAnimationManager';
|
|
3
|
+
import FWAudioManager from '../manager/FWAudioManager';
|
|
4
|
+
import FWComponentManager from '../manager/FWComponentManager';
|
|
5
|
+
import FWEventManager from '../manager/FWEventManager';
|
|
6
|
+
import FWLanguageManager from '../manager/FWLanguageManager';
|
|
7
|
+
import { FWLayerManager } from '../manager/FWLayerManager';
|
|
8
|
+
import FWObjectManager from '../manager/FWObjectManager';
|
|
9
|
+
import { FWResManager } from '../manager/FWResManager';
|
|
10
|
+
import FWSocketManager from '../manager/FWSocketManager';
|
|
11
|
+
import { FWStateManager } from '../manager/FWStateManager';
|
|
12
|
+
import { FWTimeManager } from '../manager/FWTimeManager';
|
|
13
|
+
import { FWSocketAutoProcessPause } from '../expand/FWDecorator';
|
|
14
|
+
import FWTaskManager from '../manager/FWTaskManager';
|
|
15
|
+
import FWEngineManager from '../manager/FWEngineManager';
|
|
16
|
+
import FWHotUpdateManager from '../manager/FWHotUpdateManager';
|
|
17
|
+
import FWPromiseManager from '../manager/FWPromiseManager';
|
|
18
|
+
import { FWPerformanceManager } from '../manager/FWPerformanceManager';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 入口脚本
|
|
@@ -98,18 +98,17 @@ export class FWEntry implements FW.Entry {
|
|
|
98
98
|
* bundle名字
|
|
99
99
|
*/
|
|
100
100
|
bundleName: string;
|
|
101
|
-
|
|
102
101
|
/**
|
|
103
102
|
* 初始化
|
|
104
103
|
* */
|
|
105
104
|
initialize() {
|
|
106
105
|
this.map = new Map<string, FW.RegisterBundle>();
|
|
107
106
|
this.evtMgr = new FWEventManager();
|
|
107
|
+
this.timeMgr = new FWTimeManager();
|
|
108
108
|
this.engineMgr = new FWEngineManager();
|
|
109
109
|
this.taskMgr = new FWTaskManager();
|
|
110
110
|
this.resMgr = new FWResManager();
|
|
111
111
|
this.layerMgr = new FWLayerManager();
|
|
112
|
-
this.timeMgr = new FWTimeManager();
|
|
113
112
|
this.uiMgr = new FWUiManager();
|
|
114
113
|
this.animationMgr = new FWAnimationManager();
|
|
115
114
|
this.stateMgr = new FWStateManager();
|
|
@@ -139,10 +138,10 @@ export class FWEntry implements FW.Entry {
|
|
|
139
138
|
if (!this.hasSceneName(name)) {
|
|
140
139
|
try {
|
|
141
140
|
cc.director.loadScene(name);
|
|
142
|
-
this.bundleName =
|
|
141
|
+
this.bundleName = '';
|
|
143
142
|
return;
|
|
144
143
|
} catch (e) {
|
|
145
|
-
FW.Log.error(
|
|
144
|
+
FW.Log.error('launchScene failed:', name);
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
147
|
|
|
@@ -201,13 +200,11 @@ export class FWEntry implements FW.Entry {
|
|
|
201
200
|
return this.map.get(this.bundleName)?.sceneName || undefined;
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
getComponent: <T>(serviceIdentifier: FW.ServiceIdentifier<T>) => T = (
|
|
205
|
-
serviceIdentifier
|
|
206
|
-
) => FW.Framework.getComponent(serviceIdentifier);
|
|
203
|
+
getComponent: <T>(serviceIdentifier: FW.ServiceIdentifier<T>) => T = (serviceIdentifier) =>
|
|
204
|
+
FW.Framework.getComponent(serviceIdentifier);
|
|
207
205
|
|
|
208
|
-
getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (
|
|
209
|
-
serviceIdentifier
|
|
210
|
-
) => FW.Framework.getComponents(serviceIdentifier);
|
|
206
|
+
getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (serviceIdentifier) =>
|
|
207
|
+
FW.Framework.getComponents(serviceIdentifier);
|
|
211
208
|
|
|
212
209
|
update(dt: number) {
|
|
213
210
|
this.timeMgr?.onUpdate(dt);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { FWManager } from
|
|
1
|
+
import { FWManager } from './FWManager';
|
|
2
2
|
|
|
3
|
-
export default class FWEngineManager
|
|
4
|
-
extends FWManager
|
|
5
|
-
implements FW.EngineManager
|
|
6
|
-
{
|
|
3
|
+
export default class FWEngineManager extends FWManager implements FW.EngineManager {
|
|
7
4
|
debug: boolean = false;
|
|
8
|
-
launchScene: string =
|
|
5
|
+
launchScene: string = '';
|
|
9
6
|
|
|
10
7
|
initialize() {
|
|
11
8
|
this.registerCCCSystemEvent();
|
|
@@ -14,6 +11,7 @@ export default class FWEngineManager
|
|
|
14
11
|
onDestroy(): void {
|
|
15
12
|
cc.game.off(cc.game.EVENT_SHOW, this.onAppShow, this);
|
|
16
13
|
cc.game.off(cc.game.EVENT_HIDE, this.onAppHide, this);
|
|
14
|
+
cc.game.off(cc.game.EVENT_GAME_INITED, this.onCreatorInited, this);
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
restart() {
|
|
@@ -25,21 +23,21 @@ export default class FWEngineManager
|
|
|
25
23
|
|
|
26
24
|
getMemory() {
|
|
27
25
|
if (!this.debug) return;
|
|
28
|
-
if (window.performance && window.performance[
|
|
26
|
+
if (window.performance && window.performance['memory']) {
|
|
29
27
|
FW.Log.debug(
|
|
30
|
-
|
|
31
|
-
this.formatBytes(window.performance[
|
|
28
|
+
'浏览器允许的最大内存:',
|
|
29
|
+
this.formatBytes(window.performance['memory'].jsHeapSizeLimit),
|
|
32
30
|
);
|
|
33
31
|
FW.Log.debug(
|
|
34
|
-
|
|
35
|
-
this.formatBytes(window.performance[
|
|
32
|
+
'浏览器已分配内存:',
|
|
33
|
+
this.formatBytes(window.performance['memory'].totalJSHeapSize),
|
|
36
34
|
);
|
|
37
35
|
FW.Log.debug(
|
|
38
|
-
|
|
39
|
-
this.formatBytes(window.performance[
|
|
36
|
+
'浏览器已使用内存:',
|
|
37
|
+
this.formatBytes(window.performance['memory'].usedJSHeapSize),
|
|
40
38
|
);
|
|
41
39
|
} else {
|
|
42
|
-
FW.Log.debug(
|
|
40
|
+
FW.Log.debug('当前浏览器不支持 performance.memory');
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
@@ -48,26 +46,34 @@ export default class FWEngineManager
|
|
|
48
46
|
private registerCCCSystemEvent() {
|
|
49
47
|
cc.game.on(cc.game.EVENT_SHOW, this.onAppShow, this);
|
|
50
48
|
cc.game.on(cc.game.EVENT_HIDE, this.onAppHide, this);
|
|
49
|
+
cc.game.on(cc.game.EVENT_GAME_INITED, this.onCreatorInited, this);
|
|
51
50
|
}
|
|
51
|
+
|
|
52
|
+
private onCreatorInited() {
|
|
53
|
+
FW.Entry.timeMgr.scheduleOnce(() => {
|
|
54
|
+
this.launchScene = cc.director.getScene()?.name || 'launchScene';
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
/** 应用切换到前台 */
|
|
53
59
|
private onAppShow() {
|
|
54
|
-
FW.Log.debug(
|
|
60
|
+
FW.Log.debug('game on show!');
|
|
55
61
|
FW.Entry.evtMgr?.dispatch(FW.EventDefine.CCEvent.ON_SHOW);
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/** 应用切换到后台 */
|
|
59
65
|
private onAppHide() {
|
|
60
|
-
FW.Log.debug(
|
|
66
|
+
FW.Log.debug('game on hide!');
|
|
61
67
|
FW.Entry.evtMgr?.dispatch(FW.EventDefine.CCEvent.ON_HIDE);
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
private formatBytes(bytes: number) {
|
|
65
71
|
if (bytes < 1024 * 1024) {
|
|
66
|
-
return (bytes / 1024).toFixed(2) +
|
|
72
|
+
return (bytes / 1024).toFixed(2) + ' KB';
|
|
67
73
|
} else if (bytes < 1024 * 1024 * 1024) {
|
|
68
|
-
return (bytes / 1024 / 1024).toFixed(2) +
|
|
74
|
+
return (bytes / 1024 / 1024).toFixed(2) + ' MB';
|
|
69
75
|
} else {
|
|
70
|
-
return (bytes / 1024 / 1024 / 1024).toFixed(2) +
|
|
76
|
+
return (bytes / 1024 / 1024 / 1024).toFixed(2) + ' GB';
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
}
|
package/package.json
CHANGED
package/scene/FWScene.ts
CHANGED
|
@@ -7,10 +7,6 @@ export abstract class FWScene extends cc.Component {
|
|
|
7
7
|
@FWSocketAutoProcessResume()
|
|
8
8
|
onLoad(): void {
|
|
9
9
|
this.entry.scene = this;
|
|
10
|
-
if (!this.entry.engineMgr.launchScene) {
|
|
11
|
-
this.entry.engineMgr.launchScene =
|
|
12
|
-
cc.director.getScene()?.name || undefined;
|
|
13
|
-
}
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
update(dt: number): void {
|
package/types/FW.d.ts
CHANGED
|
@@ -469,19 +469,19 @@ declare namespace FW {
|
|
|
469
469
|
*/
|
|
470
470
|
type SocketConfig = {
|
|
471
471
|
/** 心跳间隔 */
|
|
472
|
-
heartInternal
|
|
472
|
+
heartInternal?: number;
|
|
473
473
|
/** 心跳超时时间 */
|
|
474
|
-
heartTimeout
|
|
474
|
+
heartTimeout?: number;
|
|
475
475
|
/** 心跳弱网时间 */
|
|
476
|
-
heartWeakTime
|
|
476
|
+
heartWeakTime?: number;
|
|
477
477
|
/** 最大重连次数 */
|
|
478
|
-
maxReconnectTimes
|
|
478
|
+
maxReconnectTimes?: number;
|
|
479
479
|
/** 重连间隔 */
|
|
480
|
-
reconnectInternal
|
|
480
|
+
reconnectInternal?: number;
|
|
481
481
|
/** 协议符号 */
|
|
482
|
-
protocolSymbol
|
|
482
|
+
protocolSymbol?: Symbol;
|
|
483
483
|
/** 协议轮询时间 */
|
|
484
|
-
protocolPollingTime
|
|
484
|
+
protocolPollingTime?: number;
|
|
485
485
|
/** 证书(可选) */
|
|
486
486
|
certificate?: cc.Asset;
|
|
487
487
|
};
|