@sebbo2002/node-pyatv 6.0.0-develop.1 → 6.0.0-develop.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/bin/check.cjs +10 -0
  2. package/dist/bin/check.cjs.map +1 -0
  3. package/dist/bin/check.d.ts +2 -1
  4. package/dist/bin/check.js +4 -45
  5. package/dist/bin/check.js.map +1 -1
  6. package/dist/chunk-TZSWUAOB.js +7 -0
  7. package/dist/chunk-TZSWUAOB.js.map +1 -0
  8. package/dist/lib/index.cjs +7 -0
  9. package/dist/lib/index.cjs.map +1 -0
  10. package/dist/lib/{device.d.ts → index.d.cts} +351 -4
  11. package/dist/lib/index.d.ts +806 -6
  12. package/dist/lib/index.js +1 -7
  13. package/dist/lib/index.js.map +1 -1
  14. package/package.json +23 -14
  15. package/.editorconfig +0 -12
  16. package/.eslintignore +0 -4
  17. package/.eslintrc +0 -60
  18. package/.mocharc.yml +0 -7
  19. package/.nycrc +0 -32
  20. package/CHANGELOG.md +0 -288
  21. package/check.sh +0 -5
  22. package/dist/examples/push.d.ts +0 -1
  23. package/dist/examples/push.js +0 -51
  24. package/dist/examples/push.js.map +0 -1
  25. package/dist/lib/device-event.d.ts +0 -44
  26. package/dist/lib/device-event.js +0 -47
  27. package/dist/lib/device-event.js.map +0 -1
  28. package/dist/lib/device-events.d.ts +0 -30
  29. package/dist/lib/device-events.js +0 -237
  30. package/dist/lib/device-events.js.map +0 -1
  31. package/dist/lib/device.js +0 -756
  32. package/dist/lib/device.js.map +0 -1
  33. package/dist/lib/fake-spawn.d.ts +0 -43
  34. package/dist/lib/fake-spawn.js +0 -85
  35. package/dist/lib/fake-spawn.js.map +0 -1
  36. package/dist/lib/instance.d.ts +0 -97
  37. package/dist/lib/instance.js +0 -208
  38. package/dist/lib/instance.js.map +0 -1
  39. package/dist/lib/tools.d.ts +0 -12
  40. package/dist/lib/tools.js +0 -319
  41. package/dist/lib/tools.js.map +0 -1
  42. package/dist/lib/types.d.ts +0 -199
  43. package/dist/lib/types.js +0 -108
  44. package/dist/lib/types.js.map +0 -1
  45. package/docs/coverage/base.css +0 -224
  46. package/docs/coverage/block-navigation.js +0 -87
  47. package/docs/coverage/cobertura-coverage.xml +0 -2829
  48. package/docs/coverage/device-event.ts.html +0 -256
  49. package/docs/coverage/device-events.ts.html +0 -970
  50. package/docs/coverage/device.ts.html +0 -2401
  51. package/docs/coverage/fake-spawn.ts.html +0 -448
  52. package/docs/coverage/favicon.png +0 -0
  53. package/docs/coverage/index.html +0 -221
  54. package/docs/coverage/index.ts.html +0 -172
  55. package/docs/coverage/instance.ts.html +0 -718
  56. package/docs/coverage/prettify.css +0 -1
  57. package/docs/coverage/prettify.js +0 -2
  58. package/docs/coverage/sort-arrow-sprite.png +0 -0
  59. package/docs/coverage/sorter.js +0 -196
  60. package/docs/coverage/tools.ts.html +0 -1222
  61. package/docs/coverage/types.ts.html +0 -757
  62. package/docs/reference/.nojekyll +0 -1
  63. package/docs/reference/assets/highlight.css +0 -99
  64. package/docs/reference/assets/main.js +0 -58
  65. package/docs/reference/assets/search.js +0 -1
  66. package/docs/reference/assets/style.css +0 -1280
  67. package/docs/reference/classes/NodePyATVDevice.html +0 -1228
  68. package/docs/reference/classes/NodePyATVDeviceEvent.html +0 -123
  69. package/docs/reference/classes/NodePyATVInstance.html +0 -240
  70. package/docs/reference/enums/NodePyATVDeviceState.html +0 -97
  71. package/docs/reference/enums/NodePyATVExecutableType.html +0 -69
  72. package/docs/reference/enums/NodePyATVKeys.html +0 -216
  73. package/docs/reference/enums/NodePyATVListenerState.html +0 -83
  74. package/docs/reference/enums/NodePyATVMediaType.html +0 -83
  75. package/docs/reference/enums/NodePyATVPowerState.html +0 -69
  76. package/docs/reference/enums/NodePyATVProtocol.html +0 -83
  77. package/docs/reference/enums/NodePyATVRepeatState.html +0 -76
  78. package/docs/reference/enums/NodePyATVShuffleState.html +0 -76
  79. package/docs/reference/index.html +0 -139
  80. package/docs/reference/interfaces/NodePyATVDeviceOptions.html +0 -232
  81. package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +0 -193
  82. package/docs/reference/interfaces/NodePyATVFindOptions.html +0 -124
  83. package/docs/reference/interfaces/NodePyATVGetStateOptions.html +0 -66
  84. package/docs/reference/interfaces/NodePyATVInstanceOptions.html +0 -113
  85. package/docs/reference/interfaces/NodePyATVService.html +0 -73
  86. package/docs/reference/interfaces/NodePyATVState.html +0 -164
  87. package/docs/reference/interfaces/NodePyATVVersionResponse.html +0 -73
  88. package/docs/reference/modules.html +0 -106
  89. package/docs/reference/types/NodePyATVEventValueType.html +0 -66
  90. package/docs/tests/assets/MaterialIcons-Regular.woff +0 -0
  91. package/docs/tests/assets/MaterialIcons-Regular.woff2 +0 -0
  92. package/docs/tests/assets/app.css +0 -14
  93. package/docs/tests/assets/app.js +0 -2
  94. package/docs/tests/assets/app.js.LICENSE.txt +0 -55
  95. package/docs/tests/assets/roboto-light-webfont.woff +0 -0
  96. package/docs/tests/assets/roboto-light-webfont.woff2 +0 -0
  97. package/docs/tests/assets/roboto-medium-webfont.woff +0 -0
  98. package/docs/tests/assets/roboto-medium-webfont.woff2 +0 -0
  99. package/docs/tests/assets/roboto-regular-webfont.woff +0 -0
  100. package/docs/tests/assets/roboto-regular-webfont.woff2 +0 -0
  101. package/docs/tests/index.html +0 -2
  102. package/docs/tests/mochawesome.json +0 -4745
  103. package/release.config.cjs +0 -51
  104. package/src/bin/check.ts +0 -41
  105. package/src/examples/push.ts +0 -46
  106. package/src/lib/device-event.ts +0 -57
  107. package/src/lib/device-events.ts +0 -295
  108. package/src/lib/device.ts +0 -772
  109. package/src/lib/fake-spawn.ts +0 -121
  110. package/src/lib/index.ts +0 -29
  111. package/src/lib/instance.ts +0 -211
  112. package/src/lib/tools.ts +0 -379
  113. package/src/lib/types.ts +0 -224
  114. package/test/device-event.ts +0 -88
  115. package/test/device-events.ts +0 -502
  116. package/test/device.ts +0 -784
  117. package/test/instance.ts +0 -428
  118. package/test/tools.ts +0 -301
  119. package/tsconfig.json +0 -19
  120. package/typedoc.json +0 -15
@@ -1,7 +1,245 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { NodePyATVDeviceOptions, NodePyATVDeviceState, NodePyATVGetStateOptions, NodePyATVKeys, NodePyATVMediaType, NodePyATVProtocol, NodePyATVRepeatState, NodePyATVService, NodePyATVShuffleState, NodePyATVState } from './types.js';
3
- import { NodePyATVDeviceEvent } from '../lib/index.js';
1
+ import { SpawnOptions, ChildProcess } from 'child_process';
4
2
  import { EventEmitter } from 'events';
3
+
4
+ /**
5
+ * @internal
6
+ */
7
+ declare class FakeChildProcessStdIn extends EventEmitter {
8
+ write(data: string): void;
9
+ }
10
+ /**
11
+ * @internal
12
+ */
13
+ declare class FakeChildProcess extends EventEmitter {
14
+ cmd: string;
15
+ args: ReadonlyArray<string>;
16
+ timeout: NodeJS.Timeout | undefined;
17
+ stdout: EventEmitter;
18
+ stderr: EventEmitter;
19
+ stdin: FakeChildProcessStdIn;
20
+ constructor(command: string, args: ReadonlyArray<string>, options: SpawnOptions, callback: (cp: FakeChildProcessController) => void);
21
+ kill(): void;
22
+ }
23
+ /**
24
+ * @internal
25
+ */
26
+ declare class FakeChildProcessController {
27
+ _cp: FakeChildProcess;
28
+ _code: number | null;
29
+ constructor(cp: FakeChildProcess);
30
+ cmd(): string;
31
+ stdout(content: string | Record<string, unknown>): this;
32
+ stderr(content: string): this;
33
+ onStdIn(listener: (...args: any[]) => void): this;
34
+ error(error: Error): this;
35
+ code(exitCode: number): this;
36
+ end(content?: string | Record<string, unknown>): this;
37
+ }
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 NodePyATVKeys {
78
+ down = "down",
79
+ home = "home",
80
+ homeHold = "homeHold",
81
+ left = "left",
82
+ menu = "menu",
83
+ next = "next",
84
+ pause = "pause",
85
+ play = "play",
86
+ playPause = "playPause",
87
+ previous = "previous",
88
+ right = "right",
89
+ select = "select",
90
+ skipBackward = "skipBackward",
91
+ skipForward = "skipForward",
92
+ stop = "stop",
93
+ suspend = "suspend",
94
+ topMenu = "topMenu",
95
+ up = "up",
96
+ volumeDown = "volumeDown",
97
+ volumeUp = "volumeUp",
98
+ wakeup = "wakeup",
99
+ turnOff = "turnOff",
100
+ turnOn = "turnOn"
101
+ }
102
+ declare enum NodePyATVListenerState {
103
+ stopped = 0,
104
+ starting = 1,
105
+ started = 2,
106
+ stopping = 3
107
+ }
108
+ type NodePyATVStateIndex = keyof NodePyATVState;
109
+ type NodePyATVEventValueType = (string | number | NodePyATVMediaType | NodePyATVDeviceState | NodePyATVShuffleState | NodePyATVRepeatState);
110
+ interface NodePyATVInstanceOptions {
111
+ atvremotePath?: string;
112
+ atvscriptPath?: string;
113
+ debug?: true | ((msg: string) => void);
114
+ noColors?: true;
115
+ spawn?: (command: string, args: Array<string>, options: SpawnOptions) => (ChildProcess | FakeChildProcess);
116
+ }
117
+ interface NodePyATVVersionResponse {
118
+ pyatv: string | null;
119
+ module: string | null;
120
+ }
121
+ interface NodePyATVFindOptions {
122
+ host?: string;
123
+ hosts?: string[];
124
+ id?: string;
125
+ protocol?: NodePyATVProtocol;
126
+ dmapCredentials?: string;
127
+ mrpCredentials?: string;
128
+ airplayCredentials?: string;
129
+ companionCredentials?: string;
130
+ raopCredentials?: string;
131
+ }
132
+ interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {
133
+ }
134
+ interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {
135
+ host: string;
136
+ name: string;
137
+ model?: string;
138
+ modelName?: string;
139
+ os?: string;
140
+ version?: string;
141
+ services?: NodePyATVService[];
142
+ }
143
+ interface NodePyATVGetStateOptions {
144
+ maxAge?: number;
145
+ }
146
+ interface NodePyATVService {
147
+ protocol: NodePyATVProtocol;
148
+ port: number;
149
+ }
150
+ interface NodePyATVState {
151
+ dateTime: Date | null;
152
+ hash: string | null;
153
+ mediaType: NodePyATVMediaType | null;
154
+ deviceState: NodePyATVDeviceState | null;
155
+ title: string | null;
156
+ artist: string | null;
157
+ album: string | null;
158
+ genre: string | null;
159
+ totalTime: number | null;
160
+ position: number | null;
161
+ shuffle: NodePyATVShuffleState | null;
162
+ repeat: NodePyATVRepeatState | null;
163
+ app: string | null;
164
+ appId: string | null;
165
+ powerState: NodePyATVPowerState | null;
166
+ }
167
+ interface NodePyATVApp {
168
+ id: string;
169
+ name: string;
170
+ launch: () => Promise<void>;
171
+ }
172
+
173
+ declare class NodePyATVDeviceEvent {
174
+ protected readonly values: {
175
+ key: NodePyATVStateIndex;
176
+ old: NodePyATVEventValueType;
177
+ new: NodePyATVEventValueType;
178
+ device: NodePyATVDevice;
179
+ };
180
+ /**
181
+ *
182
+ * @param values
183
+ * @internal
184
+ */
185
+ constructor(values: {
186
+ key: NodePyATVStateIndex;
187
+ old: NodePyATVEventValueType;
188
+ new: NodePyATVEventValueType;
189
+ device: NodePyATVDevice;
190
+ });
191
+ /**
192
+ * References the attribute name which was changed. So if the
193
+ * title has been updated, this would be `title`.
194
+ */
195
+ get key(): NodePyATVStateIndex;
196
+ /**
197
+ * Holds the old value which was there
198
+ * before the value was changed.
199
+ */
200
+ get oldValue(): NodePyATVEventValueType;
201
+ /**
202
+ * @alias value
203
+ */
204
+ get newValue(): NodePyATVEventValueType;
205
+ /**
206
+ * New, current value for `key`
207
+ */
208
+ get value(): NodePyATVEventValueType;
209
+ /**
210
+ * References the device instance this
211
+ * event originates from
212
+ */
213
+ get device(): NodePyATVDevice;
214
+ }
215
+
216
+ /**
217
+ * @internal
218
+ */
219
+ declare class NodePyATVDeviceEvents extends EventEmitter {
220
+ private readonly options;
221
+ private readonly state;
222
+ private readonly device;
223
+ private pyatv;
224
+ private timeout;
225
+ private listenerState;
226
+ constructor(state: NodePyATVState, device: NodePyATVDevice, options: NodePyATVDeviceOptions);
227
+ applyStateAndEmitEvents(newState: NodePyATVState): void;
228
+ private parsePushUpdate;
229
+ private applyPushUpdate;
230
+ private checkListener;
231
+ private startListening;
232
+ protected stopListening(reqId: string): Promise<void>;
233
+ addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
234
+ on(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
235
+ once(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
236
+ prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
237
+ off(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
238
+ removeAllListeners(event?: string | symbol): this;
239
+ removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this;
240
+ listenerCount(event?: string | symbol): number;
241
+ }
242
+
5
243
  /**
6
244
  * Represents an Apple TV. Use [[getState]] to query the current state (e.g. media
7
245
  * type and title). You can also use the attribute methods (e.g. [[getTitle]] to get
@@ -9,7 +247,7 @@ import { EventEmitter } from 'events';
9
247
  * `EventEmitter` like API, so for example by using [[on]], [[once]] or [[addListener]].
10
248
  * It's also possible to send key commands by using [[pressKey]] or methods like [[pause]].
11
249
  */
12
- export default class NodePyATVDevice implements EventEmitter {
250
+ declare class NodePyATVDevice implements EventEmitter {
13
251
  private readonly options;
14
252
  private readonly state;
15
253
  private readonly events;
@@ -218,6 +456,11 @@ export default class NodePyATVDevice implements EventEmitter {
218
456
  * @category State
219
457
  */
220
458
  getAppId(options?: NodePyATVGetStateOptions): Promise<string | null>;
459
+ /**
460
+ * Returns the list of installed apps on the Apple TV. Probably requires `companionCredentials`,
461
+ * see https://pyatv.dev/documentation/atvremote/#apps for more details.
462
+ */
463
+ listApps(): Promise<NodePyATVApp[]>;
221
464
  private _pressKey;
222
465
  /**
223
466
  * Send a key press to the Apple TV
@@ -353,6 +596,12 @@ export default class NodePyATVDevice implements EventEmitter {
353
596
  * @category Control
354
597
  */
355
598
  turnOn(): Promise<void>;
599
+ /**
600
+ * Launch an application. Probably requires `companionCredentials`, see
601
+ * https://pyatv.dev/documentation/atvremote/#apps for more details.
602
+ * @param id App identifier, e.g. `com.netflix.Netflix`
603
+ */
604
+ launchApp(id: string): Promise<void>;
356
605
  /**
357
606
  * Add an event listener. Will start the event subscription with the
358
607
  * Apple TV as long as there are listeners for any event registered.
@@ -457,3 +706,101 @@ export default class NodePyATVDevice implements EventEmitter {
457
706
  */
458
707
  setMaxListeners(n: number): this;
459
708
  }
709
+
710
+ /**
711
+ * Default class exported by `@sebbo2002/node-pyatv`. Use [[find]] to scan for devices in your local network. Use
712
+ * [[device]] to connect to a known device by passing (at least) it's name and IP.
713
+ *
714
+ * ```typescript
715
+ * import pyatv from '@sebbo2002/node-pyatv';
716
+ * ```
717
+ */
718
+ declare class NodePyATVInstance {
719
+ private readonly options;
720
+ /**
721
+ * Checks if pyatv is installed and ready to be used.
722
+ * Will throw an error if not.
723
+ *
724
+ * @param options
725
+ */
726
+ static check(options?: NodePyATVInstanceOptions): Promise<void>;
727
+ /**
728
+ * Resolves with the version of pyatv and of the module itself.
729
+ * If a value can't be found, null is returned instead.
730
+ *
731
+ * @param options
732
+ */
733
+ static version(options?: NodePyATVInstanceOptions): Promise<NodePyATVVersionResponse>;
734
+ /**
735
+ * Scan the network for Apple TVs by using pyatv's atvscript. See [[NodePyATVFindAndInstanceOptions]]
736
+ * for the options allowed. Use the `host` / `hosts` attribute to filter by IP addresses. Resolves with
737
+ * an array of [[NodePyATVDevice]].
738
+ *
739
+ * ```typescript
740
+ * import pyatv from '@sebbo2002/node-pyatv';
741
+ * const devices = await pyatv.find();
742
+ * console.log(devices);
743
+ * ```
744
+ *
745
+ * @param options
746
+ */
747
+ static find(options?: NodePyATVFindAndInstanceOptions): Promise<NodePyATVDevice[]>;
748
+ /**
749
+ * Create a [[NodePyATVDevice]] to query the state and control it.
750
+ * At least `host` and `name` are required.
751
+ *
752
+ * @param options
753
+ */
754
+ static device(options: NodePyATVDeviceOptions): NodePyATVDevice;
755
+ /**
756
+ * Use this to apply [[NodePyATVInstanceOptions]]
757
+ * (e.g. debug log method) to all further requests
758
+ *
759
+ * ```typescript
760
+ * import pyatv from '@sebbo2002/node-pyatv';
761
+ * const myPyatv = new pyatv({debug: true});
762
+ * const devices = myPyatv.find();
763
+ * console.log(devices);
764
+ * ```
765
+ * @param options
766
+ */
767
+ constructor(options?: NodePyATVInstanceOptions);
768
+ /**
769
+ * Checks if pyatv is installed and ready to be used.
770
+ * Will throw an error if not.
771
+ *
772
+ * @param options
773
+ */
774
+ check(options?: NodePyATVInstanceOptions): Promise<void>;
775
+ /**
776
+ * Resolves with the version of pyatv and of the module itself.
777
+ * If a value can't be found, null is returned instead.
778
+ *
779
+ * @param options
780
+ */
781
+ version(options?: NodePyATVInstanceOptions): Promise<NodePyATVVersionResponse>;
782
+ /**
783
+ * Scan the network for Apple TVs by using pyatv's atvscript. See [[NodePyATVFindAndInstanceOptions]]
784
+ * for the options allowed. Use the `host` / `hosts` attribute to filter by IP addresses. Resolves with
785
+ * an array of [[NodePyATVDevice]].
786
+ *
787
+ * ```typescript
788
+ * import pyatv from '@sebbo2002/node-pyatv';
789
+ * const myPyATV = new pyatv({debug: true});
790
+ * const devices = await myPyATV.find();
791
+ * console.log(devices);
792
+ * ```
793
+ *
794
+ * @param options
795
+ */
796
+ find(options?: NodePyATVFindAndInstanceOptions): Promise<NodePyATVDevice[]>;
797
+ /**
798
+ * Create a [[NodePyATVDevice]] to query the state and control it.
799
+ * At least `host` and `name` are required.
800
+ *
801
+ * @param options
802
+ */
803
+ device(options: NodePyATVDeviceOptions): NodePyATVDevice;
804
+ }
805
+
806
+ export { NodePyATVDevice, NodePyATVDeviceEvent, NodePyATVDeviceEvents, NodePyATVDeviceOptions, NodePyATVDeviceState, NodePyATVEventValueType, NodePyATVExecutableType, NodePyATVFindAndInstanceOptions, NodePyATVFindOptions, NodePyATVGetStateOptions, NodePyATVInstance, NodePyATVInstanceOptions, NodePyATVKeys, NodePyATVListenerState, NodePyATVMediaType, NodePyATVPowerState, NodePyATVProtocol, NodePyATVRepeatState, NodePyATVService, NodePyATVShuffleState, NodePyATVState, NodePyATVVersionResponse, NodePyATVInstance as default };