@u1f992/pdfdiff 0.2.0 → 0.2.2
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/.github/workflows/gh-pages.yml +6 -1
- package/dist/browser.js +1219 -19
- package/dist/browser.js.map +1 -1
- package/dist/cli-png-worker.d.ts +13 -0
- package/dist/cli-png-worker.d.ts.map +1 -0
- package/dist/cli-png-worker.js +303 -0
- package/dist/cli-png-worker.js.map +1 -0
- package/dist/cli.js +240 -26
- package/dist/cli.js.map +1 -1
- package/dist/diff.d.ts +2 -1
- package/dist/diff.d.ts.map +1 -1
- package/dist/image.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +6 -1
- package/dist/index.js +123 -15
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts.map +1 -1
- package/dist/perf.d.ts +16 -0
- package/dist/perf.d.ts.map +1 -0
- package/dist/squoosh_png_bg.wasm +0 -0
- package/dist/style.css +12 -0
- package/dist/transferable.d.ts +7 -0
- package/dist/transferable.d.ts.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/worker.d.ts +9 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +274 -88
- package/dist/worker.js.map +1 -1
- package/package.json +5 -2
- package/rollup.config.js +20 -0
- package/scripts/version.ts +35 -0
- package/src/browser.ts +119 -5
- package/src/cli-png-worker.ts +59 -0
- package/src/cli.ts +106 -21
- package/src/diff.ts +99 -34
- package/src/image.ts +3 -0
- package/src/index.html +6 -1
- package/src/index.ts +53 -27
- package/src/pdf.ts +9 -1
- package/src/perf.ts +94 -0
- package/src/style.css +12 -0
- package/src/transferable.ts +30 -0
- package/src/worker.ts +77 -54
package/dist/diff.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export type Pallet = {
|
|
|
6
6
|
deletion: RGBAColor;
|
|
7
7
|
modification: RGBAColor;
|
|
8
8
|
};
|
|
9
|
-
export declare function drawDifference(a: JimpInstance, b: JimpInstance, mask: JimpInstance, pallet: Readonly<Pallet>, align: AlignStrategy): {
|
|
9
|
+
export declare function drawDifference(a: JimpInstance, b: JimpInstance, mask: JimpInstance | null, pallet: Readonly<Pallet>, align: AlignStrategy): {
|
|
10
10
|
diff: JimpInstance;
|
|
11
11
|
addition: [number, number][];
|
|
12
12
|
deletion: [number, number][];
|
|
13
13
|
modification: [number, number][];
|
|
14
|
+
hasDiff: boolean;
|
|
14
15
|
};
|
|
15
16
|
//# sourceMappingURL=diff.d.ts.map
|
package/dist/diff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF,wBAAgB,cAAc,CAC5B,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,EACf,IAAI,EAAE,YAAY,GAAG,IAAI,EACzB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,KAAK,EAAE,aAAa;;;;;;EAoHrB"}
|
package/dist/image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAKtD,YAAY,CACnB;AAED,wBAAgB,aAAa,CAC3B,MAAM,EACF,CAAC,YAAY,EAAE,YAAY,CAAC,GAC5B,CAAC,YAAY,EAAE,IAAI,CAAC,GACpB,CAAC,IAAI,EAAE,YAAY,CAAC,GACvB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAChC,wBAAgB,aAAa,CAC3B,MAAM,EACF,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,GAC1C,CAAC,YAAY,EAAE,YAAY,EAAE,IAAI,CAAC,GAClC,CAAC,YAAY,EAAE,IAAI,EAAE,YAAY,CAAC,GAClC,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,GAC1B,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC,GAClC,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,GAC1B,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,GAC7B,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AAK9C,QAAA,MAAM,mBAAmB,+JAWd,CAAC;AACZ,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACvD,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,GAAG,IAAI,aACX,CAAC;AA2BhD,wBAAgB,SAAS,CACvB,MAAM,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,EACpC,KAAK,EAAE,aAAa,GACnB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAChC,wBAAgB,SAAS,CACvB,MAAM,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,EAClD,KAAK,EAAE,aAAa,GACnB,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AAiB9C,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,gBAkCjC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type Pallet } from "./diff.ts";
|
|
2
2
|
import { isValidAlignStrategy, type AlignStrategy } from "./image.ts";
|
|
3
3
|
import { withIndex } from "./iterable.ts";
|
|
4
|
+
import { perf } from "./perf.ts";
|
|
4
5
|
import { parseHex, formatHex } from "./rgba-color.ts";
|
|
5
6
|
import type { JimpInstance } from "./jimp.ts";
|
|
6
|
-
export { withIndex, isValidAlignStrategy, parseHex, formatHex };
|
|
7
|
+
export { withIndex, isValidAlignStrategy, parseHex, formatHex, perf };
|
|
7
8
|
type Options = {
|
|
8
9
|
dpi: number;
|
|
9
10
|
alpha: boolean;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{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OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,yCAgHxE"}
|
package/dist/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<script type="module" src="./browser.js"></script>
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
|
-
<h1>pdfdiff
|
|
12
|
+
<h1>pdfdiff <small id="version"></small></h1>
|
|
13
13
|
<div class="form-container">
|
|
14
14
|
<form id="pdf-diff-form">
|
|
15
15
|
<div>
|
|
@@ -64,6 +64,11 @@
|
|
|
64
64
|
<input type="color" id="modification-color" value="#ffc105" />
|
|
65
65
|
</div>
|
|
66
66
|
<button type="submit">Submit</button>
|
|
67
|
+
<label>
|
|
68
|
+
<input type="checkbox" id="hide-no-diff" />
|
|
69
|
+
Hide pages with no diff
|
|
70
|
+
</label>
|
|
71
|
+
<button type="button" id="download-zip" disabled>Download zip</button>
|
|
67
72
|
</form>
|
|
68
73
|
</div>
|
|
69
74
|
<div class="error" id="error-message"></div>
|
package/dist/index.js
CHANGED
|
@@ -3233,6 +3233,82 @@ function requireBrowser () {
|
|
|
3233
3233
|
var browserExports = requireBrowser();
|
|
3234
3234
|
var Worker$1 = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
3235
3235
|
|
|
3236
|
+
/*
|
|
3237
|
+
* Copyright (C) 2025 Koutaro Mukai
|
|
3238
|
+
*
|
|
3239
|
+
* This program is free software: you can redistribute it and/or modify
|
|
3240
|
+
* it under the terms of the GNU General Public License as published by
|
|
3241
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
3242
|
+
* (at your option) any later version.
|
|
3243
|
+
*
|
|
3244
|
+
* This program is distributed in the hope that it will be useful,
|
|
3245
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
3246
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
3247
|
+
* GNU General Public License for more details.
|
|
3248
|
+
*
|
|
3249
|
+
* You should have received a copy of the GNU General Public License
|
|
3250
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
3251
|
+
*/
|
|
3252
|
+
const _enabled = (() => {
|
|
3253
|
+
try {
|
|
3254
|
+
if (typeof process !== "undefined" &&
|
|
3255
|
+
process.env &&
|
|
3256
|
+
process.env.PDFDIFF_PROFILE === "1") {
|
|
3257
|
+
return true;
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
catch {
|
|
3261
|
+
// process not available (e.g. in some browser worker environments)
|
|
3262
|
+
}
|
|
3263
|
+
const g = globalThis;
|
|
3264
|
+
return g.__PDFDIFF_PROFILE__ === true;
|
|
3265
|
+
})();
|
|
3266
|
+
const _counters = Object.create(null);
|
|
3267
|
+
const _NOOP_SPAN = Object.freeze({ stop() { } });
|
|
3268
|
+
const _noop = () => { };
|
|
3269
|
+
const _emptyDump = () => Object.freeze({});
|
|
3270
|
+
const _realPerf = {
|
|
3271
|
+
enabled: true,
|
|
3272
|
+
span(key) {
|
|
3273
|
+
const t0 = performance.now();
|
|
3274
|
+
return {
|
|
3275
|
+
stop() {
|
|
3276
|
+
_counters[key] = (_counters[key] ?? 0) + (performance.now() - t0);
|
|
3277
|
+
},
|
|
3278
|
+
};
|
|
3279
|
+
},
|
|
3280
|
+
incr(key, delta = 1) {
|
|
3281
|
+
_counters[key] = (_counters[key] ?? 0) + delta;
|
|
3282
|
+
},
|
|
3283
|
+
setMax(key, value) {
|
|
3284
|
+
const cur = _counters[key];
|
|
3285
|
+
if (cur === undefined || value > cur)
|
|
3286
|
+
_counters[key] = value;
|
|
3287
|
+
},
|
|
3288
|
+
merge(other) {
|
|
3289
|
+
for (const k of Object.keys(other)) {
|
|
3290
|
+
_counters[k] = (_counters[k] ?? 0) + other[k];
|
|
3291
|
+
}
|
|
3292
|
+
},
|
|
3293
|
+
dump() {
|
|
3294
|
+
return { ..._counters };
|
|
3295
|
+
},
|
|
3296
|
+
reset() {
|
|
3297
|
+
for (const k of Object.keys(_counters))
|
|
3298
|
+
delete _counters[k];
|
|
3299
|
+
},
|
|
3300
|
+
};
|
|
3301
|
+
const _noopPerf = {
|
|
3302
|
+
enabled: false,
|
|
3303
|
+
span: () => _NOOP_SPAN,
|
|
3304
|
+
incr: _noop,
|
|
3305
|
+
setMax: _noop,
|
|
3306
|
+
merge: _noop,
|
|
3307
|
+
dump: _emptyDump,
|
|
3308
|
+
reset: _noop,
|
|
3309
|
+
};
|
|
3310
|
+
const perf = _enabled ? _realPerf : _noopPerf;
|
|
3311
|
+
|
|
3236
3312
|
/*
|
|
3237
3313
|
* Copyright (C) 2025 Koutaro Mukai
|
|
3238
3314
|
*
|
|
@@ -3346,6 +3422,8 @@ async function* withIndex(iter, start = 0) {
|
|
|
3346
3422
|
}
|
|
3347
3423
|
}
|
|
3348
3424
|
|
|
3425
|
+
const VERSION = "0.2.2";
|
|
3426
|
+
|
|
3349
3427
|
/*
|
|
3350
3428
|
* Copyright (C) 2025 Koutaro Mukai
|
|
3351
3429
|
*
|
|
@@ -3389,24 +3467,42 @@ function asSharedBytes(bytes) {
|
|
|
3389
3467
|
}
|
|
3390
3468
|
class WorkerHandle {
|
|
3391
3469
|
worker;
|
|
3470
|
+
loaded;
|
|
3392
3471
|
pendingResolve = null;
|
|
3393
3472
|
pendingReject = null;
|
|
3394
3473
|
constructor(url) {
|
|
3395
3474
|
this.worker = new Worker$1(url, { type: "module" });
|
|
3396
|
-
this.
|
|
3397
|
-
const
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3475
|
+
this.loaded = new Promise((resolveLoaded, rejectLoaded) => {
|
|
3476
|
+
const onMessage = (e) => {
|
|
3477
|
+
const data = e.data;
|
|
3478
|
+
if (data.type === "loaded") {
|
|
3479
|
+
resolveLoaded();
|
|
3480
|
+
return;
|
|
3481
|
+
}
|
|
3482
|
+
const resolve = this.pendingResolve;
|
|
3483
|
+
const reject = this.pendingReject;
|
|
3484
|
+
this.pendingResolve = null;
|
|
3485
|
+
this.pendingReject = null;
|
|
3486
|
+
if (data.type === "error") {
|
|
3487
|
+
reject?.(new Error(`worker: ${data.message}`));
|
|
3488
|
+
}
|
|
3489
|
+
else {
|
|
3490
|
+
resolve?.(data);
|
|
3491
|
+
}
|
|
3492
|
+
};
|
|
3493
|
+
this.worker.addEventListener("message", onMessage);
|
|
3494
|
+
this.worker.addEventListener("error", (e) => {
|
|
3495
|
+
const err = e.error ?? new Error(e.message);
|
|
3496
|
+
rejectLoaded(err);
|
|
3497
|
+
const reject = this.pendingReject;
|
|
3498
|
+
this.pendingResolve = null;
|
|
3499
|
+
this.pendingReject = null;
|
|
3500
|
+
reject?.(err);
|
|
3501
|
+
});
|
|
3407
3502
|
});
|
|
3408
3503
|
}
|
|
3409
|
-
init(msg) {
|
|
3504
|
+
async init(msg) {
|
|
3505
|
+
await this.loaded;
|
|
3410
3506
|
return new Promise((resolve, reject) => {
|
|
3411
3507
|
this.pendingResolve = resolve;
|
|
3412
3508
|
this.pendingReject = reject;
|
|
@@ -3426,10 +3522,12 @@ class WorkerHandle {
|
|
|
3426
3522
|
}
|
|
3427
3523
|
}
|
|
3428
3524
|
function workerUrl() {
|
|
3429
|
-
|
|
3525
|
+
const file = import.meta.url.endsWith(".ts") ? "./worker.ts" : "./worker.js";
|
|
3526
|
+
return new URL(`${file}?v=${encodeURIComponent(VERSION)}`, import.meta.url);
|
|
3430
3527
|
}
|
|
3431
3528
|
function pageResultToResult(msg) {
|
|
3432
|
-
|
|
3529
|
+
const sP = perf.span("main.pageResultToResult_ms");
|
|
3530
|
+
const r = {
|
|
3433
3531
|
a: Jimp.fromBitmap({
|
|
3434
3532
|
width: msg.a.width,
|
|
3435
3533
|
height: msg.a.height,
|
|
@@ -3449,6 +3547,11 @@ function pageResultToResult(msg) {
|
|
|
3449
3547
|
deletion: msg.deletion,
|
|
3450
3548
|
modification: msg.modification,
|
|
3451
3549
|
};
|
|
3550
|
+
sP.stop();
|
|
3551
|
+
perf.incr("main.resultsReceived");
|
|
3552
|
+
if (msg.perf)
|
|
3553
|
+
perf.merge(msg.perf);
|
|
3554
|
+
return r;
|
|
3452
3555
|
}
|
|
3453
3556
|
async function* visualizeDifferences(a, b, options) {
|
|
3454
3557
|
const merged = {
|
|
@@ -3514,6 +3617,7 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3514
3617
|
}
|
|
3515
3618
|
else {
|
|
3516
3619
|
buffered.set(idx, result);
|
|
3620
|
+
perf.setMax("main.bufferedPeak", buffered.size);
|
|
3517
3621
|
}
|
|
3518
3622
|
}
|
|
3519
3623
|
catch (e) {
|
|
@@ -3536,11 +3640,15 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3536
3640
|
r = buf;
|
|
3537
3641
|
}
|
|
3538
3642
|
else {
|
|
3643
|
+
const sWait = perf.span("main.yieldWaitMain_ms");
|
|
3539
3644
|
r = await new Promise((resolve) => resolvers.set(i, resolve));
|
|
3645
|
+
sWait.stop();
|
|
3540
3646
|
if (workerError !== null)
|
|
3541
3647
|
throw workerError;
|
|
3542
3648
|
}
|
|
3649
|
+
const sYield = perf.span("main.consumerTime_ms");
|
|
3543
3650
|
yield r;
|
|
3651
|
+
sYield.stop();
|
|
3544
3652
|
}
|
|
3545
3653
|
await Promise.all(loops);
|
|
3546
3654
|
}
|
|
@@ -3550,5 +3658,5 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3550
3658
|
}
|
|
3551
3659
|
}
|
|
3552
3660
|
|
|
3553
|
-
export { defaultOptions, formatHex, isValidAlignStrategy, parseHex, visualizeDifferences, withIndex };
|
|
3661
|
+
export { defaultOptions, formatHex, isValidAlignStrategy, parseHex, perf, visualizeDifferences, withIndex };
|
|
3554
3662
|
//# sourceMappingURL=index.js.map
|