mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Make this mess more stable
This commit is contained in:
parent
5801aed6e6
commit
16531fa922
15 changed files with 976 additions and 2073 deletions
2856
package-lock.json
generated
2856
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ArmCord",
|
"name": "ArmCord",
|
||||||
"version": "3.1.0",
|
"version": "3.0.5",
|
||||||
"description": "ArmCord is a custom client designed to enhance your Discord experience while keeping everything lightweight.",
|
"description": "ArmCord is a custom client designed to enhance your Discord experience while keeping everything lightweight.",
|
||||||
"main": "ts-out/main.js",
|
"main": "ts-out/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
"@types/node": "^17.0.24",
|
"@types/node": "^17.0.24",
|
||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"electron": "^18.0.4",
|
"electron": "^18.0.4",
|
||||||
"electron-builder": "^23.0.3",
|
"electron-builder": "^22.5.1",
|
||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"typescript": "^4.5.4"
|
"typescript": "^4.5.4"
|
||||||
|
@ -35,7 +35,6 @@
|
||||||
"electron-context-menu": "^3.1.2",
|
"electron-context-menu": "^3.1.2",
|
||||||
"electron-json-storage": "^4.5.0",
|
"electron-json-storage": "^4.5.0",
|
||||||
"electron-tabs": "^0.17.0",
|
"electron-tabs": "^0.17.0",
|
||||||
"glasstron": "^0.1.1",
|
|
||||||
"v8-compile-cache": "^2.3.0"
|
"v8-compile-cache": "^2.3.0"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.info-3pQQBb:last-child:before {
|
.info-3pQQBb:last-child:before {
|
||||||
content: "ArmCord Version: 3.1.0" !important;
|
content: "ArmCord Version: 3.0.5" !important;
|
||||||
height: auto;
|
height: auto;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*CSS ONLY FOR INTERNAL USE (setup and loading)*/
|
/*CSS ONLY FOR INTERNAL USE (setup and loading)*/
|
||||||
@import url("https://kckarnige.github.io/femboi_owo/discord-font.css");
|
@import url("https://armcord.smartfridge.space/logofont.css");
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
background-color: #2c2f33 !important;
|
background-color: #2c2f33 !important;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@import url("https://kckarnige.github.io/femboi_owo/discord-font.css");
|
@import url("https://armcord.smartfridge.space/logofont.css");
|
||||||
:root {
|
:root {
|
||||||
--window-buttons: var(--header-secondary);
|
--window-buttons: var(--header-secondary);
|
||||||
--cord-color: var(--header-primary);
|
--cord-color: var(--header-primary);
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
content: "Cord";
|
content: "Cord";
|
||||||
color: var(--cord-color) !important;
|
color: var(--cord-color) !important;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 14px;
|
font-size: 15px;
|
||||||
font-family: Discordinated;
|
font-family: Discordinated;
|
||||||
}
|
}
|
||||||
.window-title:before {
|
.window-title:before {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
text.innerHTML = "You appear to be offline. Please connect to the internet and try again.";
|
text.innerHTML = "You appear to be offline. Please connect to the internet and try again.";
|
||||||
} else {
|
} else {
|
||||||
text.innerHTML = "Starting ArmCord...";
|
text.innerHTML = "Starting ArmCord...";
|
||||||
fetch("https://armcord.smartfridge.space/latest.json")
|
fetch("https://armcord.xyz/latest.json")
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.version !== window.armcord.version) {
|
if (data.version !== window.armcord.version) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ export function registerIpc() {
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
});
|
});
|
||||||
ipcMain.on("win-quit", (event, arg) => {
|
ipcMain.on("win-quit", (event, arg) => {
|
||||||
app.exit();
|
app.quit();
|
||||||
});
|
});
|
||||||
ipcMain.on("get-app-version", (event) => {
|
ipcMain.on("get-app-version", (event) => {
|
||||||
event.returnValue = getVersion();
|
event.returnValue = getVersion();
|
||||||
|
|
27
src/main.ts
27
src/main.ts
|
@ -1,5 +1,5 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
import {app, BrowserWindow, session} from "electron";
|
import {app, BrowserWindow, session, dialog} from "electron";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import "v8-compile-cache";
|
import "v8-compile-cache";
|
||||||
import * as storage from "electron-json-storage";
|
import * as storage from "electron-json-storage";
|
||||||
|
@ -7,20 +7,17 @@ import {getConfigUnsafe, setup} from "./utils";
|
||||||
import "./extensions/mods";
|
import "./extensions/mods";
|
||||||
import "./extensions/plugin";
|
import "./extensions/plugin";
|
||||||
import "./tray";
|
import "./tray";
|
||||||
import {mainWindow, createCustomWindow, createNativeWindow, createGlasstronWindow, createTabsHost} from "./window";
|
import {createCustomWindow, createNativeWindow, createTabsHost} from "./window";
|
||||||
import "./shortcuts";
|
import "./shortcuts";
|
||||||
export var contentPath: string;
|
export var contentPath: string;
|
||||||
var channel: string;
|
var channel: string;
|
||||||
export var settings: any;
|
export var settings: any;
|
||||||
export var customTitlebar: boolean;
|
export var customTitlebar: boolean;
|
||||||
export var tabs: boolean;
|
export var tabs: boolean;
|
||||||
async function appendSwitch() {
|
let isSingleInstance = app.requestSingleInstanceLock();
|
||||||
if ((await getConfigUnsafe("windowStyle")) == "glasstron") {
|
if (!isSingleInstance) {
|
||||||
console.log("Enabling transparency visuals.");
|
app.quit();
|
||||||
app.commandLine.appendSwitch("enable-transparent-visuals");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
appendSwitch();
|
|
||||||
storage.has("settings", function (error, hasKey) {
|
storage.has("settings", function (error, hasKey) {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
|
@ -55,15 +52,8 @@ app.whenReady().then(async () => {
|
||||||
createNativeWindow();
|
createNativeWindow();
|
||||||
break;
|
break;
|
||||||
case "glasstron":
|
case "glasstron":
|
||||||
setTimeout(
|
dialog.showErrorBox("Glasstron is unsupported.", "This build doesn't include Glasstron functionality, please edit windowStyle value in your settings.json to something different (default for example)")
|
||||||
createGlasstronWindow,
|
app.quit()
|
||||||
process.platform == "linux" ? 1000 : 0
|
|
||||||
// Electron has a bug on linux where it
|
|
||||||
// won't initialize properly when using
|
|
||||||
// transparency. To work around that, it
|
|
||||||
// is necessary to delay the window
|
|
||||||
// spawn function.
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case "tabs":
|
case "tabs":
|
||||||
createTabsHost();
|
createTabsHost();
|
||||||
|
@ -93,9 +83,6 @@ app.whenReady().then(async () => {
|
||||||
case "native":
|
case "native":
|
||||||
createNativeWindow();
|
createNativeWindow();
|
||||||
break;
|
break;
|
||||||
case "glasstron":
|
|
||||||
createGlasstronWindow();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
createCustomWindow();
|
createCustomWindow();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
import {BrowserWindow, shell, ipcMain} from "electron";
|
import {BrowserWindow, shell, ipcMain, app} from "electron";
|
||||||
import * as storage from "electron-json-storage";
|
|
||||||
import {getConfigUnsafe, saveSettings, Settings} from "../utils";
|
import {getConfigUnsafe, saveSettings, Settings} from "../utils";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
var settings: any;
|
|
||||||
var isAlreadyCreated: boolean = false;
|
|
||||||
storage.get("settings", function (error, data: any) {
|
|
||||||
if (error) throw error;
|
|
||||||
console.log(data);
|
|
||||||
settings = data;
|
|
||||||
});
|
|
||||||
var settingsWindow: BrowserWindow;
|
var settingsWindow: BrowserWindow;
|
||||||
|
var instance: number = 0;
|
||||||
|
|
||||||
export function createSettingsWindow() {
|
export function createSettingsWindow() {
|
||||||
if (isAlreadyCreated) {
|
console.log("Creating a settings window.");
|
||||||
|
instance = instance + 1;
|
||||||
|
if (instance > 1) {
|
||||||
|
if (settingsWindow) {
|
||||||
settingsWindow.show();
|
settingsWindow.show();
|
||||||
|
settingsWindow.restore();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
settingsWindow = new BrowserWindow({
|
settingsWindow = new BrowserWindow({
|
||||||
width: 500,
|
width: 500,
|
||||||
|
@ -37,10 +36,10 @@ export function createSettingsWindow() {
|
||||||
return {action: "deny"};
|
return {action: "deny"};
|
||||||
});
|
});
|
||||||
settingsWindow.loadURL(`file://${__dirname}/settings.html`);
|
settingsWindow.loadURL(`file://${__dirname}/settings.html`);
|
||||||
settingsWindow.on("close", async (e) => {
|
settingsWindow.on("close", (event: Event) => {
|
||||||
e.preventDefault();
|
ipcMain.removeHandler("getSetting");
|
||||||
settingsWindow.hide();
|
ipcMain.removeAllListeners("saveSettings");
|
||||||
|
instance = 0;
|
||||||
});
|
});
|
||||||
isAlreadyCreated = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>ArmCord Settings</title>
|
<title>ArmCord Settings</title>
|
||||||
<style>
|
<style>
|
||||||
@import url("settings.css");
|
@import url("../content/css/settings.css");
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@
|
||||||
<select name="theme" id="theme" class="left">
|
<select name="theme" id="theme" class="left">
|
||||||
<option value="default">Default</option>
|
<option value="default">Default</option>
|
||||||
<option value="native">Native</option>
|
<option value="native">Native</option>
|
||||||
<option value="glasstron">Glasstron (experimental)</option>
|
|
||||||
<option value="tabs">Tabs (experimental)</option>
|
|
||||||
</select>
|
</select>
|
||||||
<p class="header">ArmCord theme:</p>
|
<p class="header">ArmCord theme:</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,15 +51,7 @@
|
||||||
</select>
|
</select>
|
||||||
<p class="header">Client mod:</p>
|
<p class="header">Client mod:</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="switch">
|
|
||||||
<select name="blurType" id="blurType" class="left">
|
|
||||||
<option value="acrylic">Acrylic</option>
|
|
||||||
<option value="blurbehind">Blur Behind</option>
|
|
||||||
<option value="transparent">Transparent</option>
|
|
||||||
<option value="none">None</option>
|
|
||||||
</select>
|
|
||||||
<p class="header">Glasstron blur type:</p>
|
|
||||||
</div>
|
|
||||||
<button id="save" class="center">Save settings</button>
|
<button id="save" class="center">Save settings</button>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -73,7 +63,6 @@
|
||||||
document.getElementById("mod").value = await settings.get("mods");
|
document.getElementById("mod").value = await settings.get("mods");
|
||||||
document.getElementById("channel").value = await settings.get("channel");
|
document.getElementById("channel").value = await settings.get("channel");
|
||||||
document.getElementById("theme").value = await settings.get("windowStyle");
|
document.getElementById("theme").value = await settings.get("windowStyle");
|
||||||
document.getElementById("blurType").value = await settings.get("blurType");
|
|
||||||
}
|
}
|
||||||
loadSettings();
|
loadSettings();
|
||||||
document.getElementById("save").addEventListener("click", function () {
|
document.getElementById("save").addEventListener("click", function () {
|
||||||
|
@ -85,7 +74,7 @@
|
||||||
document.getElementById("tray").checked,
|
document.getElementById("tray").checked,
|
||||||
document.getElementById("patches").checked,
|
document.getElementById("patches").checked,
|
||||||
document.getElementById("mod").value,
|
document.getElementById("mod").value,
|
||||||
document.getElementById("blurType").value
|
"acrylic"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
70
src/types/glasstron.d.ts
vendored
70
src/types/glasstron.d.ts
vendored
|
@ -1,70 +0,0 @@
|
||||||
declare module "glasstron" {
|
|
||||||
export class BrowserWindow extends Electron.BrowserWindow {
|
|
||||||
getBlur(): Promise<boolean>;
|
|
||||||
setBlur(value: boolean): Promise<boolean>;
|
|
||||||
blurType: WindowsBlurType;
|
|
||||||
setVibrancy(vibrancy: MacOSVibrancy): void;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export function init(): void;
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export function update(
|
|
||||||
window: Electron.BrowserWindow,
|
|
||||||
values: {
|
|
||||||
windows?: {
|
|
||||||
blurType: WindowsBlurType;
|
|
||||||
};
|
|
||||||
macos?: {
|
|
||||||
vibrancy: MacOSVibrancy;
|
|
||||||
};
|
|
||||||
linux?: {
|
|
||||||
requestBlur: boolean;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
): void;
|
|
||||||
export class Hacks {
|
|
||||||
static injectOnElectron(): void;
|
|
||||||
static delayReadyEvent(): void;
|
|
||||||
}
|
|
||||||
export type WindowsBlurType = "acrylic" | "blurbehind" | "transparent" | "none";
|
|
||||||
export type MacOSVibrancy =
|
|
||||||
| (
|
|
||||||
| "appearance-based"
|
|
||||||
| "light"
|
|
||||||
| "dark"
|
|
||||||
| "titlebar"
|
|
||||||
| "selection"
|
|
||||||
| "menu"
|
|
||||||
| "popover"
|
|
||||||
| "sidebar"
|
|
||||||
| "medium-light"
|
|
||||||
| "ultra-dark"
|
|
||||||
| "header"
|
|
||||||
| "sheet"
|
|
||||||
| "window"
|
|
||||||
| "hud"
|
|
||||||
| "fullscreen-ui"
|
|
||||||
| "tooltip"
|
|
||||||
| "content"
|
|
||||||
| "under-window"
|
|
||||||
| "under-page"
|
|
||||||
)
|
|
||||||
| null;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "glasstron/src/utils" {
|
|
||||||
class Utils {
|
|
||||||
static getSavePath(): string;
|
|
||||||
static copyToPath(innerFile: string, outerFilename?: string, flags?: number): void;
|
|
||||||
static removeFromPath(filename: string): void;
|
|
||||||
static isInPath(filename: string): boolean;
|
|
||||||
static getPlatform(): any;
|
|
||||||
static parseKeyValString(string: string, keyvalSeparator?: string, pairSeparator?: string): any;
|
|
||||||
static makeKeyValString(object: any, keyvalSeparator?: string, pairSeparator?: string): string;
|
|
||||||
}
|
|
||||||
export = Utils;
|
|
||||||
}
|
|
|
@ -22,8 +22,9 @@ export async function sleep(ms: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkIfConfigIsNew() {
|
export async function checkIfConfigIsNew() {
|
||||||
if ((await getConfigUnsafe("automaticPatches")) == undefined) {
|
if (await getConfigUnsafe("automaticPatches") == undefined) {
|
||||||
firstRun = true;
|
console.log("Outdated config")
|
||||||
|
setup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ export async function getConfigUnsafe(object: string) {
|
||||||
}
|
}
|
||||||
export function getVersion() {
|
export function getVersion() {
|
||||||
//to-do better way of doing this
|
//to-do better way of doing this
|
||||||
return "3.1.0";
|
return "3.0.5";
|
||||||
}
|
}
|
||||||
export async function injectJS(inject: string) {
|
export async function injectJS(inject: string) {
|
||||||
const js = await (await fetch(`${inject}`)).text();
|
const js = await (await fetch(`${inject}`)).text();
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// I had to add most of the window creation code here to split both into seperete functions
|
// I had to add most of the window creation code here to split both into seperete functions
|
||||||
// WHY? Because I can't use the same code for both due to annoying bug with value `frame` not responding to variables
|
// WHY? Because I can't use the same code for both due to annoying bug with value `frame` not responding to variables
|
||||||
// I'm sorry for this mess but I'm not sure how to fix it.
|
// I'm sorry for this mess but I'm not sure how to fix it.
|
||||||
import {BrowserWindow, shell, app, ipcMain} from "electron";
|
import {BrowserWindow, shell, app, ipcMain, dialog} from "electron";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {contentPath} from "./main";
|
import {contentPath} from "./main";
|
||||||
import {checkIfConfigIsNew, firstRun, getConfigUnsafe} from "./utils";
|
import {checkIfConfigIsNew, firstRun, getConfigUnsafe} from "./utils";
|
||||||
import {registerIpc} from "./ipc";
|
import {registerIpc} from "./ipc";
|
||||||
import contextMenu from "electron-context-menu";
|
import contextMenu from "electron-context-menu";
|
||||||
export let mainWindow: BrowserWindow;
|
export let mainWindow: BrowserWindow;
|
||||||
import * as glasstron from "glasstron";
|
|
||||||
|
|
||||||
let guestWindows: BrowserWindow[] = [];
|
let guestWindows: BrowserWindow[] = [];
|
||||||
contextMenu({
|
contextMenu({
|
||||||
|
@ -37,7 +37,6 @@ function doAfterDefiningTheWindow() {
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
} else if (!(await getConfigUnsafe("minimizeToTray"))) {
|
} else if (!(await getConfigUnsafe("minimizeToTray"))) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
app.exit();
|
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -96,28 +95,9 @@ export function createNativeWindow() {
|
||||||
});
|
});
|
||||||
doAfterDefiningTheWindow();
|
doAfterDefiningTheWindow();
|
||||||
}
|
}
|
||||||
export function createGlasstronWindow() {
|
|
||||||
mainWindow = new glasstron.BrowserWindow({
|
|
||||||
width: 300,
|
|
||||||
height: 350,
|
|
||||||
title: "ArmCord",
|
|
||||||
darkTheme: true,
|
|
||||||
icon: path.join(__dirname, "/assets/icon_transparent.png"),
|
|
||||||
frame: true,
|
|
||||||
autoHideMenuBar: true,
|
|
||||||
webPreferences: {
|
|
||||||
preload: path.join(__dirname, "preload/preload.js"),
|
|
||||||
spellcheck: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//@ts-expect-error
|
|
||||||
mainWindow.blurType = getConfigUnsafe("blurType");
|
|
||||||
//@ts-expect-error
|
|
||||||
mainWindow.setBlur(true);
|
|
||||||
doAfterDefiningTheWindow();
|
|
||||||
}
|
|
||||||
export function createTabsHost() {
|
export function createTabsHost() {
|
||||||
|
dialog.showErrorBox("READ THIS BEFORE USING THE APP", "ArmCord Tabs are highly experimental and should be only used for strict testing purposes. Please don't ask for support, however you can still report bugs!")
|
||||||
guestWindows[1] = mainWindow;
|
guestWindows[1] = mainWindow;
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 300,
|
width: 300,
|
||||||
|
|
Loading…
Reference in a new issue