New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@paodingai/pdflux-pdf-viewer

Package Overview
Dependencies
Maintainers
0
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paodingai/pdflux-pdf-viewer - npm Package Compare versions

Comparing version 0.11.0-beta.10 to 0.11.0-beta.11

dist/types/module/display/editor/resizeService.d.ts

247

dist/extensions/SelectOcrTextService.js

@@ -1,2 +0,2 @@

var T = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, te = typeof T == "object" && T && T.Object === Object && T, H = te, re = H, ne = typeof self == "object" && self && self.Object === Object && self, ae = re || ne || Function("return this")(), f = ae, se = f, oe = se.Symbol, O = oe, E = O, K = Object.prototype, ie = K.hasOwnProperty, ce = K.toString, y = E ? E.toStringTag : void 0;
var T = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, te = typeof T == "object" && T && T.Object === Object && T, H = te, re = H, ne = typeof self == "object" && self && self.Object === Object && self, ae = re || ne || Function("return this")(), f = ae, oe = f, se = oe.Symbol, O = se, E = O, K = Object.prototype, ie = K.hasOwnProperty, ce = K.toString, y = E ? E.toStringTag : void 0;
function ue(e) {

@@ -16,5 +16,5 @@ var t = ie.call(e, y), r = e[y];

}
var pe = fe, B = O, de = ge, ve = pe, be = "[object Null]", xe = "[object Undefined]", N = B ? B.toStringTag : void 0;
var pe = fe, N = O, de = ge, xe = pe, ve = "[object Null]", be = "[object Undefined]", B = N ? N.toStringTag : void 0;
function ye(e) {
return e == null ? e === void 0 ? xe : be : N && N in Object(e) ? de(e) : ve(e);
return e == null ? e === void 0 ? be : ve : B && B in Object(e) ? de(e) : xe(e);
}

@@ -26,21 +26,21 @@ var _ = ye;

}
var X = Te, $e = _, je = X, Pe = "[object AsyncFunction]", we = "[object Function]", Ie = "[object GeneratorFunction]", me = "[object Proxy]";
var X = Te, $e = _, Ie = X, Pe = "[object AsyncFunction]", we = "[object Function]", je = "[object GeneratorFunction]", me = "[object Proxy]";
function Se(e) {
if (!je(e))
if (!Ie(e))
return !1;
var t = $e(e);
return t == we || t == Ie || t == Pe || t == me;
return t == we || t == je || t == Pe || t == me;
}
var ke = Se, Me = f, Oe = Me["__core-js_shared__"], _e = Oe, j = _e, A = function() {
var e = /[^.]+$/.exec(j && j.keys && j.keys.IE_PROTO || "");
var ke = Se, Me = f, Oe = Me["__core-js_shared__"], _e = Oe, I = _e, R = function() {
var e = /[^.]+$/.exec(I && I.keys && I.keys.IE_PROTO || "");
return e ? "Symbol(src)_1." + e : "";
}();
function Ce(e) {
return !!A && A in e;
return !!R && R in e;
}
var Ee = Ce, Be = Function.prototype, Ne = Be.toString;
function Ae(e) {
var Ee = Ce, Ne = Function.prototype, Be = Ne.toString;
function Re(e) {
if (e != null) {
try {
return Ne.call(e);
return Be.call(e);
} catch {

@@ -55,7 +55,7 @@ }

}
var z = Ae, Re = ke, Fe = Ee, De = X, Ge = z, Ve = /[\\^$.*+?()[\]{}|]/g, Le = /^\[object .+?Constructor\]$/, We = Function.prototype, Ue = Object.prototype, Je = We.toString, qe = Ue.hasOwnProperty, He = RegExp("^" + Je.call(qe).replace(Ve, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
var z = Re, Ae = ke, Fe = Ee, De = X, Ge = z, Ve = /[\\^$.*+?()[\]{}|]/g, Le = /^\[object .+?Constructor\]$/, We = Function.prototype, Ue = Object.prototype, Je = We.toString, qe = Ue.hasOwnProperty, He = RegExp("^" + Je.call(qe).replace(Ve, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
function Ke(e) {
if (!De(e) || Fe(e))
return !1;
var t = Re(e) ? He : Le;
var t = Ae(e) ? He : Le;
return t.test(Ge(e));

@@ -72,7 +72,7 @@ }

}
var b = et, tt = b, rt = f, nt = tt(rt, "Map"), at = nt, st = b;
st(Object, "create");
var ot = f;
ot.Uint8Array;
var R = O, F = R ? R.prototype : void 0;
var v = et, tt = v, rt = f, nt = tt(rt, "Map"), at = nt, ot = v;
ot(Object, "create");
var st = f;
st.Uint8Array;
var A = O, F = A ? A.prototype : void 0;
F && F.valueOf;

@@ -90,3 +90,3 @@ function it(e) {

}());
var P = {}, vt = {
var P = {}, xt = {
get exports() {

@@ -99,10 +99,10 @@ return P;

};
function bt() {
function vt() {
return !1;
}
var xt = bt;
var bt = vt;
(function(e, t) {
var r = f, n = xt, a = t && !t.nodeType && t, s = a && !0 && e && !e.nodeType && e, o = s && s.exports === a, i = o ? r.Buffer : void 0, c = i ? i.isBuffer : void 0, u = c || n;
var r = f, n = bt, a = t && !t.nodeType && t, o = a && !0 && e && !e.nodeType && e, s = o && o.exports === a, i = s ? r.Buffer : void 0, c = i ? i.isBuffer : void 0, u = c || n;
e.exports = u;
})(vt, P);
})(xt, P);
var $ = {}, yt = {

@@ -117,6 +117,6 @@ get exports() {

(function(e, t) {
var r = H, n = t && !t.nodeType && t, a = n && !0 && e && !e.nodeType && e, s = a && a.exports === n, o = s && r.process, i = function() {
var r = H, n = t && !t.nodeType && t, a = n && !0 && e && !e.nodeType && e, o = a && a.exports === n, s = o && r.process, i = function() {
try {
var c = a && a.require && a.require("util").types;
return c || o && o.binding && o.binding("util");
return c || s && s.binding && s.binding("util");
} catch {

@@ -129,8 +129,8 @@ }

G && G.isTypedArray;
var Tt = b, $t = f, jt = Tt($t, "DataView"), Pt = jt, wt = b, It = f, mt = wt(It, "Promise"), St = mt, kt = b, Mt = f, Ot = kt(Mt, "Set"), _t = Ot, Ct = b, Et = f, Bt = Ct(Et, "WeakMap"), Nt = Bt, w = Pt, I = at, m = St, S = _t, k = Nt, Z = _, x = z, V = "[object Map]", At = "[object Object]", L = "[object Promise]", W = "[object Set]", U = "[object WeakMap]", J = "[object DataView]", Rt = x(w), Ft = x(I), Dt = x(m), Gt = x(S), Vt = x(k), v = Z;
(w && v(new w(new ArrayBuffer(1))) != J || I && v(new I()) != V || m && v(m.resolve()) != L || S && v(new S()) != W || k && v(new k()) != U) && (v = function(e) {
var t = Z(e), r = t == At ? e.constructor : void 0, n = r ? x(r) : "";
var Tt = v, $t = f, It = Tt($t, "DataView"), Pt = It, wt = v, jt = f, mt = wt(jt, "Promise"), St = mt, kt = v, Mt = f, Ot = kt(Mt, "Set"), _t = Ot, Ct = v, Et = f, Nt = Ct(Et, "WeakMap"), Bt = Nt, w = Pt, j = at, m = St, S = _t, k = Bt, Z = _, b = z, V = "[object Map]", Rt = "[object Object]", L = "[object Promise]", W = "[object Set]", U = "[object WeakMap]", J = "[object DataView]", At = b(w), Ft = b(j), Dt = b(m), Gt = b(S), Vt = b(k), x = Z;
(w && x(new w(new ArrayBuffer(1))) != J || j && x(new j()) != V || m && x(m.resolve()) != L || S && x(new S()) != W || k && x(new k()) != U) && (x = function(e) {
var t = Z(e), r = t == Rt ? e.constructor : void 0, n = r ? b(r) : "";
if (n)
switch (n) {
case Rt:
case At:
return J;

@@ -149,6 +149,6 @@ case Ft:

function Lt(e, t, r = 0.7, n = 0.4) {
const a = Math.max(e[0], t[0]), s = Math.max(e[1], t[1]), o = Math.min(e[2], t[2]), i = Math.min(e[3], t[3]);
if (a >= o || s >= i)
const a = Math.max(e[0], t[0]), o = Math.max(e[1], t[1]), s = Math.min(e[2], t[2]), i = Math.min(e[3], t[3]);
if (a >= s || o >= i)
return !1;
const c = e[2] - e[0], u = e[3] - e[1], h = o - a, g = i - s, l = h / c, p = g / u;
const c = e[2] - e[0], u = e[3] - e[1], h = s - a, g = i - o, l = h / c, p = g / u;
return c < 10 && (r = 0.5), l > r && p > n;

@@ -166,6 +166,6 @@ }

viewport: {
scale: s
scale: o
}
} = e;
return r /= s, n /= s, t !== 0 && (a += t, a = ee(a)), (a === 90 || a === 270) && ([n, r] = [r, n]), {
return r /= o, n /= o, t !== 0 && (a += t, a = ee(a)), (a === 90 || a === 270) && ([n, r] = [r, n]), {
width: r,

@@ -184,6 +184,6 @@ height: n,

r = ee(r);
const a = Math.sign(r), s = 90 * (Math.PI / 180) * a, o = Math.cos(s), i = Math.sin(s), c = Math.abs(r / 90);
const a = Math.sign(r), o = 90 * (Math.PI / 180) * a, s = Math.cos(o), i = Math.sin(o), c = Math.abs(r / 90);
(r === -90 || r === -270) && ([e, t] = [t, e]);
const u = ([h, g], l) => {
const p = h * o - g * i, d = g * o + h * i;
const p = h * s - g * i, d = g * s + h * i;
return [p - l, d + l];

@@ -203,7 +203,7 @@ };

}, qt = (e, t) => {
const [r, n, a, s] = e, [o, i, c, u] = t;
return !(a <= o || r >= c || n >= u || s <= i);
const [r, n, a, o] = e, [s, i, c, u] = t;
return !(a <= s || r >= c || n >= u || o <= i);
}, M = (e, t) => {
const [r, n, a, s] = e, [o, i] = t;
return o >= r && i >= n && o <= a && i <= s;
const [r, n, a, o] = e, [s, i] = t;
return s >= r && i >= n && s <= a && i <= o;
};

@@ -214,6 +214,6 @@ async function Ht(e, t) {

if (n.chars) {
n.chars.forEach((s, o) => {
n.chars.forEach((o, s) => {
r.push({
...s,
index: o,
...o,
index: s,
str: n.str

@@ -238,3 +238,3 @@ });

async function Xt(e, t, r, n, a) {
const s = await this.getNearPointIndexes({
const o = await this.getNearPointIndexes({
index: r,

@@ -246,16 +246,16 @@ x: e,

});
if (s[0] !== s[1])
return s;
const [o] = await this.getRects({
if (o[0] !== o[1])
return o;
const [s] = await this.getRects({
pageIndex: r,
count: 1,
index: s[0]
index: o[0]
});
if (!o)
return s;
const [i, c, u, h] = o;
if (!s)
return o;
const [i, c, u, h] = s;
if (!(e + n >= i && e - n <= u && t + a >= c && t - a <= h))
return s;
return o;
const g = u - i;
return e - i > g / 2 ? s.map((l) => l + 1) : s;
return e - i > g / 2 ? o.map((l) => l + 1) : o;
}

@@ -275,5 +275,5 @@ function zt(e) {

height: a,
rotation: s,
pageNumber: o
} = r, i = this.app.pages[o - 1], {
rotation: o,
pageNumber: s
} = r, i = this.app.pages[s - 1], {
viewport: {

@@ -286,3 +286,3 @@ scale: c

height: a,
rotation: -s
rotation: -o
}, [e, t]);

@@ -293,4 +293,4 @@ }

r.pageNumber = t.id;
const [n, a] = this.convertToPDFPoint(e[0], e[1], r), [s, o] = this.convertToPDFPoint(e[2], e[3], r);
return [n, a, s, o];
const [n, a] = this.convertToPDFPoint(e[0], e[1], r), [o, s] = this.convertToPDFPoint(e[2], e[3], r);
return [n, a, o, s];
}

@@ -300,3 +300,3 @@ async function tr(e, t) {

}
async function rr(e) {
function rr(e) {
return this.getPageChars(e).length;

@@ -310,33 +310,33 @@ }

}
async function sr(e) {
async function or(e) {
const t = this.getPageChars(e.pageIndex), r = /[。!?;.]/, n = await this.app.pages[e.pageIndex].pdfPage.getElementBlockCharRange(e.startIndex);
let a = n[0], s = n[1];
for (let o = e.startIndex; o >= n[0]; o -= 1)
if (r.test(t[o].text)) {
a = o;
let a = n[0], o = n[1];
for (let s = e.startIndex; s >= n[0]; s -= 1)
if (r.test(t[s].text)) {
a = s;
break;
}
for (let o = e.startIndex; o < n[1]; o += 1)
if (r.test(t[o].text)) {
s = o;
for (let s = e.startIndex; s < n[1]; s += 1)
if (r.test(t[s].text)) {
o = s;
break;
}
return [a, s];
return [a, o];
}
async function or(e) {
async function sr(e) {
return e;
}
function ir(e, t, r, n, a) {
let s = 0;
const o = [t - n, r - a, t + n, r + a];
let o = 0;
const s = [t - n, r - a, t + n, r + a];
let i = Number.MAX_VALUE, c = -1;
for (; s < e.length; ) {
const u = e[s].box;
for (; o < e.length; ) {
const u = e[o].box;
if (M(u, [t, r]))
return [s, s];
if (qt(u, o)) {
return [o, o];
if (qt(u, s)) {
const [h, g, l, p] = u, d = Math.min(Math.abs(t - l), Math.abs(t - h));
(g < r || p > r) && d < i && (i = d, c = s);
(g < r || p > r) && d < i && (i = d, c = o);
}
s += 1;
o += 1;
}

@@ -350,17 +350,17 @@ return c === e.length - 1 || c === -1 ? [c, c] : [c, c + 1];

} = e, n = this.getPageChars(e.index);
let [a, s] = this.getCharIndexByPoint(n, t, r, e.xTolerance, e.yTolerance);
const o = Math.abs(e.y - n[0].box[1]) < Math.abs(e.y - n.at(-1).box[1]);
return s === -1 && a === -1 && (this.preSelect.page !== e.index ? (a = o ? 0 : n.length - 1, s = a) : (a = this.preSelect.index, s = this.preSelect.index + 1)), this.preSelect = {
let [a, o] = this.getCharIndexByPoint(n, t, r, e.xTolerance, e.yTolerance);
const s = Math.abs(e.y - n[0].box[1]) < Math.abs(e.y - n.at(-1).box[1]);
return o === -1 && a === -1 && (this.preSelect.page !== e.index ? (a = s ? 0 : n.length - 1, o = a) : (a = this.preSelect.index, o = this.preSelect.index + 1)), this.preSelect = {
index: a,
page: e.index
}, a > s && (a = s), [a, s];
}, a > o && (a = o), [a, o];
}
async function ur(e) {
const t = this.getPageChars(e.index), r = t.findIndex((a) => {
const s = a.box, o = s[2] - s[0], i = s[3] - s[1];
return M(e.rect, [s[0] + o / 2, s[1] + i / 2]);
const o = a.box, s = o[2] - o[0], i = o[3] - o[1];
return M(e.rect, [o[0] + s / 2, o[1] + i / 2]);
});
let n = t.findIndex((a, s) => {
const o = a.box, i = o[2] - o[0], c = o[3] - o[1];
return !M(e.rect, [o[0] + i / 2, o[1] + c / 2]) && s > r;
let n = t.findIndex((a, o) => {
const s = a.box, i = s[2] - s[0], c = s[3] - s[1];
return !M(e.rect, [s[0] + i / 2, s[1] + c / 2]) && o > r;
});

@@ -376,5 +376,5 @@ return n === -1 && (n = t.length - 1), [r, n];

withNewline: !1
}), a = (await this.workerTransport.getWordSegment(n)).split(" "), s = e.startIndex - t;
let o = 0;
const i = a.findIndex((c) => (o += c.length, s < o));
}), a = (await this.workerTransport.getWordSegment(n)).split(" "), o = e.startIndex - t;
let s = 0;
const i = a.findIndex((c) => (s += c.length, o < s));
return a.length > 0 && i !== -1 ? (t += a.slice(0, i).reduce((c, u) => (c += u.length, c), 0), [t, t + a[i].length]) : [e.startIndex, e.startIndex + 1];

@@ -390,13 +390,36 @@ }

async function fr(e) {
const t = this.getPageChars(e.pageIndex), r = [], [n] = t[e.start].box, a = e.direction === -1 ? 0 : e.start, s = e.direction === -1 ? e.start : t.length;
for (let o = a; o < s; o += 1) {
const [i, , c] = t[o].box, u = c - i;
Math.abs(i - n) < u && (r.length === 0 && r.push(o), r.at(-1) && o - r.at(-1) > 1 && r.push(o));
const t = this.getPageChars(e.pageIndex), r = [], [n] = t[e.start].box, a = e.direction === -1 ? 0 : e.start, o = e.direction === -1 ? e.start : t.length;
for (let s = a; s < o; s += 1) {
const [i, , c] = t[s].box, u = c - i;
Math.abs(i - n) < u && (r.length === 0 && r.push(s), r.at(-1) && s - r.at(-1) > 1 && r.push(s));
}
return r;
}
async function pr(e) {
async function pr(e, t, r, n, a) {
const o = await this.getNearPointIndexes({
index: e - 1,
x: t,
y: r,
xTolerance: n,
yTolerance: a
});
if (o[0] !== o[1])
return o;
const [s] = await this.getRects({
pageIndex: e - 1,
index: o[0],
count: 1
});
if (!s)
return o;
const [i, c, u, h] = s;
if (!(t + n >= i && t - n <= u && r + a >= c && r - a <= h))
return o;
const g = u - i;
return t - i > g / 2 ? o.map((l) => l + 1) : o;
}
async function dr(e) {
return this.getTextInRect(e.rect, e.pageIndex);
}
async function dr(e) {
async function xr(e) {
if (typeof this.getTextBlocks == "function") {

@@ -413,6 +436,6 @@ const t = await this.getTextBlocks(e - 1);

}
function xr() {
function yr() {
this.app.removeEventListener("pagerendered", this.onPagerendered);
}
class yr {
class Tr {
name = "selectOcrText";

@@ -429,2 +452,3 @@ preSelect = {

}
isOcr = !0;
async insertTextBlocks(t, r) {

@@ -436,4 +460,4 @@ return Ht.call(this, t, r);

}
async getExactIndexNearPoint(t, r, n, a = 10, s = 10) {
return Xt.call(this, t, r, n, a, s);
async getExactIndexNearPoint(t, r, n, a = 10, o = 10) {
return Xt.call(this, t, r, n, a, o);
}

@@ -470,3 +494,3 @@ getPageChars(t) {

}
async getCountChars(t) {
getCountChars(t) {
return rr.call(this, t);

@@ -481,9 +505,9 @@ }

async getExpandSentence(t) {
return sr.call(this, t);
return or.call(this, t);
}
async getSentenceCountInText(t) {
return or.call(this, t);
return sr.call(this, t);
}
getCharIndexByPoint(t, r, n, a, s) {
return ir.call(this, t, r, n, a, s);
getCharIndexByPoint(t, r, n, a, o) {
return ir.call(this, t, r, n, a, o);
}

@@ -509,4 +533,7 @@ async getNearPointIndexes(t) {

}
async getNearPointExactIndexes(t, r, n, a = 10, o = 10) {
return pr.call(this, t, r, n, a, o);
}
async getTextInRectWithoutLineBreak(t) {
return pr.call(this, t);
return dr.call(this, t);
}

@@ -516,3 +543,3 @@ async onPagerendered({

}) {
return dr.call(this, t);
return xr.call(this, t);
}

@@ -526,7 +553,7 @@ install(t) {

onDocClosed() {
return xr.call(this);
return yr.call(this);
}
}
export {
yr as default
Tr as default
};

@@ -1,2 +0,2 @@

const x = (n) => n >= 360 ? n % 360 : n;
const d = (n) => n >= 360 ? n % 360 : n;
function y({

@@ -9,13 +9,13 @@ width: n,

return e;
r = x(r);
const a = Math.sign(r), s = 90 * (Math.PI / 180) * a, o = Math.cos(s), c = Math.sin(s), i = Math.abs(r / 90);
r = d(r);
const s = Math.sign(r), a = 90 * (Math.PI / 180) * s, i = Math.cos(a), c = Math.sin(a), o = Math.abs(r / 90);
(r === -90 || r === -270) && ([n, t] = [t, n]);
const p = ([u, h], l) => {
const f = u * o - h * c, g = h * o + u * c;
return [f - l, g + l];
const g = ([u, h], l) => {
const f = u * i - h * c, p = h * i + u * c;
return [f - l, p + l];
};
for (let u = 0; u < i; u += 1) {
for (let u = 0; u < o; u += 1) {
const [h, l] = [n / 2, t / 2], f = h - l;
let [g, d] = e;
g -= h, d -= l, e = p([g, d], f), e[0] += h, e[1] += l, [n, t] = [t, n];
let [p, x] = e;
p -= h, x -= l, e = g([p, x], f), e[0] += h, e[1] += l, [n, t] = [t, n];
}

@@ -25,5 +25,5 @@ return e;

async function T(n) {
return this.pdfiumTransport.getPageRotation(n);
return this.workerTransport.getPageRotation(n);
}
async function m(n, t, r) {
async function I(n, t, r) {
const e = await this.getNearPointIndexes({

@@ -38,3 +38,3 @@ index: r,

return e;
const [a] = await this.getRects({
const [s] = await this.getRects({
pageIndex: r,

@@ -44,31 +44,31 @@ index: e[0],

});
if (!a)
if (!s)
return e;
const [s, o, c, i] = a;
if (!(c + 10 >= s && c - 10 <= c && i + 10 >= o && i - 10 <= i))
const [a, i, c, o] = s;
if (!(c + 10 >= a && c - 10 <= c && o + 10 >= i && o - 10 <= o))
return e;
const p = c - s;
return c - s > p / 2 ? e.map((u) => u + 1) : e;
const g = c - a;
return c - a > g / 2 ? e.map((u) => u + 1) : e;
}
function I(n, t, r) {
function m(n, t, r) {
const {
width: e,
height: a,
rotation: s,
pageNumber: o
} = r, c = this.app.pages[o - 1], {
height: s,
rotation: a,
pageNumber: i
} = r, c = this.app.pages[i - 1], {
viewport: {
scale: i
scale: o
}
} = c;
return n /= i, t /= i, y({
return n /= o, t /= o, y({
width: e,
height: a,
rotation: -s
height: s,
rotation: -a
}, [n, t]);
}
function R(n, t) {
function w(n, t) {
return t.viewport.convertToPdfRectangle(n);
}
async function P(n, t) {
async function R(n, t) {
return this.pdfiumTransport.getTextAtRect({

@@ -79,11 +79,11 @@ index: t,

}
async function w(n, t, r, e) {
const a = [n - 10, t - 10, n + 10, t + 10], s = e.convertToPdfRectangle(a);
return this.getTextInRect(s, r);
async function P(n, t, r, e) {
const s = [n - 10, t - 10, n + 10, t + 10], a = e.convertToPdfRectangle(s);
return this.getTextInRect(a, r);
}
async function C(n) {
return this.pdfiumTransport.getCharIndexInRect(n);
return this.workerTransport.getCharIndexInRect(n);
}
async function E(n) {
return this.pdfiumTransport.getCountChars(n);
async function k(n) {
return this.charCount[n] ? this.charCount[n] : (this.charCount[n] = await this.workerTransport.getCountChars(n), this.charCount[n]);
}

@@ -93,3 +93,3 @@ async function N(n) {

}
async function k(n) {
async function E(n) {
return this.pdfiumTransport.getRects(n);

@@ -116,6 +116,29 @@ }

async function W(n) {
return this.pdfiumTransport.getTextInRectWithoutLineBreak(n);
return this.workerTransport.getTextInRectWithoutLineBreak(n);
}
async function L(n, t, r, e, a) {
const s = await this.getNearPointIndexes({
async function L(n, t, r, e, s) {
const a = await this.getNearPointIndexes({
index: n - 1,
x: t,
y: r,
xTolerance: e,
yTolerance: s
});
if (a[0] !== a[1])
return a;
const [i] = await this.getRects({
pageIndex: n - 1,
index: a[0],
count: 1
});
if (!i)
return a;
const [c, o, g, u] = i;
if (!(t + e >= c && t - e <= g && r + s >= o && r - s <= u))
return a;
const h = g - c;
return t - c > h / 2 ? a.map((l) => l + 1) : a;
}
async function $(n, t, r, e, s) {
const a = await this.getNearPointIndexes({
index: r,

@@ -125,27 +148,28 @@ x: n,

xTolerance: e,
yTolerance: a
yTolerance: s
});
if (s[0] !== s[1])
return s;
const [o] = await this.getRects({
if (a[0] !== a[1])
return a;
const [i] = await this.getRects({
pageIndex: r,
count: 1,
index: s[0]
index: a[0]
});
if (!o)
return s;
const [c, i, p, u] = o;
if (!(n + e >= c && n - e <= p && t + a >= i && t - a <= u))
return s;
const h = p - c;
return n - c > h / 2 ? s.map((l) => l + 1) : s;
if (!i)
return a;
const [c, o, g, u] = i;
if (!(n + e >= c && n - e <= g && t + s >= o && t - s <= u))
return a;
const h = g - c;
return n - c > h / 2 ? a.map((l) => l + 1) : a;
}
function $(n) {
function D(n) {
this.app = n;
}
function D(n) {
function F(n) {
this.app = n;
}
class F {
class G {
name = "selectText";
charCount = {};
/**

@@ -189,3 +213,3 @@ * @deprecated

async getExactIndexAtPoint(t, r, e) {
return m.call(this, t, r, e);
return I.call(this, t, r, e);
}

@@ -208,12 +232,12 @@ // async getCharRects(charIndex: number, pageIndex: number): Promise<OutlineType> {

convertToPDFPoint(t, r, e) {
return I.call(this, t, r, e);
return m.call(this, t, r, e);
}
convertToPdfRectangle(t, r) {
return R.call(this, t, r);
return w.call(this, t, r);
}
async getTextInRect(t, r) {
return P.call(this, t, r);
return R.call(this, t, r);
}
async getTextAtPoint(t, r, e, a) {
return w.call(this, t, r, e, a);
async getTextAtPoint(t, r, e, s) {
return P.call(this, t, r, e, s);
}

@@ -224,3 +248,3 @@ async getCharRangeInRect(t) {

async getCountChars(t) {
return E.call(this, t);
return k.call(this, t);
}

@@ -231,3 +255,3 @@ async getText(t) {

async getRects(t) {
return k.call(this, t);
return E.call(this, t);
}

@@ -255,5 +279,8 @@ async getExpandSentence(t) {

}
async getExactIndexNearPoint(t, r, e, a = 10, s = 10) {
return L.call(this, t, r, e, a, s);
async getNearPointExactIndexes(t, r, e, s = 10, a = 10) {
return L.call(this, t, r, e, s, a);
}
async getExactIndexNearPoint(t, r, e, s = 10, a = 10) {
return $.call(this, t, r, e, s, a);
}
// async getCharOutline() {

@@ -270,10 +297,10 @@ // const charCount = await this.pdfPage.getCharCount();

onAppCreated(t) {
return $.call(this, t);
return D.call(this, t);
}
install(t) {
return D.call(this, t);
return F.call(this, t);
}
}
export {
F as default
G as default
};

@@ -18,2 +18,3 @@ import type { PDFPageView } from 'pdfjs/types/web/pdf_page_view';

constructor(getTextBlocks?: any);
readonly isOcr = true;
insertTextBlocks(pageIndex: number, texts: TextBlock[]): Promise<void>;

@@ -40,3 +41,3 @@ getTextAtPoint(x: number, y: number, pageIndex: number, viewport: any): Promise<string>;

getTextInRect(rect: number[], pageIndex: number): Promise<string>;
getCountChars(pageIndex: number): Promise<number>;
getCountChars(pageIndex: number): number;
getText(data: {

@@ -84,2 +85,3 @@ pageIndex: number;

}): Promise<number[]>;
getNearPointExactIndexes(pageNumber: number, x: number, y: number, xTolerance?: number, yTolerance?: number): Promise<number[]>;
getTextInRectWithoutLineBreak(data: {

@@ -86,0 +88,0 @@ pageIndex: number;

@@ -7,2 +7,5 @@ import type { PDFPageView } from 'pdfjs/types/web/pdf_page_view';

app: DocumentViewer;
charCount: {
[key: number]: number;
};
/**

@@ -71,2 +74,3 @@ * @deprecated

}): Promise<any>;
getNearPointExactIndexes(pageNumber: number, x: number, y: number, xTolerance?: number, yTolerance?: number): Promise<any>;
getExactIndexNearPoint(x: number, y: number, pageIndex: number, xTolerance?: number, yTolerance?: number): Promise<any>;

@@ -73,0 +77,0 @@ onAppCreated(app: DocumentViewer): void;

@@ -27,3 +27,2 @@ import type { Cell, SpanCellData } from '../../../../types/widget';

mousemove(evt: Event): void;
get viewingCellData(): Cell[];
get cellData(): Cell[];

@@ -56,2 +55,3 @@ get startCell(): Cell | undefined;

selectCell(x: number, y: number): void;
rotateCell(cell: Cell, rotation?: number): number[];
updateCell(): void;

@@ -58,0 +58,0 @@ clean(): void;

@@ -14,2 +14,3 @@ import { AnnotationEditorLayer, FreeTextEditor, StampEditor } from 'pdfjs/web/component_viewer';

import DataFactory from '../annotation-data-factory/DataFactory';
import { PolylineEditor } from './polyline';
import { TextEditor } from './text';

@@ -56,3 +57,3 @@ import { UnderlineEditor } from './underline';

};
static _editorTypes: Map<number, typeof SquareEditor | typeof TableEditor | typeof LineEditor | typeof TextEditor | typeof UnderlineEditor | typeof PopupEditor | typeof InkEditor | typeof FreeTextEditor | typeof StampEditor | typeof HighlightEditor>;
static _editorTypes: Map<number, typeof SquareEditor | typeof TableEditor | typeof LineEditor | typeof PolylineEditor | typeof TextEditor | typeof UnderlineEditor | typeof PopupEditor | typeof InkEditor | typeof FreeTextEditor | typeof StampEditor | typeof HighlightEditor>;
constructor(options: any);

@@ -65,3 +66,3 @@ createAnnotDatas: (annotType: Subtype | string, rect: number[]) => import("../annotation-data-factory/BaseData").default | null;

get originalViewport(): import("pdfjs/types/src/display/display_utils").PageViewport;
get _currentEditorType(): typeof SquareEditor | typeof TableEditor | typeof LineEditor | typeof TextEditor | typeof UnderlineEditor | typeof PopupEditor | typeof InkEditor | typeof FreeTextEditor | typeof StampEditor | typeof HighlightEditor;
get _currentEditorType(): typeof SquareEditor | typeof TableEditor | typeof LineEditor | typeof PolylineEditor | typeof TextEditor | typeof UnderlineEditor | typeof PopupEditor | typeof InkEditor | typeof FreeTextEditor | typeof StampEditor | typeof HighlightEditor;
get isEmpty(): boolean;

@@ -68,0 +69,0 @@ /**

@@ -60,2 +60,3 @@ import { AnnotationEditor, Outliner } from 'pdfjs/web/component_viewer';

get viewHeight(): number;
get isSelected(): any;
getPageClientDimensions(): any;

@@ -100,4 +101,6 @@ getPageView(): any;

addEditToolbar(): Promise<any>;
removeCtrlBar(): void;
emitUpdate(): void;
drag(tx: number, ty: number): void;
startDrawing(x: number, y: number): void;
drawing(x: number, y: number, tx?: number, ty?: number): void;

@@ -104,0 +107,0 @@ dragEnd(): void;

@@ -38,2 +38,3 @@ import { OutlineType } from '../../../types/widget';

get direction(): number;
get selectTextService(): any;
get pageCharCount(): any;

@@ -40,0 +41,0 @@ constructor(parameters: EditorParams, config?: CustomAnnotConfig);

@@ -22,3 +22,2 @@ import { BaseAnnotationEditor } from './editor';

isEmpty(): boolean;
startDrawing(x: number, y: number): void;
drawing(x: number, y: number, tx?: number, ty?: number): void;

@@ -31,2 +30,4 @@ stopDrawing(x: number, y: number): void;

update(data: AnnotationData): void;
scale(): void;
rotate(): void;
drag(tx: number, ty: number): void;

@@ -33,0 +34,0 @@ drawInk(inkLists: Array<InkData>): void;

@@ -17,9 +17,13 @@ import { BaseAnnotationEditor } from './editor';

private _observer;
resizable: boolean;
get isResizable(): boolean;
resizer: any;
getVertices(): {
x: number;
y: number;
}[];
static deserialize(parameters: AnnotationElementParameters, parent: CustomAnnotationEditorLayer, uiManager: CustomEditorUIManager, customConfig: CustomAnnotConfig): any;
constructor(parameters: EditorParams, config?: CustomAnnotConfig);
makeResizable(): void;
isEmpty(): boolean;
startDrawing(x: number, y: number): void;
drawing(x: number, y: number, tx?: number, ty?: number): void;
drawing(x: number, y: number): void;
_updateDims(): void;
stopDrawing(x: number, y: number): void;

@@ -30,4 +34,6 @@ enableEditMode(): void;

render(): HTMLDivElement | null;
resetOrigin(): void;
update(data: AnnotationData): void;
createObserver(): void;
drag(tx: number, ty: number): void;
scale(scale: number, oldScale: number): void;
drawLine(): void;

@@ -34,0 +40,0 @@ serialize(): {

@@ -5,3 +5,3 @@ import { BaseAnnotationEditor } from './editor';

import type { AnnotationElementParameters, AnnotationData, CustomAnnotConfig } from '../../../types/annotation';
interface Vertex {
export interface Vertex {
x: number;

@@ -17,13 +17,7 @@ y: number;

protected _polyEleFront: SVGPolylineElement | null;
protected _vertexEl: SVGGElement | null;
protected _origin: {
x: number;
y: number;
};
private _resizeIndex;
_boundPointerdown: (event: PointerEvent) => void;
_boundVertexPointermove: (event: PointerEvent) => void;
resizer: any;
static deserialize(parameters: AnnotationElementParameters, parent: CustomAnnotationEditorLayer, uiManager: CustomEditorUIManager, customConfig: CustomAnnotConfig): any;
get isResizable(): boolean;
getVertices(): Vertex[];
constructor(params: any, config: any);
makeResizable(): void;
isEmpty(): boolean;

@@ -33,3 +27,2 @@ enableEditMode(): void;

startDrawing(x: number, y: number): void;
_removeTempItems(): void;
drawing(x: number, y: number, tx?: number, ty?: number): void;

@@ -39,2 +32,4 @@ addVertex(x: number, y: number): void;

update(data: AnnotationData): void;
_updateDims(): void;
resetOrigin(): void;
drag(tx: number, ty: number): void;

@@ -48,10 +43,5 @@ _renderCanvas(): SVGSVGElement;

protected setPointsAttribute(points: [number, number][]): void;
_updateDims(): void;
drawPolyEle(): void;
drawVertices(): void;
_removeTempItems(): void;
stopDrawing(): void;
enableResizeByVertex(): void;
disableResizeByVertex(): void;
vertexPointerdown(event: PointerEvent): void;
vertexPointermove(event: PointerEvent): void;
serialize(): {

@@ -64,3 +54,3 @@ annotationType: number;

};
toData(): {
toData(convertToViewport?: boolean): {
rect: number[];

@@ -67,0 +57,0 @@ pageNumber: number;

@@ -31,3 +31,2 @@ import { Outliner } from 'pdfjs/web/component_viewer';

stopDrawing(x: number, y: number): void;
startDrawing(x: number, y: number): void;
drawHighlight(): void;

@@ -34,0 +33,0 @@ toggleBackground(): void;

@@ -27,3 +27,2 @@ import { BaseAnnotationEditor } from './editor';

lineWrapper: SVGGraphicsElement;
_handleMove: (event: MouseEvent) => void;
constructor(parameters: EditorParams, config?: CustomAnnotConfig);

@@ -51,9 +50,5 @@ get cellMinWidth(): number;

update(data: AnnotationData): void;
startDrawing(x: number, y: number): void;
stopDrawing(): void;
drawing(x: number, y: number, tx?: number, ty?: number): void;
redrawRowAndCol(): void;
enableDraw(): void;
disableDraw(): void;
handleMove(event: MouseEvent): void;
rotate(): void;

@@ -60,0 +55,0 @@ scale(): void;

@@ -12,4 +12,7 @@ import type { EditorParams } from '../../../types/editor';

get isResizable(): boolean;
get iconSize(): number[];
static deserialize(parameters: AnnotationElementParameters, parent: CustomAnnotationEditorLayer, uiManager: CustomEditorUIManager, customConfig: CustomAnnotConfig): any;
constructor(parameters: EditorParams, config?: CustomAnnotConfig);
isEmpty(): boolean;
get ctrlBarPoint(): number[] | null;
get outline(): OutlineType;

@@ -16,0 +19,0 @@ render(): HTMLDivElement | null;

@@ -6,2 +6,3 @@ import { AnnotationEditorUIManager } from 'pdfjs/web/component_viewer';

import { AnnotationType } from '../../../shared/constant';
import { TextSelection } from '../selection';
declare function bindEvents(obj: any, element: any, names: any): void;

@@ -61,2 +62,3 @@ interface UIManagerOptions {

drawingEditors: Set<HighlightEditor>;
willDrawingSelections: TextSelection[];
getMode: () => number;

@@ -90,2 +92,3 @@ disableUserSelect: (val: boolean) => void;

addDrawingEditor(editor: any): void;
addWillDrawingSelection(selection: TextSelection): void;
getPageNumberByEvent(event: MouseEvent): number | null;

@@ -95,2 +98,3 @@ isTriggeredInPage(event: MouseEvent): boolean;

getDrawingEditor(pageIndex: number): HighlightEditor | null;
getWillDrawingSelections(pageIndex: number): TextSelection[];
get needTriggerDrawingStart(): boolean;

@@ -97,0 +101,0 @@ clearDrawingEditors(): void;

import { OutlineType } from '../../types/widget';
import type SelectOcrTextService from '../../extensions/SelectOcrTextService';
import type SelectTextService from '../../extensions/SelectTextService';
declare class Point {

@@ -33,4 +35,4 @@ x: number;

get pageNumber(): any;
get pdfPage(): any;
get scale(): any;
get selectTextService(): SelectTextService | SelectOcrTextService;
constructor(anchor: number, head: number | undefined, parameters: any);

@@ -37,0 +39,0 @@ abstract getOutlines(): Promise<Array<number[]>>;

@@ -460,14 +460,6 @@ /// <reference path="../../../../src/types/editor.d.ts" />

* @param isByCenterPoint {Boolean} 是否通过矩形内的中心点获取字符box
* @param isTrim {Boolean} 是否过滤开头和结尾的空格字符
*/
getAllCharBoxInSquare(pageNumber: number, rect: number[], isByCenterPoint?: boolean): Promise<{
index: number;
char: any;
box: any;
}[]>;
getAllCharBoxInElement(elBlock: ParagraphElement | TableCellElement, isFormat?: boolean, isIgnoreHyphen?: boolean): Promise<{
pageNumber: number;
index: number;
char: any;
box: any;
}[]>;
getAllCharBoxInSquare(pageNumber: number, rect: number[], isByCenterPoint?: boolean, isTrim?: boolean): Promise<any[]>;
getAllCharBoxInElement(elBlock: ParagraphElement | TableCellElement, isFormat?: boolean, isIgnoreHyphen?: boolean): Promise<any[]>;
getElementBySelection(isFormatText?: boolean): Promise<any[]>;

@@ -474,0 +466,0 @@ getElementByRect(pageNumber: number, rect: number[]): Promise<any>;

@@ -1,2 +0,2 @@

import type { OutlineType, Point, SpanCellData } from '../types/widget';
import type { Cell, OutlineType, Point, SpanCellData } from '../types/widget';
import type { AnnotationDataExtended, AnnotState } from '../types/annotation';

@@ -21,2 +21,3 @@ import { AnnotationType } from './constant';

export declare function ptToPx(pt: number): number;
export declare function rotateCell(cell: Cell, rowCount: number, colCount: number, rotation: number): number[];
export declare function rotateSpanCellData(spanCellData: SpanCellData, rowCount: number, colCount: number, rotation: number): SpanCellData;

@@ -23,0 +24,0 @@ export declare function convertRect(outline: OutlineType, viewBox: number[]): OutlineType;

@@ -39,1 +39,2 @@ import type { Outline } from '../types/element';

export declare const getEnlargedRect: (rect: Outline, enlargePixel?: number) => Outline;
export declare const trimArray: (array: any[], prop: string) => any[];
{
"name": "@paodingai/pdflux-pdf-viewer",
"version": "0.11.0-beta.10",
"version": "0.11.0-beta.11",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/image-viewer.umd.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc