@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
@@ -70,9 +70,11 @@ import { join } from "node:path";
70
70
  import { fileURLToPath } from "node:url";
71
71
  import { HostError } from "../../wire.js";
72
72
  import { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS, BUILTIN_COMMANDS, BUILTIN_SUBMENUS, COMMAND_LIMITS, MENU_IDS, } from "../../commands.js";
73
- import { CAPABILITY_INFO, MESSAGE_LIMIT } from "../../capabilities.js";
73
+ import { CAPABILITIES_REMOVED } from "../../manifest.js";
74
+ import { MESSAGE_LIMIT } from "../../protocol.js";
74
75
  import { OSD_LIMITS } from "../osd.js";
75
76
  import { TIMELINE_LIMITS } from "../timeline.js";
77
+ import { PLAYER_SLINT } from "../../slint-version.js";
76
78
  import { SECRET_LIMITS, SESSION_STORAGE_LIMITS } from "../services.js";
77
79
  import { SUBTITLE_LIMITS } from "../subtitles.js";
78
80
  import { BINDING_INPUTS, canonical } from "../bindings.js";
@@ -85,27 +87,30 @@ import { PATCH_FEATURE } from "../patch.js";
85
87
  import { LOCALES, LIST_SEPARATORS, loadPackageCatalog, TEXT_LIMITS, } from "../../i18n.js";
86
88
  import { Internals } from "./internals.js";
87
89
  import { on, emit, settle, close, keepsRunning, transportHandlers, tick, takenErrors, tellResidency, } from "./transport.js";
88
- import { bindingClaims, bindingKey, keysChanged, press, barButtons, commandsHandlers, builtinHandlers, runPaletteLead, pluginCapabilities, } from "./commands.js";
90
+ import { bindingClaims, bindingKey, keysChanged, press, barButtons, commandsHandlers, builtinHandlers, runPaletteLead, } from "./commands.js";
89
91
  import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-actions.js";
90
92
  import { translate, i18nHandlers } from "./i18n.js";
91
93
  import { mountOther, unmountOther, mounted, setTimelineRanges, setTimelineLayer, layoutHandlers, } from "./layout.js";
92
94
  import { osdHandlers } from "./osd.js";
93
95
  import { mpvHandlers, setMpvProperty } from "./mpv.js";
94
96
  import { packageDirectories } from "./slint-types.js";
97
+ import { quitEvent } from "./source-events.js";
95
98
  import { failStream, jobsHandlers } from "./jobs.js";
96
99
  import { motionState, upscalingState, failVideoRender, failVideoShaders, upscalingDecoding, processingHandlers, } from "./processing.js";
97
100
  import { sourceIntent, startResolution, setSource, mediaHandlers, initialSource, } from "./media.js";
98
101
  import { drop, setMainWindow, servicesHandlers, sortedJson, } from "./services.js";
102
+ import { advance, keptTriggers, park, triggerState, triggersHandlers, upgrade, } from "./triggers.js";
103
+ import { TRIGGER_LIMITS } from "../triggers.js";
99
104
  /** Throw one of these from `host.handle(...)` to simulate a definite refusal. */
100
105
  export { HostError };
106
+ /** The player's limits on triggers (1.10.0), which the test host enforces as well. */
107
+ export { TRIGGER_LIMITS };
101
108
  /** The player's command caps, which the test host enforces as well. */
102
109
  export { COMMAND_LIMITS, MENU_IDS };
103
110
  /** The icons and limits of bottom-bar buttons, which the test host checks as well. */
104
111
  export { BAR_BUTTON_ICONS, BAR_BUTTON_LIMITS };
105
112
  /** The submenus of the player's built-in plugins, by key path. */
106
113
  export { BUILTIN_COMMANDS, BUILTIN_SUBMENUS };
107
- /** The manifest capabilities: what each opens and how the store shows it. */
108
- export { CAPABILITY_INFO };
109
114
  /** The longest message a plugin may send the player. */
110
115
  export { MESSAGE_LIMIT };
111
116
  /** The player's limits on the on-screen display. */
@@ -245,7 +250,6 @@ export { LOCALES };
245
250
  * {@link startPlugin}, drive it, `settle()`, and assert on what it
246
251
  * recorded.
247
252
  *
248
- * @capability None.
249
253
  * @see [Test a plugin](../../../docs/guides/testing.md)
250
254
  * @since 1.0.0
251
255
  * @category Testing
@@ -257,7 +261,7 @@ export class TestHost {
257
261
  * Wire-level; prefer {@link TestHost.sent} for one method.
258
262
  */
259
263
  calls = [];
260
- /** The host events the plugin subscribed to (needs `events` etc.). */
264
+ /** The host events the plugin subscribed to. */
261
265
  subscriptions = new Set();
262
266
  /**
263
267
  * The subscribed events the plugin really listens to: an `onChange` and
@@ -362,7 +366,6 @@ export class TestHost {
362
366
  * await host.pressOsdAction(0); // runs the plugin's `reveal` command
363
367
  * ```
364
368
  *
365
- * @capability None.
366
369
  * @since 1.6.9
367
370
  */
368
371
  async pressOsdAction(index) {
@@ -425,8 +428,6 @@ export class TestHost {
425
428
  * @param directory - The package directory (holding `locales/`).
426
429
  * @since 1.5.9
427
430
  *
428
- * @capability None.
429
- *
430
431
  * @example Load the translations after changing the language
431
432
  * The test switches the host to German before starting the plugin and
432
433
  * loads that catalog itself (`startPlugin` does the same). Texts are then
@@ -463,8 +464,6 @@ export class TestHost {
463
464
  * ```
464
465
  *
465
466
  * @since 1.5.9
466
- *
467
- * @capability None.
468
467
  */
469
468
  translate(text, args) {
470
469
  return translate(this, this.#inner, text, args);
@@ -483,11 +482,9 @@ export class TestHost {
483
482
  * @param language - `"system"` or a locale.
484
483
  * @since 1.5.9
485
484
  *
486
- * @capability None.
487
- *
488
485
  * @example Simulate the user choosing French for the next start
489
486
  * The plugin hears that the saved interface language changed. The host
490
- * pushes `appearance.changed`, which a plugin with `events` sees in
487
+ * pushes `appearance.changed`, which a plugin sees (after `plugin.player.subscribe()`) in
491
488
  * `appearance.language` once it has read it and subscribed; this run's
492
489
  * language does not change.
493
490
  * ```ts
@@ -705,7 +702,6 @@ export class TestHost {
705
702
  * assert.equal(plugin.timeline.ranges[0]?.plugin, "community.clips");
706
703
  * ```
707
704
  *
708
- * @capability None.
709
705
  * @since 1.6.9
710
706
  */
711
707
  setTimelineRanges(pluginId, ranges) {
@@ -721,8 +717,8 @@ export class TestHost {
721
717
  * @example Let another plugin publish chapters
722
718
  * The plugin under test sees two chapter marks another plugin put on the
723
719
  * timeline. `setTimelineLayer` stores that plugin's whole layer and pushes
724
- * `timeline.changed`; once the plugin uses `plugin.timeline` (with
725
- * `events`) the SDK keeps `marks` current from that event, and `settle()`
720
+ * `timeline.changed`; once the plugin uses `plugin.timeline` (after
721
+ * `plugin.player.subscribe()`) the SDK keeps `marks` current from that event, and `settle()`
726
722
  * lets it arrive.
727
723
  * ```ts
728
724
  * import assert from "node:assert/strict";
@@ -736,7 +732,6 @@ export class TestHost {
736
732
  * assert.equal(plugin.timeline.marks.length, 2);
737
733
  * ```
738
734
  *
739
- * @capability None.
740
735
  * @since 1.0.0
741
736
  */
742
737
  setTimelineLayer(pluginId, marks) {
@@ -770,7 +765,6 @@ export class TestHost {
770
765
  * );
771
766
  * ```
772
767
  *
773
- * @capability None.
774
768
  * @since 1.0.0
775
769
  */
776
770
  imagePath(value) {
@@ -816,7 +810,6 @@ export class TestHost {
816
810
  * });
817
811
  * ```
818
812
  *
819
- * @capability None.
820
813
  * @throws Never: files nobody takes are ignored, as in the player.
821
814
  * @since 1.0.0
822
815
  */
@@ -829,17 +822,15 @@ export class TestHost {
829
822
  * Simulate another plugin switching the palette: updates
830
823
  * {@link TestHost.appearance} and pushes `appearance.changed`.
831
824
  *
832
- * @capability None.
833
- *
834
825
  * @example Simulate another plugin switching to the light palette
835
826
  * The plugin hears the palette change. The host updates `appearance` and
836
- * pushes `appearance.changed` to a plugin that listens with `events`.
827
+ * pushes `appearance.changed` to a plugin that listens (after `plugin.player.subscribe()`).
837
828
  * ```ts
838
829
  * import assert from "node:assert/strict";
839
830
  * declare const host: TestHost;
840
831
  * // ---cut---
841
832
  * const themes: string[] = [];
842
- * plugin.player.on("appearance.changed", ({ theme }) => themes.push(theme)); // subscribes (`events`)
833
+ * plugin.player.on("appearance.changed", ({ theme }) => themes.push(theme)); // subscribes
843
834
  * host.setAppearance("vestra-light");
844
835
  * await host.settle();
845
836
  * assert.deepEqual(themes, ["vestra-light"]);
@@ -883,7 +874,6 @@ export class TestHost {
883
874
  * assert.equal(page.props["step"], 10);
884
875
  * ```
885
876
  *
886
- * @capability None.
887
877
  * @since 1.0.0
888
878
  */
889
879
  settingsPage(id) {
@@ -898,8 +888,6 @@ export class TestHost {
898
888
  * Simulate the backdrop's `effective` changing (`false`: a video frame
899
889
  * appeared; `true`: there is none again); pushed to the plugin.
900
890
  *
901
- * @capability None.
902
- *
903
891
  * @example Make a video picture replace the backdrop
904
892
  * The plugin's backdrop hears that a video frame now covers it. `false`
905
893
  * means a picture appeared; the change is pushed like the player's
@@ -950,8 +938,6 @@ export class TestHost {
950
938
  * ```
951
939
  *
952
940
  * @since 1.5.2
953
- *
954
- * @capability None.
955
941
  */
956
942
  mountOther(slot, plugin, options = {}) {
957
943
  return mountOther(this, this.#inner, slot, plugin, options);
@@ -962,8 +948,6 @@ export class TestHost {
962
948
  *
963
949
  * @since 1.5.2
964
950
  *
965
- * @capability None.
966
- *
967
951
  * @example Let the playlist's tab go away
968
952
  * The other plugin's sidebar tab disappears and the plugin's own tab
969
953
  * becomes current. When the removed tab was current, the next tab (else
@@ -987,8 +971,6 @@ export class TestHost {
987
971
  *
988
972
  * @since 1.5.2
989
973
  *
990
- * @capability None.
991
- *
992
974
  * @example Click another plugin's sidebar tab
993
975
  * The user switches the sidebar to the playlist; the plugin's panel is in
994
976
  * a background tab now. The change is pushed as `window.state`.
@@ -1022,8 +1004,6 @@ export class TestHost {
1022
1004
  * `video.view()` then fails with `conflict`), or, with `null`, releasing
1023
1005
  * it (values reset to the defaults).
1024
1006
  *
1025
- * @capability None.
1026
- *
1027
1007
  * @example Let another plugin own the display layer
1028
1008
  * The plugin's `video.view()` fails with `conflict` because another plugin
1029
1009
  * took the display layer first. `null` releases it again.
@@ -1056,8 +1036,6 @@ export class TestHost {
1056
1036
  * `video.render()` then fails with `conflict`), or, with `null`, releasing
1057
1037
  * them (values reset to the defaults).
1058
1038
  *
1059
- * @capability None.
1060
- *
1061
1039
  * @example Let another plugin own the render options
1062
1040
  * The plugin's render options report `conflict` while another plugin owns
1063
1041
  * them; `null` releases them and resets the values to the defaults.
@@ -1105,7 +1083,6 @@ export class TestHost {
1105
1083
  * assert.equal(render.status.state, "failed");
1106
1084
  * ```
1107
1085
  *
1108
- * @capability None.
1109
1086
  * @since 1.0.0
1110
1087
  */
1111
1088
  failVideoRender(code, message) {
@@ -1143,8 +1120,6 @@ export class TestHost {
1143
1120
  * player never pushes it, it refuses the `set` request itself after
1144
1121
  * an abnormal end. To test that, set {@link TestHost.previousCrash}.
1145
1122
  *
1146
- * @capability None.
1147
- *
1148
1123
  * @example Make the plugin's shader fail to compile
1149
1124
  * The plugin's shader handle reports `failed`, as when mpv rejects a
1150
1125
  * shader. The host pushes the failure only to a handle that holds
@@ -1342,8 +1317,6 @@ export class TestHost {
1342
1317
  * plugin's file resolvers and of {@link TestHost.otherResolvers}, sorted,
1343
1318
  * each once.
1344
1319
  *
1345
- * @capability None.
1346
- *
1347
1320
  * @example Check the file types a resolver adds
1348
1321
  * The test checks the list the plugin will hear in
1349
1322
  * `resolvers.fileTypes`: the extensions of its own file resolvers and of
@@ -1384,7 +1357,7 @@ export class TestHost {
1384
1357
  * declare const host: TestHost;
1385
1358
  * // ---cut---
1386
1359
  * const heard: string[][] = [];
1387
- * // A listener of the event (`events`): each list the player sends.
1360
+ * // A listener of the event: each list the player sends.
1388
1361
  * plugin.player.on("resolvers.fileTypes", ({ fileTypes }) => heard.push(fileTypes));
1389
1362
  * // Another plugin starts with a resolver for .ch8 files.
1390
1363
  * host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
@@ -1393,7 +1366,6 @@ export class TestHost {
1393
1366
  * assert.deepEqual(heard, [["ch8"]]);
1394
1367
  * ```
1395
1368
  *
1396
- * @capability None.
1397
1369
  * @since 1.5.8
1398
1370
  */
1399
1371
  updateFileTypes() {
@@ -1507,8 +1479,6 @@ export class TestHost {
1507
1479
  * @param name - The property, as mpv names it.
1508
1480
  * @param value - Its new value.
1509
1481
  *
1510
- * @capability None.
1511
- *
1512
1482
  * @example The frame rate behind the filters changes
1513
1483
  * The plugin's listener hears the value the test gives the property.
1514
1484
  * `setMpvProperty` stores it and sends the `mpv.property` event that
@@ -1583,7 +1553,7 @@ export class TestHost {
1583
1553
  components: {
1584
1554
  mpv: "mpv 0.41.0",
1585
1555
  libav: { ffmpeg: "7.1" },
1586
- slint: "1.18.1",
1556
+ slint: PLAYER_SLINT,
1587
1557
  },
1588
1558
  };
1589
1559
  /**
@@ -1728,7 +1698,6 @@ export class TestHost {
1728
1698
  * assert.match(String(host.window("upscale").props.blocker), /Picture Adjustments/);
1729
1699
  * ```
1730
1700
  *
1731
- * @capability None.
1732
1701
  * @since 1.5.43
1733
1702
  */
1734
1703
  upscalingDecoding(cause, plugins = []) {
@@ -1740,8 +1709,6 @@ export class TestHost {
1740
1709
  * plugin listening with `plugin.video.upscaling.onChange` receives it.
1741
1710
  * Nothing reaches a plugin that does not listen.
1742
1711
  *
1743
- * @capability None.
1744
- *
1745
1712
  * @example Show the new factor in the plugin's window
1746
1713
  * The window resized: the test changes the area and the factor, sends
1747
1714
  * the change, and checks that the plugin's window shows the new factor.
@@ -1816,8 +1783,6 @@ export class TestHost {
1816
1783
  * plugin listening with `plugin.video.motion("amd").onChange` receives it.
1817
1784
  * Nothing reaches a plugin that does not listen.
1818
1785
  *
1819
- * @capability None.
1820
- *
1821
1786
  * @example The GPU fell behind
1822
1787
  * The player turned the converter off for this video; the plugin's
1823
1788
  * panel shows the reason.
@@ -1958,9 +1923,9 @@ export class TestHost {
1958
1923
  // ------------------------------------------------------------ built-in only
1959
1924
  /**
1960
1925
  * The plugin is built into the player (`startPlugin`'s `builtin`). Only
1961
- * then does the host take the built-in-only capabilities
1962
- * (`commands.run`, `palette.lead`); otherwise their calls fail with
1963
- * `capability`, as in the player.
1926
+ * then does the host answer the built-in-only requests
1927
+ * (`commands.list`, `commands.run`, `palette.lead.*`); otherwise they
1928
+ * fail with `capability`, as in the player.
1964
1929
  *
1965
1930
  * @since 1.7.9
1966
1931
  */
@@ -2016,7 +1981,6 @@ export class TestHost {
2016
1981
  * await stop();
2017
1982
  * ```
2018
1983
  *
2019
- * @capability None.
2020
1984
  * @throws `Error` without a code (rejects) The plugin has no lead row.
2021
1985
  * @since 1.7.9
2022
1986
  */
@@ -2046,7 +2010,6 @@ export class TestHost {
2046
2010
  * assert.deepEqual(host.coreRuns, ["play-pause"]);
2047
2011
  * ```
2048
2012
  *
2049
- * @capability None.
2050
2013
  * @since 1.0.0
2051
2014
  */
2052
2015
  coreAction(id) {
@@ -2127,7 +2090,6 @@ export class TestHost {
2127
2090
  * host.reset("system.openPath");
2128
2091
  * ```
2129
2092
  *
2130
- * @capability None.
2131
2093
  * @since 1.0.0
2132
2094
  */
2133
2095
  handle(method, handler) {
@@ -2136,8 +2098,6 @@ export class TestHost {
2136
2098
  /**
2137
2099
  * Restore the default behaviour of a method replaced with {@link TestHost.handle}.
2138
2100
  *
2139
- * @capability None.
2140
- *
2141
2101
  * @example Restore the default answer after a simulated failure
2142
2102
  * The first write fails, the second succeeds. `reset` removes the handler
2143
2103
  * that `handle` installed, so the method is answered by the test host
@@ -2163,14 +2123,12 @@ export class TestHost {
2163
2123
  * Deliver a host event to the plugin. Like the player, subscription-based
2164
2124
  * events (`source.state`, `playback.backend`, `window.state`,
2165
2125
  * `timeline.changed`, `appearance.changed`) are delivered only when the
2166
- * plugin subscribed (it declared `events` and listens). Most tests use the
2126
+ * plugin subscribed (it called `plugin.player.subscribe()` and listens). Most tests use the
2167
2127
  * higher-level helpers (`setSource`, `setMainWindow`, ...) instead.
2168
2128
  *
2169
2129
  * @param event - The wire event name.
2170
2130
  * @param data - The event payload (wire-level shape).
2171
2131
  *
2172
- * @capability None.
2173
- *
2174
2132
  * @example Deliver a raw event the helpers do not cover
2175
2133
  * The test pushes a `window.state` event after changing `layout` by hand.
2176
2134
  * Like the player, the host delivers it only when the plugin subscribed;
@@ -2219,7 +2177,6 @@ export class TestHost {
2219
2177
  * await host.settle();
2220
2178
  * ```
2221
2179
  *
2222
- * @capability None.
2223
2180
  * @since 1.0.0
2224
2181
  */
2225
2182
  setSource(patch) {
@@ -2254,7 +2211,6 @@ export class TestHost {
2254
2211
  * assert.equal(plugin.window.state.maximized, true);
2255
2212
  * ```
2256
2213
  *
2257
- * @capability None.
2258
2214
  * @since 1.0.0
2259
2215
  */
2260
2216
  setMainWindow(patch) {
@@ -2266,8 +2222,6 @@ export class TestHost {
2266
2222
  * those switched on, pop out or collapse (reference §6.3). No effect outside
2267
2223
  * fullscreen, or on a column switched off or floating.
2268
2224
  *
2269
- * @capability None.
2270
- *
2271
2225
  * @example Pop the sidebar out in fullscreen
2272
2226
  * The pointer reaches the right edge in fullscreen and the attached
2273
2227
  * sidebar pops out over the video. Outside fullscreen, or with the
@@ -2317,7 +2271,6 @@ export class TestHost {
2317
2271
  * assert.equal(plugin.player.isCurrent(before), false);
2318
2272
  * ```
2319
2273
  *
2320
- * @capability None.
2321
2274
  * @since 1.0.0
2322
2275
  */
2323
2276
  openElsewhere(source, phase = "ready") {
@@ -2351,7 +2304,6 @@ export class TestHost {
2351
2304
  * host.failStream(producer!.id, "producer transport closed");
2352
2305
  * ```
2353
2306
  *
2354
- * @capability None.
2355
2307
  * @since 1.5.7
2356
2308
  */
2357
2309
  failStream(producerId, message) {
@@ -2387,7 +2339,6 @@ export class TestHost {
2387
2339
  * await host.press("Delete", { panel: true }); // while the panel has focus
2388
2340
  * ```
2389
2341
  *
2390
- * @capability None.
2391
2342
  * @throws `command` (rejects) A `HostError`: the command that would run is
2392
2343
  * busy (the player only logs this).
2393
2344
  * @throws `Error` (rejects) Nothing is bound to the key.
@@ -2440,7 +2391,6 @@ export class TestHost {
2440
2391
  * assert.equal(host.window("picture").props["brightness-down"], "⇧W");
2441
2392
  * ```
2442
2393
  *
2443
- * @capability None.
2444
2394
  * @throws `Error` `command` is neither a command of the plugin nor a
2445
2395
  * core command.
2446
2396
  * @since 1.6.6
@@ -2493,7 +2443,7 @@ export class TestHost {
2493
2443
  * // ---cut---
2494
2444
  * host.candidates.set("/downloads/someone.demo-1.0.0.vxp", {
2495
2445
  * id: "someone.demo", version: "1.0.0", apiVersion: "vestra/1",
2496
- * entry: "main.js", capabilities: [],
2446
+ * entry: "main.js",
2497
2447
  * });
2498
2448
  * ```
2499
2449
  */
@@ -2515,7 +2465,6 @@ export class TestHost {
2515
2465
  * host.installKeepsDisabled = false; // every install runs
2516
2466
  * ```
2517
2467
  *
2518
- * @capability None.
2519
2468
  * @since 1.5.55
2520
2469
  */
2521
2470
  installKeepsDisabled = true;
@@ -2544,7 +2493,6 @@ export class TestHost {
2544
2493
  * assert.equal(host.markdown(rows[0]!.body)?.text, "**Hello**");
2545
2494
  * ```
2546
2495
  *
2547
- * @capability None.
2548
2496
  * @since 1.1.0
2549
2497
  */
2550
2498
  markdown(value) {
@@ -2563,8 +2511,6 @@ export class TestHost {
2563
2511
  * Replace the plugin list and push `packages.changed` (another plugin
2564
2512
  * started, stopped, was installed or removed).
2565
2513
  *
2566
- * @capability None.
2567
- *
2568
2514
  * @example Simulate another plugin starting
2569
2515
  * The plugin's store window hears that a plugin is running now. The list
2570
2516
  * replaces `packages` and is pushed as `packages.changed`, which the
@@ -2587,7 +2533,6 @@ export class TestHost {
2587
2533
  * asks this plugin's sequence provider. Rejects with `unavailable` when
2588
2534
  * there is no provider or its flag is false.
2589
2535
  *
2590
- * @capability None.
2591
2536
  * @throws `unavailable` (rejects) A `HostError`: there is no sequence
2592
2537
  * provider, or its flag is false.
2593
2538
  *
@@ -2613,8 +2558,6 @@ export class TestHost {
2613
2558
  * The plugin's command with this local id. Throws when it is not
2614
2559
  * registered (never added, or disposed).
2615
2560
  *
2616
- * @capability None.
2617
- *
2618
2561
  * @example Read a command's state after a change
2619
2562
  * The test checks that Export becomes enabled once a file is ready. The
2620
2563
  * record is updated as the plugin sends new state; read it after
@@ -2683,7 +2626,6 @@ export class TestHost {
2683
2626
  * assert.equal(host.window("picture").props["brightness"], 0);
2684
2627
  * ```
2685
2628
  *
2686
- * @capability None.
2687
2629
  * @since 1.0.0
2688
2630
  */
2689
2631
  window(id) {
@@ -2713,7 +2655,6 @@ export class TestHost {
2713
2655
  * await host.settle();
2714
2656
  * ```
2715
2657
  *
2716
- * @capability None.
2717
2658
  * @since 1.0.0
2718
2659
  */
2719
2660
  mounted(slot) {
@@ -2733,7 +2674,6 @@ export class TestHost {
2733
2674
  * assert.deepEqual(host.sent("osd.show").at(-1), { text: "Saved" });
2734
2675
  * ```
2735
2676
  *
2736
- * @capability None.
2737
2677
  * @since 1.0.0
2738
2678
  */
2739
2679
  sent(method) {
@@ -2792,7 +2732,6 @@ export class TestHost {
2792
2732
  * assert.equal(importWindow.props["status-text"], expected);
2793
2733
  * ```
2794
2734
  *
2795
- * @capability None.
2796
2735
  * @throws Never.
2797
2736
  * @since 1.0.0
2798
2737
  */
@@ -2806,8 +2745,6 @@ export class TestHost {
2806
2745
  * `ENOTEMPTY`, `EBUSY`, `EPERM`) is retried for about 1.5 s, then left
2807
2746
  * for the system to clean, with a warning on the console.
2808
2747
  *
2809
- * @capability None.
2810
- *
2811
2748
  * @example Clean up a host that was never started
2812
2749
  * A test that made a host but failed before `startPlugin` removes the
2813
2750
  * host's temporary directories itself. `stop()` from `startPlugin` calls
@@ -2840,7 +2777,6 @@ export class TestHost {
2840
2777
  * and start it again on its next use. Filter chains, streams, jobs and the
2841
2778
  * like (which also keep a plugin running) are not listed.
2842
2779
  *
2843
- * @capability None.
2844
2780
  * @since 1.5.40
2845
2781
  *
2846
2782
  * @example Check that a plugin can be stopped while idle
@@ -2859,7 +2795,125 @@ export class TestHost {
2859
2795
  get keepsRunning() {
2860
2796
  return keepsRunning(this, this.#inner);
2861
2797
  }
2798
+ // ------------------------------------------------------------ triggers
2799
+ /**
2800
+ * The trigger conditions the player keeps for this plugin
2801
+ * (`plugin.trigger().firesOn`), in the wire form, with their sequence
2802
+ * numbers and whether each holds now. They stay through
2803
+ * {@link TestHost.park}; {@link TestHost.upgrade} clears the unnamed ones.
2804
+ *
2805
+ * @since 1.10.0
2806
+ */
2807
+ get triggers() {
2808
+ return keptTriggers(this);
2809
+ }
2810
+ /**
2811
+ * The test host's wall clock (Unix milliseconds), which `when.time`
2812
+ * conditions read. It starts at the real time; it moves only with
2813
+ * {@link TestHost.advance}, or when a test sets it.
2814
+ *
2815
+ * @since 1.10.0
2816
+ */
2817
+ get now() {
2818
+ return triggerState(this).now;
2819
+ }
2820
+ /**
2821
+ * Set the clock to `value` (Unix milliseconds). Only the clock moves:
2822
+ * the kept conditions see the new time at their next evaluation, on
2823
+ * {@link TestHost.advance} or a state the test pushes.
2824
+ */
2825
+ set now(value) {
2826
+ triggerState(this).now = value;
2827
+ }
2828
+ /**
2829
+ * Move the clock by `ms` milliseconds and, while the source plays
2830
+ * (`phase` `ready`, not paused), the position by `rate × ms`. Each
2831
+ * position boundary and time bound a kept condition waits for is passed
2832
+ * in its order: an `enter` or `leave` runs with the clock and the position
2833
+ * where the player would call it, and the test does not wait. The new
2834
+ * position is then pushed as `source.state`.
2835
+ *
2836
+ * @example A silence is entered 2 s before it starts
2837
+ * The source plays from 0, and the plugin's position condition has a
2838
+ * lead of 2 s before a range at 10 s. Advancing 8 s of clock plays 8 s
2839
+ * of media, so the trigger's `enter` runs on the way, at 8 s.
2840
+ * ```ts
2841
+ * import assert from "node:assert/strict";
2842
+ * declare const host: TestHost;
2843
+ * // ---cut---
2844
+ * host.setSource({ phase: "ready", duration: 60, position: 0 });
2845
+ * // … the plugin gave when.position.in([{ start: 10, end: 12 }], { lead: 2 })
2846
+ * await host.advance(8_000); // its enter ran at 8 s
2847
+ * ```
2848
+ *
2849
+ * @throws `TypeError` (rejects) `ms` is not a number of 0 or more.
2850
+ * @since 1.10.0
2851
+ */
2852
+ advance(ms) {
2853
+ return advance(this, this.#inner, ms);
2854
+ }
2855
+ /**
2856
+ * The player puts the plugin in standby: it is stopped (reason
2857
+ * `idle`); its trigger conditions and the wake events it listens to are
2858
+ * kept. A condition that flips, or a wake event, starts it again
2859
+ * (`activate()` runs anew) and delivers what waited, in order; the
2860
+ * conditions given again by `activate()` change nothing.
2861
+ *
2862
+ * @throws `Error` without a code (rejects) The plugin was not started
2863
+ * with {@link startPlugin}.
2864
+ *
2865
+ * @example A trigger condition outlives standby
2866
+ * The test puts a plugin that armed one trigger in standby, as the
2867
+ * player does when nothing uses it, and checks that the player still
2868
+ * keeps the condition that will start the plugin again.
2869
+ * ```ts
2870
+ * import assert from "node:assert/strict";
2871
+ * declare const host: TestHost;
2872
+ * // ---cut---
2873
+ * await host.park(); // stopped with reason "idle"
2874
+ * assert.equal(host.parked, true);
2875
+ * assert.equal(host.triggers.length, 1);
2876
+ * ```
2877
+ *
2878
+ * @since 1.10.0
2879
+ */
2880
+ park() {
2881
+ return park(this, this.#inner);
2882
+ }
2883
+ /** The plugin is in standby ({@link TestHost.park}) and not started again yet. */
2884
+ get parked() {
2885
+ return triggerState(this).parked;
2886
+ }
2887
+ /**
2888
+ * Another version replaces the plugin: it is stopped (reason
2889
+ * `upgrade`), the conditions of its unnamed triggers are cleared, the
2890
+ * named ones kept, and it starts again with `activate` (the new
2891
+ * version's code; default: the same). A name the new version does not
2892
+ * declare is dropped when it starts.
2893
+ *
2894
+ * @throws `Error` without a code (rejects) The plugin was not started
2895
+ * with {@link startPlugin}.
2896
+ *
2897
+ * @example A named sleep timer survives an update
2898
+ * The test arms the plugin's sleep timer from its command, replaces the
2899
+ * plugin with the same code as a new version, and checks that the
2900
+ * player still keeps the condition of the trigger named `sleep`.
2901
+ * ```ts
2902
+ * import assert from "node:assert/strict";
2903
+ * declare const host: TestHost;
2904
+ * // ---cut---
2905
+ * await host.command("in45").run();
2906
+ * await host.upgrade(); // the same activate, as the new version
2907
+ * assert.ok(host.triggers.some((kept) => kept.trigger === "sleep"));
2908
+ * ```
2909
+ *
2910
+ * @since 1.10.0
2911
+ */
2912
+ upgrade(activate) {
2913
+ return upgrade(this, this.#inner, activate);
2914
+ }
2862
2915
  #defaults = {
2916
+ ...triggersHandlers(this, this.#inner),
2863
2917
  ...transportHandlers(this, this.#inner),
2864
2918
  ...commandsHandlers(this, this.#inner),
2865
2919
  ...builtinHandlers(this, this.#inner),
@@ -2880,18 +2934,16 @@ export class TestHost {
2880
2934
  * registration started during activation (commands, panels, resolvers, ...),
2881
2935
  * then wait until the host is idle.
2882
2936
  *
2883
- * The manifest id and capabilities come from `directory/manifest.json`
2884
- * unless `capabilities` is given; then `id` (default `"test.plugin"`) and
2885
- * `capabilities` are used and no manifest is read. The test host does not
2886
- * apply the player's capability table to every request: the members that
2887
- * check a capability on the plugin's side (`plugin.media.sources` and its
2888
- * `open`, which also needs `playback.control`, `plugin.secrets`, timeline
2889
- * marks, video shaders and views, among others) fail with `capability` as in
2890
- * the player, but a call the player refuses for an undeclared capability can
2891
- * succeed here. `vestra-plugin check` (and the TypeScript plugin) reports
2892
- * those calls from the sources.
2937
+ * The manifest id comes from `directory/manifest.json` unless `id` is
2938
+ * given; then no manifest is read (and without `directory` none is read
2939
+ * either: the id is `"test.plugin"`). Nothing in the manifest changes how
2940
+ * the plugin runs: event delivery and the start-up reads are the plugin's
2941
+ * own calls (`plugin.player.subscribe()`, `plugin.player.read()`), as in
2942
+ * the player.
2893
2943
  *
2894
- * Rejects when `manifest.json` cannot be read or parsed, when `activate`
2944
+ * Rejects when `manifest.json` cannot be read or parsed, when it still has
2945
+ * `capabilities` (removed in 1.9.0; the message says what to call
2946
+ * instead), when `activate`
2895
2947
  * throws, or when a registration made during activation fails (for example
2896
2948
  * `limit`, `conflict`, `invalid`). Stricter than the player's runner for
2897
2949
  * commands: there the SDK logs a command declaration the player refuses during
@@ -2953,7 +3005,6 @@ export class TestHost {
2953
3005
  * player's runner does and returns the host to drive, the `plugin` object
2954
3006
  * to call directly, and `stop` to end it like the player.
2955
3007
  *
2956
- * @capability None.
2957
3008
  * @see [Test a plugin](../../../docs/guides/testing.md)
2958
3009
  * @since 1.0.0
2959
3010
  * @category Testing
@@ -2965,16 +3016,15 @@ export async function startPlugin(activate, options = {}) {
2965
3016
  const directory = options.directory instanceof URL
2966
3017
  ? fileURLToPath(options.directory)
2967
3018
  : (options.directory ?? process.cwd());
2968
- let manifest = {
2969
- id: options.id ?? "test.plugin",
2970
- capabilities: options.capabilities ?? [],
2971
- };
2972
- if (options.directory && !options.capabilities) {
3019
+ let manifest = { id: options.id ?? "test.plugin" };
3020
+ if (options.directory && options.id === undefined) {
2973
3021
  const read = JSON.parse(readFileSync(join(directory, "manifest.json"), "utf8"));
2974
- manifest = { id: read.id, capabilities: read.capabilities };
3022
+ // As `vestra-plugin check` and the player: the field is gone.
3023
+ if (read && typeof read === "object" && "capabilities" in read)
3024
+ throw new Error(CAPABILITIES_REMOVED);
3025
+ manifest = { id: read.id };
2975
3026
  }
2976
3027
  host.manifestId = manifest.id;
2977
- pluginCapabilities.set(host, manifest.capabilities);
2978
3028
  if (options.builtin)
2979
3029
  host.builtin = true;
2980
3030
  host.loadCatalog(directory);
@@ -2987,26 +3037,42 @@ export async function startPlugin(activate, options = {}) {
2987
3037
  mkdirSync(data, { recursive: true });
2988
3038
  if (host.fileRoots.length === 0)
2989
3039
  host.fileRoots = [directory, data];
2990
- const instance = await createPlugin(host, manifest, directory, data,
2991
- // Like the player: protocol additions it takes (`app.features` set on
2992
- // the host replaces them, e.g. `[]` for an older player's behaviour).
2993
- { features: [PATCH_FEATURE], ...host.app },
2994
- // Unlike the player's runner, which logs a refused command declaration
2995
- // and activates the rest: a plugin's tests show the refusal.
2996
- { strictDeclarations: true });
2997
- await activate(instance.plugin);
2998
- // Like the player: a position or resolver another plugin holds is not an
2999
- // activation failure.
3000
- for (;;) {
3001
- try {
3002
- await instance.activated();
3003
- break;
3004
- }
3005
- catch (error) {
3006
- if (!(error instanceof Error && takenErrors.has(error)))
3007
- throw error;
3040
+ // One run of the plugin; `park` and `upgrade` (1.10.0) start another.
3041
+ const run = async (entry) => {
3042
+ const started = await createPlugin(host, manifest, directory, data,
3043
+ // Like the player: protocol additions it takes (`app.features` set on
3044
+ // the host replaces them, e.g. `[]` for an older player's behaviour).
3045
+ { features: [PATCH_FEATURE], ...host.app },
3046
+ // Unlike the player's runner, which logs a refused command declaration
3047
+ // and activates the rest: a plugin's tests show the refusal.
3048
+ { strictDeclarations: true });
3049
+ await started.activate(entry);
3050
+ // Like the player: a position or resolver another plugin holds is not an
3051
+ // activation failure.
3052
+ for (;;) {
3053
+ try {
3054
+ await started.activated();
3055
+ break;
3056
+ }
3057
+ catch (error) {
3058
+ if (!(error instanceof Error && takenErrors.has(error)))
3059
+ throw error;
3060
+ }
3008
3061
  }
3009
- }
3062
+ return started;
3063
+ };
3064
+ let instance = await run(activate);
3065
+ const triggers = triggerState(host);
3066
+ let code = activate;
3067
+ triggers.start = async (entry) => {
3068
+ if (entry)
3069
+ code = entry;
3070
+ instance = await run(code);
3071
+ };
3072
+ triggers.stop = async (reason) => {
3073
+ await instance.dispose({ reason });
3074
+ await host.settle();
3075
+ };
3010
3076
  await host.settle();
3011
3077
  tellResidency(host);
3012
3078
  // Zero declared parameters (`stop.length === 0`) and a `()` overload, so
@@ -3019,7 +3085,14 @@ export async function startPlugin(activate, options = {}) {
3019
3085
  const reason = typeof first === "object" && first !== null && "reason" in first
3020
3086
  ? first.reason
3021
3087
  : undefined;
3022
- await instance.dispose({ reason });
3088
+ // Like the player: at a quit a running plugin hears its source end.
3089
+ const quit = reason === "quit" ? quitEvent(host.source) : null;
3090
+ if (quit) {
3091
+ host.emit("source.ended", structuredClone(quit));
3092
+ await host.settle();
3093
+ }
3094
+ if (!triggers.parked)
3095
+ await instance.dispose({ reason });
3023
3096
  await host.settle();
3024
3097
  host.close();
3025
3098
  };