@expo/metro-runtime 2.2.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +17 -1
  2. package/async-require.d.ts +1 -1
  3. package/async-require.js +1 -1
  4. package/build/HMRClient.d.ts +1 -1
  5. package/build/HMRClient.d.ts.map +1 -1
  6. package/build/HMRClient.js +40 -68
  7. package/build/HMRClient.js.map +1 -1
  8. package/build/HMRClient.native.js +2 -4
  9. package/build/HMRClient.native.js.map +1 -1
  10. package/build/LoadingView.d.ts +1 -1
  11. package/build/LoadingView.d.ts.map +1 -1
  12. package/build/LoadingView.js +4 -10
  13. package/build/LoadingView.js.map +1 -1
  14. package/build/LoadingView.native.d.ts +2 -0
  15. package/build/LoadingView.native.d.ts.map +1 -1
  16. package/build/LoadingView.native.js +2 -2
  17. package/build/LoadingView.native.js.map +1 -1
  18. package/build/async-require/buildAsyncRequire.js +3 -7
  19. package/build/async-require/buildAsyncRequire.js.map +1 -1
  20. package/build/async-require/buildUrlForBundle.js +2 -6
  21. package/build/async-require/buildUrlForBundle.js.map +1 -1
  22. package/build/async-require/buildUrlForBundle.native.js +6 -9
  23. package/build/async-require/buildUrlForBundle.native.js.map +1 -1
  24. package/build/async-require/fetchAsync.d.ts.map +1 -1
  25. package/build/async-require/fetchAsync.js +4 -8
  26. package/build/async-require/fetchAsync.js.map +1 -1
  27. package/build/async-require/fetchAsync.native.d.ts +1 -1
  28. package/build/async-require/fetchAsync.native.d.ts.map +1 -1
  29. package/build/async-require/fetchAsync.native.js +14 -21
  30. package/build/async-require/fetchAsync.native.js.map +1 -1
  31. package/build/async-require/fetchThenEval.d.ts.map +1 -1
  32. package/build/async-require/fetchThenEval.js +5 -10
  33. package/build/async-require/fetchThenEval.js.map +1 -1
  34. package/build/async-require/fetchThenEval.web.d.ts.map +1 -1
  35. package/build/async-require/fetchThenEval.web.js +14 -27
  36. package/build/async-require/fetchThenEval.web.js.map +1 -1
  37. package/build/async-require/index.js +2 -6
  38. package/build/async-require/index.js.map +1 -1
  39. package/build/async-require/loadBundle.d.ts.map +1 -1
  40. package/build/async-require/loadBundle.js +14 -18
  41. package/build/async-require/loadBundle.js.map +1 -1
  42. package/build/effects.js +5 -7
  43. package/build/effects.js.map +1 -1
  44. package/build/effects.native.js +0 -1
  45. package/build/error-overlay/Data/LogBoxData.d.ts +5 -5
  46. package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
  47. package/build/error-overlay/Data/LogBoxData.js +76 -127
  48. package/build/error-overlay/Data/LogBoxData.js.map +1 -1
  49. package/build/error-overlay/Data/LogBoxLog.d.ts +10 -10
  50. package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -1
  51. package/build/error-overlay/Data/LogBoxLog.js +46 -69
  52. package/build/error-overlay/Data/LogBoxLog.js.map +1 -1
  53. package/build/error-overlay/Data/LogBoxSymbolication.d.ts +2 -2
  54. package/build/error-overlay/Data/LogBoxSymbolication.js +9 -17
  55. package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -1
  56. package/build/error-overlay/Data/LogContext.d.ts +2 -2
  57. package/build/error-overlay/Data/LogContext.d.ts.map +1 -1
  58. package/build/error-overlay/Data/LogContext.js +12 -20
  59. package/build/error-overlay/Data/LogContext.js.map +1 -1
  60. package/build/error-overlay/Data/parseLogBoxLog.d.ts +2 -2
  61. package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
  62. package/build/error-overlay/Data/parseLogBoxLog.js +35 -50
  63. package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
  64. package/build/error-overlay/ErrorOverlay.d.ts +10 -3
  65. package/build/error-overlay/ErrorOverlay.d.ts.map +1 -1
  66. package/build/error-overlay/ErrorOverlay.js +55 -86
  67. package/build/error-overlay/ErrorOverlay.js.map +1 -1
  68. package/build/error-overlay/LogBox.d.ts +2 -2
  69. package/build/error-overlay/LogBox.d.ts.map +1 -1
  70. package/build/error-overlay/LogBox.js +1 -4
  71. package/build/error-overlay/LogBox.js.map +1 -1
  72. package/build/error-overlay/LogBox.web.d.ts +3 -3
  73. package/build/error-overlay/LogBox.web.d.ts.map +1 -1
  74. package/build/error-overlay/LogBox.web.js +12 -17
  75. package/build/error-overlay/LogBox.web.js.map +1 -1
  76. package/build/error-overlay/UI/AnsiHighlight.d.ts +2 -2
  77. package/build/error-overlay/UI/AnsiHighlight.d.ts.map +1 -1
  78. package/build/error-overlay/UI/AnsiHighlight.js +28 -36
  79. package/build/error-overlay/UI/AnsiHighlight.js.map +1 -1
  80. package/build/error-overlay/UI/LogBoxButton.d.ts +1 -1
  81. package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -1
  82. package/build/error-overlay/UI/LogBoxButton.js +18 -44
  83. package/build/error-overlay/UI/LogBoxButton.js.map +1 -1
  84. package/build/error-overlay/UI/LogBoxMessage.d.ts +2 -2
  85. package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -1
  86. package/build/error-overlay/UI/LogBoxMessage.js +10 -17
  87. package/build/error-overlay/UI/LogBoxMessage.js.map +1 -1
  88. package/build/error-overlay/UI/LogBoxStyle.d.ts +1 -1
  89. package/build/error-overlay/UI/LogBoxStyle.js +15 -32
  90. package/build/error-overlay/UI/LogBoxStyle.js.map +1 -1
  91. package/build/error-overlay/UI/constants.js +5 -8
  92. package/build/error-overlay/UI/constants.js.map +1 -1
  93. package/build/error-overlay/formatProjectFilePath.d.ts +1 -1
  94. package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -1
  95. package/build/error-overlay/formatProjectFilePath.js +7 -14
  96. package/build/error-overlay/formatProjectFilePath.js.map +1 -1
  97. package/build/error-overlay/index.d.ts +1 -1
  98. package/build/error-overlay/index.d.ts.map +1 -1
  99. package/build/error-overlay/index.js +9 -17
  100. package/build/error-overlay/index.js.map +1 -1
  101. package/build/error-overlay/modules/ExceptionsManager/index.d.ts +1 -1
  102. package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -1
  103. package/build/error-overlay/modules/ExceptionsManager/index.js +11 -21
  104. package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -1
  105. package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts +2 -1
  106. package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts.map +1 -1
  107. package/build/error-overlay/modules/ExceptionsManager/index.native.js +3 -3
  108. package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -1
  109. package/build/error-overlay/modules/NativeLogBox/index.d.ts.map +1 -1
  110. package/build/error-overlay/modules/NativeLogBox/index.js +10 -15
  111. package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -1
  112. package/build/error-overlay/modules/NativeLogBox/index.native.d.ts +1 -1
  113. package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -1
  114. package/build/error-overlay/modules/NativeLogBox/index.native.js +2 -8
  115. package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -1
  116. package/build/error-overlay/modules/openFileInEditor/index.js +5 -7
  117. package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -1
  118. package/build/error-overlay/modules/openFileInEditor/index.native.d.ts +1 -1
  119. package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -1
  120. package/build/error-overlay/modules/openFileInEditor/index.native.js +2 -8
  121. package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -1
  122. package/build/error-overlay/modules/parseErrorStack/index.d.ts +1 -1
  123. package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -1
  124. package/build/error-overlay/modules/parseErrorStack/index.js +4 -7
  125. package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -1
  126. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts +1 -1
  127. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js +2 -8
  128. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -1
  129. package/build/error-overlay/modules/stringifySafe/index.d.ts +1 -1
  130. package/build/error-overlay/modules/stringifySafe/index.d.ts.map +1 -1
  131. package/build/error-overlay/modules/stringifySafe/index.js +16 -22
  132. package/build/error-overlay/modules/stringifySafe/index.js.map +1 -1
  133. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +2 -2
  134. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -1
  135. package/build/error-overlay/modules/symbolicateStackTrace/index.js +6 -8
  136. package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -1
  137. package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts +1 -1
  138. package/build/error-overlay/modules/symbolicateStackTrace/index.native.js +2 -7
  139. package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -1
  140. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +2 -2
  141. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
  142. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +28 -58
  143. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
  144. package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -1
  145. package/build/error-overlay/overlay/LogBoxInspectorFooter.js +35 -64
  146. package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -1
  147. package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +1 -1
  148. package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -1
  149. package/build/error-overlay/overlay/LogBoxInspectorHeader.js +37 -71
  150. package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -1
  151. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +2 -2
  152. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -1
  153. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +20 -54
  154. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -1
  155. package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +2 -2
  156. package/build/error-overlay/overlay/LogBoxInspectorSection.js +13 -43
  157. package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -1
  158. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +2 -2
  159. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -1
  160. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +26 -55
  161. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -1
  162. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +2 -2
  163. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -1
  164. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +23 -53
  165. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -1
  166. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +2 -2
  167. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -1
  168. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +42 -76
  169. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -1
  170. package/build/error-overlay/toast/ErrorToast.d.ts +2 -2
  171. package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -1
  172. package/build/error-overlay/toast/ErrorToast.js +44 -72
  173. package/build/error-overlay/toast/ErrorToast.js.map +1 -1
  174. package/build/error-overlay/toast/ErrorToastContainer.d.ts +1 -1
  175. package/build/error-overlay/toast/ErrorToastContainer.js +3 -9
  176. package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -1
  177. package/build/error-overlay/toast/ErrorToastContainer.web.d.ts +2 -2
  178. package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -1
  179. package/build/error-overlay/toast/ErrorToastContainer.web.js +22 -49
  180. package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -1
  181. package/build/error-overlay/toast/ErrorToastMessage.d.ts +1 -1
  182. package/build/error-overlay/toast/ErrorToastMessage.d.ts.map +1 -1
  183. package/build/error-overlay/toast/ErrorToastMessage.js +8 -37
  184. package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -1
  185. package/build/error-overlay/useRejectionHandler.d.ts +1 -1
  186. package/build/error-overlay/useRejectionHandler.d.ts.map +1 -1
  187. package/build/error-overlay/useRejectionHandler.js +20 -28
  188. package/build/error-overlay/useRejectionHandler.js.map +1 -1
  189. package/build/getDevServer.d.ts.map +1 -1
  190. package/build/getDevServer.js +10 -16
  191. package/build/getDevServer.js.map +1 -1
  192. package/build/getDevServer.native.d.ts +2 -0
  193. package/build/getDevServer.native.d.ts.map +1 -1
  194. package/build/getDevServer.native.js +2 -2
  195. package/build/getDevServer.native.js.map +1 -1
  196. package/build/index.d.ts +2 -2
  197. package/build/index.js +4 -6
  198. package/build/index.js.map +1 -1
  199. package/build/location/Location.js +2 -7
  200. package/build/location/Location.js.map +1 -1
  201. package/build/location/Location.native.d.ts.map +1 -1
  202. package/build/location/Location.native.js +25 -32
  203. package/build/location/Location.native.js.map +1 -1
  204. package/build/location/install.js +0 -1
  205. package/build/location/install.native.d.ts +1 -1
  206. package/build/location/install.native.js +23 -34
  207. package/build/location/install.native.js.map +1 -1
  208. package/build/messageSocket.d.ts.map +1 -1
  209. package/build/messageSocket.js +5 -6
  210. package/build/messageSocket.js.map +1 -1
  211. package/build/setupFastRefresh.d.ts.map +1 -1
  212. package/build/setupFastRefresh.js +2 -4
  213. package/build/setupFastRefresh.js.map +1 -1
  214. package/build/setupHMR.js +5 -12
  215. package/build/setupHMR.js.map +1 -1
  216. package/build/symbolicate.d.ts +3 -3
  217. package/build/symbolicate.js +4 -25
  218. package/build/symbolicate.js.map +1 -1
  219. package/error-overlay.d.ts +1 -1
  220. package/error-overlay.js +1 -1
  221. package/package.json +25 -14
  222. package/LICENSE +0 -13
@@ -1,36 +1,29 @@
1
- "use strict";
2
1
  /**
3
- * Copyright (c) Evan Bacon.
2
+ * Copyright (c) 650 Industries.
4
3
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
4
  *
6
5
  * This source code is licensed under the MIT license found in the
7
6
  * LICENSE file in the root directory of this source tree.
8
7
  */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.parseLogBoxLog = exports.parseLogBoxException = exports.parseComponentStack = exports.parseInterpolation = void 0;
14
- // @ts-expect-error
15
- const UTFSequence_1 = __importDefault(require("react-native/Libraries/UTFSequence"));
16
- const parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
17
- const stringifySafe_1 = __importDefault(require("../modules/stringifySafe"));
8
+ import UTFSequence from 'react-native/Libraries/UTFSequence';
9
+ import parseErrorStack from '../modules/parseErrorStack';
10
+ import stringifySafe from '../modules/stringifySafe';
18
11
  const BABEL_TRANSFORM_ERROR_FORMAT = /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/;
19
12
  const BABEL_CODE_FRAME_ERROR_FORMAT = /^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\u{001b}[\s\S]+)/u;
20
13
  const METRO_ERROR_FORMAT = /^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/u;
21
- const SUBSTITUTION = UTFSequence_1.default.BOM + "%s";
22
- function parseInterpolation(args) {
14
+ const SUBSTITUTION = UTFSequence.BOM + '%s';
15
+ export function parseInterpolation(args) {
23
16
  const categoryParts = [];
24
17
  const contentParts = [];
25
18
  const substitutionOffsets = [];
26
19
  const remaining = [...args];
27
- if (typeof remaining[0] === "string") {
20
+ if (typeof remaining[0] === 'string') {
28
21
  const formatString = String(remaining.shift());
29
- const formatStringParts = formatString.split("%s");
22
+ const formatStringParts = formatString.split('%s');
30
23
  const substitutionCount = formatStringParts.length - 1;
31
24
  const substitutions = remaining.splice(0, substitutionCount);
32
- let categoryString = "";
33
- let contentString = "";
25
+ let categoryString = '';
26
+ let contentString = '';
34
27
  let substitutionIndex = 0;
35
28
  for (const formatStringPart of formatStringParts) {
36
29
  categoryString += formatStringPart;
@@ -40,9 +33,9 @@ function parseInterpolation(args) {
40
33
  // Don't stringify a string type.
41
34
  // It adds quotation mark wrappers around the string,
42
35
  // which causes the LogBox to look odd.
43
- const substitution = typeof substitutions[substitutionIndex] === "string"
36
+ const substitution = typeof substitutions[substitutionIndex] === 'string'
44
37
  ? substitutions[substitutionIndex]
45
- : (0, stringifySafe_1.default)(substitutions[substitutionIndex]);
38
+ : stringifySafe(substitutions[substitutionIndex]);
46
39
  substitutionOffsets.push({
47
40
  length: substitution.length,
48
41
  offset: contentString.length,
@@ -55,8 +48,8 @@ function parseInterpolation(args) {
55
48
  length: 2,
56
49
  offset: contentString.length,
57
50
  });
58
- categoryString += "%s";
59
- contentString += "%s";
51
+ categoryString += '%s';
52
+ contentString += '%s';
60
53
  }
61
54
  substitutionIndex++;
62
55
  }
@@ -68,37 +61,34 @@ function parseInterpolation(args) {
68
61
  // Don't stringify a string type.
69
62
  // It adds quotation mark wrappers around the string,
70
63
  // which causes the LogBox to look odd.
71
- return typeof arg === "string" ? arg : (0, stringifySafe_1.default)(arg);
64
+ return typeof arg === 'string' ? arg : stringifySafe(arg);
72
65
  });
73
66
  categoryParts.push(...remainingArgs);
74
67
  contentParts.push(...remainingArgs);
75
68
  return {
76
- category: categoryParts.join(" "),
69
+ category: categoryParts.join(' '),
77
70
  message: {
78
- content: contentParts.join(" "),
71
+ content: contentParts.join(' '),
79
72
  substitutions: substitutionOffsets,
80
73
  },
81
74
  };
82
75
  }
83
- exports.parseInterpolation = parseInterpolation;
84
76
  function isComponentStack(consoleArgument) {
85
77
  const isOldComponentStackFormat = / {4}in/.test(consoleArgument);
86
78
  const isNewComponentStackFormat = / {4}at/.test(consoleArgument);
87
79
  const isNewJSCComponentStackFormat = /@.*\n/.test(consoleArgument);
88
- return (isOldComponentStackFormat ||
89
- isNewComponentStackFormat ||
90
- isNewJSCComponentStackFormat);
80
+ return isOldComponentStackFormat || isNewComponentStackFormat || isNewJSCComponentStackFormat;
91
81
  }
92
- function parseComponentStack(message) {
82
+ export function parseComponentStack(message) {
93
83
  // In newer versions of React, the component stack is formatted as a call stack frame.
94
84
  // First try to parse the component stack as a call stack frame, and if that doesn't
95
85
  // work then we'll fallback to the old custom component stack format parsing.
96
- const stack = (0, parseErrorStack_1.default)(message);
86
+ const stack = parseErrorStack(message);
97
87
  if (stack && stack.length > 0) {
98
88
  return stack.map((frame) => ({
99
89
  content: frame.methodName,
100
90
  collapse: frame.collapse || false,
101
- fileName: frame.file == null ? "unknown" : frame.file,
91
+ fileName: frame.file == null ? 'unknown' : frame.file,
102
92
  location: {
103
93
  column: frame.column == null ? -1 : frame.column,
104
94
  row: frame.lineNumber == null ? -1 : frame.lineNumber,
@@ -124,15 +114,14 @@ function parseComponentStack(message) {
124
114
  })
125
115
  .filter(Boolean);
126
116
  }
127
- exports.parseComponentStack = parseComponentStack;
128
- function parseLogBoxException(error) {
129
- const message = error.originalMessage != null ? error.originalMessage : "Unknown";
117
+ export function parseLogBoxException(error) {
118
+ const message = error.originalMessage != null ? error.originalMessage : 'Unknown';
130
119
  const metroInternalError = message.match(METRO_ERROR_FORMAT);
131
120
  if (metroInternalError) {
132
121
  const [content, fileName, row, column, codeFrame] = metroInternalError.slice(1);
133
122
  return {
134
- level: "fatal",
135
- type: "Metro Error",
123
+ level: 'fatal',
124
+ type: 'Metro Error',
136
125
  stack: [],
137
126
  isComponentError: false,
138
127
  componentStack: [],
@@ -156,7 +145,7 @@ function parseLogBoxException(error) {
156
145
  // Transform errors are thrown from inside the Babel transformer.
157
146
  const [fileName, content, row, column, codeFrame] = babelTransformError.slice(1);
158
147
  return {
159
- level: "syntax",
148
+ level: 'syntax',
160
149
  stack: [],
161
150
  isComponentError: false,
162
151
  componentStack: [],
@@ -180,7 +169,7 @@ function parseLogBoxException(error) {
180
169
  // Codeframe errors are thrown from any use of buildCodeFrameError.
181
170
  const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);
182
171
  return {
183
- level: "syntax",
172
+ level: 'syntax',
184
173
  stack: [],
185
174
  isComponentError: false,
186
175
  componentStack: [],
@@ -198,7 +187,7 @@ function parseLogBoxException(error) {
198
187
  }
199
188
  if (message.match(/^TransformError /)) {
200
189
  return {
201
- level: "syntax",
190
+ level: 'syntax',
202
191
  stack: error.stack,
203
192
  isComponentError: error.isComponentError,
204
193
  componentStack: [],
@@ -212,7 +201,7 @@ function parseLogBoxException(error) {
212
201
  const componentStack = error.componentStack;
213
202
  if (error.isFatal || error.isComponentError) {
214
203
  return {
215
- level: "fatal",
204
+ level: 'fatal',
216
205
  stack: error.stack,
217
206
  isComponentError: error.isComponentError,
218
207
  componentStack: componentStack != null ? parseComponentStack(componentStack) : [],
@@ -222,7 +211,7 @@ function parseLogBoxException(error) {
222
211
  if (componentStack != null) {
223
212
  // It is possible that console errors have a componentStack.
224
213
  return {
225
- level: "error",
214
+ level: 'error',
226
215
  stack: error.stack,
227
216
  isComponentError: error.isComponentError,
228
217
  componentStack: parseComponentStack(componentStack),
@@ -232,23 +221,20 @@ function parseLogBoxException(error) {
232
221
  // Most `console.error` calls won't have a componentStack. We parse them like
233
222
  // regular logs which have the component stack burried in the message.
234
223
  return {
235
- level: "error",
224
+ level: 'error',
236
225
  stack: error.stack,
237
226
  isComponentError: error.isComponentError,
238
227
  ...parseLogBoxLog([message]),
239
228
  };
240
229
  }
241
- exports.parseLogBoxException = parseLogBoxException;
242
- function parseLogBoxLog(args) {
230
+ export function parseLogBoxLog(args) {
243
231
  const message = args[0];
244
232
  let argsWithoutComponentStack = [];
245
233
  let componentStack = [];
246
234
  // Extract component stack from warnings like "Some warning%s".
247
- if (typeof message === "string" &&
248
- message.slice(-2) === "%s" &&
249
- args.length > 0) {
235
+ if (typeof message === 'string' && message.slice(-2) === '%s' && args.length > 0) {
250
236
  const lastArg = args[args.length - 1];
251
- if (typeof lastArg === "string" && isComponentStack(lastArg)) {
237
+ if (typeof lastArg === 'string' && isComponentStack(lastArg)) {
252
238
  argsWithoutComponentStack = args.slice(0, -1);
253
239
  argsWithoutComponentStack[0] = message.slice(0, -2);
254
240
  componentStack = parseComponentStack(lastArg);
@@ -257,7 +243,7 @@ function parseLogBoxLog(args) {
257
243
  if (componentStack.length === 0) {
258
244
  // Try finding the component stack elsewhere.
259
245
  for (const arg of args) {
260
- if (typeof arg === "string" && isComponentStack(arg)) {
246
+ if (typeof arg === 'string' && isComponentStack(arg)) {
261
247
  // Strip out any messages before the component stack.
262
248
  let messageEndIndex = arg.search(/\n {4}(in|at) /);
263
249
  if (messageEndIndex < 0) {
@@ -279,5 +265,4 @@ function parseLogBoxLog(args) {
279
265
  componentStack,
280
266
  };
281
267
  }
282
- exports.parseLogBoxLog = parseLogBoxLog;
283
268
  //# sourceMappingURL=parseLogBoxLog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseLogBoxLog.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/parseLogBoxLog.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH,mBAAmB;AACnB,qFAA6D;AAE7D,iFAAyD;AACzD,6EAAqD;AAIrD,MAAM,4BAA4B,GAChC,gGAAgG,CAAC;AACnG,MAAM,6BAA6B,GACjC,sGAAsG,CAAC;AACzG,MAAM,kBAAkB,GACtB,6FAA6F,CAAC;AAgChG,MAAM,YAAY,GAAG,qBAAW,CAAC,GAAG,GAAG,IAAI,CAAC;AAE5C,SAAgB,kBAAkB,CAAC,IAAoB;IAIrD,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,mBAAmB,GAAyC,EAAE,CAAC;IAErE,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5B,IAAI,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACpC,MAAM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E;YAC5D,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9C,yBAAyB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACpD,cAAc,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;SAC/C;KACF;IAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,6CAA6C;QAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE;gBACpD,qDAAqD;gBACrD,IAAI,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;gBACnD,IAAI,eAAe,GAAG,CAAC,EAAE;oBACvB,+BAA+B;oBAC/B,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iBACpC;gBACD,IAAI,eAAe,GAAG,CAAC,EAAE;oBACvB,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;iBAC/D;gBAED,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;aAC3C;iBAAM;gBACL,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACrC;SACF;KACF;IAED,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
+ {"version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AC,IAAI,CAAC,CAAC;iBACpC;gBACD,IAAI,eAAe,GAAG,CAAC,EAAE;oBACvB,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;iBAC/D;gBAED,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;aAC3C;iBAAM;gBACL,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACrC;SACF;KACF;IAED,OAAO;QACL,GAAG,kBAAkB,CAAC,yBAAyB,CAAC;QAChD,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport UTFSequence from 'react-native/Libraries/UTFSequence';\n\nimport parseErrorStack from '../modules/parseErrorStack';\nimport stringifySafe from '../modules/stringifySafe';\nimport type { LogBoxLogData } from './LogBoxLog';\ntype ExceptionData = any;\n\nconst BABEL_TRANSFORM_ERROR_FORMAT =\n /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \\((\\d+):(\\d+)\\)\\n\\n([\\s\\S]+)/;\nconst BABEL_CODE_FRAME_ERROR_FORMAT =\n /^(?:TransformError )?(?:.*):? (?:.*?)(\\/.*): ([\\s\\S]+?)\\n([ >]{2}[\\d\\s]+ \\|[\\s\\S]+|\\u{001b}[\\s\\S]+)/u;\nconst METRO_ERROR_FORMAT =\n /^(?:InternalError Metro has encountered an error:) (.*): (.*) \\((\\d+):(\\d+)\\)\\n\\n([\\s\\S]+)/u;\n\nexport type ExtendedExceptionData = ExceptionData & {\n isComponentError: boolean;\n [key: string]: any;\n};\nexport type Category = string;\nexport type CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n } | null;\n fileName: string;\n\n // TODO: When React switched to using call stack frames,\n // we gained the ability to use the collapse flag, but\n // it is not integrated into the LogBox UI.\n collapse?: boolean;\n};\n\nexport type Message = {\n content: string;\n substitutions: {\n length: number;\n offset: number;\n }[];\n};\n\nexport type ComponentStack = CodeFrame[];\n\nconst SUBSTITUTION = UTFSequence.BOM + '%s';\n\nexport function parseInterpolation(args: readonly any[]): {\n category: Category;\n message: Message;\n} {\n const categoryParts: string[] = [];\n const contentParts: string[] = [];\n const substitutionOffsets: { length: number; offset: number }[] = [];\n\n const remaining = [...args];\n if (typeof remaining[0] === 'string') {\n const formatString = String(remaining.shift());\n const formatStringParts = formatString.split('%s');\n const substitutionCount = formatStringParts.length - 1;\n const substitutions = remaining.splice(0, substitutionCount);\n\n let categoryString = '';\n let contentString = '';\n\n let substitutionIndex = 0;\n for (const formatStringPart of formatStringParts) {\n categoryString += formatStringPart;\n contentString += formatStringPart;\n\n if (substitutionIndex < substitutionCount) {\n if (substitutionIndex < substitutions.length) {\n // Don't stringify a string type.\n // It adds quotation mark wrappers around the string,\n // which causes the LogBox to look odd.\n const substitution =\n typeof substitutions[substitutionIndex] === 'string'\n ? substitutions[substitutionIndex]\n : stringifySafe(substitutions[substitutionIndex]);\n substitutionOffsets.push({\n length: substitution.length,\n offset: contentString.length,\n });\n\n categoryString += SUBSTITUTION;\n contentString += substitution;\n } else {\n substitutionOffsets.push({\n length: 2,\n offset: contentString.length,\n });\n\n categoryString += '%s';\n contentString += '%s';\n }\n\n substitutionIndex++;\n }\n }\n\n categoryParts.push(categoryString);\n contentParts.push(contentString);\n }\n\n const remainingArgs = remaining.map((arg) => {\n // Don't stringify a string type.\n // It adds quotation mark wrappers around the string,\n // which causes the LogBox to look odd.\n return typeof arg === 'string' ? arg : stringifySafe(arg);\n });\n categoryParts.push(...remainingArgs);\n contentParts.push(...remainingArgs);\n\n return {\n category: categoryParts.join(' '),\n message: {\n content: contentParts.join(' '),\n substitutions: substitutionOffsets,\n },\n };\n}\n\nfunction isComponentStack(consoleArgument: string) {\n const isOldComponentStackFormat = / {4}in/.test(consoleArgument);\n const isNewComponentStackFormat = / {4}at/.test(consoleArgument);\n const isNewJSCComponentStackFormat = /@.*\\n/.test(consoleArgument);\n\n return isOldComponentStackFormat || isNewComponentStackFormat || isNewJSCComponentStackFormat;\n}\n\nexport function parseComponentStack(message: string): ComponentStack {\n // In newer versions of React, the component stack is formatted as a call stack frame.\n // First try to parse the component stack as a call stack frame, and if that doesn't\n // work then we'll fallback to the old custom component stack format parsing.\n const stack = parseErrorStack(message);\n if (stack && stack.length > 0) {\n return stack.map((frame) => ({\n content: frame.methodName,\n collapse: frame.collapse || false,\n fileName: frame.file == null ? 'unknown' : frame.file,\n location: {\n column: frame.column == null ? -1 : frame.column,\n row: frame.lineNumber == null ? -1 : frame.lineNumber,\n },\n }));\n }\n\n return message\n .split(/\\n {4}in /g)\n .map((s) => {\n if (!s) {\n return null;\n }\n const match = s.match(/(.*) \\(at (.*\\.js):([\\d]+)\\)/);\n if (!match) {\n return null;\n }\n\n const [content, fileName, row] = match.slice(1);\n return {\n content,\n fileName,\n location: { column: -1, row: parseInt(row, 10) },\n };\n })\n .filter(Boolean) as ComponentStack;\n}\n\nexport function parseLogBoxException(error: ExtendedExceptionData): LogBoxLogData {\n const message = error.originalMessage != null ? error.originalMessage : 'Unknown';\n\n const metroInternalError = message.match(METRO_ERROR_FORMAT);\n if (metroInternalError) {\n const [content, fileName, row, column, codeFrame] = metroInternalError.slice(1);\n\n return {\n level: 'fatal',\n type: 'Metro Error',\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelTransformError = message.match(BABEL_TRANSFORM_ERROR_FORMAT);\n if (babelTransformError) {\n // Transform errors are thrown from inside the Babel transformer.\n const [fileName, content, row, column, codeFrame] = babelTransformError.slice(1);\n\n return {\n level: 'syntax',\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: {\n row: parseInt(row, 10),\n column: parseInt(column, 10),\n },\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${row}-${column}`,\n };\n }\n\n const babelCodeFrameError = message.match(BABEL_CODE_FRAME_ERROR_FORMAT);\n\n if (babelCodeFrameError) {\n // Codeframe errors are thrown from any use of buildCodeFrameError.\n const [fileName, content, codeFrame] = babelCodeFrameError.slice(1);\n return {\n level: 'syntax',\n stack: [],\n isComponentError: false,\n componentStack: [],\n codeFrame: {\n fileName,\n location: null, // We are not given the location.\n content: codeFrame,\n },\n message: {\n content,\n substitutions: [],\n },\n category: `${fileName}-${1}-${1}`,\n };\n }\n\n if (message.match(/^TransformError /)) {\n return {\n level: 'syntax',\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: [],\n message: {\n content: message,\n substitutions: [],\n },\n category: message,\n };\n }\n\n const componentStack = error.componentStack;\n if (error.isFatal || error.isComponentError) {\n return {\n level: 'fatal',\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: componentStack != null ? parseComponentStack(componentStack) : [],\n ...parseInterpolation([message]),\n };\n }\n\n if (componentStack != null) {\n // It is possible that console errors have a componentStack.\n return {\n level: 'error',\n stack: error.stack,\n isComponentError: error.isComponentError,\n componentStack: parseComponentStack(componentStack),\n ...parseInterpolation([message]),\n };\n }\n\n // Most `console.error` calls won't have a componentStack. We parse them like\n // regular logs which have the component stack burried in the message.\n return {\n level: 'error',\n stack: error.stack,\n isComponentError: error.isComponentError,\n ...parseLogBoxLog([message]),\n };\n}\n\nexport function parseLogBoxLog(args: readonly any[]): {\n componentStack: ComponentStack;\n category: Category;\n message: Message;\n} {\n const message = args[0];\n let argsWithoutComponentStack: any[] = [];\n let componentStack: ComponentStack = [];\n\n // Extract component stack from warnings like \"Some warning%s\".\n if (typeof message === 'string' && message.slice(-2) === '%s' && args.length > 0) {\n const lastArg = args[args.length - 1];\n if (typeof lastArg === 'string' && isComponentStack(lastArg)) {\n argsWithoutComponentStack = args.slice(0, -1);\n argsWithoutComponentStack[0] = message.slice(0, -2);\n componentStack = parseComponentStack(lastArg);\n }\n }\n\n if (componentStack.length === 0) {\n // Try finding the component stack elsewhere.\n for (const arg of args) {\n if (typeof arg === 'string' && isComponentStack(arg)) {\n // Strip out any messages before the component stack.\n let messageEndIndex = arg.search(/\\n {4}(in|at) /);\n if (messageEndIndex < 0) {\n // Handle JSC component stacks.\n messageEndIndex = arg.search(/\\n/);\n }\n if (messageEndIndex > 0) {\n argsWithoutComponentStack.push(arg.slice(0, messageEndIndex));\n }\n\n componentStack = parseComponentStack(arg);\n } else {\n argsWithoutComponentStack.push(arg);\n }\n }\n }\n\n return {\n ...parseInterpolation(argsWithoutComponentStack),\n componentStack,\n };\n}\n"]}
@@ -1,12 +1,19 @@
1
- import React from "react";
2
- import { LogBoxLog, StackType } from "./Data/LogBoxLog";
1
+ /**
2
+ * Copyright (c) 650 Industries.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import React from 'react';
9
+ import { LogBoxLog, StackType } from './Data/LogBoxLog';
3
10
  export declare function LogBoxInspectorContainer(): JSX.Element | null;
4
11
  export declare function LogBoxInspector({ log, selectedLogIndex, logs, }: {
5
12
  log: LogBoxLog;
6
13
  selectedLogIndex: number;
7
14
  logs: LogBoxLog[];
8
15
  }): JSX.Element;
9
- export declare function ErrorOverlayBody({ onRetry, }: {
16
+ export declare function ErrorOverlayBody({ onRetry }: {
10
17
  onRetry: (type: StackType) => void;
11
18
  }): JSX.Element;
12
19
  export declare function ErrorOverlayBodyContents({ log, onRetry, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorOverlay.d.ts","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":"AAQA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,OAAO,EAAE,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AAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC,eAyCA;;AAmBD,wBAAqE"}
@@ -1,66 +1,38 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ErrorOverlayBodyContents = exports.ErrorOverlayBody = exports.LogBoxInspector = exports.LogBoxInspectorContainer = void 0;
27
1
  /**
28
- * Copyright (c) Evan Bacon.
2
+ * Copyright (c) 650 Industries.
29
3
  * Copyright (c) Meta Platforms, Inc. and affiliates.
30
4
  *
31
5
  * This source code is licensed under the MIT license found in the
32
6
  * LICENSE file in the root directory of this source tree.
33
7
  */
34
- const react_views_1 = require("@bacons/react-views");
35
- const react_1 = __importStar(require("react"));
36
- const react_native_1 = require("react-native");
37
- const LogBoxData = __importStar(require("./Data/LogBoxData"));
38
- const LogContext_1 = require("./Data/LogContext");
39
- const LogBoxStyle = __importStar(require("./UI/LogBoxStyle"));
40
- const LogBoxInspectorCodeFrame_1 = require("./overlay/LogBoxInspectorCodeFrame");
41
- const LogBoxInspectorFooter_1 = require("./overlay/LogBoxInspectorFooter");
42
- const LogBoxInspectorHeader_1 = require("./overlay/LogBoxInspectorHeader");
43
- const LogBoxInspectorMessageHeader_1 = require("./overlay/LogBoxInspectorMessageHeader");
44
- const LogBoxInspectorStackFrames_1 = require("./overlay/LogBoxInspectorStackFrames");
8
+ import React, { useCallback, useEffect, useState } from 'react';
9
+ import { Keyboard, ScrollView, View, StyleSheet } from 'react-native';
10
+ import * as LogBoxData from './Data/LogBoxData';
11
+ import { useLogs, useSelectedLog } from './Data/LogContext';
12
+ import * as LogBoxStyle from './UI/LogBoxStyle';
13
+ import { LogBoxInspectorCodeFrame } from './overlay/LogBoxInspectorCodeFrame';
14
+ import { LogBoxInspectorFooter as ErrorOverlayFooter } from './overlay/LogBoxInspectorFooter';
15
+ import { LogBoxInspectorHeader as ErrorOverlayHeader } from './overlay/LogBoxInspectorHeader';
16
+ import { LogBoxInspectorMessageHeader } from './overlay/LogBoxInspectorMessageHeader';
17
+ import { LogBoxInspectorStackFrames } from './overlay/LogBoxInspectorStackFrames';
45
18
  const HEADER_TITLE_MAP = {
46
- warn: "Console Warning",
47
- error: "Console Error",
48
- fatal: "Uncaught Error",
49
- syntax: "Syntax Error",
50
- static: "Static Rendering Error (Node.js)",
51
- component: "Render Error",
19
+ warn: 'Console Warning',
20
+ error: 'Console Error',
21
+ fatal: 'Uncaught Error',
22
+ syntax: 'Syntax Error',
23
+ static: 'Static Rendering Error (Node.js)',
24
+ component: 'Render Error',
52
25
  };
53
- function LogBoxInspectorContainer() {
54
- const { selectedLogIndex, logs } = (0, LogContext_1.useLogs)();
26
+ export function LogBoxInspectorContainer() {
27
+ const { selectedLogIndex, logs } = useLogs();
55
28
  const log = logs[selectedLogIndex];
56
29
  if (log == null) {
57
30
  return null;
58
31
  }
59
- return (react_1.default.createElement(LogBoxInspector, { log: log, selectedLogIndex: selectedLogIndex, logs: logs }));
32
+ return React.createElement(LogBoxInspector, { log: log, selectedLogIndex: selectedLogIndex, logs: logs });
60
33
  }
61
- exports.LogBoxInspectorContainer = LogBoxInspectorContainer;
62
- function LogBoxInspector({ log, selectedLogIndex, logs, }) {
63
- const onDismiss = (0, react_1.useCallback)(() => {
34
+ export function LogBoxInspector({ log, selectedLogIndex, logs, }) {
35
+ const onDismiss = useCallback(() => {
64
36
  // Here we handle the cases when the log is dismissed and it
65
37
  // was either the last log, or when the current index
66
38
  // is now outside the bounds of the log array.
@@ -75,70 +47,66 @@ function LogBoxInspector({ log, selectedLogIndex, logs, }) {
75
47
  LogBoxData.dismiss(logsArray[selectedLogIndex]);
76
48
  }
77
49
  }, [selectedLogIndex]);
78
- const onMinimize = (0, react_1.useCallback)(() => {
50
+ const onMinimize = useCallback(() => {
79
51
  LogBoxData.setSelectedLog(-1);
80
52
  }, []);
81
- const onChangeSelectedIndex = (0, react_1.useCallback)((index) => {
53
+ const onChangeSelectedIndex = useCallback((index) => {
82
54
  LogBoxData.setSelectedLog(index);
83
55
  }, []);
84
- (0, react_1.useEffect)(() => {
56
+ useEffect(() => {
85
57
  if (log) {
86
- LogBoxData.symbolicateLogNow("stack", log);
87
- LogBoxData.symbolicateLogNow("component", log);
58
+ LogBoxData.symbolicateLogNow('stack', log);
59
+ LogBoxData.symbolicateLogNow('component', log);
88
60
  }
89
61
  }, [log]);
90
- (0, react_1.useEffect)(() => {
62
+ useEffect(() => {
91
63
  // Optimistically symbolicate the last and next logs.
92
64
  if (logs.length > 1) {
93
65
  const selected = selectedLogIndex;
94
66
  const lastIndex = logs.length - 1;
95
67
  const prevIndex = selected - 1 < 0 ? lastIndex : selected - 1;
96
68
  const nextIndex = selected + 1 > lastIndex ? 0 : selected + 1;
97
- for (const type of ["component", "stack"]) {
69
+ for (const type of ['component', 'stack']) {
98
70
  LogBoxData.symbolicateLogLazy(type, logs[prevIndex]);
99
71
  LogBoxData.symbolicateLogLazy(type, logs[nextIndex]);
100
72
  }
101
73
  }
102
74
  }, [logs, selectedLogIndex]);
103
- (0, react_1.useEffect)(() => {
104
- react_native_1.Keyboard.dismiss();
75
+ useEffect(() => {
76
+ Keyboard.dismiss();
105
77
  }, []);
106
- const _handleRetry = (0, react_1.useCallback)((type) => {
78
+ const _handleRetry = useCallback((type) => {
107
79
  LogBoxData.retrySymbolicateLogNow(type, log);
108
80
  }, [log]);
109
- return (react_1.default.createElement(react_native_1.View, { style: styles.container },
110
- react_1.default.createElement(LogBoxInspectorHeader_1.LogBoxInspectorHeader, { onSelectIndex: onChangeSelectedIndex, level: log.level }),
111
- react_1.default.createElement(ErrorOverlayBody, { onRetry: _handleRetry }),
112
- react_1.default.createElement(LogBoxInspectorFooter_1.LogBoxInspectorFooter, { onDismiss: onDismiss, onMinimize: onMinimize })));
81
+ return (React.createElement(View, { style: styles.container },
82
+ React.createElement(ErrorOverlayHeader, { onSelectIndex: onChangeSelectedIndex, level: log.level }),
83
+ React.createElement(ErrorOverlayBody, { onRetry: _handleRetry }),
84
+ React.createElement(ErrorOverlayFooter, { onDismiss: onDismiss, onMinimize: onMinimize })));
113
85
  }
114
- exports.LogBoxInspector = LogBoxInspector;
115
- function ErrorOverlayBody({ onRetry, }) {
116
- const log = (0, LogContext_1.useSelectedLog)();
117
- return react_1.default.createElement(ErrorOverlayBodyContents, { log: log, onRetry: onRetry });
86
+ export function ErrorOverlayBody({ onRetry }) {
87
+ const log = useSelectedLog();
88
+ return React.createElement(ErrorOverlayBodyContents, { log: log, onRetry: onRetry });
118
89
  }
119
- exports.ErrorOverlayBody = ErrorOverlayBody;
120
- function ErrorOverlayBodyContents({ log, onRetry, }) {
121
- var _a, _b;
122
- const [collapsed, setCollapsed] = (0, react_1.useState)(true);
123
- (0, react_1.useEffect)(() => {
90
+ export function ErrorOverlayBodyContents({ log, onRetry, }) {
91
+ const [collapsed, setCollapsed] = useState(true);
92
+ useEffect(() => {
124
93
  setCollapsed(true);
125
94
  }, [log]);
126
- const headerTitle = (_a = HEADER_TITLE_MAP[log.isComponentError ? "component" : log.level]) !== null && _a !== void 0 ? _a : log.type;
127
- const header = (react_1.default.createElement(LogBoxInspectorMessageHeader_1.LogBoxInspectorMessageHeader, { collapsed: collapsed, onPress: () => setCollapsed(!collapsed), message: log.message, level: log.level, title: headerTitle }));
128
- return (react_1.default.createElement(react_1.default.Fragment, null,
95
+ const headerTitle = HEADER_TITLE_MAP[log.isComponentError ? 'component' : log.level] ?? log.type;
96
+ const header = (React.createElement(LogBoxInspectorMessageHeader, { collapsed: collapsed, onPress: () => setCollapsed(!collapsed), message: log.message, level: log.level, title: headerTitle }));
97
+ return (React.createElement(React.Fragment, null,
129
98
  collapsed && header,
130
- react_1.default.createElement(react_native_1.ScrollView, { style: styles.scrollBody },
99
+ React.createElement(ScrollView, { style: styles.scrollBody },
131
100
  !collapsed && header,
132
- react_1.default.createElement(LogBoxInspectorCodeFrame_1.LogBoxInspectorCodeFrame, { codeFrame: log.codeFrame }),
133
- react_1.default.createElement(LogBoxInspectorStackFrames_1.LogBoxInspectorStackFrames, { type: "stack",
101
+ React.createElement(LogBoxInspectorCodeFrame, { codeFrame: log.codeFrame }),
102
+ React.createElement(LogBoxInspectorStackFrames, { type: "stack",
134
103
  // eslint-disable-next-line react/jsx-no-bind
135
- onRetry: onRetry.bind(onRetry, "stack") }),
136
- !!((_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",
104
+ onRetry: onRetry.bind(onRetry, 'stack') }),
105
+ !!log?.componentStack?.length && (React.createElement(LogBoxInspectorStackFrames, { type: "component",
137
106
  // eslint-disable-next-line react/jsx-no-bind
138
- onRetry: onRetry.bind(onRetry, "component") })))));
107
+ onRetry: onRetry.bind(onRetry, 'component') })))));
139
108
  }
140
- exports.ErrorOverlayBodyContents = ErrorOverlayBodyContents;
141
- const styles = react_views_1.StyleSheet.create({
109
+ const styles = StyleSheet.create({
142
110
  scrollBody: {
143
111
  backgroundColor: LogBoxStyle.getBackgroundColor(1),
144
112
  flex: 1,
@@ -150,8 +118,9 @@ const styles = react_views_1.StyleSheet.create({
150
118
  right: 0,
151
119
  zIndex: 999,
152
120
  flex: 1,
153
- position: "fixed",
121
+ // @ts-expect-error: fixed is not in the RN types but it works on web
122
+ position: 'fixed',
154
123
  },
155
124
  });
156
- exports.default = LogBoxData.withSubscription(LogBoxInspectorContainer);
125
+ export default LogBoxData.withSubscription(LogBoxInspectorContainer);
157
126
  //# sourceMappingURL=ErrorOverlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorOverlay.js","sourceRoot":"","sources":["../../src/error-overlay/ErrorOverlay.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAAiD;AACjD,+CAAgE;AAChE,+CAA0D;AAE1D,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,MAAM,EAAE,kCAAkC;IAC1C,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;AAED,SAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,gBAAgB,EA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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,wBAAU,CAAC,MAAM,CAAC;IAC/B,UAAU,EAAE;QACV,eAAe,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC;KACR;IACD,SAAS,EAAE;QACT,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,OAAO;KAClB;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 { StyleSheet } from \"@bacons/react-views\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { Keyboard, ScrollView, 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={styles.container}>\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 container: {\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n zIndex: 999,\n flex: 1,\n position: \"fixed\",\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,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,kCAAkC;IAC1C,SAAS,EAAE,cAAc;CAC1B,CAAC;AAEF,MAAM,UAAU,wBAAwB;IACtC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAC7C,MAAM,GA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AS,IAAI,MAAM;YAErB,oBAAC,wBAAwB,IAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAI;YACtD,oBAAC,0BAA0B,IACzB,IAAI,EAAC,OAAO;gBACZ,6CAA6C;gBAC7C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GACvC;YACD,CAAC,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,IAAI,CAChC,oBAAC,0BAA0B,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;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,UAAU,EAAE;QACV,eAAe,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC;KACR;IACD,SAAS,EAAE;QACT,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,CAAC;QACP,qEAAqE;QACrE,QAAQ,EAAE,OAAO;KAClB;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Keyboard, ScrollView, View, StyleSheet } 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 <LogBoxInspector log={log} selectedLogIndex={selectedLogIndex} logs={logs} />;\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={styles.container}>\n <ErrorOverlayHeader onSelectIndex={onChangeSelectedIndex} level={log.level} />\n <ErrorOverlayBody onRetry={_handleRetry} />\n <ErrorOverlayFooter onDismiss={onDismiss} onMinimize={onMinimize} />\n </View>\n );\n}\n\nexport function ErrorOverlayBody({ onRetry }: { onRetry: (type: StackType) => void }) {\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 = HEADER_TITLE_MAP[log.isComponentError ? 'component' : log.level] ?? 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 container: {\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n zIndex: 999,\n flex: 1,\n // @ts-expect-error: fixed is not in the RN types but it works on web\n position: 'fixed',\n },\n});\n\nexport default LogBoxData.withSubscription(LogBoxInspectorContainer);\n"]}
@@ -1,5 +1,5 @@
1
- import { IgnorePattern, LogData } from "./Data/LogBoxData";
2
- import { ExtendedExceptionData } from "./Data/parseLogBoxLog";
1
+ import { IgnorePattern, LogData } from './Data/LogBoxData';
2
+ import { ExtendedExceptionData } from './Data/parseLogBoxLog';
3
3
  export { LogData, ExtendedExceptionData, IgnorePattern };
4
4
  interface ILogBox {
5
5
  install(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"LogBox.d.ts","sourceRoot":"","sources":["../../src/error-overlay/LogBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,CAAC;AAEzD,UAAU,OAAO;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,SAAS,IAAI,IAAI,CAAC;IAClB,WAAW,IAAI,OAAO,CAAC;IACvB,UAAU,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IACrD,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,YAAY,IAAI,IAAI,CAAC;IACrB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAClD;AAED,QAAA,MAAM,MAAM,EAAE,OAgCb,CAAC;AAIF,eAAe,MAAM,CAAC"}
1
+ {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