@sebbo2002/node-pyatv 8.0.0-develop.2 → 8.0.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.
@@ -36,218 +36,6 @@ declare class FakeChildProcessController {
36
36
  end(content?: string | Record<string, unknown>): this;
37
37
  }
38
38
 
39
- declare enum NodePyATVExecutableType {
40
- atvremote = "atvremote",
41
- atvscript = "atvscript"
42
- }
43
- declare enum NodePyATVProtocol {
44
- dmap = "dmap",
45
- mrp = "mrp",
46
- airplay = "airplay",
47
- mdns = "mdns"
48
- }
49
- declare enum NodePyATVMediaType {
50
- music = "music",
51
- tv = "tv",
52
- video = "video",
53
- unknown = "unknown"
54
- }
55
- declare enum NodePyATVDeviceState {
56
- idle = "idle",
57
- loading = "loading",
58
- paused = "paused",
59
- playing = "playing",
60
- seeking = "seeking",
61
- stopped = "stopped"
62
- }
63
- declare enum NodePyATVRepeatState {
64
- all = "all",
65
- track = "track",
66
- off = "off"
67
- }
68
- declare enum NodePyATVShuffleState {
69
- albums = "albums",
70
- songs = "songs",
71
- off = "off"
72
- }
73
- declare enum NodePyATVPowerState {
74
- on = "on",
75
- off = "off"
76
- }
77
- declare enum NodePyATVFocusState {
78
- focued = "focused",
79
- unfocused = "unfocused"
80
- }
81
- declare enum NodePyATVKeys {
82
- down = "down",
83
- home = "home",
84
- homeHold = "homeHold",
85
- left = "left",
86
- menu = "menu",
87
- next = "next",
88
- pause = "pause",
89
- play = "play",
90
- playPause = "playPause",
91
- previous = "previous",
92
- right = "right",
93
- select = "select",
94
- skipBackward = "skipBackward",
95
- skipForward = "skipForward",
96
- stop = "stop",
97
- suspend = "suspend",
98
- topMenu = "topMenu",
99
- up = "up",
100
- volumeDown = "volumeDown",
101
- volumeUp = "volumeUp",
102
- wakeup = "wakeup",
103
- turnOff = "turnOff",
104
- turnOn = "turnOn"
105
- }
106
- declare enum NodePyATVListenerState {
107
- stopped = 0,
108
- starting = 1,
109
- started = 2,
110
- stopping = 3
111
- }
112
- type NodePyATVStateIndex = keyof NodePyATVState;
113
- type NodePyATVEventValueType = (string | number | NodePyATVMediaType | NodePyATVDeviceState | NodePyATVShuffleState | NodePyATVRepeatState);
114
- interface NodePyATVInstanceOptions {
115
- atvremotePath?: string;
116
- atvscriptPath?: string;
117
- debug?: true | ((msg: string) => void);
118
- noColors?: true;
119
- spawn?: (command: string, args: Array<string>, options: SpawnOptions) => (ChildProcess | FakeChildProcess);
120
- }
121
- interface NodePyATVVersionResponse {
122
- pyatv: string | null;
123
- module: string | null;
124
- }
125
- interface NodePyATVFindOptions {
126
- host?: string;
127
- hosts?: string[];
128
- id?: string;
129
- protocol?: NodePyATVProtocol;
130
- dmapCredentials?: string;
131
- mrpCredentials?: string;
132
- airplayCredentials?: string;
133
- companionCredentials?: string;
134
- raopCredentials?: string;
135
- }
136
- interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {
137
- }
138
- interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {
139
- host: string;
140
- name: string;
141
- mac?: string;
142
- model?: string;
143
- modelName?: string;
144
- os?: string;
145
- version?: string;
146
- services?: NodePyATVService[];
147
- allIDs?: string[];
148
- }
149
- interface NodePyATVGetStateOptions {
150
- maxAge?: number;
151
- }
152
- interface NodePyATVService {
153
- protocol: NodePyATVProtocol;
154
- port: number;
155
- }
156
- interface NodePyATVState {
157
- dateTime: Date | null;
158
- hash: string | null;
159
- mediaType: NodePyATVMediaType | null;
160
- deviceState: NodePyATVDeviceState | null;
161
- title: string | null;
162
- artist: string | null;
163
- album: string | null;
164
- genre: string | null;
165
- totalTime: number | null;
166
- position: number | null;
167
- shuffle: NodePyATVShuffleState | null;
168
- repeat: NodePyATVRepeatState | null;
169
- app: string | null;
170
- appId: string | null;
171
- powerState: NodePyATVPowerState | null;
172
- volume: number | null;
173
- focusState: NodePyATVFocusState | null;
174
- }
175
- interface NodePyATVApp {
176
- id: string;
177
- name: string;
178
- launch: () => Promise<void>;
179
- }
180
-
181
- declare class NodePyATVDeviceEvent {
182
- protected readonly values: {
183
- key: NodePyATVStateIndex;
184
- old: NodePyATVEventValueType;
185
- new: NodePyATVEventValueType;
186
- device: NodePyATVDevice;
187
- };
188
- /**
189
- *
190
- * @param values
191
- * @internal
192
- */
193
- constructor(values: {
194
- key: NodePyATVStateIndex;
195
- old: NodePyATVEventValueType;
196
- new: NodePyATVEventValueType;
197
- device: NodePyATVDevice;
198
- });
199
- /**
200
- * References the attribute name which was changed. So if the
201
- * title has been updated, this would be `title`.
202
- */
203
- get key(): NodePyATVStateIndex;
204
- /**
205
- * Holds the old value which was there
206
- * before the value was changed.
207
- */
208
- get oldValue(): NodePyATVEventValueType;
209
- /**
210
- * @alias value
211
- */
212
- get newValue(): NodePyATVEventValueType;
213
- /**
214
- * New, current value for `key`
215
- */
216
- get value(): NodePyATVEventValueType;
217
- /**
218
- * References the device instance this
219
- * event originates from
220
- */
221
- get device(): NodePyATVDevice;
222
- }
223
-
224
- /**
225
- * @internal
226
- */
227
- declare class NodePyATVDeviceEvents extends EventEmitter {
228
- private readonly options;
229
- private readonly state;
230
- private readonly device;
231
- private pyatv;
232
- private timeout;
233
- private listenerState;
234
- constructor(state: NodePyATVState, device: NodePyATVDevice, options: NodePyATVDeviceOptions);
235
- applyStateAndEmitEvents(newState: NodePyATVState): void;
236
- private parsePushUpdate;
237
- private applyPushUpdate;
238
- private checkListener;
239
- private startListening;
240
- protected stopListening(reqId: string): Promise<void>;
241
- addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
242
- on(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
243
- once(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
244
- prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
245
- off(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
246
- removeAllListeners(event?: string | symbol): this;
247
- removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
248
- listenerCount(event?: string | symbol): number;
249
- }
250
-
251
39
  /**
252
40
  * Represents an Apple TV. Use [[getState]] to query the current state (e.g. media
253
41
  * type and title). You can also use the attribute methods (e.g. [[getTitle]] to get
@@ -282,6 +70,7 @@ declare class NodePyATVDevice implements EventEmitter {
282
70
  get id(): string | undefined;
283
71
  /**
284
72
  * Get all IDs of the Apple TV.
73
+ * Requires pyatv >= 0.14.5.
285
74
  */
286
75
  get allIDs(): string[] | undefined;
287
76
  /**
@@ -290,6 +79,7 @@ declare class NodePyATVDevice implements EventEmitter {
290
79
  get protocol(): NodePyATVProtocol | undefined;
291
80
  /**
292
81
  * Get the MAC address of the Apple TV.
82
+ * Requires pyatv >= 0.14.5.
293
83
  */
294
84
  get mac(): string | undefined;
295
85
  /**
@@ -477,7 +267,8 @@ declare class NodePyATVDevice implements EventEmitter {
477
267
  * see https://pyatv.dev/documentation/atvremote/#apps for more details.
478
268
  */
479
269
  listApps(): Promise<NodePyATVApp[]>;
480
- private _pressKey;
270
+ private _pressKeyWithScript;
271
+ private _pressKeyWithRemote;
481
272
  /**
482
273
  * Send a key press to the Apple TV
483
274
  *
@@ -723,6 +514,230 @@ declare class NodePyATVDevice implements EventEmitter {
723
514
  setMaxListeners(n: number): this;
724
515
  }
725
516
 
517
+ declare enum NodePyATVExecutableType {
518
+ atvremote = "atvremote",
519
+ atvscript = "atvscript"
520
+ }
521
+ declare enum NodePyATVProtocol {
522
+ dmap = "dmap",
523
+ mrp = "mrp",
524
+ airplay = "airplay",
525
+ mdns = "mdns"
526
+ }
527
+ declare enum NodePyATVMediaType {
528
+ music = "music",
529
+ tv = "tv",
530
+ video = "video",
531
+ unknown = "unknown"
532
+ }
533
+ declare enum NodePyATVDeviceState {
534
+ idle = "idle",
535
+ loading = "loading",
536
+ paused = "paused",
537
+ playing = "playing",
538
+ seeking = "seeking",
539
+ stopped = "stopped"
540
+ }
541
+ declare enum NodePyATVRepeatState {
542
+ all = "all",
543
+ track = "track",
544
+ off = "off"
545
+ }
546
+ declare enum NodePyATVShuffleState {
547
+ albums = "albums",
548
+ songs = "songs",
549
+ off = "off"
550
+ }
551
+ declare enum NodePyATVPowerState {
552
+ on = "on",
553
+ off = "off"
554
+ }
555
+ declare enum NodePyATVFocusState {
556
+ focued = "focused",
557
+ focused = "focused",
558
+ unfocused = "unfocused"
559
+ }
560
+ declare enum NodePyATVKeys {
561
+ down = "down",
562
+ home = "home",
563
+ homeHold = "homeHold",
564
+ left = "left",
565
+ menu = "menu",
566
+ next = "next",
567
+ pause = "pause",
568
+ play = "play",
569
+ playPause = "playPause",
570
+ previous = "previous",
571
+ right = "right",
572
+ select = "select",
573
+ skipBackward = "skipBackward",
574
+ skipForward = "skipForward",
575
+ stop = "stop",
576
+ suspend = "suspend",
577
+ topMenu = "topMenu",
578
+ up = "up",
579
+ volumeDown = "volumeDown",
580
+ volumeUp = "volumeUp",
581
+ wakeup = "wakeup",
582
+ turnOff = "turnOff",
583
+ turnOn = "turnOn"
584
+ }
585
+ declare enum NodePyATVListenerState {
586
+ stopped = 0,
587
+ starting = 1,
588
+ started = 2,
589
+ stopping = 3
590
+ }
591
+ type NodePyATVStateIndex = keyof NodePyATVState;
592
+ type NodePyATVEventValueType = (string | number | NodePyATVMediaType | NodePyATVDeviceState | NodePyATVShuffleState | NodePyATVRepeatState);
593
+ interface NodePyATVInstanceOptions {
594
+ atvremotePath?: string;
595
+ atvscriptPath?: string;
596
+ debug?: true | ((msg: string) => void);
597
+ noColors?: true;
598
+ spawn?: (command: string, args: Array<string>, options: SpawnOptions) => (ChildProcess | FakeChildProcess);
599
+ }
600
+ interface NodePyATVRequestOptions extends NodePyATVInstanceOptions {
601
+ allowMultipleResponses?: boolean;
602
+ }
603
+ interface NodePyATVVersionResponse {
604
+ pyatv: string | null;
605
+ module: string | null;
606
+ }
607
+ interface NodePyATVFindOptions {
608
+ host?: string;
609
+ hosts?: string[];
610
+ id?: string;
611
+ protocol?: NodePyATVProtocol;
612
+ dmapCredentials?: string;
613
+ mrpCredentials?: string;
614
+ airplayCredentials?: string;
615
+ companionCredentials?: string;
616
+ raopCredentials?: string;
617
+ }
618
+ interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {
619
+ }
620
+ interface NodePyATVFindResponseObject {
621
+ devices: NodePyATVDevice[];
622
+ errors: Record<string, unknown>[];
623
+ }
624
+ interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {
625
+ host: string;
626
+ name: string;
627
+ mac?: string;
628
+ model?: string;
629
+ modelName?: string;
630
+ os?: string;
631
+ version?: string;
632
+ services?: NodePyATVService[];
633
+ allIDs?: string[];
634
+ }
635
+ interface NodePyATVGetStateOptions {
636
+ maxAge?: number;
637
+ }
638
+ interface NodePyATVService {
639
+ protocol: NodePyATVProtocol;
640
+ port: number;
641
+ }
642
+ interface NodePyATVState {
643
+ dateTime: Date | null;
644
+ hash: string | null;
645
+ mediaType: NodePyATVMediaType | null;
646
+ deviceState: NodePyATVDeviceState | null;
647
+ title: string | null;
648
+ artist: string | null;
649
+ album: string | null;
650
+ genre: string | null;
651
+ totalTime: number | null;
652
+ position: number | null;
653
+ shuffle: NodePyATVShuffleState | null;
654
+ repeat: NodePyATVRepeatState | null;
655
+ app: string | null;
656
+ appId: string | null;
657
+ powerState: NodePyATVPowerState | null;
658
+ volume: number | null;
659
+ focusState: NodePyATVFocusState | null;
660
+ outputDevices: Array<{
661
+ name: string;
662
+ identifier: string;
663
+ }> | null;
664
+ }
665
+ interface NodePyATVApp {
666
+ id: string;
667
+ name: string;
668
+ launch: () => Promise<void>;
669
+ }
670
+
671
+ declare class NodePyATVDeviceEvent {
672
+ protected readonly values: {
673
+ key: NodePyATVStateIndex;
674
+ old: NodePyATVEventValueType;
675
+ new: NodePyATVEventValueType;
676
+ device: NodePyATVDevice;
677
+ };
678
+ /**
679
+ *
680
+ * @param values
681
+ * @internal
682
+ */
683
+ constructor(values: {
684
+ key: NodePyATVStateIndex;
685
+ old: NodePyATVEventValueType;
686
+ new: NodePyATVEventValueType;
687
+ device: NodePyATVDevice;
688
+ });
689
+ /**
690
+ * References the attribute name which was changed. So if the
691
+ * title has been updated, this would be `title`.
692
+ */
693
+ get key(): NodePyATVStateIndex;
694
+ /**
695
+ * Holds the old value which was there
696
+ * before the value was changed.
697
+ */
698
+ get oldValue(): NodePyATVEventValueType;
699
+ /**
700
+ * @alias value
701
+ */
702
+ get newValue(): NodePyATVEventValueType;
703
+ /**
704
+ * New, current value for `key`
705
+ */
706
+ get value(): NodePyATVEventValueType;
707
+ /**
708
+ * References the device instance this
709
+ * event originates from
710
+ */
711
+ get device(): NodePyATVDevice;
712
+ }
713
+
714
+ /**
715
+ * @internal
716
+ */
717
+ declare class NodePyATVDeviceEvents extends EventEmitter {
718
+ private readonly options;
719
+ private readonly state;
720
+ private readonly device;
721
+ private pyatv;
722
+ private timeout;
723
+ private listenerState;
724
+ constructor(state: NodePyATVState, device: NodePyATVDevice, options: NodePyATVDeviceOptions);
725
+ applyStateAndEmitEvents(newState: NodePyATVState): void;
726
+ private parsePushUpdate;
727
+ private applyPushUpdate;
728
+ private checkListener;
729
+ private startListening;
730
+ protected stopListening(reqId: string): Promise<void>;
731
+ addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
732
+ on(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
733
+ once(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
734
+ prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
735
+ off(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
736
+ removeAllListeners(event?: string | symbol): this;
737
+ removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
738
+ listenerCount(event?: string | symbol): number;
739
+ }
740
+
726
741
  /**
727
742
  * Default class exported by `@sebbo2002/node-pyatv`. Use [[find]] to scan for devices in your local network. Use
728
743
  * [[device]] to connect to a known device by passing (at least) it's name and IP.
@@ -758,9 +773,19 @@ declare class NodePyATVInstance {
758
773
  * console.log(devices);
759
774
  * ```
760
775
  *
776
+ * Normally `node-pyatv` ignores error messages if at least one device has been found, but if you
777
+ * always want to receive the error messages, you can set the second argument to `true`:
778
+ *
779
+ * ```typescript
780
+ * const result = await pyatv.find({}, true);
781
+ * console.log(result.devices);
782
+ * console.log(result.errors);
783
+ * ```
784
+ *
761
785
  * @param options
762
786
  */
763
787
  static find(options?: NodePyATVFindAndInstanceOptions): Promise<NodePyATVDevice[]>;
788
+ static find(options: NodePyATVFindAndInstanceOptions, returnDevicesAndErrors: true): Promise<NodePyATVFindResponseObject>;
764
789
  /**
765
790
  * Create a [[NodePyATVDevice]] to query the state and control it.
766
791
  * At least `host` and `name` are required.
@@ -819,4 +844,4 @@ declare class NodePyATVInstance {
819
844
  device(options: NodePyATVDeviceOptions): NodePyATVDevice;
820
845
  }
821
846
 
822
- export { NodePyATVDevice, NodePyATVDeviceEvent, NodePyATVDeviceEvents, type NodePyATVDeviceOptions, NodePyATVDeviceState, type NodePyATVEventValueType, NodePyATVExecutableType, type NodePyATVFindAndInstanceOptions, type NodePyATVFindOptions, type NodePyATVGetStateOptions, NodePyATVInstance, type NodePyATVInstanceOptions, NodePyATVKeys, NodePyATVListenerState, NodePyATVMediaType, NodePyATVPowerState, NodePyATVProtocol, NodePyATVRepeatState, type NodePyATVService, NodePyATVShuffleState, type NodePyATVState, type NodePyATVVersionResponse, NodePyATVInstance as default };
847
+ export { NodePyATVDevice, NodePyATVDeviceEvent, NodePyATVDeviceEvents, type NodePyATVDeviceOptions, NodePyATVDeviceState, type NodePyATVEventValueType, NodePyATVExecutableType, type NodePyATVFindAndInstanceOptions, type NodePyATVFindOptions, type NodePyATVFindResponseObject, type NodePyATVGetStateOptions, NodePyATVInstance, type NodePyATVInstanceOptions, NodePyATVKeys, NodePyATVListenerState, NodePyATVMediaType, NodePyATVPowerState, NodePyATVProtocol, NodePyATVRepeatState, type NodePyATVRequestOptions, type NodePyATVService, NodePyATVShuffleState, type NodePyATVState, type NodePyATVVersionResponse, NodePyATVInstance as default };