@basmilius/apple-companion-link 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -26,6 +26,16 @@ declare const HidCommand: {
26
26
  readonly Guide: 17;
27
27
  readonly PageUp: 18;
28
28
  readonly PageDown: 19;
29
+ readonly SkipForward: 20;
30
+ readonly SkipBackward: 21;
31
+ readonly Back: 22;
32
+ readonly Exit: 23;
33
+ readonly Info: 24;
34
+ readonly CaptionsToggle: 25;
35
+ readonly Accessibility: 26;
36
+ readonly InputSelect: 27;
37
+ readonly Mute: 29;
38
+ readonly Power: 30;
29
39
  };
30
40
  /**
31
41
  * Media control command identifiers for playback and caption control.
@@ -303,8 +313,8 @@ declare class Protocol {
303
313
  * NoOp frames are always sent unencrypted regardless of encryption state.
304
314
  */
305
315
  noOp(): void;
306
- /** The Apple TV's reported protocol source version number (e.g. `715.2`). */
307
- get sourceVersion(): number;
316
+ /** The Apple TV's reported protocol source version string (e.g. `715.2`). */
317
+ get sourceVersion(): string;
308
318
  /** Whether this Apple TV supports media control commands (sourceVersion >= 250.3). */
309
319
  get supportsMediaControl(): boolean;
310
320
  /** Whether this Apple TV supports remote text input (sourceVersion >= 340.15). */
@@ -418,6 +428,24 @@ declare class Protocol {
418
428
  */
419
429
  mediaControlCommand(command: MediaControlCommandKey, content?: Record<string, unknown>): Promise<object>;
420
430
  /**
431
+ * Skips forward or backward by a given number of seconds.
432
+ *
433
+ * @param seconds - Number of seconds to skip (positive = forward, negative = backward).
434
+ */
435
+ skipBySeconds(seconds: number): Promise<object>;
436
+ /**
437
+ * Gets the current caption/subtitle settings.
438
+ *
439
+ * @returns The caption settings response.
440
+ */
441
+ getCaptionSetting(): Promise<object>;
442
+ /**
443
+ * Enables or disables captions/subtitles.
444
+ *
445
+ * @param enabled - Whether captions should be enabled.
446
+ */
447
+ setCaptionSetting(enabled: boolean): Promise<object>;
448
+ /**
421
449
  * Launches an app on the Apple TV by its bundle identifier.
422
450
  *
423
451
  * @param bundleId - The bundle identifier of the app to launch.
@@ -528,6 +556,21 @@ declare class Protocol {
528
556
  */
529
557
  toggleFindingMode(enabled: boolean): Promise<void>;
530
558
  /**
559
+ * Wakes the Apple TV by sending a wake HID key.
560
+ * Checks the attention state first and only sends if the device is idle.
561
+ */
562
+ wakeDevice(): Promise<void>;
563
+ /**
564
+ * Puts the Apple TV to sleep.
565
+ */
566
+ sleepDevice(): Promise<void>;
567
+ /**
568
+ * Checks whether the Apple TV is currently awake (actively in use).
569
+ *
570
+ * @returns `true` if the device is awake/active, `false` if idle or unknown.
571
+ */
572
+ isAwake(): Promise<boolean>;
573
+ /**
531
574
  * Fetches the Up Next queue from the Apple TV.
532
575
  *
533
576
  * @param paginationToken - Optional token to fetch the next page of results.
@@ -570,6 +613,46 @@ declare class Protocol {
570
613
  * Deactivates Siri (releases push-to-talk) on the Apple TV.
571
614
  */
572
615
  siriStop(): Promise<void>;
616
+ /**
617
+ * Starts a game controller session on the Apple TV.
618
+ */
619
+ gameControllerStart(): Promise<void>;
620
+ /**
621
+ * Stops the game controller session.
622
+ */
623
+ gameControllerStop(): Promise<void>;
624
+ /**
625
+ * Sends a game controller event with analog stick position and button state.
626
+ *
627
+ * @param x - X coordinate (-1.0 to 1.0).
628
+ * @param y - Y coordinate (-1.0 to 1.0).
629
+ * @param isDown - Whether the button is pressed.
630
+ */
631
+ sendGameControllerEvent(x: number, y: number, isDown: boolean): void;
632
+ /**
633
+ * Initiates an app sign-in proxy flow, allowing the Apple TV app
634
+ * to authenticate via the paired companion device.
635
+ *
636
+ * @param bundleId - The bundle identifier of the app requesting sign-in.
637
+ * @param requestType - The sign-in method ('appleID', 'password', or 'custom').
638
+ * @returns The sign-in response from the Apple TV.
639
+ */
640
+ requestAppSignIn(bundleId: string, requestType?: string): Promise<object>;
641
+ /**
642
+ * Initiates a TV provider (MVPD) authentication flow on the Apple TV.
643
+ *
644
+ * @param providerUrl - The provider's authentication URL.
645
+ * @param providerName - The provider's display name.
646
+ * @returns The provider auth response.
647
+ */
648
+ requestTVProvider(providerUrl: string, providerName: string): Promise<object>;
649
+ /**
650
+ * Sends a restricted access (parental controls) approval request.
651
+ *
652
+ * @param restrictionType - The type of restriction being requested.
653
+ * @returns The approval response.
654
+ */
655
+ requestRestrictedAccess(restrictionType: string): Promise<object>;
573
656
  }
574
657
  //#endregion
575
658
  //#region src/frame.d.ts
@@ -629,7 +712,7 @@ declare const PairingFrameTypes: number[];
629
712
  */
630
713
  declare function convertAttentionState(state: number): AttentionState;
631
714
  declare namespace messages_d_exports {
632
- export { addToUpNext, buildRtiClearPayload, buildRtiInputPayload, deregisterInterests, fetchAttentionState, fetchLaunchableApps, fetchMediaControlStatus, fetchNowPlayingInfo, fetchSiriRemoteInfo, fetchSiriStatus, fetchSupportedActions, fetchUpNext, fetchUserAccounts, hidCommand, launchApp, launchUrl, markAsWatched, mediaControlCommand, ping, playMedia, publishPresence, registerInterests, removeFromUpNext, sessionStart, sessionStop, siriStart, siriStop, switchUserAccount, systemInfo, tiChange, tiStart, tiStop, toggleCaptions, toggleFindingMode, toggleReduceLoudSounds, toggleSystemAppearance, touchEvent, touchStart, touchStop, tvrcSessionStart, tvrcSessionStop };
715
+ export { addToUpNext, appSignInRequest, buildRtiClearPayload, buildRtiInputPayload, deregisterInterests, fetchAttentionState, fetchLaunchableApps, fetchMediaControlStatus, fetchNowPlayingInfo, fetchSiriRemoteInfo, fetchSiriStatus, fetchSupportedActions, fetchUpNext, fetchUserAccounts, gameControllerEvent, gameControllerStart, gameControllerStop, hidCommand, launchApp, launchUrl, markAsWatched, mediaCaptionSettingGet, mediaCaptionSettingSet, mediaControlCommand, mediaSkipBySeconds, ping, playMedia, publishPresence, registerInterests, removeFromUpNext, restrictedAccessRequest, sessionStart, sessionStop, siriStart, siriStop, switchUserAccount, systemInfo, tiChange, tiStart, tiStop, toggleCaptions, toggleFindingMode, toggleReduceLoudSounds, toggleSystemAppearance, touchEvent, touchStart, touchStop, tvProviderRequest, tvrcSessionStart, tvrcSessionStop };
633
716
  }
634
717
  /** An OPack-encoded message to be sent over the Companion Link stream. */
635
718
  type OPackMessage = Record<string, unknown>;
@@ -756,6 +839,26 @@ declare function buildRtiInputPayload(sessionUUID: Buffer, text: string): ArrayB
756
839
  */
757
840
  declare function mediaControlCommand(commandId: number, content?: Record<string, unknown>): OPackMessage;
758
841
  /**
842
+ * Builds a media control command to skip forward or backward by a given number of seconds.
843
+ *
844
+ * @param seconds - Number of seconds to skip (positive = forward, negative = backward).
845
+ * @returns The skip-by-seconds request message.
846
+ */
847
+ declare function mediaSkipBySeconds(seconds: number): OPackMessage;
848
+ /**
849
+ * Builds a message to get the current caption/subtitle settings.
850
+ *
851
+ * @returns The get caption settings request message.
852
+ */
853
+ declare function mediaCaptionSettingGet(): OPackMessage;
854
+ /**
855
+ * Builds a message to enable or disable captions/subtitles.
856
+ *
857
+ * @param enabled - Whether captions should be enabled.
858
+ * @returns The set caption settings request message.
859
+ */
860
+ declare function mediaCaptionSettingSet(enabled: boolean): OPackMessage;
861
+ /**
759
862
  * Builds a message to launch an app by its bundle identifier.
760
863
  *
761
864
  * @param bundleId - The bundle identifier of the app to launch (e.g. `com.apple.TVMovies`).
@@ -923,5 +1026,52 @@ declare function siriStop(): OPackMessage;
923
1026
  * @returns The publish presence request message.
924
1027
  */
925
1028
  declare function publishPresence(): OPackMessage;
1029
+ /**
1030
+ * Builds a game controller event message with analog stick position.
1031
+ * Sent as a fire-and-forget event (no response expected).
1032
+ *
1033
+ * @param x - X coordinate of the analog stick (-1.0 to 1.0).
1034
+ * @param y - Y coordinate of the analog stick (-1.0 to 1.0).
1035
+ * @param isDown - Whether the button is pressed.
1036
+ * @returns The game controller event message.
1037
+ */
1038
+ declare function gameControllerEvent(x: number, y: number, isDown: boolean): OPackMessage;
1039
+ /**
1040
+ * Builds a game controller session start message.
1041
+ *
1042
+ * @returns The game controller start request message.
1043
+ */
1044
+ declare function gameControllerStart(): OPackMessage;
1045
+ /**
1046
+ * Builds a game controller session stop message.
1047
+ *
1048
+ * @returns The game controller stop request message.
1049
+ */
1050
+ declare function gameControllerStop(): OPackMessage;
1051
+ /**
1052
+ * Builds a request to proxy an app sign-in flow through the companion device.
1053
+ * Used when an Apple TV app requests authentication via a paired iPhone/iPad.
1054
+ *
1055
+ * @param bundleId - The bundle identifier of the app requesting sign-in.
1056
+ * @param requestType - The type of sign-in request ('appleID', 'password', or 'custom').
1057
+ * @returns The app sign-in request message.
1058
+ */
1059
+ declare function appSignInRequest(bundleId: string, requestType?: string): OPackMessage;
1060
+ /**
1061
+ * Builds a TV provider authentication request.
1062
+ * Used for MVPD (Multichannel Video Programming Distributor) sign-in on Apple TV.
1063
+ *
1064
+ * @param providerUrl - The provider's authentication URL.
1065
+ * @param providerName - The provider's display name.
1066
+ * @returns The TV provider request message.
1067
+ */
1068
+ declare function tvProviderRequest(providerUrl: string, providerName: string): OPackMessage;
1069
+ /**
1070
+ * Builds a restricted access (parental controls) approval request.
1071
+ *
1072
+ * @param restrictionType - The type of restriction being requested.
1073
+ * @returns The restricted access request message.
1074
+ */
1075
+ declare function restrictedAccessRequest(restrictionType: string): OPackMessage;
926
1076
  //#endregion
927
- export { AttentionState, ButtonPressType, messages_d_exports as CompanionLinkMessage, FrameType, HidCommand, HidCommandKey, LaunchableApp, MediaControlCommand, MediaControlCommandKey, MediaControlFlag, MessageType, OPackFrameTypes, Pairing, PairingFrameTypes, Protocol, Stream, SwipeDirection, TextInputState, TouchPhase, TouchPhaseValue, UserAccount, Verify, convertAttentionState };
1077
+ export { type AttentionState, type ButtonPressType, messages_d_exports as CompanionLinkMessage, FrameType, HidCommand, type HidCommandKey, type LaunchableApp, MediaControlCommand, type MediaControlCommandKey, MediaControlFlag, MessageType, OPackFrameTypes, Pairing, PairingFrameTypes, Protocol, Stream, type SwipeDirection, type TextInputState, TouchPhase, type TouchPhaseValue, type UserAccount, Verify, convertAttentionState };