feat: implemented a basic store and emulatorjs

This commit is contained in:
Simeon Radivoev 2026-03-14 02:15:57 +02:00
parent 2f32cbc730
commit 7286541822
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
121 changed files with 5900 additions and 1092 deletions

View file

@ -1,10 +1,12 @@
import { RunBunServer } from './server';
import { RunAPIServer } from './api/rpc';
import { cleanup as appCleanup, events } from './api/app';
import { cleanup as appCleanup, config, events } from './api/app';
import init from './browser';
import { dirname } from 'pathe';
import { createInterface } from 'readline';
const api = RunAPIServer();
let bunServer: { stop: () => void; url: URL; } | undefined;
let bunServer: { stop: () => void; } | undefined;
if (!Bun.env.PUBLIC_ACCESS)
{
@ -16,21 +18,25 @@ async function cleanup ()
console.log("Cleaning Up");
await appCleanup();
bunServer?.stop();
await api.apiServer.stop();
await api.apiServer.stop(true);
await api.cleanup();
console.log("Finished Cleaning Up");
process.exit(0);
}
if (Bun.env.HEADLESS)
{
// Called by outside force
process.on('message', ({ type }) =>
const rl = createInterface({ input: process.stdin });
rl.on("line", async (line) =>
{
if (type === 'exitapp')
if (line.trim() === "shutdown")
{
cleanup();
console.log("Graceful Shutdown");
await cleanup();
}
});
// Called by user
events.on('exitapp', () =>
{
@ -39,7 +45,11 @@ if (Bun.env.HEADLESS)
});
} else
{
await init(events, !!Bun.env.FORCE_BROWSER);
await init(events, Bun.env.FORCE_BROWSER === "true", {
configPath: dirname(config.path),
windowPosition: config.get('windowPosition'),
windowSize: config.get('windowSize')
});
await cleanup();
}