@sebbo2002/node-pyatv 5.1.2-develop.3 → 6.0.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/CHANGELOG.md +19 -0
- package/LICENSE +1 -1
- package/dist/lib/device-events.d.ts +1 -1
- package/dist/lib/device-events.js +3 -0
- package/dist/lib/device-events.js.map +1 -1
- package/dist/lib/device.d.ts +13 -2
- package/dist/lib/device.js +37 -0
- package/dist/lib/device.js.map +1 -1
- package/dist/lib/fake-spawn.d.ts +3 -3
- package/dist/lib/tools.d.ts +2 -2
- package/dist/lib/types.d.ts +7 -2
- package/docs/coverage/cobertura-coverage.xml +846 -783
- package/docs/coverage/device-event.ts.html +1 -1
- package/docs/coverage/device-events.ts.html +24 -15
- package/docs/coverage/device.ts.html +138 -21
- package/docs/coverage/fake-spawn.ts.html +40 -40
- package/docs/coverage/index.html +28 -28
- package/docs/coverage/index.ts.html +1 -1
- package/docs/coverage/instance.ts.html +1 -1
- package/docs/coverage/tools.ts.html +251 -251
- package/docs/coverage/types.ts.html +23 -5
- package/docs/reference/assets/main.js +56 -52
- package/docs/reference/assets/search.js +1 -1
- package/docs/reference/assets/style.css +23 -0
- package/docs/reference/classes/NodePyATVDevice.html +112 -74
- package/docs/reference/classes/NodePyATVDeviceEvent.html +10 -10
- package/docs/reference/classes/NodePyATVInstance.html +14 -14
- package/docs/reference/enums/NodePyATVDeviceState.html +11 -11
- package/docs/reference/enums/NodePyATVExecutableType.html +7 -7
- package/docs/reference/enums/NodePyATVKeys.html +28 -28
- package/docs/reference/enums/NodePyATVListenerState.html +9 -9
- package/docs/reference/enums/NodePyATVMediaType.html +9 -9
- package/docs/reference/enums/NodePyATVPowerState.html +7 -7
- package/docs/reference/enums/NodePyATVProtocol.html +9 -9
- package/docs/reference/enums/NodePyATVRepeatState.html +8 -8
- package/docs/reference/enums/NodePyATVShuffleState.html +8 -8
- package/docs/reference/index.html +5 -5
- package/docs/reference/interfaces/NodePyATVDeviceOptions.html +27 -27
- package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +21 -21
- package/docs/reference/interfaces/NodePyATVFindOptions.html +14 -14
- package/docs/reference/interfaces/NodePyATVGetStateOptions.html +6 -6
- package/docs/reference/interfaces/NodePyATVInstanceOptions.html +12 -12
- package/docs/reference/interfaces/NodePyATVService.html +7 -7
- package/docs/reference/interfaces/NodePyATVState.html +20 -20
- package/docs/reference/interfaces/NodePyATVVersionResponse.html +7 -7
- package/docs/reference/modules.html +4 -4
- package/docs/reference/types/NodePyATVEventValueType.html +5 -5
- package/docs/tests/index.html +1 -1
- package/docs/tests/mochawesome.json +740 -662
- package/package.json +14 -14
- package/release.config.cjs +1 -6
- package/src/lib/device-events.ts +3 -0
- package/src/lib/device.ts +40 -1
- package/src/lib/tools.ts +1 -1
- package/src/lib/types.ts +7 -1
- package/test/device.ts +42 -0
- package/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -9,32 +9,32 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "A lightweight wrapper around pyatv…",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.3",
|
|
12
|
+
"@qiwi/semantic-release-gh-pages-plugin": "^5.2.5",
|
|
14
13
|
"@semantic-release/changelog": "^6.0.2",
|
|
15
14
|
"@semantic-release/exec": "^6.0.3",
|
|
16
15
|
"@semantic-release/git": "^10.0.1",
|
|
16
|
+
"@semantic-release/npm": "^9.0.2",
|
|
17
17
|
"@types/mocha": "^10.0.1",
|
|
18
|
-
"@types/node": "^18.
|
|
18
|
+
"@types/node": "^18.15.3",
|
|
19
19
|
"@types/semver": "^7.3.13",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
21
|
-
"@typescript-eslint/parser": "^5.
|
|
22
|
-
"c8": "^7.
|
|
23
|
-
"eslint": "^8.
|
|
24
|
-
"eslint-plugin-jsonc": "^2.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
21
|
+
"@typescript-eslint/parser": "^5.54.1",
|
|
22
|
+
"c8": "^7.13.0",
|
|
23
|
+
"eslint": "^8.35.0",
|
|
24
|
+
"eslint-plugin-jsonc": "^2.6.0",
|
|
25
25
|
"esm": "^3.2.25",
|
|
26
26
|
"license-checker": "^25.0.1",
|
|
27
|
-
"mocha": "^10.
|
|
27
|
+
"mocha": "^10.2.0",
|
|
28
28
|
"mochawesome": "^7.1.3",
|
|
29
|
-
"semantic-release": "^
|
|
29
|
+
"semantic-release": "^20.1.1",
|
|
30
30
|
"semantic-release-license": "^1.0.3",
|
|
31
31
|
"source-map-support": "^0.5.21",
|
|
32
32
|
"ts-node": "^10.9.1",
|
|
33
|
-
"typedoc": "^0.23.
|
|
34
|
-
"typescript": "^4.9.
|
|
33
|
+
"typedoc": "^0.23.26",
|
|
34
|
+
"typescript": "^4.9.5"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": "^
|
|
37
|
+
"node": "^14.8.0 || >=16.0.0"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/sebbo2002/js-template#readme",
|
|
40
40
|
"license": "MIT",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"test": "mocha"
|
|
59
59
|
},
|
|
60
60
|
"type": "module",
|
|
61
|
-
"version": "
|
|
61
|
+
"version": "6.0.0-develop.2"
|
|
62
62
|
}
|
package/release.config.cjs
CHANGED
|
@@ -25,12 +25,7 @@ configuration.plugins.push('@semantic-release/changelog');
|
|
|
25
25
|
|
|
26
26
|
configuration.plugins.push('semantic-release-license');
|
|
27
27
|
|
|
28
|
-
configuration.plugins.push(
|
|
29
|
-
'registries': {
|
|
30
|
-
'github': {},
|
|
31
|
-
'public': {}
|
|
32
|
-
}
|
|
33
|
-
}]);
|
|
28
|
+
configuration.plugins.push('@semantic-release/npm');
|
|
34
29
|
|
|
35
30
|
configuration.plugins.push(['@semantic-release/exec', {
|
|
36
31
|
'prepareCmd': './.github/workflows/build.sh'
|
package/src/lib/device-events.ts
CHANGED
|
@@ -134,6 +134,9 @@ export default class NodePyATVDeviceEvents extends EventEmitter {
|
|
|
134
134
|
const listenStart = new Date().getTime();
|
|
135
135
|
const parameters = getParamters(this.options);
|
|
136
136
|
this.pyatv = execute(reqId, NodePyATVExecutableType.atvscript, [...parameters, 'push_updates'], this.options);
|
|
137
|
+
if(!this.pyatv) {
|
|
138
|
+
throw new Error('Unable to start listener: Unable to start atvscript');
|
|
139
|
+
}
|
|
137
140
|
|
|
138
141
|
const onError = (error: Error) => {
|
|
139
142
|
debug(reqId, `Got error from child process: ${error}`, this.options);
|
package/src/lib/device.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
NodePyATVApp,
|
|
4
5
|
NodePyATVDeviceOptions,
|
|
5
6
|
NodePyATVDeviceState,
|
|
6
7
|
NodePyATVExecutableType,
|
|
@@ -378,7 +379,36 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
378
379
|
return state.appId;
|
|
379
380
|
}
|
|
380
381
|
|
|
381
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Returns the list of installed apps on the Apple TV. Probably requires `companionCredentials`,
|
|
384
|
+
* see https://pyatv.dev/documentation/atvremote/#apps for more details.
|
|
385
|
+
*/
|
|
386
|
+
async listApps(): Promise<NodePyATVApp[]> {
|
|
387
|
+
const id = addRequestId();
|
|
388
|
+
const parameters = getParamters(this.options);
|
|
389
|
+
|
|
390
|
+
const result = await request(id, NodePyATVExecutableType.atvremote, [...parameters, 'app_list'], this.options);
|
|
391
|
+
if(typeof result !== 'string' || !result.startsWith('App: ')) {
|
|
392
|
+
throw new Error('Unexpected atvremote response: ' + result);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
removeRequestId(id);
|
|
396
|
+
const regex = /(.+) \(([^\)]+)\)$/i;
|
|
397
|
+
const items = result.substring(5, ).split(', App: ').map(i => {
|
|
398
|
+
const m = i.match(regex);
|
|
399
|
+
if (m !== null) {
|
|
400
|
+
return {
|
|
401
|
+
id: m[2],
|
|
402
|
+
name: m[1],
|
|
403
|
+
launch: () => this.launchApp(m[2])
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}) as Array<NodePyATVApp | undefined>;
|
|
407
|
+
|
|
408
|
+
return items.filter(Boolean) as NodePyATVApp[];
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private async _pressKey(key: NodePyATVInternalKeys | string, executableType: NodePyATVExecutableType) {
|
|
382
412
|
const id = addRequestId();
|
|
383
413
|
const parameters = getParamters(this.options);
|
|
384
414
|
|
|
@@ -611,6 +641,15 @@ export default class NodePyATVDevice implements EventEmitter{
|
|
|
611
641
|
await this._pressKey(NodePyATVInternalKeys.turnOn, NodePyATVExecutableType.atvremote);
|
|
612
642
|
}
|
|
613
643
|
|
|
644
|
+
/**
|
|
645
|
+
* Launch an application. Probably requires `companionCredentials`, see
|
|
646
|
+
* https://pyatv.dev/documentation/atvremote/#apps for more details.
|
|
647
|
+
* @param id App identifier, e.g. `com.netflix.Netflix`
|
|
648
|
+
*/
|
|
649
|
+
async launchApp(id: string): Promise<void> {
|
|
650
|
+
await this._pressKey('launch_app=' + id, NodePyATVExecutableType.atvremote);
|
|
651
|
+
}
|
|
652
|
+
|
|
614
653
|
/**
|
|
615
654
|
* Add an event listener. Will start the event subscription with the
|
|
616
655
|
* Apple TV as long as there are listeners for any event registered.
|
package/src/lib/tools.ts
CHANGED
package/src/lib/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ChildProcess, SpawnOptions} from 'child_process';
|
|
2
|
-
import {FakeChildProcess} from './fake-spawn';
|
|
2
|
+
import {FakeChildProcess} from './fake-spawn.js';
|
|
3
3
|
|
|
4
4
|
export enum NodePyATVExecutableType {
|
|
5
5
|
atvremote = 'atvremote',
|
|
@@ -222,3 +222,9 @@ export interface NodePyATVState {
|
|
|
222
222
|
appId: string | null,
|
|
223
223
|
powerState: NodePyATVPowerState | null
|
|
224
224
|
}
|
|
225
|
+
|
|
226
|
+
export interface NodePyATVApp {
|
|
227
|
+
id: string;
|
|
228
|
+
name: string;
|
|
229
|
+
launch: () => Promise<void>;
|
|
230
|
+
}
|
package/test/device.ts
CHANGED
|
@@ -726,6 +726,35 @@ describe('NodePyATVDevice', function () {
|
|
|
726
726
|
});
|
|
727
727
|
});
|
|
728
728
|
|
|
729
|
+
describe('listApps()', function () {
|
|
730
|
+
it('should work', async function () {
|
|
731
|
+
const device = new NodePyATVDevice({
|
|
732
|
+
name: 'My Testdevice',
|
|
733
|
+
host: '192.168.178.2',
|
|
734
|
+
spawn: createFakeSpawn(cp => {
|
|
735
|
+
cp.end(
|
|
736
|
+
'App: Fitness (com.apple.Fitness), App: Podcasts (com.apple.podcasts), ' +
|
|
737
|
+
'App: Filme (com.apple.TVMovies), App: Prime Video (com.amazon.aiv.AIVApp), ' +
|
|
738
|
+
'App: TV (com.apple.TVWatchList), App: Fotos (com.apple.TVPhotos), App: App Store ' +
|
|
739
|
+
'(com.apple.TVAppStore), App: Arcade (com.apple.Arcade), App: TV-Sendungen (com.apple.TVShows), ' +
|
|
740
|
+
'App: Suchen (com.apple.TVSearch), App: Live TV (de.couchfunk.WM2014), App: RTL+ ' +
|
|
741
|
+
'(com.rtlinteractive.tvnow), App: Computer (com.apple.TVHomeSharing), App: ARTE ' +
|
|
742
|
+
'(tv.arte.plus7), App: YouTube (com.google.ios.youtube), App: ARD Mediathek ' +
|
|
743
|
+
'(de.swr.avp.ard.tablet), App: Disney+ (com.disney.disneyplus), App: Plex (com.plexapp.plex), ' +
|
|
744
|
+
'App: Joyn (de.prosiebensat1digital.seventv), App: Einstellungen (com.apple.TVSettings), ' +
|
|
745
|
+
'App: ZDFmediathek (de.zdf.mediathek.universal), App: Crossy Road (com.hipsterwhale.crossy), ' +
|
|
746
|
+
'App: Netflix (com.netflix.Netflix), App: Infuse (com.firecore.infuse), ' +
|
|
747
|
+
'App: Musik (com.apple.TVMusic)');
|
|
748
|
+
})
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
const result = await device.listApps();
|
|
752
|
+
assert.strictEqual(result.length, 25);
|
|
753
|
+
assert.strictEqual(result[0].id, 'com.apple.Fitness');
|
|
754
|
+
assert.strictEqual(result[0].name, 'Fitness');
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
|
|
729
758
|
describe('pressKey()', function () {
|
|
730
759
|
it('should work with valid key', async function () {
|
|
731
760
|
const device = new NodePyATVDevice({
|
|
@@ -781,4 +810,17 @@ describe('NodePyATVDevice', function () {
|
|
|
781
810
|
});
|
|
782
811
|
});
|
|
783
812
|
|
|
813
|
+
describe('launchApp()', function () {
|
|
814
|
+
it('should work', async function () {
|
|
815
|
+
const device = new NodePyATVDevice({
|
|
816
|
+
name: 'My Testdevice',
|
|
817
|
+
host: '192.168.178.2',
|
|
818
|
+
spawn: createFakeSpawn(cp => {
|
|
819
|
+
cp.end('');
|
|
820
|
+
})
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
await device.launchApp('com.apple.TVShows');
|
|
824
|
+
});
|
|
825
|
+
});
|
|
784
826
|
});
|