mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: D31464478 enabled clang-format by default across projects, but opted out directories with a lot of formatting errors. This removes the opt-out, so clang-format is run in that directory as well. Changelog: [Internal][Changed] - Remove clang-format opt-out for Libraries Reviewed By: lunaleaps Differential Revision: D40310275 fbshipit-source-id: abe154ab466798fbfa010364a3627f40ca18b179
118 lines
4.8 KiB
Objective-C
118 lines
4.8 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <React/RCTBridge.h>
|
|
#import <React/RCTBridgeDelegate.h>
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
// When the new architecture is enabled, the RCTAppDelegate imports some additional headers
|
|
#import <React/RCTCxxBridgeDelegate.h>
|
|
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
|
|
#endif
|
|
|
|
/**
|
|
* The RCTAppDelegate is an utility class that implements some base configurations for all the React Native apps.
|
|
* It is not mandatory to use it, but it could simplify your AppDelegate code.
|
|
*
|
|
* To use it, you just need to make your AppDelegate a subclass of RCTAppDelegate:
|
|
*
|
|
* ```objc
|
|
* #import <React/RCTAppDelegate.h>
|
|
* @interface AppDelegate: RCTAppDelegate
|
|
* @end
|
|
* ```
|
|
*
|
|
* All the methods implemented by the RCTAppDelegate can be overriden by your AppDelegate if you need to provide a
|
|
custom implementation.
|
|
* If you need to customize the default implementation, you can invoke `[super <method_name>]` and use the returned
|
|
object.
|
|
*
|
|
* Overridable methods
|
|
* Shared:
|
|
* - (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary
|
|
*)launchOptions;
|
|
* - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString*)moduleName initProps:(NSDictionary
|
|
*)initProps;
|
|
* - (UIViewController *)createRootViewController;
|
|
* New Architecture:
|
|
* - (BOOL)concurrentRootEnabled
|
|
* - (NSDictionary *)prepareInitialProps
|
|
* - (Class)getModuleClassFromName:(const char *)name
|
|
* - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
* - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
initParams:
|
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
* - (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
*/
|
|
@interface RCTAppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
|
|
|
|
/// The window object, used to render the UViewControllers
|
|
@property (nonatomic, strong) UIWindow *window;
|
|
@property (nonatomic, strong) RCTBridge *bridge;
|
|
@property (nonatomic, strong) NSString *moduleName;
|
|
|
|
/**
|
|
* It creates a `RCTBridge` using a delegate and some launch options.
|
|
* By default, it is invoked passing `self` as a delegate.
|
|
* You can override this function to customize the logic that creates the RCTBridge
|
|
*
|
|
* @parameter: delegate - an object that implements the `RCTBridgeDelegate` protocol.
|
|
* @parameter: launchOptions - a dictionary with a set of options.
|
|
*
|
|
* @returns: a newly created instance of RCTBridge.
|
|
*/
|
|
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions;
|
|
|
|
/**
|
|
* It creates a `UIView` starting from a bridge, a module name and a set of initial properties.
|
|
* By default, it is invoked using the bridge created by `createBridgeWithDelegate:launchOptions` and
|
|
* the name in the `self.moduleName` variable.
|
|
* You can override this function to customize the logic that creates the Root View.
|
|
*
|
|
* @parameter: bridge - an instance of the `RCTBridge` object.
|
|
* @parameter: moduleName - the name of the app, used by Metro to resolve the module.
|
|
* @parameter: initProps - a set of initial properties.
|
|
*
|
|
* @returns: a UIView properly configured with a bridge for React Native.
|
|
*/
|
|
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
|
|
moduleName:(NSString *)moduleName
|
|
initProps:(NSDictionary *)initProps;
|
|
|
|
/**
|
|
* It creates the RootViewController.
|
|
* By default, it creates a new instance of a `UIViewController`.
|
|
* You can override it to provide your own initial ViewController.
|
|
*
|
|
* @return: an instance of `UIViewController`.
|
|
*/
|
|
- (UIViewController *)createRootViewController;
|
|
|
|
@end
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
/// Extension that makes the RCTAppDelegate conform to New Architecture delegates
|
|
@interface RCTAppDelegate () <RCTTurboModuleManagerDelegate, RCTCxxBridgeDelegate>
|
|
|
|
/// The TurboModule manager
|
|
@property (nonatomic, strong) RCTTurboModuleManager *turboModuleManager;
|
|
@property (nonatomic, strong) RCTSurfacePresenterBridgeAdapter *bridgeAdapter;
|
|
|
|
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
|
|
///
|
|
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
|
|
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
|
|
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
|
|
- (BOOL)concurrentRootEnabled;
|
|
|
|
@end
|
|
#endif
|