@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.
Files changed (157) hide show
  1. package/README.md +84 -49
  2. package/dist/{Combination-54a77a7a.js → Combination-17ab8af1.js} +184 -187
  3. package/dist/assets/style.css +1 -1
  4. package/dist/assets/style.js +8 -8
  5. package/dist/components/RPConfig.js +5 -7
  6. package/dist/components/RPController.js +76 -77
  7. package/dist/components/RPDropFileZone.js +4 -3
  8. package/dist/components/RPPages.js +577 -573
  9. package/dist/components/RPProvider.js +2 -2
  10. package/dist/components/layout/RPDefaultLayout.js +10 -9
  11. package/dist/components/layout/RPLayout.js +10 -9
  12. package/dist/components/layout/WrapperLayout.js +4 -3
  13. package/dist/components/layout/sidebar/RPSidebar.js +8 -7
  14. package/dist/components/layout/sidebar/Thumbnail.js +4 -3
  15. package/dist/components/layout/sidebar/Thumbnails.js +4 -3
  16. package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
  17. package/dist/components/layout/toolbar/DocumentDialog.js +43 -34
  18. package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
  19. package/dist/components/layout/toolbar/FileDownloadTool.js +10 -9
  20. package/dist/components/layout/toolbar/FileUploadTool.js +10 -9
  21. package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
  22. package/dist/components/layout/toolbar/MenuItem.js +6 -6
  23. package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
  24. package/dist/components/layout/toolbar/MostPageTool.js +10 -9
  25. package/dist/components/layout/toolbar/OtherTool.js +10 -9
  26. package/dist/components/layout/toolbar/Paginate.js +8 -7
  27. package/dist/components/layout/toolbar/PrintTool.js +10 -9
  28. package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
  29. package/dist/components/layout/toolbar/RPMoreOptions.js +10 -9
  30. package/dist/components/layout/toolbar/RPToolbar.js +10 -9
  31. package/dist/components/layout/toolbar/RPToolbarEnd.js +10 -9
  32. package/dist/components/layout/toolbar/RotateTool.js +10 -9
  33. package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
  34. package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
  35. package/dist/components/layout/toolbar/SearchResultNavigator.js +23 -30
  36. package/dist/components/layout/toolbar/SearchTool.js +104 -100
  37. package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
  38. package/dist/components/layout/toolbar/ThumbnailTool.js +8 -7
  39. package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
  40. package/dist/components/layout/toolbar/ToolbarDefault.js +10 -9
  41. package/dist/components/layout/toolbar/ToolbarLayout.js +10 -9
  42. package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
  43. package/dist/components/layout/toolbar/ZoomTool.js +10 -9
  44. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +9 -8
  45. package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
  46. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +10 -11
  47. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +8 -7
  48. package/dist/components/layout/toolbar/tools/FileUploadTool.js +8 -7
  49. package/dist/components/layout/toolbar/tools/FirstPageTool.js +10 -11
  50. package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
  51. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
  52. package/dist/components/layout/toolbar/tools/InputPageTool.js +8 -7
  53. package/dist/components/layout/toolbar/tools/LastPageTool.js +10 -11
  54. package/dist/components/layout/toolbar/tools/NextPageTool.js +8 -7
  55. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
  56. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +8 -7
  57. package/dist/components/layout/toolbar/tools/PrintTool.js +8 -7
  58. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +8 -7
  59. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +8 -7
  60. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
  61. package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
  62. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
  63. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +8 -7
  64. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
  65. package/dist/components/layout/toolbar/tools/ZoomInTool.js +8 -7
  66. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +20 -19
  67. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +8 -7
  68. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +10 -9
  69. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +8 -7
  70. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
  71. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +10 -9
  72. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +10 -9
  73. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
  74. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +10 -9
  75. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +10 -9
  76. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +10 -9
  77. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
  78. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
  79. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
  80. package/dist/components/page/AnnotationLayer.js +25 -24
  81. package/dist/components/page/CanvasLayer.js +38 -54
  82. package/dist/components/page/CustomElement.js +4 -3
  83. package/dist/components/page/DualPage.js +2 -2
  84. package/dist/components/page/DualPageWithCover.js +2 -2
  85. package/dist/components/page/RPPage.js +35 -35
  86. package/dist/components/page/SinglePage.js +2 -2
  87. package/dist/components/page/TextHighlightLayer.js +16 -15
  88. package/dist/components/page/TextLayer.js +27 -28
  89. package/dist/components/ui/Checkbox.js +2 -2
  90. package/dist/components/ui/DropDown.js +6 -6
  91. package/dist/components/ui/Input.js +10 -10
  92. package/dist/components/ui/LoadingIndicator.js +8 -7
  93. package/dist/components/ui/RPTooltip.js +197 -411
  94. package/dist/contexts/DimensionPagesContext.js +28 -56
  95. package/dist/contexts/DropFileZoneContext.js +5 -4
  96. package/dist/contexts/ElementPageContext.js +6 -5
  97. package/dist/contexts/FileInputContext.js +6 -5
  98. package/dist/contexts/HighlightContext.js +6 -5
  99. package/dist/contexts/InitialStateContext.js +6 -8
  100. package/dist/contexts/PagesRotateContext.js +6 -5
  101. package/dist/contexts/PaginationContext.js +6 -5
  102. package/dist/contexts/PrintContext.js +17 -16
  103. package/dist/contexts/RPDocumentContext.js +14 -13
  104. package/dist/contexts/RenderQueueProvider.js +14 -13
  105. package/dist/contexts/RotationContext.js +9 -8
  106. package/dist/contexts/SearchContext.js +6 -5
  107. package/dist/contexts/ThumbnailsContext.js +5 -4
  108. package/dist/contexts/ZoomContext.js +6 -5
  109. package/dist/{index-c0faa594.js → index-113053cf.js} +2 -2
  110. package/dist/index-11f3cd64.js +983 -0
  111. package/dist/{index-e3ee9457.js → index-23911b43.js} +6 -6
  112. package/dist/{index-655864a7.js → index-ada501c4.js} +1 -1
  113. package/dist/index-d0f0aa9a.js +1542 -0
  114. package/dist/main.js +47 -47
  115. package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
  116. package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
  117. package/dist/types/contexts/RenderQueueProvider.d.ts +1 -2
  118. package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
  119. package/dist/types/main.d.ts +3 -1
  120. package/dist/types/utils/annotations.d.ts +2 -2
  121. package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
  122. package/dist/types/utils/highlight.d.ts +5 -5
  123. package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
  124. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
  125. package/dist/types/utils/hooks/useLoadWorker.d.ts +5 -1
  126. package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
  127. package/dist/types/utils/hooks/useWatermark.d.ts +1 -1
  128. package/dist/types/utils/link_service.d.ts +2 -3
  129. package/dist/types/utils/renderPage.d.ts +2 -2
  130. package/dist/types/utils/types.d.ts +7 -8
  131. package/dist/utils/highlight.js +36 -36
  132. package/dist/utils/hooks/useFileDownload.js +6 -5
  133. package/dist/utils/hooks/useHighlight.js +78 -40
  134. package/dist/utils/hooks/useLicense.js +1 -1
  135. package/dist/utils/hooks/useLoadPdf.js +96 -70
  136. package/dist/utils/hooks/useLoadWorker.js +4 -14
  137. package/dist/utils/hooks/usePageRotateContext.js +8 -7
  138. package/dist/utils/hooks/usePaginate.js +4 -3
  139. package/dist/utils/hooks/usePinch.js +44 -90
  140. package/dist/utils/hooks/usePresentPage.js +4 -3
  141. package/dist/utils/hooks/usePrint.js +92 -100
  142. package/dist/utils/hooks/useRotate.js +4 -3
  143. package/dist/utils/hooks/useScrollToPage.js +4 -3
  144. package/dist/utils/hooks/useSearch.js +16 -15
  145. package/dist/utils/hooks/useThumbnail.js +18 -17
  146. package/dist/utils/hooks/useVirtualReactWindow.js +4 -3
  147. package/dist/utils/hooks/useWatermark.js +43 -61
  148. package/dist/utils/injectPrintCSS.js +4 -3
  149. package/dist/utils/link_service.js +18 -19
  150. package/dist/utils/renderPage.js +14 -14
  151. package/package.json +2 -3
  152. package/dist/contexts/SmoothScaleContext.js +0 -67
  153. package/dist/floating-ui.react-dom-5ec29bd6.js +0 -1327
  154. package/dist/index-4baea9b5.js +0 -1198
  155. package/dist/types/contexts/SmoothScaleContext.d.ts +0 -16
  156. package/dist/types/utils/hooks/useAccumulateFactor.d.ts +0 -9
  157. package/dist/utils/hooks/useAccumulateFactor.js +0 -17
@@ -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
  };
@@ -1,7 +1,6 @@
1
- import { useState as Z, useRef as f, useEffect as i, useCallback as u } from "react";
2
- import { useZoomContext as G } from "../../contexts/ZoomContext.js";
3
- import { useSmoothScaleContext as N } from "../../contexts/SmoothScaleContext.js";
4
- import { useAccumulateFactor as D } from "./useAccumulateFactor.js";
1
+ import { useState as E, useRef as T, useCallback as c, useEffect as i } from "react";
2
+ import { useDebounce as g } from "./useDebounce.js";
3
+ import { useZoomContext as A } from "../../contexts/ZoomContext.js";
5
4
  import "react/jsx-runtime";
6
5
  import "../types.js";
7
6
  import "../../de_DE-a553b162.js";
@@ -9,7 +8,8 @@ import "../appConsole.js";
9
8
  import "../../contexts/InitialStateContext.js";
10
9
  import "../../contexts/RPDocumentContext.js";
11
10
  import "./useLoadPdf.js";
12
- import "pdfjs-dist";
11
+ import "@pdf-viewer/pdfium";
12
+ import "@pdf-viewer/pdfium/compat";
13
13
  import "../getThumbnailViewport.js";
14
14
  import "../../contexts/ConfigContext.js";
15
15
  import "../../contexts/DocumentPasswordContext.js";
@@ -23,93 +23,47 @@ import "../../contexts/ViewModeContext.js";
23
23
  import "../../contexts/RotationContext.js";
24
24
  import "../../contexts/GlobalCurrentPage.js";
25
25
  import "../../contexts/EventCallbackContext.js";
26
- import "./useDebounce.js";
27
- const O = 35, z = 0.25, B = 10, Ee = (n) => {
28
- const { currentZoom: v, setZoomLevel: d } = G(), { zoomOriginRef: h } = N(), [s, k] = Z(!1), a = f(v), E = f(!1), l = f(null), m = f(!1), { accumulate: M, reset: A } = D(), { accumulate: C } = D();
29
- i(() => {
30
- a.current = v;
31
- }, [v]);
32
- const p = u(
33
- (e) => {
34
- const t = a.current, o = Math.max(z, Math.min(B, t * e)), r = Math.round(o * 100);
35
- d(r);
36
- },
37
- [d]
38
- ), S = u(
39
- (e) => {
40
- const t = a.current, o = e ? 3 : -3, r = Math.round(t * 100 + o);
41
- d(Math.max(25, Math.min(1e3, r)));
42
- },
43
- [d]
44
- );
45
- i(() => {
46
- const e = (o) => {
47
- o.key === "Control" && (E.current = !0);
48
- }, t = (o) => {
49
- o.key === "Control" && (E.current = !1);
50
- };
51
- return window.addEventListener("keydown", e), window.addEventListener("keyup", t), () => {
52
- window.removeEventListener("keydown", e), window.removeEventListener("keyup", t);
53
- };
54
- }, []);
55
- const w = u(
26
+ const _ = (o) => {
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) => {
28
+ m(e ? (t) => t + 3 : (t) => t - 3);
29
+ }, []), a = c(
56
30
  (e) => {
57
- if (!e.ctrlKey && !e.metaKey)
31
+ if (!e.ctrlKey)
58
32
  return;
59
33
  e.preventDefault();
60
- const t = { x: e.clientX, y: e.clientY };
61
- h.current = t;
62
- const o = Math.exp(-e.deltaY / 100);
63
- if (e.ctrlKey && !E.current && e.deltaMode === WheelEvent.DOM_DELTA_PIXEL && e.deltaX === 0 && Math.abs(o - 1) < 0.05) {
64
- const c = C(a.current, o);
65
- c !== 1 && c !== 0 && p(c);
66
- } else {
67
- const c = e.deltaY < 0;
68
- S(c);
69
- }
34
+ const t = e.deltaY < 0;
35
+ u(t);
70
36
  },
71
- [h, C, p, S]
72
- ), L = u(
37
+ [u]
38
+ );
39
+ i(() => {
40
+ if (d) {
41
+ const e = Math.round(L * 100 + d);
42
+ m(0), w(e > 25 ? e : 25);
43
+ }
44
+ }, [d]);
45
+ const v = (e, t) => {
46
+ const n = e.clientX - t.clientX, l = e.clientY - t.clientY;
47
+ return Math.sqrt(n * n + l * l);
48
+ }, f = c(
73
49
  (e) => {
74
50
  if (!s || e.touches.length !== 2)
75
51
  return;
76
- let [t, o] = Array.from(e.touches);
77
- t.identifier > o.identifier && ([t, o] = [o, t]), l.current = {
78
- touch0X: t.screenX,
79
- touch0Y: t.screenY,
80
- touch1X: o.screenX,
81
- touch1Y: o.screenY
82
- }, m.current = !1, e.preventDefault();
52
+ const t = v(e.touches[0], e.touches[1]);
53
+ r.current = t, e.preventDefault();
83
54
  },
84
55
  [s]
85
- ), y = u(() => {
86
- l.current = null, m.current = !1, A();
87
- }, [A]), X = u(
56
+ ), h = c(() => {
57
+ r.current = null;
58
+ }, []), p = c(
88
59
  (e) => {
89
- if (!s || e.touches.length !== 2 || !l.current)
90
- return;
91
- let [t, o] = Array.from(e.touches);
92
- t.identifier > o.identifier && ([t, o] = [o, t]);
93
- const r = l.current, c = r.touch1X - r.touch0X, I = r.touch1Y - r.touch0Y, T = Math.hypot(c, I) || 1, F = o.screenX - t.screenX, P = o.screenY - t.screenY, x = Math.hypot(F, P) || 1, R = O / (window.devicePixelRatio || 1);
94
- if (!m.current && Math.abs(T - x) <= R)
95
- return;
96
- if (l.current = {
97
- touch0X: t.screenX,
98
- touch0Y: t.screenY,
99
- touch1X: o.screenX,
100
- touch1Y: o.screenY
101
- }, !m.current) {
102
- m.current = !0;
60
+ if (!s || e.touches.length !== 2 || r.current === null)
103
61
  return;
104
- }
105
- e.preventDefault(), e.stopPropagation();
106
- const _ = (t.clientX + o.clientX) / 2, b = (t.clientY + o.clientY) / 2;
107
- h.current = { x: _, y: b };
108
- const K = x / T, Y = M(a.current, K);
109
- Y !== 1 && Y !== 0 && p(Y);
62
+ const t = v(e.touches[0], e.touches[1]), n = t - r.current, l = Math.abs(n) > 5, S = n > 0;
63
+ l && (u(S), r.current = t, e.preventDefault());
110
64
  },
111
- [s, h, M, p]
112
- ), g = () => {
65
+ [u, s]
66
+ ), y = () => {
113
67
  document.activeElement instanceof HTMLElement && document.activeElement.blur();
114
68
  };
115
69
  i(() => {
@@ -120,28 +74,28 @@ const O = 35, z = 0.25, B = 10, Ee = (n) => {
120
74
  document.body.style.touchAction = "";
121
75
  }, [s]), i(() => {
122
76
  const e = () => {
123
- const t = document.activeElement, o = !!(t != null && t.closest('[data-rp="container"]'));
124
- k(o);
77
+ const t = document.activeElement, n = !!(t != null && t.closest('[data-rp="container"]'));
78
+ b(n);
125
79
  };
126
80
  return window.addEventListener("focusin", e), window.addEventListener("focusout", e), e(), () => {
127
81
  window.removeEventListener("focusin", e), window.removeEventListener("focusout", e);
128
82
  };
129
83
  }, []), i(() => {
130
- if (!n)
84
+ if (!o)
131
85
  return;
132
86
  const e = (t) => {
133
- n.contains(t.target) || g();
87
+ o.contains(t.target) || y();
134
88
  };
135
89
  return document.addEventListener("scroll", e), () => {
136
90
  document.removeEventListener("scroll", e);
137
91
  };
138
- }, [n]), i(() => {
139
- if (n)
140
- return n.addEventListener("wheel", w, { passive: !1 }), n.addEventListener("touchstart", L, { passive: !1 }), n.addEventListener("touchmove", X, { passive: !1 }), n.addEventListener("touchend", y, { passive: !1 }), () => {
141
- n.removeEventListener("wheel", w), n.removeEventListener("touchstart", L), n.removeEventListener("touchmove", X), n.removeEventListener("touchend", y);
92
+ }, [o]), i(() => {
93
+ 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);
142
96
  };
143
- }, [n, w, L, X, y]);
97
+ }, [o, a, f, p, h]);
144
98
  };
145
99
  export {
146
- Ee as usePinch
100
+ _ as usePinch
147
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 N, useEffect as R, useCallback as P } from "react";
2
- import { useDocumentContext as O } from "../../contexts/RPDocumentContext.js";
3
- import { PixelsPerInch as X, AnnotationMode as q, RenderingCancelledException as B } from "pdfjs-dist";
1
+ import { useState as g, useRef as k, useEffect as x, useCallback as P } from "react";
2
+ import { useDocumentContext as q } from "../../contexts/RPDocumentContext.js";
3
+ import { PixelsPerInch as V, AnnotationMode as O } 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";
@@ -12,174 +13,165 @@ import "../appConsole.js";
12
13
  import "./usePdfProperties.js";
13
14
  import "../convertPdfDate.js";
14
15
  import "../formatFileSize.js";
15
- const re = () => {
16
- const { pdf: l, pages: f } = O(), [D, E] = g({
16
+ const ne = () => {
17
+ const { pdf: l, pages: f } = q(), [T, E] = g({
17
18
  loadedPages: 0,
18
19
  totalPages: 0,
19
20
  percentage: 0
20
- }), [T, b] = g(!1), [A, y] = g(!1), [Z, L] = g(null), [F, w] = g(void 0), s = N(!1);
21
- R(() => {
22
- s.current;
23
- }, [s]);
21
+ }), [A, y] = g(!1), [R, b] = g(!1), [M, S] = g(null), [Z, w] = g(void 0), i = k(!1);
22
+ x(() => {
23
+ i.current;
24
+ }, [i]);
24
25
  const C = 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
- }, []), a = P(() => {
29
- s.current = !1, b(!1), y(!1), L(null), w(void 0), E({
26
+ document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing"), document.querySelector(".rp-print-zone");
27
+ }, []), s = P(() => {
28
+ i.current = !1, y(!1), b(!1), S(null), w(void 0), E({
30
29
  loadedPages: 0,
31
30
  totalPages: 0,
32
31
  percentage: 0
33
32
  });
34
- }, []), M = () => {
35
- s.current = !0;
33
+ }, []), F = () => {
34
+ i.current = !0;
36
35
  }, I = async ({
37
36
  scratchCanvas: e,
38
- pdfDocument: n,
37
+ pdfDocument: r,
39
38
  pageNumber: t,
40
- viewerPdfPage: o,
41
- printResolution: r,
42
- optionalContentConfigPromise: i,
43
- printAnnotationStoragePromise: u
39
+ viewerPdfPage: n,
40
+ printResolution: o,
41
+ optionalContentConfigPromise: c,
42
+ printAnnotationStoragePromise: d
44
43
  }) => {
45
- if (s.current) {
46
- a();
44
+ if (i.current) {
45
+ s();
47
46
  return;
48
47
  }
49
- const c = r / X.PDF;
50
- e.width = Math.floor(o.width * c), e.height = Math.floor(o.height * c);
48
+ const a = o / V.PDF;
49
+ e.width = Math.floor(n.width * a), e.height = Math.floor(n.height * a);
51
50
  const p = e.getContext("2d");
52
51
  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
52
+ const [u, h] = await Promise.all([
53
+ r.getPage(t),
54
+ d
56
55
  ]);
57
- if (s.current) {
58
- a();
56
+ if (i.current) {
57
+ s();
59
58
  return;
60
59
  }
61
60
  const v = {
62
61
  canvas: e,
63
62
  canvasContext: p,
64
- transform: [c, 0, 0, c, 0, 0],
65
- viewport: m.getViewport({ scale: 1, rotation: o.rotation }),
63
+ transform: [a, 0, 0, a, 0, 0],
64
+ viewport: u.getViewport({ scale: 1, rotation: n.rotation }),
66
65
  intent: "print",
67
- annotationMode: q.ENABLE_STORAGE,
68
- optionalContentConfigPromise: i,
66
+ annotationMode: O.ENABLE_STORAGE,
67
+ optionalContentConfigPromise: c,
69
68
  printAnnotationStorage: h
70
69
  };
71
70
  try {
72
- return m.render(v).promise;
73
- } catch (d) {
74
- throw d instanceof B || console.error(d), d;
71
+ return u.render(v).promise;
72
+ } catch (m) {
73
+ throw console.error(m), m;
75
74
  }
76
- }, S = P(() => {
75
+ }, L = P(() => {
77
76
  const e = window.print;
78
- return new Promise((n) => {
79
- const t = (i) => {
77
+ return new Promise((r) => {
78
+ const t = (c) => {
80
79
  setTimeout(() => {
81
- e.call(window), setTimeout(() => i(), 20);
80
+ e.call(window), setTimeout(() => c(), 20);
82
81
  }, 0);
83
82
  };
84
83
  if (document.querySelector(".rp-print-zone")) {
85
- t(n);
84
+ t(r);
86
85
  return;
87
86
  }
88
- const r = new MutationObserver(() => {
89
- document.querySelector(".rp-print-zone") && (t(n), r.disconnect());
87
+ const o = new MutationObserver(() => {
88
+ document.querySelector(".rp-print-zone") && (t(r), o.disconnect());
90
89
  });
91
- r.observe(document.body, { childList: !0, subtree: !0 });
90
+ o.observe(document.body, { childList: !0, subtree: !0 });
92
91
  });
93
- }, []), U = async (e) => {
94
- const n = document.createElement("img"), t = document.createElement("div");
95
- return t.classList.add("rp-print-page"), await new Promise((o, r) => {
96
- e.toBlob((i) => {
97
- i ? (n.src = URL.createObjectURL(i), n.onload = () => {
98
- URL.revokeObjectURL(n.src), o();
99
- }, n.onerror = r) : r(new Error("Failed to create blob"));
100
- });
101
- }).catch(() => {
102
- }), t.appendChild(n), t;
103
- }, x = (e, n) => {
92
+ }, []), z = (e) => {
93
+ const r = document.createElement("img"), t = document.createElement("div");
94
+ return t.classList.add("rp-print-page"), r.src = e.toDataURL(), t.appendChild(r), t;
95
+ }, D = (e, r) => {
104
96
  const t = document.createElement("div");
105
97
  t.classList.add("rp-print-zone");
106
- const o = document.createElement("style"), r = n.get(1);
107
- if (r) {
108
- const { width: i, height: u } = r == null ? void 0 : r.page.getViewport({ scale: 1 });
109
- o.innerHTML = `@page { size: ${i}px ${u}px }`;
98
+ const n = document.createElement("style"), o = r.get(1);
99
+ if (o) {
100
+ const c = o.page.getViewport({ scale: 1 }), { width: d, height: a } = c;
101
+ n.innerHTML = `@page { size: ${d}pt ${a}pt; margin: 0; }`;
110
102
  }
111
- return t.appendChild(o), t.append(...e), t;
112
- }, k = P(
103
+ return t.appendChild(n), t.append(...e), t;
104
+ }, N = P(
113
105
  async (e) => {
114
106
  if (!l)
115
107
  return;
116
- a();
117
- const n = e && "visibleDefaultProgress" in e ? e : void 0;
118
- (n == null ? void 0 : n.visibleDefaultProgress) !== void 0 ? w(n.visibleDefaultProgress) : w(!0);
119
- const t = document.createElement("canvas"), o = [];
108
+ s();
109
+ const r = e && "visibleDefaultProgress" in e ? e : void 0;
110
+ (r == null ? void 0 : r.visibleDefaultProgress) !== void 0 ? w(r.visibleDefaultProgress) : w(!0);
111
+ const t = document.createElement("canvas"), n = [];
120
112
  try {
121
113
  l.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
122
- const i = l.getOptionalContentConfig({ intent: "print" }), u = Promise.resolve(
114
+ const c = l.getOptionalContentConfig({ intent: "print" }), d = Promise.resolve(
123
115
  l.annotationStorage.print ?? void 0
124
- ), c = f.size;
125
- for (const [m, h] of f) {
126
- if (s.current) {
127
- a();
116
+ ), a = f.size;
117
+ for (const [u, h] of f) {
118
+ if (i.current) {
119
+ s();
128
120
  return;
129
121
  }
130
122
  const v = h.page.getViewport({ scale: 1 });
131
123
  if (await I({
132
124
  scratchCanvas: t,
133
125
  pdfDocument: l,
134
- pageNumber: m,
126
+ pageNumber: u,
135
127
  viewerPdfPage: v,
136
128
  printResolution: 150,
137
- optionalContentConfigPromise: i,
138
- printAnnotationStoragePromise: u
139
- }), s.current) {
140
- a();
129
+ optionalContentConfigPromise: c,
130
+ printAnnotationStoragePromise: d
131
+ }), i.current) {
132
+ s();
141
133
  return;
142
134
  }
143
- const d = await U(t);
144
- o.push(d);
145
- const z = parseFloat((o.length / c * 100).toFixed(2));
135
+ const m = z(t);
136
+ n.push(m);
137
+ const X = parseFloat((n.length / a * 100).toFixed(2));
146
138
  E({
147
- loadedPages: m,
148
- totalPages: c,
149
- percentage: z
139
+ loadedPages: u,
140
+ totalPages: a,
141
+ percentage: X
150
142
  });
151
143
  }
152
- if (s.current) {
153
- a();
144
+ if (i.current) {
145
+ s();
154
146
  return;
155
147
  }
156
- const p = x(o, f);
157
- document.body.appendChild(p), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), b(!0), await S();
158
- } catch (r) {
159
- y(!0), r instanceof Error && L(r);
148
+ const p = D(n, f);
149
+ document.body.appendChild(p), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), y(!0), await L();
150
+ } catch (o) {
151
+ b(!0), o instanceof Error && S(o);
160
152
  } finally {
161
153
  t.height = 0, t.width = 0;
162
154
  }
163
155
  },
164
- [l, f, s, a, x, S]
156
+ [l, f, i, s, D, L]
165
157
  );
166
- return R(() => {
158
+ return x(() => {
167
159
  const e = () => {
168
- a(), C();
160
+ s(), C();
169
161
  };
170
162
  return window.addEventListener("afterprint", e, !0), () => {
171
163
  window.removeEventListener("afterprint", e, !0);
172
164
  };
173
- }, [C, a]), {
174
- print: k,
175
- cancel: M,
176
- progress: D,
177
- isComplete: T,
178
- isError: A,
179
- error: Z,
180
- showDefaultProgress: F
165
+ }, [C, s]), {
166
+ print: N,
167
+ cancel: F,
168
+ progress: T,
169
+ isComplete: A,
170
+ isError: R,
171
+ error: M,
172
+ showDefaultProgress: Z
181
173
  };
182
174
  };
183
175
  export {
184
- re as usePrint
176
+ ne as usePrint
185
177
  };
@@ -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
  };