colinbdclark / osc.js

An Open Sound Control (OSC) library for JavaScript that works in both the browser and Node.js
GNU General Public License v2.0
770 stars 117 forks source link

Web Serial API support #204

Open patrykwegrzyn opened 1 year ago

patrykwegrzyn commented 1 year ago

Does this package support Web Serial API when used in a browser rather than Chrome app?

colinbdclark commented 1 year ago

Not yet, but it would be a good feature to add. It's something I've looked into a bit, and I think it should be doable, but I don't anticipate having capacity to do the work myself for the next little while. PRs of course are hugely welcome.

patrykwegrzyn commented 1 year ago

I'm already looking into it

patrykwegrzyn commented 1 year ago

Hi @colinbdclark good news i spent evening on this and i have basic webserial implementation working, tested it so far with osc messages.

Its working ok only if i use build file from dist via script tag

<script src="/osc-browser.js"></script>

image

BUT fails if im trying to use via import keyword

import "../../osc-browser.js

image

looks like some thing to do with slip package

image

Im not familiar with gunt , i think build export it in a funky way. I tried importing slip package from npm and it worked fine so it is not package issue.

import slip from "slip"

it may be related to this issue https://github.com/colinbdclark/slip.js/issues/3

Have you ever come across this before ?

It also does this when trying to import chromeapp bundle ( not touched by my code ) so you can test it on your end.

Let me know your thoughts . Best wishes

Pat

patrykwegrzyn commented 1 year ago

I have done some digging in the issues and it’s look like it’s been mentioned several times.

Would you consider to moving to something like rollup ? And have multiple module types in the dist?

Example osc-web-esm.js osc-web-umd.js ….

I’m more than happy to open new issue and assist you with it if you are up for it .

In my mind it would open broader usage of this awesome package , a lot of people including me use react and other frameworks and esm module is standard these days , it would be a lot easier to use package with divergent frameworks rather than some funky monkey patching of webpack configs.

Currently I’m re building my euclidean sequencer from nodejs for my poor man’s monome arc clone ( Arduino , LED ring and LED encoder talking osc ), with react for the nice ui, it has so many gestures that deserve ui now , webserial will make it a lot easier as there is no need for the web socket anymore and make it more accessible all you need is a browser

Anyway Let me know your thoughts. Pat

colinbdclark commented 1 year ago

Hi @patrykwegrzyn, thanks so much for looking into all of this, I really appreciate it. Moving to Rollup is fine with me, assuming we are able to continue to support the use case that is, in many ways, the polar opposite of the modern React/ES6 modules/WebPack "standard" toolchain paradigm: use with plain old script tags and no modules or imports or other things that often serve as a barrier to entry for artists who aren't professional corporate web developers. If we can add better support for ES6 modules and WebPack without cutting out that use case, I'd be delighted.

This is the busiest time of year for me, so I'll be a bit slow to respond, but I'm happy to help with whatever you need to make this happen.

patrykwegrzyn commented 1 year ago

Great sounds like a plan i will continue of webserial PR and once we there i'll look into new build system