Mesh is complicated. It’s not just a button-press recorder, but a somewhat generic OSC recorder. Thus it can record arcs or grids or other things. Furthermore, in order to work with any application, it has to funnel that recorded data back into the correct osc port that it’s spliced into. Mesh is also 63 recorders that can record / play simultaneously (overkill for most applications).
If you’re only after a single recorder, I’d start with the mesh~.maxpat file. This is the bit that actually does the recording & it’s already nicely abstracted for you. Send one of the defined messages to control it (record, start, end, clear). Anything you send it other than these magic words will be recorded if you’ve sent it a ‘record’ message and not yet an ‘end’ message.
I think I did some fancy things with ‘arming’ the recorders in the js script, but I’ll leave that to your particular application.
// to note:
This was one of the first pieces of JS i wrote. Not saying that’ll make it easy to understand, but if you’re looking for a beginner level intro into into real-world javascript, it’s a good candidate! Also when I started out I wrote a comment for almost every line of code!