mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
support jsCallInvoker in RCTBridgeProxy (#43314)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43314 Changelog: [Internal] making call invoker a breaking change to runtime executor in 0.74 seems to be causing a lot of discourse. let's simplify things and first add the callinvoker to the backwards compat layer Reviewed By: cipolleschi Differential Revision: D54404845 fbshipit-source-id: 983e86829030557033b95625dab9068492739417
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import <ReactCommon/CallInvoker.h>
|
||||
#endif
|
||||
|
||||
#import "RCTBridgeProxy.h"
|
||||
|
||||
@interface RCTBridgeProxy (Cxx)
|
||||
|
||||
#ifdef __cplusplus
|
||||
@property (nonatomic, readwrite) std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker;
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -15,6 +15,7 @@
|
||||
@class RCTViewRegistry;
|
||||
|
||||
@interface RCTBridgeProxy : NSProxy
|
||||
|
||||
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
|
||||
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
|
||||
bundleManager:(RCTBundleManager *)bundleManager
|
||||
@@ -34,4 +35,5 @@
|
||||
*/
|
||||
- (id)moduleForClass:(Class)moduleClass;
|
||||
- (id)moduleForName:(NSString *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad;
|
||||
|
||||
@end
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
*/
|
||||
|
||||
#import "RCTBridgeProxy.h"
|
||||
#import "RCTBridgeProxy+Cxx.h"
|
||||
|
||||
#import <React/RCTBridge+Private.h>
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import <React/RCTUIManager.h>
|
||||
#import <ReactCommon/CallInvoker.h>
|
||||
#import <jsi/jsi.h>
|
||||
|
||||
using namespace facebook;
|
||||
@@ -21,6 +24,12 @@ using namespace facebook;
|
||||
- (void)forwardInvocation:(NSInvocation *)invocation;
|
||||
@end
|
||||
|
||||
@interface RCTBridgeProxy ()
|
||||
|
||||
@property (nonatomic, readwrite) std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridgeProxy {
|
||||
RCTUIManagerProxy *_uiManagerProxy;
|
||||
RCTModuleRegistry *_moduleRegistry;
|
||||
@@ -84,6 +93,12 @@ using namespace facebook;
|
||||
return _runtime;
|
||||
}
|
||||
|
||||
- (std::shared_ptr<facebook::react::CallInvoker>)jsCallInvoker
|
||||
{
|
||||
[self logWarning:@"Please migrate to RuntimeExecutor" cmd:_cmd];
|
||||
return _jsCallInvoker;
|
||||
}
|
||||
|
||||
/**
|
||||
* RCTModuleRegistry
|
||||
*/
|
||||
|
||||
+8
-6
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#import "RCTInstance.h"
|
||||
#import <React/RCTBridgeProxy.h>
|
||||
|
||||
#import <memory>
|
||||
|
||||
@@ -16,6 +15,8 @@
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTBridgeModuleDecorator.h>
|
||||
#import <React/RCTBridgeProxy+Cxx.h>
|
||||
#import <React/RCTBridgeProxy.h>
|
||||
#import <React/RCTComponentViewFactory.h>
|
||||
#import <React/RCTConstants.h>
|
||||
#import <React/RCTCxxUtils.h>
|
||||
@@ -256,6 +257,7 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
RuntimeExecutor bufferedRuntimeExecutor = _reactInstance->getBufferedRuntimeExecutor();
|
||||
timerManager->setRuntimeExecutor(bufferedRuntimeExecutor);
|
||||
|
||||
auto jsCallInvoker = make_shared<BridgelessJSCallInvoker>(bufferedRuntimeExecutor);
|
||||
RCTBridgeProxy *bridgeProxy =
|
||||
[[RCTBridgeProxy alloc] initWithViewRegistry:_bridgeModuleDecorator.viewRegistry_DEPRECATED
|
||||
moduleRegistry:_bridgeModuleDecorator.moduleRegistry
|
||||
@@ -274,14 +276,14 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
}
|
||||
}
|
||||
runtime:_reactInstance->getJavaScriptContext()];
|
||||
bridgeProxy.jsCallInvoker = jsCallInvoker;
|
||||
[RCTBridge setCurrentBridge:(RCTBridge *)bridgeProxy];
|
||||
|
||||
// Set up TurboModules
|
||||
_turboModuleManager = [[RCTTurboModuleManager alloc]
|
||||
initWithBridgeProxy:bridgeProxy
|
||||
bridgeModuleDecorator:_bridgeModuleDecorator
|
||||
delegate:self
|
||||
jsInvoker:std::make_shared<BridgelessJSCallInvoker>(bufferedRuntimeExecutor)];
|
||||
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridgeProxy:bridgeProxy
|
||||
bridgeModuleDecorator:_bridgeModuleDecorator
|
||||
delegate:self
|
||||
jsInvoker:jsCallInvoker];
|
||||
_turboModuleManager.runtimeHandler = self;
|
||||
|
||||
#if RCT_DEV
|
||||
|
||||
Reference in New Issue
Block a user