@basmilius/apple-sdk 0.11.0

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.
@@ -0,0 +1,2583 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "node:events";
3
+ import * as _$_basmilius_apple_common0 from "@basmilius/apple-common";
4
+ import { AccessoryCredentials, AccessoryCredentials as AccessoryCredentials$1, AudioSource, CommandError, DeviceIdentity, DiscoveryResult, DiscoveryResult as DiscoveryResult$1, Storage, TimingServer, TimingServer as TimingServer$1 } from "@basmilius/apple-common";
5
+ import { Proto, Proto as Proto$1, Protocol } from "@basmilius/apple-airplay";
6
+ import { AttentionState, AttentionState as AttentionState$1, ButtonPressType, HidCommandKey, LaunchableApp, MediaControlCommandKey, Protocol as Protocol$1, TextInputState, TextInputState as TextInputState$1, UserAccount } from "@basmilius/apple-companion-link";
7
+
8
+ //#region src/internal/airplay-remote.d.ts
9
+ /**
10
+ * Error thrown when a SendCommand request fails on the Apple TV side.
11
+ * Contains the specific send error and handler return status for diagnostics.
12
+ */
13
+ declare class SendCommandError extends CommandError {
14
+ /**
15
+ * The send error reported by the Apple TV.
16
+ */
17
+ readonly sendError: Proto$1.SendError_Enum;
18
+ /**
19
+ * The handler return status reported by the Apple TV.
20
+ */
21
+ readonly handlerReturnStatus: Proto$1.HandlerReturnStatus_Enum;
22
+ /**
23
+ * Creates a new SendCommandError.
24
+ *
25
+ * @param sendError - The send error code from the Apple TV.
26
+ * @param handlerReturnStatus - The handler return status from the Apple TV.
27
+ */
28
+ constructor(sendError: Proto$1.SendError_Enum, handlerReturnStatus: Proto$1.HandlerReturnStatus_Enum);
29
+ }
30
+ /**
31
+ * Remote control for an AirPlay device.
32
+ * Provides HID-based navigation and media keys (USB usage pages: Generic Desktop 0x01
33
+ * and Consumer 0x0c), SendCommand-based media controls, keyboard/text input,
34
+ * and touch/gesture simulation.
35
+ */
36
+ declare class AirPlayRemote {
37
+ #private;
38
+ /**
39
+ * Creates a new Remote controller.
40
+ *
41
+ * @param device - The AirPlay device to control.
42
+ */
43
+ constructor(device: AirPlayManager);
44
+ /**
45
+ * Sends an Up navigation key press (Generic Desktop, usage 0x8C).
46
+ */
47
+ up(): Promise<void>;
48
+ /**
49
+ * Sends a Down navigation key press (Generic Desktop, usage 0x8D).
50
+ */
51
+ down(): Promise<void>;
52
+ /**
53
+ * Sends a Left navigation key press (Generic Desktop, usage 0x8B).
54
+ */
55
+ left(): Promise<void>;
56
+ /**
57
+ * Sends a Right navigation key press (Generic Desktop, usage 0x8A).
58
+ */
59
+ right(): Promise<void>;
60
+ /**
61
+ * Sends a Menu key press (Generic Desktop, usage 0x86).
62
+ */
63
+ menu(): Promise<void>;
64
+ /**
65
+ * Sends a Select/Enter key press (Generic Desktop, usage 0x89).
66
+ */
67
+ select(): Promise<void>;
68
+ /**
69
+ * Sends a Home button press (Consumer, usage 0x40).
70
+ */
71
+ home(): Promise<void>;
72
+ /**
73
+ * Sends a Suspend/Sleep key press to put the device to sleep (Generic Desktop, usage 0x82).
74
+ */
75
+ suspend(): Promise<void>;
76
+ /**
77
+ * Sends a Wake key press to wake the device (Generic Desktop, usage 0x83).
78
+ */
79
+ wake(): Promise<void>;
80
+ /**
81
+ * Sends a Play key press (Consumer, usage 0xB0).
82
+ */
83
+ play(): Promise<void>;
84
+ /**
85
+ * Sends a Pause key press (Consumer, usage 0xB1).
86
+ */
87
+ pause(): Promise<void>;
88
+ /**
89
+ * Toggles play/pause based on the current playback state.
90
+ */
91
+ playPause(): Promise<void>;
92
+ /**
93
+ * Sends a Stop key press (Consumer, usage 0xB7).
94
+ */
95
+ stop(): Promise<void>;
96
+ /**
97
+ * Sends a Next Track key press (Consumer, usage 0xB5).
98
+ */
99
+ next(): Promise<void>;
100
+ /**
101
+ * Sends a Previous Track key press (Consumer, usage 0xB6).
102
+ */
103
+ previous(): Promise<void>;
104
+ /**
105
+ * Sends a Volume Up key press (Consumer, usage 0xE9).
106
+ */
107
+ volumeUp(): Promise<void>;
108
+ /**
109
+ * Sends a Volume Down key press (Consumer, usage 0xEA).
110
+ */
111
+ volumeDown(): Promise<void>;
112
+ /**
113
+ * Sends a Mute key press (Consumer, usage 0xE2).
114
+ */
115
+ mute(): Promise<void>;
116
+ /**
117
+ * Sends a Top Menu key press (Consumer, usage 0x60).
118
+ */
119
+ topMenu(): Promise<void>;
120
+ /**
121
+ * Sends a Channel Up key press (Consumer, usage 0x9C).
122
+ */
123
+ channelUp(): Promise<void>;
124
+ /**
125
+ * Sends a Channel Down key press (Consumer, usage 0x9D).
126
+ */
127
+ channelDown(): Promise<void>;
128
+ /**
129
+ * Sends a Play command via the MRP SendCommand protocol.
130
+ */
131
+ commandPlay(): Promise<void>;
132
+ /**
133
+ * Sends a Pause command via the MRP SendCommand protocol.
134
+ */
135
+ commandPause(): Promise<void>;
136
+ /**
137
+ * Sends a TogglePlayPause command via the MRP SendCommand protocol.
138
+ */
139
+ commandTogglePlayPause(): Promise<void>;
140
+ /**
141
+ * Sends a Stop command via the MRP SendCommand protocol.
142
+ */
143
+ commandStop(): Promise<void>;
144
+ /**
145
+ * Sends a NextTrack command via the MRP SendCommand protocol.
146
+ */
147
+ commandNextTrack(): Promise<void>;
148
+ /**
149
+ * Sends a PreviousTrack command via the MRP SendCommand protocol.
150
+ */
151
+ commandPreviousTrack(): Promise<void>;
152
+ /**
153
+ * Sends a SkipForward command with a configurable interval.
154
+ *
155
+ * @param interval - Seconds to skip forward (defaults to 15).
156
+ */
157
+ commandSkipForward(interval?: number): Promise<void>;
158
+ /**
159
+ * Sends a SkipBackward command with a configurable interval.
160
+ *
161
+ * @param interval - Seconds to skip backward (defaults to 15).
162
+ */
163
+ commandSkipBackward(interval?: number): Promise<void>;
164
+ /**
165
+ * Seeks to an absolute playback position.
166
+ *
167
+ * @param position - The target position in seconds.
168
+ */
169
+ commandSeekToPosition(position: number): Promise<void>;
170
+ /**
171
+ * Sets the shuffle mode.
172
+ *
173
+ * @param mode - The desired shuffle mode.
174
+ */
175
+ commandSetShuffleMode(mode: Proto$1.ShuffleMode_Enum): Promise<void>;
176
+ /**
177
+ * Sets the repeat mode.
178
+ *
179
+ * @param mode - The desired repeat mode.
180
+ */
181
+ commandSetRepeatMode(mode: Proto$1.RepeatMode_Enum): Promise<void>;
182
+ /**
183
+ * Changes the playback rate (speed).
184
+ *
185
+ * @param rate - The desired playback rate (e.g. 1.0 for normal, 2.0 for double speed).
186
+ */
187
+ commandChangePlaybackRate(rate: number): Promise<void>;
188
+ /**
189
+ * Cycles the shuffle mode to the next value.
190
+ */
191
+ commandAdvanceShuffleMode(): Promise<void>;
192
+ /**
193
+ * Cycles the repeat mode to the next value.
194
+ */
195
+ commandAdvanceRepeatMode(): Promise<void>;
196
+ /**
197
+ * Begins fast-forwarding playback.
198
+ */
199
+ commandBeginFastForward(): Promise<void>;
200
+ /**
201
+ * Ends fast-forwarding playback.
202
+ */
203
+ commandEndFastForward(): Promise<void>;
204
+ /**
205
+ * Begins rewinding playback.
206
+ */
207
+ commandBeginRewind(): Promise<void>;
208
+ /**
209
+ * Ends rewinding playback.
210
+ */
211
+ commandEndRewind(): Promise<void>;
212
+ /**
213
+ * Skips to the next chapter.
214
+ */
215
+ commandNextChapter(): Promise<void>;
216
+ /**
217
+ * Skips to the previous chapter.
218
+ */
219
+ commandPreviousChapter(): Promise<void>;
220
+ /**
221
+ * Marks the current track as liked.
222
+ */
223
+ commandLikeTrack(): Promise<void>;
224
+ /**
225
+ * Marks the current track as disliked.
226
+ */
227
+ commandDislikeTrack(): Promise<void>;
228
+ /**
229
+ * Bookmarks the current track.
230
+ */
231
+ commandBookmarkTrack(): Promise<void>;
232
+ /**
233
+ * Adds the currently playing item to the user's library.
234
+ */
235
+ commandAddNowPlayingItemToLibrary(): Promise<void>;
236
+ /**
237
+ * Sets a sleep timer that will stop playback after the specified duration.
238
+ * The timer works by attaching sleep timer options to a Pause command.
239
+ *
240
+ * @param seconds - Timer duration in seconds. Use 0 to cancel an active timer.
241
+ * @param stopMode - Stop mode: 0 = stop playback, 1 = pause, 2 = end of track, 3 = end of queue.
242
+ */
243
+ commandSetSleepTimer(seconds: number, stopMode?: number): Promise<void>;
244
+ /**
245
+ * Sets the text input field to the given text, replacing any existing content.
246
+ *
247
+ * @param text - The text to set.
248
+ */
249
+ textSet(text: string): Promise<void>;
250
+ /**
251
+ * Appends text to the current text input field content.
252
+ *
253
+ * @param text - The text to append.
254
+ */
255
+ textAppend(text: string): Promise<void>;
256
+ /**
257
+ * Clears the text input field.
258
+ */
259
+ textClear(): Promise<void>;
260
+ /**
261
+ * Requests the current keyboard session state from the Apple TV.
262
+ */
263
+ getKeyboardSession(): Promise<void>;
264
+ /**
265
+ * Simulates a tap at the given coordinates.
266
+ *
267
+ * @param x - Horizontal position in the virtual touch area.
268
+ * @param y - Vertical position in the virtual touch area.
269
+ * @param finger - Finger index for multi-touch (defaults to 1).
270
+ */
271
+ tap(x: number, y: number, finger?: number): Promise<void>;
272
+ /**
273
+ * Simulates an upward swipe gesture.
274
+ *
275
+ * @param duration - Swipe duration in milliseconds (defaults to 200).
276
+ */
277
+ swipeUp(duration?: number): Promise<void>;
278
+ /**
279
+ * Simulates a downward swipe gesture.
280
+ *
281
+ * @param duration - Swipe duration in milliseconds (defaults to 200).
282
+ */
283
+ swipeDown(duration?: number): Promise<void>;
284
+ /**
285
+ * Simulates a leftward swipe gesture.
286
+ *
287
+ * @param duration - Swipe duration in milliseconds (defaults to 200).
288
+ */
289
+ swipeLeft(duration?: number): Promise<void>;
290
+ /**
291
+ * Simulates a rightward swipe gesture.
292
+ *
293
+ * @param duration - Swipe duration in milliseconds (defaults to 200).
294
+ */
295
+ swipeRight(duration?: number): Promise<void>;
296
+ /**
297
+ * Sends a double press of a HID key (two press-and-release cycles with a 150ms gap).
298
+ *
299
+ * @param usePage - USB HID usage page (1 = Generic Desktop, 12 = Consumer).
300
+ * @param usage - USB HID usage code.
301
+ */
302
+ doublePress(usePage: number, usage: number): Promise<void>;
303
+ /**
304
+ * Sends a long press of a HID key (hold for a configurable duration).
305
+ *
306
+ * @param usePage - USB HID usage page (1 = Generic Desktop, 12 = Consumer).
307
+ * @param usage - USB HID usage code.
308
+ * @param duration - Hold duration in milliseconds (defaults to 1000).
309
+ */
310
+ longPress(usePage: number, usage: number, duration?: number): Promise<void>;
311
+ /**
312
+ * Sends a single press-and-release of a HID key with a 25ms hold.
313
+ *
314
+ * @param usePage - USB HID usage page (1 = Generic Desktop, 12 = Consumer).
315
+ * @param usage - USB HID usage code.
316
+ */
317
+ pressAndRelease(usePage: number, usage: number): Promise<void>;
318
+ }
319
+ //#endregion
320
+ //#region src/internal/airplay-player.d.ts
321
+ /**
322
+ * Represents a single media player within an app on the Apple TV.
323
+ * Each app (Client) can have multiple players (e.g. picture-in-picture).
324
+ * Tracks now-playing metadata, playback state, and provides elapsed time extrapolation
325
+ * based on Cocoa timestamps and playback rate.
326
+ */
327
+ declare class AirPlayPlayer {
328
+ #private;
329
+ /**
330
+ * Unique identifier for this player (e.g. a player path).
331
+ */
332
+ get identifier(): string;
333
+ /**
334
+ * Human-readable display name for this player.
335
+ */
336
+ get displayName(): string;
337
+ /**
338
+ * Whether this is the default fallback player (MediaRemote-DefaultPlayer).
339
+ */
340
+ get isDefaultPlayer(): boolean;
341
+ /**
342
+ * Raw now-playing info from the Apple TV, or null if unavailable.
343
+ */
344
+ get nowPlayingInfo(): Proto$1.NowPlayingInfo | null;
345
+ /**
346
+ * Current playback queue, or null if unavailable.
347
+ */
348
+ get playbackQueue(): Proto$1.PlaybackQueue | null;
349
+ /**
350
+ * Effective playback state.
351
+ */
352
+ get playbackState(): Proto$1.PlaybackState_Enum;
353
+ /**
354
+ * Timestamp of the last playback state update, used to discard stale updates.
355
+ */
356
+ get playbackStateTimestamp(): number;
357
+ /**
358
+ * List of commands supported by this player.
359
+ */
360
+ get supportedCommands(): Proto$1.CommandInfo[];
361
+ /**
362
+ * Current track title from NowPlayingInfo or content item metadata.
363
+ */
364
+ get title(): string;
365
+ /**
366
+ * Current track artist from NowPlayingInfo or content item metadata.
367
+ */
368
+ get artist(): string;
369
+ /**
370
+ * Current track album from NowPlayingInfo or content item metadata.
371
+ */
372
+ get album(): string;
373
+ /**
374
+ * Genre of the current content item.
375
+ */
376
+ get genre(): string;
377
+ /**
378
+ * Series name for TV show content.
379
+ */
380
+ get seriesName(): string;
381
+ /**
382
+ * Season number for TV show content, or 0 if not applicable.
383
+ */
384
+ get seasonNumber(): number;
385
+ /**
386
+ * Episode number for TV show content, or 0 if not applicable.
387
+ */
388
+ get episodeNumber(): number;
389
+ /**
390
+ * Media type of the current content item (music, video, etc.).
391
+ */
392
+ get mediaType(): Proto$1.ContentItemMetadata_MediaType;
393
+ /**
394
+ * Unique content identifier for the current item (e.g. iTunes store ID).
395
+ */
396
+ get contentIdentifier(): string;
397
+ /**
398
+ * Duration of the current track in seconds, from NowPlayingInfo or metadata.
399
+ */
400
+ get duration(): number;
401
+ /**
402
+ * Current playback rate (1.0 = normal, 0 = paused, 2.0 = double speed).
403
+ */
404
+ get playbackRate(): number;
405
+ /**
406
+ * Whether the player is currently playing (based on effective playback state).
407
+ */
408
+ get isPlaying(): boolean;
409
+ /**
410
+ * Current shuffle mode, derived from the ChangeShuffleMode command info.
411
+ */
412
+ get shuffleMode(): Proto$1.ShuffleMode_Enum;
413
+ /**
414
+ * Current repeat mode, derived from the ChangeRepeatMode command info.
415
+ */
416
+ get repeatMode(): Proto$1.RepeatMode_Enum;
417
+ /**
418
+ * Extrapolated elapsed time in seconds. Uses the most recent timestamp
419
+ * from either NowPlayingInfo or content item metadata, accounting for
420
+ * playback rate to provide a real-time estimate.
421
+ */
422
+ get elapsedTime(): number;
423
+ /**
424
+ * The currently playing content item from the playback queue, or null.
425
+ */
426
+ get currentItem(): Proto$1.ContentItem | null;
427
+ /**
428
+ * Metadata of the current content item, or null if no item is playing.
429
+ */
430
+ get currentItemMetadata(): Proto$1.ContentItemMetadata | null;
431
+ /**
432
+ * Unique identifier for the current artwork, used for change detection.
433
+ * Returns null if no artwork evidence exists.
434
+ */
435
+ get artworkId(): string | null;
436
+ /**
437
+ * Resolves the best available artwork URL for the current item.
438
+ * Checks metadata artworkURL, remote artworks, and iTunes template URLs in order.
439
+ *
440
+ * @param width - Desired artwork width in pixels (used for template URLs).
441
+ * @param height - Desired artwork height in pixels (-1 for automatic).
442
+ * @returns The artwork URL, or null if no artwork URL is available.
443
+ */
444
+ artworkUrl(width?: number, height?: number): string | null;
445
+ /**
446
+ * Raw artwork data (image bytes) for the current item, or null if not embedded.
447
+ */
448
+ get currentItemArtwork(): Uint8Array | null;
449
+ /**
450
+ * Convenience getter for the artwork URL at default dimensions (600px).
451
+ */
452
+ get currentItemArtworkUrl(): string | null;
453
+ /**
454
+ * Lyrics for the current content item, or null if unavailable.
455
+ */
456
+ get currentItemLyrics(): Proto$1.LyricsItem | null;
457
+ /**
458
+ * Creates a new Player instance.
459
+ *
460
+ * @param identifier - Unique player identifier.
461
+ * @param displayName - Human-readable display name.
462
+ */
463
+ constructor(identifier: string, displayName: string);
464
+ /**
465
+ * Finds a command by its command type in the supported commands list.
466
+ *
467
+ * @param command - The command to look up.
468
+ * @returns The command info, or null if not found.
469
+ */
470
+ findCommand(command: Proto$1.Command): Proto$1.CommandInfo | null;
471
+ /**
472
+ * Checks whether a command is supported and enabled.
473
+ *
474
+ * @param command - The command to check.
475
+ * @returns True if the command is in the supported list and enabled.
476
+ */
477
+ isCommandSupported(command: Proto$1.Command): boolean;
478
+ /**
479
+ * Updates the now-playing info for this player.
480
+ *
481
+ * @param nowPlayingInfo - The new now-playing info from the Apple TV.
482
+ */
483
+ setNowPlayingInfo(nowPlayingInfo: Proto$1.NowPlayingInfo): void;
484
+ /**
485
+ * Updates the playback queue for this player.
486
+ *
487
+ * @param playbackQueue - The new playback queue from the Apple TV.
488
+ */
489
+ setPlaybackQueue(playbackQueue: Proto$1.PlaybackQueue): void;
490
+ /**
491
+ * Updates the playback state. Ignores updates with a timestamp older than the current one
492
+ * to prevent stale state from overwriting newer data.
493
+ *
494
+ * @param playbackState - The new playback state.
495
+ * @param playbackStateTimestamp - Timestamp of this state update.
496
+ */
497
+ setPlaybackState(playbackState: Proto$1.PlaybackState_Enum, playbackStateTimestamp: number): void;
498
+ /**
499
+ * Replaces the list of supported commands for this player.
500
+ *
501
+ * @param supportedCommands - The new list of supported commands.
502
+ */
503
+ setSupportedCommands(supportedCommands: Proto$1.CommandInfo[]): void;
504
+ /**
505
+ * Merges updated content item data into the existing playback queue.
506
+ * Updates metadata, artwork, lyrics, and info fields for the matching item.
507
+ *
508
+ * @param item - The content item with updated fields.
509
+ */
510
+ updateContentItem(item: Proto$1.ContentItem): void;
511
+ }
512
+ //#endregion
513
+ //#region src/internal/airplay-client.d.ts
514
+ /**
515
+ * Represents a now-playing app (client) on the Apple TV.
516
+ * Each client is identified by its bundle identifier and can contain multiple players.
517
+ * Proxies now-playing getters to the active player, merging player-specific and
518
+ * default supported commands.
519
+ */
520
+ declare class AirPlayClient {
521
+ #private;
522
+ /**
523
+ * Bundle identifier of the app (e.g. "com.apple.TVMusic").
524
+ */
525
+ get bundleIdentifier(): string;
526
+ /**
527
+ * Human-readable display name of the app.
528
+ */
529
+ get displayName(): string;
530
+ /**
531
+ * Map of all known players for this client, keyed by player identifier.
532
+ */
533
+ get players(): Map<string, AirPlayPlayer>;
534
+ /**
535
+ * The currently active player, or null if none is active. Falls back to the default player.
536
+ */
537
+ get activePlayer(): AirPlayPlayer | null;
538
+ /**
539
+ * Now-playing info from the active player, or null.
540
+ */
541
+ get nowPlayingInfo(): Proto$1.NowPlayingInfo | null;
542
+ /**
543
+ * Playback queue from the active player, or null.
544
+ */
545
+ get playbackQueue(): Proto$1.PlaybackQueue | null;
546
+ /**
547
+ * Playback state from the active player, or Unknown.
548
+ */
549
+ get playbackState(): Proto$1.PlaybackState_Enum;
550
+ /**
551
+ * Timestamp of the last playback state update from the active player.
552
+ */
553
+ get playbackStateTimestamp(): number;
554
+ /**
555
+ * Merged list of supported commands from the active player and client defaults.
556
+ * Player commands take precedence; default commands are appended if not already present.
557
+ */
558
+ get supportedCommands(): Proto$1.CommandInfo[];
559
+ /**
560
+ * Current track title from the active player.
561
+ */
562
+ get title(): string;
563
+ /**
564
+ * Current track artist from the active player.
565
+ */
566
+ get artist(): string;
567
+ /**
568
+ * Current track album from the active player.
569
+ */
570
+ get album(): string;
571
+ /**
572
+ * Genre of the current content from the active player.
573
+ */
574
+ get genre(): string;
575
+ /**
576
+ * Series name for TV show content from the active player.
577
+ */
578
+ get seriesName(): string;
579
+ /**
580
+ * Season number for TV show content from the active player.
581
+ */
582
+ get seasonNumber(): number;
583
+ /**
584
+ * Episode number for TV show content from the active player.
585
+ */
586
+ get episodeNumber(): number;
587
+ /**
588
+ * Media type of the current content from the active player.
589
+ */
590
+ get mediaType(): Proto$1.ContentItemMetadata_MediaType;
591
+ /**
592
+ * Content identifier of the current item from the active player.
593
+ */
594
+ get contentIdentifier(): string;
595
+ /**
596
+ * Duration of the current track in seconds from the active player.
597
+ */
598
+ get duration(): number;
599
+ /**
600
+ * Playback rate from the active player (1.0 = normal, 0 = paused).
601
+ */
602
+ get playbackRate(): number;
603
+ /**
604
+ * Whether the active player is currently playing.
605
+ */
606
+ get isPlaying(): boolean;
607
+ /**
608
+ * Current shuffle mode from the active player.
609
+ */
610
+ get shuffleMode(): Proto$1.ShuffleMode_Enum;
611
+ /**
612
+ * Current repeat mode from the active player.
613
+ */
614
+ get repeatMode(): Proto$1.RepeatMode_Enum;
615
+ /**
616
+ * Extrapolated elapsed time in seconds from the active player.
617
+ */
618
+ get elapsedTime(): number;
619
+ /**
620
+ * Artwork identifier for change detection from the active player.
621
+ */
622
+ get artworkId(): string | null;
623
+ /**
624
+ * Resolves the best available artwork URL from the active player.
625
+ *
626
+ * @param width - Desired artwork width in pixels.
627
+ * @param height - Desired artwork height in pixels (-1 for automatic).
628
+ * @returns The artwork URL, or null if unavailable.
629
+ */
630
+ artworkUrl(width?: number, height?: number): string | null;
631
+ /**
632
+ * Current content item from the active player's playback queue.
633
+ */
634
+ get currentItem(): Proto$1.ContentItem | null;
635
+ /**
636
+ * Metadata of the current content item from the active player.
637
+ */
638
+ get currentItemMetadata(): Proto$1.ContentItemMetadata | null;
639
+ /**
640
+ * Raw artwork data (image bytes) from the active player.
641
+ */
642
+ get currentItemArtwork(): Uint8Array | null;
643
+ /**
644
+ * Artwork URL at default dimensions from the active player.
645
+ */
646
+ get currentItemArtworkUrl(): string | null;
647
+ /**
648
+ * Lyrics for the current content item from the active player.
649
+ */
650
+ get currentItemLyrics(): Proto$1.LyricsItem | null;
651
+ /**
652
+ * Creates a new Client instance.
653
+ *
654
+ * @param bundleIdentifier - Bundle identifier of the app.
655
+ * @param displayName - Human-readable app name.
656
+ */
657
+ constructor(bundleIdentifier: string, displayName: string);
658
+ /**
659
+ * Gets an existing player or creates a new one if it does not exist.
660
+ *
661
+ * @param identifier - Unique player identifier.
662
+ * @param displayName - Human-readable player name (defaults to identifier).
663
+ * @returns The existing or newly created Player.
664
+ */
665
+ getOrCreatePlayer(identifier: string, displayName?: string): AirPlayPlayer;
666
+ /**
667
+ * Sets the active player by identifier.
668
+ *
669
+ * @param identifier - Identifier of the player to activate.
670
+ */
671
+ setActivePlayer(identifier: string): void;
672
+ /**
673
+ * Removes a player from this client. If the removed player was active,
674
+ * the active player is reset to null (falling back to the default player).
675
+ *
676
+ * @param identifier - Identifier of the player to remove.
677
+ */
678
+ removePlayer(identifier: string): void;
679
+ /**
680
+ * Sets the default supported commands for this client. These are used as
681
+ * fallback when the active player has no commands of its own.
682
+ *
683
+ * @param supportedCommands - The default command list.
684
+ */
685
+ setDefaultSupportedCommands(supportedCommands: Proto$1.CommandInfo[]): void;
686
+ /**
687
+ * Finds a command by type, checking the active player first,
688
+ * then falling back to the default supported commands.
689
+ *
690
+ * @param command - The command to look up.
691
+ * @returns The command info, or null if not found.
692
+ */
693
+ findCommand(command: Proto$1.Command): Proto$1.CommandInfo | null;
694
+ /**
695
+ * Checks whether a command is supported and enabled, checking both
696
+ * the active player and default commands.
697
+ *
698
+ * @param command - The command to check.
699
+ * @returns True if the command is supported and enabled.
700
+ */
701
+ isCommandSupported(command: Proto$1.Command): boolean;
702
+ /**
703
+ * Updates the display name for this client.
704
+ *
705
+ * @param displayName - The new display name.
706
+ */
707
+ updateDisplayName(displayName: string): void;
708
+ }
709
+ //#endregion
710
+ //#region src/internal/const.d.ts
711
+ /**
712
+ * Symbol used to access the underlying AirPlay Protocol instance from an AirPlayDevice.
713
+ */
714
+ declare const PROTOCOL: unique symbol;
715
+ /**
716
+ * Symbol used to subscribe AirPlayState to DataStream events.
717
+ */
718
+ declare const STATE_SUBSCRIBE_SYMBOL: unique symbol;
719
+ /**
720
+ * Symbol used to unsubscribe AirPlayState from DataStream events.
721
+ */
722
+ declare const STATE_UNSUBSCRIBE_SYMBOL: unique symbol;
723
+ /**
724
+ * Symbol used to access the underlying Companion Link Protocol instance from a CompanionLinkManager.
725
+ */
726
+ declare const COMPANION_LINK_PROTOCOL: unique symbol;
727
+ //#endregion
728
+ //#region src/internal/airplay-state.d.ts
729
+ /**
730
+ * Events emitted by AirPlayState.
731
+ *
732
+ * Low-level events mirror DataStream protocol messages 1:1.
733
+ * High-level events (activePlayerChanged, artworkChanged, etc.) provide
734
+ * pre-resolved Client/Player references for convenience.
735
+ */
736
+ type EventMap$3 = {
737
+ readonly clients: [Record<string, AirPlayClient>];
738
+ readonly configureConnection: [Proto$1.ConfigureConnectionMessage];
739
+ readonly deviceInfo: [Proto$1.DeviceInfoMessage];
740
+ readonly deviceInfoUpdate: [Proto$1.DeviceInfoMessage];
741
+ readonly keyboard: [Proto$1.KeyboardMessage];
742
+ readonly nowPlayingChanged: [client: AirPlayClient | null, player: AirPlayPlayer | null];
743
+ readonly originClientProperties: [Proto$1.OriginClientPropertiesMessage];
744
+ readonly playerClientProperties: [Proto$1.PlayerClientPropertiesMessage];
745
+ readonly removeClient: [Proto$1.RemoveClientMessage];
746
+ readonly removePlayer: [Proto$1.RemovePlayerMessage];
747
+ readonly sendCommandResult: [Proto$1.SendCommandResultMessage];
748
+ readonly setArtwork: [Proto$1.SetArtworkMessage];
749
+ readonly setDefaultSupportedCommands: [Proto$1.SetDefaultSupportedCommandsMessage];
750
+ readonly setNowPlayingClient: [Proto$1.SetNowPlayingClientMessage];
751
+ readonly setNowPlayingPlayer: [Proto$1.SetNowPlayingPlayerMessage];
752
+ readonly setState: [Proto$1.SetStateMessage];
753
+ readonly updateClient: [Proto$1.UpdateClientMessage];
754
+ readonly updateContentItem: [Proto$1.UpdateContentItemMessage];
755
+ readonly updateContentItemArtwork: [Proto$1.UpdateContentItemArtworkMessage];
756
+ readonly updatePlayer: [Proto$1.UpdatePlayerMessage];
757
+ readonly updateOutputDevice: [Proto$1.UpdateOutputDeviceMessage];
758
+ readonly volumeControlAvailability: [boolean, Proto$1.VolumeCapabilities_Enum];
759
+ readonly volumeControlCapabilitiesDidChange: [boolean, Proto$1.VolumeCapabilities_Enum];
760
+ readonly volumeDidChange: [number];
761
+ readonly volumeMutedDidChange: [boolean];
762
+ readonly activePlayerChanged: [client: AirPlayClient | null, player: AirPlayPlayer | null];
763
+ readonly artworkChanged: [client: AirPlayClient, player: AirPlayPlayer];
764
+ readonly lyricsEvent: [event: Proto$1.LyricsEvent, playerPath: Proto$1.PlayerPath | undefined];
765
+ readonly playbackQueueChanged: [client: AirPlayClient, player: AirPlayPlayer];
766
+ readonly playbackStateChanged: [client: AirPlayClient, player: AirPlayPlayer, oldState: Proto$1.PlaybackState_Enum, newState: Proto$1.PlaybackState_Enum];
767
+ readonly supportedCommandsChanged: [client: AirPlayClient, player: AirPlayPlayer, commands: Proto$1.CommandInfo[]];
768
+ readonly clusterChanged: [clusterID: string | null, isLeader: boolean];
769
+ readonly playerClientParticipantsUpdate: [Proto$1.PlayerClientParticipantsUpdateMessage];
770
+ };
771
+ /**
772
+ * Tracks the complete state of an AirPlay device: clients, players, now-playing,
773
+ * volume, keyboard, output devices, and cluster info.
774
+ * Listens to DataStream protocol messages and emits both low-level (1:1 with protocol)
775
+ * and high-level (deduplicated, resolved) events.
776
+ */
777
+ declare class AirPlayState extends EventEmitter<EventMap$3> {
778
+ #private;
779
+ /**
780
+ * All known clients (apps) keyed by bundle identifier.
781
+ */
782
+ get clients(): Record<string, AirPlayClient>;
783
+ /**
784
+ * Whether a keyboard/text input session is currently active on the Apple TV.
785
+ */
786
+ get isKeyboardActive(): boolean;
787
+ /**
788
+ * Text editing attributes for the active keyboard session, or null.
789
+ */
790
+ get keyboardAttributes(): Proto$1.TextEditingAttributes | null;
791
+ /**
792
+ * Current keyboard state enum value.
793
+ */
794
+ get keyboardState(): Proto$1.KeyboardState_Enum;
795
+ /**
796
+ * The currently active now-playing client, or null if nothing is playing.
797
+ */
798
+ get nowPlayingClient(): AirPlayClient | null;
799
+ /**
800
+ * UID of the primary output device (used for volume control and multi-room).
801
+ */
802
+ get outputDeviceUID(): string | null;
803
+ /**
804
+ * List of all output device descriptors in the current AirPlay group.
805
+ */
806
+ get outputDevices(): Proto$1.AVOutputDeviceDescriptor[];
807
+ /**
808
+ * Cluster identifier for multi-room groups, or null.
809
+ */
810
+ get clusterID(): string | null;
811
+ /**
812
+ * Cluster type code (0 if not clustered).
813
+ */
814
+ get clusterType(): number;
815
+ /**
816
+ * Whether this device is aware of multi-room clusters.
817
+ */
818
+ get isClusterAware(): boolean;
819
+ /**
820
+ * Whether this device is the leader of its multi-room cluster.
821
+ */
822
+ get isClusterLeader(): boolean;
823
+ /**
824
+ * Current playback queue participants (e.g. SharePlay users).
825
+ */
826
+ get participants(): Proto$1.PlaybackQueueParticipant[];
827
+ /**
828
+ * Raw JPEG artwork data from the last SET_ARTWORK_MESSAGE, or null.
829
+ */
830
+ get artworkJpegData(): Uint8Array | null;
831
+ /**
832
+ * Current volume level (0.0 - 1.0).
833
+ */
834
+ get volume(): number;
835
+ /**
836
+ * Whether volume control is available on this device.
837
+ */
838
+ get volumeAvailable(): boolean;
839
+ /**
840
+ * Volume capabilities (absolute, relative, both, or none).
841
+ */
842
+ get volumeCapabilities(): Proto$1.VolumeCapabilities_Enum;
843
+ /**
844
+ * Whether the device is currently muted.
845
+ */
846
+ get volumeMuted(): boolean;
847
+ /**
848
+ * Creates a new AirPlayState tracker.
849
+ *
850
+ * @param device - The AirPlay device to track state for.
851
+ */
852
+ constructor(device: AirPlayManager);
853
+ /**
854
+ * Subscribes to all DataStream events to track device state. Called internally via symbol.
855
+ */
856
+ [STATE_SUBSCRIBE_SYMBOL](): void;
857
+ /**
858
+ * Unsubscribes from all DataStream events. Called internally via symbol.
859
+ */
860
+ [STATE_UNSUBSCRIBE_SYMBOL](): void;
861
+ /**
862
+ * Resets all state to initial/default values. Called on connect and reconnect.
863
+ */
864
+ clear(): void;
865
+ /**
866
+ * Handles a ConfigureConnection message from the Apple TV.
867
+ *
868
+ * @param message - The configure connection message.
869
+ */
870
+ onConfigureConnection(message: Proto$1.ConfigureConnectionMessage): void;
871
+ /**
872
+ * Handles keyboard state changes. Updates internal state and emits 'keyboard'.
873
+ *
874
+ * @param message - The keyboard message with state and attributes.
875
+ */
876
+ onKeyboard(message: Proto$1.KeyboardMessage): void;
877
+ /**
878
+ * Handles initial device info. Updates output device UID and cluster info.
879
+ *
880
+ * @param message - The device info message.
881
+ */
882
+ onDeviceInfo(message: Proto$1.DeviceInfoMessage): void;
883
+ /**
884
+ * Handles device info updates (e.g. cluster changes). Updates output device UID and cluster info.
885
+ *
886
+ * @param message - The device info update message.
887
+ */
888
+ onDeviceInfoUpdate(message: Proto$1.DeviceInfoMessage): void;
889
+ /**
890
+ * Handles origin client properties updates.
891
+ *
892
+ * @param message - The origin client properties message.
893
+ */
894
+ onOriginClientProperties(message: Proto$1.OriginClientPropertiesMessage): void;
895
+ /**
896
+ * Handles player client properties updates.
897
+ *
898
+ * @param message - The player client properties message.
899
+ */
900
+ onPlayerClientProperties(message: Proto$1.PlayerClientPropertiesMessage): void;
901
+ /**
902
+ * Handles removal of a client (app). Clears the now-playing reference if
903
+ * the removed client was the active one.
904
+ *
905
+ * @param message - The remove client message.
906
+ */
907
+ onRemoveClient(message: Proto$1.RemoveClientMessage): void;
908
+ /**
909
+ * Handles command result notifications from the Apple TV.
910
+ *
911
+ * @param message - The send command result message.
912
+ */
913
+ onSendCommandResult(message: Proto$1.SendCommandResultMessage): void;
914
+ /**
915
+ * Handles lyrics events (time-synced lyrics updates).
916
+ *
917
+ * @param message - The lyrics event message.
918
+ */
919
+ onSendLyricsEvent(message: Proto$1.SendLyricsEventMessage): void;
920
+ /**
921
+ * Handles artwork set notifications.
922
+ *
923
+ * @param message - The set artwork message.
924
+ */
925
+ onSetArtwork(message: Proto$1.SetArtworkMessage): void;
926
+ /**
927
+ * Handles default supported commands for a client. These serve as fallback
928
+ * commands when a player has no commands of its own.
929
+ *
930
+ * @param message - The set default supported commands message.
931
+ */
932
+ onSetDefaultSupportedCommands(message: Proto$1.SetDefaultSupportedCommandsMessage): void;
933
+ /**
934
+ * Handles the now-playing client changing (e.g. user switches app).
935
+ * Updates the active client reference and emits change events.
936
+ *
937
+ * @param message - The set now-playing client message.
938
+ */
939
+ onSetNowPlayingClient(message: Proto$1.SetNowPlayingClientMessage): void;
940
+ /**
941
+ * Handles the active player changing within a client (e.g. PiP player becomes active).
942
+ * Creates the player if needed and sets it as the active player.
943
+ *
944
+ * @param message - The set now-playing player message.
945
+ */
946
+ onSetNowPlayingPlayer(message: Proto$1.SetNowPlayingPlayerMessage): void;
947
+ /**
948
+ * Handles comprehensive state updates. Processes playback state, now-playing info,
949
+ * supported commands, and playback queue in a single message.
950
+ * Emits granular events for each changed aspect.
951
+ *
952
+ * @param message - The set state message.
953
+ */
954
+ onSetState(message: Proto$1.SetStateMessage): void;
955
+ /**
956
+ * Handles content item updates (metadata, artwork, lyrics changes for existing items).
957
+ *
958
+ * @param message - The update content item message.
959
+ */
960
+ onUpdateContentItem(message: Proto$1.UpdateContentItemMessage): void;
961
+ /**
962
+ * Handles artwork updates for content items. Emits 'artworkChanged' if a client and player are active.
963
+ *
964
+ * @param message - The update content item artwork message.
965
+ */
966
+ onUpdateContentItemArtwork(message: Proto$1.UpdateContentItemArtworkMessage): void;
967
+ /**
968
+ * Handles player registration or update. Creates the player if it does not exist.
969
+ *
970
+ * @param message - The update player message.
971
+ */
972
+ onUpdatePlayer(message: Proto$1.UpdatePlayerMessage): void;
973
+ /**
974
+ * Handles player removal. Removes the player from its client and emits
975
+ * active player changed events if the removed player was active.
976
+ *
977
+ * @param message - The remove player message.
978
+ */
979
+ onRemovePlayer(message: Proto$1.RemovePlayerMessage): void;
980
+ /**
981
+ * Handles client (app) registration or display name update.
982
+ *
983
+ * @param message - The update client message.
984
+ */
985
+ onUpdateClient(message: Proto$1.UpdateClientMessage): void;
986
+ /**
987
+ * Handles output device list updates. Prefers cluster-aware devices when available.
988
+ *
989
+ * @param message - The update output device message.
990
+ */
991
+ /**
992
+ * Handles playback queue participant updates (e.g. SharePlay users).
993
+ *
994
+ * @param message - The participants update message.
995
+ */
996
+ onPlayerClientParticipantsUpdate(message: Proto$1.PlayerClientParticipantsUpdateMessage): void;
997
+ onUpdateOutputDevice(message: Proto$1.UpdateOutputDeviceMessage): void;
998
+ /**
999
+ * Handles volume control availability changes.
1000
+ *
1001
+ * @param message - The volume control availability message.
1002
+ */
1003
+ onVolumeControlAvailability(message: Proto$1.VolumeControlAvailabilityMessage): void;
1004
+ /**
1005
+ * Handles volume capabilities changes (e.g. device gains or loses absolute volume support).
1006
+ *
1007
+ * @param message - The volume capabilities change message.
1008
+ */
1009
+ onVolumeControlCapabilitiesDidChange(message: Proto$1.VolumeControlCapabilitiesDidChangeMessage): void;
1010
+ /**
1011
+ * Handles volume level changes.
1012
+ *
1013
+ * @param message - The volume change message.
1014
+ */
1015
+ onVolumeDidChange(message: Proto$1.VolumeDidChangeMessage): void;
1016
+ /**
1017
+ * Handles mute state changes.
1018
+ *
1019
+ * @param message - The volume muted change message.
1020
+ */
1021
+ onVolumeMutedDidChange(message: Proto$1.VolumeMutedDidChangeMessage): void;
1022
+ }
1023
+ //#endregion
1024
+ //#region src/internal/airplay-volume.d.ts
1025
+ /**
1026
+ * Smart volume controller for an AirPlay device.
1027
+ * Automatically chooses between absolute volume (set a specific level) and
1028
+ * relative volume (HID volume up/down keys) based on the device's reported capabilities.
1029
+ */
1030
+ declare class AirPlayVolume {
1031
+ #private;
1032
+ /**
1033
+ * Creates a new Volume controller.
1034
+ *
1035
+ * @param device - The AirPlay device to control volume for.
1036
+ */
1037
+ constructor(device: AirPlayManager);
1038
+ /**
1039
+ * Decreases the volume by one step. Uses absolute volume when available,
1040
+ * falls back to HID relative volume keys otherwise.
1041
+ *
1042
+ * @throws CommandError when volume control is not available.
1043
+ */
1044
+ down(): Promise<void>;
1045
+ /**
1046
+ * Increases the volume by one step. Uses absolute volume when available,
1047
+ * falls back to HID relative volume keys otherwise.
1048
+ *
1049
+ * @throws CommandError when volume control is not available.
1050
+ */
1051
+ up(): Promise<void>;
1052
+ /**
1053
+ * Fetches the current volume level from the device.
1054
+ *
1055
+ * @returns The volume level as a float between 0.0 and 1.0.
1056
+ * @throws CommandError when no output device is active or the request fails.
1057
+ */
1058
+ get(): Promise<number>;
1059
+ /**
1060
+ * Sets the volume to an absolute level.
1061
+ *
1062
+ * @param volume - The desired volume level (clamped to 0.0 - 1.0).
1063
+ * @throws CommandError when no output device is active or absolute volume is not supported.
1064
+ */
1065
+ set(volume: number): Promise<void>;
1066
+ /**
1067
+ * Mutes the output device.
1068
+ *
1069
+ * @throws CommandError when no output device is active.
1070
+ */
1071
+ mute(): Promise<void>;
1072
+ /**
1073
+ * Unmutes the output device.
1074
+ *
1075
+ * @throws CommandError when no output device is active.
1076
+ */
1077
+ unmute(): Promise<void>;
1078
+ /**
1079
+ * Toggles the mute state of the output device.
1080
+ *
1081
+ * @throws CommandError when no output device is active.
1082
+ */
1083
+ toggleMute(): Promise<void>;
1084
+ /**
1085
+ * Sets the volume for a specific output device in a speaker group.
1086
+ * Use this to control individual speakers when multiple devices are grouped.
1087
+ *
1088
+ * @param outputDeviceUID - The unique identifier of the target output device.
1089
+ * @param volume - The desired volume level (clamped to 0.0 - 1.0).
1090
+ */
1091
+ setForDevice(outputDeviceUID: string, volume: number): Promise<void>;
1092
+ /**
1093
+ * Fetches the volume for a specific output device in a speaker group.
1094
+ *
1095
+ * @param outputDeviceUID - The unique identifier of the target output device.
1096
+ * @returns The volume level as a float between 0.0 and 1.0.
1097
+ */
1098
+ getForDevice(outputDeviceUID: string): Promise<number>;
1099
+ /**
1100
+ * Mutes a specific output device in a speaker group.
1101
+ *
1102
+ * @param outputDeviceUID - The unique identifier of the target output device.
1103
+ */
1104
+ muteDevice(outputDeviceUID: string): Promise<void>;
1105
+ /**
1106
+ * Unmutes a specific output device in a speaker group.
1107
+ *
1108
+ * @param outputDeviceUID - The unique identifier of the target output device.
1109
+ */
1110
+ unmuteDevice(outputDeviceUID: string): Promise<void>;
1111
+ /**
1112
+ * Adjusts the volume by a relative increment/decrement on a specific output device.
1113
+ * This is the method Apple uses internally in Music.app for volume changes.
1114
+ *
1115
+ * @param adjustment - The volume adjustment to apply (IncrementSmall/Medium/Large, DecrementSmall/Medium/Large).
1116
+ * @param outputDeviceUID - Optional UID of the target output device. Defaults to the active device.
1117
+ */
1118
+ adjust(adjustment: Proto$1.AdjustVolumeMessage_Adjustment, outputDeviceUID?: string): Promise<void>;
1119
+ /**
1120
+ * Smoothly fades the volume to a target level over a given duration.
1121
+ * Uses linear interpolation with absolute volume set calls.
1122
+ *
1123
+ * @param targetVolume - The target volume level (0.0 - 1.0).
1124
+ * @param durationMs - The fade duration in milliseconds.
1125
+ * @throws CommandError when absolute volume control is not available.
1126
+ */
1127
+ fade(targetVolume: number, durationMs: number): Promise<void>;
1128
+ }
1129
+ //#endregion
1130
+ //#region src/internal/airplay-manager.d.ts
1131
+ /**
1132
+ * Events emitted by AirPlayDevice.
1133
+ * - `connected` — emitted after the full protocol setup completes.
1134
+ * - `disconnected` — emitted when the connection is lost or explicitly closed.
1135
+ */
1136
+ type EventMap$2 = {
1137
+ connected: [];
1138
+ disconnected: [unexpected: boolean];
1139
+ };
1140
+ /**
1141
+ * High-level abstraction for an AirPlay device (Apple TV or HomePod).
1142
+ * Manages the full lifecycle: connect, pair/verify, set up control/data/event streams,
1143
+ * and provides access to Remote, State, and Volume controllers.
1144
+ * Supports both transient (PIN-less) and credential-based pairing.
1145
+ */
1146
+ declare class AirPlayManager extends EventEmitter<EventMap$2> {
1147
+ #private;
1148
+ /**
1149
+ * @returns The underlying AirPlay Protocol instance (accessed via symbol for internal use).
1150
+ */
1151
+ get [PROTOCOL](): Protocol;
1152
+ /**
1153
+ * The mDNS discovery result used to connect to this device.
1154
+ */
1155
+ get discoveryResult(): DiscoveryResult$1;
1156
+ /**
1157
+ * Updates the discovery result, e.g. when the device's address changes.
1158
+ */
1159
+ set discoveryResult(discoveryResult: DiscoveryResult$1);
1160
+ /**
1161
+ * Device capabilities derived from the AirPlay feature flags.
1162
+ * Indicates which protocols and features the receiver supports.
1163
+ */
1164
+ get capabilities(): {
1165
+ supportsAudio: boolean;
1166
+ supportsBufferedAudio: boolean;
1167
+ supportsPTP: boolean;
1168
+ supportsRFC2198Redundancy: boolean;
1169
+ supportsHangdogRemoteControl: boolean;
1170
+ supportsUnifiedMediaControl: boolean;
1171
+ supportsTransientPairing: boolean;
1172
+ supportsSystemPairing: boolean;
1173
+ supportsCoreUtilsPairing: boolean;
1174
+ };
1175
+ /**
1176
+ * Whether the control stream TCP connection is currently active.
1177
+ */
1178
+ get isConnected(): boolean;
1179
+ /**
1180
+ * Raw receiver info dictionary from the /info endpoint, or undefined before connect.
1181
+ */
1182
+ get receiverInfo(): Record<string, any> | undefined;
1183
+ /**
1184
+ * The Artwork controller for fetching now-playing artwork from all sources.
1185
+ */
1186
+ get artwork(): AirPlayArtwork;
1187
+ /**
1188
+ * The Remote controller for HID keys, SendCommand, text input, and touch.
1189
+ */
1190
+ get remote(): AirPlayRemote;
1191
+ /**
1192
+ * The State tracker for now-playing, volume, keyboard, and output device state.
1193
+ */
1194
+ get state(): AirPlayState;
1195
+ /**
1196
+ * The Volume controller for absolute and relative volume adjustments.
1197
+ */
1198
+ get volume(): AirPlayVolume;
1199
+ /**
1200
+ * The shared PTP timing server, if one is assigned for multi-room sync.
1201
+ */
1202
+ get timingServer(): TimingServer$1 | undefined;
1203
+ /**
1204
+ * Assigns a PTP timing server for multi-room audio synchronization.
1205
+ */
1206
+ set timingServer(timingServer: TimingServer$1 | undefined);
1207
+ /**
1208
+ * Creates a new AirPlayDevice.
1209
+ *
1210
+ * @param discoveryResult - The mDNS discovery result for the target device.
1211
+ * @param identity - Optional partial device identity to present during pairing.
1212
+ */
1213
+ constructor(discoveryResult: DiscoveryResult$1, identity?: Partial<DeviceIdentity>);
1214
+ /**
1215
+ * Connects to the AirPlay device, performs pairing/verification,
1216
+ * and sets up all streams (control, data, event). Emits 'connected' on success.
1217
+ * If credentials are set, uses pair-verify; otherwise uses transient pairing.
1218
+ */
1219
+ connect(): Promise<void>;
1220
+ /**
1221
+ * Gracefully disconnects from the device, clears intervals, and tears down all streams.
1222
+ */
1223
+ disconnect(): void;
1224
+ /**
1225
+ * Disconnects gracefully, swallowing any errors during cleanup.
1226
+ */
1227
+ disconnectSafely(): void;
1228
+ /**
1229
+ * Enables or disables conversation detection on the output device (HomePod feature).
1230
+ *
1231
+ * @param enabled - Whether to enable conversation detection.
1232
+ * @throws Error when no output device is active.
1233
+ */
1234
+ setConversationDetectionEnabled(enabled: boolean): Promise<void>;
1235
+ /**
1236
+ * Adds devices to the current multi-room output context.
1237
+ *
1238
+ * @param deviceUIDs - UIDs of the devices to add.
1239
+ */
1240
+ addOutputDevices(deviceUIDs: string[]): Promise<void>;
1241
+ /**
1242
+ * Removes devices from the current multi-room output context.
1243
+ *
1244
+ * @param deviceUIDs - UIDs of the devices to remove.
1245
+ */
1246
+ removeOutputDevices(deviceUIDs: string[]): Promise<void>;
1247
+ /**
1248
+ * Replaces the entire multi-room output context with the given devices.
1249
+ *
1250
+ * @param deviceUIDs - UIDs of the devices to set as the output context.
1251
+ */
1252
+ setOutputDevices(deviceUIDs: string[]): Promise<void>;
1253
+ /**
1254
+ * Plays a URL on the device (the device fetches and plays the content).
1255
+ * Creates a separate Protocol instance to avoid conflicting with the
1256
+ * existing remote control session, following the same approach as pyatv.
1257
+ *
1258
+ * @param url - The media URL to play.
1259
+ * @param position - Start position in seconds (defaults to 0).
1260
+ * @throws Error when not connected.
1261
+ */
1262
+ playUrl(url: string, position?: number): Promise<void>;
1263
+ /**
1264
+ * Waits for the current URL playback to finish, then cleans up the play URL protocol.
1265
+ */
1266
+ waitForPlaybackEnd(): Promise<void>;
1267
+ /**
1268
+ * Stops the current URL playback and cleans up the dedicated play URL protocol.
1269
+ */
1270
+ stopPlayUrl(): void;
1271
+ /**
1272
+ * Streams audio from a source to the device via RAOP/RTP.
1273
+ * Creates a separate Protocol instance to avoid conflicting with the
1274
+ * existing remote control session, following the same approach as playUrl.
1275
+ *
1276
+ * @param source - The audio source to stream (e.g. MP3, WAV, URL, live).
1277
+ */
1278
+ streamAudio(source: AudioSource): Promise<void>;
1279
+ /**
1280
+ * Stops the current audio stream and cleans up the dedicated stream protocol.
1281
+ */
1282
+ stopStreamAudio(): void;
1283
+ /**
1284
+ * Sets the audio listening mode on the device (HomePod).
1285
+ *
1286
+ * @param mode - Listening mode string (e.g. 'Default', 'Vivid', 'LateNight').
1287
+ */
1288
+ setListeningMode(mode: string): Promise<void>;
1289
+ /**
1290
+ * Sets the audio routing mode on the receiver via the control stream.
1291
+ *
1292
+ * @param mode - Audio mode (e.g. 'default', 'moviePlayback', 'spoken').
1293
+ */
1294
+ setAudioMode(mode: string): Promise<void>;
1295
+ /**
1296
+ * Triggers an audio fade on the device.
1297
+ *
1298
+ * @param fadeType - The fade type (0 = fade out, 1 = fade in).
1299
+ */
1300
+ audioFade(fadeType: number): Promise<void>;
1301
+ /**
1302
+ * Wakes the device from sleep via the DataStream.
1303
+ */
1304
+ wake(): Promise<void>;
1305
+ /**
1306
+ * Requests the playback queue from the device.
1307
+ *
1308
+ * @param length - Maximum number of queue items to retrieve.
1309
+ */
1310
+ requestPlaybackQueue(length: number): Promise<void>;
1311
+ /**
1312
+ * Sends a raw MRP command to the device via the DataStream.
1313
+ *
1314
+ * @param command - The command to send.
1315
+ * @param options - Optional command options.
1316
+ */
1317
+ sendCommand(command: Proto$1.Command, options?: Proto$1.CommandOptions): Promise<void>;
1318
+ /**
1319
+ * Sets the pairing credentials for pair-verify authentication.
1320
+ * Must be called before connect() if credential-based pairing is desired.
1321
+ *
1322
+ * @param credentials - The accessory credentials obtained from pair-setup.
1323
+ */
1324
+ setCredentials(credentials: AccessoryCredentials$1): void;
1325
+ /**
1326
+ * Handles the control stream close event. Emits 'disconnected' with unexpected=true if not intentional.
1327
+ */
1328
+ onClose(): void;
1329
+ /**
1330
+ * Handles stream error events by logging them.
1331
+ *
1332
+ * @param err - The error that occurred.
1333
+ */
1334
+ onError(err: Error): void;
1335
+ /**
1336
+ * Handles now-playing changes to auto-fetch artwork on track changes.
1337
+ */
1338
+ onNowPlayingChanged(_client: any, player: any): void;
1339
+ /**
1340
+ * Handles stream timeout events by destroying the control stream.
1341
+ */
1342
+ onTimeout(): void;
1343
+ }
1344
+ //#endregion
1345
+ //#region src/internal/airplay-artwork.d.ts
1346
+ /**
1347
+ * Artwork result from the unified artwork API.
1348
+ * Always contains at least one of `url` or `data`.
1349
+ */
1350
+ type ArtworkResult = {
1351
+ /**
1352
+ * Direct URL to the artwork image (preferred for web/UI rendering).
1353
+ */
1354
+ readonly url: string | null;
1355
+ /**
1356
+ * Raw image bytes (available when artwork is embedded or fetched from playback queue).
1357
+ */
1358
+ readonly data: Uint8Array | null;
1359
+ /**
1360
+ * MIME type of the artwork (e.g. 'image/jpeg', 'image/png').
1361
+ */
1362
+ readonly mimeType: string;
1363
+ /**
1364
+ * The artwork identifier used for change detection.
1365
+ */
1366
+ readonly identifier: string | null;
1367
+ /**
1368
+ * Width of the artwork in pixels (0 if unknown).
1369
+ */
1370
+ readonly width: number;
1371
+ /**
1372
+ * Height of the artwork in pixels (0 if unknown).
1373
+ */
1374
+ readonly height: number;
1375
+ };
1376
+ /**
1377
+ * Unified artwork controller for an AirPlay device.
1378
+ *
1379
+ * Provides a single `get()` method that resolves artwork from all available
1380
+ * sources in priority order:
1381
+ * 1. URL from now-playing metadata (artworkURL, remoteArtworks, template)
1382
+ * 2. Inline binary data from the playback queue (artworkData, dataArtworks)
1383
+ * 3. JPEG data from SET_ARTWORK_MESSAGE
1384
+ * 4. Fetches the playback queue if artwork is expected but not yet available
1385
+ */
1386
+ declare class AirPlayArtwork {
1387
+ #private;
1388
+ constructor(device: AirPlayManager);
1389
+ /**
1390
+ * Gets the current artwork for the active now-playing item.
1391
+ *
1392
+ * Tries all available sources in priority order and returns a unified result.
1393
+ * Results are cached by artwork identifier — subsequent calls for the same
1394
+ * track return the cached result without additional requests.
1395
+ *
1396
+ * @param width - Desired artwork width in pixels (default: 600).
1397
+ * @param height - Desired artwork height in pixels (-1 for proportional).
1398
+ * @returns The artwork result, or null if no artwork is available.
1399
+ */
1400
+ get(width?: number, height?: number): Promise<ArtworkResult | null>;
1401
+ /**
1402
+ * Clears the cached artwork, forcing a fresh fetch on the next `get()` call.
1403
+ */
1404
+ clear(): void;
1405
+ }
1406
+ //#endregion
1407
+ //#region src/internal/companion-link-state.d.ts
1408
+ /**
1409
+ * Events emitted by CompanionLinkState.
1410
+ * Provides reactive state updates from the Companion Link protocol.
1411
+ */
1412
+ type EventMap$1 = {
1413
+ readonly attentionStateChanged: [AttentionState$1];
1414
+ readonly mediaControlFlagsChanged: [flags: number, capabilities: MediaCapabilities];
1415
+ readonly nowPlayingInfoChanged: [info: Record<string, unknown> | null];
1416
+ readonly supportedActionsChanged: [actions: Record<string, unknown>];
1417
+ readonly textInputChanged: [TextInputState$1];
1418
+ readonly volumeAvailabilityChanged: [available: boolean];
1419
+ };
1420
+ /**
1421
+ * Parsed media control capabilities, indicating which playback controls
1422
+ * are currently available on the device.
1423
+ */
1424
+ type MediaCapabilities = {
1425
+ readonly play: boolean;
1426
+ readonly pause: boolean;
1427
+ readonly nextTrack: boolean;
1428
+ readonly previousTrack: boolean;
1429
+ readonly fastForward: boolean;
1430
+ readonly rewind: boolean;
1431
+ readonly volume: boolean;
1432
+ readonly skipForward: boolean;
1433
+ readonly skipBackward: boolean;
1434
+ };
1435
+ /**
1436
+ * Tracks the state of a Companion Link device: attention state, media controls,
1437
+ * now-playing info, supported actions, text input, and volume availability.
1438
+ * Subscribes to protocol stream events and emits typed state change events.
1439
+ */
1440
+ declare class CompanionLinkState extends EventEmitter<EventMap$1> {
1441
+ #private;
1442
+ /**
1443
+ * Current attention state of the device (active, idle, screensaver, etc.).
1444
+ */
1445
+ get attentionState(): AttentionState$1;
1446
+ /**
1447
+ * Parsed media capabilities indicating which controls are available.
1448
+ */
1449
+ get mediaCapabilities(): MediaCapabilities;
1450
+ /**
1451
+ * Raw media control flags bitmask from the device.
1452
+ */
1453
+ get mediaControlFlags(): number;
1454
+ /**
1455
+ * Current now-playing info as a key-value dictionary, or null.
1456
+ */
1457
+ get nowPlayingInfo(): Record<string, unknown> | null;
1458
+ /**
1459
+ * Currently supported actions dictionary, or null.
1460
+ */
1461
+ get supportedActions(): Record<string, unknown> | null;
1462
+ /**
1463
+ * Current text input session state.
1464
+ */
1465
+ get textInputState(): TextInputState$1;
1466
+ /**
1467
+ * Whether volume control is currently available via the Companion Link protocol.
1468
+ */
1469
+ get volumeAvailable(): boolean;
1470
+ /**
1471
+ * Creates a new CompanionLinkState tracker.
1472
+ *
1473
+ * @param protocol - The Companion Link protocol instance to observe.
1474
+ */
1475
+ constructor(protocol: Protocol$1);
1476
+ /**
1477
+ * Subscribes to protocol stream events and registers interests for push notifications.
1478
+ */
1479
+ subscribe(): void;
1480
+ /**
1481
+ * Unsubscribes from protocol stream events and deregisters interests.
1482
+ */
1483
+ unsubscribe(): void;
1484
+ /**
1485
+ * Fetches the initial attention state and media control status from the device.
1486
+ */
1487
+ fetchInitialState(): Promise<void>;
1488
+ /**
1489
+ * Resets all state to initial/default values.
1490
+ */
1491
+ clear(): void;
1492
+ /**
1493
+ * Handles media control flag updates (_iMC). Parses the flags bitmask and
1494
+ * emits events if capabilities or volume availability changed.
1495
+ *
1496
+ * @param data - The raw media control payload.
1497
+ */
1498
+ onMediaControl(data: unknown): void;
1499
+ /**
1500
+ * Handles SystemStatus events (attention state changes from non-TV devices).
1501
+ *
1502
+ * @param data - The raw system status payload containing a state code.
1503
+ */
1504
+ onSystemStatus(data: unknown): void;
1505
+ /**
1506
+ * Handles TVSystemStatus events (attention state changes from Apple TV).
1507
+ *
1508
+ * @param data - The raw TV system status payload containing a state code.
1509
+ */
1510
+ onTVSystemStatus(data: unknown): void;
1511
+ /**
1512
+ * Handles NowPlayingInfo updates. Decodes the NSKeyedArchiver plist payload
1513
+ * when present, otherwise uses the raw dictionary.
1514
+ *
1515
+ * @param data - The raw now-playing info payload.
1516
+ */
1517
+ onNowPlayingInfo(data: unknown): void;
1518
+ /**
1519
+ * Handles SupportedActions updates from the device.
1520
+ *
1521
+ * @param data - The raw supported actions payload.
1522
+ */
1523
+ onSupportedActions(data: unknown): void;
1524
+ /**
1525
+ * Handles the start of a text input session. Parses the plist payload to extract
1526
+ * document text, security mode, keyboard type, and autocorrection settings.
1527
+ *
1528
+ * @param data - The raw text input started payload.
1529
+ */
1530
+ onTextInputStarted(data: unknown): void;
1531
+ /**
1532
+ * Handles the end of a text input session. Resets the text input state to defaults.
1533
+ *
1534
+ * @param _data - The raw text input stopped payload (unused).
1535
+ */
1536
+ onTextInputStopped(_data: unknown): void;
1537
+ }
1538
+ //#endregion
1539
+ //#region src/internal/companion-link-manager.d.ts
1540
+ /**
1541
+ * Events emitted by CompanionLinkDevice.
1542
+ * Forwards state change events from CompanionLinkState for convenience.
1543
+ */
1544
+ type EventMap = {
1545
+ connected: [];
1546
+ disconnected: [unexpected: boolean];
1547
+ attentionStateChanged: [AttentionState$1];
1548
+ mediaControlFlagsChanged: [flags: number, capabilities: MediaCapabilities];
1549
+ nowPlayingInfoChanged: [info: Record<string, unknown> | null];
1550
+ supportedActionsChanged: [actions: Record<string, unknown>];
1551
+ textInputChanged: [TextInputState$1];
1552
+ volumeAvailabilityChanged: [available: boolean];
1553
+ };
1554
+ /**
1555
+ * High-level abstraction for a Companion Link device (Apple TV).
1556
+ * Manages the OPack-based Companion Link protocol lifecycle: connect, pair-verify,
1557
+ * session setup, and provides access to HID buttons, app launching, user accounts,
1558
+ * media control, text input, touch, Siri, and system controls.
1559
+ * Requires credentials (obtained from pair-setup) to connect.
1560
+ */
1561
+ declare class CompanionLinkManager extends EventEmitter<EventMap> {
1562
+ #private;
1563
+ /**
1564
+ * @returns The underlying Companion Link Protocol instance (accessed via symbol for internal use).
1565
+ */
1566
+ get [COMPANION_LINK_PROTOCOL](): Protocol$1;
1567
+ /**
1568
+ * The mDNS discovery result used to connect to this device.
1569
+ */
1570
+ get discoveryResult(): DiscoveryResult$1;
1571
+ /**
1572
+ * Updates the discovery result, e.g. when the device's address changes.
1573
+ */
1574
+ set discoveryResult(discoveryResult: DiscoveryResult$1);
1575
+ /**
1576
+ * Whether the Companion Link stream is currently connected.
1577
+ */
1578
+ get isConnected(): boolean;
1579
+ /**
1580
+ * The state tracker for attention, media controls, now-playing, and text input.
1581
+ */
1582
+ get state(): CompanionLinkState;
1583
+ /**
1584
+ * Current text input session state (convenience accessor).
1585
+ */
1586
+ get textInputState(): TextInputState$1;
1587
+ /**
1588
+ * Creates a new CompanionLinkDevice.
1589
+ *
1590
+ * @param discoveryResult - The mDNS discovery result for the target device.
1591
+ */
1592
+ constructor(discoveryResult: DiscoveryResult$1);
1593
+ /**
1594
+ * Connects to the Companion Link device, performs pair-verify, and sets up
1595
+ * all protocol sessions (system info, TVRC, touch, text input).
1596
+ * Emits 'connected' on success.
1597
+ *
1598
+ * @throws CredentialsError when no credentials are set.
1599
+ */
1600
+ connect(): Promise<void>;
1601
+ /**
1602
+ * Gracefully disconnects from the device, clears heartbeat interval, and unsubscribes from events.
1603
+ */
1604
+ disconnect(): Promise<void>;
1605
+ /**
1606
+ * Disconnects gracefully, swallowing any errors during cleanup.
1607
+ */
1608
+ disconnectSafely(): Promise<void>;
1609
+ /**
1610
+ * Sets the pairing credentials required for pair-verify authentication.
1611
+ * Must be called before connect().
1612
+ *
1613
+ * @param credentials - The accessory credentials from pair-setup.
1614
+ */
1615
+ setCredentials(credentials: AccessoryCredentials$1): Promise<void>;
1616
+ /**
1617
+ * Fetches the current attention state of the device (active, idle, screensaver, etc.).
1618
+ *
1619
+ * @returns The current attention state.
1620
+ */
1621
+ getAttentionState(): Promise<AttentionState$1>;
1622
+ /**
1623
+ * Fetches the list of apps that can be launched on the device.
1624
+ *
1625
+ * @returns Array of launchable app descriptors.
1626
+ */
1627
+ getLaunchableApps(): Promise<LaunchableApp[]>;
1628
+ /**
1629
+ * Fetches the list of user accounts configured on the device.
1630
+ *
1631
+ * @returns Array of user account descriptors.
1632
+ */
1633
+ getUserAccounts(): Promise<UserAccount[]>;
1634
+ /**
1635
+ * Fetches the current now-playing information from the device.
1636
+ *
1637
+ * @returns The now-playing info payload.
1638
+ */
1639
+ fetchNowPlayingInfo(): Promise<any>;
1640
+ /**
1641
+ * Fetches the currently supported actions from the device.
1642
+ *
1643
+ * @returns The supported actions payload.
1644
+ */
1645
+ fetchSupportedActions(): Promise<any>;
1646
+ /**
1647
+ * Fetches the current media control status (available controls bitmask).
1648
+ *
1649
+ * @returns The media control status payload.
1650
+ */
1651
+ fetchMediaControlStatus(): Promise<any>;
1652
+ /**
1653
+ * Launches an app on the device by its bundle identifier.
1654
+ *
1655
+ * @param bundleId - The bundle identifier of the app to launch.
1656
+ */
1657
+ launchApp(bundleId: string): Promise<void>;
1658
+ /**
1659
+ * Opens a URL on the device (universal link or app-specific URL scheme).
1660
+ *
1661
+ * @param url - The URL to open.
1662
+ */
1663
+ launchUrl(url: string): Promise<void>;
1664
+ /**
1665
+ * Sends a media control command (play, pause, next, etc.) via the Companion Link protocol.
1666
+ *
1667
+ * @param command - The media control command key.
1668
+ * @param content - Optional additional content for the command.
1669
+ */
1670
+ mediaControlCommand(command: MediaControlCommandKey, content?: Record<string, unknown>): Promise<void>;
1671
+ /**
1672
+ * Sends a HID button press via the Companion Link protocol.
1673
+ *
1674
+ * @param command - The HID command key (e.g. 'up', 'select', 'menu').
1675
+ * @param type - Optional press type (short, long, double).
1676
+ * @param holdDelayMs - Optional hold duration in milliseconds for long presses.
1677
+ */
1678
+ pressButton(command: HidCommandKey, type?: ButtonPressType, holdDelayMs?: number): Promise<void>;
1679
+ /**
1680
+ * Switches to a different user account on the device.
1681
+ *
1682
+ * @param accountId - The ID of the user account to switch to.
1683
+ */
1684
+ switchUserAccount(accountId: string): Promise<void>;
1685
+ /**
1686
+ * Sets the text input field to the given text, replacing any existing content.
1687
+ *
1688
+ * @param text - The text to set.
1689
+ */
1690
+ textSet(text: string): Promise<void>;
1691
+ /**
1692
+ * Appends text to the current text input field content.
1693
+ *
1694
+ * @param text - The text to append.
1695
+ */
1696
+ textAppend(text: string): Promise<void>;
1697
+ /**
1698
+ * Clears the text input field.
1699
+ */
1700
+ textClear(): Promise<void>;
1701
+ /**
1702
+ * Sends a raw touch event to the device.
1703
+ *
1704
+ * @param finger - Finger index (0-based).
1705
+ * @param phase - Touch phase (0 = Began, 1 = Moved, 2 = Ended).
1706
+ * @param x - Horizontal position.
1707
+ * @param y - Vertical position.
1708
+ */
1709
+ sendTouchEvent(finger: number, phase: number, x: number, y: number): Promise<void>;
1710
+ /**
1711
+ * Simulates a tap at the given coordinates.
1712
+ *
1713
+ * @param x - Horizontal position (defaults to center 500).
1714
+ * @param y - Vertical position (defaults to center 500).
1715
+ */
1716
+ tap(x?: number, y?: number): Promise<void>;
1717
+ /**
1718
+ * Simulates a swipe gesture in the given direction.
1719
+ *
1720
+ * @param direction - Swipe direction.
1721
+ * @param duration - Swipe duration in milliseconds (defaults to 200).
1722
+ */
1723
+ swipe(direction: 'up' | 'down' | 'left' | 'right', duration?: number): Promise<void>;
1724
+ /**
1725
+ * Toggles closed captions on the device.
1726
+ */
1727
+ toggleCaptions(): Promise<void>;
1728
+ /**
1729
+ * Toggles the system appearance between light and dark mode.
1730
+ *
1731
+ * @param light - True for light mode, false for dark mode.
1732
+ */
1733
+ toggleSystemAppearance(light: boolean): Promise<void>;
1734
+ /**
1735
+ * Enables or disables the "Reduce Loud Sounds" setting.
1736
+ *
1737
+ * @param enabled - Whether to enable the setting.
1738
+ */
1739
+ toggleReduceLoudSounds(enabled: boolean): Promise<void>;
1740
+ /**
1741
+ * Enables or disables finding mode (Find My integration).
1742
+ *
1743
+ * @param enabled - Whether to enable finding mode.
1744
+ */
1745
+ toggleFindingMode(enabled: boolean): Promise<void>;
1746
+ /**
1747
+ * Fetches the "Up Next" queue from the device.
1748
+ *
1749
+ * @param paginationToken - Optional token for paginated results.
1750
+ * @returns The Up Next queue payload.
1751
+ */
1752
+ fetchUpNext(paginationToken?: string): Promise<any>;
1753
+ /**
1754
+ * Adds an item to the "Up Next" queue.
1755
+ *
1756
+ * @param identifier - Content item identifier.
1757
+ * @param kind - Content kind descriptor.
1758
+ */
1759
+ addToUpNext(identifier: string, kind: string): Promise<void>;
1760
+ /**
1761
+ * Removes an item from the "Up Next" queue.
1762
+ *
1763
+ * @param identifier - Content item identifier.
1764
+ * @param kind - Content kind descriptor.
1765
+ */
1766
+ removeFromUpNext(identifier: string, kind: string): Promise<void>;
1767
+ /**
1768
+ * Marks a content item as watched.
1769
+ *
1770
+ * @param identifier - Content item identifier.
1771
+ * @param kind - Content kind descriptor.
1772
+ */
1773
+ markAsWatched(identifier: string, kind: string): Promise<void>;
1774
+ /**
1775
+ * Starts a Siri session on the device.
1776
+ */
1777
+ siriStart(): Promise<void>;
1778
+ /**
1779
+ * Stops the active Siri session on the device.
1780
+ */
1781
+ siriStop(): Promise<void>;
1782
+ /**
1783
+ * Handles the stream close event. Emits 'disconnected' with unexpected=true if not intentional.
1784
+ */
1785
+ onClose(): void;
1786
+ /**
1787
+ * Handles stream error events by logging them.
1788
+ *
1789
+ * @param err - The error that occurred.
1790
+ */
1791
+ onError(err: Error): void;
1792
+ /**
1793
+ * Handles stream timeout events by destroying the stream.
1794
+ */
1795
+ onTimeout(): void;
1796
+ }
1797
+ //#endregion
1798
+ //#region src/controller/accounts.d.ts
1799
+ /**
1800
+ * User account controller for Apple TV devices.
1801
+ * Provides user account listing and switching.
1802
+ */
1803
+ declare class AccountsController {
1804
+ #private;
1805
+ constructor(companionLink: CompanionLinkManager);
1806
+ /**
1807
+ * Returns the list of user accounts configured on the device.
1808
+ */
1809
+ list(): Promise<UserAccount[]>;
1810
+ /**
1811
+ * Switches to a different user account.
1812
+ *
1813
+ * @param accountId - The account ID to switch to.
1814
+ */
1815
+ switch(accountId: string): Promise<void>;
1816
+ }
1817
+ //#endregion
1818
+ //#region src/controller/apps.d.ts
1819
+ /**
1820
+ * App management controller for Apple TV devices.
1821
+ * Provides app launching and URL opening.
1822
+ */
1823
+ declare class AppsController {
1824
+ #private;
1825
+ constructor(companionLink: CompanionLinkManager);
1826
+ /**
1827
+ * Returns the list of apps that can be launched on the device.
1828
+ */
1829
+ list(): Promise<LaunchableApp[]>;
1830
+ /**
1831
+ * Launches an app by its bundle identifier.
1832
+ *
1833
+ * @param bundleId - The bundle identifier (e.g. 'com.netflix.Netflix').
1834
+ */
1835
+ launch(bundleId: string): Promise<void>;
1836
+ /**
1837
+ * Opens a URL on the device (universal link or app-specific URL scheme).
1838
+ *
1839
+ * @param url - The URL to open.
1840
+ */
1841
+ openUrl(url: string): Promise<void>;
1842
+ }
1843
+ //#endregion
1844
+ //#region src/controller/artwork.d.ts
1845
+ /**
1846
+ * Artwork controller for Apple devices.
1847
+ * Resolves artwork from all available sources with a 4-tier fallback.
1848
+ */
1849
+ declare class ArtworkController {
1850
+ #private;
1851
+ constructor(airplay: AirPlayManager);
1852
+ /**
1853
+ * Gets the current artwork for the active now-playing item.
1854
+ *
1855
+ * @param width - Desired width in pixels (default: 600).
1856
+ * @param height - Desired height in pixels (-1 for proportional).
1857
+ * @returns Artwork result with url, data, or both.
1858
+ */
1859
+ get(width?: number, height?: number): Promise<ArtworkResult | null>;
1860
+ }
1861
+ //#endregion
1862
+ //#region src/controller/keyboard.d.ts
1863
+ /**
1864
+ * Text input controller for Apple TV devices.
1865
+ * Provides keyboard control when a text field is active on the device.
1866
+ */
1867
+ declare class KeyboardController {
1868
+ #private;
1869
+ constructor(airplay: AirPlayManager);
1870
+ /**
1871
+ * Sets the text input field to the given text, replacing any existing content.
1872
+ */
1873
+ type(text: string): Promise<void>;
1874
+ /**
1875
+ * Appends text to the current text input field content.
1876
+ */
1877
+ append(text: string): Promise<void>;
1878
+ /**
1879
+ * Clears the text input field.
1880
+ */
1881
+ clear(): Promise<void>;
1882
+ /**
1883
+ * Fetches the current keyboard session state.
1884
+ */
1885
+ getSession(): Promise<any>;
1886
+ }
1887
+ //#endregion
1888
+ //#region src/controller/media.d.ts
1889
+ /**
1890
+ * Media source controller for Apple devices.
1891
+ * Provides URL playback (device fetches and plays) and audio streaming (client sends PCM via RTP).
1892
+ */
1893
+ declare class MediaController {
1894
+ #private;
1895
+ constructor(airplay: AirPlayManager);
1896
+ /**
1897
+ * Plays a URL on the device. The device fetches and plays the content.
1898
+ * Creates a separate protocol session to avoid conflicting with remote control.
1899
+ *
1900
+ * @param url - The media URL to play.
1901
+ * @param position - Start position in seconds (default: 0).
1902
+ */
1903
+ playUrl(url: string, position?: number): Promise<void>;
1904
+ /**
1905
+ * Stops the current URL playback.
1906
+ */
1907
+ stopPlayUrl(): void;
1908
+ /**
1909
+ * Waits for the current URL playback to end naturally.
1910
+ */
1911
+ waitForPlaybackEnd(): Promise<void>;
1912
+ /**
1913
+ * Streams audio from a source to the device via RAOP/RTP.
1914
+ * Creates a separate protocol session to avoid conflicting with remote control.
1915
+ *
1916
+ * @param source - The audio source to stream (MP3, OGG, WAV, PCM, FFmpeg, URL, live).
1917
+ */
1918
+ streamAudio(source: AudioSource): Promise<void>;
1919
+ /**
1920
+ * Stops the current audio stream.
1921
+ */
1922
+ stopStreamAudio(): void;
1923
+ /**
1924
+ * Requests lyrics for the current playback.
1925
+ *
1926
+ * @param length - Maximum number of lyrics items to retrieve.
1927
+ */
1928
+ requestLyrics(length?: number): Promise<void>;
1929
+ }
1930
+ //#endregion
1931
+ //#region src/controller/multiroom.d.ts
1932
+ /**
1933
+ * Multi-room / cluster controller for Apple devices.
1934
+ * Manages output device groups for multi-room audio.
1935
+ */
1936
+ declare class MultiroomController {
1937
+ #private;
1938
+ constructor(airplay: AirPlayManager);
1939
+ /**
1940
+ * The cluster ID if the device is part of a multi-room group, or null.
1941
+ */
1942
+ get clusterId(): string | null;
1943
+ /**
1944
+ * Whether this device is the leader of its multi-room cluster.
1945
+ */
1946
+ get isLeader(): boolean;
1947
+ /**
1948
+ * Whether this device is aware of cluster functionality.
1949
+ */
1950
+ get isClusterAware(): boolean;
1951
+ /**
1952
+ * Adds devices to the current multi-room output context.
1953
+ *
1954
+ * @param deviceUIDs - UIDs of devices to add.
1955
+ */
1956
+ addDevice(...deviceUIDs: string[]): Promise<void>;
1957
+ /**
1958
+ * Removes devices from the current multi-room output context.
1959
+ *
1960
+ * @param deviceUIDs - UIDs of devices to remove.
1961
+ */
1962
+ removeDevice(...deviceUIDs: string[]): Promise<void>;
1963
+ /**
1964
+ * Replaces the entire multi-room output context.
1965
+ *
1966
+ * @param deviceUIDs - UIDs of devices to set as the output context.
1967
+ */
1968
+ setDevices(...deviceUIDs: string[]): Promise<void>;
1969
+ }
1970
+ //#endregion
1971
+ //#region src/controller/playback.d.ts
1972
+ /**
1973
+ * Media playback controller for Apple devices.
1974
+ * Provides play/pause/next/seek and other media commands via SendCommand (MRP protocol).
1975
+ */
1976
+ declare class PlaybackController {
1977
+ #private;
1978
+ constructor(airplay: AirPlayManager);
1979
+ play(): Promise<void>;
1980
+ pause(): Promise<void>;
1981
+ playPause(): Promise<void>;
1982
+ stop(): Promise<void>;
1983
+ next(): Promise<void>;
1984
+ previous(): Promise<void>;
1985
+ skipForward(seconds?: number): Promise<void>;
1986
+ skipBackward(seconds?: number): Promise<void>;
1987
+ seekTo(position: number): Promise<void>;
1988
+ setShuffleMode(mode: Proto$1.ShuffleMode_Enum): Promise<void>;
1989
+ setRepeatMode(mode: Proto$1.RepeatMode_Enum): Promise<void>;
1990
+ advanceShuffleMode(): Promise<void>;
1991
+ advanceRepeatMode(): Promise<void>;
1992
+ setPlaybackRate(rate: number): Promise<void>;
1993
+ setSleepTimer(seconds: number, stopMode?: number): Promise<void>;
1994
+ beginFastForward(): Promise<void>;
1995
+ endFastForward(): Promise<void>;
1996
+ beginRewind(): Promise<void>;
1997
+ endRewind(): Promise<void>;
1998
+ nextChapter(): Promise<void>;
1999
+ previousChapter(): Promise<void>;
2000
+ likeTrack(): Promise<void>;
2001
+ dislikeTrack(): Promise<void>;
2002
+ bookmarkTrack(): Promise<void>;
2003
+ addToLibrary(): Promise<void>;
2004
+ /**
2005
+ * Requests the playback queue from the device (includes artwork and metadata).
2006
+ *
2007
+ * @param length - Maximum number of queue items to retrieve (default: 1).
2008
+ */
2009
+ requestPlaybackQueue(length?: number): Promise<void>;
2010
+ /**
2011
+ * Checks whether a playback command is currently supported by the active media app.
2012
+ */
2013
+ isCommandSupported(command: Proto$1.Command): boolean;
2014
+ }
2015
+ //#endregion
2016
+ //#region src/controller/power.d.ts
2017
+ /**
2018
+ * Power management controller for Apple TV devices.
2019
+ * Provides power on/off and attention state queries.
2020
+ */
2021
+ declare class PowerController {
2022
+ #private;
2023
+ constructor(airplay: AirPlayManager, companionLink: CompanionLinkManager);
2024
+ /**
2025
+ * Turns on the device (sends wake HID key).
2026
+ */
2027
+ on(): Promise<void>;
2028
+ /**
2029
+ * Turns off the device (sends suspend HID key).
2030
+ */
2031
+ off(): Promise<void>;
2032
+ /**
2033
+ * Gets the current attention state of the device.
2034
+ *
2035
+ * @returns The attention state ('active', 'idle', 'screensaver', etc.).
2036
+ */
2037
+ getState(): Promise<AttentionState$1>;
2038
+ }
2039
+ //#endregion
2040
+ //#region src/controller/remote.d.ts
2041
+ /**
2042
+ * Remote controller for Apple devices.
2043
+ * Provides all HID-based keys (navigation, media, volume, power),
2044
+ * touch/swipe gestures, and low-level HID primitives.
2045
+ */
2046
+ declare class RemoteController {
2047
+ #private;
2048
+ constructor(airplay: AirPlayManager);
2049
+ up(): Promise<void>;
2050
+ down(): Promise<void>;
2051
+ left(): Promise<void>;
2052
+ right(): Promise<void>;
2053
+ select(): Promise<void>;
2054
+ menu(): Promise<void>;
2055
+ home(): Promise<void>;
2056
+ topMenu(): Promise<void>;
2057
+ play(): Promise<void>;
2058
+ pause(): Promise<void>;
2059
+ playPause(): Promise<void>;
2060
+ stop(): Promise<void>;
2061
+ next(): Promise<void>;
2062
+ previous(): Promise<void>;
2063
+ channelUp(): Promise<void>;
2064
+ channelDown(): Promise<void>;
2065
+ volumeUp(): Promise<void>;
2066
+ volumeDown(): Promise<void>;
2067
+ mute(): Promise<void>;
2068
+ wake(): Promise<void>;
2069
+ suspend(): Promise<void>;
2070
+ tap(x: number, y: number, finger?: number): Promise<void>;
2071
+ swipe(direction: 'up' | 'down' | 'left' | 'right', duration?: number): Promise<void>;
2072
+ pressAndRelease(usePage: number, usage: number): Promise<void>;
2073
+ longPress(usePage: number, usage: number, duration?: number): Promise<void>;
2074
+ doublePress(usePage: number, usage: number): Promise<void>;
2075
+ }
2076
+ //#endregion
2077
+ //#region src/types.d.ts
2078
+ /**
2079
+ * Device type identifier used in discovery results.
2080
+ */
2081
+ type DeviceType = 'appletv' | 'homepod' | 'homepod-mini' | 'unknown';
2082
+ /**
2083
+ * Device-level events shared by all device types.
2084
+ */
2085
+ type DeviceEventMap = {
2086
+ connected: [];
2087
+ disconnected: [unexpected: boolean];
2088
+ recovering: [attempt: number];
2089
+ recoveryFailed: [];
2090
+ };
2091
+ /**
2092
+ * Additional events emitted by Apple TV devices.
2093
+ */
2094
+ type AppleTVEventMap = DeviceEventMap & {
2095
+ power: [state: AttentionState$1];
2096
+ textInput: [state: TextInputState$1];
2097
+ };
2098
+ /**
2099
+ * Events emitted by the state controller.
2100
+ */
2101
+ type StateEventMap = {
2102
+ nowPlayingChanged: [client: AirPlayClient | null, player: AirPlayPlayer | null];
2103
+ playbackStateChanged: [client: AirPlayClient, player: AirPlayPlayer, oldState: Proto$1.PlaybackState_Enum, newState: Proto$1.PlaybackState_Enum];
2104
+ volumeChanged: [volume: number];
2105
+ volumeMutedChanged: [muted: boolean];
2106
+ artworkChanged: [client: AirPlayClient, player: AirPlayPlayer];
2107
+ activeAppChanged: [bundleIdentifier: string | null, displayName: string | null];
2108
+ supportedCommandsChanged: [client: AirPlayClient, player: AirPlayPlayer, commands: Proto$1.CommandInfo[]];
2109
+ clusterChanged: [clusterId: string | null, isLeader: boolean];
2110
+ };
2111
+ /**
2112
+ * Connection recovery options.
2113
+ */
2114
+ type RecoveryOptions = {
2115
+ /**
2116
+ * Maximum number of reconnection attempts. Default: 3.
2117
+ */
2118
+ readonly maxAttempts?: number;
2119
+ /**
2120
+ * Base delay in milliseconds for exponential backoff. Default: 1000.
2121
+ */
2122
+ readonly baseDelay?: number;
2123
+ /**
2124
+ * Interval in milliseconds between periodic reconnection attempts. 0 = disabled. Default: 900000 (15 min).
2125
+ */
2126
+ readonly reconnectInterval?: number;
2127
+ };
2128
+ /**
2129
+ * Options passed to device.connect().
2130
+ */
2131
+ type ConnectOptions = {
2132
+ /**
2133
+ * Connection recovery configuration. Set to false to disable recovery.
2134
+ */
2135
+ readonly recovery?: RecoveryOptions | false;
2136
+ };
2137
+ /**
2138
+ * Device construction options.
2139
+ */
2140
+ type DeviceOptions = {
2141
+ /**
2142
+ * IP address of the device.
2143
+ */
2144
+ readonly address?: string;
2145
+ /**
2146
+ * Pre-discovered AirPlay service result.
2147
+ */
2148
+ readonly airplay?: _$_basmilius_apple_common0.DiscoveryResult;
2149
+ /**
2150
+ * Pre-discovered Companion Link service result (Apple TV only).
2151
+ */
2152
+ readonly companionLink?: _$_basmilius_apple_common0.DiscoveryResult;
2153
+ /**
2154
+ * Custom device identity to present during pairing.
2155
+ */
2156
+ readonly identity?: Partial<_$_basmilius_apple_common0.DeviceIdentity>;
2157
+ /**
2158
+ * Timing server for multi-room / audio streaming.
2159
+ */
2160
+ readonly timingServer?: _$_basmilius_apple_common0.TimingServer;
2161
+ };
2162
+ //#endregion
2163
+ //#region src/controller/state.d.ts
2164
+ /**
2165
+ * Now-playing state controller.
2166
+ * Provides read-only getters for the current playback state and emits
2167
+ * typed events when state changes occur.
2168
+ */
2169
+ declare class StateController extends EventEmitter<StateEventMap> {
2170
+ #private;
2171
+ constructor(airplay: AirPlayManager);
2172
+ get title(): string;
2173
+ get artist(): string;
2174
+ get album(): string;
2175
+ get genre(): string;
2176
+ get duration(): number;
2177
+ get elapsedTime(): number;
2178
+ get playbackRate(): number;
2179
+ get isPlaying(): boolean;
2180
+ get playbackState(): Proto$1.PlaybackState_Enum | undefined;
2181
+ get mediaType(): Proto$1.ContentItemMetadata_MediaType | undefined;
2182
+ get shuffleMode(): Proto$1.ShuffleMode_Enum | undefined;
2183
+ get repeatMode(): Proto$1.RepeatMode_Enum | undefined;
2184
+ get activeApp(): {
2185
+ bundleIdentifier: string;
2186
+ displayName: string;
2187
+ } | null;
2188
+ get volume(): number;
2189
+ get isMuted(): boolean;
2190
+ get volumeAvailable(): boolean;
2191
+ get isKeyboardActive(): boolean;
2192
+ get clusterId(): string | null;
2193
+ get isClusterLeader(): boolean;
2194
+ get outputDevices(): Proto$1.AVOutputDeviceDescriptor[];
2195
+ get clients(): Record<string, AirPlayClient>;
2196
+ get activeClient(): AirPlayClient | null;
2197
+ get activePlayer(): AirPlayPlayer | null;
2198
+ isCommandSupported(command: Proto$1.Command): boolean;
2199
+ getCommandInfo(command: Proto$1.Command): Proto$1.CommandInfo | null;
2200
+ /**
2201
+ * Subscribes to the underlying AirPlayState events and re-emits them.
2202
+ * Called internally by the device after connection is established.
2203
+ * @internal
2204
+ */
2205
+ subscribe(): void;
2206
+ /**
2207
+ * Removes all event listeners from this controller.
2208
+ * @internal
2209
+ */
2210
+ unsubscribe(): void;
2211
+ }
2212
+ //#endregion
2213
+ //#region src/controller/system.d.ts
2214
+ /**
2215
+ * System controller for Apple TV devices.
2216
+ * Provides access to captions, appearance, Siri, and Up Next queue.
2217
+ */
2218
+ declare class SystemController {
2219
+ #private;
2220
+ constructor(companionLink: CompanionLinkManager);
2221
+ /**
2222
+ * Toggles closed captions on the device.
2223
+ */
2224
+ toggleCaptions(): Promise<void>;
2225
+ /**
2226
+ * Sets the system appearance.
2227
+ *
2228
+ * @param mode - 'light' or 'dark'.
2229
+ */
2230
+ setAppearance(mode: 'light' | 'dark'): Promise<void>;
2231
+ /**
2232
+ * Enables or disables the "Reduce Loud Sounds" setting.
2233
+ */
2234
+ setReduceLoudSounds(enabled: boolean): Promise<void>;
2235
+ /**
2236
+ * Enables or disables Find My mode.
2237
+ */
2238
+ setFindingMode(enabled: boolean): Promise<void>;
2239
+ /**
2240
+ * Starts a Siri session.
2241
+ */
2242
+ siriStart(): Promise<void>;
2243
+ /**
2244
+ * Stops the active Siri session.
2245
+ */
2246
+ siriStop(): Promise<void>;
2247
+ /**
2248
+ * Fetches the Up Next queue.
2249
+ *
2250
+ * @param paginationToken - Optional token for paginated results.
2251
+ */
2252
+ fetchUpNext(paginationToken?: string): Promise<any>;
2253
+ /**
2254
+ * Adds an item to the Up Next queue.
2255
+ */
2256
+ addToUpNext(identifier: string, kind: string): Promise<void>;
2257
+ /**
2258
+ * Removes an item from the Up Next queue.
2259
+ */
2260
+ removeFromUpNext(identifier: string, kind: string): Promise<void>;
2261
+ }
2262
+ //#endregion
2263
+ //#region src/controller/volume.d.ts
2264
+ /**
2265
+ * Volume controller for Apple devices.
2266
+ * Supports absolute volume (set level), relative volume (up/down),
2267
+ * muting, fading, and per-device volume in multi-room setups.
2268
+ */
2269
+ declare class VolumeController {
2270
+ #private;
2271
+ constructor(airplay: AirPlayManager);
2272
+ set(volume: number): Promise<void>;
2273
+ get(): Promise<number>;
2274
+ up(): Promise<void>;
2275
+ down(): Promise<void>;
2276
+ mute(): Promise<void>;
2277
+ unmute(): Promise<void>;
2278
+ toggleMute(): Promise<void>;
2279
+ fade(targetVolume: number, durationMs: number): Promise<void>;
2280
+ setForDevice(outputDeviceUID: string, volume: number): Promise<void>;
2281
+ getForDevice(outputDeviceUID: string): Promise<number>;
2282
+ muteDevice(outputDeviceUID: string): Promise<void>;
2283
+ unmuteDevice(outputDeviceUID: string): Promise<void>;
2284
+ adjust(adjustment: Proto$1.AdjustVolumeMessage_Adjustment, outputDeviceUID?: string): Promise<void>;
2285
+ }
2286
+ //#endregion
2287
+ //#region src/pairing/pairing-session.d.ts
2288
+ /**
2289
+ * Step-based pairing session for Apple TV devices.
2290
+ *
2291
+ * Provides a three-phase pairing flow suitable for external UI frameworks
2292
+ * (e.g., Homey's pairing wizard) where PIN entry happens asynchronously:
2293
+ *
2294
+ * ```ts
2295
+ * const session = tv.createPairingSession();
2296
+ * await session.start(); // Connects and triggers PIN dialog on TV
2297
+ * await session.pin('1234'); // Submits PIN, executes M1-M6
2298
+ * const credentials = await session.end(); // Returns credentials, cleans up
2299
+ * ```
2300
+ */
2301
+ declare class PairingSession {
2302
+ #private;
2303
+ constructor(discoveryResult: DiscoveryResult$1, identity?: Partial<DeviceIdentity>);
2304
+ /**
2305
+ * Connects to the device and triggers the PIN dialog.
2306
+ * After this method returns, the Apple TV displays a 4-digit PIN on screen.
2307
+ */
2308
+ start(): Promise<void>;
2309
+ /**
2310
+ * Submits the PIN and executes the M1-M6 key exchange.
2311
+ *
2312
+ * @param code - The 4-digit PIN displayed on the Apple TV screen.
2313
+ */
2314
+ pin(code: string): Promise<void>;
2315
+ /**
2316
+ * Finishes the pairing session, cleans up the protocol connection,
2317
+ * and returns the obtained credentials.
2318
+ *
2319
+ * @returns Long-term credentials for future connections.
2320
+ */
2321
+ end(): Promise<AccessoryCredentials$1>;
2322
+ /**
2323
+ * Aborts the pairing session and cleans up without returning credentials.
2324
+ * Use this when the user cancels pairing.
2325
+ */
2326
+ abort(): void;
2327
+ }
2328
+ //#endregion
2329
+ //#region src/pairing/types.d.ts
2330
+ /**
2331
+ * Options for the callback-based pair() convenience method.
2332
+ */
2333
+ type PairingOptions = {
2334
+ /**
2335
+ * Callback invoked when the device displays a PIN code. Must return the PIN as a string.
2336
+ */
2337
+ readonly onPinRequired: () => Promise<string>;
2338
+ };
2339
+ /**
2340
+ * Result of a successful pairing session.
2341
+ */
2342
+ type PairingResult = AccessoryCredentials$1;
2343
+ //#endregion
2344
+ //#region src/device/device.d.ts
2345
+ /**
2346
+ * Abstract base class for all Apple devices.
2347
+ * Provides shared controllers and lifecycle management.
2348
+ */
2349
+ declare abstract class AbstractDevice extends EventEmitter {
2350
+ #private;
2351
+ readonly remote: RemoteController;
2352
+ readonly playback: PlaybackController;
2353
+ readonly state: StateController;
2354
+ readonly volume: VolumeController;
2355
+ readonly artwork: ArtworkController;
2356
+ readonly media: MediaController;
2357
+ readonly multiroom: MultiroomController;
2358
+ constructor(options: DeviceOptions);
2359
+ /**
2360
+ * The unique identifier of the device (from mDNS discovery).
2361
+ */
2362
+ get id(): string;
2363
+ /**
2364
+ * The human-readable name of the device.
2365
+ */
2366
+ get name(): string;
2367
+ /**
2368
+ * The IP address of the device.
2369
+ */
2370
+ get address(): string;
2371
+ /**
2372
+ * Whether the device is currently connected.
2373
+ */
2374
+ get isConnected(): boolean;
2375
+ /**
2376
+ * Raw receiver info from the AirPlay /info endpoint.
2377
+ */
2378
+ get receiverInfo(): Record<string, any> | undefined;
2379
+ /**
2380
+ * AirPlay device capabilities (features supported by the receiver).
2381
+ */
2382
+ get capabilities(): {
2383
+ supportsAudio: boolean;
2384
+ supportsBufferedAudio: boolean;
2385
+ supportsPTP: boolean;
2386
+ supportsRFC2198Redundancy: boolean;
2387
+ supportsHangdogRemoteControl: boolean;
2388
+ supportsUnifiedMediaControl: boolean;
2389
+ supportsTransientPairing: boolean;
2390
+ supportsSystemPairing: boolean;
2391
+ supportsCoreUtilsPairing: boolean;
2392
+ };
2393
+ /**
2394
+ * Updates the discovery result (e.g. when the device's IP address changes).
2395
+ */
2396
+ set discoveryResult(result: DiscoveryResult$1);
2397
+ /**
2398
+ * Updates the timing server for multi-room audio sync.
2399
+ */
2400
+ set timingServer(server: TimingServer$1 | undefined);
2401
+ /**
2402
+ * The underlying AirPlay protocol manager.
2403
+ * Use this for low-level protocol access, raw state events, or features
2404
+ * not covered by the high-level controllers.
2405
+ */
2406
+ get airplay(): AirPlayManager;
2407
+ /**
2408
+ * Creates a step-based pairing session for interactive PIN entry flows.
2409
+ *
2410
+ * ```ts
2411
+ * const session = tv.createPairingSession();
2412
+ * await session.start(); // Connects and triggers PIN dialog
2413
+ * await session.pin('1234'); // Submits PIN, executes M1-M6
2414
+ * const creds = await session.end(); // Returns credentials, cleans up
2415
+ * ```
2416
+ */
2417
+ createPairingSession(): PairingSession;
2418
+ /**
2419
+ * Pairs with the device using a callback-based PIN flow.
2420
+ * Convenience method that wraps createPairingSession().
2421
+ *
2422
+ * @param options - Pairing options with onPinRequired callback.
2423
+ * @returns Long-term credentials for future connections.
2424
+ */
2425
+ pair(options: PairingOptions): Promise<AccessoryCredentials$1>;
2426
+ /**
2427
+ * Connects to the device.
2428
+ *
2429
+ * @param credentials - Pairing credentials. Required for Apple TV, ignored for HomePod.
2430
+ */
2431
+ abstract connect(credentials?: AccessoryCredentials$1): Promise<void>;
2432
+ /**
2433
+ * Disconnects from the device.
2434
+ */
2435
+ disconnect(): void;
2436
+ /**
2437
+ * Called when AirPlay connects successfully. Override for additional setup.
2438
+ */
2439
+ protected onAirPlayConnected(): void;
2440
+ /**
2441
+ * Called when AirPlay disconnects. Override for additional cleanup.
2442
+ */
2443
+ protected onAirPlayDisconnected(unexpected: boolean): void;
2444
+ }
2445
+ //#endregion
2446
+ //#region src/device/apple-tv.d.ts
2447
+ /**
2448
+ * Options specific to Apple TV devices.
2449
+ */
2450
+ type AppleTVOptions = DeviceOptions & {
2451
+ /**
2452
+ * Pre-discovered Companion Link service result.
2453
+ */
2454
+ readonly companionLink?: DiscoveryResult$1;
2455
+ };
2456
+ /**
2457
+ * High-level Apple TV device combining AirPlay and Companion Link protocols.
2458
+ * Provides remote control, media playback, app launching, keyboard input,
2459
+ * power management, and system settings.
2460
+ *
2461
+ * ```ts
2462
+ * const tv = new AppleTV({ airplay: result, companionLink: clResult });
2463
+ *
2464
+ * // First time — pair
2465
+ * const session = tv.createPairingSession();
2466
+ * await session.start();
2467
+ * await session.pin('1234');
2468
+ * const credentials = await session.end();
2469
+ *
2470
+ * // Connect with credentials
2471
+ * await tv.connect(credentials);
2472
+ * await tv.playback.play();
2473
+ * ```
2474
+ */
2475
+ declare class AppleTV extends AbstractDevice {
2476
+ #private;
2477
+ readonly accounts: AccountsController | undefined;
2478
+ readonly apps: AppsController | undefined;
2479
+ readonly keyboard: KeyboardController;
2480
+ readonly power: PowerController | undefined;
2481
+ readonly system: SystemController | undefined;
2482
+ constructor(options: AppleTVOptions);
2483
+ /**
2484
+ * The underlying Companion Link protocol manager, or undefined if no
2485
+ * Companion Link discovery result was provided.
2486
+ * Use this for low-level protocol access or features not covered by controllers.
2487
+ */
2488
+ get companionLink(): CompanionLinkManager | undefined;
2489
+ get isConnected(): boolean;
2490
+ /**
2491
+ * Connects to the Apple TV using AirPlay and (optionally) Companion Link.
2492
+ *
2493
+ * @param credentials - Pairing credentials from pair-setup.
2494
+ */
2495
+ connect(credentials: AccessoryCredentials$1): Promise<void>;
2496
+ disconnect(): void;
2497
+ protected onAirPlayConnected(): void;
2498
+ protected onAirPlayDisconnected(unexpected: boolean): void;
2499
+ }
2500
+ //#endregion
2501
+ //#region src/device/homepod.d.ts
2502
+ /**
2503
+ * High-level HomePod device using AirPlay only (transient pairing).
2504
+ * Provides media playback, URL playback, audio streaming, and volume control.
2505
+ * No credentials needed — transient pairing is handled transparently.
2506
+ *
2507
+ * ```ts
2508
+ * const pod = new HomePod({ airplay: result });
2509
+ * await pod.connect();
2510
+ * await pod.media.playUrl('https://example.com/song.mp3');
2511
+ * ```
2512
+ */
2513
+ declare class HomePod extends AbstractDevice {
2514
+ constructor(options: DeviceOptions);
2515
+ /**
2516
+ * Connects to the HomePod using transient pairing (no credentials needed).
2517
+ */
2518
+ connect(): Promise<void>;
2519
+ protected onAirPlayConnected(): void;
2520
+ protected onAirPlayDisconnected(unexpected: boolean): void;
2521
+ }
2522
+ //#endregion
2523
+ //#region src/device/homepod-mini.d.ts
2524
+ /**
2525
+ * High-level HomePod Mini device.
2526
+ * Functionally identical to HomePod, different device model.
2527
+ */
2528
+ declare class HomePodMini extends HomePod {}
2529
+ //#endregion
2530
+ //#region src/discover.d.ts
2531
+ /**
2532
+ * A discovered Apple device with its services and metadata.
2533
+ */
2534
+ type DiscoveredDevice = {
2535
+ readonly id: string;
2536
+ readonly name: string;
2537
+ readonly address: string;
2538
+ readonly modelName: string;
2539
+ readonly deviceType: DeviceType;
2540
+ readonly services: {
2541
+ readonly airplay?: DiscoveryResult$1;
2542
+ readonly companionLink?: DiscoveryResult$1;
2543
+ readonly raop?: DiscoveryResult$1;
2544
+ };
2545
+ };
2546
+ /**
2547
+ * Discovers Apple devices on the local network via mDNS.
2548
+ * Returns device descriptors that can be passed to createDevice().
2549
+ */
2550
+ declare function discover(): Promise<DiscoveredDevice[]>;
2551
+ /**
2552
+ * Creates a typed device instance from a discovery result.
2553
+ * Automatically selects AppleTV, HomePod, or HomePodMini based on the model.
2554
+ */
2555
+ declare function createDevice(discovered: DiscoveredDevice): AppleTV | HomePod | HomePodMini;
2556
+ //#endregion
2557
+ //#region src/configure.d.ts
2558
+ /**
2559
+ * Global SDK configuration options.
2560
+ */
2561
+ type SdkConfig = {
2562
+ /**
2563
+ * Storage backend for credentials. Default: none (consumer manages storage).
2564
+ */
2565
+ readonly storage?: Storage;
2566
+ /**
2567
+ * Enable debug logging groups. Default: none.
2568
+ */
2569
+ readonly logging?: ('debug' | 'error' | 'info' | 'net' | 'raw' | 'warn')[];
2570
+ /**
2571
+ * Shared timing server for multi-room audio sync and RAOP streaming.
2572
+ * When set, all devices automatically use this timing server unless
2573
+ * overridden per device via DeviceOptions.timingServer.
2574
+ */
2575
+ readonly timingServer?: TimingServer$1;
2576
+ };
2577
+ /**
2578
+ * Configures global settings for the Apple SDK.
2579
+ * Should be called once before creating any device instances.
2580
+ */
2581
+ declare function configure(config: SdkConfig): void;
2582
+ //#endregion
2583
+ export { PROTOCOL as AIRPLAY_PROTOCOL, AbstractDevice, type AccessoryCredentials, AccountsController, AirPlayArtwork, type AirPlayClient, AirPlayManager, type AirPlayPlayer, AirPlayRemote, AirPlayState, AirPlayVolume, AppleTV, type AppleTVEventMap, type AppleTVOptions, AppsController, ArtworkController, type ArtworkResult, type AttentionState, COMPANION_LINK_PROTOCOL, CompanionLinkManager, CompanionLinkState, type ConnectOptions, type DeviceEventMap, type DeviceOptions, type DeviceType, type DiscoveredDevice, type DiscoveryResult, HomePod, HomePodMini, KeyboardController, type MediaCapabilities, MediaController, MultiroomController, type PairingOptions, type PairingResult, PairingSession, PlaybackController, PowerController, Proto, type RecoveryOptions, RemoteController, type SdkConfig, SendCommandError, StateController, type StateEventMap, SystemController, type TextInputState, TimingServer, VolumeController, configure, createDevice, discover };