import ReactReconciler from 'react-reconciler' ; import createElement from './createElement' ; import dev from './dev' ; import { ChildSet , Container , HostContext , HydratableInstance , Instance , NoTimeout , Props , PublicInstance , TextInstance , TimeoutHandle , Type , UpdatePayload } from './types' ; import elements from './elements' ; const { env } = process ; const log = console ; const { Label } = elements ; const debug = ! ! ( env . REACT_GTK_DEBUG && ( env . REACT_GTK_DEBUG || '' ) . toLowerCase ( ) !== 'false' ) ; export default ReactReconciler < Type , Props , Container , Instance , TextInstance , HydratableInstance , PublicInstance , HostContext , UpdatePayload , ChildSet , TimeoutHandle , NoTimeout > ( { createInstance ( type , props , _rootContainerInstance , _hostContext ) { if ( debug ) log . info ( type ) ; return createElement ( type , props ) ; } , appendInitialChild ( parentInstance , child ) { parentInstance . appendChild ( child ) ; } , finalizeInitialChildren ( _parentInstance , _type , _props , _rootContainerInstance , _hostContext ) { return true ; } , createTextInstance ( text , _rootContainerInstance , _hostContext ) { if ( debug ) log . info ( 'text' ) ; const label = new Label ( { label : text } ) ; label . commitMount ( ) ; return label ; } , getPublicInstance ( instance ) { return instance ; } , prepareForCommit ( _containerInfo ) { } , prepareUpdate ( _instance , _type , _oldProps , _newProps , _rootContainerInstance , _hostContext ) { return true ; } , resetAfterCommit ( _containerInfo ) { } , resetTextContent ( _instance ) { } , commitTextUpdate ( _textInstance , _oldText , _newText ) { throw new Error ( 'commitTextUpdate should not be called' ) ; } , removeChild ( parentInstance , child ) { parentInstance . removeChild ( child ) ; } , removeChildFromContainer ( _container , _child ) { if ( dev ) log . warn ( "'removeChildFromContainer' not supported" ) ; } , insertBefore ( _parentInstance , _child , _beforeChild ) { if ( dev ) log . warn ( "'insertBefore' not supported" ) ; } , appendChildToContainer ( container , child ) { return container . appendChild ( child ) ; } , appendChild ( parentInstance , child ) { return parentInstance . appendChild ( child ) ; } , shouldSetTextContent ( _type , props ) { if ( typeof props . children === 'string' ) return true ; return false ; } , getRootHostContext ( rootContainerInstance ) { if ( dev ) log . warn ( "'getRootHostContext' not supported" ) ; return { } ; } , getChildHostContext ( _parentHostContext , _type , _rootContainerInstance ) { if ( dev ) log . warn ( "'getChildHostContext' not supported" ) ; return { } ; } , now : Date . now , commitUpdate ( instance , _updatePayload , _type , _oldProps , newProps ) { return instance . commitUpdate ( newProps ) ; } , commitMount ( instance , _type , _newProps ) { instance . commitMount ( ) ; } , shouldDeprioritizeSubtree ( ) { return true ; } , scheduleDeferredCallback ( callback ? , _options ? ) { if ( callback ) { throw new Error ( 'Scheduling a callback twice is excessive. Instead, keep track of ' + 'whether the callback has already been scheduled.' ) ; } } , cancelDeferredCallback ( _callbackID ) { } , setTimeout ( handler , timeout ) { return setTimeout ( handler , timeout ) ; } , clearTimeout ( handle ) { return clearTimeout ( handle ) ; } , noTimeout : - 1 as NoTimeout , isPrimaryRenderer : true , supportsMutation : true , supportsPersistence : false , supportsHydration : false } ) ;