@lowdefy/engine 3.22.0 → 4.0.0-alpha.1

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/Blocks.js CHANGED
@@ -1,625 +1,595 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
- var _Events = _interopRequireDefault(require("./Events"));
11
-
12
- var _getFieldValues = _interopRequireDefault(require("./getFieldValues"));
13
-
14
- var _excluded = ["blocks"];
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
-
22
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
-
24
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25
-
26
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
27
-
28
- class Blocks {
29
- constructor(_ref) {
30
- var {
31
- arrayIndices,
32
- areas,
33
- context
34
- } = _ref;
35
- this.id = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
36
- this.areas = _helpers.serializer.copy(areas || []);
37
- this.arrayIndices = _helpers.type.isArray(arrayIndices) ? arrayIndices : [];
38
- this.context = context;
39
- this.map = {};
40
- this.recCount = 0;
41
- this.subBlocks = {};
42
- this.generateBlockId = this.generateBlockId.bind(this);
43
- this.getValidateRec = this.getValidateRec.bind(this);
44
- this.init = this.init.bind(this);
45
- this.newBlocks = this.newBlocks.bind(this);
46
- this.recContainerDelState = this.recContainerDelState.bind(this);
47
- this.recEval = this.recEval.bind(this);
48
- this.recRemoveBlocksFromMap = this.recRemoveBlocksFromMap.bind(this);
49
- this.recSetUndefined = this.recSetUndefined.bind(this);
50
- this.recUpdateArrayIndices = this.recUpdateArrayIndices.bind(this);
51
- this.reset = this.reset.bind(this);
52
- this.resetValidation = this.resetValidation.bind(this);
53
- this.resetValidationRec = this.resetValidationRec.bind(this);
54
- this.setBlocksCache = this.setBlocksCache.bind(this);
55
- this.setBlocksLoadingCache = this.setBlocksLoadingCache.bind(this);
56
- this.update = this.update.bind(this);
57
- this.updateState = this.updateState.bind(this);
58
- this.updateStateFromRoot = this.updateStateFromRoot.bind(this);
59
- this.validate = this.validate.bind(this);
60
- }
61
-
62
- loopBlocks(fn) {
63
- if (_helpers.type.isObject(this.areas)) {
64
- Object.keys(this.areas).forEach(key => {
65
- if (_helpers.type.isArray(this.areas[key].blocks)) {
66
- this.areas[key].blocks.forEach(fn);
1
+ /* eslint-disable no-param-reassign */ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { applyArrayIndices, get, serializer, swap, type } from '@lowdefy/helpers';
16
+ import Events from './Events.js';
17
+ import getFieldValues from './getFieldValues.js';
18
+ let Blocks = class Blocks {
19
+ loopBlocks(fn) {
20
+ if (type.isObject(this.areas)) {
21
+ Object.keys(this.areas).forEach((key)=>{
22
+ if (type.isArray(this.areas[key].blocks)) {
23
+ this.areas[key].blocks.forEach(fn);
24
+ }
25
+ });
67
26
  }
68
- });
69
27
  }
70
- }
71
-
72
- init(initState) {
73
- this.loopBlocks(block => {
74
- block.blockIdPattern = block.blockId;
75
- block.id = this.generateBlockId(block.blockIdPattern);
76
- block.fieldPattern = block.field;
77
- block.blockId = (0, _helpers.applyArrayIndices)(this.arrayIndices, block.blockIdPattern);
78
- this.context.RootBlocks.map[block.blockId] = block;
79
- block.field = !_helpers.type.isNone(block.fieldPattern) ? (0, _helpers.applyArrayIndices)(this.arrayIndices, block.fieldPattern) : block.blockId;
80
- block.visible = _helpers.type.isNone(block.visible) ? true : block.visible;
81
- block.required = _helpers.type.isNone(block.required) ? false : block.required;
82
- block.validate = _helpers.type.isArray(block.validate) ? block.validate : [];
83
- block.properties = _helpers.type.isNone(block.properties) ? {} : block.properties;
84
- block.style = _helpers.type.isNone(block.style) ? {} : block.style;
85
- block.layout = _helpers.type.isNone(block.layout) ? {} : block.layout;
86
- block.events = _helpers.type.isNone(block.events) ? {} : block.events;
87
- block.areasLayoutEval = {};
88
- block.layoutEval = {};
89
- block.propertiesEval = {};
90
- block.requiredEval = {};
91
- block.styleEval = {};
92
- block.validationEval = {};
93
- block.visibleEval = {};
94
-
95
- if (!_helpers.type.isNone(block.areas)) {
96
- block.areasLayout = {};
97
- Object.keys(block.areas).forEach(key => {
98
- // eslint-disable-next-line no-unused-vars
99
- var _block$areas$key = block.areas[key],
100
- {
101
- blocks
102
- } = _block$areas$key,
103
- areaLayout = _objectWithoutProperties(_block$areas$key, _excluded);
104
-
105
- block.areasLayout[key] = _objectSpread({}, areaLayout);
106
- });
107
- } else {
108
- block.areasLayout = {};
109
- }
110
-
111
- block.requestKeys = (0, _getFieldValues.default)('_request', block.style, block.properties, block.validate, block.visible, block.required);
112
- block.methods = {};
113
-
114
- block.registerMethod = (methodName, method) => {
115
- block.methods[methodName] = method;
116
- }; // TODO: add callMethod on block to be used by actions and accessible in blocks
117
-
118
-
119
- if ((0, _helpers.get)(block, 'meta.category') === 'list') {
120
- // TODO: to initialize new object in array, the new value should be passed by method to unshiftItem and pushItem
121
- block.unshiftItem = () => {
122
- this.subBlocks[block.id].forEach((bl, i) => {
123
- bl.recUpdateArrayIndices(this.arrayIndices.concat([i]), this.arrayIndices.concat([i + 1]));
124
- });
125
- this.subBlocks[block.id].unshift(this.newBlocks({
126
- arrayIndices: this.arrayIndices.concat([0]),
127
- block,
128
- initState: {}
129
- }));
130
- this.context.State.set(block.field, undefined); // set block and subBlock values undefined, so as not to pass values to new blocks
131
-
132
- this.subBlocks[block.id][0].recSetUndefined();
133
- block.update = true;
134
- this.context.update();
135
- };
136
-
137
- block.pushItem = () => {
138
- this.subBlocks[block.id].push(this.newBlocks({
139
- arrayIndices: this.arrayIndices.concat([this.subBlocks[block.id].length]),
140
- block,
141
- initState: {}
142
- }));
143
- block.update = true;
144
- this.context.update();
145
- };
146
-
147
- block.removeItem = index => {
148
- this.context.State.removeItem(block.blockId, index);
149
- var lastBlock = this.subBlocks[block.id][this.subBlocks[block.id].length - 1];
150
- lastBlock.recRemoveBlocksFromMap();
151
- var largerBlocks = this.subBlocks[block.id].slice(index + 1);
152
- largerBlocks.forEach((bl, i) => {
153
- bl.recUpdateArrayIndices(this.arrayIndices.concat([index + i + 1]), this.arrayIndices.concat([index + i]));
154
- });
155
- this.subBlocks[block.id].splice(index, 1);
156
- block.update = true;
157
- this.context.update();
158
- };
159
-
160
- block.moveItemUp = index => {
161
- if (index === 0) return;
162
- this.context.State.swapItems(block.blockId, index - 1, index);
163
- this.subBlocks[block.id][index - 1].recUpdateArrayIndices(this.arrayIndices.concat([index - 1]), this.arrayIndices.concat([index]));
164
- this.subBlocks[block.id][index].recUpdateArrayIndices(this.arrayIndices.concat([index]), this.arrayIndices.concat([index - 1]));
165
- (0, _helpers.swap)(this.subBlocks[block.id], index - 1, index);
166
- block.update = true;
167
- this.context.update();
168
- };
169
-
170
- block.moveItemDown = index => {
171
- if (index === this.subBlocks[block.id].length - 1) return;
172
- this.context.State.swapItems(block.blockId, index, index + 1);
173
- this.subBlocks[block.id][index + 1].recUpdateArrayIndices(this.arrayIndices.concat([index + 1]), this.arrayIndices.concat([index]));
174
- this.subBlocks[block.id][index].recUpdateArrayIndices(this.arrayIndices.concat([index]), this.arrayIndices.concat([index + 1]));
175
- (0, _helpers.swap)(this.subBlocks[block.id], index, index + 1);
176
- block.update = true;
177
- this.context.update();
178
- };
179
- }
180
-
181
- if ((0, _helpers.get)(block, 'meta.category') === 'input') {
182
- block.setValue = value => {
183
- block.value = _helpers.type.enforceType(block.meta.valueType, value);
184
- this.context.State.set(block.field, block.value);
185
- block.update = true;
186
- this.context.update();
187
- };
188
- }
189
-
190
- block.Events = new _Events.default({
191
- arrayIndices: this.arrayIndices,
192
- block,
193
- context: this.context
194
- });
195
- block.triggerEvent = block.Events.triggerEvent;
196
- block.registerEvent = block.Events.registerEvent;
197
- });
198
- this.reset(initState); // set initial values to blocks.
199
- }
200
-
201
- reset(initWithState) {
202
- var initState = _helpers.serializer.copy(initWithState || this.context.state);
203
-
204
- this.loopBlocks(block => {
205
- block.update = true;
206
- block.showValidation = false;
207
-
208
- if ((0, _helpers.get)(block, 'meta.category') === 'input' || (0, _helpers.get)(block, 'meta.category') === 'list') {
209
- var blockValue = (0, _helpers.get)(initState, block.field);
210
-
211
- if (_helpers.type.isUndefined(blockValue)) {
212
- // default null value for block type
213
- blockValue = _helpers.type.isUndefined(block.meta.initValue) ? _helpers.type.enforceType(block.meta.valueType, null) : block.meta.initValue;
214
- this.context.State.set(block.field, block.value);
215
- }
216
-
217
- if ((0, _helpers.get)(block, 'meta.category') === 'list') {
218
- // load list value into list blocks
219
- if (!_helpers.type.isArray(this.subBlocks[block.id])) {
220
- this.subBlocks[block.id] = [];
221
- }
222
-
223
- if (_helpers.type.isArray(blockValue)) {
224
- blockValue.forEach((item, i) => {
225
- if (!this.subBlocks[block.id][i]) {
226
- this.subBlocks[block.id].push(this.newBlocks({
227
- arrayIndices: this.arrayIndices.concat([i]),
228
- block,
229
- initState
230
- }));
231
- } else {
232
- this.subBlocks[block.id][i].reset(initState);
233
- }
28
+ init(initState) {
29
+ this.loopBlocks((block)=>{
30
+ block.idPattern = block.id;
31
+ block.blockIdPattern = block.blockId;
32
+ block.fieldPattern = block.field;
33
+ block.id = applyArrayIndices(this.arrayIndices, block.idPattern);
34
+ block.blockId = applyArrayIndices(this.arrayIndices, block.blockIdPattern);
35
+ block.field = !type.isNone(block.fieldPattern) ? applyArrayIndices(this.arrayIndices, block.fieldPattern) : block.blockId;
36
+ this.context._internal.RootBlocks.map[block.id] = block;
37
+ block.visible = type.isNone(block.visible) ? true : block.visible;
38
+ block.required = type.isNone(block.required) ? false : block.required;
39
+ block.validate = type.isArray(block.validate) ? block.validate : [];
40
+ block.properties = type.isNone(block.properties) ? {
41
+ } : block.properties;
42
+ block.style = type.isNone(block.style) ? {
43
+ } : block.style;
44
+ block.layout = type.isNone(block.layout) ? {
45
+ } : block.layout;
46
+ block.events = type.isNone(block.events) ? {
47
+ } : block.events;
48
+ block.areasLayoutEval = {
49
+ };
50
+ block.layoutEval = {
51
+ };
52
+ block.propertiesEval = {
53
+ };
54
+ block.requiredEval = {
55
+ };
56
+ block.styleEval = {
57
+ };
58
+ block.validationEval = {
59
+ };
60
+ block.visibleEval = {
61
+ };
62
+ block.meta = this.context._internal.lowdefy._internal.blockComponents[block.type].meta;
63
+ if (!type.isNone(block.areas)) {
64
+ block.areasLayout = {
65
+ };
66
+ Object.keys(block.areas).forEach((key)=>{
67
+ // eslint-disable-next-line no-unused-vars
68
+ const { blocks , ...areaLayout } = block.areas[key];
69
+ block.areasLayout[key] = {
70
+ ...areaLayout
71
+ };
72
+ });
73
+ } else {
74
+ block.areasLayout = {
75
+ };
76
+ }
77
+ block.requestKeys = getFieldValues('_request', block.style, block.properties, block.validate, block.visible, block.required);
78
+ block.methods = {
79
+ };
80
+ block.registerMethod = (methodName, method)=>{
81
+ block.methods[methodName] = method;
82
+ };
83
+ // TODO: add callMethod on block to be used by actions and accessible in blocks
84
+ if (get(block, 'meta.category') === 'list') {
85
+ // TODO: to initialize new object in array, the new value should be passed by method to unshiftItem and pushItem
86
+ block.unshiftItem = ()=>{
87
+ this.subBlocks[block.id].forEach((bl, i)=>{
88
+ bl.recUpdateArrayIndices(this.arrayIndices.concat([
89
+ i
90
+ ]), this.arrayIndices.concat([
91
+ i + 1
92
+ ]));
93
+ });
94
+ this.subBlocks[block.id].unshift(this.newBlocks({
95
+ arrayIndices: this.arrayIndices.concat([
96
+ 0
97
+ ]),
98
+ block,
99
+ initState: {
100
+ }
101
+ }));
102
+ this.context._internal.State.set(block.field, undefined);
103
+ // set block and subBlock values undefined, so as not to pass values to new blocks
104
+ this.subBlocks[block.id][0].recSetUndefined();
105
+ block.update = true;
106
+ this.context._internal.update();
107
+ };
108
+ block.pushItem = ()=>{
109
+ this.subBlocks[block.id].push(this.newBlocks({
110
+ arrayIndices: this.arrayIndices.concat([
111
+ this.subBlocks[block.id].length
112
+ ]),
113
+ block,
114
+ initState: {
115
+ }
116
+ }));
117
+ block.update = true;
118
+ this.context._internal.update();
119
+ };
120
+ block.removeItem = (index)=>{
121
+ this.context._internal.State.removeItem(block.blockId, index);
122
+ const lastBlock = this.subBlocks[block.id][this.subBlocks[block.id].length - 1];
123
+ lastBlock.recRemoveBlocksFromMap();
124
+ const largerBlocks = this.subBlocks[block.id].slice(index + 1);
125
+ largerBlocks.forEach((bl, i)=>{
126
+ bl.recUpdateArrayIndices(this.arrayIndices.concat([
127
+ index + i + 1
128
+ ]), this.arrayIndices.concat([
129
+ index + i
130
+ ]));
131
+ });
132
+ this.subBlocks[block.id].splice(index, 1);
133
+ block.update = true;
134
+ this.context._internal.update();
135
+ };
136
+ block.moveItemUp = (index)=>{
137
+ if (index === 0) return;
138
+ this.context._internal.State.swapItems(block.blockId, index - 1, index);
139
+ this.subBlocks[block.id][index - 1].recUpdateArrayIndices(this.arrayIndices.concat([
140
+ index - 1
141
+ ]), this.arrayIndices.concat([
142
+ index
143
+ ]));
144
+ this.subBlocks[block.id][index].recUpdateArrayIndices(this.arrayIndices.concat([
145
+ index
146
+ ]), this.arrayIndices.concat([
147
+ index - 1
148
+ ]));
149
+ swap(this.subBlocks[block.id], index - 1, index);
150
+ block.update = true;
151
+ this.context._internal.update();
152
+ };
153
+ block.moveItemDown = (index)=>{
154
+ if (index === this.subBlocks[block.id].length - 1) return;
155
+ this.context._internal.State.swapItems(block.blockId, index, index + 1);
156
+ this.subBlocks[block.id][index + 1].recUpdateArrayIndices(this.arrayIndices.concat([
157
+ index + 1
158
+ ]), this.arrayIndices.concat([
159
+ index
160
+ ]));
161
+ this.subBlocks[block.id][index].recUpdateArrayIndices(this.arrayIndices.concat([
162
+ index
163
+ ]), this.arrayIndices.concat([
164
+ index + 1
165
+ ]));
166
+ swap(this.subBlocks[block.id], index, index + 1);
167
+ block.update = true;
168
+ this.context._internal.update();
169
+ };
170
+ }
171
+ if (get(block, 'meta.category') === 'input') {
172
+ block.setValue = (value)=>{
173
+ block.value = type.enforceType(block.meta.valueType, value);
174
+ this.context._internal.State.set(block.field, block.value);
175
+ block.update = true;
176
+ this.context._internal.update();
177
+ };
178
+ }
179
+ block.Events = new Events({
180
+ arrayIndices: this.arrayIndices,
181
+ block,
182
+ context: this.context
234
183
  });
235
- this.subBlocks[block.id].splice(blockValue.length);
236
- }
237
- } else {
238
- block.value = blockValue;
239
- }
240
- } else if ((0, _helpers.get)(block, 'meta.category') === 'container' || // do not make sub blocks for sub contexts
241
- (0, _helpers.get)(block, 'meta.category') === 'context' && this === this.context.RootBlocks) {
242
- if (!_helpers.type.isArray(this.subBlocks[block.id])) {
243
- this.subBlocks[block.id] = [];
244
- }
245
-
246
- if (!this.subBlocks[block.id][0]) {
247
- this.subBlocks[block.id].push(this.newBlocks({
248
- arrayIndices: this.arrayIndices,
249
- block,
250
- initState
251
- }));
252
- } else {
253
- this.subBlocks[block.id][0].reset(initState);
254
- }
255
- }
256
- });
257
- }
258
-
259
- newBlocks(_ref2) {
260
- var {
261
- arrayIndices,
262
- block,
263
- initState
264
- } = _ref2;
265
- var SubBlocks = new Blocks({
266
- arrayIndices,
267
- areas: block.areas,
268
- context: this.context
269
- });
270
- SubBlocks.init(initState);
271
- return SubBlocks;
272
- } // used for update comparison
273
-
274
-
275
- static blockEvalToString(block) {
276
- return _helpers.serializer.serializeToString({
277
- areasLayoutEval: block.areasLayoutEval,
278
- layoutEval: block.layoutEval,
279
- propertiesEval: block.propertiesEval,
280
- requiredEval: block.requiredEval,
281
- styleEval: block.styleEval,
282
- validationEval: block.validationEval,
283
- value: block.value,
284
- visibleEval: block.visibleEval
285
- });
286
- }
287
-
288
- recEval(visibleParent) {
289
- var repeat = false;
290
- this.loopBlocks(block => {
291
- if (block.meta.category === 'input') {
292
- var stateValue = (0, _helpers.get)(this.context.state, block.field); // TODO: related to #345
293
- // enforce type here? should we reassign value here??
294
-
295
- block.value = _helpers.type.isUndefined(stateValue) ? block.value : stateValue;
296
- }
297
-
298
- var beforeVisible = block.visibleEval ? block.visibleEval.output : true;
299
-
300
- if (visibleParent === false) {
301
- block.visibleEval.output = false;
302
- } else {
303
- block.visibleEval = this.context.parser.parse({
304
- input: block.visible,
305
- location: block.blockId,
306
- arrayIndices: this.arrayIndices
307
- }); // run parser on index combinations to get visible value object
308
- }
309
-
310
- if (beforeVisible !== block.visibleEval.output) {
311
- repeat = true;
312
- } // only evaluate visible blocks
313
-
314
-
315
- if (block.visibleEval.output !== false) {
316
- block.propertiesEval = this.context.parser.parse({
317
- input: block.properties,
318
- location: block.blockId,
319
- arrayIndices: this.arrayIndices
184
+ block.triggerEvent = block.Events.triggerEvent;
185
+ block.registerEvent = block.Events.registerEvent;
186
+ });
187
+ this.reset(initState); // set initial values to blocks.
188
+ }
189
+ reset(initWithState) {
190
+ const initState = serializer.copy(initWithState || this.context.state);
191
+ this.loopBlocks((block)=>{
192
+ block.update = true;
193
+ block.showValidation = false;
194
+ if (get(block, 'meta.category') === 'input' || get(block, 'meta.category') === 'list') {
195
+ let blockValue = get(initState, block.field);
196
+ if (type.isUndefined(blockValue)) {
197
+ // default null value for block type
198
+ blockValue = type.isUndefined(block.meta.initValue) ? type.enforceType(block.meta.valueType, null) : block.meta.initValue;
199
+ this.context._internal.State.set(block.field, block.value);
200
+ }
201
+ if (get(block, 'meta.category') === 'list') {
202
+ // load list value into list blocks
203
+ if (!type.isArray(this.subBlocks[block.id])) {
204
+ this.subBlocks[block.id] = [];
205
+ }
206
+ if (type.isArray(blockValue)) {
207
+ blockValue.forEach((item, i)=>{
208
+ if (!this.subBlocks[block.id][i]) {
209
+ this.subBlocks[block.id].push(this.newBlocks({
210
+ arrayIndices: this.arrayIndices.concat([
211
+ i
212
+ ]),
213
+ block,
214
+ initState
215
+ }));
216
+ } else {
217
+ this.subBlocks[block.id][i].reset(initState);
218
+ }
219
+ });
220
+ this.subBlocks[block.id].splice(blockValue.length);
221
+ }
222
+ } else {
223
+ block.value = blockValue;
224
+ }
225
+ } else if (get(block, 'meta.category') === 'container') {
226
+ if (!type.isArray(this.subBlocks[block.id])) {
227
+ this.subBlocks[block.id] = [];
228
+ }
229
+ if (!this.subBlocks[block.id][0]) {
230
+ this.subBlocks[block.id].push(this.newBlocks({
231
+ arrayIndices: this.arrayIndices,
232
+ block,
233
+ initState
234
+ }));
235
+ } else {
236
+ this.subBlocks[block.id][0].reset(initState);
237
+ }
238
+ }
320
239
  });
321
- block.requiredEval = this.context.parser.parse({
322
- input: block.required,
323
- location: block.blockId,
324
- arrayIndices: this.arrayIndices
240
+ }
241
+ newBlocks({ arrayIndices , block: block2 , initState: initState1 }) {
242
+ const SubBlocks = new Blocks({
243
+ arrayIndices,
244
+ areas: block2.areas,
245
+ context: this.context
246
+ });
247
+ SubBlocks.init(initState1);
248
+ return SubBlocks;
249
+ }
250
+ // used for update comparison
251
+ static blockEvalToString(block1) {
252
+ return serializer.serializeToString({
253
+ areasLayoutEval: block1.areasLayoutEval,
254
+ layoutEval: block1.layoutEval,
255
+ propertiesEval: block1.propertiesEval,
256
+ requiredEval: block1.requiredEval,
257
+ styleEval: block1.styleEval,
258
+ validationEval: block1.validationEval,
259
+ value: block1.value,
260
+ visibleEval: block1.visibleEval
325
261
  });
326
- var requiredValidation = {
327
- pass: {
328
- _not: {
329
- _type: 'none'
262
+ }
263
+ recEval(visibleParent) {
264
+ let repeat = false;
265
+ this.loopBlocks((block)=>{
266
+ if (block.meta.category === 'input') {
267
+ const stateValue = get(this.context.state, block.field);
268
+ // TODO: related to #345
269
+ // enforce type here? should we reassign value here??
270
+ block.value = type.isUndefined(stateValue) ? block.value : stateValue;
330
271
  }
331
- },
332
- status: 'error',
333
- message: _helpers.type.isString(block.requiredEval.output) ? block.requiredEval.output : 'This field is required'
334
- };
335
- var validation = block.required === false ? block.validate : [requiredValidation, ...block.validate];
336
- block.validationEval = {
337
- output: {
338
- status: null,
339
- errors: [],
340
- warnings: []
341
- },
342
- errors: []
343
- };
344
- var validationError = false;
345
- var validationWarning = false;
346
- validation.forEach(test => {
347
- var parsed = this.context.parser.parse({
348
- input: test,
349
- location: block.blockId,
350
- arrayIndices: this.arrayIndices
351
- }); // for parser errors
352
-
353
- if (parsed.errors.length > 0) {
354
- block.validationEval.output.errors.push(parsed.output.message);
355
- block.validationEval.errors.push(parsed.errors);
356
- validationError = true;
357
- return;
358
- } // failed validation
359
-
360
-
361
- if (!parsed.output.pass) {
362
- // no status indication on validation tests defaults to error
363
- if (!test.status || test.status === 'error') {
364
- block.validationEval.output.errors.push(parsed.output.message);
365
- validationError = true;
272
+ const beforeVisible = block.visibleEval ? block.visibleEval.output : true;
273
+ if (visibleParent === false) {
274
+ block.visibleEval.output = false;
275
+ } else {
276
+ block.visibleEval = this.context._internal.parser.parse({
277
+ input: block.visible,
278
+ location: block.blockId,
279
+ arrayIndices: this.arrayIndices
280
+ }); // run parser on index combinations to get visible value object
366
281
  }
367
-
368
- if (test.status === 'warning') {
369
- block.validationEval.output.warnings.push(parsed.output.message);
370
- validationWarning = true;
282
+ if (beforeVisible !== block.visibleEval.output) {
283
+ repeat = true;
284
+ }
285
+ // only evaluate visible blocks
286
+ if (block.visibleEval.output !== false) {
287
+ block.propertiesEval = this.context._internal.parser.parse({
288
+ input: block.properties,
289
+ location: block.blockId,
290
+ arrayIndices: this.arrayIndices
291
+ });
292
+ block.requiredEval = this.context._internal.parser.parse({
293
+ input: block.required,
294
+ location: block.blockId,
295
+ arrayIndices: this.arrayIndices
296
+ });
297
+ const requiredValidation = {
298
+ pass: {
299
+ _not: {
300
+ _type: 'none'
301
+ }
302
+ },
303
+ status: 'error',
304
+ message: type.isString(block.requiredEval.output) ? block.requiredEval.output : 'This field is required'
305
+ };
306
+ const validation = block.required === false ? block.validate : [
307
+ requiredValidation,
308
+ ...block.validate
309
+ ];
310
+ block.validationEval = {
311
+ output: {
312
+ status: null,
313
+ errors: [],
314
+ warnings: []
315
+ },
316
+ errors: []
317
+ };
318
+ let validationError = false;
319
+ let validationWarning = false;
320
+ validation.forEach((test)=>{
321
+ const parsed = this.context._internal.parser.parse({
322
+ input: test,
323
+ location: block.blockId,
324
+ arrayIndices: this.arrayIndices
325
+ });
326
+ // for parser errors
327
+ if (parsed.errors.length > 0) {
328
+ block.validationEval.output.errors.push(parsed.output.message);
329
+ block.validationEval.errors.push(parsed.errors);
330
+ validationError = true;
331
+ return;
332
+ }
333
+ // failed validation
334
+ if (!parsed.output.pass) {
335
+ // no status indication on validation tests defaults to error
336
+ if (!test.status || test.status === 'error') {
337
+ block.validationEval.output.errors.push(parsed.output.message);
338
+ validationError = true;
339
+ }
340
+ if (test.status === 'warning') {
341
+ block.validationEval.output.warnings.push(parsed.output.message);
342
+ validationWarning = true;
343
+ }
344
+ }
345
+ });
346
+ if (validation.length > 0) {
347
+ block.validationEval.output.status = 'success';
348
+ }
349
+ if (validationWarning) {
350
+ block.validationEval.output.status = 'warning';
351
+ }
352
+ if (validationError) {
353
+ block.validationEval.output.status = 'error';
354
+ }
355
+ block.styleEval = this.context._internal.parser.parse({
356
+ input: block.style,
357
+ location: block.blockId,
358
+ arrayIndices: this.arrayIndices
359
+ });
360
+ block.layoutEval = this.context._internal.parser.parse({
361
+ input: block.layout,
362
+ location: block.blockId,
363
+ arrayIndices: this.arrayIndices
364
+ });
365
+ block.areasLayoutEval = this.context._internal.parser.parse({
366
+ input: block.areasLayout,
367
+ location: block.blockId,
368
+ arrayIndices: this.arrayIndices
369
+ });
370
+ }
371
+ if (get(block, 'meta.category') === 'container' || get(block, 'meta.category') === 'list') {
372
+ if (this.subBlocks[block.id] && this.subBlocks[block.id].length > 0) {
373
+ this.subBlocks[block.id].forEach((blockClass)=>{
374
+ repeat = blockClass.recEval(block.visibleEval.output) || repeat;
375
+ });
376
+ }
377
+ }
378
+ const after = Blocks.blockEvalToString(block);
379
+ if (block.before !== after) {
380
+ block.update = true;
381
+ block.before = after;
371
382
  }
372
- }
373
383
  });
374
-
375
- if (validation.length > 0) {
376
- block.validationEval.output.status = 'success';
377
- }
378
-
379
- if (validationWarning) {
380
- block.validationEval.output.status = 'warning';
381
- }
382
-
383
- if (validationError) {
384
- block.validationEval.output.status = 'error';
385
- }
386
-
387
- block.styleEval = this.context.parser.parse({
388
- input: block.style,
389
- location: block.blockId,
390
- arrayIndices: this.arrayIndices
384
+ return repeat;
385
+ }
386
+ updateState() {
387
+ const toSet = new Set();
388
+ const toDelete = new Set();
389
+ this.loopBlocks((block)=>{
390
+ if (block.visibleEval.output !== false) {
391
+ if (get(block, 'meta.category') === 'container' || get(block, 'meta.category') === 'list') {
392
+ if (this.subBlocks[block.id] && this.subBlocks[block.id].length > 0) {
393
+ this.subBlocks[block.id].forEach((blockClass)=>{
394
+ blockClass.updateState();
395
+ });
396
+ } else {
397
+ toSet.add(block.field);
398
+ this.context._internal.State.set(block.field, type.enforceType(block.meta.valueType, null));
399
+ }
400
+ } else if (get(block, 'meta.category') === 'input') {
401
+ toSet.add(block.field);
402
+ this.context._internal.State.set(block.field, block.value);
403
+ }
404
+ } else if (get(block, 'meta.category') === 'container') {
405
+ this.subBlocks[block.id].forEach((blockClass)=>{
406
+ blockClass.recContainerDelState(toDelete);
407
+ });
408
+ } else {
409
+ toDelete.add(block.field);
410
+ }
391
411
  });
392
- block.layoutEval = this.context.parser.parse({
393
- input: block.layout,
394
- location: block.blockId,
395
- arrayIndices: this.arrayIndices
412
+ toDelete.forEach((field)=>{
413
+ if (!toSet.has(field)) {
414
+ this.context._internal.State.del(field);
415
+ }
396
416
  });
397
- block.areasLayoutEval = this.context.parser.parse({
398
- input: block.areasLayout,
399
- location: block.blockId,
400
- arrayIndices: this.arrayIndices
417
+ }
418
+ recContainerDelState(toDelete) {
419
+ this.loopBlocks((block)=>{
420
+ if (get(block, 'meta.category') === 'container') {
421
+ this.subBlocks[block.id].forEach((blockClass)=>{
422
+ blockClass.recContainerDelState(toDelete);
423
+ });
424
+ } else {
425
+ toDelete.add(block.field);
426
+ }
401
427
  });
402
- }
403
-
404
- if ((0, _helpers.get)(block, 'meta.category') === 'container' || (0, _helpers.get)(block, 'meta.category') === 'context' || (0, _helpers.get)(block, 'meta.category') === 'list') {
405
- if (this.subBlocks[block.id] && this.subBlocks[block.id].length > 0) {
406
- this.subBlocks[block.id].forEach(blockClass => {
407
- repeat = blockClass.recEval(block.visibleEval.output) || repeat;
408
- });
428
+ }
429
+ updateStateFromRoot() {
430
+ const repeat = this.recEval(true);
431
+ this.updateState();
432
+ if (repeat && this.recCount < 20) {
433
+ this.recCount += 1;
434
+ this.updateStateFromRoot();
409
435
  }
410
- }
411
-
412
- var after = Blocks.blockEvalToString(block);
413
-
414
- if (block.before !== after) {
415
- block.update = true;
416
- block.before = after;
417
- }
418
- });
419
- return repeat;
420
- }
421
-
422
- updateState() {
423
- var toSet = new Set();
424
- var toDelete = new Set();
425
- this.loopBlocks(block => {
426
- if (block.visibleEval.output !== false) {
427
- if ((0, _helpers.get)(block, 'meta.category') === 'container' || (0, _helpers.get)(block, 'meta.category') === 'context' || (0, _helpers.get)(block, 'meta.category') === 'list') {
428
- if (this.subBlocks[block.id] && this.subBlocks[block.id].length > 0) {
429
- this.subBlocks[block.id].forEach(blockClass => {
430
- blockClass.updateState();
436
+ this.recCount = 0;
437
+ }
438
+ recUpdateArrayIndices(oldIndices, newIndices) {
439
+ newIndices.forEach((index, i)=>{
440
+ this.arrayIndices[i] = newIndices[i];
441
+ });
442
+ this.loopBlocks((block)=>{
443
+ block.blockId = applyArrayIndices(this.arrayIndices, block.blockIdPattern);
444
+ this.context._internal.RootBlocks.map[block.blockId] = block;
445
+ block.field = !type.isNone(block.fieldPattern) ? applyArrayIndices(this.arrayIndices, block.fieldPattern) : block.blockId;
446
+ });
447
+ Object.keys(this.subBlocks).forEach((subKey)=>{
448
+ this.subBlocks[subKey].forEach((subBlock)=>{
449
+ subBlock.recUpdateArrayIndices(oldIndices, newIndices);
431
450
  });
432
- } else {
433
- toSet.add(block.field);
434
- this.context.State.set(block.field, _helpers.type.enforceType(block.meta.valueType, null));
435
- }
436
- } else if ((0, _helpers.get)(block, 'meta.category') === 'input') {
437
- toSet.add(block.field);
438
- this.context.State.set(block.field, block.value);
439
- }
440
- } else if ((0, _helpers.get)(block, 'meta.category') === 'container' || (0, _helpers.get)(block, 'meta.category') === 'context') {
441
- this.subBlocks[block.id].forEach(blockClass => {
442
- blockClass.recContainerDelState(toDelete);
443
451
  });
444
- } else {
445
- toDelete.add(block.field);
446
- }
447
- });
448
- toDelete.forEach(field => {
449
- if (!toSet.has(field)) {
450
- this.context.State.del(field);
451
- }
452
- });
453
- }
454
-
455
- recContainerDelState(toDelete) {
456
- this.loopBlocks(block => {
457
- if ((0, _helpers.get)(block, 'meta.category') === 'container' || (0, _helpers.get)(block, 'meta.category') === 'context') {
458
- this.subBlocks[block.id].forEach(blockClass => {
459
- blockClass.recContainerDelState(toDelete);
452
+ }
453
+ getValidateRec(match, result) {
454
+ this.loopBlocks((block)=>{
455
+ if (match(block.blockId)) {
456
+ block.showValidation = true;
457
+ block.update = true;
458
+ if (block.visibleEval.output !== false && block.validationEval.output && block.validationEval.output.status === 'error') {
459
+ result.push({
460
+ blockId: block.blockId,
461
+ validation: block.validationEval.output
462
+ });
463
+ }
464
+ }
460
465
  });
461
- } else {
462
- toDelete.add(block.field);
463
- }
464
- });
465
- }
466
-
467
- updateStateFromRoot() {
468
- var repeat = this.recEval(true);
469
- this.updateState();
470
-
471
- if (repeat && this.recCount < 20) {
472
- this.recCount += 1;
473
- this.updateStateFromRoot();
466
+ Object.keys(this.subBlocks).forEach((subKey)=>{
467
+ this.subBlocks[subKey].forEach((subBlock)=>{
468
+ subBlock.getValidateRec(match, result);
469
+ });
470
+ });
471
+ return result;
474
472
  }
475
-
476
- this.recCount = 0;
477
- }
478
-
479
- recUpdateArrayIndices(oldIndices, newIndices) {
480
- newIndices.forEach((index, i) => {
481
- this.arrayIndices[i] = newIndices[i];
482
- });
483
- this.loopBlocks(block => {
484
- block.blockId = (0, _helpers.applyArrayIndices)(this.arrayIndices, block.blockIdPattern);
485
- this.context.RootBlocks.map[block.blockId] = block;
486
- block.field = !_helpers.type.isNone(block.fieldPattern) ? (0, _helpers.applyArrayIndices)(this.arrayIndices, block.fieldPattern) : block.blockId;
487
- });
488
- Object.keys(this.subBlocks).forEach(subKey => {
489
- this.subBlocks[subKey].forEach(subBlock => {
490
- subBlock.recUpdateArrayIndices(oldIndices, newIndices);
491
- });
492
- });
493
- }
494
-
495
- getValidateRec(match, result) {
496
- this.loopBlocks(block => {
497
- if (match(block.blockId)) {
498
- block.showValidation = true;
499
- block.update = true;
500
-
501
- if (block.visibleEval.output !== false && block.validationEval.output && block.validationEval.output.status === 'error') {
502
- result.push({
503
- blockId: block.blockId,
504
- validation: block.validationEval.output
505
- });
506
- }
507
- }
508
- });
509
- Object.keys(this.subBlocks).forEach(subKey => {
510
- this.subBlocks[subKey].forEach(subBlock => {
511
- subBlock.getValidateRec(match, result);
512
- });
513
- });
514
- return result;
515
- }
516
-
517
- recSetUndefined() {
518
- this.loopBlocks(block => {
519
- this.context.State.set(block.field, undefined);
520
- });
521
- Object.keys(this.subBlocks).forEach(subKey => {
522
- this.subBlocks[subKey].forEach(subBlock => {
523
- subBlock.recSetUndefined();
524
- });
525
- });
526
- }
527
-
528
- recRemoveBlocksFromMap() {
529
- this.loopBlocks(block => {
530
- delete this.context.RootBlocks.map[block.blockId];
531
- });
532
- Object.keys(this.subBlocks).forEach(subKey => {
533
- this.subBlocks[subKey].forEach(subBlock => {
534
- subBlock.recRemoveBlocksFromMap();
535
- });
536
- });
537
- }
538
-
539
- validate(match) {
540
- this.updateStateFromRoot(); // update to recalculate validationEval to raise block errors
541
-
542
- var validationErrors = this.getValidateRec(match, []); // get all relevant raised block errors and set showValidation
543
-
544
- this.setBlocksCache(); // update cache to render
545
-
546
- return validationErrors;
547
- }
548
-
549
- resetValidationRec(match) {
550
- this.loopBlocks(block => {
551
- if (match(block.blockId)) {
552
- block.showValidation = false;
553
- block.update = true;
554
- }
555
- });
556
- Object.keys(this.subBlocks).forEach(subKey => {
557
- this.subBlocks[subKey].forEach(subBlock => {
558
- subBlock.resetValidationRec(match);
559
- });
560
- });
561
- }
562
-
563
- resetValidation(match) {
564
- this.resetValidationRec(match);
565
- this.setBlocksCache();
566
- }
567
-
568
- update() {
569
- this.updateStateFromRoot(); // update all the blocks
570
-
571
- this.setBlocksCache(); // finally update cache
572
- }
573
-
574
- setBlocksCache() {
575
- this.loopBlocks(block => {
576
- if (block.update) {
577
- block.update = false;
578
- block.loading = block.requestKeys.reduce((acc, key) => acc || (this.context.requests[key] ? this.context.requests[key].loading : true), false);
579
- block.eval = {
580
- areas: block.areasLayoutEval.output,
581
- events: _helpers.type.isNone(block.Events.events) ? null : block.Events.events,
582
- properties: block.propertiesEval.output,
583
- required: block.requiredEval.output,
584
- layout: block.layoutEval.output,
585
- style: block.styleEval.output,
586
- validation: _objectSpread(_objectSpread({}, block.validationEval.output || {}), {}, {
587
- status: block.showValidation ? (block.validationEval.output || {}).status : null
588
- }),
589
- value: _helpers.type.isNone(block.value) ? null : block.value,
590
- visible: block.visibleEval.output
473
+ recSetUndefined() {
474
+ this.loopBlocks((block)=>{
475
+ this.context._internal.State.set(block.field, undefined);
476
+ });
477
+ Object.keys(this.subBlocks).forEach((subKey)=>{
478
+ this.subBlocks[subKey].forEach((subBlock)=>{
479
+ subBlock.recSetUndefined();
480
+ });
481
+ });
482
+ }
483
+ recRemoveBlocksFromMap() {
484
+ this.loopBlocks((block)=>{
485
+ delete this.context._internal.RootBlocks.map[block.blockId];
486
+ });
487
+ Object.keys(this.subBlocks).forEach((subKey)=>{
488
+ this.subBlocks[subKey].forEach((subBlock)=>{
489
+ subBlock.recRemoveBlocksFromMap();
490
+ });
491
+ });
492
+ }
493
+ validate(match1) {
494
+ this.updateStateFromRoot(); // update to recalculate validationEval to raise block errors
495
+ const validationErrors = this.getValidateRec(match1, []); // get all relevant raised block errors and set showValidation
496
+ this.setBlocksCache(); // update cache to render
497
+ return validationErrors;
498
+ }
499
+ resetValidationRec(match2) {
500
+ this.loopBlocks((block)=>{
501
+ if (match2(block.blockId)) {
502
+ block.showValidation = false;
503
+ block.update = true;
504
+ }
505
+ });
506
+ Object.keys(this.subBlocks).forEach((subKey)=>{
507
+ this.subBlocks[subKey].forEach((subBlock)=>{
508
+ subBlock.resetValidationRec(match2);
509
+ });
510
+ });
511
+ }
512
+ resetValidation(match3) {
513
+ this.resetValidationRec(match3);
514
+ this.setBlocksCache();
515
+ }
516
+ update() {
517
+ this.updateStateFromRoot(); // update all the blocks
518
+ this.setBlocksCache(); // finally update cache
519
+ }
520
+ setBlocksCache() {
521
+ this.loopBlocks((block)=>{
522
+ if (block.update) {
523
+ block.update = false;
524
+ block.loading = block.requestKeys.reduce((acc, key)=>acc || (this.context.requests[key] ? this.context.requests[key].loading : true)
525
+ , false);
526
+ block.eval = {
527
+ areas: block.areasLayoutEval.output,
528
+ events: type.isNone(block.Events.events) ? null : block.Events.events,
529
+ properties: block.propertiesEval.output,
530
+ required: block.requiredEval.output,
531
+ layout: block.layoutEval.output,
532
+ style: block.styleEval.output,
533
+ validation: {
534
+ ...block.validationEval.output || {
535
+ },
536
+ status: block.showValidation ? (block.validationEval.output || {
537
+ }).status : null
538
+ },
539
+ value: type.isNone(block.value) ? null : block.value,
540
+ visible: block.visibleEval.output
541
+ };
542
+ this.context._internal.lowdefy._internal.updateBlock(block.id);
543
+ }
544
+ });
545
+ Object.keys(this.subBlocks).forEach((subKey)=>{
546
+ this.subBlocks[subKey].forEach((subBlock)=>{
547
+ subBlock.setBlocksCache();
548
+ });
549
+ });
550
+ }
551
+ setBlocksLoadingCache() {
552
+ this.loopBlocks((block)=>{
553
+ block.loading_prev = block.loading;
554
+ block.loading = block.requestKeys.reduce((acc, key)=>acc || (this.context.requests[key] ? this.context.requests[key].loading : true)
555
+ , false);
556
+ if (block.loading_prev !== block.loading) {
557
+ this.context._internal.lowdefy._internal.updateBlock(block.id);
558
+ }
559
+ });
560
+ Object.keys(this.subBlocks).forEach((subKey)=>{
561
+ this.subBlocks[subKey].forEach((subBlock)=>{
562
+ subBlock.setBlocksLoadingCache();
563
+ });
564
+ });
565
+ }
566
+ constructor({ arrayIndices: arrayIndices1 , areas , context }){
567
+ this.id = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
568
+ this.areas = serializer.copy(areas || []);
569
+ this.arrayIndices = type.isArray(arrayIndices1) ? arrayIndices1 : [];
570
+ this.context = context;
571
+ this.map = {
591
572
  };
592
- this.context.lowdefy.updateBlock(block.id);
593
- }
594
- });
595
- Object.keys(this.subBlocks).forEach(subKey => {
596
- this.subBlocks[subKey].forEach(subBlock => {
597
- subBlock.setBlocksCache();
598
- });
599
- });
600
- }
601
-
602
- setBlocksLoadingCache() {
603
- this.loopBlocks(block => {
604
- block.loading_prev = block.loading;
605
- block.loading = block.requestKeys.reduce((acc, key) => acc || (this.context.requests[key] ? this.context.requests[key].loading : true), false);
606
-
607
- if (block.loading_prev !== block.loading) {
608
- this.context.lowdefy.updateBlock(block.id);
609
- }
610
- });
611
- Object.keys(this.subBlocks).forEach(subKey => {
612
- this.subBlocks[subKey].forEach(subBlock => {
613
- subBlock.setBlocksLoadingCache();
614
- });
615
- });
616
- }
617
-
618
- generateBlockId(blockIdPattern) {
619
- return "".concat(this.context.pageId, ":").concat(blockIdPattern, ":").concat(Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5));
620
- }
621
-
622
- }
623
-
624
- var _default = Blocks;
625
- exports.default = _default;
573
+ this.recCount = 0;
574
+ this.subBlocks = {
575
+ };
576
+ this.getValidateRec = this.getValidateRec.bind(this);
577
+ this.init = this.init.bind(this);
578
+ this.newBlocks = this.newBlocks.bind(this);
579
+ this.recContainerDelState = this.recContainerDelState.bind(this);
580
+ this.recEval = this.recEval.bind(this);
581
+ this.recRemoveBlocksFromMap = this.recRemoveBlocksFromMap.bind(this);
582
+ this.recSetUndefined = this.recSetUndefined.bind(this);
583
+ this.recUpdateArrayIndices = this.recUpdateArrayIndices.bind(this);
584
+ this.reset = this.reset.bind(this);
585
+ this.resetValidation = this.resetValidation.bind(this);
586
+ this.resetValidationRec = this.resetValidationRec.bind(this);
587
+ this.setBlocksCache = this.setBlocksCache.bind(this);
588
+ this.setBlocksLoadingCache = this.setBlocksLoadingCache.bind(this);
589
+ this.update = this.update.bind(this);
590
+ this.updateState = this.updateState.bind(this);
591
+ this.updateStateFromRoot = this.updateStateFromRoot.bind(this);
592
+ this.validate = this.validate.bind(this);
593
+ }
594
+ };
595
+ export default Blocks;