expose JS source location to JS

Differential Revision: D2526103

fb-gh-sync-id: d597b52dd9442fc27b0841b7df447e9d8d7de6e1
This commit is contained in:
Felix Oghină
2015-10-09 04:22:51 -07:00
committed by facebook-github-bot-9
parent fffae394c7
commit 3a0a1a4122
3 changed files with 26 additions and 1 deletions

View File

@@ -86,6 +86,7 @@ public class ReactInstanceManager {
private @Nullable volatile ReactContext mCurrentReactContext;
private final Context mApplicationContext;
private @Nullable DefaultHardwareBackBtnHandler mDefaultBackButtonImpl;
private String mSourceUrl;
private final ReactInstanceDevCommandsHandler mDevInterface =
new ReactInstanceDevCommandsHandler() {
@@ -340,6 +341,13 @@ public class ReactInstanceManager {
mDevSupportManager.showDevOptionsDialog();
}
/**
* Get the URL where the last bundle was loaded from.
*/
public String getSourceUrl() {
return Assertions.assertNotNull(mSourceUrl);
}
/**
* Attach given {@param rootView} to a catalyst instance manager and start JS application using
* JS module provided by {@link ReactRootView#getJSModuleName}. If the react context is currently
@@ -493,6 +501,7 @@ public class ReactInstanceManager {
JavaScriptExecutor jsExecutor,
JSBundleLoader jsBundleLoader) {
FLog.i(ReactConstants.TAG, "Creating react context.");
mSourceUrl = jsBundleLoader.getSourceUrl();
NativeModuleRegistry.Builder nativeRegistryBuilder = new NativeModuleRegistry.Builder();
JavaScriptModulesConfig.Builder jsModulesBuilder = new JavaScriptModulesConfig.Builder();