import shallowEqual from 'shallowequal' ; import ReactReconciler from 'react-reconciler' ; import createElement from './createElement' ; import Text from './nodes/Text' ; import Paragraph from './nodes/Paragraph' ; import View from './nodes/View' ; import ContainerBase from './nodes/ContainerBase' ; const NOOP = ( ) => { } ; const RETURN_EMPTY_OBJ = ( ) => ( { } ) ; const NO = ( ) => false ; export default function createReconcilerConfig ( containerInstance , onFlush ) { return { createInstance ( type , props ) { return createElement ( type , props ) ; } , createTextInstance ( text ) { return createElement ( Text . TAG , { children : text } ) as Text ; } , insertInContainerBefore ( container , child , childBefore ) { container . prependChild ( child , container . findChild ( childBefore ) ) ; } , appendChildToContainer ( container , child ) { container . appendChild ( child ) ; } , removeChildFromContainer ( container , child ) { container . removeChild ( child ) ; } , appendInitialChild ( parentInstance , child ) { parentInstance . appendChild ( child ) ; } , appendChild ( parentInstance , child ) { parentInstance . appendChild ( child ) ; } , removeChild ( parentInstance , child ) { parentInstance . removeChild ( child ) ; } , insertBefore ( parentInstance , child , childBefore ) { parentInstance . prependChild ( child , parentInstance . findChild ( childBefore ) ) ; } , prepareUpdate ( ) { return true ; } , commitUpdate ( instance , _updatePayload , _type , oldProps , newProps ) { if ( newProps . onLayout !== instance . onLayoutHook ) { instance . onLayoutHook = newProps . onLayout ; } instance . eventListener . setOnClickListener ( newProps . onClick ) ; instance . eventListener . setOnWheelListener ( newProps . onWheel ) ; instance . testID = newProps . testID ; if ( ! shallowEqual ( oldProps , newProps ) ) { if ( instance instanceof View ) { instance . setLayoutStyle ( newProps . layoutStyle ) ; } else if ( instance instanceof Text ) { instance . style = newProps . style ; instance . setBody ( newProps . children ) ; } else if ( instance instanceof Paragraph ) { instance . style = newProps . style ; } } } , commitTextUpdate ( textInstance , oldText , newText ) { textInstance . setBody ( newText ) ; } , resetAfterCommit ( ) { onFlush ( ) ; } , getPublicInstance ( inst ) { return inst ; } , shouldSetTextContent : NO , commitMount : NOOP , getRootHostContext : RETURN_EMPTY_OBJ , getChildHostContext : RETURN_EMPTY_OBJ , prepareForCommit : NOOP , resetTextContent : NOOP , finalizeInitialChildren : NO , supportsMutation : true , shouldDeprioritizeSubtree : NO , scheduleDeferredCallback : NOOP , cancelDeferredCallback : NOOP , setTimeout , clearTimeout , now : ( ) => Date . now ( ) , noTimeout : undefined , isPrimaryRenderer : true , supportsHydration : false , supportsPersistence : false , } ; }