Merge branch 'ArmCord:dev' into fix-stable-actions

This commit is contained in:
Aiden 2024-06-17 14:26:45 -04:00 committed by GitHub
commit f80d22435f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 122 additions and 202 deletions

View file

@ -3,151 +3,83 @@ on:
push: push:
branches: branches:
- dev - dev
env:
FORCE_COLOR: true
jobs: jobs:
build-linux: build:
runs-on: ubuntu-latest strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
arch: [arm64, amd64]
include:
- arch: arm64
os: windows-latest
flags: "--arm64 --windows"
target: "arm64-win"
- arch: amd64
os: windows-latest
flags: "--x64 --windows"
target: "amd64-win"
- arch: arm64
os: ubuntu-latest
flags: "--arm64 --linux"
target: "arm64-linux"
- arch: amd64
os: ubuntu-latest
flags: "--x64 --linux"
target: "amd64-linux"
- arch: arm64
os: macos-latest
flags: "--arm64 --macos"
target: "arm64-mac"
- arch: amd64
os: macos-latest
flags: "--x64 --macos"
target: "amd64-mac"
runs-on: ${{matrix.os}}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- uses: pnpm/action-setup@v4 - name: Prepeare PNPM
uses: pnpm/action-setup@v4
- name: Use Node.js 22 - name: Prepare Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: "pnpm" cache: pnpm
- name: Install Node dependencies - name: Install dependencies
run: pnpm i run: pnpm i
- name: Build - name: Build TypeScript
run: pnpm run build && pnpm electron-builder --linux zip run: pnpm build
- name: Upload artifact - name: Build Electron
uses: actions/upload-artifact@v4 run: pnpm electron-builder ${{matrix.flags}} zip
with:
name: ArmCordLinux
path: dist/armcord-*.zip
build-snap:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install Node dependencies
run: pnpm i
- name: Build
run: pnpm run build && pnpm electron-builder --linux snap --config.snap.grade=devel
- uses: snapcore/action-publish@v1
env: env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }} GH_TOKEN: ${{secrets.GITHUB_TOKEN}} # MacOS needs the token or it will fail to build
with:
snap: dist/armcord_3.3.0_amd64.snap
release: edge
build-linux-arm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install Node dependencies
run: pnpm i
- name: Build
run: pnpm run build && pnpm electron-builder --arm64 --linux zip
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ArmCordLinuxArm64 name: ${{matrix.target}}
path: dist/armcord-*-arm64.zip path: dist/
build-windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install Node dependencies
run: pnpm i
- name: Build
run: pnpm run build && pnpm electron-builder --windows zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ArmCordWindows
path: dist/armcord-3.3.0-win.zip
build-windows-arm:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Set architecture
run: set npm_config_arch=arm64
- uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json
- name: Install Node dependencies
run: pnpm i
- name: Build
run: pnpm run build && pnpm electron-builder --windows zip --arm64
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ArmCordWindowsArm64
path: dist\armcord-3.3.0-arm64-win.zip
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build-linux, build-windows, build-windows-arm, build-linux-arm] needs: build
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- uses: actions/download-artifact@v4 - name: Download artifacts
uses: actions/download-artifact@v4
with: with:
path: release-files path: release-files
@ -155,18 +87,19 @@ jobs:
id: vars id: vars
run: echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT run: echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- run: gh release delete devbuild -y --cleanup-tag - name: Delete old devbuild
run: gh release delete devbuild -y --cleanup-tag
env: env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Create Release - name: Create release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
env: env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with: with:
bodyFile: .github/release.md bodyFile: .github/release.md
generateReleaseNotes: false
name: Dev Build ${{steps.vars.outputs.sha_short}} name: Dev Build ${{steps.vars.outputs.sha_short}}
prerelease: true prerelease: true
draft: false
tag: devbuild tag: devbuild
artifacts: "release-files/**/*.zip" artifacts: release-files/**/*.zip

View file

@ -20,7 +20,7 @@
"settings-theme-native": "Native", "settings-theme-native": "Native",
"settings-theme-transparent": "Transparent", "settings-theme-transparent": "Transparent",
"settings-csp-desc": "ArmCord CSP is our system that manages loading custom content loading into the Discord app. Stuff like\n client mods and themes depend on it. Disable if you want to get rid of mods and custom styles.", "settings-csp-desc": "ArmCord CSP is our system that manages loading custom content loading into the Discord app. Stuff like\n client mods and themes depend on it. Disable if you want to get rid of mods and custom styles.",
"settings-mintoTray": "Minimize to tray", "settings-mintoTray": "Work in background",
"settings-mintoTray-desc": "When disabled, ArmCord will close like any other window when closed, otherwise it'll sit back and relax\n in your system tray for later.", "settings-mintoTray-desc": "When disabled, ArmCord will close like any other window when closed, otherwise it'll sit back and relax\n in your system tray for later.",
"settings-startMinimized": "Start minimized", "settings-startMinimized": "Start minimized",
"settings-startMinimized-desc": "ArmCord starts in background and remains out of your way.", "settings-startMinimized-desc": "ArmCord starts in background and remains out of your way.",

View file

@ -11,7 +11,6 @@
"watch": "tsc -w", "watch": "tsc -w",
"start": "pnpm run build && electron --trace-warnings ./ts-out/main.js", "start": "pnpm run build && electron --trace-warnings ./ts-out/main.js",
"startThemeManager": "pnpm run build && electron ./ts-out/main.js themes", "startThemeManager": "pnpm run build && electron ./ts-out/main.js themes",
"startKeybindManager": "pnpm run build && electron ./ts-out/main.js keybinds",
"startWayland": "pnpm run build && electron ./ts-out/main.js --ozone-platform-hint=auto --enable-features=WebRTCPipeWireCapturer,WaylandWindowDecorations --disable-gpu", "startWayland": "pnpm run build && electron ./ts-out/main.js --ozone-platform-hint=auto --enable-features=WebRTCPipeWireCapturer,WaylandWindowDecorations --disable-gpu",
"package": "pnpm run build && electron-builder", "package": "pnpm run build && electron-builder",
"packageQuick": "pnpm run build && electron-builder --dir", "packageQuick": "pnpm run build && electron-builder --dir",
@ -50,6 +49,7 @@
"arrpc": "github:OpenAsar/arrpc#c62ec6a04c8d870530aa6944257fe745f6c59a24", "arrpc": "github:OpenAsar/arrpc#c62ec6a04c8d870530aa6944257fe745f6c59a24",
"cross-fetch": "^4.0.0", "cross-fetch": "^4.0.0",
"electron-context-menu": "^4.0.0", "electron-context-menu": "^4.0.0",
"electron-is-dev": "^3.0.1",
"extract-zip": "^2.0.1", "extract-zip": "^2.0.1",
"v8-compile-cache": "^2.4.0", "v8-compile-cache": "^2.4.0",
"ws": "^8.17.0" "ws": "^8.17.0"

View file

@ -17,6 +17,9 @@ importers:
electron-context-menu: electron-context-menu:
specifier: ^4.0.0 specifier: ^4.0.0
version: 4.0.0 version: 4.0.0
electron-is-dev:
specifier: ^3.0.1
version: 3.0.1
extract-zip: extract-zip:
specifier: ^2.0.1 specifier: ^2.0.1
version: 2.0.1 version: 2.0.1

View file

@ -1,5 +1,6 @@
import {app, dialog} from "electron"; import {app, dialog} from "electron";
import path from "path"; import path from "path";
import isDev from "electron-is-dev";
import fs from "fs"; import fs from "fs";
import type {Settings} from "../types/settings.d.js"; import type {Settings} from "../types/settings.d.js";
import {getWindowStateLocation} from "./windowState.js"; import {getWindowStateLocation} from "./windowState.js";
@ -10,7 +11,7 @@ export function checkForDataFolder(): void {
console.log("Found armcord-data folder. Running in portable mode."); console.log("Found armcord-data folder. Running in portable mode.");
app.setPath("userData", dataPath); app.setPath("userData", dataPath);
} }
if (path.join(app.getPath("appData"), "ArmCord")) { if (path.join(app.getPath("appData"), "ArmCord") && !isDev) {
console.log("Found existing ArmCord folder."); console.log("Found existing ArmCord folder.");
app.setPath("userData", path.join(app.getPath("appData"), "ArmCord")); app.setPath("userData", path.join(app.getPath("appData"), "ArmCord"));
} }

5
src/common/forceQuit.ts Normal file
View file

@ -0,0 +1,5 @@
export let forceQuit = false;
export function setForceQuit(e: boolean): void {
forceQuit = e;
}

View file

@ -1,13 +1,14 @@
import {app} from "electron"; import {app} from "electron";
import isDev from "electron-is-dev";
export function getVersion(): string { export function getVersion(): string {
if ((app.getVersion() == process.versions.electron) == true) { if (isDev) {
return "3.3.0"; return "0.0.0";
} }
return app.getVersion(); return app.getVersion();
} }
export function getDisplayVersion(): string { export function getDisplayVersion(): string {
if ((app.getVersion() == process.versions.electron) == true) { if (isDev) {
return "Dev Build"; return "Dev Build";
} }
return app.getVersion(); return app.getVersion();

View file

@ -1,6 +1,7 @@
import {BrowserWindow, Menu, app} from "electron"; import {BrowserWindow, Menu, app} from "electron";
import {mainWindows} from "./window.js"; import {mainWindows} from "./window.js";
import {createSettingsWindow} from "../settings/main.js"; import {createSettingsWindow} from "../settings/main.js";
import {setForceQuit} from "../common/forceQuit.js";
export function setMenu(): void { export function setMenu(): void {
const template: Electron.MenuItemConstructorOptions[] = [ const template: Electron.MenuItemConstructorOptions[] = [
@ -48,6 +49,7 @@ export function setMenu(): void {
label: "Quit", label: "Quit",
accelerator: "CmdOrCtrl+Q", accelerator: "CmdOrCtrl+Q",
click() { click() {
setForceQuit(true);
app.quit(); app.quit();
} }
} }

View file

@ -12,14 +12,14 @@ import * as fs from "fs";
import contextMenu from "electron-context-menu"; import contextMenu from "electron-context-menu";
import os from "os"; import os from "os";
import RPCServer from "arrpc"; import RPCServer from "arrpc";
import {isQuitting, tray} from "../tray.js"; import {tray} from "../tray.js";
import {iconPath, init} from "../main.js"; import {iconPath, init} from "../main.js";
import {getConfig, setConfig, firstRun} from "../common/config.js"; import {getConfig, setConfig, firstRun} from "../common/config.js";
import {getWindowState, setWindowState} from "../common/windowState.js"; import {getWindowState, setWindowState} from "../common/windowState.js";
import {forceQuit, setForceQuit} from "../common/forceQuit.js";
export let mainWindows: BrowserWindow[] = []; export let mainWindows: BrowserWindow[] = [];
export let inviteWindow: BrowserWindow; export let inviteWindow: BrowserWindow;
export let forceQuit = false;
let osType = os.type();
contextMenu({ contextMenu({
showSaveImageAs: true, showSaveImageAs: true,
showCopyImageAddress: true, showCopyImageAddress: true,
@ -65,11 +65,11 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
passedWindow.webContents.userAgent = passedWindow.webContents.userAgent =
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.149 Mobile Safari/537.36"; "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.149 Mobile Safari/537.36";
} else { } else {
// A little sloppy but it works :p let osType = process.platform === "darwin" ? "Macintosh" : process.platform === "win32" ? "Windows" : "Linux";
if (osType == "Windows_NT") { if (osType === "Linux") osType = "X11; " + osType;
osType = `Windows ${os.release().split(".")[0]} (${os.release()})`; const chromeVersion = process.versions.chrome;
} const userAgent = `Mozilla/5.0 (${osType} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
passedWindow.webContents.userAgent = `Mozilla/5.0 (X11; ${osType} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36`; //fake useragent for screenshare to work passedWindow.webContents.userAgent = userAgent;
} }
if (mainWindows.length === 1) { if (mainWindows.length === 1) {
app.on("second-instance", (_event, _commandLine, _workingDirectory, additionalData) => { app.on("second-instance", (_event, _commandLine, _workingDirectory, additionalData) => {
@ -96,6 +96,10 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
passedWindow.webContents.setWindowOpenHandler(({url}) => { passedWindow.webContents.setWindowOpenHandler(({url}) => {
// Allow about:blank (used by Vencord QuickCss popup) // Allow about:blank (used by Vencord QuickCss popup)
if (url === "about:blank") return {action: "allow"}; if (url === "about:blank") return {action: "allow"};
// Saving ics files on future events
if (url.startsWith("blob:https://discord.com/")) {
return {action: "allow", overrideBrowserWindowOptions: {show: false}};
}
// Allow Discord stream popout // Allow Discord stream popout
if ( if (
url === "https://discord.com/popout" || url === "https://discord.com/popout" ||
@ -138,6 +142,7 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
} }
}); });
} }
return {action: "deny"}; return {action: "deny"};
}); });
if (getConfig("useLegacyCapturer") == false) { if (getConfig("useLegacyCapturer") == false) {
@ -238,12 +243,18 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
}); });
setMenu(); setMenu();
passedWindow.on("close", (e) => { passedWindow.on("close", (e) => {
if (process.platform === "darwin" && forceQuit) { if (mainWindows.length > 1) {
passedWindow.close();
} else if (mainWindows.length > 1) {
mainWindows = mainWindows.filter((mainWindow) => mainWindow.id != passedWindow.id); mainWindows = mainWindows.filter((mainWindow) => mainWindow.id != passedWindow.id);
passedWindow.destroy(); passedWindow.destroy();
} else { }
if (getConfig("minimizeToTray") && !forceQuit) {
e.preventDefault();
passedWindow.hide();
} else if (!getConfig("minimizeToTray")) {
app.quit();
}
});
app.on("before-quit", () => {
const [width, height] = passedWindow.getSize(); const [width, height] = passedWindow.getSize();
setWindowState({ setWindowState({
width, width,
@ -252,25 +263,8 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
x: passedWindow.getPosition()[0], x: passedWindow.getPosition()[0],
y: passedWindow.getPosition()[1] y: passedWindow.getPosition()[1]
}); });
if (getConfig("minimizeToTray") && !isQuitting) { setForceQuit(true);
e.preventDefault();
passedWindow.hide();
} else if (!getConfig("minimizeToTray")) {
e.preventDefault();
app.quit();
}
}
}); });
if (process.platform === "darwin") {
app.on("before-quit", function (event) {
if (!forceQuit) {
event.preventDefault();
forceQuit = true;
app.quit();
}
});
}
// REVIEW - Awaiting javascript execution is silly // REVIEW - Awaiting javascript execution is silly
passedWindow.on("focus", () => { passedWindow.on("focus", () => {
void passedWindow.webContents.executeJavaScript(`document.body.removeAttribute("unFocused");`); void passedWindow.webContents.executeJavaScript(`document.body.removeAttribute("unFocused");`);

View file

@ -31,7 +31,7 @@ app.on("render-process-gone", (_event, _webContents, details) => {
app.relaunch(); app.relaunch();
} }
}); });
async function args(): Promise<void> { function args(): void {
let argNum = 2; let argNum = 2;
if (process.argv[0] == "electron") argNum++; if (process.argv[0] == "electron") argNum++;
const args = process.argv[argNum]; const args = process.argv[argNum];
@ -44,7 +44,7 @@ async function args(): Promise<void> {
app.relaunch(); app.relaunch();
app.exit(); app.exit();
} else if (args == "themes") { } else if (args == "themes") {
await app.whenReady().then(async () => { void app.whenReady().then(async () => {
await createTManagerWindow(); await createTManagerWindow();
}); });
} }
@ -74,7 +74,7 @@ export async function init(): Promise<void> {
break; break;
} }
} }
await args(); // i want my top level awaits - IMPLEMENTED :) args();
if (!app.requestSingleInstanceLock()) { if (!app.requestSingleInstanceLock()) {
// if value isn't set after 3.2.4 // if value isn't set after 3.2.4
// kill if 2nd instance // kill if 2nd instance
@ -117,31 +117,7 @@ if (!app.requestSingleInstanceLock()) {
} else { } else {
iconPath = path.join(import.meta.dirname, "../", "/assets/desktop.png"); iconPath = path.join(import.meta.dirname, "../", "/assets/desktop.png");
} }
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) // 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 new Promise<void>((resolve) => setTimeout(() => (init(), resolve()), 1500));
await installModLoader(); await installModLoader();

View file

@ -1,6 +1,7 @@
import {BrowserWindow} from "electron"; import {BrowserWindow, ipcMain} from "electron";
import {iconPath} from "../main.js"; import {iconPath} from "../main.js";
import path from "path"; import path from "path";
import isDev from "electron-is-dev";
export let splashWindow: BrowserWindow; export let splashWindow: BrowserWindow;
export async function createSplashWindow(): Promise<void> { export async function createSplashWindow(): Promise<void> {
@ -19,5 +20,8 @@ export async function createSplashWindow(): Promise<void> {
preload: path.join(import.meta.dirname, "preload.mjs") preload: path.join(import.meta.dirname, "preload.mjs")
} }
}); });
ipcMain.on("isDev", (event) => {
event.returnValue = isDev;
});
await splashWindow.loadFile(path.join(import.meta.dirname, "splash.html")); await splashWindow.loadFile(path.join(import.meta.dirname, "splash.html"));
} }

View file

@ -4,6 +4,7 @@ contextBridge.exposeInMainWorld("internal", {
restart: () => ipcRenderer.send("restart"), restart: () => ipcRenderer.send("restart"),
installState: ipcRenderer.sendSync("modInstallState") as string, installState: ipcRenderer.sendSync("modInstallState") as string,
version: ipcRenderer.sendSync("get-app-version", "app-version") as string, version: ipcRenderer.sendSync("get-app-version", "app-version") as string,
isDev: ipcRenderer.sendSync("isDev") as string,
getLang: (toGet: string) => getLang: (toGet: string) =>
ipcRenderer.invoke("getLang", toGet).then((result: string) => { ipcRenderer.invoke("getLang", toGet).then((result: string) => {
return result; return result;

View file

@ -35,7 +35,7 @@
window.internal.restart(); window.internal.restart();
} else { } else {
text.innerHTML = await internal.getLang("loading_screen_start"); text.innerHTML = await internal.getLang("loading_screen_start");
if (window.internal.version === "3.3.0") { if (internal.isDev) {
console.log("Running a development build of ArmCord. Skipping updater."); console.log("Running a development build of ArmCord. Skipping updater.");
} else { } else {
const response = await fetch("https://armcord.app/latest.json"); const response = await fetch("https://armcord.app/latest.json");

View file

@ -5,8 +5,9 @@ import path from "path";
import {createSettingsWindow} from "./settings/main.js"; import {createSettingsWindow} from "./settings/main.js";
import {getConfig, getConfigLocation, setConfig} from "./common/config.js"; import {getConfig, getConfigLocation, setConfig} from "./common/config.js";
import {getDisplayVersion} from "./common/version.js"; import {getDisplayVersion} from "./common/version.js";
import {setForceQuit} from "./common/forceQuit.js";
export let tray: Tray; export let tray: Tray;
export let isQuitting = false;
let trayIcon = "ac_plug_colored"; let trayIcon = "ac_plug_colored";
void app.whenReady().then(async () => { void app.whenReady().then(async () => {
// REVIEW - app will hang at startup if line above is awaited. // REVIEW - app will hang at startup if line above is awaited.
@ -86,8 +87,7 @@ void app.whenReady().then(async () => {
{ {
label: `Quit ${clientName}`, label: `Quit ${clientName}`,
click() { click() {
//NOTE - It would be better to unify isQuitting with forceQuit in window.ts that's used on macOS setForceQuit(true);
isQuitting = true;
app.quit(); app.quit();
} }
} }