Files
discord-decomp/_bundle/getStylesFromObject.js
T
2026-11-01 12:12:55 +02:00

422 lines
12 KiB
JavaScript

// Metro module 1779 (f1780).
import { isJest } from "./Module1609";
import "./Module1617";
import { HermesBuiltin, $forInKeys } from "../_hermes/prelude";
let getCurrentStyle, checkEqual, compareAndFormatDifferences, c1504_8;
let c1504_3 = {
fps: 60
};
const getStylesFromObject = (a0) => a0 === void 0 ? {} : Object.fromEntries(Object.entries(a0).map((item) => {
const [r13, r14] = item;
return [r13, r14._isReanimatedSharedValue ? r14.value : r14];
}));
getCurrentStyle = (a0) => {
let r47;
const style = a0.props.style;
let c13224_0 = {};
if (Array.isArray(style)) {
style.forEach((item) => {
c13224_0 = {
...c13224_0,
...item
};
});
}
const jestInlineStyle = a0.props.jestInlineStyle;
const value = a0.props.jestAnimatedStyle?.value;
if (!Array.isArray(jestInlineStyle)) {
const stylesFromObject = getStylesFromObject(jestInlineStyle);
const r44 = ((a0) => a0 ? Object.keys(a0).length === 0 : !a0)(value);
const r45 = {};
if (r44) {
HermesBuiltin.copyDataProperties(r45, stylesFromObject);
r47 = r45;
} else {
HermesBuiltin.copyDataProperties(r45, value);
r47 = r45;
}
c13224_0 = r47;
return r47;
}
for (const item of jestInlineStyle) {
if (!("jestAnimatedValues" in item)) {
c13224_0 = {
...c13224_0,
...getStylesFromObject(item)
};
}
}
const r69 = {
...c13224_0,
...value
};
c13224_0 = r69;
return r69;
};
checkEqual = (a0, a1) => {
L17: {
if (Array.isArray(a1)) {
if (Array.isArray(a0) && a1.length === a0.length) {
const r29 = 0 < a0.length;
let r31 = 0;
if (!r29) {
break L17;
}
while (true) {
const r35 = checkEqual(a0[r31], a1[r31]);
const r1 = r31;
if (!r35) {
return false;
}
r31 = r1 + 1;
if (!(r31 < a0.length)) {
break L17;
}
}
}
return false;
}
if (typeof a0 === "object" && a0) {
if (typeof a1 === "object" && a1) {
const r11 = $forInKeys(a1);
let r2 = 0;
const length = r11.length;
if (r11 === void 0) {
break L17;
}
while (true) {
const r17 = r2 < length ? r11[r2++] : void 0;
if (r17 === void 0) {
break L17;
}
if (!checkEqual(a0[r17], a1[r17])) {
return false;
}
}
}
return false;
}
return a0 === a1;
}
return true;
};
compareAndFormatDifferences = function compareAndFormatDifferences(a0, a1, r19 = false) {
let r8, r12, r14, r71, r89, r115, r118;
let c13225_0, c13225_1, c13225_2;
c13225_0 = void 0;
c13225_1 = void 0;
c13225_2 = void 0;
const r20 = [];
let r13 = true;
let r15 = true;
for (const key in a1) {
r14 = r13;
r15 = r14;
const property = key;
const r28 = a0[property];
const r27 = a1[property];
L55: {
if (Array.isArray(r27)) {
const isArray2 = Array.isArray(r28);
r12 = false;
if (isArray2) {
const length5 = r27.length;
const length6 = r28.length;
r12 = false;
if (length5 === length6) {
const r78 = 0 < r28.length;
let r79 = 0;
r12 = true;
if (r78) {
do {
const r81 = r28[r79];
const r82 = r27[r79];
const r83 = r79;
L53: {
if (Array.isArray(r82)) {
const isArray3 = Array.isArray(r81);
r89 = false;
if (isArray3) {
const length8 = r82.length;
const length9 = r81.length;
r89 = false;
if (length8 === length9) {
const r106 = 0 < r81.length;
let r107 = 0;
r89 = true;
if (r106) {
do {
const r111 = checkEqual(r81[r107], r82[r107]);
const r112 = r107;
r89 = false;
if (!r111) {
break;
}
const r113 = r112 + 1;
r115 = r113 < r81.length;
r107 = r113;
r89 = true;
} while (r115);
}
}
}
} else {
if (typeof r81 === "object" && r81) {
r89 = false;
if (typeof r82 !== "object") {
break L53;
}
r89 = false;
if (!r82) {
break L53;
}
r89 = true;
const r91 = $forInKeys(r82);
let r92 = 0;
const length7 = r91.length;
if (r91 === void 0) {
break L53;
}
while (true) {
r89 = true;
const r94 = r92 < length7 ? r91[r92++] : void 0;
if (r94 === void 0) {
break L53;
}
const r99 = checkEqual(r81[r94], r82[r94]);
r89 = false;
if (!r99) {
break L53;
}
}
}
r89 = r81 === r82;
}
}
r12 = false;
if (!r89) {
break;
}
const r116 = r83 + 1;
r118 = r116 < r28.length;
r79 = r116;
r12 = true;
} while (r118);
}
}
}
} else {
if (typeof r28 === "object" && r28) {
r12 = false;
if (typeof r27 !== "object") {
break L55;
}
r12 = false;
if (!r27) {
break L55;
}
r12 = true;
const r32 = $forInKeys(r27);
let r5 = 0;
const length2 = r32.length;
if (r32 === void 0) {
break L55;
}
while (true) {
r12 = true;
const r47 = r5 < length2 ? r32[r5++] : void 0;
if (r47 === void 0) {
break L55;
}
const r34 = r28[r47];
const r48 = r27[r47];
L30: {
if (Array.isArray(r48)) {
const isArray = Array.isArray(r34);
r8 = false;
if (isArray) {
const length3 = r48.length;
const length4 = r34.length;
r8 = false;
if (length3 === length4) {
const r62 = 0 < r34.length;
let r63 = 0;
r8 = true;
if (r62) {
do {
const r67 = checkEqual(r34[r63], r48[r63]);
const r68 = r63;
r8 = false;
if (!r67) {
break;
}
const r69 = r68 + 1;
r71 = r69 < r34.length;
r63 = r69;
r8 = true;
} while (r71);
}
}
}
} else {
if (typeof r34 === "object" && r34) {
r8 = false;
if (typeof r48 !== "object") {
break L30;
}
r8 = false;
if (!r48) {
break L30;
}
r8 = true;
const r37 = $forInKeys(r48);
let r1 = 0;
const length = r37.length;
if (r37 === void 0) {
break L30;
}
while (true) {
r8 = true;
const r54 = r1 < length ? r37[r1++] : void 0;
if (r54 === void 0) {
break L30;
}
const r9 = checkEqual(r34[r54], r48[r54]);
r8 = false;
if (!r9) {
break L30;
}
}
}
r8 = r34 === r48;
}
}
r12 = false;
if (!r8) {
break L55;
}
}
}
r12 = r28 === r27;
}
}
r13 = r14;
if (!r12) {
r20.push({
property,
current: a0[property],
expect: a1[property]
});
r13 = false;
}
}
r14 = r13;
r15 = r14;
let r124 = r15;
if (r19) {
const length10 = Object.keys(a0).length;
const length11 = Object.keys(a1).length;
r124 = r15;
if (length10 !== length11) {
r124 = false;
for (const key2 in a0) {
r124 = false;
const property2 = key2;
if (a1[property2] === void 0) {
r20.push({
property: property2,
current: a0[property2],
expect: a1[property2]
});
}
}
r124 = false;
}
}
if (r124) {
return {
message: () => "ok",
pass: true
};
}
c13225_0 = JSON.stringify(a0);
c13225_1 = JSON.stringify(a1);
c13225_2 = r20.map((item) => `- '${item.property}' should be ${JSON.stringify(item.expect)}, but is ${JSON.stringify(item.current)}`).join("\n");
return {
message: () => `Expected: ${c13225_1}
Received: ${c13225_0}
Differences:
${c13225_2}`,
pass: false
};
};
c1504_8 = Math.round(1000 / c1504_3.fps);
isJest();
export const withReanimatedTimer = (a0) => {
console.warn("This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing");
jest.useFakeTimers();
a0();
jest.runOnlyPendingTimers();
jest.useRealTimers();
};
export const advanceAnimationByTime = function(r4 = c1504_8) {
console.warn("This method is deprecated, use jest.advanceTimersByTime directly");
jest.advanceTimersByTime(r4);
jest.runOnlyPendingTimers();
};
export const advanceAnimationByFrame = (a0) => {
console.warn("This method is deprecated, use jest.advanceTimersByTime directly");
jest.advanceTimersByTime(a0 * c1504_8);
jest.runOnlyPendingTimers();
};
export const setUpTests = function(r4 = {}) {
let expect = global.expect;
if (expect === void 0) {
const r12 = require("expect");
expect = r12 !== void 0 && r12.extend !== void 0 ? r12 : r12.default;
}
c1504_8 = Math.round(1000 / ({
...c1504_3,
...r4
}).fps);
expect.extend({
toHaveAnimatedProps: (a0, a1) => {
let r20, r26;
if (a0.props.jestAnimatedProps && Object.keys(a0.props.jestAnimatedProps.value).length === 0) {
r26 = {
message: () => "Component doesn't have props.",
pass: false
};
} else {
const value = a0.props.jestAnimatedProps?.value;
const r19 = {};
if (value) {
HermesBuiltin.copyDataProperties(r19, value);
r20 = r19;
} else {
r20 = r19;
}
r26 = compareAndFormatDifferences(r20, a1);
}
return r26;
}
});
expect.extend({
toHaveAnimatedStyle: function toHaveAnimatedStyle(a0, a1, r4 = {}) {
let r9;
if (a0.props.style) {
const shouldMatchAllProps = r4.shouldMatchAllProps;
r9 = compareAndFormatDifferences(getCurrentStyle(a0), a1, shouldMatchAllProps);
} else {
r9 = {
message: () => "Component doesn't have a style.",
pass: false
};
}
return r9;
}
});
};
export const getAnimatedStyle = (a0) => getCurrentStyle(a0);