@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.
- package/dist/bin/check.cjs +5 -4
- package/dist/bin/check.cjs.map +1 -1
- package/dist/bin/check.js +1 -1
- package/dist/chunk-PSUTZJKE.js +8 -0
- package/dist/chunk-PSUTZJKE.js.map +1 -0
- package/dist/lib/index.cjs +5 -4
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +237 -219
- package/dist/lib/index.d.ts +237 -219
- package/dist/lib/index.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-52OYIOVF.js +0 -7
- package/dist/chunk-52OYIOVF.js.map +0 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -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
|
|
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 };
|
package/dist/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m}from"../chunk-
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m}from"../chunk-PSUTZJKE.js";export{l as NodePyATVDevice,j as NodePyATVDeviceEvent,k as NodePyATVDeviceEvents,d as NodePyATVDeviceState,a as NodePyATVExecutableType,m as NodePyATVInstance,h as NodePyATVKeys,i as NodePyATVListenerState,c as NodePyATVMediaType,g as NodePyATVPowerState,b as NodePyATVProtocol,e as NodePyATVRepeatState,f as NodePyATVShuffleState,m as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "http://github.com/sebbo2002/node-pyatv/issues"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"semver": "^7.6.
|
|
8
|
+
"semver": "^7.6.2"
|
|
9
9
|
},
|
|
10
10
|
"description": "A lightweight wrapper around pyatv…",
|
|
11
11
|
"devDependencies": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"@semantic-release/changelog": "^6.0.3",
|
|
14
14
|
"@semantic-release/exec": "^6.0.3",
|
|
15
15
|
"@semantic-release/git": "^10.0.1",
|
|
16
|
-
"@semantic-release/npm": "^12.0.
|
|
16
|
+
"@semantic-release/npm": "^12.0.1",
|
|
17
17
|
"@types/mocha": "^10.0.6",
|
|
18
|
-
"@types/node": "^20.12.
|
|
18
|
+
"@types/node": "^20.12.11",
|
|
19
19
|
"@types/semver": "^7.5.8",
|
|
20
20
|
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
21
21
|
"@typescript-eslint/parser": "^7.3.1",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"eslint-plugin-jsonc": "^2.14.0",
|
|
25
25
|
"esm": "^3.2.25",
|
|
26
26
|
"license-checker": "^25.0.1",
|
|
27
|
-
"mocha": "^10.
|
|
27
|
+
"mocha": "^10.4.0",
|
|
28
28
|
"mochawesome": "^7.1.3",
|
|
29
|
-
"semantic-release": "^23.
|
|
29
|
+
"semantic-release": "^23.1.1",
|
|
30
30
|
"semantic-release-license": "^1.0.3",
|
|
31
31
|
"source-map-support": "^0.5.21",
|
|
32
32
|
"ts-node": "^10.9.2",
|
|
33
33
|
"tsup": "^8.0.2",
|
|
34
|
-
"typedoc": "^0.25.
|
|
35
|
-
"typescript": "^5.4.
|
|
34
|
+
"typedoc": "^0.25.13",
|
|
35
|
+
"typescript": "^5.4.5"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=18.0.0"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"test": "mocha"
|
|
69
69
|
},
|
|
70
70
|
"type": "module",
|
|
71
|
-
"version": "7.
|
|
71
|
+
"version": "7.4.0-develop.2"
|
|
72
72
|
}
|
package/dist/chunk-52OYIOVF.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
var a=(s,t,e)=>new Promise((i,n)=>{var o=c=>{try{p(e.next(c))}catch(l){n(l)}},r=c=>{try{p(e.throw(c))}catch(l){n(l)}},p=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,r);p((e=e.apply(s,t)).next())});var A=(e=>(e.atvremote="atvremote",e.atvscript="atvscript",e))(A||{}),R=(n=>(n.dmap="dmap",n.mrp="mrp",n.airplay="airplay",n.mdns="mdns",n))(R||{}),k=(n=>(n.music="music",n.tv="tv",n.video="video",n.unknown="unknown",n))(k||{}),x=(r=>(r.idle="idle",r.loading="loading",r.paused="paused",r.playing="playing",r.seeking="seeking",r.stopped="stopped",r))(x||{}),E=(i=>(i.all="all",i.track="track",i.off="off",i))(E||{}),_=(i=>(i.albums="albums",i.songs="songs",i.off="off",i))(_||{}),D=(e=>(e.on="on",e.off="off",e))(D||{}),L=(i=>(i.focued="focused",i.focused="focused",i.unfocused="unfocused",i))(L||{}),U=(d=>(d.down="down",d.home="home",d.homeHold="homeHold",d.left="left",d.menu="menu",d.next="next",d.pause="pause",d.play="play",d.playPause="playPause",d.previous="previous",d.right="right",d.select="select",d.skipBackward="skipBackward",d.skipForward="skipForward",d.stop="stop",d.suspend="suspend",d.topMenu="topMenu",d.up="up",d.volumeDown="volumeDown",d.volumeUp="volumeUp",d.wakeup="wakeup",d.turnOff="turnOff",d.turnOn="turnOn",d))(U||{}),j=(d=>(d.down="down",d.home="home",d.homeHold="home_hold",d.left="left",d.menu="menu",d.next="next",d.pause="pause",d.play="play",d.playPause="play_pause",d.previous="previous",d.right="right",d.select="select",d.skipBackward="skip_backward",d.skipForward="skip_forward",d.stop="stop",d.suspend="suspend",d.topMenu="top_menu",d.up="up",d.volumeDown="volume_down",d.volumeUp="volume_up",d.wakeup="wakeup",d.turnOff="turn_off",d.turnOn="turn_on",d))(j||{}),F=(n=>(n[n.stopped=0]="stopped",n[n.starting=1]="starting",n[n.started=2]="started",n[n.stopping=3]="stopping",n))(F||{});var N=class{constructor(t){this.values=Object.assign({},t,{key:t.key})}get key(){return this.values.key}get oldValue(){return this.values.old}get newValue(){return this.values.new}get value(){return this.values.new}get device(){return this.values.device}};import{EventEmitter as H}from"events";import{spawn as M}from"child_process";var $=[];function f(){let s="?";for(let t=0;t<1e3;t+=1)if(s=Math.round(Math.random()*(t+6)*36).toString(36).toUpperCase(),!$.includes(s)){$.push(s);break}return s}function h(s){s&&$.includes(s)&&$.splice($.indexOf(s),1)}function u(s,t,e){if(e.debug){let i=typeof e.debug=="function"?e.debug:console.log,n=!process.env.NO_COLOR&&!e.noColors,o=[n?"\x1B[0m":"",n?"\x1B[90m":"","[node-pyatv][",n?"\x1B[37m":"",s,n?"\x1B[90m":"","] ",n?"\x1B[0m":"",t];i.apply(null,[o.join("")])}}function B(s,t){return s==="atvremote"&&typeof t.atvremotePath=="string"?t.atvremotePath:s==="atvscript"&&typeof t.atvscriptPath=="string"?t.atvscriptPath:s}function I(s,t,e,i){let n=B(t,i),o=typeof i.spawn=="function"?i.spawn:M;u(s,`${n} ${e.join(" ")}`,i);let r=o(n,e,{env:process.env}),p=v=>u(s,`stdout: ${String(v).trim()}`,i),c=v=>u(s,`stderr: ${String(v).trim()}`,i),l=v=>u(s,`error: ${String(v).trim()}`,i),m=v=>{u(s,`${n} exited with code: ${v}`,i),r.stdout&&r.stdout.off("data",p),r.stderr&&r.stderr.off("data",c),r.off("error",l),r.off("close",m)};return r.stdout&&r.stdout.on("data",p),r.stderr&&r.stderr.on("data",c),r.on("error",l),r.on("close",m),r}function T(s,t,e,i){return a(this,null,function*(){let n={stdout:"",stderr:"",code:0};if(yield new Promise((o,r)=>{let p=I(s,t,e,i),c=y=>n.stdout+=String(y).trim(),l=y=>n.stderr+=String(y).trim(),m=y=>r(y instanceof Error?y:new Error(String(y))),v=y=>{n.code=y,p.stdout&&p.stdout.off("data",c),p.stderr&&p.stderr.off("data",l),p.off("error",m),p.off("close",v),o(void 0)};p.stdout&&p.stdout.on("data",c),p.stderr&&p.stderr.on("data",l),p.on("error",m),p.on("close",v)}),n.stderr.length>0){let o=`Unable to execute request ${s}: ${n.stderr}`;throw u(s,o,i),new Error(o)}if(t==="atvscript")try{return JSON.parse(n.stdout)}catch(o){let r=`Unable to parse result ${s} json: ${o}`;throw u(s,r,i),new Error(r)}return n.stdout})}function g(s={}){let t=[];return s.hosts?t.push("-s",s.hosts.join(",")):s.host&&t.push("-s",s.host),s.id&&t.push("-i",s.id),s.protocol&&t.push("--protocol",s.protocol),s.dmapCredentials&&t.push("--dmap-credentials",s.dmapCredentials),s.mrpCredentials&&t.push("--mrp-credentials",s.mrpCredentials),s.airplayCredentials&&t.push("--airplay-credentials",s.airplayCredentials),s.companionCredentials&&t.push("--companion-credentials",s.companionCredentials),s.raopCredentials&&t.push("--raop-credentials",s.raopCredentials),t}function P(s,t,e,i,n){if(typeof s[e]=="string"){t[i]=s[e];return}n(`No ${i} value found in input (${JSON.stringify(s)})`)}function V(s,t,e){let i=o=>u(t,o,e),n={dateTime:null,hash:null,mediaType:null,deviceState:null,title:null,artist:null,album:null,genre:null,totalTime:null,position:null,shuffle:null,repeat:null,app:null,appId:null,powerState:null,volume:null,focusState:null,outputDevices:null};if(!s||typeof s!="object")return n;if(s.exception){let o="Got pyatv Error: "+s.exception;throw s.stacktrace&&(o+=`
|
|
2
|
-
|
|
3
|
-
pyatv Stacktrace:
|
|
4
|
-
`+s.stacktrace),new Error(o)}if(typeof s.datetime=="string"){let o=new Date(s.datetime);isNaN(o.getTime())?i(`Invalid datetime value ${s.datetime}, ignore attribute`):n.dateTime=o}else i(`No datetime value found in input (${JSON.stringify(s)})`);return P(s,n,"hash","hash",i),typeof s.media_type=="string"?Object.keys(k).map(r=>String(r)).includes(s.media_type)?n.mediaType=k[s.media_type]:i(`Unsupported mediaType value ${s.media_type}, ignore attribute`):i(`No mediaType value found in input (${JSON.stringify(s)})`),typeof s.device_state=="string"?Object.keys(x).map(r=>String(r)).includes(s.device_state)?n.deviceState=x[s.device_state]:i(`Unsupported deviceState value ${s.device_state}, ignore attribute`):i(`No deviceState value found in input (${JSON.stringify(s)})`),P(s,n,"title","title",i),P(s,n,"artist","artist",i),P(s,n,"album","album",i),P(s,n,"genre","genre",i),typeof s.total_time=="number"?n.totalTime=s.total_time:i(`No totalTime value found in input (${JSON.stringify(s)})`),typeof s.position=="number"?n.position=s.position:i(`No position value found in input (${JSON.stringify(s)})`),typeof s.shuffle=="string"?Object.keys(_).map(r=>String(r)).includes(s.shuffle)?n.shuffle=_[s.shuffle]:i(`Unsupported shuffle value ${s.shuffle}, ignore attribute`):i(`No shuffle value found in input (${JSON.stringify(s)})`),typeof s.repeat=="string"?Object.keys(E).map(r=>String(r)).includes(s.repeat)?n.repeat=E[s.repeat]:i(`Unsupported repeat value ${s.repeat}, ignore attribute`):i(`No repeat value found in input (${JSON.stringify(s)})`),P(s,n,"app","app",i),P(s,n,"app_id","appId",i),typeof s.power_state=="string"?Object.keys(D).map(r=>String(r)).includes(s.power_state)?n.powerState=D[s.power_state]:i(`Unsupported powerState value ${s.power_state}, ignore attribute`):i(`No powerState value found in input (${JSON.stringify(s)})`),typeof s.volume=="number"&&(n.volume=s.volume),typeof s.focus_state=="string"?Object.keys(L).map(r=>String(r)).includes(s.focus_state)?n.focusState=L[s.focus_state]:i(`Unsupported focusState value ${s.focus_state}, ignore attribute`):i(`No focusState value found in input (${JSON.stringify(s)})`),Array.isArray(s.output_devices)&&(n.outputDevices=s.output_devices),n}function J(s,t){return!!(Array.isArray(s)&&Array.isArray(t)&&JSON.stringify(s.sort((e,i)=>e.identifier<i.identifier?-1:1))===JSON.stringify(t.sort((e,i)=>e.identifier<i.identifier?-1:1)))}var b=class extends H{constructor(e,i,n){super();this.state=e,this.device=i,this.options=Object.assign({},n),this.listenerState=0}applyStateAndEmitEvents(e){let i=Object.keys(this.state);"powerState"in e&&e.powerState&&(i=["powerState"]),"focusState"in e&&e.focusState&&(i=["focusState"]),"outputDevices"in e&&e.outputDevices&&(i=["outputDevices"]),"volume"in e&&e.volume!==null&&(i=["volume"]),Object.entries(e).find(([n,o])=>!["result","dateTime"].includes(n)&&o!==null)&&i.forEach(n=>{let o=this.state[n],r=e[n];if(o===void 0||r===void 0||o===r||n==="outputDevices"&&J(o,r))return;let p=new N({key:n,old:o,new:r,device:this.device});this.state[n]=e[n];try{this.emit("update:"+n,p),this.emit("update",p)}catch(c){this.emit("error",c)}})}parsePushUpdate(e,i){let n;try{n=JSON.parse(i)}catch(o){let r=`Unable to parse stdout json: ${o}`;u(e,r,this.options),this.emit("error",new Error(r));return}this.applyPushUpdate(n,e),this.listenerState===1&&(this.listenerState=2,this.checkListener())}applyPushUpdate(e,i){try{let n=V(e,i,this.options);this.applyStateAndEmitEvents(n)}catch(n){this.emit("error",n)}}checkListener(){if(this.listenerState===0&&this.listenerCount()===0&&this.timeout)clearTimeout(this.timeout),this.timeout=void 0;else if(this.listenerState===0&&this.listenerCount()>0){let e=f();u(e,`Start listeing to events from device ${this.options.name}`,this.options),this.startListening(e),h(e)}else if([1,2].includes(this.listenerState)&&this.listenerCount()===0){let e=f();u(e,`Stop listening to events from device ${this.options.name}`,this.options),this.stopListening(e).catch(i=>u(e,`Unable to stop listeing: ${i}`,this.options)).finally(()=>h(e))}}startListening(e){if(this.listenerState!==0)return;this.listenerState=1;let i=new Date().getTime(),n=g(this.options);if(this.pyatv=I(e,"atvscript",[...n,"push_updates"],this.options),!this.pyatv)throw new Error("Unable to start listener: Unable to start atvscript");let o=l=>{u(e,`Got error from child process: ${l}`,this.options),this.emit("error",l)},r=l=>{let m=new Error(`Got stderr output from pyatv: ${l}`);u(e,l.toString(),this.options),this.emit("error",m)},p=l=>{String(l).split(`
|
|
5
|
-
`).map(m=>m.trim()).filter(Boolean).forEach(m=>{u(e,`> ${m}`,this.options),this.parsePushUpdate(e,m)})},c=l=>{this.pyatv!==void 0&&(this.listenerState=0,u(e,`Listening with atvscript exited with code ${l}`,this.options),this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0),this.pyatv.stdout&&this.pyatv.stdout.off("data",p),this.pyatv.stderr&&this.pyatv.stderr.off("data",r),this.pyatv.off("error",o),this.pyatv.off("close",c),this.listenerCount()>0&&new Date().getTime()-i<3e4?(u(e,`Wait 15s and restart listeing to events from device ${this.options.name}`,this.options),this.timeout=setTimeout(()=>{this.checkListener()},15e3)):this.listenerCount()>0&&(u(e,`Restart listeing to events from device ${this.options.name}`,this.options),this.checkListener()),h(e))};this.pyatv.on("error",o),this.pyatv.on("close",c),this.pyatv.stdout&&this.pyatv.stdout.on("data",p),this.pyatv.stderr&&this.pyatv.stderr.on("data",r)}stopListening(e){return a(this,null,function*(){if(!(this.listenerState!==1&&this.listenerState!==2)){if(this.listenerState=3,this.pyatv===void 0)throw new Error("Unable to stop listening due to internal error: state is stopping, but there's no child process. This should never happen, please report this.");this.pyatv.stdin&&(u(e,"Pressing enter to close atvscript\u2026",this.options),this.pyatv.stdin.write(`
|
|
6
|
-
`),yield new Promise(i=>this.timeout=setTimeout(i,250))),this.listenerState===3&&this.pyatv&&this.pyatv.kill(),this.listenerState=0}})}addListener(e,i){return super.addListener(e,i),this.checkListener(),this}on(e,i){return super.on(e,i),this.checkListener(),this}once(e,i){return super.once(e,n=>{i(n),setTimeout(()=>this.checkListener(),0)}),this.checkListener(),this}prependListener(e,i){return super.prependListener(e,i),this.checkListener(),this}off(e,i){return super.off(e,i),this.checkListener(),this}removeAllListeners(e){return super.removeAllListeners(e),this.checkListener(),this}removeListener(e,i){return super.removeListener(e,i),this.checkListener(),this}listenerCount(e){return e!==void 0?super.listenerCount(e):this.eventNames().map(i=>this.listenerCount(i)).reduce((i,n)=>i+n,0)}};var O=class{constructor(t){this.options=Object.assign({},t),this.state=V({},"",{}),this.events=new b(this.state,this,this.options)}get name(){return this.options.name}get host(){return this.options.host}get id(){return this.options.id}get allIDs(){return this.options.allIDs}get protocol(){return this.options.protocol}get mac(){return this.options.mac}get model(){return this.options.model}get modelName(){return this.options.modelName}get os(){return this.options.os}get version(){return this.options.version}get services(){return this.options.services}get debug(){return this.options.debug}set debug(t){typeof t=="function"?this.options.debug=t:this.options.debug=!!t||void 0}toJSON(){return{name:this.name,host:this.host,id:this.id,protocol:this.protocol}}toString(){return`NodePyATVDevice(${this.name}, ${this.host})`}getState(){return a(this,arguments,function*(t={}){var i;if((i=this.state)!=null&&i.dateTime&&new Date().getTime()-this.state.dateTime.getTime()<(t.maxAge||5e3)){let n=null;return this.state.position&&this.state.dateTime&&(n=Math.round(this.state.position+(new Date().getTime()-this.state.dateTime.getTime())/1e3)),Object.assign({},this.state,{position:n})}let e=f();try{let n=g(this.options),o=yield T(e,"atvscript",[...n,"playing"],this.options),r=V(o,e,this.options);return this.applyState(r),r}finally{h(e)}})}clearState(){this.applyState(V({},"",{}))}applyState(t){this.events.applyStateAndEmitEvents(t)}getDateTime(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).dateTime})}getHash(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).hash})}getMediaType(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).mediaType})}getDeviceState(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).deviceState})}getTitle(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).title})}getArtist(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).artist})}getAlbum(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).album})}getGenre(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).genre})}getTotalTime(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).totalTime})}getPosition(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).position})}getShuffle(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).shuffle})}getRepeat(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).repeat})}getApp(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).app})}getAppId(){return a(this,arguments,function*(t={}){return(yield this.getState(t)).appId})}listApps(){return a(this,null,function*(){let t=f(),e=g(this.options),i=yield T(t,"atvremote",[...e,"app_list"],this.options);if(typeof i!="string"||!i.startsWith("App: "))throw new Error("Unexpected atvremote response: "+i);h(t);let n=/(.+) \(([^\)]+)\)$/i;return i.substring(5).split(", App: ").map(r=>{let p=r.match(n);if(p!==null)return{id:p[2],name:p[1],launch:()=>this.launchApp(p[2])}}).filter(Boolean)})}_pressKey(t,e){return a(this,null,function*(){let i=f(),n=g(this.options),o=yield T(i,e,[...n,t],this.options);if(e==="atvscript"&&(typeof o!="object"||o.result!=="success"))throw new Error(`Unable to parse pyatv response: ${JSON.stringify(o,null," ")}`);h(i)})}pressKey(t){return a(this,null,function*(){let e=Object.entries(j).find(([o])=>t===o);if(!e)throw new Error(`Unsupported key value ${t}!`);let i=e[1],n=["turnOn","turnOff"].includes(t)?"atvremote":"atvscript";yield this._pressKey(i,n)})}down(){return a(this,null,function*(){yield this._pressKey("down","atvscript")})}home(){return a(this,null,function*(){yield this._pressKey("home","atvscript")})}homeHold(){return a(this,null,function*(){yield this._pressKey("home_hold","atvscript")})}left(){return a(this,null,function*(){yield this._pressKey("left","atvscript")})}menu(){return a(this,null,function*(){yield this._pressKey("menu","atvscript")})}next(){return a(this,null,function*(){yield this._pressKey("next","atvscript")})}pause(){return a(this,null,function*(){yield this._pressKey("pause","atvscript")})}play(){return a(this,null,function*(){yield this._pressKey("play","atvscript")})}playPause(){return a(this,null,function*(){yield this._pressKey("play_pause","atvscript")})}previous(){return a(this,null,function*(){yield this._pressKey("previous","atvscript")})}right(){return a(this,null,function*(){yield this._pressKey("right","atvscript")})}select(){return a(this,null,function*(){yield this._pressKey("select","atvscript")})}skipBackward(){return a(this,null,function*(){yield this._pressKey("skip_backward","atvscript")})}skipForward(){return a(this,null,function*(){yield this._pressKey("skip_forward","atvscript")})}stop(){return a(this,null,function*(){yield this._pressKey("stop","atvscript")})}suspend(){return a(this,null,function*(){yield this._pressKey("suspend","atvscript")})}topMenu(){return a(this,null,function*(){yield this._pressKey("top_menu","atvscript")})}up(){return a(this,null,function*(){yield this._pressKey("up","atvscript")})}volumeDown(){return a(this,null,function*(){yield this._pressKey("volume_down","atvscript")})}volumeUp(){return a(this,null,function*(){yield this._pressKey("volume_up","atvscript")})}wakeup(){return a(this,null,function*(){yield this._pressKey("wakeup","atvscript")})}turnOff(){return a(this,null,function*(){yield this._pressKey("turn_off","atvremote")})}turnOn(){return a(this,null,function*(){yield this._pressKey("turn_on","atvremote")})}launchApp(t){return a(this,null,function*(){yield this._pressKey("launch_app="+t,"atvremote")})}addListener(t,e){return this.events.addListener(t,e),this}emit(t,e){return this.events.emit(t,e)}eventNames(){return this.events.eventNames()}getMaxListeners(){return this.events.getMaxListeners()}listenerCount(t){return this.events.listenerCount(t)}listeners(t){return this.events.listeners(t)}off(t,e){return this.events.off(t,e),this}on(t,e){return this.events.on(t,e),this}once(t,e){return this.events.once(t,e),this}prependListener(t,e){return this.events.prependListener(t,e),this}prependOnceListener(t,e){return this.events.prependOnceListener(t,e),this}rawListeners(t){return this.events.rawListeners(t)}removeAllListeners(t){return this.events.removeAllListeners(t),this}removeListener(t,e){return this.events.removeListener(t,e),this}setMaxListeners(t){return this.events.setMaxListeners(t),this}};import G from"semver";import{join as W,dirname as z}from"path";import{fileURLToPath as Q}from"url";import{promises as X}from"fs";var Y={};var C=class s{constructor(t={}){this.options={};this.options=Object.assign({},t)}static check(){return a(this,arguments,function*(t={}){let e=yield this.version(t);if(!e.pyatv)throw new Error("Unable to find pyatv. Is it installed?");if(G.lt(e.pyatv,"0.6.0"))throw new Error("Found pyatv, but unforunately it's too old. Please update pyatv.");try{yield this.find(t)}catch(i){throw new Error(`Unable to scan for devices: ${String(i).replace("Error: ","")}`)}})}static version(){return a(this,arguments,function*(t={}){let e=f(),i=null,n=null;try{i=yield T(e,"atvremote",["--version"],t)}catch(o){u(e,`Unable to get pyatv version due to ${o}`,t)}i&&i.substr(0,10)==="atvremote "&&(i=i.substr(10)),G.valid(i)||(u(e,`String "${i}" is not a valid pyatv version, set it to null`,t),i=null);try{let o=W(z(Q(Y.url)),"..","..","package.json"),r=JSON.parse(yield X.readFile(o,"utf8"));n=(r==null?void 0:r.version)||null}catch(o){u(e,`Unable to get module version due to ${o}`,t)}return n&&!G.valid(n)&&(u(e,`String "${n}" is not a valid module version, set it to null`,t),n=null),h(e),{pyatv:i,module:n}})}static find(){return a(this,arguments,function*(t={}){let e=f(),i=g(t),n=yield T(e,"atvscript",[...i,"scan"],t);if(typeof n!="object"||n.result!=="success"||!Array.isArray(n.devices))throw new Error(`Unable to parse pyatv response: ${JSON.stringify(n,null," ")}`);let o=n.devices.map(r=>{var p,c,l,m,v;return this.device(Object.assign({},t,{host:r.address,id:r.identifier,allIDs:r.all_identifiers,name:r.name,mac:(p=r.device_info)==null?void 0:p.mac,model:(c=r.device_info)==null?void 0:c.model,modelName:(l=r.device_info)==null?void 0:l.model_str,os:(m=r.device_info)==null?void 0:m.operating_system,version:(v=r.device_info)==null?void 0:v.version,services:r.services}))});return h(e),o})}static device(t){return new O(t)}check(){return a(this,arguments,function*(t={}){return s.check(Object.assign({},this.options,t))})}version(){return a(this,arguments,function*(t={}){return s.version(Object.assign({},this.options,t))})}find(){return a(this,arguments,function*(t={}){return s.find(Object.assign({},this.options,t))})}device(t){return s.device(Object.assign({},this.options,t))}};export{a,A as b,R as c,k as d,x as e,E as f,_ as g,D as h,U as i,F as j,N as k,b as l,O as m,C as n};
|
|
7
|
-
//# sourceMappingURL=chunk-52OYIOVF.js.map
|