@vestra-player/sdk 1.8.0 → 1.10.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 +64 -2
- package/README.md +2 -2
- package/bin/vestra-plugin.mjs +98 -106
- package/capability-scan.json +21 -1
- package/dist/api-requests.d.ts +15 -39
- package/dist/api-requests.js +28 -50
- package/dist/capability-scan.d.ts +1 -1
- package/dist/capability-scan.js +8 -9
- 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/docs.d.ts +1 -1
- package/dist/docs.js +1 -1
- package/dist/i18n-tools.d.ts +7 -0
- package/dist/i18n-tools.js +66 -3
- 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/player-runtime.d.ts +4 -2
- package/dist/player-runtime.js +4 -2
- 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 +1 -12
- package/dist/plugin/connection.d.ts +38 -8
- package/dist/plugin/connection.js +126 -37
- package/dist/plugin/drops.js +1 -1
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +22 -15
- package/dist/plugin/media.js +0 -12
- package/dist/plugin/mpv.js +39 -12
- package/dist/plugin/packages.js +1 -2
- package/dist/plugin/player/events.d.ts +17 -7
- package/dist/plugin/player/events.js +26 -9
- package/dist/plugin/player.d.ts +37 -13
- package/dist/plugin/player.js +133 -22
- package/dist/plugin/scope.d.ts +4 -1
- package/dist/plugin/scope.js +8 -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 +24 -37
- package/dist/plugin/testing/index.d.ts +133 -116
- package/dist/plugin/testing/index.js +198 -125
- package/dist/plugin/testing/media.d.ts +6 -0
- package/dist/plugin/testing/media.js +15 -2
- package/dist/plugin/testing/processing.js +1 -1
- package/dist/plugin/testing/services.js +0 -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 +5 -6
- package/dist/plugin/timeline.js +7 -11
- package/dist/plugin/triggers.d.ts +55 -0
- package/dist/plugin/triggers.js +233 -0
- package/dist/plugin/types/base.d.ts +77 -87
- package/dist/plugin/types/commands.d.ts +384 -68
- package/dist/plugin/types/packages.d.ts +17 -55
- package/dist/plugin/types/playback.d.ts +382 -152
- 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/when.d.ts +78 -4
- package/dist/plugin/when.js +182 -14
- 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/slint-version.d.ts +7 -0
- package/dist/slint-version.js +7 -0
- 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 +6 -6
- package/package.json +1 -2
- package/dist/capabilities.d.ts +0 -107
- package/dist/capabilities.js +0 -69
- package/dist/capability-check.d.ts +0 -176
- package/dist/capability-check.js +0 -461
- 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 -492
package/dist/plugin/when.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LOCALES } from "../i18n.js";
|
|
2
2
|
import { THEMES } from "./appearance.js";
|
|
3
|
+
import { failure } from "./errors.js";
|
|
4
|
+
import { TIMELINE_LIMITS } from "./timeline.js";
|
|
3
5
|
const PHASES = [
|
|
4
6
|
"empty",
|
|
5
7
|
"loading",
|
|
@@ -51,7 +53,83 @@ export function conditionJson(condition) {
|
|
|
51
53
|
throw new TypeError("a condition comes from plugin.when");
|
|
52
54
|
return ConditionImpl.json(condition);
|
|
53
55
|
}
|
|
56
|
+
/** Whether a wire condition reads the position or the clock (a trigger's only). */
|
|
57
|
+
export function readsPositionOrTime(json) {
|
|
58
|
+
if ("position" in json || "time" in json)
|
|
59
|
+
return true;
|
|
60
|
+
if ("all" in json)
|
|
61
|
+
return json.all.some(readsPositionOrTime);
|
|
62
|
+
if ("any" in json)
|
|
63
|
+
return json.any.some(readsPositionOrTime);
|
|
64
|
+
if ("not" in json)
|
|
65
|
+
return readsPositionOrTime(json.not);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/** How many position lists a wire condition has (at most one is allowed). */
|
|
69
|
+
export function positionLists(json) {
|
|
70
|
+
if ("position" in json)
|
|
71
|
+
return 1;
|
|
72
|
+
if ("all" in json)
|
|
73
|
+
return json.all.reduce((n, c) => n + positionLists(c), 0);
|
|
74
|
+
if ("any" in json)
|
|
75
|
+
return json.any.reduce((n, c) => n + positionLists(c), 0);
|
|
76
|
+
if ("not" in json)
|
|
77
|
+
return positionLists(json.not);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
54
80
|
const make = (json) => new ConditionImpl(json);
|
|
81
|
+
const finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
82
|
+
/** A numeric atom's `{ min?, max? }`, checked. */
|
|
83
|
+
function interval(name, bounds) {
|
|
84
|
+
const shape = `${name} takes { min?, max? }: finite numbers, at least one, min < max`;
|
|
85
|
+
if (!bounds || typeof bounds !== "object")
|
|
86
|
+
throw new TypeError(shape);
|
|
87
|
+
const { min, max, ...rest } = bounds;
|
|
88
|
+
if (Object.keys(rest).length)
|
|
89
|
+
throw new TypeError(shape);
|
|
90
|
+
if (min === undefined && max === undefined)
|
|
91
|
+
throw new TypeError(shape);
|
|
92
|
+
if ((min !== undefined && !finite(min)) ||
|
|
93
|
+
(max !== undefined && !finite(max)))
|
|
94
|
+
throw new TypeError(shape);
|
|
95
|
+
if (finite(min) && finite(max) && min >= max)
|
|
96
|
+
throw new TypeError(shape);
|
|
97
|
+
const json = {};
|
|
98
|
+
if (min !== undefined)
|
|
99
|
+
json.min = min;
|
|
100
|
+
if (max !== undefined)
|
|
101
|
+
json.max = max;
|
|
102
|
+
return json;
|
|
103
|
+
}
|
|
104
|
+
function identity(name, id) {
|
|
105
|
+
if (typeof id !== "string" || id.length === 0 || id.length > 256)
|
|
106
|
+
throw new TypeError(`${name} takes an id (a string of 1–256 characters)`);
|
|
107
|
+
return id;
|
|
108
|
+
}
|
|
109
|
+
/** `when.position.in`'s ranges and lead in the wire form. */
|
|
110
|
+
function positionList(ranges, options = {}) {
|
|
111
|
+
const list = [...(ranges ?? [])];
|
|
112
|
+
if (list.length > TIMELINE_LIMITS.ranges)
|
|
113
|
+
throw failure("limit", `a position list holds at most ${TIMELINE_LIMITS.ranges} ranges`);
|
|
114
|
+
const pairs = list.map((range) => {
|
|
115
|
+
const { start, end } = (range ?? {});
|
|
116
|
+
if (!finite(start) || start < 0)
|
|
117
|
+
throw new TypeError("a range starts at a finite number of seconds, 0 or more");
|
|
118
|
+
if (end === undefined || end === null)
|
|
119
|
+
return [start];
|
|
120
|
+
if (!finite(end) || end <= start)
|
|
121
|
+
throw new TypeError("a range ends after its start");
|
|
122
|
+
return [start, end];
|
|
123
|
+
});
|
|
124
|
+
const json = { ranges: pairs };
|
|
125
|
+
const lead = options?.lead;
|
|
126
|
+
if (lead !== undefined) {
|
|
127
|
+
if (!finite(lead) || lead < 0)
|
|
128
|
+
throw new TypeError("lead is a number of seconds, 0 or more");
|
|
129
|
+
json.lead = lead;
|
|
130
|
+
}
|
|
131
|
+
return json;
|
|
132
|
+
}
|
|
55
133
|
/** The one `plugin.when` (conditions hold no plugin state). */
|
|
56
134
|
export const WHEN = Object.freeze({
|
|
57
135
|
open: make({ not: { phase: ["empty"] } }),
|
|
@@ -60,6 +138,10 @@ export const WHEN = Object.freeze({
|
|
|
60
138
|
paused: make({ all: [{ phase: ["ready"] }, { paused: true }] }),
|
|
61
139
|
stream: make({ kind: "stream" }),
|
|
62
140
|
fullscreen: make({ fullscreen: true }),
|
|
141
|
+
muted: make({ muted: true }),
|
|
142
|
+
maximized: make({ maximized: true }),
|
|
143
|
+
pip: make({ pip: true }),
|
|
144
|
+
looping: make({ looping: true }),
|
|
63
145
|
phase(...phases) {
|
|
64
146
|
if (!phases.length || phases.some((phase) => !PHASES.includes(phase)))
|
|
65
147
|
throw new TypeError(`phase is one or more of ${PHASES.join(", ")}`);
|
|
@@ -81,26 +163,112 @@ export const WHEN = Object.freeze({
|
|
|
81
163
|
throw new TypeError(`language is "system" or one of ${LOCALES.map((l) => `"${l}"`).join(", ")}`);
|
|
82
164
|
return make({ language });
|
|
83
165
|
},
|
|
166
|
+
duration: (bounds) => make({ duration: interval("duration", bounds) }),
|
|
167
|
+
volume: (bounds) => make({ volume: interval("volume", bounds) }),
|
|
168
|
+
rate: (bounds) => make({ rate: interval("rate", bounds) }),
|
|
169
|
+
time: (bounds) => make({ time: interval("time", bounds) }),
|
|
170
|
+
audioTrack(id) {
|
|
171
|
+
if (!Number.isInteger(id))
|
|
172
|
+
throw new TypeError("audioTrack takes a track id (an integer)");
|
|
173
|
+
return make({ audioTrack: id });
|
|
174
|
+
},
|
|
175
|
+
subtitleTrack: (id) => make({ subtitleTrack: identity("subtitleTrack", id) }),
|
|
176
|
+
audioDevice: (id) => make({ audioDevice: identity("audioDevice", id) }),
|
|
177
|
+
position: Object.freeze({
|
|
178
|
+
in: (ranges, options) => make({ position: positionList(ranges, options) }),
|
|
179
|
+
}),
|
|
84
180
|
});
|
|
85
|
-
/**
|
|
86
|
-
|
|
181
|
+
/**
|
|
182
|
+
* The range of `list` the position `at` is in (`start − lead ≤ at < end`):
|
|
183
|
+
* the earliest start when several are, as the player does.
|
|
184
|
+
*/
|
|
185
|
+
export function matchedRange(list, at) {
|
|
186
|
+
const lead = list.lead ?? 0;
|
|
187
|
+
let found = null;
|
|
188
|
+
let earliest = Infinity;
|
|
189
|
+
list.ranges.forEach(([start, end], index) => {
|
|
190
|
+
const from = start - lead;
|
|
191
|
+
if (from <= at && at < (end ?? Infinity) && from < earliest) {
|
|
192
|
+
earliest = from;
|
|
193
|
+
found = index;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return found;
|
|
197
|
+
}
|
|
198
|
+
/** Evaluate a wire condition as the player does, with its range (the test host). */
|
|
199
|
+
export function evaluateTruth(json, facts) {
|
|
200
|
+
const plain = (holds) => ({ holds, range: null });
|
|
201
|
+
const inside = (bounds, value) => typeof value === "number" &&
|
|
202
|
+
(bounds.min === undefined || bounds.min <= value) &&
|
|
203
|
+
(bounds.max === undefined || value < bounds.max);
|
|
87
204
|
if ("phase" in json)
|
|
88
|
-
return json.phase.includes(facts.phase);
|
|
205
|
+
return plain(json.phase.includes(facts.phase));
|
|
89
206
|
if ("paused" in json)
|
|
90
|
-
return facts.paused === json.paused;
|
|
207
|
+
return plain(facts.paused === json.paused);
|
|
91
208
|
if ("kind" in json)
|
|
92
|
-
return facts.kind === json.kind;
|
|
209
|
+
return plain(facts.kind === json.kind);
|
|
93
210
|
if ("can" in json)
|
|
94
|
-
return facts.can[json.can] === true;
|
|
211
|
+
return plain(facts.can[json.can] === true);
|
|
95
212
|
if ("fullscreen" in json)
|
|
96
|
-
return facts.fullscreen === json.fullscreen;
|
|
213
|
+
return plain(facts.fullscreen === json.fullscreen);
|
|
97
214
|
if ("theme" in json)
|
|
98
|
-
return facts.theme === json.theme;
|
|
215
|
+
return plain(facts.theme === json.theme);
|
|
99
216
|
if ("language" in json)
|
|
100
|
-
return facts.language === json.language;
|
|
101
|
-
if ("
|
|
102
|
-
return json.
|
|
103
|
-
if ("
|
|
104
|
-
return json.
|
|
105
|
-
|
|
217
|
+
return plain(facts.language === json.language);
|
|
218
|
+
if ("duration" in json)
|
|
219
|
+
return plain(inside(json.duration, facts.duration));
|
|
220
|
+
if ("volume" in json)
|
|
221
|
+
return plain(inside(json.volume, facts.volume ?? 100));
|
|
222
|
+
if ("rate" in json)
|
|
223
|
+
return plain(inside(json.rate, facts.rate ?? 1));
|
|
224
|
+
if ("time" in json)
|
|
225
|
+
return plain(inside(json.time, facts.time));
|
|
226
|
+
if ("audioTrack" in json)
|
|
227
|
+
return plain((facts.audioTrack ?? null) === json.audioTrack);
|
|
228
|
+
if ("subtitleTrack" in json)
|
|
229
|
+
return plain((facts.subtitleTrack ?? null) === json.subtitleTrack);
|
|
230
|
+
if ("audioDevice" in json)
|
|
231
|
+
return plain((facts.audioDevice ?? null) === json.audioDevice);
|
|
232
|
+
if ("muted" in json)
|
|
233
|
+
return plain((facts.muted ?? false) === json.muted);
|
|
234
|
+
if ("maximized" in json)
|
|
235
|
+
return plain((facts.maximized ?? false) === json.maximized);
|
|
236
|
+
if ("pip" in json)
|
|
237
|
+
return plain((facts.pip ?? false) === json.pip);
|
|
238
|
+
if ("looping" in json)
|
|
239
|
+
return plain((facts.looping ?? false) === json.looping);
|
|
240
|
+
if ("position" in json) {
|
|
241
|
+
const position = facts.position;
|
|
242
|
+
const range = typeof position === "number" &&
|
|
243
|
+
facts.bound !== null &&
|
|
244
|
+
facts.bound !== undefined &&
|
|
245
|
+
facts.bound === facts.sourceId
|
|
246
|
+
? matchedRange(json.position, position)
|
|
247
|
+
: null;
|
|
248
|
+
return { holds: range !== null, range };
|
|
249
|
+
}
|
|
250
|
+
if ("all" in json) {
|
|
251
|
+
let range = null;
|
|
252
|
+
for (const each of json.all) {
|
|
253
|
+
const truth = evaluateTruth(each, facts);
|
|
254
|
+
if (!truth.holds)
|
|
255
|
+
return plain(false);
|
|
256
|
+
range ??= truth.range;
|
|
257
|
+
}
|
|
258
|
+
return { holds: true, range };
|
|
259
|
+
}
|
|
260
|
+
if ("any" in json) {
|
|
261
|
+
const truth = plain(false);
|
|
262
|
+
for (const each of json.any) {
|
|
263
|
+
const one = evaluateTruth(each, facts);
|
|
264
|
+
truth.holds ||= one.holds;
|
|
265
|
+
truth.range ??= one.range;
|
|
266
|
+
}
|
|
267
|
+
return truth;
|
|
268
|
+
}
|
|
269
|
+
return plain(!evaluateTruth(json.not, facts).holds);
|
|
270
|
+
}
|
|
271
|
+
/** Evaluate a wire condition as the player does (for the test host). */
|
|
272
|
+
export function evaluate(json, facts) {
|
|
273
|
+
return evaluateTruth(json, facts).holds;
|
|
106
274
|
}
|
package/dist/plugin/window.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { WindowFacts } from "../wire.ts";
|
|
|
4
4
|
import type { MainWindow, WindowState } from "./types.ts";
|
|
5
5
|
/**
|
|
6
6
|
* One per plugin: read before activation, then kept current from
|
|
7
|
-
* `window.state` events (
|
|
7
|
+
* `window.state` events (after `plugin.player.subscribe()`) and after this plugin's own changes.
|
|
8
8
|
*/
|
|
9
9
|
export declare class WindowService {
|
|
10
10
|
#private;
|
package/dist/plugin/window.js
CHANGED
|
@@ -15,7 +15,7 @@ const view = (facts) => Object.freeze({
|
|
|
15
15
|
});
|
|
16
16
|
/**
|
|
17
17
|
* One per plugin: read before activation, then kept current from
|
|
18
|
-
* `window.state` events (
|
|
18
|
+
* `window.state` events (after `plugin.player.subscribe()`) and after this plugin's own changes.
|
|
19
19
|
*/
|
|
20
20
|
export class WindowService {
|
|
21
21
|
#runtime;
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* out access to it, and is the only file under `src/plugin/` that sends a
|
|
7
7
|
* request by a method name it was given (`scripts/check-layers.mjs`, rule 7).
|
|
8
8
|
*
|
|
9
|
-
* - `request`: `Connection.request`, the transport as is
|
|
10
|
-
* checks capabilities. The subscriptions are guarded, refused with
|
|
9
|
+
* - `request`: `Connection.request`, the transport as is. The subscriptions are guarded, refused with
|
|
11
10
|
* `invalid`: `events.subscribe` and `events.unsubscribe` of a
|
|
12
11
|
* `HostEvent` (the SDK owns those subscriptions and their marks; `on`
|
|
13
12
|
* covers them), and `events.subscribe` of any other event without
|
package/dist/processing.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { Transport } from "./wire.ts";
|
|
|
14
14
|
* and turned a quarter clockwise. The nodes run in array order; `set` sends
|
|
15
15
|
* the whole chain as this plugin's desired value (last write wins), and the
|
|
16
16
|
* player applies it to every source until it changes, needing
|
|
17
|
-
* `
|
|
17
|
+
* `plugin.player.subscribe()` and `plugin.player.read()`.
|
|
18
18
|
* ```ts
|
|
19
19
|
* const chain: VideoNode[] = [
|
|
20
20
|
* // Live fields: moving them later changes the picture in place.
|
|
@@ -306,8 +306,7 @@ export declare const VIDEO_PROCESSING_LIMITS: Readonly<{
|
|
|
306
306
|
* Speech around 1 kHz is 3 dB louder and both speakers play the same mixed
|
|
307
307
|
* channel. `set` sends this plugin's whole audio chain (the nodes in order,
|
|
308
308
|
* plus an optional `delayMs`); the player joins it with other plugins'
|
|
309
|
-
* chains and applies it to every source
|
|
310
|
-
* `playback.read`, `events`).
|
|
309
|
+
* chains and applies it to every source.
|
|
311
310
|
* ```ts
|
|
312
311
|
* plugin.audio.filter("sound").set({
|
|
313
312
|
* nodes: [
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The plugin API version this SDK implements (`manifest.apiVersion`). */
|
|
2
|
+
export declare const API_VERSION = "vestra/1";
|
|
3
|
+
/**
|
|
4
|
+
* The longest message a plugin may send the player, in UTF-8 bytes of one
|
|
5
|
+
* protocol line with its newline (1 MiB). The player stops a plugin that
|
|
6
|
+
* writes a longer one, so the plugin's side refuses such a request before
|
|
7
|
+
* sending it: it rejects with code `limit`. Property values meet
|
|
8
|
+
* {@link UI_VALUE_LIMITS} before this.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.5.14
|
|
11
|
+
*
|
|
12
|
+
* @category Testing
|
|
13
|
+
*/
|
|
14
|
+
export declare const MESSAGE_LIMIT: number;
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The plugin API version this SDK implements (`manifest.apiVersion`). */
|
|
2
|
+
export const API_VERSION = "vestra/1";
|
|
3
|
+
/**
|
|
4
|
+
* The longest message a plugin may send the player, in UTF-8 bytes of one
|
|
5
|
+
* protocol line with its newline (1 MiB). The player stops a plugin that
|
|
6
|
+
* writes a longer one, so the plugin's side refuses such a request before
|
|
7
|
+
* sending it: it rejects with code `limit`. Property values meet
|
|
8
|
+
* {@link UI_VALUE_LIMITS} before this.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.5.14
|
|
11
|
+
*
|
|
12
|
+
* @category Testing
|
|
13
|
+
*/
|
|
14
|
+
export const MESSAGE_LIMIT = 1024 * 1024;
|
package/dist/request-queue.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* same queue: tests see the same waiting.
|
|
16
16
|
*/
|
|
17
17
|
import { HostError } from "./wire.js";
|
|
18
|
-
import { MESSAGE_LIMIT } from "./
|
|
18
|
+
import { MESSAGE_LIMIT } from "./protocol.js";
|
|
19
19
|
import { abortError } from "./plugin/errors.js";
|
|
20
20
|
/**
|
|
21
21
|
* How much of the plugin's traffic the SDK keeps in flight, documented in
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Slint version the player links (its `Cargo.toml` pins `=1.18.1`): the
|
|
3
|
+
* compiler that `vestra-plugin check` asks of an installed `slint-ui` package,
|
|
4
|
+
* and `TestHost`'s `app.components.slint`. Changes with a player that
|
|
5
|
+
* upgrades Slint.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PLAYER_SLINT = "1.18.1";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Slint version the player links (its `Cargo.toml` pins `=1.18.1`): the
|
|
3
|
+
* compiler that `vestra-plugin check` asks of an installed `slint-ui` package,
|
|
4
|
+
* and `TestHost`'s `app.components.slint`. Changes with a player that
|
|
5
|
+
* upgrades Slint.
|
|
6
|
+
*/
|
|
7
|
+
export const PLAYER_SLINT = "1.18.1";
|
package/dist/subtitles.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type SubtitleStamp = {
|
|
|
26
26
|
* bottom of the video, and appear 250 ms earlier. `refresh` reads the
|
|
27
27
|
* subtitle state from the player, whose `fonts` lists the font ids a style
|
|
28
28
|
* may name; `setStyle` then sends this plugin's style layer
|
|
29
|
-
|
|
29
|
+
*. It shows unless another plugin
|
|
30
30
|
* with a manifest id that sorts later has a layer too: the player picks the
|
|
31
31
|
* effective layer by manifest id, not by which call came last.
|
|
32
32
|
* ```ts
|
package/dist/ts-plugin.d.ts
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The TypeScript language-service plugin `@vestra-player/sdk/ts-plugin
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* (`plugin.wire.request(method)` with a computed method) is a warning
|
|
8
|
-
* (`CAPABILITY_UNCHECKED`).
|
|
9
|
-
*
|
|
10
|
-
* A project enables it in its tsconfig.json:
|
|
2
|
+
* The TypeScript language-service plugin `@vestra-player/sdk/ts-plugin`.
|
|
3
|
+
* Up to 1.8 it showed the capability checker's findings in the editor, with
|
|
4
|
+
* the quick fix "Add '<capability>' to manifest.json". SDK 1.9.0 removed
|
|
5
|
+
* manifest capabilities, and with them the checker: the plugin now changes
|
|
6
|
+
* nothing and is kept only so that a tsconfig.json that lists it
|
|
11
7
|
*
|
|
12
8
|
* { "compilerOptions": { "plugins": [{ "name": "@vestra-player/sdk/ts-plugin" }] } }
|
|
13
9
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* language-service plugins, which is why `vestra-plugin check` runs the same
|
|
17
|
-
* checker. The manifest is the nearest `manifest.json` above the file; files
|
|
18
|
-
* in its `tests/`, `node_modules/`, `dist/` and `vendor/` are not checked.
|
|
10
|
+
* still loads without an error in the TypeScript server's log. Remove the
|
|
11
|
+
* entry; a later major version removes the module.
|
|
19
12
|
*
|
|
20
13
|
* @internal
|
|
21
14
|
*/
|
|
22
15
|
import type TS from "typescript";
|
|
23
16
|
/** @internal The plugin factory tsserver calls (`ts-plugin/index.js`). */
|
|
24
|
-
export default function init(
|
|
17
|
+
export default function init(_modules: {
|
|
25
18
|
typescript: typeof TS;
|
|
26
19
|
}): TS.server.PluginModule;
|
package/dist/ts-plugin.js
CHANGED
|
@@ -1,147 +1,9 @@
|
|
|
1
|
-
import { addCapabilityEdit, CAPABILITY_DIAGNOSTIC, CAPABILITY_UNCHECKED, checkCapabilities, isPluginSource, } from "./capability-check.js";
|
|
2
|
-
const FIX_NAME = "vestraAddCapability";
|
|
3
|
-
/** The nearest manifest.json at or above a file, with its capabilities. */
|
|
4
|
-
function manifestFor(ts, file) {
|
|
5
|
-
let directory = file.replaceAll("\\", "/");
|
|
6
|
-
for (;;) {
|
|
7
|
-
const parent = directory.slice(0, directory.lastIndexOf("/"));
|
|
8
|
-
if (!parent || parent === directory)
|
|
9
|
-
return undefined;
|
|
10
|
-
directory = parent;
|
|
11
|
-
const path = `${directory}/manifest.json`;
|
|
12
|
-
if (!ts.sys.fileExists(path))
|
|
13
|
-
continue;
|
|
14
|
-
try {
|
|
15
|
-
const manifest = JSON.parse(ts.sys.readFile(path) ?? "");
|
|
16
|
-
if (!Array.isArray(manifest.capabilities))
|
|
17
|
-
return undefined;
|
|
18
|
-
return {
|
|
19
|
-
path,
|
|
20
|
-
directory,
|
|
21
|
-
capabilities: manifest.capabilities.filter((each) => typeof each === "string"),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The manifest's text for the quick fix. The TypeScript server applies a
|
|
31
|
-
* code fix only to files it knows, and editors do not hand it JSON files
|
|
32
|
-
* (VS Code does not), so the manifest is made known first; its text is then
|
|
33
|
-
* the server's: an open buffer when the editor shares one, else the file on
|
|
34
|
-
* disk (VS Code: the saved manifest, not unsaved edits).
|
|
35
|
-
*/
|
|
36
|
-
function manifestText(ts, info, path) {
|
|
37
|
-
const service = info.project?.projectService;
|
|
38
|
-
const script = service && ts.server?.toNormalizedPath
|
|
39
|
-
? service.getOrCreateScriptInfoForNormalizedPath(ts.server.toNormalizedPath(path), false)
|
|
40
|
-
: undefined;
|
|
41
|
-
const snapshot = script?.getSnapshot();
|
|
42
|
-
return snapshot
|
|
43
|
-
? snapshot.getText(0, snapshot.getLength())
|
|
44
|
-
: ts.sys.readFile(path);
|
|
45
|
-
}
|
|
46
1
|
/** @internal The plugin factory tsserver calls (`ts-plugin/index.js`). */
|
|
47
|
-
export default function init(
|
|
48
|
-
const ts = modules.typescript;
|
|
2
|
+
export default function init(_modules) {
|
|
49
3
|
return {
|
|
50
4
|
create(info) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const none = { findings: [], unchecked: [] };
|
|
54
|
-
const results = (file) => {
|
|
55
|
-
const manifest = manifestFor(ts, file);
|
|
56
|
-
const program = service.getProgram();
|
|
57
|
-
if (!manifest || !program || !isPluginSource(manifest.directory, file))
|
|
58
|
-
return none;
|
|
59
|
-
try {
|
|
60
|
-
return checkCapabilities(ts, program, {
|
|
61
|
-
files: [file],
|
|
62
|
-
capabilities: manifest.capabilities,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
log(`check failed: ${error.stack ?? String(error)}`);
|
|
67
|
-
return none;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const findings = (file) => results(file).findings;
|
|
71
|
-
const proxy = Object.create(null);
|
|
72
|
-
for (const key of Object.keys(service)) {
|
|
73
|
-
const member = service[key];
|
|
74
|
-
proxy[key] =
|
|
75
|
-
typeof member === "function" ? member.bind(service) : member;
|
|
76
|
-
}
|
|
77
|
-
proxy.getSemanticDiagnostics = (file) => {
|
|
78
|
-
const prior = service.getSemanticDiagnostics(file);
|
|
79
|
-
const source = service.getProgram()?.getSourceFile(file);
|
|
80
|
-
const { findings: missing, unchecked } = results(file);
|
|
81
|
-
return [
|
|
82
|
-
...prior,
|
|
83
|
-
...missing.map((finding) => ({
|
|
84
|
-
file: source,
|
|
85
|
-
start: finding.start,
|
|
86
|
-
length: finding.length,
|
|
87
|
-
messageText: finding.message,
|
|
88
|
-
category: ts.DiagnosticCategory.Error,
|
|
89
|
-
code: CAPABILITY_DIAGNOSTIC,
|
|
90
|
-
source: "vestra",
|
|
91
|
-
})),
|
|
92
|
-
...unchecked.map((call) => ({
|
|
93
|
-
file: source,
|
|
94
|
-
start: call.start,
|
|
95
|
-
length: call.length,
|
|
96
|
-
messageText: call.message,
|
|
97
|
-
category: ts.DiagnosticCategory.Warning,
|
|
98
|
-
code: CAPABILITY_UNCHECKED,
|
|
99
|
-
source: "vestra",
|
|
100
|
-
})),
|
|
101
|
-
];
|
|
102
|
-
};
|
|
103
|
-
proxy.getSupportedCodeFixes = (file) => [
|
|
104
|
-
...service.getSupportedCodeFixes(file),
|
|
105
|
-
String(CAPABILITY_DIAGNOSTIC),
|
|
106
|
-
];
|
|
107
|
-
proxy.getCodeFixesAtPosition = (file, start, end, errorCodes, format, preferences) => {
|
|
108
|
-
const prior = service.getCodeFixesAtPosition(file, start, end, errorCodes, format, preferences);
|
|
109
|
-
if (!errorCodes.includes(CAPABILITY_DIAGNOSTIC))
|
|
110
|
-
return prior;
|
|
111
|
-
const manifest = manifestFor(ts, file);
|
|
112
|
-
if (!manifest)
|
|
113
|
-
return prior;
|
|
114
|
-
const text = manifestText(ts, info, manifest.path);
|
|
115
|
-
if (text === undefined)
|
|
116
|
-
return prior;
|
|
117
|
-
const wanted = new Set(findings(file)
|
|
118
|
-
.filter((finding) => finding.start <= end && finding.start + finding.length >= start)
|
|
119
|
-
.map((finding) => finding.capability));
|
|
120
|
-
const fixes = [];
|
|
121
|
-
for (const capability of wanted) {
|
|
122
|
-
const edit = addCapabilityEdit(ts, text, capability);
|
|
123
|
-
if (!edit)
|
|
124
|
-
continue;
|
|
125
|
-
fixes.push({
|
|
126
|
-
fixName: FIX_NAME,
|
|
127
|
-
description: `Add '${capability}' to manifest.json`,
|
|
128
|
-
changes: [
|
|
129
|
-
{
|
|
130
|
-
fileName: manifest.path,
|
|
131
|
-
textChanges: [
|
|
132
|
-
{
|
|
133
|
-
span: { start: edit.start, length: edit.length },
|
|
134
|
-
newText: edit.newText,
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
return [...prior, ...fixes];
|
|
142
|
-
};
|
|
143
|
-
log("enabled");
|
|
144
|
-
return proxy;
|
|
5
|
+
info.project?.projectService?.logger?.info("[@vestra-player/sdk/ts-plugin] does nothing since SDK 1.9.0 (no manifest capabilities); remove it from tsconfig.json");
|
|
6
|
+
return info.languageService;
|
|
145
7
|
},
|
|
146
8
|
};
|
|
147
9
|
}
|
package/dist/wire.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export interface PluginInfo {
|
|
|
17
17
|
id: string;
|
|
18
18
|
apiVersion: string;
|
|
19
19
|
entry: string;
|
|
20
|
-
capabilities: string[];
|
|
21
20
|
}
|
|
22
21
|
export interface PackageValidation {
|
|
23
22
|
token: string;
|
|
@@ -170,7 +169,7 @@ export type PropertyWrite = {
|
|
|
170
169
|
*
|
|
171
170
|
* Common codes: `stale` (the condition no longer holds; nothing was done),
|
|
172
171
|
* `invalid` (bad argument), `missing` (unknown target), `capability`
|
|
173
|
-
* (
|
|
172
|
+
* (a built-in-only request from another plugin), `busy`, `conflict`, `unavailable`, `unsupported`
|
|
174
173
|
* (refused, not executed), `backend` (load or parse failure), `failed`,
|
|
175
174
|
* `timeout`, `aborted`, `limit` (a player limit such as the command count),
|
|
176
175
|
* `disabled` (the plugin is stopping).
|
|
@@ -201,7 +200,6 @@ export type PropertyWrite = {
|
|
|
201
200
|
* A definite refusal, as opposed to a lost reply: the SDK does not retry
|
|
202
201
|
* it, and the plugin sees an `Error` with `code`.
|
|
203
202
|
*
|
|
204
|
-
* @capability None.
|
|
205
203
|
* @since 1.0.0
|
|
206
204
|
* @category Testing
|
|
207
205
|
*/
|
|
@@ -238,8 +236,6 @@ export interface PackageInfo {
|
|
|
238
236
|
state: "starting" | "running" | "disabled" | "failed" | "stopped";
|
|
239
237
|
/** Why it failed, when `state` is `failed`; else `null`. */
|
|
240
238
|
error: string | null;
|
|
241
|
-
/** The capabilities its manifest declares. */
|
|
242
|
-
capabilities: string[];
|
|
243
239
|
/** Its directory on disk. */
|
|
244
240
|
directory: string;
|
|
245
241
|
/** One of the player's built-in plugins. */
|
|
@@ -436,7 +432,7 @@ export interface WireTimeline {
|
|
|
436
432
|
/** The ranges. */
|
|
437
433
|
ranges?: WireRange[];
|
|
438
434
|
}
|
|
439
|
-
/** A panel position (`ui.mount`'s `slot`). */
|
|
435
|
+
/** A panel position (`ui.mount`'s `slot` parameter). */
|
|
440
436
|
export type MountSlot = "bottom" | "sidebar" | "backdrop" | "adjust";
|
|
441
437
|
/** The backdrop as `layout.state` reports it; `null` without one. */
|
|
442
438
|
export interface LayoutBackdrop {
|
|
@@ -782,7 +778,7 @@ export declare function createWire(transport: Transport): {
|
|
|
782
778
|
}[]>;
|
|
783
779
|
set: (id: string | null) => Promise<void>;
|
|
784
780
|
};
|
|
785
|
-
/** The binding table: list, user overlay
|
|
781
|
+
/** The binding table: list, user overlay. */
|
|
786
782
|
bindings: {
|
|
787
783
|
list: () => Promise<BindingTable>;
|
|
788
784
|
set: (plugin: string, command: string, inputs: string[]) => Promise<void>;
|
|
@@ -791,19 +787,19 @@ export declare function createWire(transport: Transport): {
|
|
|
791
787
|
command: string;
|
|
792
788
|
}) => Promise<void>;
|
|
793
789
|
};
|
|
794
|
-
/** File drops: providers by extension, panel listeners
|
|
790
|
+
/** File drops: providers by extension, panel listeners. */
|
|
795
791
|
drops: {
|
|
796
792
|
provide: (id: string, extensions: string[]) => Promise<void>;
|
|
797
793
|
withdraw: (id: string) => Promise<void>;
|
|
798
794
|
listen: (listen: boolean) => Promise<void>;
|
|
799
795
|
};
|
|
800
|
-
/** The palette
|
|
796
|
+
/** The palette: read it, change it. */
|
|
801
797
|
appearance: {
|
|
802
798
|
set: (theme: string) => Promise<void>;
|
|
803
799
|
/** The interface language for the next start. */
|
|
804
800
|
setLanguage: (language: string) => Promise<void>;
|
|
805
801
|
};
|
|
806
|
-
/** Settings pages in the player's options window
|
|
802
|
+
/** Settings pages in the player's options window. */
|
|
807
803
|
settings: {
|
|
808
804
|
register: (options: {
|
|
809
805
|
id: string;
|
|
@@ -935,6 +931,21 @@ export declare function createWire(transport: Transport): {
|
|
|
935
931
|
observeProperty: (name: string) => Promise<void>;
|
|
936
932
|
unobserveProperty: (name: string) => Promise<void>;
|
|
937
933
|
};
|
|
934
|
+
/**
|
|
935
|
+
* Trigger conditions (1.10.0, `plugin.trigger`): `set` hands one over
|
|
936
|
+
* (or replaces it), `off` removes it, `declare` names what `activate()`
|
|
937
|
+
* declared. Each `set` and `off` answers the condition's sequence
|
|
938
|
+
* number; the flips arrive as `triggers.fired` events.
|
|
939
|
+
*/
|
|
940
|
+
triggers: {
|
|
941
|
+
set: (trigger: number | string, when: Json) => Promise<{
|
|
942
|
+
seq: number;
|
|
943
|
+
}>;
|
|
944
|
+
off: (trigger: number | string, unhandled?: boolean) => Promise<{
|
|
945
|
+
seq: number;
|
|
946
|
+
}>;
|
|
947
|
+
declare: (names: string[], unnamed: number) => Promise<null>;
|
|
948
|
+
};
|
|
938
949
|
/** The system's secret store, per plugin (`secrets`). */
|
|
939
950
|
secrets: {
|
|
940
951
|
get: (name: string) => Promise<string | null>;
|
|
@@ -957,8 +968,7 @@ export declare function createWire(transport: Transport): {
|
|
|
957
968
|
system: () => Promise<WireSystemInfo>;
|
|
958
969
|
};
|
|
959
970
|
/**
|
|
960
|
-
* The rendering choice: `state
|
|
961
|
-
* `restart` need `rendering.manage`.
|
|
971
|
+
* The rendering choice: `state`, `setPreference` and `restart`.
|
|
962
972
|
*/
|
|
963
973
|
rendering: {
|
|
964
974
|
state: () => Promise<WireRenderingState>;
|