From ac28db6c4d9ee52c9fcbc79295c5e4cb0657b9c4 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 19 Jul 2024 21:52:49 +0200 Subject: [PATCH] use unpacked in dev --- src/main/constants.ts | 6 ++---- src/main/ipc.ts | 6 +++--- src/main/mainWindow.ts | 4 ++-- src/main/utils/vencordLoader.ts | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/constants.ts b/src/main/constants.ts index 6c4dc80..f78449c 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -47,11 +47,9 @@ export const VENCORD_THEMES_DIR = join(DATA_DIR, "themes"); // needs to be inline require because of circular dependency // as otherwise "DATA_DIR" (which is used by ./settings) will be uninitialised -export const VENCORD_ASAR_FILE = (() => { +export const VENCORD_DIR = (() => { const { State } = require("./settings") as typeof import("./settings"); - return State.store.vencordDir - ? join(State.store.vencordDir, "vesktop.asar") - : join(SESSION_DATA_DIR, "vencord.asar"); + return State.store.vencordDir ? join(State.store.vencordDir, "vesktop") : join(SESSION_DATA_DIR, "vencord.asar"); })(); export const USER_AGENT = `Vesktop/${app.getVersion()} (https://github.com/Vencord/Vesktop)`; diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 677ad7f..6942723 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -17,7 +17,7 @@ import { debounce } from "shared/utils/debounce"; import { IpcEvents } from "../shared/IpcEvents"; import { setBadgeCount } from "./appBadge"; import { autoStart } from "./autoStart"; -import { VENCORD_ASAR_FILE, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; +import { VENCORD_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; import { mainWin } from "./mainWindow"; import { Settings, State } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; @@ -25,8 +25,8 @@ import { PopoutWindows } from "./utils/popout"; import { isDeckGameMode, showGamePage } from "./utils/steamOS"; import { isValidVencordInstall } from "./utils/vencordLoader"; -handleSync(IpcEvents.GET_VENCORD_PRELOAD_FILE, () => join(VENCORD_ASAR_FILE, "preload.js")); -handleSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT, () => readFileSync(join(VENCORD_ASAR_FILE, "renderer.js"), "utf-8")); +handleSync(IpcEvents.GET_VENCORD_PRELOAD_FILE, () => join(VENCORD_DIR, "preload.js")); +handleSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT, () => readFileSync(join(VENCORD_DIR, "renderer.js"), "utf-8")); handleSync(IpcEvents.GET_RENDERER_SCRIPT, () => readFileSync(join(__dirname, "renderer.js"), "utf-8")); handleSync(IpcEvents.GET_RENDERER_CSS_FILE, () => join(__dirname, "renderer.css")); diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index e30792b..fd1df25 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -34,7 +34,7 @@ import { MessageBoxChoice, MIN_HEIGHT, MIN_WIDTH, - VENCORD_ASAR_FILE + VENCORD_DIR } from "./constants"; import { Settings, State, VencordSettings } from "./settings"; import { createSplashWindow } from "./splash"; @@ -465,7 +465,7 @@ function createMainWindow() { return win; } -const runVencordMain = once(() => require(VENCORD_ASAR_FILE)); +const runVencordMain = once(() => require(VENCORD_DIR)); export async function createWindows() { const startMinimized = process.argv.includes("--start-minimized"); diff --git a/src/main/utils/vencordLoader.ts b/src/main/utils/vencordLoader.ts index fe2a760..6224ca7 100644 --- a/src/main/utils/vencordLoader.ts +++ b/src/main/utils/vencordLoader.ts @@ -7,7 +7,7 @@ import { existsSync } from "fs"; import { join } from "path"; -import { USER_AGENT, VENCORD_ASAR_FILE } from "../constants"; +import { USER_AGENT, VENCORD_DIR } from "../constants"; import { downloadFile, fetchie } from "./http"; const API_BASE = "https://api.github.com"; @@ -38,18 +38,18 @@ export async function githubGet(endpoint: string) { export async function downloadVencordAsar() { await downloadFile( "https://github.com/Vendicated/Vencord/releases/latest/download/vesktop.asar", - VENCORD_ASAR_FILE, + VENCORD_DIR, {}, { retryOnNetworkError: true } ); } export function isValidVencordInstall(dir: string) { - return existsSync(join(dir, "vesktop.asar")); + return existsSync(join(dir, "vesktop/main.js")); } export async function ensureVencordFiles() { - if (existsSync(VENCORD_ASAR_FILE)) return; + if (existsSync(VENCORD_DIR)) return; await downloadVencordAsar(); }