@vestra-player/sdk 1.8.0 → 1.10.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 (106) hide show
  1. package/CHANGELOG.md +64 -2
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +98 -106
  4. package/capability-scan.json +21 -1
  5. package/dist/api-requests.d.ts +15 -39
  6. package/dist/api-requests.js +28 -50
  7. package/dist/capability-scan.d.ts +1 -1
  8. package/dist/capability-scan.js +8 -9
  9. package/dist/condition-table.d.ts +1889 -0
  10. package/dist/condition-table.js +562 -0
  11. package/dist/docs-tree.json.gz +0 -0
  12. package/dist/docs.d.ts +1 -1
  13. package/dist/docs.js +1 -1
  14. package/dist/i18n-tools.d.ts +7 -0
  15. package/dist/i18n-tools.js +66 -3
  16. package/dist/index.d.ts +4 -5
  17. package/dist/manifest.d.ts +5 -0
  18. package/dist/manifest.js +9 -24
  19. package/dist/member-uses.d.ts +61 -0
  20. package/dist/member-uses.js +160 -0
  21. package/dist/player-runtime.d.ts +4 -2
  22. package/dist/player-runtime.js +4 -2
  23. package/dist/plugin/appearance.d.ts +1 -1
  24. package/dist/plugin/appearance.js +2 -2
  25. package/dist/plugin/bindings.d.ts +1 -1
  26. package/dist/plugin/bindings.js +2 -2
  27. package/dist/plugin/commands.js +1 -12
  28. package/dist/plugin/connection.d.ts +38 -8
  29. package/dist/plugin/connection.js +126 -37
  30. package/dist/plugin/drops.js +1 -1
  31. package/dist/plugin/index.d.ts +7 -0
  32. package/dist/plugin/index.js +22 -15
  33. package/dist/plugin/media.js +0 -12
  34. package/dist/plugin/mpv.js +39 -12
  35. package/dist/plugin/packages.js +1 -2
  36. package/dist/plugin/player/events.d.ts +17 -7
  37. package/dist/plugin/player/events.js +26 -9
  38. package/dist/plugin/player.d.ts +37 -13
  39. package/dist/plugin/player.js +133 -22
  40. package/dist/plugin/scope.d.ts +4 -1
  41. package/dist/plugin/scope.js +8 -0
  42. package/dist/plugin/services.d.ts +4 -4
  43. package/dist/plugin/services.js +7 -29
  44. package/dist/plugin/settings.js +1 -1
  45. package/dist/plugin/shaders.js +0 -2
  46. package/dist/plugin/stream.d.ts +2 -1
  47. package/dist/plugin/stream.js +2 -2
  48. package/dist/plugin/testing/commands.d.ts +3 -10
  49. package/dist/plugin/testing/commands.js +24 -37
  50. package/dist/plugin/testing/index.d.ts +133 -116
  51. package/dist/plugin/testing/index.js +198 -125
  52. package/dist/plugin/testing/media.d.ts +6 -0
  53. package/dist/plugin/testing/media.js +15 -2
  54. package/dist/plugin/testing/processing.js +1 -1
  55. package/dist/plugin/testing/services.js +0 -1
  56. package/dist/plugin/testing/source-events.d.ts +28 -0
  57. package/dist/plugin/testing/source-events.js +66 -0
  58. package/dist/plugin/testing/transport.js +5 -0
  59. package/dist/plugin/testing/triggers.d.ts +82 -0
  60. package/dist/plugin/testing/triggers.js +448 -0
  61. package/dist/plugin/timeline.d.ts +5 -6
  62. package/dist/plugin/timeline.js +7 -11
  63. package/dist/plugin/triggers.d.ts +55 -0
  64. package/dist/plugin/triggers.js +233 -0
  65. package/dist/plugin/types/base.d.ts +77 -87
  66. package/dist/plugin/types/commands.d.ts +384 -68
  67. package/dist/plugin/types/packages.d.ts +17 -55
  68. package/dist/plugin/types/playback.d.ts +382 -152
  69. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  70. package/dist/plugin/types/processing.d.ts +10 -49
  71. package/dist/plugin/types/services.d.ts +11 -70
  72. package/dist/plugin/types/snapshots.d.ts +7 -60
  73. package/dist/plugin/types/sources.d.ts +2 -11
  74. package/dist/plugin/types/subtitles.d.ts +5 -26
  75. package/dist/plugin/types/ui-content.d.ts +1 -16
  76. package/dist/plugin/types/ui-layout.d.ts +53 -79
  77. package/dist/plugin/types/ui-locale.d.ts +5 -23
  78. package/dist/plugin/types/ui-shell.d.ts +13 -59
  79. package/dist/plugin/view/layout.js +1 -1
  80. package/dist/plugin/view.js +0 -2
  81. package/dist/plugin/when.d.ts +78 -4
  82. package/dist/plugin/when.js +182 -14
  83. package/dist/plugin/window.d.ts +1 -1
  84. package/dist/plugin/window.js +1 -1
  85. package/dist/plugin/wire-facade.js +1 -2
  86. package/dist/processing.d.ts +2 -3
  87. package/dist/protocol.d.ts +14 -0
  88. package/dist/protocol.js +14 -0
  89. package/dist/request-queue.js +1 -1
  90. package/dist/slint-version.d.ts +7 -0
  91. package/dist/slint-version.js +7 -0
  92. package/dist/subtitles.d.ts +1 -1
  93. package/dist/ts-plugin.d.ts +8 -15
  94. package/dist/ts-plugin.js +3 -141
  95. package/dist/wire.d.ts +22 -12
  96. package/dist/wire.js +17 -8
  97. package/llms.txt +6 -6
  98. package/package.json +1 -2
  99. package/dist/capabilities.d.ts +0 -107
  100. package/dist/capabilities.js +0 -69
  101. package/dist/capability-check.d.ts +0 -176
  102. package/dist/capability-check.js +0 -461
  103. package/dist/capability-rules.d.ts +0 -125
  104. package/dist/capability-rules.js +0 -192
  105. package/dist/host-capabilities.d.ts +0 -10
  106. package/dist/host-capabilities.js +0 -492
package/dist/index.d.ts CHANGED
@@ -8,16 +8,15 @@
8
8
  * import with `import type`.
9
9
  *
10
10
  * Start with {@link Plugin} and {@link Scope}: every module
11
- * (`plugin.commands`, `plugin.player`, `plugin.windows`…) hangs off them and
12
- * documents the manifest capability it needs. Errors are described at
11
+ * (`plugin.commands`, `plugin.player`, `plugin.windows`…) hangs off them.
12
+ * Errors are described at
13
13
  * {@link PluginError}. Tests use `@vestra-player/sdk/testing`.
14
14
  *
15
15
  * @example Add a menu item that shows a message
16
16
  * The player gets a Tools ▸ Hello menu item; picking it shows "Hello" on
17
17
  * the video. The player imports the entry module and calls `activate` with
18
- * the plugin's `Plugin` object; `commands.add` registers the item (manifest
19
- * capability `commands`), and the player calls `run` when the user picks it
20
- * or presses a key bound to it. `osd.show` needs `ui.osd`.
18
+ * the plugin's `Plugin` object; `commands.add` registers the item, and the
19
+ * player calls `run` when the user picks it or presses a key bound to it.
21
20
  * ```ts
22
21
  * import type { Plugin } from "@vestra-player/sdk";
23
22
  *
@@ -15,6 +15,11 @@ export declare const MANIFEST_LIMITS: Readonly<{
15
15
  /** Every field a manifest may have; anything else is rejected by the player. */
16
16
  export declare const MANIFEST_FIELDS: readonly string[];
17
17
  export declare const validVersion: (value: unknown) => value is string;
18
+ /**
19
+ * Why a manifest with `capabilities` is refused (SDK 1.9.0, player 0.9.0):
20
+ * the field is gone, and what it switched on is two calls.
21
+ */
22
+ export declare const CAPABILITIES_REMOVED = "manifest.json has \"capabilities\", which SDK 1.9.0 (player 0.9.0) removed: delete the field. What it switched on is now a call, first in activate(): plugin.player.subscribe() for \"events\", await plugin.player.read() for \"playback.read\"; everything else needs nothing (the store shows what the code uses, from its scan)";
18
23
  /** Problems with `manifest` (empty: valid) and hints that do not fail. */
19
24
  export declare function manifestProblems(manifest: Record<string, unknown>, directory: string): {
20
25
  problems: string[];
package/dist/manifest.js CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
7
7
  import { join, sep } from "node:path";
8
- import { API_VERSION, CAPABILITIES, CAPABILITY_INFO } from "./capabilities.js";
8
+ import { API_VERSION } from "./protocol.js";
9
9
  export const MANIFEST_LIMITS = Object.freeze({
10
10
  idBytes: 128,
11
11
  name: 64,
@@ -26,7 +26,6 @@ export const MANIFEST_FIELDS = [
26
26
  "version",
27
27
  "apiVersion",
28
28
  "entry",
29
- "capabilities",
30
29
  "name",
31
30
  "author",
32
31
  "punchline",
@@ -44,6 +43,11 @@ export const validVersion = (value) => typeof value === "string" &&
44
43
  value.length <= 32 &&
45
44
  VERSION.test(value) &&
46
45
  value.split(".").every((part) => BigInt(part) <= 4294967295n);
46
+ /**
47
+ * Why a manifest with `capabilities` is refused (SDK 1.9.0, player 0.9.0):
48
+ * the field is gone, and what it switched on is two calls.
49
+ */
50
+ export const CAPABILITIES_REMOVED = 'manifest.json has "capabilities", which SDK 1.9.0 (player 0.9.0) removed: delete the field. What it switched on is now a call, first in activate(): plugin.player.subscribe() for "events", await plugin.player.read() for "playback.read"; everything else needs nothing (the store shows what the code uses, from its scan)';
47
51
  /** Problems with `manifest` (empty: valid) and hints that do not fail. */
48
52
  export function manifestProblems(manifest, directory) {
49
53
  const problems = [];
@@ -54,7 +58,9 @@ export function manifestProblems(manifest, directory) {
54
58
  Array.isArray(manifest))
55
59
  return { problems: ["manifest.json must be an object"], hints };
56
60
  for (const key of Object.keys(manifest))
57
- if (!MANIFEST_FIELDS.includes(key))
61
+ if (key === "capabilities")
62
+ problem(CAPABILITIES_REMOVED);
63
+ else if (!MANIFEST_FIELDS.includes(key))
58
64
  problem(`unknown field "${key}"`);
59
65
  const id = manifest.id;
60
66
  if (typeof id !== "string" ||
@@ -66,27 +72,6 @@ export function manifestProblems(manifest, directory) {
66
72
  hints.push(`id "${id}" has no prefix: the official repository needs <GitHub user or organization>.<plugin name>`);
67
73
  if (manifest.apiVersion !== API_VERSION)
68
74
  problem(`apiVersion is ${JSON.stringify(manifest.apiVersion)}; this SDK is ${API_VERSION}`);
69
- const capabilities = manifest.capabilities;
70
- if (!Array.isArray(capabilities))
71
- problem("capabilities must be an array");
72
- else {
73
- const unknown = capabilities.filter((c) => !CAPABILITIES.includes(c));
74
- if (unknown.length)
75
- problem(`unknown capabilities ${unknown.join(", ")}`);
76
- if (new Set(capabilities).size !== capabilities.length)
77
- problem("capabilities must be unique");
78
- // Only a built-in plugin may declare these. Built-in plugins have a
79
- // `vestra.` id, which the player refuses for any other package: any
80
- // other id is an error, a `vestra.` id a reminder.
81
- const builtinOnly = capabilities.filter((c) => CAPABILITY_INFO[c]?.builtinOnly);
82
- if (builtinOnly.length) {
83
- const text = `${builtinOnly.join(", ")}: built-in plugins only (the player refuses any other plugin that declares ${builtinOnly.length === 1 ? "it" : "them"}, and its calls fail with code capability)`;
84
- if (typeof id === "string" && /^vestra\./i.test(id))
85
- hints.push(text);
86
- else
87
- problem(text);
88
- }
89
- }
90
75
  if (typeof manifest.entry !== "string" || !relative(manifest.entry))
91
76
  problem("entry must be a relative path inside the package");
92
77
  if (manifest.version !== undefined && !validVersion(manifest.version))
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Where a plugin's TypeScript uses SDK members: the type-aware resolution
3
+ * the capability scan (`capability-scan.ts`) reads a plugin's code with. A
4
+ * use is a property access, an element access with a literal name or a
5
+ * destructured property whose symbol is the SDK's declaration of a member
6
+ * asked for, however the object was reached (`plugin.player.seek`,
7
+ * `const { player } = plugin; player.seek`, a parameter typed `Player`, a
8
+ * `Panel` from `panels.mount`). Not detected: access with a computed name
9
+ * (`player[name]`), values typed `any` or `unknown`, plain JavaScript
10
+ * without types.
11
+ *
12
+ * Requests sent by name (`plugin.wire.request`) are found too, with the
13
+ * method when its type fixes it to one string.
14
+ *
15
+ * The TypeScript module is passed in, never imported: the CLI uses the
16
+ * SDK's own compiler.
17
+ *
18
+ * @internal
19
+ */
20
+ import type TS from "typescript";
21
+ /** @internal The module plugins import the API types from. */
22
+ export declare const SDK_MODULE = "@vestra-player/sdk";
23
+ /** @internal One use of an SDK member, where {@link findMemberUses} found it. */
24
+ export interface MemberUse {
25
+ readonly file: string;
26
+ /** 1-based line and column of the member's name. */
27
+ readonly line: number;
28
+ readonly column: number;
29
+ /** The member, as it was asked for (`Clipboard.readText`). */
30
+ readonly api: string;
31
+ }
32
+ /**
33
+ * @internal A request sent by name (`plugin.wire.request("clipboard.readText")`):
34
+ * the method when the types fix it to one string, else `undefined` (a
35
+ * computed name, a union of several, the member taken as a value).
36
+ */
37
+ export interface RequestUse {
38
+ readonly file: string;
39
+ readonly line: number;
40
+ readonly column: number;
41
+ readonly method: string | undefined;
42
+ }
43
+ /**
44
+ * Every use, in `files`, of the SDK members named by `apis`
45
+ * (`Interface.member`), and every request sent by name (`Wire.request`),
46
+ * in file and position order. It reads no manifest (the capability scan,
47
+ * `capability-scan.ts`, gives it its lists).
48
+ *
49
+ * `resolved` is `false` when the program has no import of
50
+ * `@vestra-player/sdk` that resolves: nothing can be found by type then.
51
+ *
52
+ * @internal
53
+ */
54
+ export declare function findMemberUses(ts: typeof TS, program: TS.Program, options: {
55
+ readonly files: readonly string[];
56
+ readonly apis: Iterable<string>;
57
+ }): {
58
+ resolved: boolean;
59
+ uses: MemberUse[];
60
+ requests: RequestUse[];
61
+ };
@@ -0,0 +1,160 @@
1
+ /** @internal The module plugins import the API types from. */
2
+ export const SDK_MODULE = "@vestra-player/sdk";
3
+ /** The members that send a request by the method name they are given. */
4
+ const SENDERS = ["Wire.request"];
5
+ /**
6
+ * The module `@vestra-player/sdk` as the program resolved it: from the
7
+ * first import or export of it in the program's own (non-declaration) files.
8
+ */
9
+ function sdkModule(ts, program, checker) {
10
+ for (const file of program.getSourceFiles()) {
11
+ if (file.isDeclarationFile || program.isSourceFileFromExternalLibrary(file))
12
+ continue;
13
+ for (const statement of file.statements) {
14
+ const specifier = ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)
15
+ ? statement.moduleSpecifier
16
+ : undefined;
17
+ if (specifier &&
18
+ ts.isStringLiteral(specifier) &&
19
+ specifier.text === SDK_MODULE) {
20
+ const module = checker.getSymbolAtLocation(specifier);
21
+ if (module)
22
+ return module;
23
+ }
24
+ }
25
+ }
26
+ return undefined;
27
+ }
28
+ /** The SDK's declarations of the members named (`Interface.member`). */
29
+ function resolveMembers(ts, program, apis) {
30
+ const members = new Map();
31
+ const checker = program.getTypeChecker();
32
+ const module = sdkModule(ts, program, checker);
33
+ if (!module)
34
+ return members;
35
+ const exports = new Map();
36
+ for (const symbol of checker.getExportsOfModule(module))
37
+ exports.set(symbol.name, symbol.flags & ts.SymbolFlags.Alias
38
+ ? checker.getAliasedSymbol(symbol)
39
+ : symbol);
40
+ for (const api of apis) {
41
+ const [head, ...path] = api.split(".");
42
+ const root = exports.get(head);
43
+ if (!root || !path.length)
44
+ continue;
45
+ let type = checker.getDeclaredTypeOfSymbol(root);
46
+ let property;
47
+ for (const name of path) {
48
+ property = type?.getProperty(name);
49
+ type = property && checker.getTypeOfSymbol(property);
50
+ }
51
+ for (const declaration of property?.declarations ?? [])
52
+ if (!members.has(declaration))
53
+ members.set(declaration, api);
54
+ }
55
+ return members;
56
+ }
57
+ /**
58
+ * The strings an expression's type fixes: a string literal, a constant of
59
+ * one, or a union of them (the caller takes one only); `undefined` when
60
+ * the type allows any other.
61
+ */
62
+ function literalStrings(ts, checker, node) {
63
+ if (!node)
64
+ return undefined;
65
+ if (ts.isStringLiteralLike(node))
66
+ return [node.text];
67
+ const type = checker.getTypeAtLocation(node);
68
+ const parts = type.isUnion() ? type.types : [type];
69
+ const values = [];
70
+ for (const part of parts) {
71
+ if (!part.isStringLiteral())
72
+ return undefined;
73
+ values.push(part.value);
74
+ }
75
+ return values.length ? values : undefined;
76
+ }
77
+ /**
78
+ * Every use, in `files`, of the SDK members named by `apis`
79
+ * (`Interface.member`), and every request sent by name (`Wire.request`),
80
+ * in file and position order. It reads no manifest (the capability scan,
81
+ * `capability-scan.ts`, gives it its lists).
82
+ *
83
+ * `resolved` is `false` when the program has no import of
84
+ * `@vestra-player/sdk` that resolves: nothing can be found by type then.
85
+ *
86
+ * @internal
87
+ */
88
+ export function findMemberUses(ts, program, options) {
89
+ const uses = [];
90
+ const requests = [];
91
+ const members = resolveMembers(ts, program, options.apis);
92
+ const senders = resolveMembers(ts, program, SENDERS);
93
+ const resolved = members.size > 0 || senders.size > 0;
94
+ if (!resolved)
95
+ return { resolved, uses, requests };
96
+ const checker = program.getTypeChecker();
97
+ const apiOf = (table, symbol) => {
98
+ for (const declaration of symbol?.declarations ?? []) {
99
+ const api = table.get(declaration);
100
+ if (api)
101
+ return api;
102
+ }
103
+ return undefined;
104
+ };
105
+ for (const fileName of options.files) {
106
+ const file = program.getSourceFile(fileName);
107
+ if (!file)
108
+ continue;
109
+ const position = (name) => {
110
+ const { line, character } = file.getLineAndCharacterOfPosition(name.getStart(file));
111
+ return { file: file.fileName, line: line + 1, column: character + 1 };
112
+ };
113
+ const seen = (name, symbol) => {
114
+ const api = apiOf(members, symbol);
115
+ if (api)
116
+ uses.push({ ...position(name), api });
117
+ if (!apiOf(senders, symbol))
118
+ return;
119
+ // A direct call with one literal name is a request of that name;
120
+ // anything else (a computed name, the member taken as a value) is a
121
+ // request the scan cannot name.
122
+ const access = name.parent;
123
+ const call = access?.parent;
124
+ const direct = access &&
125
+ (ts.isPropertyAccessExpression(access) ||
126
+ ts.isElementAccessExpression(access)) &&
127
+ call &&
128
+ ts.isCallExpression(call) &&
129
+ call.expression === access
130
+ ? call
131
+ : undefined;
132
+ const values = direct
133
+ ? literalStrings(ts, checker, direct.arguments[0])
134
+ : undefined;
135
+ requests.push({
136
+ ...position(name),
137
+ method: values?.length === 1 ? values[0] : undefined,
138
+ });
139
+ };
140
+ const visit = (node) => {
141
+ if (ts.isPropertyAccessExpression(node))
142
+ seen(node.name, checker.getSymbolAtLocation(node.name));
143
+ else if (ts.isElementAccessExpression(node) &&
144
+ ts.isStringLiteralLike(node.argumentExpression))
145
+ seen(node.argumentExpression, checker.getSymbolAtLocation(node.argumentExpression));
146
+ else if (ts.isBindingElement(node) &&
147
+ ts.isObjectBindingPattern(node.parent)) {
148
+ const name = node.propertyName ?? node.name;
149
+ const text = ts.isIdentifier(name) || ts.isStringLiteralLike(name)
150
+ ? name.text
151
+ : undefined;
152
+ if (text !== undefined)
153
+ seen(name, checker.getTypeAtLocation(node.parent).getProperty(text));
154
+ }
155
+ ts.forEachChild(node, visit);
156
+ };
157
+ visit(file);
158
+ }
159
+ return { resolved, uses, requests };
160
+ }
@@ -11,8 +11,7 @@ export { createPlugin } from "./plugin/index.ts";
11
11
  export type { PluginInstance, PluginManifest, RuntimeOptions, } from "./plugin/index.ts";
12
12
  export { HostError } from "./wire.ts";
13
13
  export type { Json, Transport } from "./wire.ts";
14
- export { API_VERSION, CAPABILITIES, CAPABILITY_INFO, MESSAGE_LIMIT, } from "./capabilities.ts";
15
- export { HOST_CAPABILITIES } from "./host-capabilities.ts";
14
+ export { API_VERSION, MESSAGE_LIMIT } from "./protocol.ts";
16
15
  export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "./commands.ts";
17
16
  export { BINDING_INPUTS } from "./plugin/bindings.ts";
18
17
  export { MEDIA_SOURCE_LIMITS } from "./plugin/media.ts";
@@ -21,6 +20,9 @@ export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from ".
21
20
  export { MPV_LIMITS, MPV_RULES } from "./mpv.ts";
22
21
  export { OSD_LIMITS } from "./plugin/osd.ts";
23
22
  export { TIMELINE_LIMITS } from "./plugin/timeline.ts";
23
+ export { TRIGGER_LIMITS } from "./plugin/triggers.ts";
24
+ export { CONDITION_TABLE } from "./condition-table.ts";
25
+ export { evaluateTruth } from "./plugin/when.ts";
24
26
  export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.ts";
25
27
  export { SUBTITLE_LIMITS } from "./plugin/subtitles.ts";
26
28
  export { VIDEO_PROCESSING_LIMITS } from "./processing.ts";
@@ -9,8 +9,7 @@
9
9
  */
10
10
  export { createPlugin } from "./plugin/index.js";
11
11
  export { HostError } from "./wire.js";
12
- export { API_VERSION, CAPABILITIES, CAPABILITY_INFO, MESSAGE_LIMIT, } from "./capabilities.js";
13
- export { HOST_CAPABILITIES } from "./host-capabilities.js";
12
+ export { API_VERSION, MESSAGE_LIMIT } from "./protocol.js";
14
13
  export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "./commands.js";
15
14
  export { BINDING_INPUTS } from "./plugin/bindings.js";
16
15
  export { MEDIA_SOURCE_LIMITS } from "./plugin/media.js";
@@ -19,6 +18,9 @@ export { COMMAND_RUN_LIMITS, PALETTE_LEAD_LIMITS, PALETTE_LEAD_STATES, } from ".
19
18
  export { MPV_LIMITS, MPV_RULES } from "./mpv.js";
20
19
  export { OSD_LIMITS } from "./plugin/osd.js";
21
20
  export { TIMELINE_LIMITS } from "./plugin/timeline.js";
21
+ export { TRIGGER_LIMITS } from "./plugin/triggers.js";
22
+ export { CONDITION_TABLE } from "./condition-table.js";
23
+ export { evaluateTruth } from "./plugin/when.js";
22
24
  export { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "./plugin/services.js";
23
25
  export { SUBTITLE_LIMITS } from "./plugin/subtitles.js";
24
26
  export { VIDEO_PROCESSING_LIMITS } from "./processing.js";
@@ -5,7 +5,7 @@ import type { Appearance, LanguagePreference, ThemeId } from "./types.ts";
5
5
  export declare const THEMES: readonly ThemeId[];
6
6
  /**
7
7
  * One per plugin: the value comes with the `window.state` read before
8
- * activation; with `events`, `appearance.changed` keeps it current once
8
+ * activation; after `plugin.player.subscribe()`, `appearance.changed` keeps it current once
9
9
  * the plugin uses it (or listens to that event with `player.on`).
10
10
  */
11
11
  declare class AppearanceService {
@@ -1,4 +1,4 @@
1
- /** The player's palette (`plugin.appearance`; `ui.theme` to change it). */
1
+ /** The player's palette (`plugin.appearance`). */
2
2
  import { failure } from "./errors.js";
3
3
  import { windowOf } from "./window.js";
4
4
  import { LOCALES } from "../i18n.js";
@@ -9,7 +9,7 @@ const preference = (value) => value === "system" || LOCALES.includes(value)
9
9
  export const THEMES = ["vestra", "vestra-light"];
10
10
  /**
11
11
  * One per plugin: the value comes with the `window.state` read before
12
- * activation; with `events`, `appearance.changed` keeps it current once
12
+ * activation; after `plugin.player.subscribe()`, `appearance.changed` keeps it current once
13
13
  * the plugin uses it (or listens to that event with `player.on`).
14
14
  */
15
15
  class AppearanceService {
@@ -76,7 +76,7 @@ export declare const BINDING_INPUTS: Readonly<{
76
76
  /** Throws `invalid` unless `text` is a canonical binding; returns it unchanged. */
77
77
  export declare function canonical(text: string): string;
78
78
  export declare function checkBindings(bindings: readonly string[]): string[];
79
- /** `plugin.bindings` (`bindings.manage`): the table and the user overlay. */
79
+ /** `plugin.bindings`: the table and the user overlay. */
80
80
  export declare const bindingsApi: (scope: ScopeImpl) => Bindings;
81
81
  /**
82
82
  * How the player's menus write a canonical binding (`bindings.rs`
@@ -177,7 +177,7 @@ const reference = (ref) => {
177
177
  throw failure("invalid", "a binding ref names plugin and command");
178
178
  return { plugin: ref.plugin, command: ref.command };
179
179
  };
180
- /** `plugin.bindings` (`bindings.manage`): the table and the user overlay. */
180
+ /** `plugin.bindings`: the table and the user overlay. */
181
181
  export const bindingsApi = (scope) => ({
182
182
  async list() {
183
183
  const table = await scope.runtime.host.bindings.list();
@@ -209,7 +209,7 @@ export const bindingsApi = (scope) => ({
209
209
  await scope.runtime.host.bindings.reset(ref === undefined ? undefined : reference(ref));
210
210
  },
211
211
  onChange(listener) {
212
- const watch = scope.runtime.on("bindings.changed", () => scope.run(listener), "bindings.manage");
212
+ const watch = scope.runtime.on("bindings.changed", () => scope.run(listener), null);
213
213
  return scope.add({
214
214
  dispose: async () => {
215
215
  scope.forget(watch);
@@ -304,10 +304,7 @@ class KeysService {
304
304
  return;
305
305
  this.#started = true;
306
306
  const runtime = this.#runtime;
307
- // Without `commands` the plugin has no commands: every read is [].
308
- if (!runtime.can("commands"))
309
- return;
310
- runtime.on(KEYS, (data) => this.#accept(data), "commands", true);
307
+ runtime.on(KEYS, (data) => this.#accept(data), null, true);
311
308
  // Subscribed first: a change after this answer comes as an event.
312
309
  runtime.host.commands.keys().then((answer) => this.#accept(answer),
313
310
  // `unsupported`: no keys, as without a binding.
@@ -359,11 +356,9 @@ export const commands = (scope) => ({
359
356
  return service.get(id);
360
357
  },
361
358
  list: async () => {
362
- needs(scope, "commands.run");
363
359
  return scope.runtime.host.commands.list();
364
360
  },
365
361
  async run(id, options) {
366
- needs(scope, "commands.run");
367
362
  if (typeof id !== "string" || id === "")
368
363
  throw failure("invalid", "run takes a command id: <plugin>/<id>");
369
364
  const { ticket, step, of, then } = (options ?? {});
@@ -394,11 +389,6 @@ export const commands = (scope) => ({
394
389
  });
395
390
  },
396
391
  });
397
- /** Refuse at once without `capability`, as the player does. */
398
- function needs(scope, capability) {
399
- if (!scope.runtime.can(capability))
400
- throw failure("capability", `${capability} must be declared in manifest`);
401
- }
402
392
  // ---------------------------------------------------------------- palette lead
403
393
  /** `PaletteLeadOptions` checked and in wire form; the player checks lengths. */
404
394
  function leadJson(options) {
@@ -441,7 +431,6 @@ class LeadHandle {
441
431
  #event;
442
432
  #disposed = false;
443
433
  constructor(scope, options) {
444
- needs(scope, "palette.lead");
445
434
  const first = leadJson(options);
446
435
  this.#scope = scope;
447
436
  const host = scope.runtime.host.palette;
@@ -9,12 +9,18 @@ export type Why = () => string;
9
9
  /**
10
10
  * Events the player wakes a stopped plugin for: a listener of one does not keep
11
11
  * the plugin running. They follow deliberate changes (an install, a key edit,
12
- * the palette, a resolver), not playback.
12
+ * the palette, a resolver), not playback, or report one thing that happened
13
+ * to a source (it opened, became ready, ended), never its stream of states.
13
14
  */
14
15
  export declare const WAKE_EVENTS: readonly string[];
16
+ /**
17
+ * What the runtime reads of the plugin's manifest: its id. Nothing in the
18
+ * manifest switches behaviour (1.9.0): event delivery and the start-up
19
+ * reads are the plugin's explicit calls (`plugin.player.subscribe()`,
20
+ * `plugin.player.read()`).
21
+ */
15
22
  export interface PluginManifest {
16
23
  id: string;
17
- capabilities: string[];
18
24
  }
19
25
  /** How the plugin is run: the player's runner, or `TestHost`. */
20
26
  export interface RuntimeOptions {
@@ -63,6 +69,11 @@ export declare class Connection {
63
69
  * `REQUEST_LIMITS` in flight, the rest wait in order (`request-queue.ts`).
64
70
  */
65
71
  readonly requests: RequestQueue;
72
+ /**
73
+ * The player's state is read again after the plugin's own actions:
74
+ * `plugin.player.read()` was called.
75
+ */
76
+ reads: boolean;
66
77
  readonly views: Map<string, (callback: string, args: Json[]) => void>;
67
78
  readonly commands: Map<string, () => void>;
68
79
  /**
@@ -104,7 +115,14 @@ export declare class Connection {
104
115
  */
105
116
  readonly features: ReadonlySet<string>;
106
117
  constructor(transport: Transport, manifest: PluginManifest, directory: string, dataDirectory?: string, app?: unknown, options?: RuntimeOptions);
107
- can(capability: string): boolean;
118
+ /** Event delivery is on (`plugin.player.subscribe()` was called). */
119
+ get delivering(): boolean;
120
+ /**
121
+ * Turn event delivery on (`plugin.player.subscribe()`): every later
122
+ * listener is subscribed, and so is what was added before and heard
123
+ * nothing. Idempotent.
124
+ */
125
+ deliver(): void;
108
126
  /** Read the state copy kept by `event` again, if one exists; never rejects. */
109
127
  reread(event: string): Promise<void>;
110
128
  /** Lazily created singletons shared by every scope of this plugin. */
@@ -133,19 +151,31 @@ export declare class Connection {
133
151
  callSite(): () => string | undefined;
134
152
  /**
135
153
  * Host events with one `events.subscribe` per name, however many listeners.
136
- * Without the `events` capability the listener simply never fires.
154
+ * An event that needs delivery (`"events"`) is subscribed only once
155
+ * `plugin.player.subscribe()` was called; until then its listener simply
156
+ * never fires.
137
157
  * `mirror`: the SDK's own copy of the state (`plugin.player.state` and
138
158
  * the like), not a listener of the plugin's (see {@link EventGroup}).
139
159
  */
140
160
  on(event: string, listener: Listener,
141
- /** The capability the event needs; `null`: none. */
142
- needs?: string | null, mirror?: boolean): Disposable;
161
+ /** `"events"`: it arrives after `plugin.player.subscribe()`; `null`: always. */
162
+ needs?: "events" | null, mirror?: boolean): Disposable;
143
163
  /**
144
164
  * Count `event` as listened to while held: a watcher of a service's
145
165
  * state, a binding that reads it. Nothing when nothing subscribed to it
146
- * (no capability, or the service did not start).
166
+ * (no `plugin.player.subscribe()`, or the service did not start).
147
167
  */
148
168
  hold(event: string, why?: Why): Disposable;
169
+ /**
170
+ * Hear `event` while followed, whether or not event delivery is on, and
171
+ * count it as listened to (`plugin.player.stream`, SDK 1.10.0): the group
172
+ * the caller started (a state copy's) is subscribed now if it waited for
173
+ * `plugin.player.subscribe()`, and only it. When the last follower ends,
174
+ * such a group waits again as before: its subscription at the player
175
+ * ends, and the copy stays as it was. Nothing when nothing started the
176
+ * group.
177
+ */
178
+ follow(event: string, why?: Why): Disposable;
149
179
  /**
150
180
  * Why the plugin listens to each event it really listens to (mirrors
151
181
  * left out), as the player's log says it: for {@link TestHost} and
@@ -154,7 +184,7 @@ export declare class Connection {
154
184
  listening(): Map<string, string[]>;
155
185
  /**
156
186
  * One request by its method name, as given (`plugin.wire.request`): nothing
157
- * added, nothing checked here, the player checks the capability. Every other
187
+ * added, nothing checked here; the player checks the request. Every other
158
188
  * part of the SDK uses the typed clients (`host`); `scripts/check-layers.mjs`
159
189
  * keeps it so. It waits in the request queue like every other.
160
190
  */