diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index b645d997172..fe13dd68981 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -455,4 +455,14 @@ public class ReactContext extends ContextWrapper { } return mCatalystInstance.getJSIModule(moduleType); } + + /** + * Get the sourceURL for the JS bundle from the CatalystInstance. This method is needed for + * compatibility with bridgeless mode, which has no CatalystInstance. + * + * @return The JS bundle URL set when the bundle was loaded + */ + public @Nullable String getSourceURL() { + return mCatalystInstance.getSourceURL(); + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java index 315189544d8..88ee3dbedf4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java @@ -37,7 +37,7 @@ public class SourceCodeModule extends NativeSourceCodeSpec { String sourceURL = Assertions.assertNotNull( - getReactApplicationContext().getCatalystInstance().getSourceURL(), + getReactApplicationContext().getSourceURL(), "No source URL loaded, have you initialised the instance?"); constants.put("scriptURL", sourceURL);