import type { Fn2 } from "@thi.ng/api" ; import type { IMountWithState , NumOrElement } from "./api.js" ; import { $el , $html , $remove , $text } from "./dom.js" ; import { SCHEDULER } from "./scheduler.js" ; const wrapper = < T > ( update ) => ( tag , attribs ? , body ? ) : IMountWithState < T > => ( { el : undefined , async mount ( parent , index , state ) { this . el = $el ( tag , attribs , null , parent , index ) ; update ( < any > this . el ! , state != null ? state : body ! ) ; return this . el ; } , async unmount ( ) { $remove ( this . el ! ) ; this . el = undefined ; } , update ( body ) { SCHEDULER . add ( this , ( ) => this . el && update ( < any > this . el ! , body ) ) ; } , } ) ; param tag param attribs param body export const $wrapText = wrapper ( $text ) ; param tag param attribs param body export const $wrapHtml = wrapper ( $html ) ;