@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,756 +0,0 @@
1
- 'use strict';
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- import { NodePyATVExecutableType, NodePyATVInternalKeys, NodePyATVKeys } from './types.js';
12
- import { addRequestId, getParamters, parseState, removeRequestId, request } from './tools.js';
13
- import { NodePyATVDeviceEvents } from '../lib/index.js';
14
- /**
15
- * Represents an Apple TV. Use [[getState]] to query the current state (e.g. media
16
- * type and title). You can also use the attribute methods (e.g. [[getTitle]] to get
17
- * the state. If you want realtime updates, subscribe to it's events with an
18
- * `EventEmitter` like API, so for example by using [[on]], [[once]] or [[addListener]].
19
- * It's also possible to send key commands by using [[pressKey]] or methods like [[pause]].
20
- */
21
- export default class NodePyATVDevice {
22
- constructor(options) {
23
- this.options = Object.assign({}, options);
24
- this.state = parseState({}, '', {});
25
- this.events = new NodePyATVDeviceEvents(this.state, this, this.options);
26
- // @todo basic validation
27
- }
28
- /**
29
- * Get the name of the Apple TV.
30
- *
31
- * ```typescript
32
- * import pyatv from '@sebbo2002/node-pyatv';
33
- * const devices = await pyatv.find();
34
- * devices.forEach(device =>
35
- * console.log(device.name)
36
- * );
37
- * ```
38
- */
39
- get name() {
40
- return this.options.name;
41
- }
42
- /**
43
- * Get the IP address of the Apple TV.
44
- */
45
- get host() {
46
- return this.options.host;
47
- }
48
- /**
49
- * Get the ID of the Apple TV.
50
- */
51
- get id() {
52
- return this.options.id;
53
- }
54
- /**
55
- * Get the used protocol to connect to the Apple TV.
56
- */
57
- get protocol() {
58
- return this.options.protocol;
59
- }
60
- /**
61
- * Get the model identifier of the device. Only set, if the
62
- * device was found using [[find()]]. Requires pyatv ≧ 0.10.3.
63
- *
64
- * @example device.model → "Gen4K"
65
- */
66
- get model() {
67
- return this.options.model;
68
- }
69
- /**
70
- * Get the model name of the device. Only set, if the device
71
- * was found with [[find()]]. Requires pyatv ≧ 0.10.3.
72
- *
73
- * @example device.modelName → "Apple TV 4K"
74
- */
75
- get modelName() {
76
- return this.options.modelName;
77
- }
78
- /**
79
- * Get the operating system of the device. Only set, if the
80
- * device was found with [[find()]]. Requires pyatv ≧ 0.10.3.
81
- *
82
- * @example device.os → "TvOS"
83
- */
84
- get os() {
85
- return this.options.os;
86
- }
87
- /**
88
- * Get the device version. Only set, if the device was found
89
- * during a scan using [[find()]]. Requires pyatv ≧ 0.10.3.
90
- *
91
- * @example device.version → "15.5.1"
92
- */
93
- get version() {
94
- return this.options.version;
95
- }
96
- /**
97
- * Returns a list of services supported by the device. Ony set, if
98
- * the device was found during a scan using [[find()]]. Requires
99
- * pyatv ≧ 0.10.3.
100
- *
101
- * @example device.services → [
102
- * {
103
- * "protocol": "airplay",
104
- * "port": 7000
105
- * },
106
- * {
107
- * "protocol": "dmap",
108
- * "port": 3689
109
- * }
110
- * ]
111
- */
112
- get services() {
113
- return this.options.services;
114
- }
115
- /**
116
- * Returns true, if debugging is enabled. Returns the custom
117
- * logging method, if one was specified. Otherwise, if debug
118
- * log is disabled, returns undefined.
119
- */
120
- get debug() {
121
- return this.options.debug;
122
- }
123
- /**
124
- * Enable or disable debugging or set a custom
125
- * debugging method to use.
126
- *
127
- * @param debug
128
- */
129
- set debug(debug) {
130
- if (typeof debug === 'function') {
131
- this.options.debug = debug;
132
- }
133
- else {
134
- this.options.debug = Boolean(debug) || undefined;
135
- }
136
- }
137
- /**
138
- * Returns an object with `name`, `host`, `id` and `protocol`.
139
- * Can be used to initiate a new device instance.
140
- *
141
- * @category Basic
142
- */
143
- toJSON() {
144
- return {
145
- name: this.name,
146
- host: this.host,
147
- id: this.id,
148
- protocol: this.protocol
149
- };
150
- }
151
- /**
152
- * Returns a string. Just for debugging, etc.
153
- *
154
- * @category Basic
155
- */
156
- toString() {
157
- return `NodePyATVDevice(${this.name}, ${this.host})`;
158
- }
159
- /**
160
- * Returns an [[NodePyATVState]] object representing the current state
161
- * of the device. Has an internal cache, which has a default TTL of 5s.
162
- * You can change this default value by passing the `maxAge` option.
163
- *
164
- * ```typescript
165
- * await device.getState({maxAge: 10000}); // cache TTL: 10s
166
- * ```
167
- *
168
- * @param options
169
- * @category State
170
- */
171
- getState(options = {}) {
172
- var _a;
173
- return __awaiter(this, void 0, void 0, function* () {
174
- if (((_a = this.state) === null || _a === void 0 ? void 0 : _a.dateTime) && new Date().getTime() - this.state.dateTime.getTime() < (options.maxAge || 5000)) {
175
- let position = null;
176
- if (this.state.position && this.state.dateTime) {
177
- position = Math.round(this.state.position +
178
- ((new Date().getTime() - this.state.dateTime.getTime()) / 1000));
179
- }
180
- return Object.assign({}, this.state, { position });
181
- }
182
- const id = addRequestId();
183
- try {
184
- const parameters = getParamters(this.options);
185
- const result = yield request(id, NodePyATVExecutableType.atvscript, [...parameters, 'playing'], this.options);
186
- const newState = parseState(result, id, this.options);
187
- this.applyState(newState);
188
- return newState;
189
- }
190
- finally {
191
- removeRequestId(id);
192
- }
193
- });
194
- }
195
- /**
196
- * Removes the state node-pyatv cached for this device.
197
- *
198
- * @category State
199
- */
200
- clearState() {
201
- this.applyState(parseState({}, '', {}));
202
- }
203
- applyState(newState) {
204
- this.events.applyStateAndEmitEvents(newState);
205
- }
206
- /**
207
- * Get the date and time when the state was last updated.
208
- * @param options
209
- * @category State
210
- */
211
- getDateTime(options = {}) {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- const state = yield this.getState(options);
214
- return state.dateTime;
215
- });
216
- }
217
- /**
218
- * Get the hash of the current media
219
- * @param options
220
- * @category State
221
- */
222
- getHash(options = {}) {
223
- return __awaiter(this, void 0, void 0, function* () {
224
- const state = yield this.getState(options);
225
- return state.hash;
226
- });
227
- }
228
- /**
229
- * Get the media type of the current media
230
- * @param options
231
- * @category State
232
- */
233
- getMediaType(options = {}) {
234
- return __awaiter(this, void 0, void 0, function* () {
235
- const state = yield this.getState(options);
236
- return state.mediaType;
237
- });
238
- }
239
- /**
240
- * Get the state of this device (e.g. playing, etc.)
241
- * @param options
242
- * @category State
243
- */
244
- getDeviceState(options = {}) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- const state = yield this.getState(options);
247
- return state.deviceState;
248
- });
249
- }
250
- /**
251
- * Returns the title of the current playing media
252
- * @param options
253
- * @category State
254
- */
255
- getTitle(options = {}) {
256
- return __awaiter(this, void 0, void 0, function* () {
257
- const state = yield this.getState(options);
258
- return state.title;
259
- });
260
- }
261
- /**
262
- * Returns the artist of the current playing media
263
- * @param options
264
- * @category State
265
- */
266
- getArtist(options = {}) {
267
- return __awaiter(this, void 0, void 0, function* () {
268
- const state = yield this.getState(options);
269
- return state.artist;
270
- });
271
- }
272
- /**
273
- * Returns the album of the current playing media
274
- * @param options
275
- * @category State
276
- */
277
- getAlbum(options = {}) {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- const state = yield this.getState(options);
280
- return state.album;
281
- });
282
- }
283
- /**
284
- * Returns the genre of the current playing media
285
- * @param options
286
- * @category State
287
- */
288
- getGenre(options = {}) {
289
- return __awaiter(this, void 0, void 0, function* () {
290
- const state = yield this.getState(options);
291
- return state.genre;
292
- });
293
- }
294
- /**
295
- * Returns the media length of the current playing media
296
- * @param options
297
- * @category State
298
- */
299
- getTotalTime(options = {}) {
300
- return __awaiter(this, void 0, void 0, function* () {
301
- const state = yield this.getState(options);
302
- return state.totalTime;
303
- });
304
- }
305
- /**
306
- * Returns the title of the current playing media
307
- * @param options
308
- * @category State
309
- */
310
- getPosition(options = {}) {
311
- return __awaiter(this, void 0, void 0, function* () {
312
- const state = yield this.getState(options);
313
- return state.position;
314
- });
315
- }
316
- /**
317
- * Returns the shuffle state
318
- * @param options
319
- * @category State
320
- */
321
- getShuffle(options = {}) {
322
- return __awaiter(this, void 0, void 0, function* () {
323
- const state = yield this.getState(options);
324
- return state.shuffle;
325
- });
326
- }
327
- /**
328
- * Returns the repeat state
329
- * @param options
330
- * @category State
331
- */
332
- getRepeat(options = {}) {
333
- return __awaiter(this, void 0, void 0, function* () {
334
- const state = yield this.getState(options);
335
- return state.repeat;
336
- });
337
- }
338
- /**
339
- * Returns the currently used app
340
- * @param options
341
- * @category State
342
- */
343
- getApp(options = {}) {
344
- return __awaiter(this, void 0, void 0, function* () {
345
- const state = yield this.getState(options);
346
- return state.app;
347
- });
348
- }
349
- /**
350
- * Returns the id of the currently used app
351
- * @param options
352
- * @category State
353
- */
354
- getAppId(options = {}) {
355
- return __awaiter(this, void 0, void 0, function* () {
356
- const state = yield this.getState(options);
357
- return state.appId;
358
- });
359
- }
360
- _pressKey(key, executableType) {
361
- return __awaiter(this, void 0, void 0, function* () {
362
- const id = addRequestId();
363
- const parameters = getParamters(this.options);
364
- const result = yield request(id, executableType, [...parameters, key], this.options);
365
- if (executableType === NodePyATVExecutableType.atvscript &&
366
- (typeof result !== 'object' || result.result !== 'success')) {
367
- throw new Error(`Unable to parse pyatv response: ${JSON.stringify(result, null, ' ')}`);
368
- }
369
- removeRequestId(id);
370
- });
371
- }
372
- /**
373
- * Send a key press to the Apple TV
374
- *
375
- * ```typescript
376
- * await device.pressKey(NodePyATVKeys.home);
377
- * ```
378
- *
379
- * <br />
380
- *
381
- * ```javascript
382
- * await device.pressKey('home');
383
- * ```
384
- *
385
- * @param key
386
- * @category Control
387
- */
388
- pressKey(key) {
389
- return __awaiter(this, void 0, void 0, function* () {
390
- const internalKeyEntry = Object.entries(NodePyATVInternalKeys)
391
- .find(([k]) => key === k);
392
- if (!internalKeyEntry) {
393
- throw new Error(`Unsupported key value ${key}!`);
394
- }
395
- const internalKey = internalKeyEntry[1];
396
- const executableType = [NodePyATVKeys.turnOn, NodePyATVKeys.turnOff].includes(key) ?
397
- NodePyATVExecutableType.atvremote :
398
- NodePyATVExecutableType.atvscript;
399
- yield this._pressKey(internalKey, executableType);
400
- });
401
- }
402
- /**
403
- * Send the "down" command
404
- * @category Control
405
- */
406
- down() {
407
- return __awaiter(this, void 0, void 0, function* () {
408
- yield this._pressKey(NodePyATVInternalKeys.down, NodePyATVExecutableType.atvscript);
409
- });
410
- }
411
- /**
412
- * Send the "home" command
413
- * @category Control
414
- */
415
- home() {
416
- return __awaiter(this, void 0, void 0, function* () {
417
- yield this._pressKey(NodePyATVInternalKeys.home, NodePyATVExecutableType.atvscript);
418
- });
419
- }
420
- /**
421
- * Send the "homeHold" command
422
- * @category Control
423
- */
424
- homeHold() {
425
- return __awaiter(this, void 0, void 0, function* () {
426
- yield this._pressKey(NodePyATVInternalKeys.homeHold, NodePyATVExecutableType.atvscript);
427
- });
428
- }
429
- /**
430
- * Send the "left" command
431
- * @category Control
432
- */
433
- left() {
434
- return __awaiter(this, void 0, void 0, function* () {
435
- yield this._pressKey(NodePyATVInternalKeys.left, NodePyATVExecutableType.atvscript);
436
- });
437
- }
438
- /**
439
- * Send the "menu" command
440
- * @category Control
441
- */
442
- menu() {
443
- return __awaiter(this, void 0, void 0, function* () {
444
- yield this._pressKey(NodePyATVInternalKeys.menu, NodePyATVExecutableType.atvscript);
445
- });
446
- }
447
- /**
448
- * Send the "next" command
449
- * @category Control
450
- */
451
- next() {
452
- return __awaiter(this, void 0, void 0, function* () {
453
- yield this._pressKey(NodePyATVInternalKeys.next, NodePyATVExecutableType.atvscript);
454
- });
455
- }
456
- /**
457
- * Send the "pause" command
458
- * @category Control
459
- */
460
- pause() {
461
- return __awaiter(this, void 0, void 0, function* () {
462
- yield this._pressKey(NodePyATVInternalKeys.pause, NodePyATVExecutableType.atvscript);
463
- });
464
- }
465
- /**
466
- * Send the "play" command
467
- * @category Control
468
- */
469
- play() {
470
- return __awaiter(this, void 0, void 0, function* () {
471
- yield this._pressKey(NodePyATVInternalKeys.play, NodePyATVExecutableType.atvscript);
472
- });
473
- }
474
- /**
475
- * Send the "playPause" command
476
- * @category Control
477
- */
478
- playPause() {
479
- return __awaiter(this, void 0, void 0, function* () {
480
- yield this._pressKey(NodePyATVInternalKeys.playPause, NodePyATVExecutableType.atvscript);
481
- });
482
- }
483
- /**
484
- * Send the "previous" command
485
- * @category Control
486
- */
487
- previous() {
488
- return __awaiter(this, void 0, void 0, function* () {
489
- yield this._pressKey(NodePyATVInternalKeys.previous, NodePyATVExecutableType.atvscript);
490
- });
491
- }
492
- /**
493
- * Send the "right" command
494
- * @category Control
495
- */
496
- right() {
497
- return __awaiter(this, void 0, void 0, function* () {
498
- yield this._pressKey(NodePyATVInternalKeys.right, NodePyATVExecutableType.atvscript);
499
- });
500
- }
501
- /**
502
- * Send the "select" command
503
- * @category Control
504
- */
505
- select() {
506
- return __awaiter(this, void 0, void 0, function* () {
507
- yield this._pressKey(NodePyATVInternalKeys.select, NodePyATVExecutableType.atvscript);
508
- });
509
- }
510
- /**
511
- * Send the "skipBackward" command
512
- * @category Control
513
- */
514
- skipBackward() {
515
- return __awaiter(this, void 0, void 0, function* () {
516
- yield this._pressKey(NodePyATVInternalKeys.skipBackward, NodePyATVExecutableType.atvscript);
517
- });
518
- }
519
- /**
520
- * Send the "skipForward" command
521
- * @category Control
522
- */
523
- skipForward() {
524
- return __awaiter(this, void 0, void 0, function* () {
525
- yield this._pressKey(NodePyATVInternalKeys.skipForward, NodePyATVExecutableType.atvscript);
526
- });
527
- }
528
- /**
529
- * Send the "stop" command
530
- * @category Control
531
- */
532
- stop() {
533
- return __awaiter(this, void 0, void 0, function* () {
534
- yield this._pressKey(NodePyATVInternalKeys.stop, NodePyATVExecutableType.atvscript);
535
- });
536
- }
537
- /**
538
- * Send the "suspend" command
539
- * @category Control
540
- * @deprecated
541
- */
542
- suspend() {
543
- return __awaiter(this, void 0, void 0, function* () {
544
- yield this._pressKey(NodePyATVInternalKeys.suspend, NodePyATVExecutableType.atvscript);
545
- });
546
- }
547
- /**
548
- * Send the "topMenu" command
549
- * @category Control
550
- */
551
- topMenu() {
552
- return __awaiter(this, void 0, void 0, function* () {
553
- yield this._pressKey(NodePyATVInternalKeys.topMenu, NodePyATVExecutableType.atvscript);
554
- });
555
- }
556
- /**
557
- * Send the "up" command
558
- * @category Control
559
- */
560
- up() {
561
- return __awaiter(this, void 0, void 0, function* () {
562
- yield this._pressKey(NodePyATVInternalKeys.up, NodePyATVExecutableType.atvscript);
563
- });
564
- }
565
- /**
566
- * Send the "volumeDown" command
567
- * @category Control
568
- */
569
- volumeDown() {
570
- return __awaiter(this, void 0, void 0, function* () {
571
- yield this._pressKey(NodePyATVInternalKeys.volumeDown, NodePyATVExecutableType.atvscript);
572
- });
573
- }
574
- /**
575
- * Send the "volumeUp" command
576
- * @category Control
577
- */
578
- volumeUp() {
579
- return __awaiter(this, void 0, void 0, function* () {
580
- yield this._pressKey(NodePyATVInternalKeys.volumeUp, NodePyATVExecutableType.atvscript);
581
- });
582
- }
583
- /**
584
- * Send the "wakeup" command
585
- * @category Control
586
- * @deprecated
587
- */
588
- wakeup() {
589
- return __awaiter(this, void 0, void 0, function* () {
590
- yield this._pressKey(NodePyATVInternalKeys.wakeup, NodePyATVExecutableType.atvscript);
591
- });
592
- }
593
- /**
594
- * Send the "turn_off" command
595
- * @category Control
596
- */
597
- turnOff() {
598
- return __awaiter(this, void 0, void 0, function* () {
599
- yield this._pressKey(NodePyATVInternalKeys.turnOff, NodePyATVExecutableType.atvremote);
600
- });
601
- }
602
- /**
603
- * Send the "turn_on" command
604
- * @category Control
605
- */
606
- turnOn() {
607
- return __awaiter(this, void 0, void 0, function* () {
608
- yield this._pressKey(NodePyATVInternalKeys.turnOn, NodePyATVExecutableType.atvremote);
609
- });
610
- }
611
- /**
612
- * Add an event listener. Will start the event subscription with the
613
- * Apple TV as long as there are listeners for any event registered.
614
- * @param event
615
- * @param listener
616
- * @category Event
617
- */
618
- addListener(event, listener) {
619
- this.events.addListener(event, listener);
620
- return this;
621
- }
622
- /**
623
- * Emit an event.
624
- * @param event
625
- * @param payload
626
- * @category Event
627
- */
628
- emit(event, payload) {
629
- return this.events.emit(event, payload);
630
- }
631
- /**
632
- * Get all event names which are currently known.
633
- * @category Event
634
- */
635
- eventNames() {
636
- return this.events.eventNames();
637
- }
638
- /**
639
- * Get max number of listeners allowed
640
- * @category Event
641
- */
642
- getMaxListeners() {
643
- return this.events.getMaxListeners();
644
- }
645
- /**
646
- * Get number of listeners for event
647
- * @param event
648
- * @category Event
649
- */
650
- listenerCount(event) {
651
- return this.events.listenerCount(event);
652
- }
653
- /**
654
- * Get listeners for event. Will also return
655
- * node-pyatv wrappers (e.g. once)
656
- *
657
- * @param event
658
- * @category Event
659
- */
660
- // eslint-disable-next-line @typescript-eslint/ban-types
661
- listeners(event) {
662
- return this.events.listeners(event);
663
- }
664
- /**
665
- * Remove an event listener. Will stop the event subscription with the
666
- * Apple TV if this was the last event listener.
667
- * @param event
668
- * @param listener
669
- * @category Event
670
- */
671
- off(event, listener) {
672
- this.events.off(event, listener);
673
- return this;
674
- }
675
- /**
676
- * Add an event listener. Will start the event subscription with the
677
- * Apple TV as long as there are listeners for any event registered.
678
- * @param event
679
- * @param listener
680
- * @category Event
681
- */
682
- on(event, listener) {
683
- this.events.on(event, listener);
684
- return this;
685
- }
686
- /**
687
- * Add an event listener. Will start the event subscription with the
688
- * Apple TV as long as there are listeners for any event registered.
689
- * Removes the listener automatically after the first occurrence.
690
- * @param event
691
- * @param listener
692
- * @category Event
693
- */
694
- once(event, listener) {
695
- this.events.once(event, listener);
696
- return this;
697
- }
698
- /**
699
- * @param event
700
- * @param listener
701
- * @category Event
702
- */
703
- prependListener(event, listener) {
704
- this.events.prependListener(event, listener);
705
- return this;
706
- }
707
- /**
708
- * @param event
709
- * @param listener
710
- * @category Event
711
- */
712
- prependOnceListener(event, listener) {
713
- this.events.prependOnceListener(event, listener);
714
- return this;
715
- }
716
- /**
717
- * @param event
718
- * @category Event
719
- */
720
- // eslint-disable-next-line @typescript-eslint/ban-types
721
- rawListeners(event) {
722
- return this.events.rawListeners(event);
723
- }
724
- /**
725
- * Removes all listeners, either for the given event or
726
- * for every event. Will stop the event subscription with
727
- * the Apple TV if this was the last event listener.
728
- *
729
- * @param event
730
- * @category Event
731
- */
732
- removeAllListeners(event) {
733
- this.events.removeAllListeners(event);
734
- return this;
735
- }
736
- /**
737
- * Remove an event listener. Will stop the event subscription with the
738
- * Apple TV if this was the last event listener.
739
- * @param event
740
- * @param listener
741
- * @category Event
742
- */
743
- removeListener(event, listener) {
744
- this.events.removeListener(event, listener);
745
- return this;
746
- }
747
- /**
748
- * @param n
749
- * @category Event
750
- */
751
- setMaxListeners(n) {
752
- this.events.setMaxListeners(n);
753
- return this;
754
- }
755
- }
756
- //# sourceMappingURL=device.js.map