armcord/src/main.ts

161 lines
6.2 KiB
TypeScript
Raw Normal View History

2021-12-24 21:56:49 +00:00
// Modules to control application life and create native browser window
import {BrowserWindow, app, crashReporter, session} from "electron";
2021-12-26 19:15:18 +00:00
import "v8-compile-cache";
import "./discord/extensions/csp.js";
import "./tray.js";
2024-05-15 16:14:49 +00:00
import fs from "fs";
import {createCustomWindow, createNativeWindow, createTransparentWindow} from "./discord/window.js";
2022-08-25 14:42:54 +00:00
import path from "path";
import {createTManagerWindow} from "./themeManager/main.js";
import {createSplashWindow} from "./splash/main.js";
import {createSetupWindow} from "./setup/main.js";
2024-05-15 16:14:49 +00:00
import {
setConfig,
checkForDataFolder,
checkIfConfigExists,
checkIfConfigIsBroken,
getConfig,
firstRun,
getConfigLocation
} from "./common/config.js";
import {injectElectronFlags} from "./common/flags.js";
import {setLang} from "./common/lang.js";
import {installModLoader} from "./discord/extensions/mods.js";
export let iconPath: string;
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
import type {Settings} from "./types/settings";
export let settings: Settings;
export let customTitlebar: boolean;
2024-04-05 10:04:00 +00:00
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
app.on("render-process-gone", (_event, _webContents, details) => {
if (details.reason == "crashed") {
app.relaunch();
}
});
async function args(): Promise<void> {
let argNum = 2;
2023-04-25 08:57:49 +00:00
if (process.argv[0] == "electron") argNum++;
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
const args = process.argv[argNum];
2023-04-25 08:57:49 +00:00
if (args == undefined) return;
if (args.startsWith("--")) return; //electron flag
if (args.includes("=")) {
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
const e = args.split("=");
setConfig(e[0] as keyof Settings, e[1]);
console.log(`Setting ${e[0]} to ${e[1]}`);
2023-04-25 08:57:49 +00:00
app.relaunch();
app.exit();
2023-05-14 11:42:15 +00:00
} else if (args == "themes") {
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
await app.whenReady().then(async () => {
await createTManagerWindow();
2023-05-14 11:42:15 +00:00
});
2023-04-25 08:57:49 +00:00
}
}
export async function init(): Promise<void> {
if (getConfig("skipSplash") == false) {
void createSplashWindow(); // REVIEW - Awaiting will hang at start
}
if (firstRun == true) {
setLang(new Intl.DateTimeFormat().resolvedOptions().locale);
await createSetupWindow();
}
switch (getConfig("windowStyle")) {
case "default":
createCustomWindow();
customTitlebar = true;
break;
case "native":
createNativeWindow();
break;
case "transparent":
createTransparentWindow();
break;
default:
createCustomWindow();
customTitlebar = true;
break;
}
}
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
await args(); // i want my top level awaits - IMPLEMENTED :)
if (!app.requestSingleInstanceLock()) {
2023-08-20 19:14:26 +00:00
// if value isn't set after 3.2.4
// kill if 2nd instance
app.quit();
} else {
2023-08-20 19:14:26 +00:00
app.commandLine.appendSwitch("disable-features", "WidgetLayering"); // fix dev tools layers
// Your data now belongs to CCP
2022-12-24 18:46:58 +00:00
crashReporter.start({uploadToServer: false});
// enable pulseaudio audio sharing on linux
if (process.platform === "linux") {
app.commandLine.appendSwitch("enable-features", "PulseaudioLoopbackForScreenShare");
app.commandLine.appendSwitch("disable-features", "WebRtcAllowInputVolumeAdjustment");
}
2023-08-05 12:07:42 +00:00
// enable webrtc capturer for wayland
if (process.platform === "linux" && process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland") {
app.commandLine.appendSwitch("enable-features", "WebRTCPipeWireCapturer");
2023-08-05 12:07:42 +00:00
console.log("Wayland detected, using PipeWire for video capture.");
}
2023-06-10 17:43:59 +00:00
// work around chrome 66 disabling autoplay by default
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
// WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows.
// HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service.
app.commandLine.appendSwitch(
"disable-features",
"WinRetrieveSuggestionsOnlyOnDemand,HardwareMediaKeyHandling,MediaSessionService"
);
app.commandLine.appendSwitch("enable-transparent-visuals");
checkForDataFolder();
checkIfConfigExists();
2024-04-05 10:04:00 +00:00
checkIfConfigIsBroken();
injectElectronFlags();
2024-05-15 16:14:49 +00:00
console.log("[Config Manager] Current config: " + fs.readFileSync(getConfigLocation(), "utf-8"));
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
void app.whenReady().then(async () => {
// REVIEW - Awaiting the line above will cause a hang at startup
if (getConfig("customIcon") !== null) {
iconPath = getConfig("customIcon");
} else {
2024-05-15 18:14:18 +00:00
iconPath = path.join(import.meta.dirname, "../", "/assets/desktop.png");
2022-03-04 17:53:18 +00:00
}
async function init(): Promise<void> {
if (getConfig("skipSplash") == false) {
void createSplashWindow(); // REVIEW - Awaiting will hang at start
}
if (firstRun == true) {
setLang(new Intl.DateTimeFormat().resolvedOptions().locale);
await createSetupWindow();
}
switch (getConfig("windowStyle")) {
case "default":
createCustomWindow();
customTitlebar = true;
break;
case "native":
createNativeWindow();
break;
case "transparent":
createTransparentWindow();
break;
default:
createCustomWindow();
customTitlebar = true;
break;
}
}
// Patch for linux bug to insure things are loaded before window creation (fixes transparency on some linux systems)
await new Promise<void>((resolve) => setTimeout(() => (init(), resolve()), 1500));
await installModLoader();
session.fromPartition("some-partition").setPermissionRequestHandler((_webContents, permission, callback) => {
if (permission === "notifications") {
// Approves the permissions request
callback(true);
}
if (permission === "media") {
// Approves the permissions request
callback(true);
}
});
Updates and Linting (#578) * Updates and Linting * fix lint task * [ImgBot] Optimize images *Total -- 404.98kb -> 304.38kb (24.84%) /assets/screenshot-1920x1080.png -- 205.00kb -> 123.21kb (39.9%) /build/appx/Square150x150Logo.png -- 9.63kb -> 7.71kb (20%) /assets/ac_icon.png -- 40.15kb -> 34.98kb (12.88%) /assets/StoreLogo.png -- 40.15kb -> 34.98kb (12.88%) /assets/Square150x150Logo.png -- 7.24kb -> 6.53kb (9.83%) /assets/ac_icon_transparent.png -- 45.54kb -> 42.00kb (7.76%) /assets/ac_plug_colored.png -- 17.98kb -> 16.72kb (7%) /assets/ac_black_plug.png -- 8.49kb -> 8.06kb (5.06%) /assets/ac_black_plug_hollow.png -- 10.30kb -> 9.95kb (3.4%) /build/appx/Square44x44Logo.png -- 1.69kb -> 1.64kb (2.89%) /assets/Square44x44Logo.png -- 1.90kb -> 1.85kb (2.83%) /assets/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /build/appx/Wide310x150Logo.png -- 4.21kb -> 4.17kb (0.97%) /assets/ac_white_plug.png -- 8.49kb -> 8.42kb (0.83%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Asyncification!!! Check `REVIEW` comments * More async for `src/discord` * update packages to latest minor version * Void some promises * Add some types - 93 problems left! * make DeepScan Happy * DeepScan part 2 * I am the Constant * preload must be `.mts` * Migrate electron context menu official package * fix bad preload on setup window * fix minor import oversights * fix modloader * Stop main window from continuing during setup * update packages, slow dependabot * Remove paste override, it seems to work without now * IPC typing * Package updates & a few more typings * fix linting errors in screenshare * use pnpm in actions * fix dev releaser? * update node build, fix dev one more time * release action is broke * Fix Release * update actions * actions are so finicky * remove delete-tag-and-release * add github token env * Hopefully this fixes the release workflow * [debug] * this should actually fix it * Fix typo in dev action * put everything in a dir and then get it * use a different releaser * correct release file location * action places it in a folder named x.zip, recurse into that and grab the actual files * Cleanup actions a bit * release is dependent on mac build * remove mac build * split linux arm and x86 * rely on linux arm * remove deprecated action * attempt to fix weird recursive zip * fix env * use pnpm in actions fix dev releaser? update node build, fix dev one more time release action is broke Fix Release update actions actions are so finicky remove delete-tag-and-release add github token env Hopefully this fixes the release workflow [debug] this should actually fix it Fix typo in dev action put everything in a dir and then get it use a different releaser correct release file location action places it in a folder named x.zip, recurse into that and grab the actual files Cleanup actions a bit release is dependent on mac build remove mac build split linux arm and x86 rely on linux arm remove deprecated action attempt to fix weird recursive zip fix env * don't globally install pnpm packages (I don't think the cache checks global) * Type the armcord window * Finalize typings * fix deepscan issues * fix screenshare preload * fix app quitting --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: smartfrigde <37928912+smartfrigde@users.noreply.github.com>
2024-06-14 12:57:34 +00:00
app.on("activate", function () {
// REVIEW - I don't think it really matters if this promise is voided
if (BrowserWindow.getAllWindows().length === 0) void init();
});
2022-03-04 17:53:18 +00:00
});
2022-12-13 19:23:17 +00:00
}