@lowdefy/client 4.0.0-alpha.10 → 4.0.0-alpha.13

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 CHANGED
@@ -19,11 +19,12 @@ import DisplayMessage from './DisplayMessage.js';
19
19
  import Head from './Head.js';
20
20
  import ProgressBarController from './ProgressBarController.js';
21
21
  import initLowdefyContext from './initLowdefyContext.js';
22
- const Client = ({ Components , config , resetContext ={
22
+ const Client = ({ auth , Components , config , resetContext ={
23
23
  reset: false,
24
24
  setReset: ()=>undefined
25
25
  } , router , stage , types , window , })=>{
26
26
  const lowdefy = initLowdefyContext({
27
+ auth,
27
28
  Components,
28
29
  config,
29
30
  router,
@@ -31,7 +32,7 @@ const Client = ({ Components , config , resetContext ={
31
32
  types,
32
33
  window
33
34
  });
34
- return(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ProgressBarController, {
35
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ProgressBarController, {
35
36
  id: "lowdefy-progress-bar",
36
37
  key: `${config.pageConfig.id}-progress-bar`,
37
38
  lowdefy: lowdefy,
@@ -52,16 +53,16 @@ const Client = ({ Components , config , resetContext ={
52
53
  resetContext: resetContext
53
54
  }, (context)=>{
54
55
  if (!context._internal.onInitDone) return '';
55
- return(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Head, {
56
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Head, {
56
57
  Component: Components.Head,
57
- properties: context._internal.RootBlocks.map[config.pageConfig.id].eval.properties
58
+ properties: context._internal.RootBlocks.map[config.pageConfig.blockId].eval.properties
58
59
  }), /*#__PURE__*/ React.createElement(Block, {
59
- block: context._internal.RootBlocks.map[config.pageConfig.id],
60
+ block: context._internal.RootBlocks.map[config.pageConfig.blockId],
60
61
  Blocks: context._internal.RootBlocks,
61
62
  context: context,
62
63
  lowdefy: lowdefy,
63
64
  parentLoading: false
64
- })));
65
- })));
65
+ }));
66
+ }));
66
67
  };
67
68
  export default Client;
package/dist/Context.js CHANGED
@@ -21,7 +21,7 @@ const Context = ({ children , config , lowdefy , resetContext })=>{
21
21
  lowdefy,
22
22
  resetContext
23
23
  });
24
- return(/*#__PURE__*/ React.createElement(MountEvents, {
24
+ return /*#__PURE__*/ React.createElement(MountEvents, {
25
25
  context: context,
26
26
  triggerEvent: async ()=>{
27
27
  await context._internal.runOnInit(()=>{
@@ -40,6 +40,6 @@ const Context = ({ children , config , lowdefy , resetContext })=>{
40
40
  }, (loadingOnInit)=>{
41
41
  if (loadingOnInit) return '';
42
42
  return children(context);
43
- }));
43
+ });
44
44
  };
45
45
  export default Context;
@@ -15,7 +15,7 @@
15
15
  */ import React from 'react';
16
16
  import { makeCssClass } from '@lowdefy/block-utils';
17
17
  const DisplayMessage = ({ Component , id , methods })=>{
18
- return(/*#__PURE__*/ React.createElement(Component, {
18
+ return /*#__PURE__*/ React.createElement(Component, {
19
19
  blockId: id,
20
20
  key: id,
21
21
  methods: {
@@ -24,6 +24,6 @@ const DisplayMessage = ({ Component , id , methods })=>{
24
24
  triggerEvent: ()=>undefined
25
25
  },
26
26
  properties: {}
27
- }));
27
+ });
28
28
  };
29
29
  export default DisplayMessage;
@@ -29,12 +29,12 @@ let ErrorBoundary = class ErrorBoundary extends Component {
29
29
  return fallback(error);
30
30
  }
31
31
  if (fullPage) {
32
- return(/*#__PURE__*/ React.createElement(ErrorPage, {
32
+ return /*#__PURE__*/ React.createElement(ErrorPage, {
33
33
  code: error.number,
34
34
  description: description || error.description,
35
35
  message: message || error.message,
36
36
  name: name || error.name
37
- }));
37
+ });
38
38
  }
39
39
  // Throw to console but fail silently to user?
40
40
  return '';
package/dist/ErrorPage.js CHANGED
@@ -56,6 +56,5 @@ const ErrorPage = ({ code , description , message , name })=>/*#__PURE__*/ Reac
56
56
  }
57
57
  }, /*#__PURE__*/ React.createElement("a", {
58
58
  href: "/"
59
- }, "Return to home page"))))
60
- ;
59
+ }, "Return to home page"))));
61
60
  export default ErrorPage;
package/dist/Head.js CHANGED
@@ -14,6 +14,6 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  const BindHead = ({ Component , properties })=>{
17
- return(/*#__PURE__*/ React.createElement(Component, null, /*#__PURE__*/ React.createElement("title", null, properties.title)));
17
+ return /*#__PURE__*/ React.createElement(Component, null, /*#__PURE__*/ React.createElement("title", null, properties.title));
18
18
  };
19
19
  export default BindHead;
@@ -17,27 +17,21 @@ const MountEvents = ({ children , context , triggerEvent , triggerEventAsync })
17
17
  const [loading, setLoading] = useState(true);
18
18
  const [error, setError] = useState(null);
19
19
  useEffect(()=>{
20
- let mounted = true;
21
20
  setLoading(true);
22
21
  const mount = async ()=>{
23
22
  try {
24
23
  await triggerEvent();
25
- if (mounted) {
26
- triggerEventAsync();
27
- setLoading(false);
28
- }
24
+ triggerEventAsync();
25
+ setLoading(false);
29
26
  } catch (err) {
30
27
  setError(err);
31
28
  }
32
29
  };
33
- mount(); // TODO: check only run once.
34
- return ()=>{
35
- mounted = false;
36
- };
30
+ mount();
37
31
  }, [
38
32
  context
39
33
  ]);
40
34
  if (error) throw error;
41
- return(/*#__PURE__*/ React.createElement(React.Fragment, null, children(loading)));
35
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, children(loading));
42
36
  };
43
37
  export default MountEvents;
@@ -57,10 +57,8 @@ const ProgressBarController = ({ id , lowdefy , resetContext })=>{
57
57
  useEffect(()=>{
58
58
  const timer = state.progress < 95 && setInterval(()=>dispatch({
59
59
  type: 'auto-increment'
60
- })
61
- , 500);
62
- return ()=>clearInterval(timer)
63
- ;
60
+ }), 500);
61
+ return ()=>clearInterval(timer);
64
62
  }, [
65
63
  state
66
64
  ]);
@@ -69,7 +67,7 @@ const ProgressBarController = ({ id , lowdefy , resetContext })=>{
69
67
  type: 'reset'
70
68
  });
71
69
  }
72
- return(/*#__PURE__*/ React.createElement(ProgressBar, {
70
+ return /*#__PURE__*/ React.createElement(ProgressBar, {
73
71
  basePath: lowdefy.basePath,
74
72
  blockId: id,
75
73
  components: lowdefy._internal.components,
@@ -78,8 +76,7 @@ const ProgressBarController = ({ id , lowdefy , resetContext })=>{
78
76
  makeCssClass
79
77
  },
80
78
  pageId: lowdefy.pageId,
81
- properties: state,
82
- user: lowdefy.user
83
- }));
79
+ properties: state
80
+ });
84
81
  };
85
82
  export default ProgressBarController;
@@ -0,0 +1,56 @@
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 { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';
16
+ function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
17
+ const { home , pageId , urlQuery } = callbackUrl;
18
+ if ([
19
+ !home,
20
+ !pageId
21
+ ].filter((v)=>!v).length > 1) {
22
+ throw Error(`Invalid Link: To avoid ambiguity, only one of 'home' or 'pageId' can be defined.`);
23
+ }
24
+ const query = type.isNone(urlQuery) ? '' : `${urlQueryFn.stringify(urlQuery)}`;
25
+ if (home === true) {
26
+ return `/${lowdefy.home.configured ? '' : lowdefy.home.pageId}${query ? `?${query}` : ''}`;
27
+ }
28
+ if (type.isString(pageId)) {
29
+ return `/${pageId}${query ? `?${query}` : ''}`;
30
+ }
31
+ return undefined;
32
+ }
33
+ function createAuthMethods({ lowdefy , auth }) {
34
+ // login and logout are Lowdefy function that handle action params
35
+ // signIn and signOut are the next-auth methods
36
+ function login({ providerId , callbackUrl , authUrl ={} } = {}) {
37
+ if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
38
+ providerId = auth.authConfig.providers[0].id;
39
+ }
40
+ auth.signIn(providerId, {
41
+ callbackUrl: getCallbackUrl({
42
+ lowdefy,
43
+ callbackUrl
44
+ })
45
+ }, authUrl.urlQuery);
46
+ }
47
+ // TODO: fix callbackUrl
48
+ function logout() {
49
+ auth.signOut();
50
+ }
51
+ return {
52
+ login,
53
+ logout
54
+ };
55
+ }
56
+ export default createAuthMethods;
@@ -18,9 +18,8 @@ import ErrorBoundary from '../ErrorBoundary.js';
18
18
  import MountEvents from '../MountEvents.js';
19
19
  const Block = ({ block , Blocks , context , lowdefy , parentLoading })=>{
20
20
  const [updates, setUpdate] = useState(0);
21
- lowdefy._internal.updaters[block.id] = ()=>setUpdate(updates + 1)
22
- ;
23
- return(/*#__PURE__*/ React.createElement(ErrorBoundary, null, /*#__PURE__*/ React.createElement(MountEvents, {
21
+ lowdefy._internal.updaters[block.id] = ()=>setUpdate(updates + 1);
22
+ return /*#__PURE__*/ React.createElement(ErrorBoundary, null, /*#__PURE__*/ React.createElement(MountEvents, {
24
23
  context: context,
25
24
  triggerEvent: async ()=>{
26
25
  context._internal.lowdefy._internal.progress.dispatch({
@@ -56,7 +55,6 @@ const Block = ({ block , Blocks , context , lowdefy , parentLoading })=>{
56
55
  loading: eventLoading || parentLoading || block.eval.loading,
57
56
  lowdefy: lowdefy,
58
57
  updates: updates
59
- })
60
- )));
58
+ })));
61
59
  };
62
60
  export default Block;
@@ -21,42 +21,42 @@ import List from './List.js';
21
21
  import LoadingBlock from './LoadingBlock.js';
22
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
- if (block.eval.visible === false) return(/*#__PURE__*/ React.createElement("div", {
24
+ if (block.eval.visible === false) return /*#__PURE__*/ React.createElement("div", {
25
25
  id: `vs-${block.blockId}`,
26
26
  style: {
27
27
  display: 'none'
28
28
  }
29
- }));
29
+ });
30
30
  const Component = lowdefy._internal.blockComponents[block.type];
31
31
  if (loading && type.isObject(block.eval.skeleton)) {
32
- return(/*#__PURE__*/ React.createElement(LoadingBlock, {
32
+ return /*#__PURE__*/ React.createElement(LoadingBlock, {
33
33
  blockLayout: block.eval.layout,
34
34
  context: context,
35
35
  lowdefy: lowdefy,
36
36
  skeleton: block.eval.skeleton
37
- }));
37
+ });
38
38
  }
39
39
  switch(Component.meta.category){
40
40
  case 'list':
41
- return(/*#__PURE__*/ React.createElement(List, {
41
+ return /*#__PURE__*/ React.createElement(List, {
42
42
  block: block,
43
43
  Blocks: Blocks,
44
44
  Component: Component,
45
45
  context: context,
46
46
  loading: loading,
47
47
  lowdefy: lowdefy
48
- }));
48
+ });
49
49
  case 'container':
50
- return(/*#__PURE__*/ React.createElement(Container, {
50
+ return /*#__PURE__*/ React.createElement(Container, {
51
51
  block: block,
52
52
  Blocks: Blocks,
53
53
  Component: Component,
54
54
  context: context,
55
55
  loading: loading,
56
56
  lowdefy: lowdefy
57
- }));
57
+ });
58
58
  case 'input':
59
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
59
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
60
60
  id: `bl-${block.blockId}`,
61
61
  blockStyle: block.eval.style,
62
62
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
@@ -80,12 +80,11 @@ const CategorySwitch = ({ block , Blocks , context , loading , lowdefy })=>{
80
80
  pageId: lowdefy.pageId,
81
81
  properties: block.eval.properties,
82
82
  required: block.eval.required,
83
- user: lowdefy.user,
84
83
  validation: block.eval.validation,
85
84
  value: block.value
86
- })));
85
+ }));
87
86
  default:
88
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
87
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
89
88
  id: `bl-${block.blockId}`,
90
89
  blockStyle: block.eval.style,
91
90
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
@@ -108,9 +107,8 @@ const CategorySwitch = ({ block , Blocks , context , loading , lowdefy })=>{
108
107
  pageId: lowdefy.pageId,
109
108
  properties: block.eval.properties,
110
109
  required: block.eval.required,
111
- user: lowdefy.user,
112
110
  validation: block.eval.validation
113
- })));
111
+ }));
114
112
  }
115
113
  };
116
114
  export default CategorySwitch;
@@ -42,11 +42,9 @@ const Container = ({ block , Blocks , Component , context , loading , lowdefy }
42
42
  context: context,
43
43
  parentLoading: loading,
44
44
  lowdefy: lowdefy
45
- })
46
- ))
47
- ;
45
+ })));
48
46
  });
49
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
47
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
50
48
  id: `bl-${block.blockId}`,
51
49
  blockStyle: block.eval.style,
52
50
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
@@ -70,8 +68,7 @@ const Container = ({ block , Blocks , Component , context , loading , lowdefy }
70
68
  pageId: lowdefy.pageId,
71
69
  properties: block.eval.properties,
72
70
  required: block.eval.required,
73
- user: lowdefy.user,
74
71
  validation: block.eval.validation
75
- })));
72
+ }));
76
73
  };
77
74
  export default Container;
@@ -42,15 +42,13 @@ const List = ({ block , Blocks , Component , context , loading , lowdefy })=>{
42
42
  context: context,
43
43
  parentLoading: loading,
44
44
  lowdefy: lowdefy
45
- })
46
- ))
47
- ;
45
+ })));
48
46
  });
49
47
  contentList.push({
50
48
  ...content
51
49
  });
52
50
  });
53
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
51
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
54
52
  id: `bl-${block.blockId}`,
55
53
  blockStyle: block.eval.style,
56
54
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
@@ -79,8 +77,7 @@ const List = ({ block , Blocks , Component , context , loading , lowdefy })=>{
79
77
  pageId: lowdefy.pageId,
80
78
  properties: block.eval.properties,
81
79
  required: block.eval.required,
82
- user: lowdefy.user,
83
80
  validation: block.eval.validation
84
- })));
81
+ }));
85
82
  };
86
83
  export default List;
@@ -44,25 +44,25 @@ const LoadingBlock = ({ blockLayout , blockId , context , lowdefy , skeleton })
44
44
  const layout = skeleton.layout || blockLayout || {};
45
45
  switch(Component.meta.category){
46
46
  case 'list':
47
- return(/*#__PURE__*/ React.createElement(LoadingList, {
47
+ return /*#__PURE__*/ React.createElement(LoadingList, {
48
48
  blockId: blockId,
49
49
  Component: Component,
50
50
  context: context,
51
51
  layout: layout,
52
52
  lowdefy: lowdefy,
53
53
  skeleton: skeleton
54
- }));
54
+ });
55
55
  case 'container':
56
- return(/*#__PURE__*/ React.createElement(LoadingContainer, {
56
+ return /*#__PURE__*/ React.createElement(LoadingContainer, {
57
57
  blockId: blockId,
58
58
  Component: Component,
59
59
  context: context,
60
60
  layout: layout,
61
61
  lowdefy: lowdefy,
62
62
  skeleton: skeleton
63
- }));
63
+ });
64
64
  default:
65
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
65
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
66
66
  blockStyle: skeleton.style,
67
67
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
68
68
  id: `s-bl-${blockId}-${skeleton.id}`,
@@ -76,9 +76,8 @@ const LoadingBlock = ({ blockLayout , blockId , context , lowdefy , skeleton })
76
76
  menus: lowdefy.menus,
77
77
  methods: blockMethods,
78
78
  pageId: lowdefy.pageId,
79
- properties: skeleton.properties,
80
- user: lowdefy.user
81
- })));
79
+ properties: skeleton.properties
80
+ }));
82
81
  }
83
82
  };
84
83
  export default LoadingBlock;
@@ -40,11 +40,9 @@ const LoadingContainer = ({ blockId , Component , context , layout , lowdefy , s
40
40
  key: `s-co-${skl.id}-${k}`,
41
41
  lowdefy: lowdefy,
42
42
  skeleton: skl
43
- })
44
- ))
45
- ;
43
+ })));
46
44
  });
47
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
45
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
48
46
  blockStyle: skeleton.style,
49
47
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
50
48
  id: `s-bl-${blockId}-${skeleton.id}`,
@@ -61,8 +59,7 @@ const LoadingContainer = ({ blockId , Component , context , layout , lowdefy , s
61
59
  makeCssClass
62
60
  },
63
61
  pageId: lowdefy.pageId,
64
- properties: skeleton.properties,
65
- user: lowdefy.user
66
- })));
62
+ properties: skeleton.properties
63
+ }));
67
64
  };
68
65
  export default LoadingContainer;
@@ -41,15 +41,13 @@ const LoadingList = ({ blockId , Component , context , layout , lowdefy , skelet
41
41
  key: `s-co-${skl.id}-${k}`,
42
42
  lowdefy: lowdefy,
43
43
  skeleton: skl
44
- })
45
- ))
46
- ;
44
+ })));
47
45
  });
48
46
  contentList.push({
49
47
  ...content
50
48
  });
51
49
  });
52
- return(/*#__PURE__*/ React.createElement(BlockLayout, {
50
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
53
51
  blockStyle: skeleton.style,
54
52
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
55
53
  id: `s-bl-${blockId}-${skeleton.id}`,
@@ -65,8 +63,7 @@ const LoadingList = ({ blockId , Component , context , layout , lowdefy , skelet
65
63
  makeCssClass
66
64
  },
67
65
  pageId: lowdefy.pageId,
68
- properties: skeleton.properties,
69
- user: lowdefy.user
70
- })));
66
+ properties: skeleton.properties
67
+ }));
71
68
  };
72
69
  export default LoadingList;
@@ -1,3 +1,17 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source){
6
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7
+ target[key] = source[key];
8
+ }
9
+ }
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
1
15
  /*
2
16
  Copyright 2020-2022 Lowdefy, Inc
3
17
 
@@ -18,20 +32,6 @@ import { omit, type } from '@lowdefy/helpers';
18
32
  import Icon from '@ant-design/icons';
19
33
  import { blockDefaultProps, makeCssClass } from '@lowdefy/block-utils';
20
34
  import ErrorBoundary from './ErrorBoundary.js';
21
- function _extends() {
22
- _extends = Object.assign || function(target) {
23
- for(var i = 1; i < arguments.length; i++){
24
- var source = arguments[i];
25
- for(var key in source){
26
- if (Object.prototype.hasOwnProperty.call(source, key)) {
27
- target[key] = source[key];
28
- }
29
- }
30
- }
31
- return target;
32
- };
33
- return _extends.apply(this, arguments);
34
- }
35
35
  const lowdefyProps = [
36
36
  'actionLog',
37
37
  'basePath',
@@ -45,7 +45,6 @@ const lowdefyProps = [
45
45
  'registerEvent',
46
46
  'registerMethod',
47
47
  'schemaErrors',
48
- 'user',
49
48
  'validation',
50
49
  ];
51
50
  const createIcon = (Icons)=>{
@@ -78,7 +77,7 @@ const createIcon = (Icons)=>{
78
77
  if (!IconComp) {
79
78
  IconComp = AiOutlineExclamationCircle;
80
79
  }
81
- return(/*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, _extends({}, iconProps)) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
80
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, _extends({}, iconProps)) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
82
81
  fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, _extends({}, {
83
82
  ...iconProps,
84
83
  color: '#F00'
@@ -87,16 +86,14 @@ const createIcon = (Icons)=>{
87
86
  id: blockId,
88
87
  onClick: onClick || events.onClick && (()=>methods.triggerEvent({
89
88
  name: 'onClick'
90
- })
91
- ),
89
+ })),
92
90
  size: propertiesObj.size,
93
91
  title: propertiesObj.title
94
- }, iconProps)))));
92
+ }, iconProps))));
95
93
  };
96
94
  const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
97
95
  component: ()=>/*#__PURE__*/ React.createElement(IconBlock, _extends({}, all))
98
- })
99
- ;
96
+ });
100
97
  AntIcon.defaultProps = blockDefaultProps;
101
98
  return AntIcon;
102
99
  };
@@ -4,22 +4,20 @@ import { type } from '@lowdefy/helpers';
4
4
  const createLinkComponent = (lowdefy, Link)=>{
5
5
  const backLink = ({ ariaLabel , children , className , id , rel })=>/*#__PURE__*/ React.createElement("a", {
6
6
  id: id,
7
- onClick: ()=>lowdefy._internal.router.back()
8
- ,
7
+ onClick: ()=>lowdefy._internal.router.back(),
9
8
  className: className,
10
9
  rel: rel,
11
10
  "aria-label": ariaLabel || 'back'
12
- }, type.isFunction(children) ? children(id) : children)
13
- ;
11
+ }, type.isFunction(children) ? children(id) : children);
14
12
  const newOriginLink = ({ ariaLabel , children , className , id , newTab , pageId , query , rel , url , })=>{
15
- return(/*#__PURE__*/ React.createElement("a", {
13
+ return /*#__PURE__*/ React.createElement("a", {
16
14
  id: id,
17
15
  "aria-label": ariaLabel,
18
16
  className: className,
19
17
  href: `${url}${query ? `?${query}` : ''}`,
20
18
  rel: rel || newTab && 'noopener noreferrer',
21
19
  target: newTab && '_blank'
22
- }, type.isFunction(children) ? children(pageId || url || id) : children));
20
+ }, type.isFunction(children) ? children(pageId || url || id) : children);
23
21
  };
24
22
  const sameOriginLink = ({ ariaLabel , children , className , id , newTab , pageId , pathname , query , rel , replace , scroll , setInput , url , })=>{
25
23
  if (newTab) {
@@ -33,7 +31,7 @@ const createLinkComponent = (lowdefy, Link)=>{
33
31
  target: "_blank"
34
32
  }, type.isFunction(children) ? children(pageId || url || id) : children));
35
33
  }
36
- return(/*#__PURE__*/ React.createElement(Link, {
34
+ return /*#__PURE__*/ React.createElement(Link, {
37
35
  href: {
38
36
  pathname,
39
37
  query
@@ -46,13 +44,12 @@ const createLinkComponent = (lowdefy, Link)=>{
46
44
  className: className,
47
45
  rel: rel,
48
46
  onClick: setInput
49
- }, type.isFunction(children) ? children(pageId || url || id) : children)));
47
+ }, type.isFunction(children) ? children(pageId || url || id) : children));
50
48
  };
51
49
  const noLink = ({ className , children , id })=>/*#__PURE__*/ React.createElement("span", {
52
50
  id: id,
53
51
  className: className
54
- }, type.isFunction(children) ? children(id) : children)
55
- ;
52
+ }, type.isFunction(children) ? children(id) : children);
56
53
  return createLink({
57
54
  backLink,
58
55
  lowdefy,
@@ -15,6 +15,7 @@
15
15
  */ import { urlQuery } from '@lowdefy/helpers';
16
16
  import callRequest from './callRequest.js';
17
17
  import createIcon from './createIcon.js';
18
+ import createAuthMethods from './auth/createAuthMethods.js';
18
19
  import createLinkComponent from './createLinkComponent.js';
19
20
  import setupLink from './setupLink.js';
20
21
  const lowdefy = {
@@ -24,11 +25,9 @@ const lowdefy = {
24
25
  updaters: {},
25
26
  displayMessage: ({ content })=>{
26
27
  console.log(content);
27
- return ()=>undefined
28
- ;
28
+ return ()=>undefined;
29
29
  },
30
- link: ()=>undefined
31
- ,
30
+ link: ()=>undefined,
32
31
  progress: {
33
32
  state: {
34
33
  progress: 0
@@ -40,7 +39,7 @@ const lowdefy = {
40
39
  inputs: {},
41
40
  lowdefyGlobal: {}
42
41
  };
43
- function initLowdefyContext({ Components , config , router , stage , types , window }) {
42
+ function initLowdefyContext({ auth , Components , config , router , stage , types , window }) {
44
43
  if (stage === 'dev') {
45
44
  window.lowdefy = lowdefy;
46
45
  }
@@ -50,17 +49,22 @@ function initLowdefyContext({ Components , config , router , stage , types , win
50
49
  lowdefy.menus = config.rootConfig.menus;
51
50
  lowdefy.pageId = config.pageConfig.pageId;
52
51
  lowdefy.urlQuery = urlQuery.parse(window.location.search.slice(1));
52
+ lowdefy.user = auth?.session?.user ?? null;
53
53
  lowdefy._internal.window = window;
54
54
  lowdefy._internal.document = window.document;
55
55
  lowdefy._internal.router = router;
56
56
  lowdefy._internal.link = setupLink(lowdefy);
57
- lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]()
58
- ;
57
+ lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
59
58
  lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
60
59
  lowdefy._internal.components.Icon = createIcon(types.icons);
61
60
  lowdefy._internal.actions = types.actions;
62
61
  lowdefy._internal.blockComponents = types.blocks;
63
62
  lowdefy._internal.operators = types.operators;
63
+ // TODO: discuss not using object arguments
64
+ lowdefy._internal.auth = createAuthMethods({
65
+ lowdefy,
66
+ auth
67
+ });
64
68
  return lowdefy;
65
69
  }
66
70
  export default initLowdefyContext;
package/dist/setupLink.js CHANGED
@@ -15,8 +15,7 @@
15
15
  */ import { createLink } from '@lowdefy/engine';
16
16
  function setupLink(lowdefy) {
17
17
  const { router , window } = lowdefy._internal;
18
- const backLink = ()=>router.back()
19
- ;
18
+ const backLink = ()=>router.back();
20
19
  const disabledLink = ()=>{};
21
20
  const newOriginLink = ({ url , query , newTab })=>{
22
21
  if (newTab) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/client",
3
- "version": "4.0.0-alpha.10",
3
+ "version": "4.0.0-alpha.13",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Client",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,29 +43,30 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "4.7.0",
46
- "@lowdefy/block-utils": "4.0.0-alpha.10",
47
- "@lowdefy/engine": "4.0.0-alpha.10",
48
- "@lowdefy/helpers": "4.0.0-alpha.10",
49
- "@lowdefy/layout": "4.0.0-alpha.10",
46
+ "@lowdefy/block-utils": "4.0.0-alpha.13",
47
+ "@lowdefy/engine": "4.0.0-alpha.13",
48
+ "@lowdefy/helpers": "4.0.0-alpha.13",
49
+ "@lowdefy/layout": "4.0.0-alpha.13",
50
50
  "classnames": "2.3.1",
51
- "react": "17.0.2",
52
- "react-dom": "17.0.2"
51
+ "react": "18.1.0",
52
+ "react-dom": "18.1.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@emotion/jest": "11.7.1",
56
- "@swc/cli": "0.1.55",
57
- "@swc/core": "1.2.135",
58
- "@swc/jest": "0.2.17",
59
- "@testing-library/dom": "8.11.3",
60
- "@testing-library/react": "13.0.0-alpha.4",
61
- "@testing-library/user-event": "14.0.0-alpha.14",
55
+ "@emotion/jest": "11.9.1",
56
+ "@lowdefy/jest-yaml-transform": "4.0.0-alpha.13",
57
+ "@swc/cli": "0.1.57",
58
+ "@swc/core": "1.2.194",
59
+ "@swc/jest": "0.2.21",
60
+ "@testing-library/dom": "8.13.0",
61
+ "@testing-library/react": "13.3.0",
62
+ "@testing-library/user-event": "14.2.0",
62
63
  "copyfiles": "2.4.1",
63
- "jest": "27.5.1",
64
- "jest-serializer-html": "7.1.0",
65
- "jest-transform-yaml": "1.0.0"
64
+ "jest": "28.1.0",
65
+ "jest-environment-jsdom": "28.1.0",
66
+ "jest-serializer-html": "7.1.0"
66
67
  },
67
68
  "publishConfig": {
68
69
  "access": "public"
69
70
  },
70
- "gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
71
+ "gitHead": "e99b4b6c1f59804982fc148c0fe39dcf13b35d77"
71
72
  }