@ives_xxz/framework 1.5.11 → 1.5.13

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 CHANGED
@@ -829,6 +829,11 @@ declare namespace FW {
829
829
  * @param bundleName
830
830
  */
831
831
  hasBundle(bundleName: string): boolean;
832
+ /**
833
+ * 预加载
834
+ * @param assetProperty
835
+ */
836
+ preLoad(assetProperty: FW.AssetProperty | FW.AssetProperty[]);
832
837
  /**
833
838
  * 加载远程资源
834
839
  * @param url
@@ -1026,7 +1031,7 @@ declare namespace FW {
1026
1031
  atlas: string;
1027
1032
  bin?: boolean;
1028
1033
  }): Promise<sp.SkeletonData>;
1029
-
1034
+ preLoad(assetProperty: FW.AssetProperty | FW.AssetProperty[]);
1030
1035
  /**
1031
1036
  * 加载资源
1032
1037
  * @param asset
package/entry/FWEntry.ts CHANGED
@@ -1,25 +1,24 @@
1
- import FWUiManager from '../manager/FWUiManager';
2
- import Framework from '../Framework';
3
- import FWLog from '../log/FWLog';
4
- import FWAnimationManager from '../manager/FWAnimationManager';
5
- import FWAudioManager from '../manager/FWAudioManager';
6
- import FWComponentManager from '../manager/FWComponentManager';
7
- import FWEventManager from '../manager/FWEventManager';
8
- import FWLanguageManager from '../manager/FWLanguageManager';
9
- import { FWLayerManager } from '../manager/FWLayerManager';
10
- import FWObjectManager from '../manager/FWObjectManager';
11
- import { FWResManager } from '../manager/FWResManager';
12
- import FWSocketManager from '../manager/FWSocketManager';
13
- import { FWStateManager } from '../manager/FWStateManager';
14
- import { FWTimeManager } from '../manager/FWTimeManager';
15
- import FWScene from '../scene/FWScene';
16
- import { FWSocketAutoProcessPause } from '../expand/FWDecorator';
17
- import { FWEventDefine } from '../define/FWEventDefine';
18
- import FWTaskManager from '../manager/FWTaskManager';
19
- import FWEngineManager from '../manager/FWEngineManager';
20
- import FWHotUpdateManager from '../manager/FWHotUpdateManager';
21
- import FWPromiseManager from '../manager/FWPromiseManager';
22
- import { FWPerformanceManager } from '../manager/FWPerformanceManager';
1
+ import FWUiManager from "../manager/FWUiManager";
2
+ import Framework from "../Framework";
3
+ import FWLog from "../log/FWLog";
4
+ import FWAnimationManager from "../manager/FWAnimationManager";
5
+ import FWAudioManager from "../manager/FWAudioManager";
6
+ import FWComponentManager from "../manager/FWComponentManager";
7
+ import FWEventManager from "../manager/FWEventManager";
8
+ import FWLanguageManager from "../manager/FWLanguageManager";
9
+ import { FWLayerManager } from "../manager/FWLayerManager";
10
+ import FWObjectManager from "../manager/FWObjectManager";
11
+ import { FWResManager } from "../manager/FWResManager";
12
+ import FWSocketManager from "../manager/FWSocketManager";
13
+ import { FWStateManager } from "../manager/FWStateManager";
14
+ import { FWTimeManager } from "../manager/FWTimeManager";
15
+ import FWScene from "../scene/FWScene";
16
+ import { FWSocketAutoProcessPause } from "../expand/FWDecorator";
17
+ import FWTaskManager from "../manager/FWTaskManager";
18
+ import FWEngineManager from "../manager/FWEngineManager";
19
+ import FWHotUpdateManager from "../manager/FWHotUpdateManager";
20
+ import FWPromiseManager from "../manager/FWPromiseManager";
21
+ import { FWPerformanceManager } from "../manager/FWPerformanceManager";
23
22
 
24
23
  /**
25
24
  * 入口脚本
@@ -125,11 +124,6 @@ export default class FWEntry implements FW.Entry {
125
124
  this.hotUpdateMgr = new FWHotUpdateManager();
126
125
  this.promiseMgr = new FWPromiseManager();
127
126
  this.performanceMgr = new FWPerformanceManager();
128
- this.resMgr.initialize();
129
- this.layerMgr.initialize();
130
- this.timeMgr.initialize();
131
- this.animationMgr.initialize();
132
- this.stateMgr.initialize();
133
127
  }
134
128
 
135
129
  /**
@@ -140,6 +134,7 @@ export default class FWEntry implements FW.Entry {
140
134
  @FWSocketAutoProcessPause()
141
135
  launchScene(name: string): void {
142
136
  FW.Entry.layerMgr.clear();
137
+
143
138
  if (this.bundleAutoRelease(this.bundleName)) {
144
139
  this.releaseBundle(this.bundleName);
145
140
  }
@@ -147,12 +142,15 @@ export default class FWEntry implements FW.Entry {
147
142
  if (!this.hasSceneName(name)) {
148
143
  try {
149
144
  cc.director.loadScene(name);
145
+ this.bundleName = "";
150
146
  return;
151
147
  } catch (e) {
152
- FWLog.error('launchScene failed:', name);
148
+ FWLog.error("launchScene failed:", name);
153
149
  }
154
150
  }
151
+
155
152
  this.bundleName = name;
153
+
156
154
  cc.director.loadScene(this.getSceneName());
157
155
  }
158
156
 
@@ -206,11 +204,13 @@ export default class FWEntry implements FW.Entry {
206
204
  return this.map.get(this.bundleName)?.sceneName || undefined;
207
205
  }
208
206
 
209
- getComponent: <T>(serviceIdentifier: FW.ServiceIdentifier<T>) => T = (serviceIdentifier) =>
210
- Framework.getComponent(serviceIdentifier);
207
+ getComponent: <T>(serviceIdentifier: FW.ServiceIdentifier<T>) => T = (
208
+ serviceIdentifier
209
+ ) => Framework.getComponent(serviceIdentifier);
211
210
 
212
- getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (serviceIdentifier) =>
213
- Framework.getComponents(serviceIdentifier);
211
+ getComponents: <T>(serviceIdentifier?: FW.ServiceIdentifier<T>) => T[] = (
212
+ serviceIdentifier
213
+ ) => Framework.getComponents(serviceIdentifier);
214
214
 
215
215
  update(dt: number) {
216
216
  this.timeMgr?.onUpdate(dt);
@@ -1,6 +1,6 @@
1
- import { FWSystemConfig } from '../config/FWSystemConfig';
2
- import FWLog from '../log/FWLog';
3
- import { FWManager } from './FWManager';
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 ? '.bin' : '.txt';
51
+ const type = bin ? ".bin" : ".txt";
52
52
  cc.assetManager.loadAny(
53
53
  [
54
54
  { url: atlas, ext: type },
@@ -60,37 +60,101 @@ 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['textureNames'] = [`${img}.png`];
64
- asset['_uuid'] = ske;
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('从远程加载spine动画资源失败!');
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(url, { cacheEnabled: true, maxRetryCount: 3 }, (err, asset) => {
83
- if (err || !asset) {
84
- reject(err);
82
+ cc.assetManager.loadRemote(
83
+ url,
84
+ { cacheEnabled: true, maxRetryCount: 3 },
85
+ (err, asset) => {
86
+ if (err || !asset) {
87
+ reject(err);
88
+ }
89
+ cb?.(asset as T);
90
+ resolve(asset as T);
85
91
  }
86
- cb?.(asset as T);
87
- resolve(asset as T);
88
- });
92
+ );
89
93
  }, FWSystemConfig.PromiseConfig.loadAsset).promise,
90
- `loadAssets -> ${url}`,
94
+ `loadAssets -> ${url}`
91
95
  );
92
96
  }
93
97
 
98
+ async preLoad(assetProperty: FW.AssetProperty | FW.AssetProperty[]) {
99
+ if (!assetProperty) {
100
+ FWLog.error(`加载资源失败,请检查参数列表:${assetProperty}!`);
101
+ return undefined;
102
+ }
103
+
104
+ const propertys = Array.isArray(assetProperty)
105
+ ? assetProperty
106
+ : [assetProperty];
107
+
108
+ propertys.forEach(async (property) => {
109
+ const bundleName = property.bundle || FW.Entry.bundleName;
110
+ const type = property.type;
111
+ const path = property.path;
112
+ const progress = property.progress;
113
+
114
+ if (!bundleName || bundleName === "") {
115
+ FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
116
+ return undefined;
117
+ }
118
+
119
+ if (!path || path === "") {
120
+ FWLog.error(`找不到资源路径${path},请检查!`);
121
+ return undefined;
122
+ }
123
+
124
+ let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(
125
+ bundleName
126
+ );
127
+
128
+ if (!bundle) {
129
+ FWLog.error(`加载bundle失败,请检查!`);
130
+ return undefined;
131
+ }
132
+
133
+ return await this.invoke(
134
+ FW.Entry.promiseMgr.execute((resolve, reject, signal) => {
135
+ bundle.preload(
136
+ path,
137
+ type,
138
+ (
139
+ finish: number,
140
+ total: number,
141
+ item: cc.AssetManager.RequestItem
142
+ ) => {
143
+ progress?.(finish, total, item);
144
+ },
145
+ (err: Error, item: cc.AssetManager.RequestItem[]) => {
146
+ if (err || !item || item?.length == 0) {
147
+ reject(err || "preload failed!");
148
+ }
149
+ resolve(item);
150
+ }
151
+ );
152
+ }, FWSystemConfig.PromiseConfig.loadAsset).promise,
153
+ `preLoadAssets -> ${property.path}`
154
+ );
155
+ });
156
+ }
157
+
94
158
  /**
95
159
  * 加载资源
96
160
  * @param assetProperty
@@ -108,17 +172,19 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
108
172
  const progress = assetProperty.progress;
109
173
  const autoRelease = assetProperty.autoRelease;
110
174
 
111
- if (!bundleName || bundleName === '') {
175
+ if (!bundleName || bundleName === "") {
112
176
  FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
113
177
  return undefined;
114
178
  }
115
179
 
116
- if (!path || path === '') {
180
+ if (!path || path === "") {
117
181
  FWLog.error(`找不到资源路径${path},请检查!`);
118
182
  return undefined;
119
183
  }
120
184
 
121
- let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(bundleName);
185
+ let bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(
186
+ bundleName
187
+ );
122
188
 
123
189
  if (!bundle) {
124
190
  FWLog.error(`加载bundle失败,请检查!`);
@@ -143,7 +209,11 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
143
209
  bundle.load(
144
210
  path,
145
211
  type,
146
- (finish: number, total: number, item: cc.AssetManager.RequestItem) => {
212
+ (
213
+ finish: number,
214
+ total: number,
215
+ item: cc.AssetManager.RequestItem
216
+ ) => {
147
217
  progress?.(finish, total, item);
148
218
  },
149
219
  (err: Error, asset: cc.Asset) => {
@@ -153,7 +223,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
153
223
  }
154
224
  assetData.loaded = true;
155
225
  assetData.dependentBundle = bundleName;
156
- assetData.uuid = asset['_uuid'];
226
+ assetData.uuid = asset["_uuid"];
157
227
  assetData.autoRelease = autoRelease;
158
228
  assetData.asset = asset;
159
229
  assetData.user = assetProperty.user;
@@ -164,10 +234,10 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
164
234
 
165
235
  cb?.(assetData);
166
236
  resolve(assetData);
167
- },
237
+ }
168
238
  );
169
239
  }, FWSystemConfig.PromiseConfig.loadAsset).promise,
170
- `loadAssets -> ${assetProperty.path}`,
240
+ `loadAssets -> ${assetProperty.path}`
171
241
  );
172
242
  }
173
243
  /**
@@ -186,17 +256,19 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
186
256
  const cb = assetProperty.cb;
187
257
  const autoRelease = assetProperty.autoRelease;
188
258
 
189
- if (!bundleName || bundleName === '') {
259
+ if (!bundleName || bundleName === "") {
190
260
  FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
191
261
  return undefined;
192
262
  }
193
263
 
194
- if (!path || path === '') {
264
+ if (!path || path === "") {
195
265
  FWLog.error(`找不到资源路径${path},请检查!`);
196
266
  return undefined;
197
267
  }
198
268
 
199
- const bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(bundleName);
269
+ const bundle: cc.AssetManager.Bundle = await this.resMgr.loadBundle(
270
+ bundleName
271
+ );
200
272
 
201
273
  if (!bundle) {
202
274
  FWLog.error(`加载bundle失败,请检查!`);
@@ -206,7 +278,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
206
278
  return new Promise(
207
279
  (
208
280
  resolve: (value: FW.AssetData[] | PromiseLike<FW.AssetData[]>) => void,
209
- reject: (reason?: any) => void,
281
+ reject: (reason?: any) => void
210
282
  ) => {
211
283
  bundle.loadDir(path, type, (err: Error, assets: cc.Asset[]) => {
212
284
  if (err || assets.length === 0) {
@@ -220,7 +292,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
220
292
  const assetData = new FWAssetData();
221
293
  assetData.loaded = true;
222
294
  assetData.dependentBundle = bundleName;
223
- assetData.uuid = asset['_uuid'];
295
+ assetData.uuid = asset["_uuid"];
224
296
  assetData.autoRelease = autoRelease;
225
297
  assetData.asset = asset;
226
298
  assetData.type = type;
@@ -229,7 +301,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
229
301
  const key = `${this.createAssetMapKey({
230
302
  bundle: bundleName,
231
303
  path: path,
232
- })}/${asset.name}${type ? `_${type?.name}` : ''}`;
304
+ })}/${asset.name}${type ? `_${type?.name}` : ""}`;
233
305
 
234
306
  this.assetsMap.set(key, assetData);
235
307
 
@@ -239,7 +311,7 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
239
311
  cb?.(assetDataList);
240
312
  resolve(assetDataList);
241
313
  });
242
- },
314
+ }
243
315
  );
244
316
  }
245
317
 
@@ -256,18 +328,18 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
256
328
  const bundleName = assetProperty.bundle || FW.Entry.bundleName;
257
329
  const path = assetProperty.path;
258
330
 
259
- if (!bundleName || bundleName === '') {
331
+ if (!bundleName || bundleName === "") {
260
332
  FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
261
333
  return undefined;
262
334
  }
263
335
 
264
- if (!path || path === '') {
336
+ if (!path || path === "") {
265
337
  FWLog.error(`找不到资源路径${path},请检查!`);
266
338
  return undefined;
267
339
  }
268
340
 
269
341
  if (!this.has(assetProperty)) {
270
- FWLog.error('获取资源失败,请先加载!');
342
+ FWLog.error("获取资源失败,请先加载!");
271
343
  return undefined;
272
344
  }
273
345
 
@@ -291,12 +363,12 @@ export class FWAssetManager extends FWManager implements FW.AssetManager {
291
363
  const path = assetProperty.path;
292
364
  const autoRelease = assetProperty.autoRelease;
293
365
 
294
- if (!bundleName || bundleName === '') {
366
+ if (!bundleName || bundleName === "") {
295
367
  FWLog.error(`找不到bundle${bundleName},或者bundle未加载!`);
296
368
  return undefined;
297
369
  }
298
370
 
299
- if (!path || path === '') {
371
+ if (!path || path === "") {
300
372
  FWLog.error(`找不到资源路径${path},请检查!`);
301
373
  return undefined;
302
374
  }
@@ -1,6 +1,6 @@
1
- import { FWManager } from './FWManager';
2
- import FWLog from '../log/FWLog';
3
- import { FWSystemDefine } from '../define/FWSystemDefine';
1
+ import { FWManager } from "./FWManager";
2
+ import FWLog from "../log/FWLog";
3
+ import { FWSystemDefine } from "../define/FWSystemDefine";
4
4
 
5
5
  class FWAudioData {
6
6
  clip: cc.AudioClip;
@@ -11,10 +11,17 @@ class FWAudioData {
11
11
  }
12
12
 
13
13
  class FWAudioPoolItem {
14
- constructor(public audioId: number, public startTime: number, public tag?: string) {}
14
+ constructor(
15
+ public audioId: number,
16
+ public startTime: number,
17
+ public tag?: string
18
+ ) {}
15
19
  }
16
20
 
17
- export default class FWAudioManager extends FWManager implements FW.AudioManager {
21
+ export default class FWAudioManager
22
+ extends FWManager
23
+ implements FW.AudioManager
24
+ {
18
25
  musicVolume: number = 1;
19
26
  effectsVolume: number = 1;
20
27
  soundVolume: number = 1;
@@ -31,13 +38,21 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
31
38
  * 播放背景音乐
32
39
  */
33
40
  async playMusic(path: string, volume?: number, loop?: boolean): Promise<void>;
34
- async playMusic(music: cc.AudioClip, volume?: number, loop?: boolean): Promise<void>;
35
- async playMusic(assetProperty: FW.AssetProperty, volume?: number, loop?: boolean): Promise<void>;
41
+ async playMusic(
42
+ music: cc.AudioClip,
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>;
36
51
  async playMusic(): Promise<void> {
37
52
  try {
38
53
  const audioData = await this.processAudioArguments(
39
54
  arguments,
40
- FWSystemDefine.FWAudioType.MUSIC,
55
+ FWSystemDefine.FWAudioType.MUSIC
41
56
  );
42
57
  if (!audioData.clip) return;
43
58
 
@@ -50,7 +65,7 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
50
65
 
51
66
  FWLog.debug(`播放背景音乐: ${this.getAudioName(audioData.clip)}`);
52
67
  } catch (e) {
53
- FWLog.error('播放音乐失败:', e);
68
+ FWLog.error("播放音乐失败:", e);
54
69
  }
55
70
  }
56
71
 
@@ -80,39 +95,40 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
80
95
  cb?: (id: number) => void,
81
96
  volume?: number,
82
97
  loop?: boolean,
83
- tag?: string,
98
+ tag?: string
84
99
  ): Promise<number>;
85
100
  async play(
86
101
  audio: cc.AudioClip,
87
102
  cb?: (id: number) => void,
88
103
  volume?: number,
89
104
  loop?: boolean,
90
- tag?: string,
105
+ tag?: string
91
106
  ): Promise<number>;
92
107
  async play(
93
108
  assetProperty: FW.AssetProperty,
94
109
  cb?: (id: number) => void,
95
110
  volume?: number,
96
111
  loop?: boolean,
97
- tag?: string,
112
+ tag?: string
98
113
  ): Promise<number>;
99
114
  async play(): Promise<number> {
100
115
  try {
101
116
  if (this.audioPool.size >= this.maxConcurrentAudio) {
102
117
  this.clearFinishedAudio();
103
118
  if (this.audioPool.size >= this.maxConcurrentAudio) {
104
- FWLog.warn('音频池已满,无法播放新音频');
119
+ FWLog.warn("音频池已满,无法播放新音频");
105
120
  return -1;
106
121
  }
107
122
  }
108
123
 
109
124
  const audioData = await this.processAudioArguments(
110
125
  arguments,
111
- FWSystemDefine.FWAudioType.SOUND,
126
+ FWSystemDefine.FWAudioType.SOUND
112
127
  );
113
128
  if (!audioData.clip) return -1;
114
129
 
115
- const volume = (audioData.volume ?? this.soundVolume) * this.effectsVolume;
130
+ const volume =
131
+ (audioData.volume ?? this.soundVolume) * this.effectsVolume;
116
132
  const loop = audioData.loop ?? false;
117
133
  const tag = audioData.tag;
118
134
 
@@ -127,7 +143,7 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
127
143
 
128
144
  return id;
129
145
  } catch (e) {
130
- FWLog.error('播放音效失败:', e);
146
+ FWLog.error("播放音效失败:", e);
131
147
  return -1;
132
148
  }
133
149
  }
@@ -145,24 +161,24 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
145
161
 
146
162
  pauseAll(): void {
147
163
  cc.audioEngine.pauseAll();
148
- FWLog.debug('暂停所有音效');
164
+ FWLog.debug("暂停所有音效");
149
165
  }
150
166
 
151
167
  resumeAll(): void {
152
168
  cc.audioEngine.resumeAll();
153
- FWLog.debug('恢复所有音效');
169
+ FWLog.debug("恢复所有音效");
154
170
  }
155
171
 
156
172
  stopAll(): void {
157
173
  cc.audioEngine.stopAll();
158
174
  this.audioPool.clear();
159
- FWLog.debug('停止所有音效');
175
+ FWLog.debug("停止所有音效");
160
176
  }
161
177
 
162
178
  /** 设置播放音效是否静音 */
163
179
  setSoundMute(mute: boolean): void {
164
180
  this.soundVolume = mute ? 0 : 1;
165
- FWLog.debug(`音效${mute ? '静音' : '取消静音'}`);
181
+ FWLog.debug(`音效${mute ? "静音" : "取消静音"}`);
166
182
  }
167
183
 
168
184
  /**
@@ -172,7 +188,7 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
172
188
  try {
173
189
  let clip: cc.AudioClip;
174
190
 
175
- if (typeof assetProperty === 'string') {
191
+ if (typeof assetProperty === "string") {
176
192
  clip = await FW.Entry.resMgr.loadAsset<cc.AudioClip>({
177
193
  path: assetProperty,
178
194
  bundle: FW.Entry.bundleName,
@@ -233,7 +249,7 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
233
249
  */
234
250
  private async processAudioArguments(
235
251
  args: IArguments,
236
- type: FWSystemDefine.FWAudioType,
252
+ type: FWSystemDefine.FWAudioType
237
253
  ): Promise<FWAudioData> {
238
254
  const audioData = new FWAudioData();
239
255
  const argsArray = Array.from(args);
@@ -262,7 +278,7 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
262
278
  * 标准化资源属性
263
279
  */
264
280
  private normalizeAssetProperty(input: any): FW.AssetProperty {
265
- if (typeof input === 'string') {
281
+ if (typeof input === "string") {
266
282
  return {
267
283
  path: input,
268
284
  bundle: FW.Entry.bundleName,
@@ -274,7 +290,9 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
274
290
  /**
275
291
  * 加载音频片段
276
292
  */
277
- private async loadAudioClip(assetProperty: FW.AssetProperty): Promise<cc.AudioClip> {
293
+ private async loadAudioClip(
294
+ assetProperty: FW.AssetProperty
295
+ ): Promise<cc.AudioClip> {
278
296
  try {
279
297
  return await FW.Entry.resMgr.loadAsset<cc.AudioClip>(assetProperty);
280
298
  } catch (e) {
@@ -286,17 +304,19 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
286
304
  * 生成缓存键
287
305
  */
288
306
  private getCacheKey(assetProperty: FW.AssetProperty): string {
289
- if (typeof assetProperty === 'string') {
307
+ if (typeof assetProperty === "string") {
290
308
  return `${FW.Entry.bundleName}_${assetProperty}`;
291
309
  }
292
- return `${assetProperty.bundle || FW.Entry.bundleName}_${assetProperty.path}`;
310
+ return `${assetProperty.bundle || FW.Entry.bundleName}_${
311
+ assetProperty.path
312
+ }`;
293
313
  }
294
314
 
295
315
  /**
296
316
  * 获取音频名称
297
317
  */
298
318
  private getAudioName(clip: cc.AudioClip): string {
299
- return clip.name || '未知音频';
319
+ return clip.name || "未知音频";
300
320
  }
301
321
 
302
322
  /**
@@ -324,7 +344,7 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
324
344
  this.clearFinishedAudio,
325
345
  this.cleanupInterval,
326
346
  cc.macro.REPEAT_FOREVER,
327
- this,
347
+ this
328
348
  );
329
349
  }
330
350
 
@@ -1,6 +1,6 @@
1
- import { FWAssetManager } from './FWAssetManager';
2
- import { FWBundleManager } from './FWBundleManager';
3
- import { FWManager } from './FWManager';
1
+ import { FWAssetManager } from "./FWAssetManager";
2
+ import { FWBundleManager } from "./FWBundleManager";
3
+ import { FWManager } from "./FWManager";
4
4
 
5
5
  export class FWResManager extends FWManager implements FW.ResManager {
6
6
  bundleMgr: FW.BundleManager;
@@ -35,7 +35,10 @@ export class FWResManager extends FWManager implements FW.ResManager {
35
35
  return await this.assetMgr.loadSpineDataFromRemote(data);
36
36
  }
37
37
 
38
- async loadRemote<T extends cc.Asset = cc.Asset>(url: string, cb: (asset: any) => T): Promise<T> {
38
+ async loadRemote<T extends cc.Asset = cc.Asset>(
39
+ url: string,
40
+ cb: (asset: any) => T
41
+ ): Promise<T> {
39
42
  const asset = await this.assetMgr.loadRemote(url);
40
43
  if (asset instanceof cc.Texture2D) {
41
44
  return new cc.SpriteFrame(asset) as unknown as T;
@@ -82,11 +85,17 @@ export class FWResManager extends FWManager implements FW.ResManager {
82
85
  * @param assetProperty
83
86
  * @returns
84
87
  */
85
- async loadAsset<T extends cc.Asset>(assetProperty: FW.AssetProperty): Promise<T> {
88
+ async loadAsset<T extends cc.Asset>(
89
+ assetProperty: FW.AssetProperty
90
+ ): Promise<T> {
86
91
  const res = await this.assetMgr.load(assetProperty);
87
92
  return this.process<T>(res).asset as T;
88
93
  }
89
94
 
95
+ async preLoad(assetProperty: FW.AssetProperty | FW.AssetProperty[]) {
96
+ return this.assetMgr.preLoad(assetProperty);
97
+ }
98
+
90
99
  /**
91
100
  * 加载文件夹
92
101
  */
@@ -1,5 +1,5 @@
1
- import FWLog from '../log/FWLog';
2
- import { FWManager } from './FWManager';
1
+ import FWLog from "../log/FWLog";
2
+ import { FWManager } from "./FWManager";
3
3
 
4
4
  class FWTimer implements FW.Timer {
5
5
  constructor() {
@@ -70,13 +70,13 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
70
70
  time?: number,
71
71
  repeat?: number,
72
72
  target?: FW.TargetType,
73
- tag?: string,
73
+ tag?: string
74
74
  ): FW.TimerSchedule {
75
75
  const timer = new FWTimer();
76
76
 
77
77
  timer.internal = time || 0;
78
78
  timer.repeat = repeat || 0;
79
- timer.tag = tag || '';
79
+ timer.tag = tag || "";
80
80
  timer.target = target || FW.Entry.scene;
81
81
  timer.cb = cb;
82
82
  timer.id = this.uniqueId++;
@@ -134,14 +134,12 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
134
134
  let tag: string;
135
135
  let target: any;
136
136
 
137
- const config: any = {};
138
-
139
137
  for (const arg of arguments) {
140
- if (typeof arg === 'function') {
138
+ if (typeof arg === "function") {
141
139
  cb = arg;
142
- } else if (typeof arg === 'number') {
140
+ } else if (typeof arg === "number") {
143
141
  time = arg;
144
- } else if (typeof arg === 'string') {
142
+ } else if (typeof arg === "string") {
145
143
  tag = arg;
146
144
  } else if (arg) {
147
145
  target = arg;
@@ -195,9 +193,9 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
195
193
  const args = arguments;
196
194
  if (!args || args?.length == 0) return;
197
195
 
198
- if (typeof args[0] == 'string') {
196
+ if (typeof args[0] == "string") {
199
197
  this.removeTimerFromTag(args[0]);
200
- } else if (typeof args[0] == 'number') {
198
+ } else if (typeof args[0] == "number") {
201
199
  this.removeTimerFromId(args[0]);
202
200
  } else {
203
201
  this.removeTimerFromTarget(args[0]);
@@ -226,9 +224,9 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
226
224
  pauseSchedule() {
227
225
  const args = arguments;
228
226
  if (!args || args?.length == 0) return;
229
- if (typeof args[0] == 'string') {
227
+ if (typeof args[0] == "string") {
230
228
  this.pauseTimerFromTag(args[0], true);
231
- } else if (typeof args[0] == 'number') {
229
+ } else if (typeof args[0] == "number") {
232
230
  this.pauseTimerFromId(args[0], true);
233
231
  } else {
234
232
  this.pauseTimerFromTarget(args[0], true);
@@ -256,9 +254,9 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
256
254
  resumeSchedule() {
257
255
  const args = arguments;
258
256
  if (!args || args?.length == 0) return;
259
- if (typeof args[0] == 'string') {
257
+ if (typeof args[0] == "string") {
260
258
  this.pauseTimerFromTag(args[0], false);
261
- } else if (typeof args[0] == 'number') {
259
+ } else if (typeof args[0] == "number") {
262
260
  this.pauseTimerFromId(args[0], false);
263
261
  } else {
264
262
  this.pauseTimerFromTarget(args[0], false);
@@ -299,7 +297,7 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
299
297
  var target: FW.TargetType;
300
298
  var tag: string;
301
299
  if (args.length == 2) {
302
- if (typeof args[1] == 'string') {
300
+ if (typeof args[1] == "string") {
303
301
  tag = args[1];
304
302
  } else {
305
303
  target = args[1];
@@ -313,7 +311,7 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
313
311
  timer.cb = cb;
314
312
  timer.executeTime = 0;
315
313
  timer.internal = 0;
316
- timer.tag = tag || '';
314
+ timer.tag = tag || "";
317
315
  timer.target = target || undefined;
318
316
  timer.pause = false;
319
317
  timer.repeat = cc.macro.REPEAT_FOREVER;
@@ -332,7 +330,7 @@ export class FWTimeManager extends FWManager implements FW.TimeManager {
332
330
 
333
331
  if (v.executeTime > v.internal) {
334
332
  v.executeTime = 0;
335
- v.cb?.(dt);
333
+ v.cb?.call(v.target, dt);
336
334
  v.resolve?.();
337
335
 
338
336
  if (v.repeat > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [