@frontierjs/jetty
v0.0.12
Published
Browser extension framework for FrontierJS. MV3, Mesa runtime.
Readme
@frontierjs/jetty
Browser extension framework for FrontierJS. MV3-first, Mesa-rendered, Junction-connected.
Status: Phases 0–8 complete — every phase file passes (
bun run test, which runs plainnodeover the phases in order). Foundational architecture, port protocol, Junction adapter, channels, Resources, Islands, dev tooling, Firefox parity, and permission audit + CLI are all shipped and tested. See What's not yet done for what is still owed.
What's here
src/
define/ — defineHarbor, defineDock, defineOptions, definePier, defineIsland
runtime/ — port protocol, PagePort, harbor registry, channel registry, mount, surfaces
browser/ — typed cross-browser shim w/ permission errors + audit-miss warnings
audit/ — permission audit: scans source for chrome.*/browser.* use
junction/ — adapter contract, junction-adapter (the real one), default
WS adapter (placeholder), schema cache, auth flow
resources/ — harborApp (the handle sierra's createResource takes), the
page's port, and Harbor's session as state and Mesa signals
island/ — content-script runtime: shadow DOM mount, UnoCSS mirror, page-script bridge,
chrome.scripting registration
build/ — Vite plugin pipeline, manifest emitter, auto-gen, discover, config loader
dev/ — dev WS server + client snippet + classifier, FJS port scheme, orchestrator
bin/
build-ext.js — production build CLI
dev-ext.js — dev mode CLI w/ file watching + WS broadcast
test/
phase{0–9}.test.js — the architectural layers, run in order by
`bun run test` (phase2.5 is one of them)
fixtures/basic-ext/ — minimal smoke fixture (harbor + dock + 1 island)Build & test
This package supports both Node 24+ and Bun 1.3+. bun run test runs plain
node over the phase files in order, except phase 3, which runs under bun
because it boots a real Junction app (Junction is Bun-only).
bun install
bun run test # all phases, in order (phase 3 under bun)
bun run test:bun # the same phases under bun's runtime
bun run build:fixture # Chrome build → dist/chrome/
bun run dev:fixture # dev mode, Chrome only, WS on 8400
# npm works identically — the scripts are the same
npm install && npm testOther build/dev targets: build:fixture:firefox, build:fixture:both,
dev:fixture:both, and test:phase<n> / test:bun:phase<n> to run one phase
on its own.
After build:fixture, load test/fixtures/basic-ext/dist/chrome/ via
chrome://extensions → Developer mode → "Load unpacked".
After build:fixture:firefox, load dist/firefox/ via about:debugging
→ This Firefox → Load Temporary Add-on → select manifest.json.
Monorepo layout
This package lives at packages/jetty/ in the FrontierJS monorepo. Siblings it
reaches for (when present):
packages/mesa/— reactive runtime + compiler. Optional — jetty falls back to stub mount if missing, which passes a.mesafile through as JavaScript and fails later at Vite with a parse error inside the component. If a build reportsUnexpected JSX expressionat line 1, the compiler was not found.packages/junction/— WebSocket service client. Optional — jetty falls back to its built-in default WS adapter if missing.
Both are optional peers. In this repo they are workspace devDependencies, so the siblings are linked; an app that wants one installs it beside jetty.
An app installs neither. A surface has one package.json, at the app root,
so @frontierjs/mesa lives at <app>/node_modules and jetty's compiler lookup
walks up from extension/ to find it — see Using it in an app.
CLI tools
jetty build --root=. --browser=chrome|firefox|both [--verbose]
jetty dev --root=. --browser=chrome|firefox|both [--verbose]
[--launch] [--start-url=URL]
[--profile=DIR | --temp-profile]
jetty info --root=. [--browser=chrome] # print structure summary
jetty audit --root=. [--browser=chrome] # standalone permission audit
jetty manifest --root=. [--browser=chrome|firefox|both] # print manifest onlyjetty dev in a terminal takes keys: o opens the browser(s) with the
extension loaded (what --launch does at start), q quits. A launched
browser keeps its profile at <root>/.browser-profiles/<browser>/, so a
sign-in on the page under test and the extension's own storage survive a
restart — gitignore it. --temp-profile is web-ext's fresh profile per launch.
Permission audit
Set permissions.audit in jetty.config.js:
permissions: {
declared: ['storage', 'tabs'],
audit: 'warn', // 'warn' = log; 'strict' = fail build; false = off
}The audit scans built bundles for chrome.<ns>.* / browser.<ns>.* calls,
maps each namespace to its required manifest permission, and reports:
- missing — APIs used but permission not declared
- unused — declared but no calls detected (candidate for removal)
- unknown — namespace not in the catalog (typo or new API)
- dynamic —
chrome[expr]accesses that the audit can't resolve
Limits: the scanner uses string matching, not AST. Comments are stripped,
but minification can mangle access patterns. Framework-internal indirection
(jetty's own browser shim) is invisible to the audit by design — jetty
auto-adds the perms it needs (scripting when islands present).
Browser support
Both Chrome and Firefox use Manifest V3. Differences jetty handles
automatically per --browser flag:
| Field | Chrome | Firefox |
|--------------------------------|--------------------------|------------------------------------------|
| Background script | background.service_worker | background.service_worker (default)or background.scripts[] (opt-in) |
| Min browser version | minimum_chrome_version | browser_specific_settings.gecko.strict_min_version |
| Stable extension ID (signing) | n/a (Chrome assigns) | browser_specific_settings.gecko.id (required for AMO) |
| host_permissions | identical | identical |
| web_accessible_resources | identical | identical |
| permissions / options_ui | identical | identical |
| commands (keyboard shortcuts) | identical | identical |
Firefox-specific settings live under firefox: {...} in jetty.config.js:
firefox: {
geckoId: '[email protected]',
strictMinVersion: 121,
// background: { useScripts: true }, // optional: classic scripts[] form
}A keyboard shortcut is a commands entry in jetty.config.js, written as the
manifest spells it and received in Harbor through chrome.commands.onCommand:
commands: {
'pick-element': {
suggested_key: { default: 'Ctrl+Shift+E', mac: 'Command+Shift+E' },
description: 'Start the element picker',
},
}Using it in an app
An app gets jetty as the extension/ surface — a sub-project at the app root
beside api/, web/ and widgets/, with the same six folders every sub-project
has. Root README.md § Project Structure is canonical.
fli make:extension # config/, src/harbor, src/dock, test/, deploy/
fli dev:extension # watch + reload over the dev port (8400)
fli extension:build # → extension/dist/chrome/ (--browser both for Firefox too)
fli extension:audit # permissions declared vs. chrome.* actually calledThose wrap the jetty bin with --root=extension, so an app's build and
this package's tests are one program. fli new --extension adds the surface to
any template; fli new --template extension-only is a project whose whole
product is the extension — no api/, no web/.
The app owns the install, not the surface: one package.json at the app
root, so @frontierjs/mesa lives at <app>/node_modules and jetty's compiler
lookup walks up from the surface to find it.
Resources
A page's Resource is sierra's own, the same one a web page uses. Only the app it talks to differs:
import { createResource } from '@frontierjs/sierra/resource'
import { harborApp } from '@frontierjs/jetty/resources'
export const orders = createResource('orders', { app: harborApp() })A page holds no connection, because MV3 keeps it in the service worker.
harborApp() is a Junction client created with relay: each call goes to Harbor
as the frame the socket would have carried, Harbor's client makes it, and pushes
come back over the port. So the tether, query matching, stale and
save()'s patch-what-changed all behave as they do on a web page. A call only
HTTP can carry (a file upload, a filtered bulk write, a findFirst) is refused by
name. Sign-in is signIn(email, password) / completeSignIn(code) / signOut() from the same import,
because Harbor holds the token.
What's not yet done
- AST-based audit. The current audit uses string matching, which has known false negatives on framework-internal indirection and minified code. A swap to a real JS parser (acorn/swc) would catch both.
- The default adapter is still a placeholder.
createJunctionAdapterover@frontierjs/junction/clientis the real connection and closedFJS-279;default-adapter.jsbeside it is the stand-in it says it is, and nothing points at it. Mesa is not in this bracket either: the compiler is found and used whenever the app that owns the surface has it installed, and the fixture's dock is a real Mesa component.
Architecture references
- Spec: the original planning document is not in this repo; what shipped is
described here and in
CLAUDE.md - Mesa vision:
packages/mesa/docs/VISION.md(informed Phase 3 integration) - Resources are sierra's, over a relaying Junction client (
FJS-D650);IDEAS/shipped/sierra-scope.md§ 2.7 and § 3 item 5.
FJS port scheme
Jetty's dev WS uses the FrontierJS port scheme:
[ENV] [CATEGORY] [PROJECT] [SERVICE]
8 4 XX X8= dev environment4= browser-extensions categoryXX= project slot (00–99, manually assigned per consumer extension)X= service slot (0 = primary dev WS, 1–9 reserved)
Jetty's own fixture uses 8400. Consumer extensions assign their own
project slot in jetty.config.js → dev.port and jetty validates the range
at build time.
