@byteluck-fe/model-driven-engine 2.7.0-alpha.30a → 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
@@ -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,132 +41,23 @@ 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 { EventLogic } from "@byteluck-fe/model-driven-shared";
49
+ import regeneratorRuntime from "regenerator-runtime";
50
+ import { EventLogic } from '@byteluck-fe/model-driven-shared';
158
51
  // type EventKeyMap = {
159
52
  // [eventKey in EventKeys]?: string
160
53
  // }
161
54
  export var ControlsEventPlugin = /*#__PURE__*/ function() {
162
55
  "use strict";
163
56
  function ControlsEventPlugin(config) {
164
- _class_call_check(this, ControlsEventPlugin);
165
- _define_property(this, "config", void 0);
166
- _define_property(this, "engine", void 0);
57
+ _classCallCheck(this, ControlsEventPlugin);
167
58
  this.config = config;
168
59
  }
169
- _create_class(ControlsEventPlugin, [
60
+ _createClass(ControlsEventPlugin, [
170
61
  {
171
62
  key: "apply",
172
63
  value: function apply(engine) {
@@ -208,36 +99,30 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
208
99
  value: function engineAddEventListener(eventKey, controlEventKey) {
209
100
  var _this = this;
210
101
  this.engine.on(eventKey, function() {
211
- var _ref = _async_to_generator(function(payload) {
212
- return _ts_generator(this, function(_state) {
213
- switch(_state.label){
102
+ var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(payload) {
103
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
104
+ while(1)switch(_ctx.prev = _ctx.next){
214
105
  case 0:
215
- // 初始化state的时候不触发change事件,必须在engine mounted以后才触发
216
- if (eventKey === "change" && !_this.engine.isMounted) {
217
- return [
218
- 2
219
- ];
106
+ if (!(eventKey === 'change' && !_this.engine.isMounted)) {
107
+ _ctx.next = 2;
108
+ break;
220
109
  }
221
- if (!(payload.instance !== undefined)) return [
222
- 3,
223
- 2
224
- ];
225
- return [
226
- 4,
227
- _this.callControlEvent(controlEventKey, payload)
228
- ];
229
- case 1:
230
- return [
231
- 2,
232
- _state.sent()
233
- ];
110
+ return _ctx.abrupt("return");
234
111
  case 2:
235
- return [
236
- 2
237
- ];
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();
238
123
  }
239
- });
240
- });
124
+ }, _callee);
125
+ }));
241
126
  return function(payload) {
242
127
  return _ref.apply(this, arguments);
243
128
  };
@@ -248,66 +133,58 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
248
133
  key: "callControlEvent",
249
134
  value: function callControlEvent(name, payload) {
250
135
  var _this = this;
251
- return _async_to_generator(function() {
136
+ return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() {
252
137
  var events, result;
253
- return _ts_generator(this, function(_state) {
254
- switch(_state.label){
138
+ return regeneratorRuntime.wrap(function _callee$(_ctx1) {
139
+ while(1)switch(_ctx1.prev = _ctx1.next){
255
140
  case 0:
256
141
  events = _this.config[payload.instance.id];
257
- if (!events || !Array.isArray(events[name])) {
258
- return [
259
- 2,
260
- []
261
- ];
142
+ if (!(!events || !Array.isArray(events[name]))) {
143
+ _ctx1.next = 3;
144
+ break;
262
145
  }
263
- return [
264
- 4,
265
- Promise.all(events[name].map(function() {
266
- var _ref = _async_to_generator(function(eventName) {
267
- var execResult;
268
- return _ts_generator(this, function(_state) {
269
- switch(_state.label){
270
- case 0:
271
- return [
272
- 4,
273
- _this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
274
- // this.engine,
275
- // this.engine.getAction().actionUtils, //以前是params,空的
276
- payload)
277
- ];
278
- case 1:
279
- execResult = _state.sent();
280
- return [
281
- 2,
282
- execResult
283
- ];
284
- }
285
- });
286
- });
287
- return function(eventName) {
288
- return _ref.apply(this, arguments);
289
- };
290
- }()))
291
- ];
292
- case 1:
293
- result = _state.sent();
294
- if (result.includes(false)) {
295
- return [
296
- 2,
297
- false
298
- ];
299
- } else {
300
- return [
301
- 2,
302
- result
303
- ];
146
+ return _ctx1.abrupt("return", []);
147
+ case 3:
148
+ _ctx1.next = 5;
149
+ return Promise.all(events[name].map(function() {
150
+ var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(eventName) {
151
+ var execResult;
152
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
153
+ while(1)switch(_ctx.prev = _ctx.next){
154
+ case 0:
155
+ _ctx.next = 2;
156
+ return _this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
157
+ // this.engine,
158
+ // this.engine.getAction().actionUtils, //以前是params,空的
159
+ payload);
160
+ case 2:
161
+ execResult = _ctx.sent;
162
+ return _ctx.abrupt("return", execResult);
163
+ case 4:
164
+ case "end":
165
+ return _ctx.stop();
166
+ }
167
+ }, _callee);
168
+ }));
169
+ return function(eventName) {
170
+ return _ref.apply(this, arguments);
171
+ };
172
+ }()));
173
+ case 5:
174
+ result = _ctx1.sent;
175
+ if (!result.includes(false)) {
176
+ _ctx1.next = 10;
177
+ break;
304
178
  }
305
- return [
306
- 2
307
- ];
179
+ return _ctx1.abrupt("return", false);
180
+ case 10:
181
+ return _ctx1.abrupt("return", result);
182
+ case 11:
183
+ case "end":
184
+ return _ctx1.stop();
308
185
  }
309
- });
310
- })();
186
+ }, _callee1);
187
+ }))();
311
188
  }
312
189
  }
313
190
  ]);
@@ -1,12 +1,12 @@
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_with_holes(arr) {
6
+ function _arrayWithHoles(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
- function _class_call_check(instance, Constructor) {
9
+ function _classCallCheck(instance, Constructor) {
10
10
  if (!(instance instanceof Constructor)) {
11
11
  throw new TypeError("Cannot call a class as a function");
12
12
  }
@@ -20,25 +20,12 @@ function _defineProperties(target, props) {
20
20
  Object.defineProperty(target, descriptor.key, descriptor);
21
21
  }
22
22
  }
23
- function _create_class(Constructor, protoProps, staticProps) {
23
+ function _createClass(Constructor, protoProps, staticProps) {
24
24
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
25
  if (staticProps) _defineProperties(Constructor, staticProps);
26
26
  return Constructor;
27
27
  }
28
- function _define_property(obj, key, value) {
29
- if (key in obj) {
30
- Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- } else {
37
- obj[key] = value;
38
- }
39
- return obj;
40
- }
41
- function _iterable_to_array_limit(arr, i) {
28
+ function _iterableToArrayLimit(arr, i) {
42
29
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
43
30
  if (_i == null) return;
44
31
  var _arr = [];
@@ -62,34 +49,30 @@ function _iterable_to_array_limit(arr, i) {
62
49
  }
63
50
  return _arr;
64
51
  }
65
- function _non_iterable_rest() {
52
+ function _nonIterableRest() {
66
53
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67
54
  }
68
- function _sliced_to_array(arr, i) {
69
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
55
+ function _slicedToArray(arr, i) {
56
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
70
57
  }
71
- function _unsupported_iterable_to_array(o, minLen) {
58
+ function _unsupportedIterableToArray(o, minLen) {
72
59
  if (!o) return;
73
- if (typeof o === "string") return _array_like_to_array(o, minLen);
60
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
74
61
  var n = Object.prototype.toString.call(o).slice(8, -1);
75
62
  if (n === "Object" && o.constructor) n = o.constructor.name;
76
63
  if (n === "Map" || n === "Set") return Array.from(n);
77
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
64
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
78
65
  }
79
- import { error } from "@byteluck-fe/model-driven-shared";
66
+ import { error } from '@byteluck-fe/model-driven-shared';
80
67
  export var ES6ModulePlugin = /*#__PURE__*/ function() {
81
68
  "use strict";
82
69
  function ES6ModulePlugin(config, env, eventJs) {
83
- _class_call_check(this, ES6ModulePlugin);
84
- _define_property(this, "config", void 0);
85
- _define_property(this, "engine", void 0);
86
- _define_property(this, "env", void 0);
87
- _define_property(this, "eventJs", void 0);
70
+ _classCallCheck(this, ES6ModulePlugin);
88
71
  this.config = config;
89
72
  this.env = env;
90
73
  this.eventJs = eventJs;
91
74
  }
92
- _create_class(ES6ModulePlugin, [
75
+ _createClass(ES6ModulePlugin, [
93
76
  {
94
77
  key: "apply",
95
78
  value: function apply(engine) {
@@ -107,7 +90,7 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
107
90
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
108
91
  try {
109
92
  for(var _iterator = Object.entries(this.eventJs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
110
- var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
93
+ var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
111
94
  actionManager.addAction(key, value);
112
95
  }
113
96
  } catch (err) {
@@ -132,7 +115,7 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
132
115
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
133
116
  try {
134
117
  for(var _iterator1 = Object.entries(res.funcMap)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
135
- var _step_value1 = _sliced_to_array(_step1.value, 2), key1 = _step_value1[0], value1 = _step_value1[1];
118
+ var _value1 = _slicedToArray(_step1.value, 2), key1 = _value1[0], value1 = _value1[1];
136
119
  actionManager.addAction(key1, value1);
137
120
  }
138
121
  } catch (err) {
@@ -170,11 +153,11 @@ export function parseModule(action, engine, env) {
170
153
  }
171
154
  };
172
155
  try {
173
- new Function("module", "exports", compiled).call(module, module, module.exports);
156
+ new Function('module', 'exports', compiled).call(module, module, module.exports);
174
157
  } catch (e) {
175
- error(e.message + ". fail to parse the module");
176
- if (process.env.NODE_ENV !== "production") {
177
- error("fail to parse the module");
158
+ error(e.message + '. fail to parse the module');
159
+ if (process.env.NODE_ENV !== 'production') {
160
+ error('fail to parse the module');
178
161
  }
179
162
  }
180
163
  var funcMap = {};
@@ -182,8 +165,8 @@ export function parseModule(action, engine, env) {
182
165
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
183
166
  try {
184
167
  for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
185
- var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
186
- if (typeof value === "function") {
168
+ var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
169
+ if (typeof value === 'function') {
187
170
  funcMap[key] = value;
188
171
  } else {
189
172
  variables[key] = value;