Remove unused JSDevSupport module
Summary: The `JSDevSupport` module is incompatible with Fabric. Given it's not used internally and it's undocumented in OSS, we decided to remove it altogether. Changelog: [Internal] Reviewed By: javache, nlutsenko Differential Revision: D39305892 fbshipit-source-id: 82455701a0b9ba83e6f971fc774280dceb2b22e0
This commit is contained in:
Родитель
951538c080
Коммит
34e7d48472
|
@ -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'));
|
||||
|
|
|
@ -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;
|
|
@ -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<Spec>('JSDevSupport'): ?Spec);
|
|
@ -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<View, Integer> 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<String, Object> getTypedExportedConstants() {
|
||||
HashMap<String, Object> 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;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче