@byteluck-fe/model-driven-engine 2.3.1-beta.25 → 2.3.1-beta.26

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.
Files changed (40) hide show
  1. package/dist/esm/common/ActionManager.js +273 -0
  2. package/dist/esm/common/DataManager.js +213 -0
  3. package/dist/esm/common/Engine.js +1584 -0
  4. package/dist/esm/common/OkWorker.js +134 -0
  5. package/dist/esm/common/Plugin.js +10 -0
  6. package/dist/esm/common/Runtime.js +306 -0
  7. package/dist/esm/common/Store.js +377 -0
  8. package/dist/esm/common/checkerValue.js +622 -0
  9. package/dist/esm/common/index.js +2 -0
  10. package/dist/esm/common/proxyState.js +315 -0
  11. package/dist/esm/index.js +3 -0
  12. package/dist/esm/plugins/CalcPlugin.js +482 -0
  13. package/dist/esm/plugins/ControlsEventPlugin.js +315 -0
  14. package/dist/esm/plugins/ES6ModulePlugin.js +181 -0
  15. package/dist/esm/plugins/LifecycleEventPlugin.js +320 -0
  16. package/dist/esm/plugins/StylePlugin.js +59 -0
  17. package/dist/esm/plugins/index.js +5 -0
  18. package/dist/esm/utils/index.js +1 -0
  19. package/dist/esm/utils/runtimeUtils.js +43 -0
  20. package/dist/index.umd.js +28 -0
  21. package/dist/types/common/ActionManager.d.ts +14 -0
  22. package/dist/types/common/DataManager.d.ts +10 -0
  23. package/dist/types/common/Engine.d.ts +180 -0
  24. package/dist/types/common/OkWorker.d.ts +13 -0
  25. package/dist/types/common/Plugin.d.ts +6 -0
  26. package/dist/types/common/Runtime.d.ts +25 -0
  27. package/dist/types/common/Store.d.ts +49 -0
  28. package/dist/types/common/checkerValue.d.ts +3 -0
  29. package/dist/types/common/index.d.ts +2 -0
  30. package/dist/types/common/proxyState.d.ts +30 -0
  31. package/dist/types/index.d.ts +3 -0
  32. package/dist/types/plugins/CalcPlugin.d.ts +121 -0
  33. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -0
  34. package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -0
  35. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -0
  36. package/dist/types/plugins/StylePlugin.d.ts +12 -0
  37. package/dist/types/plugins/index.d.ts +5 -0
  38. package/dist/types/utils/index.d.ts +1 -0
  39. package/dist/types/utils/runtimeUtils.d.ts +5 -0
  40. package/package.json +3 -3
@@ -0,0 +1,320 @@
1
+ function _arrayLikeToArray(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 _arrayWithHoles(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 _asyncToGenerator(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 _classCallCheck(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 _createClass(Constructor, protoProps, staticProps) {
53
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54
+ if (staticProps) _defineProperties(Constructor, staticProps);
55
+ return Constructor;
56
+ }
57
+ function _defineProperty(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 _iterableToArrayLimit(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 _nonIterableRest() {
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 _slicedToArray(arr, i) {
98
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
99
+ }
100
+ function _unsupportedIterableToArray(o, minLen) {
101
+ if (!o) return;
102
+ if (typeof o === "string") return _arrayLikeToArray(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 _arrayLikeToArray(o, minLen);
107
+ }
108
+ var __generator = this && this.__generator || function(thisArg, body) {
109
+ var f, y, t, g, _ = {
110
+ label: 0,
111
+ sent: function() {
112
+ if (t[0] & 1) throw t[1];
113
+ return t[1];
114
+ },
115
+ trys: [],
116
+ ops: []
117
+ };
118
+ return(g = {
119
+ next: verb(0),
120
+ "throw": verb(1),
121
+ "return": verb(2)
122
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
123
+ return this;
124
+ }), g);
125
+ function verb(n) {
126
+ return function(v) {
127
+ return step([
128
+ n,
129
+ v
130
+ ]);
131
+ };
132
+ }
133
+ function step(op) {
134
+ if (f) throw new TypeError("Generator is already executing.");
135
+ while(_)try {
136
+ 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;
137
+ if (y = 0, t) op = [
138
+ op[0] & 2,
139
+ t.value
140
+ ];
141
+ switch(op[0]){
142
+ case 0:
143
+ case 1:
144
+ t = op;
145
+ break;
146
+ case 4:
147
+ _.label++;
148
+ return {
149
+ value: op[1],
150
+ done: false
151
+ };
152
+ case 5:
153
+ _.label++;
154
+ y = op[1];
155
+ op = [
156
+ 0
157
+ ];
158
+ continue;
159
+ case 7:
160
+ op = _.ops.pop();
161
+ _.trys.pop();
162
+ continue;
163
+ default:
164
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
165
+ _ = 0;
166
+ continue;
167
+ }
168
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
169
+ _.label = op[1];
170
+ break;
171
+ }
172
+ if (op[0] === 6 && _.label < t[1]) {
173
+ _.label = t[1];
174
+ t = op;
175
+ break;
176
+ }
177
+ if (t && _.label < t[2]) {
178
+ _.label = t[2];
179
+ _.ops.push(op);
180
+ break;
181
+ }
182
+ if (t[2]) _.ops.pop();
183
+ _.trys.pop();
184
+ continue;
185
+ }
186
+ op = body.call(thisArg, _);
187
+ } catch (e) {
188
+ op = [
189
+ 6,
190
+ e
191
+ ];
192
+ y = 0;
193
+ } finally{
194
+ f = t = 0;
195
+ }
196
+ if (op[0] & 5) throw op[1];
197
+ return {
198
+ value: op[0] ? op[1] : void 0,
199
+ done: true
200
+ };
201
+ }
202
+ };
203
+ var LifecycleEventKeyMap = {
204
+ "engine-mounted": "did_mount",
205
+ "engine-submit": "will_submit",
206
+ "engine-submit-params": "do_submit",
207
+ "engine-submitted": "did_submit"
208
+ };
209
+ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
210
+ "use strict";
211
+ function LifecycleEventPlugin(config) {
212
+ _classCallCheck(this, LifecycleEventPlugin);
213
+ _defineProperty(this, "config", void 0);
214
+ _defineProperty(this, "engine", void 0);
215
+ this.config = config;
216
+ }
217
+ _createClass(LifecycleEventPlugin, [
218
+ {
219
+ key: "apply",
220
+ value: function apply(engine) {
221
+ var _this = this;
222
+ this.engine = engine;
223
+ Object.entries(LifecycleEventKeyMap).forEach(function(param) {
224
+ var _param = _slicedToArray(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
225
+ var _this1 = _this;
226
+ engine.on(engineKey, function() {
227
+ var _ref = _asyncToGenerator(function(payload) {
228
+ var result;
229
+ return __generator(this, function(_state) {
230
+ switch(_state.label){
231
+ case 0:
232
+ return [
233
+ 4,
234
+ _this1.callLifecycleEvent(lifecycleKey, payload)
235
+ ];
236
+ case 1:
237
+ result = _state.sent();
238
+ if (result.includes(false)) {
239
+ return [
240
+ 2,
241
+ false
242
+ ];
243
+ } else {
244
+ return [
245
+ 2,
246
+ result
247
+ ];
248
+ }
249
+ return [
250
+ 2
251
+ ];
252
+ }
253
+ });
254
+ });
255
+ return function(payload) {
256
+ return _ref.apply(this, arguments);
257
+ };
258
+ }());
259
+ });
260
+ }
261
+ },
262
+ {
263
+ key: "callLifecycleEvent",
264
+ value: function callLifecycleEvent(name, payload) {
265
+ var _this = this;
266
+ return _asyncToGenerator(function() {
267
+ var events, result;
268
+ return __generator(this, function(_state) {
269
+ switch(_state.label){
270
+ case 0:
271
+ events = _this.config;
272
+ if (!events || !Array.isArray(events[name])) {
273
+ return [
274
+ 2,
275
+ []
276
+ ];
277
+ }
278
+ return [
279
+ 4,
280
+ Promise.all(events[name].map(function() {
281
+ var _ref = _asyncToGenerator(function(eventName) {
282
+ var execResult;
283
+ return __generator(this, function(_state) {
284
+ switch(_state.label){
285
+ case 0:
286
+ return [
287
+ 4,
288
+ _this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
289
+ // this.engine,
290
+ // this.engine.getAction().actionUtils, //以前是params,空的
291
+ payload)
292
+ ];
293
+ case 1:
294
+ execResult = _state.sent();
295
+ return [
296
+ 2,
297
+ execResult
298
+ ];
299
+ }
300
+ });
301
+ });
302
+ return function(eventName) {
303
+ return _ref.apply(this, arguments);
304
+ };
305
+ }()))
306
+ ];
307
+ case 1:
308
+ result = _state.sent();
309
+ return [
310
+ 2,
311
+ result
312
+ ];
313
+ }
314
+ });
315
+ })();
316
+ }
317
+ }
318
+ ]);
319
+ return LifecycleEventPlugin;
320
+ }();
@@ -0,0 +1,59 @@
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
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
+ function _defineProperty(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ export var StylePlugin = /*#__PURE__*/ function() {
34
+ "use strict";
35
+ function StylePlugin(config) {
36
+ _classCallCheck(this, StylePlugin);
37
+ _defineProperty(this, "config", void 0);
38
+ _defineProperty(this, "engine", void 0);
39
+ this.config = config;
40
+ }
41
+ _createClass(StylePlugin, [
42
+ {
43
+ key: "apply",
44
+ value: function apply(engine) {
45
+ var _this_config;
46
+ this.engine = engine;
47
+ var _this_config_source;
48
+ 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 : "";
49
+ var style = document.createElement("style");
50
+ style.className = "edit-css";
51
+ style.type = "text/css";
52
+ style.innerHTML = compiledStyle;
53
+ var dom = document.querySelector("head");
54
+ dom.appendChild(style);
55
+ }
56
+ }
57
+ ]);
58
+ return StylePlugin;
59
+ }();
@@ -0,0 +1,5 @@
1
+ export * from "./ES6ModulePlugin";
2
+ export * from "./LifecycleEventPlugin";
3
+ export * from "./ControlsEventPlugin";
4
+ export * from "./CalcPlugin";
5
+ export * from "./StylePlugin";
@@ -0,0 +1 @@
1
+ export * from "./runtimeUtils";
@@ -0,0 +1,43 @@
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;
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
+ // @ts-ignore
11
+ var children = item.getChildrenFormControl();
12
+ callback(item, children);
13
+ } else if (hasChildrenControl(item)) {
14
+ loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
15
+ // @ts-ignore
16
+ } else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
17
+ callback(item);
18
+ }
19
+ });
20
+ }
21
+ }
22
+ export function loopDataViewControl(control, // @ts-ignore
23
+ callback) {
24
+ if (Array.isArray(control)) {
25
+ control.map(function(item) {
26
+ if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
27
+ callback(item);
28
+ } else if (hasChildrenControl(item)) {
29
+ // @ts-ignore
30
+ loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
31
+ }
32
+ });
33
+ }
34
+ }
35
+ var unique = 0;
36
+ // uuid生成
37
+ export function buildUUID() {
38
+ var prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
39
+ var time = Date.now();
40
+ var random = Math.floor(Math.random() * 1000000000);
41
+ unique++;
42
+ return prefix + "_" + random + unique + String(time);
43
+ }