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