@lowdefy/engine 4.0.0-alpha.5 → 4.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions.js +70 -68
- package/dist/Blocks.js +41 -61
- package/dist/Events.js +12 -15
- package/dist/Requests.js +14 -16
- package/dist/State.js +7 -7
- package/dist/actions/createCallMethod.js +29 -0
- package/dist/actions/{Request.js → createDisplayMessage.js} +5 -8
- package/dist/actions/createGetActions.js +27 -0
- package/dist/actions/{Logout.js → createGetBlockId.js} +5 -3
- 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} +5 -3
- package/dist/actions/createGetRequestDetails.js +27 -0
- package/dist/actions/{Wait.js → createGetState.js} +12 -8
- 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} +10 -9
- package/dist/actions/{Reset.js → createReset.js} +7 -5
- package/dist/actions/{ResetValidation.js → createResetValidation.js} +5 -3
- package/dist/actions/{SetGlobal.js → createSetGlobal.js} +10 -8
- package/dist/actions/{SetState.js → createSetState.js} +9 -7
- package/dist/actions/{Validate.js → createValidate.js} +9 -7
- package/dist/actions/getActionMethods.js +61 -0
- package/dist/actions/getFromObject.js +42 -0
- package/dist/createLink.js +45 -22
- package/dist/getContext.js +6 -10
- 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/getContext.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "4.0.0-alpha.8",
|
|
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.8",
|
|
42
|
+
"@lowdefy/operators": "4.0.0-alpha.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@swc/
|
|
47
|
-
"@swc/
|
|
48
|
-
"jest": "
|
|
45
|
+
"@lowdefy/operators-js": "4.0.0-alpha.8",
|
|
46
|
+
"@swc/cli": "0.1.55",
|
|
47
|
+
"@swc/core": "1.2.135",
|
|
48
|
+
"@swc/jest": "0.2.17",
|
|
49
|
+
"jest": "27.5.1"
|
|
49
50
|
},
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"access": "public"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
|
|
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,55 +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
|
-
};
|
|
29
|
-
Object.keys(actionFns).forEach((name)=>{
|
|
30
|
-
actions[name] = (actionParams)=>actionFns[name]({
|
|
31
|
-
arrayIndices,
|
|
32
|
-
blockId,
|
|
33
|
-
context,
|
|
34
|
-
event,
|
|
35
|
-
params: actionParams
|
|
36
|
-
})
|
|
37
|
-
;
|
|
38
|
-
});
|
|
39
|
-
return context.lowdefy.imports.jsActions[params.name]({
|
|
40
|
-
...serializer.copy({
|
|
41
|
-
global: context.lowdefy.lowdefyGlobal,
|
|
42
|
-
input: context.lowdefy.inputs[context.id],
|
|
43
|
-
state: context.state,
|
|
44
|
-
urlQuery: context.lowdefy.urlQuery,
|
|
45
|
-
user: context.lowdefy.user
|
|
46
|
-
}),
|
|
47
|
-
actions,
|
|
48
|
-
contextId: context.id,
|
|
49
|
-
pageId: context.pageId,
|
|
50
|
-
requests: {
|
|
51
|
-
...context.requests
|
|
52
|
-
}
|
|
53
|
-
}, ...params.args || []);
|
|
54
|
-
}
|
|
55
|
-
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,26 +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
|
-
} }) {
|
|
17
|
-
if (params.blockId) {
|
|
18
|
-
const element = context._internal.lowdefy._internal.document.getElementById(params.blockId);
|
|
19
|
-
if (element) {
|
|
20
|
-
element.scrollIntoView(params.options);
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
context._internal.lowdefy._internal.window.scrollTo(params);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export default ScrollTo;
|
package/dist/actions/Throw.js
DELETED
|
@@ -1,40 +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
|
-
let ThrowActionError = class ThrowActionError extends Error {
|
|
17
|
-
constructor(message, { blockId: blockId1 , context: context1 , metaData }){
|
|
18
|
-
super(message);
|
|
19
|
-
this.blockId = blockId1;
|
|
20
|
-
this.metaData = metaData;
|
|
21
|
-
this.name = 'ThrowError';
|
|
22
|
-
this.pageId = context1.pageId;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
function Throw({ blockId , context , params ={
|
|
26
|
-
} }) {
|
|
27
|
-
if (params.throw === false || type.isNone(params.throw)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (params.throw === true) {
|
|
31
|
-
throw new ThrowActionError(params.message, {
|
|
32
|
-
blockId,
|
|
33
|
-
context,
|
|
34
|
-
metaData: params.metaData
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`Invalid Throw, check action params. Received "${JSON.stringify(params)}".`);
|
|
38
|
-
}
|
|
39
|
-
export default Throw;
|
|
40
|
-
export { Throw, ThrowActionError };
|
package/dist/actions/index.js
DELETED
|
@@ -1,46 +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 CallMethod from './CallMethod.js';
|
|
16
|
-
import JsAction from './JsAction.js';
|
|
17
|
-
import Link from './Link.js';
|
|
18
|
-
import Login from './Login.js';
|
|
19
|
-
import Logout from './Logout.js';
|
|
20
|
-
import Message from './Message.js';
|
|
21
|
-
import Request from './Request.js';
|
|
22
|
-
import Reset from './Reset.js';
|
|
23
|
-
import ResetValidation from './ResetValidation.js';
|
|
24
|
-
import ScrollTo from './ScrollTo.js';
|
|
25
|
-
import SetGlobal from './SetGlobal.js';
|
|
26
|
-
import SetState from './SetState.js';
|
|
27
|
-
import Throw from './Throw.js';
|
|
28
|
-
import Validate from './Validate.js';
|
|
29
|
-
import Wait from './Wait.js';
|
|
30
|
-
export default {
|
|
31
|
-
CallMethod,
|
|
32
|
-
JsAction,
|
|
33
|
-
Link,
|
|
34
|
-
Login,
|
|
35
|
-
Logout,
|
|
36
|
-
Message,
|
|
37
|
-
Request,
|
|
38
|
-
Reset,
|
|
39
|
-
ResetValidation,
|
|
40
|
-
ScrollTo,
|
|
41
|
-
SetGlobal,
|
|
42
|
-
SetState,
|
|
43
|
-
Throw,
|
|
44
|
-
Validate,
|
|
45
|
-
Wait
|
|
46
|
-
};
|