decord/alpha/source/modules/activities/DiscordEnvironment.tsx

216 lines
7.5 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 10886
// Function ID: 10887
// Name: DiscordEnvironment
2026-10-09 10:00:15 +00:00
// Dependencies: [5080, 1205, 10887, 2041, 2]
2026-08-24 06:08:38 +00:00
// Exports: getDiscordBaseTheme, getDiscordCustomTheme, getDiscordEnvQueryParams, getDiscordEnvironment, getDiscordFontScale, getDiscordUIDensity
2026-10-09 10:00:15 +00:00
// Module 10886 (DiscordEnvironment)
import UserSettings from "UserSettings" /* 2041 */;
import AccessibilityStore from "AccessibilityStore" /* 5080 */;
2026-10-08 09:57:35 +00:00
import ThemeStore from "ThemeStore" /* 1205 */;
2026-10-09 10:00:15 +00:00
import UIDensityConstants from "UIDensityConstants" /* 10887 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
2026-10-03 08:58:59 +00:00
let closure_4;
let hasOwnProperty;
let metroRequire;
({ RESPONSIVE_DENSITY_FALLBACK: closure_4, RESPONSIVE_DENSITY_MEDIA_QUERY: hasOwnProperty, resolveUIDensity: metroRequire } = UIDensityConstants);
2026-08-24 06:08:38 +00:00
const frozen = Object.freeze({ baseTheme: "dark", customTheme: null, uiDensity: "default", messageDisplayCompact: false, fontScale: 100, reducedMotion: false, highContrast: false, forcedColors: false, underlineLinks: false });
let closure_8 = ["custom-theme-background", "custom-client-theme"];
const result = size.fileFinishedImporting("modules/activities/DiscordEnvironment.tsx");
2026-08-24 06:08:38 +00:00
export const DEFAULT_DISCORD_ENVIRONMENT = frozen;
export function getDiscordBaseTheme(arg0) {
if ("light" !== arg0) {
if ("midnight" !== arg0) {
if ("darker" !== arg0) {
return "dark";
}
}
}
return arg0;
}
export const getDiscordCustomTheme = function getDiscordCustomTheme() {
if (typeof document !== "undefined") {
const _window = window;
if (typeof window !== "undefined") {
const _document = document;
const found = closure_8.filter((item) => {
2026-08-24 06:08:38 +00:00
const classList = documentElement.classList;
return classList.contains(item);
2026-08-24 06:08:38 +00:00
});
if (0 === found.length) {
return null;
} else {
2026-10-03 08:58:59 +00:00
let num;
2026-08-24 06:08:38 +00:00
const _window2 = window;
const computedStyle = window.getComputedStyle(documentElement);
const obj = {};
2026-08-24 06:08:38 +00:00
for (let num = 0; num < computedStyle.length; num = num + 1) {
let itemResult = computedStyle.item(num);
if (itemResult.startsWith("--custom-")) {
let str = computedStyle.getPropertyValue(itemResult);
obj[itemResult] = str.trim();
}
}
2026-10-03 08:58:59 +00:00
return { classNames: found, variables: obj };
2026-08-24 06:08:38 +00:00
}
}
}
return null;
};
export const getDiscordUIDensity = function getDiscordUIDensity() {
if (typeof window !== "undefined") {
2026-10-03 08:58:59 +00:00
let tmp;
2026-08-24 06:08:38 +00:00
const _window2 = window;
if (typeof window.matchMedia === "function") {
const _window = window;
let str = "compact";
if (window.matchMedia(hasOwnProperty).matches) {
2026-08-24 06:08:38 +00:00
str = "cozy";
}
2026-10-03 08:58:59 +00:00
tmp = str;
2026-08-24 06:08:38 +00:00
}
const UIDensitySetting = UserSettings.UIDensitySetting;
2026-10-03 08:58:59 +00:00
return metroRequire(UIDensitySetting.getSetting(), tmp);
2026-08-24 06:08:38 +00:00
}
2026-10-03 08:58:59 +00:00
tmp = React3;
2026-08-24 06:08:38 +00:00
};
export const getDiscordFontScale = function getDiscordFontScale() {
2026-10-03 08:58:59 +00:00
let fontScale2;
const fontScale = AccessibilityStore.fontScale;
2026-08-24 06:08:38 +00:00
if (Number.isFinite(fontScale)) {
const _Math = Math;
2026-10-03 08:58:59 +00:00
fontScale2 = Math.round(100 * fontScale) / 100;
2026-08-24 06:08:38 +00:00
} else {
fontScale2 = frozen.fontScale;
}
return fontScale2;
};
export const getDiscordEnvironment = function getDiscordEnvironment(useReducedMotion) {
2026-10-03 08:58:59 +00:00
let tmp;
const theme = ThemeStore.theme;
2026-08-24 06:08:38 +00:00
let str = theme;
if ("light" !== theme) {
str = theme;
if ("midnight" !== theme) {
str = theme;
if ("darker" !== theme) {
str = "dark";
}
}
}
2026-10-03 08:58:59 +00:00
const obj = { baseTheme: str, customTheme: tmp, uiDensity: null, messageDisplayCompact: null, fontScale: null, reducedMotion: null, highContrast: null, forcedColors: null, underlineLinks: null };
tmp = null;
2026-08-24 06:08:38 +00:00
if (typeof document !== "undefined") {
const _window2 = window;
tmp = null;
if (typeof window !== "undefined") {
const _document = document;
const found = closure_8.filter((item) => {
2026-08-24 06:08:38 +00:00
const classList = documentElement.classList;
return classList.contains(item);
2026-08-24 06:08:38 +00:00
});
tmp = null;
if (0 !== found.length) {
2026-10-03 08:58:59 +00:00
let num;
2026-08-24 06:08:38 +00:00
const _window3 = window;
const computedStyle = window.getComputedStyle(documentElement);
const obj2 = {};
2026-08-24 06:08:38 +00:00
for (let num = 0; num < computedStyle.length; num = num + 1) {
let itemResult = computedStyle.item(num);
if (itemResult.startsWith("--custom-")) {
let str4 = computedStyle.getPropertyValue(itemResult);
obj2[itemResult] = str4.trim();
2026-08-24 06:08:38 +00:00
}
}
2026-10-03 08:58:59 +00:00
tmp = { classNames: found, variables: obj2 };
const obj3 = { classNames: found, variables: obj2 };
2026-08-24 06:08:38 +00:00
}
}
}
if (typeof window !== "undefined") {
2026-10-03 08:58:59 +00:00
let tmp3;
let fontScale2;
2026-08-24 06:08:38 +00:00
const _window4 = window;
if (typeof window.matchMedia === "function") {
const _window = window;
let str5 = "compact";
if (window.matchMedia(hasOwnProperty).matches) {
2026-08-24 06:08:38 +00:00
str5 = "cozy";
}
2026-10-03 08:58:59 +00:00
tmp3 = str5;
2026-08-24 06:08:38 +00:00
}
const UIDensitySetting = UserSettings.UIDensitySetting;
2026-10-03 08:58:59 +00:00
obj.uiDensity = metroRequire(UIDensitySetting.getSetting(), tmp3);
const MessageDisplayCompact = UserSettings.MessageDisplayCompact;
obj.messageDisplayCompact = MessageDisplayCompact.getSetting();
const fontScale = AccessibilityStore.fontScale;
2026-08-24 06:08:38 +00:00
const _Number = Number;
2026-10-03 08:58:59 +00:00
const tmp8 = AccessibilityStore;
2026-08-24 06:08:38 +00:00
if (Number.isFinite(fontScale)) {
const _Math = Math;
2026-10-03 08:58:59 +00:00
fontScale2 = Math.round(100 * fontScale) / 100;
2026-08-24 06:08:38 +00:00
} else {
fontScale2 = frozen.fontScale;
}
obj.fontScale = fontScale2;
obj.reducedMotion = useReducedMotion;
2026-10-03 08:58:59 +00:00
({ isHighContrastModeEnabled: obj.highContrast, useForcedColors: obj.forcedColors, alwaysShowLinkDecorations: obj.underlineLinks } = tmp8);
2026-08-24 06:08:38 +00:00
return obj;
}
2026-10-03 08:58:59 +00:00
tmp3 = React3;
2026-08-24 06:08:38 +00:00
};
export const getDiscordEnvQueryParams = function getDiscordEnvQueryParams() {
const theme = ThemeStore.theme;
2026-08-24 06:08:38 +00:00
let str = theme;
if ("light" !== theme) {
str = theme;
if ("midnight" !== theme) {
str = theme;
if ("darker" !== theme) {
str = "dark";
}
}
}
const obj = { theme: str, ui_density: null, message_display_compact: null, font_scale: null, reduced_motion: null, high_contrast: null, forced_colors: null, underline_links: null };
if (typeof window !== "undefined") {
2026-10-03 08:58:59 +00:00
let tmp;
let fontScale2;
2026-08-24 06:08:38 +00:00
const _window2 = window;
if (typeof window.matchMedia === "function") {
const _window = window;
let str4 = "compact";
if (window.matchMedia(hasOwnProperty).matches) {
2026-08-24 06:08:38 +00:00
str4 = "cozy";
}
2026-10-03 08:58:59 +00:00
tmp = str4;
2026-08-24 06:08:38 +00:00
}
const UIDensitySetting = UserSettings.UIDensitySetting;
2026-10-03 08:58:59 +00:00
obj.ui_density = metroRequire(UIDensitySetting.getSetting(), tmp);
2026-08-24 06:08:38 +00:00
const _String = String;
const MessageDisplayCompact = UserSettings.MessageDisplayCompact;
obj.message_display_compact = String(MessageDisplayCompact.getSetting());
const fontScale = AccessibilityStore.fontScale;
2026-08-24 06:08:38 +00:00
const _Number = Number;
2026-10-03 08:58:59 +00:00
const _String2 = String;
2026-08-24 06:08:38 +00:00
if (Number.isFinite(fontScale)) {
const _Math = Math;
2026-10-03 08:58:59 +00:00
fontScale2 = Math.round(100 * fontScale) / 100;
2026-08-24 06:08:38 +00:00
} else {
fontScale2 = frozen.fontScale;
}
2026-10-03 08:58:59 +00:00
obj.font_scale = _String2(fontScale2);
2026-08-24 06:08:38 +00:00
const _String3 = String;
2026-10-03 08:58:59 +00:00
obj.reduced_motion = String(AccessibilityStore.useReducedMotion);
2026-08-24 06:08:38 +00:00
const _String4 = String;
2026-10-03 08:58:59 +00:00
obj.high_contrast = String(AccessibilityStore.isHighContrastModeEnabled);
2026-08-24 06:08:38 +00:00
const _String5 = String;
2026-10-03 08:58:59 +00:00
obj.forced_colors = String(AccessibilityStore.useForcedColors);
const _String6 = String;
obj.underline_links = String(AccessibilityStore.alwaysShowLinkDecorations);
2026-08-24 06:08:38 +00:00
return obj;
}
2026-10-03 08:58:59 +00:00
tmp = React3;
2026-08-24 06:08:38 +00:00
};