@cicctencent/low-code-simulate-base 0.0.0-stage → 1.1.10
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/README.md +1 -3
- package/__tests__/plugin.spec.ts +40 -0
- package/__tests__/utils.transform.test.ts +37 -0
- package/api-extractor.json +36 -0
- package/build/md.js +25 -0
- package/dist/VCComponent.d.ts +5 -0
- package/dist/VCComponent.js +91 -0
- package/dist/domain/BaseProjectDomain.d.ts +389 -0
- package/dist/domain/BaseProjectDomain.js +1305 -0
- package/dist/domain/ComponentManager.d.ts +78 -0
- package/dist/domain/ComponentManager.js +293 -0
- package/dist/domain/DataHistoryDomain.d.ts +53 -0
- package/dist/domain/DataHistoryDomain.js +110 -0
- package/dist/domain/PreviewDomain.d.ts +208 -0
- package/dist/domain/PreviewDomain.js +490 -0
- package/dist/domain/ProjectDomain.d.ts +209 -0
- package/dist/domain/ProjectDomain.js +138 -0
- package/dist/event/generateEventHandler.d.ts +21 -0
- package/dist/event/generateEventHandler.js +218 -0
- package/dist/event/generateEventSchema.d.ts +123 -0
- package/dist/event/generateEventSchema.js +342 -0
- package/dist/event/register.d.ts +56 -0
- package/dist/event/register.js +207 -0
- package/dist/index.d.ts +1369 -0
- package/dist/index.js +28 -0
- package/dist/plugin/onH5PageValidate.d.ts +7 -0
- package/dist/plugin/onH5PageValidate.js +178 -0
- package/dist/plugin/onPlaceholder.d.ts +6 -0
- package/dist/plugin/onPlaceholder.js +68 -0
- package/dist/plugin/subscribeInsertUploadList.d.ts +6 -0
- package/dist/plugin/subscribeInsertUploadList.js +49 -0
- package/dist/plugin/subscribeSetTitle.d.ts +6 -0
- package/dist/plugin/subscribeSetTitle.js +16 -0
- package/dist/plugin/subscribeTransformComponentMeta.d.ts +14 -0
- package/dist/plugin/subscribeTransformComponentMeta.js +31 -0
- package/dist/plugin/subscribeValidateField.d.ts +7 -0
- package/dist/plugin/subscribeValidateField.js +57 -0
- package/dist/plugin/subscribeValidateUpload.d.ts +6 -0
- package/dist/plugin/subscribeValidateUpload.js +92 -0
- package/dist/utils/base64.d.ts +14 -0
- package/dist/utils/base64.js +14 -0
- package/dist/utils/buildInVariable.d.ts +61 -0
- package/dist/utils/buildInVariable.js +216 -0
- package/dist/utils/dom.d.ts +14 -0
- package/dist/utils/dom.js +19 -0
- package/dist/utils/index.d.ts +55 -0
- package/dist/utils/index.js +201 -0
- package/dist/utils/transform.d.ts +39 -0
- package/dist/utils/transform.js +191 -0
- package/dist/utils/validate.d.ts +7 -0
- package/dist/utils/validate.js +18 -0
- package/docs/.api/low-code-simulate-base.api.json +8450 -0
- package/jest.config.ts +20 -0
- package/package.json +45 -4
- package/src/VCComponent.ts +118 -0
- package/src/domain/BaseProjectDomain.ts +1341 -0
- package/src/domain/ComponentManager.ts +241 -0
- package/src/domain/DataHistoryDomain.ts +102 -0
- package/src/domain/PreviewDomain.ts +424 -0
- package/src/domain/ProjectDomain.ts +244 -0
- package/src/event/generateEventHandler.ts +162 -0
- package/src/event/generateEventSchema.ts +371 -0
- package/src/event/register.ts +181 -0
- package/src/index.ts +61 -0
- package/src/plugin/onH5PageValidate.ts +179 -0
- package/src/plugin/onPlaceholder.ts +71 -0
- package/src/plugin/subscribeInsertUploadList.ts +51 -0
- package/src/plugin/subscribeSetTitle.ts +18 -0
- package/src/plugin/subscribeTransformComponentMeta.ts +38 -0
- package/src/plugin/subscribeValidateField.ts +65 -0
- package/src/plugin/subscribeValidateUpload.ts +116 -0
- package/src/utils/base64.ts +17 -0
- package/src/utils/buildInVariable.ts +157 -0
- package/src/utils/dom.ts +30 -0
- package/src/utils/index.ts +194 -0
- package/src/utils/transform.ts +171 -0
- package/src/utils/validate.ts +19 -0
- package/temp/low-code-simulate-base.api.md +597 -0
- package/test/plugin.test.ts +4 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
- package/tsconfig.test.json +14 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { IEventDescriptor, ICustomEventDescriptor, InativeEventTypeDescriptor } from '@cicctencent/low-code-core';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* 关键:初始化注册表中所有的事件的表单配置 json-schema
|
|
5
|
+
* @param extraEvent - 添加的事件类型
|
|
6
|
+
* @param ignoredEvent - 过滤的事件类型
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function initAllEventsFormSchema(extraEvent?: InativeEventTypeDescriptor[], ignoredEvent?: string[]): {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
list: {
|
|
13
|
+
type: string;
|
|
14
|
+
'ui:hidden': boolean;
|
|
15
|
+
items: {
|
|
16
|
+
type: string;
|
|
17
|
+
required: string[];
|
|
18
|
+
properties: any;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
* @param eventDescriptors - eventDescriptors
|
|
26
|
+
* @param extraEvent - extraEvent 扩展事件
|
|
27
|
+
* @param ignoredEvent - ignoredEvent 过滤事件
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function initEventsFormSchema(eventDescriptors: Array<IEventDescriptor | ICustomEventDescriptor>, extraEvent?: InativeEventTypeDescriptor[], ignoredEvent?: string[]): {
|
|
31
|
+
type: string;
|
|
32
|
+
properties: {
|
|
33
|
+
list: {
|
|
34
|
+
type: string;
|
|
35
|
+
'ui:hidden': boolean;
|
|
36
|
+
items: {
|
|
37
|
+
type: string;
|
|
38
|
+
required: string[];
|
|
39
|
+
properties: any;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
* 初始化事件中间件
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export declare function initMiddlewareFormSchema(): {
|
|
50
|
+
type: string;
|
|
51
|
+
properties: {
|
|
52
|
+
middlewares: {
|
|
53
|
+
title: string;
|
|
54
|
+
type: string;
|
|
55
|
+
'x-component': string;
|
|
56
|
+
'x-decorator-props': {
|
|
57
|
+
layout: string;
|
|
58
|
+
};
|
|
59
|
+
items: {
|
|
60
|
+
type: string;
|
|
61
|
+
properties: {
|
|
62
|
+
_btn: {
|
|
63
|
+
type: string;
|
|
64
|
+
'x-component': string;
|
|
65
|
+
properties: {
|
|
66
|
+
remove: {
|
|
67
|
+
type: string;
|
|
68
|
+
'x-component': string;
|
|
69
|
+
};
|
|
70
|
+
sort: {
|
|
71
|
+
type: string;
|
|
72
|
+
'x-component': string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
name: {
|
|
77
|
+
title: string;
|
|
78
|
+
type: string;
|
|
79
|
+
'x-component-props': {
|
|
80
|
+
placeholder: string;
|
|
81
|
+
};
|
|
82
|
+
enum: any;
|
|
83
|
+
'x-reactions': string;
|
|
84
|
+
};
|
|
85
|
+
options: {
|
|
86
|
+
type: string;
|
|
87
|
+
properties: {};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
'x-data': {
|
|
91
|
+
addButtonTitle: string;
|
|
92
|
+
addButtonType: string;
|
|
93
|
+
addButtonSize: string;
|
|
94
|
+
addButtonPlain: boolean;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* @public
|
|
102
|
+
* 生成事件json schema
|
|
103
|
+
* @param eventDescriptors - 事件信息
|
|
104
|
+
* @param ignoredEvent - 过滤事件
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
export declare function generateEventsFormSchema(eventDescriptors: Array<IEventDescriptor | ICustomEventDescriptor>, extraEvent?: InativeEventTypeDescriptor[], ignoredEvent?: string[]): {
|
|
108
|
+
type: string;
|
|
109
|
+
'ui:hidden': boolean;
|
|
110
|
+
items: {
|
|
111
|
+
type: string;
|
|
112
|
+
required: string[];
|
|
113
|
+
properties: any;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* @public
|
|
118
|
+
* 生成事件属性json schema
|
|
119
|
+
* @param eventDescriptors - 事件描述
|
|
120
|
+
* @param ignoredEvent - 过滤事件
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
export declare function generateEventProperties(eventDescriptors: Array<IEventDescriptor | ICustomEventDescriptor>, extraEvent?: InativeEventTypeDescriptor[], ignoredEvent?: string[]): any;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
import { UniqueType } from '@cicctencent/low-code-core';
|
|
38
|
+
import { eventRegistry, eventMiddlewareRegistry, nativeEventTypeRegistry, } from './register';
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
* 关键:初始化注册表中所有的事件的表单配置 json-schema
|
|
42
|
+
* @param extraEvent - 添加的事件类型
|
|
43
|
+
* @param ignoredEvent - 过滤的事件类型
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export function initAllEventsFormSchema(extraEvent, ignoredEvent) {
|
|
47
|
+
var eventDescriptors = Object.values(eventRegistry || {});
|
|
48
|
+
return {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
list: generateEventsFormSchema(eventDescriptors, extraEvent, ignoredEvent),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @public
|
|
57
|
+
* @param eventDescriptors - eventDescriptors
|
|
58
|
+
* @param extraEvent - extraEvent 扩展事件
|
|
59
|
+
* @param ignoredEvent - ignoredEvent 过滤事件
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
export function initEventsFormSchema(eventDescriptors, extraEvent, ignoredEvent) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
list: generateEventsFormSchema(eventDescriptors, extraEvent, ignoredEvent),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @public
|
|
72
|
+
* 初始化事件中间件
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
export function initMiddlewareFormSchema() {
|
|
76
|
+
return {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
middlewares: generateEventMiddlewareFormSchema(),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @public
|
|
85
|
+
* 生成事件json schema
|
|
86
|
+
* @param eventDescriptors - 事件信息
|
|
87
|
+
* @param ignoredEvent - 过滤事件
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
export function generateEventsFormSchema(eventDescriptors, extraEvent, ignoredEvent) {
|
|
91
|
+
var properties = generateEventProperties(eventDescriptors, extraEvent, ignoredEvent);
|
|
92
|
+
return {
|
|
93
|
+
type: 'array',
|
|
94
|
+
// title: '事件配置',
|
|
95
|
+
'ui:hidden': properties === null,
|
|
96
|
+
items: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
required: ['type'],
|
|
99
|
+
properties: properties,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @public
|
|
105
|
+
* 生成事件属性json schema
|
|
106
|
+
* @param eventDescriptors - 事件描述
|
|
107
|
+
* @param ignoredEvent - 过滤事件
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
export function generateEventProperties(eventDescriptors, extraEvent, ignoredEvent) {
|
|
111
|
+
if (Array.isArray(eventDescriptors) && eventDescriptors.length > 0) {
|
|
112
|
+
var targetProperties = {};
|
|
113
|
+
var customEventDescriptors = eventDescriptors.filter(function (it) { return typeof it.handler !== 'function'; });
|
|
114
|
+
var nativeEventDeclarations = Object.values(nativeEventTypeRegistry);
|
|
115
|
+
var types = __spreadArray(__spreadArray([], __read(nativeEventDeclarations), false), __read(customEventDescriptors), false);
|
|
116
|
+
if (ignoredEvent && ignoredEvent.length) {
|
|
117
|
+
types = types.filter(function (type) { return !ignoredEvent.includes(type.name); });
|
|
118
|
+
}
|
|
119
|
+
if (extraEvent && extraEvent.length) {
|
|
120
|
+
types.push.apply(types, __spreadArray([], __read(extraEvent), false));
|
|
121
|
+
}
|
|
122
|
+
targetProperties['type'] = {
|
|
123
|
+
title: '事件类型',
|
|
124
|
+
enum: types.map(function (it) { return it.name; }),
|
|
125
|
+
enumNames: types.map(function (it) { return it.label; }),
|
|
126
|
+
};
|
|
127
|
+
var middlewareConf = generateEventMiddlewareFormSchema();
|
|
128
|
+
if (middlewareConf !== null) {
|
|
129
|
+
targetProperties['middlewares'] = middlewareConf;
|
|
130
|
+
}
|
|
131
|
+
// 获取name配置
|
|
132
|
+
var nameConfig = getEventHandleName(eventDescriptors);
|
|
133
|
+
// 以下是新代码
|
|
134
|
+
targetProperties['handler'] = {
|
|
135
|
+
title: '事件名称',
|
|
136
|
+
type: 'object',
|
|
137
|
+
'x-reactions': {
|
|
138
|
+
dependencies: ['type'],
|
|
139
|
+
fulfill: {
|
|
140
|
+
state: {
|
|
141
|
+
// 事件类型变化,将事件名称清空
|
|
142
|
+
value: '{{$self.value = {}}}',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
// oneOf: options,
|
|
147
|
+
properties: {
|
|
148
|
+
name: nameConfig,
|
|
149
|
+
options: getEventOptions(eventDescriptors, nameConfig),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
return targetProperties;
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @public
|
|
158
|
+
* 获取事件name
|
|
159
|
+
* @param data - 事件原始数据
|
|
160
|
+
* @returns
|
|
161
|
+
*/
|
|
162
|
+
function getEventHandleName(data) {
|
|
163
|
+
var enums = [];
|
|
164
|
+
data.forEach(function (it) {
|
|
165
|
+
var _a;
|
|
166
|
+
var name = getEventNameByDescriptor(it);
|
|
167
|
+
enums.push({
|
|
168
|
+
value: name,
|
|
169
|
+
label: it.title,
|
|
170
|
+
isNoLogin: (_a = it.isNoLogin) !== null && _a !== void 0 ? _a : false,
|
|
171
|
+
eventType: it.eventType,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
type: 'string',
|
|
176
|
+
title: '事件名称',
|
|
177
|
+
enum: enums,
|
|
178
|
+
required: true,
|
|
179
|
+
'x-reactions': {
|
|
180
|
+
dependencies: ['..type'],
|
|
181
|
+
fulfill: {
|
|
182
|
+
schema: {
|
|
183
|
+
'x-component-props.options': '{{filterOptions($deps[0])}}',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* @public
|
|
191
|
+
* 获取事件options组
|
|
192
|
+
* @param data - 事件原始数据
|
|
193
|
+
* @param nameConfig - 根据name配置设置联动
|
|
194
|
+
* @returns
|
|
195
|
+
*/
|
|
196
|
+
function getEventOptions(data, nameConfig) {
|
|
197
|
+
var propertiesGroups = {};
|
|
198
|
+
data.forEach(function (it, index) {
|
|
199
|
+
var desc = getEventOptionsPropertiesByDescriptor(it);
|
|
200
|
+
propertiesGroups["".concat(nameConfig.enum[index].value)] = {
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: Object.assign({
|
|
203
|
+
buryReportName: {
|
|
204
|
+
default: '',
|
|
205
|
+
title: '埋点名',
|
|
206
|
+
description: '输入埋点名,系统将补全埋点信息:例 运营.可视化创造.输入埋点名.点击',
|
|
207
|
+
type: 'string',
|
|
208
|
+
required: true,
|
|
209
|
+
unique: UniqueType.page,
|
|
210
|
+
'x-validator': {
|
|
211
|
+
asyncValidator: true,
|
|
212
|
+
type: 'buryReportName',
|
|
213
|
+
},
|
|
214
|
+
'x-component-props': {
|
|
215
|
+
description: '埋点名称应为:大/小写字母、数字、中文、横杠、下划线及其组合且不可重复',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
}, desc),
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
return propertiesGroups;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @public
|
|
225
|
+
* 生成中间件json schema
|
|
226
|
+
* @returns
|
|
227
|
+
*/
|
|
228
|
+
function generateEventMiddlewareFormSchema() {
|
|
229
|
+
var eventMiddlewareDescriptors = Object.values(eventMiddlewareRegistry);
|
|
230
|
+
if (eventMiddlewareDescriptors.length === 0)
|
|
231
|
+
return null;
|
|
232
|
+
var middlewareDes = [];
|
|
233
|
+
return {
|
|
234
|
+
title: '前置执行程序',
|
|
235
|
+
type: 'array',
|
|
236
|
+
'x-component': 'ArrayItems',
|
|
237
|
+
'x-decorator-props': {
|
|
238
|
+
layout: 'vertical',
|
|
239
|
+
},
|
|
240
|
+
items: {
|
|
241
|
+
type: 'object',
|
|
242
|
+
properties: {
|
|
243
|
+
_btn: {
|
|
244
|
+
type: 'void',
|
|
245
|
+
'x-component': 'Row',
|
|
246
|
+
properties: {
|
|
247
|
+
remove: {
|
|
248
|
+
type: 'void',
|
|
249
|
+
'x-component': 'ArrayItems.Remove',
|
|
250
|
+
},
|
|
251
|
+
sort: {
|
|
252
|
+
type: 'void',
|
|
253
|
+
'x-component': 'ArrayItems.SortHandle',
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
name: {
|
|
258
|
+
title: '前置执行程序',
|
|
259
|
+
type: 'string',
|
|
260
|
+
'x-component-props': {
|
|
261
|
+
placeholder: '请添加(执行顺序为列表顺序,可拖动修改)',
|
|
262
|
+
},
|
|
263
|
+
enum: getMiddlewareNameConfig(eventMiddlewareDescriptors),
|
|
264
|
+
'x-reactions': '{{middlewareFilter}}',
|
|
265
|
+
},
|
|
266
|
+
options: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: getMiddlewareOptionsConfig(eventMiddlewareDescriptors),
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
'x-data': {
|
|
272
|
+
addButtonTitle: '添加前置执行程序配置组',
|
|
273
|
+
addButtonType: 'primary',
|
|
274
|
+
addButtonSize: 'small',
|
|
275
|
+
addButtonPlain: true,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* @public
|
|
282
|
+
* 获取中间件name配置
|
|
283
|
+
*/
|
|
284
|
+
function getMiddlewareNameConfig(eventMiddlewareDescriptors) {
|
|
285
|
+
return eventMiddlewareDescriptors.map(function (it) {
|
|
286
|
+
var _a;
|
|
287
|
+
return {
|
|
288
|
+
label: it.title,
|
|
289
|
+
value: it.name || it.middleware.name,
|
|
290
|
+
isNoLogin: (_a = it === null || it === void 0 ? void 0 : it.isNoLogin) !== null && _a !== void 0 ? _a : false,
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @public
|
|
296
|
+
* 获取中间件options 参数
|
|
297
|
+
* @param eventMiddlewareDescriptors - 中间件内容
|
|
298
|
+
* @returns
|
|
299
|
+
*/
|
|
300
|
+
function getMiddlewareOptionsConfig(eventMiddlewareDescriptors) {
|
|
301
|
+
var res = {};
|
|
302
|
+
eventMiddlewareDescriptors.forEach(function (it, index) {
|
|
303
|
+
res['_' + it.name] = {
|
|
304
|
+
type: 'void',
|
|
305
|
+
'x-reactions': {
|
|
306
|
+
dependencies: ['..name'],
|
|
307
|
+
fulfill: {
|
|
308
|
+
schema: {
|
|
309
|
+
'x-visible': "{{$deps[0] == '".concat(it.name, "' }}"),
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
properties: it.parametersDescriptor,
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
return __assign({}, res);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @public
|
|
320
|
+
* @param descriptor - 描述
|
|
321
|
+
* @returns
|
|
322
|
+
*/
|
|
323
|
+
function getEventNameByDescriptor(descriptor) {
|
|
324
|
+
return (descriptor['name'] ||
|
|
325
|
+
(typeof descriptor['handler'] === 'string'
|
|
326
|
+
? descriptor['handler']
|
|
327
|
+
: typeof descriptor['handler'] === 'function'
|
|
328
|
+
? descriptor['handler'].name
|
|
329
|
+
: descriptor['type']));
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @public
|
|
333
|
+
* @param descriptor - 描述
|
|
334
|
+
* @returns
|
|
335
|
+
*/
|
|
336
|
+
function getEventOptionsPropertiesByDescriptor(descriptor) {
|
|
337
|
+
var name = getEventNameByDescriptor(descriptor);
|
|
338
|
+
return ((eventRegistry &&
|
|
339
|
+
eventRegistry[name] &&
|
|
340
|
+
eventRegistry[name].parametersDescriptor) ||
|
|
341
|
+
{});
|
|
342
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IEventDescriptor, IEventMiddlewareDescriptor, InativeEventTypeDescriptor } from '@cicctencent/low-code-core';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* 事件注册表
|
|
5
|
+
*/
|
|
6
|
+
export declare const eventRegistry: {
|
|
7
|
+
[key: string]: IEventDescriptor;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
* 批量注册事件
|
|
12
|
+
*/
|
|
13
|
+
export declare const batchRegisterEvents: (descriptors: IEventDescriptor[]) => {
|
|
14
|
+
[key: string]: IEventDescriptor;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
* 注册事件:
|
|
19
|
+
*/
|
|
20
|
+
export declare const registerEvent: (descriptor: IEventDescriptor) => {
|
|
21
|
+
[key: string]: IEventDescriptor;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 事件中间件注册表
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const eventMiddlewareRegistry: {
|
|
28
|
+
[key: string]: IEventMiddlewareDescriptor;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
* 批量注册事件中间件
|
|
33
|
+
*/
|
|
34
|
+
export declare const batchRegisterEventMiddlewares: (descriptors: IEventMiddlewareDescriptor[]) => {
|
|
35
|
+
[key: string]: IEventMiddlewareDescriptor;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 注册事件中间件:
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const registerEventMiddleware: (descriptor: IEventMiddlewareDescriptor) => {
|
|
42
|
+
[key: string]: IEventMiddlewareDescriptor;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare const nativeEventTypeRegistry: {
|
|
48
|
+
[key: string]: InativeEventTypeDescriptor;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
* 批量注册支持的原生事件类型
|
|
53
|
+
*/
|
|
54
|
+
export declare const batchRegisterNativeEventTypes: (descriptors: InativeEventTypeDescriptor[]) => {
|
|
55
|
+
[key: string]: InativeEventTypeDescriptor;
|
|
56
|
+
};
|