mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
feat(server): Make initLowdefyContext sync.
This commit is contained in:
parent
a872dfcf81
commit
ef11ebb3e3
@ -14,37 +14,33 @@
|
||||
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 = {
|
||||
function initLowdefyContext() {
|
||||
const 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 = {};
|
||||
}
|
||||
},
|
||||
contexts: {},
|
||||
inputs: {},
|
||||
lowdefyGlobal: {},
|
||||
};
|
||||
lowdefy._internal.updateBlock = (blockId) =>
|
||||
lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
||||
return <>{children}</>;
|
||||
};
|
||||
return lowdefy;
|
||||
}
|
||||
|
||||
export default LowdefyContext;
|
||||
export default initLowdefyContext;
|
@ -18,18 +18,16 @@ import React from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { ErrorBoundary } from '@lowdefy/block-utils';
|
||||
|
||||
import LowdefyContext from '../lib/components/LowdefyContext.js';
|
||||
import initLowdefyContext from '../lib/utils/initLowdefyContext.js';
|
||||
|
||||
import '../build/plugins/styles.less';
|
||||
|
||||
const lowdefy = {};
|
||||
const lowdefy = initLowdefyContext();
|
||||
|
||||
function App({ Component, pageProps }) {
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<LowdefyContext lowdefy={lowdefy}>
|
||||
<Component lowdefy={lowdefy} {...pageProps} />
|
||||
</LowdefyContext>
|
||||
<Component lowdefy={lowdefy} {...pageProps} />
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user