import ReactReconciler from 'react-reconciler' ; import createElement from '~/createElement' ; import { SmartElement } from '~/elements' ; import { dev } from '~/util' ; import { ChildSet , Container , HostContext , HydratableInstance , Instance , NoTimeout , Props , PublicInstance , SuspenseInstance , TextInstance , TimeoutHandle , Type , UpdatePayload } from '~/types' ; const logger = { ... console , debug : ( ... _args ) => undefined } ; export default ReactReconciler < Type , Props , Container , Instance , TextInstance , SuspenseInstance , HydratableInstance , PublicInstance , HostContext , UpdatePayload , ChildSet , TimeoutHandle , NoTimeout > ( { createInstance ( type , props , _rootContainerInstance , _hostContext ) { logger . debug ( 'createInstance' ) ; return createElement ( type , props ) ; } , appendInitialChild ( parentInstance , child ) { logger . debug ( 'appendInitialChild' ) ; parentInstance . appendChild ( child ) ; } , finalizeInitialChildren ( _parentInstance , _type , _props , _rootContainerInstance , _hostContext ) { logger . debug ( 'finalizeInitialChildren' ) ; return true ; } , createTextInstance ( text , _rootContainerInstance , _hostContext ) { logger . debug ( 'createTextInstance' ) ; const label = new SmartElement ( { code : text } , { } ) ; label . commitMount ( ) ; return label ; } , getPublicInstance ( instance ) { logger . debug ( 'getPublicInstance' ) ; return instance ; } , prepareForCommit ( _containerInfo ) { logger . debug ( 'prepareForCommit' ) ; return null ; } , prepareUpdate ( _instance , _type , _oldProps , _newProps , _rootContainerInstance , _hostContext ) { logger . debug ( 'prepareUpdate' ) ; return true ; } , resetAfterCommit ( _containerInfo ) { logger . debug ( 'resetAfterCommit' ) ; } , resetTextContent ( _instance ) { logger . debug ( 'resetTextContent' ) ; } , commitTextUpdate ( _textInstance , _oldText , _newText ) { logger . debug ( 'commitTextUpdate' ) ; throw new Error ( 'commitTextUpdate should not be called' ) ; } , removeChild ( parentInstance , child ) { logger . debug ( 'removeChild' ) ; parentInstance . removeChild ( child ) ; } , removeChildFromContainer ( _container , _child ) { logger . debug ( 'removeChildFromContainer' ) ; if ( dev ) logger . warn ( "'removeChildFromContainer' not supported" ) ; } , insertBefore ( _parentInstance , _child , _beforeChild ) { logger . debug ( 'insertBefore' ) ; if ( dev ) logger . warn ( "'insertBefore' not supported" ) ; } , appendChildToContainer ( container , child ) { logger . debug ( 'appendChildToContainer' ) ; container . appendChild ( child ) ; } , appendChild ( parentInstance , child ) { logger . debug ( 'appendChild' ) ; parentInstance . appendChild ( child ) ; } , shouldSetTextContent ( _type , props ) { logger . debug ( 'shouldSetTextContent' ) ; if ( typeof props . children === 'string' ) return true ; return false ; } , getRootHostContext ( _rootContainerInstance ) { logger . debug ( 'getRootHostContext' ) ; if ( dev ) logger . warn ( "'getRootHostContext' not supported" ) ; return { } ; } , getChildHostContext ( _parentHostContext , _type , _rootContainerInstance ) { logger . debug ( 'getChildHostContext' ) ; if ( dev ) logger . warn ( "'getChildHostContext' not supported" ) ; return { } ; } , now : Date . now , commitUpdate ( instance , _updatePayload , _type , _oldProps , newProps ) { logger . debug ( 'commitUpdate' ) ; return instance . commitUpdate ( newProps ) ; } , commitMount ( instance , _type , _newProps ) { logger . debug ( 'commitMount' ) ; instance . commitMount ( ) ; } , scheduleTimeout ( handler , timeout ) { logger . debug ( 'setTimeout' ) ; return setTimeout ( handler , timeout ) ; } , cancelTimeout ( handle ) { logger . debug ( 'clearTimeout' ) ; return clearTimeout ( handle ) ; } , preparePortalMount ( ) { logger . debug ( 'preparePortalMount' ) ; } , queueMicrotask ( callback ) { queueMicrotask ( callback ) ; } , clearContainer ( _container ) { logger . debug ( 'clearContainer' ) ; } , noTimeout : - 1 as NoTimeout , isPrimaryRenderer : true , supportsMutation : true , supportsPersistence : false , supportsHydration : false } ) ;