Writing a Plugin
SignalRange plugins are small git repositories that the engine compiles into its own bundle. A plugin registers things through a fixed API at boot. Today a plugin can add:
- antenna hardware configs, with an optional custom core class;
- a Mission Control page for an antenna kind (replaces ACU Control for those antennas);
- a Mission Control station tab on field stations;
- routes;
- campaigns and scenarios.
Anything a plugin registers shows up where the engine already looks. A plugin antenna appears in every sandbox’s LOADOUT picker with no UI work.
Quick start
Section titled “Quick start”# In a SignalRange checkoutpnpm install
# Scaffold a plugin (creates src/plugins-external/signal-range-plugin-my-dish)pnpm run plugin -- create my-dish
# Boot the app with only this plugin enabled, in a sandbox, with its antenna selectedpnpm run plugin -- dev signal-range-plugin-my-dish
# Validate and testpnpm run plugin -- doctor signal-range-plugin-my-dishpnpm run plugin -- test signal-range-plugin-my-dishThe scaffold is its own git repository. Push it anywhere. Users install it with:
pnpm run plugin -- add https://github.com/you/signal-range-plugin-my-dishpnpm run buildOther commands: list, update, remove, restore and sync. Prefer starting from GitHub? The
signal-range-plugin-example repository is
the rendered scaffold and works with “Use this template”.
Layout of the example
Section titled “Layout of the example”signal-range-plugin-example/ signal-range-plugin.json manifest src/plugin.ts the plugin class src/antenna-config.ts one AntennaConfig locales/en.json strings under plugins.<id> __tests__/plugin.test.ts unit testThe manifest
Section titled “The manifest”{ "formatVersion": 1, "name": "signal-range-plugin-example", "version": "0.1.0", "description": "An example SignalRange plugin.", "author": "You", "repository": "https://github.com/you/signal-range-plugin-example", "engine": ">=1.1.0 <2.0.0", "plugins": [ { "id": "ExamplePlugin", "className": "ExamplePlugin", "entry": "src/plugin.ts", "defaultConfig": { "enabled": true, "order": 500 }, "dependencies": [] } ], "localesDir": "locales", "provides": { "antennas": ["EXAMPLE_ANTENNA"] }}nameequals the install folder name and is kebab-case.engineis a semver range checked against the engine version. A different major version refuses to install unless you pass--force.- Each
pluginsentry becomes one plugin.ordersets load order; lower loads first. provides.antennasis informational.doctorchecks the ids appear in your source, anddevselects the first one.
The plugin class
Section titled “The plugin class”import { AntennaRegistry } from '@app/equipment/antenna/antenna-registry';import { type PluginApi, SignalRangePlugin } from '@app/plugins/signal-range-plugin';import { ANTENNA_ID, antennaConfig } from './antenna-config';
export class ExamplePlugin extends SignalRangePlugin { readonly id = 'ExamplePlugin';
register(api: PluginApi): void { // Strings are merged before register() runs, so t7e already knows them. api.antennas.register( ANTENNA_ID, { ...antennaConfig, name: api.t7e('plugins.ExamplePlugin.antennaName') }, { source: `plugin:${this.id}` } ); }
dispose(): void { AntennaRegistry.getInstance().unregister(ANTENNA_ID); }}register() runs once at boot, after the plugin’s locale file is merged and before the first route
resolves. It may be async. A plugin that throws is logged and skipped. Boot never fails because of a
plugin.
The two hard rules
Section titled “The two hard rules”- The entry file must have a named export matching
classNamein the manifest. - The class’s
readonly idmust equal the manifest’s pluginid. It keys the plugin’s settings and locale strings.
pnpm run plugin -- doctor <name> checks both, along with engine compatibility and locale
namespacing.
What PluginApi gives you
Section titled “What PluginApi gives you”| Member | What it is |
|---|---|
engineVersion |
Host version string. |
isPrivate, isAuthoring |
Build flags. |
antennas |
Register antenna configs: register(id, config, { source, core? }), plus unregister, get, find, has, list. |
missionControl |
registerAntennaPage(kind, factory, { tabLabel? }) and unregisterAntennaPage(kind). registerStationTab({ id, label, stationClasses, factory, isDefault? }) and unregisterStationTab(id). |
router |
addRoute({ pattern, show, hide }). |
campaigns |
registerCampaign(data). |
settings |
Read your config from settings.settings.plugins[id]. You may not write other plugins’ settings. |
events |
The application event bus. |
t7e |
Translate. Your strings live under plugins.<id>.*. |
The API is additive. New capabilities are new optional members. Existing ones do not change shape within a major version.
Antennas
Section titled “Antennas”register(id, config) takes an antenna config. Every field is documented on the config type in
src/equipment/antenna/antenna-configs.ts. Ids are upper snake case and must not collide with a
built-in or another plugin. A plugin may re-register its own id but never someone else’s.
Pass core to supply a factory that builds a custom antenna core. Use it for behavior a config
cannot express, such as electronic beam steering. The factory builds the headless variant that
Mission Control uses. The engine keeps the UI classes.
A custom core can override the protected gain hooks (antennaGain_dBi, patternGain_dBi_,
beamwidth3dB_deg_, effectiveOffAxisDeg_, angularSeparationDeg_, mainLobeEdgeDeg_). The link
budget and the RF narrowing callbacks both call them, so an override such as scan loss is seen by
both.
Mission Control pages and tabs
Section titled “Mission Control pages and tabs”An antenna config has an optional kind. Omitted means 'reflector', which gets the stock ACU
Control tab. To replace that tab, set your own kind on your configs and register a page for it:
api.antennas.register('MY_ARRAY', { ...config, kind: 'phased-array' }, { core: createMyCore });api.missionControl.registerAntennaPage( 'phased-array', (groundStation, containerId, antennaIndex) => new MyArrayPage(groundStation, containerId, antennaIndex), { tabLabel: 'Array Control' });The factory runs when the operator opens that antenna’s tab. It returns an object with tabLabel,
dom, activate(), deactivate() and dispose(), the same lifecycle as ACU Control. It renders
into the element whose id is containerId. Pass tabLabel in the options because the tab strip is
drawn before the page exists. Every antenna of a station gets its own page. 'reflector' cannot be
registered.
To add a whole tab to field stations, use a station tab:
api.missionControl.registerStationTab({ id: 'my-app', label: 'MyApp', stationClasses: ['field'], factory: createMyApp, isDefault: true,});'field' means the stations of the Frontline campaign, where the professional tabs are hidden. The
built-in Phased Array and Terminal App plugins use these two calls and nothing else, so they are
good working examples.
Strings
Section titled “Strings”Put English strings in locales/en.json, rooted at plugins.<id>:
{ "plugins": { "ExamplePlugin": { "antennaName": "Example 4.5m Ka-Band" } } }Only English is bundled today.
Built-in plugins
Section titled “Built-in plugins”A plugin that ships with the game lives in src/plugins-builtin/<name>/. It is a normal plugin
that uses only the public API. It is listed in the engine’s plugin manifest with a dynamic import
and needs no manifest file or CLI step. See Phased Array and
SkyLink Terminal for what they do.
Trying a plugin antenna
Section titled “Trying a plugin antenna”Open any campaign sandbox and click LOADOUT in the command bar. Every registered antenna,
built-in and plugin, is listed per station. Applying a choice restarts the sandbox from a clean
state and remembers the choice for that sandbox. For a one-shot launch, add ?antenna=<ID> to the
sandbox URL. Use ?antenna.1=<ID> for the second station.
dev boots the app with a settings override that enables only your plugin. Run dev --url to
print the URL without starting anything.
Testing
Section titled “Testing”Unit tests live in __tests__/ and run under the engine’s test runner with pnpm run plugin -- test <name>. The example test registers the plugin against a minimal PluginApi, then checks the
registry and a headless antenna built from your config. The scaffolded CI workflow checks out the
engine at your target version, installs your plugin and runs typecheck and tests.
Things to know
Section titled “Things to know”- The engine type-checks installed plugin sources. A type error in a plugin fails the engine’s typecheck.
- There are no runtime dependencies. The build does not compile a plugin’s
node_modules. Use the engine’s packages. - Class names survive minification, so the
classNamelookup is safe in production. - Lint stops at the plugin boundary.
What is committed
Section titled “What is committed”Plugin clones are gitignored. The engine commits the record of the plugin set: external-plugins.json
(the lockfile) and the generated manifest. A fresh checkout restores the same plugins with pnpm run plugin -- restore, which the build runs for you.
Not yet available to plugins
Section titled “Not yet available to plugins”Objective condition types, fault types and an in-app plugin manager. Each would be a new optional member of the API.
Licensing
Section titled “Licensing”Plugins may use any license. The example template is MIT. SignalRange itself is AGPL-3.0, and a plugin compiled into a SignalRange build becomes part of that combined work, so distribute accordingly.
