@u1f992/pdfdiff 0.2.2 → 0.3.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.
Files changed (71) hide show
  1. package/.clang-format +3 -0
  2. package/.github/workflows/gh-pages.yml +6 -6
  3. package/.vscode/extensions.json +1 -1
  4. package/.vscode/settings.json +1 -1
  5. package/LICENSE +68 -81
  6. package/README.md +7 -0
  7. package/dist/browser.js +243 -3109
  8. package/dist/browser.js.map +1 -1
  9. package/dist/cli-png-worker.d.ts.map +1 -1
  10. package/dist/cli-png-worker.js +0 -16
  11. package/dist/cli-png-worker.js.map +1 -1
  12. package/dist/cli.js +270 -3151
  13. package/dist/cli.js.map +1 -1
  14. package/dist/core.wasm +0 -0
  15. package/dist/decode.d.ts +9 -0
  16. package/dist/decode.d.ts.map +1 -0
  17. package/dist/diff.d.ts.map +1 -1
  18. package/dist/gs-wasm/gs.js +5821 -0
  19. package/dist/gs-wasm/gs.wasm +0 -0
  20. package/dist/gs-wasm/index.js +120 -0
  21. package/dist/gs-wasm/index.js.map +1 -0
  22. package/dist/gs-wasm/worker.js +764 -0
  23. package/dist/gs-wasm/worker.js.map +1 -0
  24. package/dist/image.d.ts.map +1 -1
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.html +1 -1
  28. package/dist/index.js +242 -3109
  29. package/dist/index.js.map +1 -1
  30. package/dist/iterable.d.ts.map +1 -1
  31. package/dist/jimp.d.ts +23 -1
  32. package/dist/jimp.d.ts.map +1 -1
  33. package/dist/pdf.d.ts +15 -4
  34. package/dist/pdf.d.ts.map +1 -1
  35. package/dist/perf.d.ts.map +1 -1
  36. package/dist/rgba-color.d.ts.map +1 -1
  37. package/dist/transferable.d.ts +6 -2
  38. package/dist/transferable.d.ts.map +1 -1
  39. package/dist/version.d.ts +1 -1
  40. package/dist/worker.d.ts +6 -8
  41. package/dist/worker.d.ts.map +1 -1
  42. package/dist/worker.js +70 -3311
  43. package/dist/worker.js.map +1 -1
  44. package/package.json +10 -5
  45. package/prettier.config.js +1 -1
  46. package/rollup.config.js +63 -5
  47. package/scripts/build-wasm.sh +32 -0
  48. package/src/browser.ts +9 -6
  49. package/src/cli-png-worker.ts +0 -17
  50. package/src/cli.ts +38 -23
  51. package/src/decode.ts +13 -0
  52. package/src/diff.ts +0 -17
  53. package/src/image.ts +1 -18
  54. package/src/index.html +1 -1
  55. package/src/index.test.ts +10 -18
  56. package/src/index.ts +170 -74
  57. package/src/iterable.test.ts +0 -17
  58. package/src/iterable.ts +0 -17
  59. package/src/jimp.ts +25 -7
  60. package/src/pdf.ts +100 -69
  61. package/src/perf.ts +0 -17
  62. package/src/rgba-color.test.ts +0 -17
  63. package/src/rgba-color.ts +0 -17
  64. package/src/transferable.ts +6 -21
  65. package/src/worker.ts +91 -87
  66. package/tsconfig.json +53 -50
  67. package/wasm/Makefile +34 -0
  68. package/wasm/bindings.cpp +76 -0
  69. package/wasm/core.c +179 -0
  70. package/wasm/core.h +69 -0
  71. package/dist/mupdf-wasm.wasm +0 -0
package/wasm/core.h ADDED
@@ -0,0 +1,69 @@
1
+ #ifndef CORE_H
2
+ #define CORE_H
3
+
4
+ #include <stdint.h>
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ enum {
11
+ CORE_OK = 0,
12
+ CORE_ERROR_ALLOC = -1,
13
+ CORE_ERROR_INVALID = -2,
14
+ };
15
+
16
+ typedef struct {
17
+ uint8_t r;
18
+ uint8_t g;
19
+ uint8_t b;
20
+ uint8_t a;
21
+ } CoreColor;
22
+
23
+ typedef struct {
24
+ CoreColor addition;
25
+ CoreColor deletion;
26
+ CoreColor modification;
27
+ } CorePallet;
28
+
29
+ /*
30
+ * Output buffers are owned by the caller; release with core_result_free.
31
+ * On error, the struct is left zero-initialized and nothing needs freeing.
32
+ *
33
+ * `overlay` : width * height * 4 bytes RGBA. Final overlay computed as
34
+ * alpha-over of (a * 0.2), (b * 0.2), and (diff layer * 1.0).
35
+ * `*_xy` : packed [x0, y0, x1, y1, ...] int32 coordinates.
36
+ * `*_count` : number of pixels (each pixel uses 2 int32 entries).
37
+ */
38
+ typedef struct {
39
+ uint8_t *overlay;
40
+ int32_t *addition_xy;
41
+ int32_t addition_count;
42
+ int32_t *deletion_xy;
43
+ int32_t deletion_count;
44
+ int32_t *modification_xy;
45
+ int32_t modification_count;
46
+ } CoreResult;
47
+
48
+ /*
49
+ * Diff scan + diff-layer paint + final overlay compose, in a single pass.
50
+ *
51
+ * a_pixels, b_pixels: width * height * 4 bytes RGBA, identical dimensions.
52
+ * mask_pixels : NULL, or width * height * 4 bytes RGBA. Pixels where
53
+ * mask alpha != 0 are excluded from the diff scan.
54
+ * pallet : colors used to paint the diff layer per category.
55
+ * out : populated with overlay + per-category coordinates.
56
+ *
57
+ * Returns CORE_OK on success, negative on error.
58
+ */
59
+ int32_t process_page(const uint8_t *a_pixels, const uint8_t *b_pixels,
60
+ const uint8_t *mask_pixels, int32_t width, int32_t height,
61
+ const CorePallet *pallet, CoreResult *out);
62
+
63
+ void core_result_free(CoreResult *r);
64
+
65
+ #ifdef __cplusplus
66
+ }
67
+ #endif
68
+
69
+ #endif
Binary file