pdfjs-vue3 0.1.7 → 0.1.8
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/pdfjs-vue3.es.js +81 -69
- package/dist/pdfjs-vue3.umd.js +1 -1
- package/package.json +10 -10
- package/types/PdfHost.vue.d.ts +105 -233
- package/types/index.d.ts +3 -3
- package/types/types.d.ts +27 -27
package/dist/pdfjs-vue3.es.js
CHANGED
|
@@ -2,53 +2,56 @@ import { defineComponent as N, ref as P, watch as j, onMounted as L, openBlock a
|
|
|
2
2
|
import { renderTextLayer as ae, getDocument as le, GlobalWorkerOptions as se } from "pdfjs-dist";
|
|
3
3
|
var S = /* @__PURE__ */ ((e) => (e[e.Auto = 0] = "Auto", e[e.WidthFit = 1] = "WidthFit", e[e.PageFit = 2] = "PageFit", e[e.Custom = 3] = "Custom", e))(S || {}), I = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
4
4
|
function ue(e) {
|
|
5
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
6
|
+
}
|
|
7
|
+
function ce(e) {
|
|
5
8
|
var i = typeof e;
|
|
6
9
|
return e != null && (i == "object" || i == "function");
|
|
7
10
|
}
|
|
8
|
-
var te =
|
|
9
|
-
return
|
|
10
|
-
},
|
|
11
|
-
function
|
|
12
|
-
for (var i = e.length; i-- &&
|
|
11
|
+
var te = ce, de = typeof I == "object" && I && I.Object === Object && I, fe = de, pe = fe, me = typeof self == "object" && self && self.Object === Object && self, ve = pe || me || Function("return this")(), oe = ve, ge = oe, he = function() {
|
|
12
|
+
return ge.Date.now();
|
|
13
|
+
}, be = he, ye = /\s/;
|
|
14
|
+
function we(e) {
|
|
15
|
+
for (var i = e.length; i-- && ye.test(e.charAt(i)); )
|
|
13
16
|
;
|
|
14
17
|
return i;
|
|
15
18
|
}
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
return e && e.slice(0,
|
|
19
|
+
var Te = we, xe = Te, Pe = /^\s+/;
|
|
20
|
+
function _e(e) {
|
|
21
|
+
return e && e.slice(0, xe(e) + 1).replace(Pe, "");
|
|
19
22
|
}
|
|
20
|
-
var ze =
|
|
21
|
-
function
|
|
22
|
-
var i =
|
|
23
|
+
var ze = _e, Se = oe, $e = Se.Symbol, ne = $e, U = ne, re = Object.prototype, ke = re.hasOwnProperty, je = re.toString, C = U ? U.toStringTag : void 0;
|
|
24
|
+
function Ee(e) {
|
|
25
|
+
var i = ke.call(e, C), l = e[C];
|
|
23
26
|
try {
|
|
24
27
|
e[C] = void 0;
|
|
25
28
|
var n = !0;
|
|
26
29
|
} catch {
|
|
27
30
|
}
|
|
28
|
-
var s =
|
|
31
|
+
var s = je.call(e);
|
|
29
32
|
return n && (i ? e[C] = l : delete e[C]), s;
|
|
30
33
|
}
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
+
var Oe = Ee, Ce = Object.prototype, Me = Ce.toString;
|
|
35
|
+
function Ie(e) {
|
|
36
|
+
return Me.call(e);
|
|
34
37
|
}
|
|
35
|
-
var
|
|
36
|
-
function
|
|
37
|
-
return e == null ? e === void 0 ?
|
|
38
|
+
var Ne = Ie, K = ne, Le = Oe, We = Ne, Be = "[object Null]", Ve = "[object Undefined]", X = K ? K.toStringTag : void 0;
|
|
39
|
+
function De(e) {
|
|
40
|
+
return e == null ? e === void 0 ? Ve : Be : X && X in Object(e) ? Le(e) : We(e);
|
|
38
41
|
}
|
|
39
|
-
var
|
|
40
|
-
function
|
|
42
|
+
var Fe = De;
|
|
43
|
+
function Ae(e) {
|
|
41
44
|
return e != null && typeof e == "object";
|
|
42
45
|
}
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
-
return typeof e == "symbol" ||
|
|
46
|
+
var Ge = Ae, Re = Fe, He = Ge, Ue = "[object Symbol]";
|
|
47
|
+
function Ke(e) {
|
|
48
|
+
return typeof e == "symbol" || He(e) && Re(e) == Ue;
|
|
46
49
|
}
|
|
47
|
-
var
|
|
48
|
-
function
|
|
50
|
+
var Xe = Ke, Ye = ze, Y = te, qe = Xe, q = 0 / 0, Je = /^[-+]0x[0-9a-f]+$/i, Qe = /^0b[01]+$/i, Ze = /^0o[0-7]+$/i, et = parseInt;
|
|
51
|
+
function tt(e) {
|
|
49
52
|
if (typeof e == "number")
|
|
50
53
|
return e;
|
|
51
|
-
if (
|
|
54
|
+
if (qe(e))
|
|
52
55
|
return q;
|
|
53
56
|
if (Y(e)) {
|
|
54
57
|
var i = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
@@ -56,30 +59,30 @@ function et(e) {
|
|
|
56
59
|
}
|
|
57
60
|
if (typeof e != "string")
|
|
58
61
|
return e === 0 ? e : +e;
|
|
59
|
-
e =
|
|
60
|
-
var l =
|
|
61
|
-
return l ||
|
|
62
|
+
e = Ye(e);
|
|
63
|
+
var l = Qe.test(e);
|
|
64
|
+
return l || Ze.test(e) ? et(e.slice(2), l ? 2 : 8) : Je.test(e) ? q : +e;
|
|
62
65
|
}
|
|
63
|
-
var
|
|
64
|
-
function
|
|
66
|
+
var ot = tt, nt = te, V = be, J = ot, rt = "Expected a function", it = Math.max, at = Math.min;
|
|
67
|
+
function lt(e, i, l) {
|
|
65
68
|
var n, s, b, g, d, u, y = 0, T = !1, w = !1, o = !0;
|
|
66
69
|
if (typeof e != "function")
|
|
67
|
-
throw new TypeError(
|
|
68
|
-
i = J(i) || 0,
|
|
70
|
+
throw new TypeError(rt);
|
|
71
|
+
i = J(i) || 0, nt(l) && (T = !!l.leading, w = "maxWait" in l, b = w ? it(J(l.maxWait) || 0, i) : b, o = "trailing" in l ? !!l.trailing : o);
|
|
69
72
|
function c(v) {
|
|
70
|
-
var
|
|
71
|
-
return n = s = void 0, y = v, g = e.apply(O,
|
|
73
|
+
var z = n, O = s;
|
|
74
|
+
return n = s = void 0, y = v, g = e.apply(O, z), g;
|
|
72
75
|
}
|
|
73
76
|
function f(v) {
|
|
74
77
|
return y = v, d = setTimeout(t, i), T ? c(v) : g;
|
|
75
78
|
}
|
|
76
79
|
function a(v) {
|
|
77
|
-
var
|
|
78
|
-
return w ?
|
|
80
|
+
var z = v - u, O = v - y, H = i - z;
|
|
81
|
+
return w ? at(H, b - O) : H;
|
|
79
82
|
}
|
|
80
83
|
function h(v) {
|
|
81
|
-
var
|
|
82
|
-
return u === void 0 ||
|
|
84
|
+
var z = v - u, O = v - y;
|
|
85
|
+
return u === void 0 || z >= i || z < 0 || w && O >= b;
|
|
83
86
|
}
|
|
84
87
|
function t() {
|
|
85
88
|
var v = V();
|
|
@@ -96,9 +99,9 @@ function at(e, i, l) {
|
|
|
96
99
|
function m() {
|
|
97
100
|
return d === void 0 ? g : r(V());
|
|
98
101
|
}
|
|
99
|
-
function
|
|
100
|
-
var v = V(),
|
|
101
|
-
if (n = arguments, s = this, u = v,
|
|
102
|
+
function _() {
|
|
103
|
+
var v = V(), z = h(v);
|
|
104
|
+
if (n = arguments, s = this, u = v, z) {
|
|
102
105
|
if (d === void 0)
|
|
103
106
|
return f(u);
|
|
104
107
|
if (w)
|
|
@@ -106,10 +109,10 @@ function at(e, i, l) {
|
|
|
106
109
|
}
|
|
107
110
|
return d === void 0 && (d = setTimeout(t, i)), g;
|
|
108
111
|
}
|
|
109
|
-
return
|
|
112
|
+
return _.cancel = p, _.flush = m, _;
|
|
110
113
|
}
|
|
111
|
-
var
|
|
112
|
-
const
|
|
114
|
+
var st = lt;
|
|
115
|
+
const A = /* @__PURE__ */ ue(st), ut = /* @__PURE__ */ N({
|
|
113
116
|
__name: "PdfPageText",
|
|
114
117
|
props: {
|
|
115
118
|
viewport: null,
|
|
@@ -133,9 +136,10 @@ const lt = /* @__PURE__ */ N({
|
|
|
133
136
|
for (; g.firstChild; )
|
|
134
137
|
g.removeChild(g.firstChild);
|
|
135
138
|
s = ae({
|
|
136
|
-
|
|
139
|
+
textContentSource: d,
|
|
137
140
|
container: g,
|
|
138
141
|
viewport: u
|
|
142
|
+
// enhanceTextSelection: true
|
|
139
143
|
}), s.promise.then(() => {
|
|
140
144
|
s = void 0;
|
|
141
145
|
}).catch(() => {
|
|
@@ -153,10 +157,10 @@ const lt = /* @__PURE__ */ N({
|
|
|
153
157
|
}, null, 512));
|
|
154
158
|
}
|
|
155
159
|
});
|
|
156
|
-
const
|
|
160
|
+
const ct = { class: "pdf-page-layout" }, dt = { class: "pdf-page-overlay" }, ft = {
|
|
157
161
|
key: 0,
|
|
158
162
|
class: "pdf-page-number"
|
|
159
|
-
},
|
|
163
|
+
}, pt = /* @__PURE__ */ N({
|
|
160
164
|
__name: "PdfPage",
|
|
161
165
|
props: {
|
|
162
166
|
zoom: null,
|
|
@@ -223,13 +227,13 @@ const st = { class: "pdf-page-layout" }, ut = { class: "pdf-page-overlay" }, ct
|
|
|
223
227
|
ref: b,
|
|
224
228
|
class: "pdf-page"
|
|
225
229
|
}, [
|
|
226
|
-
W("div",
|
|
230
|
+
W("div", ct, [
|
|
227
231
|
W("canvas", {
|
|
228
232
|
ref_key: "canvas",
|
|
229
233
|
ref: s
|
|
230
234
|
}, null, 512),
|
|
231
|
-
W("div",
|
|
232
|
-
e.hideText ? D("", !0) : (x(), R(
|
|
235
|
+
W("div", dt, [
|
|
236
|
+
e.hideText ? D("", !0) : (x(), R(ut, {
|
|
233
237
|
key: 0,
|
|
234
238
|
viewport: k(o),
|
|
235
239
|
page: e.page
|
|
@@ -237,14 +241,14 @@ const st = { class: "pdf-page-layout" }, ut = { class: "pdf-page-overlay" }, ct
|
|
|
237
241
|
E(a.$slots, "default", { displaySize: k(o) })
|
|
238
242
|
])
|
|
239
243
|
]),
|
|
240
|
-
e.hideNumber ? D("", !0) : (x(), $("div",
|
|
244
|
+
e.hideNumber ? D("", !0) : (x(), $("div", ft, Q(e.page.pageNumber), 1))
|
|
241
245
|
], 512));
|
|
242
246
|
}
|
|
243
247
|
});
|
|
244
|
-
const
|
|
248
|
+
const mt = {
|
|
245
249
|
key: 0,
|
|
246
250
|
class: "pdf-progress"
|
|
247
|
-
},
|
|
251
|
+
}, vt = /* @__PURE__ */ N({
|
|
248
252
|
__name: "PdfDocument",
|
|
249
253
|
props: {
|
|
250
254
|
hideText: { type: Boolean },
|
|
@@ -293,6 +297,7 @@ const ft = {
|
|
|
293
297
|
f && (f.inViewport = c.isIntersecting);
|
|
294
298
|
});
|
|
295
299
|
}, 50), {
|
|
300
|
+
// root: rootEl.value,
|
|
296
301
|
rootMargin: "0px"
|
|
297
302
|
});
|
|
298
303
|
}), G(() => {
|
|
@@ -307,9 +312,9 @@ const ft = {
|
|
|
307
312
|
loading: u.value,
|
|
308
313
|
progress: y.value
|
|
309
314
|
}, () => [
|
|
310
|
-
u.value ? (x(), $("p",
|
|
315
|
+
u.value ? (x(), $("p", mt, "loading " + Q(Math.ceil(100 * y.value)) + "%", 1)) : D("", !0)
|
|
311
316
|
]),
|
|
312
|
-
(x(!0), $(Z, null, ee(k(s), (f) => (x(), R(
|
|
317
|
+
(x(!0), $(Z, null, ee(k(s), (f) => (x(), R(pt, {
|
|
313
318
|
ref_for: !0,
|
|
314
319
|
ref: T,
|
|
315
320
|
key: f.pageNumber,
|
|
@@ -334,7 +339,7 @@ const ft = {
|
|
|
334
339
|
], 512));
|
|
335
340
|
}
|
|
336
341
|
});
|
|
337
|
-
const
|
|
342
|
+
const bt = /* @__PURE__ */ N({
|
|
338
343
|
__name: "PdfHost",
|
|
339
344
|
props: {
|
|
340
345
|
workerSrc: null,
|
|
@@ -349,7 +354,13 @@ const gt = /* @__PURE__ */ N({
|
|
|
349
354
|
setup(e, { expose: i, emit: l }) {
|
|
350
355
|
const n = e, s = P();
|
|
351
356
|
i({
|
|
357
|
+
/**
|
|
358
|
+
* Try to increase zoom to the next level, up to 200%.
|
|
359
|
+
*/
|
|
352
360
|
zoomIn: T,
|
|
361
|
+
/**
|
|
362
|
+
* Try to decrease zoom to the next level, down to 25%.
|
|
363
|
+
*/
|
|
353
364
|
zoomOut: w
|
|
354
365
|
}), j(() => n.workerSrc, (t) => {
|
|
355
366
|
t && (se.workerSrc = t);
|
|
@@ -382,9 +393,9 @@ const gt = /* @__PURE__ */ N({
|
|
|
382
393
|
j(() => n.zoom, (t, r) => {
|
|
383
394
|
const p = s.value;
|
|
384
395
|
if (p && t && r) {
|
|
385
|
-
const m = p.scrollTop,
|
|
396
|
+
const m = p.scrollTop, _ = p.scrollLeft, v = t / r;
|
|
386
397
|
ie(() => {
|
|
387
|
-
p.scrollTop = m * v, p.scrollLeft =
|
|
398
|
+
p.scrollTop = m * v, p.scrollLeft = _ * v;
|
|
388
399
|
});
|
|
389
400
|
}
|
|
390
401
|
}), L(() => {
|
|
@@ -395,10 +406,10 @@ const gt = /* @__PURE__ */ N({
|
|
|
395
406
|
const o = [];
|
|
396
407
|
let c = -1;
|
|
397
408
|
function f(t) {
|
|
398
|
-
|
|
409
|
+
n.enablePinchZoom && o.push(t);
|
|
399
410
|
}
|
|
400
411
|
const a = A((t) => {
|
|
401
|
-
if (
|
|
412
|
+
if (n.enablePinchZoom) {
|
|
402
413
|
for (let r = 0; r < o.length; r++)
|
|
403
414
|
if (t.pointerId === o[r].pointerId) {
|
|
404
415
|
o[r] = t;
|
|
@@ -411,7 +422,7 @@ const gt = /* @__PURE__ */ N({
|
|
|
411
422
|
}
|
|
412
423
|
}, 10);
|
|
413
424
|
function h(t) {
|
|
414
|
-
if (
|
|
425
|
+
if (n.enablePinchZoom) {
|
|
415
426
|
for (let r = 0; r < o.length; r++)
|
|
416
427
|
if (o[r].pointerId === t.pointerId) {
|
|
417
428
|
o.splice(r, 1);
|
|
@@ -426,7 +437,8 @@ const gt = /* @__PURE__ */ N({
|
|
|
426
437
|
onWheel: b,
|
|
427
438
|
onKeydown: g,
|
|
428
439
|
onPointerdown: f,
|
|
429
|
-
onPointermove: r[1] || (r[1] =
|
|
440
|
+
onPointermove: r[1] || (r[1] = //@ts-ignore
|
|
441
|
+
(...p) => k(a) && k(a)(...p)),
|
|
430
442
|
onPointerup: h,
|
|
431
443
|
onPointercancel: h,
|
|
432
444
|
onPointerleave: h,
|
|
@@ -434,7 +446,7 @@ const gt = /* @__PURE__ */ N({
|
|
|
434
446
|
tabindex: "0",
|
|
435
447
|
class: "pdf-host"
|
|
436
448
|
}, [
|
|
437
|
-
(x(!0), $(Z, null, ee(e.sources, (p) => (x(), R(
|
|
449
|
+
(x(!0), $(Z, null, ee(e.sources, (p) => (x(), R(vt, {
|
|
438
450
|
viewport: d.value,
|
|
439
451
|
src: p,
|
|
440
452
|
"hide-number": !!e.hideNumber,
|
|
@@ -443,18 +455,18 @@ const gt = /* @__PURE__ */ N({
|
|
|
443
455
|
zoom: e.zoom || 1,
|
|
444
456
|
"onUpdate:zoom": r[0] || (r[0] = (m) => l("update:zoom", m))
|
|
445
457
|
}, {
|
|
446
|
-
loading: F(({ loading: m, progress:
|
|
458
|
+
loading: F(({ loading: m, progress: _ }) => [
|
|
447
459
|
E(t.$slots, "loading", {
|
|
448
460
|
source: p,
|
|
449
461
|
loading: m,
|
|
450
|
-
progress:
|
|
462
|
+
progress: _
|
|
451
463
|
})
|
|
452
464
|
]),
|
|
453
|
-
default: F(({ doc: m, page:
|
|
465
|
+
default: F(({ doc: m, page: _, displaySize: v }) => [
|
|
454
466
|
E(t.$slots, "page", {
|
|
455
467
|
source: p,
|
|
456
468
|
doc: m,
|
|
457
|
-
page:
|
|
469
|
+
page: _,
|
|
458
470
|
displaySize: v
|
|
459
471
|
})
|
|
460
472
|
]),
|
|
@@ -465,6 +477,6 @@ const gt = /* @__PURE__ */ N({
|
|
|
465
477
|
}
|
|
466
478
|
});
|
|
467
479
|
export {
|
|
468
|
-
|
|
480
|
+
bt as PdfHost,
|
|
469
481
|
S as ZoomType
|
|
470
482
|
};
|
package/dist/pdfjs-vue3.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pdfjs-dist")):typeof define=="function"&&define.amd?define(["exports","vue","pdfjs-dist"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.pdfjsVue3={},k.Vue,k.pdfjsLib))})(this,function(k,e,$){"use strict";var P=(t=>(t[t.Auto=0]="Auto",t[t.WidthFit=1]="WidthFit",t[t.PageFit=2]="PageFit",t[t.Custom=3]="Custom",t))(P||{}),B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function G(t){var a=typeof t;return t!=null&&(a=="object"||a=="function")}var M=G,U=typeof B=="object"&&B&&B.Object===Object&&B,H=U,q=H,K=typeof self=="object"&&self&&self.Object===Object&&self,X=q||K||Function("return this")(),O=X,Y=O,J=function(){return Y.Date.now()},Q=J,Z=/\s/;function ee(t){for(var a=t.length;a--&&Z.test(t.charAt(a)););return a}var te=ee,oe=te,ne=/^\s+/;function re(t){return t&&t.slice(0,oe(t)+1).replace(ne,"")}var ie=re,ae=O,le=ae.Symbol,N=le,I=N,V=Object.prototype,ce=V.hasOwnProperty,se=V.toString,S=I?I.toStringTag:void 0;function de(t){var a=ce.call(t,S),c=t[S];try{t[S]=void 0;var r=!0}catch{}var s=se.call(t);return r&&(a?t[S]=c:delete t[S]),s}var fe=de,ue=Object.prototype,pe=ue.toString;function me(t){return pe.call(t)}var he=me,L=N,ge=fe,be=he,ye="[object Null]",we="[object Undefined]",W=L?L.toStringTag:void 0;function ve(t){return t==null?t===void 0?we:ye:W&&W in Object(t)?ge(t):be(t)}var Te=ve;function xe(t){return t!=null&&typeof t=="object"}var ke=xe,Pe=Te,_e=ke,ze="[object Symbol]";function Se(t){return typeof t=="symbol"||_e(t)&&Pe(t)==ze}var Ee=Se,Be=ie,F=M,$e=Ee,A=0/0,je=/^[-+]0x[0-9a-f]+$/i,Ce=/^0b[01]+$/i,Me=/^0o[0-7]+$/i,Oe=parseInt;function Ne(t){if(typeof t=="number")return t;if($e(t))return A;if(F(t)){var a=typeof t.valueOf=="function"?t.valueOf():t;t=F(a)?a+"":a}if(typeof t!="string")return t===0?t:+t;t=Be(t);var c=Ce.test(t);return c||Me.test(t)?Oe(t.slice(2),c?2:8):je.test(t)?A:+t}var Ie=Ne,Ve=M,j=Q,D=Ie,Le="Expected a function",We=Math.max,Fe=Math.min;function Ae(t,a,c){var r,s,w,b,u,d,v=0,x=!1,T=!1,n=!0;if(typeof t!="function")throw new TypeError(Le);a=D(a)||0,Ve(c)&&(x=!!c.leading,T="maxWait"in c,w=T?We(D(c.maxWait)||0,a):w,n="trailing"in c?!!c.trailing:n);function f(g){var z=r,E=s;return r=s=void 0,v=g,b=t.apply(E,z),b}function p(g){return v=g,u=setTimeout(o,a),x?f(g):b}function l(g){var z=g-d,E=g-v,R=a-z;return T?Fe(R,w-E):R}function y(g){var z=g-d,E=g-v;return d===void 0||z>=a||z<0||T&&E>=w}function o(){var g=j();if(y(g))return i(g);u=setTimeout(o,l(g))}function i(g){return u=void 0,n&&r?f(g):(r=s=void 0,b)}function m(){u!==void 0&&clearTimeout(u),v=0,r=d=s=u=void 0}function h(){return u===void 0?b:i(j())}function _(){var g=j(),z=y(g);if(r=arguments,s=this,d=g,z){if(u===void 0)return p(d);if(T)return clearTimeout(u),u=setTimeout(o,a),f(d)}return u===void 0&&(u=setTimeout(o,a)),b}return _.cancel=m,_.flush=h,_}var C=Ae;const De=e.defineComponent({__name:"PdfPageText",props:{viewport:null,page:null},setup(t){const a=t,c=e.ref(),r=e.ref();e.watch(()=>a.page,async b=>{c.value=await b.getTextContent()},{immediate:!0}),e.watch(()=>[c.value,r.value,a.viewport],()=>{w()});let s;function w(){const b=r.value,u=c.value,d=a.viewport;if(!(!b||!u||!d)){if(s){s.cancel();return}for(;b.firstChild;)b.removeChild(b.firstChild);s=$.renderTextLayer({textContent:c.value,container:b,viewport:d}),s.promise.then(()=>{s=void 0}).catch(()=>{s=void 0}).finally(()=>{})}}return e.onMounted(()=>{w()}),(b,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:r,class:"pdf-text-layer"},null,512))}}),Ye="",Re={class:"pdf-page-layout"},Ge={class:"pdf-page-overlay"},Ue={key:0,class:"pdf-page-number"},He=e.defineComponent({__name:"PdfPage",props:{zoom:null,zoomType:null,hideText:{type:Boolean},hideNumber:{type:Boolean},viewport:null,page:null,observer:null},emits:["update:zoom"],setup(t,{expose:a,emit:c}){const r=t,s=e.ref(),w=e.ref(),b=e.ref(!1),u=1100;a({rootEl:w,inViewport:b});const d=96/72,v=e.computed(()=>{const{width:l,height:y}=r.page.getViewport({scale:d}),{width:o,height:i}=r.viewport;let m=0,h=1;switch(r.zoomType){case P.Auto:return m=Math.min(o,u)-40,h=m/l,d*h;case P.WidthFit:return m=o-40,h=m/l,d*h;case P.PageFit:return o>i?(h=i/y,d*h):(m=o-40,h=m/l,d*h)}return d*r.zoom}),x=e.computed(()=>v.value*((window==null?void 0:window.devicePixelRatio)||1)),T=e.computed(()=>r.page.getViewport({scale:v.value})),n=e.computed(()=>r.page.getViewport({scale:x.value}));e.watch(v,l=>{const y=l/d;Math.abs(y-r.zoom)>.05&&c("update:zoom",y)},{immediate:!0});let f;function p(){if(!r.page||!s.value)return;const l=r.page,y=T.value,o=n.value,i=s.value;i.width=Math.ceil(o.width),i.height=Math.ceil(o.height),i.style.width=Math.floor(y.width)+"px",i.style.height=Math.floor(y.height)+"px";const m=i.getContext("2d");if(!m||!b.value)return;if(f){f.cancel();return}console.debug(`rendering page ${l.pageNumber}`);const h={canvasContext:m,viewport:n.value};f=l.render(h),f.promise.then(()=>f=void 0).catch(()=>{f=void 0,p()})}return e.watch(()=>[r.page,x.value,b.value],()=>{p()},{immediate:!0}),e.onMounted(()=>{var l;p(),w.value&&((l=r.observer)==null||l.observe(w.value))}),e.onBeforeUnmount(()=>{var l;w.value&&((l=r.observer)==null||l.unobserve(w.value))}),(l,y)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:w,class:"pdf-page"},[e.createElementVNode("div",Re,[e.createElementVNode("canvas",{ref_key:"canvas",ref:s},null,512),e.createElementVNode("div",Ge,[t.hideText?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(De,{key:0,viewport:e.unref(n),page:t.page},null,8,["viewport","page"])),e.renderSlot(l.$slots,"default",{displaySize:e.unref(n)})])]),t.hideNumber?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ue,e.toDisplayString(t.page.pageNumber),1))],512))}}),Je="",qe={key:0,class:"pdf-progress"},Ke=e.defineComponent({__name:"PdfDocument",props:{hideText:{type:Boolean},hideNumber:{type:Boolean},zoomType:null,zoom:null,viewport:null,src:null},emits:["error","update:zoom"],setup(t,{emit:a}){const c=t,r=e.shallowRef(),s=e.shallowRef([]),w=e.shallowRef(),b=e.ref();let u=[];const d=e.ref(!1),v=e.ref(0);function x(n){n&&(u.push(n),u.length==1&&(n.inViewport=!0))}function T(){s.value.forEach(f=>f.cleanup()),s.value=[];const n=r.value;n&&(n.destroy(),r.value=void 0),u=[]}return e.watch(()=>c.src,n=>{if(T(),!n)return;const f=$.getDocument(n);d.value=!0,f.onProgress=p=>{p.total&&(v.value=p.loaded/p.total)},f.promise.then(p=>{r.value=p;const l=[];for(let y=1;y<=p.numPages;y++)l.push(p.getPage(y));Promise.all(l).then(y=>{p===r.value&&(s.value=y)})}).catch(p=>{a("error",p)}).finally(()=>{d.value=!1})},{immediate:!0}),e.onMounted(()=>{w.value=new IntersectionObserver(C(n=>{n.forEach(f=>{const p=u.find(l=>(l==null?void 0:l.rootEl)===f.target);p&&(p.inViewport=f.isIntersecting)})},50),{rootMargin:"0px"})}),e.onBeforeUnmount(()=>{var n;T(),(n=w.value)==null||n.disconnect()}),(n,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:b},[e.renderSlot(n.$slots,"loading",{src:c.src,loading:d.value,progress:v.value},()=>[d.value?(e.openBlock(),e.createElementBlock("p",qe,"loading "+e.toDisplayString(Math.ceil(100*v.value))+"%",1)):e.createCommentVNode("",!0)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),p=>(e.openBlock(),e.createBlock(He,{ref_for:!0,ref:x,key:p.pageNumber,page:p,"hide-number":t.hideNumber,"hide-text":t.hideText,"zoom-type":t.zoomType,zoom:t.zoom,"onUpdate:zoom":f[0]||(f[0]=l=>a("update:zoom",l)),observer:e.unref(w),viewport:t.viewport},{default:e.withCtx(({displaySize:l})=>[e.renderSlot(n.$slots,"default",{doc:e.unref(r),page:p,displaySize:l})]),_:2},1032,["page","hide-number","hide-text","zoom-type","zoom","observer","viewport"]))),128))],512))}}),Qe="",Xe=e.defineComponent({__name:"PdfHost",props:{workerSrc:null,sources:null,zoomType:null,zoom:null,hideText:{type:Boolean},hideNumber:{type:Boolean},enablePinchZoom:{type:Boolean}},emits:["update:zoom","update:zoomType"],setup(t,{expose:a,emit:c}){const r=t,s=e.ref();a({zoomIn:x,zoomOut:T}),e.watch(()=>r.workerSrc,o=>{o&&($.GlobalWorkerOptions.workerSrc=o)},{immediate:!0});function w(o){o.ctrlKey&&(o.preventDefault(),o.deltaY<0?x():T())}function b(o){o.ctrlKey&&(o.key==="0"||o.which==48)&&c("update:zoomType",P.Auto)}const u=e.ref({width:0,height:0}),d=C(()=>{const o=s.value;o&&(u.value={width:o.offsetWidth,height:o.offsetHeight})},100);function v(o){const i=o%.25;return Number((o-i).toFixed(2))}function x(){const o=v((r.zoom||1)+.25);c("update:zoom",Math.min(o,2)),c("update:zoomType",P.Custom)}function T(){const o=v((r.zoom||1)-.25);c("update:zoom",Math.max(o,.25)),c("update:zoomType",P.Custom)}e.watch(()=>r.zoom,(o,i)=>{const m=s.value;if(m&&o&&i){const h=m.scrollTop,_=m.scrollLeft,g=o/i;e.nextTick(()=>{m.scrollTop=h*g,m.scrollLeft=_*g})}}),e.onMounted(()=>{window.addEventListener("resize",d),d()}),e.onBeforeUnmount(()=>{window.removeEventListener("resize",d)});const n=[];let f=-1;function p(o){!r.enablePinchZoom||n.push(o)}const l=C(o=>{if(!!r.enablePinchZoom){for(let i=0;i<n.length;i++)if(o.pointerId===n[i].pointerId){n[i]=o;break}if(n.length===2){const i=Math.abs(n[0].clientX-n[1].clientX),m=Math.abs(n[0].clientY-n[1].clientY),h=Math.sqrt(Math.pow(i,2)+Math.pow(m,2));f>0&&(h>f&&x(),h<f&&T()),f=h}}},10);function y(o){if(!!r.enablePinchZoom){for(let i=0;i<n.length;i++)if(n[i].pointerId===o.pointerId){n.splice(i,1);break}n.length<2&&(f=-1)}}return(o,i)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:s,onWheel:w,onKeydown:b,onPointerdown:p,onPointermove:i[1]||(i[1]=(...m)=>e.unref(l)&&e.unref(l)(...m)),onPointerup:y,onPointercancel:y,onPointerleave:y,onPointerout:y,tabindex:"0",class:"pdf-host"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.sources,m=>(e.openBlock(),e.createBlock(Ke,{viewport:u.value,src:m,"hide-number":!!t.hideNumber,"hide-text":!!t.hideText,"zoom-type":t.zoomType||e.unref(P).Auto,zoom:t.zoom||1,"onUpdate:zoom":i[0]||(i[0]=h=>c("update:zoom",h))},{loading:e.withCtx(({loading:h,progress:_})=>[e.renderSlot(o.$slots,"loading",{source:m,loading:h,progress:_})]),default:e.withCtx(({doc:h,page:_,displaySize:g})=>[e.renderSlot(o.$slots,"page",{source:m,doc:h,page:_,displaySize:g})]),_:2},1032,["viewport","src","hide-number","hide-text","zoom-type","zoom"]))),256)),e.renderSlot(o.$slots,"default")],544))}}),Ze="";k.PdfHost=Xe,k.ZoomType=P,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(x,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pdfjs-dist")):typeof define=="function"&&define.amd?define(["exports","vue","pdfjs-dist"],t):(x=typeof globalThis<"u"?globalThis:x||self,t(x.pdfjsVue3={},x.Vue,x.pdfjsLib))})(this,function(x,t,$){"use strict";var P=(e=>(e[e.Auto=0]="Auto",e[e.WidthFit=1]="WidthFit",e[e.PageFit=2]="PageFit",e[e.Custom=3]="Custom",e))(P||{}),B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function G(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function U(e){var a=typeof e;return e!=null&&(a=="object"||a=="function")}var O=U,H=typeof B=="object"&&B&&B.Object===Object&&B,q=H,K=q,X=typeof self=="object"&&self&&self.Object===Object&&self,Y=K||X||Function("return this")(),M=Y,J=M,Q=function(){return J.Date.now()},Z=Q,ee=/\s/;function te(e){for(var a=e.length;a--&&ee.test(e.charAt(a)););return a}var oe=te,ne=oe,re=/^\s+/;function ie(e){return e&&e.slice(0,ne(e)+1).replace(re,"")}var ae=ie,le=M,ce=le.Symbol,N=ce,I=N,V=Object.prototype,se=V.hasOwnProperty,de=V.toString,S=I?I.toStringTag:void 0;function fe(e){var a=se.call(e,S),c=e[S];try{e[S]=void 0;var r=!0}catch{}var s=de.call(e);return r&&(a?e[S]=c:delete e[S]),s}var ue=fe,pe=Object.prototype,me=pe.toString;function he(e){return me.call(e)}var ge=he,L=N,be=ue,ye=ge,we="[object Null]",ve="[object Undefined]",W=L?L.toStringTag:void 0;function Te(e){return e==null?e===void 0?ve:we:W&&W in Object(e)?be(e):ye(e)}var ke=Te;function xe(e){return e!=null&&typeof e=="object"}var Pe=xe,_e=ke,ze=Pe,Se="[object Symbol]";function Ee(e){return typeof e=="symbol"||ze(e)&&_e(e)==Se}var Be=Ee,$e=ae,F=O,je=Be,D=0/0,Ce=/^[-+]0x[0-9a-f]+$/i,Oe=/^0b[01]+$/i,Me=/^0o[0-7]+$/i,Ne=parseInt;function Ie(e){if(typeof e=="number")return e;if(je(e))return D;if(F(e)){var a=typeof e.valueOf=="function"?e.valueOf():e;e=F(a)?a+"":a}if(typeof e!="string")return e===0?e:+e;e=$e(e);var c=Oe.test(e);return c||Me.test(e)?Ne(e.slice(2),c?2:8):Ce.test(e)?D:+e}var Ve=Ie,Le=O,j=Z,A=Ve,We="Expected a function",Fe=Math.max,De=Math.min;function Ae(e,a,c){var r,s,w,b,u,d,v=0,k=!1,T=!1,n=!0;if(typeof e!="function")throw new TypeError(We);a=A(a)||0,Le(c)&&(k=!!c.leading,T="maxWait"in c,w=T?Fe(A(c.maxWait)||0,a):w,n="trailing"in c?!!c.trailing:n);function f(g){var z=r,E=s;return r=s=void 0,v=g,b=e.apply(E,z),b}function p(g){return v=g,u=setTimeout(o,a),k?f(g):b}function l(g){var z=g-d,E=g-v,R=a-z;return T?De(R,w-E):R}function y(g){var z=g-d,E=g-v;return d===void 0||z>=a||z<0||T&&E>=w}function o(){var g=j();if(y(g))return i(g);u=setTimeout(o,l(g))}function i(g){return u=void 0,n&&r?f(g):(r=s=void 0,b)}function m(){u!==void 0&&clearTimeout(u),v=0,r=d=s=u=void 0}function h(){return u===void 0?b:i(j())}function _(){var g=j(),z=y(g);if(r=arguments,s=this,d=g,z){if(u===void 0)return p(d);if(T)return clearTimeout(u),u=setTimeout(o,a),f(d)}return u===void 0&&(u=setTimeout(o,a)),b}return _.cancel=m,_.flush=h,_}var Re=Ae;const C=G(Re),Ge=t.defineComponent({__name:"PdfPageText",props:{viewport:null,page:null},setup(e){const a=e,c=t.ref(),r=t.ref();t.watch(()=>a.page,async b=>{c.value=await b.getTextContent()},{immediate:!0}),t.watch(()=>[c.value,r.value,a.viewport],()=>{w()});let s;function w(){const b=r.value,u=c.value,d=a.viewport;if(!(!b||!u||!d)){if(s){s.cancel();return}for(;b.firstChild;)b.removeChild(b.firstChild);s=$.renderTextLayer({textContentSource:u,container:b,viewport:d}),s.promise.then(()=>{s=void 0}).catch(()=>{s=void 0}).finally(()=>{})}}return t.onMounted(()=>{w()}),(b,u)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootEl",ref:r,class:"pdf-text-layer"},null,512))}}),Qe="",Ue={class:"pdf-page-layout"},He={class:"pdf-page-overlay"},qe={key:0,class:"pdf-page-number"},Ke=t.defineComponent({__name:"PdfPage",props:{zoom:null,zoomType:null,hideText:{type:Boolean},hideNumber:{type:Boolean},viewport:null,page:null,observer:null},emits:["update:zoom"],setup(e,{expose:a,emit:c}){const r=e,s=t.ref(),w=t.ref(),b=t.ref(!1),u=1100;a({rootEl:w,inViewport:b});const d=96/72,v=t.computed(()=>{const{width:l,height:y}=r.page.getViewport({scale:d}),{width:o,height:i}=r.viewport;let m=0,h=1;switch(r.zoomType){case P.Auto:return m=Math.min(o,u)-40,h=m/l,d*h;case P.WidthFit:return m=o-40,h=m/l,d*h;case P.PageFit:return o>i?(h=i/y,d*h):(m=o-40,h=m/l,d*h)}return d*r.zoom}),k=t.computed(()=>v.value*((window==null?void 0:window.devicePixelRatio)||1)),T=t.computed(()=>r.page.getViewport({scale:v.value})),n=t.computed(()=>r.page.getViewport({scale:k.value}));t.watch(v,l=>{const y=l/d;Math.abs(y-r.zoom)>.05&&c("update:zoom",y)},{immediate:!0});let f;function p(){if(!r.page||!s.value)return;const l=r.page,y=T.value,o=n.value,i=s.value;i.width=Math.ceil(o.width),i.height=Math.ceil(o.height),i.style.width=Math.floor(y.width)+"px",i.style.height=Math.floor(y.height)+"px";const m=i.getContext("2d");if(!m||!b.value)return;if(f){f.cancel();return}console.debug(`rendering page ${l.pageNumber}`);const h={canvasContext:m,viewport:n.value};f=l.render(h),f.promise.then(()=>f=void 0).catch(()=>{f=void 0,p()})}return t.watch(()=>[r.page,k.value,b.value],()=>{p()},{immediate:!0}),t.onMounted(()=>{var l;p(),w.value&&((l=r.observer)==null||l.observe(w.value))}),t.onBeforeUnmount(()=>{var l;w.value&&((l=r.observer)==null||l.unobserve(w.value))}),(l,y)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootEl",ref:w,class:"pdf-page"},[t.createElementVNode("div",Ue,[t.createElementVNode("canvas",{ref_key:"canvas",ref:s},null,512),t.createElementVNode("div",He,[e.hideText?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(Ge,{key:0,viewport:t.unref(n),page:e.page},null,8,["viewport","page"])),t.renderSlot(l.$slots,"default",{displaySize:t.unref(n)})])]),e.hideNumber?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",qe,t.toDisplayString(e.page.pageNumber),1))],512))}}),Ze="",Xe={key:0,class:"pdf-progress"},Ye=t.defineComponent({__name:"PdfDocument",props:{hideText:{type:Boolean},hideNumber:{type:Boolean},zoomType:null,zoom:null,viewport:null,src:null},emits:["error","update:zoom"],setup(e,{emit:a}){const c=e,r=t.shallowRef(),s=t.shallowRef([]),w=t.shallowRef(),b=t.ref();let u=[];const d=t.ref(!1),v=t.ref(0);function k(n){n&&(u.push(n),u.length==1&&(n.inViewport=!0))}function T(){s.value.forEach(f=>f.cleanup()),s.value=[];const n=r.value;n&&(n.destroy(),r.value=void 0),u=[]}return t.watch(()=>c.src,n=>{if(T(),!n)return;const f=$.getDocument(n);d.value=!0,f.onProgress=p=>{p.total&&(v.value=p.loaded/p.total)},f.promise.then(p=>{r.value=p;const l=[];for(let y=1;y<=p.numPages;y++)l.push(p.getPage(y));Promise.all(l).then(y=>{p===r.value&&(s.value=y)})}).catch(p=>{a("error",p)}).finally(()=>{d.value=!1})},{immediate:!0}),t.onMounted(()=>{w.value=new IntersectionObserver(C(n=>{n.forEach(f=>{const p=u.find(l=>(l==null?void 0:l.rootEl)===f.target);p&&(p.inViewport=f.isIntersecting)})},50),{rootMargin:"0px"})}),t.onBeforeUnmount(()=>{var n;T(),(n=w.value)==null||n.disconnect()}),(n,f)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootEl",ref:b},[t.renderSlot(n.$slots,"loading",{src:c.src,loading:d.value,progress:v.value},()=>[d.value?(t.openBlock(),t.createElementBlock("p",Xe,"loading "+t.toDisplayString(Math.ceil(100*v.value))+"%",1)):t.createCommentVNode("",!0)]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(s),p=>(t.openBlock(),t.createBlock(Ke,{ref_for:!0,ref:k,key:p.pageNumber,page:p,"hide-number":e.hideNumber,"hide-text":e.hideText,"zoom-type":e.zoomType,zoom:e.zoom,"onUpdate:zoom":f[0]||(f[0]=l=>a("update:zoom",l)),observer:t.unref(w),viewport:e.viewport},{default:t.withCtx(({displaySize:l})=>[t.renderSlot(n.$slots,"default",{doc:t.unref(r),page:p,displaySize:l})]),_:2},1032,["page","hide-number","hide-text","zoom-type","zoom","observer","viewport"]))),128))],512))}}),et="",Je=t.defineComponent({__name:"PdfHost",props:{workerSrc:null,sources:null,zoomType:null,zoom:null,hideText:{type:Boolean},hideNumber:{type:Boolean},enablePinchZoom:{type:Boolean}},emits:["update:zoom","update:zoomType"],setup(e,{expose:a,emit:c}){const r=e,s=t.ref();a({zoomIn:k,zoomOut:T}),t.watch(()=>r.workerSrc,o=>{o&&($.GlobalWorkerOptions.workerSrc=o)},{immediate:!0});function w(o){o.ctrlKey&&(o.preventDefault(),o.deltaY<0?k():T())}function b(o){o.ctrlKey&&(o.key==="0"||o.which==48)&&c("update:zoomType",P.Auto)}const u=t.ref({width:0,height:0}),d=C(()=>{const o=s.value;o&&(u.value={width:o.offsetWidth,height:o.offsetHeight})},100);function v(o){const i=o%.25;return Number((o-i).toFixed(2))}function k(){const o=v((r.zoom||1)+.25);c("update:zoom",Math.min(o,2)),c("update:zoomType",P.Custom)}function T(){const o=v((r.zoom||1)-.25);c("update:zoom",Math.max(o,.25)),c("update:zoomType",P.Custom)}t.watch(()=>r.zoom,(o,i)=>{const m=s.value;if(m&&o&&i){const h=m.scrollTop,_=m.scrollLeft,g=o/i;t.nextTick(()=>{m.scrollTop=h*g,m.scrollLeft=_*g})}}),t.onMounted(()=>{window.addEventListener("resize",d),d()}),t.onBeforeUnmount(()=>{window.removeEventListener("resize",d)});const n=[];let f=-1;function p(o){r.enablePinchZoom&&n.push(o)}const l=C(o=>{if(r.enablePinchZoom){for(let i=0;i<n.length;i++)if(o.pointerId===n[i].pointerId){n[i]=o;break}if(n.length===2){const i=Math.abs(n[0].clientX-n[1].clientX),m=Math.abs(n[0].clientY-n[1].clientY),h=Math.sqrt(Math.pow(i,2)+Math.pow(m,2));f>0&&(h>f&&k(),h<f&&T()),f=h}}},10);function y(o){if(r.enablePinchZoom){for(let i=0;i<n.length;i++)if(n[i].pointerId===o.pointerId){n.splice(i,1);break}n.length<2&&(f=-1)}}return(o,i)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootEl",ref:s,onWheel:w,onKeydown:b,onPointerdown:p,onPointermove:i[1]||(i[1]=(...m)=>t.unref(l)&&t.unref(l)(...m)),onPointerup:y,onPointercancel:y,onPointerleave:y,onPointerout:y,tabindex:"0",class:"pdf-host"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.sources,m=>(t.openBlock(),t.createBlock(Ye,{viewport:u.value,src:m,"hide-number":!!e.hideNumber,"hide-text":!!e.hideText,"zoom-type":e.zoomType||t.unref(P).Auto,zoom:e.zoom||1,"onUpdate:zoom":i[0]||(i[0]=h=>c("update:zoom",h))},{loading:t.withCtx(({loading:h,progress:_})=>[t.renderSlot(o.$slots,"loading",{source:m,loading:h,progress:_})]),default:t.withCtx(({doc:h,page:_,displaySize:g})=>[t.renderSlot(o.$slots,"page",{source:m,doc:h,page:_,displaySize:g})]),_:2},1032,["viewport","src","hide-number","hide-text","zoom-type","zoom"]))),256)),t.renderSlot(o.$slots,"default")],544))}}),tt="";x.PdfHost=Je,x.ZoomType=P,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfjs-vue3",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Using pdfjs to display PDFs as a vue 3 component.",
|
|
5
5
|
"author": "Eugene Wang",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"preview": "vite preview"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"pdfjs-dist": "^
|
|
40
|
-
"vue": "^3.2.
|
|
39
|
+
"pdfjs-dist": "^3.6.172",
|
|
40
|
+
"vue": "^3.2.47"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@babel/types": "^7.
|
|
44
|
-
"@types/lodash": "^4.14.
|
|
45
|
-
"@types/node": "^18.
|
|
46
|
-
"@vitejs/plugin-vue": "^
|
|
43
|
+
"@babel/types": "^7.21.5",
|
|
44
|
+
"@types/lodash": "^4.14.194",
|
|
45
|
+
"@types/node": "^18.16.6",
|
|
46
|
+
"@vitejs/plugin-vue": "^4.2.1",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"modern-normalize": "^1.1.0",
|
|
49
|
-
"typescript": "^
|
|
50
|
-
"vite": "^3.
|
|
51
|
-
"vue-tsc": "^
|
|
49
|
+
"typescript": "^5.0.4",
|
|
50
|
+
"vite": "^4.3.5",
|
|
51
|
+
"vue-tsc": "^1.6.4"
|
|
52
52
|
}
|
|
53
53
|
}
|
package/types/PdfHost.vue.d.ts
CHANGED
|
@@ -1,233 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
107
|
-
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
108
|
-
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
109
|
-
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
110
|
-
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
111
|
-
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
112
|
-
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
113
|
-
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
|
|
114
|
-
};
|
|
115
|
-
$forceUpdate: () => void;
|
|
116
|
-
$nextTick: typeof nextTick;
|
|
117
|
-
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
118
|
-
} & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
119
|
-
/**
|
|
120
|
-
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
121
|
-
*/
|
|
122
|
-
workerSrc?: string | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* Array of pdf sources to display.
|
|
125
|
-
*/
|
|
126
|
-
sources: PdfSource[];
|
|
127
|
-
/**
|
|
128
|
-
* Type of zoom used. Defaults to Auto.
|
|
129
|
-
*/
|
|
130
|
-
zoomType?: ZoomType | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
133
|
-
*/
|
|
134
|
-
zoom?: number | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Hides the selectable text layer.
|
|
137
|
-
*/
|
|
138
|
-
hideText?: boolean | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Hides page number display.
|
|
141
|
-
*/
|
|
142
|
-
hideNumber?: boolean | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* Experimental flag to enable pinch zoom gesture.
|
|
145
|
-
*/
|
|
146
|
-
enablePinchZoom?: boolean | undefined;
|
|
147
|
-
}>>> & {
|
|
148
|
-
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
149
|
-
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
150
|
-
} & import("vue").ShallowUnwrapRef<{
|
|
151
|
-
/**
|
|
152
|
-
* Try to increase zoom to the next level, up to 200%.
|
|
153
|
-
*/
|
|
154
|
-
zoomIn: () => void;
|
|
155
|
-
/**
|
|
156
|
-
* Try to decrease zoom to the next level, down to 25%.
|
|
157
|
-
*/
|
|
158
|
-
zoomOut: () => void;
|
|
159
|
-
}> & {} & import("vue").ComponentCustomProperties;
|
|
160
|
-
__isFragment?: undefined;
|
|
161
|
-
__isTeleport?: undefined;
|
|
162
|
-
__isSuspense?: undefined;
|
|
163
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
164
|
-
/**
|
|
165
|
-
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
166
|
-
*/
|
|
167
|
-
workerSrc?: string | undefined;
|
|
168
|
-
/**
|
|
169
|
-
* Array of pdf sources to display.
|
|
170
|
-
*/
|
|
171
|
-
sources: PdfSource[];
|
|
172
|
-
/**
|
|
173
|
-
* Type of zoom used. Defaults to Auto.
|
|
174
|
-
*/
|
|
175
|
-
zoomType?: ZoomType | undefined;
|
|
176
|
-
/**
|
|
177
|
-
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
178
|
-
*/
|
|
179
|
-
zoom?: number | undefined;
|
|
180
|
-
/**
|
|
181
|
-
* Hides the selectable text layer.
|
|
182
|
-
*/
|
|
183
|
-
hideText?: boolean | undefined;
|
|
184
|
-
/**
|
|
185
|
-
* Hides page number display.
|
|
186
|
-
*/
|
|
187
|
-
hideNumber?: boolean | undefined;
|
|
188
|
-
/**
|
|
189
|
-
* Experimental flag to enable pinch zoom gesture.
|
|
190
|
-
*/
|
|
191
|
-
enablePinchZoom?: boolean | undefined;
|
|
192
|
-
}>>> & {
|
|
193
|
-
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
194
|
-
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
195
|
-
}, {
|
|
196
|
-
/**
|
|
197
|
-
* Try to increase zoom to the next level, up to 200%.
|
|
198
|
-
*/
|
|
199
|
-
zoomIn: () => void;
|
|
200
|
-
/**
|
|
201
|
-
* Try to decrease zoom to the next level, down to 25%.
|
|
202
|
-
*/
|
|
203
|
-
zoomOut: () => void;
|
|
204
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
205
|
-
"update:zoom": (zoom: number) => void;
|
|
206
|
-
} & {
|
|
207
|
-
"update:zoomType": (zoomType: ZoomType) => void;
|
|
208
|
-
}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
209
|
-
$slots: {
|
|
210
|
-
loading: (_: {
|
|
211
|
-
source: PdfSource;
|
|
212
|
-
loading: boolean;
|
|
213
|
-
progress: number;
|
|
214
|
-
}) => any;
|
|
215
|
-
page: (_: {
|
|
216
|
-
source: PdfSource;
|
|
217
|
-
doc: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
|
|
218
|
-
page: import("pdfjs-dist/types/src/display/api").PDFPageProxy;
|
|
219
|
-
displaySize: import("pdfjs-dist/types/src/display/display_utils").PageViewport;
|
|
220
|
-
}) => any;
|
|
221
|
-
default: (_: {}) => any;
|
|
222
|
-
};
|
|
223
|
-
});
|
|
224
|
-
export default _default;
|
|
225
|
-
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
226
|
-
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
227
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
228
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
229
|
-
} : {
|
|
230
|
-
type: import('vue').PropType<T[K]>;
|
|
231
|
-
required: true;
|
|
232
|
-
};
|
|
233
|
-
};
|
|
1
|
+
import { PdfSource, ZoomType } from './types';
|
|
2
|
+
declare function zoomIn(): void;
|
|
3
|
+
declare function zoomOut(): void;
|
|
4
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
5
|
+
/**
|
|
6
|
+
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
7
|
+
*/
|
|
8
|
+
workerSrc?: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Array of pdf sources to display.
|
|
11
|
+
*/
|
|
12
|
+
sources: PdfSource[];
|
|
13
|
+
/**
|
|
14
|
+
* Type of zoom used. Defaults to Auto.
|
|
15
|
+
*/
|
|
16
|
+
zoomType?: ZoomType | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
19
|
+
*/
|
|
20
|
+
zoom?: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Hides the selectable text layer.
|
|
23
|
+
*/
|
|
24
|
+
hideText?: boolean | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Hides page number display.
|
|
27
|
+
*/
|
|
28
|
+
hideNumber?: boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Experimental flag to enable pinch zoom gesture.
|
|
31
|
+
*/
|
|
32
|
+
enablePinchZoom?: boolean | undefined;
|
|
33
|
+
}>, {
|
|
34
|
+
/**
|
|
35
|
+
* Try to increase zoom to the next level, up to 200%.
|
|
36
|
+
*/
|
|
37
|
+
zoomIn: typeof zoomIn;
|
|
38
|
+
/**
|
|
39
|
+
* Try to decrease zoom to the next level, down to 25%.
|
|
40
|
+
*/
|
|
41
|
+
zoomOut: typeof zoomOut;
|
|
42
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
43
|
+
"update:zoom": (zoom: number) => void;
|
|
44
|
+
"update:zoomType": (zoomType: ZoomType) => void;
|
|
45
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
46
|
+
/**
|
|
47
|
+
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
48
|
+
*/
|
|
49
|
+
workerSrc?: string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Array of pdf sources to display.
|
|
52
|
+
*/
|
|
53
|
+
sources: PdfSource[];
|
|
54
|
+
/**
|
|
55
|
+
* Type of zoom used. Defaults to Auto.
|
|
56
|
+
*/
|
|
57
|
+
zoomType?: ZoomType | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
60
|
+
*/
|
|
61
|
+
zoom?: number | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Hides the selectable text layer.
|
|
64
|
+
*/
|
|
65
|
+
hideText?: boolean | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Hides page number display.
|
|
68
|
+
*/
|
|
69
|
+
hideNumber?: boolean | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Experimental flag to enable pinch zoom gesture.
|
|
72
|
+
*/
|
|
73
|
+
enablePinchZoom?: boolean | undefined;
|
|
74
|
+
}>>> & {
|
|
75
|
+
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
76
|
+
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
77
|
+
}, {}>, {
|
|
78
|
+
loading?(_: {
|
|
79
|
+
source: PdfSource;
|
|
80
|
+
loading: boolean;
|
|
81
|
+
progress: number;
|
|
82
|
+
}): any;
|
|
83
|
+
page?(_: {
|
|
84
|
+
source: PdfSource;
|
|
85
|
+
doc: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
|
|
86
|
+
page: import("pdfjs-dist/types/src/display/api").PDFPageProxy;
|
|
87
|
+
displaySize: import("pdfjs-dist/types/src/display/display_utils").PageViewport;
|
|
88
|
+
}): any;
|
|
89
|
+
default?(_: {}): any;
|
|
90
|
+
}>;
|
|
91
|
+
export default _default;
|
|
92
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
93
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
94
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
95
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
96
|
+
} : {
|
|
97
|
+
type: import('vue').PropType<T[K]>;
|
|
98
|
+
required: true;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
102
|
+
new (): {
|
|
103
|
+
$slots: S;
|
|
104
|
+
};
|
|
105
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as PdfHost } from './PdfHost.vue';
|
|
2
|
-
export { ZoomType } from './types';
|
|
3
|
-
export type { PdfSource } from './types';
|
|
1
|
+
export { default as PdfHost } from './PdfHost.vue';
|
|
2
|
+
export { ZoomType } from './types';
|
|
3
|
+
export type { PdfSource } from './types';
|
package/types/types.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { PDFDataRangeTransport } from 'pdfjs-dist';
|
|
2
|
-
import type { TypedArray, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
|
|
3
|
-
/**
|
|
4
|
-
* Types of zooms supported in pdf display.
|
|
5
|
-
*/
|
|
6
|
-
export declare enum ZoomType {
|
|
7
|
-
/**
|
|
8
|
-
* Auto zoom to fit width of host until a certain limit.
|
|
9
|
-
*/
|
|
10
|
-
Auto = 0,
|
|
11
|
-
/**
|
|
12
|
-
* Fits width of host with no limit.
|
|
13
|
-
*/
|
|
14
|
-
WidthFit = 1,
|
|
15
|
-
/**
|
|
16
|
-
* Fits whole page in the host.
|
|
17
|
-
*/
|
|
18
|
-
PageFit = 2,
|
|
19
|
-
/**
|
|
20
|
-
* Custom zoom value percentage.
|
|
21
|
-
*/
|
|
22
|
-
Custom = 3
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Source of pdf to display in the host.
|
|
26
|
-
*/
|
|
27
|
-
export
|
|
1
|
+
import { PDFDataRangeTransport } from 'pdfjs-dist';
|
|
2
|
+
import type { TypedArray, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
|
|
3
|
+
/**
|
|
4
|
+
* Types of zooms supported in pdf display.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ZoomType {
|
|
7
|
+
/**
|
|
8
|
+
* Auto zoom to fit width of host until a certain limit.
|
|
9
|
+
*/
|
|
10
|
+
Auto = 0,
|
|
11
|
+
/**
|
|
12
|
+
* Fits width of host with no limit.
|
|
13
|
+
*/
|
|
14
|
+
WidthFit = 1,
|
|
15
|
+
/**
|
|
16
|
+
* Fits whole page in the host.
|
|
17
|
+
*/
|
|
18
|
+
PageFit = 2,
|
|
19
|
+
/**
|
|
20
|
+
* Custom zoom value percentage.
|
|
21
|
+
*/
|
|
22
|
+
Custom = 3
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Source of pdf to display in the host.
|
|
26
|
+
*/
|
|
27
|
+
export type PdfSource = string | URL | PDFDataRangeTransport | TypedArray | DocumentInitParameters;
|