mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Libraries/DevToolsSettings -> private/reactdevtools/ReactDevToolsSettings (#46662)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46662 # Changelog: [Internal] This should not have been a public API in the first place. 1. Moving this to `src/private`. 2. Removed some unused APIs, such as profiling settings. Reviewed By: huntie Differential Revision: D62965492 fbshipit-source-id: fb97eccaf647ce418f500b02d153263aa8632eee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
53b7f0e764
commit
cf491d769f
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import DevSettings from '../Utilities/DevSettings';
|
||||
import NativeDevToolsSettingsManager from './NativeDevToolsSettingsManager';
|
||||
|
||||
module.exports = {
|
||||
setConsolePatchSettings(newSettings: string) {
|
||||
NativeDevToolsSettingsManager?.setConsolePatchSettings(newSettings);
|
||||
},
|
||||
getConsolePatchSettings(): ?string {
|
||||
return NativeDevToolsSettingsManager?.getConsolePatchSettings();
|
||||
},
|
||||
setProfilingSettings(newSettings: string) {
|
||||
if (NativeDevToolsSettingsManager?.setProfilingSettings != null) {
|
||||
NativeDevToolsSettingsManager.setProfilingSettings(newSettings);
|
||||
}
|
||||
},
|
||||
getProfilingSettings(): ?string {
|
||||
if (NativeDevToolsSettingsManager?.getProfilingSettings != null) {
|
||||
return NativeDevToolsSettingsManager.getProfilingSettings();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
reload(): void {
|
||||
DevSettings?.reload();
|
||||
},
|
||||
};
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
export interface DevToolsSettingsManagerStatic {
|
||||
reload(): void;
|
||||
setConsolePatchSettings(newSettings: string): void;
|
||||
getConsolePatchSettings(): string | null;
|
||||
setProfilingSettings(newSettings: string): void;
|
||||
getProfilingSettings(): string | null;
|
||||
}
|
||||
|
||||
export const DevToolsSettingsManager: DevToolsSettingsManagerStatic;
|
||||
export type DevToolsSettingsManager = DevToolsSettingsManagerStatic;
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import Settings from '../Settings/Settings';
|
||||
import DevSettings from '../Utilities/DevSettings';
|
||||
|
||||
const CONSOLE_PATCH_SETTINGS_KEY = 'ReactDevTools::ConsolePatchSettings';
|
||||
const PROFILING_SETTINGS_KEY = 'ReactDevTools::ProfilingSettings';
|
||||
|
||||
const DevToolsSettingsManager = {
|
||||
setConsolePatchSettings(newConsolePatchSettings: string): void {
|
||||
Settings.set({
|
||||
[CONSOLE_PATCH_SETTINGS_KEY]: newConsolePatchSettings,
|
||||
});
|
||||
},
|
||||
getConsolePatchSettings(): ?string {
|
||||
const value = Settings.get(CONSOLE_PATCH_SETTINGS_KEY);
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
setProfilingSettings(newProfilingSettings: string): void {
|
||||
Settings.set({
|
||||
[PROFILING_SETTINGS_KEY]: newProfilingSettings,
|
||||
});
|
||||
},
|
||||
getProfilingSettings(): ?string {
|
||||
const value = Settings.get(PROFILING_SETTINGS_KEY);
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
reload(): void {
|
||||
DevSettings?.reload();
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = DevToolsSettingsManager;
|
||||
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
declare const DevToolsSettingsManager: {
|
||||
setConsolePatchSettings(newConsolePatchSettings: string): void,
|
||||
getConsolePatchSettings(): ?string,
|
||||
setProfilingSettings(newProfilingSettings: string): void,
|
||||
getProfilingSettings(): ?string,
|
||||
reload(): void,
|
||||
};
|
||||
|
||||
module.exports = DevToolsSettingsManager;
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
export * from '../../src/private/specs/modules/NativeDevToolsSettingsManager';
|
||||
import NativeDevToolsSettingsManager from '../../src/private/specs/modules/NativeDevToolsSettingsManager';
|
||||
export default NativeDevToolsSettingsManager;
|
||||
@@ -4548,24 +4548,6 @@ declare export default typeof useSubscribeToDebuggingOverlayRegistry;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`public API should not change unintentionally Libraries/DevToolsSettings/DevToolsSettingsManager.js.flow 1`] = `
|
||||
"declare const DevToolsSettingsManager: {
|
||||
setConsolePatchSettings(newConsolePatchSettings: string): void,
|
||||
getConsolePatchSettings(): ?string,
|
||||
setProfilingSettings(newProfilingSettings: string): void,
|
||||
getProfilingSettings(): ?string,
|
||||
reload(): void,
|
||||
};
|
||||
declare module.exports: DevToolsSettingsManager;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`public API should not change unintentionally Libraries/DevToolsSettings/NativeDevToolsSettingsManager.js 1`] = `
|
||||
"export * from \\"../../src/private/specs/modules/NativeDevToolsSettingsManager\\";
|
||||
declare export default typeof NativeDevToolsSettingsManager;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`public API should not change unintentionally Libraries/EventEmitter/NativeEventEmitter.js 1`] = `
|
||||
"interface NativeModule {
|
||||
addListener(eventType: string): void;
|
||||
|
||||
@@ -3414,14 +3414,6 @@ public final class com/facebook/react/modules/devloading/DevLoadingModule : com/
|
||||
public final class com/facebook/react/modules/devloading/DevLoadingModule$Companion {
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/devtoolssettings/DevToolsSettingsManagerModule : com/facebook/fbreact/specs/NativeDevToolsSettingsManagerSpec {
|
||||
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
|
||||
public fun getConsolePatchSettings ()Ljava/lang/String;
|
||||
public fun getProfilingSettings ()Ljava/lang/String;
|
||||
public fun setConsolePatchSettings (Ljava/lang/String;)V
|
||||
public fun setProfilingSettings (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/modules/dialog/AlertFragment : androidx/fragment/app/DialogFragment, android/content/DialogInterface$OnClickListener {
|
||||
public fun <init> ()V
|
||||
public fun <init> (Lcom/facebook/react/modules/dialog/DialogModule$AlertFragmentListener;Landroid/os/Bundle;)V
|
||||
@@ -3679,6 +3671,12 @@ public final class com/facebook/react/modules/permissions/PermissionsModule : co
|
||||
public fun shouldShowRequestPermissionRationale (Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule : com/facebook/fbreact/specs/NativeReactDevToolsSettingsManagerSpec {
|
||||
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
|
||||
public fun getGlobalHookSettings ()Ljava/lang/String;
|
||||
public fun setGlobalHookSettings (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/share/ShareModule : com/facebook/fbreact/specs/NativeShareModuleSpec {
|
||||
public static final field Companion Lcom/facebook/react/modules/share/ShareModule$Companion;
|
||||
public static final field ERROR_INVALID_CONTENT Ljava/lang/String;
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.devtoolssettings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.facebook.fbreact.specs.NativeDevToolsSettingsManagerSpec
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.module.annotations.ReactModule
|
||||
|
||||
@ReactModule(name = NativeDevToolsSettingsManagerSpec.NAME)
|
||||
public class DevToolsSettingsManagerModule(reactContext: ReactApplicationContext) :
|
||||
NativeDevToolsSettingsManagerSpec(reactContext) {
|
||||
|
||||
private val sharedPreferences: SharedPreferences =
|
||||
reactContext.getSharedPreferences(SHARED_PREFERENCES_PREFIX, Context.MODE_PRIVATE)
|
||||
|
||||
public override fun getConsolePatchSettings(): String? =
|
||||
sharedPreferences.getString(KEY_CONSOLE_PATCH_SETTINGS, null)
|
||||
|
||||
public override fun setConsolePatchSettings(newSettings: String?): Unit =
|
||||
sharedPreferences.edit().putString(KEY_CONSOLE_PATCH_SETTINGS, newSettings).apply()
|
||||
|
||||
public override fun getProfilingSettings(): String? =
|
||||
sharedPreferences.getString(KEY_PROFILING_SETTINGS, null)
|
||||
|
||||
public override fun setProfilingSettings(newSettings: String?): Unit =
|
||||
sharedPreferences.edit().putString(KEY_PROFILING_SETTINGS, newSettings).apply()
|
||||
|
||||
private companion object {
|
||||
private const val SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings"
|
||||
private const val KEY_CONSOLE_PATCH_SETTINGS = "ConsolePatchSettings"
|
||||
private const val KEY_PROFILING_SETTINGS = "ProfilingSettings"
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.reactdevtoolssettings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.facebook.fbreact.specs.NativeReactDevToolsSettingsManagerSpec
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.module.annotations.ReactModule
|
||||
|
||||
@ReactModule(name = NativeReactDevToolsSettingsManagerSpec.NAME)
|
||||
public class ReactDevToolsSettingsManagerModule(reactContext: ReactApplicationContext) :
|
||||
NativeReactDevToolsSettingsManagerSpec(reactContext) {
|
||||
|
||||
private val sharedPreferences: SharedPreferences =
|
||||
reactContext.getSharedPreferences(SHARED_PREFERENCES_PREFIX, Context.MODE_PRIVATE)
|
||||
|
||||
public override fun setGlobalHookSettings(settings: String): Unit =
|
||||
sharedPreferences.edit().putString(KEY_HOOK_SETTINGS, settings).apply()
|
||||
|
||||
public override fun getGlobalHookSettings(): String? =
|
||||
sharedPreferences.getString(KEY_HOOK_SETTINGS, null)
|
||||
|
||||
private companion object {
|
||||
private const val SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings"
|
||||
private const val KEY_HOOK_SETTINGS = "HookSettings"
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -28,7 +28,6 @@ import com.facebook.react.modules.blob.FileReaderModule;
|
||||
import com.facebook.react.modules.camera.ImageStoreManager;
|
||||
import com.facebook.react.modules.clipboard.ClipboardModule;
|
||||
import com.facebook.react.modules.devloading.DevLoadingModule;
|
||||
import com.facebook.react.modules.devtoolssettings.DevToolsSettingsManagerModule;
|
||||
import com.facebook.react.modules.dialog.DialogModule;
|
||||
import com.facebook.react.modules.fresco.FrescoModule;
|
||||
import com.facebook.react.modules.i18nmanager.I18nManagerModule;
|
||||
@@ -36,6 +35,7 @@ import com.facebook.react.modules.image.ImageLoaderModule;
|
||||
import com.facebook.react.modules.intent.IntentModule;
|
||||
import com.facebook.react.modules.network.NetworkingModule;
|
||||
import com.facebook.react.modules.permissions.PermissionsModule;
|
||||
import com.facebook.react.modules.reactdevtoolssettings.ReactDevToolsSettingsManagerModule;
|
||||
import com.facebook.react.modules.share.ShareModule;
|
||||
import com.facebook.react.modules.sound.SoundManagerModule;
|
||||
import com.facebook.react.modules.statusbar.StatusBarModule;
|
||||
@@ -153,8 +153,8 @@ public class MainReactPackage extends BaseReactPackage implements ViewManagerOnD
|
||||
return new VibrationModule(context);
|
||||
case WebSocketModule.NAME:
|
||||
return new WebSocketModule(context);
|
||||
case DevToolsSettingsManagerModule.NAME:
|
||||
return new DevToolsSettingsManagerModule(context);
|
||||
case ReactDevToolsSettingsManagerModule.NAME:
|
||||
return new ReactDevToolsSettingsManagerModule(context);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ public class MainReactPackage extends BaseReactPackage implements ViewManagerOnD
|
||||
NativeAnimatedModule.class,
|
||||
NetworkingModule.class,
|
||||
PermissionsModule.class,
|
||||
DevToolsSettingsManagerModule.class,
|
||||
ReactDevToolsSettingsManagerModule.class,
|
||||
ShareModule.class,
|
||||
StatusBarModule.class,
|
||||
SoundManagerModule.class,
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import NativeReactDevToolsSettingsManager from '../specs/modules/NativeReactDevToolsSettingsManager';
|
||||
|
||||
module.exports = {
|
||||
setGlobalHookSettings(settings: string) {
|
||||
NativeReactDevToolsSettingsManager?.setGlobalHookSettings(settings);
|
||||
},
|
||||
getGlobalHookSettings(): ?string {
|
||||
return NativeReactDevToolsSettingsManager?.getGlobalHookSettings();
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import Settings from '../../../Libraries/Settings/Settings';
|
||||
|
||||
const GLOBAL_HOOK_SETTINGS = 'ReactDevTools::HookSettings';
|
||||
|
||||
const ReactDevToolsSettingsManager = {
|
||||
setGlobalHookSettings(settings: string): void {
|
||||
Settings.set({
|
||||
[GLOBAL_HOOK_SETTINGS]: settings,
|
||||
});
|
||||
},
|
||||
getGlobalHookSettings(): ?string {
|
||||
const value = Settings.get(GLOBAL_HOOK_SETTINGS);
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = ReactDevToolsSettingsManager;
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
declare const ReactDevToolsSettingsManager: {
|
||||
setGlobalHookSettings(settings: string): void,
|
||||
getGlobalHookSettings(): ?string,
|
||||
};
|
||||
|
||||
module.exports = ReactDevToolsSettingsManager;
|
||||
+3
-5
@@ -13,12 +13,10 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+setConsolePatchSettings: (newConsolePatchSettings: string) => void;
|
||||
+getConsolePatchSettings: () => ?string;
|
||||
+setProfilingSettings?: (newProfilingSettings: string) => void;
|
||||
+getProfilingSettings?: () => ?string;
|
||||
+setGlobalHookSettings: (settings: string) => void;
|
||||
+getGlobalHookSettings: () => ?string;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.get<Spec>(
|
||||
'DevToolsSettingsManager',
|
||||
'ReactDevToolsSettingsManager',
|
||||
): ?Spec);
|
||||
-1
@@ -104,7 +104,6 @@ export * from '../Libraries/Components/View/ViewAccessibility';
|
||||
export * from '../Libraries/Components/View/ViewPropTypes';
|
||||
export * from '../Libraries/Components/Button';
|
||||
export * from '../Libraries/Core/registerCallableModule';
|
||||
export * from '../Libraries/DevToolsSettings/DevToolsSettingsManager';
|
||||
export * from '../Libraries/EventEmitter/NativeEventEmitter';
|
||||
export * from '../Libraries/EventEmitter/RCTDeviceEventEmitter';
|
||||
export * from '../Libraries/EventEmitter/RCTNativeAppEventEmitter';
|
||||
|
||||
Reference in New Issue
Block a user