feat(export): run data dictionary PDF exports in background

This commit is contained in:
ccq authored and GitHub committed 2026-09-26 00:04:52 +08:00
1 parent 4baec21fb7
commit 705ea7464d
18 files changed
+702 -104

No files matched your search

@@ -0,0 +1,18 @@
import type { DataDictionaryLabels, DictionaryLayout, DictionaryTable } from "./dataDictionary";
export function renderDataDictionaryPdf(tables: DictionaryTable[], labels: DataDictionaryLabels, layout: DictionaryLayout, warnings: string[]): Promise<Uint8Array> {
return new Promise((resolve, reject) => {
const worker = new Worker(new URL("./dataDictionaryPdf.worker.ts", import.meta.url), { type: "module" });
worker.onmessage = (event: MessageEvent<{ bytes?: Uint8Array; error?: string }>) => {
worker.terminate();
if (event.data.error) reject(new Error(event.data.error));
else if (event.data.bytes) resolve(event.data.bytes);
else reject(new Error("PDF worker returned no data"));
};
worker.onerror = (event) => {
worker.terminate();
reject(new Error(event.message));
};
worker.postMessage({ tables, labels, layout, warnings });
});
}