Open vyconm opened 2 months ago
No, this is not expected. This package is just a WASM binary with some JS glue code, but the JS doesn't do anything too fancy. Definitely nothing with AudioContext
s.
If I had to guess, either Vite or SvelteKit or a combination of both is pulling in some polyfills for WebAudio stuff that is not supported inside web workers. You would have to look at the transpiled code to see what's actually getting run though.
Awesome little package - I am currently experimenting with converting audio files to smaller versions for use in our AI platform, and this fits just the case!
As that can obviously heavily block the main thread, I am trying to create a client side worker for this, but seem to be running into Browser API issues:
Uncaught (in promise) TypeError: (self.AudioContext || self.webkitAudioContext) is not a constructor at self.onmessage (encodeMp3Worker.js:6:24) self.onmessage @ encodeMp3Worker.js:6
We are using SvelteKit 2 with Svelte 5, which is all based around Vite. My code looks like this:
I was under the impression, that the imported package should basically only be WASM, yet it is searching for Browser API types - is this expected behaviour?
Thank you for the help!