diff --git a/README.md b/README.md index 9a7fcb1..4d26d0d 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,17 @@ bun install github:pygmyapp/ipc-client - Clone this repository - Install dependencies with `bun install` -## Build - +You can then build the library: ```sh bun run build ``` ## Scripts -- `bun run lint`: runs Biome's linting, applies safe fixes, suggests fixes to errors, and auto-organizes imports +- `bun run lint`: runs Biome linting, applies safe fixes, and auto-organizes imports ## Licence -Copyright (c) 2025 Pygmy & contributors +Copyright (c) 2025 Pygmy & contributors + All code & assets are licensed under GNU GPL v3 unless stated otherwise. See `LICENSE` or [see here](https://www.gnu.org/licenses/gpl-3.0.txt). \ No newline at end of file diff --git a/bun.lock b/bun.lock index db1a044..4672539 100644 --- a/bun.lock +++ b/bun.lock @@ -5,6 +5,7 @@ "name": "ipc-client", "dependencies": { "node-ipc": "npm:@achrinza/node-ipc@^10.1.11", + "tseep": "^1.3.1", }, "devDependencies": { "@biomejs/biome": "2.1.3", @@ -60,6 +61,8 @@ "node-ipc": ["@achrinza/node-ipc@10.1.11", "", { "dependencies": { "@achrinza/event-pubsub": "5.0.11", "@achrinza/strong-type": "1.1.20", "@node-ipc/js-queue": "2.0.3", "js-message": "1.0.7" } }, "sha512-3z2yix2G8KP8gW6dWgRPj61Mu2nleqbWqTuS5vluZiXe2VDFkimqaeb4fnuS6JV2nhJz4gX+PR5PQjRKsuXm8w=="], + "tseep": ["tseep@1.3.1", "", {}, "sha512-ZPtfk1tQnZVyr7BPtbJ93qaAh2lZuIOpTMjhrYa4XctT8xe7t4SAW9LIxrySDuYMsfNNayE51E/WNGrNVgVicQ=="], + "typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], "undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="], diff --git a/dist/index.js b/dist/index.js index 944447e..06de406 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,5 @@ -import EventEmitter from 'node:events'; import IPCModule from 'node-ipc'; +import { EventEmitter } from 'tseep'; /** * Handles Inter-Process Communication (IPC) via. server/socket * diff --git a/package.json b/package.json index 193e861..6c66e2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipc-client", - "version": "0.0.3", + "version": "0.0.4", "module": "dist/index.js", "type": "module", "files": ["dist/**/*"], @@ -17,6 +17,7 @@ "typescript": "^5.9.2" }, "dependencies": { - "node-ipc": "npm:@achrinza/node-ipc@^10.1.11" + "node-ipc": "npm:@achrinza/node-ipc@^10.1.11", + "tseep": "^1.3.1" } } diff --git a/src/index.ts b/src/index.ts index 84eeb91..608a4b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ -import EventEmitter from 'node:events'; import IPCModule from 'node-ipc'; +import { EventEmitter } from 'tseep'; export interface IPCMessage { from: string; to: string; - payload: any; + payload: unknown; } /** @@ -25,7 +25,11 @@ export interface IPCMessage { * console.log(`Message:`, message); * }); */ -export default class IPC extends EventEmitter { +export default class IPC extends EventEmitter<{ + connect: () => void; + disconnect: () => void; + message: (message: IPCMessage) => void; +}> { name: string; ready: boolean; ipc: typeof IPCModule; @@ -70,7 +74,7 @@ export default class IPC extends EventEmitter { * @param to Who to send the message to * @param data JSON data to send to the process */ - send(to: string, data: any) { + send(to: string, data: unknown) { if (!this.ready) return; const message: IPCMessage = { @@ -102,7 +106,7 @@ export default class IPC extends EventEmitter { const message: IPCMessage = { from: raw.from, to: raw.to, - payload: JSON.parse(raw.payload) + payload: JSON.parse(raw.payload as string) }; this.emit('message', message);