-
Notifications
You must be signed in to change notification settings - Fork 6
Electron compatible #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Author
|
在electron中既有node环境, 也有browser环境 const {createRequire:a}=await import("module")直接调用import函数会有问题 |
Owner
|
这个文件是 emscripten 的编译产物 |
Owner
|
emscripten 编译产物同时兼容 node 和 browser 环境 |
Author
|
OK,我先自行实现绕开 |
Owner
|
如果在 electron 中出现问题,这有可能是 emscripten 的 bug |
Author
|
不知道算不算bug, 语法问题,不兼容 |
Owner
希望能提供报错信息 |
Author
Owner
|
不是这个 |
Owner
|
我是说导入 silk-wasm 时的报错信息 |
Author
|
就只是 |
Author
|
变量 |
Owner
var f = moduleArg,
aa, r, ba = new Promise((a, b) => {
aa = a;
r = b
}),
ca = "object" == typeof window,
t = "function" == typeof importScripts,
u = "object" == typeof process && "object" == typeof process.versions && "string" == typeof process.versions.node;
if (u) {
const {
createRequire: a
} = await import("module");
var require = a(import.meta.url)
}
var da = Object.assign({}, f),
x = "",
ea, A;
if (u) {
var fs = require("fs"),
fa = require("path");
x = require("url").fileURLToPath(new URL("./", import.meta.url));
A = a => {
a = B(a) ? new URL(a) : fa.normalize(a);
return fs.readFileSync(a)
};
ea = a => {
a = B(a) ? new URL(a) : fa.normalize(a);
return new Promise((b, c) => {
fs.readFile(a, void 0, (d, e) => {
d ? c(d) : b(e.buffer)
})
})
};
process.argv.slice(2)
} else if (ca || t) t ? x = self.location.href : "undefined" != typeof document && document.currentScript && (x = document.currentScript.src), _scriptName && (x = _scriptName), x.startsWith("blob:") ?
x = "" : x = x.substr(0, x.replace(/[?#].*/, "").lastIndexOf("/") + 1), t && (A = a => {
var b = new XMLHttpRequest;
b.open("GET", a, !1);
b.responseType = "arraybuffer";
b.send(null);
return new Uint8Array(b.response)
}), ea = a => B(a) ? new Promise((b, c) => {
var d = new XMLHttpRequest;
d.open("GET", a, !0);
d.responseType = "arraybuffer";
d.onload = () => {
(200 == d.status || 0 == d.status && d.response) && c(d.response);
b(d.status)
};
d.onerror = b;
d.send(null)
}) : fetch(a, {
credentials: "same-origin"
}).then(b => b.ok ? b.arrayBuffer() : Promise.reject(Error(b.status +
" : " + b.url)));
f.print || console.log.bind(console); |
Owner
|
electron 的浏览器不会是存在 process.versions.node 吧?正常情况下 |
Author
Owner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


兼容在electron中调用