decord/alpha/source/modules/routing/router_utils.tsx

240 lines
8.5 KiB
TypeScript
Raw Normal View History

2026-10-03 08:58:59 +00:00
// Module ID: 1112
// Function ID: 1113
// Name: router_utils
2026-10-03 08:58:59 +00:00
// Dependencies: [1085, 3, 1113, 1121, 1124, 2]
2026-07-29 08:29:29 +00:00
// Exports: back, currentRouteHasBackNavigation, forward, getFingerprintLocation, getHistory, getLastRouteChangeSource, getLastRouteChangeSourceLocationStack, hasNavigated, isValidFingerprintRoute, replaceWith, shouldNavigate, transitionToGuild
2026-07-20 16:05:17 +00:00
2026-10-03 08:58:59 +00:00
// Module 1112 (router_utils)
import LoggerDefault from "Logger" /* 3 */;
2026-10-03 08:58:59 +00:00
import ComponentDispatchUtils from "ComponentDispatchUtils" /* 1121 */;
import RoutingSources from "RoutingSources" /* 1124 */;
import Constants from "Constants" /* 1085 */;
import module_1113_mod from "module_1113" /* 1113 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let c3, sourceLocationStack;
let hasOwnProperty;
let metroImportDefault;
let metroRequire;
function transitionTo(Routes, source) {
let closure_0 = Routes;
let flag = !(typeof Routes !== "string" || !items.some((item) => closure_0.startsWith(item)));
const tmp = typeof Routes !== "string" || !items.some((item) => closure_0.startsWith(item));
if (flag) {
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-10-03 08:58:59 +00:00
logger.log("" + "assign" + " - route to external path " + Routes);
2026-07-20 16:05:17 +00:00
const _window = window;
const _Event = Event;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
2026-07-20 16:05:17 +00:00
const event = new Event("beforeunload");
2026-10-03 08:58:59 +00:00
dispatchEvent(event);
2026-07-20 16:05:17 +00:00
const _window2 = window;
const _location = window.location;
2026-10-03 08:58:59 +00:00
_location.assign(Routes);
2026-07-20 16:05:17 +00:00
flag = true;
}
2026-07-29 08:29:29 +00:00
if (!flag) {
2026-09-02 09:53:35 +00:00
const _URL = URL;
const _window3 = window;
2026-07-29 08:29:29 +00:00
const _HermesInternal2 = HermesInternal;
2026-10-03 08:58:59 +00:00
const self3 = this;
const self4 = this;
const uRL = new URL(Routes, "https:" + window.GLOBAL_ENV.WEBAPP_ENDPOINT);
const obj = { pathname: null, search: null, hash: null };
({ pathname: obj.pathname, search: obj.search, hash: obj.hash } = uRL);
2026-10-03 08:58:59 +00:00
const merged = Object.assign(source);
2026-09-02 09:53:35 +00:00
const _HermesInternal3 = HermesInternal;
2026-10-03 08:58:59 +00:00
logger.log("transitionTo - Transitioning to " + Routes);
source = undefined;
if (source != null) {
source = source.source;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
sourceLocationStack = undefined;
if (source != null) {
sourceLocationStack = source.sourceLocationStack;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
const _location2 = module_1113.location;
let tmp22 = _location2.pathname === obj.pathname;
if (tmp22) {
const search2 = obj.search;
2026-09-02 09:53:35 +00:00
let str9 = "";
2026-10-03 08:58:59 +00:00
const search = _location2.search;
if (null != search2) {
2026-09-02 09:53:35 +00:00
str9 = "";
2026-10-03 08:58:59 +00:00
if ("" !== search2) {
2026-09-02 09:53:35 +00:00
str9 = "";
2026-10-03 08:58:59 +00:00
if (search2 !== "?") {
let text = search2;
if (!search2.startsWith("?")) {
text = `?${search2}`;
2026-09-02 09:53:35 +00:00
}
str9 = text;
}
}
}
2026-10-03 08:58:59 +00:00
tmp22 = search === str9;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
if (tmp22) {
const hash2 = obj.hash;
2026-09-02 09:53:35 +00:00
let str12 = "";
2026-10-03 08:58:59 +00:00
const hash = _location2.hash;
if (null != hash2) {
2026-09-02 09:53:35 +00:00
str12 = "";
2026-10-03 08:58:59 +00:00
if ("" !== hash2) {
2026-09-02 09:53:35 +00:00
str12 = "";
2026-10-03 08:58:59 +00:00
if (hash2 !== "#") {
let text1 = hash2;
if (!hash2.startsWith("#")) {
text1 = `#${hash2}`;
2026-09-02 09:53:35 +00:00
}
str12 = text1;
}
}
}
2026-10-03 08:58:59 +00:00
tmp22 = hash === str12;
2026-09-02 09:53:35 +00:00
}
2026-10-03 08:58:59 +00:00
if (tmp22) {
2026-09-02 09:53:35 +00:00
const replaced = str7.replace(obj);
2026-10-03 08:58:59 +00:00
} else if (null == source) {
module_1113.push(Routes);
} else {
module_1113.push(obj);
2026-09-02 09:53:35 +00:00
}
2026-10-03 08:58:59 +00:00
c3 = source;
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
({ Routes: hasOwnProperty, PageAnalyticsLocations: metroRequire, ComponentActions: metroImportDefault } = Constants);
const RelativeMarketingURLs = Constants.RelativeMarketingURLs;
const logger = new LoggerDefault("Routing/Utils");
2026-10-03 08:58:59 +00:00
const items = [RelativeMarketingURLs.DEVELOPER_PORTAL];
const tmp3 = new LoggerDefault("Routing/Utils");
let module_1113 = module_1113_mod;
module_1113 = module_1113.createMemoryHistory();
let closure_10 = module_1113.listen((arg0, arg1) => {
2026-07-20 16:05:17 +00:00
if ("REPLACE" !== arg1) {
closure_10();
2026-07-20 16:05:17 +00:00
}
});
const result = size.fileFinishedImporting("modules/routing/router_utils.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const shouldNavigate = function shouldNavigate() {
const ComponentDispatch = ComponentDispatchUtils.ComponentDispatch;
2026-10-03 08:58:59 +00:00
return !ComponentDispatch.hasSubscribers(metroImportDefault.MODAL_CLOSE);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export { transitionTo };
2026-10-03 08:58:59 +00:00
export const transitionToGuild = function transitionToGuild(guildId, channelId, messageId, source) {
const obj = { guildId, channelId, messageId };
logger.log("transitionToGuild - Transitioning to " + JSON.stringify(obj));
transitionTo(hasOwnProperty.CHANNEL(guildId, channelId, messageId), source);
2026-07-20 16:05:17 +00:00
};
export const currentRouteHasBackNavigation = function currentRouteHasBackNavigation() {
let hasItem = null != c3;
2026-07-20 16:05:17 +00:00
if (hasItem) {
const ChannelBackNavigationSources = RoutingSources.ChannelBackNavigationSources;
hasItem = ChannelBackNavigationSources.has(c3);
2026-07-20 16:05:17 +00:00
}
return hasItem;
};
export const replaceWith = function replaceWith(ME, state, arg2) {
2026-10-03 08:58:59 +00:00
let closure_0 = ME;
let flag = !(typeof ME !== "string" || !items.some((item) => closure_0.startsWith(item)));
const tmp = typeof ME !== "string" || !items.some((item) => closure_0.startsWith(item));
if (flag) {
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-08-24 06:08:38 +00:00
logger.log("" + "replace" + " - route to external path " + ME);
2026-07-29 08:29:29 +00:00
const _window = window;
const _Event = Event;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
2026-07-29 08:29:29 +00:00
const event = new Event("beforeunload");
2026-10-03 08:58:59 +00:00
dispatchEvent(event);
2026-07-29 08:29:29 +00:00
const _window2 = window;
const str5 = window.location;
2026-10-03 08:58:59 +00:00
const replaced = str5.replace(ME);
flag = true;
2026-07-29 08:29:29 +00:00
}
if (!flag) {
const _HermesInternal2 = HermesInternal;
2026-08-24 06:08:38 +00:00
logger.log("Replacing route with " + ME);
2026-08-04 21:03:28 +00:00
if (typeof ME === "string") {
2026-10-03 08:58:59 +00:00
const replaced1 = module_1113.replace(ME, state);
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
const replaced2 = module_1113.replace(ME);
2026-07-20 16:05:17 +00:00
}
c3 = arg2;
2026-07-20 16:05:17 +00:00
}
};
export function getHistory() {
2026-10-03 08:58:59 +00:00
return module_1113;
2026-07-20 16:05:17 +00:00
}
export function getLastRouteChangeSource() {
return c3;
2026-07-20 16:05:17 +00:00
}
export function getLastRouteChangeSourceLocationStack() {
return sourceLocationStack;
2026-07-20 16:05:17 +00:00
}
export const isValidFingerprintRoute = function isValidFingerprintRoute(arg0) {
return true;
};
export const getFingerprintLocation = function getFingerprintLocation(arg0) {
let ACCOUNT_REVERT = arg0;
if (null == arg0) {
2026-10-03 08:58:59 +00:00
let str = module_1113.location.pathname;
2026-07-29 08:29:29 +00:00
if (str == null) {
str = "";
2026-07-20 16:05:17 +00:00
}
ACCOUNT_REVERT = str;
}
if (ACCOUNT_REVERT.startsWith(hasOwnProperty.LOGIN)) {
2026-10-03 08:58:59 +00:00
ACCOUNT_REVERT = metroRequire.LOGIN;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.REGISTER)) {
ACCOUNT_REVERT = metroRequire.REGISTER;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.INVITE(""))) {
ACCOUNT_REVERT = metroRequire.INVITE;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.VERIFY)) {
ACCOUNT_REVERT = metroRequire.VERIFY;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.DISABLE_EMAIL_NOTIFICATIONS)) {
ACCOUNT_REVERT = metroRequire.DISABLE_EMAIL_NOTIFICATIONS;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.DISABLE_SERVER_HIGHLIGHT_NOTIFICATIONS)) {
ACCOUNT_REVERT = metroRequire.DISABLE_SERVER_HIGHLIGHT_NOTIFICATIONS;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.REJECT_IP)) {
ACCOUNT_REVERT = metroRequire.REJECT_IP;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.REJECT_MFA)) {
ACCOUNT_REVERT = metroRequire.REJECT_MFA;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.AUTHORIZE_IP)) {
ACCOUNT_REVERT = metroRequire.AUTHORIZE_IP;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.AUTHORIZE_PAYMENT)) {
ACCOUNT_REVERT = metroRequire.AUTHORIZE_PAYMENT;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.RESET)) {
ACCOUNT_REVERT = metroRequire.RESET;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.REPORT)) {
ACCOUNT_REVERT = metroRequire.REPORT;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.REPORT_SECOND_LOOK)) {
ACCOUNT_REVERT = metroRequire.REPORT_SECOND_LOOK;
} else if (ACCOUNT_REVERT.startsWith(hasOwnProperty.ACCOUNT_REVERT(""))) {
ACCOUNT_REVERT = metroRequire.ACCOUNT_REVERT;
2026-07-20 16:05:17 +00:00
}
return ACCOUNT_REVERT;
};
export function hasNavigated() {
return false;
}
export const back = function back() {
const ComponentDispatch = ComponentDispatchUtils.ComponentDispatch;
2026-10-03 08:58:59 +00:00
const tmp2 = !ComponentDispatch.hasSubscribers(metroImportDefault.MODAL_CLOSE);
if (tmp2) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-10-03 08:58:59 +00:00
module_1113.goBack();
2026-07-20 16:05:17 +00:00
}
};
export const forward = function forward() {
const ComponentDispatch = ComponentDispatchUtils.ComponentDispatch;
2026-10-03 08:58:59 +00:00
const tmp2 = !ComponentDispatch.hasSubscribers(metroImportDefault.MODAL_CLOSE);
if (tmp2) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-10-03 08:58:59 +00:00
module_1113.goForward();
2026-07-20 16:05:17 +00:00
}
};