import { JSXElement, ElementName, Attributes } from '../jsx' import { Renderer } from './renderer' /** * Because Vulture abstracts away asynchronous operations, Vulture can also * easily allow nodes to be streamed. The `PartialRenderer` interface should be * implemented in order for streaming to be implemented. * * Vulture will only stream elements, as its children may finish before the * element itself. Therefore the partial renderer must be able to render an * element’s opening tag and closing tag seperately. * * The node, opening tag, and closing tag types will each be emitted in the * observable seperately. It is up to the observable consumer to provide a * concatenation strategy. The most common `PartialRenderer` is the string * renderer in which the opening tag and the closing tag types are the same as * the node’s type, string. */ export interface PartialRenderer extends Renderer { renderOpeningTag (elementName: ElementName, attributes: Attributes): OpeningTag renderClosingTag (elementName: ElementName): ClosingTag } /** * Determines if a renderer implements the `PartialRenderer` interface. Useful * for feature detection on a `Renderer`. */ export const isPartial = (renderer: Renderer): renderer is PartialRenderer => typeof renderer['renderOpeningTag'] === 'function' && typeof renderer['renderClosingTag'] === 'function'