@basmilius/apple-devices 0.0.100 → 0.0.102

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.
@@ -13,8 +13,8 @@ export default class extends EventEmitter<EventMap> {
13
13
  get isConnected(): boolean;
14
14
  constructor(discoveryResult: DiscoveryResult);
15
15
  connect(): Promise<void>;
16
- disconnect(emit?: boolean): Promise<void>;
17
- disconnectSafely(emit?: boolean): Promise<void>;
16
+ disconnect(): Promise<void>;
17
+ disconnectSafely(): Promise<void>;
18
18
  setCredentials(credentials: AccessoryCredentials): Promise<void>;
19
19
  getAttentionState(): Promise<AttentionState>;
20
20
  getLaunchableApps(): Promise<LaunchableApp[]>;
package/dist/index.js CHANGED
@@ -1568,7 +1568,6 @@ class device_default extends EventEmitter2 {
1568
1568
  clearInterval(this.#feedbackInterval);
1569
1569
  await this.#unsubscribe();
1570
1570
  await this.#protocol.disconnect();
1571
- this.emit("disconnected", false);
1572
1571
  }
1573
1572
  async disconnectSafely() {
1574
1573
  try {
@@ -1592,11 +1591,8 @@ class device_default extends EventEmitter2 {
1592
1591
  }
1593
1592
  }
1594
1593
  async#onClose() {
1595
- if (this.#disconnect) {
1596
- return;
1597
- }
1598
- clearInterval(this.#feedbackInterval);
1599
- this.emit("disconnected", true);
1594
+ await this.disconnectSafely();
1595
+ this.emit("disconnected", false);
1600
1596
  }
1601
1597
  async#onError(err) {
1602
1598
  reporter2.error("AirPlay error", err);
@@ -1704,18 +1700,15 @@ class device_default2 extends EventEmitter3 {
1704
1700
  await this.#setup();
1705
1701
  this.emit("connected");
1706
1702
  }
1707
- async disconnect(emit = true) {
1703
+ async disconnect() {
1708
1704
  this.#disconnect = true;
1709
1705
  clearInterval(this.#heartbeatInterval);
1710
1706
  await this.#unsubscribe();
1711
1707
  await this.#protocol.disconnect();
1712
- if (emit) {
1713
- this.emit("disconnected", false);
1714
- }
1715
1708
  }
1716
- async disconnectSafely(emit = true) {
1709
+ async disconnectSafely() {
1717
1710
  try {
1718
- await this.disconnect(emit);
1711
+ await this.disconnect();
1719
1712
  } catch (_) {}
1720
1713
  }
1721
1714
  async setCredentials(credentials) {
@@ -1753,20 +1746,17 @@ class device_default2 extends EventEmitter3 {
1753
1746
  }
1754
1747
  }
1755
1748
  async#onClose() {
1756
- if (this.#disconnect) {
1757
- return;
1758
- }
1759
- clearInterval(this.#heartbeatInterval);
1760
- this.emit("disconnected", true);
1749
+ await this.disconnectSafely();
1750
+ this.emit("disconnected", false);
1761
1751
  }
1762
1752
  async#onError(err) {
1763
1753
  reporter3.error("Companion Link error", err);
1764
- await this.disconnectSafely(false);
1754
+ await this.disconnectSafely();
1765
1755
  this.emit("disconnected", true);
1766
1756
  }
1767
1757
  async#onTimeout() {
1768
1758
  reporter3.error("Companion Link timeout");
1769
- await this.disconnectSafely(false);
1759
+ await this.disconnectSafely();
1770
1760
  this.emit("disconnected", true);
1771
1761
  }
1772
1762
  async#setup() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-devices",
3
3
  "description": "Exposes various Apple devices to connect with either AirPlay or Companion Link.",
4
- "version": "0.0.100",
4
+ "version": "0.0.102",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -43,10 +43,10 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@basmilius/apple-airplay": "0.0.100",
47
- "@basmilius/apple-common": "0.0.100",
48
- "@basmilius/apple-companion-link": "0.0.100",
49
- "@basmilius/apple-encoding": "0.0.100"
46
+ "@basmilius/apple-airplay": "0.0.102",
47
+ "@basmilius/apple-common": "0.0.102",
48
+ "@basmilius/apple-companion-link": "0.0.102",
49
+ "@basmilius/apple-encoding": "0.0.102"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@basmilius/tools": "^2.23.0",