@vestra-player/sdk 1.7.20 → 1.9.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 (96) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +2 -2
  3. package/bin/vestra-plugin.mjs +139 -100
  4. package/capability-scan.json +369 -0
  5. package/dist/api-requests.d.ts +11 -36
  6. package/dist/api-requests.js +22 -47
  7. package/dist/capability-scan.d.ts +95 -0
  8. package/dist/capability-scan.js +249 -0
  9. package/dist/commands.d.ts +35 -0
  10. package/dist/commands.js +42 -1
  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/index.d.ts +4 -5
  15. package/dist/manifest.d.ts +5 -0
  16. package/dist/manifest.js +9 -24
  17. package/dist/member-uses.d.ts +61 -0
  18. package/dist/member-uses.js +160 -0
  19. package/dist/mpv.d.ts +139 -0
  20. package/dist/mpv.js +496 -0
  21. package/dist/player-runtime.d.ts +3 -3
  22. package/dist/player-runtime.js +3 -3
  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 +6 -14
  28. package/dist/plugin/connection.d.ts +26 -7
  29. package/dist/plugin/connection.js +68 -36
  30. package/dist/plugin/drops.js +1 -1
  31. package/dist/plugin/index.js +9 -15
  32. package/dist/plugin/media.js +0 -12
  33. package/dist/plugin/mpv.d.ts +3 -0
  34. package/dist/plugin/mpv.js +91 -0
  35. package/dist/plugin/packages.js +1 -2
  36. package/dist/plugin/player/events.d.ts +4 -3
  37. package/dist/plugin/player/events.js +7 -6
  38. package/dist/plugin/player.d.ts +21 -13
  39. package/dist/plugin/player.js +56 -21
  40. package/dist/plugin/scope.d.ts +1 -0
  41. package/dist/plugin/scope.js +2 -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 +43 -24
  50. package/dist/plugin/testing/index.d.ts +75 -114
  51. package/dist/plugin/testing/index.js +83 -102
  52. package/dist/plugin/testing/mpv.d.ts +7 -0
  53. package/dist/plugin/testing/mpv.js +90 -0
  54. package/dist/plugin/testing/processing.js +1 -1
  55. package/dist/plugin/testing/services.js +0 -1
  56. package/dist/plugin/timeline.d.ts +2 -3
  57. package/dist/plugin/timeline.js +4 -8
  58. package/dist/plugin/types/base.d.ts +49 -88
  59. package/dist/plugin/types/commands.d.ts +44 -77
  60. package/dist/plugin/types/packages.d.ts +17 -55
  61. package/dist/plugin/types/playback.d.ts +302 -135
  62. package/dist/plugin/types/plugin-wire.d.ts +6 -36
  63. package/dist/plugin/types/processing.d.ts +10 -49
  64. package/dist/plugin/types/services.d.ts +11 -70
  65. package/dist/plugin/types/snapshots.d.ts +7 -60
  66. package/dist/plugin/types/sources.d.ts +2 -11
  67. package/dist/plugin/types/subtitles.d.ts +5 -26
  68. package/dist/plugin/types/ui-content.d.ts +1 -16
  69. package/dist/plugin/types/ui-layout.d.ts +53 -79
  70. package/dist/plugin/types/ui-locale.d.ts +5 -23
  71. package/dist/plugin/types/ui-shell.d.ts +13 -59
  72. package/dist/plugin/view/layout.js +1 -1
  73. package/dist/plugin/view.js +0 -2
  74. package/dist/plugin/window.d.ts +1 -1
  75. package/dist/plugin/window.js +1 -1
  76. package/dist/plugin/wire-facade.js +1 -2
  77. package/dist/processing.d.ts +2 -3
  78. package/dist/protocol.d.ts +14 -0
  79. package/dist/protocol.js +14 -0
  80. package/dist/request-queue.js +1 -1
  81. package/dist/subtitles.d.ts +1 -1
  82. package/dist/ts-plugin.d.ts +8 -15
  83. package/dist/ts-plugin.js +3 -141
  84. package/dist/wire.d.ts +22 -12
  85. package/dist/wire.js +17 -8
  86. package/llms.txt +5 -5
  87. package/package.json +4 -3
  88. package/slint/vestra/widgets.slint +12 -4
  89. package/dist/capabilities.d.ts +0 -107
  90. package/dist/capabilities.js +0 -69
  91. package/dist/capability-check.d.ts +0 -133
  92. package/dist/capability-check.js +0 -371
  93. package/dist/capability-rules.d.ts +0 -125
  94. package/dist/capability-rules.js +0 -192
  95. package/dist/host-capabilities.d.ts +0 -10
  96. package/dist/host-capabilities.js +0 -477
@@ -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
+ }
package/dist/mpv.d.ts ADDED
@@ -0,0 +1,139 @@
1
+ /**
2
+ * The mpv pass-through's rules, as data: what `plugin.mpv` may not send, by
3
+ * category, and its limits. The player applies the same table (its
4
+ * agreement test compares them); the SDK refuses early with it and
5
+ * `TestHost` models it.
6
+ *
7
+ * The channel is the SDK's contract; the command and property names and
8
+ * what they do are mpv's (https://mpv.io/manual/stable/#list-of-input-commands,
9
+ * https://mpv.io/manual/stable/#properties, https://mpv.io/manual/stable/#options).
10
+ */
11
+ /**
12
+ * Why `plugin.mpv` refuses a command or a property: the boundary it would
13
+ * cross. A key of `MPV_RULES.categories`.
14
+ *
15
+ * @internal
16
+ */
17
+ export type MpvRefusalCategory = "process" | "code" | "clients" | "files" | "quit" | "input" | "clipboard" | "managed" | "filters";
18
+ /**
19
+ * The limits of `plugin.mpv`, the same values as the player's (its
20
+ * agreement test checks that they agree). Internal: exported from
21
+ * `@vestra-player/sdk/runtime` only; [mpv](../docs/reference/mpv.md) shows
22
+ * them.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare const MPV_LIMITS: Readonly<{
27
+ /** Elements of one command, its name included (32). */
28
+ args: 32;
29
+ /** Characters of a command or property name (128). */
30
+ nameChars: 128;
31
+ /** Characters of a filter label, after the `@` (64). */
32
+ labelChars: 64;
33
+ /** Different properties one plugin observes at the same time (64). */
34
+ observed: 64;
35
+ /** A property's changes reach an observer at most this often; the newest value wins (100 ms). */
36
+ observeIntervalMs: 100;
37
+ }>;
38
+ /**
39
+ * What `plugin.mpv` refuses, as data: the same table as the player's. A
40
+ * command or property not named here goes to mpv as it is.
41
+ *
42
+ * - `categories`: one sentence per category, the end of the refusal's
43
+ * message.
44
+ * - `commands`: mpv commands by name.
45
+ * - `properties`: mpv properties and options by name (the part before the
46
+ * first `/`, after an `options/` or `file-local-options/` prefix);
47
+ * `propertyPrefixes`: by the start of the name, checked after
48
+ * `properties`. A write is refused; a read too for the categories of
49
+ * `reads`.
50
+ * - `writers`: commands that write the property their first argument
51
+ * names (`cycle-values` after an optional `!reverse`); they are checked
52
+ * as a write of it.
53
+ * - `filterCommands`: the filter chain commands and the operations a
54
+ * plugin may use, on its own labelled filters only; `filterMessages`:
55
+ * commands whose first argument is a filter label, which must be the
56
+ * plugin's own; `reservedLabel`: the start of the player's own labels;
57
+ * `reservedLabels`: whole labels that are not a plugin's (`all`, which
58
+ * mpv reads as every filter of the chain).
59
+ *
60
+ * - `prefixes`: mpv's command prefix words (mpv 0.41 `input/cmd.c`,
61
+ * `cmd_flags`, in its order). mpv takes them off the front of a
62
+ * command, in the array form too, and runs what follows: a command whose
63
+ * first element is one is `invalid`, so the name the tables check is
64
+ * the command mpv runs. Only the first element: later, the same words
65
+ * are ordinary arguments.
66
+ *
67
+ * A command's name is looked up with `_` read as `-`, as mpv reads it
68
+ * (`cycle_values` is `cycle-values`); a refusal names it as the caller
69
+ * wrote it. A property's name is looked up as written: mpv does not fold
70
+ * it.
71
+ *
72
+ * Internal: exported from `@vestra-player/sdk/runtime` only; the tables of
73
+ * [mpv](../docs/reference/mpv.md) are generated from it.
74
+ *
75
+ * @internal
76
+ */
77
+ export declare const MPV_RULES: {
78
+ readonly categories: Readonly<Record<MpvRefusalCategory, string>>;
79
+ readonly commands: Readonly<Record<string, MpvRefusalCategory>>;
80
+ readonly properties: Readonly<Record<string, MpvRefusalCategory>>;
81
+ readonly propertyPrefixes: Readonly<Record<string, MpvRefusalCategory>>;
82
+ readonly reads: readonly MpvRefusalCategory[];
83
+ readonly writers: readonly string[];
84
+ readonly filterCommands: Readonly<Record<string, readonly string[]>>;
85
+ readonly filterMessages: readonly string[];
86
+ readonly reservedLabel: string;
87
+ readonly reservedLabels: readonly string[];
88
+ readonly prefixes: readonly string[];
89
+ };
90
+ /**
91
+ * What is wrong with a property name, as the player words it (`invalid`);
92
+ * `null` when nothing is.
93
+ *
94
+ * @internal
95
+ */
96
+ export declare function mpvNameProblem(name: unknown): string | null;
97
+ /**
98
+ * What is wrong with a command's shape, as the player words it (`invalid`);
99
+ * `null` when nothing is. The first element is the command's name, the
100
+ * others its arguments: strings, numbers or booleans.
101
+ *
102
+ * @internal
103
+ */
104
+ export declare function mpvCommandProblem(args: unknown): string | null;
105
+ /**
106
+ * Why the pass-through refuses a property (`refused`), as the player words
107
+ * it; `null` when it does not.
108
+ *
109
+ * @param name - The property, as given.
110
+ * @param write - A write (`set`); a read is refused only for the
111
+ * categories of `MPV_RULES.reads`.
112
+ *
113
+ * @internal
114
+ */
115
+ export declare function mpvPropertyRefusal(name: string, write: boolean): string | null;
116
+ /**
117
+ * Why the pass-through refuses a command (`refused`), as the player words
118
+ * it; `null` when it does not. The command's shape is checked first
119
+ * ({@link mpvCommandProblem}).
120
+ *
121
+ * What only the player can tell is left to it: whether a label belongs to
122
+ * another plugin, and whether a filter value holds more than the one
123
+ * labelled filter (it compares the chain before and after).
124
+ *
125
+ * @internal
126
+ */
127
+ export declare function mpvCommandRefusal(args: readonly (string | number | boolean)[]): string | null;
128
+ /**
129
+ * The label a filter command adds or removes, for the owner's book:
130
+ * `["vf", "add", "@smooth:…"]` → `{ stage: "vf", operation: "add", label:
131
+ * "smooth" }`; `null` for any other command.
132
+ *
133
+ * @internal
134
+ */
135
+ export declare function mpvFilterChange(args: readonly (string | number | boolean)[]): {
136
+ stage: string;
137
+ operation: string;
138
+ label: string;
139
+ } | null;