@component-hook/pdf-canvas 1.2.2-alpha.1 → 1.2.2-alpha.2
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/react/pdf-canvas.es.js +56 -60
- package/dist/react/pdf-canvas.umd.js +38 -38
- package/dist/vue/pdf-canvas.es.js +230 -234
- package/dist/vue/pdf-canvas.umd.js +45 -45
- package/package.json +1 -1
|
@@ -22230,26 +22230,18 @@ Y.setLayerDimensions;
|
|
|
22230
22230
|
Y.shadow;
|
|
22231
22231
|
Y.stopEvent;
|
|
22232
22232
|
var Vg = Y.version;
|
|
22233
|
-
function Wg(a) {
|
|
22234
|
-
return new Worker(
|
|
22235
|
-
"" + new URL("assets/pdfjs.worker-DawqtvLM.js", import.meta.url).href,
|
|
22236
|
-
{
|
|
22237
|
-
name: a?.name
|
|
22238
|
-
}
|
|
22239
|
-
);
|
|
22240
|
-
}
|
|
22241
22233
|
let Ja = null;
|
|
22242
|
-
function
|
|
22234
|
+
function Wg() {
|
|
22243
22235
|
const a = document.createElement("div");
|
|
22244
22236
|
a.style.width = "1in", document.body.append(a);
|
|
22245
22237
|
const t = a.offsetWidth;
|
|
22246
22238
|
return a.remove(), t;
|
|
22247
22239
|
}
|
|
22248
|
-
function
|
|
22249
|
-
const a = Ja ??
|
|
22240
|
+
function Xg() {
|
|
22241
|
+
const a = Ja ?? Wg();
|
|
22250
22242
|
return Ja = a, a / 72;
|
|
22251
22243
|
}
|
|
22252
|
-
function
|
|
22244
|
+
function Ug(a, t = 500) {
|
|
22253
22245
|
if (typeof a != "function") throw new TypeError("The first argument is not a function.");
|
|
22254
22246
|
let e = null;
|
|
22255
22247
|
return function(...s) {
|
|
@@ -22258,15 +22250,15 @@ function Yg(a, t = 500) {
|
|
|
22258
22250
|
}, t);
|
|
22259
22251
|
};
|
|
22260
22252
|
}
|
|
22261
|
-
function
|
|
22253
|
+
function Yg(a) {
|
|
22262
22254
|
return new Promise((t, e) => {
|
|
22263
22255
|
const s = new FileReader();
|
|
22264
22256
|
s.addEventListener("load", () => t(s.result)), s.addEventListener("error", e), s.readAsDataURL(a);
|
|
22265
22257
|
});
|
|
22266
22258
|
}
|
|
22267
22259
|
Yl() || (zg.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${Vg}/pdf.worker.min.mjs`);
|
|
22268
|
-
async function
|
|
22269
|
-
const t = "data:application/pdf;base64,", e = await
|
|
22260
|
+
async function $g(a) {
|
|
22261
|
+
const t = "data:application/pdf;base64,", e = await Yg(a);
|
|
22270
22262
|
if (typeof e == "string")
|
|
22271
22263
|
return globalThis.atob(e.slice(t.length));
|
|
22272
22264
|
}
|
|
@@ -22277,10 +22269,14 @@ function Yl() {
|
|
|
22277
22269
|
return !1;
|
|
22278
22270
|
}
|
|
22279
22271
|
}
|
|
22280
|
-
async function
|
|
22281
|
-
const n =
|
|
22272
|
+
async function qg({ page: a, PDFBase64: t, scale: e, password: s }, i) {
|
|
22273
|
+
const n = Xg() / window.devicePixelRatio;
|
|
22282
22274
|
if (Yl()) {
|
|
22283
|
-
const r = new
|
|
22275
|
+
const r = new Worker(new URL(
|
|
22276
|
+
/* @vite-ignore */
|
|
22277
|
+
"" + new URL("assets/pdfjs.worker-DawqtvLM.js", import.meta.url).href,
|
|
22278
|
+
import.meta.url
|
|
22279
|
+
), { type: "module" });
|
|
22284
22280
|
return r.postMessage({ data: t, password: s, id: i, page: a, units: n, scale: e }), await new Promise((h) => {
|
|
22285
22281
|
r.addEventListener("message", ({ data: l }) => {
|
|
22286
22282
|
if (l.status === "success") {
|
|
@@ -22305,11 +22301,11 @@ async function Kg({ page: a, PDFBase64: t, scale: e, password: s }, i) {
|
|
|
22305
22301
|
}
|
|
22306
22302
|
}
|
|
22307
22303
|
const jt = /* @__PURE__ */ new Map();
|
|
22308
|
-
function
|
|
22304
|
+
function Kg(a) {
|
|
22309
22305
|
const t = new Pr(a);
|
|
22310
22306
|
return jt.set(a, t), t;
|
|
22311
22307
|
}
|
|
22312
|
-
function
|
|
22308
|
+
function Jg(a, t) {
|
|
22313
22309
|
const e = Date.now();
|
|
22314
22310
|
return {
|
|
22315
22311
|
PDFId: `${a.name}-${e}`,
|
|
@@ -22318,19 +22314,19 @@ function Zg(a, t) {
|
|
|
22318
22314
|
PDFBase64: t
|
|
22319
22315
|
};
|
|
22320
22316
|
}
|
|
22321
|
-
async function
|
|
22317
|
+
async function Zg({ src: a }, t, e) {
|
|
22322
22318
|
if (!a || !e) return null;
|
|
22323
22319
|
const { objects: s, options: i } = await kd(a), n = s.filter((o) => o !== null), r = Xu.groupSVGElements(n, i);
|
|
22324
22320
|
return n.forEach((o) => {
|
|
22325
22321
|
o.stroke = e;
|
|
22326
22322
|
}), r.hoverCursor = "pointer", r.stroke = `${e}-${t}`, r;
|
|
22327
22323
|
}
|
|
22328
|
-
function
|
|
22324
|
+
function Qg(a, t) {
|
|
22329
22325
|
if (!jt.get(a)) return;
|
|
22330
|
-
const s = 1 / 3, i =
|
|
22326
|
+
const s = 1 / 3, i = op(t, s);
|
|
22331
22327
|
ql(a, i, s);
|
|
22332
22328
|
}
|
|
22333
|
-
async function
|
|
22329
|
+
async function tp(a, t) {
|
|
22334
22330
|
const e = await Bd(a), s = Date.now(), n = {
|
|
22335
22331
|
PDFId: `${a.name}${s}`,
|
|
22336
22332
|
name: a.name.replace(/.png|.jpg|.jpeg/, ""),
|
|
@@ -22348,30 +22344,30 @@ function ql(a, t, e) {
|
|
|
22348
22344
|
const s = jt.get(a);
|
|
22349
22345
|
s && (s.setWidth(t.width * e), s.setHeight(t.height * e), s.backgroundImage = t, s.renderAll());
|
|
22350
22346
|
}
|
|
22351
|
-
function
|
|
22347
|
+
function ep(a, t) {
|
|
22352
22348
|
if (!t) return;
|
|
22353
22349
|
const { oCoords: e } = a;
|
|
22354
22350
|
if (!e) return;
|
|
22355
22351
|
const { x: s, y: i } = e.tl.touchCorner.tl, { height: n, width: r, scaleY: o, scaleX: h } = t;
|
|
22356
22352
|
t.top = i - n * o / 2, t.left = s - r * h / 2, t.setCoords();
|
|
22357
22353
|
}
|
|
22358
|
-
function
|
|
22359
|
-
!e || !a || (e.scale(1 / t),
|
|
22354
|
+
function sp(a, t, e) {
|
|
22355
|
+
!e || !a || (e.scale(1 / t), ep(a, e));
|
|
22360
22356
|
}
|
|
22361
|
-
function
|
|
22357
|
+
function ip(a, t) {
|
|
22362
22358
|
if (!a) return;
|
|
22363
22359
|
const e = a._cornerSize || 6;
|
|
22364
22360
|
a.borderScaleFactor = 1 / t, a.cornerSize = e * (1 / t), a.touchCornerSize = e * 4 * (1 / t), a.setCoords();
|
|
22365
22361
|
}
|
|
22366
|
-
function
|
|
22362
|
+
function np(a) {
|
|
22367
22363
|
const t = jt.get(a);
|
|
22368
22364
|
t && (t.discardActiveObject(), t.renderAll());
|
|
22369
22365
|
}
|
|
22370
|
-
function
|
|
22366
|
+
function rp(a) {
|
|
22371
22367
|
const t = jt.get(a);
|
|
22372
22368
|
t && (t.clear(), jt.delete(a));
|
|
22373
22369
|
}
|
|
22374
|
-
function
|
|
22370
|
+
function op(a, t) {
|
|
22375
22371
|
return new Pt(a, { scaleX: t, scaleY: t });
|
|
22376
22372
|
}
|
|
22377
22373
|
function zr(a, t) {
|
|
@@ -22379,27 +22375,27 @@ function zr(a, t) {
|
|
|
22379
22375
|
const { left: e, top: s, scaleX: i, scaleY: n, width: r, height: o } = a, h = t.x * r * i, l = t.y * o * n;
|
|
22380
22376
|
a.set({ left: e - h, top: s - l });
|
|
22381
22377
|
}
|
|
22382
|
-
function
|
|
22378
|
+
function ap(a, t, e) {
|
|
22383
22379
|
const s = a.type;
|
|
22384
22380
|
return {
|
|
22385
|
-
"application/pdf":
|
|
22381
|
+
"application/pdf": hp,
|
|
22386
22382
|
"image/png": Za,
|
|
22387
22383
|
"image/jpeg": Za
|
|
22388
22384
|
}[s]?.(a, t, e) ?? Promise.reject(new Error(`Unsupported ${s} file type.`));
|
|
22389
22385
|
}
|
|
22390
|
-
async function
|
|
22391
|
-
const s = await
|
|
22386
|
+
async function hp(a, t, e) {
|
|
22387
|
+
const s = await $g(a);
|
|
22392
22388
|
if (!s) return;
|
|
22393
|
-
const i =
|
|
22389
|
+
const i = Jg(a, s), n = await Kl({ page: 1, PDFBase64: s, scale: 0.8, password: t }, e);
|
|
22394
22390
|
return { ...i, pages: n };
|
|
22395
22391
|
}
|
|
22396
22392
|
function Kl(a, t) {
|
|
22397
|
-
return
|
|
22393
|
+
return qg(a, t).then(({ canvas: e, pages: s }) => (e && t && Qg(t, e), s));
|
|
22398
22394
|
}
|
|
22399
22395
|
async function Za(a, t, e) {
|
|
22400
|
-
return await
|
|
22396
|
+
return await tp(a, e);
|
|
22401
22397
|
}
|
|
22402
|
-
function
|
|
22398
|
+
function lp(a, t) {
|
|
22403
22399
|
const e = jt.get(a);
|
|
22404
22400
|
if (!e) return;
|
|
22405
22401
|
const s = e.getActiveObject();
|
|
@@ -22407,7 +22403,7 @@ function cp(a, t) {
|
|
|
22407
22403
|
i.set(t);
|
|
22408
22404
|
}) : s.set(t), e.renderAll());
|
|
22409
22405
|
}
|
|
22410
|
-
async function
|
|
22406
|
+
async function cp(a, t) {
|
|
22411
22407
|
const e = jt.get(a);
|
|
22412
22408
|
if (!e) return;
|
|
22413
22409
|
const s = e?.getActiveObject();
|
|
@@ -22417,7 +22413,7 @@ async function up(a, t) {
|
|
|
22417
22413
|
e.add(n), t(e, n);
|
|
22418
22414
|
}) : (e.add(i), t(e, i)), zr(i, { x: -0.1, y: -0.1 }), e.setActiveObject(i);
|
|
22419
22415
|
}
|
|
22420
|
-
function
|
|
22416
|
+
function up(a) {
|
|
22421
22417
|
const t = jt.get(a);
|
|
22422
22418
|
if (!t) return;
|
|
22423
22419
|
const e = t.getActiveObject();
|
|
@@ -22425,7 +22421,7 @@ function dp(a) {
|
|
|
22425
22421
|
t.remove(s);
|
|
22426
22422
|
}), t.discardActiveObject()) : t.remove(e));
|
|
22427
22423
|
}
|
|
22428
|
-
function
|
|
22424
|
+
function dp(a) {
|
|
22429
22425
|
const {
|
|
22430
22426
|
id: t = "",
|
|
22431
22427
|
selectionOptions: e,
|
|
@@ -22437,7 +22433,7 @@ function fp(a) {
|
|
|
22437
22433
|
} = a || {}, h = ws(null), l = ws(null), c = ws(1), u = ws({ ...hc });
|
|
22438
22434
|
function d() {
|
|
22439
22435
|
if (!t || jt.has(t)) return;
|
|
22440
|
-
const O =
|
|
22436
|
+
const O = Kg(t);
|
|
22441
22437
|
return O.on("selection:created", (D) => {
|
|
22442
22438
|
if (r?.(D), D.selected.length <= 1) return;
|
|
22443
22439
|
const z = O.getActiveObject();
|
|
@@ -22447,7 +22443,7 @@ function fp(a) {
|
|
|
22447
22443
|
}), s && O.on("mouse:down", s), i && O.on("mouse:move", i), n && O.on("mouse:up", n), O;
|
|
22448
22444
|
}
|
|
22449
22445
|
function f(O, D) {
|
|
22450
|
-
return
|
|
22446
|
+
return ap(O, D, t);
|
|
22451
22447
|
}
|
|
22452
22448
|
function g(O) {
|
|
22453
22449
|
return Kl(O, t);
|
|
@@ -22480,7 +22476,7 @@ function fp(a) {
|
|
|
22480
22476
|
uuid: M = Date.now()
|
|
22481
22477
|
}) {
|
|
22482
22478
|
if (O.getActiveObjects().length > 1 || h.current?.stroke === `${z}-${M}`) return;
|
|
22483
|
-
const W = await
|
|
22479
|
+
const W = await Zg(u.current, M, z);
|
|
22484
22480
|
T(O), h.current = W, l.current = D, _(O, D, M), S(c.current, !0), W && O.add(W);
|
|
22485
22481
|
}
|
|
22486
22482
|
function _(O, D, z) {
|
|
@@ -22499,7 +22495,7 @@ function fp(a) {
|
|
|
22499
22495
|
}
|
|
22500
22496
|
function S(O, D = !1) {
|
|
22501
22497
|
const z = jt.get(t);
|
|
22502
|
-
c.current = O, z && (
|
|
22498
|
+
c.current = O, z && (ip(l.current, O), sp(l.current, O, h.current), !D && z.renderAll());
|
|
22503
22499
|
}
|
|
22504
22500
|
function A(O) {
|
|
22505
22501
|
if (!O) return;
|
|
@@ -22511,19 +22507,19 @@ function fp(a) {
|
|
|
22511
22507
|
l.current = null, h.current && (O.remove(h.current), h.current = null);
|
|
22512
22508
|
}
|
|
22513
22509
|
function k() {
|
|
22514
|
-
|
|
22510
|
+
np(t);
|
|
22515
22511
|
}
|
|
22516
22512
|
function P() {
|
|
22517
|
-
|
|
22513
|
+
rp(t);
|
|
22518
22514
|
}
|
|
22519
22515
|
function j(O) {
|
|
22520
|
-
|
|
22516
|
+
lp(t, O);
|
|
22521
22517
|
}
|
|
22522
22518
|
function F() {
|
|
22523
|
-
return
|
|
22519
|
+
return cp(t, v);
|
|
22524
22520
|
}
|
|
22525
22521
|
function I() {
|
|
22526
|
-
|
|
22522
|
+
up(t);
|
|
22527
22523
|
}
|
|
22528
22524
|
return {
|
|
22529
22525
|
createCanvas: d,
|
|
@@ -22541,14 +22537,14 @@ function fp(a) {
|
|
|
22541
22537
|
deleteActiveFabric: I
|
|
22542
22538
|
};
|
|
22543
22539
|
}
|
|
22544
|
-
function
|
|
22545
|
-
const t = ws(0), e =
|
|
22540
|
+
function fp(a) {
|
|
22541
|
+
const t = ws(0), e = Ug(() => {
|
|
22546
22542
|
t.current !== window.innerWidth && (t.current = window.innerWidth, a());
|
|
22547
22543
|
});
|
|
22548
22544
|
Js(() => (window.addEventListener("resize", e), () => window.removeEventListener("resize", e)), []);
|
|
22549
22545
|
}
|
|
22550
|
-
const
|
|
22551
|
-
function
|
|
22546
|
+
const bp = Ql(gp);
|
|
22547
|
+
function gp({
|
|
22552
22548
|
file: a,
|
|
22553
22549
|
page: t = 1,
|
|
22554
22550
|
canvasId: e = "PDF-canvas",
|
|
@@ -22584,7 +22580,7 @@ function pp({
|
|
|
22584
22580
|
setCloseSvgOptions: ot,
|
|
22585
22581
|
copyActiveFabric: lt,
|
|
22586
22582
|
deleteActiveFabric: E
|
|
22587
|
-
} =
|
|
22583
|
+
} = dp({
|
|
22588
22584
|
id: T,
|
|
22589
22585
|
selectionOptions: P,
|
|
22590
22586
|
pointerDown: b,
|
|
@@ -22593,7 +22589,7 @@ function pp({
|
|
|
22593
22589
|
selectionCreated: y,
|
|
22594
22590
|
selectionCleared: _
|
|
22595
22591
|
});
|
|
22596
|
-
|
|
22592
|
+
fp(st);
|
|
22597
22593
|
async function H() {
|
|
22598
22594
|
globalThis.requestAnimationFrame(async () => {
|
|
22599
22595
|
if (j(), a.PDFBase64.startsWith("data:image") || a.canvas) {
|
|
@@ -22658,7 +22654,7 @@ function pp({
|
|
|
22658
22654
|
);
|
|
22659
22655
|
}
|
|
22660
22656
|
export {
|
|
22661
|
-
|
|
22662
|
-
|
|
22663
|
-
|
|
22657
|
+
bp as default,
|
|
22658
|
+
ap as loadFile,
|
|
22659
|
+
dp as useFabric
|
|
22664
22660
|
};
|