@expo/metro-runtime 3.0.0 → 3.0.2
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/build/HMRClient.js +43 -15
- package/build/HMRClient.js.map +1 -1
- package/build/HMRClient.native.js +3 -1
- package/build/HMRClient.native.js.map +1 -1
- package/build/LoadingView.d.ts +6 -0
- package/build/LoadingView.d.ts.map +1 -1
- package/build/LoadingView.js +12 -4
- package/build/LoadingView.js.map +1 -1
- package/build/LoadingView.native.js +7 -2
- package/build/LoadingView.native.js.map +1 -1
- package/build/async-require/buildAsyncRequire.js +7 -3
- package/build/async-require/buildAsyncRequire.js.map +1 -1
- package/build/async-require/buildUrlForBundle.js +5 -1
- package/build/async-require/buildUrlForBundle.js.map +1 -1
- package/build/async-require/buildUrlForBundle.native.js +5 -1
- package/build/async-require/buildUrlForBundle.native.js.map +1 -1
- package/build/async-require/fetchAsync.d.ts +6 -0
- package/build/async-require/fetchAsync.d.ts.map +1 -1
- package/build/async-require/fetchAsync.js +6 -3
- package/build/async-require/fetchAsync.js.map +1 -1
- package/build/async-require/fetchAsync.native.js +13 -6
- package/build/async-require/fetchAsync.native.js.map +1 -1
- package/build/async-require/fetchThenEval.d.ts +1 -6
- package/build/async-require/fetchThenEval.d.ts.map +1 -1
- package/build/async-require/fetchThenEval.js +5 -31
- package/build/async-require/fetchThenEval.js.map +1 -1
- package/build/async-require/fetchThenEval.web.js +6 -2
- package/build/async-require/fetchThenEval.web.js.map +1 -1
- package/build/async-require/fetchThenEvalJs.d.ts +7 -0
- package/build/async-require/fetchThenEvalJs.d.ts.map +1 -0
- package/build/async-require/fetchThenEvalJs.js +36 -0
- package/build/async-require/fetchThenEvalJs.js.map +1 -0
- package/build/async-require/index.js +4 -2
- package/build/async-require/index.js.map +1 -1
- package/build/async-require/index.native.d.ts +7 -0
- package/build/async-require/index.native.d.ts.map +1 -0
- package/build/async-require/index.native.js +14 -0
- package/build/async-require/index.native.js.map +1 -0
- package/build/async-require/loadBundle.js +10 -6
- package/build/async-require/loadBundle.js.map +1 -1
- package/build/effects.d.ts +0 -1
- package/build/effects.js +7 -10
- package/build/effects.js.map +1 -1
- package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
- package/build/error-overlay/Data/LogBoxData.js +82 -33
- package/build/error-overlay/Data/LogBoxData.js.map +1 -1
- package/build/error-overlay/Data/LogBoxLog.js +29 -2
- package/build/error-overlay/Data/LogBoxLog.js.map +1 -1
- package/build/error-overlay/Data/LogBoxSymbolication.js +12 -4
- package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -1
- package/build/error-overlay/Data/LogContext.js +17 -9
- package/build/error-overlay/Data/LogContext.js.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.js +20 -11
- package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
- package/build/error-overlay/ErrorOverlay.d.ts.map +1 -1
- package/build/error-overlay/ErrorOverlay.js +73 -41
- package/build/error-overlay/ErrorOverlay.js.map +1 -1
- package/build/error-overlay/LogBox.js +3 -1
- package/build/error-overlay/LogBox.js.map +1 -1
- package/build/error-overlay/LogBox.web.d.ts.map +1 -1
- package/build/error-overlay/LogBox.web.js +4 -3
- package/build/error-overlay/LogBox.web.js.map +1 -1
- package/build/error-overlay/UI/AnsiHighlight.js +15 -8
- package/build/error-overlay/UI/AnsiHighlight.js.map +1 -1
- package/build/error-overlay/UI/LogBoxButton.js +35 -8
- package/build/error-overlay/UI/LogBoxButton.js.map +1 -1
- package/build/error-overlay/UI/LogBoxMessage.js +13 -6
- package/build/error-overlay/UI/LogBoxMessage.js.map +1 -1
- package/build/error-overlay/UI/LogBoxStyle.js +31 -14
- package/build/error-overlay/UI/LogBoxStyle.js.map +1 -1
- package/build/error-overlay/UI/constants.js +5 -2
- package/build/error-overlay/UI/constants.js.map +1 -1
- package/build/error-overlay/formatProjectFilePath.js +7 -2
- package/build/error-overlay/formatProjectFilePath.js.map +1 -1
- package/build/error-overlay/index.d.ts.map +1 -1
- package/build/error-overlay/index.js +19 -9
- package/build/error-overlay/index.js.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.js +8 -3
- package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.js +7 -2
- package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.js +10 -5
- package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.js +7 -2
- package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.js +3 -1
- package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.js +7 -2
- package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.js +10 -7
- package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js +8 -2
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -1
- package/build/error-overlay/modules/stringifySafe/index.js +6 -2
- package/build/error-overlay/modules/stringifySafe/index.js.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.js +3 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js +7 -2
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +52 -22
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js +48 -18
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js +53 -23
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +43 -13
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSection.js +39 -9
- package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +41 -14
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +44 -14
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +55 -24
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -1
- package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToast.js +48 -21
- package/build/error-overlay/toast/ErrorToast.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.js +9 -3
- package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.js +49 -21
- package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.js +37 -7
- package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -1
- package/build/error-overlay/useRejectionHandler.js +16 -9
- package/build/error-overlay/useRejectionHandler.js.map +1 -1
- package/build/getDevServer.d.ts.map +1 -1
- package/build/getDevServer.js +10 -9
- package/build/getDevServer.js.map +1 -1
- package/build/getDevServer.native.js +7 -2
- package/build/getDevServer.native.js.map +1 -1
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +12 -8
- package/build/index.js.map +1 -1
- package/build/location/Location.js +7 -2
- package/build/location/Location.js.map +1 -1
- package/build/location/Location.native.js +12 -4
- package/build/location/Location.native.js.map +1 -1
- package/build/location/install.native.js +16 -11
- package/build/location/install.native.js.map +1 -1
- package/build/setupHMR.js +28 -26
- package/build/setupHMR.js.map +1 -1
- package/build/symbolicate.js +25 -4
- package/build/symbolicate.js.map +1 -1
- package/package.json +5 -2
- package/src/HMRClient.native.ts +3 -0
- package/src/HMRClient.ts +316 -0
- package/src/LoadingView.native.ts +3 -0
- package/src/LoadingView.ts +24 -0
- package/src/__mocks__/LoadingView.ts +4 -0
- package/src/async-require/buildAsyncRequire.ts +34 -0
- package/src/async-require/buildUrlForBundle.native.ts +28 -0
- package/src/async-require/buildUrlForBundle.ts +18 -0
- package/src/async-require/fetchAsync.native.ts +72 -0
- package/src/async-require/fetchAsync.ts +19 -0
- package/src/async-require/fetchThenEval.ts +1 -0
- package/src/async-require/fetchThenEval.web.ts +70 -0
- package/src/async-require/fetchThenEvalJs.ts +39 -0
- package/src/async-require/index.native.ts +15 -0
- package/src/async-require/index.ts +10 -0
- package/src/async-require/loadBundle.ts +46 -0
- package/src/effects.native.ts +0 -0
- package/src/effects.ts +11 -0
- package/src/error-overlay/Data/LogBoxData.tsx +438 -0
- package/src/error-overlay/Data/LogBoxLog.ts +221 -0
- package/src/error-overlay/Data/LogBoxSymbolication.tsx +64 -0
- package/src/error-overlay/Data/LogContext.tsx +41 -0
- package/src/error-overlay/Data/parseLogBoxLog.tsx +342 -0
- package/src/error-overlay/ErrorOverlay.tsx +191 -0
- package/src/error-overlay/LogBox.ts +51 -0
- package/src/error-overlay/LogBox.web.ts +174 -0
- package/src/error-overlay/UI/AnsiHighlight.tsx +96 -0
- package/src/error-overlay/UI/LogBoxButton.tsx +63 -0
- package/src/error-overlay/UI/LogBoxMessage.tsx +73 -0
- package/src/error-overlay/UI/LogBoxStyle.ts +64 -0
- package/src/error-overlay/UI/constants.ts +7 -0
- package/src/error-overlay/formatProjectFilePath.ts +38 -0
- package/src/error-overlay/index.tsx +34 -0
- package/src/error-overlay/modules/ExceptionsManager/index.native.ts +4 -0
- package/src/error-overlay/modules/ExceptionsManager/index.ts +82 -0
- package/src/error-overlay/modules/NativeLogBox/index.native.ts +3 -0
- package/src/error-overlay/modules/NativeLogBox/index.tsx +27 -0
- package/src/error-overlay/modules/openFileInEditor/index.native.ts +3 -0
- package/src/error-overlay/modules/openFileInEditor/index.ts +16 -0
- package/src/error-overlay/modules/parseErrorStack/index.ts +26 -0
- package/src/error-overlay/modules/parseErrorStack/parseHermesStack.ts +3 -0
- package/src/error-overlay/modules/stringifySafe/index.ts +115 -0
- package/src/error-overlay/modules/symbolicateStackTrace/index.native.ts +3 -0
- package/src/error-overlay/modules/symbolicateStackTrace/index.ts +39 -0
- package/src/error-overlay/overlay/LogBoxInspectorCodeFrame.tsx +102 -0
- package/src/error-overlay/overlay/LogBoxInspectorFooter.tsx +111 -0
- package/src/error-overlay/overlay/LogBoxInspectorHeader.tsx +167 -0
- package/src/error-overlay/overlay/LogBoxInspectorMessageHeader.tsx +116 -0
- package/src/error-overlay/overlay/LogBoxInspectorSection.tsx +52 -0
- package/src/error-overlay/overlay/LogBoxInspectorSourceMapStatus.tsx +125 -0
- package/src/error-overlay/overlay/LogBoxInspectorStackFrame.tsx +89 -0
- package/src/error-overlay/overlay/LogBoxInspectorStackFrames.tsx +201 -0
- package/src/error-overlay/toast/ErrorToast.tsx +167 -0
- package/src/error-overlay/toast/ErrorToastContainer.tsx +9 -0
- package/src/error-overlay/toast/ErrorToastContainer.web.tsx +92 -0
- package/src/error-overlay/toast/ErrorToastMessage.tsx +28 -0
- package/src/error-overlay/useRejectionHandler.ts +61 -0
- package/src/getDevServer.native.ts +3 -0
- package/src/getDevServer.ts +34 -0
- package/src/index.ts +12 -0
- package/src/location/Location.native.ts +201 -0
- package/src/location/Location.ts +3 -0
- package/src/location/install.native.ts +90 -0
- package/src/location/install.ts +0 -0
- package/src/messageSocket.ts +25 -0
- package/src/setupFastRefresh.ts +30 -0
- package/src/setupHMR.ts +28 -0
- package/src/symbolicate.ts +6 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) 650 Industries.
|
|
3
4
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -5,7 +6,32 @@
|
|
|
5
6
|
* This source code is licensed under the MIT license found in the
|
|
6
7
|
* LICENSE file in the root directory of this source tree.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.LogBoxLog = void 0;
|
|
34
|
+
const LogBoxSymbolication = __importStar(require("./LogBoxSymbolication"));
|
|
9
35
|
function componentStackToStack(componentStack) {
|
|
10
36
|
return componentStack.map((stack) => ({
|
|
11
37
|
file: stack.fileName,
|
|
@@ -15,7 +41,7 @@ function componentStackToStack(componentStack) {
|
|
|
15
41
|
arguments: [],
|
|
16
42
|
}));
|
|
17
43
|
}
|
|
18
|
-
|
|
44
|
+
class LogBoxLog {
|
|
19
45
|
message;
|
|
20
46
|
type;
|
|
21
47
|
category;
|
|
@@ -158,4 +184,5 @@ export class LogBoxLog {
|
|
|
158
184
|
}
|
|
159
185
|
}
|
|
160
186
|
}
|
|
187
|
+
exports.LogBoxLog = LogBoxLog;
|
|
161
188
|
//# sourceMappingURL=LogBoxLog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxLog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAqB7D,SAAS,qBAAqB,CAAC,cAA8B;IAC3D,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,UAAU,EAAE,KAAK,CAAC,OAAO;QACzB,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;QACpC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;QACnC,SAAS,EAAE,EAAE;KACd,CAAC,CAAC,CAAC;AACN,CAAC;AAUD,MAAM,OAAO,SAAS;IACpB,OAAO,CAAU;IACjB,IAAI,CAAS;IACb,QAAQ,CAAW;IACnB,cAAc,CAAiB;IAC/B,KAAK,CAAQ;IACb,KAAK,CAAS;IACd,KAAK,CAAW;IAChB,SAAS,CAAa;IACtB,gB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AEO,YAAY,CAClB,IAAe,EACf,KAAoB,EACpB,KAAoB,EACpB,SAA4B;QAE5B,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QAClD,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK;gBACL,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,QAAQ;aACjB,CAAC;SACH;aAAM,IAAI,KAAK,IAAI,IAAI,EAAE;YACxB,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;aAC5B;YAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK;gBACL,MAAM,EAAE,UAAU;aACnB,CAAC;SACH;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,SAAS;aAClB,CAAC;SACH;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QAC9C,IAAI,UAAU,KAAK,MAAM,EAAE;YACzB,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;aAC3B;SACF;IACH,CAAC;CACF","sourcesContent":["/**\n * Copyright (c) 650 Industries.\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 * as LogBoxSymbolication from './LogBoxSymbolication';\nimport type { Stack } from './LogBoxSymbolication';\nimport type { Category, Message, ComponentStack, CodeFrame } from './parseLogBoxLog';\n\ntype SymbolicationStatus = 'NONE' | 'PENDING' | 'COMPLETE' | 'FAILED';\n\nexport type LogLevel = 'warn' | 'error' | 'fatal' | 'syntax' | 'static';\n\nexport type LogBoxLogData = {\n level: LogLevel;\n type?: string;\n message: Message;\n stack: Stack;\n category: string;\n componentStack: ComponentStack;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n};\n\nexport type StackType = 'stack' | 'component';\n\nfunction componentStackToStack(componentStack: ComponentStack): Stack {\n return componentStack.map((stack) => ({\n file: stack.fileName,\n methodName: stack.content,\n lineNumber: stack.location?.row ?? 0,\n column: stack.location?.column ?? 0,\n arguments: [],\n }));\n}\n\ntype SymbolicationCallback = (status: SymbolicationStatus) => void;\n\ntype SymbolicationResult =\n | { error: null; stack: null; status: 'NONE' }\n | { error: null; stack: null; status: 'PENDING' }\n | { error: null; stack: Stack; status: 'COMPLETE' }\n | { error: Error; stack: null; status: 'FAILED' };\n\nexport class LogBoxLog {\n message: Message;\n type: string;\n category: Category;\n componentStack: ComponentStack;\n stack: Stack;\n count: number;\n level: LogLevel;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n symbolicated: Record<StackType, SymbolicationResult> = {\n stack: {\n error: null,\n stack: null,\n status: 'NONE',\n },\n component: {\n error: null,\n stack: null,\n status: 'NONE',\n },\n };\n\n private callbacks: Map<StackType, Set<SymbolicationCallback>> = new Map();\n\n constructor(\n data: LogBoxLogData & {\n symbolicated?: Record<StackType, SymbolicationResult>;\n }\n ) {\n this.level = data.level;\n this.type = data.type ?? 'error';\n this.message = data.message;\n this.stack = data.stack;\n this.category = data.category;\n this.componentStack = data.componentStack;\n this.codeFrame = data.codeFrame;\n this.isComponentError = data.isComponentError;\n this.count = 1;\n this.symbolicated = data.symbolicated ?? this.symbolicated;\n }\n\n incrementCount(): void {\n this.count += 1;\n }\n\n getAvailableStack(type: StackType): Stack | null {\n if (this.symbolicated[type].status === 'COMPLETE') {\n return this.symbolicated[type].stack;\n }\n return this.getStack(type);\n }\n\n private flushCallbacks(type: StackType): void {\n const callbacks = this.callbacks.get(type);\n const status = this.symbolicated[type].status;\n if (callbacks) {\n for (const callback of callbacks) {\n callback(status);\n }\n callbacks.clear();\n }\n }\n\n private pushCallback(type: StackType, callback: SymbolicationCallback): void {\n let callbacks = this.callbacks.get(type);\n if (!callbacks) {\n callbacks = new Set();\n this.callbacks.set(type, callbacks);\n }\n callbacks.add(callback);\n }\n\n retrySymbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void {\n this._symbolicate(type, true, callback);\n }\n\n symbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void {\n this._symbolicate(type, false, callback);\n }\n\n private _symbolicate(\n type: StackType,\n retry: boolean,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n if (callback) {\n this.pushCallback(type, callback);\n }\n const status = this.symbolicated[type].status;\n\n if (status === 'COMPLETE') {\n return this.flushCallbacks(type);\n }\n\n if (retry) {\n LogBoxSymbolication.deleteStack(this.getStack(type));\n this.handleSymbolicate(type);\n } else {\n if (status === 'NONE') {\n this.handleSymbolicate(type);\n }\n }\n }\n\n private componentStackCache: Stack | null = null;\n\n private getStack(type: StackType): Stack {\n if (type === 'component') {\n if (this.componentStackCache == null) {\n this.componentStackCache = componentStackToStack(this.componentStack);\n }\n return this.componentStackCache;\n }\n return this.stack;\n }\n\n private handleSymbolicate(type: StackType): void {\n if (type === 'component' && !this.componentStack?.length) {\n return;\n }\n\n if (this.symbolicated[type].status !== 'PENDING') {\n this.updateStatus(type, null, null, null);\n LogBoxSymbolication.symbolicate(this.getStack(type)).then(\n (data) => {\n this.updateStatus(type, null, data?.stack, data?.codeFrame);\n },\n (error) => {\n this.updateStatus(type, error, null, null);\n }\n );\n }\n }\n\n private updateStatus(\n type: StackType,\n error?: Error | null,\n stack?: Stack | null,\n codeFrame?: CodeFrame | null\n ): void {\n const lastStatus = this.symbolicated[type].status;\n if (error != null) {\n this.symbolicated[type] = {\n error,\n stack: null,\n status: 'FAILED',\n };\n } else if (stack != null) {\n if (codeFrame) {\n this.codeFrame = codeFrame;\n }\n\n this.symbolicated[type] = {\n error: null,\n stack,\n status: 'COMPLETE',\n };\n } else {\n this.symbolicated[type] = {\n error: null,\n stack: null,\n status: 'PENDING',\n };\n }\n\n const status = this.symbolicated[type].status;\n if (lastStatus !== status) {\n if (['COMPLETE', 'FAILED'].includes(status)) {\n this.flushCallbacks(type);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxLog.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2EAA6D;AAqB7D,SAAS,qBAAqB,CAAC,cAA8B;IAC3D,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,UAAU,EAAE,KAAK,CAAC,OAAO;QACzB,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;QACpC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;QACnC,SAAS,EAAE,EAAE;KACd,CAAC,CAAC,CAAC;AACN,CAAC;AAUD,MAAa,SAAS;IACpB,OAAO,CAAU;IACjB,IAAI,CAAS;IACb,QAAQ,CAAW;IACnB,cAAc,CAAiB;IAC/B,KAAK,CAAQ;IACb,KAAK,CAAS;IACd,KAAK,CAAW;IAChB,SAAS,CAAa;IACtB,gBAAgB,CAAU;IAC1B,YAAY,GAA2C;QACrD,KAAK,EAAE;YACL,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,MAAM;SACf;QACD,SAAS,EAAE;YACT,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,MAAM;SACf;KACF,CAAC;IAEM,SAAS,GAA+C,IAAI,GAAG,EAAE,CAAC;IAE1E,YACE,IAEC;QAED,IAAI,CAAC,KAAK,GAAG,IAA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AK,IAAI,IAAI,EAAE;YACxB,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;aAC5B;YAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK;gBACL,MAAM,EAAE,UAAU;aACnB,CAAC;SACH;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,SAAS;aAClB,CAAC;SACH;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QAC9C,IAAI,UAAU,KAAK,MAAM,EAAE;YACzB,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;aAC3B;SACF;IACH,CAAC;CACF;AA7KD,8BA6KC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\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 * as LogBoxSymbolication from './LogBoxSymbolication';\nimport type { Stack } from './LogBoxSymbolication';\nimport type { Category, Message, ComponentStack, CodeFrame } from './parseLogBoxLog';\n\ntype SymbolicationStatus = 'NONE' | 'PENDING' | 'COMPLETE' | 'FAILED';\n\nexport type LogLevel = 'warn' | 'error' | 'fatal' | 'syntax' | 'static';\n\nexport type LogBoxLogData = {\n level: LogLevel;\n type?: string;\n message: Message;\n stack: Stack;\n category: string;\n componentStack: ComponentStack;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n};\n\nexport type StackType = 'stack' | 'component';\n\nfunction componentStackToStack(componentStack: ComponentStack): Stack {\n return componentStack.map((stack) => ({\n file: stack.fileName,\n methodName: stack.content,\n lineNumber: stack.location?.row ?? 0,\n column: stack.location?.column ?? 0,\n arguments: [],\n }));\n}\n\ntype SymbolicationCallback = (status: SymbolicationStatus) => void;\n\ntype SymbolicationResult =\n | { error: null; stack: null; status: 'NONE' }\n | { error: null; stack: null; status: 'PENDING' }\n | { error: null; stack: Stack; status: 'COMPLETE' }\n | { error: Error; stack: null; status: 'FAILED' };\n\nexport class LogBoxLog {\n message: Message;\n type: string;\n category: Category;\n componentStack: ComponentStack;\n stack: Stack;\n count: number;\n level: LogLevel;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n symbolicated: Record<StackType, SymbolicationResult> = {\n stack: {\n error: null,\n stack: null,\n status: 'NONE',\n },\n component: {\n error: null,\n stack: null,\n status: 'NONE',\n },\n };\n\n private callbacks: Map<StackType, Set<SymbolicationCallback>> = new Map();\n\n constructor(\n data: LogBoxLogData & {\n symbolicated?: Record<StackType, SymbolicationResult>;\n }\n ) {\n this.level = data.level;\n this.type = data.type ?? 'error';\n this.message = data.message;\n this.stack = data.stack;\n this.category = data.category;\n this.componentStack = data.componentStack;\n this.codeFrame = data.codeFrame;\n this.isComponentError = data.isComponentError;\n this.count = 1;\n this.symbolicated = data.symbolicated ?? this.symbolicated;\n }\n\n incrementCount(): void {\n this.count += 1;\n }\n\n getAvailableStack(type: StackType): Stack | null {\n if (this.symbolicated[type].status === 'COMPLETE') {\n return this.symbolicated[type].stack;\n }\n return this.getStack(type);\n }\n\n private flushCallbacks(type: StackType): void {\n const callbacks = this.callbacks.get(type);\n const status = this.symbolicated[type].status;\n if (callbacks) {\n for (const callback of callbacks) {\n callback(status);\n }\n callbacks.clear();\n }\n }\n\n private pushCallback(type: StackType, callback: SymbolicationCallback): void {\n let callbacks = this.callbacks.get(type);\n if (!callbacks) {\n callbacks = new Set();\n this.callbacks.set(type, callbacks);\n }\n callbacks.add(callback);\n }\n\n retrySymbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void {\n this._symbolicate(type, true, callback);\n }\n\n symbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void {\n this._symbolicate(type, false, callback);\n }\n\n private _symbolicate(\n type: StackType,\n retry: boolean,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n if (callback) {\n this.pushCallback(type, callback);\n }\n const status = this.symbolicated[type].status;\n\n if (status === 'COMPLETE') {\n return this.flushCallbacks(type);\n }\n\n if (retry) {\n LogBoxSymbolication.deleteStack(this.getStack(type));\n this.handleSymbolicate(type);\n } else {\n if (status === 'NONE') {\n this.handleSymbolicate(type);\n }\n }\n }\n\n private componentStackCache: Stack | null = null;\n\n private getStack(type: StackType): Stack {\n if (type === 'component') {\n if (this.componentStackCache == null) {\n this.componentStackCache = componentStackToStack(this.componentStack);\n }\n return this.componentStackCache;\n }\n return this.stack;\n }\n\n private handleSymbolicate(type: StackType): void {\n if (type === 'component' && !this.componentStack?.length) {\n return;\n }\n\n if (this.symbolicated[type].status !== 'PENDING') {\n this.updateStatus(type, null, null, null);\n LogBoxSymbolication.symbolicate(this.getStack(type)).then(\n (data) => {\n this.updateStatus(type, null, data?.stack, data?.codeFrame);\n },\n (error) => {\n this.updateStatus(type, error, null, null);\n }\n );\n }\n }\n\n private updateStatus(\n type: StackType,\n error?: Error | null,\n stack?: Stack | null,\n codeFrame?: CodeFrame | null\n ): void {\n const lastStatus = this.symbolicated[type].status;\n if (error != null) {\n this.symbolicated[type] = {\n error,\n stack: null,\n status: 'FAILED',\n };\n } else if (stack != null) {\n if (codeFrame) {\n this.codeFrame = codeFrame;\n }\n\n this.symbolicated[type] = {\n error: null,\n stack,\n status: 'COMPLETE',\n };\n } else {\n this.symbolicated[type] = {\n error: null,\n stack: null,\n status: 'PENDING',\n };\n }\n\n const status = this.symbolicated[type].status;\n if (lastStatus !== status) {\n if (['COMPLETE', 'FAILED'].includes(status)) {\n this.flushCallbacks(type);\n }\n }\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) 650 Industries.
|
|
3
4
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -5,7 +6,12 @@
|
|
|
5
6
|
* This source code is licensed under the MIT license found in the
|
|
6
7
|
* LICENSE file in the root directory of this source tree.
|
|
7
8
|
*/
|
|
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"));
|
|
9
15
|
const cache = new Map();
|
|
10
16
|
/**
|
|
11
17
|
* Sanitize because sometimes, `symbolicateStackTrace` gives us invalid values.
|
|
@@ -34,15 +40,17 @@ const sanitize = ({ stack: maybeStack, codeFrame, }) => {
|
|
|
34
40
|
}
|
|
35
41
|
return { stack, codeFrame };
|
|
36
42
|
};
|
|
37
|
-
|
|
43
|
+
function deleteStack(stack) {
|
|
38
44
|
cache.delete(stack);
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
exports.deleteStack = deleteStack;
|
|
47
|
+
function symbolicate(stack) {
|
|
41
48
|
let promise = cache.get(stack);
|
|
42
49
|
if (promise == null) {
|
|
43
|
-
promise =
|
|
50
|
+
promise = (0, symbolicateStackTrace_1.default)(stack).then(sanitize);
|
|
44
51
|
cache.set(stack, promise);
|
|
45
52
|
}
|
|
46
53
|
return promise;
|
|
47
54
|
}
|
|
55
|
+
exports.symbolicate = symbolicate;
|
|
48
56
|
//# sourceMappingURL=LogBoxSymbolication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxSymbolication.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxSymbolication.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"LogBoxSymbolication.js","sourceRoot":"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AAA,+BAAqB,EAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtD,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC3B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AARD,kCAQC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\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"]}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const LogBoxLog_1 = require("./LogBoxLog");
|
|
4
10
|
// Context provider for Array<LogBoxLog>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const logs =
|
|
11
|
+
exports.LogContext = react_1.default.createContext(null);
|
|
12
|
+
function useLogs() {
|
|
13
|
+
const logs = react_1.default.useContext(exports.LogContext);
|
|
8
14
|
if (!logs) {
|
|
9
|
-
if (Platform.OS === 'web' && typeof window !== 'undefined') {
|
|
15
|
+
if (react_native_1.Platform.OS === 'web' && typeof window !== 'undefined') {
|
|
10
16
|
// Logbox data that is pre-fetched on the dev server and rendered here.
|
|
11
17
|
const expoCliStaticErrorElement = document.getElementById('_expo-static-error');
|
|
12
18
|
if (expoCliStaticErrorElement?.textContent) {
|
|
13
19
|
const raw = JSON.parse(expoCliStaticErrorElement.textContent);
|
|
14
20
|
return {
|
|
15
21
|
...raw,
|
|
16
|
-
logs: raw.logs.map((raw) => new LogBoxLog(raw)),
|
|
22
|
+
logs: raw.logs.map((raw) => new LogBoxLog_1.LogBoxLog(raw)),
|
|
17
23
|
};
|
|
18
24
|
}
|
|
19
25
|
}
|
|
@@ -21,8 +27,10 @@ export function useLogs() {
|
|
|
21
27
|
}
|
|
22
28
|
return logs;
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
exports.useLogs = useLogs;
|
|
31
|
+
function useSelectedLog() {
|
|
25
32
|
const { selectedLogIndex, logs } = useLogs();
|
|
26
33
|
return logs[selectedLogIndex];
|
|
27
34
|
}
|
|
35
|
+
exports.useSelectedLog = useSelectedLog;
|
|
28
36
|
//# sourceMappingURL=LogContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogContext.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"LogContext.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAAwC;AAExC,2CAAwC;AAExC,wCAAwC;AAE3B,QAAA,UAAU,GAAG,eAAK,CAAC,aAAa,CAInC,IAAI,CAAC,CAAC;AAEhB,SAAgB,OAAO;IAKrB,MAAM,IAAI,GAAG,eAAK,CAAC,UAAU,CAAC,kBAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAC1D,uEAAuE;YACvE,MAAM,yBAAyB,GAAG,QAAQ,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;YAChF,IAAI,yBAAyB,EAAE,WAAW,EAAE;gBAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC;gBAC9D,OAAO;oBACL,GAAG,GAAG;oBACN,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,qBAAS,CAAC,GAAG,CAAC,CAAC;iBACrD,CAAC;aACH;SACF;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAtBD,0BAsBC;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';\nimport { Platform } from 'react-native';\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} | null>(null);\n\nexport function useLogs(): {\n selectedLogIndex: number;\n isDisabled: boolean;\n logs: LogBoxLog[];\n} {\n const logs = React.useContext(LogContext);\n if (!logs) {\n if (Platform.OS === 'web' && typeof window !== 'undefined') {\n // Logbox data that is pre-fetched on the dev server and rendered here.\n const expoCliStaticErrorElement = document.getElementById('_expo-static-error');\n if (expoCliStaticErrorElement?.textContent) {\n const raw = JSON.parse(expoCliStaticErrorElement.textContent);\n return {\n ...raw,\n logs: raw.logs.map((raw: any) => new LogBoxLog(raw)),\n };\n }\n }\n\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseLogBoxLog.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"parseLogBoxLog.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,KAAK,aAAa,GAAG,GAAG,CAAC;AASzB,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAClD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GAAG,IAAI,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IAKjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE;QACb,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,EAAE,CAAC;AAIzC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAG;IACxD,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAsEA;AAUD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAoCnE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,aAAa,CA0HhF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,GAAG;IACpD,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAwCA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) 650 Industries.
|
|
3
4
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -5,14 +6,18 @@
|
|
|
5
6
|
* This source code is licensed under the MIT license found in the
|
|
6
7
|
* LICENSE file in the root directory of this source tree.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
|
|
15
|
+
const stringifySafe_1 = __importDefault(require("../modules/stringifySafe"));
|
|
11
16
|
const BABEL_TRANSFORM_ERROR_FORMAT = /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/;
|
|
12
17
|
const BABEL_CODE_FRAME_ERROR_FORMAT = /^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\u{001b}[\s\S]+)/u;
|
|
13
18
|
const METRO_ERROR_FORMAT = /^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/u;
|
|
14
|
-
const SUBSTITUTION =
|
|
15
|
-
|
|
19
|
+
const SUBSTITUTION = '\ufeff%s';
|
|
20
|
+
function parseInterpolation(args) {
|
|
16
21
|
const categoryParts = [];
|
|
17
22
|
const contentParts = [];
|
|
18
23
|
const substitutionOffsets = [];
|
|
@@ -35,7 +40,7 @@ export function parseInterpolation(args) {
|
|
|
35
40
|
// which causes the LogBox to look odd.
|
|
36
41
|
const substitution = typeof substitutions[substitutionIndex] === 'string'
|
|
37
42
|
? substitutions[substitutionIndex]
|
|
38
|
-
:
|
|
43
|
+
: (0, stringifySafe_1.default)(substitutions[substitutionIndex]);
|
|
39
44
|
substitutionOffsets.push({
|
|
40
45
|
length: substitution.length,
|
|
41
46
|
offset: contentString.length,
|
|
@@ -61,7 +66,7 @@ export function parseInterpolation(args) {
|
|
|
61
66
|
// Don't stringify a string type.
|
|
62
67
|
// It adds quotation mark wrappers around the string,
|
|
63
68
|
// which causes the LogBox to look odd.
|
|
64
|
-
return typeof arg === 'string' ? arg :
|
|
69
|
+
return typeof arg === 'string' ? arg : (0, stringifySafe_1.default)(arg);
|
|
65
70
|
});
|
|
66
71
|
categoryParts.push(...remainingArgs);
|
|
67
72
|
contentParts.push(...remainingArgs);
|
|
@@ -73,17 +78,18 @@ export function parseInterpolation(args) {
|
|
|
73
78
|
},
|
|
74
79
|
};
|
|
75
80
|
}
|
|
81
|
+
exports.parseInterpolation = parseInterpolation;
|
|
76
82
|
function isComponentStack(consoleArgument) {
|
|
77
83
|
const isOldComponentStackFormat = / {4}in/.test(consoleArgument);
|
|
78
84
|
const isNewComponentStackFormat = / {4}at/.test(consoleArgument);
|
|
79
85
|
const isNewJSCComponentStackFormat = /@.*\n/.test(consoleArgument);
|
|
80
86
|
return isOldComponentStackFormat || isNewComponentStackFormat || isNewJSCComponentStackFormat;
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
function parseComponentStack(message) {
|
|
83
89
|
// In newer versions of React, the component stack is formatted as a call stack frame.
|
|
84
90
|
// First try to parse the component stack as a call stack frame, and if that doesn't
|
|
85
91
|
// work then we'll fallback to the old custom component stack format parsing.
|
|
86
|
-
const stack =
|
|
92
|
+
const stack = (0, parseErrorStack_1.default)(message);
|
|
87
93
|
if (stack && stack.length > 0) {
|
|
88
94
|
return stack.map((frame) => ({
|
|
89
95
|
content: frame.methodName,
|
|
@@ -114,7 +120,8 @@ export function parseComponentStack(message) {
|
|
|
114
120
|
})
|
|
115
121
|
.filter(Boolean);
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
exports.parseComponentStack = parseComponentStack;
|
|
124
|
+
function parseLogBoxException(error) {
|
|
118
125
|
const message = error.originalMessage != null ? error.originalMessage : 'Unknown';
|
|
119
126
|
const metroInternalError = message.match(METRO_ERROR_FORMAT);
|
|
120
127
|
if (metroInternalError) {
|
|
@@ -227,7 +234,8 @@ export function parseLogBoxException(error) {
|
|
|
227
234
|
...parseLogBoxLog([message]),
|
|
228
235
|
};
|
|
229
236
|
}
|
|
230
|
-
|
|
237
|
+
exports.parseLogBoxException = parseLogBoxException;
|
|
238
|
+
function parseLogBoxLog(args) {
|
|
231
239
|
const message = args[0];
|
|
232
240
|
let argsWithoutComponentStack = [];
|
|
233
241
|
let componentStack = [];
|
|
@@ -265,4 +273,5 @@ export function parseLogBoxLog(args) {
|
|
|
265
273
|
componentStack,
|
|
266
274
|
};
|
|
267
275
|
}
|
|
276
|
+
exports.parseLogBoxLog = parseLogBoxLog;
|
|
268
277
|
//# sourceMappingURL=parseLogBoxLog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseLogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAE7D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,aAAa,MAAM,0BAA0B,CAAC;AAIrD,MAAM,4BAA4B,GAChC,gGAAgG,CAAC;AACnG,MAAM,6BAA6B,GACjC,sGAAsG,CAAC;AACzG,MAAM,kBAAkB,GACtB,6FAA6F,CAAC;AAgChG,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,GAAG,IAAI,CAAC;AAE5C,MAAM,UAAU,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,CAAC;QAC/C,MAAM,iBAAiB,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnD,MAAM,iBA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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,OAAO;QACL,GAAG,kBAAkB,CAAC,yBAAyB,CAAC;QAChD,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\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[]): {\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 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 isOldComponentStackFormat || isNewComponentStackFormat || isNewJSCComponentStackFormat;\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(error: ExtendedExceptionData): LogBoxLogData {\n const message = 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] = 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] = 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 return {\n level: 'fatal',\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: 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 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 (typeof message === 'string' && message.slice(-2) === '%s' && args.length > 0) {\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 return {\n ...parseInterpolation(argsWithoutComponentStack),\n componentStack,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parseLogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAGH,iFAAyD;AACzD,6EAAqD;AAGrD,MAAM,4BAA4B,GAChC,gGAAgG,CAAC;AACnG,MAAM,6BAA6B,GACjC,sGAAsG,CAAC;AACzG,MAAM,kBAAkB,GACtB,6FAA6F,CAAC;AAgChG,MAAM,YAAY,GAAG,UAAU,CAAC;AAEhC,SAAgB,kBAAkB,CA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A5CD,wCA4CC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\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 type { LogBoxLogData } from './LogBoxLog';\nimport parseErrorStack from '../modules/parseErrorStack';\nimport stringifySafe from '../modules/stringifySafe';\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 = '\\ufeff%s';\n\nexport function parseInterpolation(args: readonly any[]): {\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 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 isOldComponentStackFormat || isNewComponentStackFormat || isNewJSCComponentStackFormat;\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(error: ExtendedExceptionData): LogBoxLogData {\n const message = 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] = 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] = 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 return {\n level: 'fatal',\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: 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 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 (typeof message === 'string' && message.slice(-2) === '%s' && args.length > 0) {\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 return {\n ...parseInterpolation(argsWithoutComponentStack),\n componentStack,\n };\n}\n"]}
|
|
@@ -1 +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,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAkBxD,wBAAgB,wBAAwB,uBAOvC;AAED,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,eAgEA;AAED,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;CAAE,eAGnF;AAED,wBAAgB,wBAAwB,CAAC,EACvC,GAAG,EACH,OAAO,GACR,EAAE;IACD,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC,
|
|
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,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAkBxD,wBAAgB,wBAAwB,uBAOvC;AAED,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,eAgEA;AAED,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;CAAE,eAGnF;AAED,wBAAgB,wBAAwB,CAAC,EACvC,GAAG,EACH,OAAO,GACR,EAAE;IACD,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC,eAgDA;;AAmBD,wBAAqE"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ErrorOverlayBodyContents = exports.ErrorOverlayBody = exports.LogBoxInspector = exports.LogBoxInspectorContainer = void 0;
|
|
1
27
|
/**
|
|
2
28
|
* Copyright (c) 650 Industries.
|
|
3
29
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -5,16 +31,16 @@
|
|
|
5
31
|
* This source code is licensed under the MIT license found in the
|
|
6
32
|
* LICENSE file in the root directory of this source tree.
|
|
7
33
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
const react_1 = __importStar(require("react"));
|
|
35
|
+
const react_native_1 = require("react-native");
|
|
36
|
+
const LogBoxData = __importStar(require("./Data/LogBoxData"));
|
|
37
|
+
const LogContext_1 = require("./Data/LogContext");
|
|
38
|
+
const LogBoxStyle = __importStar(require("./UI/LogBoxStyle"));
|
|
39
|
+
const LogBoxInspectorCodeFrame_1 = require("./overlay/LogBoxInspectorCodeFrame");
|
|
40
|
+
const LogBoxInspectorFooter_1 = require("./overlay/LogBoxInspectorFooter");
|
|
41
|
+
const LogBoxInspectorHeader_1 = require("./overlay/LogBoxInspectorHeader");
|
|
42
|
+
const LogBoxInspectorMessageHeader_1 = require("./overlay/LogBoxInspectorMessageHeader");
|
|
43
|
+
const LogBoxInspectorStackFrames_1 = require("./overlay/LogBoxInspectorStackFrames");
|
|
18
44
|
const HEADER_TITLE_MAP = {
|
|
19
45
|
warn: 'Console Warning',
|
|
20
46
|
error: 'Console Error',
|
|
@@ -23,16 +49,17 @@ const HEADER_TITLE_MAP = {
|
|
|
23
49
|
static: 'Static Rendering Error (Node.js)',
|
|
24
50
|
component: 'Render Error',
|
|
25
51
|
};
|
|
26
|
-
|
|
27
|
-
const { selectedLogIndex, logs } = useLogs();
|
|
52
|
+
function LogBoxInspectorContainer() {
|
|
53
|
+
const { selectedLogIndex, logs } = (0, LogContext_1.useLogs)();
|
|
28
54
|
const log = logs[selectedLogIndex];
|
|
29
55
|
if (log == null) {
|
|
30
56
|
return null;
|
|
31
57
|
}
|
|
32
|
-
return
|
|
58
|
+
return react_1.default.createElement(LogBoxInspector, { log: log, selectedLogIndex: selectedLogIndex, logs: logs });
|
|
33
59
|
}
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
exports.LogBoxInspectorContainer = LogBoxInspectorContainer;
|
|
61
|
+
function LogBoxInspector({ log, selectedLogIndex, logs, }) {
|
|
62
|
+
const onDismiss = (0, react_1.useCallback)(() => {
|
|
36
63
|
// Here we handle the cases when the log is dismissed and it
|
|
37
64
|
// was either the last log, or when the current index
|
|
38
65
|
// is now outside the bounds of the log array.
|
|
@@ -47,19 +74,19 @@ export function LogBoxInspector({ log, selectedLogIndex, logs, }) {
|
|
|
47
74
|
LogBoxData.dismiss(logsArray[selectedLogIndex]);
|
|
48
75
|
}
|
|
49
76
|
}, [selectedLogIndex]);
|
|
50
|
-
const onMinimize = useCallback(() => {
|
|
77
|
+
const onMinimize = (0, react_1.useCallback)(() => {
|
|
51
78
|
LogBoxData.setSelectedLog(-1);
|
|
52
79
|
}, []);
|
|
53
|
-
const onChangeSelectedIndex = useCallback((index) => {
|
|
80
|
+
const onChangeSelectedIndex = (0, react_1.useCallback)((index) => {
|
|
54
81
|
LogBoxData.setSelectedLog(index);
|
|
55
82
|
}, []);
|
|
56
|
-
useEffect(() => {
|
|
83
|
+
(0, react_1.useEffect)(() => {
|
|
57
84
|
if (log) {
|
|
58
85
|
LogBoxData.symbolicateLogNow('stack', log);
|
|
59
86
|
LogBoxData.symbolicateLogNow('component', log);
|
|
60
87
|
}
|
|
61
88
|
}, [log]);
|
|
62
|
-
useEffect(() => {
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
63
90
|
// Optimistically symbolicate the last and next logs.
|
|
64
91
|
if (logs.length > 1) {
|
|
65
92
|
const selected = selectedLogIndex;
|
|
@@ -72,41 +99,46 @@ export function LogBoxInspector({ log, selectedLogIndex, logs, }) {
|
|
|
72
99
|
}
|
|
73
100
|
}
|
|
74
101
|
}, [logs, selectedLogIndex]);
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
Keyboard.dismiss();
|
|
102
|
+
(0, react_1.useEffect)(() => {
|
|
103
|
+
react_native_1.Keyboard.dismiss();
|
|
77
104
|
}, []);
|
|
78
|
-
const _handleRetry = useCallback((type) => {
|
|
105
|
+
const _handleRetry = (0, react_1.useCallback)((type) => {
|
|
79
106
|
LogBoxData.retrySymbolicateLogNow(type, log);
|
|
80
107
|
}, [log]);
|
|
81
|
-
return (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
return (react_1.default.createElement(react_native_1.View, { style: styles.container },
|
|
109
|
+
react_1.default.createElement(LogBoxInspectorHeader_1.LogBoxInspectorHeader, { onSelectIndex: onChangeSelectedIndex, level: log.level }),
|
|
110
|
+
react_1.default.createElement(ErrorOverlayBody, { onRetry: _handleRetry }),
|
|
111
|
+
react_1.default.createElement(LogBoxInspectorFooter_1.LogBoxInspectorFooter, { onDismiss: onDismiss, onMinimize: onMinimize })));
|
|
85
112
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
exports.LogBoxInspector = LogBoxInspector;
|
|
114
|
+
function ErrorOverlayBody({ onRetry }) {
|
|
115
|
+
const log = (0, LogContext_1.useSelectedLog)();
|
|
116
|
+
return react_1.default.createElement(ErrorOverlayBodyContents, { log: log, onRetry: onRetry });
|
|
89
117
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
118
|
+
exports.ErrorOverlayBody = ErrorOverlayBody;
|
|
119
|
+
function ErrorOverlayBodyContents({ log, onRetry, }) {
|
|
120
|
+
const [collapsed, setCollapsed] = (0, react_1.useState)(true);
|
|
121
|
+
(0, react_1.useEffect)(() => {
|
|
93
122
|
setCollapsed(true);
|
|
94
123
|
}, [log]);
|
|
95
124
|
const headerTitle = HEADER_TITLE_MAP[log.isComponentError ? 'component' : log.level] ?? log.type;
|
|
96
|
-
const header = (
|
|
97
|
-
|
|
125
|
+
const header = (react_1.default.createElement(LogBoxInspectorMessageHeader_1.LogBoxInspectorMessageHeader, { collapsed: collapsed, onPress: () => setCollapsed(!collapsed), message: log.message, level: log.level, title: headerTitle }));
|
|
126
|
+
// Hide useless React stack.
|
|
127
|
+
const needsStack = !log.message.content.match(/(Expected server HTML to contain a matching|Text content did not match\.)/);
|
|
128
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
98
129
|
collapsed && header,
|
|
99
|
-
|
|
130
|
+
react_1.default.createElement(react_native_1.ScrollView, { style: styles.scrollBody },
|
|
100
131
|
!collapsed && header,
|
|
101
|
-
|
|
102
|
-
|
|
132
|
+
react_1.default.createElement(LogBoxInspectorCodeFrame_1.LogBoxInspectorCodeFrame, { codeFrame: log.codeFrame }),
|
|
133
|
+
needsStack && (react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "stack",
|
|
103
134
|
// eslint-disable-next-line react/jsx-no-bind
|
|
104
|
-
onRetry: onRetry.bind(onRetry, 'stack') }),
|
|
105
|
-
!!log?.componentStack?.length && (
|
|
135
|
+
onRetry: onRetry.bind(onRetry, 'stack') })),
|
|
136
|
+
!!log?.componentStack?.length && (react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "component",
|
|
106
137
|
// eslint-disable-next-line react/jsx-no-bind
|
|
107
138
|
onRetry: onRetry.bind(onRetry, 'component') })))));
|
|
108
139
|
}
|
|
109
|
-
|
|
140
|
+
exports.ErrorOverlayBodyContents = ErrorOverlayBodyContents;
|
|
141
|
+
const styles = react_native_1.StyleSheet.create({
|
|
110
142
|
scrollBody: {
|
|
111
143
|
backgroundColor: LogBoxStyle.getBackgroundColor(1),
|
|
112
144
|
flex: 1,
|
|
@@ -122,5 +154,5 @@ const styles = StyleSheet.create({
|
|
|
122
154
|
position: 'fixed',
|
|
123
155
|
},
|
|
124
156
|
});
|
|
125
|
-
|
|
157
|
+
exports.default = LogBoxData.withSubscription(LogBoxInspectorContainer);
|
|
126
158
|
//# sourceMappingURL=ErrorOverlay.js.map
|