This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,242 @@
// Metro module 16237 (f16238).
import { AppStates, AnalyticEvents } from "../../../Constants";
import Logger from "../../debug/Logger";
import Durations from "../../../utils/Durations";
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
import Module16238 from "../../../_bundle/Module16238";
import SentryUtils_native from "../../../utils/SentryUtils.native";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { getDeviceMetadata } from "../../tti_analytics/native/TTIAnalyticsUtils";
import { isSessionExpired } from "../../analytics_sessions/SessionUtils";
import { getSession } from "../../analytics_sessions/SessionHeartbeatScheduler";
function $mk117227($env) {
return () => $env[1].ping();
}
function $mk117228($env) {
return () => $env[1].ping();
}
let c11667_8;
let env11667 = {};
const c11667_6 = new Logger("JSWatchdogManager");
const c11667_7 = 1 * Durations.Millis.HALF_SECOND;
class JSWatchdogManager extends AutomaticLifecycleManager {
_enabled = true;
_timeoutId = null;
_analyticsReportsRemaining = 3;
_cachedSession = null;
_lastSessionId = null;
_pingCompleted = true;
actions = {
APP_STATE_UPDATE: (a0) => {
this.handleAppStateUpdate(a0);
},
CONNECTION_OPEN_SUPPLEMENTAL: () => {
this.handleConnectionOpenSupplemental();
}
};
handleAppStateUpdate(a0) {
if (a0.state === AppStates.ACTIVE) {
this.startWatchdog();
} else {
this.stopWatchdog();
}
}
handleConnectionOpenSupplemental() {
setTimeout(() => {
this.startWatchdog();
}, 0);
}
async ping(r5 = false) {
let env22912 = {
$parent: env11667
};
env22912[0] = r5;
env22912[1] = this;
let c28297_0, c28297_1, c28297_2;
let c28297_3 = 0;
const r21 = env22912;
L32: {
L29: {
try {
let env31001;
c28297_1 = r21;
const r44 = env31001 = {
$parent: r21
};
c28297_0 = r44;
env31001[0] = void 0;
env31001[1] = void 0;
env22912[1]._pingCompleted = false;
c28297_3 = 2;
env31001[0] = await env22912[1].getCurrentSessionId();
if (env31001[0] == null) {
if (env22912[1]._enabled) {
const r172 = env22912[1];
const r173 = setTimeout;
r172._timeoutId = r173($mk117227(env22912), c11667_7);
}
c28297_3 = 0;
env22912[1]._pingCompleted = true;
break L32;
}
if (await (Module16238 == null ? void 0 : Module16238.ping(Date.now(), env31001[0], env22912[0], false))) {
env31001[1] = Module16238 == null ? void 0 : Module16238.checkForStallReport();
if (env31001[1] != null) {
if (env22912[1]._lastSessionId !== env31001[0]) {
env22912[1]._lastSessionId = env31001[0];
env22912[1]._analyticsReportsRemaining = 3;
}
const r121 = env22912[1];
const r123 = +r121._analyticsReportsRemaining;
r121._analyticsReportsRemaining = r123 - 1;
if (r123 > 0) {
env22912[1].reportStall(env31001[1], env31001[0], false, env22912[1]._analyticsReportsRemaining);
}
if (env22912[1]._analyticsReportsRemaining === 0) {
env22912[1].stopWatchdog();
if (Module16238 != null) {
Module16238.disable();
}
}
}
}
if (env22912[1]._enabled) {
const r157 = env22912[1];
const r158 = setTimeout;
r157._timeoutId = r158($mk117228(env22912), c11667_7);
}
c28297_3 = 1;
c28297_3 = 0;
env22912[1]._pingCompleted = true;
} catch ($e) {
const r42 = $e;
let r13 = r42;
c28297_2 = r42;
let r43 = c28297_3;
if (r43 !== 0) {
while (true) {
if (r43 === 1) {
try {
const r204 = c28297_2;
c28297_3 = 0;
env22912[1]._pingCompleted = true;
throw r204;
} catch (r202) {
r13 = r202;
c28297_2 = r202;
r43 = c28297_3;
if (r43 === 0) {
break;
}
}
} else {
try {
const r187 = c28297_2;
c28297_3 = 1;
env31001[2] = r187;
SentryUtils_native.captureException(env31001[2]);
c28297_3 = 0;
env22912[1]._pingCompleted = true;
break L29;
} catch (r184) {
r13 = r184;
c28297_2 = r184;
r43 = c28297_3;
if (r43 === 0) {
break;
}
}
}
}
}
throw r13;
}
}
return void 0;
}
}
async startWatchdog() {
const _this = this;
let c28298_1;
let c31002_0, c31002_1;
L22: {
L21: {
c28298_1 = void 0;
c31002_0 = void 0;
c31002_1 = void 0;
if (_this._timeoutId != null) {
break L22;
}
if (Module16238 != null) {
c31002_0 = await _this.getCurrentSessionId();
if (c31002_0 == null) {
break L21;
}
if (_this._lastSessionId === c31002_0 && _this._analyticsReportsRemaining === 0) {
break L21;
}
c11667_6.info("startWatchdog()");
_this._enabled = true;
if (_this._pingCompleted) {
c31002_1 = Module16238 != null ? Module16238.checkForStallReport() : void 0;
if (c31002_1 != null) {
_this.reportStall(c31002_1, c31002_0, true, -1);
}
}
_this.ping(true);
break L21;
}
break L22;
}
return void 0;
}
}
stopWatchdog() {
c11667_6.info("stopWatchdog()");
this._enabled = false;
clearTimeout(this._timeoutId);
this._timeoutId = null;
}
reportStall(a0, a1, a2, a3) {
AnalyticsUtils.track(AnalyticEvents.APP_JS_STALLED, {
...getDeviceMetadata(),
version: 1,
stall_time: a0.stallTime,
is_previous: a2,
reports_remaining: a3,
stall_session_id: a0.sessionId !== a1 ? a0.sessionId : null,
trace: null
});
}
async getCurrentSessionId() {
let uuid, uuid2;
const _this2 = this;
let c28299_1;
let c31003_0;
L17: {
L16: {
L10: {
c28299_1 = void 0;
c31003_0 = void 0;
if (_this2._cachedSession != null && !isSessionExpired(_this2._cachedSession)) {
uuid = _this2._cachedSession.uuid;
break L10;
}
c31003_0 = await getSession();
if (c31003_0 == null) {
break L17;
}
_this2._cachedSession = c31003_0;
uuid2 = _this2._cachedSession.uuid;
break L16;
}
return uuid;
}
return uuid2;
}
return null;
}
}
c11667_8 = JSWatchdogManager;
const r53 = new JSWatchdogManager();
export default r53;