@react-pdf-kit/viewer 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/README.md +84 -49
- package/dist/{Combination-54a77a7a.js → Combination-17ab8af1.js} +184 -187
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +8 -8
- package/dist/components/RPConfig.js +5 -7
- package/dist/components/RPController.js +76 -77
- package/dist/components/RPDropFileZone.js +4 -3
- package/dist/components/RPPages.js +577 -573
- package/dist/components/RPProvider.js +2 -2
- package/dist/components/layout/RPDefaultLayout.js +10 -9
- package/dist/components/layout/RPLayout.js +10 -9
- package/dist/components/layout/WrapperLayout.js +4 -3
- package/dist/components/layout/sidebar/RPSidebar.js +8 -7
- package/dist/components/layout/sidebar/Thumbnail.js +4 -3
- package/dist/components/layout/sidebar/Thumbnails.js +4 -3
- package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +43 -34
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +10 -9
- package/dist/components/layout/toolbar/FileUploadTool.js +10 -9
- package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/MenuItem.js +6 -6
- package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
- package/dist/components/layout/toolbar/MostPageTool.js +10 -9
- package/dist/components/layout/toolbar/OtherTool.js +10 -9
- package/dist/components/layout/toolbar/Paginate.js +8 -7
- package/dist/components/layout/toolbar/PrintTool.js +10 -9
- package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
- package/dist/components/layout/toolbar/RPMoreOptions.js +10 -9
- package/dist/components/layout/toolbar/RPToolbar.js +10 -9
- package/dist/components/layout/toolbar/RPToolbarEnd.js +10 -9
- package/dist/components/layout/toolbar/RotateTool.js +10 -9
- package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
- package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
- package/dist/components/layout/toolbar/SearchResultNavigator.js +23 -30
- package/dist/components/layout/toolbar/SearchTool.js +104 -100
- package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/ThumbnailTool.js +8 -7
- package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
- package/dist/components/layout/toolbar/ToolbarDefault.js +10 -9
- package/dist/components/layout/toolbar/ToolbarLayout.js +10 -9
- package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
- package/dist/components/layout/toolbar/ZoomTool.js +10 -9
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +9 -8
- package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +10 -11
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +8 -7
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +8 -7
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +10 -11
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/InputPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/LastPageTool.js +10 -11
- package/dist/components/layout/toolbar/tools/NextPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/PrintTool.js +8 -7
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +8 -7
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +8 -7
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +8 -7
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +8 -7
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +20 -19
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +8 -7
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +10 -9
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +8 -7
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
- package/dist/components/page/AnnotationLayer.js +25 -24
- package/dist/components/page/CanvasLayer.js +38 -54
- package/dist/components/page/CustomElement.js +4 -3
- package/dist/components/page/DualPage.js +2 -2
- package/dist/components/page/DualPageWithCover.js +2 -2
- package/dist/components/page/RPPage.js +35 -35
- package/dist/components/page/SinglePage.js +2 -2
- package/dist/components/page/TextHighlightLayer.js +16 -15
- package/dist/components/page/TextLayer.js +27 -28
- package/dist/components/ui/Checkbox.js +2 -2
- package/dist/components/ui/DropDown.js +6 -6
- package/dist/components/ui/Input.js +10 -10
- package/dist/components/ui/LoadingIndicator.js +8 -7
- package/dist/components/ui/RPTooltip.js +197 -411
- package/dist/contexts/DimensionPagesContext.js +28 -56
- package/dist/contexts/DropFileZoneContext.js +5 -4
- package/dist/contexts/ElementPageContext.js +6 -5
- package/dist/contexts/FileInputContext.js +6 -5
- package/dist/contexts/HighlightContext.js +6 -5
- package/dist/contexts/InitialStateContext.js +6 -8
- package/dist/contexts/PagesRotateContext.js +6 -5
- package/dist/contexts/PaginationContext.js +6 -5
- package/dist/contexts/PrintContext.js +17 -16
- package/dist/contexts/RPDocumentContext.js +14 -13
- package/dist/contexts/RenderQueueProvider.js +14 -13
- package/dist/contexts/RotationContext.js +9 -8
- package/dist/contexts/SearchContext.js +6 -5
- package/dist/contexts/ThumbnailsContext.js +5 -4
- package/dist/contexts/ZoomContext.js +6 -5
- package/dist/{index-c0faa594.js → index-113053cf.js} +2 -2
- package/dist/index-11f3cd64.js +983 -0
- package/dist/{index-e3ee9457.js → index-23911b43.js} +6 -6
- package/dist/{index-655864a7.js → index-ada501c4.js} +1 -1
- package/dist/index-d0f0aa9a.js +1542 -0
- package/dist/main.js +47 -47
- package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
- package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
- package/dist/types/contexts/RenderQueueProvider.d.ts +1 -2
- package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
- package/dist/types/main.d.ts +3 -1
- package/dist/types/utils/annotations.d.ts +2 -2
- package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
- package/dist/types/utils/highlight.d.ts +5 -5
- package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadWorker.d.ts +5 -1
- package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
- package/dist/types/utils/hooks/useWatermark.d.ts +1 -1
- package/dist/types/utils/link_service.d.ts +2 -3
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +7 -8
- package/dist/utils/highlight.js +36 -36
- package/dist/utils/hooks/useFileDownload.js +6 -5
- package/dist/utils/hooks/useHighlight.js +78 -40
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +96 -70
- package/dist/utils/hooks/useLoadWorker.js +4 -14
- package/dist/utils/hooks/usePageRotateContext.js +8 -7
- package/dist/utils/hooks/usePaginate.js +4 -3
- package/dist/utils/hooks/usePinch.js +44 -90
- package/dist/utils/hooks/usePresentPage.js +4 -3
- package/dist/utils/hooks/usePrint.js +92 -100
- package/dist/utils/hooks/useRotate.js +4 -3
- package/dist/utils/hooks/useScrollToPage.js +4 -3
- package/dist/utils/hooks/useSearch.js +16 -15
- package/dist/utils/hooks/useThumbnail.js +18 -17
- package/dist/utils/hooks/useVirtualReactWindow.js +4 -3
- package/dist/utils/hooks/useWatermark.js +43 -61
- package/dist/utils/injectPrintCSS.js +4 -3
- package/dist/utils/link_service.js +18 -19
- package/dist/utils/renderPage.js +14 -14
- package/package.json +2 -3
- package/dist/contexts/SmoothScaleContext.js +0 -67
- package/dist/floating-ui.react-dom-5ec29bd6.js +0 -1327
- package/dist/index-4baea9b5.js +0 -1198
- package/dist/types/contexts/SmoothScaleContext.d.ts +0 -16
- package/dist/types/utils/hooks/useAccumulateFactor.d.ts +0 -9
- package/dist/utils/hooks/useAccumulateFactor.js +0 -17
package/dist/main.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { RPProvider as
|
|
2
|
-
import { RPPages as
|
|
3
|
-
import { RPConfig as
|
|
4
|
-
import { RPDefaultLayout as
|
|
5
|
-
import { RPLayout as
|
|
6
|
-
import { RPTheme as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { RPProvider as dt } from "./components/RPProvider.js";
|
|
2
|
+
import { RPPages as Dt } from "./components/RPPages.js";
|
|
3
|
+
import { RPConfig as Ft } from "./components/RPConfig.js";
|
|
4
|
+
import { RPDefaultLayout as Mt } from "./components/layout/RPDefaultLayout.js";
|
|
5
|
+
import { RPLayout as vt } from "./components/layout/RPLayout.js";
|
|
6
|
+
import { RPTheme as Bt } from "./components/RPTheme.js";
|
|
7
|
+
import { default as Ht } from "./components/ui/RPTooltip.js";
|
|
8
|
+
import { UIButton as bt } from "./components/ui/Button.js";
|
|
9
|
+
import { useDarkModeContext as zt } from "./contexts/DarkModeContext.js";
|
|
10
|
+
import { u as Ut } from "./PaginationContext-9217cab4.js";
|
|
11
|
+
import { useDocumentContext as Nt } from "./contexts/RPDocumentContext.js";
|
|
10
12
|
import { useRotationContext as jt } from "./contexts/RotationContext.js";
|
|
11
13
|
import { useViewModeContext as At } from "./contexts/ViewModeContext.js";
|
|
12
14
|
import { useDropFileZoneContext as Jt } from "./contexts/DropFileZoneContext.js";
|
|
@@ -22,18 +24,18 @@ import { useElementPageContext as nm } from "./contexts/ElementPageContext.js";
|
|
|
22
24
|
import { SearchTool as Tm } from "./components/layout/toolbar/SearchTool.js";
|
|
23
25
|
import { ThemeSwitcherTool as sm } from "./components/layout/toolbar/tools/ThemeSwitcherTool.js";
|
|
24
26
|
import { ThumbnailTool as gm } from "./components/layout/toolbar/tools/ThumbnailTool.js";
|
|
25
|
-
import { FileUploadTool as
|
|
26
|
-
import { FileDownloadTool as
|
|
27
|
+
import { FileUploadTool as Rm } from "./components/layout/toolbar/tools/FileUploadTool.js";
|
|
28
|
+
import { FileDownloadTool as dm } from "./components/layout/toolbar/tools/FileDownloadTool.js";
|
|
27
29
|
import { PrintTool as Dm } from "./components/layout/toolbar/tools/PrintTool.js";
|
|
28
30
|
import { FullScreenTool as Fm } from "./components/layout/toolbar/tools/FullScreenTool.js";
|
|
29
31
|
import { PreviousPageTool as Mm } from "./components/layout/toolbar/tools/PreviousPageTool.js";
|
|
30
32
|
import { NextPageTool as vm } from "./components/layout/toolbar/tools/NextPageTool.js";
|
|
31
|
-
import { InputPageTool as
|
|
32
|
-
import { ZoomInTool as
|
|
33
|
-
import { ZoomOutTool as
|
|
34
|
-
import { ZoomLevelTool as
|
|
35
|
-
import { DocumentPropertiesTool as
|
|
36
|
-
import { RotateClockwiseTool as
|
|
33
|
+
import { InputPageTool as Bm } from "./components/layout/toolbar/tools/InputPageTool.js";
|
|
34
|
+
import { ZoomInTool as Hm } from "./components/layout/toolbar/tools/ZoomInTool.js";
|
|
35
|
+
import { ZoomOutTool as bm } from "./components/layout/toolbar/tools/ZoomOutTool.js";
|
|
36
|
+
import { ZoomLevelTool as zm } from "./components/layout/toolbar/tools/ZoomLevelTool.js";
|
|
37
|
+
import { DocumentPropertiesTool as Um } from "./components/layout/toolbar/tools/DocumentPropertiesTool.js";
|
|
38
|
+
import { RotateClockwiseTool as Nm } from "./components/layout/toolbar/tools/RotateClockwiseTool.js";
|
|
37
39
|
import { RotateCounterclockwiseTool as jm } from "./components/layout/toolbar/tools/RotateCounterclockwiseTool.js";
|
|
38
40
|
import { RPHorizontalBar as Am } from "./components/layout/toolbar/tools/defaults/RPHorizontalBar.js";
|
|
39
41
|
import { RPVerticalBar as Jm } from "./components/layout/toolbar/tools/defaults/RPVerticalBar.js";
|
|
@@ -77,9 +79,8 @@ import "./contexts/SmoothScrollContext.js";
|
|
|
77
79
|
import "./contexts/RenderQueueProvider.js";
|
|
78
80
|
import "./utils/Queue.js";
|
|
79
81
|
import "./utils/renderPage.js";
|
|
80
|
-
import "
|
|
82
|
+
import "@pdf-viewer/pdfium/compat";
|
|
81
83
|
import "./contexts/GlobalCurrentPage.js";
|
|
82
|
-
import "./contexts/SmoothScaleContext.js";
|
|
83
84
|
import "./contexts/LoaderContext.js";
|
|
84
85
|
import "./components/icons/LoaderIcon.js";
|
|
85
86
|
import "./clsx-0c6e471a.js";
|
|
@@ -113,7 +114,6 @@ import "./components/page/SinglePage.js";
|
|
|
113
114
|
import "./utils/hooks/useMousePressed.js";
|
|
114
115
|
import "./utils/hooks/useGrabScroll.js";
|
|
115
116
|
import "./utils/hooks/usePinch.js";
|
|
116
|
-
import "./utils/hooks/useAccumulateFactor.js";
|
|
117
117
|
import "./utils/hooks/useDebounce.js";
|
|
118
118
|
import "./components/ui/PasswordModal.js";
|
|
119
119
|
import "./utils/hooks/usePresentPage.js";
|
|
@@ -125,29 +125,26 @@ import "./utils/hooks/useCopyText.js";
|
|
|
125
125
|
import "./utils/hooks/useTextSelection.js";
|
|
126
126
|
import "./utils/approximateFragtion.js";
|
|
127
127
|
import "./contexts/ConfigContext.js";
|
|
128
|
-
import "./utils/hooks/useLoadWorker.js";
|
|
129
128
|
import "./components/layout/toolbar/RPToolbar.js";
|
|
130
129
|
import "./RPToolbar.module-27d7fe77.js";
|
|
131
130
|
import "./components/layout/toolbar/Paginate.js";
|
|
132
131
|
import "./components/icons/ChevronUpIcon.js";
|
|
133
|
-
import "./components/ui/Button.js";
|
|
134
132
|
import "./components/ui/Input.js";
|
|
135
133
|
import "./Paginate.module-4eef00aa.js";
|
|
136
134
|
import "./contexts/IconContext.js";
|
|
137
135
|
import "./contexts/ToolbarComponentContext.js";
|
|
138
136
|
import "./contexts/ViewportContext.js";
|
|
139
|
-
import "./components/ui/RPTooltip.js";
|
|
140
|
-
import "./index-c0faa594.js";
|
|
141
|
-
import "react-dom";
|
|
142
|
-
import "./index-e3ee9457.js";
|
|
143
|
-
import "./floating-ui.react-dom-5ec29bd6.js";
|
|
144
|
-
import "./index-655864a7.js";
|
|
145
137
|
import "./components/layout/toolbar/RPToolbarEnd.js";
|
|
146
138
|
import "./components/layout/toolbar/FileUploadTool.js";
|
|
147
139
|
import "./components/icons/FileUploadDefaultIcon.js";
|
|
148
140
|
import "./components/layout/toolbar/MenuItem.js";
|
|
149
|
-
import "./index-
|
|
150
|
-
import "./
|
|
141
|
+
import "./index-11f3cd64.js";
|
|
142
|
+
import "./index-113053cf.js";
|
|
143
|
+
import "react-dom";
|
|
144
|
+
import "./index-23911b43.js";
|
|
145
|
+
import "./Combination-17ab8af1.js";
|
|
146
|
+
import "./index-d0f0aa9a.js";
|
|
147
|
+
import "./index-ada501c4.js";
|
|
151
148
|
import "./components/layout/toolbar/DarkModeTool.js";
|
|
152
149
|
import "./components/icons/MoonIcon.js";
|
|
153
150
|
import "./components/icons/SunIcon.js";
|
|
@@ -213,6 +210,7 @@ import "./utils/hooks/useDarkMode.js";
|
|
|
213
210
|
import "./utils/smoothScrollTo.js";
|
|
214
211
|
import "./utils/getScrollDistance.js";
|
|
215
212
|
import "./utils/hooks/useLoadPdf.js";
|
|
213
|
+
import "@pdf-viewer/pdfium";
|
|
216
214
|
import "./utils/hooks/usePdfProperties.js";
|
|
217
215
|
import "./utils/convertPdfDate.js";
|
|
218
216
|
import "./utils/formatFileSize.js";
|
|
@@ -232,30 +230,32 @@ import "./components/layout/toolbar/SearchCloseButton.js";
|
|
|
232
230
|
import "./components/icons/ChevronDownIcon.js";
|
|
233
231
|
import "./components/layout/toolbar/ThumbnailTool.js";
|
|
234
232
|
export {
|
|
235
|
-
|
|
233
|
+
Um as DocumentPropertiesTool,
|
|
236
234
|
$m as DualPageTool,
|
|
237
235
|
rp as DualPageWithCoverTool,
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
dm as FileDownloadTool,
|
|
237
|
+
Rm as FileUploadTool,
|
|
240
238
|
fp as FirstPageTool,
|
|
241
239
|
Fm as FullScreenTool,
|
|
242
240
|
lp as HorizontalScrollingTool,
|
|
243
|
-
|
|
241
|
+
Bm as InputPageTool,
|
|
244
242
|
np as LastPageTool,
|
|
245
243
|
Tp as Locales,
|
|
246
244
|
vm as NextPageTool,
|
|
247
245
|
mp as PageScrollingTool,
|
|
248
246
|
Mm as PreviousPageTool,
|
|
249
247
|
Dm as PrintTool,
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
bt as RPButton,
|
|
249
|
+
Ft as RPConfig,
|
|
250
|
+
Mt as RPDefaultLayout,
|
|
252
251
|
Am as RPHorizontalBar,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
252
|
+
vt as RPLayout,
|
|
253
|
+
Dt as RPPages,
|
|
254
|
+
dt as RPProvider,
|
|
255
|
+
Bt as RPTheme,
|
|
256
|
+
Ht as RPTooltip,
|
|
257
257
|
Jm as RPVerticalBar,
|
|
258
|
-
|
|
258
|
+
Nm as RotateClockwiseTool,
|
|
259
259
|
jm as RotateCounterclockwiseTool,
|
|
260
260
|
Pp as ScrollMode,
|
|
261
261
|
Tm as SearchTool,
|
|
@@ -267,12 +267,12 @@ export {
|
|
|
267
267
|
gm as ThumbnailTool,
|
|
268
268
|
ip as VerticalScrollingTool,
|
|
269
269
|
gp as ViewMode,
|
|
270
|
-
|
|
270
|
+
Hm as ZoomInTool,
|
|
271
271
|
Cp as ZoomLevel,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
zm as ZoomLevelTool,
|
|
273
|
+
bm as ZoomOutTool,
|
|
274
|
+
zt as useDarkModeContext,
|
|
275
|
+
Nt as useDocumentContext,
|
|
276
276
|
Jt as useDropFileZoneContext,
|
|
277
277
|
nm as useElementPageContext,
|
|
278
278
|
Qt as useFileDownload,
|
|
@@ -280,7 +280,7 @@ export {
|
|
|
280
280
|
im as useHighlightContext,
|
|
281
281
|
Yt as useOpenFileContext,
|
|
282
282
|
fm as usePageRotateContext,
|
|
283
|
-
|
|
283
|
+
Ut as usePaginationContext,
|
|
284
284
|
$t as usePrintContext,
|
|
285
285
|
jt as useRotationContext,
|
|
286
286
|
mm as useSearchContext,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Viewport } from '@pdf-viewer/pdfium/compat';
|
|
3
3
|
interface Props {
|
|
4
4
|
pageNumber: number;
|
|
5
5
|
loading: boolean;
|
|
6
6
|
isFocused: boolean;
|
|
7
|
-
viewport:
|
|
7
|
+
viewport: Viewport;
|
|
8
8
|
defaultRotation: number;
|
|
9
9
|
}
|
|
10
10
|
export declare const Thumbnail: FC<Props>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { DocumentContextType, RPSrc, CharacterMap, LoadPDFOptions } from '../utils/types';
|
|
3
|
-
import { PDFDocumentProxy } from '
|
|
3
|
+
import { PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
|
|
4
4
|
declare const DocumentContext: React.Context<DocumentContextType>;
|
|
5
5
|
interface Props extends PropsWithChildren, LoadPDFOptions {
|
|
6
6
|
src?: RPSrc;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Queue } from '../utils/Queue';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
import { PDFPageProxy } from '
|
|
3
|
+
import { PDFPageProxy } from '@pdf-viewer/pdfium/compat';
|
|
4
4
|
import { RenderOptions } from '../utils/types';
|
|
5
5
|
interface RenderData {
|
|
6
6
|
page: PDFPageProxy;
|
|
7
7
|
canvasElem: HTMLCanvasElement;
|
|
8
8
|
options?: RenderOptions;
|
|
9
9
|
onLoaded?: () => void;
|
|
10
|
-
onSwap?: () => void;
|
|
11
10
|
}
|
|
12
11
|
export declare const RenderQueueContext: import('react').Context<Queue<RenderData> | null>;
|
|
13
12
|
export declare const RenderQueueProvider: FC<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Viewport } from '@pdf-viewer/pdfium/compat';
|
|
2
2
|
import { FC, PropsWithChildren } from 'react';
|
|
3
3
|
interface CacheContext {
|
|
4
|
-
viewports: Map<number,
|
|
4
|
+
viewports: Map<number, Viewport>;
|
|
5
5
|
pages: Map<number, any>;
|
|
6
6
|
}
|
|
7
7
|
export declare const RenderedPagesCacheContext: import('react').Context<CacheContext>;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { RPConfig } from './components/RPConfig';
|
|
|
4
4
|
export { RPDefaultLayout } from './components/layout/RPDefaultLayout';
|
|
5
5
|
export { RPLayout } from './components/layout/RPLayout';
|
|
6
6
|
export { RPTheme } from './components/RPTheme';
|
|
7
|
+
export { default as RPTooltip } from './components/ui/RPTooltip';
|
|
8
|
+
export { UIButton as RPButton } from './components/ui/Button';
|
|
7
9
|
export { useDarkModeContext } from './contexts/DarkModeContext';
|
|
8
10
|
export { usePaginationContext } from './contexts/PaginationContext';
|
|
9
11
|
export { useDocumentContext } from './contexts/RPDocumentContext';
|
|
@@ -19,7 +21,7 @@ export { useHighlightContext } from './contexts/HighlightContext';
|
|
|
19
21
|
export { useFullScreenContext } from './contexts/FullScreenContext';
|
|
20
22
|
export { usePageRotateContext } from './utils/hooks/usePageRotateContext';
|
|
21
23
|
export { useElementPageContext } from './contexts/ElementPageContext';
|
|
22
|
-
export { type PDFDocumentProxy } from '
|
|
24
|
+
export { type PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
|
|
23
25
|
export { SearchTool } from './components/layout/toolbar/SearchTool';
|
|
24
26
|
export { ThemeSwitcherTool } from './components/layout/toolbar/tools/ThemeSwitcherTool';
|
|
25
27
|
export { ThumbnailTool } from './components/layout/toolbar/tools/ThumbnailTool';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Viewport, PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
|
|
2
2
|
import { Annotation, AnnotationEventPayload } from './types';
|
|
3
3
|
export declare const insertDateText: (annotationLayer: HTMLDivElement | null) => void;
|
|
4
4
|
export declare function bindLayerEvents(annotatedLayer: HTMLDivElement, handler: (event: Event) => void): void;
|
|
5
5
|
export declare function unbindLayerEvents(annotatedLayer: HTMLDivElement, handler: (event: Event) => void): void;
|
|
6
6
|
export declare function handleAnnotationLink(annotation: Annotation): void;
|
|
7
|
-
export declare function handleAnnotationWidget(annotation: Annotation, viewport:
|
|
7
|
+
export declare function handleAnnotationWidget(annotation: Annotation, viewport: Viewport, canvasMap: Map<string, HTMLCanvasElement>): void;
|
|
8
8
|
/**
|
|
9
9
|
* Fixes tabindex values greater than 0 in annotation layer elements
|
|
10
10
|
* WCAG 2.1 requires tabindex to be 0, -1, or not set (for natural tab order)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PDFPageProxy } from '
|
|
1
|
+
import { PDFPageProxy } from '@pdf-viewer/pdfium/compat';
|
|
2
2
|
export declare const getThumbnailViewport: (page: PDFPageProxy, rotation?: number) => {
|
|
3
3
|
scale: number;
|
|
4
|
-
thumbnailViewport: import('
|
|
4
|
+
thumbnailViewport: import('@pdf-viewer/pdfium/compat').Viewport;
|
|
5
5
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextContentCompat } from '@pdf-viewer/pdfium/compat';
|
|
2
2
|
import { SearchOptions, Match, MatchHighlight } from './types';
|
|
3
|
-
export declare function findMatches(queries: (string | RegExp)[], textContent:
|
|
3
|
+
export declare function findMatches(queries: (string | RegExp)[], textContent: TextContentCompat, pageIndex: number, options: SearchOptions): Match[];
|
|
4
4
|
export declare function isMatchEntireWord(content: string, startIdx: number, length: number): boolean;
|
|
5
|
-
export declare function highlightMatches(matches: Match[], textContent:
|
|
5
|
+
export declare function highlightMatches(matches: Match[], textContent: TextContentCompat, textDivs: HTMLElement[]): {
|
|
6
6
|
element: HTMLElement;
|
|
7
7
|
index: number;
|
|
8
8
|
}[];
|
|
9
|
-
export declare function resetDivs(textContent:
|
|
9
|
+
export declare function resetDivs(textContent: TextContentCompat, textDivs: HTMLElement[]): void;
|
|
10
10
|
export declare function getHighlightOptionsWithDefaults(options?: SearchOptions): SearchOptions;
|
|
11
|
-
export declare function highlightMultipleColorMatches(matches: MatchHighlight[], textContent:
|
|
11
|
+
export declare function highlightMultipleColorMatches(matches: MatchHighlight[], textContent: TextContentCompat, textDivs: HTMLElement[]): {
|
|
12
12
|
element: HTMLElement;
|
|
13
13
|
index: number;
|
|
14
14
|
}[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PDFDocumentProxy } from '
|
|
1
|
+
import { PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
|
|
2
2
|
import { PdfPage, RPSrc, CharacterMap, LoadPDFOptions, ErrorType } from '../types';
|
|
3
|
-
export declare const useLoadPdf: (src?: RPSrc,
|
|
3
|
+
export declare const useLoadPdf: (src?: RPSrc, _characterMap?: CharacterMap, options?: LoadPDFOptions) => {
|
|
4
4
|
pdf: PDFDocumentProxy | undefined;
|
|
5
5
|
pages: Map<number, PdfPage>;
|
|
6
6
|
loading: boolean;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated No longer needed — PDFium uses WASM directly without a web worker.
|
|
3
|
+
* Kept for backward compatibility in case external code references it.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useLoadWorker: (_workerUrl?: string) => {
|
|
2
6
|
workerUrlAdded: boolean;
|
|
3
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useWatermark: (
|
|
1
|
+
export declare const useWatermark: (container: HTMLDivElement | null) => void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { PDFDocumentProxy } from '
|
|
2
|
-
|
|
3
|
-
declare class SimpleLinkService implements IPDFLinkService {
|
|
1
|
+
import { PDFDocumentProxy, LinkService } from '@pdf-viewer/pdfium/compat';
|
|
2
|
+
declare class SimpleLinkService implements LinkService {
|
|
4
3
|
externalLinkEnabled: boolean;
|
|
5
4
|
pdfDocument: PDFDocumentProxy | undefined;
|
|
6
5
|
constructor(pdfDocument: PDFDocumentProxy, goToPage: (page: number) => void);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PDFPageProxy } from '
|
|
1
|
+
import { PDFPageProxy, RenderTask } from '@pdf-viewer/pdfium/compat';
|
|
2
2
|
import { RenderOptions } from './types';
|
|
3
|
-
export declare const renderPage: (page: PDFPageProxy, canvasElem: HTMLCanvasElement, options?: RenderOptions) =>
|
|
3
|
+
export declare const renderPage: (page: PDFPageProxy, canvasElem: HTMLCanvasElement, options?: RenderOptions) => RenderTask;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { PDFPageProxy } from '
|
|
2
|
-
import { DocumentInitParameters, PDFDataRangeTransport, PDFDocumentProxy, TypedArray } from 'pdfjs-dist/types/src/display/api';
|
|
3
|
-
import { PageViewport } from 'pdfjs-dist/types/web/interfaces';
|
|
1
|
+
import { PDFDocumentProxy, PDFPageProxy, Viewport } from '@pdf-viewer/pdfium/compat';
|
|
4
2
|
import { Dispatch, FC, PropsWithChildren, SetStateAction } from 'react';
|
|
5
3
|
export interface DocumentContextType {
|
|
6
4
|
pdf?: PDFDocumentProxy;
|
|
@@ -253,7 +251,7 @@ export type DecryptedLicense = {
|
|
|
253
251
|
};
|
|
254
252
|
export interface PdfPage {
|
|
255
253
|
page: PDFPageProxy;
|
|
256
|
-
thumbnailViewport:
|
|
254
|
+
thumbnailViewport: Viewport;
|
|
257
255
|
thumbnailScale: number;
|
|
258
256
|
defaultRotation: number;
|
|
259
257
|
}
|
|
@@ -290,7 +288,7 @@ export interface ThumbnailRenderedList {
|
|
|
290
288
|
loading: boolean;
|
|
291
289
|
page: PDFPageProxy;
|
|
292
290
|
thumbnailSrc?: string;
|
|
293
|
-
viewport:
|
|
291
|
+
viewport: Viewport;
|
|
294
292
|
scale: number;
|
|
295
293
|
defaultRotation: number;
|
|
296
294
|
}
|
|
@@ -299,8 +297,8 @@ export declare enum ViewMode {
|
|
|
299
297
|
DUAL_PAGE = "Dual",
|
|
300
298
|
DUAL_PAGE_WITH_COVER = "DualWithCover"
|
|
301
299
|
}
|
|
302
|
-
export type PDFSrc = string | URL |
|
|
303
|
-
export type RPSrc =
|
|
300
|
+
export type PDFSrc = string | URL | ArrayBuffer | Uint8Array | undefined | null;
|
|
301
|
+
export type RPSrc = PDFSrc;
|
|
304
302
|
export interface FullScreenToolProps {
|
|
305
303
|
isFullScreen: boolean;
|
|
306
304
|
toggleFullScreen: () => void;
|
|
@@ -363,6 +361,7 @@ export interface PdfProperties {
|
|
|
363
361
|
}
|
|
364
362
|
export interface ConfigContextType {
|
|
365
363
|
workerUrlAdded: boolean;
|
|
364
|
+
wasmUrl?: string;
|
|
366
365
|
}
|
|
367
366
|
export declare enum ThemeVariables {
|
|
368
367
|
FONT_FAMILY = "--rp-font-family",
|
|
@@ -540,7 +539,6 @@ export interface ZoomContextType {
|
|
|
540
539
|
}
|
|
541
540
|
export type ZoomProps = Omit<ZoomContextType, 'currentZoom'>;
|
|
542
541
|
export type InitialStateContextType = {
|
|
543
|
-
instanceId: string;
|
|
544
542
|
interactiveForm?: boolean;
|
|
545
543
|
} & ZoomProviderProps & PageProviderProps & ViewModeInitialProps & ScrollModeInitialProps & RotateProviderProps;
|
|
546
544
|
export interface ZoomProviderProps {
|
|
@@ -820,6 +818,7 @@ export interface RPHorizontalBarIcons {
|
|
|
820
818
|
documentPropertiesIcon?: React.ReactNode;
|
|
821
819
|
printIcon?: React.ReactNode;
|
|
822
820
|
searchIcon?: React.ReactNode;
|
|
821
|
+
searchClearIcon?: React.ReactNode;
|
|
823
822
|
textSelectionIcon?: React.ReactNode;
|
|
824
823
|
handModeIcon?: React.ReactNode;
|
|
825
824
|
}
|
package/dist/utils/highlight.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { getCharacterType as D } from "./charators.js";
|
|
2
|
-
function _(
|
|
2
|
+
function _(l, c, m, i) {
|
|
3
3
|
const s = [];
|
|
4
|
-
for (const n of
|
|
4
|
+
for (const n of l) {
|
|
5
5
|
const o = y(c, n, i);
|
|
6
6
|
s.push(...R(o, c, m));
|
|
7
7
|
}
|
|
8
8
|
return s;
|
|
9
9
|
}
|
|
10
|
-
const L = (
|
|
10
|
+
const L = (l, c) => {
|
|
11
11
|
const m = ["g"];
|
|
12
12
|
c.matchCase || m.push("i");
|
|
13
|
-
let s =
|
|
13
|
+
let s = l.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
14
|
return new RegExp(s, m.join(""));
|
|
15
15
|
};
|
|
16
|
-
function y(
|
|
16
|
+
function y(l, c, m) {
|
|
17
17
|
const i = [];
|
|
18
|
-
for (const t of
|
|
18
|
+
for (const t of l.items)
|
|
19
19
|
if (t.hasEOL)
|
|
20
20
|
if (t.str.endsWith("-")) {
|
|
21
21
|
const d = t.str.lastIndexOf("-");
|
|
@@ -34,14 +34,14 @@ function y(r, c, m) {
|
|
|
34
34
|
m.wholeWords && !W(s, e.index, e[0].length) || o.push([e.index, e[0].length, e[0]]);
|
|
35
35
|
return o;
|
|
36
36
|
}
|
|
37
|
-
function R(
|
|
37
|
+
function R(l, c, m) {
|
|
38
38
|
function i(d) {
|
|
39
39
|
return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
|
|
40
40
|
}
|
|
41
41
|
let s = 0, n = 0;
|
|
42
42
|
const o = c.items, e = o.length - 1, t = [];
|
|
43
|
-
for (let d = 0; d <
|
|
44
|
-
let h =
|
|
43
|
+
for (let d = 0; d < l.length; d++) {
|
|
44
|
+
let h = l[d][0];
|
|
45
45
|
for (; s !== e && h >= n + o[s].str.length; ) {
|
|
46
46
|
const x = o[s];
|
|
47
47
|
n += x.str.length + i(x), s++;
|
|
@@ -50,19 +50,19 @@ function R(r, c, m) {
|
|
|
50
50
|
idx: s,
|
|
51
51
|
offset: h - n
|
|
52
52
|
};
|
|
53
|
-
for (h +=
|
|
53
|
+
for (h += l[d][1]; s !== e && h > n + o[s].str.length; ) {
|
|
54
54
|
const x = o[s];
|
|
55
55
|
n += x.str.length + i(x), s++;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const r = {
|
|
58
58
|
idx: s,
|
|
59
59
|
offset: h - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
62
|
start: g,
|
|
63
|
-
end:
|
|
64
|
-
str:
|
|
65
|
-
oIndex:
|
|
63
|
+
end: r,
|
|
64
|
+
str: l[d][2],
|
|
65
|
+
oIndex: l[d][0],
|
|
66
66
|
pageIndex: m,
|
|
67
67
|
rect: { left: 0, bottom: 0, width: 0, height: 0 },
|
|
68
68
|
rects: []
|
|
@@ -71,45 +71,45 @@ function R(r, c, m) {
|
|
|
71
71
|
for (const d of t) {
|
|
72
72
|
const h = [];
|
|
73
73
|
for (let g = d.start.idx; g <= d.end.idx; g++) {
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const r = o[g], x = r.transform[4], C = r.transform[5], a = r.str.length > 0 ? r.width / r.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : r.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[r.fontName], T = (u == null ? void 0 : u.ascent) ?? 1, v = (u == null ? void 0 : u.descent) != null ? Math.abs(u.descent) : 1 - T, b = C - v * r.height;
|
|
75
|
+
r.height > 0 && r.width > 0 && h.push({
|
|
76
76
|
left: f,
|
|
77
77
|
bottom: b,
|
|
78
78
|
width: E,
|
|
79
|
-
height:
|
|
79
|
+
height: r.height
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
d.rect = h[0], d.rects = h;
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
|
-
function W(
|
|
87
|
-
let i =
|
|
86
|
+
function W(l, c, m) {
|
|
87
|
+
let i = l.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
88
|
if (i) {
|
|
89
|
-
const s =
|
|
89
|
+
const s = l.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
90
|
if (D(s) === D(n))
|
|
91
91
|
return !1;
|
|
92
92
|
}
|
|
93
|
-
if (i =
|
|
94
|
-
const s =
|
|
93
|
+
if (i = l.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
|
|
94
|
+
const s = l.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
|
|
95
95
|
if (D(s) === D(n))
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
return !0;
|
|
99
99
|
}
|
|
100
|
-
function I(
|
|
100
|
+
function I(l, c, m) {
|
|
101
101
|
const i = [];
|
|
102
102
|
function s(n, o, e = -1, t = -1, d = "") {
|
|
103
103
|
const h = c.items[n], g = [];
|
|
104
|
-
let
|
|
104
|
+
let r = "", x = "", C = "", a = m[n];
|
|
105
105
|
if (!a)
|
|
106
106
|
return;
|
|
107
107
|
if (a.nodeType === Node.TEXT_NODE) {
|
|
108
108
|
const f = document.createElement("span");
|
|
109
109
|
a.before(f), f.append(a), m[n] = f, a = f;
|
|
110
110
|
}
|
|
111
|
-
e >= 0 && t >= 0 ?
|
|
112
|
-
const M = document.createTextNode(
|
|
111
|
+
e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
|
|
112
|
+
const M = document.createTextNode(r), N = document.createElement("span");
|
|
113
113
|
if (N.className = "highlight appended " + d, N.setAttribute("data-match-index", `${o}`), N.append(M), g.push(N), i.push({ element: N, index: o }), e > 0)
|
|
114
114
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
115
115
|
x = h.str.substring(0, e);
|
|
@@ -135,7 +135,7 @@ function I(r, c, m) {
|
|
|
135
135
|
}
|
|
136
136
|
a.replaceChildren(...g);
|
|
137
137
|
}
|
|
138
|
-
for (const [n, o] of
|
|
138
|
+
for (const [n, o] of l.entries())
|
|
139
139
|
if (o.start.idx === o.end.idx)
|
|
140
140
|
s(o.start.idx, n, o.start.offset, o.end.offset);
|
|
141
141
|
else
|
|
@@ -143,8 +143,8 @@ function I(r, c, m) {
|
|
|
143
143
|
e === o.start.idx ? s(e, n, o.start.offset, -1, "begin") : e === o.end.idx ? s(e, n, -1, o.end.offset, "end") : s(e, n, -1, -1, "middle");
|
|
144
144
|
return i;
|
|
145
145
|
}
|
|
146
|
-
function V(
|
|
147
|
-
const m =
|
|
146
|
+
function V(l, c) {
|
|
147
|
+
const m = l.items.map((i) => i.str);
|
|
148
148
|
for (let i = 0; i < c.length; i++) {
|
|
149
149
|
const s = c[i];
|
|
150
150
|
if (s && s.nodeType !== Node.TEXT_NODE) {
|
|
@@ -153,19 +153,19 @@ function V(r, c) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function H(
|
|
157
|
-
return { matchCase: !1, wholeWords: !1, ...
|
|
156
|
+
function H(l = {}) {
|
|
157
|
+
return { matchCase: !1, wholeWords: !1, ...l };
|
|
158
158
|
}
|
|
159
|
-
function S(
|
|
159
|
+
function S(l, c, m) {
|
|
160
160
|
const i = [];
|
|
161
161
|
function s(n, o, e = -1, t = -1, d) {
|
|
162
162
|
var f, E;
|
|
163
163
|
const h = c.items[n], g = [];
|
|
164
|
-
let
|
|
164
|
+
let r = "", x = "", C = "", a = m[n];
|
|
165
165
|
if (!a)
|
|
166
166
|
return;
|
|
167
|
-
e >= 0 && t >= 0 ?
|
|
168
|
-
const M = document.createTextNode(
|
|
167
|
+
e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
|
|
168
|
+
const M = document.createTextNode(r), N = document.createElement("span");
|
|
169
169
|
if (N.style.background = d, N.append(M), g.push(N), e > 0)
|
|
170
170
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
171
171
|
x = h.str.substring(0, e);
|
|
@@ -205,7 +205,7 @@ function S(r, c, m) {
|
|
|
205
205
|
}
|
|
206
206
|
a.replaceChildren(...g), i.push({ element: N, index: o });
|
|
207
207
|
}
|
|
208
|
-
for (const [n, o] of
|
|
208
|
+
for (const [n, o] of l.entries()) {
|
|
209
209
|
const { start: e, end: t, color: d } = o;
|
|
210
210
|
e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
|
|
211
211
|
}
|
|
@@ -3,7 +3,8 @@ import { useCallback as a } from "react";
|
|
|
3
3
|
import { useDownloadContext as s } from "../../contexts/DownloadContext.js";
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "./useLoadPdf.js";
|
|
6
|
-
import "
|
|
6
|
+
import "@pdf-viewer/pdfium";
|
|
7
|
+
import "@pdf-viewer/pdfium/compat";
|
|
7
8
|
import "../types.js";
|
|
8
9
|
import "../../de_DE-a553b162.js";
|
|
9
10
|
import "../getThumbnailViewport.js";
|
|
@@ -13,10 +14,10 @@ import "../appConsole.js";
|
|
|
13
14
|
import "./usePdfProperties.js";
|
|
14
15
|
import "../convertPdfDate.js";
|
|
15
16
|
import "../formatFileSize.js";
|
|
16
|
-
const i = ".pdf", d = (o) => URL.createObjectURL(o),
|
|
17
|
+
const i = ".pdf", d = (o) => URL.createObjectURL(o), p = async (o) => {
|
|
17
18
|
const r = await (await fetch(o)).blob();
|
|
18
19
|
return d(r);
|
|
19
|
-
},
|
|
20
|
+
}, B = () => {
|
|
20
21
|
const { filename: o, pdfSrc: e } = c(), { downloadFilename: r } = s(), m = (t) => {
|
|
21
22
|
const n = r || t;
|
|
22
23
|
return n.endsWith(i) ? n : `${n}${i}`;
|
|
@@ -25,9 +26,9 @@ const i = ".pdf", d = (o) => URL.createObjectURL(o), l = async (o) => {
|
|
|
25
26
|
if (!o || !e)
|
|
26
27
|
throw new Error("There is no PDF source to download");
|
|
27
28
|
const t = document.createElement("a");
|
|
28
|
-
t.href = await
|
|
29
|
+
t.href = await p(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
29
30
|
}, [o, e]) };
|
|
30
31
|
};
|
|
31
32
|
export {
|
|
32
|
-
|
|
33
|
+
B as useFileDownload
|
|
33
34
|
};
|