Skip to content

techmino-hub/techmino-replay-parser

Repository files navigation

Techmino Replay Parser

A TypeScript parser for Techmino base64-encoded replays.
This parser is based on Techmino's algorithm used to parse the replays, available here.

Credits to SweetSea for helping me verify the results using their own parser written in Python!
They also helped as a reference for the very early versions before the parser was completely remade, with Techmino's code as a reference.

Building

You'll need Node.js (or any Node alternatives) to build this project. (I personally use Bun for its unmatched speed.)

npm install
npm run build

Usage

You can grab the TypeScript version in /src/, or the JavaScript version in /dist/.

Sample code is available in the demo-file.html and demo-b64.html files.

// Getting replay data from `.rep` file
import { parseReplayFromBuffer, type GameReplayData } from 'techmino-replay-parser';

// Binary encoded replay file.
// It's the one in `(Techmino save dir)/replay/`.
const compressedRepFile: File = '...';

// We first convert it to an array buffer.
const arrayBuffer: ArrayBuffer = compressedRepFile.arrayBuffer();

// Then we convert it to a Uint8Array.
const buffer = new Uint8Array(arrayBuffer);

// Then we get the replay data.
const replayData: GameReplayData = await parseReplayFromBuffer(buffer);

console.log(replayData);
// Getting replay data from pasted base64 string
// (You can get this by pressing the export button in Techmino's replay list)
import { parseReplayFromRepString, type GameReplayData } from 'techmino-replay-parser';

// Base64 encoded replay data.
const base64Replay: string = '...';

const replayData: GameReplayData = await parseReplayFromRepString(base64);

console.log(replayData);

About

A TypeScript parser for Techmino's replays

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published