Extensions
Extensions are the tile content of a GM screen. Every tile shows one extension, for example a dice roller, a character sheet, or an initiative tracker. You build an extension with HTML, CSS, JavaScript, or any other web technology.
Each extension is an iframe with the Overseer SDK in it. Each extension has full access to the Overseer SDK methods. Anything you can build for the web, you can build for Overseer. You can also load a website and add your own JavaScript to it.
Creating an extension
You can create an extension by creating a definition in the plugin manifest.json file.
Example:
{
// [...]
"extensions": [
{ "$ref": "extensions/my-extension/manifest.json" }
]
}Extension definition
Similar to plugins, an extension is defined by a manifest.json file.
Reference
Please reference https://overseer.studio/schemas/extension/manifest.json for a complete definition of the file.
Custom extensions
Extensions can load custom HTML, CSS, JavaScript, and any other modern web technology.
To create a custom extension, create a extensions/my-extension/manifest.json file.
{
"id": "@my-name/my-extension",
"author": "My Name <name@example.com>",
"category": "",
"config": {},
"description": "My first extension",
"icon": { "$ref": "assets/icon.png" },
"label": "My Extension",
"source": { "$ref": "dist/index.html" },
"transparent": true,
"version": "1.0.0",
}If you created a plugin with the Overseer
SDK, then an extension should
already be created for you. Otherwise, ensure that assets/icon.png and
dist/index.html exist.
How to create an extension
You are free to use any framework or no framework at all so there is no one-size-fits-all tutorial to build extensions for Overseer. For example, you can use React, Vue, IndexedDB, localStorage, or WebWorker.
The default npx overseer init template uses vite to compile and build files into a clean plugin you can eventually distribute.
Open dropped files and links
A user can drop a file or a link on the canvas. Overseer can open it in your extension. Declare the files and the links that your extension opens in manifest.json.
Files
Use associatedFileTypes to declare the file types that your extension opens. Each entry has a list of MIME types and a list of file extensions.
"associatedFileTypes": [
{ "mimeTypes": ["application/pdf"], "extensions": [".pdf"] }
]Overseer copies a dropped file into its library. The new tile gets a reference to the file in config.url.
Overseer also downloads a dropped link to a file. It opens the download in the extension that declares the file type.
Links
Use associatedUrls to declare the links that your extension opens. Each entry is a pattern in the URLPattern syntax.
When a user drops a link that a pattern matches, Overseer creates a tile of your extension. Overseer writes the link to config.url. Overseer does not download the link.
This website extension opens Roll20 links:
{
"id": "@my-name/roll20",
"label": "Roll20",
"description": "Play Roll20 games in Overseer",
"category": "VTT",
"icon": { "$ref": "assets/icon.png" },
"source": "webview",
"webview": { "src": "{config.url}" },
"config": {
"url": {
"type": "url",
"label": "Roll20 URL",
"required": true,
"defaultValue": "https://app.roll20.net"
}
},
"associatedUrls": ["https://{*.}?roll20.net/*"],
"version": "1.0.0"
}Add a url field to config. Users can then see and change the link in the tile settings.
Use these parts of the pattern syntax:
*matches all text in one part of the URL.{*.}?makes the subdomain optional. The patternhttps://{*.}?roll20.net/*matcheshttps://roll20.net/andhttps://app.roll20.net/editor/.- A pattern without a query matches all queries. The pattern
https://{www.}?youtube.com/watchmatcheshttps://www.youtube.com/watch?v=abc. - A pattern can use a custom scheme. The pattern
notion://*matchesnotion://www.notion.so/page.
These rules apply to links:
- Overseer uses the first extension that matches the link. Extensions from plugins come before the built-in extensions. Thus, your extension can open a link that a built-in extension also opens.
- Overseer ignores links with the schemes
file,blob,data,javascript,about,assetandplugin. Do not use these schemes in a pattern. - Overseer does not load an extension that has a pattern that is not valid.
- If no extension matches a link, Overseer downloads the file at the link when an extension opens its file type. Otherwise, Overseer opens the link in a Website tile.
Conditional settings
Use visibleWhen to show a config field only for some values of other fields. The tile edit drawer updates the field when those values change.
"config": {
"style": {
"type": "select",
"label": "Style",
"defaultValue": "clock",
"options": [
{ "label": "Clock", "value": "clock" },
{ "label": "Track", "value": "track" },
{ "label": "Counter", "value": "counter" }
]
},
"marks": {
"type": "select",
"label": "Marks",
"options": [{ "label": "Single", "value": "single" }],
"visibleWhen": { "style": "track" }
},
"threshold": { "type": "number", "label": "Danger from" },
"dangerColor": {
"type": "color",
"label": "Danger color",
"visibleWhen": { "threshold": { "set": true } }
},
"limit": {
"type": "number",
"label": "Limit",
"visibleWhen": { "style": { "not": "counter" } }
}
}Each key in visibleWhen is the name of a different config field. Its value is one of these matches:
| Match | Shows the field when the other field |
|---|---|
"track" | is equal to the value. |
["clock", "track"] | is equal to one of the values. |
{ "set": true } | has a value. |
{ "set": false } | is empty. |
{ "not": "counter" } | is not equal to the value. |
{ "not": ["clock", "track"] } | is not equal to any of the values. |
These rules apply:
- All the keys in
visibleWhenmust match. - A value that is not set uses the
defaultValueof its field. - Use
trueorfalsefor acheckboxfield. - A condition reads the value of the other field. It does not check if the other field shows. If the other field has a
visibleWhen, add its keys to this field too. - Overseer keeps the value of a field that does not show. Your extension must ignore the value when it does not apply.
- Overseer does not ask for a
requiredfield when itsvisibleWhenhides it.
Play state
Set transient to true on a config field that holds play state, such as a score or the position of each card. When a user saves the tile as a prefab, Overseer does not save the field. A tile made from the prefab starts with the defaultValue of the field.
"config": {
"rounds": {
"type": "json",
"hidden": true,
"transient": true
}
}Clicks and keys
A tile that is not active does not get clicks. The click goes to the canvas, and the canvas makes the tile active. The same click then goes to your page, at the same point. A site that your page shows in a frame gets the click too.
- The click is the user’s own click. Your page can play sound or open a window, as for any other click.
- After the click, your page has the keyboard. To leave the tile, the user presses Esc two times. Your page gets each press of Esc.
- A drag that starts on a tile that is not active moves the canvas. Your page does not get it.
You do not have to change your code for this. Do not put an action that you cannot undo where one click can start it, for example Delete or Clear.
Searchable content
The session sidebar search finds tiles by name. To let it find your tile by what is inside it, publish the searchable text with the SDK’s setSearchable and handle onSearch to open the matching content when the user picks your tile from the results. Nothing is declared in the manifest.
Website extensions
Load websites and inject custom JavaScript to connect other extensions.