feat: initial commit

This commit is contained in:
Carlos
2024-08-12 23:06:35 -04:00
parent c581ce5ad2
commit de4ae5d068
776 changed files with 3868 additions and 15649 deletions

View File

@@ -14,16 +14,6 @@ try {
var bufferFrom = require('buffer-from');
/**
* Requires a module which is protected against bundler minification.
*
* @param {NodeModule} mod
* @param {string} request
*/
function dynamicRequire(mod, request) {
return mod.require(request);
}
// Only install once if called multiple times
var errorFormatterInstalled = false;
var uncaughtShimInstalled = false;
@@ -59,26 +49,6 @@ function hasGlobalProcessEventEmitter() {
return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
}
function globalProcessVersion() {
if ((typeof process === 'object') && (process !== null)) {
return process.version;
} else {
return '';
}
}
function globalProcessStderr() {
if ((typeof process === 'object') && (process !== null)) {
return process.stderr;
}
}
function globalProcessExit(code) {
if ((typeof process === 'object') && (process !== null) && (typeof process.exit === 'function')) {
return process.exit(code);
}
}
function handlerExec(list) {
return function(arg) {
for (var i = 0; i < list.length; i++) {
@@ -365,13 +335,8 @@ function cloneCallSite(frame) {
return object;
}
function wrapCallSite(frame, state) {
// provides interface backward compatibility
if (state === undefined) {
state = { nextPosition: null, curPosition: null }
}
function wrapCallSite(frame) {
if(frame.isNative()) {
state.curPosition = null;
return frame;
}
@@ -385,11 +350,7 @@ function wrapCallSite(frame, state) {
// Fix position in Node where some (internal) code is prepended.
// See https://github.com/evanw/node-source-map-support/issues/36
// Header removed in node at ^10.16 || >=11.11.0
// v11 is not an LTS candidate, we can just test the one version with it.
// Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
var noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
var headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
var headerLength = 62;
if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) {
column -= headerLength;
}
@@ -399,15 +360,9 @@ function wrapCallSite(frame, state) {
line: line,
column: column
});
state.curPosition = position;
frame = cloneCallSite(frame);
var originalFunctionName = frame.getFunctionName;
frame.getFunctionName = function() {
if (state.nextPosition == null) {
return originalFunctionName();
}
return state.nextPosition.name || originalFunctionName();
};
frame.getFunctionName = function() { return position.name || originalFunctionName(); };
frame.getFileName = function() { return position.source; };
frame.getLineNumber = function() { return position.line; };
frame.getColumnNumber = function() { return position.column + 1; };
@@ -440,14 +395,9 @@ function prepareStackTrace(error, stack) {
var message = error.message || '';
var errorString = name + ": " + message;
var state = { nextPosition: null, curPosition: null };
var processedStack = [];
for (var i = stack.length - 1; i >= 0; i--) {
processedStack.push('\n at ' + wrapCallSite(stack[i], state));
state.nextPosition = state.curPosition;
}
state.curPosition = state.nextPosition = null;
return errorString + processedStack.reverse().join('');
return errorString + stack.map(function(frame) {
return '\n at ' + wrapCallSite(frame);
}).join('');
}
// Generate position and snippet of original source with pointer
@@ -486,9 +436,8 @@ function printErrorAndExit (error) {
var source = getErrorSource(error);
// Ensure error is printed synchronously and not truncated
var stderr = globalProcessStderr();
if (stderr && stderr._handle && stderr._handle.setBlocking) {
stderr._handle.setBlocking(true);
if (process.stderr._handle && process.stderr._handle.setBlocking) {
process.stderr._handle.setBlocking(true);
}
if (source) {
@@ -497,7 +446,7 @@ function printErrorAndExit (error) {
}
console.error(error.stack);
globalProcessExit(1);
process.exit(1);
}
function shimEmitUncaughtException () {
@@ -557,8 +506,12 @@ exports.install = function(options) {
// Support runtime transpilers that include inline source maps
if (options.hookRequire && !isInBrowser()) {
// Use dynamicRequire to avoid including in browser bundles
var Module = dynamicRequire(module, 'module');
var Module;
try {
Module = require('module');
} catch (err) {
// NOP: Loading in catch block to convert webpack error to warning.
}
var $compile = Module.prototype._compile;
if (!$compile.__sourceMapSupport) {
@@ -588,17 +541,6 @@ exports.install = function(options) {
var installHandler = 'handleUncaughtExceptions' in options ?
options.handleUncaughtExceptions : true;
// Do not override 'uncaughtException' with our own handler in Node.js
// Worker threads. Workers pass the error to the main thread as an event,
// rather than printing something to stderr and exiting.
try {
// We need to use `dynamicRequire` because `require` on it's own will be optimized by WebPack/Browserify.
var worker_threads = dynamicRequire(module, 'worker_threads');
if (worker_threads.isMainThread === false) {
installHandler = false;
}
} catch(e) {}
// Provide the option to not install the uncaught exception handler. This is
// to support other uncaught exception handlers (in test frameworks, for
// example). If this handler is not installed and there are no other uncaught
@@ -619,7 +561,7 @@ exports.resetRetrieveHandlers = function() {
retrieveFileHandlers = originalRetrieveFileHandlers.slice(0);
retrieveMapHandlers = originalRetrieveMapHandlers.slice(0);
retrieveSourceMap = handlerExec(retrieveMapHandlers);
retrieveFile = handlerExec(retrieveFileHandlers);
}