diff --git a/packages/react-native/React/Base/RCTBridge+Private.h b/packages/react-native/React/Base/RCTBridge+Private.h index 4d03df3ce8d6..a5ce532a79fa 100644 --- a/packages/react-native/React/Base/RCTBridge+Private.h +++ b/packages/react-native/React/Base/RCTBridge+Private.h @@ -16,12 +16,15 @@ RCT_EXTERN void RCTRegisterModule(Class); @interface RCTBridge () +#ifndef RCT_FIT_RM_OLD_RUNTIME // Private designated initializer - (instancetype)initWithDelegate:(id)delegate bundleURL:(NSURL *)bundleURL moduleProvider:(RCTBridgeModuleListProvider)block launchOptions:(NSDictionary *)launchOptions NS_DESIGNATED_INITIALIZER; +#endif // RCT_FIT_RM_OLD_RUNTIME + // Used for the profiler flow events between JS and native @property (nonatomic, assign) int64_t flowID; @property (nonatomic, assign) CFMutableDictionaryRef flowIDMap; @@ -146,6 +149,8 @@ RCT_EXTERN void RCTRegisterModule(Class); // 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_FIT_RM_OLD_RUNTIME - (instancetype)initWithParentBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; +#endif // RCT_FIT_RM_OLD_RUNTIME @end diff --git a/packages/react-native/React/Base/RCTBridge.mm b/packages/react-native/React/Base/RCTBridge.mm index 2fa60819d215..16bdd9a8f11d 100644 --- a/packages/react-native/React/Base/RCTBridge.mm +++ b/packages/react-native/React/Base/RCTBridge.mm @@ -265,6 +265,7 @@ void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled) kDispatchAccessibilityManagerInitOntoMain = enabled; } +#ifndef RCT_FIT_RM_OLD_RUNTIME class RCTBridgeHostTargetDelegate : public facebook::react::jsinspector_modern::HostTargetDelegate { public: RCTBridgeHostTargetDelegate(RCTBridge *bridge) @@ -675,3 +676,110 @@ - (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path return _inspectorTarget.get(); } @end +#else // RCT_FIT_RM_OLD_RUNTIME +@implementation RCTBridge +- (instancetype)initWithDelegate:(id)delegate launchOptions:(NSDictionary *)launchOptions +{ + return self; +} + +- (instancetype)initWithBundleURL:(NSURL *)bundleURL + moduleProvider:(__strong RCTBridgeModuleListProvider)block + launchOptions:(NSDictionary *)launchOptions +{ + return self; +} + +- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args +{ +} + +- (void)enqueueJSCall:(NSString *)module + method:(NSString *)method + args:(NSArray *)args + completion:(__strong dispatch_block_t)completion +{ +} + +- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path +{ +} + +- (id)moduleForName:(NSString *)moduleName +{ + return nil; +} + +- (id)moduleForName:(NSString *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad +{ + return nil; +} + +- (id)moduleForClass:(Class)moduleClass +{ + return nil; +} + +- (void)setRCTTurboModuleRegistry:(id)turboModuleRegistry +{ +} + +- (RCTBridgeModuleDecorator *)bridgeModuleDecorator +{ + return nil; +} + +- (NSArray *)modulesConformingToProtocol:(Protocol *)protocol +{ + return @[]; +} + +- (BOOL)moduleIsInitialized:(Class)moduleClass +{ + return NO; +} + +- (void)reload __attribute__((deprecated("Use RCTReloadCommand instead"))) +{ +} + +- (void)reloadWithReason:(NSString *)reason __attribute__((deprecated("Use RCTReloadCommand instead"))) +{ +} + +- (void)onFastRefresh +{ +} + +- (void)requestReload __attribute__((deprecated("Use RCTReloadCommand instead"))) +{ +} + +- (BOOL)isBatchActive +{ + return NO; +} + +- (void)setUp +{ +} + +- (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args +{ +} + ++ (void)setCurrentBridge:(RCTBridge *)bridge +{ +} + +- (void)invalidate +{ +} + ++ (instancetype)currentBridge +{ + return nil; +} + +@end +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTBridgeDelegate.h b/packages/react-native/React/Base/RCTBridgeDelegate.h index fc4d6313da90..298eb650b829 100644 --- a/packages/react-native/React/Base/RCTBridgeDelegate.h +++ b/packages/react-native/React/Base/RCTBridgeDelegate.h @@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol RCTBridgeDelegate +#ifndef RCT_FIT_RM_OLD_RUNTIME /** * The location of the JavaScript source file. When running from the packager @@ -69,6 +70,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (NSDictionary *)extraLazyModuleClassesForBridge:(RCTBridge *)bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME @end NS_ASSUME_NONNULL_END diff --git a/packages/react-native/React/Base/RCTBridgeModule.h b/packages/react-native/React/Base/RCTBridgeModule.h index 435606538d66..1fb3e3e0e7ef 100644 --- a/packages/react-native/React/Base/RCTBridgeModule.h +++ b/packages/react-native/React/Base/RCTBridgeModule.h @@ -354,7 +354,9 @@ RCT_EXTERN_C_END * A class that allows NativeModules and TurboModules to look up one another. */ @interface RCTModuleRegistry : NSObject +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setTurboModuleRegistry:(id)turboModuleRegistry; - (id)moduleForName:(const char *)moduleName; @@ -373,7 +375,9 @@ typedef void (^RCTViewRegistryUIBlock)(RCTViewRegistry *viewRegistry); * A class that allows NativeModules to query for views, given React Tags. */ @interface RCTViewRegistry : NSObject +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)bridgelessComponentViewProvider; - (UIView *)viewForReactTag:(NSNumber *)reactTag; @@ -391,7 +395,9 @@ typedef void (^RCTBridgelessJSModuleMethodInvoker)( * as callable with React Native. */ @interface RCTCallableJSModules : NSObject +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setBridgelessJSModuleMethodInvoker:(RCTBridgelessJSModuleMethodInvoker)bridgelessJSModuleMethodInvoker; - (void)invokeModule:(NSString *)moduleName method:(NSString *)methodName withArgs:(NSArray *)args; diff --git a/packages/react-native/React/Base/RCTBridgeProxy.mm b/packages/react-native/React/Base/RCTBridgeProxy.mm index 6e54f3776bef..3a55fbf925e4 100644 --- a/packages/react-native/React/Base/RCTBridgeProxy.mm +++ b/packages/react-native/React/Base/RCTBridgeProxy.mm @@ -308,6 +308,7 @@ - (void)start cmd:_cmd]; } +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)registerModuleForFrameUpdates:(id)module withModuleData:(RCTModuleData *)moduleData { [self logError:@"This method is not supported. Nooping" cmd:_cmd]; @@ -318,6 +319,7 @@ - (RCTModuleData *)moduleDataForName:(NSString *)moduleName [self logError:@"This method is not supported. Returning nil." cmd:_cmd]; return nil; } +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)registerAdditionalModuleClasses:(NSArray *)newModules { diff --git a/packages/react-native/React/Base/RCTBundleManager.h b/packages/react-native/React/Base/RCTBundleManager.h index cd63944935a4..f7e963ed8b77 100644 --- a/packages/react-native/React/Base/RCTBundleManager.h +++ b/packages/react-native/React/Base/RCTBundleManager.h @@ -16,7 +16,9 @@ typedef void (^RCTBridgelessBundleURLSetter)(NSURL *bundleURL); * A class that allows NativeModules/TurboModules to read/write the bundleURL, with or without the bridge. */ @interface RCTBundleManager : NSObject +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setBridgelessBundleURLGetter:(RCTBridgelessBundleURLGetter)getter andSetter:(RCTBridgelessBundleURLSetter)setter andDefaultGetter:(RCTBridgelessBundleURLGetter)defaultGetter; diff --git a/packages/react-native/React/Base/RCTBundleManager.m b/packages/react-native/React/Base/RCTBundleManager.m index 8ea361fd5737..ce06d1d1608a 100644 --- a/packages/react-native/React/Base/RCTBundleManager.m +++ b/packages/react-native/React/Base/RCTBundleManager.m @@ -11,16 +11,20 @@ #import "RCTBridge.h" @implementation RCTBundleManager { +#ifndef RCT_FIT_RM_OLD_RUNTIME __weak RCTBridge *_bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME RCTBridgelessBundleURLGetter _bridgelessBundleURLGetter; RCTBridgelessBundleURLSetter _bridgelessBundleURLSetter; RCTBridgelessBundleURLGetter _bridgelessBundleURLDefaultGetter; } +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge { _bridge = bridge; } +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setBridgelessBundleURLGetter:(RCTBridgelessBundleURLGetter)getter andSetter:(RCTBridgelessBundleURLSetter)setter @@ -33,10 +37,12 @@ - (void)setBridgelessBundleURLGetter:(RCTBridgelessBundleURLGetter)getter - (void)setBundleURL:(NSURL *)bundleURL { +#ifndef RCT_FIT_RM_OLD_RUNTIME if (_bridge) { _bridge.bundleURL = bundleURL; return; } +#endif // RCT_FIT_RM_OLD_RUNTIME RCTAssert( _bridgelessBundleURLSetter != nil, @@ -46,9 +52,11 @@ - (void)setBundleURL:(NSURL *)bundleURL - (NSURL *)bundleURL { +#ifndef RCT_FIT_RM_OLD_RUNTIME if (_bridge) { return _bridge.bundleURL; } +#endif // RCT_FIT_RM_OLD_RUNTIME RCTAssert( _bridgelessBundleURLGetter != nil, @@ -59,11 +67,13 @@ - (NSURL *)bundleURL - (void)resetBundleURL { +#ifndef RCT_FIT_RM_OLD_RUNTIME RCTBridge *strongBridge = _bridge; if (strongBridge) { strongBridge.bundleURL = [strongBridge.delegate sourceURLForBridge:strongBridge]; return; } +#endif // RCT_FIT_RM_OLD_RUNTIME RCTAssert( _bridgelessBundleURLDefaultGetter != nil, diff --git a/packages/react-native/React/Base/RCTCallInvokerModule.h b/packages/react-native/React/Base/RCTCallInvokerModule.h index 7d33baecdad5..db8a297b3f64 100644 --- a/packages/react-native/React/Base/RCTCallInvokerModule.h +++ b/packages/react-native/React/Base/RCTCallInvokerModule.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#import + @class RCTCallInvoker; /** diff --git a/packages/react-native/React/Base/RCTCallableJSModules.m b/packages/react-native/React/Base/RCTCallableJSModules.m index 5fd69033f6a5..ac2f46151b8f 100644 --- a/packages/react-native/React/Base/RCTCallableJSModules.m +++ b/packages/react-native/React/Base/RCTCallableJSModules.m @@ -10,13 +10,17 @@ @implementation RCTCallableJSModules { RCTBridgelessJSModuleMethodInvoker _bridgelessJSModuleMethodInvoker; +#ifndef RCT_FIT_RM_OLD_RUNTIME __weak RCTBridge *_bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME } +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge { _bridge = bridge; } +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setBridgelessJSModuleMethodInvoker:(RCTBridgelessJSModuleMethodInvoker)bridgelessJSModuleMethodInvoker { @@ -33,11 +37,13 @@ - (void)invokeModule:(NSString *)moduleName withArgs:(NSArray *)args onComplete:(dispatch_block_t)onComplete { +#ifndef RCT_FIT_RM_OLD_RUNTIME RCTBridge *bridge = _bridge; if (bridge) { [bridge enqueueJSCall:moduleName method:methodName args:args completion:onComplete]; return; } +#endif // RCT_FIT_RM_OLD_RUNTIME if (_bridgelessJSModuleMethodInvoker) { _bridgelessJSModuleMethodInvoker(moduleName, methodName, args, onComplete); diff --git a/packages/react-native/React/Base/RCTJavaScriptExecutor.h b/packages/react-native/React/Base/RCTJavaScriptExecutor.h index d1913044af54..a8a71b976111 100644 --- a/packages/react-native/React/Base/RCTJavaScriptExecutor.h +++ b/packages/react-native/React/Base/RCTJavaScriptExecutor.h @@ -13,6 +13,7 @@ typedef void (^RCTJavaScriptCompleteBlock)(NSError *error); typedef void (^RCTJavaScriptCallback)(id result, NSError *error); +#ifndef RCT_FIT_RM_OLD_RUNTIME /** * Abstracts away a JavaScript execution context - we may be running code in a * web view (for debugging purposes), or may be running code in a `JSContext`. @@ -78,3 +79,4 @@ typedef void (^RCTJavaScriptCallback)(id result, NSError *error); - (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block; @end +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTModuleData.mm b/packages/react-native/React/Base/RCTModuleData.mm index eec30be066f9..225f6b3c16ef 100644 --- a/packages/react-native/React/Base/RCTModuleData.mm +++ b/packages/react-native/React/Base/RCTModuleData.mm @@ -7,6 +7,8 @@ #import "RCTModuleData.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import #import #import @@ -485,3 +487,38 @@ - (NSString *)description } @end + +#else // RCT_FIT_RM_OLD_RUNTIME +@implementation RCTModuleData + +- (instancetype)initWithModuleClass:(Class)moduleClass + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED + bundleManager:(RCTBundleManager *)bundleManager + callableJSModules:(RCTCallableJSModules *)callableJSModules +{ + return self; +} + +- (instancetype)initWithModuleInstance:(id)instance + bridge:(RCTBridge *)bridge + moduleRegistry:(RCTModuleRegistry *)moduleRegistry + viewRegistry_DEPRECATED:(RCTViewRegistry *)viewRegistry_DEPRECATED + bundleManager:(RCTBundleManager *)bundleManager + callableJSModules:(RCTCallableJSModules *)callableJSModules +{ + return self; +} + +- (void)gatherConstants +{ +} + +- (void)invalidate +{ +} + +@end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTModuleMethod.mm b/packages/react-native/React/Base/RCTModuleMethod.mm index 5b2b66d54530..ba0693a4ca80 100644 --- a/packages/react-native/React/Base/RCTModuleMethod.mm +++ b/packages/react-native/React/Base/RCTModuleMethod.mm @@ -476,6 +476,7 @@ - (SEL)selector [self processMethodSignature]; RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } + return _selector; } diff --git a/packages/react-native/React/Base/RCTModuleRegistry.m b/packages/react-native/React/Base/RCTModuleRegistry.m index 21fbfd662773..7a1c3bb85c5d 100644 --- a/packages/react-native/React/Base/RCTModuleRegistry.m +++ b/packages/react-native/React/Base/RCTModuleRegistry.m @@ -12,13 +12,17 @@ @implementation RCTModuleRegistry { __weak id _turboModuleRegistry; +#ifndef RCT_FIT_RM_OLD_RUNTIME __weak RCTBridge *_bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME } +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge { _bridge = bridge; } +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setTurboModuleRegistry:(id)turboModuleRegistry { @@ -34,10 +38,12 @@ - (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyL { id module = nil; +#ifndef RCT_FIT_RM_OLD_RUNTIME RCTBridge *bridge = _bridge; if (bridge) { module = [bridge moduleForName: [NSString stringWithUTF8String:moduleName] lazilyLoadIfNecessary:lazilyLoad]; } +#endif // RCT_FIT_RM_OLD_RUNTIME id turboModuleRegistry = _turboModuleRegistry; if (module == nil && turboModuleRegistry && (lazilyLoad || [turboModuleRegistry moduleIsInitialized:moduleName])) { @@ -49,11 +55,13 @@ - (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyL - (BOOL)moduleIsInitialized:(Class)moduleClass { +#ifndef RCT_FIT_RM_OLD_RUNTIME RCTBridge *bridge = _bridge; if (bridge) { return [bridge moduleIsInitialized:moduleClass]; } +#endif // RCT_FIT_RM_OLD_RUNTIME id turboModuleRegistry = _turboModuleRegistry; if (turboModuleRegistry) { diff --git a/packages/react-native/React/Base/RCTRootContentView.h b/packages/react-native/React/Base/RCTRootContentView.h index 50a5f3ff93fc..a29818d604e5 100644 --- a/packages/react-native/React/Base/RCTRootContentView.h +++ b/packages/react-native/React/Base/RCTRootContentView.h @@ -7,6 +7,8 @@ #import +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import #import #import @@ -30,3 +32,5 @@ sizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility NS_DESIGNATED_INITIALIZER; @end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTRootContentView.m b/packages/react-native/React/Base/RCTRootContentView.m index 24b918cc7f1a..e619b9748e96 100644 --- a/packages/react-native/React/Base/RCTRootContentView.m +++ b/packages/react-native/React/Base/RCTRootContentView.m @@ -7,6 +7,8 @@ #import "RCTRootContentView.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import "RCTBridge.h" #import "RCTPerformanceLogger.h" #import "RCTRootView.h" @@ -105,3 +107,5 @@ - (void)invalidate } @end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTRootView.m b/packages/react-native/React/Base/RCTRootView.m index 8938f4197e4d..cbfdc209ddce 100644 --- a/packages/react-native/React/Base/RCTRootView.m +++ b/packages/react-native/React/Base/RCTRootView.m @@ -30,6 +30,8 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotification"; +#ifndef RCT_FIT_RM_OLD_RUNTIME + @implementation RCTRootView { RCTBridge *_bridge; NSString *_moduleName; @@ -396,3 +398,33 @@ - (void)cancelTouches } @end + +#else // RCT_FIT_RM_OLD_RUNTIME + +@implementation RCTRootView +- (nonnull instancetype)initWithFrame:(CGRect)frame + bridge:(nonnull RCTBridge *)bridge + moduleName:(nonnull NSString *)moduleName + initialProperties:(nullable NSDictionary *)initialProperties +{ + return self; +} + +- (nonnull instancetype)initWithBridge:(nonnull RCTBridge *)bridge + moduleName:(nonnull NSString *)moduleName + initialProperties:(nullable NSDictionary *)initialProperties +{ + return self; +} + +- (nonnull instancetype)initWithBundleURL:(nonnull NSURL *)bundleURL + moduleName:(nonnull NSString *)moduleName + initialProperties:(nullable NSDictionary *)initialProperties + launchOptions:(nullable NSDictionary *)launchOptions +{ + return self; +} + +@end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTRootViewInternal.h b/packages/react-native/React/Base/RCTRootViewInternal.h index bfff4e089348..ab9bf126ac29 100644 --- a/packages/react-native/React/Base/RCTRootViewInternal.h +++ b/packages/react-native/React/Base/RCTRootViewInternal.h @@ -7,6 +7,8 @@ #import +#ifndef RCT_FIT_RM_OLD_RUNTIME + /** * The interface provides a set of functions that allow other internal framework * classes to change the RCTRootViews's internal state. @@ -22,3 +24,5 @@ - (void)contentViewInvalidated; @end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/RCTViewRegistry.m b/packages/react-native/React/Base/RCTViewRegistry.m index dc54d78c6860..d189adaa659d 100644 --- a/packages/react-native/React/Base/RCTViewRegistry.m +++ b/packages/react-native/React/Base/RCTViewRegistry.m @@ -13,13 +13,17 @@ @implementation RCTViewRegistry { RCTBridgelessComponentViewProvider _bridgelessComponentViewProvider; +#ifndef RCT_FIT_RM_OLD_RUNTIME __weak RCTBridge *_bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME } +#ifndef RCT_FIT_RM_OLD_RUNTIME - (void)setBridge:(RCTBridge *)bridge { _bridge = bridge; } +#endif // RCT_FIT_RM_OLD_RUNTIME - (void)setBridgelessComponentViewProvider:(RCTBridgelessComponentViewProvider)bridgelessComponentViewProvider { @@ -30,10 +34,12 @@ - (UIView *)viewForReactTag:(NSNumber *)reactTag { UIView *view = nil; +#ifndef RCT_FIT_RM_OLD_RUNTIME RCTBridge *bridge = _bridge; if (bridge) { view = [bridge.uiManager viewForReactTag:reactTag]; } +#endif // RCT_FIT_RM_OLD_RUNTIME if (view == nil && _bridgelessComponentViewProvider) { view = _bridgelessComponentViewProvider(reactTag); @@ -49,6 +55,7 @@ - (void)addUIBlock:(RCTViewRegistryUIBlock)block } __weak __typeof(self) weakSelf = self; +#ifndef RCT_FIT_RM_OLD_RUNTIME if (_bridge) { [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { __typeof(self) strongSelf = weakSelf; @@ -56,14 +63,16 @@ - (void)addUIBlock:(RCTViewRegistryUIBlock)block block(strongSelf); } }]; - } else { - RCTExecuteOnMainQueue(^{ - __typeof(self) strongSelf = weakSelf; - if (strongSelf) { - block(strongSelf); - } - }); + return; } +#endif + + RCTExecuteOnMainQueue(^{ + __typeof(self) strongSelf = weakSelf; + if (strongSelf) { + block(strongSelf); + } + }); // RCT_FIT_RM_OLD_RUNTIME } @end diff --git a/packages/react-native/React/Base/Surface/RCTSurface.mm b/packages/react-native/React/Base/Surface/RCTSurface.mm index 2ff9a18c3483..14f88de1f3dd 100644 --- a/packages/react-native/React/Base/Surface/RCTSurface.mm +++ b/packages/react-native/React/Base/Surface/RCTSurface.mm @@ -27,6 +27,8 @@ #import "RCTUIManagerObserverCoordinator.h" #import "RCTUIManagerUtils.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + @interface RCTSurface () @end @@ -604,3 +606,69 @@ - (NSInteger)rootTag } @end + +#else // RCT_FIT_RM_OLD_RUNTIME +@implementation RCTSurface +@synthesize stage; +@synthesize moduleName; +@synthesize delegate; +@synthesize rootViewTag; +@synthesize properties; +@synthesize rootTag; +@synthesize intrinsicSize; + +- (nonnull instancetype)initWithBridge:(nonnull RCTBridge *)bridge + moduleName:(nonnull NSString *)moduleName + initialProperties:(nonnull NSDictionary *)initialProperties +{ + return self; +} + +- (void)setSize:(CGSize)size +{ +} + +- (BOOL)synchronouslyWaitForStage:(RCTSurfaceStage)stage timeout:(NSTimeInterval)timeout +{ + return NO; +} + +- (void)mountReactComponentWithBridge:(nonnull RCTBridge *)bridge + moduleName:(nonnull NSString *)moduleName + params:(nonnull NSDictionary *)params +{ +} + +- (void)unmountReactComponentWithBridge:(nonnull RCTBridge *)bridge rootViewTag:(nonnull NSNumber *)rootViewTag +{ +} + +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize +{ +} + +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize viewportOffset:(CGPoint)viewportOffset +{ +} + +- (nonnull RCTSurfaceView *)view +{ + return nil; +} + +- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize +{ + return {}; +} + +- (void)start +{ +} + +- (void)stop +{ +} + +@end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowView.m b/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowView.m index 95cf3390657f..443382f68597 100644 --- a/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowView.m +++ b/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowView.m @@ -7,6 +7,8 @@ #import "RCTSurfaceRootShadowView.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import "RCTI18nUtil.h" #import "RCTShadowView+Layout.h" #import "RCTUIManagerUtils.h" @@ -89,3 +91,18 @@ - (CGSize)intrinsicSize } @end + +#else // RCT_FIT_RM_OLD_RUNTIME + +@implementation RCTSurfaceRootShadowView +- (void)setMinimumSize:(CGSize)size maximumSize:(CGSize)maximumSize +{ +} + +- (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews +{ +} + +@end + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Base/Surface/RCTSurfaceView.mm b/packages/react-native/React/Base/Surface/RCTSurfaceView.mm index 35040be1f773..e022df1e86de 100644 --- a/packages/react-native/React/Base/Surface/RCTSurfaceView.mm +++ b/packages/react-native/React/Base/Surface/RCTSurfaceView.mm @@ -10,6 +10,7 @@ #import "RCTDefines.h" #import "RCTSurface.h" +#import "RCTSurfaceProtocol.h" #import "RCTSurfaceRootView.h" @implementation RCTSurfaceView { diff --git a/packages/react-native/React/CoreModules/RCTLogBox.mm b/packages/react-native/React/CoreModules/RCTLogBox.mm index fd4d95036b00..70e48175cb3d 100644 --- a/packages/react-native/React/CoreModules/RCTLogBox.mm +++ b/packages/react-native/React/CoreModules/RCTLogBox.mm @@ -58,7 +58,9 @@ - (void)setSurfacePresenter:(id)surfacePresenter strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow() surfacePresenter:strongSelf->_bridgelessSurfacePresenter]; [strongSelf->_view show]; - } else if (strongSelf->_bridge && strongSelf->_bridge.valid) { + } +#ifndef RCT_FIT_RM_OLD_RUNTIME + else if (strongSelf->_bridge && strongSelf->_bridge.valid) { if (strongSelf->_bridge.surfacePresenter) { strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow() surfacePresenter:strongSelf->_bridge.surfacePresenter]; @@ -67,6 +69,7 @@ - (void)setSurfacePresenter:(id)surfacePresenter } [strongSelf->_view show]; } +#endif // RCT_FIT_RM_OLD_RUNTIME }); } } diff --git a/packages/react-native/React/CoreModules/RCTLogBoxView.h b/packages/react-native/React/CoreModules/RCTLogBoxView.h index 5c790e446651..2c46d64a9945 100644 --- a/packages/react-native/React/CoreModules/RCTLogBoxView.h +++ b/packages/react-native/React/CoreModules/RCTLogBoxView.h @@ -16,7 +16,9 @@ - (void)createRootViewController:(UIView *)view; +#ifndef RCT_FIT_RM_OLD_RUNTIME - (instancetype)initWithWindow:(UIWindow *)window bridge:(RCTBridge *)bridge; +#endif // RCT_FIT_RM_OLD_RUNTIME - (instancetype)initWithWindow:(UIWindow *)window surfacePresenter:(id)surfacePresenter; - (void)show; diff --git a/packages/react-native/React/CoreModules/RCTLogBoxView.mm b/packages/react-native/React/CoreModules/RCTLogBoxView.mm index b2de00b58515..91f5dcfbd3c3 100644 --- a/packages/react-native/React/CoreModules/RCTLogBoxView.mm +++ b/packages/react-native/React/CoreModules/RCTLogBoxView.mm @@ -12,7 +12,9 @@ #import @implementation RCTLogBoxView { +#ifndef RCT_FIT_RM_OLD_RUNTIME RCTSurface *_surface; +#endif // RCT_FIT_RM_OLD_RUNTIME } - (instancetype)initWithFrame:(CGRect)frame @@ -33,6 +35,7 @@ - (void)createRootViewController:(UIView *)view self.rootViewController = _rootViewController; } +#ifndef RCT_FIT_RM_OLD_RUNTIME - (instancetype)initWithWindow:(UIWindow *)window bridge:(RCTBridge *)bridge { RCTErrorNewArchitectureValidation(RCTNotAllowedInFabricWithoutLegacy, @"RCTLogBoxView", nil); @@ -52,6 +55,7 @@ - (instancetype)initWithWindow:(UIWindow *)window bridge:(RCTBridge *)bridge return self; } +#endif // RCT_FIT_RM_OLD_RUNTIME - (instancetype)initWithWindow:(UIWindow *)window surfacePresenter:(id)surfacePresenter { @@ -70,7 +74,9 @@ - (instancetype)initWithWindow:(UIWindow *)window surfacePresenter:(id namespace facebook::react { @@ -25,3 +27,5 @@ class JSCExecutorFactory : public JSExecutorFactory { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxBridge/JSCExecutorFactory.mm b/packages/react-native/React/CxxBridge/JSCExecutorFactory.mm index 6173ae5ccffa..401df0d7247f 100644 --- a/packages/react-native/React/CxxBridge/JSCExecutorFactory.mm +++ b/packages/react-native/React/CxxBridge/JSCExecutorFactory.mm @@ -7,6 +7,8 @@ #include "JSCExecutorFactory.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import #import @@ -22,3 +24,5 @@ } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxBridge/RCTCxxBridge.mm b/packages/react-native/React/CxxBridge/RCTCxxBridge.mm index 834c7a11c460..421e4a2f3bf0 100644 --- a/packages/react-native/React/CxxBridge/RCTCxxBridge.mm +++ b/packages/react-native/React/CxxBridge/RCTCxxBridge.mm @@ -64,6 +64,8 @@ #import #endif +#ifndef RCT_FIT_RM_OLD_RUNTIME + static NSString *const RCTJSThreadName = @"com.facebook.react.JavaScript"; typedef void (^RCTPendingCall)(); @@ -1587,3 +1589,8 @@ - (RCTCallInvoker *)callInvokerForModuleData:(RCTModuleData *)moduleData } @end + +#else // RCT_FIT_RM_OLD_RUNTIME +@implementation RCTCxxBridge +@end +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h b/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h index a258102a21ff..853d5998fdb8 100644 --- a/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h +++ b/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include namespace facebook::react { @@ -19,3 +21,5 @@ JSIExecutor::RuntimeInstaller RCTJSIExecutorRuntimeInstaller( JSIExecutor::RuntimeInstaller runtimeInstallerToWrap); } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.mm b/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.mm index 8cd4c52f6550..44d1df616092 100644 --- a/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.mm +++ b/packages/react-native/React/CxxBridge/RCTJSIExecutorRuntimeInstaller.mm @@ -7,6 +7,8 @@ #include "RCTJSIExecutorRuntimeInstaller.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import #include @@ -28,3 +30,5 @@ } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxBridge/RCTObjcExecutor.h b/packages/react-native/React/CxxBridge/RCTObjcExecutor.h index 87ad0858f505..272d73157e36 100644 --- a/packages/react-native/React/CxxBridge/RCTObjcExecutor.h +++ b/packages/react-native/React/CxxBridge/RCTObjcExecutor.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -29,3 +31,5 @@ class RCTObjcExecutorFactory : public JSExecutorFactory { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm b/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm index de029f15c85c..94976166fa92 100644 --- a/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm +++ b/packages/react-native/React/CxxBridge/RCTObjcExecutor.mm @@ -7,6 +7,8 @@ #import "RCTObjcExecutor.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import #import #import @@ -144,3 +146,5 @@ virtual void setGlobalVariable(std::string propName, std::unique_ptr #include +#ifndef RCT_FIT_RM_OLD_RUNTIME + namespace facebook::react { // RCTNativeModule arranges for native methods to be invoked on a queue which @@ -43,3 +45,5 @@ class DispatchMessageQueueThread : public MessageQueueThread { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxModule/RCTCxxUtils.h b/packages/react-native/React/CxxModule/RCTCxxUtils.h index b4411088e19f..5f041a543ffa 100644 --- a/packages/react-native/React/CxxModule/RCTCxxUtils.h +++ b/packages/react-native/React/CxxModule/RCTCxxUtils.h @@ -18,9 +18,13 @@ namespace facebook::react { class Instance; class NativeModule; +#ifndef RCT_FIT_RM_OLD_RUNTIME + std::vector> createNativeModules(NSArray *modules, RCTBridge *bridge, const std::shared_ptr &instance); +#endif // RCT_FIT_RM_OLD_RUNTIME + NSError *tryAndReturnError(const std::function &func); NSString *deriveSourceURL(NSURL *url); diff --git a/packages/react-native/React/CxxModule/RCTCxxUtils.mm b/packages/react-native/React/CxxModule/RCTCxxUtils.mm index 3f70b0d927c9..132052ae8f49 100644 --- a/packages/react-native/React/CxxModule/RCTCxxUtils.mm +++ b/packages/react-native/React/CxxModule/RCTCxxUtils.mm @@ -20,6 +20,8 @@ using facebook::jsi::JSError; +#ifndef RCT_FIT_RM_OLD_RUNTIME + std::vector> createNativeModules(NSArray *modules, RCTBridge *bridge, const std::shared_ptr &instance) { @@ -38,6 +40,8 @@ return nativeModules; } +#endif // RCT_FIT_RM_OLD_RUNTIME + static NSError *errorWithException(const std::exception &e) { NSString *msg = @(e.what()); diff --git a/packages/react-native/React/CxxModule/RCTNativeModule.h b/packages/react-native/React/CxxModule/RCTNativeModule.h index 9b870cfd2fe5..9f7d32c68b03 100644 --- a/packages/react-native/React/CxxModule/RCTNativeModule.h +++ b/packages/react-native/React/CxxModule/RCTNativeModule.h @@ -8,6 +8,8 @@ #import #import +#ifndef RCT_FIT_RM_OLD_RUNTIME + namespace facebook::react { class RCTNativeModule : public NativeModule { @@ -30,3 +32,5 @@ class RCTNativeModule : public NativeModule { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/CxxModule/RCTNativeModule.mm b/packages/react-native/React/CxxModule/RCTNativeModule.mm index 12074ae471c7..6150f31bf0c0 100644 --- a/packages/react-native/React/CxxModule/RCTNativeModule.mm +++ b/packages/react-native/React/CxxModule/RCTNativeModule.mm @@ -7,6 +7,8 @@ #import "RCTNativeModule.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #import #import #import @@ -235,3 +237,5 @@ static MethodCallResult invokeInner( } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/React/Modules/RCTUIManager.mm b/packages/react-native/React/Modules/RCTUIManager.mm index 5a5d84d1f0a3..d552a9f28eae 100644 --- a/packages/react-native/React/Modules/RCTUIManager.mm +++ b/packages/react-native/React/Modules/RCTUIManager.mm @@ -40,6 +40,101 @@ #import "RCTViewManager.h" #import "UIView+React.h" +NSMutableDictionary *RCTModuleConstantsForDestructuredComponent( + NSMutableDictionary *directEvents, + NSMutableDictionary *bubblingEvents, + Class managerClass, + NSString *name, + NSDictionary *viewConfig) +{ + NSMutableDictionary *moduleConstants = [NSMutableDictionary new]; + + // Register which event-types this view dispatches. + // React needs this for the event plugin. + NSMutableDictionary *bubblingEventTypes = [NSMutableDictionary new]; + NSMutableDictionary *directEventTypes = [NSMutableDictionary new]; + + // Add manager class + moduleConstants[@"Manager"] = RCTBridgeModuleNameForClass(managerClass); + + // Add native props + moduleConstants[@"NativeProps"] = viewConfig[@"propTypes"]; + moduleConstants[@"baseModuleName"] = viewConfig[@"baseModuleName"]; + moduleConstants[@"bubblingEventTypes"] = bubblingEventTypes; + moduleConstants[@"directEventTypes"] = directEventTypes; + // In the Old Architecture the "Commands" and "Constants" properties of view manager config are populated by + // lazifyViewManagerConfig function in JS. This fuction uses NativeModules global object that is not available in the + // New Architecture. To make native view configs work in the New Architecture we will populate these properties in + // native. + if (facebook::react::ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode()) { + moduleConstants[@"Commands"] = viewConfig[@"Commands"]; + moduleConstants[@"Constants"] = viewConfig[@"Constants"]; + } + // Add direct events + for (NSString *eventName in viewConfig[@"directEvents"]) { + if (!directEvents[eventName]) { + directEvents[eventName] = @{ + @"registrationName" : [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"], + }; + } + directEventTypes[eventName] = directEvents[eventName]; + if (RCT_DEBUG && bubblingEvents[eventName]) { + RCTLogError( + @"Component '%@' re-registered bubbling event '%@' as a " + "direct event", + name, + eventName); + } + } + + // Add bubbling events + for (NSString *eventName in viewConfig[@"bubblingEvents"]) { + if (!bubblingEvents[eventName]) { + NSString *bubbleName = [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"]; + bubblingEvents[eventName] = @{ + @"phasedRegistrationNames" : @{ + @"bubbled" : bubbleName, + @"captured" : [bubbleName stringByAppendingString:@"Capture"], + } + }; + } + bubblingEventTypes[eventName] = bubblingEvents[eventName]; + if (RCT_DEBUG && directEvents[eventName]) { + RCTLogError( + @"Component '%@' re-registered direct event '%@' as a " + "bubbling event", + name, + eventName); + } + } + + // Add capturing events (added as bubbling events but with the 'skipBubbling' flag) + for (NSString *eventName in viewConfig[@"capturingEvents"]) { + if (!bubblingEvents[eventName]) { + NSString *bubbleName = [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"]; + bubblingEvents[eventName] = @{ + @"phasedRegistrationNames" : @{ + @"bubbled" : bubbleName, + @"captured" : [bubbleName stringByAppendingString:@"Capture"], + @"skipBubbling" : @YES + } + }; + } + bubblingEventTypes[eventName] = bubblingEvents[eventName]; + if (RCT_DEBUG && directEvents[eventName]) { + RCTLogError( + @"Component '%@' re-registered direct event '%@' as a " + "bubbling event", + name, + eventName); + } + } + + return moduleConstants; +} + +#ifndef RCT_FIT_RM_OLD_RUNTIME + static void RCTTraverseViewNodes(id view, void (^block)(id)) { if (view.reactTag) { @@ -1412,99 +1507,6 @@ static void RCTMeasureLayout(RCTShadowView *view, RCTShadowView *ancestor, RCTRe }]; } -NSMutableDictionary *RCTModuleConstantsForDestructuredComponent( - NSMutableDictionary *directEvents, - NSMutableDictionary *bubblingEvents, - Class managerClass, - NSString *name, - NSDictionary *viewConfig) -{ - NSMutableDictionary *moduleConstants = [NSMutableDictionary new]; - - // Register which event-types this view dispatches. - // React needs this for the event plugin. - NSMutableDictionary *bubblingEventTypes = [NSMutableDictionary new]; - NSMutableDictionary *directEventTypes = [NSMutableDictionary new]; - - // Add manager class - moduleConstants[@"Manager"] = RCTBridgeModuleNameForClass(managerClass); - - // Add native props - moduleConstants[@"NativeProps"] = viewConfig[@"propTypes"]; - moduleConstants[@"baseModuleName"] = viewConfig[@"baseModuleName"]; - moduleConstants[@"bubblingEventTypes"] = bubblingEventTypes; - moduleConstants[@"directEventTypes"] = directEventTypes; - // In the Old Architecture the "Commands" and "Constants" properties of view manager config are populated by - // lazifyViewManagerConfig function in JS. This fuction uses NativeModules global object that is not available in the - // New Architecture. To make native view configs work in the New Architecture we will populate these properties in - // native. - if (facebook::react::ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode()) { - moduleConstants[@"Commands"] = viewConfig[@"Commands"]; - moduleConstants[@"Constants"] = viewConfig[@"Constants"]; - } - // Add direct events - for (NSString *eventName in viewConfig[@"directEvents"]) { - if (!directEvents[eventName]) { - directEvents[eventName] = @{ - @"registrationName" : [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"], - }; - } - directEventTypes[eventName] = directEvents[eventName]; - if (RCT_DEBUG && bubblingEvents[eventName]) { - RCTLogError( - @"Component '%@' re-registered bubbling event '%@' as a " - "direct event", - name, - eventName); - } - } - - // Add bubbling events - for (NSString *eventName in viewConfig[@"bubblingEvents"]) { - if (!bubblingEvents[eventName]) { - NSString *bubbleName = [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"]; - bubblingEvents[eventName] = @{ - @"phasedRegistrationNames" : @{ - @"bubbled" : bubbleName, - @"captured" : [bubbleName stringByAppendingString:@"Capture"], - } - }; - } - bubblingEventTypes[eventName] = bubblingEvents[eventName]; - if (RCT_DEBUG && directEvents[eventName]) { - RCTLogError( - @"Component '%@' re-registered direct event '%@' as a " - "bubbling event", - name, - eventName); - } - } - - // Add capturing events (added as bubbling events but with the 'skipBubbling' flag) - for (NSString *eventName in viewConfig[@"capturingEvents"]) { - if (!bubblingEvents[eventName]) { - NSString *bubbleName = [eventName stringByReplacingCharactersInRange:(NSRange){0, 3} withString:@"on"]; - bubblingEvents[eventName] = @{ - @"phasedRegistrationNames" : @{ - @"bubbled" : bubbleName, - @"captured" : [bubbleName stringByAppendingString:@"Capture"], - @"skipBubbling" : @YES - } - }; - } - bubblingEventTypes[eventName] = bubblingEvents[eventName]; - if (RCT_DEBUG && directEvents[eventName]) { - RCTLogError( - @"Component '%@' re-registered direct event '%@' as a " - "bubbling event", - name, - eventName); - } - } - - return moduleConstants; -} - static NSMutableDictionary *moduleConstantsForComponentData( NSMutableDictionary *directEvents, NSMutableDictionary *bubblingEvents, @@ -1651,6 +1653,117 @@ - (RCTUIManager *)uiManager @end +#else // RCT_FIT_RM_OLD_RUNTIME + +@implementation RCTUIManager +- (void)registerRootViewTag:(NSNumber *)rootTag +{ +} + +- (void)registerRootView:(UIView *)rootView +{ +} + +- (UIView *)viewForReactTag:(NSNumber *)reactTag +{ + return nil; +} + +- (void)removeViewFromRegistry:(NSNumber *)reactTag +{ +} + +- (NSString *)viewNameForReactTag:(NSNumber *)reactTag +{ + return nil; +} + +- (RCTShadowView *)shadowViewForReactTag:(NSNumber *)reactTag +{ + return nil; +} + +- (void)setAvailableSize:(CGSize)availableSize forRootView:(UIView *)rootView +{ +} + +- (void)setLocalData:(NSObject *)localData forView:(UIView *)view +{ +} + +- (void)setSize:(CGSize)size forView:(UIView *)view +{ +} + +- (void)setIntrinsicContentSize:(CGSize)intrinsicContentSize forView:(UIView *)view +{ +} + +- (void)setNextLayoutAnimationGroup:(RCTLayoutAnimationGroup *)layoutAnimationGroup +{ +} + +- (void)addUIBlock:(__strong RCTViewManagerUIBlock)block +{ +} + +- (void)prependUIBlock:(__strong RCTViewManagerUIBlock)block +{ +} + +- (void)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag viewName:(NSString *)viewName props:(NSDictionary *)props +{ +} + +- (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^__strong)(UIView *__strong))completion +{ +} + +- (UIView *)viewForNativeID:(NSString *)nativeID withRootTag:(NSNumber *)rootTag +{ + return nil; +} + +- (void)setNativeID:(NSString *)nativeID forView:(UIView *)view +{ +} + +- (void)setNeedsLayout +{ +} + ++ (UIView *)JSResponder +{ + return nil; +} + ++ (UIView *)paperViewOrCurrentView:(UIView *)view +{ + return nil; +} + ++ (NSString *)moduleName +{ + return @"UIManager"; +} + +- (void)invalidate +{ +} + +@end + +@implementation RCTBridge (RCTUIManager) + +- (RCTUIManager *)uiManager +{ + return [self moduleForClass:[RCTUIManager class]]; +} + +@end + +#endif // RCT_FIT_RM_OLD_RUNTIME + @implementation RCTComposedViewRegistry { __weak RCTUIManager *_uiManager; NSDictionary *_registry; diff --git a/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp b/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp index af2101b70c30..3ca3d4bbdf91 100644 --- a/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp +++ b/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp @@ -6,6 +6,9 @@ */ #include "CxxNativeModule.h" + +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include "Instance.h" #include @@ -250,3 +253,5 @@ void CxxNativeModule::lazyInit() { } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.h b/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.h index 024b80e13e8e..5390a577f10a 100644 --- a/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.h +++ b/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -66,3 +68,5 @@ class RN_EXPORT CxxNativeModule : public NativeModule { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/Instance.cpp b/packages/react-native/ReactCommon/cxxreact/Instance.cpp index c2f0feb02458..3fda838887a0 100644 --- a/packages/react-native/ReactCommon/cxxreact/Instance.cpp +++ b/packages/react-native/ReactCommon/cxxreact/Instance.cpp @@ -7,6 +7,8 @@ #include "Instance.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include "ErrorUtils.h" #include "JSBigString.h" #include "JSBundleType.h" @@ -362,3 +364,5 @@ void Instance::JSCallInvoker::scheduleAsync(CallFunc&& work) noexcept { } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/Instance.h b/packages/react-native/ReactCommon/cxxreact/Instance.h index 6a8ba6f47dd4..3c61aa2ab191 100644 --- a/packages/react-native/ReactCommon/cxxreact/Instance.h +++ b/packages/react-native/ReactCommon/cxxreact/Instance.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -184,3 +186,5 @@ class RN_EXPORT Instance : private jsinspector_modern::InstanceTargetDelegate { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp b/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp index ae47983f39b6..daffddc50357 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp +++ b/packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp @@ -18,9 +18,11 @@ namespace facebook::react { std::string JSExecutor::getSyntheticBundlePath( uint32_t bundleId, const std::string& bundlePath) { +#ifndef RCT_FIT_RM_OLD_RUNTIME if (bundleId == RAMBundleRegistry::MAIN_BUNDLE_ID) { return bundlePath; } +#endif // RCT_FIT_RM_OLD_RUNTIME std::array buffer{}; std::snprintf(buffer.data(), buffer.size(), "seg-%u.js", bundleId); diff --git a/packages/react-native/ReactCommon/cxxreact/JSExecutor.h b/packages/react-native/ReactCommon/cxxreact/JSExecutor.h index 7106147cdd94..ecc1e0fd1c5f 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSExecutor.h +++ b/packages/react-native/ReactCommon/cxxreact/JSExecutor.h @@ -70,11 +70,13 @@ class RN_EXPORT JSExecutor { std::unique_ptr script, std::string sourceURL) = 0; +#ifndef RCT_FIT_RM_OLD_RUNTIME /** * Add an application "RAM" bundle registry */ virtual void setBundleRegistry( std::unique_ptr bundleRegistry) = 0; +#endif // RCT_FIT_RM_OLD_RUNTIME /** * Register a file path for an additional "RAM" bundle diff --git a/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp b/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp index 44236f788e5b..7b89fae05118 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp +++ b/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.cpp @@ -7,6 +7,9 @@ #include "JSIndexedRAMBundle.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + +#include #include #include @@ -129,3 +132,5 @@ void JSIndexedRAMBundle::readBundle( } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.h b/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.h index 235c1751005d..9a377b50d012 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.h +++ b/packages/react-native/ReactCommon/cxxreact/JSIndexedRAMBundle.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -71,3 +73,5 @@ class RN_EXPORT JSIndexedRAMBundle : public JSModulesUnbundle { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/JSModulesUnbundle.h b/packages/react-native/ReactCommon/cxxreact/JSModulesUnbundle.h index 0d793706855c..2a6c63d3213f 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSModulesUnbundle.h +++ b/packages/react-native/ReactCommon/cxxreact/JSModulesUnbundle.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -42,3 +44,5 @@ class JSModulesUnbundle { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp b/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp index 6e7dd1222361..aaacea636c96 100644 --- a/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp +++ b/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp @@ -7,6 +7,8 @@ #include "MethodCall.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -85,3 +87,5 @@ std::vector parseMethodCalls(folly::dynamic&& jsonData) { } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/MethodCall.h b/packages/react-native/ReactCommon/cxxreact/MethodCall.h index 6869aabc08f8..f774463a0695 100644 --- a/packages/react-native/ReactCommon/cxxreact/MethodCall.h +++ b/packages/react-native/ReactCommon/cxxreact/MethodCall.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -32,3 +34,5 @@ struct MethodCall { std::vector parseMethodCalls(folly::dynamic&& calls); } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp index 080e1992ca9d..51a884321f71 100644 --- a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp +++ b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp @@ -7,6 +7,8 @@ #include "ModuleRegistry.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -239,3 +241,5 @@ MethodCallResult ModuleRegistry::callSerializableNativeHook( } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h index f3d5c76d7802..bed262bc82ed 100644 --- a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h +++ b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -88,3 +90,5 @@ class RN_EXPORT ModuleRegistry { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/NativeModule.h b/packages/react-native/ReactCommon/cxxreact/NativeModule.h index aa09befa183f..5e4bb138c63b 100644 --- a/packages/react-native/ReactCommon/cxxreact/NativeModule.h +++ b/packages/react-native/ReactCommon/cxxreact/NativeModule.h @@ -15,6 +15,7 @@ namespace facebook::react { +#ifndef RCT_FIT_RM_OLD_RUNTIME struct MethodDescriptor { std::string name; // type is one of js MessageQueue.MethodTypes @@ -23,9 +24,11 @@ struct MethodDescriptor { MethodDescriptor(std::string n, std::string t) : name(std::move(n)), type(std::move(t)) {} }; +#endif // RCT_FIT_RM_OLD_RUNTIME using MethodCallResult = std::optional; +#ifndef RCT_FIT_RM_OLD_RUNTIME class NativeModule { public: virtual ~NativeModule() {} @@ -39,5 +42,6 @@ class NativeModule { unsigned int reactMethodId, folly::dynamic&& args) = 0; }; +#endif // RCT_FIT_RM_OLD_RUNTIME } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp b/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp index 785f212fc127..8afed017083a 100644 --- a/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp +++ b/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp @@ -7,6 +7,8 @@ #include "NativeToJsBridge.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -345,3 +347,5 @@ NativeToJsBridge::getInspectorTargetDelegate() { } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.h b/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.h index da3fa32068ea..f7b48ab61da7 100644 --- a/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.h +++ b/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -135,3 +137,5 @@ class NativeToJsBridge { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp b/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp index c45be54c8cba..9ab03ea1d80b 100644 --- a/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp +++ b/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp @@ -7,6 +7,8 @@ #include "RAMBundleRegistry.h" +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -78,3 +80,5 @@ JSModulesUnbundle* RAMBundleRegistry::getBundle(uint32_t bundleId) const { } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.h b/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.h index 9defcc13bde3..16f6c297b02d 100644 --- a/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.h +++ b/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include #include @@ -52,3 +54,5 @@ class RN_EXPORT RAMBundleRegistry { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index 9a1ce11b70ae..d44721fd30a3 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -25,6 +25,8 @@ using namespace facebook::jsi; namespace facebook::react { +#ifndef RCT_FIT_RM_OLD_RUNTIME + class JSIExecutor::NativeModuleProxy : public jsi::HostObject { public: NativeModuleProxy(std::shared_ptr nativeModules) @@ -521,6 +523,55 @@ Value JSIExecutor::globalEvalWithSourceUrl(const Value* args, size_t count) { std::make_unique(std::move(code)), url); } +#else // RCT_FIT_RM_OLD_RUNTIME + +JSIExecutor::JSIExecutor( + std::shared_ptr runtime, + std::shared_ptr delegate, + const JSIScopedTimeoutInvoker& scopedTimeoutInvoker, + RuntimeInstaller runtimeInstaller) {} + +void JSIExecutor::initializeRuntime() {} + +void JSIExecutor::loadBundle( + std::unique_ptr script, + std::string sourceURL) {} + +void JSIExecutor::registerBundle( + uint32_t bundleId, + const std::string& bundlePath) {} + +void JSIExecutor::callFunction( + const std::string& moduleId, + const std::string& methodId, + const folly::dynamic& arguments) {} + +void JSIExecutor::invokeCallback( + const double callbackId, + const folly::dynamic& arguments) {} + +void JSIExecutor::setGlobalVariable( + std::string propName, + std::unique_ptr jsonValue) {} + +std::string JSIExecutor::getDescription() { + return "null"; +} + +void* JSIExecutor::getJavaScriptContext() { + return nullptr; +} + +bool JSIExecutor::isInspectable() { + return false; +} + +void JSIExecutor::handleMemoryPressure(int pressureLevel) {} + +void JSIExecutor::flush() {} + +#endif // RCT_FIT_RM_OLD_RUNTIME + void bindNativeLogger(Runtime& runtime, Logger logger) { runtime.global().setProperty( runtime, diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h index 9234e3a32e5e..6464d537ddbc 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h @@ -80,7 +80,9 @@ class JSIExecutor : public JSExecutor { void loadBundle( std::unique_ptr script, std::string sourceURL) override; +#ifndef RCT_FIT_RM_OLD_RUNTIME void setBundleRegistry(std::unique_ptr) override; +#endif // RCT_FIT_RM_OLD_RUNTIME void registerBundle(uint32_t bundleId, const std::string& bundlePath) override; void callFunction( @@ -109,6 +111,7 @@ class JSIExecutor : public JSExecutor { void flush() override; private: +#ifndef RCT_FIT_RM_OLD_RUNTIME class NativeModuleProxy; void bindBridge(); @@ -129,6 +132,7 @@ class JSIExecutor : public JSExecutor { std::optional callFunctionReturnFlushedQueue_; std::optional invokeCallbackAndReturnFlushedQueue_; std::optional flushedQueue_; +#endif // RCT_FIT_RM_OLD_RUNTIME }; using Logger = diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp index 1e90273192ba..18332c7252af 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp @@ -6,6 +6,9 @@ */ #include "jsireact/JSINativeModules.h" + +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -107,3 +110,5 @@ std::optional JSINativeModules::createModule( } } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h index 9b63e9438b94..1b32dd65d2c0 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h @@ -7,6 +7,8 @@ #pragma once +#ifndef RCT_FIT_RM_OLD_RUNTIME + #include #include @@ -36,3 +38,5 @@ class JSINativeModules { }; } // namespace facebook::react + +#endif // RCT_FIT_RM_OLD_RUNTIME diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.h b/packages/react-native/ReactCommon/react/runtime/ReactInstance.h index 51709eebcd7a..0221ce1f55db 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include #include