@react-pdf-kit/viewer 2.7.3 → 2.7.4-rc.1
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/{AnnotationLayer-SQbmx6wX.js → AnnotationLayer-C_Sk3ZMg.js} +1 -1
- package/dist/{PaginationContext-B3qzCYJu.js → PaginationContext-BmPajxlU.js} +24 -16
- package/dist/{RPPage-BdoE0RrK.js → RPPage-B1UMGNSI.js} +1 -1
- package/dist/{RPPages-Dw7lGXzM.js → RPPages-Dh4RWlPS.js} +346 -341
- package/dist/{Thumbnail-BVjnCNxv.js → Thumbnail-BOvkeGXM.js} +1 -1
- package/dist/{Thumbnails-CrKLESh3.js → Thumbnails-jteSWSw9.js} +2 -2
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPPages.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/ScrollModeTool.js +4 -4
- package/dist/components/layout/toolbar/ToolbarCustom.js +1 -1
- package/dist/components/layout/toolbar/ToolbarDefault.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +5 -5
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/DualPage.js +2 -2
- package/dist/components/page/DualPageWithCover.js +2 -2
- package/dist/components/page/RPPage.js +1 -1
- package/dist/components/page/SinglePage.js +2 -2
- package/dist/contexts/ElementThumbnailContext.js +1 -1
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +1 -1
- package/dist/{de_DE-C1OrwQKj.js → de_DE-x4Z-jQrz.js} +12 -0
- package/dist/{main-CdlJS0xf.js → main-ByQlDC9E.js} +1 -1
- package/dist/main.js +3 -3
- package/dist/types/locales/de_DE.json.d.ts +2 -0
- package/dist/types/locales/en_US.json.d.ts +2 -0
- package/dist/types/locales/it_IT.json.d.ts +2 -0
- package/dist/types/locales/pt_PT.json.d.ts +2 -0
- package/dist/types/locales/th_TH.json.d.ts +2 -0
- package/dist/types/locales/zh_CN.json.d.ts +2 -0
- package/dist/types/utils/const.d.ts +3 -0
- package/dist/types/utils/types.d.ts +4 -1
- package/dist/utils/const.js +2 -2
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +73 -63
- package/dist/utils/hooks/useLocalization.js +1 -1
- package/dist/utils/hooks/usePaginate.js +1 -1
- package/dist/utils/hooks/usePresentPage.js +1 -1
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +1 -1
- package/dist/utils/types.js +2 -2
- package/package.json +1 -1
|
@@ -2,75 +2,83 @@
|
|
|
2
2
|
import { ErrorType as e } from "../types.js";
|
|
3
3
|
import { getThumbnailViewport as t } from "../getThumbnailViewport.js";
|
|
4
4
|
import { useConfigContext as n } from "../../contexts/ConfigContext.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
5
|
+
import { appConsole as r } from "../appConsole.js";
|
|
6
|
+
import { useDocumentPasswordContext as i } from "../../contexts/DocumentPasswordContext.js";
|
|
7
|
+
import { BROWSER_NOT_SUPPORTED_MESSAGE as a, INVALID_OR_CORRUPTED_PDF_MESSAGE as o, WASM_URL_REQUIRED_CONSOLE_MESSAGE as s, WASM_URL_REQUIRED_MESSAGE as c } from "../const.js";
|
|
8
|
+
import { useEffect as l, useRef as u, useState as d } from "react";
|
|
9
|
+
import * as f from "pdfjs-dist";
|
|
9
10
|
//#region lib/utils/hooks/useLoadPdf.ts
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var p = new TextEncoder().encode("/JPXDecode");
|
|
12
|
+
function m(e) {
|
|
13
|
+
return e.some((t, n) => t === p[0] ? p.every((t, r) => e[n + r] === t) : !1);
|
|
14
|
+
}
|
|
15
|
+
function h(e) {
|
|
16
|
+
let t = Error(o);
|
|
12
17
|
return t.cause = e, t;
|
|
13
18
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
19
|
+
function g() {
|
|
20
|
+
return Error(c);
|
|
21
|
+
}
|
|
22
|
+
function _(e) {
|
|
23
|
+
let t = Error(a);
|
|
16
24
|
return t.cause = e, t;
|
|
17
25
|
}
|
|
18
|
-
var
|
|
19
|
-
let [p,
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
if (!
|
|
24
|
-
|
|
25
|
-
let t =
|
|
26
|
-
url:
|
|
27
|
-
cMapPacked:
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
...
|
|
31
|
-
...
|
|
32
|
-
...
|
|
33
|
-
...
|
|
34
|
-
...
|
|
35
|
-
...
|
|
36
|
-
verbosity:
|
|
26
|
+
var v = (a, o, c = {}) => {
|
|
27
|
+
let [p, v] = d(), { workerUrlAdded: y, wasmUrl: b } = n(), [x, S] = d(/* @__PURE__ */ new Map()), C = u(), [w, T] = d(0), [E, D] = d(!1), [O, k] = d(), { password: A, passwordError: j, setPasswordError: M, passwordRequired: N, setPasswordRequired: P } = i(), { onLoadError: F, onLoaded: I, onLoadProgress: L, disableAutoFetch: R, disableStream: z, rangeChunkSize: B, withCredentials: V, httpHeaders: H } = c;
|
|
28
|
+
return l(() => {
|
|
29
|
+
L && L(w);
|
|
30
|
+
}, [w, L]), l(() => {
|
|
31
|
+
if (!y || !a) return;
|
|
32
|
+
T(0), k(void 0), C.current = Date.now();
|
|
33
|
+
let t = C.current, n = {
|
|
34
|
+
url: a,
|
|
35
|
+
cMapPacked: o?.isCompressed ?? !0,
|
|
36
|
+
...o?.url && { cMapUrl: o.url },
|
|
37
|
+
...A && { password: A },
|
|
38
|
+
...R !== void 0 && { disableAutoFetch: R },
|
|
39
|
+
...z !== void 0 && { disableStream: z },
|
|
40
|
+
...B !== void 0 && { rangeChunkSize: B },
|
|
41
|
+
...V !== void 0 && { withCredentials: V },
|
|
42
|
+
...H !== void 0 && { httpHeaders: H },
|
|
43
|
+
...b && { wasmUrl: b },
|
|
44
|
+
verbosity: f.VerbosityLevel.ERRORS
|
|
37
45
|
};
|
|
38
46
|
try {
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
if (t ===
|
|
47
|
+
let i = f.getDocument(n);
|
|
48
|
+
i.onProgress = (e) => {
|
|
49
|
+
if (t === C.current) {
|
|
42
50
|
let { loaded: t, total: n } = e;
|
|
43
|
-
|
|
51
|
+
T(n ? Math.min(100, Math.round(t / n * 100)) : 0);
|
|
44
52
|
}
|
|
45
|
-
},
|
|
46
|
-
let
|
|
53
|
+
}, D(!0), v(void 0);
|
|
54
|
+
let a = i.promise.then(async (n) => !b && m(await n.getData()) ? (t === C.current && (v(void 0), k(e.WASM_URL_REQUIRED)), r.error(s), F?.(g()), n) : (t === C.current && (v(n), T(100)), I && I(n), P(!1), M(""), n)).catch((t) => {
|
|
47
55
|
if (t instanceof Error && t.name === "PasswordException") {
|
|
48
56
|
let e = t.code;
|
|
49
|
-
|
|
50
|
-
} else t instanceof Error && t.name === "InvalidPDFException" &&
|
|
57
|
+
P(!0), e === f.PasswordResponses.INCORRECT_PASSWORD ? M("Incorrect password") : M(void 0);
|
|
58
|
+
} else t instanceof Error && t.name === "InvalidPDFException" && A ? (P(!0), M("Incorrect password")) : t instanceof Error && t.name === "InvalidPDFException" ? (k(e.INVALID_OR_CORRUPTED_PDF), F?.(h(t))) : F && F(t);
|
|
51
59
|
}).finally(() => {
|
|
52
|
-
|
|
60
|
+
D(!1);
|
|
53
61
|
});
|
|
54
62
|
return () => {
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
a.finally(() => {
|
|
64
|
+
i.destroy();
|
|
57
65
|
});
|
|
58
66
|
};
|
|
59
67
|
} catch (t) {
|
|
60
|
-
|
|
68
|
+
k(e.NOT_SUPPORTED), F?.(_(t));
|
|
61
69
|
}
|
|
62
70
|
}, [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
]),
|
|
70
|
-
if (
|
|
71
|
+
a,
|
|
72
|
+
y,
|
|
73
|
+
b,
|
|
74
|
+
A,
|
|
75
|
+
F,
|
|
76
|
+
I
|
|
77
|
+
]), l(() => {
|
|
78
|
+
if (N) return;
|
|
71
79
|
let n = /* @__PURE__ */ new Map();
|
|
72
|
-
if (!p ||
|
|
73
|
-
|
|
80
|
+
if (!p || E) {
|
|
81
|
+
S(n);
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
84
|
let r = p.numPages, i = [];
|
|
@@ -78,8 +86,10 @@ var f = (i, a, f = {}) => {
|
|
|
78
86
|
let t = p.getPage(e);
|
|
79
87
|
i.push(t);
|
|
80
88
|
}
|
|
81
|
-
Promise.
|
|
82
|
-
e.map((e) =>
|
|
89
|
+
Promise.allSettled(i).then((e) => {
|
|
90
|
+
let r = e.filter((e) => e.status === "fulfilled").map((e) => e.value);
|
|
91
|
+
if (!r.length) throw e.find((e) => e.status === "rejected")?.reason;
|
|
92
|
+
r.map((e) => {
|
|
83
93
|
let { thumbnailViewport: r, scale: i } = t(e), a = e.getViewport();
|
|
84
94
|
n.set(e.pageNumber, {
|
|
85
95
|
page: e,
|
|
@@ -87,24 +97,24 @@ var f = (i, a, f = {}) => {
|
|
|
87
97
|
thumbnailScale: i,
|
|
88
98
|
defaultRotation: a.rotation
|
|
89
99
|
});
|
|
90
|
-
}),
|
|
100
|
+
}), S(n);
|
|
91
101
|
}).catch((t) => {
|
|
92
|
-
|
|
102
|
+
v(void 0), k(e.INVALID_OR_CORRUPTED_PDF), F?.(h(t));
|
|
93
103
|
});
|
|
94
104
|
}, [
|
|
95
105
|
p,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
E,
|
|
107
|
+
N,
|
|
108
|
+
F
|
|
99
109
|
]), {
|
|
100
110
|
pdf: p,
|
|
101
|
-
pages:
|
|
102
|
-
loading:
|
|
103
|
-
error:
|
|
104
|
-
loadingProgress:
|
|
105
|
-
passwordRequired:
|
|
106
|
-
passwordError:
|
|
111
|
+
pages: x,
|
|
112
|
+
loading: E,
|
|
113
|
+
error: O,
|
|
114
|
+
loadingProgress: w,
|
|
115
|
+
passwordRequired: N,
|
|
116
|
+
passwordError: j
|
|
107
117
|
};
|
|
108
118
|
};
|
|
109
119
|
//#endregion
|
|
110
|
-
export {
|
|
120
|
+
export { v as useLoadPdf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "../../de_DE-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "../../de_DE-x4Z-jQrz.js";
|
|
2
2
|
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
3
3
|
//#region lib/utils/hooks/useLocalization.ts
|
|
4
4
|
var l = (l) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e } from "../../PaginationContext-
|
|
1
|
+
import { i as e } from "../../PaginationContext-BmPajxlU.js";
|
|
2
2
|
export { e as usePaginate };
|
|
@@ -4,7 +4,7 @@ import { useDebounce as n } from "./useDebounce.js";
|
|
|
4
4
|
import { useDimensionPagesContext as r } from "../../contexts/DimensionPagesContext.js";
|
|
5
5
|
import { useSmoothScrollContext as i } from "../../contexts/SmoothScrollContext.js";
|
|
6
6
|
import { getGridDimension as a, getPositionFromPage as o } from "../calculatePage.js";
|
|
7
|
-
import { r as s } from "../../PaginationContext-
|
|
7
|
+
import { r as s } from "../../PaginationContext-BmPajxlU.js";
|
|
8
8
|
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
9
9
|
//#region lib/utils/hooks/usePresentPage.ts
|
|
10
10
|
var p = (p, m, h, g) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e } from "../../PaginationContext-
|
|
1
|
+
import { a as e } from "../../PaginationContext-BmPajxlU.js";
|
|
2
2
|
export { e as useScrollToPage };
|
|
@@ -9,7 +9,7 @@ import { usePagesRotateContext as c } from "../../contexts/PagesRotateContext.js
|
|
|
9
9
|
import { useDimensionPagesContext as l } from "../../contexts/DimensionPagesContext.js";
|
|
10
10
|
import { useSmoothScrollContext as u } from "../../contexts/SmoothScrollContext.js";
|
|
11
11
|
import { getScrollDistance as d } from "../getScrollDistance.js";
|
|
12
|
-
import { r as f } from "../../PaginationContext-
|
|
12
|
+
import { r as f } from "../../PaginationContext-BmPajxlU.js";
|
|
13
13
|
import { findMatches as p } from "../highlight.js";
|
|
14
14
|
import { getWordPositionInPage as m } from "../getWordPositionInPage.js";
|
|
15
15
|
import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
package/dist/utils/types.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "../de_DE-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "../de_DE-x4Z-jQrz.js";
|
|
2
2
|
//#region lib/utils/types.ts
|
|
3
3
|
var o = /* @__PURE__ */ function(e) {
|
|
4
4
|
return e[e.Text = 1] = "Text", e[e.Link = 2] = "Link", e[e.FreeText = 3] = "FreeText", e[e.Line = 4] = "Line", e[e.Square = 5] = "Square", e[e.Circle = 6] = "Circle", e[e.Polygon = 7] = "Polygon", e[e.Polyline = 8] = "Polyline", e[e.Highlight = 9] = "Highlight", e[e.Underline = 10] = "Underline", e[e.Squiggly = 11] = "Squiggly", e[e.StrikeOut = 12] = "StrikeOut", e[e.Stamp = 13] = "Stamp", e[e.Caret = 14] = "Caret", e[e.Ink = 15] = "Ink", e[e.Popup = 16] = "Popup", e[e.FileAttachment = 17] = "FileAttachment", e[e.Widget = 20] = "Widget", e;
|
|
5
5
|
}({}), s = /* @__PURE__ */ function(e) {
|
|
6
6
|
return e.INTERNAL_LINK = "internal-link", e.LINK = "link", e.FILE_ATTACHMENT = "file-attachment", e.FORM_TEXT = "form-text", e.FORM_SELECT = "form-select", e.FORM_CHECKBOX = "form-checkbox", e.FORM_RADIO = "form-radio", e.FORM_BUTTON = "form-button", e.BUTTON = "button", e;
|
|
7
7
|
}({}), c = /* @__PURE__ */ function(e) {
|
|
8
|
-
return e.NOT_SUPPORTED = "not-supported", e.INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf", e;
|
|
8
|
+
return e.NOT_SUPPORTED = "not-supported", e.INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf", e.WASM_URL_REQUIRED = "wasm-url-required", e;
|
|
9
9
|
}({}), l = /* @__PURE__ */ function(e) {
|
|
10
10
|
return e.ACTUAL = "Actual Size", e.PAGE_FIT = "Page Fit", e.PAGE_WIDTH = "Page Width", e;
|
|
11
11
|
}({}), u = /* @__PURE__ */ function(e) {
|