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