@ives_xxz/framework 1.0.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.
Files changed (139) hide show
  1. package/FW.d.ts +1845 -0
  2. package/FW.d.ts.meta +6 -0
  3. package/Framework.ts +148 -0
  4. package/Framework.ts.meta +10 -0
  5. package/README.md +93 -0
  6. package/README.md.meta +6 -0
  7. package/animation/FWAnimation.ts +13 -0
  8. package/animation/FWAnimation.ts.meta +10 -0
  9. package/animation/FWSkeleton.ts +176 -0
  10. package/animation/FWSkeleton.ts.meta +10 -0
  11. package/animation/FWTween.ts +60 -0
  12. package/animation/FWTween.ts.meta +10 -0
  13. package/animation.meta +13 -0
  14. package/component/FWVirtualViewComponent.ts +2080 -0
  15. package/component/FWVirtualViewComponent.ts.meta +10 -0
  16. package/component.meta +13 -0
  17. package/config/FWAssetConfig.ts +7 -0
  18. package/config/FWAssetConfig.ts.meta +10 -0
  19. package/config.meta +13 -0
  20. package/controller/FWLayerController.ts +236 -0
  21. package/controller/FWLayerController.ts.meta +10 -0
  22. package/controller.meta +13 -0
  23. package/data/FWData.ts +10 -0
  24. package/data/FWData.ts.meta +10 -0
  25. package/data.meta +13 -0
  26. package/define/FWEventDefine.ts +26 -0
  27. package/define/FWEventDefine.ts.meta +10 -0
  28. package/define/FWSystemDefine.ts +133 -0
  29. package/define/FWSystemDefine.ts.meta +10 -0
  30. package/define.meta +13 -0
  31. package/entry/FWEntry.ts +196 -0
  32. package/entry/FWEntry.ts.meta +10 -0
  33. package/entry.meta +13 -0
  34. package/expand/FWCocosExpand.ts +73 -0
  35. package/expand/FWCocosExpand.ts.meta +10 -0
  36. package/expand/FWDecorator.ts +256 -0
  37. package/expand/FWDecorator.ts.meta +10 -0
  38. package/expand/FWRollingViewNesting.ts +191 -0
  39. package/expand/FWRollingViewNesting.ts.meta +10 -0
  40. package/expand/FWTweenExpand.ts +44 -0
  41. package/expand/FWTweenExpand.ts.meta +10 -0
  42. package/expand.meta +13 -0
  43. package/item/FWVirtualListItem.ts +150 -0
  44. package/item/FWVirtualListItem.ts.meta +10 -0
  45. package/item.meta +13 -0
  46. package/language/FWLanguage.ts +69 -0
  47. package/language/FWLanguage.ts.meta +10 -0
  48. package/language/FWLanguageLabelLocalize.ts +144 -0
  49. package/language/FWLanguageLabelLocalize.ts.meta +10 -0
  50. package/language/FWLanguageSkeletonLocalize.ts +106 -0
  51. package/language/FWLanguageSkeletonLocalize.ts.meta +10 -0
  52. package/language/FWLanguageSpriteLocalize.ts +81 -0
  53. package/language/FWLanguageSpriteLocalize.ts.meta +10 -0
  54. package/language.meta +13 -0
  55. package/layer/FWLayer.ts +13 -0
  56. package/layer/FWLayer.ts.meta +10 -0
  57. package/layer.meta +13 -0
  58. package/log/FWLog.ts +115 -0
  59. package/log/FWLog.ts.meta +10 -0
  60. package/log.meta +13 -0
  61. package/logic/FWLogic.ts +10 -0
  62. package/logic/FWLogic.ts.meta +10 -0
  63. package/logic.meta +13 -0
  64. package/machine/FWAnimationMachine.ts +28 -0
  65. package/machine/FWAnimationMachine.ts.meta +10 -0
  66. package/machine/FWStateMachine.ts +75 -0
  67. package/machine/FWStateMachine.ts.meta +10 -0
  68. package/machine.meta +13 -0
  69. package/manager/FWAnimationManager.ts +128 -0
  70. package/manager/FWAnimationManager.ts.meta +10 -0
  71. package/manager/FWAssetManager.ts +349 -0
  72. package/manager/FWAssetManager.ts.meta +10 -0
  73. package/manager/FWAudioManager.ts +289 -0
  74. package/manager/FWAudioManager.ts.meta +10 -0
  75. package/manager/FWBundleManager.ts +91 -0
  76. package/manager/FWBundleManager.ts.meta +10 -0
  77. package/manager/FWComponentManager.ts +25 -0
  78. package/manager/FWComponentManager.ts.meta +10 -0
  79. package/manager/FWEngineManager.ts +63 -0
  80. package/manager/FWEngineManager.ts.meta +10 -0
  81. package/manager/FWEventManager.ts +275 -0
  82. package/manager/FWEventManager.ts.meta +10 -0
  83. package/manager/FWHotUpdateManager.ts +213 -0
  84. package/manager/FWHotUpdateManager.ts.meta +10 -0
  85. package/manager/FWLanguageManager.ts +116 -0
  86. package/manager/FWLanguageManager.ts.meta +10 -0
  87. package/manager/FWLayerManager.ts +490 -0
  88. package/manager/FWLayerManager.ts.meta +10 -0
  89. package/manager/FWManager.ts +8 -0
  90. package/manager/FWManager.ts.meta +10 -0
  91. package/manager/FWObjectManager.ts +91 -0
  92. package/manager/FWObjectManager.ts.meta +10 -0
  93. package/manager/FWResManager.ts +171 -0
  94. package/manager/FWResManager.ts.meta +10 -0
  95. package/manager/FWSocketManager.ts +94 -0
  96. package/manager/FWSocketManager.ts.meta +10 -0
  97. package/manager/FWStateManager.ts +102 -0
  98. package/manager/FWStateManager.ts.meta +10 -0
  99. package/manager/FWTaskManager.ts +38 -0
  100. package/manager/FWTaskManager.ts.meta +10 -0
  101. package/manager/FWTimeManager.ts +473 -0
  102. package/manager/FWTimeManager.ts.meta +10 -0
  103. package/manager/FWUiManager.ts +164 -0
  104. package/manager/FWUiManager.ts.meta +10 -0
  105. package/manager.meta +13 -0
  106. package/package.json +17 -0
  107. package/package.json.meta +6 -0
  108. package/scene/FWScene.ts +25 -0
  109. package/scene/FWScene.ts.meta +10 -0
  110. package/scene.meta +13 -0
  111. package/service/FWService.ts +7 -0
  112. package/service/FWService.ts.meta +10 -0
  113. package/service/http/FWHttp.ts +70 -0
  114. package/service/http/FWHttp.ts.meta +10 -0
  115. package/service/http.meta +13 -0
  116. package/service/socket/FWSocket.ts +236 -0
  117. package/service/socket/FWSocket.ts.meta +10 -0
  118. package/service/socket/FWSocketHandle.ts +17 -0
  119. package/service/socket/FWSocketHandle.ts.meta +10 -0
  120. package/service/socket/FWSocketSender.ts +16 -0
  121. package/service/socket/FWSocketSender.ts.meta +10 -0
  122. package/service/socket.meta +13 -0
  123. package/service.meta +13 -0
  124. package/state/FWState.ts +8 -0
  125. package/state/FWState.ts.meta +10 -0
  126. package/state.meta +13 -0
  127. package/utils/FWLodash.ts +105 -0
  128. package/utils/FWLodash.ts.meta +10 -0
  129. package/utils/FWMask.ts +222 -0
  130. package/utils/FWMask.ts.meta +10 -0
  131. package/utils/FWObject.ts +22 -0
  132. package/utils/FWObject.ts.meta +10 -0
  133. package/utils/FWObjectPool.ts +178 -0
  134. package/utils/FWObjectPool.ts.meta +10 -0
  135. package/utils/FWQueue.ts +47 -0
  136. package/utils/FWQueue.ts.meta +10 -0
  137. package/utils/FWTask.ts +223 -0
  138. package/utils/FWTask.ts.meta +10 -0
  139. package/utils.meta +13 -0
@@ -0,0 +1,25 @@
1
+ import { FWSocketAutoProcessResume } from '../expand/FWDecorator';
2
+
3
+ const { ccclass, property } = cc._decorator;
4
+
5
+ @ccclass
6
+ export default abstract class FWScene extends cc.Component {
7
+ readonly entry: FW.Entry = FW.Entry;
8
+
9
+ @FWSocketAutoProcessResume()
10
+ protected onLoad(): void {
11
+ this.entry.scene = this;
12
+ }
13
+
14
+ protected update(dt: number): void {
15
+ this.entry?.update?.(dt);
16
+ }
17
+
18
+ protected onDestroy(): void {
19
+ this.entry?.evtMgr.targetOff(this);
20
+ this.entry?.timeMgr.unSchedule(this);
21
+ this.entry?.uiMgr.unRegisterTarget(this);
22
+ this?.unscheduleAllCallbacks?.();
23
+ this?.node?.stopAllActions?.();
24
+ }
25
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "9d78ed88-e34f-455b-9d0f-73978b74107a",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
package/scene.meta ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "f8d1e84d-5adb-468b-9dcf-c84901b90bce",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,7 @@
1
+ export default abstract class FWService {
2
+ constructor() {
3
+ this.initialize();
4
+ }
5
+ public abstract initialize(): void;
6
+ public abstract destroy(): void;
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "02e35f42-98e4-45c5-8139-e90f226d3782",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,70 @@
1
+ import { FWSystemDefine } from "../../define/FWSystemDefine";
2
+ import FWLog from "../../log/FWLog";
3
+ import FWService from "../FWService";
4
+
5
+ export default class FWHttp extends FWService {
6
+ public initialize(): void {}
7
+ public destroy(): void {}
8
+
9
+ protected async getMessage(
10
+ url: string,
11
+ params?: string,
12
+ cb?: (response: string) => void
13
+ ): Promise<string> {
14
+ return this.dataProcessing(
15
+ url,
16
+ params,
17
+ cb,
18
+ FWSystemDefine.FWHttpRequestType.GET
19
+ );
20
+ }
21
+
22
+ protected async postMessage(
23
+ url: string,
24
+ params?: string,
25
+ cb?: (response: string) => void
26
+ ): Promise<string> {
27
+ return this.dataProcessing(
28
+ url,
29
+ params,
30
+ cb,
31
+ FWSystemDefine.FWHttpRequestType.POST
32
+ );
33
+ }
34
+
35
+ private dataProcessing(
36
+ url: string,
37
+ params: string,
38
+ cb: (response: any) => void,
39
+ type: FWSystemDefine.FWHttpRequestType
40
+ ): 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
+ );
66
+ }
67
+
68
+ onError(err: any) {}
69
+ onTimeout() {}
70
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "f0ad42b9-3784-4643-9175-bffd9d96570a",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "8af24859-b6c3-4ead-8cf8-386570d860a8",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,236 @@
1
+ import Framework from '../../Framework';
2
+ import FWLog from '../../log/FWLog';
3
+ import FWSocketHandle from './FWSocketHandle';
4
+ import FWSocketSender from './FWSocketSender';
5
+
6
+ /**
7
+ * TODO 犹豫socket没有改版暂时已老的cmd字符串映射方式做,后期优化
8
+ */
9
+ export default class FWSocket implements FW.Socket {
10
+ /** 发送心跳时间抽 */
11
+ private sendHeartTimestamp: number;
12
+ /** 接收心跳时间戳 */
13
+ private receiveTimeStamp: number;
14
+ /** socket */
15
+ socket: WebSocket = null;
16
+ /** 消息发送者 */
17
+ protected sender: FWSocketSender;
18
+ /** 消息处理者 */
19
+ protected handle: FWSocketHandle;
20
+ /** 重连次数 */
21
+ protected reconnectTimes: number;
22
+ /** 心跳间隔时间 */
23
+ protected heartInternal: number;
24
+ /** 心跳超时时间 */
25
+ protected heartTimeout: number;
26
+ /** 心跳弱网时间 */
27
+ protected heartWeakTime: number;
28
+ /** 最大重连次数 */
29
+ protected maxReconnectTimes: number;
30
+ /** 重连间隔 */
31
+ protected reconnectInternal: number;
32
+ /** 地址 */
33
+ protected address: string;
34
+ /** 标签 */
35
+ protected tag: string;
36
+ /** 是否暂停消息处理 */
37
+ protected isPausedMessageHandle: boolean = false;
38
+ /** 是否正在重连 */
39
+ private isReconnect: boolean = false;
40
+
41
+ private promiseProxy: FW.SocketPromiseProxy;
42
+ /**
43
+ * 消息事件列表
44
+ * TODO 目前没有消息协议号,暂时无用
45
+ */
46
+ protected messageEvents: { [key: string]: (msg: any) => void };
47
+
48
+ constructor() {
49
+ this.initialize();
50
+ }
51
+
52
+ public initialize(): void {
53
+ this.messageEvents = cc.js.createMap();
54
+ }
55
+
56
+ createSocket(
57
+ address: string,
58
+ tag: string,
59
+ sender: FWSocketSender,
60
+ handle: FWSocketHandle,
61
+ config: {
62
+ heartInternal: number;
63
+ heartTimeout: number;
64
+ heartWeakTime: number;
65
+ maxReconnectTimes: number;
66
+ reconnectInternal: number;
67
+ },
68
+ ): FW.SocketPromiseProxy {
69
+ FW.Entry.timeMgr.unSchedule(this);
70
+ this.tag = tag;
71
+ this.address = address;
72
+ this.socket = new WebSocket(address);
73
+ this.socket.onopen = this.onSocketOpen.bind(this);
74
+ this.socket.onclose = this.onSocketClose.bind(this);
75
+ this.socket.onerror = this.onSocketError.bind(this);
76
+ this.socket.onmessage = this.onSocketMessage.bind(this);
77
+
78
+ this.sender = sender;
79
+ this.handle = handle;
80
+
81
+ this.heartInternal = config?.heartInternal;
82
+ this.heartTimeout = config?.heartTimeout;
83
+ this.heartWeakTime = config?.heartWeakTime;
84
+ this.maxReconnectTimes = config?.maxReconnectTimes;
85
+
86
+ this.promiseProxy = {
87
+ promise: undefined,
88
+ socket: this,
89
+ };
90
+ new Promise<FWSocket>((resolve) => {
91
+ this.promiseProxy.promise = resolve;
92
+ });
93
+ return this.promiseProxy;
94
+ }
95
+ /**
96
+ * 注册消息事件
97
+ * @param msgId
98
+ * @param cb
99
+ */
100
+ registerMessage(msgId: string, cb: (msg: any) => void) {
101
+ this.messageEvents[msgId] = cb;
102
+ }
103
+
104
+ public onDestroy(): void {
105
+ this.messageEvents = cc.js.createMap();
106
+ this.socket = null;
107
+ }
108
+
109
+ public getTag() {
110
+ return this.tag;
111
+ }
112
+
113
+ /**
114
+ * 获取地址
115
+ * @returns
116
+ */
117
+ public getAddress() {
118
+ return this.address;
119
+ }
120
+
121
+ /**
122
+ * 获取socket状态
123
+ * @returns
124
+ */
125
+ public getReadyState() {
126
+ return this.socket.readyState;
127
+ }
128
+ /**
129
+ * 关闭连接
130
+ */
131
+ public close() {
132
+ FW.Entry.socketMgr.closeSocket(this);
133
+ }
134
+
135
+ public pauseMessageHandle() {
136
+ this.isPausedMessageHandle = true;
137
+ }
138
+
139
+ public resumeMessageHandle() {
140
+ this.isPausedMessageHandle = false;
141
+ }
142
+
143
+ private reconnect() {
144
+ FWLog.debug(
145
+ `socket reconnect : reconnectTimes->${this.reconnectTimes},maxReconnectTimes->${this.maxReconnectTimes}`,
146
+ );
147
+ if (++this.reconnectTimes >= this.maxReconnectTimes) {
148
+ this.handle?.onTimeout?.();
149
+ return;
150
+ }
151
+ FW.Entry.timeMgr.unSchedule(this);
152
+ this.isReconnect = true;
153
+ this.sendHeartTimestamp = 0;
154
+ this.receiveTimeStamp = 0;
155
+ this.socket.close();
156
+ this.socket = null;
157
+
158
+ this.createSocket(this.address, this.tag, this.sender, this.handle, {
159
+ heartInternal: this.heartInternal,
160
+ heartTimeout: this.heartTimeout,
161
+ heartWeakTime: this.heartWeakTime,
162
+ maxReconnectTimes: this.maxReconnectTimes,
163
+ reconnectInternal: this.reconnectInternal,
164
+ });
165
+ }
166
+
167
+ /** 连接打开 */
168
+ private onSocketOpen() {
169
+ FWLog.debug('on open!');
170
+ FW.Entry.timeMgr.unSchedule(this);
171
+ this.reconnectTimes = 0;
172
+ this.sendHeartTimestamp = 0;
173
+ this.receiveTimeStamp = 0;
174
+ this.isReconnect = false;
175
+ this.handle?.onOpen?.();
176
+ this.heartHandle();
177
+ this.promiseProxy?.promise(this);
178
+ }
179
+
180
+ private heartHandle() {
181
+ FW.Entry?.timeMgr?.schedule(
182
+ () => {
183
+ const interval = this.sendHeartTimestamp - this.receiveTimeStamp;
184
+ if (interval >= this.heartWeakTime) {
185
+ this.handle.onWeakNetWork?.();
186
+ if (interval >= this.heartTimeout) {
187
+ this.reconnect();
188
+ return;
189
+ }
190
+ }
191
+ this.sendHeart();
192
+ },
193
+ this.heartInternal / 1000,
194
+ cc.macro.REPEAT_FOREVER,
195
+ this,
196
+ );
197
+ }
198
+
199
+ private sendHeart() {
200
+ this.sendHeartTimestamp = new Date().getTime();
201
+ this.sender?.sendHeart?.();
202
+ }
203
+
204
+ send(msg: any) {
205
+ if (this.getReadyState() != WebSocket.OPEN) return;
206
+ if (this.isPausedMessageHandle) return;
207
+ this.socket?.send(msg);
208
+ }
209
+
210
+ /** socket关闭 */
211
+ private onSocketClose() {
212
+ this.handle?.onClose?.();
213
+ FW.Entry.timeMgr.scheduleOnce(
214
+ () => {
215
+ if (!this.isReconnect) return;
216
+ FWLog.debug('on close!');
217
+ this.reconnect();
218
+ },
219
+ 3,
220
+ this,
221
+ );
222
+ }
223
+ /** 消息处理 */
224
+ private async onSocketMessage(msg: any) {
225
+ if (await this.handle?.onHeart?.(msg)) {
226
+ this.receiveTimeStamp = new Date().getTime();
227
+ } else {
228
+ if (this.isPausedMessageHandle) return;
229
+ this.handle?.onMessage?.(msg);
230
+ }
231
+ }
232
+ /** 错误处理 */
233
+ private onSocketError(msg: any) {
234
+ this.handle?.onError?.(msg);
235
+ }
236
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "6bff4169-033b-4745-842d-fdb124b9ac6c",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,17 @@
1
+ import { injectable } from 'inversify';
2
+ @injectable()
3
+ export default abstract class FWSocketHandle implements FW.Handle {
4
+ constructor() {
5
+ this.initialize?.();
6
+ }
7
+ public readonly entry: FW.Entry = FW.Entry;
8
+ initialize?();
9
+ onDestroy?();
10
+ onHeart?(msg: any): Promise<boolean>;
11
+ onWeakNetWork?(): void;
12
+ abstract onClose(): void;
13
+ abstract onOpen(): void;
14
+ abstract onMessage(msg: any): void;
15
+ abstract onError(msg: any): void;
16
+ abstract onTimeout(): void;
17
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "2e34eee4-ca3e-4ffd-9ff5-3fab23ea4f76",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,16 @@
1
+ import { injectable } from 'inversify';
2
+ import FWLog from '../../log/FWLog';
3
+ @injectable()
4
+ export default class FWSocketSender implements FW.Sender {
5
+ constructor() {
6
+ this.initialize?.();
7
+ }
8
+ public readonly entry: FW.Entry = FW.Entry;
9
+ initialize?();
10
+ onDestroy?();
11
+ sendHeart?();
12
+
13
+ send(msg: any) {
14
+ FW.Entry.socketMgr.getSocket()?.send(msg);
15
+ }
16
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "5ef12e31-ee4f-443b-9de1-9075ecdde103",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "a7f0af4f-9f10-4654-824d-3bad8f83fe02",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
package/service.meta ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "c2964b62-8f96-4c31-99a6-dbb9ab128665",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,8 @@
1
+ export abstract class FWState implements FW.State {
2
+ constructor() {}
3
+ abstract onEnter(args: any): void;
4
+ abstract onExit(): void;
5
+ abstract onInit(): void;
6
+ abstract onDestroy(): void;
7
+ abstract onUpdate(dt?: number): void;
8
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "28581272-c60a-4687-8d91-0a3140b8c8a7",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
package/state.meta ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "91d50211-1204-4d3b-a7cb-6ae92e8fb6ca",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,105 @@
1
+ import Lodash from 'lodash';
2
+
3
+ export namespace FWLodash {
4
+ /**
5
+ * 通过字符串数组创建一个CC的枚举对象
6
+ * @param target
7
+ * @returns
8
+ */
9
+ export function CCEnum(target: string[]) {
10
+ return cc.Enum(
11
+ Lodash.chain(target)
12
+ .map((element, index) => {
13
+ return [`${element}`, index];
14
+ })
15
+ .fromPairs()
16
+ .value(),
17
+ );
18
+ }
19
+ /**
20
+ * 判断值是否为空
21
+ * @param value
22
+ * @returns
23
+ */
24
+ export const isEmpty = (value: any) => Lodash.isEmpty(value);
25
+ /**
26
+ * 递归克隆
27
+ * @param value
28
+ * @returns
29
+ */
30
+ export const cloneDeep = <T>(value: T): T => Lodash.cloneDeep(value);
31
+ /**
32
+ * 递归地将源对象的自身和继承的可枚举属性合并到目标对象中,
33
+ * 跳过解析为undefined的源属性。
34
+ * 数组和普通对象属性递归合并。
35
+ * 其他对象和值类型被赋值覆盖。
36
+ * 源对象从左向右应用。
37
+ * 后续源会覆盖先前源的属性分配。
38
+ * @param object
39
+ * @param source
40
+ * @returns
41
+ */
42
+ export const merge = <T, U>(object: T, source: U): T & U => Lodash.merge(object, source);
43
+ /**
44
+ * 创建一个 debounced(防抖动)函数,该函数会从上一次被调用后,延迟 wait 毫秒后调用 func 方法。
45
+ * @param func
46
+ * @param wait
47
+ * @returns
48
+ */
49
+ export const debounce = <T extends (...args: any[]) => any>(func: T, wait: number) =>
50
+ Lodash.debounce(func, wait);
51
+ /**
52
+ * 创建一个节流函数,在 wait 秒内最多执行 func 一次的函数。
53
+ * @param func
54
+ * @param wait
55
+ * @returns
56
+ */
57
+ export const throttle = <T extends (...args: any[]) => any>(func: T, wait: number) =>
58
+ Lodash.throttle(func, wait);
59
+ /**
60
+ * 创建数组的无重复版本,其中只保留每个元素的第一次出现。
61
+ * @param array
62
+ * @returns
63
+ */
64
+ export const uniq = <T>(array: T[]): T[] => Lodash.uniq(array);
65
+ /**
66
+ * 根据 object对象的path路径获取值
67
+ * @param object
68
+ * @param path
69
+ * @param defaultValue
70
+ * @returns
71
+ */
72
+ export const get = <T, R>(object: T, path: Lodash.PropertyPath, defaultValue?: R): R =>
73
+ Lodash.get(object, path, defaultValue);
74
+ /**
75
+ * 根据 object对象的path路径设置值
76
+ * @param object
77
+ * @param path
78
+ * @param defaultValue
79
+ * @returns
80
+ */
81
+ export const set = <T extends object>(object: T, path: Lodash.PropertyPath, value: any): T =>
82
+ Lodash.set(object, path, value);
83
+ /**
84
+ * 创建一个由通过迭代器运行集合的每个元素的结果生成的键组成的对象。每个键的对应值是负责生成键的元素数组
85
+ * @param array
86
+ * @param iteratee
87
+ * @returns
88
+ */
89
+ export const groupBy = <T>(array: T[], iteratee: Lodash.ValueIteratee<T>) =>
90
+ Lodash.groupBy(array, iteratee);
91
+ /**
92
+ * 创建一个元素数组,根据通过每个迭代器运行集合中每个元素的结果按升序排序。此方法执行稳定排序,即保留相等元素的原始排序顺序。
93
+ * @param array
94
+ * @param iteratee
95
+ * @returns
96
+ */
97
+ export const sortBy = <T>(array: T[], iteratee?: Lodash.Many<Lodash.ListIteratee<T>>) =>
98
+ Lodash.sortBy(array, iteratee);
99
+ /**
100
+ * 创建一个只调用一次的函数
101
+ * @param func
102
+ * @returns
103
+ */
104
+ export const once = (func: any) => Lodash.once(func);
105
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "167711e4-ace5-44f9-8ad3-2689277b6e7c",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }