@vestra-player/sdk 1.9.0 → 1.10.1
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 +44 -7
- package/bin/vestra-plugin.mjs +89 -8
- package/capability-scan.json +20 -0
- package/dist/api-requests.d.ts +4 -3
- package/dist/api-requests.js +11 -3
- package/dist/commands.js +1 -0
- package/dist/condition-table.d.ts +1889 -0
- package/dist/condition-table.js +562 -0
- package/dist/docs-tree.json.gz +0 -0
- package/dist/i18n-tools.d.ts +7 -0
- package/dist/i18n-tools.js +66 -3
- package/dist/player-runtime.d.ts +3 -0
- package/dist/player-runtime.js +3 -0
- package/dist/plugin/connection.d.ts +13 -2
- package/dist/plugin/connection.js +67 -4
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +13 -0
- package/dist/plugin/mpv.js +39 -5
- package/dist/plugin/player/events.d.ts +14 -5
- package/dist/plugin/player/events.js +19 -3
- package/dist/plugin/player.d.ts +16 -0
- package/dist/plugin/player.js +77 -1
- package/dist/plugin/scope.d.ts +4 -1
- package/dist/plugin/scope.js +8 -0
- package/dist/plugin/testing/commands.d.ts +5 -0
- package/dist/plugin/testing/commands.js +23 -24
- package/dist/plugin/testing/index.d.ts +134 -0
- package/dist/plugin/testing/index.js +180 -21
- package/dist/plugin/testing/media.d.ts +6 -0
- package/dist/plugin/testing/media.js +15 -2
- package/dist/plugin/testing/services.js +50 -1
- package/dist/plugin/testing/source-events.d.ts +28 -0
- package/dist/plugin/testing/source-events.js +66 -0
- package/dist/plugin/testing/transport.js +5 -0
- package/dist/plugin/testing/triggers.d.ts +82 -0
- package/dist/plugin/testing/triggers.js +448 -0
- package/dist/plugin/timeline.d.ts +3 -3
- package/dist/plugin/timeline.js +3 -3
- package/dist/plugin/triggers.d.ts +55 -0
- package/dist/plugin/triggers.js +233 -0
- package/dist/plugin/types/base.d.ts +117 -3
- package/dist/plugin/types/commands.d.ts +374 -1
- package/dist/plugin/types/packages.d.ts +10 -1
- package/dist/plugin/types/playback.d.ts +257 -9
- package/dist/plugin/types/services.d.ts +10 -4
- package/dist/plugin/when.d.ts +78 -4
- package/dist/plugin/when.js +182 -14
- package/dist/slint-version.d.ts +7 -0
- package/dist/slint-version.js +7 -0
- package/dist/wire.d.ts +18 -0
- package/dist/wire.js +12 -0
- package/llms.txt +4 -4
- package/package.json +2 -2
|
@@ -124,7 +124,7 @@ export interface TimelineLayer extends Disposable {
|
|
|
124
124
|
* marks. Disposing the layer, its scope or stopping the plugin removes both,
|
|
125
125
|
* and a new source clears every layer.
|
|
126
126
|
*
|
|
127
|
-
* At most
|
|
127
|
+
* At most 1000 ranges (`TIMELINE_LIMITS.ranges`), `0 ≤ start < end`, `end`
|
|
128
128
|
* within the media while its duration is known, titles ≤ 100 characters.
|
|
129
129
|
* Ranges may overlap. Failures go to `onError`; with `ifCurrent`, a
|
|
130
130
|
* write for another source is dropped silently. A title is data or a
|
|
@@ -260,6 +260,16 @@ export interface AudioTrack {
|
|
|
260
260
|
title: string | null;
|
|
261
261
|
/** Language tag, `null` when unknown. */
|
|
262
262
|
language: string | null;
|
|
263
|
+
/**
|
|
264
|
+
* The container stream number (`ffmpeg -map 0:<n>`) of an embedded track,
|
|
265
|
+
* when the player can vouch for it; `null` for external tracks and when
|
|
266
|
+
* the player cannot tell, as for a subtitle track. The SDK always sets
|
|
267
|
+
* it; it is optional only so that an `AudioTrack` written out in full
|
|
268
|
+
* before 1.10.0 (a test's fixture) still type-checks.
|
|
269
|
+
*
|
|
270
|
+
* @since 1.10.0
|
|
271
|
+
*/
|
|
272
|
+
streamIndex?: number | null;
|
|
263
273
|
}
|
|
264
274
|
/**
|
|
265
275
|
* An immutable view of the player. Keep one to make a later call conditional on it.
|
|
@@ -853,6 +863,45 @@ export interface PlaybackStats {
|
|
|
853
863
|
/** Seconds of media buffered ahead by the demuxer. */
|
|
854
864
|
cacheSeconds: number | null;
|
|
855
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* An open stream of the player's state ({@link Player.stream}).
|
|
868
|
+
*
|
|
869
|
+
* @remarks
|
|
870
|
+
* While it is open the player keeps the plugin running. It ends with
|
|
871
|
+
* {@link StateStream.stop}, when the scope that opened it is disposed, and
|
|
872
|
+
* when the plugin stops; it is not kept through standby.
|
|
873
|
+
*
|
|
874
|
+
* @example Follow the state while a panel is shown
|
|
875
|
+
* The stream lives only as long as what shows the state: it is opened
|
|
876
|
+
* with the scope of the panel's content and ends when that scope is
|
|
877
|
+
* disposed, so the plugin may go to standby afterwards.
|
|
878
|
+
* ```ts
|
|
879
|
+
* declare function draw(state: PlayerState): void;
|
|
880
|
+
* // ---cut---
|
|
881
|
+
* const shown = plugin.scope();
|
|
882
|
+
* shown.player.stream(draw); // stops when `shown` is disposed
|
|
883
|
+
* // … later, when the panel goes away:
|
|
884
|
+
* await shown.dispose();
|
|
885
|
+
* ```
|
|
886
|
+
*
|
|
887
|
+
* @since 1.10.0
|
|
888
|
+
* @category Playback
|
|
889
|
+
*/
|
|
890
|
+
export interface StateStream {
|
|
891
|
+
/**
|
|
892
|
+
* Stop the stream: its listener is not called again. A second call does
|
|
893
|
+
* nothing. When no other stream is open, nothing of the streams keeps the
|
|
894
|
+
* plugin running any more.
|
|
895
|
+
*
|
|
896
|
+
* @throws Never.
|
|
897
|
+
*
|
|
898
|
+
* @example See Player.stream
|
|
899
|
+
* {@link Player.stream}
|
|
900
|
+
*
|
|
901
|
+
* @since 1.10.0
|
|
902
|
+
*/
|
|
903
|
+
stop(): void;
|
|
904
|
+
}
|
|
856
905
|
/**
|
|
857
906
|
* `plugin.player`: playback state and controls.
|
|
858
907
|
*
|
|
@@ -925,6 +974,75 @@ export interface Player {
|
|
|
925
974
|
* @since 1.0.0
|
|
926
975
|
*/
|
|
927
976
|
onChange(listener: (state: PlayerState) => void): Disposable;
|
|
977
|
+
/**
|
|
978
|
+
* Follow the player's state while something needs it continuously: a
|
|
979
|
+
* window or panel that shows the position, a meter.
|
|
980
|
+
*
|
|
981
|
+
* @remarks
|
|
982
|
+
* `listener` runs with the current state as soon as the SDK has it (one
|
|
983
|
+
* read of the player's state right after the call), then with every
|
|
984
|
+
* change the player sends: about ten times a second while playing, at
|
|
985
|
+
* once when the phase, pause, speed or volume changes. Before each call
|
|
986
|
+
* the SDK updates {@link Player.state}; after each call an update pass
|
|
987
|
+
* runs, so {@link View.bind} functions and command states that read
|
|
988
|
+
* `plugin.player.state` follow the stream. It needs no
|
|
989
|
+
* {@link Player.subscribe}: the stream itself makes the state follow the
|
|
990
|
+
* player while it is open.
|
|
991
|
+
*
|
|
992
|
+
* **While a stream is open the player keeps the plugin running**: it is
|
|
993
|
+
* a listener (its log names it `a stream opened at main.ts:12`). Open it
|
|
994
|
+
* when the thing that shows the state appears and stop it when that goes
|
|
995
|
+
* away; nothing of a stopped stream keeps the plugin running. A plugin
|
|
996
|
+
* that only needs to know that something happened (a file opened, ready,
|
|
997
|
+
* ended) uses {@link Player.on} with a source event instead, which lets
|
|
998
|
+
* it go to standby.
|
|
999
|
+
*
|
|
1000
|
+
* Several streams may be open; each listener is called. A stream ends
|
|
1001
|
+
* with {@link StateStream.stop}, when its scope is disposed, and when the
|
|
1002
|
+
* plugin stops; it is not kept through standby. After the last one ends
|
|
1003
|
+
* `plugin.player.state` keeps the last snapshot, and without
|
|
1004
|
+
* {@link Player.subscribe} it no longer follows changes made elsewhere.
|
|
1005
|
+
* {@link Player.subscribe} and {@link Player.onChange} keep working as
|
|
1006
|
+
* before.
|
|
1007
|
+
*
|
|
1008
|
+
* The player judges what keeps a plugin running when the plugin becomes
|
|
1009
|
+
* ready. A stream that is open then counts as it does today for a
|
|
1010
|
+
* listener held at the ready: the plugin keeps running for that run, also
|
|
1011
|
+
* after the stream stops. Open the stream after `activate`, when what
|
|
1012
|
+
* shows the state appears.
|
|
1013
|
+
*
|
|
1014
|
+
* Errors the listener throws or rejects with go to
|
|
1015
|
+
* {@link Scope.onError}, as for every handler.
|
|
1016
|
+
*
|
|
1017
|
+
* @param listener - Receives the state now and at every change.
|
|
1018
|
+
* @returns The open stream; it is stopped with the scope.
|
|
1019
|
+
*
|
|
1020
|
+
* @throws `invalid` (throws) `listener` is not a function.
|
|
1021
|
+
*
|
|
1022
|
+
* @example Show the time left while a window is open
|
|
1023
|
+
* A tool window shows how much of the file is left, updated as it plays.
|
|
1024
|
+
* The stream starts when the window is shown and stops when the user
|
|
1025
|
+
* closes it, so the plugin can go to standby afterwards.
|
|
1026
|
+
* ```ts
|
|
1027
|
+
* const view = plugin.windows.create("ui/left.slint");
|
|
1028
|
+
* let feed: StateStream | undefined;
|
|
1029
|
+
* view.onClose(() => feed?.stop()); // closed: nothing keeps the plugin running
|
|
1030
|
+
* plugin.commands.add({
|
|
1031
|
+
* id: "left",
|
|
1032
|
+
* path: ["Tools", "Time Left"],
|
|
1033
|
+
* run: async () => {
|
|
1034
|
+
* await view.show();
|
|
1035
|
+
* feed?.stop(); // one stream per window, also when shown again
|
|
1036
|
+
* feed = plugin.player.stream((s) =>
|
|
1037
|
+
* view.set({ text: `${Math.round((s.duration ?? 0) - (s.position ?? 0))} s` }),
|
|
1038
|
+
* );
|
|
1039
|
+
* },
|
|
1040
|
+
* });
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
* @since 1.10.0
|
|
1044
|
+
*/
|
|
1045
|
+
stream(listener: (state: PlayerState) => void): StateStream;
|
|
928
1046
|
/**
|
|
929
1047
|
* Listen to one event of the player, with its data as the player sent
|
|
930
1048
|
* it: no state copy, no comparison.
|
|
@@ -987,6 +1105,45 @@ export interface Player {
|
|
|
987
1105
|
* @since 1.7.0
|
|
988
1106
|
*/
|
|
989
1107
|
on<E extends HostEvent>(event: E, listener: (data: EventPayload<E>) => void): Disposable;
|
|
1108
|
+
/**
|
|
1109
|
+
* Listen to one of the player's discrete source events: a source starts
|
|
1110
|
+
* to open, is ready, or ended.
|
|
1111
|
+
*
|
|
1112
|
+
* @remarks
|
|
1113
|
+
* `event` is a {@link SourceEvent} name; `listener` gets that event's
|
|
1114
|
+
* data, typed {@link SourceEventPayloads}, with `state` as a
|
|
1115
|
+
* {@link PlayerState}. The events arrive from the first listener,
|
|
1116
|
+
* without {@link Player.subscribe}, and a listener of one does not keep
|
|
1117
|
+
* the plugin running: the player starts a plugin in standby to deliver
|
|
1118
|
+
* them, and an event that arrives while the plugin starts waits for its
|
|
1119
|
+
* activation. `source.ended` with `reason: "quit"` reaches only a
|
|
1120
|
+
* plugin that is running when the player quits. As for every
|
|
1121
|
+
* {@link Player.on} listener, no full update pass follows it.
|
|
1122
|
+
*
|
|
1123
|
+
* @param event - The event's name.
|
|
1124
|
+
* @param listener - Receives each event's data.
|
|
1125
|
+
* @returns A handle that stops listening; it is disposed with the scope.
|
|
1126
|
+
*
|
|
1127
|
+
* @throws `invalid` (throws) `event` is not an event name, or
|
|
1128
|
+
* `listener` is not a function.
|
|
1129
|
+
*
|
|
1130
|
+
* @example Remember where each file was left
|
|
1131
|
+
* A plugin stores the position at which each file stopped playing. The
|
|
1132
|
+
* ended source's last state comes with the event, also when another
|
|
1133
|
+
* file replaced it.
|
|
1134
|
+
* ```ts
|
|
1135
|
+
* const saved = plugin.storage.json("positions", {
|
|
1136
|
+
* defaults: {} as Record<string, number>,
|
|
1137
|
+
* });
|
|
1138
|
+
* plugin.player.on("source.ended", ({ state, reason }) => {
|
|
1139
|
+
* if (reason === "natural" || state.source === null) return;
|
|
1140
|
+
* saved.save({ ...saved.value, [state.source]: state.position ?? 0 });
|
|
1141
|
+
* });
|
|
1142
|
+
* ```
|
|
1143
|
+
*
|
|
1144
|
+
* @since 1.10.0
|
|
1145
|
+
*/
|
|
1146
|
+
on<E extends SourceEvent>(event: E, listener: (data: SourceEventPayloads[E]) => void): Disposable;
|
|
990
1147
|
/**
|
|
991
1148
|
* Read the state from the player now.
|
|
992
1149
|
*
|
|
@@ -1781,6 +1938,91 @@ export interface EventPayloads {
|
|
|
1781
1938
|
* @category Playback
|
|
1782
1939
|
*/
|
|
1783
1940
|
export type EventPayload<E extends HostEvent> = EventPayloads[E];
|
|
1941
|
+
/**
|
|
1942
|
+
* The player's discrete source events: one event per thing that happened
|
|
1943
|
+
* to a source, which {@link Player.on} listens to by name.
|
|
1944
|
+
*
|
|
1945
|
+
* @remarks
|
|
1946
|
+
* `source.opening`: a new source starts to open. `source.ready`: it is
|
|
1947
|
+
* loaded. `source.ended`: it left playback. For one source the order is
|
|
1948
|
+
* `opening`, `ready`, `ended` (no `ready` when it could not be
|
|
1949
|
+
* opened); when a source is replaced, the old one's `ended` comes before
|
|
1950
|
+
* the new one's `opening`. Unlike `source.state` they arrive without
|
|
1951
|
+
* {@link Player.subscribe}, and a listener of one does not keep the plugin
|
|
1952
|
+
* running: the player starts a plugin in standby to deliver them.
|
|
1953
|
+
* {@link SourceEventPayloads} says what each one carries.
|
|
1954
|
+
*
|
|
1955
|
+
* @example Scan each file once it is loaded
|
|
1956
|
+
* A plugin looks at every file the player loads. The listener gets the
|
|
1957
|
+
* state at that moment, so the plugin needs no stream of its own and the
|
|
1958
|
+
* player may stop it between files.
|
|
1959
|
+
* ```ts
|
|
1960
|
+
* declare function scan(path: string): Promise<void>;
|
|
1961
|
+
* // ---cut---
|
|
1962
|
+
* plugin.player.on("source.ready", async ({ state }) => {
|
|
1963
|
+
* if (state.source !== null) await scan(state.source);
|
|
1964
|
+
* });
|
|
1965
|
+
* ```
|
|
1966
|
+
*
|
|
1967
|
+
* @since 1.10.0
|
|
1968
|
+
* @category Playback
|
|
1969
|
+
*/
|
|
1970
|
+
export type SourceEvent = "source.opening" | "source.ready" | "source.ended";
|
|
1971
|
+
/**
|
|
1972
|
+
* The data each {@link SourceEvent} carries, as the listener of
|
|
1973
|
+
* {@link Player.on} gets it.
|
|
1974
|
+
*
|
|
1975
|
+
* @remarks
|
|
1976
|
+
* `state` is the SDK's {@link PlayerState}, not the player's wire shape,
|
|
1977
|
+
* so it can be passed as `ifCurrent` and to {@link Player.isCurrent}.
|
|
1978
|
+
* The state of an opening or a ready is also taken into
|
|
1979
|
+
* `plugin.player.state` when it is newer than what the plugin has.
|
|
1980
|
+
*
|
|
1981
|
+
* @since 1.10.0
|
|
1982
|
+
* @category Playback
|
|
1983
|
+
*/
|
|
1984
|
+
export interface SourceEventPayloads {
|
|
1985
|
+
/**
|
|
1986
|
+
* A new source starts to open (also the same file again, and
|
|
1987
|
+
* {@link Player.restart}). `state` is the player's state at that moment,
|
|
1988
|
+
* as a {@link PlayerState} (pass it as `ifCurrent` or to
|
|
1989
|
+
* {@link Player.isCurrent}); `previous` names the source that was open
|
|
1990
|
+
* before it, `null` when nothing was.
|
|
1991
|
+
*/
|
|
1992
|
+
"source.opening": {
|
|
1993
|
+
/** The player's state as the source starts to open. */
|
|
1994
|
+
state: PlayerState;
|
|
1995
|
+
/** The source open before this one (`null`: nothing was open). */
|
|
1996
|
+
previous: {
|
|
1997
|
+
/** The previous source's id (`PlayerState.sourceId`). */
|
|
1998
|
+
sourceId: number;
|
|
1999
|
+
} | null;
|
|
2000
|
+
};
|
|
2001
|
+
/**
|
|
2002
|
+
* The source is loaded: its duration, tracks and seekability are known.
|
|
2003
|
+
* Once per opening, after its `source.opening`.
|
|
2004
|
+
*/
|
|
2005
|
+
"source.ready": {
|
|
2006
|
+
/** The player's state as the source became ready. */
|
|
2007
|
+
state: PlayerState;
|
|
2008
|
+
};
|
|
2009
|
+
/**
|
|
2010
|
+
* A source left playback: it played to its end (`natural`), was closed
|
|
2011
|
+
* (`stopped`), another source took its place (`replaced`), it could not
|
|
2012
|
+
* be played (`error`, with the failure text in `error`), or the player
|
|
2013
|
+
* quits (`quit`, sent only to a plugin that is running then). `state` is
|
|
2014
|
+
* **that** source's last state, with its last position, not the
|
|
2015
|
+
* player's current one.
|
|
2016
|
+
*/
|
|
2017
|
+
"source.ended": {
|
|
2018
|
+
/** The ended source's last state, as a {@link PlayerState}. */
|
|
2019
|
+
state: PlayerState;
|
|
2020
|
+
/** Why it left playback. */
|
|
2021
|
+
reason: "natural" | "stopped" | "replaced" | "error" | "quit";
|
|
2022
|
+
/** The failure text, when `reason` is `error` and the player has one. */
|
|
2023
|
+
error?: string;
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
1784
2026
|
/**
|
|
1785
2027
|
* A value of mpv, as JSON: what a property holds, a command returns or an
|
|
1786
2028
|
* argument of `set` is (mpv's "node": nothing, a flag, a number, a string,
|
|
@@ -1794,8 +2036,9 @@ export type MpvValue = null | boolean | number | string | MpvValue[] | {
|
|
|
1794
2036
|
};
|
|
1795
2037
|
/**
|
|
1796
2038
|
* `plugin.mpv`: mpv's own commands and properties, sent to the player's
|
|
1797
|
-
* mpv as they are.
|
|
1798
|
-
* user before installing
|
|
2039
|
+
* mpv as they are. The capability scan puts `command` and `set` in its
|
|
2040
|
+
* `player` category, which the store shows the user before installing
|
|
2041
|
+
* ([Capability scan](../../../docs/reference/scan.md)).
|
|
1799
2042
|
*
|
|
1800
2043
|
* @example Turn mpv's debanding on and show whether it took effect
|
|
1801
2044
|
* A plugin offers mpv's `deband` option, which the plugin API has no member
|
|
@@ -1838,9 +2081,11 @@ export type MpvValue = null | boolean | number | string | MpvValue[] | {
|
|
|
1838
2081
|
* the upscaler, motion smoothing) stay in the chain beside it.
|
|
1839
2082
|
*
|
|
1840
2083
|
* A property a plugin set keeps its value after the plugin stops, until
|
|
1841
|
-
* the player quits (what the
|
|
1842
|
-
* wants it back sets it back. Observers end with the plugin.
|
|
1843
|
-
* or an observer keeps the plugin running
|
|
2084
|
+
* the player quits (what the scan's `player` category discloses); a
|
|
2085
|
+
* plugin that wants it back sets it back. Observers end with the plugin.
|
|
2086
|
+
* A filter or an observer keeps the plugin running from the moment it is
|
|
2087
|
+
* added for the rest of that run, also after it is removed: the player
|
|
2088
|
+
* judges again at the plugin's next start.
|
|
1844
2089
|
*
|
|
1845
2090
|
* @see [mpv](../../../docs/reference/mpv.md)
|
|
1846
2091
|
* @since 1.8.0
|
|
@@ -1929,12 +2174,15 @@ export interface Mpv {
|
|
|
1929
2174
|
set(name: string, value: MpvValue): Promise<void>;
|
|
1930
2175
|
/**
|
|
1931
2176
|
* Hear an mpv property's value now and after each change. The player
|
|
1932
|
-
* sends the newest value at most every 100 ms.
|
|
1933
|
-
* the player keeps the plugin running
|
|
2177
|
+
* sends the newest value at most every 100 ms. From the first listener
|
|
2178
|
+
* on the player keeps the plugin running for the rest of the run, also
|
|
2179
|
+
* after the handle is disposed. As after every handler, an update pass
|
|
2180
|
+
* follows each call of the listener.
|
|
1934
2181
|
*
|
|
1935
2182
|
* @param name - The property, as mpv names it.
|
|
1936
2183
|
* @param listener - Receives the value: first the current one, then
|
|
1937
|
-
* each change.
|
|
2184
|
+
* each change. A listener added while the plugin already observes the
|
|
2185
|
+
* property gets its current value too, just after `observe` returns.
|
|
1938
2186
|
* @returns A handle that stops listening; it is disposed with the scope.
|
|
1939
2187
|
*
|
|
1940
2188
|
* @example Follow the frame rate after filters
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin, SystemInfo } from "./base.ts";
|
|
1
|
+
import type { AppInfo, Plugin, SystemInfo } from "./base.ts";
|
|
2
2
|
import type { RenderOptions } from "./processing.ts";
|
|
3
3
|
import type { Disposable } from "./base.ts";
|
|
4
4
|
/**
|
|
@@ -678,7 +678,9 @@ export interface System {
|
|
|
678
678
|
* Values are stored by the player in the system's secret store under this
|
|
679
679
|
* plugin's id: other plugins cannot read them. Names are 1–64 of
|
|
680
680
|
* `a-z 0-9 . _ -`, values 1–1024 bytes of text, at most 256 names per
|
|
681
|
-
* plugin (`SECRET_LIMITS`).
|
|
681
|
+
* plugin (`SECRET_LIMITS`). In a temporary window
|
|
682
|
+
* ({@link AppInfo.temporary}) `get` reads the main window's values and
|
|
683
|
+
* `set` and `delete` reject with `unavailable` (player 0.10.3).
|
|
682
684
|
*
|
|
683
685
|
* @since 1.0.0
|
|
684
686
|
* @category Services
|
|
@@ -715,7 +717,9 @@ export interface Secrets {
|
|
|
715
717
|
* @throws `limit` (rejects) A new name beyond 256.
|
|
716
718
|
* @throws `unsupported` (rejects) The system has no secret store.
|
|
717
719
|
* @throws `unavailable` (rejects) The store cannot be reached (no keychain,
|
|
718
|
-
* a read-only store, no logged-in session on Windows)
|
|
720
|
+
* a read-only store, no logged-in session on Windows), or the player is
|
|
721
|
+
* a temporary window ({@link AppInfo.temporary}, player 0.10.3), which
|
|
722
|
+
* reads the main window's secrets and saves none.
|
|
719
723
|
* @throws `failed` (rejects) The user denied access, or another system
|
|
720
724
|
* error.
|
|
721
725
|
*
|
|
@@ -741,7 +745,9 @@ export interface Secrets {
|
|
|
741
745
|
* @throws `invalid` (rejects) A bad name.
|
|
742
746
|
* @throws `unsupported` (rejects) The system has no secret store.
|
|
743
747
|
* @throws `unavailable` (rejects) The store cannot be reached (no keychain,
|
|
744
|
-
* a read-only store, no logged-in session on Windows)
|
|
748
|
+
* a read-only store, no logged-in session on Windows), or the player is
|
|
749
|
+
* a temporary window ({@link AppInfo.temporary}, player 0.10.3), which
|
|
750
|
+
* deletes none of the main window's secrets.
|
|
745
751
|
* @throws `failed` (rejects) The user denied access, or another system
|
|
746
752
|
* error.
|
|
747
753
|
*
|
package/dist/plugin/when.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `plugin.when`: conditions on the player's own state that the player
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* `plugin.when`: conditions on the player's own state that the player
|
|
3
|
+
* evaluates: a command's `enabled` and `checked`, and since 1.10.0 a
|
|
4
|
+
* trigger's condition (`plugin.trigger().firesOn`). The wire form is
|
|
5
|
+
* `commands.register` / `commands.update` `when` and `triggers.set` `when`.
|
|
5
6
|
*/
|
|
6
7
|
import type { Condition, LanguagePreference, PlayerState, ThemeId, When } from "./types.ts";
|
|
8
|
+
/** A numeric atom's interval: `min ≤ value < max`, at least one bound. */
|
|
9
|
+
export type IntervalJson = {
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
};
|
|
13
|
+
/** A position list in the wire form: `[start, end?]` pairs, and a lead. */
|
|
14
|
+
export type PositionJson = {
|
|
15
|
+
ranges: ([number] | [number, number | null])[];
|
|
16
|
+
lead?: number;
|
|
17
|
+
};
|
|
7
18
|
/** A condition in the wire form: an object of exactly one key. */
|
|
8
19
|
export type ConditionJson = {
|
|
9
20
|
phase: PlayerState["phase"][];
|
|
@@ -19,6 +30,30 @@ export type ConditionJson = {
|
|
|
19
30
|
theme: ThemeId;
|
|
20
31
|
} | {
|
|
21
32
|
language: LanguagePreference;
|
|
33
|
+
} | {
|
|
34
|
+
duration: IntervalJson;
|
|
35
|
+
} | {
|
|
36
|
+
volume: IntervalJson;
|
|
37
|
+
} | {
|
|
38
|
+
rate: IntervalJson;
|
|
39
|
+
} | {
|
|
40
|
+
audioTrack: number;
|
|
41
|
+
} | {
|
|
42
|
+
subtitleTrack: string;
|
|
43
|
+
} | {
|
|
44
|
+
audioDevice: string;
|
|
45
|
+
} | {
|
|
46
|
+
muted: boolean;
|
|
47
|
+
} | {
|
|
48
|
+
maximized: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
pip: boolean;
|
|
51
|
+
} | {
|
|
52
|
+
looping: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
time: IntervalJson;
|
|
55
|
+
} | {
|
|
56
|
+
position: PositionJson;
|
|
22
57
|
} | {
|
|
23
58
|
all: ConditionJson[];
|
|
24
59
|
} | {
|
|
@@ -26,7 +61,10 @@ export type ConditionJson = {
|
|
|
26
61
|
} | {
|
|
27
62
|
not: ConditionJson;
|
|
28
63
|
};
|
|
29
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* What conditions read, in the SDK's names. The fields added in 1.10.0 are
|
|
66
|
+
* optional: missing, a fact reads as unknown (false).
|
|
67
|
+
*/
|
|
30
68
|
export interface ConditionFacts {
|
|
31
69
|
phase: PlayerState["phase"];
|
|
32
70
|
paused: boolean;
|
|
@@ -35,12 +73,48 @@ export interface ConditionFacts {
|
|
|
35
73
|
fullscreen: boolean;
|
|
36
74
|
theme: string;
|
|
37
75
|
language: string;
|
|
76
|
+
/** Seconds; `null` while unknown. */
|
|
77
|
+
duration?: number | null;
|
|
78
|
+
volume?: number;
|
|
79
|
+
rate?: number;
|
|
80
|
+
muted?: boolean;
|
|
81
|
+
audioTrack?: number | null;
|
|
82
|
+
subtitleTrack?: string | null;
|
|
83
|
+
audioDevice?: string | null;
|
|
84
|
+
looping?: boolean;
|
|
85
|
+
maximized?: boolean;
|
|
86
|
+
pip?: boolean;
|
|
87
|
+
/** The current source's id. */
|
|
88
|
+
sourceId?: number;
|
|
89
|
+
/** The position; `null` without one. */
|
|
90
|
+
position?: number | null;
|
|
91
|
+
/** The wall clock, Unix milliseconds. */
|
|
92
|
+
time?: number;
|
|
93
|
+
/** The source a position list was bound to (T12). */
|
|
94
|
+
bound?: number | null;
|
|
38
95
|
}
|
|
39
96
|
/** Whether `value` is a condition made by `plugin.when`. */
|
|
40
97
|
export declare const isCondition: (value: unknown) => value is Condition;
|
|
41
98
|
/** A condition's wire form; throws for anything else. */
|
|
42
99
|
export declare function conditionJson(condition: Condition): ConditionJson;
|
|
100
|
+
/** Whether a wire condition reads the position or the clock (a trigger's only). */
|
|
101
|
+
export declare function readsPositionOrTime(json: ConditionJson): boolean;
|
|
102
|
+
/** How many position lists a wire condition has (at most one is allowed). */
|
|
103
|
+
export declare function positionLists(json: ConditionJson): number;
|
|
43
104
|
/** The one `plugin.when` (conditions hold no plugin state). */
|
|
44
105
|
export declare const WHEN: When;
|
|
106
|
+
/** One evaluation: whether it holds and, when its position list does, the range. */
|
|
107
|
+
export interface Truth {
|
|
108
|
+
holds: boolean;
|
|
109
|
+
/** The index of the range the position is in, when its position list holds. */
|
|
110
|
+
range: number | null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The range of `list` the position `at` is in (`start − lead ≤ at < end`):
|
|
114
|
+
* the earliest start when several are, as the player does.
|
|
115
|
+
*/
|
|
116
|
+
export declare function matchedRange(list: PositionJson, at: number): number | null;
|
|
117
|
+
/** Evaluate a wire condition as the player does, with its range (the test host). */
|
|
118
|
+
export declare function evaluateTruth(json: ConditionJson, facts: ConditionFacts): Truth;
|
|
45
119
|
/** Evaluate a wire condition as the player does (for the test host). */
|
|
46
120
|
export declare function evaluate(json: ConditionJson, facts: ConditionFacts): boolean;
|