import { Scope } from "./Scope"; import { destroy, Rendition } from "./traits"; let _scope = Scope.dummy; const beginRender = async () => { } const endRender = () => { } export const getScope = () => _scope; export const render = async (rendition: () => Rendition, scope = Scope.dummy) => { await beginRender(); const prev = _scope; _scope = scope; try { const node = rendition().getDomNode(); scope.own(() => destroy(node)); return node; } finally { _scope = prev; endRender(); } }