@pdf-viewer/react 0.0.0-experimental.0 → 0.0.0-experimental.2
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/{ToolbarLayout.module-89451ab3.js → ToolbarLayout.module-185b677e.js} +1071 -1059
- package/dist/components/RPController.js +5 -3
- package/dist/components/RPPages.js +4 -2
- package/dist/components/RPProvider.js +37 -22
- package/dist/components/layout/LayoutContainer.js +5 -3
- package/dist/components/layout/RPDefaultLayout.js +5 -3
- package/dist/components/layout/RPLayout.js +5 -3
- package/dist/components/layout/sidebar/RPSidebar.js +5 -3
- package/dist/components/layout/sidebar/Thumbnail.js +5 -3
- package/dist/components/layout/sidebar/Thumbnails.js +5 -3
- package/dist/components/layout/toolbar/DocumentDialog.js +5 -3
- package/dist/components/layout/toolbar/FileDownloadTool.js +5 -3
- package/dist/components/layout/toolbar/MostPageTool.js +5 -3
- package/dist/components/layout/toolbar/OtherTool.js +5 -3
- package/dist/components/layout/toolbar/Paginate.js +5 -3
- package/dist/components/layout/toolbar/PrintTool.js +5 -3
- package/dist/components/layout/toolbar/RPMoreOptions.js +6 -4
- package/dist/components/layout/toolbar/RPToolbar.js +5 -3
- package/dist/components/layout/toolbar/RPToolbarEnd.js +5 -3
- package/dist/components/layout/toolbar/SearchResultNavigator.js +5 -3
- package/dist/components/layout/toolbar/SearchTool.js +5 -3
- package/dist/components/layout/toolbar/ThumbnailTool.js +6 -4
- package/dist/components/layout/toolbar/ToolbarCustom.js +6 -4
- package/dist/components/layout/toolbar/ToolbarDefault.js +6 -4
- package/dist/components/layout/toolbar/ToolbarLayout.js +6 -4
- package/dist/components/layout/toolbar/ZoomTool.js +3 -2
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +6 -4
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +6 -4
- package/dist/components/layout/toolbar/tools/InputPageTool.js +6 -4
- package/dist/components/layout/toolbar/tools/NextPageTool.js +5 -3
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +6 -4
- package/dist/components/layout/toolbar/tools/PrintTool.js +6 -4
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +6 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +3 -2
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +3 -2
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +3 -2
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +5 -3
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +6 -4
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +6 -4
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +6 -4
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +6 -4
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +6 -4
- package/dist/components/page/AnnotationLayer.js +5 -3
- package/dist/components/page/CanvasLayer.js +5 -3
- package/dist/components/page/CustomElement.js +7 -2
- package/dist/components/page/DualPage.js +5 -3
- package/dist/components/page/RPPage.js +4 -2
- package/dist/components/page/SinglePage.js +5 -3
- package/dist/components/page/TextHighlightLayer.js +5 -3
- package/dist/components/page/TextLayer.js +5 -3
- package/dist/components/ui/LoadingIndicator.js +5 -3
- package/dist/contexts/DimensionPagesContext.js +10 -9
- package/dist/contexts/ElementPageContext.js +92 -49
- package/dist/contexts/EventCallbackContext.js +30 -0
- package/dist/contexts/GlobalCurrentPage.js +13 -10
- package/dist/contexts/PagesRotateContext.js +21 -15
- package/dist/contexts/PaginationContext.js +7 -5
- package/dist/contexts/PrintContext.js +7 -5
- package/dist/contexts/RPDocumentContext.js +21 -19
- package/dist/contexts/RenderQueueProvider.js +7 -5
- package/dist/contexts/SearchContext.js +7 -5
- package/dist/contexts/ThumbnailsContext.js +7 -5
- package/dist/contexts/ZoomContext.js +13 -12
- package/dist/main.js +86 -84
- package/dist/types/contexts/EventCallbackContext.d.ts +5 -0
- package/dist/types/utils/getElementPositionInPage.d.ts +5 -0
- package/dist/types/utils/link_service.d.ts +8 -0
- package/dist/types/utils/types.d.ts +10 -1
- package/dist/utils/getElementPositionInPage.js +84 -0
- package/dist/utils/hooks/useFileDownload.js +5 -3
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +49 -47
- package/dist/utils/hooks/useLoadWorker.js +8 -8
- package/dist/utils/hooks/usePageRotateContext.js +3 -2
- package/dist/utils/hooks/usePaginate.js +5 -3
- package/dist/utils/hooks/usePinch.js +15 -14
- package/dist/utils/hooks/usePresentPage.js +5 -3
- package/dist/utils/hooks/usePrint.js +5 -3
- package/dist/utils/hooks/useScrollToPage.js +4 -2
- package/dist/utils/hooks/useSearch.js +4 -2
- package/dist/utils/hooks/useThumbnail.js +5 -3
- package/dist/utils/hooks/useVirtualReactWindow.js +5 -3
- package/dist/utils/injectPrintCSS.js +11 -11
- package/dist/utils/link_service.js +14 -5
- package/dist/utils/renderPage.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function g(e, o) {
|
|
2
|
+
!e || typeof e != "object" || Object.entries(e).forEach(([d, i]) => {
|
|
3
|
+
if (i == null)
|
|
4
|
+
return;
|
|
5
|
+
const s = d.replace(/([A-Z])/g, "-$1").toLowerCase(), n = [
|
|
6
|
+
"width",
|
|
7
|
+
"height",
|
|
8
|
+
"top",
|
|
9
|
+
"right",
|
|
10
|
+
"bottom",
|
|
11
|
+
"left",
|
|
12
|
+
"margin",
|
|
13
|
+
"margin-top",
|
|
14
|
+
"margin-right",
|
|
15
|
+
"margin-bottom",
|
|
16
|
+
"margin-left",
|
|
17
|
+
"padding",
|
|
18
|
+
"padding-top",
|
|
19
|
+
"padding-right",
|
|
20
|
+
"padding-bottom",
|
|
21
|
+
"padding-left",
|
|
22
|
+
"border-width",
|
|
23
|
+
"border-top-width",
|
|
24
|
+
"border-right-width",
|
|
25
|
+
"border-bottom-width",
|
|
26
|
+
"border-left-width",
|
|
27
|
+
"font-size",
|
|
28
|
+
"line-height",
|
|
29
|
+
"letter-spacing",
|
|
30
|
+
"word-spacing",
|
|
31
|
+
"min-width",
|
|
32
|
+
"min-height",
|
|
33
|
+
"max-width",
|
|
34
|
+
"max-height",
|
|
35
|
+
"flex-basis",
|
|
36
|
+
"grid-gap",
|
|
37
|
+
"grid-row-gap",
|
|
38
|
+
"grid-column-gap"
|
|
39
|
+
];
|
|
40
|
+
let t;
|
|
41
|
+
typeof i == "number" && i !== 0 ? t = n.includes(s) ? `${i}px` : String(i) : t = String(i), o.style.setProperty(s, t);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const f = (e, o, d, i, s) => {
|
|
45
|
+
let n = "center";
|
|
46
|
+
switch (i) {
|
|
47
|
+
case 90:
|
|
48
|
+
n = `${e.width / 2}px ${e.width / 2}px`;
|
|
49
|
+
break;
|
|
50
|
+
case -90:
|
|
51
|
+
case 270:
|
|
52
|
+
n = `${e.height / 2}px ${e.height / 2}px`;
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
n = "center";
|
|
56
|
+
}
|
|
57
|
+
const t = document.createElement("div");
|
|
58
|
+
t.id = "parent-element", t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.style.setProperty("--scale-factor", s.toString()), t.style.setProperty("--rotation", i.toString()), t.style.setProperty("--transform-origin", n), t.style.left = "-99999px", t.style.visibility = "hidden", t.style.position = "absolute";
|
|
59
|
+
const l = document.createElement("div");
|
|
60
|
+
l.style.position = "relative", l.style.width = "100%", l.style.height = "100%", t.appendChild(l);
|
|
61
|
+
let r;
|
|
62
|
+
if (d instanceof HTMLElement)
|
|
63
|
+
r = d.cloneNode(!0), l.appendChild(r);
|
|
64
|
+
else {
|
|
65
|
+
const p = d.props;
|
|
66
|
+
r = document.createElement("div"), p.style && g(p.style, r), p.className && (r.className = p.className), l.appendChild(r);
|
|
67
|
+
}
|
|
68
|
+
o.appendChild(t);
|
|
69
|
+
const c = t.getBoundingClientRect(), h = r.getBoundingClientRect();
|
|
70
|
+
o.removeChild(t);
|
|
71
|
+
const a = {
|
|
72
|
+
top: o.clientHeight / 2,
|
|
73
|
+
left: o.clientWidth / 2
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
left: h.left - c.left - a.left,
|
|
77
|
+
top: h.top - c.top - a.top,
|
|
78
|
+
width: h.width,
|
|
79
|
+
height: h.height
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
f as getElementPagePosition
|
|
84
|
+
};
|
|
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
4
|
import "../../contexts/DocumentPasswordContext.js";
|
|
5
|
-
import { b as
|
|
5
|
+
import { b as Hr } from "../../ToolbarLayout.module-185b677e.js";
|
|
6
6
|
import "../../contexts/DarkModeContext.js";
|
|
7
7
|
import "../../contexts/RotationContext.js";
|
|
8
8
|
import "../../contexts/LayerContext.js";
|
|
@@ -30,6 +30,7 @@ import "../../contexts/LoaderContext.js";
|
|
|
30
30
|
import "../../contexts/ToolComponentContext.js";
|
|
31
31
|
import "../../contexts/IconToolContext.js";
|
|
32
32
|
import "../../contexts/OtherToolContext.js";
|
|
33
|
+
import "../../contexts/EventCallbackContext.js";
|
|
33
34
|
import "../../components/RPConfig.js";
|
|
34
35
|
import "../../components/layout/Container.js";
|
|
35
36
|
import "../../contexts/ViewportContext.js";
|
|
@@ -82,13 +83,14 @@ import "../../components/page/CustomElement.js";
|
|
|
82
83
|
import "../getZoomLevel.js";
|
|
83
84
|
import "./useDebounce.js";
|
|
84
85
|
import "./useLicense.js";
|
|
86
|
+
import "../getScrollDistance.js";
|
|
87
|
+
import "../getElementPositionInPage.js";
|
|
85
88
|
import "../calculatePage.js";
|
|
86
89
|
import "./useMousePressed.js";
|
|
87
90
|
import "./useGrabScroll.js";
|
|
88
91
|
import "./usePinch.js";
|
|
89
92
|
import "../../components/ui/PasswordModal.js";
|
|
90
93
|
import "./useLocalization.js";
|
|
91
|
-
import "../getScrollDistance.js";
|
|
92
94
|
import "../getWordPositionInPage.js";
|
|
93
95
|
import "../smoothScrollTo.js";
|
|
94
96
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
@@ -136,5 +138,5 @@ import "./useLoadWorker.js";
|
|
|
136
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
137
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
138
140
|
export {
|
|
139
|
-
|
|
141
|
+
Hr as useFileDownload
|
|
140
142
|
};
|
|
@@ -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-11-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-11-26T01:53:04.326Z"), 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,80 +1,82 @@
|
|
|
1
|
-
import { useState as a, useRef as
|
|
2
|
-
import * as
|
|
3
|
-
import { ErrorType as
|
|
4
|
-
import { getThumbnailViewport as
|
|
5
|
-
import { useConfigContext as
|
|
6
|
-
import { useDocumentPasswordContext as
|
|
1
|
+
import { useState as a, useRef as O, useEffect as T } from "react";
|
|
2
|
+
import * as C from "pdfjs-dist";
|
|
3
|
+
import { ErrorType as U } from "../types.js";
|
|
4
|
+
import { getThumbnailViewport as h } from "../getThumbnailViewport.js";
|
|
5
|
+
import { useConfigContext as j } from "../../contexts/ConfigContext.js";
|
|
6
|
+
import { useDocumentPasswordContext as A } 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
|
-
|
|
10
|
+
const Q = (l, s, I = {}) => {
|
|
11
|
+
const [n, S] = a(), { workerUrlAdded: k } = j(), [q, x] = a(/* @__PURE__ */ new Map()), d = O(), [m, P] = a(0), [g, V] = a(!1), [v, D] = a(), { password: u, passwordError: N, setPasswordError: c, passwordRequired: p, setPasswordRequired: w } = A(), { onLoadError: i, onLoaded: E, onLoadProgress: R } = I;
|
|
12
|
+
return T(() => {
|
|
13
|
+
R && R(m);
|
|
14
|
+
}, [m, R]), T(() => {
|
|
15
|
+
if (!k || !l)
|
|
14
16
|
return;
|
|
15
|
-
|
|
16
|
-
const r = d.current,
|
|
17
|
-
url:
|
|
18
|
-
cMapPacked: (
|
|
19
|
-
...(
|
|
17
|
+
P(0), d.current = Date.now();
|
|
18
|
+
const r = d.current, b = {
|
|
19
|
+
url: l,
|
|
20
|
+
cMapPacked: (s == null ? void 0 : s.isCompressed) ?? !0,
|
|
21
|
+
...(s == null ? void 0 : s.url) && { cMapUrl: s.url },
|
|
20
22
|
...u && { password: u },
|
|
21
|
-
verbosity:
|
|
23
|
+
verbosity: C.VerbosityLevel.ERRORS
|
|
22
24
|
};
|
|
23
25
|
try {
|
|
24
|
-
const e =
|
|
26
|
+
const e = C.getDocument(b);
|
|
25
27
|
e.onProgress = (o) => {
|
|
26
28
|
if (r === d.current) {
|
|
27
|
-
const { loaded:
|
|
28
|
-
|
|
29
|
+
const { loaded: y, total: f } = o, L = f ? Math.min(100, Math.round(y / f * 100)) : 0;
|
|
30
|
+
P(L);
|
|
29
31
|
}
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
o instanceof Error && o.name === "PasswordException" ? (
|
|
32
|
+
}, V(!0);
|
|
33
|
+
const t = e.promise.then((o) => (r === d.current && (S(o), P(100)), E && E(o), w(!1), c(""), o)).catch((o) => {
|
|
34
|
+
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);
|
|
33
35
|
}).finally(() => {
|
|
34
|
-
|
|
36
|
+
V(!1);
|
|
35
37
|
});
|
|
36
38
|
return () => {
|
|
37
|
-
|
|
39
|
+
t.finally(() => {
|
|
38
40
|
e.destroy();
|
|
39
41
|
});
|
|
40
42
|
};
|
|
41
43
|
} catch (e) {
|
|
42
|
-
|
|
44
|
+
D(U.NOT_SUPPORTED), i && i(e);
|
|
43
45
|
}
|
|
44
|
-
}, [
|
|
45
|
-
if (
|
|
46
|
+
}, [l, k, u, i, E]), T(() => {
|
|
47
|
+
if (p)
|
|
46
48
|
return;
|
|
47
49
|
const r = /* @__PURE__ */ new Map();
|
|
48
|
-
if (!n ||
|
|
49
|
-
|
|
50
|
+
if (!n || g) {
|
|
51
|
+
x(r);
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
|
-
const
|
|
53
|
-
for (let
|
|
54
|
-
const o = n.getPage(
|
|
54
|
+
const b = n.numPages, e = [];
|
|
55
|
+
for (let t = 1; t <= b; t++) {
|
|
56
|
+
const o = n.getPage(t);
|
|
55
57
|
e.push(o);
|
|
56
58
|
}
|
|
57
|
-
Promise.all(e).then((
|
|
58
|
-
|
|
59
|
-
const { thumbnailViewport:
|
|
59
|
+
Promise.all(e).then((t) => {
|
|
60
|
+
t.map((o) => {
|
|
61
|
+
const { thumbnailViewport: y, scale: f } = h(o), L = o.getViewport();
|
|
60
62
|
r.set(o.pageNumber, {
|
|
61
63
|
page: o,
|
|
62
|
-
thumbnailViewport:
|
|
63
|
-
thumbnailScale:
|
|
64
|
-
defaultRotation:
|
|
64
|
+
thumbnailViewport: y,
|
|
65
|
+
thumbnailScale: f,
|
|
66
|
+
defaultRotation: L.rotation
|
|
65
67
|
});
|
|
66
|
-
}),
|
|
68
|
+
}), x(r);
|
|
67
69
|
});
|
|
68
|
-
}, [n,
|
|
70
|
+
}, [n, g, p]), {
|
|
69
71
|
pdf: n,
|
|
70
|
-
pages:
|
|
71
|
-
loading:
|
|
72
|
-
error:
|
|
73
|
-
loadingProgress:
|
|
74
|
-
passwordRequired:
|
|
75
|
-
passwordError:
|
|
72
|
+
pages: q,
|
|
73
|
+
loading: g,
|
|
74
|
+
error: v,
|
|
75
|
+
loadingProgress: m,
|
|
76
|
+
passwordRequired: p,
|
|
77
|
+
passwordError: N
|
|
76
78
|
};
|
|
77
79
|
};
|
|
78
80
|
export {
|
|
79
|
-
|
|
81
|
+
Q as useLoadPdf
|
|
80
82
|
};
|