@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/browser.js
CHANGED
|
@@ -3339,6 +3339,8 @@ async function* withIndex(iter, start = 0) {
|
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
3341
|
|
|
3342
|
+
const VERSION = "0.2.1";
|
|
3343
|
+
|
|
3342
3344
|
/*
|
|
3343
3345
|
* Copyright (C) 2025 Koutaro Mukai
|
|
3344
3346
|
*
|
|
@@ -3382,24 +3384,42 @@ function asSharedBytes(bytes) {
|
|
|
3382
3384
|
}
|
|
3383
3385
|
class WorkerHandle {
|
|
3384
3386
|
worker;
|
|
3387
|
+
loaded;
|
|
3385
3388
|
pendingResolve = null;
|
|
3386
3389
|
pendingReject = null;
|
|
3387
3390
|
constructor(url) {
|
|
3388
3391
|
this.worker = new Worker$1(url, { type: "module" });
|
|
3389
|
-
this.
|
|
3390
|
-
const
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3392
|
+
this.loaded = new Promise((resolveLoaded, rejectLoaded) => {
|
|
3393
|
+
const onMessage = (e) => {
|
|
3394
|
+
const data = e.data;
|
|
3395
|
+
if (data.type === "loaded") {
|
|
3396
|
+
resolveLoaded();
|
|
3397
|
+
return;
|
|
3398
|
+
}
|
|
3399
|
+
const resolve = this.pendingResolve;
|
|
3400
|
+
const reject = this.pendingReject;
|
|
3401
|
+
this.pendingResolve = null;
|
|
3402
|
+
this.pendingReject = null;
|
|
3403
|
+
if (data.type === "error") {
|
|
3404
|
+
reject?.(new Error(`worker: ${data.message}`));
|
|
3405
|
+
}
|
|
3406
|
+
else {
|
|
3407
|
+
resolve?.(data);
|
|
3408
|
+
}
|
|
3409
|
+
};
|
|
3410
|
+
this.worker.addEventListener("message", onMessage);
|
|
3411
|
+
this.worker.addEventListener("error", (e) => {
|
|
3412
|
+
const err = e.error ?? new Error(e.message);
|
|
3413
|
+
rejectLoaded(err);
|
|
3414
|
+
const reject = this.pendingReject;
|
|
3415
|
+
this.pendingResolve = null;
|
|
3416
|
+
this.pendingReject = null;
|
|
3417
|
+
reject?.(err);
|
|
3418
|
+
});
|
|
3400
3419
|
});
|
|
3401
3420
|
}
|
|
3402
|
-
init(msg) {
|
|
3421
|
+
async init(msg) {
|
|
3422
|
+
await this.loaded;
|
|
3403
3423
|
return new Promise((resolve, reject) => {
|
|
3404
3424
|
this.pendingResolve = resolve;
|
|
3405
3425
|
this.pendingReject = reject;
|
|
@@ -3419,7 +3439,8 @@ class WorkerHandle {
|
|
|
3419
3439
|
}
|
|
3420
3440
|
}
|
|
3421
3441
|
function workerUrl() {
|
|
3422
|
-
|
|
3442
|
+
const file = import.meta.url.endsWith(".ts") ? "./worker.ts" : "./worker.js";
|
|
3443
|
+
return new URL(`${file}?v=${encodeURIComponent(VERSION)}`, import.meta.url);
|
|
3423
3444
|
}
|
|
3424
3445
|
function pageResultToResult(msg) {
|
|
3425
3446
|
return {
|
|
@@ -3544,6 +3565,9 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3544
3565
|
}
|
|
3545
3566
|
|
|
3546
3567
|
/// <reference lib="dom" />
|
|
3568
|
+
const versionEl = document.getElementById("version");
|
|
3569
|
+
if (versionEl)
|
|
3570
|
+
versionEl.textContent = "v" + VERSION;
|
|
3547
3571
|
async function readFileAsUint8Array(file) {
|
|
3548
3572
|
return new Promise((resolve, reject) => {
|
|
3549
3573
|
const reader = new FileReader();
|