neocotic / convert-svg

Node.js packages for converting SVG into other formats using headless Chromium
MIT License
198 stars 45 forks source link

Instance of puppeteer #40

Open gbtec-lukasgraessle opened 6 years ago

gbtec-lukasgraessle commented 6 years ago

Is it possible to create a way to pass not only puppeteer parameters but also an instance of puppeteer? Or maybe even just a page that is closed afterwards?

In projects where a Puppeteer instance is used, this would save resources and time in generating images.

Thank you for your help.

Nysosis commented 6 years ago

I was going to raise an issue for something very related, but thought I'd mention it in this issue instead.

Puppeteer also supports connecting to a remote instance via the .connect method, and I was hoping to be able to use this method of connecting to a browser instead of launching a new one up.

However if convert-svg supported providing your own puppeteer instance, then I can .connect() myself, and provide that instance through.

neocotic commented 5 years ago

Sorry for the super late response but this is not currently possible but could be. However, I would ask why not simply call createConverter to get an instance of Converter that reuses the same instance of puppeteer until Converter#destroy is called. I feel like this should offer sufficient control over resource management but I'm happy to accept pull requests that expand on this.

I would also like to point out that these packages are designed to be a quick-and-dirty and the whole reason we're using puppeteer under the hood is to get first class SVG rendering without any crazy native building or porting. I'd rather not get too involved with puppeteer itself unless there's genuine use cases that the currently API does not support.