Add auto-launch and bunch of other things

This commit is contained in:
smartfrigde 2022-05-14 21:02:09 +02:00
parent 6663b6de5f
commit 5893f5bea9
8 changed files with 101 additions and 105 deletions

143
package-lock.json generated
View file

@ -10,13 +10,12 @@
"hasInstallScript": true,
"license": "OSL-3.0",
"dependencies": {
"easy-auto-launch": "^6.0.2",
"electron-context-menu": "https://github.com/ArmCord/electron-context-menu.git",
"electron-editor-context-menu": "^1.1.1",
"v8-compile-cache": "^2.3.0",
"ws": "^8.6.0"
},
"devDependencies": {
"@types/electron-json-storage": "^4.5.0",
"@types/node": "^17.0.33",
"@types/ws": "^8.5.3",
"copyfiles": "^2.4.1",
@ -232,12 +231,6 @@
"@types/ms": "*"
}
},
"node_modules/@types/electron-json-storage": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@types/electron-json-storage/-/electron-json-storage-4.5.0.tgz",
"integrity": "sha512-wzDtkJHEENo4yLARfPjdYD6Foa7IORXFiNYLacZ6lJThkrGUWh5vlSSMu925ov5zv8tQHtajn2O7BpHcBtqU3g==",
"dev": true
},
"node_modules/@types/fs-extra": {
"version": "9.0.13",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz",
@ -485,6 +478,11 @@
"node": ">= 10.0.0"
}
},
"node_modules/applescript": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/applescript/-/applescript-1.0.0.tgz",
"integrity": "sha1-u4evVoytA0pOSMS9r2Bno6JwExc="
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@ -1311,6 +1309,20 @@
"integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=",
"dev": true
},
"node_modules/easy-auto-launch": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/easy-auto-launch/-/easy-auto-launch-6.0.2.tgz",
"integrity": "sha512-UhrWpPlPB2YKQXU+hw2kIfQzVecDnYsLUiFdLkKv3eCUtxmCcfEcAjxk8P6RMc8IjCoW8N9ALpJh5n0R1h/z1A==",
"dependencies": {
"applescript": "^1.0.0",
"mkdirp": "^1.0.4",
"untildify": "^4.0.0",
"winreg": "^1.2.4"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/ejs": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
@ -1459,18 +1471,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/electron-editor-context-menu": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/electron-editor-context-menu/-/electron-editor-context-menu-1.1.1.tgz",
"integrity": "sha1-3DAJjg37N/YmKOQzAxJMfzN5Vy0=",
"dependencies": {
"lodash.clonedeep": "^4.3.0",
"lodash.defaults": "^4.0.1",
"lodash.isarray": "^4.0.0",
"lodash.isempty": "^4.1.2",
"lodash.isfunction": "^3.0.8"
}
},
"node_modules/electron-is-dev": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-2.0.0.tgz",
@ -2359,32 +2359,6 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/lodash.clonedeep": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
},
"node_modules/lodash.defaults": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
"integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw="
},
"node_modules/lodash.isarray": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-4.0.0.tgz",
"integrity": "sha1-KspJayjEym1yZxUxNZDALm6jRAM=",
"deprecated": "This package is deprecated. Use Array.isArray."
},
"node_modules/lodash.isempty": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
"integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4="
},
"node_modules/lodash.isfunction": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz",
"integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw=="
},
"node_modules/lowercase-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
@ -2497,7 +2471,6 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true,
"bin": {
"mkdirp": "bin/cmd.js"
},
@ -3302,7 +3275,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz",
"integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==",
"dev": true,
"engines": {
"node": ">=8"
}
@ -3467,6 +3439,11 @@
"node": ">=8"
}
},
"node_modules/winreg": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz",
"integrity": "sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs="
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
@ -3757,12 +3734,6 @@
"@types/ms": "*"
}
},
"@types/electron-json-storage": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@types/electron-json-storage/-/electron-json-storage-4.5.0.tgz",
"integrity": "sha512-wzDtkJHEENo4yLARfPjdYD6Foa7IORXFiNYLacZ6lJThkrGUWh5vlSSMu925ov5zv8tQHtajn2O7BpHcBtqU3g==",
"dev": true
},
"@types/fs-extra": {
"version": "9.0.13",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz",
@ -3977,6 +3948,11 @@
}
}
},
"applescript": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/applescript/-/applescript-1.0.0.tgz",
"integrity": "sha1-u4evVoytA0pOSMS9r2Bno6JwExc="
},
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@ -4614,6 +4590,17 @@
"integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=",
"dev": true
},
"easy-auto-launch": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/easy-auto-launch/-/easy-auto-launch-6.0.2.tgz",
"integrity": "sha512-UhrWpPlPB2YKQXU+hw2kIfQzVecDnYsLUiFdLkKv3eCUtxmCcfEcAjxk8P6RMc8IjCoW8N9ALpJh5n0R1h/z1A==",
"requires": {
"applescript": "^1.0.0",
"mkdirp": "^1.0.4",
"untildify": "^4.0.0",
"winreg": "^1.2.4"
}
},
"ejs": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
@ -4731,18 +4718,6 @@
"unused-filename": "^2.1.0"
}
},
"electron-editor-context-menu": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/electron-editor-context-menu/-/electron-editor-context-menu-1.1.1.tgz",
"integrity": "sha1-3DAJjg37N/YmKOQzAxJMfzN5Vy0=",
"requires": {
"lodash.clonedeep": "^4.3.0",
"lodash.defaults": "^4.0.1",
"lodash.isarray": "^4.0.0",
"lodash.isempty": "^4.1.2",
"lodash.isfunction": "^3.0.8"
}
},
"electron-is-dev": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-2.0.0.tgz",
@ -5428,31 +5403,6 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"lodash.clonedeep": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
},
"lodash.defaults": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
"integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw="
},
"lodash.isarray": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-4.0.0.tgz",
"integrity": "sha1-KspJayjEym1yZxUxNZDALm6jRAM="
},
"lodash.isempty": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
"integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4="
},
"lodash.isfunction": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz",
"integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw=="
},
"lowercase-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
@ -5531,8 +5481,7 @@
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
},
"modify-filename": {
"version": "1.1.0",
@ -6167,8 +6116,7 @@
"untildify": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz",
"integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==",
"dev": true
"integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw=="
},
"unused-filename": {
"version": "2.1.0",
@ -6301,6 +6249,11 @@
"string-width": "^4.0.0"
}
},
"winreg": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz",
"integrity": "sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs="
},
"wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",

View file

@ -33,6 +33,7 @@
"typescript": "^4.6.3"
},
"dependencies": {
"easy-auto-launch": "^6.0.2",
"electron-context-menu": "https://github.com/ArmCord/electron-context-menu.git",
"v8-compile-cache": "^2.3.0",
"ws": "^8.6.0"

View file

@ -96,6 +96,7 @@
windowStyle: "default",
channel: "stable",
armcordCSP: true,
autoLaunch: true,
minimizeToTray: true,
automaticPatches: false,
mods: "cumcord",
@ -126,6 +127,7 @@
windowStyle: "default",
channel: options.channel,
armcordCSP: true,
autoLaunch: true,
minimizeToTray: true,
automaticPatches: false,
mods: options.mod,
@ -141,6 +143,7 @@
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
autoLaunch: true,
mods: "none",
inviteWebsocket: true,
blurType: "acrylic"

View file

@ -7,6 +7,7 @@ import "./extensions/plugin";
import "./tray";
import {createCustomWindow, createNativeWindow, createTabsHost} from "./window";
import "./shortcuts";
import AutoLaunch from "easy-auto-launch";
export var settings: any;
export var customTitlebar: boolean;
@ -25,7 +26,17 @@ if (process.platform == "linux") {
}
checkIfConfigExists();
var AutoLauncher = new AutoLaunch({
name: 'ArmCord',
path: '/Applications/ArmCord.app',
});
app.whenReady().then(async () => {
if (await getConfig("autoLaunch") == "true") {
AutoLauncher.enable()
} else {
AutoLauncher.disable()
}
switch (await getConfig("windowStyle")) {
case "default":
createCustomWindow();

View file

@ -15,7 +15,7 @@ export function createSettingsWindow() {
} else {
settingsWindow = new BrowserWindow({
width: 500,
height: 500,
height: 555,
title: "ArmCord Settings",
darkTheme: true,
frame: true,

View file

@ -40,6 +40,12 @@
<input class="tgl tgl-light left" id="websocket" type="checkbox" />
<label class="tgl-btn left" for="websocket"></label>
</div>
<br />
<div class="switch">
<label class="header">Auto launch</label>
<input class="tgl tgl-light left" id="autolaunch" type="checkbox" />
<label class="tgl-btn left" for="autolaunch"></label>
</div>
<div class="switch">
<select name="channel" id="channel" class="left">
<option value="stable">Stable</option>
@ -71,6 +77,7 @@
document.getElementById("mod").value = await settings.get("mods");
document.getElementById("channel").value = await settings.get("channel");
document.getElementById("theme").value = await settings.get("windowStyle");
document.getElementById("autolaunch").checked = await settings.get("autoLaunch");
}
loadSettings();
document.getElementById("save").addEventListener("click", function () {
@ -83,6 +90,7 @@
automaticPatches: document.getElementById("patches").checked,
mods: document.getElementById("mod").value,
blurType: "acrylic",
autoLaunch: document.getElementById("autolaunch").checked,
inviteWebsocket: document.getElementById("websocket").checked,
doneSetup: true
});

View file

@ -2,6 +2,7 @@ import * as fs from "fs";
import {app, dialog} from "electron";
import path from "path";
export var firstRun: boolean;
export var isSetup: boolean;
export var contentPath: string;
//utillity functions that are used all over the codebase or just too obscure to be put in the file used in
export function addStyle(styleString: string) {
@ -21,7 +22,7 @@ export async function sleep(ms: number) {
}
export async function checkIfConfigIsBroken() {
if (await getConfig("0") == "d") {
if ((await getConfig("0")) == "d") {
console.log("Detected a corrupted config");
setup();
dialog.showErrorBox(
@ -39,6 +40,7 @@ export function setup() {
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
autoLaunch: true,
mods: "cumcord",
blurType: "acrylic",
inviteWebsocket: true,
@ -71,6 +73,7 @@ export interface Settings {
armcordCSP: boolean;
minimizeToTray: boolean;
automaticPatches: boolean;
autoLaunch: boolean;
mods: string;
blurType: string;
inviteWebsocket: boolean;
@ -132,6 +135,16 @@ export async function checkIfConfigExists() {
}
console.log("First run of the ArmCord. Starting setup.");
setup();
isSetup = true;
contentPath = path.join(__dirname, "/content/setup.html");
if (!contentPath.includes("ts-out")) {
contentPath = path.join(__dirname, "/ts-out/content/setup.html");
}
} else {
if (await getConfig("doneSetup") == false) {
console.log("First run of the ArmCord. Starting setup.");
setup();
isSetup = true;
contentPath = path.join(__dirname, "/content/setup.html");
if (!contentPath.includes("ts-out")) {
contentPath = path.join(__dirname, "/ts-out/content/setup.html");
@ -144,3 +157,4 @@ export async function checkIfConfigExists() {
}
}
}
}

View file

@ -4,7 +4,7 @@
// I'm sorry for this mess but I'm not sure how to fix it.
import {BrowserWindow, shell, app, ipcMain, dialog, clipboard} from "electron";
import path from "path";
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath} from "./utils";
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath, isSetup} from "./utils";
import {registerIpc} from "./ipc";
import startServer from "./socket"
import contextMenu from "electron-context-menu";
@ -46,8 +46,12 @@ async function doAfterDefiningTheWindow() {
if (await getConfig("inviteWebsocket") == true) {
startServer()
}
try {
mainWindow.loadFile(contentPath);
if (isSetup) {
mainWindow.setSize(390, 470);
}
} catch (e) {
console.log(
"Major error detected while starting up. User is most likely on Windows platform. Fallback to alternative startup."
@ -55,12 +59,14 @@ async function doAfterDefiningTheWindow() {
console.log(process.platform);
if (process.platform === "win32") {
if (firstRun) {
mainWindow.setSize(390, 470);
mainWindow.loadURL(`file://${__dirname}/content/setup.html`);
} else {
mainWindow.loadURL(`file://${__dirname}/content/splash.html`);
}
} else {
if (firstRun) {
mainWindow.setSize(390, 470);
mainWindow.loadURL(`file://${__dirname}/ts-out/content/setup.html`);
} else {
mainWindow.loadURL(`file://${__dirname}/ts-out/content/splash.html`);
@ -70,8 +76,8 @@ async function doAfterDefiningTheWindow() {
}
export function createCustomWindow() {
mainWindow = new BrowserWindow({
width: 390,
height: 470,
width: 300,
height: 350,
title: "ArmCord",
darkTheme: true,
icon: path.join(__dirname, "/assets/icon_transparent.png"),