@byteluck-fe/model-driven-engine 2.23.2 → 2.23.3
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/README.md +30 -30
- package/dist/esm/common/ActionManager.js +10 -15
- package/dist/esm/common/DataManager.js +8 -12
- package/dist/esm/common/Engine.js +74 -68
- package/dist/esm/common/Runtime.js +2 -2
- package/dist/esm/common/Store.js +5 -6
- package/dist/esm/common/proxyState.js +18 -18
- package/dist/esm/plugins/CalcPlugin.js +46 -46
- package/dist/esm/plugins/ControlsEventPlugin.js +19 -29
- package/dist/esm/plugins/LifecycleEventPlugin.js +18 -29
- package/dist/esm/plugins/StylePlugin.js +14 -13
- package/dist/index.umd.js +40 -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 +201 -201
- 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 +31 -31
- package/dist/types/common/Store.d.ts +54 -54
- 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 +17 -17
- package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -15
- package/dist/types/plugins/StylePlugin.d.ts +13 -13
- 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 +9 -6
|
@@ -61,31 +61,31 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
61
61
|
}
|
|
62
62
|
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
63
63
|
import { format } from 'mathjs';
|
|
64
|
-
var DisplayType
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* 完全等于
|
|
64
|
+
var DisplayType = /*#__PURE__*/ function(DisplayType) {
|
|
65
|
+
/**
|
|
66
|
+
* 完全等于
|
|
68
67
|
*/ DisplayType["EQ"] = "EQ";
|
|
69
|
-
/**
|
|
70
|
-
* 包含
|
|
68
|
+
/**
|
|
69
|
+
* 包含
|
|
71
70
|
* */ DisplayType["IN"] = "IN";
|
|
72
|
-
|
|
71
|
+
return DisplayType;
|
|
72
|
+
}(DisplayType || {});
|
|
73
73
|
export var CalcPlugin = /*#__PURE__*/ function() {
|
|
74
74
|
"use strict";
|
|
75
75
|
function CalcPlugin(options) {
|
|
76
76
|
_class_call_check(this, CalcPlugin);
|
|
77
77
|
_define_property(this, "engine", void 0);
|
|
78
78
|
_define_property(this, "options", void 0);
|
|
79
|
-
/**
|
|
80
|
-
* 所有的计算公式控件
|
|
79
|
+
/**
|
|
80
|
+
* 所有的计算公式控件
|
|
81
81
|
* */ // @ts-ignore
|
|
82
82
|
_define_property(this, "calcControls", []);
|
|
83
|
-
/**
|
|
84
|
-
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
85
|
-
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
83
|
+
/**
|
|
84
|
+
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
85
|
+
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
86
86
|
* */ _define_property(this, "dependenciesTriggerMap", new Map());
|
|
87
|
-
/**
|
|
88
|
-
* 隐藏以后需要被计算的控件
|
|
87
|
+
/**
|
|
88
|
+
* 隐藏以后需要被计算的控件
|
|
89
89
|
* */ _define_property(this, "hideNotRememberControlIds", []);
|
|
90
90
|
_define_property(this, "dontHasPermissionControlIds", []);
|
|
91
91
|
_define_property(this, "cacheComputedResult", {});
|
|
@@ -96,8 +96,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
96
96
|
_create_class(CalcPlugin, [
|
|
97
97
|
{
|
|
98
98
|
key: "getNeedHideRememberControlIds",
|
|
99
|
-
value: /**
|
|
100
|
-
* @description 获取显隐控制的需要被记住值的控件id
|
|
99
|
+
value: /**
|
|
100
|
+
* @description 获取显隐控制的需要被记住值的控件id
|
|
101
101
|
* */ function getNeedHideRememberControlIds() {
|
|
102
102
|
var _this_options;
|
|
103
103
|
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.displayBoList)) {
|
|
@@ -114,8 +114,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
key: "getDontHasPermissionControlIds",
|
|
117
|
-
value: /**
|
|
118
|
-
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
117
|
+
value: /**
|
|
118
|
+
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
119
119
|
* */ function getDontHasPermissionControlIds() {
|
|
120
120
|
var _this_options;
|
|
121
121
|
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.behavior)) {
|
|
@@ -131,9 +131,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
133
|
key: "controlNeedComputedValue",
|
|
134
|
-
value: /**
|
|
135
|
-
* @description 判断控件是否需要被计算
|
|
136
|
-
* @param control 控件
|
|
134
|
+
value: /**
|
|
135
|
+
* @description 判断控件是否需要被计算
|
|
136
|
+
* @param control 控件
|
|
137
137
|
* */ function controlNeedComputedValue(control) {
|
|
138
138
|
if (!control) {
|
|
139
139
|
return false;
|
|
@@ -153,9 +153,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
155
|
key: "getControlIsHide",
|
|
156
|
-
value: /**
|
|
157
|
-
* @description 获取控件是否被隐藏
|
|
158
|
-
* @param control 控件
|
|
156
|
+
value: /**
|
|
157
|
+
* @description 获取控件是否被隐藏
|
|
158
|
+
* @param control 控件
|
|
159
159
|
* */ function getControlIsHide(control) {
|
|
160
160
|
if (control.props.isHide) {
|
|
161
161
|
return true;
|
|
@@ -184,8 +184,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
186
|
key: "resetDependencies",
|
|
187
|
-
value: /**
|
|
188
|
-
* @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
|
|
187
|
+
value: /**
|
|
188
|
+
* @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
|
|
189
189
|
* */ function resetDependencies() {
|
|
190
190
|
this.calcControls = [];
|
|
191
191
|
this.dependenciesTriggerMap.clear();
|
|
@@ -195,8 +195,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
197
|
key: "allCalcControlComputed",
|
|
198
|
-
value: /**
|
|
199
|
-
* @description 执行所有计算公式控件的计算
|
|
198
|
+
value: /**
|
|
199
|
+
* @description 执行所有计算公式控件的计算
|
|
200
200
|
* */ function allCalcControlComputed() {
|
|
201
201
|
var _this = this;
|
|
202
202
|
this.calcControls.forEach(function(item) {
|
|
@@ -210,8 +210,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
210
210
|
},
|
|
211
211
|
{
|
|
212
212
|
key: "getAllCalcControl",
|
|
213
|
-
value: /**
|
|
214
|
-
* @description 获取所有的计算公式控件
|
|
213
|
+
value: /**
|
|
214
|
+
* @description 获取所有的计算公式控件
|
|
215
215
|
* */ function getAllCalcControl() {
|
|
216
216
|
this.calcControls = this.engine.runtime.flatInstances.filter(// @ts-ignore
|
|
217
217
|
function(item) {
|
|
@@ -221,8 +221,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
223
|
key: "getCalcDependencies",
|
|
224
|
-
value: /**
|
|
225
|
-
* @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
|
|
224
|
+
value: /**
|
|
225
|
+
* @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
|
|
226
226
|
* */ function getCalcDependencies() {
|
|
227
227
|
var _this = this;
|
|
228
228
|
this.calcControls.forEach(function(item) {
|
|
@@ -274,8 +274,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
274
274
|
},
|
|
275
275
|
{
|
|
276
276
|
key: "watchSchemaHideChange",
|
|
277
|
-
value: /**
|
|
278
|
-
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
277
|
+
value: /**
|
|
278
|
+
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
279
279
|
* */ function watchSchemaHideChange() {
|
|
280
280
|
var _this = this;
|
|
281
281
|
this.engine.on('schema-change', function(payload) {
|
|
@@ -291,8 +291,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
key: "watchSubtableChange",
|
|
294
|
-
value: /**
|
|
295
|
-
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
294
|
+
value: /**
|
|
295
|
+
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
296
296
|
* */ function watchSubtableChange() {
|
|
297
297
|
var _this = this;
|
|
298
298
|
this.engine.on('list-change', function(payload) {
|
|
@@ -319,8 +319,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
319
319
|
},
|
|
320
320
|
{
|
|
321
321
|
key: "watchControlChange",
|
|
322
|
-
value: /**
|
|
323
|
-
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
322
|
+
value: /**
|
|
323
|
+
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
324
324
|
* */ function watchControlChange() {
|
|
325
325
|
var _this = this;
|
|
326
326
|
this.engine.on('change', function(payload) {
|
|
@@ -355,8 +355,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
355
355
|
},
|
|
356
356
|
{
|
|
357
357
|
key: "controlInSubtable",
|
|
358
|
-
value: /**
|
|
359
|
-
* @description 控件在明细子表内
|
|
358
|
+
value: /**
|
|
359
|
+
* @description 控件在明细子表内
|
|
360
360
|
* */ function controlInSubtable(control) {
|
|
361
361
|
var _control_parent;
|
|
362
362
|
return ((_control_parent = control.parent) === null || _control_parent === void 0 ? void 0 : _control_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
|
|
@@ -364,8 +364,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
364
364
|
},
|
|
365
365
|
{
|
|
366
366
|
key: "computedCalcValue",
|
|
367
|
-
value: /**
|
|
368
|
-
* @description 执行计算公式的计算
|
|
367
|
+
value: /**
|
|
368
|
+
* @description 执行计算公式的计算
|
|
369
369
|
* */ // @ts-ignore
|
|
370
370
|
function computedCalcValue(control) {
|
|
371
371
|
var _this = this;
|
|
@@ -455,8 +455,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
455
455
|
},
|
|
456
456
|
{
|
|
457
457
|
key: "getNumberValue",
|
|
458
|
-
value: /**
|
|
459
|
-
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
458
|
+
value: /**
|
|
459
|
+
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
460
460
|
* */ function getNumberValue(value) {
|
|
461
461
|
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value) {
|
|
462
462
|
if ('result' in value) {
|
|
@@ -473,8 +473,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
473
473
|
},
|
|
474
474
|
{
|
|
475
475
|
key: "getAggregateTypeValue",
|
|
476
|
-
value: /**
|
|
477
|
-
* 计算明细子表最大值最小值平均值总和
|
|
476
|
+
value: /**
|
|
477
|
+
* 计算明细子表最大值最小值平均值总和
|
|
478
478
|
* */ function getAggregateTypeValue(values, type) {
|
|
479
479
|
if (!type || !values || !values.length) return 0;
|
|
480
480
|
switch(type){
|
|
@@ -60,7 +60,7 @@ function _define_property(obj, key, value) {
|
|
|
60
60
|
return obj;
|
|
61
61
|
}
|
|
62
62
|
function _ts_generator(thisArg, body) {
|
|
63
|
-
var f, y, t,
|
|
63
|
+
var f, y, t, _ = {
|
|
64
64
|
label: 0,
|
|
65
65
|
sent: function() {
|
|
66
66
|
if (t[0] & 1) throw t[1];
|
|
@@ -68,12 +68,8 @@ function _ts_generator(thisArg, body) {
|
|
|
68
68
|
},
|
|
69
69
|
trys: [],
|
|
70
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() {
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
72
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
77
73
|
return this;
|
|
78
74
|
}), g;
|
|
79
75
|
function verb(n) {
|
|
@@ -86,7 +82,7 @@ function _ts_generator(thisArg, body) {
|
|
|
86
82
|
}
|
|
87
83
|
function step(op) {
|
|
88
84
|
if (f) throw new TypeError("Generator is already executing.");
|
|
89
|
-
while(_)try {
|
|
85
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
90
86
|
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
87
|
if (y = 0, t) op = [
|
|
92
88
|
op[0] & 2,
|
|
@@ -217,13 +213,13 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
217
213
|
key: "engineAddEventListener",
|
|
218
214
|
value: function engineAddEventListener(eventKey, controlEventKey) {
|
|
219
215
|
var _this = this;
|
|
220
|
-
this.engine.on(eventKey,
|
|
221
|
-
|
|
216
|
+
this.engine.on(eventKey, function(payload) {
|
|
217
|
+
return _async_to_generator(function() {
|
|
222
218
|
return _ts_generator(this, function(_state) {
|
|
223
219
|
switch(_state.label){
|
|
224
220
|
case 0:
|
|
225
221
|
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
226
|
-
if ((eventKey === 'change' || eventKey === 'list-change') && !
|
|
222
|
+
if ((eventKey === 'change' || eventKey === 'list-change') && !this.engine.isMounted) {
|
|
227
223
|
return [
|
|
228
224
|
2
|
|
229
225
|
];
|
|
@@ -234,7 +230,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
234
230
|
];
|
|
235
231
|
return [
|
|
236
232
|
4,
|
|
237
|
-
|
|
233
|
+
this.callControlEvent(controlEventKey, payload)
|
|
238
234
|
];
|
|
239
235
|
case 1:
|
|
240
236
|
return [
|
|
@@ -247,23 +243,20 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
247
243
|
];
|
|
248
244
|
}
|
|
249
245
|
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
return _ref.apply(this, arguments);
|
|
253
|
-
};
|
|
254
|
-
}());
|
|
246
|
+
}).call(_this);
|
|
247
|
+
});
|
|
255
248
|
}
|
|
256
249
|
},
|
|
257
250
|
{
|
|
258
251
|
key: "callControlEvent",
|
|
259
252
|
value: function callControlEvent(name, payload) {
|
|
260
|
-
var _this = this;
|
|
261
253
|
return _async_to_generator(function() {
|
|
262
|
-
var events, result;
|
|
254
|
+
var _this, events, result;
|
|
263
255
|
return _ts_generator(this, function(_state) {
|
|
264
256
|
switch(_state.label){
|
|
265
257
|
case 0:
|
|
266
|
-
|
|
258
|
+
_this = this;
|
|
259
|
+
events = this.config[payload.instance.id];
|
|
267
260
|
if (!events || !Array.isArray(events[name])) {
|
|
268
261
|
return [
|
|
269
262
|
2,
|
|
@@ -272,15 +265,15 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
272
265
|
}
|
|
273
266
|
return [
|
|
274
267
|
4,
|
|
275
|
-
Promise.all(events[name].map(
|
|
276
|
-
|
|
268
|
+
Promise.all(events[name].map(function(eventName) {
|
|
269
|
+
return _async_to_generator(function() {
|
|
277
270
|
var execResult;
|
|
278
271
|
return _ts_generator(this, function(_state) {
|
|
279
272
|
switch(_state.label){
|
|
280
273
|
case 0:
|
|
281
274
|
return [
|
|
282
275
|
4,
|
|
283
|
-
|
|
276
|
+
this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
284
277
|
// this.engine,
|
|
285
278
|
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
286
279
|
payload)
|
|
@@ -293,11 +286,8 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
293
286
|
];
|
|
294
287
|
}
|
|
295
288
|
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
return _ref.apply(this, arguments);
|
|
299
|
-
};
|
|
300
|
-
}()))
|
|
289
|
+
}).call(_this);
|
|
290
|
+
}))
|
|
301
291
|
];
|
|
302
292
|
case 1:
|
|
303
293
|
result = _state.sent();
|
|
@@ -317,7 +307,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
317
307
|
];
|
|
318
308
|
}
|
|
319
309
|
});
|
|
320
|
-
})();
|
|
310
|
+
}).call(this);
|
|
321
311
|
}
|
|
322
312
|
}
|
|
323
313
|
]);
|
|
@@ -106,7 +106,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
106
106
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
107
107
|
}
|
|
108
108
|
function _ts_generator(thisArg, body) {
|
|
109
|
-
var f, y, t,
|
|
109
|
+
var f, y, t, _ = {
|
|
110
110
|
label: 0,
|
|
111
111
|
sent: function() {
|
|
112
112
|
if (t[0] & 1) throw t[1];
|
|
@@ -114,12 +114,8 @@ function _ts_generator(thisArg, body) {
|
|
|
114
114
|
},
|
|
115
115
|
trys: [],
|
|
116
116
|
ops: []
|
|
117
|
-
};
|
|
118
|
-
return g = {
|
|
119
|
-
next: verb(0),
|
|
120
|
-
"throw": verb(1),
|
|
121
|
-
"return": verb(2)
|
|
122
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
117
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
118
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
123
119
|
return this;
|
|
124
120
|
}), g;
|
|
125
121
|
function verb(n) {
|
|
@@ -132,7 +128,7 @@ function _ts_generator(thisArg, body) {
|
|
|
132
128
|
}
|
|
133
129
|
function step(op) {
|
|
134
130
|
if (f) throw new TypeError("Generator is already executing.");
|
|
135
|
-
while(_)try {
|
|
131
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
136
132
|
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;
|
|
137
133
|
if (y = 0, t) op = [
|
|
138
134
|
op[0] & 2,
|
|
@@ -223,16 +219,15 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
223
219
|
this.engine = engine;
|
|
224
220
|
Object.entries(LifecycleEventKeyMap).forEach(function(param) {
|
|
225
221
|
var _param = _sliced_to_array(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
var _ref = _async_to_generator(function(payload) {
|
|
222
|
+
engine.on(engineKey, function(payload) {
|
|
223
|
+
return _async_to_generator(function() {
|
|
229
224
|
var result;
|
|
230
225
|
return _ts_generator(this, function(_state) {
|
|
231
226
|
switch(_state.label){
|
|
232
227
|
case 0:
|
|
233
228
|
return [
|
|
234
229
|
4,
|
|
235
|
-
|
|
230
|
+
this.callLifecycleEvent(lifecycleKey, payload)
|
|
236
231
|
];
|
|
237
232
|
case 1:
|
|
238
233
|
result = _state.sent();
|
|
@@ -252,24 +247,21 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
252
247
|
];
|
|
253
248
|
}
|
|
254
249
|
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
return _ref.apply(this, arguments);
|
|
258
|
-
};
|
|
259
|
-
}());
|
|
250
|
+
}).call(_this);
|
|
251
|
+
});
|
|
260
252
|
});
|
|
261
253
|
}
|
|
262
254
|
},
|
|
263
255
|
{
|
|
264
256
|
key: "callLifecycleEvent",
|
|
265
257
|
value: function callLifecycleEvent(name, payload) {
|
|
266
|
-
var _this = this;
|
|
267
258
|
return _async_to_generator(function() {
|
|
268
|
-
var events, result;
|
|
259
|
+
var _this, events, result;
|
|
269
260
|
return _ts_generator(this, function(_state) {
|
|
270
261
|
switch(_state.label){
|
|
271
262
|
case 0:
|
|
272
|
-
|
|
263
|
+
_this = this;
|
|
264
|
+
events = this.config;
|
|
273
265
|
if (!events || !Array.isArray(events[name])) {
|
|
274
266
|
return [
|
|
275
267
|
2,
|
|
@@ -278,15 +270,15 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
278
270
|
}
|
|
279
271
|
return [
|
|
280
272
|
4,
|
|
281
|
-
Promise.all(events[name].map(
|
|
282
|
-
|
|
273
|
+
Promise.all(events[name].map(function(eventName) {
|
|
274
|
+
return _async_to_generator(function() {
|
|
283
275
|
var execResult;
|
|
284
276
|
return _ts_generator(this, function(_state) {
|
|
285
277
|
switch(_state.label){
|
|
286
278
|
case 0:
|
|
287
279
|
return [
|
|
288
280
|
4,
|
|
289
|
-
|
|
281
|
+
this.engine.getAction().execAction(eventName, //qiyu 注释掉的两个参数变为全局参数
|
|
290
282
|
// this.engine,
|
|
291
283
|
// this.engine.getAction().actionUtils, //以前是params,空的
|
|
292
284
|
payload)
|
|
@@ -299,11 +291,8 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
299
291
|
];
|
|
300
292
|
}
|
|
301
293
|
});
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
return _ref.apply(this, arguments);
|
|
305
|
-
};
|
|
306
|
-
}()))
|
|
294
|
+
}).call(_this);
|
|
295
|
+
}))
|
|
307
296
|
];
|
|
308
297
|
case 1:
|
|
309
298
|
result = _state.sent();
|
|
@@ -313,7 +302,7 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
313
302
|
];
|
|
314
303
|
}
|
|
315
304
|
});
|
|
316
|
-
})();
|
|
305
|
+
}).call(this);
|
|
317
306
|
}
|
|
318
307
|
}
|
|
319
308
|
]);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
3
|
-
* @Date: 2022-04-15 14:06:03
|
|
4
|
-
* @LastEditors: SuperLuckyqi
|
|
5
|
-
* @LastEditTime: 2024-11-08 11:17:53
|
|
6
|
-
* @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
|
|
1
|
+
/*
|
|
2
|
+
* @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
3
|
+
* @Date: 2022-04-15 14:06:03
|
|
4
|
+
* @LastEditors: SuperLuckyqi
|
|
5
|
+
* @LastEditTime: 2024-11-08 11:17:53
|
|
6
|
+
* @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
|
|
7
7
|
*/ function _class_call_check(instance, Constructor) {
|
|
8
8
|
if (!(instance instanceof Constructor)) {
|
|
9
9
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -36,6 +36,8 @@ function _define_property(obj, key, value) {
|
|
|
36
36
|
}
|
|
37
37
|
return obj;
|
|
38
38
|
}
|
|
39
|
+
import postcss from 'postcss';
|
|
40
|
+
import prefixSelector from 'postcss-prefix-selector';
|
|
39
41
|
export var StylePlugin = /*#__PURE__*/ function() {
|
|
40
42
|
"use strict";
|
|
41
43
|
function StylePlugin(config) {
|
|
@@ -51,7 +53,7 @@ export var StylePlugin = /*#__PURE__*/ function() {
|
|
|
51
53
|
{
|
|
52
54
|
key: "apply",
|
|
53
55
|
value: function apply(engine) {
|
|
54
|
-
var _this_config;
|
|
56
|
+
var _this_config, _this_engine;
|
|
55
57
|
this.engine = engine;
|
|
56
58
|
var _this_config_source;
|
|
57
59
|
var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : '';
|
|
@@ -59,12 +61,11 @@ export var StylePlugin = /*#__PURE__*/ function() {
|
|
|
59
61
|
style.className = 'edit-css-' + engine.id;
|
|
60
62
|
var dom = document.querySelector('head');
|
|
61
63
|
dom === null || dom === void 0 ? void 0 : dom.appendChild(style);
|
|
62
|
-
var cssStyleText
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
64
|
+
var cssStyleText = postcss([
|
|
65
|
+
prefixSelector({
|
|
66
|
+
prefix: ".render-engine-".concat((_this_engine = this.engine) === null || _this_engine === void 0 ? void 0 : _this_engine.id)
|
|
67
|
+
})
|
|
68
|
+
]).process(compiledStyle).css;
|
|
68
69
|
style.appendChild(document.createTextNode(cssStyleText));
|
|
69
70
|
}
|
|
70
71
|
}
|