wulkano/Aperture

Refactor the codebase

sindresorhus opened this issue · 4 comments

From ac3dcc4#commitcomment-20097149:

  • Pass JSON to the Swift binary
  • Cleanup

What do we have to do here exactly? 🤔

As I understood the commitcomment right we have two options for releasing a new npm-package:
-> Update the main and recorder swift so we haven't breaking changes
TODOS:
Create a new init for recorder with 6 params
Create a new init for main with 6 params
Update index.js if display.id missing, use main as display.id

-> Otherwise we can publish breaking changes.
Then we can leave everything like it is now but add a little bit more functionality.
TODOS:
Rename main to aperture
Make all parameters optional (and set default value to smth)
update params to using unix style like -option OPTIONforTHAToption -anotherOption...

Or am I wrong?

What do you mean with Pass JSON to Swift binary❓ 🤔

The Swift binary is an implementation detail and not exposed to users, so none of your proposed TODOS are necessary. The idea of passing JSON to the binary is to simplify the communication. Right now it's just using a bunch of arguments. We could switch to use proper CLI flags, but since it's not exposed anyways, it would be simpler to just send all the options from Node.js as JSON and parse the JSON into an options dictionary on the Swift side. That way we don't have to do much on the communication side when adding new options.

@LarsJK Do you know any better way we could use to communicate between Swift and Node.js? We'll eventually want two-way communication, so the current method is not going to be very optimal. Maybe something like https://www.npmjs.com/package/node-ipc ?

Sorry I don't really have any experience with this.
node-ipc and something like https://github.com/swiftsocket/SwiftSocket could probably be an option though..

Dont know if this can be useful: https://realm.io/news/thomas-goyne-fast-inter-process-communication/