Expose DevSettings.openDebugger method to JS (#44934)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44934

Resubmission of D57681447 with an updated `ReactAndroid.api`.

 ---

Changelog: [Internal]

Adds a private API that gives JS the ability to trigger the same "open debugger" action as in the Dev Menu. This is in preparation for changes to LogBox.

For simplicity, this method operates on a best-effort basis - i.e. it doesn't report the success or failure (or failure reason) of the launch.

Reviewed By: huntie

Differential Revision: D58529832

fbshipit-source-id: e5510f529a19e0149d8dce04fa610e6c2371cc79
This commit is contained in:
Moti Zilberman 2024-06-13 12:22:48 -07:00 коммит произвёл Facebook GitHub Bot
Родитель dc460147bb
Коммит e3a76c5155
4 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -501,6 +501,15 @@ RCT_EXPORT_METHOD(addMenuItem : (NSString *)title)
}
}
RCT_EXPORT_METHOD(openDebugger)
{
#if RCT_ENABLE_INSPECTOR
[RCTInspectorDevServerHelper
openDebugger:self.bundleManager.bundleURL
withErrorMessage:@"Failed to open debugger. Please check that the dev server is running and reload the app."];
#endif
}
#pragma mark - Internal
/**
@ -608,6 +617,9 @@ RCT_EXPORT_METHOD(addMenuItem : (NSString *)title)
- (void)setupHMRClientWithAdditionalBundleURL:(NSURL *)bundleURL
{
}
- (void)openDebugger
{
}
- (void)addMenuItem:(NSString *)title
{
}

Просмотреть файл

@ -3215,6 +3215,7 @@ public final class com/facebook/react/modules/debug/DevSettingsModule : com/face
public fun addListener (Ljava/lang/String;)V
public fun addMenuItem (Ljava/lang/String;)V
public fun onFastRefresh ()V
public fun openDebugger ()V
public fun reload ()V
public fun reloadWithReason (Ljava/lang/String;)V
public fun removeListeners (D)V
@ -3829,6 +3830,7 @@ public class com/facebook/react/runtime/ReactSurfaceImpl : com/facebook/react/in
public final class com/facebook/react/runtime/ReactSurfaceView : com/facebook/react/ReactRootView {
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactSurfaceImpl;)V
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
public fun getJSModuleName ()Ljava/lang/String;
public fun getUIManagerType ()I
public fun handleException (Ljava/lang/Throwable;)V
public fun hasActiveReactContext ()Z

Просмотреть файл

@ -61,6 +61,10 @@ public class DevSettingsModule(
}
}
override fun openDebugger() {
devSupportManager.openDebugger()
}
override fun setIsShakeToShowDevMenuEnabled(enabled: Boolean) {
// iOS only
}

Просмотреть файл

@ -21,6 +21,7 @@ export interface Spec extends TurboModule {
+setProfilingEnabled: (isProfilingEnabled: boolean) => void;
+toggleElementInspector: () => void;
+addMenuItem: (title: string) => void;
+openDebugger?: () => void;
// Events
+addListener: (eventName: string) => void;