@ives_xxz/framework 2.1.14 → 2.1.16

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.
@@ -47,6 +47,7 @@ export function initializeFramework() {
47
47
  FW.Registry = require('./registry/FWRegistry').FWRegistry;
48
48
  FW.Framework = new (require('./Framework').Framework)();
49
49
  FW.FrameworkBase = require('./FrameworkBase').FrameworkBase;
50
+ FW.Object = require('./utils/FWObject').FWObject;
50
51
  FW.Entry = new (require('./entry/FWEntry').FWEntry)();
51
52
  FW.Scene = require('./scene/FWScene').FWScene;
52
53
  FW.Logic = require('./logic/FWLogic').FWLogic;
@@ -1,5 +1,4 @@
1
1
  import FWVirtualViewComponent from '../component/FWVirtualViewComponent';
2
- import FWObject from '../utils/FWObject';
3
2
 
4
3
  const { ccclass, property, disallowMultiple, menu, executionOrder } = cc._decorator;
5
4
 
@@ -13,7 +12,7 @@ enum SelectedType {
13
12
  @disallowMultiple()
14
13
  @menu('CustomComponent/FWVirtualListItem')
15
14
  @executionOrder(-5001) //先于List
16
- export default class FWVirtualListItem extends FWObject {
15
+ export default class FWVirtualListItem extends FW.Object {
17
16
  onGet(args: any) {}
18
17
  onPut() {}
19
18
  onInit() {}
@@ -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;
@@ -21,7 +21,6 @@ export class FWResManager extends FWManager implements FW.ResManager {
21
21
  async loadBundle(bundleName: string): Promise<cc.AssetManager.Bundle> {
22
22
  return await this.invoke<cc.AssetManager.Bundle>(
23
23
  FW.Entry.promiseMgr.execute(async (resolve, reject, signal) => {
24
- const bundle = await this.bundleMgr.load(bundleName);
25
24
  const depends = FWLodash.cloneDeep(FW.Entry.getDepend(bundleName));
26
25
  try {
27
26
  if (depends && depends.length > 0) {
@@ -31,7 +30,7 @@ export class FWResManager extends FWManager implements FW.ResManager {
31
30
  await this.loadBundle(depend);
32
31
 
33
32
  const config = FW.Entry.getComponent<FW.AssetConfig>(
34
- `${depend}${FW.SystemDefine.FWBindTag.CONFIG}`
33
+ `${depend}${FW.SystemDefine.FWBindTag.CONFIG}`,
35
34
  );
36
35
  if (!config) continue;
37
36
  const preLoad = config.preLoad;
@@ -62,12 +61,15 @@ export class FWResManager extends FWManager implements FW.ResManager {
62
61
  }
63
62
  }
64
63
  }
64
+
65
+ const bundle = await this.bundleMgr.load(bundleName);
66
+
65
67
  resolve(bundle);
66
68
  } catch (e) {
67
69
  reject(e);
68
70
  }
69
71
  }, FWSystemConfig.PromiseConfig.loadBundle).promise,
70
- `loadBundle -> ${bundleName}`
72
+ `loadBundle -> ${bundleName}`,
71
73
  );
72
74
  }
73
75
  /**
@@ -84,10 +86,7 @@ export class FWResManager extends FWManager implements FW.ResManager {
84
86
  return await this.assetMgr.loadSpineDataFromRemote(data);
85
87
  }
86
88
 
87
- async loadRemote<T extends cc.Asset = cc.Asset>(
88
- url: string,
89
- cb: (asset: any) => T
90
- ): Promise<T> {
89
+ async loadRemote<T extends cc.Asset = cc.Asset>(url: string, cb: (asset: any) => T): Promise<T> {
91
90
  const asset = await this.assetMgr.loadRemote(url);
92
91
  if (asset instanceof cc.Texture2D) {
93
92
  return new cc.SpriteFrame(asset) as unknown as T;
@@ -134,9 +133,7 @@ export class FWResManager extends FWManager implements FW.ResManager {
134
133
  * @param assetProperty
135
134
  * @returns
136
135
  */
137
- async loadAsset<T extends cc.Asset>(
138
- assetProperty: FW.AssetProperty
139
- ): Promise<T> {
136
+ async loadAsset<T extends cc.Asset>(assetProperty: FW.AssetProperty): Promise<T> {
140
137
  const res = await this.assetMgr.load(assetProperty);
141
138
  return this.process<T>(res).asset as T;
142
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "2.1.14",
3
+ "version": "2.1.16",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": ["123456"],
@@ -40,16 +40,7 @@ export abstract class FWRegistry implements FW.Registry {
40
40
  readonly handle?: FW.Newable<FW.Handle>;
41
41
 
42
42
  register(): void {
43
- this.bundleEnabled(true);
44
- }
45
- unRegister(): void {
46
- this.bundleEnabled(false);
47
- }
48
-
49
- bundleEnabled(enable?: boolean) {
50
- const frameworkInvoke = enable ? FW.Framework.register : FW.Framework.unRegister;
51
- const entryInvoke = enable ? FW.Entry.register : FW.Entry.unRegister;
52
- frameworkInvoke.bind(FW.Framework)({
43
+ FW.Framework.register.bind(FW.Framework)({
53
44
  bundleName: this.bundleName,
54
45
  logic: this.logic,
55
46
  data: this.data,
@@ -57,11 +48,15 @@ export abstract class FWRegistry implements FW.Registry {
57
48
  sender: this.sender,
58
49
  handle: this.handle,
59
50
  });
60
- entryInvoke.bind(FW.Entry)({
51
+ }
52
+ unRegister(): void {
53
+ FW.Framework.unRegister.bind(FW.Framework)({
61
54
  bundleName: this.bundleName,
62
- sceneName: this.sceneName,
63
- autoRelease: this.autoRelease,
64
- depend: this.depend,
55
+ logic: this.logic,
56
+ data: this.data,
57
+ config: this.config,
58
+ sender: this.sender,
59
+ handle: this.handle,
65
60
  });
66
61
  }
67
62
  }
package/types/FW.d.ts CHANGED
@@ -266,32 +266,32 @@ declare namespace FW {
266
266
 
267
267
  type ObjectManager = {
268
268
  /** 创建一个对象池 */
269
- createObjectPool<T extends FWObject = FWObject>(
269
+ createObjectPool<T extends FW.Object = FWObject>(
270
270
  node: cc.Node,
271
271
  parent: cc.Node,
272
272
  tag?: string,
273
273
  ): Promise<ObjectPool<T>>;
274
- createObjectPool<T extends FWObject = FWObject>(
274
+ createObjectPool<T extends FW.Object = FWObject>(
275
275
  prefab: cc.Prefab,
276
276
  parent: cc.Node,
277
277
  tag?: string,
278
278
  ): Promise<ObjectPool<T>>;
279
- createObjectPool<T extends FWObject = FWObject>(
279
+ createObjectPool<T extends FW.Object = FWObject>(
280
280
  assetProperty: FW.AssetProperty,
281
281
  parent: cc.Node,
282
282
  tag?: string,
283
283
  ): Promise<ObjectPool<T>>;
284
- createObjectPool<T extends FWObject = FWObject>(
284
+ createObjectPool<T extends FW.Object = FWObject>(
285
285
  node: cc.Node,
286
286
  parent: cc.Node,
287
287
  type?: number,
288
288
  ): Promise<ObjectPool<T>>;
289
- createObjectPool<T extends FWObject = FWObject>(
289
+ createObjectPool<T extends FW.Object = FWObject>(
290
290
  prefab: cc.Prefab,
291
291
  parent: cc.Node,
292
292
  type?: number,
293
293
  ): Promise<ObjectPool<T>>;
294
- createObjectPool<T extends FWObject = FWObject>(
294
+ createObjectPool<T extends FW.Object = FWObject>(
295
295
  assetProperty: FW.AssetProperty,
296
296
  parent: cc.Node,
297
297
  type?: number,
@@ -1975,19 +1975,6 @@ declare namespace FW {
1975
1975
  getAllReports(): Map<string, FW.PerformanceReport>;
1976
1976
  };
1977
1977
 
1978
- type Object = {
1979
- /** 是否已经初始化 */
1980
- initialize: boolean;
1981
- /** 对象唯一id */
1982
- uniqueId: number;
1983
- /** 对象是否启用 */
1984
- enable: boolean;
1985
- onGet(...args: any);
1986
- onPut();
1987
- onInit();
1988
- onDestroy();
1989
- };
1990
-
1991
1978
  type ObjectProperty<T extends Object = Object> = {
1992
1979
  /** 对象节点 */
1993
1980
  node?: cc.Node;
@@ -2792,18 +2779,6 @@ declare namespace FW {
2792
2779
  * bundle名字
2793
2780
  */
2794
2781
  abstract readonly bundleName: string;
2795
- /**
2796
- * 是否自动释放
2797
- */
2798
- readonly autoRelease?: boolean;
2799
- /**
2800
- * 场景名字
2801
- */
2802
- readonly sceneName?: string;
2803
- /**
2804
- * 依赖
2805
- */
2806
- readonly depend?: string[];
2807
2782
  /**
2808
2783
  * 逻辑
2809
2784
  */
@@ -2833,10 +2808,6 @@ declare namespace FW {
2833
2808
  * 卸载
2834
2809
  */
2835
2810
  unRegister(): void;
2836
- /**
2837
- * 启用bundle
2838
- */
2839
- bundleEnabled(enable?: boolean);
2840
2811
  }
2841
2812
  }
2842
2813
 
@@ -2968,3 +2939,18 @@ declare namespace FW {
2968
2939
  public static updateMockResponses(mockResponses: {});
2969
2940
  }
2970
2941
  }
2942
+
2943
+ declare namespace FW {
2944
+ export abstract class Object extends cc.Component {
2945
+ /** 是否已经初始化 */
2946
+ initialize: boolean;
2947
+ /** 对象唯一id */
2948
+ uniqueId: number;
2949
+ /** 对象是否启用 */
2950
+ enable: boolean;
2951
+ onGet(...args: any);
2952
+ onPut();
2953
+ onInit();
2954
+ onDestroy();
2955
+ }
2956
+ }
package/utils/FWObject.ts CHANGED
@@ -1,4 +1,4 @@
1
- export default abstract class FWObject extends cc.Component implements FW.Object {
1
+ export abstract class FWObject extends cc.Component {
2
2
  /** 是否已经初始化 */
3
3
  public initialize: boolean;
4
4
  /** 对象唯一id */
@@ -18,5 +18,10 @@ export default abstract class FWObject extends cc.Component implements FW.Object
18
18
  abstract onGet(args: any);
19
19
  abstract onPut();
20
20
  abstract onInit();
21
- abstract onDestroy();
21
+ onDestroy() {
22
+ FW.Entry.timeMgr?.unSchedule(this);
23
+ FW.Entry.evtMgr?.targetOff(this);
24
+ this?.unscheduleAllCallbacks();
25
+ this?.node?.stopAllActions();
26
+ }
22
27
  }