@pdf-viewer/react 1.18.0-beta.0 → 1.18.0-beta.1

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.
@@ -600,6 +600,7 @@ export interface Match {
600
600
  oIndex: number;
601
601
  pageIndex: number;
602
602
  rect: RectPosition;
603
+ rects?: RectPosition[];
603
604
  }
604
605
  export interface MatchValue extends Match {
605
606
  page: number;
@@ -1,221 +1,221 @@
1
1
  import { getCharacterType as D } from "./charators.js";
2
- function V(r, c, u, i) {
3
- const o = [];
2
+ function _(r, c, m, i) {
3
+ const s = [];
4
4
  for (const n of r) {
5
- const s = y(c, n, i);
6
- o.push(...I(s, c, u));
5
+ const o = y(c, n, i);
6
+ s.push(...R(o, c, m));
7
7
  }
8
- return o;
8
+ return s;
9
9
  }
10
- const X = (r, c) => {
11
- const u = ["g"];
12
- c.matchCase || u.push("i");
13
- let o = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
- return new RegExp(o, u.join(""));
10
+ const L = (r, c) => {
11
+ const m = ["g"];
12
+ c.matchCase || m.push("i");
13
+ let s = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
+ return new RegExp(s, m.join(""));
15
15
  };
16
- function y(r, c, u) {
16
+ function y(r, c, m) {
17
17
  const i = [];
18
18
  for (const t of r.items)
19
19
  if (t.hasEOL)
20
20
  if (t.str.endsWith("-")) {
21
- const l = t.str.lastIndexOf("-");
22
- i.push(t.str.substring(0, l));
21
+ const d = t.str.lastIndexOf("-");
22
+ i.push(t.str.substring(0, d));
23
23
  } else
24
24
  i.push(t.str, `
25
25
  `);
26
26
  else
27
27
  i.push(t.str);
28
- const o = i.join("").replace(/\n/g, " ");
28
+ const s = 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 = X(c, u);
31
- const s = [];
30
+ c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = L(c, m);
31
+ const o = [];
32
32
  let e;
33
- for (; (e = n.exec(o)) !== null; )
34
- u.wholeWords && !L(o, e.index, e[0].length) || s.push([e.index, e[0].length, e[0]]);
35
- return s;
33
+ for (; (e = n.exec(s)) !== null; )
34
+ m.wholeWords && !W(s, e.index, e[0].length) || o.push([e.index, e[0].length, e[0]]);
35
+ return o;
36
36
  }
37
- function I(r, c, u) {
38
- function i(l) {
39
- return l.hasEOL ? l.str.endsWith("-") ? -1 : 1 : 0;
37
+ function R(r, c, m) {
38
+ function i(d) {
39
+ return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
40
40
  }
41
- let o = 0, n = 0;
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++;
41
+ let s = 0, n = 0;
42
+ const o = c.items, e = o.length - 1, t = [];
43
+ for (let d = 0; d < r.length; d++) {
44
+ let h = r[d][0];
45
+ for (; s !== e && h >= n + o[s].str.length; ) {
46
+ const x = o[s];
47
+ n += x.str.length + i(x), s++;
48
48
  }
49
- const h = {
50
- idx: o,
51
- offset: d - n
49
+ const g = {
50
+ idx: s,
51
+ offset: h - n
52
52
  };
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++;
53
+ for (h += r[d][1]; s !== e && h > n + o[s].str.length; ) {
54
+ const x = o[s];
55
+ n += x.str.length + i(x), s++;
56
56
  }
57
- const m = {
58
- idx: o,
59
- offset: d - n
57
+ const l = {
58
+ idx: s,
59
+ offset: h - n
60
60
  };
61
61
  t.push({
62
- start: h,
63
- end: m,
64
- str: r[l][2],
65
- oIndex: r[l][0],
66
- pageIndex: u,
67
- rect: {
68
- left: 0,
69
- bottom: 0,
70
- width: 0,
71
- height: 0
72
- }
62
+ start: g,
63
+ end: l,
64
+ str: r[d][2],
65
+ oIndex: r[d][0],
66
+ pageIndex: m,
67
+ rect: { left: 0, bottom: 0, width: 0, height: 0 },
68
+ rects: []
73
69
  });
74
70
  }
75
- for (const l of t) {
76
- const d = s[l.start.idx], h = s[l.end.idx], m = d.transform[4] + l.start.offset * (d.width / d.str.length), f = d.transform[5], E = h.transform[4] + l.end.offset * (h.width / h.str.length), a = h.transform[5], M = {
77
- left: Math.min(m, E),
78
- bottom: Math.min(f, a),
79
- width: Math.abs(E - m),
80
- height: Math.max(d.height, h.height)
81
- };
82
- l.rect = M;
71
+ for (const d of t) {
72
+ const h = [];
73
+ for (let g = d.start.idx; g <= d.end.idx; g++) {
74
+ const l = o[g], x = l.transform[4], C = l.transform[5], a = l.str.length > 0 ? l.width / l.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : l.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[l.fontName], T = (u == null ? void 0 : u.ascent) ?? 1, v = (u == null ? void 0 : u.descent) != null ? Math.abs(u.descent) : 1 - T, b = C - v * l.height;
75
+ (E > 0 || l.height > 0) && h.push({
76
+ left: f,
77
+ bottom: b,
78
+ width: E,
79
+ height: l.height
80
+ });
81
+ }
82
+ d.rect = h[0], d.rects = h;
83
83
  }
84
84
  return t;
85
85
  }
86
- function L(r, c, u) {
86
+ function W(r, c, m) {
87
87
  let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
88
88
  if (i) {
89
- const o = r.charCodeAt(c), n = i[1].charCodeAt(0);
90
- if (D(o) === D(n))
89
+ const s = r.charCodeAt(c), n = i[1].charCodeAt(0);
90
+ if (D(s) === D(n))
91
91
  return !1;
92
92
  }
93
- if (i = r.slice(c + u).match(/^\p{M}*([^\p{M}])/u), i) {
94
- const o = r.charCodeAt(c + u - 1), n = i[1].charCodeAt(0);
95
- if (D(o) === D(n))
93
+ if (i = r.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
94
+ const s = r.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
95
+ if (D(s) === D(n))
96
96
  return !1;
97
97
  }
98
98
  return !0;
99
99
  }
100
- function H(r, c, u) {
100
+ function I(r, c, m) {
101
101
  const i = [];
102
- function o(n, s, e = -1, t = -1, l = "") {
103
- const d = c.items[n], h = [];
104
- let m = "", f = "", E = "", a = u[n];
102
+ function s(n, o, e = -1, t = -1, d = "") {
103
+ const h = c.items[n], g = [];
104
+ let l = "", x = "", C = "", a = m[n];
105
105
  if (!a)
106
106
  return;
107
107
  if (a.nodeType === Node.TEXT_NODE) {
108
- const p = document.createElement("span");
109
- a.before(p), p.append(a), u[n] = p, a = p;
108
+ const f = document.createElement("span");
109
+ a.before(f), f.append(a), m[n] = f, a = f;
110
110
  }
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 M = document.createTextNode(m), N = document.createElement("span");
113
- if (N.className = "highlight appended " + l, N.setAttribute("data-match-index", `${s}`), N.append(M), h.push(N), i.push({ element: N, index: s }), e > 0)
111
+ e >= 0 && t >= 0 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
112
+ const M = document.createTextNode(l), N = document.createElement("span");
113
+ if (N.className = "highlight appended " + d, N.setAttribute("data-match-index", `${o}`), N.append(M), g.push(N), i.push({ element: N, index: o }), e > 0)
114
114
  if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
115
- f = d.str.substring(0, e);
116
- const p = document.createTextNode(f);
117
- h.unshift(p);
115
+ x = h.str.substring(0, e);
116
+ const f = document.createTextNode(x);
117
+ g.unshift(f);
118
118
  } else {
119
- let p = 0;
120
- const b = [];
121
- for (const g of a.childNodes) {
122
- const x = g.nodeType === Node.TEXT_NODE ? g.nodeValue : g.firstChild.nodeValue;
123
- p += x.length, p <= e ? b.push(g) : e >= p - x.length && t <= p && b.push(
119
+ let f = 0;
120
+ const E = [];
121
+ for (const p of a.childNodes) {
122
+ const u = p.nodeType === Node.TEXT_NODE ? p.nodeValue : p.firstChild.nodeValue;
123
+ f += u.length, f <= e ? E.push(p) : e >= f - u.length && t <= f && E.push(
124
124
  document.createTextNode(
125
- x.substring(0, e - (p - x.length))
125
+ u.substring(0, e - (f - u.length))
126
126
  )
127
127
  );
128
128
  }
129
- h.unshift(...b);
129
+ g.unshift(...E);
130
130
  }
131
131
  if (t > 0) {
132
- E = d.str.substring(t);
133
- const p = document.createTextNode(E);
134
- h.push(p);
132
+ C = h.str.substring(t);
133
+ const f = document.createTextNode(C);
134
+ g.push(f);
135
135
  }
136
- a.replaceChildren(...h);
136
+ a.replaceChildren(...g);
137
137
  }
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);
138
+ for (const [n, o] of r.entries())
139
+ if (o.start.idx === o.end.idx)
140
+ s(o.start.idx, n, o.start.offset, o.end.offset);
141
141
  else
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");
142
+ for (let e = o.start.idx, t = o.end.idx; e <= t; e++)
143
+ e === o.start.idx ? s(e, n, o.start.offset, -1, "begin") : e === o.end.idx ? s(e, n, -1, o.end.offset, "end") : s(e, n, -1, -1, "middle");
144
144
  return i;
145
145
  }
146
- function R(r, c) {
147
- const u = r.items.map((i) => i.str);
146
+ function V(r, c) {
147
+ const m = r.items.map((i) => i.str);
148
148
  for (let i = 0; i < c.length; i++) {
149
- const o = c[i];
150
- if (o && o.nodeType !== Node.TEXT_NODE) {
151
- const n = document.createTextNode(u[i]);
152
- o.replaceChildren(n);
149
+ const s = c[i];
150
+ if (s && s.nodeType !== Node.TEXT_NODE) {
151
+ const n = document.createTextNode(m[i]);
152
+ s.replaceChildren(n);
153
153
  }
154
154
  }
155
155
  }
156
- function W(r = {}) {
156
+ function H(r = {}) {
157
157
  return { matchCase: !1, wholeWords: !1, ...r };
158
158
  }
159
- function A(r, c, u) {
159
+ function S(r, c, m) {
160
160
  const i = [];
161
- function o(n, s, e = -1, t = -1, l) {
162
- var p, b;
163
- const d = c.items[n], h = [];
164
- let m = "", f = "", E = "", a = u[n];
161
+ function s(n, o, e = -1, t = -1, d) {
162
+ var f, E;
163
+ const h = c.items[n], g = [];
164
+ let l = "", x = "", C = "", a = m[n];
165
165
  if (!a)
166
166
  return;
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 M = document.createTextNode(m), N = document.createElement("span");
169
- if (N.style.background = l, N.append(M), h.push(N), e > 0)
167
+ e >= 0 && t >= 0 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
168
+ const M = document.createTextNode(l), N = document.createElement("span");
169
+ if (N.style.background = d, N.append(M), g.push(N), e > 0)
170
170
  if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
171
- f = d.str.substring(0, e);
172
- const g = document.createTextNode(f);
173
- h.unshift(g);
171
+ x = h.str.substring(0, e);
172
+ const p = document.createTextNode(x);
173
+ g.unshift(p);
174
174
  } else {
175
- let g = 0;
176
- const x = [];
175
+ let p = 0;
176
+ const u = [];
177
177
  for (const T of a.childNodes) {
178
- const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((p = T.firstChild) == null ? void 0 : p.nodeValue) || "", C = v.length;
179
- if (g += C, g <= e)
180
- x.push(T);
181
- else if (e >= g - C && t <= g) {
182
- const w = v.substring(0, e - (g - C));
183
- x.push(document.createTextNode(w));
178
+ const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((f = T.firstChild) == null ? void 0 : f.nodeValue) || "", b = v.length;
179
+ if (p += b, p <= e)
180
+ u.push(T);
181
+ else if (e >= p - b && t <= p) {
182
+ const w = v.substring(0, e - (p - b));
183
+ u.push(document.createTextNode(w));
184
184
  }
185
185
  }
186
- h.unshift(...x);
186
+ g.unshift(...u);
187
187
  }
188
188
  if (t > 0)
189
189
  if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
190
- E = d.str.substring(t);
191
- const g = document.createTextNode(E);
192
- h.push(g);
190
+ C = h.str.substring(t);
191
+ const p = document.createTextNode(C);
192
+ g.push(p);
193
193
  } else {
194
- let g = 0;
195
- const x = [];
194
+ let p = 0;
195
+ const u = [];
196
196
  for (const T of a.childNodes) {
197
- g >= t && x.push(T);
198
- const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((b = T.firstChild) == null ? void 0 : b.nodeValue) || "", C = v.length;
199
- if (g += C, g > t) {
200
- const w = v.substring(t - (g - C));
201
- w && x.push(document.createTextNode(w));
197
+ p >= t && u.push(T);
198
+ const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((E = T.firstChild) == null ? void 0 : E.nodeValue) || "", b = v.length;
199
+ if (p += b, p > t) {
200
+ const w = v.substring(t - (p - b));
201
+ w && u.push(document.createTextNode(w));
202
202
  }
203
203
  }
204
- x.length > 0 && h.push(...x);
204
+ u.length > 0 && g.push(...u);
205
205
  }
206
- a.replaceChildren(...h), i.push({ element: N, index: s });
206
+ a.replaceChildren(...g), i.push({ element: N, index: o });
207
207
  }
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);
208
+ for (const [n, o] of r.entries()) {
209
+ const { start: e, end: t, color: d } = o;
210
+ e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
211
211
  }
212
212
  return i;
213
213
  }
214
214
  export {
215
- V as findMatches,
216
- W as getHighlightOptionsWithDefaults,
217
- H as highlightMatches,
218
- A as highlightMultipleColorMatches,
219
- L as isMatchEntireWord,
220
- R as resetDivs
215
+ _ as findMatches,
216
+ H as getHighlightOptionsWithDefaults,
217
+ I as highlightMatches,
218
+ S as highlightMultipleColorMatches,
219
+ W as isMatchEntireWord,
220
+ V as resetDivs
221
221
  };
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2026-01-30T06:22:29.291Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2026-02-02T10:36:09.752Z"), d = "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. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
5
- "version": "1.18.0-beta.0",
5
+ "version": "1.18.0-beta.1",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",