asset忘了上传了,重新传一下,增加了模板引擎(见README),修复了printable的目录bug
This commit is contained in:
1 parent
0817d33309
commit
8b88de4942
7268 files changed
+1257020
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { type GPConfig, processPdfConfig } from "./pdf_pipeline.ts";
|
||||
import type { TemplateVariables } from "./template_engine.ts";
|
||||
|
||||
type WorkerRequest = {
|
||||
id: number;
|
||||
config: GPConfig;
|
||||
options: {
|
||||
addIndex?: boolean | number;
|
||||
useQpdf?: boolean;
|
||||
signPdf?: boolean;
|
||||
signPassphrase?: string;
|
||||
keepIndexPdf?: boolean;
|
||||
variables?: TemplateVariables;
|
||||
};
|
||||
};
|
||||
|
||||
type WorkerResponse =
|
||||
| { id: number; ok: true }
|
||||
| { id: number; ok: false; error: string };
|
||||
|
||||
const workerGlobal = self as unknown as {
|
||||
onmessage: ((event: MessageEvent<WorkerRequest>) => void) | null;
|
||||
postMessage: (message: WorkerResponse) => void;
|
||||
};
|
||||
|
||||
workerGlobal.onmessage = async (event: MessageEvent<WorkerRequest>) => {
|
||||
const { id, config, options } = event.data;
|
||||
try {
|
||||
await processPdfConfig(config, options);
|
||||
workerGlobal.postMessage({ id, ok: true } satisfies WorkerResponse);
|
||||
} catch (error) {
|
||||
workerGlobal.postMessage(
|
||||
{
|
||||
id,
|
||||
ok: false,
|
||||
error: error instanceof Error ? error.stack ?? error.message : String(
|
||||
error,
|
||||
),
|
||||
} satisfies WorkerResponse,
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user