If necessary, fall back to an approximation of WorkerGlobalScope.importScripts

...for --disable-emscripten-proxy-to-pthread, where runUnoScriptUrl is run on
the browser main thread

Change-Id: I49c44219b7f77bbc8552994fe3e8483ae0e138fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181663
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann
2025-02-14 14:46:54 +01:00
parent 3b4793b366
commit bc60c54878
+12
View File
@@ -77,9 +77,21 @@ extern "C" void getUnoScriptUrls(std::vector<OUString> * urls) {
}
}
#if HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD
EM_JS(void, runUnoScriptUrl, (char16_t const * url), {
importScripts(UTF16ToString(url));
});
#else
EM_JS(void, runUnoScriptUrl, (char16_t const * url), {
fetch(UTF16ToString(url)).then(res => {
if (!res.ok) {
throw Error(
"Loading <" + res.url + "> failed with " + res.status + " " + res.statusText);
}
return res.blob();
}).then(blob => blob.text()).then(text => eval(text));
});
#endif
EM_JS(void, setupMainChannel, (), {
const orig = self.onmessage;