-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: NativeModules can read from, or write to, the bridge's bundleURL. To do so, they access the bundleURL property on the bridge directly. **Setter:** https://www.internalfb.com/code/fbsource/[2a74581dfff31febe6e91c5739294705f5244ecb]/xplat/js/react-native-github/React/CoreModules/RCTDevMenu.mm?lines=213-214 **Getter:** https://www.internalfb.com/code/fbsource/[2a74581dfff31febe6e91c5739294705f5244ecb]/xplat/js/react-native-github/React/CoreModules/RCTDevMenu.mm?lines=245%2C256 In bridgeless mode, the bridge is nil. So, this form of access will fail. After this stack lands, every NativeModule will be able to synthesize an RCTBundleManager, like so: ``` synthesize bundleManager = _bundleManager; ``` From then on, all NativeModules will use this bundleManager to access the bundle URL. This should ensure that NativeModules can read from/write to the bundleURL, **even in bridgeless mode**. Changelog: [iOS][Added] - Introduce RCTBundleManager for bundleURL access Reviewed By: PeteTheHeat Differential Revision: D28086318 fbshipit-source-id: 34c15bf05c144341aa912fad9aa25d6d3a364f9e
- v0.77.0-rc.2
- v0.77.0-rc.1
- v0.77.0-rc.0
- v0.76.5
- v0.76.4
- v0.76.3
- v0.76.2
- v0.76.1
- v0.76.0
- v0.76.0-rc.6
- v0.76.0-rc.5
- v0.76.0-rc.4
- v0.76.0-rc.3
- v0.76.0-rc.2
- v0.76.0-rc.1
- v0.76.0-rc.0
- v0.75.4
- v0.75.3
- v0.75.2
- v0.75.1
- v0.75.0
- v0.75.0-rc.7
- v0.75.0-rc.6
- v0.75.0-rc.5
- v0.75.0-rc.4
- v0.75.0-rc.3
- v0.75.0-rc.2
- v0.75.0-rc.1
- v0.75.0-rc.0
- v0.74.6
- v0.74.5
- v0.74.4
- v0.74.3
- v0.74.2
- v0.74.1
- v0.74.1-rc.0
- v0.74.0
- v0.74.0-rc.9
- v0.74.0-rc.8
- v0.74.0-rc.7
- v0.74.0-rc.6
- v0.74.0-rc.5
- v0.74.0-rc.4
- v0.74.0-rc.3
- v0.74.0-rc.2
- v0.74.0-rc.1
- v0.74.0-rc.0
- v0.73.11
- v0.73.10
- v0.73.9
- v0.73.8
- v0.73.7
- v0.73.6
- v0.73.5
- v0.73.4
- v0.73.3
- v0.73.2
- v0.73.1
- v0.73.0
- v0.73.0-rc.8
- v0.73.0-rc.7
- v0.73.0-rc.6
- v0.73.0-rc.5
- v0.73.0-rc.4
- v0.73.0-rc.3
- v0.73.0-rc.2
- v0.73.0-rc.1
- v0.73.0-rc.0
- v0.72.17
- v0.72.16
- v0.72.15
- v0.72.14
- v0.72.13
- v0.72.12
- v0.72.11
- v0.72.10
- v0.72.9
- v0.72.8
- v0.72.7
- v0.72.6
- v0.72.5
- v0.72.4
- v0.72.3
- v0.72.2
- v0.72.1
- v0.72.0
- v0.72.0-rc.6
- v0.72.0-rc.5
- v0.72.0-rc.4
- v0.72.0-rc.3
- v0.72.0-rc.2
- v0.72.0-rc.1
- v0.72.0-rc.0
- v0.71.19
- v0.71.18
- v0.71.17
- v0.71.16
- v0.71.15
- v0.71.14
- v0.71.13
- v0.71.12
- v0.71.11
- v0.71.10
- v0.71.9
- v0.71.8
- v0.71.7
- v0.71.6
- v0.71.5
- v0.71.4
- v0.71.3
- v0.71.2
- v0.71.1
- v0.71.0
- v0.71.0-rc.6
- v0.71.0-rc.5
- v0.71.0-rc.4
- v0.71.0-rc.3
- v0.71.0-rc.2
- v0.71.0-rc.1
- v0.71.0-rc.0
- v0.70.15
- v0.70.14
- v0.70.13
- v0.70.12
- v0.70.11
- v0.70.10
- v0.70.9
- v0.70.8
- v0.70.7
- v0.70.6
- v0.70.5
- v0.70.4
- v0.70.3
- v0.70.2
- v0.70.1
- v0.70.0
- v0.70.0-rc.4
- v0.70.0-rc.3
- v0.70.0-rc.2
- v0.70.0-rc.1
- v0.70.0-rc.0
- v0.69.12
- v0.69.11
- v0.69.10
- v0.69.9
- v0.69.8
- v0.69.7
- v0.69.6
- v0.69.5
- v0.69.4
- v0.69.3
- v0.69.2
- v0.69.1
- v0.69.0
- v0.69.0-rc.6
- v0.69.0-rc.5
- v0.69.0-rc.4
- v0.69.0-rc.3
- v0.69.0-rc.2
- v0.69.0-rc.1
- v0.69.0-rc.0
- v0.68.7
- v0.68.6
- v0.68.5
- v0.68.4
- v0.68.3
- v0.68.2
- v0.68.1
- v0.68.0
- v0.68.0-rc.4
- v0.68.0-rc.3
- v0.68.0-rc.2
- v0.68.0-rc.1
- v0.68.0-rc.0
- v0.67.5
- v0.67.4
- v0.67.3
- v0.67.2
- v0.67.1
- v0.67.0
- v0.67.0-rc.6
- v0.67.0-rc.5
- v0.67.0-rc.4
- v0.67.0-rc.3
- v0.67.0-rc.2
- v0.67.0-rc.1
- v0.67.0-rc.0
- v0.66.5
- v0.66.4
- v0.66.3
- v0.66.2
- v0.66.1
- v0.66.0
- v0.66.0-rc.4
- v0.66.0-rc.3
- v0.66.0-rc.2
- v0.66.0-rc.1
- v0.66.0-rc.0
- latest
1 parent
7db89f9
commit 4a1bafe
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "RCTAssert.h" | ||
#import "RCTBridge+Private.h" | ||
#import "RCTBridge.h" | ||
#import "RCTBridgeModule.h" | ||
|
||
@implementation RCTBundleManager { | ||
__weak RCTBridge *_bridge; | ||
RCTBridgelessBundleURLGetter _bridgelessBundleURLGetter; | ||
RCTBridgelessBundleURLSetter _bridgelessBundleURLSetter; | ||
} | ||
|
||
- (void)setBridge:(RCTBridge *)bridge | ||
{ | ||
_bridge = bridge; | ||
} | ||
|
||
- (void)setBridgelessBundleURLGetter:(RCTBridgelessBundleURLGetter)getter andSetter:(RCTBridgelessBundleURLSetter)setter | ||
{ | ||
_bridgelessBundleURLGetter = getter; | ||
_bridgelessBundleURLSetter = setter; | ||
} | ||
|
||
- (void)setBundleURL:(NSURL *)bundleURL | ||
{ | ||
if (_bridge) { | ||
_bridge.bundleURL = bundleURL; | ||
return; | ||
} | ||
|
||
RCTAssert( | ||
_bridgelessBundleURLSetter != nil, | ||
@"RCTBundleManager: In bridgeless mode, RCTBridgelessBundleURLSetter must not be nil."); | ||
_bridgelessBundleURLSetter(bundleURL); | ||
} | ||
|
||
- (NSURL *)bundleURL | ||
{ | ||
if (_bridge) { | ||
return _bridge.bundleURL; | ||
} | ||
|
||
RCTAssert( | ||
_bridgelessBundleURLGetter != nil, | ||
@"RCTBundleManager: In bridgeless mode, RCTBridgelessBundleURLGetter must not be nil."); | ||
|
||
return _bridgelessBundleURLGetter(); | ||
} | ||
|
||
@end |