readme.md

Excalibur Dev Tools Plugin #

This excalibur game developers to easily inspect their games while making them!

Now live in browsers!

Debug

  • Performance issues
  • Actor graphics
  • Actor geometry
  • Colliders
  • Scenes
  • Toggle Debug Draw

Example Extension Running

Chrome: Running Locally & Side Loading #

If you want to develop locally

  • Install node.js
  • Run npm install in the root directory
  • Run npm run start:chrome this will start a parcel dev server, or run npm run build:chrome to produce a prod bundle
  • Open chrome://extensions/ and click "Load unpacked" chrome extensions tab
  • Select the dist-chrome directory in the excalibur-extension project excalibur-extension dist directory

Firefox: Running Locally & Side Loading #

If you want to develop locally

  • Install node.js
  • Run npm install in the root directory
  • Run npm run start:firefox this will start a parcel dev server, or run npm run build:firefox to produce a prod bundle
  • Open about:debugging#/runtime/this-firefox and click "Load Temporary Add-on..." firefox extensions tab
  • Select the manifest.json file inside the dist-firefox directory.

Building a release artifact for Chrome or Firefox #

  • Install node.js
  • Run npm install in the root directory
  • Run npm build:chrome to produce the final build artifact in dist-chrome
    • Zip the files in the directory, not the dist-chrome directory
    • Upload the zip to chrome
  • Run npm build:firefox to product the final build artifact in dist-firefox which can be zipped and uploaded
    • Zip the files in the directory, not the dist-firefox directory
    • Upload the zip to mozilla

How it works #

The message protocol (src/protocol.ts) is the fixed seam. Three layers carry it, and each seam has two interchangeable implementations — one for the browser extension, one for the embedded build:

PanelTransportPageExecutor<app-main>Lit panel UIsrc/components/createConnection()command switch · 200msheartbeat pollframe reconcile ·pickerOpSeq · 3-striketolerancesrc/driver/connection.tspage functions(closure-free, serializable)detect · inject · clock ·pickerentities · scene · materialssrc/page/window.___EXCALIBUR_DEVTOOLExcalibur Engine
Seam Extension build Embedded build
PanelTransport chrome runtime Port (src/panel-transport/extension.ts) in-memory pair (src/embedded/local-driver.ts)
PageExecutor chrome.scripting.executeScript, world MAIN (src/background.ts) direct function call (src/embedded/local-driver.ts)
Panel UI lives in the devtools panel page a same-origin dock iframe (src/embedded/host.ts)
Connection runs in the background service worker the game page itself

The runtime flow is identical in both builds — only the plugs differ:

loop[every 200ms]ex-debug:hello (tabId stamped by the transport)ex-debug:initex-debug:update-debug (settings push)execAll(detectExcalibur)find window.___EXCALIBUR_DEVTOOL (all frames)exec(inject, settings)apply debug settings, serialize game stateex-debug:heartbeat (instances, selectedFrameId, data)ex-debug:command (dispatch: ex-debug:kill, actorId)exec(kill, [actorId])actor.kill()on-demand replies (material-detail,entity-graphics) post back the same wayapp-main (panel)createConnection (driver)PageExecutorExcalibur Engineapp-main (panel)createConnection (driver)PageExecutorExcalibur Engine

Embedded devtools (no extension needed) #

The panel can also run directly inside a game page, firebug-style — no browser extension, no devtools window. Build it with:

  • npm run build:embedded → dist-embedded/ex-devtools.js (self-contained)

Drop it into any page running an Excalibur game (the engine already exposes itself to the devtools — no game-side code needed):

<script type="module" src="ex-devtools.js"></script>

A floating Ex button appears bottom-right and opens a resizable dock with the full panel (inspector, debug draw, materials, graphs, entity picker). window.ExDevtools exposes open(), close(), toggle(), and destroy(); appending ?ex-devtools=open to the URL opens the dock on load.

For development, npm run start:embedded serves a harness page with a demo game and the embedded devtools on top.

Testing #

  • npm run test:unit — node-level Vitest specs (settings schema/store/utils, formatters, GLSL tokenizer, and a serialization tripwire that proves every src/page/ function is still self-contained).
  • npm run test:browser — Vitest browser mode (headless Chromium via Playwright; run npx playwright install chromium once): boots a real Excalibur game and drives the embedded panel against it end to end.
  • npm run test — both.

Features That We Want! #

PR's welcome

Resources #

https://developer.chrome.com/docs/extensions/mv3/devtools/