@sebbo2002/node-pyatv 4.2.0-develop.2 → 4.3.0-develop.1

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 (44) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +1 -1
  3. package/dist/lib/device.d.ts +12 -0
  4. package/dist/lib/device.js +24 -3
  5. package/dist/lib/device.js.map +1 -1
  6. package/dist/lib/types.d.ts +3 -1
  7. package/dist/lib/types.js +2 -0
  8. package/dist/lib/types.js.map +1 -1
  9. package/docs/coverage/cobertura-coverage.xml +198 -184
  10. package/docs/coverage/device-event.ts.html +1 -1
  11. package/docs/coverage/device-events.ts.html +1 -1
  12. package/docs/coverage/device.ts.html +83 -17
  13. package/docs/coverage/fake-spawn.ts.html +1 -1
  14. package/docs/coverage/index.html +21 -21
  15. package/docs/coverage/index.ts.html +1 -1
  16. package/docs/coverage/instance.ts.html +1 -1
  17. package/docs/coverage/tools.ts.html +3 -3
  18. package/docs/coverage/types.ts.html +11 -5
  19. package/docs/reference/assets/search.js +1 -1
  20. package/docs/reference/classes/NodePyATVDevice.html +63 -59
  21. package/docs/reference/classes/NodePyATVDeviceEvent.html +5 -5
  22. package/docs/reference/classes/default.html +10 -10
  23. package/docs/reference/enums/NodePyATVDeviceState.html +1 -1
  24. package/docs/reference/enums/NodePyATVKeys.html +1 -1
  25. package/docs/reference/enums/NodePyATVListenerState.html +1 -1
  26. package/docs/reference/enums/NodePyATVMediaType.html +1 -1
  27. package/docs/reference/enums/NodePyATVPowerState.html +1 -1
  28. package/docs/reference/enums/NodePyATVProtocol.html +1 -1
  29. package/docs/reference/enums/NodePyATVRepeatState.html +1 -1
  30. package/docs/reference/enums/NodePyATVShuffleState.html +1 -1
  31. package/docs/reference/index.html +1 -1
  32. package/docs/reference/interfaces/NodePyATVDeviceOptions.html +1 -1
  33. package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +1 -1
  34. package/docs/reference/interfaces/NodePyATVFindOptions.html +1 -1
  35. package/docs/reference/interfaces/NodePyATVGetStateOptions.html +1 -1
  36. package/docs/reference/interfaces/NodePyATVInstanceOptions.html +1 -1
  37. package/docs/reference/interfaces/NodePyATVState.html +1 -1
  38. package/docs/reference/interfaces/NodePyATVVersionResponse.html +1 -1
  39. package/docs/reference/modules.html +1 -1
  40. package/docs/tests/index.html +1 -1
  41. package/docs/tests/mochawesome.json +608 -608
  42. package/package.json +11 -11
  43. package/src/lib/device.ts +28 -6
  44. package/src/lib/types.ts +3 -1
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "author": "Sebastian Pekarek <sheeboothohmoolaiquu@e.sebbo.net>",
2
+ "author": "Sebastian Pekarek <mail@sebbo.net>",
3
3
  "bugs": {
4
4
  "email": "sheeboothohmoolaiquu@e.sebbo.net",
5
5
  "url": "http://github.com/sebbo2002/node-pyatv/issues"
@@ -12,25 +12,25 @@
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.2",
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": "^16.11.9",
18
+ "@types/node": "^17.0.8",
19
19
  "@types/semver": "^7.3.9",
20
- "@typescript-eslint/eslint-plugin": "^5.4.0",
21
- "@typescript-eslint/parser": "^5.4.0",
22
- "eslint": "^8.3.0",
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.3",
25
+ "mocha": "^9.1.4",
26
26
  "mochawesome": "^7.0.1",
27
27
  "nyc": "^15.1.0",
28
- "semantic-release": "^18.0.0",
28
+ "semantic-release": "^18.0.1",
29
29
  "semantic-release-license": "^1.0.3",
30
30
  "source-map-support": "^0.5.21",
31
31
  "ts-node": "^10.4.0",
32
- "typedoc": "^0.22.9",
33
- "typescript": "^4.5.2"
32
+ "typedoc": "^0.22.10",
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.2.0-develop.2"
58
+ "version": "4.3.0-develop.1"
59
59
  }
package/src/lib/device.ts CHANGED
@@ -5,7 +5,8 @@ import {
5
5
  NodePyATVDeviceState,
6
6
  NodePyATVExecutableType,
7
7
  NodePyATVGetStateOptions,
8
- NodePyATVInternalKeys, NodePyATVKeys,
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 {NodePyATVDeviceEvents, NodePyATVDeviceEvent} from '../lib';
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.atvscript) {
319
320
  const id = addRequestId();
320
321
  const parameters = getParamters(this.options);
321
322
 
322
- const result = await request(id, NodePyATVExecutableType.atvscript, [...parameters, key], this.options);
323
- if (typeof result !== 'object' || result.result !== 'success') {
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
 
@@ -478,6 +482,7 @@ export default class NodePyATVDevice implements EventEmitter{
478
482
  /**
479
483
  * Send the "suspend" command
480
484
  * @category Control
485
+ * @deprecated
481
486
  */
482
487
  async suspend(): Promise<void> {
483
488
  await this._pressKey(NodePyATVInternalKeys.suspend);
@@ -518,11 +523,28 @@ export default class NodePyATVDevice implements EventEmitter{
518
523
  /**
519
524
  * Send the "wakeup" command
520
525
  * @category Control
526
+ * @deprecated
521
527
  */
522
528
  async wakeup(): Promise<void> {
523
529
  await this._pressKey(NodePyATVInternalKeys.wakeup);
524
530
  }
525
531
 
532
+ /**
533
+ * Send the "turn_off" command
534
+ * @category Control
535
+ */
536
+ async turnOff(): Promise<void> {
537
+ await this._pressKey(NodePyATVInternalKeys.turnOff, NodePyATVExecutableType.atvremote);
538
+ }
539
+
540
+ /**
541
+ * Send the "turn_on" command
542
+ * @category Control
543
+ */
544
+ async turnOn(): Promise<void> {
545
+ await this._pressKey(NodePyATVInternalKeys.turnOn, NodePyATVExecutableType.atvremote);
546
+ }
547
+
526
548
  /**
527
549
  * Add an event listener. Will start the event subscription with the
528
550
  * Apple TV as long as there are listeners for any event registered.
package/src/lib/types.ts CHANGED
@@ -94,7 +94,9 @@ export enum NodePyATVInternalKeys {
94
94
  up = 'up',
95
95
  volumeDown = 'volume_down',
96
96
  volumeUp = 'volume_up',
97
- wakeup = 'wakeup'
97
+ wakeup = 'wakeup',
98
+ turnOff = 'turn_off',
99
+ turnOn = 'turn_on'
98
100
  }
99
101
 
100
102
  export enum NodePyATVListenerState {