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

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 (130) hide show
  1. package/dist/RPLayout.module-7766e0b4.js +14 -0
  2. package/dist/assets/style.css +1 -1
  3. package/dist/assets/style.js +15 -15
  4. package/dist/components/RPConfig.js +11 -12
  5. package/dist/components/RPController.js +26 -21
  6. package/dist/components/RPDropFileZone.js +8 -7
  7. package/dist/components/RPPages.js +360 -351
  8. package/dist/components/RPProvider.js +24 -20
  9. package/dist/components/layout/LayoutContainer.js +1 -1
  10. package/dist/components/layout/LayoutWrapper.js +1 -1
  11. package/dist/components/layout/RPDefaultLayout.js +7 -4
  12. package/dist/components/layout/RPLayout.js +7 -4
  13. package/dist/components/layout/WrapperLayout.js +4 -3
  14. package/dist/components/layout/sidebar/RPSidebar.js +4 -3
  15. package/dist/components/layout/sidebar/Thumbnail.js +4 -3
  16. package/dist/components/layout/sidebar/Thumbnails.js +4 -3
  17. package/dist/components/layout/toolbar/DocumentDialog.js +6 -5
  18. package/dist/components/layout/toolbar/FileDownloadTool.js +4 -3
  19. package/dist/components/layout/toolbar/FileUploadTool.js +4 -3
  20. package/dist/components/layout/toolbar/MostPageTool.js +4 -3
  21. package/dist/components/layout/toolbar/OtherTool.js +4 -3
  22. package/dist/components/layout/toolbar/Paginate.js +4 -3
  23. package/dist/components/layout/toolbar/PrintTool.js +4 -3
  24. package/dist/components/layout/toolbar/RPMoreOptions.js +4 -3
  25. package/dist/components/layout/toolbar/RPToolbar.js +6 -3
  26. package/dist/components/layout/toolbar/RPToolbarEnd.js +4 -3
  27. package/dist/components/layout/toolbar/RotateTool.js +4 -3
  28. package/dist/components/layout/toolbar/SearchResultNavigator.js +6 -3
  29. package/dist/components/layout/toolbar/SearchTool.js +6 -3
  30. package/dist/components/layout/toolbar/ThumbnailTool.js +4 -3
  31. package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
  32. package/dist/components/layout/toolbar/ToolbarDefault.js +6 -3
  33. package/dist/components/layout/toolbar/ToolbarLayout.js +6 -3
  34. package/dist/components/layout/toolbar/ZoomTool.js +4 -3
  35. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -3
  36. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +9 -5
  37. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -3
  38. package/dist/components/layout/toolbar/tools/FileUploadTool.js +4 -3
  39. package/dist/components/layout/toolbar/tools/FirstPageTool.js +9 -5
  40. package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -3
  41. package/dist/components/layout/toolbar/tools/LastPageTool.js +9 -5
  42. package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -3
  43. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -3
  44. package/dist/components/layout/toolbar/tools/PrintTool.js +4 -3
  45. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +4 -3
  46. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +4 -3
  47. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -3
  48. package/dist/components/layout/toolbar/tools/ZoomInTool.js +4 -3
  49. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +14 -13
  50. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +4 -3
  51. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -3
  52. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -3
  53. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +4 -3
  54. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +4 -3
  55. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +4 -3
  56. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +4 -3
  57. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +4 -3
  58. package/dist/components/page/AnnotationLayer.js +69 -72
  59. package/dist/components/page/CanvasLayer.js +4 -3
  60. package/dist/components/page/CustomElement.js +4 -3
  61. package/dist/components/page/DualPage.js +11 -5
  62. package/dist/components/page/DualPageWithCover.js +11 -5
  63. package/dist/components/page/RPPage.js +12 -6
  64. package/dist/components/page/SinglePage.js +11 -5
  65. package/dist/components/page/TextHighlightLayer.js +86 -178
  66. package/dist/components/page/TextLayer.js +125 -170
  67. package/dist/components/ui/LoadingIndicator.js +8 -7
  68. package/dist/contexts/DimensionPagesContext.js +6 -5
  69. package/dist/contexts/DropFileZoneContext.js +5 -4
  70. package/dist/contexts/ElementPageContext.js +6 -5
  71. package/dist/contexts/FileInputContext.js +6 -5
  72. package/dist/contexts/HighlightContext.js +10 -7
  73. package/dist/contexts/PagesRotateContext.js +6 -5
  74. package/dist/contexts/PaginationContext.js +6 -5
  75. package/dist/contexts/PrintContext.js +17 -16
  76. package/dist/contexts/RPDocumentContext.js +14 -13
  77. package/dist/contexts/RenderQueueProvider.js +6 -5
  78. package/dist/contexts/RotationContext.js +9 -8
  79. package/dist/contexts/SearchContext.js +8 -5
  80. package/dist/contexts/TextSelectionContext.js +191 -0
  81. package/dist/contexts/ThumbnailsContext.js +5 -4
  82. package/dist/contexts/ZoomContext.js +6 -5
  83. package/dist/main.js +116 -113
  84. package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
  85. package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
  86. package/dist/types/contexts/RenderQueueProvider.d.ts +1 -1
  87. package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
  88. package/dist/types/contexts/TextSelectionContext.d.ts +14 -0
  89. package/dist/types/main.d.ts +1 -1
  90. package/dist/types/utils/annotations.d.ts +2 -2
  91. package/dist/types/utils/geometryCache.d.ts +15 -0
  92. package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
  93. package/dist/types/utils/glyphHitTest.d.ts +12 -0
  94. package/dist/types/utils/highlight.d.ts +5 -5
  95. package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
  96. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
  97. package/dist/types/utils/hooks/useLoadWorker.d.ts +5 -1
  98. package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
  99. package/dist/types/utils/hooks/useTextSelection.d.ts +12 -3
  100. package/dist/types/utils/link_service.d.ts +2 -3
  101. package/dist/types/utils/renderPage.d.ts +2 -2
  102. package/dist/types/utils/selectionUtils.d.ts +30 -0
  103. package/dist/types/utils/types.d.ts +5 -7
  104. package/dist/utils/geometryCache.js +32 -0
  105. package/dist/utils/glyphHitTest.js +29 -0
  106. package/dist/utils/highlight.js +184 -158
  107. package/dist/utils/hooks/useCopyText.js +60 -22
  108. package/dist/utils/hooks/useFileDownload.js +6 -5
  109. package/dist/utils/hooks/useHighlight.js +35 -33
  110. package/dist/utils/hooks/useLicense.js +62 -62
  111. package/dist/utils/hooks/useLoadPdf.js +102 -70
  112. package/dist/utils/hooks/useLoadWorker.js +4 -14
  113. package/dist/utils/hooks/usePageRotateContext.js +8 -7
  114. package/dist/utils/hooks/usePaginate.js +4 -3
  115. package/dist/utils/hooks/usePinch.js +11 -10
  116. package/dist/utils/hooks/usePresentPage.js +4 -3
  117. package/dist/utils/hooks/usePrint.js +74 -78
  118. package/dist/utils/hooks/useRotate.js +4 -3
  119. package/dist/utils/hooks/useScrollToPage.js +4 -3
  120. package/dist/utils/hooks/useSearch.js +18 -15
  121. package/dist/utils/hooks/useTextSelection.js +2 -73
  122. package/dist/utils/hooks/useThumbnail.js +18 -17
  123. package/dist/utils/hooks/useVirtualReactWindow.js +4 -3
  124. package/dist/utils/link_service.js +18 -19
  125. package/dist/utils/renderPage.js +1 -1
  126. package/dist/utils/selectionUtils.js +96 -0
  127. package/package.json +2 -3
  128. package/dist/RPLayout.module-b4b23e29.js +0 -14
  129. package/dist/types/utils/hooks/useFlickerSelectText.d.ts +0 -1
  130. package/dist/utils/hooks/useFlickerSelectText.js +0 -25
@@ -6,7 +6,8 @@ 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 "pdfjs-dist";
9
+ import "@pdf-viewer/pdfium";
10
+ import "@pdf-viewer/pdfium/compat";
10
11
  import "../getThumbnailViewport.js";
11
12
  import "../../contexts/ConfigContext.js";
12
13
  import "../../contexts/DocumentPasswordContext.js";
@@ -19,8 +20,8 @@ import "../../contexts/RotationContext.js";
19
20
  import "../../contexts/InitialStateContext.js";
20
21
  import "../../contexts/EventCallbackContext.js";
21
22
  import "./useLicense.js";
22
- const U = () => {
23
- const { setSinglePageRotate: r } = c(), { type: i, validating: n } = u(), m = a(() => i !== f.Developer, [i]), p = l(
23
+ const W = () => {
24
+ const { setSinglePageRotate: r } = c(), { type: i, validating: m } = u(), n = a(() => i !== f.Developer, [i]), p = l(
24
25
  (s, t) => {
25
26
  r((o) => {
26
27
  const e = typeof t == "function" ? t(o[s] || 0) : t;
@@ -32,11 +33,11 @@ const U = () => {
32
33
  },
33
34
  [r]
34
35
  );
35
- return { rotate: a(() => n !== !1 ? () => {
36
- } : m ? p : () => {
36
+ return { rotate: a(() => m !== !1 ? () => {
37
+ } : n ? p : () => {
37
38
  console.error(R);
38
- }, [n, m, p]) };
39
+ }, [m, n, p]) };
39
40
  };
40
41
  export {
41
- U as usePageRotateContext
42
+ W as usePageRotateContext
42
43
  };
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../types.js";
3
- import { b as I } from "../../PaginationContext-9217cab4.js";
3
+ import { b as J } from "../../PaginationContext-9217cab4.js";
4
4
  import "../../contexts/ViewModeContext.js";
5
5
  import "../../contexts/ScrollModeContext.js";
6
6
  import "./useDebounce.js";
@@ -10,7 +10,8 @@ import "../../de_DE-a553b162.js";
10
10
  import "react/jsx-runtime";
11
11
  import "../../contexts/RPDocumentContext.js";
12
12
  import "./useLoadPdf.js";
13
- import "pdfjs-dist";
13
+ import "@pdf-viewer/pdfium";
14
+ import "@pdf-viewer/pdfium/compat";
14
15
  import "../getThumbnailViewport.js";
15
16
  import "../../contexts/ConfigContext.js";
16
17
  import "../../contexts/DocumentPasswordContext.js";
@@ -33,5 +34,5 @@ import "../getZoomLevel.js";
33
34
  import "../../contexts/RotationContext.js";
34
35
  import "../../contexts/PagesRotateContext.js";
35
36
  export {
36
- I as usePaginate
37
+ J as usePaginate
37
38
  };
@@ -8,7 +8,8 @@ import "../appConsole.js";
8
8
  import "../../contexts/InitialStateContext.js";
9
9
  import "../../contexts/RPDocumentContext.js";
10
10
  import "./useLoadPdf.js";
11
- import "pdfjs-dist";
11
+ import "@pdf-viewer/pdfium";
12
+ import "@pdf-viewer/pdfium/compat";
12
13
  import "../getThumbnailViewport.js";
13
14
  import "../../contexts/ConfigContext.js";
14
15
  import "../../contexts/DocumentPasswordContext.js";
@@ -22,7 +23,7 @@ import "../../contexts/ViewModeContext.js";
22
23
  import "../../contexts/RotationContext.js";
23
24
  import "../../contexts/GlobalCurrentPage.js";
24
25
  import "../../contexts/EventCallbackContext.js";
25
- const V = (o) => {
26
+ const _ = (o) => {
26
27
  const { currentZoom: L, setZoomLevel: w } = A(), [D, m] = E(0), d = g(D, 100), [s, b] = E(!1), r = T(null), u = c((e) => {
27
28
  m(e ? (t) => t + 3 : (t) => t - 3);
28
29
  }, []), a = c(
@@ -41,24 +42,24 @@ const V = (o) => {
41
42
  m(0), w(e > 25 ? e : 25);
42
43
  }
43
44
  }, [d]);
44
- const p = (e, t) => {
45
+ const v = (e, t) => {
45
46
  const n = e.clientX - t.clientX, l = e.clientY - t.clientY;
46
47
  return Math.sqrt(n * n + l * l);
47
48
  }, f = c(
48
49
  (e) => {
49
50
  if (!s || e.touches.length !== 2)
50
51
  return;
51
- const t = p(e.touches[0], e.touches[1]);
52
+ const t = v(e.touches[0], e.touches[1]);
52
53
  r.current = t, e.preventDefault();
53
54
  },
54
55
  [s]
55
56
  ), h = c(() => {
56
57
  r.current = null;
57
- }, []), v = c(
58
+ }, []), p = c(
58
59
  (e) => {
59
60
  if (!s || e.touches.length !== 2 || r.current === null)
60
61
  return;
61
- const t = p(e.touches[0], e.touches[1]), n = t - r.current, l = Math.abs(n) > 5, S = n > 0;
62
+ const t = v(e.touches[0], e.touches[1]), n = t - r.current, l = Math.abs(n) > 5, S = n > 0;
62
63
  l && (u(S), r.current = t, e.preventDefault());
63
64
  },
64
65
  [u, s]
@@ -90,11 +91,11 @@ const V = (o) => {
90
91
  };
91
92
  }, [o]), i(() => {
92
93
  if (o)
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);
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);
95
96
  };
96
- }, [o, a, f, v, h]);
97
+ }, [o, a, f, p, h]);
97
98
  };
98
99
  export {
99
- V as usePinch
100
+ _ as usePinch
100
101
  };
@@ -10,7 +10,8 @@ import "react/jsx-runtime";
10
10
  import "../appConsole.js";
11
11
  import "../../contexts/RPDocumentContext.js";
12
12
  import "./useLoadPdf.js";
13
- import "pdfjs-dist";
13
+ import "@pdf-viewer/pdfium";
14
+ import "@pdf-viewer/pdfium/compat";
14
15
  import "../getThumbnailViewport.js";
15
16
  import "../../contexts/ConfigContext.js";
16
17
  import "../../contexts/DocumentPasswordContext.js";
@@ -32,7 +33,7 @@ import "../../contexts/VirtualScrollContext.js";
32
33
  import "../../contexts/VirtualGridContext.js";
33
34
  import "../smoothScrollTo.js";
34
35
  import "../getScrollDistance.js";
35
- const Wt = (f, Y, n, W) => {
36
+ const bt = (f, Y, n, W) => {
36
37
  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(() => {
37
38
  const c = W === M.DUAL_PAGE_WITH_COVER, { rowsHeight: r, columnsWidth: o } = A({ heights: h, widths: l }, f, c);
38
39
  return h.map((m, t) => {
@@ -86,5 +87,5 @@ const Wt = (f, Y, n, W) => {
86
87
  }, [n, g]);
87
88
  };
88
89
  export {
89
- Wt as usePresentPage
90
+ bt as usePresentPage
90
91
  };
@@ -1,8 +1,9 @@
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";
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";
4
4
  import "react/jsx-runtime";
5
5
  import "./useLoadPdf.js";
6
+ import "@pdf-viewer/pdfium";
6
7
  import "../types.js";
7
8
  import "../../de_DE-a553b162.js";
8
9
  import "../getThumbnailViewport.js";
@@ -13,150 +14,145 @@ import "./usePdfProperties.js";
13
14
  import "../convertPdfDate.js";
14
15
  import "../formatFileSize.js";
15
16
  const re = () => {
16
- const { pdf: l, pages: f } = q(), [R, E] = g({
17
+ const { pdf: l, pages: g } = k(), [T, v] = m({
17
18
  loadedPages: 0,
18
19
  totalPages: 0,
19
20
  percentage: 0
20
- }), [T, y] = g(!1), [A, b] = g(!1), [Z, C] = g(null), [M, w] = g(void 0), i = k(!1);
21
- D(() => {
21
+ }), [A, E] = m(!1), [R, y] = m(!1), [C, b] = m(null), [M, P] = m(void 0), i = X(!1);
22
+ x(() => {
22
23
  i.current;
23
24
  }, [i]);
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({
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({
30
29
  loadedPages: 0,
31
30
  totalPages: 0,
32
31
  percentage: 0
33
32
  });
34
- }, []), F = () => {
33
+ }, []), Z = () => {
35
34
  i.current = !0;
36
- }, I = async ({
35
+ }, F = async ({
37
36
  scratchCanvas: e,
38
- pdfDocument: n,
37
+ pdfDocument: r,
39
38
  pageNumber: t,
40
- viewerPdfPage: r,
39
+ viewerPdfPage: n,
41
40
  printResolution: o,
42
- optionalContentConfigPromise: c,
43
- printAnnotationStoragePromise: u
41
+ printAnnotationStoragePromise: p
44
42
  }) => {
45
43
  if (i.current) {
46
44
  s();
47
45
  return;
48
46
  }
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
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
56
54
  ]);
57
55
  if (i.current) {
58
56
  s();
59
57
  return;
60
58
  }
61
- const v = {
59
+ const h = {
62
60
  canvas: e,
63
- canvasContext: p,
61
+ canvasContext: c,
64
62
  transform: [a, 0, 0, a, 0, 0],
65
- viewport: m.getViewport({ scale: 1, rotation: r.rotation }),
63
+ viewport: d.getViewport({ scale: 1, rotation: n.rotation }),
66
64
  intent: "print",
67
- annotationMode: O.ENABLE_STORAGE,
68
- optionalContentConfigPromise: c,
69
- printAnnotationStorage: h
65
+ annotationMode: V.ENABLE_STORAGE,
66
+ printAnnotationStorage: w
70
67
  };
71
68
  try {
72
- return m.render(v).promise;
73
- } catch (d) {
74
- throw d instanceof U || console.error(d), d;
69
+ return d.render(h).promise;
70
+ } catch (u) {
71
+ throw console.error(u), u;
75
72
  }
76
- }, L = P(() => {
73
+ }, L = f(() => {
77
74
  const e = window.print;
78
- return new Promise((n) => {
79
- const t = (c) => {
75
+ return new Promise((r) => {
76
+ const t = (p) => {
80
77
  setTimeout(() => {
81
- e.call(window), setTimeout(() => c(), 20);
78
+ e.call(window), setTimeout(() => p(), 20);
82
79
  }, 0);
83
80
  };
84
81
  if (document.querySelector(".rp-print-zone")) {
85
- t(n);
82
+ t(r);
86
83
  return;
87
84
  }
88
85
  const o = new MutationObserver(() => {
89
- document.querySelector(".rp-print-zone") && (t(n), o.disconnect());
86
+ document.querySelector(".rp-print-zone") && (t(r), o.disconnect());
90
87
  });
91
88
  o.observe(document.body, { childList: !0, subtree: !0 });
92
89
  });
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) => {
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) => {
97
94
  const t = document.createElement("div");
98
95
  t.classList.add("rp-print-zone");
99
- const r = document.createElement("style"), o = n.get(1);
96
+ const n = document.createElement("style"), o = r.get(1);
100
97
  if (o) {
101
- const c = o.page.getViewport({ scale: 1 }), { width: u, height: a } = c;
102
- r.innerHTML = `@page { size: ${u}pt ${a}pt; margin: 0; }`;
98
+ const p = o.page.getViewport({ scale: 1 }), { width: a, height: c } = p;
99
+ n.innerHTML = `@page { size: ${a}pt ${c}pt; margin: 0; }`;
103
100
  }
104
- return t.appendChild(r), t.append(...e), t;
105
- }, N = P(
101
+ return t.appendChild(n), t.append(...e), t;
102
+ }, z = f(
106
103
  async (e) => {
107
104
  if (!l)
108
105
  return;
109
106
  s();
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 = [];
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 = [];
113
110
  try {
114
111
  l.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
115
- const c = l.getOptionalContentConfig({ intent: "print" }), u = Promise.resolve(
112
+ const p = Promise.resolve(
116
113
  l.annotationStorage.print ?? void 0
117
- ), a = f.size;
118
- for (const [m, h] of f) {
114
+ ), a = g.size;
115
+ for (const [d, w] of g) {
119
116
  if (i.current) {
120
117
  s();
121
118
  return;
122
119
  }
123
- const v = h.page.getViewport({ scale: 1 });
124
- if (await I({
120
+ const h = w.page.getViewport({ scale: 1 });
121
+ if (await F({
125
122
  scratchCanvas: t,
126
123
  pdfDocument: l,
127
- pageNumber: m,
128
- viewerPdfPage: v,
124
+ pageNumber: d,
125
+ viewerPdfPage: h,
129
126
  printResolution: 150,
130
- optionalContentConfigPromise: c,
131
- printAnnotationStoragePromise: u
127
+ printAnnotationStoragePromise: p
132
128
  }), i.current) {
133
129
  s();
134
130
  return;
135
131
  }
136
- const d = z(t);
137
- r.push(d);
138
- const X = parseFloat((r.length / a * 100).toFixed(2));
139
- E({
140
- loadedPages: m,
132
+ const u = I(t);
133
+ n.push(u);
134
+ const N = parseFloat((n.length / a * 100).toFixed(2));
135
+ v({
136
+ loadedPages: d,
141
137
  totalPages: a,
142
- percentage: X
138
+ percentage: N
143
139
  });
144
140
  }
145
141
  if (i.current) {
146
142
  s();
147
143
  return;
148
144
  }
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();
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();
151
147
  } catch (o) {
152
- b(!0), o instanceof Error && C(o);
148
+ y(!0), o instanceof Error && b(o);
153
149
  } finally {
154
150
  t.height = 0, t.width = 0;
155
151
  }
156
152
  },
157
- [l, f, i, s, x, L]
153
+ [l, g, i, s, D, L]
158
154
  );
159
- return D(() => {
155
+ return x(() => {
160
156
  const e = () => {
161
157
  s(), S();
162
158
  };
@@ -164,12 +160,12 @@ const re = () => {
164
160
  window.removeEventListener("afterprint", e, !0);
165
161
  };
166
162
  }, [S, s]), {
167
- print: N,
168
- cancel: F,
169
- progress: R,
170
- isComplete: T,
171
- isError: A,
172
- error: Z,
163
+ print: z,
164
+ cancel: Z,
165
+ progress: T,
166
+ isComplete: A,
167
+ isError: R,
168
+ error: C,
173
169
  showDefaultProgress: M
174
170
  };
175
171
  };
@@ -5,7 +5,8 @@ import "../appConsole.js";
5
5
  import "../../contexts/InitialStateContext.js";
6
6
  import "../../contexts/RPDocumentContext.js";
7
7
  import "./useLoadPdf.js";
8
- import "pdfjs-dist";
8
+ import "@pdf-viewer/pdfium";
9
+ import "@pdf-viewer/pdfium/compat";
9
10
  import "../types.js";
10
11
  import "../../de_DE-a553b162.js";
11
12
  import "../getThumbnailViewport.js";
@@ -14,7 +15,7 @@ import "../../contexts/DocumentPasswordContext.js";
14
15
  import "./usePdfProperties.js";
15
16
  import "../convertPdfDate.js";
16
17
  import "../formatFileSize.js";
17
- const g = () => {
18
+ const j = () => {
18
19
  const { setRotate: t } = p(), i = r(() => {
19
20
  t((o) => (o + 90) % 360);
20
21
  }, [t]), m = r(() => {
@@ -23,5 +24,5 @@ const g = () => {
23
24
  return { handleRotateClockwise: i, handleRotateCounterclockwise: m };
24
25
  };
25
26
  export {
26
- g as useRotate
27
+ j as useRotate
27
28
  };
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../../contexts/ScrollModeContext.js";
3
- import { a as G } from "../../PaginationContext-9217cab4.js";
3
+ import { a as H } from "../../PaginationContext-9217cab4.js";
4
4
  import "../../contexts/ViewModeContext.js";
5
5
  import "../types.js";
6
6
  import "../../contexts/VirtualScrollContext.js";
@@ -16,7 +16,8 @@ import "../../contexts/InitialStateContext.js";
16
16
  import "../../de_DE-a553b162.js";
17
17
  import "../../contexts/RPDocumentContext.js";
18
18
  import "./useLoadPdf.js";
19
- import "pdfjs-dist";
19
+ import "@pdf-viewer/pdfium";
20
+ import "@pdf-viewer/pdfium/compat";
20
21
  import "../getThumbnailViewport.js";
21
22
  import "../../contexts/ConfigContext.js";
22
23
  import "../../contexts/DocumentPasswordContext.js";
@@ -33,5 +34,5 @@ import "../getZoomLevel.js";
33
34
  import "../../contexts/RotationContext.js";
34
35
  import "../../contexts/PagesRotateContext.js";
35
36
  export {
36
- G as useScrollToPage
37
+ H as useScrollToPage
37
38
  };
@@ -6,19 +6,22 @@ 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 ut } from "../../contexts/ViewModeContext.js";
10
- import { useDimensionPagesContext as pt } from "../../contexts/DimensionPagesContext.js";
9
+ import { useViewModeContext as pt } from "../../contexts/ViewModeContext.js";
10
+ import { useDimensionPagesContext as ut } 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";
17
19
  import "react/jsx-runtime";
18
20
  import "../appConsole.js";
19
21
  import "../../contexts/InitialStateContext.js";
20
22
  import "./useLoadPdf.js";
21
- import "pdfjs-dist";
23
+ import "@pdf-viewer/pdfium";
24
+ import "@pdf-viewer/pdfium/compat";
22
25
  import "../getThumbnailViewport.js";
23
26
  import "../../contexts/ConfigContext.js";
24
27
  import "../../contexts/DocumentPasswordContext.js";
@@ -35,8 +38,8 @@ import "../../contexts/VirtualGridContext.js";
35
38
  import "../smoothScrollTo.js";
36
39
  import "../../contexts/SmoothScrollContext.js";
37
40
  import "../calculatePage.js";
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(
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(
40
43
  (e) => {
41
44
  if (e === 0)
42
45
  return;
@@ -100,19 +103,19 @@ const Yt = (O = {}, U = "") => {
100
103
  ]
101
104
  );
102
105
  z(() => {
103
- c && p(c);
106
+ c && u(c);
104
107
  }, [c]);
105
108
  const Q = I(() => {
106
109
  i((e) => {
107
110
  let t;
108
111
  return a ? e + 1 > a ? t = 1 : t = e + 1 : t = 0, m.current = t, t;
109
- }), m.current === 1 && p(m.current);
110
- }, [a, p]), X = I(() => {
112
+ }), m.current === 1 && u(m.current);
113
+ }, [a, u]), X = I(() => {
111
114
  i((e) => {
112
115
  let t;
113
116
  return a ? e - 1 <= 0 ? t = a : t = e - 1 : t = 0, m.current = t, t;
114
- }), m.current === 1 && p(m.current);
115
- }, [a, p]), j = I(async (e) => {
117
+ }), m.current === 1 && u(m.current);
118
+ }, [a, u]), j = I(async (e) => {
116
119
  if (!e)
117
120
  return {};
118
121
  const t = e.numPages, o = {};
@@ -125,7 +128,7 @@ const Yt = (O = {}, U = "") => {
125
128
  return o;
126
129
  }, []);
127
130
  return z(() => {
128
- if (!u) {
131
+ if (!p) {
129
132
  w.current = !0, g([]), i(0);
130
133
  return;
131
134
  }
@@ -133,7 +136,7 @@ const Yt = (O = {}, U = "") => {
133
136
  J.current = e;
134
137
  const o = Object.keys(e).reduce((r, n) => {
135
138
  const l = nt(
136
- [u],
139
+ [p],
137
140
  e[n],
138
141
  Number(n) - 1,
139
142
  O
@@ -144,8 +147,8 @@ const Yt = (O = {}, U = "") => {
144
147
  }).catch(() => {
145
148
  g([]), i(0);
146
149
  }).finally(() => y(!1));
147
- }, [u, j, _, O]), {
148
- search: u,
150
+ }, [p, j, _, O]), {
151
+ search: p,
149
152
  setSearch: q,
150
153
  loading: B,
151
154
  matches: s,
@@ -158,5 +161,5 @@ const Yt = (O = {}, U = "") => {
158
161
  };
159
162
  };
160
163
  export {
161
- Yt as useSearch
164
+ ee as useSearch
162
165
  };
@@ -1,76 +1,5 @@
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]);
1
+ const o = (e) => {
73
2
  };
74
3
  export {
75
- D as useTextSelection
4
+ o as useTextSelection
76
5
  };