@chialab/pdfjs-lib 1.0.0-alpha.24 → 1.0.0-alpha.26

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 (28) hide show
  1. package/dist/browser/{chunk-W3YEFTNG.js → chunk-YWSFNHP3.js} +23 -5
  2. package/dist/browser/index.js +6775 -5170
  3. package/dist/browser/worker.js +460 -180
  4. package/dist/lib/Path2D.d.ts +8 -48
  5. package/dist/node/{NodeUtils-EDBNTTIR.js → NodeUtils-ZGLDDB6J.js} +2 -2
  6. package/dist/node/{chunk-ZKUTXCS2.js → chunk-AC5JE2E3.js} +1 -1
  7. package/dist/node/{chunk-K6VD27AD.js → chunk-GVC6TP3T.js} +4 -1
  8. package/dist/node/{chunk-XMKSLA4K.js → chunk-YDSKBMQ3.js} +23 -5
  9. package/dist/node/index.js +6776 -5174
  10. package/dist/node/worker.js +461 -181
  11. package/dist/pdf.js/src/display/annotation_layer.d.ts +9 -0
  12. package/dist/pdf.js/src/display/api.d.ts +43 -6
  13. package/dist/pdf.js/src/display/canvas.d.ts +82 -80
  14. package/dist/pdf.js/src/display/canvas_dependency_tracker.d.ts +144 -0
  15. package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +1 -1
  16. package/dist/pdf.js/src/display/editor/color_picker.d.ts +19 -0
  17. package/dist/pdf.js/src/display/editor/comment.d.ts +32 -0
  18. package/dist/pdf.js/src/display/editor/draw.d.ts +1 -1
  19. package/dist/pdf.js/src/display/editor/editor.d.ts +27 -2
  20. package/dist/pdf.js/src/display/editor/freetext.d.ts +7 -0
  21. package/dist/pdf.js/src/display/editor/highlight.d.ts +1 -0
  22. package/dist/pdf.js/src/display/editor/ink.d.ts +4 -0
  23. package/dist/pdf.js/src/display/editor/toolbar.d.ts +2 -1
  24. package/dist/pdf.js/src/display/editor/tools.d.ts +11 -3
  25. package/dist/pdf.js/src/pdf.d.ts +2 -1
  26. package/dist/pdf.js/src/shared/util.d.ts +6 -2
  27. package/dist/pdf.js/web/interfaces.d.ts +7 -0
  28. package/package.json +1 -1
@@ -1,53 +1,13 @@
1
1
  import { Path2D } from './Canvas';
2
- export interface MoveToCommand {
3
- type: 'moveTo';
4
- args: {
5
- x: number;
6
- y: number;
7
- };
2
+ export declare enum CommandType {
3
+ MoveTo = 0,
4
+ LineTo = 1,
5
+ Arc = 2,
6
+ Bezier = 3,
7
+ Quad = 4,
8
+ Close = 5
8
9
  }
9
- export interface LineToCommand {
10
- type: 'lineTo';
11
- args: {
12
- x: number;
13
- y: number;
14
- };
15
- }
16
- export interface ArcCommand {
17
- type: 'arc';
18
- args: {
19
- x: number;
20
- y: number;
21
- radius: number;
22
- startAngle: number;
23
- endAngle: number;
24
- anticlockwise: boolean;
25
- };
26
- }
27
- export interface BezierCurveToCommand {
28
- type: 'bezierCurveTo';
29
- args: {
30
- cp1x: number;
31
- cp1y: number;
32
- cp2x: number;
33
- cp2y: number;
34
- x: number;
35
- y: number;
36
- };
37
- }
38
- export interface QuadraticCurveToCommand {
39
- type: 'quadraticCurveTo';
40
- args: {
41
- qx1: number;
42
- qy1: number;
43
- qx: number;
44
- qy: number;
45
- };
46
- }
47
- export interface ClosePathCommand {
48
- type: 'closePath';
49
- }
50
- export type PathCommand = MoveToCommand | LineToCommand | ArcCommand | BezierCurveToCommand | QuadraticCurveToCommand | ClosePathCommand;
10
+ export type PathCommand = [CommandType.MoveTo, number, number] | [CommandType.LineTo, number, number] | [CommandType.Arc, number, number, number, number, number, boolean] | [CommandType.Bezier, number, number, number, number, number, number] | [CommandType.Quad, number, number, number, number] | [CommandType.Close];
51
11
  export declare function parseCommands(svgPath: string): PathCommand[];
52
12
  export declare function commandToSvgPath(command: PathCommand): string;
53
13
  export declare function transformPath(commands: PathCommand[], transform: DOMMatrix): PathCommand[];
@@ -6,8 +6,8 @@ import {
6
6
  NodeWasmFactory,
7
7
  fetchData2 as fetchData,
8
8
  filtersRegistry
9
- } from "./chunk-K6VD27AD.js";
10
- import "./chunk-XMKSLA4K.js";
9
+ } from "./chunk-GVC6TP3T.js";
10
+ import "./chunk-YDSKBMQ3.js";
11
11
  import "./chunk-7MW5RQZ5.js";
12
12
  export {
13
13
  NodeCMapReaderFactory,
@@ -8,7 +8,7 @@ import {
8
8
  UnknownErrorException,
9
9
  assert,
10
10
  unreachable
11
- } from "./chunk-XMKSLA4K.js";
11
+ } from "./chunk-YDSKBMQ3.js";
12
12
  import {
13
13
  __privateAdd,
14
14
  __privateGet,
@@ -7,7 +7,7 @@ import {
7
7
  unreachable,
8
8
  updateUrlHash,
9
9
  warn
10
- } from "./chunk-XMKSLA4K.js";
10
+ } from "./chunk-YDSKBMQ3.js";
11
11
  import {
12
12
  __privateAdd,
13
13
  __privateGet,
@@ -408,6 +408,9 @@ var PDFDateString = class {
408
408
  * @returns {Date|null}
409
409
  */
410
410
  static toDateObject(input) {
411
+ if (input instanceof Date) {
412
+ return input;
413
+ }
411
414
  if (!input || typeof input !== "string") {
412
415
  return null;
413
416
  }
@@ -34,7 +34,9 @@ var AnnotationEditorType = {
34
34
  HIGHLIGHT: 9,
35
35
  STAMP: 13,
36
36
  INK: 15,
37
- SIGNATURE: 101
37
+ POPUP: 16,
38
+ SIGNATURE: 101,
39
+ COMMENT: 102
38
40
  };
39
41
  var AnnotationEditorParamsType = {
40
42
  RESIZE: 1,
@@ -46,10 +48,9 @@ var AnnotationEditorParamsType = {
46
48
  INK_THICKNESS: 22,
47
49
  INK_OPACITY: 23,
48
50
  HIGHLIGHT_COLOR: 31,
49
- HIGHLIGHT_DEFAULT_COLOR: 32,
50
- HIGHLIGHT_THICKNESS: 33,
51
- HIGHLIGHT_FREE: 34,
52
- HIGHLIGHT_SHOW_ALL: 35,
51
+ HIGHLIGHT_THICKNESS: 32,
52
+ HIGHLIGHT_FREE: 33,
53
+ HIGHLIGHT_SHOW_ALL: 34,
53
54
  DRAW_STEP: 41
54
55
  };
55
56
  var PermissionFlag = {
@@ -532,6 +533,9 @@ var Util = class {
532
533
  static makeHexColor(r, g, b) {
533
534
  return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
534
535
  }
536
+ static domMatrixToTransform(dm) {
537
+ return [dm.a, dm.b, dm.c, dm.d, dm.e, dm.f];
538
+ }
535
539
  // Apply a scaling matrix to some min/max values.
536
540
  // If a scaling factor is negative then min and max must be
537
541
  // swapped.
@@ -590,6 +594,17 @@ var Util = class {
590
594
  m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
591
595
  ];
592
596
  }
597
+ // Multiplies m (an array-based transform) by md (a DOMMatrix transform).
598
+ static multiplyByDOMMatrix(m, md) {
599
+ return [
600
+ m[0] * md.a + m[2] * md.b,
601
+ m[1] * md.a + m[3] * md.b,
602
+ m[0] * md.c + m[2] * md.d,
603
+ m[1] * md.c + m[3] * md.d,
604
+ m[0] * md.e + m[2] * md.f + m[4],
605
+ m[1] * md.e + m[3] * md.f + m[5]
606
+ ];
607
+ }
593
608
  // For 2d affine transforms
594
609
  static applyTransform(p, m, pos = 0) {
595
610
  const p0 = p[pos];
@@ -1007,6 +1022,9 @@ function isArrayEqual(arr1, arr2) {
1007
1022
  return true;
1008
1023
  }
1009
1024
  function getModificationDate(date = /* @__PURE__ */ new Date()) {
1025
+ if (!(date instanceof Date)) {
1026
+ date = new Date(date);
1027
+ }
1010
1028
  const buffer = [
1011
1029
  date.getUTCFullYear().toString(),
1012
1030
  (date.getUTCMonth() + 1).toString().padStart(2, "0"),