@vestra-player/sdk 1.7.8 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/api-requests.js +3 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.js +1 -0
- package/dist/capability-rules.d.ts +3 -0
- package/dist/capability-rules.js +1 -0
- package/dist/commands.d.ts +15 -2
- package/dist/commands.js +7 -1
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +53 -0
- package/dist/manifest.js +12 -1
- package/dist/plugin/commands.d.ts +2 -1
- package/dist/plugin/commands.js +131 -4
- package/dist/plugin/scope.d.ts +1 -0
- package/dist/plugin/scope.js +2 -1
- package/dist/plugin/testing/commands.d.ts +7 -0
- package/dist/plugin/testing/commands.js +211 -0
- package/dist/plugin/testing/index.d.ts +70 -0
- package/dist/plugin/testing/index.js +66 -1
- package/dist/plugin/testing/internals.d.ts +14 -0
- package/dist/plugin/testing/internals.js +14 -1
- package/dist/plugin/types/base.d.ts +8 -5
- package/dist/plugin/types/commands.d.ts +412 -1
- package/dist/wire.d.ts +15 -0
- package/dist/wire.js +6 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/slint/vestra/icons.slint +4 -0
|
@@ -409,3 +409,214 @@ export function commandsHandlers(host, inner) {
|
|
|
409
409
|
},
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
|
+
/// ---------------------------------------------------------------- built-in only: commands.run, palette.lead
|
|
413
|
+
/** The player's refusal of a built-in-only capability to any other plugin. */
|
|
414
|
+
function builtinOnly(host) {
|
|
415
|
+
if (!host.builtin)
|
|
416
|
+
throw new HostError("capability", "this capability is for built-in plugins only");
|
|
417
|
+
}
|
|
418
|
+
/** The palette's rows: the player's core commands and the plugin's own. */
|
|
419
|
+
function rows(host) {
|
|
420
|
+
return [
|
|
421
|
+
...[...host.coreCommands].map(([id, command]) => ({
|
|
422
|
+
global: id,
|
|
423
|
+
local: id,
|
|
424
|
+
owner: "host",
|
|
425
|
+
command,
|
|
426
|
+
})),
|
|
427
|
+
...[...host.commands].map(([id, command]) => ({
|
|
428
|
+
global: `${host.manifestId}/${id}`,
|
|
429
|
+
local: id,
|
|
430
|
+
owner: "plugin",
|
|
431
|
+
command,
|
|
432
|
+
})),
|
|
433
|
+
].filter(({ command }) =>
|
|
434
|
+
// As the palette: no panel-only command, no disabled one without a reason.
|
|
435
|
+
command.declaration.focus !== "panel" &&
|
|
436
|
+
(command.state.enabled || !!command.display.reason));
|
|
437
|
+
}
|
|
438
|
+
/** A row as `commands.list` writes it (capabilities/commands_run.rs `listed`). */
|
|
439
|
+
function listed(host, inner, row) {
|
|
440
|
+
const { declaration, display, state } = row.command;
|
|
441
|
+
const builtin = row.owner === "host" || host.builtin;
|
|
442
|
+
const plugin = row.owner === "host" ? "Vestra Player" : host.manifestId;
|
|
443
|
+
const keys = declaration.path ?? [];
|
|
444
|
+
const parent = display.path.slice(0, -1);
|
|
445
|
+
const declared = declaration.category ?? null;
|
|
446
|
+
const category = declared !== null
|
|
447
|
+
? (display.category ?? menuTextKey(declared))
|
|
448
|
+
: parent.length
|
|
449
|
+
? parent.join(" ▸ ")
|
|
450
|
+
: plugin;
|
|
451
|
+
const categoryKey = declared !== null
|
|
452
|
+
? menuTextKey(declared)
|
|
453
|
+
: parent.length
|
|
454
|
+
? keys.slice(0, -1).map(menuTextKey).join(" ▸ ")
|
|
455
|
+
: row.owner === "host"
|
|
456
|
+
? plugin
|
|
457
|
+
: host.manifestId;
|
|
458
|
+
const home = declaration.home ? host.commands.get(declaration.home) : null;
|
|
459
|
+
const place = home
|
|
460
|
+
? home.display.title.replace(/…$/, "")
|
|
461
|
+
: !display.path.length
|
|
462
|
+
? ""
|
|
463
|
+
: declared === null || !parent.length
|
|
464
|
+
? "Menu"
|
|
465
|
+
: `${parent.join(" ▸ ")} ▸`;
|
|
466
|
+
const root = keys[0] === undefined ? undefined : menuTextKey(keys[0]);
|
|
467
|
+
return {
|
|
468
|
+
id: row.global,
|
|
469
|
+
label: `${category}: ${display.title}`,
|
|
470
|
+
labelSource: `${categoryKey}: ${menuTextKey(declaration.title)}`,
|
|
471
|
+
title: display.title,
|
|
472
|
+
category,
|
|
473
|
+
path: display.path,
|
|
474
|
+
place,
|
|
475
|
+
keys: commandKeys(host, inner).keys[row.local] ?? [],
|
|
476
|
+
plugin,
|
|
477
|
+
builtin,
|
|
478
|
+
enabled: state.enabled,
|
|
479
|
+
checkable: state.checked !== null,
|
|
480
|
+
radio: declaration.radio,
|
|
481
|
+
group: declaration.group,
|
|
482
|
+
busy: state.busy,
|
|
483
|
+
// Asks first: not built in, destructive, the player's Close and Quit,
|
|
484
|
+
// the Settings and Plugins menus.
|
|
485
|
+
dangerous: !builtin ||
|
|
486
|
+
declaration.destructive === true ||
|
|
487
|
+
row.global === "host/stop" ||
|
|
488
|
+
row.global === "host/quit" ||
|
|
489
|
+
root === "Settings" ||
|
|
490
|
+
root === "Plugins",
|
|
491
|
+
...(state.checked === null ? {} : { checked: state.checked }),
|
|
492
|
+
...(!state.enabled && display.reason ? { reason: display.reason } : {}),
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
/** `palette.lead.set` texts: at most this many characters each. */
|
|
496
|
+
const LEAD_TEXTS = {
|
|
497
|
+
title: 40,
|
|
498
|
+
placeholder: 60,
|
|
499
|
+
empty: 80,
|
|
500
|
+
note: 40,
|
|
501
|
+
"status.text": 80,
|
|
502
|
+
"status.note": 40,
|
|
503
|
+
};
|
|
504
|
+
/** The default handlers of `commands.run` and `palette.lead`. */
|
|
505
|
+
export function builtinHandlers(host, inner) {
|
|
506
|
+
return {
|
|
507
|
+
"commands.list": () => {
|
|
508
|
+
builtinOnly(host);
|
|
509
|
+
const commands = rows(host).map((row) => listed(host, inner, row));
|
|
510
|
+
// The revision changes with the table.
|
|
511
|
+
const text = JSON.stringify(commands);
|
|
512
|
+
if (text !== inner.listed.text)
|
|
513
|
+
inner.listed = { text, revision: inner.listed.revision + 1 };
|
|
514
|
+
return { revision: inner.listed.revision, commands };
|
|
515
|
+
},
|
|
516
|
+
"commands.run": async (p) => {
|
|
517
|
+
builtinOnly(host);
|
|
518
|
+
// The player's order: the ticket given, step and of, the command,
|
|
519
|
+
// then the ticket's count and rates, then the alert.
|
|
520
|
+
if (p.ticket === undefined || p.ticket === null)
|
|
521
|
+
throw new HostError("ticket", "commands.run needs the ticket of a palette.lead event");
|
|
522
|
+
const whole = (value) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 99;
|
|
523
|
+
if ((p.step === undefined) !== (p.of === undefined) ||
|
|
524
|
+
(p.step !== undefined &&
|
|
525
|
+
(!whole(p.step) || !whole(p.of) || Number(p.step) > Number(p.of))))
|
|
526
|
+
throw new HostError("invalid", "step and of go together, step ≤ of");
|
|
527
|
+
const id = String(p.id);
|
|
528
|
+
const row = rows(host).find((each) => each.global === id);
|
|
529
|
+
if (!row)
|
|
530
|
+
throw new HostError("missing", `no command ${id}`);
|
|
531
|
+
if (id === "host/palette")
|
|
532
|
+
throw new HostError("invalid", "the command palette is not run this way");
|
|
533
|
+
const item = listed(host, inner, row);
|
|
534
|
+
if (!item.enabled)
|
|
535
|
+
throw new HostError("disabled", item.reason ?? `${item.label} is disabled`);
|
|
536
|
+
if (item.busy)
|
|
537
|
+
throw new HostError("busy", `${item.label} is busy`);
|
|
538
|
+
const now = Date.now();
|
|
539
|
+
const ticket = inner.tickets.get(String(p.ticket));
|
|
540
|
+
if (!ticket || now - ticket.last > 120_000) {
|
|
541
|
+
inner.tickets.delete(String(p.ticket));
|
|
542
|
+
throw new HostError("ticket", "no live ticket");
|
|
543
|
+
}
|
|
544
|
+
inner.runs = inner.runs.filter((at) => now - at < 60_000);
|
|
545
|
+
ticket.runs = ticket.runs.filter((at) => now - at < 1000);
|
|
546
|
+
if (ticket.count >= 30)
|
|
547
|
+
throw new HostError("limit", "a ticket runs at most 30 commands");
|
|
548
|
+
if (ticket.runs.length >= 4)
|
|
549
|
+
throw new HostError("limit", "at most 4 commands a second");
|
|
550
|
+
if (inner.runs.length >= 120)
|
|
551
|
+
throw new HostError("limit", "at most 120 commands a minute");
|
|
552
|
+
ticket.count++;
|
|
553
|
+
ticket.runs.push(now);
|
|
554
|
+
ticket.last = now;
|
|
555
|
+
inner.runs.push(now);
|
|
556
|
+
// The player's own alert, answered like the plugin's alerts.
|
|
557
|
+
if (item.dangerous) {
|
|
558
|
+
const answer = host.dialogAnswers.shift();
|
|
559
|
+
if (answer === undefined || answer === null || Array.isArray(answer))
|
|
560
|
+
throw new Error("test host: no confirm answer queued for commands.run");
|
|
561
|
+
if (!answer.confirmed)
|
|
562
|
+
return { ran: false, declined: true };
|
|
563
|
+
}
|
|
564
|
+
// The OSD line naming the caller and the command.
|
|
565
|
+
const step = p.step === undefined ? "" : ` · ${p.step}/${p.of}`;
|
|
566
|
+
host.osd.push(`${host.manifestId}${step} · ${item.label}`);
|
|
567
|
+
if (row.owner === "host")
|
|
568
|
+
await host.request("host.run", { action: id.slice("host/".length) });
|
|
569
|
+
else
|
|
570
|
+
host.emit("commands.execute", {
|
|
571
|
+
id: row.local,
|
|
572
|
+
revision: row.command.revision,
|
|
573
|
+
});
|
|
574
|
+
return { ran: true };
|
|
575
|
+
},
|
|
576
|
+
"palette.lead.set": (p) => {
|
|
577
|
+
builtinOnly(host);
|
|
578
|
+
for (const [name, max] of Object.entries(LEAD_TEXTS)) {
|
|
579
|
+
const [first, second] = name.split(".");
|
|
580
|
+
const value = second
|
|
581
|
+
? p[first]?.[second]
|
|
582
|
+
: p[first];
|
|
583
|
+
if (value === undefined || value === null) {
|
|
584
|
+
if (name === "title")
|
|
585
|
+
throw new HostError("invalid", "title is required");
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
const length = [...menuTextKey(value)].length;
|
|
589
|
+
if (length < 1 || length > max)
|
|
590
|
+
throw new HostError("invalid", `${name} has 1–${max} characters`);
|
|
591
|
+
}
|
|
592
|
+
if (typeof p.icon !== "string" && host.imagePath(p.icon) === null)
|
|
593
|
+
throw new HostError("invalid", "icon is an icon name or an image");
|
|
594
|
+
host.paletteLead = { ...p };
|
|
595
|
+
},
|
|
596
|
+
"palette.lead.clear": () => {
|
|
597
|
+
builtinOnly(host);
|
|
598
|
+
host.paletteLead = null;
|
|
599
|
+
},
|
|
600
|
+
"palette.lead.done": (p) => {
|
|
601
|
+
builtinOnly(host);
|
|
602
|
+
inner.tickets.delete(String(p.ticket));
|
|
603
|
+
},
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
/** Implements `TestHost.runPaletteLead`. */
|
|
607
|
+
export async function runPaletteLead(host, inner, query, options) {
|
|
608
|
+
if (!host.paletteLead)
|
|
609
|
+
throw new Error("test host: no palette lead is set");
|
|
610
|
+
// One request at a time: the plugin's earlier tickets end.
|
|
611
|
+
inner.tickets.clear();
|
|
612
|
+
const ticket = `ticket-${++inner.next.ticket}`;
|
|
613
|
+
inner.tickets.set(ticket, { count: 0, runs: [], last: Date.now() });
|
|
614
|
+
host.emit("palette.lead", {
|
|
615
|
+
query,
|
|
616
|
+
keep: options.keep ?? false,
|
|
617
|
+
ticket,
|
|
618
|
+
status: options.status ?? false,
|
|
619
|
+
});
|
|
620
|
+
await host.settle();
|
|
621
|
+
return ticket;
|
|
622
|
+
}
|
|
@@ -2325,6 +2325,68 @@ export declare class TestHost implements Transport {
|
|
|
2325
2325
|
}[];
|
|
2326
2326
|
/** Every core action run (`host.run`, a core command, a pressed core binding), newest last. */
|
|
2327
2327
|
readonly coreRuns: string[];
|
|
2328
|
+
/**
|
|
2329
|
+
* The plugin is built into the player (`startPlugin`'s `builtin`). Only
|
|
2330
|
+
* then does the host take the built-in-only capabilities
|
|
2331
|
+
* (`commands.run`, `palette.lead`); otherwise their calls fail with
|
|
2332
|
+
* `capability`, as in the player.
|
|
2333
|
+
*
|
|
2334
|
+
* @since 1.7.9
|
|
2335
|
+
*/
|
|
2336
|
+
builtin: boolean;
|
|
2337
|
+
/**
|
|
2338
|
+
* The palette's lead row as the plugin last set it (`palette.lead.set`,
|
|
2339
|
+
* wire form), `null` without one. Wire-level.
|
|
2340
|
+
*
|
|
2341
|
+
* @since 1.7.9
|
|
2342
|
+
*/
|
|
2343
|
+
paletteLead: Record<string, Json> | null;
|
|
2344
|
+
/**
|
|
2345
|
+
* Simulate the user activating the palette's lead row: Enter (`keep`:
|
|
2346
|
+
* Shift+Enter) with `query` typed, or Enter on the status row
|
|
2347
|
+
* (`status`). Mints a ticket, sends the `palette.lead` event, waits until
|
|
2348
|
+
* the host is idle and returns the ticket.
|
|
2349
|
+
*
|
|
2350
|
+
* Like the player, `commands.run` takes the ticket until
|
|
2351
|
+
* `PaletteLead.done` or 120 s after its last run, at most 30 runs, 4 a
|
|
2352
|
+
* second, and 120 runs a minute per plugin (`limit`). A command declared
|
|
2353
|
+
* `destructive` (and the player's `host/stop`) is confirmed first: the
|
|
2354
|
+
* answer comes from {@link TestHost.dialogAnswers}
|
|
2355
|
+
* (`{ confirmed: false, checked: false }` is Don't Run); each run adds
|
|
2356
|
+
* the command's title (and ` · step/of`) to {@link TestHost.osd}.
|
|
2357
|
+
*
|
|
2358
|
+
* @param query - What the user typed.
|
|
2359
|
+
* @param options - `keep`: Shift+Enter; `status`: the status row.
|
|
2360
|
+
* @returns The ticket of this user action.
|
|
2361
|
+
*
|
|
2362
|
+
* @example Test a request that runs a destructive command
|
|
2363
|
+
* The user asks the plugin to stop playback and declines the
|
|
2364
|
+
* confirmation. `builtin` lets the plugin hold the lead; the ticket
|
|
2365
|
+
* minted here is what its listener passes to `commands.run`, and the
|
|
2366
|
+
* queued answer declines the player's alert for `host/stop`.
|
|
2367
|
+
* ```ts
|
|
2368
|
+
* import assert from "node:assert/strict";
|
|
2369
|
+
* import { startPlugin } from "@vestra-player/sdk/testing";
|
|
2370
|
+
* import activate from "../main.ts";
|
|
2371
|
+
*
|
|
2372
|
+
* const { host, stop } = await startPlugin(activate, {
|
|
2373
|
+
* directory: new URL("..", import.meta.url),
|
|
2374
|
+
* builtin: true, // as a plugin built into the player
|
|
2375
|
+
* });
|
|
2376
|
+
* host.dialogAnswers.push({ confirmed: false, checked: false }); // Don't Run
|
|
2377
|
+
* await host.runPaletteLead("stop playback");
|
|
2378
|
+
* assert.deepEqual(host.coreRuns, []); // declined: nothing ran
|
|
2379
|
+
* await stop();
|
|
2380
|
+
* ```
|
|
2381
|
+
*
|
|
2382
|
+
* @capability None.
|
|
2383
|
+
* @throws `Error` without a code (rejects) The plugin has no lead row.
|
|
2384
|
+
* @since 1.7.9
|
|
2385
|
+
*/
|
|
2386
|
+
runPaletteLead(query: string, options?: {
|
|
2387
|
+
keep?: boolean;
|
|
2388
|
+
status?: boolean;
|
|
2389
|
+
}): Promise<string>;
|
|
2328
2390
|
/**
|
|
2329
2391
|
* One of the 14 core actions (`play-pause`, `stop`, `seek-forward`, ...)
|
|
2330
2392
|
* that the test host registers like the player, as `host/<id>`. Throws for
|
|
@@ -3189,6 +3251,14 @@ export declare function startPlugin(activate: (plugin: Plugin) => unknown, optio
|
|
|
3189
3251
|
id?: string;
|
|
3190
3252
|
/** Use these capabilities instead of reading `manifest.json`. */
|
|
3191
3253
|
capabilities?: string[];
|
|
3254
|
+
/**
|
|
3255
|
+
* Run the plugin as one built into the player
|
|
3256
|
+
* ({@link TestHost.builtin}): only then do `commands.run` and
|
|
3257
|
+
* `palette.lead` work. Default `false`.
|
|
3258
|
+
*
|
|
3259
|
+
* @since 1.7.9
|
|
3260
|
+
*/
|
|
3261
|
+
builtin?: boolean;
|
|
3192
3262
|
/** A host to use (to preset data before activation). Default: a new one. */
|
|
3193
3263
|
host?: TestHost;
|
|
3194
3264
|
/** Use an existing directory as `plugin.dataDirectory` (to test a restart). */
|
|
@@ -85,7 +85,7 @@ import { PATCH_FEATURE } from "../patch.js";
|
|
|
85
85
|
import { LOCALES, LIST_SEPARATORS, loadPackageCatalog, TEXT_LIMITS, } from "../../i18n.js";
|
|
86
86
|
import { Internals } from "./internals.js";
|
|
87
87
|
import { on, emit, settle, close, keepsRunning, transportHandlers, tick, takenErrors, tellResidency, } from "./transport.js";
|
|
88
|
-
import { bindingClaims, bindingKey, keysChanged, press, barButtons, commandsHandlers, } from "./commands.js";
|
|
88
|
+
import { bindingClaims, bindingKey, keysChanged, press, barButtons, commandsHandlers, builtinHandlers, runPaletteLead, } from "./commands.js";
|
|
89
89
|
import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-actions.js";
|
|
90
90
|
import { translate, i18nHandlers } from "./i18n.js";
|
|
91
91
|
import { mountOther, unmountOther, mounted, setTimelineRanges, setTimelineLayer, layoutHandlers, } from "./layout.js";
|
|
@@ -1828,6 +1828,68 @@ export class TestHost {
|
|
|
1828
1828
|
steps = [];
|
|
1829
1829
|
/** Every core action run (`host.run`, a core command, a pressed core binding), newest last. */
|
|
1830
1830
|
coreRuns = [];
|
|
1831
|
+
// ------------------------------------------------------------ built-in only
|
|
1832
|
+
/**
|
|
1833
|
+
* The plugin is built into the player (`startPlugin`'s `builtin`). Only
|
|
1834
|
+
* then does the host take the built-in-only capabilities
|
|
1835
|
+
* (`commands.run`, `palette.lead`); otherwise their calls fail with
|
|
1836
|
+
* `capability`, as in the player.
|
|
1837
|
+
*
|
|
1838
|
+
* @since 1.7.9
|
|
1839
|
+
*/
|
|
1840
|
+
builtin = false;
|
|
1841
|
+
/**
|
|
1842
|
+
* The palette's lead row as the plugin last set it (`palette.lead.set`,
|
|
1843
|
+
* wire form), `null` without one. Wire-level.
|
|
1844
|
+
*
|
|
1845
|
+
* @since 1.7.9
|
|
1846
|
+
*/
|
|
1847
|
+
paletteLead = null;
|
|
1848
|
+
/**
|
|
1849
|
+
* Simulate the user activating the palette's lead row: Enter (`keep`:
|
|
1850
|
+
* Shift+Enter) with `query` typed, or Enter on the status row
|
|
1851
|
+
* (`status`). Mints a ticket, sends the `palette.lead` event, waits until
|
|
1852
|
+
* the host is idle and returns the ticket.
|
|
1853
|
+
*
|
|
1854
|
+
* Like the player, `commands.run` takes the ticket until
|
|
1855
|
+
* `PaletteLead.done` or 120 s after its last run, at most 30 runs, 4 a
|
|
1856
|
+
* second, and 120 runs a minute per plugin (`limit`). A command declared
|
|
1857
|
+
* `destructive` (and the player's `host/stop`) is confirmed first: the
|
|
1858
|
+
* answer comes from {@link TestHost.dialogAnswers}
|
|
1859
|
+
* (`{ confirmed: false, checked: false }` is Don't Run); each run adds
|
|
1860
|
+
* the command's title (and ` · step/of`) to {@link TestHost.osd}.
|
|
1861
|
+
*
|
|
1862
|
+
* @param query - What the user typed.
|
|
1863
|
+
* @param options - `keep`: Shift+Enter; `status`: the status row.
|
|
1864
|
+
* @returns The ticket of this user action.
|
|
1865
|
+
*
|
|
1866
|
+
* @example Test a request that runs a destructive command
|
|
1867
|
+
* The user asks the plugin to stop playback and declines the
|
|
1868
|
+
* confirmation. `builtin` lets the plugin hold the lead; the ticket
|
|
1869
|
+
* minted here is what its listener passes to `commands.run`, and the
|
|
1870
|
+
* queued answer declines the player's alert for `host/stop`.
|
|
1871
|
+
* ```ts
|
|
1872
|
+
* import assert from "node:assert/strict";
|
|
1873
|
+
* import { startPlugin } from "@vestra-player/sdk/testing";
|
|
1874
|
+
* import activate from "../main.ts";
|
|
1875
|
+
*
|
|
1876
|
+
* const { host, stop } = await startPlugin(activate, {
|
|
1877
|
+
* directory: new URL("..", import.meta.url),
|
|
1878
|
+
* builtin: true, // as a plugin built into the player
|
|
1879
|
+
* });
|
|
1880
|
+
* host.dialogAnswers.push({ confirmed: false, checked: false }); // Don't Run
|
|
1881
|
+
* await host.runPaletteLead("stop playback");
|
|
1882
|
+
* assert.deepEqual(host.coreRuns, []); // declined: nothing ran
|
|
1883
|
+
* await stop();
|
|
1884
|
+
* ```
|
|
1885
|
+
*
|
|
1886
|
+
* @capability None.
|
|
1887
|
+
* @throws `Error` without a code (rejects) The plugin has no lead row.
|
|
1888
|
+
* @since 1.7.9
|
|
1889
|
+
*/
|
|
1890
|
+
runPaletteLead(query, options = {}) {
|
|
1891
|
+
return runPaletteLead(this, this.#inner, query, options);
|
|
1892
|
+
}
|
|
1831
1893
|
/**
|
|
1832
1894
|
* One of the 14 core actions (`play-pause`, `stop`, `seek-forward`, ...)
|
|
1833
1895
|
* that the test host registers like the player, as `host/<id>`. Throws for
|
|
@@ -2667,6 +2729,7 @@ export class TestHost {
|
|
|
2667
2729
|
#defaults = {
|
|
2668
2730
|
...transportHandlers(this, this.#inner),
|
|
2669
2731
|
...commandsHandlers(this, this.#inner),
|
|
2732
|
+
...builtinHandlers(this, this.#inner),
|
|
2670
2733
|
...coreActionsHandlers(this, this.#inner),
|
|
2671
2734
|
...i18nHandlers(this, this.#inner),
|
|
2672
2735
|
...layoutHandlers(this, this.#inner),
|
|
@@ -2777,6 +2840,8 @@ export async function startPlugin(activate, options = {}) {
|
|
|
2777
2840
|
manifest = { id: read.id, capabilities: read.capabilities };
|
|
2778
2841
|
}
|
|
2779
2842
|
host.manifestId = manifest.id;
|
|
2843
|
+
if (options.builtin)
|
|
2844
|
+
host.builtin = true;
|
|
2780
2845
|
host.loadCatalog(directory);
|
|
2781
2846
|
// Its Slint files: the values its views are given are checked against
|
|
2782
2847
|
// their declared types.
|
|
@@ -70,7 +70,21 @@ export declare class Internals {
|
|
|
70
70
|
producer: number;
|
|
71
71
|
source: number;
|
|
72
72
|
resolution: number;
|
|
73
|
+
ticket: number;
|
|
73
74
|
};
|
|
75
|
+
/** `commands.run` tickets: runs, run times in the last second, last use (ms). */
|
|
76
|
+
readonly tickets: Map<string, {
|
|
77
|
+
count: number;
|
|
78
|
+
runs: number[];
|
|
79
|
+
last: number;
|
|
80
|
+
}>;
|
|
81
|
+
/** The last `commands.list` table (JSON) and its revision. */
|
|
82
|
+
listed: {
|
|
83
|
+
text: string;
|
|
84
|
+
revision: number;
|
|
85
|
+
};
|
|
86
|
+
/** The times of the plugin's `commands.run` calls in the last minute. */
|
|
87
|
+
runs: number[];
|
|
74
88
|
sourceBook: Map<number, Json>;
|
|
75
89
|
/** The pending resolutions' stamps and operations (beside `resolutions`). */
|
|
76
90
|
resolving: Map<number, {
|
|
@@ -47,7 +47,20 @@ export class Internals {
|
|
|
47
47
|
gone.catch(() => { });
|
|
48
48
|
return gone;
|
|
49
49
|
})();
|
|
50
|
-
next = {
|
|
50
|
+
next = {
|
|
51
|
+
snapshot: 0,
|
|
52
|
+
job: 0,
|
|
53
|
+
producer: 0,
|
|
54
|
+
source: 0,
|
|
55
|
+
resolution: 0,
|
|
56
|
+
ticket: 0,
|
|
57
|
+
};
|
|
58
|
+
/** `commands.run` tickets: runs, run times in the last second, last use (ms). */
|
|
59
|
+
tickets = new Map();
|
|
60
|
+
/** The last `commands.list` table (JSON) and its revision. */
|
|
61
|
+
listed = { text: "", revision: 0 };
|
|
62
|
+
/** The times of the plugin's `commands.run` calls in the last minute. */
|
|
63
|
+
runs = [];
|
|
51
64
|
sourceBook = new Map();
|
|
52
65
|
/** The pending resolutions' stamps and operations (beside `resolutions`). */
|
|
53
66
|
resolving = new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Command, CommandOptions } from "./commands.ts";
|
|
1
|
+
import type { Command, CommandOptions, PaletteLeadRun } from "./commands.ts";
|
|
2
2
|
import type { PackageCandidate, PluginInfo } from "./packages.ts";
|
|
3
3
|
import type { Conditional, Media, Stream } from "./playback.ts";
|
|
4
4
|
import type {
|
|
@@ -10,7 +10,7 @@ import type { ExportJob, MediaSources, Snapshot } from "./snapshots.ts";
|
|
|
10
10
|
import type { Resolver } from "./sources.ts";
|
|
11
11
|
import type { PropValue, View } from "./ui-content.ts";
|
|
12
12
|
import type { Panel, Window } from "./ui-layout.ts";
|
|
13
|
-
import type { Bindings, Commands, Host, When } from "./commands.ts";
|
|
13
|
+
import type { Bindings, Commands, Host, Palette, When } from "./commands.ts";
|
|
14
14
|
import type { Packages } from "./packages.ts";
|
|
15
15
|
import type { Player, Timeline } from "./playback.ts";
|
|
16
16
|
import type { AudioFilter, RenderOptions, VideoFilter, VideoShaders, VideoUpscaling, VideoView } from "./processing.ts";
|
|
@@ -100,7 +100,7 @@ export interface Disposable {
|
|
|
100
100
|
* | `invalid` | A bad argument (out of range, malformed, unknown id). |
|
|
101
101
|
* | `missing` | The target does not exist (an empty panel position, a missing file, an unknown command). |
|
|
102
102
|
* | `busy` | The player is still doing a previous call of the same kind (a dialog is open, a step is in flight). |
|
|
103
|
-
* | `conflict` | Another plugin owns the resource (the sequence provider, the display layer, the backdrop, a menu path), or this plugin already uses the id (a window or command id). |
|
|
103
|
+
* | `conflict` | Another plugin owns the resource (the sequence provider, the display layer, the backdrop, a menu path, the command palette's lead row), or this plugin already uses the id (a window or command id). |
|
|
104
104
|
* | `unavailable` | Not possible right now (no ready media, no user interface, fullscreen, a disabled core action). |
|
|
105
105
|
* | `unsupported` | Not possible on this system, build or source (a platform gap, software rendering, a source that cannot seek, a filter on a generated stream, an export the player cannot make as asked: a stream copy, a source bitrate it cannot tell). |
|
|
106
106
|
* | `backend` | Loading or resolving failed; `message` is the backend's reason. |
|
|
@@ -113,13 +113,14 @@ export interface Disposable {
|
|
|
113
113
|
* | `timeout` | A time limit ran out (`openStream` start-up, `tools.run`, `system.*` after 10 s). |
|
|
114
114
|
* | `stream`, `device` | `openStream`: the producer failed / the audio device is not ready. |
|
|
115
115
|
* | `backend-uncertain` | The player's backend blocked a filter stage; call `retry()`. |
|
|
116
|
-
* | `limit` | A player-wide limit was reached (for example the number of commands), a property value is over the limits of {@link PropValue},
|
|
116
|
+
* | `limit` | A player-wide limit was reached (for example the number of commands), a property value is over the limits of {@link PropValue}, a request is longer than the player's 1 MiB message, or {@link Commands.run} ran too often. |
|
|
117
117
|
* | `reserved` | {@link Packages.validate}, {@link PackageCandidate.install}: the id is `vestra` or starts with `vestra.` (any case), which only the player's built-in plugins use. |
|
|
118
118
|
* | `versionMismatch` | The package needs a newer player (`minPlayerVersion`). |
|
|
119
119
|
* | `ui-prepare` | The player could not prepare a mounted panel or a settings page (its Slint file does not compile, a bound property is not declared, or another plugin's panel holds the slot); `message` has the diagnostics. |
|
|
120
120
|
* | `ui` | The player could not apply a property to a tool window or a settings page, or could not build the Options window (a property the Slint file does not declare, a value of the wrong type); `message` has Slint's reason. Also reported to {@link Scope.onError} without a request: a callback whose arguments the player could not convert, a property it could not show again when it rebuilt a view (an image file removed since). |
|
|
121
121
|
* | `host` | Any other failure inside the player; `message` is the player's reason. |
|
|
122
|
-
* | `disabled` | The plugin is being stopped; pending requests fail with it. |
|
|
122
|
+
* | `disabled` | The plugin is being stopped; pending requests fail with it. {@link Commands.run}: the command is disabled; `message` has its reason. |
|
|
123
|
+
* | `ticket` | {@link Commands.run}: no ticket, or it ended or expired (a ticket comes with {@link PaletteLeadRun}). |
|
|
123
124
|
* | `unknown`, `rejected`, `expired` | After a transport problem the SDK could not confirm the outcome (does not happen in normal operation). |
|
|
124
125
|
* | `activation` | The plugin opened a tool window while its activation was still pending and the player could not track it. |
|
|
125
126
|
* | `command` | The player could not run or update a command it no longer knows for this plugin (removed meanwhile, or another plugin's). |
|
|
@@ -317,6 +318,8 @@ export interface Scope extends Disposable {
|
|
|
317
318
|
readonly packages: Packages;
|
|
318
319
|
/** On-screen messages over the video (`ui.osd`). */
|
|
319
320
|
readonly osd: Osd;
|
|
321
|
+
/** The command palette's lead row (`palette.lead`, built-in plugins only). */
|
|
322
|
+
readonly palette: Palette;
|
|
320
323
|
/** The player's own core playback actions (`commands`). */
|
|
321
324
|
readonly host: Host;
|
|
322
325
|
/** The system clipboard (`clipboard`). */
|