- Never write new tests in this repo: no Vitest unit, component, hook or renderer tests, and no new
*.test.ts(x)files. Verify a change by building it and checking it in the running client.
Pure-TypeScript renderer library for the Volt retro Habbo client. Wraps PixiJS v8 for room/avatar rendering and provides the WebSocket
- event-bus infrastructure that the React client (
../volt) sits on top of.
- TypeScript 6.0 (root) + tsgo (
@typescript/native-preview, TS 7 preview compiler — used byyarn compile:fast, ~7× faster on this codebase) - PixiJS v8 (
pixi.js@8.18) - Vite 8 for build + bundling
- Vitest 4 for unit tests
- Yarn 4.18 workspaces (
packages/*) through Corepack, using thenode-moduleslinker for compatibility with the existing build tooling. - No React — this is a pure TS library; React lives in
../volt.
Twelve internal packages under packages/*/src/, each pinning
typescript: ^6.0.3 in its own devDependencies:
packages/
api public interfaces (IEventDispatcher, ISessionDataManager, ...)
assets asset loading + caching
avatar avatar rendering / figure resolution
camera in-room camera widget
communication WebSocket + composer/parser pipeline
configuration runtime config loader
events EventDispatcher + VoltEventType + per-domain events
localization LocalizationManager
room RoomEngine + RoomVisualization
session SessionDataManager + RoomSessionManager + handlers
sound SoundManager (howler-based)
utils shared utilities (BinaryReader, Logger, …)
Root index.ts re-exports everything from @volt/* so the React
client gets a flat import { … } from '@volt/renderer'.
Three additions matter for the React client integration. Keep these backwards-compatible:
Signature matches what useSyncExternalStore expects — returns an
unsubscriber, no need to juggle callback identity. Implemented in
packages/events/src/EventDispatcher.ts. The legacy
addEventListener / removeEventListener still work.
Equivalent for packet streams. Implemented in
packages/communication/src/CommunicationManager.ts.
Pattern: getXxxSnapshot() returns a frozen value cached internally;
mutators call invalidateXxxSnapshot() which drops the cache AND
dispatches an invalidation event. The React side reads via
useSyncExternalStore.
| Manager | Getter | Invalidation event |
|---|---|---|
SessionDataManager |
getUserDataSnapshot(): Readonly<IUserDataSnapshot> |
SESSION_DATA_UPDATED |
RoomSessionManager |
getActiveRoomSessionSnapshot(): Readonly<IRoomSessionSnapshot> | null |
ROOM_SESSION_UPDATED |
IgnoredUsersManager |
getIgnoredUsersSnapshot(): ReadonlyArray<string> |
IGNORED_USERS_UPDATED |
GroupInformationManager |
getGroupBadgesSnapshot(): ReadonlyMap<number, string> |
GROUP_BADGES_UPDATED (only on real changes — no-op refresh stays quiet) |
UserDataManager |
getRoomUserListSnapshot(): ReadonlyArray<IRoomUserData> |
ROOM_USER_LIST_UPDATED (inner IRoomUserData kept mutable — don't deep-clone) |
SoundManager |
getVolumesSnapshot(): Readonly<ISoundVolumesSnapshot> |
SOUND_VOLUMES_UPDATED (only when a volume actually changes) |
Snapshot interface contracts live under packages/api/src/volt/session/
and packages/api/src/volt/sound/. When adding a new snapshot, the
checklist is:
- Define the
Ixxx Snapshotinterface inpackages/api/src/volt/...and export it from the matchingindex.ts. - Add a
XXX_UPDATEDmember topackages/events/src/VoltEventType.ts. - Add
getXxxSnapshot()to the interface AND impl; cache + invalidate on every mutation path (don't forget batch operations like queue truncation — invalidate AFTER the full batch, not mid-way).
Adding snapshots here is the preferred way to unblock new React widgets — prefer it over exposing raw event-listener APIs on the client side.
Tracked separately from the v2.1.0 batch above; all are non-breaking additions or align-with-Arcturus fixes:
new RoomEnterComposer(roomId, password?, spawnX?, spawnY?). The
Arcturus RequestRoomLoadEvent handler reads the two extra ints only
when packet.remaining >= 8, so the same composer header serves both
the legacy 2-arg form (door spawn) and the 4-arg form (reconnect /
respawn at a specific tile). RoomSession + RoomSessionManager use the
4-arg variant in their enterRoom / reconnect paths.
RoomSettingsData (and its parser) now exposes allowUnderpass: boolean. Arcturus' RoomSettingsComposer already appends one
trailing int for this flag, and the new parser reads it via
if(wrapper.bytesAvailable) … readInt() === 1 so older servers that
don't emit the field still parse cleanly. SaveRoomSettingsComposer
accepts an optional allowUnderpass arg at the end of its parameter
list; the server-side RoomSettingsSaveEvent reads it under
packet.bytesAvailable() > 0.
IRoomSession.sendWhisperGroupMessage(userId) referenced a
ChatWhisperGroupComposer that never existed in the codebase and had
zero call sites in the React client. Both the interface declaration
and the broken impl are removed. The real whisper path is
RoomUnitChatWhisperComposer(recipientName, message, styleId) —
unchanged.
ArrayBufferLikedrift handled with explicit casts inBinaryReader/BinaryWriter/WsSessionCrypto.randomNonce()/ArrayBufferToBase64. The renderer never uses SharedArrayBuffer, so these are type-level narrowings only.Container.filtersin Pixi v8 isFilter[] | readonly Filter[] | null; the AvatarImage filter-stack mutation always goes through the spread-array branch now (no single-Filter fallback).Filteris imported explicitly from pixi.js.ExtendedSpritecasts the renderer toWebGLRendererinside theRendererType.WEBGLbranch sorenderer.gl/glRenderTarget.resolveTargetFramebufferresolve.FurnitureBadgeDisplayVisualization.updateSpritesignature realigned to the parent's 2-arg(scale, layerId)shape (was a custom 4-arg override that broke base-class assignability).TextureUtils.generateImagecasts the extractor'sImageLikeunion return toHTMLImageElement(the default backend produces one).Window.VoltConfigdeclaration inVoltConfig.tsrealigned to the client'sRecord<string, unknown>type so the merged decls agree.- Empty-tuple composers (
WiredRoomSettingsRequestComposer,WiredUserVariablesRequestComposer) annotate the return type(): []explicitly soIMessageComposer<[]>lines up.
Parsers that read "one tier of optional trailing fields per emulator release" (UserProfileParser, GetGuestRoomResultMessageParser, RoomSettingsDataParser, ModeratorUserInfoData, UserSubscriptionParser …) all use a flat chain:
if(!wrapper.bytesAvailable) return true;
// block N reads
if(!wrapper.bytesAvailable) return true;
// block N+1 reads
…Defaults come from flush(). When the next emulator release ships a
new trailing block, append if(!wrapper.bytesAvailable) return true;
- the new reads. Do NOT nest with
if(wrapper.bytesAvailable) { … }— the nested form re-indents the whole chain on every new tier and is the historical source of brittle reads.
onEvent(SETTINGS_UPDATED) cached volumeFurniUpdated /
volumeTraxUpdated by comparing castedEvent.volumeFurni (percent,
e.g. 75) against this._volumeFurni (fraction, e.g. 0.75) — so the
change check almost always reported "updated" for a real settings push
and only reported "unchanged" if the percent matched the fraction by
coincidence (0 / 100 only). Fixed: divide first, compare divided
values, then write. Also tracks volumeSystemUpdated for the new
SOUND_VOLUMES_UPDATED snapshot invalidation.
bytesAvailable is a boolean (the wrapper just answers "is there
anything left?"). The pet-breeding parser used to compare it against
12 as if it were a byte count, which TS 6 caught and which was
also semantically wrong. Replaced with the standard
if(!wrapper || !wrapper.bytesAvailable) return false; guard.
yarn build # vite build
yarn compile # tsc --project ./tsconfig.json --noEmit false
yarn compile:fast # tsgo (~7× faster, TS 7 preview)
yarn eslint # lint src + packages/*/src
yarn test # vitest run
yarn test:watch # vitest watch
yarn test:coverage # vitest with v8 coverage
../volt consumes this library via link:../volt-renderer
(yarn 4 node-modules linker). DO NOT use yarn link — it confuses
vite's asset resolution. The client's vite.config.js then maps each
@volt/* package directly to its source index.ts so there's no
build step needed for development.
When making changes to renderer APIs the React client uses, the
client's feat/react19-* branches contain consumers — check
volt/src/hooks/events/ and volt/src/hooks/{session,rooms}/
for the React-side bridge code.
SessionDataManager.getUserData(id)does NOT exist. Some legacy code in the React client used it under agetUserData ?truthy guard; the branch was always dead. OnlygetUserDataSnapshot()exists.bytesAvailableis a boolean. The codebase historically had one parser (PetBreedingMessageParser) that compared it against a number — fixed. The wrapper returns "any bytes left?", not a count. Use it as a truthy guard or follow withtry {} catchif you need optional reads.- Composer
getMessageArray()return type must match the type argument.IMessageComposer<[]>means the function returns[], notany[]. The twoWired*RequestComposers that ship empty payloads each annotategetMessageArray(): []explicitly. IRoomSession.sendChatMessage/sendShoutMessageaccept an optionalchatColour3rd arg (was required pre-2.1.1, now optional to match the historical call sites in the React client). The implementation forwardsundefinedto the composer just fine; pass a value only when you need a specific bubble colour.IRoomSession.passwordandIRoomSession.sendBackgroundMessageare now part of the public interface (they always existed on the implementation class — interface caught up).- The renderer is synchronous:
EventDispatcher.dispatchEventis a synchronous loop over listeners. Don't addawaitinside theprocessEventloop — it would change ordering guarantees that consumers rely on. - Workspace package devDeps pin TS at
^6.0.3soyarn compileinside any single package keeps working. The root TS 6 is the source of truth.
../volt— React 19 client (consumes this lib via link)../Arcturus-Morningstar-Extended— Java emulator (server side)../VoltV3-Housekeeping— Next.js + Prisma admin CMS
Server-pushed furni name/description changes (pairs with Arcturus'
FurnitureDataReloadComposer). SessionDataManager.applyFurnidataDelta (pure
applyFurnidataDeltaTo in packages/session/src/furniture/) patches
_floorItems/_wallItems by id + the roomItem/wallItem.name/desc.{id}
localization keys, then dispatches the window event volt-localization-updated
so the client's already-subscribed surfaces refresh. mode 0 = delta, 1 =
reload-hint (re-runs FurnitureDataLoader.init()). Kept SEPARATE from the
furni-editor's applyLiveFurnitureNameUpdate.
Adding an incoming packet: id in IncomingHeader.ts -> map in
VoltMessages.ts (this._events.set(IncomingHeader.X, XEvent)) -> Event +
Parser under messages/incoming/<area> + messages/parser/<area> -> wire the
barrel chain (<area>/index.ts -> parent index.ts -> package src/index.ts).
Adding an outgoing composer: id in OutgoingHeader.ts -> register in
VoltMessages.ts (this._composers.set(OutgoingHeader.X, XComposer)) -> Composer
under messages/outgoing/<area> -> wire the barrel chain. An unregistered composer
makes getComposerId() return -1, logs "Unknown Composer", and the packet is
silently DROPPED — the request never reaches the server.
A feature usually needs BOTH directions registered. VoltMessages holds two
maps — _events (incoming) and _composers (outgoing). When a panel is "dead",
audit BOTH, not just _events.
Gotchas:
- A branch based on
origin/Devmay NOT contain the furni-editor slice (FurniDataUpdatedEvent/applyLiveFurnitureNameUpdate) — verify, don't assume. - Building the renderer in a fresh git worktree needs its own
yarn install.
- Titles use Conventional Commits:
type(scope): summary, e.g.fix(wired): re-stack a furni_to_furni mover already on its target. - Wrap code names in backticks in titles, descriptions, commit messages and release notes, for example
`@state`or`furni_to_furni`. GitHub turns a bare@nameinto a mention of the GitHub user with that name, and release notes are built from PR titles. Before you publish a release, check its notes: every@outside backticks must be a PR author. - Keep descriptions short: what was wrong and what changed.
- Cite Habbo evidence as "Observed on AIR
<build>" or with the AIR path and line. Don't name rooms, runs or test sessions. - No test counts, suite results, lint or code-style status, checklists or long tables.
- No "Generated with" footers and no AI co-author trailers.
- Never mention other emulators or clients (for example Turbo or Habz) in titles, descriptions, commit messages or code comments. Only official Habbo behaviour is evidence.