@expo/metro-runtime 0.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 (259) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +3 -0
  3. package/assets/alert-triangle.png +0 -0
  4. package/assets/chevron-left.png +0 -0
  5. package/assets/chevron-right.png +0 -0
  6. package/assets/close.png +0 -0
  7. package/assets/loader.png +0 -0
  8. package/asyncRequire.js +1 -0
  9. package/build/HMRClient.d.ts +17 -0
  10. package/build/HMRClient.d.ts.map +1 -0
  11. package/build/HMRClient.js +250 -0
  12. package/build/HMRClient.js.map +1 -0
  13. package/build/HMRClient.native.d.ts +1 -0
  14. package/build/HMRClient.native.d.ts.map +1 -0
  15. package/build/HMRClient.native.js +2 -0
  16. package/build/HMRClient.native.js.map +1 -0
  17. package/build/LoadingView.d.ts +8 -0
  18. package/build/LoadingView.d.ts.map +1 -0
  19. package/build/LoadingView.js +21 -0
  20. package/build/LoadingView.js.map +1 -0
  21. package/build/LoadingView.native.d.ts +1 -0
  22. package/build/LoadingView.native.d.ts.map +1 -0
  23. package/build/LoadingView.native.js +2 -0
  24. package/build/LoadingView.native.js.map +1 -0
  25. package/build/asyncRequire/buildAsyncRequire.d.ts +24 -0
  26. package/build/asyncRequire/buildAsyncRequire.d.ts.map +1 -0
  27. package/build/asyncRequire/buildAsyncRequire.js +50 -0
  28. package/build/asyncRequire/buildAsyncRequire.js.map +1 -0
  29. package/build/asyncRequire/buildUrlForBundle.d.ts +8 -0
  30. package/build/asyncRequire/buildUrlForBundle.d.ts.map +1 -0
  31. package/build/asyncRequire/buildUrlForBundle.js +25 -0
  32. package/build/asyncRequire/buildUrlForBundle.js.map +1 -0
  33. package/build/asyncRequire/buildUrlForBundle.native.d.ts +2 -0
  34. package/build/asyncRequire/buildUrlForBundle.native.d.ts.map +1 -0
  35. package/build/asyncRequire/buildUrlForBundle.native.js +25 -0
  36. package/build/asyncRequire/buildUrlForBundle.native.js.map +1 -0
  37. package/build/asyncRequire/fetchAsync.d.ts +5 -0
  38. package/build/asyncRequire/fetchAsync.d.ts.map +1 -0
  39. package/build/asyncRequire/fetchAsync.js +19 -0
  40. package/build/asyncRequire/fetchAsync.js.map +1 -0
  41. package/build/asyncRequire/fetchAsync.native.d.ts +12 -0
  42. package/build/asyncRequire/fetchAsync.native.d.ts.map +1 -0
  43. package/build/asyncRequire/fetchAsync.native.js +57 -0
  44. package/build/asyncRequire/fetchAsync.native.js.map +1 -0
  45. package/build/asyncRequire/fetchThenEval.d.ts +7 -0
  46. package/build/asyncRequire/fetchThenEval.d.ts.map +1 -0
  47. package/build/asyncRequire/fetchThenEval.js +30 -0
  48. package/build/asyncRequire/fetchThenEval.js.map +1 -0
  49. package/build/asyncRequire/fetchThenEval.web.d.ts +6 -0
  50. package/build/asyncRequire/fetchThenEval.web.d.ts.map +1 -0
  51. package/build/asyncRequire/fetchThenEval.web.js +29 -0
  52. package/build/asyncRequire/fetchThenEval.web.js.map +1 -0
  53. package/build/asyncRequire/index.d.ts +2 -0
  54. package/build/asyncRequire/index.d.ts.map +1 -0
  55. package/build/asyncRequire/index.js +5 -0
  56. package/build/asyncRequire/index.js.map +1 -0
  57. package/build/asyncRequire/loadBundle.android.d.ts +2 -0
  58. package/build/asyncRequire/loadBundle.android.d.ts.map +1 -0
  59. package/build/asyncRequire/loadBundle.android.js +22 -0
  60. package/build/asyncRequire/loadBundle.android.js.map +1 -0
  61. package/build/asyncRequire/loadBundle.d.ts +2 -0
  62. package/build/asyncRequire/loadBundle.d.ts.map +1 -0
  63. package/build/asyncRequire/loadBundle.js +6 -0
  64. package/build/asyncRequire/loadBundle.js.map +1 -0
  65. package/build/asyncRequire/loadBundlePolyfill.d.ts +7 -0
  66. package/build/asyncRequire/loadBundlePolyfill.d.ts.map +1 -0
  67. package/build/asyncRequire/loadBundlePolyfill.js +40 -0
  68. package/build/asyncRequire/loadBundlePolyfill.js.map +1 -0
  69. package/build/effects.d.ts +2 -0
  70. package/build/effects.d.ts.map +1 -0
  71. package/build/effects.js +16 -0
  72. package/build/effects.js.map +1 -0
  73. package/build/effects.native.d.ts +1 -0
  74. package/build/effects.native.d.ts.map +1 -0
  75. package/build/effects.native.js +1 -0
  76. package/build/effects.native.js.map +1 -0
  77. package/build/error-overlay/Data/LogBoxData.d.ts +60 -0
  78. package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -0
  79. package/build/error-overlay/Data/LogBoxData.js +386 -0
  80. package/build/error-overlay/Data/LogBoxData.js.map +1 -0
  81. package/build/error-overlay/Data/LogBoxLog.d.ts +61 -0
  82. package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -0
  83. package/build/error-overlay/Data/LogBoxLog.js +148 -0
  84. package/build/error-overlay/Data/LogBoxLog.js.map +1 -0
  85. package/build/error-overlay/Data/LogBoxSymbolication.d.ts +17 -0
  86. package/build/error-overlay/Data/LogBoxSymbolication.d.ts.map +1 -0
  87. package/build/error-overlay/Data/LogBoxSymbolication.js +56 -0
  88. package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -0
  89. package/build/error-overlay/Data/LogContext.d.ts +14 -0
  90. package/build/error-overlay/Data/LogContext.d.ts.map +1 -0
  91. package/build/error-overlay/Data/LogContext.js +27 -0
  92. package/build/error-overlay/Data/LogContext.js.map +1 -0
  93. package/build/error-overlay/Data/parseLogBoxLog.d.ts +45 -0
  94. package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -0
  95. package/build/error-overlay/Data/parseLogBoxLog.js +286 -0
  96. package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -0
  97. package/build/error-overlay/ErrorOverlay.d.ts +18 -0
  98. package/build/error-overlay/ErrorOverlay.d.ts.map +1 -0
  99. package/build/error-overlay/ErrorOverlay.js +146 -0
  100. package/build/error-overlay/ErrorOverlay.js.map +1 -0
  101. package/build/error-overlay/LogBox.d.ts +16 -0
  102. package/build/error-overlay/LogBox.d.ts.map +1 -0
  103. package/build/error-overlay/LogBox.js +31 -0
  104. package/build/error-overlay/LogBox.js.map +1 -0
  105. package/build/error-overlay/LogBox.web.d.ts +23 -0
  106. package/build/error-overlay/LogBox.web.d.ts.map +1 -0
  107. package/build/error-overlay/LogBox.web.js +129 -0
  108. package/build/error-overlay/LogBox.web.js.map +1 -0
  109. package/build/error-overlay/UI/AnsiHighlight.d.ts +6 -0
  110. package/build/error-overlay/UI/AnsiHighlight.d.ts.map +1 -0
  111. package/build/error-overlay/UI/AnsiHighlight.js +86 -0
  112. package/build/error-overlay/UI/AnsiHighlight.js.map +1 -0
  113. package/build/error-overlay/UI/LogBoxButton.d.ts +14 -0
  114. package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -0
  115. package/build/error-overlay/UI/LogBoxButton.js +59 -0
  116. package/build/error-overlay/UI/LogBoxButton.js.map +1 -0
  117. package/build/error-overlay/UI/LogBoxMessage.d.ts +11 -0
  118. package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -0
  119. package/build/error-overlay/UI/LogBoxMessage.js +53 -0
  120. package/build/error-overlay/UI/LogBoxMessage.js.map +1 -0
  121. package/build/error-overlay/UI/LogBoxStyle.d.ts +22 -0
  122. package/build/error-overlay/UI/LogBoxStyle.d.ts.map +1 -0
  123. package/build/error-overlay/UI/LogBoxStyle.js +68 -0
  124. package/build/error-overlay/UI/LogBoxStyle.js.map +1 -0
  125. package/build/error-overlay/UI/constants.d.ts +2 -0
  126. package/build/error-overlay/UI/constants.d.ts.map +1 -0
  127. package/build/error-overlay/UI/constants.js +10 -0
  128. package/build/error-overlay/UI/constants.js.map +1 -0
  129. package/build/error-overlay/formatProjectFilePath.d.ts +2 -0
  130. package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -0
  131. package/build/error-overlay/formatProjectFilePath.js +27 -0
  132. package/build/error-overlay/formatProjectFilePath.js.map +1 -0
  133. package/build/error-overlay/index.d.ts +3 -0
  134. package/build/error-overlay/index.d.ts.map +1 -0
  135. package/build/error-overlay/index.js +30 -0
  136. package/build/error-overlay/index.js.map +1 -0
  137. package/build/error-overlay/modules/ExceptionsManager/index.d.ts +38 -0
  138. package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -0
  139. package/build/error-overlay/modules/ExceptionsManager/index.js +80 -0
  140. package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -0
  141. package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts +2 -0
  142. package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts.map +1 -0
  143. package/build/error-overlay/modules/ExceptionsManager/index.native.js +3 -0
  144. package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -0
  145. package/build/error-overlay/modules/NativeLogBox/index.d.ts +6 -0
  146. package/build/error-overlay/modules/NativeLogBox/index.d.ts.map +1 -0
  147. package/build/error-overlay/modules/NativeLogBox/index.js +34 -0
  148. package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -0
  149. package/build/error-overlay/modules/NativeLogBox/index.native.d.ts +3 -0
  150. package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -0
  151. package/build/error-overlay/modules/NativeLogBox/index.native.js +8 -0
  152. package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -0
  153. package/build/error-overlay/modules/openFileInEditor/index.d.ts +3 -0
  154. package/build/error-overlay/modules/openFileInEditor/index.d.ts.map +1 -0
  155. package/build/error-overlay/modules/openFileInEditor/index.js +15 -0
  156. package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -0
  157. package/build/error-overlay/modules/openFileInEditor/index.native.d.ts +3 -0
  158. package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -0
  159. package/build/error-overlay/modules/openFileInEditor/index.native.js +8 -0
  160. package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -0
  161. package/build/error-overlay/modules/parseErrorStack/index.d.ts +6 -0
  162. package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -0
  163. package/build/error-overlay/modules/parseErrorStack/index.js +25 -0
  164. package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -0
  165. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts +3 -0
  166. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts.map +1 -0
  167. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js +9 -0
  168. package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -0
  169. package/build/error-overlay/modules/stringifySafe/index.d.ts +20 -0
  170. package/build/error-overlay/modules/stringifySafe/index.d.ts.map +1 -0
  171. package/build/error-overlay/modules/stringifySafe/index.js +117 -0
  172. package/build/error-overlay/modules/stringifySafe/index.js.map +1 -0
  173. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +24 -0
  174. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -0
  175. package/build/error-overlay/modules/symbolicateStackTrace/index.js +19 -0
  176. package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -0
  177. package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts +3 -0
  178. package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts.map +1 -0
  179. package/build/error-overlay/modules/symbolicateStackTrace/index.native.js +8 -0
  180. package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -0
  181. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +5 -0
  182. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -0
  183. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +113 -0
  184. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -0
  185. package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts +7 -0
  186. package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -0
  187. package/build/error-overlay/overlay/LogBoxInspectorFooter.js +111 -0
  188. package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -0
  189. package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +8 -0
  190. package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -0
  191. package/build/error-overlay/overlay/LogBoxInspectorHeader.js +139 -0
  192. package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -0
  193. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +12 -0
  194. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -0
  195. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +116 -0
  196. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -0
  197. package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +8 -0
  198. package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts.map +1 -0
  199. package/build/error-overlay/overlay/LogBoxInspectorSection.js +70 -0
  200. package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -0
  201. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +8 -0
  202. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -0
  203. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +127 -0
  204. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -0
  205. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +11 -0
  206. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -0
  207. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +103 -0
  208. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -0
  209. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +10 -0
  210. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -0
  211. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +177 -0
  212. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -0
  213. package/build/error-overlay/toast/ErrorToast.d.ts +11 -0
  214. package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -0
  215. package/build/error-overlay/toast/ErrorToast.js +147 -0
  216. package/build/error-overlay/toast/ErrorToast.js.map +1 -0
  217. package/build/error-overlay/toast/ErrorToastContainer.d.ts +4 -0
  218. package/build/error-overlay/toast/ErrorToastContainer.d.ts.map +1 -0
  219. package/build/error-overlay/toast/ErrorToastContainer.js +7 -0
  220. package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -0
  221. package/build/error-overlay/toast/ErrorToastContainer.web.d.ts +12 -0
  222. package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -0
  223. package/build/error-overlay/toast/ErrorToastContainer.web.js +83 -0
  224. package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -0
  225. package/build/error-overlay/toast/ErrorToastMessage.d.ts +5 -0
  226. package/build/error-overlay/toast/ErrorToastMessage.d.ts.map +1 -0
  227. package/build/error-overlay/toast/ErrorToastMessage.js +50 -0
  228. package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -0
  229. package/build/error-overlay/useRejectionHandler.d.ts +3 -0
  230. package/build/error-overlay/useRejectionHandler.d.ts.map +1 -0
  231. package/build/error-overlay/useRejectionHandler.js +60 -0
  232. package/build/error-overlay/useRejectionHandler.js.map +1 -0
  233. package/build/getDevServer.d.ts +8 -0
  234. package/build/getDevServer.d.ts.map +1 -0
  235. package/build/getDevServer.js +37 -0
  236. package/build/getDevServer.js.map +1 -0
  237. package/build/getDevServer.native.d.ts +1 -0
  238. package/build/getDevServer.native.d.ts.map +1 -0
  239. package/build/getDevServer.native.js +2 -0
  240. package/build/getDevServer.native.js.map +1 -0
  241. package/build/index.d.ts +2 -0
  242. package/build/index.d.ts.map +1 -0
  243. package/build/index.js +4 -0
  244. package/build/index.js.map +1 -0
  245. package/build/messageSocket.d.ts +3 -0
  246. package/build/messageSocket.d.ts.map +1 -0
  247. package/build/messageSocket.js +24 -0
  248. package/build/messageSocket.js.map +1 -0
  249. package/build/setupFastRefresh.d.ts +10 -0
  250. package/build/setupFastRefresh.d.ts.map +1 -0
  251. package/build/setupFastRefresh.js +23 -0
  252. package/build/setupFastRefresh.js.map +1 -0
  253. package/build/setupHMR.d.ts +2 -0
  254. package/build/setupHMR.d.ts.map +1 -0
  255. package/build/setupHMR.js +14 -0
  256. package/build/setupHMR.js.map +1 -0
  257. package/error-overlay.d.ts +1 -0
  258. package/error-overlay.js +1 -0
  259. package/package.json +41 -0
@@ -0,0 +1,386 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Evan Bacon.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ var __importDefault = (this && this.__importDefault) || function (mod) {
33
+ return (mod && mod.__esModule) ? mod : { "default": mod };
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.withSubscription = exports.observe = exports.isDisabled = exports.setDisabled = exports.addIgnorePatterns = exports.getIgnorePatterns = exports.dismiss = exports.clearErrors = exports.clearWarnings = exports.setSelectedLog = exports.clear = exports.symbolicateLogLazy = exports.retrySymbolicateLogNow = exports.symbolicateLogNow = exports.addException = exports.addLog = exports.isMessageIgnored = exports.isLogBoxErrorMessage = exports.reportUnexpectedLogBoxError = exports.reportLogBoxError = void 0;
37
+ const React = __importStar(require("react"));
38
+ const NativeLogBox_1 = __importDefault(require("../modules/NativeLogBox"));
39
+ const parseErrorStack_1 = __importDefault(require("../modules/parseErrorStack"));
40
+ const LogBoxLog_1 = require("./LogBoxLog");
41
+ const LogContext_1 = require("./LogContext");
42
+ const parseLogBoxLog_1 = require("./parseLogBoxLog");
43
+ const observers = new Set();
44
+ const ignorePatterns = new Set();
45
+ let logs = new Set();
46
+ let updateTimeout = null;
47
+ let _isDisabled = false;
48
+ let _selectedIndex = -1;
49
+ const LOGBOX_ERROR_MESSAGE = "An error was thrown when attempting to render log messages via LogBox.";
50
+ function getNextState() {
51
+ return {
52
+ logs,
53
+ isDisabled: _isDisabled,
54
+ selectedLogIndex: _selectedIndex,
55
+ };
56
+ }
57
+ function reportLogBoxError(error, componentStack) {
58
+ const ExceptionsManager = require("../modules/ExceptionsManager");
59
+ if (componentStack != null) {
60
+ error.componentStack = componentStack;
61
+ }
62
+ ExceptionsManager.handleException(error);
63
+ }
64
+ exports.reportLogBoxError = reportLogBoxError;
65
+ function reportUnexpectedLogBoxError(error, componentStack) {
66
+ error.message = `${LOGBOX_ERROR_MESSAGE}\n\n${error.message}`;
67
+ return reportLogBoxError(error, componentStack);
68
+ }
69
+ exports.reportUnexpectedLogBoxError = reportUnexpectedLogBoxError;
70
+ function isLogBoxErrorMessage(message) {
71
+ return typeof message === "string" && message.includes(LOGBOX_ERROR_MESSAGE);
72
+ }
73
+ exports.isLogBoxErrorMessage = isLogBoxErrorMessage;
74
+ function isMessageIgnored(message) {
75
+ for (const pattern of ignorePatterns) {
76
+ if ((pattern instanceof RegExp && pattern.test(message)) ||
77
+ (typeof pattern === "string" && message.includes(pattern))) {
78
+ return true;
79
+ }
80
+ }
81
+ return false;
82
+ }
83
+ exports.isMessageIgnored = isMessageIgnored;
84
+ function handleUpdate() {
85
+ if (updateTimeout == null) {
86
+ updateTimeout = setImmediate(() => {
87
+ updateTimeout = null;
88
+ const nextState = getNextState();
89
+ observers.forEach(({ observer }) => observer(nextState));
90
+ });
91
+ }
92
+ }
93
+ function appendNewLog(newLog) {
94
+ // Don't want store these logs because they trigger a
95
+ // state update when we add them to the store.
96
+ if (isMessageIgnored(newLog.message.content)) {
97
+ return;
98
+ }
99
+ // If the next log has the same category as the previous one
100
+ // then roll it up into the last log in the list by incrementing
101
+ // the count (similar to how Chrome does it).
102
+ const lastLog = Array.from(logs).pop();
103
+ if (lastLog && lastLog.category === newLog.category) {
104
+ lastLog.incrementCount();
105
+ handleUpdate();
106
+ return;
107
+ }
108
+ if (newLog.level === "fatal") {
109
+ // If possible, to avoid jank, we don't want to open the error before
110
+ // it's symbolicated. To do that, we optimistically wait for
111
+ // symbolication for up to a second before adding the log.
112
+ const OPTIMISTIC_WAIT_TIME = 1000;
113
+ let addPendingLog = () => {
114
+ logs.add(newLog);
115
+ if (_selectedIndex < 0) {
116
+ setSelectedLog(logs.size - 1);
117
+ }
118
+ else {
119
+ handleUpdate();
120
+ }
121
+ addPendingLog = null;
122
+ };
123
+ const optimisticTimeout = setTimeout(() => {
124
+ if (addPendingLog) {
125
+ addPendingLog();
126
+ }
127
+ }, OPTIMISTIC_WAIT_TIME);
128
+ // TODO: HANDLE THIS
129
+ newLog.symbolicate("component");
130
+ newLog.symbolicate("stack", (status) => {
131
+ if (addPendingLog && status !== "PENDING") {
132
+ addPendingLog();
133
+ clearTimeout(optimisticTimeout);
134
+ }
135
+ else if (status !== "PENDING") {
136
+ // The log has already been added but we need to trigger a render.
137
+ handleUpdate();
138
+ }
139
+ });
140
+ }
141
+ else if (newLog.level === "syntax") {
142
+ logs.add(newLog);
143
+ setSelectedLog(logs.size - 1);
144
+ }
145
+ else {
146
+ logs.add(newLog);
147
+ handleUpdate();
148
+ }
149
+ }
150
+ function addLog(log) {
151
+ const errorForStackTrace = new Error();
152
+ // Parsing logs are expensive so we schedule this
153
+ // otherwise spammy logs would pause rendering.
154
+ setImmediate(() => {
155
+ try {
156
+ const stack = (0, parseErrorStack_1.default)(errorForStackTrace === null || errorForStackTrace === void 0 ? void 0 : errorForStackTrace.stack);
157
+ appendNewLog(new LogBoxLog_1.LogBoxLog({
158
+ level: log.level,
159
+ message: log.message,
160
+ isComponentError: false,
161
+ stack,
162
+ category: log.category,
163
+ componentStack: log.componentStack,
164
+ }));
165
+ }
166
+ catch (error) {
167
+ reportUnexpectedLogBoxError(error);
168
+ }
169
+ });
170
+ }
171
+ exports.addLog = addLog;
172
+ function addException(error) {
173
+ // Parsing logs are expensive so we schedule this
174
+ // otherwise spammy logs would pause rendering.
175
+ setImmediate(() => {
176
+ try {
177
+ appendNewLog(new LogBoxLog_1.LogBoxLog((0, parseLogBoxLog_1.parseLogBoxException)(error)));
178
+ }
179
+ catch (loggingError) {
180
+ reportUnexpectedLogBoxError(loggingError);
181
+ }
182
+ });
183
+ }
184
+ exports.addException = addException;
185
+ function symbolicateLogNow(type, log) {
186
+ log.symbolicate(type, () => {
187
+ handleUpdate();
188
+ });
189
+ }
190
+ exports.symbolicateLogNow = symbolicateLogNow;
191
+ function retrySymbolicateLogNow(type, log) {
192
+ log.retrySymbolicate(type, () => {
193
+ handleUpdate();
194
+ });
195
+ }
196
+ exports.retrySymbolicateLogNow = retrySymbolicateLogNow;
197
+ function symbolicateLogLazy(type, log) {
198
+ log.symbolicate(type);
199
+ }
200
+ exports.symbolicateLogLazy = symbolicateLogLazy;
201
+ function clear() {
202
+ if (logs.size > 0) {
203
+ logs = new Set();
204
+ setSelectedLog(-1);
205
+ }
206
+ }
207
+ exports.clear = clear;
208
+ function setSelectedLog(proposedNewIndex) {
209
+ const oldIndex = _selectedIndex;
210
+ let newIndex = proposedNewIndex;
211
+ const logArray = Array.from(logs);
212
+ let index = logArray.length - 1;
213
+ while (index >= 0) {
214
+ // The latest syntax error is selected and displayed before all other logs.
215
+ if (logArray[index].level === "syntax") {
216
+ newIndex = index;
217
+ break;
218
+ }
219
+ index -= 1;
220
+ }
221
+ _selectedIndex = newIndex;
222
+ handleUpdate();
223
+ if (NativeLogBox_1.default) {
224
+ setTimeout(() => {
225
+ if (oldIndex < 0 && newIndex >= 0) {
226
+ NativeLogBox_1.default.show();
227
+ }
228
+ else if (oldIndex >= 0 && newIndex < 0) {
229
+ NativeLogBox_1.default.hide();
230
+ }
231
+ }, 0);
232
+ }
233
+ }
234
+ exports.setSelectedLog = setSelectedLog;
235
+ function clearWarnings() {
236
+ const newLogs = Array.from(logs).filter((log) => log.level !== "warn");
237
+ if (newLogs.length !== logs.size) {
238
+ logs = new Set(newLogs);
239
+ setSelectedLog(-1);
240
+ handleUpdate();
241
+ }
242
+ }
243
+ exports.clearWarnings = clearWarnings;
244
+ function clearErrors() {
245
+ const newLogs = Array.from(logs).filter((log) => log.level !== "error" && log.level !== "fatal");
246
+ if (newLogs.length !== logs.size) {
247
+ logs = new Set(newLogs);
248
+ setSelectedLog(-1);
249
+ }
250
+ }
251
+ exports.clearErrors = clearErrors;
252
+ function dismiss(log) {
253
+ if (logs.has(log)) {
254
+ logs.delete(log);
255
+ handleUpdate();
256
+ }
257
+ }
258
+ exports.dismiss = dismiss;
259
+ function getIgnorePatterns() {
260
+ return Array.from(ignorePatterns);
261
+ }
262
+ exports.getIgnorePatterns = getIgnorePatterns;
263
+ function addIgnorePatterns(patterns) {
264
+ const existingSize = ignorePatterns.size;
265
+ // The same pattern may be added multiple times, but adding a new pattern
266
+ // can be expensive so let's find only the ones that are new.
267
+ patterns.forEach((pattern) => {
268
+ if (pattern instanceof RegExp) {
269
+ for (const existingPattern of ignorePatterns) {
270
+ if (existingPattern instanceof RegExp &&
271
+ existingPattern.toString() === pattern.toString()) {
272
+ return;
273
+ }
274
+ }
275
+ ignorePatterns.add(pattern);
276
+ }
277
+ ignorePatterns.add(pattern);
278
+ });
279
+ if (ignorePatterns.size === existingSize) {
280
+ return;
281
+ }
282
+ // We need to recheck all of the existing logs.
283
+ // This allows adding an ignore pattern anywhere in the codebase.
284
+ // Without this, if you ignore a pattern after the a log is created,
285
+ // then we would keep showing the log.
286
+ logs = new Set(Array.from(logs).filter((log) => !isMessageIgnored(log.message.content)));
287
+ handleUpdate();
288
+ }
289
+ exports.addIgnorePatterns = addIgnorePatterns;
290
+ function setDisabled(value) {
291
+ if (value === _isDisabled) {
292
+ return;
293
+ }
294
+ _isDisabled = value;
295
+ handleUpdate();
296
+ }
297
+ exports.setDisabled = setDisabled;
298
+ function isDisabled() {
299
+ return _isDisabled;
300
+ }
301
+ exports.isDisabled = isDisabled;
302
+ function observe(observer) {
303
+ const subscription = { observer };
304
+ observers.add(subscription);
305
+ observer(getNextState());
306
+ return {
307
+ unsubscribe() {
308
+ observers.delete(subscription);
309
+ },
310
+ };
311
+ }
312
+ exports.observe = observe;
313
+ function withSubscription(WrappedComponent) {
314
+ class LogBoxStateSubscription extends React.Component {
315
+ constructor() {
316
+ super(...arguments);
317
+ // @ts-expect-error
318
+ this.state = {
319
+ logs: new Set(),
320
+ isDisabled: false,
321
+ hasError: false,
322
+ selectedLogIndex: -1,
323
+ };
324
+ this._handleDismiss = () => {
325
+ // Here we handle the cases when the log is dismissed and it
326
+ // was either the last log, or when the current index
327
+ // is now outside the bounds of the log array.
328
+ const { selectedLogIndex, logs: stateLogs } = this.state;
329
+ const logsArray = Array.from(stateLogs);
330
+ if (selectedLogIndex != null) {
331
+ if (logsArray.length - 1 <= 0) {
332
+ setSelectedLog(-1);
333
+ }
334
+ else if (selectedLogIndex >= logsArray.length - 1) {
335
+ setSelectedLog(selectedLogIndex - 1);
336
+ }
337
+ // @ts-expect-error
338
+ dismiss(logsArray[selectedLogIndex]);
339
+ }
340
+ };
341
+ this._handleMinimize = () => {
342
+ setSelectedLog(-1);
343
+ };
344
+ this._handleSetSelectedLog = (index) => {
345
+ setSelectedLog(index);
346
+ };
347
+ }
348
+ static getDerivedStateFromError() {
349
+ return { hasError: true };
350
+ }
351
+ componentDidCatch(err, errorInfo) {
352
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
353
+ * this parameters */
354
+ reportLogBoxError(err, errorInfo.componentStack);
355
+ }
356
+ render() {
357
+ if (this.state.hasError) {
358
+ // This happens when the component failed to render, in which case we delegate to the native redbox.
359
+ // We can't show any fallback UI here, because the error may be with <View> or <Text>.
360
+ return null;
361
+ }
362
+ return (React.createElement(LogContext_1.LogContext.Provider, { value: {
363
+ selectedLogIndex: this.state.selectedLogIndex,
364
+ isDisabled: this.state.isDisabled,
365
+ // @ts-expect-error
366
+ logs: Array.from(this.state.logs),
367
+ } },
368
+ this.props.children,
369
+ React.createElement(WrappedComponent, null)));
370
+ }
371
+ componentDidMount() {
372
+ this._subscription = observe((data) => {
373
+ this.setState(data);
374
+ });
375
+ }
376
+ componentWillUnmount() {
377
+ if (this._subscription != null) {
378
+ this._subscription.unsubscribe();
379
+ }
380
+ }
381
+ }
382
+ // @ts-expect-error
383
+ return LogBoxStateSubscription;
384
+ }
385
+ exports.withSubscription = withSubscription;
386
+ //# sourceMappingURL=LogBoxData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogBoxData.js","sourceRoot":"","sources":["../../../src/error-overlay/Data/LogBoxData.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,2EAAmD;AACnD,iFAAyD;AACzD,2CAAmD;AAEnD,6CAA0C;AAC1C,qDAAwD;AAoDxD,MAAM,SAAS,GAAsC,IAAI,GAAG,EAAE,CAAC;AAC/D,MAAM,cAAc,GAAuB,IAAI,GAAG,EAAE,CAAC;AACrD,IAAI,IAAI,GAAe,IAAI,GAAG,EAAE,CAAC;AACjC,IAAI,aAAa,GAA2C,IAAI,CAAC;AACjE,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,cAAc,GAAG,CA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AAC;QAED,oBAAoB;YAClB,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;gBAC9B,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;aAClC;QACH,CAAC;KA2BF;IAED,mBAAmB;IACnB,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAxFD,4CAwFC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as React from \"react\";\n\nimport NativeLogBox from \"../modules/NativeLogBox\";\nimport parseErrorStack from \"../modules/parseErrorStack\";\nimport { LogBoxLog, StackType } from \"./LogBoxLog\";\nimport type { LogLevel } from \"./LogBoxLog\";\nimport { LogContext } from \"./LogContext\";\nimport { parseLogBoxException } from \"./parseLogBoxLog\";\nimport type {\n Message,\n Category,\n ComponentStack,\n ExtendedExceptionData,\n} from \"./parseLogBoxLog\";\n\nexport type LogBoxLogs = Set<LogBoxLog>;\n\nexport type LogData = {\n level: LogLevel;\n message: Message;\n category: Category;\n componentStack: ComponentStack;\n};\n\ntype ExtendedError = any;\n\nexport type Observer = (options: {\n logs: LogBoxLogs;\n isDisabled: boolean;\n selectedLogIndex: number;\n}) => void;\n\nexport type IgnorePattern = string | RegExp;\n\nexport type Subscription = {\n unsubscribe: () => void;\n};\n\nexport type WarningInfo = {\n finalFormat: string;\n forceDialogImmediately: boolean;\n suppressDialog_LEGACY: boolean;\n suppressCompletely: boolean;\n monitorEvent: string | null;\n monitorListVersion: number;\n monitorSampleRate: number;\n};\n\nexport type WarningFilter = (format: string) => WarningInfo;\n\ntype Props = object;\n\ntype State = {\n logs: LogBoxLogs;\n isDisabled: boolean;\n hasError: boolean;\n selectedLogIndex: number;\n};\n\nconst observers: Set<{ observer: Observer } & any> = new Set();\nconst ignorePatterns: Set<IgnorePattern> = new Set();\nlet logs: LogBoxLogs = new Set();\nlet updateTimeout: 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<Props, State> {\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n componentDidCatch(err: Error, errorInfo: { componentStack: string } & any) {\n /* $FlowFixMe[class-object-subtyping] added when improving typing for\n * this parameters */\n reportLogBoxError(err, errorInfo.componentStack);\n }\n\n _subscription?: Subscription;\n\n // @ts-expect-error\n state = {\n logs: new Set(),\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 // @ts-expect-error\n logs: Array.from(this.state.logs),\n }}\n >\n {/* @ts-expect-error */}\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 // @ts-expect-error\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"]}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright (c) Evan Bacon.
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 type { Stack } from "./LogBoxSymbolication";
9
+ import type { Category, Message, ComponentStack, CodeFrame } from "./parseLogBoxLog";
10
+ declare type SymbolicationStatus = "NONE" | "PENDING" | "COMPLETE" | "FAILED";
11
+ export declare type LogLevel = "warn" | "error" | "fatal" | "syntax";
12
+ export declare type LogBoxLogData = {
13
+ level: LogLevel;
14
+ type?: string;
15
+ message: Message;
16
+ stack: Stack;
17
+ category: string;
18
+ componentStack: ComponentStack;
19
+ codeFrame?: CodeFrame;
20
+ isComponentError: boolean;
21
+ };
22
+ export declare type StackType = "stack" | "component";
23
+ export declare class LogBoxLog {
24
+ message: Message;
25
+ type: string;
26
+ category: Category;
27
+ componentStack: ComponentStack;
28
+ stack: Stack;
29
+ count: number;
30
+ level: LogLevel;
31
+ codeFrame?: CodeFrame;
32
+ 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);
51
+ incrementCount(): void;
52
+ getAvailableStack(type: StackType): Stack | null;
53
+ retrySymbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void;
54
+ symbolicate(type: StackType, callback?: (status: SymbolicationStatus) => void): void;
55
+ private componentStackCache;
56
+ private getStack;
57
+ private handleSymbolicate;
58
+ private updateStatus;
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=LogBoxLog.d.ts.map
@@ -0,0 +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,aAAK,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtE,oBAAY,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7D,oBAAY,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,CAAC;CAC3B,CAAC;AAEF,oBAAY,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;AAY9C,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,CAClB,SAAS,EACP;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAC5C;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE,GAC/C;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,GACjD;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,QAAQ,CAAA;KAAE,CAClD,CAWC;gBAEU,IAAI,EAAE,aAAa;IAY/B,cAAc,IAAI,IAAI;IAItB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI;IAOhD,gBAAgB,CACd,IAAI,EAAE,SAAS,EACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI;IAOP,WAAW,CACT,IAAI,EAAE,SAAS,EACf,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI;IAMP,OAAO,CAAC,mBAAmB,CAAsB;IAEjD,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,YAAY;CAoCrB"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Evan Bacon.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.LogBoxLog = void 0;
34
+ const LogBoxSymbolication = __importStar(require("./LogBoxSymbolication"));
35
+ function componentStackToStack(componentStack) {
36
+ return componentStack.map((stack) => {
37
+ var _a, _b, _c, _d;
38
+ return ({
39
+ file: stack.fileName,
40
+ methodName: stack.content,
41
+ lineNumber: (_b = (_a = stack.location) === null || _a === void 0 ? void 0 : _a.row) !== null && _b !== void 0 ? _b : 0,
42
+ column: (_d = (_c = stack.location) === null || _c === void 0 ? void 0 : _c.column) !== null && _d !== void 0 ? _d : 0,
43
+ arguments: [],
44
+ });
45
+ });
46
+ }
47
+ class LogBoxLog {
48
+ constructor(data) {
49
+ var _a;
50
+ this.symbolicated = {
51
+ stack: {
52
+ error: null,
53
+ stack: null,
54
+ status: "NONE",
55
+ },
56
+ component: {
57
+ error: null,
58
+ stack: null,
59
+ status: "NONE",
60
+ },
61
+ };
62
+ this.componentStackCache = null;
63
+ this.level = data.level;
64
+ this.type = (_a = data.type) !== null && _a !== void 0 ? _a : "error";
65
+ this.message = data.message;
66
+ this.stack = data.stack;
67
+ this.category = data.category;
68
+ this.componentStack = data.componentStack;
69
+ this.codeFrame = data.codeFrame;
70
+ this.isComponentError = data.isComponentError;
71
+ this.count = 1;
72
+ }
73
+ incrementCount() {
74
+ this.count += 1;
75
+ }
76
+ getAvailableStack(type) {
77
+ if (this.symbolicated[type].status === "COMPLETE") {
78
+ return this.symbolicated[type].stack;
79
+ }
80
+ return this.getStack(type);
81
+ }
82
+ retrySymbolicate(type, callback) {
83
+ if (this.symbolicated[type].status !== "COMPLETE") {
84
+ LogBoxSymbolication.deleteStack(this.getStack(type));
85
+ this.handleSymbolicate(type, callback);
86
+ }
87
+ }
88
+ symbolicate(type, callback) {
89
+ if (this.symbolicated[type].status === "NONE") {
90
+ this.handleSymbolicate(type, callback);
91
+ }
92
+ }
93
+ getStack(type) {
94
+ if (type === "component") {
95
+ if (this.componentStackCache == null) {
96
+ this.componentStackCache = componentStackToStack(this.componentStack);
97
+ }
98
+ return this.componentStackCache;
99
+ }
100
+ return this.stack;
101
+ }
102
+ handleSymbolicate(type, callback) {
103
+ var _a;
104
+ if (type === "component" && !((_a = this.componentStack) === null || _a === void 0 ? void 0 : _a.length)) {
105
+ return;
106
+ }
107
+ if (this.symbolicated[type].status !== "PENDING") {
108
+ this.updateStatus(type, null, null, null, callback);
109
+ 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);
111
+ }, (error) => {
112
+ this.updateStatus(type, error, null, null, callback);
113
+ });
114
+ }
115
+ }
116
+ updateStatus(type, error, stack, codeFrame, callback) {
117
+ const lastStatus = this.symbolicated[type].status;
118
+ if (error != null) {
119
+ this.symbolicated[type] = {
120
+ error,
121
+ stack: null,
122
+ status: "FAILED",
123
+ };
124
+ }
125
+ else if (stack != null) {
126
+ if (codeFrame) {
127
+ this.codeFrame = codeFrame;
128
+ }
129
+ this.symbolicated[type] = {
130
+ error: null,
131
+ stack,
132
+ status: "COMPLETE",
133
+ };
134
+ }
135
+ else {
136
+ this.symbolicated[type] = {
137
+ error: null,
138
+ stack: null,
139
+ status: "PENDING",
140
+ };
141
+ }
142
+ if (callback && lastStatus !== this.symbolicated[type].status) {
143
+ callback(this.symbolicated[type].status);
144
+ }
145
+ }
146
+ }
147
+ exports.LogBoxLog = LogBoxLog;
148
+ //# sourceMappingURL=LogBoxLog.js.map
@@ -0,0 +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;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;AAED,MAAa,SAAS;IA6BpB,YAAY,IAAmB;;QAnB/B,iBAAY,GAMR;YACF,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;QA4CM,wBAAmB,GAAiB,IAAI,CAAC;QAzC/C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,IAAI,mCAAI,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO,GAA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AAC,GAAG;gBACxB,KAAK;gBACL,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,QAAQ;aACjB,CAAC;SACH;aAAM,IAAI,KAAK,IAAI,IAAI,EAAE;YACxB,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;aAC5B;YAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK;gBACL,MAAM,EAAE,UAAU;aACnB,CAAC;SACH;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;gBACxB,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,SAAS;aAClB,CAAC;SACH;QAED,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"]}