@lowdefy/client 4.0.0-rc.1 → 4.0.0-rc.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/Client.js +6 -3
- package/dist/Context.js +1 -1
- package/dist/DisplayMessage.js +1 -1
- package/dist/ErrorBoundary.js +2 -2
- package/dist/ErrorPage.js +1 -1
- package/dist/Head.js +1 -1
- package/dist/MountEvents.js +1 -1
- package/dist/ProgressBarController.js +1 -1
- package/dist/auth/createAuthMethods.js +13 -8
- package/dist/block/Block.js +1 -1
- package/dist/block/CategorySwitch.js +1 -1
- package/dist/block/Container.js +1 -1
- package/dist/block/List.js +1 -1
- package/dist/block/LoadingBlock.js +1 -1
- package/dist/block/LoadingContainer.js +1 -1
- package/dist/block/LoadingList.js +1 -1
- package/dist/{callRequest.js → createCallRequest.js} +12 -9
- package/dist/createIcon.js +10 -23
- package/dist/createLinkComponent.js +6 -6
- package/dist/initLowdefyContext.js +41 -44
- package/dist/request.js +4 -4
- package/dist/setupLink.js +4 -4
- package/package.json +13 -13
package/dist/Client.js
CHANGED
|
@@ -13,20 +13,23 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
|
+
import { serializer } from '@lowdefy/helpers';
|
|
16
17
|
import Block from './block/Block.js';
|
|
17
18
|
import Context from './Context.js';
|
|
18
19
|
import DisplayMessage from './DisplayMessage.js';
|
|
19
20
|
import Head from './Head.js';
|
|
20
21
|
import ProgressBarController from './ProgressBarController.js';
|
|
21
22
|
import initLowdefyContext from './initLowdefyContext.js';
|
|
22
|
-
const Client = ({ auth
|
|
23
|
+
const Client = ({ auth, Components, config: rawConfig, lowdefy, resetContext = {
|
|
23
24
|
reset: false,
|
|
24
25
|
setReset: ()=>undefined
|
|
25
|
-
}
|
|
26
|
-
const
|
|
26
|
+
}, router, stage, types, window })=>{
|
|
27
|
+
const config = serializer.deserialize(rawConfig);
|
|
28
|
+
initLowdefyContext({
|
|
27
29
|
auth,
|
|
28
30
|
Components,
|
|
29
31
|
config,
|
|
32
|
+
lowdefy,
|
|
30
33
|
router,
|
|
31
34
|
stage,
|
|
32
35
|
types,
|
package/dist/Context.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
import getContext from '@lowdefy/engine';
|
|
17
17
|
import MountEvents from './MountEvents.js';
|
|
18
|
-
const Context = ({ children
|
|
18
|
+
const Context = ({ children, config, lowdefy, resetContext })=>{
|
|
19
19
|
const context = getContext({
|
|
20
20
|
config,
|
|
21
21
|
lowdefy,
|
package/dist/DisplayMessage.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
17
|
-
const DisplayMessage = ({ Component
|
|
17
|
+
const DisplayMessage = ({ Component, id, methods })=>{
|
|
18
18
|
return /*#__PURE__*/ React.createElement(Component, {
|
|
19
19
|
blockId: id,
|
|
20
20
|
key: id,
|
package/dist/ErrorBoundary.js
CHANGED
|
@@ -22,8 +22,8 @@ let ErrorBoundary = class ErrorBoundary extends Component {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
render() {
|
|
25
|
-
const { children
|
|
26
|
-
const { hasError
|
|
25
|
+
const { children, description, fallback, fullPage, message, name } = this.props;
|
|
26
|
+
const { hasError, error } = this.state;
|
|
27
27
|
if (hasError) {
|
|
28
28
|
if (fallback) {
|
|
29
29
|
return fallback(error);
|
package/dist/ErrorPage.js
CHANGED
|
@@ -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 React from 'react';
|
|
16
|
-
const ErrorPage = ({ code
|
|
16
|
+
const ErrorPage = ({ code, description, message, name })=>/*#__PURE__*/ React.createElement("div", {
|
|
17
17
|
style: {
|
|
18
18
|
height: '100%',
|
|
19
19
|
fontFamily: 'system-ui',
|
package/dist/Head.js
CHANGED
|
@@ -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 React from 'react';
|
|
16
|
-
const BindHead = ({ Component
|
|
16
|
+
const BindHead = ({ Component, properties })=>{
|
|
17
17
|
return /*#__PURE__*/ React.createElement(Component, null, /*#__PURE__*/ React.createElement("title", null, properties.title));
|
|
18
18
|
};
|
|
19
19
|
export default BindHead;
|
package/dist/MountEvents.js
CHANGED
|
@@ -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 React, { useEffect, useState } from 'react';
|
|
16
|
-
const MountEvents = ({ children
|
|
16
|
+
const MountEvents = ({ children, context, triggerEvent, triggerEventAsync })=>{
|
|
17
17
|
const [loading, setLoading] = useState(true);
|
|
18
18
|
const [error, setError] = useState(null);
|
|
19
19
|
useEffect(()=>{
|
|
@@ -49,7 +49,7 @@ function reducer(state, action) {
|
|
|
49
49
|
throw new Error('Invalid action type for ProgressBarController reducer.');
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const ProgressBarController = ({ id
|
|
52
|
+
const ProgressBarController = ({ id, lowdefy, resetContext })=>{
|
|
53
53
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
54
54
|
const ProgressBar = lowdefy._internal.blockComponents.ProgressBar;
|
|
55
55
|
lowdefy._internal.progress.state = state;
|
|
@@ -13,8 +13,8 @@
|
|
|
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 getCallbackUrl({ lowdefy
|
|
17
|
-
const { home
|
|
16
|
+
function getCallbackUrl({ lowdefy, callbackUrl = {} }) {
|
|
17
|
+
const { home, pageId, urlQuery, url } = callbackUrl;
|
|
18
18
|
if ([
|
|
19
19
|
!home,
|
|
20
20
|
!pageId,
|
|
@@ -34,14 +34,14 @@ function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
|
|
|
34
34
|
}
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
|
-
function createAuthMethods(
|
|
37
|
+
function createAuthMethods(lowdefy, auth) {
|
|
38
38
|
// login and logout are Lowdefy function that handle action params
|
|
39
39
|
// signIn and signOut are the next-auth methods
|
|
40
|
-
function login({ authUrl
|
|
40
|
+
function login({ authUrl, callbackUrl, providerId, ...rest } = {}) {
|
|
41
41
|
if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
|
|
42
42
|
providerId = auth.authConfig.providers[0].id;
|
|
43
43
|
}
|
|
44
|
-
auth.signIn(providerId, {
|
|
44
|
+
return auth.signIn(providerId, {
|
|
45
45
|
...rest,
|
|
46
46
|
callbackUrl: getCallbackUrl({
|
|
47
47
|
lowdefy,
|
|
@@ -49,8 +49,8 @@ function createAuthMethods({ lowdefy , auth }) {
|
|
|
49
49
|
})
|
|
50
50
|
}, authUrl?.urlQuery);
|
|
51
51
|
}
|
|
52
|
-
function logout({ callbackUrl
|
|
53
|
-
auth.signOut({
|
|
52
|
+
function logout({ callbackUrl, redirect } = {}) {
|
|
53
|
+
return auth.signOut({
|
|
54
54
|
callbackUrl: getCallbackUrl({
|
|
55
55
|
lowdefy,
|
|
56
56
|
callbackUrl
|
|
@@ -58,9 +58,14 @@ function createAuthMethods({ lowdefy , auth }) {
|
|
|
58
58
|
redirect
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
async function updateSession() {
|
|
62
|
+
const session = await auth.getSession();
|
|
63
|
+
lowdefy.user = session?.user ?? null;
|
|
64
|
+
}
|
|
61
65
|
return {
|
|
62
66
|
login,
|
|
63
|
-
logout
|
|
67
|
+
logout,
|
|
68
|
+
updateSession
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
71
|
export default createAuthMethods;
|
package/dist/block/Block.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import CategorySwitch from './CategorySwitch.js';
|
|
17
17
|
import ErrorBoundary from '../ErrorBoundary.js';
|
|
18
18
|
import MountEvents from '../MountEvents.js';
|
|
19
|
-
const Block = ({ block
|
|
19
|
+
const Block = ({ block, Blocks, context, lowdefy, parentLoading })=>{
|
|
20
20
|
const [updates, setUpdate] = useState(0);
|
|
21
21
|
lowdefy._internal.updaters[block.id] = ()=>setUpdate(updates + 1);
|
|
22
22
|
return /*#__PURE__*/ React.createElement(ErrorBoundary, null, /*#__PURE__*/ React.createElement(MountEvents, {
|
|
@@ -19,7 +19,7 @@ import { type } from '@lowdefy/helpers';
|
|
|
19
19
|
import Container from './Container.js';
|
|
20
20
|
import List from './List.js';
|
|
21
21
|
import LoadingBlock from './LoadingBlock.js';
|
|
22
|
-
const CategorySwitch = ({ block
|
|
22
|
+
const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
|
|
23
23
|
if (!block.eval) return null; // TODO: check Renderer updates before eval is executed for the first time on lists. See #520
|
|
24
24
|
if (block.eval.visible === false) return /*#__PURE__*/ React.createElement("div", {
|
|
25
25
|
id: `vs-${block.blockId}`,
|
package/dist/block/Container.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import Block from './Block.js';
|
|
19
|
-
const Container = ({ block
|
|
19
|
+
const Container = ({ block, Blocks, Component, context, loading, lowdefy })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
// eslint-disable-next-line prefer-destructuring
|
|
22
22
|
const areas = Blocks.subBlocks[block.id][0].areas;
|
package/dist/block/List.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import Block from './Block.js';
|
|
19
|
-
const List = ({ block
|
|
19
|
+
const List = ({ block, Blocks, Component, context, loading, lowdefy })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
const contentList = [];
|
|
22
22
|
Blocks.subBlocks[block.id].forEach((SBlock)=>{
|
|
@@ -29,7 +29,7 @@ const blockMethods = {
|
|
|
29
29
|
triggerEvent: ()=>{},
|
|
30
30
|
unshiftItem: ()=>{}
|
|
31
31
|
};
|
|
32
|
-
const LoadingBlock = ({ blockId
|
|
32
|
+
const LoadingBlock = ({ blockId, blockLayout, blockProperties, blockStyle, context, lowdefy, skeleton })=>{
|
|
33
33
|
let Component = lowdefy._internal.blockComponents[skeleton.type];
|
|
34
34
|
useEffect(()=>{
|
|
35
35
|
if (!lowdefy._internal.blockComponents[skeleton.type]) {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import LoadingBlock from './LoadingBlock.js';
|
|
19
|
-
const LoadingContainer = ({ blockId
|
|
19
|
+
const LoadingContainer = ({ blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
// eslint-disable-next-line prefer-destructuring
|
|
22
22
|
Object.keys(skeleton.areas).forEach((areaKey, i)=>{
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import LoadingBlock from './LoadingBlock.js';
|
|
19
|
-
const LoadingList = ({ blockId
|
|
19
|
+
const LoadingList = ({ blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
const contentList = [];
|
|
22
22
|
new Array(3).forEach(()=>{
|
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import request from './request.js';
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
function createCallRequest({ basePath }) {
|
|
17
|
+
function callRequest({ pageId, payload, requestId }) {
|
|
18
|
+
return request({
|
|
19
|
+
url: `${basePath}/api/request/${pageId}/${requestId}`,
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: {
|
|
22
|
+
payload
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return callRequest;
|
|
24
27
|
}
|
|
25
|
-
export default
|
|
28
|
+
export default createCallRequest;
|
package/dist/createIcon.js
CHANGED
|
@@ -12,21 +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
|
-
*/
|
|
16
|
-
_extends = Object.assign || function(target) {
|
|
17
|
-
for(var i = 1; i < arguments.length; i++){
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for(var key in source){
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
import React from 'react';
|
|
15
|
+
*/ import React from 'react';
|
|
30
16
|
import classNames from 'classnames';
|
|
31
17
|
import { omit, type } from '@lowdefy/helpers';
|
|
32
18
|
import Icon from '@ant-design/icons';
|
|
@@ -50,7 +36,7 @@ const lowdefyProps = [
|
|
|
50
36
|
const createIcon = (Icons)=>{
|
|
51
37
|
const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
|
|
52
38
|
const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
|
|
53
|
-
const IconBlock = ({ blockId
|
|
39
|
+
const IconBlock = ({ blockId, events, methods, onClick, properties, ...props })=>{
|
|
54
40
|
const propertiesObj = type.isString(properties) ? {
|
|
55
41
|
name: properties
|
|
56
42
|
} : properties;
|
|
@@ -77,22 +63,23 @@ const createIcon = (Icons)=>{
|
|
|
77
63
|
if (!IconComp) {
|
|
78
64
|
IconComp = AiOutlineExclamationCircle;
|
|
79
65
|
}
|
|
80
|
-
return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters,
|
|
81
|
-
fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle,
|
|
66
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, iconProps) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
67
|
+
fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, {
|
|
82
68
|
...iconProps,
|
|
83
69
|
color: '#F00'
|
|
84
|
-
})
|
|
85
|
-
}, /*#__PURE__*/ React.createElement(IconComp,
|
|
70
|
+
})
|
|
71
|
+
}, /*#__PURE__*/ React.createElement(IconComp, {
|
|
86
72
|
id: blockId,
|
|
87
73
|
onClick: onClick || events.onClick && (()=>methods.triggerEvent({
|
|
88
74
|
name: 'onClick'
|
|
89
75
|
})),
|
|
90
76
|
size: propertiesObj.size,
|
|
91
|
-
title: propertiesObj.title
|
|
92
|
-
|
|
77
|
+
title: propertiesObj.title,
|
|
78
|
+
...iconProps
|
|
79
|
+
})));
|
|
93
80
|
};
|
|
94
81
|
const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
|
|
95
|
-
component: ()=>/*#__PURE__*/ React.createElement(IconBlock,
|
|
82
|
+
component: ()=>/*#__PURE__*/ React.createElement(IconBlock, all)
|
|
96
83
|
});
|
|
97
84
|
AntIcon.defaultProps = blockDefaultProps;
|
|
98
85
|
return AntIcon;
|
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { createLink } from '@lowdefy/engine';
|
|
3
3
|
import { type } from '@lowdefy/helpers';
|
|
4
4
|
const createLinkComponent = (lowdefy, Link)=>{
|
|
5
|
-
const { window
|
|
6
|
-
const backLink = ({ ariaLabel
|
|
5
|
+
const { window } = lowdefy._internal.globals;
|
|
6
|
+
const backLink = ({ ariaLabel, children, className, id, onClick = ()=>{}, rel })=>/*#__PURE__*/ React.createElement("a", {
|
|
7
7
|
id: id,
|
|
8
8
|
className: className,
|
|
9
9
|
rel: rel,
|
|
@@ -13,7 +13,7 @@ const createLinkComponent = (lowdefy, Link)=>{
|
|
|
13
13
|
onClick(...params);
|
|
14
14
|
}
|
|
15
15
|
}, type.isFunction(children) ? children(id) : children);
|
|
16
|
-
const newOriginLink = ({ ariaLabel
|
|
16
|
+
const newOriginLink = ({ ariaLabel, children, className, href, id, onClick = ()=>{}, newTab, pageId, query, rel, url })=>{
|
|
17
17
|
return /*#__PURE__*/ React.createElement("a", {
|
|
18
18
|
id: id,
|
|
19
19
|
"aria-label": ariaLabel,
|
|
@@ -27,14 +27,14 @@ const createLinkComponent = (lowdefy, Link)=>{
|
|
|
27
27
|
}
|
|
28
28
|
}, type.isFunction(children) ? children(pageId || url || id) : children);
|
|
29
29
|
};
|
|
30
|
-
const sameOriginLink = ({ ariaLabel
|
|
30
|
+
const sameOriginLink = ({ ariaLabel, children, className, id, newTab, onClick = ()=>{}, pageId, pathname, query, rel, replace, scroll, setInput, url })=>{
|
|
31
31
|
if (newTab) {
|
|
32
32
|
return(// eslint-disable-next-line react/jsx-no-target-blank
|
|
33
33
|
/*#__PURE__*/ React.createElement("a", {
|
|
34
34
|
id: id,
|
|
35
35
|
"aria-label": ariaLabel,
|
|
36
36
|
className: className,
|
|
37
|
-
href: `${window.location.origin}${lowdefy.
|
|
37
|
+
href: `${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`,
|
|
38
38
|
rel: rel || 'noopener noreferrer',
|
|
39
39
|
target: "_blank",
|
|
40
40
|
onClick: async (...params)=>{
|
|
@@ -61,7 +61,7 @@ const createLinkComponent = (lowdefy, Link)=>{
|
|
|
61
61
|
}
|
|
62
62
|
}, type.isFunction(children) ? children(pageId || url || id) : children));
|
|
63
63
|
};
|
|
64
|
-
const noLink = ({ className
|
|
64
|
+
const noLink = ({ className, children, id, onClick = ()=>{} })=>/*#__PURE__*/ React.createElement("span", {
|
|
65
65
|
id: id,
|
|
66
66
|
className: className,
|
|
67
67
|
onClick: onClick
|
|
@@ -12,60 +12,57 @@
|
|
|
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
|
|
15
|
+
*/ import createAuthMethods from './auth/createAuthMethods.js';
|
|
16
|
+
import createCallRequest from './createCallRequest.js';
|
|
16
17
|
import createIcon from './createIcon.js';
|
|
17
|
-
import createAuthMethods from './auth/createAuthMethods.js';
|
|
18
18
|
import createLinkComponent from './createLinkComponent.js';
|
|
19
19
|
import setupLink from './setupLink.js';
|
|
20
|
-
|
|
21
|
-
_internal
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return ()=>undefined;
|
|
28
|
-
},
|
|
29
|
-
link: ()=>undefined,
|
|
30
|
-
progress: {
|
|
31
|
-
state: {
|
|
32
|
-
progress: 0
|
|
20
|
+
function initLowdefyContext({ auth, Components, config, lowdefy, router, stage, types, window }) {
|
|
21
|
+
if (!lowdefy._internal?.initialised) {
|
|
22
|
+
lowdefy._internal = {
|
|
23
|
+
actions: types.actions,
|
|
24
|
+
blockComponents: types.blocks,
|
|
25
|
+
components: {
|
|
26
|
+
Icon: createIcon(types.icons)
|
|
33
27
|
},
|
|
34
|
-
|
|
28
|
+
displayMessage: ({ content })=>{
|
|
29
|
+
console.log(content);
|
|
30
|
+
return ()=>undefined;
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
document: window.document,
|
|
34
|
+
fetch: window.fetch,
|
|
35
|
+
window
|
|
36
|
+
},
|
|
37
|
+
initialised: true,
|
|
38
|
+
link: ()=>undefined,
|
|
39
|
+
operators: types.operators,
|
|
40
|
+
progress: {
|
|
41
|
+
state: {
|
|
42
|
+
progress: 0
|
|
43
|
+
},
|
|
44
|
+
dispatch: ()=>undefined
|
|
45
|
+
},
|
|
46
|
+
router,
|
|
47
|
+
updaters: {}
|
|
48
|
+
};
|
|
49
|
+
lowdefy.basePath = router.basePath;
|
|
50
|
+
lowdefy.contexts = {};
|
|
51
|
+
lowdefy.inputs = {};
|
|
52
|
+
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
53
|
+
lowdefy._internal.auth = createAuthMethods(lowdefy, auth);
|
|
54
|
+
lowdefy._internal.callRequest = createCallRequest(lowdefy);
|
|
55
|
+
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
56
|
+
lowdefy._internal.link = setupLink(lowdefy);
|
|
57
|
+
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
58
|
+
if (stage === 'dev') {
|
|
59
|
+
window.lowdefy = lowdefy;
|
|
35
60
|
}
|
|
36
|
-
},
|
|
37
|
-
contexts: {},
|
|
38
|
-
inputs: {},
|
|
39
|
-
lowdefyGlobal: {}
|
|
40
|
-
};
|
|
41
|
-
function initLowdefyContext({ auth , Components , config , router , stage , types , window }) {
|
|
42
|
-
if (stage === 'dev') {
|
|
43
|
-
window.lowdefy = lowdefy;
|
|
44
61
|
}
|
|
45
|
-
lowdefy.basePath = router.basePath;
|
|
46
62
|
lowdefy.home = config.rootConfig.home || {};
|
|
47
|
-
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
48
63
|
lowdefy.menus = config.rootConfig.menus;
|
|
49
64
|
lowdefy.pageId = config.pageConfig.pageId;
|
|
50
65
|
lowdefy.user = auth?.session?.user ?? null;
|
|
51
|
-
lowdefy._internal.globals = {
|
|
52
|
-
document: window.document,
|
|
53
|
-
fetch: window.fetch,
|
|
54
|
-
window
|
|
55
|
-
};
|
|
56
|
-
lowdefy._internal.router = router;
|
|
57
|
-
lowdefy._internal.link = setupLink(lowdefy);
|
|
58
|
-
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
59
|
-
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
60
|
-
lowdefy._internal.components.Icon = createIcon(types.icons);
|
|
61
|
-
lowdefy._internal.actions = types.actions;
|
|
62
|
-
lowdefy._internal.blockComponents = types.blocks;
|
|
63
|
-
lowdefy._internal.operators = types.operators;
|
|
64
|
-
// TODO: discuss not using object arguments
|
|
65
|
-
lowdefy._internal.auth = createAuthMethods({
|
|
66
|
-
lowdefy,
|
|
67
|
-
auth
|
|
68
|
-
});
|
|
69
66
|
return lowdefy;
|
|
70
67
|
}
|
|
71
68
|
export default initLowdefyContext;
|
package/dist/request.js
CHANGED
|
@@ -12,7 +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 request({ url
|
|
15
|
+
*/ async function request({ url, method = 'GET', body }) {
|
|
16
16
|
const res = await fetch(url, {
|
|
17
17
|
method,
|
|
18
18
|
headers: {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
});
|
|
23
23
|
if (!res.ok) {
|
|
24
24
|
// TODO: check
|
|
25
|
-
const
|
|
25
|
+
const body = await res.json();
|
|
26
26
|
console.log(res);
|
|
27
|
-
console.log(
|
|
28
|
-
throw new Error(
|
|
27
|
+
console.log(body);
|
|
28
|
+
throw new Error(body.message || 'Request error');
|
|
29
29
|
}
|
|
30
30
|
return res.json();
|
|
31
31
|
}
|
package/dist/setupLink.js
CHANGED
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { createLink } from '@lowdefy/engine';
|
|
16
16
|
function setupLink(lowdefy) {
|
|
17
|
-
const { router
|
|
18
|
-
const { window
|
|
17
|
+
const { router } = lowdefy._internal;
|
|
18
|
+
const { window } = lowdefy._internal.globals;
|
|
19
19
|
const backLink = ()=>router.back();
|
|
20
20
|
const disabledLink = ()=>{};
|
|
21
|
-
const newOriginLink = ({ url
|
|
21
|
+
const newOriginLink = ({ url, query, newTab })=>{
|
|
22
22
|
if (newTab) {
|
|
23
23
|
return window.open(`${url}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
24
24
|
} else {
|
|
25
25
|
return window.location.assign(`${url}${query ? `?${query}` : ''}`);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
const sameOriginLink = ({ newTab
|
|
28
|
+
const sameOriginLink = ({ newTab, pathname, query, setInput })=>{
|
|
29
29
|
if (newTab) {
|
|
30
30
|
return window.open(`${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
31
31
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/client",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -41,31 +41,31 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@ant-design/icons": "4.8.0",
|
|
44
|
-
"@lowdefy/block-utils": "4.0.0-rc.
|
|
45
|
-
"@lowdefy/engine": "4.0.0-rc.
|
|
46
|
-
"@lowdefy/helpers": "4.0.0-rc.
|
|
47
|
-
"@lowdefy/layout": "4.0.0-rc.
|
|
44
|
+
"@lowdefy/block-utils": "4.0.0-rc.10",
|
|
45
|
+
"@lowdefy/engine": "4.0.0-rc.10",
|
|
46
|
+
"@lowdefy/helpers": "4.0.0-rc.10",
|
|
47
|
+
"@lowdefy/layout": "4.0.0-rc.10",
|
|
48
48
|
"classnames": "2.3.2",
|
|
49
49
|
"react": "18.2.0",
|
|
50
50
|
"react-dom": "18.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@emotion/jest": "11.10.5",
|
|
54
|
-
"@jest/globals": "28.1.
|
|
55
|
-
"@lowdefy/jest-yaml-transform": "4.0.0-rc.
|
|
56
|
-
"@swc/cli": "0.1.
|
|
57
|
-
"@swc/core": "1.3.
|
|
58
|
-
"@swc/jest": "0.2.
|
|
54
|
+
"@jest/globals": "28.1.3",
|
|
55
|
+
"@lowdefy/jest-yaml-transform": "4.0.0-rc.10",
|
|
56
|
+
"@swc/cli": "0.1.62",
|
|
57
|
+
"@swc/core": "1.3.70",
|
|
58
|
+
"@swc/jest": "0.2.27",
|
|
59
59
|
"@testing-library/dom": "8.19.1",
|
|
60
60
|
"@testing-library/react": "13.4.0",
|
|
61
61
|
"@testing-library/user-event": "14.4.3",
|
|
62
62
|
"copyfiles": "2.4.1",
|
|
63
|
-
"jest": "28.1.
|
|
64
|
-
"jest-environment-jsdom": "28.1.
|
|
63
|
+
"jest": "28.1.3",
|
|
64
|
+
"jest-environment-jsdom": "28.1.3",
|
|
65
65
|
"jest-serializer-html": "7.1.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
|
|
71
71
|
}
|