@react-pdf-kit/viewer 2.8.0-beta.0 → 2.8.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +44 -30
  2. package/dist/{AnnotationLayer-C6UTOVmc.js → AnnotationLayer-CyOYh0Tw.js} +2 -2
  3. package/dist/{Button-BNlmxWrV.js → Button-DBu3SaMk.js} +1 -1
  4. package/dist/CanvasLayer-CJqCJ30J.js +111 -0
  5. package/dist/{Checkbox-Brta-YKG.js → Checkbox-CSIEUyO8.js} +4 -4
  6. package/dist/{Combination-DqNkTtir.js → Combination-11kyhTGt.js} +15 -15
  7. package/dist/Container-BuamPhw4.js +18 -0
  8. package/dist/{DocumentDialog-C9G7lVTh.js → DocumentDialog-cRr9sSSH.js} +4 -4
  9. package/dist/{DropDown-DikL-krI.js → DropDown-CM6xEwZC.js} +2 -2
  10. package/dist/{Input-DjSWOjCI.js → Input-Dpo1Xfxe.js} +1 -1
  11. package/dist/{LoaderIcon-D9YjinGf.js → LoaderIcon-B3ddfd0D.js} +1 -1
  12. package/dist/{LoadingIndicator-DiWoWs4Y.js → LoadingIndicator-0E8WHnSN.js} +8 -8
  13. package/dist/MenuItem-lItnKNd5.js +31 -0
  14. package/dist/{MenuSeparator-D1H5l8Ej.js → MenuSeparator-CaFxd8b5.js} +1 -1
  15. package/dist/Paginate.module-DhE7N8AA.js +9 -0
  16. package/dist/PaginationContext-DIzsZhFd.js +194 -0
  17. package/dist/{PasswordModal-BIr84lGN.js → PasswordModal-CxHFn0pB.js} +13 -13
  18. package/dist/{RPDropFileZone-D1C3ouep.js → RPDropFileZone-Bq1bzWmO.js} +1 -1
  19. package/dist/RPLayout.module-BH5r8dDc.js +14 -0
  20. package/dist/RPPages-U8QNLlIa.js +686 -0
  21. package/dist/{RPTooltip-ZZoFqP7C.js → RPTooltip-QWwWh4HW.js} +127 -95
  22. package/dist/SearchTool.module-DY8Ucfb_.js +17 -0
  23. package/dist/{SkipLink-CdcjClGB.js → SkipLink-Dj83gZdk.js} +3 -3
  24. package/dist/{TextLayer-DWGFN9SF.js → TextLayer-D-V9kogG.js} +5 -5
  25. package/dist/{Thumbnail-CU1p9tZ6.js → Thumbnail-BXMk0OWF.js} +8 -8
  26. package/dist/{Thumbnails-VMbfTvqt.js → Thumbnails-BIuN8LZ8.js} +2 -2
  27. package/dist/assets/AnnotationLayer.css +1 -1
  28. package/dist/assets/CanvasLayer.css +1 -0
  29. package/dist/assets/LoadingIndicator.css +1 -1
  30. package/dist/assets/MenuItem.css +1 -1
  31. package/dist/assets/Paginate.css +1 -1
  32. package/dist/assets/PasswordModal.css +1 -1
  33. package/dist/assets/RPLayout.css +1 -1
  34. package/dist/assets/RPPages.css +1 -1
  35. package/dist/assets/SearchTool.css +1 -1
  36. package/dist/assets/SkipLink.css +1 -1
  37. package/dist/assets/TextLayer.css +1 -1
  38. package/dist/assets/Thumbnail.css +1 -1
  39. package/dist/assets/style.js +1 -1
  40. package/dist/{clsx-B7LyVm5O.js → clsx-DSGuh5YW.js} +1 -1
  41. package/dist/components/RPController.js +39 -39
  42. package/dist/components/RPDropFileZone.js +1 -1
  43. package/dist/components/RPPages.js +1 -1
  44. package/dist/components/RPProvider.js +1 -1
  45. package/dist/components/icons/LoaderIcon.js +1 -1
  46. package/dist/components/layout/Container.js +1 -1
  47. package/dist/components/layout/LayoutContainer.js +7 -7
  48. package/dist/components/layout/LayoutWrapper.js +5 -5
  49. package/dist/components/layout/RPDefaultLayout.js +56 -55
  50. package/dist/components/layout/RPLayout.js +39 -38
  51. package/dist/components/layout/SkipLink.js +1 -1
  52. package/dist/components/layout/sidebar/RPSidebar.js +3 -3
  53. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  54. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  55. package/dist/components/layout/toolbar/DarkModeTool.js +2 -2
  56. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  57. package/dist/components/layout/toolbar/DocumentProperties.js +7 -7
  58. package/dist/components/layout/toolbar/FileDownloadTool.js +7 -7
  59. package/dist/components/layout/toolbar/FileUploadTool.js +7 -7
  60. package/dist/components/layout/toolbar/FullScreenTool.js +10 -9
  61. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  62. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  63. package/dist/components/layout/toolbar/MostPageTool.js +25 -31
  64. package/dist/components/layout/toolbar/OtherTool.js +6 -6
  65. package/dist/components/layout/toolbar/Paginate.js +20 -5
  66. package/dist/components/layout/toolbar/PrintTool.js +7 -7
  67. package/dist/components/layout/toolbar/RPMenuItem.js +3 -3
  68. package/dist/components/layout/toolbar/RPMoreOptions.js +6 -6
  69. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  70. package/dist/components/layout/toolbar/RotateTool.js +12 -12
  71. package/dist/components/layout/toolbar/ScrollModeTool.js +18 -18
  72. package/dist/components/layout/toolbar/SearchCloseButton.js +3 -3
  73. package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -3
  74. package/dist/components/layout/toolbar/SearchTool.js +134 -122
  75. package/dist/components/layout/toolbar/SelectionModeTool.js +12 -12
  76. package/dist/components/layout/toolbar/ThumbnailTool.js +2 -2
  77. package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
  78. package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
  79. package/dist/components/layout/toolbar/ViewModeTool.js +18 -18
  80. package/dist/components/layout/toolbar/ZoomTool.js +86 -84
  81. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +3 -3
  82. package/dist/components/layout/toolbar/tools/DualPageTool.js +2 -2
  83. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
  84. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +2 -2
  85. package/dist/components/layout/toolbar/tools/FileUploadTool.js +2 -2
  86. package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
  87. package/dist/components/layout/toolbar/tools/FullScreenTool.js +2 -2
  88. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
  89. package/dist/components/layout/toolbar/tools/InputPageTool.js +37 -26
  90. package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
  91. package/dist/components/layout/toolbar/tools/NextPageTool.js +3 -3
  92. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +2 -2
  93. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +3 -3
  94. package/dist/components/layout/toolbar/tools/PrintTool.js +2 -2
  95. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +2 -2
  96. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +2 -2
  97. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +2 -2
  98. package/dist/components/layout/toolbar/tools/SinglePageTool.js +2 -2
  99. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +2 -2
  100. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +2 -2
  101. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +2 -2
  102. package/dist/components/layout/toolbar/tools/ZoomInTool.js +25 -23
  103. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +1 -1
  104. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +6 -6
  105. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +25 -23
  106. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  107. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
  108. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
  109. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  110. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +5 -5
  111. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
  112. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +4 -4
  113. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +8 -8
  114. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +4 -4
  115. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +4 -4
  116. package/dist/components/page/AnnotationLayer.js +1 -1
  117. package/dist/components/page/CanvasLayer.js +2 -48
  118. package/dist/components/page/DualPage.js +2 -2
  119. package/dist/components/page/DualPageWithCover.js +2 -2
  120. package/dist/components/page/RPPage.js +94 -2
  121. package/dist/components/page/SinglePage.js +2 -2
  122. package/dist/components/page/TextHighlightLayer.js +1 -1
  123. package/dist/components/page/TextLayer.js +1 -1
  124. package/dist/components/ui/Button.js +1 -1
  125. package/dist/components/ui/Checkbox.js +1 -1
  126. package/dist/components/ui/DropDown.js +1 -1
  127. package/dist/components/ui/Input.js +1 -1
  128. package/dist/components/ui/LoadingIndicator.js +1 -1
  129. package/dist/components/ui/PasswordModal.js +1 -1
  130. package/dist/components/ui/RPTooltip.js +1 -1
  131. package/dist/contexts/DimensionPagesContext.js +38 -22
  132. package/dist/contexts/ElementPageContext.js +46 -39
  133. package/dist/contexts/ElementThumbnailContext.js +1 -1
  134. package/dist/contexts/LoaderContext.js +1 -1
  135. package/dist/contexts/LocalizationContext.js +12 -6
  136. package/dist/contexts/PaginationContext.js +1 -1
  137. package/dist/contexts/RenderQueueProvider.js +26 -18
  138. package/dist/contexts/RenderedPagesCache.js +32 -13
  139. package/dist/contexts/VirtualScrollContext.js +10 -13
  140. package/dist/contexts/ZoomContext.js +119 -61
  141. package/dist/{de_DE--0LF-SJR.js → de_DE-x4Z-jQrz.js} +54 -6
  142. package/dist/{dist-7FA4Do6I.js → dist-B2hwhF6G.js} +7 -7
  143. package/dist/{dist-BRVqFn7R.js → dist-BfuBBQ14.js} +6 -6
  144. package/dist/{dist-C3WNMuW2.js → dist-CNbFpoT1.js} +2 -2
  145. package/dist/{dist-bK-AHWLF.js → dist-CgoP608h.js} +7 -7
  146. package/dist/{dist-CKteKPPA.js → dist-VbpVNBs6.js} +7 -7
  147. package/dist/icons.js +1 -1
  148. package/dist/{lib-BiapEtK1.js → lib-CSInlR9T.js} +142 -237
  149. package/dist/{main-B74-PfMa.js → main-DCzVrq0G.js} +3 -3
  150. package/dist/main.js +5 -5
  151. package/dist/style-CJtyyrJx.js +5 -0
  152. package/dist/types/components/page/CanvasLayer.d.ts +4 -1
  153. package/dist/types/components/ui/RPTooltip.d.ts +3 -2
  154. package/dist/types/contexts/RenderQueueProvider.d.ts +2 -0
  155. package/dist/types/contexts/RenderedPagesCache.d.ts +3 -0
  156. package/dist/types/contexts/VirtualScrollContext.d.ts +0 -3
  157. package/dist/types/locales/de_DE.json.d.ts +11 -2
  158. package/dist/types/locales/en_US.json.d.ts +11 -2
  159. package/dist/types/locales/it_IT.json.d.ts +11 -2
  160. package/dist/types/locales/pt_PT.json.d.ts +11 -2
  161. package/dist/types/locales/th_TH.json.d.ts +11 -2
  162. package/dist/types/locales/zh_CN.json.d.ts +11 -2
  163. package/dist/types/utils/Queue.d.ts +1 -0
  164. package/dist/types/utils/const.d.ts +3 -0
  165. package/dist/types/utils/constants.d.ts +9 -0
  166. package/dist/types/utils/documentLayout.d.ts +60 -0
  167. package/dist/types/utils/hooks/usePinch.d.ts +14 -1
  168. package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
  169. package/dist/types/utils/hooks/useZoomOrigin.d.ts +4 -0
  170. package/dist/types/utils/types.d.ts +25 -2
  171. package/dist/types/utils/zoom.d.ts +2 -0
  172. package/dist/utils/Queue.js +5 -0
  173. package/dist/utils/const.js +2 -2
  174. package/dist/utils/constants.js +2 -2
  175. package/dist/utils/documentLayout.js +141 -0
  176. package/dist/utils/hooks/useLicense.js +2 -2
  177. package/dist/utils/hooks/useLoadPdf.js +73 -63
  178. package/dist/utils/hooks/useLocalization.js +1 -1
  179. package/dist/utils/hooks/usePaginate.js +1 -1
  180. package/dist/utils/hooks/usePinch.js +109 -56
  181. package/dist/utils/hooks/usePresentPage.js +33 -57
  182. package/dist/utils/hooks/useScrollToPage.js +1 -1
  183. package/dist/utils/hooks/useSearch.js +66 -67
  184. package/dist/utils/hooks/useZoomOrigin.js +37 -0
  185. package/dist/utils/renderPage.js +21 -14
  186. package/dist/utils/types.js +3 -3
  187. package/dist/utils/zoom.js +8 -2
  188. package/package.json +1 -1
  189. package/dist/Container-DTWaZzc7.js +0 -16
  190. package/dist/MenuItem-BJDWfzAw.js +0 -15
  191. package/dist/Paginate.module-B0GMw-MB.js +0 -8
  192. package/dist/PaginationContext-C5CJiEW-.js +0 -242
  193. package/dist/RPLayout.module-Vc3h4xxS.js +0 -14
  194. package/dist/RPPage-BsDixmqF.js +0 -91
  195. package/dist/RPPages-BkEFexWu.js +0 -1007
  196. package/dist/SearchTool.module-DUkVXfOn.js +0 -16
  197. package/dist/assets/RPPage.css +0 -1
  198. package/dist/contexts/VirtualGridContext.js +0 -18
  199. package/dist/style-BPQRJJJ7.js +0 -5
  200. package/dist/types/contexts/VirtualGridContext.d.ts +0 -9
  201. package/dist/types/utils/calculatePage.d.ts +0 -12
  202. package/dist/types/utils/hooks/useVirtualReactWindow.d.ts +0 -17
  203. package/dist/utils/calculatePage.js +0 -30
  204. package/dist/utils/hooks/useVirtualReactWindow.js +0 -86
  205. /package/dist/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
@@ -1,51 +1,58 @@
1
- import { LicenseType as e, ScrollMode as t } from "../utils/types.js";
2
- import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as n } from "../utils/const.js";
3
- import { useScrollModeContext as r } from "./ScrollModeContext.js";
4
- import { useViewModeContext as i } from "./ViewModeContext.js";
5
- import { useVirtualScrollContext as a } from "./VirtualScrollContext.js";
6
- import { useLayoutContainer as o } from "./LayoutContainerContext.js";
7
- import { useZoomContext as s } from "./ZoomContext.js";
8
- import { usePagesRotateContext as c } from "./PagesRotateContext.js";
9
- import { useDimensionPagesContext as l } from "./DimensionPagesContext.js";
10
- import { useSmoothScrollContext as u } from "./SmoothScrollContext.js";
11
- import { getScrollDistance as d } from "../utils/getScrollDistance.js";
1
+ import { LicenseType as e } from "../utils/types.js";
2
+ import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as t } from "../utils/const.js";
3
+ import { useScrollModeContext as n } from "./ScrollModeContext.js";
4
+ import { useViewModeContext as r } from "./ViewModeContext.js";
5
+ import { useVirtualScrollContext as i } from "./VirtualScrollContext.js";
6
+ import { useLayoutContainer as a } from "./LayoutContainerContext.js";
7
+ import { useZoomContext as o } from "./ZoomContext.js";
8
+ import { usePagesRotateContext as s } from "./PagesRotateContext.js";
9
+ import { useDimensionPagesContext as c } from "./DimensionPagesContext.js";
10
+ import { useSmoothScrollContext as l } from "./SmoothScrollContext.js";
11
+ import { buildDocumentLayout as u, getPagePlacement as d } from "../utils/documentLayout.js";
12
12
  import { useLicenseContext as f } from "./LicenseContext.js";
13
13
  import { getElementPagePosition as p } from "../utils/getElementPositionInPage.js";
14
14
  import { createContext as m, useCallback as h, useContext as g, useMemo as _, useRef as v, useState as y } from "react";
15
15
  import { jsx as b } from "react/jsx-runtime";
16
16
  //#region lib/contexts/ElementPageContext.tsx
17
17
  var x = m(void 0), S = ({ children: e }) => {
18
- let [n, f] = y({}), { widths: m, heights: g } = l(), { pagesRef: _ } = o(), { scrollMode: v } = r(), { pageRotate: S } = c(), { currentZoom: C } = s(), { columnCount: w } = i(), { pageScrollElementRef: T, virtualScrollableElementRef: E } = a(), { scrollBehavior: D } = u(), O = h((e, r, i) => {
19
- let a = i ?? { behavior: D }, o = E || T;
20
- if (!_ || !o) return;
21
- let s = n[e]?.[r];
22
- if (!s) return;
23
- let c = 0, l = 0;
24
- if (v === t.VERTICAL_SCROLLING) {
25
- let t = e - 1, n = w, r = t % n;
26
- c = d(g, Math.floor(t / n)), l = d(m, r);
27
- }
28
- v === t.HORIZONTAL_SCROLLING && (l = m.slice(0, e - 1).reduce((e, t) => e + t, 0));
29
- let u = {
18
+ let [t, f] = y({}), { widths: m, heights: g } = c(), { pagesRef: _ } = a(), { scrollMode: v } = n(), { pageRotate: S } = s(), { currentZoom: C } = o(), { viewMode: w } = r(), { pageScrollElementRef: T, virtualScrollableElementRef: E } = i(), { scrollBehavior: D } = l(), O = h((e, n, r) => {
19
+ let i = r ?? { behavior: D }, a = E || T;
20
+ if (!_ || !a) return;
21
+ let o = t[e]?.[n];
22
+ if (!o) return;
23
+ let s = u({
24
+ pageDimensions: {
25
+ widths: m,
26
+ heights: g
27
+ },
28
+ viewportWidth: a.clientWidth,
29
+ viewportHeight: a.clientHeight,
30
+ scrollMode: v,
31
+ viewMode: w,
32
+ focusedPage: e
33
+ }), c = d(s, e);
34
+ if (!c) return;
35
+ let l = {
30
36
  height: g[e - 1],
31
37
  width: m[e - 1]
32
- }, f = S[e], { left: h, top: y } = p(u, _, s, f, C), b = l + h, x = c + y, O = {
38
+ }, f = S[e], { left: h, top: y } = p(l, _, o, f, C), b = s.offsetLeft + c.left + h, x = s.offsetTop + c.top + y, O = {
33
39
  left: Math.max(b, 0),
34
40
  top: Math.max(x, 0)
35
41
  };
36
- o.scrollTo({
42
+ a.scrollTo({
37
43
  ...O,
38
- behavior: a.behavior
44
+ behavior: i.behavior
39
45
  });
40
46
  }, [
41
- n,
47
+ C,
48
+ t,
42
49
  g,
43
- m,
44
- _,
45
50
  S,
46
- C,
51
+ _,
52
+ D,
47
53
  v,
48
- D
54
+ w,
55
+ m
49
56
  ]), k = h((e, t) => {
50
57
  f((n) => {
51
58
  let r = {
@@ -78,13 +85,13 @@ var x = m(void 0), S = ({ children: e }) => {
78
85
  updateElement: k,
79
86
  clearElements: A,
80
87
  removeElement: j,
81
- elementList: n,
88
+ elementList: t,
82
89
  scrollToElement: O
83
90
  },
84
91
  children: e
85
92
  });
86
93
  }, C = () => {}, w = () => {
87
- let t = g(x), { type: r, validating: i } = f(), a = v(0), o = _(() => {
94
+ let n = g(x), { type: r, validating: i } = f(), a = v(0), o = _(() => {
88
95
  if (i !== !1) return {
89
96
  updateElement: C,
90
97
  clearElements: C,
@@ -94,22 +101,22 @@ var x = m(void 0), S = ({ children: e }) => {
94
101
  };
95
102
  if (r === e.Developer) return {
96
103
  updateElement: () => {
97
- a.current === 0 && (console.error(n), a.current++);
104
+ a.current === 0 && (console.error(t), a.current++);
98
105
  },
99
106
  clearElements: () => {
100
- a.current === 0 && (console.error(n), a.current++);
107
+ a.current === 0 && (console.error(t), a.current++);
101
108
  },
102
109
  removeElement: () => {
103
- a.current === 0 && (console.error(n), a.current++);
110
+ a.current === 0 && (console.error(t), a.current++);
104
111
  },
105
112
  elementList: {},
106
113
  scrollToElement: () => {
107
- a.current === 0 && (console.error(n), a.current++);
114
+ a.current === 0 && (console.error(t), a.current++);
108
115
  }
109
116
  };
110
117
  }, [r, i]);
111
- if (!t) throw Error("useElementPageContext must be used within a ElementPageProvider");
112
- return o || t;
118
+ if (!n) throw Error("useElementPageContext must be used within a ElementPageProvider");
119
+ return o || n;
113
120
  };
114
121
  //#endregion
115
122
  export { x as ElementPageContext, S as ElementPageProvider, w as useElementPageContext };
@@ -2,7 +2,7 @@ import { LicenseType as e } from "../utils/types.js";
2
2
  import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as t } from "../utils/const.js";
3
3
  import { usePagesRotateContext as n } from "./PagesRotateContext.js";
4
4
  import { useSmoothScrollContext as r } from "./SmoothScrollContext.js";
5
- import { r as i } from "../PaginationContext-C5CJiEW-.js";
5
+ import { r as i } from "../PaginationContext-DIzsZhFd.js";
6
6
  import { useThumbnailContext as a } from "./ThumbnailsContext.js";
7
7
  import { useLicenseContext as o } from "./LicenseContext.js";
8
8
  import { createContext as s, useCallback as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
@@ -1,5 +1,5 @@
1
1
  import { appConsole as e } from "../utils/appConsole.js";
2
- import { t } from "../LoaderIcon-D9YjinGf.js";
2
+ import { t } from "../LoaderIcon-B3ddfd0D.js";
3
3
  import { createContext as n, useContext as r } from "react";
4
4
  import { jsx as i } from "react/jsx-runtime";
5
5
  //#region lib/contexts/LoaderContext.tsx
@@ -3,19 +3,25 @@ import { useLocalization as t } from "../utils/hooks/useLocalization.js";
3
3
  import { createContext as n, useContext as r, useEffect as i, useMemo as a } from "react";
4
4
  import { jsx as o } from "react/jsx-runtime";
5
5
  //#region lib/contexts/LocalizationContext.tsx
6
- var s = n({ localeMessages: {} }), c = () => {
6
+ var s = n({
7
+ locale: "en_US",
8
+ localeMessages: {}
9
+ }), c = () => {
7
10
  let t = r(s);
8
11
  return t.localeMessages === void 0 && e.error("Please use this hooks inside children component of RPProvider"), t;
9
12
  }, l = ({ children: e, locale: n = "en_US", localization: r }) => {
10
- let { setLocale: c, localeMessages: l, addLocalization: u } = t(n);
13
+ let { setLocale: c, locale: l, localeMessages: u, addLocalization: d } = t(n);
11
14
  i(() => {
12
15
  n && c(n);
13
16
  }, [n, c]), i(() => {
14
- r && u(r);
15
- }, [r, u]);
16
- let d = a(() => ({ localeMessages: l }), [l]);
17
+ r && d(r);
18
+ }, [r, d]);
19
+ let f = a(() => ({
20
+ locale: l,
21
+ localeMessages: u
22
+ }), [l, u]);
17
23
  return /* @__PURE__ */ o(s.Provider, {
18
- value: d,
24
+ value: f,
19
25
  children: e
20
26
  });
21
27
  };
@@ -1,2 +1,2 @@
1
- import { n as e, r as t, t as n } from "../PaginationContext-C5CJiEW-.js";
1
+ import { n as e, r as t, t as n } from "../PaginationContext-DIzsZhFd.js";
2
2
  export { n as PaginationContext, e as PaginationProvider, t as usePaginationContext };
@@ -1,38 +1,46 @@
1
- import { r as e } from "../PaginationContext-C5CJiEW-.js";
1
+ import { r as e } from "../PaginationContext-DIzsZhFd.js";
2
2
  import { Queue as t } from "../utils/Queue.js";
3
3
  import { renderPage as n } from "../utils/renderPage.js";
4
4
  import { createContext as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
5
5
  import { jsx as u } from "react/jsx-runtime";
6
6
  //#region lib/contexts/RenderQueueProvider.tsx
7
7
  var d = r(null), f = ({ children: r }) => {
8
- let a = c(!1), [f, p] = l([]), m = i((e) => {
9
- p((t) => [...t, {
8
+ let a = c(!1), f = c(/* @__PURE__ */ new Map()), [p, m] = l([]), h = i((e) => {
9
+ m((t) => [...t, {
10
10
  id: e.page.pageNumber.toString(),
11
11
  data: e,
12
12
  priority: 0
13
13
  }]);
14
- }, []), h = s(() => new t(m), [m]), { focusedPage: g } = e(), _ = i((e) => (a.current = !0, n(e.data.page, e.data.canvasElem, e.data.options).promise.then(() => {
15
- e.data.canvasElem.hidden = !1;
16
- }).finally(() => {
17
- e.data.onLoaded && e.data.onLoaded();
18
- })), []);
14
+ }, []), g = s(() => new t(h), [h]), { focusedPage: _ } = e(), v = i((e) => {
15
+ a.current = !0;
16
+ let t = f.current.get(e.id);
17
+ t && (t.cancel(), f.current.delete(e.id));
18
+ let r = n(e.data.page, e.data.canvasElem, e.data.options);
19
+ return f.current.set(e.id, r), e.data.onRenderTask?.(r), r.promise.then(() => {
20
+ e.data.canvasElem.hidden = !1, e.data.onLoaded && e.data.onLoaded();
21
+ }).catch((t) => {
22
+ t.name !== "RenderingCancelledException" && console.error(`Error rendering page ${e.data.page.pageNumber}:`, t);
23
+ }).finally(() => {
24
+ f.current.delete(e.id), e.data.onRenderTask?.(null);
25
+ });
26
+ }, []);
19
27
  return o(() => {
20
- g && (h.changePagePriority(`^page-${g}`, 0), h.changePagePriority(`^thumbnail-${g}`, 1));
21
- }, [g]), o(() => {
22
- if (h.isEmpty() || a.current) return;
28
+ _ && (g.changePagePriority(`^page-${_}`, 0), g.changePagePriority(`^thumbnail-${_}`, 1));
29
+ }, [_]), o(() => {
30
+ if (g.isEmpty() || a.current) return;
23
31
  let e = () => {
24
- let t = h.dequeue();
25
- t ? _(t).finally(() => {
32
+ let t = g.dequeue();
33
+ t ? v(t).catch(() => {}).finally(() => {
26
34
  e();
27
- }) : (a.current = !1, p(h.peekAll()));
35
+ }) : (a.current = !1, m(g.peekAll()));
28
36
  };
29
37
  e();
30
38
  }, [
31
- h,
32
- _,
33
- f
39
+ g,
40
+ v,
41
+ p
34
42
  ]), /* @__PURE__ */ u(d.Provider, {
35
- value: h,
43
+ value: g,
36
44
  children: r
37
45
  });
38
46
  }, p = () => {
@@ -1,18 +1,37 @@
1
- import { createContext as e, useContext as t } from "react";
2
- import { jsx as n } from "react/jsx-runtime";
1
+ import { useDocumentContext as e } from "./RPDocumentContext.js";
2
+ import { createContext as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useRef as o } from "react";
3
+ import { jsx as s } from "react/jsx-runtime";
3
4
  //#region lib/contexts/RenderedPagesCache.tsx
4
- var r = e({
5
+ var c = t({
5
6
  viewports: /* @__PURE__ */ new Map(),
6
- pages: /* @__PURE__ */ new Map()
7
- }), i = () => t(r), a = ({ children: e }) => {
8
- let t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
9
- return /* @__PURE__ */ n(r.Provider, {
10
- value: {
11
- viewports: t,
12
- pages: i
13
- },
14
- children: e
7
+ pages: /* @__PURE__ */ new Map(),
8
+ hasRenderedPage: () => !1,
9
+ markRenderedPage: () => {},
10
+ clearRenderedPages: () => {}
11
+ }), l = () => r(c), u = ({ children: t }) => {
12
+ let { pdfSrc: r } = e(), l = o(/* @__PURE__ */ new Map()), u = o(/* @__PURE__ */ new Map()), d = o(/* @__PURE__ */ new Set()), f = n((e) => d.current.has(e), []), p = n((e) => {
13
+ d.current.add(e);
14
+ }, []), m = n(() => {
15
+ d.current.clear();
16
+ }, []);
17
+ i(() => {
18
+ d.current.clear();
19
+ }, [r]);
20
+ let h = a(() => ({
21
+ viewports: l.current,
22
+ pages: u.current,
23
+ hasRenderedPage: f,
24
+ markRenderedPage: p,
25
+ clearRenderedPages: m
26
+ }), [
27
+ m,
28
+ f,
29
+ p
30
+ ]);
31
+ return /* @__PURE__ */ s(c.Provider, {
32
+ value: h,
33
+ children: t
15
34
  });
16
35
  };
17
36
  //#endregion
18
- export { r as RenderedPagesCacheContext, a as RenderedPagesCacheProvider, i as useRenderedPagesCache };
37
+ export { c as RenderedPagesCacheContext, u as RenderedPagesCacheProvider, l as useRenderedPagesCache };
@@ -2,7 +2,6 @@ import { createContext as e, useContext as t, useState as n } from "react";
2
2
  import { jsx as r } from "react/jsx-runtime";
3
3
  //#region lib/contexts/VirtualScrollContext.tsx
4
4
  var i = e({
5
- getVirtualScrollRef: () => {},
6
5
  getPageScrollElementRef: () => {},
7
6
  getVirtualScrollableElementRef: () => {},
8
7
  scrollPosition: {
@@ -16,25 +15,23 @@ var i = e({
16
15
  },
17
16
  setTotalInnerDimensions: () => {}
18
17
  }), a = () => t(i), o = ({ children: e }) => {
19
- let [t, a] = n(), [o, s] = n(), [c, l] = n(), [u, d] = n({
18
+ let [t, a] = n(), [o, s] = n(), [c, l] = n({
20
19
  scrollTop: 0,
21
20
  scrollLeft: 0
22
- }), [f, p] = n({
21
+ }), [u, d] = n({
23
22
  height: 0,
24
23
  width: 0
25
24
  });
26
25
  return /* @__PURE__ */ r(i.Provider, {
27
26
  value: {
28
- virtualScrollRef: t,
29
- getVirtualScrollRef: a,
30
- pageScrollElementRef: c,
31
- getPageScrollElementRef: l,
32
- virtualScrollableElementRef: o,
33
- getVirtualScrollableElementRef: s,
34
- scrollPosition: u,
35
- setScrollPosition: d,
36
- totalInnerDimensions: f,
37
- setTotalInnerDimensions: p
27
+ pageScrollElementRef: o,
28
+ getPageScrollElementRef: s,
29
+ virtualScrollableElementRef: t,
30
+ getVirtualScrollableElementRef: a,
31
+ scrollPosition: c,
32
+ setScrollPosition: l,
33
+ totalInnerDimensions: u,
34
+ setTotalInnerDimensions: d
38
35
  },
39
36
  children: e
40
37
  });
@@ -3,94 +3,152 @@ import { appConsole as t } from "../utils/appConsole.js";
3
3
  import { useDocumentContext as n } from "./RPDocumentContext.js";
4
4
  import { useInitialStateContext as r } from "./InitialStateContext.js";
5
5
  import { useViewModeContext as i } from "./ViewModeContext.js";
6
- import "../utils/constants.js";
7
- import { getZoomLevel as a } from "../utils/getZoomLevel.js";
8
- import { useLayoutContainer as o } from "./LayoutContainerContext.js";
9
- import { useRotationContext as s } from "./RotationContext.js";
10
- import { useGlobalCurrentPage as c } from "./GlobalCurrentPage.js";
11
- import { useDebounce as l } from "../utils/hooks/useDebounce.js";
12
- import { createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
13
- import { jsx as _ } from "react/jsx-runtime";
6
+ import { MAX_ZOOM_SCALE as a, ZOOM_SAFETY_TIMEOUT_MS as o } from "../utils/constants.js";
7
+ import { getZoomLevel as s } from "../utils/getZoomLevel.js";
8
+ import { useLayoutContainer as c } from "./LayoutContainerContext.js";
9
+ import { useRotationContext as ee } from "./RotationContext.js";
10
+ import { useGlobalCurrentPage as te } from "./GlobalCurrentPage.js";
11
+ import { useDebounce as ne } from "../utils/hooks/useDebounce.js";
12
+ import { createContext as l, useCallback as u, useContext as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
13
+ import { jsx as re } from "react/jsx-runtime";
14
14
  //#region lib/contexts/ZoomContext.tsx
15
- var v = u({
15
+ var g = l({
16
16
  zoomLevel: 100,
17
17
  currentZoom: 1,
18
+ targetZoom: 1,
19
+ isZooming: !1,
20
+ zoomOrigin: null,
21
+ zoomGesture: null,
22
+ previousTargetZoom: null,
23
+ zoomTo: () => {},
18
24
  setZoomLevel: () => {}
19
- }), y = () => {
20
- let e = f(v);
25
+ }), _ = () => {
26
+ let e = d(g);
21
27
  return typeof e.currentZoom != "number" && t.warn("Please use this hooks inside children component of RPProvider"), e;
22
- }, b = ({ children: t }) => {
23
- let { initialScale: u = e.PAGE_FIT } = r(), [f, y] = g(u), { pages: b } = n(), { pagesRef: x } = o(), { viewMode: S } = i(), [C, w] = g({
24
- width: x?.clientWidth || 0,
25
- height: x?.clientHeight || 0
26
- }), T = l(C, 100), { rotate: E } = s(), [D, O] = g(null), k = h(null), { currentPage: A } = c(), [j, M] = g(A);
27
- p(() => {
28
- let e = b.get(j);
29
- e ||= b.get(1);
28
+ }, v = ({ children: t }) => {
29
+ let { initialScale: l = e.PAGE_FIT } = r(), [d, _] = h(l), [v, ie] = h(0), [y, b] = h(0), [x, S] = h(!1), [C, w] = h(null), [T, E] = h(null), [D, O] = h(null), k = m(0), A = m(0), { pages: j } = n(), { pagesRef: M } = c(), { viewMode: N } = i(), [ae, P] = h({
30
+ width: M?.clientWidth || 0,
31
+ height: M?.clientHeight || 0
32
+ }), F = ne(ae, 100), { rotate: I } = ee(), [L, R] = h(null), z = m(null), { currentPage: B } = te(), [V, oe] = h(B), H = m(), U = m(), W = m(), G = m({});
33
+ f(() => {
34
+ let e = j.get(V);
35
+ e ||= j.get(1);
30
36
  let t = e?.page.getViewport({
31
37
  scale: 1,
32
- rotation: e.defaultRotation + E
38
+ rotation: e.defaultRotation + I
33
39
  });
34
- t && JSON.stringify(t) !== JSON.stringify(k.current) && (k.current = t, O(t));
40
+ t && JSON.stringify(t) !== JSON.stringify(z.current) && (z.current = t, R(t));
35
41
  }, [
36
- b,
37
- E,
38
- j
42
+ j,
43
+ I,
44
+ V
39
45
  ]);
40
- let N = d(() => D ? {
41
- pageWidth: (D?.width || 0) + 8,
42
- pageHeight: D?.height || 0,
43
- clientWidth: x?.clientWidth || 0,
44
- clientHeight: x?.clientHeight || 0
45
- } : null, [D, x]), P = m(() => {
46
- let e = N();
47
- if (!T.width || !T.height || !e) return 0;
48
- if (typeof f == "number") return f / 100;
49
- let { clientWidth: t, clientHeight: n, pageWidth: r, pageHeight: i } = e;
50
- return a(f, t, n, r, i, S) / 100;
46
+ let K = u(() => L ? {
47
+ pageWidth: (L?.width || 0) + 8,
48
+ pageHeight: L?.height || 0,
49
+ clientWidth: M?.clientWidth || 0,
50
+ clientHeight: M?.clientHeight || 0
51
+ } : null, [L, M]), q = p(() => {
52
+ let e = K();
53
+ if (!F.width || !F.height || !e) return 0;
54
+ if (typeof d == "number") return Math.max(25, Math.min(d, a)) / 100;
55
+ let { clientWidth: t, clientHeight: n, pageWidth: r, pageHeight: i } = e, o = s(d, t, n, r, i, N) / 100;
56
+ return Math.max(25 / 100, Math.min(o, a / 100));
51
57
  }, [
52
- f,
53
- T,
54
- N,
55
- S
56
- ]);
57
- p(() => {
58
- M(A);
59
- }, [f]), p(() => {
58
+ d,
59
+ F,
60
+ K,
61
+ N
62
+ ]), J = u(() => {
63
+ H.current &&= (clearTimeout(H.current), void 0), U.current &&= (clearTimeout(U.current), void 0), W.current &&= (cancelAnimationFrame(W.current), void 0);
64
+ }, []), Y = u((e) => {
65
+ ie(e), S(!1), w(null), E(null), O(null);
66
+ }, []), X = u((e, t = {}) => {
67
+ if (!e) return;
68
+ let n = k.current === 0;
69
+ if (!(!(Math.abs(e - A.current) > 1e-10) && !n)) {
70
+ if (J(), w(t.origin ?? null), E(t.gesture ?? null), O(t.previousTargetZoom ?? A.current ?? k.current ?? null), A.current = e, b(e), n || t.immediate) {
71
+ Y(e);
72
+ return;
73
+ }
74
+ S(!0), U.current = setTimeout(() => {
75
+ H.current &&= (clearTimeout(H.current), void 0), W.current &&= (cancelAnimationFrame(W.current), void 0), U.current = void 0, Y(e);
76
+ }, o), W.current = requestAnimationFrame(() => {
77
+ W.current = void 0, H.current = setTimeout(() => {
78
+ H.current = void 0, U.current &&= (clearTimeout(U.current), void 0), Y(e);
79
+ }, 400);
80
+ });
81
+ }
82
+ }, [J, Y]);
83
+ f(() => {
84
+ if (!q) return;
85
+ let e = G.current;
86
+ G.current = {}, X(q, e);
87
+ }, [q, X]);
88
+ let Z = u((e) => {
89
+ if (typeof e == "number") return Math.max(25, Math.min(e, a)) / 100;
90
+ let t = K();
91
+ if (!t) return 0;
92
+ let { clientWidth: n, clientHeight: r, pageWidth: i, pageHeight: o } = t, c = s(e, n, r, i, o, N);
93
+ return Math.max(25, Math.min(c, a)) / 100;
94
+ }, [K, N]), Q = u((e, t = {}) => {
95
+ G.current = t, _(e), X(Z(e), t);
96
+ }, [Z, X]);
97
+ f(() => {
98
+ y && (A.current = y);
99
+ }, [y]), f(() => {
100
+ v && (k.current = v);
101
+ }, [v]), f(() => () => {
102
+ J();
103
+ }, [J]), f(() => {
104
+ oe(B);
105
+ }, [d]), f(() => {
60
106
  let e = new ResizeObserver((e) => {
61
107
  e.forEach((e) => {
62
- w({
108
+ P({
63
109
  width: e.contentRect.width,
64
110
  height: e.contentRect.height
65
111
  });
66
112
  });
67
113
  });
68
- return x && e.observe(x), () => {
114
+ return M && e.observe(M), () => {
69
115
  e.disconnect();
70
116
  };
71
- }, [x]);
72
- let F = d((e) => {
117
+ }, [M]);
118
+ let $ = u((e) => {
73
119
  let t = 0;
74
120
  if (typeof e == "function") {
75
- let n = N();
121
+ let n = K();
76
122
  if (!n) return;
77
- let { clientWidth: r, clientHeight: i, pageWidth: o, pageHeight: s } = n;
78
- t = (t) => e(a(t, r, i, o, s, S));
123
+ let { clientWidth: r, clientHeight: i, pageWidth: a, pageHeight: o } = n;
124
+ t = (t) => e(s(t, r, i, a, o, N));
79
125
  } else t = e;
80
- t && y(t);
81
- }, [N]), I = m(() => ({
82
- zoomLevel: f,
83
- currentZoom: P,
84
- setZoomLevel: F
126
+ t && (G.current = {}, _(typeof t == "number" ? Math.max(25, Math.min(t, a)) : t));
127
+ }, [K, N]), se = p(() => ({
128
+ zoomLevel: d,
129
+ currentZoom: v,
130
+ targetZoom: y || v,
131
+ isZooming: x,
132
+ zoomOrigin: C,
133
+ zoomGesture: T,
134
+ previousTargetZoom: D,
135
+ zoomTo: Q,
136
+ setZoomLevel: $
85
137
  }), [
86
- P,
87
- f,
88
- F
138
+ v,
139
+ y,
140
+ x,
141
+ d,
142
+ C,
143
+ T,
144
+ D,
145
+ Q,
146
+ $
89
147
  ]);
90
- return /* @__PURE__ */ _(v.Provider, {
91
- value: I,
148
+ return /* @__PURE__ */ re(g.Provider, {
149
+ value: se,
92
150
  children: t
93
151
  });
94
152
  };
95
153
  //#endregion
96
- export { v as ZoomContext, b as ZoomProvider, y as useZoomContext };
154
+ export { g as ZoomContext, v as ZoomProvider, _ as useZoomContext };