reduced .exe size
This commit is contained in:
@@ -13,7 +13,7 @@ let win;
|
||||
let backend;
|
||||
const net = require('net');
|
||||
|
||||
function waitForServer(port, host = '127.0.0.1', timeout = 10000) {
|
||||
function waitForServer(port, host = '127.0.0.1', timeout = 30000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const start = Date.now();
|
||||
|
||||
|
||||
8702
desktop/package-lock.json
generated
8702
desktop/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@
|
||||
"jsonwebtoken": "^9.0.3",
|
||||
"node-addon-api": "^8.5.0",
|
||||
"node-cron": "^4.2.1",
|
||||
"playwright-chromium": "^1.57.0",
|
||||
"playwright": "^1.57.0",
|
||||
"sqlite3": "^5.1.7",
|
||||
"ws": "^8.18.3"
|
||||
},
|
||||
@@ -46,6 +46,7 @@
|
||||
"build": {
|
||||
"appId": "app.waifuboard",
|
||||
"productName": "Waifu Board",
|
||||
"asar": true,
|
||||
"files": [
|
||||
"electron/**/*",
|
||||
"server.js",
|
||||
@@ -58,10 +59,6 @@
|
||||
"loading.html"
|
||||
],
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "C:\\Users\\synta\\AppData\\Local\\ms-playwright\\chromium_headless_shell-1200",
|
||||
"to": "playwright/chromium"
|
||||
},
|
||||
".env"
|
||||
],
|
||||
"win": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { chromium } = require("playwright-core");
|
||||
const { chromium } = require("playwright");
|
||||
const {spawn} = require("node:child_process");
|
||||
|
||||
let browser;
|
||||
let context;
|
||||
@@ -9,36 +9,31 @@ const BLOCK_LIST = [
|
||||
"adsystem", "analytics", "tracker", "pixel", "quantserve", "newrelic"
|
||||
];
|
||||
|
||||
function isPackaged() {
|
||||
return process.env.IS_PACKAGED === "true";
|
||||
function runHidden(cmd, args) {
|
||||
return new Promise((res, rej) => {
|
||||
const p = spawn(cmd, args, {
|
||||
stdio: "ignore",
|
||||
shell: true,
|
||||
windowsHide: true
|
||||
});
|
||||
p.on("exit", c => c === 0 ? res() : rej(new Error("exit " + c)));
|
||||
});
|
||||
}
|
||||
|
||||
function getChromiumPath() {
|
||||
if (isPackaged()) {
|
||||
return path.join(
|
||||
process.resourcesPath,
|
||||
"playwright",
|
||||
"chromium",
|
||||
"chrome-headless-shell-win64",
|
||||
"chrome-headless-shell.exe"
|
||||
);
|
||||
}
|
||||
async function ensureChromiumShell() {
|
||||
const exe = chromium.executablePath();
|
||||
if (exe && fs.existsSync(exe)) return;
|
||||
|
||||
return chromium.executablePath();
|
||||
await runHidden("npx", ["playwright", "install", "chromium-headless-shell"]);
|
||||
}
|
||||
|
||||
async function initHeadless() {
|
||||
if (browser) return;
|
||||
|
||||
const exePath = getChromiumPath();
|
||||
|
||||
if (!fs.existsSync(exePath)) {
|
||||
throw new Error("Chromium not found: " + exePath);
|
||||
}
|
||||
await ensureChromiumShell();
|
||||
|
||||
browser = await chromium.launch({
|
||||
headless: true,
|
||||
executablePath: exePath,
|
||||
args: [
|
||||
"--no-sandbox",
|
||||
"--disable-setuid-sandbox",
|
||||
|
||||
Reference in New Issue
Block a user