scmJS docs

The API, group by group

This part covers what each group is for and the rules that matter when using it. Each section links to its page in the API reference, which has every call's signature, options and further examples; the examples here are the ones the reference does not have.

The examples are written as playground snippets, with api already defined. In a plugin the same lines go inside activate(api). Core concepts has the rules that hold for every group.

api.document#

Reference

The open map as a whole.

Reading, and a file of the plugin's own that travels with the map:

const info = api.document.info();
if (info) api.log(`${info.name}: ${info.width} × ${info.height}, ${info.tileset}${info.modified ? ", unsaved changes" : ""}`);

const name = "my-plugin\\notes.json";
const stored = api.document.extras.get(name);
const notes = stored ? JSON.parse(new TextDecoder().decode(stored)) : { opened: 0 };
notes.opened++;
api.document.extras.set(name, new TextEncoder().encode(JSON.stringify(notes)));
api.log(`runs of this snippet on this map: ${notes.opened}`);
Try it

A new map beside the open one, and a picture of it:

if (await api.document.create({ width: 96, height: 96, tileset: "jungle", name: "Sketch", startLocations: 2, into: "new" })) {
  const png = await api.document.renderImage({ pixelsPerTile: 4 });
  if (png) await api.ui.saveFile(png, "sketch.png");
}
Try it

The open map, written as Save would write it, sent to Test Map:

const file = await api.document.export();
const outcome = file && (await api.document.test(new Uint8Array(await file.arrayBuffer()), file.name, { launch: false }));
api.ui.status(outcome ? `Written to ${outcome.path}` : "No test folder chosen yet.");
Try it

api.document.sections#

Reference

The map file as a list of sections, as the game reads it and Save writes it, with unsaved edits already included. Section Explorer is built on it, and Repair uses its helpers.

Reading. list() gives each section's name, offset, size and what the editor knows about it. bytes(index) is one section's payload, combined(name) what the game uses when a name is repeated, and file() the whole file.

Writing. write, rename, insert, remove, move and replaceFile. After each:

Helpers for repairs. required() (the sections this map's revision must have), defaults(name) (what File ▸ New would write), trailing() (bytes after the last readable section), chkOf(file) (the scenario inside an .scx / .scm) and rebuild(names?) (re-encode sections from the editor's model, fixing sizes, repeats and broken string offsets).

// Sections the map must have and does not, and sections that appear more than once.
const sections = api.document.sections.list();
const present = new Set(sections.map((s) => s.name));
api.log("missing:", api.document.sections.required().filter((name) => !present.has(name)));
api.log("repeated:", [...new Set(sections.filter((s) => s.occurrences > 1).map((s) => s.name))]);
Try it

api.document.buildSteps#

Reference

For a plugin that compiles something into the map, such as a script turned into triggers. A build step runs whenever the map leaves the editor (Save, Test Map and document.export), so the user keeps one file and keeps editing the unbuilt map.

api.document.buildSteps.add({
  id: "compile",
  label: "My Compiler",
  // Only maps that carry the plugin's source file are built.
  applies: () => api.document.extras.get("my-plugin\\main.txt") !== null,
  async run({ map, fileName, purpose }) {
    api.log(`building ${fileName} (${map.length} bytes) for ${purpose}`);
    return map; // an .scx in, an .scx out: return your compiled map here
  },
});
Try it

A bare .chk is never built, since it has nowhere to keep the unbuilt copy.

EditTransaction#

Reference

What document.edit passes to its function. When the function returns, the transaction removes doodads the terrain change broke and units the new ground cannot hold (if the Units palette's Remove stranded units is on), commits and repaints.

placeUnit places the way the Units palette does but makes no checks; ask canPlaceUnit first if you want them.

Several operations, one undo entry: a ring of eight marines round the middle of the map, with a location over them.

const info = api.document.info();
if (info) {
  const t = api.consts.tile;
  const cx = (info.width * t) / 2;
  const cy = (info.height * t) / 2;
  const result = api.document.edit("Ring of marines", (tx) => {
    for (let i = 0; i < 8; i++) {
      const x = cx + Math.cos((i * Math.PI) / 4) * 3 * t;
      const y = cy + Math.sin((i * Math.PI) / 4) * 3 * t;
      if (tx.canPlaceUnit(0, x, y)) tx.placeUnit(0, 0, x, y);
    }
    tx.addLocation({ left: cx - 4 * t, top: cy - 4 * t, right: cx + 4 * t, bottom: cy + 4 * t }, "The Ring");
  });
  api.ui.status(`${result.units} marines, ${result.locations} location`);
}
Try it

UpdateTransaction#

Reference

What document.update passes to its function. The result's sections lists the file sections actually changed, and changed is false when nothing was.

Part What it covers
tx.triggers, tx.briefing The trigger and briefing lists: list, add, replace, remove, move, set, fromText.
tx.strings The string table. intern(text) reuses an identical string or adds one and never overwrites, since an index may be shared. set(index, text) overwrites a slot.
tx.switches Switch names.
tx.properties The scenario's name and description.
tx.players, tx.forces Player slots (type, race, colour, force) and the four forces.
tx.unitTypes, tx.upgrades, tx.techs Unit, upgrade and technology settings, with the game's defaults alongside.
tx.sounds, tx.cuwp WAV slots, and the unit property slots used by Create Unit with Properties.
tx.setVersion, tx.setTextEncoding The map revision and the text encoding.

A settings change, the way a dialog's OK makes one:

api.document.update("Set up the scenario", (tx) => {
  tx.properties({ name: "Last Stand", description: "Hold the ring for ten minutes." });
  tx.unitTypes.set(0, { hitPoints: 80, name: "Veteran Marine" });
  tx.switches.setName(0, "Gate is open");
});
Try it

A trigger built record by record:

const { condition, action, comparison, player } = api.consts.triggers;

api.document.update("Add a countdown", (tx) => {
  const trigger = api.triggers.newTrigger([player.Player1]);
  const timer = api.triggers.newCondition(condition.CountdownTimer);
  timer.comparison = comparison.AtMost;
  timer.amount = 30;
  trigger.conditions[0] = timer;

  const say = api.triggers.newAction(action.DisplayText);
  say.text = tx.strings.intern("30 seconds remaining");
  trigger.actions[0] = say;
  trigger.actions[1] = api.triggers.newAction(action.PreserveTrigger);
  tx.triggers.add(trigger);
});
Try it

api.settings#

Reference

The same views as the UpdateTransaction parts, for reading without a transaction: players, forces, unit types, upgrades, techs, sounds, unit property slots, whether a unit is available to a player (unitAvailable), and version() (revision and text encoding). Write through document.update.

api.triggers#

Reference

Reading triggers and everything needed to show one. Writing is document.update.

To generate triggers, write text. tx.triggers.fromText parses the text format, interns its strings and resolves names against the open map. That is easier than filling records field by field, and text with a mistake in it throws with the line and changes nothing:

const source = `
Trigger("Player 1"){
Conditions:
  Bring("Current Player", "Any unit", "Anywhere", At least, 1);
Actions:
  Display Text Message(Always Display, "You have arrived.");
  Preserve Trigger();
}`;
try {
  api.document.update("Add the arrival trigger", (tx) => { tx.triggers.fromText(source); });
} catch (error) {
  api.ui.status(String(error)); // a parse error names the line
}
Try it

A location or unit the text names has to exist in the map, or the parse fails with the line number. The trigger reference lists every condition and action in this form. Use newTrigger / newCondition / newAction to change one field of an existing record.

Claiming generated triggers. claim(spec) marks a run of the trigger list as made by your plugin. The Trigger Editor badges and locks those rows and shows your description with a button that opens your plugin. The Text Trigger Editor fences them off, and Import Triggers warns before replacing them.

The run is found by content: spec.locate(list) returns { start, count }, or null when the triggers were edited or removed. Keep a fingerprint of each trigger you generated and search for them, as TrigScript does. Call refresh() on the handle after regenerating. claims() lists every plugin's claimed runs.

const mine = new Set<string>(); // fingerprints of the triggers this plugin generated

api.document.update("Generate", (tx) => {
  const trigger = api.triggers.newTrigger();
  trigger.actions[0] = api.triggers.newAction(api.consts.triggers.action.PreserveTrigger);
  mine.add(api.triggers.fingerprint(trigger));
  tx.triggers.add(trigger);
});

api.triggers.claim({
  label: "the wave generator",
  badge: "waves",
  locate(list) {
    const start = list.findIndex((t) => mine.has(api.triggers.fingerprint(t)));
    if (start < 0) return null;
    let count = 1;
    while (start + count < list.length && mine.has(api.triggers.fingerprint(list[start + count]))) count++;
    return { start, count };
  },
  describe: () => "Made by the wave generator. Change the waves there, not here.",
});
Try it

Open Triggers ▸ Trigger Editor… after running it: the new row carries the badge and is locked, and the form is replaced by your description.

The Trigger Editor with a claimed trigger: the row has a "waves" badge and the right-hand side shows the plugin's description in place of the form. An "As text" button added by a plugin is at the bottom left

The As text button at the bottom left of the picture is a dialog slot.

api.query#

Reference

Read-only questions about the open map.

An issue's target from validate() is a unit, location or trigger that view.goTo accepts, or a settings dialog to open. The problems panel recipe uses both.

Where a Command Center fits, asked the way the Units palette asks:

const at = await api.ui.pickTile({ prompt: "Click where the Command Center should go" });
if (at) {
  const t = api.consts.tile;
  const verdict = api.query.placement(106, at.x * t, at.y * t); // 106 is the Terran Command Center
  api.ui.status(verdict?.problem ? `Blocked: ${verdict.reason}` : "It fits.");
}
Try it

api.view#

Reference

Where the map view is looking, and showing the user something.

// Visit each start location in turn, until the user takes the view back.
for (const start of api.query.startLocations()) {
  const area = { x0: start.tx - 6, y0: start.ty - 6, x1: start.tx + 6, y1: start.ty + 6 };
  if (!(await api.view.reveal(area))) break;
  api.view.flash({ units: [start.index], kind: "attention" });
  await new Promise((next) => setTimeout(next, 800));
}
Try it

api.data#

Reference

The game's own tables (units.dat and the rest): hit points, costs, weapons, flags, graphics. Call load() first; ready() says whether they are already in memory. Everything is null when the game data was never installed, so degrade instead of throwing. Values are as the files store them: hit points, for one, are in 256ths.

api.gameData#

Reference

Which set of game files the editor uses, the game's own or a mod's, and the plugin side of Help ▸ Game Data…. The "gameData" event fires on every change.

A mod's files replace the game's in the same formats, so data, tileset, graphics and names follow them automatically, at whatever width the mod's tables have: data.units() can hold more than 228 types, names.unitGroups() then ends with the set's own groups, and graphics.icon pictures the new types where the set has a sheet for them. So take counts, names and widths from api.data and api.palette rather than the game's numbers (228 unit types, 130 weapons): the editor's own plugins do, and a mod's tables are wider and named differently. A plugin written only for the game's own data can check profile().id ("starcraft") and turn itself off for anything else, or say which of its parts read the game's own data, as Walkability and Magenta do.

const source = api.gameData.source();
api.log(source ? `${source.profile.name}: ${source.label}` : "still starting up");
for (const set of await api.gameData.profiles()) api.log(`data set ${set.id}: ${set.name}`);

const dat = await api.gameData.read("arr/units.dat");
api.log(dat ? `units.dat is ${dat.length} bytes` : "no game data installed");
Try it
// A table editor's loop: draw from the edited tables, and name them once their digest is known.
const edited = new Map<string, Uint8Array>(); // by the game's names, as a mod keeps them
await api.gameData.attach({ id: "draft", name: "Draft" }, (path, file) => (file.member && edited.get(file.member)) ?? null);
// … after an edit:
api.gameData.reload();
api.gameData.rehash(await hashOfMod(edited)); // the mod's hash over every file of the set (core's modHash)

api.consts#

Reference

The numbers the map file is written in, so a plugin does not hard-code them: pixels per tile, the start location and resource unit ids, the unit and sprite flag bits, the Anywhere location's slot, and triggers, which has every condition and action type, player group and argument value.

For an argument that takes one of a fixed set of values, api.triggers.defs.choices gives the values with their labels:

// What each argument of a Set Switch action can be.
const def = api.triggers.defs.action(api.consts.triggers.action.SetSwitch);
for (const arg of def?.args ?? []) {
  api.log(arg.label, api.triggers.defs.choices(arg.kind).map((c) => `${c.label} = ${c.value}`));
}
Try it

api.graphics#

Reference

The images the map view draws, for your own lists and previews.

// A mod's marine in player 2's colour on Ice, beside the game's own.
const mine = await api.gameData.read("unit/terran/marine.grp");
const theirs = await api.gameData.read("unit/terran/marine.grp", { under: true });
for (const bytes of [mine, theirs]) {
  const pic = bytes && (await api.graphics.grpImage(bytes, 0, { palette: "ice", teamColor: 1 }));
  if (pic) api.log(`a ${pic.width} × ${pic.height} picture`);
}
Try it

Rules for using them:

api.commands#

Reference

Named actions, so a menu item, a hotkey, a context-menu entry and another plugin can all reach the same one.

// Every command other plugins offer.
for (const c of api.commands.list()) if (c.pluginId !== api.plugin.id) api.log(c.id, c.title, c.enabled ? "" : "(disabled)");
Try it

api.services#

Reference

A command is one action; a service is an object to share, such as an account, a server connection or a compiler. One plugin provides it by name and others reach it by that name, whichever starts first.

The scmjs.dev plugin provides its account this way as scmjs-dev.account, and TrigScript its build as trigscript.build.

api.sync#

Reference

Editing a map together. The editor turns each change to the map into an op (plain JSON) and applies other people's ops in the order a server gives. Your plugin carries them between the two. The scmjs.dev plugin's shared maps are built on this.

This example needs a server of your own, so it has no Try it link:

const session = api.sync.start({
  send: (op) => socket.send(JSON.stringify({ type: "op", op })),
  onEnd: (reason) => leaveRoom(reason),
  onApplied: (report) => { if (report.dropped > 0) showNotice(`${report.dropped} changes no longer applied`); },
});
socket.onmessage = (m) => {
  const msg = JSON.parse(m.data);
  if (msg.type === "ack") session?.confirm();      // the server accepted our oldest op
  if (msg.type === "op") session?.receive(msg.op); // someone else's, in the server's order
};

The server's job is small: put everyone's ops in one order, confirm each to its sender, and pass it on to the others. It never needs to read the map.

The editor does the rest. Your own ops apply at once. If someone else's arrives before the server has confirmed yours, the editor undoes yours, applies theirs and reapplies yours, so every editor ends with the same map. Changes find their objects by content, so an edit to a unit someone else deleted is dropped; onApplied reports how many.

api.terrain#

Reference

Read-only help with the current tileset: the terrains that can be painted (types, isomTypes), what a tile is (tileInfo, terrainAt, color, heightOf), the ISOM lattice (diamondAt, diamondsIn), floodRegion and blendCandidates. Also the Terrain palette's current brush (active / setActive) and Tools ▸ Symmetry (symmetry / setSymmetry, mirror).

For hand-made terrain: seamStep is the measure View ▸ Seam Overlay draws by and seams counts the seams it would draw; pinned lists the pinned tiles and handLaid the tiles the isometric data does not account for, which are the ones worth pinning before a plugin repaints around them; symmetryShares says how alike the map is to its image under each symmetry mode, and fairness is the full report for one mode: the small squares that differ in walking, height and building, where they are, and the resources with no equal counterpart.

// Widen the picked ramp by three steps and keep it as laid.
const ramp = api.palette.active().doodad;
const [axis] = api.palette.stretchAxes(ramp);
if (axis) {
  api.document.edit("Wide ramp", (tx) => { tx.pin(tx.placeStretchedDoodad(ramp, 40, 30, axis, 3)); });
}

// Is a mirrored map the same on both sides?
const report = api.terrain.fairness("h");
if (report && report.unlike > 0) {
  api.ui.status(`${report.unlike} small squares differ in ${report.places.length} places`);
}
Try it

The Tile palette's sheet, blocks and pieces are here too. sheet() says how big the tileset's sheet is and where the groups a data set adds begin; blockFrom takes a rectangle of it as a block; pieces() is the list the Pieces view shows, pieceAt the piece Alt+click would pick and blockOf the block that lays a piece; cutPieces runs the editor's rule over maps of your own. providePieces lists named pieces of yours in the Pieces view, and provideTypes names flat ground the tileset does not type, for the Rect brush. active().block is the block the Tile brush lays, and setActive({ block }) arms it. Named pieces for a tileset puts these together.

Terrain borrowed from another tileset (the Isometric tab's "From other tilesets"): borrowed() resolves to what the open map's tileset can lay that way, each with an id for setActive({ terrain }) and tx.paintBorrowed(diamonds, id), which paints it with the other tileset's own brush and writes the copies. Await it before painting: it reads the other tileset's files; { scan: true } works the copies out first where nobody has. provideBorrowTable hands the editor the pairs of tiles a mod meant for a pair of tilesets, instead of its own match by pictures. Each row of borrowed() also says, in borders, which of this tileset's grounds the terrain has drawn borders against and where each came from ("maps", a plugin's id, or the data set's terrain file); where one is known, tx.paintBorrowed lays the border as the brush does (unless the Drawn borders switch is off). provideBorderTable gives one: the tiles to lay for each shape of the border between a borrowed terrain and a ground, and it stands ahead of the terrain file's and of what maps taught. A mod's terrain.json does what providePieces, provideTypes, provideBorrowTable and provideBorderTable do, for everyone who adds the mod (Terrain a mod declares); what a plugin declares is listed ahead of it.

const roof = (await api.terrain.borrowed()).find((b) => b.source === "install" && b.name === "Roof");
if (roof) api.document.edit("Roof", (tx) => { tx.paintBorrowed(api.terrain.diamondsIn({ x0: 20, y0: 20, x1: 36, y1: 30 }), roof.id); });
// roof.borders: [{ ground: 2, from: "maps" }] — a drawn border against Dirt, learned from maps
Try it

Copied terrain (the Isometric tab's "Copied terrain", in the guide): copies() resolves to the terrains the open map's tileset holds again at another height with their edge pieces, each with an id for setActive({ terrain }) and tx.paintCopy(diamonds, id), whether it is complete (else how many shapes are missing), and the blocks of tiles it can be laid with and the ground each is drawn for. provideCopies hands the editor one such block, which takes the place of what the editor found for that terrain and height; a mod's terrain file can carry the same (copies).

const mud = (await api.terrain.copies()).find((c) => c.complete && c.height === 1);
if (mud) api.document.edit("Mud", (tx) => { tx.paintCopy(api.terrain.diamondsIn({ x0: 20, y0: 20, x1: 36, y1: 30 }), mud.id); });
Try it

checkIsom() measures how well the ISOM lattice matches the tiles. Offer a rebuild when it reports stale, not merely mismatched: some mismatch (hand-placed tiles, blends) never goes away.

const report = await api.terrain.checkIsom();
if (report?.stale && (await api.ui.confirm("The isometric data is out of step with the tiles. Rebuild it?"))) {
  api.document.edit("Rebuild ISOM", (tx) => { tx.rebuildIsom(); });
}
Try it

api.tileset#

Reference

The open map's tileset: id(), name(), isLoaded(), load() and raw() for the decoded data. load() resolves false when the graphics were never installed, which is a normal state. load("jungle") fetches another tileset without changing the map, which graphics.renderClip needs to draw a clip from a map on that tileset.

api.selection#

Reference

The marked area (markedArea / markArea), the selected units, sprites, doodads and locations (by index, with a setter for each), the active layer, and the Layers panel's locks. Listen for the "selection" event to follow what the user selects.

api.clipboard#

Reference

The Cut / Copy / Paste layer, sharing the user's clipboard: copy, cut, paste, clip / setClip, and the parts and paste mode. A Clip can be pasted into another map. capture() returns what copy would take without touching the user's clipboard, for a plugin that keeps its own clips, like Stamp Library.

// Take the top-left 8 × 8 tiles without touching the user's clipboard,
// and stamp them twice in one undo entry.
const clip = api.clipboard.capture({ rect: { x0: 0, y0: 0, x1: 8, y1: 8 } });
if (clip) {
  api.ui.status(api.clipboard.summary(clip));
  api.document.edit("Stamp twice", (tx) => {
    tx.paste(clip, 8, 0);
    tx.paste(clip, 16, 0);
  });
}
Try it

api.exchange#

Reference

The formats behind File ▸ Import / Export: SCMDraft's .trg trigger files (encodeTrg / decodeTrg) and the tab-separated strings file (formatStrings / parseStrings).

api.palette#

Reference

What the Units, Sprites, Doodads and Fog palettes have picked and what they list, so a plugin can use "whatever the user chose" without a picker of its own. Paint does this. It also holds the placement rules (collision, terrain, snap to grid, remove stranded units) that placeUnit, canPlaceUnit and query.placement follow. The Terrain palette's pick is terrain.active(). For a doodad, stretchAxes lists the directions it can be stretched along (a ramp along its cliff, a bridge along and across its deck) and doodadTwin names the doodad that is its mirror image, the ramp for the cliff running the other way.

api.names#

Reference

The names behind the numbers in a map: units, upgrades, techs, weapons, player types, races, player groups, trigger types and AI scripts from the game (with a mod's own names under a mod's data set, see docs/game-data.md), and strings, locations, switches, players and tiles from the open map. The list forms return { value, label }[] for a drop-down. race(value) names the game's eight races and the races the data set in use declares (gameData.races()), and any other number as Race and the number; races() lists the game's eight, then the declared ones.

// How many of each unit type the map has, by name.
const counts = new Map<string, number>();
for (const u of api.document.scenario()?.units ?? []) {
  const name = api.names.unit(u.unitId);
  counts.set(name, (counts.get(name) ?? 0) + 1);
}
api.log([...counts].sort((a, b) => b[1] - a[1]));

// A list form, straight into a drop-down.
const upgrade = api.ui.widgets.select(api.names.upgrades());
Try it

api.text#

Reference

StarCraft's text control codes (bytes 0x01–0x1F, written <XX>), from the same table the String Editor uses. Use it rather than your own copy: the numbering is easy to get wrong.

Repair's string checks are these functions over api.query.strings().

// Every string in the map as the game would draw it, one coloured span per run.
const lines = api.query.strings().flatMap((s) => (s ? api.text.runs(s) : []));
api.ui.dialog({
  title: "Strings as the game draws them",
  mount(body) {
    body.style.background = "#000";
    for (const line of lines.slice(0, 40)) {
      body.append(api.ui.el("div", {}, ...line.runs.map((run) => api.ui.el("span", { style: { color: run.color } }, run.text))));
    }
  },
});
Try it

api.ui#

Reference

Everything a plugin shows: messages and questions, dialogs, panels, status items, map buttons, preferences pages, dialog slots, map tools, overlays, picks, file types, map views, widgets and tooltips. Putting things on screen covers each in turn. Two calls fit nowhere else:

api.menu / api.contextMenu / api.hotkeys#

References: menu, context menu, hotkeys

Menu items, right-click entries and keys. The rules are in Menus, context menus and hotkeys.

api.i18n#

Reference

Translating your plugin the way the editor translates itself: register your catalogues, then t(text, params) translates. Translating shows the pattern the project's plugins follow.

api.events#

Reference

on(event, fn) listens for a change. Events in Core concepts lists every event and the rules listeners follow.

api.storage#

Reference

get(key, fallback), set(key, value) and remove(key) keep JSON in the browser under your plugin's id. set returns false when the browser refuses (the quota is a few megabytes for the whole editor), so a plugin storing the user's work can say so. Users can see and clear your keys in Preferences ▸ Storage, so never keep the only copy of something there.

const runs = api.storage.get("runs", 0) + 1;
const kept = api.storage.set("runs", runs);
api.log(kept ? `run number ${runs}` : "the browser's storage is full");
Try it

For data that belongs to one map, use document.extras instead, so it travels with the file.

api.scope()#

Reference

A child of your api that can be removed as a whole. Everything registered through scope.api (menu items, hotkeys, listeners, panels, dialogs, overlays, map tools, commands, services) is removed when you call scope.dispose(), and the plugin's own registrations stay. After the dispose, writes to the map through scope.api are refused, as they are for a plugin that has been turned off. Scopes can contain scopes, and turning the plugin off removes every scope it made.

// A mode the user turns on and off: its menu item and listener come and go together.
let mode: ReturnType<typeof api.scope> | null = null;

api.menu.add("Tools", {
  label: "Toggle Watch Mode",
  run: () => {
    if (mode) {
      mode.dispose();
      mode = null;
      return;
    }
    mode = api.scope();
    mode.api.menu.add("Tools", { label: "Watch Mode is on", enabled: () => false });
    mode.api.events.on("commit", (e) => api.log("changed:", e.label));
  },
});
Try it

A scope uses the plugin's own id, storage and name in the log. The API Playground runs each snippet in one. Timers and sockets are not registrations, so clear them yourself.

api.plugin, api.apiVersion, api.log(...)#

Reference

Your plugin's id, name and source, the API version, and a logger. log writes to the browser console and to the editor's View ▸ Debug Console, which users copy into bug reports, so write lines someone else could follow.

api.log(`${api.plugin.name} (${api.plugin.id}) from ${api.plugin.source}, API ${api.apiVersion}`);
Try it

scmJS 0.20.0 + main@c323d11 · Generated from the repository. The source is under the MIT license, which does not cover what ATTRIBUTION.md lists. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.