@u1f992/pdfdiff 0.0.1 → 0.1.0
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 +60 -0
- package/.github/workflows/publish.yml +34 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +20 -0
- package/LICENSE +674 -0
- package/README.md +24 -45
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +3621 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +39804 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff.d.ts +15 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/image.d.ts +13 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.html +67 -0
- package/dist/index.js +3493 -0
- package/dist/index.js.map +1 -0
- package/dist/iterable.d.ts +2 -0
- package/dist/iterable.d.ts.map +1 -0
- package/dist/iterable.test.d.ts +2 -0
- package/dist/iterable.test.d.ts.map +1 -0
- package/dist/jimp.d.ts +6 -0
- package/dist/jimp.d.ts.map +1 -0
- package/dist/mupdf-wasm.wasm +0 -0
- package/dist/pdf.d.ts +377 -0
- package/dist/pdf.d.ts.map +1 -0
- package/dist/rgba-color.d.ts +4 -0
- package/dist/rgba-color.d.ts.map +1 -0
- package/dist/rgba-color.test.d.ts +2 -0
- package/dist/rgba-color.test.d.ts.map +1 -0
- package/dist/style.css +19 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +380 -0
- package/dist/worker.js.map +1 -0
- package/package.json +44 -7
- package/prettier.config.js +3 -0
- package/prototyping/README.md +1 -0
- package/prototyping/flat-map-concurrency.js +218 -0
- package/prototyping/worker.js +10 -0
- package/rollup.config.js +121 -0
- package/src/browser.ts +184 -0
- package/src/cli.ts +175 -0
- package/src/diff.ts +70 -0
- package/src/image.ts +128 -0
- package/src/index.html +67 -0
- package/src/index.ts +186 -0
- package/src/iterable.test.ts +40 -0
- package/src/iterable.ts +24 -0
- package/src/jimp.ts +14 -0
- package/src/pdf.ts +42 -0
- package/src/rgba-color.test.ts +43 -0
- package/src/rgba-color.ts +63 -0
- package/src/style.css +19 -0
- package/src/worker.ts +62 -0
- package/test/a.pdf +0 -0
- package/test/b.pdf +0 -0
- package/test/base.xcf +0 -0
- package/test/expected.png +0 -0
- package/test/mask.pdf +0 -0
- package/tsconfig.json +50 -0
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type JimpInstance } from "./jimp.js";
|
|
2
|
+
import { type AlignStrategy } from "./image.js";
|
|
3
|
+
import { type RGBAColor } from "./rgba-color.js";
|
|
4
|
+
export type Pallet = {
|
|
5
|
+
addition: RGBAColor;
|
|
6
|
+
deletion: RGBAColor;
|
|
7
|
+
modification: RGBAColor;
|
|
8
|
+
};
|
|
9
|
+
export declare function drawDifference(a: JimpInstance, b: JimpInstance, mask: JimpInstance, pallet: Readonly<Pallet>, align: AlignStrategy): {
|
|
10
|
+
diff: JimpInstance;
|
|
11
|
+
addition: [number, number][];
|
|
12
|
+
deletion: [number, number][];
|
|
13
|
+
modification: [number, number][];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7E,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,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,KAAK,EAAE,aAAa;;;;;EAmCrB"}
|
package/dist/image.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type JimpInstance } from "./jimp.js";
|
|
2
|
+
export declare function createEmptyImage(width: number, height: number): JimpInstance;
|
|
3
|
+
export declare function fillWithEmpty(images: [JimpInstance, JimpInstance] | [JimpInstance, null] | [null, JimpInstance]): [JimpInstance, JimpInstance];
|
|
4
|
+
export declare function fillWithEmpty(images: [JimpInstance, JimpInstance, JimpInstance] | [JimpInstance, JimpInstance, null] | [JimpInstance, null, JimpInstance] | [JimpInstance, null, null] | [null, JimpInstance, JimpInstance] | [null, JimpInstance, null] | [null, null, JimpInstance]): [JimpInstance, JimpInstance, JimpInstance];
|
|
5
|
+
declare const alignStrategyValues: Set<"resize" | "top-left" | "top-center" | "top-right" | "middle-left" | "middle-center" | "middle-right" | "bottom-left" | "bottom-center" | "bottom-right">;
|
|
6
|
+
type UnwrapSet<T> = T extends Set<infer U> ? U : never;
|
|
7
|
+
export type AlignStrategy = UnwrapSet<typeof alignStrategyValues>;
|
|
8
|
+
export declare const isValidAlignStrategy: (str: string) => str is AlignStrategy;
|
|
9
|
+
export declare function alignSize(images: [JimpInstance, JimpInstance], align: AlignStrategy): [JimpInstance, JimpInstance];
|
|
10
|
+
export declare function alignSize(images: [JimpInstance, JimpInstance, JimpInstance], align: AlignStrategy): [JimpInstance, JimpInstance, JimpInstance];
|
|
11
|
+
export declare function composeLayers(canvasWidth: number, canvasHeight: number, layers: [JimpInstance, number][]): JimpInstance;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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,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,gBAUjC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isValidAlignStrategy, type AlignStrategy } from "./image.js";
|
|
2
|
+
import { withIndex } from "./iterable.js";
|
|
3
|
+
import { parseHex, formatHex } from "./rgba-color.js";
|
|
4
|
+
import type { Pallet } from "./diff.js";
|
|
5
|
+
import type { JimpInstance } from "./jimp.js";
|
|
6
|
+
export { withIndex, isValidAlignStrategy, parseHex, formatHex };
|
|
7
|
+
type Options = {
|
|
8
|
+
dpi: number;
|
|
9
|
+
alpha: boolean;
|
|
10
|
+
mask: Uint8Array | undefined;
|
|
11
|
+
align: AlignStrategy;
|
|
12
|
+
pallet: Pallet;
|
|
13
|
+
};
|
|
14
|
+
type Result = {
|
|
15
|
+
a: JimpInstance;
|
|
16
|
+
b: JimpInstance;
|
|
17
|
+
diff: JimpInstance;
|
|
18
|
+
addition: [number, number][];
|
|
19
|
+
deletion: [number, number][];
|
|
20
|
+
modification: [number, number][];
|
|
21
|
+
};
|
|
22
|
+
export declare const defaultOptions: Options;
|
|
23
|
+
export declare function visualizeDifferences(a: Uint8Array, b: Uint8Array, options: Partial<Omit<Options, "pallet"> & {
|
|
24
|
+
pallet: Partial<Pallet>;
|
|
25
|
+
}>): AsyncGenerator<Result, void, unknown>;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"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ja">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>pdfdiff</title>
|
|
7
|
+
<link rel="stylesheet" href="./style.css" />
|
|
8
|
+
<script type="module" src="./browser.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<h1>pdfdiff</h1>
|
|
12
|
+
<div class="form-container">
|
|
13
|
+
<form id="pdf-diff-form">
|
|
14
|
+
<div>
|
|
15
|
+
<label for="pdf-a">A:</label>
|
|
16
|
+
<input type="file" id="pdf-a" accept="application/pdf" required />
|
|
17
|
+
</div>
|
|
18
|
+
<div>
|
|
19
|
+
<label for="pdf-b">B:</label>
|
|
20
|
+
<input type="file" id="pdf-b" accept="application/pdf" required />
|
|
21
|
+
</div>
|
|
22
|
+
<div>
|
|
23
|
+
<label for="pdf-mask">Mask:</label>
|
|
24
|
+
<input type="file" id="pdf-mask" accept="application/pdf" />
|
|
25
|
+
</div>
|
|
26
|
+
<div>
|
|
27
|
+
<label for="dpi">DPI:</label>
|
|
28
|
+
<input type="number" id="dpi" value="150" />
|
|
29
|
+
</div>
|
|
30
|
+
<div>
|
|
31
|
+
<label for="alpha">Alpha:</label>
|
|
32
|
+
<input type="checkbox" id="alpha" checked />
|
|
33
|
+
</div>
|
|
34
|
+
<div>
|
|
35
|
+
<label for="align">Align:</label>
|
|
36
|
+
<select id="align">
|
|
37
|
+
<option value="resize">resize</option>
|
|
38
|
+
<option value="top-left">top-left</option>
|
|
39
|
+
<option value="top-center">top-center</option>
|
|
40
|
+
<option value="top-right">top-right</option>
|
|
41
|
+
<option value="middle-left">middle-left</option>
|
|
42
|
+
<option value="middle-center">middle-center</option>
|
|
43
|
+
<option value="middle-right">middle-right</option>
|
|
44
|
+
<option value="bottom-left">bottom-left</option>
|
|
45
|
+
<option value="bottom-center">bottom-center</option>
|
|
46
|
+
<option value="bottom-right">bottom-right</option>
|
|
47
|
+
</select>
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<label for="addition-color">Addition:</label>
|
|
51
|
+
<input type="color" id="addition-color" value="#4cae4f" />
|
|
52
|
+
</div>
|
|
53
|
+
<div>
|
|
54
|
+
<label for="deletion-color">Deletion:</label>
|
|
55
|
+
<input type="color" id="deletion-color" value="#ff5724" />
|
|
56
|
+
</div>
|
|
57
|
+
<div>
|
|
58
|
+
<label for="modification-color">Modification:</label>
|
|
59
|
+
<input type="color" id="modification-color" value="#ffc105" />
|
|
60
|
+
</div>
|
|
61
|
+
<button type="submit">Submit</button>
|
|
62
|
+
</form>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="error" id="error-message"></div>
|
|
65
|
+
<div class="results" id="results"></div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|