Revert Back To Asar

This commit is contained in:
thororen1234 2025-04-05 19:51:49 -04:00
parent 1e5a600213
commit d1d1e28138
No known key found for this signature in database
8 changed files with 24 additions and 65 deletions

View file

@ -53,7 +53,7 @@ jobs:
cp Vencord.user.{js,js.LEGAL.txt} release cp Vencord.user.{js,js.LEGAL.txt} release
# copy the plugin data jsons, the extension zips and the desktop/vesktop asars # copy the plugin data jsons, the extension zips and the desktop/vesktop asars
cp *.{json,zip} release cp *.{json,zip,asar} release
# legacy un-asared files # legacy un-asared files
cp desktop/* release cp desktop/* release

View file

@ -19,6 +19,7 @@
// @ts-check // @ts-check
import { createPackage } from "@electron/asar";
import { readdir, writeFile } from "fs/promises"; import { readdir, writeFile } from "fs/promises";
import { dirname, join } from "path"; import { dirname, join } from "path";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
@ -227,3 +228,8 @@ await Promise.all([
main: "main.js" main: "main.js"
})) }))
]); ]);
await Promise.all([
createPackage("dist/desktop", "dist/desktop.asar"),
createPackage("dist/equibop", "dist/equibop.asar"),
]);

View file

@ -43,11 +43,9 @@ if (IS_VESKTOP || !IS_VANILLA) {
} }
switch (url) { switch (url) {
case "renderer.js.map": case "renderer.js.map":
case "equibopRenderer.js.map":
case "preload.js.map": case "preload.js.map":
case "equibopPreload.js.map":
case "patcher.js.map": case "patcher.js.map":
case "equibopMain.js.map": case "main.js.map":
cb(join(__dirname, url)); cb(join(__dirname, url));
break; break;
default: default:

View file

@ -119,7 +119,7 @@ ipcMain.handle(IpcEvents.OPEN_MONACO_EDITOR, async () => {
autoHideMenuBar: true, autoHideMenuBar: true,
darkTheme: true, darkTheme: true,
webPreferences: { webPreferences: {
preload: join(__dirname, IS_DISCORD_DESKTOP ? "preload.js" : "equibopPreload.js"), preload: join(__dirname, "preload.js"),
contextIsolation: true, contextIsolation: true,
nodeIntegration: false, nodeIntegration: false,
sandbox: false sandbox: false

View file

@ -29,11 +29,8 @@ console.log("[Equicord] Starting up...");
// Our injector file at app/index.js // Our injector file at app/index.js
const injectorPath = require.main!.filename; const injectorPath = require.main!.filename;
// special discord_arch_electron injection method
const asarName = require.main!.path.endsWith("app.asar") ? "_app.asar" : "app.asar";
// The original app.asar // The original app.asar
const asarPath = join(dirname(injectorPath), "..", asarName); const asarPath = join(dirname(injectorPath), "..", "_app.asar");
const discordPkg = require(join(asarPath, "package.json")); const discordPkg = require(join(asarPath, "package.json"));
require.main!.filename = join(asarPath, discordPkg.main); require.main!.filename = join(asarPath, discordPkg.main);

View file

@ -16,12 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
export const EQUICORD_FILES = [ export const ASAR_FILE = IS_VESKTOP ? "vesktop.asar" : IS_EQUIBOP ? "equibop.asar" : "desktop.asar";
IS_DISCORD_DESKTOP ? "patcher.js" : "equibopMain.js",
IS_DISCORD_DESKTOP ? "preload.js" : "equibopPreload.js",
IS_DISCORD_DESKTOP ? "renderer.js" : "equibopRenderer.js",
IS_DISCORD_DESKTOP ? "renderer.css" : "equibopRenderer.css",
];
export function serializeErrors(func: (...args: any[]) => any) { export function serializeErrors(func: (...args: any[]) => any) {
return async function () { return async function () {

View file

@ -19,22 +19,16 @@
import { get } from "@main/utils/simpleGet"; import { get } from "@main/utils/simpleGet";
import { IpcEvents } from "@shared/IpcEvents"; import { IpcEvents } from "@shared/IpcEvents";
import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent"; import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
import { app, dialog, ipcMain } from "electron"; import { ipcMain } from "electron";
import { writeFile } from "fs/promises"; import { writeFileSync as originalWriteFileSync } from "original-fs";
import {
existsSync,
unlinkSync,
writeFileSync,
} from "original-fs";
import { join } from "path";
import gitHash from "~git-hash"; import gitHash from "~git-hash";
import gitRemote from "~git-remote"; import gitRemote from "~git-remote";
import { EQUICORD_FILES, serializeErrors } from "./common"; import { ASAR_FILE, serializeErrors } from "./common";
const API_BASE = `https://api.github.com/repos/${gitRemote}`; const API_BASE = `https://api.github.com/repos/${gitRemote}`;
let PendingUpdates = [] as [string, string][]; let PendingUpdate: string | null = null;
async function githubGet(endpoint: string) { async function githubGet(endpoint: string) {
return get(API_BASE + endpoint, { return get(API_BASE + endpoint, {
@ -71,54 +65,23 @@ async function fetchUpdates() {
return false; return false;
data.assets.forEach(({ name, browser_download_url }) => { const asset = data.assets.find(a => a.name === ASAR_FILE);
if (EQUICORD_FILES.some(s => name.startsWith(s))) { PendingUpdate = asset.browser_download_url;
PendingUpdates.push([name, browser_download_url]);
}
});
return true; return true;
} }
async function applyUpdates() { async function applyUpdates() {
await Promise.all(PendingUpdates.map( if (!PendingUpdate) return true;
async ([name, data]) => writeFile(
join(__dirname, name), const data = await get(PendingUpdate);
await get(data) originalWriteFileSync(__dirname, data);
)
)); PendingUpdate = null;
PendingUpdates = [];
return true; return true;
} }
async function migrateAsarToLegacy() {
try {
const isFlatpak = process.platform === "linux" && !!process.env.FLATPAK_ID;
if (isFlatpak) throw "Flatpak Discord can't automatically be migrated.";
const asarPath = join(__dirname, "../equicord.asar");
if (existsSync(asarPath)) {
unlinkSync(asarPath);
}
writeFileSync(__filename, "// Shim for legacy Equicord\n\nrequire(\"./index.js\");");
app.relaunch();
app.exit();
} catch (e) {
console.error("Failed to migrate to legacy", e);
app.whenReady().then(() => {
dialog.showErrorBox(
"Migration Error",
"Failed to migrate back to the legacy version. Please reinstall using the Equicord Installer."
);
app.exit(1);
});
}
}
ipcMain.handle(IpcEvents.GET_REPO, serializeErrors(() => `https://github.com/${gitRemote}`)); ipcMain.handle(IpcEvents.GET_REPO, serializeErrors(() => `https://github.com/${gitRemote}`));
ipcMain.handle(IpcEvents.GET_UPDATES, serializeErrors(calculateGitChanges)); ipcMain.handle(IpcEvents.GET_UPDATES, serializeErrors(calculateGitChanges));
ipcMain.handle(IpcEvents.UPDATE, serializeErrors(fetchUpdates)); ipcMain.handle(IpcEvents.UPDATE, serializeErrors(fetchUpdates));

View file

@ -28,7 +28,7 @@ contextBridge.exposeInMainWorld("VencordNative", VencordNative);
// Discord // Discord
if (location.protocol !== "data:") { if (location.protocol !== "data:") {
// #region cssInsert // #region cssInsert
const rendererCss = join(__dirname, IS_DISCORD_DESKTOP ? "renderer.css" : "equibopRenderer.css"); const rendererCss = join(__dirname, "renderer.css");
const style = document.createElement("style"); const style = document.createElement("style");
style.id = "vencord-css-core"; style.id = "vencord-css-core";