diff --git a/packages/editor/src/main.tsx b/packages/editor/src/main.tsx index 46320907..6b98860b 100644 --- a/packages/editor/src/main.tsx +++ b/packages/editor/src/main.tsx @@ -1,6 +1,7 @@ import { ChakraProvider } from '@chakra-ui/react'; import { Application } from '@meta-ui/core'; import { initMetaUI } from '@meta-ui/runtime'; +import { Registry } from '@meta-ui/runtime/lib/services/registry'; import { StrictMode } from 'react'; import ReactDOM from 'react-dom'; import 'react-grid-layout/css/styles.css'; @@ -10,7 +11,16 @@ import { Editor } from './components/Editor'; import { DefaultAppSchema } from './constants'; import { AppModelManager } from './operations/AppModelManager'; -export default function renderApp(app: Application = DefaultAppSchema) { +type Options = Partial<{ + components: Parameters[0][]; + traits: Parameters[0][]; + modules: Parameters[0][]; +}>; + +export default function renderApp( + app: Application = DefaultAppSchema, + options: Options = {} +) { const metaUI = initMetaUI(); const App = metaUI.App; @@ -18,6 +28,11 @@ export default function renderApp(app: Application = DefaultAppSchema) { const stateStore = metaUI.stateManager.store; const appModelManager = new AppModelManager(app, registry); + const { components = [], traits = [], modules = [] } = options; + components.forEach(c => registry.registerComponent(c)); + traits.forEach(t => registry.registerTrait(t)); + modules.forEach(m => registry.registerModule(m)); + ReactDOM.render(