@pdf-viewer/react 1.5.1 → 1.6.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 (94) hide show
  1. package/dist/RPDefaultLayout-4518b3d3.js +3059 -0
  2. package/dist/SearchCloseButton-959cc1ed.js +32 -0
  3. package/dist/assets/Container.css +1 -1
  4. package/dist/assets/PasswordModal.css +1 -0
  5. package/dist/assets/RPDefaultLayout.css +1 -1
  6. package/dist/assets/SearchCloseButton.css +1 -0
  7. package/dist/components/RPController.js +1 -1
  8. package/dist/components/RPPages.js +4 -2
  9. package/dist/components/RPProvider.js +13 -12
  10. package/dist/components/layout/Container.js +7 -6
  11. package/dist/components/layout/LayoutContainer.js +3 -2
  12. package/dist/components/layout/RPDefaultLayout.js +1 -1
  13. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  14. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  15. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  16. package/dist/components/layout/toolbar/DocumentDialog.js +3 -2
  17. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  18. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  19. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  20. package/dist/components/layout/toolbar/MostPageTool.js +4 -3
  21. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  22. package/dist/components/layout/toolbar/Paginate.js +1 -1
  23. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  24. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  25. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  26. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  27. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  28. package/dist/components/layout/toolbar/SearchCloseButton.js +9 -0
  29. package/dist/components/layout/toolbar/SearchResultNavigator.js +10 -0
  30. package/dist/components/layout/toolbar/SearchTool.js +5 -4
  31. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  32. package/dist/components/layout/toolbar/ViewModeTool.js +18 -19
  33. package/dist/components/layout/toolbar/ZoomTool.js +8 -27
  34. package/dist/components/page/AnnotationLayer.js +3 -2
  35. package/dist/components/page/CanvasLayer.js +3 -2
  36. package/dist/components/page/DualPage.js +1 -1
  37. package/dist/components/page/RPPage.js +3 -2
  38. package/dist/components/page/SinglePage.js +1 -1
  39. package/dist/components/page/TextHighlightLayer.js +3 -2
  40. package/dist/components/page/TextLayer.js +3 -2
  41. package/dist/components/ui/Checkbox.js +14 -13
  42. package/dist/components/ui/DropDown.js +1 -1
  43. package/dist/components/ui/LoadingIndicator.js +1 -1
  44. package/dist/components/ui/PasswordModal.js +58 -0
  45. package/dist/components/ui/RPTooltip.js +689 -331
  46. package/dist/contexts/DocumentPasswordContext.js +40 -0
  47. package/dist/contexts/PaginationContext.js +1 -1
  48. package/dist/contexts/PrintContext.js +1 -1
  49. package/dist/contexts/RPDocumentContext.js +11 -8
  50. package/dist/contexts/SearchContext.js +1 -1
  51. package/dist/contexts/SmoothScrollContext.js +8 -9
  52. package/dist/contexts/ThumbnailsContext.js +1 -1
  53. package/dist/contexts/ToolbarComponentContext.js +2 -2
  54. package/dist/contexts/ViewModeContext.js +16 -17
  55. package/dist/contexts/ZoomContext.js +17 -16
  56. package/dist/index-2e540713.js +23 -0
  57. package/dist/index-353ec0a6.js +172 -0
  58. package/dist/index-5ff5dbd0.js +1675 -0
  59. package/dist/index-71898eb9.js +139 -0
  60. package/dist/main.js +1 -1
  61. package/dist/types/components/layout/toolbar/SearchCloseButton.d.ts +7 -0
  62. package/dist/types/components/layout/toolbar/SearchResultNavigator.d.ts +1 -0
  63. package/dist/types/components/layout/toolbar/ViewModeTool.d.ts +1 -1
  64. package/dist/types/components/ui/PasswordModal.d.ts +3 -0
  65. package/dist/types/contexts/DocumentPasswordContext.d.ts +14 -0
  66. package/dist/types/contexts/SmoothScrollContext.d.ts +1 -3
  67. package/dist/types/utils/constants.d.ts +1 -0
  68. package/dist/types/utils/getScrollDistance.d.ts +1 -0
  69. package/dist/types/utils/getWordPositionInPage.d.ts +11 -0
  70. package/dist/types/utils/getZoomLevel.d.ts +2 -2
  71. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -0
  72. package/dist/types/utils/types.d.ts +20 -3
  73. package/dist/utils/constants.js +3 -2
  74. package/dist/utils/getScrollDistance.js +4 -0
  75. package/dist/utils/getWordPositionInPage.js +19 -0
  76. package/dist/utils/getZoomLevel.js +13 -9
  77. package/dist/utils/highlight.js +141 -126
  78. package/dist/utils/hooks/useFileDownload.js +3 -2
  79. package/dist/utils/hooks/useLicense.js +1 -1
  80. package/dist/utils/hooks/useLoadPdf.js +52 -40
  81. package/dist/utils/hooks/usePaginate.js +4 -2
  82. package/dist/utils/hooks/usePinch.js +68 -17
  83. package/dist/utils/hooks/usePresentPage.js +3 -2
  84. package/dist/utils/hooks/usePrint.js +3 -2
  85. package/dist/utils/hooks/useScrollToPage.js +4 -2
  86. package/dist/utils/hooks/useSearch.js +5 -3
  87. package/dist/utils/hooks/useThumbnail.js +3 -2
  88. package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
  89. package/dist/utils/types.js +4 -4
  90. package/package.json +1 -1
  91. package/dist/RPDefaultLayout-ed089918.js +0 -2958
  92. package/dist/index-1cb41342.js +0 -307
  93. package/dist/index-7279fb4e.js +0 -1557
  94. package/dist/index-aa2d3884.js +0 -140
@@ -1,205 +1,220 @@
1
- import { getCharacterType as D } from "./charators.js";
2
- function H(d, c, l, s) {
1
+ import { getCharacterType as X } from "./charators.js";
2
+ function V(r, c, a, i) {
3
3
  const o = [];
4
- for (const n of d) {
5
- const i = X(c, n, s);
6
- o.push(..._(i, c, l));
4
+ for (const n of r) {
5
+ const s = y(c, n, i);
6
+ o.push(...I(s, c, a));
7
7
  }
8
8
  return o;
9
9
  }
10
- const L = (d, c) => {
11
- const l = ["g"];
12
- c.matchCase || l.push("i");
13
- let o = d.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
- return new RegExp(o, l.join(""));
10
+ const D = (r, c) => {
11
+ const a = ["g"];
12
+ c.matchCase || a.push("i");
13
+ let o = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
+ return new RegExp(o, a.join(""));
15
15
  };
16
- function X(d, c, l) {
17
- const s = [];
18
- for (const t of d.items)
16
+ function y(r, c, a) {
17
+ const i = [];
18
+ for (const t of r.items)
19
19
  if (t.hasEOL)
20
20
  if (t.str.endsWith("-")) {
21
- const a = t.str.lastIndexOf("-");
22
- s.push(t.str.substring(0, a));
21
+ const l = t.str.lastIndexOf("-");
22
+ i.push(t.str.substring(0, l));
23
23
  } else
24
- s.push(t.str, `
24
+ i.push(t.str, `
25
25
  `);
26
26
  else
27
- s.push(t.str);
28
- const o = s.join("").replace(/\n/g, " ");
27
+ i.push(t.str);
28
+ const o = i.join("").replace(/\n/g, " ");
29
29
  let n;
30
- c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = L(c, l);
31
- const i = [];
30
+ c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = D(c, a);
31
+ const s = [];
32
32
  let e;
33
33
  for (; (e = n.exec(o)) !== null; )
34
- l.wholeWords && !w(o, e.index, e[0].length) || i.push([e.index, e[0].length, e[0]]);
35
- return i;
34
+ a.wholeWords && !L(o, e.index, e[0].length) || s.push([e.index, e[0].length, e[0]]);
35
+ return s;
36
36
  }
37
- function _(d, c, l) {
38
- function s(a) {
39
- return a.hasEOL ? a.str.endsWith("-") ? -1 : 1 : 0;
37
+ function I(r, c, a) {
38
+ function i(l) {
39
+ return l.hasEOL ? l.str.endsWith("-") ? -1 : 1 : 0;
40
40
  }
41
41
  let o = 0, n = 0;
42
- const i = c.items, e = i.length - 1, t = [];
43
- for (let a = 0; a < d.length; a++) {
44
- let r = d[a][0];
45
- for (; o !== e && r >= n + i[o].str.length; ) {
46
- const f = i[o];
47
- n += f.str.length + s(f), o++;
42
+ const s = c.items, e = s.length - 1, t = [];
43
+ for (let l = 0; l < r.length; l++) {
44
+ let d = r[l][0];
45
+ for (; o !== e && d >= n + s[o].str.length; ) {
46
+ const f = s[o];
47
+ n += f.str.length + i(f), o++;
48
48
  }
49
49
  const p = {
50
50
  idx: o,
51
- offset: r - n
51
+ offset: d - n
52
52
  };
53
- for (r += d[a][1]; o !== e && r > n + i[o].str.length; ) {
54
- const f = i[o];
55
- n += f.str.length + s(f), o++;
53
+ for (d += r[l][1]; o !== e && d > n + s[o].str.length; ) {
54
+ const f = s[o];
55
+ n += f.str.length + i(f), o++;
56
56
  }
57
57
  const m = {
58
58
  idx: o,
59
- offset: r - n
59
+ offset: d - n
60
60
  };
61
61
  t.push({
62
62
  start: p,
63
63
  end: m,
64
- str: d[a][2],
65
- oIndex: d[a][0],
66
- pageIndex: l
64
+ str: r[l][2],
65
+ oIndex: r[l][0],
66
+ pageIndex: a,
67
+ rect: {
68
+ left: 0,
69
+ top: 0,
70
+ width: 0,
71
+ height: 0
72
+ }
67
73
  });
68
74
  }
75
+ for (const l of t) {
76
+ const d = s[l.start.idx], p = s[l.end.idx], m = d.transform[4], f = d.transform[5], E = m + d.width * l.start.offset / d.str.length, h = f, b = m + p.width * l.end.offset / p.str.length, N = f, u = {
77
+ left: Math.min(E, b),
78
+ top: Math.min(h, N),
79
+ width: Math.abs(b - E),
80
+ height: Math.max(d.height, p.height)
81
+ };
82
+ l.rect = u;
83
+ }
69
84
  return t;
70
85
  }
71
- function w(d, c, l) {
72
- let s = d.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
73
- if (s) {
74
- const o = d.charCodeAt(c), n = s[1].charCodeAt(0);
75
- if (D(o) === D(n))
86
+ function L(r, c, a) {
87
+ let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
88
+ if (i) {
89
+ const o = r.charCodeAt(c), n = i[1].charCodeAt(0);
90
+ if (X(o) === X(n))
76
91
  return !1;
77
92
  }
78
- if (s = d.slice(c + l).match(/^\p{M}*([^\p{M}])/u), s) {
79
- const o = d.charCodeAt(c + l - 1), n = s[1].charCodeAt(0);
80
- if (D(o) === D(n))
93
+ if (i = r.slice(c + a).match(/^\p{M}*([^\p{M}])/u), i) {
94
+ const o = r.charCodeAt(c + a - 1), n = i[1].charCodeAt(0);
95
+ if (X(o) === X(n))
81
96
  return !1;
82
97
  }
83
98
  return !0;
84
99
  }
85
- function I(d, c, l) {
86
- const s = [];
87
- function o(n, i, e = -1, t = -1, a = "") {
88
- const r = c.items[n], p = [];
89
- let m = "", f = "", b = "", u = l[n];
90
- if (!u)
100
+ function H(r, c, a) {
101
+ const i = [];
102
+ function o(n, s, e = -1, t = -1, l = "") {
103
+ const d = c.items[n], p = [];
104
+ let m = "", f = "", E = "", h = a[n];
105
+ if (!h)
91
106
  return;
92
- if (u.nodeType === Node.TEXT_NODE) {
93
- const g = document.createElement("span");
94
- u.before(g), g.append(u), l[n] = g, u = g;
107
+ if (h.nodeType === Node.TEXT_NODE) {
108
+ const u = document.createElement("span");
109
+ h.before(u), u.append(h), a[n] = u, h = u;
95
110
  }
96
- e >= 0 && t >= 0 ? m = r.str.substring(e, t) : e < 0 && t < 0 ? m = r.str : e >= 0 ? m = r.str.substring(e) : t >= 0 && (m = r.str.substring(0, t));
97
- const y = document.createTextNode(m), N = document.createElement("span");
98
- if (N.className = "highlight appended " + a, N.setAttribute("data-match-index", `${i}`), N.append(y), p.push(N), s.push({ element: N, index: i }), e > 0)
99
- if (u.childNodes.length === 1 && u.childNodes[0].nodeType === Node.TEXT_NODE) {
100
- f = r.str.substring(0, e);
101
- const g = document.createTextNode(f);
102
- p.unshift(g);
111
+ e >= 0 && t >= 0 ? m = d.str.substring(e, t) : e < 0 && t < 0 ? m = d.str : e >= 0 ? m = d.str.substring(e) : t >= 0 && (m = d.str.substring(0, t));
112
+ const b = document.createTextNode(m), N = document.createElement("span");
113
+ if (N.className = "highlight appended " + l, N.setAttribute("data-match-index", `${s}`), N.append(b), p.push(N), i.push({ element: N, index: s }), e > 0)
114
+ if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
115
+ f = d.str.substring(0, e);
116
+ const u = document.createTextNode(f);
117
+ p.unshift(u);
103
118
  } else {
104
- let g = 0;
105
- const E = [];
106
- for (const h of u.childNodes) {
107
- const x = h.nodeType === Node.TEXT_NODE ? h.nodeValue : h.firstChild.nodeValue;
108
- g += x.length, g <= e ? E.push(h) : e >= g - x.length && t <= g && E.push(
119
+ let u = 0;
120
+ const C = [];
121
+ for (const g of h.childNodes) {
122
+ const x = g.nodeType === Node.TEXT_NODE ? g.nodeValue : g.firstChild.nodeValue;
123
+ u += x.length, u <= e ? C.push(g) : e >= u - x.length && t <= u && C.push(
109
124
  document.createTextNode(
110
- x.substring(0, e - (g - x.length))
125
+ x.substring(0, e - (u - x.length))
111
126
  )
112
127
  );
113
128
  }
114
- p.unshift(...E);
129
+ p.unshift(...C);
115
130
  }
116
131
  if (t > 0) {
117
- b = r.str.substring(t);
118
- const g = document.createTextNode(b);
119
- p.push(g);
132
+ E = d.str.substring(t);
133
+ const u = document.createTextNode(E);
134
+ p.push(u);
120
135
  }
121
- u.replaceChildren(...p);
136
+ h.replaceChildren(...p);
122
137
  }
123
- for (const [n, i] of d.entries())
124
- if (i.start.idx === i.end.idx)
125
- o(i.start.idx, n, i.start.offset, i.end.offset);
138
+ for (const [n, s] of r.entries())
139
+ if (s.start.idx === s.end.idx)
140
+ o(s.start.idx, n, s.start.offset, s.end.offset);
126
141
  else
127
- for (let e = i.start.idx, t = i.end.idx; e <= t; e++)
128
- e === i.start.idx ? o(e, n, i.start.offset, -1, "begin") : e === i.end.idx ? o(e, n, -1, i.end.offset, "end") : o(e, n, -1, -1, "middle");
129
- return s;
142
+ for (let e = s.start.idx, t = s.end.idx; e <= t; e++)
143
+ e === s.start.idx ? o(e, n, s.start.offset, -1, "begin") : e === s.end.idx ? o(e, n, -1, s.end.offset, "end") : o(e, n, -1, -1, "middle");
144
+ return i;
130
145
  }
131
- function R(d, c) {
132
- const l = d.items.map((s) => s.str);
133
- for (let s = 0; s < c.length; s++) {
134
- const o = c[s];
146
+ function R(r, c) {
147
+ const a = r.items.map((i) => i.str);
148
+ for (let i = 0; i < c.length; i++) {
149
+ const o = c[i];
135
150
  if (o && o.nodeType !== Node.TEXT_NODE) {
136
- const n = document.createTextNode(l[s]);
151
+ const n = document.createTextNode(a[i]);
137
152
  o.replaceChildren(n);
138
153
  }
139
154
  }
140
155
  }
141
- function W(d = {}) {
142
- return { matchCase: !1, wholeWords: !1, ...d };
156
+ function W(r = {}) {
157
+ return { matchCase: !1, wholeWords: !1, ...r };
143
158
  }
144
- function A(d, c, l) {
145
- const s = [];
146
- function o(n, i, e = -1, t = -1, a) {
147
- var g, E;
148
- const r = c.items[n], p = [];
149
- let m = "", f = "", b = "", u = l[n];
150
- if (!u)
159
+ function A(r, c, a) {
160
+ const i = [];
161
+ function o(n, s, e = -1, t = -1, l) {
162
+ var u, C;
163
+ const d = c.items[n], p = [];
164
+ let m = "", f = "", E = "", h = a[n];
165
+ if (!h)
151
166
  return;
152
- e >= 0 && t >= 0 ? m = r.str.substring(e, t) : e < 0 && t < 0 ? m = r.str : e >= 0 ? m = r.str.substring(e) : t >= 0 && (m = r.str.substring(0, t));
153
- const y = document.createTextNode(m), N = document.createElement("span");
154
- if (N.style.background = a, N.append(y), p.push(N), e > 0)
155
- if (u.childNodes.length === 1 && u.childNodes[0].nodeType === Node.TEXT_NODE) {
156
- f = r.str.substring(0, e);
157
- const h = document.createTextNode(f);
158
- p.unshift(h);
167
+ e >= 0 && t >= 0 ? m = d.str.substring(e, t) : e < 0 && t < 0 ? m = d.str : e >= 0 ? m = d.str.substring(e) : t >= 0 && (m = d.str.substring(0, t));
168
+ const b = document.createTextNode(m), N = document.createElement("span");
169
+ if (N.style.background = l, N.append(b), p.push(N), e > 0)
170
+ if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
171
+ f = d.str.substring(0, e);
172
+ const g = document.createTextNode(f);
173
+ p.unshift(g);
159
174
  } else {
160
- let h = 0;
175
+ let g = 0;
161
176
  const x = [];
162
- for (const T of u.childNodes) {
163
- const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((g = T.firstChild) == null ? void 0 : g.nodeValue) || "", C = v.length;
164
- if (h += C, h <= e)
177
+ for (const T of h.childNodes) {
178
+ const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((u = T.firstChild) == null ? void 0 : u.nodeValue) || "", M = v.length;
179
+ if (g += M, g <= e)
165
180
  x.push(T);
166
- else if (e >= h - C && t <= h) {
167
- const M = v.substring(0, e - (h - C));
168
- x.push(document.createTextNode(M));
181
+ else if (e >= g - M && t <= g) {
182
+ const w = v.substring(0, e - (g - M));
183
+ x.push(document.createTextNode(w));
169
184
  }
170
185
  }
171
186
  p.unshift(...x);
172
187
  }
173
188
  if (t > 0)
174
- if (u.childNodes.length === 1 && u.childNodes[0].nodeType === Node.TEXT_NODE) {
175
- b = r.str.substring(t);
176
- const h = document.createTextNode(b);
177
- p.push(h);
189
+ if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
190
+ E = d.str.substring(t);
191
+ const g = document.createTextNode(E);
192
+ p.push(g);
178
193
  } else {
179
- let h = 0;
194
+ let g = 0;
180
195
  const x = [];
181
- for (const T of u.childNodes) {
182
- h >= t && x.push(T);
183
- const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((E = T.firstChild) == null ? void 0 : E.nodeValue) || "", C = v.length;
184
- if (h += C, h > t) {
185
- const M = v.substring(t - (h - C));
186
- M && x.push(document.createTextNode(M));
196
+ for (const T of h.childNodes) {
197
+ g >= t && x.push(T);
198
+ const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((C = T.firstChild) == null ? void 0 : C.nodeValue) || "", M = v.length;
199
+ if (g += M, g > t) {
200
+ const w = v.substring(t - (g - M));
201
+ w && x.push(document.createTextNode(w));
187
202
  }
188
203
  }
189
204
  x.length > 0 && p.push(...x);
190
205
  }
191
- u.replaceChildren(...p), s.push({ element: N, index: i });
206
+ h.replaceChildren(...p), i.push({ element: N, index: s });
192
207
  }
193
- for (const [n, i] of d.entries()) {
194
- const { start: e, end: t, color: a } = i;
195
- e.idx === t.idx && o(e.idx, n, e.offset, t.offset, a);
208
+ for (const [n, s] of r.entries()) {
209
+ const { start: e, end: t, color: l } = s;
210
+ e.idx === t.idx && o(e.idx, n, e.offset, t.offset, l);
196
211
  }
197
- return s;
212
+ return i;
198
213
  }
199
214
  export {
200
- H as findMatches,
215
+ V as findMatches,
201
216
  W as getHighlightOptionsWithDefaults,
202
- I as highlightMatches,
217
+ H as highlightMatches,
203
218
  A as highlightMultipleColorMatches,
204
219
  R as resetDivs
205
220
  };
@@ -1,7 +1,8 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../contexts/RPDocumentContext.js";
4
- import { c as C } from "../../RPDefaultLayout-ed089918.js";
4
+ import "../../contexts/DocumentPasswordContext.js";
5
+ import { c as E } from "../../RPDefaultLayout-4518b3d3.js";
5
6
  import "../../contexts/DarkModeContext.js";
6
7
  import "../../contexts/RotationContext.js";
7
8
  import "../../contexts/LayerContext.js";
@@ -28,5 +29,5 @@ import "../../contexts/ThemeContext.js";
28
29
  import "../../components/RPDropFileZone.js";
29
30
  import "../../contexts/ToolbarComponentContext.js";
30
31
  export {
31
- C as useFileDownload
32
+ E as useFileDownload
32
33
  };
@@ -1,6 +1,6 @@
1
1
  import { useState as g, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as c } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-05-15T07:06:21.066Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-05-21T03:38:50.505Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${l}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
6
6
  expired: `Your license key has expired. ${l}`,
@@ -1,58 +1,70 @@
1
- import { useState as u, useRef as x, useEffect as L } from "react";
2
- import * as p from "pdfjs-dist";
3
- import { getThumbnailViewport as E } from "../getThumbnailViewport.js";
4
- import { useConfigContext as I } from "../../contexts/ConfigContext.js";
5
- const V = (d, e, y = {}) => {
6
- const [r, C] = u(), { workerUrlAdded: w } = I(), [T, b] = u(/* @__PURE__ */ new Map()), i = x(), [j, f] = u(0), [g, k] = u(!1), { onLoadError: m, onLoaded: a } = y;
7
- return L(() => {
8
- if (!w || !d)
1
+ import { useState as f, useRef as D, useEffect as C } from "react";
2
+ import * as k from "pdfjs-dist";
3
+ import { getThumbnailViewport as N } from "../getThumbnailViewport.js";
4
+ import { useConfigContext as S } from "../../contexts/ConfigContext.js";
5
+ import { useDocumentPasswordContext as U } from "../../contexts/DocumentPasswordContext.js";
6
+ const z = (m, o, I = {}) => {
7
+ const [r, q] = f(), { workerUrlAdded: x } = S(), [v, L] = f(/* @__PURE__ */ new Map()), i = D(), [R, g] = f(0), [P, y] = f(!1), {
8
+ password: d,
9
+ passwordError: T,
10
+ setPasswordError: u,
11
+ passwordRequired: c,
12
+ setPasswordRequired: a
13
+ } = U(), { onLoadError: p, onLoaded: w } = I;
14
+ return C(() => {
15
+ if (!x || !m)
9
16
  return;
10
- i.current = Date.now();
11
- const t = i.current, P = {
12
- url: d,
13
- cMapPacked: (e == null ? void 0 : e.isCompressed) ?? !0,
14
- ...(e == null ? void 0 : e.url) && { cMapUrl: e.url }
17
+ g(0), a(!1), u(""), i.current = Date.now();
18
+ const t = i.current, E = {
19
+ url: m,
20
+ cMapPacked: (o == null ? void 0 : o.isCompressed) ?? !0,
21
+ ...(o == null ? void 0 : o.url) && { cMapUrl: o.url },
22
+ ...d && { password: d }
15
23
  };
16
- console.log("currently pdfjs version", p.version, p);
17
- const n = p.getDocument(P);
18
- n.onProgress = (o) => {
24
+ console.log("currently pdfjs version", k.version, k);
25
+ const n = k.getDocument(E);
26
+ n.onProgress = (s) => {
19
27
  if (t === i.current) {
20
- const { loaded: c, total: l } = o, v = l ? Math.min(100, Math.round(c / l * 100)) : 0;
21
- f(v);
28
+ const { loaded: b, total: l } = s, j = l ? Math.min(100, Math.round(b / l * 100)) : 0;
29
+ g(j);
22
30
  }
23
- }, k(!0), f(0);
24
- const s = n.promise.then((o) => (t === i.current && (C(o), f(100)), a && a(o), o)).catch((o) => {
25
- m && m(o);
26
- }).finally(() => k(!1));
31
+ }, y(!0);
32
+ const e = n.promise.then((s) => (t === i.current && (q(s), g(100)), w && w(s), a(!1), u(""), s)).catch((s) => {
33
+ s instanceof Error && s.name === "PasswordException" ? (a(!0), u(s.message || "Password required")) : s instanceof Error && s.name === "InvalidPDFException" && d ? (a(!0), u("Incorrect password")) : p && p(s);
34
+ }).finally(() => y(!1));
27
35
  return () => {
28
- s.finally(() => {
36
+ e.finally(() => {
29
37
  n.destroy();
30
38
  });
31
39
  };
32
- }, [d, w, m, a]), L(() => {
40
+ }, [m, x, d, p, w]), C(() => {
41
+ if (c)
42
+ return;
33
43
  const t = /* @__PURE__ */ new Map();
34
- if (!r || g) {
35
- b(t);
44
+ if (!r || P) {
45
+ L(t);
36
46
  return;
37
47
  }
38
- const P = r.numPages, n = [];
39
- for (let s = 1; s <= P; s++) {
40
- const o = r.getPage(s);
41
- n.push(o);
48
+ const E = r.numPages, n = [];
49
+ for (let e = 1; e <= E; e++) {
50
+ const s = r.getPage(e);
51
+ n.push(s);
42
52
  }
43
- Promise.all(n).then((s) => {
44
- s.map((o) => {
45
- const { thumbnailViewport: c, scale: l } = E(o);
46
- t.set(o.pageNumber, { page: o, thumbnailViewport: c, thumbnailScale: l });
47
- }), b(t);
53
+ Promise.all(n).then((e) => {
54
+ e.map((s) => {
55
+ const { thumbnailViewport: b, scale: l } = N(s);
56
+ t.set(s.pageNumber, { page: s, thumbnailViewport: b, thumbnailScale: l });
57
+ }), L(t);
48
58
  });
49
- }, [r, g]), {
59
+ }, [r, P, c]), {
50
60
  pdf: r,
51
- pages: T,
52
- loading: g,
53
- loadingProgress: j
61
+ pages: v,
62
+ loading: P,
63
+ loadingProgress: R,
64
+ passwordRequired: c,
65
+ passwordError: T
54
66
  };
55
67
  };
56
68
  export {
57
- V as useLoadPdf
69
+ z as useLoadPdf
58
70
  };
@@ -1,7 +1,9 @@
1
1
  import "react";
2
- import { g as E } from "../../RPDefaultLayout-ed089918.js";
2
+ import "../types.js";
3
+ import { g as G } from "../../RPDefaultLayout-4518b3d3.js";
3
4
  import "react/jsx-runtime";
4
5
  import "../../contexts/RPDocumentContext.js";
6
+ import "../../contexts/DocumentPasswordContext.js";
5
7
  import "../../contexts/DarkModeContext.js";
6
8
  import "../../contexts/RotationContext.js";
7
9
  import "../../contexts/LayerContext.js";
@@ -29,5 +31,5 @@ import "../../components/RPDropFileZone.js";
29
31
  import "../../contexts/ToolbarComponentContext.js";
30
32
  import "./useDebounce.js";
31
33
  export {
32
- E as usePaginate
34
+ G as usePaginate
33
35
  };
@@ -1,28 +1,79 @@
1
- import { useState as d, useCallback as m, useEffect as f } from "react";
2
- import { useDebounce as h } from "./useDebounce.js";
3
- import { useZoomContext as i } from "../../contexts/ZoomContext.js";
4
- const b = (o) => {
5
- const { currentZoom: l, setZoomLevel: a } = i(), [n, s] = d(l || 100), r = h(n, 100), u = m((e) => {
6
- s(e ? (t) => t + 3 : (t) => t - 3);
7
- }, []), c = m(
1
+ import { useState as w, useRef as T, useCallback as r, useEffect as u } from "react";
2
+ import { useDebounce as g } from "./useDebounce.js";
3
+ import { useZoomContext as A } from "../../contexts/ZoomContext.js";
4
+ const I = (n) => {
5
+ const { currentZoom: m, setZoomLevel: b } = A(), [E, d] = w(m || 100), L = g(E, 100), [o, y] = w(!1), c = T(null), i = r((e) => {
6
+ d(e ? (t) => t + 3 : (t) => t - 3);
7
+ }, []), a = r(
8
8
  (e) => {
9
9
  if (!e.ctrlKey)
10
10
  return;
11
11
  e.preventDefault();
12
12
  const t = e.deltaY < 0;
13
- u(t);
13
+ i(t);
14
14
  },
15
- [u]
15
+ [i]
16
16
  );
17
- f(() => {
18
- if (r) {
19
- const e = Math.round(l * 100 + n);
20
- s(0), a(e > 25 ? e : 25);
17
+ u(() => {
18
+ if (L) {
19
+ const e = Math.round(m * 100 + E);
20
+ d(0), b(e > 25 ? e : 25);
21
21
  }
22
- }, [r]), f(() => (o && o.addEventListener("wheel", c), () => {
23
- o && o.removeEventListener("wheel", c);
24
- }), [o, c]);
22
+ }, [L]);
23
+ const p = (e, t) => {
24
+ const s = e.clientX - t.clientX, l = e.clientY - t.clientY;
25
+ return Math.sqrt(s * s + l * l);
26
+ }, h = r(
27
+ (e) => {
28
+ if (!o || e.touches.length !== 2)
29
+ return;
30
+ const t = p(e.touches[0], e.touches[1]);
31
+ c.current = t, e.preventDefault();
32
+ },
33
+ [o]
34
+ ), v = r(() => {
35
+ c.current = null;
36
+ }, []), f = r(
37
+ (e) => {
38
+ if (!o || e.touches.length !== 2 || c.current === null)
39
+ return;
40
+ const t = p(e.touches[0], e.touches[1]), s = t - c.current, l = Math.abs(s) > 5, S = s > 0;
41
+ l && (i(S), c.current = t, e.preventDefault());
42
+ },
43
+ [i, o]
44
+ ), D = () => {
45
+ document.activeElement instanceof HTMLElement && document.activeElement.blur();
46
+ };
47
+ u(() => {
48
+ if (o) {
49
+ document.body.style.touchAction = "pan-x pan-y";
50
+ return;
51
+ }
52
+ document.body.style.touchAction = "";
53
+ }, [o]), u(() => {
54
+ const e = () => {
55
+ const t = document.activeElement, s = !!(t != null && t.closest('[data-rp="container"]'));
56
+ y(s);
57
+ };
58
+ return window.addEventListener("focusin", e), window.addEventListener("focusout", e), e(), () => {
59
+ window.removeEventListener("focusin", e), window.removeEventListener("focusout", e);
60
+ };
61
+ }, []), u(() => {
62
+ if (!n)
63
+ return;
64
+ const e = (t) => {
65
+ n.contains(t.target) || D();
66
+ };
67
+ return document.addEventListener("scroll", e), () => {
68
+ document.removeEventListener("scroll", e);
69
+ };
70
+ }, [n]), u(() => {
71
+ if (n)
72
+ return n.addEventListener("wheel", a, { passive: !1 }), n.addEventListener("touchstart", h, { passive: !1 }), n.addEventListener("touchmove", f, { passive: !1 }), n.addEventListener("touchend", v, { passive: !1 }), () => {
73
+ n.removeEventListener("wheel", a), n.removeEventListener("touchstart", h), n.removeEventListener("touchmove", f), n.removeEventListener("touchend", v);
74
+ };
75
+ }, [n, a, h, f, v]);
25
76
  };
26
77
  export {
27
- b as usePinch
78
+ I as usePinch
28
79
  };
@@ -4,7 +4,8 @@ import "../../contexts/DimensionPagesContext.js";
4
4
  import "../calculatePage.js";
5
5
  import "react/jsx-runtime";
6
6
  import "../../contexts/RPDocumentContext.js";
7
- import { v as F } from "../../RPDefaultLayout-ed089918.js";
7
+ import "../../contexts/DocumentPasswordContext.js";
8
+ import { v as G } from "../../RPDefaultLayout-4518b3d3.js";
8
9
  import "../../contexts/DarkModeContext.js";
9
10
  import "../../contexts/RotationContext.js";
10
11
  import "../../contexts/LayerContext.js";
@@ -30,5 +31,5 @@ import "../../components/RPDropFileZone.js";
30
31
  import "../../contexts/ToolbarComponentContext.js";
31
32
  import "./useDebounce.js";
32
33
  export {
33
- F as usePresentPage
34
+ G as usePresentPage
34
35
  };
@@ -1,7 +1,8 @@
1
1
  import "react";
2
2
  import "react/jsx-runtime";
3
3
  import "../../contexts/RPDocumentContext.js";
4
- import { i as E } from "../../RPDefaultLayout-ed089918.js";
4
+ import "../../contexts/DocumentPasswordContext.js";
5
+ import { i as F } from "../../RPDefaultLayout-4518b3d3.js";
5
6
  import "../../contexts/DarkModeContext.js";
6
7
  import "../../contexts/RotationContext.js";
7
8
  import "../../contexts/LayerContext.js";
@@ -29,5 +30,5 @@ import "../../components/RPDropFileZone.js";
29
30
  import "../../contexts/ToolbarComponentContext.js";
30
31
  import "pdfjs-dist";
31
32
  export {
32
- E as usePrint
33
+ F as usePrint
33
34
  };