@byteluck-fe/model-driven-engine 2.7.0-alpha.0 → 2.7.0-alpha.2

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.
@@ -32,22 +32,102 @@ function _classCallCheck(instance, Constructor) {
32
32
  throw new TypeError("Cannot call a class as a function");
33
33
  }
34
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);
35
+ var __generator = this && this.__generator || function(thisArg, body) {
36
+ var f, y, t, g, _ = {
37
+ label: 0,
38
+ sent: function() {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ };
45
+ return(g = {
46
+ next: verb(0),
47
+ "throw": verb(1),
48
+ "return": verb(2)
49
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
50
+ return this;
51
+ }), g);
52
+ function verb(n) {
53
+ return function(v) {
54
+ return step([
55
+ n,
56
+ v
57
+ ]);
58
+ };
42
59
  }
43
- }
44
- function _createClass(Constructor, protoProps, staticProps) {
45
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
- if (staticProps) _defineProperties(Constructor, staticProps);
47
- return Constructor;
48
- }
49
- import regeneratorRuntime from "regenerator-runtime";
50
- import { EventLogic } from '@byteluck-fe/model-driven-shared';
60
+ function step(op) {
61
+ if (f) throw new TypeError("Generator is already executing.");
62
+ while(_)try {
63
+ 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;
64
+ if (y = 0, t) op = [
65
+ op[0] & 2,
66
+ t.value
67
+ ];
68
+ switch(op[0]){
69
+ case 0:
70
+ case 1:
71
+ t = op;
72
+ break;
73
+ case 4:
74
+ _.label++;
75
+ return {
76
+ value: op[1],
77
+ done: false
78
+ };
79
+ case 5:
80
+ _.label++;
81
+ y = op[1];
82
+ op = [
83
+ 0
84
+ ];
85
+ continue;
86
+ case 7:
87
+ op = _.ops.pop();
88
+ _.trys.pop();
89
+ continue;
90
+ default:
91
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
92
+ _ = 0;
93
+ continue;
94
+ }
95
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
96
+ _.label = op[1];
97
+ break;
98
+ }
99
+ if (op[0] === 6 && _.label < t[1]) {
100
+ _.label = t[1];
101
+ t = op;
102
+ break;
103
+ }
104
+ if (t && _.label < t[2]) {
105
+ _.label = t[2];
106
+ _.ops.push(op);
107
+ break;
108
+ }
109
+ if (t[2]) _.ops.pop();
110
+ _.trys.pop();
111
+ continue;
112
+ }
113
+ op = body.call(thisArg, _);
114
+ } catch (e) {
115
+ op = [
116
+ 6,
117
+ e
118
+ ];
119
+ y = 0;
120
+ } finally{
121
+ f = t = 0;
122
+ }
123
+ if (op[0] & 5) throw op[1];
124
+ return {
125
+ value: op[0] ? op[1] : void 0,
126
+ done: true
127
+ };
128
+ }
129
+ };
130
+ import { EventLogic } from "@byteluck-fe/model-driven-shared";
51
131
  // type EventKeyMap = {
52
132
  // [eventKey in EventKeys]?: string
53
133
  // }
@@ -57,136 +137,140 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
57
137
  _classCallCheck(this, ControlsEventPlugin);
58
138
  this.config = config;
59
139
  }
60
- _createClass(ControlsEventPlugin, [
61
- {
62
- key: "apply",
63
- value: function apply(engine) {
64
- var _this = this;
65
- this.engine = engine;
66
- // const eventKeyMap: EventKeyMap = {
67
- // click: 'on_click',
68
- // change: 'on_change',
69
- // search: 'on_search',
70
- // focus: 'on_focus',
71
- // blur: 'on_blur',
72
- // input: 'on_input',
73
- // 'click-finish': 'on_click_finish',
74
- // 'list-change': 'on_list_change',
75
- // 'list-delete': 'on_list_delete',
76
- // 'list-search': 'on_list_search',
77
- // 'list-mounted': 'on_list_mounted',
78
- // 'list-actions': 'on_list_actions',
79
- // 'list-rowclick': 'on_list_rowclick',
80
- // 'list-before-import': 'on_list_before_import',
81
- // 'wps-open': 'on_wps_open',
82
- // 'wps-save': 'on_wps_save',
83
- // 'wps-rename': 'on_wps_rename',
84
- // }
85
- // Object.entries(eventKeyMap).forEach(([eventKey, controlEventKey]) => {
86
- // if (eventKey && controlEventKey) {
87
- // this.engineAddEventListener(eventKey as EventKeys, controlEventKey)
88
- // }
89
- // })
90
- EventLogic.events.forEach(function(eventItem) {
91
- if (eventItem.code && eventItem.key) {
92
- _this.engineAddEventListener(eventItem.code, eventItem.key);
93
- }
94
- });
140
+ var _proto = ControlsEventPlugin.prototype;
141
+ _proto.apply = function apply(engine) {
142
+ var _this = this;
143
+ this.engine = engine;
144
+ // const eventKeyMap: EventKeyMap = {
145
+ // click: 'on_click',
146
+ // change: 'on_change',
147
+ // search: 'on_search',
148
+ // focus: 'on_focus',
149
+ // blur: 'on_blur',
150
+ // input: 'on_input',
151
+ // 'click-finish': 'on_click_finish',
152
+ // 'list-change': 'on_list_change',
153
+ // 'list-delete': 'on_list_delete',
154
+ // 'list-search': 'on_list_search',
155
+ // 'list-mounted': 'on_list_mounted',
156
+ // 'list-actions': 'on_list_actions',
157
+ // 'list-rowclick': 'on_list_rowclick',
158
+ // 'list-before-import': 'on_list_before_import',
159
+ // 'wps-open': 'on_wps_open',
160
+ // 'wps-save': 'on_wps_save',
161
+ // 'wps-rename': 'on_wps_rename',
162
+ // }
163
+ // Object.entries(eventKeyMap).forEach(([eventKey, controlEventKey]) => {
164
+ // if (eventKey && controlEventKey) {
165
+ // this.engineAddEventListener(eventKey as EventKeys, controlEventKey)
166
+ // }
167
+ // })
168
+ EventLogic.events.forEach(function(eventItem) {
169
+ if (eventItem.code && eventItem.key) {
170
+ _this.engineAddEventListener(eventItem.code, eventItem.key);
95
171
  }
96
- },
97
- {
98
- key: "engineAddEventListener",
99
- value: function engineAddEventListener(eventKey, controlEventKey) {
100
- var _this = this;
101
- this.engine.on(eventKey, function() {
102
- var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(payload) {
103
- return regeneratorRuntime.wrap(function _callee$(_ctx) {
104
- while(1)switch(_ctx.prev = _ctx.next){
105
- case 0:
106
- if (!(eventKey === 'change' && !_this.engine.isMounted)) {
107
- _ctx.next = 2;
108
- break;
109
- }
110
- return _ctx.abrupt("return");
111
- case 2:
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();
172
+ });
173
+ };
174
+ _proto.engineAddEventListener = function engineAddEventListener(eventKey, controlEventKey) {
175
+ var _this = this;
176
+ this.engine.on(eventKey, function() {
177
+ var _ref = _asyncToGenerator(function(payload) {
178
+ return __generator(this, function(_state) {
179
+ switch(_state.label){
180
+ case 0:
181
+ // 初始化state的时候不触发change事件,必须在engine mounted以后才触发
182
+ if (eventKey === "change" && !_this.engine.isMounted) {
183
+ return [
184
+ 2
185
+ ];
123
186
  }
124
- }, _callee);
125
- }));
126
- return function(payload) {
127
- return _ref.apply(this, arguments);
128
- };
129
- }());
130
- }
131
- },
132
- {
133
- key: "callControlEvent",
134
- value: function callControlEvent(name, payload) {
135
- var _this = this;
136
- return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() {
137
- var events, result;
138
- return regeneratorRuntime.wrap(function _callee$(_ctx1) {
139
- while(1)switch(_ctx1.prev = _ctx1.next){
140
- case 0:
141
- events = _this.config[payload.instance.id];
142
- if (!(!events || !Array.isArray(events[name]))) {
143
- _ctx1.next = 3;
144
- break;
145
- }
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 注释掉的两个参数变为全局参数
187
+ if (!(payload.instance !== undefined)) return [
188
+ 3,
189
+ 2
190
+ ];
191
+ return [
192
+ 4,
193
+ _this.callControlEvent(controlEventKey, payload)
194
+ ];
195
+ case 1:
196
+ return [
197
+ 2,
198
+ _state.sent()
199
+ ];
200
+ case 2:
201
+ return [
202
+ 2
203
+ ];
204
+ }
205
+ });
206
+ });
207
+ return function(payload) {
208
+ return _ref.apply(this, arguments);
209
+ };
210
+ }());
211
+ };
212
+ _proto.callControlEvent = function callControlEvent(name, payload) {
213
+ var _this = this;
214
+ return _asyncToGenerator(function() {
215
+ var events, result;
216
+ return __generator(this, function(_state) {
217
+ switch(_state.label){
218
+ case 0:
219
+ events = _this.config[payload.instance.id];
220
+ if (!events || !Array.isArray(events[name])) {
221
+ return [
222
+ 2,
223
+ []
224
+ ];
225
+ }
226
+ return [
227
+ 4,
228
+ Promise.all(events[name].map(function() {
229
+ var _ref = _asyncToGenerator(function(eventName) {
230
+ var execResult;
231
+ return __generator(this, function(_state) {
232
+ switch(_state.label){
233
+ case 0:
234
+ return [
235
+ 4,
236
+ _this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
157
237
  // this.engine,
158
238
  // 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;
178
- }
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();
239
+ payload)
240
+ ];
241
+ case 1:
242
+ execResult = _state.sent();
243
+ return [
244
+ 2,
245
+ execResult
246
+ ];
247
+ }
248
+ });
249
+ });
250
+ return function(eventName) {
251
+ return _ref.apply(this, arguments);
252
+ };
253
+ }()))
254
+ ];
255
+ case 1:
256
+ result = _state.sent();
257
+ if (result.includes(false)) {
258
+ return [
259
+ 2,
260
+ false
261
+ ];
262
+ } else {
263
+ return [
264
+ 2,
265
+ result
266
+ ];
185
267
  }
186
- }, _callee1);
187
- }))();
188
- }
189
- }
190
- ]);
268
+ return [
269
+ 2
270
+ ];
271
+ }
272
+ });
273
+ })();
274
+ };
191
275
  return ControlsEventPlugin;
192
276
  }();
@@ -11,20 +11,6 @@ function _classCallCheck(instance, Constructor) {
11
11
  throw new TypeError("Cannot call a class as a function");
12
12
  }
13
13
  }
14
- function _defineProperties(target, props) {
15
- for(var i = 0; i < props.length; i++){
16
- var descriptor = props[i];
17
- descriptor.enumerable = descriptor.enumerable || false;
18
- descriptor.configurable = true;
19
- if ("value" in descriptor) descriptor.writable = true;
20
- Object.defineProperty(target, descriptor.key, descriptor);
21
- }
22
- }
23
- function _createClass(Constructor, protoProps, staticProps) {
24
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
- if (staticProps) _defineProperties(Constructor, staticProps);
26
- return Constructor;
27
- }
28
14
  function _iterableToArrayLimit(arr, i) {
29
15
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
30
16
  if (_i == null) return;
@@ -63,7 +49,7 @@ function _unsupportedIterableToArray(o, minLen) {
63
49
  if (n === "Map" || n === "Set") return Array.from(n);
64
50
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
65
51
  }
66
- import { error } from '@byteluck-fe/model-driven-shared';
52
+ import { error } from "@byteluck-fe/model-driven-shared";
67
53
  export var ES6ModulePlugin = /*#__PURE__*/ function() {
68
54
  "use strict";
69
55
  function ES6ModulePlugin(config, env) {
@@ -71,45 +57,41 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
71
57
  this.config = config;
72
58
  this.env = env;
73
59
  }
74
- _createClass(ES6ModulePlugin, [
75
- {
76
- key: "apply",
77
- value: function apply(engine) {
78
- this.engine = engine;
79
- var action = this.config;
80
- if (!action) {
81
- return;
82
- }
83
- var res = parseModule(action, engine, this.env);
84
- if (!res) {
85
- return;
60
+ var _proto = ES6ModulePlugin.prototype;
61
+ _proto.apply = function apply(engine) {
62
+ this.engine = engine;
63
+ var action = this.config;
64
+ if (!action) {
65
+ return;
66
+ }
67
+ var res = parseModule(action, engine, this.env);
68
+ if (!res) {
69
+ return;
70
+ }
71
+ var actionManager = engine.getAction();
72
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
73
+ try {
74
+ for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
75
+ var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
76
+ actionManager.addAction(key, value);
77
+ }
78
+ } catch (err) {
79
+ _didIteratorError = true;
80
+ _iteratorError = err;
81
+ } finally{
82
+ try {
83
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
84
+ _iterator.return();
86
85
  }
87
- var actionManager = engine.getAction();
88
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
89
- try {
90
- for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
91
- var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
92
- actionManager.addAction(key, value);
93
- }
94
- } catch (err) {
95
- _didIteratorError = true;
96
- _iteratorError = err;
97
- } finally{
98
- try {
99
- if (!_iteratorNormalCompletion && _iterator.return != null) {
100
- _iterator.return();
101
- }
102
- } finally{
103
- if (_didIteratorError) {
104
- throw _iteratorError;
105
- }
106
- }
86
+ } finally{
87
+ if (_didIteratorError) {
88
+ throw _iteratorError;
107
89
  }
108
- //qiyu state会proxy,将过深的变量存储会导致崩溃
109
- // engine.setState('variables', res.variables)
110
90
  }
111
91
  }
112
- ]);
92
+ //qiyu state会proxy,将过深的变量存储会导致崩溃
93
+ // engine.setState('variables', res.variables)
94
+ };
113
95
  return ES6ModulePlugin;
114
96
  }();
115
97
  export function parseModule(action, engine, env) {
@@ -125,11 +107,11 @@ export function parseModule(action, engine, env) {
125
107
  }
126
108
  };
127
109
  try {
128
- new Function('module', 'exports', compiled).call(module, module, module.exports);
110
+ new Function("module", "exports", compiled).call(module, module, module.exports);
129
111
  } catch (e) {
130
- error(e.message + '. fail to parse the module');
131
- if (process.env.NODE_ENV !== 'production') {
132
- error('fail to parse the module');
112
+ error(e.message + ". fail to parse the module");
113
+ if (process.env.NODE_ENV !== "production") {
114
+ error("fail to parse the module");
133
115
  }
134
116
  }
135
117
  var funcMap = {};
@@ -137,8 +119,8 @@ export function parseModule(action, engine, env) {
137
119
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
138
120
  try {
139
121
  for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
140
- var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
141
- if (typeof value === 'function') {
122
+ var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
123
+ if (typeof value === "function") {
142
124
  funcMap[key] = value;
143
125
  } else {
144
126
  variables[key] = value;