@u1f992/pdfdiff 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "0.2.1";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/dist/worker.d.ts CHANGED
@@ -14,6 +14,9 @@ export type PageMessage = {
14
14
  type: "page";
15
15
  index: number;
16
16
  };
17
+ export type LoadedMessage = {
18
+ type: "loaded";
19
+ };
17
20
  export type ReadyMessage = {
18
21
  type: "ready";
19
22
  };
@@ -39,4 +42,8 @@ export type PageResultMessage = {
39
42
  deletion: [number, number][];
40
43
  modification: [number, number][];
41
44
  };
45
+ export type ErrorMessage = {
46
+ type: "error";
47
+ message: string;
48
+ };
42
49
  //# sourceMappingURL=worker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,UAAU,GAAG,IAAI,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,M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EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC;IACxD,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC;IACxD,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC;IAC3D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC7B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/dist/worker.js CHANGED
@@ -3485,31 +3485,42 @@ async function processPage(index) {
3485
3485
  };
3486
3486
  }
3487
3487
  self.addEventListener("message", async (e) => {
3488
- const msg = e.data;
3489
- if (msg.type === "init") {
3490
- pdfA = PDFDocument.openDocument(msg.aBytes, "application/pdf");
3491
- pdfB = PDFDocument.openDocument(msg.bBytes, "application/pdf");
3492
- pdfMask = msg.maskBytes
3493
- ? PDFDocument.openDocument(msg.maskBytes, "application/pdf")
3494
- : new PDFDocument();
3495
- opts = {
3496
- dpi: msg.dpi,
3497
- alpha: msg.alpha,
3498
- pallet: msg.pallet,
3499
- align: msg.align,
3500
- };
3501
- if (pdfA.countPages() > 0)
3502
- pdfA.loadPage(0).destroy();
3503
- const ready = { type: "ready" };
3504
- self.postMessage(ready);
3488
+ try {
3489
+ const msg = e.data;
3490
+ if (msg.type === "init") {
3491
+ pdfA = PDFDocument.openDocument(msg.aBytes, "application/pdf");
3492
+ pdfB = PDFDocument.openDocument(msg.bBytes, "application/pdf");
3493
+ pdfMask = msg.maskBytes
3494
+ ? PDFDocument.openDocument(msg.maskBytes, "application/pdf")
3495
+ : new PDFDocument();
3496
+ opts = {
3497
+ dpi: msg.dpi,
3498
+ alpha: msg.alpha,
3499
+ pallet: msg.pallet,
3500
+ align: msg.align,
3501
+ };
3502
+ if (pdfA.countPages() > 0)
3503
+ pdfA.loadPage(0).destroy();
3504
+ const ready = { type: "ready" };
3505
+ self.postMessage(ready);
3506
+ }
3507
+ else if (msg.type === "page") {
3508
+ const result = await processPage(msg.index);
3509
+ self.postMessage(result, [
3510
+ result.a.data,
3511
+ result.b.data,
3512
+ result.diff.data,
3513
+ ]);
3514
+ }
3505
3515
  }
3506
- else if (msg.type === "page") {
3507
- const result = await processPage(msg.index);
3508
- self.postMessage(result, [
3509
- result.a.data,
3510
- result.b.data,
3511
- result.diff.data,
3512
- ]);
3516
+ catch (err) {
3517
+ const errorMsg = {
3518
+ type: "error",
3519
+ message: err instanceof Error ? `${err.message}\n${err.stack}` : String(err),
3520
+ };
3521
+ self.postMessage(errorMsg);
3513
3522
  }
3514
3523
  });
3524
+ const loaded = { type: "loaded" };
3525
+ self.postMessage(loaded);
3515
3526
  //# sourceMappingURL=worker.js.map