@basmilius/apple-airplay 0.9.7 → 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 +3 -2
- package/dist/index.mjs +49 -33
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -10334,6 +10334,7 @@ declare namespace index_d_exports {
|
|
|
10334
10334
|
//#endregion
|
|
10335
10335
|
//#region src/dataStream.d.ts
|
|
10336
10336
|
type EventMap$1 = {
|
|
10337
|
+
readonly rawMessage: [ProtocolMessage];
|
|
10337
10338
|
readonly deviceInfo: [DeviceInfoMessage];
|
|
10338
10339
|
readonly deviceInfoUpdate: [DeviceInfoMessage];
|
|
10339
10340
|
readonly originClientProperties: [OriginClientPropertiesMessage];
|
|
@@ -10358,7 +10359,7 @@ declare class DataStream extends BaseStream<EventMap$1> {
|
|
|
10358
10359
|
#private;
|
|
10359
10360
|
constructor(context: Context, address: string, port: number);
|
|
10360
10361
|
disconnect(): Promise<void>;
|
|
10361
|
-
exchange(message: ProtocolMessage | [ProtocolMessage, DescExtension]): Promise<ProtocolMessage>;
|
|
10362
|
+
exchange(message: ProtocolMessage | [ProtocolMessage, DescExtension], timeout?: number): Promise<ProtocolMessage>;
|
|
10362
10363
|
reply(seqno: bigint): void;
|
|
10363
10364
|
send(message: ProtocolMessage | [ProtocolMessage, DescExtension]): void;
|
|
10364
10365
|
setup(sharedSecret: Buffer, seed: bigint): void;
|
|
@@ -10422,7 +10423,7 @@ declare function getState(): [ProtocolMessage, DescExtension];
|
|
|
10422
10423
|
declare function getVolume(outputDeviceUID: string): [ProtocolMessage, DescExtension];
|
|
10423
10424
|
declare function getVolumeMuted(outputDeviceUID: string): [ProtocolMessage, DescExtension];
|
|
10424
10425
|
declare function notification(notification: string): [ProtocolMessage, DescExtension];
|
|
10425
|
-
declare function playbackQueueRequest(location: number, length: number,
|
|
10426
|
+
declare function playbackQueueRequest(location: number, length: number, artworkWidth?: number, artworkHeight?: number): [ProtocolMessage, DescExtension];
|
|
10426
10427
|
declare function sendButtonEvent(usagePage: number, usage: number, buttonDown: boolean): [ProtocolMessage, DescExtension];
|
|
10427
10428
|
declare function sendCommandWithSkipInterval(command: Command, skipInterval: number): [ProtocolMessage, DescExtension];
|
|
10428
10429
|
declare function sendCommandWithPlaybackPosition(command: Command, playbackPosition: number): [ProtocolMessage, DescExtension];
|
package/dist/index.mjs
CHANGED
|
@@ -10625,15 +10625,13 @@ function buildHeader(totalSize, seqno) {
|
|
|
10625
10625
|
}
|
|
10626
10626
|
function buildReply(seqno) {
|
|
10627
10627
|
const header = Buffer.allocUnsafe(32);
|
|
10628
|
-
header.writeUInt32BE(
|
|
10628
|
+
header.writeUInt32BE(32, 0);
|
|
10629
10629
|
header.write("rply", 4, "ascii");
|
|
10630
10630
|
header.fill(0, 8, 16);
|
|
10631
|
+
header.fill(0, 16, 20);
|
|
10631
10632
|
header.writeBigUInt64BE(seqno, 20);
|
|
10632
10633
|
header.writeUInt32BE(0, 28);
|
|
10633
|
-
|
|
10634
|
-
const total = header.length + plist.length;
|
|
10635
|
-
header.writeUInt32BE(total, 0);
|
|
10636
|
-
return Buffer.concat([header, plist]);
|
|
10634
|
+
return header;
|
|
10637
10635
|
}
|
|
10638
10636
|
function encodeVarint(value) {
|
|
10639
10637
|
if (value < 0) throw new RangeError("Varint only supports non-negative integers");
|
|
@@ -10869,7 +10867,7 @@ const DATA_HEADER_LENGTH = 32;
|
|
|
10869
10867
|
var DataStream = class extends BaseStream {
|
|
10870
10868
|
#buffer = Buffer.alloc(0);
|
|
10871
10869
|
#seqno;
|
|
10872
|
-
#
|
|
10870
|
+
#outstanding = /* @__PURE__ */ new Map();
|
|
10873
10871
|
#handlers = {};
|
|
10874
10872
|
constructor(context, address, port) {
|
|
10875
10873
|
super(context, address, port);
|
|
@@ -10901,13 +10899,24 @@ var DataStream = class extends BaseStream {
|
|
|
10901
10899
|
this.#cleanup();
|
|
10902
10900
|
await super.disconnect();
|
|
10903
10901
|
}
|
|
10904
|
-
exchange(message) {
|
|
10902
|
+
exchange(message, timeout = 5e3) {
|
|
10903
|
+
let msg = Array.isArray(message) ? message[0] : message;
|
|
10904
|
+
const identifier = msg.identifier || `type_${msg.type}`;
|
|
10905
10905
|
return new Promise((resolve, reject) => {
|
|
10906
|
-
|
|
10906
|
+
const timer = setTimeout(() => {
|
|
10907
|
+
this.#outstanding.delete(identifier);
|
|
10908
|
+
reject(/* @__PURE__ */ new Error(`Exchange timed out for ${identifier}`));
|
|
10909
|
+
}, timeout);
|
|
10910
|
+
this.#outstanding.set(identifier, {
|
|
10911
|
+
resolve,
|
|
10912
|
+
reject,
|
|
10913
|
+
timer
|
|
10914
|
+
});
|
|
10907
10915
|
try {
|
|
10908
10916
|
this.send(message);
|
|
10909
10917
|
} catch (err) {
|
|
10910
|
-
this.#
|
|
10918
|
+
this.#outstanding.delete(identifier);
|
|
10919
|
+
clearTimeout(timer);
|
|
10911
10920
|
reject(err);
|
|
10912
10921
|
}
|
|
10913
10922
|
});
|
|
@@ -10952,22 +10961,22 @@ var DataStream = class extends BaseStream {
|
|
|
10952
10961
|
}
|
|
10953
10962
|
#cleanup() {
|
|
10954
10963
|
this.#buffer = Buffer.alloc(0);
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
reject(/* @__PURE__ */ new Error("Connection closed."));
|
|
10964
|
+
for (const [id, req] of this.#outstanding) {
|
|
10965
|
+
clearTimeout(req.timer);
|
|
10966
|
+
req.reject(/* @__PURE__ */ new Error("Connection closed."));
|
|
10959
10967
|
}
|
|
10968
|
+
this.#outstanding.clear();
|
|
10960
10969
|
}
|
|
10961
10970
|
#onClose() {
|
|
10962
10971
|
this.#cleanup();
|
|
10963
10972
|
}
|
|
10964
10973
|
#onError(err) {
|
|
10965
10974
|
this.context.logger.error("[data]", "#onError()", err);
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
reject(err);
|
|
10975
|
+
for (const [id, req] of this.#outstanding) {
|
|
10976
|
+
clearTimeout(req.timer);
|
|
10977
|
+
req.reject(err);
|
|
10970
10978
|
}
|
|
10979
|
+
this.#outstanding.clear();
|
|
10971
10980
|
}
|
|
10972
10981
|
async #onData(data) {
|
|
10973
10982
|
try {
|
|
@@ -10989,13 +10998,16 @@ var DataStream = class extends BaseStream {
|
|
|
10989
10998
|
const command = header.toString("ascii", 4, 8);
|
|
10990
10999
|
this.#buffer = this.#buffer.subarray(totalLength);
|
|
10991
11000
|
if (!plist || !plist.params || !plist.params.data) {
|
|
10992
|
-
if (command === "rply")
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
|
|
11001
|
+
if (command === "rply") {
|
|
11002
|
+
this.context.logger.raw("[data]", "Received reply packet.");
|
|
11003
|
+
const first = this.#outstanding.entries().next();
|
|
11004
|
+
if (!first.done) {
|
|
11005
|
+
const [id, req] = first.value;
|
|
11006
|
+
this.#outstanding.delete(id);
|
|
11007
|
+
clearTimeout(req.timer);
|
|
11008
|
+
req.resolve(void 0);
|
|
11009
|
+
}
|
|
11010
|
+
} else if (command === "sync") this.reply(parseHeaderSeqno(header));
|
|
10999
11011
|
continue;
|
|
11000
11012
|
}
|
|
11001
11013
|
const content = Buffer.from(plist.params.data);
|
|
@@ -11011,10 +11023,13 @@ var DataStream = class extends BaseStream {
|
|
|
11011
11023
|
}
|
|
11012
11024
|
}
|
|
11013
11025
|
#handleMessage(message) {
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11026
|
+
this.emit("rawMessage", message);
|
|
11027
|
+
const identifier = message.identifier || `type_${message.type}`;
|
|
11028
|
+
const outstanding = this.#outstanding.get(identifier);
|
|
11029
|
+
if (outstanding) {
|
|
11030
|
+
this.#outstanding.delete(identifier);
|
|
11031
|
+
clearTimeout(outstanding.timer);
|
|
11032
|
+
outstanding.resolve(message);
|
|
11018
11033
|
}
|
|
11019
11034
|
if (message.type in this.#handlers) {
|
|
11020
11035
|
const [extension, handler] = this.#handlers[message.type];
|
|
@@ -11647,15 +11662,16 @@ function notification(notification) {
|
|
|
11647
11662
|
setExtension(protocolMessage, notificationMessage, message);
|
|
11648
11663
|
return [protocolMessage, notificationMessage];
|
|
11649
11664
|
}
|
|
11650
|
-
function playbackQueueRequest(location, length,
|
|
11665
|
+
function playbackQueueRequest(location, length, artworkWidth = 600, artworkHeight = -1) {
|
|
11651
11666
|
const protocolMessage = protocol(ProtocolMessage_Type.PLAYBACK_QUEUE_REQUEST_MESSAGE);
|
|
11652
11667
|
const message = create(PlaybackQueueRequestMessageSchema, {
|
|
11653
11668
|
location,
|
|
11654
11669
|
length,
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11670
|
+
artworkWidth,
|
|
11671
|
+
artworkHeight,
|
|
11672
|
+
returnContentItemAssetsInUserCompletion: true,
|
|
11673
|
+
includeMetadata: true,
|
|
11674
|
+
includeLanguageOptions: false,
|
|
11659
11675
|
includeInfo: true,
|
|
11660
11676
|
includeLyrics: true,
|
|
11661
11677
|
includeSections: true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/apple-airplay",
|
|
3
3
|
"description": "Implementation of Apple's AirPlay2 in Node.js.",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@basmilius/apple-common": "0.9.
|
|
52
|
-
"@basmilius/apple-encoding": "0.9.
|
|
53
|
-
"@basmilius/apple-encryption": "0.9.
|
|
51
|
+
"@basmilius/apple-common": "0.9.9",
|
|
52
|
+
"@basmilius/apple-encoding": "0.9.9",
|
|
53
|
+
"@basmilius/apple-encryption": "0.9.9"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@bufbuild/buf": "^1.66.0",
|