mount.ts 1.0 KB

123456789101112131415161718192021222324
  1. /**
  2. * Application mount through a dependency fiber, so replacing `uiRenderer`
  3. * remounts the application. Shared by `AppWebEntry` and the test carrier.
  4. * @module @deepseek-ai/dsh-client-web/src/mount
  5. */
  6. import type { Context } from '@deepseek-ai/cordis'
  7. import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
  8. /**
  9. * Mount the UI renderer into `container` through a dependency fiber on
  10. * `uiRenderer`: the mount effect installs when the service is provided and
  11. * reinstalls when it is replaced.
  12. * @param ctx - booted root Context.
  13. * @param container - application mount point.
  14. * @returns resolves once the dependency fiber exists; with `uiRenderer`
  15. * already provided (as after `bootClient`) the mount effect is installed by
  16. * then, otherwise it installs when the service arrives.
  17. */
  18. export async function mountClient(ctx: Context, container: HTMLElement): Promise<void> {
  19. const mounted = ctx.inject(['uiRenderer'], (scope) => {
  20. scope.effect(() => scope.uiRenderer.mount(container), 'web boot: application mount')
  21. })
  22. await mounted
  23. }