scmJS docs

In the source

For developers. Everything above is implemented under src/formats/chk/ and src/formats/mpq/, with the file-level policy in src/editor/:

File Does
src/formats/mpq/scm.ts Opens and writes the archive over mopaq: finds staredit\scenario.chk, accepts a bare .chk, reports how the member was stored, keeps the other members.
src/formats/chk/reader.ts Parses the chunk stream into a ChkFile: every occurrence in order, truncation and negative lengths recorded, trailing bytes kept. layer() reproduces the game's overwrite semantics.
src/formats/chk/sections/registry.ts One entry per known section: combine mode, fixed size (some depend on the map's dimensions), record stride, and the editorOnly flag the Save dialog's strip groups are built from.
src/formats/chk/scenario.ts The Scenario model, parseScenario and serializeScenario, the dirty set that decides what is re-encoded, the revision table, revisionSections for the settings pairs, and the insertion order for a section the file did not have.
src/formats/chk/sections/*.ts The codecs: terrain, objects (units, sprites, doodads, locations), players, strings, settings, triggers, cuwp, sounds, and the vcod table.
src/formats/chk/create.ts File ▸ New, and requiredSections(version), which Check Map tests a file against.
src/editor/save.ts The save plan: strip groups, merging repeats with the registry's mode, the sector size per compression, and the warnings the dialog shows.
src/editor/mapBuild.ts, src/services/mapBuild.ts Built maps: packing the step's output with the source beside it, restoring the source on open, and running the steps without letting one cost a save.
src/editor/sections.ts Section-level reads and writes for the Section Explorer plugin and api.document.sections.
src/editor/validate.ts Check Map.
src/data/triggerDefs.ts, src/formats/triggers/text.ts Which field of a trigger record holds which argument, and the text format.

The rules that matter when changing any of it: