@byteluck-fe/model-driven-engine 2.7.0-alpha.0 → 2.7.0-alpha.2
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 +154 -72
- package/dist/esm/common/DataManager.js +128 -60
- package/dist/esm/common/Engine.js +1060 -1111
- package/dist/esm/common/OkWorker.js +75 -106
- package/dist/esm/common/Runtime.js +27 -29
- package/dist/esm/common/Store.js +149 -181
- package/dist/esm/common/checkerValue.js +253 -328
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +306 -382
- package/dist/esm/plugins/ControlsEventPlugin.js +225 -141
- package/dist/esm/plugins/ES6ModulePlugin.js +38 -56
- package/dist/esm/plugins/LifecycleEventPlugin.js +190 -107
- package/dist/esm/plugins/StylePlugin.js +13 -31
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +5 -7
- package/dist/index.umd.js +9 -9
- package/dist/types/common/Engine.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +1 -1
- package/dist/types/common/Store.d.ts +5 -5
- package/dist/types/common/proxyState.d.ts +3 -3
- package/dist/types/plugins/ControlsEventPlugin.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +4 -4
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -1
- package/dist/types/plugins/StylePlugin.d.ts +1 -1
- package/package.json +4 -4
|
@@ -40,20 +40,6 @@ function _classCallCheck(instance, Constructor) {
|
|
|
40
40
|
throw new TypeError("Cannot call a class as a function");
|
|
41
41
|
}
|
|
42
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 _createClass(Constructor, protoProps, staticProps) {
|
|
53
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
-
return Constructor;
|
|
56
|
-
}
|
|
57
43
|
function _iterableToArrayLimit(arr, i) {
|
|
58
44
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
59
45
|
if (_i == null) return;
|
|
@@ -92,12 +78,106 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
92
78
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
93
79
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
94
80
|
}
|
|
95
|
-
|
|
81
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
82
|
+
var f, y, t, g, _ = {
|
|
83
|
+
label: 0,
|
|
84
|
+
sent: function() {
|
|
85
|
+
if (t[0] & 1) throw t[1];
|
|
86
|
+
return t[1];
|
|
87
|
+
},
|
|
88
|
+
trys: [],
|
|
89
|
+
ops: []
|
|
90
|
+
};
|
|
91
|
+
return(g = {
|
|
92
|
+
next: verb(0),
|
|
93
|
+
"throw": verb(1),
|
|
94
|
+
"return": verb(2)
|
|
95
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
96
|
+
return this;
|
|
97
|
+
}), g);
|
|
98
|
+
function verb(n) {
|
|
99
|
+
return function(v) {
|
|
100
|
+
return step([
|
|
101
|
+
n,
|
|
102
|
+
v
|
|
103
|
+
]);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function step(op) {
|
|
107
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
108
|
+
while(_)try {
|
|
109
|
+
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;
|
|
110
|
+
if (y = 0, t) op = [
|
|
111
|
+
op[0] & 2,
|
|
112
|
+
t.value
|
|
113
|
+
];
|
|
114
|
+
switch(op[0]){
|
|
115
|
+
case 0:
|
|
116
|
+
case 1:
|
|
117
|
+
t = op;
|
|
118
|
+
break;
|
|
119
|
+
case 4:
|
|
120
|
+
_.label++;
|
|
121
|
+
return {
|
|
122
|
+
value: op[1],
|
|
123
|
+
done: false
|
|
124
|
+
};
|
|
125
|
+
case 5:
|
|
126
|
+
_.label++;
|
|
127
|
+
y = op[1];
|
|
128
|
+
op = [
|
|
129
|
+
0
|
|
130
|
+
];
|
|
131
|
+
continue;
|
|
132
|
+
case 7:
|
|
133
|
+
op = _.ops.pop();
|
|
134
|
+
_.trys.pop();
|
|
135
|
+
continue;
|
|
136
|
+
default:
|
|
137
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
138
|
+
_ = 0;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
142
|
+
_.label = op[1];
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
146
|
+
_.label = t[1];
|
|
147
|
+
t = op;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (t && _.label < t[2]) {
|
|
151
|
+
_.label = t[2];
|
|
152
|
+
_.ops.push(op);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
if (t[2]) _.ops.pop();
|
|
156
|
+
_.trys.pop();
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
op = body.call(thisArg, _);
|
|
160
|
+
} catch (e) {
|
|
161
|
+
op = [
|
|
162
|
+
6,
|
|
163
|
+
e
|
|
164
|
+
];
|
|
165
|
+
y = 0;
|
|
166
|
+
} finally{
|
|
167
|
+
f = t = 0;
|
|
168
|
+
}
|
|
169
|
+
if (op[0] & 5) throw op[1];
|
|
170
|
+
return {
|
|
171
|
+
value: op[0] ? op[1] : void 0,
|
|
172
|
+
done: true
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
};
|
|
96
176
|
var LifecycleEventKeyMap = {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
177
|
+
"engine-mounted": "did_mount",
|
|
178
|
+
"engine-submit": "will_submit",
|
|
179
|
+
"engine-submit-params": "do_submit",
|
|
180
|
+
"engine-submitted": "did_submit"
|
|
101
181
|
};
|
|
102
182
|
export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
103
183
|
"use strict";
|
|
@@ -105,97 +185,100 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
105
185
|
_classCallCheck(this, LifecycleEventPlugin);
|
|
106
186
|
this.config = config;
|
|
107
187
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
121
|
-
while(1)switch(_ctx.prev = _ctx.next){
|
|
122
|
-
case 0:
|
|
123
|
-
_ctx.next = 2;
|
|
124
|
-
return _this1.callLifecycleEvent(lifecycleKey, payload);
|
|
125
|
-
case 2:
|
|
126
|
-
result = _ctx.sent;
|
|
127
|
-
if (!result.includes(false)) {
|
|
128
|
-
_ctx.next = 7;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
return _ctx.abrupt("return", false);
|
|
132
|
-
case 7:
|
|
133
|
-
return _ctx.abrupt("return", result);
|
|
134
|
-
case 8:
|
|
135
|
-
case "end":
|
|
136
|
-
return _ctx.stop();
|
|
137
|
-
}
|
|
138
|
-
}, _callee);
|
|
139
|
-
}));
|
|
140
|
-
return function(payload) {
|
|
141
|
-
return _ref.apply(this, arguments);
|
|
142
|
-
};
|
|
143
|
-
}());
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
key: "callLifecycleEvent",
|
|
149
|
-
value: function callLifecycleEvent(name, payload) {
|
|
150
|
-
var _this = this;
|
|
151
|
-
return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() {
|
|
152
|
-
var events, result;
|
|
153
|
-
return regeneratorRuntime.wrap(function _callee$(_ctx1) {
|
|
154
|
-
while(1)switch(_ctx1.prev = _ctx1.next){
|
|
188
|
+
var _proto = LifecycleEventPlugin.prototype;
|
|
189
|
+
_proto.apply = function apply(engine) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
this.engine = engine;
|
|
192
|
+
Object.entries(LifecycleEventKeyMap).forEach(function(param) {
|
|
193
|
+
var _param = _slicedToArray(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
|
|
194
|
+
var _this1 = _this;
|
|
195
|
+
engine.on(engineKey, function() {
|
|
196
|
+
var _ref = _asyncToGenerator(function(payload) {
|
|
197
|
+
var result;
|
|
198
|
+
return __generator(this, function(_state) {
|
|
199
|
+
switch(_state.label){
|
|
155
200
|
case 0:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
201
|
+
return [
|
|
202
|
+
4,
|
|
203
|
+
_this1.callLifecycleEvent(lifecycleKey, payload)
|
|
204
|
+
];
|
|
205
|
+
case 1:
|
|
206
|
+
result = _state.sent();
|
|
207
|
+
if (result.includes(false)) {
|
|
208
|
+
return [
|
|
209
|
+
2,
|
|
210
|
+
false
|
|
211
|
+
];
|
|
212
|
+
} else {
|
|
213
|
+
return [
|
|
214
|
+
2,
|
|
215
|
+
result
|
|
216
|
+
];
|
|
160
217
|
}
|
|
161
|
-
return
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
218
|
+
return [
|
|
219
|
+
2
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
return function(payload) {
|
|
225
|
+
return _ref.apply(this, arguments);
|
|
226
|
+
};
|
|
227
|
+
}());
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
_proto.callLifecycleEvent = function callLifecycleEvent(name, payload) {
|
|
231
|
+
var _this = this;
|
|
232
|
+
return _asyncToGenerator(function() {
|
|
233
|
+
var events, result;
|
|
234
|
+
return __generator(this, function(_state) {
|
|
235
|
+
switch(_state.label){
|
|
236
|
+
case 0:
|
|
237
|
+
events = _this.config;
|
|
238
|
+
if (!events || !Array.isArray(events[name])) {
|
|
239
|
+
return [
|
|
240
|
+
2,
|
|
241
|
+
[]
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
return [
|
|
245
|
+
4,
|
|
246
|
+
Promise.all(events[name].map(function() {
|
|
247
|
+
var _ref = _asyncToGenerator(function(eventName) {
|
|
248
|
+
var execResult;
|
|
249
|
+
return __generator(this, function(_state) {
|
|
250
|
+
switch(_state.label){
|
|
251
|
+
case 0:
|
|
252
|
+
return [
|
|
253
|
+
4,
|
|
254
|
+
_this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
172
255
|
// this.engine,
|
|
173
256
|
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
174
|
-
payload)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
257
|
+
payload)
|
|
258
|
+
];
|
|
259
|
+
case 1:
|
|
260
|
+
execResult = _state.sent();
|
|
261
|
+
return [
|
|
262
|
+
2,
|
|
263
|
+
execResult
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
return function(eventName) {
|
|
269
|
+
return _ref.apply(this, arguments);
|
|
270
|
+
};
|
|
271
|
+
}()))
|
|
272
|
+
];
|
|
273
|
+
case 1:
|
|
274
|
+
result = _state.sent();
|
|
275
|
+
return [
|
|
276
|
+
2,
|
|
277
|
+
result
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
})();
|
|
282
|
+
};
|
|
200
283
|
return LifecycleEventPlugin;
|
|
201
284
|
}();
|
|
@@ -3,42 +3,24 @@ function _classCallCheck(instance, Constructor) {
|
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
function _defineProperties(target, props) {
|
|
7
|
-
for(var i = 0; i < props.length; i++){
|
|
8
|
-
var descriptor = props[i];
|
|
9
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
-
descriptor.configurable = true;
|
|
11
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
16
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
-
return Constructor;
|
|
19
|
-
}
|
|
20
6
|
export var StylePlugin = /*#__PURE__*/ function() {
|
|
21
7
|
"use strict";
|
|
22
8
|
function StylePlugin(config) {
|
|
23
9
|
_classCallCheck(this, StylePlugin);
|
|
24
10
|
this.config = config;
|
|
25
11
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
dom.appendChild(style);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]);
|
|
12
|
+
var _proto = StylePlugin.prototype;
|
|
13
|
+
_proto.apply = function apply(engine) {
|
|
14
|
+
var _this_config;
|
|
15
|
+
this.engine = engine;
|
|
16
|
+
var _this_config_source;
|
|
17
|
+
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 : "";
|
|
18
|
+
var style = document.createElement("style");
|
|
19
|
+
style.className = "edit-css";
|
|
20
|
+
style.type = "text/css";
|
|
21
|
+
style.innerHTML = compiledStyle;
|
|
22
|
+
var dom = document.querySelector("head");
|
|
23
|
+
dom.appendChild(style);
|
|
24
|
+
};
|
|
43
25
|
return StylePlugin;
|
|
44
26
|
}();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./ES6ModulePlugin";
|
|
2
|
+
export * from "./LifecycleEventPlugin";
|
|
3
|
+
export * from "./ControlsEventPlugin";
|
|
4
|
+
export * from "./CalcPlugin";
|
|
5
|
+
export * from "./StylePlugin";
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./runtimeUtils";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from
|
|
1
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
|
|
2
2
|
export function hasChildrenControl(instance) {
|
|
3
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;
|
|
4
4
|
}
|
|
@@ -11,8 +11,7 @@ export function loopFormControl(control, callback) {
|
|
|
11
11
|
var children = item.getChildrenFormControl();
|
|
12
12
|
callback(item, children);
|
|
13
13
|
} else if (hasChildrenControl(item)) {
|
|
14
|
-
|
|
15
|
-
loopFormControl((ref = item) === null || ref === void 0 ? void 0 : ref.children, callback);
|
|
14
|
+
loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
16
15
|
// @ts-ignore
|
|
17
16
|
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
18
17
|
callback(item);
|
|
@@ -27,9 +26,8 @@ callback) {
|
|
|
27
26
|
if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
|
|
28
27
|
callback(item);
|
|
29
28
|
} else if (hasChildrenControl(item)) {
|
|
30
|
-
var ref;
|
|
31
29
|
// @ts-ignore
|
|
32
|
-
loopDataViewControl(
|
|
30
|
+
loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
33
31
|
}
|
|
34
32
|
});
|
|
35
33
|
}
|
|
@@ -37,9 +35,9 @@ callback) {
|
|
|
37
35
|
var unique = 0;
|
|
38
36
|
// uuid生成
|
|
39
37
|
export function buildUUID() {
|
|
40
|
-
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
38
|
+
var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
41
39
|
var time = Date.now();
|
|
42
40
|
var random = Math.floor(Math.random() * 1000000000);
|
|
43
41
|
unique++;
|
|
44
|
-
return prefix +
|
|
42
|
+
return prefix + "_" + random + unique + String(time);
|
|
45
43
|
}
|