@byteluck-fe/model-driven-engine 2.7.0-alpha.15 → 2.7.0-alpha.15a
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 +40 -157
- package/dist/esm/common/DataManager.js +20 -129
- package/dist/esm/common/Engine.js +322 -412
- package/dist/esm/common/OkWorker.js +13 -27
- package/dist/esm/common/Runtime.js +78 -54
- package/dist/esm/common/Store.js +50 -51
- package/dist/esm/common/checkerValue.js +39 -39
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +59 -67
- package/dist/esm/plugins/ControlsEventPlugin.js +68 -191
- package/dist/esm/plugins/ES6ModulePlugin.js +8 -24
- package/dist/esm/plugins/LifecycleEventPlugin.js +64 -183
- package/dist/esm/plugins/StylePlugin.js +7 -22
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +7 -5
- package/dist/index.umd.js +10 -10
- package/dist/types/common/Engine.d.ts +10 -9
- package/dist/types/common/Runtime.d.ts +2 -1
- package/dist/types/common/Store.d.ts +5 -5
- package/dist/types/common/proxyState.d.ts +3 -3
- package/dist/types/plugins/ControlsEventPlugin.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +4 -4
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -1
- package/dist/types/plugins/StylePlugin.d.ts +1 -1
- package/package.json +4 -4
|
@@ -25,19 +25,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
25
25
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
26
26
|
return Constructor;
|
|
27
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
28
|
function _iterableToArray(iter) {
|
|
42
29
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
43
30
|
}
|
|
@@ -55,8 +42,8 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
55
42
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56
43
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
57
44
|
}
|
|
58
|
-
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from
|
|
59
|
-
import { format } from
|
|
45
|
+
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
46
|
+
import { format } from 'mathjs';
|
|
60
47
|
var DisplayType;
|
|
61
48
|
(function(DisplayType) {
|
|
62
49
|
DisplayType[/**
|
|
@@ -70,21 +57,19 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
70
57
|
"use strict";
|
|
71
58
|
function CalcPlugin(options) {
|
|
72
59
|
_classCallCheck(this, CalcPlugin);
|
|
73
|
-
_defineProperty(this, "engine", void 0);
|
|
74
|
-
_defineProperty(this, "options", void 0);
|
|
75
60
|
/**
|
|
76
61
|
* 所有的计算公式控件
|
|
77
62
|
* */ // @ts-ignore
|
|
78
|
-
|
|
63
|
+
this.calcControls = [];
|
|
79
64
|
/**
|
|
80
65
|
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
81
66
|
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
82
|
-
* */
|
|
67
|
+
* */ this.dependenciesTriggerMap = new Map();
|
|
83
68
|
/**
|
|
84
69
|
* 隐藏以后需要被计算的控件
|
|
85
|
-
* */
|
|
86
|
-
|
|
87
|
-
|
|
70
|
+
* */ this.hideNotRememberControlIds = [];
|
|
71
|
+
this.dontHasPermissionControlIds = [];
|
|
72
|
+
this.cacheComputedResult = {};
|
|
88
73
|
this.options = options;
|
|
89
74
|
this.getDontHasPermissionControlIds();
|
|
90
75
|
this.getNeedHideRememberControlIds();
|
|
@@ -95,8 +80,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
95
80
|
value: /**
|
|
96
81
|
* @description 获取显隐控制的需要被记住值的控件id
|
|
97
82
|
* */ function getNeedHideRememberControlIds() {
|
|
98
|
-
var
|
|
99
|
-
if (!((
|
|
83
|
+
var ref;
|
|
84
|
+
if (!((ref = this.options) === null || ref === void 0 ? void 0 : ref.displayBoList)) {
|
|
100
85
|
return;
|
|
101
86
|
}
|
|
102
87
|
this.hideNotRememberControlIds = this.options.displayBoList.reduce(function(result, current) {
|
|
@@ -113,8 +98,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
113
98
|
value: /**
|
|
114
99
|
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
115
100
|
* */ function getDontHasPermissionControlIds() {
|
|
116
|
-
var
|
|
117
|
-
if (!((
|
|
101
|
+
var ref;
|
|
102
|
+
if (!((ref = this.options) === null || ref === void 0 ? void 0 : ref.behavior)) {
|
|
118
103
|
return;
|
|
119
104
|
}
|
|
120
105
|
this.dontHasPermissionControlIds = this.options.behavior.reduce(function(result, current) {
|
|
@@ -171,7 +156,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
171
156
|
this.watchControlChange();
|
|
172
157
|
this.watchSubtableChange();
|
|
173
158
|
this.watchSchemaHideChange();
|
|
174
|
-
this.engine.on(
|
|
159
|
+
this.engine.on('engine-mounted', function() {
|
|
175
160
|
_this.allCalcControlComputed();
|
|
176
161
|
});
|
|
177
162
|
}
|
|
@@ -216,15 +201,16 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
216
201
|
* */ function getCalcDependencies() {
|
|
217
202
|
var _this = this;
|
|
218
203
|
this.calcControls.forEach(function(item) {
|
|
204
|
+
var _this1 = _this;
|
|
219
205
|
var scriptEcho = item.props.scriptEcho;
|
|
220
206
|
scriptEcho.forEach(function(scriptItem) {
|
|
221
207
|
if (scriptItem.type === CALC_TOKEN_TYPE.VariableInMainTable || scriptItem.type === CALC_TOKEN_TYPE.VariableInCurrentSubTable || scriptItem.type === CALC_TOKEN_TYPE.VariableInOtherSubTable) {
|
|
222
208
|
// 当前是一个变量,存储依赖于当前变量的计算公式
|
|
223
|
-
|
|
209
|
+
_this1.setDependenciesTriggerMapItem(scriptItem.id, item);
|
|
224
210
|
}
|
|
225
211
|
// 依赖明细子表的计算公式控件,不收集自己表内的,而是主表或者其他明细子表的控件
|
|
226
212
|
if (scriptItem.type === CALC_TOKEN_TYPE.VariableInOtherSubTable && scriptItem.subTableId) {
|
|
227
|
-
|
|
213
|
+
_this1.setDependenciesTriggerMapItem(scriptItem.subTableId, item);
|
|
228
214
|
}
|
|
229
215
|
});
|
|
230
216
|
});
|
|
@@ -249,11 +235,12 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
249
235
|
subtableRows) {
|
|
250
236
|
var _this = this;
|
|
251
237
|
return subtableRows.reduce(function(result, current) {
|
|
238
|
+
var _this2 = _this;
|
|
252
239
|
// @ts-ignore
|
|
253
240
|
current.children.forEach(function(item) {
|
|
254
241
|
var control = item.children[0];
|
|
255
242
|
// @ts-ignore
|
|
256
|
-
if (control &&
|
|
243
|
+
if (control && _this2.engine.assertInstance(control, CONTROL_TYPE.CALC)) {
|
|
257
244
|
result.push(control);
|
|
258
245
|
}
|
|
259
246
|
});
|
|
@@ -268,12 +255,13 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
268
255
|
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
269
256
|
* */ function watchSchemaHideChange() {
|
|
270
257
|
var _this = this;
|
|
271
|
-
this.engine.on(
|
|
272
|
-
if (payload.props ===
|
|
273
|
-
var
|
|
274
|
-
var
|
|
258
|
+
this.engine.on('schema-change', function(payload) {
|
|
259
|
+
if (payload.props === 'isHide') {
|
|
260
|
+
var _this3 = _this;
|
|
261
|
+
var ref;
|
|
262
|
+
var calcControls = (ref = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && ref !== void 0 ? ref : [];
|
|
275
263
|
calcControls.forEach(function(calc) {
|
|
276
|
-
|
|
264
|
+
_this3.computedCalcValue(calc);
|
|
277
265
|
});
|
|
278
266
|
}
|
|
279
267
|
});
|
|
@@ -285,22 +273,23 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
285
273
|
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
286
274
|
* */ function watchSubtableChange() {
|
|
287
275
|
var _this = this;
|
|
288
|
-
this.engine.on(
|
|
289
|
-
var
|
|
276
|
+
this.engine.on('list-change', function(payload) {
|
|
277
|
+
var _this5 = _this;
|
|
278
|
+
var ref;
|
|
290
279
|
_this.resetDependencies();
|
|
291
|
-
var
|
|
292
|
-
var changedRows = (
|
|
280
|
+
var ref1;
|
|
281
|
+
var changedRows = (ref1 = (ref = payload.options) === null || ref === void 0 ? void 0 : ref.changed) !== null && ref1 !== void 0 ? ref1 : [];
|
|
293
282
|
// 对发生改变的行进行重新计算
|
|
294
283
|
var changedCalc = _this.getCalcControlsFromSubtableRows(changedRows);
|
|
295
284
|
// @ts-ignore
|
|
296
285
|
changedCalc.forEach(function(calcControl) {
|
|
297
|
-
|
|
286
|
+
_this5.computedCalcValue(calcControl);
|
|
298
287
|
});
|
|
299
|
-
var
|
|
300
|
-
var calcControls = (
|
|
288
|
+
var ref2;
|
|
289
|
+
var calcControls = (ref2 = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && ref2 !== void 0 ? ref2 : [];
|
|
301
290
|
// @ts-ignore
|
|
302
291
|
calcControls.forEach(function(calcControl) {
|
|
303
|
-
|
|
292
|
+
_this5.computedCalcValue(calcControl);
|
|
304
293
|
});
|
|
305
294
|
});
|
|
306
295
|
}
|
|
@@ -311,29 +300,31 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
311
300
|
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
312
301
|
* */ function watchControlChange() {
|
|
313
302
|
var _this = this;
|
|
314
|
-
this.engine.on(
|
|
303
|
+
this.engine.on('change', function(payload) {
|
|
315
304
|
var instance = payload.instance;
|
|
316
305
|
if (!_this.dependenciesTriggerMap.has(instance.id)) {
|
|
317
306
|
return;
|
|
318
307
|
}
|
|
319
|
-
var
|
|
320
|
-
var calcControls = (
|
|
308
|
+
var ref;
|
|
309
|
+
var calcControls = (ref = _this.dependenciesTriggerMap.get(instance.id)) !== null && ref !== void 0 ? ref : [];
|
|
321
310
|
// 在明细子表中的控件,如果计算公式也在明细子表,那只触发同一行的计算公式的计算
|
|
322
311
|
if (payload.rowIndex !== undefined && payload.rowIndex > -1) {
|
|
312
|
+
var _this7 = _this;
|
|
323
313
|
// @ts-ignore
|
|
324
314
|
calcControls.forEach(function(calcControl) {
|
|
325
|
-
if (
|
|
326
|
-
var calcIndex =
|
|
315
|
+
if (_this7.controlInSubtable(calcControl)) {
|
|
316
|
+
var calcIndex = _this7.engine.getInstanceRowIndex(calcControl);
|
|
327
317
|
if (calcIndex !== payload.rowIndex) {
|
|
328
318
|
return;
|
|
329
319
|
}
|
|
330
320
|
}
|
|
331
|
-
|
|
321
|
+
_this7.computedCalcValue(calcControl);
|
|
332
322
|
});
|
|
333
323
|
} else {
|
|
324
|
+
var _this6 = _this;
|
|
334
325
|
// @ts-ignore
|
|
335
326
|
calcControls.forEach(function(calcControl) {
|
|
336
|
-
|
|
327
|
+
_this6.computedCalcValue(calcControl);
|
|
337
328
|
});
|
|
338
329
|
}
|
|
339
330
|
});
|
|
@@ -344,8 +335,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
344
335
|
value: /**
|
|
345
336
|
* @description 控件在明细子表内
|
|
346
337
|
* */ function controlInSubtable(control) {
|
|
347
|
-
var
|
|
348
|
-
return ((
|
|
338
|
+
var ref;
|
|
339
|
+
return ((ref = control.parent) === null || ref === void 0 ? void 0 : ref.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
|
|
349
340
|
}
|
|
350
341
|
},
|
|
351
342
|
{
|
|
@@ -389,9 +380,10 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
389
380
|
}
|
|
390
381
|
case CALC_TOKEN_TYPE.VariableInOtherSubTable:
|
|
391
382
|
{
|
|
383
|
+
var _this8 = _this;
|
|
392
384
|
var states = _this.engine.getState(current.id);
|
|
393
385
|
var values = Array.isArray(states) ? states.map(function(item) {
|
|
394
|
-
return
|
|
386
|
+
return _this8.getNumberValue(item);
|
|
395
387
|
}) : [];
|
|
396
388
|
var value2 = _this.getAggregateTypeValue(values, current.aggregateType);
|
|
397
389
|
instance = _this.engine.getInstance(current.subTableId);
|
|
@@ -406,17 +398,17 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
406
398
|
result += 0;
|
|
407
399
|
}
|
|
408
400
|
return result;
|
|
409
|
-
},
|
|
410
|
-
var
|
|
401
|
+
}, '');
|
|
402
|
+
var value3;
|
|
411
403
|
// 有缓存的话取缓存,没有缓存再执行eval
|
|
412
404
|
if (this.cacheComputedResult[scriptText] !== undefined) {
|
|
413
|
-
|
|
405
|
+
value3 = this.cacheComputedResult[scriptText];
|
|
414
406
|
} else {
|
|
415
407
|
// 解决js精准度问题
|
|
416
|
-
|
|
408
|
+
value3 = Number(format(new Function("return ".concat(scriptText))(), {
|
|
417
409
|
precision: 16
|
|
418
410
|
}));
|
|
419
|
-
this.cacheComputedResult[scriptText] =
|
|
411
|
+
this.cacheComputedResult[scriptText] = value3;
|
|
420
412
|
}
|
|
421
413
|
// let rowIndex = undefined
|
|
422
414
|
if (this.controlInSubtable(control)) {
|
|
@@ -427,15 +419,15 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
427
419
|
}
|
|
428
420
|
}
|
|
429
421
|
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
430
|
-
var
|
|
422
|
+
var result1 = !value3 || value3 === Infinity || value3 === -Infinity ? 0 : control.props.precision === '' ? value3 : Number(value3.toFixed(control.props.precision));
|
|
431
423
|
// 如果值没变的话,不触发修改
|
|
432
|
-
if (
|
|
424
|
+
if (result1 === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
433
425
|
return;
|
|
434
426
|
}
|
|
435
|
-
var
|
|
427
|
+
var ref;
|
|
436
428
|
this.engine.setState(control.id, {
|
|
437
|
-
result:
|
|
438
|
-
unit: (
|
|
429
|
+
result: result1,
|
|
430
|
+
unit: (ref = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && ref !== void 0 ? ref : ''
|
|
439
431
|
}, rowIndex);
|
|
440
432
|
}
|
|
441
433
|
},
|
|
@@ -444,14 +436,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
444
436
|
value: /**
|
|
445
437
|
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
446
438
|
* */ function getNumberValue(value) {
|
|
447
|
-
if (typeof value ===
|
|
448
|
-
if (
|
|
439
|
+
if (typeof value === 'object' && value) {
|
|
440
|
+
if ('result' in value) {
|
|
449
441
|
return value.result;
|
|
450
|
-
} else if (
|
|
442
|
+
} else if ('amount' in value) {
|
|
451
443
|
return value.amount;
|
|
452
444
|
}
|
|
453
445
|
}
|
|
454
|
-
if (typeof value ===
|
|
446
|
+
if (typeof value === 'number') {
|
|
455
447
|
return value;
|
|
456
448
|
}
|
|
457
449
|
return 0;
|
|
@@ -46,115 +46,8 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
46
46
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
47
|
return Constructor;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
var __generator = this && this.__generator || function(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
|
// }
|
|
@@ -162,8 +55,6 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
162
55
|
"use strict";
|
|
163
56
|
function ControlsEventPlugin(config) {
|
|
164
57
|
_classCallCheck(this, ControlsEventPlugin);
|
|
165
|
-
_defineProperty(this, "config", void 0);
|
|
166
|
-
_defineProperty(this, "engine", void 0);
|
|
167
58
|
this.config = config;
|
|
168
59
|
}
|
|
169
60
|
_createClass(ControlsEventPlugin, [
|
|
@@ -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 = _asyncToGenerator(function(payload) {
|
|
212
|
-
return
|
|
213
|
-
switch(
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
2
|
|
219
|
-
];
|
|
106
|
+
if (!(eventKey === 'change' && !_this.engine.isMounted)) {
|
|
107
|
+
_ctx.next = 2;
|
|
108
|
+
break;
|
|
220
109
|
}
|
|
221
|
-
|
|
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
|
-
|
|
236
|
-
|
|
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 _asyncToGenerator(function() {
|
|
136
|
+
return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() {
|
|
252
137
|
var events, result;
|
|
253
|
-
return
|
|
254
|
-
switch(
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
[]
|
|
261
|
-
];
|
|
142
|
+
if (!(!events || !Array.isArray(events[name]))) {
|
|
143
|
+
_ctx1.next = 3;
|
|
144
|
+
break;
|
|
262
145
|
}
|
|
263
|
-
return [
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
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
|
]);
|