mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
30c1196d7d
Summary: This diff adds a JS spec for RCTImageLoader, and conforms to it in ObjC++. Since RCTImageLoader isn't called from JS, the js spec is empty. Since `/CoreModules/` is the only dir in OSS which supports TM, move the ObjC++ impl there. The change in `NativeExceptionsManager.js` fixes a weird bug I was hitting in codegen, where the codegen cpp file wouldn't compile due to unused variable. Reviewed By: JoshuaGross Differential Revision: D16495674 fbshipit-source-id: 191897b87730a6b0b96022eedc6412551fae04a6
104 lines
2.4 KiB
JavaScript
104 lines
2.4 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its 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
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {TurboModule} from '../TurboModule/RCTExport';
|
|
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
|
|
|
export type StackFrame = {|
|
|
column: ?number,
|
|
file: ?string,
|
|
lineNumber: ?number,
|
|
methodName: string,
|
|
collapse?: boolean,
|
|
|};
|
|
|
|
export type ExceptionData = {
|
|
message: string,
|
|
originalMessage: ?string,
|
|
name: ?string,
|
|
componentStack: ?string,
|
|
stack: Array<StackFrame>,
|
|
id: number,
|
|
isFatal: boolean,
|
|
// flowlint-next-line unclear-type:off
|
|
extraData?: Object,
|
|
};
|
|
|
|
export interface Spec extends TurboModule {
|
|
// Deprecated: Use `reportException`
|
|
+reportFatalException: (
|
|
message: string,
|
|
stack: Array<StackFrame>,
|
|
exceptionId: number,
|
|
) => void;
|
|
// Deprecated: Use `reportException`
|
|
+reportSoftException: (
|
|
message: string,
|
|
stack: Array<StackFrame>,
|
|
exceptionId: number,
|
|
) => void;
|
|
+reportException?: (data: ExceptionData) => void;
|
|
+updateExceptionMessage: (
|
|
message: string,
|
|
stack: Array<StackFrame>,
|
|
exceptionId: number,
|
|
) => void;
|
|
// Android only
|
|
+dismissRedbox?: () => void;
|
|
}
|
|
|
|
const NativeModule = TurboModuleRegistry.getEnforcing<Spec>(
|
|
'ExceptionsManager',
|
|
);
|
|
|
|
const ExceptionsManager = {
|
|
reportFatalException(
|
|
message: string,
|
|
stack: Array<StackFrame>,
|
|
exceptionId: number,
|
|
) {
|
|
NativeModule.reportFatalException(message, stack, exceptionId);
|
|
},
|
|
reportSoftException(
|
|
message: string,
|
|
stack: Array<StackFrame>,
|
|
exceptionId: number,
|
|
) {
|
|
NativeModule.reportSoftException(message, stack, exceptionId);
|
|
},
|
|
updateExceptionMessage(
|
|
message: string,
|
|
stack: Array<StackFrame>,
|
|
exceptionId: number,
|
|
) {
|
|
NativeModule.updateExceptionMessage(message, stack, exceptionId);
|
|
},
|
|
dismissRedbox(): void {
|
|
if (NativeModule.dismissRedbox) {
|
|
NativeModule.dismissRedbox();
|
|
}
|
|
},
|
|
reportException(data: ExceptionData): void {
|
|
if (NativeModule.reportException) {
|
|
NativeModule.reportException(data);
|
|
return;
|
|
}
|
|
if (data.isFatal) {
|
|
ExceptionsManager.reportFatalException(data.message, data.stack, data.id);
|
|
} else {
|
|
ExceptionsManager.reportSoftException(data.message, data.stack, data.id);
|
|
}
|
|
},
|
|
};
|
|
|
|
export default ExceptionsManager;
|