@byteluck-fe/model-driven-engine 2.0.1 → 2.1.0-beta.0
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 +136 -33
- package/dist/esm/common/DataManager.js +113 -18
- package/dist/esm/common/Engine.js +227 -132
- package/dist/esm/common/OkWorker.js +5 -5
- package/dist/esm/common/Store.js +8 -8
- package/dist/esm/common/SubTableSpeedUp.js +17 -0
- package/dist/esm/common/checkerValue.js +2 -2
- package/dist/esm/common/proxyState.js +9 -9
- package/dist/esm/plugins/CalcPlugin.js +17 -17
- package/dist/esm/plugins/ControlsEventPlugin.js +175 -67
- package/dist/esm/plugins/ES6ModulePlugin.js +8 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +165 -61
- package/dist/esm/plugins/StylePlugin.js +3 -3
- package/dist/esm/utils/runtimeUtils.js +2 -4
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +8 -6
- package/dist/types/common/Runtime.d.ts +1 -1
- package/dist/types/common/Store.d.ts +5 -5
- package/dist/types/common/SubTableSpeedUp.d.ts +1 -0
- 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 +7 -6
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -1
- package/dist/types/plugins/StylePlugin.d.ts +1 -1
- package/package.json +6 -4
package/dist/esm/common/Store.js
CHANGED
|
@@ -30,7 +30,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
30
30
|
"use strict";
|
|
31
31
|
function Store(props) {
|
|
32
32
|
_classCallCheck(this, Store);
|
|
33
|
-
var
|
|
33
|
+
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping;
|
|
34
34
|
this.emptyState = emptyState;
|
|
35
35
|
this.state = state;
|
|
36
36
|
this.dataBindMapping = databindMapping;
|
|
@@ -96,8 +96,8 @@ var Store = /*#__PURE__*/ function() {
|
|
|
96
96
|
if (children !== undefined) {
|
|
97
97
|
Object.keys(children).map(function(childControlId) {
|
|
98
98
|
if (childControlId === controlId) {
|
|
99
|
-
var
|
|
100
|
-
state = (
|
|
99
|
+
var _this_state_dataViewId_subtableId_rowIndex;
|
|
100
|
+
state = (_this_state_dataViewId_subtableId_rowIndex = _this.state[dataViewId][subtableId][rowIndex]) === null || _this_state_dataViewId_subtableId_rowIndex === void 0 ? void 0 : _this_state_dataViewId_subtableId_rowIndex[controlId];
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -210,8 +210,8 @@ item) {
|
|
|
210
210
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
211
211
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
212
212
|
});
|
|
213
|
-
var
|
|
214
|
-
dataViewState[item.id] = new Array((
|
|
213
|
+
var _item_props_defaultRows;
|
|
214
|
+
dataViewState[item.id] = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
215
215
|
return JSONCopy(emptyTemplate);
|
|
216
216
|
});
|
|
217
217
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
@@ -320,9 +320,9 @@ item) {
|
|
|
320
320
|
options: []
|
|
321
321
|
};
|
|
322
322
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
323
|
-
var
|
|
324
|
-
var
|
|
325
|
-
Object.assign((
|
|
323
|
+
var _data_item_id;
|
|
324
|
+
var _data_item_id_children;
|
|
325
|
+
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {}, _defineProperty({}, formControl.id, {
|
|
326
326
|
dataBind: formControl.props.dataBind
|
|
327
327
|
}));
|
|
328
328
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// import { RuntimeSubTableColumnControl } from '@byteluck-fe/model-driven-core'
|
|
2
|
+
// import { RuntimeControl } from '@byteluck-fe/model-driven-core'
|
|
3
|
+
import cloneDeep from "lodash.clonedeep";
|
|
4
|
+
export function genSubTableRowInstanceFromHeaders(// headers: RuntimeSubTableColumnControl[]
|
|
5
|
+
headers) {
|
|
6
|
+
var subtableRow = headers.reduce(function(pre, cur) {
|
|
7
|
+
var children = cur.children;
|
|
8
|
+
children.forEach(function(control) {
|
|
9
|
+
pre[control.id] = copyPropsFromControlInstance(control);
|
|
10
|
+
});
|
|
11
|
+
return pre;
|
|
12
|
+
}, {});
|
|
13
|
+
return subtableRow;
|
|
14
|
+
}
|
|
15
|
+
function copyPropsFromControlInstance(control) {
|
|
16
|
+
return cloneDeep(control.props);
|
|
17
|
+
}
|
|
@@ -520,8 +520,8 @@ function getFieldTypeFromKey(key) {
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
export function checkerValue(fieldType, key, value, oldValue) {
|
|
523
|
-
var
|
|
524
|
-
var getCheckerFieldType = (
|
|
523
|
+
var _getFieldTypeFromKey;
|
|
524
|
+
var getCheckerFieldType = (_getFieldTypeFromKey = getFieldTypeFromKey(key)) !== null && _getFieldTypeFromKey !== void 0 ? _getFieldTypeFromKey : fieldType;
|
|
525
525
|
var checker = ValueCheckerFactory.getValueChecker(getCheckerFieldType);
|
|
526
526
|
if (!checker || checker.validate(value)) {
|
|
527
527
|
return value;
|
|
@@ -38,7 +38,7 @@ var proxyArrayApi = [
|
|
|
38
38
|
"shift",
|
|
39
39
|
"pop",
|
|
40
40
|
"unshift",
|
|
41
|
-
"reverse"
|
|
41
|
+
"reverse"
|
|
42
42
|
];
|
|
43
43
|
export var engineProxyFlag = Symbol("__engineProxy__");
|
|
44
44
|
export var engineTargetKey = Symbol("__engineTarget__");
|
|
@@ -85,7 +85,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
85
85
|
return function() {
|
|
86
86
|
return callback.call(null, target, thisKey, "splice", [
|
|
87
87
|
newLength,
|
|
88
|
-
oldLength - newLength
|
|
88
|
+
oldLength - newLength
|
|
89
89
|
]);
|
|
90
90
|
};
|
|
91
91
|
// 直接操作下标
|
|
@@ -148,8 +148,8 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
148
148
|
// @ts-ignore
|
|
149
149
|
var oldValue = target[propertyKey];
|
|
150
150
|
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
151
|
-
var
|
|
152
|
-
newValue = (
|
|
151
|
+
var _reProxyState;
|
|
152
|
+
newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
|
|
153
153
|
// 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
|
|
154
154
|
var setResult;
|
|
155
155
|
// TODO 数组拦截操作需要重构,优化现有逻辑
|
|
@@ -243,10 +243,10 @@ function flatInstanceForChildren(controls) {
|
|
|
243
243
|
// 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
|
|
244
244
|
return findEndItem ? findEndItem : _instanceof(prevItem, RuntimeFormControl) ? prevItem : undefined;
|
|
245
245
|
} else {
|
|
246
|
-
var
|
|
247
|
-
var
|
|
246
|
+
var _prevItem_children;
|
|
247
|
+
var _prevItem_children_index;
|
|
248
248
|
// 如果有children,则取children中对应的下标,没有的话一直返回prevItem
|
|
249
|
-
return (
|
|
249
|
+
return (_prevItem_children_index = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
|
|
250
250
|
}
|
|
251
251
|
}, initInstance);
|
|
252
252
|
}
|
|
@@ -286,9 +286,9 @@ function getArrayNewArgs(type, args, value) {
|
|
|
286
286
|
var result;
|
|
287
287
|
var addValue = getArrayNewValue(key, args);
|
|
288
288
|
if (addValue.length) {
|
|
289
|
-
var
|
|
289
|
+
var _this, _this_engineArrayBeforeSetCallbackFlag;
|
|
290
290
|
// @ts-ignore
|
|
291
|
-
var newValue = (
|
|
291
|
+
var newValue = (_this_engineArrayBeforeSetCallbackFlag = (_this = this)[engineArrayBeforeSetCallbackFlag]) === null || _this_engineArrayBeforeSetCallbackFlag === void 0 ? void 0 : _this_engineArrayBeforeSetCallbackFlag.call(_this, // @ts-ignore
|
|
292
292
|
this[engineTargetKey], // @ts-ignore
|
|
293
293
|
this[engineProxyThisKey], addValue);
|
|
294
294
|
var newArgs = getArrayNewArgs(key, args, newValue);
|
|
@@ -64,8 +64,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
64
64
|
/**
|
|
65
65
|
* @description 获取显隐控制的需要被记住值的控件id
|
|
66
66
|
* */ _proto.getNeedHideRememberControlIds = function getNeedHideRememberControlIds() {
|
|
67
|
-
var
|
|
68
|
-
if (!((
|
|
67
|
+
var _this_options;
|
|
68
|
+
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.displayBoList)) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
this.hideNotRememberControlIds = this.options.displayBoList.reduce(function(result, current) {
|
|
@@ -79,8 +79,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
79
79
|
/**
|
|
80
80
|
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
81
81
|
* */ _proto.getDontHasPermissionControlIds = function getDontHasPermissionControlIds() {
|
|
82
|
-
var
|
|
83
|
-
if (!((
|
|
82
|
+
var _this_options;
|
|
83
|
+
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.behavior)) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
this.dontHasPermissionControlIds = this.options.behavior.reduce(function(result, current) {
|
|
@@ -206,8 +206,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
206
206
|
var _this = this;
|
|
207
207
|
this.engine.on("schema-change", function(payload) {
|
|
208
208
|
if (payload.props === "isHide") {
|
|
209
|
-
var
|
|
210
|
-
var calcControls = (
|
|
209
|
+
var _this_dependenciesTriggerMap_get;
|
|
210
|
+
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
211
211
|
calcControls.forEach(function(calc) {
|
|
212
212
|
_this.computedCalcValue(calc);
|
|
213
213
|
});
|
|
@@ -219,18 +219,18 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
219
219
|
* */ _proto.watchSubtableChange = function watchSubtableChange() {
|
|
220
220
|
var _this = this;
|
|
221
221
|
this.engine.on("list-change", function(payload) {
|
|
222
|
-
var
|
|
222
|
+
var _payload_options;
|
|
223
223
|
_this.resetDependencies();
|
|
224
|
-
var
|
|
225
|
-
var changedRows = (
|
|
224
|
+
var _payload_options_changed;
|
|
225
|
+
var changedRows = (_payload_options_changed = (_payload_options = payload.options) === null || _payload_options === void 0 ? void 0 : _payload_options.changed) !== null && _payload_options_changed !== void 0 ? _payload_options_changed : [];
|
|
226
226
|
// 对发生改变的行进行重新计算
|
|
227
227
|
var changedCalc = _this.getCalcControlsFromSubtableRows(changedRows);
|
|
228
228
|
// @ts-ignore
|
|
229
229
|
changedCalc.forEach(function(calcControl) {
|
|
230
230
|
_this.computedCalcValue(calcControl);
|
|
231
231
|
});
|
|
232
|
-
var
|
|
233
|
-
var calcControls = (
|
|
232
|
+
var _this_dependenciesTriggerMap_get;
|
|
233
|
+
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
234
234
|
// @ts-ignore
|
|
235
235
|
calcControls.forEach(function(calcControl) {
|
|
236
236
|
_this.computedCalcValue(calcControl);
|
|
@@ -246,8 +246,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
246
246
|
if (!_this.dependenciesTriggerMap.has(instance.id)) {
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
|
-
var
|
|
250
|
-
var calcControls = (
|
|
249
|
+
var _this_dependenciesTriggerMap_get;
|
|
250
|
+
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
251
251
|
// 在明细子表中的控件,如果计算公式也在明细子表,那只触发同一行的计算公式的计算
|
|
252
252
|
if (payload.rowIndex !== undefined && payload.rowIndex > -1) {
|
|
253
253
|
// @ts-ignore
|
|
@@ -271,8 +271,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
271
271
|
/**
|
|
272
272
|
* @description 控件在明细子表内
|
|
273
273
|
* */ _proto.controlInSubtable = function controlInSubtable(control) {
|
|
274
|
-
var
|
|
275
|
-
return ((
|
|
274
|
+
var _control_parent;
|
|
275
|
+
return ((_control_parent = control.parent) === null || _control_parent === void 0 ? void 0 : _control_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
|
|
276
276
|
};
|
|
277
277
|
/**
|
|
278
278
|
* @description 执行计算公式的计算
|
|
@@ -352,10 +352,10 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
352
352
|
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
var
|
|
355
|
+
var _oldValue_unit;
|
|
356
356
|
this.engine.setState(control.id, {
|
|
357
357
|
result: result,
|
|
358
|
-
unit: (
|
|
358
|
+
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
|
|
359
359
|
}, rowIndex);
|
|
360
360
|
};
|
|
361
361
|
/**
|
|
@@ -32,7 +32,101 @@ function _classCallCheck(instance, Constructor) {
|
|
|
32
32
|
throw new TypeError("Cannot call a class as a function");
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
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
|
+
};
|
|
59
|
+
}
|
|
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
|
+
};
|
|
36
130
|
import { EventLogic } from "@byteluck-fe/model-driven-shared";
|
|
37
131
|
// type EventKeyMap = {
|
|
38
132
|
// [eventKey in EventKeys]?: string
|
|
@@ -80,30 +174,36 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
80
174
|
_proto.engineAddEventListener = function engineAddEventListener(eventKey, controlEventKey) {
|
|
81
175
|
var _this = this;
|
|
82
176
|
this.engine.on(eventKey, function() {
|
|
83
|
-
var _ref = _asyncToGenerator(
|
|
84
|
-
return
|
|
85
|
-
|
|
177
|
+
var _ref = _asyncToGenerator(function(payload) {
|
|
178
|
+
return __generator(this, function(_state) {
|
|
179
|
+
switch(_state.label){
|
|
86
180
|
case 0:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
181
|
+
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
182
|
+
if (eventKey === "change" && !_this.engine.isMounted) {
|
|
183
|
+
return [
|
|
184
|
+
2
|
|
185
|
+
];
|
|
90
186
|
}
|
|
91
|
-
|
|
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
|
+
];
|
|
92
200
|
case 2:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
_ctx.next = 5;
|
|
98
|
-
return _this.callControlEvent(controlEventKey, payload);
|
|
99
|
-
case 5:
|
|
100
|
-
return _ctx.abrupt("return", _ctx.sent);
|
|
101
|
-
case 6:
|
|
102
|
-
case "end":
|
|
103
|
-
return _ctx.stop();
|
|
201
|
+
return [
|
|
202
|
+
2
|
|
203
|
+
];
|
|
104
204
|
}
|
|
105
|
-
}
|
|
106
|
-
})
|
|
205
|
+
});
|
|
206
|
+
});
|
|
107
207
|
return function(payload) {
|
|
108
208
|
return _ref.apply(this, arguments);
|
|
109
209
|
};
|
|
@@ -111,58 +211,66 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
111
211
|
};
|
|
112
212
|
_proto.callControlEvent = function callControlEvent(name, payload) {
|
|
113
213
|
var _this = this;
|
|
114
|
-
return _asyncToGenerator(
|
|
214
|
+
return _asyncToGenerator(function() {
|
|
115
215
|
var events, result;
|
|
116
|
-
return
|
|
117
|
-
|
|
216
|
+
return __generator(this, function(_state) {
|
|
217
|
+
switch(_state.label){
|
|
118
218
|
case 0:
|
|
119
219
|
events = _this.config[payload.instance.id];
|
|
120
|
-
if (!
|
|
121
|
-
|
|
122
|
-
|
|
220
|
+
if (!events || !Array.isArray(events[name])) {
|
|
221
|
+
return [
|
|
222
|
+
2,
|
|
223
|
+
[]
|
|
224
|
+
];
|
|
123
225
|
}
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
+
];
|
|
156
267
|
}
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case 11:
|
|
161
|
-
case "end":
|
|
162
|
-
return _ctx.stop();
|
|
268
|
+
return [
|
|
269
|
+
2
|
|
270
|
+
];
|
|
163
271
|
}
|
|
164
|
-
}
|
|
165
|
-
})
|
|
272
|
+
});
|
|
273
|
+
})();
|
|
166
274
|
};
|
|
167
275
|
return ControlsEventPlugin;
|
|
168
276
|
}();
|
|
@@ -52,9 +52,10 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
52
52
|
import { error } from "@byteluck-fe/model-driven-shared";
|
|
53
53
|
export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
54
54
|
"use strict";
|
|
55
|
-
function ES6ModulePlugin(config) {
|
|
55
|
+
function ES6ModulePlugin(config, env) {
|
|
56
56
|
_classCallCheck(this, ES6ModulePlugin);
|
|
57
57
|
this.config = config;
|
|
58
|
+
this.env = env;
|
|
58
59
|
}
|
|
59
60
|
var _proto = ES6ModulePlugin.prototype;
|
|
60
61
|
_proto.apply = function apply(engine) {
|
|
@@ -63,7 +64,7 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
|
63
64
|
if (!action) {
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
|
-
var res = parseModule(action, engine);
|
|
67
|
+
var res = parseModule(action, engine, this.env);
|
|
67
68
|
if (!res) {
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
@@ -71,7 +72,7 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
|
71
72
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
72
73
|
try {
|
|
73
74
|
for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
74
|
-
var
|
|
75
|
+
var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
75
76
|
actionManager.addAction(key, value);
|
|
76
77
|
}
|
|
77
78
|
} catch (err) {
|
|
@@ -93,7 +94,7 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
|
93
94
|
};
|
|
94
95
|
return ES6ModulePlugin;
|
|
95
96
|
}();
|
|
96
|
-
export function parseModule(action, engine) {
|
|
97
|
+
export function parseModule(action, engine, env) {
|
|
97
98
|
if (!action.module || !action.module.compiled) {
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
@@ -101,7 +102,8 @@ export function parseModule(action, engine) {
|
|
|
101
102
|
var module = {
|
|
102
103
|
exports: {
|
|
103
104
|
ctx: engine,
|
|
104
|
-
utils: engine.getAction().actionUtils
|
|
105
|
+
utils: engine.getAction().actionUtils,
|
|
106
|
+
env: env
|
|
105
107
|
}
|
|
106
108
|
};
|
|
107
109
|
try {
|
|
@@ -117,7 +119,7 @@ export function parseModule(action, engine) {
|
|
|
117
119
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
118
120
|
try {
|
|
119
121
|
for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
120
|
-
var
|
|
122
|
+
var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
121
123
|
if (typeof value === "function") {
|
|
122
124
|
funcMap[key] = value;
|
|
123
125
|
} else {
|