featherbear / presonus-studiolive-api

Exploring the PreSonus network control protocol from a StudioLive Series III
https://featherbear.cc/presonus-studiolive-api/
46 stars 13 forks source link

TypeScript typings problem #18

Open fis-cz opened 2 years ago

fis-cz commented 2 years ago

Latest version of the TypeScript don't compile and types has to added / changed manually (especially ZB parsing is problematic).

The project should use more strict typing whenever possible (default any should be forbidden, indexing should be limited to known values and so on).

Also I checked the code and it would be great to use some strict linting settings (there are missing semicolons almost everywhere - I know its not mandatory, but...).

I would also refactor those ultra long promises and split them to separate async functions, its hard to read them.

There are also other things I would change, such as the parser is not related to ZB/ZLib so I would move it and rename it to JBSON and so on.

Would you mind if I try to refactor and cleanup the code and make the typings strict to be able to work with latest TypeScript?

featherbear commented 2 years ago

I envisioned that the project will eventually be linted against standardx, but the project is still in its early stages and the code structure will keep changing until I/we figure out what works best and is relatively stable; so I haven't yet tightened the typings

https://github.com/featherbear/presonus-studiolive-api/blob/master/package.json#L40-L56


https://github.com/featherbear/presonus-studiolive-api/blob/master/src/lib/types/ZlibPayload.ts

This file is auto generated, and can definitely be cleaned up / properly built


Anyhow, feel free to refactor things where you see fit. I agree with the parsing routine being renamed to disassociate itself with the zlib payload

featherbear commented 2 years ago

Perhaps the zlib-decoded payload (both ZB and CK) should be re-emitted as the JSON packet?

fis-cz commented 2 years ago

Perhaps the zlib-decoded payload (both ZB and CK) should be re-emitted as the JSON packet?

I’ll try to fugure out what will be the best way to “reemit”, but this seems to be the best way so all listeners can catch it.

fis-cz commented 2 years ago

I am back, but my box is in service, once it will be back I am gonna start to help you.

featherbear commented 1 year ago

Regarding typings, we should also seek to identify the "device options", "project options", and "scene options" - and then build type unions that fit the target.

I have plans to build an offline editor (likely just simple settings) that can open the exported project and scene files - https://github.com/featherbear/SL-Edit (stale). It would be cool to then be able to remotely sync the console

featherbear commented 1 year ago

Here are some exported files for reference (C:\Users\Andrew\Documents\PreSonus\StudioLive AI\Library\Presets\Project\20201219 Wedding.proj)

01.20201218 Update.scn.txt

20201219 Wedding.cnfg.txt

and the previously seen https://github.com/featherbear/presonus-studiolive-api/blob/documentation/dumps/zlib.parsed