@byteluck-fe/model-driven-engine 2.7.0-alpha.0 → 2.7.0-alpha.2
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 +154 -72
- package/dist/esm/common/DataManager.js +128 -60
- package/dist/esm/common/Engine.js +1060 -1111
- package/dist/esm/common/OkWorker.js +75 -106
- package/dist/esm/common/Runtime.js +27 -29
- package/dist/esm/common/Store.js +149 -181
- package/dist/esm/common/checkerValue.js +253 -328
- 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 +306 -382
- package/dist/esm/plugins/ControlsEventPlugin.js +225 -141
- package/dist/esm/plugins/ES6ModulePlugin.js +38 -56
- package/dist/esm/plugins/LifecycleEventPlugin.js +190 -107
- package/dist/esm/plugins/StylePlugin.js +13 -31
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +5 -7
- package/dist/index.umd.js +9 -9
- package/dist/types/common/Engine.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +1 -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
|
@@ -3,118 +3,87 @@ function _classCallCheck(instance, Constructor) {
|
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
|
|
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 _createClass(Constructor, protoProps, staticProps) {
|
|
16
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
-
return Constructor;
|
|
19
|
-
}
|
|
20
|
-
import { log } from '@byteluck-fe/model-driven-shared';
|
|
6
|
+
import { log } from "@byteluck-fe/model-driven-shared";
|
|
21
7
|
var OkWorker = /*#__PURE__*/ function() {
|
|
22
8
|
"use strict";
|
|
23
9
|
function OkWorker() {
|
|
24
10
|
_classCallCheck(this, OkWorker);
|
|
25
11
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return function() {
|
|
66
|
-
var createHandler = function createHandler(parentKey) {
|
|
67
|
-
return {
|
|
68
|
-
get: function get(target, key, value) {
|
|
69
|
-
return Reflect.get(target, key, value);
|
|
70
|
-
},
|
|
71
|
-
set: function set(target, key, value) {
|
|
72
|
-
if (parentKey) {
|
|
73
|
-
_self.postMessage({
|
|
74
|
-
action: 'update',
|
|
75
|
-
key: "".concat(parentKey, ".").concat(key)
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return Reflect.set(target, key, value);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
log('🚀 worker running');
|
|
83
|
-
var _self = self;
|
|
84
|
-
// function createProxy(
|
|
85
|
-
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
86
|
-
// parentKey?: string
|
|
87
|
-
// ) {
|
|
88
|
-
// for (const key in obj) {
|
|
89
|
-
// if (Array.isArray(obj[key])) {
|
|
90
|
-
//
|
|
91
|
-
// }
|
|
92
|
-
// }
|
|
93
|
-
// return new Proxy(obj, createHandler(parentKey))
|
|
94
|
-
// }
|
|
95
|
-
_self.addEventListener('message', function(event) {
|
|
96
|
-
var _data = event.data, action = _data.action, payload = _data.payload, fn = _data.fn;
|
|
97
|
-
log(action, payload);
|
|
98
|
-
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
99
|
-
// data.key1 = 1
|
|
100
|
-
//
|
|
101
|
-
// data.key2.amount = 1
|
|
102
|
-
//
|
|
103
|
-
// data.key3[0].key1 = 2
|
|
104
|
-
//
|
|
105
|
-
// const result = fn(data, schema)
|
|
106
|
-
_self.postMessage({
|
|
107
|
-
action: 'delete',
|
|
108
|
-
payload: {
|
|
109
|
-
key: 'key3[0].key1',
|
|
110
|
-
value: 'index'
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
12
|
+
var _proto = OkWorker.prototype;
|
|
13
|
+
_proto.run = function run(initState) {
|
|
14
|
+
this.worker = OkWorker.createWorker();
|
|
15
|
+
this.postMessage({
|
|
16
|
+
action: "init",
|
|
17
|
+
payload: initState
|
|
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
|
+
}
|
|
114
51
|
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
};
|
|
118
87
|
return OkWorker;
|
|
119
88
|
}();
|
|
120
89
|
export { OkWorker };
|
|
@@ -83,17 +83,17 @@ function _createSuper(Derived) {
|
|
|
83
83
|
return _possibleConstructorReturn(this, result);
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
import { RegisterControls } from
|
|
87
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from
|
|
88
|
-
import { hasChildrenControl, loopDataViewControl, loopFormControl } from
|
|
89
|
-
export var Runtime = /*#__PURE__*/ function(
|
|
86
|
+
import { RegisterControls } from "@byteluck-fe/model-driven-core";
|
|
87
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from "@byteluck-fe/model-driven-shared";
|
|
88
|
+
import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../utils/runtimeUtils";
|
|
89
|
+
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
90
90
|
"use strict";
|
|
91
|
-
_inherits(Runtime,
|
|
91
|
+
_inherits(Runtime, RegisterControls);
|
|
92
92
|
var _super = _createSuper(Runtime);
|
|
93
93
|
function Runtime(props) {
|
|
94
94
|
_classCallCheck(this, Runtime);
|
|
95
95
|
var _this;
|
|
96
|
-
_this = _super.call(this,
|
|
96
|
+
_this = _super.call(this, "Runtime");
|
|
97
97
|
_this._flatInstances = [];
|
|
98
98
|
_this._instanceMap = {};
|
|
99
99
|
var schema = props.schema;
|
|
@@ -102,28 +102,26 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
102
102
|
_this.getFlatInstances();
|
|
103
103
|
return _this;
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
instances.push(item);
|
|
117
|
-
if (!instanceMap[item.id]) {
|
|
118
|
-
instanceMap[item.id] = [];
|
|
119
|
-
}
|
|
120
|
-
instanceMap[item.id].push(item);
|
|
121
|
-
});
|
|
122
|
-
this._flatInstances = instances;
|
|
123
|
-
this._instanceMap = instanceMap;
|
|
124
|
-
return this._flatInstances;
|
|
105
|
+
var _proto = Runtime.prototype;
|
|
106
|
+
_proto.getFlatInstances = function getFlatInstances() {
|
|
107
|
+
var instances = [];
|
|
108
|
+
var instanceMap = {};
|
|
109
|
+
loop(this._instance, function(item) {
|
|
110
|
+
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
111
|
+
if (item.type === "subtable-row" || item.type === "subtable-column") {
|
|
112
|
+
return;
|
|
125
113
|
}
|
|
126
|
-
|
|
114
|
+
instances.push(item);
|
|
115
|
+
if (!instanceMap[item.id]) {
|
|
116
|
+
instanceMap[item.id] = [];
|
|
117
|
+
}
|
|
118
|
+
instanceMap[item.id].push(item);
|
|
119
|
+
});
|
|
120
|
+
this._flatInstances = instances;
|
|
121
|
+
this._instanceMap = instanceMap;
|
|
122
|
+
return this._flatInstances;
|
|
123
|
+
};
|
|
124
|
+
_createClass(Runtime, [
|
|
127
125
|
{
|
|
128
126
|
key: "schema",
|
|
129
127
|
get: function get() {
|
|
@@ -249,7 +247,7 @@ item) {
|
|
|
249
247
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
250
248
|
data[item.id] = item.rules;
|
|
251
249
|
var itemRules = {
|
|
252
|
-
type:
|
|
250
|
+
type: "array",
|
|
253
251
|
fields: {}
|
|
254
252
|
};
|
|
255
253
|
item.children.forEach(function(row, index) {
|
|
@@ -257,7 +255,7 @@ item) {
|
|
|
257
255
|
if (itemRules.fields) {
|
|
258
256
|
if (!itemRules.fields[index]) {
|
|
259
257
|
itemRules.fields[index] = {
|
|
260
|
-
type:
|
|
258
|
+
type: "object",
|
|
261
259
|
required: true,
|
|
262
260
|
fields: {}
|
|
263
261
|
};
|