@basmilius/apple-devices 0.9.8 → 0.9.9
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 +6 -0
- package/dist/index.mjs +33 -19
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,12 @@ declare class Client {
|
|
|
18
18
|
get title(): string;
|
|
19
19
|
get artist(): string;
|
|
20
20
|
get album(): string;
|
|
21
|
+
get genre(): string;
|
|
22
|
+
get seriesName(): string;
|
|
23
|
+
get seasonNumber(): number;
|
|
24
|
+
get episodeNumber(): number;
|
|
25
|
+
get mediaType(): Proto.ContentItemMetadata_MediaType;
|
|
26
|
+
get contentIdentifier(): string;
|
|
21
27
|
get duration(): number;
|
|
22
28
|
get playbackRate(): number;
|
|
23
29
|
get isPlaying(): boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1964,6 +1964,24 @@ var Client = class {
|
|
|
1964
1964
|
get album() {
|
|
1965
1965
|
return this.#nowPlayingInfo?.album || this.currentItemMetadata?.albumName || "";
|
|
1966
1966
|
}
|
|
1967
|
+
get genre() {
|
|
1968
|
+
return this.currentItemMetadata?.genre || "";
|
|
1969
|
+
}
|
|
1970
|
+
get seriesName() {
|
|
1971
|
+
return this.currentItemMetadata?.seriesName || "";
|
|
1972
|
+
}
|
|
1973
|
+
get seasonNumber() {
|
|
1974
|
+
return this.currentItemMetadata?.seasonNumber || 0;
|
|
1975
|
+
}
|
|
1976
|
+
get episodeNumber() {
|
|
1977
|
+
return this.currentItemMetadata?.episodeNumber || 0;
|
|
1978
|
+
}
|
|
1979
|
+
get mediaType() {
|
|
1980
|
+
return this.currentItemMetadata?.mediaType ?? Proto.ContentItemMetadata_MediaType.UnknownMediaType;
|
|
1981
|
+
}
|
|
1982
|
+
get contentIdentifier() {
|
|
1983
|
+
return this.currentItemMetadata?.contentIdentifier || "";
|
|
1984
|
+
}
|
|
1967
1985
|
get duration() {
|
|
1968
1986
|
return this.#nowPlayingInfo?.duration || this.currentItemMetadata?.duration || 0;
|
|
1969
1987
|
}
|
|
@@ -1982,8 +2000,14 @@ var Client = class {
|
|
|
1982
2000
|
get elapsedTime() {
|
|
1983
2001
|
const npi = this.#nowPlayingInfo;
|
|
1984
2002
|
const meta = this.currentItemMetadata;
|
|
1985
|
-
|
|
1986
|
-
|
|
2003
|
+
const npiValid = npi?.elapsedTime != null && npi.timestamp;
|
|
2004
|
+
const metaValid = meta?.elapsedTime != null && meta.elapsedTimeTimestamp;
|
|
2005
|
+
if (npiValid && metaValid) {
|
|
2006
|
+
if (meta.elapsedTimeTimestamp > npi.timestamp) return extrapolateElapsed(meta.elapsedTime, meta.elapsedTimeTimestamp, meta.playbackRate ?? npi.playbackRate, this.isPlaying);
|
|
2007
|
+
return extrapolateElapsed(npi.elapsedTime, npi.timestamp, npi.playbackRate, this.isPlaying);
|
|
2008
|
+
}
|
|
2009
|
+
if (npiValid) return extrapolateElapsed(npi.elapsedTime, npi.timestamp, npi.playbackRate, this.isPlaying);
|
|
2010
|
+
if (metaValid) return extrapolateElapsed(meta.elapsedTime, meta.elapsedTimeTimestamp, meta.playbackRate, this.isPlaying);
|
|
1987
2011
|
return npi?.elapsedTime || meta?.elapsedTime || 0;
|
|
1988
2012
|
}
|
|
1989
2013
|
get currentItem() {
|
|
@@ -2609,22 +2633,10 @@ var device_default = class extends EventEmitter {
|
|
|
2609
2633
|
this.#protocol.eventStream.on("timeout", this.#onTimeout.bind(this));
|
|
2610
2634
|
this.#feedbackInterval = setInterval(async () => await this.#feedback(), FEEDBACK_INTERVAL);
|
|
2611
2635
|
try {
|
|
2612
|
-
await this.#protocol.dataStream.exchange(DataStreamMessage.
|
|
2613
|
-
await
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
if (!await Promise.race([new Promise(async (resolve) => {
|
|
2617
|
-
this.#protocol.dataStream.once("deviceInfo", async () => {
|
|
2618
|
-
await this.#protocol.dataStream.exchange(DataStreamMessage.setConnectionState());
|
|
2619
|
-
await this.#protocol.dataStream.exchange(DataStreamMessage.clientUpdatesConfig());
|
|
2620
|
-
resolve(true);
|
|
2621
|
-
});
|
|
2622
|
-
await this.#protocol.dataStream.exchange(DataStreamMessage.deviceInfo(keys.pairingId));
|
|
2623
|
-
}), async () => {
|
|
2624
|
-
await waitFor(3e3);
|
|
2625
|
-
return false;
|
|
2626
|
-
}])) this.#onError(/* @__PURE__ */ new Error("Device did not respond in time with its info."));
|
|
2627
|
-
else this.#protocol.context.logger.info("Device info received successfully, protocol should be ready.");
|
|
2636
|
+
await this.#protocol.dataStream.exchange(DataStreamMessage.deviceInfo(keys.pairingId));
|
|
2637
|
+
await this.#protocol.dataStream.exchange(DataStreamMessage.setConnectionState());
|
|
2638
|
+
await this.#protocol.dataStream.exchange(DataStreamMessage.clientUpdatesConfig());
|
|
2639
|
+
this.#protocol.context.logger.info("Protocol ready.");
|
|
2628
2640
|
} catch (err) {
|
|
2629
2641
|
clearInterval(this.#feedbackInterval);
|
|
2630
2642
|
this.#feedbackInterval = void 0;
|
|
@@ -2757,7 +2769,9 @@ var device_default$1 = class extends EventEmitter {
|
|
|
2757
2769
|
await this.#protocol.tvrcSessionStart();
|
|
2758
2770
|
await this.#protocol.touchStart();
|
|
2759
2771
|
await this.#protocol.tiStart();
|
|
2760
|
-
await this.#protocol.
|
|
2772
|
+
await this.#protocol.subscribe("_iMC", (data) => {
|
|
2773
|
+
this.emit("mediaControl", data);
|
|
2774
|
+
});
|
|
2761
2775
|
this.#heartbeatInterval = setInterval(async () => await this.#heartbeat(), 15e3);
|
|
2762
2776
|
await this.#subscribe();
|
|
2763
2777
|
} catch (err) {
|
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.9",
|
|
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.9",
|
|
53
|
+
"@basmilius/apple-common": "0.9.9",
|
|
54
|
+
"@basmilius/apple-companion-link": "0.9.9",
|
|
55
|
+
"@basmilius/apple-encoding": "0.9.9"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/bun": "^1.3.9",
|