@ives_xxz/framework 1.6.3 → 1.6.5
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 +74 -125
- package/Framework.ts +24 -64
- package/FrameworkBase.ts +28 -48
- package/config/FWSystemConfig.ts +4 -4
- package/entry/FWEntry.ts +26 -29
- package/manager/FWAssetManager.ts +46 -67
- package/manager/FWBundleManager.ts +12 -13
- package/manager/FWPromiseManager.ts +39 -76
- package/manager/FWResManager.ts +14 -21
- package/manager/FWUiManager.ts +11 -18
- package/package.json +1 -1
- package/register/FWRegistry.ts +2 -3
- package/service/http/FWHttp.ts +37 -57
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/config/FWSystemConfig.ts
CHANGED
|
@@ -11,13 +11,13 @@ export namespace FWSystemConfig {
|
|
|
11
11
|
|
|
12
12
|
export const PromiseConfig = {
|
|
13
13
|
loadAsset: {
|
|
14
|
-
retryCount:
|
|
15
|
-
retryInterval:
|
|
14
|
+
retryCount: 0,
|
|
15
|
+
retryInterval: 0,
|
|
16
16
|
timeout: 10,
|
|
17
17
|
},
|
|
18
18
|
loadBundle: {
|
|
19
|
-
retryCount:
|
|
20
|
-
retryInterval:
|
|
19
|
+
retryCount: 0,
|
|
20
|
+
retryInterval: 0,
|
|
21
21
|
timeout: 10,
|
|
22
22
|
},
|
|
23
23
|
http: {
|
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,6 +1,6 @@
|
|
|
1
|
-
import { FWSystemConfig } from
|
|
2
|
-
import FWLog from
|
|
3
|
-
import { FWManager } from
|
|
1
|
+
import { FWSystemConfig } from '../config/FWSystemConfig';
|
|
2
|
+
import FWLog from '../log/FWLog';
|
|
3
|
+
import { FWManager } from './FWManager';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 资源数据
|
|
@@ -48,7 +48,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
48
48
|
const img = data.img;
|
|
49
49
|
const ske = data.ske;
|
|
50
50
|
const atlas = data.atlas;
|
|
51
|
-
const type = bin ?
|
|
51
|
+
const type = bin ? '.bin' : '.txt';
|
|
52
52
|
cc.assetManager.loadAny(
|
|
53
53
|
[
|
|
54
54
|
{ url: atlas, ext: type },
|
|
@@ -60,38 +60,34 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
60
60
|
asset.skeletonJson = assets[1];
|
|
61
61
|
asset.atlasText = assets[0];
|
|
62
62
|
asset.textures.push(texture);
|
|
63
|
-
asset[
|
|
64
|
-
asset[
|
|
63
|
+
asset['textureNames'] = [`${img}.png`];
|
|
64
|
+
asset['_uuid'] = ske;
|
|
65
65
|
resolve(asset);
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
67
|
);
|
|
68
|
-
}, FWSystemConfig.PromiseConfig.loadAsset).promise
|
|
68
|
+
}, FWSystemConfig.PromiseConfig.loadAsset).promise,
|
|
69
69
|
);
|
|
70
70
|
} catch (e) {
|
|
71
|
-
FWLog.error(
|
|
71
|
+
FWLog.error('从远程加载spine动画资源失败!');
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/** 加载远程资源 */
|
|
76
76
|
async loadRemote<T extends cc.Asset = cc.Asset>(
|
|
77
77
|
url?: string,
|
|
78
|
-
cb?: (asset: cc.Asset) => void
|
|
78
|
+
cb?: (asset: cc.Asset) => void,
|
|
79
79
|
): Promise<T> {
|
|
80
80
|
return await this.invoke(
|
|
81
81
|
FW.Entry.promiseMgr.execute((resolve, reject, signal) => {
|
|
82
|
-
cc.assetManager.loadRemote(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
(err, asset) => {
|
|
86
|
-
if (err || !asset) {
|
|
87
|
-
reject(err);
|
|
88
|
-
}
|
|
89
|
-
cb?.(asset as T);
|
|
90
|
-
resolve(asset as T);
|
|
82
|
+
cc.assetManager.loadRemote(url, { cacheEnabled: true, maxRetryCount: 3 }, (err, asset) => {
|
|
83
|
+
if (err || !asset) {
|
|
84
|
+
reject(err);
|
|
91
85
|
}
|
|
92
|
-
|
|
86
|
+
cb?.(asset as T);
|
|
87
|
+
resolve(asset as T);
|
|
88
|
+
});
|
|
93
89
|
}, FWSystemConfig.PromiseConfig.loadAsset).promise,
|
|
94
|
-
`loadAssets -> ${url}
|
|
90
|
+
`loadAssets -> ${url}`,
|
|
95
91
|
);
|
|
96
92
|
}
|
|
97
93
|
|
|
@@ -101,9 +97,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
101
97
|
return undefined;
|
|
102
98
|
}
|
|
103
99
|
|
|
104
|
-
const propertys = Array.isArray(assetProperty)
|
|
105
|
-
? assetProperty
|
|
106
|
-
: [assetProperty];
|
|
100
|
+
const propertys = Array.isArray(assetProperty) ? assetProperty : [assetProperty];
|
|
107
101
|
|
|
108
102
|
await Promise.all(
|
|
109
103
|
propertys.map(async (property) => {
|
|
@@ -112,19 +106,17 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
112
106
|
const path = property.path;
|
|
113
107
|
const progress = property.progress;
|
|
114
108
|
|
|
115
|
-
if (!bundleName || bundleName ===
|
|
109
|
+
if (!bundleName || bundleName === '') {
|
|
116
110
|
FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
|
|
117
111
|
return undefined;
|
|
118
112
|
}
|
|
119
113
|
|
|
120
|
-
if (!path || path ===
|
|
114
|
+
if (!path || path === '') {
|
|
121
115
|
FWLog.error(`找不到资源路径${path},请检查!`);
|
|
122
116
|
return undefined;
|
|
123
117
|
}
|
|
124
118
|
|
|
125
|
-
let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(
|
|
126
|
-
bundleName
|
|
127
|
-
);
|
|
119
|
+
let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(bundleName);
|
|
128
120
|
|
|
129
121
|
if (!bundle) {
|
|
130
122
|
FWLog.error(`加载bundle失败,请检查!`);
|
|
@@ -136,24 +128,20 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
136
128
|
bundle.preload(
|
|
137
129
|
path,
|
|
138
130
|
type,
|
|
139
|
-
(
|
|
140
|
-
finish: number,
|
|
141
|
-
total: number,
|
|
142
|
-
item: cc.AssetManager.RequestItem
|
|
143
|
-
) => {
|
|
131
|
+
(finish: number, total: number, item: cc.AssetManager.RequestItem) => {
|
|
144
132
|
progress?.(finish, total, item);
|
|
145
133
|
},
|
|
146
134
|
(err: Error, item: cc.AssetManager.RequestItem[]) => {
|
|
147
135
|
if (err || !item || item?.length == 0) {
|
|
148
|
-
reject(err ||
|
|
136
|
+
reject(err || 'preload failed!');
|
|
149
137
|
}
|
|
150
138
|
resolve(item);
|
|
151
|
-
}
|
|
139
|
+
},
|
|
152
140
|
);
|
|
153
141
|
}, FWSystemConfig.PromiseConfig.loadAsset).promise,
|
|
154
|
-
`preLoadAssets -> ${property.path}
|
|
142
|
+
`preLoadAssets -> ${property.path}`,
|
|
155
143
|
);
|
|
156
|
-
})
|
|
144
|
+
}),
|
|
157
145
|
);
|
|
158
146
|
}
|
|
159
147
|
|
|
@@ -174,19 +162,17 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
174
162
|
const progress = assetProperty.progress;
|
|
175
163
|
const autoRelease = assetProperty.autoRelease;
|
|
176
164
|
|
|
177
|
-
if (!bundleName || bundleName ===
|
|
165
|
+
if (!bundleName || bundleName === '') {
|
|
178
166
|
FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
|
|
179
167
|
return undefined;
|
|
180
168
|
}
|
|
181
169
|
|
|
182
|
-
if (!path || path ===
|
|
170
|
+
if (!path || path === '') {
|
|
183
171
|
FWLog.error(`找不到资源路径${path},请检查!`);
|
|
184
172
|
return undefined;
|
|
185
173
|
}
|
|
186
174
|
|
|
187
|
-
let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(
|
|
188
|
-
bundleName
|
|
189
|
-
);
|
|
175
|
+
let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(bundleName);
|
|
190
176
|
|
|
191
177
|
if (!bundle) {
|
|
192
178
|
FWLog.error(`加载bundle失败,请检查!`);
|
|
@@ -204,18 +190,13 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
204
190
|
|
|
205
191
|
assetData.loaded = false;
|
|
206
192
|
|
|
207
|
-
return
|
|
193
|
+
return this.invoke(
|
|
208
194
|
FW.Entry.promiseMgr.execute((resolve, reject, signal) => {
|
|
209
195
|
const self = this;
|
|
210
|
-
|
|
211
196
|
bundle.load(
|
|
212
197
|
path,
|
|
213
198
|
type,
|
|
214
|
-
(
|
|
215
|
-
finish: number,
|
|
216
|
-
total: number,
|
|
217
|
-
item: cc.AssetManager.RequestItem
|
|
218
|
-
) => {
|
|
199
|
+
(finish: number, total: number, item: cc.AssetManager.RequestItem) => {
|
|
219
200
|
progress?.(finish, total, item);
|
|
220
201
|
},
|
|
221
202
|
(err: Error, asset: cc.Asset) => {
|
|
@@ -225,7 +206,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
225
206
|
}
|
|
226
207
|
assetData.loaded = true;
|
|
227
208
|
assetData.dependentBundle = bundleName;
|
|
228
|
-
assetData.uuid = asset[
|
|
209
|
+
assetData.uuid = asset['_uuid'];
|
|
229
210
|
assetData.autoRelease = autoRelease;
|
|
230
211
|
assetData.asset = asset;
|
|
231
212
|
assetData.user = assetProperty.user;
|
|
@@ -236,10 +217,10 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
236
217
|
|
|
237
218
|
cb?.(assetData);
|
|
238
219
|
resolve(assetData);
|
|
239
|
-
}
|
|
220
|
+
},
|
|
240
221
|
);
|
|
241
222
|
}, FWSystemConfig.PromiseConfig.loadAsset).promise,
|
|
242
|
-
`loadAssets -> ${assetProperty.path}
|
|
223
|
+
`loadAssets -> ${assetProperty.path}`,
|
|
243
224
|
);
|
|
244
225
|
}
|
|
245
226
|
/**
|
|
@@ -258,19 +239,17 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
258
239
|
const cb = assetProperty.cb;
|
|
259
240
|
const autoRelease = assetProperty.autoRelease;
|
|
260
241
|
|
|
261
|
-
if (!bundleName || bundleName ===
|
|
242
|
+
if (!bundleName || bundleName === '') {
|
|
262
243
|
FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
|
|
263
244
|
return undefined;
|
|
264
245
|
}
|
|
265
246
|
|
|
266
|
-
if (!path || path ===
|
|
247
|
+
if (!path || path === '') {
|
|
267
248
|
FWLog.error(`找不到资源路径${path},请检查!`);
|
|
268
249
|
return undefined;
|
|
269
250
|
}
|
|
270
251
|
|
|
271
|
-
const bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(
|
|
272
|
-
bundleName
|
|
273
|
-
);
|
|
252
|
+
const bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(bundleName);
|
|
274
253
|
|
|
275
254
|
if (!bundle) {
|
|
276
255
|
FWLog.error(`加载bundle失败,请检查!`);
|
|
@@ -280,7 +259,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
280
259
|
return new Promise(
|
|
281
260
|
(
|
|
282
261
|
resolve: (value: FW.AssetData[] | PromiseLike<FW.AssetData[]>) => void,
|
|
283
|
-
reject: (reason?: any) => void
|
|
262
|
+
reject: (reason?: any) => void,
|
|
284
263
|
) => {
|
|
285
264
|
bundle.loadDir(path, type, (err: Error, assets: cc.Asset[]) => {
|
|
286
265
|
if (err || assets.length === 0) {
|
|
@@ -294,7 +273,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
294
273
|
const assetData = new FWAssetData();
|
|
295
274
|
assetData.loaded = true;
|
|
296
275
|
assetData.dependentBundle = bundleName;
|
|
297
|
-
assetData.uuid = asset[
|
|
276
|
+
assetData.uuid = asset['_uuid'];
|
|
298
277
|
assetData.autoRelease = autoRelease;
|
|
299
278
|
assetData.asset = asset;
|
|
300
279
|
assetData.type = type;
|
|
@@ -303,7 +282,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
303
282
|
const key = `${this.createAssetMapKey({
|
|
304
283
|
bundle: bundleName,
|
|
305
284
|
path: path,
|
|
306
|
-
})}/${asset.name}${type ? `_${type?.name}` :
|
|
285
|
+
})}/${asset.name}${type ? `_${type?.name}` : ''}`;
|
|
307
286
|
|
|
308
287
|
this.assetsMap.set(key, assetData);
|
|
309
288
|
|
|
@@ -313,7 +292,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
313
292
|
cb?.(assetDataList);
|
|
314
293
|
resolve(assetDataList);
|
|
315
294
|
});
|
|
316
|
-
}
|
|
295
|
+
},
|
|
317
296
|
);
|
|
318
297
|
}
|
|
319
298
|
|
|
@@ -330,18 +309,18 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
330
309
|
const bundleName = assetProperty.bundle || FW.Entry.bundleName;
|
|
331
310
|
const path = assetProperty.path;
|
|
332
311
|
|
|
333
|
-
if (!bundleName || bundleName ===
|
|
312
|
+
if (!bundleName || bundleName === '') {
|
|
334
313
|
FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
|
|
335
314
|
return undefined;
|
|
336
315
|
}
|
|
337
316
|
|
|
338
|
-
if (!path || path ===
|
|
317
|
+
if (!path || path === '') {
|
|
339
318
|
FWLog.error(`找不到资源路径${path},请检查!`);
|
|
340
319
|
return undefined;
|
|
341
320
|
}
|
|
342
321
|
|
|
343
322
|
if (!this.has(assetProperty)) {
|
|
344
|
-
FWLog.error(
|
|
323
|
+
FWLog.error('获取资源失败,请先加载!');
|
|
345
324
|
return undefined;
|
|
346
325
|
}
|
|
347
326
|
|
|
@@ -365,12 +344,12 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
|
|
|
365
344
|
const path = assetProperty.path;
|
|
366
345
|
const autoRelease = assetProperty.autoRelease;
|
|
367
346
|
|
|
368
|
-
if (!bundleName || bundleName ===
|
|
347
|
+
if (!bundleName || bundleName === '') {
|
|
369
348
|
FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
|
|
370
349
|
return undefined;
|
|
371
350
|
}
|
|
372
351
|
|
|
373
|
-
if (!path || path ===
|
|
352
|
+
if (!path || path === '') {
|
|
374
353
|
FWLog.error(`找不到资源路径${path},请检查!`);
|
|
375
354
|
return undefined;
|
|
376
355
|
}
|
|
@@ -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
|
/**
|