File Lab plugin that parses binary files with Kaitai Struct and visualizes the decoded structure in an interactive tree view. The UI is built with Lit.
Bundled formats (from the Kaitai format gallery):
Executables
.exe, .dll, .sys).elf, .so, .o).dylib, universal binaries).exe, .com).dex).class).te, .efi).swf).pyc)Media
Auto-detection uses magic bytes first (e.g. MZ + PE\0\0 for PE, \x7FELF for ELF), then falls back to file extension.
This directory is intended to be used as a git submodule inside retroReversing:
public/js/file-lab/plugins/kaitai-viewer/ ← this repo
├── formats/ # .ksy source definitions
├── src/ # Lit plugin source
├── src/parsers/ # Kaitai-compiled JS (committed)
├── dist/ # Vite production bundle (committed for GitHub Pages)
└── package.json
From the retroReversing repo root (after creating this repository on GitHub):
git submodule add https://github.com/YOUR_ORG/file-lab-kaitai-viewer.git public/js/file-lab/plugins/kaitai-viewer
git submodule update --init --recursive
plugins.json already references:
{
"id": "kaitai-viewer",
"module": "/public/js/file-lab/plugins/kaitai-viewer/dist/index.js",
"css": "plugin.css"
}
Clone with submodules:
git clone --recurse-submodules https://github.com/retroreversing/retroReversing.git
Requirements: Node.js 20+
npm install
npm run build
Build steps:
compile:formats - compiles .ksy files with kaitai-struct-compiler into src/parsers/export:parsers - wraps UMD parsers as browser ES modules in src/parsers-esm/vite build - bundles Lit UI, parsers, and kaitai-struct runtime into dist/Watch mode:
npm run dev
.ksy file into formats/ (pull dependencies into formats/ as needed, e.g. formats/common/riff.ksy).src/format-registry.js and add a catalog entry with magic bytes / extensions.npm run build and commit src/parsers/ + dist/.The built dist/index.js exports a default object compatible with File Lab’s plugin registry:
matches(ctx) - returns true when magic bytes or extension match a bundled formatactivate(ctx, panel) - mounts the <kaitai-viewer> Lit elementdeactivate(panel) - tears down the panelKaitai Struct compiler output is GPL-3.0-or-later (see kaitai-struct-compiler license). Format definitions in formats/ are CC0-1.0 from the Kaitai format gallery. Plugin source in src/ follows the retroReversing repository license.