@byteluck-fe/model-driven-engine 1.3.0-beta.25

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 (42) hide show
  1. package/README.md +30 -0
  2. package/dist/esm/common/ActionManager.js +135 -0
  3. package/dist/esm/common/DataManager.js +77 -0
  4. package/dist/esm/common/Engine.js +1161 -0
  5. package/dist/esm/common/OkWorker.js +89 -0
  6. package/dist/esm/common/Plugin.js +10 -0
  7. package/dist/esm/common/Runtime.js +257 -0
  8. package/dist/esm/common/Store.js +331 -0
  9. package/dist/esm/common/checkerValue.js +547 -0
  10. package/dist/esm/common/index.js +2 -0
  11. package/dist/esm/common/proxyState.js +316 -0
  12. package/dist/esm/index.js +3 -0
  13. package/dist/esm/plugins/CalcPlugin.js +394 -0
  14. package/dist/esm/plugins/ControlsEventPlugin.js +168 -0
  15. package/dist/esm/plugins/ES6ModulePlugin.js +145 -0
  16. package/dist/esm/plugins/LifecycleEventPlugin.js +180 -0
  17. package/dist/esm/plugins/StylePlugin.js +26 -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 +48 -0
  21. package/dist/index.umd.js +2 -0
  22. package/dist/types/common/ActionManager.d.ts +14 -0
  23. package/dist/types/common/DataManager.d.ts +10 -0
  24. package/dist/types/common/Engine.d.ts +165 -0
  25. package/dist/types/common/OkWorker.d.ts +13 -0
  26. package/dist/types/common/Plugin.d.ts +6 -0
  27. package/dist/types/common/Runtime.d.ts +22 -0
  28. package/dist/types/common/Store.d.ts +49 -0
  29. package/dist/types/common/checkerValue.d.ts +3 -0
  30. package/dist/types/common/index.d.ts +2 -0
  31. package/dist/types/common/proxyState.d.ts +29 -0
  32. package/dist/types/index.d.ts +3 -0
  33. package/dist/types/plugins/CalcPlugin.d.ts +121 -0
  34. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -0
  35. package/dist/types/plugins/ES6ModulePlugin.d.ts +25 -0
  36. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -0
  37. package/dist/types/plugins/StylePlugin.d.ts +12 -0
  38. package/dist/types/plugins/index.d.ts +5 -0
  39. package/dist/types/utils/index.d.ts +1 -0
  40. package/dist/types/utils/runtimeUtils.d.ts +4 -0
  41. package/package.json +32 -0
  42. package/src/index.ts +3 -0
package/README.md ADDED
@@ -0,0 +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
+ ```
@@ -0,0 +1,135 @@
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 _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(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 _iterableToArray(iter) {
44
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
45
+ }
46
+ function _nonIterableSpread() {
47
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
+ }
49
+ function _toConsumableArray(arr) {
50
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
51
+ }
52
+ function _unsupportedIterableToArray(o, minLen) {
53
+ if (!o) return;
54
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
55
+ var n = Object.prototype.toString.call(o).slice(8, -1);
56
+ if (n === "Object" && o.constructor) n = o.constructor.name;
57
+ if (n === "Map" || n === "Set") return Array.from(n);
58
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
59
+ }
60
+ import regeneratorRuntime from "regenerator-runtime";
61
+ import { error, logerror } from "@byteluck-fe/model-driven-shared";
62
+ export var ActionManager = /*#__PURE__*/ function() {
63
+ "use strict";
64
+ function ActionManager() {
65
+ _classCallCheck(this, ActionManager);
66
+ this.actionMap = new Map();
67
+ this.buildinActions = {};
68
+ /**
69
+ * 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
70
+ */ this.actionUtils = {};
71
+ /**
72
+ * 用于存储es module解析出来的源码,CustomVueControlPlugin
73
+ */ this.sources = {};
74
+ }
75
+ var _proto = ActionManager.prototype;
76
+ _proto.execAction = function execAction(name, context) {
77
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
78
+ args[_key - 2] = arguments[_key];
79
+ }
80
+ var _this = this;
81
+ return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
82
+ var action, _func, result;
83
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
84
+ while(1)switch(_ctx.prev = _ctx.next){
85
+ case 0:
86
+ action = _this.actionMap.get(name);
87
+ if (action) {
88
+ _ctx.next = 3;
89
+ break;
90
+ }
91
+ return _ctx.abrupt("return");
92
+ case 3:
93
+ _ctx.prev = 3;
94
+ ;
95
+ _ctx.next = 7;
96
+ return (_func = action.func).call.apply(_func, [
97
+ null,
98
+ context
99
+ ].concat(_toConsumableArray(args)));
100
+ case 7:
101
+ result = _ctx.sent;
102
+ return _ctx.abrupt("return", result);
103
+ case 11:
104
+ _ctx.prev = 11;
105
+ _ctx.t0 = _ctx["catch"](3);
106
+ // 执行的时候不使用throw error,而是使用console.error,避免阻塞内置代码的执行
107
+ logerror("".concat(action.id, " Exception during calling action: ").concat(_ctx.t0));
108
+ case 14:
109
+ case "end":
110
+ return _ctx.stop();
111
+ }
112
+ }, _callee, null, [
113
+ [
114
+ 3,
115
+ 11
116
+ ]
117
+ ]);
118
+ }))();
119
+ };
120
+ _proto.addAction = function addAction(name, func) {
121
+ if (this.actionMap.has(name)) {
122
+ error("duplicated action key");
123
+ }
124
+ var action = new Action(name, func);
125
+ this.actionMap.set(name, action);
126
+ };
127
+ return ActionManager;
128
+ }();
129
+ var Action = function Action(id, func) {
130
+ "use strict";
131
+ _classCallCheck(this, Action);
132
+ this.id = "";
133
+ this.id = id;
134
+ this.func = func;
135
+ };
@@ -0,0 +1,77 @@
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 _asyncToGenerator(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 _classCallCheck(instance, Constructor) {
31
+ if (!(instance instanceof Constructor)) {
32
+ throw new TypeError("Cannot call a class as a function");
33
+ }
34
+ }
35
+ import regeneratorRuntime from "regenerator-runtime";
36
+ import { JSONCopy, logerror } from "@byteluck-fe/model-driven-shared";
37
+ export var DataManager = /*#__PURE__*/ function() {
38
+ "use strict";
39
+ function DataManager(callbackExecuter) {
40
+ _classCallCheck(this, DataManager);
41
+ this._dataStore = new Map();
42
+ this.executer = callbackExecuter;
43
+ }
44
+ var _proto = DataManager.prototype;
45
+ _proto.add = function add(key, data) {
46
+ this._dataStore.set(key, data);
47
+ };
48
+ _proto.get = function get(key) {
49
+ var result = this._dataStore.get(key);
50
+ return JSONCopy(result);
51
+ };
52
+ _proto.remove = function remove(key) {
53
+ this._dataStore.delete(key);
54
+ };
55
+ _proto.getRemoteData = function getRemoteData(payload) {
56
+ var _this = this;
57
+ return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
58
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
59
+ while(1)switch(_ctx.prev = _ctx.next){
60
+ case 0:
61
+ if (!(_this.executer === undefined)) {
62
+ _ctx.next = 5;
63
+ break;
64
+ }
65
+ logerror("未初始化executer");
66
+ return _ctx.abrupt("return", []);
67
+ case 5:
68
+ return _ctx.abrupt("return", _this.executer(payload));
69
+ case 6:
70
+ case "end":
71
+ return _ctx.stop();
72
+ }
73
+ }, _callee);
74
+ }))();
75
+ };
76
+ return DataManager;
77
+ }();