@basmilius/apple-devices 0.9.16 → 0.9.17
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.mjs +26 -25
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -87,8 +87,8 @@ var Player = class {
|
|
|
87
87
|
get elapsedTime() {
|
|
88
88
|
const npi = this.#nowPlayingInfo;
|
|
89
89
|
const meta = this.currentItemMetadata;
|
|
90
|
-
const npiValid = npi?.elapsedTime != null && npi.timestamp;
|
|
91
|
-
const metaValid = meta?.elapsedTime != null && meta.elapsedTimeTimestamp;
|
|
90
|
+
const npiValid = npi?.elapsedTime != null && npi.timestamp != null && npi.timestamp !== 0;
|
|
91
|
+
const metaValid = meta?.elapsedTime != null && meta.elapsedTimeTimestamp != null && meta.elapsedTimeTimestamp !== 0;
|
|
92
92
|
if (npiValid && metaValid) {
|
|
93
93
|
if (meta.elapsedTimeTimestamp > npi.timestamp) return extrapolateElapsed(meta.elapsedTime, meta.elapsedTimeTimestamp, meta.playbackRate);
|
|
94
94
|
return extrapolateElapsed(npi.elapsedTime, npi.timestamp, npi.playbackRate);
|
|
@@ -131,11 +131,7 @@ var Player = class {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
get currentItemArtworkUrl() {
|
|
134
|
-
|
|
135
|
-
if (metadata?.artworkURL) return metadata.artworkURL;
|
|
136
|
-
const item = this.currentItem;
|
|
137
|
-
if (item?.remoteArtworks.length > 0 && item.remoteArtworks[0].artworkURLString) return item.remoteArtworks[0].artworkURLString;
|
|
138
|
-
return null;
|
|
134
|
+
return this.artworkUrl();
|
|
139
135
|
}
|
|
140
136
|
get currentItemLyrics() {
|
|
141
137
|
return this.currentItem?.lyrics ?? null;
|
|
@@ -199,8 +195,7 @@ var Client = class {
|
|
|
199
195
|
return this.#players;
|
|
200
196
|
}
|
|
201
197
|
get activePlayer() {
|
|
202
|
-
|
|
203
|
-
return this.#players.get("MediaRemote-DefaultPlayer") ?? null;
|
|
198
|
+
return this.#players.get(this.#activePlayerId ?? "MediaRemote-DefaultPlayer") ?? null;
|
|
204
199
|
}
|
|
205
200
|
get nowPlayingInfo() {
|
|
206
201
|
return this.activePlayer?.nowPlayingInfo ?? null;
|
|
@@ -668,15 +663,11 @@ var state_default = class extends EventEmitter {
|
|
|
668
663
|
this.#volumeCapabilities = Proto.VolumeCapabilities_Enum.None;
|
|
669
664
|
}
|
|
670
665
|
onDeviceInfo(message) {
|
|
671
|
-
|
|
672
|
-
else if (message.deviceUID) this.#outputDeviceUID = message.deviceUID;
|
|
673
|
-
else if (message.uniqueIdentifier) this.#outputDeviceUID = message.uniqueIdentifier;
|
|
666
|
+
this.#updateOutputDeviceUID(message);
|
|
674
667
|
this.emit("deviceInfo", message);
|
|
675
668
|
}
|
|
676
669
|
onDeviceInfoUpdate(message) {
|
|
677
|
-
|
|
678
|
-
else if (message.deviceUID) this.#outputDeviceUID = message.deviceUID;
|
|
679
|
-
else if (message.uniqueIdentifier) this.#outputDeviceUID = message.uniqueIdentifier;
|
|
670
|
+
this.#updateOutputDeviceUID(message);
|
|
680
671
|
this.emit("deviceInfoUpdate", message);
|
|
681
672
|
}
|
|
682
673
|
onOriginClientProperties(message) {
|
|
@@ -777,6 +768,9 @@ var state_default = class extends EventEmitter {
|
|
|
777
768
|
this.#volume = message.volume;
|
|
778
769
|
this.emit("volumeDidChange", message.volume);
|
|
779
770
|
}
|
|
771
|
+
#updateOutputDeviceUID(message) {
|
|
772
|
+
this.#outputDeviceUID = message.clusterID || message.deviceUID || message.uniqueIdentifier || null;
|
|
773
|
+
}
|
|
780
774
|
#client(bundleIdentifier, displayName) {
|
|
781
775
|
if (bundleIdentifier in this.#clients) {
|
|
782
776
|
const client = this.#clients[bundleIdentifier];
|
|
@@ -956,7 +950,9 @@ var device_default = class extends EventEmitter {
|
|
|
956
950
|
disconnectSafely() {
|
|
957
951
|
try {
|
|
958
952
|
this.disconnect();
|
|
959
|
-
} catch (
|
|
953
|
+
} catch (err) {
|
|
954
|
+
this.#protocol?.context?.logger?.warn("[device]", "Error during safe disconnect", err);
|
|
955
|
+
}
|
|
960
956
|
}
|
|
961
957
|
async addOutputDevices(deviceUIDs) {
|
|
962
958
|
await this.#protocol.dataStream.exchange(DataStreamMessage.modifyOutputContext(deviceUIDs));
|
|
@@ -1005,21 +1001,26 @@ var device_default = class extends EventEmitter {
|
|
|
1005
1001
|
this.#protocol.controlStream.enableEncryption(keys.accessoryToControllerKey, keys.controllerToAccessoryKey);
|
|
1006
1002
|
this.#unsubscribe();
|
|
1007
1003
|
if (this.#timingServer) this.#protocol.useTimingServer(this.#timingServer);
|
|
1008
|
-
await this.#protocol.setupEventStream(keys.sharedSecret, keys.pairingId);
|
|
1009
|
-
await this.#protocol.setupDataStream(keys.sharedSecret, () => this.#subscribe());
|
|
1010
|
-
this.#protocol.dataStream.on("error", this.#onError.bind(this));
|
|
1011
|
-
this.#protocol.dataStream.on("timeout", this.#onTimeout.bind(this));
|
|
1012
|
-
this.#protocol.eventStream.on("error", this.#onError.bind(this));
|
|
1013
|
-
this.#protocol.eventStream.on("timeout", this.#onTimeout.bind(this));
|
|
1014
|
-
this.#feedbackInterval = setInterval(async () => await this.#feedback(), FEEDBACK_INTERVAL);
|
|
1015
1004
|
try {
|
|
1005
|
+
await this.#protocol.setupEventStream(keys.sharedSecret, keys.pairingId);
|
|
1006
|
+
await this.#protocol.setupDataStream(keys.sharedSecret, () => this.#subscribe());
|
|
1007
|
+
this.#protocol.dataStream.on("error", this.#onError.bind(this));
|
|
1008
|
+
this.#protocol.dataStream.on("timeout", this.#onTimeout.bind(this));
|
|
1009
|
+
this.#protocol.eventStream.on("error", this.#onError.bind(this));
|
|
1010
|
+
this.#protocol.eventStream.on("timeout", this.#onTimeout.bind(this));
|
|
1011
|
+
if (this.#feedbackInterval) clearInterval(this.#feedbackInterval);
|
|
1012
|
+
this.#feedbackInterval = setInterval(async () => await this.#feedback(), FEEDBACK_INTERVAL);
|
|
1016
1013
|
await this.#protocol.dataStream.exchange(DataStreamMessage.deviceInfo(keys.pairingId));
|
|
1017
1014
|
await this.#protocol.dataStream.exchange(DataStreamMessage.setConnectionState());
|
|
1018
1015
|
await this.#protocol.dataStream.exchange(DataStreamMessage.clientUpdatesConfig());
|
|
1019
1016
|
this.#protocol.context.logger.info("Protocol ready.");
|
|
1020
1017
|
} catch (err) {
|
|
1021
|
-
|
|
1022
|
-
|
|
1018
|
+
if (this.#feedbackInterval) {
|
|
1019
|
+
clearInterval(this.#feedbackInterval);
|
|
1020
|
+
this.#feedbackInterval = void 0;
|
|
1021
|
+
}
|
|
1022
|
+
this.#protocol.context.logger.error("[device]", "Setup failed, cleaning up", err);
|
|
1023
|
+
this.#protocol.disconnect();
|
|
1023
1024
|
throw err;
|
|
1024
1025
|
}
|
|
1025
1026
|
}
|
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.9.
|
|
4
|
+
"version": "0.9.17",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@basmilius/apple-airplay": "0.9.
|
|
53
|
-
"@basmilius/apple-common": "0.9.
|
|
54
|
-
"@basmilius/apple-companion-link": "0.9.
|
|
55
|
-
"@basmilius/apple-encoding": "0.9.
|
|
52
|
+
"@basmilius/apple-airplay": "0.9.17",
|
|
53
|
+
"@basmilius/apple-common": "0.9.17",
|
|
54
|
+
"@basmilius/apple-companion-link": "0.9.17",
|
|
55
|
+
"@basmilius/apple-encoding": "0.9.17"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/bun": "^1.3.11",
|