@byteluck-fe/model-driven-engine 2.6.0-alpha.1 → 2.6.0-alpha.8

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 (39) hide show
  1. package/dist/esm/common/ActionManager.js +72 -154
  2. package/dist/esm/common/DataManager.js +60 -128
  3. package/dist/esm/common/Engine.js +1104 -1054
  4. package/dist/esm/common/OkWorker.js +106 -75
  5. package/dist/esm/common/Runtime.js +29 -27
  6. package/dist/esm/common/Store.js +180 -148
  7. package/dist/esm/common/checkerValue.js +328 -253
  8. package/dist/esm/common/index.js +2 -2
  9. package/dist/esm/common/proxyState.js +47 -47
  10. package/dist/esm/index.js +3 -3
  11. package/dist/esm/plugins/CalcPlugin.js +378 -302
  12. package/dist/esm/plugins/ControlsEventPlugin.js +141 -225
  13. package/dist/esm/plugins/ES6ModulePlugin.js +56 -38
  14. package/dist/esm/plugins/LifecycleEventPlugin.js +107 -190
  15. package/dist/esm/plugins/StylePlugin.js +31 -13
  16. package/dist/esm/plugins/index.js +5 -5
  17. package/dist/esm/utils/index.js +1 -1
  18. package/dist/esm/utils/runtimeUtils.js +7 -5
  19. package/dist/index.umd.js +8 -8
  20. package/dist/types/common/ActionManager.d.ts +14 -14
  21. package/dist/types/common/DataManager.d.ts +10 -10
  22. package/dist/types/common/Engine.d.ts +180 -180
  23. package/dist/types/common/OkWorker.d.ts +13 -13
  24. package/dist/types/common/Plugin.d.ts +6 -6
  25. package/dist/types/common/Runtime.d.ts +25 -25
  26. package/dist/types/common/Store.d.ts +49 -49
  27. package/dist/types/common/checkerValue.d.ts +3 -3
  28. package/dist/types/common/index.d.ts +2 -2
  29. package/dist/types/common/proxyState.d.ts +30 -30
  30. package/dist/types/index.d.ts +3 -3
  31. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  32. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
  33. package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -26
  34. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
  35. package/dist/types/plugins/StylePlugin.d.ts +12 -12
  36. package/dist/types/plugins/index.d.ts +5 -5
  37. package/dist/types/utils/index.d.ts +1 -1
  38. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  39. package/package.json +4 -4
@@ -3,87 +3,118 @@ function _classCallCheck(instance, Constructor) {
3
3
  throw new TypeError("Cannot call a class as a function");
4
4
  }
5
5
  }
6
- import { log } from "@byteluck-fe/model-driven-shared";
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 _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';
7
21
  var OkWorker = /*#__PURE__*/ function() {
8
22
  "use strict";
9
23
  function OkWorker() {
10
24
  _classCallCheck(this, OkWorker);
11
25
  }
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
- }
26
+ _createClass(OkWorker, [
27
+ {
28
+ key: "run",
29
+ value: function run(initState) {
30
+ this.worker = OkWorker.createWorker();
31
+ this.postMessage({
32
+ action: 'init',
33
+ payload: initState
83
34
  });
84
- });
85
- };
86
- };
35
+ }
36
+ },
37
+ {
38
+ key: "destroy",
39
+ value: function destroy() {
40
+ var ref;
41
+ (ref = this.worker) === null || ref === void 0 ? void 0 : ref.terminate();
42
+ }
43
+ },
44
+ {
45
+ key: "postMessage",
46
+ value: function postMessage(message) {
47
+ var ref;
48
+ (ref = this.worker) === null || ref === void 0 ? void 0 : ref.postMessage(message);
49
+ }
50
+ }
51
+ ], [
52
+ {
53
+ key: "createWorker",
54
+ value: function createWorker() {
55
+ var blob = new Blob([
56
+ "(".concat(OkWorker.createWorkerFunction().toString(), ")()")
57
+ ]);
58
+ var url = window.URL.createObjectURL(blob);
59
+ return new Worker(url);
60
+ }
61
+ },
62
+ {
63
+ key: "createWorkerFunction",
64
+ value: function createWorkerFunction() {
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
+ });
114
+ };
115
+ }
116
+ }
117
+ ]);
87
118
  return OkWorker;
88
119
  }();
89
120
  export { OkWorker };
@@ -83,17 +83,17 @@ function _createSuper(Derived) {
83
83
  return _possibleConstructorReturn(this, result);
84
84
  };
85
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) {
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(RegisterControls1) {
90
90
  "use strict";
91
- _inherits(Runtime, RegisterControls);
91
+ _inherits(Runtime, RegisterControls1);
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, "Runtime");
96
+ _this = _super.call(this, 'Runtime');
97
97
  _this._flatInstances = [];
98
98
  _this._instanceMap = {};
99
99
  var schema = props.schema;
@@ -102,26 +102,28 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
102
102
  _this.getFlatInstances();
103
103
  return _this;
104
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
105
  _createClass(Runtime, [
106
+ {
107
+ key: "getFlatInstances",
108
+ value: function getFlatInstances() {
109
+ var instances = [];
110
+ var instanceMap = {};
111
+ loop(this._instance, function(item) {
112
+ // 3.4.1 避免将subtable-row 放到 _flatInstances 中
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;
125
+ }
126
+ },
125
127
  {
126
128
  key: "schema",
127
129
  get: function get() {
@@ -247,7 +249,7 @@ item) {
247
249
  } else if (item.type === CONTROL_TYPE.SUBTABLE) {
248
250
  data[item.id] = item.rules;
249
251
  var itemRules = {
250
- type: "array",
252
+ type: 'array',
251
253
  fields: {}
252
254
  };
253
255
  item.children.forEach(function(row, index) {
@@ -255,7 +257,7 @@ item) {
255
257
  if (itemRules.fields) {
256
258
  if (!itemRules.fields[index]) {
257
259
  itemRules.fields[index] = {
258
- type: "object",
260
+ type: 'object',
259
261
  required: true,
260
262
  fields: {}
261
263
  };