Remove ws dep

This commit is contained in:
Andras Schmelczer 2025-12-14 14:39:16 +00:00
parent a21b1e8c03
commit 63867be48a
11 changed files with 172 additions and 144 deletions

View file

@ -31,28 +31,12 @@ export class WebSocketManager {
private readonly outstandingPromises: Promise<unknown>[] = [];
private webSocket: WebSocket | undefined;
private readonly webSocketFactoryImplementation: typeof globalThis.WebSocket;
public constructor(
private readonly deviceId: string,
private readonly logger: Logger,
private readonly settings: Settings,
webSocketImplementation?: typeof globalThis.WebSocket
) {
if (webSocketImplementation) {
this.webSocketFactoryImplementation = webSocketImplementation;
} else {
if (
typeof globalThis !== "undefined" &&
typeof globalThis.WebSocket === "undefined"
) {
// eslint-disable-next-line
this.webSocketFactoryImplementation = require("ws"); // polyfill for WebSocket in Node.js
} else {
this.webSocketFactoryImplementation = WebSocket;
}
}
}
private readonly webSocketFactoryImplementation: typeof globalThis.WebSocket = WebSocket
) {}
public get isWebSocketConnected(): boolean {
return (