@ives_xxz/framework 1.1.9 → 1.2.1
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 +7 -7
- package/item/FWVirtualListItem.ts +0 -8
- package/language/FWLanguageLabelLocalize.ts +1 -1
- package/manager/FWAudioManager.ts +2 -2
- package/manager/FWBundleManager.ts +1 -1
- package/manager/FWLanguageManager.ts +1 -2
- package/manager/FWLayerManager.ts +2 -0
- package/manager/FWTaskManager.ts +1 -1
- package/package.json +1 -1
- package/service/http/FWHttp.ts +33 -45
- package/service/socket/FWSocket.ts +1 -0
- package/utils/FWTask.ts +16 -14
package/FW.d.ts
CHANGED
|
@@ -1092,7 +1092,7 @@ declare namespace FW {
|
|
|
1092
1092
|
* tasksFrameCount?: number; 每帧最多执行的任务个数
|
|
1093
1093
|
*/
|
|
1094
1094
|
|
|
1095
|
-
createTask(options: FW.TaskOptions): FW.Task;
|
|
1095
|
+
createTask(options: Partial<FW.TaskOptions>): FW.Task;
|
|
1096
1096
|
/**
|
|
1097
1097
|
* 获取任务
|
|
1098
1098
|
* @param taskId
|
|
@@ -1732,19 +1732,19 @@ declare namespace FW {
|
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
1734
|
type TaskOptions = {
|
|
1735
|
-
taskId
|
|
1735
|
+
taskId: number;
|
|
1736
1736
|
/**
|
|
1737
1737
|
* 每帧最大执行时间(ms),默认16ms (60fps) 帧预算
|
|
1738
1738
|
*/
|
|
1739
|
-
frameBudget
|
|
1739
|
+
frameBudget: number;
|
|
1740
1740
|
/**
|
|
1741
1741
|
* 每帧最多执行的任务个数
|
|
1742
1742
|
*/
|
|
1743
|
-
tasksFrameCount
|
|
1743
|
+
tasksFrameCount: number;
|
|
1744
1744
|
/**
|
|
1745
1745
|
* 是否打印日志
|
|
1746
1746
|
*/
|
|
1747
|
-
log
|
|
1747
|
+
log: boolean;
|
|
1748
1748
|
};
|
|
1749
1749
|
|
|
1750
1750
|
type TaskEvent = {
|
|
@@ -1795,12 +1795,12 @@ declare namespace FW {
|
|
|
1795
1795
|
* 任务开始
|
|
1796
1796
|
* @param generator
|
|
1797
1797
|
*/
|
|
1798
|
-
start(generator: TaskFunction):
|
|
1798
|
+
start(generator: TaskFunction): Task;
|
|
1799
1799
|
/**
|
|
1800
1800
|
* 添加任务
|
|
1801
1801
|
* @param generator
|
|
1802
1802
|
*/
|
|
1803
|
-
add(generator: TaskFunction):
|
|
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 :
|
|
80
|
-
const loop = data.loop === undefined ? false :
|
|
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);
|
|
@@ -70,9 +70,9 @@ export class FWBundleManager extends FWManager implements FW.BundleManager {
|
|
|
70
70
|
/** 释放bundle */
|
|
71
71
|
release(bundleName: string): void {
|
|
72
72
|
if (!this.has(bundleName)) {
|
|
73
|
-
FWLog.warn('bundle未加载,无需释放!');
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
75
|
+
cc.assetManager.removeBundle(this.bundleMap.get(bundleName));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
@@ -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/manager/FWTaskManager.ts
CHANGED
|
@@ -13,7 +13,7 @@ export default class FWTaskManager extends FWManager implements FW.TaskManager {
|
|
|
13
13
|
*/
|
|
14
14
|
private taskId = 0;
|
|
15
15
|
|
|
16
|
-
createTask(options
|
|
16
|
+
createTask(options?: Partial<FW.TaskOptions>): FW.Task {
|
|
17
17
|
const task = new FWTask({
|
|
18
18
|
tasksFrameCount: options?.tasksFrameCount,
|
|
19
19
|
frameBudget: options?.frameBudget,
|
package/package.json
CHANGED
package/service/http/FWHttp.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FWSystemDefine } from
|
|
2
|
-
import FWLog from
|
|
3
|
-
import FWService from
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
xhr.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
@@ -20,13 +20,13 @@ export default class FWTask implements FW.Task {
|
|
|
20
20
|
|
|
21
21
|
readonly id: number;
|
|
22
22
|
|
|
23
|
-
constructor(options
|
|
24
|
-
this.id = options
|
|
23
|
+
constructor(options?: Partial<FW.TaskOptions>) {
|
|
24
|
+
this.id = options?.taskId || 0;
|
|
25
25
|
this.taskCounter = 0;
|
|
26
26
|
this.totalTaskDuration = 0;
|
|
27
|
-
this.log = options
|
|
28
|
-
this.frameBudget = options
|
|
29
|
-
this.tasksFrameCount = options
|
|
27
|
+
this.log = options?.log ?? true;
|
|
28
|
+
this.frameBudget = options?.frameBudget ?? 16;
|
|
29
|
+
this.tasksFrameCount = options?.tasksFrameCount ?? 3;
|
|
30
30
|
this.performanceData = {
|
|
31
31
|
frameTimes: [],
|
|
32
32
|
detailedFrames: [],
|
|
@@ -34,7 +34,7 @@ export default class FWTask implements FW.Task {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
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
|
-
|
|
50
|
+
this.executeFrame();
|
|
51
51
|
return this;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
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
|
-
|
|
66
|
+
this.executeFrame();
|
|
67
67
|
}
|
|
68
68
|
return this;
|
|
69
69
|
}
|
|
@@ -138,11 +138,13 @@ export default class FWTask implements FW.Task {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
if ((result?.value as any)?.message) {
|
|
142
|
+
frameTasks.push({
|
|
143
|
+
taskId: taskId,
|
|
144
|
+
result: result.done ? FWEventDefine.TaskEvent.COMPLETE : FWEventDefine.TaskEvent.YIELDED,
|
|
145
|
+
message: (result?.value as any)?.message,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
146
148
|
|
|
147
149
|
processed++;
|
|
148
150
|
}
|