@sebbo2002/node-pyatv 4.2.1-develop.1 → 4.3.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.
- package/CHANGELOG.md +28 -0
- package/LICENSE +1 -1
- package/dist/lib/device.d.ts +12 -0
- package/dist/lib/device.js +49 -25
- package/dist/lib/device.js.map +1 -1
- package/dist/lib/types.d.ts +6 -2
- package/dist/lib/types.js +4 -0
- package/dist/lib/types.js.map +1 -1
- package/docs/coverage/cobertura-coverage.xml +370 -353
- package/docs/coverage/device-event.ts.html +1 -1
- package/docs/coverage/device-events.ts.html +6 -6
- package/docs/coverage/device.ts.html +125 -47
- package/docs/coverage/fake-spawn.ts.html +22 -22
- package/docs/coverage/index.html +20 -20
- package/docs/coverage/index.ts.html +2 -2
- package/docs/coverage/instance.ts.html +1 -1
- package/docs/coverage/tools.ts.html +102 -102
- package/docs/coverage/types.ts.html +18 -6
- package/docs/reference/assets/search.js +1 -1
- package/docs/reference/classes/NodePyATVDevice.html +63 -59
- package/docs/reference/classes/NodePyATVDeviceEvent.html +5 -5
- package/docs/reference/classes/default.html +10 -10
- package/docs/reference/enums/NodePyATVDeviceState.html +1 -1
- package/docs/reference/enums/NodePyATVKeys.html +1 -1
- package/docs/reference/enums/NodePyATVListenerState.html +1 -1
- package/docs/reference/enums/NodePyATVMediaType.html +1 -1
- package/docs/reference/enums/NodePyATVPowerState.html +1 -1
- package/docs/reference/enums/NodePyATVProtocol.html +1 -1
- package/docs/reference/enums/NodePyATVRepeatState.html +1 -1
- package/docs/reference/enums/NodePyATVShuffleState.html +1 -1
- package/docs/reference/index.html +1 -1
- package/docs/reference/interfaces/NodePyATVDeviceOptions.html +1 -1
- package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +1 -1
- package/docs/reference/interfaces/NodePyATVFindOptions.html +1 -1
- package/docs/reference/interfaces/NodePyATVGetStateOptions.html +1 -1
- package/docs/reference/interfaces/NodePyATVInstanceOptions.html +1 -1
- package/docs/reference/interfaces/NodePyATVState.html +1 -1
- package/docs/reference/interfaces/NodePyATVVersionResponse.html +1 -1
- package/docs/reference/modules.html +1 -1
- package/docs/tests/index.html +1 -1
- package/docs/tests/mochawesome.json +675 -597
- package/package.json +8 -8
- package/src/lib/device.ts +54 -28
- package/src/lib/types.ts +6 -2
package/package.json
CHANGED
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"@amanda-mitchell/semantic-release-npm-multiple": "^2.15.0",
|
|
13
13
|
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.0",
|
|
14
14
|
"@semantic-release/changelog": "^6.0.1",
|
|
15
|
-
"@semantic-release/exec": "^6.0.
|
|
15
|
+
"@semantic-release/exec": "^6.0.3",
|
|
16
16
|
"@semantic-release/git": "^10.0.1",
|
|
17
17
|
"@types/mocha": "^9.0.0",
|
|
18
|
-
"@types/node": "^
|
|
18
|
+
"@types/node": "^17.0.8",
|
|
19
19
|
"@types/semver": "^7.3.9",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
21
|
-
"@typescript-eslint/parser": "^5.
|
|
22
|
-
"eslint": "^8.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
21
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
22
|
+
"eslint": "^8.7.0",
|
|
23
23
|
"eslint-plugin-jsonc": "^2.0.0",
|
|
24
24
|
"license-checker": "^25.0.1",
|
|
25
|
-
"mocha": "^9.1.
|
|
25
|
+
"mocha": "^9.1.4",
|
|
26
26
|
"mochawesome": "^7.0.1",
|
|
27
27
|
"nyc": "^15.1.0",
|
|
28
28
|
"semantic-release": "^18.0.1",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"source-map-support": "^0.5.21",
|
|
31
31
|
"ts-node": "^10.4.0",
|
|
32
32
|
"typedoc": "^0.22.10",
|
|
33
|
-
"typescript": "^4.5.
|
|
33
|
+
"typescript": "^4.5.4"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=12.0.0"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"postinstall": "./check.sh",
|
|
56
56
|
"test": "mocha"
|
|
57
57
|
},
|
|
58
|
-
"version": "4.
|
|
58
|
+
"version": "4.3.0-develop.3"
|
|
59
59
|
}
|
package/src/lib/device.ts
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
NodePyATVDeviceState,
|
|
6
6
|
NodePyATVExecutableType,
|
|
7
7
|
NodePyATVGetStateOptions,
|
|
8
|
-
NodePyATVInternalKeys,
|
|
8
|
+
NodePyATVInternalKeys,
|
|
9
|
+
NodePyATVKeys,
|
|
9
10
|
NodePyATVMediaType,
|
|
10
11
|
NodePyATVProtocol,
|
|
11
12
|
NodePyATVRepeatState,
|
|
@@ -13,8 +14,8 @@ import {
|
|
|
13
14
|
NodePyATVState
|
|
14
15
|
} from './types';
|
|
15
16
|
|
|
16
|
-
import {addRequestId, getParamters, parseState, removeRequestId, request} from './tools';
|
|
17
|
-
import {
|
|
17
|
+
import { addRequestId, getParamters, parseState, removeRequestId, request } from './tools';
|
|
18
|
+
import { NodePyATVDeviceEvent, NodePyATVDeviceEvents } from '../lib';
|
|
18
19
|
import { EventEmitter } from 'events';
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -315,12 +316,15 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
315
316
|
return state.appId;
|
|
316
317
|
}
|
|
317
318
|
|
|
318
|
-
private async _pressKey(key: NodePyATVInternalKeys) {
|
|
319
|
+
private async _pressKey(key: NodePyATVInternalKeys, executableType: NodePyATVExecutableType) {
|
|
319
320
|
const id = addRequestId();
|
|
320
321
|
const parameters = getParamters(this.options);
|
|
321
322
|
|
|
322
|
-
const result = await request(id,
|
|
323
|
-
if (
|
|
323
|
+
const result = await request(id, executableType, [...parameters, key], this.options);
|
|
324
|
+
if (
|
|
325
|
+
executableType === NodePyATVExecutableType.atvscript &&
|
|
326
|
+
(typeof result !== 'object' || result.result !== 'success')
|
|
327
|
+
) {
|
|
324
328
|
throw new Error(`Unable to parse pyatv response: ${JSON.stringify(result, null, ' ')}`);
|
|
325
329
|
}
|
|
326
330
|
|
|
@@ -352,7 +356,11 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
352
356
|
}
|
|
353
357
|
|
|
354
358
|
const internalKey = internalKeyEntry[1];
|
|
355
|
-
|
|
359
|
+
const executableType = [NodePyATVKeys.turnOn, NodePyATVKeys.turnOff].includes(key) ?
|
|
360
|
+
NodePyATVExecutableType.atvremote :
|
|
361
|
+
NodePyATVExecutableType.atvscript;
|
|
362
|
+
|
|
363
|
+
await this._pressKey(internalKey, executableType);
|
|
356
364
|
}
|
|
357
365
|
|
|
358
366
|
/**
|
|
@@ -360,7 +368,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
360
368
|
* @category Control
|
|
361
369
|
*/
|
|
362
370
|
async down(): Promise<void> {
|
|
363
|
-
await this._pressKey(NodePyATVInternalKeys.down);
|
|
371
|
+
await this._pressKey(NodePyATVInternalKeys.down, NodePyATVExecutableType.atvscript);
|
|
364
372
|
}
|
|
365
373
|
|
|
366
374
|
/**
|
|
@@ -368,7 +376,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
368
376
|
* @category Control
|
|
369
377
|
*/
|
|
370
378
|
async home(): Promise<void> {
|
|
371
|
-
await this._pressKey(NodePyATVInternalKeys.home);
|
|
379
|
+
await this._pressKey(NodePyATVInternalKeys.home, NodePyATVExecutableType.atvscript);
|
|
372
380
|
}
|
|
373
381
|
|
|
374
382
|
/**
|
|
@@ -376,7 +384,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
376
384
|
* @category Control
|
|
377
385
|
*/
|
|
378
386
|
async homeHold(): Promise<void> {
|
|
379
|
-
await this._pressKey(NodePyATVInternalKeys.homeHold);
|
|
387
|
+
await this._pressKey(NodePyATVInternalKeys.homeHold, NodePyATVExecutableType.atvscript);
|
|
380
388
|
}
|
|
381
389
|
|
|
382
390
|
/**
|
|
@@ -384,7 +392,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
384
392
|
* @category Control
|
|
385
393
|
*/
|
|
386
394
|
async left(): Promise<void> {
|
|
387
|
-
await this._pressKey(NodePyATVInternalKeys.left);
|
|
395
|
+
await this._pressKey(NodePyATVInternalKeys.left, NodePyATVExecutableType.atvscript);
|
|
388
396
|
}
|
|
389
397
|
|
|
390
398
|
/**
|
|
@@ -392,7 +400,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
392
400
|
* @category Control
|
|
393
401
|
*/
|
|
394
402
|
async menu(): Promise<void> {
|
|
395
|
-
await this._pressKey(NodePyATVInternalKeys.menu);
|
|
403
|
+
await this._pressKey(NodePyATVInternalKeys.menu, NodePyATVExecutableType.atvscript);
|
|
396
404
|
}
|
|
397
405
|
|
|
398
406
|
/**
|
|
@@ -400,7 +408,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
400
408
|
* @category Control
|
|
401
409
|
*/
|
|
402
410
|
async next(): Promise<void> {
|
|
403
|
-
await this._pressKey(NodePyATVInternalKeys.next);
|
|
411
|
+
await this._pressKey(NodePyATVInternalKeys.next, NodePyATVExecutableType.atvscript);
|
|
404
412
|
}
|
|
405
413
|
|
|
406
414
|
/**
|
|
@@ -408,7 +416,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
408
416
|
* @category Control
|
|
409
417
|
*/
|
|
410
418
|
async pause(): Promise<void> {
|
|
411
|
-
await this._pressKey(NodePyATVInternalKeys.pause);
|
|
419
|
+
await this._pressKey(NodePyATVInternalKeys.pause, NodePyATVExecutableType.atvscript);
|
|
412
420
|
}
|
|
413
421
|
|
|
414
422
|
/**
|
|
@@ -416,7 +424,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
416
424
|
* @category Control
|
|
417
425
|
*/
|
|
418
426
|
async play(): Promise<void> {
|
|
419
|
-
await this._pressKey(NodePyATVInternalKeys.play);
|
|
427
|
+
await this._pressKey(NodePyATVInternalKeys.play, NodePyATVExecutableType.atvscript);
|
|
420
428
|
}
|
|
421
429
|
|
|
422
430
|
/**
|
|
@@ -424,7 +432,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
424
432
|
* @category Control
|
|
425
433
|
*/
|
|
426
434
|
async playPause(): Promise<void> {
|
|
427
|
-
await this._pressKey(NodePyATVInternalKeys.playPause);
|
|
435
|
+
await this._pressKey(NodePyATVInternalKeys.playPause, NodePyATVExecutableType.atvscript);
|
|
428
436
|
}
|
|
429
437
|
|
|
430
438
|
/**
|
|
@@ -432,7 +440,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
432
440
|
* @category Control
|
|
433
441
|
*/
|
|
434
442
|
async previous(): Promise<void> {
|
|
435
|
-
await this._pressKey(NodePyATVInternalKeys.previous);
|
|
443
|
+
await this._pressKey(NodePyATVInternalKeys.previous, NodePyATVExecutableType.atvscript);
|
|
436
444
|
}
|
|
437
445
|
|
|
438
446
|
/**
|
|
@@ -440,7 +448,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
440
448
|
* @category Control
|
|
441
449
|
*/
|
|
442
450
|
async right(): Promise<void> {
|
|
443
|
-
await this._pressKey(NodePyATVInternalKeys.right);
|
|
451
|
+
await this._pressKey(NodePyATVInternalKeys.right, NodePyATVExecutableType.atvscript);
|
|
444
452
|
}
|
|
445
453
|
|
|
446
454
|
/**
|
|
@@ -448,7 +456,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
448
456
|
* @category Control
|
|
449
457
|
*/
|
|
450
458
|
async select(): Promise<void> {
|
|
451
|
-
await this._pressKey(NodePyATVInternalKeys.select);
|
|
459
|
+
await this._pressKey(NodePyATVInternalKeys.select, NodePyATVExecutableType.atvscript);
|
|
452
460
|
}
|
|
453
461
|
|
|
454
462
|
/**
|
|
@@ -456,7 +464,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
456
464
|
* @category Control
|
|
457
465
|
*/
|
|
458
466
|
async skipBackward(): Promise<void> {
|
|
459
|
-
await this._pressKey(NodePyATVInternalKeys.skipBackward);
|
|
467
|
+
await this._pressKey(NodePyATVInternalKeys.skipBackward, NodePyATVExecutableType.atvscript);
|
|
460
468
|
}
|
|
461
469
|
|
|
462
470
|
/**
|
|
@@ -464,7 +472,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
464
472
|
* @category Control
|
|
465
473
|
*/
|
|
466
474
|
async skipForward(): Promise<void> {
|
|
467
|
-
await this._pressKey(NodePyATVInternalKeys.skipForward);
|
|
475
|
+
await this._pressKey(NodePyATVInternalKeys.skipForward, NodePyATVExecutableType.atvscript);
|
|
468
476
|
}
|
|
469
477
|
|
|
470
478
|
/**
|
|
@@ -472,15 +480,16 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
472
480
|
* @category Control
|
|
473
481
|
*/
|
|
474
482
|
async stop(): Promise<void> {
|
|
475
|
-
await this._pressKey(NodePyATVInternalKeys.stop);
|
|
483
|
+
await this._pressKey(NodePyATVInternalKeys.stop, NodePyATVExecutableType.atvscript);
|
|
476
484
|
}
|
|
477
485
|
|
|
478
486
|
/**
|
|
479
487
|
* Send the "suspend" command
|
|
480
488
|
* @category Control
|
|
489
|
+
* @deprecated
|
|
481
490
|
*/
|
|
482
491
|
async suspend(): Promise<void> {
|
|
483
|
-
await this._pressKey(NodePyATVInternalKeys.suspend);
|
|
492
|
+
await this._pressKey(NodePyATVInternalKeys.suspend, NodePyATVExecutableType.atvscript);
|
|
484
493
|
}
|
|
485
494
|
|
|
486
495
|
/**
|
|
@@ -488,7 +497,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
488
497
|
* @category Control
|
|
489
498
|
*/
|
|
490
499
|
async topMenu(): Promise<void> {
|
|
491
|
-
await this._pressKey(NodePyATVInternalKeys.topMenu);
|
|
500
|
+
await this._pressKey(NodePyATVInternalKeys.topMenu, NodePyATVExecutableType.atvscript);
|
|
492
501
|
}
|
|
493
502
|
|
|
494
503
|
/**
|
|
@@ -496,7 +505,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
496
505
|
* @category Control
|
|
497
506
|
*/
|
|
498
507
|
async up(): Promise<void> {
|
|
499
|
-
await this._pressKey(NodePyATVInternalKeys.up);
|
|
508
|
+
await this._pressKey(NodePyATVInternalKeys.up, NodePyATVExecutableType.atvscript);
|
|
500
509
|
}
|
|
501
510
|
|
|
502
511
|
/**
|
|
@@ -504,7 +513,7 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
504
513
|
* @category Control
|
|
505
514
|
*/
|
|
506
515
|
async volumeDown(): Promise<void> {
|
|
507
|
-
await this._pressKey(NodePyATVInternalKeys.volumeDown);
|
|
516
|
+
await this._pressKey(NodePyATVInternalKeys.volumeDown, NodePyATVExecutableType.atvscript);
|
|
508
517
|
}
|
|
509
518
|
|
|
510
519
|
/**
|
|
@@ -512,15 +521,32 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
512
521
|
* @category Control
|
|
513
522
|
*/
|
|
514
523
|
async volumeUp(): Promise<void> {
|
|
515
|
-
await this._pressKey(NodePyATVInternalKeys.volumeUp);
|
|
524
|
+
await this._pressKey(NodePyATVInternalKeys.volumeUp, NodePyATVExecutableType.atvscript);
|
|
516
525
|
}
|
|
517
526
|
|
|
518
527
|
/**
|
|
519
528
|
* Send the "wakeup" command
|
|
520
529
|
* @category Control
|
|
530
|
+
* @deprecated
|
|
521
531
|
*/
|
|
522
532
|
async wakeup(): Promise<void> {
|
|
523
|
-
await this._pressKey(NodePyATVInternalKeys.wakeup);
|
|
533
|
+
await this._pressKey(NodePyATVInternalKeys.wakeup, NodePyATVExecutableType.atvscript);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Send the "turn_off" command
|
|
538
|
+
* @category Control
|
|
539
|
+
*/
|
|
540
|
+
async turnOff(): Promise<void> {
|
|
541
|
+
await this._pressKey(NodePyATVInternalKeys.turnOff, NodePyATVExecutableType.atvremote);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Send the "turn_on" command
|
|
546
|
+
* @category Control
|
|
547
|
+
*/
|
|
548
|
+
async turnOn(): Promise<void> {
|
|
549
|
+
await this._pressKey(NodePyATVInternalKeys.turnOn, NodePyATVExecutableType.atvremote);
|
|
524
550
|
}
|
|
525
551
|
|
|
526
552
|
/**
|
package/src/lib/types.ts
CHANGED
|
@@ -67,7 +67,9 @@ export enum NodePyATVKeys {
|
|
|
67
67
|
up = 'up',
|
|
68
68
|
volumeDown = 'volumeDown',
|
|
69
69
|
volumeUp = 'volumeUp',
|
|
70
|
-
wakeup = 'wakeup'
|
|
70
|
+
wakeup = 'wakeup',
|
|
71
|
+
turnOff = 'turnOff',
|
|
72
|
+
turnOn = 'turnOn'
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/**
|
|
@@ -94,7 +96,9 @@ export enum NodePyATVInternalKeys {
|
|
|
94
96
|
up = 'up',
|
|
95
97
|
volumeDown = 'volume_down',
|
|
96
98
|
volumeUp = 'volume_up',
|
|
97
|
-
wakeup = 'wakeup'
|
|
99
|
+
wakeup = 'wakeup',
|
|
100
|
+
turnOff = 'turn_off',
|
|
101
|
+
turnOn = 'turn_on'
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
export enum NodePyATVListenerState {
|