Multi-thread support for applyTemplate

This commit is contained in:
oom 2026-11-03 14:48:37 +07:00
parent f7e84e3ee7
commit bfb07c633d
10 changed files with 1260 additions and 154 deletions

29
workers/docx.worker.ts Normal file
View file

@ -0,0 +1,29 @@
import {
applyTemplate,
type DocumentTemplate
} from '../lib/lib-tmpl';
interface DocxWorkerInput {
templateBuffer: Uint8Array;
templateData: DocumentTemplate;
secret: string;
privateKeyHex: string;
ticketSec: number;
}
export default async function generateDocx(
input: DocxWorkerInput
): Promise<Buffer> {
const templateBuffer = Buffer.from(input.templateBuffer);
const output = await applyTemplate(
templateBuffer,
input.templateData,
input.secret,
input.privateKeyHex,
input.ticketSec
);
return Buffer.from(output);
}