From 84bad0af9c87de607c4261a8001f4694b4fae0f6 Mon Sep 17 00:00:00 2001 From: Bowen Tan Date: Wed, 30 Aug 2023 17:04:25 +0800 Subject: [PATCH] feat(runtime): mount sunmao services on window --- packages/runtime/src/index.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts index 0d5710ae3..752590345 100644 --- a/packages/runtime/src/index.ts +++ b/packages/runtime/src/index.ts @@ -4,7 +4,7 @@ import { initRegistry, SunmaoLib } from './services/Registry'; import { initApiService } from './services/apiService'; import { initGlobalHandlerMap } from './services/handler'; import { UtilMethodManager } from './services/UtilMethodManager'; -import { AppHooks } from './types'; +import { AppHooks, UIServices } from './types'; import { enableES5, setAutoFreeze } from 'immer'; import './style.css'; import { initSlotReceiver } from './services/SlotReciver'; @@ -47,20 +47,19 @@ export function initSunmaoUI(props: SunmaoUIRuntimeProps = {}) { props.libs?.forEach(lib => { registry.installLib(lib); }); + const services: UIServices = { + registry, + stateManager, + globalHandlerMap, + apiService, + eleMap, + slotReceiver, + }; + + (window as any).sunmaoServices = services; return { - App: genApp( - { - registry, - stateManager, - globalHandlerMap, - apiService, - eleMap, - slotReceiver, - }, - props.hooks, - props.isInEditor - ), + App: genApp(services, props.hooks, props.isInEditor), stateManager, registry, globalHandlerMap,