Closed julenwang closed 11 months ago
I fixed it use patch-package, It is working well
diff --git a/node_modules/@imagemagick/magick-wasm/dist/index.mjs b/node_modules/@imagemagick/magick-wasm/dist/index.mjs
index 2a43ef4..2ef32fb 100644
--- a/node_modules/@imagemagick/magick-wasm/dist/index.mjs
+++ b/node_modules/@imagemagick/magick-wasm/dist/index.mjs
@@ -95,9 +95,19 @@ class Hi {
*/
message;
}
+
var Fi = (() => {
var t = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
return function(a = {}) {
+
+ // hack in worker
+ if(typeof window === "undefined"){
+ var window = {
+ crypto,
+ prompt: console.log
+ }
+ }
+
var e = a, l, m;
e.ready = new Promise((n, r) => {
l = n, m = r;
I can confirm that this patch fixes the issue. It would be great to get this merged soon!
@Peeterush created a PR to resolve this. But I also wonder if we could add an extra check to test if the code can be executed in a webworker and maybe also inside a web browser?
magick-wasm version
0.0.26
Description
Not working in web worker context
I cannot find this code in repo, I guess it generated by compiler
Sorry, My English is bad
Steps to Reproduce
use @imagemagick/magick-wasm in web worker
Images