@vestra-player/sdk 1.7.7 → 1.7.8
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 +18 -0
- package/dist/api-requests.js +15 -0
- package/dist/capability-rules.js +46 -21
- package/dist/commands.d.ts +12 -4
- package/dist/commands.js +12 -4
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +18 -0
- package/dist/media.d.ts +108 -1
- package/dist/media.js +20 -0
- package/dist/player-runtime.d.ts +1 -0
- package/dist/player-runtime.js +1 -0
- package/dist/plugin/media.d.ts +26 -0
- package/dist/plugin/media.js +166 -0
- package/dist/plugin/player.d.ts +7 -1
- package/dist/plugin/player.js +3 -1
- package/dist/plugin/testing/index.d.ts +100 -3
- package/dist/plugin/testing/index.js +54 -3
- package/dist/plugin/testing/internals.d.ts +13 -0
- package/dist/plugin/testing/jobs.js +348 -1
- package/dist/plugin/testing/media.js +29 -0
- package/dist/plugin/types/base.d.ts +2 -2
- package/dist/plugin/types/snapshots.d.ts +511 -1
- package/dist/wire.d.ts +28 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.8
|
|
4
|
+
|
|
5
|
+
**Who must change: nobody; additions only.** A plugin that uses them declares the new capability `media.sources` (exports of its files also `media.read` and `media.control`, as any export; `media.sources.open` also `playback.control`, as any open) and needs the player that serves them (`minPlayerVersion` of the first player release after 0.7.6). `apiVersion` stays `vestra/1`; the API surface snapshot gains the new members. Snapshot exports are unchanged.
|
|
6
|
+
|
|
7
|
+
**API design rule (user, 2026-11-10)**: a new API names uses by two or three different plugins, otherwise an existing one is extended. Applied here: `media.sources` is new because several plugins need files the user opened, named without paths and found again after a move: Clip Export (its Collection page), a bookmarks or history plugin (reopen what was watched, at its position), a resume plugin (follow a file across renames with Locate…), a compare plugin (switch between two remembered files) and a chapters plugin (marks per file without storing paths). Exporting several ranges is not a new API: it extends the export of a clip, whose input can now be parts of remembered files instead of a snapshot (one part is a clip of one file).
|
|
8
|
+
|
|
9
|
+
- **`plugin.media.sources`** (`MediaSources`): tokens for local files the user opened, kept by the player across restarts. `remember(options?)` gives a token for the file playing now (a stream, an address or a plugin's picture fails `unsupported`; `ifCurrent` as for a capture), with the file's name, duration and stream facts (`SourceReference`), never its path or content. `get(token)` looks at the file again (`status`: `ok`, `missing`, `changed`), `locate(token)` shows the player's own file dialog and rebinds the token to the user's choice (`null` when cancelled), `forget(token)`, `list()`. A token belongs to the plugin that got it; at most 500 per plugin (`limit`); the player deletes them when the plugin is uninstalled. An unknown token fails `missing`.
|
|
10
|
+
- **`plugin.media.sources.open(token, { start? })`**: the player opens the remembered file and plays it from `start` (Clip Export's "preview this part", a bookmark's "go there"), an ordinary open like `player.open` of that file (the playlist treats it as any open), so it needs `playback.control` as well as `media.sources` (`capability` without either; the player's table has an `ifDeclared` rule for `media.sources.open`); followed until loaded like `player.open` (with `playback.read`). The plugin names the file by its token instead of keeping its path; once it plays, `player.state.source` shows the path as for any open. A missing or changed file rejects with `source-missing` / `source-changed` before anything opens.
|
|
11
|
+
- **`plugin.media.export(options)`** (`PartsExportOptions`): a clip whose input is 1 to 100 parts `{ source: token, start, end }` of remembered files instead of a snapshot, in the formats of a snapshot's clip: `format: "copy"` copies the parts as they are, each from the keyframe at or before its start; `format: "mp4"` re-encodes them to H.264 + AAC at the first part's size and frame rate under the `encoding` ceilings, letterboxed, the sound at 48 kHz stereo. The same `ExportJob` as `Snapshot.export` (the same queue, `done`, `cancel`, `outcome`); on the wire the same `jobs.start`, with `parts` in place of `snapshotId`. `progress` gains `part` and `parts`; `facts.join` says how each part was written; a part whose file is gone ends the job `source-missing`, a changed one `source-changed`.
|
|
12
|
+
- **`plugin.media.exportCheck(parts, options?)`** (`ExportCheck`, wire `jobs.check`): what blocks an export of the parts (`missing`, `changed`, `unknown`, `noVideo`, `range`), whether `copy` can write them (else each difference from the first part: `videoCodec`, `videoParams`, `size`, `fps`, `pixelFormat`, `audio`, with both values) and what `mp4` writes. Cheap (nothing is decoded): run it on every change of a list.
|
|
13
|
+
- **Bounds and safety** (security review): an export's parts are at most 24 hours in all (`invalid`); before writing, the player compares the free space with an estimate for the intermediate parts (kept in its own temporary folder, emptied at its next start, so a crash leaves nothing beside the user's videos) and for the output, and ends the job `failed` with `no-space` when there is too little; every join of a copy is decode-checked, not only the start. One plugin has at most 4 `remember`/`get`/`list`/check requests running (`busy`), and one `locate` dialog every 2 seconds (`busy`). A development load's tokens end with the run that loaded it. Tokens hiding paths is an API convenience, not a security boundary: `player.state.source` has the path of the playing file and plugin processes are not sandboxed from the file system (said at `MediaSources` and `MediaSources.open`). `MEDIA_SOURCE_LIMITS` in the limits reference; `./runtime` exports it for the player's agreement test, and the SDK's parts check and `TestHost` read their bounds from it.
|
|
14
|
+
- **`exportCheck({ snapshot, end })`**: the check also takes a snapshot's clip (one part; no `media.sources` needed), so any export can be checked first; a processed snapshot cannot be copied (reason `effects`). The wire `jobs.check` takes `parts` or `snapshotId`, one of them (`invalid` otherwise); `end` belongs to the `snapshotId` form only, so `parts` with an `end` is `invalid` (in the SDK, `TestHost` and the player). Both kinds count in the plugin's 4 requests. The player's messages for a missing or mistyped field of `media.sources.*` and `jobs.check` are its parser's (`missing field `token``); the code stays `invalid`.
|
|
15
|
+
- **Thumbnails**: no API. A part's thumbnail is a frame the plugin captures while the file plays (`media.capture`, `snapshot.export` as JPEG into its data directory; `media.read`, `media.control`) and shows with `plugin.ui.image(path, { maxSide })` (the example at `MediaSources.remember`).
|
|
16
|
+
- **`TestHost`**: `mediaFiles` (the facts, status and `version` of local files by path; a new version reads `changed` and gets a new token, as the player's size and time), parts exports that end `source-missing` / `source-changed` when their files went or changed, the player's bounds in `jobs.check`, and the SDK refuses parts exports and `media.sources` members without `media.sources`, and `open` without `playback.control` (`capability`), as the player does; `sourceReferences` (token → path) and `sourceOpens`; `exports` also records exports of parts (with `parts`); `locate` takes its answer from `dialogAnswers`. An export of parts advances like a clip's, reporting its middle part while running.
|
|
17
|
+
- Capability table synced from the player (`media.sources`: `media.sources.*`, and `media.sources.open` asks for `playback.control` until it is declared, then for `media.sources`; `jobs.start` with `parts` and `jobs.check` are `media.control`'s, and the player also checks `media.sources` for them); the generated Capabilities, Errors, Limits ("Remembered files and exports of their parts"), Messages and Testing tables follow. Tests: `test/media-sources.test.ts`.
|
|
18
|
+
- **Capability checker** (`vestra-plugin check`, the TypeScript plugin): a member whose `ifDeclared` rules read each other's answers is worked out again until its needs stop changing, so `MediaSources.open` reports both `media.sources` and `playback.control` (before, a rule was decided once). Members whose needs settled at once (`Player.seek`, `Player.open`) are unchanged.
|
|
19
|
+
- **Docs**: `BUILTIN_COMMANDS`, `BUILTIN_SUBMENUS` and the built-in tables of the Commands reference say they are a snapshot of the player's built-ins at this SDK release, which the player may change between SDK releases; a test pins `plugin.appearance`'s list of themes to `THEME_PALETTES`. `PartsExportOptions` says its fields are a snapshot clip's; `ExportPart.source` says it is a token, not a path. `startPlugin` says which capability checks the test host makes (those on the plugin's side) and that `vestra-plugin check` finds the rest.
|
|
20
|
+
|
|
3
21
|
## 1.7.7
|
|
4
22
|
|
|
5
23
|
**Who must change: nobody; the table follows player #235** (the built-in capture plugin keeps snapshots only; clip export moves to a store plugin). A data refresh of `BUILTIN_COMMANDS`: no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged. A plugin whose tests compare a key against the table sees the player's current one: Alt+S, Ctrl+Shift+E and Ctrl+Shift+R are no longer held by a built-in.
|
package/dist/api-requests.js
CHANGED
|
@@ -129,6 +129,21 @@ export const API_REQUESTS = Object.freeze({
|
|
|
129
129
|
{ method: "snapshot.capture" },
|
|
130
130
|
],
|
|
131
131
|
"Snapshot.export": [{ method: "jobs.state" }, { method: "jobs.start" }],
|
|
132
|
+
// Parts of remembered files: also media.sources (documented at the
|
|
133
|
+
// members; the player checks it for jobs.start with parts and jobs.check).
|
|
134
|
+
"MediaCapture.export": [{ method: "jobs.state" }, { method: "jobs.start" }],
|
|
135
|
+
"MediaCapture.exportCheck": [{ method: "jobs.check" }],
|
|
136
|
+
"MediaSources.remember": [{ method: "media.sources.remember" }],
|
|
137
|
+
"MediaSources.get": [{ method: "media.sources.get" }],
|
|
138
|
+
"MediaSources.locate": [{ method: "media.sources.locate" }],
|
|
139
|
+
"MediaSources.forget": [{ method: "media.sources.forget" }],
|
|
140
|
+
"MediaSources.list": [{ method: "media.sources.list" }],
|
|
141
|
+
// An open like Player.open: playback.control (the player's rule for
|
|
142
|
+
// media.sources.open), with which source.operation needs it too.
|
|
143
|
+
"MediaSources.open": [
|
|
144
|
+
{ method: "media.sources.open" },
|
|
145
|
+
{ method: "source.operation" },
|
|
146
|
+
],
|
|
132
147
|
"Osd.show": [{ method: "osd.show" }],
|
|
133
148
|
"Osd.panel": [{ method: "osd.panel" }],
|
|
134
149
|
"Clipboard.readText": [{ method: "clipboard.readText" }],
|
package/dist/capability-rules.js
CHANGED
|
@@ -103,34 +103,59 @@ export function requestsNeed(requests, capabilities, rules = RULES) {
|
|
|
103
103
|
// An `ifDeclared` rule is decided last, as if the plugin had declared what
|
|
104
104
|
// the member's other requests need: `Player.seek` needs `playback.control`
|
|
105
105
|
// for `source.submit`, and with it `source.operation` needs nothing more.
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
// What a rule answers can change what another rule reads, so the needs are
|
|
107
|
+
// worked out again, as if the plugin had declared everything an earlier
|
|
108
|
+
// round needed, until no round adds a capability: `media.sources.open`
|
|
109
|
+
// asks for `playback.control` until it is declared, then for
|
|
110
|
+
// `media.sources` (and `source.operation` follows the first). The set
|
|
111
|
+
// only grows, so the rounds end.
|
|
108
112
|
const conditional = (request) => {
|
|
109
113
|
const rule = hostMethod(request.method, rules.host)?.needs;
|
|
110
114
|
return typeof rule === "object" && rule !== null && "ifDeclared" in rule;
|
|
111
115
|
};
|
|
112
|
-
const
|
|
113
|
-
const add = (need) => {
|
|
114
|
-
if (needs.some((each) => each.capability === need.capability))
|
|
115
|
-
return;
|
|
116
|
-
needs.push(need);
|
|
117
|
-
const entry = rules.host.capabilities.find((capability) => capability.name === need.capability);
|
|
118
|
-
for (const required of entry?.requires ?? [])
|
|
119
|
-
add({
|
|
120
|
-
capability: required,
|
|
121
|
-
method: need.method,
|
|
122
|
-
requiredBy: need.capability,
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
for (const request of [
|
|
116
|
+
const ordered = [
|
|
126
117
|
...requests.filter((request) => !conditional(request)),
|
|
127
118
|
...requests.filter(conditional),
|
|
128
|
-
]
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
119
|
+
];
|
|
120
|
+
const round = (previous) => {
|
|
121
|
+
const needs = [];
|
|
122
|
+
const declared = (name) => capabilities.includes(name) ||
|
|
123
|
+
previous.has(name) ||
|
|
124
|
+
needs.some((need) => need.capability === name);
|
|
125
|
+
const add = (need) => {
|
|
126
|
+
if (needs.some((each) => each.capability === need.capability))
|
|
127
|
+
return;
|
|
128
|
+
needs.push(need);
|
|
129
|
+
const entry = rules.host.capabilities.find((capability) => capability.name === need.capability);
|
|
130
|
+
for (const required of entry?.requires ?? [])
|
|
131
|
+
add({
|
|
132
|
+
capability: required,
|
|
133
|
+
method: need.method,
|
|
134
|
+
requiredBy: need.capability,
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
for (const request of ordered) {
|
|
138
|
+
const capability = requestNeeds(request.method, request.params, declared, rules.host);
|
|
139
|
+
if (capability)
|
|
140
|
+
add({ capability, method: request.method });
|
|
141
|
+
}
|
|
142
|
+
return needs;
|
|
143
|
+
};
|
|
144
|
+
// Every capability any round needed; the answer is the last round's needs
|
|
145
|
+
// (read with all of them declared) and then any earlier one it left out.
|
|
146
|
+
const all = new Map();
|
|
147
|
+
for (;;) {
|
|
148
|
+
const needs = round(new Set(all.keys()));
|
|
149
|
+
const before = all.size;
|
|
150
|
+
for (const need of needs)
|
|
151
|
+
if (!all.has(need.capability))
|
|
152
|
+
all.set(need.capability, need);
|
|
153
|
+
if (all.size === before)
|
|
154
|
+
return [
|
|
155
|
+
...needs,
|
|
156
|
+
...[...all.values()].filter((need) => !needs.some((each) => each.capability === need.capability)),
|
|
157
|
+
];
|
|
132
158
|
}
|
|
133
|
-
return needs;
|
|
134
159
|
}
|
|
135
160
|
/**
|
|
136
161
|
* `CAPABILITY_INFO` from the tables: the label, highlight and requirements
|
package/dist/commands.d.ts
CHANGED
|
@@ -198,8 +198,12 @@ export interface BuiltinSubmenu {
|
|
|
198
198
|
* with the same keys appears in the same submenu, whatever the interface
|
|
199
199
|
* language; the submenu's title is the declaring plugin's translation. The
|
|
200
200
|
* player's own submenus (`Playback ▸ Speed`, `Playback ▸ Seek`) are not
|
|
201
|
-
* listed.
|
|
202
|
-
*
|
|
201
|
+
* listed.
|
|
202
|
+
*
|
|
203
|
+
* A snapshot of the player's built-in submenus at this SDK release; the
|
|
204
|
+
* player may differ between SDK releases. The player's tests check that
|
|
205
|
+
* this list agrees with what its built-in plugins declare when the SDK is
|
|
206
|
+
* released.
|
|
203
207
|
*
|
|
204
208
|
* @example Add an item to the built-in Snapshot submenu
|
|
205
209
|
* "Copy Snapshot" appears in Snapshot ▸ next to the built-in capture
|
|
@@ -264,8 +268,12 @@ export interface BuiltinCommand {
|
|
|
264
268
|
* placeholders (`No Audio Tracks`) are. Items that appear only in a
|
|
265
269
|
* passing state are not listed either: the Picture Adjustments plugin's
|
|
266
270
|
* `Video ▸ Restart Player to Apply` (`video.gpu-rendering.restart`), shown
|
|
267
|
-
* while a rendering choice waits for the next start.
|
|
268
|
-
*
|
|
271
|
+
* while a rendering choice waits for the next start.
|
|
272
|
+
*
|
|
273
|
+
* A snapshot of the player's built-in commands at this SDK release; the
|
|
274
|
+
* player may differ between SDK releases. The player's tests check that
|
|
275
|
+
* this list agrees with what the player and its built-in plugins register
|
|
276
|
+
* when the SDK is released, not with the player a user runs later.
|
|
269
277
|
*
|
|
270
278
|
* @example Check in a test that a default key is still free
|
|
271
279
|
* The test fails if the player or a built-in plugin already binds Ctrl+K
|
package/dist/commands.js
CHANGED
|
@@ -224,8 +224,12 @@ export const BAR_BUTTON_LIMITS = {
|
|
|
224
224
|
* with the same keys appears in the same submenu, whatever the interface
|
|
225
225
|
* language; the submenu's title is the declaring plugin's translation. The
|
|
226
226
|
* player's own submenus (`Playback ▸ Speed`, `Playback ▸ Seek`) are not
|
|
227
|
-
* listed.
|
|
228
|
-
*
|
|
227
|
+
* listed.
|
|
228
|
+
*
|
|
229
|
+
* A snapshot of the player's built-in submenus at this SDK release; the
|
|
230
|
+
* player may differ between SDK releases. The player's tests check that
|
|
231
|
+
* this list agrees with what its built-in plugins declare when the SDK is
|
|
232
|
+
* released.
|
|
229
233
|
*
|
|
230
234
|
* @example Add an item to the built-in Snapshot submenu
|
|
231
235
|
* "Copy Snapshot" appears in Snapshot ▸ next to the built-in capture
|
|
@@ -603,8 +607,12 @@ vestra.video | video.upscaling | (AI Upscaling)
|
|
|
603
607
|
* placeholders (`No Audio Tracks`) are. Items that appear only in a
|
|
604
608
|
* passing state are not listed either: the Picture Adjustments plugin's
|
|
605
609
|
* `Video ▸ Restart Player to Apply` (`video.gpu-rendering.restart`), shown
|
|
606
|
-
* while a rendering choice waits for the next start.
|
|
607
|
-
*
|
|
610
|
+
* while a rendering choice waits for the next start.
|
|
611
|
+
*
|
|
612
|
+
* A snapshot of the player's built-in commands at this SDK release; the
|
|
613
|
+
* player may differ between SDK releases. The player's tests check that
|
|
614
|
+
* this list agrees with what the player and its built-in plugins register
|
|
615
|
+
* when the SDK is released, not with the player a user runs later.
|
|
608
616
|
*
|
|
609
617
|
* @example Check in a test that a default key is still free
|
|
610
618
|
* The test fails if the player or a built-in plugin already binds Ctrl+K
|
package/dist/docs-tree.json.gz
CHANGED
|
Binary file
|
|
@@ -250,6 +250,24 @@ export const HOST_CAPABILITIES = {
|
|
|
250
250
|
residency: "live",
|
|
251
251
|
risky: false,
|
|
252
252
|
},
|
|
253
|
+
{
|
|
254
|
+
label: "Remember videos you add and export from them later",
|
|
255
|
+
methods: [
|
|
256
|
+
{
|
|
257
|
+
name: "media.sources.open",
|
|
258
|
+
needs: {
|
|
259
|
+
ifDeclared: "playback.control",
|
|
260
|
+
otherwise: "playback.control",
|
|
261
|
+
then: "media.sources",
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{ name: "media.sources.*", needs: "media.sources" },
|
|
265
|
+
],
|
|
266
|
+
name: "media.sources",
|
|
267
|
+
requires: [],
|
|
268
|
+
residency: "none",
|
|
269
|
+
risky: false,
|
|
270
|
+
},
|
|
253
271
|
{
|
|
254
272
|
label: "Show messages on the video",
|
|
255
273
|
methods: [
|
package/dist/media.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Finite media jobs. Native-subtitle freezing remains pending. */
|
|
2
2
|
import type { Transport } from "./wire.ts";
|
|
3
|
-
import type { SourceStamp, SourceAudioTrack } from "./source.ts";
|
|
3
|
+
import type { SourceStamp, SourceAudioTrack, SourceOperation } from "./source.ts";
|
|
4
4
|
import type { VideoNode, AudioNode } from "./processing.ts";
|
|
5
5
|
import type { SubtitleStamp, SubtitleStyle, SubtitleTrack } from "./subtitles.ts";
|
|
6
6
|
export type RawSnapshot = {
|
|
@@ -174,6 +174,22 @@ export type MediaJob = {
|
|
|
174
174
|
end: number;
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
|
+
/** An export of parts (`jobs.start { parts }`): how it was written. */
|
|
178
|
+
join?: {
|
|
179
|
+
mode: "copy" | "mp4";
|
|
180
|
+
container: "mp4" | "mkv";
|
|
181
|
+
/** Each part as written, in seconds of its own file. */
|
|
182
|
+
parts: {
|
|
183
|
+
start: number;
|
|
184
|
+
end: number;
|
|
185
|
+
}[];
|
|
186
|
+
/** A re-encode: the output size and frame rate. */
|
|
187
|
+
target: {
|
|
188
|
+
width: number;
|
|
189
|
+
height: number;
|
|
190
|
+
fps: number;
|
|
191
|
+
} | null;
|
|
192
|
+
};
|
|
177
193
|
};
|
|
178
194
|
outcome: null | {
|
|
179
195
|
destination: string;
|
|
@@ -196,6 +212,10 @@ export type MediaJob = {
|
|
|
196
212
|
progress?: {
|
|
197
213
|
done: number;
|
|
198
214
|
total: number;
|
|
215
|
+
/** An export of parts: the part being written, from 1. */
|
|
216
|
+
part?: number;
|
|
217
|
+
/** An export of parts: how many parts. */
|
|
218
|
+
parts?: number;
|
|
199
219
|
} | null;
|
|
200
220
|
};
|
|
201
221
|
/** The wire form of `ExportEncoding` (`jobs.start`). */
|
|
@@ -208,6 +228,62 @@ export type WireEncoding = {
|
|
|
208
228
|
threads?: "single" | "auto";
|
|
209
229
|
videoBitrate?: "source";
|
|
210
230
|
};
|
|
231
|
+
/** A source reference as the player describes it (`media.sources.*`). */
|
|
232
|
+
export type WireSourceReference = {
|
|
233
|
+
token: string;
|
|
234
|
+
name: string;
|
|
235
|
+
duration: number;
|
|
236
|
+
status: "ok" | "missing" | "changed";
|
|
237
|
+
video: {
|
|
238
|
+
codec: string;
|
|
239
|
+
width: number;
|
|
240
|
+
height: number;
|
|
241
|
+
fps: number;
|
|
242
|
+
pixelFormat: string | null;
|
|
243
|
+
} | null;
|
|
244
|
+
audio: {
|
|
245
|
+
codec: string;
|
|
246
|
+
sampleRate: number;
|
|
247
|
+
channels: number;
|
|
248
|
+
} | null;
|
|
249
|
+
};
|
|
250
|
+
/** One part of an export (`jobs.start { parts }`, `jobs.check`). */
|
|
251
|
+
export type WireExportPart = {
|
|
252
|
+
source: string;
|
|
253
|
+
start: number;
|
|
254
|
+
end: number;
|
|
255
|
+
};
|
|
256
|
+
/** The answer of `jobs.check`. */
|
|
257
|
+
export type WireExportCheck = {
|
|
258
|
+
blocking: {
|
|
259
|
+
part: number;
|
|
260
|
+
problem: "unknown" | "missing" | "changed" | "noVideo" | "range";
|
|
261
|
+
/** `range`: the file's duration. */
|
|
262
|
+
duration?: number;
|
|
263
|
+
}[];
|
|
264
|
+
copy: {
|
|
265
|
+
ok: true;
|
|
266
|
+
container: "mp4" | "mkv";
|
|
267
|
+
} | {
|
|
268
|
+
ok: false;
|
|
269
|
+
reasons: {
|
|
270
|
+
part: number;
|
|
271
|
+
field: "videoCodec" | "videoParams" | "size" | "fps" | "pixelFormat" | "audio" | "effects";
|
|
272
|
+
value: string | number | null;
|
|
273
|
+
expected: string | number | null;
|
|
274
|
+
}[];
|
|
275
|
+
};
|
|
276
|
+
encode: {
|
|
277
|
+
width: number;
|
|
278
|
+
height: number;
|
|
279
|
+
fps: number;
|
|
280
|
+
audio: {
|
|
281
|
+
sampleRate: 48000;
|
|
282
|
+
channels: 2;
|
|
283
|
+
} | null;
|
|
284
|
+
} | null;
|
|
285
|
+
duration: number;
|
|
286
|
+
};
|
|
211
287
|
export type MediaOperation = {
|
|
212
288
|
status: "pending" | "unknown" | "unknownExpired";
|
|
213
289
|
} | {
|
|
@@ -264,5 +340,36 @@ export declare function mediaClients(transport: Transport): {
|
|
|
264
340
|
cancel: "requested" | "tooLate" | "terminal";
|
|
265
341
|
}>;
|
|
266
342
|
operation: (operationId: number) => Promise<MediaOperation>;
|
|
343
|
+
/** `jobs.start` with parts of remembered files instead of a snapshot. */
|
|
344
|
+
startParts: (options: {
|
|
345
|
+
operationId: number;
|
|
346
|
+
parts: WireExportPart[];
|
|
347
|
+
destination: string;
|
|
348
|
+
} & ({
|
|
349
|
+
kind: "rawCopy";
|
|
350
|
+
container?: "auto" | "mp4" | "mkv";
|
|
351
|
+
} | {
|
|
352
|
+
kind: "rawMp4";
|
|
353
|
+
encoding?: WireEncoding;
|
|
354
|
+
})) => Promise<{
|
|
355
|
+
jobId: number;
|
|
356
|
+
status: "queued";
|
|
357
|
+
}>;
|
|
358
|
+
check: (parts: WireExportPart[], encoding?: WireEncoding) => Promise<WireExportCheck>;
|
|
359
|
+
/** `jobs.check` of a snapshot's clip (to `end`) instead of parts. */
|
|
360
|
+
checkSnapshot: (snapshotId: number, end: number, encoding?: WireEncoding) => Promise<WireExportCheck>;
|
|
361
|
+
};
|
|
362
|
+
mediaSources: {
|
|
363
|
+
remember: (expected?: SourceStamp) => Promise<WireSourceReference>;
|
|
364
|
+
get: (token: string) => Promise<WireSourceReference>;
|
|
365
|
+
locate: (token: string) => Promise<WireSourceReference | null>;
|
|
366
|
+
forget: (token: string) => Promise<void>;
|
|
367
|
+
list: () => Promise<WireSourceReference[]>;
|
|
368
|
+
/** An `open` submit of the file, under the player service's operation id. */
|
|
369
|
+
open: (options: {
|
|
370
|
+
token: string;
|
|
371
|
+
operationId: number;
|
|
372
|
+
start?: number;
|
|
373
|
+
}) => Promise<SourceOperation>;
|
|
267
374
|
};
|
|
268
375
|
};
|
package/dist/media.js
CHANGED
|
@@ -16,6 +16,26 @@ export function mediaClients(transport) {
|
|
|
16
16
|
state: (jobId) => transport.request("jobs.state", { jobId }),
|
|
17
17
|
cancel: (jobId, operationId) => transport.request("jobs.cancel", { jobId, operationId }),
|
|
18
18
|
operation: (operationId) => transport.request("jobs.operation", { operationId }),
|
|
19
|
+
/** `jobs.start` with parts of remembered files instead of a snapshot. */
|
|
20
|
+
startParts: (options) => transport.request("jobs.start", options),
|
|
21
|
+
check: (parts, encoding) => transport.request("jobs.check", encoding === undefined ? { parts } : { parts, encoding }),
|
|
22
|
+
/** `jobs.check` of a snapshot's clip (to `end`) instead of parts. */
|
|
23
|
+
checkSnapshot: (snapshotId, end, encoding) => transport.request("jobs.check", encoding === undefined
|
|
24
|
+
? { snapshotId, end }
|
|
25
|
+
: { snapshotId, end, encoding }),
|
|
26
|
+
},
|
|
27
|
+
mediaSources: {
|
|
28
|
+
remember: (expected) => transport.request("media.sources.remember", expected === undefined ? {} : { expected }),
|
|
29
|
+
get: (token) => transport.request("media.sources.get", {
|
|
30
|
+
token,
|
|
31
|
+
}),
|
|
32
|
+
locate: (token) => transport.request("media.sources.locate", {
|
|
33
|
+
token,
|
|
34
|
+
}),
|
|
35
|
+
forget: (token) => transport.request("media.sources.forget", { token }),
|
|
36
|
+
list: () => transport.request("media.sources.list", {}),
|
|
37
|
+
/** An `open` submit of the file, under the player service's operation id. */
|
|
38
|
+
open: (options) => transport.request("media.sources.open", options),
|
|
19
39
|
},
|
|
20
40
|
};
|
|
21
41
|
}
|
package/dist/player-runtime.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { API_VERSION, CAPABILITIES, CAPABILITY_INFO, MESSAGE_LIMIT, } from "./ca
|
|
|
15
15
|
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
|
+
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.ts";
|
|
18
19
|
export { OSD_LIMITS } from "./plugin/osd.ts";
|
|
19
20
|
export { TIMELINE_LIMITS } from "./plugin/timeline.ts";
|
|
20
21
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
|
package/dist/player-runtime.js
CHANGED
|
@@ -13,6 +13,7 @@ export { API_VERSION, CAPABILITIES, CAPABILITY_INFO, MESSAGE_LIMIT, } from "./ca
|
|
|
13
13
|
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
|
+
export { MEDIA_SOURCE_LIMITS } from "./plugin/media.js";
|
|
16
17
|
export { OSD_LIMITS } from "./plugin/osd.js";
|
|
17
18
|
export { TIMELINE_LIMITS } from "./plugin/timeline.js";
|
|
18
19
|
export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
|
package/dist/plugin/media.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
import type { ScopeImpl } from "./scope.ts";
|
|
2
2
|
import type { MediaCapture } from "./types.ts";
|
|
3
3
|
export declare function mediaCapture(scope: ScopeImpl): MediaCapture;
|
|
4
|
+
/**
|
|
5
|
+
* The player's bounds of remembered files and exports of their parts,
|
|
6
|
+
* documented in the limits reference. Exported from `./runtime` only, for
|
|
7
|
+
* the player's agreement test; TestHost and the SDK's own checks read
|
|
8
|
+
* these figures. The bound on references is a resource limit; tokens are
|
|
9
|
+
* an API convenience, not a security boundary.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const MEDIA_SOURCE_LIMITS: Readonly<{
|
|
14
|
+
/** References one plugin may hold; one more fails with `limit` (500). */
|
|
15
|
+
readonly references: 500;
|
|
16
|
+
/** Parts of one export or check, at least 1; more fail with `invalid` (100). */
|
|
17
|
+
readonly parts: 100;
|
|
18
|
+
/** Seconds of a part's end in its file (24 hours). */
|
|
19
|
+
readonly partEnd: 86400;
|
|
20
|
+
/** Seconds of all parts of one export together, as one clip (24 hours). */
|
|
21
|
+
readonly totalSeconds: 86400;
|
|
22
|
+
/**
|
|
23
|
+
* `remember`, `get`, `list` and checks one plugin may have the
|
|
24
|
+
* player working on at the same time; one more fails with `busy` (4).
|
|
25
|
+
*/
|
|
26
|
+
readonly requests: 4;
|
|
27
|
+
/** Seconds between two `locate` dialogs of one plugin; sooner fails with `busy` (2). */
|
|
28
|
+
readonly locateInterval: 2;
|
|
29
|
+
}>;
|
package/dist/plugin/media.js
CHANGED
|
@@ -140,6 +140,8 @@ class JobHandle {
|
|
|
140
140
|
await this.cancel().catch(() => { });
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
+
/** A live snapshot's id, for `exportCheck({ snapshot })`. */
|
|
144
|
+
const snapshotIds = new WeakMap();
|
|
143
145
|
class SnapshotHandle {
|
|
144
146
|
#scope;
|
|
145
147
|
#service;
|
|
@@ -150,6 +152,11 @@ class SnapshotHandle {
|
|
|
150
152
|
this.#service = service;
|
|
151
153
|
this.#frozen = frozen;
|
|
152
154
|
scope.add(this);
|
|
155
|
+
snapshotIds.set(this, () => {
|
|
156
|
+
if (this.#released)
|
|
157
|
+
throw failure("released", "snapshot already released");
|
|
158
|
+
return this.#frozen.snapshotId;
|
|
159
|
+
});
|
|
153
160
|
}
|
|
154
161
|
get kind() {
|
|
155
162
|
return this.#frozen.kind;
|
|
@@ -311,5 +318,164 @@ export function mediaCapture(scope) {
|
|
|
311
318
|
: await runtime.host.snapshot.state(captured.snapshotId);
|
|
312
319
|
return new SnapshotHandle(scope, service, frozen);
|
|
313
320
|
},
|
|
321
|
+
sources: mediaSources(scope),
|
|
322
|
+
async export(options) {
|
|
323
|
+
const runtime = scope.runtime;
|
|
324
|
+
const service = serviceOf(runtime);
|
|
325
|
+
if (typeof options !== "object" || options === null)
|
|
326
|
+
throw failure("invalid", "export options must be an object");
|
|
327
|
+
needSources(scope);
|
|
328
|
+
const parts = checkParts(options.parts);
|
|
329
|
+
let mode;
|
|
330
|
+
if (options.format === "copy") {
|
|
331
|
+
const container = options.container;
|
|
332
|
+
if (container !== undefined &&
|
|
333
|
+
!["auto", "mp4", "mkv"].includes(container))
|
|
334
|
+
throw failure("invalid", "container must be auto, mp4 or mkv");
|
|
335
|
+
if (options.encoding !== undefined)
|
|
336
|
+
throw failure("invalid", "a copy takes no encoding");
|
|
337
|
+
mode = {
|
|
338
|
+
kind: "rawCopy",
|
|
339
|
+
...(container === undefined ? {} : { container }),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
else if (options.format === "mp4") {
|
|
343
|
+
if (options.container !== undefined)
|
|
344
|
+
throw failure("invalid", "a re-encode takes no container");
|
|
345
|
+
mode = {
|
|
346
|
+
kind: "rawMp4",
|
|
347
|
+
...(options.encoding === undefined
|
|
348
|
+
? {}
|
|
349
|
+
: { encoding: checkEncoding(options.encoding) }),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
else
|
|
353
|
+
throw failure("invalid", `an export of parts is format copy or mp4, not ${String(options.format)}`);
|
|
354
|
+
const result = await service.mutate((operationId) => runtime.host.jobs.startParts({
|
|
355
|
+
operationId,
|
|
356
|
+
parts,
|
|
357
|
+
destination: options.destination,
|
|
358
|
+
...mode,
|
|
359
|
+
}));
|
|
360
|
+
return new JobHandle(scope, service, result.jobId);
|
|
361
|
+
},
|
|
362
|
+
async exportCheck(input, options) {
|
|
363
|
+
const encoding = options?.encoding === undefined
|
|
364
|
+
? undefined
|
|
365
|
+
: checkEncoding(options.encoding);
|
|
366
|
+
if (!Array.isArray(input)) {
|
|
367
|
+
// A snapshot's clip: needs no media.sources.
|
|
368
|
+
const id = input?.snapshot
|
|
369
|
+
? snapshotIds.get(input.snapshot)
|
|
370
|
+
: undefined;
|
|
371
|
+
if (!id)
|
|
372
|
+
throw failure("invalid", "exportCheck takes parts or { snapshot, end }");
|
|
373
|
+
if (!Number.isFinite(input.end))
|
|
374
|
+
throw failure("invalid", "end must be seconds");
|
|
375
|
+
return scope.runtime.host.jobs.checkSnapshot(id(), input.end, encoding);
|
|
376
|
+
}
|
|
377
|
+
// As the player: parts carry their own ends; `end` is a snapshot's.
|
|
378
|
+
if (options?.end !== undefined)
|
|
379
|
+
throw failure("invalid", "end belongs to a snapshot's check; parts carry their own end");
|
|
380
|
+
needSources(scope);
|
|
381
|
+
return scope.runtime.host.jobs.check(checkParts(input), encoding);
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* The player's bounds of remembered files and exports of their parts,
|
|
387
|
+
* documented in the limits reference. Exported from `./runtime` only, for
|
|
388
|
+
* the player's agreement test; TestHost and the SDK's own checks read
|
|
389
|
+
* these figures. The bound on references is a resource limit; tokens are
|
|
390
|
+
* an API convenience, not a security boundary.
|
|
391
|
+
*
|
|
392
|
+
* @internal
|
|
393
|
+
*/
|
|
394
|
+
export const MEDIA_SOURCE_LIMITS = Object.freeze({
|
|
395
|
+
/** References one plugin may hold; one more fails with `limit` (500). */
|
|
396
|
+
references: 500,
|
|
397
|
+
/** Parts of one export or check, at least 1; more fail with `invalid` (100). */
|
|
398
|
+
parts: 100,
|
|
399
|
+
/** Seconds of a part's end in its file (24 hours). */
|
|
400
|
+
partEnd: 86400,
|
|
401
|
+
/** Seconds of all parts of one export together, as one clip (24 hours). */
|
|
402
|
+
totalSeconds: 86400,
|
|
403
|
+
/**
|
|
404
|
+
* `remember`, `get`, `list` and checks one plugin may have the
|
|
405
|
+
* player working on at the same time; one more fails with `busy` (4).
|
|
406
|
+
*/
|
|
407
|
+
requests: 4,
|
|
408
|
+
/** Seconds between two `locate` dialogs of one plugin; sooner fails with `busy` (2). */
|
|
409
|
+
locateInterval: 2,
|
|
410
|
+
});
|
|
411
|
+
/** Refuse what the player would refuse of an export's parts, naming the part. */
|
|
412
|
+
function checkParts(parts) {
|
|
413
|
+
if (!Array.isArray(parts) ||
|
|
414
|
+
parts.length === 0 ||
|
|
415
|
+
parts.length > MEDIA_SOURCE_LIMITS.parts)
|
|
416
|
+
throw failure("invalid", `an export takes 1 to ${MEDIA_SOURCE_LIMITS.parts} parts`);
|
|
417
|
+
const checked = parts.map((part, index) => {
|
|
418
|
+
const { source, start, end } = part ?? {};
|
|
419
|
+
if (typeof source !== "string" || source === "")
|
|
420
|
+
throw failure("invalid", `part ${index}: source must be a token`);
|
|
421
|
+
if (!Number.isFinite(start) ||
|
|
422
|
+
!Number.isFinite(end) ||
|
|
423
|
+
start < 0 ||
|
|
424
|
+
end > MEDIA_SOURCE_LIMITS.partEnd ||
|
|
425
|
+
end <= start)
|
|
426
|
+
throw failure("invalid", `part ${index}: start and end must be seconds with 0 <= start < end <= ${MEDIA_SOURCE_LIMITS.partEnd}`);
|
|
427
|
+
return { source, start, end };
|
|
428
|
+
});
|
|
429
|
+
const total = checked.reduce((sum, part) => sum + part.end - part.start, 0);
|
|
430
|
+
if (total > MEDIA_SOURCE_LIMITS.totalSeconds)
|
|
431
|
+
throw failure("invalid", `the parts are ${total} s long; an export takes at most ${MEDIA_SOURCE_LIMITS.totalSeconds} s`);
|
|
432
|
+
return checked;
|
|
433
|
+
}
|
|
434
|
+
/** The parts' tokens are media.sources': refuse at once without it, as the player does. */
|
|
435
|
+
function needSources(scope) {
|
|
436
|
+
if (!scope.runtime.can("media.sources"))
|
|
437
|
+
throw failure("capability", "media.sources must be declared in manifest");
|
|
438
|
+
}
|
|
439
|
+
function mediaSources(scope) {
|
|
440
|
+
const host = () => {
|
|
441
|
+
needSources(scope);
|
|
442
|
+
return scope.runtime.host.mediaSources;
|
|
443
|
+
};
|
|
444
|
+
const token = (value) => {
|
|
445
|
+
if (typeof value !== "string" || value === "")
|
|
446
|
+
throw failure("invalid", "token must be a non-empty string");
|
|
447
|
+
return value;
|
|
448
|
+
};
|
|
449
|
+
return {
|
|
450
|
+
async remember(options) {
|
|
451
|
+
// Conditional like a capture: the token is for the file in `ifCurrent`.
|
|
452
|
+
const expected = options?.ifCurrent === undefined
|
|
453
|
+
? undefined
|
|
454
|
+
: playerOf(scope.runtime).expected(options.ifCurrent).expected;
|
|
455
|
+
return host().remember(expected);
|
|
456
|
+
},
|
|
457
|
+
get: async (value) => host().get(token(value)),
|
|
458
|
+
locate: async (value) => host().locate(token(value)),
|
|
459
|
+
forget: async (value) => host().forget(token(value)),
|
|
460
|
+
list: async () => host().list(),
|
|
461
|
+
async open(value, options = {}) {
|
|
462
|
+
needSources(scope);
|
|
463
|
+
// An open like Player.open's: the player asks playback.control too.
|
|
464
|
+
if (!scope.runtime.can("playback.control"))
|
|
465
|
+
throw failure("capability", "playback.control must be declared in manifest");
|
|
466
|
+
const start = options?.start;
|
|
467
|
+
if (start !== undefined && !(Number.isFinite(start) && start >= 0))
|
|
468
|
+
throw failure("invalid", "start must be seconds from 0");
|
|
469
|
+
const checked = token(value);
|
|
470
|
+
// An ordinary open, followed like player.open's (the player opens the
|
|
471
|
+
// path the token stands for; the plugin never sees it).
|
|
472
|
+
await playerOf(scope.runtime).submit({ kind: "open", source: "", startPaused: false }, {
|
|
473
|
+
send: (operationId) => host().open({
|
|
474
|
+
token: checked,
|
|
475
|
+
operationId,
|
|
476
|
+
...(start === undefined ? {} : { start }),
|
|
477
|
+
}),
|
|
478
|
+
});
|
|
479
|
+
},
|
|
314
480
|
};
|
|
315
481
|
}
|
package/dist/plugin/player.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SourceIntent, SourceStamp, SourceState, SourceTicket } from "../source.ts";
|
|
1
|
+
import type { SourceIntent, SourceOperation, SourceStamp, SourceState, SourceTicket } from "../source.ts";
|
|
2
2
|
import { Latest } from "./latest.ts";
|
|
3
3
|
import type { Runtime } from "./runtime.ts";
|
|
4
4
|
import type { ScopeImpl } from "./scope.ts";
|
|
@@ -69,6 +69,12 @@ export declare class PlayerService implements StreamSource {
|
|
|
69
69
|
submit(intent: SourceIntent, options?: {
|
|
70
70
|
signal?: AbortSignal;
|
|
71
71
|
accepted?: (ticket: SourceTicket) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Send the submit another way under this service's operation id
|
|
74
|
+
* (`media.sources.open`, which the player turns into this intent's
|
|
75
|
+
* `source.submit`); followed with `source.operation` as any submit.
|
|
76
|
+
*/
|
|
77
|
+
send?: (operationId: number) => Promise<SourceOperation>;
|
|
72
78
|
}): Promise<SourceTicket>;
|
|
73
79
|
expected(state: PlayerState | undefined): {
|
|
74
80
|
expected?: SourceStamp;
|