- server: SET_PEER_ROLE now uses the same per-room 500ms debounce as SET_CONTROL_MODE (M-4), preventing a buggy/malicious host from thrashing the room's UI with rapid promote/demote bursts. - server: PEER_STATUS relay treats explicit null as 'clear' for tabTitle/mediaTitle/currentTime, so the tab-close heartbeat actually zeroes out stale state on other peers instead of being silently preserved by the clamp fallback. - background: _persistLastSeq is now trailing-debounced (500ms), cutting storage.session IPC writes from one-per-relayed-event to one-per-quiet-window in active rooms. - locales: add missing TOAST_ID_REGENERATED to all 14 non-English locales (was blocking locale coverage test on main). - test: H-1 force-sync demote test now waits out the debounce window to reflect real-world UI timing (a host cannot promote, run a force-sync, and demote inside 500ms).
Development Scripts
This directory contains utility scripts for the KoalaSync development workflow.
build-extension.cjs
The primary build tool for KoalaSync. This Node.js script automates two critical tasks:
- Protocol Synchronization: Copies the "Single Source of Truth" constants (
shared/constants.js) and the domain blacklist (shared/blacklist.js) from the root/shareddirectory into theextension/shared/directory. - Content Script Injection: Injects protocol constants directly into
content.jsusing marker-based replacement. This is necessary becausecontent.jsexecutes synchronously and cannot use ES module imports. - Artifact Generation: Compiles the extension into browser-specific bundles for Chrome and Firefox, located in the
dist/directory.
Usage
From the repository root, run:
node scripts/build-extension.cjs
Why this script exists
KoalaSync uses Vanilla JS in the extension to maintain zero runtime dependencies and maximum privacy. Since we don't use a bundler (like Webpack or Vite) inside the extension, this script serves as our lightweight "pre-build" step to ensure that the protocol constants remain synchronized between the extension and the relay server.
Content Injection Markers
The build script uses marker comments in content.js to locate and replace constant blocks:
| Marker Pair | Injected Value | Source |
|---|---|---|
SHARED_EVENTS_INJECT_START / END |
The full EVENTS object |
shared/constants.js |
SHARED_HEARTBEAT_INJECT_START / END |
HEARTBEAT_INTERVAL value |
shared/constants.js |
⚠️ Do NOT remove or modify these marker comments in
content.js. They are required for the build script to function. If the markers are missing, the build will fail with a clear error message.