@vestra-player/sdk 1.6.21 → 1.7.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/bin/vestra-plugin.mjs +34 -12
  3. package/dist/api-requests.d.ts +22 -0
  4. package/dist/api-requests.js +38 -0
  5. package/dist/capability-check.d.ts +48 -0
  6. package/dist/capability-check.js +219 -51
  7. package/dist/capability-rules.d.ts +21 -0
  8. package/dist/capability-rules.js +32 -1
  9. package/dist/commands.d.ts +9 -1
  10. package/dist/commands.js +8 -8
  11. package/dist/docs-tree.json.gz +0 -0
  12. package/dist/plugin/commands.js +43 -13
  13. package/dist/plugin/connection.d.ts +37 -0
  14. package/dist/plugin/connection.js +34 -0
  15. package/dist/plugin/index.js +12 -2
  16. package/dist/plugin/media.js +3 -1
  17. package/dist/plugin/packages.js +3 -1
  18. package/dist/plugin/passes.d.ts +38 -1
  19. package/dist/plugin/passes.js +89 -5
  20. package/dist/plugin/player/events.d.ts +9 -0
  21. package/dist/plugin/player/events.js +43 -0
  22. package/dist/plugin/player/rules.d.ts +7 -0
  23. package/dist/plugin/player/rules.js +11 -0
  24. package/dist/plugin/player.d.ts +37 -4
  25. package/dist/plugin/player.js +85 -12
  26. package/dist/plugin/resolvers.js +2 -3
  27. package/dist/plugin/runtime.d.ts +2 -3
  28. package/dist/plugin/runtime.js +8 -2
  29. package/dist/plugin/scope.d.ts +9 -0
  30. package/dist/plugin/scope.js +24 -0
  31. package/dist/plugin/services.js +4 -5
  32. package/dist/plugin/state.d.ts +3 -0
  33. package/dist/plugin/state.js +81 -0
  34. package/dist/plugin/stream.d.ts +27 -3
  35. package/dist/plugin/testing/commands.js +3 -3
  36. package/dist/plugin/testing/core-actions.js +1 -1
  37. package/dist/plugin/testing/services.js +1 -1
  38. package/dist/plugin/types/base.d.ts +78 -2
  39. package/dist/plugin/types/commands.d.ts +17 -1
  40. package/dist/plugin/types/playback.d.ts +156 -1
  41. package/dist/plugin/types/plugin-wire.d.ts +589 -0
  42. package/dist/plugin/types/plugin-wire.js +1 -0
  43. package/dist/plugin/types/ui-content.d.ts +23 -4
  44. package/dist/plugin/types/ui-layout.d.ts +1 -1
  45. package/dist/plugin/types/ui-shell.d.ts +4 -3
  46. package/dist/plugin/types.d.ts +4 -2
  47. package/dist/plugin/view/base.d.ts +10 -3
  48. package/dist/plugin/view/base.js +30 -6
  49. package/dist/plugin/view/binder.js +8 -1
  50. package/dist/plugin/view/writer.d.ts +49 -4
  51. package/dist/plugin/view/writer.js +383 -17
  52. package/dist/plugin/wire-facade.d.ts +4 -0
  53. package/dist/plugin/wire-facade.js +190 -0
  54. package/dist/ts-plugin.d.ts +3 -0
  55. package/dist/ts-plugin.js +18 -6
  56. package/dist/wire.d.ts +233 -20
  57. package/llms.txt +3 -3
  58. package/package.json +1 -1
  59. package/slint/vestra/focus.slint +33 -0
@@ -0,0 +1,190 @@
1
+ /**
2
+ * `plugin.wire` (SDK 1.7.0; doc/specs/sdk-refactor.md §3.3 and §4 Step 3
3
+ * in the player repository): the protocol (L0) and the primitives (L1)
4
+ * behind one experimental member, for the plugin's own direct messages.
5
+ * Not to be confused with `src/wire.ts` (later `src/wire/`), the L0 code
6
+ * itself: this file hands out access to it, and is the only file under
7
+ * `src/plugin/` that sends a request by a method name it was given
8
+ * (`scripts/check-layers.mjs`, rule 7).
9
+ *
10
+ * - `request`: `Connection.request`, the transport as is; the player
11
+ * checks capabilities. The subscriptions are guarded, refused with
12
+ * `invalid`: `events.subscribe` and `events.unsubscribe` of a
13
+ * `HostEvent` (the SDK owns those subscriptions and their marks; `on`
14
+ * covers them), and `events.subscribe` of any other event without
15
+ * `why` or `mirror` (the player would misjudge whether the plugin
16
+ * listens: lazy activation).
17
+ * - `on`: a {@link HostEvent} through `Connection.on`, always a listener
18
+ * with its `why`, never a mirror (as `player.on`); any other name through
19
+ * `Connection.raw`, no subscription.
20
+ * - `view(v)`: the view writer's direct track (`view/writer.ts`), reached
21
+ * through the `DIRECT` key so that no view class (and with it the binder)
22
+ * is loaded here.
23
+ * - `commands.register`: one `commands.register` with the plugin's own
24
+ * declaration, waited for during activation as a declaration
25
+ * (`Connection.declaring`, so `strictDeclarations` applies), then
26
+ * `commands.update` with the next revision on each `update`.
27
+ */
28
+ import { failure, quiet } from "./errors.js";
29
+ import { Latest } from "./latest.js";
30
+ import { EVENT_NEEDS } from "./player/events.js";
31
+ import { DIRECT } from "./view/writer.js";
32
+ /**
33
+ * `events.subscribe` parameters that say why the plugin listens: a list of
34
+ * reasons (`why`, a listener) or `mirror: true` (only a copy of the state).
35
+ */
36
+ function marked(params) {
37
+ if (params === null || typeof params !== "object" || Array.isArray(params))
38
+ return false;
39
+ if (params.mirror === true)
40
+ return true;
41
+ const why = params.why;
42
+ return (Array.isArray(why) &&
43
+ why.length > 0 &&
44
+ why.every((line) => typeof line === "string"));
45
+ }
46
+ class RawCommand {
47
+ id;
48
+ ready;
49
+ #scope;
50
+ #state;
51
+ /** The conditions last sent: kept by an `update` without `when`. */
52
+ #when;
53
+ #revision = 1;
54
+ #registered = false;
55
+ #disposed = false;
56
+ #run;
57
+ #updates;
58
+ constructor(scope, options) {
59
+ const runtime = scope.runtime;
60
+ const { id, declaration, state, when, run } = (options ??
61
+ {});
62
+ if (typeof id !== "string" || id === "")
63
+ throw failure("invalid", "register takes an id: a non-empty string");
64
+ if (declaration === null ||
65
+ typeof declaration !== "object" ||
66
+ Array.isArray(declaration))
67
+ throw failure("invalid", `command ${id}: declaration is an object, as commands.register takes it`);
68
+ if (run !== undefined && typeof run !== "function")
69
+ throw failure("invalid", `command ${id}: run is a function`);
70
+ if (runtime.commands.has(id))
71
+ throw failure("conflict", `command ${id} is already declared`);
72
+ this.id = id;
73
+ this.#scope = scope;
74
+ const initial = {
75
+ enabled: true,
76
+ checked: null,
77
+ busy: false,
78
+ reason: null,
79
+ ...state,
80
+ };
81
+ this.#state = initial;
82
+ this.#when = when;
83
+ // Shared with `commands.add`: re-registering an id waits for any
84
+ // removal of it in flight, whichever made it.
85
+ const previous = runtime.removals.get(id);
86
+ const registration = (async () => {
87
+ await previous;
88
+ await runtime.host.commands.register(id, 1, declaration, initial, when === undefined ? undefined : when);
89
+ this.#registered = true;
90
+ })();
91
+ this.ready = quiet(runtime
92
+ .declaring(registration, `command ${id}`, (error) => scope.report(error))
93
+ .then(() => { }));
94
+ this.#updates = new Latest(async ({ state: next, when: conditions }) => {
95
+ await this.ready.catch(() => {
96
+ throw failure("missing", `command ${id} is not registered`);
97
+ });
98
+ await runtime.host.commands.update(id, ++this.#revision, next, conditions === undefined ? undefined : conditions);
99
+ });
100
+ this.#run = () => {
101
+ if (!this.#disposed && run)
102
+ scope.run(run);
103
+ };
104
+ runtime.commands.set(id, this.#run);
105
+ scope.add(this);
106
+ }
107
+ async update(state, when) {
108
+ if (state === null || typeof state !== "object")
109
+ throw failure("invalid", `command ${this.id}: update takes a state`);
110
+ if (this.#disposed)
111
+ throw failure("missing", `command ${this.id} was disposed`);
112
+ this.#state = { ...this.#state, ...state };
113
+ if (when !== undefined)
114
+ this.#when = when;
115
+ await this.#updates.push(this.#when === undefined
116
+ ? { state: this.#state }
117
+ : { state: this.#state, when: this.#when });
118
+ }
119
+ async dispose() {
120
+ if (this.#disposed)
121
+ return;
122
+ this.#disposed = true;
123
+ this.#scope.forget(this);
124
+ const runtime = this.#scope.runtime;
125
+ if (runtime.commands.get(this.id) === this.#run)
126
+ runtime.commands.delete(this.id);
127
+ this.#updates.stop();
128
+ const pending = runtime.removals;
129
+ const removal = (async () => {
130
+ await this.ready.catch(() => { });
131
+ if (this.#registered)
132
+ await runtime.host.commands.unregister(this.id).catch(() => { });
133
+ })();
134
+ pending.set(this.id, removal);
135
+ await removal;
136
+ if (pending.get(this.id) === removal)
137
+ pending.delete(this.id);
138
+ }
139
+ }
140
+ /** `plugin.wire` for one scope. */
141
+ export const wire = (scope) => ({
142
+ request(method, params) {
143
+ if (typeof method !== "string" || method === "")
144
+ throw failure("invalid", "request takes a method name");
145
+ if (method === "events.subscribe" || method === "events.unsubscribe") {
146
+ const event = params !== null && typeof params === "object" && !Array.isArray(params)
147
+ ? params.event
148
+ : undefined;
149
+ // The player keeps one subscription per event name, with one mark:
150
+ // the SDK's own (state copies, `player.on`, `wire.on`) for these.
151
+ if (typeof event === "string" && Object.hasOwn(EVENT_NEEDS, event))
152
+ throw failure("invalid", method === "events.subscribe"
153
+ ? `${event} is one of the SDK's events: listen with plugin.wire.on, which subscribes and marks it`
154
+ : `${event} is one of the SDK's events: use the Disposable from plugin.wire.on`);
155
+ if (method === "events.subscribe" && !marked(params))
156
+ throw failure("invalid", "events.subscribe needs why (a list of reasons) or mirror: true, or the player misjudges whether the plugin listens");
157
+ }
158
+ return scope.runtime.request(method, params);
159
+ },
160
+ on(event, listener) {
161
+ if (typeof event !== "string" || event === "")
162
+ throw failure("invalid", "on takes an event name and a listener");
163
+ if (typeof listener !== "function")
164
+ throw failure("invalid", "on takes an event name and a listener");
165
+ // A copy: the same data also feeds the SDK's own state copies. No full
166
+ // pass after it (`runQuiet`), as for `player.on`.
167
+ const deliver = (data) => scope.runQuiet(listener, structuredClone(data));
168
+ const watch = Object.hasOwn(EVENT_NEEDS, event)
169
+ ? scope.runtime.on(event, deliver, EVENT_NEEDS[event])
170
+ : scope.runtime.raw(event, deliver);
171
+ const handle = {
172
+ dispose: async () => {
173
+ scope.forget(handle);
174
+ await watch.dispose();
175
+ },
176
+ };
177
+ return scope.add(handle);
178
+ },
179
+ view(view) {
180
+ const direct = view !== null && typeof view === "object"
181
+ ? view[DIRECT]
182
+ : undefined;
183
+ if (typeof direct !== "function")
184
+ throw failure("invalid", "view takes a window, panel or settings page of this plugin");
185
+ return direct.call(view, scope);
186
+ },
187
+ commands: {
188
+ register: (options) => new RawCommand(scope, options),
189
+ },
190
+ });
@@ -3,6 +3,9 @@
3
3
  * capability checker of `vestra-plugin check` in the editor. A use of an API
4
4
  * member whose capability `manifest.json` does not declare is an error at
5
5
  * the member, with the quick fix "Add '<capability>' to manifest.json".
6
+ * A call whose capability depends on a name the checker cannot read
7
+ * (`plugin.wire.request(method)` with a computed method, SDK 1.7.0) is a
8
+ * warning (`CAPABILITY_UNCHECKED`).
6
9
  *
7
10
  * A project enables it in its tsconfig.json:
8
11
  *
package/dist/ts-plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- import { addCapabilityEdit, CAPABILITY_DIAGNOSTIC, findUndeclaredCapabilities, isPluginSource, } from "./capability-check.js";
1
+ import { addCapabilityEdit, CAPABILITY_DIAGNOSTIC, CAPABILITY_UNCHECKED, checkCapabilities, isPluginSource, } from "./capability-check.js";
2
2
  const FIX_NAME = "vestraAddCapability";
3
3
  /** The nearest manifest.json at or above a file, with its capabilities. */
4
4
  function manifestFor(ts, file) {
@@ -50,22 +50,24 @@ export default function init(modules) {
50
50
  create(info) {
51
51
  const service = info.languageService;
52
52
  const log = (message) => info.project?.projectService?.logger?.info(`[@vestra-player/sdk/ts-plugin] ${message}`);
53
- const findings = (file) => {
53
+ const none = { findings: [], unchecked: [] };
54
+ const results = (file) => {
54
55
  const manifest = manifestFor(ts, file);
55
56
  const program = service.getProgram();
56
57
  if (!manifest || !program || !isPluginSource(manifest.directory, file))
57
- return [];
58
+ return none;
58
59
  try {
59
- return findUndeclaredCapabilities(ts, program, {
60
+ return checkCapabilities(ts, program, {
60
61
  files: [file],
61
62
  capabilities: manifest.capabilities,
62
63
  });
63
64
  }
64
65
  catch (error) {
65
66
  log(`check failed: ${error.stack ?? String(error)}`);
66
- return [];
67
+ return none;
67
68
  }
68
69
  };
70
+ const findings = (file) => results(file).findings;
69
71
  const proxy = Object.create(null);
70
72
  for (const key of Object.keys(service)) {
71
73
  const member = service[key];
@@ -75,9 +77,10 @@ export default function init(modules) {
75
77
  proxy.getSemanticDiagnostics = (file) => {
76
78
  const prior = service.getSemanticDiagnostics(file);
77
79
  const source = service.getProgram()?.getSourceFile(file);
80
+ const { findings: missing, unchecked } = results(file);
78
81
  return [
79
82
  ...prior,
80
- ...findings(file).map((finding) => ({
83
+ ...missing.map((finding) => ({
81
84
  file: source,
82
85
  start: finding.start,
83
86
  length: finding.length,
@@ -86,6 +89,15 @@ export default function init(modules) {
86
89
  code: CAPABILITY_DIAGNOSTIC,
87
90
  source: "vestra",
88
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
+ })),
89
101
  ];
90
102
  };
91
103
  proxy.getSupportedCodeFixes = (file) => [
package/dist/wire.d.ts CHANGED
@@ -57,42 +57,102 @@ export interface UiCallback {
57
57
  args: Json[];
58
58
  }
59
59
  /**
60
- * One row operation of a patch, by index, applied to the result of the
61
- * ones before (player 0.6.0, feature `ui.patch`). `move` takes `count` rows
62
- * out at `from` and puts them back at `to`, an index of the list without
63
- * them.
60
+ * One row operation of a list property's patch, by index, applied to the
61
+ * result of the ones before (player 0.6.0, feature `ui.patch`).
62
+ *
63
+ * @remarks
64
+ * Part of the wire protocol, which is not semver: this type changes with
65
+ * versions. `set` replaces the row at `at`; `insert` puts `rows` before
66
+ * index `at` (the list's length: at the end); `remove` takes `count` rows
67
+ * out at `at`; `move` takes `count` rows out at `from` and puts them back
68
+ * at `to`, an index of the list without them. The SDK sends them for
69
+ * bound lists by itself; a plugin writes them with
70
+ * {@link WireView.writeRows}.
71
+ *
72
+ * @example Move the first row to the end
73
+ * A three-row list becomes rows 2, 3, 1: the first row is taken out and
74
+ * put back at index 2 of the two rows left.
75
+ * ```ts
76
+ * const op: RowOp = { op: "move", from: 0, count: 1, to: 2 };
77
+ * ```
78
+ *
79
+ * @experimental
80
+ * @since 1.7.0
81
+ * @category Plugin
64
82
  */
65
83
  export type RowOp = {
84
+ /** Replace one row. */
66
85
  op: "set";
86
+ /** The row's index. */
67
87
  at: number;
88
+ /** The new row. */
68
89
  row: Json;
69
90
  } | {
91
+ /** Insert rows. */
70
92
  op: "insert";
93
+ /** The index the first new row gets (the list's length: at the end). */
71
94
  at: number;
95
+ /** The new rows, in order. */
72
96
  rows: Json[];
73
97
  } | {
98
+ /** Remove a run of rows. */
74
99
  op: "remove";
100
+ /** The index of the first row removed. */
75
101
  at: number;
102
+ /** How many rows. */
76
103
  count: number;
77
104
  } | {
105
+ /** Move a run of rows. */
78
106
  op: "move";
107
+ /** The index of the first row moved. */
79
108
  from: number;
109
+ /** How many rows. */
80
110
  count: number;
111
+ /** Where they go, an index of the list without them. */
81
112
  to: number;
82
113
  };
83
114
  /**
84
- * A property write: a whole value (with its `seq` to players that take
85
- * patches), or a row patch of an array applying on the write numbered
86
- * `base` (0: the initial properties).
115
+ * One write of a view property as the player takes it: a whole value, or
116
+ * a row patch of a list.
117
+ *
118
+ * @remarks
119
+ * Part of the wire protocol, which is not semver: this type changes with
120
+ * versions. `{ value }` replaces the property; to a player that takes row
121
+ * patches (player 0.6.0) it carries a `seq` that later patches apply on.
122
+ * `{ patch: { base, seq, ops } }` applies `ops` on the write numbered
123
+ * `base` (0: the view's initial properties) and is numbered `seq` itself;
124
+ * the player refuses it with `stale` when the property changed since
125
+ * `base`. `more` marks a part of a whole value sent in several, not the
126
+ * last: the player shows the value at the last part. The SDK writes these
127
+ * for `set()` and `bind()`; a plugin writes them with
128
+ * {@link WireView.write}.
129
+ *
130
+ * @example Write a whole list, numbered
131
+ * The property `items` becomes a list of two rows; a later patch with
132
+ * `base: 7` applies on it.
133
+ * ```ts
134
+ * const write: PropertyWrite = { value: [{ id: "a" }, { id: "b" }], seq: 7 };
135
+ * ```
136
+ *
137
+ * @experimental
138
+ * @since 1.7.0
139
+ * @category Plugin
87
140
  */
88
141
  export type PropertyWrite = {
142
+ /** The property's new value. */
89
143
  value: Json;
144
+ /** This write's number, which later patches name as their `base`. */
90
145
  seq?: number;
146
+ /** A part of a whole value sent in parts, not the last (player 0.6.0). */
91
147
  more?: boolean;
92
148
  } | {
149
+ /** Row operations on a list property. */
93
150
  patch: {
151
+ /** The `seq` of the write they apply on (0: the initial properties). */
94
152
  base: number;
153
+ /** This patch's own number (1 or more). */
95
154
  seq: number;
155
+ /** The operations, applied in order. */
96
156
  ops: RowOp[];
97
157
  };
98
158
  /** A part of a whole value sent in parts, not the last (player 0.6.0). */
@@ -157,47 +217,90 @@ export declare class HostError extends Error {
157
217
  */
158
218
  constructor(code: string, message: string);
159
219
  }
160
- /** One plugin as `packages.list` reports it. */
220
+ /**
221
+ * One plugin as `packages.list` and the event `packages.changed` report
222
+ * it: what `PluginInfo` (`plugin.packages`) is made from.
223
+ *
224
+ * @remarks
225
+ * The player's wire shape (`packages.list`, `packages.changed`), part of the protocol, which is not
226
+ * semver: it can gain fields with a player version.
227
+ *
228
+ * @since 1.7.0
229
+ * @category Playback
230
+ */
161
231
  export interface PackageInfo {
232
+ /** The manifest id. */
162
233
  id: string;
234
+ /** The installed version; `null` for a development directory without one. */
163
235
  version: string | null;
236
+ /** Installed from a package, or loaded from a development directory. */
164
237
  origin: "installed" | "development";
238
+ /** Its lifecycle state. */
165
239
  state: "starting" | "running" | "disabled" | "failed" | "stopped";
240
+ /** Why it failed, when `state` is `failed`; else `null`. */
166
241
  error: string | null;
242
+ /** The capabilities its manifest declares. */
167
243
  capabilities: string[];
244
+ /** Its directory on disk. */
168
245
  directory: string;
169
- /** Player 0.2.0; absent from older players. */
246
+ /** One of the player's built-in plugins (player 0.2.0; absent from older players). */
170
247
  builtin?: boolean;
248
+ /** Where an installed package came from; `null` for a development directory. */
171
249
  source?: WireSource | null;
250
+ /** Its data directory, `null` when it has none. */
172
251
  dataDirectory?: string | null;
173
252
  /** What the plugin was refused because another plugin holds it (player 0.4.x, after 0.4.0). */
174
253
  warnings?: {
254
+ /** Why: `slot-occupied`, `sequence-taken` or `resolver-taken`; a newer player may add codes. */
175
255
  code: string;
256
+ /** The panel position concerned, if any. */
176
257
  slot?: string;
258
+ /** The manifest id of the plugin holding it, if any. */
177
259
  owner?: string;
178
260
  }[];
179
261
  /** The manifest's display texts in the interface language (player 0.4.3). */
180
262
  display?: {
263
+ /** The display name, or `null`. */
181
264
  name: string | null;
265
+ /** The one-line pitch, or `null`. */
182
266
  punchline: string | null;
267
+ /** The description, or `null`. */
183
268
  description: string | null;
269
+ /** The store tags. */
184
270
  tags: string[];
185
271
  };
186
272
  /** Whether it has a process now (player 0.5.18, `state: "running"`). */
187
273
  process?: "running" | "idle";
188
274
  }
189
- /** Where an installed package came from (`packages.install` `source`). */
275
+ /**
276
+ * Where an installed package came from (`packages.install` `source`),
277
+ * as {@link PackageInfo.source} reports it.
278
+ *
279
+ * @remarks
280
+ * The player's wire shape (`source` of `packages.list`), part of the protocol, which is not
281
+ * semver: it can gain fields with a player version.
282
+ *
283
+ * @since 1.7.0
284
+ * @category Playback
285
+ */
190
286
  export type WireSource = {
287
+ /** A plugin repository. */
191
288
  kind: "repository";
289
+ /** The repository's URL. */
192
290
  url: string;
193
291
  } | {
292
+ /** A download link. */
194
293
  kind: "link";
294
+ /** The link. */
195
295
  url: string;
196
296
  } | {
297
+ /** A package file. */
197
298
  kind: "file";
198
299
  } | {
300
+ /** The plugin workshop. */
199
301
  kind: "workshop";
200
302
  } | {
303
+ /** Shipped with the player. */
201
304
  kind: "bundled";
202
305
  };
203
306
  /** `bindings.list`. */
@@ -232,18 +335,36 @@ export interface BindingTable {
232
335
  inputs: string[];
233
336
  }[];
234
337
  }
235
- /** `window.state`: the main window, in logical points (zero without one). */
338
+ /**
339
+ * The main window as `window.state` reports it, in logical points (zero
340
+ * without one): what `WindowState` (`plugin.window`) is made from, plus
341
+ * the palette, the resolvers' file types and the language that come with
342
+ * the same answer.
343
+ *
344
+ * @remarks
345
+ * The player's wire shape (`window.state`), part of the protocol, which is not
346
+ * semver: it can gain fields with a player version.
347
+ *
348
+ * @since 1.7.0
349
+ * @category Playback
350
+ */
236
351
  export interface WindowFacts {
352
+ /** The main window is fullscreen. */
237
353
  fullscreen: boolean;
238
354
  /** The main window is maximized, `false` in fullscreen (player 0.6.3; absent from older players: `false`). */
239
355
  maximized?: boolean;
356
+ /** The video area's size. */
240
357
  videoArea: {
358
+ /** Width in logical points. */
241
359
  width: number;
360
+ /** Height in logical points. */
242
361
  height: number;
243
362
  };
244
363
  /** System picture-in-picture (absent from older players: unsupported). */
245
364
  pictureInPicture?: {
365
+ /** The system offers it. */
246
366
  supported: boolean;
367
+ /** It is on. */
247
368
  active: boolean;
248
369
  };
249
370
  /** The palette (`plugin.appearance`), with the `window.state` reply; a newer player may name a palette this SDK does not list. */
@@ -255,24 +376,65 @@ export interface WindowFacts {
255
376
  /** The interface language of this run (player 0.4.3). */
256
377
  locale?: string;
257
378
  }
258
- /** One timeline mark as the player merges them (`timeline.marks`). */
379
+ /**
380
+ * One timeline mark as the player merges them (`timeline.marks`): what
381
+ * `TimelineMark` is made from.
382
+ *
383
+ * @remarks
384
+ * The player's wire shape (`timeline.marks`, `timeline.changed`), part of the protocol, which is not
385
+ * semver: it can gain fields with a player version.
386
+ *
387
+ * @since 1.7.0
388
+ * @category Playback
389
+ */
259
390
  export interface WireMark {
391
+ /** Its position in seconds. */
260
392
  time: number;
393
+ /** What it marks. */
261
394
  kind: "chapter" | "bookmark" | "marker";
395
+ /** Its title, or `null`. */
262
396
  title: string | null;
397
+ /** The manifest id of the plugin that published it. */
263
398
  plugin: string;
264
399
  }
265
- /** One timeline range as the player merges them (player 0.7.6). */
400
+ /**
401
+ * One timeline range as the player merges them (player 0.7.6): what
402
+ * `TimelineRange` is made from.
403
+ *
404
+ * @remarks
405
+ * The player's wire shape (`timeline.marks`, `timeline.changed`), part of the protocol, which is not
406
+ * semver: it can gain fields with a player version.
407
+ *
408
+ * @since 1.7.0
409
+ * @category Playback
410
+ */
266
411
  export interface WireRange {
412
+ /** Its start in seconds. */
267
413
  start: number;
414
+ /** Its end in seconds. */
268
415
  end: number;
416
+ /** How it is drawn. */
269
417
  style: "selection" | "region";
418
+ /** Its title, or `null`. */
270
419
  title: string | null;
420
+ /** The manifest id of the plugin that published it. */
271
421
  plugin: string;
272
422
  }
273
- /** `timeline.marks` and `timeline.changed`; `ranges` from player 0.7.6. */
423
+ /**
424
+ * Every timeline mark and range, merged from every layer: the answer to
425
+ * `timeline.marks` and the data of the event `timeline.changed`.
426
+ *
427
+ * @remarks
428
+ * The player's wire shape (`timeline.marks`, `timeline.changed`), part of the protocol, which is not
429
+ * semver: it can gain fields with a player version.
430
+ *
431
+ * @since 1.7.0
432
+ * @category Playback
433
+ */
274
434
  export interface WireTimeline {
435
+ /** The marks, in time order. */
275
436
  marks: WireMark[];
437
+ /** The ranges (from player 0.7.6; absent from older players). */
276
438
  ranges?: WireRange[];
277
439
  }
278
440
  /** A panel position (`ui.mount`'s `slot`). */
@@ -384,9 +546,20 @@ export interface WireSystemInfo {
384
546
  /** Why `rendering` is what it is (player 0.5.13; older players leave it out). */
385
547
  renderingReason?: WireRenderingReason;
386
548
  }
387
- /** A rendering reason: a stable kebab-case `code` and English text. */
549
+ /**
550
+ * A rendering reason: a stable kebab-case `code` and English text.
551
+ *
552
+ * @remarks
553
+ * The player's wire shape (`rendering.state`, `app.system`), part of the protocol, which is not
554
+ * semver: it can gain fields with a player version.
555
+ *
556
+ * @since 1.7.0
557
+ * @category Playback
558
+ */
388
559
  export interface WireRenderingReason {
560
+ /** The stable code, to branch on. */
389
561
  code: string;
562
+ /** English text, to show. */
390
563
  message: string;
391
564
  }
392
565
  /** `rendering.state` and `rendering.setPreference` (player 0.5.13). */
@@ -405,37 +578,73 @@ export interface WireRenderingState {
405
578
  /**
406
579
  * An upscaling reason: `{ code, message }` as a rendering reason; with
407
580
  * `decoding` a `cause`, with cause `copy-back` the `plugins` (player 0.5.25).
581
+ * What `UpscalingReason` is made from.
582
+ *
583
+ * @remarks
584
+ * The player's wire shape (`video.upscaling.state`, `video.upscaling.changed`), part of the protocol, which is not
585
+ * semver: it can gain fields with a player version.
586
+ *
587
+ * @since 1.7.0
588
+ * @category Playback
408
589
  */
409
590
  export interface WireUpscalingReason extends WireRenderingReason {
591
+ /** Why decoding stands in the way, with code `decoding`. */
410
592
  cause?: string;
593
+ /** The plugins whose filters copy frames back, with cause `copy-back`. */
411
594
  plugins?: {
595
+ /** The plugin's id. */
412
596
  id: string;
597
+ /** Its display name. */
413
598
  name: string;
414
599
  }[];
415
600
  }
416
601
  /**
417
- * `video.upscaling.state` and `video.upscaling.set` (player 0.5.16); the
418
- * monitoring fields from player 0.5.25, which also sends the state without
419
- * `enabled` as the event `video.upscaling.changed`.
602
+ * The GPU video upscaler's state as `video.upscaling.state` and
603
+ * `video.upscaling.set` answer it (player 0.5.16; the monitoring fields
604
+ * from player 0.5.25, which also sends it without `enabled` as the event
605
+ * `video.upscaling.changed`): what `UpscalingState` is made from.
606
+ *
607
+ * @remarks
608
+ * The player's wire shape (`video.upscaling.state`, `video.upscaling.changed`), part of the protocol, which is not
609
+ * semver: it can gain fields with a player version.
610
+ *
611
+ * @since 1.7.0
612
+ * @category Playback
420
613
  */
421
614
  export interface WireUpscalingState {
615
+ /** The upscaler works now. */
422
616
  available: boolean;
617
+ /** Why not, when `available` is `false`; else `null`. */
423
618
  reason: WireUpscalingReason | null;
619
+ /** This plugin asked for upscaling and has not turned it off. */
424
620
  enabled: boolean;
621
+ /** The player has the upscaler in the video filter chain now, for this plugin or another one. */
425
622
  requested: boolean;
623
+ /** The scale factor the upscaler was asked for, in hundredths; `null` while nothing is requested. */
426
624
  factor: number | null;
625
+ /** The video's size as the upscaler gets it; `null` while no video decodes. */
427
626
  video?: {
627
+ /** The frames' stored width in pixels. */
428
628
  width: number;
629
+ /** The frames' stored height in pixels. */
429
630
  height: number;
631
+ /** The width the video is meant to be shown at (non-square pixels). */
430
632
  displayWidth: number;
633
+ /** The height the video is meant to be shown at. */
431
634
  displayHeight: number;
432
635
  } | null;
636
+ /** The area the video is shown in, in pixels; `null` while the player shows no video area. */
433
637
  area?: {
638
+ /** Width in physical pixels. */
434
639
  width: number;
640
+ /** Height in physical pixels. */
435
641
  height: number;
436
642
  } | null;
643
+ /** The name of the GPU that renders; `null` in software rendering or where the player does not know it. */
437
644
  gpu?: string | null;
645
+ /** The hardware decoder in use, as mpv names it (`no`: software); `null` while no video decodes. */
438
646
  hwdecCurrent?: string | null;
647
+ /** The upscaler is in the player's video filter chain now, read from the chain itself. */
439
648
  inChain?: boolean;
440
649
  }
441
650
  /**
@@ -458,8 +667,12 @@ export interface Transport {
458
667
  */
459
668
  locale?: string;
460
669
  }
461
- /** The events a plugin subscribes to (`events.subscribe`). */
462
- type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed";
670
+ /**
671
+ * The events a plugin subscribes to (`events.subscribe`). The plugin API
672
+ * names the same list `HostEvent` (`plugin.player.on`, SDK 1.7.0); a test
673
+ * keeps the two equal.
674
+ */
675
+ export type HostEvent = "source.state" | "playback.backend" | "window.state" | "packages.changed" | "bindings.changed" | "commands.keys" | "timeline.changed" | "appearance.changed" | "resolvers.fileTypes" | "video.upscaling.changed";
463
676
  export declare function createWire(transport: Transport): {
464
677
  processing: {
465
678
  state: () => Promise<import("./processing.ts").ProcessingState>;