decord/source/modules/routing/RouteManager.tsx

246 lines
7.7 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11055
// Function ID: 11056
2026-07-29 08:29:29 +00:00
// Name: initialize
2026-08-25 06:04:03 +00:00
// Dependencies: [5102, 11056, 676, 1222, 11057, 7592, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 11055 (initialize)
import closure_2 from "_handleConnectionOpen" /* 5102 */;
import closure_3 from "getMatchData" /* 11056 */;
2026-08-24 06:08:38 +00:00
import { Routes } from "ME" /* 676 */;
import set from "set" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
let set = arg1;
2026-07-29 08:29:29 +00:00
class RouteManager {
constructor() {
obj = Object.create(new.target.prototype);
2026-08-24 06:08:38 +00:00
closure_0 = obj;
2026-07-29 08:29:29 +00:00
set = new Set();
obj.rewrites = set;
set1 = new Set();
obj.listeners = set1;
obj.routeChangeCount = 0;
obj.timer = -1;
obj.connected = false;
obj.handleConnectionChange = function handleConnectionChange() {
2026-08-24 06:08:38 +00:00
const isConnectedResult = closure_1_2.isConnected();
2026-07-29 08:29:29 +00:00
let tmp2 = isConnectedResult;
if (isConnectedResult) {
tmp2 = !obj.connected;
}
obj.connected = isConnectedResult;
if (tmp2) {
obj.routeChangeCount = 0;
2026-08-24 06:08:38 +00:00
obj.executeRouteRewrites(obj(closure_1_1[3]).getHistory().location, "REPLACE");
const obj2 = obj(closure_1_1[3]);
2026-07-29 08:29:29 +00:00
}
};
obj.handleRouteChange = function handleRouteChange(pathname, REPLACE) {
if ("POP" !== REPLACE) {
if (!obj.executeRouteRewrites(pathname, REPLACE)) {
2026-08-24 06:08:38 +00:00
obj = obj(closure_1_1[4]);
2026-07-29 08:29:29 +00:00
if (!obj.convertRouteToNavigation(pathname)) {
2026-08-24 06:08:38 +00:00
tmp2(tmp3[3]).replaceWith(closure_1_4.ME);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp2 = obj;
2026-08-24 06:08:38 +00:00
tmp3 = closure_1_1;
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
const state = closure_1_3.getState();
2026-07-29 08:29:29 +00:00
if (state.basePath !== pathname.pathname) {
state.resetPath(pathname.pathname);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const iter = obj.listeners[Symbol.iterator]();
if (iter === undefined) {
obj.routeChangeCount = 0;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
try {
tmp8(pathname, REPLACE);
} catch (err) {
}
2026-07-20 16:05:17 +00:00
}
};
2026-07-29 08:29:29 +00:00
obj.handleKeybindRouteChange = function handleKeybindRouteChange(path) {
if (-1 !== obj.timer) {
const _clearTimeout = clearTimeout;
clearTimeout(tmp.timer);
}
if (null != path.path) {
const _setTimeout = setTimeout;
tmp.timer = setTimeout(tmp.flushRoute, 200);
}
};
obj.flushRoute = function flushRoute() {
clearTimeout(obj.timer);
2026-08-24 06:08:38 +00:00
const state = closure_1_3.getState();
2026-07-29 08:29:29 +00:00
if (null != state.path) {
2026-08-24 06:08:38 +00:00
obj = obj(closure_1_1[3]);
2026-07-29 08:29:29 +00:00
obj.transitionTo(state.path);
}
};
return obj;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const prototype = RouteManager.prototype;
prototype["initialize"] = function initialize() {
this.cleanup();
2026-08-24 06:08:38 +00:00
const history = set(1222).getHistory();
2026-07-29 08:29:29 +00:00
this.unlistenHistory = history.listen(this.handleRouteChange);
2026-08-24 06:08:38 +00:00
const obj = set(1222);
const state = closure_3.getState();
state.resetPath(set(1222).getHistory().location.pathname);
this.unlistenKeyboardChange = closure_3.subscribe(this.handleKeybindRouteChange);
closure_2.addChangeListener(this.handleConnectionChange);
2026-07-29 08:29:29 +00:00
};
prototype["executeRouteRewrites"] = function executeRouteRewrites(location, REPLACE) {
this.routeChangeCount = this.routeChangeCount + 1;
if (this.routeChangeCount < 10) {
const rewrites = this.rewrites;
let obj = rewrites[Symbol.iterator]();
while (obj !== undefined) {
2026-08-24 06:08:38 +00:00
let tmp11 = set;
2026-07-29 08:29:29 +00:00
let tmp12 = dependencyMap;
2026-08-24 06:08:38 +00:00
let obj2 = set(1222);
2026-07-29 08:29:29 +00:00
let tmp9Result = tmp9(location, REPLACE);
let tmp14 = tmp9Result;
if (null != tmp9Result) {
2026-08-25 06:04:03 +00:00
let tmp11Result = tmp11(7592);
2026-07-29 08:29:29 +00:00
obj = { message: "RouteManager.handleRouteChange: A route rewrite is replacing the current route", data: null };
obj = { replacePath: null, previousPath: null };
obj[0] = tmp9Result.path;
obj[1] = obj2.getHistory().location.pathname;
obj[1] = obj;
let addBreadcrumbResult = tmp11Result.addBreadcrumb(obj);
tmp11Result = tmp11(1222);
let replaceWithResult = tmp11Result.replaceWith(tmp9Result.path, tmp9Result.state);
let tmp17 = obj;
obj.return();
let flag = true;
return true;
}
}
return false;
} else {
const _Error = Error;
2026-08-24 06:08:38 +00:00
error = new Error("RouteManager: Something has gone horribly wrong with rewrites");
2026-07-29 08:29:29 +00:00
throw error;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
prototype["cleanup"] = function cleanup() {
const self = this;
const unlistenHistory = this.unlistenHistory;
if (unlistenHistory != null) {
unlistenHistory();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
self.unlistenHistory = undefined;
const unlistenKeyboardChange = self.unlistenKeyboardChange;
if (unlistenKeyboardChange != null) {
const result = unlistenKeyboardChange();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
self.unlistenKeyboardChange = undefined;
2026-08-24 06:08:38 +00:00
closure_2.removeChangeListener(self.handleConnectionChange);
2026-07-29 08:29:29 +00:00
};
prototype["addRouteChangeListener"] = function addRouteChangeListener(hideLaunchPad) {
const self = this;
if (null != this.unlistenHistory) {
2026-08-24 06:08:38 +00:00
hideLaunchPad(set(self[3]).getHistory().location, "REPLACE");
const obj = set(self[3]);
2026-07-29 08:29:29 +00:00
}
const listeners = this.listeners;
listeners.add(hideLaunchPad);
return () => self.removeRouteChangeListener(closure_0);
};
prototype["addRouteRewriter"] = function addRouteRewriter(voiceRouteRewriter) {
const self = this;
if (null != this.unlistenHistory) {
2026-08-24 06:08:38 +00:00
const obj = set(self[3]);
const tmp = set;
const tmp2 = self;
const tmp3 = voiceRouteRewriter(obj.getHistory().location, set(self[3]).getHistory().action);
2026-07-29 08:29:29 +00:00
if (null != tmp3) {
tmp(tmp2[3]).replaceWith(tmp3.path, tmp3.state);
const tmpResult = tmp(tmp2[3]);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const obj2 = set(self[3]);
2026-07-29 08:29:29 +00:00
}
const rewrites = this.rewrites;
rewrites.add(voiceRouteRewriter);
return () => self.removeRouteRewriter(closure_0);
};
prototype["removeRouteChangeListener"] = function removeRouteChangeListener(closure_0) {
const listeners = this.listeners;
listeners.delete(closure_0);
};
prototype["removeRouteRewriter"] = function removeRouteRewriter(closure_0) {
const rewrites = this.rewrites;
rewrites.delete(closure_0);
};
prototype["getHistory"] = function getHistory() {
2026-08-24 06:08:38 +00:00
return set(1222).getHistory();
2026-07-29 08:29:29 +00:00
};
2026-08-24 06:08:38 +00:00
set = Object.create(RouteManager.prototype);
2026-07-29 08:29:29 +00:00
set = new Set();
set.rewrites = set;
set.listeners = new Set();
set.routeChangeCount = 0;
set.timer = -1;
set.connected = false;
set.handleConnectionChange = function handleConnectionChange() {
2026-08-24 06:08:38 +00:00
const isConnectedResult = closure_1_2.isConnected();
2026-07-29 08:29:29 +00:00
let tmp2 = isConnectedResult;
if (isConnectedResult) {
tmp2 = !obj.connected;
}
obj.connected = isConnectedResult;
if (tmp2) {
obj.routeChangeCount = 0;
2026-08-24 06:08:38 +00:00
obj.executeRouteRewrites(obj(closure_1_1[3]).getHistory().location, "REPLACE");
const obj2 = obj(closure_1_1[3]);
2026-07-29 08:29:29 +00:00
}
};
set.handleRouteChange = function handleRouteChange(pathname, REPLACE) {
if ("POP" !== REPLACE) {
if (!obj.executeRouteRewrites(pathname, REPLACE)) {
2026-08-24 06:08:38 +00:00
obj = obj(closure_1_1[4]);
2026-07-29 08:29:29 +00:00
if (!obj.convertRouteToNavigation(pathname)) {
2026-08-24 06:08:38 +00:00
tmp2(tmp3[3]).replaceWith(closure_1_4.ME);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp2 = obj;
2026-08-24 06:08:38 +00:00
tmp3 = closure_1_1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
const state = closure_1_3.getState();
2026-07-29 08:29:29 +00:00
if (state.basePath !== pathname.pathname) {
state.resetPath(pathname.pathname);
}
const iter = obj.listeners[Symbol.iterator]();
if (iter === undefined) {
obj.routeChangeCount = 0;
} else {
try {
tmp8(pathname, REPLACE);
} catch (err) {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
};
set.handleKeybindRouteChange = function handleKeybindRouteChange(path) {
if (-1 !== obj.timer) {
const _clearTimeout = clearTimeout;
clearTimeout(tmp.timer);
}
if (null != path.path) {
const _setTimeout = setTimeout;
tmp.timer = setTimeout(tmp.flushRoute, 200);
}
};
set.flushRoute = function flushRoute() {
clearTimeout(obj.timer);
2026-08-24 06:08:38 +00:00
const state = closure_1_3.getState();
2026-07-29 08:29:29 +00:00
if (null != state.path) {
2026-08-24 06:08:38 +00:00
obj = obj(closure_1_1[3]);
2026-07-29 08:29:29 +00:00
obj.transitionTo(state.path);
}
};
let result = set.fileFinishedImporting("modules/routing/RouteManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default set;