@vestra-player/sdk 1.7.20 → 1.9.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/CHANGELOG.md +72 -0
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +139 -100
- package/capability-scan.json +369 -0
- package/dist/api-requests.d.ts +11 -36
- package/dist/api-requests.js +22 -47
- package/dist/capability-scan.d.ts +95 -0
- package/dist/capability-scan.js +249 -0
- package/dist/commands.d.ts +35 -0
- package/dist/commands.js +42 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/manifest.d.ts +5 -0
- package/dist/manifest.js +9 -24
- package/dist/member-uses.d.ts +61 -0
- package/dist/member-uses.js +160 -0
- package/dist/mpv.d.ts +139 -0
- package/dist/mpv.js +496 -0
- package/dist/player-runtime.d.ts +3 -3
- package/dist/player-runtime.js +3 -3
- package/dist/plugin/appearance.d.ts +1 -1
- package/dist/plugin/appearance.js +2 -2
- package/dist/plugin/bindings.d.ts +1 -1
- package/dist/plugin/bindings.js +2 -2
- package/dist/plugin/commands.js +6 -14
- package/dist/plugin/connection.d.ts +26 -7
- package/dist/plugin/connection.js +68 -36
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.js +9 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.d.ts +3 -0
- package/dist/plugin/mpv.js +91 -0
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +4 -3
- package/dist/plugin/player/events.js +7 -6
- package/dist/plugin/player.d.ts +21 -13
- package/dist/plugin/player.js +56 -21
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -0
- package/dist/plugin/services.d.ts +4 -4
- package/dist/plugin/services.js +7 -29
- package/dist/plugin/settings.js +1 -1
- package/dist/plugin/shaders.js +0 -2
- package/dist/plugin/stream.d.ts +2 -1
- package/dist/plugin/stream.js +2 -2
- package/dist/plugin/testing/commands.d.ts +3 -10
- package/dist/plugin/testing/commands.js +43 -24
- package/dist/plugin/testing/index.d.ts +75 -114
- package/dist/plugin/testing/index.js +83 -102
- package/dist/plugin/testing/mpv.d.ts +7 -0
- package/dist/plugin/testing/mpv.js +90 -0
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -1
- package/dist/plugin/timeline.d.ts +2 -3
- package/dist/plugin/timeline.js +4 -8
- package/dist/plugin/types/base.d.ts +49 -88
- package/dist/plugin/types/commands.d.ts +44 -77
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +302 -135
- package/dist/plugin/types/plugin-wire.d.ts +6 -36
- package/dist/plugin/types/processing.d.ts +10 -49
- package/dist/plugin/types/services.d.ts +11 -70
- package/dist/plugin/types/snapshots.d.ts +7 -60
- package/dist/plugin/types/sources.d.ts +2 -11
- package/dist/plugin/types/subtitles.d.ts +5 -26
- package/dist/plugin/types/ui-content.d.ts +1 -16
- package/dist/plugin/types/ui-layout.d.ts +53 -79
- package/dist/plugin/types/ui-locale.d.ts +5 -23
- package/dist/plugin/types/ui-shell.d.ts +13 -59
- package/dist/plugin/view/layout.js +1 -1
- package/dist/plugin/view.js +0 -2
- package/dist/plugin/window.d.ts +1 -1
- package/dist/plugin/window.js +1 -1
- package/dist/plugin/wire-facade.js +1 -2
- package/dist/processing.d.ts +2 -3
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +14 -0
- package/dist/request-queue.js +1 -1
- package/dist/subtitles.d.ts +1 -1
- package/dist/ts-plugin.d.ts +8 -15
- package/dist/ts-plugin.js +3 -141
- package/dist/wire.d.ts +22 -12
- package/dist/wire.js +17 -8
- package/llms.txt +5 -5
- package/package.json +4 -3
- package/slint/vestra/widgets.slint +12 -4
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -133
- package/dist/capability-check.js +0 -371
- package/dist/capability-rules.d.ts +0 -125
- package/dist/capability-rules.js +0 -192
- package/dist/host-capabilities.d.ts +0 -10
- package/dist/host-capabilities.js +0 -477
package/dist/mpv.js
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mpv pass-through's rules, as data: what `plugin.mpv` may not send, by
|
|
3
|
+
* category, and its limits. The player applies the same table (its
|
|
4
|
+
* agreement test compares them); the SDK refuses early with it and
|
|
5
|
+
* `TestHost` models it.
|
|
6
|
+
*
|
|
7
|
+
* The channel is the SDK's contract; the command and property names and
|
|
8
|
+
* what they do are mpv's (https://mpv.io/manual/stable/#list-of-input-commands,
|
|
9
|
+
* https://mpv.io/manual/stable/#properties, https://mpv.io/manual/stable/#options).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The limits of `plugin.mpv`, the same values as the player's (its
|
|
13
|
+
* agreement test checks that they agree). Internal: exported from
|
|
14
|
+
* `@vestra-player/sdk/runtime` only; [mpv](../docs/reference/mpv.md) shows
|
|
15
|
+
* them.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const MPV_LIMITS = Object.freeze({
|
|
20
|
+
/** Elements of one command, its name included (32). */
|
|
21
|
+
args: 32,
|
|
22
|
+
/** Characters of a command or property name (128). */
|
|
23
|
+
nameChars: 128,
|
|
24
|
+
/** Characters of a filter label, after the `@` (64). */
|
|
25
|
+
labelChars: 64,
|
|
26
|
+
/** Different properties one plugin observes at the same time (64). */
|
|
27
|
+
observed: 64,
|
|
28
|
+
/** A property's changes reach an observer at most this often; the newest value wins (100 ms). */
|
|
29
|
+
observeIntervalMs: 100,
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* What `plugin.mpv` refuses, as data: the same table as the player's. A
|
|
33
|
+
* command or property not named here goes to mpv as it is.
|
|
34
|
+
*
|
|
35
|
+
* - `categories`: one sentence per category, the end of the refusal's
|
|
36
|
+
* message.
|
|
37
|
+
* - `commands`: mpv commands by name.
|
|
38
|
+
* - `properties`: mpv properties and options by name (the part before the
|
|
39
|
+
* first `/`, after an `options/` or `file-local-options/` prefix);
|
|
40
|
+
* `propertyPrefixes`: by the start of the name, checked after
|
|
41
|
+
* `properties`. A write is refused; a read too for the categories of
|
|
42
|
+
* `reads`.
|
|
43
|
+
* - `writers`: commands that write the property their first argument
|
|
44
|
+
* names (`cycle-values` after an optional `!reverse`); they are checked
|
|
45
|
+
* as a write of it.
|
|
46
|
+
* - `filterCommands`: the filter chain commands and the operations a
|
|
47
|
+
* plugin may use, on its own labelled filters only; `filterMessages`:
|
|
48
|
+
* commands whose first argument is a filter label, which must be the
|
|
49
|
+
* plugin's own; `reservedLabel`: the start of the player's own labels;
|
|
50
|
+
* `reservedLabels`: whole labels that are not a plugin's (`all`, which
|
|
51
|
+
* mpv reads as every filter of the chain).
|
|
52
|
+
*
|
|
53
|
+
* - `prefixes`: mpv's command prefix words (mpv 0.41 `input/cmd.c`,
|
|
54
|
+
* `cmd_flags`, in its order). mpv takes them off the front of a
|
|
55
|
+
* command, in the array form too, and runs what follows: a command whose
|
|
56
|
+
* first element is one is `invalid`, so the name the tables check is
|
|
57
|
+
* the command mpv runs. Only the first element: later, the same words
|
|
58
|
+
* are ordinary arguments.
|
|
59
|
+
*
|
|
60
|
+
* A command's name is looked up with `_` read as `-`, as mpv reads it
|
|
61
|
+
* (`cycle_values` is `cycle-values`); a refusal names it as the caller
|
|
62
|
+
* wrote it. A property's name is looked up as written: mpv does not fold
|
|
63
|
+
* it.
|
|
64
|
+
*
|
|
65
|
+
* Internal: exported from `@vestra-player/sdk/runtime` only; the tables of
|
|
66
|
+
* [mpv](../docs/reference/mpv.md) are generated from it.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export const MPV_RULES = Object.freeze({
|
|
71
|
+
categories: Object.freeze({
|
|
72
|
+
process: "it starts a program (a plugin starts its own with Node)",
|
|
73
|
+
code: "it loads scripts or configuration into the player",
|
|
74
|
+
clients: "it opens a control channel to the player or talks to its other clients",
|
|
75
|
+
files: "it makes the player write or delete files (a plugin writes its own with Node)",
|
|
76
|
+
quit: "it ends the player",
|
|
77
|
+
input: "the keyboard and the mouse are the player's (plugin.commands, plugin.bindings)",
|
|
78
|
+
clipboard: "the clipboard has its own capability (plugin.clipboard)",
|
|
79
|
+
managed: "the player manages it and keeps its own state of it (use the plugin API's member for it)",
|
|
80
|
+
filters: "a plugin changes only its own labelled filters (vf/af add, pre, toggle or remove of @label:…, a label not starting with vestra-)",
|
|
81
|
+
}),
|
|
82
|
+
commands: Object.freeze({
|
|
83
|
+
// Programs.
|
|
84
|
+
run: "process",
|
|
85
|
+
subprocess: "process",
|
|
86
|
+
// Scripts and configuration.
|
|
87
|
+
"load-script": "code",
|
|
88
|
+
"load-config-file": "code",
|
|
89
|
+
"load-input-conf": "code",
|
|
90
|
+
"apply-profile": "code",
|
|
91
|
+
// Other clients of the player.
|
|
92
|
+
"script-message": "clients",
|
|
93
|
+
"script-message-to": "clients",
|
|
94
|
+
"script-binding": "clients",
|
|
95
|
+
// Hooks: a client that does not answer one stalls loading.
|
|
96
|
+
"hook-add": "clients",
|
|
97
|
+
"hook-continue": "clients",
|
|
98
|
+
// Files the player would write or delete.
|
|
99
|
+
screenshot: "files",
|
|
100
|
+
"screenshot-to-file": "files",
|
|
101
|
+
"write-watch-later-config": "files",
|
|
102
|
+
"delete-watch-later-config": "files",
|
|
103
|
+
"dump-cache": "files",
|
|
104
|
+
"ab-loop-dump-cache": "files",
|
|
105
|
+
// The player's process.
|
|
106
|
+
quit: "quit",
|
|
107
|
+
"quit-watch-later": "quit",
|
|
108
|
+
// Input.
|
|
109
|
+
keypress: "input",
|
|
110
|
+
keydown: "input",
|
|
111
|
+
keyup: "input",
|
|
112
|
+
keybind: "input",
|
|
113
|
+
mouse: "input",
|
|
114
|
+
"enable-section": "input",
|
|
115
|
+
"disable-section": "input",
|
|
116
|
+
"define-section": "input",
|
|
117
|
+
"begin-vo-dragging": "input",
|
|
118
|
+
"context-menu": "input",
|
|
119
|
+
// The clipboard.
|
|
120
|
+
"update-clipboard": "clipboard",
|
|
121
|
+
// What plays and the playlist: plugin.player.open, provideSequence.
|
|
122
|
+
loadfile: "managed",
|
|
123
|
+
loadlist: "managed",
|
|
124
|
+
stop: "managed",
|
|
125
|
+
"playlist-next": "managed",
|
|
126
|
+
"playlist-prev": "managed",
|
|
127
|
+
"playlist-next-playlist": "managed",
|
|
128
|
+
"playlist-prev-playlist": "managed",
|
|
129
|
+
"playlist-play-index": "managed",
|
|
130
|
+
"playlist-clear": "managed",
|
|
131
|
+
"playlist-remove": "managed",
|
|
132
|
+
"playlist-move": "managed",
|
|
133
|
+
"playlist-shuffle": "managed",
|
|
134
|
+
"playlist-unshuffle": "managed",
|
|
135
|
+
// The position: plugin.player.seek, step, setLoop.
|
|
136
|
+
seek: "managed",
|
|
137
|
+
"revert-seek": "managed",
|
|
138
|
+
"sub-seek": "managed",
|
|
139
|
+
"sub-step": "managed",
|
|
140
|
+
"frame-step": "managed",
|
|
141
|
+
"frame-back-step": "managed",
|
|
142
|
+
"ab-loop": "managed",
|
|
143
|
+
"ab-loop-align-cache": "managed",
|
|
144
|
+
// Tracks: plugin.player.addAudioTrack, plugin.subtitles.
|
|
145
|
+
"sub-add": "managed",
|
|
146
|
+
"sub-remove": "managed",
|
|
147
|
+
"sub-reload": "managed",
|
|
148
|
+
"audio-add": "managed",
|
|
149
|
+
"audio-remove": "managed",
|
|
150
|
+
"audio-reload": "managed",
|
|
151
|
+
"video-add": "managed",
|
|
152
|
+
"video-remove": "managed",
|
|
153
|
+
"video-reload": "managed",
|
|
154
|
+
"rescan-external-files": "managed",
|
|
155
|
+
// The picture's overlays and snapshots: plugin.osd, plugin.media.
|
|
156
|
+
"screenshot-raw": "managed",
|
|
157
|
+
"overlay-add": "managed",
|
|
158
|
+
"overlay-remove": "managed",
|
|
159
|
+
"osd-overlay": "managed",
|
|
160
|
+
"show-text": "managed",
|
|
161
|
+
"show-progress": "managed",
|
|
162
|
+
}),
|
|
163
|
+
properties: Object.freeze({
|
|
164
|
+
// Programs (the ytdl hook runs one).
|
|
165
|
+
ytdl: "process",
|
|
166
|
+
"ytdl-format": "process",
|
|
167
|
+
"ytdl-raw-options": "process",
|
|
168
|
+
// Scripts and configuration.
|
|
169
|
+
scripts: "code",
|
|
170
|
+
script: "code",
|
|
171
|
+
"script-opts": "code",
|
|
172
|
+
include: "code",
|
|
173
|
+
profile: "code",
|
|
174
|
+
config: "code",
|
|
175
|
+
"config-dir": "code",
|
|
176
|
+
"use-filedir-conf": "code",
|
|
177
|
+
osc: "code",
|
|
178
|
+
// Control channels.
|
|
179
|
+
wid: "clients",
|
|
180
|
+
// Files the player would write.
|
|
181
|
+
"stream-record": "files",
|
|
182
|
+
"stream-dump": "files",
|
|
183
|
+
"record-file": "files",
|
|
184
|
+
"log-file": "files",
|
|
185
|
+
"dump-stats": "files",
|
|
186
|
+
o: "files",
|
|
187
|
+
"ao-pcm-file": "files",
|
|
188
|
+
"cache-dir": "files",
|
|
189
|
+
"demuxer-cache-dir": "files",
|
|
190
|
+
"icc-cache": "files",
|
|
191
|
+
"icc-cache-dir": "files",
|
|
192
|
+
"gpu-shader-cache": "files",
|
|
193
|
+
"gpu-shader-cache-dir": "files",
|
|
194
|
+
"save-position-on-quit": "files",
|
|
195
|
+
// The player's process and window.
|
|
196
|
+
idle: "quit",
|
|
197
|
+
"keep-open": "quit",
|
|
198
|
+
"keep-open-pause": "quit",
|
|
199
|
+
"force-window": "quit",
|
|
200
|
+
"cursor-autohide": "input",
|
|
201
|
+
// The clipboard.
|
|
202
|
+
clipboard: "clipboard",
|
|
203
|
+
// Playback state: plugin.player.
|
|
204
|
+
pause: "managed",
|
|
205
|
+
speed: "managed",
|
|
206
|
+
volume: "managed",
|
|
207
|
+
mute: "managed",
|
|
208
|
+
// Above the player's volume, or the system mixer's.
|
|
209
|
+
"volume-gain": "managed",
|
|
210
|
+
"ao-volume": "managed",
|
|
211
|
+
"ao-mute": "managed",
|
|
212
|
+
"time-pos": "managed",
|
|
213
|
+
"playback-time": "managed",
|
|
214
|
+
"percent-pos": "managed",
|
|
215
|
+
chapter: "managed",
|
|
216
|
+
edition: "managed",
|
|
217
|
+
start: "managed",
|
|
218
|
+
end: "managed",
|
|
219
|
+
length: "managed",
|
|
220
|
+
loop: "managed",
|
|
221
|
+
"loop-file": "managed",
|
|
222
|
+
"loop-playlist": "managed",
|
|
223
|
+
shuffle: "managed",
|
|
224
|
+
"chapter-list": "managed",
|
|
225
|
+
"ab-loop-a": "managed",
|
|
226
|
+
"ab-loop-b": "managed",
|
|
227
|
+
"ab-loop-count": "managed",
|
|
228
|
+
"audio-device": "managed",
|
|
229
|
+
"audio-delay": "managed",
|
|
230
|
+
"stop-screensaver": "managed",
|
|
231
|
+
// Tracks and their files: plugin.player, plugin.subtitles.
|
|
232
|
+
aid: "managed",
|
|
233
|
+
vid: "managed",
|
|
234
|
+
sid: "managed",
|
|
235
|
+
"secondary-sid": "managed",
|
|
236
|
+
// Which track the next load selects.
|
|
237
|
+
alang: "managed",
|
|
238
|
+
slang: "managed",
|
|
239
|
+
vlang: "managed",
|
|
240
|
+
audio: "managed",
|
|
241
|
+
video: "managed",
|
|
242
|
+
sub: "managed",
|
|
243
|
+
"audio-files": "managed",
|
|
244
|
+
"audio-file-auto": "managed",
|
|
245
|
+
"external-files": "managed",
|
|
246
|
+
"cover-art-auto": "managed",
|
|
247
|
+
"cover-art-files": "managed",
|
|
248
|
+
"audio-display": "managed",
|
|
249
|
+
embeddedfonts: "managed",
|
|
250
|
+
// The filter chains (as a whole), the output and the decoder.
|
|
251
|
+
vf: "managed",
|
|
252
|
+
af: "managed",
|
|
253
|
+
vo: "managed",
|
|
254
|
+
ao: "managed",
|
|
255
|
+
hwdec: "managed",
|
|
256
|
+
"hwdec-software-fallback": "managed",
|
|
257
|
+
"gpu-api": "managed",
|
|
258
|
+
"gpu-context": "managed",
|
|
259
|
+
deinterlace: "managed",
|
|
260
|
+
framedrop: "managed",
|
|
261
|
+
"audio-stream-silence": "managed",
|
|
262
|
+
"lavfi-complex": "managed",
|
|
263
|
+
// The renderer's options: plugin.video.render(), plugin.video.shaders().
|
|
264
|
+
"glsl-shaders": "managed",
|
|
265
|
+
"video-sync": "managed",
|
|
266
|
+
"display-fps-override": "managed",
|
|
267
|
+
"tone-mapping": "managed",
|
|
268
|
+
"gamut-mapping-mode": "managed",
|
|
269
|
+
"hdr-compute-peak": "managed",
|
|
270
|
+
"target-peak": "managed",
|
|
271
|
+
interpolation: "managed",
|
|
272
|
+
// The display layer: plugin.video.view().
|
|
273
|
+
"video-zoom": "managed",
|
|
274
|
+
"video-pan-x": "managed",
|
|
275
|
+
"video-pan-y": "managed",
|
|
276
|
+
"video-aspect-override": "managed",
|
|
277
|
+
"video-rotate": "managed",
|
|
278
|
+
"video-crop": "managed",
|
|
279
|
+
"video-scale-x": "managed",
|
|
280
|
+
"video-scale-y": "managed",
|
|
281
|
+
keepaspect: "managed",
|
|
282
|
+
panscan: "managed",
|
|
283
|
+
// The window: plugin.window.
|
|
284
|
+
fullscreen: "managed",
|
|
285
|
+
fs: "managed",
|
|
286
|
+
ontop: "managed",
|
|
287
|
+
border: "managed",
|
|
288
|
+
title: "managed",
|
|
289
|
+
geometry: "managed",
|
|
290
|
+
"window-scale": "managed",
|
|
291
|
+
"window-minimized": "managed",
|
|
292
|
+
"window-maximized": "managed",
|
|
293
|
+
}),
|
|
294
|
+
propertyPrefixes: Object.freeze({
|
|
295
|
+
"input-ipc-": "clients",
|
|
296
|
+
"input-": "input",
|
|
297
|
+
"load-": "code",
|
|
298
|
+
"clipboard-": "clipboard",
|
|
299
|
+
"screenshot-": "files",
|
|
300
|
+
"watch-later-": "files",
|
|
301
|
+
"playlist-": "managed",
|
|
302
|
+
autofit: "managed",
|
|
303
|
+
// Where the picture sits in the video area: the display layer's.
|
|
304
|
+
"video-align-": "managed",
|
|
305
|
+
// Subtitle selection, files and style: plugin.subtitles.
|
|
306
|
+
"sub-": "managed",
|
|
307
|
+
"secondary-sub-": "managed",
|
|
308
|
+
}),
|
|
309
|
+
reads: Object.freeze(["clipboard"]),
|
|
310
|
+
writers: Object.freeze([
|
|
311
|
+
"set",
|
|
312
|
+
"del",
|
|
313
|
+
"add",
|
|
314
|
+
"multiply",
|
|
315
|
+
"cycle",
|
|
316
|
+
"cycle-values",
|
|
317
|
+
"change-list",
|
|
318
|
+
]),
|
|
319
|
+
filterCommands: Object.freeze({
|
|
320
|
+
vf: Object.freeze(["add", "pre", "toggle", "remove"]),
|
|
321
|
+
af: Object.freeze(["add", "pre", "toggle", "remove"]),
|
|
322
|
+
}),
|
|
323
|
+
filterMessages: Object.freeze(["vf-command", "af-command"]),
|
|
324
|
+
reservedLabel: "vestra-",
|
|
325
|
+
reservedLabels: Object.freeze(["all"]),
|
|
326
|
+
prefixes: Object.freeze([
|
|
327
|
+
"no-osd",
|
|
328
|
+
"osd-bar",
|
|
329
|
+
"osd-msg",
|
|
330
|
+
"osd-msg-bar",
|
|
331
|
+
"osd-auto",
|
|
332
|
+
"expand-properties",
|
|
333
|
+
"raw",
|
|
334
|
+
"repeatable",
|
|
335
|
+
"nonrepeatable",
|
|
336
|
+
"nonscalable",
|
|
337
|
+
"async",
|
|
338
|
+
"sync",
|
|
339
|
+
]),
|
|
340
|
+
});
|
|
341
|
+
/**
|
|
342
|
+
* `invalid` for `vf-command` / `af-command` without a label argument, as
|
|
343
|
+
* the player words it.
|
|
344
|
+
*/
|
|
345
|
+
const MPV_FILTER_MESSAGE_PROBLEM = "vf-command and af-command take a filter label as their first argument";
|
|
346
|
+
/** A command or property name as mpv writes one. */
|
|
347
|
+
const NAME = /^[a-z0-9][a-z0-9/_-]*$/i;
|
|
348
|
+
const LABEL = /^[A-Za-z0-9._-]+$/;
|
|
349
|
+
/** The rule's name of a property: without an options prefix and sub-path. */
|
|
350
|
+
function propertyKey(name) {
|
|
351
|
+
const bare = name.replace(/^(?:file-local-options|options)\//, "");
|
|
352
|
+
return bare.split("/")[0];
|
|
353
|
+
}
|
|
354
|
+
/** The category that refuses a property, for a read or a write; else `null`. */
|
|
355
|
+
function propertyCategory(name, write) {
|
|
356
|
+
const key = propertyKey(name);
|
|
357
|
+
let category = Object.hasOwn(MPV_RULES.properties, key)
|
|
358
|
+
? MPV_RULES.properties[key]
|
|
359
|
+
: undefined;
|
|
360
|
+
if (!category)
|
|
361
|
+
for (const [prefix, each] of Object.entries(MPV_RULES.propertyPrefixes))
|
|
362
|
+
if (key.startsWith(prefix)) {
|
|
363
|
+
category = each;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
if (!category)
|
|
367
|
+
return null;
|
|
368
|
+
return write || MPV_RULES.reads.includes(category) ? category : null;
|
|
369
|
+
}
|
|
370
|
+
const refusal = (what, category) => `${what} is refused: ${MPV_RULES.categories[category]}`;
|
|
371
|
+
/**
|
|
372
|
+
* What is wrong with a property name, as the player words it (`invalid`);
|
|
373
|
+
* `null` when nothing is.
|
|
374
|
+
*
|
|
375
|
+
* @internal
|
|
376
|
+
*/
|
|
377
|
+
export function mpvNameProblem(name) {
|
|
378
|
+
return typeof name === "string" &&
|
|
379
|
+
name.length <= MPV_LIMITS.nameChars &&
|
|
380
|
+
NAME.test(name)
|
|
381
|
+
? null
|
|
382
|
+
: `a property name is 1–${MPV_LIMITS.nameChars} characters of letters, digits, "-", "_" and "/"`;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* What is wrong with a command's shape, as the player words it (`invalid`);
|
|
386
|
+
* `null` when nothing is. The first element is the command's name, the
|
|
387
|
+
* others its arguments: strings, numbers or booleans.
|
|
388
|
+
*
|
|
389
|
+
* @internal
|
|
390
|
+
*/
|
|
391
|
+
export function mpvCommandProblem(args) {
|
|
392
|
+
if (!Array.isArray(args) || args.length < 1 || args.length > MPV_LIMITS.args)
|
|
393
|
+
return `a command is an array of 1–${MPV_LIMITS.args} elements, its name first`;
|
|
394
|
+
const [name, ...rest] = args;
|
|
395
|
+
if (typeof name !== "string" ||
|
|
396
|
+
name.length > MPV_LIMITS.nameChars ||
|
|
397
|
+
!NAME.test(name) ||
|
|
398
|
+
// mpv would take the prefix off and run the next element.
|
|
399
|
+
MPV_RULES.prefixes.includes(commandKey(name)))
|
|
400
|
+
return "a command's first element is its name (no prefixes such as no-osd or async)";
|
|
401
|
+
for (const each of rest)
|
|
402
|
+
if (typeof each !== "string" &&
|
|
403
|
+
typeof each !== "boolean" &&
|
|
404
|
+
!(typeof each === "number" && Number.isFinite(each)))
|
|
405
|
+
return "a command's arguments are strings, finite numbers or booleans";
|
|
406
|
+
// A message to a filter names the filter: without a label there is
|
|
407
|
+
// nothing to check the owner of.
|
|
408
|
+
if (MPV_RULES.filterMessages.includes(commandKey(name)) &&
|
|
409
|
+
typeof rest[0] !== "string")
|
|
410
|
+
return MPV_FILTER_MESSAGE_PROBLEM;
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Why the pass-through refuses a property (`refused`), as the player words
|
|
415
|
+
* it; `null` when it does not.
|
|
416
|
+
*
|
|
417
|
+
* @param name - The property, as given.
|
|
418
|
+
* @param write - A write (`set`); a read is refused only for the
|
|
419
|
+
* categories of `MPV_RULES.reads`.
|
|
420
|
+
*
|
|
421
|
+
* @internal
|
|
422
|
+
*/
|
|
423
|
+
export function mpvPropertyRefusal(name, write) {
|
|
424
|
+
const category = propertyCategory(name, write);
|
|
425
|
+
return category
|
|
426
|
+
? refusal(`mpv property ${JSON.stringify(name)}`, category)
|
|
427
|
+
: null;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* The label of a filter value: `@label` or `@label:…`; `null` without
|
|
431
|
+
* one a plugin may have (the player's own start, a reserved word).
|
|
432
|
+
*/
|
|
433
|
+
function filterLabel(value) {
|
|
434
|
+
if (typeof value !== "string" || !value.startsWith("@"))
|
|
435
|
+
return null;
|
|
436
|
+
const label = value.slice(1).split(":")[0];
|
|
437
|
+
return label.length >= 1 &&
|
|
438
|
+
label.length <= MPV_LIMITS.labelChars &&
|
|
439
|
+
LABEL.test(label) &&
|
|
440
|
+
!label.startsWith(MPV_RULES.reservedLabel) &&
|
|
441
|
+
!MPV_RULES.reservedLabels.includes(label)
|
|
442
|
+
? label
|
|
443
|
+
: null;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* A command's name as the tables have it: mpv reads `_` in a command's
|
|
447
|
+
* name as `-` (`cycle_values` runs `cycle-values`). Nothing else is
|
|
448
|
+
* folded: mpv does not accept another case.
|
|
449
|
+
*/
|
|
450
|
+
const commandKey = (name) => name.replaceAll("_", "-");
|
|
451
|
+
/**
|
|
452
|
+
* Why the pass-through refuses a command (`refused`), as the player words
|
|
453
|
+
* it; `null` when it does not. The command's shape is checked first
|
|
454
|
+
* ({@link mpvCommandProblem}).
|
|
455
|
+
*
|
|
456
|
+
* What only the player can tell is left to it: whether a label belongs to
|
|
457
|
+
* another plugin, and whether a filter value holds more than the one
|
|
458
|
+
* labelled filter (it compares the chain before and after).
|
|
459
|
+
*
|
|
460
|
+
* @internal
|
|
461
|
+
*/
|
|
462
|
+
export function mpvCommandRefusal(args) {
|
|
463
|
+
// Looked up as mpv reads it; shown as the caller wrote it.
|
|
464
|
+
const name = commandKey(String(args[0]));
|
|
465
|
+
const shown = `mpv command ${JSON.stringify(String(args[0]))}`;
|
|
466
|
+
if (Object.hasOwn(MPV_RULES.commands, name))
|
|
467
|
+
return refusal(shown, MPV_RULES.commands[name]);
|
|
468
|
+
if (MPV_RULES.writers.includes(name)) {
|
|
469
|
+
const target = name === "cycle-values" && args[1] === "!reverse" ? args[2] : args[1];
|
|
470
|
+
return typeof target === "string" ? mpvPropertyRefusal(target, true) : null;
|
|
471
|
+
}
|
|
472
|
+
if (Object.hasOwn(MPV_RULES.filterCommands, name))
|
|
473
|
+
return MPV_RULES.filterCommands[name].includes(String(args[1])) &&
|
|
474
|
+
filterLabel(args[2]) !== null
|
|
475
|
+
? null
|
|
476
|
+
: refusal(shown, "filters");
|
|
477
|
+
if (MPV_RULES.filterMessages.includes(name))
|
|
478
|
+
return filterLabel(`@${String(args[1])}`) !== null
|
|
479
|
+
? null
|
|
480
|
+
: refusal(shown, "filters");
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* The label a filter command adds or removes, for the owner's book:
|
|
485
|
+
* `["vf", "add", "@smooth:…"]` → `{ stage: "vf", operation: "add", label:
|
|
486
|
+
* "smooth" }`; `null` for any other command.
|
|
487
|
+
*
|
|
488
|
+
* @internal
|
|
489
|
+
*/
|
|
490
|
+
export function mpvFilterChange(args) {
|
|
491
|
+
const stage = commandKey(String(args[0]));
|
|
492
|
+
if (!Object.hasOwn(MPV_RULES.filterCommands, stage))
|
|
493
|
+
return null;
|
|
494
|
+
const label = filterLabel(args[2]);
|
|
495
|
+
return label === null ? null : { stage, operation: String(args[1]), label };
|
|
496
|
+
}
|
package/dist/player-runtime.d.ts
CHANGED
|
@@ -11,13 +11,13 @@ export { createPlugin } from "./plugin/index.ts";
|
|
|
11
11
|
export type { PluginInstance, PluginManifest, RuntimeOptions, } from "./plugin/index.ts";
|
|
12
12
|
export { HostError } from "./wire.ts";
|
|
13
13
|
export type { Json, Transport } from "./wire.ts";
|
|
14
|
-
export { API_VERSION,
|
|
15
|
-
export { HOST_CAPABILITIES } from "./host-capabilities.ts";
|
|
14
|
+
export { API_VERSION, MESSAGE_LIMIT } from "./protocol.ts";
|
|
16
15
|
export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "./commands.ts";
|
|
17
16
|
export { BINDING_INPUTS } from "./plugin/bindings.ts";
|
|
18
17
|
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.ts";
|
|
19
18
|
export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.ts";
|
|
20
|
-
export { COMMAND_RUN_LIMITS } from "./commands.ts";
|
|
19
|
+
export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from "./commands.ts";
|
|
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
23
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
|
package/dist/player-runtime.js
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export { createPlugin } from "./plugin/index.js";
|
|
11
11
|
export { HostError } from "./wire.js";
|
|
12
|
-
export { API_VERSION,
|
|
13
|
-
export { HOST_CAPABILITIES } from "./host-capabilities.js";
|
|
12
|
+
export { API_VERSION, MESSAGE_LIMIT } from "./protocol.js";
|
|
14
13
|
export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "./commands.js";
|
|
15
14
|
export { BINDING_INPUTS } from "./plugin/bindings.js";
|
|
16
15
|
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.js";
|
|
17
16
|
export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.js";
|
|
18
|
-
export { COMMAND_RUN_LIMITS } from "./commands.js";
|
|
17
|
+
export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from "./commands.js";
|
|
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
21
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
|
|
@@ -5,7 +5,7 @@ import type { Appearance, LanguagePreference, ThemeId } from "./types.ts";
|
|
|
5
5
|
export declare const THEMES: readonly ThemeId[];
|
|
6
6
|
/**
|
|
7
7
|
* One per plugin: the value comes with the `window.state` read before
|
|
8
|
-
* activation;
|
|
8
|
+
* activation; after `plugin.player.subscribe()`, `appearance.changed` keeps it current once
|
|
9
9
|
* the plugin uses it (or listens to that event with `player.on`).
|
|
10
10
|
*/
|
|
11
11
|
declare class AppearanceService {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The player's palette (`plugin.appearance
|
|
1
|
+
/** The player's palette (`plugin.appearance`). */
|
|
2
2
|
import { failure } from "./errors.js";
|
|
3
3
|
import { windowOf } from "./window.js";
|
|
4
4
|
import { LOCALES } from "../i18n.js";
|
|
@@ -9,7 +9,7 @@ const preference = (value) => value === "system" || LOCALES.includes(value)
|
|
|
9
9
|
export const THEMES = ["vestra", "vestra-light"];
|
|
10
10
|
/**
|
|
11
11
|
* One per plugin: the value comes with the `window.state` read before
|
|
12
|
-
* activation;
|
|
12
|
+
* activation; after `plugin.player.subscribe()`, `appearance.changed` keeps it current once
|
|
13
13
|
* the plugin uses it (or listens to that event with `player.on`).
|
|
14
14
|
*/
|
|
15
15
|
class AppearanceService {
|
|
@@ -76,7 +76,7 @@ export declare const BINDING_INPUTS: Readonly<{
|
|
|
76
76
|
/** Throws `invalid` unless `text` is a canonical binding; returns it unchanged. */
|
|
77
77
|
export declare function canonical(text: string): string;
|
|
78
78
|
export declare function checkBindings(bindings: readonly string[]): string[];
|
|
79
|
-
/** `plugin.bindings
|
|
79
|
+
/** `plugin.bindings`: the table and the user overlay. */
|
|
80
80
|
export declare const bindingsApi: (scope: ScopeImpl) => Bindings;
|
|
81
81
|
/**
|
|
82
82
|
* How the player's menus write a canonical binding (`bindings.rs`
|
package/dist/plugin/bindings.js
CHANGED
|
@@ -177,7 +177,7 @@ const reference = (ref) => {
|
|
|
177
177
|
throw failure("invalid", "a binding ref names plugin and command");
|
|
178
178
|
return { plugin: ref.plugin, command: ref.command };
|
|
179
179
|
};
|
|
180
|
-
/** `plugin.bindings
|
|
180
|
+
/** `plugin.bindings`: the table and the user overlay. */
|
|
181
181
|
export const bindingsApi = (scope) => ({
|
|
182
182
|
async list() {
|
|
183
183
|
const table = await scope.runtime.host.bindings.list();
|
|
@@ -209,7 +209,7 @@ export const bindingsApi = (scope) => ({
|
|
|
209
209
|
await scope.runtime.host.bindings.reset(ref === undefined ? undefined : reference(ref));
|
|
210
210
|
},
|
|
211
211
|
onChange(listener) {
|
|
212
|
-
const watch = scope.runtime.on("bindings.changed", () => scope.run(listener),
|
|
212
|
+
const watch = scope.runtime.on("bindings.changed", () => scope.run(listener), null);
|
|
213
213
|
return scope.add({
|
|
214
214
|
dispose: async () => {
|
|
215
215
|
scope.forget(watch);
|
package/dist/plugin/commands.js
CHANGED
|
@@ -304,10 +304,7 @@ class KeysService {
|
|
|
304
304
|
return;
|
|
305
305
|
this.#started = true;
|
|
306
306
|
const runtime = this.#runtime;
|
|
307
|
-
|
|
308
|
-
if (!runtime.can("commands"))
|
|
309
|
-
return;
|
|
310
|
-
runtime.on(KEYS, (data) => this.#accept(data), "commands", true);
|
|
307
|
+
runtime.on(KEYS, (data) => this.#accept(data), null, true);
|
|
311
308
|
// Subscribed first: a change after this answer comes as an event.
|
|
312
309
|
runtime.host.commands.keys().then((answer) => this.#accept(answer),
|
|
313
310
|
// `unsupported`: no keys, as without a binding.
|
|
@@ -359,11 +356,9 @@ export const commands = (scope) => ({
|
|
|
359
356
|
return service.get(id);
|
|
360
357
|
},
|
|
361
358
|
list: async () => {
|
|
362
|
-
needs(scope, "commands.run");
|
|
363
359
|
return scope.runtime.host.commands.list();
|
|
364
360
|
},
|
|
365
361
|
async run(id, options) {
|
|
366
|
-
needs(scope, "commands.run");
|
|
367
362
|
if (typeof id !== "string" || id === "")
|
|
368
363
|
throw failure("invalid", "run takes a command id: <plugin>/<id>");
|
|
369
364
|
const { ticket, step, of, then } = (options ?? {});
|
|
@@ -394,11 +389,6 @@ export const commands = (scope) => ({
|
|
|
394
389
|
});
|
|
395
390
|
},
|
|
396
391
|
});
|
|
397
|
-
/** Refuse at once without `capability`, as the player does. */
|
|
398
|
-
function needs(scope, capability) {
|
|
399
|
-
if (!scope.runtime.can(capability))
|
|
400
|
-
throw failure("capability", `${capability} must be declared in manifest`);
|
|
401
|
-
}
|
|
402
392
|
// ---------------------------------------------------------------- palette lead
|
|
403
393
|
/** `PaletteLeadOptions` checked and in wire form; the player checks lengths. */
|
|
404
394
|
function leadJson(options) {
|
|
@@ -423,8 +413,11 @@ function leadJson(options) {
|
|
|
423
413
|
...(status.note === undefined
|
|
424
414
|
? {}
|
|
425
415
|
: { note: text(status.note, "status.note") }),
|
|
426
|
-
// Sent only when set (players before
|
|
427
|
-
// player checks the
|
|
416
|
+
// Sent only when set (players before them refuse the fields); the
|
|
417
|
+
// player checks the values.
|
|
418
|
+
...(status.strip === undefined
|
|
419
|
+
? {}
|
|
420
|
+
: { strip: text(status.strip, "status.strip") }),
|
|
428
421
|
...(status.state === undefined ? {} : { state: status.state }),
|
|
429
422
|
};
|
|
430
423
|
}
|
|
@@ -438,7 +431,6 @@ class LeadHandle {
|
|
|
438
431
|
#event;
|
|
439
432
|
#disposed = false;
|
|
440
433
|
constructor(scope, options) {
|
|
441
|
-
needs(scope, "palette.lead");
|
|
442
434
|
const first = leadJson(options);
|
|
443
435
|
this.#scope = scope;
|
|
444
436
|
const host = scope.runtime.host.palette;
|