Files
discord-decomp/sources/by-id/module-06385-RVEngagedIndicesTrackerImpl.js
2026-07-28 01:06:53 +03:00

172 lines
7.9 KiB
JavaScript

/* Metro module 6385; source: unknown; dependencies: [6386, 6374, 6375, 6380, 6390] */
import ClassCallCheck from './module-06374-ClassCallCheck.js'; /* Metro dependency 6374 */
import CreateClass from './module-06375-CreateClass.js'; /* Metro dependency 6375 */
import Module06386 from './module-06386.js'; /* Metro dependency 6386 */
import * as PlatformConfigModule from './module-06380-PlatformConfig.js'; /* Metro dependency 6380 */
import * as ConsecutiveNumbersModule from './module-06390-ConsecutiveNumbers.js'; /* Metro dependency 6390 */
function _fun50051(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#50051, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6563:6, offset: 0x01210060, size: 120 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
exports.RVEngagedIndicesTrackerImpl = _fun50052();
function _fun50052() { // fn#50052, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6563:132, offset: 0x012100d8, size: 247 bytes, params: 1, frame: 15
return CreateClass(RVEngagedIndicesTrackerImpl, [{key: 'updateScrollOffset', value: value_50054},
{key: 'updateVelocityHistory', value: function(a0) {
this.velocityHistory[this.velocityIndex] = a0;
this.velocityIndex = (this.velocityIndex + 1) % this.velocityHistory.length;
}}, {key: 'isScrollingBackward', value: function() {
var r3;
var r4;
var r5;
var r8;
var r9;
var r0;
var r1;
var value2;
var value3;
var value4;
var value = 0;
if (value < this.velocityHistory.length) {
r3 = value;
r4 = value;
r5 = value;
while (true) {
if (!(this.velocityHistory[r3] > value)) {
if (this.velocityHistory[r3] < value) {
value2 = typeof r4 === 'bigint' ? r4 + 1n : +r4 + 1;
r8 = value2;
r9 = r5;
break;
}
r8 = r4;
r9 = r5;
break;
}
value3 = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1;
r8 = r4;
r9 = value3;
value4 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
if (value4 < this.velocityHistory.length) {
r3 = value4;
r4 = r8;
r5 = r9;
continue;
}
r0 = r8;
r1 = r9;
break;
}
} else {
r0 = value;
r1 = value;
}
return r1 < r0;
}}, {key: 'getMedianVelocity', value: value_50057}, {key: 'getProjectedScrollOffset', value: function(a0, a1) {
return a0 + this.getMedianVelocity() * a1;
}}, {key: 'computeVisibleIndices', value: function(a0) {
var value = a0.getWindowsSize();
var isHorizontal = a0.isHorizontal();
var scrollOffset = this.scrollOffset;
return a0.getVisibleLayouts(scrollOffset, scrollOffset + (isHorizontal ? value.width : value.height));
}}, {key: 'getEngagedIndices', value: function() {
return this.engagedIndices;
}}, {key: 'setScrollDirection', value: function(a0) {
if (a0 === 'forward') {
this.velocityHistory = [0, 0, 0, 0.1, 0.1];
this.velocityIndex = 0;
} else {
this.velocityHistory = [0, 0, 0, -0.1, -0.1];
this.velocityIndex = 0;
}
}}, {key: 'resetVelocityHistory', value: function() {
var isScrollingBackward = this.isScrollingBackward();
var setScrollDirection = this.setScrollDirection;
if (isScrollingBackward) {
Reflect.apply(setScrollDirection, this, ['backward']);
} else {
Reflect.apply(setScrollDirection, this, ['forward']);
}
}}]);
function RVEngagedIndicesTrackerImpl() { // fn#50053, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6563:153, offset: 0x012101cf, size: 200 bytes, params: 1, frame: 15
env1_3(this, RVEngagedIndicesTrackerImpl);
this.scrollOffset = 0;
const PlatformConfig = (PlatformConfigModule).PlatformConfig;
this.drawDistance = PlatformConfig.defaultDrawDistance;
this.enableOffsetProjection = true;
this.averageRenderTime = 16;
this.forceDisableOffsetProjection = false;
const ConsecutiveNumbers = (ConsecutiveNumbersModule).ConsecutiveNumbers;
const EMPTY = ConsecutiveNumbers.EMPTY;
this.engagedIndices = EMPTY;
this.smallMultiplier = 0.3;
this.largeMultiplier = 0.7;
this.velocityHistory = [0, 0, 0, -0.1, -0.1];
this.velocityIndex = 0;
}
function value_50057() { // fn#50057, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6563:1700, offset: 0x012104d1, size: 115 bytes, params: 1, frame: 13
var environment;
var Math;
let value = environment.__proto__;
value = env1_2(this.velocityHistory);
value = value.sort(function(a0, a1) {
return a0 - a1;
});
const length = value.length;
if (length % 2 === 1) {
Math = global.Math;
return value[Math.floor(length / 2)];
}
const value2 = length / 2;
return (value[value2 - 1] + value[value2]) / 2;
}
}
}
function value_50054(a0, a1, a2) { // fn#50054, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6563:597, offset: 0x01210297, size: 393 bytes, params: 4, frame: 21
let value = a0;
this.scrollOffset = value;
const windowsSize = a2.getWindowsSize();
const isHorizontal2 = a2.isHorizontal();
if (a1) {
this.updateVelocityHistory(isHorizontal2 ? a1.x : a1.y);
}
const isScrollingBackward2 = this.isScrollingBackward();
const r10 = this.enableOffsetProjection ? this.forceDisableOffsetProjection ? value : this.getProjectedScrollOffset(value,
this.averageRenderTime) : value;
value = r10 + (isHorizontal2 ? windowsSize.width : windowsSize.height);
const value3 = 2 * this.drawDistance;
let r2 = isScrollingBackward2 ? this.largeMultiplier : this.smallMultiplier;
let r3 = isScrollingBackward2 ? this.smallMultiplier : this.largeMultiplier;
let Math = global.Math;
const value4 = Math.ceil(value3 * r2);
Math = global.Math;
const value5 = Math.ceil(value3 * r3);
Math = global.Math;
const value6 = Math.max(0, r10 - value4);
value += value5;
Math = global.Math;
value += Math.max(0, value4 - r10);
const layoutSize = a2.getLayoutSize();
const r1 = isHorizontal2 ? layoutSize.width : layoutSize.height;
if (value > r1) {
value -= r1;
value = global.Math.max(0, value6 - value);
r2 = r1;
r3 = value;
} else {
r2 = value;
r3 = value6;
}
value = a2.getVisibleLayouts(r3, r2);
const engagedIndices = this.engagedIndices;
this.engagedIndices = value;
return value.equals(engagedIndices) ? undefined : value;
}
global.__d(_fun50051, 6385, [6386, 6374, 6375, 6380,
6390]) /* metro module 6385, dependencies: [6386, 6374, 6375, 6380, 6390] */;