Closed subframe7536 closed 1 year ago
Hello! This library is meant to be consumed by node.js, so, no it isn't possible to use it in the browser. In particular, the node fs module would not be available for accessing a file.
I suppose the file abstraction concept could be expanded to operate on files that are purely in memory, similarly to how the test file object is used for unit tests. However, this doesn't exist today and the file abstraction is really only used to wrap around a file in the filesystem.
get it. thanks for your reply!
After a few attempts, I finally create a wrapper to read and write in the browser. but the main drawback currently is that the polyfill for node:crypto
is a little big:
with crypto polyfill: 972.38 kB │ gzip: 391.16 kB without crypto polyfill: 683.34 kB │ gzip: 297.25 kB
I find it is only used in matroskaAttachment.ts
and generate random array by crypto.randomFillSyn
. Is it equal to window.crypto.getRandomValue
?
It looks like it's pretty much the same as window.crypto.getRandomValues
. Though looking at the docs for that, it appears to only be supported in Node v15 and up. At the moment node-taglib-sharp maintains compatibility with Node v12 and up. Upgrading would be possible but would require a major version bump. I'm also not entirely sure if that's the only place crypto
is used. The uuid
package used in various places around the library is hopefully relying on cryptographically secure values.
I'm also curious:
Thanks for your explain. The polyfill process is running at build time, so there is no need to modify the original code.
I am building a web app that manage audio files tags directly inside the browser using file system api. I used to choose music-metadata-browser, but its data is read-only and still have a long road to support write feature, so I write a wrapper for this. I will open source the package later.
300KB (100KB in gzip) data may not impact on most browsers. I personally consider it as an learning research and optimization. Build once and run everywhere without installation is wonderful
is it possible to use in browser?
using
File.createFromAbstraction()
?