fix: switched to node-7z

fix: switched to bun spawn but with windowsVerbatimArguments
feat: Added ppsspp integration
feat: Added focusing controls for windows
feat: Added shortcut to kill emulators
This commit is contained in:
Simeon Radivoev 2026-03-29 22:18:05 +03:00
parent a7eb655a48
commit 90d6711935
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
31 changed files with 1382 additions and 88 deletions

View file

@ -2,6 +2,8 @@ import EventEmitter from "events";
import browser from '../src/bun/browser';
import { tmpdir } from "os";
import path from "path";
import { createInterface } from "readline";
import { Readable } from "stream";
const events = new EventEmitter();
const abortController = new AbortController();
@ -12,23 +14,16 @@ let retries = 0;
function spawnServer ()
{
return Bun.spawn(["bun", '--watch', '--install=fallback', "run", "--inspect=127.0.0.1:9228/fixed-session", "./src/bun/index.ts"], {
const s = Bun.spawn(["bun", '--watch', '--install=fallback', "run", "--inspect=127.0.0.1:9228/fixed-session", "./src/bun/index.ts"], {
env: {
...process.env,
HEADLESS: "true",
},
stdout: "inherit",
stdout: "pipe",
stderr: "inherit",
stdin: "pipe",
signal: abortController.signal,
killSignal: 'SIGUSR1',
ipc (message, subprocess, handle)
{
if (message.type === 'exitapp')
{
events.emit('exitapp');
}
},
onExit (subprocess, exitCode, signalCode)
{
if (exitCode === 1 && retries <= 3)
@ -42,6 +37,18 @@ function spawnServer ()
}
});
const rl = createInterface({ input: Readable.fromWeb(s.stdout as any) });
rl.on('line', e =>
{
if (e === 'focus')
{
events.emit('focus');
} else
{
console.log(e);
}
});
return s;
}
function spawnBrowser ()

View file

@ -26,13 +26,30 @@ if (process.env.TARGET)
compileOption.target = process.env.TARGET as any;
}
let webviewLib = "libwebview.dll";
if (process.platform === 'linux' && system.arch === 'x64')
webviewLib = "libwebview-x64.so";
if (process.platform === 'linux' && system.arch === 'arm64')
webviewLib = "libwebview-arm64.so";
if (process.platform === 'darwin')
webviewLib = "libwebview-arm64.dylib";
let zip: string | undefined;
let zipNodePath: string | undefined;
let webviewLib: string | undefined;
switch (process.platform)
{
case "win32":
zip = "7za.exe";
zipNodePath = "win";
webviewLib = `libwebview.dll`;
break;
case "linux":
zip = "7za";
zipNodePath = 'linux';
webviewLib = `libwebview-${system.arch}.so`;
break;
case "darwin":
zip = "7za";
zipNodePath = 'mac';
webviewLib = `libwebview-${system.arch}.dylib`;
break;
}
if (!webviewLib) throw new Error("Could not find webviewlib");
let webviewLibPath = '.';
if (process.env.APPIMAGE === "true")
@ -47,6 +64,7 @@ await Bun.build({
define: {
"process.env.IS_BINARY": "true",
"process.env.WEBVIEW_PATH": `${webviewLibPath}/${webviewLib}`,
"process.env.ZIP7_PATH": `"${zip}"`
},
minify: process.env.NODE_ENV !== 'development',
sourcemap: process.env.NODE_ENV === 'development' ? 'inline' : "linked",
@ -77,6 +95,8 @@ await Bun.build({
await fs.cp('./drizzle', `${buildSubDir}/drizzle`, { recursive: true });
await fs.cp(`./vendors/es-de/emulators.${system.platform}.${system.arch}.sqlite`, `${buildSubDir}/vendors/es-de/emulators.${system.platform}.${system.arch}.sqlite`, { recursive: true });
await fs.cp(path.join(`node_modules/webview-bun/build/`, webviewLib), path.join(buildSubDir, webviewLib));
await fs.cp(`node_modules/@kmamal/sdl/dist`, buildSubDir, { recursive: true, errorOnExist: false });
await fs.cp(`node_modules/7zip-bin/${zipNodePath}/${process.arch}`, buildSubDir, { recursive: true, errorOnExist: false });
});
},
}]