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

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.
@@ -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 _asyncToGenerator(fn) {
15
+ function _async_to_generator(fn) {
16
16
  return function() {
17
17
  var self = this, args = arguments;
18
18
  return new Promise(function(resolve, reject) {
@@ -27,12 +27,39 @@ function _asyncToGenerator(fn) {
27
27
  });
28
28
  };
29
29
  }
30
- function _classCallCheck(instance, Constructor) {
30
+ function _class_call_check(instance, Constructor) {
31
31
  if (!(instance instanceof Constructor)) {
32
32
  throw new TypeError("Cannot call a class as a function");
33
33
  }
34
34
  }
35
- var __generator = this && this.__generator || function(thisArg, body) {
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) {
36
63
  var f, y, t, g, _ = {
37
64
  label: 0,
38
65
  sent: function() {
@@ -126,7 +153,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
126
153
  done: true
127
154
  };
128
155
  }
129
- };
156
+ }
130
157
  import { EventLogic } from "@byteluck-fe/model-driven-shared";
131
158
  // type EventKeyMap = {
132
159
  // [eventKey in EventKeys]?: string
@@ -134,143 +161,155 @@ import { EventLogic } from "@byteluck-fe/model-driven-shared";
134
161
  export var ControlsEventPlugin = /*#__PURE__*/ function() {
135
162
  "use strict";
136
163
  function ControlsEventPlugin(config) {
137
- _classCallCheck(this, ControlsEventPlugin);
164
+ _class_call_check(this, ControlsEventPlugin);
165
+ _define_property(this, "config", void 0);
166
+ _define_property(this, "engine", void 0);
138
167
  this.config = config;
139
168
  }
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);
169
+ _create_class(ControlsEventPlugin, [
170
+ {
171
+ key: "apply",
172
+ value: function apply(engine) {
173
+ var _this = this;
174
+ this.engine = engine;
175
+ // const eventKeyMap: EventKeyMap = {
176
+ // click: 'on_click',
177
+ // change: 'on_change',
178
+ // search: 'on_search',
179
+ // focus: 'on_focus',
180
+ // blur: 'on_blur',
181
+ // input: 'on_input',
182
+ // 'click-finish': 'on_click_finish',
183
+ // 'list-change': 'on_list_change',
184
+ // 'list-delete': 'on_list_delete',
185
+ // 'list-search': 'on_list_search',
186
+ // 'list-mounted': 'on_list_mounted',
187
+ // 'list-actions': 'on_list_actions',
188
+ // 'list-rowclick': 'on_list_rowclick',
189
+ // 'list-before-import': 'on_list_before_import',
190
+ // 'wps-open': 'on_wps_open',
191
+ // 'wps-save': 'on_wps_save',
192
+ // 'wps-rename': 'on_wps_rename',
193
+ // }
194
+ // Object.entries(eventKeyMap).forEach(([eventKey, controlEventKey]) => {
195
+ // if (eventKey && controlEventKey) {
196
+ // this.engineAddEventListener(eventKey as EventKeys, controlEventKey)
197
+ // }
198
+ // })
199
+ EventLogic.events.forEach(function(eventItem) {
200
+ if (eventItem.code && eventItem.key) {
201
+ _this.engineAddEventListener(eventItem.code, eventItem.key);
202
+ }
203
+ });
171
204
  }
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) {
205
+ },
206
+ {
207
+ key: "engineAddEventListener",
208
+ value: function engineAddEventListener(eventKey, controlEventKey) {
209
+ var _this = this;
210
+ this.engine.on(eventKey, function() {
211
+ var _ref = _async_to_generator(function(payload) {
212
+ return _ts_generator(this, function(_state) {
213
+ switch(_state.label){
214
+ case 0:
215
+ // 初始化state的时候不触发change事件,必须在engine mounted以后才触发
216
+ if (eventKey === "change" && !_this.engine.isMounted) {
217
+ return [
218
+ 2
219
+ ];
220
+ }
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
+ ];
234
+ case 2:
235
+ return [
236
+ 2
237
+ ];
238
+ }
239
+ });
240
+ });
241
+ return function(payload) {
242
+ return _ref.apply(this, arguments);
243
+ };
244
+ }());
245
+ }
246
+ },
247
+ {
248
+ key: "callControlEvent",
249
+ value: function callControlEvent(name, payload) {
250
+ var _this = this;
251
+ return _async_to_generator(function() {
252
+ var events, result;
253
+ return _ts_generator(this, function(_state) {
254
+ switch(_state.label){
255
+ case 0:
256
+ events = _this.config[payload.instance.id];
257
+ if (!events || !Array.isArray(events[name])) {
258
+ return [
259
+ 2,
260
+ []
261
+ ];
262
+ }
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
+ ];
304
+ }
183
305
  return [
184
306
  2
185
307
  ];
186
- }
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 注释掉的两个参数变为全局参数
237
- // this.engine,
238
- // this.engine.getAction().actionUtils, //以前是params,空的
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
- ];
267
308
  }
268
- return [
269
- 2
270
- ];
271
- }
272
- });
273
- })();
274
- };
309
+ });
310
+ })();
311
+ }
312
+ }
313
+ ]);
275
314
  return ControlsEventPlugin;
276
315
  }();
@@ -1,17 +1,44 @@
1
- function _arrayLikeToArray(arr, len) {
1
+ function _array_like_to_array(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 _arrayWithHoles(arr) {
6
+ function _array_with_holes(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
- function _classCallCheck(instance, Constructor) {
9
+ function _class_call_check(instance, Constructor) {
10
10
  if (!(instance instanceof Constructor)) {
11
11
  throw new TypeError("Cannot call a class as a function");
12
12
  }
13
13
  }
14
- function _iterableToArrayLimit(arr, i) {
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 _create_class(Constructor, protoProps, staticProps) {
24
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
+ if (staticProps) _defineProperties(Constructor, staticProps);
26
+ return Constructor;
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) {
15
42
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
16
43
  if (_i == null) return;
17
44
  var _arr = [];
@@ -35,63 +62,70 @@ function _iterableToArrayLimit(arr, i) {
35
62
  }
36
63
  return _arr;
37
64
  }
38
- function _nonIterableRest() {
65
+ function _non_iterable_rest() {
39
66
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40
67
  }
41
- function _slicedToArray(arr, i) {
42
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
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();
43
70
  }
44
- function _unsupportedIterableToArray(o, minLen) {
71
+ function _unsupported_iterable_to_array(o, minLen) {
45
72
  if (!o) return;
46
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
73
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
47
74
  var n = Object.prototype.toString.call(o).slice(8, -1);
48
75
  if (n === "Object" && o.constructor) n = o.constructor.name;
49
76
  if (n === "Map" || n === "Set") return Array.from(n);
50
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
77
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
51
78
  }
52
79
  import { error } from "@byteluck-fe/model-driven-shared";
53
80
  export var ES6ModulePlugin = /*#__PURE__*/ function() {
54
81
  "use strict";
55
82
  function ES6ModulePlugin(config, env) {
56
- _classCallCheck(this, ES6ModulePlugin);
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);
57
87
  this.config = config;
58
88
  this.env = env;
59
89
  }
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();
90
+ _create_class(ES6ModulePlugin, [
91
+ {
92
+ key: "apply",
93
+ value: function apply(engine) {
94
+ this.engine = engine;
95
+ var action = this.config;
96
+ if (!action) {
97
+ return;
98
+ }
99
+ var res = parseModule(action, engine, this.env);
100
+ if (!res) {
101
+ return;
85
102
  }
86
- } finally{
87
- if (_didIteratorError) {
88
- throw _iteratorError;
103
+ var actionManager = engine.getAction();
104
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
105
+ try {
106
+ for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
107
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
108
+ actionManager.addAction(key, value);
109
+ }
110
+ } catch (err) {
111
+ _didIteratorError = true;
112
+ _iteratorError = err;
113
+ } finally{
114
+ try {
115
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
116
+ _iterator.return();
117
+ }
118
+ } finally{
119
+ if (_didIteratorError) {
120
+ throw _iteratorError;
121
+ }
122
+ }
89
123
  }
124
+ //qiyu state会proxy,将过深的变量存储会导致崩溃
125
+ // engine.setState('variables', res.variables)
90
126
  }
91
127
  }
92
- //qiyu state会proxy,将过深的变量存储会导致崩溃
93
- // engine.setState('variables', res.variables)
94
- };
128
+ ]);
95
129
  return ES6ModulePlugin;
96
130
  }();
97
131
  export function parseModule(action, engine, env) {
@@ -119,7 +153,7 @@ export function parseModule(action, engine, env) {
119
153
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
120
154
  try {
121
155
  for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
122
- var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
156
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
123
157
  if (typeof value === "function") {
124
158
  funcMap[key] = value;
125
159
  } else {