unpdf 0.10.0 → 0.11.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.
Files changed (61) hide show
  1. package/README.md +9 -7
  2. package/dist/index.cjs +15 -19
  3. package/dist/index.d.cts +32 -13
  4. package/dist/index.d.mts +32 -13
  5. package/dist/index.d.ts +32 -13
  6. package/dist/index.mjs +15 -19
  7. package/dist/pdfjs.d.mts +1 -0
  8. package/dist/pdfjs.d.ts +1 -0
  9. package/dist/pdfjs.mjs +1 -1
  10. package/dist/types/src/display/annotation_layer.d.ts +10 -3
  11. package/dist/types/src/display/annotation_storage.d.ts +1 -0
  12. package/dist/types/src/display/api.d.ts +54 -26
  13. package/dist/types/src/display/base_factory.d.ts +3 -1
  14. package/dist/types/src/display/canvas.d.ts +2 -0
  15. package/dist/types/src/display/display_utils.d.ts +7 -5
  16. package/dist/types/src/display/draw_layer.d.ts +38 -0
  17. package/dist/types/src/display/editor/alt_text.d.ts +22 -0
  18. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +24 -2
  19. package/dist/types/src/display/editor/color_picker.d.ts +19 -0
  20. package/dist/types/src/display/editor/editor.d.ts +78 -16
  21. package/dist/types/src/display/editor/freetext.d.ts +6 -1
  22. package/dist/types/src/display/editor/highlight.d.ts +88 -0
  23. package/dist/types/src/display/editor/ink.d.ts +4 -4
  24. package/dist/types/src/display/editor/outliner.d.ts +70 -0
  25. package/dist/types/src/display/editor/stamp.d.ts +1 -1
  26. package/dist/types/src/display/editor/toolbar.d.ts +17 -0
  27. package/dist/types/src/display/editor/tools.d.ts +39 -4
  28. package/dist/types/src/display/fetch_stream.d.ts +3 -4
  29. package/dist/types/src/display/font_loader.d.ts +1 -5
  30. package/dist/types/src/display/network.d.ts +2 -3
  31. package/dist/types/src/display/node_stream.d.ts +4 -5
  32. package/dist/types/src/display/node_utils.d.ts +6 -5
  33. package/dist/types/src/display/optional_content_config.d.ts +6 -1
  34. package/dist/types/src/display/text_layer.d.ts +40 -108
  35. package/dist/types/src/display/transport_stream.d.ts +3 -7
  36. package/dist/types/src/display/worker_options.d.ts +20 -22
  37. package/dist/types/src/pdf.d.ts +6 -3
  38. package/dist/types/src/shared/util.d.ts +24 -23
  39. package/dist/types/web/annotation_editor_layer_builder.d.ts +10 -13
  40. package/dist/types/web/annotation_layer_builder.d.ts +7 -4
  41. package/dist/types/web/app_options.d.ts +1 -2
  42. package/dist/types/web/draw_layer_builder.d.ts +23 -0
  43. package/dist/types/web/genericl10n.d.ts +5 -3
  44. package/dist/types/web/interfaces.d.ts +11 -8
  45. package/dist/types/web/l10n.d.ts +5 -2
  46. package/dist/types/web/pdf_find_controller.d.ts +1 -2
  47. package/dist/types/web/pdf_history.d.ts +1 -53
  48. package/dist/types/web/pdf_link_service.d.ts +6 -109
  49. package/dist/types/web/pdf_page_view.d.ts +5 -16
  50. package/dist/types/web/pdf_scripting_manager.d.ts +6 -10
  51. package/dist/types/web/pdf_single_page_viewer.d.ts +2 -2
  52. package/dist/types/web/pdf_thumbnail_view.d.ts +1 -13
  53. package/dist/types/web/pdf_thumbnail_viewer.d.ts +1 -17
  54. package/dist/types/web/pdf_viewer.component.d.ts +1 -2
  55. package/dist/types/web/pdf_viewer.d.ts +90 -42
  56. package/dist/types/web/text_accessibility.d.ts +1 -1
  57. package/dist/types/web/text_highlighter.d.ts +1 -1
  58. package/dist/types/web/text_layer_builder.d.ts +17 -29
  59. package/dist/types/web/ui_utils.d.ts +1 -1
  60. package/package.json +21 -30
  61. package/dist/types/web/l10n_utils.d.ts +0 -9
@@ -14,7 +14,7 @@ export class TextAccessibilityManager {
14
14
  * @param {HTMLElement} e2
15
15
  * @returns {number}
16
16
  */
17
- static "__#4@#compareElementPositions"(e1: HTMLElement, e2: HTMLElement): number;
17
+ static "__#6@#compareElementPositions"(e1: HTMLElement, e2: HTMLElement): number;
18
18
  setTextMapping(textDivs: any): void;
19
19
  /**
20
20
  * Function called when the text layer has finished rendering.
@@ -32,7 +32,6 @@ export class TextHighlighter {
32
32
  matches: any[];
33
33
  eventBus: import("./event_utils").EventBus;
34
34
  pageIdx: number;
35
- _onUpdateTextLayerMatches: ((evt: any) => void) | null;
36
35
  textDivs: Node[] | null;
37
36
  textContentItemsStr: string[] | null;
38
37
  enabled: boolean;
@@ -60,4 +59,5 @@ export class TextHighlighter {
60
59
  }[];
61
60
  _renderMatches(matches: any): void;
62
61
  _updateMatches(reset?: boolean): void;
62
+ #private;
63
63
  }
@@ -1,27 +1,24 @@
1
+ export type PDFPageProxy = import("../src/display/api").PDFPageProxy;
1
2
  export type PageViewport = import("../src/display/display_utils").PageViewport;
2
- export type TextContent = import("../src/display/api").TextContent;
3
3
  export type TextHighlighter = import("./text_highlighter").TextHighlighter;
4
4
  export type TextAccessibilityManager = import("./text_accessibility.js").TextAccessibilityManager;
5
5
  export type TextLayerBuilderOptions = {
6
+ pdfPage: PDFPageProxy;
6
7
  /**
7
8
  * - Optional object that will handle
8
9
  * highlighting text from the find controller.
9
10
  */
10
- highlighter: TextHighlighter;
11
+ highlighter?: import("./text_highlighter").TextHighlighter | undefined;
11
12
  accessibilityManager?: import("./text_accessibility.js").TextAccessibilityManager | undefined;
12
- /**
13
- * - Allows to use an
14
- * OffscreenCanvas if needed.
15
- */
16
- isOffscreenCanvasSupported?: boolean | undefined;
13
+ onAppend?: Function | undefined;
17
14
  };
18
15
  /**
19
16
  * @typedef {Object} TextLayerBuilderOptions
20
- * @property {TextHighlighter} highlighter - Optional object that will handle
17
+ * @property {PDFPageProxy} pdfPage
18
+ * @property {TextHighlighter} [highlighter] - Optional object that will handle
21
19
  * highlighting text from the find controller.
22
20
  * @property {TextAccessibilityManager} [accessibilityManager]
23
- * @property {boolean} [isOffscreenCanvasSupported] - Allows to use an
24
- * OffscreenCanvas if needed.
21
+ * @property {function} [onAppend]
25
22
  */
26
23
  /**
27
24
  * The text layer builder provides text selection functionality for the PDF.
@@ -29,41 +26,32 @@ export type TextLayerBuilderOptions = {
29
26
  * contain text that matches the PDF text they are overlaying.
30
27
  */
31
28
  export class TextLayerBuilder {
32
- constructor({ highlighter, accessibilityManager, isOffscreenCanvasSupported, enablePermissions, }: {
29
+ static "__#65@#textLayers": Map<any, any>;
30
+ static "__#65@#selectionChangeAbortController": null;
31
+ static "__#65@#removeGlobalSelectionListener"(textLayerDiv: any): void;
32
+ static "__#65@#enableGlobalSelectionListener"(): void;
33
+ constructor({ pdfPage, highlighter, accessibilityManager, enablePermissions, onAppend, }: {
34
+ pdfPage: any;
33
35
  highlighter?: null | undefined;
34
36
  accessibilityManager?: null | undefined;
35
- isOffscreenCanvasSupported?: boolean | undefined;
36
37
  enablePermissions?: boolean | undefined;
38
+ onAppend?: null | undefined;
37
39
  });
38
- textContentItemsStr: any[];
39
- renderingDone: boolean;
40
- textDivs: any[];
41
- textDivProperties: WeakMap<WeakKey, any>;
42
- textLayerRenderTask: import("../src/display/text_layer.js").TextLayerRenderTask | null;
40
+ pdfPage: any;
43
41
  highlighter: any;
44
42
  accessibilityManager: any;
45
- isOffscreenCanvasSupported: boolean;
46
- /**
47
- * Callback used to attach the textLayer to the DOM.
48
- * @type {function}
49
- */
50
- onAppend: Function;
51
43
  div: HTMLDivElement;
52
- get numTextDivs(): number;
53
44
  /**
54
45
  * Renders the text layer.
55
46
  * @param {PageViewport} viewport
47
+ * @param {Object} [textContentParams]
56
48
  */
57
- render(viewport: PageViewport): Promise<void>;
49
+ render(viewport: PageViewport, textContentParams?: Object | undefined): Promise<void>;
58
50
  hide(): void;
59
51
  show(): void;
60
52
  /**
61
53
  * Cancel rendering of the text layer.
62
54
  */
63
55
  cancel(): void;
64
- /**
65
- * @param {ReadableStream | TextContent} source
66
- */
67
- setTextContentSource(source: ReadableStream | TextContent): void;
68
56
  #private;
69
57
  }
@@ -201,7 +201,7 @@ export namespace PresentationModeState {
201
201
  }
202
202
  export class ProgressBar {
203
203
  constructor(bar: any);
204
- set percent(arg: number);
204
+ set percent(val: number);
205
205
  get percent(): number;
206
206
  setWidth(viewer: any): void;
207
207
  setDisableAutoFetch(delay?: number): void;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "unpdf",
3
3
  "type": "module",
4
- "version": "0.10.0",
5
- "packageManager": "pnpm@8.10.2",
4
+ "version": "0.11.0",
5
+ "packageManager": "pnpm@9.4.0",
6
6
  "description": "Utilities to work with PDFs in Node.js, browser and workers",
7
- "author": "Johann Schopplich <pkg@johannschopplich.com>",
7
+ "author": "Johann Schopplich <hello@johannschopplich.com>",
8
8
  "license": "MIT",
9
9
  "homepage": "https://github.com/unjs/unpdf#readme",
10
10
  "repository": {
@@ -55,11 +55,11 @@
55
55
  "build": "unbuild && node scripts/post-build.mjs",
56
56
  "build:pdfjs": "rollup --config pdfjs.rollup.config.ts --configPlugin typescript && cp -R node_modules/pdfjs-dist/types dist",
57
57
  "dev": "unbuild --stub",
58
- "lint": "eslint \"**/*.{cjs,mjs,ts}\" --ignore-path .gitignore",
58
+ "lint": "eslint .",
59
59
  "lint:fix": "npm run lint -- --fix",
60
60
  "format": "prettier \"**/*.{json,md,cjs,mjs,ts,yml}\" --write",
61
61
  "format:check": "prettier \"**/*.{json,md,cjs,mjs,ts,yml}\" --check",
62
- "release": "bumpp --commit --push --tag",
62
+ "release": "bumpp",
63
63
  "test": "vitest",
64
64
  "test:types": "tsc --noEmit"
65
65
  },
@@ -67,39 +67,30 @@
67
67
  "canvas": "^2.11.2"
68
68
  },
69
69
  "devDependencies": {
70
- "@rollup/plugin-alias": "^5.0.1",
71
- "@rollup/plugin-commonjs": "^25.0.7",
70
+ "@rollup/plugin-alias": "^5.1.0",
71
+ "@rollup/plugin-commonjs": "^26.0.1",
72
72
  "@rollup/plugin-inject": "^5.0.5",
73
73
  "@rollup/plugin-node-resolve": "^15.2.3",
74
- "@rollup/plugin-replace": "^5.0.5",
74
+ "@rollup/plugin-replace": "^5.0.7",
75
75
  "@rollup/plugin-terser": "^0.4.4",
76
- "@rollup/plugin-typescript": "^11.1.5",
77
- "@types/node": "^20.9.0",
78
- "bumpp": "^9.2.0",
79
- "eslint": "^8.53.0",
80
- "eslint-config-unjs": "^0.2.1",
76
+ "@rollup/plugin-typescript": "^11.1.6",
77
+ "@types/node": "^20.14.8",
78
+ "bumpp": "^9.4.1",
79
+ "eslint": "^9.5.0",
80
+ "eslint-config-unjs": "^0.3.2",
81
81
  "fast-glob": "^3.3.2",
82
- "pdfjs-dist": "^4.0.189",
83
- "prettier": "^3.0.3",
84
- "rollup": "^3.28.1",
85
- "typescript": "^5.2.2",
82
+ "pdfjs-dist": "^4.3.136",
83
+ "prettier": "^3.3.2",
84
+ "rollup": "^4.18.0",
85
+ "tslib": "^2.6.3",
86
+ "typescript": "^5.4.4",
86
87
  "unbuild": "^2.0.0",
87
- "unenv": "^1.7.4",
88
- "vitest": "^0.34.3"
88
+ "unenv": "^1.9.0",
89
+ "vitest": "^1.6.0"
89
90
  },
90
91
  "pnpm": {
91
- "overrides": {
92
- "array-includes": "npm:@nolyfill/array-includes@latest",
93
- "array.prototype.findlastindex": "npm:@nolyfill/array.prototype.findlastindex@latest",
94
- "array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
95
- "array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
96
- "has": "npm:@nolyfill/has@latest",
97
- "object.fromentries": "npm:@nolyfill/object.fromentries@latest",
98
- "object.groupby": "npm:@nolyfill/object.groupby@latest",
99
- "object.values": "npm:@nolyfill/object.values@latest"
100
- },
101
92
  "patchedDependencies": {
102
- "pdfjs-dist@4.0.189": "patches/pdfjs-dist@4.0.189.patch"
93
+ "pdfjs-dist@4.3.136": "patches/pdfjs-dist@4.3.136.patch"
103
94
  }
104
95
  }
105
96
  }
@@ -1,9 +0,0 @@
1
- export type IL10n = import("./interfaces").IL10n;
2
- export namespace NullL10n {
3
- function getLanguage(): any;
4
- function getDirection(): any;
5
- function get(ids: any, args: null | undefined, fallback: any): Promise<any>;
6
- function translate(element: any): Promise<any>;
7
- function pause(): any;
8
- function resume(): any;
9
- }