Home
CW: typescript yapping
im still not sure how should i make mp4 boxes typings i want the library user to be able to "build" a custom version that would only include the boxes they need, allowing both for tree-shakeability and extensibility. and i want the typings to reflect that - that this parser function can read e.g. an `ftyp`+fields, an `elst`+fields, or anything else (returning raw bytes) which is by itself fairly trivial, but problems arise when we want to add support for boxes with children (e.g. `moov`) the initial idea was to have something like this ```ts [BoxParser<'ftyp', FtypBox>, BoxParser<'elst', ElstBox>, BoxParser<'moov'>] ``` mapped to smth like this ```ts (Mp4Box<'ftyp'> & FtypBox) | (Mp4Box<'elst'> & ElstBox) | Mp4Box<'moov'> ``` but we also want moov to have children, so we want to do smth like ```ts (Mp4Box<'ftyp'> & FtypBox) | (Mp4Box<'elst'> & ElstBox) | Mp4Box< 'moov', (Mp4Box<'ftyp'> & FtypBox) | (Mp4Box<'elst'> & ElstBox) | Mp4Box<'moov'> > ``` but now if there happens to be a moov inside a moov everything breaks... and im not sure if its even possible making these truly recursive (and how slow would it be, and if its even valid per spec anywhere), yet i dont want to enforce ordering in the "builder" either... thats not even to say that i also want to have `.parent`, though i *can* tolerate it being not fully sound... ~~yes i know im overengineering, its not fun otherwise~~