@ives_xxz/framework 1.1.8 → 1.2.0

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
@@ -843,7 +843,7 @@ declare namespace FW {
843
843
  };
844
844
 
845
845
  type HotUpdateManager = {
846
- setListener(listener: HotUpdateListener): void;
846
+ setListener(listener: HotUpdateListener): HotUpdateManager;
847
847
  update(localManifest: cc.Asset): void;
848
848
  };
849
849
 
@@ -1470,7 +1470,7 @@ declare namespace FW {
1470
1470
  /**
1471
1471
  * 状态构造类
1472
1472
  */
1473
- stateConstructor: { new(): T };
1473
+ stateConstructor: { new (): T };
1474
1474
  };
1475
1475
 
1476
1476
  type AudioManager = {
@@ -1795,12 +1795,12 @@ declare namespace FW {
1795
1795
  * 任务开始
1796
1796
  * @param generator
1797
1797
  */
1798
- start(generator: TaskFunction): Promise<Task>;
1798
+ start(generator: TaskFunction): Task;
1799
1799
  /**
1800
1800
  * 添加任务
1801
1801
  * @param generator
1802
1802
  */
1803
- add(generator: TaskFunction): Promise<Task>;
1803
+ add(generator: TaskFunction): Task;
1804
1804
  /**
1805
1805
  * 任务暂停
1806
1806
  */
@@ -1,14 +1,6 @@
1
1
  import FWVirtualViewComponent from '../component/FWVirtualViewComponent';
2
2
  import FWObject from '../utils/FWObject';
3
3
 
4
- /******************************************
5
- * @author kL <klk0@qq.com>
6
- * @date 2019/6/6
7
- * @doc 列表Item组件.
8
- * 说明:
9
- * 1、此组件须配合List组件使用。(配套的配套的..)
10
- * @end
11
- ******************************************/
12
4
  const { ccclass, property, disallowMultiple, menu, executionOrder } = cc._decorator;
13
5
 
14
6
  enum SelectedType {
@@ -9,7 +9,7 @@ const { ccclass, property, executeInEditMode, menu, requireComponent } = cc._dec
9
9
  @executeInEditMode
10
10
  export default class FWLanguageLabelLocalize extends FWLanguage {
11
11
  @property({
12
- type: FWLodash.CCEnum(['请选择语言包']),
12
+ type: FWLodash.CCEnum(['请选择语言']),
13
13
  displayName: 'bundle',
14
14
  visible: true,
15
15
  })
@@ -76,8 +76,8 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
76
76
  );
77
77
  if (!data) return;
78
78
  const clip = data.clip;
79
- const volume = data.volume === undefined ? this.soundVolume : arguments[1];
80
- const loop = data.loop === undefined ? false : arguments[2];
79
+ const volume = data.volume === undefined ? this.soundVolume : data.volume;
80
+ const loop = data.loop === undefined ? false : data.loop;
81
81
  const id = cc.audioEngine.play(clip, loop, volume);
82
82
  cc.audioEngine.setFinishCallback(id, () => {
83
83
  data.cb?.(id);
@@ -11,11 +11,12 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
11
11
  private localManifest: cc.Asset;
12
12
  private isRetry: boolean;
13
13
  private currentVersion: string;
14
- private newVersion: string
14
+ private newVersion: string;
15
15
 
16
- setListener(listener: FW.HotUpdateListener): void {
16
+ setListener(listener: FW.HotUpdateListener): FW.HotUpdateManager {
17
17
  this.listener = listener;
18
18
  FWLog.debug('热更新监听设置');
19
+ return this;
19
20
  }
20
21
 
21
22
  public update(localManifest: cc.Asset) {
@@ -96,7 +97,6 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
96
97
  }
97
98
  }
98
99
 
99
-
100
100
  this.assetMgr.setEventCallback(this.checkEventHandle.bind(this));
101
101
  this.assetMgr.checkUpdate();
102
102
  this.isUpdate = true;
@@ -148,7 +148,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
148
148
  this.listener.checkHotUpdateHandle?.(code);
149
149
  this.assetMgr.setEventCallback(null!);
150
150
  this.isUpdate = false;
151
- FWLog.debug('isFind New Version -> ', event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND);
151
+ FWLog.debug(
152
+ 'isFind New Version -> ',
153
+ event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND,
154
+ );
152
155
  if (event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND) {
153
156
  this.hotUpdate();
154
157
  }
@@ -158,7 +161,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
158
161
  FWLog.debug('start hotUpdate ->', this.assetMgr, this.isUpdate);
159
162
  if (this.assetMgr && !this.isUpdate) {
160
163
  this.assetMgr.setEventCallback(this.updateEventHandle.bind(this));
161
- FWLog.debug('assetMgr state ->', this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED);
164
+ FWLog.debug(
165
+ 'assetMgr state ->',
166
+ this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED,
167
+ );
162
168
  if (this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED) {
163
169
  this.assetMgr.loadLocalManifest(this.localManifest.nativeUrl);
164
170
  }
@@ -197,7 +203,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
197
203
  convertDownloadedBytes = this.convertBytes(downloadedBytes);
198
204
  convertTotalBytes = this.convertBytes(totalBytes);
199
205
  percent = event.getPercent();
200
- FWLog.debug('正在更新中 -> ', '下载文件数量:', downloadedFiles, ',下载文件总数量:', totalFiles, ',已下载大小:', convertDownloadedBytes, ',下载总大小:', convertTotalBytes);
206
+ FWLog.debug(
207
+ '正在更新中 -> ',
208
+ '下载文件数量:',
209
+ downloadedFiles,
210
+ ',下载文件总数量:',
211
+ totalFiles,
212
+ ',已下载大小:',
213
+ convertDownloadedBytes,
214
+ ',下载总大小:',
215
+ convertTotalBytes,
216
+ );
201
217
  }
202
218
  break;
203
219
  case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
@@ -220,7 +236,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
220
236
  convertDownloadedBytes = this.convertBytes(downloadedBytes);
221
237
  convertTotalBytes = this.convertBytes(totalBytes);
222
238
  percent = event.getPercent();
223
- FWLog.debug('正在更新完成 -> ', '下载文件数量:', downloadedFiles, ',下载文件总数量:', totalFiles, ',已下载大小:', convertDownloadedBytes, ',下载总大小:', convertTotalBytes);
239
+ FWLog.debug(
240
+ '正在更新完成 -> ',
241
+ '下载文件数量:',
242
+ downloadedFiles,
243
+ ',下载文件总数量:',
244
+ totalFiles,
245
+ ',已下载大小:',
246
+ convertDownloadedBytes,
247
+ ',下载总大小:',
248
+ convertTotalBytes,
249
+ );
224
250
  }
225
251
  str = 'UPDATE_FINISHED';
226
252
  needRestart = true;
@@ -268,12 +294,10 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
268
294
  this.isRetry = false;
269
295
  this.isUpdate = false;
270
296
 
271
-
272
297
  this.reloadLocalManifest();
273
298
 
274
299
  this.assetMgr.setEventCallback(null!);
275
300
  this.listener.completedHandle?.(this.newVersion);
276
-
277
301
  }
278
302
  }
279
303
 
@@ -288,6 +312,6 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
288
312
  return `${size.toFixed(size < 10 ? 2 : 1)} ${units[unitIndex]}`;
289
313
  }
290
314
 
291
- public initialize(): void { }
292
- public onDestroy(): void { }
315
+ public initialize(): void {}
316
+ public onDestroy(): void {}
293
317
  }
@@ -1,4 +1,3 @@
1
- import FWLog from '../log/FWLog';
2
1
  import { FWEventDefine } from '../define/FWEventDefine';
3
2
  import { FWManager } from './FWManager';
4
3
 
@@ -103,7 +102,7 @@ export default class FWLanguageManager extends FWManager implements FW.LanguageM
103
102
  * 获取支持的所有语言
104
103
  */
105
104
  getSupportedLanguages(): string[] {
106
- return [...this.supportedLanguages]; // 返回副本
105
+ return [...this.supportedLanguages];
107
106
  }
108
107
 
109
108
  /**
@@ -274,6 +274,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
274
274
  node.resumeSystemEvents(true);
275
275
 
276
276
  FW.Entry.evtMgr.targetResume(ctr);
277
+ FW.Entry.timeMgr.pauseSchedule(ctr);
277
278
  }
278
279
 
279
280
  /**
@@ -295,6 +296,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
295
296
  node.opacity = 0;
296
297
  node.pauseSystemEvents(true);
297
298
  FW.Entry.evtMgr.targetPause(ctr);
299
+ FW.Entry.timeMgr.resumeSchedule(ctr);
298
300
  }
299
301
 
300
302
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
- import { FWSystemDefine } from "../../define/FWSystemDefine";
2
- import FWLog from "../../log/FWLog";
3
- import FWService from "../FWService";
1
+ import { FWSystemDefine } from '../../define/FWSystemDefine';
2
+ import FWLog from '../../log/FWLog';
3
+ import FWService from '../FWService';
4
4
 
5
5
  export default class FWHttp extends FWService {
6
6
  public initialize(): void {}
@@ -9,62 +9,50 @@ export default class FWHttp extends FWService {
9
9
  protected async getMessage(
10
10
  url: string,
11
11
  params?: string,
12
- cb?: (response: string) => void
12
+ cb?: (response: string) => void,
13
13
  ): Promise<string> {
14
- return this.dataProcessing(
15
- url,
16
- params,
17
- cb,
18
- FWSystemDefine.FWHttpRequestType.GET
19
- );
14
+ return this.dataProcessing(url, params, cb, FWSystemDefine.FWHttpRequestType.GET);
20
15
  }
21
16
 
22
17
  protected async postMessage(
23
18
  url: string,
24
19
  params?: string,
25
- cb?: (response: string) => void
20
+ cb?: (response: string) => void,
26
21
  ): Promise<string> {
27
- return this.dataProcessing(
28
- url,
29
- params,
30
- cb,
31
- FWSystemDefine.FWHttpRequestType.POST
32
- );
22
+ return this.dataProcessing(url, params, cb, FWSystemDefine.FWHttpRequestType.POST);
33
23
  }
34
24
 
35
25
  private dataProcessing(
36
26
  url: string,
37
27
  params: string,
38
28
  cb: (response: any) => void,
39
- type: FWSystemDefine.FWHttpRequestType
29
+ type: FWSystemDefine.FWHttpRequestType,
40
30
  ): Promise<string> {
41
- return new Promise(
42
- (resolve: (msg: string) => void, reject: (error: string) => void) => {
43
- const xhr = new XMLHttpRequest();
44
- xhr.onreadystatechange = () => {
45
- if (xhr.readyState == 4 && xhr.status === 200) {
46
- cb?.(xhr.response);
47
- resolve(xhr.response);
48
- }
49
- };
50
-
51
- xhr.onerror = (err: any) => {
52
- FWLog.error(err);
53
- this.onError(err);
54
- reject(`http request error:${err}`);
55
- };
56
-
57
- xhr.ontimeout = () => {
58
- this.onTimeout();
59
- reject(`http request timeout!`);
60
- };
61
-
62
- xhr.open(type, url, true);
63
- xhr.send(params);
64
- }
65
- );
31
+ return new Promise((resolve: (msg: string) => void, reject: (error: string) => void) => {
32
+ const xhr = new XMLHttpRequest();
33
+ xhr.onreadystatechange = () => {
34
+ if (xhr.readyState == 4 && xhr.status === 200) {
35
+ cb?.(xhr.response);
36
+ resolve(xhr.response);
37
+ }
38
+ };
39
+
40
+ xhr.onerror = (err: any) => {
41
+ FWLog.error(err);
42
+ this.onError(err);
43
+ reject(`http request error:${err}`);
44
+ };
45
+
46
+ xhr.ontimeout = () => {
47
+ this.onTimeout();
48
+ reject(`http request timeout!`);
49
+ };
50
+
51
+ xhr.open(type, url, true);
52
+ xhr.send(params);
53
+ });
66
54
  }
67
55
 
68
- onError(err: any) {}
69
- onTimeout() {}
56
+ onError?(err: any);
57
+ onTimeout?();
70
58
  }
package/utils/FWTask.ts CHANGED
@@ -34,7 +34,7 @@ export default class FWTask implements FW.Task {
34
34
  };
35
35
  }
36
36
 
37
- async start(generator: FW.TaskFunction): Promise<FW.Task> {
37
+ start(generator: FW.TaskFunction): FW.Task {
38
38
  this.reset();
39
39
  const taskId = `TaskId:${this.id}->TaskCounter${this.taskCounter++}`;
40
40
  const gen = generator();
@@ -47,11 +47,11 @@ export default class FWTask implements FW.Task {
47
47
  taskId,
48
48
  });
49
49
  this.taskStartTime = FW.Entry.timeMgr.getTime();
50
- await this.executeFrame();
50
+ this.executeFrame();
51
51
  return this;
52
52
  }
53
53
 
54
- async add(generator: FW.TaskFunction): Promise<FW.Task> {
54
+ add(generator: FW.TaskFunction): FW.Task {
55
55
  const taskId = `TaskId:${this.id}->TaskCounter${this.taskCounter++}`;
56
56
  const gen = generator();
57
57
  (gen as any).taskId = taskId;
@@ -63,7 +63,7 @@ export default class FWTask implements FW.Task {
63
63
  });
64
64
  if (this.status !== FWSystemDefine.FWTaskStatus.RUNNING && !this.isPaused) {
65
65
  this.status = FWSystemDefine.FWTaskStatus.RUNNING;
66
- await this.executeFrame();
66
+ this.executeFrame();
67
67
  }
68
68
  return this;
69
69
  }