@basmilius/apple-sdk 0.13.1 → 0.13.3
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 +28 -1
- package/dist/index.mjs +108 -35
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1779,6 +1779,18 @@ declare class CompanionLinkManager extends EventEmitter<EventMap> {
|
|
|
1779
1779
|
* Stops the active Siri session on the device.
|
|
1780
1780
|
*/
|
|
1781
1781
|
siriStop(): Promise<void>;
|
|
1782
|
+
/** @internal */
|
|
1783
|
+
onAttentionStateChanged(state: AttentionState$1): void;
|
|
1784
|
+
/** @internal */
|
|
1785
|
+
onMediaControlFlagsChanged(flags: number, capabilities: MediaCapabilities): void;
|
|
1786
|
+
/** @internal */
|
|
1787
|
+
onNowPlayingInfoChanged(info: Record<string, unknown> | null): void;
|
|
1788
|
+
/** @internal */
|
|
1789
|
+
onSupportedActionsChanged(actions: Record<string, unknown>): void;
|
|
1790
|
+
/** @internal */
|
|
1791
|
+
onTextInputChanged(state: TextInputState$1): void;
|
|
1792
|
+
/** @internal */
|
|
1793
|
+
onVolumeAvailabilityChanged(available: boolean): void;
|
|
1782
1794
|
/**
|
|
1783
1795
|
* Handles the stream close event. Emits 'disconnected' with unexpected=true if not intentional.
|
|
1784
1796
|
*/
|
|
@@ -2204,10 +2216,25 @@ declare class StateController extends EventEmitter<StateEventMap> {
|
|
|
2204
2216
|
*/
|
|
2205
2217
|
subscribe(): void;
|
|
2206
2218
|
/**
|
|
2207
|
-
* Removes
|
|
2219
|
+
* Removes forwarding listeners from the underlying AirPlayState.
|
|
2220
|
+
* Does not remove external listeners registered on this controller.
|
|
2208
2221
|
* @internal
|
|
2209
2222
|
*/
|
|
2210
2223
|
unsubscribe(): void;
|
|
2224
|
+
/** @internal */
|
|
2225
|
+
onNowPlayingChanged(client: AirPlayClient | null, player: AirPlayPlayer | null): void;
|
|
2226
|
+
/** @internal */
|
|
2227
|
+
onPlaybackStateChanged(client: AirPlayClient, player: AirPlayPlayer, oldState: Proto$1.PlaybackState_Enum, newState: Proto$1.PlaybackState_Enum): void;
|
|
2228
|
+
/** @internal */
|
|
2229
|
+
onVolumeDidChange(volume: number): void;
|
|
2230
|
+
/** @internal */
|
|
2231
|
+
onVolumeMutedDidChange(muted: boolean): void;
|
|
2232
|
+
/** @internal */
|
|
2233
|
+
onArtworkChanged(client: AirPlayClient, player: AirPlayPlayer): void;
|
|
2234
|
+
/** @internal */
|
|
2235
|
+
onSupportedCommandsChanged(client: AirPlayClient, player: AirPlayPlayer, commands: Proto$1.CommandInfo[]): void;
|
|
2236
|
+
/** @internal */
|
|
2237
|
+
onClusterChanged(clusterId: string | null, isLeader: boolean): void;
|
|
2211
2238
|
}
|
|
2212
2239
|
//#endregion
|
|
2213
2240
|
//#region src/controller/system.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -515,6 +515,13 @@ var StateController = class extends EventEmitter {
|
|
|
515
515
|
constructor(airplay) {
|
|
516
516
|
super();
|
|
517
517
|
this.#airplay = airplay;
|
|
518
|
+
this.onNowPlayingChanged = this.onNowPlayingChanged.bind(this);
|
|
519
|
+
this.onPlaybackStateChanged = this.onPlaybackStateChanged.bind(this);
|
|
520
|
+
this.onVolumeDidChange = this.onVolumeDidChange.bind(this);
|
|
521
|
+
this.onVolumeMutedDidChange = this.onVolumeMutedDidChange.bind(this);
|
|
522
|
+
this.onArtworkChanged = this.onArtworkChanged.bind(this);
|
|
523
|
+
this.onSupportedCommandsChanged = this.onSupportedCommandsChanged.bind(this);
|
|
524
|
+
this.onClusterChanged = this.onClusterChanged.bind(this);
|
|
518
525
|
}
|
|
519
526
|
get #state() {
|
|
520
527
|
return this.#airplay.state;
|
|
@@ -606,39 +613,61 @@ var StateController = class extends EventEmitter {
|
|
|
606
613
|
*/
|
|
607
614
|
subscribe() {
|
|
608
615
|
const state = this.#state;
|
|
609
|
-
state.on("nowPlayingChanged",
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
});
|
|
617
|
-
state.on("playbackStateChanged", (client, player, oldState, newState) => {
|
|
618
|
-
this.emit("playbackStateChanged", client, player, oldState, newState);
|
|
619
|
-
});
|
|
620
|
-
state.on("volumeDidChange", (volume) => {
|
|
621
|
-
this.emit("volumeChanged", volume);
|
|
622
|
-
});
|
|
623
|
-
state.on("volumeMutedDidChange", (muted) => {
|
|
624
|
-
this.emit("volumeMutedChanged", muted);
|
|
625
|
-
});
|
|
626
|
-
state.on("artworkChanged", (client, player) => {
|
|
627
|
-
this.emit("artworkChanged", client, player);
|
|
628
|
-
});
|
|
629
|
-
state.on("supportedCommandsChanged", (client, player, commands) => {
|
|
630
|
-
this.emit("supportedCommandsChanged", client, player, commands);
|
|
631
|
-
});
|
|
632
|
-
state.on("clusterChanged", (clusterId, isLeader) => {
|
|
633
|
-
this.emit("clusterChanged", clusterId, isLeader);
|
|
634
|
-
});
|
|
616
|
+
state.on("nowPlayingChanged", this.onNowPlayingChanged);
|
|
617
|
+
state.on("playbackStateChanged", this.onPlaybackStateChanged);
|
|
618
|
+
state.on("volumeDidChange", this.onVolumeDidChange);
|
|
619
|
+
state.on("volumeMutedDidChange", this.onVolumeMutedDidChange);
|
|
620
|
+
state.on("artworkChanged", this.onArtworkChanged);
|
|
621
|
+
state.on("supportedCommandsChanged", this.onSupportedCommandsChanged);
|
|
622
|
+
state.on("clusterChanged", this.onClusterChanged);
|
|
635
623
|
}
|
|
636
624
|
/**
|
|
637
|
-
* Removes
|
|
625
|
+
* Removes forwarding listeners from the underlying AirPlayState.
|
|
626
|
+
* Does not remove external listeners registered on this controller.
|
|
638
627
|
* @internal
|
|
639
628
|
*/
|
|
640
629
|
unsubscribe() {
|
|
641
|
-
this
|
|
630
|
+
const state = this.#state;
|
|
631
|
+
state.off("nowPlayingChanged", this.onNowPlayingChanged);
|
|
632
|
+
state.off("playbackStateChanged", this.onPlaybackStateChanged);
|
|
633
|
+
state.off("volumeDidChange", this.onVolumeDidChange);
|
|
634
|
+
state.off("volumeMutedDidChange", this.onVolumeMutedDidChange);
|
|
635
|
+
state.off("artworkChanged", this.onArtworkChanged);
|
|
636
|
+
state.off("supportedCommandsChanged", this.onSupportedCommandsChanged);
|
|
637
|
+
state.off("clusterChanged", this.onClusterChanged);
|
|
638
|
+
}
|
|
639
|
+
/** @internal */
|
|
640
|
+
onNowPlayingChanged(client, player) {
|
|
641
|
+
this.emit("nowPlayingChanged", client, player);
|
|
642
|
+
const app = client ? {
|
|
643
|
+
bundleIdentifier: client.bundleIdentifier,
|
|
644
|
+
displayName: client.displayName
|
|
645
|
+
} : null;
|
|
646
|
+
this.emit("activeAppChanged", app?.bundleIdentifier ?? null, app?.displayName ?? null);
|
|
647
|
+
}
|
|
648
|
+
/** @internal */
|
|
649
|
+
onPlaybackStateChanged(client, player, oldState, newState) {
|
|
650
|
+
this.emit("playbackStateChanged", client, player, oldState, newState);
|
|
651
|
+
}
|
|
652
|
+
/** @internal */
|
|
653
|
+
onVolumeDidChange(volume) {
|
|
654
|
+
this.emit("volumeChanged", volume);
|
|
655
|
+
}
|
|
656
|
+
/** @internal */
|
|
657
|
+
onVolumeMutedDidChange(muted) {
|
|
658
|
+
this.emit("volumeMutedChanged", muted);
|
|
659
|
+
}
|
|
660
|
+
/** @internal */
|
|
661
|
+
onArtworkChanged(client, player) {
|
|
662
|
+
this.emit("artworkChanged", client, player);
|
|
663
|
+
}
|
|
664
|
+
/** @internal */
|
|
665
|
+
onSupportedCommandsChanged(client, player, commands) {
|
|
666
|
+
this.emit("supportedCommandsChanged", client, player, commands);
|
|
667
|
+
}
|
|
668
|
+
/** @internal */
|
|
669
|
+
onClusterChanged(clusterId, isLeader) {
|
|
670
|
+
this.emit("clusterChanged", clusterId, isLeader);
|
|
642
671
|
}
|
|
643
672
|
};
|
|
644
673
|
|
|
@@ -3101,9 +3130,16 @@ var AirPlayManager = class extends EventEmitter {
|
|
|
3101
3130
|
clearInterval(this.#feedbackInterval);
|
|
3102
3131
|
this.#feedbackInterval = void 0;
|
|
3103
3132
|
}
|
|
3133
|
+
this.#prevDataStream?.off("error", this.onError);
|
|
3134
|
+
this.#prevDataStream?.off("timeout", this.onTimeout);
|
|
3135
|
+
this.#prevEventStream?.off("error", this.onError);
|
|
3136
|
+
this.#prevEventStream?.off("timeout", this.onTimeout);
|
|
3137
|
+
this.#prevDataStream = void 0;
|
|
3138
|
+
this.#prevEventStream = void 0;
|
|
3104
3139
|
this.#cleanupPlayUrl();
|
|
3105
3140
|
this.#cleanupStream();
|
|
3106
3141
|
this.#unsubscribe();
|
|
3142
|
+
this.#artwork.clear();
|
|
3107
3143
|
this.#protocol.disconnect();
|
|
3108
3144
|
this.emit("disconnected", false);
|
|
3109
3145
|
}
|
|
@@ -3790,6 +3826,12 @@ var CompanionLinkManager = class extends EventEmitter {
|
|
|
3790
3826
|
this.onClose = this.onClose.bind(this);
|
|
3791
3827
|
this.onError = this.onError.bind(this);
|
|
3792
3828
|
this.onTimeout = this.onTimeout.bind(this);
|
|
3829
|
+
this.onAttentionStateChanged = this.onAttentionStateChanged.bind(this);
|
|
3830
|
+
this.onMediaControlFlagsChanged = this.onMediaControlFlagsChanged.bind(this);
|
|
3831
|
+
this.onNowPlayingInfoChanged = this.onNowPlayingInfoChanged.bind(this);
|
|
3832
|
+
this.onSupportedActionsChanged = this.onSupportedActionsChanged.bind(this);
|
|
3833
|
+
this.onTextInputChanged = this.onTextInputChanged.bind(this);
|
|
3834
|
+
this.onVolumeAvailabilityChanged = this.onVolumeAvailabilityChanged.bind(this);
|
|
3793
3835
|
}
|
|
3794
3836
|
/**
|
|
3795
3837
|
* Connects to the Companion Link device, performs pair-verify, and sets up
|
|
@@ -4122,14 +4164,21 @@ var CompanionLinkManager = class extends EventEmitter {
|
|
|
4122
4164
|
this.#protocol.context.logger.error("Heartbeat failed", err);
|
|
4123
4165
|
}
|
|
4124
4166
|
}, 15e3);
|
|
4125
|
-
if (this.#state)
|
|
4167
|
+
if (this.#state) {
|
|
4168
|
+
this.#state.off("attentionStateChanged", this.onAttentionStateChanged);
|
|
4169
|
+
this.#state.off("mediaControlFlagsChanged", this.onMediaControlFlagsChanged);
|
|
4170
|
+
this.#state.off("nowPlayingInfoChanged", this.onNowPlayingInfoChanged);
|
|
4171
|
+
this.#state.off("supportedActionsChanged", this.onSupportedActionsChanged);
|
|
4172
|
+
this.#state.off("textInputChanged", this.onTextInputChanged);
|
|
4173
|
+
this.#state.off("volumeAvailabilityChanged", this.onVolumeAvailabilityChanged);
|
|
4174
|
+
}
|
|
4126
4175
|
this.#state = new CompanionLinkState(this.#protocol);
|
|
4127
|
-
this.#state.on("attentionStateChanged",
|
|
4128
|
-
this.#state.on("mediaControlFlagsChanged",
|
|
4129
|
-
this.#state.on("nowPlayingInfoChanged",
|
|
4130
|
-
this.#state.on("supportedActionsChanged",
|
|
4131
|
-
this.#state.on("textInputChanged",
|
|
4132
|
-
this.#state.on("volumeAvailabilityChanged",
|
|
4176
|
+
this.#state.on("attentionStateChanged", this.onAttentionStateChanged);
|
|
4177
|
+
this.#state.on("mediaControlFlagsChanged", this.onMediaControlFlagsChanged);
|
|
4178
|
+
this.#state.on("nowPlayingInfoChanged", this.onNowPlayingInfoChanged);
|
|
4179
|
+
this.#state.on("supportedActionsChanged", this.onSupportedActionsChanged);
|
|
4180
|
+
this.#state.on("textInputChanged", this.onTextInputChanged);
|
|
4181
|
+
this.#state.on("volumeAvailabilityChanged", this.onVolumeAvailabilityChanged);
|
|
4133
4182
|
this.#state.subscribe();
|
|
4134
4183
|
await this.#state.fetchInitialState();
|
|
4135
4184
|
} catch (err) {
|
|
@@ -4138,6 +4187,30 @@ var CompanionLinkManager = class extends EventEmitter {
|
|
|
4138
4187
|
throw err;
|
|
4139
4188
|
}
|
|
4140
4189
|
}
|
|
4190
|
+
/** @internal */
|
|
4191
|
+
onAttentionStateChanged(state) {
|
|
4192
|
+
this.emit("attentionStateChanged", state);
|
|
4193
|
+
}
|
|
4194
|
+
/** @internal */
|
|
4195
|
+
onMediaControlFlagsChanged(flags, capabilities) {
|
|
4196
|
+
this.emit("mediaControlFlagsChanged", flags, capabilities);
|
|
4197
|
+
}
|
|
4198
|
+
/** @internal */
|
|
4199
|
+
onNowPlayingInfoChanged(info) {
|
|
4200
|
+
this.emit("nowPlayingInfoChanged", info);
|
|
4201
|
+
}
|
|
4202
|
+
/** @internal */
|
|
4203
|
+
onSupportedActionsChanged(actions) {
|
|
4204
|
+
this.emit("supportedActionsChanged", actions);
|
|
4205
|
+
}
|
|
4206
|
+
/** @internal */
|
|
4207
|
+
onTextInputChanged(state) {
|
|
4208
|
+
this.emit("textInputChanged", state);
|
|
4209
|
+
}
|
|
4210
|
+
/** @internal */
|
|
4211
|
+
onVolumeAvailabilityChanged(available) {
|
|
4212
|
+
this.emit("volumeAvailabilityChanged", available);
|
|
4213
|
+
}
|
|
4141
4214
|
/**
|
|
4142
4215
|
* Handles the stream close event. Emits 'disconnected' with unexpected=true if not intentional.
|
|
4143
4216
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/apple-sdk",
|
|
3
3
|
"description": "High-level SDK for controlling Apple devices (Apple TV, HomePod) via AirPlay and Companion Link.",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@basmilius/apple-airplay": "0.13.
|
|
49
|
-
"@basmilius/apple-common": "0.13.
|
|
50
|
-
"@basmilius/apple-companion-link": "0.13.
|
|
51
|
-
"@basmilius/apple-encoding": "0.13.
|
|
52
|
-
"@basmilius/apple-raop": "0.13.
|
|
48
|
+
"@basmilius/apple-airplay": "0.13.3",
|
|
49
|
+
"@basmilius/apple-common": "0.13.3",
|
|
50
|
+
"@basmilius/apple-companion-link": "0.13.3",
|
|
51
|
+
"@basmilius/apple-encoding": "0.13.3",
|
|
52
|
+
"@basmilius/apple-raop": "0.13.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/bun": "^1.3.11",
|