From 4230de0f5817c0ba4f43acaec525102ffaee6c7e Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Fri, 26 Aug 2022 17:56:51 -0700 Subject: [PATCH] Modularlize RCTBridgeModule.h 1/n - Move RCTBundleManager.h to its own file in ReactInternal target Summary: Changelog: [Internal][iOS] Modularlize RCTBridgeModule.h 1/n - Move RCTBundleManager.h to its own file in ReactInternal target # Why clean up RCTBridgeModule.h? Clean up one unnecessary import of RCTBridgeModule.h. RCTBridgeModule includes a lot of header files, and this header is imported everywhere. The ultimate goal is that files (especially React Native infra files) should only import only what they need and not import the entirely of RCTBridgeModule.h whenever possible. This way, certain headers that are Bridge-only can be compiled out of the new architecture with a flag. The other benefit of splitting up the headers like this is that it'll be much easier for developers to navigate between the .h and .mm files. Reviewed By: philIip Differential Revision: D38943262 fbshipit-source-id: 90876324de9fae25bf33c7aef820a32d7c6ce2f8 --- BUCK | 1 + React/Base/Modules/RCTBundleManager.h | 23 +++++++++++++++++++++ React/Base/{ => Modules}/RCTBundleManager.m | 2 +- React/Base/RCTBridgeModule.h | 18 ++-------------- packages/rn-tester/Podfile.lock | 6 +++--- 5 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 React/Base/Modules/RCTBundleManager.h rename React/Base/{ => Modules}/RCTBundleManager.m (98%) diff --git a/BUCK b/BUCK index ba4cfef87ee..9305085d9cf 100644 --- a/BUCK +++ b/BUCK @@ -255,6 +255,7 @@ REACT_PUBLIC_HEADERS = { "React/RCTBridgeMethod.h": RCTBASE_PATH + "RCTBridgeMethod.h", "React/RCTBridgeModule.h": RCTBASE_PATH + "RCTBridgeModule.h", "React/RCTBridgeModuleDecorator.h": RCTBASE_PATH + "RCTBridgeModuleDecorator.h", + "React/RCTBundleManager.h": RCTBASE_PATH + "Modules/RCTBundleManager.h", "React/RCTBundleURLProvider.h": RCTBASE_PATH + "RCTBundleURLProvider.h", "React/RCTComponent.h": RCTVIEWS_PATH + "RCTComponent.h", "React/RCTComponentData.h": RCTVIEWS_PATH + "RCTComponentData.h", diff --git a/React/Base/Modules/RCTBundleManager.h b/React/Base/Modules/RCTBundleManager.h new file mode 100644 index 00000000000..15ed245dbea --- /dev/null +++ b/React/Base/Modules/RCTBundleManager.h @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@class RCTBridge; + +typedef NSURL * (^RCTBridgelessBundleURLGetter)(void); +typedef void (^RCTBridgelessBundleURLSetter)(NSURL *bundleURL); + +/** + * A class that allows NativeModules/TurboModules to read/write the bundleURL, with or without the bridge. + */ +@interface RCTBundleManager : NSObject +- (void)setBridge:(RCTBridge *)bridge; +- (void)setBridgelessBundleURLGetter:(RCTBridgelessBundleURLGetter)getter + andSetter:(RCTBridgelessBundleURLSetter)setter + andDefaultGetter:(RCTBridgelessBundleURLGetter)defaultGetter; +- (void)resetBundleURL; +@property NSURL *bundleURL; +@end diff --git a/React/Base/RCTBundleManager.m b/React/Base/Modules/RCTBundleManager.m similarity index 98% rename from React/Base/RCTBundleManager.m rename to React/Base/Modules/RCTBundleManager.m index 97b9400af60..8ea361fd573 100644 --- a/React/Base/RCTBundleManager.m +++ b/React/Base/Modules/RCTBundleManager.m @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ +#import "RCTBundleManager.h" #import "RCTAssert.h" #import "RCTBridge+Private.h" #import "RCTBridge.h" -#import "RCTBridgeModule.h" @implementation RCTBundleManager { __weak RCTBridge *_bridge; diff --git a/React/Base/RCTBridgeModule.h b/React/Base/RCTBridgeModule.h index ae2066f16f4..ebff76a153e 100644 --- a/React/Base/RCTBridgeModule.h +++ b/React/Base/RCTBridgeModule.h @@ -15,9 +15,10 @@ @protocol RCTBridgeMethod; @class RCTModuleRegistry; @class RCTViewRegistry; -@class RCTBundleManager; @class RCTCallableJSModules; +#import "Modules/RCTBundleManager.h" + /** * The type of a block that is capable of sending a response to a bridged * operation. Use this for returning callback methods to JS. @@ -420,21 +421,6 @@ RCT_EXTERN_C_END - (id)moduleForName:(const char *)moduleName lazilyLoadIfNecessary:(BOOL)lazilyLoad; @end -typedef void (^RCTBridgelessBundleURLSetter)(NSURL *bundleURL); -typedef NSURL * (^RCTBridgelessBundleURLGetter)(void); - -/** - * A class that allows NativeModules/TurboModules to read/write the bundleURL, with or without the bridge. - */ -@interface RCTBundleManager : NSObject -- (void)setBridge:(RCTBridge *)bridge; -- (void)setBridgelessBundleURLGetter:(RCTBridgelessBundleURLGetter)getter - andSetter:(RCTBridgelessBundleURLSetter)setter - andDefaultGetter:(RCTBridgelessBundleURLGetter)defaultGetter; -- (void)resetBundleURL; -@property NSURL *bundleURL; -@end - typedef UIView * (^RCTBridgelessComponentViewProvider)(NSNumber *); typedef void (^RCTViewRegistryUIBlock)(RCTViewRegistry *viewRegistry); diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 79f3012fe08..104aa5779f2 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -918,13 +918,13 @@ SPEC CHECKSUMS: RCTRequired: 1c8808cf84569265784a6c33984bbb506ada8c6e RCTTypeSafety: b6dcb5036a808864ee8cad66ca15f263c24661cc React: 8d809d414723bb5763093ddec7658066a21ccabc - React-bridging: cc10a051eff1f03306a1d7659593d8aac3242bc3 + React-bridging: c8806159f8ef90f27443857eed1efdb8c85940e1 React-callinvoker: 5f16202ad4e45f0607b1fae0f6955a8f7c87eef1 React-Codegen: 5adf19af97eb37a7d441c040521191e446255086 React-Core: ce4282fb714ffbe444b84d296d1728eaee4d0e9f React-CoreModules: 675170bccf156da3a3348e04e2036ce401b2010d React-cxxreact: 7276467c246302fedf598cc40d7003896ddb20ba - React-Fabric: abfd61dc5498ce165634af85d65fcc42b82b5bf4 + React-Fabric: b49c8e76c926b5b6b708802759b27dd6e02bb4bc React-graphics: 5ccc9cc0d91794fd42bc1c693e9aea207554bbef React-jsi: a042596cb558abea721ab5e23cb175647610a73d React-jsiexecutor: f7fbac5dff7e7ff110a66edf2626b4f4f4600ef5 @@ -946,7 +946,7 @@ SPEC CHECKSUMS: React-RCTVibration: 0386f50996a153b3f39cecbe7d139763ac9a9fdf React-rncore: 2a6ad37560e94cf7ff32e3f2ae1e708491b4c1f3 React-runtimeexecutor: 97dca9247f4d3cfe0733384b189c6930fbd402b7 - ReactCommon: 6cef8ed13ee2a9d7d4cf9660dbe6dd2ea6ba7104 + ReactCommon: 8e39c4b24da570ea2b631accbf779b5891befe0c ScreenshotManager: 71d047abd38a77310985b87f8136b620c5c61e88 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 Yoga: 1b1a12ff3d86a10565ea7cbe057d42f5e5fb2a07