@byteluck-fe/model-driven-engine 2.5.0-alpha.9 → 2.5.0-beta.1
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.
- package/dist/esm/common/ActionManager.js +63 -98
- package/dist/esm/common/DataManager.js +34 -75
- package/dist/esm/common/Engine.js +931 -1100
- package/dist/esm/common/OkWorker.js +74 -119
- package/dist/esm/common/Runtime.js +21 -38
- package/dist/esm/common/Store.js +141 -152
- package/dist/esm/common/checkerValue.js +241 -316
- package/dist/esm/plugins/CalcPlugin.js +309 -389
- package/dist/esm/plugins/ControlsEventPlugin.js +130 -169
- package/dist/esm/plugins/ES6ModulePlugin.js +31 -65
- package/dist/esm/plugins/LifecycleEventPlugin.js +83 -119
- package/dist/esm/plugins/StylePlugin.js +13 -46
- package/dist/index.umd.js +8 -8
- package/dist/types/common/ActionManager.d.ts +14 -14
- package/dist/types/common/DataManager.d.ts +10 -10
- package/dist/types/common/Engine.d.ts +180 -180
- package/dist/types/common/OkWorker.d.ts +13 -13
- package/dist/types/common/Plugin.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +25 -25
- package/dist/types/common/Store.d.ts +50 -49
- package/dist/types/common/checkerValue.d.ts +3 -3
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/common/proxyState.d.ts +30 -30
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins/CalcPlugin.d.ts +121 -121
- package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
- package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -26
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
- package/dist/types/plugins/StylePlugin.d.ts +12 -12
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/runtimeUtils.d.ts +5 -5
- package/package.json +4 -4
|
@@ -32,33 +32,6 @@ 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);
|
|
42
|
-
}
|
|
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
|
-
function _defineProperty(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
35
|
var __generator = this && this.__generator || function(thisArg, body) {
|
|
63
36
|
var f, y, t, g, _ = {
|
|
64
37
|
label: 0,
|
|
@@ -162,154 +135,142 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
162
135
|
"use strict";
|
|
163
136
|
function ControlsEventPlugin(config) {
|
|
164
137
|
_classCallCheck(this, ControlsEventPlugin);
|
|
165
|
-
_defineProperty(this, "config", void 0);
|
|
166
|
-
_defineProperty(this, "engine", void 0);
|
|
167
138
|
this.config = config;
|
|
168
139
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (eventItem.code && eventItem.key) {
|
|
201
|
-
_this.engineAddEventListener(eventItem.code, eventItem.key);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
key: "engineAddEventListener",
|
|
208
|
-
value: function engineAddEventListener(eventKey, controlEventKey) {
|
|
209
|
-
var _this = this;
|
|
210
|
-
this.engine.on(eventKey, function() {
|
|
211
|
-
var _ref = _asyncToGenerator(function(payload) {
|
|
212
|
-
return __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
|
-
}());
|
|
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);
|
|
245
171
|
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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 = _asyncToGenerator(function(eventName) {
|
|
267
|
-
var execResult;
|
|
268
|
-
return __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
|
-
}
|
|
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) {
|
|
305
183
|
return [
|
|
306
184
|
2
|
|
307
185
|
];
|
|
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
|
+
];
|
|
308
225
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
+
}
|
|
268
|
+
return [
|
|
269
|
+
2
|
|
270
|
+
];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
})();
|
|
274
|
+
};
|
|
314
275
|
return ControlsEventPlugin;
|
|
315
276
|
}();
|
|
@@ -11,33 +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
|
-
function _defineProperty(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
14
|
function _iterableToArrayLimit(arr, i) {
|
|
42
15
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
43
16
|
if (_i == null) return;
|
|
@@ -81,51 +54,44 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
|
81
54
|
"use strict";
|
|
82
55
|
function ES6ModulePlugin(config, env) {
|
|
83
56
|
_classCallCheck(this, ES6ModulePlugin);
|
|
84
|
-
_defineProperty(this, "config", void 0);
|
|
85
|
-
_defineProperty(this, "engine", void 0);
|
|
86
|
-
_defineProperty(this, "env", void 0);
|
|
87
57
|
this.config = config;
|
|
88
58
|
this.env = env;
|
|
89
59
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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();
|
|
102
85
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
107
|
-
var _step_value = _slicedToArray(_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
|
-
}
|
|
86
|
+
} finally{
|
|
87
|
+
if (_didIteratorError) {
|
|
88
|
+
throw _iteratorError;
|
|
123
89
|
}
|
|
124
|
-
//qiyu state会proxy,将过深的变量存储会导致崩溃
|
|
125
|
-
// engine.setState('variables', res.variables)
|
|
126
90
|
}
|
|
127
91
|
}
|
|
128
|
-
|
|
92
|
+
//qiyu state会proxy,将过深的变量存储会导致崩溃
|
|
93
|
+
// engine.setState('variables', res.variables)
|
|
94
|
+
};
|
|
129
95
|
return ES6ModulePlugin;
|
|
130
96
|
}();
|
|
131
97
|
export function parseModule(action, engine, env) {
|
|
@@ -40,33 +40,6 @@ function _classCallCheck(instance, Constructor) {
|
|
|
40
40
|
throw new TypeError("Cannot call a class as a function");
|
|
41
41
|
}
|
|
42
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 _createClass(Constructor, protoProps, staticProps) {
|
|
53
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
-
return Constructor;
|
|
56
|
-
}
|
|
57
|
-
function _defineProperty(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
43
|
function _iterableToArrayLimit(arr, i) {
|
|
71
44
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
72
45
|
if (_i == null) return;
|
|
@@ -210,111 +183,102 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
210
183
|
"use strict";
|
|
211
184
|
function LifecycleEventPlugin(config) {
|
|
212
185
|
_classCallCheck(this, LifecycleEventPlugin);
|
|
213
|
-
_defineProperty(this, "config", void 0);
|
|
214
|
-
_defineProperty(this, "engine", void 0);
|
|
215
186
|
this.config = config;
|
|
216
187
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var _ref = _asyncToGenerator(function(payload) {
|
|
228
|
-
var result;
|
|
229
|
-
return __generator(this, function(_state) {
|
|
230
|
-
switch(_state.label){
|
|
231
|
-
case 0:
|
|
232
|
-
return [
|
|
233
|
-
4,
|
|
234
|
-
_this1.callLifecycleEvent(lifecycleKey, payload)
|
|
235
|
-
];
|
|
236
|
-
case 1:
|
|
237
|
-
result = _state.sent();
|
|
238
|
-
if (result.includes(false)) {
|
|
239
|
-
return [
|
|
240
|
-
2,
|
|
241
|
-
false
|
|
242
|
-
];
|
|
243
|
-
} else {
|
|
244
|
-
return [
|
|
245
|
-
2,
|
|
246
|
-
result
|
|
247
|
-
];
|
|
248
|
-
}
|
|
249
|
-
return [
|
|
250
|
-
2
|
|
251
|
-
];
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
return function(payload) {
|
|
256
|
-
return _ref.apply(this, arguments);
|
|
257
|
-
};
|
|
258
|
-
}());
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
key: "callLifecycleEvent",
|
|
264
|
-
value: function callLifecycleEvent(name, payload) {
|
|
265
|
-
var _this = this;
|
|
266
|
-
return _asyncToGenerator(function() {
|
|
267
|
-
var events, result;
|
|
188
|
+
var _proto = LifecycleEventPlugin.prototype;
|
|
189
|
+
_proto.apply = function apply(engine) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
this.engine = engine;
|
|
192
|
+
Object.entries(LifecycleEventKeyMap).forEach(function(param) {
|
|
193
|
+
var _param = _slicedToArray(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
|
|
194
|
+
var _this1 = _this;
|
|
195
|
+
engine.on(engineKey, function() {
|
|
196
|
+
var _ref = _asyncToGenerator(function(payload) {
|
|
197
|
+
var result;
|
|
268
198
|
return __generator(this, function(_state) {
|
|
269
199
|
switch(_state.label){
|
|
270
200
|
case 0:
|
|
271
|
-
events = _this.config;
|
|
272
|
-
if (!events || !Array.isArray(events[name])) {
|
|
273
|
-
return [
|
|
274
|
-
2,
|
|
275
|
-
[]
|
|
276
|
-
];
|
|
277
|
-
}
|
|
278
201
|
return [
|
|
279
202
|
4,
|
|
280
|
-
|
|
281
|
-
var _ref = _asyncToGenerator(function(eventName) {
|
|
282
|
-
var execResult;
|
|
283
|
-
return __generator(this, function(_state) {
|
|
284
|
-
switch(_state.label){
|
|
285
|
-
case 0:
|
|
286
|
-
return [
|
|
287
|
-
4,
|
|
288
|
-
_this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
289
|
-
// this.engine,
|
|
290
|
-
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
291
|
-
payload)
|
|
292
|
-
];
|
|
293
|
-
case 1:
|
|
294
|
-
execResult = _state.sent();
|
|
295
|
-
return [
|
|
296
|
-
2,
|
|
297
|
-
execResult
|
|
298
|
-
];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
return function(eventName) {
|
|
303
|
-
return _ref.apply(this, arguments);
|
|
304
|
-
};
|
|
305
|
-
}()))
|
|
203
|
+
_this1.callLifecycleEvent(lifecycleKey, payload)
|
|
306
204
|
];
|
|
307
205
|
case 1:
|
|
308
206
|
result = _state.sent();
|
|
207
|
+
if (result.includes(false)) {
|
|
208
|
+
return [
|
|
209
|
+
2,
|
|
210
|
+
false
|
|
211
|
+
];
|
|
212
|
+
} else {
|
|
213
|
+
return [
|
|
214
|
+
2,
|
|
215
|
+
result
|
|
216
|
+
];
|
|
217
|
+
}
|
|
309
218
|
return [
|
|
310
|
-
2
|
|
311
|
-
result
|
|
219
|
+
2
|
|
312
220
|
];
|
|
313
221
|
}
|
|
314
222
|
});
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
223
|
+
});
|
|
224
|
+
return function(payload) {
|
|
225
|
+
return _ref.apply(this, arguments);
|
|
226
|
+
};
|
|
227
|
+
}());
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
_proto.callLifecycleEvent = function callLifecycleEvent(name, payload) {
|
|
231
|
+
var _this = this;
|
|
232
|
+
return _asyncToGenerator(function() {
|
|
233
|
+
var events, result;
|
|
234
|
+
return __generator(this, function(_state) {
|
|
235
|
+
switch(_state.label){
|
|
236
|
+
case 0:
|
|
237
|
+
events = _this.config;
|
|
238
|
+
if (!events || !Array.isArray(events[name])) {
|
|
239
|
+
return [
|
|
240
|
+
2,
|
|
241
|
+
[]
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
return [
|
|
245
|
+
4,
|
|
246
|
+
Promise.all(events[name].map(function() {
|
|
247
|
+
var _ref = _asyncToGenerator(function(eventName) {
|
|
248
|
+
var execResult;
|
|
249
|
+
return __generator(this, function(_state) {
|
|
250
|
+
switch(_state.label){
|
|
251
|
+
case 0:
|
|
252
|
+
return [
|
|
253
|
+
4,
|
|
254
|
+
_this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
255
|
+
// this.engine,
|
|
256
|
+
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
257
|
+
payload)
|
|
258
|
+
];
|
|
259
|
+
case 1:
|
|
260
|
+
execResult = _state.sent();
|
|
261
|
+
return [
|
|
262
|
+
2,
|
|
263
|
+
execResult
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
return function(eventName) {
|
|
269
|
+
return _ref.apply(this, arguments);
|
|
270
|
+
};
|
|
271
|
+
}()))
|
|
272
|
+
];
|
|
273
|
+
case 1:
|
|
274
|
+
result = _state.sent();
|
|
275
|
+
return [
|
|
276
|
+
2,
|
|
277
|
+
result
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
})();
|
|
282
|
+
};
|
|
319
283
|
return LifecycleEventPlugin;
|
|
320
284
|
}();
|