@pdf-viewer/react 1.14.0-rc.0 → 1.15.0-beta.0
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.
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { DocumentProvider as
|
|
4
|
-
import { DocumentPasswordProvider as
|
|
5
|
-
import { RPController as
|
|
6
|
-
import { LoaderProvider as
|
|
7
|
-
import { ToolComponentProvider as
|
|
8
|
-
import { IconToolProvider as
|
|
9
|
-
import { OtherToolProvider as
|
|
10
|
-
import { useFlickerSelectText as
|
|
11
|
-
import { EventCallbackProvider as
|
|
12
|
-
import { combinedCSS as
|
|
13
|
-
import { injectGlobalCSS as
|
|
14
|
-
import { injectPrintCSS as
|
|
2
|
+
import { useMemo as v, useEffect as S } from "react";
|
|
3
|
+
import { DocumentProvider as C } from "../contexts/RPDocumentContext.js";
|
|
4
|
+
import { DocumentPasswordProvider as g } from "../contexts/DocumentPasswordContext.js";
|
|
5
|
+
import { RPController as b } from "./RPController.js";
|
|
6
|
+
import { LoaderProvider as L } from "../contexts/LoaderContext.js";
|
|
7
|
+
import { ToolComponentProvider as T } from "../contexts/ToolComponentContext.js";
|
|
8
|
+
import { IconToolProvider as j } from "../contexts/IconToolContext.js";
|
|
9
|
+
import { OtherToolProvider as k } from "../contexts/OtherToolContext.js";
|
|
10
|
+
import { useFlickerSelectText as w } from "../utils/hooks/useFlickerSelectText.js";
|
|
11
|
+
import { EventCallbackProvider as x } from "../contexts/EventCallbackContext.js";
|
|
12
|
+
import { combinedCSS as y } from "../assets/style.js";
|
|
13
|
+
import { injectGlobalCSS as D } from "../libInjectCss.js";
|
|
14
|
+
import { injectPrintCSS as E } from "../utils/injectPrintCSS.js";
|
|
15
15
|
import "../utils/hooks/useLoadPdf.js";
|
|
16
16
|
import "pdfjs-dist";
|
|
17
17
|
import "../utils/types.js";
|
|
@@ -139,7 +139,7 @@ import "../utils/zoom.js";
|
|
|
139
139
|
import "./icons/SearchIcon.js";
|
|
140
140
|
import "./icons/ClearIcon.js";
|
|
141
141
|
import "../utils/hooks/useWatermark.js";
|
|
142
|
-
const
|
|
142
|
+
const at = (i) => {
|
|
143
143
|
const {
|
|
144
144
|
children: m,
|
|
145
145
|
src: o,
|
|
@@ -148,26 +148,32 @@ const ct = (i) => {
|
|
|
148
148
|
onLoadError: n,
|
|
149
149
|
loaderImage: c,
|
|
150
150
|
onLoadProgress: d,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
159
|
-
|
|
151
|
+
disableAutoFetch: l,
|
|
152
|
+
disableStream: a,
|
|
153
|
+
rangeChunkSize: s,
|
|
154
|
+
onPageChange: f,
|
|
155
|
+
onRotate: P,
|
|
156
|
+
onScroll: h,
|
|
157
|
+
...u
|
|
158
|
+
} = i, t = v(() => typeof o == "string" ? o : `${Date.now()}`, [o]);
|
|
159
|
+
return w(), S(() => {
|
|
160
|
+
D(y, "rp-viewer-styles"), E();
|
|
161
|
+
}, []), /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(
|
|
162
|
+
C,
|
|
160
163
|
{
|
|
161
164
|
src: o,
|
|
162
165
|
characterMap: p,
|
|
163
166
|
onLoaded: e,
|
|
164
167
|
onLoadError: n,
|
|
165
168
|
onLoadProgress: d,
|
|
166
|
-
|
|
169
|
+
disableAutoFetch: l,
|
|
170
|
+
disableStream: a,
|
|
171
|
+
rangeChunkSize: s,
|
|
172
|
+
children: /* @__PURE__ */ r(x, { onPageChange: f, onRotate: P, onScroll: h, children: /* @__PURE__ */ r(b, { ...u, children: /* @__PURE__ */ r(L, { loaderImage: c, children: /* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(k, { children: m }) }) }) }, t) }, t) })
|
|
167
173
|
},
|
|
168
174
|
t
|
|
169
175
|
) });
|
|
170
176
|
};
|
|
171
177
|
export {
|
|
172
|
-
|
|
178
|
+
at as RPProvider
|
|
173
179
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLoadPdf as
|
|
4
|
-
import { usePdfProperties as
|
|
5
|
-
import { appConsole as
|
|
1
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as M, useState as l, useEffect as j, useMemo as k, useContext as w } from "react";
|
|
3
|
+
import { useLoadPdf as E } from "../utils/hooks/useLoadPdf.js";
|
|
4
|
+
import { usePdfProperties as L } from "../utils/hooks/usePdfProperties.js";
|
|
5
|
+
import { appConsole as R } from "../utils/appConsole.js";
|
|
6
6
|
import "pdfjs-dist";
|
|
7
7
|
import "../utils/types.js";
|
|
8
8
|
import "../th_TH-d627cd51.js";
|
|
@@ -11,7 +11,7 @@ import "./ConfigContext.js";
|
|
|
11
11
|
import "./DocumentPasswordContext.js";
|
|
12
12
|
import "../utils/convertPdfDate.js";
|
|
13
13
|
import "../utils/formatFileSize.js";
|
|
14
|
-
const u =
|
|
14
|
+
const u = M({
|
|
15
15
|
pdf: void 0,
|
|
16
16
|
pages: /* @__PURE__ */ new Map(),
|
|
17
17
|
setPdfSrc: () => {
|
|
@@ -21,23 +21,31 @@ const u = v({
|
|
|
21
21
|
loading: !1,
|
|
22
22
|
loaderProgress: 0,
|
|
23
23
|
error: void 0
|
|
24
|
-
}),
|
|
24
|
+
}), Q = ({
|
|
25
25
|
children: t,
|
|
26
26
|
src: e,
|
|
27
27
|
characterMap: c,
|
|
28
28
|
onLoadError: P,
|
|
29
29
|
onLoaded: g,
|
|
30
|
-
onLoadProgress: x
|
|
30
|
+
onLoadProgress: x,
|
|
31
|
+
disableAutoFetch: C,
|
|
32
|
+
disableStream: h,
|
|
33
|
+
rangeChunkSize: v,
|
|
34
|
+
loaderImage: S
|
|
31
35
|
}) => {
|
|
32
|
-
const [o, n] = l(e), [i, s] = l(), { pdf: r, pages: p, loading: m, loadingProgress: d, error: f } =
|
|
36
|
+
const [o, n] = l(e), [i, s] = l(), { pdf: r, pages: p, loading: m, loadingProgress: d, error: f } = E(o, c, {
|
|
33
37
|
onLoadError: P,
|
|
34
38
|
onLoaded: g,
|
|
35
|
-
onLoadProgress: x
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
onLoadProgress: x,
|
|
40
|
+
disableAutoFetch: C,
|
|
41
|
+
disableStream: h,
|
|
42
|
+
rangeChunkSize: v,
|
|
43
|
+
loaderImage: S
|
|
44
|
+
}), a = L(o, r, i);
|
|
45
|
+
j(() => {
|
|
38
46
|
s(e == null ? void 0 : e.split("/").pop()), n(e);
|
|
39
47
|
}, [e]);
|
|
40
|
-
const
|
|
48
|
+
const D = k(() => ({
|
|
41
49
|
pdf: r,
|
|
42
50
|
pages: p,
|
|
43
51
|
pdfSrc: o,
|
|
@@ -49,13 +57,13 @@ const u = v({
|
|
|
49
57
|
loaderProgress: d,
|
|
50
58
|
error: f
|
|
51
59
|
}), [r, p, o, a, m, d, f]);
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
},
|
|
54
|
-
const t =
|
|
55
|
-
return t.pdfSrc ||
|
|
60
|
+
return /* @__PURE__ */ F(u.Provider, { value: D, children: o ? t : null });
|
|
61
|
+
}, T = () => {
|
|
62
|
+
const t = w(u);
|
|
63
|
+
return t.pdfSrc || R.error("Please use this hooks inside children component of RPDocument"), t;
|
|
56
64
|
};
|
|
57
65
|
export {
|
|
58
|
-
|
|
66
|
+
Q as DocumentProvider,
|
|
59
67
|
u as default,
|
|
60
|
-
|
|
68
|
+
T as useDocumentContext
|
|
61
69
|
};
|
|
@@ -641,6 +641,9 @@ export interface LoadPDFOptions {
|
|
|
641
641
|
onLoaded?: (pdfDocument: PDFDocumentProxy) => void;
|
|
642
642
|
onLoadProgress?: (progress: number) => void;
|
|
643
643
|
loaderImage?: LoaderImage;
|
|
644
|
+
disableAutoFetch?: boolean;
|
|
645
|
+
disableStream?: boolean;
|
|
646
|
+
rangeChunkSize?: number;
|
|
644
647
|
}
|
|
645
648
|
export interface ScrollPosition {
|
|
646
649
|
left: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as E, useCallback as h, useEffect as A } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2025-12-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-12-12T03:35:49.089Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
|
|
4
4
|
invalidLicense: `You are currently using without a valid license. ${d}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
|
|
6
6
|
expired: `Your license key has expired. ${d}`,
|
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import * as
|
|
3
|
-
import { ErrorType as
|
|
4
|
-
import { getThumbnailViewport as
|
|
5
|
-
import { useConfigContext as
|
|
6
|
-
import { useDocumentPasswordContext as
|
|
1
|
+
import { useState as d, useRef as A, useEffect as k } from "react";
|
|
2
|
+
import * as I from "pdfjs-dist";
|
|
3
|
+
import { ErrorType as F } from "../types.js";
|
|
4
|
+
import { getThumbnailViewport as j } from "../getThumbnailViewport.js";
|
|
5
|
+
import { useConfigContext as z } from "../../contexts/ConfigContext.js";
|
|
6
|
+
import { useDocumentPasswordContext as _ } from "../../contexts/DocumentPasswordContext.js";
|
|
7
7
|
import "../../th_TH-d627cd51.js";
|
|
8
8
|
import "react/jsx-runtime";
|
|
9
9
|
import "../appConsole.js";
|
|
10
|
-
const
|
|
11
|
-
const [n,
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
}, [
|
|
15
|
-
if (!
|
|
10
|
+
const Y = (m, s, h = {}) => {
|
|
11
|
+
const [n, q] = d(), { workerUrlAdded: v } = z(), [D, S] = d(/* @__PURE__ */ new Map()), a = A(), [f, g] = d(0), [P, T] = d(!1), [N, O] = d(), { password: u, passwordError: U, setPasswordError: c, passwordRequired: p, setPasswordRequired: w } = _(), { onLoadError: i, onLoaded: E, onLoadProgress: b, disableAutoFetch: x, disableStream: C, rangeChunkSize: V } = h;
|
|
12
|
+
return k(() => {
|
|
13
|
+
b && b(f);
|
|
14
|
+
}, [f, b]), k(() => {
|
|
15
|
+
if (!v || !m)
|
|
16
16
|
return;
|
|
17
|
-
|
|
18
|
-
const r =
|
|
19
|
-
url:
|
|
17
|
+
g(0), a.current = Date.now();
|
|
18
|
+
const r = a.current, R = {
|
|
19
|
+
url: m,
|
|
20
20
|
cMapPacked: (s == null ? void 0 : s.isCompressed) ?? !0,
|
|
21
21
|
...(s == null ? void 0 : s.url) && { cMapUrl: s.url },
|
|
22
22
|
...u && { password: u },
|
|
23
|
-
|
|
23
|
+
...x !== void 0 && { disableAutoFetch: x },
|
|
24
|
+
...C !== void 0 && { disableStream: C },
|
|
25
|
+
...V !== void 0 && { rangeChunkSize: V },
|
|
26
|
+
verbosity: I.VerbosityLevel.ERRORS
|
|
24
27
|
};
|
|
25
28
|
try {
|
|
26
|
-
const e =
|
|
29
|
+
const e = I.getDocument(R);
|
|
27
30
|
e.onProgress = (o) => {
|
|
28
|
-
if (r ===
|
|
29
|
-
const { loaded: y, total:
|
|
30
|
-
|
|
31
|
+
if (r === a.current) {
|
|
32
|
+
const { loaded: y, total: l } = o, L = l ? Math.min(100, Math.round(y / l * 100)) : 0;
|
|
33
|
+
g(L);
|
|
31
34
|
}
|
|
32
|
-
},
|
|
33
|
-
const t = e.promise.then((o) => (r ===
|
|
35
|
+
}, T(!0);
|
|
36
|
+
const t = e.promise.then((o) => (r === a.current && (q(o), g(100)), E && E(o), w(!1), c(""), o)).catch((o) => {
|
|
34
37
|
o instanceof Error && o.name === "PasswordException" ? (w(!0), c(o.message || "Password required")) : o instanceof Error && o.name === "InvalidPDFException" && u ? (w(!0), c("Incorrect password")) : i && i(o);
|
|
35
38
|
}).finally(() => {
|
|
36
|
-
|
|
39
|
+
T(!1);
|
|
37
40
|
});
|
|
38
41
|
return () => {
|
|
39
42
|
t.finally(() => {
|
|
@@ -41,42 +44,42 @@ const Q = (l, s, I = {}) => {
|
|
|
41
44
|
});
|
|
42
45
|
};
|
|
43
46
|
} catch (e) {
|
|
44
|
-
|
|
47
|
+
O(F.NOT_SUPPORTED), i && i(e);
|
|
45
48
|
}
|
|
46
|
-
}, [
|
|
49
|
+
}, [m, v, u, i, E]), k(() => {
|
|
47
50
|
if (p)
|
|
48
51
|
return;
|
|
49
52
|
const r = /* @__PURE__ */ new Map();
|
|
50
|
-
if (!n ||
|
|
51
|
-
|
|
53
|
+
if (!n || P) {
|
|
54
|
+
S(r);
|
|
52
55
|
return;
|
|
53
56
|
}
|
|
54
|
-
const
|
|
55
|
-
for (let t = 1; t <=
|
|
57
|
+
const R = n.numPages, e = [];
|
|
58
|
+
for (let t = 1; t <= R; t++) {
|
|
56
59
|
const o = n.getPage(t);
|
|
57
60
|
e.push(o);
|
|
58
61
|
}
|
|
59
62
|
Promise.all(e).then((t) => {
|
|
60
63
|
t.map((o) => {
|
|
61
|
-
const { thumbnailViewport: y, scale:
|
|
64
|
+
const { thumbnailViewport: y, scale: l } = j(o), L = o.getViewport();
|
|
62
65
|
r.set(o.pageNumber, {
|
|
63
66
|
page: o,
|
|
64
67
|
thumbnailViewport: y,
|
|
65
|
-
thumbnailScale:
|
|
68
|
+
thumbnailScale: l,
|
|
66
69
|
defaultRotation: L.rotation
|
|
67
70
|
});
|
|
68
|
-
}),
|
|
71
|
+
}), S(r);
|
|
69
72
|
});
|
|
70
|
-
}, [n,
|
|
73
|
+
}, [n, P, p]), {
|
|
71
74
|
pdf: n,
|
|
72
|
-
pages:
|
|
73
|
-
loading:
|
|
74
|
-
error:
|
|
75
|
-
loadingProgress:
|
|
75
|
+
pages: D,
|
|
76
|
+
loading: P,
|
|
77
|
+
error: N,
|
|
78
|
+
loadingProgress: f,
|
|
76
79
|
passwordRequired: p,
|
|
77
|
-
passwordError:
|
|
80
|
+
passwordError: U
|
|
78
81
|
};
|
|
79
82
|
};
|
|
80
83
|
export {
|
|
81
|
-
|
|
84
|
+
Y as useLoadPdf
|
|
82
85
|
};
|
package/package.json
CHANGED