@chialab/pdfjs-lib 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
@@ -52641,18 +52641,29 @@ var _OperatorList = class _OperatorList {
52641
52641
  switch (fnArray[i]) {
52642
52642
  case OPS.paintInlineImageXObject:
52643
52643
  case OPS.paintInlineImageXObjectGroup:
52644
- case OPS.paintImageMaskXObject:
52645
- const arg = argsArray[i][0];
52646
- if (arg.data?.buffer instanceof ArrayBuffer) {
52647
- transfers.push(arg.data.buffer);
52644
+ case OPS.paintImageMaskXObject: {
52645
+ const { bitmap, data } = argsArray[i][0];
52646
+ if (bitmap || data?.buffer) {
52647
+ transfers.push(bitmap || data.buffer);
52648
52648
  }
52649
52649
  break;
52650
- case OPS.constructPath:
52650
+ }
52651
+ case OPS.constructPath: {
52651
52652
  const [, [data], minMax] = argsArray[i];
52652
52653
  if (data) {
52653
52654
  transfers.push(data.buffer, minMax.buffer);
52654
52655
  }
52655
52656
  break;
52657
+ }
52658
+ case OPS.paintFormXObjectBegin:
52659
+ const [matrix, bbox] = argsArray[i];
52660
+ if (matrix) {
52661
+ transfers.push(matrix.buffer);
52662
+ }
52663
+ if (bbox) {
52664
+ transfers.push(bbox.buffer);
52665
+ }
52666
+ break;
52656
52667
  }
52657
52668
  }
52658
52669
  return transfers;
@@ -54272,7 +54283,9 @@ var PartialEvaluator = class _PartialEvaluator {
54272
54283
  }
54273
54284
  operatorList.addOp(OPS.beginGroup, [groupOptions]);
54274
54285
  }
54275
- const args = group ? [matrix, null] : [matrix, bbox];
54286
+ const f32matrix = matrix && new Float32Array(matrix);
54287
+ const f32bbox = !group && bbox && new Float32Array(bbox) || null;
54288
+ const args = [f32matrix, f32bbox];
54276
54289
  operatorList.addOp(OPS.paintFormXObjectBegin, args);
54277
54290
  await this.getOperatorList({
54278
54291
  stream: xobj,
@@ -1,3 +1,4 @@
1
+ import type { SvgRoot } from './SvgCanvasContext';
1
2
  type Rect = [number, number, number, number];
2
3
  type Color = [number, number, number];
3
4
  type Dir = 'ltr' | 'rtl';
@@ -106,7 +107,7 @@ export interface StrikeOutAnnotationData extends TextAnnotationData {
106
107
  }
107
108
  export interface StampAnnotationData extends TextAnnotationData {
108
109
  subtype: 'Stamp';
109
- graphics: Uint8Array;
110
+ graphics: SvgRoot;
110
111
  }
111
112
  export interface CaretAnnotationData extends TextAnnotationData {
112
113
  subtype: 'Caret';
@@ -102,6 +102,7 @@ export declare class SvgCanvasContext {
102
102
  getNode(): SvgRoot;
103
103
  resize(width: number, height: number): void;
104
104
  save(): void;
105
+ clearRect(x: number, y: number, width: number, height: number): void;
105
106
  restore(): void;
106
107
  beginPath(): void;
107
108
  closePath(): void;
@@ -8,6 +8,14 @@ export declare function canvasToData(canvas: HTMLCanvasElement | Canvas): Promis
8
8
  /**
9
9
  * Convert a buffer to a data url.
10
10
  * @param data The buffer to convert.
11
+ * @param type The type of the data url. Defaults to 'image/png'.
11
12
  * @returns A promise that resolves to the data url.
12
13
  */
13
- export declare function toDataUrl(data: Uint8Array): Promise<string>;
14
+ export declare function toDataUrl(data: Uint8Array, type?: string): Promise<string>;
15
+ /**
16
+ * Ensure the object can be serialized and unserialized as JSON.
17
+ * Internally it converts typed arrays to plain arrays.
18
+ * @param object The object to serialize.
19
+ * @returns The serialized object.
20
+ */
21
+ export declare function makeSerializable<T>(object: T): T;