@chialab/pdfjs-lib 1.0.0-alpha.10 → 1.0.0-alpha.12
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-AK2AE3GS.js → chunk-TKDBOXH4.js} +31 -39
- package/dist/browser/index.js +632 -489
- package/dist/browser/openjpeg-K2XBCFFN.js +9 -0
- package/dist/browser/qcms_bg-Q7BRLLZG.js +9 -0
- package/dist/browser/worker.js +1261 -1122
- package/dist/index.d.ts +1 -0
- package/dist/lib/WasmFactory.d.ts +5 -0
- package/dist/lib/utils.d.ts +6 -0
- package/dist/node/{chunk-WL32POZ2.js → chunk-MAMMG4XK.js} +31 -39
- package/dist/node/index.js +773 -491
- package/dist/node/openjpeg-B2WN24QZ.js +9 -0
- package/dist/node/qcms_bg-T4RSHPOQ.js +9 -0
- package/dist/node/worker.js +1261 -1122
- package/dist/pdf.js/src/display/annotation_storage.d.ts +1 -8
- package/dist/pdf.js/src/display/api.d.ts +10 -69
- package/dist/pdf.js/src/display/api_utils.d.ts +13 -0
- package/dist/pdf.js/src/display/canvas.d.ts +2 -2
- package/dist/pdf.js/src/display/display_utils.d.ts +2 -1
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +4 -4
- package/dist/pdf.js/src/display/editor/editor.d.ts +17 -3
- package/dist/pdf.js/src/display/editor/freetext.d.ts +2 -5
- package/dist/pdf.js/src/display/editor/tools.d.ts +2 -1
- package/dist/pdf.js/src/display/metadata.d.ts +1 -2
- package/dist/pdf.js/src/display/optional_content_config.d.ts +1 -1
- package/dist/pdf.js/src/display/pdf_objects.d.ts +40 -0
- package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
- package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
- package/dist/pdf.js/src/pdf.d.ts +3 -2
- package/dist/pdf.js/src/shared/util.d.ts +12 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { DocumentInitParameters } from './pdf.js/src/display/api';
|
|
|
4
4
|
export type { BaseCanvasFactory } from './pdf.js/src/display/canvas_factory';
|
|
5
5
|
export * from './lib/utils';
|
|
6
6
|
export * from './lib/Canvas';
|
|
7
|
+
export * from './lib/WasmFactory';
|
|
7
8
|
export * from './lib/StandardFontDataFactory';
|
|
8
9
|
export * from './lib/AnnotationData';
|
|
9
10
|
export * from './lib/SvgCanvasContext';
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -19,3 +19,9 @@ export declare function toDataUrl(data: Uint8Array, type?: string): Promise<stri
|
|
|
19
19
|
* @returns The serialized object.
|
|
20
20
|
*/
|
|
21
21
|
export declare function makeSerializable<T>(object: T): T;
|
|
22
|
+
/**
|
|
23
|
+
* Convert hash color to RGB array.
|
|
24
|
+
* @param color The color in hex format (e.g., '#ff0000' or '#f00').
|
|
25
|
+
* @returns An array of RGB values [r, g, b].
|
|
26
|
+
*/
|
|
27
|
+
export declare function colorToRgb(color: string): number[];
|
|
@@ -48,7 +48,6 @@ if (!("try" in Promise)) {
|
|
|
48
48
|
|
|
49
49
|
// src/pdf.js/src/shared/util.js
|
|
50
50
|
var isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
|
|
51
|
-
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
|
|
52
51
|
var FONT_IDENTITY_MATRIX = [1e-3, 0, 0, 1e-3, 0, 0];
|
|
53
52
|
var LINE_FACTOR = 1.35;
|
|
54
53
|
var LINE_DESCENT_FACTOR = 0.35;
|
|
@@ -397,6 +396,17 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
|
|
|
397
396
|
const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
|
|
398
397
|
return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;
|
|
399
398
|
}
|
|
399
|
+
function updateUrlHash(url, hash, allowRel = false) {
|
|
400
|
+
const res = URL.parse(url);
|
|
401
|
+
if (res) {
|
|
402
|
+
res.hash = hash;
|
|
403
|
+
return res.href;
|
|
404
|
+
}
|
|
405
|
+
if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
|
|
406
|
+
return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
|
|
407
|
+
}
|
|
408
|
+
return "";
|
|
409
|
+
}
|
|
400
410
|
function shadow(obj, prop, value, nonSerializable = false) {
|
|
401
411
|
if (false) {
|
|
402
412
|
assert(
|
|
@@ -503,13 +513,6 @@ function string32(value) {
|
|
|
503
513
|
function objectSize(obj) {
|
|
504
514
|
return Object.keys(obj).length;
|
|
505
515
|
}
|
|
506
|
-
function objectFromMap(map) {
|
|
507
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
508
|
-
for (const [key, value] of map) {
|
|
509
|
-
obj[key] = value;
|
|
510
|
-
}
|
|
511
|
-
return obj;
|
|
512
|
-
}
|
|
513
516
|
function isLittleEndian() {
|
|
514
517
|
const buffer8 = new Uint8Array(4);
|
|
515
518
|
buffer8[0] = 1;
|
|
@@ -546,22 +549,13 @@ var FeatureTest = class {
|
|
|
546
549
|
);
|
|
547
550
|
}
|
|
548
551
|
static get platform() {
|
|
549
|
-
|
|
550
|
-
const { platform, userAgent } = navigator;
|
|
551
|
-
return shadow(this, "platform", {
|
|
552
|
-
isAndroid: userAgent.includes("Android"),
|
|
553
|
-
isLinux: platform.includes("Linux"),
|
|
554
|
-
isMac: platform.includes("Mac"),
|
|
555
|
-
isWindows: platform.includes("Win"),
|
|
556
|
-
isFirefox: userAgent.includes("Firefox")
|
|
557
|
-
});
|
|
558
|
-
}
|
|
552
|
+
const { platform, userAgent } = navigator;
|
|
559
553
|
return shadow(this, "platform", {
|
|
560
|
-
isAndroid:
|
|
561
|
-
isLinux:
|
|
562
|
-
isMac:
|
|
563
|
-
isWindows:
|
|
564
|
-
isFirefox:
|
|
554
|
+
isAndroid: userAgent.includes("Android"),
|
|
555
|
+
isLinux: platform.includes("Linux"),
|
|
556
|
+
isMac: platform.includes("Mac"),
|
|
557
|
+
isWindows: platform.includes("Win"),
|
|
558
|
+
isFirefox: userAgent.includes("Firefox")
|
|
565
559
|
});
|
|
566
560
|
}
|
|
567
561
|
static get isCSSRoundSupported() {
|
|
@@ -640,14 +634,13 @@ var Util = class {
|
|
|
640
634
|
];
|
|
641
635
|
}
|
|
642
636
|
// For 2d affine transforms
|
|
643
|
-
static applyTransform(p, m) {
|
|
644
|
-
const p0 = p[
|
|
645
|
-
const p1 = p[1];
|
|
646
|
-
p[
|
|
647
|
-
p[1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
637
|
+
static applyTransform(p, m, pos = 0) {
|
|
638
|
+
const p0 = p[pos];
|
|
639
|
+
const p1 = p[pos + 1];
|
|
640
|
+
p[pos] = p0 * m[0] + p1 * m[2] + m[4];
|
|
641
|
+
p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
648
642
|
}
|
|
649
|
-
|
|
650
|
-
static applyTransformToBezier(p, transform) {
|
|
643
|
+
static applyTransformToBezier(p, transform, pos = 0) {
|
|
651
644
|
const m0 = transform[0];
|
|
652
645
|
const m1 = transform[1];
|
|
653
646
|
const m2 = transform[2];
|
|
@@ -655,10 +648,10 @@ var Util = class {
|
|
|
655
648
|
const m4 = transform[4];
|
|
656
649
|
const m5 = transform[5];
|
|
657
650
|
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;
|
|
651
|
+
const pI = p[pos + i];
|
|
652
|
+
const pI1 = p[pos + i + 1];
|
|
653
|
+
p[pos + i] = pI * m0 + pI1 * m2 + m4;
|
|
654
|
+
p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;
|
|
662
655
|
}
|
|
663
656
|
}
|
|
664
657
|
static applyInverseTransform(p, m) {
|
|
@@ -996,7 +989,7 @@ var PDFStringTranslateTable = [
|
|
|
996
989
|
0,
|
|
997
990
|
8364
|
|
998
991
|
];
|
|
999
|
-
function stringToPDFString(str) {
|
|
992
|
+
function stringToPDFString(str, keepEscapeSequence = false) {
|
|
1000
993
|
if (str[0] >= "\xEF") {
|
|
1001
994
|
let encoding;
|
|
1002
995
|
if (str[0] === "\xFE" && str[1] === "\xFF") {
|
|
@@ -1017,7 +1010,7 @@ function stringToPDFString(str) {
|
|
|
1017
1010
|
const decoder = new TextDecoder(encoding, { fatal: true });
|
|
1018
1011
|
const buffer = stringToBytes(str);
|
|
1019
1012
|
const decoded = decoder.decode(buffer);
|
|
1020
|
-
if (!decoded.includes("\x1B")) {
|
|
1013
|
+
if (keepEscapeSequence || !decoded.includes("\x1B")) {
|
|
1021
1014
|
return decoded;
|
|
1022
1015
|
}
|
|
1023
1016
|
return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
|
|
@@ -1029,7 +1022,7 @@ function stringToPDFString(str) {
|
|
|
1029
1022
|
const strBuf = [];
|
|
1030
1023
|
for (let i = 0, ii = str.length; i < ii; i++) {
|
|
1031
1024
|
const charCode = str.charCodeAt(i);
|
|
1032
|
-
if (charCode === 27) {
|
|
1025
|
+
if (!keepEscapeSequence && charCode === 27) {
|
|
1033
1026
|
while (++i < ii && str.charCodeAt(i) !== 27) {
|
|
1034
1027
|
}
|
|
1035
1028
|
continue;
|
|
@@ -1840,7 +1833,6 @@ function grayToRGBA(src, dest) {
|
|
|
1840
1833
|
|
|
1841
1834
|
export {
|
|
1842
1835
|
isNodeJS,
|
|
1843
|
-
IDENTITY_MATRIX,
|
|
1844
1836
|
FONT_IDENTITY_MATRIX,
|
|
1845
1837
|
LINE_FACTOR,
|
|
1846
1838
|
LINE_DESCENT_FACTOR,
|
|
@@ -1872,6 +1864,7 @@ export {
|
|
|
1872
1864
|
unreachable,
|
|
1873
1865
|
assert,
|
|
1874
1866
|
createValidAbsoluteUrl,
|
|
1867
|
+
updateUrlHash,
|
|
1875
1868
|
shadow,
|
|
1876
1869
|
BaseException,
|
|
1877
1870
|
PasswordException,
|
|
@@ -1883,7 +1876,6 @@ export {
|
|
|
1883
1876
|
stringToBytes,
|
|
1884
1877
|
string32,
|
|
1885
1878
|
objectSize,
|
|
1886
|
-
objectFromMap,
|
|
1887
1879
|
FeatureTest,
|
|
1888
1880
|
hexNumbers,
|
|
1889
1881
|
Util,
|