diff --git a/sdui/server/server/region.js b/sdui/server/server/region.js index 7aca24f10c..0343ff5bb5 100644 --- a/sdui/server/server/region.js +++ b/sdui/server/server/region.js @@ -53,13 +53,15 @@ async function renderApp(res, returnValue, formState) { // const m = require('../src/App.js'); const m = await import('../src/App.js') - const moduleMap = { - Text: { - id: 'Text', + let moduleMap = {} + for (let id of Object.keys(await import('../src/client.js'))) { + moduleMap[id] = { + id, name: 'default', chunks: ['main'], - }, + } } + const App = m.default.default || m.default const root = React.createElement( React.Fragment, diff --git a/sdui/server/src/App.js b/sdui/server/src/App.js index 051c60bd70..7f40aed516 100644 --- a/sdui/server/src/App.js +++ b/sdui/server/src/App.js @@ -1,9 +1,13 @@ import * as React from 'react' -import {Text} from './client.js' +import {Label, Stack} from './client.js' export default async function App() { - return hello + return ( + + + ) } // TODO diff --git a/sdui/server/src/client.js b/sdui/server/src/client.js index 93be6c6fca..9df8c7c3b8 100644 --- a/sdui/server/src/client.js +++ b/sdui/server/src/client.js @@ -1,4 +1,16 @@ -export const Text = { - $$typeof: Symbol.for('react.client.reference'), - $$id: 'Text', +export const Text = createClientReference('Text') +export const ActorLabel = createClientReference('ActorLabel') +export const Avatar = createClientReference('Avatar') +export const Box = createClientReference('Box') +export const Embed = createClientReference('Embed') +export const Expandable = createClientReference('Expandable') +export const Label = createClientReference('Label') +export const Stack = createClientReference('Stack') +export const Tabs = createClientReference('Tabs') + +function createClientReference(id) { + return { + $$typeof: Symbol.for('react.client.reference'), + $$id: id, + } } diff --git a/src/components/appcom/AppComponent.tsx b/src/components/appcom/AppComponent.tsx index 7247c8a386..61cdee44dd 100644 --- a/src/components/appcom/AppComponent.tsx +++ b/src/components/appcom/AppComponent.tsx @@ -1,3 +1,4 @@ +import React, {Suspense} from 'react' import {useQuery} from '@tanstack/react-query' // @ts-ignore import {createFromFetch} from 'react-server-dom-webpack/client' @@ -23,5 +24,6 @@ export function AppComponent({origin}: {origin: string}) { if (!data) { return null // TODO } - return data.root + + return {data.root} }