fix: stabilize web loading and paper rendering

This commit is contained in:
Hakan Seven committed 2026-07-25 21:34:29 +03:00
1 parent fe49cc8eb5
commit bca65600cd
25 files changed
+109 -62

No files matched your search

+11 -2
View File
@@ -3,9 +3,16 @@ import init, { parse_document } from "./worker_pkg/ocs_web_worker.js";
const ready = init();
self.onmessage = async ({ data }) => {
let stage = "initialize worker";
try {
await ready;
const encoded = parse_document(data.name, new Uint8Array(data.bytes));
const encoded = parse_document(
data.name,
new Uint8Array(data.bytes),
(next) => {
stage = next;
},
);
// wasm-bindgen returns a view into WebAssembly.Memory. Copy to a standalone
// ArrayBuffer before transferring it, otherwise the worker's wasm memory
// itself would be detached.
@@ -14,7 +21,9 @@ self.onmessage = async ({ data }) => {
} catch (error) {
self.postMessage({
ok: false,
error: error instanceof Error ? error.message : String(error),
error: `${stage}: ${
error instanceof Error ? error.stack || error.message : String(error)
}`,
});
}
};