@chialab/pdfjs-lib 1.0.0-alpha.2 → 1.0.0-alpha.20

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 (68) hide show
  1. package/README.md +15 -7
  2. package/dist/browser/NodeCanvasFactory-ONRE5YYL.js +58 -0
  3. package/dist/browser/chunk-5IWODJWD.js +801 -0
  4. package/dist/browser/chunk-ELOUEWKT.js +1142 -0
  5. package/dist/browser/chunk-NJUB3B5A.js +1207 -0
  6. package/dist/browser/index.js +2641 -3053
  7. package/dist/browser/openjpeg-K2XBCFFN.js +9 -0
  8. package/dist/browser/qcms_bg-Q7BRLLZG.js +9 -0
  9. package/dist/browser/worker.js +7307 -6457
  10. package/dist/index.d.ts +3 -0
  11. package/dist/lib/AnnotationData.d.ts +8 -8
  12. package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
  13. package/dist/lib/CanvasGraphics.d.ts +1 -0
  14. package/dist/lib/NodeCanvasFactory.d.ts +9 -0
  15. package/dist/lib/NodeFilterFactory.d.ts +10 -0
  16. package/dist/lib/Path2D.d.ts +1 -1
  17. package/dist/lib/StandardFontDataFactory.d.ts +2 -2
  18. package/dist/lib/Svg.d.ts +143 -0
  19. package/dist/lib/SvgCanvasContext.d.ts +31 -22
  20. package/dist/lib/TextLayer.d.ts +12 -5
  21. package/dist/lib/WasmFactory.d.ts +5 -0
  22. package/dist/lib/utils.d.ts +29 -3
  23. package/dist/node/NodeCanvasFactory-YRBSQ5MH.js +8 -0
  24. package/dist/node/chunk-3XZOTLLE.js +1439 -0
  25. package/dist/node/chunk-XMKSLA4K.js +1207 -0
  26. package/dist/node/chunk-ZKUTXCS2.js +801 -0
  27. package/dist/node/index.js +2659 -3102
  28. package/dist/node/openjpeg-B2WN24QZ.js +9 -0
  29. package/dist/node/qcms_bg-T4RSHPOQ.js +9 -0
  30. package/dist/node/worker.js +7307 -6457
  31. package/dist/pdf.js/src/display/annotation_layer.d.ts +1 -2
  32. package/dist/pdf.js/src/display/annotation_storage.d.ts +1 -8
  33. package/dist/pdf.js/src/display/api.d.ts +38 -72
  34. package/dist/pdf.js/src/display/api_utils.d.ts +13 -0
  35. package/dist/pdf.js/src/display/canvas.d.ts +21 -29
  36. package/dist/pdf.js/src/display/display_utils.d.ts +12 -1
  37. package/dist/pdf.js/src/display/draw_layer.d.ts +2 -2
  38. package/dist/pdf.js/src/display/editor/alt_text.d.ts +1 -1
  39. package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +5 -5
  40. package/dist/pdf.js/src/display/editor/color_picker.d.ts +1 -1
  41. package/dist/pdf.js/src/display/editor/draw.d.ts +7 -7
  42. package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +3 -3
  43. package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +13 -13
  44. package/dist/pdf.js/src/display/editor/editor.d.ts +30 -6
  45. package/dist/pdf.js/src/display/editor/freetext.d.ts +4 -7
  46. package/dist/pdf.js/src/display/editor/highlight.d.ts +6 -3
  47. package/dist/pdf.js/src/display/editor/ink.d.ts +1 -0
  48. package/dist/pdf.js/src/display/editor/signature.d.ts +3 -0
  49. package/dist/pdf.js/src/display/editor/stamp.d.ts +4 -3
  50. package/dist/pdf.js/src/display/editor/toolbar.d.ts +4 -2
  51. package/dist/pdf.js/src/display/editor/tools.d.ts +7 -9
  52. package/dist/pdf.js/src/display/metadata.d.ts +1 -2
  53. package/dist/pdf.js/src/display/optional_content_config.d.ts +1 -1
  54. package/dist/pdf.js/src/display/pattern_helper.d.ts +4 -2
  55. package/dist/pdf.js/src/display/pdf_objects.d.ts +40 -0
  56. package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
  57. package/dist/pdf.js/src/display/touch_manager.d.ts +5 -1
  58. package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
  59. package/dist/pdf.js/src/pdf.d.ts +4 -1
  60. package/dist/pdf.js/src/shared/scripting_utils.d.ts +2 -0
  61. package/dist/pdf.js/src/shared/util.d.ts +123 -100
  62. package/dist/pdf.js/web/text_accessibility.d.ts +1 -1
  63. package/package.json +7 -4
  64. package/dist/browser/chunk-DYHYQ33L.js +0 -1775
  65. package/dist/node/chunk-KTTVPO2G.js +0 -1775
  66. package/dist/pdf.js/src/display/cmap_reader_factory.d.ts +0 -25
  67. package/dist/pdf.js/src/display/node_utils.d.ts +0 -32
  68. package/dist/pdf.js/src/display/wasm_factory.d.ts +0 -20
package/README.md CHANGED
@@ -7,12 +7,12 @@
7
7
 
8
8
  ## Features
9
9
 
10
- * Browser and Node (and Bun) optimized builds using ES modules
11
- * Bundler-friendly
12
- * Polyfills included
13
- * Extended annotation models support
14
- * SVG renderer for PDF pages
15
- * Improved TextLayer extraction with structure information
10
+ - Browser and Node (and Bun) optimized builds using ES modules
11
+ - Bundler-friendly
12
+ - Polyfills included
13
+ - Extended annotation models support
14
+ - SVG renderer for PDF pages
15
+ - Improved TextLayer extraction with structure information
16
16
 
17
17
  ## Install
18
18
 
@@ -26,4 +26,12 @@ yarn add @chialab/pdfjs-lib
26
26
 
27
27
  ```
28
28
  pnpm add @chialab/pdfjs-lib
29
- ```
29
+ ```
30
+
31
+ ## Before building
32
+
33
+ Before building the library:
34
+
35
+ ```
36
+ git submodule init && git submodule update
37
+ ```
@@ -0,0 +1,58 @@
1
+ import {
2
+ BaseCanvasFactory
3
+ } from "./chunk-ELOUEWKT.js";
4
+ import "./chunk-NJUB3B5A.js";
5
+ import "./chunk-O4UKW7AD.js";
6
+
7
+ // src/lib/NodeCanvasFactory.ts
8
+ import { Canvas } from "skia-canvas";
9
+
10
+ // src/lib/NodeFilterFactory.ts
11
+ var filtersRegistry = /* @__PURE__ */ new Map();
12
+
13
+ // src/lib/NodeCanvasFactory.ts
14
+ var NodeCanvasFactory = class extends BaseCanvasFactory {
15
+ _createCanvas(width, height) {
16
+ return new Canvas(width, height);
17
+ }
18
+ create(width, height) {
19
+ const factory = this;
20
+ const { canvas, context } = super.create(width, height);
21
+ const drawImage = context.drawImage;
22
+ let currentFilter = "none";
23
+ Object.defineProperty(context, "filter", {
24
+ get() {
25
+ if (currentFilter.startsWith("url(")) {
26
+ return "none";
27
+ }
28
+ return currentFilter;
29
+ },
30
+ set(value) {
31
+ currentFilter = value;
32
+ },
33
+ configurable: true
34
+ });
35
+ context.drawImage = function(src, ...args) {
36
+ const filter = filtersRegistry.get(currentFilter);
37
+ if (!filter) {
38
+ drawImage.call(this, src, ...args);
39
+ return;
40
+ }
41
+ const { canvas: canvas2, context: context2 } = factory.create(src.width, src.height);
42
+ context2.drawImage(src, 0, 0, src.width, src.height);
43
+ filter(context2);
44
+ drawImage.call(this, canvas2, ...args);
45
+ factory.destroy({
46
+ canvas: canvas2,
47
+ context: context2
48
+ });
49
+ };
50
+ return {
51
+ canvas,
52
+ context
53
+ };
54
+ }
55
+ };
56
+ export {
57
+ NodeCanvasFactory
58
+ };