@thisisayande/openscrim-core
The engine behind OpenScrim — an open-source, Scrimba-style format for interactive code screencasts. Instead of recording pixels, OpenScrim records editor events (keystrokes, cursor moves, content changes, scrolls) as timestamped data, so a "video" of a coding session is ~100× smaller than pixel video, fully seekable, and forkable: viewers can pause at any moment and edit the instructor's exact code.
This package is framework-agnostic (no React, no Monaco dependency). For wiring it to a Monaco editor, see @thisisayande/openscrim-monaco.
Install
npm install @thisisayande/openscrim-core
What's inside
RecordingManager— captures editor events into aRecordingSessionbufferPlaybackEngine— schedules and replays events with play/pause/seek/speed; emits events to your renderer via handler callbackscompressEvents/decompressEvents— event-stream compression (cursor dedup, keystroke batching)sessionToTantricaFile/writeTantricaBuffer/readTantricaBuffer— the.tantricafile format: gzipped JSON with magic bytes and a fast-readable metadata headertypes— the fullRecordingEventunion andRecordingSessionmodel
Quick example
import { PlaybackEngine } from '@thisisayande/openscrim-core';
const engine = new PlaybackEngine();
engine.addEventHandler(({ type, data }) => {
if (type === 'eventProcessed') renderIntoYourEditor(data);
});
engine.loadSession(session);
engine.play();
engine.seek(30_000); // jump to 0:30
engine.setSpeed(1.5);
Environment notes
- Recording, playback, and event compression work in browsers and Node.
- Reading
.tantricafiles works everywhere:parseTantricaBytes(bytes)is async and uses Web APIs only (DecompressionStream), so it runs in browsers and Node 18+. - The synchronous binary helpers (
writeTantricaBuffer/readTantricaBuffer) require Node (they usezlibandBuffer); use them server-side. Plain-JSON serialization works everywhere.
Status
0.x — APIs and the file format may still change between minor versions. Feedback and issues welcome at github.com/ayan-de/openscrim.
License
MIT Ayan De