decord/beta/source/modules/routing/RouteManager.tsx
github-actions e7a050048e chore: update source for beta 347.7
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4943.js (118.4 MB)
2026-09-21 19:31:18 +00:00

239 lines
7.6 KiB
TypeScript

// Module ID: 13041
// Function ID: 13042
// Name: RouteManager
// Dependencies: [5496, 13042, 1078, 1105, 13043, 13044, 2]
// Module 13041 (RouteManager)
import GatewayConnectionStore from "GatewayConnectionStore" /* 5496 */;
import KeybindRouterStore from "KeybindRouterStore" /* 13042 */;
let obj2 = fn;
const Routes = fn(1078).Routes;
class RouteManager {
constructor() {
obj = Object.create(new.target.prototype);
closure_0 = obj;
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() {
const isConnectedResult = GatewayConnectionStore.isConnected();
let tmp2 = isConnectedResult;
if (isConnectedResult) {
tmp2 = !obj.connected;
}
obj.connected = isConnectedResult;
if (tmp2) {
obj.routeChangeCount = 0;
obj2 = obj2(1105);
obj.executeRouteRewrites(obj2.getHistory().location, "REPLACE");
}
};
obj.handleRouteChange = function handleRouteChange(pathname, REPLACE) {
if ("POP" !== REPLACE) {
if (!obj.executeRouteRewrites(pathname, REPLACE)) {
obj = obj2(13043);
if (!obj.convertRouteToNavigation(pathname)) {
tmp2(1105).replaceWith(Routes.ME);
}
tmp2 = obj2;
}
}
state = KeybindRouterStore.getState();
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) {
}
}
};
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);
state = KeybindRouterStore.getState();
if (null != state.path) {
obj = obj2(1105);
obj.transitionTo(state.path);
}
};
return obj;
}
}
const prototype = RouteManager.prototype;
prototype["initialize"] = function initialize() {
this.cleanup();
const history = obj2(1105).getHistory();
this.unlistenHistory = history.listen(this.handleRouteChange);
const obj = obj2(1105);
state = KeybindRouterStore.getState();
state.resetPath(obj2(1105).getHistory().location.pathname);
this.unlistenKeyboardChange = KeybindRouterStore.subscribe(this.handleKeybindRouteChange);
GatewayConnectionStore.addChangeListener(this.handleConnectionChange);
};
prototype["executeRouteRewrites"] = function executeRouteRewrites(location, REPLACE) {
this.routeChangeCount = this.routeChangeCount + 1;
if (this.routeChangeCount < 10) {
const rewrites = this.rewrites;
const obj = rewrites[Symbol.iterator]();
while (obj !== undefined) {
let tmp11 = obj2;
obj2 = obj2(1105);
let tmp9Result = tmp9(location, REPLACE);
if (null != tmp9Result) {
let tmp11Result = tmp11(13044);
let obj3 = { message: "RouteManager.handleRouteChange: A route rewrite is replacing the current route", data: null };
let obj4 = { replacePath: tmp9Result.path, previousPath: obj2.getHistory().location.pathname };
obj3.data = obj4;
let addBreadcrumbResult = tmp11Result.addBreadcrumb(obj3);
let tmp11Result2 = tmp11(1105);
let replaceWithResult = tmp11Result2.replaceWith(tmp9Result.path, tmp9Result.state);
obj.return();
let flag = true;
return true;
}
}
return false;
} else {
const _Error = Error;
const error = new Error("RouteManager: Something has gone horribly wrong with rewrites");
throw error;
}
};
prototype["cleanup"] = function cleanup() {
const self = this;
const unlistenHistory = this.unlistenHistory;
if (unlistenHistory != null) {
unlistenHistory();
}
self.unlistenHistory = undefined;
const unlistenKeyboardChange = self.unlistenKeyboardChange;
if (unlistenKeyboardChange != null) {
const result = unlistenKeyboardChange();
}
self.unlistenKeyboardChange = undefined;
GatewayConnectionStore.removeChangeListener(self.handleConnectionChange);
};
prototype["addRouteChangeListener"] = function addRouteChangeListener(hideLaunchPad) {
const self = this;
closure_0 = hideLaunchPad;
if (null != this.unlistenHistory) {
hideLaunchPad(obj2(1105).getHistory().location, "REPLACE");
const obj = obj2(1105);
}
const listeners = this.listeners;
listeners.add(hideLaunchPad);
return () => self.removeRouteChangeListener(closure_0);
};
prototype["addRouteRewriter"] = function addRouteRewriter(voiceRouteRewriter) {
const self = this;
closure_0 = voiceRouteRewriter;
if (null != this.unlistenHistory) {
obj2 = obj2(1105);
const tmp3 = voiceRouteRewriter(obj2(1105).getHistory().location, obj2.getHistory().action);
if (null != tmp3) {
tmp(1105).replaceWith(tmp3.path, tmp3.state);
const tmpResult = tmp(1105);
}
const obj = obj2(1105);
tmp = obj2;
}
const rewrites = this.rewrites;
rewrites.add(voiceRouteRewriter);
return () => self.removeRouteRewriter(closure_0);
};
prototype["removeRouteChangeListener"] = function removeRouteChangeListener(logRouteChange) {
const listeners = this.listeners;
listeners.delete(logRouteChange);
};
prototype["removeRouteRewriter"] = function removeRouteRewriter(voiceRouteRewriter) {
const rewrites = this.rewrites;
rewrites.delete(voiceRouteRewriter);
};
prototype["getHistory"] = function getHistory() {
return obj2(1105).getHistory();
};
obj2 = Object.create(RouteManager.prototype);
obj2.rewrites = new Set();
let set = new Set();
obj2.listeners = new Set();
obj2.routeChangeCount = 0;
obj2.timer = -1;
obj2.connected = false;
obj2.handleConnectionChange = function handleConnectionChange() {
const isConnectedResult = GatewayConnectionStore.isConnected();
let tmp2 = isConnectedResult;
if (isConnectedResult) {
tmp2 = !obj.connected;
}
obj.connected = isConnectedResult;
if (tmp2) {
obj.routeChangeCount = 0;
obj2 = obj2(1105);
obj.executeRouteRewrites(obj2.getHistory().location, "REPLACE");
}
};
obj2.handleRouteChange = function handleRouteChange(pathname, REPLACE) {
if ("POP" !== REPLACE) {
if (!obj.executeRouteRewrites(pathname, REPLACE)) {
obj = obj2(13043);
if (!obj.convertRouteToNavigation(pathname)) {
tmp2(1105).replaceWith(Routes.ME);
}
tmp2 = obj2;
}
}
state = KeybindRouterStore.getState();
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) {
}
}
};
obj2.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);
}
};
obj2.flushRoute = function flushRoute() {
clearTimeout(obj.timer);
state = KeybindRouterStore.getState();
if (null != state.path) {
obj = obj2(1105);
obj.transitionTo(state.path);
}
};
const size = fn(2);
let result = size.fileFinishedImporting("modules/routing/RouteManager.tsx");
export default obj2;