#import #import #import #import #import #if __has_include() // for importing the header from framework, the dash will be transformed to underscore #import #else #import #endif #ifdef RCT_NEW_ARCH_ENABLED #import #import #import #import #import #import #import #import @interface DevClientAppDelegate () { std::shared_ptr _reactNativeConfig; facebook::react::ContextContainer::Shared _contextContainer; } @end #endif @interface RCTAppDelegate (DevClientAppDelegate) - (void)unstable_registerLegacyComponents; @end @interface DevClientAppDelegate () { std::shared_ptr _runtimeScheduler; } @end @implementation DevClientAppDelegate #if RCT_NEW_ARCH_ENABLED - (instancetype)init { if (self = [super init]) { _contextContainer = std::make_shared(); _reactNativeConfig = std::make_shared(); _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); } return self; } #endif - (RCTBridge *)createBridgeAndSetAdapterWithLaunchOptions:(NSDictionary * _Nullable)launchOptions { self.bridge = [self createBridgeWithDelegate:self launchOptions:launchOptions]; #ifdef RCT_NEW_ARCH_ENABLED self.bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:self.bridge contextContainer:_contextContainer]; self.bridge.surfacePresenter = self.bridgeAdapter.surfacePresenter; [self unstable_registerLegacyComponents]; #endif return self.bridge; } #pragma mark - RCTCxxBridgeDelegate - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge { #if RCT_NEW_ARCH_ENABLED _runtimeScheduler = std::make_shared(RCTRuntimeExecutorFromBridge(bridge)); std::shared_ptr callInvoker = std::make_shared(_runtimeScheduler); self.turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge delegate:self jsInvoker:callInvoker]; _contextContainer->erase("RuntimeScheduler"); _contextContainer->insert("RuntimeScheduler", _runtimeScheduler); return RCTAppSetupDefaultJsExecutorFactory(bridge, self.turboModuleManager, _runtimeScheduler); #else if (self.runtimeSchedulerEnabled) { _runtimeScheduler = std::make_shared(RCTRuntimeExecutorFromBridge(bridge)); } return RCTAppSetupJsExecutorFactoryForOldArch(bridge, _runtimeScheduler); #endif } @end