209 lines
5.6 KiB
JavaScript
209 lines
5.6 KiB
JavaScript
// Metro module 6374 (f6375).
|
|
import { DEBUG_BUILD } from "./Module6367";
|
|
import { logger } from "./consoleSandbox_6368";
|
|
import { isError, isEvent, isInstanceOf, isElement, isPlainObject, isPrimitive } from "./isInstanceOf_6375";
|
|
import { htmlTreeAsString } from "./Module6376";
|
|
import { truncate } from "./Module6377";
|
|
import { HermesBuiltin, $forInKeys } from "../_hermes/prelude";
|
|
let markFunctionWrapped, convertToPlainObject, serializeEventTarget, _dropUndefinedKeys;
|
|
const addNonEnumerableProperty = function addNonEnumerableProperty(a0, a1, a2) {
|
|
try {
|
|
Object.defineProperty(a0, a1, {
|
|
value: a2,
|
|
writable: true,
|
|
configurable: true
|
|
});
|
|
} catch ($e) {
|
|
if (DEBUG_BUILD) {
|
|
logger.log(`Failed to add non-enumerable property "${a1}" to object`, a0);
|
|
}
|
|
}
|
|
};
|
|
markFunctionWrapped = function markFunctionWrapped(a0, a1) {
|
|
try {
|
|
const prototype = a1.prototype || {};
|
|
a1.prototype = prototype;
|
|
a0.prototype = prototype;
|
|
addNonEnumerableProperty(a0, "__sentry_original__", a1);
|
|
} catch ($e) {}
|
|
};
|
|
convertToPlainObject = function convertToPlainObject(a0) {
|
|
let r26, r32, r48, r52;
|
|
if (isError(a0)) {
|
|
L28: {
|
|
r48 = {
|
|
message: a0.message,
|
|
name: a0.name,
|
|
stack: a0.stack
|
|
};
|
|
if (typeof a0 === "object" && a0 !== null) {
|
|
const r53 = {};
|
|
r52 = r53;
|
|
const r56 = $forInKeys(a0);
|
|
let r57 = 0;
|
|
const length2 = r56.length;
|
|
if (r56 === void 0) {
|
|
break L28;
|
|
}
|
|
while (true) {
|
|
r52 = r53;
|
|
const r59 = r57 < length2 ? r56[r57++] : void 0;
|
|
if (r59 === void 0) {
|
|
break L28;
|
|
}
|
|
if (Object.prototype.hasOwnProperty.call(a0, r59)) {
|
|
r53[r59] = a0[r59];
|
|
}
|
|
}
|
|
}
|
|
r52 = {};
|
|
}
|
|
HermesBuiltin.copyDataProperties(r48, r52);
|
|
return r48;
|
|
}
|
|
if (isEvent(a0)) {
|
|
L13: {
|
|
r26 = {
|
|
type: a0.type,
|
|
target: serializeEventTarget(a0.target),
|
|
currentTarget: serializeEventTarget(a0.currentTarget)
|
|
};
|
|
if (typeof a0 === "object" && a0 !== null) {
|
|
const r13 = {};
|
|
r32 = r13;
|
|
const r12 = $forInKeys(a0);
|
|
let r0 = 0;
|
|
const length = r12.length;
|
|
if (r12 === void 0) {
|
|
break L13;
|
|
}
|
|
while (true) {
|
|
r32 = r13;
|
|
const r9 = r0 < length ? r12[r0++] : void 0;
|
|
if (r9 === void 0) {
|
|
break L13;
|
|
}
|
|
if (Object.prototype.hasOwnProperty.call(a0, r9)) {
|
|
r13[r9] = a0[r9];
|
|
}
|
|
}
|
|
}
|
|
r32 = {};
|
|
}
|
|
HermesBuiltin.copyDataProperties(r26, r32);
|
|
const CustomEvent2 = globalThis.CustomEvent;
|
|
if (typeof CustomEvent2 !== "undefined" ? isInstanceOf(a0, CustomEvent) : typeof CustomEvent2 !== "undefined") {
|
|
r26.detail = a0.detail;
|
|
}
|
|
return r26;
|
|
}
|
|
return a0;
|
|
};
|
|
serializeEventTarget = function serializeEventTarget(a0) {
|
|
let r14;
|
|
try {
|
|
r14 = isElement(a0) ? htmlTreeAsString(a0) : Object.prototype.toString.call(a0);
|
|
} catch ($e) {
|
|
return "<unknown>";
|
|
}
|
|
return r14;
|
|
};
|
|
_dropUndefinedKeys = function _dropUndefinedKeys(a0, a1) {
|
|
let c15692_1;
|
|
if (!(function isPojo(a0) {
|
|
let r18;
|
|
if (isPlainObject(a0)) {
|
|
try {
|
|
const name = Object.getPrototypeOf(a0).constructor.name;
|
|
r18 = name ? name === "Object" : !name;
|
|
} catch ($e) {
|
|
return true;
|
|
}
|
|
return r18;
|
|
}
|
|
return false;
|
|
})(a0)) {
|
|
if (Array.isArray(a0)) {
|
|
const r29 = a1.get(a0);
|
|
if (r29 !== void 0) {
|
|
return r29;
|
|
}
|
|
const r30 = [];
|
|
c15692_1 = r30;
|
|
a1.set(a0, r30);
|
|
a0.forEach((item) => {
|
|
c15692_1.push(_dropUndefinedKeys(item, a1));
|
|
});
|
|
return r30;
|
|
}
|
|
return a0;
|
|
}
|
|
const r36 = a1.get(a0);
|
|
if (r36 !== void 0) {
|
|
return r36;
|
|
}
|
|
const r37 = {};
|
|
a1.set(a0, r37);
|
|
for (const item of Object.getOwnPropertyNames(a0)) {
|
|
if (a0[item] !== void 0) {
|
|
r37[item] = _dropUndefinedKeys(a0[item], a1);
|
|
}
|
|
}
|
|
return r37;
|
|
};
|
|
export { addNonEnumerableProperty };
|
|
export { convertToPlainObject };
|
|
export function dropUndefinedKeys(a0) {
|
|
return _dropUndefinedKeys(a0, new Map());
|
|
}
|
|
export function extractExceptionKeysForMessage(a0, r5 = 40) {
|
|
const r15 = Object.keys(convertToPlainObject(a0));
|
|
r15.sort();
|
|
const r18 = r15[0];
|
|
if (r18) {
|
|
if (r18.length >= r5) {
|
|
return truncate(r18, r5);
|
|
}
|
|
let length = r15.length;
|
|
while (length > 0) {
|
|
const r12 = r15.slice(0, length).join(", ");
|
|
const length2 = r12.length;
|
|
if (!(length2 > r5)) {
|
|
return length !== r15.length ? truncate(r12, r5) : r12;
|
|
}
|
|
length = length - 1;
|
|
}
|
|
return "";
|
|
}
|
|
return "[object has no keys]";
|
|
}
|
|
export function fill(a0, a1, a2) {
|
|
if (a1 in a0) {
|
|
const r5 = a0[a1];
|
|
const r8 = a2(r5);
|
|
if (typeof r8 === "function") {
|
|
markFunctionWrapped(r8, r5);
|
|
}
|
|
try {
|
|
a0[a1] = r8;
|
|
} catch ($e) {
|
|
if (DEBUG_BUILD) {
|
|
logger.log(`Failed to replace method "${a1}" in object`, a0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export function getOriginalFunction(a0) {
|
|
return a0.__sentry_original__;
|
|
}
|
|
export { markFunctionWrapped };
|
|
export function objectify(a0) {
|
|
return a0 == null === true ? new String(a0) : (typeof a0 !== "symbol" ? typeof a0 === "bigint" : typeof a0 === "symbol") === true ? Object(a0) : isPrimitive(a0) === true ? new a0.constructor(a0) : a0;
|
|
}
|
|
export function urlEncode(a0) {
|
|
return Object.entries(a0).map((item) => {
|
|
const [r24, r25] = item;
|
|
return `${encodeURIComponent(r24)}=${encodeURIComponent(r25)}`;
|
|
}).join("&");
|
|
}
|