@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
|
@@ -32,22 +32,102 @@ function _classCallCheck(instance, Constructor) {
|
|
|
32
32
|
throw new TypeError("Cannot call a class as a function");
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
36
|
+
var f, y, t, g, _ = {
|
|
37
|
+
label: 0,
|
|
38
|
+
sent: function() {
|
|
39
|
+
if (t[0] & 1) throw t[1];
|
|
40
|
+
return t[1];
|
|
41
|
+
},
|
|
42
|
+
trys: [],
|
|
43
|
+
ops: []
|
|
44
|
+
};
|
|
45
|
+
return(g = {
|
|
46
|
+
next: verb(0),
|
|
47
|
+
"throw": verb(1),
|
|
48
|
+
"return": verb(2)
|
|
49
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
50
|
+
return this;
|
|
51
|
+
}), g);
|
|
52
|
+
function verb(n) {
|
|
53
|
+
return function(v) {
|
|
54
|
+
return step([
|
|
55
|
+
n,
|
|
56
|
+
v
|
|
57
|
+
]);
|
|
58
|
+
};
|
|
42
59
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
function step(op) {
|
|
61
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
+
while(_)try {
|
|
63
|
+
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;
|
|
64
|
+
if (y = 0, t) op = [
|
|
65
|
+
op[0] & 2,
|
|
66
|
+
t.value
|
|
67
|
+
];
|
|
68
|
+
switch(op[0]){
|
|
69
|
+
case 0:
|
|
70
|
+
case 1:
|
|
71
|
+
t = op;
|
|
72
|
+
break;
|
|
73
|
+
case 4:
|
|
74
|
+
_.label++;
|
|
75
|
+
return {
|
|
76
|
+
value: op[1],
|
|
77
|
+
done: false
|
|
78
|
+
};
|
|
79
|
+
case 5:
|
|
80
|
+
_.label++;
|
|
81
|
+
y = op[1];
|
|
82
|
+
op = [
|
|
83
|
+
0
|
|
84
|
+
];
|
|
85
|
+
continue;
|
|
86
|
+
case 7:
|
|
87
|
+
op = _.ops.pop();
|
|
88
|
+
_.trys.pop();
|
|
89
|
+
continue;
|
|
90
|
+
default:
|
|
91
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
92
|
+
_ = 0;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
96
|
+
_.label = op[1];
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
100
|
+
_.label = t[1];
|
|
101
|
+
t = op;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t && _.label < t[2]) {
|
|
105
|
+
_.label = t[2];
|
|
106
|
+
_.ops.push(op);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (t[2]) _.ops.pop();
|
|
110
|
+
_.trys.pop();
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
op = body.call(thisArg, _);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
op = [
|
|
116
|
+
6,
|
|
117
|
+
e
|
|
118
|
+
];
|
|
119
|
+
y = 0;
|
|
120
|
+
} finally{
|
|
121
|
+
f = t = 0;
|
|
122
|
+
}
|
|
123
|
+
if (op[0] & 5) throw op[1];
|
|
124
|
+
return {
|
|
125
|
+
value: op[0] ? op[1] : void 0,
|
|
126
|
+
done: true
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
import { EventLogic } from "@byteluck-fe/model-driven-shared";
|
|
51
131
|
// type EventKeyMap = {
|
|
52
132
|
// [eventKey in EventKeys]?: string
|
|
53
133
|
// }
|
|
@@ -57,136 +137,140 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
57
137
|
_classCallCheck(this, ControlsEventPlugin);
|
|
58
138
|
this.config = config;
|
|
59
139
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (eventItem.code && eventItem.key) {
|
|
92
|
-
_this.engineAddEventListener(eventItem.code, eventItem.key);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
140
|
+
var _proto = ControlsEventPlugin.prototype;
|
|
141
|
+
_proto.apply = function apply(engine) {
|
|
142
|
+
var _this = this;
|
|
143
|
+
this.engine = engine;
|
|
144
|
+
// const eventKeyMap: EventKeyMap = {
|
|
145
|
+
// click: 'on_click',
|
|
146
|
+
// change: 'on_change',
|
|
147
|
+
// search: 'on_search',
|
|
148
|
+
// focus: 'on_focus',
|
|
149
|
+
// blur: 'on_blur',
|
|
150
|
+
// input: 'on_input',
|
|
151
|
+
// 'click-finish': 'on_click_finish',
|
|
152
|
+
// 'list-change': 'on_list_change',
|
|
153
|
+
// 'list-delete': 'on_list_delete',
|
|
154
|
+
// 'list-search': 'on_list_search',
|
|
155
|
+
// 'list-mounted': 'on_list_mounted',
|
|
156
|
+
// 'list-actions': 'on_list_actions',
|
|
157
|
+
// 'list-rowclick': 'on_list_rowclick',
|
|
158
|
+
// 'list-before-import': 'on_list_before_import',
|
|
159
|
+
// 'wps-open': 'on_wps_open',
|
|
160
|
+
// 'wps-save': 'on_wps_save',
|
|
161
|
+
// 'wps-rename': 'on_wps_rename',
|
|
162
|
+
// }
|
|
163
|
+
// Object.entries(eventKeyMap).forEach(([eventKey, controlEventKey]) => {
|
|
164
|
+
// if (eventKey && controlEventKey) {
|
|
165
|
+
// this.engineAddEventListener(eventKey as EventKeys, controlEventKey)
|
|
166
|
+
// }
|
|
167
|
+
// })
|
|
168
|
+
EventLogic.events.forEach(function(eventItem) {
|
|
169
|
+
if (eventItem.code && eventItem.key) {
|
|
170
|
+
_this.engineAddEventListener(eventItem.code, eventItem.key);
|
|
95
171
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return _ctx.abrupt("return");
|
|
111
|
-
case 2:
|
|
112
|
-
if (!(payload.instance !== undefined)) {
|
|
113
|
-
_ctx.next = 6;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
_ctx.next = 5;
|
|
117
|
-
return _this.callControlEvent(controlEventKey, payload);
|
|
118
|
-
case 5:
|
|
119
|
-
return _ctx.abrupt("return", _ctx.sent);
|
|
120
|
-
case 6:
|
|
121
|
-
case "end":
|
|
122
|
-
return _ctx.stop();
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
_proto.engineAddEventListener = function engineAddEventListener(eventKey, controlEventKey) {
|
|
175
|
+
var _this = this;
|
|
176
|
+
this.engine.on(eventKey, function() {
|
|
177
|
+
var _ref = _asyncToGenerator(function(payload) {
|
|
178
|
+
return __generator(this, function(_state) {
|
|
179
|
+
switch(_state.label){
|
|
180
|
+
case 0:
|
|
181
|
+
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
182
|
+
if (eventKey === "change" && !_this.engine.isMounted) {
|
|
183
|
+
return [
|
|
184
|
+
2
|
|
185
|
+
];
|
|
123
186
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
187
|
+
if (!(payload.instance !== undefined)) return [
|
|
188
|
+
3,
|
|
189
|
+
2
|
|
190
|
+
];
|
|
191
|
+
return [
|
|
192
|
+
4,
|
|
193
|
+
_this.callControlEvent(controlEventKey, payload)
|
|
194
|
+
];
|
|
195
|
+
case 1:
|
|
196
|
+
return [
|
|
197
|
+
2,
|
|
198
|
+
_state.sent()
|
|
199
|
+
];
|
|
200
|
+
case 2:
|
|
201
|
+
return [
|
|
202
|
+
2
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
return function(payload) {
|
|
208
|
+
return _ref.apply(this, arguments);
|
|
209
|
+
};
|
|
210
|
+
}());
|
|
211
|
+
};
|
|
212
|
+
_proto.callControlEvent = function callControlEvent(name, payload) {
|
|
213
|
+
var _this = this;
|
|
214
|
+
return _asyncToGenerator(function() {
|
|
215
|
+
var events, result;
|
|
216
|
+
return __generator(this, function(_state) {
|
|
217
|
+
switch(_state.label){
|
|
218
|
+
case 0:
|
|
219
|
+
events = _this.config[payload.instance.id];
|
|
220
|
+
if (!events || !Array.isArray(events[name])) {
|
|
221
|
+
return [
|
|
222
|
+
2,
|
|
223
|
+
[]
|
|
224
|
+
];
|
|
225
|
+
}
|
|
226
|
+
return [
|
|
227
|
+
4,
|
|
228
|
+
Promise.all(events[name].map(function() {
|
|
229
|
+
var _ref = _asyncToGenerator(function(eventName) {
|
|
230
|
+
var execResult;
|
|
231
|
+
return __generator(this, function(_state) {
|
|
232
|
+
switch(_state.label){
|
|
233
|
+
case 0:
|
|
234
|
+
return [
|
|
235
|
+
4,
|
|
236
|
+
_this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
157
237
|
// this.engine,
|
|
158
238
|
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
159
|
-
payload)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
239
|
+
payload)
|
|
240
|
+
];
|
|
241
|
+
case 1:
|
|
242
|
+
execResult = _state.sent();
|
|
243
|
+
return [
|
|
244
|
+
2,
|
|
245
|
+
execResult
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
return function(eventName) {
|
|
251
|
+
return _ref.apply(this, arguments);
|
|
252
|
+
};
|
|
253
|
+
}()))
|
|
254
|
+
];
|
|
255
|
+
case 1:
|
|
256
|
+
result = _state.sent();
|
|
257
|
+
if (result.includes(false)) {
|
|
258
|
+
return [
|
|
259
|
+
2,
|
|
260
|
+
false
|
|
261
|
+
];
|
|
262
|
+
} else {
|
|
263
|
+
return [
|
|
264
|
+
2,
|
|
265
|
+
result
|
|
266
|
+
];
|
|
185
267
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
268
|
+
return [
|
|
269
|
+
2
|
|
270
|
+
];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
})();
|
|
274
|
+
};
|
|
191
275
|
return ControlsEventPlugin;
|
|
192
276
|
}();
|
|
@@ -11,20 +11,6 @@ function _classCallCheck(instance, Constructor) {
|
|
|
11
11
|
throw new TypeError("Cannot call a class as a function");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
function _defineProperties(target, props) {
|
|
15
|
-
for(var i = 0; i < props.length; i++){
|
|
16
|
-
var descriptor = props[i];
|
|
17
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
18
|
-
descriptor.configurable = true;
|
|
19
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
20
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
24
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
25
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
26
|
-
return Constructor;
|
|
27
|
-
}
|
|
28
14
|
function _iterableToArrayLimit(arr, i) {
|
|
29
15
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30
16
|
if (_i == null) return;
|
|
@@ -63,7 +49,7 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
63
49
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
64
50
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
65
51
|
}
|
|
66
|
-
import { error } from
|
|
52
|
+
import { error } from "@byteluck-fe/model-driven-shared";
|
|
67
53
|
export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
68
54
|
"use strict";
|
|
69
55
|
function ES6ModulePlugin(config, env) {
|
|
@@ -71,45 +57,41 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
|
71
57
|
this.config = config;
|
|
72
58
|
this.env = env;
|
|
73
59
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
var _proto = ES6ModulePlugin.prototype;
|
|
61
|
+
_proto.apply = function apply(engine) {
|
|
62
|
+
this.engine = engine;
|
|
63
|
+
var action = this.config;
|
|
64
|
+
if (!action) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var res = parseModule(action, engine, this.env);
|
|
68
|
+
if (!res) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var actionManager = engine.getAction();
|
|
72
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
73
|
+
try {
|
|
74
|
+
for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
75
|
+
var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
76
|
+
actionManager.addAction(key, value);
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
_didIteratorError = true;
|
|
80
|
+
_iteratorError = err;
|
|
81
|
+
} finally{
|
|
82
|
+
try {
|
|
83
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
84
|
+
_iterator.return();
|
|
86
85
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
91
|
-
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
92
|
-
actionManager.addAction(key, value);
|
|
93
|
-
}
|
|
94
|
-
} catch (err) {
|
|
95
|
-
_didIteratorError = true;
|
|
96
|
-
_iteratorError = err;
|
|
97
|
-
} finally{
|
|
98
|
-
try {
|
|
99
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
100
|
-
_iterator.return();
|
|
101
|
-
}
|
|
102
|
-
} finally{
|
|
103
|
-
if (_didIteratorError) {
|
|
104
|
-
throw _iteratorError;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
86
|
+
} finally{
|
|
87
|
+
if (_didIteratorError) {
|
|
88
|
+
throw _iteratorError;
|
|
107
89
|
}
|
|
108
|
-
//qiyu state会proxy,将过深的变量存储会导致崩溃
|
|
109
|
-
// engine.setState('variables', res.variables)
|
|
110
90
|
}
|
|
111
91
|
}
|
|
112
|
-
|
|
92
|
+
//qiyu state会proxy,将过深的变量存储会导致崩溃
|
|
93
|
+
// engine.setState('variables', res.variables)
|
|
94
|
+
};
|
|
113
95
|
return ES6ModulePlugin;
|
|
114
96
|
}();
|
|
115
97
|
export function parseModule(action, engine, env) {
|
|
@@ -125,11 +107,11 @@ export function parseModule(action, engine, env) {
|
|
|
125
107
|
}
|
|
126
108
|
};
|
|
127
109
|
try {
|
|
128
|
-
new Function(
|
|
110
|
+
new Function("module", "exports", compiled).call(module, module, module.exports);
|
|
129
111
|
} catch (e) {
|
|
130
|
-
error(e.message +
|
|
131
|
-
if (process.env.NODE_ENV !==
|
|
132
|
-
error(
|
|
112
|
+
error(e.message + ". fail to parse the module");
|
|
113
|
+
if (process.env.NODE_ENV !== "production") {
|
|
114
|
+
error("fail to parse the module");
|
|
133
115
|
}
|
|
134
116
|
}
|
|
135
117
|
var funcMap = {};
|
|
@@ -137,8 +119,8 @@ export function parseModule(action, engine, env) {
|
|
|
137
119
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
138
120
|
try {
|
|
139
121
|
for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
140
|
-
var
|
|
141
|
-
if (typeof value ===
|
|
122
|
+
var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
123
|
+
if (typeof value === "function") {
|
|
142
124
|
funcMap[key] = value;
|
|
143
125
|
} else {
|
|
144
126
|
variables[key] = value;
|