@sebbo2002/node-pyatv 6.0.0-develop.2 → 6.0.0
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/dist/bin/check.cjs +10 -0
- package/dist/bin/check.cjs.map +1 -0
- package/dist/bin/check.d.ts +2 -1
- package/dist/bin/check.js +4 -45
- package/dist/bin/check.js.map +1 -1
- package/dist/chunk-TZSWUAOB.js +7 -0
- package/dist/chunk-TZSWUAOB.js.map +1 -0
- package/dist/lib/index.cjs +7 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/{device.d.ts → index.d.cts} +340 -4
- package/dist/lib/index.d.ts +806 -6
- package/dist/lib/index.js +1 -7
- package/dist/lib/index.js.map +1 -1
- package/package.json +18 -9
- package/.editorconfig +0 -12
- package/.eslintignore +0 -4
- package/.eslintrc +0 -60
- package/.mocharc.yml +0 -7
- package/.nycrc +0 -32
- package/CHANGELOG.md +0 -295
- package/check.sh +0 -5
- package/dist/examples/push.d.ts +0 -1
- package/dist/examples/push.js +0 -51
- package/dist/examples/push.js.map +0 -1
- package/dist/lib/device-event.d.ts +0 -44
- package/dist/lib/device-event.js +0 -47
- package/dist/lib/device-event.js.map +0 -1
- package/dist/lib/device-events.d.ts +0 -30
- package/dist/lib/device-events.js +0 -237
- package/dist/lib/device-events.js.map +0 -1
- package/dist/lib/device.js +0 -793
- package/dist/lib/device.js.map +0 -1
- package/dist/lib/fake-spawn.d.ts +0 -43
- package/dist/lib/fake-spawn.js +0 -85
- package/dist/lib/fake-spawn.js.map +0 -1
- package/dist/lib/instance.d.ts +0 -97
- package/dist/lib/instance.js +0 -208
- package/dist/lib/instance.js.map +0 -1
- package/dist/lib/tools.d.ts +0 -12
- package/dist/lib/tools.js +0 -319
- package/dist/lib/tools.js.map +0 -1
- package/dist/lib/types.d.ts +0 -204
- package/dist/lib/types.js +0 -108
- package/dist/lib/types.js.map +0 -1
- package/docs/coverage/base.css +0 -224
- package/docs/coverage/block-navigation.js +0 -87
- package/docs/coverage/cobertura-coverage.xml +0 -2889
- package/docs/coverage/device-event.ts.html +0 -256
- package/docs/coverage/device-events.ts.html +0 -970
- package/docs/coverage/device.ts.html +0 -2518
- package/docs/coverage/fake-spawn.ts.html +0 -448
- package/docs/coverage/favicon.png +0 -0
- package/docs/coverage/index.html +0 -221
- package/docs/coverage/index.ts.html +0 -172
- package/docs/coverage/instance.ts.html +0 -718
- package/docs/coverage/prettify.css +0 -1
- package/docs/coverage/prettify.js +0 -2
- package/docs/coverage/sort-arrow-sprite.png +0 -0
- package/docs/coverage/sorter.js +0 -196
- package/docs/coverage/tools.ts.html +0 -1222
- package/docs/coverage/types.ts.html +0 -775
- package/docs/reference/.nojekyll +0 -1
- package/docs/reference/assets/highlight.css +0 -99
- package/docs/reference/assets/main.js +0 -58
- package/docs/reference/assets/search.js +0 -1
- package/docs/reference/assets/style.css +0 -1280
- package/docs/reference/classes/NodePyATVDevice.html +0 -1266
- package/docs/reference/classes/NodePyATVDeviceEvent.html +0 -123
- package/docs/reference/classes/NodePyATVInstance.html +0 -240
- package/docs/reference/enums/NodePyATVDeviceState.html +0 -97
- package/docs/reference/enums/NodePyATVExecutableType.html +0 -69
- package/docs/reference/enums/NodePyATVKeys.html +0 -216
- package/docs/reference/enums/NodePyATVListenerState.html +0 -83
- package/docs/reference/enums/NodePyATVMediaType.html +0 -83
- package/docs/reference/enums/NodePyATVPowerState.html +0 -69
- package/docs/reference/enums/NodePyATVProtocol.html +0 -83
- package/docs/reference/enums/NodePyATVRepeatState.html +0 -76
- package/docs/reference/enums/NodePyATVShuffleState.html +0 -76
- package/docs/reference/index.html +0 -139
- package/docs/reference/interfaces/NodePyATVDeviceOptions.html +0 -232
- package/docs/reference/interfaces/NodePyATVFindAndInstanceOptions.html +0 -193
- package/docs/reference/interfaces/NodePyATVFindOptions.html +0 -124
- package/docs/reference/interfaces/NodePyATVGetStateOptions.html +0 -66
- package/docs/reference/interfaces/NodePyATVInstanceOptions.html +0 -113
- package/docs/reference/interfaces/NodePyATVService.html +0 -73
- package/docs/reference/interfaces/NodePyATVState.html +0 -164
- package/docs/reference/interfaces/NodePyATVVersionResponse.html +0 -73
- package/docs/reference/modules.html +0 -106
- package/docs/reference/types/NodePyATVEventValueType.html +0 -66
- package/docs/tests/assets/MaterialIcons-Regular.woff +0 -0
- package/docs/tests/assets/MaterialIcons-Regular.woff2 +0 -0
- package/docs/tests/assets/app.css +0 -14
- package/docs/tests/assets/app.js +0 -2
- package/docs/tests/assets/app.js.LICENSE.txt +0 -55
- package/docs/tests/assets/roboto-light-webfont.woff +0 -0
- package/docs/tests/assets/roboto-light-webfont.woff2 +0 -0
- package/docs/tests/assets/roboto-medium-webfont.woff +0 -0
- package/docs/tests/assets/roboto-medium-webfont.woff2 +0 -0
- package/docs/tests/assets/roboto-regular-webfont.woff +0 -0
- package/docs/tests/assets/roboto-regular-webfont.woff2 +0 -0
- package/docs/tests/index.html +0 -2
- package/docs/tests/mochawesome.json +0 -4823
- package/release.config.cjs +0 -51
- package/src/bin/check.ts +0 -41
- package/src/examples/push.ts +0 -46
- package/src/lib/device-event.ts +0 -57
- package/src/lib/device-events.ts +0 -295
- package/src/lib/device.ts +0 -811
- package/src/lib/fake-spawn.ts +0 -121
- package/src/lib/index.ts +0 -29
- package/src/lib/instance.ts +0 -211
- package/src/lib/tools.ts +0 -379
- package/src/lib/types.ts +0 -230
- package/test/device-event.ts +0 -88
- package/test/device-events.ts +0 -502
- package/test/device.ts +0 -826
- package/test/instance.ts +0 -428
- package/test/tools.ts +0 -301
- package/tsconfig.json +0 -19
- package/typedoc.json +0 -15
package/test/tools.ts
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import assert from 'assert';
|
|
4
|
-
import { addRequestId, debug, getExecutable, getParamters, parseState, removeRequestId } from '../src/lib/tools.js';
|
|
5
|
-
import {
|
|
6
|
-
NodePyATVDeviceState,
|
|
7
|
-
NodePyATVExecutableType,
|
|
8
|
-
NodePyATVMediaType,
|
|
9
|
-
NodePyATVProtocol,
|
|
10
|
-
NodePyATVRepeatState,
|
|
11
|
-
NodePyATVShuffleState
|
|
12
|
-
} from '../src/lib/types.js';
|
|
13
|
-
|
|
14
|
-
describe('Tools', function () {
|
|
15
|
-
describe('addRequestId() / removeRequestId()', function () {
|
|
16
|
-
it('should return a string', function () {
|
|
17
|
-
const id = addRequestId();
|
|
18
|
-
assert.strictEqual(typeof id, 'string');
|
|
19
|
-
removeRequestId(id);
|
|
20
|
-
});
|
|
21
|
-
it('should work if given id is not in index', function () {
|
|
22
|
-
removeRequestId('FOO');
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('debug()', function () {
|
|
27
|
-
it('should work without any options', function () {
|
|
28
|
-
debug('TEST', 'Hello World.', {});
|
|
29
|
-
});
|
|
30
|
-
it('should work with default logger', function () {
|
|
31
|
-
debug('TEST', 'Hello World.', { debug: true });
|
|
32
|
-
});
|
|
33
|
-
it('should work with custom logger', function () {
|
|
34
|
-
debug('TEST', 'Hello World.', {
|
|
35
|
-
debug: function (msg) {
|
|
36
|
-
assert.strictEqual(this, null);
|
|
37
|
-
assert.ok(msg.includes('Hello World'));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
it('should work with colors disabled', function () {
|
|
42
|
-
debug('TEST', 'Hello World.', { noColors: true });
|
|
43
|
-
});
|
|
44
|
-
it('should work with custom logger and colors disabled', function () {
|
|
45
|
-
debug('TEST', 'Hello World.', {
|
|
46
|
-
noColors: true,
|
|
47
|
-
debug: function (msg) {
|
|
48
|
-
assert.strictEqual(this, null);
|
|
49
|
-
assert.strictEqual(msg, '[node-pyatv][TEST] Hello World.');
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('getExecutable()', function () {
|
|
56
|
-
it('should handle atvremotePath if set', function () {
|
|
57
|
-
const result = getExecutable(NodePyATVExecutableType.atvremote, {
|
|
58
|
-
atvremotePath: '/tmp/1',
|
|
59
|
-
atvscriptPath: '/tmp/2'
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
assert.strictEqual(result, '/tmp/1');
|
|
63
|
-
});
|
|
64
|
-
it('should handle atvscriptPath if set', function () {
|
|
65
|
-
const result = getExecutable(NodePyATVExecutableType.atvscript, {
|
|
66
|
-
atvremotePath: '/tmp/1',
|
|
67
|
-
atvscriptPath: '/tmp/2'
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
assert.strictEqual(result, '/tmp/2');
|
|
71
|
-
});
|
|
72
|
-
it('should handle default for atvremote', function () {
|
|
73
|
-
const result = getExecutable(NodePyATVExecutableType.atvremote, {
|
|
74
|
-
atvscriptPath: '/tmp'
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
assert.strictEqual(result, 'atvremote');
|
|
78
|
-
});
|
|
79
|
-
it('should handle default for atvscript', function () {
|
|
80
|
-
const result = getExecutable(NodePyATVExecutableType.atvscript, {
|
|
81
|
-
atvremotePath: '/tmp'
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
assert.strictEqual(result, 'atvscript');
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('getParameters()', function () {
|
|
89
|
-
it('empty case', async function () {
|
|
90
|
-
const result = await getParamters();
|
|
91
|
-
assert.deepEqual(result, []);
|
|
92
|
-
});
|
|
93
|
-
it('easy case', async function () {
|
|
94
|
-
const result = await getParamters({
|
|
95
|
-
host: '192.168.178.2'
|
|
96
|
-
});
|
|
97
|
-
assert.deepEqual(result, ['-s', '192.168.178.2']);
|
|
98
|
-
});
|
|
99
|
-
it('full case', async function () {
|
|
100
|
-
const result = await getParamters({
|
|
101
|
-
hosts: ['192.168.178.2', '192.168.178.3'],
|
|
102
|
-
id: '****',
|
|
103
|
-
protocol: NodePyATVProtocol.mrp,
|
|
104
|
-
dmapCredentials: '****',
|
|
105
|
-
mrpCredentials: '****',
|
|
106
|
-
airplayCredentials: '****',
|
|
107
|
-
companionCredentials: '1234',
|
|
108
|
-
raopCredentials: '::foo:'
|
|
109
|
-
});
|
|
110
|
-
assert.deepEqual(result, [
|
|
111
|
-
'-s', '192.168.178.2,192.168.178.3',
|
|
112
|
-
'-i', '****',
|
|
113
|
-
'--protocol', 'mrp',
|
|
114
|
-
'--dmap-credentials', '****',
|
|
115
|
-
'--mrp-credentials', '****',
|
|
116
|
-
'--airplay-credentials', '****',
|
|
117
|
-
'--companion-credentials', '1234',
|
|
118
|
-
'--raop-credentials', '::foo:'
|
|
119
|
-
]);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('parseState()', function () {
|
|
124
|
-
it('should work with empty data', function () {
|
|
125
|
-
const input = {};
|
|
126
|
-
const result = parseState(input, '', {});
|
|
127
|
-
assert.deepStrictEqual(result, {
|
|
128
|
-
dateTime: null,
|
|
129
|
-
hash: null,
|
|
130
|
-
mediaType: null,
|
|
131
|
-
deviceState: null,
|
|
132
|
-
title: null,
|
|
133
|
-
artist: null,
|
|
134
|
-
album: null,
|
|
135
|
-
genre: null,
|
|
136
|
-
totalTime: null,
|
|
137
|
-
position: null,
|
|
138
|
-
shuffle: null,
|
|
139
|
-
repeat: null,
|
|
140
|
-
app: null,
|
|
141
|
-
appId: null,
|
|
142
|
-
powerState: null
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
it('should work without data', function () {
|
|
146
|
-
// @ts-ignore
|
|
147
|
-
const result = parseState(null, '', {});
|
|
148
|
-
assert.deepStrictEqual(result, {
|
|
149
|
-
dateTime: null,
|
|
150
|
-
hash: null,
|
|
151
|
-
mediaType: null,
|
|
152
|
-
deviceState: null,
|
|
153
|
-
title: null,
|
|
154
|
-
artist: null,
|
|
155
|
-
album: null,
|
|
156
|
-
genre: null,
|
|
157
|
-
totalTime: null,
|
|
158
|
-
position: null,
|
|
159
|
-
shuffle: null,
|
|
160
|
-
repeat: null,
|
|
161
|
-
app: null,
|
|
162
|
-
appId: null,
|
|
163
|
-
powerState: null
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
it('should work with example data', function () {
|
|
167
|
-
const input = {
|
|
168
|
-
result: 'success',
|
|
169
|
-
datetime: '2020-11-07T22:38:43.608030+01:00',
|
|
170
|
-
hash: '100e0ab6-6ff5-4199-9c04-a7107ff78712',
|
|
171
|
-
media_type: 'video',
|
|
172
|
-
device_state: 'playing',
|
|
173
|
-
title: 'Solo: A Star Wars Story',
|
|
174
|
-
artist: null,
|
|
175
|
-
album: null,
|
|
176
|
-
genre: null,
|
|
177
|
-
total_time: 8097,
|
|
178
|
-
position: 27,
|
|
179
|
-
shuffle: 'off',
|
|
180
|
-
repeat: 'off',
|
|
181
|
-
app: 'Disney+',
|
|
182
|
-
app_id: 'com.disney.disneyplus',
|
|
183
|
-
powerState: null
|
|
184
|
-
};
|
|
185
|
-
const result = parseState(input, '', {});
|
|
186
|
-
assert.deepStrictEqual(result, {
|
|
187
|
-
dateTime: new Date('2020-11-07T22:38:43.608030+01:00'),
|
|
188
|
-
hash: '100e0ab6-6ff5-4199-9c04-a7107ff78712',
|
|
189
|
-
mediaType: NodePyATVMediaType.video,
|
|
190
|
-
deviceState: NodePyATVDeviceState.playing,
|
|
191
|
-
title: 'Solo: A Star Wars Story',
|
|
192
|
-
artist: null,
|
|
193
|
-
album: null,
|
|
194
|
-
genre: null,
|
|
195
|
-
totalTime: 8097,
|
|
196
|
-
position: 27,
|
|
197
|
-
shuffle: NodePyATVShuffleState.off,
|
|
198
|
-
repeat: NodePyATVRepeatState.off,
|
|
199
|
-
app: 'Disney+',
|
|
200
|
-
appId: 'com.disney.disneyplus',
|
|
201
|
-
powerState: null
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
it('should throw an error for pyatv exceptions', function () {
|
|
205
|
-
const input = {
|
|
206
|
-
result: 'failure',
|
|
207
|
-
datetime: '2021-11-24T21:13:36.424576+03:00',
|
|
208
|
-
exception: 'invalid credentials: 321',
|
|
209
|
-
stacktrace: 'Traceback (most recent call last):\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 302, in appstart\n print(args.output(await _handle_command(args, abort_sem, loop)), flush=True)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 196, in _handle_command\n atv = await connect(config, loop, protocol=Protocol.MRP)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/__init__.py\", line 96, in connect\n for setup_data in proto_methods.setup(\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 192, in setup\n stream = AirPlayStream(config, service)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 79, in __init__\n self._credentials: HapCredentials = parse_credentials(self.service.credentials)\n File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/auth/hap_pairing.py\", line 139, in parse_credentials\n raise exceptions.InvalidCredentialsError(\"invalid credentials: \" + detail_string)\npyatv.exceptions.InvalidCredentialsError: invalid credentials: 321\n'
|
|
210
|
-
};
|
|
211
|
-
assert.throws(() => {
|
|
212
|
-
parseState(input, '', {});
|
|
213
|
-
}, /Got pyatv Error: invalid credentials: 321/);
|
|
214
|
-
});
|
|
215
|
-
it('should ignore date if it\'s an invalid date', function () {
|
|
216
|
-
const input = { datetime: 'today' };
|
|
217
|
-
const result = parseState(input, '', {});
|
|
218
|
-
assert.deepStrictEqual(result, {
|
|
219
|
-
dateTime: null,
|
|
220
|
-
hash: null,
|
|
221
|
-
mediaType: null,
|
|
222
|
-
deviceState: null,
|
|
223
|
-
title: null,
|
|
224
|
-
artist: null,
|
|
225
|
-
album: null,
|
|
226
|
-
genre: null,
|
|
227
|
-
totalTime: null,
|
|
228
|
-
position: null,
|
|
229
|
-
shuffle: null,
|
|
230
|
-
repeat: null,
|
|
231
|
-
app: null,
|
|
232
|
-
appId: null,
|
|
233
|
-
powerState: null
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
it('should ignore data if unsupported type', function () {
|
|
237
|
-
const input = {
|
|
238
|
-
result: 'success',
|
|
239
|
-
datetime: true,
|
|
240
|
-
hash: 1337,
|
|
241
|
-
media_type: false,
|
|
242
|
-
device_state: 43,
|
|
243
|
-
title: undefined,
|
|
244
|
-
artist: 90,
|
|
245
|
-
album: Infinity,
|
|
246
|
-
genre: Math.PI,
|
|
247
|
-
total_time: '23min',
|
|
248
|
-
position: '0:30.123',
|
|
249
|
-
shuffle: false,
|
|
250
|
-
repeat: true,
|
|
251
|
-
app: 0,
|
|
252
|
-
app_id: 891645381647289,
|
|
253
|
-
powerState: null
|
|
254
|
-
};
|
|
255
|
-
const result = parseState(input, '', {});
|
|
256
|
-
assert.deepStrictEqual(result, {
|
|
257
|
-
dateTime: null,
|
|
258
|
-
hash: null,
|
|
259
|
-
mediaType: null,
|
|
260
|
-
deviceState: null,
|
|
261
|
-
title: null,
|
|
262
|
-
artist: null,
|
|
263
|
-
album: null,
|
|
264
|
-
genre: null,
|
|
265
|
-
totalTime: null,
|
|
266
|
-
position: null,
|
|
267
|
-
shuffle: null,
|
|
268
|
-
repeat: null,
|
|
269
|
-
app: null,
|
|
270
|
-
appId: null,
|
|
271
|
-
powerState: null
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
it('should ignore enums with unsupported valid', function () {
|
|
275
|
-
const input = {
|
|
276
|
-
media_type: '3d-experience',
|
|
277
|
-
device_state: 'initiating',
|
|
278
|
-
shuffle: 'everything',
|
|
279
|
-
repeat: 'nothing'
|
|
280
|
-
};
|
|
281
|
-
const result = parseState(input, '', {});
|
|
282
|
-
assert.deepStrictEqual(result, {
|
|
283
|
-
dateTime: null,
|
|
284
|
-
hash: null,
|
|
285
|
-
mediaType: null,
|
|
286
|
-
deviceState: null,
|
|
287
|
-
title: null,
|
|
288
|
-
artist: null,
|
|
289
|
-
album: null,
|
|
290
|
-
genre: null,
|
|
291
|
-
totalTime: null,
|
|
292
|
-
position: null,
|
|
293
|
-
shuffle: null,
|
|
294
|
-
repeat: null,
|
|
295
|
-
app: null,
|
|
296
|
-
appId: null,
|
|
297
|
-
powerState: null
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"module": "es2020",
|
|
6
|
-
"moduleResolution": "node16",
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"sourceMap": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"target": "es6"
|
|
11
|
-
},
|
|
12
|
-
"exclude": [
|
|
13
|
-
"node_modules",
|
|
14
|
-
"**/*.spec.ts"
|
|
15
|
-
],
|
|
16
|
-
"include": [
|
|
17
|
-
"src/**/*"
|
|
18
|
-
]
|
|
19
|
-
}
|
package/typedoc.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entryPoints": ["./src/lib/index.ts"],
|
|
3
|
-
"exclude": [
|
|
4
|
-
"./lib/tools.ts"
|
|
5
|
-
],
|
|
6
|
-
"excludeInternal": true,
|
|
7
|
-
"excludePrivate": true,
|
|
8
|
-
"excludeProtected": true,
|
|
9
|
-
"includeVersion": true,
|
|
10
|
-
"name": "node-pyatv",
|
|
11
|
-
"out": "./docs/reference",
|
|
12
|
-
"plugin": [],
|
|
13
|
-
"readme": "README.md",
|
|
14
|
-
"theme": "default"
|
|
15
|
-
}
|