@vestra-player/sdk 1.6.20 → 1.6.22

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 (35) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/commands.d.ts +1 -1
  3. package/dist/commands.js +8 -8
  4. package/dist/docs-tree.json.gz +0 -0
  5. package/dist/i18n-tools.js +7 -2
  6. package/dist/plugin/testing/commands.js +3 -3
  7. package/dist/plugin/types/base.d.ts +1097 -0
  8. package/dist/plugin/types/base.js +1 -0
  9. package/dist/plugin/types/commands.d.ts +1189 -0
  10. package/dist/plugin/types/commands.js +1 -0
  11. package/dist/plugin/types/packages.d.ts +661 -0
  12. package/dist/plugin/types/packages.js +1 -0
  13. package/dist/plugin/types/playback.d.ts +1654 -0
  14. package/dist/plugin/types/playback.js +1 -0
  15. package/dist/plugin/types/processing.d.ts +974 -0
  16. package/dist/plugin/types/processing.js +1 -0
  17. package/dist/plugin/types/services.d.ts +1132 -0
  18. package/dist/plugin/types/services.js +1 -0
  19. package/dist/plugin/types/snapshots.d.ts +491 -0
  20. package/dist/plugin/types/snapshots.js +1 -0
  21. package/dist/plugin/types/sources.d.ts +302 -0
  22. package/dist/plugin/types/sources.js +1 -0
  23. package/dist/plugin/types/subtitles.d.ts +327 -0
  24. package/dist/plugin/types/subtitles.js +1 -0
  25. package/dist/plugin/types/ui-content.d.ts +692 -0
  26. package/dist/plugin/types/ui-content.js +1 -0
  27. package/dist/plugin/types/ui-layout.d.ts +1079 -0
  28. package/dist/plugin/types/ui-layout.js +1 -0
  29. package/dist/plugin/types/ui-locale.d.ts +490 -0
  30. package/dist/plugin/types/ui-locale.js +1 -0
  31. package/dist/plugin/types/ui-shell.d.ts +1072 -0
  32. package/dist/plugin/types/ui-shell.js +1 -0
  33. package/dist/plugin/types.d.ts +18 -11072
  34. package/llms.txt +1 -1
  35. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,661 @@
1
+ import type { Plugin } from "./base.ts";
2
+ import type { Disposable } from "./base.ts";
3
+ /**
4
+ * The manifest of a package, as validated. The display fields and
5
+ * `minPlayerVersion` are optional (player 0.2.0); see the API reference for
6
+ * their rules.
7
+ *
8
+ * @since 1.0.0
9
+ * @category Packages
10
+ */
11
+ export interface PackageManifest {
12
+ /** Plugin id. */
13
+ id: string;
14
+ /** `x.y.z`. */
15
+ version: string;
16
+ /** `vestra/1`. */
17
+ apiVersion: string;
18
+ /** Entry module path inside the package. */
19
+ entry: string;
20
+ /** Declared capabilities. */
21
+ capabilities: string[];
22
+ /** Display name, 1–64 characters. */
23
+ name?: string;
24
+ /** Author, 1–64 characters. */
25
+ author?: string;
26
+ /** One-line summary, 1–120 characters. */
27
+ punchline?: string;
28
+ /** Plain-text description, 1–2000 characters. */
29
+ description?: string;
30
+ /** Up to 8 tags of 1–24 characters. */
31
+ tags?: string[];
32
+ /** Package path of a PNG or JPEG icon (≤ 512 KB, sides ≤ 1024). */
33
+ icon?: string;
34
+ /** Package path of the README (`.md`, ≤ 256 KB); `README.md` when present. */
35
+ readme?: string;
36
+ /** Package path of the changelog (`.md`, ≤ 256 KB); `CHANGELOG.md` when present. */
37
+ changelog?: string;
38
+ /** `https:` address of the source code. */
39
+ sourceUrl?: string;
40
+ /** License, preferably an SPDX expression. */
41
+ license?: string;
42
+ /** The oldest player version that can load the package (`x.y.z`). */
43
+ minPlayerVersion?: string;
44
+ }
45
+ /**
46
+ * Where an installed plugin came from. Installs with the same source
47
+ * upgrade the plugin and keep its data; links and local files count as one
48
+ * source. `bundled` marks the player's built-in plugins (set by the player
49
+ * only).
50
+ *
51
+ * @since 1.1.0
52
+ * @category Packages
53
+ */
54
+ export type PackageSource = {
55
+ /** A repository. */
56
+ kind: "repository";
57
+ /** The full address of its `index.json`. */
58
+ url: string;
59
+ } | {
60
+ /** A package link. */
61
+ kind: "link";
62
+ /** The package's address. */
63
+ url: string;
64
+ } | {
65
+ /** A local `.vxp` file or package directory. */
66
+ kind: "file";
67
+ } | {
68
+ /** Generated by the plugin workshop. */
69
+ kind: "workshop";
70
+ } | {
71
+ /** Shipped with the player (built-in). */
72
+ kind: "bundled";
73
+ };
74
+ /**
75
+ * Options of {@link PackageCandidate.install}.
76
+ *
77
+ * @since 1.1.0
78
+ * @category Packages
79
+ */
80
+ export interface InstallOptions {
81
+ /**
82
+ * Where the package comes from (default `{ kind: "file" }`). Repository
83
+ * and link addresses must be `http(s)`. `bundled` is `invalid`.
84
+ */
85
+ source?: PackageSource;
86
+ /**
87
+ * Replace a plugin of the same id installed from another source (ask the
88
+ * user first). Without it such an install fails with `conflict`. The
89
+ * replaced plugin's data is kept; installing from its source again
90
+ * reconnects to it.
91
+ */
92
+ replace?: boolean;
93
+ /**
94
+ * Whether the plugin runs once installed (SDK 1.5.55). Left out, a first
95
+ * install runs and an update or reinstall (from any source, `replace`
96
+ * included) keeps the installed plugin's state: one the user or a store
97
+ * disabled stays disabled, and only its files are installed (nothing
98
+ * starts it, so the change commits without an `activating` step). `true`
99
+ * enables and starts it, for example a version the store disabled that
100
+ * an update fixes; if it fails to start, the old version is restored,
101
+ * still disabled. `false` installs it disabled: a running version is
102
+ * stopped and its session values go, as with {@link Packages.setEnabled}.
103
+ * Built-in plugins always run (and cannot be installed over). A value
104
+ * that is not a boolean is `invalid`.
105
+ *
106
+ * Player 0.6.4 and later: older players ignore it and an install there
107
+ * always runs the plugin, so after a committed install call
108
+ * {@link Packages.setEnabled} when the state matters.
109
+ *
110
+ * @player 0.6.4; older players ignore it (an install always
111
+ * enables the plugin).
112
+ */
113
+ enabled?: boolean;
114
+ }
115
+ /**
116
+ * A validated package directory, from {@link Packages.validate}.
117
+ *
118
+ * @remarks
119
+ * A package the player has checked, from {@link Packages.validate} or
120
+ * {@link Packages.validateArchive}: its manifest, digest and the checks
121
+ * it passed. The player copies the whole package when it checks it and
122
+ * installs that copy, so later changes to the directory do not matter.
123
+ * Installing starts a {@link PackageChange}; the player keeps only the 32
124
+ * most recent candidates.
125
+ *
126
+ * @capability plugins.manage
127
+ *
128
+ * @example Show what a package asks for before installing it
129
+ * Before installing, the plugin shows the package's name and the
130
+ * capabilities it declares. The candidate's `manifest` is the manifest
131
+ * as the player read it.
132
+ * ```ts
133
+ * declare const directory: string;
134
+ * // ---cut---
135
+ * const candidate = await plugin.packages.validate(directory);
136
+ * const { id, version, capabilities } = candidate.manifest;
137
+ * await plugin.osd.show("{} {}: {}", [id, version, capabilities.join(", ")]);
138
+ * ```
139
+ *
140
+ * @since 1.0.0
141
+ * @category Packages
142
+ */
143
+ export interface PackageCandidate {
144
+ /** The package directory. */
145
+ readonly directory: string;
146
+ /** Content digest of the package. */
147
+ readonly digest: string;
148
+ /** Its manifest. */
149
+ readonly manifest: PackageManifest;
150
+ /** The checks the player ran. */
151
+ readonly checks: string[];
152
+ /**
153
+ * Install it. The same source upgrades the installed plugin (its data
154
+ * stays); another source fails with `conflict` unless `replace` is set;
155
+ * a built-in id fails with `unsupported` (built-ins update with the
156
+ * player). A reserved id (`vestra` or `vestra.*`, which every built-in
157
+ * uses) fails with `reserved` (player 0.4.1; already when validated), as
158
+ * only the player installs built-in plugins. An update keeps a disabled
159
+ * plugin disabled unless `enabled` says otherwise (player 0.6.4; see
160
+ * {@link InstallOptions.enabled}).
161
+ *
162
+ * @capability plugins.manage
163
+ * @throws `invalid` (rejects) An option is malformed: a `source` the
164
+ * player does not accept, or a `replace` or `enabled` that is not a
165
+ * boolean.
166
+ * @throws `conflict` (rejects) The plugin is installed from another source
167
+ * and `replace` is not set.
168
+ * @throws `unsupported` (rejects) A built-in plugin's id.
169
+ * @throws `reserved` (rejects) A reserved id (`vestra`, `vestra.*`).
170
+ * @throws `busy` (rejects) The plugin library is being cleaned up, or the
171
+ * player already keeps 64 change records.
172
+ * @throws `revisionConflict` (rejects) The installed revision of this
173
+ * plugin changed meanwhile; call `install` again (no new validation
174
+ * needed).
175
+ * @throws `stale` (rejects) The candidate is older than the 32 the player
176
+ * keeps.
177
+ * @throws `capability` (rejects) The manifest does not declare
178
+ * `plugins.manage`.
179
+ *
180
+ * @example Replace a plugin installed from another source
181
+ * The new package replaces the installed plugin even though it came from
182
+ * another source. Without `replace` the player refuses with `conflict`;
183
+ * the same source simply upgrades and keeps the plugin's data.
184
+ * ```ts
185
+ * declare const candidate: PackageCandidate;
186
+ * // ---cut---
187
+ * const change = await candidate.install({ replace: true });
188
+ * await change.done; // "committed" once installed (running unless it stays disabled)
189
+ * ```
190
+ *
191
+ * @example Enable a fixed version of a plugin the store disabled
192
+ * A store disabled a version it revoked; the update that fixes it
193
+ * should run again. Without `enabled` the update keeps the plugin
194
+ * disabled (player 0.6.4); `true` enables it once installed. Older
195
+ * players ignore the option and enable every install.
196
+ * ```ts
197
+ * declare const candidate: PackageCandidate;
198
+ * // ---cut---
199
+ * const change = await candidate.install({ enabled: true });
200
+ * await change.done; // "committed" once the fixed version runs
201
+ * ```
202
+ *
203
+ * @since 1.0.0
204
+ */
205
+ install(options?: InstallOptions): Promise<PackageChange>;
206
+ }
207
+ /**
208
+ * The progress of an install or uninstall.
209
+ *
210
+ * @since 1.0.0
211
+ * @category Packages
212
+ */
213
+ export type PackageChangeStatus = "preparing" | "activating" | "restoring" | "committed" | "cancelled" | "failed" | "failedDegraded" | "tooLate";
214
+ /**
215
+ * An install or uninstall in progress. The SDK never submits a
216
+ * change twice: after a lost reply it only queries the same request.
217
+ *
218
+ * @remarks
219
+ * An install or uninstall the player carries out in steps (`preparing`,
220
+ * `activating`, possibly `restoring`) until a terminal status. The SDK
221
+ * asks the player for the status about every 400 ms until then; `done`
222
+ * resolves with the terminal status and does not reject for a failed
223
+ * change: `message` says why.
224
+ *
225
+ * @capability plugins.manage
226
+ *
227
+ * @example Report each step of an install
228
+ * The OSD shows each step of the install and the end result. `onChange`
229
+ * runs for every new status; `done` resolves when the change is over.
230
+ * ```ts
231
+ * declare const change: PackageChange;
232
+ * // ---cut---
233
+ * change.onChange((status) => void plugin.osd.show("Install: {}", [status]));
234
+ * const end = await change.done;
235
+ * if (end !== "committed") await plugin.osd.show("Not installed: {}", [change.message ?? end]);
236
+ * ```
237
+ *
238
+ * @since 1.0.0
239
+ * @category Packages
240
+ */
241
+ export interface PackageChange {
242
+ /** Current status. */
243
+ readonly status: PackageChangeStatus;
244
+ /** Details for failures, `null` otherwise. */
245
+ readonly message: string | null;
246
+ /**
247
+ * The status changed.
248
+ *
249
+ * @capability plugins.manage
250
+ *
251
+ * @example Close a progress window when the change ends
252
+ * The plugin's progress window closes once the install is over, whatever
253
+ * the outcome. The listener receives each new status; the terminal ones
254
+ * are `committed`, `cancelled`, `failed`, `failedDegraded` and `tooLate`
255
+ * (`tooLate` only answers a `cancel` of a change that had committed, and
256
+ * `committed` may follow it).
257
+ * ```ts
258
+ * declare const change: PackageChange;
259
+ * declare const progress: Window;
260
+ * // ---cut---
261
+ * change.onChange((status) => {
262
+ * if (["committed", "cancelled", "failed", "failedDegraded", "tooLate"].includes(status))
263
+ * void progress.close();
264
+ * });
265
+ * ```
266
+ *
267
+ * @since 1.0.0
268
+ */
269
+ onChange(listener: (status: PackageChangeStatus) => void): Disposable;
270
+ /**
271
+ * Resolves with the final status.
272
+ *
273
+ * @throws `missing` (rejects) The player no longer knows the change (a
274
+ * `HostError` with that code); a failed change is a terminal status,
275
+ * not a rejection.
276
+ */
277
+ readonly done: Promise<PackageChangeStatus>;
278
+ /**
279
+ * Ask to cancel (it may be `tooLate`).
280
+ *
281
+ * @capability plugins.manage
282
+ * @throws `capability` (rejects) The manifest does not declare
283
+ * `plugins.manage`.
284
+ *
285
+ * @example Cancel an install the user no longer wants
286
+ * The install stops if it has not gone too far. `cancel` asks the player;
287
+ * the change then ends `cancelled`. When the change had already committed
288
+ * the player answers `tooLate` and `done` still resolves `committed`; a
289
+ * change that is restoring cannot be cancelled and ends `failed` or
290
+ * `failedDegraded`.
291
+ * ```ts
292
+ * declare const change: PackageChange;
293
+ * // ---cut---
294
+ * await change.cancel();
295
+ * console.log(await change.done); // "cancelled"; "committed" when it was too late
296
+ * ```
297
+ *
298
+ * @since 1.0.0
299
+ */
300
+ cancel(): Promise<void>;
301
+ }
302
+ /**
303
+ * One plugin as the player knows it (`packages.list`).
304
+ *
305
+ * @since 1.0.0
306
+ * @category Packages
307
+ */
308
+ export interface PluginInfo {
309
+ /** Manifest id. */
310
+ id: string;
311
+ /** Version, `null` when unknown. */
312
+ version: string | null;
313
+ /** From the install library, or a `--plugin` development load. */
314
+ origin: "installed" | "development";
315
+ /** Run state. */
316
+ state: "starting" | "running" | "disabled" | "failed" | "stopped";
317
+ /** Why it failed (`state: "failed"`). */
318
+ error: string | null;
319
+ /** Declared capabilities. */
320
+ capabilities: string[];
321
+ /**
322
+ * The package directory (read its `manifest.json` for display fields).
323
+ * A built-in's directory is inside the player installation
324
+ * (`<install resources>/plugins/<id>`) and read-only: a plugin writes only
325
+ * under its own {@link Plugin.dataDirectory}.
326
+ */
327
+ directory: string;
328
+ /**
329
+ * Shipped with the player: it always runs; it cannot be disabled,
330
+ * uninstalled or replaced (older players, before SDK 1.5.18, let it be disabled).
331
+ * `false` from players before 0.2.0.
332
+ */
333
+ builtin: boolean;
334
+ /** Where an installed plugin came from; `null` for development loads. */
335
+ source: PackageSource | null;
336
+ /**
337
+ * Its data directory (`plugin.dataDirectory` of that plugin); `null` when
338
+ * the player has none. The path's layout is not part of the API.
339
+ */
340
+ dataDirectory: string | null;
341
+ /**
342
+ * What a running plugin was refused because another plugin holds it: a
343
+ * panel position (`slot-occupied`, with `slot`) or the next/previous
344
+ * sequence (`sequence-taken`). Neither fails activation; `error` has the
345
+ * same as text. Empty from players before 0.4.x (after 0.4.0).
346
+ * Always set by the SDK; optional so that code building `PluginInfo`
347
+ * values itself (tests) keeps compiling.
348
+ *
349
+ * @since 1.5.2
350
+ */
351
+ warnings?: readonly PluginWarning[];
352
+ /**
353
+ * The manifest's display texts in the interface language, translated
354
+ * with that package's catalog; absent from players before 0.4.3 (read
355
+ * `manifest.json` there).
356
+ *
357
+ * @since 1.5.9
358
+ */
359
+ display?: PluginDisplay;
360
+ /**
361
+ * For `state: "running"`: `"running"` while its process runs, `"idle"`
362
+ * while the plugin is switched on but has no process. That is standby
363
+ * with on-demand start (lazy activation): nothing used it for the idle
364
+ * time, or the player's limit on third-party processes or low system
365
+ * memory stopped it early (player 0.7.1); it starts again on its next
366
+ * use, and its menu items, keys, settings pages, resolvers and drop
367
+ * targets stay. From player 0.7.1 it is also the pause after a crash: a
368
+ * built-in or resident plugin waiting to start again by itself, or a
369
+ * plugin that has run before whose commands are shown disabled with the
370
+ * reason until the pause ends. Absent in other states and from players
371
+ * before 0.5.18. A change between the two alone does not fire
372
+ * {@link Packages.onChange}; a plugin stopped by the start limit (five
373
+ * crashes within 10 minutes) is `state: "failed"` with that in
374
+ * {@link PluginInfo.error}.
375
+ *
376
+ * @since 1.5.38
377
+ */
378
+ process?: "running" | "idle";
379
+ }
380
+ /**
381
+ * {@link PluginInfo.display}: a package's `name`, `punchline`,
382
+ * `description` and `tags` as the player shows them.
383
+ *
384
+ * @since 1.5.9
385
+ *
386
+ * @category Packages
387
+ */
388
+ export interface PluginDisplay {
389
+ /** `name`, translated; `null` when the manifest has none. */
390
+ readonly name: string | null;
391
+ /** `punchline`, translated; `null` when the manifest has none. */
392
+ readonly punchline: string | null;
393
+ /** `description`, translated; `null` when the manifest has none. */
394
+ readonly description: string | null;
395
+ /** `tags`, each translated. */
396
+ readonly tags: readonly string[];
397
+ }
398
+ /**
399
+ * One refusal in {@link PluginInfo.warnings}.
400
+ *
401
+ * @since 1.5.2
402
+ *
403
+ * @category Packages
404
+ */
405
+ export interface PluginWarning {
406
+ /**
407
+ * `"slot-occupied"`, `"sequence-taken"` or `"resolver-taken"` (player
408
+ * 0.4.1); a newer player may add codes.
409
+ */
410
+ code: string;
411
+ /** The panel position (`"bottom"`, `"backdrop"`; the sidebar and the adjust column hold any number of tabs) for `slot-occupied`. */
412
+ slot?: string;
413
+ /**
414
+ * What was taken, for `resolver-taken`: 「文件类型 .nes」 or the
415
+ * `scheme://host` of a web resolver.
416
+ */
417
+ target?: string;
418
+ /** The manifest id of the plugin holding it (absent for a full sidebar). */
419
+ owner?: string;
420
+ }
421
+ /**
422
+ * `plugin.packages`: the plugins the player knows. `list` and `onChange`
423
+ * need no capability; everything else needs `plugins.manage`.
424
+ *
425
+ * @example Install a plugin from an unpacked package
426
+ * The plugin installs a package directory it downloaded and unpacked, and
427
+ * reports why when it does not work. `validate` asks the player to check
428
+ * the package and returns a candidate; `install` starts the change and
429
+ * `done` resolves with its final status: `committed` only once the new
430
+ * plugin reported that it is running, otherwise `failed`, `cancelled`,
431
+ * `failedDegraded` or `tooLate`.
432
+ * ```ts
433
+ * declare const unpackedDirectory: string;
434
+ * // ---cut---
435
+ * const candidate = await plugin.packages.validate(unpackedDirectory);
436
+ * const change = await candidate.install();
437
+ * // `message` says why a change did not commit.
438
+ * if ((await change.done) !== "committed") throw new Error(change.message ?? "install failed");
439
+ * ```
440
+ *
441
+ * @remarks
442
+ * The plugins the player knows: installed, built-in and this run's
443
+ * development loads. Reading the list needs no capability; installing,
444
+ * enabling, reloading and uninstalling need `plugins.manage` and act on
445
+ * other plugins, never on the calling one. Built-in plugins update with
446
+ * the player and cannot be installed, disabled or uninstalled.
447
+ *
448
+ * @capability None for `list` and `onChange`; plugins.manage for the rest.
449
+ * @since 1.0.0
450
+ * @category Packages
451
+ */
452
+ export interface Packages {
453
+ /**
454
+ * Validate a package directory (`plugins.manage`). A package whose id is
455
+ * reserved for the built-in plugins (`vestra` or `vestra.*`) fails with
456
+ * `reserved` (player 0.4.1).
457
+ *
458
+ * The player keeps the 32 most recent candidates of all plugins; an
459
+ * older one's `install` fails with `stale` (validate again). Before
460
+ * player 0.4.2 the 33rd validation of a run failed with `busy` instead.
461
+ *
462
+ * @capability plugins.manage
463
+ * @throws `host` (rejects) Not a package directory, or a manifest that
464
+ * breaks the rules (another `apiVersion` included); `message` says why.
465
+ * @throws `invalid` (rejects) A bad request (a path that is not a string).
466
+ * @throws `javascript` (rejects) The entry module does not parse.
467
+ * @throws `slint` (rejects) A Slint file does not compile.
468
+ * @throws `reserved` (rejects) A reserved id (`vestra`, `vestra.*`).
469
+ * @throws `versionMismatch` (rejects) The package's `minPlayerVersion` is
470
+ * newer than the player.
471
+ * @throws `disabled` (rejects) The calling plugin is stopping.
472
+ * @throws `capability` (rejects) The manifest does not declare
473
+ * `plugins.manage`.
474
+ *
475
+ * @example Check a package directory before installing it
476
+ * The plugin checks a folder it unpacked and installs it if the player
477
+ * accepts it. `validate` runs the player's checks and resolves with a
478
+ * candidate; a package that fails them rejects with the reason.
479
+ * ```ts
480
+ * declare const directory: string;
481
+ * // ---cut---
482
+ * try {
483
+ * // Rejects with the reason when the package fails the checks.
484
+ * const candidate = await plugin.packages.validate(directory);
485
+ * await (await candidate.install()).done;
486
+ * } catch (error) {
487
+ * await plugin.osd.show("Not a valid plugin: {}", [(error as Error).message]);
488
+ * }
489
+ * ```
490
+ *
491
+ * @since 1.0.0
492
+ */
493
+ validate(directory: string): Promise<PackageCandidate>;
494
+ /**
495
+ * Validate a `.vxp` package file (`plugins.manage`, player 0.2.0): the
496
+ * same checks as {@link Packages.validate} after unpacking. Check the
497
+ * file's sha256 yourself before calling when you know it. A reserved id
498
+ * fails with `reserved`, as in {@link Packages.validate}.
499
+ *
500
+ * @capability plugins.manage
501
+ * @throws `invalid` (rejects) The path does not end in `.vxp`, or the
502
+ * archive cannot be unpacked (over 64 MB, too many files, a damaged zip,
503
+ * an unsafe path).
504
+ * @throws `host` (rejects) The unpacked package or its manifest breaks the
505
+ * rules; `message` says why.
506
+ * @throws `javascript` (rejects) The entry module does not parse.
507
+ * @throws `slint` (rejects) A Slint file does not compile.
508
+ * @throws `reserved` (rejects) A reserved id.
509
+ * @throws `versionMismatch` (rejects) The package's `minPlayerVersion` is
510
+ * newer than the player.
511
+ * @throws `disabled` (rejects) The calling plugin is stopping.
512
+ * @throws `capability` (rejects) The manifest does not declare
513
+ * `plugins.manage`.
514
+ *
515
+ * @example Install a downloaded package file
516
+ * A `.vxp` the plugin downloaded is checked and installed. The player
517
+ * unpacks and checks it like a directory; checking the file's sha256
518
+ * first, when the store publishes one, is up to the plugin.
519
+ * ```ts
520
+ * declare const file: string;
521
+ * // ---cut---
522
+ * const candidate = await plugin.packages.validateArchive(file); // a .vxp path
523
+ * const change = await candidate.install();
524
+ * await plugin.osd.show("Install: {}", [await change.done]);
525
+ * ```
526
+ *
527
+ * @since 1.1.0
528
+ */
529
+ validateArchive(file: string): Promise<PackageCandidate>;
530
+ /**
531
+ * Every plugin: running, installed, and this run's development loads. No capability.
532
+ *
533
+ * @capability None.
534
+ * @throws `Error` (rejects) Only when the player cannot be asked; no
535
+ * capability is needed.
536
+ *
537
+ * @example Show which plugins are running
538
+ * The plugin lists the running plugins by name. `list` asks the player
539
+ * and resolves with every plugin it knows, with its state, origin and
540
+ * display texts in the interface language.
541
+ * ```ts
542
+ * const plugins = await plugin.packages.list();
543
+ * const running = plugins.filter((info) => info.state === "running");
544
+ * console.log(running.map((info) => info.display?.name ?? info.id));
545
+ * ```
546
+ *
547
+ * @since 1.0.0
548
+ */
549
+ list(): Promise<PluginInfo[]>;
550
+ /**
551
+ * The new list after any start, stop, failure, install or uninstall. No capability.
552
+ *
553
+ * @capability None.
554
+ *
555
+ * @example Refresh a plugin list after any change
556
+ * A store window's list updates when a plugin starts, stops, fails, is
557
+ * installed or uninstalled. The listener receives the new list each time.
558
+ * ```ts
559
+ * plugin.packages.onChange((plugins) => console.log(plugins.length, "plugins"));
560
+ * ```
561
+ *
562
+ * @since 1.0.0
563
+ */
564
+ onChange(listener: (plugins: PluginInfo[]) => void): Disposable;
565
+ /**
566
+ * Stop or start a plugin (`plugins.manage`). An installed plugin stays
567
+ * disabled across launches; a development load only for this run.
568
+ * `invalid` to disable oneself, `missing` unknown.
569
+ * `busy` while it is being installed or reloaded. `unsupported` to disable a built-in
570
+ * ({@link PluginInfo.builtin}): users manage third-party plugins only
571
+ * (players released with SDK 1.5.18 on; older ones disabled built-ins too).
572
+ *
573
+ * @capability plugins.manage
574
+ * @throws `invalid` (rejects) Disabling the calling plugin itself.
575
+ * @throws `missing` (rejects) An unknown id.
576
+ * @throws `busy` (rejects) The plugin is being installed or reloaded.
577
+ * @throws `unsupported` (rejects) A built-in plugin.
578
+ * @throws `capability` (rejects) The manifest does not declare
579
+ * `plugins.manage`.
580
+ *
581
+ * @example Turn a third-party plugin off
582
+ * The plugin stops another plugin and keeps it disabled across launches
583
+ * until it is enabled again. Built-in plugins cannot be disabled
584
+ * (`unsupported`).
585
+ * ```ts
586
+ * await plugin.packages.setEnabled("someone.demo", false);
587
+ * ```
588
+ *
589
+ * @since 1.0.0
590
+ */
591
+ setEnabled(id: string, enabled: boolean): Promise<void>;
592
+ /**
593
+ * Restart a plugin (`plugins.manage`): stop it and start it again from the
594
+ * same package with the same data directory, for example to recover one
595
+ * that misbehaves. Built-ins included. A stopped or failed plugin is just
596
+ * started. The disabled flag is never written, so a reload never leaves
597
+ * a plugin disabled.
598
+ *
599
+ * Resolves once the plugin is stopped and its start is scheduled; the
600
+ * player starts it as soon as the old process is gone (at most 20 s).
601
+ * Follow it with {@link Packages.onChange}: `starting`, then `running`,
602
+ * or `failed` with the reason.
603
+ *
604
+ * `invalid` for oneself or a disabled plugin (enable it instead),
605
+ * `missing` unknown, `busy` while it is being installed or reloaded.
606
+ *
607
+ * @player 0.5.1; older players reject it as an unknown request
608
+ * (`unsupported`).
609
+ * @since 1.5.19
610
+ *
611
+ * @capability plugins.manage
612
+ * @throws `invalid` (rejects) The calling plugin itself, or a disabled
613
+ * plugin.
614
+ * @throws `missing` (rejects) An unknown id.
615
+ * @throws `busy` (rejects) The plugin is being installed or reloaded.
616
+ * @throws `unsupported` (rejects) A player before 0.5.1.
617
+ * @throws `capability` (rejects) The manifest does not declare
618
+ * `plugins.manage`.
619
+ *
620
+ * @example Restart a plugin that misbehaves
621
+ * The other plugin is stopped and started again from the same package and
622
+ * data. `reload` resolves once the old process is stopped and the start is
623
+ * scheduled; `onChange` then shows `starting` and `running` (or `failed`).
624
+ * ```ts
625
+ * await plugin.packages.reload("someone.demo");
626
+ * ```
627
+ */
628
+ reload(id: string): Promise<void>;
629
+ /**
630
+ * Remove an installed plugin (`plugins.manage`); `removeData` also deletes
631
+ * its data directory, otherwise reinstalling it from the same source
632
+ * reconnects to its data. Its user bindings stay (as orphans).
633
+ * `unsupported` for built-ins and development loads, `missing`
634
+ * unknown, `invalid` for oneself.
635
+ *
636
+ * @capability plugins.manage
637
+ * @throws `unsupported` (rejects) A built-in plugin or a development load.
638
+ * @throws `missing` (rejects) An unknown id.
639
+ * @throws `invalid` (rejects) The calling plugin itself.
640
+ * @throws `busy` (rejects) The plugin library is being cleaned up, or that
641
+ * plugin is being installed or reloaded.
642
+ * @throws `revisionConflict` (rejects) The installed revision of that
643
+ * plugin changed meanwhile; call `uninstall` again.
644
+ * @throws `capability` (rejects) The manifest does not declare
645
+ * `plugins.manage`.
646
+ *
647
+ * @example Uninstall a plugin together with its data
648
+ * The other plugin is removed and its data directory deleted, so a later
649
+ * reinstall starts fresh. Without `removeData` a reinstall from the same
650
+ * source finds its data again.
651
+ * ```ts
652
+ * const change = await plugin.packages.uninstall("someone.demo", { removeData: true });
653
+ * await change.done;
654
+ * ```
655
+ *
656
+ * @since 1.0.0
657
+ */
658
+ uninstall(id: string, options?: {
659
+ removeData?: boolean;
660
+ }): Promise<PackageChange>;
661
+ }
@@ -0,0 +1 @@
1
+ export {};