From eb7c552fbf671f35ab0b18156431a99403c8a7b2 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 10 Apr 2024 17:28:12 +0100 Subject: [PATCH] Add initializers to make the RC8 changes not breaking --- .../react-native/React/Base/RCTBridgeProxy.h | 8 ++++++++ .../react-native/React/Base/RCTBridgeProxy.mm | 18 ++++++++++++++++++ .../runtime/platform/ios/ReactCommon/RCTHost.h | 5 +++++ .../platform/ios/ReactCommon/RCTHost.mm | 15 +++++++++++++++ .../platform/ios/ReactCommon/RCTInstance.h | 10 +++++++++- .../platform/ios/ReactCommon/RCTInstance.mm | 18 ++++++++++++++++++ 6 files changed, 73 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/Base/RCTBridgeProxy.h b/packages/react-native/React/Base/RCTBridgeProxy.h index 71bb9cf0831640..d49360e57f20f3 100644 --- a/packages/react-native/React/Base/RCTBridgeProxy.h +++ b/packages/react-native/React/Base/RCTBridgeProxy.h @@ -18,6 +18,14 @@ NS_ASSUME_NONNULL_BEGIN @interface RCTBridgeProxy : NSProxy +- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + bundleManager:(RCTBundleManager *)bundleManager + callableJSModules:(RCTCallableJSModules *)callableJSModules + dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread + registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId + runtime:(void *)runtime __deprecated; + - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry moduleRegistry:(RCTModuleRegistry *)moduleRegistry bundleManager:(RCTBundleManager *)bundleManager diff --git a/packages/react-native/React/Base/RCTBridgeProxy.mm b/packages/react-native/React/Base/RCTBridgeProxy.mm index 5b3e0656929ee3..82ee59a189ff50 100644 --- a/packages/react-native/React/Base/RCTBridgeProxy.mm +++ b/packages/react-native/React/Base/RCTBridgeProxy.mm @@ -41,6 +41,24 @@ @implementation RCTBridgeProxy { void *_runtime; } +- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + bundleManager:(RCTBundleManager *)bundleManager + callableJSModules:(RCTCallableJSModules *)callableJSModules + dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread + registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId + runtime:(void *)runtime +{ + return [self initWithViewRegistry:viewRegistry + moduleRegistry:moduleRegistry + bundleManager:bundleManager + callableJSModules:callableJSModules + dispatchToJSThread:dispatchToJSThread + registerSegmentWithId:registerSegmentWithId + runtime:runtime + launchOptions:@{}]; +} + - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry moduleRegistry:(RCTModuleRegistry *)moduleRegistry bundleManager:(RCTBundleManager *)bundleManager diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h index 87f6de0b7fa045..f5bd7d631355b6 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h @@ -59,6 +59,11 @@ typedef std::shared_ptr (^RCTHostJSEngineProv jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider launchOptions:(nullable NSDictionary *)launchOptions __deprecated; +- (instancetype)initWithBundleURL:(NSURL *)bundleURL + hostDelegate:(id)hostDelegate + turboModuleManagerDelegate:(id)turboModuleManagerDelegate + jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider __deprecated; + @property (nonatomic, weak, nullable) id runtimeDelegate; @property (nonatomic, readonly) RCTSurfacePresenter *surfacePresenter; diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm index cddebbe109fba7..a07faa7045e379 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm @@ -79,6 +79,21 @@ + (void)initialize _RCTInitializeJSThreadConstantInternal(); } +- (instancetype)initWithBundleURL:(NSURL *)bundleURL + hostDelegate:(id)hostDelegate + turboModuleManagerDelegate:(id)turboModuleManagerDelegate + jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider +{ + return [self + initWithBundleURLProvider:^{ + return bundleURL; + } + hostDelegate:hostDelegate + turboModuleManagerDelegate:turboModuleManagerDelegate + jsEngineProvider:jsEngineProvider + launchOptions:@{}]; +} + - (instancetype)initWithBundleURL:(NSURL *)bundleURL hostDelegate:(id)hostDelegate turboModuleManagerDelegate:(id)turboModuleManagerDelegate diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h index 6eaba0a1a8b782..1b803144d5aeb9 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h @@ -56,6 +56,14 @@ typedef void (^_Null_unspecified RCTInstanceInitialBundleLoadCompletionBlock)(); */ @interface RCTInstance : NSObject +- (instancetype)initWithDelegate:(id)delegate + jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory + bundleManager:(RCTBundleManager *)bundleManager + turboModuleManagerDelegate:(id)turboModuleManagerDelegate + onInitialBundleLoad:(RCTInstanceInitialBundleLoadCompletionBlock)onInitialBundleLoad + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + parentInspectorTarget:(facebook::react::jsinspector_modern::PageTarget *)parentInspectorTarget __deprecated; + - (instancetype)initWithDelegate:(id)delegate jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory bundleManager:(RCTBundleManager *)bundleManager @@ -63,7 +71,7 @@ typedef void (^_Null_unspecified RCTInstanceInitialBundleLoadCompletionBlock)(); onInitialBundleLoad:(RCTInstanceInitialBundleLoadCompletionBlock)onInitialBundleLoad moduleRegistry:(RCTModuleRegistry *)moduleRegistry parentInspectorTarget:(facebook::react::jsinspector_modern::PageTarget *)parentInspectorTarget - launchOptions:(nullable NSDictionary *)launchOptions; + launchOptions:(nullable NSDictionary *)launchOptions NS_DESIGNATED_INITIALIZER; - (void)callFunctionOnJSModule:(NSString *)moduleName method:(NSString *)method args:(NSArray *)args; diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index 029525a10c033a..b8b572ac439a52 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -93,6 +93,24 @@ @implementation RCTInstance { #pragma mark - Public +- (instancetype)initWithDelegate:(id)delegate + jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory + bundleManager:(RCTBundleManager *)bundleManager + turboModuleManagerDelegate:(id)turboModuleManagerDelegate + onInitialBundleLoad:(RCTInstanceInitialBundleLoadCompletionBlock)onInitialBundleLoad + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + parentInspectorTarget:(facebook::react::jsinspector_modern::PageTarget *)parentInspectorTarget +{ + return [self initWithDelegate:delegate + jsRuntimeFactory:jsRuntimeFactory + bundleManager:bundleManager + turboModuleManagerDelegate:turboModuleManagerDelegate + onInitialBundleLoad:onInitialBundleLoad + moduleRegistry:moduleRegistry + parentInspectorTarget:parentInspectorTarget + launchOptions:@{}]; +} + - (instancetype)initWithDelegate:(id)delegate jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory bundleManager:(RCTBundleManager *)bundleManager