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 6b869377a83..ea4492980f9 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 @@ -52,6 +52,10 @@ typedef std::shared_ptr (^RCTHostJSEngineProv @property (nonatomic, weak, nullable) id runtimeDelegate; +@property (nonatomic, readonly) RCTSurfacePresenter *surfacePresenter; + +@property (nonatomic, readonly) RCTModuleRegistry *moduleRegistry; + - (void)start; - (void)callFunctionOnJSModule:(NSString *)moduleName method:(NSString *)method args:(NSArray *)args; @@ -64,11 +68,11 @@ typedef std::shared_ptr (^RCTHostJSEngineProv - (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName initialProperties:(NSDictionary *)properties; -- (RCTSurfacePresenter *)getSurfacePresenter; +- (RCTSurfacePresenter *)getSurfacePresenter __attribute__((deprecated("Use `surfacePresenter` property instead."))); // Native module API -- (RCTModuleRegistry *)getModuleRegistry; +- (RCTModuleRegistry *)getModuleRegistry __attribute__((deprecated("Use `moduleRegistry` property instead."))); @end 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 85602c4c8a6..ff0bb9703d3 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 @@ -212,7 +212,7 @@ class RCTHostPageTargetDelegate : public facebook::react::jsinspector_modern::Pa mode:(DisplayMode)displayMode initialProperties:(NSDictionary *)properties { - RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithSurfacePresenter:[self getSurfacePresenter] + RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithSurfacePresenter:self.surfacePresenter moduleName:moduleName initialProperties:properties]; surface.surfaceHandler.setDisplayMode(displayMode); @@ -235,16 +235,28 @@ class RCTHostPageTargetDelegate : public facebook::react::jsinspector_modern::Pa return [self createSurfaceWithModuleName:moduleName mode:DisplayMode::Visible initialProperties:properties]; } -- (RCTModuleRegistry *)getModuleRegistry +- (RCTModuleRegistry *)moduleRegistry { return _moduleRegistry; } -- (RCTSurfacePresenter *)getSurfacePresenter +// Deprecated +- (RCTModuleRegistry *)getModuleRegistry +{ + return self.moduleRegistry; +} + +- (RCTSurfacePresenter *)surfacePresenter { return [_instance surfacePresenter]; } +// Deprecated +- (RCTSurfacePresenter *)getSurfacePresenter +{ + return self.surfacePresenter; +} + - (void)callFunctionOnJSModule:(NSString *)moduleName method:(NSString *)method args:(NSArray *)args { [_instance callFunctionOnJSModule:moduleName method:method args:args]; @@ -276,7 +288,7 @@ class RCTHostPageTargetDelegate : public facebook::react::jsinspector_modern::Pa [_hostDelegate hostDidStart:self]; for (RCTFabricSurface *surface in [self _getAttachedSurfaces]) { - [surface resetWithSurfacePresenter:[self getSurfacePresenter]]; + [surface resetWithSurfacePresenter:self.surfacePresenter]; } }