use unpacked in dev

This commit is contained in:
Vendicated 2024-07-19 21:52:49 +02:00
parent 94a0c4dc10
commit ac28db6c4d
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
4 changed files with 11 additions and 13 deletions

View file

@ -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)`;

View file

@ -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"));

View file

@ -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");

View file

@ -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();
}