@chialab/pdfjs-lib 1.0.0-alpha.6 → 1.0.0-alpha.8
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.
- package/dist/browser/{chunk-KKGFKVEF.js → chunk-LJIJQE3F.js} +83 -24
- package/dist/browser/index.js +96 -214
- package/dist/browser/worker.js +3412 -3258
- package/dist/lib/SvgCanvasContext.d.ts +1 -1
- package/dist/node/{chunk-PWUBNK7D.js → chunk-XZBSEIET.js} +83 -24
- package/dist/node/index.js +96 -214
- package/dist/node/worker.js +3412 -3258
- package/dist/pdf.js/src/display/canvas.d.ts +1 -1
- package/dist/pdf.js/src/shared/util.d.ts +6 -3
- package/package.json +1 -1
|
@@ -113,7 +113,7 @@ export declare class SvgCanvasContext {
|
|
|
113
113
|
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
114
114
|
rect(x: number, y: number, width: number, height: number): void;
|
|
115
115
|
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: boolean): void;
|
|
116
|
-
stroke(): void;
|
|
116
|
+
stroke(path?: Path2D): void;
|
|
117
117
|
transform(...values: number[]): void;
|
|
118
118
|
translate(x: number, y: number): void;
|
|
119
119
|
scale(x: number, y: number): void;
|
|
@@ -324,7 +324,8 @@ var OPS = {
|
|
|
324
324
|
paintSolidColorImageMask: 90,
|
|
325
325
|
constructPath: 91,
|
|
326
326
|
setStrokeTransparent: 92,
|
|
327
|
-
setFillTransparent: 93
|
|
327
|
+
setFillTransparent: 93,
|
|
328
|
+
rawFillPath: 94
|
|
328
329
|
};
|
|
329
330
|
var DrawOPS = {
|
|
330
331
|
moveTo: 0,
|
|
@@ -576,10 +577,57 @@ var hexNumbers = Array.from(
|
|
|
576
577
|
(n) => n.toString(16).padStart(2, "0")
|
|
577
578
|
);
|
|
578
579
|
var _Util_static, getExtremumOnCurve_fn, getExtremum_fn;
|
|
579
|
-
var
|
|
580
|
+
var _Util = class _Util {
|
|
580
581
|
static makeHexColor(r, g, b) {
|
|
581
582
|
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
|
|
582
583
|
}
|
|
584
|
+
// Apply a scaling matrix to some min/max values.
|
|
585
|
+
// If a scaling factor is negative then min and max must be
|
|
586
|
+
// swapped.
|
|
587
|
+
static scaleMinMax(transform, minMax) {
|
|
588
|
+
let temp;
|
|
589
|
+
if (transform[0]) {
|
|
590
|
+
if (transform[0] < 0) {
|
|
591
|
+
temp = minMax[0];
|
|
592
|
+
minMax[0] = minMax[2];
|
|
593
|
+
minMax[2] = temp;
|
|
594
|
+
}
|
|
595
|
+
minMax[0] *= transform[0];
|
|
596
|
+
minMax[2] *= transform[0];
|
|
597
|
+
if (transform[3] < 0) {
|
|
598
|
+
temp = minMax[1];
|
|
599
|
+
minMax[1] = minMax[3];
|
|
600
|
+
minMax[3] = temp;
|
|
601
|
+
}
|
|
602
|
+
minMax[1] *= transform[3];
|
|
603
|
+
minMax[3] *= transform[3];
|
|
604
|
+
} else {
|
|
605
|
+
temp = minMax[0];
|
|
606
|
+
minMax[0] = minMax[1];
|
|
607
|
+
minMax[1] = temp;
|
|
608
|
+
temp = minMax[2];
|
|
609
|
+
minMax[2] = minMax[3];
|
|
610
|
+
minMax[3] = temp;
|
|
611
|
+
if (transform[1] < 0) {
|
|
612
|
+
temp = minMax[1];
|
|
613
|
+
minMax[1] = minMax[3];
|
|
614
|
+
minMax[3] = temp;
|
|
615
|
+
}
|
|
616
|
+
minMax[1] *= transform[1];
|
|
617
|
+
minMax[3] *= transform[1];
|
|
618
|
+
if (transform[2] < 0) {
|
|
619
|
+
temp = minMax[0];
|
|
620
|
+
minMax[0] = minMax[2];
|
|
621
|
+
minMax[2] = temp;
|
|
622
|
+
}
|
|
623
|
+
minMax[0] *= transform[2];
|
|
624
|
+
minMax[2] *= transform[2];
|
|
625
|
+
}
|
|
626
|
+
minMax[0] += transform[4];
|
|
627
|
+
minMax[1] += transform[5];
|
|
628
|
+
minMax[2] += transform[4];
|
|
629
|
+
minMax[3] += transform[5];
|
|
630
|
+
}
|
|
583
631
|
// Concatenates two transformation matrices together and returns the result.
|
|
584
632
|
static transform(m1, m2) {
|
|
585
633
|
return [
|
|
@@ -593,23 +641,36 @@ var Util = class {
|
|
|
593
641
|
}
|
|
594
642
|
// For 2d affine transforms
|
|
595
643
|
static applyTransform(p, m) {
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
644
|
+
const [p0, p1] = p;
|
|
645
|
+
p[0] = p0 * m[0] + p1 * m[2] + m[4];
|
|
646
|
+
p[1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
647
|
+
}
|
|
648
|
+
// For 2d affine transforms
|
|
649
|
+
static applyTransformToBezier(p, [m0, m1, m2, m3, m4, m5]) {
|
|
650
|
+
for (let i = 0; i < 6; i += 2) {
|
|
651
|
+
const pI = p[i];
|
|
652
|
+
const pI1 = p[i + 1];
|
|
653
|
+
p[i] = pI * m0 + pI1 * m2 + m4;
|
|
654
|
+
p[i + 1] = pI * m1 + pI1 * m3 + m5;
|
|
655
|
+
}
|
|
599
656
|
}
|
|
600
657
|
static applyInverseTransform(p, m) {
|
|
658
|
+
const [p0, p1] = p;
|
|
601
659
|
const d = m[0] * m[3] - m[1] * m[2];
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return [xt, yt];
|
|
660
|
+
p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
|
|
661
|
+
p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
|
|
605
662
|
}
|
|
606
663
|
// Applies the transform to the rectangle and finds the minimum axially
|
|
607
664
|
// aligned bounding box.
|
|
608
665
|
static getAxialAlignedBoundingBox(r, m) {
|
|
609
|
-
const p1 =
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
666
|
+
const p1 = [r[0], r[1]];
|
|
667
|
+
_Util.applyTransform(p1, m);
|
|
668
|
+
const p2 = [r[2], r[3]];
|
|
669
|
+
_Util.applyTransform(p2, m);
|
|
670
|
+
const p3 = [r[0], r[3]];
|
|
671
|
+
_Util.applyTransform(p3, m);
|
|
672
|
+
const p4 = [r[2], r[1]];
|
|
673
|
+
_Util.applyTransform(p4, m);
|
|
613
674
|
return [
|
|
614
675
|
Math.min(p1[0], p2[0], p3[0], p4[0]),
|
|
615
676
|
Math.min(p1[1], p2[1], p3[1], p4[1]),
|
|
@@ -631,17 +692,14 @@ var Util = class {
|
|
|
631
692
|
// This calculation uses Singular Value Decomposition.
|
|
632
693
|
// The SVD can be represented with formula A = USV. We are interested in the
|
|
633
694
|
// matrix S here because it represents the scale values.
|
|
634
|
-
static singularValueDecompose2dScale(
|
|
635
|
-
const
|
|
636
|
-
const
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const sx = first + second || 1;
|
|
643
|
-
const sy = first - second || 1;
|
|
644
|
-
return [Math.sqrt(sx), Math.sqrt(sy)];
|
|
695
|
+
static singularValueDecompose2dScale([m0, m1, m2, m3], output) {
|
|
696
|
+
const a = m0 ** 2 + m1 ** 2;
|
|
697
|
+
const b = m0 * m2 + m1 * m3;
|
|
698
|
+
const c = m2 ** 2 + m3 ** 2;
|
|
699
|
+
const first = (a + c) / 2;
|
|
700
|
+
const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
|
|
701
|
+
output[0] = Math.sqrt(first + second || 1);
|
|
702
|
+
output[1] = Math.sqrt(first - second || 1);
|
|
645
703
|
}
|
|
646
704
|
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
|
|
647
705
|
// For coordinate systems whose origin lies in the bottom-left, this
|
|
@@ -740,7 +798,8 @@ getExtremum_fn = function(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
|
|
|
740
798
|
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
|
|
741
799
|
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
|
|
742
800
|
};
|
|
743
|
-
__privateAdd(
|
|
801
|
+
__privateAdd(_Util, _Util_static);
|
|
802
|
+
var Util = _Util;
|
|
744
803
|
var PDFStringTranslateTable = [
|
|
745
804
|
0,
|
|
746
805
|
0,
|