@lowdefy/engine 4.0.0-alpha.1 → 4.0.0-alpha.10
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 +80 -71
- package/dist/Blocks.js +67 -85
- package/dist/Events.js +14 -16
- package/dist/Requests.js +15 -20
- package/dist/State.js +8 -8
- package/dist/actions/createCallMethod.js +29 -0
- package/dist/actions/{Request.js → createDisplayMessage.js} +6 -9
- package/dist/actions/createGetActions.js +27 -0
- package/dist/actions/{Logout.js → createGetBlockId.js} +6 -4
- package/dist/actions/createGetEvent.js +27 -0
- package/dist/actions/createGetGlobal.js +27 -0
- package/dist/actions/createGetInput.js +27 -0
- package/dist/actions/{Login.js → createGetPageId.js} +6 -4
- package/dist/actions/createGetRequestDetails.js +27 -0
- package/dist/actions/{Wait.js → createGetState.js} +13 -9
- package/dist/actions/createGetUrlQuery.js +27 -0
- package/dist/actions/createGetUser.js +27 -0
- package/dist/actions/createLink.js +20 -0
- package/dist/actions/createLogin.js +20 -0
- package/dist/actions/createLogout.js +20 -0
- package/dist/actions/{Message.js → createRequest.js} +11 -10
- package/dist/actions/{Reset.js → createReset.js} +8 -6
- package/dist/actions/{ResetValidation.js → createResetValidation.js} +6 -4
- package/dist/actions/{SetGlobal.js → createSetGlobal.js} +11 -9
- package/dist/actions/{SetState.js → createSetState.js} +10 -8
- package/dist/actions/{Validate.js → createValidate.js} +10 -8
- package/dist/actions/getActionMethods.js +61 -0
- package/dist/actions/getFromObject.js +42 -0
- package/dist/createLink.js +46 -23
- package/dist/getBlockMatcher.js +1 -1
- package/dist/getContext.js +37 -32
- package/dist/index.js +1 -1
- package/package.json +9 -8
- package/dist/actions/CallMethod.js +0 -28
- package/dist/actions/JsAction.js +0 -55
- package/dist/actions/Link.js +0 -27
- package/dist/actions/ScrollTo.js +0 -26
- package/dist/actions/Throw.js +0 -40
- package/dist/actions/index.js +0 -46
- package/dist/getFieldValues.js +0 -35
package/dist/Actions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
-
import
|
|
16
|
+
import getActionMethods from './actions/getActionMethods.js';
|
|
17
17
|
let Actions = class Actions {
|
|
18
18
|
async callAsyncAction({ action , arrayIndices , block , event , index , responses }) {
|
|
19
19
|
try {
|
|
@@ -31,31 +31,33 @@ let Actions = class Actions {
|
|
|
31
31
|
console.error(error);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
async callActionLoop({ actions
|
|
35
|
-
for (const [index, action] of
|
|
34
|
+
async callActionLoop({ actions , arrayIndices , block , event , progress , responses }) {
|
|
35
|
+
for (const [index, action] of actions.entries()){
|
|
36
36
|
try {
|
|
37
37
|
if (action.async === true) {
|
|
38
38
|
this.callAsyncAction({
|
|
39
39
|
action,
|
|
40
|
-
arrayIndices
|
|
41
|
-
block
|
|
42
|
-
event
|
|
40
|
+
arrayIndices,
|
|
41
|
+
block,
|
|
42
|
+
event,
|
|
43
43
|
index,
|
|
44
|
-
|
|
44
|
+
progress,
|
|
45
|
+
responses
|
|
45
46
|
});
|
|
46
47
|
} else {
|
|
47
48
|
const response = await this.callAction({
|
|
48
49
|
action,
|
|
49
|
-
arrayIndices
|
|
50
|
-
block
|
|
51
|
-
event
|
|
50
|
+
arrayIndices,
|
|
51
|
+
block,
|
|
52
|
+
event,
|
|
52
53
|
index,
|
|
53
|
-
|
|
54
|
+
progress,
|
|
55
|
+
responses
|
|
54
56
|
});
|
|
55
|
-
|
|
57
|
+
responses[action.id] = response;
|
|
56
58
|
}
|
|
57
59
|
} catch (error) {
|
|
58
|
-
|
|
60
|
+
responses[action.id] = error;
|
|
59
61
|
throw {
|
|
60
62
|
error,
|
|
61
63
|
action
|
|
@@ -63,37 +65,38 @@ let Actions = class Actions {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
async callActions({ actions
|
|
68
|
+
async callActions({ actions , arrayIndices , block , catchActions , event , eventName , progress }) {
|
|
67
69
|
const startTimestamp = new Date();
|
|
68
|
-
const responses = {
|
|
69
|
-
};
|
|
70
|
+
const responses = {};
|
|
70
71
|
try {
|
|
71
72
|
await this.callActionLoop({
|
|
72
|
-
actions
|
|
73
|
-
arrayIndices
|
|
74
|
-
block
|
|
75
|
-
event
|
|
76
|
-
responses
|
|
73
|
+
actions,
|
|
74
|
+
arrayIndices,
|
|
75
|
+
block,
|
|
76
|
+
event,
|
|
77
|
+
responses,
|
|
78
|
+
progress
|
|
77
79
|
});
|
|
78
80
|
} catch (error) {
|
|
79
81
|
console.error(error);
|
|
80
82
|
try {
|
|
81
83
|
await this.callActionLoop({
|
|
82
84
|
actions: catchActions,
|
|
83
|
-
arrayIndices
|
|
84
|
-
block
|
|
85
|
-
event
|
|
86
|
-
responses
|
|
85
|
+
arrayIndices,
|
|
86
|
+
block,
|
|
87
|
+
event,
|
|
88
|
+
responses,
|
|
89
|
+
progress
|
|
87
90
|
});
|
|
88
91
|
} catch (errorCatch) {
|
|
89
92
|
console.error(errorCatch);
|
|
90
93
|
return {
|
|
91
|
-
blockId:
|
|
94
|
+
blockId: block.blockId,
|
|
92
95
|
bounced: false,
|
|
93
96
|
endTimestamp: new Date(),
|
|
94
97
|
error,
|
|
95
98
|
errorCatch,
|
|
96
|
-
event
|
|
99
|
+
event,
|
|
97
100
|
eventName,
|
|
98
101
|
responses,
|
|
99
102
|
startTimestamp,
|
|
@@ -101,11 +104,11 @@ let Actions = class Actions {
|
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
106
|
return {
|
|
104
|
-
blockId:
|
|
107
|
+
blockId: block.blockId,
|
|
105
108
|
bounced: false,
|
|
106
109
|
endTimestamp: new Date(),
|
|
107
110
|
error,
|
|
108
|
-
event
|
|
111
|
+
event,
|
|
109
112
|
eventName,
|
|
110
113
|
responses,
|
|
111
114
|
startTimestamp,
|
|
@@ -113,47 +116,46 @@ let Actions = class Actions {
|
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
return {
|
|
116
|
-
blockId:
|
|
119
|
+
blockId: block.blockId,
|
|
117
120
|
bounced: false,
|
|
118
121
|
endTimestamp: new Date(),
|
|
119
|
-
event
|
|
122
|
+
event,
|
|
120
123
|
eventName,
|
|
121
124
|
responses,
|
|
122
125
|
startTimestamp,
|
|
123
126
|
success: true
|
|
124
127
|
};
|
|
125
128
|
}
|
|
126
|
-
async callAction({ action
|
|
127
|
-
if (!actions[
|
|
129
|
+
async callAction({ action , arrayIndices , block , event , index , progress , responses }) {
|
|
130
|
+
if (!this.actions[action.type]) {
|
|
128
131
|
throw {
|
|
129
|
-
error: new Error(`Invalid action type "${
|
|
130
|
-
type:
|
|
131
|
-
index
|
|
132
|
+
error: new Error(`Invalid action type "${action.type}" at "${block.blockId}".`),
|
|
133
|
+
type: action.type,
|
|
134
|
+
index
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
137
|
const { output: parsedAction , errors: parserErrors } = this.context._internal.parser.parse({
|
|
135
|
-
actions:
|
|
136
|
-
event
|
|
137
|
-
arrayIndices
|
|
138
|
-
input:
|
|
139
|
-
location:
|
|
138
|
+
actions: responses,
|
|
139
|
+
event,
|
|
140
|
+
arrayIndices,
|
|
141
|
+
input: action,
|
|
142
|
+
location: block.blockId
|
|
140
143
|
});
|
|
141
144
|
if (parserErrors.length > 0) {
|
|
142
145
|
throw {
|
|
143
146
|
error: parserErrors[0],
|
|
144
|
-
type:
|
|
145
|
-
index
|
|
147
|
+
type: action.type,
|
|
148
|
+
index
|
|
146
149
|
};
|
|
147
150
|
}
|
|
148
151
|
if (parsedAction.skip === true) {
|
|
149
152
|
return {
|
|
150
|
-
type:
|
|
153
|
+
type: action.type,
|
|
151
154
|
skipped: true,
|
|
152
|
-
index
|
|
155
|
+
index
|
|
153
156
|
};
|
|
154
157
|
}
|
|
155
|
-
const messages = parsedAction.messages || {
|
|
156
|
-
};
|
|
158
|
+
const messages = parsedAction.messages || {};
|
|
157
159
|
let response;
|
|
158
160
|
const closeLoading = this.displayMessage({
|
|
159
161
|
defaultMessage: 'Loading',
|
|
@@ -162,32 +164,40 @@ let Actions = class Actions {
|
|
|
162
164
|
status: 'loading'
|
|
163
165
|
});
|
|
164
166
|
try {
|
|
165
|
-
response = await actions[
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
response = await this.actions[action.type]({
|
|
168
|
+
methods: getActionMethods({
|
|
169
|
+
actions: responses,
|
|
170
|
+
arrayIndices,
|
|
171
|
+
blockId: block.blockId,
|
|
172
|
+
context: this.context,
|
|
173
|
+
event
|
|
174
|
+
}),
|
|
175
|
+
document: this.context._internal.lowdefy._internal.document,
|
|
176
|
+
params: parsedAction.params,
|
|
177
|
+
window: this.context._internal.lowdefy._internal.window
|
|
171
178
|
});
|
|
179
|
+
if (progress) {
|
|
180
|
+
progress();
|
|
181
|
+
}
|
|
172
182
|
} catch (error) {
|
|
173
|
-
|
|
183
|
+
responses[action.id] = {
|
|
174
184
|
error,
|
|
175
|
-
index
|
|
176
|
-
type:
|
|
185
|
+
index,
|
|
186
|
+
type: action.type
|
|
177
187
|
};
|
|
178
188
|
const { output: parsedMessages , errors: parserErrors } = this.context._internal.parser.parse({
|
|
179
|
-
actions:
|
|
180
|
-
event
|
|
181
|
-
arrayIndices
|
|
182
|
-
input:
|
|
183
|
-
location:
|
|
189
|
+
actions: responses,
|
|
190
|
+
event,
|
|
191
|
+
arrayIndices,
|
|
192
|
+
input: action.messages,
|
|
193
|
+
location: block.blockId
|
|
184
194
|
});
|
|
185
195
|
if (parserErrors.length > 0) {
|
|
186
196
|
// this condition is very unlikely since parser errors usually occur in the first parse.
|
|
187
197
|
throw {
|
|
188
198
|
error: parserErrors[0],
|
|
189
|
-
type:
|
|
190
|
-
index
|
|
199
|
+
type: action.type,
|
|
200
|
+
index
|
|
191
201
|
};
|
|
192
202
|
}
|
|
193
203
|
closeLoading();
|
|
@@ -195,14 +205,13 @@ let Actions = class Actions {
|
|
|
195
205
|
defaultMessage: error.message,
|
|
196
206
|
duration: 6,
|
|
197
207
|
hideExplicitly: true,
|
|
198
|
-
message: (parsedMessages || {
|
|
199
|
-
}).error,
|
|
208
|
+
message: (parsedMessages || {}).error,
|
|
200
209
|
status: 'error'
|
|
201
210
|
});
|
|
202
211
|
throw {
|
|
203
|
-
type:
|
|
212
|
+
type: action.type,
|
|
204
213
|
error,
|
|
205
|
-
index
|
|
214
|
+
index
|
|
206
215
|
};
|
|
207
216
|
}
|
|
208
217
|
closeLoading();
|
|
@@ -212,9 +221,9 @@ let Actions = class Actions {
|
|
|
212
221
|
status: 'success'
|
|
213
222
|
});
|
|
214
223
|
return {
|
|
215
|
-
type:
|
|
224
|
+
type: action.type,
|
|
216
225
|
response,
|
|
217
|
-
index
|
|
226
|
+
index
|
|
218
227
|
};
|
|
219
228
|
}
|
|
220
229
|
displayMessage({ defaultMessage , duration , hideExplicitly , message , status }) {
|
|
@@ -235,7 +244,7 @@ let Actions = class Actions {
|
|
|
235
244
|
this.callActionLoop = this.callActionLoop.bind(this);
|
|
236
245
|
this.callActions = this.callActions.bind(this);
|
|
237
246
|
this.displayMessage = this.displayMessage.bind(this);
|
|
238
|
-
this.actions = actions;
|
|
247
|
+
this.actions = context._internal.lowdefy._internal.actions;
|
|
239
248
|
}
|
|
240
249
|
};
|
|
241
250
|
export default Actions;
|
package/dist/Blocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */ /*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { applyArrayIndices, get, serializer, swap, type } from '@lowdefy/helpers';
|
|
16
16
|
import Events from './Events.js';
|
|
17
|
-
import getFieldValues from './getFieldValues.js';
|
|
18
17
|
let Blocks = class Blocks {
|
|
19
18
|
loopBlocks(fn) {
|
|
20
19
|
if (type.isObject(this.areas)) {
|
|
@@ -34,35 +33,31 @@ let Blocks = class Blocks {
|
|
|
34
33
|
block.blockId = applyArrayIndices(this.arrayIndices, block.blockIdPattern);
|
|
35
34
|
block.field = !type.isNone(block.fieldPattern) ? applyArrayIndices(this.arrayIndices, block.fieldPattern) : block.blockId;
|
|
36
35
|
this.context._internal.RootBlocks.map[block.id] = block;
|
|
37
|
-
block.
|
|
36
|
+
block.events = type.isNone(block.events) ? {} : block.events;
|
|
37
|
+
block.layout = type.isNone(block.layout) ? {} : block.layout;
|
|
38
|
+
block.loading = type.isNone(block.loading) ? false : block.loading;
|
|
39
|
+
block.properties = type.isNone(block.properties) ? {} : block.properties;
|
|
38
40
|
block.required = type.isNone(block.required) ? false : block.required;
|
|
39
|
-
block.
|
|
40
|
-
block.
|
|
41
|
-
|
|
42
|
-
block.
|
|
43
|
-
|
|
44
|
-
block.
|
|
45
|
-
|
|
46
|
-
block.
|
|
47
|
-
|
|
48
|
-
block.
|
|
49
|
-
};
|
|
50
|
-
block.
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
block.validationEval = {
|
|
59
|
-
};
|
|
60
|
-
block.visibleEval = {
|
|
61
|
-
};
|
|
62
|
-
block.meta = this.context._internal.lowdefy._internal.blockComponents[block.type].meta;
|
|
41
|
+
block.skeleton = type.isNone(block.skeleton) ? null : block.skeleton;
|
|
42
|
+
block.style = type.isNone(block.style) ? {} : block.style;
|
|
43
|
+
block.validate = type.isNone(block.validate) ? [] : block.validate;
|
|
44
|
+
block.visible = type.isNone(block.visible) ? true : block.visible;
|
|
45
|
+
block.areasLayoutEval = {};
|
|
46
|
+
block.layoutEval = {};
|
|
47
|
+
block.loadingEval = {};
|
|
48
|
+
block.propertiesEval = {};
|
|
49
|
+
block.requiredEval = {};
|
|
50
|
+
block.skeletonEval = {};
|
|
51
|
+
block.styleEval = {};
|
|
52
|
+
block.validationEval = {};
|
|
53
|
+
block.visibleEval = {};
|
|
54
|
+
try {
|
|
55
|
+
block.meta = this.context._internal.lowdefy._internal.blockComponents[block.type].meta;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
throw new Error(`Block type ${block.type} not found at ${block.blockId}. Check your plugins to make sure the block is installed. For more info, see https://docs.lowdefy.com/plugins.`);
|
|
58
|
+
}
|
|
63
59
|
if (!type.isNone(block.areas)) {
|
|
64
|
-
block.areasLayout = {
|
|
65
|
-
};
|
|
60
|
+
block.areasLayout = {};
|
|
66
61
|
Object.keys(block.areas).forEach((key)=>{
|
|
67
62
|
// eslint-disable-next-line no-unused-vars
|
|
68
63
|
const { blocks , ...areaLayout } = block.areas[key];
|
|
@@ -71,12 +66,9 @@ let Blocks = class Blocks {
|
|
|
71
66
|
};
|
|
72
67
|
});
|
|
73
68
|
} else {
|
|
74
|
-
block.areasLayout = {
|
|
75
|
-
};
|
|
69
|
+
block.areasLayout = {};
|
|
76
70
|
}
|
|
77
|
-
block.
|
|
78
|
-
block.methods = {
|
|
79
|
-
};
|
|
71
|
+
block.methods = {};
|
|
80
72
|
block.registerMethod = (methodName, method)=>{
|
|
81
73
|
block.methods[methodName] = method;
|
|
82
74
|
};
|
|
@@ -96,8 +88,7 @@ let Blocks = class Blocks {
|
|
|
96
88
|
0
|
|
97
89
|
]),
|
|
98
90
|
block,
|
|
99
|
-
initState: {
|
|
100
|
-
}
|
|
91
|
+
initState: {}
|
|
101
92
|
}));
|
|
102
93
|
this.context._internal.State.set(block.field, undefined);
|
|
103
94
|
// set block and subBlock values undefined, so as not to pass values to new blocks
|
|
@@ -111,8 +102,7 @@ let Blocks = class Blocks {
|
|
|
111
102
|
this.subBlocks[block.id].length
|
|
112
103
|
]),
|
|
113
104
|
block,
|
|
114
|
-
initState: {
|
|
115
|
-
}
|
|
105
|
+
initState: {}
|
|
116
106
|
}));
|
|
117
107
|
block.update = true;
|
|
118
108
|
this.context._internal.update();
|
|
@@ -238,26 +228,28 @@ let Blocks = class Blocks {
|
|
|
238
228
|
}
|
|
239
229
|
});
|
|
240
230
|
}
|
|
241
|
-
newBlocks({ arrayIndices , block
|
|
231
|
+
newBlocks({ arrayIndices , block , initState }) {
|
|
242
232
|
const SubBlocks = new Blocks({
|
|
243
233
|
arrayIndices,
|
|
244
|
-
areas:
|
|
234
|
+
areas: block.areas,
|
|
245
235
|
context: this.context
|
|
246
236
|
});
|
|
247
|
-
SubBlocks.init(
|
|
237
|
+
SubBlocks.init(initState);
|
|
248
238
|
return SubBlocks;
|
|
249
239
|
}
|
|
250
240
|
// used for update comparison
|
|
251
|
-
static blockEvalToString(
|
|
241
|
+
static blockEvalToString(block) {
|
|
252
242
|
return serializer.serializeToString({
|
|
253
|
-
areasLayoutEval:
|
|
254
|
-
layoutEval:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
243
|
+
areasLayoutEval: block.areasLayoutEval,
|
|
244
|
+
layoutEval: block.layoutEval,
|
|
245
|
+
loadingEval: block.loadingEval,
|
|
246
|
+
propertiesEval: block.propertiesEval,
|
|
247
|
+
requiredEval: block.requiredEval,
|
|
248
|
+
skeletonEval: block.skeletonEval,
|
|
249
|
+
styleEval: block.styleEval,
|
|
250
|
+
validationEval: block.validationEval,
|
|
251
|
+
value: block.value,
|
|
252
|
+
visibleEval: block.visibleEval
|
|
261
253
|
});
|
|
262
254
|
}
|
|
263
255
|
recEval(visibleParent) {
|
|
@@ -362,6 +354,16 @@ let Blocks = class Blocks {
|
|
|
362
354
|
location: block.blockId,
|
|
363
355
|
arrayIndices: this.arrayIndices
|
|
364
356
|
});
|
|
357
|
+
block.loadingEval = this.context._internal.parser.parse({
|
|
358
|
+
input: block.loading,
|
|
359
|
+
location: block.blockId,
|
|
360
|
+
arrayIndices: this.arrayIndices
|
|
361
|
+
});
|
|
362
|
+
block.skeletonEval = this.context._internal.parser.parse({
|
|
363
|
+
input: block.skeleton,
|
|
364
|
+
location: block.blockId,
|
|
365
|
+
arrayIndices: this.arrayIndices
|
|
366
|
+
});
|
|
365
367
|
block.areasLayoutEval = this.context._internal.parser.parse({
|
|
366
368
|
input: block.areasLayout,
|
|
367
369
|
location: block.blockId,
|
|
@@ -490,27 +492,27 @@ let Blocks = class Blocks {
|
|
|
490
492
|
});
|
|
491
493
|
});
|
|
492
494
|
}
|
|
493
|
-
validate(
|
|
495
|
+
validate(match) {
|
|
494
496
|
this.updateStateFromRoot(); // update to recalculate validationEval to raise block errors
|
|
495
|
-
const validationErrors = this.getValidateRec(
|
|
497
|
+
const validationErrors = this.getValidateRec(match, []); // get all relevant raised block errors and set showValidation
|
|
496
498
|
this.setBlocksCache(); // update cache to render
|
|
497
499
|
return validationErrors;
|
|
498
500
|
}
|
|
499
|
-
resetValidationRec(
|
|
501
|
+
resetValidationRec(match) {
|
|
500
502
|
this.loopBlocks((block)=>{
|
|
501
|
-
if (
|
|
503
|
+
if (match(block.blockId)) {
|
|
502
504
|
block.showValidation = false;
|
|
503
505
|
block.update = true;
|
|
504
506
|
}
|
|
505
507
|
});
|
|
506
508
|
Object.keys(this.subBlocks).forEach((subKey)=>{
|
|
507
509
|
this.subBlocks[subKey].forEach((subBlock)=>{
|
|
508
|
-
subBlock.resetValidationRec(
|
|
510
|
+
subBlock.resetValidationRec(match);
|
|
509
511
|
});
|
|
510
512
|
});
|
|
511
513
|
}
|
|
512
|
-
resetValidation(
|
|
513
|
-
this.resetValidationRec(
|
|
514
|
+
resetValidation(match) {
|
|
515
|
+
this.resetValidationRec(match);
|
|
514
516
|
this.setBlocksCache();
|
|
515
517
|
}
|
|
516
518
|
update() {
|
|
@@ -521,20 +523,18 @@ let Blocks = class Blocks {
|
|
|
521
523
|
this.loopBlocks((block)=>{
|
|
522
524
|
if (block.update) {
|
|
523
525
|
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
526
|
block.eval = {
|
|
527
527
|
areas: block.areasLayoutEval.output,
|
|
528
528
|
events: type.isNone(block.Events.events) ? null : block.Events.events,
|
|
529
529
|
properties: block.propertiesEval.output,
|
|
530
|
+
loading: block.loadingEval.output,
|
|
531
|
+
skeleton: block.skeletonEval.output,
|
|
530
532
|
required: block.requiredEval.output,
|
|
531
533
|
layout: block.layoutEval.output,
|
|
532
534
|
style: block.styleEval.output,
|
|
533
535
|
validation: {
|
|
534
|
-
...block.validationEval.output || {
|
|
535
|
-
}
|
|
536
|
-
status: block.showValidation ? (block.validationEval.output || {
|
|
537
|
-
}).status : null
|
|
536
|
+
...block.validationEval.output || {},
|
|
537
|
+
status: block.showValidation ? (block.validationEval.output || {}).status : null
|
|
538
538
|
},
|
|
539
539
|
value: type.isNone(block.value) ? null : block.value,
|
|
540
540
|
visible: block.visibleEval.output
|
|
@@ -548,31 +548,14 @@ let Blocks = class Blocks {
|
|
|
548
548
|
});
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
|
-
|
|
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 }){
|
|
551
|
+
constructor({ arrayIndices , areas , context }){
|
|
567
552
|
this.id = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
|
|
568
553
|
this.areas = serializer.copy(areas || []);
|
|
569
|
-
this.arrayIndices = type.isArray(
|
|
554
|
+
this.arrayIndices = type.isArray(arrayIndices) ? arrayIndices : [];
|
|
570
555
|
this.context = context;
|
|
571
|
-
this.map = {
|
|
572
|
-
};
|
|
556
|
+
this.map = {};
|
|
573
557
|
this.recCount = 0;
|
|
574
|
-
this.subBlocks = {
|
|
575
|
-
};
|
|
558
|
+
this.subBlocks = {};
|
|
576
559
|
this.getValidateRec = this.getValidateRec.bind(this);
|
|
577
560
|
this.init = this.init.bind(this);
|
|
578
561
|
this.newBlocks = this.newBlocks.bind(this);
|
|
@@ -585,7 +568,6 @@ let Blocks = class Blocks {
|
|
|
585
568
|
this.resetValidation = this.resetValidation.bind(this);
|
|
586
569
|
this.resetValidationRec = this.resetValidationRec.bind(this);
|
|
587
570
|
this.setBlocksCache = this.setBlocksCache.bind(this);
|
|
588
|
-
this.setBlocksLoadingCache = this.setBlocksLoadingCache.bind(this);
|
|
589
571
|
this.update = this.update.bind(this);
|
|
590
572
|
this.updateState = this.updateState.bind(this);
|
|
591
573
|
this.updateStateFromRoot = this.updateStateFromRoot.bind(this);
|
package/dist/Events.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -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
|
|
32
|
-
this.events[name] = this.initEvent(
|
|
31
|
+
registerEvent({ name , actions }) {
|
|
32
|
+
this.events[name] = this.initEvent(actions);
|
|
33
33
|
}
|
|
34
|
-
async triggerEvent({ name
|
|
35
|
-
const eventDescription = this.events[
|
|
34
|
+
async triggerEvent({ name , event , progress }) {
|
|
35
|
+
const eventDescription = this.events[name];
|
|
36
36
|
let result = {
|
|
37
37
|
blockId: this.block.blockId,
|
|
38
38
|
event,
|
|
39
|
-
eventName:
|
|
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,8 @@ let Events = class Events {
|
|
|
58
57
|
block: this.block,
|
|
59
58
|
catchActions: eventDescription.catchActions,
|
|
60
59
|
event,
|
|
61
|
-
eventName:
|
|
60
|
+
eventName: name,
|
|
61
|
+
progress
|
|
62
62
|
});
|
|
63
63
|
eventDescription.history.unshift(res);
|
|
64
64
|
this.context.eventLog.unshift(res);
|
|
@@ -73,7 +73,7 @@ let Events = class Events {
|
|
|
73
73
|
}
|
|
74
74
|
const delay = !type.isNone(eventDescription.debounce.ms) ? eventDescription.debounce.ms : this.defaultDebounceMs;
|
|
75
75
|
// leading edge: bounce
|
|
76
|
-
if (this.timeouts[
|
|
76
|
+
if (this.timeouts[name] && eventDescription.debounce.immediate === true) {
|
|
77
77
|
result.bounced = true;
|
|
78
78
|
eventDescription.history.unshift(result);
|
|
79
79
|
this.context.eventLog.unshift(result);
|
|
@@ -81,8 +81,8 @@ let Events = class Events {
|
|
|
81
81
|
}
|
|
82
82
|
// leading edge: trigger
|
|
83
83
|
if (eventDescription.debounce.immediate === true) {
|
|
84
|
-
this.timeouts[
|
|
85
|
-
this.timeouts[
|
|
84
|
+
this.timeouts[name] = setTimeout(()=>{
|
|
85
|
+
this.timeouts[name] = null;
|
|
86
86
|
}, delay);
|
|
87
87
|
return actionHandle();
|
|
88
88
|
}
|
|
@@ -107,10 +107,8 @@ let Events = class Events {
|
|
|
107
107
|
}
|
|
108
108
|
constructor({ arrayIndices , block , context }){
|
|
109
109
|
this.defaultDebounceMs = 300;
|
|
110
|
-
this.events = {
|
|
111
|
-
};
|
|
112
|
-
this.timeouts = {
|
|
113
|
-
};
|
|
110
|
+
this.events = {};
|
|
111
|
+
this.timeouts = {};
|
|
114
112
|
this.arrayIndices = arrayIndices;
|
|
115
113
|
this.block = block;
|
|
116
114
|
this.context = context;
|