diff --git a/package-lock.json b/package-lock.json index 5bb2375e2..5fcb9f3de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,6 +64,7 @@ "@sinonjs/fake-timers": "^10.0.2", "@types/b4a": "^1.6.0", "@types/bogon": "^1.0.2", + "@types/compact-encoding": "^2.15.0", "@types/debug": "^4.1.8", "@types/json-schema": "^7.0.11", "@types/json-stable-stringify": "^1.0.36", @@ -1217,6 +1218,13 @@ "integrity": "sha512-R7YtCuBSS16AfLJttU/WxFzEC/rlPxUrdfyHkE/VcIybpC1nXftIg1eaFWx0PpV1ZBF/COjTgwRXprUsNew0ng==", "dev": true }, + "node_modules/@types/compact-encoding": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@types/compact-encoding/-/compact-encoding-2.15.0.tgz", + "integrity": "sha512-NmvvYrQC9QqbbEfm6ISHfCvvfQIwq53B4hZ7aAP6mEXsPc2F15Lkxj+jGzqVeKTT+Ir0HXAj4O9YUDsIpJbOuA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/debug": { "version": "4.1.8", "dev": true, diff --git a/package.json b/package.json index 769ca50de..f06c1b97b 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "@sinonjs/fake-timers": "^10.0.2", "@types/b4a": "^1.6.0", "@types/bogon": "^1.0.2", + "@types/compact-encoding": "^2.15.0", "@types/debug": "^4.1.8", "@types/json-schema": "^7.0.11", "@types/json-stable-stringify": "^1.0.36", diff --git a/types/compact-encoding.d.ts b/types/compact-encoding.d.ts deleted file mode 100644 index 5d9a8553f..000000000 --- a/types/compact-encoding.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'compact-encoding' diff --git a/types/protomux.d.ts b/types/protomux.d.ts index 5930dcd70..f4b3e9bea 100644 --- a/types/protomux.d.ts +++ b/types/protomux.d.ts @@ -1,30 +1,13 @@ declare module 'protomux' { import { Duplex } from 'streamx' import { Duplex as NodeDuplex } from 'stream' - - interface PreEncodingState { - buffer: null - start: number - end: number - } - - interface EncodingState { - buffer: null | Buffer - start: number - end: number - } - - interface Encoding { - preencode(state: PreEncodingState, value: any): void - encode(state: EncodingState, value: any): void - decode(state: EncodingState): any - } + import type cenc from 'compact-encoding' interface Message { type: number send(msg: any): void onmessage: (message: any) => void - encoding: Encoding + encoding: cenc.Encoder } type MessageOptions = Partial> @@ -65,7 +48,7 @@ declare module 'protomux' { aliases?: string[] id?: null | Buffer unique?: boolean - handshake?: Encoding + handshake?: cenc.Encoder messages: MessageOptions[] onopen?(handshake?: any): Promise | void onclose?(): Promise | void