diff --git a/packages/server-dev/lib/components/App.js b/packages/server-dev/lib/App.js similarity index 50% rename from packages/server-dev/lib/components/App.js rename to packages/server-dev/lib/App.js index dca2d9ba2..b5fe22901 100644 --- a/packages/server-dev/lib/components/App.js +++ b/packages/server-dev/lib/App.js @@ -16,40 +16,47 @@ import React from 'react'; -import { urlQuery } from '@lowdefy/helpers'; import { useRouter } from 'next/router'; -import Page from './Page.js'; -import Reload from './Reload.js'; -import setPageId from '../utils/setPageId.js'; -import setupLink from '../utils/setupLink.js'; -import useRootConfig from '../utils/useRootConfig.js'; -import createComponents from './createComponents.js'; +import Head from 'next/head'; +import Link from 'next/link'; -const App = ({ lowdefy }) => { +import Reload from './Reload.js'; +import Page from './Page.js'; +import setPageId from './utils/setPageId.js'; +import useRootConfig from './utils/useRootConfig.js'; + +import actions from '../build/plugins/actions.js'; +import blocks from '../build/plugins/blocks.js'; +import icons from '../build/plugins/icons.js'; +import operators from '../build/plugins/operatorsClient.js'; + +import '../build/plugins/styles.less'; + +const App = () => { const router = useRouter(); const { data: rootConfig } = useRootConfig(router.basePath); - window.lowdefy = lowdefy; - - lowdefy._internal.router = router; - lowdefy._internal.link = setupLink(lowdefy); - lowdefy._internal.components = createComponents(lowdefy); - - lowdefy.basePath = lowdefy._internal.router.basePath; - lowdefy.home = rootConfig.home; - lowdefy.lowdefyGlobal = rootConfig.lowdefyGlobal; - lowdefy.menus = rootConfig.menus; - lowdefy.urlQuery = urlQuery.parse(window.location.search.slice(1)); - - const redirect = setPageId(lowdefy); + const { redirect, pageId } = setPageId(router); if (redirect) { - lowdefy._internal.router.push(`/${lowdefy.pageId}`); + router.push(`/${pageId}`); } - return ( - - + + ); }; diff --git a/packages/server-dev/lib/components/Head.js b/packages/server-dev/lib/Page.js similarity index 55% rename from packages/server-dev/lib/components/Head.js rename to packages/server-dev/lib/Page.js index 10cb9cbfb..8904abfa7 100644 --- a/packages/server-dev/lib/components/Head.js +++ b/packages/server-dev/lib/Page.js @@ -15,14 +15,29 @@ */ import React from 'react'; -import Head from 'next/head'; -const BindHead = ({ properties }) => { +import Client from '@lowdefy/client'; +import usePageConfig from './utils/usePageConfig.js'; + +const Page = ({ Components, config, pageId, router, types }) => { + const { data: pageConfig } = usePageConfig(pageId, router.basePath); + if (!pageConfig) { + router.replace(`/404`); + return ''; + } return ( - - {properties.title} - + ); }; -export default BindHead; +export default Page; diff --git a/packages/server-dev/lib/components/Reload.js b/packages/server-dev/lib/Reload.js similarity index 73% rename from packages/server-dev/lib/components/Reload.js rename to packages/server-dev/lib/Reload.js index 2c9d67772..bf701ffef 100644 --- a/packages/server-dev/lib/components/Reload.js +++ b/packages/server-dev/lib/Reload.js @@ -16,13 +16,13 @@ import React, { useEffect } from 'react'; -import useMutateCache from '../utils/useMutateCache.js'; -import waitForRestartedServer from '../utils/waitForRestartedServer.js'; +import useMutateCache from './utils/useMutateCache.js'; +import waitForRestartedServer from './utils/waitForRestartedServer.js'; -const Reload = ({ children, lowdefy }) => { - const mutateCache = useMutateCache(lowdefy.basePath); +const Reload = ({ children, basePath }) => { + const mutateCache = useMutateCache(basePath); useEffect(() => { - const sse = new EventSource(`${lowdefy.basePath}/api/reload`); + const sse = new EventSource(`${basePath}/api/reload`); sse.addEventListener('reload', () => { mutateCache(); @@ -31,7 +31,7 @@ const Reload = ({ children, lowdefy }) => { sse.onerror = () => { sse.close(); - waitForRestartedServer(lowdefy); + waitForRestartedServer(basePath); }; return () => { sse.close(); diff --git a/packages/server-dev/lib/components/Context.js b/packages/server-dev/lib/components/Context.js deleted file mode 100644 index 19899a4e1..000000000 --- a/packages/server-dev/lib/components/Context.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React from 'react'; -import getContext from '@lowdefy/engine'; - -import MountEvents from './block/MountEvents.js'; - -const Context = ({ children, lowdefy, config }) => { - const context = getContext({ config, lowdefy }); - - return ( - { - if (!async) { - context._internal.update(); // TODO: do we need this? - context._internal.State.freezeState(); - } - context._internal.RootBlocks.areas.root.blocks[0].triggerEvent({ name }); - }} - > - {(loadingOnInit) => { - if (loadingOnInit) return ''; // TODO: handle onInit Loader - return ( - - context._internal.RootBlocks.areas.root.blocks[0].triggerEvent({ name }) - } - > - {(loadingOnEnter) => children(context, loadingOnEnter)} - - ); - }} - - ); -}; - -export default Context; diff --git a/packages/server-dev/lib/components/LowdefyContext.js b/packages/server-dev/lib/components/LowdefyContext.js deleted file mode 100644 index 536f889e6..000000000 --- a/packages/server-dev/lib/components/LowdefyContext.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React from 'react'; - -import actions from '../../build/plugins/actions.js'; -import callRequest from '../utils/callRequest.js'; -import blockComponents from '../../build/plugins/blocks.js'; -import operators from '../../build/plugins/operatorsClient.js'; - -const LowdefyContext = ({ children, lowdefy }) => { - if (!lowdefy._internal) { - lowdefy._internal = { - actions, - blockComponents, - callRequest, - components: {}, - document, - operators, - updaters: {}, - window, - displayMessage: ({ content }) => { - console.log(content); - return () => undefined; - }, - link: () => undefined, - }; - lowdefy.contexts = {}; - lowdefy.inputs = {}; - lowdefy.lowdefyGlobal = {}; - } - lowdefy._internal.updateBlock = (blockId) => - lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId](); - return <>{children}; -}; - -export default LowdefyContext; diff --git a/packages/server-dev/lib/components/Page.js b/packages/server-dev/lib/components/Page.js deleted file mode 100644 index bc2a63616..000000000 --- a/packages/server-dev/lib/components/Page.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React from 'react'; - -import Block from './block/Block.js'; -import Context from './Context.js'; -import Head from './Head.js'; -import usePageConfig from '../utils/usePageConfig.js'; - -const LoadingBlock = () =>
Loading...
; - -const Page = ({ lowdefy }) => { - const { data: pageConfig } = usePageConfig(lowdefy.pageId, lowdefy.basePath); - if (!pageConfig) { - lowdefy._internal.router.replace(`/404`); - return ; - } - return ( - - {(context, loading) => { - if (loading) { - return ; - } - return ( - <> - - - - ); - }} - - ); -}; - -export default Page; diff --git a/packages/server-dev/lib/components/block/Block.js b/packages/server-dev/lib/components/block/Block.js deleted file mode 100644 index d17706c0c..000000000 --- a/packages/server-dev/lib/components/block/Block.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React, { Suspense, useState } from 'react'; - -import { ErrorBoundary } from '@lowdefy/block-utils'; - -import CategorySwitch from './CategorySwitch.js'; -import LoadingBlock from './LoadingBlock.js'; -import MountEvents from './MountEvents.js'; - -const Block = ({ block, Blocks, context, isRoot, lowdefy }) => { - const [updates, setUpdate] = useState(0); - lowdefy._internal.updaters[block.id] = () => setUpdate(updates + 1); - return ( - - }> - - {(loading) => - loading ? ( - - ) : ( - - ) - } - - - - ); -}; - -export default Block; diff --git a/packages/server-dev/lib/components/block/CategorySwitch.js b/packages/server-dev/lib/components/block/CategorySwitch.js deleted file mode 100644 index f1b052ec7..000000000 --- a/packages/server-dev/lib/components/block/CategorySwitch.js +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React from 'react'; -import { BlockLayout } from '@lowdefy/layout'; -import { makeCssClass } from '@lowdefy/block-utils'; - -import Container from './Container.js'; -import List from './List.js'; - -const CategorySwitch = ({ block, Blocks, context, lowdefy }) => { - if (!block.eval) return null; // Renderer updates before eval is executed for the first time on lists. See #520 - if (block.eval.visible === false) - return
; - const Component = lowdefy._internal.blockComponents[block.type]; - switch (Component.meta.category) { - case 'list': - return ( - - ); - case 'container': - return ( - - ); - case 'input': - return ( - - - - ); - default: - return ( - - - - ); - } -}; - -export default CategorySwitch; diff --git a/packages/server-dev/lib/components/block/Container.js b/packages/server-dev/lib/components/block/Container.js deleted file mode 100644 index 0738f4427..000000000 --- a/packages/server-dev/lib/components/block/Container.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React from 'react'; -import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout'; -import { makeCssClass } from '@lowdefy/block-utils'; - -import Block from './Block.js'; - -const Container = ({ block, Blocks, Component, context, lowdefy }) => { - const content = {}; - // eslint-disable-next-line prefer-destructuring - const areas = Blocks.subBlocks[block.id][0].areas; - Object.keys(areas).forEach((areaKey, i) => { - content[areaKey] = (areaStyle) => ( - - {areas[areaKey].blocks.map((bl, k) => ( - - ))} - - ); - }); - return ( - - - - ); -}; - -export default Container; diff --git a/packages/server-dev/lib/components/block/List.js b/packages/server-dev/lib/components/block/List.js deleted file mode 100644 index ab24fbb34..000000000 --- a/packages/server-dev/lib/components/block/List.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React from 'react'; -import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout'; -import { makeCssClass } from '@lowdefy/block-utils'; - -import Block from './Block.js'; - -const List = ({ block, Blocks, Component, context, lowdefy }) => { - const content = {}; - const contentList = []; - Blocks.subBlocks[block.id].forEach((SBlock) => { - Object.keys(SBlock.areas).forEach((areaKey) => { - content[areaKey] = (areaStyle) => ( - - {SBlock.areas[areaKey].blocks.map((bl) => ( - - ))} - - ); - }); - contentList.push({ ...content }); - }); - return ( - - - - ); -}; - -export default List; diff --git a/packages/server-dev/lib/components/block/LoadingBlock.js b/packages/server-dev/lib/components/block/LoadingBlock.js deleted file mode 100644 index 73480d185..000000000 --- a/packages/server-dev/lib/components/block/LoadingBlock.js +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -// import { Loading, makeCssClass } from '@lowdefy/block-utils'; -// import { get } from '@lowdefy/helpers'; -// import { BlockLayout } from '@lowdefy/layout'; - -const LoadingBlock = ({ block, lowdefy }) => ( -
LoadingBlock
- // - // - // -); - -export default LoadingBlock; diff --git a/packages/server-dev/lib/components/block/MountEvents.js b/packages/server-dev/lib/components/block/MountEvents.js deleted file mode 100644 index e8bf988f2..000000000 --- a/packages/server-dev/lib/components/block/MountEvents.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import React, { useEffect, useState } from 'react'; - -const MountEvents = ({ asyncEventName, context, eventName, triggerEvent, children }) => { - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - useEffect(() => { - let mounted = true; - const mount = async () => { - try { - await triggerEvent({ name: eventName, context }); - if (mounted) { - triggerEvent({ name: asyncEventName, context, async: true }); - setLoading(false); - } - } catch (err) { - setError(err); - } - }; - mount(); - return () => { - mounted = false; - }; - }, [context]); - - if (error) throw error; - - return <>{children(loading)}; -}; - -export default MountEvents; diff --git a/packages/server-dev/lib/components/createComponents.js b/packages/server-dev/lib/components/createComponents.js deleted file mode 100644 index 596e97795..000000000 --- a/packages/server-dev/lib/components/createComponents.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { createIcon } from '@lowdefy/block-utils'; - -import createLinkComponent from './createLinkComponent.js'; -import icons from '../../build/plugins/icons.js'; - -const createComponents = (lowdefy) => { - return { - Link: createLinkComponent(lowdefy), - Icon: createIcon(icons), - }; -}; - -export default createComponents; diff --git a/packages/server-dev/lib/components/createLinkComponent.js b/packages/server-dev/lib/components/createLinkComponent.js deleted file mode 100644 index 424f4124d..000000000 --- a/packages/server-dev/lib/components/createLinkComponent.js +++ /dev/null @@ -1,97 +0,0 @@ -import React from 'react'; -import NextLink from 'next/link'; -import { createLink } from '@lowdefy/engine'; -import { type } from '@lowdefy/helpers'; - -const createLinkComponent = (lowdefy) => { - const backLink = ({ ariaLabel, children, className, id, rel }) => ( - lowdefy._internal.router.back()} - className={className} - rel={rel} - aria-label={ariaLabel || 'back'} - > - {type.isFunction(children) ? children(id) : children} - - ); - const newOriginLink = ({ - ariaLabel, - children, - className, - id, - newTab, - pageId, - query, - rel, - url, - }) => { - return ( - - {type.isFunction(children) ? children(pageId || url || id) : children} - - ); - }; - const sameOriginLink = ({ - ariaLabel, - children, - className, - id, - newTab, - pageId, - pathname, - query, - rel, - replace, - scroll, - setInput, - url, - }) => { - if (newTab) { - return ( - // eslint-disable-next-line react/jsx-no-target-blank - - {type.isFunction(children) ? children(pageId || url || id) : children} - - ); - } - return ( - - - {type.isFunction(children) ? children(pageId || url || id) : children} - - - ); - }; - const noLink = ({ className, children, id }) => ( - - {type.isFunction(children) ? children(id) : children} - - ); - return createLink({ - backLink, - lowdefy, - newOriginLink, - sameOriginLink, - noLink, - disabledLink: noLink, - }); -}; - -export default createLinkComponent; diff --git a/packages/server-dev/lib/utils/setPageId.js b/packages/server-dev/lib/setPageId.js similarity index 61% rename from packages/server-dev/lib/utils/setPageId.js rename to packages/server-dev/lib/setPageId.js index 6a724ede1..dfcd3317f 100644 --- a/packages/server-dev/lib/utils/setPageId.js +++ b/packages/server-dev/lib/setPageId.js @@ -14,20 +14,17 @@ limitations under the License. */ -function setPageId(lowdefy) { - if (lowdefy._internal.router.pathname === `/404`) { - lowdefy.pageId = '404'; - return false; +function setPageId(router, rootConfig) { + if (router.pathname === `/404`) { + return { redirect: false, pageId: '404' }; } - if (!lowdefy._internal.router.query.pageId) { - lowdefy.pageId = lowdefy.home.pageId; - if (lowdefy.home.configured === false) { - return true; + if (!router.query.pageId) { + if (rootConfig.home.configured === false) { + return { redirect: true, pageId: rootConfig.home.pageId }; } - return false; + return { redirect: false, pageId: rootConfig.home.pageId }; } - lowdefy.pageId = lowdefy._internal.router.query.pageId; - return false; + return { redirect: false, pageId: router.query.pageId }; } export default setPageId; diff --git a/packages/server-dev/lib/utils/callRequest.js b/packages/server-dev/lib/utils/callRequest.js deleted file mode 100644 index e80c9d243..000000000 --- a/packages/server-dev/lib/utils/callRequest.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import request from './request.js'; - -function callRequest(apiContext, { pageId, payload, requestId }) { - return request({ - url: `${apiContext.config.basePath}/api/request/${pageId}/${requestId}`, - method: 'POST', - body: { payload }, - }); -} - -export default callRequest; diff --git a/packages/server-dev/lib/utils/request.js b/packages/server-dev/lib/utils/request.js index e79ec0f62..4ab200274 100644 --- a/packages/server-dev/lib/utils/request.js +++ b/packages/server-dev/lib/utils/request.js @@ -20,14 +20,13 @@ async function request({ url, method = 'GET', body }) { headers: { 'Content-Type': 'application/json', }, - body: body && JSON.stringify(body), + body: JSON.stringify(body), }); - if (res.status === 404) { - return null; - } if (!res.ok) { // TODO: check const body = await res.json(); + console.log(res); + console.log(body); throw new Error(body.message || 'Request error'); } return res.json(); diff --git a/packages/server-dev/lib/utils/setupLink.js b/packages/server-dev/lib/utils/setupLink.js deleted file mode 100644 index cec5e21de..000000000 --- a/packages/server-dev/lib/utils/setupLink.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright 2020-2022 Lowdefy, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { createLink } from '@lowdefy/engine'; - -function setupLink(lowdefy) { - const { router, window } = lowdefy._internal; - const backLink = () => router.back(); - const disabledLink = () => {}; - const newOriginLink = ({ url, query, newTab }) => { - if (newTab) { - return window.open(`${url}${query ? `?${query}` : ''}`, '_blank').focus(); - } else { - return window.location.assign(`${url}${query ? `?${query}` : ''}`); - } - }; - const sameOriginLink = ({ newTab, pathname, query, setInput }) => { - if (newTab) { - return window - .open( - `${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`, - '_blank' - ) - .focus(); - } else { - setInput(); - return router.push({ - pathname, - query, - }); - } - }; - const noLink = () => { - throw new Error(`Invalid Link.`); - }; - return createLink({ backLink, disabledLink, lowdefy, newOriginLink, noLink, sameOriginLink }); -} - -export default setupLink; diff --git a/packages/server-dev/lib/utils/usePageConfig.js b/packages/server-dev/lib/utils/usePageConfig.js index 98caa0b5e..9fc20c2f1 100644 --- a/packages/server-dev/lib/utils/usePageConfig.js +++ b/packages/server-dev/lib/utils/usePageConfig.js @@ -18,7 +18,7 @@ import request from './request.js'; // TODO: Handle TokenExpiredError function fetchPageConfig(url) { - return request({ url }); + return request(url); } function usePageConfig(pageId, basePath) { diff --git a/packages/server-dev/lib/utils/waitForRestartedServer.js b/packages/server-dev/lib/utils/waitForRestartedServer.js index 3c37bbcf8..98bbcd250 100644 --- a/packages/server-dev/lib/utils/waitForRestartedServer.js +++ b/packages/server-dev/lib/utils/waitForRestartedServer.js @@ -16,15 +16,15 @@ import request from './request.js'; -function waitForRestartedServer(lowdefy) { +function waitForRestartedServer(basePath) { setTimeout(async () => { try { await request({ - url: `${lowdefy.basePath}/api/ping`, + url: `${basePath}/api/ping`, }); - lowdefy._internal.window.location.reload(); + window.location.reload(); } catch (error) { - waitForRestartedServer(lowdefy); + waitForRestartedServer(basePath); } }, 1500); } diff --git a/packages/server-dev/package.json b/packages/server-dev/package.json index a5881a663..51e413474 100644 --- a/packages/server-dev/package.json +++ b/packages/server-dev/package.json @@ -37,8 +37,8 @@ "next": "next" }, "dependencies": { + "@lowdefy/actions-core": "4.0.0-alpha.8", "@lowdefy/api": "4.0.0-alpha.8", - "@lowdefy/block-utils": "4.0.0-alpha.8", "@lowdefy/blocks-antd": "4.0.0-alpha.8", "@lowdefy/blocks-basic": "4.0.0-alpha.8", "@lowdefy/blocks-color-selectors": "4.0.0-alpha.8", @@ -46,6 +46,7 @@ "@lowdefy/blocks-loaders": "4.0.0-alpha.8", "@lowdefy/blocks-markdown": "4.0.0-alpha.8", "@lowdefy/build": "4.0.0-alpha.8", + "@lowdefy/client": "4.0.0-alpha.8", "@lowdefy/connection-axios-http": "4.0.0-alpha.8", "@lowdefy/engine": "4.0.0-alpha.8", "@lowdefy/helpers": "4.0.0-alpha.8", diff --git a/packages/server-dev/pages/_app.js b/packages/server-dev/pages/_app.js index 2b58b4e90..adff5f43d 100644 --- a/packages/server-dev/pages/_app.js +++ b/packages/server-dev/pages/_app.js @@ -14,27 +14,14 @@ limitations under the License. */ -import React, { Suspense } from 'react'; +import React from 'react'; import dynamic from 'next/dynamic'; -import { ErrorBoundary } from '@lowdefy/block-utils'; - -import LowdefyContext from '../lib/components/LowdefyContext.js'; - +// Must be in _app due to next specifications. import '../build/plugins/styles.less'; -const lowdefy = {}; - function App({ Component, pageProps }) { - return ( - - - - - - - - ); + return ; } const DynamicApp = dynamic(() => Promise.resolve(App), {