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

Make library browser friendly #41

Open
diegomura opened this issue Sep 17, 2018 · 0 comments
Open

Make library browser friendly #41

diegomura opened this issue Sep 17, 2018 · 0 comments

Comments

@diegomura
Copy link

Hi @devongovett !

On my current effort of getting rid of your libraries's forks on react-pdf (textkit, unicode-properties, pdfkit, fontkit and this lib), I think it would be beneficial for everybody to make this library a bit more browser friendly.

These are some of the issues I currently have with png.js:

  • Node version depends on fs, which is the one that pdfkit uses. So I cant use pdfkit without adding shims
  • Web version does not export the PNG object. Only adds it globally to window
  • Blocker for using directly pdfkit if your lib runs seamlessly on node and web

Changes proposal:

  • Write some tests to ensure everything works as before
  • Rewrite to ES6 (optional)
  • Make library browser friendly: ignoring fs on web build and (maybe) adding the XMLHttpRequest instead. Maybe adding the animation decoding also to this core (fcTL, fdAT sections)? There's no issues with zlib and Buffer since bundlers will shim them automatically (at least as far as I saw)
  • Keep /png.js with all the canvas manipulation for the people who is already using it

I already have a react-pdf fork with some of these points, and it's working great. These types of changes will make one day possible for me to rely directly on the main packages, and actively contribute to those. It's getting very complicated for me to do so when I have to also work on the forks

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

1 participant