@byteluck-fe/model-driven-engine 2.22.4-beta.2 → 2.22.4-beta.4
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/dist/esm/common/ActionManager.js +269 -0
- package/dist/esm/common/DataManager.js +209 -0
- package/dist/esm/common/Engine.js +1785 -0
- package/dist/esm/common/OkWorker.js +134 -0
- package/dist/esm/common/Plugin.js +10 -0
- package/dist/esm/common/Runtime.js +458 -0
- package/dist/esm/common/Store.js +443 -0
- package/dist/esm/common/checkerValue.js +609 -0
- package/dist/esm/common/index.js +2 -0
- package/dist/esm/common/proxyState.js +321 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/plugins/CalcPlugin.js +500 -0
- package/dist/esm/plugins/ControlsEventPlugin.js +315 -0
- package/dist/esm/plugins/ES6ModulePlugin.js +210 -0
- package/dist/esm/plugins/LifecycleEventPlugin.js +310 -0
- package/dist/esm/plugins/StylePlugin.js +73 -0
- package/dist/esm/plugins/index.js +5 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/runtimeUtils.js +45 -0
- package/dist/index.umd.js +22 -0
- package/dist/types/common/Engine.d.ts +201 -0
- package/package.json +4 -4
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _class_call_check(instance, Constructor) {
|
|
39
|
+
if (!(instance instanceof Constructor)) {
|
|
40
|
+
throw new TypeError("Cannot call a class as a function");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _defineProperties(target, props) {
|
|
44
|
+
for(var i = 0; i < props.length; i++){
|
|
45
|
+
var descriptor = props[i];
|
|
46
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
47
|
+
descriptor.configurable = true;
|
|
48
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
49
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
53
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
+
return Constructor;
|
|
56
|
+
}
|
|
57
|
+
function _define_property(obj, key, value) {
|
|
58
|
+
if (key in obj) {
|
|
59
|
+
Object.defineProperty(obj, key, {
|
|
60
|
+
value: value,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
obj[key] = value;
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
function _iterable_to_array_limit(arr, i) {
|
|
71
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
72
|
+
if (_i == null) return;
|
|
73
|
+
var _arr = [];
|
|
74
|
+
var _n = true;
|
|
75
|
+
var _d = false;
|
|
76
|
+
var _s, _e;
|
|
77
|
+
try {
|
|
78
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
79
|
+
_arr.push(_s.value);
|
|
80
|
+
if (i && _arr.length === i) break;
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
_d = true;
|
|
84
|
+
_e = err;
|
|
85
|
+
} finally{
|
|
86
|
+
try {
|
|
87
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
88
|
+
} finally{
|
|
89
|
+
if (_d) throw _e;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return _arr;
|
|
93
|
+
}
|
|
94
|
+
function _non_iterable_rest() {
|
|
95
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
96
|
+
}
|
|
97
|
+
function _sliced_to_array(arr, i) {
|
|
98
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
99
|
+
}
|
|
100
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
101
|
+
if (!o) return;
|
|
102
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
103
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
104
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
105
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
106
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
107
|
+
}
|
|
108
|
+
function _ts_generator(thisArg, body) {
|
|
109
|
+
var f, y, t, _ = {
|
|
110
|
+
label: 0,
|
|
111
|
+
sent: function() {
|
|
112
|
+
if (t[0] & 1) throw t[1];
|
|
113
|
+
return t[1];
|
|
114
|
+
},
|
|
115
|
+
trys: [],
|
|
116
|
+
ops: []
|
|
117
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
118
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
119
|
+
return this;
|
|
120
|
+
}), g;
|
|
121
|
+
function verb(n) {
|
|
122
|
+
return function(v) {
|
|
123
|
+
return step([
|
|
124
|
+
n,
|
|
125
|
+
v
|
|
126
|
+
]);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function step(op) {
|
|
130
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
131
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
132
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
133
|
+
if (y = 0, t) op = [
|
|
134
|
+
op[0] & 2,
|
|
135
|
+
t.value
|
|
136
|
+
];
|
|
137
|
+
switch(op[0]){
|
|
138
|
+
case 0:
|
|
139
|
+
case 1:
|
|
140
|
+
t = op;
|
|
141
|
+
break;
|
|
142
|
+
case 4:
|
|
143
|
+
_.label++;
|
|
144
|
+
return {
|
|
145
|
+
value: op[1],
|
|
146
|
+
done: false
|
|
147
|
+
};
|
|
148
|
+
case 5:
|
|
149
|
+
_.label++;
|
|
150
|
+
y = op[1];
|
|
151
|
+
op = [
|
|
152
|
+
0
|
|
153
|
+
];
|
|
154
|
+
continue;
|
|
155
|
+
case 7:
|
|
156
|
+
op = _.ops.pop();
|
|
157
|
+
_.trys.pop();
|
|
158
|
+
continue;
|
|
159
|
+
default:
|
|
160
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
161
|
+
_ = 0;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
165
|
+
_.label = op[1];
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
169
|
+
_.label = t[1];
|
|
170
|
+
t = op;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (t && _.label < t[2]) {
|
|
174
|
+
_.label = t[2];
|
|
175
|
+
_.ops.push(op);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
if (t[2]) _.ops.pop();
|
|
179
|
+
_.trys.pop();
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
op = body.call(thisArg, _);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
op = [
|
|
185
|
+
6,
|
|
186
|
+
e
|
|
187
|
+
];
|
|
188
|
+
y = 0;
|
|
189
|
+
} finally{
|
|
190
|
+
f = t = 0;
|
|
191
|
+
}
|
|
192
|
+
if (op[0] & 5) throw op[1];
|
|
193
|
+
return {
|
|
194
|
+
value: op[0] ? op[1] : void 0,
|
|
195
|
+
done: true
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
var LifecycleEventKeyMap = {
|
|
200
|
+
'engine-initialized': 'did_init',
|
|
201
|
+
'engine-mounted': 'did_mount',
|
|
202
|
+
'engine-submit': 'will_submit',
|
|
203
|
+
'engine-submit-params': 'do_submit',
|
|
204
|
+
'engine-submitted': 'did_submit'
|
|
205
|
+
};
|
|
206
|
+
export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
207
|
+
"use strict";
|
|
208
|
+
function LifecycleEventPlugin(config) {
|
|
209
|
+
_class_call_check(this, LifecycleEventPlugin);
|
|
210
|
+
_define_property(this, "config", void 0);
|
|
211
|
+
_define_property(this, "engine", void 0);
|
|
212
|
+
this.config = config;
|
|
213
|
+
}
|
|
214
|
+
_create_class(LifecycleEventPlugin, [
|
|
215
|
+
{
|
|
216
|
+
key: "apply",
|
|
217
|
+
value: function apply(engine) {
|
|
218
|
+
var _this = this;
|
|
219
|
+
this.engine = engine;
|
|
220
|
+
Object.entries(LifecycleEventKeyMap).forEach(function(param) {
|
|
221
|
+
var _param = _sliced_to_array(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
|
|
222
|
+
engine.on(engineKey, function(payload) {
|
|
223
|
+
return _async_to_generator(function() {
|
|
224
|
+
var result;
|
|
225
|
+
return _ts_generator(this, function(_state) {
|
|
226
|
+
switch(_state.label){
|
|
227
|
+
case 0:
|
|
228
|
+
return [
|
|
229
|
+
4,
|
|
230
|
+
this.callLifecycleEvent(lifecycleKey, payload)
|
|
231
|
+
];
|
|
232
|
+
case 1:
|
|
233
|
+
result = _state.sent();
|
|
234
|
+
if (result.includes(false)) {
|
|
235
|
+
return [
|
|
236
|
+
2,
|
|
237
|
+
false
|
|
238
|
+
];
|
|
239
|
+
} else {
|
|
240
|
+
return [
|
|
241
|
+
2,
|
|
242
|
+
result
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
return [
|
|
246
|
+
2
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}).call(_this);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
key: "callLifecycleEvent",
|
|
257
|
+
value: function callLifecycleEvent(name, payload) {
|
|
258
|
+
return _async_to_generator(function() {
|
|
259
|
+
var _this, events, result;
|
|
260
|
+
return _ts_generator(this, function(_state) {
|
|
261
|
+
switch(_state.label){
|
|
262
|
+
case 0:
|
|
263
|
+
_this = this;
|
|
264
|
+
events = this.config;
|
|
265
|
+
if (!events || !Array.isArray(events[name])) {
|
|
266
|
+
return [
|
|
267
|
+
2,
|
|
268
|
+
[]
|
|
269
|
+
];
|
|
270
|
+
}
|
|
271
|
+
return [
|
|
272
|
+
4,
|
|
273
|
+
Promise.all(events[name].map(function(eventName) {
|
|
274
|
+
return _async_to_generator(function() {
|
|
275
|
+
var execResult;
|
|
276
|
+
return _ts_generator(this, function(_state) {
|
|
277
|
+
switch(_state.label){
|
|
278
|
+
case 0:
|
|
279
|
+
return [
|
|
280
|
+
4,
|
|
281
|
+
this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
282
|
+
// this.engine,
|
|
283
|
+
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
284
|
+
payload)
|
|
285
|
+
];
|
|
286
|
+
case 1:
|
|
287
|
+
execResult = _state.sent();
|
|
288
|
+
return [
|
|
289
|
+
2,
|
|
290
|
+
execResult
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}).call(_this);
|
|
295
|
+
}))
|
|
296
|
+
];
|
|
297
|
+
case 1:
|
|
298
|
+
result = _state.sent();
|
|
299
|
+
return [
|
|
300
|
+
2,
|
|
301
|
+
result
|
|
302
|
+
];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}).call(this);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
]);
|
|
309
|
+
return LifecycleEventPlugin;
|
|
310
|
+
}();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
3
|
+
* @Date: 2022-04-15 14:06:03
|
|
4
|
+
* @LastEditors: SuperLuckyqi
|
|
5
|
+
* @LastEditTime: 2025-04-10 10:23:07
|
|
6
|
+
* @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
|
|
7
|
+
*/ function _class_call_check(instance, Constructor) {
|
|
8
|
+
if (!(instance instanceof Constructor)) {
|
|
9
|
+
throw new TypeError("Cannot call a class as a function");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function _defineProperties(target, props) {
|
|
13
|
+
for(var i = 0; i < props.length; i++){
|
|
14
|
+
var descriptor = props[i];
|
|
15
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
16
|
+
descriptor.configurable = true;
|
|
17
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
18
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
22
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
|
+
return Constructor;
|
|
25
|
+
}
|
|
26
|
+
function _define_property(obj, key, value) {
|
|
27
|
+
if (key in obj) {
|
|
28
|
+
Object.defineProperty(obj, key, {
|
|
29
|
+
value: value,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
obj[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
export var StylePlugin = /*#__PURE__*/ function() {
|
|
40
|
+
"use strict";
|
|
41
|
+
function StylePlugin(config) {
|
|
42
|
+
var isPC = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
43
|
+
_class_call_check(this, StylePlugin);
|
|
44
|
+
_define_property(this, "config", void 0);
|
|
45
|
+
_define_property(this, "engine", void 0);
|
|
46
|
+
_define_property(this, "isPc", void 0);
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.isPc = isPC;
|
|
49
|
+
}
|
|
50
|
+
_create_class(StylePlugin, [
|
|
51
|
+
{
|
|
52
|
+
key: "apply",
|
|
53
|
+
value: function apply(engine) {
|
|
54
|
+
var _this_config;
|
|
55
|
+
this.engine = engine;
|
|
56
|
+
var _this_config_source;
|
|
57
|
+
var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : '';
|
|
58
|
+
var style = document.createElement('style');
|
|
59
|
+
style.className = 'edit-css-' + engine.id;
|
|
60
|
+
var dom = document.querySelector('head');
|
|
61
|
+
dom === null || dom === void 0 ? void 0 : dom.appendChild(style);
|
|
62
|
+
var cssStyleText;
|
|
63
|
+
if (this.isPc) {
|
|
64
|
+
cssStyleText = ".render-engine-".concat(engine.id, "{ ").concat(compiledStyle, " }");
|
|
65
|
+
} else {
|
|
66
|
+
cssStyleText = compiledStyle;
|
|
67
|
+
}
|
|
68
|
+
style.appendChild(document.createTextNode(cssStyleText));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
return StylePlugin;
|
|
73
|
+
}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtimeUtils';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
2
|
+
export function hasChildrenControl(instance) {
|
|
3
|
+
return instance.controlType === CONTROL_BASE_TYPE.LAYOUT || instance.controlType === CONTROL_BASE_TYPE.WRAP || instance.controlType === CONTROL_BASE_TYPE.LIST || instance.controlType === CONTROL_BASE_TYPE.SEARCH || instance.controlType === CONTROL_BASE_TYPE.COLUMN && instance.type !== CONTROL_TYPE.OPERATION_COLUMN;
|
|
4
|
+
}
|
|
5
|
+
export function loopFormControl(control, callback) {
|
|
6
|
+
if (Array.isArray(control)) {
|
|
7
|
+
control.map(function(item) {
|
|
8
|
+
//TODO 此处需要再抽象一层 datagrid/datalist
|
|
9
|
+
// if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
10
|
+
if (item.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
var children = []//item.getChildrenFormControl() as RuntimeFormControl[]
|
|
13
|
+
;
|
|
14
|
+
callback(item, children);
|
|
15
|
+
} else if (hasChildrenControl(item)) {
|
|
16
|
+
loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
19
|
+
callback(item);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function loopDataViewControl(control, // @ts-ignore
|
|
25
|
+
callback) {
|
|
26
|
+
if (Array.isArray(control)) {
|
|
27
|
+
control.map(function(item) {
|
|
28
|
+
if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
|
|
29
|
+
callback(item);
|
|
30
|
+
} else if (hasChildrenControl(item)) {
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var unique = 0;
|
|
38
|
+
// uuid生成
|
|
39
|
+
export function buildUUID() {
|
|
40
|
+
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
|
|
41
|
+
var time = Date.now();
|
|
42
|
+
var random = Math.floor(Math.random() * 1000000000);
|
|
43
|
+
unique++;
|
|
44
|
+
return prefix + '_' + random + unique + String(time);
|
|
45
|
+
}
|