pdfjs-vue3 0.1.6 → 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/README.md +3 -3
- package/dist/pdfjs-vue3.es.js +124 -107
- package/dist/pdfjs-vue3.umd.js +1 -1
- package/package.json +53 -53
- package/types/PdfHost.vue.d.ts +105 -217
- package/types/index.d.ts +3 -3
- package/types/types.d.ts +27 -27
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Pdfjs in Vue 3
|
|
2
|
-
|
|
3
|
-
This is an experiment in displaying PDFs using pdfjs as a vue 3 component.
|
|
1
|
+
# Pdfjs in Vue 3
|
|
2
|
+
|
|
3
|
+
This is an experiment in displaying PDFs using pdfjs as a vue 3 component.
|
package/dist/pdfjs-vue3.es.js
CHANGED
|
@@ -1,54 +1,57 @@
|
|
|
1
|
-
import { defineComponent as N, ref as
|
|
1
|
+
import { defineComponent as N, ref as P, watch as j, onMounted as L, openBlock as x, createElementBlock as $, computed as M, onBeforeUnmount as G, createElementVNode as W, createBlock as R, unref as k, createCommentVNode as D, renderSlot as E, toDisplayString as Q, shallowRef as B, Fragment as Z, renderList as ee, withCtx as F, nextTick as ie } from "vue";
|
|
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
|
|
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,49 +59,49 @@ 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,
|
|
69
|
-
function c(
|
|
70
|
-
var
|
|
71
|
-
return n = s = void 0, y =
|
|
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);
|
|
72
|
+
function c(v) {
|
|
73
|
+
var z = n, O = s;
|
|
74
|
+
return n = s = void 0, y = v, g = e.apply(O, z), g;
|
|
72
75
|
}
|
|
73
|
-
function f(
|
|
74
|
-
return y =
|
|
76
|
+
function f(v) {
|
|
77
|
+
return y = v, d = setTimeout(t, i), T ? c(v) : g;
|
|
75
78
|
}
|
|
76
|
-
function a(
|
|
77
|
-
var
|
|
78
|
-
return w ?
|
|
79
|
+
function a(v) {
|
|
80
|
+
var z = v - u, O = v - y, H = i - z;
|
|
81
|
+
return w ? at(H, b - O) : H;
|
|
79
82
|
}
|
|
80
|
-
function h(
|
|
81
|
-
var
|
|
82
|
-
return u === void 0 ||
|
|
83
|
+
function h(v) {
|
|
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
|
-
var
|
|
86
|
-
if (h(
|
|
87
|
-
return r(
|
|
88
|
-
d = setTimeout(t, a(
|
|
88
|
+
var v = V();
|
|
89
|
+
if (h(v))
|
|
90
|
+
return r(v);
|
|
91
|
+
d = setTimeout(t, a(v));
|
|
89
92
|
}
|
|
90
|
-
function r(
|
|
91
|
-
return d = void 0, o && n ? c(
|
|
93
|
+
function r(v) {
|
|
94
|
+
return d = void 0, o && n ? c(v) : (n = s = void 0, g);
|
|
92
95
|
}
|
|
93
96
|
function p() {
|
|
94
97
|
d !== void 0 && clearTimeout(d), y = 0, n = u = s = d = void 0;
|
|
95
98
|
}
|
|
96
|
-
function
|
|
99
|
+
function m() {
|
|
97
100
|
return d === void 0 ? g : r(V());
|
|
98
101
|
}
|
|
99
102
|
function _() {
|
|
100
|
-
var
|
|
101
|
-
if (n = arguments, s = this, u =
|
|
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,17 +109,17 @@ function at(e, i, l) {
|
|
|
106
109
|
}
|
|
107
110
|
return d === void 0 && (d = setTimeout(t, i)), g;
|
|
108
111
|
}
|
|
109
|
-
return _.cancel = p, _.flush =
|
|
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,
|
|
116
119
|
page: null
|
|
117
120
|
},
|
|
118
121
|
setup(e) {
|
|
119
|
-
const i = e, l =
|
|
122
|
+
const i = e, l = P(), n = P();
|
|
120
123
|
j(() => i.page, async (g) => {
|
|
121
124
|
l.value = await g.getTextContent();
|
|
122
125
|
}, { immediate: !0 }), j(() => [l.value, n.value, i.viewport], () => {
|
|
@@ -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,
|
|
@@ -169,18 +173,18 @@ const st = { class: "pdf-page-layout" }, ut = { class: "pdf-page-overlay" }, ct
|
|
|
169
173
|
},
|
|
170
174
|
emits: ["update:zoom"],
|
|
171
175
|
setup(e, { expose: i, emit: l }) {
|
|
172
|
-
const n = e, s =
|
|
176
|
+
const n = e, s = P(), b = P(), g = P(!1), d = 1100;
|
|
173
177
|
i({ rootEl: b, inViewport: g });
|
|
174
178
|
const u = 96 / 72, y = M(() => {
|
|
175
179
|
const { width: a, height: h } = n.page.getViewport({ scale: u }), { width: t, height: r } = n.viewport;
|
|
176
|
-
let p = 0,
|
|
180
|
+
let p = 0, m = 1;
|
|
177
181
|
switch (n.zoomType) {
|
|
178
182
|
case S.Auto:
|
|
179
|
-
return p = Math.min(t, d) - 40,
|
|
183
|
+
return p = Math.min(t, d) - 40, m = p / a, u * m;
|
|
180
184
|
case S.WidthFit:
|
|
181
|
-
return p = t - 40,
|
|
185
|
+
return p = t - 40, m = p / a, u * m;
|
|
182
186
|
case S.PageFit:
|
|
183
|
-
return t > r ? (
|
|
187
|
+
return t > r ? (m = r / h, u * m) : (p = t - 40, m = p / a, u * m);
|
|
184
188
|
}
|
|
185
189
|
return u * n.zoom;
|
|
186
190
|
}), T = M(() => y.value * ((window == null ? void 0 : window.devicePixelRatio) || 1)), w = M(() => n.page.getViewport({ scale: y.value })), o = M(() => n.page.getViewport({ scale: T.value }));
|
|
@@ -202,11 +206,11 @@ const st = { class: "pdf-page-layout" }, ut = { class: "pdf-page-overlay" }, ct
|
|
|
202
206
|
return;
|
|
203
207
|
}
|
|
204
208
|
console.debug(`rendering page ${a.pageNumber}`);
|
|
205
|
-
const
|
|
209
|
+
const m = {
|
|
206
210
|
canvasContext: p,
|
|
207
211
|
viewport: o.value
|
|
208
212
|
};
|
|
209
|
-
c = a.render(
|
|
213
|
+
c = a.render(m), c.promise.then(() => c = void 0).catch(() => {
|
|
210
214
|
c = void 0, f();
|
|
211
215
|
});
|
|
212
216
|
}
|
|
@@ -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 },
|
|
@@ -256,9 +260,9 @@ const ft = {
|
|
|
256
260
|
},
|
|
257
261
|
emits: ["error", "update:zoom"],
|
|
258
262
|
setup(e, { emit: i }) {
|
|
259
|
-
const l = e, n = B(), s = B([]), b = B(), g =
|
|
263
|
+
const l = e, n = B(), s = B([]), b = B(), g = P();
|
|
260
264
|
let d = [];
|
|
261
|
-
const u =
|
|
265
|
+
const u = P(!1), y = P(0);
|
|
262
266
|
function T(o) {
|
|
263
267
|
o && (d.push(o), d.length == 1 && (o.inViewport = !0));
|
|
264
268
|
}
|
|
@@ -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,
|
|
@@ -342,13 +347,20 @@ const gt = /* @__PURE__ */ N({
|
|
|
342
347
|
zoomType: null,
|
|
343
348
|
zoom: null,
|
|
344
349
|
hideText: { type: Boolean },
|
|
345
|
-
hideNumber: { type: Boolean }
|
|
350
|
+
hideNumber: { type: Boolean },
|
|
351
|
+
enablePinchZoom: { type: Boolean }
|
|
346
352
|
},
|
|
347
353
|
emits: ["update:zoom", "update:zoomType"],
|
|
348
354
|
setup(e, { expose: i, emit: l }) {
|
|
349
|
-
const n = e, s =
|
|
355
|
+
const n = e, s = P();
|
|
350
356
|
i({
|
|
357
|
+
/**
|
|
358
|
+
* Try to increase zoom to the next level, up to 200%.
|
|
359
|
+
*/
|
|
351
360
|
zoomIn: T,
|
|
361
|
+
/**
|
|
362
|
+
* Try to decrease zoom to the next level, down to 25%.
|
|
363
|
+
*/
|
|
352
364
|
zoomOut: w
|
|
353
365
|
}), j(() => n.workerSrc, (t) => {
|
|
354
366
|
t && (se.workerSrc = t);
|
|
@@ -359,7 +371,7 @@ const gt = /* @__PURE__ */ N({
|
|
|
359
371
|
function g(t) {
|
|
360
372
|
t.ctrlKey && (t.key === "0" || t.which == 48) && l("update:zoomType", S.Auto);
|
|
361
373
|
}
|
|
362
|
-
const d =
|
|
374
|
+
const d = P({ width: 0, height: 0 }), u = A(() => {
|
|
363
375
|
const t = s.value;
|
|
364
376
|
t && (d.value = {
|
|
365
377
|
width: t.offsetWidth,
|
|
@@ -381,9 +393,9 @@ const gt = /* @__PURE__ */ N({
|
|
|
381
393
|
j(() => n.zoom, (t, r) => {
|
|
382
394
|
const p = s.value;
|
|
383
395
|
if (p && t && r) {
|
|
384
|
-
const
|
|
396
|
+
const m = p.scrollTop, _ = p.scrollLeft, v = t / r;
|
|
385
397
|
ie(() => {
|
|
386
|
-
p.scrollTop =
|
|
398
|
+
p.scrollTop = m * v, p.scrollLeft = _ * v;
|
|
387
399
|
});
|
|
388
400
|
}
|
|
389
401
|
}), L(() => {
|
|
@@ -394,26 +406,30 @@ const gt = /* @__PURE__ */ N({
|
|
|
394
406
|
const o = [];
|
|
395
407
|
let c = -1;
|
|
396
408
|
function f(t) {
|
|
397
|
-
o.push(t);
|
|
409
|
+
n.enablePinchZoom && o.push(t);
|
|
398
410
|
}
|
|
399
411
|
const a = A((t) => {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
o[r]
|
|
403
|
-
|
|
412
|
+
if (n.enablePinchZoom) {
|
|
413
|
+
for (let r = 0; r < o.length; r++)
|
|
414
|
+
if (t.pointerId === o[r].pointerId) {
|
|
415
|
+
o[r] = t;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
if (o.length === 2) {
|
|
419
|
+
const r = Math.abs(o[0].clientX - o[1].clientX), p = Math.abs(o[0].clientY - o[1].clientY), m = Math.sqrt(Math.pow(r, 2) + Math.pow(p, 2));
|
|
420
|
+
c > 0 && (m > c && T(), m < c && w()), c = m;
|
|
404
421
|
}
|
|
405
|
-
if (o.length === 2) {
|
|
406
|
-
const r = Math.abs(o[0].clientX - o[1].clientX), p = Math.abs(o[0].clientY - o[1].clientY), v = Math.sqrt(Math.pow(r, 2) + Math.pow(p, 2));
|
|
407
|
-
c > 0 && (v > c && T(), v < c && w()), c = v;
|
|
408
422
|
}
|
|
409
423
|
}, 10);
|
|
410
424
|
function h(t) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
o.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
425
|
+
if (n.enablePinchZoom) {
|
|
426
|
+
for (let r = 0; r < o.length; r++)
|
|
427
|
+
if (o[r].pointerId === t.pointerId) {
|
|
428
|
+
o.splice(r, 1);
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
o.length < 2 && (c = -1);
|
|
432
|
+
}
|
|
417
433
|
}
|
|
418
434
|
return (t, r) => (x(), $("div", {
|
|
419
435
|
ref_key: "rootEl",
|
|
@@ -421,7 +437,8 @@ const gt = /* @__PURE__ */ N({
|
|
|
421
437
|
onWheel: b,
|
|
422
438
|
onKeydown: g,
|
|
423
439
|
onPointerdown: f,
|
|
424
|
-
onPointermove: r[1] || (r[1] =
|
|
440
|
+
onPointermove: r[1] || (r[1] = //@ts-ignore
|
|
441
|
+
(...p) => k(a) && k(a)(...p)),
|
|
425
442
|
onPointerup: h,
|
|
426
443
|
onPointercancel: h,
|
|
427
444
|
onPointerleave: h,
|
|
@@ -429,28 +446,28 @@ const gt = /* @__PURE__ */ N({
|
|
|
429
446
|
tabindex: "0",
|
|
430
447
|
class: "pdf-host"
|
|
431
448
|
}, [
|
|
432
|
-
(x(!0), $(Z, null, ee(e.sources, (p) => (x(), R(
|
|
449
|
+
(x(!0), $(Z, null, ee(e.sources, (p) => (x(), R(vt, {
|
|
433
450
|
viewport: d.value,
|
|
434
451
|
src: p,
|
|
435
452
|
"hide-number": !!e.hideNumber,
|
|
436
453
|
"hide-text": !!e.hideText,
|
|
437
454
|
"zoom-type": e.zoomType || k(S).Auto,
|
|
438
455
|
zoom: e.zoom || 1,
|
|
439
|
-
"onUpdate:zoom": r[0] || (r[0] = (
|
|
456
|
+
"onUpdate:zoom": r[0] || (r[0] = (m) => l("update:zoom", m))
|
|
440
457
|
}, {
|
|
441
|
-
loading: F(({ loading:
|
|
458
|
+
loading: F(({ loading: m, progress: _ }) => [
|
|
442
459
|
E(t.$slots, "loading", {
|
|
443
460
|
source: p,
|
|
444
|
-
loading:
|
|
461
|
+
loading: m,
|
|
445
462
|
progress: _
|
|
446
463
|
})
|
|
447
464
|
]),
|
|
448
|
-
default: F(({ doc:
|
|
465
|
+
default: F(({ doc: m, page: _, displaySize: v }) => [
|
|
449
466
|
E(t.$slots, "page", {
|
|
450
467
|
source: p,
|
|
451
|
-
doc:
|
|
468
|
+
doc: m,
|
|
452
469
|
page: _,
|
|
453
|
-
displaySize:
|
|
470
|
+
displaySize: v
|
|
454
471
|
})
|
|
455
472
|
]),
|
|
456
473
|
_: 2
|
|
@@ -460,6 +477,6 @@ const gt = /* @__PURE__ */ N({
|
|
|
460
477
|
}
|
|
461
478
|
});
|
|
462
479
|
export {
|
|
463
|
-
|
|
480
|
+
bt as PdfHost,
|
|
464
481
|
S as ZoomType
|
|
465
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 _=(t=>(t[t.Auto=0]="Auto",t[t.WidthFit=1]="WidthFit",t[t.PageFit=2]="PageFit",t[t.Custom=3]="Custom",t))(_||{}),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,_e=Te,ze=ke,Pe="[object Symbol]";function Se(t){return typeof t=="symbol"||ze(t)&&_e(t)==Pe}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 P=r,E=s;return r=s=void 0,v=g,b=t.apply(E,P),b}function p(g){return v=g,u=setTimeout(o,a),x?f(g):b}function l(g){var P=g-d,E=g-v,R=a-P;return T?Fe(R,w-E):R}function y(g){var P=g-d,E=g-v;return d===void 0||P>=a||P<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 z(){var g=j(),P=y(g);if(r=arguments,s=this,d=g,P){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 z.cancel=m,z.flush=h,z}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 _.Auto:return m=Math.min(o,u)-40,h=m/l,d*h;case _.WidthFit:return m=o-40,h=m/l,d*h;case _.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}},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",_.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",_.Custom)}function T(){const o=v((r.zoom||1)-.25);c("update:zoom",Math.max(o,.25)),c("update:zoomType",_.Custom)}e.watch(()=>r.zoom,(o,i)=>{const m=s.value;if(m&&o&&i){const h=m.scrollTop,z=m.scrollLeft,g=o/i;e.nextTick(()=>{m.scrollTop=h*g,m.scrollLeft=z*g})}}),e.onMounted(()=>{window.addEventListener("resize",d),d()}),e.onBeforeUnmount(()=>{window.removeEventListener("resize",d)});const n=[];let f=-1;function p(o){n.push(o)}const l=C(o=>{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){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(_).Auto,zoom:t.zoom||1,"onUpdate:zoom":i[0]||(i[0]=h=>c("update:zoom",h))},{loading:e.withCtx(({loading:h,progress:z})=>[e.renderSlot(o.$slots,"loading",{source:m,loading:h,progress:z})]),default:e.withCtx(({doc:h,page:z,displaySize:g})=>[e.renderSlot(o.$slots,"page",{source:m,doc:h,page:z,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=_,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,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pdfjs-vue3",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Using pdfjs to display PDFs as a vue 3 component.",
|
|
5
|
-
"author": "Eugene Wang",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"homepage": "https://github.com/soukoku/pdfjs-vue",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/soukoku/pdfjs-vue.git"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/soukoku/pdfjs-vue/issues"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist/pdfjs*",
|
|
17
|
-
"dist/style*",
|
|
18
|
-
"types/index*",
|
|
19
|
-
"types/types*",
|
|
20
|
-
"types/PdfHost*"
|
|
21
|
-
],
|
|
22
|
-
"types": "./types/index.d.ts",
|
|
23
|
-
"main": "./dist/pdfjs-vue3.umd.js",
|
|
24
|
-
"style": "./dist/style.css",
|
|
25
|
-
"module": "./dist/pdfjs-vue3.es.js",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"import": "./dist/pdfjs-vue3.es.js",
|
|
29
|
-
"require": "./dist/pdfjs-vue3.umd.js"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"scripts": {
|
|
33
|
-
"dev": "vite",
|
|
34
|
-
"build": "vite build && vue-tsc",
|
|
35
|
-
"build-lib": "vite build -c vite.config.lib.ts && vue-tsc",
|
|
36
|
-
"preview": "vite preview"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"pdfjs-dist": "^
|
|
40
|
-
"vue": "^3.2.
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@babel/types": "^7.
|
|
44
|
-
"@types/lodash": "^4.14.
|
|
45
|
-
"@types/node": "^18.
|
|
46
|
-
"@vitejs/plugin-vue": "^
|
|
47
|
-
"lodash": "^4.17.21",
|
|
48
|
-
"modern-normalize": "^1.1.0",
|
|
49
|
-
"typescript": "^
|
|
50
|
-
"vite": "^3.
|
|
51
|
-
"vue-tsc": "^
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pdfjs-vue3",
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"description": "Using pdfjs to display PDFs as a vue 3 component.",
|
|
5
|
+
"author": "Eugene Wang",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://github.com/soukoku/pdfjs-vue",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/soukoku/pdfjs-vue.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/soukoku/pdfjs-vue/issues"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/pdfjs*",
|
|
17
|
+
"dist/style*",
|
|
18
|
+
"types/index*",
|
|
19
|
+
"types/types*",
|
|
20
|
+
"types/PdfHost*"
|
|
21
|
+
],
|
|
22
|
+
"types": "./types/index.d.ts",
|
|
23
|
+
"main": "./dist/pdfjs-vue3.umd.js",
|
|
24
|
+
"style": "./dist/style.css",
|
|
25
|
+
"module": "./dist/pdfjs-vue3.es.js",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/pdfjs-vue3.es.js",
|
|
29
|
+
"require": "./dist/pdfjs-vue3.umd.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite",
|
|
34
|
+
"build": "vite build && vue-tsc",
|
|
35
|
+
"build-lib": "vite build -c vite.config.lib.ts && vue-tsc",
|
|
36
|
+
"preview": "vite preview"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"pdfjs-dist": "^3.6.172",
|
|
40
|
+
"vue": "^3.2.47"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
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
|
+
"lodash": "^4.17.21",
|
|
48
|
+
"modern-normalize": "^1.1.0",
|
|
49
|
+
"typescript": "^5.0.4",
|
|
50
|
+
"vite": "^4.3.5",
|
|
51
|
+
"vue-tsc": "^1.6.4"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/types/PdfHost.vue.d.ts
CHANGED
|
@@ -1,217 +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
|
-
};
|
|
107
|
-
$forceUpdate: () => void;
|
|
108
|
-
$nextTick: typeof nextTick;
|
|
109
|
-
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
110
|
-
} & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
111
|
-
/**
|
|
112
|
-
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
113
|
-
*/
|
|
114
|
-
workerSrc?: string | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Array of pdf sources to display.
|
|
117
|
-
*/
|
|
118
|
-
sources: PdfSource[];
|
|
119
|
-
/**
|
|
120
|
-
* Type of zoom used. Defaults to Auto.
|
|
121
|
-
*/
|
|
122
|
-
zoomType?: ZoomType | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
125
|
-
*/
|
|
126
|
-
zoom?: number | undefined;
|
|
127
|
-
/**
|
|
128
|
-
* Hides the selectable text layer.
|
|
129
|
-
*/
|
|
130
|
-
hideText?: boolean | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Hides page number display.
|
|
133
|
-
*/
|
|
134
|
-
hideNumber?: boolean | undefined;
|
|
135
|
-
}>>> & {
|
|
136
|
-
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
137
|
-
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
138
|
-
} & import("vue").ShallowUnwrapRef<{
|
|
139
|
-
/**
|
|
140
|
-
* Try to increase zoom to the next level, up to 200%.
|
|
141
|
-
*/
|
|
142
|
-
zoomIn: () => void;
|
|
143
|
-
/**
|
|
144
|
-
* Try to decrease zoom to the next level, down to 25%.
|
|
145
|
-
*/
|
|
146
|
-
zoomOut: () => void;
|
|
147
|
-
}> & {} & import("vue").ComponentCustomProperties;
|
|
148
|
-
__isFragment?: undefined;
|
|
149
|
-
__isTeleport?: undefined;
|
|
150
|
-
__isSuspense?: undefined;
|
|
151
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
152
|
-
/**
|
|
153
|
-
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
154
|
-
*/
|
|
155
|
-
workerSrc?: string | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Array of pdf sources to display.
|
|
158
|
-
*/
|
|
159
|
-
sources: PdfSource[];
|
|
160
|
-
/**
|
|
161
|
-
* Type of zoom used. Defaults to Auto.
|
|
162
|
-
*/
|
|
163
|
-
zoomType?: ZoomType | undefined;
|
|
164
|
-
/**
|
|
165
|
-
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
166
|
-
*/
|
|
167
|
-
zoom?: number | undefined;
|
|
168
|
-
/**
|
|
169
|
-
* Hides the selectable text layer.
|
|
170
|
-
*/
|
|
171
|
-
hideText?: boolean | undefined;
|
|
172
|
-
/**
|
|
173
|
-
* Hides page number display.
|
|
174
|
-
*/
|
|
175
|
-
hideNumber?: boolean | undefined;
|
|
176
|
-
}>>> & {
|
|
177
|
-
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
178
|
-
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
179
|
-
}, {
|
|
180
|
-
/**
|
|
181
|
-
* Try to increase zoom to the next level, up to 200%.
|
|
182
|
-
*/
|
|
183
|
-
zoomIn: () => void;
|
|
184
|
-
/**
|
|
185
|
-
* Try to decrease zoom to the next level, down to 25%.
|
|
186
|
-
*/
|
|
187
|
-
zoomOut: () => void;
|
|
188
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
189
|
-
"update:zoom": (zoom: number) => void;
|
|
190
|
-
} & {
|
|
191
|
-
"update:zoomType": (zoomType: ZoomType) => void;
|
|
192
|
-
}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
193
|
-
$slots: {
|
|
194
|
-
loading: (_: {
|
|
195
|
-
source: PdfSource;
|
|
196
|
-
loading: boolean;
|
|
197
|
-
progress: number;
|
|
198
|
-
}) => any;
|
|
199
|
-
page: (_: {
|
|
200
|
-
source: PdfSource;
|
|
201
|
-
doc: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
|
|
202
|
-
page: import("pdfjs-dist/types/src/display/api").PDFPageProxy;
|
|
203
|
-
displaySize: import("pdfjs-dist/types/src/display/display_utils").PageViewport;
|
|
204
|
-
}) => any;
|
|
205
|
-
default: (_: {}) => any;
|
|
206
|
-
};
|
|
207
|
-
});
|
|
208
|
-
export default _default;
|
|
209
|
-
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
210
|
-
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
211
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
212
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
213
|
-
} : {
|
|
214
|
-
type: import('vue').PropType<T[K]>;
|
|
215
|
-
required: true;
|
|
216
|
-
};
|
|
217
|
-
};
|
|
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;
|