cwilso / WebMIDIAPIShim

Polyfill using the Jazz NPAPI MIDI plugin to implement the Web MIDI API on Mac and Windows.
380 stars 53 forks source link

Nodejs #61

Closed abudaan closed 9 years ago

abudaan commented 9 years ago
jazz-soft commented 9 years ago

Daniel, I just wonder if it's possible to browserify the performance-now module into WebMIDIAPI.js to minimize the number of end user dependencies?

abudaan commented 9 years ago

Not sure if I understand you correctly. The performance-now package is only needed in the nodejs version; for the browser version we have the performance polyfill in src/util.js or the native implementation of performance.now() when available

jazz-soft commented 9 years ago

Ok, I'll try to do it myself after your check-in gets merged. If that will not work, I'll leave everything as it is :)

abudaan commented 9 years ago

Okay, but browserify is meant for adding functionality of nodejs packages to a web project. So it is a bit odd to browserify performance-now while performance.now() has been implemented in most modern browsers.

Also I don't see a problem in having dependencies; npm is made for managing dependencies and it encourages the use of smaller interdependent modules for the sake of maintainability and scalability.

The way the WebMIDIAPIShim is currently set up only needs and uses the performance-now package for nodejs projects. Browser projects only need the transpiled .js file in the /lib folder.

If you insist on limiting the number of dependencies, you could remove the performance-now package all together: in that case the polyfill will add a performance.now() function based on setTimer().

You can do this by replacing the lines 6 - 8 in in /lib/index.js

var performance = {
  now: require('performance-now')
};

by just:

var performance;
jazz-soft commented 9 years ago

Thanks a lot for the advice. I'll try it. By the way, the plugin itself has function Time() that returns time in ms

abudaan commented 9 years ago

The examples routing_1 and routing_2 didn't work correctly on Windows and OSX because in Chrome 43 stable the device ids on Windows are index numbers (0, 1, 2, etc.) and therefor not unique per device. On OSX the device ids can be negative numbers which can't be used as html id attribute for the checkboxes. So I have added the prefixes 'input' and 'output'.

jazz-soft commented 9 years ago

Chris, are you on vacation? :)

cwilso commented 9 years ago

Kind of. Swamped post-I/O, and haven't had a chance to review this (sizable!) update.

jazz-soft commented 9 years ago

Hey Chris, just wonder if you are still maintaining this project?

cwilso commented 9 years ago

Sooooo sorry. Been very busy, and I wanted to look this over in detail.