@tavora/sdk / TavoraSDK
Interface: TavoraSDK
Defined in: packages/sdk/src/index.ts:260
Properties
blobs
blobs:
BlobFiles&object
Defined in: packages/sdk/src/index.ts:436
Files (pictures, PDFs and sounds) this module keeps in the current workspace, shared by all of its panels. They live in a folder Tavora manages, not in a document, so they can be large: up to 50 MB each and 500 MB together. Only PNG, JPEG, GIF and WebP pictures, PDFs and (Tavora 0.23.101 and newer) MP3, Ogg and WAV sounds are accepted, judged by the file itself.
Type Declaration
app
app:
BlobFiles
The same for files this module shares across every workspace, such as a library the user builds once, with limits of their own. Tavora 0.23.101 and newer: set minTavora, or check sdk.supports("blobs.app.put").
clipboard
clipboard:
object
Defined in: packages/sdk/src/index.ts:443
writeImage()
writeImage(
png):Promise<void>
Puts a picture on the system clipboard, so the user can paste it anywhere. Call it from the click or key press that asked for it: the host refuses it otherwise (PERMISSION_DENIED), and one press copies one picture. PNG only, a complete one, at most 20 MB and 16384 pixels on a side (INVALID_PARAMS, QUOTA_EXCEEDED).
Parameters
png
Blob
Returns
Promise<void>
connectors
connectors:
object
Defined in: packages/sdk/src/index.ts:574
Parts of Tavora that hold a sign-in, used without seeing it. Each needs its connector in permissions.connectors and the user's grant (PERMISSION_DENIED otherwise).
aiUsage
aiUsage:
object
ai-usage: the usage of the Claude and Codex accounts the user set up in Settings > Integrations > AI usage.
aiUsage.accounts()
accounts():
Promise<AiUsageAccountInfo[]>
Returns
Promise<AiUsageAccountInfo[]>
aiUsage.onAccountsChange()
onAccountsChange(
fn):Unsubscribe
Fires when the user adds, renames or removes an account.
Parameters
fn
() => void
Returns
Unsubscribe
aiUsage.read()
read(
accountId):Promise<AiUsageReading>
Reads one account. Tavora reads each account at most once a minute; asking sooner gives the last reading.
Parameters
accountId
string
Returns
Promise<AiUsageReading>
discord
discord:
object
discord: the Discord app on this PC, through Tavora's Discord sign-in. The connection runs while a panel has asked for state(); Tavora keeps the sign-in and sends only the commands in DISCORD_COMMANDS.
discord.allowControl()
allowControl():
Promise<void>
Asks Discord to approve muting and deafening, for a sign-in that can't yet (canControl false). From a click or key press.
Returns
Promise<void>
discord.command()
command<
C>(command,args):Promise<DiscordResult>
Sends one command; resolves with Discord's answer as it came, or why there is none. SELECT_VOICE_CHANNEL and SET_VOICE_SETTINGS only from a click or key press.
Type Parameters
C
C extends keyof DiscordCommands
Parameters
command
C
args
Returns
Promise<DiscordResult>
discord.connect()
connect():
Promise<void>
Signs in, asking for approval in Discord the first time. Call it from a click or key press handler.
Returns
Promise<void>
discord.image()
image(
url):Promise<string|null>
A picture from cdn.discordapp.com (an avatar or server icon address) as a small PNG data address, or null.
Parameters
url
string
Returns
Promise<string | null>
discord.onEvent()
onEvent(
fn):Unsubscribe
Parameters
fn
(event) => void
Returns
Unsubscribe
discord.onStateChange()
onStateChange(
fn):Unsubscribe
Parameters
fn
(state) => void
Returns
Unsubscribe
discord.state()
state():
Promise<DiscordState>
The connection now. The first call starts it for this panel.
Returns
Promise<DiscordState>
discord.subscribe()
subscribe(
event,channelId?):Promise<void>
Starts sending an event to this panel (VOICE_CHANNEL_SELECT without a channel, the others for one voice channel). Kept across reconnects.
Parameters
event
"VOICE_CHANNEL_SELECT" | "VOICE_STATE_CREATE" | "VOICE_STATE_UPDATE" | "VOICE_STATE_DELETE" | "SPEAKING_START" | "SPEAKING_STOP"
channelId?
string
Returns
Promise<void>
discord.unsubscribe()
unsubscribe(
event,channelId?):Promise<void>
Parameters
event
"VOICE_CHANNEL_SELECT" | "VOICE_STATE_CREATE" | "VOICE_STATE_UPDATE" | "VOICE_STATE_DELETE" | "SPEAKING_START" | "SPEAKING_STOP"
channelId?
string
Returns
Promise<void>
media
media:
object
media: what plays on this PC, as Windows' media controls show it (Spotify, browsers, video players), and play/pause, next and previous. Windows only. A hidden panel keeps getting changes, so an overlay stays current.
media.control()
control(
session,action):Promise<boolean>
Asks a session's app to play or pause, skip or go back. Call it from a click or key press in the panel, or from one of the module's hotkeys; one press allows one call. True when the app took it.
Parameters
session
string
action
Returns
Promise<boolean>
media.onChange()
onChange(
fn):Unsubscribe
Fires with what plays now whenever it changes, while the panel watches.
Parameters
fn
(state) => void
Returns
Unsubscribe
media.unwatch()
unwatch():
Promise<void>
Ends this panel's watch. It also ends with the page.
Returns
Promise<void>
media.watch()
watch():
Promise<MediaState>
Starts this panel's watch and answers what plays now; onChange fires with every change from then on.
Returns
Promise<MediaState>
systemInfo
systemInfo:
object
system-info: this PC's hardware and how busy it is, read by Tavora while a panel shows it. Nothing is read while no panel watches, and a hidden panel gets no snapshots. Names and numbers only, never paths or serial numbers.
systemInfo.apps()
apps():
Promise<SystemApps>
The apps running now with their memory and CPU. Only for Tavora's own System Monitor; others get PERMISSION_DENIED.
Returns
Promise<SystemApps>
systemInfo.clearConnectionLog()
clearConnectionLog():
Promise<void>
Empties the log of drops. Only for Tavora's own System Monitor, right after a click or key press (Tavora 0.21.22 and newer).
Returns
Promise<void>
systemInfo.connectionLog()
connectionLog():
Promise<SystemConnectionLog>
The drops of the connection in the last 30 days, newest first (Tavora 0.21.22 and newer). Tavora watches the connection while a System Monitor panel exists in any workspace, shown or not: it pings the router and one internet address every 5 seconds and sends nothing else.
Returns
Promise<SystemConnectionLog>
systemInfo.connectionSettings()
connectionSettings():
Promise<SystemConnectionSettings>
Whether the connection is watched and which address is pinged (Tavora 0.21.22 and newer).
Returns
Promise<SystemConnectionSettings>
systemInfo.info()
info():
Promise<SystemInfo>
The processor, memory, graphics cards and drives. Read once and kept; ask again after onDrivesChange.
Returns
Promise<SystemInfo>
systemInfo.onConnectionChange()
onConnectionChange(
fn):Unsubscribe
Fires when the connection goes down, changes kind or comes back, for a panel that watches connection (Tavora 0.21.22 and newer).
Parameters
fn
(connection) => void
Returns
Unsubscribe
systemInfo.onDrivesChange()
onDrivesChange(
fn):Unsubscribe
Fires when a drive is plugged in or removed; ask info() again.
Parameters
fn
() => void
Returns
Unsubscribe
systemInfo.onSnapshot()
onSnapshot(
fn):Unsubscribe
Fires with each snapshot of what the panel watches.
Parameters
fn
(snapshot) => void
Returns
Unsubscribe
systemInfo.setConnectionSettings()
setConnectionSettings(
settings):Promise<SystemConnectionSettings>
Changes the settings given and returns all of them. Only for Tavora's own System Monitor, right after a click or key press, once every 5 seconds; a target that is not a public IPv4 address or public name is refused (Tavora 0.21.22 and newer).
Parameters
settings
Partial<SystemConnectionSettings>
Returns
Promise<SystemConnectionSettings>
systemInfo.traffic()
traffic():
Promise<SystemTraffic>
What this PC received and sent this week and this month and in the 3 months before, as Windows counts it. Only for Tavora's own System Monitor; others get PERMISSION_DENIED (Tavora 0.21.31 and newer).
Returns
Promise<SystemTraffic>
systemInfo.watch()
watch(
options):Promise<void>
Sets what this panel watches, replacing what it watched before; empty blocks stop it. A first snapshot comes at once, then one every intervalMs (1000, 2000, 5000, 15000 or 60000). The panel's watch ends with the page.
Parameters
options
blocks
intervalMs
Returns
Promise<void>
documents
documents:
object
Defined in: packages/sdk/src/index.ts:282
Named documents (builds, plans, checklists), private to this module in the current workspace and shared by all of its panels.
delete()
delete(
id,options?):Promise<void>
Parameters
id
string
options?
ifRevision?
number
Returns
Promise<void>
get()
get<
T>(id):Promise<TavoraDocument&object|null>
Type Parameters
T
T = JsonValue
Parameters
id
string
Returns
Promise<TavoraDocument & object | null>
list()
list():
Promise<DocumentSummary[]>
Returns
Promise<DocumentSummary[]>
onChange()
onChange(
fn):Unsubscribe
Fires when another panel of this module changes a document.
Parameters
fn
(change) => void
Returns
Unsubscribe
put()
put(
document):Promise<DocumentSummary>
Creates or replaces a document. Pass ifRevision to avoid overwriting another panel's change.
Parameters
document
Returns
Promise<DocumentSummary>
files
files:
object
Defined in: packages/sdk/src/index.ts:451
check()
check(
id):Promise<ReadOnlyFileState>
Whether a picked file is still there, with its size and last change, without reading it. Tavora 0.23.6+.
Parameters
id
string
Returns
Promise<ReadOnlyFileState>
exportJson()
exportJson(
value,name?):Promise<{fileName:string; }>
Saves JSON (up to 8 MiB) in Downloads/Tavora after a click or key press, without asking. Never replaces a file. Tavora 0.19.17+.
Parameters
value
name?
string
Returns
Promise<{ fileName: string; }>
Deprecated
Use files.saveJson, which shows Tavora's save dialog. Kept for modules made for older Tavora versions.
forget()
forget(
id):Promise<void>
Revokes a remembered file reference; never deletes the user's file.
Parameters
id
string
Returns
Promise<void>
open()
open(
options?):Promise<OpenedFile|null>
Opens a .csv or .xlsx the user picks in Tavora's open dialog (options.types limits it to one; both when left out), which starts in the same folder as saveJson. Resolves with the file's name and kind and its content (a CSV as text, read as UTF-8, or as Windows-1252 when it is not UTF-8; an xlsx as bytes), at most 8 MiB (QUOTA_EXCEEDED), or null when the user closed the dialog. The module never learns the folder. Call it from the click or key press that asked for it (PERMISSION_DENIED otherwise); one press opens one file. Needs Tavora 0.23.102 or newer: check sdk.supports("files.open").
Parameters
options?
types?
FileKind[]
Returns
Promise<OpenedFile | null>
openJson()
openJson():
Promise<{fileName:string;value:JsonValue; } |null>
Opens a .json file the user picks in Tavora's open dialog, which starts in the same folder as saveJson. Resolves with the file's name and its parsed content (at most 8 MiB), or null when the user closed the dialog; a file that is not JSON is INVALID_PARAMS. The module never learns the folder. Call it from the click or key press that asked for it (PERMISSION_DENIED otherwise); one press opens one file.
Returns
Promise<{ fileName: string; value: JsonValue; } | null>
pickReadOnly()
Call Signature
pickReadOnly(
options):Promise<ReadOnlyFile|null>
Opens Tavora's native picker after a real click and remembers read-only access on this PC. near opens it in the folder of a file this module linked, up folders higher (0 to 3), such as the save next to one picked before; it only chooses where the picker starts and grants nothing. Tavora 0.23.30+; older ones ignore it.
Parameters
options
extensions
string[]
multiple?
false
near?
Returns
Promise<ReadOnlyFile | null>
Call Signature
pickReadOnly(
options):Promise<ReadOnlyFile[]>
The same, letting the user pick several files; an empty list when the dialog was closed. Tavora 0.23.6+.
Parameters
options
extensions
string[]
multiple
true
near?
Returns
Promise<ReadOnlyFile[]>
read()
read(
id):Promise<Uint8Array<ArrayBufferLike>>
Rereads only a file previously picked by this module in this workspace. At most 50 MiB (32 MiB before Tavora 0.23.6).
Parameters
id
string
Returns
Promise<Uint8Array<ArrayBufferLike>>
save()
save(
data,options):Promise<{fileName:string; } |null>
Saves a table file where the user says: a .csv (data is its text) or an .xlsx (data is its bytes), up to 8 MiB. Tavora's save dialog opens in the same folder as saveJson and fills in options.name (made safe, " (2)" and so on when taken); only that extension can be chosen. Resolves with the name it was saved under, or null when the user closed the dialog; the module never learns the folder. Replacing a file needs the user's OK in the dialog. An xlsx that is not a zip, or a csv that is not UTF-8 text, is INVALID_PARAMS. Call it from the click or key press that asked for it (PERMISSION_DENIED otherwise); one press saves one file. Needs Tavora 0.23.102 or newer: check sdk.supports("files.save").
Parameters
data
string | Uint8Array<ArrayBufferLike>
options
name?
string
type
Returns
Promise<{ fileName: string; } | null>
saveJson()
saveJson(
value,name?):Promise<{fileName:string; } |null>
Saves JSON (up to 8 MiB) as a .json file where the user says: Tavora's save dialog opens in the folder they last saved a file to or opened one from for this module, at first Documents\Tavora. name suggests the file name: Tavora makes it safe and adds " (2)" and so on when it is taken. Resolves with the name it was saved under, or null when the user closed the dialog; the module never learns the folder. Replacing a file needs the user's OK in the dialog. Call it from the click or key press that asked for it: the host refuses it otherwise (PERMISSION_DENIED), and one press saves one file.
Parameters
value
name?
string
Returns
Promise<{ fileName: string; } | null>
showInFolder()
showInFolder(
id):Promise<void>
Opens the folder of a picked file with the file selected. Call it from a click or key press. Tavora 0.23.6+.
Parameters
id
string
Returns
Promise<void>
folders
folders:
object
Defined in: packages/sdk/src/index.ts:517
Folders on this PC the manifest asks to read (permissions.folders), such as a game's replays, once the user allowed them. Each call names the folder by its manifest path ("Documents/My Game") and every file by its path inside it, joined by /; the module never learns where the folder is. Only the extensions the manifest lists show: read ones can be read, names ones only listed. Needs capability folders and Tavora 0.23.113 or newer: check sdk.supports("folders.list").
choose()
choose(
folder):Promise<boolean>
Opens the system's folder dialog so the user can show Tavora where the folder is. Call it from a click or key press (PERMISSION_DENIED otherwise). True when the user chose a folder Tavora accepts; then list it again.
Parameters
folder
string
Returns
Promise<boolean>
list()
list(
folder):Promise<FolderListing>
The files the module may see, subfolders too (8 deep), at most 20,000 (truncated past that).
Parameters
folder
string
Returns
Promise<FolderListing>
read()
read(
folder,path):Promise<Uint8Array<ArrayBufferLike>>
Reads one file of a read extension, at most 50 MB.
Parameters
folder
string
path
string
Returns
Promise<Uint8Array<ArrayBufferLike>>
showInFolder()
showInFolder(
folder,path):Promise<void>
Shows a file of the folder in Explorer with the file selected, like files.showInFolder does for a file the user picked; when the file is gone, the folder it was in is selected instead, and when that is gone too nothing is shown. path is inside the folder, joined by /, of an extension the manifest lists (read or names). Call it from the click or key press that asked for it (PERMISSION_DENIED otherwise); one press opens one window. It resolves with nothing either way, so the module learns nothing back, and never where the folder is. Needs Tavora 0.23.116 or newer: check sdk.supports("folders.showInFolder").
Parameters
folder
string
path
string
Returns
Promise<void>
state()
state(
folder):Promise<FolderState>
Whether the folder can be read now: missing when it isn't where the manifest says (offer folders.choose).
Parameters
folder
string
Returns
Promise<FolderState>
watch()
watch(
folder,fn):Promise<() =>void>
Tells fn about files added, changed or removed while the panel is open; returns a function that stops it.
Parameters
folder
string
fn
(change) => void
Returns
Promise<() => void>
game
game:
object
Defined in: packages/sdk/src/index.ts:269
getCurrent()
getCurrent():
Promise<TavoraGame>
Returns
Promise<TavoraGame>
Deprecated
Use workspace.getCurrent.
Deprecated
Use workspace.getCurrent. Tavora answers it until its 1.0 preparation.
host
readonlyhost:HandshakeResult
Defined in: packages/sdk/src/index.ts:262
What the host reported when this module connected.
hotkeys
hotkeys:
object
Defined in: packages/sdk/src/index.ts:764
Hotkeys for the manifest's actions. The user picks the keys in a Tavora dialog, for this workspace; the module only hears which action fired, for which target, in its panel used last in the workspace shown now. Tavora 0.19.26 and newer.
list()
list():
Promise<HotkeyBinding[]>
Returns
Promise<HotkeyBinding[]>
onPress()
onPress(
fn):Unsubscribe
Parameters
fn
(binding) => void
Returns
Unsubscribe
remove()
remove(
target,action?):Promise<void>
Removes the hotkeys for target: all of them, or the one for action.
Parameters
target
string
action?
string
Returns
Promise<void>
set()
set(
action,target,label):Promise<HotkeySetResult>
Opens Tavora's dialog to set a key for action on target, named label there. Call it from a click or key press.
Parameters
action
string
target
string
label
string
Returns
Promise<HotkeySetResult>
leaderboards
leaderboards:
object
Defined in: packages/sdk/src/index.ts:670
The module's leaderboards (the manifest's leaderboards), kept by Tavora's service with the user's Tavora account. Needs "leaderboards" in permissions.connectors and the user's grant (PERMISSION_DENIED otherwise). Tavora asks the user once in your panel before their name and results go public (show); your module never learns who they are, only which line is their own (self). Results played while signed out still count: keep them and send them once the user signed in and agreed. Tavora 0.21.92 and newer.
hide()
hide():
Promise<LeaderboardStatus>
Takes the user off your boards and deletes their results there. Call it from a click or key press.
Returns
Promise<LeaderboardStatus>
mine()
mine(
options?):Promise<LeaderboardMine>
The user's own standing on every board of the manifest, in every period, in one call: rank, how many users the board has, and their numbers; null where they aren't on it. Every standing is null while signed out or not shown. Tavora 0.21.97 and newer.
Parameters
options?
day?
string
Returns
Promise<LeaderboardMine>
show()
show():
Promise<LeaderboardStatus>
Asks the user in your panel, in Tavora's own words, whether to show their Tavora name and results on your boards; signed out, it offers to sign in instead. Resolves with the status after their answer. Call it from a click or key press (PERMISSION_DENIED otherwise).
Returns
Promise<LeaderboardStatus>
status()
status():
Promise<LeaderboardStatus>
Where the user stands: whether Tavora's service answered (online), signed in, boards available for this module, shown on them, and (once shown) the name the boards show. Never throws for being offline: online is false then.
Returns
Promise<LeaderboardStatus>
submit()
submit(
board,results):Promise<LeaderboardSubmitResult>
Sends finished games to a board of the manifest, up to LIMITS.maxLeaderboardResults at once. Each result is taken or refused on its own; a refused one never counts, so drop it. A result without a day gets the local calendar day of its at. Throws PERMISSION_DENIED while the user is signed out or not shown, NETWORK_ERROR while Tavora's service can't be reached: keep the results and send them later.
Parameters
board
string
results
Returns
Promise<LeaderboardSubmitResult>
top()
top(
board,options?):Promise<LeaderboardTop>
The best lines of a board (limit: default 20, at most LIMITS.maxLeaderboardRows); the user's own line comes last when they are further down. period picks a day, week, month, year or all time (the default); day (the user's local day, YYYY-MM-DD, default today) picks which one, and on a daily board shows streaks that ended as 0.
Parameters
board
string
options?
day?
string
limit?
number
period?
Returns
Promise<LeaderboardTop>
lifecycle
lifecycle:
object
Defined in: packages/sdk/src/index.ts:772
onBehindChange()
onBehindChange(
fn):Unsubscribe
Tavora's window went behind another program, usually the game (true), or came back in front (false). The panel is not hidden and keeps running; only what the user must be there to see, such as a toast with Undo, should wait. Called with true at once if the window is behind already. Tavora 0.23.82 and newer; an older Tavora never calls it.
Parameters
fn
(behind) => void
Returns
Unsubscribe
onDispose()
onDispose(
fn):Unsubscribe
Best effort only: autosave must not depend on this firing.
Parameters
fn
() => void
Returns
Unsubscribe
onResume()
onResume(
fn):Unsubscribe
Parameters
fn
() => void
Returns
Unsubscribe
onSuspend()
onSuspend(
fn):Unsubscribe
The panel is hidden; pause timers and animations. Called immediately if already suspended.
Parameters
fn
() => void
Returns
Unsubscribe
links
links:
object
Defined in: packages/sdk/src/index.ts:551
open()
open(
url):Promise<void>
Opens a web address (http or https) in a Browser panel of this workspace, as a new tab or in a new panel. Call it from the click or key press that asked for it: the host refuses it otherwise (PERMISSION_DENIED). The module learns nothing about the page.
Parameters
url
string
Returns
Promise<void>
network
network:
object
Defined in: packages/sdk/src/index.ts:559
fetch()
fetch(
url,init?):Promise<NetworkResponse>
Makes a web request through Tavora, to a host listed in permissions.network that the user granted (PERMISSION_DENIED otherwise). HTTPS only, no cookies, at most 5 MB back and 15 seconds. Error statuses such as 404 are answers, not errors; NETWORK_ERROR means no answer came. A program on this PC listed as localhost:<port> (such as a game's local API) is read only: http or https, GET or HEAD, no redirects. Needs Tavora newer than 0.23.111.
Parameters
url
string
init?
Omit<NetworkRequest, "url">
Returns
Promise<NetworkResponse>
readPage()
readPage(
url):Promise<PageResponse>
Render a public HTTPS page in a temporary session, with the same granted domains. No browser logins, module scripts or interactions. Up to 5 MB / 30 seconds. Requires Tavora 0.19.3. Login and verification pages fail with NETWORK_ERROR.
Parameters
url
string
Returns
Promise<PageResponse>
overlay
overlay:
object
Defined in: packages/sdk/src/index.ts:708
Pages for streaming software such as OBS (the manifest's overlay), one per key: an item, a scoreboard, whatever the module shows on stream. Needs "stream-overlay" in permissions.connectors and the user's grant (PERMISSION_DENIED otherwise). Tavora 0.19.26 and newer.
copyLink()
copyLink(
key):Promise<OverlayLinkResult>
Puts the overlay's link on the clipboard, for the user to paste into OBS as a Browser Source. Call it from the click or key press that asked for it. Resolves with "off" when Stream overlays are off in Tavora: Tavora then opens that setting.
Parameters
key
string
Returns
Promise<OverlayLinkResult>
hideOverGame()
hideOverGame(
key):Promise<void>
Takes this module's game overlay for key away in the panel's workspace scope. No click or permission needed; nothing happens when there is none. Tavora 0.21.3 and newer.
Parameters
key
string
Returns
Promise<void>
onOverGameChange()
onOverGameChange(
fn):Unsubscribe
Fires when the game overlays of this module in the panel's workspace scope changed without this panel asking: the user added or removed one on the Overlay page. keys is what overGame() gives now; publish the state of the new ones. Needs Tavora 0.23.43 or newer.
Parameters
fn
(keys) => void
Returns
Unsubscribe
openPage()
openPage():
Promise<void>
Shows Tavora's Overlay page, where the user adds this module's overlays to their game and arranges them (a settings page's "Arrange in Overlays" link); an open dialog of this panel closes. Only right after a click or key press in the panel. Needs Tavora 0.23.77 or newer: check sdk.supports("overlay.openPage").
Returns
Promise<void>
overGame()
overGame():
Promise<string[]>
The keys of this module's game overlays in the panel's workspace scope. Tavora 0.21.3 and newer.
Returns
Promise<string[]>
preview()
preview(
key):Promise<void>
Opens a small Tavora window with the overlay for key at its real size, on a dark, light or checkered background, so the user can see what it looks like. Call it from the click or key press that asked for it; it needs no permission, but the module needs an overlay in its manifest. It works whether or not Game overlays and Stream overlays are on. Tavora 0.21.3 and newer.
Parameters
key
string
Returns
Promise<void>
publish()
publish(
key,state):Promise<void>
What the overlay for key shows now. Tavora keeps it, so the overlay goes on showing it while no panel runs.
Parameters
key
string
state
Returns
Promise<void>
remove()
remove(
key):Promise<void>
The overlay for key shows nothing until it is published again. Its link stays the same.
Parameters
key
string
Returns
Promise<void>
resetLink()
resetLink(
key):Promise<void>
Gives the overlay a new link; the old one stops working.
Parameters
key
string
Returns
Promise<void>
setSources()
setSources(
sources):Promise<void>
Tells Tavora what this panel can show over the game on its own, one entry per item with the overlay key it shows from (OverlaySource). The Overlay page lists them under the panel, and a click on one adds the overlay for its key to the setup, as showOverGame does. Once a panel has sent a list, it is not offered as a whole any more. Call it again when the items or their names change: the last call wins, and an empty list says there is nothing right now (the panel is still not offered as a whole). At most LIMITS.maxOverlaySources entries; needs no click and no permission. Needs Tavora 0.23.43 or newer.
Parameters
sources
Returns
Promise<void>
showOverGame()
showOverGame(
key):Promise<GameOverlayResult>
Shows the overlay for key over the user's game, in a Tavora window above it, only while that game is in front. Call it from the click or key press that asked for it; it needs no permission. Resolves with "off" when Game overlays are off in Tavora (Tavora then opens that setting) and "full" when the overlay setup it lands in (its game's, or All games) has no room for another. Tavora 0.20.51 and newer.
Parameters
key
string
Returns
Promise<GameOverlayResult>
panel
panel:
object
Defined in: packages/sdk/src/index.ts:292
UI state for this one panel (selection, scroll, open tab). Cleared when the panel is closed.
type
readonlytype:string|null
Which of the manifest's panels this panel is, by id; null for a module without panel types (or an older Tavora).
closeDialog()
closeDialog():
Promise<void>
Puts this panel back in its slot after openDialog. Needs Tavora 0.21.95 or newer.
Returns
Promise<void>
getLaunch()
getLaunch():
Promise<PanelLaunch>
Why this page is loading: { reason: "add" } for a panel the user just added (pick its content yourself, such as the last one used, or show a picker), or { reason: "restore", content } for a panel that was open before, with what it last showed. Needs Tavora 0.17.17 or newer.
Returns
Promise<PanelLaunch>
getState()
getState<
T>():Promise<T|null>
Type Parameters
T
T = JsonValue
Returns
Promise<T | null>
isMaximized()
isMaximized():
Promise<boolean>
Whether this panel fills the workspace now (Maximize in its menu). Needs Tavora 0.20.20 or newer.
Returns
Promise<boolean>
onDialogChange()
onDialogChange(
fn):Unsubscribe
Fires when this panel's dialog opens or closes, whoever did it. Needs Tavora 0.21.95 or newer.
Parameters
fn
(open) => void
Returns
Unsubscribe
onMaximizedChange()
onMaximizedChange(
fn):Unsubscribe
Fires when this panel starts or stops filling the workspace, whoever did it. Needs Tavora 0.20.20 or newer.
Parameters
fn
(maximized) => void
Returns
Unsubscribe
onNavigate()
onNavigate(
fn):Unsubscribe
Lets another panel of this module switch this one to other content (panels.open). The handler saves any pending edits and switches, then resolves; it throws (or rejects) when it cannot, and the panel keeps what it showed. It has 5 seconds. One handler per page: a new one replaces the last. Without one, Tavora opens a new panel instead of switching this one. Needs Tavora 0.17.18 or newer.
Parameters
fn
(content) => void | Promise<void>
Returns
Unsubscribe
onOpenSettings()
onOpenSettings(
fn):Unsubscribe
Fires when the user presses Settings on one of this module's overlays on the Overlay page. Tavora has put this panel in its dialog already (as openDialog does, over the Overlay page), so show the settings of what key shows, as you would after openDialog; the dialog closes with closeDialog or the user's close button, and the panel stays where it was. Without a handler the dialog shows the panel as it is. Needs Tavora 0.23.43 or newer.
Parameters
fn
(target) => void
Returns
Unsubscribe
openDialog()
openDialog(
size?):Promise<void>
Shows this panel big in a dialog centred over the workspace, above the other panels (the rail and header stay in sight, dimmed), with the module's name and a close button: for settings or details that don't fit a small panel. It is the same page, now size big (CSS pixels, 240 to 2000 a side, default 560 x 640; Tavora makes it fit the workspace), so it keeps all it had. Call it from the click or key press that asked for it: the host refuses it otherwise. One exception, for a welcome: a panel whose launch reason is add may call it once without a press, within 10 seconds of its page starting (not over the game). The user closes it with the close button or, when a press opened it, a click beside it (Esc in the page is the module's to handle); onDialogChange says so. From a panel over the game, Tavora closes the in-game layer and comes to the front with the dialog open. Needs Tavora 0.21.95 or newer (older ones throw UNKNOWN_METHOD); older ones than this change refuse the welcome without a press.
Parameters
size?
height?
number
width?
number
Returns
Promise<void>
setContent()
setContent(
content):Promise<void>
Tells Tavora what this panel shows now, such as the build picked in your toolbar's selector, or null for nothing. Tavora keeps it with the panel, shows the title when the user hovers the tab, and gives it back through getLaunch after a restart. Needs Tavora 0.17.17 or newer.
Parameters
content
PanelContent | null
Returns
Promise<void>
setDialogTitle()
setDialogTitle(
title):Promise<void>
Changes the title in the frame of this panel's dialog (the module's name by default) while it is open, for example to name what its settings are about; null goes back to the module's name. Plain text of 1 to LIMITS.maxTitleLength characters, on one line. Nothing happens while no dialog is open, and the next one starts with the module's name, so call it when onDialogChange says the dialog opened. Needs no click. Needs Tavora 0.23.71 or newer: check sdk.supports("panel.setDialogTitle") and keep a title of your own in the page for an older one.
Parameters
title
string | null
Returns
Promise<void>
setLive()
setLive(
state):Promise<void>
What this panel's live view shows: while the user shows the panel in their game and the in-game layer is closed, Tavora shows the module's overlay page (the manifest's overlay) read-only and click-through in the panel's spot, with this state. Any JSON up to LIMITS.maxOverlayStateBytes; null shows nothing. Tavora keeps showing the last state while the panel isn't running, e.g. while you look at another workspace in Tavora; after a restart nothing shows until the panel runs again and calls setLive. Needs no click or permission. Tavora 0.21.11 and newer.
Parameters
state
Returns
Promise<void>
setMaximized()
setMaximized(
maximized):Promise<void>
Makes this panel fill the workspace (true), as Maximize in its menu does, or puts it back (false). Call true from the click or key press that asked for it: the host refuses it otherwise. Nothing happens while the panel is the only one, as it fills the workspace already. Needs Tavora 0.20.20 or newer.
Parameters
maximized
boolean
Returns
Promise<void>
setState()
setState(
value):Promise<void>
Parameters
value
Returns
Promise<void>
panels
panels:
object
Defined in: packages/sdk/src/index.ts:367
The module's other panels.
open()
open(
type,options?):Promise<PanelOpenResult>
Opens one of this module's own panel types in the current workspace, on content when given. Tavora brings forward a panel of that type already showing the content, else switches the one used last (panel.onNavigate), else opens a new one. Call it from the click or key press that asked for it: the host refuses it otherwise (PERMISSION_DENIED). Needs Tavora 0.17.18 or newer.
Parameters
type
string
options?
content?
Returns
Promise<PanelOpenResult>
openMany()
openMany(
types):Promise<Record<string,PanelOpenManyResult>>
Opens several of this module's own panel types from one click, such as the ones a welcome page let the user tick. Each type at most once, without content. The new panels go inside this panel's group, laid out as the manifest's panelLayout says (else each where open would put it); a type already open in the workspace comes to the front where it is, and this panel keeps the focus. Answers per type: opened, shown or failed. Call it from the click or key press that asked for it: one press covers the whole call (PERMISSION_DENIED otherwise). Needs Tavora 0.23.29 or newer: check sdk.supports("panels.openMany").
Parameters
types
string[]
Returns
Promise<Record<string, PanelOpenManyResult>>
pictures
pictures:
object
Defined in: packages/sdk/src/index.ts:540
save()
save(
png,name?):Promise<{fileName:string; } |null>
Saves a picture as a .png file where the user says: Tavora's save dialog opens in the folder they last saved a picture to, at first Pictures\Tavora. name suggests the file name: Tavora makes it safe and adds " (2)" and so on when it is taken. Resolves with the name it was saved under, or null when the user closed the dialog; the module never learns the folder. Tavora 0.20.16 and older save in Pictures\Tavora without asking. Call it from the click or key press that asked for it: the host refuses it otherwise (PERMISSION_DENIED), and one press saves one picture. The same PNG limits as clipboard.writeImage apply.
Parameters
png
Blob
name?
string
Returns
Promise<{ fileName: string; } | null>
storage
storage:
KeyValueStore&object
Defined in: packages/sdk/src/index.ts:274
Small key/value settings, private to this module in the current workspace.
Type Declaration
app
app:
KeyValueStore
The same, shared by every workspace: settings that should not change from one workspace to the next.
ui
ui:
object
Defined in: packages/sdk/src/index.ts:394
tooltip
tooltip:
object
One shared tooltip above the workspace (Tavora 0.19.3+). A pin needs a real click/key press.
tooltip.close()
close(
id):Promise<void>
Parameters
id
string
Returns
Promise<void>
tooltip.defineSkin()
defineSkin(
name,skin):Promise<void>
Defines one of this module's item-card skins (a frame picture, colours, a font for the title and the effect box), or replaces the one of that name; a card asks for it with content.skin and layout: "card". It holds for every panel of the module until Tavora restarts, so define your skins when a panel starts. Names are 1 to 32 of a-z, 0-9 and -, at most 32 per module. Tavora checks the files (from your own dist/, PNG or WebP and WOFF2, up to 512 KB each) and the colours' contrast, and refuses a skin that fails with INVALID_PARAMS and the reason. On a Tavora older than sdk.supports("ui.tooltip.skin") it does nothing (the cards show plain there).
Parameters
name
string
skin
Returns
Promise<void>
tooltip.hide()
hide(
id):Promise<void>
Ends hover only; a pin remains until close, Escape, or a lifecycle change.
Parameters
id
string
Returns
Promise<void>
tooltip.move()
move(
anchor):Promise<void>
Parameters
anchor
Returns
Promise<void>
tooltip.onClose()
onClose(
fn):Unsubscribe
Parameters
fn
(event) => void
Returns
Unsubscribe
tooltip.show()
show(
request):Promise<boolean>
anchor (the element or its box) or at (a point); with an anchor the tooltip opens next to it, never on top of it.
Parameters
request
Returns
Promise<boolean>
getLanguage()
getLanguage():
Promise<string>
The language Tavora shows its own texts in, as a code such as "en" or "de". Show yours in it, or in English when you have no translation.
Returns
Promise<string>
getTheme()
getTheme():
Promise<TavoraTheme>
Returns
Promise<TavoraTheme>
onLanguageChange()
onLanguageChange(
fn):Unsubscribe
Fires when the user changes the language.
Parameters
fn
(language) => void
Returns
Unsubscribe
onThemeChange()
onThemeChange(
fn):Unsubscribe
Parameters
fn
(theme) => void
Returns
Unsubscribe
showMenu()
showMenu(
request):Promise<string|null>
Shows a menu that Tavora draws above every panel, so it is never cut off at the panel's edge. Call it from the click, right-click or key press that asked for it: the host refuses it otherwise (PERMISSION_DENIED). Resolves with the chosen item's id, or null when the user closed the menu without choosing. Pass the element the menu is for as anchor (a button, or the row that was right-clicked): its box is read when you call, and Tavora opens the menu next to it, never at the pointer. at (a bare box) stays for the rare case without an element; with neither, INVALID_PARAMS.
Parameters
request
Returns
Promise<string | null>
workspace
workspace:
object
Defined in: packages/sdk/src/index.ts:385
getCurrent()
getCurrent():
Promise<TavoraWorkspace>
The workspace this panel is in: a game workspace (kind "game", its id is the game's) or a personal one. On a Tavora older than 0.21.43 this asks game.getCurrent and puts its answer in the new words.
Returns
Promise<TavoraWorkspace>
getViewport()
getViewport():
Promise<TavoraViewport>
Returns
Promise<TavoraViewport>
onResize()
onResize(
fn):Unsubscribe
Parameters
fn
(viewport) => void
Returns
Unsubscribe
Methods
supports()
supports(
call):boolean
Defined in: packages/sdk/src/index.ts:267
Whether the Tavora this module runs in has a call, by the table in @tavora/sdk/protocol: supports("storage.compareAndSet"), supports("panel.openDialog"). Use it to pick a fallback before calling; a call the Tavora does not have throws UNKNOWN_METHOD.
Parameters
call
Returns
boolean