@react-pdf-kit/viewer 2.8.0-beta.1 → 2.8.0-beta.10
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/README.md +44 -30
- package/dist/{AnnotationLayer-C6UTOVmc.js → AnnotationLayer-CyOYh0Tw.js} +2 -2
- package/dist/CanvasLayer-CJqCJ30J.js +111 -0
- package/dist/{LoadingIndicator-Bzzf28Xv.js → LoadingIndicator-0E8WHnSN.js} +7 -7
- package/dist/MenuItem-lItnKNd5.js +31 -0
- package/dist/Paginate.module-DhE7N8AA.js +9 -0
- package/dist/PaginationContext-DIzsZhFd.js +194 -0
- package/dist/{PasswordModal-BeLyLUsu.js → PasswordModal-CxHFn0pB.js} +12 -12
- package/dist/RPLayout.module-BH5r8dDc.js +14 -0
- package/dist/RPPages-U8QNLlIa.js +686 -0
- package/dist/{RPTooltip-CXBVXusS.js → RPTooltip-QWwWh4HW.js} +123 -91
- package/dist/SearchTool.module-DY8Ucfb_.js +17 -0
- package/dist/{SkipLink-CdcjClGB.js → SkipLink-Dj83gZdk.js} +3 -3
- package/dist/{TextLayer-DWGFN9SF.js → TextLayer-D-V9kogG.js} +5 -5
- package/dist/{Thumbnail-BO3QHzxR.js → Thumbnail-BXMk0OWF.js} +6 -6
- package/dist/{Thumbnails-DyeBsQJT.js → Thumbnails-BIuN8LZ8.js} +2 -2
- package/dist/assets/AnnotationLayer.css +1 -1
- package/dist/assets/CanvasLayer.css +1 -0
- package/dist/assets/LoadingIndicator.css +1 -1
- package/dist/assets/MenuItem.css +1 -1
- package/dist/assets/Paginate.css +1 -1
- package/dist/assets/PasswordModal.css +1 -1
- package/dist/assets/RPLayout.css +1 -1
- package/dist/assets/RPPages.css +1 -1
- package/dist/assets/SearchTool.css +1 -1
- package/dist/assets/SkipLink.css +1 -1
- package/dist/assets/TextLayer.css +1 -1
- package/dist/assets/Thumbnail.css +1 -1
- package/dist/assets/style.js +1 -1
- package/dist/components/RPController.js +39 -39
- package/dist/components/RPPages.js +1 -1
- package/dist/components/RPProvider.js +1 -1
- package/dist/components/layout/LayoutContainer.js +6 -6
- package/dist/components/layout/LayoutWrapper.js +5 -5
- package/dist/components/layout/RPDefaultLayout.js +56 -55
- package/dist/components/layout/RPLayout.js +39 -38
- package/dist/components/layout/SkipLink.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +2 -2
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DarkModeTool.js +1 -1
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
- package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
- package/dist/components/layout/toolbar/FullScreenTool.js +9 -8
- package/dist/components/layout/toolbar/MenuItem.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +23 -29
- package/dist/components/layout/toolbar/OtherTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +18 -3
- package/dist/components/layout/toolbar/PrintTool.js +6 -6
- package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
- package/dist/components/layout/toolbar/RPMoreOptions.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RotateTool.js +10 -10
- package/dist/components/layout/toolbar/ScrollModeTool.js +17 -17
- package/dist/components/layout/toolbar/SearchCloseButton.js +2 -2
- package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
- package/dist/components/layout/toolbar/SearchTool.js +133 -121
- package/dist/components/layout/toolbar/SelectionModeTool.js +10 -10
- package/dist/components/layout/toolbar/ThumbnailTool.js +1 -1
- package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
- package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
- package/dist/components/layout/toolbar/ViewModeTool.js +16 -16
- package/dist/components/layout/toolbar/ZoomTool.js +82 -80
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +1 -1
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +3 -3
- package/dist/components/layout/toolbar/tools/InputPageTool.js +36 -25
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +1 -1
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PrintTool.js +1 -1
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +1 -1
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +1 -1
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +1 -1
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +1 -1
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +1 -1
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +25 -23
- package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +1 -1
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +25 -23
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +3 -3
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +7 -7
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +2 -48
- package/dist/components/page/DualPage.js +2 -2
- package/dist/components/page/DualPageWithCover.js +2 -2
- package/dist/components/page/RPPage.js +94 -2
- package/dist/components/page/SinglePage.js +2 -2
- package/dist/components/page/TextHighlightLayer.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +1 -1
- package/dist/components/ui/RPTooltip.js +1 -1
- package/dist/contexts/DimensionPagesContext.js +38 -22
- package/dist/contexts/ElementPageContext.js +46 -39
- package/dist/contexts/ElementThumbnailContext.js +1 -1
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +26 -18
- package/dist/contexts/RenderedPagesCache.js +32 -13
- package/dist/contexts/VirtualScrollContext.js +10 -13
- package/dist/contexts/ZoomContext.js +119 -61
- package/dist/{de_DE--0LF-SJR.js → de_DE-x4Z-jQrz.js} +54 -6
- package/dist/{main-0RC2E65p.js → main-DCzVrq0G.js} +2 -2
- package/dist/main.js +4 -4
- package/dist/style-CJtyyrJx.js +5 -0
- package/dist/types/components/page/CanvasLayer.d.ts +4 -1
- package/dist/types/components/ui/RPTooltip.d.ts +3 -2
- package/dist/types/contexts/RenderQueueProvider.d.ts +2 -0
- package/dist/types/contexts/RenderedPagesCache.d.ts +3 -0
- package/dist/types/contexts/VirtualScrollContext.d.ts +0 -3
- package/dist/types/locales/de_DE.json.d.ts +11 -2
- package/dist/types/locales/en_US.json.d.ts +11 -2
- package/dist/types/locales/it_IT.json.d.ts +11 -2
- package/dist/types/locales/pt_PT.json.d.ts +11 -2
- package/dist/types/locales/th_TH.json.d.ts +11 -2
- package/dist/types/locales/zh_CN.json.d.ts +11 -2
- package/dist/types/utils/Queue.d.ts +1 -0
- package/dist/types/utils/const.d.ts +3 -0
- package/dist/types/utils/constants.d.ts +9 -0
- package/dist/types/utils/documentLayout.d.ts +60 -0
- package/dist/types/utils/hooks/usePinch.d.ts +14 -1
- package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
- package/dist/types/utils/hooks/useZoomOrigin.d.ts +4 -0
- package/dist/types/utils/types.d.ts +24 -2
- package/dist/types/utils/zoom.d.ts +2 -0
- package/dist/utils/Queue.js +5 -0
- package/dist/utils/const.js +2 -2
- package/dist/utils/constants.js +2 -2
- package/dist/utils/documentLayout.js +141 -0
- 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/usePinch.js +109 -56
- package/dist/utils/hooks/usePresentPage.js +33 -57
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +66 -67
- package/dist/utils/hooks/useZoomOrigin.js +37 -0
- package/dist/utils/renderPage.js +21 -14
- package/dist/utils/types.js +3 -3
- package/dist/utils/zoom.js +8 -2
- package/package.json +1 -1
- package/dist/MenuItem-9kCH_GQ0.js +0 -15
- package/dist/Paginate.module-B0GMw-MB.js +0 -8
- package/dist/PaginationContext-C5CJiEW-.js +0 -242
- package/dist/RPLayout.module-Vc3h4xxS.js +0 -14
- package/dist/RPPage-BsDixmqF.js +0 -91
- package/dist/RPPages-Cf-FDd0a.js +0 -1007
- package/dist/SearchTool.module-DUkVXfOn.js +0 -16
- package/dist/assets/RPPage.css +0 -1
- package/dist/contexts/VirtualGridContext.js +0 -18
- package/dist/style-BPQRJJJ7.js +0 -5
- package/dist/types/contexts/VirtualGridContext.d.ts +0 -9
- package/dist/types/utils/calculatePage.d.ts +0 -12
- package/dist/types/utils/hooks/useVirtualReactWindow.d.ts +0 -17
- package/dist/utils/calculatePage.js +0 -30
- package/dist/utils/hooks/useVirtualReactWindow.js +0 -86
- /package/dist/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
|
@@ -1,51 +1,58 @@
|
|
|
1
|
-
import { LicenseType as e
|
|
2
|
-
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as
|
|
3
|
-
import { useScrollModeContext as
|
|
4
|
-
import { useViewModeContext as
|
|
5
|
-
import { useVirtualScrollContext as
|
|
6
|
-
import { useLayoutContainer as
|
|
7
|
-
import { useZoomContext as
|
|
8
|
-
import { usePagesRotateContext as
|
|
9
|
-
import { useDimensionPagesContext as
|
|
10
|
-
import { useSmoothScrollContext as
|
|
11
|
-
import {
|
|
1
|
+
import { LicenseType as e } from "../utils/types.js";
|
|
2
|
+
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as t } from "../utils/const.js";
|
|
3
|
+
import { useScrollModeContext as n } from "./ScrollModeContext.js";
|
|
4
|
+
import { useViewModeContext as r } from "./ViewModeContext.js";
|
|
5
|
+
import { useVirtualScrollContext as i } from "./VirtualScrollContext.js";
|
|
6
|
+
import { useLayoutContainer as a } from "./LayoutContainerContext.js";
|
|
7
|
+
import { useZoomContext as o } from "./ZoomContext.js";
|
|
8
|
+
import { usePagesRotateContext as s } from "./PagesRotateContext.js";
|
|
9
|
+
import { useDimensionPagesContext as c } from "./DimensionPagesContext.js";
|
|
10
|
+
import { useSmoothScrollContext as l } from "./SmoothScrollContext.js";
|
|
11
|
+
import { buildDocumentLayout as u, getPagePlacement as d } from "../utils/documentLayout.js";
|
|
12
12
|
import { useLicenseContext as f } from "./LicenseContext.js";
|
|
13
13
|
import { getElementPagePosition as p } from "../utils/getElementPositionInPage.js";
|
|
14
14
|
import { createContext as m, useCallback as h, useContext as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
15
15
|
import { jsx as b } from "react/jsx-runtime";
|
|
16
16
|
//#region lib/contexts/ElementPageContext.tsx
|
|
17
17
|
var x = m(void 0), S = ({ children: e }) => {
|
|
18
|
-
let [
|
|
19
|
-
let
|
|
20
|
-
if (!_ || !
|
|
21
|
-
let
|
|
22
|
-
if (!
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
let [t, f] = y({}), { widths: m, heights: g } = c(), { pagesRef: _ } = a(), { scrollMode: v } = n(), { pageRotate: S } = s(), { currentZoom: C } = o(), { viewMode: w } = r(), { pageScrollElementRef: T, virtualScrollableElementRef: E } = i(), { scrollBehavior: D } = l(), O = h((e, n, r) => {
|
|
19
|
+
let i = r ?? { behavior: D }, a = E || T;
|
|
20
|
+
if (!_ || !a) return;
|
|
21
|
+
let o = t[e]?.[n];
|
|
22
|
+
if (!o) return;
|
|
23
|
+
let s = u({
|
|
24
|
+
pageDimensions: {
|
|
25
|
+
widths: m,
|
|
26
|
+
heights: g
|
|
27
|
+
},
|
|
28
|
+
viewportWidth: a.clientWidth,
|
|
29
|
+
viewportHeight: a.clientHeight,
|
|
30
|
+
scrollMode: v,
|
|
31
|
+
viewMode: w,
|
|
32
|
+
focusedPage: e
|
|
33
|
+
}), c = d(s, e);
|
|
34
|
+
if (!c) return;
|
|
35
|
+
let l = {
|
|
30
36
|
height: g[e - 1],
|
|
31
37
|
width: m[e - 1]
|
|
32
|
-
}, f = S[e], { left: h, top: y } = p(
|
|
38
|
+
}, f = S[e], { left: h, top: y } = p(l, _, o, f, C), b = s.offsetLeft + c.left + h, x = s.offsetTop + c.top + y, O = {
|
|
33
39
|
left: Math.max(b, 0),
|
|
34
40
|
top: Math.max(x, 0)
|
|
35
41
|
};
|
|
36
|
-
|
|
42
|
+
a.scrollTo({
|
|
37
43
|
...O,
|
|
38
|
-
behavior:
|
|
44
|
+
behavior: i.behavior
|
|
39
45
|
});
|
|
40
46
|
}, [
|
|
41
|
-
|
|
47
|
+
C,
|
|
48
|
+
t,
|
|
42
49
|
g,
|
|
43
|
-
m,
|
|
44
|
-
_,
|
|
45
50
|
S,
|
|
46
|
-
|
|
51
|
+
_,
|
|
52
|
+
D,
|
|
47
53
|
v,
|
|
48
|
-
|
|
54
|
+
w,
|
|
55
|
+
m
|
|
49
56
|
]), k = h((e, t) => {
|
|
50
57
|
f((n) => {
|
|
51
58
|
let r = {
|
|
@@ -78,13 +85,13 @@ var x = m(void 0), S = ({ children: e }) => {
|
|
|
78
85
|
updateElement: k,
|
|
79
86
|
clearElements: A,
|
|
80
87
|
removeElement: j,
|
|
81
|
-
elementList:
|
|
88
|
+
elementList: t,
|
|
82
89
|
scrollToElement: O
|
|
83
90
|
},
|
|
84
91
|
children: e
|
|
85
92
|
});
|
|
86
93
|
}, C = () => {}, w = () => {
|
|
87
|
-
let
|
|
94
|
+
let n = g(x), { type: r, validating: i } = f(), a = v(0), o = _(() => {
|
|
88
95
|
if (i !== !1) return {
|
|
89
96
|
updateElement: C,
|
|
90
97
|
clearElements: C,
|
|
@@ -94,22 +101,22 @@ var x = m(void 0), S = ({ children: e }) => {
|
|
|
94
101
|
};
|
|
95
102
|
if (r === e.Developer) return {
|
|
96
103
|
updateElement: () => {
|
|
97
|
-
a.current === 0 && (console.error(
|
|
104
|
+
a.current === 0 && (console.error(t), a.current++);
|
|
98
105
|
},
|
|
99
106
|
clearElements: () => {
|
|
100
|
-
a.current === 0 && (console.error(
|
|
107
|
+
a.current === 0 && (console.error(t), a.current++);
|
|
101
108
|
},
|
|
102
109
|
removeElement: () => {
|
|
103
|
-
a.current === 0 && (console.error(
|
|
110
|
+
a.current === 0 && (console.error(t), a.current++);
|
|
104
111
|
},
|
|
105
112
|
elementList: {},
|
|
106
113
|
scrollToElement: () => {
|
|
107
|
-
a.current === 0 && (console.error(
|
|
114
|
+
a.current === 0 && (console.error(t), a.current++);
|
|
108
115
|
}
|
|
109
116
|
};
|
|
110
117
|
}, [r, i]);
|
|
111
|
-
if (!
|
|
112
|
-
return o ||
|
|
118
|
+
if (!n) throw Error("useElementPageContext must be used within a ElementPageProvider");
|
|
119
|
+
return o || n;
|
|
113
120
|
};
|
|
114
121
|
//#endregion
|
|
115
122
|
export { x as ElementPageContext, S as ElementPageProvider, w as useElementPageContext };
|
|
@@ -2,7 +2,7 @@ import { LicenseType as e } from "../utils/types.js";
|
|
|
2
2
|
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as t } from "../utils/const.js";
|
|
3
3
|
import { usePagesRotateContext as n } from "./PagesRotateContext.js";
|
|
4
4
|
import { useSmoothScrollContext as r } from "./SmoothScrollContext.js";
|
|
5
|
-
import { r as i } from "../PaginationContext-
|
|
5
|
+
import { r as i } from "../PaginationContext-DIzsZhFd.js";
|
|
6
6
|
import { useThumbnailContext as a } from "./ThumbnailsContext.js";
|
|
7
7
|
import { useLicenseContext as o } from "./LicenseContext.js";
|
|
8
8
|
import { createContext as s, useCallback as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../PaginationContext-
|
|
1
|
+
import { n as e, r as t, t as n } from "../PaginationContext-DIzsZhFd.js";
|
|
2
2
|
export { n as PaginationContext, e as PaginationProvider, t as usePaginationContext };
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
import { r as e } from "../PaginationContext-
|
|
1
|
+
import { r as e } from "../PaginationContext-DIzsZhFd.js";
|
|
2
2
|
import { Queue as t } from "../utils/Queue.js";
|
|
3
3
|
import { renderPage as n } from "../utils/renderPage.js";
|
|
4
4
|
import { createContext as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
5
5
|
import { jsx as u } from "react/jsx-runtime";
|
|
6
6
|
//#region lib/contexts/RenderQueueProvider.tsx
|
|
7
7
|
var d = r(null), f = ({ children: r }) => {
|
|
8
|
-
let a = c(!1),
|
|
9
|
-
|
|
8
|
+
let a = c(!1), f = c(/* @__PURE__ */ new Map()), [p, m] = l([]), h = i((e) => {
|
|
9
|
+
m((t) => [...t, {
|
|
10
10
|
id: e.page.pageNumber.toString(),
|
|
11
11
|
data: e,
|
|
12
12
|
priority: 0
|
|
13
13
|
}]);
|
|
14
|
-
}, []),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
}, []), g = s(() => new t(h), [h]), { focusedPage: _ } = e(), v = i((e) => {
|
|
15
|
+
a.current = !0;
|
|
16
|
+
let t = f.current.get(e.id);
|
|
17
|
+
t && (t.cancel(), f.current.delete(e.id));
|
|
18
|
+
let r = n(e.data.page, e.data.canvasElem, e.data.options);
|
|
19
|
+
return f.current.set(e.id, r), e.data.onRenderTask?.(r), r.promise.then(() => {
|
|
20
|
+
e.data.canvasElem.hidden = !1, e.data.onLoaded && e.data.onLoaded();
|
|
21
|
+
}).catch((t) => {
|
|
22
|
+
t.name !== "RenderingCancelledException" && console.error(`Error rendering page ${e.data.page.pageNumber}:`, t);
|
|
23
|
+
}).finally(() => {
|
|
24
|
+
f.current.delete(e.id), e.data.onRenderTask?.(null);
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
19
27
|
return o(() => {
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
if (
|
|
28
|
+
_ && (g.changePagePriority(`^page-${_}`, 0), g.changePagePriority(`^thumbnail-${_}`, 1));
|
|
29
|
+
}, [_]), o(() => {
|
|
30
|
+
if (g.isEmpty() || a.current) return;
|
|
23
31
|
let e = () => {
|
|
24
|
-
let t =
|
|
25
|
-
t ?
|
|
32
|
+
let t = g.dequeue();
|
|
33
|
+
t ? v(t).catch(() => {}).finally(() => {
|
|
26
34
|
e();
|
|
27
|
-
}) : (a.current = !1,
|
|
35
|
+
}) : (a.current = !1, m(g.peekAll()));
|
|
28
36
|
};
|
|
29
37
|
e();
|
|
30
38
|
}, [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
g,
|
|
40
|
+
v,
|
|
41
|
+
p
|
|
34
42
|
]), /* @__PURE__ */ u(d.Provider, {
|
|
35
|
-
value:
|
|
43
|
+
value: g,
|
|
36
44
|
children: r
|
|
37
45
|
});
|
|
38
46
|
}, p = () => {
|
|
@@ -1,18 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useDocumentContext as e } from "./RPDocumentContext.js";
|
|
2
|
+
import { createContext as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useRef as o } from "react";
|
|
3
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
4
|
//#region lib/contexts/RenderedPagesCache.tsx
|
|
4
|
-
var
|
|
5
|
+
var c = t({
|
|
5
6
|
viewports: /* @__PURE__ */ new Map(),
|
|
6
|
-
pages: /* @__PURE__ */ new Map()
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
pages: /* @__PURE__ */ new Map(),
|
|
8
|
+
hasRenderedPage: () => !1,
|
|
9
|
+
markRenderedPage: () => {},
|
|
10
|
+
clearRenderedPages: () => {}
|
|
11
|
+
}), l = () => r(c), u = ({ children: t }) => {
|
|
12
|
+
let { pdfSrc: r } = e(), l = o(/* @__PURE__ */ new Map()), u = o(/* @__PURE__ */ new Map()), d = o(/* @__PURE__ */ new Set()), f = n((e) => d.current.has(e), []), p = n((e) => {
|
|
13
|
+
d.current.add(e);
|
|
14
|
+
}, []), m = n(() => {
|
|
15
|
+
d.current.clear();
|
|
16
|
+
}, []);
|
|
17
|
+
i(() => {
|
|
18
|
+
d.current.clear();
|
|
19
|
+
}, [r]);
|
|
20
|
+
let h = a(() => ({
|
|
21
|
+
viewports: l.current,
|
|
22
|
+
pages: u.current,
|
|
23
|
+
hasRenderedPage: f,
|
|
24
|
+
markRenderedPage: p,
|
|
25
|
+
clearRenderedPages: m
|
|
26
|
+
}), [
|
|
27
|
+
m,
|
|
28
|
+
f,
|
|
29
|
+
p
|
|
30
|
+
]);
|
|
31
|
+
return /* @__PURE__ */ s(c.Provider, {
|
|
32
|
+
value: h,
|
|
33
|
+
children: t
|
|
15
34
|
});
|
|
16
35
|
};
|
|
17
36
|
//#endregion
|
|
18
|
-
export {
|
|
37
|
+
export { c as RenderedPagesCacheContext, u as RenderedPagesCacheProvider, l as useRenderedPagesCache };
|
|
@@ -2,7 +2,6 @@ import { createContext as e, useContext as t, useState as n } from "react";
|
|
|
2
2
|
import { jsx as r } from "react/jsx-runtime";
|
|
3
3
|
//#region lib/contexts/VirtualScrollContext.tsx
|
|
4
4
|
var i = e({
|
|
5
|
-
getVirtualScrollRef: () => {},
|
|
6
5
|
getPageScrollElementRef: () => {},
|
|
7
6
|
getVirtualScrollableElementRef: () => {},
|
|
8
7
|
scrollPosition: {
|
|
@@ -16,25 +15,23 @@ var i = e({
|
|
|
16
15
|
},
|
|
17
16
|
setTotalInnerDimensions: () => {}
|
|
18
17
|
}), a = () => t(i), o = ({ children: e }) => {
|
|
19
|
-
let [t, a] = n(), [o, s] = n(), [c, l] = n(
|
|
18
|
+
let [t, a] = n(), [o, s] = n(), [c, l] = n({
|
|
20
19
|
scrollTop: 0,
|
|
21
20
|
scrollLeft: 0
|
|
22
|
-
}), [
|
|
21
|
+
}), [u, d] = n({
|
|
23
22
|
height: 0,
|
|
24
23
|
width: 0
|
|
25
24
|
});
|
|
26
25
|
return /* @__PURE__ */ r(i.Provider, {
|
|
27
26
|
value: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
totalInnerDimensions: f,
|
|
37
|
-
setTotalInnerDimensions: p
|
|
27
|
+
pageScrollElementRef: o,
|
|
28
|
+
getPageScrollElementRef: s,
|
|
29
|
+
virtualScrollableElementRef: t,
|
|
30
|
+
getVirtualScrollableElementRef: a,
|
|
31
|
+
scrollPosition: c,
|
|
32
|
+
setScrollPosition: l,
|
|
33
|
+
totalInnerDimensions: u,
|
|
34
|
+
setTotalInnerDimensions: d
|
|
38
35
|
},
|
|
39
36
|
children: e
|
|
40
37
|
});
|
|
@@ -3,94 +3,152 @@ import { appConsole as t } from "../utils/appConsole.js";
|
|
|
3
3
|
import { useDocumentContext as n } from "./RPDocumentContext.js";
|
|
4
4
|
import { useInitialStateContext as r } from "./InitialStateContext.js";
|
|
5
5
|
import { useViewModeContext as i } from "./ViewModeContext.js";
|
|
6
|
-
import "../utils/constants.js";
|
|
7
|
-
import { getZoomLevel as
|
|
8
|
-
import { useLayoutContainer as
|
|
9
|
-
import { useRotationContext as
|
|
10
|
-
import { useGlobalCurrentPage as
|
|
11
|
-
import { useDebounce as
|
|
12
|
-
import { createContext as
|
|
13
|
-
import { jsx as
|
|
6
|
+
import { MAX_ZOOM_SCALE as a, ZOOM_SAFETY_TIMEOUT_MS as o } from "../utils/constants.js";
|
|
7
|
+
import { getZoomLevel as s } from "../utils/getZoomLevel.js";
|
|
8
|
+
import { useLayoutContainer as c } from "./LayoutContainerContext.js";
|
|
9
|
+
import { useRotationContext as ee } from "./RotationContext.js";
|
|
10
|
+
import { useGlobalCurrentPage as te } from "./GlobalCurrentPage.js";
|
|
11
|
+
import { useDebounce as ne } from "../utils/hooks/useDebounce.js";
|
|
12
|
+
import { createContext as l, useCallback as u, useContext as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
13
|
+
import { jsx as re } from "react/jsx-runtime";
|
|
14
14
|
//#region lib/contexts/ZoomContext.tsx
|
|
15
|
-
var
|
|
15
|
+
var g = l({
|
|
16
16
|
zoomLevel: 100,
|
|
17
17
|
currentZoom: 1,
|
|
18
|
+
targetZoom: 1,
|
|
19
|
+
isZooming: !1,
|
|
20
|
+
zoomOrigin: null,
|
|
21
|
+
zoomGesture: null,
|
|
22
|
+
previousTargetZoom: null,
|
|
23
|
+
zoomTo: () => {},
|
|
18
24
|
setZoomLevel: () => {}
|
|
19
|
-
}),
|
|
20
|
-
let e =
|
|
25
|
+
}), _ = () => {
|
|
26
|
+
let e = d(g);
|
|
21
27
|
return typeof e.currentZoom != "number" && t.warn("Please use this hooks inside children component of RPProvider"), e;
|
|
22
|
-
},
|
|
23
|
-
let { initialScale:
|
|
24
|
-
width:
|
|
25
|
-
height:
|
|
26
|
-
}),
|
|
27
|
-
|
|
28
|
-
let e =
|
|
29
|
-
e ||=
|
|
28
|
+
}, v = ({ children: t }) => {
|
|
29
|
+
let { initialScale: l = e.PAGE_FIT } = r(), [d, _] = h(l), [v, ie] = h(0), [y, b] = h(0), [x, S] = h(!1), [C, w] = h(null), [T, E] = h(null), [D, O] = h(null), k = m(0), A = m(0), { pages: j } = n(), { pagesRef: M } = c(), { viewMode: N } = i(), [ae, P] = h({
|
|
30
|
+
width: M?.clientWidth || 0,
|
|
31
|
+
height: M?.clientHeight || 0
|
|
32
|
+
}), F = ne(ae, 100), { rotate: I } = ee(), [L, R] = h(null), z = m(null), { currentPage: B } = te(), [V, oe] = h(B), H = m(), U = m(), W = m(), G = m({});
|
|
33
|
+
f(() => {
|
|
34
|
+
let e = j.get(V);
|
|
35
|
+
e ||= j.get(1);
|
|
30
36
|
let t = e?.page.getViewport({
|
|
31
37
|
scale: 1,
|
|
32
|
-
rotation: e.defaultRotation +
|
|
38
|
+
rotation: e.defaultRotation + I
|
|
33
39
|
});
|
|
34
|
-
t && JSON.stringify(t) !== JSON.stringify(
|
|
40
|
+
t && JSON.stringify(t) !== JSON.stringify(z.current) && (z.current = t, R(t));
|
|
35
41
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
j,
|
|
43
|
+
I,
|
|
44
|
+
V
|
|
39
45
|
]);
|
|
40
|
-
let
|
|
41
|
-
pageWidth: (
|
|
42
|
-
pageHeight:
|
|
43
|
-
clientWidth:
|
|
44
|
-
clientHeight:
|
|
45
|
-
} : null, [
|
|
46
|
-
let e =
|
|
47
|
-
if (!
|
|
48
|
-
if (typeof
|
|
49
|
-
let { clientWidth: t, clientHeight: n, pageWidth: r, pageHeight: i } = e;
|
|
50
|
-
return
|
|
46
|
+
let K = u(() => L ? {
|
|
47
|
+
pageWidth: (L?.width || 0) + 8,
|
|
48
|
+
pageHeight: L?.height || 0,
|
|
49
|
+
clientWidth: M?.clientWidth || 0,
|
|
50
|
+
clientHeight: M?.clientHeight || 0
|
|
51
|
+
} : null, [L, M]), q = p(() => {
|
|
52
|
+
let e = K();
|
|
53
|
+
if (!F.width || !F.height || !e) return 0;
|
|
54
|
+
if (typeof d == "number") return Math.max(25, Math.min(d, a)) / 100;
|
|
55
|
+
let { clientWidth: t, clientHeight: n, pageWidth: r, pageHeight: i } = e, o = s(d, t, n, r, i, N) / 100;
|
|
56
|
+
return Math.max(25 / 100, Math.min(o, a / 100));
|
|
51
57
|
}, [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
])
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
d,
|
|
59
|
+
F,
|
|
60
|
+
K,
|
|
61
|
+
N
|
|
62
|
+
]), J = u(() => {
|
|
63
|
+
H.current &&= (clearTimeout(H.current), void 0), U.current &&= (clearTimeout(U.current), void 0), W.current &&= (cancelAnimationFrame(W.current), void 0);
|
|
64
|
+
}, []), Y = u((e) => {
|
|
65
|
+
ie(e), S(!1), w(null), E(null), O(null);
|
|
66
|
+
}, []), X = u((e, t = {}) => {
|
|
67
|
+
if (!e) return;
|
|
68
|
+
let n = k.current === 0;
|
|
69
|
+
if (!(!(Math.abs(e - A.current) > 1e-10) && !n)) {
|
|
70
|
+
if (J(), w(t.origin ?? null), E(t.gesture ?? null), O(t.previousTargetZoom ?? A.current ?? k.current ?? null), A.current = e, b(e), n || t.immediate) {
|
|
71
|
+
Y(e);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
S(!0), U.current = setTimeout(() => {
|
|
75
|
+
H.current &&= (clearTimeout(H.current), void 0), W.current &&= (cancelAnimationFrame(W.current), void 0), U.current = void 0, Y(e);
|
|
76
|
+
}, o), W.current = requestAnimationFrame(() => {
|
|
77
|
+
W.current = void 0, H.current = setTimeout(() => {
|
|
78
|
+
H.current = void 0, U.current &&= (clearTimeout(U.current), void 0), Y(e);
|
|
79
|
+
}, 400);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, [J, Y]);
|
|
83
|
+
f(() => {
|
|
84
|
+
if (!q) return;
|
|
85
|
+
let e = G.current;
|
|
86
|
+
G.current = {}, X(q, e);
|
|
87
|
+
}, [q, X]);
|
|
88
|
+
let Z = u((e) => {
|
|
89
|
+
if (typeof e == "number") return Math.max(25, Math.min(e, a)) / 100;
|
|
90
|
+
let t = K();
|
|
91
|
+
if (!t) return 0;
|
|
92
|
+
let { clientWidth: n, clientHeight: r, pageWidth: i, pageHeight: o } = t, c = s(e, n, r, i, o, N);
|
|
93
|
+
return Math.max(25, Math.min(c, a)) / 100;
|
|
94
|
+
}, [K, N]), Q = u((e, t = {}) => {
|
|
95
|
+
G.current = t, _(e), X(Z(e), t);
|
|
96
|
+
}, [Z, X]);
|
|
97
|
+
f(() => {
|
|
98
|
+
y && (A.current = y);
|
|
99
|
+
}, [y]), f(() => {
|
|
100
|
+
v && (k.current = v);
|
|
101
|
+
}, [v]), f(() => () => {
|
|
102
|
+
J();
|
|
103
|
+
}, [J]), f(() => {
|
|
104
|
+
oe(B);
|
|
105
|
+
}, [d]), f(() => {
|
|
60
106
|
let e = new ResizeObserver((e) => {
|
|
61
107
|
e.forEach((e) => {
|
|
62
|
-
|
|
108
|
+
P({
|
|
63
109
|
width: e.contentRect.width,
|
|
64
110
|
height: e.contentRect.height
|
|
65
111
|
});
|
|
66
112
|
});
|
|
67
113
|
});
|
|
68
|
-
return
|
|
114
|
+
return M && e.observe(M), () => {
|
|
69
115
|
e.disconnect();
|
|
70
116
|
};
|
|
71
|
-
}, [
|
|
72
|
-
let
|
|
117
|
+
}, [M]);
|
|
118
|
+
let $ = u((e) => {
|
|
73
119
|
let t = 0;
|
|
74
120
|
if (typeof e == "function") {
|
|
75
|
-
let n =
|
|
121
|
+
let n = K();
|
|
76
122
|
if (!n) return;
|
|
77
|
-
let { clientWidth: r, clientHeight: i, pageWidth:
|
|
78
|
-
t = (t) => e(
|
|
123
|
+
let { clientWidth: r, clientHeight: i, pageWidth: a, pageHeight: o } = n;
|
|
124
|
+
t = (t) => e(s(t, r, i, a, o, N));
|
|
79
125
|
} else t = e;
|
|
80
|
-
t &&
|
|
81
|
-
}, [N]),
|
|
82
|
-
zoomLevel:
|
|
83
|
-
currentZoom:
|
|
84
|
-
|
|
126
|
+
t && (G.current = {}, _(typeof t == "number" ? Math.max(25, Math.min(t, a)) : t));
|
|
127
|
+
}, [K, N]), se = p(() => ({
|
|
128
|
+
zoomLevel: d,
|
|
129
|
+
currentZoom: v,
|
|
130
|
+
targetZoom: y || v,
|
|
131
|
+
isZooming: x,
|
|
132
|
+
zoomOrigin: C,
|
|
133
|
+
zoomGesture: T,
|
|
134
|
+
previousTargetZoom: D,
|
|
135
|
+
zoomTo: Q,
|
|
136
|
+
setZoomLevel: $
|
|
85
137
|
}), [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
138
|
+
v,
|
|
139
|
+
y,
|
|
140
|
+
x,
|
|
141
|
+
d,
|
|
142
|
+
C,
|
|
143
|
+
T,
|
|
144
|
+
D,
|
|
145
|
+
Q,
|
|
146
|
+
$
|
|
89
147
|
]);
|
|
90
|
-
return /* @__PURE__ */
|
|
91
|
-
value:
|
|
148
|
+
return /* @__PURE__ */ re(g.Provider, {
|
|
149
|
+
value: se,
|
|
92
150
|
children: t
|
|
93
151
|
});
|
|
94
152
|
};
|
|
95
153
|
//#endregion
|
|
96
|
-
export {
|
|
154
|
+
export { g as ZoomContext, v as ZoomProvider, _ as useZoomContext };
|