@ives_xxz/framework 1.6.4 → 1.6.6
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 +19 -0
- package/Framework.ts +24 -64
- package/FrameworkBase.ts +28 -48
- package/entry/FWEntry.ts +26 -29
- package/manager/FWBundleManager.ts +12 -13
- package/manager/FWEngineManager.ts +1 -2
- package/package.json +1 -1
- package/register/FWRegistry.ts +2 -3
package/FW.d.ts
CHANGED
|
@@ -2024,3 +2024,22 @@ declare namespace FW {
|
|
|
2024
2024
|
declare function timeScale(scale: number);
|
|
2025
2025
|
declare let Entry: Entry;
|
|
2026
2026
|
}
|
|
2027
|
+
|
|
2028
|
+
declare namespace FW {
|
|
2029
|
+
export type Framework = {
|
|
2030
|
+
initialize(): void;
|
|
2031
|
+
addRegistry(bundleName: string, registry: new () => Registry): void;
|
|
2032
|
+
getContainer(): any;
|
|
2033
|
+
getComponent<T>(serviceIdentifier: ServiceIdentifier<T>): T;
|
|
2034
|
+
getComponents<T>(serviceIdentifier: ServiceIdentifier<T>): T[];
|
|
2035
|
+
hasRegistry(bundleName: string): boolean;
|
|
2036
|
+
getRegistry(bundleName: string): Registry;
|
|
2037
|
+
createRegistry(bundleName: string): Registry;
|
|
2038
|
+
destroyRegistry(bundleName: string): void;
|
|
2039
|
+
register(data: RegisterFramework): void;
|
|
2040
|
+
unRegister(data: RegisterFramework): void;
|
|
2041
|
+
restart(): void;
|
|
2042
|
+
getRegisteredComponents(): Map<string, RegisterFramework[]>;
|
|
2043
|
+
};
|
|
2044
|
+
declare let Framework: Framework;
|
|
2045
|
+
}
|
package/Framework.ts
CHANGED
|
@@ -1,44 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Container, interfaces } from
|
|
3
|
-
import { FWSystemDefine } from
|
|
4
|
-
import FWLog from
|
|
5
|
-
import { FWEventDefine } from
|
|
6
|
-
import { FrameworkBase } from
|
|
7
|
-
|
|
8
|
-
class Framework {
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Container, interfaces } from 'inversify';
|
|
3
|
+
import { FWSystemDefine } from './define/FWSystemDefine';
|
|
4
|
+
import FWLog from './log/FWLog';
|
|
5
|
+
import { FWEventDefine } from './define/FWEventDefine';
|
|
6
|
+
import { FrameworkBase } from './FrameworkBase';
|
|
7
|
+
|
|
8
|
+
export class Framework implements FW.Framework {
|
|
9
9
|
private container: Container;
|
|
10
10
|
private registry: Map<string, new () => FW.Registry>;
|
|
11
11
|
private registeredComponents: Map<string, FW.RegisterFramework[]> = new Map();
|
|
12
|
-
private static instance: Framework;
|
|
13
|
-
private constructor() {}
|
|
14
12
|
|
|
15
13
|
initialize() {
|
|
16
14
|
this.container = new Container({
|
|
17
|
-
defaultScope:
|
|
15
|
+
defaultScope: 'Singleton',
|
|
18
16
|
autoBindInjectable: true,
|
|
19
17
|
});
|
|
20
18
|
this.registry = new Map<string, new () => FW.Registry>();
|
|
21
19
|
this.registeredComponents.clear();
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
public static getInstance() {
|
|
25
|
-
if (!this.instance) {
|
|
26
|
-
this.instance = new Framework();
|
|
27
|
-
}
|
|
28
|
-
return this.instance;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
public getContainer(): Container {
|
|
32
23
|
return this.container;
|
|
33
24
|
}
|
|
34
25
|
|
|
35
26
|
/** 获取组件 */
|
|
36
27
|
public getComponent<T>(serviceIdentifier: FW.ServiceIdentifier<T>): T {
|
|
37
|
-
if (typeof serviceIdentifier ===
|
|
28
|
+
if (typeof serviceIdentifier === 'string') {
|
|
38
29
|
if (this.container.isBound(serviceIdentifier)) {
|
|
39
30
|
return this.container.get<T>(serviceIdentifier);
|
|
40
31
|
}
|
|
41
|
-
} else if (typeof serviceIdentifier ===
|
|
32
|
+
} else if (typeof serviceIdentifier === 'function') {
|
|
42
33
|
const className = serviceIdentifier.name;
|
|
43
34
|
|
|
44
35
|
if (this.container.isBound(serviceIdentifier)) {
|
|
@@ -53,9 +44,7 @@ class Framework {
|
|
|
53
44
|
Handle: FWSystemDefine.FWBindTag.HANDLE,
|
|
54
45
|
};
|
|
55
46
|
|
|
56
|
-
const [suffix] =
|
|
57
|
-
Object.entries(suffixMap).find(([key]) => className.endsWith(key)) ||
|
|
58
|
-
[];
|
|
47
|
+
const [suffix] = Object.entries(suffixMap).find(([key]) => className.endsWith(key)) || [];
|
|
59
48
|
|
|
60
49
|
if (suffix) {
|
|
61
50
|
const bundleName = FW.Entry.bundleName;
|
|
@@ -131,10 +120,7 @@ class Framework {
|
|
|
131
120
|
*/
|
|
132
121
|
createRegistry(bundleName: string): FW.Registry {
|
|
133
122
|
if (!this.registry.has(bundleName)) return;
|
|
134
|
-
this.container
|
|
135
|
-
.bind(this.registry.get(bundleName))
|
|
136
|
-
.toSelf()
|
|
137
|
-
.inSingletonScope();
|
|
123
|
+
this.container.bind(this.registry.get(bundleName)).toSelf().inSingletonScope();
|
|
138
124
|
return this.getRegistry(bundleName);
|
|
139
125
|
}
|
|
140
126
|
|
|
@@ -152,13 +138,7 @@ class Framework {
|
|
|
152
138
|
* @param data
|
|
153
139
|
*/
|
|
154
140
|
register(data: FW.RegisterFramework) {
|
|
155
|
-
const classes = [
|
|
156
|
-
data.logic,
|
|
157
|
-
data.data,
|
|
158
|
-
data.config,
|
|
159
|
-
data.sender,
|
|
160
|
-
data.handle,
|
|
161
|
-
];
|
|
141
|
+
const classes = [data.logic, data.data, data.config, data.sender, data.handle];
|
|
162
142
|
classes.forEach((cls, index) => {
|
|
163
143
|
if (cls && !this.container.isBound(cls)) {
|
|
164
144
|
this.container.bind(cls).toSelf().inSingletonScope();
|
|
@@ -186,21 +166,15 @@ class Framework {
|
|
|
186
166
|
* @returns
|
|
187
167
|
*/
|
|
188
168
|
unRegister(data: FW.RegisterFramework) {
|
|
189
|
-
const classes = [
|
|
190
|
-
data.logic,
|
|
191
|
-
data.data,
|
|
192
|
-
data.config,
|
|
193
|
-
data.sender,
|
|
194
|
-
data.handle,
|
|
195
|
-
];
|
|
169
|
+
const classes = [data.logic, data.data, data.config, data.sender, data.handle];
|
|
196
170
|
classes.forEach((cls, index) => {
|
|
197
171
|
const key = this.getKey(data.bundleName, index);
|
|
198
172
|
if (cls && this.container.isBound(cls)) {
|
|
199
|
-
this.container.get(key)?.[
|
|
173
|
+
this.container.get(key)?.['onDestroy']?.();
|
|
200
174
|
this.container.unbind(cls);
|
|
201
175
|
}
|
|
202
176
|
if (this.container.isBound(key)) {
|
|
203
|
-
this.container.get(key)?.[
|
|
177
|
+
this.container.get(key)?.['onDestroy']?.();
|
|
204
178
|
this.container.unbind(this.getKey(data.bundleName, index));
|
|
205
179
|
}
|
|
206
180
|
});
|
|
@@ -216,10 +190,7 @@ class Framework {
|
|
|
216
190
|
|
|
217
191
|
const registrations = this.registeredComponents.get(bundleName)!;
|
|
218
192
|
const exists = registrations.some(
|
|
219
|
-
(reg) =>
|
|
220
|
-
reg.logic === data.logic &&
|
|
221
|
-
reg.data === data.data &&
|
|
222
|
-
reg.config === data.config
|
|
193
|
+
(reg) => reg.logic === data.logic && reg.data === data.data && reg.config === data.config,
|
|
223
194
|
);
|
|
224
195
|
|
|
225
196
|
if (!exists) {
|
|
@@ -232,10 +203,7 @@ class Framework {
|
|
|
232
203
|
if (this.registeredComponents.has(bundleName)) {
|
|
233
204
|
const registrations = this.registeredComponents.get(bundleName)!;
|
|
234
205
|
const index = registrations.findIndex(
|
|
235
|
-
(reg) =>
|
|
236
|
-
reg.logic === data.logic &&
|
|
237
|
-
reg.data === data.data &&
|
|
238
|
-
reg.config === data.config
|
|
206
|
+
(reg) => reg.logic === data.logic && reg.data === data.data && reg.config === data.config,
|
|
239
207
|
);
|
|
240
208
|
|
|
241
209
|
if (index !== -1) {
|
|
@@ -252,7 +220,7 @@ class Framework {
|
|
|
252
220
|
this.destroyAllComponents();
|
|
253
221
|
this.container.unbindAll();
|
|
254
222
|
this.container = new Container({
|
|
255
|
-
defaultScope:
|
|
223
|
+
defaultScope: 'Singleton',
|
|
256
224
|
autoBindInjectable: true,
|
|
257
225
|
});
|
|
258
226
|
|
|
@@ -268,7 +236,7 @@ class Framework {
|
|
|
268
236
|
try {
|
|
269
237
|
if (this.container.isBound(binding.serviceIdentifier)) {
|
|
270
238
|
const instance = this.container.get(binding.serviceIdentifier);
|
|
271
|
-
instance?.[
|
|
239
|
+
instance?.['onDestroy']?.();
|
|
272
240
|
}
|
|
273
241
|
} catch (e) {
|
|
274
242
|
FWLog.warn(`Error destroying component ${key}:`, e);
|
|
@@ -278,18 +246,12 @@ class Framework {
|
|
|
278
246
|
}
|
|
279
247
|
|
|
280
248
|
private reregisterAllComponents(): void {
|
|
281
|
-
for (const [
|
|
282
|
-
bundleName,
|
|
283
|
-
registrations,
|
|
284
|
-
] of this.registeredComponents.entries()) {
|
|
249
|
+
for (const [bundleName, registrations] of this.registeredComponents.entries()) {
|
|
285
250
|
for (const data of registrations) {
|
|
286
251
|
try {
|
|
287
252
|
this.register(data);
|
|
288
253
|
} catch (e) {
|
|
289
|
-
console.error(
|
|
290
|
-
`Error re-registering component for bundle ${bundleName}:`,
|
|
291
|
-
e
|
|
292
|
-
);
|
|
254
|
+
console.error(`Error re-registering component for bundle ${bundleName}:`, e);
|
|
293
255
|
}
|
|
294
256
|
}
|
|
295
257
|
}
|
|
@@ -304,7 +266,7 @@ class Framework {
|
|
|
304
266
|
}
|
|
305
267
|
|
|
306
268
|
private isSubclassOf(child: any, parent: any): boolean {
|
|
307
|
-
if (typeof child !==
|
|
269
|
+
if (typeof child !== 'function' || typeof parent !== 'function') {
|
|
308
270
|
return false;
|
|
309
271
|
}
|
|
310
272
|
let current = child;
|
|
@@ -317,5 +279,3 @@ class Framework {
|
|
|
317
279
|
return false;
|
|
318
280
|
}
|
|
319
281
|
}
|
|
320
|
-
|
|
321
|
-
export default Framework.getInstance();
|
package/FrameworkBase.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { injectable } from
|
|
2
|
-
import { FWEventDefine } from
|
|
3
|
-
import FWLog from
|
|
4
|
-
import { FWSystemDefine } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import FWData from "./data/FWData";
|
|
1
|
+
import { injectable } from 'inversify';
|
|
2
|
+
import { FWEventDefine } from './define/FWEventDefine';
|
|
3
|
+
import FWLog from './log/FWLog';
|
|
4
|
+
import { FWSystemDefine } from './define/FWSystemDefine';
|
|
5
|
+
import FWLogic from './logic/FWLogic';
|
|
6
|
+
import FWData from './data/FWData';
|
|
8
7
|
@injectable()
|
|
9
8
|
export abstract class FrameworkBase {
|
|
10
9
|
public readonly entry: FW.Entry = FW.Entry;
|
|
@@ -20,11 +19,7 @@ export abstract class FrameworkBase {
|
|
|
20
19
|
protected onRestart?(): void;
|
|
21
20
|
constructor() {
|
|
22
21
|
this.initialize?.();
|
|
23
|
-
this.entry.evtMgr.register(
|
|
24
|
-
FWEventDefine.SystemEvent.SYSTEM_RESTART,
|
|
25
|
-
this.onRestart,
|
|
26
|
-
this
|
|
27
|
-
);
|
|
22
|
+
this.entry.evtMgr.register(FWEventDefine.SystemEvent.SYSTEM_RESTART, this.onRestart, this);
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
protected get moduleName(): string {
|
|
@@ -63,40 +58,37 @@ export abstract class FrameworkBase {
|
|
|
63
58
|
const tag = this.getClassTag();
|
|
64
59
|
|
|
65
60
|
if (tag !== FWSystemDefine.FWBindTag.LOGIC) {
|
|
66
|
-
this.logic = Framework.getComponent<FW.Logic>(
|
|
67
|
-
`${bundleName}${FWSystemDefine.FWBindTag.LOGIC}
|
|
61
|
+
this.logic = FW.Framework.getComponent<FW.Logic>(
|
|
62
|
+
`${bundleName}${FWSystemDefine.FWBindTag.LOGIC}`,
|
|
68
63
|
);
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
if (tag !== FWSystemDefine.FWBindTag.DATA) {
|
|
72
|
-
this.data = Framework.getComponent<FW.Data>(
|
|
73
|
-
`${bundleName}${FWSystemDefine.FWBindTag.DATA}
|
|
67
|
+
this.data = FW.Framework.getComponent<FW.Data>(
|
|
68
|
+
`${bundleName}${FWSystemDefine.FWBindTag.DATA}`,
|
|
74
69
|
);
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
if (tag !== FWSystemDefine.FWBindTag.CONFIG) {
|
|
78
|
-
this.config = Framework.getComponent<FW.Config>(
|
|
79
|
-
`${bundleName}${FWSystemDefine.FWBindTag.CONFIG}
|
|
73
|
+
this.config = FW.Framework.getComponent<FW.Config>(
|
|
74
|
+
`${bundleName}${FWSystemDefine.FWBindTag.CONFIG}`,
|
|
80
75
|
);
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
if (tag !== FWSystemDefine.FWBindTag.SENDER) {
|
|
84
|
-
this.sender = Framework.getComponent<FW.SocketSender>(
|
|
85
|
-
`${bundleName}${FWSystemDefine.FWBindTag.SENDER}
|
|
79
|
+
this.sender = FW.Framework.getComponent<FW.SocketSender>(
|
|
80
|
+
`${bundleName}${FWSystemDefine.FWBindTag.SENDER}`,
|
|
86
81
|
);
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
if (tag !== FWSystemDefine.FWBindTag.HANDLE) {
|
|
90
|
-
this.handle = Framework.getComponent<FW.SocketHandle>(
|
|
91
|
-
`${bundleName}${FWSystemDefine.FWBindTag.HANDLE}
|
|
85
|
+
this.handle = FW.Framework.getComponent<FW.SocketHandle>(
|
|
86
|
+
`${bundleName}${FWSystemDefine.FWBindTag.HANDLE}`,
|
|
92
87
|
);
|
|
93
88
|
}
|
|
94
89
|
}
|
|
95
90
|
|
|
96
|
-
protected async invoke<T>(
|
|
97
|
-
operation: Promise<T>,
|
|
98
|
-
operationName: string = "unknown"
|
|
99
|
-
): Promise<T> {
|
|
91
|
+
protected async invoke<T>(operation: Promise<T>, operationName: string = 'unknown'): Promise<T> {
|
|
100
92
|
const startTime = this.getCurrentTime();
|
|
101
93
|
|
|
102
94
|
try {
|
|
@@ -110,25 +102,16 @@ export abstract class FrameworkBase {
|
|
|
110
102
|
}
|
|
111
103
|
}
|
|
112
104
|
|
|
113
|
-
private recordPerformanceMetric(
|
|
114
|
-
operationName: string,
|
|
115
|
-
duration: number
|
|
116
|
-
): void {
|
|
105
|
+
private recordPerformanceMetric(operationName: string, duration: number): void {
|
|
117
106
|
if (FW.Entry.performanceMgr) {
|
|
118
|
-
FW.Entry.performanceMgr.recordOperationMetric(
|
|
119
|
-
this.moduleName,
|
|
120
|
-
operationName,
|
|
121
|
-
duration
|
|
122
|
-
);
|
|
107
|
+
FW.Entry.performanceMgr.recordOperationMetric(this.moduleName, operationName, duration);
|
|
123
108
|
}
|
|
124
109
|
|
|
125
110
|
const shouldWarn = duration > 1000;
|
|
126
111
|
|
|
127
112
|
if (FW.Entry.engineMgr.debug || shouldWarn) {
|
|
128
113
|
const log = shouldWarn ? FWLog.warn : FWLog.debug;
|
|
129
|
-
log(
|
|
130
|
-
`[${this.moduleName?.toUpperCase()}] Operation ${operationName} took ${duration}ms`
|
|
131
|
-
);
|
|
114
|
+
log(`[${this.moduleName?.toUpperCase()}] Operation ${operationName} took ${duration}ms`);
|
|
132
115
|
}
|
|
133
116
|
}
|
|
134
117
|
|
|
@@ -148,7 +131,7 @@ export abstract class FrameworkBase {
|
|
|
148
131
|
}
|
|
149
132
|
|
|
150
133
|
private findBundleNameByClassName(): string | undefined {
|
|
151
|
-
const registeredComponents = Framework.getRegisteredComponents();
|
|
134
|
+
const registeredComponents = FW.Framework.getRegisteredComponents();
|
|
152
135
|
|
|
153
136
|
const bundleNames = Array.from(registeredComponents.keys());
|
|
154
137
|
|
|
@@ -161,10 +144,7 @@ export abstract class FrameworkBase {
|
|
|
161
144
|
return undefined;
|
|
162
145
|
}
|
|
163
146
|
|
|
164
|
-
private doesClassNameContainBundleName(
|
|
165
|
-
className: string,
|
|
166
|
-
bundleName: string
|
|
167
|
-
): boolean {
|
|
147
|
+
private doesClassNameContainBundleName(className: string, bundleName: string): boolean {
|
|
168
148
|
const bundleNameLower = bundleName.toLowerCase();
|
|
169
149
|
const classNameLower = className.toLowerCase();
|
|
170
150
|
return classNameLower.includes(bundleNameLower);
|
|
@@ -172,13 +152,13 @@ export abstract class FrameworkBase {
|
|
|
172
152
|
|
|
173
153
|
private getClassTag(): FWSystemDefine.FWBindTag {
|
|
174
154
|
const className = this.moduleName;
|
|
175
|
-
if (className.endsWith(
|
|
176
|
-
if (className.endsWith(
|
|
177
|
-
if (className.endsWith(
|
|
155
|
+
if (className.endsWith('Logic')) return FWSystemDefine.FWBindTag.LOGIC;
|
|
156
|
+
if (className.endsWith('Data')) return FWSystemDefine.FWBindTag.DATA;
|
|
157
|
+
if (className.endsWith('Config') || className.endsWith('AssetConfig'))
|
|
178
158
|
return FWSystemDefine.FWBindTag.CONFIG;
|
|
179
|
-
if (className.endsWith(
|
|
159
|
+
if (className.endsWith('Sender') || className.endsWith('SocketSender'))
|
|
180
160
|
return FWSystemDefine.FWBindTag.SENDER;
|
|
181
|
-
if (className.endsWith(
|
|
161
|
+
if (className.endsWith('Handle') || className.endsWith('SocketHandle'))
|
|
182
162
|
return FWSystemDefine.FWBindTag.HANDLE;
|
|
183
163
|
return;
|
|
184
164
|
}
|
package/entry/FWEntry.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import FWUiManager from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { FWPerformanceManager } from "../manager/FWPerformanceManager";
|
|
1
|
+
import FWUiManager from '../manager/FWUiManager';
|
|
2
|
+
import FWLog from '../log/FWLog';
|
|
3
|
+
import FWAnimationManager from '../manager/FWAnimationManager';
|
|
4
|
+
import FWAudioManager from '../manager/FWAudioManager';
|
|
5
|
+
import FWComponentManager from '../manager/FWComponentManager';
|
|
6
|
+
import FWEventManager from '../manager/FWEventManager';
|
|
7
|
+
import FWLanguageManager from '../manager/FWLanguageManager';
|
|
8
|
+
import { FWLayerManager } from '../manager/FWLayerManager';
|
|
9
|
+
import FWObjectManager from '../manager/FWObjectManager';
|
|
10
|
+
import { FWResManager } from '../manager/FWResManager';
|
|
11
|
+
import FWSocketManager from '../manager/FWSocketManager';
|
|
12
|
+
import { FWStateManager } from '../manager/FWStateManager';
|
|
13
|
+
import { FWTimeManager } from '../manager/FWTimeManager';
|
|
14
|
+
import FWScene from '../scene/FWScene';
|
|
15
|
+
import { FWSocketAutoProcessPause } from '../expand/FWDecorator';
|
|
16
|
+
import FWTaskManager from '../manager/FWTaskManager';
|
|
17
|
+
import FWEngineManager from '../manager/FWEngineManager';
|
|
18
|
+
import FWHotUpdateManager from '../manager/FWHotUpdateManager';
|
|
19
|
+
import FWPromiseManager from '../manager/FWPromiseManager';
|
|
20
|
+
import { FWPerformanceManager } from '../manager/FWPerformanceManager';
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* 入口脚本
|
|
@@ -142,10 +141,10 @@ export default class FWEntry implements FW.Entry {
|
|
|
142
141
|
if (!this.hasSceneName(name)) {
|
|
143
142
|
try {
|
|
144
143
|
cc.director.loadScene(name);
|
|
145
|
-
this.bundleName =
|
|
144
|
+
this.bundleName = '';
|
|
146
145
|
return;
|
|
147
146
|
} catch (e) {
|
|
148
|
-
FWLog.error(
|
|
147
|
+
FWLog.error('launchScene failed:', name);
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
|
|
@@ -204,13 +203,11 @@ export default class FWEntry implements FW.Entry {
|
|
|
204
203
|
return this.map.get(this.bundleName)?.sceneName || undefined;
|
|
205
204
|
}
|
|
206
205
|
|
|
207
|
-
getComponent: <T>(serviceIdentifier: FW.ServiceIdentifier<T>) => T = (
|
|
208
|
-
serviceIdentifier
|
|
209
|
-
) => Framework.getComponent(serviceIdentifier);
|
|
206
|
+
getComponent: <T>(serviceIdentifier: FW.ServiceIdentifier<T>) => T = (serviceIdentifier) =>
|
|
207
|
+
FW.Framework.getComponent(serviceIdentifier);
|
|
210
208
|
|
|
211
|
-
getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (
|
|
212
|
-
serviceIdentifier
|
|
213
|
-
) => Framework.getComponents(serviceIdentifier);
|
|
209
|
+
getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (serviceIdentifier) =>
|
|
210
|
+
FW.Framework.getComponents(serviceIdentifier);
|
|
214
211
|
|
|
215
212
|
update(dt: number) {
|
|
216
213
|
this.timeMgr?.onUpdate(dt);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { FWManager } from
|
|
2
|
-
import FWLog from
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { FWLodash } from "../utils/FWLodash";
|
|
1
|
+
import { FWManager } from './FWManager';
|
|
2
|
+
import FWLog from '../log/FWLog';
|
|
3
|
+
import { FWSystemConfig } from '../config/FWSystemConfig';
|
|
4
|
+
import { FWLodash } from '../utils/FWLodash';
|
|
6
5
|
|
|
7
6
|
export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
8
7
|
bundleMap: Map<string, cc.AssetManager.Bundle>;
|
|
@@ -36,12 +35,12 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
36
35
|
return await this.invoke(
|
|
37
36
|
FW.Entry.promiseMgr.execute((resolve, reject, signal) => {
|
|
38
37
|
const remote = this.remoteBundleConfigMap.get(bundleName);
|
|
39
|
-
const url = remote ? remote.url :
|
|
38
|
+
const url = remote ? remote.url : '';
|
|
40
39
|
const path = `${url}${bundleName}`;
|
|
41
40
|
cc.assetManager.loadBundle(
|
|
42
41
|
path,
|
|
43
42
|
{
|
|
44
|
-
version: this.remoteBundleConfigMap.get(bundleName)?.version ||
|
|
43
|
+
version: this.remoteBundleConfigMap.get(bundleName)?.version || '',
|
|
45
44
|
},
|
|
46
45
|
async (err: Error, bundle: cc.AssetManager.Bundle) => {
|
|
47
46
|
if (err || !bundle) {
|
|
@@ -49,15 +48,15 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
49
48
|
reject(err);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
Framework.createRegistry(bundleName)?.register();
|
|
51
|
+
FW.Framework.createRegistry(bundleName)?.register();
|
|
53
52
|
|
|
54
53
|
this.bundleMap.set(bundleName, bundle);
|
|
55
54
|
|
|
56
55
|
resolve(bundle);
|
|
57
|
-
}
|
|
56
|
+
},
|
|
58
57
|
);
|
|
59
58
|
}, FWSystemConfig.PromiseConfig.loadBundle).promise,
|
|
60
|
-
`loadBundle -> ${bundleName}
|
|
59
|
+
`loadBundle -> ${bundleName}`,
|
|
61
60
|
);
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -68,7 +67,7 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
68
67
|
*/
|
|
69
68
|
get(bundleName: string): cc.AssetManager.Bundle {
|
|
70
69
|
if (!this.has(bundleName)) {
|
|
71
|
-
FWLog.error(
|
|
70
|
+
FWLog.error('获取bundle失败,请先加载!');
|
|
72
71
|
return undefined;
|
|
73
72
|
}
|
|
74
73
|
return this.bundleMap.get(bundleName);
|
|
@@ -81,8 +80,8 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
81
80
|
}
|
|
82
81
|
cc.assetManager.removeBundle(this.bundleMap.get(bundleName));
|
|
83
82
|
this.bundleMap.delete(bundleName);
|
|
84
|
-
Framework.getRegistry(bundleName)?.unRegister();
|
|
85
|
-
Framework.destroyRegistry(bundleName);
|
|
83
|
+
FW.Framework.getRegistry(bundleName)?.unRegister();
|
|
84
|
+
FW.Framework.destroyRegistry(bundleName);
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FWEventDefine } from '../define/FWEventDefine';
|
|
2
2
|
import { FWSystemDefine } from '../define/FWSystemDefine';
|
|
3
|
-
import Framework from '../Framework';
|
|
4
3
|
import FWLog from '../log/FWLog';
|
|
5
4
|
import { FWManager } from './FWManager';
|
|
6
5
|
|
|
@@ -19,7 +18,7 @@ export default class FWEngineManager extends FWManager implements FW.EngineManag
|
|
|
19
18
|
restart() {
|
|
20
19
|
FW.Entry.evtMgr.dispatch(FWEventDefine.SystemEvent.SYSTEM_RESTART);
|
|
21
20
|
FW.Entry.initialize();
|
|
22
|
-
Framework.restart();
|
|
21
|
+
FW.Framework.restart();
|
|
23
22
|
cc.game.restart();
|
|
24
23
|
}
|
|
25
24
|
|
package/package.json
CHANGED
package/register/FWRegistry.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { injectable } from 'inversify';
|
|
2
|
-
import Framework from '../Framework';
|
|
3
2
|
|
|
4
3
|
@injectable()
|
|
5
4
|
export default abstract class FWRegistry implements FW.Registry {
|
|
@@ -48,9 +47,9 @@ export default abstract class FWRegistry implements FW.Registry {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
private bundleEnabled(enable?: boolean) {
|
|
51
|
-
const frameworkInvoke = enable ? Framework.register : Framework.unRegister;
|
|
50
|
+
const frameworkInvoke = enable ? FW.Framework.register : FW.Framework.unRegister;
|
|
52
51
|
const entryInvoke = enable ? FW.Entry.register : FW.Entry.unRegister;
|
|
53
|
-
frameworkInvoke.bind(Framework)({
|
|
52
|
+
frameworkInvoke.bind(FW.Framework)({
|
|
54
53
|
bundleName: this.bundleName,
|
|
55
54
|
logic: this.logic,
|
|
56
55
|
data: this.data,
|