Skip to content

Commit bc9fa22

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Deprecate unread factory config blocks, delete loadSourceForBridge (#59439)
Summary: Pull Request resolved: #59439 Seven bridge-related factory configuration blocks are written but never read. Mark them deprecated since external clients still set them, and delete the eighth (`loadSourceForBridge`), which has no writers at all. Also remove our own dead write and the only reader method. Changelog: [Internal] Reviewed By: andrewdacenko Differential Revision: D127294779
1 parent af45c03 commit bc9fa22

7 files changed

Lines changed: 15 additions & 33 deletions

File tree

‎packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,6 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
295295
[weakSelf.delegate customizeRootView:(RCTRootView *)rootView];
296296
};
297297

298-
if ([self.delegate respondsToSelector:@selector(extraModulesForBridge:)]) {
299-
configuration.extraModulesForBridge = ^NSArray<id<RCTBridgeModule>> *_Nonnull(RCTBridge *_Nonnull bridge)
300-
{
301-
return [weakSelf.delegate extraModulesForBridge:bridge];
302-
};
303-
}
304-
305298
configuration.jsRuntimeConfiguratorDelegate = self;
306299

307300
return [[RCTRootViewFactory alloc] initWithTurboModuleDelegate:self hostDelegate:self configuration:configuration];

‎packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ typedef void (^RCTLoadSourceForBridgeWithProgressBlock)(
3838
RCTBridge *bridge,
3939
RCTSourceLoadProgressBlock onProgress,
4040
RCTSourceLoadBlock loadCallback);
41-
typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBlock loadCallback);
4241

4342
#pragma mark - RCTRootViewFactory Configuration
4443
@interface RCTRootViewFactoryConfiguration : NSObject
@@ -79,7 +78,8 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
7978
*
8079
* @returns: a UIView properly configured with a bridge for React Native.
8180
*/
82-
@property (nonatomic, nullable) RCTCreateRootViewWithBridgeBlock createRootViewWithBridge;
81+
@property (nonatomic, nullable) RCTCreateRootViewWithBridgeBlock createRootViewWithBridge __deprecated_msg(
82+
"This API will be removed along with the legacy architecture.");
8383

8484
/**
8585
* Block that allows to override default behavior of creating bridge.
@@ -92,7 +92,8 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
9292
*
9393
* @returns: a newly created instance of RCTBridge.
9494
*/
95-
@property (nonatomic, nullable) RCTCreateBridgeWithDelegateBlock createBridgeWithDelegate;
95+
@property (nonatomic, nullable) RCTCreateBridgeWithDelegateBlock createBridgeWithDelegate __deprecated_msg(
96+
"This API will be removed along with the legacy architecture.");
9697

9798
/**
9899
* Block that allows to customize the rootView that is passed to React Native.
@@ -111,7 +112,8 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
111112
* When running from a locally bundled JS file, this should be a `file://` url
112113
* pointing to a path inside the app resources, e.g. `file://.../main.jsbundle`.
113114
*/
114-
@property (nonatomic, nullable) RCTSourceURLForBridgeBlock sourceURLForBridge;
115+
@property (nonatomic, nullable) RCTSourceURLForBridgeBlock sourceURLForBridge __deprecated_msg(
116+
"This API will be removed along with the legacy architecture.");
115117

116118
/**
117119
* The bridge initializes any registered RCTBridgeModules automatically, however
@@ -127,12 +129,14 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
127129
* not recommended in most cases - if the module methods and behavior do not
128130
* match exactly, it may lead to bugs or crashes.
129131
*/
130-
@property (nonatomic, nullable) RCTExtraModulesForBridgeBlock extraModulesForBridge;
132+
@property (nonatomic, nullable) RCTExtraModulesForBridgeBlock extraModulesForBridge __deprecated_msg(
133+
"This API will be removed along with the legacy architecture.");
131134

132135
/**
133136
* Retrieve the list of lazy-native-modules names for the given bridge.
134137
*/
135-
@property (nonatomic, nullable) RCTExtraLazyModuleClassesForBridge extraLazyModuleClassesForBridge;
138+
@property (nonatomic, nullable) RCTExtraLazyModuleClassesForBridge extraLazyModuleClassesForBridge __deprecated_msg(
139+
"This API will be removed along with the legacy architecture.");
136140

137141
/**
138142
* The bridge will call this block when a module has been called from JS
@@ -141,20 +145,17 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
141145
* in the implementation, and the system must attempt to look for it again among registered.
142146
* If the module was not registered, return NO to prevent further searches.
143147
*/
144-
@property (nonatomic, nullable) RCTBridgeDidNotFindModuleBlock bridgeDidNotFindModule;
148+
@property (nonatomic, nullable) RCTBridgeDidNotFindModuleBlock bridgeDidNotFindModule __deprecated_msg(
149+
"This API will be removed along with the legacy architecture.");
145150

146151
/**
147152
* The bridge will automatically attempt to load the JS source code from the
148153
* location specified by the `sourceURLForBridge:` method, however, if you want
149154
* to handle loading the JS yourself, you can do so by setting this property.
150155
*/
151-
@property (nonatomic, nullable) RCTLoadSourceForBridgeWithProgressBlock loadSourceForBridgeWithProgress;
152-
153-
/**
154-
* Similar to loadSourceForBridgeWithProgress but without progress
155-
* reporting.
156-
*/
157-
@property (nonatomic, nullable) RCTLoadSourceForBridgeBlock loadSourceForBridge;
156+
@property (nonatomic, nullable)
157+
RCTLoadSourceForBridgeWithProgressBlock loadSourceForBridgeWithProgress __deprecated_msg(
158+
"This API will be removed along with the legacy architecture.");
158159

159160
@end
160161

‎packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,6 @@ - (RCTHost *)createReactHost:(NSDictionary *)launchOptions
229229
reinterpret_cast<facebook::react::JSRuntimeFactory *>(jsRuntimeFactory), &js_runtime_factory_destroy);
230230
}
231231

232-
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
233-
{
234-
if (_configuration.extraModulesForBridge != nil) {
235-
return _configuration.extraModulesForBridge(bridge);
236-
}
237-
return nil;
238-
}
239-
240232
- (NSURL *)bundleURL
241233
{
242234
return self->_configuration.bundleURLBlock();

‎scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,6 @@ interface RCTRootViewFactoryConfiguration : public NSObject {
15651565
public @property (assign) RCTCustomizeRootViewBlock customizeRootView;
15661566
public @property (assign) RCTExtraLazyModuleClassesForBridge extraLazyModuleClassesForBridge;
15671567
public @property (assign) RCTExtraModulesForBridgeBlock extraModulesForBridge;
1568-
public @property (assign) RCTLoadSourceForBridgeBlock loadSourceForBridge;
15691568
public @property (assign) RCTLoadSourceForBridgeWithProgressBlock loadSourceForBridgeWithProgress;
15701569
public @property (assign) RCTSourceURLForBridgeBlock sourceURLForBridge;
15711570
public @property (weak) id<RCTJSRuntimeConfiguratorProtocol> jsRuntimeConfiguratorDelegate;

‎scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,6 @@ interface RCTRootViewFactoryConfiguration : public NSObject {
16081608
public @property (assign) RCTCustomizeRootViewBlock customizeRootView;
16091609
public @property (assign) RCTExtraLazyModuleClassesForBridge extraLazyModuleClassesForBridge;
16101610
public @property (assign) RCTExtraModulesForBridgeBlock extraModulesForBridge;
1611-
public @property (assign) RCTLoadSourceForBridgeBlock loadSourceForBridge;
16121611
public @property (assign) RCTLoadSourceForBridgeWithProgressBlock loadSourceForBridgeWithProgress;
16131612
public @property (assign) RCTSourceURLForBridgeBlock sourceURLForBridge;
16141613
public @property (weak) id<RCTJSRuntimeConfiguratorProtocol> jsRuntimeConfiguratorDelegate;

‎scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,6 @@ interface RCTRootViewFactoryConfiguration : public NSObject {
15641564
public @property (assign) RCTCustomizeRootViewBlock customizeRootView;
15651565
public @property (assign) RCTExtraLazyModuleClassesForBridge extraLazyModuleClassesForBridge;
15661566
public @property (assign) RCTExtraModulesForBridgeBlock extraModulesForBridge;
1567-
public @property (assign) RCTLoadSourceForBridgeBlock loadSourceForBridge;
15681567
public @property (assign) RCTLoadSourceForBridgeWithProgressBlock loadSourceForBridgeWithProgress;
15691568
public @property (assign) RCTSourceURLForBridgeBlock sourceURLForBridge;
15701569
public @property (weak) id<RCTJSRuntimeConfiguratorProtocol> jsRuntimeConfiguratorDelegate;

‎scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,6 @@ interface RCTRootViewFactoryConfiguration : public NSObject {
15651565
public @property (assign) RCTCustomizeRootViewBlock customizeRootView;
15661566
public @property (assign) RCTExtraLazyModuleClassesForBridge extraLazyModuleClassesForBridge;
15671567
public @property (assign) RCTExtraModulesForBridgeBlock extraModulesForBridge;
1568-
public @property (assign) RCTLoadSourceForBridgeBlock loadSourceForBridge;
15691568
public @property (assign) RCTLoadSourceForBridgeWithProgressBlock loadSourceForBridgeWithProgress;
15701569
public @property (assign) RCTSourceURLForBridgeBlock sourceURLForBridge;
15711570
public @property (weak) id<RCTJSRuntimeConfiguratorProtocol> jsRuntimeConfiguratorDelegate;

0 commit comments

Comments
 (0)