Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js support? #38

Closed
s-a opened this issue May 30, 2015 · 8 comments
Closed

Node.js support? #38

s-a opened this issue May 30, 2015 · 8 comments

Comments

@s-a
Copy link

s-a commented May 30, 2015

Are there plans to support node.js? Best regards

@serratus
Copy link
Owner

Sorry, there are not plans yet. From my understanding, a node.js implementation would be focused around decoding still-images instead of live-video, right? I haven't focused too much on still-image barcode reading, but making it compatible with node.js might be a good incentive.

Do you know how to get around the fact that node.js does not support any DOM APIs like <canvas> and <img> which are needed for quaggaJS to work?

@s-a
Copy link
Author

s-a commented May 30, 2015

Hi,
no it would not be limited to static image files. In best case the lib supports streams from where it is also possible to scan webcam inputs. For my needs it is enough to support static images. There are a few libs out there for node providing canvas support. https://github.com/Automattic/node-canvas not tested yet if it is full OS independent. I think the tdd with your testsiute will be more productive if you are willing to support node .
I inspected your code a little bit and think it is well modular coded from where it should be easy to Add node support.
As far as I can see the only missing feature for node is canvas element but have not read all code. I d like to use your library but need server side processing to avoid hacks.

Please let me know if you need any support regarding node.

@s-a
Copy link
Author

s-a commented May 30, 2015

just tested node-canvas... It attracts a rat tail of dependencies which are complicated to install and everything else than stable. at the repo are 220 tickets open o.O So canvas is not trivial in node sorry :/.

Any chance to abstact the logic behind? I found https://www.npmjs.com/package/get-pixels to read pixel informations from static image, but not tested yet

@serratus
Copy link
Owner

Thanks for the research so far. Abstracting the image reading depending on the system might be best way to go. get-pixels seems like a good start, although I have just scrolled through the dependencies and docs. This could definitely work for server-side environments.

Would you create a separate build for server and client, or simply combine them in one file? I don't have much experience in creating a library which can be run on node (using different features) and the client. What I'm afraid of is, that the library gets bloated when I create a distributed version for the client that also includes the node-js part.

@s-a
Copy link
Author

s-a commented May 30, 2015

I suggest to keep it separate and include shared sources from https://github.com/serratus/quaggaJS/tree/master/src with node's requiere. There is no need to bundle and minify for node and the most code should run on both environments? To make the shared code run on client and server should do the trick. I saw some places where you used module.exports which is already native node usage. All you need is a field "main" pointing to your server side index.js.
Personaly I put Server side code in a subfolder called lib and pass this folder to a test coverage process with output to lib-cov.

Here is a very simple setup .
https://github.com/s-a/package.js

@serratus
Copy link
Owner

During my research I discovered the presence of another field in the package.json file which can be used to distinguish between browser and main environment. This could be helpful for creating browserify/webpack client applications and node.js server-side implementations. I still have to figure out how to get the requirejs styled code into node's module.exports format.

@s-a
Copy link
Author

s-a commented May 31, 2015

Did not know this field. Interesting info.
I used require.js years ago but simplyfied my build processes and renounced amd a long time.
I have noticed that http://browserify.org became very much fame . it provides require Syntax which is identical to node.js.

Do you use require.js to support amd or is it just a part of your build process? In this case you could simply concat all files and publish your library to public scope. For example like jquery which runs also in both environments .

@serratus
Copy link
Owner

serratus commented Jun 2, 2015

Basically, I use require.js during development simply for dependency management and modularization. This also helps packaging the library in a single file. Anyways, yesterday I was tinkering on the node.js support and created a new branch (a042422) for that. Decoding static images should basically work, but there is still a lot to do. This is just an experiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants