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

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,230 @@ 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 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
+
733
741
  /**
734
742
  * Default class exported by `@sebbo2002/node-pyatv`. Use [[find]] to scan for devices in your local network. Use
735
743
  * [[device]] to connect to a known device by passing (at least) it's name and IP.
@@ -765,9 +773,19 @@ declare class NodePyATVInstance {
765
773
  * console.log(devices);
766
774
  * ```
767
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
+ *
768
785
  * @param options
769
786
  */
770
787
  static find(options?: NodePyATVFindAndInstanceOptions): Promise<NodePyATVDevice[]>;
788
+ static find(options: NodePyATVFindAndInstanceOptions, returnDevicesAndErrors: true): Promise<NodePyATVFindResponseObject>;
771
789
  /**
772
790
  * Create a [[NodePyATVDevice]] to query the state and control it.
773
791
  * At least `host` and `name` are required.
@@ -826,4 +844,4 @@ declare class NodePyATVInstance {
826
844
  device(options: NodePyATVDeviceOptions): NodePyATVDevice;
827
845
  }
828
846
 
829
- 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 };