@byteluck-fe/model-driven-engine 2.7.0-alpha.31a → 2.7.0-alpha.31b

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 (41) hide show
  1. package/README.md +30 -30
  2. package/dist/esm/common/ActionManager.js +60 -177
  3. package/dist/esm/common/DataManager.js +25 -134
  4. package/dist/esm/common/Engine.js +292 -397
  5. package/dist/esm/common/OkWorker.js +17 -31
  6. package/dist/esm/common/Plugin.js +2 -2
  7. package/dist/esm/common/Runtime.js +41 -56
  8. package/dist/esm/common/Store.js +62 -63
  9. package/dist/esm/common/checkerValue.js +108 -108
  10. package/dist/esm/common/index.js +2 -2
  11. package/dist/esm/common/proxyState.js +76 -76
  12. package/dist/esm/index.js +3 -3
  13. package/dist/esm/plugins/CalcPlugin.js +119 -127
  14. package/dist/esm/plugins/ControlsEventPlugin.js +73 -196
  15. package/dist/esm/plugins/ES6ModulePlugin.js +22 -39
  16. package/dist/esm/plugins/LifecycleEventPlugin.js +79 -198
  17. package/dist/esm/plugins/StylePlugin.js +11 -26
  18. package/dist/esm/plugins/index.js +5 -5
  19. package/dist/esm/utils/index.js +1 -1
  20. package/dist/esm/utils/runtimeUtils.js +7 -5
  21. package/dist/index.umd.js +8 -8
  22. package/dist/types/common/ActionManager.d.ts +14 -14
  23. package/dist/types/common/DataManager.d.ts +10 -10
  24. package/dist/types/common/Engine.d.ts +181 -181
  25. package/dist/types/common/OkWorker.d.ts +13 -13
  26. package/dist/types/common/Plugin.d.ts +6 -6
  27. package/dist/types/common/Runtime.d.ts +26 -26
  28. package/dist/types/common/Store.d.ts +50 -50
  29. package/dist/types/common/checkerValue.d.ts +3 -3
  30. package/dist/types/common/index.d.ts +2 -2
  31. package/dist/types/common/proxyState.d.ts +30 -30
  32. package/dist/types/index.d.ts +3 -3
  33. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  34. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
  35. package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
  36. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
  37. package/dist/types/plugins/StylePlugin.d.ts +12 -12
  38. package/dist/types/plugins/index.d.ts +5 -5
  39. package/dist/types/utils/index.d.ts +1 -1
  40. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  41. package/package.json +3 -3
package/README.md CHANGED
@@ -1,30 +1,30 @@
1
- # Engine
2
- 运行态引擎
3
-
4
- ```
5
- │ index.ts // 入口文件
6
-
7
- ├─common // 引擎相关
8
- │ ActionManager.ts // utils操作管理
9
- │ checkerValue.ts // 表单值校验器
10
- │ DataManager.ts // 数据源容器
11
- │ Engine.ts // 引擎
12
- │ index.ts // 入口
13
- │ OkWorker.ts // 无用
14
- │ Plugin.ts // 插件
15
- │ proxyState.ts // 劫持引擎表单数据
16
- │ Runtime.ts // 控件注册和创建
17
- │ Store.ts // 数据管理
18
-
19
- ├─plugins
20
- │ CalcPlugin.ts // 计算公式插件
21
- │ ControlsEventPlugin.ts // 控件二开事件插件
22
- │ ES6ModulePlugin.ts //
23
- │ index.ts
24
- │ LifecycleEventPlugin.ts // 页面生命周期事件
25
- │ StylePlugin.ts // css二开
26
-
27
- └─utils
28
- index.ts
29
- runtimeUtils.ts // 工具函数
30
- ```
1
+ # Engine
2
+ 运行态引擎
3
+
4
+ ```
5
+ │ index.ts // 入口文件
6
+
7
+ ├─common // 引擎相关
8
+ │ ActionManager.ts // utils操作管理
9
+ │ checkerValue.ts // 表单值校验器
10
+ │ DataManager.ts // 数据源容器
11
+ │ Engine.ts // 引擎
12
+ │ index.ts // 入口
13
+ │ OkWorker.ts // 无用
14
+ │ Plugin.ts // 插件
15
+ │ proxyState.ts // 劫持引擎表单数据
16
+ │ Runtime.ts // 控件注册和创建
17
+ │ Store.ts // 数据管理
18
+
19
+ ├─plugins
20
+ │ CalcPlugin.ts // 计算公式插件
21
+ │ ControlsEventPlugin.ts // 控件二开事件插件
22
+ │ ES6ModulePlugin.ts //
23
+ │ index.ts
24
+ │ LifecycleEventPlugin.ts // 页面生命周期事件
25
+ │ StylePlugin.ts // css二开
26
+
27
+ └─utils
28
+ index.ts
29
+ runtimeUtils.ts // 工具函数
30
+ ```
@@ -1,10 +1,10 @@
1
- function _array_like_to_array(arr, len) {
1
+ function _arrayLikeToArray(arr, len) {
2
2
  if (len == null || len > arr.length) len = arr.length;
3
3
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
4
  return arr2;
5
5
  }
6
- function _array_without_holes(arr) {
7
- if (Array.isArray(arr)) return _array_like_to_array(arr);
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
8
  }
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
10
  try {
@@ -20,7 +20,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
20
20
  Promise.resolve(value).then(_next, _throw);
21
21
  }
22
22
  }
23
- function _async_to_generator(fn) {
23
+ function _asyncToGenerator(fn) {
24
24
  return function() {
25
25
  var self = this, args = arguments;
26
26
  return new Promise(function(resolve, reject) {
@@ -35,7 +35,7 @@ function _async_to_generator(fn) {
35
35
  });
36
36
  };
37
37
  }
38
- function _class_call_check(instance, Constructor) {
38
+ function _classCallCheck(instance, Constructor) {
39
39
  if (!(instance instanceof Constructor)) {
40
40
  throw new TypeError("Cannot call a class as a function");
41
41
  }
@@ -49,151 +49,44 @@ function _defineProperties(target, props) {
49
49
  Object.defineProperty(target, descriptor.key, descriptor);
50
50
  }
51
51
  }
52
- function _create_class(Constructor, protoProps, staticProps) {
52
+ function _createClass(Constructor, protoProps, staticProps) {
53
53
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54
54
  if (staticProps) _defineProperties(Constructor, staticProps);
55
55
  return Constructor;
56
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(iter) {
57
+ function _iterableToArray(iter) {
71
58
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
72
59
  }
73
- function _non_iterable_spread() {
60
+ function _nonIterableSpread() {
74
61
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
75
62
  }
76
- function _to_consumable_array(arr) {
77
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
63
+ function _toConsumableArray(arr) {
64
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
78
65
  }
79
- function _unsupported_iterable_to_array(o, minLen) {
66
+ function _unsupportedIterableToArray(o, minLen) {
80
67
  if (!o) return;
81
- if (typeof o === "string") return _array_like_to_array(o, minLen);
68
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
82
69
  var n = Object.prototype.toString.call(o).slice(8, -1);
83
70
  if (n === "Object" && o.constructor) n = o.constructor.name;
84
71
  if (n === "Map" || n === "Set") return Array.from(n);
85
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
86
- }
87
- function _ts_generator(thisArg, body) {
88
- var f, y, t, g, _ = {
89
- label: 0,
90
- sent: function() {
91
- if (t[0] & 1) throw t[1];
92
- return t[1];
93
- },
94
- trys: [],
95
- ops: []
96
- };
97
- return g = {
98
- next: verb(0),
99
- "throw": verb(1),
100
- "return": verb(2)
101
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
102
- return this;
103
- }), g;
104
- function verb(n) {
105
- return function(v) {
106
- return step([
107
- n,
108
- v
109
- ]);
110
- };
111
- }
112
- function step(op) {
113
- if (f) throw new TypeError("Generator is already executing.");
114
- while(_)try {
115
- 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;
116
- if (y = 0, t) op = [
117
- op[0] & 2,
118
- t.value
119
- ];
120
- switch(op[0]){
121
- case 0:
122
- case 1:
123
- t = op;
124
- break;
125
- case 4:
126
- _.label++;
127
- return {
128
- value: op[1],
129
- done: false
130
- };
131
- case 5:
132
- _.label++;
133
- y = op[1];
134
- op = [
135
- 0
136
- ];
137
- continue;
138
- case 7:
139
- op = _.ops.pop();
140
- _.trys.pop();
141
- continue;
142
- default:
143
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
144
- _ = 0;
145
- continue;
146
- }
147
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
148
- _.label = op[1];
149
- break;
150
- }
151
- if (op[0] === 6 && _.label < t[1]) {
152
- _.label = t[1];
153
- t = op;
154
- break;
155
- }
156
- if (t && _.label < t[2]) {
157
- _.label = t[2];
158
- _.ops.push(op);
159
- break;
160
- }
161
- if (t[2]) _.ops.pop();
162
- _.trys.pop();
163
- continue;
164
- }
165
- op = body.call(thisArg, _);
166
- } catch (e) {
167
- op = [
168
- 6,
169
- e
170
- ];
171
- y = 0;
172
- } finally{
173
- f = t = 0;
174
- }
175
- if (op[0] & 5) throw op[1];
176
- return {
177
- value: op[0] ? op[1] : void 0,
178
- done: true
179
- };
180
- }
72
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
181
73
  }
182
- import { error, logerror } from "@byteluck-fe/model-driven-shared";
74
+ import regeneratorRuntime from "regenerator-runtime";
75
+ import { error, logerror } from '@byteluck-fe/model-driven-shared';
183
76
  export var ActionManager = /*#__PURE__*/ function() {
184
77
  "use strict";
185
78
  function ActionManager() {
186
- _class_call_check(this, ActionManager);
187
- _define_property(this, "actionMap", new Map());
188
- _define_property(this, "buildinActions", {});
189
- /**
190
- * 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
191
- */ _define_property(this, "actionUtils", {});
192
- /**
193
- * 用于存储es module解析出来的源码,CustomVueControlPlugin
194
- */ _define_property(this, "sources", {});
79
+ _classCallCheck(this, ActionManager);
80
+ this.actionMap = new Map();
81
+ this.buildinActions = {};
82
+ /**
83
+ * 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
84
+ */ this.actionUtils = {};
85
+ /**
86
+ * 用于存储es module解析出来的源码,CustomVueControlPlugin
87
+ */ this.sources = {};
195
88
  }
196
- _create_class(ActionManager, [
89
+ _createClass(ActionManager, [
197
90
  {
198
91
  key: "execAction",
199
92
  value: function execAction(name, context) {
@@ -201,60 +94,51 @@ export var ActionManager = /*#__PURE__*/ function() {
201
94
  args[_key - 2] = arguments[_key];
202
95
  }
203
96
  var _this = this;
204
- return _async_to_generator(function() {
205
- var action, _action_func, result, e;
206
- return _ts_generator(this, function(_state) {
207
- switch(_state.label){
97
+ return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
98
+ var action, _func, result;
99
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
100
+ while(1)switch(_ctx.prev = _ctx.next){
208
101
  case 0:
209
102
  action = _this.actionMap.get(name);
210
- if (!action) {
211
- return [
212
- 2
213
- ];
103
+ if (action) {
104
+ _ctx.next = 3;
105
+ break;
214
106
  }
215
- _state.label = 1;
216
- case 1:
217
- _state.trys.push([
218
- 1,
219
- 3,
220
- ,
221
- 4
222
- ]);
223
- return [
224
- 4,
225
- (_action_func = action.func).call.apply(_action_func, [
226
- null,
227
- context
228
- ].concat(_to_consumable_array(args)))
229
- ];
230
- case 2:
231
- result = _state.sent();
232
- return [
233
- 2,
234
- result
235
- ];
107
+ return _ctx.abrupt("return");
236
108
  case 3:
237
- e = _state.sent();
109
+ _ctx.prev = 3;
110
+ ;
111
+ _ctx.next = 7;
112
+ return (_func = action.func).call.apply(_func, [
113
+ null,
114
+ context
115
+ ].concat(_toConsumableArray(args)));
116
+ case 7:
117
+ result = _ctx.sent;
118
+ return _ctx.abrupt("return", result);
119
+ case 11:
120
+ _ctx.prev = 11;
121
+ _ctx.t0 = _ctx["catch"](3);
238
122
  // 执行的时候不使用throw error,而是使用console.error,避免阻塞内置代码的执行
239
- logerror("".concat(action.id, " Exception during calling action: ").concat(e));
240
- return [
241
- 3,
242
- 4
243
- ];
244
- case 4:
245
- return [
246
- 2
247
- ];
123
+ logerror("".concat(action.id, " Exception during calling action: ").concat(_ctx.t0));
124
+ case 14:
125
+ case "end":
126
+ return _ctx.stop();
248
127
  }
249
- });
250
- })();
128
+ }, _callee, null, [
129
+ [
130
+ 3,
131
+ 11
132
+ ]
133
+ ]);
134
+ }))();
251
135
  }
252
136
  },
253
137
  {
254
138
  key: "addAction",
255
139
  value: function addAction(name, func) {
256
140
  if (this.actionMap.has(name)) {
257
- error("duplicated action key");
141
+ error('duplicated action key');
258
142
  }
259
143
  var action = new Action(name, func);
260
144
  this.actionMap.set(name, action);
@@ -265,9 +149,8 @@ export var ActionManager = /*#__PURE__*/ function() {
265
149
  }();
266
150
  var Action = function Action(id, func) {
267
151
  "use strict";
268
- _class_call_check(this, Action);
269
- _define_property(this, "func", void 0);
270
- _define_property(this, "id", "");
152
+ _classCallCheck(this, Action);
153
+ this.id = '';
271
154
  this.id = id;
272
155
  this.func = func;
273
156
  };
@@ -12,7 +12,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
12
  Promise.resolve(value).then(_next, _throw);
13
13
  }
14
14
  }
15
- function _async_to_generator(fn) {
15
+ function _asyncToGenerator(fn) {
16
16
  return function() {
17
17
  var self = this, args = arguments;
18
18
  return new Promise(function(resolve, reject) {
@@ -27,7 +27,7 @@ function _async_to_generator(fn) {
27
27
  });
28
28
  };
29
29
  }
30
- function _class_call_check(instance, Constructor) {
30
+ function _classCallCheck(instance, Constructor) {
31
31
  if (!(instance instanceof Constructor)) {
32
32
  throw new TypeError("Cannot call a class as a function");
33
33
  }
@@ -41,129 +41,21 @@ function _defineProperties(target, props) {
41
41
  Object.defineProperty(target, descriptor.key, descriptor);
42
42
  }
43
43
  }
44
- function _create_class(Constructor, protoProps, staticProps) {
44
+ function _createClass(Constructor, protoProps, staticProps) {
45
45
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
46
  if (staticProps) _defineProperties(Constructor, staticProps);
47
47
  return Constructor;
48
48
  }
49
- function _define_property(obj, key, value) {
50
- if (key in obj) {
51
- Object.defineProperty(obj, key, {
52
- value: value,
53
- enumerable: true,
54
- configurable: true,
55
- writable: true
56
- });
57
- } else {
58
- obj[key] = value;
59
- }
60
- return obj;
61
- }
62
- function _ts_generator(thisArg, body) {
63
- var f, y, t, g, _ = {
64
- label: 0,
65
- sent: function() {
66
- if (t[0] & 1) throw t[1];
67
- return t[1];
68
- },
69
- trys: [],
70
- ops: []
71
- };
72
- return g = {
73
- next: verb(0),
74
- "throw": verb(1),
75
- "return": verb(2)
76
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
77
- return this;
78
- }), g;
79
- function verb(n) {
80
- return function(v) {
81
- return step([
82
- n,
83
- v
84
- ]);
85
- };
86
- }
87
- function step(op) {
88
- if (f) throw new TypeError("Generator is already executing.");
89
- while(_)try {
90
- 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;
91
- if (y = 0, t) op = [
92
- op[0] & 2,
93
- t.value
94
- ];
95
- switch(op[0]){
96
- case 0:
97
- case 1:
98
- t = op;
99
- break;
100
- case 4:
101
- _.label++;
102
- return {
103
- value: op[1],
104
- done: false
105
- };
106
- case 5:
107
- _.label++;
108
- y = op[1];
109
- op = [
110
- 0
111
- ];
112
- continue;
113
- case 7:
114
- op = _.ops.pop();
115
- _.trys.pop();
116
- continue;
117
- default:
118
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
119
- _ = 0;
120
- continue;
121
- }
122
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
123
- _.label = op[1];
124
- break;
125
- }
126
- if (op[0] === 6 && _.label < t[1]) {
127
- _.label = t[1];
128
- t = op;
129
- break;
130
- }
131
- if (t && _.label < t[2]) {
132
- _.label = t[2];
133
- _.ops.push(op);
134
- break;
135
- }
136
- if (t[2]) _.ops.pop();
137
- _.trys.pop();
138
- continue;
139
- }
140
- op = body.call(thisArg, _);
141
- } catch (e) {
142
- op = [
143
- 6,
144
- e
145
- ];
146
- y = 0;
147
- } finally{
148
- f = t = 0;
149
- }
150
- if (op[0] & 5) throw op[1];
151
- return {
152
- value: op[0] ? op[1] : void 0,
153
- done: true
154
- };
155
- }
156
- }
157
- import { JSONCopy, logerror } from "@byteluck-fe/model-driven-shared";
49
+ import regeneratorRuntime from "regenerator-runtime";
50
+ import { JSONCopy, logerror } from '@byteluck-fe/model-driven-shared';
158
51
  export var DataManager = /*#__PURE__*/ function() {
159
52
  "use strict";
160
53
  function DataManager(callbackExecuter) {
161
- _class_call_check(this, DataManager);
162
- _define_property(this, "_dataStore", new Map());
163
- _define_property(this, "executer", void 0);
54
+ _classCallCheck(this, DataManager);
55
+ this._dataStore = new Map();
164
56
  this.executer = callbackExecuter;
165
57
  }
166
- _create_class(DataManager, [
58
+ _createClass(DataManager, [
167
59
  {
168
60
  key: "add",
169
61
  value: function add(key, data) {
@@ -187,25 +79,24 @@ export var DataManager = /*#__PURE__*/ function() {
187
79
  key: "getRemoteData",
188
80
  value: function getRemoteData(payload) {
189
81
  var _this = this;
190
- return _async_to_generator(function() {
191
- return _ts_generator(this, function(_state) {
192
- if (_this.executer === undefined) {
193
- logerror("未初始化executer");
194
- return [
195
- 2,
196
- []
197
- ];
198
- } else {
199
- return [
200
- 2,
201
- _this.executer(payload)
202
- ];
82
+ return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
83
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
84
+ while(1)switch(_ctx.prev = _ctx.next){
85
+ case 0:
86
+ if (!(_this.executer === undefined)) {
87
+ _ctx.next = 5;
88
+ break;
89
+ }
90
+ logerror('未初始化executer');
91
+ return _ctx.abrupt("return", []);
92
+ case 5:
93
+ return _ctx.abrupt("return", _this.executer(payload));
94
+ case 6:
95
+ case "end":
96
+ return _ctx.stop();
203
97
  }
204
- return [
205
- 2
206
- ];
207
- });
208
- })();
98
+ }, _callee);
99
+ }))();
209
100
  }
210
101
  }
211
102
  ]);