mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-01 14:25:08 +08:00
stash the Source URL when loading a script.
Reviewed By: javache Differential Revision: D4437195 fbshipit-source-id: 14698fc81bbe24cab81668bfb54578fc434abc58
This commit is contained in:
committed by
Facebook Github Bot
parent
cec787563a
commit
2ade5f3781
@@ -26,22 +26,11 @@ import com.facebook.react.module.annotations.ReactModule;
|
||||
public class SourceCodeModule extends BaseJavaModule {
|
||||
|
||||
private final ReactContext mReactContext;
|
||||
private @Nullable String mSourceUrl;
|
||||
|
||||
public SourceCodeModule(ReactContext reactContext) {
|
||||
mReactContext = reactContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
mSourceUrl =
|
||||
Assertions.assertNotNull(
|
||||
mReactContext.getCatalystInstance().getSourceURL(),
|
||||
"No source URL loaded, have you initialised the instance?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RCTSourceCode";
|
||||
@@ -50,7 +39,13 @@ public class SourceCodeModule extends BaseJavaModule {
|
||||
@Override
|
||||
public @Nullable Map<String, Object> getConstants() {
|
||||
HashMap<String, Object> constants = new HashMap<>();
|
||||
constants.put("scriptURL", mSourceUrl);
|
||||
|
||||
String sourceURL =
|
||||
Assertions.assertNotNull(
|
||||
mReactContext.getCatalystInstance().getSourceURL(),
|
||||
"No source URL loaded, have you initialised the instance?");
|
||||
|
||||
constants.put("scriptURL", sourceURL);
|
||||
return constants;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user