@u1f992/pdfdiff 0.2.1 → 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 +1183 -7
- 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 +206 -5
- 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 +5 -0
- package/dist/index.js +90 -3
- 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 +1 -1
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +239 -64
- package/dist/worker.js.map +1 -1
- package/package.json +3 -1
- package/rollup.config.js +20 -0
- package/src/browser.ts +115 -5
- package/src/cli-png-worker.ts +59 -0
- package/src/cli.ts +104 -11
- package/src/diff.ts +99 -34
- package/src/image.ts +3 -0
- package/src/index.html +5 -0
- package/src/index.ts +13 -2
- 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 +34 -32
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":[],"mapp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Y,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;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAU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b,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,yCAgHxE"}
|
package/dist/index.html
CHANGED
|
@@ -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,7 +3422,7 @@ async function* withIndex(iter, start = 0) {
|
|
|
3346
3422
|
}
|
|
3347
3423
|
}
|
|
3348
3424
|
|
|
3349
|
-
const VERSION = "0.2.
|
|
3425
|
+
const VERSION = "0.2.2";
|
|
3350
3426
|
|
|
3351
3427
|
/*
|
|
3352
3428
|
* Copyright (C) 2025 Koutaro Mukai
|
|
@@ -3450,7 +3526,8 @@ function workerUrl() {
|
|
|
3450
3526
|
return new URL(`${file}?v=${encodeURIComponent(VERSION)}`, import.meta.url);
|
|
3451
3527
|
}
|
|
3452
3528
|
function pageResultToResult(msg) {
|
|
3453
|
-
|
|
3529
|
+
const sP = perf.span("main.pageResultToResult_ms");
|
|
3530
|
+
const r = {
|
|
3454
3531
|
a: Jimp.fromBitmap({
|
|
3455
3532
|
width: msg.a.width,
|
|
3456
3533
|
height: msg.a.height,
|
|
@@ -3470,6 +3547,11 @@ function pageResultToResult(msg) {
|
|
|
3470
3547
|
deletion: msg.deletion,
|
|
3471
3548
|
modification: msg.modification,
|
|
3472
3549
|
};
|
|
3550
|
+
sP.stop();
|
|
3551
|
+
perf.incr("main.resultsReceived");
|
|
3552
|
+
if (msg.perf)
|
|
3553
|
+
perf.merge(msg.perf);
|
|
3554
|
+
return r;
|
|
3473
3555
|
}
|
|
3474
3556
|
async function* visualizeDifferences(a, b, options) {
|
|
3475
3557
|
const merged = {
|
|
@@ -3535,6 +3617,7 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3535
3617
|
}
|
|
3536
3618
|
else {
|
|
3537
3619
|
buffered.set(idx, result);
|
|
3620
|
+
perf.setMax("main.bufferedPeak", buffered.size);
|
|
3538
3621
|
}
|
|
3539
3622
|
}
|
|
3540
3623
|
catch (e) {
|
|
@@ -3557,11 +3640,15 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3557
3640
|
r = buf;
|
|
3558
3641
|
}
|
|
3559
3642
|
else {
|
|
3643
|
+
const sWait = perf.span("main.yieldWaitMain_ms");
|
|
3560
3644
|
r = await new Promise((resolve) => resolvers.set(i, resolve));
|
|
3645
|
+
sWait.stop();
|
|
3561
3646
|
if (workerError !== null)
|
|
3562
3647
|
throw workerError;
|
|
3563
3648
|
}
|
|
3649
|
+
const sYield = perf.span("main.consumerTime_ms");
|
|
3564
3650
|
yield r;
|
|
3651
|
+
sYield.stop();
|
|
3565
3652
|
}
|
|
3566
3653
|
await Promise.all(loops);
|
|
3567
3654
|
}
|
|
@@ -3571,5 +3658,5 @@ async function* visualizeDifferences(a, b, options) {
|
|
|
3571
3658
|
}
|
|
3572
3659
|
}
|
|
3573
3660
|
|
|
3574
|
-
export { defaultOptions, formatHex, isValidAlignStrategy, parseHex, visualizeDifferences, withIndex };
|
|
3661
|
+
export { defaultOptions, formatHex, isValidAlignStrategy, parseHex, perf, visualizeDifferences, withIndex };
|
|
3575
3662
|
//# sourceMappingURL=index.js.map
|