@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.
- package/dist/esm/common/ActionManager.js +114 -79
- package/dist/esm/common/DataManager.js +80 -39
- package/dist/esm/common/Engine.js +1205 -985
- package/dist/esm/common/OkWorker.js +121 -76
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +66 -45
- package/dist/esm/common/Store.js +168 -137
- package/dist/esm/common/checkerValue.js +383 -299
- package/dist/esm/common/proxyState.js +18 -17
- package/dist/esm/plugins/CalcPlugin.js +406 -321
- package/dist/esm/plugins/ControlsEventPlugin.js +174 -135
- package/dist/esm/plugins/ES6ModulePlugin.js +77 -43
- package/dist/esm/plugins/LifecycleEventPlugin.js +134 -98
- package/dist/esm/plugins/StylePlugin.js +48 -15
- package/dist/esm/utils/runtimeUtils.js +6 -3
- package/dist/index.umd.js +11 -11
- package/dist/types/common/Engine.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,89 +1,134 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
6
33
|
import { log } from "@byteluck-fe/model-driven-shared";
|
|
7
34
|
var OkWorker = /*#__PURE__*/ function() {
|
|
8
35
|
"use strict";
|
|
9
36
|
function OkWorker() {
|
|
10
|
-
|
|
37
|
+
_class_call_check(this, OkWorker);
|
|
38
|
+
_define_property(this, "worker", void 0);
|
|
11
39
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
_proto.destroy = function destroy() {
|
|
21
|
-
var _this_worker;
|
|
22
|
-
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.terminate();
|
|
23
|
-
};
|
|
24
|
-
_proto.postMessage = function postMessage(message) {
|
|
25
|
-
var _this_worker;
|
|
26
|
-
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.postMessage(message);
|
|
27
|
-
};
|
|
28
|
-
OkWorker.createWorker = function createWorker() {
|
|
29
|
-
var blob = new Blob([
|
|
30
|
-
"(".concat(OkWorker.createWorkerFunction().toString(), ")()")
|
|
31
|
-
]);
|
|
32
|
-
var url = window.URL.createObjectURL(blob);
|
|
33
|
-
return new Worker(url);
|
|
34
|
-
};
|
|
35
|
-
OkWorker.createWorkerFunction = function createWorkerFunction() {
|
|
36
|
-
return function() {
|
|
37
|
-
var createHandler = function createHandler(parentKey) {
|
|
38
|
-
return {
|
|
39
|
-
get: function get(target, key, value) {
|
|
40
|
-
return Reflect.get(target, key, value);
|
|
41
|
-
},
|
|
42
|
-
set: function set(target, key, value) {
|
|
43
|
-
if (parentKey) {
|
|
44
|
-
_self.postMessage({
|
|
45
|
-
action: "update",
|
|
46
|
-
key: "".concat(parentKey, ".").concat(key)
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return Reflect.set(target, key, value);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
log("\uD83D\uDE80 worker running");
|
|
54
|
-
var _self = self;
|
|
55
|
-
// function createProxy(
|
|
56
|
-
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
57
|
-
// parentKey?: string
|
|
58
|
-
// ) {
|
|
59
|
-
// for (const key in obj) {
|
|
60
|
-
// if (Array.isArray(obj[key])) {
|
|
61
|
-
//
|
|
62
|
-
// }
|
|
63
|
-
// }
|
|
64
|
-
// return new Proxy(obj, createHandler(parentKey))
|
|
65
|
-
// }
|
|
66
|
-
_self.addEventListener("message", function(event) {
|
|
67
|
-
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
68
|
-
log(action, payload);
|
|
69
|
-
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
70
|
-
// data.key1 = 1
|
|
71
|
-
//
|
|
72
|
-
// data.key2.amount = 1
|
|
73
|
-
//
|
|
74
|
-
// data.key3[0].key1 = 2
|
|
75
|
-
//
|
|
76
|
-
// const result = fn(data, schema)
|
|
77
|
-
_self.postMessage({
|
|
78
|
-
action: "delete",
|
|
79
|
-
payload: {
|
|
80
|
-
key: "key3[0].key1",
|
|
81
|
-
value: "index"
|
|
82
|
-
}
|
|
40
|
+
_create_class(OkWorker, [
|
|
41
|
+
{
|
|
42
|
+
key: "run",
|
|
43
|
+
value: function run(initState) {
|
|
44
|
+
this.worker = OkWorker.createWorker();
|
|
45
|
+
this.postMessage({
|
|
46
|
+
action: "init",
|
|
47
|
+
payload: initState
|
|
83
48
|
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "destroy",
|
|
53
|
+
value: function destroy() {
|
|
54
|
+
var _this_worker;
|
|
55
|
+
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.terminate();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "postMessage",
|
|
60
|
+
value: function postMessage(message) {
|
|
61
|
+
var _this_worker;
|
|
62
|
+
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.postMessage(message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
], [
|
|
66
|
+
{
|
|
67
|
+
key: "createWorker",
|
|
68
|
+
value: function createWorker() {
|
|
69
|
+
var blob = new Blob([
|
|
70
|
+
"(".concat(OkWorker.createWorkerFunction().toString(), ")()")
|
|
71
|
+
]);
|
|
72
|
+
var url = window.URL.createObjectURL(blob);
|
|
73
|
+
return new Worker(url);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "createWorkerFunction",
|
|
78
|
+
value: function createWorkerFunction() {
|
|
79
|
+
return function() {
|
|
80
|
+
var createHandler = function createHandler(parentKey) {
|
|
81
|
+
return {
|
|
82
|
+
get: function get(target, key, value) {
|
|
83
|
+
return Reflect.get(target, key, value);
|
|
84
|
+
},
|
|
85
|
+
set: function set(target, key, value) {
|
|
86
|
+
if (parentKey) {
|
|
87
|
+
_self.postMessage({
|
|
88
|
+
action: "update",
|
|
89
|
+
key: "".concat(parentKey, ".").concat(key)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return Reflect.set(target, key, value);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
log("\uD83D\uDE80 worker running");
|
|
97
|
+
var _self = self;
|
|
98
|
+
// function createProxy(
|
|
99
|
+
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
100
|
+
// parentKey?: string
|
|
101
|
+
// ) {
|
|
102
|
+
// for (const key in obj) {
|
|
103
|
+
// if (Array.isArray(obj[key])) {
|
|
104
|
+
//
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
// return new Proxy(obj, createHandler(parentKey))
|
|
108
|
+
// }
|
|
109
|
+
_self.addEventListener("message", function(event) {
|
|
110
|
+
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
111
|
+
log(action, payload);
|
|
112
|
+
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
113
|
+
// data.key1 = 1
|
|
114
|
+
//
|
|
115
|
+
// data.key2.amount = 1
|
|
116
|
+
//
|
|
117
|
+
// data.key3[0].key1 = 2
|
|
118
|
+
//
|
|
119
|
+
// const result = fn(data, schema)
|
|
120
|
+
_self.postMessage({
|
|
121
|
+
action: "delete",
|
|
122
|
+
payload: {
|
|
123
|
+
key: "key3[0].key1",
|
|
124
|
+
value: "index"
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
]);
|
|
87
132
|
return OkWorker;
|
|
88
133
|
}();
|
|
89
134
|
export { OkWorker };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
var Plugin = function Plugin() {
|
|
7
7
|
"use strict";
|
|
8
|
-
|
|
8
|
+
_class_call_check(this, Plugin);
|
|
9
9
|
};
|
|
10
10
|
export { Plugin };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
2
|
if (self === void 0) {
|
|
3
3
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
4
|
}
|
|
5
5
|
return self;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
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");
|
|
10
10
|
}
|
|
@@ -18,16 +18,29 @@ function _defineProperties(target, props) {
|
|
|
18
18
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
22
22
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
23
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
24
|
return Constructor;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
26
|
+
function _define_property(obj, key, value) {
|
|
27
|
+
if (key in obj) {
|
|
28
|
+
Object.defineProperty(obj, key, {
|
|
29
|
+
value: value,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
obj[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
function _get_prototype_of(o) {
|
|
40
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
28
41
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
29
42
|
};
|
|
30
|
-
return
|
|
43
|
+
return _get_prototype_of(o);
|
|
31
44
|
}
|
|
32
45
|
function _inherits(subClass, superClass) {
|
|
33
46
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -40,26 +53,26 @@ function _inherits(subClass, superClass) {
|
|
|
40
53
|
configurable: true
|
|
41
54
|
}
|
|
42
55
|
});
|
|
43
|
-
if (superClass)
|
|
56
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
44
57
|
}
|
|
45
|
-
function
|
|
46
|
-
if (call && (
|
|
58
|
+
function _possible_constructor_return(self, call) {
|
|
59
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
47
60
|
return call;
|
|
48
61
|
}
|
|
49
|
-
return
|
|
62
|
+
return _assert_this_initialized(self);
|
|
50
63
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
64
|
+
function _set_prototype_of(o, p) {
|
|
65
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
53
66
|
o.__proto__ = p;
|
|
54
67
|
return o;
|
|
55
68
|
};
|
|
56
|
-
return
|
|
69
|
+
return _set_prototype_of(o, p);
|
|
57
70
|
}
|
|
58
|
-
|
|
71
|
+
function _type_of(obj) {
|
|
59
72
|
"@swc/helpers - typeof";
|
|
60
73
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
61
|
-
}
|
|
62
|
-
function
|
|
74
|
+
}
|
|
75
|
+
function _is_native_reflect_construct() {
|
|
63
76
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
64
77
|
if (Reflect.construct.sham) return false;
|
|
65
78
|
if (typeof Proxy === "function") return true;
|
|
@@ -70,17 +83,17 @@ function _isNativeReflectConstruct() {
|
|
|
70
83
|
return false;
|
|
71
84
|
}
|
|
72
85
|
}
|
|
73
|
-
function
|
|
74
|
-
var hasNativeReflectConstruct =
|
|
86
|
+
function _create_super(Derived) {
|
|
87
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
75
88
|
return function _createSuperInternal() {
|
|
76
|
-
var Super =
|
|
89
|
+
var Super = _get_prototype_of(Derived), result;
|
|
77
90
|
if (hasNativeReflectConstruct) {
|
|
78
|
-
var NewTarget =
|
|
91
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
79
92
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
80
93
|
} else {
|
|
81
94
|
result = Super.apply(this, arguments);
|
|
82
95
|
}
|
|
83
|
-
return
|
|
96
|
+
return _possible_constructor_return(this, result);
|
|
84
97
|
};
|
|
85
98
|
}
|
|
86
99
|
import { RegisterControls } from "@byteluck-fe/model-driven-core";
|
|
@@ -89,39 +102,43 @@ import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../uti
|
|
|
89
102
|
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
90
103
|
"use strict";
|
|
91
104
|
_inherits(Runtime, RegisterControls);
|
|
92
|
-
var _super =
|
|
105
|
+
var _super = _create_super(Runtime);
|
|
93
106
|
function Runtime(props) {
|
|
94
|
-
|
|
107
|
+
_class_call_check(this, Runtime);
|
|
95
108
|
var _this;
|
|
96
109
|
_this = _super.call(this, "Runtime");
|
|
97
|
-
_this
|
|
98
|
-
_this
|
|
110
|
+
_define_property(_assert_this_initialized(_this), "_schema", void 0);
|
|
111
|
+
_define_property(_assert_this_initialized(_this), "_instance", void 0);
|
|
112
|
+
_define_property(_assert_this_initialized(_this), "_flatInstances", []);
|
|
113
|
+
_define_property(_assert_this_initialized(_this), "_instanceMap", {});
|
|
99
114
|
var schema = props.schema;
|
|
100
115
|
_this._schema = schema;
|
|
101
116
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
102
117
|
_this.getFlatInstances();
|
|
103
118
|
return _this;
|
|
104
119
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
_create_class(Runtime, [
|
|
121
|
+
{
|
|
122
|
+
key: "getFlatInstances",
|
|
123
|
+
value: function getFlatInstances() {
|
|
124
|
+
var instances = [];
|
|
125
|
+
var instanceMap = {};
|
|
126
|
+
loop(this._instance, function(item) {
|
|
127
|
+
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
128
|
+
if (item.type === "subtable-row" || item.type === "subtable-column") {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
instances.push(item);
|
|
132
|
+
if (!instanceMap[item.id]) {
|
|
133
|
+
instanceMap[item.id] = [];
|
|
134
|
+
}
|
|
135
|
+
instanceMap[item.id].push(item);
|
|
136
|
+
});
|
|
137
|
+
this._flatInstances = instances;
|
|
138
|
+
this._instanceMap = instanceMap;
|
|
139
|
+
return this._flatInstances;
|
|
117
140
|
}
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
this._flatInstances = instances;
|
|
121
|
-
this._instanceMap = instanceMap;
|
|
122
|
-
return this._flatInstances;
|
|
123
|
-
};
|
|
124
|
-
_createClass(Runtime, [
|
|
141
|
+
},
|
|
125
142
|
{
|
|
126
143
|
key: "schema",
|
|
127
144
|
get: function get() {
|
|
@@ -217,8 +234,12 @@ function loop(control, callback) {
|
|
|
217
234
|
control.map(function(item) {
|
|
218
235
|
callback(item);
|
|
219
236
|
if (hasChildrenControl(item)) {
|
|
237
|
+
var ctl = item;
|
|
238
|
+
if (!ctl.children) {
|
|
239
|
+
ctl.children = [];
|
|
240
|
+
}
|
|
220
241
|
// @ts-ignore
|
|
221
|
-
loop(
|
|
242
|
+
loop(ctl.children, callback);
|
|
222
243
|
}
|
|
223
244
|
});
|
|
224
245
|
} else {
|