@@ -98,8 +98,8 @@ exports.WorkerPlugin = function WorkerPlugin(options = {}) {
9898 }
9999 }
100100
101- function run_single_threaded(code, e ) {
102- console.error("Running perspective in single-threaded mode due to error initializing Web Worker:", e );
101+ function run_single_threaded(code) {
102+ console.error("Running perspective in single-threaded mode" );
103103 let f = Function("const self = arguments[0];" + code);
104104 const workers = [];
105105 const mains = [];
@@ -109,17 +109,16 @@ exports.WorkerPlugin = function WorkerPlugin(options = {}) {
109109
110110 export const initialize = async function () {
111111 try {
112- const blob = new Blob([worker], {type: 'application/javascript'});
113- const url = URL.createObjectURL(blob);
114- return new Worker(url, {type: "module"});
115- } catch (e) {
116112 if (window.location.protocol.startsWith("file")) {
117113 console.warn("file:// protocol does not support Web Workers");
114+ return run_single_threaded(worker);
118115 } else {
119- console.error("Error instantiating Web Worker");
116+ const blob = new Blob([worker], {type: 'application/javascript'});
117+ const url = URL.createObjectURL(blob);
118+ return new Worker(url, {type: "module"});
120119 }
121-
122- return run_single_threaded(worker , e);
120+ } catch (e) {
121+ console.error("Error instantiating engine" , e);
123122 }
124123 };
125124
0 commit comments