import * as ld from "lodash" ; import { LifecycleInfo } from "./dom-parser" ; export interface AnyProps { [ key ] : any ; } export interface WithChildren { children ? : any | any [ ] ; } export function isDOMNode ( n ) { return n instanceof DOMNode ; } export class DOMNode { parent : DOMNode | null = null ; readonly props : AnyProps & WithChildren ; constructor ( readonly componentType , props , readonly lifecycleInfo , readonly uri , children ? ) { this . props = ld . clone ( props ) ; if ( children != null ) { if ( children . length !== 0 ) { for ( const child of children ) { if ( isDOMNode ( child ) ) { child . parent = this ; } } this . props . children = ( children . length === 1 ) ? children [ 0 ] : children ; } } } } export class DOMObject { constructor ( readonly uri , readonly data ) { } } export function isDOMObject ( n ) { return n instanceof DOMObject ; }