123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- Object.defineProperty(exports, '__esModule', { value: true });
- const object = require('./object.js');
- const string = require('./string.js');
- const worldwide = require('./worldwide.js');
- function uuid4() {
- const gbl = worldwide.GLOBAL_OBJ ;
- const crypto = gbl.crypto || gbl.msCrypto;
- let getRandomByte = () => Math.random() * 16;
- try {
- if (crypto && crypto.randomUUID) {
- return crypto.randomUUID().replace(/-/g, '');
- }
- if (crypto && crypto.getRandomValues) {
- getRandomByte = () => {
-
-
-
-
- const typedArray = new Uint8Array(1);
- crypto.getRandomValues(typedArray);
- return typedArray[0];
- };
- }
- } catch (_) {
-
-
- }
-
-
- return (([1e7] ) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, c =>
-
- ((c ) ^ ((getRandomByte() & 15) >> ((c ) / 4))).toString(16),
- );
- }
- function getFirstException(event) {
- return event.exception && event.exception.values ? event.exception.values[0] : undefined;
- }
- function getEventDescription(event) {
- const { message, event_id: eventId } = event;
- if (message) {
- return message;
- }
- const firstException = getFirstException(event);
- if (firstException) {
- if (firstException.type && firstException.value) {
- return `${firstException.type}: ${firstException.value}`;
- }
- return firstException.type || firstException.value || eventId || '<unknown>';
- }
- return eventId || '<unknown>';
- }
- function addExceptionTypeValue(event, value, type) {
- const exception = (event.exception = event.exception || {});
- const values = (exception.values = exception.values || []);
- const firstException = (values[0] = values[0] || {});
- if (!firstException.value) {
- firstException.value = value || '';
- }
- if (!firstException.type) {
- firstException.type = type || 'Error';
- }
- }
- function addExceptionMechanism(event, newMechanism) {
- const firstException = getFirstException(event);
- if (!firstException) {
- return;
- }
- const defaultMechanism = { type: 'generic', handled: true };
- const currentMechanism = firstException.mechanism;
- firstException.mechanism = { ...defaultMechanism, ...currentMechanism, ...newMechanism };
- if (newMechanism && 'data' in newMechanism) {
- const mergedData = { ...(currentMechanism && currentMechanism.data), ...newMechanism.data };
- firstException.mechanism.data = mergedData;
- }
- }
- const SEMVER_REGEXP =
- /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
- function parseSemver(input) {
- const match = input.match(SEMVER_REGEXP) || [];
- const major = parseInt(match[1], 10);
- const minor = parseInt(match[2], 10);
- const patch = parseInt(match[3], 10);
- return {
- buildmetadata: match[5],
- major: isNaN(major) ? undefined : major,
- minor: isNaN(minor) ? undefined : minor,
- patch: isNaN(patch) ? undefined : patch,
- prerelease: match[4],
- };
- }
- function addContextToFrame(lines, frame, linesOfContext = 5) {
-
- if (frame.lineno === undefined) {
- return;
- }
- const maxLines = lines.length;
- const sourceLine = Math.max(Math.min(maxLines - 1, frame.lineno - 1), 0);
- frame.pre_context = lines
- .slice(Math.max(0, sourceLine - linesOfContext), sourceLine)
- .map((line) => string.snipLine(line, 0));
- frame.context_line = string.snipLine(lines[Math.min(maxLines - 1, sourceLine)], frame.colno || 0);
- frame.post_context = lines
- .slice(Math.min(sourceLine + 1, maxLines), sourceLine + 1 + linesOfContext)
- .map((line) => string.snipLine(line, 0));
- }
- function checkOrSetAlreadyCaught(exception) {
-
- if (exception && (exception ).__sentry_captured__) {
- return true;
- }
- try {
-
-
- object.addNonEnumerableProperty(exception , '__sentry_captured__', true);
- } catch (err) {
-
- }
- return false;
- }
- function arrayify(maybeArray) {
- return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
- }
- exports.addContextToFrame = addContextToFrame;
- exports.addExceptionMechanism = addExceptionMechanism;
- exports.addExceptionTypeValue = addExceptionTypeValue;
- exports.arrayify = arrayify;
- exports.checkOrSetAlreadyCaught = checkOrSetAlreadyCaught;
- exports.getEventDescription = getEventDescription;
- exports.parseSemver = parseSemver;
- exports.uuid4 = uuid4;
|