@chialab/pdfjs-lib 1.0.0-alpha.1 → 1.0.0-alpha.10
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-DYHYQ33L.js → chunk-AK2AE3GS.js} +177 -43
- package/dist/browser/index.js +907 -998
- package/dist/browser/worker.js +5827 -5389
- package/dist/lib/AnnotationData.d.ts +2 -1
- package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
- package/dist/lib/SvgCanvasContext.d.ts +2 -1
- package/dist/lib/TextLayer.d.ts +0 -6
- package/dist/lib/utils.d.ts +9 -1
- package/dist/node/{chunk-KTTVPO2G.js → chunk-WL32POZ2.js} +177 -43
- package/dist/node/index.js +914 -992
- package/dist/node/worker.js +5827 -5389
- package/dist/pdf.js/src/display/api.d.ts +30 -5
- package/dist/pdf.js/src/display/canvas.d.ts +19 -27
- package/dist/pdf.js/src/display/display_utils.d.ts +10 -0
- package/dist/pdf.js/src/display/editor/editor.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/highlight.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/ink.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/signature.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/stamp.d.ts +1 -2
- package/dist/pdf.js/src/display/editor/tools.d.ts +0 -6
- package/dist/pdf.js/src/display/pattern_helper.d.ts +4 -2
- package/dist/pdf.js/src/display/touch_manager.d.ts +5 -1
- package/dist/pdf.js/src/pdf.d.ts +3 -1
- package/dist/pdf.js/src/shared/util.d.ts +111 -95
- package/package.json +7 -5
- package/dist/browser/LiberationMono-Regular-UUOCTXY2.js +0 -9
- package/dist/browser/LiberationSerif-Regular-ASQ2LI3D.js +0 -9
- package/dist/node/LiberationMono-Regular-KMFXXO3B.js +0 -9
- package/dist/node/LiberationSerif-Regular-WAOWR76G.js +0 -9
|
@@ -324,7 +324,14 @@ var OPS = {
|
|
|
324
324
|
paintSolidColorImageMask: 90,
|
|
325
325
|
constructPath: 91,
|
|
326
326
|
setStrokeTransparent: 92,
|
|
327
|
-
setFillTransparent: 93
|
|
327
|
+
setFillTransparent: 93,
|
|
328
|
+
rawFillPath: 94
|
|
329
|
+
};
|
|
330
|
+
var DrawOPS = {
|
|
331
|
+
moveTo: 0,
|
|
332
|
+
lineTo: 1,
|
|
333
|
+
curveTo: 2,
|
|
334
|
+
closePath: 3
|
|
328
335
|
};
|
|
329
336
|
var PasswordResponses = {
|
|
330
337
|
NEED_PASSWORD: 1,
|
|
@@ -634,29 +641,72 @@ var Util = class {
|
|
|
634
641
|
}
|
|
635
642
|
// For 2d affine transforms
|
|
636
643
|
static applyTransform(p, m) {
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
|
|
644
|
+
const p0 = p[0];
|
|
645
|
+
const p1 = p[1];
|
|
646
|
+
p[0] = p0 * m[0] + p1 * m[2] + m[4];
|
|
647
|
+
p[1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
648
|
+
}
|
|
649
|
+
// For 2d affine transforms
|
|
650
|
+
static applyTransformToBezier(p, transform) {
|
|
651
|
+
const m0 = transform[0];
|
|
652
|
+
const m1 = transform[1];
|
|
653
|
+
const m2 = transform[2];
|
|
654
|
+
const m3 = transform[3];
|
|
655
|
+
const m4 = transform[4];
|
|
656
|
+
const m5 = transform[5];
|
|
657
|
+
for (let i = 0; i < 6; i += 2) {
|
|
658
|
+
const pI = p[i];
|
|
659
|
+
const pI1 = p[i + 1];
|
|
660
|
+
p[i] = pI * m0 + pI1 * m2 + m4;
|
|
661
|
+
p[i + 1] = pI * m1 + pI1 * m3 + m5;
|
|
662
|
+
}
|
|
640
663
|
}
|
|
641
664
|
static applyInverseTransform(p, m) {
|
|
665
|
+
const p0 = p[0];
|
|
666
|
+
const p1 = p[1];
|
|
642
667
|
const d = m[0] * m[3] - m[1] * m[2];
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
return [xt, yt];
|
|
668
|
+
p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
|
|
669
|
+
p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
|
|
646
670
|
}
|
|
647
671
|
// Applies the transform to the rectangle and finds the minimum axially
|
|
648
672
|
// aligned bounding box.
|
|
649
|
-
static
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
const
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
];
|
|
673
|
+
static axialAlignedBoundingBox(rect, transform, output) {
|
|
674
|
+
const m0 = transform[0];
|
|
675
|
+
const m1 = transform[1];
|
|
676
|
+
const m2 = transform[2];
|
|
677
|
+
const m3 = transform[3];
|
|
678
|
+
const m4 = transform[4];
|
|
679
|
+
const m5 = transform[5];
|
|
680
|
+
const r0 = rect[0];
|
|
681
|
+
const r1 = rect[1];
|
|
682
|
+
const r2 = rect[2];
|
|
683
|
+
const r3 = rect[3];
|
|
684
|
+
let a0 = m0 * r0 + m4;
|
|
685
|
+
let a2 = a0;
|
|
686
|
+
let a1 = m0 * r2 + m4;
|
|
687
|
+
let a3 = a1;
|
|
688
|
+
let b0 = m3 * r1 + m5;
|
|
689
|
+
let b2 = b0;
|
|
690
|
+
let b1 = m3 * r3 + m5;
|
|
691
|
+
let b3 = b1;
|
|
692
|
+
if (m1 !== 0 || m2 !== 0) {
|
|
693
|
+
const m1r0 = m1 * r0;
|
|
694
|
+
const m1r2 = m1 * r2;
|
|
695
|
+
const m2r1 = m2 * r1;
|
|
696
|
+
const m2r3 = m2 * r3;
|
|
697
|
+
a0 += m2r1;
|
|
698
|
+
a3 += m2r1;
|
|
699
|
+
a1 += m2r3;
|
|
700
|
+
a2 += m2r3;
|
|
701
|
+
b0 += m1r0;
|
|
702
|
+
b3 += m1r0;
|
|
703
|
+
b1 += m1r2;
|
|
704
|
+
b2 += m1r2;
|
|
705
|
+
}
|
|
706
|
+
output[0] = Math.min(output[0], a0, a1, a2, a3);
|
|
707
|
+
output[1] = Math.min(output[1], b0, b1, b2, b3);
|
|
708
|
+
output[2] = Math.max(output[2], a0, a1, a2, a3);
|
|
709
|
+
output[3] = Math.max(output[3], b0, b1, b2, b3);
|
|
660
710
|
}
|
|
661
711
|
static inverseTransform(m) {
|
|
662
712
|
const d = m[0] * m[3] - m[1] * m[2];
|
|
@@ -672,17 +722,18 @@ var Util = class {
|
|
|
672
722
|
// This calculation uses Singular Value Decomposition.
|
|
673
723
|
// The SVD can be represented with formula A = USV. We are interested in the
|
|
674
724
|
// matrix S here because it represents the scale values.
|
|
675
|
-
static singularValueDecompose2dScale(
|
|
676
|
-
const
|
|
677
|
-
const
|
|
678
|
-
const
|
|
679
|
-
const
|
|
680
|
-
const
|
|
681
|
-
const
|
|
682
|
-
const
|
|
683
|
-
const
|
|
684
|
-
const
|
|
685
|
-
|
|
725
|
+
static singularValueDecompose2dScale(matrix, output) {
|
|
726
|
+
const m0 = matrix[0];
|
|
727
|
+
const m1 = matrix[1];
|
|
728
|
+
const m2 = matrix[2];
|
|
729
|
+
const m3 = matrix[3];
|
|
730
|
+
const a = m0 ** 2 + m1 ** 2;
|
|
731
|
+
const b = m0 * m2 + m1 * m3;
|
|
732
|
+
const c = m2 ** 2 + m3 ** 2;
|
|
733
|
+
const first = (a + c) / 2;
|
|
734
|
+
const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
|
|
735
|
+
output[0] = Math.sqrt(first + second || 1);
|
|
736
|
+
output[1] = Math.sqrt(first - second || 1);
|
|
686
737
|
}
|
|
687
738
|
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
|
|
688
739
|
// For coordinate systems whose origin lies in the bottom-left, this
|
|
@@ -728,24 +779,26 @@ var Util = class {
|
|
|
728
779
|
}
|
|
729
780
|
return [xLow, yLow, xHigh, yHigh];
|
|
730
781
|
}
|
|
782
|
+
static pointBoundingBox(x, y, minMax) {
|
|
783
|
+
minMax[0] = Math.min(minMax[0], x);
|
|
784
|
+
minMax[1] = Math.min(minMax[1], y);
|
|
785
|
+
minMax[2] = Math.max(minMax[2], x);
|
|
786
|
+
minMax[3] = Math.max(minMax[3], y);
|
|
787
|
+
}
|
|
788
|
+
static rectBoundingBox(x0, y0, x1, y1, minMax) {
|
|
789
|
+
minMax[0] = Math.min(minMax[0], x0, x1);
|
|
790
|
+
minMax[1] = Math.min(minMax[1], y0, y1);
|
|
791
|
+
minMax[2] = Math.max(minMax[2], x0, x1);
|
|
792
|
+
minMax[3] = Math.max(minMax[3], y0, y1);
|
|
793
|
+
}
|
|
731
794
|
// From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852
|
|
732
795
|
static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
minMax[3] = Math.max(minMax[3], y0, y3);
|
|
738
|
-
} else {
|
|
739
|
-
minMax = [
|
|
740
|
-
Math.min(x0, x3),
|
|
741
|
-
Math.min(y0, y3),
|
|
742
|
-
Math.max(x0, x3),
|
|
743
|
-
Math.max(y0, y3)
|
|
744
|
-
];
|
|
745
|
-
}
|
|
796
|
+
minMax[0] = Math.min(minMax[0], x0, x3);
|
|
797
|
+
minMax[1] = Math.min(minMax[1], y0, y3);
|
|
798
|
+
minMax[2] = Math.max(minMax[2], x0, x3);
|
|
799
|
+
minMax[3] = Math.max(minMax[3], y0, y3);
|
|
746
800
|
__privateMethod(this, _Util_static, getExtremum_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
|
|
747
801
|
__privateMethod(this, _Util_static, getExtremum_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
|
|
748
|
-
return minMax;
|
|
749
802
|
}
|
|
750
803
|
};
|
|
751
804
|
_Util_static = new WeakSet();
|
|
@@ -1035,6 +1088,56 @@ function getUuid() {
|
|
|
1035
1088
|
return bytesToString(buf);
|
|
1036
1089
|
}
|
|
1037
1090
|
var AnnotationPrefix = "pdfjs_internal_id_";
|
|
1091
|
+
function _isValidExplicitDest(validRef, validName, dest) {
|
|
1092
|
+
if (!Array.isArray(dest) || dest.length < 2) {
|
|
1093
|
+
return false;
|
|
1094
|
+
}
|
|
1095
|
+
const [page, zoom, ...args] = dest;
|
|
1096
|
+
if (!validRef(page) && !Number.isInteger(page)) {
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
if (!validName(zoom)) {
|
|
1100
|
+
return false;
|
|
1101
|
+
}
|
|
1102
|
+
const argsLen = args.length;
|
|
1103
|
+
let allowNull = true;
|
|
1104
|
+
switch (zoom.name) {
|
|
1105
|
+
case "XYZ":
|
|
1106
|
+
if (argsLen < 2 || argsLen > 3) {
|
|
1107
|
+
return false;
|
|
1108
|
+
}
|
|
1109
|
+
break;
|
|
1110
|
+
case "Fit":
|
|
1111
|
+
case "FitB":
|
|
1112
|
+
return argsLen === 0;
|
|
1113
|
+
case "FitH":
|
|
1114
|
+
case "FitBH":
|
|
1115
|
+
case "FitV":
|
|
1116
|
+
case "FitBV":
|
|
1117
|
+
if (argsLen > 1) {
|
|
1118
|
+
return false;
|
|
1119
|
+
}
|
|
1120
|
+
break;
|
|
1121
|
+
case "FitR":
|
|
1122
|
+
if (argsLen !== 4) {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
allowNull = false;
|
|
1126
|
+
break;
|
|
1127
|
+
default:
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
for (const arg of args) {
|
|
1131
|
+
if (typeof arg === "number" || allowNull && arg === null) {
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
return false;
|
|
1135
|
+
}
|
|
1136
|
+
return true;
|
|
1137
|
+
}
|
|
1138
|
+
function MathClamp(v, min, max) {
|
|
1139
|
+
return Math.min(Math.max(v, min), max);
|
|
1140
|
+
}
|
|
1038
1141
|
function toHexUtil(arr) {
|
|
1039
1142
|
if (Uint8Array.prototype.toHex) {
|
|
1040
1143
|
return arr.toHex();
|
|
@@ -1060,6 +1163,34 @@ if (false) {
|
|
|
1060
1163
|
});
|
|
1061
1164
|
};
|
|
1062
1165
|
}
|
|
1166
|
+
if (typeof Math.sumPrecise !== "function") {
|
|
1167
|
+
Math.sumPrecise = function(numbers) {
|
|
1168
|
+
return numbers.reduce((a, b) => a + b, 0);
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
if (false) {
|
|
1172
|
+
AbortSignal.any = function(iterable) {
|
|
1173
|
+
const ac = new AbortController();
|
|
1174
|
+
const { signal } = ac;
|
|
1175
|
+
for (const s of iterable) {
|
|
1176
|
+
if (s.aborted) {
|
|
1177
|
+
ac.abort(s.reason);
|
|
1178
|
+
return signal;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
for (const s of iterable) {
|
|
1182
|
+
s.addEventListener(
|
|
1183
|
+
"abort",
|
|
1184
|
+
() => {
|
|
1185
|
+
ac.abort(s.reason);
|
|
1186
|
+
},
|
|
1187
|
+
{ signal }
|
|
1188
|
+
// Automatically remove the listener.
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
return signal;
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1063
1194
|
|
|
1064
1195
|
// src/pdf.js/src/shared/message_handler.js
|
|
1065
1196
|
var CallbackKind = {
|
|
@@ -1732,6 +1863,7 @@ export {
|
|
|
1732
1863
|
PageActionEventType,
|
|
1733
1864
|
VerbosityLevel,
|
|
1734
1865
|
OPS,
|
|
1866
|
+
DrawOPS,
|
|
1735
1867
|
PasswordResponses,
|
|
1736
1868
|
setVerbosityLevel,
|
|
1737
1869
|
getVerbosityLevel,
|
|
@@ -1763,6 +1895,8 @@ export {
|
|
|
1763
1895
|
normalizeUnicode,
|
|
1764
1896
|
getUuid,
|
|
1765
1897
|
AnnotationPrefix,
|
|
1898
|
+
_isValidExplicitDest,
|
|
1899
|
+
MathClamp,
|
|
1766
1900
|
toHexUtil,
|
|
1767
1901
|
toBase64Util,
|
|
1768
1902
|
fromBase64Util,
|