@react-pdf-kit/viewer 2.4.0-beta.4 → 2.4.0-beta.5
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.
|
@@ -2,3 +2,4 @@ import { NormalizedKeyword } from './types';
|
|
|
2
2
|
export declare const EMPTY_KEYWORD_REGEXP: NormalizedKeyword;
|
|
3
3
|
export declare const ORGANIZATION_ALLOWED_FEATURES_MESSAGE = "This feature is only available for the Organization license";
|
|
4
4
|
export declare const INVALID_OR_CORRUPTED_PDF_MESSAGE = "Invalid or corrupted PDF file.";
|
|
5
|
+
export declare const BROWSER_NOT_SUPPORTED_MESSAGE = "React PDF Kit is unable to render on this browser.";
|
package/dist/utils/const.js
CHANGED
|
@@ -2,8 +2,9 @@ const e = {
|
|
|
2
2
|
keyword: "",
|
|
3
3
|
regExp: new RegExp(" "),
|
|
4
4
|
wholeWords: !1
|
|
5
|
-
}, E = "This feature is only available for the Organization license", o = "Invalid or corrupted PDF file.";
|
|
5
|
+
}, E = "This feature is only available for the Organization license", o = "Invalid or corrupted PDF file.", r = "React PDF Kit is unable to render on this browser.";
|
|
6
6
|
export {
|
|
7
|
+
r as BROWSER_NOT_SUPPORTED_MESSAGE,
|
|
7
8
|
e as EMPTY_KEYWORD_REGEXP,
|
|
8
9
|
o as INVALID_OR_CORRUPTED_PDF_MESSAGE,
|
|
9
10
|
E as ORGANIZATION_ALLOWED_FEATURES_MESSAGE
|
|
@@ -2,7 +2,7 @@ import { useState as E, useCallback as y, useEffect as b } from "react";
|
|
|
2
2
|
import { LicenseType as L } from "../types.js";
|
|
3
3
|
import { appConsole as c } from "../appConsole.js";
|
|
4
4
|
import "../../de_DE-8145915f.js";
|
|
5
|
-
const A = /* @__PURE__ */ new Date("2026-04-
|
|
5
|
+
const A = /* @__PURE__ */ new Date("2026-04-17T07:06:06.167Z"), w = `-----BEGIN PUBLIC KEY-----
|
|
6
6
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
|
|
7
7
|
gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
|
|
8
8
|
HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
|
|
@@ -1,48 +1,52 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import * as
|
|
3
|
-
import { ErrorType as
|
|
4
|
-
import { getThumbnailViewport as
|
|
5
|
-
import { useConfigContext as
|
|
6
|
-
import { useDocumentPasswordContext as
|
|
7
|
-
import { INVALID_OR_CORRUPTED_PDF_MESSAGE as H } from "../const.js";
|
|
1
|
+
import { useState as u, useRef as B, useEffect as T } from "react";
|
|
2
|
+
import * as k from "pdfjs-dist";
|
|
3
|
+
import { ErrorType as b } from "../types.js";
|
|
4
|
+
import { getThumbnailViewport as G } from "../getThumbnailViewport.js";
|
|
5
|
+
import { useConfigContext as j } from "../../contexts/ConfigContext.js";
|
|
6
|
+
import { useDocumentPasswordContext as z } from "../../contexts/DocumentPasswordContext.js";
|
|
7
|
+
import { INVALID_OR_CORRUPTED_PDF_MESSAGE as W, BROWSER_NOT_SUPPORTED_MESSAGE as H } from "../const.js";
|
|
8
8
|
import "../../de_DE-8145915f.js";
|
|
9
9
|
import "react/jsx-runtime";
|
|
10
10
|
import "../appConsole.js";
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
return
|
|
11
|
+
function x(n) {
|
|
12
|
+
const o = new Error(W);
|
|
13
|
+
return o.cause = n, o;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
function J(n) {
|
|
16
|
+
const o = new Error(H);
|
|
17
|
+
return o.cause = n, o;
|
|
18
|
+
}
|
|
19
|
+
const te = (n, o, F = {}) => {
|
|
20
|
+
const [a, c] = u(), { workerUrlAdded: C, wasmUrl: P } = j(), [h, N] = u(/* @__PURE__ */ new Map()), d = B(), [p, g] = u(0), [w, U] = u(!1), [L, l] = u(), { password: f, passwordError: q, setPasswordError: E, passwordRequired: R, setPasswordRequired: D } = z(), { onLoadError: t, onLoaded: _, onLoadProgress: O, disableAutoFetch: V, disableStream: y, rangeChunkSize: A } = F;
|
|
21
|
+
return T(() => {
|
|
22
|
+
O && O(p);
|
|
23
|
+
}, [p, O]), T(() => {
|
|
24
|
+
if (!C || !n)
|
|
21
25
|
return;
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
url:
|
|
25
|
-
cMapPacked: (
|
|
26
|
-
...(
|
|
26
|
+
g(0), l(void 0), d.current = Date.now();
|
|
27
|
+
const i = d.current, S = {
|
|
28
|
+
url: n,
|
|
29
|
+
cMapPacked: (o == null ? void 0 : o.isCompressed) ?? !0,
|
|
30
|
+
...(o == null ? void 0 : o.url) && { cMapUrl: o.url },
|
|
27
31
|
...f && { password: f },
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
...
|
|
31
|
-
...
|
|
32
|
-
verbosity:
|
|
32
|
+
...V !== void 0 && { disableAutoFetch: V },
|
|
33
|
+
...y !== void 0 && { disableStream: y },
|
|
34
|
+
...A !== void 0 && { rangeChunkSize: A },
|
|
35
|
+
...P && { wasmUrl: P },
|
|
36
|
+
verbosity: k.VerbosityLevel.ERRORS
|
|
33
37
|
};
|
|
34
38
|
try {
|
|
35
|
-
const r =
|
|
39
|
+
const r = k.getDocument(S);
|
|
36
40
|
r.onProgress = (e) => {
|
|
37
|
-
if (
|
|
38
|
-
const { loaded:
|
|
39
|
-
|
|
41
|
+
if (i === d.current) {
|
|
42
|
+
const { loaded: I, total: m } = e, v = m ? Math.min(100, Math.round(I / m * 100)) : 0;
|
|
43
|
+
g(v);
|
|
40
44
|
}
|
|
41
|
-
},
|
|
42
|
-
const s = r.promise.then((e) => (
|
|
43
|
-
e instanceof Error && e.name === "PasswordException" ? (D(!0), E(e.message || "Password required")) : e instanceof Error && e.name === "InvalidPDFException" && f ? (D(!0), E("Incorrect password")) : e instanceof Error && e.name === "InvalidPDFException" ? (l(
|
|
45
|
+
}, U(!0), c(void 0);
|
|
46
|
+
const s = r.promise.then((e) => (i === d.current && (c(e), g(100)), _ && _(e), D(!1), E(""), e)).catch((e) => {
|
|
47
|
+
e instanceof Error && e.name === "PasswordException" ? (D(!0), E(e.message || "Password required")) : e instanceof Error && e.name === "InvalidPDFException" && f ? (D(!0), E("Incorrect password")) : e instanceof Error && e.name === "InvalidPDFException" ? (l(b.INVALID_OR_CORRUPTED_PDF), t == null || t(x(e))) : t && t(e);
|
|
44
48
|
}).finally(() => {
|
|
45
|
-
|
|
49
|
+
U(!1);
|
|
46
50
|
});
|
|
47
51
|
return () => {
|
|
48
52
|
s.finally(() => {
|
|
@@ -50,44 +54,44 @@ const ee = (i, t, L = {}) => {
|
|
|
50
54
|
});
|
|
51
55
|
};
|
|
52
56
|
} catch (r) {
|
|
53
|
-
l(
|
|
57
|
+
l(b.NOT_SUPPORTED), t == null || t(J(r));
|
|
54
58
|
}
|
|
55
|
-
}, [
|
|
59
|
+
}, [n, C, P, f, t, _]), T(() => {
|
|
56
60
|
if (R)
|
|
57
61
|
return;
|
|
58
|
-
const
|
|
62
|
+
const i = /* @__PURE__ */ new Map();
|
|
59
63
|
if (!a || w) {
|
|
60
|
-
|
|
64
|
+
N(i);
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
const
|
|
64
|
-
for (let s = 1; s <=
|
|
67
|
+
const S = a.numPages, r = [];
|
|
68
|
+
for (let s = 1; s <= S; s++) {
|
|
65
69
|
const e = a.getPage(s);
|
|
66
70
|
r.push(e);
|
|
67
71
|
}
|
|
68
72
|
Promise.all(r).then((s) => {
|
|
69
73
|
s.map((e) => {
|
|
70
|
-
const { thumbnailViewport:
|
|
71
|
-
|
|
74
|
+
const { thumbnailViewport: I, scale: m } = G(e), v = e.getViewport();
|
|
75
|
+
i.set(e.pageNumber, {
|
|
72
76
|
page: e,
|
|
73
|
-
thumbnailViewport:
|
|
77
|
+
thumbnailViewport: I,
|
|
74
78
|
thumbnailScale: m,
|
|
75
|
-
defaultRotation:
|
|
79
|
+
defaultRotation: v.rotation
|
|
76
80
|
});
|
|
77
|
-
}),
|
|
81
|
+
}), N(i);
|
|
78
82
|
}).catch((s) => {
|
|
79
|
-
|
|
83
|
+
c(void 0), l(b.INVALID_OR_CORRUPTED_PDF), t == null || t(x(s));
|
|
80
84
|
});
|
|
81
|
-
}, [a, w, R,
|
|
85
|
+
}, [a, w, R, t]), {
|
|
82
86
|
pdf: a,
|
|
83
|
-
pages:
|
|
87
|
+
pages: h,
|
|
84
88
|
loading: w,
|
|
85
|
-
error:
|
|
86
|
-
loadingProgress:
|
|
89
|
+
error: L,
|
|
90
|
+
loadingProgress: p,
|
|
87
91
|
passwordRequired: R,
|
|
88
92
|
passwordError: q
|
|
89
93
|
};
|
|
90
94
|
};
|
|
91
95
|
export {
|
|
92
|
-
|
|
96
|
+
te as useLoadPdf
|
|
93
97
|
};
|