@vestra-player/sdk 1.7.9 → 1.7.11
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 +19 -0
- package/dist/capability-rules.js +5 -1
- package/dist/commands.d.ts +4 -3
- package/dist/commands.js +5 -4
- package/dist/docs-tree.json.gz +0 -0
- package/dist/player-runtime.d.ts +1 -0
- package/dist/player-runtime.js +1 -0
- package/dist/plugin/connection.d.ts +7 -1
- package/dist/plugin/connection.js +16 -3
- package/dist/plugin/errors.d.ts +5 -1
- package/dist/plugin/errors.js +8 -2
- package/dist/plugin/index.js +4 -0
- package/dist/plugin/player.js +1 -1
- package/dist/plugin/subtitles.js +2 -2
- package/dist/plugin/types/base.d.ts +2 -2
- package/dist/plugin/types/processing.d.ts +5 -5
- package/dist/request-queue.d.ts +66 -0
- package/dist/request-queue.js +209 -0
- package/dist/source.d.ts +2 -1
- package/dist/source.js +3 -5
- package/dist/subtitles.d.ts +4 -2
- package/dist/subtitles.js +4 -10
- package/dist/wire.d.ts +10 -4
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.11
|
|
4
|
+
|
|
5
|
+
**Who must change: nobody; the table follows player #271.** A data refresh of `BUILTIN_COMMANDS`: no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged.
|
|
6
|
+
|
|
7
|
+
- **Changed row** (`vestra.video`): `video.gpu-rendering` is titled GPU Rendering (was GPU Rendering (Experimental)); still palette-only, no default key. The table in [Reference: commands](docs/reference/commands.md#built-in-commands) follows.
|
|
8
|
+
- **Not synced, by design**: the built-ins' new `destructive` marks (player #274) are not a column of `BUILTIN_COMMANDS`, which lists owners, paths, titles and keys only. `BUILTIN_SUBMENUS`, the Slint library copy, the capability table, translations, palettes and menu ids already matched the player.
|
|
9
|
+
- **Docs**: the player's renderer switch is named as it now is, the Picture panel's GPU Rendering (it named Video ▸ GPU Rendering (Experimental)): `SystemInfo.rendering`, `RenderOptions`, `VideoShaders`, the `UpscalingReasonCode` example, the GPU rendering guide and Platforms; `BUILTIN_COMMANDS` places the passing `video.gpu-rendering.restart` in the Picture panel's Rendering section (it named Video ▸ Restart Player to Apply).
|
|
10
|
+
|
|
11
|
+
## 1.7.10
|
|
12
|
+
|
|
13
|
+
**Who must change: nobody.** No API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged. A plugin that sends many requests at once now sees some of them answered later, never refused.
|
|
14
|
+
|
|
15
|
+
- **Requests in flight** (user design, 2026-11-11): the SDK keeps at most 256 of a plugin's requests, and 3 MiB of their lines, sent and not yet answered (`REQUEST_LIMITS`, exported from `./runtime` for the player's agreement test). The rest wait in the plugin's own queue and go out in the order made as answers come in: no error, no reordering. The player's backstop (past 320 unanswered lines or 4 MiB per plugin it answers `limit`; it does not stop the plugin) is so never reached by a plugin on the SDK, only by a client that bypasses it; the byte cap leaves one `MESSAGE_LIMIT` line of room under 4 MiB, since a few large lines would cross 4 MiB long before 256 requests, and each line counts 32 bytes more than the SDK's estimate, for the id's digits and the shared runner's envelope the player also counts. One queue per plugin, each member of the shared runner included (it lives in the plugin's connection, over the runner's transport).
|
|
16
|
+
- **What never waits**: the answers to the player's own calls (`sourceResolvers.respond`, `producer.ack`, `producer.ackInput`), which the player may be waiting for before it answers one of the plugin's requests; they count while in flight. `palette.lead.done` waits in order like any request, so it never passes a waiting `commands.run` of the same ticket. A line over `MESSAGE_LIMIT` is refused at once as before. Events are not requests.
|
|
17
|
+
- **Aborting**: a waiting request whose `AbortSignal` is aborted leaves the queue unsent and rejects with `aborted` (`player.open`'s submit, `subtitles.load`'s upload). A sent request runs to its answer, as before. An abort counts as a definite outcome (nothing is asked again about an operation that was never sent).
|
|
18
|
+
- **Stopping**: when the plugin stops, every waiting request rejects with `disabled` ("plugin stopped"), as the runner rejects those in flight; the cleanup's own requests go out as before.
|
|
19
|
+
- **`TestHost`** sits behind the same queue, so a plugin's tests see the same waiting. Limits reference: "Requests in flight". Tests: `test/request-queue.test.ts` (10,000 requests in order with at most 256 in flight, the byte cap, abort while waiting, stop and disconnect with a full queue, replies past a full queue, `palette.lead.done` behind a waiting `commands.run`). Errors reference: `limit` names the player's backstop.
|
|
20
|
+
- **Capability checker**: `media.sources.open` without `playback.control` names the request `media.sources.open` (it named `source.operation`, which asks for that capability only once it counts as declared); a need is attributed to the request that needed it first.
|
|
21
|
+
|
|
3
22
|
## 1.7.9
|
|
4
23
|
|
|
5
24
|
**Who must change: nobody; additions only.** The two new capabilities are for the player's built-in plugins only: a third-party plugin cannot declare them (the player refuses the package at install, the plugin registry refuses it, `vestra-plugin check` reports it, and every call fails with `capability`). A built-in plugin that uses them needs player 0.7.6. `apiVersion` stays `vestra/1`; the API surface snapshot gains the new members.
|
package/dist/capability-rules.js
CHANGED
|
@@ -143,6 +143,10 @@ export function requestsNeed(requests, capabilities, rules = RULES) {
|
|
|
143
143
|
};
|
|
144
144
|
// Every capability any round needed; the answer is the last round's needs
|
|
145
145
|
// (read with all of them declared) and then any earlier one it left out.
|
|
146
|
+
// Each keeps the request of the round that first needed it, the one read
|
|
147
|
+
// closest to the manifest: `MediaSources.open` needs `playback.control` for
|
|
148
|
+
// `media.sources.open`, not for `source.operation`, which asks for it only
|
|
149
|
+
// once it counts as declared.
|
|
146
150
|
const all = new Map();
|
|
147
151
|
for (;;) {
|
|
148
152
|
const needs = round(new Set(all.keys()));
|
|
@@ -152,7 +156,7 @@ export function requestsNeed(requests, capabilities, rules = RULES) {
|
|
|
152
156
|
all.set(need.capability, need);
|
|
153
157
|
if (all.size === before)
|
|
154
158
|
return [
|
|
155
|
-
...needs,
|
|
159
|
+
...needs.map((need) => all.get(need.capability)),
|
|
156
160
|
...[...all.values()].filter((need) => !needs.some((each) => each.capability === need.capability)),
|
|
157
161
|
];
|
|
158
162
|
}
|
package/dist/commands.d.ts
CHANGED
|
@@ -268,9 +268,10 @@ export interface BuiltinCommand {
|
|
|
268
268
|
* user's own changes come on top; see {@link @vestra-player/sdk!Bindings | Bindings}). Menu items built
|
|
269
269
|
* from content (tracks, recent files, output devices) are not listed; their
|
|
270
270
|
* placeholders (`No Audio Tracks`) are. Items that appear only in a
|
|
271
|
-
* passing state are not listed either: the
|
|
272
|
-
*
|
|
273
|
-
* while a rendering choice waits
|
|
271
|
+
* passing state are not listed either: the video plugin's Restart
|
|
272
|
+
* (`video.gpu-rendering.restart`), in the Picture panel's Rendering section
|
|
273
|
+
* beside GPU Rendering (not in a menu), shown while a rendering choice waits
|
|
274
|
+
* for the next start.
|
|
274
275
|
*
|
|
275
276
|
* A snapshot of the player's built-in commands at this SDK release; the
|
|
276
277
|
* player may differ between SDK releases. The player's tests check that
|
package/dist/commands.js
CHANGED
|
@@ -596,7 +596,7 @@ vestra.video | video.saturation.down | (Saturation -1%) | Y
|
|
|
596
596
|
vestra.video | video.saturation.up | (Saturation +1%) | U
|
|
597
597
|
vestra.video | video.hue.down | (Hue -1%) | I
|
|
598
598
|
vestra.video | video.hue.up | (Hue +1%) | O
|
|
599
|
-
vestra.video | video.gpu-rendering | (GPU Rendering
|
|
599
|
+
vestra.video | video.gpu-rendering | (GPU Rendering)
|
|
600
600
|
vestra.video | video.upscaling | (AI Upscaling)
|
|
601
601
|
`;
|
|
602
602
|
/**
|
|
@@ -607,9 +607,10 @@ vestra.video | video.upscaling | (AI Upscaling)
|
|
|
607
607
|
* user's own changes come on top; see {@link @vestra-player/sdk!Bindings | Bindings}). Menu items built
|
|
608
608
|
* from content (tracks, recent files, output devices) are not listed; their
|
|
609
609
|
* placeholders (`No Audio Tracks`) are. Items that appear only in a
|
|
610
|
-
* passing state are not listed either: the
|
|
611
|
-
*
|
|
612
|
-
* while a rendering choice waits
|
|
610
|
+
* passing state are not listed either: the video plugin's Restart
|
|
611
|
+
* (`video.gpu-rendering.restart`), in the Picture panel's Rendering section
|
|
612
|
+
* beside GPU Rendering (not in a menu), shown while a rendering choice waits
|
|
613
|
+
* for the next start.
|
|
613
614
|
*
|
|
614
615
|
* A snapshot of the player's built-in commands at this SDK release; the
|
|
615
616
|
* player may differ between SDK releases. The player's tests check that
|
package/dist/docs-tree.json.gz
CHANGED
|
Binary file
|
package/dist/player-runtime.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { HOST_CAPABILITIES } from "./host-capabilities.ts";
|
|
|
16
16
|
export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "./commands.ts";
|
|
17
17
|
export { BINDING_INPUTS } from "./plugin/bindings.ts";
|
|
18
18
|
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.ts";
|
|
19
|
+
export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.ts";
|
|
19
20
|
export { OSD_LIMITS } from "./plugin/osd.ts";
|
|
20
21
|
export { TIMELINE_LIMITS } from "./plugin/timeline.ts";
|
|
21
22
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
|
package/dist/player-runtime.js
CHANGED
|
@@ -14,6 +14,7 @@ export { HOST_CAPABILITIES } from "./host-capabilities.js";
|
|
|
14
14
|
export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "./commands.js";
|
|
15
15
|
export { BINDING_INPUTS } from "./plugin/bindings.js";
|
|
16
16
|
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.js";
|
|
17
|
+
export { REQUEST_LIMITS, UNQUEUED_METHODS } from "./request-queue.js";
|
|
17
18
|
export { OSD_LIMITS } from "./plugin/osd.js";
|
|
18
19
|
export { TIMELINE_LIMITS } from "./plugin/timeline.js";
|
|
19
20
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestQueue } from "../request-queue.ts";
|
|
1
2
|
import type { Json, LocalServices, Transport, Wire } from "../wire.ts";
|
|
2
3
|
import type { App, Disposable, Locale, StopReason, SystemInfo } from "./types.ts";
|
|
3
4
|
/**
|
|
@@ -57,6 +58,11 @@ export declare class Connection {
|
|
|
57
58
|
readonly local: LocalServices | undefined;
|
|
58
59
|
/** Registrations that activation must wait for before reporting ready. */
|
|
59
60
|
readonly startup: Set<Promise<unknown>>;
|
|
61
|
+
/**
|
|
62
|
+
* Every request of this plugin goes through it: at most
|
|
63
|
+
* `REQUEST_LIMITS` in flight, the rest wait in order (`request-queue.ts`).
|
|
64
|
+
*/
|
|
65
|
+
readonly requests: RequestQueue;
|
|
60
66
|
readonly views: Map<string, (callback: string, args: Json[]) => void>;
|
|
61
67
|
readonly commands: Map<string, () => void>;
|
|
62
68
|
/**
|
|
@@ -150,7 +156,7 @@ export declare class Connection {
|
|
|
150
156
|
* One request by its method name, as given (`plugin.wire.request`): nothing
|
|
151
157
|
* added, nothing checked here, the player checks the capability. Every other
|
|
152
158
|
* part of the SDK uses the typed clients (`host`); `scripts/check-layers.mjs`
|
|
153
|
-
* keeps it so.
|
|
159
|
+
* keeps it so. It waits in the request queue like every other.
|
|
154
160
|
*/
|
|
155
161
|
request<T>(method: string, params?: Json): Promise<T>;
|
|
156
162
|
/** Raw transport events the host pushes without a subscription. */
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* nothing of update passes (`passes.ts`); `Runtime` (`runtime.ts`) adds them.
|
|
8
8
|
*/
|
|
9
9
|
import { createWire, HostError } from "../wire.js";
|
|
10
|
+
import { RequestQueue } from "../request-queue.js";
|
|
10
11
|
import { LOCALES } from "../i18n.js";
|
|
11
12
|
import { failure } from "./errors.js";
|
|
12
13
|
import { basename, isAbsolute, relative } from "node:path";
|
|
@@ -81,6 +82,11 @@ export class Connection {
|
|
|
81
82
|
/** Declarations skipped during activation: reported once it completes. */
|
|
82
83
|
#refusals = [];
|
|
83
84
|
#transport;
|
|
85
|
+
/**
|
|
86
|
+
* Every request of this plugin goes through it: at most
|
|
87
|
+
* `REQUEST_LIMITS` in flight, the rest wait in order (`request-queue.ts`).
|
|
88
|
+
*/
|
|
89
|
+
requests;
|
|
84
90
|
#events = new Map();
|
|
85
91
|
/** The missing `events` warning was given (once per plugin). */
|
|
86
92
|
#warnedEvents = false;
|
|
@@ -127,7 +133,14 @@ export class Connection {
|
|
|
127
133
|
this.#strict = options.strictDeclarations ?? false;
|
|
128
134
|
this.dataDirectory = dataDirectory;
|
|
129
135
|
this.local = transport.local;
|
|
130
|
-
|
|
136
|
+
const requests = new RequestQueue(transport);
|
|
137
|
+
this.requests = requests;
|
|
138
|
+
this.host = createWire({
|
|
139
|
+
request: (method, params, options) => requests.request(method, params, options),
|
|
140
|
+
on: (event, listener) => transport.on(event, listener),
|
|
141
|
+
local: transport.local,
|
|
142
|
+
locale: transport.locale,
|
|
143
|
+
});
|
|
131
144
|
const host = this.host;
|
|
132
145
|
this.app = appInfo(app, () => host.app.system());
|
|
133
146
|
const features = app
|
|
@@ -419,10 +432,10 @@ export class Connection {
|
|
|
419
432
|
* One request by its method name, as given (`plugin.wire.request`): nothing
|
|
420
433
|
* added, nothing checked here, the player checks the capability. Every other
|
|
421
434
|
* part of the SDK uses the typed clients (`host`); `scripts/check-layers.mjs`
|
|
422
|
-
* keeps it so.
|
|
435
|
+
* keeps it so. It waits in the request queue like every other.
|
|
423
436
|
*/
|
|
424
437
|
request(method, params) {
|
|
425
|
-
return this
|
|
438
|
+
return this.requests.request(method, params);
|
|
426
439
|
}
|
|
427
440
|
/** Raw transport events the host pushes without a subscription. */
|
|
428
441
|
raw(event, listener) {
|
package/dist/plugin/errors.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import type { PluginError } from "./types.ts";
|
|
|
2
2
|
export declare const sleep: (ms: number) => Promise<void>;
|
|
3
3
|
export declare function toError(error: unknown): PluginError;
|
|
4
4
|
export declare const failure: (code: string, message?: string) => PluginError;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Host replies are definite; anything else (lost reply, client timeout) is
|
|
7
|
+
* not. An abort is definite too: the SDK's request queue rejects a waiting
|
|
8
|
+
* request with it, unsent (`request-queue.ts`).
|
|
9
|
+
*/
|
|
6
10
|
export declare const uncertain: (error: unknown) => boolean;
|
|
7
11
|
/** Mark a promise as observed so an unused `ready` never crashes the runner. */
|
|
8
12
|
export declare function quiet<T>(promise: Promise<T>): Promise<T>;
|
package/dist/plugin/errors.js
CHANGED
|
@@ -20,8 +20,14 @@ export function toError(error) {
|
|
|
20
20
|
return new HostError("error", String(error));
|
|
21
21
|
}
|
|
22
22
|
export const failure = (code, message = code) => new HostError(code, message);
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Host replies are definite; anything else (lost reply, client timeout) is
|
|
25
|
+
* not. An abort is definite too: the SDK's request queue rejects a waiting
|
|
26
|
+
* request with it, unsent (`request-queue.ts`).
|
|
27
|
+
*/
|
|
28
|
+
export const uncertain = (error) => error instanceof HostError
|
|
29
|
+
? error.code === "timeout"
|
|
30
|
+
: !(error instanceof Error && error.name === "AbortError");
|
|
25
31
|
/** Mark a promise as observed so an unused `ready` never crashes the runner. */
|
|
26
32
|
export function quiet(promise) {
|
|
27
33
|
promise.catch(() => { });
|
package/dist/plugin/index.js
CHANGED
|
@@ -43,6 +43,10 @@ options) {
|
|
|
43
43
|
activated: () => runtime.activated(),
|
|
44
44
|
dispose: async (info) => {
|
|
45
45
|
runtime.stopping ??= { reason: stopReason(info?.reason) };
|
|
46
|
+
// Before the cleanup runs: what still waits to be sent rejects as the
|
|
47
|
+
// requests in flight do when the runner stops (`disabled`); the
|
|
48
|
+
// cleanup's own requests go to the transport as before.
|
|
49
|
+
runtime.requests.close();
|
|
46
50
|
await root.dispose();
|
|
47
51
|
runtime.stop();
|
|
48
52
|
},
|
package/dist/plugin/player.js
CHANGED
|
@@ -272,7 +272,7 @@ export class PlayerService {
|
|
|
272
272
|
try {
|
|
273
273
|
result = await (options.send
|
|
274
274
|
? options.send(id)
|
|
275
|
-
: this.runtime.host.source.submit(intent, id));
|
|
275
|
+
: this.runtime.host.source.submit(intent, id, options.signal));
|
|
276
276
|
}
|
|
277
277
|
catch (error) {
|
|
278
278
|
if (!uncertain(error))
|
package/dist/plugin/subtitles.js
CHANGED
|
@@ -324,11 +324,11 @@ export function subtitles(scope) {
|
|
|
324
324
|
throw abortError();
|
|
325
325
|
};
|
|
326
326
|
check();
|
|
327
|
-
await host().begin(uploadId, current.sourceId, srt.length);
|
|
327
|
+
await host().begin(uploadId, current.sourceId, srt.length, options?.signal);
|
|
328
328
|
for (let offset = 0; offset < srt.length; offset += CHUNK) {
|
|
329
329
|
check();
|
|
330
330
|
const chunk = Buffer.from(srt.subarray(offset, offset + CHUNK));
|
|
331
|
-
await host().append(uploadId, offset, chunk.toString("base64"));
|
|
331
|
+
await host().append(uploadId, offset, chunk.toString("base64"), options?.signal);
|
|
332
332
|
}
|
|
333
333
|
const sha256 = createHash("sha256").update(srt).digest("hex");
|
|
334
334
|
check();
|
|
@@ -113,7 +113,7 @@ export interface Disposable {
|
|
|
113
113
|
* | `timeout` | A time limit ran out (`openStream` start-up, `tools.run`, `system.*` after 10 s). |
|
|
114
114
|
* | `stream`, `device` | `openStream`: the producer failed / the audio device is not ready. |
|
|
115
115
|
* | `backend-uncertain` | The player's backend blocked a filter stage; call `retry()`. |
|
|
116
|
-
* | `limit` | A player-wide limit was reached (for example the number of commands), a property value is over the limits of {@link PropValue}, a request is longer than the player's 1 MiB message,
|
|
116
|
+
* | `limit` | A player-wide limit was reached (for example the number of commands), a property value is over the limits of {@link PropValue}, a request is longer than the player's 1 MiB message, {@link Commands.run} ran too often, or a client that bypasses the SDK left more than 320 requests or 4 MiB of them unanswered (the player's backstop; the SDK keeps a plugin under it). |
|
|
117
117
|
* | `reserved` | {@link Packages.validate}, {@link PackageCandidate.install}: the id is `vestra` or starts with `vestra.` (any case), which only the player's built-in plugins use. |
|
|
118
118
|
* | `versionMismatch` | The package needs a newer player (`minPlayerVersion`). |
|
|
119
119
|
* | `ui-prepare` | The player could not prepare a mounted panel or a settings page (its Slint file does not compile, a bound property is not declared, or another plugin's panel holds the slot); `message` has the diagnostics. |
|
|
@@ -1081,7 +1081,7 @@ export interface SystemInfo {
|
|
|
1081
1081
|
* the renderer is then unknown, not software.
|
|
1082
1082
|
*
|
|
1083
1083
|
* Today the player renders on the GPU on macOS, on Windows when the
|
|
1084
|
-
* user turned on
|
|
1084
|
+
* user turned on the Picture panel's GPU Rendering (since version 0.5.14;
|
|
1085
1085
|
* off by default), and in software otherwise: on Windows by default, on
|
|
1086
1086
|
* Linux and without a user interface (see
|
|
1087
1087
|
* [Platforms](../../../docs/reference/platforms.md)); test this field
|
|
@@ -256,8 +256,8 @@ export interface RenderSettings {
|
|
|
256
256
|
* independent handles.
|
|
257
257
|
*
|
|
258
258
|
* Platforms: macOS renders on the GPU by default; Windows does since
|
|
259
|
-
* version 0.5.14 of the player when the user turns on
|
|
260
|
-
*
|
|
259
|
+
* version 0.5.14 of the player when the user turns on the Picture panel's
|
|
260
|
+
* GPU Rendering (off by default, {@link Rendering}). Under software
|
|
261
261
|
* rendering (Windows by default, Linux, headless, fallback) every `set`
|
|
262
262
|
* fails with `unsupported`; {@link SystemInfo.rendering} tells which
|
|
263
263
|
* renderer draws without creating the handle. macOS OpenGL 4.1 has no
|
|
@@ -371,8 +371,8 @@ export interface RenderOptions extends Disposable {
|
|
|
371
371
|
* at most 16 MiB. Elsewhere: `invalid`; a file that does not exist:
|
|
372
372
|
* `missing`. The player reads the files when the list is set.
|
|
373
373
|
*
|
|
374
|
-
* GPU rendering only (macOS; Windows with
|
|
375
|
-
*
|
|
374
|
+
* GPU rendering only (macOS; Windows with the Picture panel's GPU Rendering
|
|
375
|
+
* turned on): under software rendering a non-empty list is
|
|
376
376
|
* `failed` with `unsupported`, and a switch to software during the run
|
|
377
377
|
* pushes `unsupported` to every handle with shaders and removes every
|
|
378
378
|
* list (they no longer count against the 16); set them again once the
|
|
@@ -540,7 +540,7 @@ export interface VideoShaders extends Disposable {
|
|
|
540
540
|
* // Advice for the codes this plugin knows; any other code shows the message.
|
|
541
541
|
* const advice: Partial<Record<UpscalingReasonCode, string>> = {
|
|
542
542
|
* driver: "Update the NVIDIA driver to 530 or newer.",
|
|
543
|
-
* rendering: "Turn on
|
|
543
|
+
* rendering: "Turn on Picture ▸ GPU Rendering and restart.",
|
|
544
544
|
* };
|
|
545
545
|
* if (reason) console.log(advice[reason.code] ?? reason.message);
|
|
546
546
|
* ```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Json, Transport } from "./wire.ts";
|
|
2
|
+
/**
|
|
3
|
+
* How much of the plugin's traffic the SDK keeps in flight, documented in
|
|
4
|
+
* the limits reference. Exported from `./runtime` only, for the player's
|
|
5
|
+
* agreement test: a plugin never meets these figures as an error, only as
|
|
6
|
+
* a delay.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const REQUEST_LIMITS: Readonly<{
|
|
11
|
+
/**
|
|
12
|
+
* Requests one plugin has sent the player and not yet had answered; the
|
|
13
|
+
* next waits in the plugin's queue until an answer comes, under the
|
|
14
|
+
* player's backstop of 320 lines (256).
|
|
15
|
+
*/
|
|
16
|
+
readonly inFlight: 256;
|
|
17
|
+
/**
|
|
18
|
+
* UTF-8 bytes of those requests' lines together; the next waits unless
|
|
19
|
+
* nothing is in flight. One `MESSAGE_LIMIT` line more stays under the
|
|
20
|
+
* player's backstop of 4 MiB, for the replies that never wait (3 MiB).
|
|
21
|
+
*/
|
|
22
|
+
readonly inFlightBytes: number;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Requests that answer the player's own calls (a resolution, a producer's
|
|
26
|
+
* control): sent at once, never behind the queue. The player may hold one
|
|
27
|
+
* of the plugin's requests until such an answer comes (an open waits for
|
|
28
|
+
* the plugin's resolver), so waiting behind it could never end.
|
|
29
|
+
* `palette.lead.done` is not one: the player waits for nothing on it, and
|
|
30
|
+
* unqueued it could pass a waiting `commands.run` of the same ticket. They count while in flight; their number is the player's, so
|
|
31
|
+
* the backstop's margin over `inFlight` covers them.
|
|
32
|
+
*/
|
|
33
|
+
export declare const UNQUEUED_METHODS: ReadonlySet<string>;
|
|
34
|
+
/** A request's options on the plugin's side; nothing of them is sent. */
|
|
35
|
+
export interface RequestOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Aborting it while the request still waits takes the request out of the
|
|
38
|
+
* queue, unsent, and rejects it with `aborted` (`AbortError`). Once sent,
|
|
39
|
+
* it runs to its answer, as before.
|
|
40
|
+
*/
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
}
|
|
43
|
+
/** The transport behind a per-plugin limit of requests in flight. */
|
|
44
|
+
export declare class RequestQueue {
|
|
45
|
+
#private;
|
|
46
|
+
/** The most in flight at once (the SDK's own tests). */
|
|
47
|
+
peak: number;
|
|
48
|
+
constructor(transport: Transport, limits?: {
|
|
49
|
+
inFlight: number;
|
|
50
|
+
inFlightBytes: number;
|
|
51
|
+
});
|
|
52
|
+
/** Requests sent and not yet answered, and their bytes. */
|
|
53
|
+
get inFlight(): {
|
|
54
|
+
requests: number;
|
|
55
|
+
bytes: number;
|
|
56
|
+
};
|
|
57
|
+
/** Requests waiting to be sent. */
|
|
58
|
+
get waiting(): number;
|
|
59
|
+
request<T>(method: string, params?: Json, options?: RequestOptions): Promise<T>;
|
|
60
|
+
/**
|
|
61
|
+
* The plugin stops: every waiting request rejects with `error` (the one
|
|
62
|
+
* the runner gives the requests in flight), and later ones go to the
|
|
63
|
+
* transport as they come, which refuses them while stopping.
|
|
64
|
+
*/
|
|
65
|
+
close(error?: Error): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin's side of the player's request backstop (L0): at most
|
|
3
|
+
* `REQUEST_LIMITS.inFlight` requests, and `REQUEST_LIMITS.inFlightBytes` of
|
|
4
|
+
* them, sent and not yet answered; the rest wait here in the order they were
|
|
5
|
+
* made and go out as answers come in. Nothing fails and nothing is
|
|
6
|
+
* reordered: a request that waits is only late. The player answers
|
|
7
|
+
* `limit` to a request past 320 unanswered lines or 4 MiB of them per plugin
|
|
8
|
+
* (its backstop; it does not stop the plugin), which a plugin on the SDK so
|
|
9
|
+
* never reaches: only a client that bypasses the SDK meets it.
|
|
10
|
+
*
|
|
11
|
+
* One queue per plugin, made by its `Connection` over the runner's
|
|
12
|
+
* transport: in the shared runner every member has its own `boot`, its own
|
|
13
|
+
* `createPlugin` and so its own queue, so one member's flood never delays
|
|
14
|
+
* another's. `TestHost` is the transport of a plugin under test, behind the
|
|
15
|
+
* same queue: tests see the same waiting.
|
|
16
|
+
*/
|
|
17
|
+
import { HostError } from "./wire.js";
|
|
18
|
+
import { MESSAGE_LIMIT } from "./capabilities.js";
|
|
19
|
+
import { abortError } from "./plugin/errors.js";
|
|
20
|
+
/**
|
|
21
|
+
* How much of the plugin's traffic the SDK keeps in flight, documented in
|
|
22
|
+
* the limits reference. Exported from `./runtime` only, for the player's
|
|
23
|
+
* agreement test: a plugin never meets these figures as an error, only as
|
|
24
|
+
* a delay.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export const REQUEST_LIMITS = Object.freeze({
|
|
29
|
+
/**
|
|
30
|
+
* Requests one plugin has sent the player and not yet had answered; the
|
|
31
|
+
* next waits in the plugin's queue until an answer comes, under the
|
|
32
|
+
* player's backstop of 320 lines (256).
|
|
33
|
+
*/
|
|
34
|
+
inFlight: 256,
|
|
35
|
+
/**
|
|
36
|
+
* UTF-8 bytes of those requests' lines together; the next waits unless
|
|
37
|
+
* nothing is in flight. One `MESSAGE_LIMIT` line more stays under the
|
|
38
|
+
* player's backstop of 4 MiB, for the replies that never wait (3 MiB).
|
|
39
|
+
*/
|
|
40
|
+
inFlightBytes: 3 * 1024 * 1024,
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Requests that answer the player's own calls (a resolution, a producer's
|
|
44
|
+
* control): sent at once, never behind the queue. The player may hold one
|
|
45
|
+
* of the plugin's requests until such an answer comes (an open waits for
|
|
46
|
+
* the plugin's resolver), so waiting behind it could never end.
|
|
47
|
+
* `palette.lead.done` is not one: the player waits for nothing on it, and
|
|
48
|
+
* unqueued it could pass a waiting `commands.run` of the same ticket. They count while in flight; their number is the player's, so
|
|
49
|
+
* the backstop's margin over `inFlight` covers them.
|
|
50
|
+
*/
|
|
51
|
+
export const UNQUEUED_METHODS = new Set([
|
|
52
|
+
"sourceResolvers.respond",
|
|
53
|
+
"producer.ack",
|
|
54
|
+
"producer.ackInput",
|
|
55
|
+
]);
|
|
56
|
+
/**
|
|
57
|
+
* What the player counts of a line beyond the SDK's estimate: the id's
|
|
58
|
+
* digits past one and the shared runner's `"g":<n>,` envelope (about 10–20
|
|
59
|
+
* bytes), rounded up. With it, `inFlightBytes` plus one unqueued line of
|
|
60
|
+
* `MESSAGE_LIMIT` stays under the player's 4 MiB.
|
|
61
|
+
*/
|
|
62
|
+
const LINE_MARGIN = 32;
|
|
63
|
+
/**
|
|
64
|
+
* UTF-8 bytes of the request's line as the runner writes it, with a
|
|
65
|
+
* one-digit id and the newline (without {@link LINE_MARGIN});
|
|
66
|
+
* `undefined` when it cannot be written (the transport says why).
|
|
67
|
+
*/
|
|
68
|
+
function lineBytes(method, params) {
|
|
69
|
+
try {
|
|
70
|
+
return (Buffer.byteLength(JSON.stringify({ id: 0, method, params: params ?? {} })) + 1);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** The transport behind a per-plugin limit of requests in flight. */
|
|
77
|
+
export class RequestQueue {
|
|
78
|
+
#transport;
|
|
79
|
+
#limit;
|
|
80
|
+
#byteLimit;
|
|
81
|
+
#inFlight = 0;
|
|
82
|
+
#bytes = 0;
|
|
83
|
+
/** Waiting requests in order; `#head` is the first still in it. */
|
|
84
|
+
#waiting = [];
|
|
85
|
+
#head = 0;
|
|
86
|
+
#count = 0;
|
|
87
|
+
/** Set by `close`: later requests go to the transport as they come. */
|
|
88
|
+
#closed = false;
|
|
89
|
+
/** The most in flight at once (the SDK's own tests). */
|
|
90
|
+
peak = 0;
|
|
91
|
+
constructor(transport, limits = REQUEST_LIMITS) {
|
|
92
|
+
this.#transport = transport;
|
|
93
|
+
this.#limit = limits.inFlight;
|
|
94
|
+
this.#byteLimit = limits.inFlightBytes;
|
|
95
|
+
}
|
|
96
|
+
/** Requests sent and not yet answered, and their bytes. */
|
|
97
|
+
get inFlight() {
|
|
98
|
+
return { requests: this.#inFlight, bytes: this.#bytes };
|
|
99
|
+
}
|
|
100
|
+
/** Requests waiting to be sent. */
|
|
101
|
+
get waiting() {
|
|
102
|
+
return this.#count;
|
|
103
|
+
}
|
|
104
|
+
request(method, params, options) {
|
|
105
|
+
const signal = options?.signal;
|
|
106
|
+
if (this.#closed)
|
|
107
|
+
return this.#transport.request(method, params);
|
|
108
|
+
if (signal?.aborted)
|
|
109
|
+
return Promise.reject(abortError());
|
|
110
|
+
const line = lineBytes(method, params);
|
|
111
|
+
// Not writable, or longer than a line: the transport refuses it
|
|
112
|
+
// without writing it, at once as before.
|
|
113
|
+
if (line === undefined || line > MESSAGE_LIMIT)
|
|
114
|
+
return this.#transport.request(method, params);
|
|
115
|
+
const bytes = line + LINE_MARGIN;
|
|
116
|
+
if (UNQUEUED_METHODS.has(method) || (!this.#count && this.#fits(bytes)))
|
|
117
|
+
return this.#send(method, params, bytes);
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const entry = {
|
|
120
|
+
method,
|
|
121
|
+
params,
|
|
122
|
+
bytes,
|
|
123
|
+
resolve: resolve,
|
|
124
|
+
reject,
|
|
125
|
+
signal,
|
|
126
|
+
abort: undefined,
|
|
127
|
+
};
|
|
128
|
+
const index = this.#waiting.length;
|
|
129
|
+
if (signal) {
|
|
130
|
+
entry.abort = () => {
|
|
131
|
+
if (this.#waiting[index] !== entry)
|
|
132
|
+
return;
|
|
133
|
+
this.#waiting[index] = undefined;
|
|
134
|
+
this.#count--;
|
|
135
|
+
reject(abortError());
|
|
136
|
+
};
|
|
137
|
+
signal.addEventListener("abort", entry.abort, { once: true });
|
|
138
|
+
}
|
|
139
|
+
this.#waiting.push(entry);
|
|
140
|
+
this.#count++;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The plugin stops: every waiting request rejects with `error` (the one
|
|
145
|
+
* the runner gives the requests in flight), and later ones go to the
|
|
146
|
+
* transport as they come, which refuses them while stopping.
|
|
147
|
+
*/
|
|
148
|
+
close(error = new HostError("disabled", "plugin stopped")) {
|
|
149
|
+
if (this.#closed)
|
|
150
|
+
return;
|
|
151
|
+
this.#closed = true;
|
|
152
|
+
const waiting = this.#waiting.slice(this.#head);
|
|
153
|
+
this.#waiting = [];
|
|
154
|
+
this.#head = 0;
|
|
155
|
+
this.#count = 0;
|
|
156
|
+
for (const entry of waiting) {
|
|
157
|
+
if (!entry)
|
|
158
|
+
continue;
|
|
159
|
+
entry.signal?.removeEventListener("abort", entry.abort);
|
|
160
|
+
entry.reject(error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
#fits(bytes) {
|
|
164
|
+
return (this.#inFlight < this.#limit &&
|
|
165
|
+
(this.#inFlight === 0 || this.#bytes + bytes <= this.#byteLimit));
|
|
166
|
+
}
|
|
167
|
+
#send(method, params, bytes) {
|
|
168
|
+
let reply;
|
|
169
|
+
try {
|
|
170
|
+
reply = this.#transport.request(method, params);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
// Thrown, not rejected: nothing went out.
|
|
174
|
+
return Promise.reject(error);
|
|
175
|
+
}
|
|
176
|
+
this.#inFlight++;
|
|
177
|
+
this.#bytes += bytes;
|
|
178
|
+
if (this.#inFlight > this.peak)
|
|
179
|
+
this.peak = this.#inFlight;
|
|
180
|
+
// Registered before the caller's own reaction, so the next request goes
|
|
181
|
+
// out before the caller's code runs on (no extra tick for it).
|
|
182
|
+
const done = () => {
|
|
183
|
+
this.#inFlight--;
|
|
184
|
+
this.#bytes -= bytes;
|
|
185
|
+
this.#pump();
|
|
186
|
+
};
|
|
187
|
+
reply.then(done, done);
|
|
188
|
+
return reply;
|
|
189
|
+
}
|
|
190
|
+
#pump() {
|
|
191
|
+
while (this.#count && !this.#closed) {
|
|
192
|
+
let entry = this.#waiting[this.#head];
|
|
193
|
+
while (!entry)
|
|
194
|
+
entry = this.#waiting[++this.#head];
|
|
195
|
+
if (!this.#fits(entry.bytes))
|
|
196
|
+
return;
|
|
197
|
+
this.#waiting[this.#head++] = undefined;
|
|
198
|
+
this.#count--;
|
|
199
|
+
if (entry.abort)
|
|
200
|
+
entry.signal.removeEventListener("abort", entry.abort);
|
|
201
|
+
entry.resolve(this.#send(entry.method, entry.params, entry.bytes));
|
|
202
|
+
}
|
|
203
|
+
// Drained: start the array again rather than let it grow.
|
|
204
|
+
if (!this.#count) {
|
|
205
|
+
this.#waiting = [];
|
|
206
|
+
this.#head = 0;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
package/dist/source.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ export type SourceOperation = {
|
|
|
124
124
|
};
|
|
125
125
|
export declare function sourceClient(transport: Transport): {
|
|
126
126
|
state: () => Promise<SourceState>;
|
|
127
|
-
submit
|
|
127
|
+
/** `signal`: aborted while the submit still waits to be sent, it is not sent. */
|
|
128
|
+
submit: (intent: SourceIntent, operationId?: number, signal?: AbortSignal) => Promise<SourceOperation>;
|
|
128
129
|
operation: (operationId: number) => Promise<SourceOperation>;
|
|
129
130
|
};
|
package/dist/source.js
CHANGED
|
@@ -2,16 +2,14 @@ export function sourceClient(transport) {
|
|
|
2
2
|
let next = 0;
|
|
3
3
|
return {
|
|
4
4
|
state: () => transport.request("source.state"),
|
|
5
|
-
submit
|
|
5
|
+
/** `signal`: aborted while the submit still waits to be sent, it is not sent. */
|
|
6
|
+
submit: (intent, operationId, signal) => {
|
|
6
7
|
operationId ??= next + 1;
|
|
7
8
|
if (!Number.isSafeInteger(operationId) || operationId <= 0) {
|
|
8
9
|
return Promise.reject(Object.assign(new TypeError("operationId must be a positive safe integer"), { code: "invalid" }));
|
|
9
10
|
}
|
|
10
11
|
next = Math.max(next, operationId);
|
|
11
|
-
return transport.request("source.submit", {
|
|
12
|
-
operationId,
|
|
13
|
-
intent,
|
|
14
|
-
});
|
|
12
|
+
return transport.request("source.submit", { operationId, intent }, { signal });
|
|
15
13
|
},
|
|
16
14
|
operation: (operationId) => transport.request("source.operation", { operationId }),
|
|
17
15
|
};
|
package/dist/subtitles.d.ts
CHANGED
|
@@ -174,8 +174,10 @@ export declare function subtitleClient(transport: Transport): {
|
|
|
174
174
|
expected: SubtitleStamp;
|
|
175
175
|
style: SubtitleStyle | null;
|
|
176
176
|
}) => Promise<SubtitleState>;
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
/** `signal`: aborted while the request still waits to be sent, it is not sent. */
|
|
178
|
+
begin: (uploadId: number, generation: number, expectedBytes: number, signal?: AbortSignal) => Promise<SubtitleUpload>;
|
|
179
|
+
/** `signal`: as for `begin`. */
|
|
180
|
+
append: (uploadId: number, offset: number, base64: string, signal?: AbortSignal) => Promise<SubtitleUpload>;
|
|
179
181
|
discard: (uploadId: number) => Promise<void>;
|
|
180
182
|
/** Atomic registration plus selection. inputOrigin guards a translation's original content revision. */
|
|
181
183
|
commit: (options: {
|
package/dist/subtitles.js
CHANGED
|
@@ -4,16 +4,10 @@ export function subtitleClient(transport) {
|
|
|
4
4
|
state: () => transport.request("subtitles.state"),
|
|
5
5
|
/** Property application is not a visible-frame or exact-font identity fence. */
|
|
6
6
|
style: (options) => transport.request("subtitles.style", options),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}),
|
|
12
|
-
append: (uploadId, offset, base64) => transport.request("subtitles.upload.append", {
|
|
13
|
-
uploadId,
|
|
14
|
-
offset,
|
|
15
|
-
base64,
|
|
16
|
-
}),
|
|
7
|
+
/** `signal`: aborted while the request still waits to be sent, it is not sent. */
|
|
8
|
+
begin: (uploadId, generation, expectedBytes, signal) => transport.request("subtitles.upload.begin", { uploadId, generation, expectedBytes }, { signal }),
|
|
9
|
+
/** `signal`: as for `begin`. */
|
|
10
|
+
append: (uploadId, offset, base64, signal) => transport.request("subtitles.upload.append", { uploadId, offset, base64 }, { signal }),
|
|
17
11
|
discard: (uploadId) => transport.request("subtitles.upload.discard", { uploadId }),
|
|
18
12
|
/** Atomic registration plus selection. inputOrigin guards a translation's original content revision. */
|
|
19
13
|
commit: (options) => transport.request("subtitles.commit", options),
|
package/dist/wire.d.ts
CHANGED
|
@@ -655,7 +655,13 @@ export type TemplateArgsJson = ArgJson[] | {
|
|
|
655
655
|
/** A text the player shows: source text, or a text value. */
|
|
656
656
|
export type TextValueJson = string | TextJson | ListJson;
|
|
657
657
|
export interface Transport {
|
|
658
|
-
|
|
658
|
+
/**
|
|
659
|
+
* One request. `options` belong to the plugin's side (the SDK's request
|
|
660
|
+
* queue, `request-queue.ts`) and are never sent; a runner ignores them.
|
|
661
|
+
*/
|
|
662
|
+
request<T>(method: string, params?: Json, options?: {
|
|
663
|
+
signal?: AbortSignal;
|
|
664
|
+
}): Promise<T>;
|
|
659
665
|
on(event: string, listener: (data: unknown) => void): () => void;
|
|
660
666
|
/** Replaces the real local services (test host). */
|
|
661
667
|
local?: LocalServices;
|
|
@@ -1082,7 +1088,7 @@ export declare function createWire(transport: Transport): {
|
|
|
1082
1088
|
};
|
|
1083
1089
|
source: {
|
|
1084
1090
|
state: () => Promise<import("./source.ts").SourceState>;
|
|
1085
|
-
submit: (intent: import("./source.ts").SourceIntent, operationId?: number) => Promise<import("./source.ts").SourceOperation>;
|
|
1091
|
+
submit: (intent: import("./source.ts").SourceIntent, operationId?: number, signal?: AbortSignal) => Promise<import("./source.ts").SourceOperation>;
|
|
1086
1092
|
operation: (operationId: number) => Promise<import("./source.ts").SourceOperation>;
|
|
1087
1093
|
};
|
|
1088
1094
|
sourceResolvers: {
|
|
@@ -1135,8 +1141,8 @@ export declare function createWire(transport: Transport): {
|
|
|
1135
1141
|
expected: import("./subtitles.ts").SubtitleStamp;
|
|
1136
1142
|
style: import("./subtitles.ts").SubtitleStyle | null;
|
|
1137
1143
|
}) => Promise<import("./subtitles.ts").SubtitleState>;
|
|
1138
|
-
begin: (uploadId: number, generation: number, expectedBytes: number) => Promise<import("./subtitles.ts").SubtitleUpload>;
|
|
1139
|
-
append: (uploadId: number, offset: number, base64: string) => Promise<import("./subtitles.ts").SubtitleUpload>;
|
|
1144
|
+
begin: (uploadId: number, generation: number, expectedBytes: number, signal?: AbortSignal) => Promise<import("./subtitles.ts").SubtitleUpload>;
|
|
1145
|
+
append: (uploadId: number, offset: number, base64: string, signal?: AbortSignal) => Promise<import("./subtitles.ts").SubtitleUpload>;
|
|
1140
1146
|
discard: (uploadId: number) => Promise<void>;
|
|
1141
1147
|
commit: (options: {
|
|
1142
1148
|
operationId: number;
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vestra Player SDK
|
|
2
2
|
|
|
3
|
-
> @vestra-player/sdk 1.7.
|
|
3
|
+
> @vestra-player/sdk 1.7.11: write plugins for Vestra Player in TypeScript (plugin API `vestra/1`). A plugin is a folder with `manifest.json` and an entry module whose default export `activate(plugin)` the player calls. The documentation is a tree of short pages read by path, like `go doc`: the same pages and API as https://vestrasys.github.io/vestra-player-sdk/.
|
|
4
4
|
|
|
5
5
|
## Read the documentation
|
|
6
6
|
|