@basmilius/apple-devices 0.9.19 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1167 -15
- package/dist/index.mjs +1659 -191
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -2,173 +2,528 @@
|
|
|
2
2
|
import * as AirPlay from "@basmilius/apple-airplay";
|
|
3
3
|
import { Proto, Protocol } from "@basmilius/apple-airplay";
|
|
4
4
|
import { EventEmitter } from "node:events";
|
|
5
|
-
import { AccessoryCredentials, AudioSource, CommandError, DiscoveryResult, TimingServer } from "@basmilius/apple-common";
|
|
5
|
+
import { AccessoryCredentials, AudioSource, CommandError, DeviceIdentity, DiscoveryResult, TimingServer } from "@basmilius/apple-common";
|
|
6
6
|
import { AttentionState, ButtonPressType, HidCommandKey, LaunchableApp, MediaControlCommandKey, Protocol as Protocol$1, TextInputState, UserAccount } from "@basmilius/apple-companion-link";
|
|
7
7
|
|
|
8
8
|
//#region src/airplay/player.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Represents a single media player within an app on the Apple TV.
|
|
11
|
+
* Each app (Client) can have multiple players (e.g. picture-in-picture).
|
|
12
|
+
* Tracks now-playing metadata, playback state, and provides elapsed time extrapolation
|
|
13
|
+
* based on Cocoa timestamps and playback rate.
|
|
14
|
+
*/
|
|
9
15
|
declare class Player {
|
|
10
16
|
#private;
|
|
17
|
+
/** Unique identifier for this player (e.g. a player path). */
|
|
11
18
|
get identifier(): string;
|
|
19
|
+
/** Human-readable display name for this player. */
|
|
12
20
|
get displayName(): string;
|
|
21
|
+
/** Whether this is the default fallback player (MediaRemote-DefaultPlayer). */
|
|
13
22
|
get isDefaultPlayer(): boolean;
|
|
23
|
+
/** Raw now-playing info from the Apple TV, or null if unavailable. */
|
|
14
24
|
get nowPlayingInfo(): Proto.NowPlayingInfo | null;
|
|
25
|
+
/** Current playback queue, or null if unavailable. */
|
|
15
26
|
get playbackQueue(): Proto.PlaybackQueue | null;
|
|
27
|
+
/**
|
|
28
|
+
* Effective playback state.
|
|
29
|
+
*/
|
|
16
30
|
get playbackState(): Proto.PlaybackState_Enum;
|
|
31
|
+
/** The raw playback state as reported by the Apple TV, without corrections. */
|
|
17
32
|
get rawPlaybackState(): Proto.PlaybackState_Enum;
|
|
33
|
+
/** Timestamp of the last playback state update, used to discard stale updates. */
|
|
18
34
|
get playbackStateTimestamp(): number;
|
|
35
|
+
/** List of commands supported by this player. */
|
|
19
36
|
get supportedCommands(): Proto.CommandInfo[];
|
|
37
|
+
/** Current track title from NowPlayingInfo or content item metadata. */
|
|
20
38
|
get title(): string;
|
|
39
|
+
/** Current track artist from NowPlayingInfo or content item metadata. */
|
|
21
40
|
get artist(): string;
|
|
41
|
+
/** Current track album from NowPlayingInfo or content item metadata. */
|
|
22
42
|
get album(): string;
|
|
43
|
+
/** Genre of the current content item. */
|
|
23
44
|
get genre(): string;
|
|
45
|
+
/** Series name for TV show content. */
|
|
24
46
|
get seriesName(): string;
|
|
47
|
+
/** Season number for TV show content, or 0 if not applicable. */
|
|
25
48
|
get seasonNumber(): number;
|
|
49
|
+
/** Episode number for TV show content, or 0 if not applicable. */
|
|
26
50
|
get episodeNumber(): number;
|
|
51
|
+
/** Media type of the current content item (music, video, etc.). */
|
|
27
52
|
get mediaType(): Proto.ContentItemMetadata_MediaType;
|
|
53
|
+
/** Unique content identifier for the current item (e.g. iTunes store ID). */
|
|
28
54
|
get contentIdentifier(): string;
|
|
55
|
+
/** Duration of the current track in seconds, from NowPlayingInfo or metadata. */
|
|
29
56
|
get duration(): number;
|
|
57
|
+
/** Current playback rate (1.0 = normal, 0 = paused, 2.0 = double speed). */
|
|
30
58
|
get playbackRate(): number;
|
|
59
|
+
/** Whether the player is currently playing (based on effective playback state). */
|
|
31
60
|
get isPlaying(): boolean;
|
|
61
|
+
/** Current shuffle mode, derived from the ChangeShuffleMode command info. */
|
|
32
62
|
get shuffleMode(): Proto.ShuffleMode_Enum;
|
|
63
|
+
/** Current repeat mode, derived from the ChangeRepeatMode command info. */
|
|
33
64
|
get repeatMode(): Proto.RepeatMode_Enum;
|
|
65
|
+
/**
|
|
66
|
+
* Extrapolated elapsed time in seconds. Uses the most recent timestamp
|
|
67
|
+
* from either NowPlayingInfo or content item metadata, accounting for
|
|
68
|
+
* playback rate to provide a real-time estimate.
|
|
69
|
+
*/
|
|
34
70
|
get elapsedTime(): number;
|
|
71
|
+
/** The currently playing content item from the playback queue, or null. */
|
|
35
72
|
get currentItem(): Proto.ContentItem | null;
|
|
73
|
+
/** Metadata of the current content item, or null if no item is playing. */
|
|
36
74
|
get currentItemMetadata(): Proto.ContentItemMetadata | null;
|
|
75
|
+
/**
|
|
76
|
+
* Unique identifier for the current artwork, used for change detection.
|
|
77
|
+
* Returns null if no artwork evidence exists.
|
|
78
|
+
*/
|
|
37
79
|
get artworkId(): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the best available artwork URL for the current item.
|
|
82
|
+
* Checks metadata artworkURL, remote artworks, and iTunes template URLs in order.
|
|
83
|
+
*
|
|
84
|
+
* @param width - Desired artwork width in pixels (used for template URLs).
|
|
85
|
+
* @param height - Desired artwork height in pixels (-1 for automatic).
|
|
86
|
+
* @returns The artwork URL, or null if no artwork URL is available.
|
|
87
|
+
*/
|
|
38
88
|
artworkUrl(width?: number, height?: number): string | null;
|
|
89
|
+
/** Raw artwork data (image bytes) for the current item, or null if not embedded. */
|
|
39
90
|
get currentItemArtwork(): Uint8Array | null;
|
|
91
|
+
/** Convenience getter for the artwork URL at default dimensions (600px). */
|
|
40
92
|
get currentItemArtworkUrl(): string | null;
|
|
93
|
+
/** Lyrics for the current content item, or null if unavailable. */
|
|
41
94
|
get currentItemLyrics(): Proto.LyricsItem | null;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new Player instance.
|
|
97
|
+
*
|
|
98
|
+
* @param identifier - Unique player identifier.
|
|
99
|
+
* @param displayName - Human-readable display name.
|
|
100
|
+
*/
|
|
42
101
|
constructor(identifier: string, displayName: string);
|
|
102
|
+
/**
|
|
103
|
+
* Finds a command by its command type in the supported commands list.
|
|
104
|
+
*
|
|
105
|
+
* @param command - The command to look up.
|
|
106
|
+
* @returns The command info, or null if not found.
|
|
107
|
+
*/
|
|
43
108
|
findCommand(command: Proto.Command): Proto.CommandInfo | null;
|
|
109
|
+
/**
|
|
110
|
+
* Checks whether a command is supported and enabled.
|
|
111
|
+
*
|
|
112
|
+
* @param command - The command to check.
|
|
113
|
+
* @returns True if the command is in the supported list and enabled.
|
|
114
|
+
*/
|
|
44
115
|
isCommandSupported(command: Proto.Command): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Updates the now-playing info for this player.
|
|
118
|
+
*
|
|
119
|
+
* @param nowPlayingInfo - The new now-playing info from the Apple TV.
|
|
120
|
+
*/
|
|
45
121
|
setNowPlayingInfo(nowPlayingInfo: Proto.NowPlayingInfo): void;
|
|
122
|
+
/**
|
|
123
|
+
* Updates the playback queue for this player.
|
|
124
|
+
*
|
|
125
|
+
* @param playbackQueue - The new playback queue from the Apple TV.
|
|
126
|
+
*/
|
|
46
127
|
setPlaybackQueue(playbackQueue: Proto.PlaybackQueue): void;
|
|
128
|
+
/**
|
|
129
|
+
* Updates the playback state. Ignores updates with a timestamp older than the current one
|
|
130
|
+
* to prevent stale state from overwriting newer data.
|
|
131
|
+
*
|
|
132
|
+
* @param playbackState - The new playback state.
|
|
133
|
+
* @param playbackStateTimestamp - Timestamp of this state update.
|
|
134
|
+
*/
|
|
47
135
|
setPlaybackState(playbackState: Proto.PlaybackState_Enum, playbackStateTimestamp: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Replaces the list of supported commands for this player.
|
|
138
|
+
*
|
|
139
|
+
* @param supportedCommands - The new list of supported commands.
|
|
140
|
+
*/
|
|
48
141
|
setSupportedCommands(supportedCommands: Proto.CommandInfo[]): void;
|
|
142
|
+
/**
|
|
143
|
+
* Merges updated content item data into the existing playback queue.
|
|
144
|
+
* Updates metadata, artwork, lyrics, and info fields for the matching item.
|
|
145
|
+
*
|
|
146
|
+
* @param item - The content item with updated fields.
|
|
147
|
+
*/
|
|
49
148
|
updateContentItem(item: Proto.ContentItem): void;
|
|
50
149
|
}
|
|
51
150
|
//#endregion
|
|
52
151
|
//#region src/airplay/client.d.ts
|
|
152
|
+
/**
|
|
153
|
+
* Represents a now-playing app (client) on the Apple TV.
|
|
154
|
+
* Each client is identified by its bundle identifier and can contain multiple players.
|
|
155
|
+
* Proxies now-playing getters to the active player, merging player-specific and
|
|
156
|
+
* default supported commands.
|
|
157
|
+
*/
|
|
53
158
|
declare class Client {
|
|
54
159
|
#private;
|
|
160
|
+
/** Bundle identifier of the app (e.g. "com.apple.TVMusic"). */
|
|
55
161
|
get bundleIdentifier(): string;
|
|
162
|
+
/** Human-readable display name of the app. */
|
|
56
163
|
get displayName(): string;
|
|
164
|
+
/** Map of all known players for this client, keyed by player identifier. */
|
|
57
165
|
get players(): Map<string, Player>;
|
|
166
|
+
/** The currently active player, or null if none is active. Falls back to the default player. */
|
|
58
167
|
get activePlayer(): Player | null;
|
|
168
|
+
/** Now-playing info from the active player, or null. */
|
|
59
169
|
get nowPlayingInfo(): Proto.NowPlayingInfo | null;
|
|
170
|
+
/** Playback queue from the active player, or null. */
|
|
60
171
|
get playbackQueue(): Proto.PlaybackQueue | null;
|
|
172
|
+
/** Playback state from the active player, or Unknown. */
|
|
61
173
|
get playbackState(): Proto.PlaybackState_Enum;
|
|
174
|
+
/** Timestamp of the last playback state update from the active player. */
|
|
62
175
|
get playbackStateTimestamp(): number;
|
|
176
|
+
/**
|
|
177
|
+
* Merged list of supported commands from the active player and client defaults.
|
|
178
|
+
* Player commands take precedence; default commands are appended if not already present.
|
|
179
|
+
*/
|
|
63
180
|
get supportedCommands(): Proto.CommandInfo[];
|
|
181
|
+
/** Current track title from the active player. */
|
|
64
182
|
get title(): string;
|
|
183
|
+
/** Current track artist from the active player. */
|
|
65
184
|
get artist(): string;
|
|
185
|
+
/** Current track album from the active player. */
|
|
66
186
|
get album(): string;
|
|
187
|
+
/** Genre of the current content from the active player. */
|
|
67
188
|
get genre(): string;
|
|
189
|
+
/** Series name for TV show content from the active player. */
|
|
68
190
|
get seriesName(): string;
|
|
191
|
+
/** Season number for TV show content from the active player. */
|
|
69
192
|
get seasonNumber(): number;
|
|
193
|
+
/** Episode number for TV show content from the active player. */
|
|
70
194
|
get episodeNumber(): number;
|
|
195
|
+
/** Media type of the current content from the active player. */
|
|
71
196
|
get mediaType(): Proto.ContentItemMetadata_MediaType;
|
|
197
|
+
/** Content identifier of the current item from the active player. */
|
|
72
198
|
get contentIdentifier(): string;
|
|
199
|
+
/** Duration of the current track in seconds from the active player. */
|
|
73
200
|
get duration(): number;
|
|
201
|
+
/** Playback rate from the active player (1.0 = normal, 0 = paused). */
|
|
74
202
|
get playbackRate(): number;
|
|
203
|
+
/** Whether the active player is currently playing. */
|
|
75
204
|
get isPlaying(): boolean;
|
|
205
|
+
/** Current shuffle mode from the active player. */
|
|
76
206
|
get shuffleMode(): Proto.ShuffleMode_Enum;
|
|
207
|
+
/** Current repeat mode from the active player. */
|
|
77
208
|
get repeatMode(): Proto.RepeatMode_Enum;
|
|
209
|
+
/** Extrapolated elapsed time in seconds from the active player. */
|
|
78
210
|
get elapsedTime(): number;
|
|
211
|
+
/** Artwork identifier for change detection from the active player. */
|
|
79
212
|
get artworkId(): string | null;
|
|
213
|
+
/**
|
|
214
|
+
* Resolves the best available artwork URL from the active player.
|
|
215
|
+
*
|
|
216
|
+
* @param width - Desired artwork width in pixels.
|
|
217
|
+
* @param height - Desired artwork height in pixels (-1 for automatic).
|
|
218
|
+
* @returns The artwork URL, or null if unavailable.
|
|
219
|
+
*/
|
|
80
220
|
artworkUrl(width?: number, height?: number): string | null;
|
|
221
|
+
/** Current content item from the active player's playback queue. */
|
|
81
222
|
get currentItem(): Proto.ContentItem | null;
|
|
223
|
+
/** Metadata of the current content item from the active player. */
|
|
82
224
|
get currentItemMetadata(): Proto.ContentItemMetadata | null;
|
|
225
|
+
/** Raw artwork data (image bytes) from the active player. */
|
|
83
226
|
get currentItemArtwork(): Uint8Array | null;
|
|
227
|
+
/** Artwork URL at default dimensions from the active player. */
|
|
84
228
|
get currentItemArtworkUrl(): string | null;
|
|
229
|
+
/** Lyrics for the current content item from the active player. */
|
|
85
230
|
get currentItemLyrics(): Proto.LyricsItem | null;
|
|
231
|
+
/**
|
|
232
|
+
* Creates a new Client instance.
|
|
233
|
+
*
|
|
234
|
+
* @param bundleIdentifier - Bundle identifier of the app.
|
|
235
|
+
* @param displayName - Human-readable app name.
|
|
236
|
+
*/
|
|
86
237
|
constructor(bundleIdentifier: string, displayName: string);
|
|
238
|
+
/**
|
|
239
|
+
* Gets an existing player or creates a new one if it does not exist.
|
|
240
|
+
*
|
|
241
|
+
* @param identifier - Unique player identifier.
|
|
242
|
+
* @param displayName - Human-readable player name (defaults to identifier).
|
|
243
|
+
* @returns The existing or newly created Player.
|
|
244
|
+
*/
|
|
87
245
|
getOrCreatePlayer(identifier: string, displayName?: string): Player;
|
|
246
|
+
/**
|
|
247
|
+
* Sets the active player by identifier.
|
|
248
|
+
*
|
|
249
|
+
* @param identifier - Identifier of the player to activate.
|
|
250
|
+
*/
|
|
88
251
|
setActivePlayer(identifier: string): void;
|
|
252
|
+
/**
|
|
253
|
+
* Removes a player from this client. If the removed player was active,
|
|
254
|
+
* the active player is reset to null (falling back to the default player).
|
|
255
|
+
*
|
|
256
|
+
* @param identifier - Identifier of the player to remove.
|
|
257
|
+
*/
|
|
89
258
|
removePlayer(identifier: string): void;
|
|
259
|
+
/**
|
|
260
|
+
* Sets the default supported commands for this client. These are used as
|
|
261
|
+
* fallback when the active player has no commands of its own.
|
|
262
|
+
*
|
|
263
|
+
* @param supportedCommands - The default command list.
|
|
264
|
+
*/
|
|
90
265
|
setDefaultSupportedCommands(supportedCommands: Proto.CommandInfo[]): void;
|
|
266
|
+
/**
|
|
267
|
+
* Finds a command by type, checking the active player first,
|
|
268
|
+
* then falling back to the default supported commands.
|
|
269
|
+
*
|
|
270
|
+
* @param command - The command to look up.
|
|
271
|
+
* @returns The command info, or null if not found.
|
|
272
|
+
*/
|
|
91
273
|
findCommand(command: Proto.Command): Proto.CommandInfo | null;
|
|
274
|
+
/**
|
|
275
|
+
* Checks whether a command is supported and enabled, checking both
|
|
276
|
+
* the active player and default commands.
|
|
277
|
+
*
|
|
278
|
+
* @param command - The command to check.
|
|
279
|
+
* @returns True if the command is supported and enabled.
|
|
280
|
+
*/
|
|
92
281
|
isCommandSupported(command: Proto.Command): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Updates the display name for this client.
|
|
284
|
+
*
|
|
285
|
+
* @param displayName - The new display name.
|
|
286
|
+
*/
|
|
93
287
|
updateDisplayName(displayName: string): void;
|
|
94
288
|
}
|
|
95
289
|
//#endregion
|
|
96
290
|
//#region src/airplay/const.d.ts
|
|
291
|
+
/** Symbol used to access the underlying AirPlay Protocol instance from an AirPlayDevice. */
|
|
97
292
|
declare const PROTOCOL: unique symbol;
|
|
293
|
+
/** Symbol used to subscribe AirPlayState to DataStream events. */
|
|
98
294
|
declare const STATE_SUBSCRIBE_SYMBOL: unique symbol;
|
|
295
|
+
/** Symbol used to unsubscribe AirPlayState from DataStream events. */
|
|
99
296
|
declare const STATE_UNSUBSCRIBE_SYMBOL: unique symbol;
|
|
100
297
|
//#endregion
|
|
101
298
|
//#region src/airplay/remote.d.ts
|
|
299
|
+
/**
|
|
300
|
+
* Error thrown when a SendCommand request fails on the Apple TV side.
|
|
301
|
+
* Contains the specific send error and handler return status for diagnostics.
|
|
302
|
+
*/
|
|
102
303
|
declare class SendCommandError extends CommandError {
|
|
304
|
+
/** The send error reported by the Apple TV. */
|
|
103
305
|
readonly sendError: Proto.SendError_Enum;
|
|
306
|
+
/** The handler return status reported by the Apple TV. */
|
|
104
307
|
readonly handlerReturnStatus: Proto.HandlerReturnStatus_Enum;
|
|
308
|
+
/**
|
|
309
|
+
* Creates a new SendCommandError.
|
|
310
|
+
*
|
|
311
|
+
* @param sendError - The send error code from the Apple TV.
|
|
312
|
+
* @param handlerReturnStatus - The handler return status from the Apple TV.
|
|
313
|
+
*/
|
|
105
314
|
constructor(sendError: Proto.SendError_Enum, handlerReturnStatus: Proto.HandlerReturnStatus_Enum);
|
|
106
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Remote control for an AirPlay device.
|
|
318
|
+
* Provides HID-based navigation and media keys (USB usage pages: Generic Desktop 0x01
|
|
319
|
+
* and Consumer 0x0c), SendCommand-based media controls, keyboard/text input,
|
|
320
|
+
* and touch/gesture simulation.
|
|
321
|
+
*/
|
|
107
322
|
declare class export_default$1 {
|
|
108
323
|
#private;
|
|
324
|
+
/**
|
|
325
|
+
* Creates a new Remote controller.
|
|
326
|
+
*
|
|
327
|
+
* @param device - The AirPlay device to control.
|
|
328
|
+
*/
|
|
109
329
|
constructor(device: export_default);
|
|
330
|
+
/** Sends an Up navigation key press (Generic Desktop, usage 0x8C). */
|
|
110
331
|
up(): Promise<void>;
|
|
332
|
+
/** Sends a Down navigation key press (Generic Desktop, usage 0x8D). */
|
|
111
333
|
down(): Promise<void>;
|
|
334
|
+
/** Sends a Left navigation key press (Generic Desktop, usage 0x8B). */
|
|
112
335
|
left(): Promise<void>;
|
|
336
|
+
/** Sends a Right navigation key press (Generic Desktop, usage 0x8A). */
|
|
113
337
|
right(): Promise<void>;
|
|
338
|
+
/** Sends a Menu key press (Generic Desktop, usage 0x86). */
|
|
114
339
|
menu(): Promise<void>;
|
|
340
|
+
/** Sends a Select/Enter key press (Generic Desktop, usage 0x89). */
|
|
115
341
|
select(): Promise<void>;
|
|
342
|
+
/** Sends a Home button press (Consumer, usage 0x40). */
|
|
116
343
|
home(): Promise<void>;
|
|
344
|
+
/** Sends a Suspend/Sleep key press to put the device to sleep (Generic Desktop, usage 0x82). */
|
|
117
345
|
suspend(): Promise<void>;
|
|
346
|
+
/** Sends a Wake key press to wake the device (Generic Desktop, usage 0x83). */
|
|
118
347
|
wake(): Promise<void>;
|
|
348
|
+
/** Sends a Play key press (Consumer, usage 0xB0). */
|
|
119
349
|
play(): Promise<void>;
|
|
350
|
+
/** Sends a Pause key press (Consumer, usage 0xB1). */
|
|
120
351
|
pause(): Promise<void>;
|
|
352
|
+
/** Toggles play/pause based on the current playback state. */
|
|
121
353
|
playPause(): Promise<void>;
|
|
354
|
+
/** Sends a Stop key press (Consumer, usage 0xB7). */
|
|
122
355
|
stop(): Promise<void>;
|
|
356
|
+
/** Sends a Next Track key press (Consumer, usage 0xB5). */
|
|
123
357
|
next(): Promise<void>;
|
|
358
|
+
/** Sends a Previous Track key press (Consumer, usage 0xB6). */
|
|
124
359
|
previous(): Promise<void>;
|
|
360
|
+
/** Sends a Volume Up key press (Consumer, usage 0xE9). */
|
|
125
361
|
volumeUp(): Promise<void>;
|
|
362
|
+
/** Sends a Volume Down key press (Consumer, usage 0xEA). */
|
|
126
363
|
volumeDown(): Promise<void>;
|
|
364
|
+
/** Sends a Mute key press (Consumer, usage 0xE2). */
|
|
127
365
|
mute(): Promise<void>;
|
|
366
|
+
/** Sends a Top Menu key press (Consumer, usage 0x60). */
|
|
128
367
|
topMenu(): Promise<void>;
|
|
368
|
+
/** Sends a Channel Up key press (Consumer, usage 0x9C). */
|
|
129
369
|
channelUp(): Promise<void>;
|
|
370
|
+
/** Sends a Channel Down key press (Consumer, usage 0x9D). */
|
|
130
371
|
channelDown(): Promise<void>;
|
|
372
|
+
/** Sends a Play command via the MRP SendCommand protocol. */
|
|
131
373
|
commandPlay(): Promise<void>;
|
|
374
|
+
/** Sends a Pause command via the MRP SendCommand protocol. */
|
|
132
375
|
commandPause(): Promise<void>;
|
|
376
|
+
/** Sends a TogglePlayPause command via the MRP SendCommand protocol. */
|
|
133
377
|
commandTogglePlayPause(): Promise<void>;
|
|
378
|
+
/** Sends a Stop command via the MRP SendCommand protocol. */
|
|
134
379
|
commandStop(): Promise<void>;
|
|
380
|
+
/** Sends a NextTrack command via the MRP SendCommand protocol. */
|
|
135
381
|
commandNextTrack(): Promise<void>;
|
|
382
|
+
/** Sends a PreviousTrack command via the MRP SendCommand protocol. */
|
|
136
383
|
commandPreviousTrack(): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* Sends a SkipForward command with a configurable interval.
|
|
386
|
+
*
|
|
387
|
+
* @param interval - Seconds to skip forward (defaults to 15).
|
|
388
|
+
*/
|
|
137
389
|
commandSkipForward(interval?: number): Promise<void>;
|
|
390
|
+
/**
|
|
391
|
+
* Sends a SkipBackward command with a configurable interval.
|
|
392
|
+
*
|
|
393
|
+
* @param interval - Seconds to skip backward (defaults to 15).
|
|
394
|
+
*/
|
|
138
395
|
commandSkipBackward(interval?: number): Promise<void>;
|
|
396
|
+
/**
|
|
397
|
+
* Seeks to an absolute playback position.
|
|
398
|
+
*
|
|
399
|
+
* @param position - The target position in seconds.
|
|
400
|
+
*/
|
|
139
401
|
commandSeekToPosition(position: number): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Sets the shuffle mode.
|
|
404
|
+
*
|
|
405
|
+
* @param mode - The desired shuffle mode.
|
|
406
|
+
*/
|
|
140
407
|
commandSetShuffleMode(mode: Proto.ShuffleMode_Enum): Promise<void>;
|
|
408
|
+
/**
|
|
409
|
+
* Sets the repeat mode.
|
|
410
|
+
*
|
|
411
|
+
* @param mode - The desired repeat mode.
|
|
412
|
+
*/
|
|
141
413
|
commandSetRepeatMode(mode: Proto.RepeatMode_Enum): Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* Changes the playback rate (speed).
|
|
416
|
+
*
|
|
417
|
+
* @param rate - The desired playback rate (e.g. 1.0 for normal, 2.0 for double speed).
|
|
418
|
+
*/
|
|
142
419
|
commandChangePlaybackRate(rate: number): Promise<void>;
|
|
420
|
+
/** Cycles the shuffle mode to the next value. */
|
|
143
421
|
commandAdvanceShuffleMode(): Promise<void>;
|
|
422
|
+
/** Cycles the repeat mode to the next value. */
|
|
144
423
|
commandAdvanceRepeatMode(): Promise<void>;
|
|
424
|
+
/** Begins fast-forwarding playback. */
|
|
145
425
|
commandBeginFastForward(): Promise<void>;
|
|
426
|
+
/** Ends fast-forwarding playback. */
|
|
146
427
|
commandEndFastForward(): Promise<void>;
|
|
428
|
+
/** Begins rewinding playback. */
|
|
147
429
|
commandBeginRewind(): Promise<void>;
|
|
430
|
+
/** Ends rewinding playback. */
|
|
148
431
|
commandEndRewind(): Promise<void>;
|
|
432
|
+
/** Skips to the next chapter. */
|
|
149
433
|
commandNextChapter(): Promise<void>;
|
|
434
|
+
/** Skips to the previous chapter. */
|
|
150
435
|
commandPreviousChapter(): Promise<void>;
|
|
436
|
+
/** Marks the current track as liked. */
|
|
151
437
|
commandLikeTrack(): Promise<void>;
|
|
438
|
+
/** Marks the current track as disliked. */
|
|
152
439
|
commandDislikeTrack(): Promise<void>;
|
|
440
|
+
/** Bookmarks the current track. */
|
|
153
441
|
commandBookmarkTrack(): Promise<void>;
|
|
442
|
+
/** Adds the currently playing item to the user's library. */
|
|
154
443
|
commandAddNowPlayingItemToLibrary(): Promise<void>;
|
|
444
|
+
/**
|
|
445
|
+
* Sets the text input field to the given text, replacing any existing content.
|
|
446
|
+
*
|
|
447
|
+
* @param text - The text to set.
|
|
448
|
+
*/
|
|
155
449
|
textSet(text: string): Promise<void>;
|
|
450
|
+
/**
|
|
451
|
+
* Appends text to the current text input field content.
|
|
452
|
+
*
|
|
453
|
+
* @param text - The text to append.
|
|
454
|
+
*/
|
|
156
455
|
textAppend(text: string): Promise<void>;
|
|
456
|
+
/** Clears the text input field. */
|
|
157
457
|
textClear(): Promise<void>;
|
|
458
|
+
/** Requests the current keyboard session state from the Apple TV. */
|
|
158
459
|
getKeyboardSession(): Promise<void>;
|
|
460
|
+
/**
|
|
461
|
+
* Simulates a tap at the given coordinates.
|
|
462
|
+
*
|
|
463
|
+
* @param x - Horizontal position in the virtual touch area.
|
|
464
|
+
* @param y - Vertical position in the virtual touch area.
|
|
465
|
+
* @param finger - Finger index for multi-touch (defaults to 1).
|
|
466
|
+
*/
|
|
159
467
|
tap(x: number, y: number, finger?: number): Promise<void>;
|
|
468
|
+
/**
|
|
469
|
+
* Simulates an upward swipe gesture.
|
|
470
|
+
*
|
|
471
|
+
* @param duration - Swipe duration in milliseconds (defaults to 200).
|
|
472
|
+
*/
|
|
160
473
|
swipeUp(duration?: number): Promise<void>;
|
|
474
|
+
/**
|
|
475
|
+
* Simulates a downward swipe gesture.
|
|
476
|
+
*
|
|
477
|
+
* @param duration - Swipe duration in milliseconds (defaults to 200).
|
|
478
|
+
*/
|
|
161
479
|
swipeDown(duration?: number): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* Simulates a leftward swipe gesture.
|
|
482
|
+
*
|
|
483
|
+
* @param duration - Swipe duration in milliseconds (defaults to 200).
|
|
484
|
+
*/
|
|
162
485
|
swipeLeft(duration?: number): Promise<void>;
|
|
486
|
+
/**
|
|
487
|
+
* Simulates a rightward swipe gesture.
|
|
488
|
+
*
|
|
489
|
+
* @param duration - Swipe duration in milliseconds (defaults to 200).
|
|
490
|
+
*/
|
|
163
491
|
swipeRight(duration?: number): Promise<void>;
|
|
492
|
+
/**
|
|
493
|
+
* Sends a double press of a HID key (two press-and-release cycles with a 150ms gap).
|
|
494
|
+
*
|
|
495
|
+
* @param usePage - USB HID usage page (1 = Generic Desktop, 12 = Consumer).
|
|
496
|
+
* @param usage - USB HID usage code.
|
|
497
|
+
*/
|
|
164
498
|
doublePress(usePage: number, usage: number): Promise<void>;
|
|
499
|
+
/**
|
|
500
|
+
* Sends a long press of a HID key (hold for a configurable duration).
|
|
501
|
+
*
|
|
502
|
+
* @param usePage - USB HID usage page (1 = Generic Desktop, 12 = Consumer).
|
|
503
|
+
* @param usage - USB HID usage code.
|
|
504
|
+
* @param duration - Hold duration in milliseconds (defaults to 1000).
|
|
505
|
+
*/
|
|
165
506
|
longPress(usePage: number, usage: number, duration?: number): Promise<void>;
|
|
507
|
+
/**
|
|
508
|
+
* Sends a single press-and-release of a HID key with a 25ms hold.
|
|
509
|
+
*
|
|
510
|
+
* @param usePage - USB HID usage page (1 = Generic Desktop, 12 = Consumer).
|
|
511
|
+
* @param usage - USB HID usage code.
|
|
512
|
+
*/
|
|
166
513
|
pressAndRelease(usePage: number, usage: number): Promise<void>;
|
|
167
514
|
}
|
|
168
515
|
//#endregion
|
|
169
516
|
//#region src/airplay/state.d.ts
|
|
170
|
-
|
|
517
|
+
/**
|
|
518
|
+
* Events emitted by AirPlayState.
|
|
519
|
+
*
|
|
520
|
+
* Low-level events mirror DataStream protocol messages 1:1.
|
|
521
|
+
* High-level events (activePlayerChanged, artworkChanged, etc.) provide
|
|
522
|
+
* pre-resolved Client/Player references for convenience.
|
|
523
|
+
*/
|
|
524
|
+
type EventMap$5 = {
|
|
171
525
|
readonly clients: [Record<string, Client>];
|
|
526
|
+
readonly configureConnection: [Proto.ConfigureConnectionMessage];
|
|
172
527
|
readonly deviceInfo: [Proto.DeviceInfoMessage];
|
|
173
528
|
readonly deviceInfoUpdate: [Proto.DeviceInfoMessage];
|
|
174
529
|
readonly keyboard: [Proto.KeyboardMessage];
|
|
@@ -191,230 +546,1027 @@ type EventMap$4 = {
|
|
|
191
546
|
readonly volumeControlAvailability: [boolean, Proto.VolumeCapabilities_Enum];
|
|
192
547
|
readonly volumeControlCapabilitiesDidChange: [boolean, Proto.VolumeCapabilities_Enum];
|
|
193
548
|
readonly volumeDidChange: [number];
|
|
549
|
+
readonly volumeMutedDidChange: [boolean];
|
|
550
|
+
readonly activePlayerChanged: [client: Client | null, player: Player | null];
|
|
551
|
+
readonly artworkChanged: [client: Client, player: Player];
|
|
552
|
+
readonly lyricsEvent: [event: Proto.LyricsEvent, playerPath: Proto.PlayerPath | undefined];
|
|
553
|
+
readonly playbackQueueChanged: [client: Client, player: Player];
|
|
554
|
+
readonly playbackStateChanged: [client: Client, player: Player, oldState: Proto.PlaybackState_Enum, newState: Proto.PlaybackState_Enum];
|
|
555
|
+
readonly supportedCommandsChanged: [client: Client, player: Player, commands: Proto.CommandInfo[]];
|
|
194
556
|
};
|
|
195
|
-
|
|
557
|
+
/**
|
|
558
|
+
* Tracks the complete state of an AirPlay device: clients, players, now-playing,
|
|
559
|
+
* volume, keyboard, output devices, and cluster info.
|
|
560
|
+
* Listens to DataStream protocol messages and emits both low-level (1:1 with protocol)
|
|
561
|
+
* and high-level (deduplicated, resolved) events.
|
|
562
|
+
*/
|
|
563
|
+
declare class export_default$2 extends EventEmitter<EventMap$5> {
|
|
196
564
|
#private;
|
|
565
|
+
/** All known clients (apps) keyed by bundle identifier. */
|
|
197
566
|
get clients(): Record<string, Client>;
|
|
567
|
+
/** Whether a keyboard/text input session is currently active on the Apple TV. */
|
|
198
568
|
get isKeyboardActive(): boolean;
|
|
569
|
+
/** Text editing attributes for the active keyboard session, or null. */
|
|
199
570
|
get keyboardAttributes(): Proto.TextEditingAttributes | null;
|
|
571
|
+
/** Current keyboard state enum value. */
|
|
200
572
|
get keyboardState(): Proto.KeyboardState_Enum;
|
|
573
|
+
/** The currently active now-playing client, or null if nothing is playing. */
|
|
201
574
|
get nowPlayingClient(): Client | null;
|
|
575
|
+
/** UID of the primary output device (used for volume control and multi-room). */
|
|
202
576
|
get outputDeviceUID(): string | null;
|
|
577
|
+
/** List of all output device descriptors in the current AirPlay group. */
|
|
203
578
|
get outputDevices(): Proto.AVOutputDeviceDescriptor[];
|
|
579
|
+
/** Cluster identifier for multi-room groups, or null. */
|
|
204
580
|
get clusterID(): string | null;
|
|
581
|
+
/** Cluster type code (0 if not clustered). */
|
|
205
582
|
get clusterType(): number;
|
|
583
|
+
/** Whether this device is aware of multi-room clusters. */
|
|
206
584
|
get isClusterAware(): boolean;
|
|
585
|
+
/** Whether this device is the leader of its multi-room cluster. */
|
|
586
|
+
get isClusterLeader(): boolean;
|
|
587
|
+
/** Current volume level (0.0 - 1.0). */
|
|
207
588
|
get volume(): number;
|
|
589
|
+
/** Whether volume control is available on this device. */
|
|
208
590
|
get volumeAvailable(): boolean;
|
|
591
|
+
/** Volume capabilities (absolute, relative, both, or none). */
|
|
209
592
|
get volumeCapabilities(): Proto.VolumeCapabilities_Enum;
|
|
593
|
+
/** Whether the device is currently muted. */
|
|
594
|
+
get volumeMuted(): boolean;
|
|
595
|
+
/**
|
|
596
|
+
* Creates a new AirPlayState tracker.
|
|
597
|
+
*
|
|
598
|
+
* @param device - The AirPlay device to track state for.
|
|
599
|
+
*/
|
|
210
600
|
constructor(device: export_default);
|
|
601
|
+
/** Subscribes to all DataStream events to track device state. Called internally via symbol. */
|
|
211
602
|
[STATE_SUBSCRIBE_SYMBOL](): void;
|
|
603
|
+
/** Unsubscribes from all DataStream events. Called internally via symbol. */
|
|
212
604
|
[STATE_UNSUBSCRIBE_SYMBOL](): void;
|
|
605
|
+
/** Resets all state to initial/default values. Called on connect and reconnect. */
|
|
213
606
|
clear(): void;
|
|
607
|
+
/**
|
|
608
|
+
* Handles a ConfigureConnection message from the Apple TV.
|
|
609
|
+
*
|
|
610
|
+
* @param message - The configure connection message.
|
|
611
|
+
*/
|
|
612
|
+
onConfigureConnection(message: Proto.ConfigureConnectionMessage): void;
|
|
613
|
+
/**
|
|
614
|
+
* Handles keyboard state changes. Updates internal state and emits 'keyboard'.
|
|
615
|
+
*
|
|
616
|
+
* @param message - The keyboard message with state and attributes.
|
|
617
|
+
*/
|
|
214
618
|
onKeyboard(message: Proto.KeyboardMessage): void;
|
|
619
|
+
/**
|
|
620
|
+
* Handles initial device info. Updates output device UID and cluster info.
|
|
621
|
+
*
|
|
622
|
+
* @param message - The device info message.
|
|
623
|
+
*/
|
|
215
624
|
onDeviceInfo(message: Proto.DeviceInfoMessage): void;
|
|
625
|
+
/**
|
|
626
|
+
* Handles device info updates (e.g. cluster changes). Updates output device UID and cluster info.
|
|
627
|
+
*
|
|
628
|
+
* @param message - The device info update message.
|
|
629
|
+
*/
|
|
216
630
|
onDeviceInfoUpdate(message: Proto.DeviceInfoMessage): void;
|
|
631
|
+
/**
|
|
632
|
+
* Handles origin client properties updates.
|
|
633
|
+
*
|
|
634
|
+
* @param message - The origin client properties message.
|
|
635
|
+
*/
|
|
217
636
|
onOriginClientProperties(message: Proto.OriginClientPropertiesMessage): void;
|
|
637
|
+
/**
|
|
638
|
+
* Handles player client properties updates.
|
|
639
|
+
*
|
|
640
|
+
* @param message - The player client properties message.
|
|
641
|
+
*/
|
|
218
642
|
onPlayerClientProperties(message: Proto.PlayerClientPropertiesMessage): void;
|
|
643
|
+
/**
|
|
644
|
+
* Handles removal of a client (app). Clears the now-playing reference if
|
|
645
|
+
* the removed client was the active one.
|
|
646
|
+
*
|
|
647
|
+
* @param message - The remove client message.
|
|
648
|
+
*/
|
|
219
649
|
onRemoveClient(message: Proto.RemoveClientMessage): void;
|
|
650
|
+
/**
|
|
651
|
+
* Handles command result notifications from the Apple TV.
|
|
652
|
+
*
|
|
653
|
+
* @param message - The send command result message.
|
|
654
|
+
*/
|
|
220
655
|
onSendCommandResult(message: Proto.SendCommandResultMessage): void;
|
|
656
|
+
/**
|
|
657
|
+
* Handles lyrics events (time-synced lyrics updates).
|
|
658
|
+
*
|
|
659
|
+
* @param message - The lyrics event message.
|
|
660
|
+
*/
|
|
661
|
+
onSendLyricsEvent(message: Proto.SendLyricsEventMessage): void;
|
|
662
|
+
/**
|
|
663
|
+
* Handles artwork set notifications.
|
|
664
|
+
*
|
|
665
|
+
* @param message - The set artwork message.
|
|
666
|
+
*/
|
|
221
667
|
onSetArtwork(message: Proto.SetArtworkMessage): void;
|
|
668
|
+
/**
|
|
669
|
+
* Handles default supported commands for a client. These serve as fallback
|
|
670
|
+
* commands when a player has no commands of its own.
|
|
671
|
+
*
|
|
672
|
+
* @param message - The set default supported commands message.
|
|
673
|
+
*/
|
|
222
674
|
onSetDefaultSupportedCommands(message: Proto.SetDefaultSupportedCommandsMessage): void;
|
|
675
|
+
/**
|
|
676
|
+
* Handles the now-playing client changing (e.g. user switches app).
|
|
677
|
+
* Updates the active client reference and emits change events.
|
|
678
|
+
*
|
|
679
|
+
* @param message - The set now-playing client message.
|
|
680
|
+
*/
|
|
223
681
|
onSetNowPlayingClient(message: Proto.SetNowPlayingClientMessage): void;
|
|
682
|
+
/**
|
|
683
|
+
* Handles the active player changing within a client (e.g. PiP player becomes active).
|
|
684
|
+
* Creates the player if needed and sets it as the active player.
|
|
685
|
+
*
|
|
686
|
+
* @param message - The set now-playing player message.
|
|
687
|
+
*/
|
|
224
688
|
onSetNowPlayingPlayer(message: Proto.SetNowPlayingPlayerMessage): void;
|
|
689
|
+
/**
|
|
690
|
+
* Handles comprehensive state updates. Processes playback state, now-playing info,
|
|
691
|
+
* supported commands, and playback queue in a single message.
|
|
692
|
+
* Emits granular events for each changed aspect.
|
|
693
|
+
*
|
|
694
|
+
* @param message - The set state message.
|
|
695
|
+
*/
|
|
225
696
|
onSetState(message: Proto.SetStateMessage): void;
|
|
697
|
+
/**
|
|
698
|
+
* Handles content item updates (metadata, artwork, lyrics changes for existing items).
|
|
699
|
+
*
|
|
700
|
+
* @param message - The update content item message.
|
|
701
|
+
*/
|
|
226
702
|
onUpdateContentItem(message: Proto.UpdateContentItemMessage): void;
|
|
703
|
+
/**
|
|
704
|
+
* Handles artwork updates for content items. Emits 'artworkChanged' if a client and player are active.
|
|
705
|
+
*
|
|
706
|
+
* @param message - The update content item artwork message.
|
|
707
|
+
*/
|
|
227
708
|
onUpdateContentItemArtwork(message: Proto.UpdateContentItemArtworkMessage): void;
|
|
709
|
+
/**
|
|
710
|
+
* Handles player registration or update. Creates the player if it does not exist.
|
|
711
|
+
*
|
|
712
|
+
* @param message - The update player message.
|
|
713
|
+
*/
|
|
228
714
|
onUpdatePlayer(message: Proto.UpdatePlayerMessage): void;
|
|
715
|
+
/**
|
|
716
|
+
* Handles player removal. Removes the player from its client and emits
|
|
717
|
+
* active player changed events if the removed player was active.
|
|
718
|
+
*
|
|
719
|
+
* @param message - The remove player message.
|
|
720
|
+
*/
|
|
229
721
|
onRemovePlayer(message: Proto.RemovePlayerMessage): void;
|
|
722
|
+
/**
|
|
723
|
+
* Handles client (app) registration or display name update.
|
|
724
|
+
*
|
|
725
|
+
* @param message - The update client message.
|
|
726
|
+
*/
|
|
230
727
|
onUpdateClient(message: Proto.UpdateClientMessage): void;
|
|
728
|
+
/**
|
|
729
|
+
* Handles output device list updates. Prefers cluster-aware devices when available.
|
|
730
|
+
*
|
|
731
|
+
* @param message - The update output device message.
|
|
732
|
+
*/
|
|
231
733
|
onUpdateOutputDevice(message: Proto.UpdateOutputDeviceMessage): void;
|
|
734
|
+
/**
|
|
735
|
+
* Handles volume control availability changes.
|
|
736
|
+
*
|
|
737
|
+
* @param message - The volume control availability message.
|
|
738
|
+
*/
|
|
232
739
|
onVolumeControlAvailability(message: Proto.VolumeControlAvailabilityMessage): void;
|
|
740
|
+
/**
|
|
741
|
+
* Handles volume capabilities changes (e.g. device gains or loses absolute volume support).
|
|
742
|
+
*
|
|
743
|
+
* @param message - The volume capabilities change message.
|
|
744
|
+
*/
|
|
233
745
|
onVolumeControlCapabilitiesDidChange(message: Proto.VolumeControlCapabilitiesDidChangeMessage): void;
|
|
746
|
+
/**
|
|
747
|
+
* Handles volume level changes.
|
|
748
|
+
*
|
|
749
|
+
* @param message - The volume change message.
|
|
750
|
+
*/
|
|
234
751
|
onVolumeDidChange(message: Proto.VolumeDidChangeMessage): void;
|
|
752
|
+
/**
|
|
753
|
+
* Handles mute state changes.
|
|
754
|
+
*
|
|
755
|
+
* @param message - The volume muted change message.
|
|
756
|
+
*/
|
|
757
|
+
onVolumeMutedDidChange(message: Proto.VolumeMutedDidChangeMessage): void;
|
|
235
758
|
}
|
|
236
759
|
//#endregion
|
|
237
760
|
//#region src/airplay/volume.d.ts
|
|
761
|
+
/**
|
|
762
|
+
* Smart volume controller for an AirPlay device.
|
|
763
|
+
* Automatically chooses between absolute volume (set a specific level) and
|
|
764
|
+
* relative volume (HID volume up/down keys) based on the device's reported capabilities.
|
|
765
|
+
*/
|
|
238
766
|
declare class export_default$3 {
|
|
239
767
|
#private;
|
|
768
|
+
/**
|
|
769
|
+
* Creates a new Volume controller.
|
|
770
|
+
*
|
|
771
|
+
* @param device - The AirPlay device to control volume for.
|
|
772
|
+
*/
|
|
240
773
|
constructor(device: export_default);
|
|
774
|
+
/**
|
|
775
|
+
* Decreases the volume by one step. Uses absolute volume when available,
|
|
776
|
+
* falls back to HID relative volume keys otherwise.
|
|
777
|
+
*
|
|
778
|
+
* @throws CommandError when volume control is not available.
|
|
779
|
+
*/
|
|
241
780
|
down(): Promise<void>;
|
|
781
|
+
/**
|
|
782
|
+
* Increases the volume by one step. Uses absolute volume when available,
|
|
783
|
+
* falls back to HID relative volume keys otherwise.
|
|
784
|
+
*
|
|
785
|
+
* @throws CommandError when volume control is not available.
|
|
786
|
+
*/
|
|
242
787
|
up(): Promise<void>;
|
|
788
|
+
/**
|
|
789
|
+
* Fetches the current volume level from the device.
|
|
790
|
+
*
|
|
791
|
+
* @returns The volume level as a float between 0.0 and 1.0.
|
|
792
|
+
* @throws CommandError when no output device is active or the request fails.
|
|
793
|
+
*/
|
|
243
794
|
get(): Promise<number>;
|
|
795
|
+
/**
|
|
796
|
+
* Sets the volume to an absolute level.
|
|
797
|
+
*
|
|
798
|
+
* @param volume - The desired volume level (clamped to 0.0 - 1.0).
|
|
799
|
+
* @throws CommandError when no output device is active or absolute volume is not supported.
|
|
800
|
+
*/
|
|
244
801
|
set(volume: number): Promise<void>;
|
|
245
802
|
}
|
|
246
803
|
//#endregion
|
|
247
804
|
//#region src/airplay/device.d.ts
|
|
248
|
-
|
|
805
|
+
/**
|
|
806
|
+
* Events emitted by AirPlayDevice.
|
|
807
|
+
* - `connected` — emitted after the full protocol setup completes.
|
|
808
|
+
* - `disconnected` — emitted when the connection is lost or explicitly closed.
|
|
809
|
+
*/
|
|
810
|
+
type EventMap$4 = {
|
|
249
811
|
connected: [];
|
|
250
812
|
disconnected: [unexpected: boolean];
|
|
251
813
|
};
|
|
252
|
-
|
|
814
|
+
/**
|
|
815
|
+
* High-level abstraction for an AirPlay device (Apple TV or HomePod).
|
|
816
|
+
* Manages the full lifecycle: connect, pair/verify, set up control/data/event streams,
|
|
817
|
+
* and provides access to Remote, State, and Volume controllers.
|
|
818
|
+
* Supports both transient (PIN-less) and credential-based pairing.
|
|
819
|
+
*/
|
|
820
|
+
declare class export_default extends EventEmitter<EventMap$4> {
|
|
253
821
|
#private;
|
|
822
|
+
/** @returns The underlying AirPlay Protocol instance (accessed via symbol for internal use). */
|
|
254
823
|
get [PROTOCOL](): Protocol;
|
|
824
|
+
/** The mDNS discovery result used to connect to this device. */
|
|
255
825
|
get discoveryResult(): DiscoveryResult;
|
|
826
|
+
/** Updates the discovery result, e.g. when the device's address changes. */
|
|
256
827
|
set discoveryResult(discoveryResult: DiscoveryResult);
|
|
828
|
+
/**
|
|
829
|
+
* Device capabilities derived from the AirPlay feature flags.
|
|
830
|
+
* Indicates which protocols and features the receiver supports.
|
|
831
|
+
*/
|
|
832
|
+
get capabilities(): {
|
|
833
|
+
supportsAudio: boolean;
|
|
834
|
+
supportsBufferedAudio: boolean;
|
|
835
|
+
supportsPTP: boolean;
|
|
836
|
+
supportsRFC2198Redundancy: boolean;
|
|
837
|
+
supportsHangdogRemoteControl: boolean;
|
|
838
|
+
supportsUnifiedMediaControl: boolean;
|
|
839
|
+
supportsTransientPairing: boolean;
|
|
840
|
+
supportsSystemPairing: boolean;
|
|
841
|
+
supportsCoreUtilsPairing: boolean;
|
|
842
|
+
};
|
|
843
|
+
/** Whether the control stream TCP connection is currently active. */
|
|
257
844
|
get isConnected(): boolean;
|
|
845
|
+
/** Raw receiver info dictionary from the /info endpoint, or undefined before connect. */
|
|
846
|
+
get receiverInfo(): Record<string, any> | undefined;
|
|
847
|
+
/** The Remote controller for HID keys, SendCommand, text input, and touch. */
|
|
258
848
|
get remote(): export_default$1;
|
|
849
|
+
/** The State tracker for now-playing, volume, keyboard, and output device state. */
|
|
259
850
|
get state(): export_default$2;
|
|
851
|
+
/** The Volume controller for absolute and relative volume adjustments. */
|
|
260
852
|
get volume(): export_default$3;
|
|
853
|
+
/** The shared PTP timing server, if one is assigned for multi-room sync. */
|
|
261
854
|
get timingServer(): TimingServer | undefined;
|
|
855
|
+
/** Assigns a PTP timing server for multi-room audio synchronization. */
|
|
262
856
|
set timingServer(timingServer: TimingServer | undefined);
|
|
263
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Creates a new AirPlayDevice.
|
|
859
|
+
*
|
|
860
|
+
* @param discoveryResult - The mDNS discovery result for the target device.
|
|
861
|
+
* @param identity - Optional partial device identity to present during pairing.
|
|
862
|
+
*/
|
|
863
|
+
constructor(discoveryResult: DiscoveryResult, identity?: Partial<DeviceIdentity>);
|
|
864
|
+
/**
|
|
865
|
+
* Connects to the AirPlay device, performs pairing/verification,
|
|
866
|
+
* and sets up all streams (control, data, event). Emits 'connected' on success.
|
|
867
|
+
* If credentials are set, uses pair-verify; otherwise uses transient pairing.
|
|
868
|
+
*/
|
|
264
869
|
connect(): Promise<void>;
|
|
870
|
+
/** Gracefully disconnects from the device, clears intervals, and tears down all streams. */
|
|
265
871
|
disconnect(): void;
|
|
872
|
+
/** Disconnects gracefully, swallowing any errors during cleanup. */
|
|
266
873
|
disconnectSafely(): void;
|
|
874
|
+
/**
|
|
875
|
+
* Enables or disables conversation detection on the output device (HomePod feature).
|
|
876
|
+
*
|
|
877
|
+
* @param enabled - Whether to enable conversation detection.
|
|
878
|
+
* @throws Error when no output device is active.
|
|
879
|
+
*/
|
|
880
|
+
setConversationDetectionEnabled(enabled: boolean): Promise<void>;
|
|
881
|
+
/**
|
|
882
|
+
* Adds devices to the current multi-room output context.
|
|
883
|
+
*
|
|
884
|
+
* @param deviceUIDs - UIDs of the devices to add.
|
|
885
|
+
*/
|
|
267
886
|
addOutputDevices(deviceUIDs: string[]): Promise<void>;
|
|
887
|
+
/**
|
|
888
|
+
* Removes devices from the current multi-room output context.
|
|
889
|
+
*
|
|
890
|
+
* @param deviceUIDs - UIDs of the devices to remove.
|
|
891
|
+
*/
|
|
268
892
|
removeOutputDevices(deviceUIDs: string[]): Promise<void>;
|
|
893
|
+
/**
|
|
894
|
+
* Replaces the entire multi-room output context with the given devices.
|
|
895
|
+
*
|
|
896
|
+
* @param deviceUIDs - UIDs of the devices to set as the output context.
|
|
897
|
+
*/
|
|
269
898
|
setOutputDevices(deviceUIDs: string[]): Promise<void>;
|
|
899
|
+
/**
|
|
900
|
+
* Plays a URL on the device (the device fetches and plays the content).
|
|
901
|
+
* Creates a separate Protocol instance to avoid conflicting with the
|
|
902
|
+
* existing remote control session, following the same approach as pyatv.
|
|
903
|
+
*
|
|
904
|
+
* @param url - The media URL to play.
|
|
905
|
+
* @param position - Start position in seconds (defaults to 0).
|
|
906
|
+
* @throws Error when not connected.
|
|
907
|
+
*/
|
|
270
908
|
playUrl(url: string, position?: number): Promise<void>;
|
|
909
|
+
/** Waits for the current URL playback to finish, then cleans up the play URL protocol. */
|
|
271
910
|
waitForPlaybackEnd(): Promise<void>;
|
|
911
|
+
/** Stops the current URL playback and cleans up the dedicated play URL protocol. */
|
|
272
912
|
stopPlayUrl(): void;
|
|
913
|
+
/**
|
|
914
|
+
* Streams audio from a source to the device via RAOP/RTP.
|
|
915
|
+
*
|
|
916
|
+
* @param source - The audio source to stream (e.g. MP3, WAV, URL, live).
|
|
917
|
+
*/
|
|
273
918
|
streamAudio(source: AudioSource): Promise<void>;
|
|
919
|
+
/**
|
|
920
|
+
* Requests the playback queue from the device.
|
|
921
|
+
*
|
|
922
|
+
* @param length - Maximum number of queue items to retrieve.
|
|
923
|
+
*/
|
|
274
924
|
requestPlaybackQueue(length: number): Promise<void>;
|
|
925
|
+
/**
|
|
926
|
+
* Sends a raw MRP command to the device via the DataStream.
|
|
927
|
+
*
|
|
928
|
+
* @param command - The command to send.
|
|
929
|
+
* @param options - Optional command options.
|
|
930
|
+
*/
|
|
275
931
|
sendCommand(command: Proto.Command, options?: Proto.CommandOptions): Promise<void>;
|
|
932
|
+
/**
|
|
933
|
+
* Sets the pairing credentials for pair-verify authentication.
|
|
934
|
+
* Must be called before connect() if credential-based pairing is desired.
|
|
935
|
+
*
|
|
936
|
+
* @param credentials - The accessory credentials obtained from pair-setup.
|
|
937
|
+
*/
|
|
276
938
|
setCredentials(credentials: AccessoryCredentials): void;
|
|
939
|
+
/** Handles the control stream close event. Emits 'disconnected' with unexpected=true if not intentional. */
|
|
940
|
+
onClose(): void;
|
|
941
|
+
/**
|
|
942
|
+
* Handles stream error events by logging them.
|
|
943
|
+
*
|
|
944
|
+
* @param err - The error that occurred.
|
|
945
|
+
*/
|
|
946
|
+
onError(err: Error): void;
|
|
947
|
+
/** Handles stream timeout events by destroying the control stream. */
|
|
948
|
+
onTimeout(): void;
|
|
277
949
|
}
|
|
278
950
|
//#endregion
|
|
279
951
|
//#region src/companion-link/const.d.ts
|
|
952
|
+
/** Symbol used to access the underlying Companion Link Protocol instance from a CompanionLinkDevice. */
|
|
280
953
|
declare const PROTOCOL$1: unique symbol;
|
|
281
954
|
//#endregion
|
|
955
|
+
//#region src/companion-link/state.d.ts
|
|
956
|
+
/**
|
|
957
|
+
* Events emitted by CompanionLinkState.
|
|
958
|
+
* Provides reactive state updates from the Companion Link protocol.
|
|
959
|
+
*/
|
|
960
|
+
type EventMap$3 = {
|
|
961
|
+
readonly attentionStateChanged: [AttentionState];
|
|
962
|
+
readonly mediaControlFlagsChanged: [flags: number, capabilities: MediaCapabilities];
|
|
963
|
+
readonly nowPlayingInfoChanged: [info: Record<string, unknown> | null];
|
|
964
|
+
readonly supportedActionsChanged: [actions: Record<string, unknown>];
|
|
965
|
+
readonly textInputChanged: [TextInputState];
|
|
966
|
+
readonly volumeAvailabilityChanged: [available: boolean];
|
|
967
|
+
};
|
|
968
|
+
/**
|
|
969
|
+
* Parsed media control capabilities, indicating which playback controls
|
|
970
|
+
* are currently available on the device.
|
|
971
|
+
*/
|
|
972
|
+
type MediaCapabilities = {
|
|
973
|
+
readonly play: boolean;
|
|
974
|
+
readonly pause: boolean;
|
|
975
|
+
readonly nextTrack: boolean;
|
|
976
|
+
readonly previousTrack: boolean;
|
|
977
|
+
readonly fastForward: boolean;
|
|
978
|
+
readonly rewind: boolean;
|
|
979
|
+
readonly volume: boolean;
|
|
980
|
+
readonly skipForward: boolean;
|
|
981
|
+
readonly skipBackward: boolean;
|
|
982
|
+
};
|
|
983
|
+
/**
|
|
984
|
+
* Tracks the state of a Companion Link device: attention state, media controls,
|
|
985
|
+
* now-playing info, supported actions, text input, and volume availability.
|
|
986
|
+
* Subscribes to protocol stream events and emits typed state change events.
|
|
987
|
+
*/
|
|
988
|
+
declare class CompanionLinkState extends EventEmitter<EventMap$3> {
|
|
989
|
+
#private;
|
|
990
|
+
/** Current attention state of the device (active, idle, screensaver, etc.). */
|
|
991
|
+
get attentionState(): AttentionState;
|
|
992
|
+
/** Parsed media capabilities indicating which controls are available. */
|
|
993
|
+
get mediaCapabilities(): MediaCapabilities;
|
|
994
|
+
/** Raw media control flags bitmask from the device. */
|
|
995
|
+
get mediaControlFlags(): number;
|
|
996
|
+
/** Current now-playing info as a key-value dictionary, or null. */
|
|
997
|
+
get nowPlayingInfo(): Record<string, unknown> | null;
|
|
998
|
+
/** Currently supported actions dictionary, or null. */
|
|
999
|
+
get supportedActions(): Record<string, unknown> | null;
|
|
1000
|
+
/** Current text input session state. */
|
|
1001
|
+
get textInputState(): TextInputState;
|
|
1002
|
+
/** Whether volume control is currently available via the Companion Link protocol. */
|
|
1003
|
+
get volumeAvailable(): boolean;
|
|
1004
|
+
/**
|
|
1005
|
+
* Creates a new CompanionLinkState tracker.
|
|
1006
|
+
*
|
|
1007
|
+
* @param protocol - The Companion Link protocol instance to observe.
|
|
1008
|
+
*/
|
|
1009
|
+
constructor(protocol: Protocol$1);
|
|
1010
|
+
/** Subscribes to protocol stream events and registers interests for push notifications. */
|
|
1011
|
+
subscribe(): void;
|
|
1012
|
+
/** Unsubscribes from protocol stream events and deregisters interests. */
|
|
1013
|
+
unsubscribe(): void;
|
|
1014
|
+
/** Fetches the initial attention state and media control status from the device. */
|
|
1015
|
+
fetchInitialState(): Promise<void>;
|
|
1016
|
+
/** Resets all state to initial/default values. */
|
|
1017
|
+
clear(): void;
|
|
1018
|
+
/**
|
|
1019
|
+
* Handles media control flag updates (_iMC). Parses the flags bitmask and
|
|
1020
|
+
* emits events if capabilities or volume availability changed.
|
|
1021
|
+
*
|
|
1022
|
+
* @param data - The raw media control payload.
|
|
1023
|
+
*/
|
|
1024
|
+
onMediaControl(data: unknown): void;
|
|
1025
|
+
/**
|
|
1026
|
+
* Handles SystemStatus events (attention state changes from non-TV devices).
|
|
1027
|
+
*
|
|
1028
|
+
* @param data - The raw system status payload containing a state code.
|
|
1029
|
+
*/
|
|
1030
|
+
onSystemStatus(data: unknown): void;
|
|
1031
|
+
/**
|
|
1032
|
+
* Handles TVSystemStatus events (attention state changes from Apple TV).
|
|
1033
|
+
*
|
|
1034
|
+
* @param data - The raw TV system status payload containing a state code.
|
|
1035
|
+
*/
|
|
1036
|
+
onTVSystemStatus(data: unknown): void;
|
|
1037
|
+
/**
|
|
1038
|
+
* Handles NowPlayingInfo updates. Decodes the NSKeyedArchiver plist payload
|
|
1039
|
+
* when present, otherwise uses the raw dictionary.
|
|
1040
|
+
*
|
|
1041
|
+
* @param data - The raw now-playing info payload.
|
|
1042
|
+
*/
|
|
1043
|
+
onNowPlayingInfo(data: unknown): void;
|
|
1044
|
+
/**
|
|
1045
|
+
* Handles SupportedActions updates from the device.
|
|
1046
|
+
*
|
|
1047
|
+
* @param data - The raw supported actions payload.
|
|
1048
|
+
*/
|
|
1049
|
+
onSupportedActions(data: unknown): void;
|
|
1050
|
+
/**
|
|
1051
|
+
* Handles the start of a text input session. Parses the plist payload to extract
|
|
1052
|
+
* document text, security mode, keyboard type, and autocorrection settings.
|
|
1053
|
+
*
|
|
1054
|
+
* @param data - The raw text input started payload.
|
|
1055
|
+
*/
|
|
1056
|
+
onTextInputStarted(data: unknown): void;
|
|
1057
|
+
/**
|
|
1058
|
+
* Handles the end of a text input session. Resets the text input state to defaults.
|
|
1059
|
+
*
|
|
1060
|
+
* @param _data - The raw text input stopped payload (unused).
|
|
1061
|
+
*/
|
|
1062
|
+
onTextInputStopped(_data: unknown): void;
|
|
1063
|
+
}
|
|
1064
|
+
//#endregion
|
|
282
1065
|
//#region src/companion-link/device.d.ts
|
|
1066
|
+
/**
|
|
1067
|
+
* Events emitted by CompanionLinkDevice.
|
|
1068
|
+
* Forwards state change events from CompanionLinkState for convenience.
|
|
1069
|
+
*/
|
|
283
1070
|
type EventMap$2 = {
|
|
284
1071
|
connected: [];
|
|
285
1072
|
disconnected: [unexpected: boolean];
|
|
286
|
-
|
|
287
|
-
|
|
1073
|
+
attentionStateChanged: [AttentionState];
|
|
1074
|
+
mediaControlFlagsChanged: [flags: number, capabilities: MediaCapabilities];
|
|
1075
|
+
nowPlayingInfoChanged: [info: Record<string, unknown> | null];
|
|
1076
|
+
supportedActionsChanged: [actions: Record<string, unknown>];
|
|
1077
|
+
textInputChanged: [TextInputState];
|
|
1078
|
+
volumeAvailabilityChanged: [available: boolean];
|
|
288
1079
|
};
|
|
1080
|
+
/**
|
|
1081
|
+
* High-level abstraction for a Companion Link device (Apple TV).
|
|
1082
|
+
* Manages the OPack-based Companion Link protocol lifecycle: connect, pair-verify,
|
|
1083
|
+
* session setup, and provides access to HID buttons, app launching, user accounts,
|
|
1084
|
+
* media control, text input, touch, Siri, and system controls.
|
|
1085
|
+
* Requires credentials (obtained from pair-setup) to connect.
|
|
1086
|
+
*/
|
|
289
1087
|
declare class export_default$5 extends EventEmitter<EventMap$2> {
|
|
290
1088
|
#private;
|
|
1089
|
+
/** @returns The underlying Companion Link Protocol instance (accessed via symbol for internal use). */
|
|
291
1090
|
get [PROTOCOL$1](): Protocol$1;
|
|
1091
|
+
/** The mDNS discovery result used to connect to this device. */
|
|
292
1092
|
get discoveryResult(): DiscoveryResult;
|
|
1093
|
+
/** Updates the discovery result, e.g. when the device's address changes. */
|
|
293
1094
|
set discoveryResult(discoveryResult: DiscoveryResult);
|
|
1095
|
+
/** Whether the Companion Link stream is currently connected. */
|
|
294
1096
|
get isConnected(): boolean;
|
|
1097
|
+
/** The state tracker for attention, media controls, now-playing, and text input. */
|
|
1098
|
+
get state(): CompanionLinkState;
|
|
1099
|
+
/** Current text input session state (convenience accessor). */
|
|
295
1100
|
get textInputState(): TextInputState;
|
|
1101
|
+
/**
|
|
1102
|
+
* Creates a new CompanionLinkDevice.
|
|
1103
|
+
*
|
|
1104
|
+
* @param discoveryResult - The mDNS discovery result for the target device.
|
|
1105
|
+
*/
|
|
296
1106
|
constructor(discoveryResult: DiscoveryResult);
|
|
1107
|
+
/**
|
|
1108
|
+
* Connects to the Companion Link device, performs pair-verify, and sets up
|
|
1109
|
+
* all protocol sessions (system info, TVRC, touch, text input).
|
|
1110
|
+
* Emits 'connected' on success.
|
|
1111
|
+
*
|
|
1112
|
+
* @throws CredentialsError when no credentials are set.
|
|
1113
|
+
*/
|
|
297
1114
|
connect(): Promise<void>;
|
|
1115
|
+
/** Gracefully disconnects from the device, clears heartbeat interval, and unsubscribes from events. */
|
|
298
1116
|
disconnect(): Promise<void>;
|
|
1117
|
+
/** Disconnects gracefully, swallowing any errors during cleanup. */
|
|
299
1118
|
disconnectSafely(): Promise<void>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Sets the pairing credentials required for pair-verify authentication.
|
|
1121
|
+
* Must be called before connect().
|
|
1122
|
+
*
|
|
1123
|
+
* @param credentials - The accessory credentials from pair-setup.
|
|
1124
|
+
*/
|
|
300
1125
|
setCredentials(credentials: AccessoryCredentials): Promise<void>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Fetches the current attention state of the device (active, idle, screensaver, etc.).
|
|
1128
|
+
*
|
|
1129
|
+
* @returns The current attention state.
|
|
1130
|
+
*/
|
|
301
1131
|
getAttentionState(): Promise<AttentionState>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Fetches the list of apps that can be launched on the device.
|
|
1134
|
+
*
|
|
1135
|
+
* @returns Array of launchable app descriptors.
|
|
1136
|
+
*/
|
|
302
1137
|
getLaunchableApps(): Promise<LaunchableApp[]>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Fetches the list of user accounts configured on the device.
|
|
1140
|
+
*
|
|
1141
|
+
* @returns Array of user account descriptors.
|
|
1142
|
+
*/
|
|
303
1143
|
getUserAccounts(): Promise<UserAccount[]>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Fetches the current now-playing information from the device.
|
|
1146
|
+
*
|
|
1147
|
+
* @returns The now-playing info payload.
|
|
1148
|
+
*/
|
|
1149
|
+
fetchNowPlayingInfo(): Promise<any>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Fetches the currently supported actions from the device.
|
|
1152
|
+
*
|
|
1153
|
+
* @returns The supported actions payload.
|
|
1154
|
+
*/
|
|
1155
|
+
fetchSupportedActions(): Promise<any>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Fetches the current media control status (available controls bitmask).
|
|
1158
|
+
*
|
|
1159
|
+
* @returns The media control status payload.
|
|
1160
|
+
*/
|
|
1161
|
+
fetchMediaControlStatus(): Promise<any>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Launches an app on the device by its bundle identifier.
|
|
1164
|
+
*
|
|
1165
|
+
* @param bundleId - The bundle identifier of the app to launch.
|
|
1166
|
+
*/
|
|
304
1167
|
launchApp(bundleId: string): Promise<void>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Opens a URL on the device (universal link or app-specific URL scheme).
|
|
1170
|
+
*
|
|
1171
|
+
* @param url - The URL to open.
|
|
1172
|
+
*/
|
|
305
1173
|
launchUrl(url: string): Promise<void>;
|
|
306
|
-
|
|
1174
|
+
/**
|
|
1175
|
+
* Sends a media control command (play, pause, next, etc.) via the Companion Link protocol.
|
|
1176
|
+
*
|
|
1177
|
+
* @param command - The media control command key.
|
|
1178
|
+
* @param content - Optional additional content for the command.
|
|
1179
|
+
*/
|
|
1180
|
+
mediaControlCommand(command: MediaControlCommandKey, content?: Record<string, unknown>): Promise<void>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Sends a HID button press via the Companion Link protocol.
|
|
1183
|
+
*
|
|
1184
|
+
* @param command - The HID command key (e.g. 'up', 'select', 'menu').
|
|
1185
|
+
* @param type - Optional press type (short, long, double).
|
|
1186
|
+
* @param holdDelayMs - Optional hold duration in milliseconds for long presses.
|
|
1187
|
+
*/
|
|
307
1188
|
pressButton(command: HidCommandKey, type?: ButtonPressType, holdDelayMs?: number): Promise<void>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Switches to a different user account on the device.
|
|
1191
|
+
*
|
|
1192
|
+
* @param accountId - The ID of the user account to switch to.
|
|
1193
|
+
*/
|
|
308
1194
|
switchUserAccount(accountId: string): Promise<void>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Sets the text input field to the given text, replacing any existing content.
|
|
1197
|
+
*
|
|
1198
|
+
* @param text - The text to set.
|
|
1199
|
+
*/
|
|
309
1200
|
textSet(text: string): Promise<void>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Appends text to the current text input field content.
|
|
1203
|
+
*
|
|
1204
|
+
* @param text - The text to append.
|
|
1205
|
+
*/
|
|
310
1206
|
textAppend(text: string): Promise<void>;
|
|
1207
|
+
/** Clears the text input field. */
|
|
311
1208
|
textClear(): Promise<void>;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
1209
|
+
/**
|
|
1210
|
+
* Sends a raw touch event to the device.
|
|
1211
|
+
*
|
|
1212
|
+
* @param finger - Finger index (0-based).
|
|
1213
|
+
* @param phase - Touch phase (0 = Began, 1 = Moved, 2 = Ended).
|
|
1214
|
+
* @param x - Horizontal position.
|
|
1215
|
+
* @param y - Vertical position.
|
|
1216
|
+
*/
|
|
1217
|
+
sendTouchEvent(finger: number, phase: number, x: number, y: number): Promise<void>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Simulates a tap at the given coordinates.
|
|
1220
|
+
*
|
|
1221
|
+
* @param x - Horizontal position (defaults to center 500).
|
|
1222
|
+
* @param y - Vertical position (defaults to center 500).
|
|
1223
|
+
*/
|
|
1224
|
+
tap(x?: number, y?: number): Promise<void>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Simulates a swipe gesture in the given direction.
|
|
1227
|
+
*
|
|
1228
|
+
* @param direction - Swipe direction.
|
|
1229
|
+
* @param duration - Swipe duration in milliseconds (defaults to 200).
|
|
1230
|
+
*/
|
|
1231
|
+
swipe(direction: 'up' | 'down' | 'left' | 'right', duration?: number): Promise<void>;
|
|
1232
|
+
/** Toggles closed captions on the device. */
|
|
1233
|
+
toggleCaptions(): Promise<void>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Toggles the system appearance between light and dark mode.
|
|
1236
|
+
*
|
|
1237
|
+
* @param light - True for light mode, false for dark mode.
|
|
1238
|
+
*/
|
|
1239
|
+
toggleSystemAppearance(light: boolean): Promise<void>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Enables or disables the "Reduce Loud Sounds" setting.
|
|
1242
|
+
*
|
|
1243
|
+
* @param enabled - Whether to enable the setting.
|
|
1244
|
+
*/
|
|
1245
|
+
toggleReduceLoudSounds(enabled: boolean): Promise<void>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Enables or disables finding mode (Find My integration).
|
|
1248
|
+
*
|
|
1249
|
+
* @param enabled - Whether to enable finding mode.
|
|
1250
|
+
*/
|
|
1251
|
+
toggleFindingMode(enabled: boolean): Promise<void>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Fetches the "Up Next" queue from the device.
|
|
1254
|
+
*
|
|
1255
|
+
* @param paginationToken - Optional token for paginated results.
|
|
1256
|
+
* @returns The Up Next queue payload.
|
|
1257
|
+
*/
|
|
1258
|
+
fetchUpNext(paginationToken?: string): Promise<any>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Adds an item to the "Up Next" queue.
|
|
1261
|
+
*
|
|
1262
|
+
* @param identifier - Content item identifier.
|
|
1263
|
+
* @param kind - Content kind descriptor.
|
|
1264
|
+
*/
|
|
1265
|
+
addToUpNext(identifier: string, kind: string): Promise<void>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Removes an item from the "Up Next" queue.
|
|
1268
|
+
*
|
|
1269
|
+
* @param identifier - Content item identifier.
|
|
1270
|
+
* @param kind - Content kind descriptor.
|
|
1271
|
+
*/
|
|
1272
|
+
removeFromUpNext(identifier: string, kind: string): Promise<void>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Marks a content item as watched.
|
|
1275
|
+
*
|
|
1276
|
+
* @param identifier - Content item identifier.
|
|
1277
|
+
* @param kind - Content kind descriptor.
|
|
1278
|
+
*/
|
|
1279
|
+
markAsWatched(identifier: string, kind: string): Promise<void>;
|
|
1280
|
+
/** Starts a Siri session on the device. */
|
|
1281
|
+
siriStart(): Promise<void>;
|
|
1282
|
+
/** Stops the active Siri session on the device. */
|
|
1283
|
+
siriStop(): Promise<void>;
|
|
1284
|
+
/** Handles the stream close event. Emits 'disconnected' with unexpected=true if not intentional. */
|
|
1285
|
+
onClose(): void;
|
|
1286
|
+
/**
|
|
1287
|
+
* Handles stream error events by logging them.
|
|
1288
|
+
*
|
|
1289
|
+
* @param err - The error that occurred.
|
|
1290
|
+
*/
|
|
1291
|
+
onError(err: Error): void;
|
|
1292
|
+
/** Handles stream timeout events by destroying the stream. */
|
|
1293
|
+
onTimeout(): void;
|
|
318
1294
|
}
|
|
319
1295
|
//#endregion
|
|
320
1296
|
//#region src/model/apple-tv.d.ts
|
|
1297
|
+
/**
|
|
1298
|
+
* Events emitted by AppleTV.
|
|
1299
|
+
* - `connected` — emitted after both AirPlay and Companion Link are connected.
|
|
1300
|
+
* - `disconnected` — emitted when either connection is lost.
|
|
1301
|
+
* - `power` — emitted when the device's attention state changes.
|
|
1302
|
+
* - `textInput` — emitted when a text input session starts, changes, or stops.
|
|
1303
|
+
*/
|
|
321
1304
|
type EventMap$1 = {
|
|
322
1305
|
connected: [];
|
|
323
1306
|
disconnected: [unexpected: boolean];
|
|
324
1307
|
power: [AttentionState];
|
|
325
1308
|
textInput: [TextInputState];
|
|
326
1309
|
};
|
|
1310
|
+
/**
|
|
1311
|
+
* High-level Apple TV device model combining AirPlay (remote control, media, streaming)
|
|
1312
|
+
* and Companion Link (apps, accounts, power, text input) protocols.
|
|
1313
|
+
* Provides a unified interface for controlling an Apple TV.
|
|
1314
|
+
*/
|
|
327
1315
|
declare class export_default$4 extends EventEmitter<EventMap$1> {
|
|
328
1316
|
#private;
|
|
1317
|
+
/** The underlying AirPlay device for direct protocol access. */
|
|
329
1318
|
get airplay(): export_default;
|
|
1319
|
+
/** The underlying Companion Link device for direct protocol access. */
|
|
330
1320
|
get companionLink(): export_default$5;
|
|
1321
|
+
/** AirPlay remote controller for HID keys and commands. */
|
|
331
1322
|
get remote(): export_default$1;
|
|
1323
|
+
/** AirPlay state tracker for now-playing, volume, and keyboard. */
|
|
332
1324
|
get state(): export_default$2;
|
|
1325
|
+
/** AirPlay volume controller. */
|
|
333
1326
|
get volumeControl(): export_default$3;
|
|
1327
|
+
/** Bundle identifier of the currently playing app, or null. */
|
|
334
1328
|
get bundleIdentifier(): string | null;
|
|
1329
|
+
/** Display name of the currently playing app, or null. */
|
|
335
1330
|
get displayName(): string | null;
|
|
1331
|
+
/** Whether both AirPlay and Companion Link are connected. */
|
|
336
1332
|
get isConnected(): boolean;
|
|
1333
|
+
/** Whether the active player is currently playing. */
|
|
337
1334
|
get isPlaying(): boolean;
|
|
1335
|
+
/** Current track title. */
|
|
338
1336
|
get title(): string;
|
|
1337
|
+
/** Current track artist. */
|
|
339
1338
|
get artist(): string;
|
|
1339
|
+
/** Current track album. */
|
|
340
1340
|
get album(): string;
|
|
1341
|
+
/** Duration of the current track in seconds. */
|
|
341
1342
|
get duration(): number;
|
|
1343
|
+
/** Extrapolated elapsed time in seconds. */
|
|
342
1344
|
get elapsedTime(): number;
|
|
1345
|
+
/** Current playback queue from the active player. */
|
|
343
1346
|
get playbackQueue(): AirPlay.Proto.PlaybackQueue | null;
|
|
1347
|
+
/** Current playback state. */
|
|
344
1348
|
get playbackState(): AirPlay.Proto.PlaybackState_Enum;
|
|
1349
|
+
/** Timestamp of the last playback state update. */
|
|
345
1350
|
get playbackStateTimestamp(): number;
|
|
1351
|
+
/** Current volume level (0.0 - 1.0). */
|
|
346
1352
|
get volume(): number;
|
|
1353
|
+
/**
|
|
1354
|
+
* Creates a new AppleTV instance.
|
|
1355
|
+
*
|
|
1356
|
+
* @param airplayDiscoveryResult - The mDNS discovery result for the AirPlay service.
|
|
1357
|
+
* @param companionLinkDiscoveryResult - The mDNS discovery result for the Companion Link service.
|
|
1358
|
+
*/
|
|
347
1359
|
constructor(airplayDiscoveryResult: DiscoveryResult, companionLinkDiscoveryResult: DiscoveryResult);
|
|
1360
|
+
/**
|
|
1361
|
+
* Connects both AirPlay and Companion Link protocols.
|
|
1362
|
+
* If Companion Link fails, AirPlay is disconnected to maintain consistency.
|
|
1363
|
+
*
|
|
1364
|
+
* @param airplayCredentials - Credentials for the AirPlay service.
|
|
1365
|
+
* @param companionLinkCredentials - Optional separate credentials for Companion Link (defaults to AirPlay credentials).
|
|
1366
|
+
*/
|
|
348
1367
|
connect(airplayCredentials: AccessoryCredentials, companionLinkCredentials?: AccessoryCredentials): Promise<void>;
|
|
1368
|
+
/** Disconnects both AirPlay and Companion Link protocols. */
|
|
349
1369
|
disconnect(): Promise<void>;
|
|
1370
|
+
/** Puts the Apple TV to sleep via a suspend HID key press. */
|
|
350
1371
|
turnOff(): Promise<void>;
|
|
1372
|
+
/** Wakes the Apple TV from sleep via a wake HID key press. */
|
|
351
1373
|
turnOn(): Promise<void>;
|
|
1374
|
+
/** Sends a Pause command. */
|
|
352
1375
|
pause(): Promise<void>;
|
|
1376
|
+
/** Sends a TogglePlayPause command. */
|
|
353
1377
|
playPause(): Promise<void>;
|
|
1378
|
+
/** Sends a Play command. */
|
|
354
1379
|
play(): Promise<void>;
|
|
1380
|
+
/** Sends a Stop command. */
|
|
355
1381
|
stop(): Promise<void>;
|
|
1382
|
+
/** Sends a NextInContext command (next track/episode). */
|
|
356
1383
|
next(): Promise<void>;
|
|
1384
|
+
/** Sends a PreviousInContext command (previous track/episode). */
|
|
357
1385
|
previous(): Promise<void>;
|
|
1386
|
+
/** Decreases volume via HID volume down key. */
|
|
358
1387
|
volumeDown(): Promise<void>;
|
|
1388
|
+
/** Toggles mute via HID mute key. */
|
|
359
1389
|
volumeMute(): Promise<void>;
|
|
1390
|
+
/** Increases volume via HID volume up key. */
|
|
360
1391
|
volumeUp(): Promise<void>;
|
|
1392
|
+
/**
|
|
1393
|
+
* Fetches the current attention state via Companion Link.
|
|
1394
|
+
*
|
|
1395
|
+
* @returns The current attention state.
|
|
1396
|
+
*/
|
|
361
1397
|
getAttentionState(): Promise<AttentionState>;
|
|
1398
|
+
/**
|
|
1399
|
+
* Fetches the list of launchable apps via Companion Link.
|
|
1400
|
+
*
|
|
1401
|
+
* @returns Array of launchable app descriptors.
|
|
1402
|
+
*/
|
|
362
1403
|
getLaunchableApps(): Promise<LaunchableApp[]>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Fetches user accounts configured on the device via Companion Link.
|
|
1406
|
+
*
|
|
1407
|
+
* @returns Array of user account descriptors.
|
|
1408
|
+
*/
|
|
363
1409
|
getUserAccounts(): Promise<UserAccount[]>;
|
|
1410
|
+
/**
|
|
1411
|
+
* Launches an app via Companion Link.
|
|
1412
|
+
*
|
|
1413
|
+
* @param bundleId - The bundle identifier of the app to launch.
|
|
1414
|
+
*/
|
|
364
1415
|
launchApp(bundleId: string): Promise<void>;
|
|
1416
|
+
/**
|
|
1417
|
+
* Switches user account via Companion Link.
|
|
1418
|
+
*
|
|
1419
|
+
* @param accountId - The ID of the user account to switch to.
|
|
1420
|
+
*/
|
|
365
1421
|
switchUserAccount(accountId: string): Promise<void>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Sets the text input field to the given text via Companion Link.
|
|
1424
|
+
*
|
|
1425
|
+
* @param text - The text to set.
|
|
1426
|
+
*/
|
|
366
1427
|
textSet(text: string): Promise<void>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Appends text to the text input field via Companion Link.
|
|
1430
|
+
*
|
|
1431
|
+
* @param text - The text to append.
|
|
1432
|
+
*/
|
|
367
1433
|
textAppend(text: string): Promise<void>;
|
|
1434
|
+
/** Clears the text input field via Companion Link. */
|
|
368
1435
|
textClear(): Promise<void>;
|
|
1436
|
+
/**
|
|
1437
|
+
* Gets the CommandInfo for a specific command from the active player.
|
|
1438
|
+
*
|
|
1439
|
+
* @param command - The command to look up.
|
|
1440
|
+
* @returns The command info, or null if no client is active or command not found.
|
|
1441
|
+
*/
|
|
369
1442
|
getCommandInfo(command: AirPlay.Proto.Command): Promise<AirPlay.Proto.CommandInfo | null>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Checks whether a command is supported and enabled by the active player.
|
|
1445
|
+
*
|
|
1446
|
+
* @param command - The command to check.
|
|
1447
|
+
* @returns True if supported and enabled, false otherwise.
|
|
1448
|
+
*/
|
|
370
1449
|
isCommandSupported(command: AirPlay.Proto.Command): Promise<boolean>;
|
|
371
1450
|
}
|
|
372
1451
|
//#endregion
|
|
373
1452
|
//#region src/model/homepod-base.d.ts
|
|
1453
|
+
/**
|
|
1454
|
+
* Events emitted by HomePod models.
|
|
1455
|
+
* - `connected` — emitted after the AirPlay connection is established.
|
|
1456
|
+
* - `disconnected` — emitted when the connection is lost.
|
|
1457
|
+
*/
|
|
374
1458
|
type EventMap = {
|
|
375
1459
|
connected: [];
|
|
376
1460
|
disconnected: [unexpected: boolean];
|
|
377
1461
|
};
|
|
1462
|
+
/**
|
|
1463
|
+
* Abstract base class for HomePod models (HomePod and HomePod Mini).
|
|
1464
|
+
* Uses AirPlay only (no Companion Link). Supports transient pairing, media control,
|
|
1465
|
+
* URL playback, and audio streaming.
|
|
1466
|
+
*/
|
|
378
1467
|
declare abstract class export_default$8 extends EventEmitter<EventMap> {
|
|
379
1468
|
#private;
|
|
1469
|
+
/** The underlying AirPlay device for direct protocol access. */
|
|
380
1470
|
get airplay(): export_default;
|
|
1471
|
+
/** AirPlay remote controller for HID keys and commands. */
|
|
381
1472
|
get remote(): export_default$1;
|
|
1473
|
+
/** AirPlay state tracker for now-playing and volume. */
|
|
382
1474
|
get state(): export_default$2;
|
|
1475
|
+
/** AirPlay volume controller. */
|
|
383
1476
|
get volumeControl(): export_default$3;
|
|
1477
|
+
/** Bundle identifier of the currently playing app, or null. */
|
|
384
1478
|
get bundleIdentifier(): string | null;
|
|
1479
|
+
/** Display name of the currently playing app, or null. */
|
|
385
1480
|
get displayName(): string | null;
|
|
1481
|
+
/** Whether the AirPlay connection is active. */
|
|
386
1482
|
get isConnected(): boolean;
|
|
1483
|
+
/** Whether the active player is currently playing. */
|
|
387
1484
|
get isPlaying(): boolean;
|
|
1485
|
+
/** Current track title. */
|
|
388
1486
|
get title(): string;
|
|
1487
|
+
/** Current track artist. */
|
|
389
1488
|
get artist(): string;
|
|
1489
|
+
/** Current track album. */
|
|
390
1490
|
get album(): string;
|
|
1491
|
+
/** Duration of the current track in seconds. */
|
|
391
1492
|
get duration(): number;
|
|
1493
|
+
/** Extrapolated elapsed time in seconds. */
|
|
392
1494
|
get elapsedTime(): number;
|
|
1495
|
+
/** Current playback queue from the active player. */
|
|
393
1496
|
get playbackQueue(): AirPlay.Proto.PlaybackQueue | null;
|
|
1497
|
+
/** Current playback state. */
|
|
394
1498
|
get playbackState(): AirPlay.Proto.PlaybackState_Enum;
|
|
1499
|
+
/** Timestamp of the last playback state update. */
|
|
395
1500
|
get playbackStateTimestamp(): number;
|
|
1501
|
+
/** Current volume level (0.0 - 1.0). */
|
|
396
1502
|
get volume(): number;
|
|
1503
|
+
/**
|
|
1504
|
+
* Creates a new HomePod base instance.
|
|
1505
|
+
*
|
|
1506
|
+
* @param discoveryResult - The mDNS discovery result for the AirPlay service.
|
|
1507
|
+
*/
|
|
397
1508
|
constructor(discoveryResult: DiscoveryResult);
|
|
1509
|
+
/** Connects to the HomePod via AirPlay (transient pairing). */
|
|
398
1510
|
connect(): Promise<void>;
|
|
1511
|
+
/** Disconnects from the HomePod. */
|
|
399
1512
|
disconnect(): Promise<void>;
|
|
1513
|
+
/** Sends a Pause command. */
|
|
400
1514
|
pause(): Promise<void>;
|
|
1515
|
+
/** Sends a TogglePlayPause command. */
|
|
401
1516
|
playPause(): Promise<void>;
|
|
1517
|
+
/** Sends a Play command. */
|
|
402
1518
|
play(): Promise<void>;
|
|
1519
|
+
/** Sends a Stop command. */
|
|
403
1520
|
stop(): Promise<void>;
|
|
1521
|
+
/** Sends a NextInContext command (next track). */
|
|
404
1522
|
next(): Promise<void>;
|
|
1523
|
+
/** Sends a PreviousInContext command (previous track). */
|
|
405
1524
|
previous(): Promise<void>;
|
|
1525
|
+
/**
|
|
1526
|
+
* Plays a URL on the HomePod (the device fetches and plays the content).
|
|
1527
|
+
*
|
|
1528
|
+
* @param url - The media URL to play.
|
|
1529
|
+
* @param position - Start position in seconds (defaults to 0).
|
|
1530
|
+
*/
|
|
406
1531
|
playUrl(url: string, position?: number): Promise<void>;
|
|
1532
|
+
/** Waits for the current URL playback to finish. */
|
|
407
1533
|
waitForPlaybackEnd(): Promise<void>;
|
|
1534
|
+
/** Stops the current URL playback and cleans up. */
|
|
408
1535
|
stopPlayUrl(): void;
|
|
1536
|
+
/**
|
|
1537
|
+
* Streams audio from a source to the HomePod via RAOP/RTP.
|
|
1538
|
+
*
|
|
1539
|
+
* @param source - The audio source to stream.
|
|
1540
|
+
*/
|
|
409
1541
|
streamAudio(source: AudioSource): Promise<void>;
|
|
1542
|
+
/**
|
|
1543
|
+
* Gets the CommandInfo for a specific command from the active player.
|
|
1544
|
+
*
|
|
1545
|
+
* @param command - The command to look up.
|
|
1546
|
+
* @returns The command info, or null if no client is active or command not found.
|
|
1547
|
+
*/
|
|
410
1548
|
getCommandInfo(command: AirPlay.Proto.Command): Promise<AirPlay.Proto.CommandInfo | null>;
|
|
1549
|
+
/**
|
|
1550
|
+
* Checks whether a command is supported and enabled by the active player.
|
|
1551
|
+
*
|
|
1552
|
+
* @param command - The command to check.
|
|
1553
|
+
* @returns True if supported and enabled, false otherwise.
|
|
1554
|
+
*/
|
|
411
1555
|
isCommandSupported(command: AirPlay.Proto.Command): Promise<boolean>;
|
|
412
1556
|
}
|
|
413
1557
|
//#endregion
|
|
414
1558
|
//#region src/model/homepod.d.ts
|
|
1559
|
+
/**
|
|
1560
|
+
* HomePod device model. AirPlay only (no Companion Link).
|
|
1561
|
+
* Supports media control, URL playback, audio streaming, and volume control.
|
|
1562
|
+
*/
|
|
415
1563
|
declare class export_default$6 extends export_default$8 {}
|
|
416
1564
|
//#endregion
|
|
417
1565
|
//#region src/model/homepod-mini.d.ts
|
|
1566
|
+
/**
|
|
1567
|
+
* HomePod Mini device model. AirPlay only (no Companion Link).
|
|
1568
|
+
* Identical feature set to HomePod, distinguished for device model identification.
|
|
1569
|
+
*/
|
|
418
1570
|
declare class export_default$7 extends export_default$8 {}
|
|
419
1571
|
//#endregion
|
|
420
1572
|
export { PROTOCOL as AIRPLAY, Client as AirPlayClient, export_default as AirPlayDevice, Player as AirPlayPlayer, export_default$1 as AirPlayRemote, export_default$2 as AirPlayState, export_default$3 as AirPlayVolume, export_default$4 as AppleTV, PROTOCOL$1 as COMPANION_LINK, export_default$5 as CompanionLinkDevice, export_default$6 as HomePod, export_default$7 as HomePodMini, SendCommandError };
|