Warning
This library is currently in development.
This is a small TypeScript library for reading and writing KSH and KSON files, which are used by K-Shoot Mania and USC.
NOTE: This package is intended to replace kshoot.js.
NOTE: Check out kshoot-tools if you are looking for a program or a tool to do something with chart files. This library can be used to create such tools, but is not a tool by itself.
The library can be installed via:
npm install @rhythm-gaming/ksonBoth KSH and KSON charts are internally represented as a KSON object. Consult the KSON specification for how to navigate through a KSON object.
import * as fs from "node:fs/promises";
import {
parseKSH, // KSH source to KSON or KSH
stringifyKSH, // KSON or KSH to KSH source
type KSON,
} from "@rhythm-gaming/kson";
const ksh_text = await fs.readFile("chart.ksh", "utf-8");
const kson: KSON = parseKSH(ksh_text);
kson.meta.title = "Hello, world!";
const new_ksh_text = stringifyKSH(kson);
await fs.writeFile("new_chart.ksh", new_ksh_text, "utf-8");Note that, by default, parseKSH will convert the KSH file to KSON representation.
When the second argument to parseKSH is true, the library will not convert the KSH file to KSON representation, and will return an AST for the original KSH file.
import * as fs from "node:fs/promises";
import {
parseKSON, // KSON source or non-normalized KSON to normalized KSON
stringifyKSON, // KSON to KSON source
createKSON, // Create a new empty KSON object
type KSON,
} from "@rhythm-gaming/kson";
// Open and read a KSON file.
const kson_text = await fs.readFile("chart.kson", "utf-8");
const kson: KSON = parseKSON(kson_text);
kson.meta.title = "Hello, world!";
kson.meta.artist = "John Doe";
const new_kson_text = stringifyKSON(kson);
await fs.writeFile("new_chart.kson", new_kson_text, "utf-8");- Reading KSH
- Reading KSON
- Writing KSH
- Writing KSON
- Header parsing
-
title,artist,effect,illustrator -
title_img,artist_img,jacket -
difficulty,level -
t,beat -
o,m,mvol -
total -
po,plength -
bg,layer,v,vo -
chokkakuvol,chokkakuautovol,pfilterdelay -
filtertype,pfiltergain -
ver,information
-
- Body parsing
- Chart lines
- BT notes (chip, long)
- FX notes (chip, long)
- FX notes (legacy effects)
- Laser notes (linear, slam)
- Laser notes (spin)
- Option lines
-
t,beat -
chokkakuvol -
laserrange_l,laserrange_r -
stop -
tilt -
zoom_*,center_split -
fx-* -
filtertype,pfiltergain
-
- Chart lines
- Footer parsing
-
#define_fx -
#define_filter
-
This project uses pnpm for package management.
pnpm build– compile TypeScript fromsrc/intodist/.pnpm build:watch– recompile on every file change.
pnpm test– run unit tests fromsrc/**/*.spec.ts.- Don't forget to run
pnpm buildbefore running tests!
- Don't forget to run
pnpm lint– run ESLint on the source code.pnpm clean– remove thedist/directory.