@expo/metro-runtime 2.0.6 → 2.1.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.
Files changed (70) hide show
  1. package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
  2. package/build/error-overlay/Data/LogBoxData.js +7 -1
  3. package/build/error-overlay/Data/LogBoxData.js.map +1 -1
  4. package/build/error-overlay/Data/LogBoxLog.d.ts +26 -19
  5. package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -1
  6. package/build/error-overlay/Data/LogBoxLog.js +50 -14
  7. package/build/error-overlay/Data/LogBoxLog.js.map +1 -1
  8. package/build/error-overlay/Data/LogContext.d.ts +1 -1
  9. package/build/error-overlay/Data/LogContext.d.ts.map +1 -1
  10. package/build/error-overlay/Data/LogContext.js +14 -5
  11. package/build/error-overlay/Data/LogContext.js.map +1 -1
  12. package/build/error-overlay/ErrorOverlay.d.ts +8 -1
  13. package/build/error-overlay/ErrorOverlay.d.ts.map +1 -1
  14. package/build/error-overlay/ErrorOverlay.js +20 -19
  15. package/build/error-overlay/ErrorOverlay.js.map +1 -1
  16. package/build/error-overlay/formatProjectFilePath.d.ts +6 -1
  17. package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -1
  18. package/build/error-overlay/formatProjectFilePath.js +14 -7
  19. package/build/error-overlay/formatProjectFilePath.js.map +1 -1
  20. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -1
  21. package/build/error-overlay/modules/symbolicateStackTrace/index.js +3 -1
  22. package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -1
  23. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +1 -1
  24. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
  25. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +2 -3
  26. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
  27. package/build/error-overlay/overlay/LogBoxInspectorFooter.js +1 -1
  28. package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -1
  29. package/build/error-overlay/overlay/LogBoxInspectorHeader.js +7 -0
  30. package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -1
  31. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +3 -0
  32. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -1
  33. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -1
  34. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +1 -7
  35. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -1
  36. package/build/symbolicate.d.ts +5 -0
  37. package/build/symbolicate.d.ts.map +1 -0
  38. package/build/symbolicate.js +26 -0
  39. package/build/symbolicate.js.map +1 -0
  40. package/package.json +4 -2
  41. package/symbolicate/index.d.ts +1 -0
  42. package/symbolicate/index.js +1 -0
  43. package/build/async-require/__tests__/buildAsyncRequire.test.d.ts +0 -3
  44. package/build/async-require/__tests__/buildAsyncRequire.test.d.ts.map +0 -1
  45. package/build/async-require/__tests__/buildAsyncRequire.test.js +0 -71
  46. package/build/async-require/__tests__/buildAsyncRequire.test.js.map +0 -1
  47. package/build/async-require/__tests__/buildUrlForBundle.test.native.d.ts +0 -3
  48. package/build/async-require/__tests__/buildUrlForBundle.test.native.d.ts.map +0 -1
  49. package/build/async-require/__tests__/buildUrlForBundle.test.native.js +0 -38
  50. package/build/async-require/__tests__/buildUrlForBundle.test.native.js.map +0 -1
  51. package/build/async-require/__tests__/buildUrlForBundle.test.web.d.ts +0 -2
  52. package/build/async-require/__tests__/buildUrlForBundle.test.web.d.ts.map +0 -1
  53. package/build/async-require/__tests__/buildUrlForBundle.test.web.js +0 -13
  54. package/build/async-require/__tests__/buildUrlForBundle.test.web.js.map +0 -1
  55. package/build/async-require/__tests__/fetchAsync.test.web.d.ts +0 -2
  56. package/build/async-require/__tests__/fetchAsync.test.web.d.ts.map +0 -1
  57. package/build/async-require/__tests__/fetchAsync.test.web.js +0 -22
  58. package/build/async-require/__tests__/fetchAsync.test.web.js.map +0 -1
  59. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.d.ts +0 -2
  60. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.d.ts.map +0 -1
  61. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.js +0 -32
  62. package/build/async-require/__tests__/loadBundlePolyfill.test.ios.js.map +0 -1
  63. package/build/async-require/__tests__/loadBundlePolyfill.test.web.d.ts +0 -2
  64. package/build/async-require/__tests__/loadBundlePolyfill.test.web.d.ts.map +0 -1
  65. package/build/async-require/__tests__/loadBundlePolyfill.test.web.js +0 -31
  66. package/build/async-require/__tests__/loadBundlePolyfill.test.web.js.map +0 -1
  67. package/build/transformer/css/__tests__/css-transformer.test.web.d.ts +0 -2
  68. package/build/transformer/css/__tests__/css-transformer.test.web.d.ts.map +0 -1
  69. package/build/transformer/css/__tests__/css-transformer.test.web.js +0 -111
  70. package/build/transformer/css/__tests__/css-transformer.test.web.js.map +0 -1
@@ -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;AAE/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;AAI1B,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;AAExC,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAA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,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"}
@@ -81,9 +81,15 @@ function isMessageIgnored(message) {
81
81
  return false;
82
82
  }
83
83
  exports.isMessageIgnored = isMessageIgnored;
84
+ function setImmediateShim(callback) {
85
+ if (!global.setImmediate) {
86
+ return setTimeout(callback, 0);
87
+ }
88
+ return global.setImmediate(callback);
89
+ }
84
90
  function handleUpdate() {
85
91
  if (updateTimeout == null) {
86
- updateTimeout = setImmediate(() => {
92
+ updateTimeout = setImmediateShim(() => {
87
93
  updateTimeout = null;
88
94
  const nextState = getNextState();
89
95
  observers.forEach(({ observer }) => observer(nextState));
@@ -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,GAA2C,IAAI,CAAC;AACjE,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,CAAC,CAAC;AAC3C,CAAC;AAVD,8CAUC;AAED,SAAgB,2BAA2B,CACzC,KAAoB,EACpB,cAAuB;IAEvB,KAAK,CAAC,OAAO,GAAG,GAAG,oBAAoB,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9D,OAAO,iBAAiB,CAAC,KAAK,EAAE,cAAc,CAAC,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ACvB,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 { 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: null | ReturnType<typeof setImmediate> = 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 handleUpdate(): void {\n if (updateTimeout == null) {\n updateTimeout = setImmediate(() => {\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,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,CAA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iB;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 { 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"]}
@@ -8,7 +8,7 @@
8
8
  import type { Stack } from "./LogBoxSymbolication";
9
9
  import type { Category, Message, ComponentStack, CodeFrame } from "./parseLogBoxLog";
10
10
  type SymbolicationStatus = "NONE" | "PENDING" | "COMPLETE" | "FAILED";
11
- export type LogLevel = "warn" | "error" | "fatal" | "syntax";
11
+ export type LogLevel = "warn" | "error" | "fatal" | "syntax" | "static";
12
12
  export type LogBoxLogData = {
13
13
  level: LogLevel;
14
14
  type?: string;
@@ -20,6 +20,23 @@ export type LogBoxLogData = {
20
20
  isComponentError: boolean;
21
21
  };
22
22
  export type StackType = "stack" | "component";
23
+ type SymbolicationResult = {
24
+ error: null;
25
+ stack: null;
26
+ status: "NONE";
27
+ } | {
28
+ error: null;
29
+ stack: null;
30
+ status: "PENDING";
31
+ } | {
32
+ error: null;
33
+ stack: Stack;
34
+ status: "COMPLETE";
35
+ } | {
36
+ error: Error;
37
+ stack: null;
38
+ status: "FAILED";
39
+ };
23
40
  export declare class LogBoxLog {
24
41
  message: Message;
25
42
  type: string;
@@ -30,28 +47,18 @@ export declare class LogBoxLog {
30
47
  level: LogLevel;
31
48
  codeFrame?: CodeFrame;
32
49
  isComponentError: boolean;
33
- symbolicated: Record<StackType, {
34
- error: null;
35
- stack: null;
36
- status: "NONE";
37
- } | {
38
- error: null;
39
- stack: null;
40
- status: "PENDING";
41
- } | {
42
- error: null;
43
- stack: Stack;
44
- status: "COMPLETE";
45
- } | {
46
- error: Error;
47
- stack: null;
48
- status: "FAILED";
49
- }>;
50
- constructor(data: LogBoxLogData);
50
+ symbolicated: Record<StackType, SymbolicationResult>;
51
+ private callbacks;
52
+ constructor(data: LogBoxLogData & {
53
+ symbolicated?: Record<StackType, SymbolicationResult>;
54
+ });
51
55
  incrementCount(): void;
52
56
  getAvailableStack(type: StackType): Stack | null;
57
+ private flushCallbacks;
58
+ private pushCallback;
53
59
  retrySymbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void;
54
60
  symbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void;
61
+ private _symbolicate;
55
62
  private componentStackCache;
56
63
  private getStack;
57
64
  private handleSymbolicate;
@@ -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,EACV,QAAQ,EACR,OAAO,EACP,cAAc,EACd,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,KAAK,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,EAAE,OAAO,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,IAAI,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEpD,qBAAa,SAAS;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAWlD;IAEF,OAAO,CAAC,SAAS,CAAyD;gBAGxE,IAAI,EAAE,aAAa,GAAG;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;KACvD;IAcH,cAAc,IAAI,IAAI;IAItB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI;IAOhD,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,YAAY;IASpB,gBAAgB,CACd,IAAI,EAAE,SAAS,EACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI;IAIP,WAAW,CACT,IAAI,EAAE,SAAS,EACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI;IAIP,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,mBAAmB,CAAsB;IAEjD,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,YAAY;CAsCrB"}
@@ -46,7 +46,7 @@ function componentStackToStack(componentStack) {
46
46
  }
47
47
  class LogBoxLog {
48
48
  constructor(data) {
49
- var _a;
49
+ var _a, _b;
50
50
  this.symbolicated = {
51
51
  stack: {
52
52
  error: null,
@@ -59,6 +59,7 @@ class LogBoxLog {
59
59
  status: "NONE",
60
60
  },
61
61
  };
62
+ this.callbacks = new Map();
62
63
  this.componentStackCache = null;
63
64
  this.level = data.level;
64
65
  this.type = (_a = data.type) !== null && _a !== void 0 ? _a : "error";
@@ -69,6 +70,7 @@ class LogBoxLog {
69
70
  this.codeFrame = data.codeFrame;
70
71
  this.isComponentError = data.isComponentError;
71
72
  this.count = 1;
73
+ this.symbolicated = (_b = data.symbolicated) !== null && _b !== void 0 ? _b : this.symbolicated;
72
74
  }
73
75
  incrementCount() {
74
76
  this.count += 1;
@@ -79,15 +81,46 @@ class LogBoxLog {
79
81
  }
80
82
  return this.getStack(type);
81
83
  }
82
- retrySymbolicate(type, callback) {
83
- if (this.symbolicated[type].status !== "COMPLETE") {
84
- LogBoxSymbolication.deleteStack(this.getStack(type));
85
- this.handleSymbolicate(type, callback);
84
+ flushCallbacks(type) {
85
+ const callbacks = this.callbacks.get(type);
86
+ const status = this.symbolicated[type].status;
87
+ if (callbacks) {
88
+ for (const callback of callbacks) {
89
+ callback(status);
90
+ }
91
+ callbacks.clear();
86
92
  }
87
93
  }
94
+ pushCallback(type, callback) {
95
+ let callbacks = this.callbacks.get(type);
96
+ if (!callbacks) {
97
+ callbacks = new Set();
98
+ this.callbacks.set(type, callbacks);
99
+ }
100
+ callbacks.add(callback);
101
+ }
102
+ retrySymbolicate(type, callback) {
103
+ this._symbolicate(type, true, callback);
104
+ }
88
105
  symbolicate(type, callback) {
89
- if (this.symbolicated[type].status === "NONE") {
90
- this.handleSymbolicate(type, callback);
106
+ this._symbolicate(type, false, callback);
107
+ }
108
+ _symbolicate(type, retry, callback) {
109
+ if (callback) {
110
+ this.pushCallback(type, callback);
111
+ }
112
+ const status = this.symbolicated[type].status;
113
+ if (status === "COMPLETE") {
114
+ return this.flushCallbacks(type);
115
+ }
116
+ if (retry) {
117
+ LogBoxSymbolication.deleteStack(this.getStack(type));
118
+ this.handleSymbolicate(type);
119
+ }
120
+ else {
121
+ if (status === "NONE") {
122
+ this.handleSymbolicate(type);
123
+ }
91
124
  }
92
125
  }
93
126
  getStack(type) {
@@ -99,21 +132,21 @@ class LogBoxLog {
99
132
  }
100
133
  return this.stack;
101
134
  }
102
- handleSymbolicate(type, callback) {
135
+ handleSymbolicate(type) {
103
136
  var _a;
104
137
  if (type === "component" && !((_a = this.componentStack) === null || _a === void 0 ? void 0 : _a.length)) {
105
138
  return;
106
139
  }
107
140
  if (this.symbolicated[type].status !== "PENDING") {
108
- this.updateStatus(type, null, null, null, callback);
141
+ this.updateStatus(type, null, null, null);
109
142
  LogBoxSymbolication.symbolicate(this.getStack(type)).then((data) => {
110
- this.updateStatus(type, null, data === null || data === void 0 ? void 0 : data.stack, data === null || data === void 0 ? void 0 : data.codeFrame, callback);
143
+ this.updateStatus(type, null, data === null || data === void 0 ? void 0 : data.stack, data === null || data === void 0 ? void 0 : data.codeFrame);
111
144
  }, (error) => {
112
- this.updateStatus(type, error, null, null, callback);
145
+ this.updateStatus(type, error, null, null);
113
146
  });
114
147
  }
115
148
  }
116
- updateStatus(type, error, stack, codeFrame, callback) {
149
+ updateStatus(type, error, stack, codeFrame) {
117
150
  const lastStatus = this.symbolicated[type].status;
118
151
  if (error != null) {
119
152
  this.symbolicated[type] = {
@@ -139,8 +172,11 @@ class LogBoxLog {
139
172
  status: "PENDING",
140
173
  };
141
174
  }
142
- if (callback && lastStatus !== this.symbolicated[type].status) {
143
- callback(this.symbolicated[type].status);
175
+ const status = this.symbolicated[type].status;
176
+ if (lastStatus !== status) {
177
+ if (["COMPLETE", "FAILED"].includes(status)) {
178
+ this.flushCallbacks(type);
179
+ }
144
180
  }
145
181
  }
146
182
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxLog.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2EAA6D;AA0B7D,SAAS,qBAAqB,CAAC,cAA8B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gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,SAAS;aAClB,CAAC;SACH;QAED,IAAI,QAAQ,IAAI,UAAU,KAAK,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;YAC7D,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;SAC1C;IACH,CAAC;CACF;AA5ID,8BA4IC","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 LogBoxSymbolication from \"./LogBoxSymbolication\";\nimport type { Stack } from \"./LogBoxSymbolication\";\nimport type {\n Category,\n Message,\n ComponentStack,\n CodeFrame,\n} from \"./parseLogBoxLog\";\n\ntype SymbolicationStatus = \"NONE\" | \"PENDING\" | \"COMPLETE\" | \"FAILED\";\n\nexport type LogLevel = \"warn\" | \"error\" | \"fatal\" | \"syntax\";\n\nexport type LogBoxLogData = {\n level: LogLevel;\n type?: string;\n message: Message;\n stack: Stack;\n category: string;\n componentStack: ComponentStack;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n};\n\nexport type StackType = \"stack\" | \"component\";\n\nfunction componentStackToStack(componentStack: ComponentStack): Stack {\n return componentStack.map((stack) => ({\n file: stack.fileName,\n methodName: stack.content,\n lineNumber: stack.location?.row ?? 0,\n column: stack.location?.column ?? 0,\n arguments: [],\n }));\n}\n\nexport class LogBoxLog {\n message: Message;\n type: string;\n category: Category;\n componentStack: ComponentStack;\n stack: Stack;\n count: number;\n level: LogLevel;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n symbolicated: Record<\n StackType,\n | { error: null; stack: null; status: \"NONE\" }\n | { error: null; stack: null; status: \"PENDING\" }\n | { error: null; stack: Stack; status: \"COMPLETE\" }\n | { error: Error; stack: null; status: \"FAILED\" }\n > = {\n stack: {\n error: null,\n stack: null,\n status: \"NONE\",\n },\n component: {\n error: null,\n stack: null,\n status: \"NONE\",\n },\n };\n\n constructor(data: LogBoxLogData) {\n this.level = data.level;\n this.type = data.type ?? \"error\";\n this.message = data.message;\n this.stack = data.stack;\n this.category = data.category;\n this.componentStack = data.componentStack;\n this.codeFrame = data.codeFrame;\n this.isComponentError = data.isComponentError;\n this.count = 1;\n }\n\n incrementCount(): void {\n this.count += 1;\n }\n\n getAvailableStack(type: StackType): Stack | null {\n if (this.symbolicated[type].status === \"COMPLETE\") {\n return this.symbolicated[type].stack;\n }\n return this.getStack(type);\n }\n\n retrySymbolicate(\n type: StackType,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n if (this.symbolicated[type].status !== \"COMPLETE\") {\n LogBoxSymbolication.deleteStack(this.getStack(type));\n this.handleSymbolicate(type, callback);\n }\n }\n\n symbolicate(\n type: StackType,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n if (this.symbolicated[type].status === \"NONE\") {\n this.handleSymbolicate(type, callback);\n }\n }\n\n private componentStackCache: Stack | null = null;\n\n private getStack(type: StackType): Stack {\n if (type === \"component\") {\n if (this.componentStackCache == null) {\n this.componentStackCache = componentStackToStack(this.componentStack);\n }\n return this.componentStackCache;\n }\n return this.stack;\n }\n\n private handleSymbolicate(\n type: StackType,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n if (type === \"component\" && !this.componentStack?.length) {\n return;\n }\n\n if (this.symbolicated[type].status !== \"PENDING\") {\n this.updateStatus(type, null, null, null, callback);\n LogBoxSymbolication.symbolicate(this.getStack(type)).then(\n (data) => {\n this.updateStatus(type, null, data?.stack, data?.codeFrame, callback);\n },\n (error) => {\n this.updateStatus(type, error, null, null, callback);\n }\n );\n }\n }\n\n private updateStatus(\n type: StackType,\n error?: Error | null,\n stack?: Stack | null,\n codeFrame?: CodeFrame | null,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n const lastStatus = this.symbolicated[type].status;\n if (error != null) {\n this.symbolicated[type] = {\n error,\n stack: null,\n status: \"FAILED\",\n };\n } else if (stack != null) {\n if (codeFrame) {\n this.codeFrame = codeFrame;\n }\n\n this.symbolicated[type] = {\n error: null,\n stack,\n status: \"COMPLETE\",\n };\n } else {\n this.symbolicated[type] = {\n error: null,\n stack: null,\n status: \"PENDING\",\n };\n }\n\n if (callback && lastStatus !== this.symbolicated[type].status) {\n callback(this.symbolicated[type].status);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"LogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxLog.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2EAA6D;AA0B7D,SAAS,qBAAqB,CAAC,cAA8B;IAC3D,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;;QAAC,OAAA,CAAC;YACpC,IAAI,EAAE,KAAK,CAAC,QAAQ;YACpB,UAAU,EAAE,KAAK,CAAC,OAAO;YACzB,UAAU,EAAE,MAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,GAAG,mCAAI,CAAC;YACpC,MAAM,EAAE,MAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,mCAAI,CAAC;YACnC,SAAS,EAAE,EAAE;SACd,CAAC,CAAA;KAAA,CAAC,CAAC;AACN,CAAC;AAUD,MAAa,SAAS;IAyBpB,YACE,IAEC;;QAlBH,iBAAY,GAA2C;YACrD,KAAK,EAAE;gBACL,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,MAAM;aACf;YACD,SAAS,EAAE;gBACT,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,MAAM;aACf;SACF,CAAC;QAEM,cAAS,GAA+C,IAAI,GAAG,EAAE,CAAC;QAwFlE,wBAAmB,GAAiB,IAAI,CAAC;QAjF/C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,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AAM,IAAI,KAAK,IAAI,IAAI,EAAE;YACxB,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;aAC5B;YAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK;gBACL,MAAM,EAAE,UAAU;aACnB,CAAC;SACH;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,SAAS;aAClB,CAAC;SACH;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QAC9C,IAAI,UAAU,KAAK,MAAM,EAAE;YACzB,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;aAC3B;SACF;IACH,CAAC;CACF;AAnLD,8BAmLC","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 LogBoxSymbolication from \"./LogBoxSymbolication\";\nimport type { Stack } from \"./LogBoxSymbolication\";\nimport type {\n Category,\n Message,\n ComponentStack,\n CodeFrame,\n} from \"./parseLogBoxLog\";\n\ntype SymbolicationStatus = \"NONE\" | \"PENDING\" | \"COMPLETE\" | \"FAILED\";\n\nexport type LogLevel = \"warn\" | \"error\" | \"fatal\" | \"syntax\" | \"static\";\n\nexport type LogBoxLogData = {\n level: LogLevel;\n type?: string;\n message: Message;\n stack: Stack;\n category: string;\n componentStack: ComponentStack;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n};\n\nexport type StackType = \"stack\" | \"component\";\n\nfunction componentStackToStack(componentStack: ComponentStack): Stack {\n return componentStack.map((stack) => ({\n file: stack.fileName,\n methodName: stack.content,\n lineNumber: stack.location?.row ?? 0,\n column: stack.location?.column ?? 0,\n arguments: [],\n }));\n}\n\ntype SymbolicationCallback = (status: SymbolicationStatus) => void;\n\ntype SymbolicationResult =\n | { error: null; stack: null; status: \"NONE\" }\n | { error: null; stack: null; status: \"PENDING\" }\n | { error: null; stack: Stack; status: \"COMPLETE\" }\n | { error: Error; stack: null; status: \"FAILED\" };\n\nexport class LogBoxLog {\n message: Message;\n type: string;\n category: Category;\n componentStack: ComponentStack;\n stack: Stack;\n count: number;\n level: LogLevel;\n codeFrame?: CodeFrame;\n isComponentError: boolean;\n symbolicated: Record<StackType, SymbolicationResult> = {\n stack: {\n error: null,\n stack: null,\n status: \"NONE\",\n },\n component: {\n error: null,\n stack: null,\n status: \"NONE\",\n },\n };\n\n private callbacks: Map<StackType, Set<SymbolicationCallback>> = new Map();\n\n constructor(\n data: LogBoxLogData & {\n symbolicated?: Record<StackType, SymbolicationResult>;\n }\n ) {\n this.level = data.level;\n this.type = data.type ?? \"error\";\n this.message = data.message;\n this.stack = data.stack;\n this.category = data.category;\n this.componentStack = data.componentStack;\n this.codeFrame = data.codeFrame;\n this.isComponentError = data.isComponentError;\n this.count = 1;\n this.symbolicated = data.symbolicated ?? this.symbolicated;\n }\n\n incrementCount(): void {\n this.count += 1;\n }\n\n getAvailableStack(type: StackType): Stack | null {\n if (this.symbolicated[type].status === \"COMPLETE\") {\n return this.symbolicated[type].stack;\n }\n return this.getStack(type);\n }\n\n private flushCallbacks(type: StackType): void {\n const callbacks = this.callbacks.get(type);\n const status = this.symbolicated[type].status;\n if (callbacks) {\n for (const callback of callbacks) {\n callback(status);\n }\n callbacks.clear();\n }\n }\n\n private pushCallback(type: StackType, callback: SymbolicationCallback): void {\n let callbacks = this.callbacks.get(type);\n if (!callbacks) {\n callbacks = new Set();\n this.callbacks.set(type, callbacks);\n }\n callbacks.add(callback);\n }\n\n retrySymbolicate(\n type: StackType,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n this._symbolicate(type, true, callback);\n }\n\n symbolicate(\n type: StackType,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n this._symbolicate(type, false, callback);\n }\n\n private _symbolicate(\n type: StackType,\n retry: boolean,\n callback?: (status: SymbolicationStatus) => void\n ): void {\n if (callback) {\n this.pushCallback(type, callback);\n }\n const status = this.symbolicated[type].status;\n\n if (status === \"COMPLETE\") {\n return this.flushCallbacks(type);\n }\n\n if (retry) {\n LogBoxSymbolication.deleteStack(this.getStack(type));\n this.handleSymbolicate(type);\n } else {\n if (status === \"NONE\") {\n this.handleSymbolicate(type);\n }\n }\n }\n\n private componentStackCache: Stack | null = null;\n\n private getStack(type: StackType): Stack {\n if (type === \"component\") {\n if (this.componentStackCache == null) {\n this.componentStackCache = componentStackToStack(this.componentStack);\n }\n return this.componentStackCache;\n }\n return this.stack;\n }\n\n private handleSymbolicate(type: StackType): void {\n if (type === \"component\" && !this.componentStack?.length) {\n return;\n }\n\n if (this.symbolicated[type].status !== \"PENDING\") {\n this.updateStatus(type, null, null, null);\n LogBoxSymbolication.symbolicate(this.getStack(type)).then(\n (data) => {\n this.updateStatus(type, null, data?.stack, data?.codeFrame);\n },\n (error) => {\n this.updateStatus(type, error, null, null);\n }\n );\n }\n }\n\n private updateStatus(\n type: StackType,\n error?: Error | null,\n stack?: Stack | null,\n codeFrame?: CodeFrame | null\n ): void {\n const lastStatus = this.symbolicated[type].status;\n if (error != null) {\n this.symbolicated[type] = {\n error,\n stack: null,\n status: \"FAILED\",\n };\n } else if (stack != null) {\n if (codeFrame) {\n this.codeFrame = codeFrame;\n }\n\n this.symbolicated[type] = {\n error: null,\n stack,\n status: \"COMPLETE\",\n };\n } else {\n this.symbolicated[type] = {\n error: null,\n stack: null,\n status: \"PENDING\",\n };\n }\n\n const status = this.symbolicated[type].status;\n if (lastStatus !== status) {\n if ([\"COMPLETE\", \"FAILED\"].includes(status)) {\n this.flushCallbacks(type);\n }\n }\n }\n}\n"]}
@@ -4,7 +4,7 @@ export declare const LogContext: React.Context<{
4
4
  selectedLogIndex: number;
5
5
  isDisabled: boolean;
6
6
  logs: LogBoxLog[];
7
- }>;
7
+ } | null>;
8
8
  export declare function useLogs(): {
9
9
  selectedLogIndex: number;
10
10
  isDisabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"LogContext.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,eAAO,MAAM,UAAU;sBACH,MAAM;gBACZ,OAAO;UACb,SAAS,EAAE;EAKjB,CAAC;AAEH,wBAAgB,OAAO;;;;EAMtB;AAED,wBAAgB,cAAc,cAG7B"}
1
+ {"version":3,"file":"LogContext.d.ts","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,eAAO,MAAM,UAAU;sBACH,MAAM;gBACZ,OAAO;UACb,SAAS,EAAE;SACJ,CAAC;AAEhB,wBAAgB,OAAO,IAAI;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB,CAmBA;AAED,wBAAgB,cAAc,cAG7B"}
@@ -5,15 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useSelectedLog = exports.useLogs = exports.LogContext = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
+ const react_native_1 = require("react-native");
9
+ const LogBoxLog_1 = require("./LogBoxLog");
8
10
  // Context provider for Array<LogBoxLog>
9
- exports.LogContext = react_1.default.createContext({
10
- selectedLogIndex: -1,
11
- isDisabled: false,
12
- logs: [],
13
- });
11
+ exports.LogContext = react_1.default.createContext(null);
14
12
  function useLogs() {
15
13
  const logs = react_1.default.useContext(exports.LogContext);
16
14
  if (!logs) {
15
+ if (react_native_1.Platform.OS === "web" && typeof window !== "undefined") {
16
+ // Logbox data that is pre-fetched on the dev server and rendered here.
17
+ const expoCliStaticErrorElement = document.getElementById("_expo-static-error");
18
+ if (expoCliStaticErrorElement === null || expoCliStaticErrorElement === void 0 ? void 0 : expoCliStaticErrorElement.textContent) {
19
+ const raw = JSON.parse(expoCliStaticErrorElement.textContent);
20
+ return {
21
+ ...raw,
22
+ logs: raw.logs.map((raw) => new LogBoxLog_1.LogBoxLog(raw)),
23
+ };
24
+ }
25
+ }
17
26
  throw new Error("useLogs must be used within a LogProvider");
18
27
  }
19
28
  return logs;
@@ -1 +1 @@
1
- {"version":3,"file":"LogContext.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,wCAAwC;AAE3B,QAAA,UAAU,GAAG,eAAK,CAAC,aAAa,CAI1C;IACD,gBAAgB,EAAE,CAAC,CAAC;IACpB,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,EAAE;CACT,CAAC,CAAC;AAEH,SAAgB,OAAO;IACrB,MAAM,IAAI,GAAG,eAAK,CAAC,UAAU,CAAC,kBAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,0BAMC;AAED,SAAgB,cAAc;IAC5B,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAChC,CAAC;AAHD,wCAGC","sourcesContent":["import React from \"react\";\n\nimport { LogBoxLog } from \"./LogBoxLog\";\n\n// Context provider for Array<LogBoxLog>\n\nexport const LogContext = React.createContext<{\n selectedLogIndex: number;\n isDisabled: boolean;\n logs: LogBoxLog[];\n}>({\n selectedLogIndex: -1,\n isDisabled: false,\n logs: [],\n});\n\nexport function useLogs() {\n const logs = React.useContext(LogContext);\n if (!logs) {\n throw new Error(\"useLogs must be used within a LogProvider\");\n }\n return logs;\n}\n\nexport function useSelectedLog() {\n const { selectedLogIndex, logs } = useLogs();\n return logs[selectedLogIndex];\n}\n"]}
1
+ {"version":3,"file":"LogContext.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogContext.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAAwC;AAExC,2CAAwC;AAExC,wCAAwC;AAE3B,QAAA,UAAU,GAAG,eAAK,CAAC,aAAa,CAInC,IAAI,CAAC,CAAC;AAEhB,SAAgB,OAAO;IAKrB,MAAM,IAAI,GAAG,eAAK,CAAC,UAAU,CAAC,kBAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAC1D,uEAAuE;YACvE,MAAM,yBAAyB,GAC7B,QAAQ,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;YAChD,IAAI,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,WAAW,EAAE;gBAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC;gBAC9D,OAAO;oBACL,GAAG,GAAG;oBACN,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,qBAAS,CAAC,GAAG,CAAC,CAAC;iBACrD,CAAC;aACH;SACF;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAvBD,0BAuBC;AAED,SAAgB,cAAc;IAC5B,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAChC,CAAC;AAHD,wCAGC","sourcesContent":["import React from \"react\";\nimport { Platform } from \"react-native\";\n\nimport { LogBoxLog } from \"./LogBoxLog\";\n\n// Context provider for Array<LogBoxLog>\n\nexport const LogContext = React.createContext<{\n selectedLogIndex: number;\n isDisabled: boolean;\n logs: LogBoxLog[];\n} | null>(null);\n\nexport function useLogs(): {\n selectedLogIndex: number;\n isDisabled: boolean;\n logs: LogBoxLog[];\n} {\n const logs = React.useContext(LogContext);\n if (!logs) {\n if (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n // Logbox data that is pre-fetched on the dev server and rendered here.\n const expoCliStaticErrorElement =\n document.getElementById(\"_expo-static-error\");\n if (expoCliStaticErrorElement?.textContent) {\n const raw = JSON.parse(expoCliStaticErrorElement.textContent);\n return {\n ...raw,\n logs: raw.logs.map((raw: any) => new LogBoxLog(raw)),\n };\n }\n }\n\n throw new Error(\"useLogs must be used within a LogProvider\");\n }\n return logs;\n}\n\nexport function useSelectedLog() {\n const { selectedLogIndex, logs } = useLogs();\n return logs[selectedLogIndex];\n}\n"]}
@@ -6,13 +6,20 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import React from "react";
9
- import { LogBoxLog } from "./Data/LogBoxLog";
9
+ import { LogBoxLog, StackType } from "./Data/LogBoxLog";
10
10
  export declare function LogBoxInspectorContainer(): JSX.Element | null;
11
11
  export declare function LogBoxInspector({ log, selectedLogIndex, logs, }: {
12
12
  log: LogBoxLog;
13
13
  selectedLogIndex: number;
14
14
  logs: LogBoxLog[];
15
15
  }): JSX.Element;
16
+ export declare function ErrorOverlayBody({ onRetry, }: {
17
+ onRetry: (type: StackType) => void;
18
+ }): JSX.Element;
19
+ export declare function ErrorOverlayBodyContents({ log, onRetry, }: {
20
+ log: LogBoxLog;
21
+ onRetry: (type: StackType) => void;
22
+ }): JSX.Element;
16
23
  declare const _default: React.Component<object, {}, any>;
17
24
  export default _default;
18
25
  //# sourceMappingURL=ErrorOverlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorOverlay.d.ts","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAa,MAAM,kBAAkB,CAAC;AAiBxD,wBAAgB,wBAAwB,uBAavC;AACD,wBAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,gBAAgB,EAChB,IAAI,GACL,EAAE;IACD,GAAG,EAAE,SAAS,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB,eAmEA;;AAiED,wBAAqE"}
1
+ {"version":3,"file":"ErrorOverlay.d.ts","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAkBxD,wBAAgB,wBAAwB,uBAavC;AAED,wBAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,gBAAgB,EAChB,IAAI,GACL,EAAE;IACD,GAAG,EAAE,SAAS,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB,eAmEA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,GACR,EAAE;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC,eAGA;AAED,wBAAgB,wBAAwB,CAAC,EACvC,GAAG,EACH,OAAO,GACR,EAAE;IACD,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC,eA2CA;;AASD,wBAAqE"}
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.LogBoxInspector = exports.LogBoxInspectorContainer = void 0;
26
+ exports.ErrorOverlayBodyContents = exports.ErrorOverlayBody = exports.LogBoxInspector = exports.LogBoxInspectorContainer = void 0;
27
27
  /**
28
28
  * Copyright (c) Evan Bacon.
29
29
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -46,6 +46,7 @@ const HEADER_TITLE_MAP = {
46
46
  error: "Console Error",
47
47
  fatal: "Uncaught Error",
48
48
  syntax: "Syntax Error",
49
+ static: "Static Rendering Error (Node.js)",
49
50
  component: "Render Error",
50
51
  };
51
52
  function LogBoxInspectorContainer() {
@@ -110,32 +111,32 @@ function LogBoxInspector({ log, selectedLogIndex, logs, }) {
110
111
  react_1.default.createElement(LogBoxInspectorFooter_1.LogBoxInspectorFooter, { onDismiss: onDismiss, onMinimize: onMinimize })));
111
112
  }
112
113
  exports.LogBoxInspector = LogBoxInspector;
113
- function ErrorOverlayBody({ onRetry }) {
114
- var _a, _b;
114
+ function ErrorOverlayBody({ onRetry, }) {
115
115
  const log = (0, LogContext_1.useSelectedLog)();
116
+ return react_1.default.createElement(ErrorOverlayBodyContents, { log: log, onRetry: onRetry });
117
+ }
118
+ exports.ErrorOverlayBody = ErrorOverlayBody;
119
+ function ErrorOverlayBodyContents({ log, onRetry, }) {
120
+ var _a, _b;
116
121
  const [collapsed, setCollapsed] = (0, react_1.useState)(true);
117
122
  (0, react_1.useEffect)(() => {
118
123
  setCollapsed(true);
119
124
  }, [log]);
120
125
  const headerTitle = (_a = HEADER_TITLE_MAP[log.isComponentError ? "component" : log.level]) !== null && _a !== void 0 ? _a : log.type;
121
126
  const header = (react_1.default.createElement(LogBoxInspectorMessageHeader_1.LogBoxInspectorMessageHeader, { collapsed: collapsed, onPress: () => setCollapsed(!collapsed), message: log.message, level: log.level, title: headerTitle }));
122
- const content = (react_1.default.createElement(react_1.default.Fragment, null,
123
- react_1.default.createElement(LogBoxInspectorCodeFrame_1.LogBoxInspectorCodeFrame, { codeFrame: log.codeFrame }),
124
- react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "stack",
125
- // eslint-disable-next-line react/jsx-no-bind
126
- onRetry: onRetry.bind(onRetry, "stack") }),
127
- !!((_b = log === null || log === void 0 ? void 0 : log.componentStack) === null || _b === void 0 ? void 0 : _b.length) && (react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "component",
128
- // eslint-disable-next-line react/jsx-no-bind
129
- onRetry: onRetry.bind(onRetry, "component") }))));
130
- if (collapsed) {
131
- return (react_1.default.createElement(react_1.default.Fragment, null,
132
- header,
133
- react_1.default.createElement(react_native_1.ScrollView, { style: styles.scrollBody }, content)));
134
- }
135
- return (react_1.default.createElement(react_native_1.ScrollView, { style: styles.scrollBody },
136
- header,
137
- content));
127
+ return (react_1.default.createElement(react_1.default.Fragment, null,
128
+ collapsed && header,
129
+ react_1.default.createElement(react_native_1.ScrollView, { style: styles.scrollBody },
130
+ !collapsed && header,
131
+ react_1.default.createElement(LogBoxInspectorCodeFrame_1.LogBoxInspectorCodeFrame, { codeFrame: log.codeFrame }),
132
+ react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "stack",
133
+ // eslint-disable-next-line react/jsx-no-bind
134
+ onRetry: onRetry.bind(onRetry, "stack") }),
135
+ !!((_b = log === null || log === void 0 ? void 0 : log.componentStack) === null || _b === void 0 ? void 0 : _b.length) && (react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "component",
136
+ // eslint-disable-next-line react/jsx-no-bind
137
+ onRetry: onRetry.bind(onRetry, "component") })))));
138
138
  }
139
+ exports.ErrorOverlayBodyContents = ErrorOverlayBodyContents;
139
140
  const styles = react_native_1.StyleSheet.create({
140
141
  scrollBody: {
141
142
  backgroundColor: LogBoxStyle.getBackgroundColor(1),
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorOverlay.js","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,+CAAgE;AAChE,+CAAsE;AAEtE,8DAAgD;AAEhD,kDAA4D;AAC5D,8DAAgD;AAChD,iFAA8E;AAC9E,2EAA8F;AAC9F,2EAA8F;AAC9F,yFAAsF;AACtF,qFAAkF;AAElF,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,cAAc;IACtB,SAAS,EAAE,cAAc;CAC1B,CAAC;AAEF,SAAgB,wBAAwB;IACtC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,IAAA,oBAAO,GAAE,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnC,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,8BAAC,eAAe,IACd,GAAG,EAAE,GAAG,EACR,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,IAAI,GACV,CACH,CAAC;AACJ,CAAC;AAbD,4DAaC;AACD,SAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,gBAAgB,EAChB,IAAI,GAKL;IACC,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,GAAS,EAAE;QACvC,4DAA4D;QAC5D,qDAAqD;QACrD,8CAA8C;QAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,gBAAgB,IAAI,IAAI,EAAE;YAC5B,IAAI,SAAS,CAAC,MAAM,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AE,MAAM,CAAC,UAAU;QACjC,MAAM;QACN,OAAO,CACG,CACd,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,UAAU,EAAE;QACV,eAAe,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC,gBAAgB,CAAC,wBAAwB,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, useEffect, useState } from \"react\";\nimport { Keyboard, ScrollView, StyleSheet, View } from \"react-native\";\n\nimport * as LogBoxData from \"./Data/LogBoxData\";\nimport { LogBoxLog, StackType } from \"./Data/LogBoxLog\";\nimport { useLogs, useSelectedLog } from \"./Data/LogContext\";\nimport * as LogBoxStyle from \"./UI/LogBoxStyle\";\nimport { LogBoxInspectorCodeFrame } from \"./overlay/LogBoxInspectorCodeFrame\";\nimport { LogBoxInspectorFooter as ErrorOverlayFooter } from \"./overlay/LogBoxInspectorFooter\";\nimport { LogBoxInspectorHeader as ErrorOverlayHeader } from \"./overlay/LogBoxInspectorHeader\";\nimport { LogBoxInspectorMessageHeader } from \"./overlay/LogBoxInspectorMessageHeader\";\nimport { LogBoxInspectorStackFrames } from \"./overlay/LogBoxInspectorStackFrames\";\n\nconst HEADER_TITLE_MAP = {\n warn: \"Console Warning\",\n error: \"Console Error\",\n fatal: \"Uncaught Error\",\n syntax: \"Syntax Error\",\n component: \"Render Error\",\n};\n\nexport function LogBoxInspectorContainer() {\n const { selectedLogIndex, logs } = useLogs();\n const log = logs[selectedLogIndex];\n if (log == null) {\n return null;\n }\n return (\n <LogBoxInspector\n log={log}\n selectedLogIndex={selectedLogIndex}\n logs={logs}\n />\n );\n}\nexport function LogBoxInspector({\n log,\n selectedLogIndex,\n logs,\n}: {\n log: LogBoxLog;\n selectedLogIndex: number;\n logs: LogBoxLog[];\n}) {\n const onDismiss = useCallback((): 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 logsArray = Array.from(logs);\n if (selectedLogIndex != null) {\n if (logsArray.length - 1 <= 0) {\n LogBoxData.setSelectedLog(-1);\n } else if (selectedLogIndex >= logsArray.length - 1) {\n LogBoxData.setSelectedLog(selectedLogIndex - 1);\n }\n\n LogBoxData.dismiss(logsArray[selectedLogIndex]);\n }\n }, [selectedLogIndex]);\n\n const onMinimize = useCallback((): void => {\n LogBoxData.setSelectedLog(-1);\n }, []);\n\n const onChangeSelectedIndex = useCallback((index: number): void => {\n LogBoxData.setSelectedLog(index);\n }, []);\n\n useEffect(() => {\n if (log) {\n LogBoxData.symbolicateLogNow(\"stack\", log);\n LogBoxData.symbolicateLogNow(\"component\", log);\n }\n }, [log]);\n\n useEffect(() => {\n // Optimistically symbolicate the last and next logs.\n if (logs.length > 1) {\n const selected = selectedLogIndex;\n const lastIndex = logs.length - 1;\n const prevIndex = selected - 1 < 0 ? lastIndex : selected - 1;\n const nextIndex = selected + 1 > lastIndex ? 0 : selected + 1;\n for (const type of [\"component\", \"stack\"] as const) {\n LogBoxData.symbolicateLogLazy(type, logs[prevIndex]);\n LogBoxData.symbolicateLogLazy(type, logs[nextIndex]);\n }\n }\n }, [logs, selectedLogIndex]);\n\n useEffect(() => {\n Keyboard.dismiss();\n }, []);\n\n const _handleRetry = useCallback(\n (type: StackType) => {\n LogBoxData.retrySymbolicateLogNow(type, log);\n },\n [log]\n );\n\n return (\n <View style={[StyleSheet.absoluteFill, { flex: 1 }]}>\n <ErrorOverlayHeader\n onSelectIndex={onChangeSelectedIndex}\n level={log.level}\n />\n <ErrorOverlayBody onRetry={_handleRetry} />\n <ErrorOverlayFooter onDismiss={onDismiss} onMinimize={onMinimize} />\n </View>\n );\n}\n\nfunction ErrorOverlayBody({ onRetry }: { onRetry: (type: StackType) => void }) {\n const log = useSelectedLog();\n const [collapsed, setCollapsed] = useState(true);\n\n useEffect(() => {\n setCollapsed(true);\n }, [log]);\n\n const headerTitle =\n HEADER_TITLE_MAP[log.isComponentError ? \"component\" : log.level] ??\n log.type;\n\n const header = (\n <LogBoxInspectorMessageHeader\n collapsed={collapsed}\n onPress={() => setCollapsed(!collapsed)}\n message={log.message}\n level={log.level}\n title={headerTitle}\n />\n );\n\n const content = (\n <>\n <LogBoxInspectorCodeFrame codeFrame={log.codeFrame} />\n <LogBoxInspectorStackFrames\n type=\"stack\"\n // eslint-disable-next-line react/jsx-no-bind\n onRetry={onRetry.bind(onRetry, \"stack\")}\n />\n {!!log?.componentStack?.length && (\n <LogBoxInspectorStackFrames\n type=\"component\"\n // eslint-disable-next-line react/jsx-no-bind\n onRetry={onRetry.bind(onRetry, \"component\")}\n />\n )}\n </>\n );\n\n if (collapsed) {\n return (\n <>\n {header}\n <ScrollView style={styles.scrollBody}>{content}</ScrollView>\n </>\n );\n }\n return (\n <ScrollView style={styles.scrollBody}>\n {header}\n {content}\n </ScrollView>\n );\n}\n\nconst styles = StyleSheet.create({\n scrollBody: {\n backgroundColor: LogBoxStyle.getBackgroundColor(1),\n flex: 1,\n },\n});\n\nexport default LogBoxData.withSubscription(LogBoxInspectorContainer);\n"]}
1
+ {"version":3,"file":"ErrorOverlay.js","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,+CAAgE;AAChE,+CAAsE;AAEtE,8DAAgD;AAEhD,kDAA4D;AAC5D,8DAAgD;AAChD,iFAA8E;AAC9E,2EAA8F;AAC9F,2EAA8F;AAC9F,yFAAsF;AACtF,qFAAkF;AAElF,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,gBAAgB;IACvB,MA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MAAM,MAAM,GAAG,CACb,8BAAC,2DAA4B,IAC3B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,EACvC,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,KAAK,EAAE,GAAG,CAAC,KAAK,EAChB,KAAK,EAAE,WAAW,GAClB,CACH,CAAC;IAEF,OAAO,CACL;QACG,SAAS,IAAI,MAAM;QACpB,8BAAC,yBAAU,IAAC,KAAK,EAAE,MAAM,CAAC,UAAU;YACjC,CAAC,SAAS,IAAI,MAAM;YAErB,8BAAC,mDAAwB,IAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAI;YACtD,8BAAC,uDAA0B,IACzB,IAAI,EAAC,OAAO;gBACZ,6CAA6C;gBAC7C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GACvC;YACD,CAAC,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,cAAc,0CAAE,MAAM,CAAA,IAAI,CAChC,8BAAC,uDAA0B,IACzB,IAAI,EAAC,WAAW;gBAChB,6CAA6C;gBAC7C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,GAC3C,CACH,CACU,CACZ,CACJ,CAAC;AACJ,CAAC;AAjDD,4DAiDC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,UAAU,EAAE;QACV,eAAe,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC,gBAAgB,CAAC,wBAAwB,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, useEffect, useState } from \"react\";\nimport { Keyboard, ScrollView, StyleSheet, View } from \"react-native\";\n\nimport * as LogBoxData from \"./Data/LogBoxData\";\nimport { LogBoxLog, StackType } from \"./Data/LogBoxLog\";\nimport { useLogs, useSelectedLog } from \"./Data/LogContext\";\nimport * as LogBoxStyle from \"./UI/LogBoxStyle\";\nimport { LogBoxInspectorCodeFrame } from \"./overlay/LogBoxInspectorCodeFrame\";\nimport { LogBoxInspectorFooter as ErrorOverlayFooter } from \"./overlay/LogBoxInspectorFooter\";\nimport { LogBoxInspectorHeader as ErrorOverlayHeader } from \"./overlay/LogBoxInspectorHeader\";\nimport { LogBoxInspectorMessageHeader } from \"./overlay/LogBoxInspectorMessageHeader\";\nimport { LogBoxInspectorStackFrames } from \"./overlay/LogBoxInspectorStackFrames\";\n\nconst HEADER_TITLE_MAP = {\n warn: \"Console Warning\",\n error: \"Console Error\",\n fatal: \"Uncaught Error\",\n syntax: \"Syntax Error\",\n static: \"Static Rendering Error (Node.js)\",\n component: \"Render Error\",\n};\n\nexport function LogBoxInspectorContainer() {\n const { selectedLogIndex, logs } = useLogs();\n const log = logs[selectedLogIndex];\n if (log == null) {\n return null;\n }\n return (\n <LogBoxInspector\n log={log}\n selectedLogIndex={selectedLogIndex}\n logs={logs}\n />\n );\n}\n\nexport function LogBoxInspector({\n log,\n selectedLogIndex,\n logs,\n}: {\n log: LogBoxLog;\n selectedLogIndex: number;\n logs: LogBoxLog[];\n}) {\n const onDismiss = useCallback((): 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 logsArray = Array.from(logs);\n if (selectedLogIndex != null) {\n if (logsArray.length - 1 <= 0) {\n LogBoxData.setSelectedLog(-1);\n } else if (selectedLogIndex >= logsArray.length - 1) {\n LogBoxData.setSelectedLog(selectedLogIndex - 1);\n }\n\n LogBoxData.dismiss(logsArray[selectedLogIndex]);\n }\n }, [selectedLogIndex]);\n\n const onMinimize = useCallback((): void => {\n LogBoxData.setSelectedLog(-1);\n }, []);\n\n const onChangeSelectedIndex = useCallback((index: number): void => {\n LogBoxData.setSelectedLog(index);\n }, []);\n\n useEffect(() => {\n if (log) {\n LogBoxData.symbolicateLogNow(\"stack\", log);\n LogBoxData.symbolicateLogNow(\"component\", log);\n }\n }, [log]);\n\n useEffect(() => {\n // Optimistically symbolicate the last and next logs.\n if (logs.length > 1) {\n const selected = selectedLogIndex;\n const lastIndex = logs.length - 1;\n const prevIndex = selected - 1 < 0 ? lastIndex : selected - 1;\n const nextIndex = selected + 1 > lastIndex ? 0 : selected + 1;\n for (const type of [\"component\", \"stack\"] as const) {\n LogBoxData.symbolicateLogLazy(type, logs[prevIndex]);\n LogBoxData.symbolicateLogLazy(type, logs[nextIndex]);\n }\n }\n }, [logs, selectedLogIndex]);\n\n useEffect(() => {\n Keyboard.dismiss();\n }, []);\n\n const _handleRetry = useCallback(\n (type: StackType) => {\n LogBoxData.retrySymbolicateLogNow(type, log);\n },\n [log]\n );\n\n return (\n <View style={[StyleSheet.absoluteFill, { flex: 1 }]}>\n <ErrorOverlayHeader\n onSelectIndex={onChangeSelectedIndex}\n level={log.level}\n />\n <ErrorOverlayBody onRetry={_handleRetry} />\n <ErrorOverlayFooter onDismiss={onDismiss} onMinimize={onMinimize} />\n </View>\n );\n}\n\nexport function ErrorOverlayBody({\n onRetry,\n}: {\n onRetry: (type: StackType) => void;\n}) {\n const log = useSelectedLog();\n return <ErrorOverlayBodyContents log={log} onRetry={onRetry} />;\n}\n\nexport function ErrorOverlayBodyContents({\n log,\n onRetry,\n}: {\n log: LogBoxLog;\n onRetry: (type: StackType) => void;\n}) {\n const [collapsed, setCollapsed] = useState(true);\n\n useEffect(() => {\n setCollapsed(true);\n }, [log]);\n\n const headerTitle =\n HEADER_TITLE_MAP[log.isComponentError ? \"component\" : log.level] ??\n log.type;\n\n const header = (\n <LogBoxInspectorMessageHeader\n collapsed={collapsed}\n onPress={() => setCollapsed(!collapsed)}\n message={log.message}\n level={log.level}\n title={headerTitle}\n />\n );\n\n return (\n <>\n {collapsed && header}\n <ScrollView style={styles.scrollBody}>\n {!collapsed && header}\n\n <LogBoxInspectorCodeFrame codeFrame={log.codeFrame} />\n <LogBoxInspectorStackFrames\n type=\"stack\"\n // eslint-disable-next-line react/jsx-no-bind\n onRetry={onRetry.bind(onRetry, \"stack\")}\n />\n {!!log?.componentStack?.length && (\n <LogBoxInspectorStackFrames\n type=\"component\"\n // eslint-disable-next-line react/jsx-no-bind\n onRetry={onRetry.bind(onRetry, \"component\")}\n />\n )}\n </ScrollView>\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n scrollBody: {\n backgroundColor: LogBoxStyle.getBackgroundColor(1),\n flex: 1,\n },\n});\n\nexport default LogBoxData.withSubscription(LogBoxInspectorContainer);\n"]}
@@ -1,2 +1,7 @@
1
- export declare function formatProjectFileName(file?: string | null): string;
1
+ import type { StackFrame } from "stacktrace-parser";
2
+ export type MetroStackFrame = StackFrame & {
3
+ collapse?: boolean;
4
+ };
5
+ export declare function formatProjectFilePath(projectRoot: string, file?: string | null): string;
6
+ export declare function getStackFormattedLocation(projectRoot: string, frame: MetroStackFrame): string;
2
7
  //# sourceMappingURL=formatProjectFilePath.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatProjectFilePath.d.ts","sourceRoot":"","sources":["../../src/error-overlay/formatProjectFilePath.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAYlE"}
1
+ {"version":3,"file":"formatProjectFilePath.d.ts","sourceRoot":"","sources":["../../src/error-overlay/formatProjectFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAElE,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GACnB,MAAM,CASR;AAeD,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,eAAe,UAYvB"}