1"use strict"; 2/** 3 * Copyright (c) 650 Industries. 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 */ 9var __importDefault = (this && this.__importDefault) || function (mod) { 10 return (mod && mod.__esModule) ? mod : { "default": mod }; 11}; 12Object.defineProperty(exports, "__esModule", { value: true }); 13exports.symbolicate = exports.deleteStack = void 0; 14const symbolicateStackTrace_1 = __importDefault(require("../modules/symbolicateStackTrace")); 15const cache = new Map(); 16/** 17 * Sanitize because sometimes, `symbolicateStackTrace` gives us invalid values. 18 */ 19const sanitize = ({ stack: maybeStack, codeFrame, }) => { 20 if (!Array.isArray(maybeStack)) { 21 throw new Error('Expected stack to be an array.'); 22 } 23 const stack = []; 24 for (const maybeFrame of maybeStack) { 25 let collapse = false; 26 if ('collapse' in maybeFrame) { 27 if (typeof maybeFrame.collapse !== 'boolean') { 28 throw new Error('Expected stack frame `collapse` to be a boolean.'); 29 } 30 collapse = maybeFrame.collapse; 31 } 32 stack.push({ 33 arguments: [], 34 column: maybeFrame.column, 35 file: maybeFrame.file, 36 lineNumber: maybeFrame.lineNumber, 37 methodName: maybeFrame.methodName, 38 collapse, 39 }); 40 } 41 return { stack, codeFrame }; 42}; 43function deleteStack(stack) { 44 cache.delete(stack); 45} 46exports.deleteStack = deleteStack; 47function symbolicate(stack) { 48 let promise = cache.get(stack); 49 if (promise == null) { 50 promise = (0, symbolicateStackTrace_1.default)(stack).then(sanitize); 51 cache.set(stack, promise); 52 } 53 return promise; 54} 55exports.symbolicate = symbolicate; 56//# sourceMappingURL=LogBoxSymbolication.js.map