@vestra-player/sdk 1.7.19 → 1.8.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 +38 -0
- package/bin/vestra-plugin.mjs +128 -0
- package/capability-scan.json +367 -0
- package/dist/api-requests.js +4 -0
- package/dist/capability-check.d.ts +43 -0
- package/dist/capability-check.js +90 -0
- package/dist/capability-scan.d.ts +95 -0
- package/dist/capability-scan.js +250 -0
- package/dist/commands.d.ts +35 -0
- package/dist/commands.js +42 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +15 -0
- package/dist/mpv.d.ts +139 -0
- package/dist/mpv.js +496 -0
- package/dist/player-runtime.d.ts +2 -1
- package/dist/player-runtime.js +2 -1
- package/dist/plugin/commands.js +5 -2
- package/dist/plugin/mpv.d.ts +3 -0
- package/dist/plugin/mpv.js +98 -0
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -0
- package/dist/plugin/testing/commands.js +37 -9
- package/dist/plugin/testing/index.d.ts +52 -1
- package/dist/plugin/testing/index.js +55 -0
- package/dist/plugin/testing/mpv.d.ts +7 -0
- package/dist/plugin/testing/mpv.js +90 -0
- package/dist/plugin/types/base.d.ts +9 -2
- package/dist/plugin/types/commands.d.ts +34 -10
- package/dist/plugin/types/playback.d.ts +185 -0
- package/dist/plugin/types/processing.d.ts +11 -3
- package/dist/wire.d.ts +16 -1
- package/dist/wire.js +11 -0
- package/llms.txt +2 -2
- package/package.json +4 -2
- package/slint/vestra/widgets.slint +12 -4
package/dist/mpv.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
* Why `plugin.mpv` refuses a command or a property: the boundary it would
|
|
13
|
+
* cross. A key of `MPV_RULES.categories`.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export type MpvRefusalCategory = "process" | "code" | "clients" | "files" | "quit" | "input" | "clipboard" | "managed" | "filters";
|
|
18
|
+
/**
|
|
19
|
+
* The limits of `plugin.mpv`, the same values as the player's (its
|
|
20
|
+
* agreement test checks that they agree). Internal: exported from
|
|
21
|
+
* `@vestra-player/sdk/runtime` only; [mpv](../docs/reference/mpv.md) shows
|
|
22
|
+
* them.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const MPV_LIMITS: Readonly<{
|
|
27
|
+
/** Elements of one command, its name included (32). */
|
|
28
|
+
args: 32;
|
|
29
|
+
/** Characters of a command or property name (128). */
|
|
30
|
+
nameChars: 128;
|
|
31
|
+
/** Characters of a filter label, after the `@` (64). */
|
|
32
|
+
labelChars: 64;
|
|
33
|
+
/** Different properties one plugin observes at the same time (64). */
|
|
34
|
+
observed: 64;
|
|
35
|
+
/** A property's changes reach an observer at most this often; the newest value wins (100 ms). */
|
|
36
|
+
observeIntervalMs: 100;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* What `plugin.mpv` refuses, as data: the same table as the player's. A
|
|
40
|
+
* command or property not named here goes to mpv as it is.
|
|
41
|
+
*
|
|
42
|
+
* - `categories`: one sentence per category, the end of the refusal's
|
|
43
|
+
* message.
|
|
44
|
+
* - `commands`: mpv commands by name.
|
|
45
|
+
* - `properties`: mpv properties and options by name (the part before the
|
|
46
|
+
* first `/`, after an `options/` or `file-local-options/` prefix);
|
|
47
|
+
* `propertyPrefixes`: by the start of the name, checked after
|
|
48
|
+
* `properties`. A write is refused; a read too for the categories of
|
|
49
|
+
* `reads`.
|
|
50
|
+
* - `writers`: commands that write the property their first argument
|
|
51
|
+
* names (`cycle-values` after an optional `!reverse`); they are checked
|
|
52
|
+
* as a write of it.
|
|
53
|
+
* - `filterCommands`: the filter chain commands and the operations a
|
|
54
|
+
* plugin may use, on its own labelled filters only; `filterMessages`:
|
|
55
|
+
* commands whose first argument is a filter label, which must be the
|
|
56
|
+
* plugin's own; `reservedLabel`: the start of the player's own labels;
|
|
57
|
+
* `reservedLabels`: whole labels that are not a plugin's (`all`, which
|
|
58
|
+
* mpv reads as every filter of the chain).
|
|
59
|
+
*
|
|
60
|
+
* - `prefixes`: mpv's command prefix words (mpv 0.41 `input/cmd.c`,
|
|
61
|
+
* `cmd_flags`, in its order). mpv takes them off the front of a
|
|
62
|
+
* command, in the array form too, and runs what follows: a command whose
|
|
63
|
+
* first element is one is `invalid`, so the name the tables check is
|
|
64
|
+
* the command mpv runs. Only the first element: later, the same words
|
|
65
|
+
* are ordinary arguments.
|
|
66
|
+
*
|
|
67
|
+
* A command's name is looked up with `_` read as `-`, as mpv reads it
|
|
68
|
+
* (`cycle_values` is `cycle-values`); a refusal names it as the caller
|
|
69
|
+
* wrote it. A property's name is looked up as written: mpv does not fold
|
|
70
|
+
* it.
|
|
71
|
+
*
|
|
72
|
+
* Internal: exported from `@vestra-player/sdk/runtime` only; the tables of
|
|
73
|
+
* [mpv](../docs/reference/mpv.md) are generated from it.
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export declare const MPV_RULES: {
|
|
78
|
+
readonly categories: Readonly<Record<MpvRefusalCategory, string>>;
|
|
79
|
+
readonly commands: Readonly<Record<string, MpvRefusalCategory>>;
|
|
80
|
+
readonly properties: Readonly<Record<string, MpvRefusalCategory>>;
|
|
81
|
+
readonly propertyPrefixes: Readonly<Record<string, MpvRefusalCategory>>;
|
|
82
|
+
readonly reads: readonly MpvRefusalCategory[];
|
|
83
|
+
readonly writers: readonly string[];
|
|
84
|
+
readonly filterCommands: Readonly<Record<string, readonly string[]>>;
|
|
85
|
+
readonly filterMessages: readonly string[];
|
|
86
|
+
readonly reservedLabel: string;
|
|
87
|
+
readonly reservedLabels: readonly string[];
|
|
88
|
+
readonly prefixes: readonly string[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* What is wrong with a property name, as the player words it (`invalid`);
|
|
92
|
+
* `null` when nothing is.
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
export declare function mpvNameProblem(name: unknown): string | null;
|
|
97
|
+
/**
|
|
98
|
+
* What is wrong with a command's shape, as the player words it (`invalid`);
|
|
99
|
+
* `null` when nothing is. The first element is the command's name, the
|
|
100
|
+
* others its arguments: strings, numbers or booleans.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
export declare function mpvCommandProblem(args: unknown): string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Why the pass-through refuses a property (`refused`), as the player words
|
|
107
|
+
* it; `null` when it does not.
|
|
108
|
+
*
|
|
109
|
+
* @param name - The property, as given.
|
|
110
|
+
* @param write - A write (`set`); a read is refused only for the
|
|
111
|
+
* categories of `MPV_RULES.reads`.
|
|
112
|
+
*
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
export declare function mpvPropertyRefusal(name: string, write: boolean): string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Why the pass-through refuses a command (`refused`), as the player words
|
|
118
|
+
* it; `null` when it does not. The command's shape is checked first
|
|
119
|
+
* ({@link mpvCommandProblem}).
|
|
120
|
+
*
|
|
121
|
+
* What only the player can tell is left to it: whether a label belongs to
|
|
122
|
+
* another plugin, and whether a filter value holds more than the one
|
|
123
|
+
* labelled filter (it compares the chain before and after).
|
|
124
|
+
*
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare function mpvCommandRefusal(args: readonly (string | number | boolean)[]): string | null;
|
|
128
|
+
/**
|
|
129
|
+
* The label a filter command adds or removes, for the owner's book:
|
|
130
|
+
* `["vf", "add", "@smooth:…"]` → `{ stage: "vf", operation: "add", label:
|
|
131
|
+
* "smooth" }`; `null` for any other command.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
export declare function mpvFilterChange(args: readonly (string | number | boolean)[]): {
|
|
136
|
+
stage: string;
|
|
137
|
+
operation: string;
|
|
138
|
+
label: string;
|
|
139
|
+
} | null;
|
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
|
@@ -17,7 +17,8 @@ export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS
|
|
|
17
17
|
export { BINDING_INPUTS } from "./plugin/bindings.ts";
|
|
18
18
|
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.ts";
|
|
19
19
|
export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.ts";
|
|
20
|
-
export { COMMAND_RUN_LIMITS } from "./commands.ts";
|
|
20
|
+
export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from "./commands.ts";
|
|
21
|
+
export { MPV_LIMITS, MPV_RULES } from "./mpv.ts";
|
|
21
22
|
export { OSD_LIMITS } from "./plugin/osd.ts";
|
|
22
23
|
export { TIMELINE_LIMITS } from "./plugin/timeline.ts";
|
|
23
24
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
|
package/dist/player-runtime.js
CHANGED
|
@@ -15,7 +15,8 @@ export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS
|
|
|
15
15
|
export { BINDING_INPUTS } from "./plugin/bindings.js";
|
|
16
16
|
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.js";
|
|
17
17
|
export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.js";
|
|
18
|
-
export { COMMAND_RUN_LIMITS } from "./commands.js";
|
|
18
|
+
export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from "./commands.js";
|
|
19
|
+
export { MPV_LIMITS, MPV_RULES } from "./mpv.js";
|
|
19
20
|
export { OSD_LIMITS } from "./plugin/osd.js";
|
|
20
21
|
export { TIMELINE_LIMITS } from "./plugin/timeline.js";
|
|
21
22
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
|
package/dist/plugin/commands.js
CHANGED
|
@@ -423,8 +423,11 @@ function leadJson(options) {
|
|
|
423
423
|
...(status.note === undefined
|
|
424
424
|
? {}
|
|
425
425
|
: { note: text(status.note, "status.note") }),
|
|
426
|
-
// Sent only when set (players before
|
|
427
|
-
// player checks the
|
|
426
|
+
// Sent only when set (players before them refuse the fields); the
|
|
427
|
+
// player checks the values.
|
|
428
|
+
...(status.strip === undefined
|
|
429
|
+
? {}
|
|
430
|
+
: { strip: text(status.strip, "status.strip") }),
|
|
428
431
|
...(status.state === undefined ? {} : { state: status.state }),
|
|
429
432
|
};
|
|
430
433
|
}
|