decord/source/modules/activities/DiscordEnvironment.tsx

205 lines
7.3 KiB
TypeScript
Raw Normal View History

// Module ID: 9707
// Function ID: 9708
// Name: DiscordEnvironment
// Dependencies: [4597, 1183, 9708, 1935, 2]
2026-08-24 06:08:38 +00:00
// Exports: getDiscordBaseTheme, getDiscordCustomTheme, getDiscordEnvQueryParams, getDiscordEnvironment, getDiscordFontScale, getDiscordUIDensity
// Module 9707 (DiscordEnvironment)
import UserSettings from "UserSettings" /* 1935 */;
import AccessibilityStore from "AccessibilityStore" /* 4597 */;
import ThemeStore from "ThemeStore" /* 1183 */;
2026-08-24 06:08:38 +00:00
require = fn;
const UIDensityConstants = fn(9708);
({ 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 size = fn(2);
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 {
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();
}
}
const obj2 = { classNames: found, variables: obj };
return obj2;
2026-08-24 06:08:38 +00:00
}
}
}
return null;
};
export const getDiscordUIDensity = function getDiscordUIDensity() {
if (typeof window !== "undefined") {
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";
}
let tmp = str;
}
const UIDensitySetting = UserSettings.UIDensitySetting;
return timestampProducer(UIDensitySetting.getSetting(), tmp);
2026-08-24 06:08:38 +00:00
}
tmp = React4;
2026-08-24 06:08:38 +00:00
};
export const getDiscordFontScale = function getDiscordFontScale() {
const fontScale = AccessibilityStore.fontScale;
2026-08-24 06:08:38 +00:00
if (Number.isFinite(fontScale)) {
const _Math = Math;
let fontScale2 = Math.round(100 * fontScale) / 100;
} else {
fontScale2 = frozen.fontScale;
}
return fontScale2;
};
export const getDiscordEnvironment = function getDiscordEnvironment(useReducedMotion) {
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 = { baseTheme: str, customTheme: null, uiDensity: null, messageDisplayCompact: null, fontScale: null, reducedMotion: null, highContrast: null, forcedColors: null, underlineLinks: null };
2026-08-24 06:08:38 +00:00
let tmp = null;
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) {
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
}
}
const obj3 = { classNames: found, variables: obj2 };
tmp = obj3;
2026-08-24 06:08:38 +00:00
}
}
}
obj.customTheme = tmp;
2026-08-24 06:08:38 +00:00
if (typeof window !== "undefined") {
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";
}
let tmp3 = str5;
}
const UIDensitySetting = UserSettings.UIDensitySetting;
obj.uiDensity = timestampProducer(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;
if (Number.isFinite(fontScale)) {
const _Math = Math;
let fontScale2 = Math.round(100 * fontScale) / 100;
} else {
fontScale2 = frozen.fontScale;
}
obj.fontScale = fontScale2;
obj.reducedMotion = useReducedMotion;
({ isHighContrastModeEnabled: obj.highContrast, useForcedColors: obj.forcedColors, alwaysShowLinkDecorations: obj.underlineLinks } = AccessibilityStore);
2026-08-24 06:08:38 +00:00
return obj;
}
tmp3 = React4;
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") {
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";
}
let tmp = str4;
}
const UIDensitySetting = UserSettings.UIDensitySetting;
obj.ui_density = timestampProducer(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;
if (Number.isFinite(fontScale)) {
const _Math = Math;
let fontScale2 = Math.round(100 * fontScale) / 100;
} else {
fontScale2 = frozen.fontScale;
}
obj.font_scale = String(fontScale2);
2026-08-24 06:08:38 +00:00
const _String2 = String;
obj.reduced_motion = String(AccessibilityStore.useReducedMotion);
2026-08-24 06:08:38 +00:00
const _String3 = String;
obj.high_contrast = String(AccessibilityStore.isHighContrastModeEnabled);
2026-08-24 06:08:38 +00:00
const _String4 = String;
obj.forced_colors = String(AccessibilityStore.useForcedColors);
2026-08-24 06:08:38 +00:00
const _String5 = String;
obj.underline_links = String(AccessibilityStore.alwaysShowLinkDecorations);
2026-08-24 06:08:38 +00:00
return obj;
}
tmp = React4;
2026-08-24 06:08:38 +00:00
};