Closed djipco closed 2 years ago
The error comes from this bit of code that detects whether the current environment is Node.js or not:
/**
* Indicates whether the execution environment is Node.js (`true`) or not (`false`)
* @type {boolean}
*/
static get isNode() {
return new Function("try { return this === global; } catch(e) { return false; }")();
}
This code does not use eval()
per se but something that is functionally equivalent. It seems that Electron does not like eval()
at all. I tried adding usafe-eval
to script-src
in the Content-Security-Policy
and it did solve the problem (but still threw a warning in the console):
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'"
>
This is the solution I can offer for now.
Obviously, we need a better solution than that. Oddly, it turns out to be difficult to properly detect the environment the code is running in. I guess I will have to find another way...
Discussed in https://github.com/djipco/webmidi/discussions/276