@ives_xxz/framework 2.3.5 → 2.3.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.
@@ -1,8 +1,8 @@
1
- import { FWSystemConfig } from "../config/FWSystemConfig";
2
- import { FWLodash } from "../utils/FWLodash";
3
- import { FWAssetManager } from "./FWAssetManager";
4
- import { FWBundleManager } from "./FWBundleManager";
5
- import { FWManager } from "./FWManager";
1
+ import { FWSystemConfig } from '../config/FWSystemConfig';
2
+ import { FWLodash } from '../utils/FWLodash';
3
+ import { FWAssetManager } from './FWAssetManager';
4
+ import { FWBundleManager } from './FWBundleManager';
5
+ import { FWManager } from './FWManager';
6
6
 
7
7
  export class FWResManager extends FWManager implements FW.ResManager {
8
8
  private bundleMgr: FW.BundleManager;
@@ -22,65 +22,60 @@ export class FWResManager extends FWManager implements FW.ResManager {
22
22
  * @returns
23
23
  */
24
24
  async loadBundle(bundleName: string): Promise<cc.AssetManager.Bundle> {
25
- return await this.invoke<cc.AssetManager.Bundle>(
26
- FW.Entry.promiseMgr.execute(async (resolve, reject, signal) => {
25
+ return new Promise(async (resolve, reject) => {
26
+ try {
27
27
  const depends = FWLodash.cloneDeep(FW.Entry.getDepend(bundleName));
28
- try {
29
- if (depends && depends.length > 0) {
30
- for (const depend of depends) {
31
- if (depend === undefined) continue;
28
+ if (depends && depends.length > 0) {
29
+ for (const depend of depends) {
30
+ if (depend === undefined) continue;
32
31
 
33
- if (this.bundleMgr.has(depend)) continue;
32
+ if (this.bundleMgr.has(depend)) continue;
34
33
 
35
- await this.loadBundle(depend);
34
+ await this.loadBundle(depend);
36
35
 
37
- const config = FW.Entry.getComponent<FW.AssetConfig>(
38
- `${depend}${FW.SystemDefine.FWBindTag.CONFIG}`,
39
- );
40
- if (!config) continue;
41
- const preLoad = config.preLoad;
42
- const keys = Object.keys(preLoad);
36
+ const config = FW.Entry.getComponent<FW.AssetConfig>(
37
+ `${depend}${FW.SystemDefine.FWBindTag.CONFIG}`,
38
+ );
39
+ if (!config) continue;
40
+ const preLoad = config.preLoad;
41
+ const keys = Object.keys(preLoad);
43
42
 
44
- if (keys.length > 0) {
45
- const preloadRecursive = async (
46
- obj: FW.LoadConfig | FW.AssetProperty,
47
- ) => {
48
- for (const key of Object.keys(obj)) {
49
- const value: any = (obj as any)[key];
43
+ if (keys.length > 0) {
44
+ const preloadRecursive = async (obj: FW.LoadConfig | FW.AssetProperty) => {
45
+ for (const key of Object.keys(obj)) {
46
+ const value: any = (obj as any)[key];
50
47
 
51
- if (value && typeof value.path === "string") {
52
- const path: string = value.path;
53
- const type: string = value.type;
54
- const d: string = value.bundle || depend;
55
- const priorityLoaded = value.priorityLoaded || false;
48
+ if (value && typeof value.path === 'string') {
49
+ const path: string = value.path;
50
+ const type: string = value.type;
51
+ const d: string = value.bundle || depend;
52
+ const priorityLoaded = value.priorityLoaded || false;
56
53
 
57
- if (path && priorityLoaded) {
58
- await this.assetMgr.load({
59
- path,
60
- bundle: d,
61
- type,
62
- });
63
- }
64
- } else if (value && typeof value === "object") {
65
- await preloadRecursive(value);
54
+ if (path && priorityLoaded) {
55
+ await this.assetMgr.load({
56
+ path,
57
+ bundle: d,
58
+ type,
59
+ });
66
60
  }
61
+ } else if (value && typeof value === 'object') {
62
+ await preloadRecursive(value);
67
63
  }
68
- };
69
- await preloadRecursive(config.preLoad);
70
- }
64
+ }
65
+ };
66
+ await preloadRecursive(config.preLoad);
71
67
  }
72
68
  }
69
+ }
73
70
 
74
- const bundle = await this.bundleMgr.load(bundleName);
71
+ const bundle = await this.bundleMgr.load(bundleName);
75
72
 
76
- resolve(bundle);
77
- } catch (e) {
78
- this.rejectHandlerListener?.loadBundleHandler?.(e, bundleName);
79
- reject(e);
80
- }
81
- }, FWSystemConfig.PromiseConfig.loadBundle).promise,
82
- `loadBundle -> ${bundleName}`,
83
- );
73
+ resolve(bundle);
74
+ } catch (e) {
75
+ this.rejectHandlerListener?.loadBundleHandler?.(e, bundleName);
76
+ reject(e);
77
+ }
78
+ });
84
79
  }
85
80
  /**
86
81
  * 从远程加载spine动画
@@ -96,10 +91,7 @@ export class FWResManager extends FWManager implements FW.ResManager {
96
91
  return await this.assetMgr.loadSpineDataFromRemote(data);
97
92
  }
98
93
 
99
- async loadRemote<T extends cc.Asset = cc.Asset>(
100
- url: string,
101
- texture?: boolean,
102
- ): Promise<T> {
94
+ async loadRemote<T extends cc.Asset = cc.Asset>(url: string, texture?: boolean): Promise<T> {
103
95
  try {
104
96
  const asset = await this.assetMgr.loadRemote(url);
105
97
  if (texture) {
@@ -191,10 +183,7 @@ export class FWResManager extends FWManager implements FW.ResManager {
191
183
  * @param bundleName
192
184
  * @returns
193
185
  */
194
- getAssetData<T extends cc.Asset>(
195
- assetProperty: FW.AssetProperty,
196
- texture?: boolean,
197
- ) {
186
+ getAssetData<T extends cc.Asset>(assetProperty: FW.AssetProperty, texture?: boolean) {
198
187
  const res = this.assetMgr.get(assetProperty);
199
188
  if (texture) {
200
189
  return res;
@@ -206,10 +195,7 @@ export class FWResManager extends FWManager implements FW.ResManager {
206
195
  * @param assetProperty
207
196
  * @returns
208
197
  */
209
- getAsset<T extends cc.Asset>(
210
- assetProperty: FW.AssetProperty,
211
- texture?: boolean,
212
- ): T {
198
+ getAsset<T extends cc.Asset>(assetProperty: FW.AssetProperty, texture?: boolean): T {
213
199
  const res = this.assetMgr.get(assetProperty);
214
200
  if (texture) {
215
201
  return res.asset as T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": ["123456"],