The dev loop
phantom-plugin dev runs your plugin inside Phantom while you work on it. Components hot reload, the logic reloads when its code changes, and the manifest is checked every time you save.
The CLI is @phantomclient/plugin-cli. New plugins already depend on it and have a script for each command:
npm run dev # phantom-plugin dev
npm run build # phantom-plugin build
npm run validate # phantom-plugin validate
npm run pack # phantom-plugin packStart it
npm run devThis serves the plugin on port 5299. Phantom looks for dev plugins on ports 5299 to 5309, so if you're running more than one, give each its own port:
phantom-plugin dev --port 5300Turn on Developer mode
In Phantom, open Plugins and turn on Developer mode. Your plugin shows up marked Development. It's served from the dev server rather than installed, but it follows the same rules as a store plugin and asks for its permissions the first time it runs.
Pick the games it runs on in its Games tab.
What reloads
- Views (panels, pages, canvas widgets and command views) hot reload in place when the component changes.
- Logic (
setupand commands) reloads in place when its code changes, without restarting the game or Phantom. Whateversetupreturned runs first and is waited for. Then everything the old code's SDK still held is released (hooks, UI rules, overlays, watches, keys, traffic subscriptions,ctxlisteners), andsetupruns again with the new code. If the newsetupthrows, the plugin shows the error and stack, and the next save tries again. - The manifest is read again when
package.jsonchanges. Add a permission and the player is asked again, like with an update.
Turning the plugin off or closing its game runs the same cleanup. If your plugin draws in the game, return something from setup that removes the drawing, or it stays after the plugin stops.