import { ComponentType , render } from 'preact' ; import { uuidv4 } from './util' ; import m , { Children , Vnode , VnodeDOM } from 'mithril' ; export function MithrilPreactAdapter < P > ( Component ) { const uuid = uuidv4 ( ) ; const displayName = Component . displayName ?? Component . name ?? 'some-component' ; return class implements m . ClassComponent < P > { oncreate ( vnode ) { render ( < Component { ... vnode . attrs } / > , vnode . dom ) ; } onupdate ( vnode ) { render ( < Component { ... vnode . attrs } / > , vnode . dom ) ; } view ( vnode ) { return m ( `div#preact-${ displayName }-${ uuid }` ) ; } } ; }