// Runs one app by its key (plan step 3.1b): loads its chunk, shows a spinner meanwhile and a // clear screen for an app this terminal doesn't have (an older terminal image). import { lazy, Suspense } from 'react' import { useTranslation } from '@xenia/i18n' import { EmptyState, Spinner } from '@xenia/ui' import { APPS } from './registry' // One lazy component per app, made once (React must see the same component every render) const LAZY = Object.fromEntries(Object.entries(APPS).map(([key, load]) => [key, lazy(load)])) export default function AppHost({ appKey }) { const { t } = useTranslation('terminal') const App = Object.hasOwn(LAZY, appKey) ? LAZY[appKey] : null if (!App) { return (
) } return ( }> ) }