@lowdefy/engine 4.0.0-alpha.5 → 4.0.0-alpha.6

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/Actions.js CHANGED
@@ -31,31 +31,31 @@ let Actions = class Actions {
31
31
  console.error(error);
32
32
  }
33
33
  }
34
- async callActionLoop({ actions: actions1 , arrayIndices: arrayIndices1 , block: block1 , event: event1 , responses: responses1 }) {
34
+ async callActionLoop({ actions: actions1 , arrayIndices , block , event , responses }) {
35
35
  for (const [index, action] of actions1.entries()){
36
36
  try {
37
37
  if (action.async === true) {
38
38
  this.callAsyncAction({
39
39
  action,
40
- arrayIndices: arrayIndices1,
41
- block: block1,
42
- event: event1,
40
+ arrayIndices,
41
+ block,
42
+ event,
43
43
  index,
44
- responses: responses1
44
+ responses
45
45
  });
46
46
  } else {
47
47
  const response = await this.callAction({
48
48
  action,
49
- arrayIndices: arrayIndices1,
50
- block: block1,
51
- event: event1,
49
+ arrayIndices,
50
+ block,
51
+ event,
52
52
  index,
53
- responses: responses1
53
+ responses
54
54
  });
55
- responses1[action.id] = response;
55
+ responses[action.id] = response;
56
56
  }
57
57
  } catch (error) {
58
- responses1[action.id] = error;
58
+ responses[action.id] = error;
59
59
  throw {
60
60
  error,
61
61
  action
@@ -63,16 +63,15 @@ let Actions = class Actions {
63
63
  }
64
64
  }
65
65
  }
66
- async callActions({ actions: actions2 , arrayIndices: arrayIndices2 , block: block2 , catchActions , event: event2 , eventName }) {
66
+ async callActions({ actions: actions2 , arrayIndices , block , catchActions , event , eventName }) {
67
67
  const startTimestamp = new Date();
68
- const responses = {
69
- };
68
+ const responses = {};
70
69
  try {
71
70
  await this.callActionLoop({
72
71
  actions: actions2,
73
- arrayIndices: arrayIndices2,
74
- block: block2,
75
- event: event2,
72
+ arrayIndices,
73
+ block,
74
+ event,
76
75
  responses
77
76
  });
78
77
  } catch (error) {
@@ -80,20 +79,20 @@ let Actions = class Actions {
80
79
  try {
81
80
  await this.callActionLoop({
82
81
  actions: catchActions,
83
- arrayIndices: arrayIndices2,
84
- block: block2,
85
- event: event2,
82
+ arrayIndices,
83
+ block,
84
+ event,
86
85
  responses
87
86
  });
88
87
  } catch (errorCatch) {
89
88
  console.error(errorCatch);
90
89
  return {
91
- blockId: block2.blockId,
90
+ blockId: block.blockId,
92
91
  bounced: false,
93
92
  endTimestamp: new Date(),
94
93
  error,
95
94
  errorCatch,
96
- event: event2,
95
+ event,
97
96
  eventName,
98
97
  responses,
99
98
  startTimestamp,
@@ -101,11 +100,11 @@ let Actions = class Actions {
101
100
  };
102
101
  }
103
102
  return {
104
- blockId: block2.blockId,
103
+ blockId: block.blockId,
105
104
  bounced: false,
106
105
  endTimestamp: new Date(),
107
106
  error,
108
- event: event2,
107
+ event,
109
108
  eventName,
110
109
  responses,
111
110
  startTimestamp,
@@ -113,47 +112,46 @@ let Actions = class Actions {
113
112
  };
114
113
  }
115
114
  return {
116
- blockId: block2.blockId,
115
+ blockId: block.blockId,
117
116
  bounced: false,
118
117
  endTimestamp: new Date(),
119
- event: event2,
118
+ event,
120
119
  eventName,
121
120
  responses,
122
121
  startTimestamp,
123
122
  success: true
124
123
  };
125
124
  }
126
- async callAction({ action: action1 , arrayIndices: arrayIndices3 , block: block3 , event: event3 , index: index1 , responses: responses2 }) {
127
- if (!actions[action1.type]) {
125
+ async callAction({ action , arrayIndices , block , event , index , responses }) {
126
+ if (!actions[action.type]) {
128
127
  throw {
129
- error: new Error(`Invalid action type "${action1.type}" at "${block3.blockId}".`),
130
- type: action1.type,
131
- index: index1
128
+ error: new Error(`Invalid action type "${action.type}" at "${block.blockId}".`),
129
+ type: action.type,
130
+ index
132
131
  };
133
132
  }
134
133
  const { output: parsedAction , errors: parserErrors } = this.context._internal.parser.parse({
135
- actions: responses2,
136
- event: event3,
137
- arrayIndices: arrayIndices3,
138
- input: action1,
139
- location: block3.blockId
134
+ actions: responses,
135
+ event,
136
+ arrayIndices,
137
+ input: action,
138
+ location: block.blockId
140
139
  });
141
140
  if (parserErrors.length > 0) {
142
141
  throw {
143
142
  error: parserErrors[0],
144
- type: action1.type,
145
- index: index1
143
+ type: action.type,
144
+ index
146
145
  };
147
146
  }
148
147
  if (parsedAction.skip === true) {
149
148
  return {
150
- type: action1.type,
149
+ type: action.type,
151
150
  skipped: true,
152
- index: index1
151
+ index
153
152
  };
154
153
  }
155
- const messages = parsedAction.messages || {
156
- };
154
+ const messages = parsedAction.messages || {};
157
155
  let response;
158
156
  const closeLoading = this.displayMessage({
159
157
  defaultMessage: 'Loading',
@@ -162,32 +160,32 @@ let Actions = class Actions {
162
160
  status: 'loading'
163
161
  });
164
162
  try {
165
- response = await actions[action1.type]({
166
- arrayIndices: arrayIndices3,
167
- blockId: block3.blockId,
163
+ response = await actions[action.type]({
164
+ arrayIndices,
165
+ blockId: block.blockId,
168
166
  context: this.context,
169
- event: event3,
167
+ event,
170
168
  params: parsedAction.params
171
169
  });
172
170
  } catch (error) {
173
- responses2[action1.id] = {
171
+ responses[action.id] = {
174
172
  error,
175
- index: index1,
176
- type: action1.type
173
+ index,
174
+ type: action.type
177
175
  };
178
176
  const { output: parsedMessages , errors: parserErrors } = this.context._internal.parser.parse({
179
- actions: responses2,
180
- event: event3,
181
- arrayIndices: arrayIndices3,
182
- input: action1.messages,
183
- location: block3.blockId
177
+ actions: responses,
178
+ event,
179
+ arrayIndices,
180
+ input: action.messages,
181
+ location: block.blockId
184
182
  });
185
183
  if (parserErrors.length > 0) {
186
184
  // this condition is very unlikely since parser errors usually occur in the first parse.
187
185
  throw {
188
186
  error: parserErrors[0],
189
- type: action1.type,
190
- index: index1
187
+ type: action.type,
188
+ index
191
189
  };
192
190
  }
193
191
  closeLoading();
@@ -195,14 +193,13 @@ let Actions = class Actions {
195
193
  defaultMessage: error.message,
196
194
  duration: 6,
197
195
  hideExplicitly: true,
198
- message: (parsedMessages || {
199
- }).error,
196
+ message: (parsedMessages || {}).error,
200
197
  status: 'error'
201
198
  });
202
199
  throw {
203
- type: action1.type,
200
+ type: action.type,
204
201
  error,
205
- index: index1
202
+ index
206
203
  };
207
204
  }
208
205
  closeLoading();
@@ -212,9 +209,9 @@ let Actions = class Actions {
212
209
  status: 'success'
213
210
  });
214
211
  return {
215
- type: action1.type,
212
+ type: action.type,
216
213
  response,
217
- index: index1
214
+ index
218
215
  };
219
216
  }
220
217
  displayMessage({ defaultMessage , duration , hideExplicitly , message , status }) {
package/dist/Blocks.js CHANGED
@@ -37,32 +37,20 @@ let Blocks = class Blocks {
37
37
  block.visible = type.isNone(block.visible) ? true : block.visible;
38
38
  block.required = type.isNone(block.required) ? false : block.required;
39
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
- };
40
+ block.properties = type.isNone(block.properties) ? {} : block.properties;
41
+ block.style = type.isNone(block.style) ? {} : block.style;
42
+ block.layout = type.isNone(block.layout) ? {} : block.layout;
43
+ block.events = type.isNone(block.events) ? {} : block.events;
44
+ block.areasLayoutEval = {};
45
+ block.layoutEval = {};
46
+ block.propertiesEval = {};
47
+ block.requiredEval = {};
48
+ block.styleEval = {};
49
+ block.validationEval = {};
50
+ block.visibleEval = {};
62
51
  block.meta = this.context._internal.lowdefy._internal.blockComponents[block.type].meta;
63
52
  if (!type.isNone(block.areas)) {
64
- block.areasLayout = {
65
- };
53
+ block.areasLayout = {};
66
54
  Object.keys(block.areas).forEach((key)=>{
67
55
  // eslint-disable-next-line no-unused-vars
68
56
  const { blocks , ...areaLayout } = block.areas[key];
@@ -71,12 +59,10 @@ let Blocks = class Blocks {
71
59
  };
72
60
  });
73
61
  } else {
74
- block.areasLayout = {
75
- };
62
+ block.areasLayout = {};
76
63
  }
77
64
  block.requestKeys = getFieldValues('_request', block.style, block.properties, block.validate, block.visible, block.required);
78
- block.methods = {
79
- };
65
+ block.methods = {};
80
66
  block.registerMethod = (methodName, method)=>{
81
67
  block.methods[methodName] = method;
82
68
  };
@@ -96,8 +82,7 @@ let Blocks = class Blocks {
96
82
  0
97
83
  ]),
98
84
  block,
99
- initState: {
100
- }
85
+ initState: {}
101
86
  }));
102
87
  this.context._internal.State.set(block.field, undefined);
103
88
  // set block and subBlock values undefined, so as not to pass values to new blocks
@@ -111,8 +96,7 @@ let Blocks = class Blocks {
111
96
  this.subBlocks[block.id].length
112
97
  ]),
113
98
  block,
114
- initState: {
115
- }
99
+ initState: {}
116
100
  }));
117
101
  block.update = true;
118
102
  this.context._internal.update();
@@ -238,26 +222,26 @@ let Blocks = class Blocks {
238
222
  }
239
223
  });
240
224
  }
241
- newBlocks({ arrayIndices , block: block2 , initState: initState1 }) {
225
+ newBlocks({ arrayIndices , block , initState }) {
242
226
  const SubBlocks = new Blocks({
243
227
  arrayIndices,
244
- areas: block2.areas,
228
+ areas: block.areas,
245
229
  context: this.context
246
230
  });
247
- SubBlocks.init(initState1);
231
+ SubBlocks.init(initState);
248
232
  return SubBlocks;
249
233
  }
250
234
  // used for update comparison
251
- static blockEvalToString(block1) {
235
+ static blockEvalToString(block) {
252
236
  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
237
+ areasLayoutEval: block.areasLayoutEval,
238
+ layoutEval: block.layoutEval,
239
+ propertiesEval: block.propertiesEval,
240
+ requiredEval: block.requiredEval,
241
+ styleEval: block.styleEval,
242
+ validationEval: block.validationEval,
243
+ value: block.value,
244
+ visibleEval: block.visibleEval
261
245
  });
262
246
  }
263
247
  recEval(visibleParent) {
@@ -490,27 +474,27 @@ let Blocks = class Blocks {
490
474
  });
491
475
  });
492
476
  }
493
- validate(match1) {
477
+ validate(match) {
494
478
  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
479
+ const validationErrors = this.getValidateRec(match, []); // get all relevant raised block errors and set showValidation
496
480
  this.setBlocksCache(); // update cache to render
497
481
  return validationErrors;
498
482
  }
499
- resetValidationRec(match2) {
483
+ resetValidationRec(match) {
500
484
  this.loopBlocks((block)=>{
501
- if (match2(block.blockId)) {
485
+ if (match(block.blockId)) {
502
486
  block.showValidation = false;
503
487
  block.update = true;
504
488
  }
505
489
  });
506
490
  Object.keys(this.subBlocks).forEach((subKey)=>{
507
491
  this.subBlocks[subKey].forEach((subBlock)=>{
508
- subBlock.resetValidationRec(match2);
492
+ subBlock.resetValidationRec(match);
509
493
  });
510
494
  });
511
495
  }
512
- resetValidation(match3) {
513
- this.resetValidationRec(match3);
496
+ resetValidation(match) {
497
+ this.resetValidationRec(match);
514
498
  this.setBlocksCache();
515
499
  }
516
500
  update() {
@@ -531,10 +515,8 @@ let Blocks = class Blocks {
531
515
  layout: block.layoutEval.output,
532
516
  style: block.styleEval.output,
533
517
  validation: {
534
- ...block.validationEval.output || {
535
- },
536
- status: block.showValidation ? (block.validationEval.output || {
537
- }).status : null
518
+ ...block.validationEval.output || {},
519
+ status: block.showValidation ? (block.validationEval.output || {}).status : null
538
520
  },
539
521
  value: type.isNone(block.value) ? null : block.value,
540
522
  visible: block.visibleEval.output
@@ -563,16 +545,14 @@ let Blocks = class Blocks {
563
545
  });
564
546
  });
565
547
  }
566
- constructor({ arrayIndices: arrayIndices1 , areas , context }){
548
+ constructor({ arrayIndices , areas , context }){
567
549
  this.id = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
568
550
  this.areas = serializer.copy(areas || []);
569
- this.arrayIndices = type.isArray(arrayIndices1) ? arrayIndices1 : [];
551
+ this.arrayIndices = type.isArray(arrayIndices) ? arrayIndices : [];
570
552
  this.context = context;
571
- this.map = {
572
- };
553
+ this.map = {};
573
554
  this.recCount = 0;
574
- this.subBlocks = {
575
- };
555
+ this.subBlocks = {};
576
556
  this.getValidateRec = this.getValidateRec.bind(this);
577
557
  this.init = this.init.bind(this);
578
558
  this.newBlocks = this.newBlocks.bind(this);
package/dist/Events.js CHANGED
@@ -28,17 +28,16 @@ let Events = class Events {
28
28
  this.events[eventName] = this.initEvent(this.block.events[eventName]);
29
29
  });
30
30
  }
31
- registerEvent({ name , actions: actions1 }) {
32
- this.events[name] = this.initEvent(actions1);
31
+ registerEvent({ name , actions }) {
32
+ this.events[name] = this.initEvent(actions);
33
33
  }
34
- async triggerEvent({ name: name1 , event }) {
35
- const eventDescription = this.events[name1];
34
+ async triggerEvent({ name , event }) {
35
+ const eventDescription = this.events[name];
36
36
  let result = {
37
37
  blockId: this.block.blockId,
38
38
  event,
39
- eventName: name1,
40
- responses: {
41
- },
39
+ eventName: name,
40
+ responses: {},
42
41
  endTimestamp: new Date(),
43
42
  startTimestamp: new Date(),
44
43
  success: true,
@@ -58,7 +57,7 @@ let Events = class Events {
58
57
  block: this.block,
59
58
  catchActions: eventDescription.catchActions,
60
59
  event,
61
- eventName: name1
60
+ eventName: name
62
61
  });
63
62
  eventDescription.history.unshift(res);
64
63
  this.context.eventLog.unshift(res);
@@ -73,7 +72,7 @@ let Events = class Events {
73
72
  }
74
73
  const delay = !type.isNone(eventDescription.debounce.ms) ? eventDescription.debounce.ms : this.defaultDebounceMs;
75
74
  // leading edge: bounce
76
- if (this.timeouts[name1] && eventDescription.debounce.immediate === true) {
75
+ if (this.timeouts[name] && eventDescription.debounce.immediate === true) {
77
76
  result.bounced = true;
78
77
  eventDescription.history.unshift(result);
79
78
  this.context.eventLog.unshift(result);
@@ -81,8 +80,8 @@ let Events = class Events {
81
80
  }
82
81
  // leading edge: trigger
83
82
  if (eventDescription.debounce.immediate === true) {
84
- this.timeouts[name1] = setTimeout(()=>{
85
- this.timeouts[name1] = null;
83
+ this.timeouts[name] = setTimeout(()=>{
84
+ this.timeouts[name] = null;
86
85
  }, delay);
87
86
  return actionHandle();
88
87
  }
@@ -107,10 +106,8 @@ let Events = class Events {
107
106
  }
108
107
  constructor({ arrayIndices , block , context }){
109
108
  this.defaultDebounceMs = 300;
110
- this.events = {
111
- };
112
- this.timeouts = {
113
- };
109
+ this.events = {};
110
+ this.timeouts = {};
114
111
  this.arrayIndices = arrayIndices;
115
112
  this.block = block;
116
113
  this.context = context;
package/dist/Requests.js CHANGED
@@ -14,8 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { get, serializer, type } from '@lowdefy/helpers';
16
16
  let Requests = class Requests {
17
- callRequests({ actions , arrayIndices , event , params } = {
18
- }) {
17
+ callRequests({ actions , arrayIndices , event , params } = {}) {
19
18
  if (params.all === true) {
20
19
  return Promise.all(Object.keys(this.requestConfig).map((requestId)=>this.callRequest({
21
20
  requestId,
@@ -37,7 +36,7 @@ let Requests = class Requests {
37
36
  })
38
37
  ));
39
38
  }
40
- callRequest({ actions: actions1 , arrayIndices: arrayIndices1 , event: event1 , requestId }) {
39
+ callRequest({ actions , arrayIndices , event , requestId }) {
41
40
  const request = this.requestConfig[requestId];
42
41
  if (!request) {
43
42
  const error = new Error(`Configuration Error: Request ${requestId} not defined on page.`);
@@ -58,9 +57,9 @@ let Requests = class Requests {
58
57
  };
59
58
  }
60
59
  const { output: payload , errors: parserErrors } = this.context._internal.parser.parse({
61
- actions: actions1,
62
- event: event1,
63
- arrayIndices: arrayIndices1,
60
+ actions,
61
+ event,
62
+ arrayIndices,
64
63
  input: request.payload,
65
64
  location: requestId
66
65
  });
@@ -73,8 +72,8 @@ let Requests = class Requests {
73
72
  payload
74
73
  });
75
74
  }
76
- async fetch({ requestId: requestId1 , payload }) {
77
- this.context.requests[requestId1].loading = true;
75
+ async fetch({ requestId , payload }) {
76
+ this.context.requests[requestId].loading = true;
78
77
  if (this.context._internal.RootBlocks) {
79
78
  this.context._internal.RootBlocks.setBlocksLoadingCache();
80
79
  }
@@ -82,18 +81,18 @@ let Requests = class Requests {
82
81
  const response = await this.context._internal.lowdefy._internal.callRequest({
83
82
  pageId: this.context.pageId,
84
83
  payload: serializer.serialize(payload),
85
- requestId: requestId1
84
+ requestId
86
85
  });
87
86
  const deserializedResponse = serializer.deserialize(get(response, 'response', {
88
87
  default: null
89
88
  }));
90
- this.context.requests[requestId1].response = deserializedResponse;
91
- this.context.requests[requestId1].loading = false;
89
+ this.context.requests[requestId].response = deserializedResponse;
90
+ this.context.requests[requestId].loading = false;
92
91
  this.context._internal.update();
93
92
  return deserializedResponse;
94
93
  } catch (error) {
95
- this.context.requests[requestId1].error.unshift(error);
96
- this.context.requests[requestId1].loading = false;
94
+ this.context.requests[requestId].error.unshift(error);
95
+ this.context.requests[requestId].loading = false;
97
96
  this.context._internal.update();
98
97
  throw error;
99
98
  }
@@ -103,8 +102,7 @@ let Requests = class Requests {
103
102
  this.callRequests = this.callRequests.bind(this);
104
103
  this.callRequest = this.callRequest.bind(this);
105
104
  this.fetch = this.fetch.bind(this);
106
- this.requestConfig = {
107
- };
105
+ this.requestConfig = {};
108
106
  (this.context._internal.rootBlock.requests || []).forEach((request)=>{
109
107
  this.requestConfig[request.requestId] = request;
110
108
  });
package/dist/State.js CHANGED
@@ -32,10 +32,10 @@ let State = class State {
32
32
  set(field, value) {
33
33
  set(this.context.state, field, value);
34
34
  }
35
- del(field1) {
36
- unset(this.context.state, field1);
35
+ del(field) {
36
+ unset(this.context.state, field);
37
37
  // remove all empty objects from state as an effect of deleted values
38
- const fields = field1.split('.');
38
+ const fields = field.split('.');
39
39
  if (fields.length > 1) {
40
40
  const parent = fields.slice(0, fields.length - 1).join('.');
41
41
  const parentValue = get(this.context.state, parent);
@@ -44,15 +44,15 @@ let State = class State {
44
44
  }
45
45
  }
46
46
  }
47
- swapItems(field2, from, to) {
48
- const arr = get(this.context.state, field2);
47
+ swapItems(field, from, to) {
48
+ const arr = get(this.context.state, field);
49
49
  if (!type.isArray(arr) || from < 0 || to < 0 || from >= arr.length || to >= arr.length) {
50
50
  return;
51
51
  }
52
52
  swap(arr, from, to);
53
53
  }
54
- removeItem(field3, index) {
55
- const arr = get(this.context.state, field3);
54
+ removeItem(field, index) {
55
+ const arr = get(this.context.state, field);
56
56
  if (!type.isArray(arr) || index < 0 || index >= arr.length) {
57
57
  return;
58
58
  }
@@ -24,8 +24,7 @@ async function JsAction({ context , event , params , arrayIndices , blockId })
24
24
  if (!type.isFunction(context.lowdefy.imports.jsActions[params.name])) {
25
25
  throw new Error(`JsAction ${params.name} is not a function.`);
26
26
  }
27
- const actions = {
28
- };
27
+ const actions = {};
29
28
  Object.keys(actionFns).forEach((name)=>{
30
29
  actions[name] = (actionParams)=>actionFns[name]({
31
30
  arrayIndices,
@@ -12,8 +12,7 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function Message({ context , params ={
16
- } }) {
15
+ */ function Message({ context , params ={} }) {
17
16
  context._internal.lowdefy._internal.displayMessage({
18
17
  content: params.content || 'Success',
19
18
  duration: params.duration,
@@ -12,8 +12,7 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ async function ScrollTo({ context , params ={
16
- } }) {
15
+ */ async function ScrollTo({ context , params ={} }) {
17
16
  if (params.blockId) {
18
17
  const element = context._internal.lowdefy._internal.document.getElementById(params.blockId);
19
18
  if (element) {
@@ -14,16 +14,15 @@
14
14
  limitations under the License.
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  let ThrowActionError = class ThrowActionError extends Error {
17
- constructor(message, { blockId: blockId1 , context: context1 , metaData }){
17
+ constructor(message, { blockId , context , metaData }){
18
18
  super(message);
19
- this.blockId = blockId1;
19
+ this.blockId = blockId;
20
20
  this.metaData = metaData;
21
21
  this.name = 'ThrowError';
22
- this.pageId = context1.pageId;
22
+ this.pageId = context.pageId;
23
23
  }
24
24
  };
25
- function Throw({ blockId , context , params ={
26
- } }) {
25
+ function Throw({ blockId , context , params ={} }) {
27
26
  if (params.throw === false || type.isNone(params.throw)) {
28
27
  return;
29
28
  }
@@ -12,12 +12,11 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { type } from '@lowdefy/helpers';
15
+ */ import { type, wait } from '@lowdefy/helpers';
16
16
  async function Wait({ params }) {
17
17
  if (!type.isInt(params.ms)) {
18
18
  throw new Error(`Wait action "ms" param should be an integer.`);
19
19
  }
20
- return new Promise((resolve)=>setTimeout(resolve, params.ms)
21
- );
20
+ return wait(params.ms);
22
21
  }
23
22
  export default Wait;
@@ -35,32 +35,28 @@ const blockData = ({ areas , blockId , blocks , events , field , id , layout , p
35
35
  visible
36
36
  })
37
37
  ;
38
- async function getContext({ config , lowdefy }) {
38
+ async function getContext({ config , lowdefy , development =false }) {
39
39
  if (!config) {
40
40
  throw new Error('A page must be provided to get context.');
41
41
  }
42
42
  const { id } = config;
43
- if (lowdefy.contexts[id]) {
43
+ if (lowdefy.contexts[id] && !development) {
44
44
  lowdefy.contexts[id]._internal.update();
45
45
  return lowdefy.contexts[id];
46
46
  }
47
47
  if (!lowdefy.inputs[id]) {
48
- lowdefy.inputs[id] = {
49
- };
48
+ lowdefy.inputs[id] = {};
50
49
  }
51
50
  const ctx = {
52
51
  id: id,
53
52
  pageId: config.pageId,
54
53
  eventLog: [],
55
- requests: {
56
- },
57
- state: {
58
- },
54
+ requests: {},
55
+ state: {},
59
56
  _internal: {
60
57
  lowdefy,
61
58
  rootBlock: blockData(config),
62
- update: ()=>{
63
- }
59
+ update: ()=>{}
64
60
  }
65
61
  };
66
62
  const _internal = ctx._internal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/engine",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-alpha.6",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -38,17 +38,17 @@
38
38
  "test": "jest --coverage"
39
39
  },
40
40
  "dependencies": {
41
- "@lowdefy/helpers": "4.0.0-alpha.5",
42
- "@lowdefy/operators": "4.0.0-alpha.5"
41
+ "@lowdefy/helpers": "4.0.0-alpha.6",
42
+ "@lowdefy/operators": "4.0.0-alpha.6"
43
43
  },
44
44
  "devDependencies": {
45
- "@swc/cli": "0.1.52",
46
- "@swc/core": "1.2.112",
47
- "@swc/jest": "0.2.9",
45
+ "@swc/cli": "0.1.55",
46
+ "@swc/core": "1.2.130",
47
+ "@swc/jest": "0.2.17",
48
48
  "jest": "27.3.1"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "995fcdb020927f3cdc626fc99c15a2e4137bd962"
53
+ "gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
54
54
  }