@lowdefy/engine 4.0.0-alpha.6 → 4.0.0-alpha.9
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 +29 -17
- package/dist/Blocks.js +29 -27
- package/dist/Events.js +4 -3
- package/dist/Requests.js +2 -5
- package/dist/State.js +1 -1
- 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/createGetState.js +27 -0
- 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 -9
- 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 +30 -12
- package/dist/index.js +1 -1
- package/package.json +7 -6
- package/dist/actions/CallMethod.js +0 -28
- package/dist/actions/JsAction.js +0 -54
- package/dist/actions/Link.js +0 -27
- package/dist/actions/ScrollTo.js +0 -25
- package/dist/actions/Throw.js +0 -39
- package/dist/actions/Wait.js +0 -22
- package/dist/actions/index.js +0 -46
- package/dist/getFieldValues.js +0 -35
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ function createLogin({ context }) {
|
|
16
|
+
return function login(params) {
|
|
17
|
+
return context._internal.lowdefy._internal.auth.login(params);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createLogin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ function createLogout({ context }) {
|
|
16
|
+
return function logout() {
|
|
17
|
+
return context._internal.lowdefy._internal.auth.logout();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createLogout;
|
|
@@ -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.
|
|
@@ -12,12 +12,14 @@
|
|
|
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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
*/ function createRequest({ actions , arrayIndices , context , event }) {
|
|
16
|
+
return async function request(params) {
|
|
17
|
+
return await context._internal.Requests.callRequests({
|
|
18
|
+
actions,
|
|
19
|
+
arrayIndices,
|
|
20
|
+
event,
|
|
21
|
+
params
|
|
22
|
+
});
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
|
-
export default
|
|
25
|
+
export default createRequest;
|
|
@@ -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,9 +13,11 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { serializer } from '@lowdefy/helpers';
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function createReset({ context }) {
|
|
17
|
+
return function reset() {
|
|
18
|
+
context._internal.State.resetState();
|
|
19
|
+
context._internal.RootBlocks.reset(serializer.deserializeFromString(context._internal.State.frozenState));
|
|
20
|
+
context._internal.update();
|
|
21
|
+
};
|
|
20
22
|
}
|
|
21
|
-
export default
|
|
23
|
+
export default createReset;
|
|
@@ -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,9 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import getBlockMatcher from '../getBlockMatcher.js';
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
function createResetValidation({ context }) {
|
|
17
|
+
return function resetValidation(params) {
|
|
18
|
+
context._internal.RootBlocks.resetValidation(getBlockMatcher(params));
|
|
19
|
+
};
|
|
18
20
|
}
|
|
19
|
-
export default
|
|
21
|
+
export default createResetValidation;
|
|
@@ -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,11 +13,13 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { applyArrayIndices, set } from '@lowdefy/helpers';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const createSetGlobal = ({ arrayIndices , context })=>{
|
|
17
|
+
return function setGlobal(params) {
|
|
18
|
+
Object.keys(params).forEach((key)=>{
|
|
19
|
+
set(context._internal.lowdefy._internal.lowdefyGlobal, applyArrayIndices(arrayIndices, key), params[key]);
|
|
20
|
+
});
|
|
21
|
+
context._internal.RootBlocks.reset();
|
|
22
|
+
context._internal.update();
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default createSetGlobal;
|
|
@@ -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,11 +13,13 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { applyArrayIndices } from '@lowdefy/helpers';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function createSetState({ arrayIndices , context }) {
|
|
17
|
+
return function setState(params) {
|
|
18
|
+
Object.keys(params).forEach((key)=>{
|
|
19
|
+
context._internal.State.set(applyArrayIndices(arrayIndices, key), params[key]);
|
|
20
|
+
});
|
|
21
|
+
context._internal.RootBlocks.reset();
|
|
22
|
+
context._internal.update();
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
|
-
export default
|
|
25
|
+
export default createSetState;
|
|
@@ -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,11 +13,13 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import getBlockMatcher from '../getBlockMatcher.js';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function createValidate({ context }) {
|
|
17
|
+
return function validate(params) {
|
|
18
|
+
const validationErrors = context._internal.RootBlocks.validate(getBlockMatcher(params));
|
|
19
|
+
if (validationErrors.length > 0) {
|
|
20
|
+
const error = new Error(`Your input has ${validationErrors.length} validation error${validationErrors.length !== 1 ? 's' : ''}.`);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
|
-
export default
|
|
25
|
+
export default createValidate;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 createCallMethod from './createCallMethod.js';
|
|
16
|
+
import createGetActions from './createGetActions.js';
|
|
17
|
+
import createGetBlockId from './createGetBlockId.js';
|
|
18
|
+
import createGetEvent from './createGetEvent.js';
|
|
19
|
+
import createGetGlobal from './createGetGlobal.js';
|
|
20
|
+
import createGetInput from './createGetInput.js';
|
|
21
|
+
import createGetPageId from './createGetPageId.js';
|
|
22
|
+
import createGetRequestDetails from './createGetRequestDetails.js';
|
|
23
|
+
import createGetState from './createGetState.js';
|
|
24
|
+
import createGetUrlQuery from './createGetUrlQuery.js';
|
|
25
|
+
import createGetUser from './createGetUser.js';
|
|
26
|
+
import createLink from './createLink.js';
|
|
27
|
+
import createLogin from './createLogin.js';
|
|
28
|
+
import createLogout from './createLogout.js';
|
|
29
|
+
import createDisplayMessage from './createDisplayMessage.js';
|
|
30
|
+
import createRequest from './createRequest.js';
|
|
31
|
+
import createReset from './createReset.js';
|
|
32
|
+
import createResetValidation from './createResetValidation.js';
|
|
33
|
+
import createSetGlobal from './createSetGlobal.js';
|
|
34
|
+
import createSetState from './createSetState.js';
|
|
35
|
+
import createValidate from './createValidate.js';
|
|
36
|
+
function getActionMethods(props) {
|
|
37
|
+
return {
|
|
38
|
+
callMethod: createCallMethod(props),
|
|
39
|
+
displayMessage: createDisplayMessage(props),
|
|
40
|
+
getActions: createGetActions(props),
|
|
41
|
+
getBlockId: createGetBlockId(props),
|
|
42
|
+
getEvent: createGetEvent(props),
|
|
43
|
+
getGlobal: createGetGlobal(props),
|
|
44
|
+
getInput: createGetInput(props),
|
|
45
|
+
getPageId: createGetPageId(props),
|
|
46
|
+
getRequestDetails: createGetRequestDetails(props),
|
|
47
|
+
getState: createGetState(props),
|
|
48
|
+
getUrlQuery: createGetUrlQuery(props),
|
|
49
|
+
getUser: createGetUser(props),
|
|
50
|
+
link: createLink(props),
|
|
51
|
+
login: createLogin(props),
|
|
52
|
+
logout: createLogout(props),
|
|
53
|
+
request: createRequest(props),
|
|
54
|
+
reset: createReset(props),
|
|
55
|
+
resetValidation: createResetValidation(props),
|
|
56
|
+
setGlobal: createSetGlobal(props),
|
|
57
|
+
setState: createSetState(props),
|
|
58
|
+
validate: createValidate(props)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export default getActionMethods;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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, type } from '@lowdefy/helpers';
|
|
16
|
+
const getFromObject = ({ arrayIndices , location , method , object , params })=>{
|
|
17
|
+
if (params === true) params = {
|
|
18
|
+
all: true
|
|
19
|
+
};
|
|
20
|
+
if (type.isString(params) || type.isInt(params)) params = {
|
|
21
|
+
key: params
|
|
22
|
+
};
|
|
23
|
+
if (!type.isObject(params)) {
|
|
24
|
+
throw new Error(`Method Error: ${method} params must be of type string, integer, boolean or object. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
25
|
+
}
|
|
26
|
+
if (params.key === null) return get(params, 'default', {
|
|
27
|
+
default: null,
|
|
28
|
+
copy: true
|
|
29
|
+
});
|
|
30
|
+
if (params.all === true) return serializer.copy(object);
|
|
31
|
+
if (!type.isString(params.key) && !type.isInt(params.key)) {
|
|
32
|
+
throw new Error(`Method Error: ${method} params.key must be of type string or integer. Received: ${JSON.stringify(params)} at ${location}.`);
|
|
33
|
+
}
|
|
34
|
+
return get(object, applyArrayIndices(arrayIndices, params.key), {
|
|
35
|
+
default: get(params, 'default', {
|
|
36
|
+
default: null,
|
|
37
|
+
copy: true
|
|
38
|
+
}),
|
|
39
|
+
copy: true
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export default getFromObject;
|
package/dist/createLink.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,32 +13,55 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';
|
|
16
|
-
function createLink({ backLink , lowdefy , newOriginLink , sameOriginLink }) {
|
|
17
|
-
function link(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return backLink();
|
|
16
|
+
function createLink({ backLink , disabledLink , lowdefy , newOriginLink , noLink , sameOriginLink }) {
|
|
17
|
+
function link(props) {
|
|
18
|
+
if (props.disabled === true) {
|
|
19
|
+
return disabledLink(props);
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
21
|
+
if ([
|
|
22
|
+
!props.pageId,
|
|
23
|
+
!props.back,
|
|
24
|
+
!props.home,
|
|
25
|
+
!props.url
|
|
26
|
+
].filter((v)=>!v
|
|
27
|
+
).length > 1) {
|
|
28
|
+
throw Error(`Invalid Link: To avoid ambiguity, only one of 'back', 'home', 'pageId' or 'url' can be defined.`);
|
|
31
29
|
}
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return sameOriginLink(`/${pathname}${lowdefyUrlQuery}`, newTab);
|
|
30
|
+
if (props.back === true) {
|
|
31
|
+
// Cannot set input or urlQuery on back
|
|
32
|
+
return backLink(props);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const query = type.isNone(props.urlQuery) ? '' : `${urlQueryFn.stringify(props.urlQuery)}`;
|
|
35
|
+
if (props.home === true) {
|
|
36
|
+
const pathname = `/${lowdefy.home.configured ? '' : lowdefy.home.pageId}`;
|
|
37
|
+
return sameOriginLink({
|
|
38
|
+
...props,
|
|
39
|
+
pathname,
|
|
40
|
+
query,
|
|
41
|
+
setInput: ()=>{
|
|
42
|
+
lowdefy.inputs[`page:${lowdefy.home.pageId}`] = props.input || {};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
|
-
|
|
46
|
+
if (type.isString(props.pageId)) {
|
|
47
|
+
return sameOriginLink({
|
|
48
|
+
...props,
|
|
49
|
+
pathname: `/${props.pageId}`,
|
|
50
|
+
query,
|
|
51
|
+
setInput: ()=>{
|
|
52
|
+
lowdefy.inputs[`page:${props.pageId}`] = props.input || {};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (type.isString(props.url)) {
|
|
57
|
+
const protocol = props.url.includes(':') ? '' : 'https://';
|
|
58
|
+
return newOriginLink({
|
|
59
|
+
...props,
|
|
60
|
+
url: `${protocol}${props.url}`,
|
|
61
|
+
query
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return noLink(props);
|
|
42
65
|
}
|
|
43
66
|
return link;
|
|
44
67
|
}
|
package/dist/getBlockMatcher.js
CHANGED
package/dist/getContext.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.
|
|
@@ -35,15 +35,20 @@ const blockData = ({ areas , blockId , blocks , events , field , id , layout , p
|
|
|
35
35
|
visible
|
|
36
36
|
})
|
|
37
37
|
;
|
|
38
|
-
|
|
38
|
+
function getContext({ config , lowdefy , resetContext ={
|
|
39
|
+
reset: false,
|
|
40
|
+
setReset: ()=>undefined
|
|
41
|
+
} , }) {
|
|
39
42
|
if (!config) {
|
|
40
43
|
throw new Error('A page must be provided to get context.');
|
|
41
44
|
}
|
|
42
45
|
const { id } = config;
|
|
43
|
-
if (lowdefy.contexts[id] && !
|
|
46
|
+
if (lowdefy.contexts[id] && !resetContext.reset) {
|
|
47
|
+
// memoize context if already created, eg between page transitions, unless the reset flag is raised
|
|
44
48
|
lowdefy.contexts[id]._internal.update();
|
|
45
49
|
return lowdefy.contexts[id];
|
|
46
50
|
}
|
|
51
|
+
resetContext.setReset(false); // lower context reset flag.
|
|
47
52
|
if (!lowdefy.inputs[id]) {
|
|
48
53
|
lowdefy.inputs[id] = {};
|
|
49
54
|
}
|
|
@@ -64,7 +69,6 @@ async function getContext({ config , lowdefy , development =false }) {
|
|
|
64
69
|
context: ctx,
|
|
65
70
|
operators: lowdefy._internal.operators
|
|
66
71
|
});
|
|
67
|
-
await _internal.parser.init();
|
|
68
72
|
_internal.State = new State(ctx);
|
|
69
73
|
_internal.Actions = new Actions(ctx);
|
|
70
74
|
_internal.Requests = new Requests(ctx);
|
|
@@ -82,14 +86,28 @@ async function getContext({ config , lowdefy , development =false }) {
|
|
|
82
86
|
_internal.update = ()=>{
|
|
83
87
|
_internal.RootBlocks.update();
|
|
84
88
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
_internal.runOnInit = async (progress)=>{
|
|
90
|
+
progress();
|
|
91
|
+
if (!_internal.onInitDone) {
|
|
92
|
+
await _internal.RootBlocks.areas.root.blocks[0].triggerEvent({
|
|
93
|
+
name: 'onInit',
|
|
94
|
+
progress
|
|
95
|
+
});
|
|
96
|
+
_internal.update();
|
|
97
|
+
_internal.State.freezeState();
|
|
98
|
+
_internal.onInitDone = true;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
_internal.runOnInitAsync = async (progress)=>{
|
|
102
|
+
if (_internal.onInitDone && !_internal.onInitAsyncDone) {
|
|
103
|
+
await _internal.RootBlocks.areas.root.blocks[0].triggerEvent({
|
|
104
|
+
name: 'onInitAsync',
|
|
105
|
+
progress
|
|
106
|
+
});
|
|
107
|
+
_internal.onInitAsyncDone = true;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
ctx._internal.update();
|
|
93
111
|
lowdefy.contexts[id] = ctx;
|
|
94
112
|
return ctx;
|
|
95
113
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/engine",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -38,17 +38,18 @@
|
|
|
38
38
|
"test": "jest --coverage"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
42
|
-
"@lowdefy/operators": "4.0.0-alpha.
|
|
41
|
+
"@lowdefy/helpers": "4.0.0-alpha.9",
|
|
42
|
+
"@lowdefy/operators": "4.0.0-alpha.9"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@lowdefy/operators-js": "4.0.0-alpha.9",
|
|
45
46
|
"@swc/cli": "0.1.55",
|
|
46
|
-
"@swc/core": "1.2.
|
|
47
|
+
"@swc/core": "1.2.135",
|
|
47
48
|
"@swc/jest": "0.2.17",
|
|
48
|
-
"jest": "27.
|
|
49
|
+
"jest": "27.5.1"
|
|
49
50
|
},
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"access": "public"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
54
55
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/*
|
|
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, type } from '@lowdefy/helpers';
|
|
16
|
-
// context, event, params
|
|
17
|
-
async function CallMethod({ arrayIndices , context , params }) {
|
|
18
|
-
const { blockId , method , args =[] } = params;
|
|
19
|
-
const blockMethod = context._internal.RootBlocks.map[applyArrayIndices(arrayIndices, blockId)].methods[method];
|
|
20
|
-
if (!type.isArray(args)) {
|
|
21
|
-
throw new Error(`Failed to call method "${method}" on block "${blockId}": "args" should be an array. Received "${JSON.stringify(params)}".`);
|
|
22
|
-
}
|
|
23
|
-
if (!type.isFunction(blockMethod)) {
|
|
24
|
-
throw new Error(`Failed to call method "${method}" on block "${blockId}". Check if "${method}" is a valid block method for block "${blockId}". Received "${JSON.stringify(params)}".`);
|
|
25
|
-
}
|
|
26
|
-
return blockMethod(...args);
|
|
27
|
-
}
|
|
28
|
-
export default CallMethod;
|
package/dist/actions/JsAction.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/*
|
|
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 { type, serializer } from '@lowdefy/helpers';
|
|
16
|
-
import actionFns from './index.js';
|
|
17
|
-
async function JsAction({ context , event , params , arrayIndices , blockId }) {
|
|
18
|
-
if (!type.isString(params.name)) {
|
|
19
|
-
throw new Error(`JsAction requires a string for 'params.name'.`);
|
|
20
|
-
}
|
|
21
|
-
if (!type.isNone(params.args) && !type.isArray(params.args)) {
|
|
22
|
-
throw new Error(`JsAction requires a array for 'params.args'.`);
|
|
23
|
-
}
|
|
24
|
-
if (!type.isFunction(context.lowdefy.imports.jsActions[params.name])) {
|
|
25
|
-
throw new Error(`JsAction ${params.name} is not a function.`);
|
|
26
|
-
}
|
|
27
|
-
const actions = {};
|
|
28
|
-
Object.keys(actionFns).forEach((name)=>{
|
|
29
|
-
actions[name] = (actionParams)=>actionFns[name]({
|
|
30
|
-
arrayIndices,
|
|
31
|
-
blockId,
|
|
32
|
-
context,
|
|
33
|
-
event,
|
|
34
|
-
params: actionParams
|
|
35
|
-
})
|
|
36
|
-
;
|
|
37
|
-
});
|
|
38
|
-
return context.lowdefy.imports.jsActions[params.name]({
|
|
39
|
-
...serializer.copy({
|
|
40
|
-
global: context.lowdefy.lowdefyGlobal,
|
|
41
|
-
input: context.lowdefy.inputs[context.id],
|
|
42
|
-
state: context.state,
|
|
43
|
-
urlQuery: context.lowdefy.urlQuery,
|
|
44
|
-
user: context.lowdefy.user
|
|
45
|
-
}),
|
|
46
|
-
actions,
|
|
47
|
-
contextId: context.id,
|
|
48
|
-
pageId: context.pageId,
|
|
49
|
-
requests: {
|
|
50
|
-
...context.requests
|
|
51
|
-
}
|
|
52
|
-
}, ...params.args || []);
|
|
53
|
-
}
|
|
54
|
-
export default JsAction;
|
package/dist/actions/Link.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
-
async function Link({ context , params }) {
|
|
17
|
-
const linkParams = type.isString(params) ? {
|
|
18
|
-
pageId: params
|
|
19
|
-
} : params;
|
|
20
|
-
try {
|
|
21
|
-
context._internal.lowdefy._internal.link(linkParams);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.log(error);
|
|
24
|
-
throw new Error(`Invalid Link, check action params. Received "${JSON.stringify(params)}".`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export default Link;
|
package/dist/actions/ScrollTo.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
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
|
-
*/ async function ScrollTo({ context , params ={} }) {
|
|
16
|
-
if (params.blockId) {
|
|
17
|
-
const element = context._internal.lowdefy._internal.document.getElementById(params.blockId);
|
|
18
|
-
if (element) {
|
|
19
|
-
element.scrollIntoView(params.options);
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
context._internal.lowdefy._internal.window.scrollTo(params);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export default ScrollTo;
|