@vestra-player/sdk 1.9.0 → 1.10.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.
- package/CHANGELOG.md +44 -7
- package/bin/vestra-plugin.mjs +89 -8
- package/capability-scan.json +20 -0
- package/dist/api-requests.d.ts +4 -3
- package/dist/api-requests.js +11 -3
- package/dist/commands.js +1 -0
- package/dist/condition-table.d.ts +1889 -0
- package/dist/condition-table.js +562 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/i18n-tools.d.ts +7 -0
- package/dist/i18n-tools.js +66 -3
- package/dist/player-runtime.d.ts +3 -0
- package/dist/player-runtime.js +3 -0
- package/dist/plugin/connection.d.ts +13 -2
- package/dist/plugin/connection.js +67 -4
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +13 -0
- package/dist/plugin/mpv.js +39 -5
- package/dist/plugin/player/events.d.ts +14 -5
- package/dist/plugin/player/events.js +19 -3
- package/dist/plugin/player.d.ts +16 -0
- package/dist/plugin/player.js +77 -1
- package/dist/plugin/scope.d.ts +4 -1
- package/dist/plugin/scope.js +8 -0
- package/dist/plugin/testing/commands.d.ts +5 -0
- package/dist/plugin/testing/commands.js +23 -24
- package/dist/plugin/testing/index.d.ts +134 -0
- package/dist/plugin/testing/index.js +180 -21
- package/dist/plugin/testing/media.d.ts +6 -0
- package/dist/plugin/testing/media.js +15 -2
- package/dist/plugin/testing/services.js +50 -1
- package/dist/plugin/testing/source-events.d.ts +28 -0
- package/dist/plugin/testing/source-events.js +66 -0
- package/dist/plugin/testing/transport.js +5 -0
- package/dist/plugin/testing/triggers.d.ts +82 -0
- package/dist/plugin/testing/triggers.js +448 -0
- package/dist/plugin/timeline.d.ts +3 -3
- package/dist/plugin/timeline.js +3 -3
- package/dist/plugin/triggers.d.ts +55 -0
- package/dist/plugin/triggers.js +233 -0
- package/dist/plugin/types/base.d.ts +117 -3
- package/dist/plugin/types/commands.d.ts +374 -1
- package/dist/plugin/types/packages.d.ts +10 -1
- package/dist/plugin/types/playback.d.ts +257 -9
- package/dist/plugin/types/services.d.ts +10 -4
- package/dist/plugin/when.d.ts +78 -4
- package/dist/plugin/when.js +182 -14
- package/dist/slint-version.d.ts +7 -0
- package/dist/slint-version.js +7 -0
- package/dist/wire.d.ts +18 -0
- package/dist/wire.js +12 -0
- package/llms.txt +4 -4
- package/package.json +2 -2
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK-host agreement table of the `when` language (1.10.0,
|
|
3
|
+
* events-and-triggers.md §4.3, §4.11): condition × facts → truth. The
|
|
4
|
+
* player has the same table (`src/host/condition-table.json`); its
|
|
5
|
+
* host-agreement test checks the two are equal, and each side evaluates
|
|
6
|
+
* every row (`test/triggers.test.ts` here, `conditions_tests.rs` there).
|
|
7
|
+
* Each row's facts override `defaults`.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export const CONDITION_TABLE = {
|
|
12
|
+
about: "The SDK-host agreement table of the when language (events-and-triggers.md §4.3, §4.11): condition x facts -> truth. The SDK's copy is CONDITION_TABLE in @vestra-player/sdk/runtime; src/tests/sdk/host-agreement.test.ts checks the two are equal, the host's conditions tests and the SDK's tests evaluate every row. Each row's facts override the defaults.",
|
|
13
|
+
defaults: {
|
|
14
|
+
phase: "ready",
|
|
15
|
+
paused: false,
|
|
16
|
+
kind: "media",
|
|
17
|
+
can: ["pause", "seek", "rate"],
|
|
18
|
+
fullscreen: false,
|
|
19
|
+
theme: "vestra",
|
|
20
|
+
language: "system",
|
|
21
|
+
duration: 600,
|
|
22
|
+
volume: 100,
|
|
23
|
+
rate: 1,
|
|
24
|
+
muted: false,
|
|
25
|
+
audioTrack: 1,
|
|
26
|
+
audioDevice: "auto",
|
|
27
|
+
looping: false,
|
|
28
|
+
maximized: false,
|
|
29
|
+
pip: false,
|
|
30
|
+
subtitleTrack: "embedded:2",
|
|
31
|
+
sourceId: 7,
|
|
32
|
+
position: 30,
|
|
33
|
+
time: 1800000000000,
|
|
34
|
+
bound: 7,
|
|
35
|
+
},
|
|
36
|
+
rows: [
|
|
37
|
+
{
|
|
38
|
+
when: {
|
|
39
|
+
phase: ["ready"],
|
|
40
|
+
},
|
|
41
|
+
facts: {},
|
|
42
|
+
holds: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
when: {
|
|
46
|
+
phase: ["empty", "ended"],
|
|
47
|
+
},
|
|
48
|
+
facts: {},
|
|
49
|
+
holds: false,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
when: {
|
|
53
|
+
paused: true,
|
|
54
|
+
},
|
|
55
|
+
facts: {
|
|
56
|
+
paused: true,
|
|
57
|
+
},
|
|
58
|
+
holds: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
when: {
|
|
62
|
+
kind: "stream",
|
|
63
|
+
},
|
|
64
|
+
facts: {},
|
|
65
|
+
holds: false,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
when: {
|
|
69
|
+
can: "seek",
|
|
70
|
+
},
|
|
71
|
+
facts: {},
|
|
72
|
+
holds: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
when: {
|
|
76
|
+
can: "snapshot",
|
|
77
|
+
},
|
|
78
|
+
facts: {},
|
|
79
|
+
holds: false,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
when: {
|
|
83
|
+
fullscreen: true,
|
|
84
|
+
},
|
|
85
|
+
facts: {
|
|
86
|
+
fullscreen: true,
|
|
87
|
+
},
|
|
88
|
+
holds: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
when: {
|
|
92
|
+
theme: "vestra",
|
|
93
|
+
},
|
|
94
|
+
facts: {},
|
|
95
|
+
holds: true,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
when: {
|
|
99
|
+
language: "de",
|
|
100
|
+
},
|
|
101
|
+
facts: {},
|
|
102
|
+
holds: false,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
when: {
|
|
106
|
+
duration: {
|
|
107
|
+
min: 600,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
facts: {},
|
|
111
|
+
holds: true,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
when: {
|
|
115
|
+
duration: {
|
|
116
|
+
max: 600,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
facts: {},
|
|
120
|
+
holds: false,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
when: {
|
|
124
|
+
duration: {
|
|
125
|
+
min: 0,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
facts: {
|
|
129
|
+
duration: null,
|
|
130
|
+
},
|
|
131
|
+
holds: false,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
when: {
|
|
135
|
+
duration: {
|
|
136
|
+
max: 1,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
facts: {
|
|
140
|
+
duration: null,
|
|
141
|
+
},
|
|
142
|
+
holds: false,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
when: {
|
|
146
|
+
not: {
|
|
147
|
+
duration: {
|
|
148
|
+
min: 0,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
facts: {
|
|
153
|
+
duration: null,
|
|
154
|
+
},
|
|
155
|
+
holds: true,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
when: {
|
|
159
|
+
volume: {
|
|
160
|
+
min: 50,
|
|
161
|
+
max: 101,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
facts: {},
|
|
165
|
+
holds: true,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
when: {
|
|
169
|
+
volume: {
|
|
170
|
+
max: 100,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
facts: {},
|
|
174
|
+
holds: false,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
when: {
|
|
178
|
+
rate: {
|
|
179
|
+
min: 1.5,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
facts: {
|
|
183
|
+
rate: 2,
|
|
184
|
+
},
|
|
185
|
+
holds: true,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
when: {
|
|
189
|
+
rate: {
|
|
190
|
+
min: 1.5,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
facts: {},
|
|
194
|
+
holds: false,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
when: {
|
|
198
|
+
audioTrack: 1,
|
|
199
|
+
},
|
|
200
|
+
facts: {},
|
|
201
|
+
holds: true,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
when: {
|
|
205
|
+
audioTrack: 2,
|
|
206
|
+
},
|
|
207
|
+
facts: {},
|
|
208
|
+
holds: false,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
when: {
|
|
212
|
+
audioTrack: 1,
|
|
213
|
+
},
|
|
214
|
+
facts: {
|
|
215
|
+
audioTrack: null,
|
|
216
|
+
},
|
|
217
|
+
holds: false,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
when: {
|
|
221
|
+
subtitleTrack: "embedded:2",
|
|
222
|
+
},
|
|
223
|
+
facts: {},
|
|
224
|
+
holds: true,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
when: {
|
|
228
|
+
subtitleTrack: "embedded:2",
|
|
229
|
+
},
|
|
230
|
+
facts: {
|
|
231
|
+
subtitleTrack: null,
|
|
232
|
+
},
|
|
233
|
+
holds: false,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
when: {
|
|
237
|
+
audioDevice: "auto",
|
|
238
|
+
},
|
|
239
|
+
facts: {},
|
|
240
|
+
holds: true,
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
when: {
|
|
244
|
+
audioDevice: "auto",
|
|
245
|
+
},
|
|
246
|
+
facts: {
|
|
247
|
+
audioDevice: null,
|
|
248
|
+
},
|
|
249
|
+
holds: false,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
when: {
|
|
253
|
+
muted: true,
|
|
254
|
+
},
|
|
255
|
+
facts: {},
|
|
256
|
+
holds: false,
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
when: {
|
|
260
|
+
muted: false,
|
|
261
|
+
},
|
|
262
|
+
facts: {},
|
|
263
|
+
holds: true,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
when: {
|
|
267
|
+
maximized: true,
|
|
268
|
+
},
|
|
269
|
+
facts: {
|
|
270
|
+
maximized: true,
|
|
271
|
+
},
|
|
272
|
+
holds: true,
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
when: {
|
|
276
|
+
pip: true,
|
|
277
|
+
},
|
|
278
|
+
facts: {},
|
|
279
|
+
holds: false,
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
when: {
|
|
283
|
+
looping: true,
|
|
284
|
+
},
|
|
285
|
+
facts: {
|
|
286
|
+
looping: true,
|
|
287
|
+
},
|
|
288
|
+
holds: true,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
when: {
|
|
292
|
+
time: {
|
|
293
|
+
min: 1800000000000,
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
facts: {},
|
|
297
|
+
holds: true,
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
when: {
|
|
301
|
+
time: {
|
|
302
|
+
max: 1800000000000,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
facts: {},
|
|
306
|
+
holds: false,
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
when: {
|
|
310
|
+
time: {
|
|
311
|
+
min: 1700000000000,
|
|
312
|
+
max: 1800000000001,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
facts: {},
|
|
316
|
+
holds: true,
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
when: {
|
|
320
|
+
position: {
|
|
321
|
+
ranges: [
|
|
322
|
+
[10, 20],
|
|
323
|
+
[30, 40],
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
facts: {},
|
|
328
|
+
holds: true,
|
|
329
|
+
range: 1,
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
when: {
|
|
333
|
+
position: {
|
|
334
|
+
ranges: [
|
|
335
|
+
[10, 20],
|
|
336
|
+
[30, 40],
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
facts: {
|
|
341
|
+
position: 40,
|
|
342
|
+
},
|
|
343
|
+
holds: false,
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
when: {
|
|
347
|
+
position: {
|
|
348
|
+
ranges: [
|
|
349
|
+
[10, 20],
|
|
350
|
+
[32, 40],
|
|
351
|
+
],
|
|
352
|
+
lead: 2,
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
facts: {},
|
|
356
|
+
holds: true,
|
|
357
|
+
range: 1,
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
when: {
|
|
361
|
+
position: {
|
|
362
|
+
ranges: [
|
|
363
|
+
[10, 20],
|
|
364
|
+
[33, 40],
|
|
365
|
+
],
|
|
366
|
+
lead: 2,
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
facts: {},
|
|
370
|
+
holds: false,
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
when: {
|
|
374
|
+
position: {
|
|
375
|
+
ranges: [
|
|
376
|
+
[25, 35],
|
|
377
|
+
[20, 45],
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
facts: {},
|
|
382
|
+
holds: true,
|
|
383
|
+
range: 1,
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
when: {
|
|
387
|
+
position: {
|
|
388
|
+
ranges: [[29]],
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
facts: {},
|
|
392
|
+
holds: true,
|
|
393
|
+
range: 0,
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
when: {
|
|
397
|
+
position: {
|
|
398
|
+
ranges: [[31]],
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
facts: {},
|
|
402
|
+
holds: false,
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
when: {
|
|
406
|
+
position: {
|
|
407
|
+
ranges: [],
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
facts: {},
|
|
411
|
+
holds: false,
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
when: {
|
|
415
|
+
position: {
|
|
416
|
+
ranges: [[0, 100]],
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
facts: {
|
|
420
|
+
bound: 6,
|
|
421
|
+
},
|
|
422
|
+
holds: false,
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
when: {
|
|
426
|
+
position: {
|
|
427
|
+
ranges: [[0, 100]],
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
facts: {
|
|
431
|
+
position: null,
|
|
432
|
+
},
|
|
433
|
+
holds: false,
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
when: {
|
|
437
|
+
not: {
|
|
438
|
+
position: {
|
|
439
|
+
ranges: [[0, 100]],
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
facts: {
|
|
444
|
+
position: null,
|
|
445
|
+
},
|
|
446
|
+
holds: true,
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
when: {
|
|
450
|
+
all: [
|
|
451
|
+
{
|
|
452
|
+
phase: ["ready"],
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
paused: false,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
position: {
|
|
459
|
+
ranges: [[20, 40]],
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
},
|
|
464
|
+
facts: {},
|
|
465
|
+
holds: true,
|
|
466
|
+
range: 0,
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
when: {
|
|
470
|
+
all: [
|
|
471
|
+
{
|
|
472
|
+
phase: ["ready"],
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
paused: false,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
position: {
|
|
479
|
+
ranges: [[20, 40]],
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
},
|
|
484
|
+
facts: {
|
|
485
|
+
paused: true,
|
|
486
|
+
},
|
|
487
|
+
holds: false,
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
when: {
|
|
491
|
+
any: [
|
|
492
|
+
{
|
|
493
|
+
fullscreen: true,
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
position: {
|
|
497
|
+
ranges: [[20, 40]],
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
],
|
|
501
|
+
},
|
|
502
|
+
facts: {},
|
|
503
|
+
holds: true,
|
|
504
|
+
range: 0,
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
when: {
|
|
508
|
+
any: [
|
|
509
|
+
{
|
|
510
|
+
fullscreen: true,
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
position: {
|
|
514
|
+
ranges: [[50, 60]],
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
],
|
|
518
|
+
},
|
|
519
|
+
facts: {
|
|
520
|
+
fullscreen: true,
|
|
521
|
+
},
|
|
522
|
+
holds: true,
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
when: {
|
|
526
|
+
all: [
|
|
527
|
+
{
|
|
528
|
+
phase: ["ready"],
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
paused: false,
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
fullscreen: true,
|
|
535
|
+
},
|
|
536
|
+
],
|
|
537
|
+
},
|
|
538
|
+
facts: {
|
|
539
|
+
fullscreen: true,
|
|
540
|
+
},
|
|
541
|
+
holds: true,
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
when: {
|
|
545
|
+
not: {
|
|
546
|
+
all: [
|
|
547
|
+
{
|
|
548
|
+
muted: true,
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
volume: {
|
|
552
|
+
max: 10,
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
facts: {},
|
|
559
|
+
holds: true,
|
|
560
|
+
},
|
|
561
|
+
],
|
|
562
|
+
};
|
package/dist/docs-tree.json.gz
CHANGED
|
Binary file
|
package/dist/i18n-tools.d.ts
CHANGED
|
@@ -30,6 +30,13 @@ export interface ExtractOptions {
|
|
|
30
30
|
compilerOptions?: TS.CompilerOptions;
|
|
31
31
|
}
|
|
32
32
|
export declare const pluralForms: (language: string) => "nplurals=1; plural=0;" | "nplurals=2; plural=(n != 1);";
|
|
33
|
+
/**
|
|
34
|
+
* Thrown by {@link extract} when a text cannot be read for want of the SDK's
|
|
35
|
+
* types: `code` is `"sdk-types"`, `message` names each call and why.
|
|
36
|
+
*/
|
|
37
|
+
export declare class SdkTypesMissing extends Error {
|
|
38
|
+
readonly code = "sdk-types";
|
|
39
|
+
}
|
|
33
40
|
/** Find every translatable text of a plugin, in reference order. */
|
|
34
41
|
export declare function extract(options: ExtractOptions): {
|
|
35
42
|
messages: Message[];
|
package/dist/i18n-tools.js
CHANGED
|
@@ -74,6 +74,17 @@ const SITES = {
|
|
|
74
74
|
"I18n.error": { argument: 0 },
|
|
75
75
|
"I18n.resolve": { argument: 0 },
|
|
76
76
|
};
|
|
77
|
+
/** The members of `I18n` that are sites (`text`, `error`, `resolve`). */
|
|
78
|
+
const I18N_MEMBERS = new Set(Object.keys(SITES)
|
|
79
|
+
.filter((name) => name.startsWith("I18n."))
|
|
80
|
+
.map((name) => name.slice("I18n.".length)));
|
|
81
|
+
/**
|
|
82
|
+
* Thrown by {@link extract} when a text cannot be read for want of the SDK's
|
|
83
|
+
* types: `code` is `"sdk-types"`, `message` names each call and why.
|
|
84
|
+
*/
|
|
85
|
+
export class SdkTypesMissing extends Error {
|
|
86
|
+
code = "sdk-types";
|
|
87
|
+
}
|
|
77
88
|
/** Without the SDK's types: the module property names in front of the method. */
|
|
78
89
|
const BY_NAME = {
|
|
79
90
|
"commands.add": "Commands.add",
|
|
@@ -172,9 +183,18 @@ class Extractor {
|
|
|
172
183
|
*/
|
|
173
184
|
tableNotes = new Map();
|
|
174
185
|
findings = [];
|
|
186
|
+
/**
|
|
187
|
+
* Calls of an `I18n` member through a name of their own (`const { text }
|
|
188
|
+
* = plugin.i18n`) seen while the program has none of the SDK's types:
|
|
189
|
+
* only the types tell that such a call is the SDK's, so they would be
|
|
190
|
+
* left out silently. `extract` fails with them instead.
|
|
191
|
+
*/
|
|
192
|
+
detached = [];
|
|
175
193
|
#checker;
|
|
176
|
-
|
|
194
|
+
#sdkTypes;
|
|
195
|
+
constructor(checker, sdkTypes = true) {
|
|
177
196
|
this.#checker = checker;
|
|
197
|
+
this.#sdkTypes = sdkTypes;
|
|
178
198
|
}
|
|
179
199
|
add(file, line, message) {
|
|
180
200
|
this.found.push({ ...message, file, line, references: [] });
|
|
@@ -317,6 +337,32 @@ class Extractor {
|
|
|
317
337
|
else if (values.dynamic)
|
|
318
338
|
this.finding(file, line, "dynamic", DYNAMIC(what));
|
|
319
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* The `I18n` member a call through a bare name stands for, by how the
|
|
342
|
+
* name was bound: `const { text } = …`, `const { text: t } = …` or
|
|
343
|
+
* `const t = ….text`. Only asked without the SDK's types.
|
|
344
|
+
*/
|
|
345
|
+
#detachedMember(call) {
|
|
346
|
+
const callee = call.expression;
|
|
347
|
+
if (!ts.isIdentifier(callee) || !this.#checker)
|
|
348
|
+
return undefined;
|
|
349
|
+
const declaration = this.#checker.getSymbolAtLocation(callee)?.declarations?.[0];
|
|
350
|
+
if (!declaration)
|
|
351
|
+
return undefined;
|
|
352
|
+
let member;
|
|
353
|
+
if (ts.isBindingElement(declaration)) {
|
|
354
|
+
const key = declaration.propertyName ?? declaration.name;
|
|
355
|
+
if (ts.isIdentifier(key) || ts.isStringLiteral(key))
|
|
356
|
+
member = key.text;
|
|
357
|
+
}
|
|
358
|
+
else if (ts.isVariableDeclaration(declaration) &&
|
|
359
|
+
declaration.initializer &&
|
|
360
|
+
ts.isPropertyAccessExpression(declaration.initializer))
|
|
361
|
+
member = declaration.initializer.name.text;
|
|
362
|
+
return member !== undefined && I18N_MEMBERS.has(member)
|
|
363
|
+
? member
|
|
364
|
+
: undefined;
|
|
365
|
+
}
|
|
320
366
|
/** `Interface.method` of a call to the SDK, if it is one of `SITES`. */
|
|
321
367
|
#site(call) {
|
|
322
368
|
const callee = call.expression;
|
|
@@ -398,8 +444,17 @@ class Extractor {
|
|
|
398
444
|
}
|
|
399
445
|
#call(call, file, source, text) {
|
|
400
446
|
const name = this.#site(call);
|
|
401
|
-
if (!name)
|
|
447
|
+
if (!name) {
|
|
448
|
+
const member = this.#sdkTypes ? undefined : this.#detachedMember(call);
|
|
449
|
+
if (member && !ignored(statementOf(call), text))
|
|
450
|
+
this.detached.push({
|
|
451
|
+
file,
|
|
452
|
+
line: source.getLineAndCharacterOfPosition(call.getStart(source)).line +
|
|
453
|
+
1,
|
|
454
|
+
member,
|
|
455
|
+
});
|
|
402
456
|
return;
|
|
457
|
+
}
|
|
403
458
|
const site = SITES[name];
|
|
404
459
|
if (ignored(statementOf(call), text))
|
|
405
460
|
return;
|
|
@@ -630,13 +685,21 @@ export function extract(options) {
|
|
|
630
685
|
});
|
|
631
686
|
checker = program.getTypeChecker();
|
|
632
687
|
}
|
|
633
|
-
const
|
|
688
|
+
const sdkTypes = !program ||
|
|
689
|
+
program
|
|
690
|
+
.getSourceFiles()
|
|
691
|
+
.some((file) => SDK_TYPES.test(slash(file.fileName)));
|
|
692
|
+
const extractor = new Extractor(checker, sdkTypes);
|
|
634
693
|
for (const file of [...options.typescript].sort()) {
|
|
635
694
|
const path = join(directory, file);
|
|
636
695
|
const source = program?.getSourceFile(path) ??
|
|
637
696
|
ts.createSourceFile(path, readFileSync(path, "utf8"), ts.ScriptTarget.Latest, true);
|
|
638
697
|
extractor.typescript(slash(file), source);
|
|
639
698
|
}
|
|
699
|
+
if (extractor.detached.length)
|
|
700
|
+
throw new SdkTypesMissing(`TypeScript does not resolve the types of @vestra-player/sdk from ${directory}, so these calls cannot be told apart from any other function and their texts would be left out: ${extractor.detached
|
|
701
|
+
.map(({ file, line, member }) => `${file}:${line} (${member}, called through a name of its own)`)
|
|
702
|
+
.join(", ")}. Install the plugin's dependencies (npm install, with @vestra-player/sdk among them), or call plugin.i18n.${extractor.detached[0].member}(…) directly`);
|
|
640
703
|
for (const file of [...options.slint].sort())
|
|
641
704
|
extractor.slint(slash(file), readFileSync(join(directory, file), "utf8"));
|
|
642
705
|
const manifest = options.manifest;
|
package/dist/player-runtime.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from ".
|
|
|
20
20
|
export { MPV_LIMITS, MPV_RULES } from "./mpv.ts";
|
|
21
21
|
export { OSD_LIMITS } from "./plugin/osd.ts";
|
|
22
22
|
export { TIMELINE_LIMITS } from "./plugin/timeline.ts";
|
|
23
|
+
export { TRIGGER_LIMITS } from "./plugin/triggers.ts";
|
|
24
|
+
export { CONDITION_TABLE } from "./condition-table.ts";
|
|
25
|
+
export { evaluateTruth } from "./plugin/when.ts";
|
|
23
26
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
|
|
24
27
|
export { SUBTITLE_LIMITS } from "./plugin/subtitles.ts";
|
|
25
28
|
export { VIDEO_PROCESSING_LIMITS } from "./processing.ts";
|
package/dist/player-runtime.js
CHANGED
|
@@ -18,6 +18,9 @@ export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from ".
|
|
|
18
18
|
export { MPV_LIMITS, MPV_RULES } from "./mpv.js";
|
|
19
19
|
export { OSD_LIMITS } from "./plugin/osd.js";
|
|
20
20
|
export { TIMELINE_LIMITS } from "./plugin/timeline.js";
|
|
21
|
+
export { TRIGGER_LIMITS } from "./plugin/triggers.js";
|
|
22
|
+
export { CONDITION_TABLE } from "./condition-table.js";
|
|
23
|
+
export { evaluateTruth } from "./plugin/when.js";
|
|
21
24
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
|
|
22
25
|
export { SUBTITLE_LIMITS } from "./plugin/subtitles.js";
|
|
23
26
|
export { VIDEO_PROCESSING_LIMITS } from "./processing.js";
|