@byteluck-fe/model-driven-engine 2.22.4-beta.1 → 2.22.4-beta.10

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 +269 -0
  3. package/dist/esm/common/DataManager.js +209 -0
  4. package/dist/esm/common/Engine.js +1785 -0
  5. package/dist/esm/common/OkWorker.js +134 -0
  6. package/dist/esm/common/Plugin.js +10 -0
  7. package/dist/esm/common/Runtime.js +458 -0
  8. package/dist/esm/common/Store.js +444 -0
  9. package/dist/esm/common/checkerValue.js +609 -0
  10. package/dist/esm/common/index.js +2 -0
  11. package/dist/esm/common/proxyState.js +321 -0
  12. package/dist/esm/index.js +3 -0
  13. package/dist/esm/plugins/CalcPlugin.js +500 -0
  14. package/dist/esm/plugins/ControlsEventPlugin.js +315 -0
  15. package/dist/esm/plugins/ES6ModulePlugin.js +210 -0
  16. package/dist/esm/plugins/LifecycleEventPlugin.js +310 -0
  17. package/dist/esm/plugins/StylePlugin.js +74 -0
  18. package/dist/esm/plugins/index.js +5 -0
  19. package/dist/esm/utils/index.js +1 -0
  20. package/dist/esm/utils/runtimeUtils.js +45 -0
  21. package/dist/index.umd.js +54 -0
  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 +201 -0
  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 +31 -31
  28. package/dist/types/common/Store.d.ts +54 -54
  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 +17 -17
  35. package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
  36. package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -15
  37. package/dist/types/plugins/StylePlugin.d.ts +13 -13
  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 +9 -6
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
+ ```
@@ -0,0 +1,269 @@
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_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(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(iter) {
71
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
72
+ }
73
+ function _non_iterable_spread() {
74
+ 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
+ }
76
+ function _to_consumable_array(arr) {
77
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
78
+ }
79
+ function _unsupported_iterable_to_array(o, minLen) {
80
+ if (!o) return;
81
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
82
+ var n = Object.prototype.toString.call(o).slice(8, -1);
83
+ if (n === "Object" && o.constructor) n = o.constructor.name;
84
+ 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, _ = {
89
+ label: 0,
90
+ sent: function() {
91
+ if (t[0] & 1) throw t[1];
92
+ return t[1];
93
+ },
94
+ trys: [],
95
+ ops: []
96
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
97
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
98
+ return this;
99
+ }), g;
100
+ function verb(n) {
101
+ return function(v) {
102
+ return step([
103
+ n,
104
+ v
105
+ ]);
106
+ };
107
+ }
108
+ function step(op) {
109
+ if (f) throw new TypeError("Generator is already executing.");
110
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
111
+ 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;
112
+ if (y = 0, t) op = [
113
+ op[0] & 2,
114
+ t.value
115
+ ];
116
+ switch(op[0]){
117
+ case 0:
118
+ case 1:
119
+ t = op;
120
+ break;
121
+ case 4:
122
+ _.label++;
123
+ return {
124
+ value: op[1],
125
+ done: false
126
+ };
127
+ case 5:
128
+ _.label++;
129
+ y = op[1];
130
+ op = [
131
+ 0
132
+ ];
133
+ continue;
134
+ case 7:
135
+ op = _.ops.pop();
136
+ _.trys.pop();
137
+ continue;
138
+ default:
139
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
140
+ _ = 0;
141
+ continue;
142
+ }
143
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
144
+ _.label = op[1];
145
+ break;
146
+ }
147
+ if (op[0] === 6 && _.label < t[1]) {
148
+ _.label = t[1];
149
+ t = op;
150
+ break;
151
+ }
152
+ if (t && _.label < t[2]) {
153
+ _.label = t[2];
154
+ _.ops.push(op);
155
+ break;
156
+ }
157
+ if (t[2]) _.ops.pop();
158
+ _.trys.pop();
159
+ continue;
160
+ }
161
+ op = body.call(thisArg, _);
162
+ } catch (e) {
163
+ op = [
164
+ 6,
165
+ e
166
+ ];
167
+ y = 0;
168
+ } finally{
169
+ f = t = 0;
170
+ }
171
+ if (op[0] & 5) throw op[1];
172
+ return {
173
+ value: op[0] ? op[1] : void 0,
174
+ done: true
175
+ };
176
+ }
177
+ }
178
+ import { error, logerror } from '@byteluck-fe/model-driven-shared';
179
+ export var ActionManager = /*#__PURE__*/ function() {
180
+ "use strict";
181
+ function ActionManager() {
182
+ _class_call_check(this, ActionManager);
183
+ _define_property(this, "actionMap", new Map());
184
+ _define_property(this, "buildinActions", {});
185
+ /**
186
+ * 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
187
+ */ _define_property(this, "actionUtils", {});
188
+ /**
189
+ * 用于存储es module解析出来的源码,CustomVueControlPlugin
190
+ */ _define_property(this, "sources", {});
191
+ }
192
+ _create_class(ActionManager, [
193
+ {
194
+ key: "execAction",
195
+ value: function execAction(name, context) {
196
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
197
+ args[_key - 2] = arguments[_key];
198
+ }
199
+ return _async_to_generator(function() {
200
+ var action, _action_func, result, e;
201
+ return _ts_generator(this, function(_state) {
202
+ switch(_state.label){
203
+ case 0:
204
+ action = this.actionMap.get(name);
205
+ if (!action) {
206
+ return [
207
+ 2
208
+ ];
209
+ }
210
+ _state.label = 1;
211
+ case 1:
212
+ _state.trys.push([
213
+ 1,
214
+ 3,
215
+ ,
216
+ 4
217
+ ]);
218
+ return [
219
+ 4,
220
+ (_action_func = action.func).call.apply(_action_func, [
221
+ null,
222
+ context
223
+ ].concat(_to_consumable_array(args)))
224
+ ];
225
+ case 2:
226
+ result = _state.sent();
227
+ return [
228
+ 2,
229
+ result
230
+ ];
231
+ case 3:
232
+ e = _state.sent();
233
+ // 执行的时候不使用throw error,而是使用console.error,避免阻塞内置代码的执行
234
+ logerror("".concat(action.id, " Exception during calling action: ").concat(e));
235
+ //尤其是在表单提交前事件异常,不能默认允许它通过。
236
+ return [
237
+ 2,
238
+ false
239
+ ];
240
+ case 4:
241
+ return [
242
+ 2
243
+ ];
244
+ }
245
+ });
246
+ }).call(this);
247
+ }
248
+ },
249
+ {
250
+ key: "addAction",
251
+ value: function addAction(name, func) {
252
+ if (this.actionMap.has(name)) {
253
+ error('duplicated action key');
254
+ }
255
+ var action = new Action(name, func);
256
+ this.actionMap.set(name, action);
257
+ }
258
+ }
259
+ ]);
260
+ return ActionManager;
261
+ }();
262
+ var Action = function Action(id, func) {
263
+ "use strict";
264
+ _class_call_check(this, Action);
265
+ _define_property(this, "func", void 0);
266
+ _define_property(this, "id", '');
267
+ this.id = id;
268
+ this.func = func;
269
+ };
@@ -0,0 +1,209 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _class_call_check(instance, Constructor) {
31
+ if (!(instance instanceof Constructor)) {
32
+ throw new TypeError("Cannot call a class as a function");
33
+ }
34
+ }
35
+ function _defineProperties(target, props) {
36
+ for(var i = 0; i < props.length; i++){
37
+ var descriptor = props[i];
38
+ descriptor.enumerable = descriptor.enumerable || false;
39
+ descriptor.configurable = true;
40
+ if ("value" in descriptor) descriptor.writable = true;
41
+ Object.defineProperty(target, descriptor.key, descriptor);
42
+ }
43
+ }
44
+ function _create_class(Constructor, protoProps, staticProps) {
45
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
+ if (staticProps) _defineProperties(Constructor, staticProps);
47
+ return Constructor;
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, _ = {
64
+ label: 0,
65
+ sent: function() {
66
+ if (t[0] & 1) throw t[1];
67
+ return t[1];
68
+ },
69
+ trys: [],
70
+ ops: []
71
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
72
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
73
+ return this;
74
+ }), g;
75
+ function verb(n) {
76
+ return function(v) {
77
+ return step([
78
+ n,
79
+ v
80
+ ]);
81
+ };
82
+ }
83
+ function step(op) {
84
+ if (f) throw new TypeError("Generator is already executing.");
85
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
86
+ 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;
87
+ if (y = 0, t) op = [
88
+ op[0] & 2,
89
+ t.value
90
+ ];
91
+ switch(op[0]){
92
+ case 0:
93
+ case 1:
94
+ t = op;
95
+ break;
96
+ case 4:
97
+ _.label++;
98
+ return {
99
+ value: op[1],
100
+ done: false
101
+ };
102
+ case 5:
103
+ _.label++;
104
+ y = op[1];
105
+ op = [
106
+ 0
107
+ ];
108
+ continue;
109
+ case 7:
110
+ op = _.ops.pop();
111
+ _.trys.pop();
112
+ continue;
113
+ default:
114
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
+ _ = 0;
116
+ continue;
117
+ }
118
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
119
+ _.label = op[1];
120
+ break;
121
+ }
122
+ if (op[0] === 6 && _.label < t[1]) {
123
+ _.label = t[1];
124
+ t = op;
125
+ break;
126
+ }
127
+ if (t && _.label < t[2]) {
128
+ _.label = t[2];
129
+ _.ops.push(op);
130
+ break;
131
+ }
132
+ if (t[2]) _.ops.pop();
133
+ _.trys.pop();
134
+ continue;
135
+ }
136
+ op = body.call(thisArg, _);
137
+ } catch (e) {
138
+ op = [
139
+ 6,
140
+ e
141
+ ];
142
+ y = 0;
143
+ } finally{
144
+ f = t = 0;
145
+ }
146
+ if (op[0] & 5) throw op[1];
147
+ return {
148
+ value: op[0] ? op[1] : void 0,
149
+ done: true
150
+ };
151
+ }
152
+ }
153
+ import { JSONCopy, logerror } from '@byteluck-fe/model-driven-shared';
154
+ export var DataManager = /*#__PURE__*/ function() {
155
+ "use strict";
156
+ function DataManager(callbackExecuter) {
157
+ _class_call_check(this, DataManager);
158
+ _define_property(this, "_dataStore", new Map());
159
+ _define_property(this, "executer", void 0);
160
+ this.executer = callbackExecuter;
161
+ }
162
+ _create_class(DataManager, [
163
+ {
164
+ key: "add",
165
+ value: function add(key, data) {
166
+ this._dataStore.set(key, data);
167
+ }
168
+ },
169
+ {
170
+ key: "get",
171
+ value: function get(key) {
172
+ var result = this._dataStore.get(key);
173
+ return JSONCopy(result);
174
+ }
175
+ },
176
+ {
177
+ key: "remove",
178
+ value: function remove(key) {
179
+ this._dataStore.delete(key);
180
+ }
181
+ },
182
+ {
183
+ key: "getRemoteData",
184
+ value: function getRemoteData(payload) {
185
+ return _async_to_generator(function() {
186
+ return _ts_generator(this, function(_state) {
187
+ if (this.executer === undefined) {
188
+ // @i18n-translate-ignore
189
+ logerror('未初始化executer');
190
+ return [
191
+ 2,
192
+ []
193
+ ];
194
+ } else {
195
+ return [
196
+ 2,
197
+ this.executer(payload)
198
+ ];
199
+ }
200
+ return [
201
+ 2
202
+ ];
203
+ });
204
+ }).call(this);
205
+ }
206
+ }
207
+ ]);
208
+ return DataManager;
209
+ }();