@sebbo2002/node-pyatv 7.3.1-develop.9 → 7.4.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,223 +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
- focused = "focused",
80
- unfocused = "unfocused"
81
- }
82
- declare enum NodePyATVKeys {
83
- down = "down",
84
- home = "home",
85
- homeHold = "homeHold",
86
- left = "left",
87
- menu = "menu",
88
- next = "next",
89
- pause = "pause",
90
- play = "play",
91
- playPause = "playPause",
92
- previous = "previous",
93
- right = "right",
94
- select = "select",
95
- skipBackward = "skipBackward",
96
- skipForward = "skipForward",
97
- stop = "stop",
98
- suspend = "suspend",
99
- topMenu = "topMenu",
100
- up = "up",
101
- volumeDown = "volumeDown",
102
- volumeUp = "volumeUp",
103
- wakeup = "wakeup",
104
- turnOff = "turnOff",
105
- turnOn = "turnOn"
106
- }
107
- declare enum NodePyATVListenerState {
108
- stopped = 0,
109
- starting = 1,
110
- started = 2,
111
- stopping = 3
112
- }
113
- type NodePyATVStateIndex = keyof NodePyATVState;
114
- type NodePyATVEventValueType = (string | number | NodePyATVMediaType | NodePyATVDeviceState | NodePyATVShuffleState | NodePyATVRepeatState);
115
- interface NodePyATVInstanceOptions {
116
- atvremotePath?: string;
117
- atvscriptPath?: string;
118
- debug?: true | ((msg: string) => void);
119
- noColors?: true;
120
- spawn?: (command: string, args: Array<string>, options: SpawnOptions) => (ChildProcess | FakeChildProcess);
121
- }
122
- interface NodePyATVVersionResponse {
123
- pyatv: string | null;
124
- module: string | null;
125
- }
126
- interface NodePyATVFindOptions {
127
- host?: string;
128
- hosts?: string[];
129
- id?: string;
130
- protocol?: NodePyATVProtocol;
131
- dmapCredentials?: string;
132
- mrpCredentials?: string;
133
- airplayCredentials?: string;
134
- companionCredentials?: string;
135
- raopCredentials?: string;
136
- }
137
- interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {
138
- }
139
- interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {
140
- host: string;
141
- name: string;
142
- mac?: string;
143
- model?: string;
144
- modelName?: string;
145
- os?: string;
146
- version?: string;
147
- services?: NodePyATVService[];
148
- allIDs?: string[];
149
- }
150
- interface NodePyATVGetStateOptions {
151
- maxAge?: number;
152
- }
153
- interface NodePyATVService {
154
- protocol: NodePyATVProtocol;
155
- port: number;
156
- }
157
- interface NodePyATVState {
158
- dateTime: Date | null;
159
- hash: string | null;
160
- mediaType: NodePyATVMediaType | null;
161
- deviceState: NodePyATVDeviceState | null;
162
- title: string | null;
163
- artist: string | null;
164
- album: string | null;
165
- genre: string | null;
166
- totalTime: number | null;
167
- position: number | null;
168
- shuffle: NodePyATVShuffleState | null;
169
- repeat: NodePyATVRepeatState | null;
170
- app: string | null;
171
- appId: string | null;
172
- powerState: NodePyATVPowerState | null;
173
- volume: number | null;
174
- focusState: NodePyATVFocusState | null;
175
- outputDevices: Array<{
176
- name: string;
177
- identifier: string;
178
- }> | null;
179
- }
180
- interface NodePyATVApp {
181
- id: string;
182
- name: string;
183
- launch: () => Promise<void>;
184
- }
185
-
186
- declare class NodePyATVDeviceEvent {
187
- protected readonly values: {
188
- key: NodePyATVStateIndex;
189
- old: NodePyATVEventValueType;
190
- new: NodePyATVEventValueType;
191
- device: NodePyATVDevice;
192
- };
193
- /**
194
- *
195
- * @param values
196
- * @internal
197
- */
198
- constructor(values: {
199
- key: NodePyATVStateIndex;
200
- old: NodePyATVEventValueType;
201
- new: NodePyATVEventValueType;
202
- device: NodePyATVDevice;
203
- });
204
- /**
205
- * References the attribute name which was changed. So if the
206
- * title has been updated, this would be `title`.
207
- */
208
- get key(): NodePyATVStateIndex;
209
- /**
210
- * Holds the old value which was there
211
- * before the value was changed.
212
- */
213
- get oldValue(): NodePyATVEventValueType;
214
- /**
215
- * @alias value
216
- */
217
- get newValue(): NodePyATVEventValueType;
218
- /**
219
- * New, current value for `key`
220
- */
221
- get value(): NodePyATVEventValueType;
222
- /**
223
- * References the device instance this
224
- * event originates from
225
- */
226
- get device(): NodePyATVDevice;
227
- }
228
-
229
- /**
230
- * @internal
231
- */
232
- declare class NodePyATVDeviceEvents extends EventEmitter {
233
- private readonly options;
234
- private readonly state;
235
- private readonly device;
236
- private pyatv;
237
- private timeout;
238
- private listenerState;
239
- constructor(state: NodePyATVState, device: NodePyATVDevice, options: NodePyATVDeviceOptions);
240
- applyStateAndEmitEvents(newState: NodePyATVState): void;
241
- private parsePushUpdate;
242
- private applyPushUpdate;
243
- private checkListener;
244
- private startListening;
245
- protected stopListening(reqId: string): Promise<void>;
246
- addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
247
- on(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
248
- once(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
249
- prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
250
- off(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
251
- removeAllListeners(event?: string | symbol): this;
252
- removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
253
- listenerCount(event?: string | symbol): number;
254
- }
255
-
256
39
  /**
257
40
  * Represents an Apple TV. Use [[getState]] to query the current state (e.g. media
258
41
  * type and title). You can also use the attribute methods (e.g. [[getTitle]] to get
@@ -484,7 +267,8 @@ declare class NodePyATVDevice implements EventEmitter {
484
267
  * see https://pyatv.dev/documentation/atvremote/#apps for more details.
485
268
  */
486
269
  listApps(): Promise<NodePyATVApp[]>;
487
- private _pressKey;
270
+ private _pressKeyWithScript;
271
+ private _pressKeyWithRemote;
488
272
  /**
489
273
  * Send a key press to the Apple TV
490
274
  *
@@ -730,6 +514,227 @@ declare class NodePyATVDevice implements EventEmitter {
730
514
  setMaxListeners(n: number): this;
731
515
  }
732
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 NodePyATVVersionResponse {
601
+ pyatv: string | null;
602
+ module: string | null;
603
+ }
604
+ interface NodePyATVFindOptions {
605
+ host?: string;
606
+ hosts?: string[];
607
+ id?: string;
608
+ protocol?: NodePyATVProtocol;
609
+ dmapCredentials?: string;
610
+ mrpCredentials?: string;
611
+ airplayCredentials?: string;
612
+ companionCredentials?: string;
613
+ raopCredentials?: string;
614
+ }
615
+ interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {
616
+ }
617
+ interface NodePyATVFindResponseObject {
618
+ devices: NodePyATVDevice[];
619
+ errors: Record<string, unknown>[];
620
+ }
621
+ interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {
622
+ host: string;
623
+ name: string;
624
+ mac?: string;
625
+ model?: string;
626
+ modelName?: string;
627
+ os?: string;
628
+ version?: string;
629
+ services?: NodePyATVService[];
630
+ allIDs?: string[];
631
+ }
632
+ interface NodePyATVGetStateOptions {
633
+ maxAge?: number;
634
+ }
635
+ interface NodePyATVService {
636
+ protocol: NodePyATVProtocol;
637
+ port: number;
638
+ }
639
+ interface NodePyATVState {
640
+ dateTime: Date | null;
641
+ hash: string | null;
642
+ mediaType: NodePyATVMediaType | null;
643
+ deviceState: NodePyATVDeviceState | null;
644
+ title: string | null;
645
+ artist: string | null;
646
+ album: string | null;
647
+ genre: string | null;
648
+ totalTime: number | null;
649
+ position: number | null;
650
+ shuffle: NodePyATVShuffleState | null;
651
+ repeat: NodePyATVRepeatState | null;
652
+ app: string | null;
653
+ appId: string | null;
654
+ powerState: NodePyATVPowerState | null;
655
+ volume: number | null;
656
+ focusState: NodePyATVFocusState | null;
657
+ outputDevices: Array<{
658
+ name: string;
659
+ identifier: string;
660
+ }> | null;
661
+ }
662
+ interface NodePyATVApp {
663
+ id: string;
664
+ name: string;
665
+ launch: () => Promise<void>;
666
+ }
667
+
668
+ declare class NodePyATVDeviceEvent {
669
+ protected readonly values: {
670
+ key: NodePyATVStateIndex;
671
+ old: NodePyATVEventValueType;
672
+ new: NodePyATVEventValueType;
673
+ device: NodePyATVDevice;
674
+ };
675
+ /**
676
+ *
677
+ * @param values
678
+ * @internal
679
+ */
680
+ constructor(values: {
681
+ key: NodePyATVStateIndex;
682
+ old: NodePyATVEventValueType;
683
+ new: NodePyATVEventValueType;
684
+ device: NodePyATVDevice;
685
+ });
686
+ /**
687
+ * References the attribute name which was changed. So if the
688
+ * title has been updated, this would be `title`.
689
+ */
690
+ get key(): NodePyATVStateIndex;
691
+ /**
692
+ * Holds the old value which was there
693
+ * before the value was changed.
694
+ */
695
+ get oldValue(): NodePyATVEventValueType;
696
+ /**
697
+ * @alias value
698
+ */
699
+ get newValue(): NodePyATVEventValueType;
700
+ /**
701
+ * New, current value for `key`
702
+ */
703
+ get value(): NodePyATVEventValueType;
704
+ /**
705
+ * References the device instance this
706
+ * event originates from
707
+ */
708
+ get device(): NodePyATVDevice;
709
+ }
710
+
711
+ /**
712
+ * @internal
713
+ */
714
+ declare class NodePyATVDeviceEvents extends EventEmitter {
715
+ private readonly options;
716
+ private readonly state;
717
+ private readonly device;
718
+ private pyatv;
719
+ private timeout;
720
+ private listenerState;
721
+ constructor(state: NodePyATVState, device: NodePyATVDevice, options: NodePyATVDeviceOptions);
722
+ applyStateAndEmitEvents(newState: NodePyATVState): void;
723
+ private parsePushUpdate;
724
+ private applyPushUpdate;
725
+ private checkListener;
726
+ private startListening;
727
+ protected stopListening(reqId: string): Promise<void>;
728
+ addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
729
+ on(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
730
+ once(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
731
+ prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
732
+ off(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
733
+ removeAllListeners(event?: string | symbol): this;
734
+ removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
735
+ listenerCount(event?: string | symbol): number;
736
+ }
737
+
733
738
  /**
734
739
  * Default class exported by `@sebbo2002/node-pyatv`. Use [[find]] to scan for devices in your local network. Use
735
740
  * [[device]] to connect to a known device by passing (at least) it's name and IP.
@@ -765,9 +770,19 @@ declare class NodePyATVInstance {
765
770
  * console.log(devices);
766
771
  * ```
767
772
  *
773
+ * Normally `node-pyatv` ignores error messages if at least one device has been found, but if you
774
+ * always want to receive the error messages, you can set the second argument to `true`:
775
+ *
776
+ * ```typescript
777
+ * const result = await pyatv.find({}, true);
778
+ * console.log(result.devices);
779
+ * console.log(result.errors);
780
+ * ```
781
+ *
768
782
  * @param options
769
783
  */
770
784
  static find(options?: NodePyATVFindAndInstanceOptions): Promise<NodePyATVDevice[]>;
785
+ static find(options: NodePyATVFindAndInstanceOptions, returnDevicesAndErrors: true): Promise<NodePyATVFindResponseObject>;
771
786
  /**
772
787
  * Create a [[NodePyATVDevice]] to query the state and control it.
773
788
  * At least `host` and `name` are required.