API reference
Everything a plugin can see and do, as the editor declares it. Plugin API version 1; generated from src/plugins/api.ts, the same declarations @scm-js/plugin-api publishes.
A plugin is one activate(api) function. Everything below hangs off that argument.
import type { PluginApi } from "@scm-js/plugin-api";
export default function activate(api: PluginApi) {
api.menu.add("Tools", { label: "Say hello", run: () => api.ui.toast({ title: "Hello" }) });
}
Nothing here is written by hand. A member with no description has no doc comment in api.ts; the fix belongs there, not on this page.
Groups
api.document |
The open map: what it says, and the three ways of writing to it — |
|---|---|
api.settings |
The settings dialogs' tables, read-only; |
api.triggers |
Reading triggers, and the pure helpers that make them presentable. Writing goes
through |
api.terrain |
Reading the terrain: the tileset's paintable types, the ISOM lattice, flood regions,
blend candidates and the symmetry mode. Painting goes through |
api.tileset |
The loaded tileset graphics: whether they are there, and the decoded files behind them. |
api.selection |
What is selected on each object layer, the marked area, the active layer and the locked ones. |
api.clipboard |
Cut / Copy / Paste: the clip, its parts, and pasting — what the clipboard layer does. |
api.exchange |
The file formats behind File ▸ Import / Export: |
api.palette |
The palettes' current picks — the terrain brush, the unit, sprite and doodad, the fog mode — and the placement options a plugin that places things should honour. |
api.names |
The names behind the numbers a map stores, so a plugin that shows raw values need not
carry the game's tables itself. The per-map ones ( |
api.text |
StarCraft's |
api.query |
Reading the open map: what is under a point, what lies in a rectangle, and the editor's own analyses — Check Map's issues, Tools ▸ Statistics, the Ctrl+F search and the string usage map the String Editor is built on. Everything here is a read: nothing changes the map, and nothing throws without one (an empty list, or null). |
api.data |
The game's own tables, as the editor decoded them: Everything is null until the tables are loaded ( |
api.consts |
Bit masks, special unit ids and the pixels-per-tile every record is written in. |
api.graphics |
The pictures the viewport draws, for a plugin's own lists and previews: the same cached canvases, so asking for one costs nothing after the first time. Everything is null when the graphics it needs were never extracted — a plugin shows a name instead. |
api.view |
The map view: where the viewport is looking, how far in, and what it draws over the terrain. A plugin that finds something needs this to show the user where it is. |
api.ui |
Everything a plugin puts on the screen: the status line, toasts, dialogs, floating
panels, |
api.menu |
Items in the editor's menu bar. A path whose last segment names no submenu makes one. |
api.contextMenu |
Items in the right-click menus of the map and the terrain palette. |
api.hotkeys |
Key combinations, tried before the editor's own and never while a text field has focus. |
api.commands |
Named things a plugin can do, so a menu item, a hotkey, a context entry and another
plugin all reach the same one. |
api.events |
Listeners are notifications: they run after the change, in the order the plugins were
activated, and cannot veto or reorder one another. A listener that rewrites the map in
response (through |
api.storage |
A small key-value store of the plugin's own, kept in the browser's local storage under the plugin's id and listed with everything else in Preferences ▸ Browser storage. |
On the api object itself
api.apiVersion— numberapi.plugin— PluginInfoapi.log— console.log with the plugin's name in front.api.plugin— the manifest of the plugin thisapibelongs to (PluginInfo).
Plugins to read
Every plugin the editor ships is a repository of its own, compiled against these declarations, and the tour of them is in Plugins.
- Paintmap tools, a floating panel, and painting with the active layer's brush
- Walkabilitya read-only overlay drawn over the map
- Section Explorerraw section bytes, re-parsed into the open map
- Repairchecking a file on open and repairing it
- Melee Wizardplacing units with the editor's own placement checks
- Terrain from Imagean image turned into terrain, one transaction
- scmscx.comopening a map fetched from elsewhere
- Trigger Scriptgenerating a run of triggers and claiming it