@cc-component/cc-core 1.2.8
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/.cc-ex-component.md +12 -0
- package/assets/core/config/CommonEnum.ts +94 -0
- package/assets/core/config/CommonEnum.ts.meta +9 -0
- package/assets/core/config/IConfig.ts +89 -0
- package/assets/core/config/IConfig.ts.meta +9 -0
- package/assets/core/config/LayerType.ts +44 -0
- package/assets/core/config/LayerType.ts.meta +9 -0
- package/assets/core/config/LayerUI.ts +113 -0
- package/assets/core/config/LayerUI.ts.meta +9 -0
- package/assets/core/config.meta +9 -0
- package/assets/core/editor/LanguageManager.ts +323 -0
- package/assets/core/editor/LanguageManager.ts.meta +9 -0
- package/assets/core/editor/SpineRunner.ts +39 -0
- package/assets/core/editor/SpineRunner.ts.meta +9 -0
- package/assets/core/editor/i18nEditorComponent.ts +137 -0
- package/assets/core/editor/i18nEditorComponent.ts.meta +9 -0
- package/assets/core/editor.meta +9 -0
- package/assets/core/home/AudioUtil.ts +164 -0
- package/assets/core/home/AudioUtil.ts.meta +9 -0
- package/assets/core/home/BaseBoxView.ts +60 -0
- package/assets/core/home/BaseBoxView.ts.meta +9 -0
- package/assets/core/home/BaseLaunchComponent.ts +9 -0
- package/assets/core/home/BaseLaunchComponent.ts.meta +9 -0
- package/assets/core/home/BaseLoading.ts +136 -0
- package/assets/core/home/BaseLoading.ts.meta +9 -0
- package/assets/core/home/BaseSkeleton.ts +39 -0
- package/assets/core/home/BaseSkeleton.ts.meta +9 -0
- package/assets/core/home/CameraAngel.ts +326 -0
- package/assets/core/home/CameraAngel.ts.meta +9 -0
- package/assets/core/home/DouYinShow.ts +27 -0
- package/assets/core/home/DouYinShow.ts.meta +9 -0
- package/assets/core/home/EventManager.ts +39 -0
- package/assets/core/home/EventManager.ts.meta +9 -0
- package/assets/core/home/ExView.ts +9 -0
- package/assets/core/home/ExView.ts.meta +9 -0
- package/assets/core/home/FollowCamera.ts +205 -0
- package/assets/core/home/FollowCamera.ts.meta +9 -0
- package/assets/core/home/InViewCenter.ts +52 -0
- package/assets/core/home/InViewCenter.ts.meta +9 -0
- package/assets/core/home/JsonUtil.ts +102 -0
- package/assets/core/home/JsonUtil.ts.meta +9 -0
- package/assets/core/home/LoadingWindow.ts +44 -0
- package/assets/core/home/LoadingWindow.ts.meta +9 -0
- package/assets/core/home/ParabolaTween.ts +110 -0
- package/assets/core/home/ParabolaTween.ts.meta +9 -0
- package/assets/core/home/ProgessView.ts +96 -0
- package/assets/core/home/ProgessView.ts.meta +9 -0
- package/assets/core/home/Quaternion.ts +237 -0
- package/assets/core/home/Quaternion.ts.meta +9 -0
- package/assets/core/home/ResUtil.ts +132 -0
- package/assets/core/home/ResUtil.ts.meta +9 -0
- package/assets/core/home/ResourceManager.ts +430 -0
- package/assets/core/home/ResourceManager.ts.meta +9 -0
- package/assets/core/home/StateMachine.ts +93 -0
- package/assets/core/home/StateMachine.ts.meta +9 -0
- package/assets/core/home/StorageManager.ts +161 -0
- package/assets/core/home/StorageManager.ts.meta +9 -0
- package/assets/core/home/ThirdFreeLookCamera.ts +201 -0
- package/assets/core/home/ThirdFreeLookCamera.ts.meta +9 -0
- package/assets/core/home/TimeManager.ts +486 -0
- package/assets/core/home/TimeManager.ts.meta +9 -0
- package/assets/core/home/Tools.ts +103 -0
- package/assets/core/home/Tools.ts.meta +9 -0
- package/assets/core/home/prefabs.meta +12 -0
- package/assets/core/home/util/EncryptUtil.ts +60 -0
- package/assets/core/home/util/EncryptUtil.ts.meta +11 -0
- package/assets/core/home/util/MathUtil.ts +22 -0
- package/assets/core/home/util/MathUtil.ts.meta +9 -0
- package/assets/core/home/util/Md5.ts +202 -0
- package/assets/core/home/util/Md5.ts.meta +11 -0
- package/assets/core/home/util/RandomUtil.ts +61 -0
- package/assets/core/home/util/RandomUtil.ts.meta +9 -0
- package/assets/core/home/util/ResUtil.ts +129 -0
- package/assets/core/home/util/ResUtil.ts.meta +9 -0
- package/assets/core/home/util/crypto-js.d.ts +30 -0
- package/assets/core/home/util/crypto-js.d.ts.meta +11 -0
- package/assets/core/home/util/crypto-js.js +6030 -0
- package/assets/core/home/util/crypto-js.js.meta +9 -0
- package/assets/core/home/util.meta +12 -0
- package/assets/core/home.meta +12 -0
- package/assets/core/interface/ISceneParam.ts +11 -0
- package/assets/core/interface/ISceneParam.ts.meta +9 -0
- package/assets/core/interface/Interface.ts +160 -0
- package/assets/core/interface/Interface.ts.meta +1 -0
- package/assets/core/interface/MainModule.ts +1019 -0
- package/assets/core/interface/MainModule.ts.meta +9 -0
- package/assets/core/interface.meta +9 -0
- package/assets/core/lib/Logger.ts +286 -0
- package/assets/core/lib/Logger.ts.meta +9 -0
- package/assets/core/lib/language/.language.md +1 -0
- package/assets/core/lib/language/Language.ts +133 -0
- package/assets/core/lib/language/Language.ts.meta +13 -0
- package/assets/core/lib/language/LanguageData.ts +114 -0
- package/assets/core/lib/language/LanguageData.ts.meta +9 -0
- package/assets/core/lib/language/LanguageLabel.ts +172 -0
- package/assets/core/lib/language/LanguageLabel.ts.meta +13 -0
- package/assets/core/lib/language/LanguagePack.ts +126 -0
- package/assets/core/lib/language/LanguagePack.ts.meta +13 -0
- package/assets/core/lib/language/LanguagePointLabel.ts.meta +16 -0
- package/assets/core/lib/language/LanguageSpine.ts +60 -0
- package/assets/core/lib/language/LanguageSpine.ts.meta +9 -0
- package/assets/core/lib/language/LanguageSprite.ts +138 -0
- package/assets/core/lib/language/LanguageSprite.ts.meta +13 -0
- package/assets/core/lib/language.meta +9 -0
- package/assets/core/lib/logger/ELoggerLevel.ts +16 -0
- package/assets/core/lib/logger/ELoggerLevel.ts.meta +9 -0
- package/assets/core/lib/logger/MLogger.ts +118 -0
- package/assets/core/lib/logger/MLogger.ts.meta +9 -0
- package/assets/core/lib/logger.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.d.ts +2729 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.d.ts.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.min.js +8 -0
- package/assets/core/lib/net/libs/proto/output/protobuf.min.js.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts +102 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts.meta +9 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.js +222 -0
- package/assets/core/lib/net/libs/proto/output/protobuf_custom.js.meta +9 -0
- package/assets/core/lib/net/libs/proto/output.meta +9 -0
- package/assets/core/lib/net/libs/proto/source/Cmd.proto +6 -0
- package/assets/core/lib/net/libs/proto/source/Cmd.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/UserLogin.proto +12 -0
- package/assets/core/lib/net/libs/proto/source/UserLogin.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/base.proto +24 -0
- package/assets/core/lib/net/libs/proto/source/base.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/command.proto +31 -0
- package/assets/core/lib/net/libs/proto/source/command.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto +13 -0
- package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto +26 -0
- package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/domain.meta +9 -0
- package/assets/core/lib/net/libs/proto/source/message/game_push.proto +23 -0
- package/assets/core/lib/net/libs/proto/source/message/game_push.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/message/game_request.proto +24 -0
- package/assets/core/lib/net/libs/proto/source/message/game_request.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/message/game_response.proto +24 -0
- package/assets/core/lib/net/libs/proto/source/message/game_response.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/message.meta +9 -0
- package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto +43 -0
- package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto.meta +11 -0
- package/assets/core/lib/net/libs/proto/source/push.meta +9 -0
- package/assets/core/lib/net/libs/proto/source.meta +12 -0
- package/assets/core/lib/net/libs/proto.meta +9 -0
- package/assets/core/lib/net/libs.meta +9 -0
- package/assets/core/lib/net/net/HttpManager.ts +307 -0
- package/assets/core/lib/net/net/HttpManager.ts.meta +9 -0
- package/assets/core/lib/net/net/NetInterface.ts +114 -0
- package/assets/core/lib/net/net/NetInterface.ts.meta +9 -0
- package/assets/core/lib/net/net/NetManager.ts +77 -0
- package/assets/core/lib/net/net/NetManager.ts.meta +9 -0
- package/assets/core/lib/net/net/NetNode.ts +471 -0
- package/assets/core/lib/net/net/NetNode.ts.meta +9 -0
- package/assets/core/lib/net/net/WebSock.ts +81 -0
- package/assets/core/lib/net/net/WebSock.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetChannelManager.ts +41 -0
- package/assets/core/lib/net/net/custom/NetChannelManager.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetConfig.ts +11 -0
- package/assets/core/lib/net/net/custom/NetConfig.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetErrorCode.ts +4 -0
- package/assets/core/lib/net/net/custom/NetErrorCode.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetGameTips.ts +53 -0
- package/assets/core/lib/net/net/custom/NetGameTips.ts.meta +9 -0
- package/assets/core/lib/net/net/custom/NetNodeGame.ts +105 -0
- package/assets/core/lib/net/net/custom/NetNodeGame.ts.meta +9 -0
- package/assets/core/lib/net/net/custom.meta +9 -0
- package/assets/core/lib/net/net/protocol/NetProtocolJson.ts +39 -0
- package/assets/core/lib/net/net/protocol/NetProtocolJson.ts.meta +9 -0
- package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts +85 -0
- package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts.meta +9 -0
- package/assets/core/lib/net/net/protocol.meta +9 -0
- package/assets/core/lib/net/net.meta +9 -0
- package/assets/core/lib/net/prompt.meta +9 -0
- package/assets/core/lib/net.meta +9 -0
- package/assets/core/lib/old/VM2.ts +619 -0
- package/assets/core/lib/old/VM2.ts.meta +9 -0
- package/assets/core/lib/old/ViewModel.ts +905 -0
- package/assets/core/lib/old/ViewModel.ts.meta +9 -0
- package/assets/core/lib/old/ViewSearch.ts +125 -0
- package/assets/core/lib/old/ViewSearch.ts.meta +9 -0
- package/assets/core/lib/old.meta +9 -0
- package/assets/core/lib/tabbar/TabBarComponent.ts +113 -0
- package/assets/core/lib/tabbar/TabBarComponent.ts.meta +9 -0
- package/assets/core/lib/tabbar/TabBarController.ts +86 -0
- package/assets/core/lib/tabbar/TabBarController.ts.meta +9 -0
- package/assets/core/lib/tabbar/TabBarItem.ts +52 -0
- package/assets/core/lib/tabbar/TabBarItem.ts.meta +9 -0
- package/assets/core/lib/tabbar.meta +9 -0
- package/assets/core/lib.meta +12 -0
- package/assets/core.meta +9 -0
- package/assets.meta +9 -0
- package/index.ts +3 -0
- package/index.ts.meta +9 -0
- package/package.json +19 -0
- package/package.json.meta +11 -0
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { _decorator, assetManager, ImageAsset, SpriteFrame, Texture2D, resources, log, instantiate, Node, isValid, error, Label, Sprite } from "cc";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DateTime = Mon Sep 26 2022 13:36:06 GMT+0800 (中国标准时间)
|
|
5
|
+
* Author = 柏白
|
|
6
|
+
*
|
|
7
|
+
* 声明式编程
|
|
8
|
+
* fp 函数式编程
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
12
|
+
|
|
13
|
+
/*********************************************** handlers ****************************************/
|
|
14
|
+
|
|
15
|
+
const handlers = {
|
|
16
|
+
get(target:object,key:string|symbol,receiver:object){
|
|
17
|
+
const res = Reflect.get(target,key,receiver);
|
|
18
|
+
track(target,key)
|
|
19
|
+
return isObject(res)? reactive(res) : res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/*********************************************** handlers ****************************************/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/*********************************************** reactive ****************************************/
|
|
28
|
+
|
|
29
|
+
const proxyMap = new WeakMap(); //缓存代理过的对象
|
|
30
|
+
const rawMap = new WeakMap(); //缓存被代理的对象
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function reactive(object:any){
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*********************************************** reactive ****************************************/
|
|
38
|
+
|
|
39
|
+
/*********************************************** effect ****************************************/
|
|
40
|
+
const targetMap = new WeakMap();
|
|
41
|
+
export let activeEffect = null;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function track(target: object, key: any) {
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
/*********************************************** effect ****************************************/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// type vforType = { component: any; prefab: string; data: string };
|
|
52
|
+
|
|
53
|
+
// type TargetMapItem = { type: string; property: string; key: string; handle: any };
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// /**
|
|
57
|
+
// * 数据绑定
|
|
58
|
+
// */
|
|
59
|
+
// const dataBindingContainer: {} = {};
|
|
60
|
+
|
|
61
|
+
// export const enum PropertyType {
|
|
62
|
+
// V_BIND = "vbind",
|
|
63
|
+
// V_FOR = "vfor",
|
|
64
|
+
// V_SHOW = "vshow",
|
|
65
|
+
// }
|
|
66
|
+
|
|
67
|
+
// export const reactive = function (target: any, obj: any) {
|
|
68
|
+
// let thiz = this;
|
|
69
|
+
// const handler = {
|
|
70
|
+
// get(target: object, propertyKey: PropertyKey, receiver?: any) {
|
|
71
|
+
// const result = Reflect.get(target, propertyKey);
|
|
72
|
+
// log(`get--${String(propertyKey)} -- ${result}`);
|
|
73
|
+
// return isObject(result) ? reactive.call(thiz, result) : result;
|
|
74
|
+
// },
|
|
75
|
+
// set(target: object, propertyKey: PropertyKey, value: any, receiver?: any) {
|
|
76
|
+
// log(`set--${String(propertyKey)}`);
|
|
77
|
+
// const extraInfo = { oldValue: target[propertyKey], newValue: value };
|
|
78
|
+
|
|
79
|
+
// const result = Reflect.set(target, propertyKey, value);
|
|
80
|
+
// emit.call(thiz, target, propertyKey, extraInfo);
|
|
81
|
+
// return result;
|
|
82
|
+
// },
|
|
83
|
+
|
|
84
|
+
// deleteProperty(target: object, propertyKey) {
|
|
85
|
+
// log(`${target}--${propertyKey}被刪除`);
|
|
86
|
+
// const result = Reflect.deleteProperty(target, propertyKey);
|
|
87
|
+
// emit.call(thiz, target, propertyKey, {});
|
|
88
|
+
// return result;
|
|
89
|
+
// },
|
|
90
|
+
// };
|
|
91
|
+
|
|
92
|
+
// return new Proxy(target, handler);
|
|
93
|
+
// };
|
|
94
|
+
|
|
95
|
+
// const emit_handle_vbind = function (element: TargetMapItem) {
|
|
96
|
+
// let { type, property, key, handle } = element;
|
|
97
|
+
|
|
98
|
+
// if ("string" == typeof handle) {
|
|
99
|
+
// let func = funcList[key];
|
|
100
|
+
// if (!func) {
|
|
101
|
+
// func = commonHandler;
|
|
102
|
+
// }
|
|
103
|
+
// func(this, handle)
|
|
104
|
+
// .then((result) => {
|
|
105
|
+
// this[property][key] = result;
|
|
106
|
+
// })
|
|
107
|
+
// .catch((e) => {
|
|
108
|
+
// log(e);
|
|
109
|
+
// });
|
|
110
|
+
// } else if ("function" == typeof handle) {
|
|
111
|
+
// this[property][key] = handle(this);
|
|
112
|
+
// } else {
|
|
113
|
+
// this[property][key] = handle;
|
|
114
|
+
// }
|
|
115
|
+
// };
|
|
116
|
+
|
|
117
|
+
// const emit_handle_vfor = function (element: TargetMapItem) {
|
|
118
|
+
// let { type, property, key, handle } = element;
|
|
119
|
+
// let func = vforHandler;
|
|
120
|
+
// func(this, property, handle)
|
|
121
|
+
// .then((result) => {
|
|
122
|
+
// log(result);
|
|
123
|
+
// })
|
|
124
|
+
// .catch((e) => {
|
|
125
|
+
// log(e);
|
|
126
|
+
// });
|
|
127
|
+
// };
|
|
128
|
+
|
|
129
|
+
// const emit_handle_vshow = function (element: TargetMapItem) {
|
|
130
|
+
// let { type, property, key, handle } = element;
|
|
131
|
+
// let func = vshowHandler;
|
|
132
|
+
// func(this, property, handle)
|
|
133
|
+
// .then((result) => {
|
|
134
|
+
// log(result);
|
|
135
|
+
// })
|
|
136
|
+
// .catch((e) => {
|
|
137
|
+
// log(e);
|
|
138
|
+
// });
|
|
139
|
+
// };
|
|
140
|
+
|
|
141
|
+
// const _emit_func = {
|
|
142
|
+
// vbind: emit_handle_vbind,
|
|
143
|
+
// vfor: emit_handle_vfor,
|
|
144
|
+
// vshow: emit_handle_vshow,
|
|
145
|
+
// };
|
|
146
|
+
|
|
147
|
+
// const emit = function (target, propertyKey, extraInfo) {
|
|
148
|
+
// let map = this.targetMap[propertyKey] || [];
|
|
149
|
+
// // map.push({
|
|
150
|
+
// // property: property,
|
|
151
|
+
// // key: key,
|
|
152
|
+
// // handle:handle
|
|
153
|
+
// // })
|
|
154
|
+
// for (let i = 0; i < map.length; i++) {
|
|
155
|
+
// const element = map[i];
|
|
156
|
+
// let { type, property, key, handle } = element;
|
|
157
|
+
// _emit_func[type].call(this, element);
|
|
158
|
+
// }
|
|
159
|
+
// };
|
|
160
|
+
|
|
161
|
+
// const addToTagetMap = function (type, targetKeyArr, propertyKey, key, handle) {
|
|
162
|
+
// if (targetKeyArr.length > 0) {
|
|
163
|
+
// for (let i = 0; i < targetKeyArr.length; i++) {
|
|
164
|
+
// const element = targetKeyArr[i];
|
|
165
|
+
// let map = this.targetMap[element] || [];
|
|
166
|
+
// map.push({
|
|
167
|
+
// type: type,
|
|
168
|
+
// property: propertyKey,
|
|
169
|
+
// key: key,
|
|
170
|
+
// handle: handle,
|
|
171
|
+
// });
|
|
172
|
+
// this.targetMap[element] = map;
|
|
173
|
+
// }
|
|
174
|
+
// }
|
|
175
|
+
// };
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
// const getHandleString = function (handle: any) {
|
|
179
|
+
// if ("function" == typeof handle) {
|
|
180
|
+
// handle = handle.toString();
|
|
181
|
+
// } else if ("string" == typeof handle) {
|
|
182
|
+
// } else {
|
|
183
|
+
// handle = String(handle);
|
|
184
|
+
// }
|
|
185
|
+
// return handle;
|
|
186
|
+
// };
|
|
187
|
+
|
|
188
|
+
// const getTargetKeyArray = function (handle: string) {
|
|
189
|
+
// let targetKeyArr = [];
|
|
190
|
+
// let keys = Object.keys(this.data);
|
|
191
|
+
// for (let i = 0; i < keys.length; i++) {
|
|
192
|
+
// const targetKey = keys[i];
|
|
193
|
+
// if (handle.indexOf(`${targetKey}.`) != -1) {
|
|
194
|
+
// targetKeyArr.push(targetKey);
|
|
195
|
+
// }
|
|
196
|
+
// if (handle.indexOf(`${targetKey}?.`) != -1) {
|
|
197
|
+
// targetKeyArr.push(targetKey);
|
|
198
|
+
// }
|
|
199
|
+
|
|
200
|
+
// if (handle == targetKey) {
|
|
201
|
+
// targetKeyArr.push(targetKey);
|
|
202
|
+
// }
|
|
203
|
+
|
|
204
|
+
// if (handle.indexOf(`\$\{${targetKey}\}`) != -1) {
|
|
205
|
+
// targetKeyArr.push(targetKey);
|
|
206
|
+
// }
|
|
207
|
+
// if (handle.indexOf(`data.${targetKey}`) != -1) {
|
|
208
|
+
// targetKeyArr.push(targetKey);
|
|
209
|
+
// }
|
|
210
|
+
// }
|
|
211
|
+
|
|
212
|
+
// return targetKeyArr;
|
|
213
|
+
// };
|
|
214
|
+
|
|
215
|
+
// const getDefaultKey = function (propertyKey) {
|
|
216
|
+
// let obj = this[propertyKey];
|
|
217
|
+
// if (obj instanceof Label) {
|
|
218
|
+
// return "string";
|
|
219
|
+
// } else if (obj instanceof Sprite) {
|
|
220
|
+
// return "spriteFrame";
|
|
221
|
+
// }
|
|
222
|
+
|
|
223
|
+
// return "string";
|
|
224
|
+
// };
|
|
225
|
+
|
|
226
|
+
// const track_vbind = function (iterator: any) {
|
|
227
|
+
// let { type, propertyKey, handler } = iterator;
|
|
228
|
+
|
|
229
|
+
// if ("string" == typeof handler) {
|
|
230
|
+
// let key = getDefaultKey.call(this, propertyKey);
|
|
231
|
+
// let handle = getHandleString(handler);
|
|
232
|
+
// let targetKeyArr = getTargetKeyArray.call(this, handle);
|
|
233
|
+
// addToTagetMap.call(this, type, targetKeyArr, propertyKey, key, handler);
|
|
234
|
+
// } else if ("function" == typeof handler) {
|
|
235
|
+
// let key = getDefaultKey.call(this, propertyKey);
|
|
236
|
+
// let handle = getHandleString(handler);
|
|
237
|
+
// let targetKeyArr = getTargetKeyArray.call(this, handle);
|
|
238
|
+
// addToTagetMap.call(this, type, targetKeyArr, propertyKey, key, handler);
|
|
239
|
+
// } else {
|
|
240
|
+
// for (const key in handler) {
|
|
241
|
+
// // log(handler,propertyKey,key)
|
|
242
|
+
// let handle = handler[key];
|
|
243
|
+
// handle = getHandleString(handle);
|
|
244
|
+
// let targetKeyArr = getTargetKeyArray.call(this, handle);
|
|
245
|
+
// addToTagetMap.call(this, type, targetKeyArr, propertyKey, key, handler[key]);
|
|
246
|
+
// }
|
|
247
|
+
// }
|
|
248
|
+
// };
|
|
249
|
+
|
|
250
|
+
// const track_vfor = function (iterator: any) {
|
|
251
|
+
// let { type, propertyKey, handler } = iterator;
|
|
252
|
+
|
|
253
|
+
// let key = "data";
|
|
254
|
+
// let handle = handler[key];
|
|
255
|
+
// handle = getHandleString(handle);
|
|
256
|
+
// let targetKeyArr = getTargetKeyArray.call(this, handle);
|
|
257
|
+
// addToTagetMap.call(this, type, targetKeyArr, propertyKey, key, handler);
|
|
258
|
+
// };
|
|
259
|
+
|
|
260
|
+
// const track_vshow = function (iterator: any) {
|
|
261
|
+
// let { type, propertyKey, handler } = iterator;
|
|
262
|
+
|
|
263
|
+
// let key = "show";
|
|
264
|
+
// let handle = handler;
|
|
265
|
+
// handle = getHandleString(handle);
|
|
266
|
+
// let targetKeyArr = getTargetKeyArray.call(this, handle);
|
|
267
|
+
// addToTagetMap.call(this, type, targetKeyArr, propertyKey, key, handler);
|
|
268
|
+
// };
|
|
269
|
+
|
|
270
|
+
// const _track_func = {
|
|
271
|
+
// vbind: track_vbind,
|
|
272
|
+
// vfor: track_vfor,
|
|
273
|
+
// vshow: track_vshow,
|
|
274
|
+
// };
|
|
275
|
+
|
|
276
|
+
// const track = function (iterator: any) {
|
|
277
|
+
// let { type, propertyKey, handler } = iterator;
|
|
278
|
+
// _track_func[type].call(this, iterator);
|
|
279
|
+
// };
|
|
280
|
+
|
|
281
|
+
// const inject_define_data = function (key, targetDataBinding) {
|
|
282
|
+
// //targetMap
|
|
283
|
+
// Object.defineProperty(this, "targetMap", { value: {}, configurable: true, writable: true, enumerable: true });
|
|
284
|
+
|
|
285
|
+
// //data 数据响应注入
|
|
286
|
+
// const iterator = "data";
|
|
287
|
+
// let newProerty = `_${iterator}`;
|
|
288
|
+
// let value = this[iterator];
|
|
289
|
+
// delete this[iterator];
|
|
290
|
+
// Object.defineProperty(this, newProerty, { value: value, configurable: true, writable: true, enumerable: true });
|
|
291
|
+
// this[iterator] = reactive.call(this, this[newProerty]);
|
|
292
|
+
// };
|
|
293
|
+
|
|
294
|
+
// const inject_vsearch = function (key, targetDataBinding) {
|
|
295
|
+
// let propertys = targetDataBinding["vsearch"] || [];
|
|
296
|
+
// for (const property of propertys) {
|
|
297
|
+
// let className = property.className;
|
|
298
|
+
// let tag = property.tag || property.name;
|
|
299
|
+
|
|
300
|
+
// let instance = vsearchHandler(this, tag);
|
|
301
|
+
// if (className.name != "Node") {
|
|
302
|
+
// instance = instance?.getComponent(className) ?? null;
|
|
303
|
+
// }
|
|
304
|
+
|
|
305
|
+
// if (instance == null) {
|
|
306
|
+
// error(`没有找到属性 ${key}->${property.name}`);
|
|
307
|
+
// continue;
|
|
308
|
+
// }
|
|
309
|
+
// this[property.name] = instance;
|
|
310
|
+
// }
|
|
311
|
+
// };
|
|
312
|
+
|
|
313
|
+
// const inject_track = function (key, targetDataBinding) {
|
|
314
|
+
// let protperty = targetDataBinding["protperty"] || [];
|
|
315
|
+
// for (const iterator of protperty) {
|
|
316
|
+
// track.call(this, iterator);
|
|
317
|
+
// }
|
|
318
|
+
// };
|
|
319
|
+
|
|
320
|
+
// const inject_emit_default = function (key, targetDataBinding) {
|
|
321
|
+
// let keys = Object.keys(this.data);
|
|
322
|
+
// for (let i = 0; i < keys.length; i++) {
|
|
323
|
+
// const targetKey = keys[i];
|
|
324
|
+
// if (this.data[targetKey] != null) {
|
|
325
|
+
// emit.call(this, this.data, targetKey, null);
|
|
326
|
+
// }
|
|
327
|
+
// }
|
|
328
|
+
// };
|
|
329
|
+
|
|
330
|
+
// const _inject_func = [inject_define_data, inject_vsearch, inject_track, inject_emit_default];
|
|
331
|
+
|
|
332
|
+
// /**
|
|
333
|
+
// * ViewModel
|
|
334
|
+
// * @param target
|
|
335
|
+
// */
|
|
336
|
+
// export function vm(target: any) {
|
|
337
|
+
// const onLoad = target.prototype.onLoad;
|
|
338
|
+
// /**
|
|
339
|
+
// * 重载onload 注入更新
|
|
340
|
+
// */
|
|
341
|
+
// target.prototype.onLoad = function () {
|
|
342
|
+
// let classKey = `${this.constructor.name}`;
|
|
343
|
+
// let targetDataBinding = dataBindingContainer[classKey] || {};
|
|
344
|
+
|
|
345
|
+
// for (const func of _inject_func) {
|
|
346
|
+
// func.call(this, classKey, targetDataBinding);
|
|
347
|
+
// }
|
|
348
|
+
|
|
349
|
+
// //调用之前的onload
|
|
350
|
+
// onLoad?.call(this);
|
|
351
|
+
// };
|
|
352
|
+
// }
|
|
353
|
+
|
|
354
|
+
// export function vshow(handler: any) {
|
|
355
|
+
// return (target: any, propertyKey: string) => {
|
|
356
|
+
// let key = `${target.constructor.name}`;
|
|
357
|
+
// let targetDataBinding = dataBindingContainer[key] || {};
|
|
358
|
+
// let protperty = targetDataBinding["protperty"] || [];
|
|
359
|
+
// protperty.push({
|
|
360
|
+
// type: PropertyType.V_SHOW,
|
|
361
|
+
// propertyKey: propertyKey,
|
|
362
|
+
// handler: handler,
|
|
363
|
+
// });
|
|
364
|
+
// targetDataBinding["protperty"] = protperty;
|
|
365
|
+
// dataBindingContainer[key] = targetDataBinding;
|
|
366
|
+
// };
|
|
367
|
+
// }
|
|
368
|
+
|
|
369
|
+
// /**
|
|
370
|
+
// * 通过 属性名称 或者标签查询对应的node 或组件
|
|
371
|
+
// * @example
|
|
372
|
+
// * @vsearch(Sprite)
|
|
373
|
+
// * icon:Label = null;
|
|
374
|
+
// *
|
|
375
|
+
// * @vsearch(Label,"aa")
|
|
376
|
+
// * version:Label = null;
|
|
377
|
+
// *
|
|
378
|
+
// * @param className 组件名称
|
|
379
|
+
// * @param tag 名称
|
|
380
|
+
// * @returns
|
|
381
|
+
// */
|
|
382
|
+
// export function vsearch(className: any, tag?: string) {
|
|
383
|
+
// return (target: any, propertyKey: string) => {
|
|
384
|
+
// let key = `${target.constructor.name}`;
|
|
385
|
+
// let targetDataBinding = dataBindingContainer[key] || {};
|
|
386
|
+
// let propertys = targetDataBinding["vsearch"] || [];
|
|
387
|
+
// propertys.push({ tag: tag, name: propertyKey, className: className });
|
|
388
|
+
// targetDataBinding["vsearch"] = propertys;
|
|
389
|
+
// dataBindingContainer[key] = targetDataBinding;
|
|
390
|
+
// };
|
|
391
|
+
// }
|
|
392
|
+
|
|
393
|
+
// /**
|
|
394
|
+
// *循环添加预制件到容器中,一般是ScrollView Layout ToggleGrop
|
|
395
|
+
// *@example
|
|
396
|
+
// * @vfor({ prefab: "itemPrefab", component: Item, data: "goodsList" })
|
|
397
|
+
// * @property(Node)
|
|
398
|
+
// * content: Node = null;
|
|
399
|
+
// *
|
|
400
|
+
// * @param handler
|
|
401
|
+
// * @returns
|
|
402
|
+
// */
|
|
403
|
+
// export function vfor(handler: vforType) {
|
|
404
|
+
// return (target: any, propertyKey: string) => {
|
|
405
|
+
// let key = `${target.constructor.name}`;
|
|
406
|
+
// let targetDataBinding = dataBindingContainer[key] || {};
|
|
407
|
+
// let protperty = targetDataBinding["protperty"] || [];
|
|
408
|
+
// protperty.push({
|
|
409
|
+
// type: PropertyType.V_FOR,
|
|
410
|
+
// propertyKey: propertyKey,
|
|
411
|
+
// handler: handler,
|
|
412
|
+
// });
|
|
413
|
+
// targetDataBinding["protperty"] = protperty;
|
|
414
|
+
// dataBindingContainer[key] = targetDataBinding;
|
|
415
|
+
// };
|
|
416
|
+
// }
|
|
417
|
+
|
|
418
|
+
// /**
|
|
419
|
+
// * 绑定数据
|
|
420
|
+
// * @example
|
|
421
|
+
// * 绑定string
|
|
422
|
+
// * @vbind({string:"tt.aa"})
|
|
423
|
+
// * @property(Label)
|
|
424
|
+
// * aaa: Label = null;
|
|
425
|
+
// *
|
|
426
|
+
// * @vbind({string:"${tt.aa}米/${bb.cc}亩"})
|
|
427
|
+
// * @property(Label)
|
|
428
|
+
// * aaa: Label = null;
|
|
429
|
+
// *
|
|
430
|
+
// * 绑定精灵图片
|
|
431
|
+
// * @vbind({spriteFrame:"tt.aa"})
|
|
432
|
+
// * @property(Sprite)
|
|
433
|
+
// * aaa: Sprite = null;
|
|
434
|
+
// *
|
|
435
|
+
// * @vbind({spriteFrame:"${tt.aa}"})
|
|
436
|
+
// * @property(Sprite)
|
|
437
|
+
// * aaa: Sprite = null;
|
|
438
|
+
// *
|
|
439
|
+
// * 绑定处理器
|
|
440
|
+
// *
|
|
441
|
+
// *
|
|
442
|
+
// * @param handler
|
|
443
|
+
// * @returns
|
|
444
|
+
// */
|
|
445
|
+
// export function vbind(handler: any) {
|
|
446
|
+
// return (target: any, propertyKey: string) => {
|
|
447
|
+
// let key = `${target.constructor.name}`;
|
|
448
|
+
// let targetDataBinding = dataBindingContainer[key] || {};
|
|
449
|
+
// let protperty = targetDataBinding["protperty"] || [];
|
|
450
|
+
// protperty.push({
|
|
451
|
+
// type: PropertyType.V_BIND,
|
|
452
|
+
// propertyKey: propertyKey,
|
|
453
|
+
// handler: handler,
|
|
454
|
+
// });
|
|
455
|
+
// targetDataBinding["protperty"] = protperty;
|
|
456
|
+
// dataBindingContainer[key] = targetDataBinding;
|
|
457
|
+
// };
|
|
458
|
+
// }
|
|
459
|
+
|
|
460
|
+
// /**
|
|
461
|
+
// * 字符串处理
|
|
462
|
+
// * @param target
|
|
463
|
+
// * @param data
|
|
464
|
+
// * @returns
|
|
465
|
+
// */
|
|
466
|
+
// function stringHandler(target: any, data: string): Promise<string> {
|
|
467
|
+
// return new Promise((res, rej) => {
|
|
468
|
+
// try {
|
|
469
|
+
// if (data.indexOf("{") != -1) {
|
|
470
|
+
// data = data.replace(/{/g, "{target.data.");
|
|
471
|
+
// } else {
|
|
472
|
+
// data = "${target.data." + data + "}";
|
|
473
|
+
// }
|
|
474
|
+
|
|
475
|
+
// let funcstr = `(target)=>\`${data}\``;
|
|
476
|
+
// let func = eval(funcstr);
|
|
477
|
+
// let result = func.call(target, target);
|
|
478
|
+
// res(result);
|
|
479
|
+
// } catch (e) {
|
|
480
|
+
// rej("失败");
|
|
481
|
+
// }
|
|
482
|
+
// });
|
|
483
|
+
// }
|
|
484
|
+
|
|
485
|
+
// /**
|
|
486
|
+
// * 图片处理
|
|
487
|
+
// * @param target
|
|
488
|
+
// * @param data
|
|
489
|
+
// * @returns
|
|
490
|
+
// */
|
|
491
|
+
// function spriteFrameHandler(target: any, data: string) {
|
|
492
|
+
// return new Promise(async (res, rej) => {
|
|
493
|
+
// let url = await stringHandler(target, data);
|
|
494
|
+
// if (url.startsWith("http")) {
|
|
495
|
+
// assetManager.loadRemote(url, { ext: ".png" }, (error: Error, data: ImageAsset) => {
|
|
496
|
+
// if (!!error) {
|
|
497
|
+
// rej(`${url}加载失败!`);
|
|
498
|
+
// return;
|
|
499
|
+
// }
|
|
500
|
+
|
|
501
|
+
// const spriteFrame = new SpriteFrame();
|
|
502
|
+
// spriteFrame.packable = true;
|
|
503
|
+
// const texture = new Texture2D();
|
|
504
|
+
// texture.image = data;
|
|
505
|
+
// spriteFrame.texture = texture;
|
|
506
|
+
// res(spriteFrame);
|
|
507
|
+
// });
|
|
508
|
+
// } else {
|
|
509
|
+
// resources.load(url + "/spriteFrame", SpriteFrame, (e: Error, spriteFrame: SpriteFrame) => {
|
|
510
|
+
// if (!!e) {
|
|
511
|
+
// rej(`${url}加载失败!`);
|
|
512
|
+
// return;
|
|
513
|
+
// }
|
|
514
|
+
// res(spriteFrame);
|
|
515
|
+
// });
|
|
516
|
+
// }
|
|
517
|
+
// });
|
|
518
|
+
// }
|
|
519
|
+
|
|
520
|
+
// /**
|
|
521
|
+
// *
|
|
522
|
+
// * @param target
|
|
523
|
+
// * @param data
|
|
524
|
+
// * @returns
|
|
525
|
+
// */
|
|
526
|
+
// function commonHandler(target: any, data: string): Promise<any> {
|
|
527
|
+
// return new Promise((res, rej) => {
|
|
528
|
+
// if (data.indexOf("{") != -1) {
|
|
529
|
+
// data = data.replace(/\${/g, "target.data.");
|
|
530
|
+
// data = data.replace(/}/g, "");
|
|
531
|
+
// } else {
|
|
532
|
+
// data = "target.data." + data;
|
|
533
|
+
// }
|
|
534
|
+
|
|
535
|
+
// let funcstr = `(target)=>${data}`;
|
|
536
|
+
// let func = eval(funcstr);
|
|
537
|
+
// let result = func.call(target, target);
|
|
538
|
+
// res(result);
|
|
539
|
+
// });
|
|
540
|
+
// }
|
|
541
|
+
|
|
542
|
+
// /**
|
|
543
|
+
// *
|
|
544
|
+
// * @param target
|
|
545
|
+
// * @param property
|
|
546
|
+
// * @param handle
|
|
547
|
+
// * @returns
|
|
548
|
+
// */
|
|
549
|
+
// function vshowHandler(target: any, property: string, handle: any) {
|
|
550
|
+
// return new Promise(async (res, rej) => {
|
|
551
|
+
// try {
|
|
552
|
+
// let propertyIns = target[property];
|
|
553
|
+
|
|
554
|
+
// if (propertyIns instanceof Node) {
|
|
555
|
+
// propertyIns.active = await commonHandler(target, handle);
|
|
556
|
+
// } else {
|
|
557
|
+
// propertyIns.node.active = await commonHandler(target, handle);
|
|
558
|
+
// }
|
|
559
|
+
// res(1);
|
|
560
|
+
// } catch (e) {
|
|
561
|
+
// rej(e);
|
|
562
|
+
// }
|
|
563
|
+
// });
|
|
564
|
+
// }
|
|
565
|
+
|
|
566
|
+
// /**
|
|
567
|
+
// *
|
|
568
|
+
// * @param target
|
|
569
|
+
// * @param property
|
|
570
|
+
// * @param handle
|
|
571
|
+
// * @returns
|
|
572
|
+
// */
|
|
573
|
+
// function vforHandler(target: any, property: string, handle: vforType) {
|
|
574
|
+
// return new Promise(async (res, rej) => {
|
|
575
|
+
// try {
|
|
576
|
+
// let { component, prefab, data } = handle;
|
|
577
|
+
|
|
578
|
+
// let dataIns: any[] = await commonHandler(target, data);
|
|
579
|
+
// let propertyIns: Node = target[property];
|
|
580
|
+
|
|
581
|
+
// propertyIns.removeAllChildren();
|
|
582
|
+
// for (let i = 0, length = dataIns.length; i < length; i++) {
|
|
583
|
+
// const element = dataIns[i];
|
|
584
|
+
// let inc = instantiate(target[prefab]);
|
|
585
|
+
// propertyIns.addChild(inc);
|
|
586
|
+
// inc.getComponent(component).prefabData = element;
|
|
587
|
+
// }
|
|
588
|
+
// res(1);
|
|
589
|
+
// } catch (e) {
|
|
590
|
+
// rej(e);
|
|
591
|
+
// }
|
|
592
|
+
// });
|
|
593
|
+
// }
|
|
594
|
+
|
|
595
|
+
// function vsearchHandler(target: any, parent: any, uiName: string = null) {
|
|
596
|
+
// if (typeof parent == "string") {
|
|
597
|
+
// uiName = parent;
|
|
598
|
+
// parent = target.node;
|
|
599
|
+
// }
|
|
600
|
+
|
|
601
|
+
// if (parent.name === uiName) {
|
|
602
|
+
// return parent;
|
|
603
|
+
// }
|
|
604
|
+
|
|
605
|
+
// let children = parent.children;
|
|
606
|
+
// for (const key in children) {
|
|
607
|
+
// if (!isValid(children[key])) continue;
|
|
608
|
+
// let resultNode = vsearchHandler(target, children[key], uiName);
|
|
609
|
+
// if (resultNode) {
|
|
610
|
+
// return resultNode;
|
|
611
|
+
// }
|
|
612
|
+
// }
|
|
613
|
+
// }
|
|
614
|
+
|
|
615
|
+
// const funcList = {
|
|
616
|
+
// common: commonHandler,
|
|
617
|
+
// string: stringHandler,
|
|
618
|
+
// spriteFrame: spriteFrameHandler,
|
|
619
|
+
// };
|