desktop/source/app/appinit.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit bc60c54878185bcd7d95cc87e9b94a785a086915
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Fri Feb 14 13:39:10 2025 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Fri Feb 14 14:46:54 2025 +0100

    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.bergm...@allotropia.de>

diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx
index a9d70d3da45a..10867b75a5c0 100644
--- a/desktop/source/app/appinit.cxx
+++ b/desktop/source/app/appinit.cxx
@@ -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;

Reply via email to