diff --git a/Libraries/Core/setUpBatchedBridge.js b/Libraries/Core/setUpBatchedBridge.js index 17ba06eb818..4ceff36bc50 100644 --- a/Libraries/Core/setUpBatchedBridge.js +++ b/Libraries/Core/setUpBatchedBridge.js @@ -20,7 +20,6 @@ if (global.RN$Bridgeless === true && global.RN$registerCallableModule) { | $TEMPORARY$string<'GlobalPerformanceLogger'> | $TEMPORARY$string<'HMRClient'> | $TEMPORARY$string<'HeapCapture'> - | $TEMPORARY$string<'JSDevSupportModule'> | $TEMPORARY$string<'JSTimers'> | $TEMPORARY$string<'RCTDeviceEventEmitter'> | $TEMPORARY$string<'RCTLog'> @@ -52,9 +51,6 @@ registerModule('RCTNativeAppEventEmitter', () => registerModule('GlobalPerformanceLogger', () => require('../Utilities/GlobalPerformanceLogger'), ); -registerModule('JSDevSupportModule', () => - require('../Utilities/JSDevSupportModule'), -); if (__DEV__ && !global.__RCTProfileIsProfiling) { registerModule('HMRClient', () => require('../Utilities/HMRClient')); diff --git a/Libraries/Utilities/JSDevSupportModule.js b/Libraries/Utilities/JSDevSupportModule.js deleted file mode 100644 index c88df1f1dd3..00000000000 --- a/Libraries/Utilities/JSDevSupportModule.js +++ /dev/null @@ -1,37 +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. - * - * @format - * @flow strict-local - */ - -import NativeJSDevSupport from './NativeJSDevSupport'; -const ReactNative = require('../Renderer/shims/ReactNative'); - -const JSDevSupportModule = { - getJSHierarchy: function (tag: number) { - if (NativeJSDevSupport) { - const constants = NativeJSDevSupport.getConstants(); - try { - const {computeComponentStackForErrorReporting} = - ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - const componentStack = computeComponentStackForErrorReporting(tag); - if (!componentStack) { - NativeJSDevSupport.onFailure( - constants.ERROR_CODE_VIEW_NOT_FOUND, - "Component stack doesn't exist for tag " + tag, - ); - } else { - NativeJSDevSupport.onSuccess(componentStack); - } - } catch (e) { - NativeJSDevSupport.onFailure(constants.ERROR_CODE_EXCEPTION, e.message); - } - } - }, -}; - -module.exports = JSDevSupportModule; diff --git a/Libraries/Utilities/NativeJSDevSupport.js b/Libraries/Utilities/NativeJSDevSupport.js deleted file mode 100644 index 59347258888..00000000000 --- a/Libraries/Utilities/NativeJSDevSupport.js +++ /dev/null @@ -1,23 +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 - */ - -import type {TurboModule} from '../TurboModule/RCTExport'; -import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; - -export interface Spec extends TurboModule { - +getConstants: () => {| - ERROR_CODE_EXCEPTION: number, - ERROR_CODE_VIEW_NOT_FOUND: number, - |}; - +onSuccess: (data: string) => void; - +onFailure: (errorCode: number, error: string) => void; -} - -export default (TurboModuleRegistry.get('JSDevSupport'): ?Spec); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java deleted file mode 100644 index 4ea6a82c7c9..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java +++ /dev/null @@ -1,103 +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.devsupport; - -import android.util.Pair; -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.fbreact.specs.NativeJSDevSupportSpec; -import com.facebook.react.bridge.JavaScriptModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.module.annotations.ReactModule; -import java.util.HashMap; -import java.util.Map; - -@ReactModule(name = JSDevSupport.MODULE_NAME) -public class JSDevSupport extends NativeJSDevSupportSpec { - public static final String MODULE_NAME = "JSDevSupport"; - - public static final int ERROR_CODE_EXCEPTION = 0; - public static final int ERROR_CODE_VIEW_NOT_FOUND = 1; - - @Nullable private volatile DevSupportCallback mCurrentCallback = null; - - public interface JSDevSupportModule extends JavaScriptModule { - void getJSHierarchy(int reactTag); - } - - public JSDevSupport(ReactApplicationContext reactContext) { - super(reactContext); - } - - public interface DevSupportCallback { - - void onSuccess(String data); - - void onFailure(int errorCode, Exception error); - } - - /** - * Notifies the callback with either the JS hierarchy of the deepest leaf from the given root view - * or with an error. - */ - public synchronized void computeDeepestJSHierarchy(View root, DevSupportCallback callback) { - final Pair deepestPairView = ViewHierarchyUtil.getDeepestLeaf(root); - View deepestView = deepestPairView.first; - Integer tagId = deepestView.getId(); - getJSHierarchy(tagId, callback); - } - - public synchronized void getJSHierarchy(int reactTag, DevSupportCallback callback) { - ReactApplicationContext reactApplicationContext = getReactApplicationContextIfActiveOrWarn(); - - JSDevSupportModule jsDevSupportModule = null; - if (reactApplicationContext != null) { - jsDevSupportModule = reactApplicationContext.getJSModule(JSDevSupportModule.class); - } - - if (jsDevSupportModule == null) { - callback.onFailure( - ERROR_CODE_EXCEPTION, - new JSCHeapCapture.CaptureException(MODULE_NAME + " module not registered.")); - return; - } - mCurrentCallback = callback; - jsDevSupportModule.getJSHierarchy(reactTag); - } - - @SuppressWarnings("unused") - @Override - public synchronized void onSuccess(String data) { - if (mCurrentCallback != null) { - mCurrentCallback.onSuccess(data); - } - } - - @SuppressWarnings("unused") - @Override - public synchronized void onFailure(double errorCodeDouble, String error) { - int errorCode = (int) errorCodeDouble; - - if (mCurrentCallback != null) { - mCurrentCallback.onFailure(errorCode, new RuntimeException(error)); - } - } - - @Override - public Map getTypedExportedConstants() { - HashMap constants = new HashMap<>(); - constants.put("ERROR_CODE_EXCEPTION", ERROR_CODE_EXCEPTION); - constants.put("ERROR_CODE_VIEW_NOT_FOUND", ERROR_CODE_VIEW_NOT_FOUND); - return constants; - } - - @Override - public String getName() { - return MODULE_NAME; - } -}