@expo/metro-runtime 2.2.4 → 3.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/README.md +17 -1
- package/async-require.d.ts +1 -1
- package/async-require.js +1 -1
- package/build/HMRClient.d.ts +1 -1
- package/build/HMRClient.d.ts.map +1 -1
- package/build/HMRClient.js +40 -68
- package/build/HMRClient.js.map +1 -1
- package/build/HMRClient.native.js +2 -4
- package/build/HMRClient.native.js.map +1 -1
- package/build/LoadingView.d.ts +1 -1
- package/build/LoadingView.d.ts.map +1 -1
- package/build/LoadingView.js +4 -10
- package/build/LoadingView.js.map +1 -1
- package/build/LoadingView.native.d.ts +2 -0
- package/build/LoadingView.native.d.ts.map +1 -1
- package/build/LoadingView.native.js +2 -2
- package/build/LoadingView.native.js.map +1 -1
- package/build/async-require/buildAsyncRequire.js +3 -7
- package/build/async-require/buildAsyncRequire.js.map +1 -1
- package/build/async-require/buildUrlForBundle.js +2 -6
- package/build/async-require/buildUrlForBundle.js.map +1 -1
- package/build/async-require/buildUrlForBundle.native.js +6 -9
- package/build/async-require/buildUrlForBundle.native.js.map +1 -1
- package/build/async-require/fetchAsync.d.ts.map +1 -1
- package/build/async-require/fetchAsync.js +4 -8
- package/build/async-require/fetchAsync.js.map +1 -1
- package/build/async-require/fetchAsync.native.d.ts +1 -1
- package/build/async-require/fetchAsync.native.d.ts.map +1 -1
- package/build/async-require/fetchAsync.native.js +14 -21
- package/build/async-require/fetchAsync.native.js.map +1 -1
- package/build/async-require/fetchThenEval.d.ts.map +1 -1
- package/build/async-require/fetchThenEval.js +5 -10
- package/build/async-require/fetchThenEval.js.map +1 -1
- package/build/async-require/fetchThenEval.web.d.ts.map +1 -1
- package/build/async-require/fetchThenEval.web.js +14 -27
- package/build/async-require/fetchThenEval.web.js.map +1 -1
- package/build/async-require/index.js +2 -6
- package/build/async-require/index.js.map +1 -1
- package/build/async-require/loadBundle.d.ts.map +1 -1
- package/build/async-require/loadBundle.js +14 -18
- package/build/async-require/loadBundle.js.map +1 -1
- package/build/effects.js +5 -7
- package/build/effects.js.map +1 -1
- package/build/effects.native.js +0 -1
- package/build/error-overlay/Data/LogBoxData.d.ts +5 -5
- package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
- package/build/error-overlay/Data/LogBoxData.js +76 -127
- package/build/error-overlay/Data/LogBoxData.js.map +1 -1
- package/build/error-overlay/Data/LogBoxLog.d.ts +10 -10
- package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -1
- package/build/error-overlay/Data/LogBoxLog.js +46 -69
- package/build/error-overlay/Data/LogBoxLog.js.map +1 -1
- package/build/error-overlay/Data/LogBoxSymbolication.d.ts +2 -2
- package/build/error-overlay/Data/LogBoxSymbolication.js +9 -17
- package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -1
- package/build/error-overlay/Data/LogContext.d.ts +2 -2
- package/build/error-overlay/Data/LogContext.d.ts.map +1 -1
- package/build/error-overlay/Data/LogContext.js +12 -20
- package/build/error-overlay/Data/LogContext.js.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.d.ts +2 -2
- package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.js +35 -50
- package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
- package/build/error-overlay/ErrorOverlay.d.ts +10 -3
- package/build/error-overlay/ErrorOverlay.d.ts.map +1 -1
- package/build/error-overlay/ErrorOverlay.js +55 -86
- package/build/error-overlay/ErrorOverlay.js.map +1 -1
- package/build/error-overlay/LogBox.d.ts +2 -2
- package/build/error-overlay/LogBox.d.ts.map +1 -1
- package/build/error-overlay/LogBox.js +1 -4
- package/build/error-overlay/LogBox.js.map +1 -1
- package/build/error-overlay/LogBox.web.d.ts +3 -3
- package/build/error-overlay/LogBox.web.d.ts.map +1 -1
- package/build/error-overlay/LogBox.web.js +12 -17
- package/build/error-overlay/LogBox.web.js.map +1 -1
- package/build/error-overlay/UI/AnsiHighlight.d.ts +2 -2
- package/build/error-overlay/UI/AnsiHighlight.d.ts.map +1 -1
- package/build/error-overlay/UI/AnsiHighlight.js +28 -36
- package/build/error-overlay/UI/AnsiHighlight.js.map +1 -1
- package/build/error-overlay/UI/LogBoxButton.d.ts +1 -1
- package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -1
- package/build/error-overlay/UI/LogBoxButton.js +11 -40
- package/build/error-overlay/UI/LogBoxButton.js.map +1 -1
- package/build/error-overlay/UI/LogBoxMessage.d.ts +2 -2
- package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -1
- package/build/error-overlay/UI/LogBoxMessage.js +10 -17
- package/build/error-overlay/UI/LogBoxMessage.js.map +1 -1
- package/build/error-overlay/UI/LogBoxStyle.d.ts +1 -1
- package/build/error-overlay/UI/LogBoxStyle.js +15 -32
- package/build/error-overlay/UI/LogBoxStyle.js.map +1 -1
- package/build/error-overlay/UI/constants.js +5 -8
- package/build/error-overlay/UI/constants.js.map +1 -1
- package/build/error-overlay/formatProjectFilePath.d.ts +1 -1
- package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -1
- package/build/error-overlay/formatProjectFilePath.js +7 -14
- package/build/error-overlay/formatProjectFilePath.js.map +1 -1
- package/build/error-overlay/index.d.ts +1 -1
- package/build/error-overlay/index.d.ts.map +1 -1
- package/build/error-overlay/index.js +9 -17
- package/build/error-overlay/index.js.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.js +11 -21
- package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts +2 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.js +3 -3
- package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.d.ts.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.js +10 -15
- package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.js +2 -8
- package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.js +5 -7
- package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.js +2 -8
- package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.d.ts +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.js +4 -7
- package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts +1 -1
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js +2 -8
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -1
- package/build/error-overlay/modules/stringifySafe/index.d.ts +1 -1
- package/build/error-overlay/modules/stringifySafe/index.d.ts.map +1 -1
- package/build/error-overlay/modules/stringifySafe/index.js +16 -22
- package/build/error-overlay/modules/stringifySafe/index.js.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +2 -2
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.js +6 -8
- package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js +2 -7
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +28 -59
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js +34 -61
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js +36 -66
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +19 -49
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorSection.js +13 -43
- package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +26 -53
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +23 -53
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +42 -76
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -1
- package/build/error-overlay/toast/ErrorToast.d.ts +2 -2
- package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToast.js +43 -69
- package/build/error-overlay/toast/ErrorToast.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.d.ts +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.js +3 -9
- package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts +2 -2
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.js +22 -49
- package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.d.ts +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.js +8 -38
- package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -1
- package/build/error-overlay/useRejectionHandler.d.ts +1 -1
- package/build/error-overlay/useRejectionHandler.d.ts.map +1 -1
- package/build/error-overlay/useRejectionHandler.js +20 -28
- package/build/error-overlay/useRejectionHandler.js.map +1 -1
- package/build/getDevServer.d.ts.map +1 -1
- package/build/getDevServer.js +10 -16
- package/build/getDevServer.js.map +1 -1
- package/build/getDevServer.native.d.ts +2 -0
- package/build/getDevServer.native.d.ts.map +1 -1
- package/build/getDevServer.native.js +2 -2
- package/build/getDevServer.native.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +4 -6
- package/build/index.js.map +1 -1
- package/build/location/Location.js +2 -7
- package/build/location/Location.js.map +1 -1
- package/build/location/Location.native.d.ts.map +1 -1
- package/build/location/Location.native.js +25 -32
- package/build/location/Location.native.js.map +1 -1
- package/build/location/install.js +0 -1
- package/build/location/install.native.d.ts +1 -1
- package/build/location/install.native.js +23 -34
- package/build/location/install.native.js.map +1 -1
- package/build/messageSocket.d.ts.map +1 -1
- package/build/messageSocket.js +5 -6
- package/build/messageSocket.js.map +1 -1
- package/build/setupFastRefresh.d.ts.map +1 -1
- package/build/setupFastRefresh.js +2 -4
- package/build/setupFastRefresh.js.map +1 -1
- package/build/setupHMR.js +5 -12
- package/build/setupHMR.js.map +1 -1
- package/build/symbolicate.d.ts +3 -3
- package/build/symbolicate.js +4 -25
- package/build/symbolicate.js.map +1 -1
- package/error-overlay.d.ts +1 -1
- package/error-overlay.js +1 -1
- package/package.json +25 -14
- package/LICENSE +0 -13
|
@@ -1,52 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 650 Industries.
|
|
4
3
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
4
|
*
|
|
6
5
|
* This source code is licensed under the MIT license found in the
|
|
7
6
|
* LICENSE file in the root directory of this source tree.
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.withSubscription = exports.observe = exports.isDisabled = exports.setDisabled = exports.addIgnorePatterns = exports.getIgnorePatterns = exports.dismiss = exports.clearErrors = exports.clearWarnings = exports.setSelectedLog = exports.clear = exports.symbolicateLogLazy = exports.retrySymbolicateLogNow = exports.symbolicateLogNow = exports.addException = exports.addLog = exports.isMessageIgnored = exports.isLogBoxErrorMessage = exports.reportUnexpectedLogBoxError = exports.reportLogBoxError = void 0;
|
|
37
|
-
const React = __importStar(require("react"));
|
|
38
|
-
const NativeLogBox_1 = __importDefault(require("../modules/NativeLogBox"));
|
|
39
|
-
const parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
|
|
40
|
-
const LogBoxLog_1 = require("./LogBoxLog");
|
|
41
|
-
const LogContext_1 = require("./LogContext");
|
|
42
|
-
const parseLogBoxLog_1 = require("./parseLogBoxLog");
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import NativeLogBox from '../modules/NativeLogBox';
|
|
10
|
+
import parseErrorStack from '../modules/parseErrorStack';
|
|
11
|
+
import { LogBoxLog } from './LogBoxLog';
|
|
12
|
+
import { LogContext } from './LogContext';
|
|
13
|
+
import { parseLogBoxException } from './parseLogBoxLog';
|
|
43
14
|
const observers = new Set();
|
|
44
15
|
const ignorePatterns = new Set();
|
|
45
16
|
let logs = new Set();
|
|
46
17
|
let updateTimeout = null;
|
|
47
18
|
let _isDisabled = false;
|
|
48
19
|
let _selectedIndex = -1;
|
|
49
|
-
const LOGBOX_ERROR_MESSAGE =
|
|
20
|
+
const LOGBOX_ERROR_MESSAGE = 'An error was thrown when attempting to render log messages via LogBox.';
|
|
50
21
|
function getNextState() {
|
|
51
22
|
return {
|
|
52
23
|
logs,
|
|
@@ -54,33 +25,29 @@ function getNextState() {
|
|
|
54
25
|
selectedLogIndex: _selectedIndex,
|
|
55
26
|
};
|
|
56
27
|
}
|
|
57
|
-
function reportLogBoxError(error, componentStack) {
|
|
58
|
-
const ExceptionsManager = require(
|
|
28
|
+
export function reportLogBoxError(error, componentStack) {
|
|
29
|
+
const ExceptionsManager = require('../modules/ExceptionsManager').default;
|
|
59
30
|
if (componentStack != null) {
|
|
60
31
|
error.componentStack = componentStack;
|
|
61
32
|
}
|
|
62
33
|
ExceptionsManager.handleException(error);
|
|
63
34
|
}
|
|
64
|
-
|
|
65
|
-
function reportUnexpectedLogBoxError(error, componentStack) {
|
|
35
|
+
export function reportUnexpectedLogBoxError(error, componentStack) {
|
|
66
36
|
error.message = `${LOGBOX_ERROR_MESSAGE}\n\n${error.message}`;
|
|
67
37
|
return reportLogBoxError(error, componentStack);
|
|
68
38
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return typeof message === "string" && message.includes(LOGBOX_ERROR_MESSAGE);
|
|
39
|
+
export function isLogBoxErrorMessage(message) {
|
|
40
|
+
return typeof message === 'string' && message.includes(LOGBOX_ERROR_MESSAGE);
|
|
72
41
|
}
|
|
73
|
-
|
|
74
|
-
function isMessageIgnored(message) {
|
|
42
|
+
export function isMessageIgnored(message) {
|
|
75
43
|
for (const pattern of ignorePatterns) {
|
|
76
44
|
if ((pattern instanceof RegExp && pattern.test(message)) ||
|
|
77
|
-
(typeof pattern ===
|
|
45
|
+
(typeof pattern === 'string' && message.includes(pattern))) {
|
|
78
46
|
return true;
|
|
79
47
|
}
|
|
80
48
|
}
|
|
81
49
|
return false;
|
|
82
50
|
}
|
|
83
|
-
exports.isMessageIgnored = isMessageIgnored;
|
|
84
51
|
function setImmediateShim(callback) {
|
|
85
52
|
if (!global.setImmediate) {
|
|
86
53
|
return setTimeout(callback, 0);
|
|
@@ -111,7 +78,7 @@ function appendNewLog(newLog) {
|
|
|
111
78
|
handleUpdate();
|
|
112
79
|
return;
|
|
113
80
|
}
|
|
114
|
-
if (newLog.level ===
|
|
81
|
+
if (newLog.level === 'fatal') {
|
|
115
82
|
// If possible, to avoid jank, we don't want to open the error before
|
|
116
83
|
// it's symbolicated. To do that, we optimistically wait for
|
|
117
84
|
// symbolication for up to a second before adding the log.
|
|
@@ -132,19 +99,19 @@ function appendNewLog(newLog) {
|
|
|
132
99
|
}
|
|
133
100
|
}, OPTIMISTIC_WAIT_TIME);
|
|
134
101
|
// TODO: HANDLE THIS
|
|
135
|
-
newLog.symbolicate(
|
|
136
|
-
newLog.symbolicate(
|
|
137
|
-
if (addPendingLog && status !==
|
|
102
|
+
newLog.symbolicate('component');
|
|
103
|
+
newLog.symbolicate('stack', (status) => {
|
|
104
|
+
if (addPendingLog && status !== 'PENDING') {
|
|
138
105
|
addPendingLog();
|
|
139
106
|
clearTimeout(optimisticTimeout);
|
|
140
107
|
}
|
|
141
|
-
else if (status !==
|
|
108
|
+
else if (status !== 'PENDING') {
|
|
142
109
|
// The log has already been added but we need to trigger a render.
|
|
143
110
|
handleUpdate();
|
|
144
111
|
}
|
|
145
112
|
});
|
|
146
113
|
}
|
|
147
|
-
else if (newLog.level ===
|
|
114
|
+
else if (newLog.level === 'syntax') {
|
|
148
115
|
logs.add(newLog);
|
|
149
116
|
setSelectedLog(logs.size - 1);
|
|
150
117
|
}
|
|
@@ -153,14 +120,14 @@ function appendNewLog(newLog) {
|
|
|
153
120
|
handleUpdate();
|
|
154
121
|
}
|
|
155
122
|
}
|
|
156
|
-
function addLog(log) {
|
|
123
|
+
export function addLog(log) {
|
|
157
124
|
const errorForStackTrace = new Error();
|
|
158
125
|
// Parsing logs are expensive so we schedule this
|
|
159
126
|
// otherwise spammy logs would pause rendering.
|
|
160
127
|
setImmediate(() => {
|
|
161
128
|
try {
|
|
162
|
-
const stack = (
|
|
163
|
-
appendNewLog(new
|
|
129
|
+
const stack = parseErrorStack(errorForStackTrace?.stack);
|
|
130
|
+
appendNewLog(new LogBoxLog({
|
|
164
131
|
level: log.level,
|
|
165
132
|
message: log.message,
|
|
166
133
|
isComponentError: false,
|
|
@@ -174,51 +141,45 @@ function addLog(log) {
|
|
|
174
141
|
}
|
|
175
142
|
});
|
|
176
143
|
}
|
|
177
|
-
|
|
178
|
-
function addException(error) {
|
|
144
|
+
export function addException(error) {
|
|
179
145
|
// Parsing logs are expensive so we schedule this
|
|
180
146
|
// otherwise spammy logs would pause rendering.
|
|
181
147
|
setImmediate(() => {
|
|
182
148
|
try {
|
|
183
|
-
appendNewLog(new
|
|
149
|
+
appendNewLog(new LogBoxLog(parseLogBoxException(error)));
|
|
184
150
|
}
|
|
185
151
|
catch (loggingError) {
|
|
186
152
|
reportUnexpectedLogBoxError(loggingError);
|
|
187
153
|
}
|
|
188
154
|
});
|
|
189
155
|
}
|
|
190
|
-
|
|
191
|
-
function symbolicateLogNow(type, log) {
|
|
156
|
+
export function symbolicateLogNow(type, log) {
|
|
192
157
|
log.symbolicate(type, () => {
|
|
193
158
|
handleUpdate();
|
|
194
159
|
});
|
|
195
160
|
}
|
|
196
|
-
|
|
197
|
-
function retrySymbolicateLogNow(type, log) {
|
|
161
|
+
export function retrySymbolicateLogNow(type, log) {
|
|
198
162
|
log.retrySymbolicate(type, () => {
|
|
199
163
|
handleUpdate();
|
|
200
164
|
});
|
|
201
165
|
}
|
|
202
|
-
|
|
203
|
-
function symbolicateLogLazy(type, log) {
|
|
166
|
+
export function symbolicateLogLazy(type, log) {
|
|
204
167
|
log.symbolicate(type);
|
|
205
168
|
}
|
|
206
|
-
|
|
207
|
-
function clear() {
|
|
169
|
+
export function clear() {
|
|
208
170
|
if (logs.size > 0) {
|
|
209
171
|
logs = new Set();
|
|
210
172
|
setSelectedLog(-1);
|
|
211
173
|
}
|
|
212
174
|
}
|
|
213
|
-
|
|
214
|
-
function setSelectedLog(proposedNewIndex) {
|
|
175
|
+
export function setSelectedLog(proposedNewIndex) {
|
|
215
176
|
const oldIndex = _selectedIndex;
|
|
216
177
|
let newIndex = proposedNewIndex;
|
|
217
178
|
const logArray = Array.from(logs);
|
|
218
179
|
let index = logArray.length - 1;
|
|
219
180
|
while (index >= 0) {
|
|
220
181
|
// The latest syntax error is selected and displayed before all other logs.
|
|
221
|
-
if (logArray[index].level ===
|
|
182
|
+
if (logArray[index].level === 'syntax') {
|
|
222
183
|
newIndex = index;
|
|
223
184
|
break;
|
|
224
185
|
}
|
|
@@ -226,47 +187,42 @@ function setSelectedLog(proposedNewIndex) {
|
|
|
226
187
|
}
|
|
227
188
|
_selectedIndex = newIndex;
|
|
228
189
|
handleUpdate();
|
|
229
|
-
if (
|
|
190
|
+
if (NativeLogBox) {
|
|
230
191
|
setTimeout(() => {
|
|
231
192
|
if (oldIndex < 0 && newIndex >= 0) {
|
|
232
|
-
|
|
193
|
+
NativeLogBox.show();
|
|
233
194
|
}
|
|
234
195
|
else if (oldIndex >= 0 && newIndex < 0) {
|
|
235
|
-
|
|
196
|
+
NativeLogBox.hide();
|
|
236
197
|
}
|
|
237
198
|
}, 0);
|
|
238
199
|
}
|
|
239
200
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const newLogs = Array.from(logs).filter((log) => log.level !== "warn");
|
|
201
|
+
export function clearWarnings() {
|
|
202
|
+
const newLogs = Array.from(logs).filter((log) => log.level !== 'warn');
|
|
243
203
|
if (newLogs.length !== logs.size) {
|
|
244
204
|
logs = new Set(newLogs);
|
|
245
205
|
setSelectedLog(-1);
|
|
246
206
|
handleUpdate();
|
|
247
207
|
}
|
|
248
208
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const newLogs = Array.from(logs).filter((log) => log.level !== "error" && log.level !== "fatal");
|
|
209
|
+
export function clearErrors() {
|
|
210
|
+
const newLogs = Array.from(logs).filter((log) => log.level !== 'error' && log.level !== 'fatal');
|
|
252
211
|
if (newLogs.length !== logs.size) {
|
|
253
212
|
logs = new Set(newLogs);
|
|
254
213
|
setSelectedLog(-1);
|
|
255
214
|
}
|
|
256
215
|
}
|
|
257
|
-
|
|
258
|
-
function dismiss(log) {
|
|
216
|
+
export function dismiss(log) {
|
|
259
217
|
if (logs.has(log)) {
|
|
260
218
|
logs.delete(log);
|
|
261
219
|
handleUpdate();
|
|
262
220
|
}
|
|
263
221
|
}
|
|
264
|
-
|
|
265
|
-
function getIgnorePatterns() {
|
|
222
|
+
export function getIgnorePatterns() {
|
|
266
223
|
return Array.from(ignorePatterns);
|
|
267
224
|
}
|
|
268
|
-
|
|
269
|
-
function addIgnorePatterns(patterns) {
|
|
225
|
+
export function addIgnorePatterns(patterns) {
|
|
270
226
|
const existingSize = ignorePatterns.size;
|
|
271
227
|
// The same pattern may be added multiple times, but adding a new pattern
|
|
272
228
|
// can be expensive so let's find only the ones that are new.
|
|
@@ -292,20 +248,17 @@ function addIgnorePatterns(patterns) {
|
|
|
292
248
|
logs = new Set(Array.from(logs).filter((log) => !isMessageIgnored(log.message.content)));
|
|
293
249
|
handleUpdate();
|
|
294
250
|
}
|
|
295
|
-
|
|
296
|
-
function setDisabled(value) {
|
|
251
|
+
export function setDisabled(value) {
|
|
297
252
|
if (value === _isDisabled) {
|
|
298
253
|
return;
|
|
299
254
|
}
|
|
300
255
|
_isDisabled = value;
|
|
301
256
|
handleUpdate();
|
|
302
257
|
}
|
|
303
|
-
|
|
304
|
-
function isDisabled() {
|
|
258
|
+
export function isDisabled() {
|
|
305
259
|
return _isDisabled;
|
|
306
260
|
}
|
|
307
|
-
|
|
308
|
-
function observe(observer) {
|
|
261
|
+
export function observe(observer) {
|
|
309
262
|
const subscription = { observer };
|
|
310
263
|
observers.add(subscription);
|
|
311
264
|
observer(getNextState());
|
|
@@ -315,40 +268,8 @@ function observe(observer) {
|
|
|
315
268
|
},
|
|
316
269
|
};
|
|
317
270
|
}
|
|
318
|
-
|
|
319
|
-
function withSubscription(WrappedComponent) {
|
|
271
|
+
export function withSubscription(WrappedComponent) {
|
|
320
272
|
class LogBoxStateSubscription extends React.Component {
|
|
321
|
-
constructor() {
|
|
322
|
-
super(...arguments);
|
|
323
|
-
this.state = {
|
|
324
|
-
logs: new Set(),
|
|
325
|
-
isDisabled: false,
|
|
326
|
-
hasError: false,
|
|
327
|
-
selectedLogIndex: -1,
|
|
328
|
-
};
|
|
329
|
-
this._handleDismiss = () => {
|
|
330
|
-
// Here we handle the cases when the log is dismissed and it
|
|
331
|
-
// was either the last log, or when the current index
|
|
332
|
-
// is now outside the bounds of the log array.
|
|
333
|
-
const { selectedLogIndex, logs: stateLogs } = this.state;
|
|
334
|
-
const logsArray = Array.from(stateLogs);
|
|
335
|
-
if (selectedLogIndex != null) {
|
|
336
|
-
if (logsArray.length - 1 <= 0) {
|
|
337
|
-
setSelectedLog(-1);
|
|
338
|
-
}
|
|
339
|
-
else if (selectedLogIndex >= logsArray.length - 1) {
|
|
340
|
-
setSelectedLog(selectedLogIndex - 1);
|
|
341
|
-
}
|
|
342
|
-
dismiss(logsArray[selectedLogIndex]);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
this._handleMinimize = () => {
|
|
346
|
-
setSelectedLog(-1);
|
|
347
|
-
};
|
|
348
|
-
this._handleSetSelectedLog = (index) => {
|
|
349
|
-
setSelectedLog(index);
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
273
|
static getDerivedStateFromError() {
|
|
353
274
|
return { hasError: true };
|
|
354
275
|
}
|
|
@@ -357,13 +278,20 @@ function withSubscription(WrappedComponent) {
|
|
|
357
278
|
* this parameters */
|
|
358
279
|
reportLogBoxError(err, errorInfo.componentStack);
|
|
359
280
|
}
|
|
281
|
+
_subscription;
|
|
282
|
+
state = {
|
|
283
|
+
logs: new Set(),
|
|
284
|
+
isDisabled: false,
|
|
285
|
+
hasError: false,
|
|
286
|
+
selectedLogIndex: -1,
|
|
287
|
+
};
|
|
360
288
|
render() {
|
|
361
289
|
if (this.state.hasError) {
|
|
362
290
|
// This happens when the component failed to render, in which case we delegate to the native redbox.
|
|
363
291
|
// We can't show any fallback UI here, because the error may be with <View> or <Text>.
|
|
364
292
|
return null;
|
|
365
293
|
}
|
|
366
|
-
return (React.createElement(
|
|
294
|
+
return (React.createElement(LogContext.Provider, { value: {
|
|
367
295
|
selectedLogIndex: this.state.selectedLogIndex,
|
|
368
296
|
isDisabled: this.state.isDisabled,
|
|
369
297
|
logs: Array.from(this.state.logs),
|
|
@@ -381,9 +309,30 @@ function withSubscription(WrappedComponent) {
|
|
|
381
309
|
this._subscription.unsubscribe();
|
|
382
310
|
}
|
|
383
311
|
}
|
|
312
|
+
_handleDismiss = () => {
|
|
313
|
+
// Here we handle the cases when the log is dismissed and it
|
|
314
|
+
// was either the last log, or when the current index
|
|
315
|
+
// is now outside the bounds of the log array.
|
|
316
|
+
const { selectedLogIndex, logs: stateLogs } = this.state;
|
|
317
|
+
const logsArray = Array.from(stateLogs);
|
|
318
|
+
if (selectedLogIndex != null) {
|
|
319
|
+
if (logsArray.length - 1 <= 0) {
|
|
320
|
+
setSelectedLog(-1);
|
|
321
|
+
}
|
|
322
|
+
else if (selectedLogIndex >= logsArray.length - 1) {
|
|
323
|
+
setSelectedLog(selectedLogIndex - 1);
|
|
324
|
+
}
|
|
325
|
+
dismiss(logsArray[selectedLogIndex]);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
_handleMinimize = () => {
|
|
329
|
+
setSelectedLog(-1);
|
|
330
|
+
};
|
|
331
|
+
_handleSetSelectedLog = (index) => {
|
|
332
|
+
setSelectedLog(index);
|
|
333
|
+
};
|
|
384
334
|
}
|
|
385
335
|
// @ts-expect-error
|
|
386
336
|
return LogBoxStateSubscription;
|
|
387
337
|
}
|
|
388
|
-
exports.withSubscription = withSubscription;
|
|
389
338
|
//# sourceMappingURL=LogBoxData.js.map
|
|
@@ -1 +1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Ac,CAAC,CAAC;QACnD,CAAC;QAWD,MAAM;YACJ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACvB,oGAAoG;gBACpG,sFAAsF;gBACtF,OAAO,IAAI,CAAC;aACb;YAED,OAAO,CACL,oBAAC,uBAAU,CAAC,QAAQ,IAClB,KAAK,EAAE;oBACL,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB;oBAC7C,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;oBACjC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;iBAClC;gBAEA,IAAI,CAAC,KAAK,CAAC,QAAQ;gBACpB,oBAAC,gBAAgB,OAAG,CACA,CACvB,CAAC;QACJ,CAAC;QAED,iBAAiB;YACf,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACpC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,oBAAoB;YAClB,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;gBAC9B,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;aAClC;QACH,CAAC;KA0BF;IAED,mBAAmB;IACnB,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAvFD,4CAuFC","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 * as React from \"react\";\n\nimport NativeLogBox from \"../modules/NativeLogBox\";\nimport parseErrorStack from \"../modules/parseErrorStack\";\nimport { LogBoxLog, StackType } from \"./LogBoxLog\";\nimport type { LogLevel } from \"./LogBoxLog\";\nimport { LogContext } from \"./LogContext\";\nimport { parseLogBoxException } from \"./parseLogBoxLog\";\nimport type {\n Message,\n Category,\n ComponentStack,\n ExtendedExceptionData,\n} from \"./parseLogBoxLog\";\n\nexport type LogBoxLogs = Set<LogBoxLog>;\n\nexport type LogData = {\n level: LogLevel;\n message: Message;\n category: Category;\n componentStack: ComponentStack;\n};\n\ntype ExtendedError = any;\n\nexport type Observer = (options: {\n logs: LogBoxLogs;\n isDisabled: boolean;\n selectedLogIndex: number;\n}) => void;\n\nexport type IgnorePattern = string | RegExp;\n\nexport type Subscription = {\n unsubscribe: () => void;\n};\n\nexport type WarningInfo = {\n finalFormat: string;\n forceDialogImmediately: boolean;\n suppressDialog_LEGACY: boolean;\n suppressCompletely: boolean;\n monitorEvent: string | null;\n monitorListVersion: number;\n monitorSampleRate: number;\n};\n\nexport type WarningFilter = (format: string) => WarningInfo;\n\ntype Props = object;\n\ntype State = {\n logs: LogBoxLogs;\n isDisabled: boolean;\n hasError: boolean;\n selectedLogIndex: number;\n};\n\nconst observers: Set<{ observer: Observer } & any> = new Set();\nconst ignorePatterns: Set<IgnorePattern> = new Set();\nlet logs: LogBoxLogs = new Set();\nlet updateTimeout:\n | null\n | ReturnType<typeof setImmediate>\n | ReturnType<typeof setTimeout> = null;\nlet _isDisabled = false;\nlet _selectedIndex = -1;\n\nconst LOGBOX_ERROR_MESSAGE =\n \"An error was thrown when attempting to render log messages via LogBox.\";\n\nfunction getNextState() {\n return {\n logs,\n isDisabled: _isDisabled,\n selectedLogIndex: _selectedIndex,\n };\n}\n\nexport function reportLogBoxError(\n error: ExtendedError,\n componentStack?: string\n): void {\n const ExceptionsManager = require(\"../modules/ExceptionsManager\");\n\n if (componentStack != null) {\n error.componentStack = componentStack;\n }\n ExceptionsManager.handleException(error);\n}\n\nexport function reportUnexpectedLogBoxError(\n error: ExtendedError,\n componentStack?: string\n): void {\n error.message = `${LOGBOX_ERROR_MESSAGE}\\n\\n${error.message}`;\n return reportLogBoxError(error, componentStack);\n}\n\nexport function isLogBoxErrorMessage(message: string): boolean {\n return typeof message === \"string\" && message.includes(LOGBOX_ERROR_MESSAGE);\n}\n\nexport function isMessageIgnored(message: string): boolean {\n for (const pattern of ignorePatterns) {\n if (\n (pattern instanceof RegExp && pattern.test(message)) ||\n (typeof pattern === \"string\" && message.includes(pattern))\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction setImmediateShim(callback: () => void) {\n if (!global.setImmediate) {\n return setTimeout(callback, 0);\n }\n return global.setImmediate(callback);\n}\n\nfunction handleUpdate(): void {\n if (updateTimeout == null) {\n updateTimeout = setImmediateShim(() => {\n updateTimeout = null;\n const nextState = getNextState();\n observers.forEach(({ observer }) => observer(nextState));\n });\n }\n}\n\nfunction appendNewLog(newLog: LogBoxLog): void {\n // Don't want store these logs because they trigger a\n // state update when we add them to the store.\n if (isMessageIgnored(newLog.message.content)) {\n return;\n }\n\n // If the next log has the same category as the previous one\n // then roll it up into the last log in the list by incrementing\n // the count (similar to how Chrome does it).\n const lastLog = Array.from(logs).pop();\n if (lastLog && lastLog.category === newLog.category) {\n lastLog.incrementCount();\n handleUpdate();\n return;\n }\n\n if (newLog.level === \"fatal\") {\n // If possible, to avoid jank, we don't want to open the error before\n // it's symbolicated. To do that, we optimistically wait for\n // symbolication for up to a second before adding the log.\n const OPTIMISTIC_WAIT_TIME = 1000;\n\n let addPendingLog: null | (() => void) = () => {\n logs.add(newLog);\n if (_selectedIndex < 0) {\n setSelectedLog(logs.size - 1);\n } else {\n handleUpdate();\n }\n addPendingLog = null;\n };\n\n const optimisticTimeout = setTimeout(() => {\n if (addPendingLog) {\n addPendingLog();\n }\n }, OPTIMISTIC_WAIT_TIME);\n\n // TODO: HANDLE THIS\n newLog.symbolicate(\"component\");\n\n newLog.symbolicate(\"stack\", (status) => {\n if (addPendingLog && status !== \"PENDING\") {\n addPendingLog();\n clearTimeout(optimisticTimeout);\n } else if (status !== \"PENDING\") {\n // The log has already been added but we need to trigger a render.\n handleUpdate();\n }\n });\n } else if (newLog.level === \"syntax\") {\n logs.add(newLog);\n setSelectedLog(logs.size - 1);\n } else {\n logs.add(newLog);\n handleUpdate();\n }\n}\n\nexport function addLog(log: LogData): void {\n const errorForStackTrace = new Error();\n\n // Parsing logs are expensive so we schedule this\n // otherwise spammy logs would pause rendering.\n setImmediate(() => {\n try {\n const stack = parseErrorStack(errorForStackTrace?.stack);\n\n appendNewLog(\n new LogBoxLog({\n level: log.level,\n message: log.message,\n isComponentError: false,\n stack,\n category: log.category,\n componentStack: log.componentStack,\n })\n );\n } catch (error) {\n reportUnexpectedLogBoxError(error);\n }\n });\n}\n\nexport function addException(error: ExtendedExceptionData): void {\n // Parsing logs are expensive so we schedule this\n // otherwise spammy logs would pause rendering.\n setImmediate(() => {\n try {\n appendNewLog(new LogBoxLog(parseLogBoxException(error)));\n } catch (loggingError) {\n reportUnexpectedLogBoxError(loggingError);\n }\n });\n}\n\nexport function symbolicateLogNow(type: StackType, log: LogBoxLog) {\n log.symbolicate(type, () => {\n handleUpdate();\n });\n}\n\nexport function retrySymbolicateLogNow(type: StackType, log: LogBoxLog) {\n log.retrySymbolicate(type, () => {\n handleUpdate();\n });\n}\n\nexport function symbolicateLogLazy(type: StackType, log: LogBoxLog) {\n log.symbolicate(type);\n}\n\nexport function clear(): void {\n if (logs.size > 0) {\n logs = new Set();\n setSelectedLog(-1);\n }\n}\n\nexport function setSelectedLog(proposedNewIndex: number): void {\n const oldIndex = _selectedIndex;\n let newIndex = proposedNewIndex;\n\n const logArray = Array.from(logs);\n let index = logArray.length - 1;\n while (index >= 0) {\n // The latest syntax error is selected and displayed before all other logs.\n if (logArray[index].level === \"syntax\") {\n newIndex = index;\n break;\n }\n index -= 1;\n }\n _selectedIndex = newIndex;\n handleUpdate();\n if (NativeLogBox) {\n setTimeout(() => {\n if (oldIndex < 0 && newIndex >= 0) {\n NativeLogBox.show();\n } else if (oldIndex >= 0 && newIndex < 0) {\n NativeLogBox.hide();\n }\n }, 0);\n }\n}\n\nexport function clearWarnings(): void {\n const newLogs = Array.from(logs).filter((log) => log.level !== \"warn\");\n if (newLogs.length !== logs.size) {\n logs = new Set(newLogs);\n setSelectedLog(-1);\n handleUpdate();\n }\n}\n\nexport function clearErrors(): void {\n const newLogs = Array.from(logs).filter(\n (log) => log.level !== \"error\" && log.level !== \"fatal\"\n );\n if (newLogs.length !== logs.size) {\n logs = new Set(newLogs);\n setSelectedLog(-1);\n }\n}\n\nexport function dismiss(log: LogBoxLog): void {\n if (logs.has(log)) {\n logs.delete(log);\n handleUpdate();\n }\n}\n\nexport function getIgnorePatterns(): IgnorePattern[] {\n return Array.from(ignorePatterns);\n}\n\nexport function addIgnorePatterns(patterns: IgnorePattern[]): void {\n const existingSize = ignorePatterns.size;\n // The same pattern may be added multiple times, but adding a new pattern\n // can be expensive so let's find only the ones that are new.\n patterns.forEach((pattern: IgnorePattern) => {\n if (pattern instanceof RegExp) {\n for (const existingPattern of ignorePatterns) {\n if (\n existingPattern instanceof RegExp &&\n existingPattern.toString() === pattern.toString()\n ) {\n return;\n }\n }\n ignorePatterns.add(pattern);\n }\n ignorePatterns.add(pattern);\n });\n if (ignorePatterns.size === existingSize) {\n return;\n }\n // We need to recheck all of the existing logs.\n // This allows adding an ignore pattern anywhere in the codebase.\n // Without this, if you ignore a pattern after the a log is created,\n // then we would keep showing the log.\n logs = new Set(\n Array.from(logs).filter((log) => !isMessageIgnored(log.message.content))\n );\n handleUpdate();\n}\n\nexport function setDisabled(value: boolean): void {\n if (value === _isDisabled) {\n return;\n }\n _isDisabled = value;\n handleUpdate();\n}\n\nexport function isDisabled(): boolean {\n return _isDisabled;\n}\n\nexport function observe(observer: Observer): Subscription {\n const subscription = { observer };\n observers.add(subscription);\n\n observer(getNextState());\n\n return {\n unsubscribe(): void {\n observers.delete(subscription);\n },\n };\n}\n\nexport function withSubscription(\n WrappedComponent: React.FC<object>\n): React.Component<object> {\n class LogBoxStateSubscription extends React.Component<\n React.PropsWithChildren<Props>,\n State\n > {\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n componentDidCatch(err: Error, errorInfo: { componentStack: string } & any) {\n /* $FlowFixMe[class-object-subtyping] added when improving typing for\n * this parameters */\n reportLogBoxError(err, errorInfo.componentStack);\n }\n\n _subscription?: Subscription;\n\n state = {\n logs: new Set<LogBoxLog>(),\n isDisabled: false,\n hasError: false,\n selectedLogIndex: -1,\n };\n\n render() {\n if (this.state.hasError) {\n // This happens when the component failed to render, in which case we delegate to the native redbox.\n // We can't show any fallback UI here, because the error may be with <View> or <Text>.\n return null;\n }\n\n return (\n <LogContext.Provider\n value={{\n selectedLogIndex: this.state.selectedLogIndex,\n isDisabled: this.state.isDisabled,\n logs: Array.from(this.state.logs),\n }}\n >\n {this.props.children}\n <WrappedComponent />\n </LogContext.Provider>\n );\n }\n\n componentDidMount(): void {\n this._subscription = observe((data) => {\n this.setState(data);\n });\n }\n\n componentWillUnmount(): void {\n if (this._subscription != null) {\n this._subscription.unsubscribe();\n }\n }\n\n _handleDismiss = (): void => {\n // Here we handle the cases when the log is dismissed and it\n // was either the last log, or when the current index\n // is now outside the bounds of the log array.\n const { selectedLogIndex, logs: stateLogs } = this.state;\n const logsArray = Array.from(stateLogs);\n if (selectedLogIndex != null) {\n if (logsArray.length - 1 <= 0) {\n setSelectedLog(-1);\n } else if (selectedLogIndex >= logsArray.length - 1) {\n setSelectedLog(selectedLogIndex - 1);\n }\n\n dismiss(logsArray[selectedLogIndex]);\n }\n };\n\n _handleMinimize = (): void => {\n setSelectedLog(-1);\n };\n\n _handleSetSelectedLog = (index: number): void => {\n setSelectedLog(index);\n };\n }\n\n // @ts-expect-error\n return LogBoxStateSubscription;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LogBoxData.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxData.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AAEn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AAC,CAAC,CAAC,CAAC;iBACpB;qBAAM,IAAI,gBAAgB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;oBACnD,cAAc,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;iBACtC;gBAED,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;aACtC;QACH,CAAC,CAAC;QAEF,eAAe,GAAG,GAAS,EAAE;YAC3B,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC;QAEF,qBAAqB,GAAG,CAAC,KAAa,EAAQ,EAAE;YAC9C,cAAc,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC;KACH;IAED,mBAAmB;IACnB,OAAO,uBAAuB,CAAC;AACjC,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 * as React from 'react';\n\nimport NativeLogBox from '../modules/NativeLogBox';\nimport parseErrorStack from '../modules/parseErrorStack';\nimport { LogBoxLog, StackType } from './LogBoxLog';\nimport type { LogLevel } from './LogBoxLog';\nimport { LogContext } from './LogContext';\nimport { parseLogBoxException } from './parseLogBoxLog';\nimport type { Message, Category, ComponentStack, ExtendedExceptionData } from './parseLogBoxLog';\n\nexport type LogBoxLogs = Set<LogBoxLog>;\n\nexport type LogData = {\n level: LogLevel;\n message: Message;\n category: Category;\n componentStack: ComponentStack;\n};\n\ntype ExtendedError = any;\n\nexport type Observer = (options: {\n logs: LogBoxLogs;\n isDisabled: boolean;\n selectedLogIndex: number;\n}) => void;\n\nexport type IgnorePattern = string | RegExp;\n\nexport type Subscription = {\n unsubscribe: () => void;\n};\n\nexport type WarningInfo = {\n finalFormat: string;\n forceDialogImmediately: boolean;\n suppressDialog_LEGACY: boolean;\n suppressCompletely: boolean;\n monitorEvent: string | null;\n monitorListVersion: number;\n monitorSampleRate: number;\n};\n\nexport type WarningFilter = (format: string) => WarningInfo;\n\ntype Props = object;\n\ntype State = {\n logs: LogBoxLogs;\n isDisabled: boolean;\n hasError: boolean;\n selectedLogIndex: number;\n};\n\nconst observers: Set<{ observer: Observer } & any> = new Set();\nconst ignorePatterns: Set<IgnorePattern> = new Set();\nlet logs: LogBoxLogs = new Set();\nlet updateTimeout: null | ReturnType<typeof setImmediate> | ReturnType<typeof setTimeout> = null;\nlet _isDisabled = false;\nlet _selectedIndex = -1;\n\nconst LOGBOX_ERROR_MESSAGE =\n 'An error was thrown when attempting to render log messages via LogBox.';\n\nfunction getNextState() {\n return {\n logs,\n isDisabled: _isDisabled,\n selectedLogIndex: _selectedIndex,\n };\n}\n\nexport function reportLogBoxError(error: ExtendedError, componentStack?: string): void {\n const ExceptionsManager = require('../modules/ExceptionsManager').default;\n\n if (componentStack != null) {\n error.componentStack = componentStack;\n }\n ExceptionsManager.handleException(error);\n}\n\nexport function reportUnexpectedLogBoxError(error: ExtendedError, componentStack?: string): void {\n error.message = `${LOGBOX_ERROR_MESSAGE}\\n\\n${error.message}`;\n return reportLogBoxError(error, componentStack);\n}\n\nexport function isLogBoxErrorMessage(message: string): boolean {\n return typeof message === 'string' && message.includes(LOGBOX_ERROR_MESSAGE);\n}\n\nexport function isMessageIgnored(message: string): boolean {\n for (const pattern of ignorePatterns) {\n if (\n (pattern instanceof RegExp && pattern.test(message)) ||\n (typeof pattern === 'string' && message.includes(pattern))\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction setImmediateShim(callback: () => void) {\n if (!global.setImmediate) {\n return setTimeout(callback, 0);\n }\n return global.setImmediate(callback);\n}\n\nfunction handleUpdate(): void {\n if (updateTimeout == null) {\n updateTimeout = setImmediateShim(() => {\n updateTimeout = null;\n const nextState = getNextState();\n observers.forEach(({ observer }) => observer(nextState));\n });\n }\n}\n\nfunction appendNewLog(newLog: LogBoxLog): void {\n // Don't want store these logs because they trigger a\n // state update when we add them to the store.\n if (isMessageIgnored(newLog.message.content)) {\n return;\n }\n\n // If the next log has the same category as the previous one\n // then roll it up into the last log in the list by incrementing\n // the count (similar to how Chrome does it).\n const lastLog = Array.from(logs).pop();\n if (lastLog && lastLog.category === newLog.category) {\n lastLog.incrementCount();\n handleUpdate();\n return;\n }\n\n if (newLog.level === 'fatal') {\n // If possible, to avoid jank, we don't want to open the error before\n // it's symbolicated. To do that, we optimistically wait for\n // symbolication for up to a second before adding the log.\n const OPTIMISTIC_WAIT_TIME = 1000;\n\n let addPendingLog: null | (() => void) = () => {\n logs.add(newLog);\n if (_selectedIndex < 0) {\n setSelectedLog(logs.size - 1);\n } else {\n handleUpdate();\n }\n addPendingLog = null;\n };\n\n const optimisticTimeout = setTimeout(() => {\n if (addPendingLog) {\n addPendingLog();\n }\n }, OPTIMISTIC_WAIT_TIME);\n\n // TODO: HANDLE THIS\n newLog.symbolicate('component');\n\n newLog.symbolicate('stack', (status) => {\n if (addPendingLog && status !== 'PENDING') {\n addPendingLog();\n clearTimeout(optimisticTimeout);\n } else if (status !== 'PENDING') {\n // The log has already been added but we need to trigger a render.\n handleUpdate();\n }\n });\n } else if (newLog.level === 'syntax') {\n logs.add(newLog);\n setSelectedLog(logs.size - 1);\n } else {\n logs.add(newLog);\n handleUpdate();\n }\n}\n\nexport function addLog(log: LogData): void {\n const errorForStackTrace = new Error();\n\n // Parsing logs are expensive so we schedule this\n // otherwise spammy logs would pause rendering.\n setImmediate(() => {\n try {\n const stack = parseErrorStack(errorForStackTrace?.stack);\n\n appendNewLog(\n new LogBoxLog({\n level: log.level,\n message: log.message,\n isComponentError: false,\n stack,\n category: log.category,\n componentStack: log.componentStack,\n })\n );\n } catch (error) {\n reportUnexpectedLogBoxError(error);\n }\n });\n}\n\nexport function addException(error: ExtendedExceptionData): void {\n // Parsing logs are expensive so we schedule this\n // otherwise spammy logs would pause rendering.\n setImmediate(() => {\n try {\n appendNewLog(new LogBoxLog(parseLogBoxException(error)));\n } catch (loggingError) {\n reportUnexpectedLogBoxError(loggingError);\n }\n });\n}\n\nexport function symbolicateLogNow(type: StackType, log: LogBoxLog) {\n log.symbolicate(type, () => {\n handleUpdate();\n });\n}\n\nexport function retrySymbolicateLogNow(type: StackType, log: LogBoxLog) {\n log.retrySymbolicate(type, () => {\n handleUpdate();\n });\n}\n\nexport function symbolicateLogLazy(type: StackType, log: LogBoxLog) {\n log.symbolicate(type);\n}\n\nexport function clear(): void {\n if (logs.size > 0) {\n logs = new Set();\n setSelectedLog(-1);\n }\n}\n\nexport function setSelectedLog(proposedNewIndex: number): void {\n const oldIndex = _selectedIndex;\n let newIndex = proposedNewIndex;\n\n const logArray = Array.from(logs);\n let index = logArray.length - 1;\n while (index >= 0) {\n // The latest syntax error is selected and displayed before all other logs.\n if (logArray[index].level === 'syntax') {\n newIndex = index;\n break;\n }\n index -= 1;\n }\n _selectedIndex = newIndex;\n handleUpdate();\n if (NativeLogBox) {\n setTimeout(() => {\n if (oldIndex < 0 && newIndex >= 0) {\n NativeLogBox.show();\n } else if (oldIndex >= 0 && newIndex < 0) {\n NativeLogBox.hide();\n }\n }, 0);\n }\n}\n\nexport function clearWarnings(): void {\n const newLogs = Array.from(logs).filter((log) => log.level !== 'warn');\n if (newLogs.length !== logs.size) {\n logs = new Set(newLogs);\n setSelectedLog(-1);\n handleUpdate();\n }\n}\n\nexport function clearErrors(): void {\n const newLogs = Array.from(logs).filter((log) => log.level !== 'error' && log.level !== 'fatal');\n if (newLogs.length !== logs.size) {\n logs = new Set(newLogs);\n setSelectedLog(-1);\n }\n}\n\nexport function dismiss(log: LogBoxLog): void {\n if (logs.has(log)) {\n logs.delete(log);\n handleUpdate();\n }\n}\n\nexport function getIgnorePatterns(): IgnorePattern[] {\n return Array.from(ignorePatterns);\n}\n\nexport function addIgnorePatterns(patterns: IgnorePattern[]): void {\n const existingSize = ignorePatterns.size;\n // The same pattern may be added multiple times, but adding a new pattern\n // can be expensive so let's find only the ones that are new.\n patterns.forEach((pattern: IgnorePattern) => {\n if (pattern instanceof RegExp) {\n for (const existingPattern of ignorePatterns) {\n if (\n existingPattern instanceof RegExp &&\n existingPattern.toString() === pattern.toString()\n ) {\n return;\n }\n }\n ignorePatterns.add(pattern);\n }\n ignorePatterns.add(pattern);\n });\n if (ignorePatterns.size === existingSize) {\n return;\n }\n // We need to recheck all of the existing logs.\n // This allows adding an ignore pattern anywhere in the codebase.\n // Without this, if you ignore a pattern after the a log is created,\n // then we would keep showing the log.\n logs = new Set(Array.from(logs).filter((log) => !isMessageIgnored(log.message.content)));\n handleUpdate();\n}\n\nexport function setDisabled(value: boolean): void {\n if (value === _isDisabled) {\n return;\n }\n _isDisabled = value;\n handleUpdate();\n}\n\nexport function isDisabled(): boolean {\n return _isDisabled;\n}\n\nexport function observe(observer: Observer): Subscription {\n const subscription = { observer };\n observers.add(subscription);\n\n observer(getNextState());\n\n return {\n unsubscribe(): void {\n observers.delete(subscription);\n },\n };\n}\n\nexport function withSubscription(WrappedComponent: React.FC<object>): React.Component<object> {\n class LogBoxStateSubscription extends React.Component<React.PropsWithChildren<Props>, State> {\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n componentDidCatch(err: Error, errorInfo: { componentStack: string } & any) {\n /* $FlowFixMe[class-object-subtyping] added when improving typing for\n * this parameters */\n reportLogBoxError(err, errorInfo.componentStack);\n }\n\n _subscription?: Subscription;\n\n state = {\n logs: new Set<LogBoxLog>(),\n isDisabled: false,\n hasError: false,\n selectedLogIndex: -1,\n };\n\n render() {\n if (this.state.hasError) {\n // This happens when the component failed to render, in which case we delegate to the native redbox.\n // We can't show any fallback UI here, because the error may be with <View> or <Text>.\n return null;\n }\n\n return (\n <LogContext.Provider\n value={{\n selectedLogIndex: this.state.selectedLogIndex,\n isDisabled: this.state.isDisabled,\n logs: Array.from(this.state.logs),\n }}>\n {this.props.children}\n <WrappedComponent />\n </LogContext.Provider>\n );\n }\n\n componentDidMount(): void {\n this._subscription = observe((data) => {\n this.setState(data);\n });\n }\n\n componentWillUnmount(): void {\n if (this._subscription != null) {\n this._subscription.unsubscribe();\n }\n }\n\n _handleDismiss = (): void => {\n // Here we handle the cases when the log is dismissed and it\n // was either the last log, or when the current index\n // is now outside the bounds of the log array.\n const { selectedLogIndex, logs: stateLogs } = this.state;\n const logsArray = Array.from(stateLogs);\n if (selectedLogIndex != null) {\n if (logsArray.length - 1 <= 0) {\n setSelectedLog(-1);\n } else if (selectedLogIndex >= logsArray.length - 1) {\n setSelectedLog(selectedLogIndex - 1);\n }\n\n dismiss(logsArray[selectedLogIndex]);\n }\n };\n\n _handleMinimize = (): void => {\n setSelectedLog(-1);\n };\n\n _handleSetSelectedLog = (index: number): void => {\n setSelectedLog(index);\n };\n }\n\n // @ts-expect-error\n return LogBoxStateSubscription;\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 650 Industries.
|
|
3
3
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import type { Stack } from
|
|
9
|
-
import type { Category, Message, ComponentStack, CodeFrame } from
|
|
10
|
-
type SymbolicationStatus =
|
|
11
|
-
export type LogLevel =
|
|
8
|
+
import type { Stack } from './LogBoxSymbolication';
|
|
9
|
+
import type { Category, Message, ComponentStack, CodeFrame } from './parseLogBoxLog';
|
|
10
|
+
type SymbolicationStatus = 'NONE' | 'PENDING' | 'COMPLETE' | 'FAILED';
|
|
11
|
+
export type LogLevel = 'warn' | 'error' | 'fatal' | 'syntax' | 'static';
|
|
12
12
|
export type LogBoxLogData = {
|
|
13
13
|
level: LogLevel;
|
|
14
14
|
type?: string;
|
|
@@ -19,23 +19,23 @@ export type LogBoxLogData = {
|
|
|
19
19
|
codeFrame?: CodeFrame;
|
|
20
20
|
isComponentError: boolean;
|
|
21
21
|
};
|
|
22
|
-
export type StackType =
|
|
22
|
+
export type StackType = 'stack' | 'component';
|
|
23
23
|
type SymbolicationResult = {
|
|
24
24
|
error: null;
|
|
25
25
|
stack: null;
|
|
26
|
-
status:
|
|
26
|
+
status: 'NONE';
|
|
27
27
|
} | {
|
|
28
28
|
error: null;
|
|
29
29
|
stack: null;
|
|
30
|
-
status:
|
|
30
|
+
status: 'PENDING';
|
|
31
31
|
} | {
|
|
32
32
|
error: null;
|
|
33
33
|
stack: Stack;
|
|
34
|
-
status:
|
|
34
|
+
status: 'COMPLETE';
|
|
35
35
|
} | {
|
|
36
36
|
error: Error;
|
|
37
37
|
stack: null;
|
|
38
|
-
status:
|
|
38
|
+
status: 'FAILED';
|
|
39
39
|
};
|
|
40
40
|
export declare class LogBoxLog {
|
|
41
41
|
message: Message;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxLog.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxLog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"LogBoxLog.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxLog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAErF,KAAK,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd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