@react-pdf-kit/viewer 2.0.0-beta.1 → 2.0.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 +6 -6
- package/dist/Combination-54a77a7a.js +701 -0
- package/dist/MostPageTool.module-13578ad6.js +6 -0
- package/dist/OtherTool.module-a4be5f1f.js +6 -0
- package/dist/Paginate.module-206a7d7d.js +8 -0
- package/dist/PaginationContext-9217cab4.js +201 -0
- package/dist/{LayoutWrapper-6224491f.js → RPLayout.module-967bf4bc.js} +3 -9
- package/dist/RPToolbar.module-27d7fe77.js +10 -0
- package/dist/SearchTool.module-99f60dc7.js +16 -0
- package/dist/ToolbarLayout.module-1fee0a18.js +11 -0
- package/dist/ZoomTool.module-7082af8c.js +12 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +32 -31
- package/dist/components/RPConfig.js +10 -1485
- package/dist/components/RPController.js +77 -148
- package/dist/components/RPPages.js +981 -124
- package/dist/components/RPProvider.js +56 -118
- package/dist/components/icons/DualPageIcon.js +6 -6
- package/dist/components/icons/SinglePageIcon.js +6 -6
- package/dist/components/layout/LayoutContainer.js +31 -138
- package/dist/components/layout/LayoutWrapper.js +8 -4
- package/dist/components/layout/RPDefaultLayout.js +162 -88
- package/dist/components/layout/RPLayout.js +119 -107
- package/dist/components/layout/sidebar/RPSidebar.js +83 -113
- package/dist/components/layout/sidebar/Thumbnail.js +120 -126
- package/dist/components/layout/sidebar/Thumbnails.js +56 -121
- package/dist/components/layout/toolbar/DarkModeTool.js +6 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +304 -132
- package/dist/components/layout/toolbar/DocumentProperties.js +12 -9
- package/dist/components/layout/toolbar/FileDownloadTool.js +34 -126
- package/dist/components/layout/toolbar/FileUploadTool.js +8 -5
- package/dist/components/layout/toolbar/FullScreenTool.js +16 -13
- package/dist/components/layout/toolbar/MenuItem.js +11 -8
- package/dist/components/layout/toolbar/MenuSeparator.js +8 -5
- package/dist/components/layout/toolbar/MostPageTool.js +64 -125
- package/dist/components/layout/toolbar/OtherTool.js +162 -114
- package/dist/components/layout/toolbar/Paginate.js +113 -117
- package/dist/components/layout/toolbar/PrintTool.js +55 -125
- package/dist/components/layout/toolbar/RPMenuItem.js +14 -11
- package/dist/components/layout/toolbar/RPMoreOptions.js +66 -121
- package/dist/components/layout/toolbar/RPToolbar.js +89 -81
- package/dist/components/layout/toolbar/RPToolbarEnd.js +68 -90
- package/dist/components/layout/toolbar/RotateTool.js +12 -9
- package/dist/components/layout/toolbar/ScrollModeTool.js +14 -11
- package/dist/components/layout/toolbar/SearchCloseButton.js +23 -9
- package/dist/components/layout/toolbar/SearchResultNavigator.js +53 -106
- package/dist/components/layout/toolbar/SearchTool.js +222 -121
- package/dist/components/layout/toolbar/SelectionModeTool.js +8 -5
- package/dist/components/layout/toolbar/ThumbnailTool.js +15 -124
- package/dist/components/layout/toolbar/ToolbarCustom.js +44 -130
- package/dist/components/layout/toolbar/ToolbarDefault.js +122 -120
- package/dist/components/layout/toolbar/ToolbarLayout.js +85 -83
- package/dist/components/layout/toolbar/ViewModeTool.js +10 -7
- package/dist/components/layout/toolbar/ZoomTool.js +128 -120
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +17 -123
- package/dist/components/layout/toolbar/tools/DualPageTool.js +26 -0
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +10 -121
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +6 -4
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +13 -11
- package/dist/components/layout/toolbar/tools/InputPageTool.js +19 -112
- package/dist/components/layout/toolbar/tools/NextPageTool.js +30 -123
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +16 -109
- package/dist/components/layout/toolbar/tools/PrintTool.js +12 -123
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +6 -4
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +6 -4
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +31 -0
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +26 -0
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +6 -4
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +17 -128
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +6 -4
- package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +22 -137
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +26 -123
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +6 -4
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +95 -105
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +16 -125
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +8 -5
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +10 -117
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +12 -120
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +10 -7
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +36 -125
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +16 -123
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +14 -11
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +15 -12
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +18 -15
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +10 -7
- package/dist/components/page/AnnotationLayer.js +122 -126
- package/dist/components/page/CanvasLayer.js +54 -125
- package/dist/components/page/DualPage.js +68 -111
- package/dist/components/page/RPPage.js +126 -125
- package/dist/components/page/SinglePage.js +58 -111
- package/dist/components/page/TextHighlightLayer.js +184 -128
- package/dist/components/page/TextLayer.js +184 -125
- package/dist/components/ui/Checkbox.js +25 -24
- package/dist/components/ui/DropDown.js +11 -8
- package/dist/components/ui/LoadingIndicator.js +34 -129
- package/dist/components/ui/RPTooltip.js +412 -196
- package/dist/contexts/ElementPageContext.js +1 -1
- package/dist/contexts/FullScreenContext.js +17 -10
- package/dist/contexts/LocalizationContext.js +24 -29
- package/dist/contexts/PaginationContext.js +14 -119
- package/dist/contexts/PrintContext.js +67 -133
- package/dist/contexts/RPDocumentContext.js +32 -24
- package/dist/contexts/RenderQueueProvider.js +47 -119
- package/dist/contexts/SearchContext.js +65 -113
- package/dist/contexts/ThumbnailsContext.js +32 -133
- package/dist/contexts/ZoomContext.js +22 -22
- package/dist/floating-ui.react-dom-5ec29bd6.js +1327 -0
- package/dist/index-4baea9b5.js +1198 -0
- package/dist/index-655864a7.js +27 -0
- package/dist/{index-c9a2990a.js → index-c0faa594.js} +64 -87
- package/dist/index-e3ee9457.js +150 -0
- package/dist/main.js +193 -142
- package/dist/types/components/icons/DualPageIcon.d.ts +1 -1
- package/dist/types/components/icons/SinglePageIcon.d.ts +1 -1
- package/dist/types/components/layout/toolbar/tools/DualPageTool.d.ts +3 -0
- package/dist/types/components/layout/toolbar/tools/SelectionModeSwitcherTool.d.ts +3 -0
- package/dist/types/components/layout/toolbar/tools/SinglePageTool.d.ts +3 -0
- package/dist/types/contexts/RenderQueueProvider.d.ts +2 -2
- package/dist/types/main.d.ts +5 -5
- package/dist/types/utils/annotations.d.ts +2 -1
- package/dist/types/utils/getElementPositionInPage.d.ts +2 -2
- package/dist/types/utils/hooks/useCopyText.d.ts +1 -0
- package/dist/types/utils/hooks/usePrint.d.ts +3 -2
- package/dist/types/utils/hooks/useSearch.d.ts +1 -2
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +27 -4
- package/dist/utils/annotations.js +128 -142
- package/dist/utils/getWordPositionInPage.js +5 -5
- package/dist/utils/highlight.js +72 -72
- package/dist/utils/hooks/useCopyText.js +36 -0
- package/dist/utils/hooks/useFileDownload.js +20 -129
- package/dist/utils/hooks/useHighlight.js +28 -28
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +42 -39
- package/dist/utils/hooks/useLoadWorker.js +9 -6
- package/dist/utils/hooks/useLocalization.js +13 -13
- package/dist/utils/hooks/usePaginate.js +21 -126
- package/dist/utils/hooks/usePresentPage.js +75 -127
- package/dist/utils/hooks/usePrint.js +173 -130
- package/dist/utils/hooks/useScrollToPage.js +15 -120
- package/dist/utils/hooks/useSearch.js +132 -126
- package/dist/utils/hooks/useThumbnail.js +47 -130
- package/dist/utils/hooks/useVirtualReactWindow.js +64 -128
- package/dist/utils/injectPrintCSS.js +1 -1
- package/dist/utils/renderPage.js +12 -10
- package/package.json +23 -20
- package/dist/SearchCloseButton-08d57275.js +0 -33
- package/dist/ToolbarLayout.module-37619c4b.js +0 -3548
- package/dist/index-808ea7bf.js +0 -1685
- package/dist/index-a48ec088.js +0 -1672
|
@@ -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
|
};
|