@expo/metro-runtime 2.1.0 → 2.1.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/async-require/loadBundlePolyfill.js +2 -2
- package/build/async-require/loadBundlePolyfill.js.map +1 -1
- package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
- package/build/error-overlay/Data/LogBoxData.js +2 -2
- package/build/error-overlay/Data/LogBoxData.js.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +3 -3
- 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 +1 -1
- package/build/error-overlay/toast/ErrorToast.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.js +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -1
- package/build/location/install.native.js +2 -2
- package/build/location/install.native.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,10 +11,10 @@ exports.loadBundleAsync = void 0;
|
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
13
|
const react_native_1 = require("react-native");
|
|
14
|
-
const buildUrlForBundle_1 = require("./buildUrlForBundle");
|
|
15
|
-
const fetchThenEval_1 = require("./fetchThenEval");
|
|
16
14
|
const HMRClient_1 = __importDefault(require("../HMRClient"));
|
|
17
15
|
const LoadingView_1 = __importDefault(require("../LoadingView"));
|
|
16
|
+
const buildUrlForBundle_1 = require("./buildUrlForBundle");
|
|
17
|
+
const fetchThenEval_1 = require("./fetchThenEval");
|
|
18
18
|
let pendingRequests = 0;
|
|
19
19
|
/**
|
|
20
20
|
* Load a bundle for a URL using fetch + eval on native and script tag injection on web.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadBundlePolyfill.js","sourceRoot":"","sources":["../../src/async-require/loadBundlePolyfill.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,+CAAwC;AAExC,
|
|
1
|
+
{"version":3,"file":"loadBundlePolyfill.js","sourceRoot":"","sources":["../../src/async-require/loadBundlePolyfill.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,+CAAwC;AAExC,6DAAqC;AACrC,iEAAyC;AACzC,2DAAwD;AACxD,mDAAqD;AAErD,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;;;GAIG;AACH,SAAgB,eAAe,CAAC,UAAkB;IAChD,MAAM,UAAU,GAAG,IAAA,qCAAiB,EAAC,UAAU,EAAE;QAC/C,WAAW,EAAE,MAAM;QACnB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,uBAAQ,CAAC,EAAE;QACrB,mDAAmD;QACnD,sBAAsB,EAAE,IAAI;KAC7B,CAAC,CAAC;IAEH,qEAAqE;IACrE,qBAAW,CAAC,WAAW,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAClD,eAAe,EAAE,CAAC;IAElB,OAAO,IAAA,kCAAkB,EAAC,UAAU,CAAC;SAClC,IAAI,CAAC,GAAG,EAAE;QACT,mBAAS,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACZ,IAAI,CAAC,EAAE,eAAe,EAAE;YACtB,qBAAW,CAAC,IAAI,EAAE,CAAC;SACpB;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAtBD,0CAsBC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\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 */\nimport { Platform } from \"react-native\";\n\nimport HMRClient from \"../HMRClient\";\nimport LoadingView from \"../LoadingView\";\nimport { buildUrlForBundle } from \"./buildUrlForBundle\";\nimport { fetchThenEvalAsync } from \"./fetchThenEval\";\n\nlet pendingRequests = 0;\n\n/**\n * Load a bundle for a URL using fetch + eval on native and script tag injection on web.\n *\n * @param bundlePath Given a statement like `import('./Bacon')` `bundlePath` would be `Bacon`.\n */\nexport function loadBundleAsync(bundlePath: string): Promise<void> {\n const requestUrl = buildUrlForBundle(bundlePath, {\n modulesOnly: \"true\",\n runModule: \"false\",\n platform: Platform.OS,\n // The JavaScript loader does not support bytecode.\n runtimeBytecodeVersion: null,\n });\n\n // Send a signal to the `expo` package to show the loading indicator.\n LoadingView.showMessage(\"Downloading...\", \"load\");\n pendingRequests++;\n\n return fetchThenEvalAsync(requestUrl)\n .then(() => {\n HMRClient.registerBundle(requestUrl);\n })\n .finally(() => {\n if (!--pendingRequests) {\n LoadingView.hide();\n }\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxData.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxData.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LogBoxData.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxData.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EACV,OAAO,EACP,QAAQ,EACR,cAAc,EACd,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAE1B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UzD;AA+ED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAuBzC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAU/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,QAIhE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,QAIrE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,QAEjE;AAED,wBAAgB,KAAK,IAAI,IAAI,CAK5B;AAED,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAyB7D;AAED,wBAAgB,aAAa,IAAI,IAAI,CAOpC;AAED,wBAAgB,WAAW,IAAI,IAAI,CAQlC;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAK5C;AAED,wBAAgB,iBAAiB,IAAI,aAAa,EAAE,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,CA6BjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAMhD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAWxD;AAED,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAqFzB"}
|
|
@@ -35,11 +35,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
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
37
|
const React = __importStar(require("react"));
|
|
38
|
+
const NativeLogBox_1 = __importDefault(require("../modules/NativeLogBox"));
|
|
39
|
+
const parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
|
|
38
40
|
const LogBoxLog_1 = require("./LogBoxLog");
|
|
39
41
|
const LogContext_1 = require("./LogContext");
|
|
40
42
|
const parseLogBoxLog_1 = require("./parseLogBoxLog");
|
|
41
|
-
const NativeLogBox_1 = __importDefault(require("../modules/NativeLogBox"));
|
|
42
|
-
const parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
|
|
43
43
|
const observers = new Set();
|
|
44
44
|
const ignorePatterns = new Set();
|
|
45
45
|
let logs = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxData.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxData.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,2CAAmD;AAEnD,6CAA0C;AAC1C,qDAAwD;AAOxD,2EAAmD;AACnD,iFAAyD;AA8CzD,MAAM,SAAS,GAAsC,IAAI,GAAG,EAAE,CAAC;AAC/D,MAAM,cAAc,GAAuB,IAAI,GAAG,EAAE,CAAC;AACrD,IAAI,IAAI,GAAe,IAAI,GAAG,EAAE,CAAC;AACjC,IAAI,aAAa,GAGmB,IAAI,CAAC;AACzC,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC;AAExB,MAAM,oBAAoB,GACxB,wEAAwE,CAAC;AAE3E,SAAS,YAAY;IACnB,OAAO;QACL,IAAI;QACJ,UAAU,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AC,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 { 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\";\nimport NativeLogBox from \"../modules/NativeLogBox\";\nimport parseErrorStack from \"../modules/parseErrorStack\";\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,6CAA+B;AAE/B,2EAAmD;AACnD,iFAAyD;AACzD,2CAAmD;AAEnD,6CAA0C;AAC1C,qDAAwD;AAoDxD,MAAM,SAAS,GAAsC,IAAI,GAAG,EAAE,CAAC;AAC/D,MAAM,cAAc,GAAuB,IAAI,GAAG,EAAE,CAAC;AACrD,IAAI,IAAI,GAAe,IAAI,GAAG,EAAE,CAAC;AACjC,IAAI,aAAa,GAGmB,IAAI,CAAC;AACzC,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC;AAExB,MAAM,oBAAoB,GACxB,wEAAwE,CAAC;AAE3E,SAAS,YAAY;IACnB,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,WAAW;QACvB,gBAAgB,EAAE,cAAc;KACjC,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAC/B,KAAoB,EACpB,cAAuB;IAEvB,MAAM,iBAAiB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAElE,IAAI,cAAc,IAAI,IAAI,EAAE;QAC1B,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;KACvC;IACD,iBAAiB,CAAC,eAAe,CAAC,KAAK,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\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 +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;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,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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;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;AAhDD,wCAgDC","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\n// @ts-expect-error\nimport UTFSequence from \"react-native/Libraries/UTFSequence\";\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 = 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 (\n isOldComponentStackFormat ||\n isNewComponentStackFormat ||\n isNewJSCComponentStackFormat\n );\n}\n\nexport function parseComponentStack(message: string): ComponentStack {\n // In newer versions of React, the component stack is formatted as a call stack frame.\n // First try to parse the component stack as a call stack frame, and if that doesn't\n // work then we'll fallback to the old custom component stack format parsing.\n const stack = parseErrorStack(message);\n if (stack && stack.length > 0) {\n return stack.map((frame) => ({\n content: frame.methodName,\n collapse: frame.collapse || false,\n fileName: frame.file == null ? \"unknown\" : frame.file,\n location: {\n column: frame.column == null ? -1 : frame.column,\n row: frame.lineNumber == null ? -1 : frame.lineNumber,\n },\n }));\n }\n\n return message\n .split(/\\n {4}in /g)\n .map((s) => {\n if (!s) {\n return null;\n }\n const match = s.match(/(.*) \\(at (.*\\.js):([\\d]+)\\)/);\n if (!match) {\n return null;\n }\n\n const [content, fileName, row] = match.slice(1);\n return {\n content,\n fileName,\n location: { column: -1, row: parseInt(row, 10) },\n };\n })\n .filter(Boolean) as ComponentStack;\n}\n\nexport function parseLogBoxException(\n error: ExtendedExceptionData\n): LogBoxLogData {\n const message =\n error.originalMessage != null ? error.originalMessage : \"Unknown\";\n\n const metroInternalError = message.match(METRO_ERROR_FORMAT);\n if (metroInternalError) {\n const [content, fileName, row, column, codeFrame] =\n metroInternalError.slice(1);\n\n return {\n level: \"fatal\",\n type: \"Metro Error\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelTransformError = message.match(BABEL_TRANSFORM_ERROR_FORMAT);\n if (babelTransformError) {\n // Transform errors are thrown from inside the Babel transformer.\n const [fileName, content, row, column, codeFrame] =\n babelTransformError.slice(1);\n\n return {\n level: \"syntax\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelCodeFrameError = message.match(BABEL_CODE_FRAME_ERROR_FORMAT);\n\n if (babelCodeFrameError) {\n // Codeframe errors are thrown from any use of buildCodeFrameError.\n const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);\n return {\n level: \"syntax\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: null, // We are not given the location.\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${1}-${1}`,\n };\n }\n\n if (message.match(/^TransformError /)) {\n return {\n level: \"syntax\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: [],\n message: {\n content: message,\n substitutions: [],\n },\n category: message,\n };\n }\n\n const componentStack = error.componentStack;\n if (error.isFatal || error.isComponentError) {\n return {\n level: \"fatal\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack:\n componentStack != null ? parseComponentStack(componentStack) : [],\n ...parseInterpolation([message]),\n };\n }\n\n if (componentStack != null) {\n // It is possible that console errors have a componentStack.\n return {\n level: \"error\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: parseComponentStack(componentStack),\n ...parseInterpolation([message]),\n };\n }\n\n // Most `console.error` calls won't have a componentStack. We parse them like\n // regular logs which have the component stack burried in the message.\n return {\n level: \"error\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n ...parseLogBoxLog([message]),\n };\n}\n\nexport function parseLogBoxLog(args: readonly any[]): {\n componentStack: ComponentStack;\n category: Category;\n message: Message;\n} {\n const message = args[0];\n let argsWithoutComponentStack: any[] = [];\n let componentStack: ComponentStack = [];\n\n // Extract component stack from warnings like \"Some warning%s\".\n if (\n typeof message === \"string\" &&\n message.slice(-2) === \"%s\" &&\n args.length > 0\n ) {\n const lastArg = args[args.length - 1];\n if (typeof lastArg === \"string\" && isComponentStack(lastArg)) {\n argsWithoutComponentStack = args.slice(0, -1);\n argsWithoutComponentStack[0] = message.slice(0, -2);\n componentStack = parseComponentStack(lastArg);\n }\n }\n\n if (componentStack.length === 0) {\n // Try finding the component stack elsewhere.\n for (const arg of args) {\n if (typeof arg === \"string\" && isComponentStack(arg)) {\n // Strip out any messages before the component stack.\n let messageEndIndex = arg.search(/\\n {4}(in|at) /);\n if (messageEndIndex < 0) {\n // Handle JSC component stacks.\n messageEndIndex = arg.search(/\\n/);\n }\n if (messageEndIndex > 0) {\n argsWithoutComponentStack.push(arg.slice(0, messageEndIndex));\n }\n\n componentStack = parseComponentStack(arg);\n } else {\n argsWithoutComponentStack.push(arg);\n }\n }\n }\n\n 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;;;;;;AAEH,mBAAmB;AACnB,qFAA6D;AAE7D,iFAAyD;AACzD,6EAAqD;AAIrD,MAAM,4BAA4B,GAChC,gGAAgG,CAAC;AACnG,MAAM,6BAA6B,GACjC,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M;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;AAhDD,wCAgDC","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\n// @ts-expect-error\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 (\n isOldComponentStackFormat ||\n isNewComponentStackFormat ||\n isNewJSCComponentStackFormat\n );\n}\n\nexport function parseComponentStack(message: string): ComponentStack {\n // In newer versions of React, the component stack is formatted as a call stack frame.\n // First try to parse the component stack as a call stack frame, and if that doesn't\n // work then we'll fallback to the old custom component stack format parsing.\n const stack = parseErrorStack(message);\n if (stack && stack.length > 0) {\n return stack.map((frame) => ({\n content: frame.methodName,\n collapse: frame.collapse || false,\n fileName: frame.file == null ? \"unknown\" : frame.file,\n location: {\n column: frame.column == null ? -1 : frame.column,\n row: frame.lineNumber == null ? -1 : frame.lineNumber,\n },\n }));\n }\n\n return message\n .split(/\\n {4}in /g)\n .map((s) => {\n if (!s) {\n return null;\n }\n const match = s.match(/(.*) \\(at (.*\\.js):([\\d]+)\\)/);\n if (!match) {\n return null;\n }\n\n const [content, fileName, row] = match.slice(1);\n return {\n content,\n fileName,\n location: { column: -1, row: parseInt(row, 10) },\n };\n })\n .filter(Boolean) as ComponentStack;\n}\n\nexport function parseLogBoxException(\n error: ExtendedExceptionData\n): LogBoxLogData {\n const message =\n error.originalMessage != null ? error.originalMessage : \"Unknown\";\n\n const metroInternalError = message.match(METRO_ERROR_FORMAT);\n if (metroInternalError) {\n const [content, fileName, row, column, codeFrame] =\n metroInternalError.slice(1);\n\n return {\n level: \"fatal\",\n type: \"Metro Error\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelTransformError = message.match(BABEL_TRANSFORM_ERROR_FORMAT);\n if (babelTransformError) {\n // Transform errors are thrown from inside the Babel transformer.\n const [fileName, content, row, column, codeFrame] =\n babelTransformError.slice(1);\n\n return {\n level: \"syntax\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelCodeFrameError = message.match(BABEL_CODE_FRAME_ERROR_FORMAT);\n\n if (babelCodeFrameError) {\n // Codeframe errors are thrown from any use of buildCodeFrameError.\n const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);\n return {\n level: \"syntax\",\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: null, // We are not given the location.\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${1}-${1}`,\n };\n }\n\n if (message.match(/^TransformError /)) {\n return {\n level: \"syntax\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: [],\n message: {\n content: message,\n substitutions: [],\n },\n category: message,\n };\n }\n\n const componentStack = error.componentStack;\n if (error.isFatal || error.isComponentError) {\n return {\n level: \"fatal\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack:\n componentStack != null ? parseComponentStack(componentStack) : [],\n ...parseInterpolation([message]),\n };\n }\n\n if (componentStack != null) {\n // It is possible that console errors have a componentStack.\n return {\n level: \"error\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: parseComponentStack(componentStack),\n ...parseInterpolation([message]),\n };\n }\n\n // Most `console.error` calls won't have a componentStack. We parse them like\n // regular logs which have the component stack burried in the message.\n return {\n level: \"error\",\n stack: error.stack,\n isComponentError: error.isComponentError,\n ...parseLogBoxLog([message]),\n };\n}\n\nexport function parseLogBoxLog(args: readonly any[]): {\n componentStack: ComponentStack;\n category: Category;\n message: Message;\n} {\n const message = args[0];\n let argsWithoutComponentStack: any[] = [];\n let componentStack: ComponentStack = [];\n\n // Extract component stack from warnings like \"Some warning%s\".\n if (\n typeof message === \"string\" &&\n message.slice(-2) === \"%s\" &&\n args.length > 0\n ) {\n const lastArg = args[args.length - 1];\n if (typeof lastArg === \"string\" && isComponentStack(lastArg)) {\n argsWithoutComponentStack = args.slice(0, -1);\n argsWithoutComponentStack[0] = message.slice(0, -2);\n componentStack = parseComponentStack(lastArg);\n }\n }\n\n if (componentStack.length === 0) {\n // Try finding the component stack elsewhere.\n for (const arg of args) {\n if (typeof arg === \"string\" && isComponentStack(arg)) {\n // Strip out any messages before the component stack.\n let messageEndIndex = arg.search(/\\n {4}(in|at) /);\n if (messageEndIndex < 0) {\n // Handle JSC component stacks.\n messageEndIndex = arg.search(/\\n/);\n }\n if (messageEndIndex > 0) {\n argsWithoutComponentStack.push(arg.slice(0, messageEndIndex));\n }\n\n componentStack = parseComponentStack(arg);\n } else {\n argsWithoutComponentStack.push(arg);\n }\n }\n }\n\n return {\n ...parseInterpolation(argsWithoutComponentStack),\n componentStack,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxInspectorCodeFrame.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorCodeFrame.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LogBoxInspectorCodeFrame.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorCodeFrame.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAWxD,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,GACV,EAAE;IACD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,sBAiDA"}
|
|
@@ -36,13 +36,13 @@ exports.LogBoxInspectorCodeFrame = void 0;
|
|
|
36
36
|
*/
|
|
37
37
|
const react_1 = __importDefault(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
|
-
const LogBoxInspectorSection_1 = require("./LogBoxInspectorSection");
|
|
40
39
|
const AnsiHighlight_1 = require("../UI/AnsiHighlight");
|
|
41
40
|
const LogBoxButton_1 = require("../UI/LogBoxButton");
|
|
42
41
|
const LogBoxStyle = __importStar(require("../UI/LogBoxStyle"));
|
|
43
42
|
const constants_1 = require("../UI/constants");
|
|
44
43
|
const formatProjectFilePath_1 = require("../formatProjectFilePath");
|
|
45
44
|
const openFileInEditor_1 = __importDefault(require("../modules/openFileInEditor"));
|
|
45
|
+
const LogBoxInspectorSection_1 = require("./LogBoxInspectorSection");
|
|
46
46
|
function LogBoxInspectorCodeFrame({ codeFrame, }) {
|
|
47
47
|
if (codeFrame == null) {
|
|
48
48
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxInspectorCodeFrame.js","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorCodeFrame.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,kDAA0B;AAC1B,+CAAkE;
|
|
1
|
+
{"version":3,"file":"LogBoxInspectorCodeFrame.js","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorCodeFrame.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,kDAA0B;AAC1B,+CAAkE;AAGlE,uDAA2C;AAC3C,qDAAkD;AAClD,+DAAiD;AACjD,+CAA4C;AAC5C,oEAAiE;AACjE,mFAA2D;AAC3D,qEAAkE;AAIlE,SAAgB,wBAAwB,CAAC,EACvC,SAAS,GAGV;IACC,IAAI,SAAS,IAAI,IAAI,EAAE;QACrB,OAAO,IAAI,CAAC;KACb;IAED,SAAS,WAAW;QAClB,OAAO,IAAA,6CAAqB,EAC1B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAC7B,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CACpB,CAAC;IACJ,CAAC;IAED,SAAS,WAAW;QAClB,MAAM,QAAQ,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC;QACrC,IAAI,QAAQ,IAAI,IAAI,EAAE;YACpB,OAAO,KAAK,QAAQ,CAAC,GAAG,IACtB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,yCACtB,GAAG,CAAC;SACL;QAED,OAAO,IAAI,CAAC;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AAE;QACN,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,EAAE;KAClB;IACD,OAAO,EAAE;QACP,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,EAAE;QACZ,kBAAkB,EAAE,KAAK;QACzB,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,qBAAS;KACtB;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC;QACpC,SAAS,EAAE,QAAQ;QACnB,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,EAAE;QACZ,kBAAkB,EAAE,KAAK;QACzB,UAAU,EAAE,qBAAS;KACtB;CACF,CAAC,CAAC","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 */\nimport React from \"react\";\nimport { ScrollView, StyleSheet, Text, View } from \"react-native\";\n\nimport type { CodeFrame } from \"../Data/parseLogBoxLog\";\nimport { Ansi } from \"../UI/AnsiHighlight\";\nimport { LogBoxButton } from \"../UI/LogBoxButton\";\nimport * as LogBoxStyle from \"../UI/LogBoxStyle\";\nimport { CODE_FONT } from \"../UI/constants\";\nimport { formatProjectFilePath } from \"../formatProjectFilePath\";\nimport openFileInEditor from \"../modules/openFileInEditor\";\nimport { LogBoxInspectorSection } from \"./LogBoxInspectorSection\";\n\ndeclare const process: any;\n\nexport function LogBoxInspectorCodeFrame({\n codeFrame,\n}: {\n codeFrame?: CodeFrame;\n}) {\n if (codeFrame == null) {\n return null;\n }\n\n function getFileName() {\n return formatProjectFilePath(\n process.env.EXPO_PROJECT_ROOT,\n codeFrame?.fileName\n );\n }\n\n function getLocation() {\n const location = codeFrame?.location;\n if (location != null) {\n return ` (${location.row}:${\n location.column + 1 /* Code frame columns are zero indexed */\n })`;\n }\n\n return null;\n }\n\n return (\n <LogBoxInspectorSection heading=\"Source\">\n <View style={styles.box}>\n <View style={styles.frame}>\n <ScrollView horizontal>\n <Ansi style={styles.content} text={codeFrame.content} />\n </ScrollView>\n </View>\n <LogBoxButton\n backgroundColor={{\n default: \"transparent\",\n pressed: LogBoxStyle.getBackgroundDarkColor(1),\n }}\n style={styles.button}\n onPress={() => {\n openFileInEditor(codeFrame.fileName, codeFrame.location?.row ?? 0);\n }}\n >\n <Text selectable={false} style={styles.fileText}>\n {getFileName()}\n {getLocation()}\n </Text>\n </LogBoxButton>\n </View>\n </LogBoxInspectorSection>\n );\n}\n\nconst styles = StyleSheet.create({\n box: {\n backgroundColor: LogBoxStyle.getBackgroundColor(),\n borderWidth: 1,\n borderColor: \"#323232\",\n marginLeft: 10,\n marginRight: 10,\n marginTop: 5,\n borderRadius: 3,\n },\n frame: {\n padding: 10,\n borderBottomColor: LogBoxStyle.getTextColor(0.1),\n borderBottomWidth: 1,\n },\n button: {\n paddingTop: 10,\n paddingBottom: 10,\n },\n content: {\n color: LogBoxStyle.getTextColor(1),\n fontSize: 12,\n includeFontPadding: false,\n lineHeight: 20,\n fontFamily: CODE_FONT,\n },\n fileText: {\n color: LogBoxStyle.getTextColor(0.5),\n textAlign: \"center\",\n flex: 1,\n fontSize: 16,\n includeFontPadding: false,\n fontFamily: CODE_FONT,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxInspectorStackFrames.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorStackFrames.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LogBoxInspectorStackFrames.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorStackFrames.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AASzD,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,KAAK,EAClB,SAAS,EAAE,OAAO,GACjB,MAAM,CA+BR;AAED,wBAAgB,0BAA0B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,sBAgDlE"}
|
|
@@ -36,13 +36,13 @@ exports.LogBoxInspectorStackFrames = exports.getCollapseMessage = void 0;
|
|
|
36
36
|
*/
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
|
-
const LogBoxInspectorSection_1 = require("./LogBoxInspectorSection");
|
|
40
|
-
const LogBoxInspectorSourceMapStatus_1 = require("./LogBoxInspectorSourceMapStatus");
|
|
41
|
-
const LogBoxInspectorStackFrame_1 = require("./LogBoxInspectorStackFrame");
|
|
42
39
|
const LogContext_1 = require("../Data/LogContext");
|
|
43
40
|
const LogBoxButton_1 = require("../UI/LogBoxButton");
|
|
44
41
|
const LogBoxStyle = __importStar(require("../UI/LogBoxStyle"));
|
|
45
42
|
const openFileInEditor_1 = __importDefault(require("../modules/openFileInEditor"));
|
|
43
|
+
const LogBoxInspectorSection_1 = require("./LogBoxInspectorSection");
|
|
44
|
+
const LogBoxInspectorSourceMapStatus_1 = require("./LogBoxInspectorSourceMapStatus");
|
|
45
|
+
const LogBoxInspectorStackFrame_1 = require("./LogBoxInspectorStackFrame");
|
|
46
46
|
function getCollapseMessage(stackFrames, collapsed) {
|
|
47
47
|
if (stackFrames.length === 0) {
|
|
48
48
|
return "No frames to show";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogBoxInspectorStackFrames.js","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorStackFrames.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,+CAAwC;AACxC,+CAAsD;AAEtD,qEAAkE;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KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC;QACpC,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,CAAC;KACnB;CACF,CAAC,CAAC","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 */\nimport React, { useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { LogBoxInspectorSection } from \"./LogBoxInspectorSection\";\nimport { LogBoxInspectorSourceMapStatus } from \"./LogBoxInspectorSourceMapStatus\";\nimport { LogBoxInspectorStackFrame } from \"./LogBoxInspectorStackFrame\";\nimport type { StackType } from \"../Data/LogBoxLog\";\nimport type { Stack } from \"../Data/LogBoxSymbolication\";\nimport { useSelectedLog } from \"../Data/LogContext\";\nimport { LogBoxButton } from \"../UI/LogBoxButton\";\nimport * as LogBoxStyle from \"../UI/LogBoxStyle\";\nimport openFileInEditor from \"../modules/openFileInEditor\";\n\ntype Props = {\n type: StackType;\n onRetry: () => void;\n};\n\nexport function getCollapseMessage(\n stackFrames: Stack,\n collapsed: boolean\n): string {\n if (stackFrames.length === 0) {\n return \"No frames to show\";\n }\n\n const collapsedCount = stackFrames.reduce((count, { collapse }) => {\n if (collapse === true) {\n return count + 1;\n }\n\n return count;\n }, 0);\n\n if (collapsedCount === 0) {\n return \"Showing all frames\";\n }\n\n const framePlural = `frame${collapsedCount > 1 ? \"s\" : \"\"}`;\n if (collapsedCount === stackFrames.length) {\n return collapsed\n ? `See${\n collapsedCount > 1 ? \" all \" : \" \"\n }${collapsedCount} collapsed ${framePlural}`\n : `Collapse${\n collapsedCount > 1 ? \" all \" : \" \"\n }${collapsedCount} ${framePlural}`;\n } else {\n return collapsed\n ? `See ${collapsedCount} more ${framePlural}`\n : `Collapse ${collapsedCount} ${framePlural}`;\n }\n}\n\nexport function LogBoxInspectorStackFrames({ onRetry, type }: Props) {\n const log = useSelectedLog();\n\n const [collapsed, setCollapsed] = useState(() => {\n // Only collapse frames initially if some frames are not collapsed.\n return log.getAvailableStack(type)?.some(({ collapse }) => !collapse);\n });\n\n function getStackList() {\n if (collapsed === true) {\n return log.getAvailableStack(type)?.filter(({ collapse }) => !collapse);\n } else {\n return log.getAvailableStack(type);\n }\n }\n\n if (log.getAvailableStack(type)?.length === 0) {\n return null;\n }\n\n return (\n <LogBoxInspectorSection\n heading={type === \"component\" ? \"Component Stack\" : \"Call Stack\"}\n action={\n <LogBoxInspectorSourceMapStatus\n onPress={log.symbolicated[type].status === \"FAILED\" ? onRetry : null}\n status={log.symbolicated[type].status}\n />\n }\n >\n {log.symbolicated[type].status !== \"COMPLETE\" && (\n <View style={stackStyles.hintBox}>\n <Text style={stackStyles.hintText}>\n This call stack is not symbolicated. Some features are unavailable\n such as viewing the function name or tapping to open files.\n </Text>\n </View>\n )}\n <StackFrameList\n list={getStackList()!}\n status={log.symbolicated[type].status}\n />\n <StackFrameFooter\n onPress={() => setCollapsed(!collapsed)}\n message={getCollapseMessage(log.getAvailableStack(type)!, !!collapsed)}\n />\n </LogBoxInspectorSection>\n );\n}\n\nfunction StackFrameList({\n list,\n status,\n}: {\n list: Stack;\n status: \"NONE\" | \"PENDING\" | \"COMPLETE\" | \"FAILED\";\n}): any {\n return list.map((frame, index) => {\n const { file, lineNumber } = frame;\n return (\n <LogBoxInspectorStackFrame\n key={index}\n frame={frame}\n onPress={\n status === \"COMPLETE\" && file != null && lineNumber != null\n ? () => openFileInEditor(file, lineNumber)\n : undefined\n }\n />\n );\n });\n}\n\nfunction StackFrameFooter({\n message,\n onPress,\n}: {\n message: string;\n onPress: () => void;\n}) {\n return (\n <View style={stackStyles.collapseContainer}>\n <LogBoxButton\n backgroundColor={{\n default: \"transparent\",\n pressed: LogBoxStyle.getBackgroundColor(1),\n }}\n onPress={onPress}\n style={stackStyles.collapseButton}\n >\n <Text style={stackStyles.collapse}>{message}</Text>\n </LogBoxButton>\n </View>\n );\n}\n\nconst stackStyles = StyleSheet.create({\n section: {\n marginTop: 15,\n },\n heading: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 12,\n marginBottom: 10,\n },\n headingText: {\n color: LogBoxStyle.getTextColor(1),\n flex: 1,\n fontSize: 20,\n fontWeight: \"600\",\n includeFontPadding: false,\n lineHeight: 20,\n },\n body: {\n paddingBottom: 10,\n },\n bodyText: {\n color: LogBoxStyle.getTextColor(1),\n fontSize: 14,\n includeFontPadding: false,\n lineHeight: 18,\n fontWeight: \"500\",\n paddingHorizontal: 27,\n },\n hintText: {\n color: LogBoxStyle.getTextColor(0.7),\n fontSize: 13,\n includeFontPadding: false,\n lineHeight: 18,\n fontWeight: \"400\",\n marginHorizontal: 10,\n },\n hintBox: {\n backgroundColor: LogBoxStyle.getBackgroundColor(),\n marginHorizontal: 10,\n paddingHorizontal: 5,\n paddingVertical: 10,\n borderRadius: 5,\n marginBottom: 5,\n },\n collapseContainer: {\n marginLeft: 15,\n flexDirection: \"row\",\n },\n collapseButton: {\n borderRadius: 5,\n },\n collapse: {\n color: LogBoxStyle.getTextColor(0.7),\n fontSize: 12,\n fontWeight: \"300\",\n lineHeight: 20,\n marginTop: 0,\n paddingHorizontal: 10,\n paddingVertical: 5,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"LogBoxInspectorStackFrames.js","sourceRoot":"","sources":["../../../src/error-overlay/overlay/LogBoxInspectorStackFrames.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,+CAAwC;AACxC,+CAAsD;AAItD,mDAAoD;AACpD,qDAAkD;AAClD,+DAAiD;AACjD,mFAA2D;AAC3D,qEAAkE;AAClE,qFAAkF;AAClF,2EAAwE;AAOxE,SAAgB,kBAAkB,CAChC,WAAkB,EAClB,S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,EAAE,CAAC;QACZ,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,CAAC;KACnB;CACF,CAAC,CAAC","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 */\nimport React, { useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport type { StackType } from \"../Data/LogBoxLog\";\nimport type { Stack } from \"../Data/LogBoxSymbolication\";\nimport { useSelectedLog } from \"../Data/LogContext\";\nimport { LogBoxButton } from \"../UI/LogBoxButton\";\nimport * as LogBoxStyle from \"../UI/LogBoxStyle\";\nimport openFileInEditor from \"../modules/openFileInEditor\";\nimport { LogBoxInspectorSection } from \"./LogBoxInspectorSection\";\nimport { LogBoxInspectorSourceMapStatus } from \"./LogBoxInspectorSourceMapStatus\";\nimport { LogBoxInspectorStackFrame } from \"./LogBoxInspectorStackFrame\";\n\ntype Props = {\n type: StackType;\n onRetry: () => void;\n};\n\nexport function getCollapseMessage(\n stackFrames: Stack,\n collapsed: boolean\n): string {\n if (stackFrames.length === 0) {\n return \"No frames to show\";\n }\n\n const collapsedCount = stackFrames.reduce((count, { collapse }) => {\n if (collapse === true) {\n return count + 1;\n }\n\n return count;\n }, 0);\n\n if (collapsedCount === 0) {\n return \"Showing all frames\";\n }\n\n const framePlural = `frame${collapsedCount > 1 ? \"s\" : \"\"}`;\n if (collapsedCount === stackFrames.length) {\n return collapsed\n ? `See${\n collapsedCount > 1 ? \" all \" : \" \"\n }${collapsedCount} collapsed ${framePlural}`\n : `Collapse${\n collapsedCount > 1 ? \" all \" : \" \"\n }${collapsedCount} ${framePlural}`;\n } else {\n return collapsed\n ? `See ${collapsedCount} more ${framePlural}`\n : `Collapse ${collapsedCount} ${framePlural}`;\n }\n}\n\nexport function LogBoxInspectorStackFrames({ onRetry, type }: Props) {\n const log = useSelectedLog();\n\n const [collapsed, setCollapsed] = useState(() => {\n // Only collapse frames initially if some frames are not collapsed.\n return log.getAvailableStack(type)?.some(({ collapse }) => !collapse);\n });\n\n function getStackList() {\n if (collapsed === true) {\n return log.getAvailableStack(type)?.filter(({ collapse }) => !collapse);\n } else {\n return log.getAvailableStack(type);\n }\n }\n\n if (log.getAvailableStack(type)?.length === 0) {\n return null;\n }\n\n return (\n <LogBoxInspectorSection\n heading={type === \"component\" ? \"Component Stack\" : \"Call Stack\"}\n action={\n <LogBoxInspectorSourceMapStatus\n onPress={log.symbolicated[type].status === \"FAILED\" ? onRetry : null}\n status={log.symbolicated[type].status}\n />\n }\n >\n {log.symbolicated[type].status !== \"COMPLETE\" && (\n <View style={stackStyles.hintBox}>\n <Text style={stackStyles.hintText}>\n This call stack is not symbolicated. Some features are unavailable\n such as viewing the function name or tapping to open files.\n </Text>\n </View>\n )}\n <StackFrameList\n list={getStackList()!}\n status={log.symbolicated[type].status}\n />\n <StackFrameFooter\n onPress={() => setCollapsed(!collapsed)}\n message={getCollapseMessage(log.getAvailableStack(type)!, !!collapsed)}\n />\n </LogBoxInspectorSection>\n );\n}\n\nfunction StackFrameList({\n list,\n status,\n}: {\n list: Stack;\n status: \"NONE\" | \"PENDING\" | \"COMPLETE\" | \"FAILED\";\n}): any {\n return list.map((frame, index) => {\n const { file, lineNumber } = frame;\n return (\n <LogBoxInspectorStackFrame\n key={index}\n frame={frame}\n onPress={\n status === \"COMPLETE\" && file != null && lineNumber != null\n ? () => openFileInEditor(file, lineNumber)\n : undefined\n }\n />\n );\n });\n}\n\nfunction StackFrameFooter({\n message,\n onPress,\n}: {\n message: string;\n onPress: () => void;\n}) {\n return (\n <View style={stackStyles.collapseContainer}>\n <LogBoxButton\n backgroundColor={{\n default: \"transparent\",\n pressed: LogBoxStyle.getBackgroundColor(1),\n }}\n onPress={onPress}\n style={stackStyles.collapseButton}\n >\n <Text style={stackStyles.collapse}>{message}</Text>\n </LogBoxButton>\n </View>\n );\n}\n\nconst stackStyles = StyleSheet.create({\n section: {\n marginTop: 15,\n },\n heading: {\n alignItems: \"center\",\n flexDirection: \"row\",\n paddingHorizontal: 12,\n marginBottom: 10,\n },\n headingText: {\n color: LogBoxStyle.getTextColor(1),\n flex: 1,\n fontSize: 20,\n fontWeight: \"600\",\n includeFontPadding: false,\n lineHeight: 20,\n },\n body: {\n paddingBottom: 10,\n },\n bodyText: {\n color: LogBoxStyle.getTextColor(1),\n fontSize: 14,\n includeFontPadding: false,\n lineHeight: 18,\n fontWeight: \"500\",\n paddingHorizontal: 27,\n },\n hintText: {\n color: LogBoxStyle.getTextColor(0.7),\n fontSize: 13,\n includeFontPadding: false,\n lineHeight: 18,\n fontWeight: \"400\",\n marginHorizontal: 10,\n },\n hintBox: {\n backgroundColor: LogBoxStyle.getBackgroundColor(),\n marginHorizontal: 10,\n paddingHorizontal: 5,\n paddingVertical: 10,\n borderRadius: 5,\n marginBottom: 5,\n },\n collapseContainer: {\n marginLeft: 15,\n flexDirection: \"row\",\n },\n collapseButton: {\n borderRadius: 5,\n },\n collapse: {\n color: LogBoxStyle.getTextColor(0.7),\n fontSize: 12,\n fontWeight: \"300\",\n lineHeight: 20,\n marginTop: 0,\n paddingHorizontal: 10,\n paddingVertical: 5,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorToast.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/toast/ErrorToast.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorToast.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/toast/ErrorToast.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,SAAS,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AAUF,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,eA8BtC"}
|
|
@@ -33,9 +33,9 @@ exports.ErrorToast = void 0;
|
|
|
33
33
|
*/
|
|
34
34
|
const react_views_1 = require("@bacons/react-views");
|
|
35
35
|
const react_1 = __importStar(require("react"));
|
|
36
|
-
const ErrorToastMessage_1 = require("./ErrorToastMessage");
|
|
37
36
|
const LogBoxData = __importStar(require("../Data/LogBoxData"));
|
|
38
37
|
const LogBoxStyle = __importStar(require("../UI/LogBoxStyle"));
|
|
38
|
+
const ErrorToastMessage_1 = require("./ErrorToastMessage");
|
|
39
39
|
function useSymbolicatedLog(log) {
|
|
40
40
|
// Eagerly symbolicate so the stack is available when pressing to inspect.
|
|
41
41
|
(0, react_1.useEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorToast.js","sourceRoot":"","sources":["../../../src/error-overlay/toast/ErrorToast.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAA+E;AAC/E,+CAAyC;AAEzC
|
|
1
|
+
{"version":3,"file":"ErrorToast.js","sourceRoot":"","sources":["../../../src/error-overlay/toast/ErrorToast.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAA+E;AAC/E,+CAAyC;AAEzC,+DAAiD;AAEjD,+DAAiD;AACjD,2DAAwD;AAUxD,SAAS,kBAAkB,CAAC,GAAc;IACxC,0EAA0E;IAC1E,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,UAAU,CAAC,kBAAkB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC5C,UAAU,CAAC,kBAAkB,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACZ,CAAC;AAED,SAAgB,UAAU,CAAC,KAAY;IACrC,MAAM,EAAE,aAA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B,CAAC,GAAG,CAAC;QACpD,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QACzC,gBAAgB,EAAE,CAAC;KACpB;CACF,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,wBAAU,CAAC,MAAM,CAAC;IACtC,KAAK,EAAE;QACL,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;KACT;CACF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,wBAAU,CAAC,MAAM,CAAC;IACpC,SAAS,EAAE;QACT,MAAM,EAAE,EAAE;QACV,cAAc,EAAE,QAAQ;QACxB,YAAY,EAAE,CAAC;KAChB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,QAAQ;QAClB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,WAAW,EAAE,SAAS;QACtB,eAAe,EAAE,WAAW,CAAC,kBAAkB,EAAE;QACjD,IAAI,EAAE,CAAC;QACP,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAC,CAAC","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 */\nimport { Image, Pressable, StyleSheet, Text, View } from \"@bacons/react-views\";\nimport React, { useEffect } from \"react\";\n\nimport * as LogBoxData from \"../Data/LogBoxData\";\nimport { LogBoxLog } from \"../Data/LogBoxLog\";\nimport * as LogBoxStyle from \"../UI/LogBoxStyle\";\nimport { ErrorToastMessage } from \"./ErrorToastMessage\";\n\ntype Props = {\n log: LogBoxLog;\n totalLogCount: number;\n level: \"warn\" | \"error\";\n onPressOpen: () => void;\n onPressDismiss: () => void;\n};\n\nfunction useSymbolicatedLog(log: LogBoxLog) {\n // Eagerly symbolicate so the stack is available when pressing to inspect.\n useEffect(() => {\n LogBoxData.symbolicateLogLazy(\"stack\", log);\n LogBoxData.symbolicateLogLazy(\"component\", log);\n }, [log]);\n}\n\nexport function ErrorToast(props: Props) {\n const { totalLogCount, level, log } = props;\n\n useSymbolicatedLog(log);\n\n return (\n <View style={toastStyles.container}>\n <Pressable style={{ flex: 1 }} onPress={props.onPressOpen}>\n {({ hovered, pressed }) => (\n <View\n style={[\n toastStyles.press,\n {\n transitionDuration: \"150ms\",\n backgroundColor: pressed\n ? \"#323232\"\n : hovered\n ? \"#111111\"\n : LogBoxStyle.getBackgroundColor(),\n },\n ]}\n >\n <Count count={totalLogCount} level={level} />\n <ErrorToastMessage message={log.message} />\n <Dismiss onPress={props.onPressDismiss} />\n </View>\n )}\n </Pressable>\n </View>\n );\n}\n\nfunction Count({ count, level }: { count: number; level: Props[\"level\"] }) {\n return (\n <View style={[countStyles.inside, countStyles[level]]}>\n <Text style={countStyles.text}>{count <= 1 ? \"!\" : count}</Text>\n </View>\n );\n}\n\nfunction Dismiss({ onPress }: { onPress: () => void }) {\n return (\n <Pressable\n style={{\n marginLeft: 5,\n }}\n hitSlop={{\n top: 12,\n right: 10,\n bottom: 12,\n left: 10,\n }}\n onPress={onPress}\n >\n {({ hovered, pressed }) => (\n <View\n style={[\n dismissStyles.press,\n hovered && { opacity: 0.8 },\n pressed && { opacity: 0.5 },\n ]}\n >\n <Image\n source={require(\"@expo/metro-runtime/assets/close.png\")}\n style={dismissStyles.image}\n />\n </View>\n )}\n </Pressable>\n );\n}\n\nconst countStyles = StyleSheet.create({\n warn: {\n backgroundColor: LogBoxStyle.getWarningColor(1),\n },\n error: {\n backgroundColor: LogBoxStyle.getErrorColor(1),\n },\n log: {\n backgroundColor: LogBoxStyle.getLogColor(1),\n },\n inside: {\n marginRight: 8,\n minWidth: 22,\n aspectRatio: 1,\n paddingHorizontal: 4,\n borderRadius: 11,\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n text: {\n color: LogBoxStyle.getTextColor(1),\n fontSize: 14,\n lineHeight: 18,\n textAlign: \"center\",\n fontWeight: \"600\",\n textShadowColor: LogBoxStyle.getBackgroundColor(0.8),\n textShadowOffset: { width: 0, height: 0 },\n textShadowRadius: 3,\n },\n});\n\nconst dismissStyles = StyleSheet.create({\n press: {\n backgroundColor: \"#323232\",\n height: 20,\n width: 20,\n borderRadius: 25,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n image: {\n height: 8,\n width: 8,\n },\n});\n\nconst toastStyles = StyleSheet.create({\n container: {\n height: 48,\n justifyContent: \"center\",\n marginBottom: 4,\n },\n press: {\n borderWidth: 1,\n borderRadius: 8,\n overflow: \"hidden\",\n flexDirection: \"row\",\n alignItems: \"center\",\n borderColor: \"#323232\",\n backgroundColor: LogBoxStyle.getBackgroundColor(),\n flex: 1,\n paddingHorizontal: 12,\n },\n});\n"]}
|
|
@@ -33,10 +33,10 @@ exports.ErrorToastContainer = void 0;
|
|
|
33
33
|
*/
|
|
34
34
|
const react_1 = __importStar(require("react"));
|
|
35
35
|
const react_native_1 = require("react-native");
|
|
36
|
-
const ErrorToast_1 = require("./ErrorToast");
|
|
37
36
|
const LogBoxData = __importStar(require("../Data/LogBoxData"));
|
|
38
37
|
const LogContext_1 = require("../Data/LogContext");
|
|
39
38
|
const useRejectionHandler_1 = require("../useRejectionHandler");
|
|
39
|
+
const ErrorToast_1 = require("./ErrorToast");
|
|
40
40
|
function ErrorToastContainer() {
|
|
41
41
|
(0, useRejectionHandler_1.useRejectionHandler)();
|
|
42
42
|
const { logs, isDisabled } = (0, LogContext_1.useLogs)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorToastContainer.web.js","sourceRoot":"","sources":["../../../src/error-overlay/toast/ErrorToastContainer.web.tsx"],"names":[],"mappings":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AAE,eAAe,GAC/B,CACH,CACI,CACR,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC","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 */\nimport React, { useCallback, useMemo } from \"react\";\nimport { StyleSheet, View } from \"react-native\";\n\nimport * as LogBoxData from \"../Data/LogBoxData\";\nimport { LogBoxLog } from \"../Data/LogBoxLog\";\nimport { useLogs } from \"../Data/LogContext\";\nimport { useRejectionHandler } from \"../useRejectionHandler\";\nimport { ErrorToast } from \"./ErrorToast\";\n\nexport function ErrorToastContainer() {\n useRejectionHandler();\n const { logs, isDisabled } = useLogs();\n if (!logs.length || isDisabled) {\n return null;\n }\n return <ErrorToastStack logs={logs} />;\n}\n\nfunction ErrorToastStack({ logs }: { logs: LogBoxLog[] }) {\n const onDismissWarns = useCallback(() => {\n LogBoxData.clearWarnings();\n }, []);\n\n const onDismissErrors = useCallback(() => {\n LogBoxData.clearErrors();\n }, []);\n\n const setSelectedLog = useCallback((index: number): void => {\n LogBoxData.setSelectedLog(index);\n }, []);\n\n function openLog(log: LogBoxLog) {\n let index = logs.length - 1;\n\n // Stop at zero because if we don't find any log, we'll open the first log.\n while (index > 0 && logs[index] !== log) {\n index -= 1;\n }\n setSelectedLog(index);\n }\n\n const warnings = useMemo(\n () => logs.filter((log) => log.level === \"warn\"),\n [logs]\n );\n\n const errors = useMemo(\n () => logs.filter((log) => log.level === \"error\" || log.level === \"fatal\"),\n [logs]\n );\n\n return (\n <View style={styles.list}>\n {warnings.length > 0 && (\n <ErrorToast\n log={warnings[warnings.length - 1]}\n level=\"warn\"\n totalLogCount={warnings.length}\n onPressOpen={() => openLog(warnings[warnings.length - 1])}\n onPressDismiss={onDismissWarns}\n />\n )}\n\n {errors.length > 0 && (\n <ErrorToast\n log={errors[errors.length - 1]}\n level=\"error\"\n totalLogCount={errors.length}\n onPressOpen={() => openLog(errors[errors.length - 1])}\n onPressDismiss={onDismissErrors}\n />\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n list: {\n bottom: 6,\n left: 10,\n right: 10,\n position: \"absolute\",\n maxWidth: 320,\n },\n});\n\nexport default LogBoxData.withSubscription(ErrorToastContainer);\n"]}
|
|
@@ -6,8 +6,8 @@ var _a, _b, _c, _d;
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const expo_constants_1 = __importDefault(require("expo-constants"));
|
|
8
8
|
const url_parse_1 = __importDefault(require("url-parse"));
|
|
9
|
-
const Location_1 = require("./Location");
|
|
10
9
|
const getDevServer_1 = __importDefault(require("../getDevServer"));
|
|
10
|
+
const Location_1 = require("./Location");
|
|
11
11
|
let hasWarned = false;
|
|
12
12
|
const manifest = ((_b = (_a = expo_constants_1.default.manifest) !== null && _a !== void 0 ? _a : expo_constants_1.default.manifest2) !== null && _b !== void 0 ? _b : expo_constants_1.default.expoConfig);
|
|
13
13
|
// Add a development warning for fetch requests with relative paths
|
|
@@ -20,7 +20,7 @@ function warnProductionOriginNotConfigured(requestUrl) {
|
|
|
20
20
|
}
|
|
21
21
|
hasWarned = true;
|
|
22
22
|
if (!((_b = (_a = manifest === null || manifest === void 0 ? void 0 : manifest.extra) === null || _a === void 0 ? void 0 : _a.router) === null || _b === void 0 ? void 0 : _b.origin)) {
|
|
23
|
-
console.warn(`The relative fetch request "${requestUrl}" will not work in production until the Expo
|
|
23
|
+
console.warn(`The relative fetch request "${requestUrl}" will not work in production until the Expo Router Config Plugin (app.json) is configured with the \`origin\` prop set to the base URL of your web server, e.g. \`{ plugins: [["expo-router", { origin: "..." }]] }\`. [Learn more](https://expo.github.io/router/docs/lab/runtime-location)`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
// TODO: This would be better if native and tied as close to the JS engine as possible, i.e. it should
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.native.js","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AACvC,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"install.native.js","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AACvC,0DAA4B;AAE5B,mEAA2C;AAC3C,yCAAsD;AAEtD,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,MAAM,QAAQ,GAAG,CAAC,MAAA,MAAA,wBAAS,CAAC,QAAQ,mCAClC,wBAAS,CAAC,SAAS,mCACnB,wBAAS,CAAC,UAAU,CAA+B,CAAC;AAEtD,mEAAmE;AACnE,uEAAuE;AACvE,2EAA2E;AAC3E,SAAS,iCAAiC,CAAC,UAAkB;;IAC3D,IAAI,SAAS,EAAE;QACb,OAAO;KACR;IACD,SAAS,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,CAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,0CAAE,MAAM,0CAAE,MAAM,CAAA,EAAE;QACpC,OAAO,CAAC,IAAI,CACV,+BAA+B,UAAU,+RAA+R,CACzU,CAAC;KACH;AACH,CAAC;AAED,sGAAsG;AACtG,+DAA+D;AAC/D,SAAS,UAAU;;IACjB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,8BAA8B;QAC9B,OAAO,MAAA,IAAA,sBAAY,GAAE,CAAC,GAAG,0CAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KAC/C;IAED,kDAAkD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K,YAAY,EAAE;oBACzC,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC7C;gBAED,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,mBAAG,CACpB,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EACZ,MAAA,MAAM,CAAC,QAAQ,0CAAE,MAAM,CACxB,CAAC,QAAQ,EAAE,CAAC;aACd;SACF;QACD,OAAO,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,IAAI,CAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,0CAAE,MAAM,0CAAE,MAAM,MAAK,KAAK,EAAE;IAC7C,+CAA+C;IAC/C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;QACzB,IAAI,GAAG,EAAE;YACP,IAAA,0BAAe,EAAC,GAAG,CAAC,CAAC;YACrB,IAAA,kBAAO,GAAE,CAAC;SACX;KACF;IACD,iDAAiD;IACjD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE;QACrC,KAAK,EAAE,2BAA2B,CAAC,KAAK,CAAC;KAC1C,CAAC,CAAC;CACJ","sourcesContent":["import Constants from \"expo-constants\";\nimport URL from \"url-parse\";\n\nimport getDevServer from \"../getDevServer\";\nimport { install, setLocationHref } from \"./Location\";\n\nlet hasWarned = false;\n\nconst manifest = (Constants.manifest ??\n Constants.manifest2 ??\n Constants.expoConfig) as Record<string, any> | null;\n\n// Add a development warning for fetch requests with relative paths\n// to ensure developers are aware of the need to configure a production\n// base URL in the Expo config (app.json) under `expo.extra.router.origin`.\nfunction warnProductionOriginNotConfigured(requestUrl: string) {\n if (hasWarned) {\n return;\n }\n hasWarned = true;\n if (!manifest?.extra?.router?.origin) {\n console.warn(\n `The relative fetch request \"${requestUrl}\" will not work in production until the Expo Router Config Plugin (app.json) is configured with the \\`origin\\` prop set to the base URL of your web server, e.g. \\`{ plugins: [[\"expo-router\", { origin: \"...\" }]] }\\`. [Learn more](https://expo.github.io/router/docs/lab/runtime-location)`\n );\n }\n}\n\n// TODO: This would be better if native and tied as close to the JS engine as possible, i.e. it should\n// reflect the exact location of the JS file that was executed.\nfunction getBaseUrl() {\n if (process.env.NODE_ENV !== \"production\") {\n // e.g. http://localhost:19006\n return getDevServer().url?.replace(/\\/$/, \"\");\n }\n\n // TODO: Make it official by moving out of `extra`\n const productionBaseUrl = manifest?.extra?.router?.origin;\n\n if (!productionBaseUrl) {\n return null;\n }\n\n // Ensure no trailing slash\n return productionBaseUrl?.replace(/\\/$/, \"\");\n}\n\nfunction wrapFetchWithWindowLocation(\n fetch: Function & { __EXPO_BASE_URL_POLYFILLED?: boolean }\n) {\n if (fetch.__EXPO_BASE_URL_POLYFILLED) {\n return fetch;\n }\n\n const _fetch = (...props: any[]) => {\n if (props[0] && typeof props[0] === \"string\" && props[0].startsWith(\"/\")) {\n if (process.env.NODE_ENV !== \"production\") {\n warnProductionOriginNotConfigured(props[0]);\n }\n\n props[0] = new URL(props[0], window.location?.origin).toString();\n } else if (props[0] && typeof props[0] === \"object\") {\n if (\n props[0].url &&\n typeof props[0].url === \"string\" &&\n props[0].url.startsWith(\"/\")\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n warnProductionOriginNotConfigured(props[0]);\n }\n\n props[0].url = new URL(\n props[0].url,\n window.location?.origin\n ).toString();\n }\n }\n return fetch(...props);\n };\n\n _fetch.__EXPO_BASE_URL_POLYFILLED = true;\n\n return _fetch;\n}\n\nif (manifest?.extra?.router?.origin !== false) {\n // Polyfill window.location in native runtimes.\n if (typeof window !== \"undefined\" && !window.location) {\n const url = getBaseUrl();\n if (url) {\n setLocationHref(url);\n install();\n }\n }\n // Polyfill native fetch to support relative URLs\n Object.defineProperty(global, \"fetch\", {\n value: wrapFetchWithWindowLocation(fetch),\n });\n}\n"]}
|
package/package.json
CHANGED