@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.
- package/dist/browser.js +37 -13
- package/dist/browser.js.map +1 -1
- package/dist/cli.js +35 -22
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +34 -13
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/worker.d.ts +7 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +35 -24
- package/dist/worker.js.map +1 -1
- package/package.json +3 -2
- package/scripts/version.ts +35 -0
- package/src/browser.ts +4 -0
- package/src/cli.ts +2 -10
- package/src/index.html +1 -1
- package/src/index.ts +40 -25
- package/src/worker.ts +43 -22
package/dist/cli.js
CHANGED
|
@@ -39520,6 +39520,8 @@ async function* withIndex(iter, start = 0) {
|
|
|
39520
39520
|
}
|
|
39521
39521
|
}
|
|
39522
39522
|
|
|
39523
|
+
const VERSION = "0.2.1";
|
|
39524
|
+
|
|
39523
39525
|
/*
|
|
39524
39526
|
* Copyright (C) 2025 Koutaro Mukai
|
|
39525
39527
|
*
|
|
@@ -39563,24 +39565,42 @@ function asSharedBytes(bytes) {
|
|
|
39563
39565
|
}
|
|
39564
39566
|
class WorkerHandle {
|
|
39565
39567
|
worker;
|
|
39568
|
+
loaded;
|
|
39566
39569
|
pendingResolve = null;
|
|
39567
39570
|
pendingReject = null;
|
|
39568
39571
|
constructor(url) {
|
|
39569
39572
|
this.worker = new Worker(url, { type: "module" });
|
|
39570
|
-
this.
|
|
39571
|
-
const
|
|
39572
|
-
|
|
39573
|
-
|
|
39574
|
-
|
|
39575
|
-
|
|
39576
|
-
|
|
39577
|
-
|
|
39578
|
-
|
|
39579
|
-
|
|
39580
|
-
|
|
39573
|
+
this.loaded = new Promise((resolveLoaded, rejectLoaded) => {
|
|
39574
|
+
const onMessage = (e) => {
|
|
39575
|
+
const data = e.data;
|
|
39576
|
+
if (data.type === "loaded") {
|
|
39577
|
+
resolveLoaded();
|
|
39578
|
+
return;
|
|
39579
|
+
}
|
|
39580
|
+
const resolve = this.pendingResolve;
|
|
39581
|
+
const reject = this.pendingReject;
|
|
39582
|
+
this.pendingResolve = null;
|
|
39583
|
+
this.pendingReject = null;
|
|
39584
|
+
if (data.type === "error") {
|
|
39585
|
+
reject?.(new Error(`worker: ${data.message}`));
|
|
39586
|
+
}
|
|
39587
|
+
else {
|
|
39588
|
+
resolve?.(data);
|
|
39589
|
+
}
|
|
39590
|
+
};
|
|
39591
|
+
this.worker.addEventListener("message", onMessage);
|
|
39592
|
+
this.worker.addEventListener("error", (e) => {
|
|
39593
|
+
const err = e.error ?? new Error(e.message);
|
|
39594
|
+
rejectLoaded(err);
|
|
39595
|
+
const reject = this.pendingReject;
|
|
39596
|
+
this.pendingResolve = null;
|
|
39597
|
+
this.pendingReject = null;
|
|
39598
|
+
reject?.(err);
|
|
39599
|
+
});
|
|
39581
39600
|
});
|
|
39582
39601
|
}
|
|
39583
|
-
init(msg) {
|
|
39602
|
+
async init(msg) {
|
|
39603
|
+
await this.loaded;
|
|
39584
39604
|
return new Promise((resolve, reject) => {
|
|
39585
39605
|
this.pendingResolve = resolve;
|
|
39586
39606
|
this.pendingReject = reject;
|
|
@@ -39600,7 +39620,8 @@ class WorkerHandle {
|
|
|
39600
39620
|
}
|
|
39601
39621
|
}
|
|
39602
39622
|
function workerUrl() {
|
|
39603
|
-
|
|
39623
|
+
const file = import.meta.url.endsWith(".ts") ? "./worker.ts" : "./worker.js";
|
|
39624
|
+
return new URL(`${file}?v=${encodeURIComponent(VERSION)}`, import.meta.url);
|
|
39604
39625
|
}
|
|
39605
39626
|
function pageResultToResult(msg) {
|
|
39606
39627
|
return {
|
|
@@ -39784,15 +39805,7 @@ NOTES:
|
|
|
39784
39805
|
process.exit(0);
|
|
39785
39806
|
}
|
|
39786
39807
|
if (version) {
|
|
39787
|
-
|
|
39788
|
-
const versionStr = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), {
|
|
39789
|
-
encoding: "utf-8",
|
|
39790
|
-
})).version;
|
|
39791
|
-
console.log(versionStr);
|
|
39792
|
-
}
|
|
39793
|
-
catch {
|
|
39794
|
-
console.log("unknown");
|
|
39795
|
-
}
|
|
39808
|
+
console.log(VERSION);
|
|
39796
39809
|
process.exit(0);
|
|
39797
39810
|
}
|
|
39798
39811
|
if (positionals.length !== 3) {
|