@vestra-player/sdk 1.7.1 → 1.7.3
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 +20 -0
- package/README.md +6 -9
- package/bin/vestra-plugin.mjs +4 -4
- package/dist/api-requests.d.ts +8 -8
- package/dist/api-requests.js +8 -8
- package/dist/capability-check.d.ts +15 -15
- package/dist/capability-check.js +4 -4
- package/dist/capability-rules.d.ts +4 -5
- package/dist/capability-rules.js +4 -5
- package/dist/commands.d.ts +34 -44
- package/dist/commands.js +21 -27
- package/dist/docs-tree.json.gz +0 -0
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +13 -3
- package/dist/i18n-tools.js +1 -1
- package/dist/i18n.js +1 -1
- package/dist/media.d.ts +7 -7
- package/dist/palettes.d.ts +5 -5
- package/dist/palettes.js +5 -5
- package/dist/plugin/appearance.js +1 -1
- package/dist/plugin/bindings.d.ts +2 -3
- package/dist/plugin/bindings.js +2 -3
- package/dist/plugin/commands.js +10 -11
- package/dist/plugin/connection.d.ts +18 -19
- package/dist/plugin/connection.js +23 -24
- package/dist/plugin/index.d.ts +5 -5
- package/dist/plugin/index.js +1 -1
- package/dist/plugin/osd.d.ts +1 -1
- package/dist/plugin/osd.js +1 -1
- package/dist/plugin/passes.d.ts +4 -4
- package/dist/plugin/passes.js +4 -4
- package/dist/plugin/patch.d.ts +8 -8
- package/dist/plugin/patch.js +12 -12
- package/dist/plugin/player/events.js +5 -5
- package/dist/plugin/resolvers.js +3 -3
- package/dist/plugin/scope.d.ts +4 -4
- package/dist/plugin/scope.js +4 -4
- package/dist/plugin/services.d.ts +2 -3
- package/dist/plugin/services.js +2 -3
- package/dist/plugin/shaders.js +5 -6
- package/dist/plugin/state.js +10 -10
- package/dist/plugin/testing/commands.d.ts +4 -5
- package/dist/plugin/testing/commands.js +4 -5
- package/dist/plugin/testing/i18n.d.ts +1 -1
- package/dist/plugin/testing/i18n.js +1 -1
- package/dist/plugin/testing/index.d.ts +147 -165
- package/dist/plugin/testing/index.js +141 -155
- package/dist/plugin/testing/internals.d.ts +9 -2
- package/dist/plugin/testing/internals.js +9 -2
- package/dist/plugin/testing/layout.d.ts +46 -3
- package/dist/plugin/testing/layout.js +102 -7
- package/dist/plugin/testing/services.js +10 -2
- package/dist/plugin/testing/slint-types.d.ts +75 -0
- package/dist/plugin/testing/slint-types.js +974 -0
- package/dist/plugin/timeline.d.ts +1 -1
- package/dist/plugin/timeline.js +2 -2
- package/dist/plugin/types/base.d.ts +90 -111
- package/dist/plugin/types/commands.d.ts +142 -174
- package/dist/plugin/types/packages.d.ts +48 -63
- package/dist/plugin/types/playback.d.ts +45 -59
- package/dist/plugin/types/plugin-wire.d.ts +38 -45
- package/dist/plugin/types/processing.d.ts +52 -65
- package/dist/plugin/types/services.d.ts +18 -25
- package/dist/plugin/types/snapshots.d.ts +34 -46
- package/dist/plugin/types/sources.d.ts +14 -16
- package/dist/plugin/types/subtitles.d.ts +7 -8
- package/dist/plugin/types/ui-content.d.ts +111 -116
- package/dist/plugin/types/ui-layout.d.ts +52 -63
- package/dist/plugin/types/ui-locale.d.ts +41 -45
- package/dist/plugin/types/ui-shell.d.ts +69 -87
- package/dist/plugin/values.d.ts +15 -18
- package/dist/plugin/values.js +16 -19
- package/dist/plugin/view/base.d.ts +2 -2
- package/dist/plugin/view/base.js +7 -8
- package/dist/plugin/view/layout.d.ts +2 -2
- package/dist/plugin/view/panel.js +2 -4
- package/dist/plugin/view/writer.d.ts +8 -8
- package/dist/plugin/view/writer.js +37 -39
- package/dist/plugin/when.d.ts +3 -3
- package/dist/plugin/wire-facade.js +6 -7
- package/dist/processing.d.ts +26 -30
- package/dist/processing.js +4 -4
- package/dist/source-resolvers.d.ts +2 -2
- package/dist/source.d.ts +1 -2
- package/dist/subtitles.d.ts +1 -1
- package/dist/ts-plugin.d.ts +5 -5
- package/dist/wire.d.ts +63 -70
- package/dist/wire.js +21 -25
- package/llms.txt +7 -10
- package/package.json +1 -1
- package/slint/vestra/bar-buttons.slint +6 -8
- package/slint/vestra/focus.slint +1 -1
- package/slint/vestra/widgets.slint +2 -4
|
@@ -90,6 +90,7 @@ import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-a
|
|
|
90
90
|
import { translate, i18nHandlers } from "./i18n.js";
|
|
91
91
|
import { mountOther, unmountOther, mounted, setTimelineRanges, setTimelineLayer, layoutHandlers, } from "./layout.js";
|
|
92
92
|
import { osdHandlers } from "./osd.js";
|
|
93
|
+
import { packageDirectories } from "./slint-types.js";
|
|
93
94
|
import { failStream, jobsHandlers } from "./jobs.js";
|
|
94
95
|
import { upscalingState, failVideoRender, failVideoShaders, upscalingDecoding, processingHandlers, } from "./processing.js";
|
|
95
96
|
import { sourceIntent, startResolution, setSource, mediaHandlers, initialSource, } from "./media.js";
|
|
@@ -244,7 +245,7 @@ export { LOCALES };
|
|
|
244
245
|
* recorded.
|
|
245
246
|
*
|
|
246
247
|
* @capability None.
|
|
247
|
-
* @see [Test a plugin](../../../docs/
|
|
248
|
+
* @see [Test a plugin](../../../docs/guides/testing.md)
|
|
248
249
|
* @since 1.0.0
|
|
249
250
|
* @category Testing
|
|
250
251
|
*/
|
|
@@ -286,8 +287,8 @@ export class TestHost {
|
|
|
286
287
|
/** Tool windows by id (see {@link TestHost.window}). */
|
|
287
288
|
windows = new Map();
|
|
288
289
|
/**
|
|
289
|
-
* The plugin's mounted panels by slot, in mount order (
|
|
290
|
-
*
|
|
290
|
+
* The plugin's mounted panels by slot, in mount order (one panel per slot).
|
|
291
|
+
* See {@link TestHost.mounted}.
|
|
291
292
|
*/
|
|
292
293
|
panels = new Map();
|
|
293
294
|
/**
|
|
@@ -333,15 +334,15 @@ export class TestHost {
|
|
|
333
334
|
*/
|
|
334
335
|
osd = [];
|
|
335
336
|
/**
|
|
336
|
-
* The action buttons of each `osd.show` message, in step with `osd`
|
|
337
|
-
*
|
|
338
|
-
*
|
|
337
|
+
* The action buttons of each `osd.show` message, in step with `osd` (index
|
|
338
|
+
* for index): each button's title as shown and its command; `[]` for a
|
|
339
|
+
* message without actions.
|
|
339
340
|
*/
|
|
340
341
|
osdActions = [];
|
|
341
342
|
/**
|
|
342
|
-
* Press button `index` of the newest OSD message, as the user does
|
|
343
|
-
*
|
|
344
|
-
*
|
|
343
|
+
* Press button `index` of the newest OSD message, as the user does: its
|
|
344
|
+
* command runs as if picked from a menu, and settles. A disabled or busy
|
|
345
|
+
* command does nothing, as in the player.
|
|
345
346
|
*
|
|
346
347
|
* @param index - 0 or 1.
|
|
347
348
|
*
|
|
@@ -382,11 +383,10 @@ export class TestHost {
|
|
|
382
383
|
* messages, dialog texts, settings page and panel titles show its
|
|
383
384
|
* translations, the way the player shows them.
|
|
384
385
|
*
|
|
385
|
-
* The player's own texts (core actions' messages and menus, its
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* passing; set `locale` to test what a user sees now.
|
|
386
|
+
* The player's own texts (core actions' messages and menus, its refusals) are
|
|
387
|
+
* English, or the player's Simplified Chinese for `"zh-Hans"`. While `locale`
|
|
388
|
+
* was never set they stay in Chinese; set `locale` to test what a user sees
|
|
389
|
+
* now.
|
|
390
390
|
*
|
|
391
391
|
* @example Check a menu path in Simplified Chinese
|
|
392
392
|
* The test starts the plugin with a Chinese interface and checks the
|
|
@@ -668,8 +668,7 @@ export class TestHost {
|
|
|
668
668
|
.sort((a, b) => a.time - b.time);
|
|
669
669
|
},
|
|
670
670
|
/**
|
|
671
|
-
* Each plugin's ranges by plugin id; layers without ranges are absent
|
|
672
|
-
* (SDK 1.6.9).
|
|
671
|
+
* Each plugin's ranges by plugin id; layers without ranges are absent.
|
|
673
672
|
*/
|
|
674
673
|
rangeLayers: new Map(),
|
|
675
674
|
/** Every layer's ranges merged, sorted by start, with the plugin's id. */
|
|
@@ -744,10 +743,10 @@ export class TestHost {
|
|
|
744
743
|
}
|
|
745
744
|
/**
|
|
746
745
|
* Runtime images written to views (`plugin.ui.image`,
|
|
747
|
-
* `plugin.ui.remoteImage`), whole values and
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
746
|
+
* `plugin.ui.remoteImage`), whole values and images nested in rows, newest
|
|
747
|
+
* last. The SDK refuses images of released scopes before anything is sent.
|
|
748
|
+
* The test host does not read the files, so it does not check the player's
|
|
749
|
+
* per-view budget (`IMAGE_LIMITS.viewBytes`).
|
|
751
750
|
*/
|
|
752
751
|
images = [];
|
|
753
752
|
/**
|
|
@@ -1080,14 +1079,13 @@ export class TestHost {
|
|
|
1080
1079
|
this.videoRender.values = { ...RENDER_DEFAULTS, shaders: [] };
|
|
1081
1080
|
}
|
|
1082
1081
|
/**
|
|
1083
|
-
* What the player pushes when mpv cannot compile a shader (code `failed`)
|
|
1084
|
-
*
|
|
1085
|
-
* `videoRender.gpu` to false and `rendering.reason` to `window-fallback`
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
*
|
|
1090
|
-
* {@link TestHost.previousCrash}.
|
|
1082
|
+
* What the player pushes when mpv cannot compile a shader (code `failed`) or
|
|
1083
|
+
* switches to software rendering (`unsupported`, which also sets
|
|
1084
|
+
* `videoRender.gpu` to false and `rendering.reason` to `window-fallback` with
|
|
1085
|
+
* `message`). Pushed only when this plugin is the owner. `previous-crash` is
|
|
1086
|
+
* a shortcut that only sets the handle's status and reaches `onError`: the
|
|
1087
|
+
* real player never pushes it, it refuses the `set` request itself. To test
|
|
1088
|
+
* that, set {@link TestHost.previousCrash}.
|
|
1091
1089
|
*
|
|
1092
1090
|
* @example Make a shader fail to compile
|
|
1093
1091
|
* The plugin's render options report `failed`, as when mpv rejects a
|
|
@@ -1113,11 +1111,11 @@ export class TestHost {
|
|
|
1113
1111
|
return failVideoRender(this, this.#inner, code, message);
|
|
1114
1112
|
}
|
|
1115
1113
|
/**
|
|
1116
|
-
* The shader channel (`plugin.video.shaders(id)
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1114
|
+
* The shader channel (`plugin.video.shaders(id)`): the lists the player holds
|
|
1115
|
+
* for this plugin's handles by id (the real paths, after following links),
|
|
1116
|
+
* and how many shaders other plugins hold, which count against
|
|
1117
|
+
* {@link VIDEO_PROCESSING_LIMITS}`.shaders` (`limit`). Files must be under
|
|
1118
|
+
* {@link TestHost.fileRoots}; under software rendering
|
|
1121
1119
|
* (`videoRender.gpu = false`) a non-empty list fails with `unsupported`.
|
|
1122
1120
|
*
|
|
1123
1121
|
* @since 1.5.39
|
|
@@ -1139,11 +1137,10 @@ export class TestHost {
|
|
|
1139
1137
|
* rendering (`unsupported`; use {@link TestHost.failVideoRender}, which
|
|
1140
1138
|
* also tells the handles). Pushed only to a handle that holds shaders.
|
|
1141
1139
|
*
|
|
1142
|
-
* `code` (
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
* {@link TestHost.previousCrash}.
|
|
1140
|
+
* `code` (default `failed`) is the error code pushed. `previous-crash` is a
|
|
1141
|
+
* shortcut that only sets the handle's status and reaches `onError`: the real
|
|
1142
|
+
* player never pushes it, it refuses the `set` request itself after
|
|
1143
|
+
* an abnormal end. To test that, set {@link TestHost.previousCrash}.
|
|
1147
1144
|
*
|
|
1148
1145
|
* @capability None.
|
|
1149
1146
|
*
|
|
@@ -1174,11 +1171,10 @@ export class TestHost {
|
|
|
1174
1171
|
return failVideoShaders(this, this.#inner, id, message, code);
|
|
1175
1172
|
}
|
|
1176
1173
|
/**
|
|
1177
|
-
* Play a run after an abnormal end with plugin shaders on
|
|
1178
|
-
*
|
|
1179
|
-
* `
|
|
1180
|
-
*
|
|
1181
|
-
* (default): shaders apply.
|
|
1174
|
+
* Play a run after an abnormal end with plugin shaders on: while set, a
|
|
1175
|
+
* non-empty `video.shaders` list and a render options `set` with a non-empty
|
|
1176
|
+
* `shaders` list are refused with `previous-crash` and this message; clearing
|
|
1177
|
+
* still works. `null` (default): shaders apply.
|
|
1182
1178
|
*
|
|
1183
1179
|
* @example Check that the plugin stops retrying while shaders are off
|
|
1184
1180
|
* The plugin's shader handle turns `failed` with `previous-crash`, as
|
|
@@ -1487,10 +1483,10 @@ export class TestHost {
|
|
|
1487
1483
|
},
|
|
1488
1484
|
};
|
|
1489
1485
|
/**
|
|
1490
|
-
* The player's rendering choice behind `plugin.rendering
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1486
|
+
* The player's rendering choice behind `plugin.rendering`. The mode drawing
|
|
1487
|
+
* now is {@link TestHost.videoRender | videoRender.gpu}, as for
|
|
1488
|
+
* `plugin.app.system()`; the rest is preset here and changed by the plugin's
|
|
1489
|
+
* calls, as the player would:
|
|
1494
1490
|
*
|
|
1495
1491
|
* - `setPreference` saves `preference` and never changes the mode. It
|
|
1496
1492
|
* refuses `"gpu"` while `gpu.available` is false: with `unsupported`
|
|
@@ -1545,8 +1541,8 @@ export class TestHost {
|
|
|
1545
1541
|
restarts: 0,
|
|
1546
1542
|
};
|
|
1547
1543
|
/**
|
|
1548
|
-
* The GPU's video upscaler behind `plugin.video.upscaling
|
|
1549
|
-
*
|
|
1544
|
+
* The GPU's video upscaler behind `plugin.video.upscaling`, answered as the
|
|
1545
|
+
* player would:
|
|
1550
1546
|
*
|
|
1551
1547
|
* - `state()` and `set(true)` set `checked` (the player's one GPU check; a
|
|
1552
1548
|
* plugin that should not wake the GPU while it starts can assert it is
|
|
@@ -1609,10 +1605,10 @@ export class TestHost {
|
|
|
1609
1605
|
};
|
|
1610
1606
|
/**
|
|
1611
1607
|
* Make the upscaler's reason `decoding` with `cause`, with the player's
|
|
1612
|
-
* message
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1608
|
+
* message, and set `upscaling.hwdecCurrent` to match (`d3d11va-copy`, `no`,
|
|
1609
|
+
* `nvdec`). `plugins` are named for `copy-back` only, as the player does.
|
|
1610
|
+
* Returns the reason; call {@link TestHost.upscalingChanged} to tell a
|
|
1611
|
+
* listening plugin.
|
|
1616
1612
|
*
|
|
1617
1613
|
* @example Test the window's advice for each cause
|
|
1618
1614
|
* The plugin's window explains why upscaling waits. The test fakes the
|
|
@@ -1636,10 +1632,9 @@ export class TestHost {
|
|
|
1636
1632
|
}
|
|
1637
1633
|
/**
|
|
1638
1634
|
* Send `video.upscaling.changed` with the state {@link TestHost.upscaling}
|
|
1639
|
-
* describes now (without `enabled`), as the player does when it changes
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1642
|
-
* that does not listen.
|
|
1635
|
+
* describes now (without `enabled`), as the player does when it changes; a
|
|
1636
|
+
* plugin listening with `plugin.video.upscaling.onChange` receives it.
|
|
1637
|
+
* Nothing reaches a plugin that does not listen.
|
|
1643
1638
|
*
|
|
1644
1639
|
* @capability None.
|
|
1645
1640
|
*
|
|
@@ -1733,7 +1728,7 @@ export class TestHost {
|
|
|
1733
1728
|
// ------------------------------------------------------------ core actions
|
|
1734
1729
|
/** The `player.setStepSeek` value in effect (default 5). */
|
|
1735
1730
|
stepSeek = 5;
|
|
1736
|
-
/** The `player.setStepSeek` `keyframes` in effect (default `false
|
|
1731
|
+
/** The `player.setStepSeek` `keyframes` in effect (default `false`). */
|
|
1737
1732
|
stepSeekKeyframes = false;
|
|
1738
1733
|
/**
|
|
1739
1734
|
* Test data: the keyframe times (seconds, ascending) of the current
|
|
@@ -1976,10 +1971,10 @@ export class TestHost {
|
|
|
1976
1971
|
/**
|
|
1977
1972
|
* Simulate the user changing the main window (resizing, maximizing or
|
|
1978
1973
|
* restoring it, entering or leaving fullscreen, closing the
|
|
1979
|
-
* picture-in-picture window) and broadcast it. `maximized`
|
|
1980
|
-
*
|
|
1981
|
-
* sidebar (`effective: false`, `reason: "fullscreen"`) and
|
|
1982
|
-
* fullscreen docks it again.
|
|
1974
|
+
* picture-in-picture window) and broadcast it. `maximized` reads `false`
|
|
1975
|
+
* while fullscreen. Like the player, entering fullscreen collapses an
|
|
1976
|
+
* attached, visible sidebar (`effective: false`, `reason: "fullscreen"`) and
|
|
1977
|
+
* leaving fullscreen docks it again.
|
|
1983
1978
|
*
|
|
1984
1979
|
* @example Go fullscreen, report picture-in-picture support, maximize
|
|
1985
1980
|
* The plugin sees the main window fullscreen at 1920×1080, then learns
|
|
@@ -2010,9 +2005,9 @@ export class TestHost {
|
|
|
2010
2005
|
}
|
|
2011
2006
|
/**
|
|
2012
2007
|
* The pointer reached the right edge in fullscreen (`true`) or left the
|
|
2013
|
-
* popped-out columns (`false`): the attached sidebar and the adjust column
|
|
2014
|
-
*
|
|
2015
|
-
*
|
|
2008
|
+
* popped-out columns (`false`): the attached sidebar and the adjust column,
|
|
2009
|
+
* those switched on, pop out or collapse (reference §6.3). No effect outside
|
|
2010
|
+
* fullscreen, or on a column switched off or floating.
|
|
2016
2011
|
*
|
|
2017
2012
|
* @capability None.
|
|
2018
2013
|
*
|
|
@@ -2108,18 +2103,18 @@ export class TestHost {
|
|
|
2108
2103
|
/**
|
|
2109
2104
|
* Press a binding like the host's table would: panel-focus bindings first
|
|
2110
2105
|
* when `panel` is true, then global ones; within a scope the earliest
|
|
2111
|
-
* registration first (the player's own commands before the plugin's), as
|
|
2112
|
-
*
|
|
2113
|
-
*
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2117
|
-
*
|
|
2118
|
-
* `
|
|
2119
|
-
*
|
|
2120
|
-
*
|
|
2121
|
-
*
|
|
2122
|
-
*
|
|
2106
|
+
* registration first (the player's own commands before the plugin's), as the
|
|
2107
|
+
* conflict rule orders them. A disabled command lets the key pass to the next
|
|
2108
|
+
* command bound to it: the one it shadowed, then the global
|
|
2109
|
+
* scope. The first enabled one runs; `press` resolves after it ran (`"ran"`).
|
|
2110
|
+
* When only disabled commands hold the key, the first of them decides, as in
|
|
2111
|
+
* the player: with a `reason` it shows the reason on the OSD and eats the key
|
|
2112
|
+
* (`"reason"`, see `host.osd`); without one the key goes on to the focused
|
|
2113
|
+
* control (`"passed"`, nothing runs). Unlike the player, which only logs a
|
|
2114
|
+
* key that reaches a busy command, `press` then rejects, so a test notices.
|
|
2115
|
+
* Rejects when nothing is bound. Bindings use the reference syntax
|
|
2116
|
+
* (`"Space"`, `"Ctrl+O"`, `"Mouse:WheelUp"`), and user overrides in
|
|
2117
|
+
* `bindings.overlay` apply.
|
|
2123
2118
|
*
|
|
2124
2119
|
* @returns What the key did: `"ran"`, `"reason"` or `"passed"`.
|
|
2125
2120
|
*
|
|
@@ -2166,14 +2161,13 @@ export class TestHost {
|
|
|
2166
2161
|
.map(([key, ids]) => [key.split(" ")[1], ...ids]);
|
|
2167
2162
|
}
|
|
2168
2163
|
/**
|
|
2169
|
-
* Change the keys of one of the plugin's commands, or of one of the
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2172
|
-
*
|
|
2173
|
-
*
|
|
2174
|
-
*
|
|
2175
|
-
*
|
|
2176
|
-
* `plugin.commands.keys` reads changed, `commands.keys`.
|
|
2164
|
+
* Change the keys of one of the plugin's commands, or of one of the player's
|
|
2165
|
+
* core commands by its `host/<id>`, as the user does in Keyboard Shortcuts:
|
|
2166
|
+
* `inputs` replaces its keys (`[]` clears them, as Ignore Default Shortcuts
|
|
2167
|
+
* does for every default), `null` gives it its own defaults back. It writes
|
|
2168
|
+
* {@link TestHost.bindings | bindings.overlay}, and the plugin hears it as
|
|
2169
|
+
* from the player: `bindings.changed` and, when what `plugin.commands.keys`
|
|
2170
|
+
* reads changed, `commands.keys`.
|
|
2177
2171
|
*
|
|
2178
2172
|
* @example Check that a key hint follows a rebinding
|
|
2179
2173
|
* The view showed W for Brightness −; after the user moves it to
|
|
@@ -2222,17 +2216,15 @@ export class TestHost {
|
|
|
2222
2216
|
/** Every `packages.setEnabled` / `uninstall` / `install`, newest last. */
|
|
2223
2217
|
packageCalls = [];
|
|
2224
2218
|
/**
|
|
2225
|
-
* Packages `validate` and `validateArchive` accept: path (directory or
|
|
2226
|
-
*
|
|
2227
|
-
*
|
|
2228
|
-
*
|
|
2229
|
-
*
|
|
2230
|
-
*
|
|
2231
|
-
* {@link "@vestra-player/sdk"!InstallOptions.enabled}: a first install
|
|
2232
|
-
*
|
|
2233
|
-
*
|
|
2234
|
-
* {@link TestHost.installKeepsDisabled} to `false` for the older players'
|
|
2235
|
-
* rule (every install runs).
|
|
2219
|
+
* Packages `validate` and `validateArchive` accept: path (directory or `.vxp`
|
|
2220
|
+
* file) → its manifest. Other paths fail with `missing`. `install` adds or
|
|
2221
|
+
* upgrades the entry in {@link TestHost.packages} following the player's
|
|
2222
|
+
* source rules: the same source upgrades, another source needs `replace`
|
|
2223
|
+
* (`conflict` otherwise), a built-in id is `unsupported`. The installed
|
|
2224
|
+
* entry's `state` follows
|
|
2225
|
+
* {@link "@vestra-player/sdk"!InstallOptions.enabled}: a first install runs,
|
|
2226
|
+
* an update of a `disabled` entry stays `disabled` unless `enabled` is
|
|
2227
|
+
* `true`, and `enabled: false` installs it `disabled`.
|
|
2236
2228
|
*
|
|
2237
2229
|
* @example Offer a package file the plugin can install
|
|
2238
2230
|
* The plugin can validate and install `/downloads/someone.demo-1.0.0.vxp`
|
|
@@ -2250,25 +2242,20 @@ export class TestHost {
|
|
|
2250
2242
|
*/
|
|
2251
2243
|
candidates = new Map();
|
|
2252
2244
|
/**
|
|
2253
|
-
* Which
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2256
|
-
*
|
|
2257
|
-
*
|
|
2258
|
-
*
|
|
2259
|
-
*
|
|
2260
|
-
* updates a disabled plugin sets it to `false`; one that keeps testing
|
|
2261
|
-
* both runs once with each.
|
|
2262
|
-
*
|
|
2263
|
-
* @example Keep a test written for players up to 0.6.3
|
|
2245
|
+
* Which install rule `packages.install` plays. `true` (default): an update
|
|
2246
|
+
* or reinstall keeps a `disabled` plugin disabled unless the plugin passes
|
|
2247
|
+
* {@link "@vestra-player/sdk"!InstallOptions.enabled}. `false`: every
|
|
2248
|
+
* install runs the plugin and `enabled` is ignored (it is still checked and
|
|
2249
|
+
* recorded in {@link TestHost.packageCalls}).
|
|
2250
|
+
*
|
|
2251
|
+
* @example Every install runs
|
|
2264
2252
|
* The plugin under test installs an update over a plugin the user
|
|
2265
|
-
* disabled and expects it to run afterwards
|
|
2266
|
-
*
|
|
2267
|
-
* where the update stays disabled.
|
|
2253
|
+
* disabled and expects it to run afterwards. With `false` the host plays
|
|
2254
|
+
* that rule; the default keeps the update disabled.
|
|
2268
2255
|
* ```ts
|
|
2269
2256
|
* declare const host: TestHost;
|
|
2270
2257
|
* // ---cut---
|
|
2271
|
-
* host.installKeepsDisabled = false; // every install runs
|
|
2258
|
+
* host.installKeepsDisabled = false; // every install runs
|
|
2272
2259
|
* ```
|
|
2273
2260
|
*
|
|
2274
2261
|
* @capability None.
|
|
@@ -2450,10 +2437,10 @@ export class TestHost {
|
|
|
2450
2437
|
}
|
|
2451
2438
|
/**
|
|
2452
2439
|
* The plugin's mounted panel (bottom bar, sidebar, adjust column or
|
|
2453
|
-
* backdrop): the one in `slot`, or without it the only one (
|
|
2454
|
-
*
|
|
2455
|
-
*
|
|
2456
|
-
*
|
|
2440
|
+
* backdrop): the one in `slot`, or without it the only one (a plugin mounts
|
|
2441
|
+
* one panel per slot; with several, name the slot). Throws when there is
|
|
2442
|
+
* none. Its `props` use Slint (kebab-case) names; `emit` fires a callback on
|
|
2443
|
+
* the panel's global.
|
|
2457
2444
|
*
|
|
2458
2445
|
* @example Select a row in the plugin's sidebar panel
|
|
2459
2446
|
* The test checks the panel sits in the sidebar and selects its third
|
|
@@ -2508,12 +2495,12 @@ export class TestHost {
|
|
|
2508
2495
|
* for: on a loaded machine it can finish after `settle()` returns. Poll
|
|
2509
2496
|
* the result you assert on instead (second example).
|
|
2510
2497
|
*
|
|
2511
|
-
* `settle()` does not wait for the SDK's once-a-second full update pass
|
|
2512
|
-
*
|
|
2513
|
-
*
|
|
2514
|
-
*
|
|
2515
|
-
* `plugin.update()`
|
|
2516
|
-
*
|
|
2498
|
+
* `settle()` does not wait for the SDK's once-a-second full update pass.
|
|
2499
|
+
* After `setSource` (or another player state change) only the bindings that
|
|
2500
|
+
* read a changed field of `plugin.player.state` run again; state the plugin
|
|
2501
|
+
* changed outside a handler without `plugin.update()` shows only in the next
|
|
2502
|
+
* full pass. Have the plugin call `plugin.update()` after such a change, or
|
|
2503
|
+
* wait `settle(1000)`.
|
|
2517
2504
|
*
|
|
2518
2505
|
* @param ms - Extra time to wait, for debounces and timers (default 0).
|
|
2519
2506
|
*
|
|
@@ -2581,19 +2568,17 @@ export class TestHost {
|
|
|
2581
2568
|
}
|
|
2582
2569
|
// ------------------------------------------------------------ simulated host
|
|
2583
2570
|
/**
|
|
2584
|
-
* Why the player would keep this plugin running while nothing uses it
|
|
2585
|
-
*
|
|
2586
|
-
*
|
|
2587
|
-
*
|
|
2588
|
-
*
|
|
2589
|
-
* player
|
|
2590
|
-
*
|
|
2591
|
-
*
|
|
2592
|
-
*
|
|
2593
|
-
*
|
|
2594
|
-
*
|
|
2595
|
-
* streams, jobs and the like (which also keep a plugin running) are not
|
|
2596
|
-
* listed.
|
|
2571
|
+
* Why the player would keep this plugin running while nothing uses it (lazy
|
|
2572
|
+
* activation), one line per reason: an event it listens to that is not one
|
|
2573
|
+
* the player wakes it for (with what listens and where it was added), its
|
|
2574
|
+
* panel in the bottom bar or the backdrop, its open windows (these as the
|
|
2575
|
+
* player's log says them), and its sidebar tab while that is the current tab.
|
|
2576
|
+
* The player counts the current tab as busy work, not as something live: it
|
|
2577
|
+
* keeps the plugin running only while the tab is shown, and a sidebar panel
|
|
2578
|
+
* in a background tab is no reason at all (the plugin may go to standby;
|
|
2579
|
+
* showing the tab starts it again). Empty: the player may stop it while idle
|
|
2580
|
+
* and start it again on its next use. Filter chains, streams, jobs and the
|
|
2581
|
+
* like (which also keep a plugin running) are not listed.
|
|
2597
2582
|
*
|
|
2598
2583
|
* @capability None.
|
|
2599
2584
|
* @since 1.5.40
|
|
@@ -2641,21 +2626,19 @@ export class TestHost {
|
|
|
2641
2626
|
* Rejects when `manifest.json` cannot be read or parsed, when `activate`
|
|
2642
2627
|
* throws, or when a registration made during activation fails (for example
|
|
2643
2628
|
* `limit`, `conflict`, `invalid`). Stricter than the player's runner for
|
|
2644
|
-
* commands
|
|
2645
|
-
*
|
|
2646
|
-
*
|
|
2647
|
-
* bad declaration.
|
|
2629
|
+
* commands: there the SDK logs a command declaration the player refuses during
|
|
2630
|
+
* activation, skips it and activates the rest of the plugin (`onError` hears
|
|
2631
|
+
* it); `startPlugin` fails, so a test shows the bad declaration.
|
|
2648
2632
|
*
|
|
2649
2633
|
* @param activate - The plugin's default-exported `activate` function.
|
|
2650
2634
|
* @param options - Where the plugin lives and how to start it.
|
|
2651
2635
|
* @returns `host`: the {@link TestHost}; `plugin`: the object passed to
|
|
2652
|
-
*
|
|
2653
|
-
*
|
|
2654
|
-
*
|
|
2655
|
-
*
|
|
2656
|
-
*
|
|
2657
|
-
*
|
|
2658
|
-
* temporary files never fails a test.
|
|
2636
|
+
* `activate` (call the plugin API on it directly); `stop()`: dispose the plugin
|
|
2637
|
+
* like the player stopping it (scopes released, stores flushed), wait until the
|
|
2638
|
+
* host is idle and remove the host's temporary files; `stop({ reason })`:
|
|
2639
|
+
* `reason` is the `StopReason` the player sends; `disconnect()` stops it as
|
|
2640
|
+
* when the player is lost (`host-lost`, requests refused with `disabled`).
|
|
2641
|
+
* Removing the temporary files never fails a test.
|
|
2659
2642
|
*
|
|
2660
2643
|
* @example Test that a setting survives a restart
|
|
2661
2644
|
* The test turns on the 10-step option, stops the plugin, starts it again
|
|
@@ -2703,7 +2686,7 @@ export class TestHost {
|
|
|
2703
2686
|
* to call directly, and `stop` to end it like the player.
|
|
2704
2687
|
*
|
|
2705
2688
|
* @capability None.
|
|
2706
|
-
* @see [Test a plugin](../../../docs/
|
|
2689
|
+
* @see [Test a plugin](../../../docs/guides/testing.md)
|
|
2707
2690
|
* @since 1.0.0
|
|
2708
2691
|
* @category Testing
|
|
2709
2692
|
*/
|
|
@@ -2724,6 +2707,9 @@ export async function startPlugin(activate, options = {}) {
|
|
|
2724
2707
|
}
|
|
2725
2708
|
host.manifestId = manifest.id;
|
|
2726
2709
|
host.loadCatalog(directory);
|
|
2710
|
+
// Its Slint files: the values its views are given are checked against
|
|
2711
|
+
// their declared types.
|
|
2712
|
+
packageDirectories.set(host, directory);
|
|
2727
2713
|
const data = options.dataDirectory ?? host.dataDirectory;
|
|
2728
2714
|
for (const [key, value] of options.sessionStorage ?? [])
|
|
2729
2715
|
host.sessionStorage.set(key, sortedJson(value));
|
|
@@ -2773,18 +2759,18 @@ export async function startPlugin(activate, options = {}) {
|
|
|
2773
2759
|
plugin: instance.plugin,
|
|
2774
2760
|
/**
|
|
2775
2761
|
* Stop the plugin, wait for the host, and remove temporary files.
|
|
2776
|
-
* `stop({ reason })
|
|
2777
|
-
*
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
2780
|
-
*
|
|
2762
|
+
* `stop({ reason })`: `reason` is the reason the player gives
|
|
2763
|
+
* (`plugin.stopReason`, the `onDispose` cleanups' `info.reason`); `stop()`:
|
|
2764
|
+
* none (`undefined`). It still
|
|
2765
|
+
* takes no declared parameter, so it can be passed as a callback
|
|
2766
|
+
* (`t.after(stop)`, `promise.then(stop)`).
|
|
2781
2767
|
*/
|
|
2782
2768
|
stop,
|
|
2783
2769
|
/**
|
|
2784
|
-
* Lose the player
|
|
2785
|
-
*
|
|
2786
|
-
*
|
|
2787
|
-
*
|
|
2770
|
+
* Lose the player: as when it crashes or is killed, the runner stops the
|
|
2771
|
+
* plugin with reason `host-lost`; requests still waiting for their answer
|
|
2772
|
+
* and every later request are refused with `disabled`. Then waits and
|
|
2773
|
+
* removes the temporary files like `stop`.
|
|
2788
2774
|
*/
|
|
2789
2775
|
async disconnect() {
|
|
2790
2776
|
host.loseConnection();
|
|
@@ -11,8 +11,8 @@ export declare class Internals {
|
|
|
11
11
|
/** The plugin's translations for `locale` (see `loadCatalog`). */
|
|
12
12
|
catalog: Catalog;
|
|
13
13
|
/**
|
|
14
|
-
* Row patches
|
|
15
|
-
*
|
|
14
|
+
* Row patches: the `seq` of each property's last write, by view and property
|
|
15
|
+
* (none: 0, the initial properties).
|
|
16
16
|
*/
|
|
17
17
|
readonly writes: Map<string, number>;
|
|
18
18
|
/** The parts of a whole value held until its last part, by view and property. */
|
|
@@ -20,6 +20,13 @@ export declare class Internals {
|
|
|
20
20
|
seq: number;
|
|
21
21
|
rows: Json[];
|
|
22
22
|
}>;
|
|
23
|
+
/** The exported global each mounted panel's properties belong to, by slot. */
|
|
24
|
+
readonly globals: Map<string, string | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* A panel's properties (view and name) whose stored initial value the
|
|
27
|
+
* panel could not take: it shows the property's default.
|
|
28
|
+
*/
|
|
29
|
+
readonly unshown: Set<string>;
|
|
23
30
|
nextOwner: number;
|
|
24
31
|
/** Owners of other plugins' panels, by plugin id ({@link TestHost.mountOther}). */
|
|
25
32
|
readonly others: Map<string, {
|
|
@@ -14,12 +14,19 @@ export class Internals {
|
|
|
14
14
|
/** The plugin's translations for `locale` (see `loadCatalog`). */
|
|
15
15
|
catalog = new Catalog();
|
|
16
16
|
/**
|
|
17
|
-
* Row patches
|
|
18
|
-
*
|
|
17
|
+
* Row patches: the `seq` of each property's last write, by view and property
|
|
18
|
+
* (none: 0, the initial properties).
|
|
19
19
|
*/
|
|
20
20
|
writes = new Map();
|
|
21
21
|
/** The parts of a whole value held until its last part, by view and property. */
|
|
22
22
|
parts = new Map();
|
|
23
|
+
/** The exported global each mounted panel's properties belong to, by slot. */
|
|
24
|
+
globals = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* A panel's properties (view and name) whose stored initial value the
|
|
27
|
+
* panel could not take: it shows the property's default.
|
|
28
|
+
*/
|
|
29
|
+
unshown = new Set();
|
|
23
30
|
nextOwner = 2;
|
|
24
31
|
/** Owners of other plugins' panels, by plugin id ({@link TestHost.mountOther}). */
|
|
25
32
|
others = new Map();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Json, LayoutPanel } from "../../wire.ts";
|
|
2
2
|
import type { FakePanel, TestHost } from "./index.ts";
|
|
3
3
|
import type { Handler, Internals } from "./internals.ts";
|
|
4
|
+
import type { Refusal, ViewTypes } from "./slint-types.ts";
|
|
4
5
|
export declare const kebab: (name: string) => string;
|
|
5
6
|
export declare const SLOT_LABELS: Record<string, string>;
|
|
6
7
|
/** The view a panel's writes are kept under (the player's, per slot). */
|
|
@@ -43,16 +44,58 @@ export declare function resetWrites(_host: TestHost, inner: Internals, view: str
|
|
|
43
44
|
* otherwise). The result is checked against the value limits whole: the
|
|
44
45
|
* player counts the rows a patch keeps too.
|
|
45
46
|
*/
|
|
46
|
-
export declare function writeProperty(host: TestHost, inner: Internals, view: string, property: string, p: Record<string, Json>, current: Json | undefined): Json | undefined;
|
|
47
|
+
export declare function writeProperty(host: TestHost, inner: Internals, view: string, property: string, p: Record<string, Json>, current: Json | undefined, typed?: TypedView | null): Json | undefined;
|
|
47
48
|
/**
|
|
48
49
|
* Refuse property values over the player's limits ({@link UI_VALUE_LIMITS})
|
|
49
50
|
* with `limit`, naming the property, as the player does.
|
|
50
51
|
*/
|
|
51
52
|
export declare function checkValues(_host: TestHost, _inner: Internals, values: Record<string, Json>): void;
|
|
53
|
+
/**
|
|
54
|
+
* A view's declared property types, with how the player words a refusal
|
|
55
|
+
* there: the error `code`, and `bare` when it reads the property before it
|
|
56
|
+
* writes it (`ui.set`, `ui.setMount`, `settings.set`, a panel's or settings
|
|
57
|
+
* page's initial values), so that an unknown one is refused as "no such
|
|
58
|
+
* property" without its name. Those writes compare first
|
|
59
|
+
* (`ui_values::reconcile_in`): a value equal to what the property holds
|
|
60
|
+
* does nothing, on an `out` property too. `fresh`: the property shows its
|
|
61
|
+
* default although a value is stored (a panel's initial value it could
|
|
62
|
+
* not take).
|
|
63
|
+
*/
|
|
64
|
+
export interface TypedView {
|
|
65
|
+
types: ViewTypes;
|
|
66
|
+
code: string;
|
|
67
|
+
bare: boolean;
|
|
68
|
+
fresh?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The declared types of the view in `file` of the plugin's package: its
|
|
72
|
+
* exported component, or `global` (a panel's or settings page's). `null`
|
|
73
|
+
* (nothing checked) when the host runs no package or the file cannot be
|
|
74
|
+
* read.
|
|
75
|
+
*/
|
|
76
|
+
export declare function typedView(host: TestHost, file: string, global: string | undefined, code: string, bare: boolean): TypedView | null;
|
|
77
|
+
/** A refusal in the player's words, for a write that reads the property first (`bare`) or not. */
|
|
78
|
+
export declare const refusalText: (found: Refusal, bare: boolean) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Refuse a value the player's Slint refuses for `property` (a value of
|
|
81
|
+
* another type than declared, an undeclared or `out` property), with the
|
|
82
|
+
* player's code and words. `current`: what the property shows now (none:
|
|
83
|
+
* its default), which the words describe the declared type by.
|
|
84
|
+
*/
|
|
85
|
+
export declare function checkType(typed: TypedView, property: string, value: Json, current: Json | undefined): void;
|
|
86
|
+
/**
|
|
87
|
+
* Refuse a struct field name the player's conversion refuses (not in
|
|
88
|
+
* Slint's canonical spelling), whatever the view declares: code `host`,
|
|
89
|
+
* the property named.
|
|
90
|
+
*/
|
|
91
|
+
export declare function checkSpelling(property: string, value: Json): void;
|
|
92
|
+
/** Property names in the order the player sets them (a `BTreeMap`). */
|
|
93
|
+
export declare const inSetOrder: (values: Record<string, Json>) => string[];
|
|
52
94
|
/**
|
|
53
95
|
* A panel's or settings page's initial properties, as the player keeps
|
|
54
|
-
* them: one over the limits
|
|
55
|
-
*
|
|
96
|
+
* them: one over the limits (`limit`) or with a struct field name not in
|
|
97
|
+
* Slint's canonical spelling (`host`) is left out (the property keeps its
|
|
98
|
+
* default) and reported with `ui.error`, the request itself succeeds.
|
|
56
99
|
*/
|
|
57
100
|
export declare function initialValues(host: TestHost, _inner: Internals, values: Record<string, Json>): Record<string, Json>;
|
|
58
101
|
export declare function seeImages(host: TestHost, _inner: Internals, values: Record<string, Json> | Json[]): void;
|