import { patch , createNode as _h , Component , VNode } from 'ultradom' ; import { App } from '../index' ; const React = { createElement : h } ; export { React } ; export function h < Props > ( type , props ? , ... children ) { if ( props ) { for ( const key in props ) { if ( key . match ( /^on[A-Z]\w+$/ ) ) { props [ key . toLowerCase ( ) ] = props [ key ] ; } } } return _h ( type , props , ... children ) ; } const __HYDUX_RENDER_NODE__ = '__HYDUX_RENDER_NODE__' ; export default function withUltradom < State , Actions > ( container = document . body , options = { raf : true } ) { let rafId ; return app => props => app ( { ... props , onRender ( view ) { props . onRender && props . onRender ( view ) ; const render = ( ) => { let rootEl = container [ __HYDUX_RENDER_NODE__ ] ; if ( ! rootEl ) { rootEl = container [ __HYDUX_RENDER_NODE__ ] = patch ( view ) ; container . appendChild ( rootEl ) ; } else { container [ __HYDUX_RENDER_NODE__ ] = patch ( view , rootEl ) ; } } ; if ( ! options . raf ) { return render ( ) ; } if ( rafId ) { window . cancelAnimationFrame ( rafId ) ; } rafId = window . requestAnimationFrame ( render ) ; } } ) ; }