Skip to content

ADOFAI-JS

ADOFAI-JS is a zero-dependency JavaScript / TypeScript level library for parsing, editing, and exporting ADOFAI level files, fully browser-compatible.

Features

  • Multiple parsersStringParser, BufferParser, ArrayBufferParser, LargeFileParser (incremental parsing for large files)
  • Level management — Load, edit, and export .adofai files with full tile and event access
  • Typed events — TypeScript definitions for 56 ADOFAI event types
  • Shared types — Constant enums and utility types (angles, judgment, filters, etc.)
  • PathData conversion — Convert between pathData strings and angleData arrays
  • Effect filtering — Preset and custom event filtering (remove effects, include/exclude events)
  • Precompute mode — Batch process and cache progress events for rendering pipeline polling
  • Lightweight data — Memory-optimized data extraction for large levels

Before getting started, we recommend reading Understanding Level Files to learn about the structure of .adofai files and Path Data encoding.

Installation

bash
npm install adofai
# or
yarn add adofai
# or
pnpm add adofai

Import

ESM:

ts
import * as adofai from 'adofai'
import { Level, Parsers, Types, Events, Structure } from 'adofai'

CommonJS:

ts
const adofai = require('adofai')

Subpath imports:

ts
import { StringParser } from 'adofai/parser/string'
import { BufferParser } from 'adofai/parser/buffer'
import { ArrayBufferParser } from 'adofai/parser/array-buffer'
import * as Types from 'adofai/types'
import * as Events from 'adofai/event'

Package Exports Overview

Import PathContents
adofaiMain entry: Level, Parsers, Types, Events, Structure, Presets, pathData
adofai/parserParser classes
adofai/parser/stringStringParser
adofai/parser/bufferBufferParser
adofai/parser/array-bufferArrayBufferParser
adofai/typesTypes (constant enums, utility types and functions)
adofai/eventAll event type interfaces
adofai/structureCore interfaces (LevelOptions, Tile, etc.)
adofai/filterFilter presets
adofai/filter/effect-processorLow-level effect processor
adofai/pathdataPathData conversion tables

Quick Start

ts
import { Level } from 'adofai'
import fs from 'node:fs'

const raw = fs.readFileSync('level.adofai', 'utf-8')
const level = new Level(raw)
await level.load()

// Number of tiles
console.log(level.tiles.length)

// Read settings
console.log(level.settings.bpm, level.settings.artist)

// Remove all effects
level.clearEffect('preset_noeffect')

// Export back to ADOFAI JSON
fs.writeFileSync('output.adofai', level.export('string', 0, true))

Sections

Interoperability

An organization that researches and expands the functions of ADOFAI