pdfjs-serverless 0.4.2 → 0.5.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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/index.mjs +1 -1
  3. package/dist/types/src/display/annotation_layer.d.ts +10 -3
  4. package/dist/types/src/display/annotation_storage.d.ts +1 -0
  5. package/dist/types/src/display/api.d.ts +49 -22
  6. package/dist/types/src/display/base_factory.d.ts +3 -1
  7. package/dist/types/src/display/canvas.d.ts +2 -0
  8. package/dist/types/src/display/display_utils.d.ts +4 -3
  9. package/dist/types/src/display/draw_layer.d.ts +12 -14
  10. package/dist/types/src/display/editor/alt_text.d.ts +1 -0
  11. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +13 -12
  12. package/dist/types/src/display/editor/color_picker.d.ts +2 -2
  13. package/dist/types/src/display/editor/editor.d.ts +50 -2
  14. package/dist/types/src/display/editor/freetext.d.ts +6 -1
  15. package/dist/types/src/display/editor/highlight.d.ts +38 -4
  16. package/dist/types/src/display/editor/ink.d.ts +4 -4
  17. package/dist/types/src/display/editor/outliner.d.ts +53 -9
  18. package/dist/types/src/display/editor/stamp.d.ts +1 -1
  19. package/dist/types/src/display/editor/toolbar.d.ts +7 -1
  20. package/dist/types/src/display/editor/tools.d.ts +37 -4
  21. package/dist/types/src/display/fetch_stream.d.ts +3 -4
  22. package/dist/types/src/display/font_loader.d.ts +1 -5
  23. package/dist/types/src/display/network.d.ts +2 -3
  24. package/dist/types/src/display/node_stream.d.ts +4 -5
  25. package/dist/types/src/display/node_utils.d.ts +6 -5
  26. package/dist/types/src/display/optional_content_config.d.ts +6 -1
  27. package/dist/types/src/display/text_layer.d.ts +40 -108
  28. package/dist/types/src/display/transport_stream.d.ts +3 -7
  29. package/dist/types/src/display/worker_options.d.ts +20 -22
  30. package/dist/types/src/pdf.d.ts +2 -3
  31. package/dist/types/src/shared/util.d.ts +19 -22
  32. package/dist/types/web/annotation_editor_layer_builder.d.ts +6 -13
  33. package/dist/types/web/annotation_layer_builder.d.ts +7 -4
  34. package/dist/types/web/app_options.d.ts +1 -2
  35. package/dist/types/web/genericl10n.d.ts +5 -3
  36. package/dist/types/web/interfaces.d.ts +8 -5
  37. package/dist/types/web/l10n.d.ts +3 -2
  38. package/dist/types/web/pdf_find_controller.d.ts +1 -2
  39. package/dist/types/web/pdf_history.d.ts +1 -53
  40. package/dist/types/web/pdf_link_service.d.ts +4 -107
  41. package/dist/types/web/pdf_page_view.d.ts +3 -15
  42. package/dist/types/web/pdf_scripting_manager.d.ts +0 -4
  43. package/dist/types/web/pdf_thumbnail_view.d.ts +1 -13
  44. package/dist/types/web/pdf_thumbnail_viewer.d.ts +0 -16
  45. package/dist/types/web/pdf_viewer.component.d.ts +1 -2
  46. package/dist/types/web/pdf_viewer.d.ts +38 -29
  47. package/dist/types/web/text_accessibility.d.ts +1 -1
  48. package/dist/types/web/text_highlighter.d.ts +1 -1
  49. package/dist/types/web/text_layer_builder.d.ts +17 -29
  50. package/package.json +14 -14
  51. package/dist/types/web/l10n_utils.d.ts +0 -9
@@ -84,15 +84,10 @@ export type PDFViewerOptions = {
84
84
  * landscape pages upon printing. The default is `false`.
85
85
  */
86
86
  enablePrintAutoRotate?: boolean | undefined;
87
- /**
88
- * - Allows to use an
89
- * OffscreenCanvas if needed.
90
- */
91
- isOffscreenCanvasSupported?: boolean | undefined;
92
87
  /**
93
88
  * - The maximum supported canvas size in
94
89
  * total pixels, i.e. width * height. Use `-1` for no limit, or `0` for
95
- * CSS-only zooming. The default value is 4096 * 4096 (16 mega-pixels).
90
+ * CSS-only zooming. The default value is 4096 * 8192 (32 mega-pixels).
96
91
  */
97
92
  maxCanvasPixels?: number | undefined;
98
93
  /**
@@ -148,11 +143,9 @@ export namespace PagesCountLimit {
148
143
  * mainly for annotation icons. Include trailing slash.
149
144
  * @property {boolean} [enablePrintAutoRotate] - Enables automatic rotation of
150
145
  * landscape pages upon printing. The default is `false`.
151
- * @property {boolean} [isOffscreenCanvasSupported] - Allows to use an
152
- * OffscreenCanvas if needed.
153
146
  * @property {number} [maxCanvasPixels] - The maximum supported canvas size in
154
147
  * total pixels, i.e. width * height. Use `-1` for no limit, or `0` for
155
- * CSS-only zooming. The default value is 4096 * 4096 (16 mega-pixels).
148
+ * CSS-only zooming. The default value is 4096 * 8192 (32 mega-pixels).
156
149
  * @property {IL10n} [l10n] - Localization service.
157
150
  * @property {boolean} [enablePermissions] - Enables PDF document permissions,
158
151
  * when they exist. The default value is `false`.
@@ -193,16 +186,8 @@ export class PDFViewer {
193
186
  imageResourcesPath: string;
194
187
  enablePrintAutoRotate: boolean;
195
188
  removePageBorders: boolean | undefined;
196
- isOffscreenCanvasSupported: boolean;
197
189
  maxCanvasPixels: number | undefined;
198
- l10n: {
199
- getLanguage(): any;
200
- getDirection(): any;
201
- get(ids: any, args: null | undefined, fallback: any): Promise<any>;
202
- translate(element: any): Promise<any>;
203
- pause(): any;
204
- resume(): any;
205
- };
190
+ l10n: import("./interfaces").IL10n | GenericL10n | undefined;
206
191
  pageColors: Object | null;
207
192
  defaultRenderingQueue: boolean;
208
193
  renderingQueue: PDFRenderingQueue | undefined;
@@ -214,8 +199,6 @@ export class PDFViewer {
214
199
  _eventHandler: (evt: any) => void;
215
200
  };
216
201
  presentationModeState: number;
217
- _onBeforeDraw: ((evt: any) => void) | null;
218
- _onAfterDraw: any;
219
202
  get pagesCount(): number;
220
203
  getPageView(index: any): any;
221
204
  getCachedPageViews(): Set<any>;
@@ -279,9 +262,9 @@ export class PDFViewer {
279
262
  */
280
263
  get pagesRotation(): number;
281
264
  _pagesRotation: any;
282
- get firstPagePromise(): Promise<any> | null;
283
- get onePageRendered(): Promise<any> | null;
284
- get pagesPromise(): Promise<any> | null;
265
+ get firstPagePromise(): any;
266
+ get onePageRendered(): any;
267
+ get pagesPromise(): any;
285
268
  get _layerProperties(): any;
286
269
  getAllText(): Promise<string | null>;
287
270
  /**
@@ -308,9 +291,9 @@ export class PDFViewer {
308
291
  rotation: any;
309
292
  pdfOpenParams: string;
310
293
  } | null | undefined;
311
- _firstPageCapability: PromiseCapability | undefined;
312
- _onePageRenderedCapability: PromiseCapability | undefined;
313
- _pagesCapability: PromiseCapability | undefined;
294
+ _firstPageCapability: any;
295
+ _onePageRenderedCapability: any;
296
+ _pagesCapability: any;
314
297
  _previousScrollMode: any;
315
298
  _spreadMode: any;
316
299
  _scrollUpdate(): void;
@@ -431,24 +414,50 @@ export class PDFViewer {
431
414
  * @property {number} [drawingDelay]
432
415
  * @property {number} [scaleFactor]
433
416
  * @property {number} [steps]
417
+ * @property {Array} [origin] x and y coordinates of the scale
418
+ * transformation origin.
419
+ */
420
+ /**
421
+ * Changes the current zoom level by the specified amount.
422
+ * @param {ChangeScaleOptions} [options]
434
423
  */
424
+ updateScale({ drawingDelay, scaleFactor, steps, origin }?: {
425
+ drawingDelay?: number | undefined;
426
+ scaleFactor?: number | undefined;
427
+ steps?: number | undefined;
428
+ /**
429
+ * x and y coordinates of the scale
430
+ * transformation origin.
431
+ */
432
+ origin?: any[] | undefined;
433
+ } | undefined): void;
435
434
  /**
436
435
  * Increase the current zoom level one, or more, times.
437
436
  * @param {ChangeScaleOptions} [options]
438
437
  */
439
- increaseScale({ drawingDelay, scaleFactor, steps }?: {
438
+ increaseScale(options?: {
440
439
  drawingDelay?: number | undefined;
441
440
  scaleFactor?: number | undefined;
442
441
  steps?: number | undefined;
442
+ /**
443
+ * x and y coordinates of the scale
444
+ * transformation origin.
445
+ */
446
+ origin?: any[] | undefined;
443
447
  } | undefined): void;
444
448
  /**
445
449
  * Decrease the current zoom level one, or more, times.
446
450
  * @param {ChangeScaleOptions} [options]
447
451
  */
448
- decreaseScale({ drawingDelay, scaleFactor, steps }?: {
452
+ decreaseScale(options?: {
449
453
  drawingDelay?: number | undefined;
450
454
  scaleFactor?: number | undefined;
451
455
  steps?: number | undefined;
456
+ /**
457
+ * x and y coordinates of the scale
458
+ * transformation origin.
459
+ */
460
+ origin?: any[] | undefined;
452
461
  } | undefined): void;
453
462
  get containerTopLeft(): number[];
454
463
  /**
@@ -497,4 +506,4 @@ export class PDFViewer {
497
506
  }
498
507
  import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
499
508
  import { SimpleLinkService } from "./pdf_link_service.js";
500
- import { PromiseCapability } from "../src/pdf";
509
+ import { GenericL10n } from "./genericl10n";
@@ -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
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "pdfjs-serverless",
3
3
  "type": "module",
4
- "version": "0.4.2",
5
- "packageManager": "pnpm@8.14.3",
4
+ "version": "0.5.0",
5
+ "packageManager": "pnpm@9.3.0",
6
6
  "description": "Serverless build of PDF.js for Deno, workers, and other nodeless environments",
7
- "author": "Johann Schopplich <pkg@johannschopplich.com>",
7
+ "author": "Johann Schopplich <hello@johannschopplich.com>",
8
8
  "license": "MIT",
9
9
  "homepage": "https://github.com/johannschopplich/pdfjs-serverless#readme",
10
10
  "repository": {
@@ -42,26 +42,26 @@
42
42
  "release": "bumpp --commit --push --tag"
43
43
  },
44
44
  "devDependencies": {
45
- "@antfu/eslint-config": "^2.6.3",
45
+ "@antfu/eslint-config": "^2.21.1",
46
46
  "@rollup/plugin-alias": "^5.1.0",
47
- "@rollup/plugin-commonjs": "^25.0.7",
47
+ "@rollup/plugin-commonjs": "^26.0.1",
48
48
  "@rollup/plugin-inject": "^5.0.5",
49
49
  "@rollup/plugin-node-resolve": "^15.2.3",
50
- "@rollup/plugin-replace": "^5.0.5",
50
+ "@rollup/plugin-replace": "^5.0.7",
51
51
  "@rollup/plugin-terser": "^0.4.4",
52
52
  "@rollup/plugin-typescript": "^11.1.6",
53
- "@types/node": "^20.11.7",
54
- "bumpp": "^9.3.0",
55
- "eslint": "^8.56.0",
56
- "pdfjs-dist": "^4.0.379",
57
- "rollup": "^4.9.6",
58
- "tslib": "^2.6.2",
59
- "typescript": "5.2.2",
53
+ "@types/node": "^20.14.2",
54
+ "bumpp": "^9.4.1",
55
+ "eslint": "^9.4.0",
56
+ "pdfjs-dist": "^4.3.136",
57
+ "rollup": "^4.18.0",
58
+ "tslib": "^2.6.3",
59
+ "typescript": "^5.4.5",
60
60
  "unenv": "^1.9.0"
61
61
  },
62
62
  "pnpm": {
63
63
  "patchedDependencies": {
64
- "pdfjs-dist@4.0.379": "patches/pdfjs-dist@4.0.379.patch"
64
+ "pdfjs-dist@4.3.136": "patches/pdfjs-dist@4.3.136.patch"
65
65
  }
66
66
  }
67
67
  }
@@ -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
- }