@vestra-player/sdk 1.6.17 → 1.6.19

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 (88) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/docs-tree.json.gz +0 -0
  3. package/dist/plugin/appearance.js +1 -1
  4. package/dist/plugin/bindings.js +1 -1
  5. package/dist/plugin/commands.js +3 -2
  6. package/dist/plugin/connection.d.ts +119 -0
  7. package/dist/plugin/connection.js +402 -0
  8. package/dist/plugin/drops.d.ts +3 -3
  9. package/dist/plugin/drops.js +1 -1
  10. package/dist/plugin/errors.d.ts +9 -0
  11. package/dist/plugin/errors.js +35 -0
  12. package/dist/plugin/filters.js +1 -1
  13. package/dist/plugin/index.d.ts +1 -1
  14. package/dist/plugin/index.js +3 -1
  15. package/dist/plugin/language.js +1 -1
  16. package/dist/plugin/latest.d.ts +12 -0
  17. package/dist/plugin/latest.js +52 -0
  18. package/dist/plugin/local.js +1 -2
  19. package/dist/plugin/markdown.d.ts +2 -2
  20. package/dist/plugin/markdown.js +1 -1
  21. package/dist/plugin/media.js +1 -1
  22. package/dist/plugin/osd.js +2 -2
  23. package/dist/plugin/packages.js +1 -1
  24. package/dist/plugin/passes.d.ts +111 -0
  25. package/dist/plugin/passes.js +341 -0
  26. package/dist/plugin/player.d.ts +2 -3
  27. package/dist/plugin/player.js +2 -7
  28. package/dist/plugin/resolvers.js +1 -1
  29. package/dist/plugin/runtime.d.ts +26 -185
  30. package/dist/plugin/runtime.js +35 -755
  31. package/dist/plugin/scope.d.ts +2 -1
  32. package/dist/plugin/scope.js +5 -2
  33. package/dist/plugin/services/dialogs.d.ts +3 -0
  34. package/dist/plugin/services/dialogs.js +62 -0
  35. package/dist/plugin/services.js +1 -1
  36. package/dist/plugin/settings.js +2 -2
  37. package/dist/plugin/shaders.js +2 -1
  38. package/dist/plugin/stream.js +1 -2
  39. package/dist/plugin/subtitles.js +2 -2
  40. package/dist/plugin/testing/commands.d.ts +65 -0
  41. package/dist/plugin/testing/commands.js +412 -0
  42. package/dist/plugin/testing/core-actions.d.ts +39 -0
  43. package/dist/plugin/testing/core-actions.js +371 -0
  44. package/dist/plugin/testing/declarations.d.ts +37 -0
  45. package/dist/plugin/testing/declarations.js +80 -0
  46. package/dist/plugin/testing/i18n.d.ts +28 -0
  47. package/dist/plugin/testing/i18n.js +107 -0
  48. package/dist/plugin/testing/index.d.ts +3140 -0
  49. package/dist/plugin/testing/index.js +2796 -0
  50. package/dist/plugin/testing/internals.d.ts +76 -0
  51. package/dist/plugin/testing/internals.js +60 -0
  52. package/dist/plugin/testing/jobs.d.ts +9 -0
  53. package/dist/plugin/testing/jobs.js +304 -0
  54. package/dist/plugin/testing/layout.d.ts +85 -0
  55. package/dist/plugin/testing/layout.js +622 -0
  56. package/dist/plugin/testing/media.d.ts +55 -0
  57. package/dist/plugin/testing/media.js +615 -0
  58. package/dist/plugin/testing/osd.d.ts +4 -0
  59. package/dist/plugin/testing/osd.js +57 -0
  60. package/dist/plugin/testing/processing.d.ts +56 -0
  61. package/dist/plugin/testing/processing.js +491 -0
  62. package/dist/plugin/testing/services.d.ts +50 -0
  63. package/dist/plugin/testing/services.js +466 -0
  64. package/dist/plugin/testing/transport.d.ts +29 -0
  65. package/dist/plugin/testing/transport.js +140 -0
  66. package/dist/plugin/testing.d.ts +1 -3140
  67. package/dist/plugin/testing.js +1 -6203
  68. package/dist/plugin/timeline.js +2 -1
  69. package/dist/plugin/view/base.d.ts +29 -0
  70. package/dist/plugin/view/base.js +88 -0
  71. package/dist/plugin/view/binder.d.ts +22 -0
  72. package/dist/plugin/view/binder.js +57 -0
  73. package/dist/plugin/view/image.d.ts +21 -0
  74. package/dist/plugin/view/image.js +60 -0
  75. package/dist/plugin/view/layout.d.ts +47 -0
  76. package/dist/plugin/view/layout.js +171 -0
  77. package/dist/plugin/view/panel.d.ts +3 -0
  78. package/dist/plugin/view/panel.js +178 -0
  79. package/dist/plugin/view/window.d.ts +3 -0
  80. package/dist/plugin/view/window.js +99 -0
  81. package/dist/plugin/view/writer.d.ts +58 -0
  82. package/dist/plugin/view/writer.js +634 -0
  83. package/dist/plugin/view.js +2 -1
  84. package/dist/plugin/window.js +1 -1
  85. package/llms.txt +1 -1
  86. package/package.json +6 -4
  87. package/dist/plugin/ui.d.ts +0 -74
  88. package/dist/plugin/ui.js +0 -1234
@@ -3,7 +3,8 @@
3
3
  * here; plugins see immutable states, conditional calls and media handles.
4
4
  */
5
5
  import { HostError } from "../wire.js";
6
- import { Latest, failure, quiet, sleep, uncertain } from "./runtime.js";
6
+ import { Latest } from "./latest.js";
7
+ import { abortError, failure, quiet, sleep, uncertain } from "./errors.js";
7
8
  import { openStream } from "./stream.js";
8
9
  const raws = new WeakMap();
9
10
  const empty = {
@@ -155,12 +156,6 @@ function sourceFailure(error) {
155
156
  ? failure(error)
156
157
  : failure("backend", error.backend);
157
158
  }
158
- export function abortError() {
159
- const error = new Error("aborted");
160
- error.name = "AbortError";
161
- error.code = "aborted";
162
- return error;
163
- }
164
159
  /** One per plugin: the state store and the operation book client. */
165
160
  export class PlayerService {
166
161
  runtime;
@@ -2,7 +2,7 @@
2
2
  * Source resolvers: page URLs to stream URLs, or local files to a stream
3
3
  * this plugin generates, for `player.open`.
4
4
  */
5
- import { failure, quiet } from "./runtime.js";
5
+ import { failure, quiet } from "./errors.js";
6
6
  import { playerOf } from "./player.js";
7
7
  import { resolvedStream } from "./stream.js";
8
8
  import { windowOf } from "./window.js";
@@ -1,204 +1,45 @@
1
- import type { Json, LocalServices, Transport, Wire } from "../wire.ts";
2
- import type { App, Disposable, Locale, PluginError, StopReason, SystemInfo } from "./types.ts";
3
1
  /**
4
- * Why something listens, for the player's log line that says why a plugin
5
- * keeps running (`events.subscribe { why }`, player 0.5.21): computed
6
- * only when the player is told.
2
+ * Shared machinery behind every scope: the connection to the player
3
+ * (`connection.ts`, L1) with the update passes (`passes.ts`, L2) on top.
4
+ * `Runtime` is the connection plus the pass methods, delegated, so every
5
+ * caller keeps `runtime.host`, `runtime.on`, `runtime.bind` and the rest.
7
6
  */
8
- export type Why = () => string;
9
- /**
10
- * Events the player wakes a stopped plugin for (player 0.5.21): a listener
11
- * of one does not keep the plugin running. They follow deliberate changes
12
- * (an install, a key edit, the palette, a resolver), not playback.
13
- */
14
- export declare const WAKE_EVENTS: readonly string[];
15
- export interface PluginManifest {
16
- id: string;
17
- capabilities: string[];
18
- }
19
- export declare const sleep: (ms: number) => Promise<void>;
20
- export declare function toError(error: unknown): PluginError;
21
- export declare const failure: (code: string, message?: string) => PluginError;
22
- /** Host replies are definite; anything else (lost reply, client timeout) is not. */
23
- export declare const uncertain: (error: unknown) => boolean;
24
- /** Mark a promise as observed so an unused `ready` never crashes the runner. */
25
- export declare function quiet<T>(promise: Promise<T>): Promise<T>;
26
- /**
27
- * The fields of the SDK's state copies that a binding or listener read, by
28
- * state (`player`: `plugin.player.state`). An empty set: the state was
29
- * taken whole (no field read was seen), so any change of it counts.
30
- */
31
- export type Deps = Map<string, Set<string>>;
32
- /** A change of the SDK's state copies: the fields that changed, by state. */
33
- export type Change = ReadonlyMap<string, ReadonlySet<string>>;
34
- /**
35
- * The longest a binding waits for a full pass while precise passes skip
36
- * it: state a plugin changes outside code the SDK runs (its own timer,
37
- * without `update()`) still shows within about this long.
38
- */
39
- export declare const SAFETY_PASS_MS = 1000;
40
- /** How the plugin is run: the player's runner, or `TestHost`. */
41
- export interface RuntimeOptions {
42
- /**
43
- * A declaration the player refuses during activation fails activation
44
- * (`startPlugin`, so a plugin's tests show it) instead of being logged,
45
- * reported to `onError` and skipped (the player's runner).
46
- */
47
- strictDeclarations?: boolean;
48
- }
49
- /** A stop reason the runner passed on, if this SDK knows it. */
50
- export declare function stopReason(value: unknown): StopReason | undefined;
51
- export declare const same: (a: Json | undefined, b: Json | undefined) => boolean;
52
- /** One value in flight, only the newest waiting. Each push learns its fate. */
53
- export declare class Latest<T> {
54
- #private;
55
- constructor(send: (value: T) => Promise<void>);
56
- push(value: T): Promise<boolean>;
57
- stop(): void;
58
- }
59
- type Listener = (data: unknown) => void;
60
- /**
61
- * Per-plugin services. Scopes are thin views over this object; the flat RPC
62
- * clients stay private here so protocol fields never reach plugin code.
63
- */
64
- export declare class Runtime {
65
- #private;
66
- readonly host: Wire;
67
- readonly manifest: PluginManifest;
68
- readonly directory: string;
69
- /** Writable per-plugin data directory from the host, if it provided one. */
70
- readonly dataDirectory: string | undefined;
71
- /** Test doubles for local processes; the real system when absent. */
72
- readonly local: LocalServices | undefined;
73
- /** Registrations that activation must wait for before reporting ready. */
74
- readonly startup: Set<Promise<unknown>>;
75
- readonly views: Map<string, (callback: string, args: Json[]) => void>;
76
- readonly commands: Map<string, () => void>;
77
- readonly services: Map<string, unknown>;
78
- /**
79
- * Set when the player stops the plugin (`PluginInstance.dispose`), before
80
- * the root scope is disposed: `DisposeInfo` and `plugin.stopReason`.
81
- */
82
- stopping: {
83
- reason: StopReason | undefined;
84
- } | undefined;
85
- /** `plugin.app`, from the start-up handshake; `system()` asks the player. */
86
- readonly app: App;
87
- /** `plugin.i18n.locale`, from the start-up handshake; English when unknown. */
88
- readonly locale: Locale;
89
- /**
90
- * Protocol additions the player advertises at start-up (`features` in the
91
- * handshake's app data, player 0.6.0): `ui.patch` (row patches of
92
- * property writes). Not part of the plugin API; empty for older players.
93
- */
94
- readonly features: ReadonlySet<string>;
7
+ import { Connection } from "./connection.ts";
8
+ import type { PluginManifest, RuntimeOptions } from "./connection.ts";
9
+ import { Passes } from "./passes.ts";
10
+ import type { Change, Deps, PassCounts } from "./passes.ts";
11
+ import type { Transport } from "../wire.ts";
12
+ import type { Disposable } from "./types.ts";
13
+ /** Per-plugin services: the connection, and the update passes over it. */
14
+ export declare class Runtime extends Connection {
15
+ /** The update pass scheduler. */
16
+ readonly passes: Passes;
17
+ /** Pass counters, read by the SDK's own tests and benchmark ({@link PassCounts}). */
18
+ readonly counts: PassCounts;
95
19
  constructor(transport: Transport, manifest: PluginManifest, directory: string, dataDirectory?: string, app?: unknown, options?: RuntimeOptions);
96
- can(capability: string): boolean;
97
- /** Lazily created singletons shared by every scope of this plugin. */
98
- service<T>(name: string, create: () => T): T;
99
- /**
100
- * Registrations started while `activate` runs must succeed before the
101
- * plugin reports ready; later ones report failures to their scope.
102
- */
103
- starting<T>(work: Promise<T>, report: (error: unknown) => void): Promise<T>;
104
- /**
105
- * A declaration the player checks on its own (`what`: "command x"),
106
- * started like `starting`. In the player's runner a refusal of it during
107
- * activation (`invalid`, `conflict`, `limit`) does not fail the plugin:
108
- * it is logged, skipped and reported to the scope once activation
109
- * completes, so an `onError` added anywhere in `activate` hears it (SDK
110
- * 1.5.49; VS Code logs a bad contribution and activates the extension).
111
- * Under `strictDeclarations` (TestHost) it fails activation as before.
112
- */
113
- declaring<T>(work: Promise<T>, what: string, report: (error: unknown) => void): Promise<T>;
114
- activated(): Promise<void>;
20
+ /** {@link Passes.bind} */
115
21
  bind(evaluate: () => void): Disposable;
116
- /**
117
- * A service's state for `event` is read: a binding evaluated now depends
118
- * on it, so the event counts as listened to while the binding reads it.
119
- */
22
+ /** {@link Passes.reading} */
120
23
  reading(event: string): void;
121
- /**
122
- * A field of the SDK's copy of a state (`key`) is read; without `field`,
123
- * the state is taken (`plugin.player.state`). What is being evaluated
124
- * then depends on it: a precise pass after a change of that field runs
125
- * it again.
126
- */
24
+ /** {@link Passes.depends} */
127
25
  depends(key: string, field?: string): void;
128
- /**
129
- * Evaluate one part of the binding being evaluated (one `view.bind`
130
- * function), identified by `token`. A precise pass skips it when nothing
131
- * it read last time changed, and returns `undefined`; what it read then
132
- * still counts for the binding.
133
- */
26
+ /** {@link Passes.part} */
134
27
  part<T>(token: object, read: () => T): {
135
28
  value: T;
136
29
  } | undefined;
137
- /**
138
- * Run plugin code (a state listener) and return the state copy fields it
139
- * read; they are not counted as a binding's.
140
- */
30
+ /** {@link Passes.observe} */
141
31
  observe<T>(run: () => T): {
142
32
  value: T;
143
33
  deps: Deps;
144
34
  };
145
- /**
146
- * Whether code that read `deps` while `change` was delivered needs a full
147
- * pass after it: it read a field that changed, or no field of that state
148
- * at all (so the SDK cannot tell what it depends on).
149
- */
35
+ /** {@link Passes.needsFull} */
150
36
  needsFull(deps: Deps, change: Change): boolean;
151
- /**
152
- * Evaluate `read` as `label`, added at `where`: the state it reads is
153
- * reported as read by it. `field`: a command's `enabled` or `checked`,
154
- * which a `plugin.when` condition can replace.
155
- */
37
+ /** {@link Passes.reader} */
156
38
  reader<T>(label: string, where: (() => string | undefined) | undefined, read: () => T, field?: boolean): T;
157
- /**
158
- * Where the plugin's code called into the SDK: the first stack frame
159
- * outside the SDK, as a path relative to the plugin's directory and a
160
- * line (`main.ts:353`). Captured now, formatted when asked.
161
- */
162
- callSite(): () => string | undefined;
163
- /**
164
- * A full pass: every binding is evaluated. Requested after plugin code
165
- * the SDK ran, by `plugin.update()`, and on any change other than a state
166
- * copy's fields. Coalesced: one pass per microtask turn, however many
167
- * requests.
168
- */
39
+ /** {@link Passes.invalidate} */
169
40
  invalidate(): void;
170
- /**
171
- * Fields of the SDK's copy of a state (`key`) changed: a precise pass
172
- * evaluates only the bindings (and view bind functions) that read one of
173
- * them, unless a full pass is due anyway.
174
- */
41
+ /** {@link Passes.changed} */
175
42
  changed(key: string, fields: Iterable<string>): void;
176
- /** The plugin was disposed: cancel the pending safety pass, arm no more. */
43
+ /** {@link Passes.stop} */
177
44
  stop(): void;
178
- /**
179
- * Host events with one `events.subscribe` per name, however many listeners.
180
- * Without the `events` capability the listener simply never fires.
181
- * `mirror`: the SDK's own copy of the state (`plugin.player.state` and
182
- * the like), not a listener of the plugin's (see {@link EventGroup}).
183
- */
184
- on(event: string, listener: Listener,
185
- /** The capability the event needs; `null`: none. */
186
- needs?: string | null, mirror?: boolean): Disposable;
187
- /**
188
- * Count `event` as listened to while held: a watcher of a service's
189
- * state, a binding that reads it. Nothing when nothing subscribed to it
190
- * (no capability, or the service did not start).
191
- */
192
- hold(event: string, why?: Why): Disposable;
193
- /**
194
- * Why the plugin listens to each event it really listens to (mirrors
195
- * left out), as the player's log says it: for {@link TestHost} and
196
- * `vestra-plugin test`.
197
- */
198
- listening(): Map<string, string[]>;
199
- /** Raw transport events the host pushes without a subscription. */
200
- raw(event: string, listener: Listener): Disposable;
201
45
  }
202
- /** `plugin.app` from the start-up handshake (the runner's environment). */
203
- export declare function appInfo(raw: unknown, system?: () => Promise<SystemInfo>): App;
204
- export {};