@lowdefy/server-dev 4.0.0-rc.6 → 4.0.0-rc.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/lib/App.js CHANGED
@@ -31,7 +31,7 @@ import blocks from '../build/plugins/blocks.js';
31
31
  import icons from '../build/plugins/icons.js';
32
32
  import operators from '../build/plugins/operators/client.js';
33
33
 
34
- const App = ({ auth }) => {
34
+ const App = ({ auth, lowdefy }) => {
35
35
  const router = useRouter();
36
36
  const { data: rootConfig } = useRootConfig(router.basePath);
37
37
 
@@ -41,7 +41,7 @@ const App = ({ auth }) => {
41
41
  return '';
42
42
  }
43
43
  return (
44
- <Reload basePath={router.basePath}>
44
+ <Reload basePath={router.basePath} lowdefy={lowdefy}>
45
45
  {(resetContext) => (
46
46
  <Page
47
47
  auth={auth}
@@ -49,6 +49,7 @@ const App = ({ auth }) => {
49
49
  config={{
50
50
  rootConfig,
51
51
  }}
52
+ lowdefy={lowdefy}
52
53
  pageId={pageId}
53
54
  resetContext={resetContext}
54
55
  router={router}
package/lib/Page.js CHANGED
@@ -20,7 +20,7 @@ import Client from '@lowdefy/client';
20
20
  import RestartingPage from './RestartingPage.js';
21
21
  import usePageConfig from './utils/usePageConfig.js';
22
22
 
23
- const Page = ({ auth, Components, config, pageId, resetContext, router, types }) => {
23
+ const Page = ({ auth, Components, config, lowdefy, pageId, resetContext, router, types }) => {
24
24
  const { data: pageConfig } = usePageConfig(pageId, router.basePath);
25
25
 
26
26
  if (!pageConfig) {
@@ -38,6 +38,7 @@ const Page = ({ auth, Components, config, pageId, resetContext, router, types })
38
38
  ...config,
39
39
  pageConfig,
40
40
  }}
41
+ lowdefy={lowdefy}
41
42
  resetContext={resetContext}
42
43
  router={router}
43
44
  stage="dev"
package/lib/Reload.js CHANGED
@@ -19,7 +19,7 @@ import React, { useEffect, useState } from 'react';
19
19
  import useMutateCache from './utils/useMutateCache.js';
20
20
  import waitForRestartedServer from './utils/waitForRestartedServer.js';
21
21
 
22
- const Reload = ({ children, basePath }) => {
22
+ const Reload = ({ children, basePath, lowdefy }) => {
23
23
  const [reset, setReset] = useState(false);
24
24
  const [restarting, setRestarting] = useState(false);
25
25
  const mutateCache = useMutateCache(basePath);
@@ -31,6 +31,9 @@ const Reload = ({ children, basePath }) => {
31
31
  // TODO: We need to pass a flag when a rebuild will happen so that client does not trigger render.
32
32
  setTimeout(async () => {
33
33
  await mutateCache();
34
+ if (lowdefy._internal?.initialised) {
35
+ lowdefy._internal.initialised = false;
36
+ }
34
37
  setReset(true);
35
38
  console.log('Reloaded config.');
36
39
  }, 600);
package/lib/auth/Auth.js CHANGED
@@ -24,7 +24,7 @@ import authConfig from '../../build/auth.json';
24
24
  function Auth({ children, session }) {
25
25
  if (authConfig.configured === true) {
26
26
  return (
27
- <AuthConfigured session={session} authConfig={authConfig}>
27
+ <AuthConfigured serverSession={session} authConfig={authConfig}>
28
28
  {(auth) => children(auth)}
29
29
  </AuthConfigured>
30
30
  );
@@ -15,11 +15,22 @@
15
15
  */
16
16
  /* eslint-disable react/jsx-props-no-spreading */
17
17
 
18
- import React from 'react';
19
- import { SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
18
+ import React, { useEffect, useRef } from 'react';
19
+ import { getSession, SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
20
+
21
+ import lowdefyConfig from '../../build/config.json';
20
22
 
21
23
  function Session({ children }) {
24
+ const wasAuthenticated = useRef(false);
22
25
  const { data: session, status } = useSession();
26
+ wasAuthenticated.current = wasAuthenticated.current || status === 'authenticated';
27
+
28
+ useEffect(() => {
29
+ if (wasAuthenticated.current && status === 'unauthenticated') {
30
+ window.location.reload();
31
+ }
32
+ }, [status]);
33
+
23
34
  // If session is passed to SessionProvider from getServerSideProps
24
35
  // we won't have a loading state here.
25
36
  // But 404 uses getStaticProps so we have this for 404.
@@ -30,10 +41,13 @@ function Session({ children }) {
30
41
  }
31
42
 
32
43
  function AuthConfigured({ authConfig, children, serverSession }) {
33
- const auth = { signIn, signOut, authConfig };
34
-
44
+ const auth = { authConfig, getSession, signIn, signOut };
45
+ let basePath = lowdefyConfig.basePath;
46
+ if (basePath) {
47
+ basePath = `${basePath}/api/auth`;
48
+ }
35
49
  return (
36
- <SessionProvider session={serverSession}>
50
+ <SessionProvider session={serverSession} basePath={basePath}>
37
51
  <Session>
38
52
  {(session) => {
39
53
  auth.session = session;
@@ -22,6 +22,7 @@ function authNotConfigured() {
22
22
  function AuthNotConfigured({ authConfig, children }) {
23
23
  const auth = {
24
24
  authConfig,
25
+ getSession: authNotConfigured,
25
26
  signIn: authNotConfigured,
26
27
  signOut: authNotConfigured,
27
28
  };
package/next.config.js CHANGED
@@ -2,7 +2,7 @@ const withLess = require('next-with-less');
2
2
  const lowdefyConfig = require('./build/config.json');
3
3
 
4
4
  module.exports = withLess({
5
- basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
5
+ basePath: lowdefyConfig.basePath,
6
6
  // reactStrictMode: true,
7
7
  webpack: (config, { isServer }) => {
8
8
  if (!isServer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.0.0-rc.6",
3
+ "version": "4.0.0-rc.8",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,30 +42,30 @@
42
42
  "next": "next"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/actions-core": "4.0.0-rc.6",
46
- "@lowdefy/api": "4.0.0-rc.6",
47
- "@lowdefy/blocks-antd": "4.0.0-rc.6",
48
- "@lowdefy/blocks-basic": "4.0.0-rc.6",
49
- "@lowdefy/blocks-color-selectors": "4.0.0-rc.6",
50
- "@lowdefy/blocks-echarts": "4.0.0-rc.6",
51
- "@lowdefy/blocks-loaders": "4.0.0-rc.6",
52
- "@lowdefy/blocks-markdown": "4.0.0-rc.6",
53
- "@lowdefy/blocks-qr": "4.0.0-rc.6",
54
- "@lowdefy/build": "4.0.0-rc.6",
55
- "@lowdefy/client": "4.0.0-rc.6",
56
- "@lowdefy/connection-axios-http": "4.0.0-rc.6",
57
- "@lowdefy/engine": "4.0.0-rc.6",
58
- "@lowdefy/helpers": "4.0.0-rc.6",
59
- "@lowdefy/layout": "4.0.0-rc.6",
60
- "@lowdefy/node-utils": "4.0.0-rc.6",
61
- "@lowdefy/operators-change-case": "4.0.0-rc.6",
62
- "@lowdefy/operators-diff": "4.0.0-rc.6",
63
- "@lowdefy/operators-js": "4.0.0-rc.6",
64
- "@lowdefy/operators-mql": "4.0.0-rc.6",
65
- "@lowdefy/operators-nunjucks": "4.0.0-rc.6",
66
- "@lowdefy/operators-uuid": "4.0.0-rc.6",
67
- "@lowdefy/operators-yaml": "4.0.0-rc.6",
68
- "@lowdefy/plugin-next-auth": "4.0.0-rc.6",
45
+ "@lowdefy/actions-core": "4.0.0-rc.8",
46
+ "@lowdefy/api": "4.0.0-rc.8",
47
+ "@lowdefy/blocks-antd": "4.0.0-rc.8",
48
+ "@lowdefy/blocks-basic": "4.0.0-rc.8",
49
+ "@lowdefy/blocks-color-selectors": "4.0.0-rc.8",
50
+ "@lowdefy/blocks-echarts": "4.0.0-rc.8",
51
+ "@lowdefy/blocks-loaders": "4.0.0-rc.8",
52
+ "@lowdefy/blocks-markdown": "4.0.0-rc.8",
53
+ "@lowdefy/blocks-qr": "4.0.0-rc.8",
54
+ "@lowdefy/build": "4.0.0-rc.8",
55
+ "@lowdefy/client": "4.0.0-rc.8",
56
+ "@lowdefy/connection-axios-http": "4.0.0-rc.8",
57
+ "@lowdefy/engine": "4.0.0-rc.8",
58
+ "@lowdefy/helpers": "4.0.0-rc.8",
59
+ "@lowdefy/layout": "4.0.0-rc.8",
60
+ "@lowdefy/node-utils": "4.0.0-rc.8",
61
+ "@lowdefy/operators-change-case": "4.0.0-rc.8",
62
+ "@lowdefy/operators-diff": "4.0.0-rc.8",
63
+ "@lowdefy/operators-js": "4.0.0-rc.8",
64
+ "@lowdefy/operators-mql": "4.0.0-rc.8",
65
+ "@lowdefy/operators-nunjucks": "4.0.0-rc.8",
66
+ "@lowdefy/operators-uuid": "4.0.0-rc.8",
67
+ "@lowdefy/operators-yaml": "4.0.0-rc.8",
68
+ "@lowdefy/plugin-next-auth": "4.0.0-rc.8",
69
69
  "chokidar": "3.5.3",
70
70
  "dotenv": "16.0.3",
71
71
  "next": "12.3.1",
@@ -77,7 +77,7 @@
77
77
  "react-dom": "18.2.0",
78
78
  "react-icons": "4.7.1",
79
79
  "swr": "2.0.0",
80
- "yaml": "2.2.1",
80
+ "yaml": "2.2.2",
81
81
  "yargs": "17.6.2"
82
82
  },
83
83
  "devDependencies": {
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "8238145a9eb26c6f3dc48661ab6eca6e3aca4f83"
94
+ "gitHead": "db883daef0443647439b6fe2db845b846ffb6d4e"
95
95
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.0.0-rc.6",
3
+ "version": "4.0.0-rc.8",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,30 +42,30 @@
42
42
  "next": "next"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/actions-core": "4.0.0-rc.6",
46
- "@lowdefy/api": "4.0.0-rc.6",
47
- "@lowdefy/blocks-antd": "4.0.0-rc.6",
48
- "@lowdefy/blocks-basic": "4.0.0-rc.6",
49
- "@lowdefy/blocks-color-selectors": "4.0.0-rc.6",
50
- "@lowdefy/blocks-echarts": "4.0.0-rc.6",
51
- "@lowdefy/blocks-loaders": "4.0.0-rc.6",
52
- "@lowdefy/blocks-markdown": "4.0.0-rc.6",
53
- "@lowdefy/blocks-qr": "4.0.0-rc.6",
54
- "@lowdefy/build": "4.0.0-rc.6",
55
- "@lowdefy/client": "4.0.0-rc.6",
56
- "@lowdefy/connection-axios-http": "4.0.0-rc.6",
57
- "@lowdefy/engine": "4.0.0-rc.6",
58
- "@lowdefy/helpers": "4.0.0-rc.6",
59
- "@lowdefy/layout": "4.0.0-rc.6",
60
- "@lowdefy/node-utils": "4.0.0-rc.6",
61
- "@lowdefy/operators-change-case": "4.0.0-rc.6",
62
- "@lowdefy/operators-diff": "4.0.0-rc.6",
63
- "@lowdefy/operators-js": "4.0.0-rc.6",
64
- "@lowdefy/operators-mql": "4.0.0-rc.6",
65
- "@lowdefy/operators-nunjucks": "4.0.0-rc.6",
66
- "@lowdefy/operators-uuid": "4.0.0-rc.6",
67
- "@lowdefy/operators-yaml": "4.0.0-rc.6",
68
- "@lowdefy/plugin-next-auth": "4.0.0-rc.6",
45
+ "@lowdefy/actions-core": "4.0.0-rc.8",
46
+ "@lowdefy/api": "4.0.0-rc.8",
47
+ "@lowdefy/blocks-antd": "4.0.0-rc.8",
48
+ "@lowdefy/blocks-basic": "4.0.0-rc.8",
49
+ "@lowdefy/blocks-color-selectors": "4.0.0-rc.8",
50
+ "@lowdefy/blocks-echarts": "4.0.0-rc.8",
51
+ "@lowdefy/blocks-loaders": "4.0.0-rc.8",
52
+ "@lowdefy/blocks-markdown": "4.0.0-rc.8",
53
+ "@lowdefy/blocks-qr": "4.0.0-rc.8",
54
+ "@lowdefy/build": "4.0.0-rc.8",
55
+ "@lowdefy/client": "4.0.0-rc.8",
56
+ "@lowdefy/connection-axios-http": "4.0.0-rc.8",
57
+ "@lowdefy/engine": "4.0.0-rc.8",
58
+ "@lowdefy/helpers": "4.0.0-rc.8",
59
+ "@lowdefy/layout": "4.0.0-rc.8",
60
+ "@lowdefy/node-utils": "4.0.0-rc.8",
61
+ "@lowdefy/operators-change-case": "4.0.0-rc.8",
62
+ "@lowdefy/operators-diff": "4.0.0-rc.8",
63
+ "@lowdefy/operators-js": "4.0.0-rc.8",
64
+ "@lowdefy/operators-mql": "4.0.0-rc.8",
65
+ "@lowdefy/operators-nunjucks": "4.0.0-rc.8",
66
+ "@lowdefy/operators-uuid": "4.0.0-rc.8",
67
+ "@lowdefy/operators-yaml": "4.0.0-rc.8",
68
+ "@lowdefy/plugin-next-auth": "4.0.0-rc.8",
69
69
  "chokidar": "3.5.3",
70
70
  "dotenv": "16.0.3",
71
71
  "next": "12.3.1",
@@ -77,7 +77,7 @@
77
77
  "react-dom": "18.2.0",
78
78
  "react-icons": "4.7.1",
79
79
  "swr": "2.0.0",
80
- "yaml": "2.2.1",
80
+ "yaml": "2.2.2",
81
81
  "yargs": "17.6.2"
82
82
  },
83
83
  "devDependencies": {
package/pages/_app.js CHANGED
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import React, { Suspense } from 'react';
17
+ import React, { Suspense, useRef } from 'react';
18
18
  import dynamic from 'next/dynamic';
19
19
 
20
20
  import Auth from '../lib/auth/Auth.js';
@@ -23,9 +23,10 @@ import Auth from '../lib/auth/Auth.js';
23
23
  import '../build/plugins/styles.less';
24
24
 
25
25
  function App({ Component }) {
26
+ const lowdefyRef = useRef({});
26
27
  return (
27
28
  <Suspense fallback="">
28
- <Auth>{(auth) => <Component auth={auth} />}</Auth>
29
+ <Auth>{(auth) => <Component auth={auth} lowdefy={lowdefyRef.current} />}</Auth>
29
30
  </Suspense>
30
31
  );
31
32
  }
@@ -16,16 +16,20 @@
16
16
 
17
17
  import React from 'react';
18
18
  import Document, { Html, Head, Main, NextScript } from 'next/document';
19
+
19
20
  import appJson from '../build/app.json';
21
+ import lowdefyConfig from '../build/config.json';
22
+
23
+ const basePath = lowdefyConfig.basePath ?? '';
20
24
 
21
25
  class LowdefyDocument extends Document {
22
26
  render() {
23
27
  return (
24
28
  <Html>
25
29
  <Head>
26
- <link rel="manifest" href="/manifest.webmanifest" />
27
- <link rel="icon" type="image/svg+xml" href="/icon.svg" />
28
- <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
30
+ <link rel="manifest" href={`${basePath}/manifest.webmanifest`} />
31
+ <link rel="icon" type="image/svg+xml" href={`${basePath}/icon.svg`} />
32
+ <link rel="apple-touch-icon" href={`${basePath}/apple-touch-icon.png`} />
29
33
  <meta name="viewport" content="width=device-width, initial-scale=1" />
30
34
  <script
31
35
  dangerouslySetInnerHTML={{
@@ -36,6 +36,11 @@ export const authOptions = getNextAuthConfig(
36
36
 
37
37
  export default async function auth(req, res) {
38
38
  if (authJson.configured === true) {
39
+ // Required for emails in corporate networks, see:
40
+ // https://next-auth.js.org/tutorials/avoid-corporate-link-checking-email-provider
41
+ if (req.method === 'HEAD') {
42
+ return res.status(200).end();
43
+ }
39
44
  return await NextAuth(req, res, authOptions);
40
45
  }
41
46