import React , { ComponentType } from 'react' ; import meow from 'meow' ; const runnables = { } ; export type ComponentProvider = ( ) => ComponentType < any > ; export type ComponentProviderInstrumentationHook = ( component : ComponentProvider ) => ComponentType < any > ; export type WrapperComponentProvider = ( props : any ) => ComponentType < any > ; export type AppConfig = { appKey : string ; component ? : ComponentProvider ; run ? : Function ; section ? : boolean ; } ; import Instance from '../../Modules/Instance' ; import instances from '../../Modules/Instance/instances' ; /**
 * `AppRegistry` is the JS entry point to running all React Native apps.
 */ export default class AppRegistry { static getAppKeys ( ) { return Object . keys ( runnables ) ; } static getApplication ( appKey , appParameters ? ) { return runnables [ appKey ] . getApplication ( appParameters ) ; } static registerComponent ( appKey , componentProvider ) { const App = componentProvider ( ) ; runnables [ appKey ] = App ; return appKey ; } static registerConfig ( config ) { throw new Error ( 'NO_IMP' ) ; } static registerRunnable ( appKey , run ) { throw new Error ( 'NO_IMP' ) ; return appKey ; } static runApplication ( appKey , appParameters ) { const cli = meow ( appParameters ) ; const App = runnables [ appKey ] ; const node = React . createElement ( App , cli . flags ) ; let options = { } ; if ( typeof options . write === 'function' ) { options = { stdout : options , stdin : process . stdin , } ; } options = { stdout : process . stdout , stdin : process . stdin , debug : false , exitOnCtrlC : true , experimental : false , ... options , } ; let instance ; if ( instances . has ( options . stdout ) ) { instance = instances . get ( options . stdout ) ; } else { instance = new Instance ( options ) ; instances . set ( options . stdout , instance ) ; } instance . render ( node ) ; return { rerender : instance . render , unmount : ( ) => instance . unmount ( ) , waitUntilExit : instance . waitUntilExit , cleanup : ( ) => instances . delete ( options . stdout ) , } ; } static setComponentProviderInstrumentationHook ( hook ) { throw new Error ( 'NO_IMP' ) ; } static setWrapperComponentProvider ( provider ) { throw new Error ( 'NO_IMP' ) ; } static unmountApplicationComponentAtRootTag ( rootTag ) { throw new Error ( 'NO_IMP' ) ; } }