diff options
author | Aylur <[email protected]> | 2024-07-15 22:09:58 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-07-15 22:09:58 +0200 |
commit | e5251d23f158c7cc092121c3a7cc0438a73746ec (patch) | |
tree | dbd972adfb768e5600ca15f779b4cffc666a442f /node/src/application.ts | |
parent | be163b310398ad7f454d3ece574a476abfa216e9 (diff) |
remove python and node
I have no desire to work on the python version
The node version has the issue of promises not working which makes it
unusable but gjs works just as good if not better. Might look back into
node later
Diffstat (limited to 'node/src/application.ts')
-rw-r--r-- | node/src/application.ts | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/node/src/application.ts b/node/src/application.ts deleted file mode 100644 index 13a999c..0000000 --- a/node/src/application.ts +++ /dev/null @@ -1,78 +0,0 @@ -import gi from "node-gtk" -const Astal = gi.require("Astal", "0.1") - -type RequestHandler = { - (request: string, res: (response: any) => void): void -} - -type Config = Partial<{ - instanceName: string - gtkTheme: string - iconTheme: string - cursorTheme: string - css: string - requestHandler: RequestHandler - hold: boolean -}> - -class AstalJS extends Astal.Application { - static GTypeName = "AstalJS" - static { gi.registerClass(this) } - - eval(body: string): Promise<any> { - return new Promise((res, rej) => { - try { - const fn = Function(`return (async function() { - ${body.includes(";") ? body : `return ${body};`} - })`) - fn()() - .then(res) - .catch(rej) - } catch (error) { - rej(error) - } - }) - } - - requestHandler?: RequestHandler - - vfunc_request(msg: string, conn: any): void { - if (typeof this.requestHandler === "function") { - this.requestHandler(msg, response => { - Astal.writeSock(conn, String(response), (_, res) => - Astal.writeSockFinish(res), - ) - }) - } else { - // @ts-expect-error missing type - super.vfunc_request(msg, conn) - } - } - - start( - { requestHandler, css, ...cfg }: Omit<Config, "hold"> = {}, - callback?: (args: string[]) => any, - ) { - Object.assign(this, cfg) - - this.requestHandler = requestHandler - this.on("activate", () => { - callback?.(process.argv) - }) - - if (!this.acquireSocket()) { - console.error(`Astal instance "${this.instanceName}" already running`) - process.exit() - } - - if (css) - this.applyCss(css, false) - - // FIXME: promises never resolve - // https://github.com/romgrk/node-gtk/issues/121 - // https://gitlab.gnome.org/GNOME/gjs/-/issues/468 - App.run([]) - } -} - -export const App = new AstalJS |