@pdf-viewer/react 1.6.0-beta.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.
- package/dist/RPDefaultLayout-4518b3d3.js +3059 -0
- package/dist/{SearchCloseButton-d6135e7c.js → SearchCloseButton-959cc1ed.js} +11 -11
- package/dist/assets/Container.css +1 -1
- package/dist/assets/PasswordModal.css +1 -0
- package/dist/assets/RPDefaultLayout.css +1 -1
- package/dist/assets/SearchCloseButton.css +1 -1
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPPages.js +4 -2
- package/dist/components/RPProvider.js +13 -12
- package/dist/components/layout/Container.js +7 -6
- package/dist/components/layout/LayoutContainer.js +3 -2
- package/dist/components/layout/RPDefaultLayout.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DocumentDialog.js +3 -2
- package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +3 -2
- package/dist/components/layout/toolbar/OtherTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/PrintTool.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
- package/dist/components/layout/toolbar/SearchCloseButton.js +1 -1
- package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
- package/dist/components/layout/toolbar/SearchTool.js +4 -3
- package/dist/components/layout/toolbar/ViewModeTool.js +18 -19
- package/dist/components/layout/toolbar/ZoomTool.js +7 -26
- package/dist/components/page/AnnotationLayer.js +3 -2
- package/dist/components/page/CanvasLayer.js +3 -2
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/RPPage.js +3 -2
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextHighlightLayer.js +3 -2
- package/dist/components/page/TextLayer.js +3 -2
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +58 -0
- package/dist/contexts/DocumentPasswordContext.js +40 -0
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/PrintContext.js +1 -1
- package/dist/contexts/RPDocumentContext.js +11 -8
- package/dist/contexts/SearchContext.js +1 -1
- package/dist/contexts/SmoothScrollContext.js +8 -9
- package/dist/contexts/ThumbnailsContext.js +1 -1
- package/dist/contexts/ToolbarComponentContext.js +2 -2
- package/dist/contexts/ViewModeContext.js +16 -17
- package/dist/contexts/ZoomContext.js +17 -16
- package/dist/main.js +1 -1
- package/dist/types/components/layout/toolbar/ViewModeTool.d.ts +1 -1
- package/dist/types/components/ui/PasswordModal.d.ts +3 -0
- package/dist/types/contexts/DocumentPasswordContext.d.ts +14 -0
- package/dist/types/contexts/SmoothScrollContext.d.ts +1 -3
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/getScrollDistance.d.ts +1 -0
- package/dist/types/utils/getWordPositionInPage.d.ts +11 -0
- package/dist/types/utils/getZoomLevel.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -0
- package/dist/types/utils/types.d.ts +20 -3
- package/dist/utils/constants.js +3 -2
- package/dist/utils/getScrollDistance.js +4 -0
- package/dist/utils/getWordPositionInPage.js +19 -0
- package/dist/utils/getZoomLevel.js +13 -9
- package/dist/utils/highlight.js +141 -126
- package/dist/utils/hooks/useFileDownload.js +3 -2
- package/dist/utils/hooks/useLicense.js +18 -18
- package/dist/utils/hooks/useLoadPdf.js +52 -40
- package/dist/utils/hooks/usePaginate.js +4 -2
- package/dist/utils/hooks/usePinch.js +68 -17
- package/dist/utils/hooks/usePresentPage.js +3 -2
- package/dist/utils/hooks/usePrint.js +3 -2
- package/dist/utils/hooks/useScrollToPage.js +4 -2
- package/dist/utils/hooks/useSearch.js +5 -3
- package/dist/utils/hooks/useThumbnail.js +3 -2
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
- package/dist/utils/types.js +4 -4
- package/package.json +1 -1
- package/dist/RPDefaultLayout-3a892bb5.js +0 -3041
package/dist/utils/highlight.js
CHANGED
|
@@ -1,205 +1,220 @@
|
|
|
1
|
-
import { getCharacterType as
|
|
2
|
-
function
|
|
1
|
+
import { getCharacterType as X } from "./charators.js";
|
|
2
|
+
function V(r, c, a, i) {
|
|
3
3
|
const o = [];
|
|
4
|
-
for (const n of
|
|
5
|
-
const
|
|
6
|
-
o.push(...
|
|
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
|
|
11
|
-
const
|
|
12
|
-
c.matchCase ||
|
|
13
|
-
let o =
|
|
14
|
-
return new RegExp(o,
|
|
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
|
|
17
|
-
const
|
|
18
|
-
for (const t of
|
|
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
|
|
22
|
-
|
|
21
|
+
const l = t.str.lastIndexOf("-");
|
|
22
|
+
i.push(t.str.substring(0, l));
|
|
23
23
|
} else
|
|
24
|
-
|
|
24
|
+
i.push(t.str, `
|
|
25
25
|
`);
|
|
26
26
|
else
|
|
27
|
-
|
|
28
|
-
const o =
|
|
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 =
|
|
31
|
-
const
|
|
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
|
-
|
|
35
|
-
return
|
|
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
|
|
38
|
-
function
|
|
39
|
-
return
|
|
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
|
|
43
|
-
for (let
|
|
44
|
-
let
|
|
45
|
-
for (; o !== e &&
|
|
46
|
-
const f =
|
|
47
|
-
n += f.str.length +
|
|
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:
|
|
51
|
+
offset: d - n
|
|
52
52
|
};
|
|
53
|
-
for (
|
|
54
|
-
const f =
|
|
55
|
-
n += f.str.length +
|
|
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:
|
|
59
|
+
offset: d - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
62
|
start: p,
|
|
63
63
|
end: m,
|
|
64
|
-
str:
|
|
65
|
-
oIndex:
|
|
66
|
-
pageIndex:
|
|
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
|
|
72
|
-
let
|
|
73
|
-
if (
|
|
74
|
-
const o =
|
|
75
|
-
if (
|
|
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 (
|
|
79
|
-
const o =
|
|
80
|
-
if (
|
|
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
|
|
86
|
-
const
|
|
87
|
-
function o(n,
|
|
88
|
-
const
|
|
89
|
-
let m = "", f = "",
|
|
90
|
-
if (!
|
|
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 (
|
|
93
|
-
const
|
|
94
|
-
|
|
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 =
|
|
97
|
-
const
|
|
98
|
-
if (N.className = "highlight appended " +
|
|
99
|
-
if (
|
|
100
|
-
f =
|
|
101
|
-
const
|
|
102
|
-
p.unshift(
|
|
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
|
|
105
|
-
const
|
|
106
|
-
for (const
|
|
107
|
-
const x =
|
|
108
|
-
|
|
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 - (
|
|
125
|
+
x.substring(0, e - (u - x.length))
|
|
111
126
|
)
|
|
112
127
|
);
|
|
113
128
|
}
|
|
114
|
-
p.unshift(...
|
|
129
|
+
p.unshift(...C);
|
|
115
130
|
}
|
|
116
131
|
if (t > 0) {
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
p.push(
|
|
132
|
+
E = d.str.substring(t);
|
|
133
|
+
const u = document.createTextNode(E);
|
|
134
|
+
p.push(u);
|
|
120
135
|
}
|
|
121
|
-
|
|
136
|
+
h.replaceChildren(...p);
|
|
122
137
|
}
|
|
123
|
-
for (const [n,
|
|
124
|
-
if (
|
|
125
|
-
o(
|
|
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 =
|
|
128
|
-
e ===
|
|
129
|
-
return
|
|
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(
|
|
132
|
-
const
|
|
133
|
-
for (let
|
|
134
|
-
const o = c[
|
|
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(
|
|
151
|
+
const n = document.createTextNode(a[i]);
|
|
137
152
|
o.replaceChildren(n);
|
|
138
153
|
}
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
|
-
function W(
|
|
142
|
-
return { matchCase: !1, wholeWords: !1, ...
|
|
156
|
+
function W(r = {}) {
|
|
157
|
+
return { matchCase: !1, wholeWords: !1, ...r };
|
|
143
158
|
}
|
|
144
|
-
function A(
|
|
145
|
-
const
|
|
146
|
-
function o(n,
|
|
147
|
-
var
|
|
148
|
-
const
|
|
149
|
-
let m = "", f = "",
|
|
150
|
-
if (!
|
|
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 =
|
|
153
|
-
const
|
|
154
|
-
if (N.style.background =
|
|
155
|
-
if (
|
|
156
|
-
f =
|
|
157
|
-
const
|
|
158
|
-
p.unshift(
|
|
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
|
|
175
|
+
let g = 0;
|
|
161
176
|
const x = [];
|
|
162
|
-
for (const T of
|
|
163
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
164
|
-
if (
|
|
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 >=
|
|
167
|
-
const
|
|
168
|
-
x.push(document.createTextNode(
|
|
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 (
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
p.push(
|
|
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
|
|
194
|
+
let g = 0;
|
|
180
195
|
const x = [];
|
|
181
|
-
for (const T of
|
|
182
|
-
|
|
183
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
|
|
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
|
-
|
|
206
|
+
h.replaceChildren(...p), i.push({ element: N, index: s });
|
|
192
207
|
}
|
|
193
|
-
for (const [n,
|
|
194
|
-
const { start: e, end: t, color:
|
|
195
|
-
e.idx === t.idx && o(e.idx, n, e.offset, t.offset,
|
|
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
|
|
212
|
+
return i;
|
|
198
213
|
}
|
|
199
214
|
export {
|
|
200
|
-
|
|
215
|
+
V as findMatches,
|
|
201
216
|
W as getHighlightOptionsWithDefaults,
|
|
202
|
-
|
|
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
|
|
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
|
-
|
|
32
|
+
E as useFileDownload
|
|
32
33
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useState as
|
|
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-
|
|
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}`,
|
|
@@ -44,20 +44,20 @@ kwIDAQAB
|
|
|
44
44
|
// Convert signature to ArrayBuffer
|
|
45
45
|
new TextEncoder().encode(atob(e))
|
|
46
46
|
))
|
|
47
|
-
throw new Error(
|
|
47
|
+
throw new Error(s.invalidSignature);
|
|
48
48
|
return JSON.parse(atob(e));
|
|
49
49
|
} catch {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error(s.invalidLicense);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), d = {
|
|
54
54
|
isValid: !0,
|
|
55
|
-
invalidatedMessage:
|
|
55
|
+
invalidatedMessage: s.invalidLicense,
|
|
56
56
|
type: void 0
|
|
57
57
|
}, x = (r) => {
|
|
58
|
-
const [t, e] =
|
|
58
|
+
const [t, e] = g(d), n = h(async () => {
|
|
59
59
|
if (!r)
|
|
60
|
-
throw e(d), new Error(
|
|
60
|
+
throw e(d), new Error(s.invalidLicense);
|
|
61
61
|
let i;
|
|
62
62
|
try {
|
|
63
63
|
i = await I(r);
|
|
@@ -65,35 +65,35 @@ const y = (r, t) => r === "specific" ? t === window.location.host : window.locat
|
|
|
65
65
|
throw c.warn(m.message), new Error(m.message);
|
|
66
66
|
}
|
|
67
67
|
c.debug(">>> validatedLicense", i);
|
|
68
|
-
const { avu: a, exp:
|
|
69
|
-
if (!
|
|
68
|
+
const { avu: a, exp: o, dmt: w, dm: p, t: v } = i;
|
|
69
|
+
if (!o)
|
|
70
70
|
throw new Error("License is missing expiration timestamp");
|
|
71
|
-
if (
|
|
71
|
+
if (o > Number.MAX_SAFE_INTEGER / 1e3)
|
|
72
72
|
throw new Error("Invalid expiration timestamp: value too large");
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
throw new Error(
|
|
73
|
+
const f = new Date(o * 1e3), E = (/* @__PURE__ */ new Date()).getTime();
|
|
74
|
+
if (f.getTime() < E)
|
|
75
|
+
throw new Error(s.expired);
|
|
76
76
|
if (!a)
|
|
77
77
|
throw new Error("License is missing available until version timestamp");
|
|
78
78
|
if (a > Number.MAX_SAFE_INTEGER / 1e3)
|
|
79
79
|
throw new Error("Invalid available until version timestamp: value too large");
|
|
80
80
|
const u = new Date(a * 1e3);
|
|
81
81
|
if (c.debug("availableUntilTimestamp", u), u.getTime() < b.getTime())
|
|
82
|
-
throw new Error(
|
|
82
|
+
throw new Error(s.exceededVersion);
|
|
83
83
|
if (!y(w, p))
|
|
84
|
-
throw new Error(
|
|
84
|
+
throw new Error(s.mismatchedDomain);
|
|
85
85
|
return {
|
|
86
86
|
isValid: !0,
|
|
87
|
-
type:
|
|
87
|
+
type: v,
|
|
88
88
|
invalidatedMessage: void 0
|
|
89
89
|
};
|
|
90
90
|
}, [r]);
|
|
91
91
|
return A(() => {
|
|
92
|
-
n().then(({ isValid: i, type: a, invalidatedMessage:
|
|
92
|
+
n().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
|
|
93
93
|
e({
|
|
94
94
|
isValid: i,
|
|
95
95
|
type: a,
|
|
96
|
-
invalidatedMessage:
|
|
96
|
+
invalidatedMessage: o
|
|
97
97
|
});
|
|
98
98
|
}).catch((i) => {
|
|
99
99
|
e({
|
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import * as
|
|
3
|
-
import { getThumbnailViewport as
|
|
4
|
-
import { useConfigContext as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,
|
|
12
|
-
url:
|
|
13
|
-
cMapPacked: (
|
|
14
|
-
...(
|
|
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",
|
|
17
|
-
const n =
|
|
18
|
-
n.onProgress = (
|
|
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:
|
|
21
|
-
|
|
28
|
+
const { loaded: b, total: l } = s, j = l ? Math.min(100, Math.round(b / l * 100)) : 0;
|
|
29
|
+
g(j);
|
|
22
30
|
}
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
}).finally(() =>
|
|
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
|
-
|
|
36
|
+
e.finally(() => {
|
|
29
37
|
n.destroy();
|
|
30
38
|
});
|
|
31
39
|
};
|
|
32
|
-
}, [
|
|
40
|
+
}, [m, x, d, p, w]), C(() => {
|
|
41
|
+
if (c)
|
|
42
|
+
return;
|
|
33
43
|
const t = /* @__PURE__ */ new Map();
|
|
34
|
-
if (!r ||
|
|
35
|
-
|
|
44
|
+
if (!r || P) {
|
|
45
|
+
L(t);
|
|
36
46
|
return;
|
|
37
47
|
}
|
|
38
|
-
const
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
n.push(
|
|
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((
|
|
44
|
-
|
|
45
|
-
const { thumbnailViewport:
|
|
46
|
-
t.set(
|
|
47
|
-
}),
|
|
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,
|
|
59
|
+
}, [r, P, c]), {
|
|
50
60
|
pdf: r,
|
|
51
|
-
pages:
|
|
52
|
-
loading:
|
|
53
|
-
loadingProgress:
|
|
61
|
+
pages: v,
|
|
62
|
+
loading: P,
|
|
63
|
+
loadingProgress: R,
|
|
64
|
+
passwordRequired: c,
|
|
65
|
+
passwordError: T
|
|
54
66
|
};
|
|
55
67
|
};
|
|
56
68
|
export {
|
|
57
|
-
|
|
69
|
+
z as useLoadPdf
|
|
58
70
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import
|
|
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
|
-
|
|
34
|
+
G as usePaginate
|
|
33
35
|
};
|