pdfjs-vue3 0.1.2 → 0.1.3
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 +341 -518
- package/dist/pdfjs-vue3.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +10 -10
- package/types/PdfHost.vue.d.ts +170 -31
package/dist/pdfjs-vue3.es.js
CHANGED
|
@@ -1,268 +1,163 @@
|
|
|
1
|
-
import { defineComponent, ref, watch, onMounted, openBlock, createElementBlock
|
|
2
|
-
import { renderTextLayer, getDocument, GlobalWorkerOptions } from "pdfjs-dist";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ZoomType2[ZoomType2["Custom"] = 3] = "Custom";
|
|
8
|
-
return ZoomType2;
|
|
9
|
-
})(ZoomType || {});
|
|
10
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
11
|
-
function isObject$2(value) {
|
|
12
|
-
var type = typeof value;
|
|
13
|
-
return value != null && (type == "object" || type == "function");
|
|
1
|
+
import { defineComponent as I, ref as _, watch as P, onMounted as L, openBlock as T, createElementBlock as $, computed as C, onBeforeUnmount as D, createElementVNode as W, createBlock as G, unref as k, createCommentVNode as F, renderSlot as j, toDisplayString as J, shallowRef as B, Fragment as Q, renderList as Z, withCtx as A, nextTick as ie } from "vue";
|
|
2
|
+
import { renderTextLayer as ae, getDocument as le, GlobalWorkerOptions as se } from "pdfjs-dist";
|
|
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 || {}), N = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
4
|
+
function ue(e) {
|
|
5
|
+
var i = typeof e;
|
|
6
|
+
return e != null && (i == "object" || i == "function");
|
|
14
7
|
}
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var root$1 = _root;
|
|
23
|
-
var now$1 = function() {
|
|
24
|
-
return root$1.Date.now();
|
|
25
|
-
};
|
|
26
|
-
var now_1 = now$1;
|
|
27
|
-
var reWhitespace = /\s/;
|
|
28
|
-
function trimmedEndIndex$1(string) {
|
|
29
|
-
var index = string.length;
|
|
30
|
-
while (index-- && reWhitespace.test(string.charAt(index))) {
|
|
31
|
-
}
|
|
32
|
-
return index;
|
|
8
|
+
var ee = ue, ce = typeof N == "object" && N && N.Object === Object && N, de = ce, fe = de, me = typeof self == "object" && self && self.Object === Object && self, ve = fe || me || Function("return this")(), te = ve, pe = te, ge = function() {
|
|
9
|
+
return pe.Date.now();
|
|
10
|
+
}, he = ge, be = /\s/;
|
|
11
|
+
function ye(e) {
|
|
12
|
+
for (var i = e.length; i-- && be.test(e.charAt(i)); )
|
|
13
|
+
;
|
|
14
|
+
return i;
|
|
33
15
|
}
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function baseTrim$1(string) {
|
|
38
|
-
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
|
|
16
|
+
var we = ye, Te = we, xe = /^\s+/;
|
|
17
|
+
function _e(e) {
|
|
18
|
+
return e && e.slice(0, Te(e) + 1).replace(xe, "");
|
|
39
19
|
}
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
var _Symbol = Symbol$3;
|
|
44
|
-
var Symbol$2 = _Symbol;
|
|
45
|
-
var objectProto$1 = Object.prototype;
|
|
46
|
-
var hasOwnProperty = objectProto$1.hasOwnProperty;
|
|
47
|
-
var nativeObjectToString$1 = objectProto$1.toString;
|
|
48
|
-
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
49
|
-
function getRawTag$1(value) {
|
|
50
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
20
|
+
var ze = _e, Se = te, $e = Se.Symbol, oe = $e, H = oe, ne = Object.prototype, Pe = ne.hasOwnProperty, ke = ne.toString, O = H ? H.toStringTag : void 0;
|
|
21
|
+
function je(e) {
|
|
22
|
+
var i = Pe.call(e, O), l = e[O];
|
|
51
23
|
try {
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
} catch
|
|
55
|
-
}
|
|
56
|
-
var result = nativeObjectToString$1.call(value);
|
|
57
|
-
if (unmasked) {
|
|
58
|
-
if (isOwn) {
|
|
59
|
-
value[symToStringTag$1] = tag;
|
|
60
|
-
} else {
|
|
61
|
-
delete value[symToStringTag$1];
|
|
62
|
-
}
|
|
24
|
+
e[O] = void 0;
|
|
25
|
+
var n = !0;
|
|
26
|
+
} catch {
|
|
63
27
|
}
|
|
64
|
-
|
|
28
|
+
var s = ke.call(e);
|
|
29
|
+
return n && (i ? e[O] = l : delete e[O]), s;
|
|
65
30
|
}
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function objectToString$1(value) {
|
|
70
|
-
return nativeObjectToString.call(value);
|
|
31
|
+
var Ee = je, Oe = Object.prototype, Ce = Oe.toString;
|
|
32
|
+
function Ne(e) {
|
|
33
|
+
return Ce.call(e);
|
|
71
34
|
}
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
76
|
-
function baseGetTag$1(value) {
|
|
77
|
-
if (value == null) {
|
|
78
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
79
|
-
}
|
|
80
|
-
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
35
|
+
var Ie = Ne, U = oe, Le = Ee, Me = Ie, We = "[object Null]", Be = "[object Undefined]", K = U ? U.toStringTag : void 0;
|
|
36
|
+
function Ve(e) {
|
|
37
|
+
return e == null ? e === void 0 ? Be : We : K && K in Object(e) ? Le(e) : Me(e);
|
|
81
38
|
}
|
|
82
|
-
var
|
|
83
|
-
function
|
|
84
|
-
return
|
|
39
|
+
var Fe = Ve;
|
|
40
|
+
function Ae(e) {
|
|
41
|
+
return e != null && typeof e == "object";
|
|
85
42
|
}
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
function isSymbol$1(value) {
|
|
90
|
-
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
|
43
|
+
var De = Ae, Ge = Fe, Re = De, He = "[object Symbol]";
|
|
44
|
+
function Ue(e) {
|
|
45
|
+
return typeof e == "symbol" || Re(e) && Ge(e) == He;
|
|
91
46
|
}
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
if (isSymbol(value)) {
|
|
104
|
-
return NAN;
|
|
105
|
-
}
|
|
106
|
-
if (isObject$1(value)) {
|
|
107
|
-
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
108
|
-
value = isObject$1(other) ? other + "" : other;
|
|
47
|
+
var Ke = Ue, Xe = ze, X = ee, Ye = Ke, Y = 0 / 0, qe = /^[-+]0x[0-9a-f]+$/i, Je = /^0b[01]+$/i, Qe = /^0o[0-7]+$/i, Ze = parseInt;
|
|
48
|
+
function et(e) {
|
|
49
|
+
if (typeof e == "number")
|
|
50
|
+
return e;
|
|
51
|
+
if (Ye(e))
|
|
52
|
+
return Y;
|
|
53
|
+
if (X(e)) {
|
|
54
|
+
var i = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
55
|
+
e = X(i) ? i + "" : i;
|
|
109
56
|
}
|
|
110
|
-
if (typeof
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
57
|
+
if (typeof e != "string")
|
|
58
|
+
return e === 0 ? e : +e;
|
|
59
|
+
e = Xe(e);
|
|
60
|
+
var l = Je.test(e);
|
|
61
|
+
return l || Qe.test(e) ? Ze(e.slice(2), l ? 2 : 8) : qe.test(e) ? Y : +e;
|
|
116
62
|
}
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
63
|
+
var tt = et, ot = ee, V = he, q = tt, nt = "Expected a function", rt = Math.max, it = Math.min;
|
|
64
|
+
function at(e, i, l) {
|
|
65
|
+
var n, s, m, d, c, u, g = 0, x = !1, h = !1, t = !0;
|
|
66
|
+
if (typeof e != "function")
|
|
67
|
+
throw new TypeError(nt);
|
|
68
|
+
i = q(i) || 0, ot(l) && (x = !!l.leading, h = "maxWait" in l, m = h ? rt(q(l.maxWait) || 0, i) : m, t = "trailing" in l ? !!l.trailing : t);
|
|
69
|
+
function a(v) {
|
|
70
|
+
var z = n, E = s;
|
|
71
|
+
return n = s = void 0, g = v, d = e.apply(E, z), d;
|
|
125
72
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
leading = !!options.leading;
|
|
129
|
-
maxing = "maxWait" in options;
|
|
130
|
-
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
131
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
73
|
+
function r(v) {
|
|
74
|
+
return g = v, c = setTimeout(p, i), x ? a(v) : d;
|
|
132
75
|
}
|
|
133
|
-
function
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
lastInvokeTime = time;
|
|
137
|
-
result = func.apply(thisArg, args);
|
|
138
|
-
return result;
|
|
76
|
+
function o(v) {
|
|
77
|
+
var z = v - u, E = v - g, R = i - z;
|
|
78
|
+
return h ? it(R, m - E) : R;
|
|
139
79
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return leading ? invokeFunc(time) : result;
|
|
80
|
+
function f(v) {
|
|
81
|
+
var z = v - u, E = v - g;
|
|
82
|
+
return u === void 0 || z >= i || z < 0 || h && E >= m;
|
|
144
83
|
}
|
|
145
|
-
function
|
|
146
|
-
var
|
|
147
|
-
|
|
84
|
+
function p() {
|
|
85
|
+
var v = V();
|
|
86
|
+
if (f(v))
|
|
87
|
+
return y(v);
|
|
88
|
+
c = setTimeout(p, o(v));
|
|
148
89
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
90
|
+
function y(v) {
|
|
91
|
+
return c = void 0, t && n ? a(v) : (n = s = void 0, d);
|
|
152
92
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
if (shouldInvoke(time)) {
|
|
156
|
-
return trailingEdge(time);
|
|
157
|
-
}
|
|
158
|
-
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
93
|
+
function w() {
|
|
94
|
+
c !== void 0 && clearTimeout(c), g = 0, n = u = s = c = void 0;
|
|
159
95
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
if (trailing && lastArgs) {
|
|
163
|
-
return invokeFunc(time);
|
|
164
|
-
}
|
|
165
|
-
lastArgs = lastThis = void 0;
|
|
166
|
-
return result;
|
|
96
|
+
function b() {
|
|
97
|
+
return c === void 0 ? d : y(V());
|
|
167
98
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
99
|
+
function M() {
|
|
100
|
+
var v = V(), z = f(v);
|
|
101
|
+
if (n = arguments, s = this, u = v, z) {
|
|
102
|
+
if (c === void 0)
|
|
103
|
+
return r(u);
|
|
104
|
+
if (h)
|
|
105
|
+
return clearTimeout(c), c = setTimeout(p, i), a(u);
|
|
171
106
|
}
|
|
172
|
-
|
|
173
|
-
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
174
|
-
}
|
|
175
|
-
function flush() {
|
|
176
|
-
return timerId === void 0 ? result : trailingEdge(now());
|
|
107
|
+
return c === void 0 && (c = setTimeout(p, i)), d;
|
|
177
108
|
}
|
|
178
|
-
|
|
179
|
-
var time = now(), isInvoking = shouldInvoke(time);
|
|
180
|
-
lastArgs = arguments;
|
|
181
|
-
lastThis = this;
|
|
182
|
-
lastCallTime = time;
|
|
183
|
-
if (isInvoking) {
|
|
184
|
-
if (timerId === void 0) {
|
|
185
|
-
return leadingEdge(lastCallTime);
|
|
186
|
-
}
|
|
187
|
-
if (maxing) {
|
|
188
|
-
clearTimeout(timerId);
|
|
189
|
-
timerId = setTimeout(timerExpired, wait);
|
|
190
|
-
return invokeFunc(lastCallTime);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (timerId === void 0) {
|
|
194
|
-
timerId = setTimeout(timerExpired, wait);
|
|
195
|
-
}
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
debounced.cancel = cancel;
|
|
199
|
-
debounced.flush = flush;
|
|
200
|
-
return debounced;
|
|
109
|
+
return M.cancel = w, M.flush = b, M;
|
|
201
110
|
}
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
111
|
+
var re = at;
|
|
112
|
+
const lt = /* @__PURE__ */ I({
|
|
113
|
+
__name: "PdfPageText",
|
|
205
114
|
props: {
|
|
206
115
|
viewport: null,
|
|
207
116
|
page: null
|
|
208
117
|
},
|
|
209
|
-
setup(
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}, { immediate: true });
|
|
216
|
-
watch(() => [textContent.value, rootEl.value, props.viewport], () => {
|
|
217
|
-
renderText();
|
|
118
|
+
setup(e) {
|
|
119
|
+
const i = e, l = _(), n = _();
|
|
120
|
+
P(() => i.page, async (d) => {
|
|
121
|
+
l.value = await d.getTextContent();
|
|
122
|
+
}, { immediate: !0 }), P(() => [l.value, n.value, i.viewport], () => {
|
|
123
|
+
m();
|
|
218
124
|
});
|
|
219
|
-
let
|
|
220
|
-
function
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
125
|
+
let s;
|
|
126
|
+
function m() {
|
|
127
|
+
const d = n.value, c = l.value, u = i.viewport;
|
|
128
|
+
if (!(!d || !c || !u)) {
|
|
129
|
+
if (s) {
|
|
130
|
+
s.cancel();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
for (; d.firstChild; )
|
|
134
|
+
d.removeChild(d.firstChild);
|
|
135
|
+
s = ae({
|
|
136
|
+
textContent: l.value,
|
|
137
|
+
container: d,
|
|
138
|
+
viewport: u
|
|
139
|
+
}), s.promise.then(() => {
|
|
140
|
+
s = void 0;
|
|
141
|
+
}).catch(() => {
|
|
142
|
+
s = void 0;
|
|
143
|
+
}).finally(() => {
|
|
144
|
+
});
|
|
232
145
|
}
|
|
233
|
-
renderTask = renderTextLayer({
|
|
234
|
-
textContent: textContent.value,
|
|
235
|
-
container: el,
|
|
236
|
-
viewport: vp,
|
|
237
|
-
enhanceTextSelection: true
|
|
238
|
-
});
|
|
239
|
-
renderTask.promise.then(() => {
|
|
240
|
-
renderTask = void 0;
|
|
241
|
-
}).catch(() => {
|
|
242
|
-
renderTask = void 0;
|
|
243
|
-
}).finally(() => {
|
|
244
|
-
});
|
|
245
146
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
class: "pdf-text-layer"
|
|
254
|
-
}, null, 512);
|
|
255
|
-
};
|
|
147
|
+
return L(() => {
|
|
148
|
+
m();
|
|
149
|
+
}), (d, c) => (T(), $("div", {
|
|
150
|
+
ref_key: "rootEl",
|
|
151
|
+
ref: n,
|
|
152
|
+
class: "pdf-text-layer"
|
|
153
|
+
}, null, 512));
|
|
256
154
|
}
|
|
257
155
|
});
|
|
258
|
-
|
|
259
|
-
const _hoisted_1 = { class: "pdf-page-layout" };
|
|
260
|
-
const _hoisted_2 = { class: "pdf-page-overlay" };
|
|
261
|
-
const _hoisted_3 = {
|
|
156
|
+
const st = { class: "pdf-page-layout" }, ut = { class: "pdf-page-overlay" }, ct = {
|
|
262
157
|
key: 0,
|
|
263
158
|
class: "pdf-page-number"
|
|
264
|
-
}
|
|
265
|
-
|
|
159
|
+
}, dt = /* @__PURE__ */ I({
|
|
160
|
+
__name: "PdfPage",
|
|
266
161
|
props: {
|
|
267
162
|
zoom: null,
|
|
268
163
|
zoomType: null,
|
|
@@ -273,126 +168,84 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
273
168
|
observer: null
|
|
274
169
|
},
|
|
275
170
|
emits: ["update:zoom"],
|
|
276
|
-
setup(
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
switch (props.zoomType) {
|
|
290
|
-
case ZoomType.Auto:
|
|
291
|
-
wLimit = Math.min(vpWidth, maxAutoWidth) - 40;
|
|
292
|
-
newZoom = wLimit / pageWidth;
|
|
293
|
-
return baseScale * newZoom;
|
|
294
|
-
case ZoomType.WidthFit:
|
|
295
|
-
wLimit = vpWidth - 40;
|
|
296
|
-
newZoom = wLimit / pageWidth;
|
|
297
|
-
return baseScale * newZoom;
|
|
298
|
-
case ZoomType.PageFit:
|
|
299
|
-
if (vpWidth > vpHeight) {
|
|
300
|
-
newZoom = vpHeight / pageHeight;
|
|
301
|
-
return baseScale * newZoom;
|
|
302
|
-
} else {
|
|
303
|
-
wLimit = vpWidth - 40;
|
|
304
|
-
newZoom = wLimit / pageWidth;
|
|
305
|
-
return baseScale * newZoom;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return baseScale * props.zoom;
|
|
309
|
-
});
|
|
310
|
-
const displayScale = computed(() => {
|
|
311
|
-
return pdfScale.value * ((window == null ? void 0 : window.devicePixelRatio) || 1);
|
|
312
|
-
});
|
|
313
|
-
const pdfViewport = computed(() => {
|
|
314
|
-
return props.page.getViewport({ scale: pdfScale.value });
|
|
315
|
-
});
|
|
316
|
-
const displayViewport = computed(() => {
|
|
317
|
-
return props.page.getViewport({ scale: displayScale.value });
|
|
318
|
-
});
|
|
319
|
-
watch(pdfScale, (newScale) => {
|
|
320
|
-
const newZoom = newScale / baseScale;
|
|
321
|
-
const delta = Math.abs(newZoom - props.zoom);
|
|
322
|
-
if (delta > 0.05) {
|
|
323
|
-
emits("update:zoom", newZoom);
|
|
171
|
+
setup(e, { expose: i, emit: l }) {
|
|
172
|
+
const n = e, s = _(), m = _(), d = _(!1), c = 1100;
|
|
173
|
+
i({ rootEl: m, inViewport: d });
|
|
174
|
+
const u = 96 / 72, g = C(() => {
|
|
175
|
+
const { width: o, height: f } = n.page.getViewport({ scale: u }), { width: p, height: y } = n.viewport;
|
|
176
|
+
let w = 0, b = 1;
|
|
177
|
+
switch (n.zoomType) {
|
|
178
|
+
case S.Auto:
|
|
179
|
+
return w = Math.min(p, c) - 40, b = w / o, u * b;
|
|
180
|
+
case S.WidthFit:
|
|
181
|
+
return w = p - 40, b = w / o, u * b;
|
|
182
|
+
case S.PageFit:
|
|
183
|
+
return p > y ? (b = y / f, u * b) : (w = p - 40, b = w / o, u * b);
|
|
324
184
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
185
|
+
return u * n.zoom;
|
|
186
|
+
}), x = C(() => g.value * ((window == null ? void 0 : window.devicePixelRatio) || 1)), h = C(() => n.page.getViewport({ scale: g.value })), t = C(() => n.page.getViewport({ scale: x.value }));
|
|
187
|
+
P(g, (o) => {
|
|
188
|
+
const f = o / u;
|
|
189
|
+
Math.abs(f - n.zoom) > 0.05 && l("update:zoom", f);
|
|
190
|
+
}, { immediate: !0 });
|
|
191
|
+
let a;
|
|
192
|
+
function r() {
|
|
193
|
+
if (!n.page || !s.value)
|
|
329
194
|
return;
|
|
330
|
-
const page =
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
canvasEl.width = Math.ceil(dispVP.width);
|
|
335
|
-
canvasEl.height = Math.ceil(dispVP.height);
|
|
336
|
-
canvasEl.style.width = Math.floor(pdfVP.width) + "px";
|
|
337
|
-
canvasEl.style.height = Math.floor(pdfVP.height) + "px";
|
|
338
|
-
const context = canvasEl.getContext("2d");
|
|
339
|
-
if (!context || !inViewport.value)
|
|
195
|
+
const o = n.page, f = h.value, p = t.value, y = s.value;
|
|
196
|
+
y.width = Math.ceil(p.width), y.height = Math.ceil(p.height), y.style.width = Math.floor(f.width) + "px", y.style.height = Math.floor(f.height) + "px";
|
|
197
|
+
const w = y.getContext("2d");
|
|
198
|
+
if (!w || !d.value)
|
|
340
199
|
return;
|
|
341
|
-
if (
|
|
342
|
-
|
|
200
|
+
if (a) {
|
|
201
|
+
a.cancel();
|
|
343
202
|
return;
|
|
344
203
|
}
|
|
345
|
-
console.debug(`rendering page ${
|
|
346
|
-
const
|
|
347
|
-
canvasContext:
|
|
348
|
-
viewport:
|
|
204
|
+
console.debug(`rendering page ${o.pageNumber}`);
|
|
205
|
+
const b = {
|
|
206
|
+
canvasContext: w,
|
|
207
|
+
viewport: t.value
|
|
349
208
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
renderTask = void 0;
|
|
353
|
-
renderPage();
|
|
209
|
+
a = o.render(b), a.promise.then(() => a = void 0).catch(() => {
|
|
210
|
+
a = void 0, r();
|
|
354
211
|
});
|
|
355
212
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}, { immediate:
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
page: __props.page
|
|
386
|
-
}, null, 8, ["viewport", "page"])) : createCommentVNode("", true),
|
|
387
|
-
renderSlot(_ctx.$slots, "default", { displaySize: unref(displayViewport) })
|
|
388
|
-
])
|
|
389
|
-
]),
|
|
390
|
-
!__props.hideNumber ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(__props.page.pageNumber), 1)) : createCommentVNode("", true)
|
|
391
|
-
], 512);
|
|
392
|
-
};
|
|
213
|
+
return P(() => [n.page, x.value, d.value], () => {
|
|
214
|
+
r();
|
|
215
|
+
}, { immediate: !0 }), L(() => {
|
|
216
|
+
var o;
|
|
217
|
+
r(), m.value && ((o = n.observer) == null || o.observe(m.value));
|
|
218
|
+
}), D(() => {
|
|
219
|
+
var o;
|
|
220
|
+
m.value && ((o = n.observer) == null || o.unobserve(m.value));
|
|
221
|
+
}), (o, f) => (T(), $("div", {
|
|
222
|
+
ref_key: "rootEl",
|
|
223
|
+
ref: m,
|
|
224
|
+
class: "pdf-page"
|
|
225
|
+
}, [
|
|
226
|
+
W("div", st, [
|
|
227
|
+
W("canvas", {
|
|
228
|
+
ref_key: "canvas",
|
|
229
|
+
ref: s
|
|
230
|
+
}, null, 512),
|
|
231
|
+
W("div", ut, [
|
|
232
|
+
e.hideText ? F("", !0) : (T(), G(lt, {
|
|
233
|
+
key: 0,
|
|
234
|
+
viewport: k(t),
|
|
235
|
+
page: e.page
|
|
236
|
+
}, null, 8, ["viewport", "page"])),
|
|
237
|
+
j(o.$slots, "default", { displaySize: k(t) })
|
|
238
|
+
])
|
|
239
|
+
]),
|
|
240
|
+
e.hideNumber ? F("", !0) : (T(), $("div", ct, J(e.page.pageNumber), 1))
|
|
241
|
+
], 512));
|
|
393
242
|
}
|
|
394
243
|
});
|
|
395
|
-
const
|
|
244
|
+
const ft = {
|
|
245
|
+
key: 0,
|
|
246
|
+
class: "pdf-progress"
|
|
247
|
+
}, mt = /* @__PURE__ */ I({
|
|
248
|
+
__name: "PdfDocument",
|
|
396
249
|
props: {
|
|
397
250
|
hideText: { type: Boolean },
|
|
398
251
|
hideNumber: { type: Boolean },
|
|
@@ -402,97 +255,87 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
402
255
|
src: null
|
|
403
256
|
},
|
|
404
257
|
emits: ["error", "update:zoom"],
|
|
405
|
-
setup(
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const pageComps = ref([]);
|
|
412
|
-
function setPageComp(component) {
|
|
413
|
-
pageComps.value.push(component);
|
|
414
|
-
if (pageComps.value.length == 1)
|
|
415
|
-
component.inViewport = true;
|
|
258
|
+
setup(e, { emit: i }) {
|
|
259
|
+
const l = e, n = B(), s = B([]), m = B(), d = _();
|
|
260
|
+
let c = [];
|
|
261
|
+
const u = _(!1), g = _(0);
|
|
262
|
+
function x(t) {
|
|
263
|
+
c.push(t), c.length == 1 && (t.inViewport = !0);
|
|
416
264
|
}
|
|
417
|
-
function
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (doc) {
|
|
422
|
-
doc.destroy();
|
|
423
|
-
pdfDoc.value = void 0;
|
|
424
|
-
}
|
|
265
|
+
function h() {
|
|
266
|
+
s.value.forEach((a) => a.cleanup()), s.value = [];
|
|
267
|
+
const t = n.value;
|
|
268
|
+
t && (t.destroy(), n.value = void 0), c = [];
|
|
425
269
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (!src)
|
|
270
|
+
return P(() => l.src, (t) => {
|
|
271
|
+
if (h(), !t)
|
|
429
272
|
return;
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
273
|
+
const a = le(t);
|
|
274
|
+
u.value = !0, a.onProgress = (r) => {
|
|
275
|
+
r.total && (g.value = r.loaded / r.total);
|
|
276
|
+
}, a.promise.then((r) => {
|
|
277
|
+
n.value = r;
|
|
278
|
+
const o = [];
|
|
279
|
+
for (let f = 1; f <= r.numPages; f++)
|
|
280
|
+
o.push(r.getPage(f));
|
|
281
|
+
Promise.all(o).then((f) => {
|
|
282
|
+
r === n.value && (s.value = f);
|
|
439
283
|
});
|
|
440
|
-
}).catch((
|
|
441
|
-
|
|
284
|
+
}).catch((r) => {
|
|
285
|
+
i("error", r);
|
|
286
|
+
}).finally(() => {
|
|
287
|
+
u.value = !1;
|
|
442
288
|
});
|
|
443
|
-
}, { immediate:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (foundComp) {
|
|
449
|
-
foundComp.inViewport = entry.isIntersecting;
|
|
450
|
-
}
|
|
289
|
+
}, { immediate: !0 }), L(() => {
|
|
290
|
+
m.value = new IntersectionObserver(re((t) => {
|
|
291
|
+
t.forEach((a) => {
|
|
292
|
+
const r = c.find((o) => (o == null ? void 0 : o.rootEl) === a.target);
|
|
293
|
+
r && (r.inViewport = a.isIntersecting);
|
|
451
294
|
});
|
|
452
295
|
}, 50), {
|
|
453
296
|
rootMargin: "0px"
|
|
454
297
|
});
|
|
455
|
-
})
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
],
|
|
491
|
-
|
|
298
|
+
}), D(() => {
|
|
299
|
+
var t;
|
|
300
|
+
h(), (t = m.value) == null || t.disconnect();
|
|
301
|
+
}), (t, a) => (T(), $("div", {
|
|
302
|
+
ref_key: "rootEl",
|
|
303
|
+
ref: d
|
|
304
|
+
}, [
|
|
305
|
+
j(t.$slots, "loading", {
|
|
306
|
+
src: l.src,
|
|
307
|
+
loading: u.value,
|
|
308
|
+
progress: g.value
|
|
309
|
+
}, () => [
|
|
310
|
+
u.value ? (T(), $("p", ft, "loading " + J(Math.ceil(100 * g.value)) + "%", 1)) : F("", !0)
|
|
311
|
+
]),
|
|
312
|
+
(T(!0), $(Q, null, Z(k(s), (r) => (T(), G(dt, {
|
|
313
|
+
ref_for: !0,
|
|
314
|
+
ref: x,
|
|
315
|
+
key: r.pageNumber,
|
|
316
|
+
page: r,
|
|
317
|
+
"hide-number": e.hideNumber,
|
|
318
|
+
"hide-text": e.hideText,
|
|
319
|
+
"zoom-type": e.zoomType,
|
|
320
|
+
zoom: e.zoom,
|
|
321
|
+
"onUpdate:zoom": a[0] || (a[0] = (o) => i("update:zoom", o)),
|
|
322
|
+
observer: k(m),
|
|
323
|
+
viewport: e.viewport
|
|
324
|
+
}, {
|
|
325
|
+
default: A(({ displaySize: o }) => [
|
|
326
|
+
j(t.$slots, "default", {
|
|
327
|
+
doc: k(n),
|
|
328
|
+
page: r,
|
|
329
|
+
displaySize: o
|
|
330
|
+
})
|
|
331
|
+
]),
|
|
332
|
+
_: 2
|
|
333
|
+
}, 1032, ["page", "hide-number", "hide-text", "zoom-type", "zoom", "observer", "viewport"]))), 128))
|
|
334
|
+
], 512));
|
|
492
335
|
}
|
|
493
336
|
});
|
|
494
|
-
|
|
495
|
-
|
|
337
|
+
const gt = /* @__PURE__ */ I({
|
|
338
|
+
__name: "PdfHost",
|
|
496
339
|
props: {
|
|
497
340
|
workerSrc: null,
|
|
498
341
|
sources: null,
|
|
@@ -502,110 +345,90 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
502
345
|
hideNumber: { type: Boolean }
|
|
503
346
|
},
|
|
504
347
|
emits: ["update:zoom", "update:zoomType"],
|
|
505
|
-
setup(
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}, { immediate: true });
|
|
516
|
-
function onMouseWheel(e) {
|
|
517
|
-
if (e.ctrlKey) {
|
|
518
|
-
e.preventDefault();
|
|
519
|
-
if (e.deltaY < 0) {
|
|
520
|
-
zoomIn();
|
|
521
|
-
} else {
|
|
522
|
-
zoomOut();
|
|
523
|
-
}
|
|
524
|
-
}
|
|
348
|
+
setup(e, { expose: i, emit: l }) {
|
|
349
|
+
const n = e, s = _();
|
|
350
|
+
i({
|
|
351
|
+
zoomIn: x,
|
|
352
|
+
zoomOut: h
|
|
353
|
+
}), P(() => n.workerSrc, (t) => {
|
|
354
|
+
t && (se.workerSrc = t);
|
|
355
|
+
}, { immediate: !0 });
|
|
356
|
+
function m(t) {
|
|
357
|
+
t.ctrlKey && (t.preventDefault(), t.deltaY < 0 ? x() : h());
|
|
525
358
|
}
|
|
526
|
-
function
|
|
527
|
-
|
|
528
|
-
if (e.key === "0" || e.which == 48) {
|
|
529
|
-
emits("update:zoomType", ZoomType.Auto);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
359
|
+
function d(t) {
|
|
360
|
+
t.ctrlKey && (t.key === "0" || t.which == 48) && l("update:zoomType", S.Auto);
|
|
532
361
|
}
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
height: root2.offsetHeight
|
|
540
|
-
};
|
|
541
|
-
}
|
|
362
|
+
const c = _({ width: 0, height: 0 }), u = re(() => {
|
|
363
|
+
const t = s.value;
|
|
364
|
+
t && (c.value = {
|
|
365
|
+
width: t.offsetWidth,
|
|
366
|
+
height: t.offsetHeight
|
|
367
|
+
});
|
|
542
368
|
}, 100);
|
|
543
|
-
function
|
|
544
|
-
const
|
|
545
|
-
return Number((
|
|
369
|
+
function g(t) {
|
|
370
|
+
const a = t % 0.25;
|
|
371
|
+
return Number((t - a).toFixed(2));
|
|
546
372
|
}
|
|
547
|
-
function
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
emits("update:zoomType", ZoomType.Custom);
|
|
373
|
+
function x() {
|
|
374
|
+
const t = g((n.zoom || 1) + 0.25);
|
|
375
|
+
l("update:zoom", Math.min(t, 2)), l("update:zoomType", S.Custom);
|
|
551
376
|
}
|
|
552
|
-
function
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
emits("update:zoomType", ZoomType.Custom);
|
|
377
|
+
function h() {
|
|
378
|
+
const t = g((n.zoom || 1) - 0.25);
|
|
379
|
+
l("update:zoom", Math.max(t, 0.25)), l("update:zoomType", S.Custom);
|
|
556
380
|
}
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
nextTick(() => {
|
|
564
|
-
root2.scrollTop = curTop * ratio;
|
|
565
|
-
root2.scrollLeft = curLeft * ratio;
|
|
381
|
+
return P(() => n.zoom, (t, a) => {
|
|
382
|
+
const r = s.value;
|
|
383
|
+
if (r && t && a) {
|
|
384
|
+
const o = r.scrollTop, f = r.scrollLeft, p = t / a;
|
|
385
|
+
ie(() => {
|
|
386
|
+
r.scrollTop = o * p, r.scrollLeft = f * p;
|
|
566
387
|
});
|
|
567
388
|
}
|
|
568
|
-
})
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
})
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
};
|
|
389
|
+
}), L(() => {
|
|
390
|
+
window.addEventListener("resize", u), u();
|
|
391
|
+
}), D(() => {
|
|
392
|
+
window.removeEventListener("resize", u);
|
|
393
|
+
}), (t, a) => (T(), $("div", {
|
|
394
|
+
ref_key: "rootEl",
|
|
395
|
+
ref: s,
|
|
396
|
+
onWheel: m,
|
|
397
|
+
onKeydown: d,
|
|
398
|
+
tabindex: "0",
|
|
399
|
+
class: "pdf-host"
|
|
400
|
+
}, [
|
|
401
|
+
(T(!0), $(Q, null, Z(e.sources, (r) => (T(), G(mt, {
|
|
402
|
+
viewport: c.value,
|
|
403
|
+
src: r,
|
|
404
|
+
"hide-number": !!e.hideNumber,
|
|
405
|
+
"hide-text": !!e.hideText,
|
|
406
|
+
"zoom-type": e.zoomType || k(S).Auto,
|
|
407
|
+
zoom: e.zoom || 1,
|
|
408
|
+
"onUpdate:zoom": a[0] || (a[0] = (o) => l("update:zoom", o))
|
|
409
|
+
}, {
|
|
410
|
+
loading: A(({ loading: o, progress: f }) => [
|
|
411
|
+
j(t.$slots, "loading", {
|
|
412
|
+
source: r,
|
|
413
|
+
loading: o,
|
|
414
|
+
progress: f
|
|
415
|
+
})
|
|
416
|
+
]),
|
|
417
|
+
default: A(({ doc: o, page: f, displaySize: p }) => [
|
|
418
|
+
j(t.$slots, "page", {
|
|
419
|
+
source: r,
|
|
420
|
+
doc: o,
|
|
421
|
+
page: f,
|
|
422
|
+
displaySize: p
|
|
423
|
+
})
|
|
424
|
+
]),
|
|
425
|
+
_: 2
|
|
426
|
+
}, 1032, ["viewport", "src", "hide-number", "hide-text", "zoom-type", "zoom"]))), 256)),
|
|
427
|
+
j(t.$slots, "default")
|
|
428
|
+
], 544));
|
|
609
429
|
}
|
|
610
430
|
});
|
|
611
|
-
export {
|
|
431
|
+
export {
|
|
432
|
+
gt as PdfHost,
|
|
433
|
+
S as ZoomType
|
|
434
|
+
};
|