@basmilius/apple-companion-link 0.6.4 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -207,6 +207,10 @@ class Stream extends EncryptionAwareConnection {
207
207
  this.on("data", this.#onData.bind(this));
208
208
  this.on("error", this.#onError.bind(this));
209
209
  }
210
+ async disconnect() {
211
+ this.#cleanup();
212
+ await super.disconnect();
213
+ }
210
214
  async exchange(type, obj) {
211
215
  const _x = this.#xid;
212
216
  return new Promise((resolve, reject) => {
@@ -246,12 +250,21 @@ class Stream extends EncryptionAwareConnection {
246
250
  this.emit("error", err);
247
251
  }
248
252
  }
253
+ #cleanup() {
254
+ this.#buffer = Buffer.alloc(0);
255
+ const error = new Error("Stream cleanup");
256
+ for (const [, reject] of this.#queue.values()) {
257
+ reject(error);
258
+ }
259
+ this.#queue.clear();
260
+ }
249
261
  #onClose() {
250
262
  const error = new Error("Connection closed while waiting for response");
251
263
  for (const [, reject] of this.#queue.values()) {
252
264
  reject(error);
253
265
  }
254
266
  this.#queue.clear();
267
+ this.#cleanup();
255
268
  }
256
269
  async#onData(data) {
257
270
  this.#buffer = Buffer.concat([this.#buffer, data]);
package/dist/stream.d.ts CHANGED
@@ -2,6 +2,7 @@ import { type Context, EncryptionAwareConnection } from "@basmilius/apple-common
2
2
  export default class Stream extends EncryptionAwareConnection<Record<string, [unknown]>> {
3
3
  #private;
4
4
  constructor(context: Context, address: string, port: number);
5
+ disconnect(): Promise<void>;
5
6
  exchange(type: number, obj: Record<string, unknown>): Promise<[number, unknown]>;
6
7
  send(type: number, obj: Record<string, unknown>): Promise<void>;
7
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-companion-link",
3
3
  "description": "Implementation of Apple's Companion Link in Node.js.",
4
- "version": "0.6.4",
4
+ "version": "0.6.6",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -40,9 +40,9 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "@basmilius/apple-common": "0.6.4",
44
- "@basmilius/apple-encoding": "0.6.4",
45
- "@basmilius/apple-encryption": "0.6.4"
43
+ "@basmilius/apple-common": "0.6.6",
44
+ "@basmilius/apple-encoding": "0.6.6",
45
+ "@basmilius/apple-encryption": "0.6.6"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@basmilius/tools": "^2.24.0",