lib: Split out serialport code to separate file

Initial preparation for more flexible host<->device transport
handling.
Add JS API for runtime<->host communication

Allows to test/simulate much more of the runtime
without having device available.