@basmilius/apple-sdk 0.13.3 → 0.13.4

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.d.mts CHANGED
@@ -1327,11 +1327,21 @@ declare class AirPlayManager extends EventEmitter<EventMap$2> {
1327
1327
  */
1328
1328
  onClose(): void;
1329
1329
  /**
1330
- * Handles stream error events by logging them.
1330
+ * Handles control stream error events by logging them.
1331
+ * Control stream errors are non-fatal by themselves; the 'close' event
1332
+ * that follows will trigger disconnect.
1331
1333
  *
1332
1334
  * @param err - The error that occurred.
1333
1335
  */
1334
1336
  onError(err: Error): void;
1337
+ /**
1338
+ * Handles data/event stream error events by tearing down the connection.
1339
+ * These streams are critical for state tracking; if they fail, the device
1340
+ * is effectively unreachable and a full reconnect is needed.
1341
+ *
1342
+ * @param err - The error that occurred.
1343
+ */
1344
+ onStreamError(err: Error): void;
1335
1345
  /**
1336
1346
  * Handles now-playing changes to auto-fetch artwork on track changes.
1337
1347
  */
package/dist/index.mjs CHANGED
@@ -3087,6 +3087,7 @@ var AirPlayManager = class extends EventEmitter {
3087
3087
  this.#state = new AirPlayState(this);
3088
3088
  this.onClose = this.onClose.bind(this);
3089
3089
  this.onError = this.onError.bind(this);
3090
+ this.onStreamError = this.onStreamError.bind(this);
3090
3091
  this.onNowPlayingChanged = this.onNowPlayingChanged.bind(this);
3091
3092
  this.onTimeout = this.onTimeout.bind(this);
3092
3093
  this.#volume = new AirPlayVolume(this);
@@ -3130,9 +3131,9 @@ var AirPlayManager = class extends EventEmitter {
3130
3131
  clearInterval(this.#feedbackInterval);
3131
3132
  this.#feedbackInterval = void 0;
3132
3133
  }
3133
- this.#prevDataStream?.off("error", this.onError);
3134
+ this.#prevDataStream?.off("error", this.onStreamError);
3134
3135
  this.#prevDataStream?.off("timeout", this.onTimeout);
3135
- this.#prevEventStream?.off("error", this.onError);
3136
+ this.#prevEventStream?.off("error", this.onStreamError);
3136
3137
  this.#prevEventStream?.off("timeout", this.onTimeout);
3137
3138
  this.#prevDataStream = void 0;
3138
3139
  this.#prevEventStream = void 0;
@@ -3380,7 +3381,9 @@ var AirPlayManager = class extends EventEmitter {
3380
3381
  this.emit("disconnected", true);
3381
3382
  }
3382
3383
  /**
3383
- * Handles stream error events by logging them.
3384
+ * Handles control stream error events by logging them.
3385
+ * Control stream errors are non-fatal by themselves; the 'close' event
3386
+ * that follows will trigger disconnect.
3384
3387
  *
3385
3388
  * @param err - The error that occurred.
3386
3389
  */
@@ -3388,6 +3391,17 @@ var AirPlayManager = class extends EventEmitter {
3388
3391
  this.#protocol.context.logger.error("AirPlay error", err);
3389
3392
  }
3390
3393
  /**
3394
+ * Handles data/event stream error events by tearing down the connection.
3395
+ * These streams are critical for state tracking; if they fail, the device
3396
+ * is effectively unreachable and a full reconnect is needed.
3397
+ *
3398
+ * @param err - The error that occurred.
3399
+ */
3400
+ onStreamError(err) {
3401
+ this.#protocol.context.logger.error("AirPlay stream error", err);
3402
+ this.#protocol.controlStream.destroy();
3403
+ }
3404
+ /**
3391
3405
  * Handles now-playing changes to auto-fetch artwork on track changes.
3392
3406
  */
3393
3407
  onNowPlayingChanged(_client, player) {
@@ -3414,15 +3428,15 @@ var AirPlayManager = class extends EventEmitter {
3414
3428
  this.#unsubscribe();
3415
3429
  if (this.#timingServer) this.#protocol.useTimingServer(this.#timingServer);
3416
3430
  try {
3417
- this.#prevDataStream?.off("error", this.onError);
3431
+ this.#prevDataStream?.off("error", this.onStreamError);
3418
3432
  this.#prevDataStream?.off("timeout", this.onTimeout);
3419
- this.#prevEventStream?.off("error", this.onError);
3433
+ this.#prevEventStream?.off("error", this.onStreamError);
3420
3434
  this.#prevEventStream?.off("timeout", this.onTimeout);
3421
3435
  await this.#protocol.setupEventStream(keys.sharedSecret, keys.pairingId);
3422
3436
  await this.#protocol.setupDataStream(keys.sharedSecret, () => this.#subscribe());
3423
- this.#protocol.dataStream.on("error", this.onError);
3437
+ this.#protocol.dataStream.on("error", this.onStreamError);
3424
3438
  this.#protocol.dataStream.on("timeout", this.onTimeout);
3425
- this.#protocol.eventStream.on("error", this.onError);
3439
+ this.#protocol.eventStream.on("error", this.onStreamError);
3426
3440
  this.#protocol.eventStream.on("timeout", this.onTimeout);
3427
3441
  this.#prevDataStream = this.#protocol.dataStream;
3428
3442
  this.#prevEventStream = this.#protocol.eventStream;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-sdk",
3
3
  "description": "High-level SDK for controlling Apple devices (Apple TV, HomePod) via AirPlay and Companion Link.",
4
- "version": "0.13.3",
4
+ "version": "0.13.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -45,11 +45,11 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@basmilius/apple-airplay": "0.13.3",
49
- "@basmilius/apple-common": "0.13.3",
50
- "@basmilius/apple-companion-link": "0.13.3",
51
- "@basmilius/apple-encoding": "0.13.3",
52
- "@basmilius/apple-raop": "0.13.3"
48
+ "@basmilius/apple-airplay": "0.13.4",
49
+ "@basmilius/apple-common": "0.13.4",
50
+ "@basmilius/apple-companion-link": "0.13.4",
51
+ "@basmilius/apple-encoding": "0.13.4",
52
+ "@basmilius/apple-raop": "0.13.4"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/bun": "^1.3.11",