@vestra-player/sdk 1.6.22 → 1.7.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.
- package/CHANGELOG.md +47 -0
- package/bin/vestra-plugin.mjs +34 -12
- package/dist/api-requests.d.ts +22 -0
- package/dist/api-requests.js +38 -0
- package/dist/capability-check.d.ts +48 -0
- package/dist/capability-check.js +219 -51
- package/dist/capability-rules.d.ts +21 -0
- package/dist/capability-rules.js +32 -1
- package/dist/commands.d.ts +8 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/plugin/commands.js +43 -13
- package/dist/plugin/connection.d.ts +37 -0
- package/dist/plugin/connection.js +34 -0
- package/dist/plugin/index.js +12 -2
- package/dist/plugin/media.js +3 -1
- package/dist/plugin/packages.js +3 -1
- package/dist/plugin/passes.d.ts +38 -1
- package/dist/plugin/passes.js +89 -5
- package/dist/plugin/player/events.d.ts +9 -0
- package/dist/plugin/player/events.js +43 -0
- package/dist/plugin/player/rules.d.ts +7 -0
- package/dist/plugin/player/rules.js +11 -0
- package/dist/plugin/player.d.ts +37 -4
- package/dist/plugin/player.js +85 -12
- package/dist/plugin/resolvers.js +2 -3
- package/dist/plugin/runtime.d.ts +2 -3
- package/dist/plugin/runtime.js +8 -2
- package/dist/plugin/scope.d.ts +9 -0
- package/dist/plugin/scope.js +24 -0
- package/dist/plugin/services.js +4 -5
- package/dist/plugin/state.d.ts +3 -0
- package/dist/plugin/state.js +81 -0
- package/dist/plugin/stream.d.ts +27 -3
- package/dist/plugin/testing/core-actions.js +1 -1
- package/dist/plugin/testing/services.js +1 -1
- package/dist/plugin/types/base.d.ts +78 -2
- package/dist/plugin/types/commands.d.ts +17 -1
- package/dist/plugin/types/playback.d.ts +156 -1
- package/dist/plugin/types/plugin-wire.d.ts +589 -0
- package/dist/plugin/types/plugin-wire.js +1 -0
- package/dist/plugin/types/ui-content.d.ts +23 -4
- package/dist/plugin/types/ui-shell.d.ts +1 -0
- package/dist/plugin/types.d.ts +4 -2
- package/dist/plugin/view/base.d.ts +10 -3
- package/dist/plugin/view/base.js +30 -6
- package/dist/plugin/view/binder.js +8 -1
- package/dist/plugin/view/writer.d.ts +49 -4
- package/dist/plugin/view/writer.js +383 -17
- package/dist/plugin/wire-facade.d.ts +4 -0
- package/dist/plugin/wire-facade.js +190 -0
- package/dist/ts-plugin.d.ts +3 -0
- package/dist/ts-plugin.js +18 -6
- package/dist/wire.d.ts +233 -20
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/slint/vestra/focus.slint +33 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Json, PropertyWrite } from "../../wire.ts";
|
|
2
2
|
import type { ScopeImpl } from "../scope.ts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PropValue, Props, View } from "../types.ts";
|
|
4
|
+
import { DIRECT } from "./writer.ts";
|
|
5
|
+
import type { DirectWrites } from "./writer.ts";
|
|
4
6
|
/** Property and callback plumbing shared by windows, panels and settings pages. */
|
|
5
7
|
export declare abstract class ViewBase implements View {
|
|
6
8
|
#private;
|
|
@@ -12,9 +14,14 @@ export declare abstract class ViewBase implements View {
|
|
|
12
14
|
protected abstract write(property: string, write: PropertyWrite): Promise<void>;
|
|
13
15
|
/** {@link ViewWriter.wired}: initial properties in wire form. */
|
|
14
16
|
protected wired(values: Record<string, PropValue>, refuse?: boolean): Record<string, Json>;
|
|
15
|
-
on<A extends Json[]>(callback: string, handler: (...args: A) => unknown): Disposable;
|
|
17
|
+
on<A extends Json[]>(callback: string, handler: (...args: A) => unknown): import("../types.ts").Disposable;
|
|
16
18
|
set(props: Props): void;
|
|
17
|
-
bind(props: () => Props): Disposable;
|
|
19
|
+
bind(props: () => Props): import("../types.ts").Disposable;
|
|
20
|
+
/**
|
|
21
|
+
* `plugin.wire.view(v)` (SDK 1.7.0): the writer's direct writes, for a
|
|
22
|
+
* scope of the plugin that made this view.
|
|
23
|
+
*/
|
|
24
|
+
[DIRECT](scope: ScopeImpl): DirectWrites;
|
|
18
25
|
/** {@link ViewBinder.snapshot}: current desired properties. */
|
|
19
26
|
protected snapshot(): Record<string, PropValue>;
|
|
20
27
|
protected evaluate(): void;
|
package/dist/plugin/view/base.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ViewBase`: what windows, panels and settings pages share — callbacks, and
|
|
3
|
-
* a {@link ViewWriter} (L1) with a {@link ViewBinder} (L2) over it.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* a {@link ViewWriter} (L1) with a {@link ViewBinder} (L2) over it. A view
|
|
4
|
+
* joins the update passes on its first `bind()` (SDK 1.7.0,
|
|
5
|
+
* doc/specs/sdk-refactor.md §4 Step 2 in the player repository); until
|
|
6
|
+
* then `set()` goes straight to the writer, which sends whole values and
|
|
7
|
+
* keeps no row-patch bases for it.
|
|
6
8
|
*/
|
|
7
9
|
import { readFileSync } from "node:fs";
|
|
8
10
|
import { resolve } from "node:path";
|
|
11
|
+
import { failure } from "../errors.js";
|
|
9
12
|
import { PATCH_FEATURE } from "../patch.js";
|
|
10
13
|
import { ViewBinder } from "./binder.js";
|
|
11
|
-
import { kebab, ViewWriter } from "./writer.js";
|
|
14
|
+
import { DIRECT, kebab, ViewWriter } from "./writer.js";
|
|
12
15
|
/** Property and callback plumbing shared by windows, panels and settings pages. */
|
|
13
16
|
export class ViewBase {
|
|
14
17
|
scope;
|
|
15
18
|
handlers = new Map();
|
|
16
19
|
#writer;
|
|
17
20
|
#binder;
|
|
21
|
+
/** Its place in the update passes, from the first `bind()` on. */
|
|
18
22
|
#binding;
|
|
23
|
+
/** Its place in the order of evaluation, kept from when it was made. */
|
|
24
|
+
#slot;
|
|
19
25
|
closed = false;
|
|
20
26
|
constructor(scope) {
|
|
21
27
|
this.scope = scope;
|
|
@@ -26,7 +32,7 @@ export class ViewBase {
|
|
|
26
32
|
patches: () => this.scope.runtime.features.has(PATCH_FEATURE),
|
|
27
33
|
});
|
|
28
34
|
this.#binder = new ViewBinder(scope, this.#writer, () => this.closed);
|
|
29
|
-
this.#
|
|
35
|
+
this.#slot = scope.runtime.passes.slot();
|
|
30
36
|
}
|
|
31
37
|
/** {@link ViewWriter.wired}: initial properties in wire form. */
|
|
32
38
|
wired(values, refuse = false) {
|
|
@@ -44,8 +50,26 @@ export class ViewBase {
|
|
|
44
50
|
this.#writer.set(props);
|
|
45
51
|
}
|
|
46
52
|
bind(props) {
|
|
53
|
+
if (!this.#binding && !this.closed) {
|
|
54
|
+
// The first bind: the view takes part in the update passes, and its
|
|
55
|
+
// writer compares and patches from now on.
|
|
56
|
+
this.#writer.track();
|
|
57
|
+
this.#binding = this.scope.runtime.bind(() => this.evaluate(), this.#slot);
|
|
58
|
+
}
|
|
47
59
|
return this.#binder.bind(props);
|
|
48
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* `plugin.wire.view(v)` (SDK 1.7.0): the writer's direct writes, for a
|
|
63
|
+
* scope of the plugin that made this view.
|
|
64
|
+
*/
|
|
65
|
+
[DIRECT](scope) {
|
|
66
|
+
if (scope.runtime !== this.scope.runtime)
|
|
67
|
+
throw failure("invalid", "view takes a window, panel or settings page of this plugin");
|
|
68
|
+
return {
|
|
69
|
+
write: (property, write) => this.#writer.direct(property, write),
|
|
70
|
+
writeRows: (property, ops) => this.#writer.directRows(property, ops),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
49
73
|
/** {@link ViewBinder.snapshot}: current desired properties. */
|
|
50
74
|
snapshot() {
|
|
51
75
|
return this.#binder.snapshot();
|
|
@@ -73,7 +97,7 @@ export class ViewBase {
|
|
|
73
97
|
async release() {
|
|
74
98
|
this.closed = true;
|
|
75
99
|
this.#writer.stop();
|
|
76
|
-
await this.#binding
|
|
100
|
+
await this.#binding?.dispose();
|
|
77
101
|
}
|
|
78
102
|
}
|
|
79
103
|
/** Find `export component X` / `export global Y` so most mounts need no names. */
|
|
@@ -39,7 +39,14 @@ export class ViewBinder {
|
|
|
39
39
|
if (!result)
|
|
40
40
|
continue;
|
|
41
41
|
for (const [key, value] of Object.entries(result.value))
|
|
42
|
-
|
|
42
|
+
try {
|
|
43
|
+
this.#writer.assign(key, value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// A property written directly (`plugin.wire.view`): reported
|
|
47
|
+
// once, the binding's other values still count.
|
|
48
|
+
this.#scope.report(error);
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
catch (error) {
|
|
45
52
|
this.#scope.report(error);
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import type { Json, PropertyWrite } from "../../wire.ts";
|
|
1
|
+
import type { Json, PropertyWrite, RowOp } from "../../wire.ts";
|
|
2
2
|
import type { PropValue, Props } from "../types.ts";
|
|
3
3
|
/** Slint names are kebab-case; plugin code may use camelCase. */
|
|
4
4
|
export declare const kebab: (name: string) => string;
|
|
5
5
|
export declare const encode: (props: Props) => {
|
|
6
6
|
[k: string]: PropValue;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* How `plugin.wire.view(v)` (`wire-facade.ts`) reaches a view's writer
|
|
10
|
+
* without importing the view classes (which load the binder): a view
|
|
11
|
+
* answers this key with its {@link DirectWrites}, given a scope of the
|
|
12
|
+
* plugin that made it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DIRECT: unique symbol;
|
|
15
|
+
/** A view's direct writes, as `plugin.wire.view(v)` hands them out. */
|
|
16
|
+
export interface DirectWrites {
|
|
17
|
+
write(property: string, write: PropertyWrite): Promise<boolean>;
|
|
18
|
+
writeRows(property: string, ops: readonly RowOp[]): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
/** The message of a write on the other track of a property. */
|
|
21
|
+
export declare const bothTracks: (property: string, written: boolean) => string;
|
|
8
22
|
/** Where a {@link ViewWriter}'s writes go, and what it asks of its view. */
|
|
9
23
|
export interface WriterTarget {
|
|
10
24
|
/** The view shows its properties: writes may be sent. */
|
|
@@ -23,6 +37,12 @@ export interface WriterTarget {
|
|
|
23
37
|
export declare class ViewWriter {
|
|
24
38
|
#private;
|
|
25
39
|
constructor(target: WriterTarget);
|
|
40
|
+
/**
|
|
41
|
+
* The view's first `bind()`: compare and patch from now on. What was
|
|
42
|
+
* sent before is known as whole values, so the first patchable write of
|
|
43
|
+
* an array goes whole and patches follow it.
|
|
44
|
+
*/
|
|
45
|
+
track(): void;
|
|
26
46
|
/**
|
|
27
47
|
* Initial properties in wire form. A released image is left out (the
|
|
28
48
|
* property keeps its default) and reported, like a failed write. With a
|
|
@@ -34,10 +54,35 @@ export declare class ViewWriter {
|
|
|
34
54
|
* with `refuse` (a window's `show`), thrown.
|
|
35
55
|
*/
|
|
36
56
|
wired(values: Record<string, PropValue>, refuse?: boolean): Record<string, Json>;
|
|
37
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* `View.set`: each value is sent once even if equal to what was sent. A
|
|
59
|
+
* property written directly is refused (`invalid`), before anything is
|
|
60
|
+
* kept.
|
|
61
|
+
*/
|
|
38
62
|
set(props: Props): void;
|
|
39
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* A bound value (Slint name): sent by the next flush if it changed. A
|
|
65
|
+
* property written directly is refused (`invalid`, the first time; the
|
|
66
|
+
* binder reports it) and the value is never kept.
|
|
67
|
+
*/
|
|
40
68
|
assign(key: string, value: PropValue): void;
|
|
69
|
+
/**
|
|
70
|
+
* `plugin.wire.view(v).write`: one property's `PropertyWrite`, sent as
|
|
71
|
+
* given after the property's earlier direct writes (a whole value drops
|
|
72
|
+
* those still waiting, which resolve `false`). With a player that takes
|
|
73
|
+
* row patches, a whole value without `seq` gets one, so that row
|
|
74
|
+
* operations can follow it, and an array larger than one request goes in
|
|
75
|
+
* parts (`more`). The property is marked: `set()` and `bind()` refuse it
|
|
76
|
+
* from now on. Rejects with `unavailable` while the view does not show.
|
|
77
|
+
*/
|
|
78
|
+
direct(property: string, write: PropertyWrite): Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* `plugin.wire.view(v).writeRows`: row operations on the property's last
|
|
81
|
+
* direct write (or on its initial value), in as many patches as one
|
|
82
|
+
* request carries, each applying on the one before. Needs a player that
|
|
83
|
+
* takes row patches (`unsupported` otherwise).
|
|
84
|
+
*/
|
|
85
|
+
directRows(property: string, ops: readonly RowOp[]): Promise<boolean>;
|
|
41
86
|
/** Every property's value now, by Slint name. */
|
|
42
87
|
values(): Record<string, PropValue>;
|
|
43
88
|
/** The host already shows these values (e.g. sent as initial properties). */
|
|
@@ -53,6 +98,6 @@ export declare class ViewWriter {
|
|
|
53
98
|
* a broken view cannot spin.
|
|
54
99
|
*/
|
|
55
100
|
flush(): void;
|
|
56
|
-
/** The view closed: no retry after a back-off. */
|
|
101
|
+
/** The view closed: no retry after a back-off, no direct write waiting. */
|
|
57
102
|
stop(): void;
|
|
58
103
|
}
|