import type { Template } from '@kirei/html' ; import { KireiError } from '../warn' ; import { defineComponent , html } from '../index' ; import { Component } from '../runtime/component' ; import { compiler } from '../runtime/compiler' ; import { getComponentInstance } from '../runtime/instance' ; import type { ComponentInstance } from '../types' ; type SuspenseFallback = ( typeof Component | Template ) ; type SuspenseTarget = typeof Component | Promise < Template > ; param target param fallback returns private export function suspense ( fallback ) { let node ; let multiple = false ; if ( fallback instanceof Template ) { node = fallback . updateOnce ( ) ; if ( node instanceof DocumentFragment ) { multiple = true ; } } else { node = new fallback ( ) ; } if ( ! Array . isArray ( target ) ) { target = [ target ] ; } const promises = target . map ( el => { if ( el instanceof Component ) { const instance = getComponentInstance ( el ) ; return Promise . resolve ( instance . template ) . then ( ( ) => instance ) ; } return el ; } ) ; Promise . all < Node | ComponentInstance > ( promises ) . then ( results => { if ( multiple ) { node . childNodes . length ; } else { } for ( const result of results ) { } } ) ; return node ; }