feat(m4): playtest friction: perf overlay, fresh import, token seed (#82)

Opt-in ?perf=1 overlay (fps, frame p50/p95, JS p50/p95, tokens, zoom; no node or ticker work when off). fff-vtt import creates and migrates a fresh/empty state dir through the shared server startup path; devbox run serve gains --image. devbox run seed creates deterministic labelled NPC tokens over the real WS (idempotent rerun, --replace), and the GM token form defaults X/Y to the viewport centre.
This commit is contained in:
2026-11-21 17:20:05 +01:00
parent 356705823b
commit 9c7f9de910
20 changed files with 933 additions and 53 deletions
+11
View File
@@ -347,3 +347,14 @@ proc migrate*(db: DbConn): int =
except CatchableError: discard # the original error is the one worth reporting
raise newException(MigrationError,
"migration " & $m.version & " (" & m.name & ") failed: " & e.msg)
proc openMigratedDatabase*(path: string): tuple[db: DbConn, applied: int] =
## The one startup path shared by the server, `gm-key` and `import` (#82): open the DB with the
## engine settings above, then apply every pending migration. A failure closes the connection
## before re-raising, so a caller that handles the error never leaks the handle.
result.db = openDatabase(path)
try:
result.applied = migrate(result.db)
except CatchableError:
close(result.db)
raise