@basmilius/apple-common 0.6.11 → 0.7.0

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.
@@ -22,7 +22,7 @@ export declare class Connection<TEventMap extends EventMap> extends EventEmitter
22
22
  disconnect(): Promise<void>;
23
23
  debug(enabled: boolean): this;
24
24
  retry(attempts: number, interval?: number): this;
25
- write(data: Buffer | Uint8Array): Promise<void>;
25
+ write(data: Buffer | Uint8Array): void;
26
26
  }
27
27
  export declare class EncryptionAwareConnection<TEventMap extends EventMap> extends Connection<TEventMap> {
28
28
  get isEncrypted(): boolean;
package/dist/index.js CHANGED
@@ -264,17 +264,17 @@ class Connection extends EventEmitter {
264
264
  this.#retryInterval = interval;
265
265
  return this;
266
266
  }
267
- async write(data) {
267
+ write(data) {
268
268
  if (!this.#socket || this.state !== "connected" || !this.#socket.writable) {
269
269
  this.emit("error", new Error("Cannot write to a disconnected connection."));
270
270
  return;
271
271
  }
272
- return new Promise((resolve, reject) => {
273
- try {
274
- this.#socket.write(data, (err) => err ? reject(err) : resolve());
275
- } catch (err) {
276
- reject(err);
272
+ this.#socket.write(data, (err) => {
273
+ if (!err) {
274
+ return;
277
275
  }
276
+ this.#context.logger.error("Failed to write data to socket.");
277
+ this.emit("error", err);
278
278
  });
279
279
  }
280
280
  async#attemptConnect() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-common",
3
3
  "description": "Common features shared across various apple protocol packages.",
4
- "version": "0.6.11",
4
+ "version": "0.7.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -39,14 +39,14 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@basmilius/apple-encoding": "0.6.11",
43
- "@basmilius/apple-encryption": "0.6.11",
42
+ "@basmilius/apple-encoding": "0.7.0",
43
+ "@basmilius/apple-encryption": "0.7.0",
44
44
  "fast-srp-hap": "^2.0.4",
45
45
  "node-dns-sd": "^1.0.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@basmilius/tools": "^2.24.0",
49
- "@types/bun": "^1.3.8",
48
+ "@basmilius/tools": "^2.25.0",
49
+ "@types/bun": "^1.3.9",
50
50
  "uuid": "^13.0.0"
51
51
  }
52
52
  }