2.1 KiB
KoalaSync Protocol Synchronization Guide
Why do we need to sync?
KoalaSync uses a "Single Source of Truth" for its communication protocol constants located in the root shared/ directory. However, Chrome Extensions (Manifest V3) are strictly sandboxed and cannot load or import files from outside their root directory.
To ensure that the extension and the relay server are always using the exact same event names and protocol versions, we maintain a mirrored copy of the shared files within the extension/shared/ folder.
When should you run the sync script?
You MUST run the synchronization script in any of the following scenarios:
- After a fresh
git cloneorgit pull(as the synced files are ignored by git). - After modifying
shared/constants.js. - After modifying
shared/blacklist.js. - Before committing changes to the repository if any protocol-related files were touched.
- Before deploying the server or releasing the extension.
How to sync
On Windows
Run the batch script from the repository root:
.\scripts\sync-constants.bat
On macOS / Linux
Run the shell script from the repository root:
./scripts/sync-constants.sh
What does it do?
The script performs the following actions:
- Ensures the
extension/shared/directory exists. - Copies
shared/constants.jstoextension/shared/constants.js. - Copies
shared/blacklist.jstoextension/shared/blacklist.js.
Protocol Versioning
As of v1.0.0-RC5, the system enforces a strict protocolVersion check during the JOIN_ROOM handshake.
- The version is defined in
shared/constants.js. - If the extension and server versions mismatch, the server will reject the connection with an
Incompatible protocol versionerror. - Always run the sync script after bumping the version number to ensure both components are updated.
Caution
NEVER edit the files inside
extension/shared/directly. They will be overwritten the next time the sync script is run. Always edit the files in the rootshared/directory and then run the sync script.