@byteluck-fe/model-driven-engine 2.3.1-beta.23 → 2.3.1-beta.25

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.
Files changed (40) hide show
  1. package/package.json +2 -2
  2. package/dist/esm/common/ActionManager.js +0 -238
  3. package/dist/esm/common/DataManager.js +0 -172
  4. package/dist/esm/common/Engine.js +0 -1401
  5. package/dist/esm/common/OkWorker.js +0 -89
  6. package/dist/esm/common/Plugin.js +0 -10
  7. package/dist/esm/common/Runtime.js +0 -289
  8. package/dist/esm/common/Store.js +0 -345
  9. package/dist/esm/common/checkerValue.js +0 -547
  10. package/dist/esm/common/index.js +0 -2
  11. package/dist/esm/common/proxyState.js +0 -315
  12. package/dist/esm/index.js +0 -3
  13. package/dist/esm/plugins/CalcPlugin.js +0 -398
  14. package/dist/esm/plugins/ControlsEventPlugin.js +0 -276
  15. package/dist/esm/plugins/ES6ModulePlugin.js +0 -147
  16. package/dist/esm/plugins/LifecycleEventPlugin.js +0 -284
  17. package/dist/esm/plugins/StylePlugin.js +0 -26
  18. package/dist/esm/plugins/index.js +0 -5
  19. package/dist/esm/utils/index.js +0 -1
  20. package/dist/esm/utils/runtimeUtils.js +0 -43
  21. package/dist/index.umd.js +0 -28
  22. package/dist/types/common/ActionManager.d.ts +0 -14
  23. package/dist/types/common/DataManager.d.ts +0 -10
  24. package/dist/types/common/Engine.d.ts +0 -180
  25. package/dist/types/common/OkWorker.d.ts +0 -13
  26. package/dist/types/common/Plugin.d.ts +0 -6
  27. package/dist/types/common/Runtime.d.ts +0 -25
  28. package/dist/types/common/Store.d.ts +0 -49
  29. package/dist/types/common/checkerValue.d.ts +0 -3
  30. package/dist/types/common/index.d.ts +0 -2
  31. package/dist/types/common/proxyState.d.ts +0 -30
  32. package/dist/types/index.d.ts +0 -3
  33. package/dist/types/plugins/CalcPlugin.d.ts +0 -121
  34. package/dist/types/plugins/ControlsEventPlugin.d.ts +0 -15
  35. package/dist/types/plugins/ES6ModulePlugin.d.ts +0 -26
  36. package/dist/types/plugins/LifecycleEventPlugin.d.ts +0 -14
  37. package/dist/types/plugins/StylePlugin.d.ts +0 -12
  38. package/dist/types/plugins/index.d.ts +0 -5
  39. package/dist/types/utils/index.d.ts +0 -1
  40. package/dist/types/utils/runtimeUtils.d.ts +0 -5
@@ -1,89 +0,0 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
5
- }
6
- import { log } from "@byteluck-fe/model-driven-shared";
7
- var OkWorker = /*#__PURE__*/ function() {
8
- "use strict";
9
- function OkWorker() {
10
- _classCallCheck(this, OkWorker);
11
- }
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
- }
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
- }
83
- });
84
- });
85
- };
86
- };
87
- return OkWorker;
88
- }();
89
- export { OkWorker };
@@ -1,10 +0,0 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
5
- }
6
- var Plugin = function Plugin() {
7
- "use strict";
8
- _classCallCheck(this, Plugin);
9
- };
10
- export { Plugin };
@@ -1,289 +0,0 @@
1
- function _assertThisInitialized(self) {
2
- if (self === void 0) {
3
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
- }
5
- return self;
6
- }
7
- function _classCallCheck(instance, Constructor) {
8
- if (!(instance instanceof Constructor)) {
9
- throw new TypeError("Cannot call a class as a function");
10
- }
11
- }
12
- function _defineProperties(target, props) {
13
- for(var i = 0; i < props.length; i++){
14
- var descriptor = props[i];
15
- descriptor.enumerable = descriptor.enumerable || false;
16
- descriptor.configurable = true;
17
- if ("value" in descriptor) descriptor.writable = true;
18
- Object.defineProperty(target, descriptor.key, descriptor);
19
- }
20
- }
21
- function _createClass(Constructor, protoProps, staticProps) {
22
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
23
- if (staticProps) _defineProperties(Constructor, staticProps);
24
- return Constructor;
25
- }
26
- function _getPrototypeOf(o) {
27
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
28
- return o.__proto__ || Object.getPrototypeOf(o);
29
- };
30
- return _getPrototypeOf(o);
31
- }
32
- function _inherits(subClass, superClass) {
33
- if (typeof superClass !== "function" && superClass !== null) {
34
- throw new TypeError("Super expression must either be null or a function");
35
- }
36
- subClass.prototype = Object.create(superClass && superClass.prototype, {
37
- constructor: {
38
- value: subClass,
39
- writable: true,
40
- configurable: true
41
- }
42
- });
43
- if (superClass) _setPrototypeOf(subClass, superClass);
44
- }
45
- function _possibleConstructorReturn(self, call) {
46
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
47
- return call;
48
- }
49
- return _assertThisInitialized(self);
50
- }
51
- function _setPrototypeOf(o, p) {
52
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
53
- o.__proto__ = p;
54
- return o;
55
- };
56
- return _setPrototypeOf(o, p);
57
- }
58
- var _typeof = function(obj) {
59
- "@swc/helpers - typeof";
60
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
61
- };
62
- function _isNativeReflectConstruct() {
63
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
64
- if (Reflect.construct.sham) return false;
65
- if (typeof Proxy === "function") return true;
66
- try {
67
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
68
- return true;
69
- } catch (e) {
70
- return false;
71
- }
72
- }
73
- function _createSuper(Derived) {
74
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
75
- return function _createSuperInternal() {
76
- var Super = _getPrototypeOf(Derived), result;
77
- if (hasNativeReflectConstruct) {
78
- var NewTarget = _getPrototypeOf(this).constructor;
79
- result = Reflect.construct(Super, arguments, NewTarget);
80
- } else {
81
- result = Super.apply(this, arguments);
82
- }
83
- return _possibleConstructorReturn(this, result);
84
- };
85
- }
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
- "use strict";
91
- _inherits(Runtime, RegisterControls);
92
- var _super = _createSuper(Runtime);
93
- function Runtime(props) {
94
- _classCallCheck(this, Runtime);
95
- var _this;
96
- _this = _super.call(this, "Runtime");
97
- _this._flatInstances = [];
98
- _this._instanceMap = {};
99
- var schema = props.schema;
100
- _this._schema = schema;
101
- _this._instance = _this.createControl(schema, props.beforeCreateInstance);
102
- _this.getFlatInstances();
103
- return _this;
104
- }
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;
113
- }
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, [
125
- {
126
- key: "schema",
127
- get: function get() {
128
- return this._schema;
129
- }
130
- },
131
- {
132
- key: "instance",
133
- get: function get() {
134
- return this._instance;
135
- }
136
- },
137
- {
138
- key: "flatInstances",
139
- get: function get() {
140
- return this._flatInstances;
141
- }
142
- },
143
- {
144
- key: "instanceMap",
145
- get: function get() {
146
- return this._instanceMap;
147
- }
148
- },
149
- {
150
- key: "allRules",
151
- get: function get() {
152
- var antdRules = {};
153
- var ruleItems = {};
154
- loopDataViewControl(this._instance, function(dataView) {
155
- ruleItems[dataView.id] = dataView.rules[0];
156
- antdRules[dataView.id] = dataView.rules[0];
157
- loopFormControl(dataView.children, function(item) {
158
- // if (
159
- // item instanceof RuntimeFormControl ||
160
- // item instanceof RuntimeListControl
161
- // ) {
162
- if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
163
- buildControlRules(ruleItems[dataView.id].fields, item);
164
- buildControlAntdRules(antdRules[dataView.id].fields, item);
165
- }
166
- });
167
- });
168
- return {
169
- rules: ruleItems,
170
- antdRules: antdRules
171
- };
172
- }
173
- },
174
- {
175
- key: "rules",
176
- get: function get() {
177
- var ruleItems = {};
178
- loopDataViewControl(this._instance, function(dataView) {
179
- ruleItems[dataView.id] = dataView.rules[0];
180
- loopFormControl(dataView.children, function(item) {
181
- // if (
182
- // item instanceof RuntimeFormControl ||
183
- // item instanceof RuntimeListControl
184
- // ) {
185
- if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
186
- buildControlRules(ruleItems[dataView.id].fields, item);
187
- }
188
- });
189
- });
190
- return ruleItems;
191
- }
192
- },
193
- {
194
- key: "antdRules",
195
- get: function get() {
196
- var antdRules = {};
197
- loopDataViewControl(this._instance, function(dataView) {
198
- antdRules[dataView.id] = dataView.rules[0];
199
- loopFormControl(dataView.children, function(item) {
200
- // if (
201
- // item instanceof RuntimeFormControl ||
202
- // item instanceof RuntimeListControl
203
- // ) {
204
- if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
205
- buildControlAntdRules(antdRules[dataView.id].fields, item);
206
- }
207
- });
208
- });
209
- return antdRules;
210
- }
211
- }
212
- ]);
213
- return Runtime;
214
- }(RegisterControls);
215
- function loop(control, callback) {
216
- if (Array.isArray(control)) {
217
- control.map(function(item) {
218
- callback(item);
219
- if (hasChildrenControl(item)) {
220
- // @ts-ignore
221
- loop(item.children, callback);
222
- }
223
- });
224
- } else {
225
- callback(control);
226
- }
227
- }
228
- /**
229
- * 控件是否在视图中隐藏,遍历查找所有parent
230
- * */ function getControlIsHide(control) {
231
- if (control.props.isHide) {
232
- return true;
233
- }
234
- if (control.parent === null) {
235
- return false;
236
- }
237
- return getControlIsHide(control.parent);
238
- }
239
- function buildControlRules(data, // @ts-ignore
240
- item) {
241
- if (getControlIsHide(item)) {
242
- return;
243
- }
244
- // if (item instanceof RuntimeFormControl) {
245
- if (item.controlType === CONTROL_BASE_TYPE.FORM) {
246
- data[item.id] = item.rules;
247
- } else if (item.type === CONTROL_TYPE.SUBTABLE) {
248
- data[item.id] = item.rules;
249
- var itemRules = {
250
- type: "array",
251
- fields: {}
252
- };
253
- item.children.forEach(function(row, index) {
254
- loopFormSchema(row.children, function(formControl) {
255
- if (itemRules.fields) {
256
- if (!itemRules.fields[index]) {
257
- itemRules.fields[index] = {
258
- type: "object",
259
- required: true,
260
- fields: {}
261
- };
262
- }
263
- // @ts-ignore
264
- itemRules.fields[index].fields[formControl.id] = formControl.rules;
265
- }
266
- });
267
- });
268
- data[item.id].push(itemRules);
269
- }
270
- }
271
- function buildControlAntdRules(antdRules, // @ts-ignore
272
- item) {
273
- if (getControlIsHide(item)) {
274
- return;
275
- }
276
- // if (item instanceof RuntimeFormControl) {
277
- if (item.controlType === CONTROL_BASE_TYPE.FORM) {
278
- antdRules[item.id] = item.rules;
279
- } else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
280
- antdRules[item.id] = [];
281
- item.children.forEach(function(row) {
282
- var rules = {};
283
- loopFormSchema(row.children, function(formControl) {
284
- rules[formControl.id] = formControl.rules;
285
- });
286
- antdRules[item.id].push(rules);
287
- });
288
- }
289
- }