Trigger Script
scm-js/plugin-trigger-script, installed
from Browse Plugins, is the Script Editor: a TypeScript-subset language kept as a file inside
the map (scmjs\triggers.ts, with a build manifest in scmjs\triggers.json) and compiled
into a block of the trigger list. It used to be part of the editor and was moved out so
the editor no longer carries Monaco and a second TypeScript; the plugin fetches both from
a CDN when the dialog first opens (Monaco as jsDelivr's bundled ESM build, TypeScript into
a blob worker with a main-thread fallback). It is the worked example for
api.triggers.claim — the manifest holds a hash of the generated records, locate looks
for them at the recorded start and then anywhere in the list, so the Trigger Editor badges
and locks the block wherever local edits moved it, and a hand edit inside it makes the
block stale (ordinary triggers again; the next Build appends a fresh one) — and for a
plugin publishing commands for other plugins: trigger-script.state, .declarations,
.compile, .build, .print, .simulate, .triggerAtLine and .open, which the AI
plugin calls through api.commands.run after checking commands.has, listening to the
"commands" event since plugins activate in no fixed order. Its source keeps the
compiler out of the browser-specific parts (compiler/ is pure, tested under vitest with
the real typescript package, and vendors the trigger tables it reads), which is what
lets the same modules run in the worker.