Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@ __attribute__((deprecated(
/// The window object, used to render the UViewControllers
@property (nonatomic, strong, nonnull) UIWindow *window;

#if !defined(RCT_REMOVE_LEGACY_ARCH)
@property (nonatomic, nullable) RCTBridge *bridge
__attribute__((deprecated("The bridge is deprecated and will be removed when removing the legacy architecture.")));
@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter __attribute__((
deprecated("The bridge adapter is deprecated and will be removed when removing the legacy architecture.")));
#endif

@property (nonatomic, strong, nullable) NSString *moduleName;
@property (nonatomic, strong, nullable) NSDictionary *initialProps;
@property (nonatomic, strong) RCTReactNativeFactory *reactNativeFactory;

/// If `automaticallyLoadReactNativeWindow` is set to `true`, the React Native window will be loaded automatically.
@property (nonatomic, assign) BOOL automaticallyLoadReactNativeWindow;

@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter __attribute__((
deprecated("The bridge adapter is deprecated and will be removed when removing the legacy architecture.")));
;

- (RCTRootViewFactory *)rootViewFactory;

@end
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ - (RCTRootViewFactory *)rootViewFactory
return self.reactNativeFactory.rootViewFactory;
}

#if !defined(RCT_REMOVE_LEGACY_ARCH)
- (RCTBridge *)bridge
{
return self.rootViewFactory.bridge;
Expand All @@ -86,5 +87,6 @@ - (void)setBridgeAdapter:(RCTSurfacePresenterBridgeAdapter *)bridgeAdapter
{
self.reactNativeFactory.rootViewFactory.bridgeAdapter = bridgeAdapter;
}
#endif

@end
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
*/
@interface RCTRootViewFactory : NSObject

#if !defined(RCT_REMOVE_LEGACY_ARCH)
@property (nonatomic, strong, nullable) RCTBridge *bridge;
@property (nonatomic, strong, nullable) RCTHost *reactHost;
@property (nonatomic, strong, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter;
#endif

@property (nonatomic, strong, nullable) RCTHost *reactHost;

- (instancetype)initWithConfiguration:(RCTRootViewFactoryConfiguration *)configuration
andTurboModuleManagerDelegate:(id<RCTTurboModuleManagerDelegate> _Nullable)turboModuleManagerDelegate;
Expand Down
63 changes: 3 additions & 60 deletions packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
*/

#import "RCTRootViewFactory.h"
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTDevMenu.h>
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <React/RCTUtils.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import "RCTAppDelegate.h"
Expand Down Expand Up @@ -90,7 +88,7 @@ - (instancetype)initWithBundleURL:(NSURL *)bundleURL

@end

@interface RCTRootViewFactory () <RCTCxxBridgeDelegate> {
@interface RCTRootViewFactory () {
std::shared_ptr<const facebook::react::ContextContainer> _contextContainer;
std::shared_ptr<facebook::react::RuntimeScheduler> _runtimeScheduler;
}
Expand Down Expand Up @@ -201,63 +199,6 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
return surfaceHostingProxyRootView;
}

- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions
{
return [[RCTBridge alloc] initWithDelegate:delegate launchOptions:launchOptions];
}

- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initProps:(NSDictionary *)initProps
{
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, YES);
#if !TARGET_OS_TV
rootView.backgroundColor = [UIColor systemBackgroundColor];
#else
rootView.backgroundColor = [UIColor blackColor];
#endif
return rootView;
}

#pragma mark - RCTCxxBridgeDelegate
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));

std::shared_ptr<facebook::react::CallInvoker> callInvoker =
std::make_shared<facebook::react::RuntimeSchedulerCallInvoker>(_runtimeScheduler);
RCTTurboModuleManager *turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:_turboModuleManagerDelegate
jsInvoker:callInvoker];
_contextContainer->erase(facebook::react::RuntimeSchedulerKey);
_contextContainer->insert(facebook::react::RuntimeSchedulerKey, _runtimeScheduler);
return RCTAppSetupDefaultJsExecutorFactory(bridge, turboModuleManager, _runtimeScheduler);
}

- (void)createBridgeIfNeeded:(NSDictionary *)launchOptions
{
if (self.bridge != nil) {
return;
}

if (self->_configuration.createBridgeWithDelegate != nil) {
self.bridge = self->_configuration.createBridgeWithDelegate(self, launchOptions);
} else {
self.bridge = [self createBridgeWithDelegate:self launchOptions:launchOptions];
}
}

- (void)createBridgeAdapterIfNeeded
{
if (self.bridgeAdapter != nullptr) {
return;
}

self.bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:self.bridge
contextContainer:_contextContainer];
self.bridge.surfacePresenter = self.bridgeAdapter.surfacePresenter;
}

#pragma mark - New Arch Utilities

- (void)createReactHostIfNeeded:(NSDictionary *)launchOptions
Expand Down Expand Up @@ -316,6 +257,7 @@ - (RCTHost *)createReactHost:(NSDictionary *)launchOptions
reinterpret_cast<facebook::react::JSRuntimeFactory *>(jsRuntimeFactory), &js_runtime_factory_destroy);
}

#ifndef RCT_REMOVE_LEGACY_ARCH
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
if (_configuration.extraModulesForBridge != nil) {
Expand Down Expand Up @@ -363,6 +305,7 @@ - (void)loadSourceForBridge:(RCTBridge *)bridge
_configuration.loadSourceForBridgeWithProgress(bridge, onProgress, loadCallback);
}
}
#endif

- (NSURL *)bundleURL
{
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Base/RCTBridge+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ RCT_EXTERN void RCTRegisterModule(Class);

@end

#if !defined(RCT_REMOVE_LEGACY_ARCH)
@interface RCTCxxBridge : RCTBridge

// TODO(cjhopman): this seems unsafe unless we require that it is only called on the main js queue.
@property (nonatomic, readonly) void *runtime;

#ifndef RCT_REMOVE_LEGACY_ARCH
- (instancetype)initWithParentBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER
__deprecated_msg("This API will be removed along with the legacy architecture.");
#endif // RCT_REMOVE_LEGACY_ARCH

@end
#endif // RCT_REMOVE_LEGACY_ARCH
4 changes: 4 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,11 @@ - (void)requestReload

- (Class)bridgeClass
{
#if !defined(RCT_REMOVE_LEGACY_ARCH)
return [RCTCxxBridge class];
#else
return nil;
#endif
}

- (void)setUp
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/React/Base/RCTBridgeProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ - (RCTBridgeProxy *)object
*/
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel;
{
#ifndef RCT_REMOVE_LEGACY_ARCH
return [RCTCxxBridge instanceMethodSignatureForSelector:sel];
#else
return [RCTBridge instanceMethodSignatureForSelector:sel];
#endif
}

- (void)forwardInvocation:(NSInvocation *)invocation
Expand Down
5 changes: 1 addition & 4 deletions packages/react-native/React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,4 @@ - (RCTCallInvoker *)callInvokerForModuleData:(RCTModuleData *)moduleData

@end

#else // RCT_REMOVE_LEGACY_ARCH
@implementation RCTCxxBridge
@end
#endif // RCT_REMOVE_LEGACY_ARCH
#endif // RCT_REMOVE_LEGACY_ARCHH
50 changes: 0 additions & 50 deletions packages/react-native/React/CxxModule/DispatchMessageQueueThread.h

This file was deleted.

17 changes: 0 additions & 17 deletions packages/react-native/React/CxxModule/RCTCxxMethod.h

This file was deleted.

Loading
Loading