@vestra-player/sdk 1.6.18 → 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 (61) hide show
  1. package/CHANGELOG.md +11 -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 +24 -209
  30. package/dist/plugin/runtime.js +34 -770
  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/transport.js +1 -1
  41. package/dist/plugin/timeline.js +2 -1
  42. package/dist/plugin/view/base.d.ts +29 -0
  43. package/dist/plugin/view/base.js +88 -0
  44. package/dist/plugin/view/binder.d.ts +22 -0
  45. package/dist/plugin/view/binder.js +57 -0
  46. package/dist/plugin/view/image.d.ts +21 -0
  47. package/dist/plugin/view/image.js +60 -0
  48. package/dist/plugin/view/layout.d.ts +47 -0
  49. package/dist/plugin/view/layout.js +171 -0
  50. package/dist/plugin/view/panel.d.ts +3 -0
  51. package/dist/plugin/view/panel.js +178 -0
  52. package/dist/plugin/view/window.d.ts +3 -0
  53. package/dist/plugin/view/window.js +99 -0
  54. package/dist/plugin/view/writer.d.ts +58 -0
  55. package/dist/plugin/view/writer.js +634 -0
  56. package/dist/plugin/view.js +2 -1
  57. package/dist/plugin/window.js +1 -1
  58. package/llms.txt +1 -1
  59. package/package.json +2 -2
  60. package/dist/plugin/ui.d.ts +0 -74
  61. package/dist/plugin/ui.js +0 -1234
@@ -1,230 +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
- /**
41
- * Read-only counters of the update passes, for the SDK's own
42
- * characterisation tests and benchmark (`test/golden-traces.test.ts`,
43
- * `scripts/bench.mjs`): how many passes ran, how many were full, how many
44
- * bindings and view bind functions (parts) were evaluated or skipped. Not
45
- * part of the plugin API; counting changes no behaviour.
46
- */
47
- export interface PassCounts {
48
- /** Passes run (`Runtime.#run`), precise and full. */
49
- passes: number;
50
- /** Of them, full passes (every binding evaluated). */
51
- fullPasses: number;
52
- /** Bindings evaluated (`Runtime.#evaluate`). */
53
- evaluations: number;
54
- /** View bind functions evaluated inside a binding (`Runtime.part`). */
55
- parts: number;
56
- /** View bind functions a precise pass skipped (`Runtime.part`). */
57
- skippedParts: number;
58
- /**
59
- * Full passes the safety timer requested (`SAFETY_PASS_MS` after a
60
- * precise pass skipped something), counted when the timer fires.
61
- */
62
- safetyPasses: number;
63
- }
64
- /** How the plugin is run: the player's runner, or `TestHost`. */
65
- export interface RuntimeOptions {
66
- /**
67
- * A declaration the player refuses during activation fails activation
68
- * (`startPlugin`, so a plugin's tests show it) instead of being logged,
69
- * reported to `onError` and skipped (the player's runner).
70
- */
71
- strictDeclarations?: boolean;
72
- }
73
- /** A stop reason the runner passed on, if this SDK knows it. */
74
- export declare function stopReason(value: unknown): StopReason | undefined;
75
- export declare const same: (a: Json | undefined, b: Json | undefined) => boolean;
76
- /** One value in flight, only the newest waiting. Each push learns its fate. */
77
- export declare class Latest<T> {
78
- #private;
79
- constructor(send: (value: T) => Promise<void>);
80
- push(value: T): Promise<boolean>;
81
- stop(): void;
82
- }
83
- type Listener = (data: unknown) => void;
84
- /**
85
- * Per-plugin services. Scopes are thin views over this object; the flat RPC
86
- * clients stay private here so protocol fields never reach plugin code.
87
- */
88
- export declare class Runtime {
89
- #private;
90
- readonly host: Wire;
91
- readonly manifest: PluginManifest;
92
- readonly directory: string;
93
- /** Writable per-plugin data directory from the host, if it provided one. */
94
- readonly dataDirectory: string | undefined;
95
- /** Test doubles for local processes; the real system when absent. */
96
- readonly local: LocalServices | undefined;
97
- /** Registrations that activation must wait for before reporting ready. */
98
- readonly startup: Set<Promise<unknown>>;
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;
99
17
  /** Pass counters, read by the SDK's own tests and benchmark ({@link PassCounts}). */
100
18
  readonly counts: PassCounts;
101
- readonly views: Map<string, (callback: string, args: Json[]) => void>;
102
- readonly commands: Map<string, () => void>;
103
- readonly services: Map<string, unknown>;
104
- /**
105
- * Set when the player stops the plugin (`PluginInstance.dispose`), before
106
- * the root scope is disposed: `DisposeInfo` and `plugin.stopReason`.
107
- */
108
- stopping: {
109
- reason: StopReason | undefined;
110
- } | undefined;
111
- /** `plugin.app`, from the start-up handshake; `system()` asks the player. */
112
- readonly app: App;
113
- /** `plugin.i18n.locale`, from the start-up handshake; English when unknown. */
114
- readonly locale: Locale;
115
- /**
116
- * Protocol additions the player advertises at start-up (`features` in the
117
- * handshake's app data, player 0.6.0): `ui.patch` (row patches of
118
- * property writes). Not part of the plugin API; empty for older players.
119
- */
120
- readonly features: ReadonlySet<string>;
121
19
  constructor(transport: Transport, manifest: PluginManifest, directory: string, dataDirectory?: string, app?: unknown, options?: RuntimeOptions);
122
- can(capability: string): boolean;
123
- /** Lazily created singletons shared by every scope of this plugin. */
124
- service<T>(name: string, create: () => T): T;
125
- /**
126
- * Registrations started while `activate` runs must succeed before the
127
- * plugin reports ready; later ones report failures to their scope.
128
- */
129
- starting<T>(work: Promise<T>, report: (error: unknown) => void): Promise<T>;
130
- /**
131
- * A declaration the player checks on its own (`what`: "command x"),
132
- * started like `starting`. In the player's runner a refusal of it during
133
- * activation (`invalid`, `conflict`, `limit`) does not fail the plugin:
134
- * it is logged, skipped and reported to the scope once activation
135
- * completes, so an `onError` added anywhere in `activate` hears it (SDK
136
- * 1.5.49; VS Code logs a bad contribution and activates the extension).
137
- * Under `strictDeclarations` (TestHost) it fails activation as before.
138
- */
139
- declaring<T>(work: Promise<T>, what: string, report: (error: unknown) => void): Promise<T>;
140
- activated(): Promise<void>;
20
+ /** {@link Passes.bind} */
141
21
  bind(evaluate: () => void): Disposable;
142
- /**
143
- * A service's state for `event` is read: a binding evaluated now depends
144
- * on it, so the event counts as listened to while the binding reads it.
145
- */
22
+ /** {@link Passes.reading} */
146
23
  reading(event: string): void;
147
- /**
148
- * A field of the SDK's copy of a state (`key`) is read; without `field`,
149
- * the state is taken (`plugin.player.state`). What is being evaluated
150
- * then depends on it: a precise pass after a change of that field runs
151
- * it again.
152
- */
24
+ /** {@link Passes.depends} */
153
25
  depends(key: string, field?: string): void;
154
- /**
155
- * Evaluate one part of the binding being evaluated (one `view.bind`
156
- * function), identified by `token`. A precise pass skips it when nothing
157
- * it read last time changed, and returns `undefined`; what it read then
158
- * still counts for the binding.
159
- */
26
+ /** {@link Passes.part} */
160
27
  part<T>(token: object, read: () => T): {
161
28
  value: T;
162
29
  } | undefined;
163
- /**
164
- * Run plugin code (a state listener) and return the state copy fields it
165
- * read; they are not counted as a binding's.
166
- */
30
+ /** {@link Passes.observe} */
167
31
  observe<T>(run: () => T): {
168
32
  value: T;
169
33
  deps: Deps;
170
34
  };
171
- /**
172
- * Whether code that read `deps` while `change` was delivered needs a full
173
- * pass after it: it read a field that changed, or no field of that state
174
- * at all (so the SDK cannot tell what it depends on).
175
- */
35
+ /** {@link Passes.needsFull} */
176
36
  needsFull(deps: Deps, change: Change): boolean;
177
- /**
178
- * Evaluate `read` as `label`, added at `where`: the state it reads is
179
- * reported as read by it. `field`: a command's `enabled` or `checked`,
180
- * which a `plugin.when` condition can replace.
181
- */
37
+ /** {@link Passes.reader} */
182
38
  reader<T>(label: string, where: (() => string | undefined) | undefined, read: () => T, field?: boolean): T;
183
- /**
184
- * Where the plugin's code called into the SDK: the first stack frame
185
- * outside the SDK, as a path relative to the plugin's directory and a
186
- * line (`main.ts:353`). Captured now, formatted when asked.
187
- */
188
- callSite(): () => string | undefined;
189
- /**
190
- * A full pass: every binding is evaluated. Requested after plugin code
191
- * the SDK ran, by `plugin.update()`, and on any change other than a state
192
- * copy's fields. Coalesced: one pass per microtask turn, however many
193
- * requests.
194
- */
39
+ /** {@link Passes.invalidate} */
195
40
  invalidate(): void;
196
- /**
197
- * Fields of the SDK's copy of a state (`key`) changed: a precise pass
198
- * evaluates only the bindings (and view bind functions) that read one of
199
- * them, unless a full pass is due anyway.
200
- */
41
+ /** {@link Passes.changed} */
201
42
  changed(key: string, fields: Iterable<string>): void;
202
- /** The plugin was disposed: cancel the pending safety pass, arm no more. */
43
+ /** {@link Passes.stop} */
203
44
  stop(): void;
204
- /**
205
- * Host events with one `events.subscribe` per name, however many listeners.
206
- * Without the `events` capability the listener simply never fires.
207
- * `mirror`: the SDK's own copy of the state (`plugin.player.state` and
208
- * the like), not a listener of the plugin's (see {@link EventGroup}).
209
- */
210
- on(event: string, listener: Listener,
211
- /** The capability the event needs; `null`: none. */
212
- needs?: string | null, mirror?: boolean): Disposable;
213
- /**
214
- * Count `event` as listened to while held: a watcher of a service's
215
- * state, a binding that reads it. Nothing when nothing subscribed to it
216
- * (no capability, or the service did not start).
217
- */
218
- hold(event: string, why?: Why): Disposable;
219
- /**
220
- * Why the plugin listens to each event it really listens to (mirrors
221
- * left out), as the player's log says it: for {@link TestHost} and
222
- * `vestra-plugin test`.
223
- */
224
- listening(): Map<string, string[]>;
225
- /** Raw transport events the host pushes without a subscription. */
226
- raw(event: string, listener: Listener): Disposable;
227
45
  }
228
- /** `plugin.app` from the start-up handshake (the runner's environment). */
229
- export declare function appInfo(raw: unknown, system?: () => Promise<SystemInfo>): App;
230
- export {};