import type { Component , Props , Slots } from './types' ; import { onDispose } from './hydration' ; type MaybeAsync < T > = T | Promise < T > ; export type OnDisposeFn = ( ) => void ; export type OnLoadFn = ( el : Element , props : Props , slots : Slots | undefined ) => MaybeAsync < void | OnDisposeFn > ; const isFunction = ( val ) : val is Function => typeof val === 'function' ; export default async function createIsland ( component , id , el , props , slots ) { if ( isFunction ( component ) ) { const dispose = await component ( el , props , slots ) ; if ( import . meta . env . DISPOSE_ISLANDS && isFunction ( dispose ) ) onDispose ( id , dispose ) ; } if ( import . meta . env . DEV ) ( window as any ) . __ILE_DEVTOOLS__ ?. onHydration ( { id , el , props , slots , component , framework : 'none' } ) ; }