@expo/metro-runtime 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +3 -0
- package/assets/alert-triangle.png +0 -0
- package/assets/chevron-left.png +0 -0
- package/assets/chevron-right.png +0 -0
- package/assets/close.png +0 -0
- package/assets/loader.png +0 -0
- package/asyncRequire.js +1 -0
- package/build/HMRClient.d.ts +17 -0
- package/build/HMRClient.d.ts.map +1 -0
- package/build/HMRClient.js +250 -0
- package/build/HMRClient.js.map +1 -0
- package/build/HMRClient.native.d.ts +1 -0
- package/build/HMRClient.native.d.ts.map +1 -0
- package/build/HMRClient.native.js +2 -0
- package/build/HMRClient.native.js.map +1 -0
- package/build/LoadingView.d.ts +8 -0
- package/build/LoadingView.d.ts.map +1 -0
- package/build/LoadingView.js +21 -0
- package/build/LoadingView.js.map +1 -0
- package/build/LoadingView.native.d.ts +1 -0
- package/build/LoadingView.native.d.ts.map +1 -0
- package/build/LoadingView.native.js +2 -0
- package/build/LoadingView.native.js.map +1 -0
- package/build/asyncRequire/buildAsyncRequire.d.ts +24 -0
- package/build/asyncRequire/buildAsyncRequire.d.ts.map +1 -0
- package/build/asyncRequire/buildAsyncRequire.js +50 -0
- package/build/asyncRequire/buildAsyncRequire.js.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.d.ts +8 -0
- package/build/asyncRequire/buildUrlForBundle.d.ts.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.js +25 -0
- package/build/asyncRequire/buildUrlForBundle.js.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.native.d.ts +2 -0
- package/build/asyncRequire/buildUrlForBundle.native.d.ts.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.native.js +25 -0
- package/build/asyncRequire/buildUrlForBundle.native.js.map +1 -0
- package/build/asyncRequire/fetchAsync.d.ts +5 -0
- package/build/asyncRequire/fetchAsync.d.ts.map +1 -0
- package/build/asyncRequire/fetchAsync.js +19 -0
- package/build/asyncRequire/fetchAsync.js.map +1 -0
- package/build/asyncRequire/fetchAsync.native.d.ts +12 -0
- package/build/asyncRequire/fetchAsync.native.d.ts.map +1 -0
- package/build/asyncRequire/fetchAsync.native.js +57 -0
- package/build/asyncRequire/fetchAsync.native.js.map +1 -0
- package/build/asyncRequire/fetchThenEval.d.ts +7 -0
- package/build/asyncRequire/fetchThenEval.d.ts.map +1 -0
- package/build/asyncRequire/fetchThenEval.js +30 -0
- package/build/asyncRequire/fetchThenEval.js.map +1 -0
- package/build/asyncRequire/fetchThenEval.web.d.ts +6 -0
- package/build/asyncRequire/fetchThenEval.web.d.ts.map +1 -0
- package/build/asyncRequire/fetchThenEval.web.js +29 -0
- package/build/asyncRequire/fetchThenEval.web.js.map +1 -0
- package/build/asyncRequire/index.d.ts +2 -0
- package/build/asyncRequire/index.d.ts.map +1 -0
- package/build/asyncRequire/index.js +5 -0
- package/build/asyncRequire/index.js.map +1 -0
- package/build/asyncRequire/loadBundle.android.d.ts +2 -0
- package/build/asyncRequire/loadBundle.android.d.ts.map +1 -0
- package/build/asyncRequire/loadBundle.android.js +22 -0
- package/build/asyncRequire/loadBundle.android.js.map +1 -0
- package/build/asyncRequire/loadBundle.d.ts +2 -0
- package/build/asyncRequire/loadBundle.d.ts.map +1 -0
- package/build/asyncRequire/loadBundle.js +6 -0
- package/build/asyncRequire/loadBundle.js.map +1 -0
- package/build/asyncRequire/loadBundlePolyfill.d.ts +7 -0
- package/build/asyncRequire/loadBundlePolyfill.d.ts.map +1 -0
- package/build/asyncRequire/loadBundlePolyfill.js +40 -0
- package/build/asyncRequire/loadBundlePolyfill.js.map +1 -0
- package/build/effects.d.ts +2 -0
- package/build/effects.d.ts.map +1 -0
- package/build/effects.js +16 -0
- package/build/effects.js.map +1 -0
- package/build/effects.native.d.ts +1 -0
- package/build/effects.native.d.ts.map +1 -0
- package/build/effects.native.js +1 -0
- package/build/effects.native.js.map +1 -0
- package/build/error-overlay/Data/LogBoxData.d.ts +60 -0
- package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -0
- package/build/error-overlay/Data/LogBoxData.js +386 -0
- package/build/error-overlay/Data/LogBoxData.js.map +1 -0
- package/build/error-overlay/Data/LogBoxLog.d.ts +61 -0
- package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -0
- package/build/error-overlay/Data/LogBoxLog.js +148 -0
- package/build/error-overlay/Data/LogBoxLog.js.map +1 -0
- package/build/error-overlay/Data/LogBoxSymbolication.d.ts +17 -0
- package/build/error-overlay/Data/LogBoxSymbolication.d.ts.map +1 -0
- package/build/error-overlay/Data/LogBoxSymbolication.js +56 -0
- package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -0
- package/build/error-overlay/Data/LogContext.d.ts +14 -0
- package/build/error-overlay/Data/LogContext.d.ts.map +1 -0
- package/build/error-overlay/Data/LogContext.js +27 -0
- package/build/error-overlay/Data/LogContext.js.map +1 -0
- package/build/error-overlay/Data/parseLogBoxLog.d.ts +45 -0
- package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -0
- package/build/error-overlay/Data/parseLogBoxLog.js +286 -0
- package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -0
- package/build/error-overlay/ErrorOverlay.d.ts +18 -0
- package/build/error-overlay/ErrorOverlay.d.ts.map +1 -0
- package/build/error-overlay/ErrorOverlay.js +146 -0
- package/build/error-overlay/ErrorOverlay.js.map +1 -0
- package/build/error-overlay/LogBox.d.ts +16 -0
- package/build/error-overlay/LogBox.d.ts.map +1 -0
- package/build/error-overlay/LogBox.js +31 -0
- package/build/error-overlay/LogBox.js.map +1 -0
- package/build/error-overlay/LogBox.web.d.ts +23 -0
- package/build/error-overlay/LogBox.web.d.ts.map +1 -0
- package/build/error-overlay/LogBox.web.js +129 -0
- package/build/error-overlay/LogBox.web.js.map +1 -0
- package/build/error-overlay/UI/AnsiHighlight.d.ts +6 -0
- package/build/error-overlay/UI/AnsiHighlight.d.ts.map +1 -0
- package/build/error-overlay/UI/AnsiHighlight.js +86 -0
- package/build/error-overlay/UI/AnsiHighlight.js.map +1 -0
- package/build/error-overlay/UI/LogBoxButton.d.ts +14 -0
- package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -0
- package/build/error-overlay/UI/LogBoxButton.js +59 -0
- package/build/error-overlay/UI/LogBoxButton.js.map +1 -0
- package/build/error-overlay/UI/LogBoxMessage.d.ts +11 -0
- package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -0
- package/build/error-overlay/UI/LogBoxMessage.js +53 -0
- package/build/error-overlay/UI/LogBoxMessage.js.map +1 -0
- package/build/error-overlay/UI/LogBoxStyle.d.ts +22 -0
- package/build/error-overlay/UI/LogBoxStyle.d.ts.map +1 -0
- package/build/error-overlay/UI/LogBoxStyle.js +68 -0
- package/build/error-overlay/UI/LogBoxStyle.js.map +1 -0
- package/build/error-overlay/UI/constants.d.ts +2 -0
- package/build/error-overlay/UI/constants.d.ts.map +1 -0
- package/build/error-overlay/UI/constants.js +10 -0
- package/build/error-overlay/UI/constants.js.map +1 -0
- package/build/error-overlay/formatProjectFilePath.d.ts +2 -0
- package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -0
- package/build/error-overlay/formatProjectFilePath.js +27 -0
- package/build/error-overlay/formatProjectFilePath.js.map +1 -0
- package/build/error-overlay/index.d.ts +3 -0
- package/build/error-overlay/index.d.ts.map +1 -0
- package/build/error-overlay/index.js +30 -0
- package/build/error-overlay/index.js.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts +38 -0
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.js +80 -0
- package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts +2 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.js +3 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.d.ts +6 -0
- package/build/error-overlay/modules/NativeLogBox/index.d.ts.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.js +34 -0
- package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts +3 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.js +8 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.d.ts +3 -0
- package/build/error-overlay/modules/openFileInEditor/index.d.ts.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.js +15 -0
- package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts +3 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.js +8 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/index.d.ts +6 -0
- package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/index.js +25 -0
- package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts +3 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js +9 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -0
- package/build/error-overlay/modules/stringifySafe/index.d.ts +20 -0
- package/build/error-overlay/modules/stringifySafe/index.d.ts.map +1 -0
- package/build/error-overlay/modules/stringifySafe/index.js +117 -0
- package/build/error-overlay/modules/stringifySafe/index.js.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +24 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.js +19 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts +3 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js +8 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +5 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +113 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts +7 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js +111 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +8 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js +139 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +12 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +116 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +8 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.js +70 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +8 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +127 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +11 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +103 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +10 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +177 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -0
- package/build/error-overlay/toast/ErrorToast.d.ts +11 -0
- package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToast.js +147 -0
- package/build/error-overlay/toast/ErrorToast.js.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.d.ts +4 -0
- package/build/error-overlay/toast/ErrorToastContainer.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.js +7 -0
- package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts +12 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.js +83 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -0
- package/build/error-overlay/toast/ErrorToastMessage.d.ts +5 -0
- package/build/error-overlay/toast/ErrorToastMessage.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToastMessage.js +50 -0
- package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -0
- package/build/error-overlay/useRejectionHandler.d.ts +3 -0
- package/build/error-overlay/useRejectionHandler.d.ts.map +1 -0
- package/build/error-overlay/useRejectionHandler.js +60 -0
- package/build/error-overlay/useRejectionHandler.js.map +1 -0
- package/build/getDevServer.d.ts +8 -0
- package/build/getDevServer.d.ts.map +1 -0
- package/build/getDevServer.js +37 -0
- package/build/getDevServer.js.map +1 -0
- package/build/getDevServer.native.d.ts +1 -0
- package/build/getDevServer.native.d.ts.map +1 -0
- package/build/getDevServer.native.js +2 -0
- package/build/getDevServer.native.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +4 -0
- package/build/index.js.map +1 -0
- package/build/messageSocket.d.ts +3 -0
- package/build/messageSocket.d.ts.map +1 -0
- package/build/messageSocket.js +24 -0
- package/build/messageSocket.js.map +1 -0
- package/build/setupFastRefresh.d.ts +10 -0
- package/build/setupFastRefresh.d.ts.map +1 -0
- package/build/setupFastRefresh.js +23 -0
- package/build/setupFastRefresh.js.map +1 -0
- package/build/setupHMR.d.ts +2 -0
- package/build/setupHMR.d.ts.map +1 -0
- package/build/setupHMR.js +14 -0
- package/build/setupHMR.js.map +1 -0
- package/error-overlay.d.ts +1 -0
- package/error-overlay.js +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Evan Bacon.
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { StackFrame as UpstreamStackFrame } from "stacktrace-parser";
|
|
9
|
+
declare type SymbolicatedStackTrace = any;
|
|
10
|
+
declare type StackFrame = UpstreamStackFrame & {
|
|
11
|
+
collapse?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare type Stack = StackFrame[];
|
|
14
|
+
export declare function deleteStack(stack: Stack): void;
|
|
15
|
+
export declare function symbolicate(stack: Stack): Promise<SymbolicatedStackTrace>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=LogBoxSymbolication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogBoxSymbolication.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxSymbolication.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIrE,aAAK,sBAAsB,GAAG,GAAG,CAAC;AAElC,aAAK,UAAU,GAAG,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9D,oBAAY,KAAK,GAAG,UAAU,EAAE,CAAC;AAmCjC,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAQzE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Evan Bacon.
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.symbolicate = exports.deleteStack = void 0;
|
|
14
|
+
const symbolicateStackTrace_1 = __importDefault(require("../modules/symbolicateStackTrace"));
|
|
15
|
+
const cache = new Map();
|
|
16
|
+
/**
|
|
17
|
+
* Sanitize because sometimes, `symbolicateStackTrace` gives us invalid values.
|
|
18
|
+
*/
|
|
19
|
+
const sanitize = ({ stack: maybeStack, codeFrame, }) => {
|
|
20
|
+
if (!Array.isArray(maybeStack)) {
|
|
21
|
+
throw new Error("Expected stack to be an array.");
|
|
22
|
+
}
|
|
23
|
+
const stack = [];
|
|
24
|
+
for (const maybeFrame of maybeStack) {
|
|
25
|
+
let collapse = false;
|
|
26
|
+
if ("collapse" in maybeFrame) {
|
|
27
|
+
if (typeof maybeFrame.collapse !== "boolean") {
|
|
28
|
+
throw new Error("Expected stack frame `collapse` to be a boolean.");
|
|
29
|
+
}
|
|
30
|
+
collapse = maybeFrame.collapse;
|
|
31
|
+
}
|
|
32
|
+
stack.push({
|
|
33
|
+
arguments: [],
|
|
34
|
+
column: maybeFrame.column,
|
|
35
|
+
file: maybeFrame.file,
|
|
36
|
+
lineNumber: maybeFrame.lineNumber,
|
|
37
|
+
methodName: maybeFrame.methodName,
|
|
38
|
+
collapse,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return { stack, codeFrame };
|
|
42
|
+
};
|
|
43
|
+
function deleteStack(stack) {
|
|
44
|
+
cache.delete(stack);
|
|
45
|
+
}
|
|
46
|
+
exports.deleteStack = deleteStack;
|
|
47
|
+
function symbolicate(stack) {
|
|
48
|
+
let promise = cache.get(stack);
|
|
49
|
+
if (promise == null) {
|
|
50
|
+
promise = (0, symbolicateStackTrace_1.default)(stack).then(sanitize);
|
|
51
|
+
cache.set(stack, promise);
|
|
52
|
+
}
|
|
53
|
+
return promise;
|
|
54
|
+
}
|
|
55
|
+
exports.symbolicate = symbolicate;
|
|
56
|
+
//# sourceMappingURL=LogBoxSymbolication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogBoxSymbolication.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxSymbolication.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAIH,6FAAqE;AAQrE,MAAM,KAAK,GAAgD,IAAI,GAAG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C3B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AARD,kCAQC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { StackFrame as UpstreamStackFrame } from \"stacktrace-parser\";\n\nimport symbolicateStackTrace from \"../modules/symbolicateStackTrace\";\n\ntype SymbolicatedStackTrace = any;\n\ntype StackFrame = UpstreamStackFrame & { collapse?: boolean };\n\nexport type Stack = StackFrame[];\n\nconst cache: Map<Stack, Promise<SymbolicatedStackTrace>> = new Map();\n\n/**\n * Sanitize because sometimes, `symbolicateStackTrace` gives us invalid values.\n */\nconst sanitize = ({\n stack: maybeStack,\n codeFrame,\n}: SymbolicatedStackTrace): SymbolicatedStackTrace => {\n if (!Array.isArray(maybeStack)) {\n throw new Error(\"Expected stack to be an array.\");\n }\n const stack: StackFrame[] = [];\n for (const maybeFrame of maybeStack) {\n let collapse = false;\n if (\"collapse\" in maybeFrame) {\n if (typeof maybeFrame.collapse !== \"boolean\") {\n throw new Error(\"Expected stack frame `collapse` to be a boolean.\");\n }\n collapse = maybeFrame.collapse;\n }\n stack.push({\n arguments: [],\n column: maybeFrame.column,\n file: maybeFrame.file,\n lineNumber: maybeFrame.lineNumber,\n methodName: maybeFrame.methodName,\n collapse,\n });\n }\n return { stack, codeFrame };\n};\n\nexport function deleteStack(stack: Stack): void {\n cache.delete(stack);\n}\n\nexport function symbolicate(stack: Stack): Promise<SymbolicatedStackTrace> {\n let promise = cache.get(stack);\n if (promise == null) {\n promise = symbolicateStackTrace(stack).then(sanitize);\n cache.set(stack, promise);\n }\n\n return promise;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LogBoxLog } from "./LogBoxLog";
|
|
3
|
+
export declare const LogContext: React.Context<{
|
|
4
|
+
selectedLogIndex: number;
|
|
5
|
+
isDisabled: boolean;
|
|
6
|
+
logs: LogBoxLog[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare function useLogs(): {
|
|
9
|
+
selectedLogIndex: number;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
logs: LogBoxLog[];
|
|
12
|
+
};
|
|
13
|
+
export declare function useSelectedLog(): LogBoxLog;
|
|
14
|
+
//# sourceMappingURL=LogContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogContext.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,eAAO,MAAM,UAAU;sBACH,MAAM;gBACZ,OAAO;UACb,SAAS,EAAE;EAKjB,CAAC;AAEH,wBAAgB,OAAO;;;;EAMtB;AAED,wBAAgB,cAAc,cAG7B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useSelectedLog = exports.useLogs = exports.LogContext = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
// Context provider for Array<LogBoxLog>
|
|
9
|
+
exports.LogContext = react_1.default.createContext({
|
|
10
|
+
selectedLogIndex: -1,
|
|
11
|
+
isDisabled: false,
|
|
12
|
+
logs: [],
|
|
13
|
+
});
|
|
14
|
+
function useLogs() {
|
|
15
|
+
const logs = react_1.default.useContext(exports.LogContext);
|
|
16
|
+
if (!logs) {
|
|
17
|
+
throw new Error("useLogs must be used within a LogProvider");
|
|
18
|
+
}
|
|
19
|
+
return logs;
|
|
20
|
+
}
|
|
21
|
+
exports.useLogs = useLogs;
|
|
22
|
+
function useSelectedLog() {
|
|
23
|
+
const { selectedLogIndex, logs } = useLogs();
|
|
24
|
+
return logs[selectedLogIndex];
|
|
25
|
+
}
|
|
26
|
+
exports.useSelectedLog = useSelectedLog;
|
|
27
|
+
//# sourceMappingURL=LogContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogContext.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,wCAAwC;AAE3B,QAAA,UAAU,GAAG,eAAK,CAAC,aAAa,CAI1C;IACD,gBAAgB,EAAE,CAAC,CAAC;IACpB,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,EAAE;CACT,CAAC,CAAC;AAEH,SAAgB,OAAO;IACrB,MAAM,IAAI,GAAG,eAAK,CAAC,UAAU,CAAC,kBAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,0BAMC;AAED,SAAgB,cAAc;IAC5B,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAChC,CAAC;AAHD,wCAGC","sourcesContent":["import React from \"react\";\n\nimport { LogBoxLog } from \"./LogBoxLog\";\n\n// Context provider for Array<LogBoxLog>\n\nexport const LogContext = React.createContext<{\n selectedLogIndex: number;\n isDisabled: boolean;\n logs: LogBoxLog[];\n}>({\n selectedLogIndex: -1,\n isDisabled: false,\n logs: [],\n});\n\nexport function useLogs() {\n const logs = React.useContext(LogContext);\n if (!logs) {\n throw new Error(\"useLogs must be used within a LogProvider\");\n }\n return logs;\n}\n\nexport function useSelectedLog() {\n const { selectedLogIndex, logs } = useLogs();\n return logs[selectedLogIndex];\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Evan Bacon.
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import type { LogBoxLogData } from "./LogBoxLog";
|
|
9
|
+
declare type ExceptionData = any;
|
|
10
|
+
export declare type ExtendedExceptionData = ExceptionData & {
|
|
11
|
+
isComponentError: boolean;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
export declare type Category = string;
|
|
15
|
+
export declare type CodeFrame = {
|
|
16
|
+
content: string;
|
|
17
|
+
location?: {
|
|
18
|
+
row: number;
|
|
19
|
+
column: number;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
} | null;
|
|
22
|
+
fileName: string;
|
|
23
|
+
collapse?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare type Message = {
|
|
26
|
+
content: string;
|
|
27
|
+
substitutions: {
|
|
28
|
+
length: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
export declare type ComponentStack = CodeFrame[];
|
|
33
|
+
export declare function parseInterpolation(args: readonly any[]): readonly {
|
|
34
|
+
category: Category;
|
|
35
|
+
message: Message;
|
|
36
|
+
}[];
|
|
37
|
+
export declare function parseComponentStack(message: string): ComponentStack;
|
|
38
|
+
export declare function parseLogBoxException(error: ExtendedExceptionData): LogBoxLogData;
|
|
39
|
+
export declare function parseLogBoxLog(args: readonly any[]): {
|
|
40
|
+
componentStack: ComponentStack;
|
|
41
|
+
category: Category;
|
|
42
|
+
message: Message;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=parseLogBoxLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseLogBoxLog.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog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O,CAAC;CAClB,CA6CA"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Evan Bacon.
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.parseLogBoxLog = exports.parseLogBoxException = exports.parseComponentStack = exports.parseInterpolation = void 0;
|
|
14
|
+
const UTFSequence_1 = __importDefault(require("react-native/Libraries/UTFSequence"));
|
|
15
|
+
const parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
|
|
16
|
+
const stringifySafe_1 = __importDefault(require("../modules/stringifySafe"));
|
|
17
|
+
const BABEL_TRANSFORM_ERROR_FORMAT = /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/;
|
|
18
|
+
const BABEL_CODE_FRAME_ERROR_FORMAT = /^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\u{001b}[\s\S]+)/u;
|
|
19
|
+
const METRO_ERROR_FORMAT = /^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/u;
|
|
20
|
+
const SUBSTITUTION = UTFSequence_1.default.BOM + "%s";
|
|
21
|
+
function parseInterpolation(args) {
|
|
22
|
+
const categoryParts = [];
|
|
23
|
+
const contentParts = [];
|
|
24
|
+
const substitutionOffsets = [];
|
|
25
|
+
const remaining = [...args];
|
|
26
|
+
if (typeof remaining[0] === "string") {
|
|
27
|
+
const formatString = String(remaining.shift());
|
|
28
|
+
const formatStringParts = formatString.split("%s");
|
|
29
|
+
const substitutionCount = formatStringParts.length - 1;
|
|
30
|
+
const substitutions = remaining.splice(0, substitutionCount);
|
|
31
|
+
let categoryString = "";
|
|
32
|
+
let contentString = "";
|
|
33
|
+
let substitutionIndex = 0;
|
|
34
|
+
for (const formatStringPart of formatStringParts) {
|
|
35
|
+
categoryString += formatStringPart;
|
|
36
|
+
contentString += formatStringPart;
|
|
37
|
+
if (substitutionIndex < substitutionCount) {
|
|
38
|
+
if (substitutionIndex < substitutions.length) {
|
|
39
|
+
// Don't stringify a string type.
|
|
40
|
+
// It adds quotation mark wrappers around the string,
|
|
41
|
+
// which causes the LogBox to look odd.
|
|
42
|
+
const substitution = typeof substitutions[substitutionIndex] === "string"
|
|
43
|
+
? substitutions[substitutionIndex]
|
|
44
|
+
: (0, stringifySafe_1.default)(substitutions[substitutionIndex]);
|
|
45
|
+
substitutionOffsets.push({
|
|
46
|
+
length: substitution.length,
|
|
47
|
+
offset: contentString.length,
|
|
48
|
+
});
|
|
49
|
+
categoryString += SUBSTITUTION;
|
|
50
|
+
contentString += substitution;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
substitutionOffsets.push({
|
|
54
|
+
length: 2,
|
|
55
|
+
offset: contentString.length,
|
|
56
|
+
});
|
|
57
|
+
categoryString += "%s";
|
|
58
|
+
contentString += "%s";
|
|
59
|
+
}
|
|
60
|
+
substitutionIndex++;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
categoryParts.push(categoryString);
|
|
64
|
+
contentParts.push(contentString);
|
|
65
|
+
}
|
|
66
|
+
const remainingArgs = remaining.map((arg) => {
|
|
67
|
+
// Don't stringify a string type.
|
|
68
|
+
// It adds quotation mark wrappers around the string,
|
|
69
|
+
// which causes the LogBox to look odd.
|
|
70
|
+
return typeof arg === "string" ? arg : (0, stringifySafe_1.default)(arg);
|
|
71
|
+
});
|
|
72
|
+
categoryParts.push(...remainingArgs);
|
|
73
|
+
contentParts.push(...remainingArgs);
|
|
74
|
+
return {
|
|
75
|
+
// @ts-expect-error
|
|
76
|
+
category: categoryParts.join(" "),
|
|
77
|
+
message: {
|
|
78
|
+
content: contentParts.join(" "),
|
|
79
|
+
substitutions: substitutionOffsets,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.parseInterpolation = parseInterpolation;
|
|
84
|
+
function isComponentStack(consoleArgument) {
|
|
85
|
+
const isOldComponentStackFormat = / {4}in/.test(consoleArgument);
|
|
86
|
+
const isNewComponentStackFormat = / {4}at/.test(consoleArgument);
|
|
87
|
+
const isNewJSCComponentStackFormat = /@.*\n/.test(consoleArgument);
|
|
88
|
+
return (isOldComponentStackFormat ||
|
|
89
|
+
isNewComponentStackFormat ||
|
|
90
|
+
isNewJSCComponentStackFormat);
|
|
91
|
+
}
|
|
92
|
+
function parseComponentStack(message) {
|
|
93
|
+
// In newer versions of React, the component stack is formatted as a call stack frame.
|
|
94
|
+
// First try to parse the component stack as a call stack frame, and if that doesn't
|
|
95
|
+
// work then we'll fallback to the old custom component stack format parsing.
|
|
96
|
+
const stack = (0, parseErrorStack_1.default)(message);
|
|
97
|
+
if (stack && stack.length > 0) {
|
|
98
|
+
return stack.map((frame) => ({
|
|
99
|
+
content: frame.methodName,
|
|
100
|
+
collapse: frame.collapse || false,
|
|
101
|
+
fileName: frame.file == null ? "unknown" : frame.file,
|
|
102
|
+
location: {
|
|
103
|
+
column: frame.column == null ? -1 : frame.column,
|
|
104
|
+
row: frame.lineNumber == null ? -1 : frame.lineNumber,
|
|
105
|
+
},
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
return message
|
|
109
|
+
.split(/\n {4}in /g)
|
|
110
|
+
.map((s) => {
|
|
111
|
+
if (!s) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const match = s.match(/(.*) \(at (.*\.js):([\d]+)\)/);
|
|
115
|
+
if (!match) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const [content, fileName, row] = match.slice(1);
|
|
119
|
+
return {
|
|
120
|
+
content,
|
|
121
|
+
fileName,
|
|
122
|
+
location: { column: -1, row: parseInt(row, 10) },
|
|
123
|
+
};
|
|
124
|
+
})
|
|
125
|
+
.filter(Boolean);
|
|
126
|
+
}
|
|
127
|
+
exports.parseComponentStack = parseComponentStack;
|
|
128
|
+
function parseLogBoxException(error) {
|
|
129
|
+
const message = error.originalMessage != null ? error.originalMessage : "Unknown";
|
|
130
|
+
const metroInternalError = message.match(METRO_ERROR_FORMAT);
|
|
131
|
+
if (metroInternalError) {
|
|
132
|
+
const [content, fileName, row, column, codeFrame] = metroInternalError.slice(1);
|
|
133
|
+
return {
|
|
134
|
+
level: "fatal",
|
|
135
|
+
type: "Metro Error",
|
|
136
|
+
stack: [],
|
|
137
|
+
isComponentError: false,
|
|
138
|
+
componentStack: [],
|
|
139
|
+
codeFrame: {
|
|
140
|
+
fileName,
|
|
141
|
+
location: {
|
|
142
|
+
row: parseInt(row, 10),
|
|
143
|
+
column: parseInt(column, 10),
|
|
144
|
+
},
|
|
145
|
+
content: codeFrame,
|
|
146
|
+
},
|
|
147
|
+
message: {
|
|
148
|
+
content,
|
|
149
|
+
substitutions: [],
|
|
150
|
+
},
|
|
151
|
+
category: `${fileName}-${row}-${column}`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const babelTransformError = message.match(BABEL_TRANSFORM_ERROR_FORMAT);
|
|
155
|
+
if (babelTransformError) {
|
|
156
|
+
// Transform errors are thrown from inside the Babel transformer.
|
|
157
|
+
const [fileName, content, row, column, codeFrame] = babelTransformError.slice(1);
|
|
158
|
+
return {
|
|
159
|
+
level: "syntax",
|
|
160
|
+
stack: [],
|
|
161
|
+
isComponentError: false,
|
|
162
|
+
componentStack: [],
|
|
163
|
+
codeFrame: {
|
|
164
|
+
fileName,
|
|
165
|
+
location: {
|
|
166
|
+
row: parseInt(row, 10),
|
|
167
|
+
column: parseInt(column, 10),
|
|
168
|
+
},
|
|
169
|
+
content: codeFrame,
|
|
170
|
+
},
|
|
171
|
+
message: {
|
|
172
|
+
content,
|
|
173
|
+
substitutions: [],
|
|
174
|
+
},
|
|
175
|
+
category: `${fileName}-${row}-${column}`,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const babelCodeFrameError = message.match(BABEL_CODE_FRAME_ERROR_FORMAT);
|
|
179
|
+
if (babelCodeFrameError) {
|
|
180
|
+
// Codeframe errors are thrown from any use of buildCodeFrameError.
|
|
181
|
+
const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);
|
|
182
|
+
return {
|
|
183
|
+
level: "syntax",
|
|
184
|
+
stack: [],
|
|
185
|
+
isComponentError: false,
|
|
186
|
+
componentStack: [],
|
|
187
|
+
codeFrame: {
|
|
188
|
+
fileName,
|
|
189
|
+
location: null,
|
|
190
|
+
content: codeFrame,
|
|
191
|
+
},
|
|
192
|
+
message: {
|
|
193
|
+
content,
|
|
194
|
+
substitutions: [],
|
|
195
|
+
},
|
|
196
|
+
category: `${fileName}-${1}-${1}`,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (message.match(/^TransformError /)) {
|
|
200
|
+
return {
|
|
201
|
+
level: "syntax",
|
|
202
|
+
stack: error.stack,
|
|
203
|
+
isComponentError: error.isComponentError,
|
|
204
|
+
componentStack: [],
|
|
205
|
+
message: {
|
|
206
|
+
content: message,
|
|
207
|
+
substitutions: [],
|
|
208
|
+
},
|
|
209
|
+
category: message,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const componentStack = error.componentStack;
|
|
213
|
+
if (error.isFatal || error.isComponentError) {
|
|
214
|
+
// @ts-expect-error
|
|
215
|
+
return {
|
|
216
|
+
level: "fatal",
|
|
217
|
+
stack: error.stack,
|
|
218
|
+
isComponentError: error.isComponentError,
|
|
219
|
+
componentStack: componentStack != null ? parseComponentStack(componentStack) : [],
|
|
220
|
+
...parseInterpolation([message]),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (componentStack != null) {
|
|
224
|
+
// It is possible that console errors have a componentStack.
|
|
225
|
+
// @ts-expect-error
|
|
226
|
+
return {
|
|
227
|
+
level: "error",
|
|
228
|
+
stack: error.stack,
|
|
229
|
+
isComponentError: error.isComponentError,
|
|
230
|
+
componentStack: parseComponentStack(componentStack),
|
|
231
|
+
...parseInterpolation([message]),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// Most `console.error` calls won't have a componentStack. We parse them like
|
|
235
|
+
// regular logs which have the component stack burried in the message.
|
|
236
|
+
return {
|
|
237
|
+
level: "error",
|
|
238
|
+
stack: error.stack,
|
|
239
|
+
isComponentError: error.isComponentError,
|
|
240
|
+
...parseLogBoxLog([message]),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
exports.parseLogBoxException = parseLogBoxException;
|
|
244
|
+
function parseLogBoxLog(args) {
|
|
245
|
+
const message = args[0];
|
|
246
|
+
let argsWithoutComponentStack = [];
|
|
247
|
+
let componentStack = [];
|
|
248
|
+
// Extract component stack from warnings like "Some warning%s".
|
|
249
|
+
if (typeof message === "string" &&
|
|
250
|
+
message.slice(-2) === "%s" &&
|
|
251
|
+
args.length > 0) {
|
|
252
|
+
const lastArg = args[args.length - 1];
|
|
253
|
+
if (typeof lastArg === "string" && isComponentStack(lastArg)) {
|
|
254
|
+
argsWithoutComponentStack = args.slice(0, -1);
|
|
255
|
+
argsWithoutComponentStack[0] = message.slice(0, -2);
|
|
256
|
+
componentStack = parseComponentStack(lastArg);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (componentStack.length === 0) {
|
|
260
|
+
// Try finding the component stack elsewhere.
|
|
261
|
+
for (const arg of args) {
|
|
262
|
+
if (typeof arg === "string" && isComponentStack(arg)) {
|
|
263
|
+
// Strip out any messages before the component stack.
|
|
264
|
+
let messageEndIndex = arg.search(/\n {4}(in|at) /);
|
|
265
|
+
if (messageEndIndex < 0) {
|
|
266
|
+
// Handle JSC component stacks.
|
|
267
|
+
messageEndIndex = arg.search(/\n/);
|
|
268
|
+
}
|
|
269
|
+
if (messageEndIndex > 0) {
|
|
270
|
+
argsWithoutComponentStack.push(arg.slice(0, messageEndIndex));
|
|
271
|
+
}
|
|
272
|
+
componentStack = parseComponentStack(arg);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
argsWithoutComponentStack.push(arg);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// @ts-expect-error
|
|
280
|
+
return {
|
|
281
|
+
...parseInterpolation(argsWithoutComponentStack),
|
|
282
|
+
componentStack,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
exports.parseLogBoxLog = parseLogBoxLog;
|
|
286
|
+
//# sourceMappingURL=parseLogBoxLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseLogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH,qFAA6D;AAE7D,iFAAyD;AACzD,6EAAqD;AAIrD,MAAM,4BAA4B,GAChC,gGAAgG,CAAC;AACnG,MAAM,6BAA6B,GACjC,sGAAsG,CAAC;AACzG,MAAM,kBAAkB,GACtB,6FAA6F,CAAC;AAgChG,MAAM,YAAY,GAAG,qBAAW,CAAC,GAAG,GAAG,IAAI,CAAC;AAE5C,SAAgB,kBAAkB,CAAC,IAAoB;IAIrD,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,mBAAmB,GAAyC,EAAE,CAAC;IAErE,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5B,IAAI,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACpC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,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BAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9C,yBAAyB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACpD,cAAc,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;SAC/C;KACF;IAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,6CAA6C;QAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE;gBACpD,qDAAqD;gBACrD,IAAI,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;gBACnD,IAAI,eAAe,GAAG,CAAC,EAAE;oBACvB,+BAA+B;oBAC/B,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iBACpC;gBACD,IAAI,eAAe,GAAG,CAAC,EAAE;oBACvB,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;iBAC/D;gBAED,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;aAC3C;iBAAM;gBACL,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACrC;SACF;KACF;IAED,mBAAmB;IACnB,OAAO;QACL,GAAG,kBAAkB,CAAC,yBAAyB,CAAC;QAChD,cAAc;KACf,CAAC;AACJ,CAAC;AAjDD,wCAiDC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport UTFSequence from \"react-native/Libraries/UTFSequence\";\n\nimport parseErrorStack from \"../modules/parseErrorStack\";\nimport stringifySafe from \"../modules/stringifySafe\";\nimport type { LogBoxLogData } from \"./LogBoxLog\";\ntype ExceptionData = any;\n\nconst BABEL_TRANSFORM_ERROR_FORMAT =\n /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \\((\\d+):(\\d+)\\)\\n\\n([\\s\\S]+)/;\nconst BABEL_CODE_FRAME_ERROR_FORMAT =\n /^(?:TransformError )?(?:.*):? (?:.*?)(\\/.*): ([\\s\\S]+?)\\n([ >]{2}[\\d\\s]+ \\|[\\s\\S]+|\\u{001b}[\\s\\S]+)/u;\nconst METRO_ERROR_FORMAT =\n /^(?:InternalError Metro has encountered an error:) (.*): (.*) \\((\\d+):(\\d+)\\)\\n\\n([\\s\\S]+)/u;\n\nexport type ExtendedExceptionData = ExceptionData & {\n isComponentError: boolean;\n [key: string]: any;\n};\nexport type Category = string;\nexport type CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n } | null;\n fileName: string;\n\n // TODO: When React switched to using call stack frames,\n // we gained the ability to use the collapse flag, but\n // it is not integrated into the LogBox UI.\n collapse?: boolean;\n};\n\nexport type Message = {\n content: string;\n substitutions: {\n length: number;\n offset: number;\n }[];\n};\n\nexport type ComponentStack = CodeFrame[];\n\nconst SUBSTITUTION = UTFSequence.BOM + \"%s\";\n\nexport function parseInterpolation(args: readonly any[]): readonly {\n category: Category;\n message: Message;\n}[] {\n const categoryParts: string[] = [];\n const contentParts: string[] = [];\n const substitutionOffsets: { length: number; offset: number }[] = [];\n\n const remaining = [...args];\n if (typeof remaining[0] === \"string\") {\n const formatString = String(remaining.shift());\n const formatStringParts = formatString.split(\"%s\");\n const substitutionCount = formatStringParts.length - 1;\n const substitutions = remaining.splice(0, substitutionCount);\n\n let categoryString = \"\";\n let contentString = \"\";\n\n let substitutionIndex = 0;\n for (const formatStringPart of formatStringParts) {\n categoryString += formatStringPart;\n contentString += formatStringPart;\n\n if (substitutionIndex < substitutionCount) {\n if (substitutionIndex < substitutions.length) {\n // Don't stringify a string type.\n // It adds quotation mark wrappers around the string,\n // which causes the LogBox to look odd.\n const substitution =\n typeof substitutions[substitutionIndex] === \"string\"\n ? substitutions[substitutionIndex]\n : stringifySafe(substitutions[substitutionIndex]);\n substitutionOffsets.push({\n length: substitution.length,\n offset: contentString.length,\n });\n\n categoryString += SUBSTITUTION;\n contentString += substitution;\n } else {\n substitutionOffsets.push({\n length: 2,\n offset: contentString.length,\n });\n\n categoryString += \"%s\";\n contentString += \"%s\";\n }\n\n substitutionIndex++;\n }\n }\n\n categoryParts.push(categoryString);\n contentParts.push(contentString);\n }\n\n const remainingArgs = remaining.map((arg) => {\n // Don't stringify a string type.\n // It adds quotation mark wrappers around the string,\n // which causes the LogBox to look odd.\n return typeof arg === \"string\" ? arg : stringifySafe(arg);\n });\n categoryParts.push(...remainingArgs);\n contentParts.push(...remainingArgs);\n\n return {\n // @ts-expect-error\n category: categoryParts.join(\" \"),\n message: {\n content: contentParts.join(\" \"),\n substitutions: substitutionOffsets,\n },\n };\n}\n\nfunction isComponentStack(consoleArgument: string) {\n const isOldComponentStackFormat = / {4}in/.test(consoleArgument);\n const isNewComponentStackFormat = / {4}at/.test(consoleArgument);\n const isNewJSCComponentStackFormat = /@.*\\n/.test(consoleArgument);\n\n return (\n isOldComponentStackFormat ||\n isNewComponentStackFormat ||\n isNewJSCComponentStackFormat\n );\n}\n\nexport function parseComponentStack(message: string): ComponentStack {\n // In newer versions of React, the component stack is formatted as a call stack frame.\n // First try to parse the component stack as a call stack frame, and if that doesn't\n // work then we'll fallback to the old custom component stack format parsing.\n const stack = parseErrorStack(message);\n if (stack && stack.length > 0) {\n return stack.map((frame) => ({\n content: frame.methodName,\n collapse: frame.collapse || false,\n fileName: frame.file == null ? \"unknown\" : frame.file,\n location: {\n column: frame.column == null ? -1 : frame.column,\n row: frame.lineNumber == null ? -1 : frame.lineNumber,\n },\n }));\n }\n\n return message\n .split(/\\n {4}in /g)\n .map((s) => {\n if (!s) {\n return null;\n }\n const match = s.match(/(.*) \\(at (.*\\.js):([\\d]+)\\)/);\n if (!match) {\n return null;\n }\n\n const [content, fileName, row] = match.slice(1);\n return {\n content,\n fileName,\n location: { column: -1, row: parseInt(row, 10) },\n };\n })\n .filter(Boolean) as ComponentStack;\n}\n\nexport function parseLogBoxException(\n error: ExtendedExceptionData\n): LogBoxLogData {\n const message =\n error.originalMessage != null ? error.originalMessage : \"Unknown\";\n\n const metroInternalError = message.match(METRO_ERROR_FORMAT);\n if (metroInternalError) {\n const [content, fileName, row, column, codeFrame] =\n metroInternalError.slice(1);\n\n return {\n level: \"fatal\",\n type: \"Metro Error\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelTransformError = message.match(BABEL_TRANSFORM_ERROR_FORMAT);\n if (babelTransformError) {\n // Transform errors are thrown from inside the Babel transformer.\n const [fileName, content, row, column, codeFrame] =\n babelTransformError.slice(1);\n\n return {\n level: \"syntax\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelCodeFrameError = message.match(BABEL_CODE_FRAME_ERROR_FORMAT);\n\n if (babelCodeFrameError) {\n // Codeframe errors are thrown from any use of buildCodeFrameError.\n const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);\n return {\n level: \"syntax\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: null, // We are not given the location.\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${1}-${1}`,\n };\n }\n\n if (message.match(/^TransformError /)) {\n return {\n level: \"syntax\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: [],\n message: {\n content: message,\n substitutions: [],\n },\n category: message,\n };\n }\n\n const componentStack = error.componentStack;\n if (error.isFatal || error.isComponentError) {\n // @ts-expect-error\n return {\n level: \"fatal\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack:\n componentStack != null ? parseComponentStack(componentStack) : [],\n ...parseInterpolation([message]),\n };\n }\n\n if (componentStack != null) {\n // It is possible that console errors have a componentStack.\n // @ts-expect-error\n return {\n level: \"error\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: parseComponentStack(componentStack),\n ...parseInterpolation([message]),\n };\n }\n\n // Most `console.error` calls won't have a componentStack. We parse them like\n // regular logs which have the component stack burried in the message.\n return {\n level: \"error\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n ...parseLogBoxLog([message]),\n };\n}\n\nexport function parseLogBoxLog(args: readonly any[]): {\n componentStack: ComponentStack;\n category: Category;\n message: Message;\n} {\n const message = args[0];\n let argsWithoutComponentStack: any[] = [];\n let componentStack: ComponentStack = [];\n\n // Extract component stack from warnings like \"Some warning%s\".\n if (\n typeof message === \"string\" &&\n message.slice(-2) === \"%s\" &&\n args.length > 0\n ) {\n const lastArg = args[args.length - 1];\n if (typeof lastArg === \"string\" && isComponentStack(lastArg)) {\n argsWithoutComponentStack = args.slice(0, -1);\n argsWithoutComponentStack[0] = message.slice(0, -2);\n componentStack = parseComponentStack(lastArg);\n }\n }\n\n if (componentStack.length === 0) {\n // Try finding the component stack elsewhere.\n for (const arg of args) {\n if (typeof arg === \"string\" && isComponentStack(arg)) {\n // Strip out any messages before the component stack.\n let messageEndIndex = arg.search(/\\n {4}(in|at) /);\n if (messageEndIndex < 0) {\n // Handle JSC component stacks.\n messageEndIndex = arg.search(/\\n/);\n }\n if (messageEndIndex > 0) {\n argsWithoutComponentStack.push(arg.slice(0, messageEndIndex));\n }\n\n componentStack = parseComponentStack(arg);\n } else {\n argsWithoutComponentStack.push(arg);\n }\n }\n }\n\n // @ts-expect-error\n return {\n ...parseInterpolation(argsWithoutComponentStack),\n componentStack,\n };\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Evan Bacon.
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { LogBoxLog } from "./Data/LogBoxLog";
|
|
10
|
+
export declare function LogBoxInspectorContainer(): JSX.Element | null;
|
|
11
|
+
export declare function LogBoxInspector({ log, selectedLogIndex, logs, }: {
|
|
12
|
+
log: LogBoxLog;
|
|
13
|
+
selectedLogIndex: number;
|
|
14
|
+
logs: LogBoxLog[];
|
|
15
|
+
}): JSX.Element;
|
|
16
|
+
declare const _default: React.Component<object, {}, any>;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=ErrorOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorOverlay.d.ts","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAa,MAAM,kBAAkB,CAAC;AAiBxD,wBAAgB,wBAAwB,uBAavC;AACD,wBAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,gBAAgB,EAChB,IAAI,GACL,EAAE;IACD,GAAG,EAAE,SAAS,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB,eAmEA;;AAiED,wBAAqE"}
|