@react-pdf-kit/viewer 0.0.0-experimental.9 → 0.0.0-legacy.1

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.
Files changed (155) hide show
  1. package/dist/{Combination-479e39c6.js → Combination-17ab8af1.js} +184 -187
  2. package/dist/RPLayout.module-b4b23e29.js +14 -0
  3. package/dist/assets/style.css +1 -1
  4. package/dist/assets/style.js +15 -15
  5. package/dist/components/RPConfig.js +7 -16
  6. package/dist/components/RPController.js +21 -26
  7. package/dist/components/RPDropFileZone.js +27 -35
  8. package/dist/components/RPPages.js +352 -361
  9. package/dist/components/RPProvider.js +20 -24
  10. package/dist/components/layout/LayoutContainer.js +1 -1
  11. package/dist/components/layout/LayoutWrapper.js +1 -1
  12. package/dist/components/layout/RPDefaultLayout.js +6 -11
  13. package/dist/components/layout/RPLayout.js +21 -27
  14. package/dist/components/layout/WrapperLayout.js +9 -10
  15. package/dist/components/layout/sidebar/RPSidebar.js +3 -4
  16. package/dist/components/layout/sidebar/Thumbnail.js +3 -4
  17. package/dist/components/layout/sidebar/Thumbnails.js +3 -4
  18. package/dist/components/layout/toolbar/DocumentDialog.js +6 -7
  19. package/dist/components/layout/toolbar/DocumentProperties.js +2 -2
  20. package/dist/components/layout/toolbar/FileDownloadTool.js +5 -6
  21. package/dist/components/layout/toolbar/FileUploadTool.js +5 -6
  22. package/dist/components/layout/toolbar/FullScreenTool.js +2 -2
  23. package/dist/components/layout/toolbar/MenuItem.js +2 -2
  24. package/dist/components/layout/toolbar/MenuSeparator.js +2 -2
  25. package/dist/components/layout/toolbar/MostPageTool.js +5 -6
  26. package/dist/components/layout/toolbar/OtherTool.js +5 -6
  27. package/dist/components/layout/toolbar/Paginate.js +3 -4
  28. package/dist/components/layout/toolbar/PrintTool.js +5 -6
  29. package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
  30. package/dist/components/layout/toolbar/RPMoreOptions.js +5 -6
  31. package/dist/components/layout/toolbar/RPToolbar.js +5 -8
  32. package/dist/components/layout/toolbar/RPToolbarEnd.js +5 -6
  33. package/dist/components/layout/toolbar/RotateTool.js +5 -6
  34. package/dist/components/layout/toolbar/ScrollModeTool.js +2 -2
  35. package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -6
  36. package/dist/components/layout/toolbar/SearchTool.js +5 -8
  37. package/dist/components/layout/toolbar/SelectionModeTool.js +2 -2
  38. package/dist/components/layout/toolbar/ThumbnailTool.js +3 -4
  39. package/dist/components/layout/toolbar/ToolbarCustom.js +3 -4
  40. package/dist/components/layout/toolbar/ToolbarDefault.js +5 -8
  41. package/dist/components/layout/toolbar/ToolbarLayout.js +5 -8
  42. package/dist/components/layout/toolbar/ViewModeTool.js +2 -2
  43. package/dist/components/layout/toolbar/ZoomTool.js +5 -6
  44. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -5
  45. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +7 -13
  46. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +3 -4
  47. package/dist/components/layout/toolbar/tools/FileUploadTool.js +3 -4
  48. package/dist/components/layout/toolbar/tools/FirstPageTool.js +7 -13
  49. package/dist/components/layout/toolbar/tools/InputPageTool.js +3 -4
  50. package/dist/components/layout/toolbar/tools/LastPageTool.js +7 -13
  51. package/dist/components/layout/toolbar/tools/NextPageTool.js +3 -4
  52. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +3 -4
  53. package/dist/components/layout/toolbar/tools/PrintTool.js +3 -4
  54. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +3 -4
  55. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +3 -4
  56. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +3 -4
  57. package/dist/components/layout/toolbar/tools/ZoomInTool.js +3 -4
  58. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +15 -16
  59. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +3 -4
  60. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +5 -8
  61. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +3 -4
  62. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  63. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +5 -6
  64. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +5 -6
  65. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  66. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +5 -6
  67. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +5 -6
  68. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +5 -6
  69. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +2 -2
  70. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
  71. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
  72. package/dist/components/page/AnnotationLayer.js +72 -69
  73. package/dist/components/page/CanvasLayer.js +3 -4
  74. package/dist/components/page/CustomElement.js +3 -4
  75. package/dist/components/page/DualPage.js +5 -11
  76. package/dist/components/page/DualPageWithCover.js +5 -11
  77. package/dist/components/page/RPPage.js +6 -12
  78. package/dist/components/page/SinglePage.js +5 -11
  79. package/dist/components/page/TextHighlightLayer.js +178 -86
  80. package/dist/components/page/TextLayer.js +170 -125
  81. package/dist/components/ui/DropDown.js +2 -2
  82. package/dist/components/ui/LoadingIndicator.js +7 -8
  83. package/dist/contexts/ConfigContext.js +4 -5
  84. package/dist/contexts/DimensionPagesContext.js +5 -6
  85. package/dist/contexts/DropFileZoneContext.js +4 -5
  86. package/dist/contexts/ElementPageContext.js +5 -6
  87. package/dist/contexts/FileInputContext.js +5 -6
  88. package/dist/contexts/HighlightContext.js +7 -10
  89. package/dist/contexts/LicenseContext.js +6 -8
  90. package/dist/contexts/PagesRotateContext.js +5 -6
  91. package/dist/contexts/PaginationContext.js +5 -6
  92. package/dist/contexts/PrintContext.js +16 -17
  93. package/dist/contexts/RPDocumentContext.js +13 -14
  94. package/dist/contexts/RenderQueueProvider.js +5 -6
  95. package/dist/contexts/RotationContext.js +8 -9
  96. package/dist/contexts/SearchContext.js +5 -8
  97. package/dist/contexts/ThumbnailsContext.js +4 -5
  98. package/dist/contexts/ZoomContext.js +5 -6
  99. package/dist/{index-535ad364.js → index-11f3cd64.js} +1 -1
  100. package/dist/main.js +115 -120
  101. package/dist/polyfills.js +8166 -0
  102. package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
  103. package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
  104. package/dist/types/contexts/RenderQueueProvider.d.ts +1 -1
  105. package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
  106. package/dist/types/main.d.ts +1 -1
  107. package/dist/types/utils/annotations.d.ts +2 -2
  108. package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
  109. package/dist/types/utils/highlight.d.ts +5 -5
  110. package/dist/types/utils/hooks/useFlickerSelectText.d.ts +1 -0
  111. package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
  112. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
  113. package/dist/types/utils/hooks/useLoadWorker.d.ts +1 -5
  114. package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
  115. package/dist/types/utils/hooks/useTextSelection.d.ts +3 -12
  116. package/dist/types/utils/link_service.d.ts +3 -2
  117. package/dist/types/utils/renderPage.d.ts +2 -2
  118. package/dist/types/utils/types.d.ts +8 -9
  119. package/dist/utils/highlight.js +158 -184
  120. package/dist/utils/hooks/useCopyText.js +22 -60
  121. package/dist/utils/hooks/useFileDownload.js +5 -6
  122. package/dist/utils/hooks/useFlickerSelectText.js +25 -0
  123. package/dist/utils/hooks/useHighlight.js +33 -35
  124. package/dist/utils/hooks/useLicense.js +29 -38
  125. package/dist/utils/hooks/useLoadPdf.js +80 -103
  126. package/dist/utils/hooks/useLoadWorker.js +14 -4
  127. package/dist/utils/hooks/usePageRotateContext.js +7 -8
  128. package/dist/utils/hooks/usePaginate.js +3 -4
  129. package/dist/utils/hooks/usePinch.js +10 -11
  130. package/dist/utils/hooks/usePresentPage.js +3 -4
  131. package/dist/utils/hooks/usePrint.js +78 -74
  132. package/dist/utils/hooks/useRotate.js +3 -4
  133. package/dist/utils/hooks/useScrollToPage.js +3 -4
  134. package/dist/utils/hooks/useSearch.js +15 -18
  135. package/dist/utils/hooks/useTextSelection.js +73 -2
  136. package/dist/utils/hooks/useThumbnail.js +17 -18
  137. package/dist/utils/hooks/useVirtualReactWindow.js +3 -4
  138. package/dist/utils/hooks/useWatermark.js +6 -8
  139. package/dist/utils/link_service.js +19 -18
  140. package/dist/utils/renderPage.js +1 -1
  141. package/dist/utils/types.js +3 -3
  142. package/package.json +14 -3
  143. package/dist/RPLayout.module-7766e0b4.js +0 -14
  144. package/dist/contexts/LayoutDropFileZoneContext.js +0 -11
  145. package/dist/contexts/TextSelectionContext.js +0 -191
  146. package/dist/types/contexts/LayoutDropFileZoneContext.d.ts +0 -9
  147. package/dist/types/contexts/TextSelectionContext.d.ts +0 -14
  148. package/dist/types/utils/geometryCache.d.ts +0 -15
  149. package/dist/types/utils/glyphHitTest.d.ts +0 -12
  150. package/dist/types/utils/hooks/useDropFileZone.d.ts +0 -5
  151. package/dist/types/utils/selectionUtils.d.ts +0 -30
  152. package/dist/utils/geometryCache.js +0 -32
  153. package/dist/utils/glyphHitTest.js +0 -29
  154. package/dist/utils/hooks/useDropFileZone.js +0 -12
  155. package/dist/utils/selectionUtils.js +0 -96
@@ -6,8 +6,7 @@ import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as R } from "../const.js";
6
6
  import "react/jsx-runtime";
7
7
  import "../../contexts/RPDocumentContext.js";
8
8
  import "./useLoadPdf.js";
9
- import "@pdf-viewer/pdfium";
10
- import "@pdf-viewer/pdfium/compat";
9
+ import "pdfjs-dist";
11
10
  import "../getThumbnailViewport.js";
12
11
  import "../../contexts/ConfigContext.js";
13
12
  import "../../contexts/DocumentPasswordContext.js";
@@ -20,8 +19,8 @@ import "../../contexts/RotationContext.js";
20
19
  import "../../contexts/InitialStateContext.js";
21
20
  import "../../contexts/EventCallbackContext.js";
22
21
  import "./useLicense.js";
23
- const W = () => {
24
- const { setSinglePageRotate: r } = c(), { type: i, validating: m } = u(), n = a(() => i !== f.Developer, [i]), p = l(
22
+ const U = () => {
23
+ const { setSinglePageRotate: r } = c(), { type: i, validating: n } = u(), m = a(() => i !== f.Developer, [i]), p = l(
25
24
  (s, t) => {
26
25
  r((o) => {
27
26
  const e = typeof t == "function" ? t(o[s] || 0) : t;
@@ -33,11 +32,11 @@ const W = () => {
33
32
  },
34
33
  [r]
35
34
  );
36
- return { rotate: a(() => m !== !1 ? () => {
37
- } : n ? p : () => {
35
+ return { rotate: a(() => n !== !1 ? () => {
36
+ } : m ? p : () => {
38
37
  console.error(R);
39
- }, [m, n, p]) };
38
+ }, [n, m, p]) };
40
39
  };
41
40
  export {
42
- W as usePageRotateContext
41
+ U as usePageRotateContext
43
42
  };
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../types.js";
3
- import { b as J } from "../../PaginationContext-9217cab4.js";
3
+ import { b as I } from "../../PaginationContext-9217cab4.js";
4
4
  import "../../contexts/ViewModeContext.js";
5
5
  import "../../contexts/ScrollModeContext.js";
6
6
  import "./useDebounce.js";
@@ -10,8 +10,7 @@ import "../../de_DE-a553b162.js";
10
10
  import "react/jsx-runtime";
11
11
  import "../../contexts/RPDocumentContext.js";
12
12
  import "./useLoadPdf.js";
13
- import "@pdf-viewer/pdfium";
14
- import "@pdf-viewer/pdfium/compat";
13
+ import "pdfjs-dist";
15
14
  import "../getThumbnailViewport.js";
16
15
  import "../../contexts/ConfigContext.js";
17
16
  import "../../contexts/DocumentPasswordContext.js";
@@ -34,5 +33,5 @@ import "../getZoomLevel.js";
34
33
  import "../../contexts/RotationContext.js";
35
34
  import "../../contexts/PagesRotateContext.js";
36
35
  export {
37
- J as usePaginate
36
+ I as usePaginate
38
37
  };
@@ -8,8 +8,7 @@ import "../appConsole.js";
8
8
  import "../../contexts/InitialStateContext.js";
9
9
  import "../../contexts/RPDocumentContext.js";
10
10
  import "./useLoadPdf.js";
11
- import "@pdf-viewer/pdfium";
12
- import "@pdf-viewer/pdfium/compat";
11
+ import "pdfjs-dist";
13
12
  import "../getThumbnailViewport.js";
14
13
  import "../../contexts/ConfigContext.js";
15
14
  import "../../contexts/DocumentPasswordContext.js";
@@ -23,7 +22,7 @@ import "../../contexts/ViewModeContext.js";
23
22
  import "../../contexts/RotationContext.js";
24
23
  import "../../contexts/GlobalCurrentPage.js";
25
24
  import "../../contexts/EventCallbackContext.js";
26
- const _ = (o) => {
25
+ const V = (o) => {
27
26
  const { currentZoom: L, setZoomLevel: w } = A(), [D, m] = E(0), d = g(D, 100), [s, b] = E(!1), r = T(null), u = c((e) => {
28
27
  m(e ? (t) => t + 3 : (t) => t - 3);
29
28
  }, []), a = c(
@@ -42,24 +41,24 @@ const _ = (o) => {
42
41
  m(0), w(e > 25 ? e : 25);
43
42
  }
44
43
  }, [d]);
45
- const v = (e, t) => {
44
+ const p = (e, t) => {
46
45
  const n = e.clientX - t.clientX, l = e.clientY - t.clientY;
47
46
  return Math.sqrt(n * n + l * l);
48
47
  }, f = c(
49
48
  (e) => {
50
49
  if (!s || e.touches.length !== 2)
51
50
  return;
52
- const t = v(e.touches[0], e.touches[1]);
51
+ const t = p(e.touches[0], e.touches[1]);
53
52
  r.current = t, e.preventDefault();
54
53
  },
55
54
  [s]
56
55
  ), h = c(() => {
57
56
  r.current = null;
58
- }, []), p = c(
57
+ }, []), v = c(
59
58
  (e) => {
60
59
  if (!s || e.touches.length !== 2 || r.current === null)
61
60
  return;
62
- const t = v(e.touches[0], e.touches[1]), n = t - r.current, l = Math.abs(n) > 5, S = n > 0;
61
+ const t = p(e.touches[0], e.touches[1]), n = t - r.current, l = Math.abs(n) > 5, S = n > 0;
63
62
  l && (u(S), r.current = t, e.preventDefault());
64
63
  },
65
64
  [u, s]
@@ -91,11 +90,11 @@ const _ = (o) => {
91
90
  };
92
91
  }, [o]), i(() => {
93
92
  if (o)
94
- return o.addEventListener("wheel", a, { passive: !1 }), o.addEventListener("touchstart", f, { passive: !1 }), o.addEventListener("touchmove", p, { passive: !1 }), o.addEventListener("touchend", h, { passive: !1 }), () => {
95
- o.removeEventListener("wheel", a), o.removeEventListener("touchstart", f), o.removeEventListener("touchmove", p), o.removeEventListener("touchend", h);
93
+ return o.addEventListener("wheel", a, { passive: !1 }), o.addEventListener("touchstart", f, { passive: !1 }), o.addEventListener("touchmove", v, { passive: !1 }), o.addEventListener("touchend", h, { passive: !1 }), () => {
94
+ o.removeEventListener("wheel", a), o.removeEventListener("touchstart", f), o.removeEventListener("touchmove", v), o.removeEventListener("touchend", h);
96
95
  };
97
- }, [o, a, f, p, h]);
96
+ }, [o, a, f, v, h]);
98
97
  };
99
98
  export {
100
- _ as usePinch
99
+ V as usePinch
101
100
  };
@@ -10,8 +10,7 @@ import "react/jsx-runtime";
10
10
  import "../appConsole.js";
11
11
  import "../../contexts/RPDocumentContext.js";
12
12
  import "./useLoadPdf.js";
13
- import "@pdf-viewer/pdfium";
14
- import "@pdf-viewer/pdfium/compat";
13
+ import "pdfjs-dist";
15
14
  import "../getThumbnailViewport.js";
16
15
  import "../../contexts/ConfigContext.js";
17
16
  import "../../contexts/DocumentPasswordContext.js";
@@ -33,7 +32,7 @@ import "../../contexts/VirtualScrollContext.js";
33
32
  import "../../contexts/VirtualGridContext.js";
34
33
  import "../smoothScrollTo.js";
35
34
  import "../getScrollDistance.js";
36
- const bt = (f, Y, n, W) => {
35
+ const Wt = (f, Y, n, W) => {
37
36
  const P = x(), { contentRef: E } = N(), { heights: h, widths: l } = v(), { setFocusedPage: b } = _(), [S, R] = C([]), { targetScrollPage: L } = G(), i = q(S, 0, 500), I = D(() => {
38
37
  const c = W === M.DUAL_PAGE_WITH_COVER, { rowsHeight: r, columnsWidth: o } = A({ heights: h, widths: l }, f, c);
39
38
  return h.map((m, t) => {
@@ -87,5 +86,5 @@ const bt = (f, Y, n, W) => {
87
86
  }, [n, g]);
88
87
  };
89
88
  export {
90
- bt as usePresentPage
89
+ Wt as usePresentPage
91
90
  };
@@ -1,9 +1,8 @@
1
- import { useState as m, useRef as X, useEffect as x, useCallback as f } from "react";
2
- import { useDocumentContext as k } from "../../contexts/RPDocumentContext.js";
3
- import { PixelsPerInch as q, AnnotationMode as V } from "@pdf-viewer/pdfium/compat";
1
+ import { useState as g, useRef as k, useEffect as D, useCallback as P } from "react";
2
+ import { useDocumentContext as q } from "../../contexts/RPDocumentContext.js";
3
+ import { PixelsPerInch as V, AnnotationMode as O, RenderingCancelledException as U } from "pdfjs-dist";
4
4
  import "react/jsx-runtime";
5
5
  import "./useLoadPdf.js";
6
- import "@pdf-viewer/pdfium";
7
6
  import "../types.js";
8
7
  import "../../de_DE-a553b162.js";
9
8
  import "../getThumbnailViewport.js";
@@ -14,145 +13,150 @@ import "./usePdfProperties.js";
14
13
  import "../convertPdfDate.js";
15
14
  import "../formatFileSize.js";
16
15
  const re = () => {
17
- const { pdf: l, pages: g } = k(), [T, v] = m({
16
+ const { pdf: l, pages: f } = q(), [R, E] = g({
18
17
  loadedPages: 0,
19
18
  totalPages: 0,
20
19
  percentage: 0
21
- }), [A, E] = m(!1), [R, y] = m(!1), [C, b] = m(null), [M, P] = m(void 0), i = X(!1);
22
- x(() => {
20
+ }), [T, y] = g(!1), [A, b] = g(!1), [Z, C] = g(null), [M, w] = g(void 0), i = k(!1);
21
+ D(() => {
23
22
  i.current;
24
23
  }, [i]);
25
- const S = f(() => {
26
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing"), document.querySelector(".rp-print-zone");
27
- }, []), s = f(() => {
28
- i.current = !1, E(!1), y(!1), b(null), P(void 0), v({
24
+ const S = P(() => {
25
+ document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
26
+ const e = document.querySelector(".rp-print-zone");
27
+ e && e.remove();
28
+ }, []), s = P(() => {
29
+ i.current = !1, y(!1), b(!1), C(null), w(void 0), E({
29
30
  loadedPages: 0,
30
31
  totalPages: 0,
31
32
  percentage: 0
32
33
  });
33
- }, []), Z = () => {
34
+ }, []), F = () => {
34
35
  i.current = !0;
35
- }, F = async ({
36
+ }, I = async ({
36
37
  scratchCanvas: e,
37
- pdfDocument: r,
38
+ pdfDocument: n,
38
39
  pageNumber: t,
39
- viewerPdfPage: n,
40
+ viewerPdfPage: r,
40
41
  printResolution: o,
41
- printAnnotationStoragePromise: p
42
+ optionalContentConfigPromise: c,
43
+ printAnnotationStoragePromise: u
42
44
  }) => {
43
45
  if (i.current) {
44
46
  s();
45
47
  return;
46
48
  }
47
- const a = o / q.PDF;
48
- e.width = Math.floor(n.width * a), e.height = Math.floor(n.height * a);
49
- const c = e.getContext("2d");
50
- c.save(), c.fillStyle = "rgb(255, 255, 255)", c.fillRect(0, 0, e.width, e.height), c.restore();
51
- const [d, w] = await Promise.all([
52
- r.getPage(t),
53
- p
49
+ const a = o / V.PDF;
50
+ e.width = Math.floor(r.width * a), e.height = Math.floor(r.height * a);
51
+ const p = e.getContext("2d");
52
+ p.save(), p.fillStyle = "rgb(255, 255, 255)", p.fillRect(0, 0, e.width, e.height), p.restore();
53
+ const [m, h] = await Promise.all([
54
+ n.getPage(t),
55
+ u
54
56
  ]);
55
57
  if (i.current) {
56
58
  s();
57
59
  return;
58
60
  }
59
- const h = {
61
+ const v = {
60
62
  canvas: e,
61
- canvasContext: c,
63
+ canvasContext: p,
62
64
  transform: [a, 0, 0, a, 0, 0],
63
- viewport: d.getViewport({ scale: 1, rotation: n.rotation }),
65
+ viewport: m.getViewport({ scale: 1, rotation: r.rotation }),
64
66
  intent: "print",
65
- annotationMode: V.ENABLE_STORAGE,
66
- printAnnotationStorage: w
67
+ annotationMode: O.ENABLE_STORAGE,
68
+ optionalContentConfigPromise: c,
69
+ printAnnotationStorage: h
67
70
  };
68
71
  try {
69
- return d.render(h).promise;
70
- } catch (u) {
71
- throw console.error(u), u;
72
+ return m.render(v).promise;
73
+ } catch (d) {
74
+ throw d instanceof U || console.error(d), d;
72
75
  }
73
- }, L = f(() => {
76
+ }, L = P(() => {
74
77
  const e = window.print;
75
- return new Promise((r) => {
76
- const t = (p) => {
78
+ return new Promise((n) => {
79
+ const t = (c) => {
77
80
  setTimeout(() => {
78
- e.call(window), setTimeout(() => p(), 20);
81
+ e.call(window), setTimeout(() => c(), 20);
79
82
  }, 0);
80
83
  };
81
84
  if (document.querySelector(".rp-print-zone")) {
82
- t(r);
85
+ t(n);
83
86
  return;
84
87
  }
85
88
  const o = new MutationObserver(() => {
86
- document.querySelector(".rp-print-zone") && (t(r), o.disconnect());
89
+ document.querySelector(".rp-print-zone") && (t(n), o.disconnect());
87
90
  });
88
91
  o.observe(document.body, { childList: !0, subtree: !0 });
89
92
  });
90
- }, []), I = (e) => {
91
- const r = document.createElement("img"), t = document.createElement("div");
92
- return t.classList.add("rp-print-page"), r.src = e.toDataURL(), t.appendChild(r), t;
93
- }, D = (e, r) => {
93
+ }, []), z = (e) => {
94
+ const n = document.createElement("img"), t = document.createElement("div");
95
+ return t.classList.add("rp-print-page"), n.src = e.toDataURL(), t.appendChild(n), t;
96
+ }, x = (e, n) => {
94
97
  const t = document.createElement("div");
95
98
  t.classList.add("rp-print-zone");
96
- const n = document.createElement("style"), o = r.get(1);
99
+ const r = document.createElement("style"), o = n.get(1);
97
100
  if (o) {
98
- const p = o.page.getViewport({ scale: 1 }), { width: a, height: c } = p;
99
- n.innerHTML = `@page { size: ${a}pt ${c}pt; margin: 0; }`;
101
+ const c = o.page.getViewport({ scale: 1 }), { width: u, height: a } = c;
102
+ r.innerHTML = `@page { size: ${u}pt ${a}pt; margin: 0; }`;
100
103
  }
101
- return t.appendChild(n), t.append(...e), t;
102
- }, z = f(
104
+ return t.appendChild(r), t.append(...e), t;
105
+ }, N = P(
103
106
  async (e) => {
104
107
  if (!l)
105
108
  return;
106
109
  s();
107
- const r = e && "visibleDefaultProgress" in e ? e : void 0;
108
- (r == null ? void 0 : r.visibleDefaultProgress) !== void 0 ? P(r.visibleDefaultProgress) : P(!0);
109
- const t = document.createElement("canvas"), n = [];
110
+ const n = e && "visibleDefaultProgress" in e ? e : void 0;
111
+ (n == null ? void 0 : n.visibleDefaultProgress) !== void 0 ? w(n.visibleDefaultProgress) : w(!0);
112
+ const t = document.createElement("canvas"), r = [];
110
113
  try {
111
114
  l.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
112
- const p = Promise.resolve(
115
+ const c = l.getOptionalContentConfig({ intent: "print" }), u = Promise.resolve(
113
116
  l.annotationStorage.print ?? void 0
114
- ), a = g.size;
115
- for (const [d, w] of g) {
117
+ ), a = f.size;
118
+ for (const [m, h] of f) {
116
119
  if (i.current) {
117
120
  s();
118
121
  return;
119
122
  }
120
- const h = w.page.getViewport({ scale: 1 });
121
- if (await F({
123
+ const v = h.page.getViewport({ scale: 1 });
124
+ if (await I({
122
125
  scratchCanvas: t,
123
126
  pdfDocument: l,
124
- pageNumber: d,
125
- viewerPdfPage: h,
127
+ pageNumber: m,
128
+ viewerPdfPage: v,
126
129
  printResolution: 150,
127
- printAnnotationStoragePromise: p
130
+ optionalContentConfigPromise: c,
131
+ printAnnotationStoragePromise: u
128
132
  }), i.current) {
129
133
  s();
130
134
  return;
131
135
  }
132
- const u = I(t);
133
- n.push(u);
134
- const N = parseFloat((n.length / a * 100).toFixed(2));
135
- v({
136
- loadedPages: d,
136
+ const d = z(t);
137
+ r.push(d);
138
+ const X = parseFloat((r.length / a * 100).toFixed(2));
139
+ E({
140
+ loadedPages: m,
137
141
  totalPages: a,
138
- percentage: N
142
+ percentage: X
139
143
  });
140
144
  }
141
145
  if (i.current) {
142
146
  s();
143
147
  return;
144
148
  }
145
- const c = D(n, g);
146
- document.body.appendChild(c), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), E(!0), await L();
149
+ const p = x(r, f);
150
+ document.body.appendChild(p), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), y(!0), await L();
147
151
  } catch (o) {
148
- y(!0), o instanceof Error && b(o);
152
+ b(!0), o instanceof Error && C(o);
149
153
  } finally {
150
154
  t.height = 0, t.width = 0;
151
155
  }
152
156
  },
153
- [l, g, i, s, D, L]
157
+ [l, f, i, s, x, L]
154
158
  );
155
- return x(() => {
159
+ return D(() => {
156
160
  const e = () => {
157
161
  s(), S();
158
162
  };
@@ -160,12 +164,12 @@ const re = () => {
160
164
  window.removeEventListener("afterprint", e, !0);
161
165
  };
162
166
  }, [S, s]), {
163
- print: z,
164
- cancel: Z,
165
- progress: T,
166
- isComplete: A,
167
- isError: R,
168
- error: C,
167
+ print: N,
168
+ cancel: F,
169
+ progress: R,
170
+ isComplete: T,
171
+ isError: A,
172
+ error: Z,
169
173
  showDefaultProgress: M
170
174
  };
171
175
  };
@@ -5,8 +5,7 @@ import "../appConsole.js";
5
5
  import "../../contexts/InitialStateContext.js";
6
6
  import "../../contexts/RPDocumentContext.js";
7
7
  import "./useLoadPdf.js";
8
- import "@pdf-viewer/pdfium";
9
- import "@pdf-viewer/pdfium/compat";
8
+ import "pdfjs-dist";
10
9
  import "../types.js";
11
10
  import "../../de_DE-a553b162.js";
12
11
  import "../getThumbnailViewport.js";
@@ -15,7 +14,7 @@ import "../../contexts/DocumentPasswordContext.js";
15
14
  import "./usePdfProperties.js";
16
15
  import "../convertPdfDate.js";
17
16
  import "../formatFileSize.js";
18
- const j = () => {
17
+ const g = () => {
19
18
  const { setRotate: t } = p(), i = r(() => {
20
19
  t((o) => (o + 90) % 360);
21
20
  }, [t]), m = r(() => {
@@ -24,5 +23,5 @@ const j = () => {
24
23
  return { handleRotateClockwise: i, handleRotateCounterclockwise: m };
25
24
  };
26
25
  export {
27
- j as useRotate
26
+ g as useRotate
28
27
  };
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../../contexts/ScrollModeContext.js";
3
- import { a as H } from "../../PaginationContext-9217cab4.js";
3
+ import { a as G } from "../../PaginationContext-9217cab4.js";
4
4
  import "../../contexts/ViewModeContext.js";
5
5
  import "../types.js";
6
6
  import "../../contexts/VirtualScrollContext.js";
@@ -16,8 +16,7 @@ import "../../contexts/InitialStateContext.js";
16
16
  import "../../de_DE-a553b162.js";
17
17
  import "../../contexts/RPDocumentContext.js";
18
18
  import "./useLoadPdf.js";
19
- import "@pdf-viewer/pdfium";
20
- import "@pdf-viewer/pdfium/compat";
19
+ import "pdfjs-dist";
21
20
  import "../getThumbnailViewport.js";
22
21
  import "../../contexts/ConfigContext.js";
23
22
  import "../../contexts/DocumentPasswordContext.js";
@@ -34,5 +33,5 @@ import "../getZoomLevel.js";
34
33
  import "../../contexts/RotationContext.js";
35
34
  import "../../contexts/PagesRotateContext.js";
36
35
  export {
37
- H as useScrollToPage
36
+ G as useScrollToPage
38
37
  };
@@ -6,22 +6,19 @@ import { useScrollModeContext as ct } from "../../contexts/ScrollModeContext.js"
6
6
  import { useDocumentContext as it } from "../../contexts/RPDocumentContext.js";
7
7
  import { useZoomContext as at } from "../../contexts/ZoomContext.js";
8
8
  import { u as mt } from "../../PaginationContext-9217cab4.js";
9
- import { useViewModeContext as pt } from "../../contexts/ViewModeContext.js";
10
- import { useDimensionPagesContext as ut } from "../../contexts/DimensionPagesContext.js";
9
+ import { useViewModeContext as ut } from "../../contexts/ViewModeContext.js";
10
+ import { useDimensionPagesContext as pt } from "../../contexts/DimensionPagesContext.js";
11
11
  import { useLayoutContainer as lt } from "../../contexts/LayoutContainerContext.js";
12
12
  import { getScrollDistance as F } from "../getScrollDistance.js";
13
13
  import { getWordPositionInPage as ft } from "../getWordPositionInPage.js";
14
14
  import { usePagesRotateContext as gt } from "../../contexts/PagesRotateContext.js";
15
15
  import "../../de_DE-a553b162.js";
16
16
  import "../charators.js";
17
- import "../selectionUtils.js";
18
- import "../geometryCache.js";
19
17
  import "react/jsx-runtime";
20
18
  import "../appConsole.js";
21
19
  import "../../contexts/InitialStateContext.js";
22
20
  import "./useLoadPdf.js";
23
- import "@pdf-viewer/pdfium";
24
- import "@pdf-viewer/pdfium/compat";
21
+ import "pdfjs-dist";
25
22
  import "../getThumbnailViewport.js";
26
23
  import "../../contexts/ConfigContext.js";
27
24
  import "../../contexts/DocumentPasswordContext.js";
@@ -38,8 +35,8 @@ import "../../contexts/VirtualGridContext.js";
38
35
  import "../smoothScrollTo.js";
39
36
  import "../../contexts/SmoothScrollContext.js";
40
37
  import "../calculatePage.js";
41
- const ee = (O = {}, U = "") => {
42
- const [p, q] = C(U), [B, y] = C(!1), { pdf: _, pages: S } = it(), { widths: f, heights: R } = ut(), w = b(!p), { currentZoom: A } = at(), [s, g] = C([]), { setFocusedPage: D } = mt(), { columnCount: G, viewMode: V } = pt(), { pageRotate: v } = gt(), [c, i] = C(0), { pageScrollElementRef: W, virtualScrollableElementRef: Z } = st(), { scrollMode: h } = ct(), { pagesRef: L } = lt(), J = b({}), m = b(0), K = H(() => c === 0 ? null : s[c - 1], [c, s]), a = H(() => s.length, [s]), u = I(
38
+ const Yt = (O = {}, U = "") => {
39
+ const [u, q] = C(U), [B, y] = C(!1), { pdf: _, pages: S } = it(), { widths: f, heights: R } = pt(), w = b(!u), { currentZoom: A } = at(), [s, g] = C([]), { setFocusedPage: D } = mt(), { columnCount: G, viewMode: V } = ut(), { pageRotate: v } = gt(), [c, i] = C(0), { pageScrollElementRef: W, virtualScrollableElementRef: Z } = st(), { scrollMode: h } = ct(), { pagesRef: L } = lt(), J = b({}), m = b(0), K = H(() => c === 0 ? null : s[c - 1], [c, s]), a = H(() => s.length, [s]), p = I(
43
40
  (e) => {
44
41
  if (e === 0)
45
42
  return;
@@ -103,19 +100,19 @@ const ee = (O = {}, U = "") => {
103
100
  ]
104
101
  );
105
102
  z(() => {
106
- c && u(c);
103
+ c && p(c);
107
104
  }, [c]);
108
105
  const Q = I(() => {
109
106
  i((e) => {
110
107
  let t;
111
108
  return a ? e + 1 > a ? t = 1 : t = e + 1 : t = 0, m.current = t, t;
112
- }), m.current === 1 && u(m.current);
113
- }, [a, u]), X = I(() => {
109
+ }), m.current === 1 && p(m.current);
110
+ }, [a, p]), X = I(() => {
114
111
  i((e) => {
115
112
  let t;
116
113
  return a ? e - 1 <= 0 ? t = a : t = e - 1 : t = 0, m.current = t, t;
117
- }), m.current === 1 && u(m.current);
118
- }, [a, u]), j = I(async (e) => {
114
+ }), m.current === 1 && p(m.current);
115
+ }, [a, p]), j = I(async (e) => {
119
116
  if (!e)
120
117
  return {};
121
118
  const t = e.numPages, o = {};
@@ -128,7 +125,7 @@ const ee = (O = {}, U = "") => {
128
125
  return o;
129
126
  }, []);
130
127
  return z(() => {
131
- if (!p) {
128
+ if (!u) {
132
129
  w.current = !0, g([]), i(0);
133
130
  return;
134
131
  }
@@ -136,7 +133,7 @@ const ee = (O = {}, U = "") => {
136
133
  J.current = e;
137
134
  const o = Object.keys(e).reduce((r, n) => {
138
135
  const l = nt(
139
- [p],
136
+ [u],
140
137
  e[n],
141
138
  Number(n) - 1,
142
139
  O
@@ -147,8 +144,8 @@ const ee = (O = {}, U = "") => {
147
144
  }).catch(() => {
148
145
  g([]), i(0);
149
146
  }).finally(() => y(!1));
150
- }, [p, j, _, O]), {
151
- search: p,
147
+ }, [u, j, _, O]), {
148
+ search: u,
152
149
  setSearch: q,
153
150
  loading: B,
154
151
  matches: s,
@@ -161,5 +158,5 @@ const ee = (O = {}, U = "") => {
161
158
  };
162
159
  };
163
160
  export {
164
- ee as useSearch
161
+ Yt as useSearch
165
162
  };
@@ -1,5 +1,76 @@
1
- const o = (e) => {
1
+ import { useCallback as p, useEffect as b } from "react";
2
+ const D = ({ onTextSelect: s, pagesRef: n }) => {
3
+ const f = p(() => {
4
+ const e = n == null ? void 0 : n.querySelectorAll('[data-rp$="-textLayer"]');
5
+ return e ? Array.from(e) : [];
6
+ }, [n]), N = p(() => {
7
+ const e = document.getSelection();
8
+ if (!e || e.rangeCount === 0 || e.toString().trim() === "")
9
+ return null;
10
+ const E = e.toString(), a = /* @__PURE__ */ new Map(), O = f();
11
+ for (let i = 0; i < e.rangeCount; i++) {
12
+ const t = e.getRangeAt(i);
13
+ O.forEach((d) => {
14
+ if (t.intersectsNode(d)) {
15
+ const g = d.getAttribute("data-rp"), T = g == null ? void 0 : g.match(/page-(\d+)-textLayer/);
16
+ if (T) {
17
+ const h = parseInt(T[1]), C = d.closest('[data-rp*="page-"]');
18
+ if (!C)
19
+ return;
20
+ const c = C.getBoundingClientRect();
21
+ a.has(h) || a.set(h, {
22
+ rects: [],
23
+ pageRect: c
24
+ });
25
+ const y = a.get(h), _ = document.createTreeWalker(d, NodeFilter.SHOW_TEXT, null);
26
+ let u;
27
+ for (; u = _.nextNode(); )
28
+ if (t.intersectsNode(u) && u.parentElement) {
29
+ const o = document.createRange();
30
+ o.selectNodeContents(u);
31
+ const A = t.compareBoundaryPoints(Range.START_TO_START, o) > 0 ? t.startContainer : o.startContainer, B = t.compareBoundaryPoints(Range.START_TO_START, o) > 0 ? t.startOffset : o.startOffset, R = t.compareBoundaryPoints(Range.END_TO_END, o) < 0 ? t.endContainer : o.endContainer, S = t.compareBoundaryPoints(Range.END_TO_END, o) < 0 ? t.endOffset : o.endOffset, m = document.createRange();
32
+ m.setStart(A, B), m.setEnd(R, S);
33
+ const r = m.getBoundingClientRect();
34
+ if (r.width === 0 || r.height === 0)
35
+ continue;
36
+ const P = {
37
+ left: r.left - c.left,
38
+ top: r.top - c.top,
39
+ right: r.right - c.left,
40
+ bottom: r.bottom - c.top,
41
+ width: r.width,
42
+ height: r.height
43
+ };
44
+ y.rects.push(P);
45
+ }
46
+ }
47
+ }
48
+ });
49
+ }
50
+ const w = Array.from(a.entries()).sort(([i], [t]) => i - t).map(([i, t]) => ({
51
+ pageNumber: i,
52
+ pageBasedBoundingRects: t.rects,
53
+ pageDimension: {
54
+ width: t.pageRect.width,
55
+ height: t.pageRect.height
56
+ },
57
+ pagePositionInWindow: {
58
+ x: t.pageRect.left,
59
+ y: t.pageRect.top
60
+ }
61
+ }));
62
+ return {
63
+ text: E,
64
+ pageSelections: w
65
+ };
66
+ }, [f]), l = p(() => {
67
+ const e = N();
68
+ e && (s == null || s(e));
69
+ }, [N, s]);
70
+ b(() => (n == null || n.addEventListener("pointerup", l), () => {
71
+ n == null || n.removeEventListener("pointerup", l);
72
+ }), [n, l]);
2
73
  };
3
74
  export {
4
- o as useTextSelection
75
+ D as useTextSelection
5
76
  };